@novu/js 3.11.1 → 3.11.2-nightly.20251224.97b30e30dd
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/cjs/{chunk-MKYWGA37.js → chunk-AFLPFCXM.js} +1069 -294
- package/dist/cjs/{chunk-WFVHYVDM.js → chunk-CDGREQFE.js} +6 -0
- package/dist/cjs/index.d.ts +4 -3
- package/dist/cjs/index.js +26 -14
- package/dist/cjs/internal/index.d.ts +8 -2
- package/dist/cjs/internal/index.js +9 -5
- package/dist/{esm/novu-3CfttQ8e.d.mts → cjs/novu-DxuaDf-Z.d.ts} +28 -1
- package/dist/{esm/novu-event-emitter-C7GZ7-r1.d.mts → cjs/novu-event-emitter-BOA_6GfJ.d.ts} +195 -1
- package/dist/cjs/themes/index.d.ts +11 -5
- package/dist/cjs/themes/index.js +17 -1
- package/dist/cjs/types-Buzm23uF.d.ts +836 -0
- package/dist/cjs/ui/index.d.ts +74 -8
- package/dist/cjs/ui/index.js +1836 -261
- package/dist/esm/{chunk-76A4RQYD.mjs → chunk-GDLXUD4E.mjs} +1038 -265
- package/dist/esm/{chunk-GY4JXBST.mjs → chunk-SWKDFXVR.mjs} +6 -1
- package/dist/esm/index.d.mts +4 -3
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/internal/index.d.mts +8 -2
- package/dist/esm/internal/index.mjs +1 -1
- package/dist/{cjs/novu-CKWESYFZ.d.ts → esm/novu-DY8vwRGE.d.mts} +28 -1
- package/dist/{cjs/novu-event-emitter-C7GZ7-r1.d.ts → esm/novu-event-emitter-BOA_6GfJ.d.mts} +195 -1
- package/dist/esm/themes/index.d.mts +11 -5
- package/dist/esm/themes/index.mjs +16 -2
- package/dist/esm/types-xBjzv9ok.d.mts +836 -0
- package/dist/esm/ui/index.d.mts +74 -8
- package/dist/esm/ui/index.mjs +1833 -257
- package/dist/index.css +1 -1
- package/dist/novu.min.js +12 -12
- package/dist/novu.min.js.gz +0 -0
- package/package.json +2 -1
- package/dist/cjs/types-CeLsxWJg.d.ts +0 -537
- package/dist/esm/types-4YuozpWu.d.mts +0 -537
package/dist/novu.min.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";(()=>{var ca=Object.create;var _i=Object.defineProperty,la=Object.defineProperties,ha=Object.getOwnPropertyDescriptor,fa=Object.getOwnPropertyDescriptors,ua=Object.getOwnPropertyNames,vi=Object.getOwnPropertySymbols,da=Object.getPrototypeOf,wr=Object.prototype.hasOwnProperty,Tn=Object.prototype.propertyIsEnumerable;var On=i=>{throw TypeError(i)},In=Math.pow,xr=(i,e,t)=>e in i?_i(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,E=(i,e)=>{for(var t in e||(e={}))wr.call(e,t)&&xr(i,t,e[t]);if(vi)for(var t of vi(e))Tn.call(e,t)&&xr(i,t,e[t]);return i},A=(i,e)=>la(i,fa(e));var R=(i=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(i,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):i)(function(i){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var Cr=(i,e)=>{var t={};for(var r in i)wr.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&vi)for(var r of vi(i))e.indexOf(r)<0&&Tn.call(i,r)&&(t[r]=i[r]);return t};var F=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),pa=(i,e)=>{for(var t in e)_i(i,t,{get:e[t],enumerable:!0})},ma=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ua(e))!wr.call(i,n)&&n!==t&&_i(i,n,{get:()=>e[n],enumerable:!(r=ha(e,n))||r.enumerable});return i};var Q=(i,e,t)=>(t=i!=null?ca(da(i)):{},ma(e||!i||!i.__esModule?_i(t,"default",{value:i,enumerable:!0}):t,i));var I=(i,e,t)=>xr(i,typeof e!="symbol"?e+"":e,t),Nr=(i,e,t)=>e.has(i)||On("Cannot "+t);var a=(i,e,t)=>(Nr(i,e,"read from private field"),t?t.call(i):e.get(i)),_=(i,e,t)=>e.has(i)?On("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),S=(i,e,t,r)=>(Nr(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ue=(i,e,t)=>(Nr(i,e,"access private method"),t);var m=(i,e,t)=>new Promise((r,n)=>{var s=l=>{try{c(t.next(l))}catch(u){n(u)}},o=l=>{try{c(t.throw(l))}catch(u){n(u)}},c=l=>l.done?r(l.value):Promise.resolve(l.value).then(s,o);c((t=t.apply(i,e)).next())});var qr=F((pu,as)=>{"use strict";var bt=1e3,xt=bt*60,wt=xt*60,at=wt*24,qa=at*7,Wa=at*365.25;as.exports=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return za(i);if(t==="number"&&isFinite(i))return e.long?Va(i):$a(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function za(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*Wa;case"weeks":case"week":case"w":return t*qa;case"days":case"day":case"d":return t*at;case"hours":case"hour":case"hrs":case"hr":case"h":return t*wt;case"minutes":case"minute":case"mins":case"min":case"m":return t*xt;case"seconds":case"second":case"secs":case"sec":case"s":return t*bt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function $a(i){var e=Math.abs(i);return e>=at?Math.round(i/at)+"d":e>=wt?Math.round(i/wt)+"h":e>=xt?Math.round(i/xt)+"m":e>=bt?Math.round(i/bt)+"s":i+"ms"}function Va(i){var e=Math.abs(i);return e>=at?Ji(i,e,at,"day"):e>=wt?Ji(i,e,wt,"hour"):e>=xt?Ji(i,e,xt,"minute"):e>=bt?Ji(i,e,bt,"second"):i+" ms"}function Ji(i,e,t,r){var n=e>=t*1.5;return Math.round(i/t)+" "+r+(n?"s":"")}});var Wr=F((mu,cs)=>{"use strict";function Ha(i){t.debug=t,t.default=t,t.coerce=l,t.disable=s,t.enable=n,t.enabled=o,t.humanize=qr(),t.destroy=u,Object.keys(i).forEach(h=>{t[h]=i[h]}),t.names=[],t.skips=[],t.formatters={};function e(h){let f=0;for(let d=0;d<h.length;d++)f=(f<<5)-f+h.charCodeAt(d),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(h){let f,d=null,p,x;function g(...v){if(!g.enabled)return;let T=g,w=Number(new Date),y=w-(f||w);T.diff=y,T.prev=f,T.curr=w,f=w,v[0]=t.coerce(v[0]),typeof v[0]!="string"&&v.unshift("%O");let b=0;v[0]=v[0].replace(/%([a-zA-Z%])/g,(N,P)=>{if(N==="%%")return"%";b++;let q=t.formatters[P];if(typeof q=="function"){let ne=v[b];N=q.call(T,ne),v.splice(b,1),b--}return N}),t.formatArgs.call(T,v),(T.log||t.log).apply(T,v)}return g.namespace=h,g.useColors=t.useColors(),g.color=t.selectColor(h),g.extend=r,g.destroy=t.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(p!==t.namespaces&&(p=t.namespaces,x=t.enabled(h)),x),set:v=>{d=v}}),typeof t.init=="function"&&t.init(g),g}function r(h,f){let d=t(this.namespace+(typeof f=="undefined"?":":f)+h);return d.log=this.log,d}function n(h){t.save(h),t.namespaces=h,t.names=[],t.skips=[];let f,d=(typeof h=="string"?h:"").split(/[\s,]+/),p=d.length;for(f=0;f<p;f++)d[f]&&(h=d[f].replace(/\*/g,".*?"),h[0]==="-"?t.skips.push(new RegExp("^"+h.slice(1)+"$")):t.names.push(new RegExp("^"+h+"$")))}function s(){let h=[...t.names.map(c),...t.skips.map(c).map(f=>"-"+f)].join(",");return t.enable(""),h}function o(h){if(h[h.length-1]==="*")return!0;let f,d;for(f=0,d=t.skips.length;f<d;f++)if(t.skips[f].test(h))return!1;for(f=0,d=t.names.length;f<d;f++)if(t.names[f].test(h))return!0;return!1}function c(h){return h.toString().substring(2,h.toString().length-2).replace(/\.\*\?$/,"*")}function l(h){return h instanceof Error?h.stack||h.message:h}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}cs.exports=Ha});var ls=F((oe,Xi)=>{"use strict";oe.formatArgs=Ga;oe.save=Ka;oe.load=Ya;oe.useColors=ja;oe.storage=Ja();oe.destroy=(()=>{let i=!1;return()=>{i||(i=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();oe.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function ja(){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 Ga(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+Xi.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;i.splice(1,0,e,"color: inherit");let t=0,r=0;i[0].replace(/%[a-zA-Z%]/g,n=>{n!=="%%"&&(t++,n==="%c"&&(r=t))}),i.splice(r,0,e)}oe.log=console.debug||console.log||(()=>{});function Ka(i){try{i?oe.storage.setItem("debug",i):oe.storage.removeItem("debug")}catch(e){}}function Ya(){let i;try{i=oe.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function Ja(){try{return localStorage}catch(i){}}Xi.exports=Wr()(oe);var{formatters:Xa}=Xi.exports;Xa.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var fs=F((gu,hs)=>{"use strict";hs.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 Vr=F((yu,ds)=>{"use strict";var Qa=R("os"),us=R("tty"),pe=fs(),{env:j}=process,Ge;pe("no-color")||pe("no-colors")||pe("color=false")||pe("color=never")?Ge=0:(pe("color")||pe("colors")||pe("color=true")||pe("color=always"))&&(Ge=1);"FORCE_COLOR"in j&&(j.FORCE_COLOR==="true"?Ge=1:j.FORCE_COLOR==="false"?Ge=0:Ge=j.FORCE_COLOR.length===0?1:Math.min(parseInt(j.FORCE_COLOR,10),3));function zr(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function $r(i,e){if(Ge===0)return 0;if(pe("color=16m")||pe("color=full")||pe("color=truecolor"))return 3;if(pe("color=256"))return 2;if(i&&!e&&Ge===void 0)return 0;let t=Ge||0;if(j.TERM==="dumb")return t;if(process.platform==="win32"){let r=Qa.release().split(".");return Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in j)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(r=>r in j)||j.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in j)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(j.TEAMCITY_VERSION)?1:0;if(j.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in j){let r=parseInt((j.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(j.TERM_PROGRAM){case"iTerm.app":return r>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(j.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(j.TERM)||"COLORTERM"in j?1:t}function Za(i){let e=$r(i,i&&i.isTTY);return zr(e)}ds.exports={supportsColor:Za,stdout:zr($r(!0,us.isatty(1))),stderr:zr($r(!0,us.isatty(2)))}});var ms=F((G,Zi)=>{"use strict";var ec=R("tty"),Qi=R("util");G.init=ac;G.log=nc;G.formatArgs=ic;G.save=sc;G.load=oc;G.useColors=tc;G.destroy=Qi.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");G.colors=[6,2,3,4,5,1];try{let i=Vr();i&&(i.stderr||i).level>=2&&(G.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(i){}G.inspectOpts=Object.keys(process.env).filter(i=>/^debug_/i.test(i)).reduce((i,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(n,s)=>s.toUpperCase()),r=process.env[e];return/^(yes|on|true|enabled)$/i.test(r)?r=!0:/^(no|off|false|disabled)$/i.test(r)?r=!1:r==="null"?r=null:r=Number(r),i[t]=r,i},{});function tc(){return"colors"in G.inspectOpts?!!G.inspectOpts.colors:ec.isatty(process.stderr.fd)}function ic(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 qa=Object.create;var Wi=Object.defineProperty,Wa=Object.defineProperties,$a=Object.getOwnPropertyDescriptor,Ka=Object.getOwnPropertyDescriptors,za=Object.getOwnPropertyNames,qi=Object.getOwnPropertySymbols,Va=Object.getPrototypeOf,Jr=Object.prototype.hasOwnProperty,is=Object.prototype.propertyIsEnumerable;var rs=i=>{throw TypeError(i)},ns=Math.pow,Yr=(i,e,t)=>e in i?Wi(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,y=(i,e)=>{for(var t in e||(e={}))Jr.call(e,t)&&Yr(i,t,e[t]);if(qi)for(var t of qi(e))is.call(e,t)&&Yr(i,t,e[t]);return i},x=(i,e)=>Wa(i,Ka(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 Xr=(i,e)=>{var t={};for(var r in i)Jr.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&qi)for(var r of qi(i))e.indexOf(r)<0&&is.call(i,r)&&(t[r]=i[r]);return t};var F=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Ha=(i,e)=>{for(var t in e)Wi(i,t,{get:e[t],enumerable:!0})},ja=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of za(e))!Jr.call(i,n)&&n!==t&&Wi(i,n,{get:()=>e[n],enumerable:!(r=$a(e,n))||r.enumerable});return i};var te=(i,e,t)=>(t=i!=null?qa(Va(i)):{},ja(e||!i||!i.__esModule?Wi(t,"default",{value:i,enumerable:!0}):t,i));var O=(i,e,t)=>Yr(i,typeof e!="symbol"?e+"":e,t),Qr=(i,e,t)=>e.has(i)||rs("Cannot "+t);var a=(i,e,t)=>(Qr(i,e,"read from private field"),t?t.call(i):e.get(i)),g=(i,e,t)=>e.has(i)?rs("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),v=(i,e,t,r)=>(Qr(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ge=(i,e,t)=>(Qr(i,e,"access private method"),t);var d=(i,e,t)=>new Promise((r,n)=>{var s=l=>{try{c(t.next(l))}catch(h){n(h)}},o=l=>{try{c(t.throw(l))}catch(h){n(h)}},c=l=>l.done?r(l.value):Promise.resolve(l.value).then(s,o);c((t=t.apply(i,e)).next())});var dn=F((bd,Ms)=>{"use strict";var Ft=1e3,Ut=Ft*60,Dt=Ut*60,bt=Dt*24,vc=bt*7,bc=bt*365.25;Ms.exports=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return Sc(i);if(t==="number"&&isFinite(i))return e.long?Ec(i):_c(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function Sc(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*bc;case"weeks":case"week":case"w":return t*vc;case"days":case"day":case"d":return t*bt;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Dt;case"minutes":case"minute":case"mins":case"min":case"m":return t*Ut;case"seconds":case"second":case"secs":case"sec":case"s":return t*Ft;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function _c(i){var e=Math.abs(i);return e>=bt?Math.round(i/bt)+"d":e>=Dt?Math.round(i/Dt)+"h":e>=Ut?Math.round(i/Ut)+"m":e>=Ft?Math.round(i/Ft)+"s":i+"ms"}function Ec(i){var e=Math.abs(i);return e>=bt?Er(i,e,bt,"day"):e>=Dt?Er(i,e,Dt,"hour"):e>=Ut?Er(i,e,Ut,"minute"):e>=Ft?Er(i,e,Ft,"second"):i+" ms"}function Er(i,e,t,r){var n=e>=t*1.5;return Math.round(i/t)+" "+r+(n?"s":"")}});var pn=F((Sd,qs)=>{"use strict";function wc(i){t.debug=t,t.default=t,t.coerce=l,t.disable=s,t.enable=n,t.enabled=o,t.humanize=dn(),t.destroy=h,Object.keys(i).forEach(u=>{t[u]=i[u]}),t.names=[],t.skips=[],t.formatters={};function e(u){let f=0;for(let p=0;p<u.length;p++)f=(f<<5)-f+u.charCodeAt(p),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(u){let f,p=null,m,C;function b(..._){if(!b.enabled)return;let T=b,N=Number(new Date),S=N-(f||N);T.diff=S,T.prev=f,T.curr=N,f=N,_[0]=t.coerce(_[0]),typeof _[0]!="string"&&_.unshift("%O");let E=0;_[0]=_[0].replace(/%([a-zA-Z%])/g,(R,P)=>{if(R==="%%")return"%";E++;let $=t.formatters[P];if(typeof $=="function"){let le=_[E];R=$.call(T,le),_.splice(E,1),E--}return R}),t.formatArgs.call(T,_),(T.log||t.log).apply(T,_)}return b.namespace=u,b.useColors=t.useColors(),b.color=t.selectColor(u),b.extend=r,b.destroy=t.destroy,Object.defineProperty(b,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(m!==t.namespaces&&(m=t.namespaces,C=t.enabled(u)),C),set:_=>{p=_}}),typeof t.init=="function"&&t.init(b),b}function r(u,f){let p=t(this.namespace+(typeof f=="undefined"?":":f)+u);return p.log=this.log,p}function n(u){t.save(u),t.namespaces=u,t.names=[],t.skips=[];let f,p=(typeof u=="string"?u:"").split(/[\s,]+/),m=p.length;for(f=0;f<m;f++)p[f]&&(u=p[f].replace(/\*/g,".*?"),u[0]==="-"?t.skips.push(new RegExp("^"+u.slice(1)+"$")):t.names.push(new RegExp("^"+u+"$")))}function s(){let u=[...t.names.map(c),...t.skips.map(c).map(f=>"-"+f)].join(",");return t.enable(""),u}function o(u){if(u[u.length-1]==="*")return!0;let f,p;for(f=0,p=t.skips.length;f<p;f++)if(t.skips[f].test(u))return!1;for(f=0,p=t.names.length;f<p;f++)if(t.names[f].test(u))return!0;return!1}function c(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function l(u){return u instanceof Error?u.stack||u.message:u}function h(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}qs.exports=wc});var Ws=F((he,wr)=>{"use strict";he.formatArgs=Cc;he.save=Nc;he.load=kc;he.useColors=xc;he.storage=Ac();he.destroy=(()=>{let i=!1;return()=>{i||(i=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();he.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function xc(){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 Cc(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)}he.log=console.debug||console.log||(()=>{});function Nc(i){try{i?he.storage.setItem("debug",i):he.storage.removeItem("debug")}catch(e){}}function kc(){let i;try{i=he.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function Ac(){try{return localStorage}catch(i){}}wr.exports=pn()(he);var{formatters:Rc}=wr.exports;Rc.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Ks=F((_d,$s)=>{"use strict";$s.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 gn=F((Ed,Vs)=>{"use strict";var Ic=I("os"),zs=I("tty"),ve=Ks(),{env:G}=process,ot;ve("no-color")||ve("no-colors")||ve("color=false")||ve("color=never")?ot=0:(ve("color")||ve("colors")||ve("color=true")||ve("color=always"))&&(ot=1);"FORCE_COLOR"in G&&(G.FORCE_COLOR==="true"?ot=1:G.FORCE_COLOR==="false"?ot=0:ot=G.FORCE_COLOR.length===0?1:Math.min(parseInt(G.FORCE_COLOR,10),3));function mn(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function yn(i,e){if(ot===0)return 0;if(ve("color=16m")||ve("color=full")||ve("color=truecolor"))return 3;if(ve("color=256"))return 2;if(i&&!e&&ot===void 0)return 0;let t=ot||0;if(G.TERM==="dumb")return t;if(process.platform==="win32"){let r=Ic.release().split(".");return Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in G)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(r=>r in G)||G.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in G)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(G.TEAMCITY_VERSION)?1:0;if(G.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in G){let r=parseInt((G.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(G.TERM_PROGRAM){case"iTerm.app":return r>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(G.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(G.TERM)||"COLORTERM"in G?1:t}function Tc(i){let e=yn(i,i&&i.isTTY);return mn(e)}Vs.exports={supportsColor:Tc,stdout:mn(yn(!0,zs.isatty(1))),stderr:mn(yn(!0,zs.isatty(2)))}});var js=F((Y,Cr)=>{"use strict";var Oc=I("tty"),xr=I("util");Y.init=Mc;Y.log=Uc;Y.formatArgs=Lc;Y.save=Dc;Y.load=Bc;Y.useColors=Pc;Y.destroy=xr.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Y.colors=[6,2,3,4,5,1];try{let i=gn();i&&(i.stderr||i).level>=2&&(Y.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){}Y.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 Pc(){return"colors"in Y.inspectOpts?!!Y.inspectOpts.colors:Oc.isatty(process.stderr.fd)}function Lc(i){let{namespace:e,useColors:t}=this;if(t){let r=this.color,n="\x1B[3"+(r<8?r:"8;5;"+r),s=` ${n};1m${e} \x1B[0m`;i[0]=s+i[0].split(`
|
|
2
2
|
`).join(`
|
|
3
|
-
`+s),i.push(n+"m+"+
|
|
4
|
-
`)}function
|
|
5
|
-
`).map(e=>e.trim()).join(" ")};
|
|
6
|
-
`);return y.substr(0,y.length-2)},this.getRequestHeader=function(y){return typeof y=="string"&&u[y]?u[y]:""},this.send=function(y){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");if(d)throw new Error("INVALID_STATE_ERR: send has already been called");var b=!1,$=!1,N=xs.parse(o.url),P;switch(N.protocol){case"https:":b=!0;case"http:":P=N.hostname;break;case"file:":$=!0;break;case void 0:case"":P="localhost";break;default:throw new Error("Protocol not supported.")}if($){if(o.method!=="GET")throw new Error("XMLHttpRequest: Only GET method is supported");if(o.async)Ct.readFile(unescape(N.pathname),"utf8",function(fe,mt){fe?e.handleError(fe,fe.errno||-1):(e.status=200,e.responseText=mt,w(e.DONE))});else try{this.responseText=Ct.readFileSync(unescape(N.pathname),"utf8"),this.status=200,w(e.DONE)}catch(fe){this.handleError(fe,fe.errno||-1)}return}var q=N.port||(b?443:80),ne=N.pathname+(N.search?N.search:"");if(u.Host=P,b&&q===443||q===80||(u.Host+=":"+N.port),o.user){typeof o.password=="undefined"&&(o.password="");var Ze=new Buffer(o.user+":"+o.password);u.Authorization="Basic "+Ze.toString("base64")}o.method==="GET"||o.method==="HEAD"?y=null:y?(u["Content-Length"]=Buffer.isBuffer(y)?y.length:Buffer.byteLength(y),u["Content-Type"]||(u["Content-Type"]="text/plain;charset=UTF-8")):o.method==="POST"&&(u["Content-Length"]=0);var et=i.agent||!1,ie={host:P,port:q,path:ne,method:o.method,headers:u,agent:et};if(b&&(ie.pfx=i.pfx,ie.key=i.key,ie.passphrase=i.passphrase,ie.cert=i.cert,ie.ca=i.ca,ie.ciphers=i.ciphers,ie.rejectUnauthorized=i.rejectUnauthorized!==!1),p=!1,o.async){var Me=b?r.request:t.request;d=!0,e.dispatchEvent("readystatechange");var qe=function(fe){if(s=fe,s.statusCode===302||s.statusCode===303||s.statusCode===307){o.url=s.headers.location;var mt=xs.parse(o.url);P=mt.hostname;var ze={hostname:mt.hostname,port:mt.port,path:mt.path,method:s.statusCode===303?"GET":o.method,headers:u};b&&(ze.pfx=i.pfx,ze.key=i.key,ze.passphrase=i.passphrase,ze.cert=i.cert,ze.ca=i.ca,ze.ciphers=i.ciphers,ze.rejectUnauthorized=i.rejectUnauthorized!==!1),n=Me(ze,qe).on("error",We),n.end();return}s&&s.setEncoding&&s.setEncoding("utf8"),w(e.HEADERS_RECEIVED),e.status=s.statusCode,s.on("data",function(yi){yi&&(e.responseText+=yi),d&&w(e.LOADING)}),s.on("end",function(){d&&(d=!1,w(e.DONE))}),s.on("error",function(yi){e.handleError(yi)})},We=function(fe){e.handleError(fe)};n=Me(ie,qe).on("error",We),i.autoUnref&&n.on("socket",fe=>{fe.unref()}),y&&n.write(y),n.end(),e.dispatchEvent("loadstart")}else{var me=".node-xmlhttprequest-content-"+process.pid,ge=".node-xmlhttprequest-sync-"+process.pid;Ct.writeFileSync(ge,"","utf8");for(var Te="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(b?"s":"")+".request;var options = "+JSON.stringify(ie)+";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('"+me+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+ge+"');});response.on('error', function(error) {fs.writeFileSync('"+me+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+ge+"');});}).on('error', function(error) {fs.writeFileSync('"+me+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+ge+"');});"+(y?"req.write('"+JSON.stringify(y).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",oa=hc(process.argv[0],["-e",Te]),sh;Ct.existsSync(ge););if(e.responseText=Ct.readFileSync(me,"utf8"),oa.stdin.end(),Ct.unlinkSync(me),e.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var aa=e.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");e.handleError(aa,503)}else e.status=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1"),e.responseText=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"),w(e.DONE)}},this.handleError=function(y,b){this.status=b||0,this.statusText=y,this.responseText=y.stack,p=!0,w(this.DONE)},this.abort=function(){n&&(n.abort(),n=null),u=Object.assign({},l),this.responseText="",this.responseXML="",p=x=!0,this.readyState!==this.UNSENT&&(this.readyState!==this.OPENED||d)&&this.readyState!==this.DONE&&(d=!1,w(this.DONE)),this.readyState=this.UNSENT},this.addEventListener=function(y,b){y in g||(g[y]=[]),g[y].push(b)},this.removeEventListener=function(y,b){y in g&&(g[y]=g[y].filter(function($){return $!==b}))},this.dispatchEvent=function(y){if(typeof e["on"+y]=="function"&&(this.readyState===this.DONE?setImmediate(function(){e["on"+y]()}):e["on"+y]()),y in g)for(let b=0,$=g[y].length;b<$;b++)this.readyState===this.DONE?setImmediate(function(){g[y][b].call(e)}):g[y][b].call(e)};var w=function(y){if(!(e.readyState===y||e.readyState===e.UNSENT&&x)&&(e.readyState=y,(o.async||e.readyState<e.OPENED||e.readyState===e.DONE)&&e.dispatchEvent("readystatechange"),e.readyState===e.DONE)){let b;x?b="abort":p?b="error":b="load",e.dispatchEvent(b),e.dispatchEvent("loadend")}}}});var Is=F((Uu,Os)=>{"use strict";var{Duplex:pc}=R("stream");function Rs(i){i.emit("close")}function mc(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Ts(i){this.removeListener("error",Ts),this.destroy(),this.listenerCount("error")===0&&this.emit("error",i)}function gc(i,e){let t=!0,r=new pc(A(E({},e),{autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1}));return i.on("message",function(s,o){let c=!o&&r._readableState.objectMode?s.toString():s;r.push(c)||i.pause()}),i.once("error",function(s){r.destroyed||(t=!1,r.destroy(s))}),i.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(n,s){if(i.readyState===i.CLOSED){s(n),process.nextTick(Rs,r);return}let o=!1;i.once("error",function(l){o=!0,s(l)}),i.once("close",function(){o||s(n),process.nextTick(Rs,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",mc),r.on("error",Ts),r}Os.exports=gc});var Ye=F((Bu,Ps)=>{"use strict";Ps.exports={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Zt=F((Mu,rr)=>{"use strict";var{EMPTY_BUFFER:yc}=Ye();function vc(i,e){if(i.length===0)return yc;if(i.length===1)return i[0];let t=Buffer.allocUnsafe(e),r=0;for(let n=0;n<i.length;n++){let s=i[n];t.set(s,r),r+=s.length}return r<e?t.slice(0,r):t}function Ls(i,e,t,r,n){for(let s=0;s<n;s++)t[r+s]=i[s]^e[s&3]}function Fs(i,e){for(let t=0;t<i.length;t++)i[t]^=e[t&3]}function _c(i){return i.byteLength===i.buffer.byteLength?i.buffer:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}function Qr(i){if(Qr.readOnly=!0,Buffer.isBuffer(i))return i;let e;return i instanceof ArrayBuffer?e=Buffer.from(i):ArrayBuffer.isView(i)?e=Buffer.from(i.buffer,i.byteOffset,i.byteLength):(e=Buffer.from(i),Qr.readOnly=!1),e}rr.exports={concat:vc,mask:Ls,toArrayBuffer:_c,toBuffer:Qr,unmask:Fs};if(!process.env.WS_NO_BUFFER_UTIL)try{let i=R("bufferutil");rr.exports.mask=function(e,t,r,n,s){s<48?Ls(e,t,r,n,s):i.mask(e,t,r,n,s)},rr.exports.unmask=function(e,t){e.length<32?Fs(e,t):i.unmask(e,t)}}catch(i){}});var Bs=F((qu,Ds)=>{"use strict";var Us=Symbol("kDone"),Zr=Symbol("kRun"),en=class{constructor(e){this[Us]=()=>{this.pending--,this[Zr]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Zr]()}[Zr](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Us])}}};Ds.exports=en});var ii=F((Wu,zs)=>{"use strict";var ei=R("zlib"),Ms=Zt(),Ec=Bs(),{kStatusCode:qs}=Ye(),Sc=Buffer.from([0,0,255,255]),or=Symbol("permessage-deflate"),Ue=Symbol("total-length"),ti=Symbol("callback"),Je=Symbol("buffers"),sr=Symbol("error"),nr,tn=class{constructor(e,t,r){if(this._maxPayload=r|0,this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!nr){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;nr=new Ec(n)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[ti];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){nr.add(n=>{this._decompress(e,t,(s,o)=>{n(),r(s,o)})})}compress(e,t,r){nr.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"?ei.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=ei.createInflateRaw(A(E({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[or]=this,this._inflate[Ue]=0,this._inflate[Je]=[],this._inflate.on("error",xc),this._inflate.on("data",Ws)}this._inflate[ti]=r,this._inflate.write(e),t&&this._inflate.write(Sc),this._inflate.flush(()=>{let s=this._inflate[sr];if(s){this._inflate.close(),this._inflate=null,r(s);return}let o=Ms.concat(this._inflate[Je],this._inflate[Ue]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ue]=0,this._inflate[Je]=[],t&&this.params[`${n}_no_context_takeover`]&&this._inflate.reset()),r(null,o)})}_compress(e,t,r){let n=this._isServer?"server":"client";if(!this._deflate){let s=`${n}_max_window_bits`,o=typeof this.params[s]!="number"?ei.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=ei.createDeflateRaw(A(E({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[Ue]=0,this._deflate[Je]=[],this._deflate.on("data",bc)}this._deflate[ti]=r,this._deflate.write(e),this._deflate.flush(ei.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=Ms.concat(this._deflate[Je],this._deflate[Ue]);t&&(s=s.slice(0,s.length-4)),this._deflate[ti]=null,this._deflate[Ue]=0,this._deflate[Je]=[],t&&this.params[`${n}_no_context_takeover`]&&this._deflate.reset(),r(null,s)})}};zs.exports=tn;function bc(i){this[Je].push(i),this[Ue]+=i.length}function Ws(i){if(this[Ue]+=i.length,this[or]._maxPayload<1||this[Ue]<=this[or]._maxPayload){this[Je].push(i);return}this[sr]=new RangeError("Max payload size exceeded"),this[sr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[sr][qs]=1009,this.removeListener("data",Ws),this.reset()}function xc(i){this[or]._inflate=null,i[qs]=1007,this[ti](i)}});var ri=F(($u,rn)=>{"use strict";var wc=[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 Cc(i){return i>=1e3&&i<=1014&&i!==1004&&i!==1005&&i!==1006||i>=3e3&&i<=4999}function $s(i){let e=i.length,t=0;for(;t<e;)if(!(i[t]&128))t++;else if((i[t]&224)===192){if(t+1===e||(i[t+1]&192)!==128||(i[t]&254)===192)return!1;t+=2}else if((i[t]&240)===224){if(t+2>=e||(i[t+1]&192)!==128||(i[t+2]&192)!==128||i[t]===224&&(i[t+1]&224)===128||i[t]===237&&(i[t+1]&224)===160)return!1;t+=3}else if((i[t]&248)===240){if(t+3>=e||(i[t+1]&192)!==128||(i[t+2]&192)!==128||(i[t+3]&192)!==128||i[t]===240&&(i[t+1]&240)===128||i[t]===244&&i[t+1]>143||i[t]>244)return!1;t+=4}else return!1;return!0}rn.exports={isValidStatusCode:Cc,isValidUTF8:$s,tokenChars:wc};if(!process.env.WS_NO_UTF_8_VALIDATE)try{let i=R("utf-8-validate");rn.exports.isValidUTF8=function(e){return e.length<150?$s(e):i(e)}}catch(i){}});var an=F((Vu,Js)=>{"use strict";var{Writable:Nc}=R("stream"),Vs=ii(),{BINARY_TYPES:kc,EMPTY_BUFFER:Hs,kStatusCode:Ac,kWebSocket:Rc}=Ye(),{concat:nn,toArrayBuffer:Tc,unmask:Oc}=Zt(),{isValidStatusCode:Ic,isValidUTF8:js}=ri(),ni=0,Gs=1,Ks=2,Ys=3,sn=4,Pc=5,on=class extends Nc{constructor(e={}){super(),this._binaryType=e.binaryType||kc[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Rc]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._state=ni,this._loop=!1}_write(e,t,r){if(this._opcode===8&&this._state==ni)return r();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=r.slice(e),r.slice(0,e)}let t=Buffer.allocUnsafe(e);do{let r=this._buffers[0],n=t.length-e;e>=r.length?t.set(this._buffers.shift(),n):(t.set(new Uint8Array(r.buffer,r.byteOffset,e),n),this._buffers[0]=r.slice(e)),e-=r.length}while(e>0);return t}startLoop(e){let t;this._loop=!0;do switch(this._state){case ni:t=this.getInfo();break;case Gs:t=this.getPayloadLength16();break;case Ks:t=this.getPayloadLength64();break;case Ys:this.getMask();break;case sn:t=this.getData(e);break;default:this._loop=!1;return}while(this._loop);e(t)}getInfo(){if(this._bufferedBytes<2){this._loop=!1;return}let e=this.consume(2);if(e[0]&48)return this._loop=!1,W(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");let t=(e[0]&64)===64;if(t&&!this._extensions[Vs.extensionName])return this._loop=!1,W(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._fin=(e[0]&128)===128,this._opcode=e[0]&15,this._payloadLength=e[1]&127,this._opcode===0){if(t)return this._loop=!1,W(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,W(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented)return this._loop=!1,W(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");this._compressed=t}else if(this._opcode>7&&this._opcode<11){if(!this._fin)return this._loop=!1,W(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(t)return this._loop=!1,W(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,W(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else return this._loop=!1,W(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(e[1]&128)===128,this._isServer){if(!this._masked)return this._loop=!1,W(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,W(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(this._payloadLength===126)this._state=Gs;else if(this._payloadLength===127)this._state=Ks;else return this.haveLength()}getPayloadLength16(){if(this._bufferedBytes<2){this._loop=!1;return}return this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength()}getPayloadLength64(){if(this._bufferedBytes<8){this._loop=!1;return}let e=this.consume(8),t=e.readUInt32BE(0);return t>Math.pow(2,21)-1?(this._loop=!1,W(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=t*Math.pow(2,32)+e.readUInt32BE(4),this.haveLength())}haveLength(){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0))return this._loop=!1,W(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=Ys:this._state=sn}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=sn}getData(e){let t=Hs;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]&&Oc(t,this._mask)}if(this._opcode>7)return this.controlMessage(t);if(this._compressed){this._state=Pc,this.decompress(t,e);return}return t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage()}decompress(e,t){this._extensions[Vs.extensionName].decompress(e,this._fin,(n,s)=>{if(n)return t(n);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return t(W(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(s)}let o=this.dataMessage();if(o)return t(o);this.startLoop(t)})}dataMessage(){if(this._fin){let e=this._messageLength,t=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let r;this._binaryType==="nodebuffer"?r=nn(t,e):this._binaryType==="arraybuffer"?r=Tc(nn(t,e)):r=t,this.emit("message",r,!0)}else{let r=nn(t,e);if(!this._skipUTF8Validation&&!js(r))return this._loop=!1,W(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",r,!1)}}this._state=ni}controlMessage(e){if(this._opcode===8)if(this._loop=!1,e.length===0)this.emit("conclude",1005,Hs),this.end();else{if(e.length===1)return W(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{let t=e.readUInt16BE(0);if(!Ic(t))return W(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let r=e.slice(2);if(!this._skipUTF8Validation&&!js(r))return W(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("conclude",t,r),this.end()}}else this._opcode===9?this.emit("ping",e):this.emit("pong",e);this._state=ni}};Js.exports=on;function W(i,e,t,r,n){let s=new i(t?`Invalid WebSocket frame: ${e}`:e);return Error.captureStackTrace(s,W),s.code=n,s[Ac]=r,s}});var ln=F((Gu,Zs)=>{"use strict";var Hu=R("net"),ju=R("tls"),{randomFillSync:Lc}=R("crypto"),Xs=ii(),{EMPTY_BUFFER:Fc}=Ye(),{isValidStatusCode:Uc}=ri(),{mask:Qs,toBuffer:Nt}=Zt(),be=Symbol("kByteLength"),Dc=Buffer.alloc(4),cn=class i{constructor(e,t,r){this._extensions=t||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(e,t){let r,n=!1,s=2,o=!1;t.mask&&(r=t.maskBuffer||Dc,t.generateMask?t.generateMask(r):Lc(r,0,4),o=(r[0]|r[1]|r[2]|r[3])===0,s=6);let c;typeof e=="string"?(!t.mask||o)&&t[be]!==void 0?c=t[be]:(e=Buffer.from(e),c=e.length):(c=e.length,n=t.mask&&t.readOnly&&!o);let l=c;c>=65536?(s+=8,l=127):c>125&&(s+=2,l=126);let u=Buffer.allocUnsafe(n?c+s:s);return u[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(u[0]|=64),u[1]=l,l===126?u.writeUInt16BE(c,2):l===127&&(u[2]=u[3]=0,u.writeUIntBE(c,4,6)),t.mask?(u[1]|=128,u[s-4]=r[0],u[s-3]=r[1],u[s-2]=r[2],u[s-1]=r[3],o?[u,e]:n?(Qs(e,r,u,s,c),[u]):(Qs(e,r,e,0,c),[u,e])):[u,e]}close(e,t,r,n){let s;if(e===void 0)s=Fc;else{if(typeof e!="number"||!Uc(e))throw new TypeError("First argument must be a valid error code number");if(t===void 0||!t.length)s=Buffer.allocUnsafe(2),s.writeUInt16BE(e,0);else{let c=Buffer.byteLength(t);if(c>123)throw new RangeError("The message must not be greater than 123 bytes");s=Buffer.allocUnsafe(2+c),s.writeUInt16BE(e,0),typeof t=="string"?s.write(t,2):s.set(t,2)}}let o={[be]:s.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,s,!1,o,n]):this.sendFrame(i.frame(s,o),n)}ping(e,t,r){let n,s;if(typeof e=="string"?(n=Buffer.byteLength(e),s=!1):(e=Nt(e),n=e.length,s=Nt.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[be]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:s,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(i.frame(e,o),r)}pong(e,t,r){let n,s;if(typeof e=="string"?(n=Buffer.byteLength(e),s=!1):(e=Nt(e),n=e.length,s=Nt.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[be]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:s,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(i.frame(e,o),r)}send(e,t,r){let n=this._extensions[Xs.extensionName],s=t.binary?2:1,o=t.compress,c,l;if(typeof e=="string"?(c=Buffer.byteLength(e),l=!1):(e=Nt(e),c=e.length,l=Nt.readOnly),this._firstFragment?(this._firstFragment=!1,o&&n&&n.params[n._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=c>=n._threshold),this._compress=o):(o=!1,s=0),t.fin&&(this._firstFragment=!0),n){let u={[be]:c,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:l,rsv1:o};this._deflating?this.enqueue([this.dispatch,e,this._compress,u,r]):this.dispatch(e,this._compress,u,r)}else this.sendFrame(i.frame(e,{[be]:c,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:l,rsv1:!1}),r)}dispatch(e,t,r,n){if(!t){this.sendFrame(i.frame(e,r),n);return}let s=this._extensions[Xs.extensionName];this._bufferedBytes+=r[be],this._deflating=!0,s.compress(e,r.fin,(o,c)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");typeof n=="function"&&n(l);for(let u=0;u<this._queue.length;u++){let h=this._queue[u],f=h[h.length-1];typeof f=="function"&&f(l)}return}this._bufferedBytes-=r[be],this._deflating=!1,r.readOnly=!1,this.sendFrame(i.frame(c,r),n),this.dequeue()})}dequeue(){for(;!this._deflating&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][be],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][be],this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};Zs.exports=cn});var co=F((Ku,ao)=>{"use strict";var{kForOnEventAttribute:si,kListener:hn}=Ye(),eo=Symbol("kCode"),to=Symbol("kData"),io=Symbol("kError"),ro=Symbol("kMessage"),no=Symbol("kReason"),kt=Symbol("kTarget"),so=Symbol("kType"),oo=Symbol("kWasClean"),De=class{constructor(e){this[kt]=null,this[so]=e}get target(){return this[kt]}get type(){return this[so]}};Object.defineProperty(De.prototype,"target",{enumerable:!0});Object.defineProperty(De.prototype,"type",{enumerable:!0});var lt=class extends De{constructor(e,t={}){super(e),this[eo]=t.code===void 0?0:t.code,this[no]=t.reason===void 0?"":t.reason,this[oo]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[eo]}get reason(){return this[no]}get wasClean(){return this[oo]}};Object.defineProperty(lt.prototype,"code",{enumerable:!0});Object.defineProperty(lt.prototype,"reason",{enumerable:!0});Object.defineProperty(lt.prototype,"wasClean",{enumerable:!0});var At=class extends De{constructor(e,t={}){super(e),this[io]=t.error===void 0?null:t.error,this[ro]=t.message===void 0?"":t.message}get error(){return this[io]}get message(){return this[ro]}};Object.defineProperty(At.prototype,"error",{enumerable:!0});Object.defineProperty(At.prototype,"message",{enumerable:!0});var oi=class extends De{constructor(e,t={}){super(e),this[to]=t.data===void 0?null:t.data}get data(){return this[to]}};Object.defineProperty(oi.prototype,"data",{enumerable:!0});var Bc={addEventListener(i,e,t={}){for(let n of this.listeners(i))if(!t[si]&&n[hn]===e&&!n[si])return;let r;if(i==="message")r=function(s,o){let c=new oi("message",{data:o?s:s.toString()});c[kt]=this,ar(e,this,c)};else if(i==="close")r=function(s,o){let c=new lt("close",{code:s,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});c[kt]=this,ar(e,this,c)};else if(i==="error")r=function(s){let o=new At("error",{error:s,message:s.message});o[kt]=this,ar(e,this,o)};else if(i==="open")r=function(){let s=new De("open");s[kt]=this,ar(e,this,s)};else return;r[si]=!!t[si],r[hn]=e,t.once?this.once(i,r):this.on(i,r)},removeEventListener(i,e){for(let t of this.listeners(i))if(t[hn]===e&&!t[si]){this.removeListener(i,t);break}}};ao.exports={CloseEvent:lt,ErrorEvent:At,Event:De,EventTarget:Bc,MessageEvent:oi};function ar(i,e,t){typeof i=="object"&&i.handleEvent?i.handleEvent.call(i,t):i.call(e,t)}});var fn=F((Yu,lo)=>{"use strict";var{tokenChars:ai}=ri();function ke(i,e,t){i[e]===void 0?i[e]=[t]:i[e].push(t)}function Mc(i){let e=Object.create(null),t=Object.create(null),r=!1,n=!1,s=!1,o,c,l=-1,u=-1,h=-1,f=0;for(;f<i.length;f++)if(u=i.charCodeAt(f),o===void 0)if(h===-1&&ai[u]===1)l===-1&&(l=f);else if(f!==0&&(u===32||u===9))h===-1&&l!==-1&&(h=f);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);h===-1&&(h=f);let p=i.slice(l,h);u===44?(ke(e,p,t),t=Object.create(null)):o=p,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);else if(c===void 0)if(h===-1&&ai[u]===1)l===-1&&(l=f);else if(u===32||u===9)h===-1&&l!==-1&&(h=f);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);h===-1&&(h=f),ke(t,i.slice(l,h),!0),u===44&&(ke(e,o,t),t=Object.create(null),o=void 0),l=h=-1}else if(u===61&&l!==-1&&h===-1)c=i.slice(l,f),l=h=-1;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(n){if(ai[u]!==1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1?l=f:r||(r=!0),n=!1}else if(s)if(ai[u]===1)l===-1&&(l=f);else if(u===34&&l!==-1)s=!1,h=f;else if(u===92)n=!0;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(u===34&&i.charCodeAt(f-1)===61)s=!0;else if(h===-1&&ai[u]===1)l===-1&&(l=f);else if(l!==-1&&(u===32||u===9))h===-1&&(h=f);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);h===-1&&(h=f);let p=i.slice(l,h);r&&(p=p.replace(/\\/g,""),r=!1),ke(t,c,p),u===44&&(ke(e,o,t),t=Object.create(null),o=void 0),c=void 0,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);if(l===-1||s||u===32||u===9)throw new SyntaxError("Unexpected end of input");h===-1&&(h=f);let d=i.slice(l,h);return o===void 0?ke(e,d,t):(c===void 0?ke(t,d,!0):r?ke(t,c,d.replace(/\\/g,"")):ke(t,c,d),ke(e,o,t)),e}function qc(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(", ")}lo.exports={format:qc,parse:Mc}});var gn=F((Xu,So)=>{"use strict";var Wc=R("events"),zc=R("https"),$c=R("http"),uo=R("net"),Vc=R("tls"),{randomBytes:Hc,createHash:jc}=R("crypto"),{Readable:Ju}=R("stream"),{URL:un}=R("url"),Xe=ii(),Gc=an(),Kc=ln(),{BINARY_TYPES:ho,EMPTY_BUFFER:cr,GUID:Yc,kForOnEventAttribute:dn,kListener:Jc,kStatusCode:Xc,kWebSocket:te,NOOP:po}=Ye(),{EventTarget:{addEventListener:Qc,removeEventListener:Zc}}=co(),{format:el,parse:tl}=fn(),{toBuffer:il}=Zt(),rl=30*1e3,mo=Symbol("kAborted"),pn=[8,13],Be=["CONNECTING","OPEN","CLOSING","CLOSED"],nl=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,M=class i extends Wc{constructor(e,t,r){super(),this._binaryType=ho[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=cr,this._closeTimer=null,this._extensions={},this._paused=!1,this._protocol="",this._readyState=i.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,t===void 0?t=[]:Array.isArray(t)||(typeof t=="object"&&t!==null?(r=t,t=[]):t=[t]),go(this,e,t,r)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){ho.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 Gc({binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation});this._sender=new Kc(e,this._extensions,r.generateMask),this._receiver=n,this._socket=e,n[te]=this,e[te]=this,n.on("conclude",al),n.on("drain",cl),n.on("error",ll),n.on("message",hl),n.on("ping",fl),n.on("pong",ul),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",vo),e.on("data",hr),e.on("end",_o),e.on("error",Eo),this._readyState=i.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=i.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[Xe.extensionName]&&this._extensions[Xe.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=i.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==i.CLOSED){if(this.readyState===i.CONNECTING)return ae(this,this._req,"WebSocket was closed before the connection was established");if(this.readyState===i.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=i.CLOSING,this._sender.close(e,t,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),rl)}}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){mn(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||cr,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){mn(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||cr,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){mn(this,e,r);return}let n=E({binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0},t);this._extensions[Xe.extensionName]||(n.compress=!1),this._sender.send(e||cr,n,r)}terminate(){if(this.readyState!==i.CLOSED){if(this.readyState===i.CONNECTING)return ae(this,this._req,"WebSocket was closed before the connection was established");this._socket&&(this._readyState=i.CLOSING,this._socket.destroy())}}};Object.defineProperty(M,"CONNECTING",{enumerable:!0,value:Be.indexOf("CONNECTING")});Object.defineProperty(M.prototype,"CONNECTING",{enumerable:!0,value:Be.indexOf("CONNECTING")});Object.defineProperty(M,"OPEN",{enumerable:!0,value:Be.indexOf("OPEN")});Object.defineProperty(M.prototype,"OPEN",{enumerable:!0,value:Be.indexOf("OPEN")});Object.defineProperty(M,"CLOSING",{enumerable:!0,value:Be.indexOf("CLOSING")});Object.defineProperty(M.prototype,"CLOSING",{enumerable:!0,value:Be.indexOf("CLOSING")});Object.defineProperty(M,"CLOSED",{enumerable:!0,value:Be.indexOf("CLOSED")});Object.defineProperty(M.prototype,"CLOSED",{enumerable:!0,value:Be.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(i=>{Object.defineProperty(M.prototype,i,{enumerable:!0})});["open","error","close","message"].forEach(i=>{Object.defineProperty(M.prototype,`on${i}`,{enumerable:!0,get(){for(let e of this.listeners(i))if(e[dn])return e[Jc];return null},set(e){for(let t of this.listeners(i))if(t[dn]){this.removeListener(i,t);break}typeof e=="function"&&this.addEventListener(i,e,{[dn]:!0})}})});M.prototype.addEventListener=Qc;M.prototype.removeEventListener=Zc;So.exports=M;function go(i,e,t,r){let n=A(E({protocolVersion:pn[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10},r),{createConnection:void 0,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0});if(!pn.includes(n.protocolVersion))throw new RangeError(`Unsupported protocol version: ${n.protocolVersion} (supported versions: ${pn.join(", ")})`);let s;if(e instanceof un)s=e,i._url=e.href;else{try{s=new un(e)}catch(g){throw new SyntaxError(`Invalid URL: ${e}`)}i._url=e}let o=s.protocol==="wss:",c=s.protocol==="ws+unix:",l;if(s.protocol!=="ws:"&&!o&&!c?l=`The URL's protocol must be one of "ws:", "wss:", or "ws+unix:"`:c&&!s.pathname?l="The URL's pathname is empty":s.hash&&(l="The URL contains a fragment identifier"),l){let g=new SyntaxError(l);if(i._redirects===0)throw g;lr(i,g);return}let u=o?443:80,h=Hc(16).toString("base64"),f=o?zc.request:$c.request,d=new Set,p;if(n.createConnection=o?ol:sl,n.defaultPort=n.defaultPort||u,n.port=s.port||u,n.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,n.headers=A(E({},n.headers),{"Sec-WebSocket-Version":n.protocolVersion,"Sec-WebSocket-Key":h,Connection:"Upgrade",Upgrade:"websocket"}),n.path=s.pathname+s.search,n.timeout=n.handshakeTimeout,n.perMessageDeflate&&(p=new Xe(n.perMessageDeflate!==!0?n.perMessageDeflate:{},!1,n.maxPayload),n.headers["Sec-WebSocket-Extensions"]=el({[Xe.extensionName]:p.offer()})),t.length){for(let g of t){if(typeof g!="string"||!nl.test(g)||d.has(g))throw new SyntaxError("An invalid or duplicated subprotocol was specified");d.add(g)}n.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(n.origin&&(n.protocolVersion<13?n.headers["Sec-WebSocket-Origin"]=n.origin:n.headers.Origin=n.origin),(s.username||s.password)&&(n.auth=`${s.username}:${s.password}`),c){let g=n.path.split(":");n.socketPath=g[0],n.path=g[1]}let x;if(n.followRedirects){if(i._redirects===0){i._originalIpc=c,i._originalSecure=o,i._originalHostOrSocketPath=c?n.socketPath:s.host;let g=r&&r.headers;if(r=A(E({},r),{headers:{}}),g)for(let[v,T]of Object.entries(g))r.headers[v.toLowerCase()]=T}else if(i.listenerCount("redirect")===0){let g=c?i._originalIpc?n.socketPath===i._originalHostOrSocketPath:!1:i._originalIpc?!1:s.host===i._originalHostOrSocketPath;(!g||i._originalSecure&&!o)&&(delete n.headers.authorization,delete n.headers.cookie,g||delete n.headers.host,n.auth=void 0)}n.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(n.auth).toString("base64")),x=i._req=f(n),i._redirects&&i.emit("redirect",i.url,x)}else x=i._req=f(n);n.timeout&&x.on("timeout",()=>{ae(i,x,"Opening handshake has timed out")}),x.on("error",g=>{x===null||x[mo]||(x=i._req=null,lr(i,g))}),x.on("response",g=>{let v=g.headers.location,T=g.statusCode;if(v&&n.followRedirects&&T>=300&&T<400){if(++i._redirects>n.maxRedirects){ae(i,x,"Maximum redirects exceeded");return}x.abort();let w;try{w=new un(v,e)}catch(y){let b=new SyntaxError(`Invalid URL: ${v}`);lr(i,b);return}go(i,w,t,r)}else i.emit("unexpected-response",x,g)||ae(i,x,`Unexpected server response: ${g.statusCode}`)}),x.on("upgrade",(g,v,T)=>{if(i.emit("upgrade",g),i.readyState!==M.CONNECTING)return;if(x=i._req=null,g.headers.upgrade.toLowerCase()!=="websocket"){ae(i,v,"Invalid Upgrade header");return}let w=jc("sha1").update(h+Yc).digest("base64");if(g.headers["sec-websocket-accept"]!==w){ae(i,v,"Invalid Sec-WebSocket-Accept header");return}let y=g.headers["sec-websocket-protocol"],b;if(y!==void 0?d.size?d.has(y)||(b="Server sent an invalid subprotocol"):b="Server sent a subprotocol but none was requested":d.size&&(b="Server sent no subprotocol"),b){ae(i,v,b);return}y&&(i._protocol=y);let $=g.headers["sec-websocket-extensions"];if($!==void 0){if(!p){ae(i,v,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let N;try{N=tl($)}catch(q){ae(i,v,"Invalid Sec-WebSocket-Extensions header");return}let P=Object.keys(N);if(P.length!==1||P[0]!==Xe.extensionName){ae(i,v,"Server indicated an extension that was not requested");return}try{p.accept(N[Xe.extensionName])}catch(q){ae(i,v,"Invalid Sec-WebSocket-Extensions header");return}i._extensions[Xe.extensionName]=p}i.setSocket(v,T,{generateMask:n.generateMask,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation})}),x.end()}function lr(i,e){i._readyState=M.CLOSING,i.emit("error",e),i.emitClose()}function sl(i){return i.path=i.socketPath,uo.connect(i)}function ol(i){return i.path=void 0,!i.servername&&i.servername!==""&&(i.servername=uo.isIP(i.host)?"":i.host),Vc.connect(i)}function ae(i,e,t){i._readyState=M.CLOSING;let r=new Error(t);Error.captureStackTrace(r,ae),e.setHeader?(e[mo]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(lr,i,r)):(e.destroy(r),e.once("error",i.emit.bind(i,"error")),e.once("close",i.emitClose.bind(i)))}function mn(i,e,t){if(e){let r=il(e).length;i._socket?i._sender._bufferedBytes+=r:i._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${i.readyState} (${Be[i.readyState]})`);t(r)}}function al(i,e){let t=this[te];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=i,t._socket[te]!==void 0&&(t._socket.removeListener("data",hr),process.nextTick(yo,t._socket),i===1005?t.close():t.close(i,e))}function cl(){let i=this[te];i.isPaused||i._socket.resume()}function ll(i){let e=this[te];e._socket[te]!==void 0&&(e._socket.removeListener("data",hr),process.nextTick(yo,e._socket),e.close(i[Xc])),e.emit("error",i)}function fo(){this[te].emitClose()}function hl(i,e){this[te].emit("message",i,e)}function fl(i){let e=this[te];e.pong(i,!e._isServer,po),e.emit("ping",i)}function ul(i){this[te].emit("pong",i)}function yo(i){i.resume()}function vo(){let i=this[te];this.removeListener("close",vo),this.removeListener("data",hr),this.removeListener("end",_o),i._readyState=M.CLOSING;let e;!this._readableState.endEmitted&&!i._closeFrameReceived&&!i._receiver._writableState.errorEmitted&&(e=i._socket.read())!==null&&i._receiver.write(e),i._receiver.end(),this[te]=void 0,clearTimeout(i._closeTimer),i._receiver._writableState.finished||i._receiver._writableState.errorEmitted?i.emitClose():(i._receiver.on("error",fo),i._receiver.on("finish",fo))}function hr(i){this[te]._receiver.write(i)||this.pause()}function _o(){let i=this[te];i._readyState=M.CLOSING,i._receiver.end(),this.end()}function Eo(){let i=this[te];this.removeListener("error",Eo),this.on("error",po),i&&(i._readyState=M.CLOSING,this.destroy())}});var xo=F((Zu,bo)=>{"use strict";var{tokenChars:dl}=ri();function pl(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&&dl[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}bo.exports={parse:pl}});var To=F((rd,Ro)=>{"use strict";var ml=R("events"),fr=R("http"),ed=R("https"),td=R("net"),id=R("tls"),{createHash:gl}=R("crypto"),wo=fn(),ht=ii(),yl=xo(),vl=gn(),{GUID:_l,kWebSocket:El}=Ye(),Sl=/^[+/0-9A-Za-z]{22}==$/,Co=0,No=1,Ao=2,yn=class extends ml{constructor(e,t){if(super(),e=E({maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:vl},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=fr.createServer((r,n)=>{let s=fr.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=bl(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=Co}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===Ao){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(ci,this);return}if(e&&this.once("close",e),this._state!==No)if(this._state=No,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(ci,this):process.nextTick(ci,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{ci(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",ko);let s=e.headers["sec-websocket-key"],o=+e.headers["sec-websocket-version"];if(e.method!=="GET"){ft(this,e,t,405,"Invalid HTTP method");return}if(e.headers.upgrade.toLowerCase()!=="websocket"){ft(this,e,t,400,"Invalid Upgrade header");return}if(!s||!Sl.test(s)){ft(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(o!==8&&o!==13){ft(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header");return}if(!this.shouldHandle(e)){li(t,400);return}let c=e.headers["sec-websocket-protocol"],l=new Set;if(c!==void 0)try{l=yl.parse(c)}catch(f){ft(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let u=e.headers["sec-websocket-extensions"],h={};if(this.options.perMessageDeflate&&u!==void 0){let f=new ht(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let d=wo.parse(u);d[ht.extensionName]&&(f.accept(d[ht.extensionName]),h[ht.extensionName]=f)}catch(d){ft(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let f={origin:e.headers[`${o===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(f,(d,p,x,g)=>{if(!d)return li(t,p||401,x,g);this.completeUpgrade(h,s,l,e,t,r,n)});return}if(!this.options.verifyClient(f))return li(t,401)}this.completeUpgrade(h,s,l,e,t,r,n)}completeUpgrade(e,t,r,n,s,o,c){if(!s.readable||!s.writable)return s.destroy();if(s[El])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Co)return li(s,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${gl("sha1").update(t+_l).digest("base64")}`],h=new this.options.WebSocket(null);if(r.size){let f=this.options.handleProtocols?this.options.handleProtocols(r,n):r.values().next().value;f&&(u.push(`Sec-WebSocket-Protocol: ${f}`),h._protocol=f)}if(e[ht.extensionName]){let f=e[ht.extensionName].params,d=wo.format({[ht.extensionName]:[f]});u.push(`Sec-WebSocket-Extensions: ${d}`),h._extensions=e}this.emit("headers",u,n),s.write(u.concat(`\r
|
|
3
|
+
`+s),i.push(n+"m+"+Cr.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=Fc()+e+" "+i[0]}function Fc(){return Y.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Uc(...i){return process.stderr.write(xr.formatWithOptions(Y.inspectOpts,...i)+`
|
|
4
|
+
`)}function Dc(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function Bc(){return process.env.DEBUG}function Mc(i){i.inspectOpts={};let e=Object.keys(Y.inspectOpts);for(let t=0;t<e.length;t++)i.inspectOpts[e[t]]=Y.inspectOpts[e[t]]}Cr.exports=pn()(Y);var{formatters:Hs}=Cr.exports;Hs.o=function(i){return this.inspectOpts.colors=this.useColors,xr.inspect(i,this.inspectOpts).split(`
|
|
5
|
+
`).map(e=>e.trim()).join(" ")};Hs.O=function(i){return this.inspectOpts.colors=this.useColors,xr.inspect(i,this.inspectOpts)}});var St=F((wd,vn)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?vn.exports=Ws():vn.exports=js()});var ro=F((Td,io)=>{"use strict";var Bt=I("fs"),to=I("url"),$c=I("child_process").spawn;io.exports=_n;_n.XMLHttpRequest=_n;function _n(i){"use strict";i=i||{};var e=this,t=I("http"),r=I("https"),n,s,o={},c=!1,l={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},h=Object.assign({},l),u=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","content-transfer-encoding","cookie","cookie2","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"],f=["TRACE","TRACK","CONNECT"],p=!1,m=!1,C=!1,b={};this.UNSENT=0,this.OPENED=1,this.HEADERS_RECEIVED=2,this.LOADING=3,this.DONE=4,this.readyState=this.UNSENT,this.onreadystatechange=null,this.responseText="",this.responseXML="",this.status=null,this.statusText=null;var _=function(S){return c||S&&u.indexOf(S.toLowerCase())===-1},T=function(S){return S&&f.indexOf(S)===-1};this.open=function(S,E,V,R,P){if(this.abort(),m=!1,C=!1,!T(S))throw new Error("SecurityError: Request method not allowed");o={method:S,url:E.toString(),async:typeof V!="boolean"?!0:V,user:R||null,password:P||null},N(this.OPENED)},this.setDisableHeaderCheck=function(S){c=S},this.setRequestHeader=function(S,E){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");if(!_(S))return console.warn('Refused to set unsafe header "'+S+'"'),!1;if(p)throw new Error("INVALID_STATE_ERR: send flag is true");return h[S]=E,!0},this.getResponseHeader=function(S){return typeof S=="string"&&this.readyState>this.OPENED&&s.headers[S.toLowerCase()]&&!m?s.headers[S.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState<this.HEADERS_RECEIVED||m)return"";var S="";for(var E in s.headers)E!=="set-cookie"&&E!=="set-cookie2"&&(S+=E+": "+s.headers[E]+`\r
|
|
6
|
+
`);return S.substr(0,S.length-2)},this.getRequestHeader=function(S){return typeof S=="string"&&h[S]?h[S]:""},this.send=function(S){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,V=!1,R=to.parse(o.url),P;switch(R.protocol){case"https:":E=!0;case"http:":P=R.hostname;break;case"file:":V=!0;break;case void 0:case"":P="localhost";break;default:throw new Error("Protocol not supported.")}if(V){if(o.method!=="GET")throw new Error("XMLHttpRequest: Only GET method is supported");if(o.async)Bt.readFile(unescape(R.pathname),"utf8",function(ye,kt){ye?e.handleError(ye,ye.errno||-1):(e.status=200,e.responseText=kt,N(e.DONE))});else try{this.responseText=Bt.readFileSync(unescape(R.pathname),"utf8"),this.status=200,N(e.DONE)}catch(ye){this.handleError(ye,ye.errno||-1)}return}var $=R.port||(E?443:80),le=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 ht=new Buffer(o.user+":"+o.password);h.Authorization="Basic "+ht.toString("base64")}o.method==="GET"||o.method==="HEAD"?S=null:S?(h["Content-Length"]=Buffer.isBuffer(S)?S.length:Buffer.byteLength(S),h["Content-Type"]||(h["Content-Type"]="text/plain;charset=UTF-8")):o.method==="POST"&&(h["Content-Length"]=0);var ft=i.agent||!1,se={host:P,port:$,path:le,method:o.method,headers:h,agent:ft};if(E&&(se.pfx=i.pfx,se.key=i.key,se.passphrase=i.passphrase,se.cert=i.cert,se.ca=i.ca,se.ciphers=i.ciphers,se.rejectUnauthorized=i.rejectUnauthorized!==!1),m=!1,o.async){var Ye=E?r.request:t.request;p=!0,e.dispatchEvent("readystatechange");var Je=function(ye){if(s=ye,s.statusCode===302||s.statusCode===303||s.statusCode===307){o.url=s.headers.location;var kt=to.parse(o.url);P=kt.hostname;var Qe={hostname:kt.hostname,port:kt.port,path:kt.path,method:s.statusCode===303?"GET":o.method,headers:h};E&&(Qe.pfx=i.pfx,Qe.key=i.key,Qe.passphrase=i.passphrase,Qe.cert=i.cert,Qe.ca=i.ca,Qe.ciphers=i.ciphers,Qe.rejectUnauthorized=i.rejectUnauthorized!==!1),n=Ye(Qe,Je).on("error",Xe),n.end();return}s&&s.setEncoding&&s.setEncoding("utf8"),N(e.HEADERS_RECEIVED),e.status=s.statusCode,s.on("data",function(Mi){Mi&&(e.responseText+=Mi),p&&N(e.LOADING)}),s.on("end",function(){p&&(p=!1,N(e.DONE))}),s.on("error",function(Mi){e.handleError(Mi)})},Xe=function(ye){e.handleError(ye)};n=Ye(se,Je).on("error",Xe),i.autoUnref&&n.on("socket",ye=>{ye.unref()}),S&&n.write(S),n.end(),e.dispatchEvent("loadstart")}else{var be=".node-xmlhttprequest-content-"+process.pid,Se=".node-xmlhttprequest-sync-"+process.pid;Bt.writeFileSync(Se,"","utf8");for(var Fe="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(E?"s":"")+".request;var options = "+JSON.stringify(se)+";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('"+be+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+Se+"');});response.on('error', function(error) {fs.writeFileSync('"+be+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+Se+"');});}).on('error', function(error) {fs.writeFileSync('"+be+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+Se+"');});"+(S?"req.write('"+JSON.stringify(S).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",Ba=$c(process.argv[0],["-e",Fe]),Du;Bt.existsSync(Se););if(e.responseText=Bt.readFileSync(be,"utf8"),Ba.stdin.end(),Bt.unlinkSync(be),e.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var Ma=e.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");e.handleError(Ma,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(S,E){this.status=E||0,this.statusText=S,this.responseText=S.stack,m=!0,N(this.DONE)},this.abort=function(){n&&(n.abort(),n=null),h=Object.assign({},l),this.responseText="",this.responseXML="",m=C=!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(S,E){S in b||(b[S]=[]),b[S].push(E)},this.removeEventListener=function(S,E){S in b&&(b[S]=b[S].filter(function(V){return V!==E}))},this.dispatchEvent=function(S){if(typeof e["on"+S]=="function"&&(this.readyState===this.DONE?setImmediate(function(){e["on"+S]()}):e["on"+S]()),S in b)for(let E=0,V=b[S].length;E<V;E++)this.readyState===this.DONE?setImmediate(function(){b[S][E].call(e)}):b[S][E].call(e)};var N=function(S){if(!(e.readyState===S||e.readyState===e.UNSENT&&C)&&(e.readyState=S,(o.async||e.readyState<e.OPENED||e.readyState===e.DONE)&&e.dispatchEvent("readystatechange"),e.readyState===e.DONE)){let E;C?E="abort":m?E="error":E="load",e.dispatchEvent(E),e.dispatchEvent("loadend")}}}});var uo=F((Wd,lo)=>{"use strict";var{Duplex:Hc}=I("stream");function ao(i){i.emit("close")}function jc(){!this.destroyed&&this._writableState.finished&&this.destroy()}function co(i){this.removeListener("error",co),this.destroy(),this.listenerCount("error")===0&&this.emit("error",i)}function Gc(i,e){let t=!0,r=new Hc(x(y({},e),{autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1}));return i.on("message",function(s,o){let c=!o&&r._readableState.objectMode?s.toString():s;r.push(c)||i.pause()}),i.once("error",function(s){r.destroyed||(t=!1,r.destroy(s))}),i.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(n,s){if(i.readyState===i.CLOSED){s(n),process.nextTick(ao,r);return}let o=!1;i.once("error",function(l){o=!0,s(l)}),i.once("close",function(){o||s(n),process.nextTick(ao,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",jc),r.on("error",co),r}lo.exports=Gc});var ct=F((Kd,ho)=>{"use strict";ho.exports={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Si=F((zd,Rr)=>{"use strict";var{EMPTY_BUFFER:Yc}=ct();function Jc(i,e){if(i.length===0)return Yc;if(i.length===1)return i[0];let t=Buffer.allocUnsafe(e),r=0;for(let n=0;n<i.length;n++){let s=i[n];t.set(s,r),r+=s.length}return r<e?t.slice(0,r):t}function fo(i,e,t,r,n){for(let s=0;s<n;s++)t[r+s]=i[s]^e[s&3]}function po(i,e){for(let t=0;t<i.length;t++)i[t]^=e[t&3]}function Xc(i){return i.byteLength===i.buffer.byteLength?i.buffer:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}function Cn(i){if(Cn.readOnly=!0,Buffer.isBuffer(i))return i;let e;return i instanceof ArrayBuffer?e=Buffer.from(i):ArrayBuffer.isView(i)?e=Buffer.from(i.buffer,i.byteOffset,i.byteLength):(e=Buffer.from(i),Cn.readOnly=!1),e}Rr.exports={concat:Jc,mask:fo,toArrayBuffer:Xc,toBuffer:Cn,unmask:po};if(!process.env.WS_NO_BUFFER_UTIL)try{let i=I("bufferutil");Rr.exports.mask=function(e,t,r,n,s){s<48?fo(e,t,r,n,s):i.mask(e,t,r,n,s)},Rr.exports.unmask=function(e,t){e.length<32?po(e,t):i.unmask(e,t)}}catch(i){}});var go=F((Vd,yo)=>{"use strict";var mo=Symbol("kDone"),Nn=Symbol("kRun"),kn=class{constructor(e){this[mo]=()=>{this.pending--,this[Nn]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Nn]()}[Nn](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[mo])}}};yo.exports=kn});var wi=F((Hd,_o)=>{"use strict";var _i=I("zlib"),vo=Si(),Qc=go(),{kStatusCode:bo}=ct(),Zc=Buffer.from([0,0,255,255]),Or=Symbol("permessage-deflate"),Ve=Symbol("total-length"),Ei=Symbol("callback"),lt=Symbol("buffers"),Tr=Symbol("error"),Ir,An=class{constructor(e,t,r){if(this._maxPayload=r|0,this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!Ir){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Ir=new Qc(n)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Ei];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let t=this._options,r=e.find(n=>!(t.serverNoContextTakeover===!1&&n.server_no_context_takeover||n.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>n.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!n.client_max_window_bits));if(!r)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(r.server_no_context_takeover=!0),t.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof t.serverMaxWindowBits=="number"&&(r.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits=="number"?r.client_max_window_bits=t.clientMaxWindowBits:(r.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return t}normalizeParams(e){return e.forEach(t=>{Object.keys(t).forEach(r=>{let n=t[r];if(n.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(n=n[0],r==="client_max_window_bits"){if(n!==!0){let s=+n;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${n}`);n=s}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${n}`)}else if(r==="server_max_window_bits"){let s=+n;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${n}`);n=s}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(n!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${n}`)}else throw new Error(`Unknown parameter "${r}"`);t[r]=n})}),e}decompress(e,t,r){Ir.add(n=>{this._decompress(e,t,(s,o)=>{n(),r(s,o)})})}compress(e,t,r){Ir.add(n=>{this._compress(e,t,(s,o)=>{n(),r(s,o)})})}_decompress(e,t,r){let n=this._isServer?"client":"server";if(!this._inflate){let s=`${n}_max_window_bits`,o=typeof this.params[s]!="number"?_i.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=_i.createInflateRaw(x(y({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[Or]=this,this._inflate[Ve]=0,this._inflate[lt]=[],this._inflate.on("error",tl),this._inflate.on("data",So)}this._inflate[Ei]=r,this._inflate.write(e),t&&this._inflate.write(Zc),this._inflate.flush(()=>{let s=this._inflate[Tr];if(s){this._inflate.close(),this._inflate=null,r(s);return}let o=vo.concat(this._inflate[lt],this._inflate[Ve]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ve]=0,this._inflate[lt]=[],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"?_i.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=_i.createDeflateRaw(x(y({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[Ve]=0,this._deflate[lt]=[],this._deflate.on("data",el)}this._deflate[Ei]=r,this._deflate.write(e),this._deflate.flush(_i.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=vo.concat(this._deflate[lt],this._deflate[Ve]);t&&(s=s.slice(0,s.length-4)),this._deflate[Ei]=null,this._deflate[Ve]=0,this._deflate[lt]=[],t&&this.params[`${n}_no_context_takeover`]&&this._deflate.reset(),r(null,s)})}};_o.exports=An;function el(i){this[lt].push(i),this[Ve]+=i.length}function So(i){if(this[Ve]+=i.length,this[Or]._maxPayload<1||this[Ve]<=this[Or]._maxPayload){this[lt].push(i);return}this[Tr]=new RangeError("Max payload size exceeded"),this[Tr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Tr][bo]=1009,this.removeListener("data",So),this.reset()}function tl(i){this[Or]._inflate=null,i[bo]=1007,this[Ei](i)}});var xi=F((Gd,Rn)=>{"use strict";var il=[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 rl(i){return i>=1e3&&i<=1014&&i!==1004&&i!==1005&&i!==1006||i>=3e3&&i<=4999}function Eo(i){let e=i.length,t=0;for(;t<e;)if(!(i[t]&128))t++;else if((i[t]&224)===192){if(t+1===e||(i[t+1]&192)!==128||(i[t]&254)===192)return!1;t+=2}else if((i[t]&240)===224){if(t+2>=e||(i[t+1]&192)!==128||(i[t+2]&192)!==128||i[t]===224&&(i[t+1]&224)===128||i[t]===237&&(i[t+1]&224)===160)return!1;t+=3}else if((i[t]&248)===240){if(t+3>=e||(i[t+1]&192)!==128||(i[t+2]&192)!==128||(i[t+3]&192)!==128||i[t]===240&&(i[t+1]&240)===128||i[t]===244&&i[t+1]>143||i[t]>244)return!1;t+=4}else return!1;return!0}Rn.exports={isValidStatusCode:rl,isValidUTF8:Eo,tokenChars:il};if(!process.env.WS_NO_UTF_8_VALIDATE)try{let i=I("utf-8-validate");Rn.exports.isValidUTF8=function(e){return e.length<150?Eo(e):i(e)}}catch(i){}});var Pn=F((Yd,Ro)=>{"use strict";var{Writable:nl}=I("stream"),wo=wi(),{BINARY_TYPES:sl,EMPTY_BUFFER:xo,kStatusCode:ol,kWebSocket:al}=ct(),{concat:In,toArrayBuffer:cl,unmask:ll}=Si(),{isValidStatusCode:ul,isValidUTF8:Co}=xi(),Ci=0,No=1,ko=2,Ao=3,Tn=4,hl=5,On=class extends nl{constructor(e={}){super(),this._binaryType=e.binaryType||sl[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[al]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._state=Ci,this._loop=!1}_write(e,t,r){if(this._opcode===8&&this._state==Ci)return r();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=r.slice(e),r.slice(0,e)}let t=Buffer.allocUnsafe(e);do{let r=this._buffers[0],n=t.length-e;e>=r.length?t.set(this._buffers.shift(),n):(t.set(new Uint8Array(r.buffer,r.byteOffset,e),n),this._buffers[0]=r.slice(e)),e-=r.length}while(e>0);return t}startLoop(e){let t;this._loop=!0;do switch(this._state){case Ci:t=this.getInfo();break;case No:t=this.getPayloadLength16();break;case ko:t=this.getPayloadLength64();break;case Ao:this.getMask();break;case Tn:t=this.getData(e);break;default:this._loop=!1;return}while(this._loop);e(t)}getInfo(){if(this._bufferedBytes<2){this._loop=!1;return}let e=this.consume(2);if(e[0]&48)return this._loop=!1,K(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");let t=(e[0]&64)===64;if(t&&!this._extensions[wo.extensionName])return this._loop=!1,K(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._fin=(e[0]&128)===128,this._opcode=e[0]&15,this._payloadLength=e[1]&127,this._opcode===0){if(t)return this._loop=!1,K(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,K(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented)return this._loop=!1,K(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");this._compressed=t}else if(this._opcode>7&&this._opcode<11){if(!this._fin)return this._loop=!1,K(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(t)return this._loop=!1,K(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,K(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else return this._loop=!1,K(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(e[1]&128)===128,this._isServer){if(!this._masked)return this._loop=!1,K(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,K(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(this._payloadLength===126)this._state=No;else if(this._payloadLength===127)this._state=ko;else return this.haveLength()}getPayloadLength16(){if(this._bufferedBytes<2){this._loop=!1;return}return this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength()}getPayloadLength64(){if(this._bufferedBytes<8){this._loop=!1;return}let e=this.consume(8),t=e.readUInt32BE(0);return t>Math.pow(2,21)-1?(this._loop=!1,K(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=t*Math.pow(2,32)+e.readUInt32BE(4),this.haveLength())}haveLength(){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0))return this._loop=!1,K(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=Ao:this._state=Tn}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Tn}getData(e){let t=xo;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]&&ll(t,this._mask)}if(this._opcode>7)return this.controlMessage(t);if(this._compressed){this._state=hl,this.decompress(t,e);return}return t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage()}decompress(e,t){this._extensions[wo.extensionName].decompress(e,this._fin,(n,s)=>{if(n)return t(n);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return t(K(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(s)}let o=this.dataMessage();if(o)return t(o);this.startLoop(t)})}dataMessage(){if(this._fin){let e=this._messageLength,t=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let r;this._binaryType==="nodebuffer"?r=In(t,e):this._binaryType==="arraybuffer"?r=cl(In(t,e)):r=t,this.emit("message",r,!0)}else{let r=In(t,e);if(!this._skipUTF8Validation&&!Co(r))return this._loop=!1,K(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",r,!1)}}this._state=Ci}controlMessage(e){if(this._opcode===8)if(this._loop=!1,e.length===0)this.emit("conclude",1005,xo),this.end();else{if(e.length===1)return K(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{let t=e.readUInt16BE(0);if(!ul(t))return K(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let r=e.slice(2);if(!this._skipUTF8Validation&&!Co(r))return K(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("conclude",t,r),this.end()}}else this._opcode===9?this.emit("ping",e):this.emit("pong",e);this._state=Ci}};Ro.exports=On;function K(i,e,t,r,n){let s=new i(t?`Invalid WebSocket frame: ${e}`:e);return Error.captureStackTrace(s,K),s.code=n,s[ol]=r,s}});var Fn=F((Qd,Oo)=>{"use strict";var Jd=I("net"),Xd=I("tls"),{randomFillSync:fl}=I("crypto"),Io=wi(),{EMPTY_BUFFER:dl}=ct(),{isValidStatusCode:pl}=xi(),{mask:To,toBuffer:Mt}=Si(),ke=Symbol("kByteLength"),ml=Buffer.alloc(4),Ln=class i{constructor(e,t,r){this._extensions=t||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(e,t){let r,n=!1,s=2,o=!1;t.mask&&(r=t.maskBuffer||ml,t.generateMask?t.generateMask(r):fl(r,0,4),o=(r[0]|r[1]|r[2]|r[3])===0,s=6);let c;typeof e=="string"?(!t.mask||o)&&t[ke]!==void 0?c=t[ke]:(e=Buffer.from(e),c=e.length):(c=e.length,n=t.mask&&t.readOnly&&!o);let l=c;c>=65536?(s+=8,l=127):c>125&&(s+=2,l=126);let h=Buffer.allocUnsafe(n?c+s:s);return h[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(h[0]|=64),h[1]=l,l===126?h.writeUInt16BE(c,2):l===127&&(h[2]=h[3]=0,h.writeUIntBE(c,4,6)),t.mask?(h[1]|=128,h[s-4]=r[0],h[s-3]=r[1],h[s-2]=r[2],h[s-1]=r[3],o?[h,e]:n?(To(e,r,h,s,c),[h]):(To(e,r,e,0,c),[h,e])):[h,e]}close(e,t,r,n){let s;if(e===void 0)s=dl;else{if(typeof e!="number"||!pl(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={[ke]:s.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,s,!1,o,n]):this.sendFrame(i.frame(s,o),n)}ping(e,t,r){let n,s;if(typeof e=="string"?(n=Buffer.byteLength(e),s=!1):(e=Mt(e),n=e.length,s=Mt.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[ke]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:s,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(i.frame(e,o),r)}pong(e,t,r){let n,s;if(typeof e=="string"?(n=Buffer.byteLength(e),s=!1):(e=Mt(e),n=e.length,s=Mt.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[ke]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:s,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(i.frame(e,o),r)}send(e,t,r){let n=this._extensions[Io.extensionName],s=t.binary?2:1,o=t.compress,c,l;if(typeof e=="string"?(c=Buffer.byteLength(e),l=!1):(e=Mt(e),c=e.length,l=Mt.readOnly),this._firstFragment?(this._firstFragment=!1,o&&n&&n.params[n._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=c>=n._threshold),this._compress=o):(o=!1,s=0),t.fin&&(this._firstFragment=!0),n){let h={[ke]:c,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:l,rsv1:o};this._deflating?this.enqueue([this.dispatch,e,this._compress,h,r]):this.dispatch(e,this._compress,h,r)}else this.sendFrame(i.frame(e,{[ke]:c,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:l,rsv1:!1}),r)}dispatch(e,t,r,n){if(!t){this.sendFrame(i.frame(e,r),n);return}let s=this._extensions[Io.extensionName];this._bufferedBytes+=r[ke],this._deflating=!0,s.compress(e,r.fin,(o,c)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");typeof n=="function"&&n(l);for(let h=0;h<this._queue.length;h++){let u=this._queue[h],f=u[u.length-1];typeof f=="function"&&f(l)}return}this._bufferedBytes-=r[ke],this._deflating=!1,r.readOnly=!1,this.sendFrame(i.frame(c,r),n),this.dequeue()})}dequeue(){for(;!this._deflating&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ke],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ke],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)}};Oo.exports=Ln});var Wo=F((Zd,qo)=>{"use strict";var{kForOnEventAttribute:Ni,kListener:Un}=ct(),Po=Symbol("kCode"),Lo=Symbol("kData"),Fo=Symbol("kError"),Uo=Symbol("kMessage"),Do=Symbol("kReason"),qt=Symbol("kTarget"),Bo=Symbol("kType"),Mo=Symbol("kWasClean"),He=class{constructor(e){this[qt]=null,this[Bo]=e}get target(){return this[qt]}get type(){return this[Bo]}};Object.defineProperty(He.prototype,"target",{enumerable:!0});Object.defineProperty(He.prototype,"type",{enumerable:!0});var _t=class extends He{constructor(e,t={}){super(e),this[Po]=t.code===void 0?0:t.code,this[Do]=t.reason===void 0?"":t.reason,this[Mo]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[Po]}get reason(){return this[Do]}get wasClean(){return this[Mo]}};Object.defineProperty(_t.prototype,"code",{enumerable:!0});Object.defineProperty(_t.prototype,"reason",{enumerable:!0});Object.defineProperty(_t.prototype,"wasClean",{enumerable:!0});var Wt=class extends He{constructor(e,t={}){super(e),this[Fo]=t.error===void 0?null:t.error,this[Uo]=t.message===void 0?"":t.message}get error(){return this[Fo]}get message(){return this[Uo]}};Object.defineProperty(Wt.prototype,"error",{enumerable:!0});Object.defineProperty(Wt.prototype,"message",{enumerable:!0});var ki=class extends He{constructor(e,t={}){super(e),this[Lo]=t.data===void 0?null:t.data}get data(){return this[Lo]}};Object.defineProperty(ki.prototype,"data",{enumerable:!0});var yl={addEventListener(i,e,t={}){for(let n of this.listeners(i))if(!t[Ni]&&n[Un]===e&&!n[Ni])return;let r;if(i==="message")r=function(s,o){let c=new ki("message",{data:o?s:s.toString()});c[qt]=this,Pr(e,this,c)};else if(i==="close")r=function(s,o){let c=new _t("close",{code:s,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});c[qt]=this,Pr(e,this,c)};else if(i==="error")r=function(s){let o=new Wt("error",{error:s,message:s.message});o[qt]=this,Pr(e,this,o)};else if(i==="open")r=function(){let s=new He("open");s[qt]=this,Pr(e,this,s)};else return;r[Ni]=!!t[Ni],r[Un]=e,t.once?this.once(i,r):this.on(i,r)},removeEventListener(i,e){for(let t of this.listeners(i))if(t[Un]===e&&!t[Ni]){this.removeListener(i,t);break}}};qo.exports={CloseEvent:_t,ErrorEvent:Wt,Event:He,EventTarget:yl,MessageEvent:ki};function Pr(i,e,t){typeof i=="object"&&i.handleEvent?i.handleEvent.call(i,t):i.call(e,t)}});var Dn=F((ep,$o)=>{"use strict";var{tokenChars:Ai}=xi();function Pe(i,e,t){i[e]===void 0?i[e]=[t]:i[e].push(t)}function gl(i){let e=Object.create(null),t=Object.create(null),r=!1,n=!1,s=!1,o,c,l=-1,h=-1,u=-1,f=0;for(;f<i.length;f++)if(h=i.charCodeAt(f),o===void 0)if(u===-1&&Ai[h]===1)l===-1&&(l=f);else if(f!==0&&(h===32||h===9))u===-1&&l!==-1&&(u=f);else if(h===59||h===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);u===-1&&(u=f);let m=i.slice(l,u);h===44?(Pe(e,m,t),t=Object.create(null)):o=m,l=u=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);else if(c===void 0)if(u===-1&&Ai[h]===1)l===-1&&(l=f);else if(h===32||h===9)u===-1&&l!==-1&&(u=f);else if(h===59||h===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);u===-1&&(u=f),Pe(t,i.slice(l,u),!0),h===44&&(Pe(e,o,t),t=Object.create(null),o=void 0),l=u=-1}else if(h===61&&l!==-1&&u===-1)c=i.slice(l,f),l=u=-1;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(n){if(Ai[h]!==1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1?l=f:r||(r=!0),n=!1}else if(s)if(Ai[h]===1)l===-1&&(l=f);else if(h===34&&l!==-1)s=!1,u=f;else if(h===92)n=!0;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(h===34&&i.charCodeAt(f-1)===61)s=!0;else if(u===-1&&Ai[h]===1)l===-1&&(l=f);else if(l!==-1&&(h===32||h===9))u===-1&&(u=f);else if(h===59||h===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);u===-1&&(u=f);let m=i.slice(l,u);r&&(m=m.replace(/\\/g,""),r=!1),Pe(t,c,m),h===44&&(Pe(e,o,t),t=Object.create(null),o=void 0),c=void 0,l=u=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);if(l===-1||s||h===32||h===9)throw new SyntaxError("Unexpected end of input");u===-1&&(u=f);let p=i.slice(l,u);return o===void 0?Pe(e,p,t):(c===void 0?Pe(t,p,!0):r?Pe(t,c,p.replace(/\\/g,"")):Pe(t,c,p),Pe(e,o,t)),e}function vl(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(", ")}$o.exports={format:vl,parse:gl}});var $n=F((ip,Zo)=>{"use strict";var bl=I("events"),Sl=I("https"),_l=I("http"),Vo=I("net"),El=I("tls"),{randomBytes:wl,createHash:xl}=I("crypto"),{Readable:tp}=I("stream"),{URL:Bn}=I("url"),ut=wi(),Cl=Pn(),Nl=Fn(),{BINARY_TYPES:Ko,EMPTY_BUFFER:Lr,GUID:kl,kForOnEventAttribute:Mn,kListener:Al,kStatusCode:Rl,kWebSocket:ne,NOOP:Ho}=ct(),{EventTarget:{addEventListener:Il,removeEventListener:Tl}}=Wo(),{format:Ol,parse:Pl}=Dn(),{toBuffer:Ll}=Si(),Fl=30*1e3,jo=Symbol("kAborted"),qn=[8,13],je=["CONNECTING","OPEN","CLOSING","CLOSED"],Ul=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,W=class i extends bl{constructor(e,t,r){super(),this._binaryType=Ko[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Lr,this._closeTimer=null,this._extensions={},this._paused=!1,this._protocol="",this._readyState=i.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,t===void 0?t=[]:Array.isArray(t)||(typeof t=="object"&&t!==null?(r=t,t=[]):t=[t]),Go(this,e,t,r)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){Ko.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 Cl({binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation});this._sender=new Nl(e,this._extensions,r.generateMask),this._receiver=n,this._socket=e,n[ne]=this,e[ne]=this,n.on("conclude",Ml),n.on("drain",ql),n.on("error",Wl),n.on("message",$l),n.on("ping",Kl),n.on("pong",zl),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",Jo),e.on("data",Ur),e.on("end",Xo),e.on("error",Qo),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[ut.extensionName]&&this._extensions[ut.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=i.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==i.CLOSED){if(this.readyState===i.CONNECTING)return fe(this,this._req,"WebSocket was closed before the connection was established");if(this.readyState===i.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=i.CLOSING,this._sender.close(e,t,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),Fl)}}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){Wn(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||Lr,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){Wn(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||Lr,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){Wn(this,e,r);return}let n=y({binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0},t);this._extensions[ut.extensionName]||(n.compress=!1),this._sender.send(e||Lr,n,r)}terminate(){if(this.readyState!==i.CLOSED){if(this.readyState===i.CONNECTING)return fe(this,this._req,"WebSocket was closed before the connection was established");this._socket&&(this._readyState=i.CLOSING,this._socket.destroy())}}};Object.defineProperty(W,"CONNECTING",{enumerable:!0,value:je.indexOf("CONNECTING")});Object.defineProperty(W.prototype,"CONNECTING",{enumerable:!0,value:je.indexOf("CONNECTING")});Object.defineProperty(W,"OPEN",{enumerable:!0,value:je.indexOf("OPEN")});Object.defineProperty(W.prototype,"OPEN",{enumerable:!0,value:je.indexOf("OPEN")});Object.defineProperty(W,"CLOSING",{enumerable:!0,value:je.indexOf("CLOSING")});Object.defineProperty(W.prototype,"CLOSING",{enumerable:!0,value:je.indexOf("CLOSING")});Object.defineProperty(W,"CLOSED",{enumerable:!0,value:je.indexOf("CLOSED")});Object.defineProperty(W.prototype,"CLOSED",{enumerable:!0,value:je.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(i=>{Object.defineProperty(W.prototype,i,{enumerable:!0})});["open","error","close","message"].forEach(i=>{Object.defineProperty(W.prototype,`on${i}`,{enumerable:!0,get(){for(let e of this.listeners(i))if(e[Mn])return e[Al];return null},set(e){for(let t of this.listeners(i))if(t[Mn]){this.removeListener(i,t);break}typeof e=="function"&&this.addEventListener(i,e,{[Mn]:!0})}})});W.prototype.addEventListener=Il;W.prototype.removeEventListener=Tl;Zo.exports=W;function Go(i,e,t,r){let n=x(y({protocolVersion:qn[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10},r),{createConnection:void 0,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0});if(!qn.includes(n.protocolVersion))throw new RangeError(`Unsupported protocol version: ${n.protocolVersion} (supported versions: ${qn.join(", ")})`);let s;if(e instanceof Bn)s=e,i._url=e.href;else{try{s=new Bn(e)}catch(b){throw new SyntaxError(`Invalid URL: ${e}`)}i._url=e}let o=s.protocol==="wss:",c=s.protocol==="ws+unix:",l;if(s.protocol!=="ws:"&&!o&&!c?l=`The URL's protocol must be one of "ws:", "wss:", or "ws+unix:"`:c&&!s.pathname?l="The URL's pathname is empty":s.hash&&(l="The URL contains a fragment identifier"),l){let b=new SyntaxError(l);if(i._redirects===0)throw b;Fr(i,b);return}let h=o?443:80,u=wl(16).toString("base64"),f=o?Sl.request:_l.request,p=new Set,m;if(n.createConnection=o?Bl:Dl,n.defaultPort=n.defaultPort||h,n.port=s.port||h,n.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,n.headers=x(y({},n.headers),{"Sec-WebSocket-Version":n.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"}),n.path=s.pathname+s.search,n.timeout=n.handshakeTimeout,n.perMessageDeflate&&(m=new ut(n.perMessageDeflate!==!0?n.perMessageDeflate:{},!1,n.maxPayload),n.headers["Sec-WebSocket-Extensions"]=Ol({[ut.extensionName]:m.offer()})),t.length){for(let b of t){if(typeof b!="string"||!Ul.test(b)||p.has(b))throw new SyntaxError("An invalid or duplicated subprotocol was specified");p.add(b)}n.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(n.origin&&(n.protocolVersion<13?n.headers["Sec-WebSocket-Origin"]=n.origin:n.headers.Origin=n.origin),(s.username||s.password)&&(n.auth=`${s.username}:${s.password}`),c){let b=n.path.split(":");n.socketPath=b[0],n.path=b[1]}let C;if(n.followRedirects){if(i._redirects===0){i._originalIpc=c,i._originalSecure=o,i._originalHostOrSocketPath=c?n.socketPath:s.host;let b=r&&r.headers;if(r=x(y({},r),{headers:{}}),b)for(let[_,T]of Object.entries(b))r.headers[_.toLowerCase()]=T}else if(i.listenerCount("redirect")===0){let b=c?i._originalIpc?n.socketPath===i._originalHostOrSocketPath:!1:i._originalIpc?!1:s.host===i._originalHostOrSocketPath;(!b||i._originalSecure&&!o)&&(delete n.headers.authorization,delete n.headers.cookie,b||delete n.headers.host,n.auth=void 0)}n.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(n.auth).toString("base64")),C=i._req=f(n),i._redirects&&i.emit("redirect",i.url,C)}else C=i._req=f(n);n.timeout&&C.on("timeout",()=>{fe(i,C,"Opening handshake has timed out")}),C.on("error",b=>{C===null||C[jo]||(C=i._req=null,Fr(i,b))}),C.on("response",b=>{let _=b.headers.location,T=b.statusCode;if(_&&n.followRedirects&&T>=300&&T<400){if(++i._redirects>n.maxRedirects){fe(i,C,"Maximum redirects exceeded");return}C.abort();let N;try{N=new Bn(_,e)}catch(S){let E=new SyntaxError(`Invalid URL: ${_}`);Fr(i,E);return}Go(i,N,t,r)}else i.emit("unexpected-response",C,b)||fe(i,C,`Unexpected server response: ${b.statusCode}`)}),C.on("upgrade",(b,_,T)=>{if(i.emit("upgrade",b),i.readyState!==W.CONNECTING)return;if(C=i._req=null,b.headers.upgrade.toLowerCase()!=="websocket"){fe(i,_,"Invalid Upgrade header");return}let N=xl("sha1").update(u+kl).digest("base64");if(b.headers["sec-websocket-accept"]!==N){fe(i,_,"Invalid Sec-WebSocket-Accept header");return}let S=b.headers["sec-websocket-protocol"],E;if(S!==void 0?p.size?p.has(S)||(E="Server sent an invalid subprotocol"):E="Server sent a subprotocol but none was requested":p.size&&(E="Server sent no subprotocol"),E){fe(i,_,E);return}S&&(i._protocol=S);let V=b.headers["sec-websocket-extensions"];if(V!==void 0){if(!m){fe(i,_,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let R;try{R=Pl(V)}catch($){fe(i,_,"Invalid Sec-WebSocket-Extensions header");return}let P=Object.keys(R);if(P.length!==1||P[0]!==ut.extensionName){fe(i,_,"Server indicated an extension that was not requested");return}try{m.accept(R[ut.extensionName])}catch($){fe(i,_,"Invalid Sec-WebSocket-Extensions header");return}i._extensions[ut.extensionName]=m}i.setSocket(_,T,{generateMask:n.generateMask,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation})}),C.end()}function Fr(i,e){i._readyState=W.CLOSING,i.emit("error",e),i.emitClose()}function Dl(i){return i.path=i.socketPath,Vo.connect(i)}function Bl(i){return i.path=void 0,!i.servername&&i.servername!==""&&(i.servername=Vo.isIP(i.host)?"":i.host),El.connect(i)}function fe(i,e,t){i._readyState=W.CLOSING;let r=new Error(t);Error.captureStackTrace(r,fe),e.setHeader?(e[jo]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Fr,i,r)):(e.destroy(r),e.once("error",i.emit.bind(i,"error")),e.once("close",i.emitClose.bind(i)))}function Wn(i,e,t){if(e){let r=Ll(e).length;i._socket?i._sender._bufferedBytes+=r:i._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${i.readyState} (${je[i.readyState]})`);t(r)}}function Ml(i,e){let t=this[ne];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=i,t._socket[ne]!==void 0&&(t._socket.removeListener("data",Ur),process.nextTick(Yo,t._socket),i===1005?t.close():t.close(i,e))}function ql(){let i=this[ne];i.isPaused||i._socket.resume()}function Wl(i){let e=this[ne];e._socket[ne]!==void 0&&(e._socket.removeListener("data",Ur),process.nextTick(Yo,e._socket),e.close(i[Rl])),e.emit("error",i)}function zo(){this[ne].emitClose()}function $l(i,e){this[ne].emit("message",i,e)}function Kl(i){let e=this[ne];e.pong(i,!e._isServer,Ho),e.emit("ping",i)}function zl(i){this[ne].emit("pong",i)}function Yo(i){i.resume()}function Jo(){let i=this[ne];this.removeListener("close",Jo),this.removeListener("data",Ur),this.removeListener("end",Xo),i._readyState=W.CLOSING;let e;!this._readableState.endEmitted&&!i._closeFrameReceived&&!i._receiver._writableState.errorEmitted&&(e=i._socket.read())!==null&&i._receiver.write(e),i._receiver.end(),this[ne]=void 0,clearTimeout(i._closeTimer),i._receiver._writableState.finished||i._receiver._writableState.errorEmitted?i.emitClose():(i._receiver.on("error",zo),i._receiver.on("finish",zo))}function Ur(i){this[ne]._receiver.write(i)||this.pause()}function Xo(){let i=this[ne];i._readyState=W.CLOSING,i._receiver.end(),this.end()}function Qo(){let i=this[ne];this.removeListener("error",Qo),this.on("error",Ho),i&&(i._readyState=W.CLOSING,this.destroy())}});var ta=F((np,ea)=>{"use strict";var{tokenChars:Vl}=xi();function Hl(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&&Vl[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}ea.exports={parse:Hl}});var ca=F((cp,aa)=>{"use strict";var jl=I("events"),Dr=I("http"),sp=I("https"),op=I("net"),ap=I("tls"),{createHash:Gl}=I("crypto"),ia=Dn(),Et=wi(),Yl=ta(),Jl=$n(),{GUID:Xl,kWebSocket:Ql}=ct(),Zl=/^[+/0-9A-Za-z]{22}==$/,ra=0,na=1,oa=2,Kn=class extends jl{constructor(e,t){if(super(),e=y({maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Jl},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=Dr.createServer((r,n)=>{let s=Dr.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=eu(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=ra}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===oa){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Ri,this);return}if(e&&this.once("close",e),this._state!==na)if(this._state=na,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(Ri,this):process.nextTick(Ri,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{Ri(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf("?");if((t!==-1?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,r,n){t.on("error",sa);let s=e.headers["sec-websocket-key"],o=+e.headers["sec-websocket-version"];if(e.method!=="GET"){wt(this,e,t,405,"Invalid HTTP method");return}if(e.headers.upgrade.toLowerCase()!=="websocket"){wt(this,e,t,400,"Invalid Upgrade header");return}if(!s||!Zl.test(s)){wt(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(o!==8&&o!==13){wt(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header");return}if(!this.shouldHandle(e)){Ii(t,400);return}let c=e.headers["sec-websocket-protocol"],l=new Set;if(c!==void 0)try{l=Yl.parse(c)}catch(f){wt(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let h=e.headers["sec-websocket-extensions"],u={};if(this.options.perMessageDeflate&&h!==void 0){let f=new Et(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let p=ia.parse(h);p[Et.extensionName]&&(f.accept(p[Et.extensionName]),u[Et.extensionName]=f)}catch(p){wt(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let f={origin:e.headers[`${o===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(f,(p,m,C,b)=>{if(!p)return Ii(t,m||401,C,b);this.completeUpgrade(u,s,l,e,t,r,n)});return}if(!this.options.verifyClient(f))return Ii(t,401)}this.completeUpgrade(u,s,l,e,t,r,n)}completeUpgrade(e,t,r,n,s,o,c){if(!s.readable||!s.writable)return s.destroy();if(s[Ql])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>ra)return Ii(s,503);let h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Gl("sha1").update(t+Xl).digest("base64")}`],u=new this.options.WebSocket(null);if(r.size){let f=this.options.handleProtocols?this.options.handleProtocols(r,n):r.values().next().value;f&&(h.push(`Sec-WebSocket-Protocol: ${f}`),u._protocol=f)}if(e[Et.extensionName]){let f=e[Et.extensionName].params,p=ia.format({[Et.extensionName]:[f]});h.push(`Sec-WebSocket-Extensions: ${p}`),u._extensions=e}this.emit("headers",h,n),s.write(h.concat(`\r
|
|
7
7
|
`).join(`\r
|
|
8
|
-
`)),s.removeListener("error",
|
|
8
|
+
`)),s.removeListener("error",sa),u.setSocket(s,o,{maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(u),u.on("close",()=>{this.clients.delete(u),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Ri,this)})),c(u,n)}};aa.exports=Kn;function eu(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 Ri(i){i._state=oa,i.emit("close")}function sa(){this.destroy()}function Ii(i,e,t,r){t=t||Dr.STATUS_CODES[e],r=y({Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t)},r),i.once("finish",i.destroy),i.end(`HTTP/1.1 ${e} ${Dr.STATUS_CODES[e]}\r
|
|
9
9
|
`+Object.keys(r).map(n=>`${n}: ${r[n]}`).join(`\r
|
|
10
10
|
`)+`\r
|
|
11
11
|
\r
|
|
12
|
-
`+t)}function
|
|
12
|
+
`+t)}function wt(i,e,t,r,n){if(i.listenerCount("wsClientError")){let s=new Error(n);Error.captureStackTrace(s,wt),i.emit("wsClientError",s,t,e)}else Ii(t,r,n)}});var Vn=F((zp,ya)=>{"use strict";function uu(i){t.debug=t,t.default=t,t.coerce=l,t.disable=s,t.enable=n,t.enabled=o,t.humanize=dn(),t.destroy=h,Object.keys(i).forEach(u=>{t[u]=i[u]}),t.names=[],t.skips=[],t.formatters={};function e(u){let f=0;for(let p=0;p<u.length;p++)f=(f<<5)-f+u.charCodeAt(p),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(u){let f,p=null,m,C;function b(..._){if(!b.enabled)return;let T=b,N=Number(new Date),S=N-(f||N);T.diff=S,T.prev=f,T.curr=N,f=N,_[0]=t.coerce(_[0]),typeof _[0]!="string"&&_.unshift("%O");let E=0;_[0]=_[0].replace(/%([a-zA-Z%])/g,(R,P)=>{if(R==="%%")return"%";E++;let $=t.formatters[P];if(typeof $=="function"){let le=_[E];R=$.call(T,le),_.splice(E,1),E--}return R}),t.formatArgs.call(T,_),(T.log||t.log).apply(T,_)}return b.namespace=u,b.useColors=t.useColors(),b.color=t.selectColor(u),b.extend=r,b.destroy=t.destroy,Object.defineProperty(b,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(m!==t.namespaces&&(m=t.namespaces,C=t.enabled(u)),C),set:_=>{p=_}}),typeof t.init=="function"&&t.init(b),b}function r(u,f){let p=t(this.namespace+(typeof f=="undefined"?":":f)+u);return p.log=this.log,p}function n(u){t.save(u),t.namespaces=u,t.names=[],t.skips=[];let f,p=(typeof u=="string"?u:"").split(/[\s,]+/),m=p.length;for(f=0;f<m;f++)p[f]&&(u=p[f].replace(/\*/g,".*?"),u[0]==="-"?t.skips.push(new RegExp("^"+u.slice(1)+"$")):t.names.push(new RegExp("^"+u+"$")))}function s(){let u=[...t.names.map(c),...t.skips.map(c).map(f=>"-"+f)].join(",");return t.enable(""),u}function o(u){if(u[u.length-1]==="*")return!0;let f,p;for(f=0,p=t.skips.length;f<p;f++)if(t.skips[f].test(u))return!1;for(f=0,p=t.names.length;f<p;f++)if(t.names[f].test(u))return!0;return!1}function c(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function l(u){return u instanceof Error?u.stack||u.message:u}function h(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}ya.exports=uu});var ga=F((de,Wr)=>{"use strict";de.formatArgs=fu;de.save=du;de.load=pu;de.useColors=hu;de.storage=mu();de.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`."))}})();de.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 hu(){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 fu(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)}de.log=console.debug||console.log||(()=>{});function du(i){try{i?de.storage.setItem("debug",i):de.storage.removeItem("debug")}catch(e){}}function pu(){let i;try{i=de.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function mu(){try{return localStorage}catch(i){}}Wr.exports=Vn()(de);var{formatters:yu}=Wr.exports;yu.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var ba=F((J,Kr)=>{"use strict";var gu=I("tty"),$r=I("util");J.init=xu;J.log=_u;J.formatArgs=bu;J.save=Eu;J.load=wu;J.useColors=vu;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=gn();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 vu(){return"colors"in J.inspectOpts?!!J.inspectOpts.colors:gu.isatty(process.stderr.fd)}function bu(i){let{namespace:e,useColors:t}=this;if(t){let r=this.color,n="\x1B[3"+(r<8?r:"8;5;"+r),s=` ${n};1m${e} \x1B[0m`;i[0]=s+i[0].split(`
|
|
13
13
|
`).join(`
|
|
14
|
-
`+s),i.push(n+"m+"+
|
|
15
|
-
`)}function
|
|
16
|
-
`).map(e=>e.trim()).join(" ")};qo.O=function(i){return this.inspectOpts.colors=this.useColors,gr.inspect(i,this.inspectOpts)}});var ui=F((qd,En)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?En.exports=Mo():En.exports=Wo()});var ga="v1",ya=`${PACKAGE_NAME}@${PACKAGE_VERSION}`,Ei=class{constructor(e={}){this.DEFAULT_BACKEND_URL=typeof window!="undefined"&&window.NOVU_LOCAL_BACKEND_URL||"https://api.novu.co";let{apiVersion:t=ga,apiUrl:r=this.DEFAULT_BACKEND_URL,userAgent:n=ya,headers:s={}}=e||{};this.apiVersion=t,this.apiUrl=`${r}/${t}`,this.headers=E({"Novu-API-Version":NOVU_API_VERSION,"Content-Type":"application/json","User-Agent":n},s)}setAuthorizationToken(e){this.headers.Authorization=`Bearer ${e}`}setKeylessHeader(e){var r;let t=e||typeof window!="undefined"&&((r=window.localStorage)==null?void 0:r.getItem("novu_keyless_application_identifier"));!t||!t.startsWith("pk_keyless_")||(this.headers["Novu-Application-Identifier"]=t)}setHeaders(e){this.headers=E(E({},this.headers),e)}get(e,t,r=!0){return m(this,null,function*(){return this.doFetch({path:e,searchParams:t,options:{method:"GET"},unwrapEnvelope:r})})}post(e,t,r){return m(this,null,function*(){return this.doFetch({path:e,options:{method:"POST",body:t,headers:r==null?void 0:r.headers}})})}patch(e,t){return m(this,null,function*(){return this.doFetch({path:e,options:{method:"PATCH",body:t}})})}delete(e,t){return m(this,null,function*(){return this.doFetch({path:e,options:{method:"DELETE",body:t}})})}doFetch(s){return m(this,arguments,function*({path:e,searchParams:t,options:r,unwrapEnvelope:n=!0}){let o=va(this.apiUrl,e,t?`?${t.toString()}`:""),c={method:(r==null?void 0:r.method)||"GET",headers:E(E({},this.headers),(r==null?void 0:r.headers)||{}),body:r!=null&&r.body?JSON.stringify(r.body):void 0},l=yield fetch(o,c);if(!l.ok){let h=yield l.json();throw new Error(`${this.headers["User-Agent"]} error. Status: ${l.status}, Message: ${h.message}`)}if(l.status===204)return;let u=yield l.json();return n?u.data:u})}};function va(...i){return i.reduce((e,t)=>(t&&e.push(t.replace(new RegExp("(?<!https?:)\\/+","g"),"/").replace(/^\/+|\/+$/g,"")),e),[]).join("/").replace(/\/\?/,"?")}var tt="/inbox",Z=`${tt}/notifications`,O,Si=class{constructor(e={}){this.isSessionInitialized=!1;_(this,O);S(this,O,new Ei(e))}initializeSession(c){return m(this,arguments,function*({applicationIdentifier:e,subscriberHash:t,contextHash:r,subscriber:n,defaultSchedule:s,context:o}){let l=yield a(this,O).post(`${tt}/session`,{applicationIdentifier:e,subscriberHash:t,contextHash:r,subscriber:n,defaultSchedule:s,context:o});return a(this,O).setAuthorizationToken(l.token),a(this,O).setKeylessHeader(l.applicationIdentifier),this.isSessionInitialized=!0,l})}fetchNotifications({after:e,archived:t,limit:r=10,offset:n,read:s,tags:o,snoozed:c,seen:l,data:u,severity:h}){let f=new URLSearchParams(`limit=${r}`);if(e&&f.append("after",e),n&&f.append("offset",`${n}`),o)for(let d of o)f.append("tags[]",d);if(s!==void 0&&f.append("read",`${s}`),t!==void 0&&f.append("archived",`${t}`),c!==void 0&&f.append("snoozed",`${c}`),l!==void 0&&f.append("seen",`${l}`),u!==void 0&&f.append("data",JSON.stringify(u)),h&&Array.isArray(h))for(let d of h)f.append("severity[]",d);else h&&f.append("severity",h);return a(this,O).get(Z,f,!1)}count({filters:e}){return a(this,O).get(`${Z}/count`,new URLSearchParams({filters:JSON.stringify(e)}),!1)}read(e){return a(this,O).patch(`${Z}/${e}/read`)}unread(e){return a(this,O).patch(`${Z}/${e}/unread`)}archive(e){return a(this,O).patch(`${Z}/${e}/archive`)}unarchive(e){return a(this,O).patch(`${Z}/${e}/unarchive`)}snooze(e,t){return a(this,O).patch(`${Z}/${e}/snooze`,{snoozeUntil:t})}unsnooze(e){return a(this,O).patch(`${Z}/${e}/unsnooze`)}readAll({tags:e,data:t}){return a(this,O).post(`${Z}/read`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAll({tags:e,data:t}){return a(this,O).post(`${Z}/archive`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAllRead({tags:e,data:t}){return a(this,O).post(`${Z}/read-archive`,{tags:e,data:t?JSON.stringify(t):void 0})}delete(e){return a(this,O).delete(`${Z}/${e}/delete`)}deleteAll({tags:e,data:t}){return a(this,O).post(`${Z}/delete`,{tags:e,data:t?JSON.stringify(t):void 0})}markAsSeen({notificationIds:e,tags:t,data:r}){return a(this,O).post(`${Z}/seen`,{notificationIds:e,tags:t,data:r?JSON.stringify(r):void 0})}seen(e){return this.markAsSeen({notificationIds:[e]})}completeAction({actionType:e,notificationId:t}){return a(this,O).patch(`${Z}/${t}/complete`,{actionType:e})}revertAction({actionType:e,notificationId:t}){return a(this,O).patch(`${Z}/${t}/revert`,{actionType:e})}fetchPreferences({tags:e,severity:t,criticality:r}){let n=new URLSearchParams;if(e)for(let o of e)n.append("tags[]",o);if(t&&Array.isArray(t))for(let o of t)n.append("severity[]",o);else t&&n.append("severity",t);r&&n.append("criticality",r);let s=n.size?`?${n.toString()}`:"";return a(this,O).get(`${tt}/preferences${s}`)}bulkUpdatePreferences(e){return a(this,O).patch(`${tt}/preferences/bulk`,{preferences:e})}updateGlobalPreferences(e){return a(this,O).patch(`${tt}/preferences`,e)}updateWorkflowPreferences({workflowId:e,channels:t}){return a(this,O).patch(`${tt}/preferences/${e}`,t)}fetchGlobalPreferences(){return a(this,O).get(`${tt}/preferences/global`)}triggerHelloWorldEvent(){let e={name:"hello-world",to:{subscriberId:"keyless-subscriber-id"},payload:{subject:"Novu Keyless Environment",body:"You're using a keyless demo environment. For full access to Novu features and cloud integration, obtain your API key.",primaryActionText:"Obtain API Key",primaryActionUrl:"https://go.novu.co/keyless",secondaryActionText:"Explore Documentation",secondaryActionUrl:"https://go.novu.co/keyless-docs"}};return a(this,O).post("/inbox/events",e)}};O=new WeakMap;function Pn(i){return{all:i=i||new Map,on:function(e,t){var r=i.get(e);r?r.push(t):i.set(e,[t])},off:function(e,t){var r=i.get(e);r&&(t?r.splice(r.indexOf(t)>>>0,1):i.set(e,[]))},emit:function(e,t){var r=i.get(e);r&&r.slice().map(function(n){n(t)}),(r=i.get("*"))&&r.slice().map(function(n){n(e,t)})}}}var it,bi=class{constructor(){_(this,it);S(this,it,Pn())}on(e,t){return a(this,it).on(e,t),()=>{this.off(e,t)}}off(e,t){a(this,it).off(e,t)}emit(e,t){a(this,it).emit(e,t)}};it=new WeakMap;var k=class extends Error{constructor(e,t){super(e),this.originalError=t}};var xi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=we(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 k("Failed to read notification",o)}}}),wi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=we(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 k("Failed to unread notification",o)}}}),Ci=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=we(t,{isSeen:!0},{emitter:i,apiService:e});try{if(i.emit("notification.seen.pending",{args:t,data:s}),yield e.seen(n),!s)throw new Error("Failed to create optimistic value for notification");let o=new U(s,i,e);return i.emit("notification.seen.resolved",{args:t,data:o}),{data:o}}catch(o){return i.emit("notification.seen.resolved",{args:t,error:o}),{error:new k("Failed to mark notification as seen",o)}}}),Ni=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=we(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 k("Failed to archive notification",o)}}}),ki=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=we(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 k("Failed to unarchive notification",o)}}}),Ai=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=we(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 k("Failed to snooze notification",o)}}}),Ri=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=we(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 k("Failed to unsnooze notification",o)}}}),gt=n=>m(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="primary"?{primaryAction:A(E({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!0})}:{secondaryAction:A(E({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!0})},{notificationId:o,optimisticValue:c}=we(t,s,{emitter:i,apiService:e});try{i.emit("notification.complete_action.pending",{args:t,data:c});let l=yield e.completeAction({actionType:r,notificationId:o}),u=new U(l,i,e);return i.emit("notification.complete_action.resolved",{args:t,data:u}),{data:u}}catch(l){return i.emit("notification.complete_action.resolved",{args:t,error:l}),{error:new k(`Failed to complete ${r} action on the notification`,l)}}}),yt=n=>m(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="primary"?{primaryAction:A(E({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!1})}:{secondaryAction:A(E({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!1})},{notificationId:o,optimisticValue:c}=we(t,s,{emitter:i,apiService:e});try{i.emit("notification.revert_action.pending",{args:t,data:c});let l=yield e.revertAction({actionType:r,notificationId:o}),u=new U(l,i,e);return i.emit("notification.revert_action.resolved",{args:t,data:u}),{data:u}}catch(l){return i.emit("notification.revert_action.resolved",{args:t,error:l}),{error:new k("Failed to fetch notifications",l)}}}),we=(i,e,t)=>"notification"in i?{notificationId:i.notification.id,optimisticValue:new U(E(E({},i.notification),e),t.emitter,t.apiService)}:{notificationId:i.notificationId},Ln=s=>m(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let c=t.getUniqueNotifications({tags:r,data:n}).map(l=>new U(A(E({},l),{isRead:!0,readAt:new Date().toISOString(),isArchived:!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 k("Failed to read all notifications",o)}}}),kr=o=>m(void 0,[o],function*({emitter:i,inboxService:e,notificationsCache:t,notificationIds:r,tags:n,data:s}){try{let c=t.getUniqueNotifications({tags:n,data:s}),u=(r&&r.length>0?c.filter(h=>r.includes(h.id)):c).map(h=>new U(A(E({},h),{isSeen:!0,firstSeenAt:h.firstSeenAt||new Date().toISOString()}),i,e));return i.emit("notifications.seen_all.pending",{args:{notificationIds:r,tags:n,data:s},data:u}),yield e.markAsSeen({notificationIds:r,tags:n,data:s}),i.emit("notifications.seen_all.resolved",{args:{notificationIds:r,tags:n,data:s},data:u}),{}}catch(c){return i.emit("notifications.seen_all.resolved",{args:{notificationIds:r,tags:n,data:s},error:c}),{error:new k("Failed to mark all notifications as seen",c)}}}),Fn=s=>m(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let c=t.getUniqueNotifications({tags:r,data:n}).map(l=>new U(A(E({},l),{isRead:!0,readAt:new Date().toISOString(),isArchived:!0,archivedAt:new Date().toISOString()}),i,e));return i.emit("notifications.archive_all.pending",{args:{tags:r,data:n},data:c}),yield e.archiveAll({tags:r,data:n}),i.emit("notifications.archive_all.resolved",{args:{tags:r,data:n},data:c}),{}}catch(o){return i.emit("notifications.archive_all.resolved",{args:{tags:r,data:n},error:o}),{error:new k("Failed to archive all notifications",o)}}}),Un=s=>m(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let c=t.getUniqueNotifications({tags:r,data:n,read:!0}).map(l=>new U(A(E({},l),{isArchived:!0,archivedAt:new Date().toISOString()}),i,e));return i.emit("notifications.archive_all_read.pending",{args:{tags:r,data:n},data:c}),yield e.archiveAllRead({tags:r,data:n}),i.emit("notifications.archive_all_read.resolved",{args:{tags:r,data:n},data:c}),{}}catch(o){return i.emit("notifications.archive_all_read.resolved",{args:{tags:r,data:n},error:o}),{error:new k("Failed to archive all read notifications",o)}}}),Ti=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n}=we(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 k("Failed to delete notification",s)}}}),Dn=s=>m(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let o=t.getUniqueNotifications({tags:r,data:n});return i.emit("notifications.delete_all.pending",{args:{tags:r,data:n},data:o}),yield e.deleteAll({tags:r,data:n}),i.emit("notifications.delete_all.resolved",{args:{tags:r,data:n}}),{}}catch(o){return i.emit("notifications.delete_all.resolved",{args:{tags:r,data:n},error:o}),{error:new k("Failed to delete all notifications",o)}}});var V,ee,U=class{constructor(e,t,r){_(this,V);_(this,ee);S(this,V,t),S(this,ee,r),this.id=e.id,this.transactionId=e.transactionId,this.subject=e.subject,this.body=e.body,this.to=e.to,this.isRead=e.isRead,this.isSeen=e.isSeen,this.isArchived=e.isArchived,this.isSnoozed=e.isSnoozed,this.snoozedUntil=e.snoozedUntil,this.deliveredAt=e.deliveredAt,this.createdAt=e.createdAt,this.readAt=e.readAt,this.firstSeenAt=e.firstSeenAt,this.archivedAt=e.archivedAt,this.avatar=e.avatar,this.primaryAction=e.primaryAction,this.secondaryAction=e.secondaryAction,this.channelType=e.channelType,this.tags=e.tags,this.redirect=e.redirect,this.data=e.data,this.workflow=e.workflow,this.severity=e.severity}read(){return xi({emitter:a(this,V),apiService:a(this,ee),args:{notification:this}})}unread(){return wi({emitter:a(this,V),apiService:a(this,ee),args:{notification:this}})}seen(){return Ci({emitter:a(this,V),apiService:a(this,ee),args:{notification:this}})}archive(){return Ni({emitter:a(this,V),apiService:a(this,ee),args:{notification:this}})}unarchive(){return ki({emitter:a(this,V),apiService:a(this,ee),args:{notification:this}})}delete(){return Ti({emitter:a(this,V),apiService:a(this,ee),args:{notification:this}})}snooze(e){return Ai({emitter:a(this,V),apiService:a(this,ee),args:{notification:this,snoozeUntil:e}})}unsnooze(){return Ri({emitter:a(this,V),apiService:a(this,ee),args:{notification:this}})}completePrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return gt({emitter:a(this,V),apiService:a(this,ee),args:{notification:this},actionType:"primary"})}completeSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return gt({emitter:a(this,V),apiService:a(this,ee),args:{notification:this},actionType:"secondary"})}revertPrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return yt({emitter:a(this,V),apiService:a(this,ee),args:{notification:this},actionType:"primary"})}revertSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return yt({emitter:a(this,V),apiService:a(this,ee),args:{notification:this},actionType:"secondary"})}on(e,t){let r=a(this,V).on(e,t);return()=>{r()}}off(e,t){a(this,V).off(e,t)}};V=new WeakMap,ee=new WeakMap;var $e,vt,de=class{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){_(this,$e,[]);_(this,vt);this._emitter=t,this._inboxService=e,this._emitter.on("session.initialize.resolved",({error:r,data:n})=>{n?(this.onSessionSuccess(n),a(this,$e).forEach(c=>m(this,[c],function*({fn:s,resolve:o}){o(yield s())})),S(this,$e,[])):r&&(this.onSessionError(r),S(this,vt,r),a(this,$e).forEach(({resolve:s})=>{s({error:new k("Failed to initialize session, please contact the support",r)})}),S(this,$e,[]))})}onSessionSuccess(e){}onSessionError(e){}callWithSession(e){return m(this,null,function*(){return this._inboxService.isSessionInitialized?e():a(this,vt)?Promise.resolve({error:new k("Failed to initialize session, please contact the support",a(this,vt))}):new Promise((t,r)=>{a(this,$e).push({fn:e,resolve:t,reject:r})})})}};$e=new WeakMap,vt=new WeakMap;function Bn({emitter:i,inboxService:e,notification:t}){return new U(t,i,e)}var Ar=(i,e)=>i===e?!0:!i||!e||i.length!==e.length?!1:i.every((t,r)=>t===e[r]);var Ph=["seen","unseen"],Lh=["read","unread"],Rr=(i,e)=>Ar(i,e)||!i&&(e==null?void 0:e.length)===0||(i==null?void 0:i.length)===0&&!e,_a=(i,e)=>{let t=Array.isArray(i)?i:i?[i]:[],r=Array.isArray(e)?e:e?[e]:[];return Ar(t,r)},Tr=(i,e)=>{if(!i&&!e)return!0;if(!i||!e)return!1;try{return JSON.stringify(i)===JSON.stringify(e)}catch(t){return!1}},Or=(i,e)=>Tr(i.data,e.data)&&Rr(i.tags,e.tags)&&i.read===e.read&&i.archived===e.archived&&i.snoozed===e.snoozed&&i.seen===e.seen&&_a(i.severity,e.severity);var ye,Ve=class{constructor(){_(this,ye);S(this,ye,new Map)}get(e){return a(this,ye).get(e)}getValues(){return Array.from(a(this,ye).values())}entries(){return Array.from(a(this,ye).entries())}keys(){return Array.from(a(this,ye).keys())}set(e,t){a(this,ye).set(e,t)}remove(e){a(this,ye).delete(e)}clear(){a(this,ye).clear()}};ye=new WeakMap;var Mn=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:u})=>Object.entries({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:u}).filter(([h,f])=>f!=null&&!(Array.isArray(f)&&f.length===0)).reduce((h,[f,d])=>(h[f]=d,h),{}),Lt=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:u})=>JSON.stringify(Mn({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:u})),Ea=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o})=>JSON.stringify(Mn({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o})),rt=i=>JSON.parse(i),Sa=["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"],ba=["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"],Oe,Ut,B,Ft=class{constructor({emitter:e,inboxService:t}){_(this,Oe);_(this,Ut);_(this,B);this.updateNotification=(e,t)=>{let r=a(this,B).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,B).set(e,A(E({},r),{notifications:s})),!0};this.removeNotification=(e,t)=>{let r=a(this,B).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,B).set(e,A(E({},r),{notifications:s})),!0};this.handleNotificationEvent=({remove:e}={remove:!1})=>t=>{let{data:r,args:n}=t,s=[];if(r!=null)Array.isArray(r)&&r.every(c=>typeof c=="object"&&"id"in c)?s=r:typeof r=="object"&&"id"in r&&(s=[r]);else if(e&&n){if("notification"in n&&n.notification)s=[n.notification];else if("notificationId"in n&&n.notificationId){let c=[];a(this,B).keys().forEach(l=>{let u=a(this,B).get(l);if(u){let h=u.notifications.find(f=>f.id===n.notificationId);h&&c.push(h)}}),s=c}}if(s.length===0)return;let o=new Set;a(this,B).keys().forEach(c=>{s.forEach(l=>{let u=!1;e?u=this.removeNotification(c,l):u=this.updateNotification(c,l),u&&o.add(Ea(rt(c)))})}),o.forEach(c=>{let l=this.getAggregated(rt(c));a(this,Oe).emit("notifications.list.updated",{data:l})})};S(this,Oe,e),S(this,Ut,t),Sa.forEach(r=>{a(this,Oe).on(r,this.handleNotificationEvent())}),ba.forEach(r=>{a(this,Oe).on(r,this.handleNotificationEvent({remove:!0}))}),S(this,B,new Ve)}getAggregated(e){return a(this,B).keys().filter(r=>{let n=rt(r);return Or(n,e)}).map(r=>a(this,B).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,B).get(Lt(e))}has(e){return a(this,B).get(Lt(e))!==void 0}set(e,t){a(this,B).set(Lt(e),t)}unshift(e,t){let r=Lt(e),n=a(this,B).get(r)||{hasMore:!1,filter:rt(r),notifications:[]},s=Bn({notification:E({},t),emitter:a(this,Oe),inboxService:a(this,Ut)});this.update(e,A(E({},n),{notifications:[s,...n.notifications]}))}update(e,t){this.set(e,t);let r=this.getAggregated(rt(Lt(e)));a(this,Oe).emit("notifications.list.updated",{data:r})}getAll(e){if(this.has(e))return this.getAggregated({tags:e.tags,data:e.data,read:e.read,snoozed:e.snoozed,archived:e.archived,seen:e.seen,severity:e.severity})}getUniqueNotifications({tags:e,read:t,data:r}){let n=a(this,B).keys(),s=new Map;return n.forEach(o=>{let c=rt(o);if(Rr(e,c.tags)&&Tr(r,c.data)){let l=a(this,B).get(o);if(!l)return;l.notifications.filter(u=>typeof t=="undefined"||t===u.isRead).forEach(u=>{s.set(u.id,u)})}}),Array.from(s.values())}clear(e){a(this,B).keys().forEach(r=>{Or(rt(r),e)&&a(this,B).remove(r)})}clearAll(){a(this,B).clear()}};Oe=new WeakMap,Ut=new WeakMap,B=new WeakMap;var Dt,Oi=class extends de{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});_(this,Dt);this.cache=new Ft({emitter:n,inboxService:r}),S(this,Dt,t)}list(){return m(this,arguments,function*(n={}){var s=n,{limit:t=10}=s,r=Cr(s,["limit"]);return this.callWithSession(()=>m(this,null,function*(){let o=E({limit:t},r);try{let c="useCache"in o?o.useCache:a(this,Dt),l=c?this.cache.getAll(o):void 0;if(this._emitter.emit("notifications.list.pending",{args:o,data:l}),!l){let u=yield this._inboxService.fetchNotifications(E({limit:t},r));l={hasMore:u.hasMore,filter:u.filter,notifications:u.data.map(h=>new U(h,this._emitter,this._inboxService))},c&&(this.cache.set(o,l),l=this.cache.getAll(o))}return this._emitter.emit("notifications.list.resolved",{args:o,data:l}),{data:l}}catch(c){return this._emitter.emit("notifications.list.resolved",{args:o,error:c}),{error:new k("Failed to fetch notifications",c)}}}))})}count(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){let r=t&&"filters"in t?t.filters:[E({},t)];try{this._emitter.emit("notifications.count.pending",{args:t});let n=yield this._inboxService.count({filters:r}),s=t&&"filters"in t?{counts:n.data}:n.data[0];return this._emitter.emit("notifications.count.resolved",{args:t,data:s}),{data:s}}catch(n){return this._emitter.emit("notifications.count.resolved",{args:t,error:n}),{error:new k("Failed to count notifications",n)}}}))})}read(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return xi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unread(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return wi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}seen(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Ci({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}archive(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Ni({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unarchive(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return ki({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}delete(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Ti({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}snooze(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Ai({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unsnooze(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Ri({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}completePrimary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return gt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}completeSecondary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return gt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}revertPrimary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return yt({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 yt({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 Ln({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?kr({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,notificationIds:t.notificationIds}):kr({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 Fn({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 Un({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 Dn({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()})}};Dt=new WeakMap;var Bt,Mt,qt,Wt,Ie=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:n,useCache:s}){_(this,Bt);_(this,Mt);_(this,qt);_(this,Wt);S(this,Bt,t),S(this,Mt,r),S(this,qt,n),S(this,Wt,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 Ii({emitter:a(this,Bt),apiService:a(this,Mt),cache:a(this,qt),useCache:a(this,Wt),args:E({isEnabled:(r=e.isEnabled)!=null?r:this.isEnabled},t&&{weeklySchedule:E(E({},this.weeklySchedule),e.weeklySchedule)})})})}};Bt=new WeakMap,Mt=new WeakMap,qt=new WeakMap,Wt=new WeakMap;var zt,$t,Vt,Ht,jt,Ce=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:n,scheduleCache:s,useCache:o}){_(this,zt);_(this,$t);_(this,Vt);_(this,Ht);_(this,jt);S(this,zt,t),S(this,$t,r),S(this,Vt,n),S(this,Ht,s),S(this,jt,o),this.level=e.level,this.enabled=e.enabled,this.channels=e.channels,this.workflow=e.workflow,this.schedule=new Ie(E({},e.schedule),{emitterInstance:t,inboxServiceInstance:r,cache:s,useCache:o})}update({channels:e,channelPreferences:t}){var r;return Pi({emitter:a(this,zt),apiService:a(this,$t),cache:a(this,Vt),scheduleCache:a(this,Ht),useCache:a(this,jt),args:{workflowId:(r=this.workflow)==null?void 0:r.id,channels:e||t,preference:this}})}};zt=new WeakMap,$t=new WeakMap,Vt=new WeakMap,Ht=new WeakMap,jt=new WeakMap;var Pi=o=>m(void 0,[o],function*({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s}){var u;let{channels:c}=s,l="workflowId"in s?s.workflowId:(u=s.preference.workflow)==null?void 0:u.id;try{i.emit("preference.update.pending",{args:s,data:"preference"in s?new Ce(A(E({},s.preference),{channels:E(E({},s.preference.channels),c)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}):void 0});let h;l?h=yield e.updateWorkflowPreferences({workflowId:l,channels:c}):(xa({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s}),h=yield e.updateGlobalPreferences(c));let f=new Ce(h,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n});return i.emit("preference.update.resolved",{args:s,data:f}),{data:f}}catch(h){return i.emit("preference.update.resolved",{args:s,error:h}),{error:new k("Failed to update preference",h)}}}),qn=o=>m(void 0,[o],function*({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s}){if(s.find(l=>"preference"in l&&l.preference.level==="global"))return{error:new k("Global preference is not supported in bulk update","")};try{let l=s.map(d=>"preference"in d?new Ce(A(E({},d.preference),{channels:E(E({},d.preference.channels),d.channels)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}):void 0).filter(d=>d!==void 0);i.emit("preferences.bulk_update.pending",{args:s,data:l});let u=s.map(d=>{var p,x,g,v;return E({workflowId:"workflowId"in d?d.workflowId:(v=(g=(p=d.preference.workflow)==null?void 0:p.id)!=null?g:(x=d.preference.workflow)==null?void 0:x.identifier)!=null?v:""},d.channels)}),f=(yield e.bulkUpdatePreferences(u)).map(d=>new Ce(d,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}));return i.emit("preferences.bulk_update.resolved",{args:s,data:f}),{data:f}}catch(l){return i.emit("preferences.bulk_update.resolved",{args:s,error:l}),{error:new k("Failed to bulk update preferences",l)}}}),xa=({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s})=>{let o=n?t==null?void 0:t.getAll({}):void 0;o==null||o.forEach(c=>{var l,u;if(c.level==="template"){let h=A(E({},c),{channels:Object.entries(c.channels).reduce((d,[p,x])=>{var v;let g=p;return d[g]=(v=s.channels[g])!=null?v:x,d},{})}),f="preference"in s?new Ce(h,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}):void 0;f&&i.emit("preference.update.pending",{args:{workflowId:(u=(l=c.workflow)==null?void 0:l.id)!=null?u:"",channels:f.channels},data:f})}})},Ii=s=>m(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){var o,c;try{let{isEnabled:l,weeklySchedule:u}=n,h=new Ie({isEnabled:l,weeklySchedule:u},{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r});i.emit("preference.schedule.update.pending",{args:n,data:h});let f=yield e.updateGlobalPreferences({schedule:{isEnabled:l,weeklySchedule:u}}),d=new Ie({isEnabled:(o=f.schedule)==null?void 0:o.isEnabled,weeklySchedule:(c=f.schedule)==null?void 0:c.weeklySchedule},{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r});return i.emit("preference.schedule.update.resolved",{args:n,data:d}),{data:d}}catch(l){return i.emit("preference.schedule.update.resolved",{args:n,error:l}),{error:new k("Failed to update preference",l)}}});var He,Li=class extends de{constructor({cache:t,useCache:r,inboxServiceInstance:n,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:n});_(this,He);this.cache=t,S(this,He,r)}get(){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){var t,r;try{let n=a(this,He)?this.cache.getAll():void 0;if(this._emitter.emit("preference.schedule.get.pending",{args:void 0,data:n}),!n){let s=yield this._inboxService.fetchGlobalPreferences();n=new Ie({isEnabled:(t=s==null?void 0:s.schedule)==null?void 0:t.isEnabled,weeklySchedule:(r=s==null?void 0:s.schedule)==null?void 0:r.weeklySchedule},{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,useCache:a(this,He)}),a(this,He)&&(this.cache.set(n),n=this.cache.getAll())}return this._emitter.emit("preference.schedule.get.resolved",{args:void 0,data:n}),{data:n}}catch(n){throw this._emitter.emit("preference.schedule.get.resolved",{args:void 0,error:n}),n}}))})}update(t){return m(this,null,function*(){return this.callWithSession(()=>Ii({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,He),args:t}))})}};He=new WeakMap;var wa=["preference.update.pending","preference.update.resolved","preferences.bulk_update.pending","preferences.bulk_update.resolved"],Ca=["preference.schedule.update.pending","preference.schedule.update.resolved"],Na=({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),{}),Ir=({tags:i,severity:e})=>JSON.stringify(Na({tags:i,severity:e})),je,H,Fi=class{constructor({emitterInstance:e}){_(this,je);_(this,H);this.updatePreference=(e,t)=>{let r=a(this,H).get(e);if(!r)return!1;let n=r.findIndex(o=>{var c,l;return((c=o.workflow)==null?void 0:c.id)===((l=t.workflow)==null?void 0:l.id)||o.level===t.level&&t.level==="global"});if(n===-1)return!1;let s=[...r];return s[n]=t,a(this,H).set(e,s),!0};this.updatePreferenceSchedule=(e,t)=>{let r=a(this,H).get(e);if(!r)return!1;let n=r.findIndex(o=>o.level==="global");if(n===-1)return!1;let s=[...r];return s[n].schedule=t,a(this,H).set(e,s),!0};this.handleScheduleEvent=({data:e})=>{var n;if(!e)return;let t=a(this,H).keys(),r=new Set;for(let s of t){let o=this.updatePreferenceSchedule(s,e),c=a(this,H).get(s);!o||!c||r.add(s)}for(let s of r)a(this,je).emit("preferences.list.updated",{data:(n=a(this,H).get(s))!=null?n:[]})};this.handlePreferenceEvent=({data:e})=>{if(!e)return;let t=Array.isArray(e)?e:[e],r=new Set;a(this,H).keys().forEach(n=>{t.forEach(s=>{let o=this.updatePreference(n,s),c=a(this,H).get(n);!o||!c||r.add(n)})}),r.forEach(n=>{var s;a(this,je).emit("preferences.list.updated",{data:(s=a(this,H).get(n))!=null?s:[]})})};S(this,je,e);for(let t of wa)a(this,je).on(t,this.handlePreferenceEvent);for(let t of Ca)a(this,je).on(t,this.handleScheduleEvent);S(this,H,new Ve)}has(e){return a(this,H).get(Ir(e))!==void 0}set(e,t){a(this,H).set(Ir(e),t)}getAll(e){if(this.has(e))return a(this,H).get(Ir(e))}clearAll(){a(this,H).clear()}};je=new WeakMap,H=new WeakMap;var ka=["preference.schedule.update.pending","preference.schedule.update.resolved"],Pr=()=>"schedule",_t,se,Ui=class{constructor({emitterInstance:e}){_(this,_t);_(this,se);this.updateScheduleInCache=(e,t)=>a(this,se).get(e)?(a(this,se).set(e,t),!0):!1;this.handleScheduleEvent=({data:e})=>{if(!e)return;let t=new Set,r=a(this,se).keys();for(let n of r){let s=this.updateScheduleInCache(n,e),o=a(this,se).get(n);!s||!o||t.add(n)}for(let n of t)a(this,_t).emit("preference.schedule.get.updated",{data:a(this,se).get(n)})};S(this,_t,e);for(let t of ka)a(this,_t).on(t,this.handleScheduleEvent);S(this,se,new Ve)}has(){return a(this,se).get(Pr())!==void 0}set(e){a(this,se).set(Pr(),e)}getAll(){if(this.has())return a(this,se).get(Pr())}clearAll(){a(this,se).clear()}};_t=new WeakMap,se=new WeakMap;var Pe,Di=class extends de{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});_(this,Pe);this.cache=new Fi({emitterInstance:this._emitter}),this.scheduleCache=new Ui({emitterInstance:this._emitter}),S(this,Pe,t),this.schedule=new Li({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,Pe)?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 Ce(o,{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,Pe)})),a(this,Pe)&&(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(()=>Pi({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,Pe),args:t}))})}bulkUpdate(t){return m(this,null,function*(){return this.callWithSession(()=>qn({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,Pe),args:t}))})}};Pe=new WeakMap;function Wn(){return typeof window!="undefined"}var nt,Gt,Y,Bi=class{constructor(e,t,r){_(this,nt);_(this,Gt);_(this,Y);S(this,nt,r),S(this,Gt,t),S(this,Y,e)}get applicationIdentifier(){return a(this,Y).applicationIdentifier}get subscriberId(){var e;return(e=a(this,Y).subscriber)==null?void 0:e.subscriberId}get context(){return a(this,Y).context}get subscriberHash(){return a(this,Y).subscriberHash}get contextHash(){return a(this,Y).contextHash}get subscriber(){return a(this,Y).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,l,u;let t=((n=a(this,Y).subscriber)==null?void 0:n.subscriberId)===((s=e==null?void 0:e.subscriber)==null?void 0:s.subscriberId),r=JSON.stringify(a(this,Y).context)===JSON.stringify(e==null?void 0:e.context);if(!(t&&r))try{e&&S(this,Y,e);let{subscriber:h,subscriberHash:f,contextHash:d,applicationIdentifier:p,defaultSchedule:x,context:g}=a(this,Y),v;Wn()&&(v=Intl.DateTimeFormat().resolvedOptions().timeZone);let T=p;if(T)this.handleApplicationIdentifier("delete");else{let y=this.handleApplicationIdentifier("get");y&&(T=y)}a(this,nt).emit("session.initialize.pending",{args:a(this,Y)});let w=yield a(this,Gt).initializeSession({applicationIdentifier:T,subscriberHash:f,contextHash:d,subscriber:A(E({},h),{subscriberId:(o=h==null?void 0:h.subscriberId)!=null?o:"",timezone:(c=h==null?void 0:h.timezone)!=null?c:v}),defaultSchedule:x,context:g});(l=w==null?void 0:w.applicationIdentifier)!=null&&l.startsWith("pk_keyless_")&&this.handleApplicationIdentifier("store",w.applicationIdentifier),(u=w==null?void 0:w.applicationIdentifier)!=null&&u.startsWith("pk_keyless_")||this.handleApplicationIdentifier("delete"),a(this,nt).emit("session.initialize.resolved",{args:a(this,Y),data:w})}catch(h){a(this,nt).emit("session.initialize.resolved",{args:a(this,Y),error:h})}})}};nt=new WeakMap,Gt=new WeakMap,Y=new WeakMap;function zn(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 $n({subscriberId:i,subscriber:e}){return e?typeof e=="string"?{subscriberId:e}:e:i?{subscriberId:i}:{subscriberId:""}}var Mi=typeof globalThis!="undefined"&&globalThis||typeof self!="undefined"&&self||typeof global!="undefined"&&global,Aa=function(){try{new Mi.Event("")}catch(i){return!0}return!1}(),Ra=function(){try{new Mi.EventTarget}catch(i){return!0}return!1}();Aa&&(Mi.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}());Ra&&(Mi.EventTarget=function(){function i(){this.__listeners=new Map}return i.prototype=Object.create(Object.prototype),i.prototype.addEventListener=function(e,t,r){if(arguments.length<2)throw new TypeError("TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only "+arguments.length+" present.");let n=this.__listeners,s=e.toString();n.has(s)||n.set(s,new Map);let o=n.get(s);o.has(t)||o.set(t,r)},i.prototype.removeEventListener=function(e,t,r){if(arguments.length<2)throw new TypeError("TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only "+arguments.length+" present.");let n=this.__listeners,s=e.toString();if(n.has(s)){let o=n.get(s);o.has(t)&&o.delete(t)}},i.prototype.dispatchEvent=function(e){if(!(e instanceof Event))throw new TypeError("Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.");let t=e.type,n=this.__listeners.get(t);if(n)for(var s of n.entries()){let o=s[0],c=s[1];try{typeof o=="function"?o.call(this,e):o&&typeof o.handleEvent=="function"&&o.handleEvent(e)}catch(l){setTimeout(()=>{throw l})}c&&c.once&&n.delete(o)}return!0},i}());(!globalThis.EventTarget||!globalThis.Event)&&console.error(`
|
|
14
|
+
`+s),i.push(n+"m+"+Kr.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=Su()+e+" "+i[0]}function Su(){return J.inspectOpts.hideDate?"":new Date().toISOString()+" "}function _u(...i){return process.stderr.write($r.formatWithOptions(J.inspectOpts,...i)+`
|
|
15
|
+
`)}function Eu(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function wu(){return process.env.DEBUG}function xu(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=Vn()(J);var{formatters:va}=Kr.exports;va.o=function(i){return this.inspectOpts.colors=this.useColors,$r.inspect(i,this.inspectOpts).split(`
|
|
16
|
+
`).map(e=>e.trim()).join(" ")};va.O=function(i){return this.inspectOpts.colors=this.useColors,$r.inspect(i,this.inspectOpts)}});var Pi=F((Vp,Hn)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?Hn.exports=ga():Hn.exports=ba()});var Ga="v1",Ya=`${PACKAGE_NAME}@${PACKAGE_VERSION}`,$i=class{constructor(e={}){this.DEFAULT_BACKEND_URL=typeof window!="undefined"&&window.NOVU_LOCAL_BACKEND_URL||"https://api.novu.co";let{apiVersion:t=Ga,apiUrl:r=this.DEFAULT_BACKEND_URL,userAgent:n=Ya,headers:s={}}=e||{};this.apiVersion=t,this.apiUrl=`${r}/${t}`,this.headers=y({"Novu-API-Version":NOVU_API_VERSION,"Content-Type":"application/json","User-Agent":n},s)}setAuthorizationToken(e){this.headers.Authorization=`Bearer ${e}`}setKeylessHeader(e){var r;let t=e||typeof window!="undefined"&&((r=window.localStorage)==null?void 0:r.getItem("novu_keyless_application_identifier"));!t||!t.startsWith("pk_keyless_")||(this.headers["Novu-Application-Identifier"]=t)}setHeaders(e){this.headers=y(y({},this.headers),e)}get(e,t,r=!0){return d(this,null,function*(){return this.doFetch({path:e,searchParams:t,options:{method:"GET"},unwrapEnvelope:r})})}post(e,t,r){return d(this,null,function*(){return this.doFetch({path:e,options:{method:"POST",body:t,headers:r==null?void 0:r.headers}})})}patch(e,t){return d(this,null,function*(){return this.doFetch({path:e,options:{method:"PATCH",body:t}})})}delete(e,t){return d(this,null,function*(){return this.doFetch({path:e,options:{method:"DELETE",body:t}})})}doFetch(s){return d(this,arguments,function*({path:e,searchParams:t,options:r,unwrapEnvelope:n=!0}){let o=Ja(this.apiUrl,e,t?`?${t.toString()}`:""),c={method:(r==null?void 0:r.method)||"GET",headers:y(y({},this.headers),(r==null?void 0:r.headers)||{}),body:r!=null&&r.body?JSON.stringify(r.body):void 0},l=yield fetch(o,c);if(!l.ok){let u=yield l.json();throw new Error(`${this.headers["User-Agent"]} error. Status: ${l.status}, Message: ${u.message}`)}if(l.status===204)return;let h=yield l.json();return n?h.data:h})}};function Ja(...i){return i.reduce((e,t)=>(t&&e.push(t.replace(new RegExp("(?<!https?:)\\/+","g"),"/").replace(/^\/+|\/+$/g,"")),e),[]).join("/").replace(/\/\?/,"?")}var oe="/inbox",ie=`${oe}/notifications`,k,Ki=class{constructor(e={}){this.isSessionInitialized=!1;g(this,k);v(this,k,new $i(e))}initializeSession(c){return d(this,arguments,function*({applicationIdentifier:e,subscriberHash:t,contextHash:r,subscriber:n,defaultSchedule:s,context:o}){let l=yield a(this,k).post(`${oe}/session`,{applicationIdentifier:e,subscriberHash:t,contextHash:r,subscriber:n,defaultSchedule:s,context:o});return a(this,k).setAuthorizationToken(l.token),a(this,k).setKeylessHeader(l.applicationIdentifier),this.isSessionInitialized=!0,l})}fetchNotifications({after:e,archived:t,limit:r=10,offset:n,read:s,tags:o,snoozed:c,seen:l,data:h,severity:u}){let f=new URLSearchParams(`limit=${r}`);if(e&&f.append("after",e),n&&f.append("offset",`${n}`),o)for(let p of o)f.append("tags[]",p);if(s!==void 0&&f.append("read",`${s}`),t!==void 0&&f.append("archived",`${t}`),c!==void 0&&f.append("snoozed",`${c}`),l!==void 0&&f.append("seen",`${l}`),h!==void 0&&f.append("data",JSON.stringify(h)),u&&Array.isArray(u))for(let p of u)f.append("severity[]",p);else u&&f.append("severity",u);return a(this,k).get(ie,f,!1)}count({filters:e}){return a(this,k).get(`${ie}/count`,new URLSearchParams({filters:JSON.stringify(e)}),!1)}read(e){return a(this,k).patch(`${ie}/${e}/read`)}unread(e){return a(this,k).patch(`${ie}/${e}/unread`)}archive(e){return a(this,k).patch(`${ie}/${e}/archive`)}unarchive(e){return a(this,k).patch(`${ie}/${e}/unarchive`)}snooze(e,t){return a(this,k).patch(`${ie}/${e}/snooze`,{snoozeUntil:t})}unsnooze(e){return a(this,k).patch(`${ie}/${e}/unsnooze`)}readAll({tags:e,data:t}){return a(this,k).post(`${ie}/read`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAll({tags:e,data:t}){return a(this,k).post(`${ie}/archive`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAllRead({tags:e,data:t}){return a(this,k).post(`${ie}/read-archive`,{tags:e,data:t?JSON.stringify(t):void 0})}delete(e){return a(this,k).delete(`${ie}/${e}/delete`)}deleteAll({tags:e,data:t}){return a(this,k).post(`${ie}/delete`,{tags:e,data:t?JSON.stringify(t):void 0})}markAsSeen({notificationIds:e,tags:t,data:r}){return a(this,k).post(`${ie}/seen`,{notificationIds:e,tags:t,data:r?JSON.stringify(r):void 0})}seen(e){return this.markAsSeen({notificationIds:[e]})}completeAction({actionType:e,notificationId:t}){return a(this,k).patch(`${ie}/${t}/complete`,{actionType:e})}revertAction({actionType:e,notificationId:t}){return a(this,k).patch(`${ie}/${t}/revert`,{actionType:e})}fetchPreferences({tags:e,severity:t,criticality:r}){let n=new URLSearchParams;if(e)for(let o of e)n.append("tags[]",o);if(t&&Array.isArray(t))for(let o of t)n.append("severity[]",o);else t&&n.append("severity",t);r&&n.append("criticality",r);let s=n.size?`?${n.toString()}`:"";return a(this,k).get(`${oe}/preferences${s}`)}bulkUpdatePreferences(e){return a(this,k).patch(`${oe}/preferences/bulk`,{preferences:e})}updateGlobalPreferences(e){return a(this,k).patch(`${oe}/preferences`,e)}updateWorkflowPreferences({workflowId:e,channels:t}){return a(this,k).patch(`${oe}/preferences/${e}`,t)}fetchGlobalPreferences(){return a(this,k).get(`${oe}/preferences/global`)}triggerHelloWorldEvent(){let e={name:"hello-world",to:{subscriberId:"keyless-subscriber-id"},payload:{subject:"Novu Keyless Environment",body:"You're using a keyless demo environment. For full access to Novu features and cloud integration, obtain your API key.",primaryActionText:"Obtain API Key",primaryActionUrl:"https://go.novu.co/keyless",secondaryActionText:"Explore Documentation",secondaryActionUrl:"https://go.novu.co/keyless-docs"}};return a(this,k).post("/inbox/events",e)}fetchSubscriptions(e){return a(this,k).get(`${oe}/topics/${e}/subscriptions`)}getSubscription(e,t,r,n){let s=new URLSearchParams;if(r!=null&&r.length)for(let c of r)s.append("workflowIds",c);if(n!=null&&n.length)for(let c of n)s.append("tags",c);let o=s.size?`?${s.toString()}`:"";return a(this,k).get(`${oe}/topics/${e}/subscriptions/${t}${o}`)}createSubscription({identifier:e,name:t,topicKey:r,topicName:n,preferences:s}){return a(this,k).post(`${oe}/topics/${r}/subscriptions`,y(y({identifier:e,name:t},n&&{topic:{name:n}}),s!==void 0&&{preferences:s}))}updateSubscription({topicKey:e,subscriptionId:t,name:r,preferences:n}){return a(this,k).patch(`${oe}/topics/${e}/subscriptions/${t}`,y({name:r},n!==void 0&&{preferences:n}))}updateSubscriptionPreference({subscriptionId:e,workflowId:t,enabled:r,condition:n,email:s,sms:o,in_app:c,chat:l,push:h}){return a(this,k).patch(`${oe}/subscriptions/${e}/preferences/${t}`,{enabled:r,condition:n,email:s,sms:o,in_app:c,chat:l,push:h})}bulkUpdateSubscriptionPreferences(e){return a(this,k).patch(`${oe}/preferences/bulk`,{preferences:e})}deleteSubscription({topicKey:e,subscriptionId:t}){return a(this,k).delete(`${oe}/topics/${e}/subscriptions/${t}`)}};k=new WeakMap;function ss(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 dt,zi=class{constructor(){g(this,dt);v(this,dt,ss())}on(e,t){return a(this,dt).on(e,t),()=>{this.off(e,t)}}off(e,t){a(this,dt).off(e,t)}emit(e,t){a(this,dt).emit(e,t)}};dt=new WeakMap;var w=class extends Error{constructor(e,t){super(e),this.originalError=t}};var Vi=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(t,{isRead:!0,readAt:new Date().toISOString(),isArchived:!1,archivedAt:void 0},{emitter:i,apiService:e});try{i.emit("notification.read.pending",{args:t,data:s});let o=yield e.read(n),c=new U(o,i,e);return i.emit("notification.read.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.read.resolved",{args:t,error:o}),{error:new w("Failed to read notification",o)}}}),Hi=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(t,{isRead:!1,readAt:null,isArchived:!1,archivedAt:void 0},{emitter:i,apiService:e});try{i.emit("notification.unread.pending",{args:t,data:s});let o=yield e.unread(n),c=new U(o,i,e);return i.emit("notification.unread.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.unread.resolved",{args:t,error:o}),{error:new w("Failed to unread notification",o)}}}),ji=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(t,{isSeen:!0},{emitter:i,apiService:e});try{if(i.emit("notification.seen.pending",{args:t,data:s}),yield e.seen(n),!s)throw new Error("Failed to create optimistic value for notification");let o=new U(s,i,e);return i.emit("notification.seen.resolved",{args:t,data:o}),{data:o}}catch(o){return i.emit("notification.seen.resolved",{args:t,error:o}),{error:new w("Failed to mark notification as seen",o)}}}),Gi=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(t,{isArchived:!0,archivedAt:new Date().toISOString(),isRead:!0,readAt:new Date().toISOString()},{emitter:i,apiService:e});try{i.emit("notification.archive.pending",{args:t,data:s});let o=yield e.archive(n),c=new U(o,i,e);return i.emit("notification.archive.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.archive.resolved",{args:t,error:o}),{error:new w("Failed to archive notification",o)}}}),Yi=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(t,{isArchived:!1,archivedAt:null,isRead:!0,readAt:new Date().toISOString()},{emitter:i,apiService:e});try{i.emit("notification.unarchive.pending",{args:t,data:s});let o=yield e.unarchive(n),c=new U(o,i,e);return i.emit("notification.unarchive.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.unarchive.resolved",{args:t,error:o}),{error:new w("Failed to unarchive notification",o)}}}),Ji=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(t,{isSnoozed:!0,snoozedUntil:t.snoozeUntil},{emitter:i,apiService:e});try{i.emit("notification.snooze.pending",{args:t,data:s});let o=yield e.snooze(n,t.snoozeUntil),c=new U(o,i,e);return i.emit("notification.snooze.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.snooze.resolved",{args:t,error:o}),{error:new w("Failed to snooze notification",o)}}}),Xi=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(t,{isSnoozed:!1,snoozedUntil:null},{emitter:i,apiService:e});try{i.emit("notification.unsnooze.pending",{args:t,data:s});let o=yield e.unsnooze(n),c=new U(o,i,e);return i.emit("notification.unsnooze.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.unsnooze.resolved",{args:t,error:o}),{error:new w("Failed to unsnooze notification",o)}}}),At=n=>d(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="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}=Ie(t,s,{emitter:i,apiService:e});try{i.emit("notification.complete_action.pending",{args:t,data:c});let l=yield e.completeAction({actionType:r,notificationId:o}),h=new U(l,i,e);return i.emit("notification.complete_action.resolved",{args:t,data:h}),{data:h}}catch(l){return i.emit("notification.complete_action.resolved",{args:t,error:l}),{error:new w(`Failed to complete ${r} action on the notification`,l)}}}),Rt=n=>d(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="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}=Ie(t,s,{emitter:i,apiService:e});try{i.emit("notification.revert_action.pending",{args:t,data:c});let l=yield e.revertAction({actionType:r,notificationId:o}),h=new U(l,i,e);return i.emit("notification.revert_action.resolved",{args:t,data:h}),{data:h}}catch(l){return i.emit("notification.revert_action.resolved",{args:t,error:l}),{error:new w("Failed to fetch notifications",l)}}}),Ie=(i,e,t)=>"notification"in i?{notificationId:i.notification.id,optimisticValue:new U(y(y({},i.notification),e),t.emitter,t.apiService)}:{notificationId:i.notificationId},os=s=>d(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let c=t.getUniqueNotifications({tags:r,data:n}).map(l=>new U(x(y({},l),{isRead:!0,readAt:new Date().toISOString(),isArchived:!1,archivedAt:void 0}),i,e));return i.emit("notifications.read_all.pending",{args:{tags:r,data:n},data:c}),yield e.readAll({tags:r,data:n}),i.emit("notifications.read_all.resolved",{args:{tags:r,data:n},data:c}),{}}catch(o){return i.emit("notifications.read_all.resolved",{args:{tags:r,data:n},error:o}),{error:new w("Failed to read all notifications",o)}}}),Zr=o=>d(void 0,[o],function*({emitter:i,inboxService:e,notificationsCache:t,notificationIds:r,tags:n,data:s}){try{let c=t.getUniqueNotifications({tags:n,data:s}),h=(r&&r.length>0?c.filter(u=>r.includes(u.id)):c).map(u=>new U(x(y({},u),{isSeen:!0,firstSeenAt:u.firstSeenAt||new Date().toISOString()}),i,e));return i.emit("notifications.seen_all.pending",{args:{notificationIds:r,tags:n,data:s},data:h}),yield e.markAsSeen({notificationIds:r,tags:n,data:s}),i.emit("notifications.seen_all.resolved",{args:{notificationIds:r,tags:n,data:s},data:h}),{}}catch(c){return i.emit("notifications.seen_all.resolved",{args:{notificationIds:r,tags:n,data:s},error:c}),{error:new w("Failed to mark all notifications as seen",c)}}}),as=s=>d(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let c=t.getUniqueNotifications({tags:r,data:n}).map(l=>new U(x(y({},l),{isRead:!0,readAt:new Date().toISOString(),isArchived:!0,archivedAt:new Date().toISOString()}),i,e));return i.emit("notifications.archive_all.pending",{args:{tags:r,data:n},data:c}),yield e.archiveAll({tags:r,data:n}),i.emit("notifications.archive_all.resolved",{args:{tags:r,data:n},data:c}),{}}catch(o){return i.emit("notifications.archive_all.resolved",{args:{tags:r,data:n},error:o}),{error:new w("Failed to archive all notifications",o)}}}),cs=s=>d(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let c=t.getUniqueNotifications({tags:r,data:n,read:!0}).map(l=>new U(x(y({},l),{isArchived:!0,archivedAt:new Date().toISOString()}),i,e));return i.emit("notifications.archive_all_read.pending",{args:{tags:r,data:n},data:c}),yield e.archiveAllRead({tags:r,data:n}),i.emit("notifications.archive_all_read.resolved",{args:{tags:r,data:n},data:c}),{}}catch(o){return i.emit("notifications.archive_all_read.resolved",{args:{tags:r,data:n},error:o}),{error:new w("Failed to archive all read notifications",o)}}}),Qi=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n}=Ie(t,{},{emitter:i,apiService:e});try{return i.emit("notification.delete.pending",{args:t}),yield e.delete(n),i.emit("notification.delete.resolved",{args:t}),{}}catch(s){return i.emit("notification.delete.resolved",{args:t,error:s}),{error:new w("Failed to delete notification",s)}}}),ls=s=>d(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let o=t.getUniqueNotifications({tags:r,data:n});return i.emit("notifications.delete_all.pending",{args:{tags:r,data:n},data:o}),yield e.deleteAll({tags:r,data:n}),i.emit("notifications.delete_all.resolved",{args:{tags:r,data:n}}),{}}catch(o){return i.emit("notifications.delete_all.resolved",{args:{tags:r,data:n},error:o}),{error:new w("Failed to delete all notifications",o)}}});var H,re,U=class{constructor(e,t,r){g(this,H);g(this,re);v(this,H,t),v(this,re,r),this.id=e.id,this.transactionId=e.transactionId,this.subject=e.subject,this.body=e.body,this.to=e.to,this.isRead=e.isRead,this.isSeen=e.isSeen,this.isArchived=e.isArchived,this.isSnoozed=e.isSnoozed,this.snoozedUntil=e.snoozedUntil,this.deliveredAt=e.deliveredAt,this.createdAt=e.createdAt,this.readAt=e.readAt,this.firstSeenAt=e.firstSeenAt,this.archivedAt=e.archivedAt,this.avatar=e.avatar,this.primaryAction=e.primaryAction,this.secondaryAction=e.secondaryAction,this.channelType=e.channelType,this.tags=e.tags,this.redirect=e.redirect,this.data=e.data,this.workflow=e.workflow,this.severity=e.severity}read(){return Vi({emitter:a(this,H),apiService:a(this,re),args:{notification:this}})}unread(){return Hi({emitter:a(this,H),apiService:a(this,re),args:{notification:this}})}seen(){return ji({emitter:a(this,H),apiService:a(this,re),args:{notification:this}})}archive(){return Gi({emitter:a(this,H),apiService:a(this,re),args:{notification:this}})}unarchive(){return Yi({emitter:a(this,H),apiService:a(this,re),args:{notification:this}})}delete(){return Qi({emitter:a(this,H),apiService:a(this,re),args:{notification:this}})}snooze(e){return Ji({emitter:a(this,H),apiService:a(this,re),args:{notification:this,snoozeUntil:e}})}unsnooze(){return Xi({emitter:a(this,H),apiService:a(this,re),args:{notification:this}})}completePrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return At({emitter:a(this,H),apiService:a(this,re),args:{notification:this},actionType:"primary"})}completeSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return At({emitter:a(this,H),apiService:a(this,re),args:{notification:this},actionType:"secondary"})}revertPrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return Rt({emitter:a(this,H),apiService:a(this,re),args:{notification:this},actionType:"primary"})}revertSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return Rt({emitter:a(this,H),apiService:a(this,re),args:{notification:this},actionType:"secondary"})}on(e,t){let r=a(this,H).on(e,t);return()=>{r()}}off(e,t){a(this,H).off(e,t)}};H=new WeakMap,re=new WeakMap;var Ze,It,ae=class{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){g(this,Ze,[]);g(this,It);this._emitter=t,this._inboxService=e,this._emitter.on("session.initialize.resolved",({error:r,data:n})=>{n?(this.onSessionSuccess(n),a(this,Ze).forEach(c=>d(this,[c],function*({fn:s,resolve:o}){o(yield s())})),v(this,Ze,[])):r&&(this.onSessionError(r),v(this,It,r),a(this,Ze).forEach(({resolve:s})=>{s({error:new w("Failed to initialize session, please contact the support",r)})}),v(this,Ze,[]))})}onSessionSuccess(e){}onSessionError(e){}callWithSession(e){return d(this,null,function*(){return this._inboxService.isSessionInitialized?e():a(this,It)?Promise.resolve({error:new w("Failed to initialize session, please contact the support",a(this,It))}):new Promise((t,r)=>{a(this,Ze).push({fn:e,resolve:t,reject:r})})})}};Ze=new WeakMap,It=new WeakMap;function us({emitter:i,inboxService:e,notification:t}){return new U(t,i,e)}var en=(i,e)=>i===e?!0:!i||!e||i.length!==e.length?!1:i.every((t,r)=>t===e[r]);var hh=["seen","unseen"],fh=["read","unread"],tn=(i,e)=>en(i,e)||!i&&(e==null?void 0:e.length)===0||(i==null?void 0:i.length)===0&&!e,Xa=(i,e)=>{let t=Array.isArray(i)?i:i?[i]:[],r=Array.isArray(e)?e:e?[e]:[];return en(t,r)},rn=(i,e)=>{if(!i&&!e)return!0;if(!i||!e)return!1;try{return JSON.stringify(i)===JSON.stringify(e)}catch(t){return!1}},nn=(i,e)=>rn(i.data,e.data)&&tn(i.tags,e.tags)&&i.read===e.read&&i.archived===e.archived&&i.snoozed===e.snoozed&&i.seen===e.seen&&Xa(i.severity,e.severity);var _e,Ee=class{constructor(){g(this,_e);v(this,_e,new Map)}get(e){return a(this,_e).get(e)}getValues(){return Array.from(a(this,_e).values())}entries(){return Array.from(a(this,_e).entries())}keys(){return Array.from(a(this,_e).keys())}set(e,t){a(this,_e).set(e,t)}remove(e){a(this,_e).delete(e)}clear(){a(this,_e).clear()}};_e=new WeakMap;var hs=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:h})=>Object.entries({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:h}).filter(([u,f])=>f!=null&&!(Array.isArray(f)&&f.length===0)).reduce((u,[f,p])=>(u[f]=p,u),{}),jt=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:h})=>JSON.stringify(hs({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:h})),Qa=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o})=>JSON.stringify(hs({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o})),pt=i=>JSON.parse(i),Za=["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"],ec=["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"],Ue,Yt,B,Gt=class{constructor({emitter:e,inboxService:t}){g(this,Ue);g(this,Yt);g(this,B);this.updateNotification=(e,t)=>{let r=a(this,B).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,B).set(e,x(y({},r),{notifications:s})),!0};this.removeNotification=(e,t)=>{let r=a(this,B).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,B).set(e,x(y({},r),{notifications:s})),!0};this.handleNotificationEvent=({remove:e}={remove:!1})=>t=>{let{data:r,args:n}=t,s=[];if(r!=null)Array.isArray(r)&&r.every(c=>typeof c=="object"&&"id"in c)?s=r:typeof r=="object"&&"id"in r&&(s=[r]);else if(e&&n){if("notification"in n&&n.notification)s=[n.notification];else if("notificationId"in n&&n.notificationId){let c=[];a(this,B).keys().forEach(l=>{let h=a(this,B).get(l);if(h){let u=h.notifications.find(f=>f.id===n.notificationId);u&&c.push(u)}}),s=c}}if(s.length===0)return;let o=new Set;a(this,B).keys().forEach(c=>{s.forEach(l=>{let h=!1;e?h=this.removeNotification(c,l):h=this.updateNotification(c,l),h&&o.add(Qa(pt(c)))})}),o.forEach(c=>{let l=this.getAggregated(pt(c));a(this,Ue).emit("notifications.list.updated",{data:l})})};v(this,Ue,e),v(this,Yt,t),Za.forEach(r=>{a(this,Ue).on(r,this.handleNotificationEvent())}),ec.forEach(r=>{a(this,Ue).on(r,this.handleNotificationEvent({remove:!0}))}),v(this,B,new Ee)}getAggregated(e){return a(this,B).keys().filter(r=>{let n=pt(r);return nn(n,e)}).map(r=>a(this,B).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,B).get(jt(e))}has(e){return a(this,B).get(jt(e))!==void 0}set(e,t){a(this,B).set(jt(e),t)}unshift(e,t){let r=jt(e),n=a(this,B).get(r)||{hasMore:!1,filter:pt(r),notifications:[]},s=us({notification:y({},t),emitter:a(this,Ue),inboxService:a(this,Yt)});this.update(e,x(y({},n),{notifications:[s,...n.notifications]}))}update(e,t){this.set(e,t);let r=this.getAggregated(pt(jt(e)));a(this,Ue).emit("notifications.list.updated",{data:r})}getAll(e){if(this.has(e))return this.getAggregated({tags:e.tags,data:e.data,read:e.read,snoozed:e.snoozed,archived:e.archived,seen:e.seen,severity:e.severity})}getUniqueNotifications({tags:e,read:t,data:r}){let n=a(this,B).keys(),s=new Map;return n.forEach(o=>{let c=pt(o);if(tn(e,c.tags)&&rn(r,c.data)){let l=a(this,B).get(o);if(!l)return;l.notifications.filter(h=>typeof t=="undefined"||t===h.isRead).forEach(h=>{s.set(h.id,h)})}}),Array.from(s.values())}clear(e){a(this,B).keys().forEach(r=>{nn(pt(r),e)&&a(this,B).remove(r)})}clearAll(){a(this,B).clear()}};Ue=new WeakMap,Yt=new WeakMap,B=new WeakMap;var Jt,Xt,Qt,Zt,De=class{constructor(e,t,r,n,s){g(this,Jt);g(this,Xt);g(this,Qt);g(this,Zt);var o;v(this,Jt,t),v(this,Xt,r),v(this,Qt,n),v(this,Zt,s),this.enabled=e.enabled,this.condition=(o=e.condition)!=null?o:void 0,this.workflow=e.workflow,this.subscriptionId=e.subscriptionId}update(e){return d(this,null,function*(){var t;return Zi({emitter:a(this,Jt),apiService:a(this,Xt),cache:a(this,Qt),useCache:a(this,Zt),args:{subscriptionId:this.subscriptionId,workflowId:(t=this.workflow)==null?void 0:t.id,value:e.value,preference:this}})})}};Jt=new WeakMap,Xt=new WeakMap,Qt=new WeakMap,Zt=new WeakMap;var fs=s=>d(void 0,[s],function*({emitter:i,apiService:e,cache:t,options:r,args:n}){try{let{useCache:o,refetch:c}=r,l=o&&!c?t.getAll(n):void 0;return i.emit("subscriptions.list.pending",{args:n,data:l}),(!l||c)&&(l=(yield e.fetchSubscriptions(n.topicKey)).map(u=>new Be(x(y({},u),{topicKey:n.topicKey}),i,e,t,o)),o&&(t.set(n,l),l=t.getAll(n))),i.emit("subscriptions.list.resolved",{args:n,data:l}),{data:l}}catch(o){return i.emit("subscriptions.list.resolved",{args:n,error:o}),{error:new w("Failed to fetch subscriptions",o)}}}),ds=s=>d(void 0,[s],function*({emitter:i,apiService:e,cache:t,options:r,args:n}){try{let{useCache:o,refetch:c}=r,l=o&&!c?t.get(n):void 0;if(i.emit("subscription.get.pending",{args:n,data:l}),!l||c){let h=yield e.getSubscription(n.topicKey,n.identifier,n.workflowIds,n.tags);if(!h)return i.emit("subscription.get.resolved",{args:n,data:null}),{data:null};l=new Be(x(y({},h),{topicKey:n.topicKey}),i,e,t,o),o&&(t.setOne(n,l),l=t.get(n))}return i.emit("subscription.get.resolved",{args:n,data:l}),{data:l}}catch(o){return i.emit("subscription.get.resolved",{args:n,error:o}),{error:new w("Failed to fetch subscription",o)}}}),ps=s=>d(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){var o;try{i.emit("subscription.create.pending",{args:n});let c=yield e.createSubscription({identifier:(o=n.identifier)!=null?o:"",name:n.name,topicKey:n.topicKey,topicName:n.topicName,preferences:n.preferences}),l=new Be(x(y({},c),{topicKey:n.topicKey}),i,e,t,r);return i.emit("subscription.create.resolved",{args:n,data:l}),{data:l}}catch(c){return i.emit("subscription.create.resolved",{args:n,error:c}),{error:new w("Failed to create subscription",c)}}}),er=s=>d(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){let o="subscriptionId"in n?n.subscriptionId:n.subscription.id,c="topicKey"in n?n.topicKey:n.subscription.topicKey;try{i.emit("subscription.update.pending",{args:n});let l=yield e.updateSubscription({topicKey:c,subscriptionId:o,name:n.name,preferences:n.preferences}),h=new Be(x(y({},l),{topicKey:c}),i,e,t,r);return i.emit("subscription.update.resolved",{args:n,data:h}),{data:h}}catch(l){return i.emit("subscription.update.resolved",{args:n,error:l}),{error:new w("Failed to update subscription",l)}}}),Zi=s=>d(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){var c,l;let o="workflowId"in n?n.workflowId:(l=(c=n.preference)==null?void 0:c.workflow)==null?void 0:l.id;try{i.emit("subscription.preference.update.pending",{args:n,data:"preference"in n?new De(y(y({},n.preference),typeof n.value=="boolean"?{enabled:n.value}:{condition:n.value}),i,e,t,r):void 0});let h=yield e.updateSubscriptionPreference(y({subscriptionId:n.subscriptionId,workflowId:o},typeof n.value=="boolean"?{enabled:n.value,email:n.value,sms:n.value,in_app:n.value,chat:n.value,push:n.value}:{condition:n.value})),u=new De(y({},h),i,e,t,r);return i.emit("subscription.preference.update.resolved",{args:n,data:u}),{data:u}}catch(h){return i.emit("subscription.preference.update.resolved",{args:n,error:h}),{error:new w("Failed to update subscription",h)}}}),ms=s=>d(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){try{let o=n.map(u=>"preference"in u?new De(y(y({},u.preference),typeof u.value=="boolean"?{enabled:u.value}:{condition:u.value}),i,e,t,r):void 0).filter(u=>u!==void 0);i.emit("subscription.preferences.bulk_update.pending",{args:n,data:o});let c=n.map(u=>{var f,p,m,C,b,_;return y({subscriptionIdOrIdentifier:u.subscriptionId,workflowId:"workflowId"in u?u.workflowId:(_=(b=(p=(f=u.preference)==null?void 0:f.workflow)==null?void 0:p.id)!=null?b:(C=(m=u.preference)==null?void 0:m.workflow)==null?void 0:C.identifier)!=null?_:""},typeof u.value=="boolean"?{enabled:u.value,email:u.value,sms:u.value,in_app:u.value,chat:u.value,push:u.value}:{condition:u.value})}),h=(yield e.bulkUpdateSubscriptionPreferences(c)).map(u=>new De(u,i,e,t,r));return i.emit("subscription.preferences.bulk_update.resolved",{args:n,data:h}),{data:h}}catch(o){return i.emit("subscription.preferences.bulk_update.resolved",{args:n,error:o}),{error:new w("Failed to bulk update subscription preferences",o)}}}),tr=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let n="subscriptionId"in t?t.subscriptionId:t.subscription.id,s="topicKey"in t?t.topicKey:t.subscription.topicKey;try{return i.emit("subscription.delete.pending",{args:t}),yield e.deleteSubscription({topicKey:s,subscriptionId:n}),i.emit("subscription.delete.resolved",{args:t}),{data:void 0}}catch(o){return i.emit("subscription.delete.resolved",{args:t,error:o}),{error:new w("Failed to delete subscription",o)}}});var Me,qe,et,tt,Tt,Be=class{constructor(e,t,r,n,s){g(this,Me);g(this,qe);g(this,et);g(this,tt);g(this,Tt,!1);var o;v(this,Me,t),v(this,qe,r),v(this,et,n),v(this,tt,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 De(y({},c),a(this,Me),a(this,qe),a(this,et),a(this,tt)))}update(e){return d(this,null,function*(){return er({emitter:a(this,Me),apiService:a(this,qe),cache:a(this,et),useCache:a(this,tt),args:x(y({},e),{subscription:this})})})}updatePreference(e){return d(this,null,function*(){return a(this,Tt)?{error:new w("Cannot update a deleted subscription",new Error("Subscription is stale"))}:Zi({emitter:a(this,Me),apiService:a(this,qe),cache:a(this,et),useCache:a(this,tt),args:x(y({},e),{subscriptionId:this.id})})})}bulkUpdatePreferences(e){return d(this,null,function*(){return a(this,Tt)?{error:new w("Cannot bulk update a deleted subscription",new Error("Subscription is stale"))}:ms({emitter:a(this,Me),apiService:a(this,qe),cache:a(this,et),useCache:a(this,tt),args:e.map(t=>x(y({},t),{subscriptionId:this.id}))})})}delete(){return d(this,null,function*(){return a(this,Tt)?{error:new w("Cannot delete an already deleted subscription",new Error("Subscription is stale"))}:tr({emitter:a(this,Me),apiService:a(this,qe),args:{subscription:this}})})}};Me=new WeakMap,qe=new WeakMap,et=new WeakMap,tt=new WeakMap,Tt=new WeakMap;var mt=i=>`list:${i.topicKey}`,ys=i=>i.split(":")[1],it=i=>`item:${i.topicKey}:${i.identifier}`,X,M,ei,q,ti,ir=class{constructor({emitterInstance:e,inboxServiceInstance:t,useCache:r}){g(this,X);g(this,M);g(this,ei);g(this,q);g(this,ti);this.handleCreate=e=>{let t=mt({topicKey:e.topicKey}),r=a(this,M).get(t);if(r){let n=[...r,e];a(this,M).set(t,n),a(this,X).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:n}})}a(this,q).set(it({topicKey:e.topicKey,identifier:e.identifier}),e)};this.handleUpdate=e=>{let t=mt({topicKey:e.topicKey}),r=a(this,M).get(t);if(r){let n=r.map(s=>s.id===e.id?e:s);a(this,M).set(t,n),a(this,X).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:n}})}a(this,q).set(it({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,M).keys();for(let o of r){let c=a(this,M).get(o);if(!c)continue;let l=!1,h=c.map(u=>{let f=t.get(u.id);return f?(l=!0,this.createUpdatedSubscription(u,f)):u});l&&(a(this,M).set(o,h),a(this,X).emit("subscriptions.list.updated",{data:{topicKey:ys(o),subscriptions:h}}))}let n=a(this,q).keys();for(let o of n){let c=a(this,q).get(o);if(!c)continue;let l=t.get(c.id);if(l){let h=this.createUpdatedSubscription(c,l);a(this,q).set(o,h),a(this,X).emit("subscription.update.resolved",{args:{subscription:c},data:h})}}};this.createUpdatedSubscription=(e,t)=>{var n;let r=(n=e.preferences)==null?void 0:n.map(s=>{let o=t.find(c=>c.workflow.id===s.workflow.id);return o||s});return new Be({id:e.id,identifier:e.identifier,topicKey:e.topicKey,preferences:r},a(this,X),a(this,ti),this,a(this,ei))};this.handleDelete=e=>{let t=mt({topicKey:e.topicKey}),r=a(this,M).get(t);if(r){let n=r.filter(s=>s.id!==e.id);a(this,M).set(t,n),a(this,X).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:n}})}a(this,q).remove(it({topicKey:e.topicKey,identifier:e.identifier}))};this.handleDeleteById=e=>{let t=a(this,M).keys();for(let n of t){let s=a(this,M).get(n);if(s){let o=s.find(c=>c.id===e||c.identifier===e);if(o){let c=s.filter(l=>l.id!==o.id);a(this,M).set(n,c),a(this,X).emit("subscriptions.list.updated",{data:{topicKey:ys(n),subscriptions:c}}),a(this,q).remove(it({topicKey:o.topicKey,identifier:o.identifier}));return}}}let r=a(this,q).keys();for(let n of r){let s=a(this,q).get(n);if(s&&(s.id===e||s.identifier===e)){a(this,q).remove(n);return}}};v(this,X,e),v(this,M,new Ee),v(this,q,new Ee),v(this,ti,t),v(this,ei,r),a(this,X).on("subscription.create.resolved",({data:n})=>{n&&this.handleCreate(n)}),a(this,X).on("subscription.update.resolved",({data:n})=>{n&&this.handleUpdate(n)}),a(this,X).on("subscription.delete.resolved",({args:n})=>{"subscription"in n?this.handleDelete(n.subscription):"subscriptionId"in n&&this.handleDeleteById(n.subscriptionId)}),a(this,X).on("subscription.preference.update.pending",({data:n})=>{n&&this.handlePreferenceUpdate(n)}),a(this,X).on("subscription.preference.update.resolved",({data:n})=>{n&&this.handlePreferenceUpdate(n)}),a(this,X).on("subscription.preferences.bulk_update.resolved",({data:n})=>{n&&n.length>0&&this.handleBulkPreferenceUpdate(n)})}has(e){return a(this,M).get(mt(e))!==void 0}set(e,t){a(this,M).set(mt(e),t);for(let r of t)a(this,q).set(it({topicKey:e.topicKey,identifier:r.identifier}),r)}setOne(e,t){a(this,q).set(it(e),t)}getAll(e){return a(this,M).get(mt(e))}get(e){return a(this,q).get(it(e))}invalidate(e){let t=mt({topicKey:e.topicKey}),r=a(this,M).get(t);if(r)for(let s of r)a(this,q).remove(it({topicKey:e.topicKey,identifier:s.identifier}));a(this,M).remove(t);let n=a(this,q).keys();for(let s of n)s.startsWith(`item:${e.topicKey}:`)&&a(this,q).remove(s)}clearAll(){a(this,M).clear(),a(this,q).clear()}};X=new WeakMap,M=new WeakMap,ei=new WeakMap,q=new WeakMap,ti=new WeakMap;var ii,rr=class extends ae{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});g(this,ii);this.cache=new Gt({emitter:n,inboxService:r}),v(this,ii,t)}list(){return d(this,arguments,function*(n={}){var s=n,{limit:t=10}=s,r=Xr(s,["limit"]);return this.callWithSession(()=>d(this,null,function*(){let o=y({limit:t},r);try{let c="useCache"in o?o.useCache:a(this,ii),l=c?this.cache.getAll(o):void 0;if(this._emitter.emit("notifications.list.pending",{args:o,data:l}),!l){let h=yield this._inboxService.fetchNotifications(y({limit:t},r));l={hasMore:h.hasMore,filter:h.filter,notifications:h.data.map(u=>new U(u,this._emitter,this._inboxService))},c&&(this.cache.set(o,l),l=this.cache.getAll(o))}return this._emitter.emit("notifications.list.resolved",{args:o,data:l}),{data:l}}catch(c){return this._emitter.emit("notifications.list.resolved",{args:o,error:c}),{error:new w("Failed to fetch notifications",c)}}}))})}count(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){let r=t&&"filters"in t?t.filters:[y({},t)];try{this._emitter.emit("notifications.count.pending",{args:t});let n=yield this._inboxService.count({filters:r}),s=t&&"filters"in t?{counts:n.data}:n.data[0];return this._emitter.emit("notifications.count.resolved",{args:t,data:s}),{data:s}}catch(n){return this._emitter.emit("notifications.count.resolved",{args:t,error:n}),{error:new w("Failed to count notifications",n)}}}))})}read(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Vi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unread(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Hi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}seen(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return ji({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}archive(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Gi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unarchive(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Yi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}delete(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Qi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}snooze(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Ji({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unsnooze(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Xi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}completePrimary(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return At({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}completeSecondary(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return At({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}revertPrimary(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Rt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}revertSecondary(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Rt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}readAll(){return d(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>d(this,null,function*(){return os({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}seenAll(){return d(this,arguments,function*(t={}){return this.callWithSession(()=>d(this,null,function*(){return"notificationIds"in t?Zr({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,notificationIds:t.notificationIds}):Zr({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:"tags"in t?t.tags:void 0,data:"data"in t?t.data:void 0})}))})}archiveAll(){return d(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>d(this,null,function*(){return as({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}archiveAllRead(){return d(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>d(this,null,function*(){return cs({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}deleteAll(){return d(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>d(this,null,function*(){return ls({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}clearCache({filter:t}={}){if(t){this.cache.clear(t!=null?t:{});return}this.cache.clearAll()}triggerHelloWorldEvent(){return d(this,null,function*(){return this._inboxService.triggerHelloWorldEvent()})}};ii=new WeakMap;var ri,ni,si,oi,We=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:n,useCache:s}){g(this,ri);g(this,ni);g(this,si);g(this,oi);v(this,ri,t),v(this,ni,r),v(this,si,n),v(this,oi,s),this.isEnabled=e.isEnabled,this.weeklySchedule=e.weeklySchedule}update(e){return d(this,null,function*(){var r;let t=!!e.weeklySchedule||!!this.weeklySchedule;return nr({emitter:a(this,ri),apiService:a(this,ni),cache:a(this,si),useCache:a(this,oi),args:y({isEnabled:(r=e.isEnabled)!=null?r:this.isEnabled},t&&{weeklySchedule:y(y({},this.weeklySchedule),e.weeklySchedule)})})})}};ri=new WeakMap,ni=new WeakMap,si=new WeakMap,oi=new WeakMap;var ai,ci,li,ui,hi,Te=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:n,scheduleCache:s,useCache:o}){g(this,ai);g(this,ci);g(this,li);g(this,ui);g(this,hi);v(this,ai,t),v(this,ci,r),v(this,li,n),v(this,ui,s),v(this,hi,o),this.level=e.level,this.enabled=e.enabled,this.channels=e.channels,this.workflow=e.workflow,this.schedule=new We(y({},e.schedule),{emitterInstance:t,inboxServiceInstance:r,cache:s,useCache:o})}update({channels:e,channelPreferences:t}){var r;return sr({emitter:a(this,ai),apiService:a(this,ci),cache:a(this,li),scheduleCache:a(this,ui),useCache:a(this,hi),args:{workflowId:(r=this.workflow)==null?void 0:r.id,channels:e||t,preference:this}})}};ai=new WeakMap,ci=new WeakMap,li=new WeakMap,ui=new WeakMap,hi=new WeakMap;var sr=o=>d(void 0,[o],function*({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s}){var h;let{channels:c}=s,l="workflowId"in s?s.workflowId:(h=s.preference.workflow)==null?void 0:h.id;try{i.emit("preference.update.pending",{args:s,data:"preference"in s?new Te(x(y({},s.preference),{channels:y(y({},s.preference.channels),c)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}):void 0});let u;l?u=yield e.updateWorkflowPreferences({workflowId:l,channels:c}):(tc({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s}),u=yield e.updateGlobalPreferences(c));let f=new Te(u,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n});return i.emit("preference.update.resolved",{args:s,data:f}),{data:f}}catch(u){return i.emit("preference.update.resolved",{args:s,error:u}),{error:new w("Failed to update preference",u)}}}),gs=o=>d(void 0,[o],function*({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s}){if(s.find(l=>"preference"in l&&l.preference.level==="global"))return{error:new w("Global preference is not supported in bulk update","")};try{let l=s.map(p=>"preference"in p?new Te(x(y({},p.preference),{channels:y(y({},p.preference.channels),p.channels)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}):void 0).filter(p=>p!==void 0);i.emit("preferences.bulk_update.pending",{args:s,data:l});let h=s.map(p=>{var m,C,b,_;return y({workflowId:"workflowId"in p?p.workflowId:(_=(b=(m=p.preference.workflow)==null?void 0:m.id)!=null?b:(C=p.preference.workflow)==null?void 0:C.identifier)!=null?_:""},p.channels)}),f=(yield e.bulkUpdatePreferences(h)).map(p=>new Te(p,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}));return i.emit("preferences.bulk_update.resolved",{args:s,data:f}),{data:f}}catch(l){return i.emit("preferences.bulk_update.resolved",{args:s,error:l}),{error:new w("Failed to bulk update preferences",l)}}}),tc=({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s})=>{let o=n?t==null?void 0:t.getAll({}):void 0;o==null||o.forEach(c=>{var l,h;if(c.level==="template"){let u=x(y({},c),{channels:Object.entries(c.channels).reduce((p,[m,C])=>{var _;let b=m;return p[b]=(_=s.channels[b])!=null?_:C,p},{})}),f="preference"in s?new Te(u,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}):void 0;f&&i.emit("preference.update.pending",{args:{workflowId:(h=(l=c.workflow)==null?void 0:l.id)!=null?h:"",channels:f.channels},data:f})}})},nr=s=>d(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){var o,c;try{let{isEnabled:l,weeklySchedule:h}=n,u=new We({isEnabled:l,weeklySchedule:h},{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r});i.emit("preference.schedule.update.pending",{args:n,data:u});let f=yield e.updateGlobalPreferences({schedule:{isEnabled:l,weeklySchedule:h}}),p=new We({isEnabled:(o=f.schedule)==null?void 0:o.isEnabled,weeklySchedule:(c=f.schedule)==null?void 0:c.weeklySchedule},{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r});return i.emit("preference.schedule.update.resolved",{args:n,data:p}),{data:p}}catch(l){return i.emit("preference.schedule.update.resolved",{args:n,error:l}),{error:new w("Failed to update preference",l)}}});var rt,or=class extends ae{constructor({cache:t,useCache:r,inboxServiceInstance:n,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:n});g(this,rt);this.cache=t,v(this,rt,r)}get(){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){var t,r;try{let n=a(this,rt)?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 We({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,rt)}),a(this,rt)&&(this.cache.set(n),n=this.cache.getAll())}return this._emitter.emit("preference.schedule.get.resolved",{args:void 0,data:n}),{data:n}}catch(n){throw this._emitter.emit("preference.schedule.get.resolved",{args:void 0,error:n}),n}}))})}update(t){return d(this,null,function*(){return this.callWithSession(()=>nr({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,rt),args:t}))})}};rt=new WeakMap;var ic=["preference.update.pending","preference.update.resolved","preferences.bulk_update.pending","preferences.bulk_update.resolved"],rc=["preference.schedule.update.pending","preference.schedule.update.resolved"],nc=({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),{}),sn=({tags:i,severity:e})=>JSON.stringify(nc({tags:i,severity:e})),nt,j,ar=class{constructor({emitterInstance:e}){g(this,nt);g(this,j);this.updatePreference=(e,t)=>{let r=a(this,j).get(e);if(!r)return!1;let n=r.findIndex(o=>{var c,l;return((c=o.workflow)==null?void 0:c.id)===((l=t.workflow)==null?void 0:l.id)||o.level===t.level&&t.level==="global"});if(n===-1)return!1;let s=[...r];return s[n]=t,a(this,j).set(e,s),!0};this.updatePreferenceSchedule=(e,t)=>{let r=a(this,j).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,j).set(e,s),!0};this.handleScheduleEvent=({data:e})=>{var n;if(!e)return;let t=a(this,j).keys(),r=new Set;for(let s of t){let o=this.updatePreferenceSchedule(s,e),c=a(this,j).get(s);!o||!c||r.add(s)}for(let s of r)a(this,nt).emit("preferences.list.updated",{data:(n=a(this,j).get(s))!=null?n:[]})};this.handlePreferenceEvent=({data:e})=>{if(!e)return;let t=Array.isArray(e)?e:[e],r=new Set;a(this,j).keys().forEach(n=>{t.forEach(s=>{let o=this.updatePreference(n,s),c=a(this,j).get(n);!o||!c||r.add(n)})}),r.forEach(n=>{var s;a(this,nt).emit("preferences.list.updated",{data:(s=a(this,j).get(n))!=null?s:[]})})};v(this,nt,e);for(let t of ic)a(this,nt).on(t,this.handlePreferenceEvent);for(let t of rc)a(this,nt).on(t,this.handleScheduleEvent);v(this,j,new Ee)}has(e){return a(this,j).get(sn(e))!==void 0}set(e,t){a(this,j).set(sn(e),t)}getAll(e){if(this.has(e))return a(this,j).get(sn(e))}clearAll(){a(this,j).clear()}};nt=new WeakMap,j=new WeakMap;var sc=["preference.schedule.update.pending","preference.schedule.update.resolved"],on=()=>"schedule",Ot,ue,cr=class{constructor({emitterInstance:e}){g(this,Ot);g(this,ue);this.updateScheduleInCache=(e,t)=>a(this,ue).get(e)?(a(this,ue).set(e,t),!0):!1;this.handleScheduleEvent=({data:e})=>{if(!e)return;let t=new Set,r=a(this,ue).keys();for(let n of r){let s=this.updateScheduleInCache(n,e),o=a(this,ue).get(n);!s||!o||t.add(n)}for(let n of t)a(this,Ot).emit("preference.schedule.get.updated",{data:a(this,ue).get(n)})};v(this,Ot,e);for(let t of sc)a(this,Ot).on(t,this.handleScheduleEvent);v(this,ue,new Ee)}has(){return a(this,ue).get(on())!==void 0}set(e){a(this,ue).set(on(),e)}getAll(){if(this.has())return a(this,ue).get(on())}clearAll(){a(this,ue).clear()}};Ot=new WeakMap,ue=new WeakMap;var $e,lr=class extends ae{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});g(this,$e);this.cache=new ar({emitterInstance:this._emitter}),this.scheduleCache=new cr({emitterInstance:this._emitter}),v(this,$e,t),this.schedule=new or({cache:this.scheduleCache,useCache:t,inboxServiceInstance:r,eventEmitterInstance:n})}list(){return d(this,arguments,function*(t={}){return this.callWithSession(()=>d(this,null,function*(){var r;try{let n=a(this,$e)?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 Te(o,{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,$e)})),a(this,$e)&&(this.cache.set(t,n),n=this.cache.getAll(t))),this._emitter.emit("preferences.list.resolved",{args:t,data:n}),{data:n}}catch(n){throw this._emitter.emit("preferences.list.resolved",{args:t,error:n}),n}}))})}update(t){return d(this,null,function*(){return this.callWithSession(()=>sr({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,$e),args:t}))})}bulkUpdate(t){return d(this,null,function*(){return this.callWithSession(()=>gs({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,$e),args:t}))})}};$e=new WeakMap;function vs(){return typeof window!="undefined"}var yt,fi,Q,ur=class{constructor(e,t,r){g(this,yt);g(this,fi);g(this,Q);v(this,yt,r),v(this,fi,t),v(this,Q,e)}get applicationIdentifier(){return a(this,Q).applicationIdentifier}get subscriberId(){var e;return(e=a(this,Q).subscriber)==null?void 0:e.subscriberId}get context(){return a(this,Q).context}get subscriberHash(){return a(this,Q).subscriberHash}get contextHash(){return a(this,Q).contextHash}get subscriber(){return a(this,Q).subscriber}handleApplicationIdentifier(e,t){if(typeof window=="undefined"||!window.localStorage)return null;let r="novu_keyless_application_identifier";switch(e){case"get":return window.localStorage.getItem(r);case"store":return t&&window.localStorage.setItem(r,t),null;case"delete":return window.localStorage.removeItem(r),null;default:return null}}initialize(e){return d(this,null,function*(){var n,s,o,c,l,h;let t=((n=a(this,Q).subscriber)==null?void 0:n.subscriberId)===((s=e==null?void 0:e.subscriber)==null?void 0:s.subscriberId),r=JSON.stringify(a(this,Q).context)===JSON.stringify(e==null?void 0:e.context);if(!(t&&r))try{e&&v(this,Q,e);let{subscriber:u,subscriberHash:f,contextHash:p,applicationIdentifier:m,defaultSchedule:C,context:b}=a(this,Q),_;vs()&&(_=Intl.DateTimeFormat().resolvedOptions().timeZone);let T=m;if(T)this.handleApplicationIdentifier("delete");else{let S=this.handleApplicationIdentifier("get");S&&(T=S)}a(this,yt).emit("session.initialize.pending",{args:a(this,Q)});let N=yield a(this,fi).initializeSession({applicationIdentifier:T,subscriberHash:f,contextHash:p,subscriber:x(y({},u),{subscriberId:(o=u==null?void 0:u.subscriberId)!=null?o:"",timezone:(c=u==null?void 0:u.timezone)!=null?c:_}),defaultSchedule:C,context:b});(l=N==null?void 0:N.applicationIdentifier)!=null&&l.startsWith("pk_keyless_")&&this.handleApplicationIdentifier("store",N.applicationIdentifier),(h=N==null?void 0:N.applicationIdentifier)!=null&&h.startsWith("pk_keyless_")||this.handleApplicationIdentifier("delete"),a(this,yt).emit("session.initialize.resolved",{args:a(this,Q),data:N})}catch(u){a(this,yt).emit("session.initialize.resolved",{args:a(this,Q),error:u})}})}};yt=new WeakMap,fi=new WeakMap,Q=new WeakMap;function bs(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 Ss({subscriberId:i,subscriber:e}){return e?typeof e=="string"?{subscriberId:e}:e:i?{subscriberId:i}:{subscriberId:""}}function _s({topicKey:i,subscriberId:e}){return`tk_${i}:si_${e}`}var st,pi,di=class extends ae{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n,subscriber:s}){super({eventEmitterInstance:n,inboxServiceInstance:r});g(this,st);g(this,pi);this.cache=new ir({emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,useCache:t}),v(this,st,t),v(this,pi,s)}list(t,r){return d(this,null,function*(){return this.callWithSession(()=>{var n;return fs({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,options:x(y({},r),{useCache:(n=r==null?void 0:r.useCache)!=null?n:a(this,st)}),args:t})})})}get(t,r){return d(this,null,function*(){return this.callWithSession(()=>{var n,s;return ds({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,options:x(y({},r),{useCache:(n=r==null?void 0:r.useCache)!=null?n:a(this,st)}),args:x(y({},t),{identifier:(s=t.identifier)!=null?s:_s({topicKey:t.topicKey,subscriberId:a(this,pi).subscriberId})})})})})}create(t){return d(this,null,function*(){return this.callWithSession(()=>ps({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,st),args:t}))})}update(t){return d(this,null,function*(){return this.callWithSession(()=>er({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,st),args:t}))})}delete(t){return d(this,null,function*(){return this.callWithSession(()=>tr({emitter:this._emitter,apiService:this._inboxService,args:t}))})}};st=new WeakMap,pi=new WeakMap;var hr=typeof globalThis!="undefined"&&globalThis||typeof self!="undefined"&&self||typeof global!="undefined"&&global,oc=function(){try{new hr.Event("")}catch(i){return!0}return!1}(),ac=function(){try{new hr.EventTarget}catch(i){return!0}return!1}();oc&&(hr.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}());ac&&(hr.EventTarget=function(){function i(){this.__listeners=new Map}return i.prototype=Object.create(Object.prototype),i.prototype.addEventListener=function(e,t,r){if(arguments.length<2)throw new TypeError("TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only "+arguments.length+" present.");let n=this.__listeners,s=e.toString();n.has(s)||n.set(s,new Map);let o=n.get(s);o.has(t)||o.set(t,r)},i.prototype.removeEventListener=function(e,t,r){if(arguments.length<2)throw new TypeError("TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only "+arguments.length+" present.");let n=this.__listeners,s=e.toString();if(n.has(s)){let o=n.get(s);o.has(t)&&o.delete(t)}},i.prototype.dispatchEvent=function(e){if(!(e instanceof Event))throw new TypeError("Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.");let t=e.type,n=this.__listeners.get(t);if(n)for(var s of n.entries()){let o=s[0],c=s[1];try{typeof o=="function"?o.call(this,e):o&&typeof o.handleEvent=="function"&&o.handleEvent(e)}catch(l){setTimeout(()=>{throw l})}c&&c.once&&n.delete(o)}return!0},i}());(!globalThis.EventTarget||!globalThis.Event)&&console.error(`
|
|
17
17
|
PartySocket requires a global 'EventTarget' class to be available!
|
|
18
18
|
You can polyfill this global by adding this to your code before any partysocket imports:
|
|
19
19
|
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
import 'partysocket/event-target-polyfill';
|
|
22
22
|
\`\`\`
|
|
23
23
|
Please file an issue at https://github.com/partykit/partykit if you're still having trouble.
|
|
24
|
-
`);var
|
|
24
|
+
`);var xs=class extends Event{constructor(e,t){super("error",t);O(this,"message");O(this,"error");this.message=e.message,this.error=e}},Cs=class extends Event{constructor(e=1e3,t="",r){super("close",r);O(this,"code");O(this,"reason");O(this,"wasClean",!0);this.code=e,this.reason=t}},an={Event,ErrorEvent:xs,CloseEvent:Cs};function cc(i,e){if(!i)throw new Error(e)}function lc(i){return new i.constructor(i.type,i)}function uc(i){return"data"in i?new MessageEvent(i.type,i):"code"in i||"reason"in i?new Cs(i.code||1999,i.reason||"unknown reason",i):"error"in i?new xs(i.error,i):new Event(i.type,i)}var Es,hc=typeof process!="undefined"&&typeof((Es=process.versions)==null?void 0:Es.node)!="undefined"&&typeof document=="undefined",fr=hc?uc:lc,gt={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},ws=!1,dr=class vt extends EventTarget{constructor(t,r,n={}){super();O(this,"_ws");O(this,"_retryCount",-1);O(this,"_uptimeTimeout");O(this,"_connectTimeout");O(this,"_shouldReconnect",!0);O(this,"_connectLock",!1);O(this,"_binaryType","blob");O(this,"_closeCalled",!1);O(this,"_messageQueue",[]);O(this,"_debugLogger",console.log.bind(console));O(this,"_url");O(this,"_protocols");O(this,"_options");O(this,"onclose",null);O(this,"onerror",null);O(this,"onmessage",null);O(this,"onopen",null);O(this,"_handleOpen",t=>{this._debug("open event");let{minUptime:r=gt.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),r),cc(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(fr(t))});O(this,"_handleMessage",t=>{this._debug("message event"),this.onmessage&&this.onmessage(t),this.dispatchEvent(fr(t))});O(this,"_handleError",t=>{this._debug("error event",t.message),this._disconnect(void 0,t.message==="TIMEOUT"?"timeout":void 0),this.onerror&&this.onerror(t),this._debug("exec error listeners"),this.dispatchEvent(fr(t)),this._connect()});O(this,"_handleClose",t=>{this._debug("close event"),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(t),this.dispatchEvent(fr(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 vt.CONNECTING}get OPEN(){return vt.OPEN}get CLOSING(){return vt.CLOSING}get CLOSED(){return vt.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?vt.CLOSED:vt.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=gt.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=gt.reconnectionDelayGrowFactor,minReconnectionDelay:r=gt.minReconnectionDelay,maxReconnectionDelay:n=gt.maxReconnectionDelay}=this._options,s=0;return this._retryCount>0&&(s=r*ns(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=gt.maxRetries,connectionTimeout:r=gt.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"&&!ws&&(console.error(`\u203C\uFE0F No WebSocket implementation available. You should define options.WebSocket.
|
|
25
25
|
|
|
26
26
|
For example, if you're using node.js, run \`npm install ws\`, and then in your code:
|
|
27
27
|
|
|
@@ -34,7 +34,7 @@ const partysocket = new PartySocket({
|
|
|
34
34
|
WebSocket: WS
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
`),Hn=!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 Lr.ErrorEvent(Error(n.message),this))})}_handleTimeout(){this._debug("timeout event"),this._handleError(new Lr.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 Lr.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 Kt="wss://socket.novu.co",Kn="notifications.notification_received",Yn="notifications.unseen_count_changed",Jn="notifications.unread_count_changed",La=({_id:i,transactionId:e,content:t,read:r,seen:n,archived:s,snoozedUntil:o,deliveredAt:c,createdAt:l,lastReadDate:u,firstSeenDate:h,archivedAt:f,channel:d,subscriber:p,subject:x,avatar:g,cta:v,tags:T,data:w,workflow:y,severity:b})=>{var Ze,et,ie,Me,qe,We,me,ge;let $={id:p==null?void 0:p._id,subscriberId:p==null?void 0:p.subscriberId,firstName:p==null?void 0:p.firstName,lastName:p==null?void 0:p.lastName,avatar:p==null?void 0:p.avatar,locale:p==null?void 0:p.locale,data:p==null?void 0:p.data,timezone:p==null?void 0:p.timezone,email:p==null?void 0:p.email,phone:p==null?void 0:p.phone},N=(et=(Ze=v.action)==null?void 0:Ze.buttons)==null?void 0:et.find(Te=>Te.type==="primary"),P=(Me=(ie=v.action)==null?void 0:ie.buttons)==null?void 0:Me.find(Te=>Te.type==="secondary"),q=(We=(qe=v.action)==null?void 0:qe.result)==null?void 0:We.type,ne=(me=v.action)==null?void 0:me.status;return A(E(E({id:i,transactionId:e,subject:x,body:t,to:$,isRead:r,isSeen:n,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:l,readAt:u,firstSeenAt:h,archivedAt:f,avatar:g,primaryAction:N&&{label:N.content,isCompleted:q==="primary"&&ne==="done",redirect:N.url?{target:N.target,url:N.url}:void 0},secondaryAction:P&&{label:P.content,isCompleted:q==="secondary"&&ne==="done",redirect:P.url?{target:P.target,url:P.url}:void 0},channelType:d,tags:T,redirect:(ge=v.data)!=null&&ge.url?{url:v.data.url,target:v.data.target}:void 0,data:w,workflow:y,severity:b})},Et,ve,_e,St,$i,Vi,Hi,ji,Ne,Xn,Fr,Ur,zi=class extends de{constructor({socketUrl:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});_(this,Ne);_(this,Et);_(this,ve);_(this,_e);_(this,St);_(this,$i,t=>{try{let r=JSON.parse(t.data);r.event==="notification_received"&&a(this,ve).emit(Kn,{result:new U(La(r.data.message),a(this,ve),this._inboxService)})}catch(r){console.log("error",r)}});_(this,Vi,t=>{try{let r=JSON.parse(t.data);r.event==="unseen_count_changed"&&a(this,ve).emit(Yn,{result:r.data.unseenCount})}catch(r){}});_(this,Hi,t=>{try{let r=JSON.parse(t.data);r.event==="unread_count_changed"&&a(this,ve).emit(Jn,{result:r.data.counts})}catch(r){}});_(this,ji,t=>{try{switch(JSON.parse(t.data).event){case"notification_received":a(this,$i).call(this,t);break;case"unseen_count_changed":a(this,Vi).call(this,t);break;case"unread_count_changed":a(this,Hi).call(this,t);break;default:}}catch(r){}});S(this,ve,n),S(this,St,t!=null?t:Kt)}onSessionSuccess({token:t}){S(this,Et,t)}isSocketEvent(t){return t===Kn||t===Yn||t===Jn}connect(){return m(this,null,function*(){return a(this,Et)?ue(this,Ne,Fr).call(this):this.callWithSession(ue(this,Ne,Fr).bind(this))})}disconnect(){return m(this,null,function*(){return a(this,_e)?ue(this,Ne,Ur).call(this):this.callWithSession(ue(this,Ne,Ur).bind(this))})}};Et=new WeakMap,ve=new WeakMap,_e=new WeakMap,St=new WeakMap,$i=new WeakMap,Vi=new WeakMap,Hi=new WeakMap,ji=new WeakMap,Ne=new WeakSet,Xn=function(){return m(this,null,function*(){if(a(this,_e))return;let t={socketUrl:a(this,St)};a(this,ve).emit("socket.connect.pending",{args:t});let r=new URL(a(this,St));r.searchParams.set("token",a(this,Et)),S(this,_e,new Wi(r.toString())),a(this,_e).addEventListener("open",()=>{a(this,ve).emit("socket.connect.resolved",{args:t})}),a(this,_e).addEventListener("error",n=>{a(this,ve).emit("socket.connect.resolved",{args:t,error:n})}),a(this,_e).addEventListener("message",a(this,ji))})},Fr=function(){return m(this,null,function*(){try{return yield ue(this,Ne,Xn).call(this),{}}catch(t){return{error:new k("Failed to initialize the PartySocket",t)}}})},Ur=function(){return m(this,null,function*(){var t;try{return(t=a(this,_e))==null||t.close(),S(this,_e,void 0),{}}catch(r){return{error:new k("Failed to disconnect from the PartySocket",r)}}})};var Ee=Object.create(null);Ee.open="0";Ee.close="1";Ee.ping="2";Ee.pong="3";Ee.message="4";Ee.upgrade="5";Ee.noop="6";var Yt=Object.create(null);Object.keys(Ee).forEach(i=>{Yt[Ee[i]]=i});var Jt={type:"error",data:"parser error"};var Xt=({type:i,data:e},t,r)=>e instanceof ArrayBuffer||ArrayBuffer.isView(e)?r(t?e:"b"+Qn(e,!0).toString("base64")):r(Ee[i]+(e||"")),Qn=(i,e)=>Buffer.isBuffer(i)||i instanceof Uint8Array&&!e?i:i instanceof ArrayBuffer?Buffer.from(i):Buffer.from(i.buffer,i.byteOffset,i.byteLength),Dr;function Zn(i,e){if(i.data instanceof ArrayBuffer||ArrayBuffer.isView(i.data))return e(Qn(i.data,!1));Xt(i,!0,t=>{Dr||(Dr=new TextEncoder),e(Dr.encode(t))})}var Qt=(i,e)=>{if(typeof i!="string")return{type:"message",data:es(i,e)};let t=i.charAt(0);if(t==="b"){let r=Buffer.from(i.substring(1),"base64");return{type:"message",data:es(r,e)}}return Yt[t]?i.length>1?{type:Yt[t],data:i.substring(1)}:{type:Yt[t]}:Jt},es=(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 ts="",is=(i,e)=>{let t=i.length,r=new Array(t),n=0;i.forEach((s,o)=>{Xt(s,!1,c=>{r[o]=c,++n===t&&e(r.join(ts))})})},rs=(i,e)=>{let t=i.split(ts),r=[];for(let n=0;n<t.length;n++){let s=Qt(t[n],e);if(r.push(s),s.type==="error")break}return r};function ns(){return new TransformStream({transform(i,e){Zn(i,t=>{let r=t.length,n;if(r<126)n=new Uint8Array(1),new DataView(n.buffer).setUint8(0,r);else if(r<65536){n=new Uint8Array(3);let s=new DataView(n.buffer);s.setUint8(0,126),s.setUint16(1,r)}else{n=new Uint8Array(9);let s=new DataView(n.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(r))}i.data&&typeof i.data!="string"&&(n[0]|=128),e.enqueue(n),e.enqueue(t)})}})}var Br;function Gi(i){return i.reduce((e,t)=>e+t.length,0)}function Ki(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 ss(i,e){Br||(Br=new TextDecoder);let t=[],r=0,n=-1,s=!1;return new TransformStream({transform(o,c){for(t.push(o);;){if(r===0){if(Gi(t)<1)break;let l=Ki(t,1);s=(l[0]&128)===128,n=l[0]&127,n<126?r=3:n===126?r=1:r=2}else if(r===1){if(Gi(t)<2)break;let l=Ki(t,2);n=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(r===2){if(Gi(t)<8)break;let l=Ki(t,8),u=new DataView(l.buffer,l.byteOffset,l.length),h=u.getUint32(0);if(h>Math.pow(2,21)-1){c.enqueue(Jt);break}n=h*Math.pow(2,32)+u.getUint32(4),r=3}else{if(Gi(t)<n)break;let l=Ki(t,n);c.enqueue(Qt(s?l:Br.decode(l),e)),r=0}if(n===0||n>i){c.enqueue(Jt);break}}}})}var Mr=4;function L(i){if(i)return Fa(i)}function Fa(i){for(var e in L.prototype)i[e]=L.prototype[e];return i}L.prototype.on=L.prototype.addEventListener=function(i,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+i]=this._callbacks["$"+i]||[]).push(e),this};L.prototype.once=function(i,e){function t(){this.off(i,t),e.apply(this,arguments)}return t.fn=e,this.on(i,t),this};L.prototype.off=L.prototype.removeListener=L.prototype.removeAllListeners=L.prototype.removeEventListener=function(i,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+i];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+i],this;for(var r,n=0;n<t.length;n++)if(r=t[n],r===e||r.fn===e){t.splice(n,1);break}return t.length===0&&delete this._callbacks["$"+i],this};L.prototype.emit=function(i){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+i],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(t){t=t.slice(0);for(var r=0,n=t.length;r<n;++r)t[r].apply(this,e)}return this};L.prototype.emitReserved=L.prototype.emit;L.prototype.listeners=function(i){return this._callbacks=this._callbacks||{},this._callbacks["$"+i]||[]};L.prototype.hasListeners=function(i){return!!this.listeners(i).length};var Se=global;function Yi(i,...e){return e.reduce((t,r)=>(i.hasOwnProperty(r)&&(t[r]=i[r]),t),{})}var Ua=Se.setTimeout,Da=Se.clearTimeout;function Le(i,e){e.useNativeTimers?(i.setTimeoutFn=Ua.bind(Se),i.clearTimeoutFn=Da.bind(Se)):(i.setTimeoutFn=Se.setTimeout.bind(Se),i.clearTimeoutFn=Se.clearTimeout.bind(Se))}var Ba=1.33;function os(i){return typeof i=="string"?Ma(i):Math.ceil((i.byteLength||i.size)*Ba)}function Ma(i){let e=0,t=0;for(let r=0,n=i.length;r<n;r++)e=i.charCodeAt(r),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(r++,t+=4);return t}var vs=Q(ct(),1);function gs(i){let e="";for(let t in i)i.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(i[t]));return e}function ys(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 cc=(0,vs.default)("engine.io-client:transport"),jr=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},Fe=class extends L{constructor(e){super(),this.writable=!1,Le(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new jr(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):cc("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=Qt(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){let t=gs(e);return t.length?"?"+t:""}};var As=Q(ct(),1);var bs="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Gr=64,lc={},_s=0,er=0,Es;function Ss(i){let e="";do e=bs[i%Gr]+e,i=Math.floor(i/Gr);while(i>0);return e}function tr(){let i=Ss(+new Date);return i!==Es?(_s=0,Es=i):i+"."+Ss(_s++)}for(;er<Gr;er++)lc[bs[er]]=er;var Jr=Q(Cs(),1),Xr=Jr.default||Jr;function Ns(){return new Yr}function fc(i){let e=i.split("; "),t=e[0].indexOf("=");if(t===-1)return;let r=e[0].substring(0,t).trim();if(!r.length)return;let n=e[0].substring(t+1).trim();n.charCodeAt(0)===34&&(n=n.slice(1,-1));let s={name:r,value:n};for(let o=1;o<e.length;o++){let c=e[o].split("=");if(c.length!==2)continue;let l=c[0].trim(),u=c[1].trim();switch(l){case"Expires":s.expires=new Date(u);break;case"Max-Age":let h=new Date;h.setUTCSeconds(h.getUTCSeconds()+parseInt(u,10)),s.expires=h;break;default:}}return s}var Yr=class{constructor(){this.cookies=new Map}parseCookies(e){let t=e.getResponseHeader("set-cookie");t&&t.forEach(r=>{let n=fc(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 re=(0,As.default)("engine.io-client:polling");function uc(){}var dc=function(){return new Xr({xdomain:!1}).responseType!=null}(),ir=class extends Fe{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=dc&&!t,this.opts.withCredentials&&(this.cookieJar=Ns())}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";let t=()=>{re("paused"),this.readyState="paused",e()};if(this.polling||!this.writable){let r=0;this.polling&&(re("we are currently polling - waiting to pause"),r++,this.once("pollComplete",function(){re("pre-pause polling complete"),--r||t()})),this.writable||(re("we are currently writing - waiting to pause"),r++,this.once("drain",function(){re("pre-pause writing complete"),--r||t()}))}else t()}poll(){re("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){re("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)};rs(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this.poll():re('ignoring poll - transport state "%s"',this.readyState))}doClose(){let e=()=>{re("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(re("transport open - closing"),e()):(re("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,is(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]=tr()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new Ke(this.uri(),e)}doWrite(e,t){let r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",(n,s)=>{this.onError("xhr post error",n,s)})}doPoll(){re("xhr poll");let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,r)=>{this.onError("xhr poll error",t,r)}),this.pollXhr=e}},Ke=class i extends L{constructor(e,t){super(),Le(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=Yi(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;let r=this.xhr=new Xr(t);try{re("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))},re("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=uc,e)try{this.xhr.abort()}catch(t){}typeof document!="undefined"&&delete i.requests[this.index],this.xhr=null}}onLoad(){let e=this.xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}};Ke.requestsCount=0;Ke.requests={};if(typeof document!="undefined"){if(typeof attachEvent=="function")attachEvent("onunload",ks);else if(typeof addEventListener=="function"){let i="onpagehide"in Se?"pagehide":"unload";addEventListener(i,ks,!1)}}function ks(){for(let i in Ke.requests)Ke.requests.hasOwnProperty(i)&&Ke.requests[i].abort()}var xl=Q(Is(),1),wl=Q(an(),1),Cl=Q(ln(),1),Oo=Q(gn(),1),Nl=Q(To(),1);var Io=Oo.default;var hi=Io,ur=!1,Po="nodebuffer",ut=process.nextTick;var Fo=Q(ct(),1);var kl=(0,Fo.default)("engine.io-client:websocket"),Lo=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",dr=class extends Fe{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=Lo?{}:Yi(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=ur&&!Lo?t?new hi(e,t):new hi(e):new hi(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;Xt(r,this.supportsBinary,s=>{let o={};ur||(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{ur?this.ws.send(s):this.ws.send(s,o)}catch(c){kl("websocket closed before onclose event")}n&&ut(()=>{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]=tr()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!hi}};var Uo=Q(ct(),1),fi=(0,Uo.default)("engine.io-client:webtransport"),pr=class extends Fe{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{fi("transport closed gracefully"),this.onClose()}).catch(e=>{fi("transport closed due to %s",e),this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{let t=ss(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),n=ns();n.readable.pipeTo(e.writable),this.writer=n.writable.getWriter();let s=()=>{r.read().then(({done:c,value:l})=>{if(c){fi("session is closed");return}fi("received chunk: %o",l),this.onPacket(l),s()}).catch(c=>{fi("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&&ut(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}};var vn={websocket:dr,webtransport:pr,polling:ir};var Al=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Rl=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Rt(i){let e=i,t=i.indexOf("["),r=i.indexOf("]");t!=-1&&r!=-1&&(i=i.substring(0,t)+i.substring(t,r).replace(/:/g,";")+i.substring(r,i.length));let n=Al.exec(i||""),s={},o=14;for(;o--;)s[Rl[o]]=n[o]||"";return t!=-1&&r!=-1&&(s.source=e,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=Tl(s,s.path),s.queryKey=Ol(s,s.query),s}function Tl(i,e){let t=/\/{2,9}/g,r=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&r.splice(0,1),e.slice(-1)=="/"&&r.splice(r.length-1,1),r}function Ol(i,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,n,s){n&&(t[n]=s)}),t}var Do=Q(ct(),1);var D=(0,Do.default)("engine.io-client:socket"),dt=class i extends L{constructor(e,t={}){super(),this.binaryType=Po,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=Rt(e),t.hostname=e.host,t.secure=e.protocol==="https"||e.protocol==="wss",t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=Rt(t.host).host),Le(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=ys(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){D('creating transport "%s"',e);let t=Object.assign({},this.opts.query);t.EIO=Mr,t.transport=e,this.id&&(t.sid=this.id);let r=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return D("options: %j",r),new vn[e](r)}open(){let e;if(this.opts.rememberUpgrade&&i.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e=this.transports[0];this.readyState="opening";try{e=this.createTransport(e)}catch(t){D("error while creating transport: %s",t),this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){D("setting transport %s",e.name),this.transport&&(D("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",t=>this.onClose("transport close",t))}probe(e){D('probing transport "%s"',e);let t=this.createTransport(e),r=!1;i.priorWebsocketSuccess=!1;let n=()=>{r||(D('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",f=>{if(!r)if(f.type==="pong"&&f.data==="probe"){if(D('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;i.priorWebsocketSuccess=t.name==="websocket",D('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{r||this.readyState!=="closed"&&(D("changing transport and sending upgrade packet"),h(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{D('probe transport "%s" failed',e);let d=new Error("probe error");d.transport=t.name,this.emitReserved("upgradeError",d)}}))};function s(){r||(r=!0,h(),t.close(),t=null)}let o=f=>{let d=new Error("probe error: "+f);d.transport=t.name,s(),D('probe transport "%s" failed because of error: %s',e,f),this.emitReserved("upgradeError",d)};function c(){o("transport closed")}function l(){o("socket closed")}function u(f){t&&f.name!==t.name&&(D('"%s" works - aborting "%s"',f.name,t.name),s())}let h=()=>{t.removeListener("open",n),t.removeListener("error",o),t.removeListener("close",c),this.off("close",l),this.off("upgrading",u)};t.once("open",n),t.once("error",o),t.once("close",c),this.once("close",l),this.once("upgrading",u),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||t.open()},200):t.open()}onOpen(){if(D("socket open"),this.readyState="open",i.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){D("starting upgrade probes");let e=0,t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(D('socket receive: type "%s", data "%s"',e.type,e.data),this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":let t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}else D('packet received with socket readyState "%s"',this.readyState)}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this.getWritablePackets();D("flushing %d packets in socket",e.length),this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let r=0;r<this.writeBuffer.length;r++){let n=this.writeBuffer[r].data;if(n&&(t+=os(n)),r>0&&t>this.maxPayload)return D("only send %d out of %d packets",r,this.writeBuffer.length),this.writeBuffer.slice(0,r);t+=2}return D("payload size is %d (max: %d)",t,this.maxPayload),this.writeBuffer}write(e,t,r){return this.sendPacket("message",e,t,r),this}send(e,t,r){return this.sendPacket("message",e,t,r),this}sendPacket(e,t,r,n){if(typeof t=="function"&&(n=t,t=void 0),typeof r=="function"&&(n=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;let s={type:e,data:t,options:r};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),n&&this.once("flush",n),this.flush()}close(){let e=()=>{this.onClose("forced close"),D("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},r=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():e()}):this.upgrading?r():e()),this}onError(e){D("socket error %j",e),i.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(D('socket close with reason: "%s"',e),this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){let t=[],r=0,n=e.length;for(;r<n;r++)~this.transports.indexOf(e[r])&&t.push(e[r]);return t}};dt.protocol=Mr;var Id=dt.protocol;var $o=Q(ui(),1),zo=(0,$o.default)("socket.io-client:url");function Vo(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)||(zo("protocol-less url %s",i),typeof t!="undefined"?i=t.protocol+"//"+i:i="https://"+i),zo("parse %s",i),r=Rt(i)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";let s=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+s+":"+r.port+e,r.href=r.protocol+"://"+s+(t&&t.port===r.port?"":":"+r.port),r}var kn={};pa(kn,{Decoder:()=>Cn,Encoder:()=>wn,PacketType:()=>C,protocol:()=>Jo});var Gl=typeof ArrayBuffer=="function",Kl=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,Ho=Object.prototype.toString,Yl=typeof Blob=="function"||typeof Blob!="undefined"&&Ho.call(Blob)==="[object BlobConstructor]",Jl=typeof File=="function"||typeof File!="undefined"&&Ho.call(File)==="[object FileConstructor]";function pi(i){return Gl&&(i instanceof ArrayBuffer||Kl(i))||Yl&&i instanceof Blob||Jl&&i instanceof File}function di(i,e){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let t=0,r=i.length;t<r;t++)if(di(i[t]))return!0;return!1}if(pi(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return di(i.toJSON(),!0);for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&di(i[t]))return!0;return!1}function jo(i){let e=[],t=i.data,r=i;return r.data=Sn(t,e),r.attachments=e.length,{packet:r,buffers:e}}function Sn(i,e){if(!i)return i;if(pi(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]=Sn(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]=Sn(i[r],e));return t}return i}function Go(i,e){return i.data=bn(i.data,e),delete i.attachments,i}function bn(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]=bn(i[t],e);else if(typeof i=="object")for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(i[t]=bn(i[t],e));return i}var Yo=Q(ct(),1),xn=(0,Yo.default)("socket.io-parser"),Xl=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Jo=5,C;(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"})(C||(C={}));var wn=class{constructor(e){this.replacer=e}encode(e){return xn("encoding packet %j",e),(e.type===C.EVENT||e.type===C.ACK)&&di(e)?this.encodeAsBinary({type:e.type===C.EVENT?C.BINARY_EVENT:C.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===C.BINARY_EVENT||e.type===C.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)),xn("encoded %j as %s",e,t),t}encodeAsBinary(e){let t=jo(e),r=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(r),n}};function Ko(i){return Object.prototype.toString.call(i)==="[object Object]"}var Cn=class i extends L{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);let r=t.type===C.BINARY_EVENT;r||t.type===C.BINARY_ACK?(t.type=r?C.EVENT:C.ACK,this.reconstructor=new Nn(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(pi(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(C[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===C.BINARY_EVENT||r.type===C.BINARY_ACK){let s=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);let o=e.substring(s,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");r.attachments=Number(o)}if(e.charAt(t+1)==="/"){let s=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););r.nsp=e.substring(s,t)}else r.nsp="/";let n=e.charAt(t+1);if(n!==""&&Number(n)==n){let s=t+1;for(;++t;){let o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}r.id=Number(e.substring(s,t+1))}if(e.charAt(++t)){let s=this.tryParse(e.substr(t));if(i.isPayloadValid(r.type,s))r.data=s;else throw new Error("invalid payload")}return xn("decoded %s as %j",e,r),r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(t){return!1}}static isPayloadValid(e,t){switch(e){case C.CONNECT:return Ko(t);case C.DISCONNECT:return t===void 0;case C.CONNECT_ERROR:return typeof t=="string"||Ko(t);case C.EVENT:case C.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&Xl.indexOf(t[0])===-1);case C.ACK:case C.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},Nn=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=Go(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function le(i,e,t){return i.on(e,t),function(){i.off(e,t)}}var Xo=Q(ui(),1),z=(0,Xo.default)("socket.io-client:socket"),Ql=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Tt=class extends L{constructor(e,t,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[le(e,"open",this.onopen.bind(this)),le(e,"packet",this.onpacket.bind(this)),le(e,"error",this.onerror.bind(this)),le(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(Ql.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:C.EVENT,data:t};if(r.options={},r.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let o=this.ids++;z("emitting packet with ack id %d",o);let c=t.pop();this._registerAckCallback(o,c),r.id=o}let n=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!n||!this.connected)?z("discard packet as the transport is not currently writable"):this.connected?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r),this.flags={},this}_registerAckCallback(e,t){var r;let n=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let s=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let o=0;o<this.sendBuffer.length;o++)this.sendBuffer[o].id===e&&(z("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(o,1));z("event with ack id %d has timed out after %d ms",e,n),t.call(this,new Error("operation has timed out"))},n);this.acks[e]=(...o)=>{this.io.clearTimeoutFn(s),t.apply(this,[null,...o])}}emitWithAck(e,...t){let r=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((n,s)=>{t.push((o,c)=>r?o?s(o):n(c):n(o)),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());let r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((n,...s)=>r!==this._queue[0]?void 0:(n!==null?r.tryCount>this._opts.retries&&(z("packet [%d] is discarded after %d tries",r.id,r.tryCount),this._queue.shift(),t&&t(n)):(z("packet [%d] was successfully sent",r.id),this._queue.shift(),t&&t(null,...s)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(z("draining queue"),!this.connected||this._queue.length===0)return;let t=this._queue[0];if(t.pending&&!e){z("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,z("sending packet [%d] (try n\xB0%d)",t.id,t.tryCount),this.flags=t.flags,this.emit.apply(this,t.args)}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){z("transport is open - connecting"),typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:C.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){z("close (%s)",e),this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case C.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 C.EVENT:case C.BINARY_EVENT:this.onevent(e);break;case C.ACK:case C.BINARY_ACK:this.onack(e);break;case C.DISCONNECT:this.ondisconnect();break;case C.CONNECT_ERROR:this.destroy();let r=new Error(e.data.message);r.data=e.data.data,this.emitReserved("connect_error",r);break}}onevent(e){let t=e.data||[];z("emitting event %j",t),e.id!=null&&(z("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let r of t)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,r=!1;return function(...n){r||(r=!0,z("sending ack %j",n),t.packet({type:C.ACK,id:e,data:n}))}}onack(e){let t=this.acks[e.id];typeof t=="function"?(z("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):z("bad ack %s",e.id)}onconnect(e,t){z("socket connected with id %s",e),this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){z("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(z("performing disconnect (%s)",this.nsp),this.packet({type:C.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 pt(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}pt.prototype.duration=function(){var i=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*i);i=Math.floor(e*10)&1?i+t:i-t}return Math.min(i,this.max)|0};pt.prototype.reset=function(){this.attempts=0};pt.prototype.setMin=function(i){this.ms=i};pt.prototype.setMax=function(i){this.max=i};pt.prototype.setJitter=function(i){this.jitter=i};var Qo=Q(ui(),1),J=(0,Qo.default)("socket.io-client:manager"),Ot=class extends L{constructor(e,t){var r;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,Le(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 pt({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||kn;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(J("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;J("opening %s",this.uri),this.engine=new dt(this.uri,this.opts);let t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let n=le(t,"open",function(){r.onopen(),e&&e()}),s=c=>{J("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",c),e?e(c):this.maybeReconnectOnOpen()},o=le(t,"error",s);if(this._timeout!==!1){let c=this._timeout;J("connect attempt will timeout after %d",c);let l=this.setTimeoutFn(()=>{J("connect attempt timed out after %d",c),n(),s(new Error("timeout")),t.close()},c);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(n),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){J("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(le(e,"ping",this.onping.bind(this)),le(e,"data",this.ondata.bind(this)),le(e,"error",this.onerror.bind(this)),le(e,"close",this.onclose.bind(this)),le(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){ut(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){J("error",e),this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new Tt(this,e,t),this.nsps[e]=r),r}_destroy(e){let t=Object.keys(this.nsps);for(let r of t)if(this.nsps[r].active){J("socket %s is still active, skipping close",r);return}this._close()}_packet(e){J("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(){J("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){J("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){J("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)J("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();J("will wait %dms before reconnect attempt",t),this._reconnecting=!0;let r=this.setTimeoutFn(()=>{e.skipReconnect||(J("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(n=>{n?(J("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",n)):(J("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 ea=Q(ui(),1),Zo=(0,ea.default)("socket.io-client"),mi={};function gi(i,e){typeof i=="object"&&(e=i,i=void 0),e=e||{};let t=Vo(i,e.path||"/socket.io"),r=t.source,n=t.id,s=t.path,o=mi[n]&&s in mi[n].nsps,c=e.forceNew||e["force new connection"]||e.multiplex===!1||o,l;return c?(Zo("ignoring socket cache for %s",r),l=new Ot(r,e)):(mi[n]||(Zo("new io instance for %s",r),mi[n]=new Ot(r,e)),l=mi[n]),t.query&&!e.query&&(e.query=t.queryKey),l.socket(t.path,e)}Object.assign(gi,{Manager:Ot,Socket:Tt,io:gi,connect:gi});var Zl="https://ws.novu.co",ta="notifications.notification_received",ia="notifications.unseen_count_changed",ra="notifications.unread_count_changed",eh=({_id:i,transactionId:e,content:t,read:r,seen:n,archived:s,snoozedUntil:o,deliveredAt:c,createdAt:l,lastReadDate:u,firstSeenDate:h,archivedAt:f,channel:d,subscriber:p,subject:x,avatar:g,cta:v,tags:T,data:w,workflow:y,severity:b})=>{var Ze,et,ie,Me,qe,We,me,ge;let $={id:p==null?void 0:p._id,subscriberId:p==null?void 0:p.subscriberId,firstName:p==null?void 0:p.firstName,lastName:p==null?void 0:p.lastName,avatar:p==null?void 0:p.avatar,locale:p==null?void 0:p.locale,data:p==null?void 0:p.data,timezone:p==null?void 0:p.timezone,email:p==null?void 0:p.email,phone:p==null?void 0:p.phone},N=(et=(Ze=v.action)==null?void 0:Ze.buttons)==null?void 0:et.find(Te=>Te.type==="primary"),P=(Me=(ie=v.action)==null?void 0:ie.buttons)==null?void 0:Me.find(Te=>Te.type==="secondary"),q=(We=(qe=v.action)==null?void 0:qe.result)==null?void 0:We.type,ne=(me=v.action)==null?void 0:me.status;return A(E(E({id:i,transactionId:e,subject:x,body:t,to:$,isRead:r,isSeen:n,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:l,readAt:u,firstSeenAt:h,archivedAt:f,avatar:g,primaryAction:N&&{label:N.content,isCompleted:q==="primary"&&ne==="done",redirect:N.url?{target:N.target,url:N.url}:void 0},secondaryAction:P&&{label:P.content,isCompleted:q==="secondary"&&ne==="done",redirect:P.url?{target:P.target,url:P.url}:void 0},channelType:d,tags:T,redirect:(ge=v.data)!=null&&ge.url?{url:v.data.url,target:v.data.target}:void 0,data:w,workflow:y,severity:b})},It,xe,he,Pt,_r,Er,Sr,Ae,na,An,Rn,vr=class extends de{constructor({socketUrl:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});_(this,Ae);_(this,It);_(this,xe);_(this,he);_(this,Pt);_(this,_r,({message:t})=>{a(this,xe).emit(ta,{result:new U(eh(t),a(this,xe),this._inboxService)})});_(this,Er,({unseenCount:t})=>{a(this,xe).emit(ia,{result:t})});_(this,Sr,({counts:t})=>{a(this,xe).emit(ra,{result:t})});S(this,xe,n),S(this,Pt,t!=null?t:Zl)}onSessionSuccess({token:t}){S(this,It,t)}isSocketEvent(t){return t===ta||t===ia||t===ra}connect(){return m(this,null,function*(){return a(this,It)?ue(this,Ae,An).call(this):this.callWithSession(ue(this,Ae,An).bind(this))})}disconnect(){return m(this,null,function*(){return a(this,he)?ue(this,Ae,Rn).call(this):this.callWithSession(ue(this,Ae,Rn).bind(this))})}};It=new WeakMap,xe=new WeakMap,he=new WeakMap,Pt=new WeakMap,_r=new WeakMap,Er=new WeakMap,Sr=new WeakMap,Ae=new WeakSet,na=function(){return m(this,null,function*(){var r,n,s;if(a(this,he))return;let t={socketUrl:a(this,Pt)};a(this,xe).emit("socket.connect.pending",{args:t}),S(this,he,gi(a(this,Pt),{reconnectionDelayMax:1e4,transports:["websocket"],query:{token:`${a(this,It)}`}})),a(this,he).on("connect",()=>{a(this,xe).emit("socket.connect.resolved",{args:t})}),a(this,he).on("connect_error",o=>{a(this,xe).emit("socket.connect.resolved",{args:t,error:o})}),(r=a(this,he))==null||r.on("notification_received",a(this,_r)),(n=a(this,he))==null||n.on("unseen_count_changed",a(this,Er)),(s=a(this,he))==null||s.on("unread_count_changed",a(this,Sr))})},An=function(){return m(this,null,function*(){try{return yield ue(this,Ae,na).call(this),{}}catch(t){return{error:new k("Failed to initialize the socket",t)}}})},Rn=function(){return m(this,null,function*(){var t;try{return(t=a(this,he))==null||t.disconnect(),S(this,he,void 0),{}}catch(r){return{error:new k("Failed to disconnect from the socket",r)}}})};var th=["wss://eu.socket.novu.co",Kt,"wss://socket.novu-staging.co","wss://socket-worker-local.cli-shortener.workers.dev"],ih={"https://eu.ws.novu.co":"wss://eu.socket.novu.co","https://ws.novu.co":Kt,"https://dev.ws.novu.co":"wss://socket.novu-staging.co"};function rh(i){return i?ih[i]||i:Kt}function nh(i){return!i||th.includes(i)}function sa({socketUrl:i,inboxServiceInstance:e,eventEmitterInstance:t}){let r=rh(i);switch(nh(r)?"partysocket":"socket.io"){case"partysocket":return new zi({socketUrl:r,inboxServiceInstance:e,eventEmitterInstance:t});case"socket.io":default:return new vr({socketUrl:r,inboxServiceInstance:e,eventEmitterInstance:t})}}var Re,X,Qe,br=class{constructor(e){_(this,Re);_(this,X);_(this,Qe);var t,r;S(this,Qe,new Si({apiUrl:e.apiUrl||e.backendUrl,userAgent:e.__userAgent})),S(this,Re,new bi),S(this,X,new Bi({applicationIdentifier:e.applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:$n({subscriberId:e.subscriberId,subscriber:e.subscriber}),defaultSchedule:e.defaultSchedule,context:e.context,contextHash:e.contextHash},a(this,Qe),a(this,Re))),a(this,X).initialize(),this.notifications=new Oi({useCache:(t=e.useCache)!=null?t:!0,inboxServiceInstance:a(this,Qe),eventEmitterInstance:a(this,Re)}),this.preferences=new Di({useCache:(r=e.useCache)!=null?r:!0,inboxServiceInstance:a(this,Qe),eventEmitterInstance:a(this,Re)}),this.socket=sa({socketUrl:e.socketUrl,eventEmitterInstance:a(this,Re),inboxServiceInstance:a(this,Qe)}),this.on=(n,s)=>{this.socket.isSocketEvent(n)&&this.socket.connect();let o=a(this,Re).on(n,s);return()=>{o()}},this.off=(n,s)=>{a(this,Re).off(n,s)}}get applicationIdentifier(){return a(this,X).applicationIdentifier}get subscriberId(){return a(this,X).subscriberId}get context(){return a(this,X).context}get contextKey(){return zn(a(this,X).context)}changeSubscriber(e){return m(this,null,function*(){yield a(this,X).initialize({applicationIdentifier:a(this,X).applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:e.subscriber,context:a(this,X).context,contextHash:a(this,X).contextHash}),this.notifications.cache.clearAll(),(yield this.socket.disconnect()).error||(yield this.socket.connect())})}changeContext(e){return m(this,null,function*(){let t=a(this,X).subscriber;if(!t)throw new Error("Cannot change context without an active subscriber");yield a(this,X).initialize({applicationIdentifier:a(this,X).applicationIdentifier||"",subscriberHash:a(this,X).subscriberHash,subscriber:t,context:e.context,contextHash:e.contextHash}),this.notifications.cache.clearAll(),(yield this.socket.disconnect()).error||(yield this.socket.connect())})}};Re=new WeakMap,X=new WeakMap,Qe=new WeakMap;window.Novu=br;})();
|
|
37
|
+
`),ws=!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 an.ErrorEvent(Error(n.message),this))})}_handleTimeout(){this._debug("timeout event"),this._handleError(new an.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 an.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 mi="wss://socket.novu.co",Ns="notifications.notification_received",ks="notifications.unseen_count_changed",As="notifications.unread_count_changed",fc=({_id:i,transactionId:e,content:t,read:r,seen:n,archived:s,snoozedUntil:o,deliveredAt:c,createdAt:l,lastReadDate:h,firstSeenDate:u,archivedAt:f,channel:p,subscriber:m,subject:C,avatar:b,cta:_,tags:T,data:N,workflow:S,severity:E})=>{var ht,ft,se,Ye,Je,Xe,be,Se;let V={id:m==null?void 0:m._id,subscriberId:m==null?void 0:m.subscriberId,firstName:m==null?void 0:m.firstName,lastName:m==null?void 0:m.lastName,avatar:m==null?void 0:m.avatar,locale:m==null?void 0:m.locale,data:m==null?void 0:m.data,timezone:m==null?void 0:m.timezone,email:m==null?void 0:m.email,phone:m==null?void 0:m.phone},R=(ft=(ht=_.action)==null?void 0:ht.buttons)==null?void 0:ft.find(Fe=>Fe.type==="primary"),P=(Ye=(se=_.action)==null?void 0:se.buttons)==null?void 0:Ye.find(Fe=>Fe.type==="secondary"),$=(Xe=(Je=_.action)==null?void 0:Je.result)==null?void 0:Xe.type,le=(be=_.action)==null?void 0:be.status;return x(y(y({id:i,transactionId:e,subject:C,body:t,to:V,isRead:r,isSeen:n,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:l,readAt:h,firstSeenAt:u,archivedAt:f,avatar:b,primaryAction:R&&{label:R.content,isCompleted:$==="primary"&&le==="done",redirect:R.url?{target:R.target,url:R.url}:void 0},secondaryAction:P&&{label:P.content,isCompleted:$==="secondary"&&le==="done",redirect:P.url?{target:P.target,url:P.url}:void 0},channelType:p,tags:T,redirect:(Se=_.data)!=null&&Se.url?{url:_.data.url,target:_.data.target}:void 0,data:N,workflow:S,severity:E})},Pt,we,xe,Lt,mr,yr,gr,vr,Oe,Rs,cn,ln,pr=class extends ae{constructor({socketUrl:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});g(this,Oe);g(this,Pt);g(this,we);g(this,xe);g(this,Lt);g(this,mr,t=>{try{let r=JSON.parse(t.data);r.event==="notification_received"&&a(this,we).emit(Ns,{result:new U(fc(r.data.message),a(this,we),this._inboxService)})}catch(r){console.log("error",r)}});g(this,yr,t=>{try{let r=JSON.parse(t.data);r.event==="unseen_count_changed"&&a(this,we).emit(ks,{result:r.data.unseenCount})}catch(r){}});g(this,gr,t=>{try{let r=JSON.parse(t.data);r.event==="unread_count_changed"&&a(this,we).emit(As,{result:r.data.counts})}catch(r){}});g(this,vr,t=>{try{switch(JSON.parse(t.data).event){case"notification_received":a(this,mr).call(this,t);break;case"unseen_count_changed":a(this,yr).call(this,t);break;case"unread_count_changed":a(this,gr).call(this,t);break;default:}}catch(r){}});v(this,we,n),v(this,Lt,t!=null?t:mi)}onSessionSuccess({token:t}){v(this,Pt,t)}isSocketEvent(t){return t===Ns||t===ks||t===As}connect(){return d(this,null,function*(){return a(this,Pt)?ge(this,Oe,cn).call(this):this.callWithSession(ge(this,Oe,cn).bind(this))})}disconnect(){return d(this,null,function*(){return a(this,xe)?ge(this,Oe,ln).call(this):this.callWithSession(ge(this,Oe,ln).bind(this))})}};Pt=new WeakMap,we=new WeakMap,xe=new WeakMap,Lt=new WeakMap,mr=new WeakMap,yr=new WeakMap,gr=new WeakMap,vr=new WeakMap,Oe=new WeakSet,Rs=function(){return d(this,null,function*(){if(a(this,xe))return;let t={socketUrl:a(this,Lt)};a(this,we).emit("socket.connect.pending",{args:t});let r=new URL(a(this,Lt));r.searchParams.set("token",a(this,Pt)),v(this,xe,new dr(r.toString())),a(this,xe).addEventListener("open",()=>{a(this,we).emit("socket.connect.resolved",{args:t})}),a(this,xe).addEventListener("error",n=>{a(this,we).emit("socket.connect.resolved",{args:t,error:n})}),a(this,xe).addEventListener("message",a(this,vr))})},cn=function(){return d(this,null,function*(){try{return yield ge(this,Oe,Rs).call(this),{}}catch(t){return{error:new w("Failed to initialize the PartySocket",t)}}})},ln=function(){return d(this,null,function*(){var t;try{return(t=a(this,xe))==null||t.close(),v(this,xe,void 0),{}}catch(r){return{error:new w("Failed to disconnect from the PartySocket",r)}}})};var Ce=Object.create(null);Ce.open="0";Ce.close="1";Ce.ping="2";Ce.pong="3";Ce.message="4";Ce.upgrade="5";Ce.noop="6";var yi=Object.create(null);Object.keys(Ce).forEach(i=>{yi[Ce[i]]=i});var gi={type:"error",data:"parser error"};var vi=({type:i,data:e},t,r)=>e instanceof ArrayBuffer||ArrayBuffer.isView(e)?r(t?e:"b"+Is(e,!0).toString("base64")):r(Ce[i]+(e||"")),Is=(i,e)=>Buffer.isBuffer(i)||i instanceof Uint8Array&&!e?i:i instanceof ArrayBuffer?Buffer.from(i):Buffer.from(i.buffer,i.byteOffset,i.byteLength),un;function Ts(i,e){if(i.data instanceof ArrayBuffer||ArrayBuffer.isView(i.data))return e(Is(i.data,!1));vi(i,!0,t=>{un||(un=new TextEncoder),e(un.encode(t))})}var bi=(i,e)=>{if(typeof i!="string")return{type:"message",data:Os(i,e)};let t=i.charAt(0);if(t==="b"){let r=Buffer.from(i.substring(1),"base64");return{type:"message",data:Os(r,e)}}return yi[t]?i.length>1?{type:yi[t],data:i.substring(1)}:{type:yi[t]}:gi},Os=(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 Ps="",Ls=(i,e)=>{let t=i.length,r=new Array(t),n=0;i.forEach((s,o)=>{vi(s,!1,c=>{r[o]=c,++n===t&&e(r.join(Ps))})})},Fs=(i,e)=>{let t=i.split(Ps),r=[];for(let n=0;n<t.length;n++){let s=bi(t[n],e);if(r.push(s),s.type==="error")break}return r};function Us(){return new TransformStream({transform(i,e){Ts(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 hn;function br(i){return i.reduce((e,t)=>e+t.length,0)}function Sr(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 Ds(i,e){hn||(hn=new TextDecoder);let t=[],r=0,n=-1,s=!1;return new TransformStream({transform(o,c){for(t.push(o);;){if(r===0){if(br(t)<1)break;let l=Sr(t,1);s=(l[0]&128)===128,n=l[0]&127,n<126?r=3:n===126?r=1:r=2}else if(r===1){if(br(t)<2)break;let l=Sr(t,2);n=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(r===2){if(br(t)<8)break;let l=Sr(t,8),h=new DataView(l.buffer,l.byteOffset,l.length),u=h.getUint32(0);if(u>Math.pow(2,21)-1){c.enqueue(gi);break}n=u*Math.pow(2,32)+h.getUint32(4),r=3}else{if(br(t)<n)break;let l=Sr(t,n);c.enqueue(bi(s?l:hn.decode(l),e)),r=0}if(n===0||n>i){c.enqueue(gi);break}}}})}var fn=4;function L(i){if(i)return dc(i)}function dc(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 Ne=global;function _r(i,...e){return e.reduce((t,r)=>(i.hasOwnProperty(r)&&(t[r]=i[r]),t),{})}var pc=Ne.setTimeout,mc=Ne.clearTimeout;function Ke(i,e){e.useNativeTimers?(i.setTimeoutFn=pc.bind(Ne),i.clearTimeoutFn=mc.bind(Ne)):(i.setTimeoutFn=Ne.setTimeout.bind(Ne),i.clearTimeoutFn=Ne.clearTimeout.bind(Ne))}var yc=1.33;function Bs(i){return typeof i=="string"?gc(i):Math.ceil((i.byteLength||i.size)*yc)}function gc(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 Js=te(St(),1);function Gs(i){let e="";for(let t in i)i.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(i[t]));return e}function Ys(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 qc=(0,Js.default)("engine.io-client:transport"),bn=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},ze=class extends L{constructor(e){super(),this.writable=!1,Ke(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new bn(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):qc("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=bi(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=Gs(e);return t.length?"?"+t:""}};var oo=te(St(),1);var eo="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Sn=64,Wc={},Xs=0,Nr=0,Qs;function Zs(i){let e="";do e=eo[i%Sn]+e,i=Math.floor(i/Sn);while(i>0);return e}function kr(){let i=Zs(+new Date);return i!==Qs?(Xs=0,Qs=i):i+"."+Zs(Xs++)}for(;Nr<Sn;Nr++)Wc[eo[Nr]]=Nr;var wn=te(ro(),1),xn=wn.default||wn;function no(){return new En}function Kc(i){let e=i.split("; "),t=e[0].indexOf("=");if(t===-1)return;let r=e[0].substring(0,t).trim();if(!r.length)return;let n=e[0].substring(t+1).trim();n.charCodeAt(0)===34&&(n=n.slice(1,-1));let s={name:r,value:n};for(let o=1;o<e.length;o++){let c=e[o].split("=");if(c.length!==2)continue;let l=c[0].trim(),h=c[1].trim();switch(l){case"Expires":s.expires=new Date(h);break;case"Max-Age":let u=new Date;u.setUTCSeconds(u.getUTCSeconds()+parseInt(h,10)),s.expires=u;break;default:}}return s}var En=class{constructor(){this.cookies=new Map}parseCookies(e){let t=e.getResponseHeader("set-cookie");t&&t.forEach(r=>{let n=Kc(r);n&&this.cookies.set(n.name,n)})}addCookies(e){let t=[];this.cookies.forEach((r,n)=>{var s;((s=r.expires)===null||s===void 0?void 0:s.getTime())<Date.now()?this.cookies.delete(n):t.push(`${n}=${r.value}`)}),t.length&&(e.setDisableHeaderCheck(!0),e.setRequestHeader("cookie",t.join("; ")))}};var ce=(0,oo.default)("engine.io-client:polling");function zc(){}var Vc=function(){return new xn({xdomain:!1}).responseType!=null}(),Ar=class extends ze{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=Vc&&!t,this.opts.withCredentials&&(this.cookieJar=no())}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";let t=()=>{ce("paused"),this.readyState="paused",e()};if(this.polling||!this.writable){let r=0;this.polling&&(ce("we are currently polling - waiting to pause"),r++,this.once("pollComplete",function(){ce("pre-pause polling complete"),--r||t()})),this.writable||(ce("we are currently writing - waiting to pause"),r++,this.once("drain",function(){ce("pre-pause writing complete"),--r||t()}))}else t()}poll(){ce("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){ce("polling got data %s",e);let t=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};Fs(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this.poll():ce('ignoring poll - transport state "%s"',this.readyState))}doClose(){let e=()=>{ce("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(ce("transport open - closing"),e()):(ce("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,Ls(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]=kr()),!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 at(this.uri(),e)}doWrite(e,t){let r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",(n,s)=>{this.onError("xhr post error",n,s)})}doPoll(){ce("xhr poll");let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,r)=>{this.onError("xhr poll error",t,r)}),this.pollXhr=e}},at=class i extends L{constructor(e,t){super(),Ke(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=_r(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;let r=this.xhr=new xn(t);try{ce("xhr open %s: %s",this.method,this.uri),r.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let n in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(n)&&r.setRequestHeader(n,this.opts.extraHeaders[n])}}catch(n){}if(this.method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(n){}try{r.setRequestHeader("Accept","*/*")}catch(n){}(e=this.opts.cookieJar)===null||e===void 0||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(r.timeout=this.opts.requestTimeout),r.onreadystatechange=()=>{var n;r.readyState===3&&((n=this.opts.cookieJar)===null||n===void 0||n.parseCookies(r)),r.readyState===4&&(r.status===200||r.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof r.status=="number"?r.status:0)},0))},ce("xhr data %s",this.data),r.send(this.data)}catch(n){this.setTimeoutFn(()=>{this.onError(n)},0);return}typeof document!="undefined"&&(this.index=i.requestsCount++,i.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(!(typeof this.xhr=="undefined"||this.xhr===null)){if(this.xhr.onreadystatechange=zc,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()}};at.requestsCount=0;at.requests={};if(typeof document!="undefined"){if(typeof attachEvent=="function")attachEvent("onunload",so);else if(typeof addEventListener=="function"){let i="onpagehide"in Ne?"pagehide":"unload";addEventListener(i,so,!1)}}function so(){for(let i in at.requests)at.requests.hasOwnProperty(i)&&at.requests[i].abort()}var tu=te(uo(),1),iu=te(Pn(),1),ru=te(Fn(),1),la=te($n(),1),nu=te(ca(),1);var ua=la.default;var Ti=ua,Br=!1,ha="nodebuffer",xt=process.nextTick;var da=te(St(),1);var su=(0,da.default)("engine.io-client:websocket"),fa=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",Mr=class extends ze{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=fa?{}:_r(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=Br&&!fa?t?new Ti(e,t):new Ti(e):new Ti(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;vi(r,this.supportsBinary,s=>{let o={};Br||(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{Br?this.ws.send(s):this.ws.send(s,o)}catch(c){su("websocket closed before onclose event")}n&&xt(()=>{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]=kr()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!Ti}};var pa=te(St(),1),Oi=(0,pa.default)("engine.io-client:webtransport"),qr=class extends ze{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{Oi("transport closed gracefully"),this.onClose()}).catch(e=>{Oi("transport closed due to %s",e),this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{let t=Ds(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),n=Us();n.readable.pipeTo(e.writable),this.writer=n.writable.getWriter();let s=()=>{r.read().then(({done:c,value:l})=>{if(c){Oi("session is closed");return}Oi("received chunk: %o",l),this.onPacket(l),s()}).catch(c=>{Oi("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&&xt(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}};var zn={websocket:Mr,webtransport:qr,polling:Ar};var ou=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,au=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function $t(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=ou.exec(i||""),s={},o=14;for(;o--;)s[au[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=cu(s,s.path),s.queryKey=lu(s,s.query),s}function cu(i,e){let t=/\/{2,9}/g,r=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&r.splice(0,1),e.slice(-1)=="/"&&r.splice(r.length-1,1),r}function lu(i,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,n,s){n&&(t[n]=s)}),t}var ma=te(St(),1);var D=(0,ma.default)("engine.io-client:socket"),Ct=class i extends L{constructor(e,t={}){super(),this.binaryType=ha,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=$t(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=$t(t.host).host),Ke(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=Ys(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){D('creating transport "%s"',e);let t=Object.assign({},this.opts.query);t.EIO=fn,t.transport=e,this.id&&(t.sid=this.id);let r=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return D("options: %j",r),new zn[e](r)}open(){let e;if(this.opts.rememberUpgrade&&i.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e=this.transports[0];this.readyState="opening";try{e=this.createTransport(e)}catch(t){D("error while creating transport: %s",t),this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){D("setting transport %s",e.name),this.transport&&(D("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",t=>this.onClose("transport close",t))}probe(e){D('probing transport "%s"',e);let t=this.createTransport(e),r=!1;i.priorWebsocketSuccess=!1;let n=()=>{r||(D('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",f=>{if(!r)if(f.type==="pong"&&f.data==="probe"){if(D('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;i.priorWebsocketSuccess=t.name==="websocket",D('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{r||this.readyState!=="closed"&&(D("changing transport and sending upgrade packet"),u(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{D('probe transport "%s" failed',e);let p=new Error("probe error");p.transport=t.name,this.emitReserved("upgradeError",p)}}))};function s(){r||(r=!0,u(),t.close(),t=null)}let o=f=>{let p=new Error("probe error: "+f);p.transport=t.name,s(),D('probe transport "%s" failed because of error: %s',e,f),this.emitReserved("upgradeError",p)};function c(){o("transport closed")}function l(){o("socket closed")}function h(f){t&&f.name!==t.name&&(D('"%s" works - aborting "%s"',f.name,t.name),s())}let u=()=>{t.removeListener("open",n),t.removeListener("error",o),t.removeListener("close",c),this.off("close",l),this.off("upgrading",h)};t.once("open",n),t.once("error",o),t.once("close",c),this.once("close",l),this.once("upgrading",h),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||t.open()},200):t.open()}onOpen(){if(D("socket open"),this.readyState="open",i.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){D("starting upgrade probes");let e=0,t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(D('socket receive: type "%s", data "%s"',e.type,e.data),this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":let t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}else D('packet received with socket readyState "%s"',this.readyState)}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this.getWritablePackets();D("flushing %d packets in socket",e.length),this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let r=0;r<this.writeBuffer.length;r++){let n=this.writeBuffer[r].data;if(n&&(t+=Bs(n)),r>0&&t>this.maxPayload)return D("only send %d out of %d packets",r,this.writeBuffer.length),this.writeBuffer.slice(0,r);t+=2}return D("payload size is %d (max: %d)",t,this.maxPayload),this.writeBuffer}write(e,t,r){return this.sendPacket("message",e,t,r),this}send(e,t,r){return this.sendPacket("message",e,t,r),this}sendPacket(e,t,r,n){if(typeof t=="function"&&(n=t,t=void 0),typeof r=="function"&&(n=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;let s={type:e,data:t,options:r};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),n&&this.once("flush",n),this.flush()}close(){let e=()=>{this.onClose("forced close"),D("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},r=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():e()}):this.upgrading?r():e()),this}onError(e){D("socket error %j",e),i.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(D('socket close with reason: "%s"',e),this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){let t=[],r=0,n=e.length;for(;r<n;r++)~this.transports.indexOf(e[r])&&t.push(e[r]);return t}};Ct.protocol=fn;var Dp=Ct.protocol;var _a=te(Pi(),1),Sa=(0,_a.default)("socket.io-client:url");function Ea(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)||(Sa("protocol-less url %s",i),typeof t!="undefined"?i=t.protocol+"//"+i:i="https://"+i),Sa("parse %s",i),r=$t(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 Zn={};Ha(Zn,{Decoder:()=>Xn,Encoder:()=>Jn,PacketType:()=>A,protocol:()=>Aa});var Cu=typeof ArrayBuffer=="function",Nu=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,wa=Object.prototype.toString,ku=typeof Blob=="function"||typeof Blob!="undefined"&&wa.call(Blob)==="[object BlobConstructor]",Au=typeof File=="function"||typeof File!="undefined"&&wa.call(File)==="[object FileConstructor]";function Fi(i){return Cu&&(i instanceof ArrayBuffer||Nu(i))||ku&&i instanceof Blob||Au&&i instanceof File}function Li(i,e){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let t=0,r=i.length;t<r;t++)if(Li(i[t]))return!0;return!1}if(Fi(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return Li(i.toJSON(),!0);for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&Li(i[t]))return!0;return!1}function xa(i){let e=[],t=i.data,r=i;return r.data=jn(t,e),r.attachments=e.length,{packet:r,buffers:e}}function jn(i,e){if(!i)return i;if(Fi(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]=jn(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]=jn(i[r],e));return t}return i}function Ca(i,e){return i.data=Gn(i.data,e),delete i.attachments,i}function Gn(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]=Gn(i[t],e);else if(typeof i=="object")for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(i[t]=Gn(i[t],e));return i}var ka=te(St(),1),Yn=(0,ka.default)("socket.io-parser"),Ru=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Aa=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 Jn=class{constructor(e){this.replacer=e}encode(e){return Yn("encoding packet %j",e),(e.type===A.EVENT||e.type===A.ACK)&&Li(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)),Yn("encoded %j as %s",e,t),t}encodeAsBinary(e){let t=xa(e),r=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(r),n}};function Na(i){return Object.prototype.toString.call(i)==="[object Object]"}var Xn=class i extends L{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);let r=t.type===A.BINARY_EVENT;r||t.type===A.BINARY_ACK?(t.type=r?A.EVENT:A.ACK,this.reconstructor=new Qn(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(Fi(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0,r={type:Number(e.charAt(0))};if(A[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===A.BINARY_EVENT||r.type===A.BINARY_ACK){let s=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);let o=e.substring(s,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");r.attachments=Number(o)}if(e.charAt(t+1)==="/"){let s=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););r.nsp=e.substring(s,t)}else r.nsp="/";let n=e.charAt(t+1);if(n!==""&&Number(n)==n){let s=t+1;for(;++t;){let o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}r.id=Number(e.substring(s,t+1))}if(e.charAt(++t)){let s=this.tryParse(e.substr(t));if(i.isPayloadValid(r.type,s))r.data=s;else throw new Error("invalid payload")}return Yn("decoded %s as %j",e,r),r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(t){return!1}}static isPayloadValid(e,t){switch(e){case A.CONNECT:return Na(t);case A.DISCONNECT:return t===void 0;case A.CONNECT_ERROR:return typeof t=="string"||Na(t);case A.EVENT:case A.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&Ru.indexOf(t[0])===-1);case A.ACK:case A.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},Qn=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=Ca(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function pe(i,e,t){return i.on(e,t),function(){i.off(e,t)}}var Ra=te(Pi(),1),z=(0,Ra.default)("socket.io-client:socket"),Iu=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Kt=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=[pe(e,"open",this.onopen.bind(this)),pe(e,"packet",this.onpacket.bind(this)),pe(e,"error",this.onerror.bind(this)),pe(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(Iu.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++;z("emitting packet with ack id %d",o);let c=t.pop();this._registerAckCallback(o,c),r.id=o}let n=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!n||!this.connected)?z("discard packet as the transport is not currently writable"):this.connected?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r),this.flags={},this}_registerAckCallback(e,t){var r;let n=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let s=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let o=0;o<this.sendBuffer.length;o++)this.sendBuffer[o].id===e&&(z("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(o,1));z("event with ack id %d has timed out after %d ms",e,n),t.call(this,new Error("operation has timed out"))},n);this.acks[e]=(...o)=>{this.io.clearTimeoutFn(s),t.apply(this,[null,...o])}}emitWithAck(e,...t){let r=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((n,s)=>{t.push((o,c)=>r?o?s(o):n(c):n(o)),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());let r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((n,...s)=>r!==this._queue[0]?void 0:(n!==null?r.tryCount>this._opts.retries&&(z("packet [%d] is discarded after %d tries",r.id,r.tryCount),this._queue.shift(),t&&t(n)):(z("packet [%d] was successfully sent",r.id),this._queue.shift(),t&&t(null,...s)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(z("draining queue"),!this.connected||this._queue.length===0)return;let t=this._queue[0];if(t.pending&&!e){z("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,z("sending packet [%d] (try n\xB0%d)",t.id,t.tryCount),this.flags=t.flags,this.emit.apply(this,t.args)}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){z("transport is open - connecting"),typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type: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){z("close (%s)",e),this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case 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||[];z("emitting event %j",t),e.id!=null&&(z("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let r of t)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,r=!1;return function(...n){r||(r=!0,z("sending ack %j",n),t.packet({type:A.ACK,id:e,data:n}))}}onack(e){let t=this.acks[e.id];typeof t=="function"?(z("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):z("bad ack %s",e.id)}onconnect(e,t){z("socket connected with id %s",e),this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){z("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(z("performing disconnect (%s)",this.nsp),this.packet({type: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 Nt(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}Nt.prototype.duration=function(){var i=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*i);i=Math.floor(e*10)&1?i+t:i-t}return Math.min(i,this.max)|0};Nt.prototype.reset=function(){this.attempts=0};Nt.prototype.setMin=function(i){this.ms=i};Nt.prototype.setMax=function(i){this.max=i};Nt.prototype.setJitter=function(i){this.jitter=i};var Ia=te(Pi(),1),Z=(0,Ia.default)("socket.io-client:manager"),zt=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,Ke(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 Nt({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||Zn;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(Z("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;Z("opening %s",this.uri),this.engine=new Ct(this.uri,this.opts);let t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let n=pe(t,"open",function(){r.onopen(),e&&e()}),s=c=>{Z("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",c),e?e(c):this.maybeReconnectOnOpen()},o=pe(t,"error",s);if(this._timeout!==!1){let c=this._timeout;Z("connect attempt will timeout after %d",c);let l=this.setTimeoutFn(()=>{Z("connect attempt timed out after %d",c),n(),s(new Error("timeout")),t.close()},c);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(n),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){Z("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(pe(e,"ping",this.onping.bind(this)),pe(e,"data",this.ondata.bind(this)),pe(e,"error",this.onerror.bind(this)),pe(e,"close",this.onclose.bind(this)),pe(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){xt(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){Z("error",e),this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new Kt(this,e,t),this.nsps[e]=r),r}_destroy(e){let t=Object.keys(this.nsps);for(let r of t)if(this.nsps[r].active){Z("socket %s is still active, skipping close",r);return}this._close()}_packet(e){Z("writing packet %j",e);let t=this.encoder.encode(e);for(let r=0;r<t.length;r++)this.engine.write(t[r],e.options)}cleanup(){Z("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){Z("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){Z("closed due to %s",e),this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)Z("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();Z("will wait %dms before reconnect attempt",t),this._reconnecting=!0;let r=this.setTimeoutFn(()=>{e.skipReconnect||(Z("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(n=>{n?(Z("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",n)):(Z("reconnect success"),e.onreconnect())}))},t);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}};var Oa=te(Pi(),1),Ta=(0,Oa.default)("socket.io-client"),Ui={};function Di(i,e){typeof i=="object"&&(e=i,i=void 0),e=e||{};let t=Ea(i,e.path||"/socket.io"),r=t.source,n=t.id,s=t.path,o=Ui[n]&&s in Ui[n].nsps,c=e.forceNew||e["force new connection"]||e.multiplex===!1||o,l;return c?(Ta("ignoring socket cache for %s",r),l=new zt(r,e)):(Ui[n]||(Ta("new io instance for %s",r),Ui[n]=new zt(r,e)),l=Ui[n]),t.query&&!e.query&&(e.query=t.queryKey),l.socket(t.path,e)}Object.assign(Di,{Manager:zt,Socket:Kt,io:Di,connect:Di});var Tu="https://ws.novu.co",Pa="notifications.notification_received",La="notifications.unseen_count_changed",Fa="notifications.unread_count_changed",Ou=({_id:i,transactionId:e,content:t,read:r,seen:n,archived:s,snoozedUntil:o,deliveredAt:c,createdAt:l,lastReadDate:h,firstSeenDate:u,archivedAt:f,channel:p,subscriber:m,subject:C,avatar:b,cta:_,tags:T,data:N,workflow:S,severity:E})=>{var ht,ft,se,Ye,Je,Xe,be,Se;let V={id:m==null?void 0:m._id,subscriberId:m==null?void 0:m.subscriberId,firstName:m==null?void 0:m.firstName,lastName:m==null?void 0:m.lastName,avatar:m==null?void 0:m.avatar,locale:m==null?void 0:m.locale,data:m==null?void 0:m.data,timezone:m==null?void 0:m.timezone,email:m==null?void 0:m.email,phone:m==null?void 0:m.phone},R=(ft=(ht=_.action)==null?void 0:ht.buttons)==null?void 0:ft.find(Fe=>Fe.type==="primary"),P=(Ye=(se=_.action)==null?void 0:se.buttons)==null?void 0:Ye.find(Fe=>Fe.type==="secondary"),$=(Xe=(Je=_.action)==null?void 0:Je.result)==null?void 0:Xe.type,le=(be=_.action)==null?void 0:be.status;return x(y(y({id:i,transactionId:e,subject:C,body:t,to:V,isRead:r,isSeen:n,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:l,readAt:h,firstSeenAt:u,archivedAt:f,avatar:b,primaryAction:R&&{label:R.content,isCompleted:$==="primary"&&le==="done",redirect:R.url?{target:R.target,url:R.url}:void 0},secondaryAction:P&&{label:P.content,isCompleted:$==="secondary"&&le==="done",redirect:P.url?{target:P.target,url:P.url}:void 0},channelType:p,tags:T,redirect:(Se=_.data)!=null&&Se.url?{url:_.data.url,target:_.data.target}:void 0,data:N,workflow:S,severity:E})},Vt,Ae,me,Ht,Vr,Hr,jr,Le,Ua,es,ts,zr=class extends ae{constructor({socketUrl:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});g(this,Le);g(this,Vt);g(this,Ae);g(this,me);g(this,Ht);g(this,Vr,({message:t})=>{a(this,Ae).emit(Pa,{result:new U(Ou(t),a(this,Ae),this._inboxService)})});g(this,Hr,({unseenCount:t})=>{a(this,Ae).emit(La,{result:t})});g(this,jr,({counts:t})=>{a(this,Ae).emit(Fa,{result:t})});v(this,Ae,n),v(this,Ht,t!=null?t:Tu)}onSessionSuccess({token:t}){v(this,Vt,t)}isSocketEvent(t){return t===Pa||t===La||t===Fa}connect(){return d(this,null,function*(){return a(this,Vt)?ge(this,Le,es).call(this):this.callWithSession(ge(this,Le,es).bind(this))})}disconnect(){return d(this,null,function*(){return a(this,me)?ge(this,Le,ts).call(this):this.callWithSession(ge(this,Le,ts).bind(this))})}};Vt=new WeakMap,Ae=new WeakMap,me=new WeakMap,Ht=new WeakMap,Vr=new WeakMap,Hr=new WeakMap,jr=new WeakMap,Le=new WeakSet,Ua=function(){return d(this,null,function*(){var r,n,s;if(a(this,me))return;let t={socketUrl:a(this,Ht)};a(this,Ae).emit("socket.connect.pending",{args:t}),v(this,me,Di(a(this,Ht),{reconnectionDelayMax:1e4,transports:["websocket"],query:{token:`${a(this,Vt)}`}})),a(this,me).on("connect",()=>{a(this,Ae).emit("socket.connect.resolved",{args:t})}),a(this,me).on("connect_error",o=>{a(this,Ae).emit("socket.connect.resolved",{args:t,error:o})}),(r=a(this,me))==null||r.on("notification_received",a(this,Vr)),(n=a(this,me))==null||n.on("unseen_count_changed",a(this,Hr)),(s=a(this,me))==null||s.on("unread_count_changed",a(this,jr))})},es=function(){return d(this,null,function*(){try{return yield ge(this,Le,Ua).call(this),{}}catch(t){return{error:new w("Failed to initialize the socket",t)}}})},ts=function(){return d(this,null,function*(){var t;try{return(t=a(this,me))==null||t.disconnect(),v(this,me,void 0),{}}catch(r){return{error:new w("Failed to disconnect from the socket",r)}}})};var Pu=["wss://eu.socket.novu.co",mi,"wss://socket.novu-staging.co","wss://socket-worker-local.cli-shortener.workers.dev"],Lu={"https://eu.ws.novu.co":"wss://eu.socket.novu.co","https://ws.novu.co":mi,"https://dev.ws.novu.co":"wss://socket.novu-staging.co"};function Fu(i){return i?Lu[i]||i:mi}function Uu(i){return!i||Pu.includes(i)}function Da({socketUrl:i,inboxServiceInstance:e,eventEmitterInstance:t}){let r=Fu(i);switch(Uu(r)?"partysocket":"socket.io"){case"partysocket":return new pr({socketUrl:r,inboxServiceInstance:e,eventEmitterInstance:t});case"socket.io":default:return new zr({socketUrl:r,inboxServiceInstance:e,eventEmitterInstance:t})}}var Re,ee,Ge,Bi,Gr=class{constructor(e){g(this,Re);g(this,ee);g(this,Ge);g(this,Bi);var r,n,s;v(this,Bi,e),v(this,Ge,new Ki({apiUrl:e.apiUrl||e.backendUrl,userAgent:e.__userAgent})),v(this,Re,new zi);let t=Ss({subscriberId:e.subscriberId,subscriber:e.subscriber});v(this,ee,new ur({applicationIdentifier:e.applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:t,defaultSchedule:e.defaultSchedule,context:e.context,contextHash:e.contextHash},a(this,Ge),a(this,Re))),a(this,ee).initialize(),this.notifications=new rr({useCache:(r=e.useCache)!=null?r:!0,inboxServiceInstance:a(this,Ge),eventEmitterInstance:a(this,Re)}),this.preferences=new lr({useCache:(n=e.useCache)!=null?n:!0,inboxServiceInstance:a(this,Ge),eventEmitterInstance:a(this,Re)}),this.subscriptions=new di({subscriber:t,useCache:(s=e.useCache)!=null?s:!0,inboxServiceInstance:a(this,Ge),eventEmitterInstance:a(this,Re)}),this.socket=Da({socketUrl:e.socketUrl,eventEmitterInstance:a(this,Re),inboxServiceInstance:a(this,Ge)}),this.on=(o,c)=>{this.socket.isSocketEvent(o)&&this.socket.connect();let l=a(this,Re).on(o,c);return()=>{l()}},this.off=(o,c)=>{a(this,Re).off(o,c)}}get applicationIdentifier(){return a(this,ee).applicationIdentifier}get subscriberId(){return a(this,ee).subscriberId}get context(){return a(this,ee).context}get options(){return a(this,Bi)}get contextKey(){return bs(a(this,ee).context)}clearCache(){this.notifications.cache.clearAll(),this.preferences.cache.clearAll(),this.preferences.scheduleCache.clearAll(),this.subscriptions.cache.clearAll()}changeSubscriber(e){return d(this,null,function*(){yield a(this,ee).initialize({applicationIdentifier:a(this,ee).applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:e.subscriber,context:a(this,ee).context,contextHash:a(this,ee).contextHash}),this.clearCache(),(yield this.socket.disconnect()).error||(yield this.socket.connect())})}changeContext(e){return d(this,null,function*(){let t=a(this,ee).subscriber;if(!t)throw new Error("Cannot change context without an active subscriber");yield a(this,ee).initialize({applicationIdentifier:a(this,ee).applicationIdentifier||"",subscriberHash:a(this,ee).subscriberHash,subscriber:t,context:e.context,contextHash:e.contextHash}),this.clearCache(),(yield this.socket.disconnect()).error||(yield this.socket.connect())})}};Re=new WeakMap,ee=new WeakMap,Ge=new WeakMap,Bi=new WeakMap;window.Novu=Gr;})();
|
|
38
38
|
/*! Bundled license information:
|
|
39
39
|
|
|
40
40
|
xmlhttprequest-ssl/lib/XMLHttpRequest.js:
|