@novu/js 2.0.0-canary.1 → 2.0.0-canary.2
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-2C4L4ZUQ.cjs → chunk-NEEKTCEQ.cjs} +17 -5
- package/dist/cjs/index.cjs +12 -12
- package/dist/cjs/ui/index.cjs +284 -217
- package/dist/esm/{chunk-Y6CIZNAK.mjs → chunk-YOLQVRKF.mjs} +17 -5
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/ui/index.mjs +208 -141
- package/dist/index.css +1 -1
- package/dist/novu.min.js +7 -7
- package/dist/novu.min.js.gz +0 -0
- package/dist/types/base-module.d.ts +0 -2
- package/dist/types/base-module.d.ts.map +1 -1
- package/dist/types/notifications/notification.d.ts +1 -0
- package/dist/types/notifications/notification.d.ts.map +1 -1
- package/dist/types/types.d.ts +9 -5
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/ui/components/ExternalElementRenderer.d.ts +7 -0
- package/dist/types/ui/components/ExternalElementRenderer.d.ts.map +1 -0
- package/dist/types/ui/components/Inbox.d.ts +4 -4
- package/dist/types/ui/components/Inbox.d.ts.map +1 -1
- package/dist/types/ui/components/InboxTabs/InboxTabs.d.ts +5 -1
- package/dist/types/ui/components/InboxTabs/InboxTabs.d.ts.map +1 -1
- package/dist/types/ui/components/Notification/DefaultNotification.d.ts.map +1 -1
- package/dist/types/ui/components/Notification/NewMessagesCta.d.ts.map +1 -1
- package/dist/types/ui/components/Notification/Notification.d.ts +2 -2
- package/dist/types/ui/components/Notification/Notification.d.ts.map +1 -1
- package/dist/types/ui/components/Notification/NotificationList.d.ts +2 -2
- package/dist/types/ui/components/Notification/NotificationList.d.ts.map +1 -1
- package/dist/types/ui/components/Renderer.d.ts +1 -1
- package/dist/types/ui/components/elements/Bell/Bell.d.ts +2 -2
- package/dist/types/ui/components/elements/Bell/Bell.d.ts.map +1 -1
- package/dist/types/ui/components/elements/Header/MoreActionsOptions.d.ts +2 -1
- package/dist/types/ui/components/elements/Header/MoreActionsOptions.d.ts.map +1 -1
- package/dist/types/ui/components/elements/Header/PreferencesHeader.d.ts.map +1 -1
- package/dist/types/ui/components/elements/InboxStatus/InboxStatusDropdown.d.ts.map +1 -1
- package/dist/types/ui/components/elements/InboxStatus/InboxStatusOptions.d.ts +2 -1
- package/dist/types/ui/components/elements/InboxStatus/InboxStatusOptions.d.ts.map +1 -1
- package/dist/types/ui/components/elements/InboxStatus/constants.d.ts +7 -7
- package/dist/types/ui/components/elements/Preferences/Preferences.d.ts.map +1 -1
- package/dist/types/ui/config/defaultLocalization.d.ts +11 -10
- package/dist/types/ui/config/defaultLocalization.d.ts.map +1 -1
- package/dist/types/ui/context/LocalizationContext.d.ts +12 -4
- package/dist/types/ui/context/LocalizationContext.d.ts.map +1 -1
- package/dist/types/ui/helpers/constants.d.ts +2 -0
- package/dist/types/ui/helpers/constants.d.ts.map +1 -1
- package/dist/types/ui/helpers/index.d.ts +1 -0
- package/dist/types/ui/helpers/index.d.ts.map +1 -1
- package/dist/types/ui/types.d.ts +7 -7
- package/dist/types/ui/types.d.ts.map +1 -1
- package/dist/types/ws/socket.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/types/ui/components/ExternalElementMounter.d.ts +0 -7
- package/dist/types/ui/components/ExternalElementMounter.d.ts.map +0 -1
package/dist/novu.min.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";(()=>{var Hn=Object.create;var zt=Object.defineProperty,Gn=Object.defineProperties,zn=Object.getOwnPropertyDescriptor,Kn=Object.getOwnPropertyDescriptors,Yn=Object.getOwnPropertyNames,Gt=Object.getOwnPropertySymbols,Xn=Object.getPrototypeOf,Ii=Object.prototype.hasOwnProperty,Ar=Object.prototype.propertyIsEnumerable;var kr=i=>{throw TypeError(i)};var Nr=(i,e,t)=>e in i?zt(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,b=(i,e)=>{for(var t in e||(e={}))Ii.call(e,t)&&Nr(i,t,e[t]);if(Gt)for(var t of Gt(e))Ar.call(e,t)&&Nr(i,t,e[t]);return i},U=(i,e)=>Gn(i,Kn(e));var x=(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 Rr=(i,e)=>{var t={};for(var r in i)Ii.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&Gt)for(var r of Gt(i))e.indexOf(r)<0&&Ar.call(i,r)&&(t[r]=i[r]);return t};var T=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Jn=(i,e)=>{for(var t in e)zt(i,t,{get:e[t],enumerable:!0})},Qn=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Yn(e))!Ii.call(i,s)&&s!==t&&zt(i,s,{get:()=>e[s],enumerable:!(r=zn(e,s))||r.enumerable});return i};var j=(i,e,t)=>(t=i!=null?Hn(Xn(i)):{},Qn(e||!i||!i.__esModule?zt(t,"default",{value:i,enumerable:!0}):t,i));var Pi=(i,e,t)=>e.has(i)||kr("Cannot "+t);var h=(i,e,t)=>(Pi(i,e,"read from private field"),t?t.call(i):e.get(i)),v=(i,e,t)=>e.has(i)?kr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),_=(i,e,t,r)=>(Pi(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Li=(i,e,t)=>(Pi(i,e,"access private method"),t);var g=(i,e,t)=>new Promise((r,s)=>{var n=c=>{try{a(t.next(c))}catch(u){s(u)}},o=c=>{try{a(t.throw(c))}catch(u){s(u)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(n,o);a((t=t.apply(i,e)).next())});var zr=T((rl,Gr)=>{"use strict";var Ye=1e3,Xe=Ye*60,Je=Xe*60,Le=Je*24,po=Le*7,mo=Le*365.25;Gr.exports=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return go(i);if(t==="number"&&isFinite(i))return e.long?vo(i):yo(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function go(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*mo;case"weeks":case"week":case"w":return t*po;case"days":case"day":case"d":return t*Le;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Je;case"minutes":case"minute":case"mins":case"min":case"m":return t*Xe;case"seconds":case"second":case"secs":case"sec":case"s":return t*Ye;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function yo(i){var e=Math.abs(i);return e>=Le?Math.round(i/Le)+"d":e>=Je?Math.round(i/Je)+"h":e>=Xe?Math.round(i/Xe)+"m":e>=Ye?Math.round(i/Ye)+"s":i+"ms"}function vo(i){var e=Math.abs(i);return e>=Le?ai(i,e,Le,"day"):e>=Je?ai(i,e,Je,"hour"):e>=Xe?ai(i,e,Xe,"minute"):e>=Ye?ai(i,e,Ye,"second"):i+" ms"}function ai(i,e,t,r){var s=e>=t*1.5;return Math.round(i/t)+" "+r+(s?"s":"")}});var qi=T((sl,Kr)=>{"use strict";function _o(i){t.debug=t,t.default=t,t.coerce=c,t.disable=n,t.enable=s,t.enabled=o,t.humanize=zr(),t.destroy=u,Object.keys(i).forEach(l=>{t[l]=i[l]}),t.names=[],t.skips=[],t.formatters={};function e(l){let f=0;for(let m=0;m<l.length;m++)f=(f<<5)-f+l.charCodeAt(m),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(l){let f,m=null,w,C;function p(...S){if(!p.enabled)return;let L=p,k=Number(new Date),d=k-(f||k);L.diff=d,L.prev=f,L.curr=k,f=k,S[0]=t.coerce(S[0]),typeof S[0]!="string"&&S.unshift("%O");let y=0;S[0]=S[0].replace(/%([a-zA-Z%])/g,(R,z)=>{if(R==="%%")return"%";y++;let X=t.formatters[z];if(typeof X=="function"){let Ee=S[y];R=X.call(L,Ee),S.splice(y,1),y--}return R}),t.formatArgs.call(L,S),(L.log||t.log).apply(L,S)}return p.namespace=l,p.useColors=t.useColors(),p.color=t.selectColor(l),p.extend=r,p.destroy=t.destroy,Object.defineProperty(p,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(w!==t.namespaces&&(w=t.namespaces,C=t.enabled(l)),C),set:S=>{m=S}}),typeof t.init=="function"&&t.init(p),p}function r(l,f){let m=t(this.namespace+(typeof f=="undefined"?":":f)+l);return m.log=this.log,m}function s(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let f,m=(typeof l=="string"?l:"").split(/[\s,]+/),w=m.length;for(f=0;f<w;f++)m[f]&&(l=m[f].replace(/\*/g,".*?"),l[0]==="-"?t.skips.push(new RegExp("^"+l.slice(1)+"$")):t.names.push(new RegExp("^"+l+"$")))}function n(){let l=[...t.names.map(a),...t.skips.map(a).map(f=>"-"+f)].join(",");return t.enable(""),l}function o(l){if(l[l.length-1]==="*")return!0;let f,m;for(f=0,m=t.skips.length;f<m;f++)if(t.skips[f].test(l))return!1;for(f=0,m=t.names.length;f<m;f++)if(t.names[f].test(l))return!0;return!1}function a(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function c(l){return l instanceof Error?l.stack||l.message:l}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}Kr.exports=_o});var Yr=T((Q,ci)=>{"use strict";Q.formatArgs=So;Q.save=bo;Q.load=xo;Q.useColors=Eo;Q.storage=wo();Q.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`."))}})();Q.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 Eo(){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 So(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+ci.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,s=>{s!=="%%"&&(t++,s==="%c"&&(r=t))}),i.splice(r,0,e)}Q.log=console.debug||console.log||(()=>{});function bo(i){try{i?Q.storage.setItem("debug",i):Q.storage.removeItem("debug")}catch(e){}}function xo(){let i;try{i=Q.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function wo(){try{return localStorage}catch(i){}}ci.exports=qi()(Q);var{formatters:Co}=ci.exports;Co.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Jr=T((nl,Xr)=>{"use strict";Xr.exports=(i,e=process.argv)=>{let t=i.startsWith("-")?"":i.length===1?"-":"--",r=e.indexOf(t+i),s=e.indexOf("--");return r!==-1&&(s===-1||r<s)}});var es=T((ol,Zr)=>{"use strict";var No=x("os"),Qr=x("tty"),ne=Jr(),{env:M}=process,hi;ne("no-color")||ne("no-colors")||ne("color=false")||ne("color=never")?hi=0:(ne("color")||ne("colors")||ne("color=true")||ne("color=always"))&&(hi=1);function Ao(){if("FORCE_COLOR"in M)return M.FORCE_COLOR==="true"?1:M.FORCE_COLOR==="false"?0:M.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(M.FORCE_COLOR,10),3)}function ko(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function Ro(i,{streamIsTTY:e,sniffFlags:t=!0}={}){let r=Ao();r!==void 0&&(hi=r);let s=t?hi:r;if(s===0)return 0;if(t){if(ne("color=16m")||ne("color=full")||ne("color=truecolor"))return 3;if(ne("color=256"))return 2}if(i&&!e&&s===void 0)return 0;let n=s||0;if(M.TERM==="dumb")return n;if(process.platform==="win32"){let o=No.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in M)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(o=>o in M)||M.CI_NAME==="codeship"?1:n;if("TEAMCITY_VERSION"in M)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(M.TEAMCITY_VERSION)?1:0;if(M.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in M){let o=Number.parseInt((M.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(M.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(M.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(M.TERM)||"COLORTERM"in M?1:n}function Wi(i,e={}){let t=Ro(i,b({streamIsTTY:i&&i.isTTY},e));return ko(t)}Zr.exports={supportsColor:Wi,stdout:Wi({isTTY:Qr.isatty(1)}),stderr:Wi({isTTY:Qr.isatty(2)})}});var is=T((q,fi)=>{"use strict";var To=x("tty"),li=x("util");q.init=Uo;q.log=Lo;q.formatArgs=Io;q.save=Fo;q.load=Bo;q.useColors=Oo;q.destroy=li.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");q.colors=[6,2,3,4,5,1];try{let i=es();i&&(i.stderr||i).level>=2&&(q.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(i){}q.inspectOpts=Object.keys(process.env).filter(i=>/^debug_/i.test(i)).reduce((i,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(s,n)=>n.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 Oo(){return"colors"in q.inspectOpts?!!q.inspectOpts.colors:To.isatty(process.stderr.fd)}function Io(i){let{namespace:e,useColors:t}=this;if(t){let r=this.color,s="\x1B[3"+(r<8?r:"8;5;"+r),n=` ${s};1m${e} \x1B[0m`;i[0]=n+i[0].split(`
|
|
1
|
+
"use strict";(()=>{var Hn=Object.create;var Kt=Object.defineProperty,Gn=Object.defineProperties,zn=Object.getOwnPropertyDescriptor,Kn=Object.getOwnPropertyDescriptors,Yn=Object.getOwnPropertyNames,zt=Object.getOwnPropertySymbols,Xn=Object.getPrototypeOf,Pi=Object.prototype.hasOwnProperty,Ar=Object.prototype.propertyIsEnumerable;var kr=i=>{throw TypeError(i)};var Nr=(i,e,t)=>e in i?Kt(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,S=(i,e)=>{for(var t in e||(e={}))Pi.call(e,t)&&Nr(i,t,e[t]);if(zt)for(var t of zt(e))Ar.call(e,t)&&Nr(i,t,e[t]);return i},U=(i,e)=>Gn(i,Kn(e));var x=(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 Rr=(i,e)=>{var t={};for(var r in i)Pi.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&zt)for(var r of zt(i))e.indexOf(r)<0&&Ar.call(i,r)&&(t[r]=i[r]);return t};var T=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Jn=(i,e)=>{for(var t in e)Kt(i,t,{get:e[t],enumerable:!0})},Qn=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Yn(e))!Pi.call(i,s)&&s!==t&&Kt(i,s,{get:()=>e[s],enumerable:!(r=zn(e,s))||r.enumerable});return i};var j=(i,e,t)=>(t=i!=null?Hn(Xn(i)):{},Qn(e||!i||!i.__esModule?Kt(t,"default",{value:i,enumerable:!0}):t,i));var Li=(i,e,t)=>e.has(i)||kr("Cannot "+t);var h=(i,e,t)=>(Li(i,e,"read from private field"),t?t.call(i):e.get(i)),v=(i,e,t)=>e.has(i)?kr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),_=(i,e,t,r)=>(Li(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Fi=(i,e,t)=>(Li(i,e,"access private method"),t);var g=(i,e,t)=>new Promise((r,s)=>{var n=c=>{try{a(t.next(c))}catch(u){s(u)}},o=c=>{try{a(t.throw(c))}catch(u){s(u)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(n,o);a((t=t.apply(i,e)).next())});var zr=T((rl,Gr)=>{"use strict";var Xe=1e3,Je=Xe*60,Qe=Je*60,Le=Qe*24,po=Le*7,mo=Le*365.25;Gr.exports=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return go(i);if(t==="number"&&isFinite(i))return e.long?vo(i):yo(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function go(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*mo;case"weeks":case"week":case"w":return t*po;case"days":case"day":case"d":return t*Le;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Qe;case"minutes":case"minute":case"mins":case"min":case"m":return t*Je;case"seconds":case"second":case"secs":case"sec":case"s":return t*Xe;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function yo(i){var e=Math.abs(i);return e>=Le?Math.round(i/Le)+"d":e>=Qe?Math.round(i/Qe)+"h":e>=Je?Math.round(i/Je)+"m":e>=Xe?Math.round(i/Xe)+"s":i+"ms"}function vo(i){var e=Math.abs(i);return e>=Le?ci(i,e,Le,"day"):e>=Qe?ci(i,e,Qe,"hour"):e>=Je?ci(i,e,Je,"minute"):e>=Xe?ci(i,e,Xe,"second"):i+" ms"}function ci(i,e,t,r){var s=e>=t*1.5;return Math.round(i/t)+" "+r+(s?"s":"")}});var Wi=T((sl,Kr)=>{"use strict";function _o(i){t.debug=t,t.default=t,t.coerce=c,t.disable=n,t.enable=s,t.enabled=o,t.humanize=zr(),t.destroy=u,Object.keys(i).forEach(l=>{t[l]=i[l]}),t.names=[],t.skips=[],t.formatters={};function e(l){let f=0;for(let m=0;m<l.length;m++)f=(f<<5)-f+l.charCodeAt(m),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(l){let f,m=null,w,C;function p(...b){if(!p.enabled)return;let L=p,k=Number(new Date),d=k-(f||k);L.diff=d,L.prev=f,L.curr=k,f=k,b[0]=t.coerce(b[0]),typeof b[0]!="string"&&b.unshift("%O");let y=0;b[0]=b[0].replace(/%([a-zA-Z%])/g,(R,z)=>{if(R==="%%")return"%";y++;let X=t.formatters[z];if(typeof X=="function"){let Ee=b[y];R=X.call(L,Ee),b.splice(y,1),y--}return R}),t.formatArgs.call(L,b),(L.log||t.log).apply(L,b)}return p.namespace=l,p.useColors=t.useColors(),p.color=t.selectColor(l),p.extend=r,p.destroy=t.destroy,Object.defineProperty(p,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(w!==t.namespaces&&(w=t.namespaces,C=t.enabled(l)),C),set:b=>{m=b}}),typeof t.init=="function"&&t.init(p),p}function r(l,f){let m=t(this.namespace+(typeof f=="undefined"?":":f)+l);return m.log=this.log,m}function s(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let f,m=(typeof l=="string"?l:"").split(/[\s,]+/),w=m.length;for(f=0;f<w;f++)m[f]&&(l=m[f].replace(/\*/g,".*?"),l[0]==="-"?t.skips.push(new RegExp("^"+l.slice(1)+"$")):t.names.push(new RegExp("^"+l+"$")))}function n(){let l=[...t.names.map(a),...t.skips.map(a).map(f=>"-"+f)].join(",");return t.enable(""),l}function o(l){if(l[l.length-1]==="*")return!0;let f,m;for(f=0,m=t.skips.length;f<m;f++)if(t.skips[f].test(l))return!1;for(f=0,m=t.names.length;f<m;f++)if(t.names[f].test(l))return!0;return!1}function a(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function c(l){return l instanceof Error?l.stack||l.message:l}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}Kr.exports=_o});var Yr=T((J,hi)=>{"use strict";J.formatArgs=bo;J.save=So;J.load=xo;J.useColors=Eo;J.storage=wo();J.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`."))}})();J.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 Eo(){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 bo(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+hi.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;i.splice(1,0,e,"color: inherit");let t=0,r=0;i[0].replace(/%[a-zA-Z%]/g,s=>{s!=="%%"&&(t++,s==="%c"&&(r=t))}),i.splice(r,0,e)}J.log=console.debug||console.log||(()=>{});function So(i){try{i?J.storage.setItem("debug",i):J.storage.removeItem("debug")}catch(e){}}function xo(){let i;try{i=J.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function wo(){try{return localStorage}catch(i){}}hi.exports=Wi()(J);var{formatters:Co}=hi.exports;Co.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Jr=T((nl,Xr)=>{"use strict";Xr.exports=(i,e=process.argv)=>{let t=i.startsWith("-")?"":i.length===1?"-":"--",r=e.indexOf(t+i),s=e.indexOf("--");return r!==-1&&(s===-1||r<s)}});var es=T((ol,Zr)=>{"use strict";var No=x("os"),Qr=x("tty"),ne=Jr(),{env:M}=process,li;ne("no-color")||ne("no-colors")||ne("color=false")||ne("color=never")?li=0:(ne("color")||ne("colors")||ne("color=true")||ne("color=always"))&&(li=1);function Ao(){if("FORCE_COLOR"in M)return M.FORCE_COLOR==="true"?1:M.FORCE_COLOR==="false"?0:M.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(M.FORCE_COLOR,10),3)}function ko(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function Ro(i,{streamIsTTY:e,sniffFlags:t=!0}={}){let r=Ao();r!==void 0&&(li=r);let s=t?li:r;if(s===0)return 0;if(t){if(ne("color=16m")||ne("color=full")||ne("color=truecolor"))return 3;if(ne("color=256"))return 2}if(i&&!e&&s===void 0)return 0;let n=s||0;if(M.TERM==="dumb")return n;if(process.platform==="win32"){let o=No.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in M)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(o=>o in M)||M.CI_NAME==="codeship"?1:n;if("TEAMCITY_VERSION"in M)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(M.TEAMCITY_VERSION)?1:0;if(M.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in M){let o=Number.parseInt((M.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(M.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(M.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(M.TERM)||"COLORTERM"in M?1:n}function $i(i,e={}){let t=Ro(i,S({streamIsTTY:i&&i.isTTY},e));return ko(t)}Zr.exports={supportsColor:$i,stdout:$i({isTTY:Qr.isatty(1)}),stderr:$i({isTTY:Qr.isatty(2)})}});var is=T((q,ui)=>{"use strict";var To=x("tty"),fi=x("util");q.init=Uo;q.log=Lo;q.formatArgs=Io;q.save=Fo;q.load=Bo;q.useColors=Oo;q.destroy=fi.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");q.colors=[6,2,3,4,5,1];try{let i=es();i&&(i.stderr||i).level>=2&&(q.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(i){}q.inspectOpts=Object.keys(process.env).filter(i=>/^debug_/i.test(i)).reduce((i,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(s,n)=>n.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 Oo(){return"colors"in q.inspectOpts?!!q.inspectOpts.colors:To.isatty(process.stderr.fd)}function Io(i){let{namespace:e,useColors:t}=this;if(t){let r=this.color,s="\x1B[3"+(r<8?r:"8;5;"+r),n=` ${s};1m${e} \x1B[0m`;i[0]=n+i[0].split(`
|
|
2
2
|
`).join(`
|
|
3
|
-
`+n),i.push(s+"m+"+
|
|
4
|
-
`)}function Fo(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function Bo(){return process.env.DEBUG}function Uo(i){i.inspectOpts={};let e=Object.keys(q.inspectOpts);for(let t=0;t<e.length;t++)i.inspectOpts[e[t]]=q.inspectOpts[e[t]]}
|
|
5
|
-
`).map(e=>e.trim()).join(" ")};ts.O=function(i){return this.inspectOpts.colors=this.useColors,
|
|
6
|
-
`);return d.substr(0,d.length-2)},this.getRequestHeader=function(d){return typeof d=="string"&&u[d]?u[d]:""},this.send=function(d){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");if(m)throw new Error("INVALID_STATE_ERR: send has already been called");var y=!1,V=!1,R=ls.parse(o.url),z;switch(R.protocol){case"https:":y=!0;case"http:":z=R.hostname;break;case"file:":V=!0;break;case void 0:case"":z="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)Qe.readFile(unescape(R.pathname),"utf8",function(te,We){te?e.handleError(te,te.errno||-1):(e.status=200,e.responseText=We,k(e.DONE))});else try{this.responseText=Qe.readFileSync(unescape(R.pathname),"utf8"),this.status=200,k(e.DONE)}catch(te){this.handleError(te,te.errno||-1)}return}var X=R.port||(y?443:80),Ee=R.pathname+(R.search?R.search:"");if(u.Host=z,y&&X===443||X===80||(u.Host+=":"+R.port),o.user){typeof o.password=="undefined"&&(o.password="");var Vt=new Buffer(o.user+":"+o.password);u.Authorization="Basic "+Vt.toString("base64")}o.method==="GET"||o.method==="HEAD"?d=null:d?(u["Content-Length"]=Buffer.isBuffer(d)?d.length:Buffer.byteLength(d),u["Content-Type"]||(u["Content-Type"]="text/plain;charset=UTF-8")):o.method==="POST"&&(u["Content-Length"]=0);var jt=i.agent||!1,J={host:z,port:X,path:Ee,method:o.method,headers:u,agent:jt};if(y&&(J.pfx=i.pfx,J.key=i.key,J.passphrase=i.passphrase,J.cert=i.cert,J.ca=i.ca,J.ciphers=i.ciphers,J.rejectUnauthorized=i.rejectUnauthorized!==!1),w=!1,o.async){var xr=y?r.request:t.request;m=!0,e.dispatchEvent("readystatechange");var wr=function(te){if(n=te,n.statusCode===302||n.statusCode===303||n.statusCode===307){o.url=n.headers.location;var We=ls.parse(o.url);z=We.hostname;var Se={hostname:We.hostname,port:We.port,path:We.path,method:n.statusCode===303?"GET":o.method,headers:u};y&&(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),s=xr(Se,wr).on("error",Cr),s.end();return}n&&n.setEncoding&&n.setEncoding("utf8"),k(e.HEADERS_RECEIVED),e.status=n.statusCode,n.on("data",function(Ht){Ht&&(e.responseText+=Ht),m&&k(e.LOADING)}),n.on("end",function(){m&&(m=!1,k(e.DONE))}),n.on("error",function(Ht){e.handleError(Ht)})},Cr=function(te){e.handleError(te)};s=xr(J,wr).on("error",Cr),i.autoUnref&&s.on("socket",te=>{te.unref()}),d&&s.write(d),s.end(),e.dispatchEvent("loadstart")}else{var ht=".node-xmlhttprequest-content-"+process.pid,lt=".node-xmlhttprequest-sync-"+process.pid;Qe.writeFileSync(lt,"","utf8");for(var $n="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(y?"s":"")+".request;var options = "+JSON.stringify(J)+";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('"+ht+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+lt+"');});response.on('error', function(error) {fs.writeFileSync('"+ht+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+lt+"');});}).on('error', function(error) {fs.writeFileSync('"+ht+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+lt+"');});"+(d?"req.write('"+JSON.stringify(d).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",Vn=qo(process.argv[0],["-e",$n]),gc;Qe.existsSync(lt););if(e.responseText=Qe.readFileSync(ht,"utf8"),Vn.stdin.end(),Qe.unlinkSync(ht),e.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var jn=e.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");e.handleError(jn,503)}else e.status=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1"),e.responseText=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"),k(e.DONE)}},this.handleError=function(d,y){this.status=y||0,this.statusText=d,this.responseText=d.stack,w=!0,k(this.DONE)},this.abort=function(){s&&(s.abort(),s=null),u=Object.assign({},c),this.responseText="",this.responseXML="",w=C=!0,this.readyState!==this.UNSENT&&(this.readyState!==this.OPENED||m)&&this.readyState!==this.DONE&&(m=!1,k(this.DONE)),this.readyState=this.UNSENT},this.addEventListener=function(d,y){d in p||(p[d]=[]),p[d].push(y)},this.removeEventListener=function(d,y){d in p&&(p[d]=p[d].filter(function(V){return V!==y}))},this.dispatchEvent=function(d){if(typeof e["on"+d]=="function"&&(this.readyState===this.DONE?setImmediate(function(){e["on"+d]()}):e["on"+d]()),d in p)for(let y=0,V=p[d].length;y<V;y++)this.readyState===this.DONE?setImmediate(function(){p[d][y].call(e)}):p[d][y].call(e)};var k=function(d){if(!(e.readyState===d||e.readyState===e.UNSENT&&C)&&(e.readyState=d,(o.async||e.readyState<e.OPENED||e.readyState===e.DONE)&&e.dispatchEvent("readystatechange"),e.readyState===e.DONE)){let y;C?y="abort":w?y="error":y="load",e.dispatchEvent(y),e.dispatchEvent("loadend")}}}});var _s=T((Nl,vs)=>{"use strict";var{Duplex:jo}=x("stream");function gs(i){i.emit("close")}function Ho(){!this.destroyed&&this._writableState.finished&&this.destroy()}function ys(i){this.removeListener("error",ys),this.destroy(),this.listenerCount("error")===0&&this.emit("error",i)}function Go(i,e){let t=!0,r=new jo(U(b({},e),{autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1}));return i.on("message",function(n,o){let a=!o&&r._readableState.objectMode?n.toString():n;r.push(a)||i.pause()}),i.once("error",function(n){r.destroyed||(t=!1,r.destroy(n))}),i.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(s,n){if(i.readyState===i.CLOSED){n(s),process.nextTick(gs,r);return}let o=!1;i.once("error",function(c){o=!0,n(c)}),i.once("close",function(){o||n(s),process.nextTick(gs,r)}),t&&i.terminate()},r._final=function(s){if(i.readyState===i.CONNECTING){i.once("open",function(){r._final(s)});return}i._socket!==null&&(i._socket._writableState.finished?(s(),r._readableState.endEmitted&&r.destroy()):(i._socket.once("finish",function(){s()}),i.close()))},r._read=function(){i.isPaused&&i.resume()},r._write=function(s,n,o){if(i.readyState===i.CONNECTING){i.once("open",function(){r._write(s,n,o)});return}i.send(s,o)},r.on("end",Ho),r.on("error",ys),r}vs.exports=Go});var Ne=T((kl,Es)=>{"use strict";Es.exports={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var wt=T((Rl,mi)=>{"use strict";var{EMPTY_BUFFER:zo}=Ne();function Ko(i,e){if(i.length===0)return zo;if(i.length===1)return i[0];let t=Buffer.allocUnsafe(e),r=0;for(let s=0;s<i.length;s++){let n=i[s];t.set(n,r),r+=n.length}return r<e?t.slice(0,r):t}function Ss(i,e,t,r,s){for(let n=0;n<s;n++)t[r+n]=i[n]^e[n&3]}function bs(i,e){for(let t=0;t<i.length;t++)i[t]^=e[t&3]}function Yo(i){return i.byteLength===i.buffer.byteLength?i.buffer:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}function Yi(i){if(Yi.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),Yi.readOnly=!1),e}mi.exports={concat:Ko,mask:Ss,toArrayBuffer:Yo,toBuffer:Yi,unmask:bs};if(!process.env.WS_NO_BUFFER_UTIL)try{let i=x("bufferutil");mi.exports.mask=function(e,t,r,s,n){n<48?Ss(e,t,r,s,n):i.mask(e,t,r,s,n)},mi.exports.unmask=function(e,t){e.length<32?bs(e,t):i.unmask(e,t)}}catch(i){}});var Cs=T((Tl,ws)=>{"use strict";var xs=Symbol("kDone"),Xi=Symbol("kRun"),Ji=class{constructor(e){this[xs]=()=>{this.pending--,this[Xi]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Xi]()}[Xi](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[xs])}}};ws.exports=Ji});var At=T((Ol,Rs)=>{"use strict";var Ct=x("zlib"),Ns=wt(),Xo=Cs(),{kStatusCode:As}=Ne(),Jo=Buffer.from([0,0,255,255]),vi=Symbol("permessage-deflate"),ye=Symbol("total-length"),Nt=Symbol("callback"),Ae=Symbol("buffers"),yi=Symbol("error"),gi,Qi=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,!gi){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;gi=new Xo(s)}}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[Nt];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(s=>!(t.serverNoContextTakeover===!1&&s.server_no_context_takeover||s.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>s.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!s.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 s=t[r];if(s.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(s=s[0],r==="client_max_window_bits"){if(s!==!0){let n=+s;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${r}": ${s}`);s=n}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${s}`)}else if(r==="server_max_window_bits"){let n=+s;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${r}": ${s}`);s=n}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(s!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${s}`)}else throw new Error(`Unknown parameter "${r}"`);t[r]=s})}),e}decompress(e,t,r){gi.add(s=>{this._decompress(e,t,(n,o)=>{s(),r(n,o)})})}compress(e,t,r){gi.add(s=>{this._compress(e,t,(n,o)=>{s(),r(n,o)})})}_decompress(e,t,r){let s=this._isServer?"client":"server";if(!this._inflate){let n=`${s}_max_window_bits`,o=typeof this.params[n]!="number"?Ct.Z_DEFAULT_WINDOWBITS:this.params[n];this._inflate=Ct.createInflateRaw(U(b({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[vi]=this,this._inflate[ye]=0,this._inflate[Ae]=[],this._inflate.on("error",Zo),this._inflate.on("data",ks)}this._inflate[Nt]=r,this._inflate.write(e),t&&this._inflate.write(Jo),this._inflate.flush(()=>{let n=this._inflate[yi];if(n){this._inflate.close(),this._inflate=null,r(n);return}let o=Ns.concat(this._inflate[Ae],this._inflate[ye]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[ye]=0,this._inflate[Ae]=[],t&&this.params[`${s}_no_context_takeover`]&&this._inflate.reset()),r(null,o)})}_compress(e,t,r){let s=this._isServer?"server":"client";if(!this._deflate){let n=`${s}_max_window_bits`,o=typeof this.params[n]!="number"?Ct.Z_DEFAULT_WINDOWBITS:this.params[n];this._deflate=Ct.createDeflateRaw(U(b({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[ye]=0,this._deflate[Ae]=[],this._deflate.on("data",Qo)}this._deflate[Nt]=r,this._deflate.write(e),this._deflate.flush(Ct.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let n=Ns.concat(this._deflate[Ae],this._deflate[ye]);t&&(n=n.slice(0,n.length-4)),this._deflate[Nt]=null,this._deflate[ye]=0,this._deflate[Ae]=[],t&&this.params[`${s}_no_context_takeover`]&&this._deflate.reset(),r(null,n)})}};Rs.exports=Qi;function Qo(i){this[Ae].push(i),this[ye]+=i.length}function ks(i){if(this[ye]+=i.length,this[vi]._maxPayload<1||this[ye]<=this[vi]._maxPayload){this[Ae].push(i);return}this[yi]=new RangeError("Max payload size exceeded"),this[yi].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[yi][As]=1009,this.removeListener("data",ks),this.reset()}function Zo(i){this[vi]._inflate=null,i[As]=1007,this[Nt](i)}});var kt=T((Pl,Zi)=>{"use strict";var ea=[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 ta(i){return i>=1e3&&i<=1014&&i!==1004&&i!==1005&&i!==1006||i>=3e3&&i<=4999}function Ts(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}Zi.exports={isValidStatusCode:ta,isValidUTF8:Ts,tokenChars:ea};if(!process.env.WS_NO_UTF_8_VALIDATE)try{let i=x("utf-8-validate");Zi.exports.isValidUTF8=function(e){return e.length<150?Ts(e):i(e)}}catch(i){}});var rr=T((Ll,Us)=>{"use strict";var{Writable:ia}=x("stream"),Os=At(),{BINARY_TYPES:ra,EMPTY_BUFFER:Is,kStatusCode:sa,kWebSocket:na}=Ne(),{concat:er,toArrayBuffer:oa,unmask:aa}=wt(),{isValidStatusCode:ca,isValidUTF8:Ps}=kt(),Rt=0,Ls=1,Fs=2,Bs=3,tr=4,ha=5,ir=class extends ia{constructor(e={}){super(),this._binaryType=e.binaryType||ra[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[na]=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=Rt,this._loop=!1}_write(e,t,r){if(this._opcode===8&&this._state==Rt)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],s=t.length-e;e>=r.length?t.set(this._buffers.shift(),s):(t.set(new Uint8Array(r.buffer,r.byteOffset,e),s),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 Rt:t=this.getInfo();break;case Ls:t=this.getPayloadLength16();break;case Fs:t=this.getPayloadLength64();break;case Bs:this.getMask();break;case tr: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,F(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[Os.extensionName])return this._loop=!1,F(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,F(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,F(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,F(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,F(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(t)return this._loop=!1,F(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,F(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else return this._loop=!1,F(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,F(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,F(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(this._payloadLength===126)this._state=Ls;else if(this._payloadLength===127)this._state=Fs;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,F(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,F(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=Bs:this._state=tr}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=tr}getData(e){let t=Is;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]&&aa(t,this._mask)}if(this._opcode>7)return this.controlMessage(t);if(this._compressed){this._state=ha,this.decompress(t,e);return}return t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage()}decompress(e,t){this._extensions[Os.extensionName].decompress(e,this._fin,(s,n)=>{if(s)return t(s);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return t(F(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(n)}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=er(t,e):this._binaryType==="arraybuffer"?r=oa(er(t,e)):r=t,this.emit("message",r,!0)}else{let r=er(t,e);if(!this._skipUTF8Validation&&!Ps(r))return this._loop=!1,F(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",r,!1)}}this._state=Rt}controlMessage(e){if(this._opcode===8)if(this._loop=!1,e.length===0)this.emit("conclude",1005,Is),this.end();else{if(e.length===1)return F(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{let t=e.readUInt16BE(0);if(!ca(t))return F(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let r=e.slice(2);if(!this._skipUTF8Validation&&!Ps(r))return F(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=Rt}};Us.exports=ir;function F(i,e,t,r,s){let n=new i(t?`Invalid WebSocket frame: ${e}`:e);return Error.captureStackTrace(n,F),n.code=s,n[sa]=r,n}});var nr=T((Ul,qs)=>{"use strict";var Fl=x("net"),Bl=x("tls"),{randomFillSync:la}=x("crypto"),Ds=At(),{EMPTY_BUFFER:fa}=Ne(),{isValidStatusCode:ua}=kt(),{mask:Ms,toBuffer:Ze}=wt(),fe=Symbol("kByteLength"),da=Buffer.alloc(4),sr=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,s=!1,n=2,o=!1;t.mask&&(r=t.maskBuffer||da,t.generateMask?t.generateMask(r):la(r,0,4),o=(r[0]|r[1]|r[2]|r[3])===0,n=6);let a;typeof e=="string"?(!t.mask||o)&&t[fe]!==void 0?a=t[fe]:(e=Buffer.from(e),a=e.length):(a=e.length,s=t.mask&&t.readOnly&&!o);let c=a;a>=65536?(n+=8,c=127):a>125&&(n+=2,c=126);let u=Buffer.allocUnsafe(s?a+n:n);return u[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(u[0]|=64),u[1]=c,c===126?u.writeUInt16BE(a,2):c===127&&(u[2]=u[3]=0,u.writeUIntBE(a,4,6)),t.mask?(u[1]|=128,u[n-4]=r[0],u[n-3]=r[1],u[n-2]=r[2],u[n-1]=r[3],o?[u,e]:s?(Ms(e,r,u,n,a),[u]):(Ms(e,r,e,0,a),[u,e])):[u,e]}close(e,t,r,s){let n;if(e===void 0)n=fa;else{if(typeof e!="number"||!ua(e))throw new TypeError("First argument must be a valid error code number");if(t===void 0||!t.length)n=Buffer.allocUnsafe(2),n.writeUInt16BE(e,0);else{let a=Buffer.byteLength(t);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");n=Buffer.allocUnsafe(2+a),n.writeUInt16BE(e,0),typeof t=="string"?n.write(t,2):n.set(t,2)}}let o={[fe]:n.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,n,!1,o,s]):this.sendFrame(i.frame(n,o),s)}ping(e,t,r){let s,n;if(typeof e=="string"?(s=Buffer.byteLength(e),n=!1):(e=Ze(e),s=e.length,n=Ze.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[fe]:s,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(i.frame(e,o),r)}pong(e,t,r){let s,n;if(typeof e=="string"?(s=Buffer.byteLength(e),n=!1):(e=Ze(e),s=e.length,n=Ze.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[fe]:s,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(i.frame(e,o),r)}send(e,t,r){let s=this._extensions[Ds.extensionName],n=t.binary?2:1,o=t.compress,a,c;if(typeof e=="string"?(a=Buffer.byteLength(e),c=!1):(e=Ze(e),a=e.length,c=Ze.readOnly),this._firstFragment?(this._firstFragment=!1,o&&s&&s.params[s._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=a>=s._threshold),this._compress=o):(o=!1,n=0),t.fin&&(this._firstFragment=!0),s){let u={[fe]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:c,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,{[fe]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:c,rsv1:!1}),r)}dispatch(e,t,r,s){if(!t){this.sendFrame(i.frame(e,r),s);return}let n=this._extensions[Ds.extensionName];this._bufferedBytes+=r[fe],this._deflating=!0,n.compress(e,r.fin,(o,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being compressed");typeof s=="function"&&s(c);for(let u=0;u<this._queue.length;u++){let l=this._queue[u],f=l[l.length-1];typeof f=="function"&&f(c)}return}this._bufferedBytes-=r[fe],this._deflating=!1,r.readOnly=!1,this.sendFrame(i.frame(a,r),s),this.dequeue()})}dequeue(){for(;!this._deflating&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][fe],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][fe],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)}};qs.exports=sr});var Ys=T((Dl,Ks)=>{"use strict";var{kForOnEventAttribute:Tt,kListener:or}=Ne(),Ws=Symbol("kCode"),$s=Symbol("kData"),Vs=Symbol("kError"),js=Symbol("kMessage"),Hs=Symbol("kReason"),et=Symbol("kTarget"),Gs=Symbol("kType"),zs=Symbol("kWasClean"),ve=class{constructor(e){this[et]=null,this[Gs]=e}get target(){return this[et]}get type(){return this[Gs]}};Object.defineProperty(ve.prototype,"target",{enumerable:!0});Object.defineProperty(ve.prototype,"type",{enumerable:!0});var Fe=class extends ve{constructor(e,t={}){super(e),this[Ws]=t.code===void 0?0:t.code,this[Hs]=t.reason===void 0?"":t.reason,this[zs]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[Ws]}get reason(){return this[Hs]}get wasClean(){return this[zs]}};Object.defineProperty(Fe.prototype,"code",{enumerable:!0});Object.defineProperty(Fe.prototype,"reason",{enumerable:!0});Object.defineProperty(Fe.prototype,"wasClean",{enumerable:!0});var tt=class extends ve{constructor(e,t={}){super(e),this[Vs]=t.error===void 0?null:t.error,this[js]=t.message===void 0?"":t.message}get error(){return this[Vs]}get message(){return this[js]}};Object.defineProperty(tt.prototype,"error",{enumerable:!0});Object.defineProperty(tt.prototype,"message",{enumerable:!0});var Ot=class extends ve{constructor(e,t={}){super(e),this[$s]=t.data===void 0?null:t.data}get data(){return this[$s]}};Object.defineProperty(Ot.prototype,"data",{enumerable:!0});var pa={addEventListener(i,e,t={}){for(let s of this.listeners(i))if(!t[Tt]&&s[or]===e&&!s[Tt])return;let r;if(i==="message")r=function(n,o){let a=new Ot("message",{data:o?n:n.toString()});a[et]=this,_i(e,this,a)};else if(i==="close")r=function(n,o){let a=new Fe("close",{code:n,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[et]=this,_i(e,this,a)};else if(i==="error")r=function(n){let o=new tt("error",{error:n,message:n.message});o[et]=this,_i(e,this,o)};else if(i==="open")r=function(){let n=new ve("open");n[et]=this,_i(e,this,n)};else return;r[Tt]=!!t[Tt],r[or]=e,t.once?this.once(i,r):this.on(i,r)},removeEventListener(i,e){for(let t of this.listeners(i))if(t[or]===e&&!t[Tt]){this.removeListener(i,t);break}}};Ks.exports={CloseEvent:Fe,ErrorEvent:tt,Event:ve,EventTarget:pa,MessageEvent:Ot};function _i(i,e,t){typeof i=="object"&&i.handleEvent?i.handleEvent.call(i,t):i.call(e,t)}});var ar=T((Ml,Xs)=>{"use strict";var{tokenChars:It}=kt();function ue(i,e,t){i[e]===void 0?i[e]=[t]:i[e].push(t)}function ma(i){let e=Object.create(null),t=Object.create(null),r=!1,s=!1,n=!1,o,a,c=-1,u=-1,l=-1,f=0;for(;f<i.length;f++)if(u=i.charCodeAt(f),o===void 0)if(l===-1&&It[u]===1)c===-1&&(c=f);else if(f!==0&&(u===32||u===9))l===-1&&c!==-1&&(l=f);else if(u===59||u===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f);let w=i.slice(c,l);u===44?(ue(e,w,t),t=Object.create(null)):o=w,c=l=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);else if(a===void 0)if(l===-1&&It[u]===1)c===-1&&(c=f);else if(u===32||u===9)l===-1&&c!==-1&&(l=f);else if(u===59||u===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f),ue(t,i.slice(c,l),!0),u===44&&(ue(e,o,t),t=Object.create(null),o=void 0),c=l=-1}else if(u===61&&c!==-1&&l===-1)a=i.slice(c,f),c=l=-1;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(s){if(It[u]!==1)throw new SyntaxError(`Unexpected character at index ${f}`);c===-1?c=f:r||(r=!0),s=!1}else if(n)if(It[u]===1)c===-1&&(c=f);else if(u===34&&c!==-1)n=!1,l=f;else if(u===92)s=!0;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(u===34&&i.charCodeAt(f-1)===61)n=!0;else if(l===-1&&It[u]===1)c===-1&&(c=f);else if(c!==-1&&(u===32||u===9))l===-1&&(l=f);else if(u===59||u===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f);let w=i.slice(c,l);r&&(w=w.replace(/\\/g,""),r=!1),ue(t,a,w),u===44&&(ue(e,o,t),t=Object.create(null),o=void 0),a=void 0,c=l=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);if(c===-1||n||u===32||u===9)throw new SyntaxError("Unexpected end of input");l===-1&&(l=f);let m=i.slice(c,l);return o===void 0?ue(e,m,t):(a===void 0?ue(t,m,!0):r?ue(t,a,m.replace(/\\/g,"")):ue(t,a,m),ue(e,o,t)),e}function ga(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(s=>{let n=r[s];return Array.isArray(n)||(n=[n]),n.map(o=>o===!0?s:`${s}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Xs.exports={format:ga,parse:ma}});var ur=T((Wl,cn)=>{"use strict";var ya=x("events"),va=x("https"),_a=x("http"),Zs=x("net"),Ea=x("tls"),{randomBytes:Sa,createHash:ba}=x("crypto"),{Readable:ql}=x("stream"),{URL:cr}=x("url"),ke=At(),xa=rr(),wa=nr(),{BINARY_TYPES:Js,EMPTY_BUFFER:Ei,GUID:Ca,kForOnEventAttribute:hr,kListener:Na,kStatusCode:Aa,kWebSocket:G,NOOP:en}=Ne(),{EventTarget:{addEventListener:ka,removeEventListener:Ra}}=Ys(),{format:Ta,parse:Oa}=ar(),{toBuffer:Ia}=wt(),Pa=30*1e3,tn=Symbol("kAborted"),lr=[8,13],_e=["CONNECTING","OPEN","CLOSING","CLOSED"],La=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,I=class i extends ya{constructor(e,t,r){super(),this._binaryType=Js[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Ei,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]),rn(this,e,t,r)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){Js.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,r){let s=new xa({binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation});this._sender=new wa(e,this._extensions,r.generateMask),this._receiver=s,this._socket=e,s[G]=this,e[G]=this,s.on("conclude",Ua),s.on("drain",Da),s.on("error",Ma),s.on("message",qa),s.on("ping",Wa),s.on("pong",$a),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",nn),e.on("data",bi),e.on("end",on),e.on("error",an),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[ke.extensionName]&&this._extensions[ke.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 Z(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),Pa)}}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){fr(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||Ei,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){fr(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||Ei,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){fr(this,e,r);return}let s=b({binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0},t);this._extensions[ke.extensionName]||(s.compress=!1),this._sender.send(e||Ei,s,r)}terminate(){if(this.readyState!==i.CLOSED){if(this.readyState===i.CONNECTING)return Z(this,this._req,"WebSocket was closed before the connection was established");this._socket&&(this._readyState=i.CLOSING,this._socket.destroy())}}};Object.defineProperty(I,"CONNECTING",{enumerable:!0,value:_e.indexOf("CONNECTING")});Object.defineProperty(I.prototype,"CONNECTING",{enumerable:!0,value:_e.indexOf("CONNECTING")});Object.defineProperty(I,"OPEN",{enumerable:!0,value:_e.indexOf("OPEN")});Object.defineProperty(I.prototype,"OPEN",{enumerable:!0,value:_e.indexOf("OPEN")});Object.defineProperty(I,"CLOSING",{enumerable:!0,value:_e.indexOf("CLOSING")});Object.defineProperty(I.prototype,"CLOSING",{enumerable:!0,value:_e.indexOf("CLOSING")});Object.defineProperty(I,"CLOSED",{enumerable:!0,value:_e.indexOf("CLOSED")});Object.defineProperty(I.prototype,"CLOSED",{enumerable:!0,value:_e.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(i=>{Object.defineProperty(I.prototype,i,{enumerable:!0})});["open","error","close","message"].forEach(i=>{Object.defineProperty(I.prototype,`on${i}`,{enumerable:!0,get(){for(let e of this.listeners(i))if(e[hr])return e[Na];return null},set(e){for(let t of this.listeners(i))if(t[hr]){this.removeListener(i,t);break}typeof e=="function"&&this.addEventListener(i,e,{[hr]:!0})}})});I.prototype.addEventListener=ka;I.prototype.removeEventListener=Ra;cn.exports=I;function rn(i,e,t,r){let s=U(b({protocolVersion:lr[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(!lr.includes(s.protocolVersion))throw new RangeError(`Unsupported protocol version: ${s.protocolVersion} (supported versions: ${lr.join(", ")})`);let n;if(e instanceof cr)n=e,i._url=e.href;else{try{n=new cr(e)}catch(p){throw new SyntaxError(`Invalid URL: ${e}`)}i._url=e}let o=n.protocol==="wss:",a=n.protocol==="ws+unix:",c;if(n.protocol!=="ws:"&&!o&&!a?c=`The URL's protocol must be one of "ws:", "wss:", or "ws+unix:"`:a&&!n.pathname?c="The URL's pathname is empty":n.hash&&(c="The URL contains a fragment identifier"),c){let p=new SyntaxError(c);if(i._redirects===0)throw p;Si(i,p);return}let u=o?443:80,l=Sa(16).toString("base64"),f=o?va.request:_a.request,m=new Set,w;if(s.createConnection=o?Ba:Fa,s.defaultPort=s.defaultPort||u,s.port=n.port||u,s.host=n.hostname.startsWith("[")?n.hostname.slice(1,-1):n.hostname,s.headers=U(b({},s.headers),{"Sec-WebSocket-Version":s.protocolVersion,"Sec-WebSocket-Key":l,Connection:"Upgrade",Upgrade:"websocket"}),s.path=n.pathname+n.search,s.timeout=s.handshakeTimeout,s.perMessageDeflate&&(w=new ke(s.perMessageDeflate!==!0?s.perMessageDeflate:{},!1,s.maxPayload),s.headers["Sec-WebSocket-Extensions"]=Ta({[ke.extensionName]:w.offer()})),t.length){for(let p of t){if(typeof p!="string"||!La.test(p)||m.has(p))throw new SyntaxError("An invalid or duplicated subprotocol was specified");m.add(p)}s.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(s.origin&&(s.protocolVersion<13?s.headers["Sec-WebSocket-Origin"]=s.origin:s.headers.Origin=s.origin),(n.username||n.password)&&(s.auth=`${n.username}:${n.password}`),a){let p=s.path.split(":");s.socketPath=p[0],s.path=p[1]}let C;if(s.followRedirects){if(i._redirects===0){i._originalIpc=a,i._originalSecure=o,i._originalHostOrSocketPath=a?s.socketPath:n.host;let p=r&&r.headers;if(r=U(b({},r),{headers:{}}),p)for(let[S,L]of Object.entries(p))r.headers[S.toLowerCase()]=L}else if(i.listenerCount("redirect")===0){let p=a?i._originalIpc?s.socketPath===i._originalHostOrSocketPath:!1:i._originalIpc?!1:n.host===i._originalHostOrSocketPath;(!p||i._originalSecure&&!o)&&(delete s.headers.authorization,delete s.headers.cookie,p||delete s.headers.host,s.auth=void 0)}s.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(s.auth).toString("base64")),C=i._req=f(s),i._redirects&&i.emit("redirect",i.url,C)}else C=i._req=f(s);s.timeout&&C.on("timeout",()=>{Z(i,C,"Opening handshake has timed out")}),C.on("error",p=>{C===null||C[tn]||(C=i._req=null,Si(i,p))}),C.on("response",p=>{let S=p.headers.location,L=p.statusCode;if(S&&s.followRedirects&&L>=300&&L<400){if(++i._redirects>s.maxRedirects){Z(i,C,"Maximum redirects exceeded");return}C.abort();let k;try{k=new cr(S,e)}catch(d){let y=new SyntaxError(`Invalid URL: ${S}`);Si(i,y);return}rn(i,k,t,r)}else i.emit("unexpected-response",C,p)||Z(i,C,`Unexpected server response: ${p.statusCode}`)}),C.on("upgrade",(p,S,L)=>{if(i.emit("upgrade",p),i.readyState!==I.CONNECTING)return;if(C=i._req=null,p.headers.upgrade.toLowerCase()!=="websocket"){Z(i,S,"Invalid Upgrade header");return}let k=ba("sha1").update(l+Ca).digest("base64");if(p.headers["sec-websocket-accept"]!==k){Z(i,S,"Invalid Sec-WebSocket-Accept header");return}let d=p.headers["sec-websocket-protocol"],y;if(d!==void 0?m.size?m.has(d)||(y="Server sent an invalid subprotocol"):y="Server sent a subprotocol but none was requested":m.size&&(y="Server sent no subprotocol"),y){Z(i,S,y);return}d&&(i._protocol=d);let V=p.headers["sec-websocket-extensions"];if(V!==void 0){if(!w){Z(i,S,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let R;try{R=Oa(V)}catch(X){Z(i,S,"Invalid Sec-WebSocket-Extensions header");return}let z=Object.keys(R);if(z.length!==1||z[0]!==ke.extensionName){Z(i,S,"Server indicated an extension that was not requested");return}try{w.accept(R[ke.extensionName])}catch(X){Z(i,S,"Invalid Sec-WebSocket-Extensions header");return}i._extensions[ke.extensionName]=w}i.setSocket(S,L,{generateMask:s.generateMask,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation})}),C.end()}function Si(i,e){i._readyState=I.CLOSING,i.emit("error",e),i.emitClose()}function Fa(i){return i.path=i.socketPath,Zs.connect(i)}function Ba(i){return i.path=void 0,!i.servername&&i.servername!==""&&(i.servername=Zs.isIP(i.host)?"":i.host),Ea.connect(i)}function Z(i,e,t){i._readyState=I.CLOSING;let r=new Error(t);Error.captureStackTrace(r,Z),e.setHeader?(e[tn]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Si,i,r)):(e.destroy(r),e.once("error",i.emit.bind(i,"error")),e.once("close",i.emitClose.bind(i)))}function fr(i,e,t){if(e){let r=Ia(e).length;i._socket?i._sender._bufferedBytes+=r:i._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${i.readyState} (${_e[i.readyState]})`);t(r)}}function Ua(i,e){let t=this[G];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=i,t._socket[G]!==void 0&&(t._socket.removeListener("data",bi),process.nextTick(sn,t._socket),i===1005?t.close():t.close(i,e))}function Da(){let i=this[G];i.isPaused||i._socket.resume()}function Ma(i){let e=this[G];e._socket[G]!==void 0&&(e._socket.removeListener("data",bi),process.nextTick(sn,e._socket),e.close(i[Aa])),e.emit("error",i)}function Qs(){this[G].emitClose()}function qa(i,e){this[G].emit("message",i,e)}function Wa(i){let e=this[G];e.pong(i,!e._isServer,en),e.emit("ping",i)}function $a(i){this[G].emit("pong",i)}function sn(i){i.resume()}function nn(){let i=this[G];this.removeListener("close",nn),this.removeListener("data",bi),this.removeListener("end",on),i._readyState=I.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[G]=void 0,clearTimeout(i._closeTimer),i._receiver._writableState.finished||i._receiver._writableState.errorEmitted?i.emitClose():(i._receiver.on("error",Qs),i._receiver.on("finish",Qs))}function bi(i){this[G]._receiver.write(i)||this.pause()}function on(){let i=this[G];i._readyState=I.CLOSING,i._receiver.end(),this.end()}function an(){let i=this[G];this.removeListener("error",an),this.on("error",en),i&&(i._readyState=I.CLOSING,this.destroy())}});var ln=T((Vl,hn)=>{"use strict";var{tokenChars:Va}=kt();function ja(i){let e=new Set,t=-1,r=-1,s=0;for(s;s<i.length;s++){let o=i.charCodeAt(s);if(r===-1&&Va[o]===1)t===-1&&(t=s);else if(s!==0&&(o===32||o===9))r===-1&&t!==-1&&(r=s);else if(o===44){if(t===-1)throw new SyntaxError(`Unexpected character at index ${s}`);r===-1&&(r=s);let a=i.slice(t,r);if(e.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);e.add(a),t=r=-1}else throw new SyntaxError(`Unexpected character at index ${s}`)}if(t===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let n=i.slice(t,s);if(e.has(n))throw new SyntaxError(`The "${n}" subprotocol is duplicated`);return e.add(n),e}hn.exports={parse:ja}});var yn=T((zl,gn)=>{"use strict";var Ha=x("events"),xi=x("http"),jl=x("https"),Hl=x("net"),Gl=x("tls"),{createHash:Ga}=x("crypto"),fn=ar(),Be=At(),za=ln(),Ka=ur(),{GUID:Ya,kWebSocket:Xa}=Ne(),Ja=/^[+/0-9A-Za-z]{22}==$/,un=0,dn=1,mn=2,dr=class extends Ha{constructor(e,t){if(super(),e=b({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:Ka},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=xi.createServer((r,s)=>{let n=xi.STATUS_CODES[426];s.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),s.end(n)}),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=Qa(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(s,n,o)=>{this.handleUpgrade(s,n,o,r)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=un}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===mn){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Pt,this);return}if(e&&this.once("close",e),this._state!==dn)if(this._state=dn,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(Pt,this):process.nextTick(Pt,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{Pt(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,s){t.on("error",pn);let n=e.headers["sec-websocket-key"],o=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Ue(this,e,t,405,"Invalid HTTP method");return}if(e.headers.upgrade.toLowerCase()!=="websocket"){Ue(this,e,t,400,"Invalid Upgrade header");return}if(!n||!Ja.test(n)){Ue(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(o!==8&&o!==13){Ue(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header");return}if(!this.shouldHandle(e)){Lt(t,400);return}let a=e.headers["sec-websocket-protocol"],c=new Set;if(a!==void 0)try{c=za.parse(a)}catch(f){Ue(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let u=e.headers["sec-websocket-extensions"],l={};if(this.options.perMessageDeflate&&u!==void 0){let f=new Be(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let m=fn.parse(u);m[Be.extensionName]&&(f.accept(m[Be.extensionName]),l[Be.extensionName]=f)}catch(m){Ue(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,(m,w,C,p)=>{if(!m)return Lt(t,w||401,C,p);this.completeUpgrade(l,n,c,e,t,r,s)});return}if(!this.options.verifyClient(f))return Lt(t,401)}this.completeUpgrade(l,n,c,e,t,r,s)}completeUpgrade(e,t,r,s,n,o,a){if(!n.readable||!n.writable)return n.destroy();if(n[Xa])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>un)return Lt(n,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Ga("sha1").update(t+Ya).digest("base64")}`],l=new this.options.WebSocket(null);if(r.size){let f=this.options.handleProtocols?this.options.handleProtocols(r,s):r.values().next().value;f&&(u.push(`Sec-WebSocket-Protocol: ${f}`),l._protocol=f)}if(e[Be.extensionName]){let f=e[Be.extensionName].params,m=fn.format({[Be.extensionName]:[f]});u.push(`Sec-WebSocket-Extensions: ${m}`),l._extensions=e}this.emit("headers",u,s),n.write(u.concat(`\r
|
|
3
|
+
`+n),i.push(s+"m+"+ui.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=Po()+e+" "+i[0]}function Po(){return q.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Lo(...i){return process.stderr.write(fi.formatWithOptions(q.inspectOpts,...i)+`
|
|
4
|
+
`)}function Fo(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function Bo(){return process.env.DEBUG}function Uo(i){i.inspectOpts={};let e=Object.keys(q.inspectOpts);for(let t=0;t<e.length;t++)i.inspectOpts[e[t]]=q.inspectOpts[e[t]]}ui.exports=Wi()(q);var{formatters:ts}=ui.exports;ts.o=function(i){return this.inspectOpts.colors=this.useColors,fi.inspect(i,this.inspectOpts).split(`
|
|
5
|
+
`).map(e=>e.trim()).join(" ")};ts.O=function(i){return this.inspectOpts.colors=this.useColors,fi.inspect(i,this.inspectOpts)}});var le=T((cl,Vi)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?Vi.exports=Yr():Vi.exports=is()});var us=T((gl,fs)=>{"use strict";var Ze=x("fs"),ls=x("url"),qo=x("child_process").spawn;fs.exports=Gi;Gi.XMLHttpRequest=Gi;function Gi(i){"use strict";i=i||{};var e=this,t=x("http"),r=x("https"),s,n,o={},a=!1,c={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},u=Object.assign({},c),l=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","content-transfer-encoding","cookie","cookie2","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"],f=["TRACE","TRACK","CONNECT"],m=!1,w=!1,C=!1,p={};this.UNSENT=0,this.OPENED=1,this.HEADERS_RECEIVED=2,this.LOADING=3,this.DONE=4,this.readyState=this.UNSENT,this.onreadystatechange=null,this.responseText="",this.responseXML="",this.status=null,this.statusText=null;var b=function(d){return a||d&&l.indexOf(d.toLowerCase())===-1},L=function(d){return d&&f.indexOf(d)===-1};this.open=function(d,y,V,R,z){if(this.abort(),w=!1,C=!1,!L(d))throw new Error("SecurityError: Request method not allowed");o={method:d,url:y.toString(),async:typeof V!="boolean"?!0:V,user:R||null,password:z||null},k(this.OPENED)},this.setDisableHeaderCheck=function(d){a=d},this.setRequestHeader=function(d,y){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");if(!b(d))return console.warn('Refused to set unsafe header "'+d+'"'),!1;if(m)throw new Error("INVALID_STATE_ERR: send flag is true");return u[d]=y,!0},this.getResponseHeader=function(d){return typeof d=="string"&&this.readyState>this.OPENED&&n.headers[d.toLowerCase()]&&!w?n.headers[d.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState<this.HEADERS_RECEIVED||w)return"";var d="";for(var y in n.headers)y!=="set-cookie"&&y!=="set-cookie2"&&(d+=y+": "+n.headers[y]+`\r
|
|
6
|
+
`);return d.substr(0,d.length-2)},this.getRequestHeader=function(d){return typeof d=="string"&&u[d]?u[d]:""},this.send=function(d){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");if(m)throw new Error("INVALID_STATE_ERR: send has already been called");var y=!1,V=!1,R=ls.parse(o.url),z;switch(R.protocol){case"https:":y=!0;case"http:":z=R.hostname;break;case"file:":V=!0;break;case void 0:case"":z="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)Ze.readFile(unescape(R.pathname),"utf8",function(te,$e){te?e.handleError(te,te.errno||-1):(e.status=200,e.responseText=$e,k(e.DONE))});else try{this.responseText=Ze.readFileSync(unescape(R.pathname),"utf8"),this.status=200,k(e.DONE)}catch(te){this.handleError(te,te.errno||-1)}return}var X=R.port||(y?443:80),Ee=R.pathname+(R.search?R.search:"");if(u.Host=z,y&&X===443||X===80||(u.Host+=":"+R.port),o.user){typeof o.password=="undefined"&&(o.password="");var jt=new Buffer(o.user+":"+o.password);u.Authorization="Basic "+jt.toString("base64")}o.method==="GET"||o.method==="HEAD"?d=null:d?(u["Content-Length"]=Buffer.isBuffer(d)?d.length:Buffer.byteLength(d),u["Content-Type"]||(u["Content-Type"]="text/plain;charset=UTF-8")):o.method==="POST"&&(u["Content-Length"]=0);var Ht=i.agent||!1,ee={host:z,port:X,path:Ee,method:o.method,headers:u,agent:Ht};if(y&&(ee.pfx=i.pfx,ee.key=i.key,ee.passphrase=i.passphrase,ee.cert=i.cert,ee.ca=i.ca,ee.ciphers=i.ciphers,ee.rejectUnauthorized=i.rejectUnauthorized!==!1),w=!1,o.async){var We=y?r.request:t.request;m=!0,e.dispatchEvent("readystatechange");var wr=function(te){if(n=te,n.statusCode===302||n.statusCode===303||n.statusCode===307){o.url=n.headers.location;var $e=ls.parse(o.url);z=$e.hostname;var be={hostname:$e.hostname,port:$e.port,path:$e.path,method:n.statusCode===303?"GET":o.method,headers:u};y&&(be.pfx=i.pfx,be.key=i.key,be.passphrase=i.passphrase,be.cert=i.cert,be.ca=i.ca,be.ciphers=i.ciphers,be.rejectUnauthorized=i.rejectUnauthorized!==!1),s=We(be,wr).on("error",Cr),s.end();return}n&&n.setEncoding&&n.setEncoding("utf8"),k(e.HEADERS_RECEIVED),e.status=n.statusCode,n.on("data",function(Gt){Gt&&(e.responseText+=Gt),m&&k(e.LOADING)}),n.on("end",function(){m&&(m=!1,k(e.DONE))}),n.on("error",function(Gt){e.handleError(Gt)})},Cr=function(te){e.handleError(te)};s=We(ee,wr).on("error",Cr),i.autoUnref&&s.on("socket",te=>{te.unref()}),d&&s.write(d),s.end(),e.dispatchEvent("loadstart")}else{var lt=".node-xmlhttprequest-content-"+process.pid,ft=".node-xmlhttprequest-sync-"+process.pid;Ze.writeFileSync(ft,"","utf8");for(var $n="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(y?"s":"")+".request;var options = "+JSON.stringify(ee)+";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('"+lt+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+ft+"');});response.on('error', function(error) {fs.writeFileSync('"+lt+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+ft+"');});}).on('error', function(error) {fs.writeFileSync('"+lt+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+ft+"');});"+(d?"req.write('"+JSON.stringify(d).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",Vn=qo(process.argv[0],["-e",$n]),gc;Ze.existsSync(ft););if(e.responseText=Ze.readFileSync(lt,"utf8"),Vn.stdin.end(),Ze.unlinkSync(lt),e.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var jn=e.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");e.handleError(jn,503)}else e.status=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1"),e.responseText=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"),k(e.DONE)}},this.handleError=function(d,y){this.status=y||0,this.statusText=d,this.responseText=d.stack,w=!0,k(this.DONE)},this.abort=function(){s&&(s.abort(),s=null),u=Object.assign({},c),this.responseText="",this.responseXML="",w=C=!0,this.readyState!==this.UNSENT&&(this.readyState!==this.OPENED||m)&&this.readyState!==this.DONE&&(m=!1,k(this.DONE)),this.readyState=this.UNSENT},this.addEventListener=function(d,y){d in p||(p[d]=[]),p[d].push(y)},this.removeEventListener=function(d,y){d in p&&(p[d]=p[d].filter(function(V){return V!==y}))},this.dispatchEvent=function(d){if(typeof e["on"+d]=="function"&&(this.readyState===this.DONE?setImmediate(function(){e["on"+d]()}):e["on"+d]()),d in p)for(let y=0,V=p[d].length;y<V;y++)this.readyState===this.DONE?setImmediate(function(){p[d][y].call(e)}):p[d][y].call(e)};var k=function(d){if(!(e.readyState===d||e.readyState===e.UNSENT&&C)&&(e.readyState=d,(o.async||e.readyState<e.OPENED||e.readyState===e.DONE)&&e.dispatchEvent("readystatechange"),e.readyState===e.DONE)){let y;C?y="abort":w?y="error":y="load",e.dispatchEvent(y),e.dispatchEvent("loadend")}}}});var _s=T((Nl,vs)=>{"use strict";var{Duplex:jo}=x("stream");function gs(i){i.emit("close")}function Ho(){!this.destroyed&&this._writableState.finished&&this.destroy()}function ys(i){this.removeListener("error",ys),this.destroy(),this.listenerCount("error")===0&&this.emit("error",i)}function Go(i,e){let t=!0,r=new jo(U(S({},e),{autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1}));return i.on("message",function(n,o){let a=!o&&r._readableState.objectMode?n.toString():n;r.push(a)||i.pause()}),i.once("error",function(n){r.destroyed||(t=!1,r.destroy(n))}),i.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(s,n){if(i.readyState===i.CLOSED){n(s),process.nextTick(gs,r);return}let o=!1;i.once("error",function(c){o=!0,n(c)}),i.once("close",function(){o||n(s),process.nextTick(gs,r)}),t&&i.terminate()},r._final=function(s){if(i.readyState===i.CONNECTING){i.once("open",function(){r._final(s)});return}i._socket!==null&&(i._socket._writableState.finished?(s(),r._readableState.endEmitted&&r.destroy()):(i._socket.once("finish",function(){s()}),i.close()))},r._read=function(){i.isPaused&&i.resume()},r._write=function(s,n,o){if(i.readyState===i.CONNECTING){i.once("open",function(){r._write(s,n,o)});return}i.send(s,o)},r.on("end",Ho),r.on("error",ys),r}vs.exports=Go});var Ne=T((kl,Es)=>{"use strict";Es.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 Ct=T((Rl,gi)=>{"use strict";var{EMPTY_BUFFER:zo}=Ne();function Ko(i,e){if(i.length===0)return zo;if(i.length===1)return i[0];let t=Buffer.allocUnsafe(e),r=0;for(let s=0;s<i.length;s++){let n=i[s];t.set(n,r),r+=n.length}return r<e?t.slice(0,r):t}function bs(i,e,t,r,s){for(let n=0;n<s;n++)t[r+n]=i[n]^e[n&3]}function Ss(i,e){for(let t=0;t<i.length;t++)i[t]^=e[t&3]}function Yo(i){return i.byteLength===i.buffer.byteLength?i.buffer:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}function Xi(i){if(Xi.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),Xi.readOnly=!1),e}gi.exports={concat:Ko,mask:bs,toArrayBuffer:Yo,toBuffer:Xi,unmask:Ss};if(!process.env.WS_NO_BUFFER_UTIL)try{let i=x("bufferutil");gi.exports.mask=function(e,t,r,s,n){n<48?bs(e,t,r,s,n):i.mask(e,t,r,s,n)},gi.exports.unmask=function(e,t){e.length<32?Ss(e,t):i.unmask(e,t)}}catch(i){}});var Cs=T((Tl,ws)=>{"use strict";var xs=Symbol("kDone"),Ji=Symbol("kRun"),Qi=class{constructor(e){this[xs]=()=>{this.pending--,this[Ji]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Ji]()}[Ji](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[xs])}}};ws.exports=Qi});var kt=T((Ol,Rs)=>{"use strict";var Nt=x("zlib"),Ns=Ct(),Xo=Cs(),{kStatusCode:As}=Ne(),Jo=Buffer.from([0,0,255,255]),_i=Symbol("permessage-deflate"),ye=Symbol("total-length"),At=Symbol("callback"),Ae=Symbol("buffers"),vi=Symbol("error"),yi,Zi=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,!yi){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;yi=new Xo(s)}}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[At];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(s=>!(t.serverNoContextTakeover===!1&&s.server_no_context_takeover||s.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>s.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!s.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 s=t[r];if(s.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(s=s[0],r==="client_max_window_bits"){if(s!==!0){let n=+s;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${r}": ${s}`);s=n}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${s}`)}else if(r==="server_max_window_bits"){let n=+s;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${r}": ${s}`);s=n}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(s!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${s}`)}else throw new Error(`Unknown parameter "${r}"`);t[r]=s})}),e}decompress(e,t,r){yi.add(s=>{this._decompress(e,t,(n,o)=>{s(),r(n,o)})})}compress(e,t,r){yi.add(s=>{this._compress(e,t,(n,o)=>{s(),r(n,o)})})}_decompress(e,t,r){let s=this._isServer?"client":"server";if(!this._inflate){let n=`${s}_max_window_bits`,o=typeof this.params[n]!="number"?Nt.Z_DEFAULT_WINDOWBITS:this.params[n];this._inflate=Nt.createInflateRaw(U(S({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[_i]=this,this._inflate[ye]=0,this._inflate[Ae]=[],this._inflate.on("error",Zo),this._inflate.on("data",ks)}this._inflate[At]=r,this._inflate.write(e),t&&this._inflate.write(Jo),this._inflate.flush(()=>{let n=this._inflate[vi];if(n){this._inflate.close(),this._inflate=null,r(n);return}let o=Ns.concat(this._inflate[Ae],this._inflate[ye]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[ye]=0,this._inflate[Ae]=[],t&&this.params[`${s}_no_context_takeover`]&&this._inflate.reset()),r(null,o)})}_compress(e,t,r){let s=this._isServer?"server":"client";if(!this._deflate){let n=`${s}_max_window_bits`,o=typeof this.params[n]!="number"?Nt.Z_DEFAULT_WINDOWBITS:this.params[n];this._deflate=Nt.createDeflateRaw(U(S({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[ye]=0,this._deflate[Ae]=[],this._deflate.on("data",Qo)}this._deflate[At]=r,this._deflate.write(e),this._deflate.flush(Nt.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let n=Ns.concat(this._deflate[Ae],this._deflate[ye]);t&&(n=n.slice(0,n.length-4)),this._deflate[At]=null,this._deflate[ye]=0,this._deflate[Ae]=[],t&&this.params[`${s}_no_context_takeover`]&&this._deflate.reset(),r(null,n)})}};Rs.exports=Zi;function Qo(i){this[Ae].push(i),this[ye]+=i.length}function ks(i){if(this[ye]+=i.length,this[_i]._maxPayload<1||this[ye]<=this[_i]._maxPayload){this[Ae].push(i);return}this[vi]=new RangeError("Max payload size exceeded"),this[vi].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[vi][As]=1009,this.removeListener("data",ks),this.reset()}function Zo(i){this[_i]._inflate=null,i[As]=1007,this[At](i)}});var Rt=T((Pl,er)=>{"use strict";var ea=[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 ta(i){return i>=1e3&&i<=1014&&i!==1004&&i!==1005&&i!==1006||i>=3e3&&i<=4999}function Ts(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}er.exports={isValidStatusCode:ta,isValidUTF8:Ts,tokenChars:ea};if(!process.env.WS_NO_UTF_8_VALIDATE)try{let i=x("utf-8-validate");er.exports.isValidUTF8=function(e){return e.length<150?Ts(e):i(e)}}catch(i){}});var sr=T((Ll,Us)=>{"use strict";var{Writable:ia}=x("stream"),Os=kt(),{BINARY_TYPES:ra,EMPTY_BUFFER:Is,kStatusCode:sa,kWebSocket:na}=Ne(),{concat:tr,toArrayBuffer:oa,unmask:aa}=Ct(),{isValidStatusCode:ca,isValidUTF8:Ps}=Rt(),Tt=0,Ls=1,Fs=2,Bs=3,ir=4,ha=5,rr=class extends ia{constructor(e={}){super(),this._binaryType=e.binaryType||ra[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[na]=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=Tt,this._loop=!1}_write(e,t,r){if(this._opcode===8&&this._state==Tt)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],s=t.length-e;e>=r.length?t.set(this._buffers.shift(),s):(t.set(new Uint8Array(r.buffer,r.byteOffset,e),s),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 Tt:t=this.getInfo();break;case Ls:t=this.getPayloadLength16();break;case Fs:t=this.getPayloadLength64();break;case Bs:this.getMask();break;case ir: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,F(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[Os.extensionName])return this._loop=!1,F(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,F(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,F(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,F(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,F(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(t)return this._loop=!1,F(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,F(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else return this._loop=!1,F(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,F(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,F(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(this._payloadLength===126)this._state=Ls;else if(this._payloadLength===127)this._state=Fs;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,F(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,F(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=Bs:this._state=ir}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=ir}getData(e){let t=Is;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]&&aa(t,this._mask)}if(this._opcode>7)return this.controlMessage(t);if(this._compressed){this._state=ha,this.decompress(t,e);return}return t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage()}decompress(e,t){this._extensions[Os.extensionName].decompress(e,this._fin,(s,n)=>{if(s)return t(s);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return t(F(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(n)}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=tr(t,e):this._binaryType==="arraybuffer"?r=oa(tr(t,e)):r=t,this.emit("message",r,!0)}else{let r=tr(t,e);if(!this._skipUTF8Validation&&!Ps(r))return this._loop=!1,F(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",r,!1)}}this._state=Tt}controlMessage(e){if(this._opcode===8)if(this._loop=!1,e.length===0)this.emit("conclude",1005,Is),this.end();else{if(e.length===1)return F(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{let t=e.readUInt16BE(0);if(!ca(t))return F(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let r=e.slice(2);if(!this._skipUTF8Validation&&!Ps(r))return F(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=Tt}};Us.exports=rr;function F(i,e,t,r,s){let n=new i(t?`Invalid WebSocket frame: ${e}`:e);return Error.captureStackTrace(n,F),n.code=s,n[sa]=r,n}});var or=T((Ul,qs)=>{"use strict";var Fl=x("net"),Bl=x("tls"),{randomFillSync:la}=x("crypto"),Ds=kt(),{EMPTY_BUFFER:fa}=Ne(),{isValidStatusCode:ua}=Rt(),{mask:Ms,toBuffer:et}=Ct(),fe=Symbol("kByteLength"),da=Buffer.alloc(4),nr=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,s=!1,n=2,o=!1;t.mask&&(r=t.maskBuffer||da,t.generateMask?t.generateMask(r):la(r,0,4),o=(r[0]|r[1]|r[2]|r[3])===0,n=6);let a;typeof e=="string"?(!t.mask||o)&&t[fe]!==void 0?a=t[fe]:(e=Buffer.from(e),a=e.length):(a=e.length,s=t.mask&&t.readOnly&&!o);let c=a;a>=65536?(n+=8,c=127):a>125&&(n+=2,c=126);let u=Buffer.allocUnsafe(s?a+n:n);return u[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(u[0]|=64),u[1]=c,c===126?u.writeUInt16BE(a,2):c===127&&(u[2]=u[3]=0,u.writeUIntBE(a,4,6)),t.mask?(u[1]|=128,u[n-4]=r[0],u[n-3]=r[1],u[n-2]=r[2],u[n-1]=r[3],o?[u,e]:s?(Ms(e,r,u,n,a),[u]):(Ms(e,r,e,0,a),[u,e])):[u,e]}close(e,t,r,s){let n;if(e===void 0)n=fa;else{if(typeof e!="number"||!ua(e))throw new TypeError("First argument must be a valid error code number");if(t===void 0||!t.length)n=Buffer.allocUnsafe(2),n.writeUInt16BE(e,0);else{let a=Buffer.byteLength(t);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");n=Buffer.allocUnsafe(2+a),n.writeUInt16BE(e,0),typeof t=="string"?n.write(t,2):n.set(t,2)}}let o={[fe]:n.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,n,!1,o,s]):this.sendFrame(i.frame(n,o),s)}ping(e,t,r){let s,n;if(typeof e=="string"?(s=Buffer.byteLength(e),n=!1):(e=et(e),s=e.length,n=et.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[fe]:s,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(i.frame(e,o),r)}pong(e,t,r){let s,n;if(typeof e=="string"?(s=Buffer.byteLength(e),n=!1):(e=et(e),s=e.length,n=et.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[fe]:s,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(i.frame(e,o),r)}send(e,t,r){let s=this._extensions[Ds.extensionName],n=t.binary?2:1,o=t.compress,a,c;if(typeof e=="string"?(a=Buffer.byteLength(e),c=!1):(e=et(e),a=e.length,c=et.readOnly),this._firstFragment?(this._firstFragment=!1,o&&s&&s.params[s._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=a>=s._threshold),this._compress=o):(o=!1,n=0),t.fin&&(this._firstFragment=!0),s){let u={[fe]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:c,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,{[fe]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:c,rsv1:!1}),r)}dispatch(e,t,r,s){if(!t){this.sendFrame(i.frame(e,r),s);return}let n=this._extensions[Ds.extensionName];this._bufferedBytes+=r[fe],this._deflating=!0,n.compress(e,r.fin,(o,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being compressed");typeof s=="function"&&s(c);for(let u=0;u<this._queue.length;u++){let l=this._queue[u],f=l[l.length-1];typeof f=="function"&&f(c)}return}this._bufferedBytes-=r[fe],this._deflating=!1,r.readOnly=!1,this.sendFrame(i.frame(a,r),s),this.dequeue()})}dequeue(){for(;!this._deflating&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][fe],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][fe],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)}};qs.exports=nr});var Ys=T((Dl,Ks)=>{"use strict";var{kForOnEventAttribute:Ot,kListener:ar}=Ne(),Ws=Symbol("kCode"),$s=Symbol("kData"),Vs=Symbol("kError"),js=Symbol("kMessage"),Hs=Symbol("kReason"),tt=Symbol("kTarget"),Gs=Symbol("kType"),zs=Symbol("kWasClean"),ve=class{constructor(e){this[tt]=null,this[Gs]=e}get target(){return this[tt]}get type(){return this[Gs]}};Object.defineProperty(ve.prototype,"target",{enumerable:!0});Object.defineProperty(ve.prototype,"type",{enumerable:!0});var Fe=class extends ve{constructor(e,t={}){super(e),this[Ws]=t.code===void 0?0:t.code,this[Hs]=t.reason===void 0?"":t.reason,this[zs]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[Ws]}get reason(){return this[Hs]}get wasClean(){return this[zs]}};Object.defineProperty(Fe.prototype,"code",{enumerable:!0});Object.defineProperty(Fe.prototype,"reason",{enumerable:!0});Object.defineProperty(Fe.prototype,"wasClean",{enumerable:!0});var it=class extends ve{constructor(e,t={}){super(e),this[Vs]=t.error===void 0?null:t.error,this[js]=t.message===void 0?"":t.message}get error(){return this[Vs]}get message(){return this[js]}};Object.defineProperty(it.prototype,"error",{enumerable:!0});Object.defineProperty(it.prototype,"message",{enumerable:!0});var It=class extends ve{constructor(e,t={}){super(e),this[$s]=t.data===void 0?null:t.data}get data(){return this[$s]}};Object.defineProperty(It.prototype,"data",{enumerable:!0});var pa={addEventListener(i,e,t={}){for(let s of this.listeners(i))if(!t[Ot]&&s[ar]===e&&!s[Ot])return;let r;if(i==="message")r=function(n,o){let a=new It("message",{data:o?n:n.toString()});a[tt]=this,Ei(e,this,a)};else if(i==="close")r=function(n,o){let a=new Fe("close",{code:n,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[tt]=this,Ei(e,this,a)};else if(i==="error")r=function(n){let o=new it("error",{error:n,message:n.message});o[tt]=this,Ei(e,this,o)};else if(i==="open")r=function(){let n=new ve("open");n[tt]=this,Ei(e,this,n)};else return;r[Ot]=!!t[Ot],r[ar]=e,t.once?this.once(i,r):this.on(i,r)},removeEventListener(i,e){for(let t of this.listeners(i))if(t[ar]===e&&!t[Ot]){this.removeListener(i,t);break}}};Ks.exports={CloseEvent:Fe,ErrorEvent:it,Event:ve,EventTarget:pa,MessageEvent:It};function Ei(i,e,t){typeof i=="object"&&i.handleEvent?i.handleEvent.call(i,t):i.call(e,t)}});var cr=T((Ml,Xs)=>{"use strict";var{tokenChars:Pt}=Rt();function ue(i,e,t){i[e]===void 0?i[e]=[t]:i[e].push(t)}function ma(i){let e=Object.create(null),t=Object.create(null),r=!1,s=!1,n=!1,o,a,c=-1,u=-1,l=-1,f=0;for(;f<i.length;f++)if(u=i.charCodeAt(f),o===void 0)if(l===-1&&Pt[u]===1)c===-1&&(c=f);else if(f!==0&&(u===32||u===9))l===-1&&c!==-1&&(l=f);else if(u===59||u===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f);let w=i.slice(c,l);u===44?(ue(e,w,t),t=Object.create(null)):o=w,c=l=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);else if(a===void 0)if(l===-1&&Pt[u]===1)c===-1&&(c=f);else if(u===32||u===9)l===-1&&c!==-1&&(l=f);else if(u===59||u===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f),ue(t,i.slice(c,l),!0),u===44&&(ue(e,o,t),t=Object.create(null),o=void 0),c=l=-1}else if(u===61&&c!==-1&&l===-1)a=i.slice(c,f),c=l=-1;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(s){if(Pt[u]!==1)throw new SyntaxError(`Unexpected character at index ${f}`);c===-1?c=f:r||(r=!0),s=!1}else if(n)if(Pt[u]===1)c===-1&&(c=f);else if(u===34&&c!==-1)n=!1,l=f;else if(u===92)s=!0;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(u===34&&i.charCodeAt(f-1)===61)n=!0;else if(l===-1&&Pt[u]===1)c===-1&&(c=f);else if(c!==-1&&(u===32||u===9))l===-1&&(l=f);else if(u===59||u===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f);let w=i.slice(c,l);r&&(w=w.replace(/\\/g,""),r=!1),ue(t,a,w),u===44&&(ue(e,o,t),t=Object.create(null),o=void 0),a=void 0,c=l=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);if(c===-1||n||u===32||u===9)throw new SyntaxError("Unexpected end of input");l===-1&&(l=f);let m=i.slice(c,l);return o===void 0?ue(e,m,t):(a===void 0?ue(t,m,!0):r?ue(t,a,m.replace(/\\/g,"")):ue(t,a,m),ue(e,o,t)),e}function ga(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(s=>{let n=r[s];return Array.isArray(n)||(n=[n]),n.map(o=>o===!0?s:`${s}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Xs.exports={format:ga,parse:ma}});var dr=T((Wl,cn)=>{"use strict";var ya=x("events"),va=x("https"),_a=x("http"),Zs=x("net"),Ea=x("tls"),{randomBytes:ba,createHash:Sa}=x("crypto"),{Readable:ql}=x("stream"),{URL:hr}=x("url"),ke=kt(),xa=sr(),wa=or(),{BINARY_TYPES:Js,EMPTY_BUFFER:bi,GUID:Ca,kForOnEventAttribute:lr,kListener:Na,kStatusCode:Aa,kWebSocket:G,NOOP:en}=Ne(),{EventTarget:{addEventListener:ka,removeEventListener:Ra}}=Ys(),{format:Ta,parse:Oa}=cr(),{toBuffer:Ia}=Ct(),Pa=30*1e3,tn=Symbol("kAborted"),fr=[8,13],_e=["CONNECTING","OPEN","CLOSING","CLOSED"],La=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,I=class i extends ya{constructor(e,t,r){super(),this._binaryType=Js[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=bi,this._closeTimer=null,this._extensions={},this._paused=!1,this._protocol="",this._readyState=i.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,t===void 0?t=[]:Array.isArray(t)||(typeof t=="object"&&t!==null?(r=t,t=[]):t=[t]),rn(this,e,t,r)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){Js.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,r){let s=new xa({binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation});this._sender=new wa(e,this._extensions,r.generateMask),this._receiver=s,this._socket=e,s[G]=this,e[G]=this,s.on("conclude",Ua),s.on("drain",Da),s.on("error",Ma),s.on("message",qa),s.on("ping",Wa),s.on("pong",$a),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",nn),e.on("data",xi),e.on("end",on),e.on("error",an),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[ke.extensionName]&&this._extensions[ke.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 Q(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),Pa)}}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){ur(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||bi,t,r)}pong(e,t,r){if(this.readyState===i.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=t=void 0):typeof t=="function"&&(r=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==i.OPEN){ur(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||bi,t,r)}resume(){this.readyState===i.CONNECTING||this.readyState===i.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,r){if(this.readyState===i.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"&&(r=t,t={}),typeof e=="number"&&(e=e.toString()),this.readyState!==i.OPEN){ur(this,e,r);return}let s=S({binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0},t);this._extensions[ke.extensionName]||(s.compress=!1),this._sender.send(e||bi,s,r)}terminate(){if(this.readyState!==i.CLOSED){if(this.readyState===i.CONNECTING)return Q(this,this._req,"WebSocket was closed before the connection was established");this._socket&&(this._readyState=i.CLOSING,this._socket.destroy())}}};Object.defineProperty(I,"CONNECTING",{enumerable:!0,value:_e.indexOf("CONNECTING")});Object.defineProperty(I.prototype,"CONNECTING",{enumerable:!0,value:_e.indexOf("CONNECTING")});Object.defineProperty(I,"OPEN",{enumerable:!0,value:_e.indexOf("OPEN")});Object.defineProperty(I.prototype,"OPEN",{enumerable:!0,value:_e.indexOf("OPEN")});Object.defineProperty(I,"CLOSING",{enumerable:!0,value:_e.indexOf("CLOSING")});Object.defineProperty(I.prototype,"CLOSING",{enumerable:!0,value:_e.indexOf("CLOSING")});Object.defineProperty(I,"CLOSED",{enumerable:!0,value:_e.indexOf("CLOSED")});Object.defineProperty(I.prototype,"CLOSED",{enumerable:!0,value:_e.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(i=>{Object.defineProperty(I.prototype,i,{enumerable:!0})});["open","error","close","message"].forEach(i=>{Object.defineProperty(I.prototype,`on${i}`,{enumerable:!0,get(){for(let e of this.listeners(i))if(e[lr])return e[Na];return null},set(e){for(let t of this.listeners(i))if(t[lr]){this.removeListener(i,t);break}typeof e=="function"&&this.addEventListener(i,e,{[lr]:!0})}})});I.prototype.addEventListener=ka;I.prototype.removeEventListener=Ra;cn.exports=I;function rn(i,e,t,r){let s=U(S({protocolVersion:fr[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(!fr.includes(s.protocolVersion))throw new RangeError(`Unsupported protocol version: ${s.protocolVersion} (supported versions: ${fr.join(", ")})`);let n;if(e instanceof hr)n=e,i._url=e.href;else{try{n=new hr(e)}catch(p){throw new SyntaxError(`Invalid URL: ${e}`)}i._url=e}let o=n.protocol==="wss:",a=n.protocol==="ws+unix:",c;if(n.protocol!=="ws:"&&!o&&!a?c=`The URL's protocol must be one of "ws:", "wss:", or "ws+unix:"`:a&&!n.pathname?c="The URL's pathname is empty":n.hash&&(c="The URL contains a fragment identifier"),c){let p=new SyntaxError(c);if(i._redirects===0)throw p;Si(i,p);return}let u=o?443:80,l=ba(16).toString("base64"),f=o?va.request:_a.request,m=new Set,w;if(s.createConnection=o?Ba:Fa,s.defaultPort=s.defaultPort||u,s.port=n.port||u,s.host=n.hostname.startsWith("[")?n.hostname.slice(1,-1):n.hostname,s.headers=U(S({},s.headers),{"Sec-WebSocket-Version":s.protocolVersion,"Sec-WebSocket-Key":l,Connection:"Upgrade",Upgrade:"websocket"}),s.path=n.pathname+n.search,s.timeout=s.handshakeTimeout,s.perMessageDeflate&&(w=new ke(s.perMessageDeflate!==!0?s.perMessageDeflate:{},!1,s.maxPayload),s.headers["Sec-WebSocket-Extensions"]=Ta({[ke.extensionName]:w.offer()})),t.length){for(let p of t){if(typeof p!="string"||!La.test(p)||m.has(p))throw new SyntaxError("An invalid or duplicated subprotocol was specified");m.add(p)}s.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(s.origin&&(s.protocolVersion<13?s.headers["Sec-WebSocket-Origin"]=s.origin:s.headers.Origin=s.origin),(n.username||n.password)&&(s.auth=`${n.username}:${n.password}`),a){let p=s.path.split(":");s.socketPath=p[0],s.path=p[1]}let C;if(s.followRedirects){if(i._redirects===0){i._originalIpc=a,i._originalSecure=o,i._originalHostOrSocketPath=a?s.socketPath:n.host;let p=r&&r.headers;if(r=U(S({},r),{headers:{}}),p)for(let[b,L]of Object.entries(p))r.headers[b.toLowerCase()]=L}else if(i.listenerCount("redirect")===0){let p=a?i._originalIpc?s.socketPath===i._originalHostOrSocketPath:!1:i._originalIpc?!1:n.host===i._originalHostOrSocketPath;(!p||i._originalSecure&&!o)&&(delete s.headers.authorization,delete s.headers.cookie,p||delete s.headers.host,s.auth=void 0)}s.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(s.auth).toString("base64")),C=i._req=f(s),i._redirects&&i.emit("redirect",i.url,C)}else C=i._req=f(s);s.timeout&&C.on("timeout",()=>{Q(i,C,"Opening handshake has timed out")}),C.on("error",p=>{C===null||C[tn]||(C=i._req=null,Si(i,p))}),C.on("response",p=>{let b=p.headers.location,L=p.statusCode;if(b&&s.followRedirects&&L>=300&&L<400){if(++i._redirects>s.maxRedirects){Q(i,C,"Maximum redirects exceeded");return}C.abort();let k;try{k=new hr(b,e)}catch(d){let y=new SyntaxError(`Invalid URL: ${b}`);Si(i,y);return}rn(i,k,t,r)}else i.emit("unexpected-response",C,p)||Q(i,C,`Unexpected server response: ${p.statusCode}`)}),C.on("upgrade",(p,b,L)=>{if(i.emit("upgrade",p),i.readyState!==I.CONNECTING)return;if(C=i._req=null,p.headers.upgrade.toLowerCase()!=="websocket"){Q(i,b,"Invalid Upgrade header");return}let k=Sa("sha1").update(l+Ca).digest("base64");if(p.headers["sec-websocket-accept"]!==k){Q(i,b,"Invalid Sec-WebSocket-Accept header");return}let d=p.headers["sec-websocket-protocol"],y;if(d!==void 0?m.size?m.has(d)||(y="Server sent an invalid subprotocol"):y="Server sent a subprotocol but none was requested":m.size&&(y="Server sent no subprotocol"),y){Q(i,b,y);return}d&&(i._protocol=d);let V=p.headers["sec-websocket-extensions"];if(V!==void 0){if(!w){Q(i,b,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let R;try{R=Oa(V)}catch(X){Q(i,b,"Invalid Sec-WebSocket-Extensions header");return}let z=Object.keys(R);if(z.length!==1||z[0]!==ke.extensionName){Q(i,b,"Server indicated an extension that was not requested");return}try{w.accept(R[ke.extensionName])}catch(X){Q(i,b,"Invalid Sec-WebSocket-Extensions header");return}i._extensions[ke.extensionName]=w}i.setSocket(b,L,{generateMask:s.generateMask,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation})}),C.end()}function Si(i,e){i._readyState=I.CLOSING,i.emit("error",e),i.emitClose()}function Fa(i){return i.path=i.socketPath,Zs.connect(i)}function Ba(i){return i.path=void 0,!i.servername&&i.servername!==""&&(i.servername=Zs.isIP(i.host)?"":i.host),Ea.connect(i)}function Q(i,e,t){i._readyState=I.CLOSING;let r=new Error(t);Error.captureStackTrace(r,Q),e.setHeader?(e[tn]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Si,i,r)):(e.destroy(r),e.once("error",i.emit.bind(i,"error")),e.once("close",i.emitClose.bind(i)))}function ur(i,e,t){if(e){let r=Ia(e).length;i._socket?i._sender._bufferedBytes+=r:i._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${i.readyState} (${_e[i.readyState]})`);t(r)}}function Ua(i,e){let t=this[G];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=i,t._socket[G]!==void 0&&(t._socket.removeListener("data",xi),process.nextTick(sn,t._socket),i===1005?t.close():t.close(i,e))}function Da(){let i=this[G];i.isPaused||i._socket.resume()}function Ma(i){let e=this[G];e._socket[G]!==void 0&&(e._socket.removeListener("data",xi),process.nextTick(sn,e._socket),e.close(i[Aa])),e.emit("error",i)}function Qs(){this[G].emitClose()}function qa(i,e){this[G].emit("message",i,e)}function Wa(i){let e=this[G];e.pong(i,!e._isServer,en),e.emit("ping",i)}function $a(i){this[G].emit("pong",i)}function sn(i){i.resume()}function nn(){let i=this[G];this.removeListener("close",nn),this.removeListener("data",xi),this.removeListener("end",on),i._readyState=I.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[G]=void 0,clearTimeout(i._closeTimer),i._receiver._writableState.finished||i._receiver._writableState.errorEmitted?i.emitClose():(i._receiver.on("error",Qs),i._receiver.on("finish",Qs))}function xi(i){this[G]._receiver.write(i)||this.pause()}function on(){let i=this[G];i._readyState=I.CLOSING,i._receiver.end(),this.end()}function an(){let i=this[G];this.removeListener("error",an),this.on("error",en),i&&(i._readyState=I.CLOSING,this.destroy())}});var ln=T((Vl,hn)=>{"use strict";var{tokenChars:Va}=Rt();function ja(i){let e=new Set,t=-1,r=-1,s=0;for(s;s<i.length;s++){let o=i.charCodeAt(s);if(r===-1&&Va[o]===1)t===-1&&(t=s);else if(s!==0&&(o===32||o===9))r===-1&&t!==-1&&(r=s);else if(o===44){if(t===-1)throw new SyntaxError(`Unexpected character at index ${s}`);r===-1&&(r=s);let a=i.slice(t,r);if(e.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);e.add(a),t=r=-1}else throw new SyntaxError(`Unexpected character at index ${s}`)}if(t===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let n=i.slice(t,s);if(e.has(n))throw new SyntaxError(`The "${n}" subprotocol is duplicated`);return e.add(n),e}hn.exports={parse:ja}});var yn=T((zl,gn)=>{"use strict";var Ha=x("events"),wi=x("http"),jl=x("https"),Hl=x("net"),Gl=x("tls"),{createHash:Ga}=x("crypto"),fn=cr(),Be=kt(),za=ln(),Ka=dr(),{GUID:Ya,kWebSocket:Xa}=Ne(),Ja=/^[+/0-9A-Za-z]{22}==$/,un=0,dn=1,mn=2,pr=class extends Ha{constructor(e,t){if(super(),e=S({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:Ka},e),e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=wi.createServer((r,s)=>{let n=wi.STATUS_CODES[426];s.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),s.end(n)}),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=Qa(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(s,n,o)=>{this.handleUpgrade(s,n,o,r)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=un}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===mn){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Lt,this);return}if(e&&this.once("close",e),this._state!==dn)if(this._state=dn,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(Lt,this):process.nextTick(Lt,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{Lt(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,s){t.on("error",pn);let n=e.headers["sec-websocket-key"],o=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Ue(this,e,t,405,"Invalid HTTP method");return}if(e.headers.upgrade.toLowerCase()!=="websocket"){Ue(this,e,t,400,"Invalid Upgrade header");return}if(!n||!Ja.test(n)){Ue(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(o!==8&&o!==13){Ue(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header");return}if(!this.shouldHandle(e)){Ft(t,400);return}let a=e.headers["sec-websocket-protocol"],c=new Set;if(a!==void 0)try{c=za.parse(a)}catch(f){Ue(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let u=e.headers["sec-websocket-extensions"],l={};if(this.options.perMessageDeflate&&u!==void 0){let f=new Be(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let m=fn.parse(u);m[Be.extensionName]&&(f.accept(m[Be.extensionName]),l[Be.extensionName]=f)}catch(m){Ue(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,(m,w,C,p)=>{if(!m)return Ft(t,w||401,C,p);this.completeUpgrade(l,n,c,e,t,r,s)});return}if(!this.options.verifyClient(f))return Ft(t,401)}this.completeUpgrade(l,n,c,e,t,r,s)}completeUpgrade(e,t,r,s,n,o,a){if(!n.readable||!n.writable)return n.destroy();if(n[Xa])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>un)return Ft(n,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Ga("sha1").update(t+Ya).digest("base64")}`],l=new this.options.WebSocket(null);if(r.size){let f=this.options.handleProtocols?this.options.handleProtocols(r,s):r.values().next().value;f&&(u.push(`Sec-WebSocket-Protocol: ${f}`),l._protocol=f)}if(e[Be.extensionName]){let f=e[Be.extensionName].params,m=fn.format({[Be.extensionName]:[f]});u.push(`Sec-WebSocket-Extensions: ${m}`),l._extensions=e}this.emit("headers",u,s),n.write(u.concat(`\r
|
|
7
7
|
`).join(`\r
|
|
8
|
-
`)),n.removeListener("error",pn),l.setSocket(n,o,{maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(l),l.on("close",()=>{this.clients.delete(l),this._shouldEmitClose&&!this.clients.size&&process.nextTick(
|
|
8
|
+
`)),n.removeListener("error",pn),l.setSocket(n,o,{maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(l),l.on("close",()=>{this.clients.delete(l),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Lt,this)})),a(l,s)}};gn.exports=pr;function Qa(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 Lt(i){i._state=mn,i.emit("close")}function pn(){this.destroy()}function Ft(i,e,t,r){t=t||wi.STATUS_CODES[e],r=S({Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t)},r),i.once("finish",i.destroy),i.end(`HTTP/1.1 ${e} ${wi.STATUS_CODES[e]}\r
|
|
9
9
|
`+Object.keys(r).map(s=>`${s}: ${r[s]}`).join(`\r
|
|
10
10
|
`)+`\r
|
|
11
11
|
\r
|
|
12
|
-
`+t)}function Ue(i,e,t,r,s){if(i.listenerCount("wsClientError")){let n=new Error(s);Error.captureStackTrace(n,Ue),i.emit("wsClientError",n,t,e)}else Lt(t,r,s)}});function Tr(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(s){s(t)}),(r=i.get("*"))&&r.slice().map(function(s){s(e,t)})}}}var ft,Re,$e=class $e{constructor(){v(this,Re);_(this,Re,Tr())}static getInstance(e){return e!=null&&e.recreate&&_($e,ft,new $e),h($e,ft)}on(e,t){h(this,Re).on(e,t)}off(e,t){h(this,Re).off(e,t)}emit(e,t){h(this,Re).emit(e,t)}};ft=new WeakMap,Re=new WeakMap,v($e,ft);var H=$e;var P=class extends Error{constructor(e,t){super(e),this.originalError=t}};var Te=function(i,e,t,r){function s(n){return n instanceof t?n:new t(function(o){o(n)})}return new(t||(t=Promise))(function(n,o){function a(l){try{u(r.next(l))}catch(f){o(f)}}function c(l){try{u(r.throw(l))}catch(f){o(f)}}function u(l){l.done?n(l.value):s(l.value).then(a,c)}u((r=r.apply(i,e||[])).next())})},Zn="v1",eo="https://api.novu.co",to="@novu/client",io="2.0.0-canary.0",ro=`${to}-${io}`,Ve=class{constructor({apiVersion:e=Zn,backendUrl:t=eo,userAgent:r=ro}={}){this.apiVersion=e,this.backendUrl=`${t}/${this.apiVersion}`,this.headers={"Content-Type":"application/json","User-Agent":r}}setAuthorizationToken(e){this.headers.Authorization=`Bearer ${e}`}disposeAuthorizationToken(){delete this.headers.Authorization}updateHeaders(e){this.headers=Object.assign(Object.assign({},this.headers),e)}getFullResponse(e,t){return Te(this,void 0,void 0,function*(){return yield(yield this.doFetch(e+this.getQueryString(t))).json()})}get(e,t){return Te(this,void 0,void 0,function*(){return(yield(yield this.doFetch(e+this.getQueryString(t))).json()).data})}post(e,t={}){return Te(this,void 0,void 0,function*(){return(yield(yield this.doFetch(e,{method:"POST",body:JSON.stringify(t)})).json()).data})}patch(e,t={}){return Te(this,void 0,void 0,function*(){return(yield(yield this.doFetch(e,{method:"PATCH",body:JSON.stringify(t)})).json()).data})}delete(e,t={}){return Te(this,void 0,void 0,function*(){return(yield(yield this.doFetch(e,{method:"DELETE",body:JSON.stringify(t)})).json()).data})}getQueryString(e){return e?"?"+new URLSearchParams(e).toString():""}doFetch(e,t={}){return Te(this,void 0,void 0,function*(){try{let r=yield fetch(this.backendUrl+e,Object.assign(Object.assign({},t),{headers:this.headers}));return yield this.checkResponseStatus(r),r}catch(r){throw r}})}checkResponseStatus(e){return Te(this,void 0,void 0,function*(){if(!e.ok){let t=yield e.json();throw new Error(`HTTP error! Status: ${e.status}, Message: ${t.message}`)}})}};var so="2024-06-26",ut="/inbox",oe=`${ut}/notifications`,O,Kt=class{constructor(e={}){this.isSessionInitialized=!1;v(this,O);_(this,O,new Ve(e)),h(this,O).updateHeaders({"Novu-API-Version":so})}initializeSession(s){return g(this,arguments,function*({applicationIdentifier:e,subscriberId:t,subscriberHash:r}){let n=yield h(this,O).post(`${ut}/session`,{applicationIdentifier:e,subscriberId:t,subscriberHash:r});return h(this,O).setAuthorizationToken(n.token),this.isSessionInitialized=!0,n})}fetchNotifications({after:e,archived:t,limit:r=10,offset:s,read:n,tags:o}){let a=new URLSearchParams(`limit=${r}`);return e&&a.append("after",e),s&&a.append("offset",`${s}`),o&&o.forEach(c=>a.append("tags[]",c)),n!==void 0&&a.append("read",`${n}`),t!==void 0&&a.append("archived",`${t}`),h(this,O).getFullResponse(`${oe}?${a.toString()}`)}count({filters:e}){return h(this,O).getFullResponse(`${oe}/count?filters=${JSON.stringify(e)}`)}read(e){return h(this,O).patch(`${oe}/${e}/read`)}unread(e){return h(this,O).patch(`${oe}/${e}/unread`)}archive(e){return h(this,O).patch(`${oe}/${e}/archive`)}unarchive(e){return h(this,O).patch(`${oe}/${e}/unarchive`)}readAll({tags:e}){return h(this,O).post(`${oe}/read`,{tags:e})}archiveAll({tags:e}){return h(this,O).post(`${oe}/archive`,{tags:e})}archiveAllRead({tags:e}){return h(this,O).post(`${oe}/read-archive`,{tags:e})}completeAction({actionType:e,notificationId:t}){return h(this,O).patch(`${oe}/${t}/complete`,{actionType:e})}revertAction({actionType:e,notificationId:t}){return h(this,O).patch(`${oe}/${t}/revert`,{actionType:e})}fetchPreferences(){return h(this,O).get(`${ut}/preferences`)}updateGlobalPreferences(e){return h(this,O).patch(`${ut}/preferences`,e)}updateWorkflowPreferences({workflowId:e,channelPreferences:t}){return h(this,O).patch(`${ut}/preferences/${e}`,t)}};O=new WeakMap;var pt,dt=class dt{static getInstance(e){return!!e&&_(dt,pt,new Kt(e)),h(dt,pt)}};pt=new WeakMap,v(dt,pt);var ie=dt;var be,je,xe=class{constructor(){v(this,be,[]);v(this,je);this._emitter=H.getInstance(),this._inboxService=ie.getInstance(),this._emitter.on("session.initialize.resolved",({error:e,data:t})=>{t?(this.onSessionSuccess(t),h(this,be).forEach(n=>g(this,[n],function*({fn:r,resolve:s}){s(yield r())})),_(this,be,[])):e&&(this.onSessionError(e),_(this,je,e),h(this,be).forEach(({resolve:r})=>{r({error:new P("Failed to initialize session, please contact the support",e)})}),_(this,be,[]))})}onSessionSuccess(e){}onSessionError(e){}callWithSession(e){return g(this,null,function*(){return this._inboxService.isSessionInitialized?e():h(this,je)?Promise.resolve({error:new P("Failed to initialize session, please contact the support",h(this,je))}):new Promise((t,r)=>g(this,null,function*(){h(this,be).push({fn:e,resolve:t,reject:r})}))})}};be=new WeakMap,je=new WeakMap;var K,re,W=class{constructor(e){v(this,K);v(this,re);_(this,K,H.getInstance()),_(this,re,ie.getInstance()),this.id=e.id,this.subject=e.subject,this.body=e.body,this.to=e.to,this.isRead=e.isRead,this.isArchived=e.isArchived,this.createdAt=e.createdAt,this.readAt=e.readAt,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}read(){return Yt({emitter:h(this,K),apiService:h(this,re),args:{notification:this}})}unread(){return Xt({emitter:h(this,K),apiService:h(this,re),args:{notification:this}})}archive(){return Jt({emitter:h(this,K),apiService:h(this,re),args:{notification:this}})}unarchive(){return Qt({emitter:h(this,K),apiService:h(this,re),args:{notification:this}})}completePrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return He({emitter:h(this,K),apiService:h(this,re),args:{notification:this},actionType:"primary"})}completeSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return He({emitter:h(this,K),apiService:h(this,re),args:{notification:this},actionType:"secondary"})}revertPrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return Ge({emitter:h(this,K),apiService:h(this,re),args:{notification:this},actionType:"primary"})}revertSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return Ge({emitter:h(this,K),apiService:h(this,re),args:{notification:this},actionType:"secondary"})}on(e,t){h(this,K).on(e,t)}off(e,t){h(this,K).off(e,t)}};K=new WeakMap,re=new WeakMap;var Yt=r=>g(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:s,optimisticValue:n}=ze(t,{isRead:!0,readAt:new Date().toISOString(),isArchived:!1,archivedAt:void 0});try{i.emit("notification.read.pending",{args:t,data:n});let o=yield e.read(s),a=new W(o);return i.emit("notification.read.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.read.resolved",{args:t,error:o}),{error:new P("Failed to read notification",o)}}}),Xt=r=>g(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:s,optimisticValue:n}=ze(t,{isRead:!1,readAt:null,isArchived:!1,archivedAt:void 0});try{i.emit("notification.unread.pending",{args:t,data:n});let o=yield e.unread(s),a=new W(o);return i.emit("notification.unread.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.unread.resolved",{args:t,error:o}),{error:new P("Failed to unread notification",o)}}}),Jt=r=>g(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:s,optimisticValue:n}=ze(t,{isArchived:!0,archivedAt:new Date().toISOString(),isRead:!0,readAt:new Date().toISOString()});try{i.emit("notification.archive.pending",{args:t,data:n});let o=yield e.archive(s),a=new W(o);return i.emit("notification.archive.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.archive.resolved",{args:t,error:o}),{error:new P("Failed to archive notification",o)}}}),Qt=r=>g(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:s,optimisticValue:n}=ze(t,{isArchived:!1,archivedAt:null,isRead:!0,readAt:new Date().toISOString()});try{i.emit("notification.unarchive.pending",{args:t,data:n});let o=yield e.unarchive(s),a=new W(o);return i.emit("notification.unarchive.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.unarchive.resolved",{args:t,error:o}),{error:new P("Failed to unarchive notification",o)}}}),He=s=>g(void 0,[s],function*({emitter:i,apiService:e,args:t,actionType:r}){var c,u;let n="notification"in t?{isCompleted:!0,label:(u=(c=t.notification.primaryAction)==null?void 0:c.label)!=null?u:""}:{isCompleted:!0,label:""},{notificationId:o,optimisticValue:a}=ze(t,r==="primary"?{primaryAction:n}:{secondaryAction:n});try{i.emit("notification.complete_action.pending",{args:t,data:a});let l=yield e.completeAction({actionType:r,notificationId:o}),f=new W(l);return i.emit("notification.complete_action.resolved",{args:t,data:f}),{data:f}}catch(l){return i.emit("notification.complete_action.resolved",{args:t,error:l}),{error:new P(`Failed to complete ${r} action on the notification`,l)}}}),Ge=s=>g(void 0,[s],function*({emitter:i,apiService:e,args:t,actionType:r}){var c,u;let n="notification"in t?{isCompleted:!1,label:(u=(c=t.notification.primaryAction)==null?void 0:c.label)!=null?u:""}:{isCompleted:!1,label:""},{notificationId:o,optimisticValue:a}=ze(t,r==="primary"?{primaryAction:n}:{secondaryAction:n});try{i.emit("notification.revert_action.pending",{args:t,data:a});let l=yield e.revertAction({actionType:r,notificationId:o}),f=new W(l);return i.emit("notification.revert_action.resolved",{args:t,data:f}),{data:f}}catch(l){return i.emit("notification.revert_action.resolved",{args:t,error:l}),{error:new P("Failed to fetch notifications",l)}}}),ze=(i,e)=>"notification"in i?{notificationId:i.notification.id,optimisticValue:new W(b(b({},i.notification),e))}:{notificationId:i.notificationId},Or=s=>g(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r}){try{let o=t.getUniqueNotifications({tags:r}).map(a=>new W(U(b({},a),{isRead:!0,readAt:new Date().toISOString(),isArchived:!1,archivedAt:void 0})));return i.emit("notifications.read_all.pending",{args:{tags:r},data:o}),yield e.readAll({tags:r}),i.emit("notifications.read_all.resolved",{args:{tags:r},data:o}),{}}catch(n){return i.emit("notifications.read_all.resolved",{args:{tags:r},error:n}),{error:new P("Failed to read all notifications",n)}}}),Ir=s=>g(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r}){try{let o=t.getUniqueNotifications({tags:r}).map(a=>new W(U(b({},a),{isRead:!0,readAt:new Date().toISOString(),isArchived:!0,archivedAt:new Date().toISOString()})));return i.emit("notifications.archive_all.pending",{args:{tags:r},data:o}),yield e.archiveAll({tags:r}),i.emit("notifications.archive_all.resolved",{args:{tags:r},data:o}),{}}catch(n){return i.emit("notifications.archive_all.resolved",{args:{tags:r},error:n}),{error:new P("Failed to archive all notifications",n)}}}),Pr=s=>g(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r}){try{let o=t.getUniqueNotifications({tags:r,read:!0}).map(a=>new W(U(b({},a),{isArchived:!0,archivedAt:new Date().toISOString()})));return i.emit("notifications.archive_all_read.pending",{args:{tags:r},data:o}),yield e.archiveAllRead({tags:r}),i.emit("notifications.archive_all_read.resolved",{args:{tags:r},data:o}),{}}catch(n){return i.emit("notifications.archive_all_read.resolved",{args:{tags:r},error:n}),{error:new P("Failed to archive all read notifications",n)}}});var ae,Zt=class{constructor(){v(this,ae);_(this,ae,new Map)}get(e){return h(this,ae).get(e)}getValues(){return Array.from(h(this,ae).values())}entries(){return Array.from(h(this,ae).entries())}keys(){return Array.from(h(this,ae).keys())}set(e,t){h(this,ae).set(e,t)}remove(e){h(this,ae).delete(e)}clear(){h(this,ae).clear()}};ae=new WeakMap;var Lr=(i,e)=>i===e?!0:!i||!e||i.length!==e.length?!1:i.every((t,r)=>t===e[r]);var ch=["seen","unseen"],hh=["read","unread"],Fi=(i,e)=>Lr(i,e)||!i&&(e==null?void 0:e.length)===0||(i==null?void 0:i.length)===0&&!e,Bi=(i,e)=>Fi(i.tags,e.tags)&&i.read==e.read&&i.archived==e.archived;var Br=({tags:i,read:e,archived:t,limit:r,offset:s,after:n})=>Object.entries({tags:i,read:e,archived:t,limit:r,offset:s,after:n}).filter(([o,a])=>a!=null&&!(Array.isArray(a)&&a.length===0)).reduce((o,[a,c])=>(o[a]=c,o),{}),Fr=({tags:i,read:e,archived:t,limit:r,offset:s,after:n})=>JSON.stringify(Br({tags:i,read:e,archived:t,limit:r,offset:s,after:n})),no=({tags:i,read:e,archived:t})=>JSON.stringify(Br({tags:i,read:e,archived:t})),mt=i=>JSON.parse(i),oo=["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"],ao=["notification.archive.pending","notification.unarchive.pending","notifications.archive_all.pending","notifications.archive_all_read.pending"],Oe,D,gt=class{constructor(){v(this,Oe);v(this,D);this.updateNotification=(e,t)=>{let r=h(this,D).get(e);if(!r)return!1;let s=r.notifications.findIndex(o=>o.id===t.id);if(s===-1)return!1;let n=[...r.notifications];return n[s]=t,h(this,D).set(e,U(b({},r),{notifications:n})),!0};this.removeNotification=(e,t)=>{let r=h(this,D).get(e);if(!r)return!1;let s=r.notifications.findIndex(o=>o.id===t.id);if(s===-1)return!1;let n=[...r.notifications];return n.splice(s,1),h(this,D).set(e,U(b({},r),{notifications:n})),!0};this.handleNotificationEvent=({remove:e}={remove:!1})=>({data:t})=>{if(!t)return;let r=Array.isArray(t)?t:[t],s=new Set;h(this,D).keys().forEach(n=>{r.forEach(o=>{let a=!1;e?a=this.removeNotification(n,o):a=this.updateNotification(n,o),a&&s.add(no(mt(n)))})}),s.forEach(n=>{let o=this.getAggregated(mt(n));h(this,Oe).emit("notifications.list.updated",{data:o})})};_(this,Oe,H.getInstance()),oo.forEach(e=>{h(this,Oe).on(e,this.handleNotificationEvent())}),ao.forEach(e=>{h(this,Oe).on(e,this.handleNotificationEvent({remove:!0}))}),_(this,D,new Zt)}has(e){return h(this,D).get(Fr(e))!==void 0}getAggregated(e){return h(this,D).keys().filter(r=>{let s=mt(r);return Bi(s,e)}).map(r=>h(this,D).get(r)).reduce((r,s)=>s?{hasMore:s.hasMore,filter:s.filter,notifications:[...r.notifications,...s.notifications]}:r,{hasMore:!1,filter:{},notifications:[]})}set(e,t){h(this,D).set(Fr(e),t)}getAll(e){if(this.has(e))return this.getAggregated({tags:e.tags,read:e.read,archived:e.archived})}getUniqueNotifications({tags:e,read:t}){let r=h(this,D).keys(),s=new Map;return r.forEach(n=>{let o=mt(n);if(Fi(e,o.tags)){let a=h(this,D).get(n);if(!a)return;a.notifications.filter(c=>typeof t=="undefined"||t===c.isRead).forEach(c=>s.set(c.id,c))}}),Array.from(s.values())}clear(e){h(this,D).keys().forEach(r=>{Bi(mt(r),e)&&h(this,D).remove(r)})}clearAll(){h(this,D).clear()}};Oe=new WeakMap,D=new WeakMap;var Ke,se,ei=class extends xe{constructor({useCache:t}){super();v(this,Ke);v(this,se);_(this,se,new gt),_(this,Ke,t)}list(){return g(this,arguments,function*(s={}){var n=s,{limit:t=10}=n,r=Rr(n,["limit"]);return this.callWithSession(()=>g(this,null,function*(){let o=b({limit:t},r);try{let a=h(this,Ke)?h(this,se).getAll(o):void 0;if(!a){let c=yield this._inboxService.fetchNotifications(b({limit:t},r));a={hasMore:c.hasMore,filter:c.filter,notifications:c.data.map(u=>new W(u))},h(this,Ke)&&(h(this,se).set(o,a),a=h(this,se).getAll(o))}return this._emitter.emit("notifications.list.resolved",{args:o,data:a}),{data:a}}catch(a){return this._emitter.emit("notifications.list.resolved",{args:o,error:a}),{error:new P("Failed to fetch notifications",a)}}}))})}count(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){let r=t&&"filters"in t?t.filters:[b({},t)];try{this._emitter.emit("notifications.count.pending",{args:t});let s=yield this._inboxService.count({filters:r}),n=t&&"filters"in t?{counts:s.data}:s.data[0];return this._emitter.emit("notifications.count.resolved",{args:t,data:n}),{data:n}}catch(s){return this._emitter.emit("notifications.count.resolved",{args:t,error:s}),{error:new P("Failed to count notifications",s)}}}))})}read(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return Yt({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unread(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return Xt({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}archive(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return Jt({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unarchive(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return Qt({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}completePrimary(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return He({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}completeSecondary(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return He({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}revertPrimary(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return Ge({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}revertSecondary(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return Ge({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}readAll(){return g(this,arguments,function*({tags:t}={}){return this.callWithSession(()=>g(this,null,function*(){return Or({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:h(this,se),tags:t})}))})}archiveAll(){return g(this,arguments,function*({tags:t}={}){return this.callWithSession(()=>g(this,null,function*(){return Ir({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:h(this,se),tags:t})}))})}archiveAllRead(){return g(this,arguments,function*({tags:t}={}){return this.callWithSession(()=>g(this,null,function*(){return Pr({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:h(this,se),tags:t})}))})}clearCache({filter:t}={}){return t?h(this,se).clear(t!=null?t:{}):h(this,se).clearAll()}};Ke=new WeakMap,se=new WeakMap;var Ie,yt,we,ti=class{constructor(e){v(this,Ie);v(this,yt);v(this,we);_(this,Ie,H.getInstance()),_(this,yt,ie.getInstance()),_(this,we,e)}initialize(){return g(this,null,function*(){try{let{applicationIdentifier:e,subscriberId:t,subscriberHash:r}=h(this,we);h(this,Ie).emit("session.initialize.pending",{args:h(this,we)});let s=yield h(this,yt).initializeSession({applicationIdentifier:e,subscriberId:t,subscriberHash:r});h(this,Ie).emit("session.initialize.resolved",{args:h(this,we),data:s})}catch(e){h(this,Ie).emit("session.initialize.resolved",{args:h(this,we),error:e})}})}};Ie=new WeakMap,yt=new WeakMap,we=new WeakMap;var vt,_t,Pe=class{constructor(e){v(this,vt);v(this,_t);_(this,vt,H.getInstance()),_(this,_t,ie.getInstance()),this.level=e.level,this.enabled=e.enabled,this.channels=e.channels,this.workflow=e.workflow}update({channelPreferences:e}){var t;return ii({emitter:h(this,vt),apiService:h(this,_t),args:{workflowId:(t=this.workflow)==null?void 0:t.id,channelPreferences:e,preference:{level:this.level,enabled:this.enabled,channels:this.channels,workflow:this.workflow}}})}};vt=new WeakMap,_t=new WeakMap;var ii=r=>g(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{workflowId:s,channelPreferences:n}=t;try{i.emit("preferences.update.pending",{args:t,data:t.preference?new Pe(U(b({},t.preference),{channels:b(b({},t.preference.channels),n)})):void 0});let o;s?o=yield e.updateWorkflowPreferences({workflowId:s,channelPreferences:n}):o=yield e.updateGlobalPreferences(n);let a=new Pe(o);return i.emit("preferences.update.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("preferences.update.resolved",{args:t,error:o}),{error:new P("Failed to fetch notifications",o)}}});var ri=class extends xe{list(){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){try{this._emitter.emit("preferences.list.pending");let t=(yield this._inboxService.fetchPreferences()).map(r=>new Pe(r));return this._emitter.emit("preferences.list.resolved",{args:void 0,data:t}),{data:t}}catch(e){throw this._emitter.emit("preferences.list.resolved",{args:void 0,error:e}),e}}))})}update(e){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return ii({emitter:this._emitter,apiService:this._inboxService,args:e})}))})}};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 Et=Object.create(null);Object.keys(ce).forEach(i=>{Et[ce[i]]=i});var St={type:"error",data:"parser error"};var bt=({type:i,data:e},t,r)=>e instanceof ArrayBuffer||ArrayBuffer.isView(e)?r(t?e:"b"+Ur(e,!0).toString("base64")):r(ce[i]+(e||"")),Ur=(i,e)=>Buffer.isBuffer(i)||i instanceof Uint8Array&&!e?i:i instanceof ArrayBuffer?Buffer.from(i):Buffer.from(i.buffer,i.byteOffset,i.byteLength),Ui;function Dr(i,e){if(i.data instanceof ArrayBuffer||ArrayBuffer.isView(i.data))return e(Ur(i.data,!1));bt(i,!0,t=>{Ui||(Ui=new TextEncoder),e(Ui.encode(t))})}var xt=(i,e)=>{if(typeof i!="string")return{type:"message",data:Mr(i,e)};let t=i.charAt(0);if(t==="b"){let r=Buffer.from(i.substring(1),"base64");return{type:"message",data:Mr(r,e)}}return Et[t]?i.length>1?{type:Et[t],data:i.substring(1)}:{type:Et[t]}:St},Mr=(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 qr="",Wr=(i,e)=>{let t=i.length,r=new Array(t),s=0;i.forEach((n,o)=>{bt(n,!1,a=>{r[o]=a,++s===t&&e(r.join(qr))})})},$r=(i,e)=>{let t=i.split(qr),r=[];for(let s=0;s<t.length;s++){let n=xt(t[s],e);if(r.push(n),n.type==="error")break}return r};function Vr(){return new TransformStream({transform(i,e){Dr(i,t=>{let r=t.length,s;if(r<126)s=new Uint8Array(1),new DataView(s.buffer).setUint8(0,r);else if(r<65536){s=new Uint8Array(3);let n=new DataView(s.buffer);n.setUint8(0,126),n.setUint16(1,r)}else{s=new Uint8Array(9);let n=new DataView(s.buffer);n.setUint8(0,127),n.setBigUint64(1,BigInt(r))}i.data&&typeof i.data!="string"&&(s[0]|=128),e.enqueue(s),e.enqueue(t)})}})}var Di;function si(i){return i.reduce((e,t)=>e+t.length,0)}function ni(i,e){if(i[0].length===e)return i.shift();let t=new Uint8Array(e),r=0;for(let s=0;s<e;s++)t[s]=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 jr(i,e){Di||(Di=new TextDecoder);let t=[],r=0,s=-1,n=!1;return new TransformStream({transform(o,a){for(t.push(o);;){if(r===0){if(si(t)<1)break;let c=ni(t,1);n=(c[0]&128)===128,s=c[0]&127,s<126?r=3:s===126?r=1:r=2}else if(r===1){if(si(t)<2)break;let c=ni(t,2);s=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),r=3}else if(r===2){if(si(t)<8)break;let c=ni(t,8),u=new DataView(c.buffer,c.byteOffset,c.length),l=u.getUint32(0);if(l>Math.pow(2,21)-1){a.enqueue(St);break}s=l*Math.pow(2,32)+u.getUint32(4),r=3}else{if(si(t)<s)break;let c=ni(t,s);a.enqueue(xt(n?c:Di.decode(c),e)),r=0}if(s===0||s>i){a.enqueue(St);break}}}})}var Mi=4;function N(i){if(i)return co(i)}function co(i){for(var e in N.prototype)i[e]=N.prototype[e];return i}N.prototype.on=N.prototype.addEventListener=function(i,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+i]=this._callbacks["$"+i]||[]).push(e),this};N.prototype.once=function(i,e){function t(){this.off(i,t),e.apply(this,arguments)}return t.fn=e,this.on(i,t),this};N.prototype.off=N.prototype.removeListener=N.prototype.removeAllListeners=N.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,s=0;s<t.length;s++)if(r=t[s],r===e||r.fn===e){t.splice(s,1);break}return t.length===0&&delete this._callbacks["$"+i],this};N.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,s=t.length;r<s;++r)t[r].apply(this,e)}return this};N.prototype.emitReserved=N.prototype.emit;N.prototype.listeners=function(i){return this._callbacks=this._callbacks||{},this._callbacks["$"+i]||[]};N.prototype.hasListeners=function(i){return!!this.listeners(i).length};var he=global;function oi(i,...e){return e.reduce((t,r)=>(i.hasOwnProperty(r)&&(t[r]=i[r]),t),{})}var ho=he.setTimeout,lo=he.clearTimeout;function me(i,e){e.useNativeTimers?(i.setTimeoutFn=ho.bind(he),i.clearTimeoutFn=lo.bind(he)):(i.setTimeoutFn=he.setTimeout.bind(he),i.clearTimeoutFn=he.clearTimeout.bind(he))}var fo=1.33;function Hr(i){return typeof i=="string"?uo(i):Math.ceil((i.byteLength||i.size)*fo)}function uo(i){let e=0,t=0;for(let r=0,s=i.length;r<s;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 ns=j(le(),1);function rs(i){let e="";for(let t in i)i.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(i[t]));return e}function ss(i){let e={},t=i.split("&");for(let r=0,s=t.length;r<s;r++){let n=t[r].split("=");e[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return e}var Do=(0,ns.default)("engine.io-client:transport"),Vi=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},ge=class extends N{constructor(e){super(),this.writable=!1,me(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new Vi(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):Do("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=xt(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=rs(e);return t.length?"?"+t:""}};var ms=j(le(),1);var hs="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),ji=64,Mo={},os=0,ui=0,as;function cs(i){let e="";do e=hs[i%ji]+e,i=Math.floor(i/ji);while(i>0);return e}function di(){let i=cs(+new Date);return i!==as?(os=0,as=i):i+"."+cs(os++)}for(;ui<ji;ui++)Mo[hs[ui]]=ui;var zi=j(us(),1),Ki=zi.default||zi;function ds(){return new Gi}function Wo(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 s=e[0].substring(t+1).trim();s.charCodeAt(0)===34&&(s=s.slice(1,-1));let n={name:r,value:s};for(let o=1;o<e.length;o++){let a=e[o].split("=");if(a.length!==2)continue;let c=a[0].trim(),u=a[1].trim();switch(c){case"Expires":n.expires=new Date(u);break;case"Max-Age":let l=new Date;l.setUTCSeconds(l.getUTCSeconds()+parseInt(u,10)),n.expires=l;break;default:}}return n}var Gi=class{constructor(){this.cookies=new Map}parseCookies(e){let t=e.getResponseHeader("set-cookie");t&&t.forEach(r=>{let s=Wo(r);s&&this.cookies.set(s.name,s)})}addCookies(e){let t=[];this.cookies.forEach((r,s)=>{var n;((n=r.expires)===null||n===void 0?void 0:n.getTime())<Date.now()?this.cookies.delete(s):t.push(`${s}=${r.value}`)}),t.length&&(e.setDisableHeaderCheck(!0),e.setRequestHeader("cookie",t.join("; ")))}};var Y=(0,ms.default)("engine.io-client:polling");function $o(){}var Vo=function(){return new Ki({xdomain:!1}).responseType!=null}(),pi=class extends ge{constructor(e){if(super(e),this.polling=!1,typeof location!="undefined"){let r=location.protocol==="https:",s=location.port;s||(s=r?"443":"80"),this.xd=typeof location!="undefined"&&e.hostname!==location.hostname||s!==e.port}let t=e&&e.forceBase64;this.supportsBinary=Vo&&!t,this.opts.withCredentials&&(this.cookieJar=ds())}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";let t=()=>{Y("paused"),this.readyState="paused",e()};if(this.polling||!this.writable){let r=0;this.polling&&(Y("we are currently polling - waiting to pause"),r++,this.once("pollComplete",function(){Y("pre-pause polling complete"),--r||t()})),this.writable||(Y("we are currently writing - waiting to pause"),r++,this.once("drain",function(){Y("pre-pause writing complete"),--r||t()}))}else t()}poll(){Y("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){Y("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)};$r(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this.poll():Y('ignoring poll - transport state "%s"',this.readyState))}doClose(){let e=()=>{Y("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(Y("transport open - closing"),e()):(Y("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,Wr(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]=di()),!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 Ce(this.uri(),e)}doWrite(e,t){let r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",(s,n)=>{this.onError("xhr post error",s,n)})}doPoll(){Y("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}},Ce=class i extends N{constructor(e,t){super(),me(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=oi(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;let r=this.xhr=new Ki(t);try{Y("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 s in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(s)&&r.setRequestHeader(s,this.opts.extraHeaders[s])}}catch(s){}if(this.method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(s){}try{r.setRequestHeader("Accept","*/*")}catch(s){}(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 s;r.readyState===3&&((s=this.opts.cookieJar)===null||s===void 0||s.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))},Y("xhr data %s",this.data),r.send(this.data)}catch(s){this.setTimeoutFn(()=>{this.onError(s)},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=$o,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()}};Ce.requestsCount=0;Ce.requests={};if(typeof document!="undefined"){if(typeof attachEvent=="function")attachEvent("onunload",ps);else if(typeof addEventListener=="function"){let i="onpagehide"in he?"pagehide":"unload";addEventListener(i,ps,!1)}}function ps(){for(let i in Ce.requests)Ce.requests.hasOwnProperty(i)&&Ce.requests[i].abort()}var Za=j(_s(),1),ec=j(rr(),1),tc=j(nr(),1),vn=j(ur(),1),ic=j(yn(),1);var _n=vn.default;var Ft=_n,wi=!1,En="nodebuffer",De=process.nextTick;var bn=j(le(),1);var rc=(0,bn.default)("engine.io-client:websocket"),Sn=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",Ci=class extends ge{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=Sn?{}:oi(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=wi&&!Sn?t?new Ft(e,t):new Ft(e):new Ft(e,t,r)}catch(s){return this.emitReserved("error",s)}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],s=t===e.length-1;bt(r,this.supportsBinary,n=>{let o={};wi||(r.options&&(o.compress=r.options.compress),this.opts.perMessageDeflate&&(typeof n=="string"?Buffer.byteLength(n):n.length)<this.opts.perMessageDeflate.threshold&&(o.compress=!1));try{wi?this.ws.send(n):this.ws.send(n,o)}catch(a){rc("websocket closed before onclose event")}s&&De(()=>{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]=di()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!Ft}};var xn=j(le(),1),Bt=(0,xn.default)("engine.io-client:webtransport"),Ni=class extends ge{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{Bt("transport closed gracefully"),this.onClose()}).catch(e=>{Bt("transport closed due to %s",e),this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{let t=jr(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),s=Vr();s.readable.pipeTo(e.writable),this.writer=s.writable.getWriter();let n=()=>{r.read().then(({done:a,value:c})=>{if(a){Bt("session is closed");return}Bt("received chunk: %o",c),this.onPacket(c),n()}).catch(a=>{Bt("an error occurred while reading: %s",a)})};n();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],s=t===e.length-1;this.writer.write(r).then(()=>{s&&De(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}};var pr={websocket:Ci,webtransport:Ni,polling:pi};var sc=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,nc=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function it(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 s=sc.exec(i||""),n={},o=14;for(;o--;)n[nc[o]]=s[o]||"";return t!=-1&&r!=-1&&(n.source=e,n.host=n.host.substring(1,n.host.length-1).replace(/;/g,":"),n.authority=n.authority.replace("[","").replace("]","").replace(/;/g,":"),n.ipv6uri=!0),n.pathNames=oc(n,n.path),n.queryKey=ac(n,n.query),n}function oc(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 ac(i,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,s,n){s&&(t[s]=n)}),t}var wn=j(le(),1);var A=(0,wn.default)("engine.io-client:socket"),Me=class i extends N{constructor(e,t={}){super(),this.binaryType=En,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=it(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=it(t.host).host),me(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=ss(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){A('creating transport "%s"',e);let t=Object.assign({},this.opts.query);t.EIO=Mi,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 A("options: %j",r),new pr[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){A("error while creating transport: %s",t),this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){A("setting transport %s",e.name),this.transport&&(A("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){A('probing transport "%s"',e);let t=this.createTransport(e),r=!1;i.priorWebsocketSuccess=!1;let s=()=>{r||(A('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(A('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;i.priorWebsocketSuccess=t.name==="websocket",A('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{r||this.readyState!=="closed"&&(A("changing transport and sending upgrade packet"),l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{A('probe transport "%s" failed',e);let m=new Error("probe error");m.transport=t.name,this.emitReserved("upgradeError",m)}}))};function n(){r||(r=!0,l(),t.close(),t=null)}let o=f=>{let m=new Error("probe error: "+f);m.transport=t.name,n(),A('probe transport "%s" failed because of error: %s',e,f),this.emitReserved("upgradeError",m)};function a(){o("transport closed")}function c(){o("socket closed")}function u(f){t&&f.name!==t.name&&(A('"%s" works - aborting "%s"',f.name,t.name),n())}let l=()=>{t.removeListener("open",s),t.removeListener("error",o),t.removeListener("close",a),this.off("close",c),this.off("upgrading",u)};t.once("open",s),t.once("error",o),t.once("close",a),this.once("close",c),this.once("upgrading",u),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||t.open()},200):t.open()}onOpen(){if(A("socket open"),this.readyState="open",i.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){A("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(A('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 A('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();A("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 s=this.writeBuffer[r].data;if(s&&(t+=Hr(s)),r>0&&t>this.maxPayload)return A("only send %d out of %d packets",r,this.writeBuffer.length),this.writeBuffer.slice(0,r);t+=2}return A("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,s){if(typeof t=="function"&&(s=t,t=void 0),typeof r=="function"&&(s=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;let n={type:e,data:t,options:r};this.emitReserved("packetCreate",n),this.writeBuffer.push(n),s&&this.once("flush",s),this.flush()}close(){let e=()=>{this.onClose("forced close"),A("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){A("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")&&(A('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,s=e.length;for(;r<s;r++)~this.transports.indexOf(e[r])&&t.push(e[r]);return t}};Me.protocol=Mi;var xf=Me.protocol;var Nn=j(le(),1),Cn=(0,Nn.default)("socket.io-client:url");function An(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)||(Cn("protocol-less url %s",i),typeof t!="undefined"?i=t.protocol+"//"+i:i="https://"+i),Cn("parse %s",i),r=it(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 n=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+n+":"+r.port+e,r.href=r.protocol+"://"+n+(t&&t.port===r.port?"":":"+r.port),r}var Sr={};Jn(Sr,{Decoder:()=>_r,Encoder:()=>vr,PacketType:()=>E,protocol:()=>Pn});var cc=typeof ArrayBuffer=="function",hc=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,kn=Object.prototype.toString,lc=typeof Blob=="function"||typeof Blob!="undefined"&&kn.call(Blob)==="[object BlobConstructor]",fc=typeof File=="function"||typeof File!="undefined"&&kn.call(File)==="[object FileConstructor]";function Dt(i){return cc&&(i instanceof ArrayBuffer||hc(i))||lc&&i instanceof Blob||fc&&i instanceof File}function Ut(i,e){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let t=0,r=i.length;t<r;t++)if(Ut(i[t]))return!0;return!1}if(Dt(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return Ut(i.toJSON(),!0);for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&Ut(i[t]))return!0;return!1}function Rn(i){let e=[],t=i.data,r=i;return r.data=mr(t,e),r.attachments=e.length,{packet:r,buffers:e}}function mr(i,e){if(!i)return i;if(Dt(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]=mr(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]=mr(i[r],e));return t}return i}function Tn(i,e){return i.data=gr(i.data,e),delete i.attachments,i}function gr(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]=gr(i[t],e);else if(typeof i=="object")for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(i[t]=gr(i[t],e));return i}var In=j(le(),1),yr=(0,In.default)("socket.io-parser"),uc=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Pn=5,E;(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"})(E||(E={}));var vr=class{constructor(e){this.replacer=e}encode(e){return yr("encoding packet %j",e),(e.type===E.EVENT||e.type===E.ACK)&&Ut(e)?this.encodeAsBinary({type:e.type===E.EVENT?E.BINARY_EVENT:E.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===E.BINARY_EVENT||e.type===E.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)),yr("encoded %j as %s",e,t),t}encodeAsBinary(e){let t=Rn(e),r=this.encodeAsString(t.packet),s=t.buffers;return s.unshift(r),s}};function On(i){return Object.prototype.toString.call(i)==="[object Object]"}var _r=class i extends N{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===E.BINARY_EVENT;r||t.type===E.BINARY_ACK?(t.type=r?E.EVENT:E.ACK,this.reconstructor=new Er(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(Dt(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(E[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===E.BINARY_EVENT||r.type===E.BINARY_ACK){let n=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);let o=e.substring(n,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");r.attachments=Number(o)}if(e.charAt(t+1)==="/"){let n=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););r.nsp=e.substring(n,t)}else r.nsp="/";let s=e.charAt(t+1);if(s!==""&&Number(s)==s){let n=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(n,t+1))}if(e.charAt(++t)){let n=this.tryParse(e.substr(t));if(i.isPayloadValid(r.type,n))r.data=n;else throw new Error("invalid payload")}return yr("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 E.CONNECT:return On(t);case E.DISCONNECT:return t===void 0;case E.CONNECT_ERROR:return typeof t=="string"||On(t);case E.EVENT:case E.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&uc.indexOf(t[0])===-1);case E.ACK:case E.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},Er=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=Tn(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function ee(i,e,t){return i.on(e,t),function(){i.off(e,t)}}var Ln=j(le(),1),B=(0,Ln.default)("socket.io-client:socket"),dc=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),rt=class extends N{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=[ee(e,"open",this.onopen.bind(this)),ee(e,"packet",this.onpacket.bind(this)),ee(e,"error",this.onerror.bind(this)),ee(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(dc.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:E.EVENT,data:t};if(r.options={},r.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let o=this.ids++;B("emitting packet with ack id %d",o);let a=t.pop();this._registerAckCallback(o,a),r.id=o}let s=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!s||!this.connected)?B("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 s=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(s===void 0){this.acks[e]=t;return}let n=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let o=0;o<this.sendBuffer.length;o++)this.sendBuffer[o].id===e&&(B("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(o,1));B("event with ack id %d has timed out after %d ms",e,s),t.call(this,new Error("operation has timed out"))},s);this.acks[e]=(...o)=>{this.io.clearTimeoutFn(n),t.apply(this,[null,...o])}}emitWithAck(e,...t){let r=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((s,n)=>{t.push((o,a)=>r?o?n(o):s(a):s(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((s,...n)=>r!==this._queue[0]?void 0:(s!==null?r.tryCount>this._opts.retries&&(B("packet [%d] is discarded after %d tries",r.id,r.tryCount),this._queue.shift(),t&&t(s)):(B("packet [%d] was successfully sent",r.id),this._queue.shift(),t&&t(null,...n)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(B("draining queue"),!this.connected||this._queue.length===0)return;let t=this._queue[0];if(t.pending&&!e){B("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,B("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(){B("transport is open - connecting"),typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:E.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){B("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 E.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 E.EVENT:case E.BINARY_EVENT:this.onevent(e);break;case E.ACK:case E.BINARY_ACK:this.onack(e);break;case E.DISCONNECT:this.ondisconnect();break;case E.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||[];B("emitting event %j",t),e.id!=null&&(B("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(...s){r||(r=!0,B("sending ack %j",s),t.packet({type:E.ACK,id:e,data:s}))}}onack(e){let t=this.acks[e.id];typeof t=="function"?(B("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):B("bad ack %s",e.id)}onconnect(e,t){B("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(){B("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&&(B("performing disconnect (%s)",this.nsp),this.packet({type:E.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 qe(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}qe.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};qe.prototype.reset=function(){this.attempts=0};qe.prototype.setMin=function(i){this.ms=i};qe.prototype.setMax=function(i){this.max=i};qe.prototype.setJitter=function(i){this.jitter=i};var Fn=j(le(),1),$=(0,Fn.default)("socket.io-client:manager"),st=class extends N{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,me(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 qe({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let s=t.parser||Sr;this.encoder=new s.Encoder,this.decoder=new s.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($("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;$("opening %s",this.uri),this.engine=new Me(this.uri,this.opts);let t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let s=ee(t,"open",function(){r.onopen(),e&&e()}),n=a=>{$("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",a),e?e(a):this.maybeReconnectOnOpen()},o=ee(t,"error",n);if(this._timeout!==!1){let a=this._timeout;$("connect attempt will timeout after %d",a);let c=this.setTimeoutFn(()=>{$("connect attempt timed out after %d",a),s(),n(new Error("timeout")),t.close()},a);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(s),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){$("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(ee(e,"ping",this.onping.bind(this)),ee(e,"data",this.ondata.bind(this)),ee(e,"error",this.onerror.bind(this)),ee(e,"close",this.onclose.bind(this)),ee(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){De(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){$("error",e),this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new rt(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){$("socket %s is still active, skipping close",r);return}this._close()}_packet(e){$("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(){$("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){$("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){$("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)$("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();$("will wait %dms before reconnect attempt",t),this._reconnecting=!0;let r=this.setTimeoutFn(()=>{e.skipReconnect||($("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(s=>{s?($("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",s)):($("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 Un=j(le(),1),Bn=(0,Un.default)("socket.io-client"),Mt={};function qt(i,e){typeof i=="object"&&(e=i,i=void 0),e=e||{};let t=An(i,e.path||"/socket.io"),r=t.source,s=t.id,n=t.path,o=Mt[s]&&n in Mt[s].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o,c;return a?(Bn("ignoring socket cache for %s",r),c=new st(r,e)):(Mt[s]||(Bn("new io instance for %s",r),Mt[s]=new st(r,e)),c=Mt[s]),t.query&&!e.query&&(e.query=t.queryKey),c.socket(t.path,e)}Object.assign(qt,{Manager:st,Socket:rt,io:qt,connect:qt});var pc="https://ws.novu.co",Dn="notifications.notification_received",Mn="notifications.unseen_count_changed",qn="notifications.unread_count_changed",mc=({_id:i,content:e,read:t,archived:r,createdAt:s,lastReadDate:n,archivedAt:o,channel:a,subscriber:c,subject:u,avatar:l,cta:f,tags:m})=>{var k,d,y,V,R,z,X,Ee,Vt,jt;let w={id:(k=c==null?void 0:c._id)!=null?k:"",firstName:c==null?void 0:c.firstName,lastName:c==null?void 0:c.lastName,avatar:c==null?void 0:c.avatar,subscriberId:(d=c==null?void 0:c.subscriberId)!=null?d:""},C=(V=(y=f.action)==null?void 0:y.buttons)==null?void 0:V.find(J=>J.type==="primary"),p=(z=(R=f.action)==null?void 0:R.buttons)==null?void 0:z.find(J=>J.type==="secondary"),S=(Ee=(X=f.action)==null?void 0:X.result)==null?void 0:Ee.type,L=(Vt=f.action)==null?void 0:Vt.status;return{id:i,subject:u,body:e,to:w,isRead:t,isArchived:r,createdAt:s,readAt:n,archivedAt:o,avatar:l,primaryAction:C&&{label:C.content,isCompleted:S==="primary"&&L==="done"},secondaryAction:p&&{label:p.content,isCompleted:S==="secondary"&&L==="done"},channelType:a,tags:m,redirect:(jt=f.data)!=null&&jt.url?{url:f.data.url}:void 0}},nt,de,pe,ot,ki,Ri,Ti,Wt,br,Ai=class extends xe{constructor({socketUrl:t}){super();v(this,Wt);v(this,nt);v(this,de);v(this,pe);v(this,ot);v(this,ki,({message:t})=>{h(this,de).emit(Dn,{result:new W(mc(t))})});v(this,Ri,({unseenCount:t})=>{h(this,de).emit(Mn,{result:t})});v(this,Ti,({unreadCount:t})=>{h(this,de).emit(qn,{result:t})});_(this,de,H.getInstance()),_(this,ot,t!=null?t:pc)}onSessionSuccess({token:t}){_(this,nt,t)}isSocketEvent(t){return t===Dn||t===Mn||t===qn}initialize(){if(h(this,nt)){Li(this,Wt,br).call(this).catch(t=>{console.error(t)});return}this.callWithSession(()=>g(this,null,function*(){return Li(this,Wt,br).call(this).catch(t=>{console.error(t)}),{}}))}};nt=new WeakMap,de=new WeakMap,pe=new WeakMap,ot=new WeakMap,ki=new WeakMap,Ri=new WeakMap,Ti=new WeakMap,Wt=new WeakSet,br=function(){return g(this,null,function*(){var r,s,n;if(h(this,pe))return;let t={socketUrl:h(this,ot)};h(this,de).emit("socket.connect.pending",{args:t}),_(this,pe,qt(h(this,ot),{reconnectionDelayMax:1e4,transports:["websocket"],query:{token:`${h(this,nt)}`}})),h(this,pe).on("connect",()=>{h(this,de).emit("socket.connect.resolved",{args:t})}),h(this,pe).on("connect_error",o=>{h(this,de).emit("socket.connect.resolved",{args:t,error:o})}),(r=h(this,pe))==null||r.on("notification_received",h(this,ki)),(s=h(this,pe))==null||s.on("unseen_count_changed",h(this,Ri)),(n=h(this,pe))==null||n.on("unread_count_changed",h(this,Ti))})};var Wn="https://api.novu.co";var at,$t,ct,Oi=class{constructor(e){v(this,at);v(this,$t);v(this,ct);var t,r;ie.getInstance({backendUrl:(t=e.backendUrl)!=null?t:Wn}),_(this,at,H.getInstance({recreate:!0})),_(this,$t,new ti({applicationIdentifier:e.applicationIdentifier,subscriberId:e.subscriberId,subscriberHash:e.subscriberHash})),h(this,$t).initialize(),this.notifications=new ei({useCache:(r=e.useCache)!=null?r:!0}),this.preferences=new ri,_(this,ct,new Ai({socketUrl:e.socketUrl}))}on(e,t){h(this,ct).isSocketEvent(e)&&h(this,ct).initialize(),h(this,at).on(e,t)}off(e,t){h(this,at).off(e,t)}};at=new WeakMap,$t=new WeakMap,ct=new WeakMap;window.Novu=Oi;})();
|
|
12
|
+
`+t)}function Ue(i,e,t,r,s){if(i.listenerCount("wsClientError")){let n=new Error(s);Error.captureStackTrace(n,Ue),i.emit("wsClientError",n,t,e)}else Ft(t,r,s)}});function Tr(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(s){s(t)}),(r=i.get("*"))&&r.slice().map(function(s){s(e,t)})}}}var ut,Re,Ve=class Ve{constructor(){v(this,Re);_(this,Re,Tr())}static getInstance(e){return e!=null&&e.recreate&&_(Ve,ut,new Ve),h(Ve,ut)}on(e,t){h(this,Re).on(e,t)}off(e,t){h(this,Re).off(e,t)}emit(e,t){h(this,Re).emit(e,t)}};ut=new WeakMap,Re=new WeakMap,v(Ve,ut);var H=Ve;var P=class extends Error{constructor(e,t){super(e),this.originalError=t}};var Te=function(i,e,t,r){function s(n){return n instanceof t?n:new t(function(o){o(n)})}return new(t||(t=Promise))(function(n,o){function a(l){try{u(r.next(l))}catch(f){o(f)}}function c(l){try{u(r.throw(l))}catch(f){o(f)}}function u(l){l.done?n(l.value):s(l.value).then(a,c)}u((r=r.apply(i,e||[])).next())})},Zn="v1",eo="https://api.novu.co",to="@novu/client",io="2.0.0-canary.0",ro=`${to}-${io}`,je=class{constructor({apiVersion:e=Zn,backendUrl:t=eo,userAgent:r=ro}={}){this.apiVersion=e,this.backendUrl=`${t}/${this.apiVersion}`,this.headers={"Content-Type":"application/json","User-Agent":r}}setAuthorizationToken(e){this.headers.Authorization=`Bearer ${e}`}disposeAuthorizationToken(){delete this.headers.Authorization}updateHeaders(e){this.headers=Object.assign(Object.assign({},this.headers),e)}getFullResponse(e,t){return Te(this,void 0,void 0,function*(){return yield(yield this.doFetch(e+this.getQueryString(t))).json()})}get(e,t){return Te(this,void 0,void 0,function*(){return(yield(yield this.doFetch(e+this.getQueryString(t))).json()).data})}post(e,t={}){return Te(this,void 0,void 0,function*(){return(yield(yield this.doFetch(e,{method:"POST",body:JSON.stringify(t)})).json()).data})}patch(e,t={}){return Te(this,void 0,void 0,function*(){return(yield(yield this.doFetch(e,{method:"PATCH",body:JSON.stringify(t)})).json()).data})}delete(e,t={}){return Te(this,void 0,void 0,function*(){return(yield(yield this.doFetch(e,{method:"DELETE",body:JSON.stringify(t)})).json()).data})}getQueryString(e){return e?"?"+new URLSearchParams(e).toString():""}doFetch(e,t={}){return Te(this,void 0,void 0,function*(){try{let r=yield fetch(this.backendUrl+e,Object.assign(Object.assign({},t),{headers:this.headers}));return yield this.checkResponseStatus(r),r}catch(r){throw r}})}checkResponseStatus(e){return Te(this,void 0,void 0,function*(){if(!e.ok){let t=yield e.json();throw new Error(`HTTP error! Status: ${e.status}, Message: ${t.message}`)}})}};var so="2024-06-26",dt="/inbox",oe=`${dt}/notifications`,O,Yt=class{constructor(e={}){this.isSessionInitialized=!1;v(this,O);_(this,O,new je(e)),h(this,O).updateHeaders({"Novu-API-Version":so})}initializeSession(s){return g(this,arguments,function*({applicationIdentifier:e,subscriberId:t,subscriberHash:r}){let n=yield h(this,O).post(`${dt}/session`,{applicationIdentifier:e,subscriberId:t,subscriberHash:r});return h(this,O).setAuthorizationToken(n.token),this.isSessionInitialized=!0,n})}fetchNotifications({after:e,archived:t,limit:r=10,offset:s,read:n,tags:o}){let a=new URLSearchParams(`limit=${r}`);return e&&a.append("after",e),s&&a.append("offset",`${s}`),o&&o.forEach(c=>a.append("tags[]",c)),n!==void 0&&a.append("read",`${n}`),t!==void 0&&a.append("archived",`${t}`),h(this,O).getFullResponse(`${oe}?${a.toString()}`)}count({filters:e}){return h(this,O).getFullResponse(`${oe}/count?filters=${JSON.stringify(e)}`)}read(e){return h(this,O).patch(`${oe}/${e}/read`)}unread(e){return h(this,O).patch(`${oe}/${e}/unread`)}archive(e){return h(this,O).patch(`${oe}/${e}/archive`)}unarchive(e){return h(this,O).patch(`${oe}/${e}/unarchive`)}readAll({tags:e}){return h(this,O).post(`${oe}/read`,{tags:e})}archiveAll({tags:e}){return h(this,O).post(`${oe}/archive`,{tags:e})}archiveAllRead({tags:e}){return h(this,O).post(`${oe}/read-archive`,{tags:e})}completeAction({actionType:e,notificationId:t}){return h(this,O).patch(`${oe}/${t}/complete`,{actionType:e})}revertAction({actionType:e,notificationId:t}){return h(this,O).patch(`${oe}/${t}/revert`,{actionType:e})}fetchPreferences(){return h(this,O).get(`${dt}/preferences`)}updateGlobalPreferences(e){return h(this,O).patch(`${dt}/preferences`,e)}updateWorkflowPreferences({workflowId:e,channelPreferences:t}){return h(this,O).patch(`${dt}/preferences/${e}`,t)}};O=new WeakMap;var mt,pt=class pt{static getInstance(e){return!!e&&_(pt,mt,new Yt(e)),h(pt,mt)}};mt=new WeakMap,v(pt,mt);var ie=pt;var Se,He,xe=class{constructor(){v(this,Se,[]);v(this,He);this._emitter=H.getInstance(),this._inboxService=ie.getInstance(),this._emitter.on("session.initialize.resolved",({error:e,data:t})=>{t?(this.onSessionSuccess(t),h(this,Se).forEach(n=>g(this,[n],function*({fn:r,resolve:s}){s(yield r())})),_(this,Se,[])):e&&(this.onSessionError(e),_(this,He,e),h(this,Se).forEach(({resolve:r})=>{r({error:new P("Failed to initialize session, please contact the support",e)})}),_(this,Se,[]))})}onSessionSuccess(e){}onSessionError(e){}callWithSession(e){return g(this,null,function*(){return this._inboxService.isSessionInitialized?e():h(this,He)?Promise.resolve({error:new P("Failed to initialize session, please contact the support",h(this,He))}):new Promise((t,r)=>g(this,null,function*(){h(this,Se).push({fn:e,resolve:t,reject:r})}))})}};Se=new WeakMap,He=new WeakMap;var K,re,W=class{constructor(e){v(this,K);v(this,re);_(this,K,H.getInstance()),_(this,re,ie.getInstance()),this.id=e.id,this.subject=e.subject,this.body=e.body,this.to=e.to,this.isRead=e.isRead,this.isArchived=e.isArchived,this.createdAt=e.createdAt,this.readAt=e.readAt,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}read(){return Xt({emitter:h(this,K),apiService:h(this,re),args:{notification:this}})}unread(){return Jt({emitter:h(this,K),apiService:h(this,re),args:{notification:this}})}archive(){return Qt({emitter:h(this,K),apiService:h(this,re),args:{notification:this}})}unarchive(){return Zt({emitter:h(this,K),apiService:h(this,re),args:{notification:this}})}completePrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return Ge({emitter:h(this,K),apiService:h(this,re),args:{notification:this},actionType:"primary"})}completeSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return Ge({emitter:h(this,K),apiService:h(this,re),args:{notification:this},actionType:"secondary"})}revertPrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return ze({emitter:h(this,K),apiService:h(this,re),args:{notification:this},actionType:"primary"})}revertSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return ze({emitter:h(this,K),apiService:h(this,re),args:{notification:this},actionType:"secondary"})}on(e,t){h(this,K).on(e,t)}off(e,t){h(this,K).off(e,t)}};K=new WeakMap,re=new WeakMap;var Xt=r=>g(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:s,optimisticValue:n}=Ke(t,{isRead:!0,readAt:new Date().toISOString(),isArchived:!1,archivedAt:void 0});try{i.emit("notification.read.pending",{args:t,data:n});let o=yield e.read(s),a=new W(o);return i.emit("notification.read.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.read.resolved",{args:t,error:o}),{error:new P("Failed to read notification",o)}}}),Jt=r=>g(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:s,optimisticValue:n}=Ke(t,{isRead:!1,readAt:null,isArchived:!1,archivedAt:void 0});try{i.emit("notification.unread.pending",{args:t,data:n});let o=yield e.unread(s),a=new W(o);return i.emit("notification.unread.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.unread.resolved",{args:t,error:o}),{error:new P("Failed to unread notification",o)}}}),Qt=r=>g(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:s,optimisticValue:n}=Ke(t,{isArchived:!0,archivedAt:new Date().toISOString(),isRead:!0,readAt:new Date().toISOString()});try{i.emit("notification.archive.pending",{args:t,data:n});let o=yield e.archive(s),a=new W(o);return i.emit("notification.archive.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.archive.resolved",{args:t,error:o}),{error:new P("Failed to archive notification",o)}}}),Zt=r=>g(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:s,optimisticValue:n}=Ke(t,{isArchived:!1,archivedAt:null,isRead:!0,readAt:new Date().toISOString()});try{i.emit("notification.unarchive.pending",{args:t,data:n});let o=yield e.unarchive(s),a=new W(o);return i.emit("notification.unarchive.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.unarchive.resolved",{args:t,error:o}),{error:new P("Failed to unarchive notification",o)}}}),Ge=s=>g(void 0,[s],function*({emitter:i,apiService:e,args:t,actionType:r}){var c,u;let n="notification"in t?{isCompleted:!0,label:(u=(c=t.notification.primaryAction)==null?void 0:c.label)!=null?u:""}:{isCompleted:!0,label:""},{notificationId:o,optimisticValue:a}=Ke(t,r==="primary"?{primaryAction:n}:{secondaryAction:n});try{i.emit("notification.complete_action.pending",{args:t,data:a});let l=yield e.completeAction({actionType:r,notificationId:o}),f=new W(l);return i.emit("notification.complete_action.resolved",{args:t,data:f}),{data:f}}catch(l){return i.emit("notification.complete_action.resolved",{args:t,error:l}),{error:new P(`Failed to complete ${r} action on the notification`,l)}}}),ze=s=>g(void 0,[s],function*({emitter:i,apiService:e,args:t,actionType:r}){var c,u;let n="notification"in t?{isCompleted:!1,label:(u=(c=t.notification.primaryAction)==null?void 0:c.label)!=null?u:""}:{isCompleted:!1,label:""},{notificationId:o,optimisticValue:a}=Ke(t,r==="primary"?{primaryAction:n}:{secondaryAction:n});try{i.emit("notification.revert_action.pending",{args:t,data:a});let l=yield e.revertAction({actionType:r,notificationId:o}),f=new W(l);return i.emit("notification.revert_action.resolved",{args:t,data:f}),{data:f}}catch(l){return i.emit("notification.revert_action.resolved",{args:t,error:l}),{error:new P("Failed to fetch notifications",l)}}}),Ke=(i,e)=>"notification"in i?{notificationId:i.notification.id,optimisticValue:new W(S(S({},i.notification),e))}:{notificationId:i.notificationId},Or=s=>g(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r}){try{let o=t.getUniqueNotifications({tags:r}).map(a=>new W(U(S({},a),{isRead:!0,readAt:new Date().toISOString(),isArchived:!1,archivedAt:void 0})));return i.emit("notifications.read_all.pending",{args:{tags:r},data:o}),yield e.readAll({tags:r}),i.emit("notifications.read_all.resolved",{args:{tags:r},data:o}),{}}catch(n){return i.emit("notifications.read_all.resolved",{args:{tags:r},error:n}),{error:new P("Failed to read all notifications",n)}}}),Ir=s=>g(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r}){try{let o=t.getUniqueNotifications({tags:r}).map(a=>new W(U(S({},a),{isRead:!0,readAt:new Date().toISOString(),isArchived:!0,archivedAt:new Date().toISOString()})));return i.emit("notifications.archive_all.pending",{args:{tags:r},data:o}),yield e.archiveAll({tags:r}),i.emit("notifications.archive_all.resolved",{args:{tags:r},data:o}),{}}catch(n){return i.emit("notifications.archive_all.resolved",{args:{tags:r},error:n}),{error:new P("Failed to archive all notifications",n)}}}),Pr=s=>g(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r}){try{let o=t.getUniqueNotifications({tags:r,read:!0}).map(a=>new W(U(S({},a),{isArchived:!0,archivedAt:new Date().toISOString()})));return i.emit("notifications.archive_all_read.pending",{args:{tags:r},data:o}),yield e.archiveAllRead({tags:r}),i.emit("notifications.archive_all_read.resolved",{args:{tags:r},data:o}),{}}catch(n){return i.emit("notifications.archive_all_read.resolved",{args:{tags:r},error:n}),{error:new P("Failed to archive all read notifications",n)}}});var ae,ei=class{constructor(){v(this,ae);_(this,ae,new Map)}get(e){return h(this,ae).get(e)}getValues(){return Array.from(h(this,ae).values())}entries(){return Array.from(h(this,ae).entries())}keys(){return Array.from(h(this,ae).keys())}set(e,t){h(this,ae).set(e,t)}remove(e){h(this,ae).delete(e)}clear(){h(this,ae).clear()}};ae=new WeakMap;var Lr=(i,e)=>i===e?!0:!i||!e||i.length!==e.length?!1:i.every((t,r)=>t===e[r]);var ch=["seen","unseen"],hh=["read","unread"],Bi=(i,e)=>Lr(i,e)||!i&&(e==null?void 0:e.length)===0||(i==null?void 0:i.length)===0&&!e,Ui=(i,e)=>Bi(i.tags,e.tags)&&i.read==e.read&&i.archived==e.archived;var Br=({tags:i,read:e,archived:t,limit:r,offset:s,after:n})=>Object.entries({tags:i,read:e,archived:t,limit:r,offset:s,after:n}).filter(([o,a])=>a!=null&&!(Array.isArray(a)&&a.length===0)).reduce((o,[a,c])=>(o[a]=c,o),{}),Fr=({tags:i,read:e,archived:t,limit:r,offset:s,after:n})=>JSON.stringify(Br({tags:i,read:e,archived:t,limit:r,offset:s,after:n})),no=({tags:i,read:e,archived:t})=>JSON.stringify(Br({tags:i,read:e,archived:t})),gt=i=>JSON.parse(i),oo=["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"],ao=["notification.archive.pending","notification.unarchive.pending","notifications.archive_all.pending","notifications.archive_all_read.pending"],Oe,D,yt=class{constructor(){v(this,Oe);v(this,D);this.updateNotification=(e,t)=>{let r=h(this,D).get(e);if(!r)return!1;let s=r.notifications.findIndex(o=>o.id===t.id);if(s===-1)return!1;let n=[...r.notifications];return n[s]=t,h(this,D).set(e,U(S({},r),{notifications:n})),!0};this.removeNotification=(e,t)=>{let r=h(this,D).get(e);if(!r)return!1;let s=r.notifications.findIndex(o=>o.id===t.id);if(s===-1)return!1;let n=[...r.notifications];return n.splice(s,1),h(this,D).set(e,U(S({},r),{notifications:n})),!0};this.handleNotificationEvent=({remove:e}={remove:!1})=>({data:t})=>{if(!t)return;let r=Array.isArray(t)?t:[t],s=new Set;h(this,D).keys().forEach(n=>{r.forEach(o=>{let a=!1;e?a=this.removeNotification(n,o):a=this.updateNotification(n,o),a&&s.add(no(gt(n)))})}),s.forEach(n=>{let o=this.getAggregated(gt(n));h(this,Oe).emit("notifications.list.updated",{data:o})})};_(this,Oe,H.getInstance()),oo.forEach(e=>{h(this,Oe).on(e,this.handleNotificationEvent())}),ao.forEach(e=>{h(this,Oe).on(e,this.handleNotificationEvent({remove:!0}))}),_(this,D,new ei)}has(e){return h(this,D).get(Fr(e))!==void 0}getAggregated(e){return h(this,D).keys().filter(r=>{let s=gt(r);return Ui(s,e)}).map(r=>h(this,D).get(r)).reduce((r,s)=>s?{hasMore:s.hasMore,filter:s.filter,notifications:[...r.notifications,...s.notifications]}:r,{hasMore:!1,filter:{},notifications:[]})}set(e,t){h(this,D).set(Fr(e),t)}getAll(e){if(this.has(e))return this.getAggregated({tags:e.tags,read:e.read,archived:e.archived})}getUniqueNotifications({tags:e,read:t}){let r=h(this,D).keys(),s=new Map;return r.forEach(n=>{let o=gt(n);if(Bi(e,o.tags)){let a=h(this,D).get(n);if(!a)return;a.notifications.filter(c=>typeof t=="undefined"||t===c.isRead).forEach(c=>s.set(c.id,c))}}),Array.from(s.values())}clear(e){h(this,D).keys().forEach(r=>{Ui(gt(r),e)&&h(this,D).remove(r)})}clearAll(){h(this,D).clear()}};Oe=new WeakMap,D=new WeakMap;var Ye,se,ti=class extends xe{constructor({useCache:t}){super();v(this,Ye);v(this,se);_(this,se,new yt),_(this,Ye,t)}list(){return g(this,arguments,function*(s={}){var n=s,{limit:t=10}=n,r=Rr(n,["limit"]);return this.callWithSession(()=>g(this,null,function*(){let o=S({limit:t},r);try{let a=h(this,Ye)?h(this,se).getAll(o):void 0;if(!a){let c=yield this._inboxService.fetchNotifications(S({limit:t},r));a={hasMore:c.hasMore,filter:c.filter,notifications:c.data.map(u=>new W(u))},h(this,Ye)&&(h(this,se).set(o,a),a=h(this,se).getAll(o))}return this._emitter.emit("notifications.list.resolved",{args:o,data:a}),{data:a}}catch(a){return this._emitter.emit("notifications.list.resolved",{args:o,error:a}),{error:new P("Failed to fetch notifications",a)}}}))})}count(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){let r=t&&"filters"in t?t.filters:[S({},t)];try{this._emitter.emit("notifications.count.pending",{args:t});let s=yield this._inboxService.count({filters:r}),n=t&&"filters"in t?{counts:s.data}:s.data[0];return this._emitter.emit("notifications.count.resolved",{args:t,data:n}),{data:n}}catch(s){return this._emitter.emit("notifications.count.resolved",{args:t,error:s}),{error:new P("Failed to count notifications",s)}}}))})}read(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return Xt({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unread(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return Jt({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}archive(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return Qt({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unarchive(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return Zt({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}completePrimary(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return Ge({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}completeSecondary(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return Ge({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}revertPrimary(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return ze({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}revertSecondary(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return ze({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}readAll(){return g(this,arguments,function*({tags:t}={}){return this.callWithSession(()=>g(this,null,function*(){return Or({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:h(this,se),tags:t})}))})}archiveAll(){return g(this,arguments,function*({tags:t}={}){return this.callWithSession(()=>g(this,null,function*(){return Ir({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:h(this,se),tags:t})}))})}archiveAllRead(){return g(this,arguments,function*({tags:t}={}){return this.callWithSession(()=>g(this,null,function*(){return Pr({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:h(this,se),tags:t})}))})}clearCache({filter:t}={}){return t?h(this,se).clear(t!=null?t:{}):h(this,se).clearAll()}};Ye=new WeakMap,se=new WeakMap;var Ie,vt,we,ii=class{constructor(e){v(this,Ie);v(this,vt);v(this,we);_(this,Ie,H.getInstance()),_(this,vt,ie.getInstance()),_(this,we,e)}initialize(){return g(this,null,function*(){try{let{applicationIdentifier:e,subscriberId:t,subscriberHash:r}=h(this,we);h(this,Ie).emit("session.initialize.pending",{args:h(this,we)});let s=yield h(this,vt).initializeSession({applicationIdentifier:e,subscriberId:t,subscriberHash:r});h(this,Ie).emit("session.initialize.resolved",{args:h(this,we),data:s})}catch(e){h(this,Ie).emit("session.initialize.resolved",{args:h(this,we),error:e})}})}};Ie=new WeakMap,vt=new WeakMap,we=new WeakMap;var _t,Et,Pe=class{constructor(e){v(this,_t);v(this,Et);_(this,_t,H.getInstance()),_(this,Et,ie.getInstance()),this.level=e.level,this.enabled=e.enabled,this.channels=e.channels,this.workflow=e.workflow}update({channelPreferences:e}){var t;return ri({emitter:h(this,_t),apiService:h(this,Et),args:{workflowId:(t=this.workflow)==null?void 0:t.id,channelPreferences:e,preference:{level:this.level,enabled:this.enabled,channels:this.channels,workflow:this.workflow}}})}};_t=new WeakMap,Et=new WeakMap;var ri=r=>g(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{workflowId:s,channelPreferences:n}=t;try{i.emit("preferences.update.pending",{args:t,data:t.preference?new Pe(U(S({},t.preference),{channels:S(S({},t.preference.channels),n)})):void 0});let o;s?o=yield e.updateWorkflowPreferences({workflowId:s,channelPreferences:n}):o=yield e.updateGlobalPreferences(n);let a=new Pe(o);return i.emit("preferences.update.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("preferences.update.resolved",{args:t,error:o}),{error:new P("Failed to fetch notifications",o)}}});var si=class extends xe{list(){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){try{this._emitter.emit("preferences.list.pending");let t=(yield this._inboxService.fetchPreferences()).map(r=>new Pe(r));return this._emitter.emit("preferences.list.resolved",{args:void 0,data:t}),{data:t}}catch(e){throw this._emitter.emit("preferences.list.resolved",{args:void 0,error:e}),e}}))})}update(e){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return ri({emitter:this._emitter,apiService:this._inboxService,args:e})}))})}};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 bt=Object.create(null);Object.keys(ce).forEach(i=>{bt[ce[i]]=i});var St={type:"error",data:"parser error"};var xt=({type:i,data:e},t,r)=>e instanceof ArrayBuffer||ArrayBuffer.isView(e)?r(t?e:"b"+Ur(e,!0).toString("base64")):r(ce[i]+(e||"")),Ur=(i,e)=>Buffer.isBuffer(i)||i instanceof Uint8Array&&!e?i:i instanceof ArrayBuffer?Buffer.from(i):Buffer.from(i.buffer,i.byteOffset,i.byteLength),Di;function Dr(i,e){if(i.data instanceof ArrayBuffer||ArrayBuffer.isView(i.data))return e(Ur(i.data,!1));xt(i,!0,t=>{Di||(Di=new TextEncoder),e(Di.encode(t))})}var wt=(i,e)=>{if(typeof i!="string")return{type:"message",data:Mr(i,e)};let t=i.charAt(0);if(t==="b"){let r=Buffer.from(i.substring(1),"base64");return{type:"message",data:Mr(r,e)}}return bt[t]?i.length>1?{type:bt[t],data:i.substring(1)}:{type:bt[t]}:St},Mr=(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 qr="",Wr=(i,e)=>{let t=i.length,r=new Array(t),s=0;i.forEach((n,o)=>{xt(n,!1,a=>{r[o]=a,++s===t&&e(r.join(qr))})})},$r=(i,e)=>{let t=i.split(qr),r=[];for(let s=0;s<t.length;s++){let n=wt(t[s],e);if(r.push(n),n.type==="error")break}return r};function Vr(){return new TransformStream({transform(i,e){Dr(i,t=>{let r=t.length,s;if(r<126)s=new Uint8Array(1),new DataView(s.buffer).setUint8(0,r);else if(r<65536){s=new Uint8Array(3);let n=new DataView(s.buffer);n.setUint8(0,126),n.setUint16(1,r)}else{s=new Uint8Array(9);let n=new DataView(s.buffer);n.setUint8(0,127),n.setBigUint64(1,BigInt(r))}i.data&&typeof i.data!="string"&&(s[0]|=128),e.enqueue(s),e.enqueue(t)})}})}var Mi;function ni(i){return i.reduce((e,t)=>e+t.length,0)}function oi(i,e){if(i[0].length===e)return i.shift();let t=new Uint8Array(e),r=0;for(let s=0;s<e;s++)t[s]=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 jr(i,e){Mi||(Mi=new TextDecoder);let t=[],r=0,s=-1,n=!1;return new TransformStream({transform(o,a){for(t.push(o);;){if(r===0){if(ni(t)<1)break;let c=oi(t,1);n=(c[0]&128)===128,s=c[0]&127,s<126?r=3:s===126?r=1:r=2}else if(r===1){if(ni(t)<2)break;let c=oi(t,2);s=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),r=3}else if(r===2){if(ni(t)<8)break;let c=oi(t,8),u=new DataView(c.buffer,c.byteOffset,c.length),l=u.getUint32(0);if(l>Math.pow(2,21)-1){a.enqueue(St);break}s=l*Math.pow(2,32)+u.getUint32(4),r=3}else{if(ni(t)<s)break;let c=oi(t,s);a.enqueue(wt(n?c:Mi.decode(c),e)),r=0}if(s===0||s>i){a.enqueue(St);break}}}})}var qi=4;function N(i){if(i)return co(i)}function co(i){for(var e in N.prototype)i[e]=N.prototype[e];return i}N.prototype.on=N.prototype.addEventListener=function(i,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+i]=this._callbacks["$"+i]||[]).push(e),this};N.prototype.once=function(i,e){function t(){this.off(i,t),e.apply(this,arguments)}return t.fn=e,this.on(i,t),this};N.prototype.off=N.prototype.removeListener=N.prototype.removeAllListeners=N.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,s=0;s<t.length;s++)if(r=t[s],r===e||r.fn===e){t.splice(s,1);break}return t.length===0&&delete this._callbacks["$"+i],this};N.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,s=t.length;r<s;++r)t[r].apply(this,e)}return this};N.prototype.emitReserved=N.prototype.emit;N.prototype.listeners=function(i){return this._callbacks=this._callbacks||{},this._callbacks["$"+i]||[]};N.prototype.hasListeners=function(i){return!!this.listeners(i).length};var he=global;function ai(i,...e){return e.reduce((t,r)=>(i.hasOwnProperty(r)&&(t[r]=i[r]),t),{})}var ho=he.setTimeout,lo=he.clearTimeout;function me(i,e){e.useNativeTimers?(i.setTimeoutFn=ho.bind(he),i.clearTimeoutFn=lo.bind(he)):(i.setTimeoutFn=he.setTimeout.bind(he),i.clearTimeoutFn=he.clearTimeout.bind(he))}var fo=1.33;function Hr(i){return typeof i=="string"?uo(i):Math.ceil((i.byteLength||i.size)*fo)}function uo(i){let e=0,t=0;for(let r=0,s=i.length;r<s;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 ns=j(le(),1);function rs(i){let e="";for(let t in i)i.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(i[t]));return e}function ss(i){let e={},t=i.split("&");for(let r=0,s=t.length;r<s;r++){let n=t[r].split("=");e[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return e}var Do=(0,ns.default)("engine.io-client:transport"),ji=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},ge=class extends N{constructor(e){super(),this.writable=!1,me(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new ji(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):Do("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=wt(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){let t=rs(e);return t.length?"?"+t:""}};var ms=j(le(),1);var hs="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Hi=64,Mo={},os=0,di=0,as;function cs(i){let e="";do e=hs[i%Hi]+e,i=Math.floor(i/Hi);while(i>0);return e}function pi(){let i=cs(+new Date);return i!==as?(os=0,as=i):i+"."+cs(os++)}for(;di<Hi;di++)Mo[hs[di]]=di;var Ki=j(us(),1),Yi=Ki.default||Ki;function ds(){return new zi}function Wo(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 s=e[0].substring(t+1).trim();s.charCodeAt(0)===34&&(s=s.slice(1,-1));let n={name:r,value:s};for(let o=1;o<e.length;o++){let a=e[o].split("=");if(a.length!==2)continue;let c=a[0].trim(),u=a[1].trim();switch(c){case"Expires":n.expires=new Date(u);break;case"Max-Age":let l=new Date;l.setUTCSeconds(l.getUTCSeconds()+parseInt(u,10)),n.expires=l;break;default:}}return n}var zi=class{constructor(){this.cookies=new Map}parseCookies(e){let t=e.getResponseHeader("set-cookie");t&&t.forEach(r=>{let s=Wo(r);s&&this.cookies.set(s.name,s)})}addCookies(e){let t=[];this.cookies.forEach((r,s)=>{var n;((n=r.expires)===null||n===void 0?void 0:n.getTime())<Date.now()?this.cookies.delete(s):t.push(`${s}=${r.value}`)}),t.length&&(e.setDisableHeaderCheck(!0),e.setRequestHeader("cookie",t.join("; ")))}};var Y=(0,ms.default)("engine.io-client:polling");function $o(){}var Vo=function(){return new Yi({xdomain:!1}).responseType!=null}(),mi=class extends ge{constructor(e){if(super(e),this.polling=!1,typeof location!="undefined"){let r=location.protocol==="https:",s=location.port;s||(s=r?"443":"80"),this.xd=typeof location!="undefined"&&e.hostname!==location.hostname||s!==e.port}let t=e&&e.forceBase64;this.supportsBinary=Vo&&!t,this.opts.withCredentials&&(this.cookieJar=ds())}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";let t=()=>{Y("paused"),this.readyState="paused",e()};if(this.polling||!this.writable){let r=0;this.polling&&(Y("we are currently polling - waiting to pause"),r++,this.once("pollComplete",function(){Y("pre-pause polling complete"),--r||t()})),this.writable||(Y("we are currently writing - waiting to pause"),r++,this.once("drain",function(){Y("pre-pause writing complete"),--r||t()}))}else t()}poll(){Y("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){Y("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)};$r(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this.poll():Y('ignoring poll - transport state "%s"',this.readyState))}doClose(){let e=()=>{Y("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(Y("transport open - closing"),e()):(Y("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,Wr(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]=pi()),!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 Ce(this.uri(),e)}doWrite(e,t){let r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",(s,n)=>{this.onError("xhr post error",s,n)})}doPoll(){Y("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}},Ce=class i extends N{constructor(e,t){super(),me(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=ai(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;let r=this.xhr=new Yi(t);try{Y("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 s in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(s)&&r.setRequestHeader(s,this.opts.extraHeaders[s])}}catch(s){}if(this.method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(s){}try{r.setRequestHeader("Accept","*/*")}catch(s){}(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 s;r.readyState===3&&((s=this.opts.cookieJar)===null||s===void 0||s.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))},Y("xhr data %s",this.data),r.send(this.data)}catch(s){this.setTimeoutFn(()=>{this.onError(s)},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=$o,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()}};Ce.requestsCount=0;Ce.requests={};if(typeof document!="undefined"){if(typeof attachEvent=="function")attachEvent("onunload",ps);else if(typeof addEventListener=="function"){let i="onpagehide"in he?"pagehide":"unload";addEventListener(i,ps,!1)}}function ps(){for(let i in Ce.requests)Ce.requests.hasOwnProperty(i)&&Ce.requests[i].abort()}var Za=j(_s(),1),ec=j(sr(),1),tc=j(or(),1),vn=j(dr(),1),ic=j(yn(),1);var _n=vn.default;var Bt=_n,Ci=!1,En="nodebuffer",De=process.nextTick;var Sn=j(le(),1);var rc=(0,Sn.default)("engine.io-client:websocket"),bn=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",Ni=class extends ge{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=bn?{}:ai(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=Ci&&!bn?t?new Bt(e,t):new Bt(e):new Bt(e,t,r)}catch(s){return this.emitReserved("error",s)}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],s=t===e.length-1;xt(r,this.supportsBinary,n=>{let o={};Ci||(r.options&&(o.compress=r.options.compress),this.opts.perMessageDeflate&&(typeof n=="string"?Buffer.byteLength(n):n.length)<this.opts.perMessageDeflate.threshold&&(o.compress=!1));try{Ci?this.ws.send(n):this.ws.send(n,o)}catch(a){rc("websocket closed before onclose event")}s&&De(()=>{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]=pi()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!Bt}};var xn=j(le(),1),Ut=(0,xn.default)("engine.io-client:webtransport"),Ai=class extends ge{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{Ut("transport closed gracefully"),this.onClose()}).catch(e=>{Ut("transport closed due to %s",e),this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{let t=jr(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),s=Vr();s.readable.pipeTo(e.writable),this.writer=s.writable.getWriter();let n=()=>{r.read().then(({done:a,value:c})=>{if(a){Ut("session is closed");return}Ut("received chunk: %o",c),this.onPacket(c),n()}).catch(a=>{Ut("an error occurred while reading: %s",a)})};n();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],s=t===e.length-1;this.writer.write(r).then(()=>{s&&De(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}};var mr={websocket:Ni,webtransport:Ai,polling:mi};var sc=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,nc=["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 s=sc.exec(i||""),n={},o=14;for(;o--;)n[nc[o]]=s[o]||"";return t!=-1&&r!=-1&&(n.source=e,n.host=n.host.substring(1,n.host.length-1).replace(/;/g,":"),n.authority=n.authority.replace("[","").replace("]","").replace(/;/g,":"),n.ipv6uri=!0),n.pathNames=oc(n,n.path),n.queryKey=ac(n,n.query),n}function oc(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 ac(i,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,s,n){s&&(t[s]=n)}),t}var wn=j(le(),1);var A=(0,wn.default)("engine.io-client:socket"),Me=class i extends N{constructor(e,t={}){super(),this.binaryType=En,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),me(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=ss(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){A('creating transport "%s"',e);let t=Object.assign({},this.opts.query);t.EIO=qi,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 A("options: %j",r),new mr[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){A("error while creating transport: %s",t),this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){A("setting transport %s",e.name),this.transport&&(A("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){A('probing transport "%s"',e);let t=this.createTransport(e),r=!1;i.priorWebsocketSuccess=!1;let s=()=>{r||(A('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(A('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;i.priorWebsocketSuccess=t.name==="websocket",A('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{r||this.readyState!=="closed"&&(A("changing transport and sending upgrade packet"),l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{A('probe transport "%s" failed',e);let m=new Error("probe error");m.transport=t.name,this.emitReserved("upgradeError",m)}}))};function n(){r||(r=!0,l(),t.close(),t=null)}let o=f=>{let m=new Error("probe error: "+f);m.transport=t.name,n(),A('probe transport "%s" failed because of error: %s',e,f),this.emitReserved("upgradeError",m)};function a(){o("transport closed")}function c(){o("socket closed")}function u(f){t&&f.name!==t.name&&(A('"%s" works - aborting "%s"',f.name,t.name),n())}let l=()=>{t.removeListener("open",s),t.removeListener("error",o),t.removeListener("close",a),this.off("close",c),this.off("upgrading",u)};t.once("open",s),t.once("error",o),t.once("close",a),this.once("close",c),this.once("upgrading",u),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||t.open()},200):t.open()}onOpen(){if(A("socket open"),this.readyState="open",i.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){A("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(A('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 A('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();A("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 s=this.writeBuffer[r].data;if(s&&(t+=Hr(s)),r>0&&t>this.maxPayload)return A("only send %d out of %d packets",r,this.writeBuffer.length),this.writeBuffer.slice(0,r);t+=2}return A("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,s){if(typeof t=="function"&&(s=t,t=void 0),typeof r=="function"&&(s=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;let n={type:e,data:t,options:r};this.emitReserved("packetCreate",n),this.writeBuffer.push(n),s&&this.once("flush",s),this.flush()}close(){let e=()=>{this.onClose("forced close"),A("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){A("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")&&(A('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,s=e.length;for(;r<s;r++)~this.transports.indexOf(e[r])&&t.push(e[r]);return t}};Me.protocol=qi;var xf=Me.protocol;var Nn=j(le(),1),Cn=(0,Nn.default)("socket.io-client:url");function An(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)||(Cn("protocol-less url %s",i),typeof t!="undefined"?i=t.protocol+"//"+i:i="https://"+i),Cn("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 n=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+n+":"+r.port+e,r.href=r.protocol+"://"+n+(t&&t.port===r.port?"":":"+r.port),r}var Sr={};Jn(Sr,{Decoder:()=>Er,Encoder:()=>_r,PacketType:()=>E,protocol:()=>Pn});var cc=typeof ArrayBuffer=="function",hc=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,kn=Object.prototype.toString,lc=typeof Blob=="function"||typeof Blob!="undefined"&&kn.call(Blob)==="[object BlobConstructor]",fc=typeof File=="function"||typeof File!="undefined"&&kn.call(File)==="[object FileConstructor]";function Mt(i){return cc&&(i instanceof ArrayBuffer||hc(i))||lc&&i instanceof Blob||fc&&i instanceof File}function Dt(i,e){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let t=0,r=i.length;t<r;t++)if(Dt(i[t]))return!0;return!1}if(Mt(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return Dt(i.toJSON(),!0);for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&Dt(i[t]))return!0;return!1}function Rn(i){let e=[],t=i.data,r=i;return r.data=gr(t,e),r.attachments=e.length,{packet:r,buffers:e}}function gr(i,e){if(!i)return i;if(Mt(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]=gr(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]=gr(i[r],e));return t}return i}function Tn(i,e){return i.data=yr(i.data,e),delete i.attachments,i}function yr(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]=yr(i[t],e);else if(typeof i=="object")for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(i[t]=yr(i[t],e));return i}var In=j(le(),1),vr=(0,In.default)("socket.io-parser"),uc=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Pn=5,E;(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"})(E||(E={}));var _r=class{constructor(e){this.replacer=e}encode(e){return vr("encoding packet %j",e),(e.type===E.EVENT||e.type===E.ACK)&&Dt(e)?this.encodeAsBinary({type:e.type===E.EVENT?E.BINARY_EVENT:E.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===E.BINARY_EVENT||e.type===E.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)),vr("encoded %j as %s",e,t),t}encodeAsBinary(e){let t=Rn(e),r=this.encodeAsString(t.packet),s=t.buffers;return s.unshift(r),s}};function On(i){return Object.prototype.toString.call(i)==="[object Object]"}var Er=class i extends N{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===E.BINARY_EVENT;r||t.type===E.BINARY_ACK?(t.type=r?E.EVENT:E.ACK,this.reconstructor=new br(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(Mt(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(E[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===E.BINARY_EVENT||r.type===E.BINARY_ACK){let n=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);let o=e.substring(n,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");r.attachments=Number(o)}if(e.charAt(t+1)==="/"){let n=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););r.nsp=e.substring(n,t)}else r.nsp="/";let s=e.charAt(t+1);if(s!==""&&Number(s)==s){let n=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(n,t+1))}if(e.charAt(++t)){let n=this.tryParse(e.substr(t));if(i.isPayloadValid(r.type,n))r.data=n;else throw new Error("invalid payload")}return vr("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 E.CONNECT:return On(t);case E.DISCONNECT:return t===void 0;case E.CONNECT_ERROR:return typeof t=="string"||On(t);case E.EVENT:case E.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&uc.indexOf(t[0])===-1);case E.ACK:case E.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},br=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=Tn(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function Z(i,e,t){return i.on(e,t),function(){i.off(e,t)}}var Ln=j(le(),1),B=(0,Ln.default)("socket.io-client:socket"),dc=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),st=class extends N{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=[Z(e,"open",this.onopen.bind(this)),Z(e,"packet",this.onpacket.bind(this)),Z(e,"error",this.onerror.bind(this)),Z(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(dc.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:E.EVENT,data:t};if(r.options={},r.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let o=this.ids++;B("emitting packet with ack id %d",o);let a=t.pop();this._registerAckCallback(o,a),r.id=o}let s=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!s||!this.connected)?B("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 s=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(s===void 0){this.acks[e]=t;return}let n=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let o=0;o<this.sendBuffer.length;o++)this.sendBuffer[o].id===e&&(B("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(o,1));B("event with ack id %d has timed out after %d ms",e,s),t.call(this,new Error("operation has timed out"))},s);this.acks[e]=(...o)=>{this.io.clearTimeoutFn(n),t.apply(this,[null,...o])}}emitWithAck(e,...t){let r=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((s,n)=>{t.push((o,a)=>r?o?n(o):s(a):s(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((s,...n)=>r!==this._queue[0]?void 0:(s!==null?r.tryCount>this._opts.retries&&(B("packet [%d] is discarded after %d tries",r.id,r.tryCount),this._queue.shift(),t&&t(s)):(B("packet [%d] was successfully sent",r.id),this._queue.shift(),t&&t(null,...n)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(B("draining queue"),!this.connected||this._queue.length===0)return;let t=this._queue[0];if(t.pending&&!e){B("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,B("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(){B("transport is open - connecting"),typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:E.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){B("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 E.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 E.EVENT:case E.BINARY_EVENT:this.onevent(e);break;case E.ACK:case E.BINARY_ACK:this.onack(e);break;case E.DISCONNECT:this.ondisconnect();break;case E.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||[];B("emitting event %j",t),e.id!=null&&(B("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(...s){r||(r=!0,B("sending ack %j",s),t.packet({type:E.ACK,id:e,data:s}))}}onack(e){let t=this.acks[e.id];typeof t=="function"?(B("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):B("bad ack %s",e.id)}onconnect(e,t){B("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(){B("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&&(B("performing disconnect (%s)",this.nsp),this.packet({type:E.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 qe(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}qe.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};qe.prototype.reset=function(){this.attempts=0};qe.prototype.setMin=function(i){this.ms=i};qe.prototype.setMax=function(i){this.max=i};qe.prototype.setJitter=function(i){this.jitter=i};var Fn=j(le(),1),$=(0,Fn.default)("socket.io-client:manager"),nt=class extends N{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,me(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 qe({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let s=t.parser||Sr;this.encoder=new s.Encoder,this.decoder=new s.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($("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;$("opening %s",this.uri),this.engine=new Me(this.uri,this.opts);let t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let s=Z(t,"open",function(){r.onopen(),e&&e()}),n=a=>{$("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",a),e?e(a):this.maybeReconnectOnOpen()},o=Z(t,"error",n);if(this._timeout!==!1){let a=this._timeout;$("connect attempt will timeout after %d",a);let c=this.setTimeoutFn(()=>{$("connect attempt timed out after %d",a),s(),n(new Error("timeout")),t.close()},a);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(s),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){$("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(Z(e,"ping",this.onping.bind(this)),Z(e,"data",this.ondata.bind(this)),Z(e,"error",this.onerror.bind(this)),Z(e,"close",this.onclose.bind(this)),Z(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){De(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){$("error",e),this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new st(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){$("socket %s is still active, skipping close",r);return}this._close()}_packet(e){$("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(){$("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){$("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){$("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)$("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();$("will wait %dms before reconnect attempt",t),this._reconnecting=!0;let r=this.setTimeoutFn(()=>{e.skipReconnect||($("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(s=>{s?($("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",s)):($("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 Un=j(le(),1),Bn=(0,Un.default)("socket.io-client"),qt={};function Wt(i,e){typeof i=="object"&&(e=i,i=void 0),e=e||{};let t=An(i,e.path||"/socket.io"),r=t.source,s=t.id,n=t.path,o=qt[s]&&n in qt[s].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o,c;return a?(Bn("ignoring socket cache for %s",r),c=new nt(r,e)):(qt[s]||(Bn("new io instance for %s",r),qt[s]=new nt(r,e)),c=qt[s]),t.query&&!e.query&&(e.query=t.queryKey),c.socket(t.path,e)}Object.assign(Wt,{Manager:nt,Socket:st,io:Wt,connect:Wt});var pc="https://ws.novu.co",Dn="notifications.notification_received",Mn="notifications.unseen_count_changed",qn="notifications.unread_count_changed",mc=({_id:i,content:e,read:t,archived:r,createdAt:s,lastReadDate:n,archivedAt:o,channel:a,subscriber:c,subject:u,avatar:l,cta:f,tags:m,data:w})=>{var d,y,V,R,z,X,Ee,jt,Ht,ee;let C={id:(d=c==null?void 0:c._id)!=null?d:"",firstName:c==null?void 0:c.firstName,lastName:c==null?void 0:c.lastName,avatar:c==null?void 0:c.avatar,subscriberId:(y=c==null?void 0:c.subscriberId)!=null?y:""},p=(R=(V=f.action)==null?void 0:V.buttons)==null?void 0:R.find(We=>We.type==="primary"),b=(X=(z=f.action)==null?void 0:z.buttons)==null?void 0:X.find(We=>We.type==="secondary"),L=(jt=(Ee=f.action)==null?void 0:Ee.result)==null?void 0:jt.type,k=(Ht=f.action)==null?void 0:Ht.status;return{id:i,subject:u,body:e,to:C,isRead:t,isArchived:r,createdAt:s,readAt:n,archivedAt:o,avatar:l,primaryAction:p&&{label:p.content,isCompleted:L==="primary"&&k==="done",redirect:p.url?{target:p.target,url:p.url}:void 0},secondaryAction:b&&{label:b.content,isCompleted:L==="secondary"&&k==="done",redirect:b.url?{target:b.target,url:b.url}:void 0},channelType:a,tags:m,redirect:(ee=f.data)!=null&&ee.url?{url:f.data.url,target:f.data.target}:void 0,data:w}},ot,de,pe,at,Ri,Ti,Oi,$t,xr,ki=class extends xe{constructor({socketUrl:t}){super();v(this,$t);v(this,ot);v(this,de);v(this,pe);v(this,at);v(this,Ri,({message:t})=>{h(this,de).emit(Dn,{result:new W(mc(t))})});v(this,Ti,({unseenCount:t})=>{h(this,de).emit(Mn,{result:t})});v(this,Oi,({unreadCount:t})=>{h(this,de).emit(qn,{result:t})});_(this,de,H.getInstance()),_(this,at,t!=null?t:pc)}onSessionSuccess({token:t}){_(this,ot,t)}isSocketEvent(t){return t===Dn||t===Mn||t===qn}initialize(){if(h(this,ot)){Fi(this,$t,xr).call(this).catch(t=>{console.error(t)});return}this.callWithSession(()=>g(this,null,function*(){return Fi(this,$t,xr).call(this).catch(t=>{console.error(t)}),{}}))}};ot=new WeakMap,de=new WeakMap,pe=new WeakMap,at=new WeakMap,Ri=new WeakMap,Ti=new WeakMap,Oi=new WeakMap,$t=new WeakSet,xr=function(){return g(this,null,function*(){var r,s,n;if(h(this,pe))return;let t={socketUrl:h(this,at)};h(this,de).emit("socket.connect.pending",{args:t}),_(this,pe,Wt(h(this,at),{reconnectionDelayMax:1e4,transports:["websocket"],query:{token:`${h(this,ot)}`}})),h(this,pe).on("connect",()=>{h(this,de).emit("socket.connect.resolved",{args:t})}),h(this,pe).on("connect_error",o=>{h(this,de).emit("socket.connect.resolved",{args:t,error:o})}),(r=h(this,pe))==null||r.on("notification_received",h(this,Ri)),(s=h(this,pe))==null||s.on("unseen_count_changed",h(this,Ti)),(n=h(this,pe))==null||n.on("unread_count_changed",h(this,Oi))})};var Wn="https://api.novu.co";var ct,Vt,ht,Ii=class{constructor(e){v(this,ct);v(this,Vt);v(this,ht);var t,r;ie.getInstance({backendUrl:(t=e.backendUrl)!=null?t:Wn}),_(this,ct,H.getInstance({recreate:!0})),_(this,Vt,new ii({applicationIdentifier:e.applicationIdentifier,subscriberId:e.subscriberId,subscriberHash:e.subscriberHash})),h(this,Vt).initialize(),this.notifications=new ti({useCache:(r=e.useCache)!=null?r:!0}),this.preferences=new si,_(this,ht,new ki({socketUrl:e.socketUrl}))}on(e,t){h(this,ht).isSocketEvent(e)&&h(this,ht).initialize(),h(this,ct).on(e,t)}off(e,t){h(this,ct).off(e,t)}};ct=new WeakMap,Vt=new WeakMap,ht=new WeakMap;window.Novu=Ii;})();
|
|
13
13
|
/*! Bundled license information:
|
|
14
14
|
|
|
15
15
|
xmlhttprequest-ssl/lib/XMLHttpRequest.js:
|