-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
1 lines (1 loc) · 72.3 KB
/
Copy pathmain.js
File metadata and controls
1 lines (1 loc) · 72.3 KB
1
(()=>{var e,t,n={137:(e,t,n)=>{"use strict";var r=String.prototype.replace,i=/%20/g,s=n(733),o={RFC1738:"RFC1738",RFC3986:"RFC3986"};e.exports=s.assign({default:o.RFC3986,formatters:{RFC1738:function(e){return r.call(e,i,"+")},RFC3986:function(e){return String(e)}}},o)},998:(e,t,n)=>{"use strict";var r=n(733),i=Object.prototype.hasOwnProperty,s=Array.isArray,o={allowDots:!1,allowPrototypes:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:r.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},a=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},c=function(e,t){return e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1?e.split(","):e},u=function(e,t){if(s(e)){for(var n=[],r=0;r<e.length;r+=1)n.push(t(e[r]));return n}return t(e)},l=function(e,t,n,r){if(e){var s=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(s),u=a?s.slice(0,a.index):s,l=[];if(u){if(!n.plainObjects&&i.call(Object.prototype,u)&&!n.allowPrototypes)return;l.push(u)}for(var h=0;n.depth>0&&null!==(a=o.exec(s))&&h<n.depth;){if(h+=1,!n.plainObjects&&i.call(Object.prototype,a[1].slice(1,-1))&&!n.allowPrototypes)return;l.push(a[1])}return a&&l.push("["+s.slice(a.index)+"]"),function(e,t,n,r){for(var i=r?t:c(t,n),s=e.length-1;s>=0;--s){var o,a=e[s];if("[]"===a&&n.parseArrays)o=[].concat(i);else{o=n.plainObjects?Object.create(null):{};var u="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,l=parseInt(u,10);n.parseArrays||""!==u?!isNaN(l)&&a!==u&&String(l)===u&&l>=0&&n.parseArrays&&l<=n.arrayLimit?(o=[])[l]=i:o[u]=i:o={0:i}}i=o}return i}(l,t,n,r)}};e.exports=function(e,t){var n=function(e){if(!e)return o;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?o.charset:e.charset;return{allowDots:void 0===e.allowDots?o.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:o.allowPrototypes,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:o.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:o.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:o.comma,decoder:"function"==typeof e.decoder?e.decoder:o.decoder,delimiter:"string"==typeof e.delimiter||r.isRegExp(e.delimiter)?e.delimiter:o.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:o.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:o.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:o.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:o.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:o.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var h="string"==typeof e?function(e,t){var n,l={},h=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,d=t.parameterLimit===1/0?void 0:t.parameterLimit,f=h.split(t.delimiter,d),p=-1,g=t.charset;if(t.charsetSentinel)for(n=0;n<f.length;++n)0===f[n].indexOf("utf8=")&&("utf8=%E2%9C%93"===f[n]?g="utf-8":"utf8=%26%2310003%3B"===f[n]&&(g="iso-8859-1"),p=n,n=f.length);for(n=0;n<f.length;++n)if(n!==p){var y,m,_=f[n],v=_.indexOf("]="),b=-1===v?_.indexOf("="):v+1;-1===b?(y=t.decoder(_,o.decoder,g,"key"),m=t.strictNullHandling?null:""):(y=t.decoder(_.slice(0,b),o.decoder,g,"key"),m=u(c(_.slice(b+1),t),(function(e){return t.decoder(e,o.decoder,g,"value")}))),m&&t.interpretNumericEntities&&"iso-8859-1"===g&&(m=a(m)),_.indexOf("[]=")>-1&&(m=s(m)?[m]:m),i.call(l,y)?l[y]=r.combine(l[y],m):l[y]=m}return l}(e,n):e,d=n.plainObjects?Object.create(null):{},f=Object.keys(h),p=0;p<f.length;++p){var g=f[p],y=l(g,h[g],n,"string"==typeof e);d=r.merge(d,y,n)}return r.compact(d)}},149:(e,t,n)=>{"use strict";var r=n(733),i=n(137),s=Object.prototype.hasOwnProperty,o={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},a=Array.isArray,c=Array.prototype.push,u=function(e,t){c.apply(e,a(t)?t:[t])},l=Date.prototype.toISOString,h=i.default,d={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:r.encode,encodeValuesOnly:!1,format:h,formatter:i.formatters[h],indices:!1,serializeDate:function(e){return l.call(e)},skipNulls:!1,strictNullHandling:!1},f=function e(t,n,i,s,o,c,l,h,f,p,g,y,m){var _,v=t;if("function"==typeof l?v=l(n,v):v instanceof Date?v=p(v):"comma"===i&&a(v)&&(v=v.join(",")),null===v){if(s)return c&&!y?c(n,d.encoder,m,"key"):n;v=""}if("string"==typeof(_=v)||"number"==typeof _||"boolean"==typeof _||"symbol"==typeof _||"bigint"==typeof _||r.isBuffer(v))return c?[g(y?n:c(n,d.encoder,m,"key"))+"="+g(c(v,d.encoder,m,"value"))]:[g(n)+"="+g(String(v))];var b,w=[];if(void 0===v)return w;if(a(l))b=l;else{var C=Object.keys(v);b=h?C.sort(h):C}for(var k=0;k<b.length;++k){var I=b[k];o&&null===v[I]||(a(v)?u(w,e(v[I],"function"==typeof i?i(n,I):n,i,s,o,c,l,h,f,p,g,y,m)):u(w,e(v[I],n+(f?"."+I:"["+I+"]"),i,s,o,c,l,h,f,p,g,y,m)))}return w};e.exports=function(e,t){var n,r=e,c=function(e){if(!e)return d;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||d.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=i.default;if(void 0!==e.format){if(!s.call(i.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=i.formatters[n],o=d.filter;return("function"==typeof e.filter||a(e.filter))&&(o=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:d.addQueryPrefix,allowDots:void 0===e.allowDots?d.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:d.charsetSentinel,delimiter:void 0===e.delimiter?d.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:d.encode,encoder:"function"==typeof e.encoder?e.encoder:d.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:d.encodeValuesOnly,filter:o,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:d.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:d.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:d.strictNullHandling}}(t);"function"==typeof c.filter?r=(0,c.filter)("",r):a(c.filter)&&(n=c.filter);var l,h=[];if("object"!=typeof r||null===r)return"";l=t&&t.arrayFormat in o?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var p=o[l];n||(n=Object.keys(r)),c.sort&&n.sort(c.sort);for(var g=0;g<n.length;++g){var y=n[g];c.skipNulls&&null===r[y]||u(h,f(r[y],y,p,c.strictNullHandling,c.skipNulls,c.encode?c.encoder:null,c.filter,c.sort,c.allowDots,c.serializeDate,c.formatter,c.encodeValuesOnly,c.charset))}var m=h.join(c.delimiter),_=!0===c.addQueryPrefix?"?":"";return c.charsetSentinel&&("iso-8859-1"===c.charset?_+="utf8=%26%2310003%3B&":_+="utf8=%E2%9C%93&"),m.length>0?_+m:""}},733:e=>{"use strict";var t=Object.prototype.hasOwnProperty,n=Array.isArray,r=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),i=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r<e.length;++r)void 0!==e[r]&&(n[r]=e[r]);return n};e.exports={arrayToObject:i,assign:function(e,t){return Object.keys(t).reduce((function(e,n){return e[n]=t[n],e}),e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],r=[],i=0;i<t.length;++i)for(var s=t[i],o=s.obj[s.prop],a=Object.keys(o),c=0;c<a.length;++c){var u=a[c],l=o[u];"object"==typeof l&&null!==l&&-1===r.indexOf(l)&&(t.push({obj:o,prop:u}),r.push(l))}return function(e){for(;e.length>1;){var t=e.pop(),r=t.obj[t.prop];if(n(r)){for(var i=[],s=0;s<r.length;++s)void 0!==r[s]&&i.push(r[s]);t.obj[t.prop]=i}}}(t),e},decode:function(e,t,n){var r=e.replace(/\+/g," ");if("iso-8859-1"===n)return r.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(r)}catch(e){return r}},encode:function(e,t,n){if(0===e.length)return e;var i=e;if("symbol"==typeof e?i=Symbol.prototype.toString.call(e):"string"!=typeof e&&(i=String(e)),"iso-8859-1"===n)return escape(i).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));for(var s="",o=0;o<i.length;++o){var a=i.charCodeAt(o);45===a||46===a||95===a||126===a||a>=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122?s+=i.charAt(o):a<128?s+=r[a]:a<2048?s+=r[192|a>>6]+r[128|63&a]:a<55296||a>=57344?s+=r[224|a>>12]+r[128|a>>6&63]+r[128|63&a]:(o+=1,a=65536+((1023&a)<<10|1023&i.charCodeAt(o)),s+=r[240|a>>18]+r[128|a>>12&63]+r[128|a>>6&63]+r[128|63&a])}return s},isBuffer:function(e){return!(!e||"object"!=typeof e||!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e)))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},merge:function e(r,s,o){if(!s)return r;if("object"!=typeof s){if(n(r))r.push(s);else{if(!r||"object"!=typeof r)return[r,s];(o&&(o.plainObjects||o.allowPrototypes)||!t.call(Object.prototype,s))&&(r[s]=!0)}return r}if(!r||"object"!=typeof r)return[r].concat(s);var a=r;return n(r)&&!n(s)&&(a=i(r,o)),n(r)&&n(s)?(s.forEach((function(n,i){if(t.call(r,i)){var s=r[i];s&&"object"==typeof s&&n&&"object"==typeof n?r[i]=e(s,n,o):r.push(n)}else r[i]=n})),r):Object.keys(s).reduce((function(n,r){var i=s[r];return t.call(n,r)?n[r]=e(n[r],i,o):n[r]=i,n}),a)}}},249:function(e,t,n){var r;e.exports=(r=r||function(e,t){var r;if("undefined"!=typeof window&&window.crypto&&(r=window.crypto),"undefined"!=typeof self&&self.crypto&&(r=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(r=globalThis.crypto),!r&&"undefined"!=typeof window&&window.msCrypto&&(r=window.msCrypto),!r&&void 0!==n.g&&n.g.crypto&&(r=n.g.crypto),!r)try{r=n(480)}catch(e){}var i=function(){if(r){if("function"==typeof r.getRandomValues)try{return r.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof r.randomBytes)try{return r.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},s=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),o={},a=o.lib={},c=a.Base={extend:function(e){var t=s(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},u=a.WordArray=c.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||h).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,i=e.sigBytes;if(this.clamp(),r%4)for(var s=0;s<i;s++){var o=n[s>>>2]>>>24-s%4*8&255;t[r+s>>>2]|=o<<24-(r+s)%4*8}else for(var a=0;a<i;a+=4)t[r+a>>>2]=n[a>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=c.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(i());return new u.init(t,e)}}),l=o.enc={},h=l.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var s=t[i>>>2]>>>24-i%4*8&255;r.push((s>>>4).toString(16)),r.push((15&s).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new u.init(n,t/2)}},d=l.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var s=t[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(s))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new u.init(n,t)}},f=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(d.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return d.parse(unescape(encodeURIComponent(e)))}},p=a.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=f.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n,r=this._data,i=r.words,s=r.sigBytes,o=this.blockSize,a=s/(4*o),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,l=e.min(4*c,s);if(c){for(var h=0;h<c;h+=o)this._doProcessBlock(i,h);n=i.splice(0,c),r.sigBytes-=l}return new u.init(n,l)},clone:function(){var e=c.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),g=(a.Hasher=p.extend({cfg:c.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new g.HMAC.init(e,n).finalize(t)}}}),o.algo={});return o}(Math),r)},269:function(e,t,n){var r,i,s;e.exports=(r=n(249),s=(i=r).lib.WordArray,i.enc.Base64={stringify:function(e){var t=e.words,n=e.sigBytes,r=this._map;e.clamp();for(var i=[],s=0;s<n;s+=3)for(var o=(t[s>>>2]>>>24-s%4*8&255)<<16|(t[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|t[s+2>>>2]>>>24-(s+2)%4*8&255,a=0;a<4&&s+.75*a<n;a++)i.push(r.charAt(o>>>6*(3-a)&63));var c=r.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(e){var t=e.length,n=this._map,r=this._reverseMap;if(!r){r=this._reverseMap=[];for(var i=0;i<n.length;i++)r[n.charCodeAt(i)]=i}var o=n.charAt(64);if(o){var a=e.indexOf(o);-1!==a&&(t=a)}return function(e,t,n){for(var r=[],i=0,o=0;o<t;o++)if(o%4){var a=n[e.charCodeAt(o-1)]<<o%4*2|n[e.charCodeAt(o)]>>>6-o%4*2;r[i>>>2]|=a<<24-i%4*8,i++}return s.create(r,i)}(e,t,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},r.enc.Base64)},153:function(e,t,n){var r;e.exports=(r=n(249),function(e){var t=r,n=t.lib,i=n.WordArray,s=n.Hasher,o=t.algo,a=[],c=[];!function(){function t(t){for(var n=e.sqrt(t),r=2;r<=n;r++)if(!(t%r))return!1;return!0}function n(e){return 4294967296*(e-(0|e))|0}for(var r=2,i=0;i<64;)t(r)&&(i<8&&(a[i]=n(e.pow(r,.5))),c[i]=n(e.pow(r,1/3)),i++),r++}();var u=[],l=o.SHA256=s.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],s=n[2],o=n[3],a=n[4],l=n[5],h=n[6],d=n[7],f=0;f<64;f++){if(f<16)u[f]=0|e[t+f];else{var p=u[f-15],g=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,y=u[f-2],m=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;u[f]=g+u[f-7]+m+u[f-16]}var _=r&i^r&s^i&s,v=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),b=d+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&l^~a&h)+c[f]+u[f];d=h,h=l,l=a,a=o+b|0,o=s,s=i,i=r,r=b+(v+_)|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+s|0,n[3]=n[3]+o|0,n[4]=n[4]+a|0,n[5]=n[5]+l|0,n[6]=n[6]+h|0,n[7]=n[7]+d|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=s._createHelper(l),t.HmacSHA256=s._createHmacHelper(l)}(Math),r.SHA256)},227:(e,t,n)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(i=r))})),t.splice(i,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!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`."))}})(),t.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"],t.log=console.debug||console.log||(()=>{}),e.exports=n(447)(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},447:(e,t,n)=>{e.exports=function(e){function t(e){let n,i,s,o=null;function a(...e){if(!a.enabled)return;const r=a,i=Number(new Date),s=i-(n||i);r.diff=s,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,i)=>{if("%%"===n)return"%";o++;const s=t.formatters[i];if("function"==typeof s){const t=e[o];n=s.call(r,t),e.splice(o,1),o--}return n})),t.formatArgs.call(r,e),(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(i!==t.namespaces&&(i=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function i(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(i),...t.skips.map(i).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(n=0;n<i;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=n(824),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}},643:e=>{e.exports=!1},729:e=>{"use strict";var t=Object.prototype.hasOwnProperty,n="~";function r(){}function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function s(e,t,r,s,o){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new i(r,s||e,o),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function o(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var e,r,i=[];if(0===this._eventsCount)return i;for(r in e=this._events)t.call(e,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,s=r.length,o=new Array(s);i<s;i++)o[i]=r[i].fn;return o},a.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},a.prototype.emit=function(e,t,r,i,s,o){var a=n?n+e:e;if(!this._events[a])return!1;var c,u,l=this._events[a],h=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,i),!0;case 5:return l.fn.call(l.context,t,r,i,s),!0;case 6:return l.fn.call(l.context,t,r,i,s,o),!0}for(u=1,c=new Array(h-1);u<h;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var d,f=l.length;for(u=0;u<f;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),h){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,r);break;case 4:l[u].fn.call(l[u].context,t,r,i);break;default:if(!c)for(d=1,c=new Array(h-1);d<h;d++)c[d-1]=arguments[d];l[u].fn.apply(l[u].context,c)}}return!0},a.prototype.on=function(e,t,n){return s(this,e,t,n,!1)},a.prototype.once=function(e,t,n){return s(this,e,t,n,!0)},a.prototype.removeListener=function(e,t,r,i){var s=n?n+e:e;if(!this._events[s])return this;if(!t)return o(this,s),this;var a=this._events[s];if(a.fn)a.fn!==t||i&&!a.once||r&&a.context!==r||o(this,s);else{for(var c=0,u=[],l=a.length;c<l;c++)(a[c].fn!==t||i&&!a[c].once||r&&a[c].context!==r)&&u.push(a[c]);u.length?this._events[s]=1===u.length?u[0]:u:o(this,s)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&o(this,t)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a},792:(e,t,n)=>{var r=null;"undefined"!=typeof WebSocket?r=WebSocket:"undefined"!=typeof MozWebSocket?r=MozWebSocket:void 0!==n.g?r=n.g.WebSocket||n.g.MozWebSocket:"undefined"!=typeof window?r=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(r=self.WebSocket||self.MozWebSocket),e.exports=r},104:(e,t,n)=>{var r,i,s;!function(o){if("object"==typeof e.exports){var a=o(n(636),t);void 0!==a&&(e.exports=a)}else i=[n,t],void 0===(s="function"==typeof(r=o)?r.apply(t,i):r)||(e.exports=s)}((function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=t.repeatedStart=t.delayError=t.callbackError=void 0,t.callbackError="Expeting to get a cb function as the first argument",t.delayError="Delay argument should be a number >= 0",t.repeatedStart="Timeout was already started";var n=function(){function e(e,n){this._pending=!1,this._canceled=!1,this._paused=!1;var r="number"==typeof e?e:n;if("number"!=typeof r||r<0)throw new Error(t.delayError);this._delay=r,this._timeLeft=r,"number"!=typeof e&&this.start(e)}return Object.defineProperty(e.prototype,"isPending",{get:function(){return this._pending},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isStarted",{get:function(){return null!=this._startTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCanceled",{get:function(){return this._canceled},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isFinished",{get:function(){return!this.isPending&&!this._canceled},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isFinishedPreemptively",{get:function(){return this.isFinished&&this._timeLeft>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"timeLeft",{get:function(){return!this._pending||this._paused?this._timeLeft:this._delay-((new Date).getTime()-this._startTime)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"timePassed",{get:function(){return this._delay-this.timeLeft},enumerable:!1,configurable:!0}),e.prototype._run=function(){var e=this;this._startTime=(new Date).getTime(),this._pending=!0,this._canceled=!1,this._paused=!1,this._to=setTimeout((function(){e._to=null,e._pending=!1,e._timeLeft=0,e._cb()}),this._timeLeft)},e.prototype._halt=function(){this._to&&(clearTimeout(this._to),this._to=null),this._timeLeft=this.timeLeft},e.prototype.start=function(e){var n=this;if(null!=e){if("function"!=typeof e)throw new Error(t.callbackError);return!this._pending&&(this._cb=e,this._run(),!0)}return new Promise((function(e,r){if(n._pending)return r(t.repeatedStart);n._cb=e,n._run()}))},e.prototype.cancel=function(){return!!this._pending&&(this._halt(),this._pending=!1,this._canceled=!0,!0)},e.prototype.execute=function(){return!!this._pending&&(this._halt(),this._pending=!1,this._cb(),!0)},e.prototype.pause=function(){return!(!this._pending||this._paused||(this._halt(),this._paused=!0,0))},e.prototype.resume=function(){return!(!this._pending||!this._paused||(this._run(),0))},Object.defineProperty(e.prototype,"paused",{get:function(){return this._paused},set:function(e){e?this.pause():this.resume()},enumerable:!1,configurable:!0}),e.prototype.reset=function(e){if(null==e&&(e=this._delay),"number"!=typeof e||e<0)throw new Error(t.delayError);if(this.isStarted){if(!this.isPending)return!1;this._halt(),this._delay=e,this._timeLeft=e,this._run()}else this._delay=e,this._timeLeft=e;return!0},Object.defineProperty(e.prototype,"delay",{get:function(){return this._delay},enumerable:!1,configurable:!0}),e}();t.Timeout=n,t.default=n}))},636:e=>{function t(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}t.keys=()=>[],t.resolve=t,t.id=636,e.exports=t},824:e=>{var t=1e3,n=60*t,r=60*n,i=24*r;function s(e,t,n,r){var i=t>=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}e.exports=function(e,o){o=o||{};var a,c,u=typeof e;if("string"===u&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var s=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(s){var o=parseFloat(s[1]);switch((s[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*o;case"weeks":case"week":case"w":return 6048e5*o;case"days":case"day":case"d":return o*i;case"hours":case"hour":case"hrs":case"hr":case"h":return o*r;case"minutes":case"minute":case"mins":case"min":case"m":return o*n;case"seconds":case"second":case"secs":case"sec":case"s":return o*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return o;default:return}}}}(e);if("number"===u&&isFinite(e))return o.long?(a=e,(c=Math.abs(a))>=i?s(a,c,i,"day"):c>=r?s(a,c,r,"hour"):c>=n?s(a,c,n,"minute"):c>=t?s(a,c,t,"second"):a+" ms"):function(e){var s=Math.abs(e);return s>=i?Math.round(e/i)+"d":s>=r?Math.round(e/r)+"h":s>=n?Math.round(e/n)+"m":s>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},300:(e,t)=>{"use strict";var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();e.exports=t=n.fetch,n.fetch&&(t.default=n.fetch.bind(n)),t.Headers=n.Headers,t.Request=n.Request,t.Response=n.Response},480:()=>{}},r={};function i(e){var t=r[e];if(void 0!==t)return t.exports;var s=r[e]={exports:{}};return n[e].call(s.exports,s,s.exports,i),s.exports}t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var s=Object.create(null);i.r(s);var o={};e=e||[null,t({}),t([]),t(t)];for(var a=2&r&&n;"object"==typeof a&&!~e.indexOf(a);a=t(a))Object.getOwnPropertyNames(a).forEach((e=>o[e]=()=>n[e]));return o.default=()=>n,i.d(s,o),s},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{"use strict";var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}function n(e,t,n,r){var i,s=arguments.length,o=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(s<3?i(o):s>3?i(t,n,o):i(t,n))||o);return s>3&&o&&Object.defineProperty(t,n,o),o}function r(e){return void 0===e&&(e=!0),function(t,n){Object.defineProperty(t,n,{get:function(){},set:function(t){Object.defineProperty(this,n,{value:t,writable:!0,enumerable:e})},enumerable:e})}}function s(e,t,n){return r=>{const i=n?function(){return`[${t}#${this[n]} - please check https://twurple.js.org/reference/${e}/classes/${t}.html for available properties]`}:function(){return`[${t} - please check https://twurple.js.org/reference/${e}/classes/${t}.html for available properties]`};Object.defineProperty(r.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:i,enumerable:!1})}}Object.create,Object.create;var o=i(300),a=o.default||o;const c=o.Headers;o.Request,o.Response;var u=i(149);i(998),i(137);class l extends Error{constructor(e,t){var n;super(e,t),Object.setPrototypeOf(this,new.target.prototype),null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,new.target.constructor)}get name(){return this.constructor.name}}class h extends l{constructor(e,t,n,r,i,s){super(`Encountered HTTP status code ${e}: ${t}\n\nURL: ${n}\nMethod: ${r}\nBody:\n${!s&&i.length>150?`${i.slice(0,147)}...`:i}`),this._statusCode=e,this._url=n,this._method=r,this._body=i}get statusCode(){return this._statusCode}get url(){return this._url}get method(){return this._method}get body(){return this._body}}async function d(e,t,n,r,i={}){const s=await async function(e,t,n,r,i={}){var s,o;const l=null!==(s=e.type)&&void 0!==s?s:"helix",h=function(e,t){switch(t){case"helix":return`https://api.twitch.tv/helix/${e.replace(/^\//,"")}`;case"auth":return`https://id.twitch.tv/oauth2/${e.replace(/^\//,"")}`;default:return e}}(e.url,l),d=u(e.query,{arrayFormat:"repeat",addQueryPrefix:!0}),f=new c({Accept:"application/json"});let p;e.jsonBody&&(p=JSON.stringify(e.jsonBody),f.append("Content-Type","application/json")),t&&"auth"!==l&&f.append("Client-ID",t),n&&f.append("Authorization",`${"helix"===l?null!=r?r:"Bearer":"OAuth"} ${n}`);const g={...i,method:null!==(o=e.method)&&void 0!==o?o:"GET",headers:f,body:p};return await function(e,t){return/^\/\//.test(e)&&(e="https:"+e),a.call(this,e,t)}(`${h}${d}`,g)}(e,t,n,r,i);return await async function(e,t){var n;if(!e.ok){const r="application/json"===e.headers.get("Content-Type"),i=r?JSON.stringify(await e.json(),null,2):await e.text(),s=u(t.query,{arrayFormat:"repeat",addQueryPrefix:!0}),o=`${t.url}${s}`;throw new h(e.status,e.statusText,o,null!==(n=t.method)&&void 0!==n?n:"GET",i,r)}}(s,e),await async function(e){if(204===e.status)return;const t=await e.text();return t?JSON.parse(t):void 0}(s)}class f extends l{constructor(e){super("Invalid token supplied",e)}}function p(e){return null==e}function g(e,t){return p(e)?void 0:t(e)}const y=Symbol("twurpleRawData");class m{constructor(e){this[y]=e}}let _=class extends m{constructor(e){super(e),this._obtainmentDate=new Date}get clientId(){return this[y].client_id}get userId(){var e;return null!==(e=this[y].user_id)&&void 0!==e?e:null}get userName(){var e;return null!==(e=this[y].login)&&void 0!==e?e:null}get scopes(){return this[y].scopes}get expiryDate(){return t=e=>new Date(this._obtainmentDate.getTime()+1e3*e),p(e=this[y].expires_in)?null:t(e);var e,t}};async function v(e,t){try{const n=await d({type:"auth",url:"validate"},t,e);return new _(n)}catch(e){if(e instanceof h&&401===e.statusCode)throw new f({cause:e});throw e}}async function b(e,t,n){let r=null;try{const n=await e.getAccessToken(t);if(n)return{accessToken:n,tokenInfo:await v(n.accessToken)}}catch(e){e instanceof f?r=e:null==n||n.error(`Retrieving an access token failed: ${e.message}`)}if(null==n||n.warn("No valid token available; trying to refresh"),e.refresh)try{const t=await e.refresh();if(t)return{accessToken:t,tokenInfo:await v(t.accessToken)}}catch(e){e instanceof f?r=e:null==n||n.error(`Refreshing the access token failed: ${e.message}`)}throw null!=r?r:new Error("Could not retrieve a valid token")}_=n([s("auth","TokenInfo","clientId")],_);const w=new Map([["channel_commercial",["channel:edit:commercial"]],["channel_editor",["channel:manage:broadcast"]],["channel_read",["channel:read:stream_key"]],["channel_subscriptions",["channel:read:subscriptions"]],["user_blocks_read",["user:read:blocked_users"]],["user_blocks_edit",["user:manage:blocked_users"]],["user_follows_edit",["user:edit:follows"]],["user_read",["user:read:email"]],["user_subscriptions",["user:read:subscriptions"]],["user:edit:broadcast",["channel:manage:broadcast","channel:manage:extensions"]]]);let C=class{constructor(e,t,n,r="user"){this._clientId=e||"",this.tokenType=r,this._accessToken="string"==typeof t?{accessToken:t,refreshToken:null,scope:null!=n?n:[],expiresIn:null,obtainmentTimestamp:Date.now()}:t,this._scopes=n}async getAccessToken(e){return this._scopes=await async function(e,t,n,r){if(null==r?void 0:r.length){const i=null!=n?n:(await v(t,e)).scopes;return function(e,t){if(void 0!==t){const n=new Set(e.flatMap((e=>{var t;return[e,...null!==(t=w.get(e))&&void 0!==t?t:[]]})));if(t.some((e=>!n.has(e))))throw new Error(`This token does not have the requested scopes (${t.join(", ")}) and can not be upgraded.\nIf you need dynamically upgrading scopes, please implement the AuthProvider interface accordingly:\n\n\thttps://twurple.js.org/reference/auth/interfaces/AuthProvider.html`)}}(i,r),i}return n}(this._clientId,this._accessToken.accessToken,this._scopes,e),this._accessToken}get clientId(){return this._clientId}get currentScopes(){var e;return null!==(e=this._scopes)&&void 0!==e?e:[]}};n([r(!1)],C.prototype,"_clientId",void 0),n([r(!1)],C.prototype,"_accessToken",void 0),C=n([s("auth","StaticAuthProvider","clientId")],C);class k extends l{}function I(e){return"string"==typeof e?e:"number"==typeof e?e.toString(10):e.id}function x(e){return t=this,n=void 0,i=function(){return function(e,t){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t){return setTimeout(t,e)}))];case 1:return t.sent(),[2]}}))},new((r=Promise)||(r=Promise))((function(e,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(e){e(n)}))).then(o,a)}c((i=i.apply(t,n||[])).next())}));var t,n,r,i}class S{constructor(e,t,n,r=!1){this.owner=e,this.event=t,this.listener=n,this._internal=r}unbind(){this.owner.removeListener(this)}}class O{constructor(){this._eventListeners=new Map,this._internalEventListeners=new Map}on(e,t){return this._addListener(!1,e,t)}addListener(e,t){return this._addListener(!1,e,t)}removeListener(e,t){this._removeListener(!1,e,t)}registerEvent(){const e=t=>this.addListener(e,t);return e}emit(e,...t){if(this._eventListeners.has(e))for(const n of this._eventListeners.get(e))n(...t);if(this._internalEventListeners.has(e))for(const n of this._internalEventListeners.get(e))n(...t)}registerInternalEvent(){const e=t=>this.addInternalListener(e,t);return e}addInternalListener(e,t){return this._addListener(!0,e,t)}removeInternalListener(e,t){this._removeListener(!0,e,t)}_addListener(e,t,n){const r=e?this._eventListeners:this._internalEventListeners;return r.has(t)?r.get(t).push(n):r.set(t,[n]),new S(this,t,n,e)}_removeListener(e,t,n){const r=e?this._eventListeners:this._internalEventListeners;if(t)if("object"==typeof t){const e=t;this._removeListener(e._internal,e.event,e.listener)}else{const e=t;if(r.has(e))if(n){const t=r.get(e);let i=0;for(;-1!==(i=t.indexOf(n));)t.splice(i,1)}else r.delete(e)}else r.clear()}}class E extends O{constructor(e,t,n={}){var r;super(),this._type=e,this._target=t,this._config=n,this._retryLimit=1/0,this._initialRetryLimit=3,this._connecting=!1,this._connectionRetryCount=0,this.onReceive=this.registerEvent(),this.onConnect=this.registerEvent(),this.onDisconnect=this.registerEvent(),this.onEnd=this.registerEvent(),this._retryLimit=null!==(r=n.retryLimit)&&void 0!==r?r:1/0,this._logger=n.logger}get isConnected(){var e,t;return null!==(t=null===(e=this._currentConnection)||void 0===e?void 0:e.isConnected)&&void 0!==t&&t}get isConnecting(){var e,t;return null!==(t=null===(e=this._currentConnection)||void 0===e?void 0:e.isConnecting)&&void 0!==t?t:this._connecting}get hasSocket(){var e,t;return null!==(t=null===(e=this._currentConnection)||void 0===e?void 0:e.hasSocket)&&void 0!==t&&t}sendLine(e){var t;null===(t=this._currentConnection)||void 0===t||t.sendLine(e)}async connect(){await this._connect(!0)}async disconnect(){var e;if(null===(e=this._logger)||void 0===e||e.trace(`PersistentConnection disconnect currentConnectionExists:${Boolean(this._currentConnection).toString()} connecting:${this._connecting.toString()}`),this._connecting=!1,this._currentConnection){const e=this._currentConnection;this._currentConnection=void 0,await e.disconnect()}}assumeExternalDisconnect(){var e,t;null===(e=this._logger)||void 0===e||e.trace("PersistentConnection assumeExternalDisconnect"),null===(t=this._currentConnection)||void 0===t||t.assumeExternalDisconnect()}async reconnect(){await this._reconnect(!0)}async _connect(e=!1){var t,n,r,i;if(null===(t=this._logger)||void 0===t||t.trace(`PersistentConnection connect currentConnectionExists:${Boolean(this._currentConnection).toString()} connecting:${this._connecting.toString()}`),this._currentConnection||this._connecting)throw new Error("Connection already present");this._connectionRetryCount=0,this._connecting=!0;const s=e?this._initialRetryLimit:this._retryLimit;for(this._retryTimerGenerator=E._getReconnectWaitTime();this._connectionRetryCount<=s;){const t=this._currentConnection=new this._type(this._target,this._config);t.onReceive((e=>this.emit(this.onReceive,e))),t.onConnect((()=>this.emit(this.onConnect))),t.onDisconnect(((e,n)=>{this.emit(this.onDisconnect,e,n),e?(this.emit(this.onEnd,!0),t.disconnect(),this._currentConnection===t&&(this._currentConnection=void 0)):this._connecting||this._reconnect()}));try{return await t.connect(),void(this._connecting=!1)}catch(t){if(!this._connecting)return;if(null===(n=this._logger)||void 0===n||n.debug(`Connection error caught: ${t.message}`),this._connectionRetryCount>=s)break;this._connectionRetryCount++;const o=this._retryTimerGenerator.next().value;if(0!==o&&(null===(r=this._logger)||void 0===r||r.info(`Retrying in ${o} seconds`)),await x(1e3*o),null===(i=this._logger)||void 0===i||i.info(e?"Retrying connection":"Trying to reconnect"),!this._connecting)return}}const o=new Error(`Connection failed after trying ${s} times`);if(this.emit(this.onEnd,!1,o),e)throw o}async _reconnect(e=!1){this.disconnect().catch((e=>{var t;return null===(t=this._logger)||void 0===t?void 0:t.error(`Error while disconnecting for the reconnect: ${e.message}`)})),await this._connect(e)}static*_getReconnectWaitTime(){let e=0,t=1;for(;e<120;)yield e,[e,t]=[t,e+t];for(;;)yield 120}}var R=null;"undefined"!=typeof WebSocket?R=WebSocket:"undefined"!=typeof MozWebSocket?R=MozWebSocket:"undefined"!=typeof global?R=global.WebSocket||global.MozWebSocket:"undefined"!=typeof window?R=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(R=self.WebSocket||self.MozWebSocket);class L extends O{constructor({lineBased:e,logger:t,additionalOptions:n}={}){super(),this._currentLine="",this._connecting=!1,this._connected=!1,this.onReceive=this.registerEvent(),this.onConnect=this.registerEvent(),this.onDisconnect=this.registerEvent(),this.onEnd=this.registerEvent(),this._lineBased=null!=e&&e,this._logger=t,this._additionalOptions=n}get isConnecting(){return this._connecting}get isConnected(){return this._connected}sendLine(e){this._connected&&(e=e.replace(/[\0\r\n]/g,""),this.sendRaw(`${e}\r\n`))}assumeExternalDisconnect(){var e;null===(e=this._logger)||void 0===e||e.trace("AbstrctConnection assumeExternalDisconnect"),this._connected=!1,this._connecting=!1,this.emit(this.onDisconnect,!1)}receiveRaw(e){var t,n;if(!this._lineBased)return void this.emit(this.onReceive,e);const r=e.split("\r\n");if(this._currentLine+=null!==(t=r.shift())&&void 0!==t?t:"",r.length){this.emit(this.onReceive,this._currentLine),this._currentLine=null!==(n=r.pop())&&void 0!==n?n:"";for(const e of r)this.emit(this.onReceive,e)}}}class P extends L{constructor(e,t){if(super(t),this._socket=null,e.hostName&&e.port)this._url=`ws${e.secure?"s":""}://${e.hostName}:${e.port}`;else{if(!e.url)throw new Error("WebSocketConnection requires either hostName & port or url to be set");this._url=e.url}}get hasSocket(){return!!this._socket}sendRaw(e){var t;null===(t=this._socket)||void 0===t||t.send(e)}async connect(){var e;null===(e=this._logger)||void 0===e||e.trace("WebSocketConnection connect"),await new Promise(((e,t)=>{var n;this._connecting=!0,this._socket=new R(this._url,null===(n=this._additionalOptions)||void 0===n?void 0:n.wsOptions),this._socket.onopen=()=>{var t;null===(t=this._logger)||void 0===t||t.trace("WebSocketConnection onOpen"),this._connected=!0,this._connecting=!1,this.emit(this.onConnect),e()},this._socket.onmessage=({data:e})=>{this.receiveRaw(e.toString())},this._socket.onerror=e=>{var t;null===(t=this._logger)||void 0===t||t.trace(`WebSocketConnection onError message:${e.message}`)},this._socket.onclose=e=>{var n;const r=this._connected;if(null===(n=this._logger)||void 0===n||n.trace(`WebSocketConnection onClose wasConnected:${r.toString()} wasClean:${e.wasClean.toString()}`),this._connected=!1,this._connecting=!1,e.wasClean)this.emit(this.onDisconnect,!0),this.emit(this.onEnd,!0);else{const n=new Error(`[${e.code}] ${e.reason}`);this.emit(this.onDisconnect,!1,n),this.emit(this.onEnd,!1,n),r||t(n)}this._socket&&(this._socket.onopen=null,this._socket.onmessage=null,this._socket.onerror=null,this._socket.onclose=null,this._socket=null)}}))}async disconnect(){var e;null===(e=this._logger)||void 0===e||e.trace("WebSocketConnection disconnect"),await new Promise((e=>{if(this._socket){const t=this.onDisconnect((()=>{t.unbind(),e()}));this._socket.close()}else e()}))}}var T,j,N=i(643),A=i.t(N,2);function F(e){if("number"==typeof e){if(Object.prototype.hasOwnProperty.call(j,e))return e;var t=Object.keys(j).map((function(e){return parseInt(e,10)})).filter((function(t){return!isNaN(t)&&t<e}));return t.length?Math.max.apply(Math,t):j.WARNING}var n=e.replace(/\d+$/,"").toUpperCase();if(!Object.prototype.hasOwnProperty.call(j,n))throw new Error("Unknown log level string: "+e);return j[n]}!function(e){e[e.CRITICAL=0]="CRITICAL",e[e.ERROR=1]="ERROR",e[e.WARNING=2]="WARNING",e[e.INFO=3]="INFO",e[e.DEBUG=4]="DEBUG",e[e.TRACE=7]="TRACE"}(j||(j={}));var B,M,D=A?console.log.bind(console):console.debug.bind(console),$=((T={})[j.CRITICAL]=console.error.bind(console),T[j.ERROR]=console.error.bind(console),T[j.WARNING]=console.warn.bind(console),T[j.INFO]=console.info.bind(console),T[j.DEBUG]=D.bind(console),T[j.TRACE]=console.trace.bind(console),T),U="undefined"==typeof process?[]:null!==(M=null===(B=process.env.LOGGING)||void 0===B?void 0:B.split(";").map((function(e){var t=e.split("=",2),n=t[0],r=t[1];return r?["default"===n?void 0:n.split(":"),F(r)]:null})).filter((function(e){return!!e})).sort((function(e,t){var n,r,i=e[0],s=t[0];return(null!==(n=null==s?void 0:s.length)&&void 0!==n?n:0)-(null!==(r=null==i?void 0:i.length)&&void 0!==r?r:0)})))&&void 0!==M?M:[],W=U.findIndex((function(e){return!e[0]})),G=void 0;function H(e,t){return t.length<=e.length&&t.every((function(t,n){return t===e[n]}))}function z(e){for(var t=e.split(":"),n=0,r=U;n<r.length;n++){var i=r[n],s=i[0],o=i[1];if(H(t,s))return o}return G}-1!==W&&(G=U[W][1],U.splice(W));var q,V,Q,J=function(){function e(e){var t,n,r=e.name,i=e.minLevel,s=e.emoji,o=void 0!==s&&s,a=e.colors,c=e.timestamps,u=void 0===c?A:c;this._name=r,this._minLevel=null!==(n=null!==(t=g(i,(function(e){return F(e)})))&&void 0!==t?t:z(r))&&void 0!==n?n:j.WARNING,this._emoji=o,this._colors=a,this._timestamps=u}return e.prototype.crit=function(e){this.log(j.CRITICAL,e)},e.prototype.error=function(e){this.log(j.ERROR,e)},e.prototype.warn=function(e){this.log(j.WARNING,e)},e.prototype.info=function(e){this.log(j.INFO,e)},e.prototype.debug=function(e){this.log(j.DEBUG,e)},e.prototype.trace=function(e){this.log(j.TRACE,e)},e}(),Y=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.log=function(e,t){if(!(e>this._minLevel)){var n=$[e],r="["+this._name+"] "+t;this._timestamps&&(r="["+(new Date).toISOString()+"] "+t),n(r)}},n}(J),Z=function(){function e(e){var t,n=e.name,r=e.minLevel,i=e.custom;this._minLevel=null!==(t=g(r,(function(e){return F(e)})))&&void 0!==t?t:z(n),this._override="function"==typeof i?{log:i}:i}return e.prototype.log=function(e,t){this._shouldLog(e)&&this._override.log(e,t)},e.prototype.crit=function(e){this._override.crit?this._shouldLog(j.CRITICAL)&&this._override.crit(e):this.log(j.CRITICAL,e)},e.prototype.error=function(e){this._override.error?this._shouldLog(j.ERROR)&&this._override.error(e):this.log(j.ERROR,e)},e.prototype.warn=function(e){this._override.warn?this._shouldLog(j.WARNING)&&this._override.warn(e):this.log(j.WARNING,e)},e.prototype.info=function(e){this._override.info?this._shouldLog(j.INFO)&&this._override.info(e):this.log(j.INFO,e)},e.prototype.debug=function(e){this._override.debug?this._shouldLog(j.DEBUG)&&this._override.debug(e):this.log(j.DEBUG,e)},e.prototype.trace=function(e){this._override.trace?this._shouldLog(j.TRACE)&&this._override.trace(e):this.log(j.TRACE,e)},e.prototype._shouldLog=function(e){return void 0===this._minLevel||this._minLevel>=e},e}(),K=((q={})[j.CRITICAL]="🛑",q[j.ERROR]="❌",q[j.WARNING]="⚠️ ",q[j.INFO]="ℹ️ ",q[j.DEBUG]="🐞",q[j.TRACE]="🐾",q),X={black:30,red:31,green:32,yellow:33,blue:34,magenta:35,cyan:36,white:37,blackBright:90,redBright:91,greenBright:92,yellowBright:93,blueBright:94,magentaBright:95,cyanBright:96,whiteBright:97},ee={bgBlack:40,bgRed:41,bgGreen:42,bgYellow:43,bgBlue:44,bgMagenta:45,bgCyan:46,bgWhite:47,bgBlackBright:100,bgRedBright:101,bgGreenBright:102,bgYellowBright:103,bgBlueBright:104,bgMagentaBright:105,bgCyanBright:106,bgWhiteBright:107};function te(e,t,n){return function(r){return"["+e+"m"+(n?n(r):r)+"["+t+"m"}}function ne(e){return te(X[e],39)}function re(e,t){return te(ee[e],49,t)}var ie,se=((V={})[j.CRITICAL]=ne("red"),V[j.ERROR]=ne("redBright"),V[j.WARNING]=ne("yellow"),V[j.INFO]=ne("blue"),V[j.DEBUG]=ne("magenta"),V[j.TRACE]=te(0,0),V),oe=((Q={})[j.CRITICAL]=re("bgRed",ne("white")),Q[j.ERROR]=re("bgRedBright",ne("white")),Q[j.WARNING]=re("bgYellow",ne("black")),Q[j.INFO]=re("bgBlue",ne("white")),Q[j.DEBUG]=re("bgMagenta",ne("black")),Q[j.TRACE]=te(7,27),Q),ae=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.log=function(e,t){var n,r,i;if(!(e>this._minLevel)){var s=$[e],o="";this._timestamps&&(o+="["+(new Date).toISOString()+"] "),this._emoji&&(o+=K[e]+" "),s(o+=null===(i=null!==(n=this._colors)&&void 0!==n?n:null===(r=process.stdout)||void 0===r?void 0:r.isTTY)||void 0===i||i?oe[e](this._name)+" "+oe[e](j[e])+" "+se[e](t):"["+this._name+":"+j[e].toLowerCase()+"] "+t)}},n}(J);class ce extends l{constructor(e){super(`${e} - this should never happen, please file a bug in the GitHub issue tracker`)}}let ue=ie=class extends O{constructor(e){super(),this._topics=new Map,this._pingOnActivity=240,this._pingOnInactivity=60,this._pingTimeout=10,this._onPong=this.registerInternalEvent(),this._onResponse=this.registerInternalEvent(),this.onMessage=this.registerEvent(),this.onConnect=this.registerEvent(),this.onDisconnect=this.registerEvent(),this.onPong=this.registerEvent(),this._logger=function(e){return e.custom?new Z(e):A?new ae(e):new Y(e)}({name:"twurple:pubsub",emoji:!0,...null==e?void 0:e.logger}),this._connection=new E(P,{hostName:"pubsub-edge.twitch.tv",port:443,secure:!0},{logger:this._logger,additionalOptions:{wsOptions:null==e?void 0:e.wsOptions}}),this._connection.onConnect((async()=>{this._logger.info("Connection established"),this._pingCheck(),this._startActivityPingCheckTimer(),this._startInactivityPingCheckTimer(),await this._resendListens(),this._topics.size&&(this._logger.info("Listened to previously registered topics"),this._logger.debug(`Previously registered topics: ${Array.from(this._topics.keys()).join(", ")}`)),this.emit(this.onConnect)})),this._connection.onReceive((e=>{this._receiveMessage(e.trim()),this._startInactivityPingCheckTimer()})),this._connection.onDisconnect(((e,t)=>{clearInterval(this._activityPingCheckTimer),clearInterval(this._inactivityPingCheckTimer),clearTimeout(this._pingTimeoutTimer),this.removeInternalListener(),e?this._logger.info("Disconnected"):t?this._logger.error(`Disconnected unexpectedly: ${t.message}`):this._logger.error("Disconnected unexpectedly"),this.emit(this.onDisconnect,e,t)}))}async listen(e,t,n){"string"==typeof e&&(e=[e]);const r=ie._wrapResolvable(t,n);for(const t of e)this._topics.set(t,r);this.isConnected&&await this._sendListen(e,await this._resolveToken(r))}async unlisten(e){"string"==typeof e&&(e=[e]);for(const t of e)this._topics.delete(t);this.isConnected&&await this._sendUnlisten(e)}async connect(){this._connection.isConnected||this._connection.isConnecting||(this._logger.info("Connecting..."),await this._connection.connect())}async disconnect(){this._logger.info("Disconnecting..."),await this._connection.disconnect()}async reconnect(){await this.disconnect(),await this.connect()}get isConnecting(){return this._connection.isConnecting}get isConnected(){return this._connection.isConnected}get hasAnyTopics(){return this._topics.size>0}async _sendListen(e,t){await this._sendNonced(function(e,t){return{type:"LISTEN",data:{topics:e,auth_token:t}}}(e,t))}async _sendUnlisten(e){await this._sendNonced({type:"UNLISTEN",data:{topics:e}})}static _wrapResolvable(e,t){switch(typeof e){case"object":return"type"in e?e:{type:"provider",provider:e,scopes:t?[t]:[]};case"string":return{type:"static",token:e};case"function":return{type:"function",function:e};default:throw new ce("Passed unknown type to wrapResolvable: "+typeof e)}}async _resolveToken(e){switch(e.type){case"provider":{const{provider:t,scopes:n}=e,{accessToken:r}=await b(t,n,this._logger);return r.accessToken}case"function":return await e.function();case"static":return e.token;default:throw new ce(`Passed unknown type to resolveToken: ${e.type}`)}}async _resendListens(){const e=new Map;for(const[t,n]of this._topics)e.has(n)?e.get(n).push(t):e.set(n,[t]);const t=new Map;for(const[n,r]of e){const e=await this._resolveToken(n);t.has(e)?t.get(e).push(...r):t.set(e,r)}return await Promise.all(Array.from(t.entries()).map((async([e,t])=>await this._sendListen(t,e))))}async _sendNonced(e){await new Promise(((t,n)=>{const r=Math.random().toString(16).slice(2),i=this._onResponse(((s,o)=>{s===r&&(o?n(new Error(`Error sending nonced ${e.type} packet: ${o}`)):t(),i.unbind())}));e.nonce=r,this._sendPacket(e)}))}_receiveMessage(e){this._logger.debug(`Received message: ${e}`);const t=JSON.parse(e);switch(t.type){case"PONG":this.emit(this._onPong);break;case"RECONNECT":this.reconnect();break;case"RESPONSE":this.emit(this._onResponse,t.nonce,t.error);break;case"MESSAGE":this.emit(this.onMessage,t.data.topic,JSON.parse(t.data.message));break;default:this._logger.warn(`PubSub connection received unexpected message type: ${t.type}`)}}_sendPacket(e){const t=JSON.stringify(e);this._logger.debug(`Sending message: ${t}`),this._connection.sendLine(t)}_pingCheck(){const e=Date.now();this._onPong((()=>{const t=Date.now()-e;this.emit(this.onPong,t,e),this._logger.info(`Current latency: ${t}ms`),this._pingTimeoutTimer&&clearTimeout(this._pingTimeoutTimer),this.removeInternalListener(this._onPong)})),this._pingTimeoutTimer=setTimeout((async()=>{this._logger.error("Ping timeout"),this.removeInternalListener(this._onPong),this._connection.assumeExternalDisconnect()}),1e3*this._pingTimeout),this._sendPacket({type:"PING"})}_startActivityPingCheckTimer(){clearInterval(this._activityPingCheckTimer),this._connection.isConnected?this._activityPingCheckTimer=setInterval((()=>{this._startInactivityPingCheckTimer(),this._pingCheck()}),1e3*this._pingOnActivity):this._activityPingCheckTimer=void 0}_startInactivityPingCheckTimer(){clearInterval(this._inactivityPingCheckTimer),this._connection.isConnected?this._inactivityPingCheckTimer=setInterval((()=>{this._startActivityPingCheckTimer(),this._pingCheck()}),1e3*this._pingOnInactivity):this._inactivityPingCheckTimer=void 0}};n([r(!1)],ue.prototype,"_logger",void 0),n([r(!1)],ue.prototype,"_topics",void 0),ue=ie=n([s("pubsub","BasicPubSubClient")],ue);let le=class extends m{constructor(e,t){super(e),this._channelId=t}get channelId(){return this._channelId}get messageId(){return this[y].data.message.id}get messageContent(){return this[y].data.message.content.text}get foundMessageFragments(){return this[y].data.message.content.fragments}get senderId(){return this[y].data.message.sender.user_id}get senderName(){return this[y].data.message.sender.login}get senderDisplayName(){return this[y].data.message.sender.display_name}get senderColor(){return this[y].data.message.sender.chat_color}get sendDate(){return new Date(this[y].data.message.sent_at)}get contentClassification(){return this[y].data.content_classification}get status(){return this[y].data.status}get resolverId(){return this[y].data.resolver_id||null}get resolverName(){return this[y].data.resolver_login||null}};le=n([s("pubsub","PubSubAutoModQueueMessage","messageId")],le);let he=class extends m{get userId(){return this[y].data.user_id}get userName(){return this[y].data.user_name}get message(){return this[y].data.chat_message}get badgeTier(){return this[y].data.badge_tier}};he=n([s("pubsub","PubSubBitsBadgeUnlockMessage","userId")],he);let de=class extends m{get userId(){return this[y].data.user_id}get userName(){return this[y].data.user_name}get message(){return this[y].data.chat_message}get bits(){return this[y].data.bits_used}get totalBits(){return this[y].data.total_bits_used}get isAnonymous(){return this[y].data.is_anonymous}};de=n([s("pubsub","PubSubBitsMessage","userId")],de);let fe=class extends m{constructor(e,t){super(e),this._channelId=t}get channelId(){return this._channelId}get type(){return this[y].data.type}get action(){return this[y].data.moderation_action}get args(){return this[y].data.args}get userId(){return this[y].data.created_by_user_id}get userName(){return this[y].data.created_by}};fe=n([s("pubsub","PubSubChatModActionMessage","userId")],fe);let pe=class extends m{get data(){return this[y]}};pe=n([s("pubsub","PubSubCustomMessage")],pe);let ge=class extends m{get id(){return this[y].data.redemption.id}get userId(){return this[y].data.redemption.user.id}get userName(){return this[y].data.redemption.user.login}get userDisplayName(){return this[y].data.redemption.user.display_name}get channelId(){return this[y].data.redemption.channel_id}get redemptionDate(){return new Date(this[y].data.redemption.redeemed_at)}get rewardId(){return this[y].data.redemption.reward.id}get rewardTitle(){return this[y].data.redemption.reward.title}get rewardPrompt(){return this[y].data.redemption.reward.prompt}get rewardCost(){return this[y].data.redemption.reward.cost}get rewardIsQueued(){return!this[y].data.redemption.reward.should_redemptions_skip_request_queue}get rewardImage(){return this[y].data.redemption.reward.image}get defaultImage(){return this[y].data.redemption.reward.default_image}get message(){return this[y].data.redemption.user_input}get status(){return this[y].data.redemption.status}};ge=n([s("pubsub","PubSubRedemptionMessage","id")],ge);let ye=class extends m{get userId(){const e=this[y];return"subgift"===e.context||"anonsubgift"===e.context||"resubgift"===e.context||"anonresubgift"===e.context?e.recipient_id:e.user_id}get userName(){const e=this[y];return"subgift"===e.context||"anonsubgift"===e.context||"resubgift"===e.context||"anonresubgift"===e.context?e.recipient_user_name:e.user_name}get userDisplayName(){const e=this[y];return"subgift"===e.context||"anonsubgift"===e.context||"resubgift"===e.context||"anonresubgift"===e.context?e.recipient_display_name:e.display_name}get streakMonths(){const e=this[y];return"subgift"===e.context||"anonsubgift"===e.context||"resubgift"===e.context||"anonresubgift"===e.context?0:e.streak_months}get cumulativeMonths(){const e=this[y];return"subgift"===e.context||"anonsubgift"===e.context||"resubgift"===e.context||"anonresubgift"===e.context?e.months:e.cumulative_months}get months(){return this.cumulativeMonths}get time(){return new Date(this[y].time)}get message(){return"subgift"===this[y].context||"anonsubgift"===this[y].context?null:this[y].sub_message}get subPlan(){return this[y].sub_plan}get isResub(){return"resub"===this[y].context}get isGift(){return"subgift"===this[y].context||"resubgift"===this[y].context||"anonsubgift"===this[y].context||"anonresubgift"===this[y].context}get isAnonymous(){return"anonsubgift"===this[y].context||"anonresubgift"===this[y].context}get gifterId(){return this.isGift?this[y].user_id:null}get gifterName(){return this.isGift?this[y].user_name:null}get gifterDisplayName(){return this.isGift?this[y].display_name:null}get giftDuration(){const e=this[y];return"subgift"===e.context||"resubgift"===e.context||"anonsubgift"===e.context||"anonresubgift"===e.context?e.multi_month_duration:null}};ye=n([s("pubsub","PubSubSubscriptionMessage","userId")],ye);let me=class extends m{constructor(e,t){super(e),this._channelId=t}get channelId(){return this._channelId}get messageId(){return this[y].data.message_id}get status(){return this[y].data.status}};me=n([s("pubsub","PubSubUserModerationNotificationMessage","messageId")],me);let _e=class extends m{get text(){return this[y].data_object.body}get senderId(){return this[y].data_object.from_id.toString()}get senderName(){return this[y].data_object.tags.login}get senderDisplayName(){return this[y].data_object.tags.display_name}};_e=n([s("pubsub","PubSubWhisperMessage","senderId")],_e);let ve=class{constructor(e,t,n,r){this._topic=e,this._userId=t,this._callback=n,this._client=r}get topic(){return this._topic}get userId(){return this._userId}async remove(){await this._client.removeListener(this)}call(e){this._callback(e)}};var be;n([r(!1)],ve.prototype,"_client",void 0),ve=n([s("pubsub","PubSubListener","userId")],ve);let we=be=class{constructor(e){this._listeners=new Map;const{authProvider:t,pubSubClient:n,logger:r}=e;this._authProvider=t,this._pubSubClient=null!=n?n:new ue({logger:r}),this._pubSubClient.onMessage((async(e,t)=>{const[n,r,...i]=e.split(".");if(this._listeners.has(e)&&r===await this._getUserId()){const r=be._parseMessage(n,i,t);for(const t of this._listeners.get(e))t.call(r)}}))}async onAutoModQueue(e,t){return await this._addListener("automod-queue",t,"channel:moderate",I(e))}async onBits(e){return await this._addListener("channel-bits-events-v2",e,"bits:read")}async onBitsBadgeUnlock(e){return await this._addListener("channel-bits-badge-unlocks",e,"bits:read")}async onModAction(e,t){return await this._addListener("chat_moderator_actions",t,"channel:moderate",I(e))}async onRedemption(e){return await this._addListener("channel-points-channel-v1",e,"channel:read:redemptions")}async onUserModeration(e,t){return await this._addListener("user-moderation-notifications",t,"chat:read",I(e))}async onSubscription(e){return await this._addListener("channel-subscribe-events-v1",e,"channel:read:subscriptions")}async onWhisper(e){return await this._addListener("whispers",e,"whispers:read")}async onCustomTopic(e,t,n,r){return r?await this._addListener(e,t,n,I(r)):await this._addListener(e,t,n)}async removeListener(e){if(this._listeners.has(e.topic)){const t=this._listeners.get(e.topic).filter((t=>t!==e));0===t.length?(this._listeners.delete(e.topic),await this._pubSubClient.unlisten(`${e.topic}.${e.userId}`),this._pubSubClient.hasAnyTopics||!this._pubSubClient.isConnected&&!this._pubSubClient.isConnecting||await this._pubSubClient.disconnect()):this._listeners.set(e.topic,t)}}async removeAllListeners(){for(const e of this._listeners.values())for(const t of e)await this.removeListener(t)}static _parseMessage(e,t,n){switch(e){case"automod-queue":return new le(n,t[0]);case"channel-bits-events-v2":return new de(n);case"channel-bits-badge-unlocks":return new he(n);case"channel-points-channel-v1":return new ge(n);case"channel-subscribe-events-v1":return new ye(n);case"chat_moderator_actions":return new fe(n,t[0]);case"user-moderation-notifications":return new me(n,t[0]);case"whispers":return new _e(n);default:return new pe(n)}}async _getUserId(){if(this._userId)return this._userId;const{tokenInfo:e}=await b(this._authProvider);if(!e.userId)throw new k("Could not determine a user ID for your token; you might be trying to disguise an app token as a user token.");return this._userId=e.userId}async _addListener(e,t,n,...r){await this._pubSubClient.connect();const i=await this._getUserId(),s=[e,i,...r].join("."),o=new ve(s,i,t,this);return this._listeners.has(s)?this._listeners.get(s).push(o):(this._listeners.set(s,[o]),await this._pubSubClient.listen(s,this._authProvider,n)),o}};var Ce;n([r(!1)],we.prototype,"_authProvider",void 0),n([r(!1)],we.prototype,"_pubSubClient",void 0),we=be=n([s("pubsub","SingleUserPubSubClient")],we);let ke=Ce=class{constructor(e){this._userClients=new Map,this._rootClient=null!=e?e:new ue}async registerUserListener(e,t){const n=await Ce._getCorrectUserId(e,t);return this._userClients.set(n,new we({authProvider:e,pubSubClient:this._rootClient})),n}getUserListener(e){const t=I(e);if(!this._userClients.has(t))throw new Error(`No auth provider registered for user ID ${t}\nRegister one using:\n\n\tpubSubClient.registerUserListener(authProvider);`);return this._userClients.get(t)}async onAutoModQueue(e,t,n){return await this.getUserListener(e).onAutoModQueue(t,n)}async onBits(e,t){return await this.getUserListener(e).onBits(t)}async onBitsBadgeUnlock(e,t){return await this.getUserListener(e).onBitsBadgeUnlock(t)}async onModAction(e,t,n){return await this.getUserListener(e).onModAction(t,n)}async onRedemption(e,t){return await this.getUserListener(e).onRedemption(t)}async onSubscription(e,t){return await this.getUserListener(e).onSubscription(t)}async onUserModeration(e,t,n){return await this.getUserListener(e).onUserModeration(t,n)}async onWhisper(e,t){return await this.getUserListener(e).onWhisper(t)}async onCustomTopic(e,t,n,r,i){return await this.getUserListener(e).onCustomTopic(t,n,r,i)}static async _getCorrectUserId(e,t){if(t)return I(t);{if("app"===e.tokenType)throw new k("App tokens are not supported by PubSubClient; you need to pass authentication representing a user.");const{tokenInfo:t}=await b(e);if(!t.userId)throw new k("Could not determine a user ID for your token; you might be trying to disguise an app token as a user token.");return t.userId}}};n([r(!1)],ke.prototype,"_rootClient",void 0),n([r(!1)],ke.prototype,"_userClients",void 0),ke=Ce=n([s("pubsub","PubSubClient")],ke);var Ie,xe,Se,Oe=i(104),Ee=i(227),Re=i(729),Le=i(792),Pe=i(153),Te=i(269);function je(){return je=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},je.apply(this,arguments)}!function(e){e[e.Hello=0]="Hello",e[e.Identify=1]="Identify",e[e.Identified=2]="Identified",e[e.Reidentify=3]="Reidentify",e[e.Event=5]="Event",e[e.Request=6]="Request",e[e.RequestResponse=7]="RequestResponse",e[e.RequestBatch=8]="RequestBatch",e[e.RequestBatchResponse=9]="RequestBatchResponse"}(Ie||(Ie={})),function(e){e[e.None=0]="None",e[e.General=1]="General",e[e.Config=2]="Config",e[e.Scenes=4]="Scenes",e[e.Inputs=8]="Inputs",e[e.Transitions=16]="Transitions",e[e.Filters=32]="Filters",e[e.Outputs=64]="Outputs",e[e.SceneItems=128]="SceneItems",e[e.MediaInputs=256]="MediaInputs",e[e.Vendors=512]="Vendors",e[e.Ui=1024]="Ui",e[e.All=1023]="All",e[e.InputVolumeMeters=65536]="InputVolumeMeters",e[e.InputActiveStateChanged=131072]="InputActiveStateChanged",e[e.InputShowStateChanged=262144]="InputShowStateChanged",e[e.SceneItemTransformChanged=524288]="SceneItemTransformChanged"}(xe||(xe={})),function(e){e[e.None=-1]="None",e[e.SerialRealtime=0]="SerialRealtime",e[e.SerialFrame=1]="SerialFrame",e[e.Parallel=2]="Parallel"}(Se||(Se={}));const Ne=["authentication","rpcVersion"],Ae=Ee("obs-websocket-js");class Fe extends Error{constructor(e,t){super(t),this.code=void 0,this.code=e}}class Be extends Re{constructor(...e){super(...e),this._identified=!1,this.internalListeners=new Re,this.socket=void 0}static generateMessageId(){return String(Be.requestCounter++)}get identified(){return this._identified}async connect(e="ws://127.0.0.1:4455",t,n={}){var r=this;this.socket&&await this.disconnect();try{const i=this.internalEventPromise("ConnectionClosed"),s=this.internalEventPromise("ConnectionError");return await Promise.race([async function(){const i=await r.createConnection(e);return r.emit("Hello",i),r.identify(i,t,n)}(),new Promise(((e,t)=>{s.then((e=>{e.message&&t(e)})),i.then((e=>{t(e)}))}))])}catch(e){throw await this.disconnect(),e}}async disconnect(){if(!this.socket||this.socket.readyState===Le.CLOSED)return;const e=this.internalEventPromise("ConnectionClosed");this.socket.close(),await e}async reidentify(e){const t=this.internalEventPromise(`op:${Ie.Identified}`);return await this.message(Ie.Reidentify,e),t}async call(e,t){const n=Be.generateMessageId(),r=this.internalEventPromise(`res:${n}`);await this.message(Ie.Request,{requestId:n,requestType:e,requestData:t});const{requestStatus:i,responseData:s}=await r;if(!i.result)throw new Fe(i.code,i.comment);return s}async callBatch(e,t={}){const n=Be.generateMessageId(),r=this.internalEventPromise(`res:${n}`);await this.message(Ie.RequestBatch,je({requestId:n,requests:e},t));const{results:i}=await r;return i}cleanup(){this.socket&&(this.socket.onopen=null,this.socket.onmessage=null,this.socket.onerror=null,this.socket.onclose=null,this.socket=void 0,this._identified=!1,this.internalListeners.removeAllListeners())}async createConnection(e){var t;const n=this.internalEventPromise("ConnectionOpened"),r=this.internalEventPromise(`op:${Ie.Hello}`);this.socket=new Le(e,this.protocol),this.socket.onopen=this.onOpen.bind(this),this.socket.onmessage=this.onMessage.bind(this),this.socket.onerror=this.onError.bind(this),this.socket.onclose=this.onClose.bind(this),await n;const i=null==(t=this.socket)?void 0:t.protocol;if(!i)throw new Fe(-1,"Server sent no subprotocol");if(i!==this.protocol)throw new Fe(-1,"Server sent an invalid subprotocol");return r}async identify(e,t,n={}){let{authentication:r,rpcVersion:i}=e,s=function(e,t){if(null==e)return{};var n,r,i={},s=Object.keys(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,Ne);const o=je({rpcVersion:i},n);r&&t&&(o.authentication=function(e,t,n){const r=Te.stringify(Pe(n+e));return Te.stringify(Pe(r+t))}(r.salt,r.challenge,t));const a=this.internalEventPromise(`op:${Ie.Identified}`);await this.message(Ie.Identify,o);const c=await a;return this._identified=!0,this.emit("Identified",c),je({rpcVersion:i},s,c)}async message(e,t){if(!this.socket)throw new Error("Not connected");if(!this.identified&&1!==e)throw new Error("Socket not identified");const n=await this.encodeMessage({op:e,d:t});this.socket.send(n)}async internalEventPromise(e){return new Promise((t=>{this.internalListeners.once(e,t)}))}onOpen(e){Ae("socket.open"),this.emit("ConnectionOpened"),this.internalListeners.emit("ConnectionOpened",e)}async onMessage(e){try{const{op:t,d:n}=await this.decodeMessage(e.data);if(Ae("socket.message: %d %j",t,n),void 0===t||void 0===n)return;switch(t){case Ie.Event:{const{eventType:e,eventData:t}=n;return void this.emit(e,t)}case Ie.RequestResponse:case Ie.RequestBatchResponse:{const{requestId:e}=n;return void this.internalListeners.emit(`res:${e}`,n)}default:this.internalListeners.emit(`op:${t}`,n)}}catch(e){Ae("error handling message: %o",e)}}onError(e){Ae("socket.error: %o",e);const t=new Fe(-1,e.message);this.emit("ConnectionError",t),this.internalListeners.emit("ConnectionError",t)}onClose(e){Ae("socket.close: %s (%d)",e.reason,e.code);const t=new Fe(e.code,e.reason);this.emit("ConnectionClosed",t),this.internalListeners.emit("ConnectionClosed",t),this.cleanup()}}Be.requestCounter=1,"undefined"!=typeof exports&&Object.defineProperty(exports,"__esModule",{value:!0});const Me=new class extends Be{constructor(...e){super(...e),this.protocol="obswebsocket.json"}async encodeMessage(e){return JSON.stringify(e)}async decodeMessage(e){return JSON.parse(e)}},De=new ke;function $e(e,t=window.location.href){e=e.replace(/[\[\]]/g,"\\$&");var n=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(t);return n?n[2]?decodeURIComponent(n[2].replace(/\+/g," ")):"":null}document.getElementById("muteImage");const Ue={password:$e("obspw"),token:$e("token"),rewardName:$e("rewardname"),source:$e("sourcename"),time:$e("time"),filteramount:$e("filteramount")};var We=!1,Ge=[];const He=1e3*Ue.time;var ze=new Oe.Timeout(He);async function qe(e){We?We&&(await Me.call("GetSourceFilterList",{sourceName:Ue.source}),Ge.push(e)):(console.log("Enabling random filter..."),We=!0,Me.call("SetSourceFilterEnabled",{sourceName:Ue.source,filterName:e,filterEnabled:!0}),ze.start((()=>{console.log("Disabled filter"),Me.call("SetSourceFilterEnabled",{sourceName:Ue.source,filterName:e,filterEnabled:!1}),ze=new Oe.Timeout(He),We=!1,Ge.length>0&&qe(Ge.shift())})))}!async function(){const e=new C("f3l7ldc6zwtdunaoe53rzms4icn0pl",Ue.token),t=await De.registerUserListener(e);document.getElementById("counter");try{const{obsWebSocketVersion:e,negotiatedRpcVersion:t}=await Me.connect("ws://127.0.0.1:4455",Ue.password);console.log(`Connected to server ${e} (using RPC ${t})`)}catch(e){console.error("Failed to connect",e.code,e.message)}await De.onRedemption(t,(async e=>{if(e.rewardTitle!=Ue.rewardName)return;const t=await Me.call("GetSourceFilterList",{sourceName:Ue.source}),n=t.filters.findIndex((t=>t.filterName.toLowerCase()===e.message.trim().toLowerCase()));var r;console.log(n),qe(-1==n?t.filters[(r=Ue.filteramount-1,Math.floor(Math.random()*r))].filterName:t.filters[n].filterName)}))}()})()})();