tiny-essentials 1.10.1 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +1 -1
  2. package/dist/{TinyBasicsEs.js → v1/TinyBasicsEs.js} +2 -2
  3. package/dist/{TinyEssentials.js → v1/TinyEssentials.js} +806 -2
  4. package/dist/v1/TinyEssentials.min.js +2 -0
  5. package/dist/v1/TinyNotifyCenter.js +461 -0
  6. package/dist/v1/TinyNotifyCenter.min.js +1 -0
  7. package/dist/v1/TinyToastNotify.js +417 -0
  8. package/dist/v1/TinyToastNotify.min.js +1 -0
  9. package/dist/v1/basics/objFilter.cjs +2 -2
  10. package/dist/v1/basics/objFilter.d.mts +2 -2
  11. package/dist/v1/basics/objFilter.mjs +2 -2
  12. package/dist/v1/build/TinyNotifyCenter.cjs +7 -0
  13. package/dist/v1/build/TinyNotifyCenter.d.mts +3 -0
  14. package/dist/v1/build/TinyNotifyCenter.mjs +2 -0
  15. package/dist/v1/build/TinyToastNotify.cjs +7 -0
  16. package/dist/v1/build/TinyToastNotify.d.mts +3 -0
  17. package/dist/v1/build/TinyToastNotify.mjs +2 -0
  18. package/dist/v1/css/TinyNotify.css +350 -0
  19. package/dist/v1/css/TinyNotify.min.css +1 -0
  20. package/dist/v1/index.cjs +4 -0
  21. package/dist/v1/index.d.mts +3 -1
  22. package/dist/v1/index.mjs +3 -1
  23. package/dist/v1/libs/TinyNotifyCenter.cjs +422 -0
  24. package/dist/v1/libs/TinyNotifyCenter.d.mts +166 -0
  25. package/dist/v1/libs/TinyNotifyCenter.mjs +385 -0
  26. package/dist/v1/libs/TinyToastNotify.cjs +378 -0
  27. package/dist/v1/libs/TinyToastNotify.d.mts +157 -0
  28. package/dist/v1/libs/TinyToastNotify.mjs +332 -0
  29. package/docs/{README.md → v1/README.md} +2 -0
  30. package/docs/{basics → v1/basics}/text.md +2 -2
  31. package/docs/v1/libs/TinyNotifyCenter.md +291 -0
  32. package/docs/v1/libs/TinyToastNotify.md +290 -0
  33. package/package.json +4 -2
  34. package/dist/TinyEssentials.min.js +0 -2
  35. package/dist/v1/libs/TinyRateLimit.cjs +0 -196
  36. package/dist/v1/libs/TinyRateLimit.d.mts +0 -86
  37. package/dist/v1/libs/TinyRateLimit.mjs +0 -171
  38. /package/dist/{ColorSafeStringify.js → v1/ColorSafeStringify.js} +0 -0
  39. /package/dist/{ColorSafeStringify.min.js → v1/ColorSafeStringify.min.js} +0 -0
  40. /package/dist/{TinyBasicsEs.min.js → v1/TinyBasicsEs.min.js} +0 -0
  41. /package/dist/{TinyBasicsEs.min.js.LICENSE.txt → v1/TinyBasicsEs.min.js.LICENSE.txt} +0 -0
  42. /package/dist/{TinyEssentials.min.js.LICENSE.txt → v1/TinyEssentials.min.js.LICENSE.txt} +0 -0
  43. /package/dist/{TinyLevelUp.js → v1/TinyLevelUp.js} +0 -0
  44. /package/dist/{TinyLevelUp.min.js → v1/TinyLevelUp.min.js} +0 -0
  45. /package/dist/{TinyPromiseQueue.js → v1/TinyPromiseQueue.js} +0 -0
  46. /package/dist/{TinyPromiseQueue.min.js → v1/TinyPromiseQueue.min.js} +0 -0
  47. /package/dist/{TinyRateLimiter.js → v1/TinyRateLimiter.js} +0 -0
  48. /package/dist/{TinyRateLimiter.min.js → v1/TinyRateLimiter.min.js} +0 -0
  49. /package/dist/{aiMarker.css → v1/css/aiMarker.css} +0 -0
  50. /package/dist/{aiMarker.min.css → v1/css/aiMarker.min.css} +0 -0
  51. /package/docs/{basics → v1/basics}/array.md +0 -0
  52. /package/docs/{basics → v1/basics}/asyncReplace.md +0 -0
  53. /package/docs/{basics → v1/basics}/clock.md +0 -0
  54. /package/docs/{basics → v1/basics}/objFilter.md +0 -0
  55. /package/docs/{basics → v1/basics}/simpleMath.md +0 -0
  56. /package/docs/{libs → v1/libs}/ColorSafeStringify.md +0 -0
  57. /package/docs/{libs → v1/libs}/TinyLevelUp.md +0 -0
  58. /package/docs/{libs → v1/libs}/TinyPromiseQueue.md +0 -0
  59. /package/docs/{libs → v1/libs}/TinyRateLimiter.md +0 -0
@@ -0,0 +1,2 @@
1
+ /*! For license information please see TinyEssentials.min.js.LICENSE.txt */
2
+ (()=>{var e={251:(e,t)=>{t.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,l=u>>1,f=-7,h=r?i-1:0,c=r?-1:1,p=e[t+h];for(h+=c,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+e[t+h],h+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+h],h+=c,f-=8);if(0===o)o=1-l;else{if(o===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=l}return(p?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,u,l=8*o-i-1,f=(1<<l)-1,h=f>>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+h>=1?c/u:c*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(t*u-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;e[r+p]=255&s,p+=d,s/=256,l-=8);e[r+p-d]|=128*m}},287:(e,t,r)=>{"use strict";var n=r(526),i=r(251),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.hp=u,t.IS=50;var s=2147483647;function a(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,u.prototype),t}function u(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return l(e,t,r)}function l(e,t,r){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!u.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|m(e,t),n=a(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(G(e,Uint8Array)){var t=new Uint8Array(e);return p(t.buffer,t.byteOffset,t.byteLength)}return c(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(G(e,ArrayBuffer)||e&&G(e.buffer,ArrayBuffer))return p(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(G(e,SharedArrayBuffer)||e&&G(e.buffer,SharedArrayBuffer)))return p(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return u.from(n,t,r);var i=function(e){if(u.isBuffer(e)){var t=0|d(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||F(e.length)?a(0):c(e):"Buffer"===e.type&&Array.isArray(e.data)?c(e.data):void 0}(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return u.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function f(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function h(e){return f(e),a(e<0?0:0|d(e))}function c(e){for(var t=e.length<0?0:0|d(e.length),r=a(t),n=0;n<t;n+=1)r[n]=255&e[n];return r}function p(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(n,u.prototype),n}function d(e){if(e>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function m(e,t){if(u.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||G(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return $(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return H(e).length;default:if(i)return n?-1:$(e).length;t=(""+t).toLowerCase(),i=!0}}function g(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,r);case"utf8":case"utf-8":return A(this,t,r);case"ascii":return C(this,t,r);case"latin1":case"binary":return B(this,t,r);case"base64":return N(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function v(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),F(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:b(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):b(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;o<a;o++)if(l(e,o)===l(t,-1===f?0:o-f)){if(-1===f&&(f=o),o-f+1===u)return f*s}else-1!==f&&(o-=o-f),f=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){for(var h=!0,c=0;c<u;c++)if(l(e,o+c)!==l(t,c)){h=!1;break}if(h)return o}return-1}function w(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(F(a))return s;e[r+s]=a}return s}function E(e,t,r,n){return j($(t,e.length-r),e,r,n)}function x(e,t,r,n){return j(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function T(e,t,r,n){return j(H(t),e,r,n)}function L(e,t,r,n){return j(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function N(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function A(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o,s,a,u,l=e[i],f=null,h=l>239?4:l>223?3:l>191?2:1;if(i+h<=r)switch(h){case 1:l<128&&(f=l);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&l)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&l)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(e){var t=e.length;if(t<=M)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=M));return r}(n)}u.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(e,t,r){return l(e,t,r)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(e,t,r){return function(e,t,r){return f(e),e<=0?a(e):void 0!==t?"string"==typeof r?a(e).fill(t,r):a(e).fill(t):a(e)}(e,t,r)},u.allocUnsafe=function(e){return h(e)},u.allocUnsafeSlow=function(e){return h(e)},u.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==u.prototype},u.compare=function(e,t){if(G(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),G(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=u.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var o=e[r];if(G(o,Uint8Array))i+o.length>n.length?u.from(o).copy(n,i):Uint8Array.prototype.set.call(n,o,i);else{if(!u.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i)}i+=o.length}return n},u.byteLength=m,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},u.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},u.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},u.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?A(this,0,e):g.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",r=t.IS;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},o&&(u.prototype[o]=u.prototype.inspect),u.prototype.compare=function(e,t,r,n,i){if(G(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),l=this.slice(n,i),f=e.slice(t,r),h=0;h<a;++h)if(l[h]!==f[h]){o=l[h],s=f[h];break}return o<s?-1:s<o?1:0},u.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},u.prototype.indexOf=function(e,t,r){return v(this,e,t,r,!0)},u.prototype.lastIndexOf=function(e,t,r){return v(this,e,t,r,!1)},u.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return w(this,e,t,r);case"utf8":case"utf-8":return E(this,e,t,r);case"ascii":case"latin1":case"binary":return x(this,e,t,r);case"base64":return T(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var M=4096;function C(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function B(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function I(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=t;o<r;++o)i+=_[e[o]];return i}function S(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function D(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function k(e,t,r,n,i,o){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function O(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function U(e,t,r,n,o){return t=+t,r>>>=0,o||O(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function P(e,t,r,n,o){return t=+t,r>>>=0,o||O(e,0,r,8),i.write(e,t,r,n,52,8),r+8}u.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var n=this.subarray(e,t);return Object.setPrototypeOf(n,u.prototype),n},u.prototype.readUintLE=u.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||D(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},u.prototype.readUintBE=u.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||D(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},u.prototype.readUint8=u.prototype.readUInt8=function(e,t){return e>>>=0,t||D(e,1,this.length),this[e]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,t){return e>>>=0,t||D(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,t){return e>>>=0,t||D(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,t){return e>>>=0,t||D(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(e,t){return e>>>=0,t||D(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||D(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||D(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},u.prototype.readInt8=function(e,t){return e>>>=0,t||D(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){e>>>=0,t||D(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){e>>>=0,t||D(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return e>>>=0,t||D(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return e>>>=0,t||D(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return e>>>=0,t||D(e,4,this.length),i.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return e>>>=0,t||D(e,4,this.length),i.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return e>>>=0,t||D(e,8,this.length),i.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return e>>>=0,t||D(e,8,this.length),i.read(this,e,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||k(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||k(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||k(this,e,t,1,255,0),this[t]=255&e,t+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||k(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||k(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||k(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||k(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);k(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);k(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},u.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||k(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||k(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||k(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||k(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||k(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},u.prototype.writeFloatLE=function(e,t,r){return U(this,e,t,!0,r)},u.prototype.writeFloatBE=function(e,t,r){return U(this,e,t,!1,r)},u.prototype.writeDoubleLE=function(e,t,r){return P(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return P(this,e,t,!1,r)},u.prototype.copy=function(e,t,r,n){if(!u.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i=n-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,n):Uint8Array.prototype.set.call(e,this.subarray(r,n),t),i},u.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var i=e.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(e=i)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var s=u.isBuffer(e)?e:u.from(e,n),a=s.length;if(0===a)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<r-t;++o)this[o+t]=s[o%a]}return this};var R=/[^+/0-9A-Za-z-_]/g;function $(e,t){var r;t=t||1/0;for(var n=e.length,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function H(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(R,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function j(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function G(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function F(e){return e!=e}var _=function(){for(var e="0123456789abcdef",t=new Array(256),r=0;r<16;++r)for(var n=16*r,i=0;i<16;++i)t[n+i]=e[r]+e[i];return t}()},526:(e,t)=>{"use strict";t.byteLength=function(e){var t=a(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,o=a(e),s=o[0],u=o[1],l=new i(function(e,t,r){return 3*(t+r)/4-r}(0,s,u)),f=0,h=u>0?s-4:s;for(r=0;r<h;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],l[f++]=t>>16&255,l[f++]=t>>8&255,l[f++]=255&t;return 2===u&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,l[f++]=255&t),1===u&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,l[f++]=t>>8&255,l[f++]=255&t),l},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],s=16383,a=0,l=n-i;a<l;a+=s)o.push(u(e,a,a+s>l?l:a+s));return 1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,n){for(var i,o,s=[],a=t;a<n;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";async function e(e,t,r){const n=[];e.replace(t,((e,...t)=>(n.push(r(e,...t)),e)));const i=await Promise.all(n);return e.replace(t,(()=>i.shift()))}r.r(n),r.d(n,{ColorSafeStringify:()=>B,TinyLevelUp:()=>t,TinyNotifyCenter:()=>k,TinyPromiseQueue:()=>I,TinyRateLimiter:()=>S,TinyToastNotify:()=>O,addAiMarkerShortcut:()=>M,arraySortPositions:()=>i,asyncReplace:()=>e,checkObj:()=>v,cloneObjTypeOrder:()=>m,countObj:()=>b,extendObjType:()=>p,formatBytes:()=>L,formatCustomTimer:()=>a,formatDayTimer:()=>l,formatTimer:()=>u,getAge:()=>T,getSimplePerc:()=>x,getTimeDuration:()=>s,isJsonObject:()=>w,objType:()=>y,reorderObjTypeOrder:()=>d,ruleOfThree:()=>E,shuffleArray:()=>o,toTitleCase:()=>N,toTitleCaseLowerFirst:()=>A});const t=class{constructor(e,t){if("number"!=typeof e||Number.isNaN(e))throw new Error("giveExp must be a valid number");if("number"!=typeof t||Number.isNaN(t))throw new Error("expLevel must be a valid number");this.giveExp=e,this.expLevel=t}createUser(){return{exp:0,level:1,totalExp:0}}validateUser(e){if("number"!=typeof e.exp||Number.isNaN(e.exp))throw new Error("exp must be a valid number");if("number"!=typeof e.level||Number.isNaN(e.level))throw new Error("level must be a valid number");if(e.level<1)throw new Error("level must be at least 1");if("number"!=typeof e.totalExp||Number.isNaN(e.totalExp))throw new Error("totalExp must be a valid number")}isValidUser(e){return!("number"!=typeof e.exp||Number.isNaN(e.exp)||"number"!=typeof e.level||Number.isNaN(e.level)||e.level<1||"number"!=typeof e.totalExp||Number.isNaN(e.totalExp))}getGiveExpBase(){if("number"!=typeof this.giveExp||Number.isNaN(this.giveExp))throw new Error("giveExp must be a valid number");return this.giveExp}getExpLevelBase(){if("number"!=typeof this.expLevel||Number.isNaN(this.expLevel))throw new Error("expLevel must be a valid number");return this.expLevel}expValidator(e){const t=this.getExpLevelBase();this.validateUser(e);let r=0;const n=t*e.level;return e.exp>=n&&(e.level++,r=e.exp-n,e.exp=0,r>0)?this.give(e,r,"extra"):e.exp<1&&e.level>1&&(e.level--,r=Math.abs(e.exp),e.exp=t*e.level,r>0)?this.remove(e,r,"extra"):e}getTotalExp(e){this.validateUser(e);let t=0;for(let r=1;r<=e.level;r++)t+=this.getExpLevelBase()*r;return t+=e.exp,t}expGenerator(e=1){if("number"!=typeof e||Number.isNaN(e))throw new Error("multi must be a valid number");return Math.floor(Math.random()*this.getGiveExpBase())*e}getMissingExp(e){return this.getProgress(e)-e.exp}progress(e){return this.getProgress(e)}getProgress(e){return this.validateUser(e),this.getExpLevelBase()*e.level}set(e,t){if("number"!=typeof t||Number.isNaN(t))throw new Error("value must be a valid number");return e.exp=t,this.expValidator(e),e.totalExp=this.getTotalExp(e),e}give(e,t=0,r="add",n=1){if("number"!=typeof n||Number.isNaN(n))throw new Error("multi must be a valid number");if("number"!=typeof t||Number.isNaN(t))throw new Error("extraExp must be a valid number");if("string"!=typeof r)throw new Error("type must be a valid string");return"add"===r?e.exp+=this.expGenerator(n)+t:"extra"===r&&(e.exp+=t),this.expValidator(e),e.totalExp=this.getTotalExp(e),e}remove(e,t=0,r="add",n=1){if("number"!=typeof n||Number.isNaN(n))throw new Error("multi must be a valid number");if("number"!=typeof t||Number.isNaN(t))throw new Error("extraExp must be a valid number");if("string"!=typeof r)throw new Error("type must be a valid string");return"add"===r?e.exp-=this.expGenerator(n)+t:"extra"===r&&(e.exp-=t),this.expValidator(e),e.totalExp=this.getTotalExp(e),e}};function i(e,t=!1){return t?function(t,r){return t[e]>r[e]?-1:t[e]<r[e]?1:0}:function(t,r){return t[e]<r[e]?-1:t[e]>r[e]?1:0}}function o(e){let t,r=e.length;for(;0!==r;)t=Math.floor(Math.random()*r),r--,[e[r],e[t]]=[e[t],e[r]];return e}function s(e=new Date,t="asSeconds",r=null){if(e instanceof Date){const n=r instanceof Date?r:new Date,i=e.getTime()-n.getTime();switch(t){case"asMilliseconds":return i;case"asSeconds":default:return i/1e3;case"asMinutes":return i/6e4;case"asHours":return i/36e5;case"asDays":return i/864e5}}return null}function a(e,t="seconds",r="{time}"){e=Math.max(0,Math.floor(e));const n=["seconds","minutes","hours","days","months","years"].indexOf(t),i=n>=5,o=n>=4,s=n>=3,a=n>=2,u=n>=1,l=n>=0,f={years:i?0:NaN,months:o?0:NaN,days:s?0:NaN,hours:a?0:NaN,minutes:u?0:NaN,seconds:l?0:NaN,total:NaN};let h=e;if(i||o||s){const e=new Date(1980,0,1),t=new Date(e.getTime()+1e3*h),r=new Date(e);if(i)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),f.years++;if(o)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),f.months++;if(s)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),f.days++;h=Math.floor((t.getTime()-r.getTime())/1e3)}a&&(f.hours=Math.floor(h/3600),h%=3600),u&&(f.minutes=Math.floor(h/60),h%=60),l&&(f.seconds=h);const c={seconds:l?e:NaN,minutes:u?e/60:NaN,hours:a?e/3600:NaN,days:s?e/86400:NaN,months:o?12*f.years+f.months+(f.days||0)/30:NaN,years:i?f.years+(f.months||0)/12+(f.days||0)/365:NaN};f.total=+(c[t]||0).toFixed(2).replace(/\.00$/,"");const p=e=>{const t="string"==typeof e?parseInt(e):e;return Number.isNaN(t)?"NaN":String(t).padStart(2,"0")},d=[a?p(f.hours):null,u?p(f.minutes):null,l?p(f.seconds):null].filter((e=>null!==e)).join(":");return r.replace(/\{years\}/g,String(f.years)).replace(/\{months\}/g,String(f.months)).replace(/\{days\}/g,String(f.days)).replace(/\{hours\}/g,p(f.hours)).replace(/\{minutes\}/g,p(f.minutes)).replace(/\{seconds\}/g,p(f.seconds)).replace(/\{time\}/g,d).replace(/\{total\}/g,String(f.total)).trim()}function u(e){return a(e,"hours","{hours}:{minutes}:{seconds}")}function l(e){return a(e,"days","{days}d {hours}:{minutes}:{seconds}")}var f=r(287);const h="undefined"!=typeof window&&void 0!==window.document,c={items:{},order:[]};function p(e,t){const r=[],n=Array.isArray(e)?e:Object.entries(e);for(const[e,i]of n)if(!c.items.hasOwnProperty(e)){c.items[e]=i;let n="number"==typeof t?t:-1;if(-1===n){const e=c.order.indexOf("object");n=e>-1?e:c.order.length}n=Math.min(Math.max(0,n),c.order.length),c.order.splice(n,0,e),r.push(e)}return r}function d(e){const t=[...c.order];return!!e.every((e=>t.includes(e)))&&(c.order=e.slice(),!0)}function m(){return[...c.order]}const g=e=>{if(null===e)return"null";for(const t of c.order)if("function"!=typeof c.items[t]||c.items[t](e))return t;return"unknown"};function y(e,t){if(void 0===e)return null;const r=g(e);return"string"==typeof t?r===t.toLowerCase():r}function v(e){const t={valid:null,type:null};for(const r of c.order)if("function"==typeof c.items[r]){const n=c.items[r](e);if(n){t.valid=n,t.type=r;break}}return t}function b(e){return Array.isArray(e)?e.length:y(e,"object")?Object.keys(e).length:0}function w(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}function E(e,t,r,n=!1){return n?Number(e*t)/r:Number(r*t)/e}function x(e,t){return e*(t/100)}function T(e=0,t=null){if(null!=e&&0!==e){const r=new Date(e);if(Number.isNaN(r.getTime()))return null;const n=t instanceof Date?t:new Date;let i=n.getFullYear()-r.getFullYear();const o=n.getMonth(),s=r.getMonth(),a=n.getDate(),u=r.getDate();return(o<s||o===s&&a<u)&&i--,Math.abs(i)}return null}function L(e,t=null,r=null){if("number"!=typeof e||e<0)return{unit:null,value:null};if(0===e)return{unit:"Bytes",value:0};const n=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],i=r&&n.includes(r)?n.indexOf(r):n.length-1,o=Math.min(Math.floor(Math.log(e)/Math.log(1024)),i);let s=e/Math.pow(1024,o);if(null!==t){const e=t<0?0:t;s=parseFloat(s.toFixed(e))}return{unit:n[o],value:s}}function N(e){return e.replace(/\w\S*/g,(e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()))}function A(e){const t=e.replace(/\w\S*/g,(e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()));return t.charAt(0).toLowerCase()+t.slice(1)}function M(e="a"){"undefined"!=typeof HTMLElement?document.addEventListener("keydown",(function(t){if(t.ctrlKey&&t.altKey&&t.key.toLowerCase()===e){if(t.preventDefault(),!document.body)return void console.warn("[AiMarkerShortcut] <body> element not found. Cannot toggle class. Ensure the DOM is fully loaded when using the shortcut.");document.body.classList.toggle("detect-made-by-ai")}})):console.error("[AiMarkerShortcut] Environment does not support the DOM. This function must be run in a browser.")}p([["undefined",e=>void 0===e],["null",e=>null===e],["boolean",e=>"boolean"==typeof e],["number",e=>"number"==typeof e&&!Number.isNaN(e)],["bigint",e=>"bigint"==typeof e],["string",e=>"string"==typeof e],["symbol",e=>"symbol"==typeof e],["function",e=>"function"==typeof e],["array",e=>Array.isArray(e)]]),h||p([["buffer",e=>void 0!==f.hp&&f.hp.isBuffer(e)]]),h&&p([["file",e=>"undefined"!=typeof File&&e instanceof File]]),p([["date",e=>e instanceof Date],["regexp",e=>e instanceof RegExp],["map",e=>e instanceof Map],["set",e=>e instanceof Set],["weakmap",e=>e instanceof WeakMap],["weakset",e=>e instanceof WeakSet],["promise",e=>e instanceof Promise]]),h&&p([["htmlelement",e=>"undefined"!=typeof HTMLElement&&e instanceof HTMLElement]]),p([["object",e=>w(e)]]);class C{#e;static#t={default:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""},solarized:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""},monokai:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""}};constructor(e={}){this.#e={...C.#t.default,...e}}#r(e,t){const r=[];e=(e=(e=e.replace(/(?<!")\b(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b(?!")/g,`${t.number}$1${t.reset}`)).replace(/"([^"]+)":/g,((e,t)=>{const n=`___KEY${r.length}___`;return r.push({marker:n,key:t}),`${n}:`}))).replace(/"(?:\\.|[^"\\])*?"/g,(e=>{const r=e.slice(1,-1);return/^(https?|ftp):\/\/[^\s]+$/i.test(r)?`${t.string_url}${e}${t.reset}`:/^(true|false|null)$/.test(r)?`${t.string_bool}${e}${t.reset}`:/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(r)?`${t.string_number}${e}${t.reset}`:`${t.string}${e}${t.reset}`}));for(const{marker:n,key:i}of r){const r=new RegExp(n,"g");e=e.replace(r,`${t.key}"${i}"${t.reset}`)}return(e=(e=(e=(e=e.replace(/(?<!")\b(true|false)\b(?!")/g,`${t.boolean}$1${t.reset}`)).replace(/(?<!")\bnull\b(?!")/g,`${t.null}null${t.reset}`)).replace(/\[Circular\]/g,`${t.special}[Circular]${t.reset}`)).replace(/\[undefined\]/g,`${t.special}[undefined]${t.reset}`)).replace(/"function.*?[^\\]"/gs,`${t.func}$&${t.reset}`)}colorize(e,t={}){const r={...this.#e,...t};return this.#r(e,r)}getColors(){return{...this.#e}}updateColors(e){Object.assign(this.#e,e)}resetColors(){this.#e={...C.#t.default}}loadColorPreset(e){const t=C.#t[e];if(!t)throw new Error(`Preset "${e}" not found.`);this.#e={...t}}saveColorPreset(e,t){C.#t[e]={...t}}getAvailablePresets(){return Object.keys(C.#t)}}const B=C,I=class{#n=[];#i=!1;#o={};#s=new Set;isRunning(){return this.#i}async#a(e){if(e&&"function"==typeof e.task&&"function"==typeof e.resolve&&"function"==typeof e.reject){const{task:t,resolve:r,reject:n,delay:i,id:o}=e;try{if(o&&this.#s.has(o))return n(new Error("The function was canceled on TinyPromiseQueue.")),this.#s.delete(o),this.#i=!1,void this.#u();i&&o&&await new Promise((e=>{const t=setTimeout((()=>{delete this.#o[o],e(null)}),i);this.#o[o]=t})),r(await t())}catch(e){n(e)}finally{this.#i=!1,this.#u()}}}async#l(){const e=[];for(;this.#n.length&&"POINT_MARKER"===this.#n[0]?.marker;)e.push(this.#n.shift());if(0===e.length)return this.#i=!1,void this.#u();await Promise.all(e.map((({task:e,resolve:t,reject:r,id:n})=>new Promise((async i=>{if(n&&this.#s.has(n))return this.#s.delete(n),r(new Error("The function was canceled on TinyPromiseQueue.")),void i(!0);await e().then(t).catch(r),i(!0)}))))),this.#i=!1,this.#u()}async#u(){if(!this.#i&&0!==this.#n.length)if(this.#i=!0,"string"!=typeof this.#n[0]?.marker||"POINT_MARKER"!==this.#n[0]?.marker){const e=this.#n.shift();this.#a(e)}else this.#l()}getIndexById(e){return this.#n.findIndex((t=>t.id===e))}getQueuedIds(){return this.#n.map(((e,t)=>({index:t,id:e.id}))).filter((e=>"string"==typeof e.id))}reorderQueue(e,t){if("number"!=typeof e||"number"!=typeof t||e<0||t<0||e>=this.#n.length||t>=this.#n.length)return;const[r]=this.#n.splice(e,1);this.#n.splice(t,0,r)}async enqueuePoint(e,t){if("function"!=typeof e)return Promise.reject(new Error("Task must be a function returning a Promise."));if(void 0!==t&&"string"!=typeof t)throw new Error('The "id" parameter must be a string.');return this.#i?new Promise(((r,n)=>{this.#n.push({marker:"POINT_MARKER",task:e,resolve:r,reject:n,id:t}),this.#u()})):e()}enqueue(e,t,r){if("function"!=typeof e)return Promise.reject(new Error("Task must be a function returning a Promise."));if(void 0!==t&&("number"!=typeof t||t<0))return Promise.reject(new Error("Delay must be a positive number or undefined."));if(void 0!==r&&"string"!=typeof r)throw new Error('The "id" parameter must be a string.');return new Promise(((n,i)=>{this.#n.push({task:e,resolve:n,reject:i,id:r,delay:t}),this.#u()}))}cancelTask(e){if("string"!=typeof e)throw new Error('The "id" parameter must be a string.');let t=!1;e in this.#o&&(clearTimeout(this.#o[e]),delete this.#o[e],t=!0);const r=this.getIndexById(e);if(-1!==r){const[e]=this.#n.splice(r,1);e?.reject?.(new Error("The function was canceled on TinyPromiseQueue.")),t=!0}return t&&this.#s.add(e),t}},S=class{#f=null;#h=null;#c=null;#p=null;#d=null;#m=null;groupData=new Map;lastSeen=new Map;userToGroup=new Map;groupFlags=new Map;groupTTL=new Map;#g=null;setOnMemoryExceeded(e){if("function"!=typeof e)throw new Error("onMemoryExceeded must be a function");this.#g=e}clearOnMemoryExceeded(){this.#g=null}#y=null;setOnGroupExpired(e){if("function"!=typeof e)throw new Error("onGroupExpired must be a function");this.#y=e}clearOnGroupExpired(){this.#y=null}constructor({maxHits:e,interval:t,cleanupInterval:r,maxIdle:n=3e5,maxMemory:i=1e5}){const o=e=>"number"==typeof e&&Number.isFinite(e)&&e>=1&&Number.isInteger(e),s=o(e),a=o(t),u=o(r),l=o(n);if(!s&&!a)throw new Error("RateLimiter requires at least one valid option: 'maxHits' or 'interval'.");if(void 0!==e&&!s)throw new Error("'maxHits' must be a positive integer if defined.");if(void 0!==t&&!a)throw new Error("'interval' must be a positive integer in milliseconds if defined.");if(void 0!==r&&!u)throw new Error("'cleanupInterval' must be a positive integer in milliseconds if defined.");if(!l)throw new Error("'maxIdle' must be a positive integer in milliseconds.");if("number"==typeof i&&Number.isFinite(i)&&i>0)this.#f=Math.floor(i);else{if(null!=i)throw new Error("maxMemory must be a positive number or null");this.#f=null}this.#c=s?e:null,this.#p=a?t:null,this.#d=u?r:null,this.#m=n,null!==this.#d&&(this.#h=setInterval((()=>this._cleanup()),this.#d))}isGroupId(e){const t=this.groupFlags.get(e);return"boolean"==typeof t&&t}getUsersInGroup(e){const t=[];for(const[r,n]of this.userToGroup.entries())n===e&&t.push(r);return t}setGroupTTL(e,t){if("number"!=typeof t||!Number.isFinite(t)||t<=0)throw new Error("TTL must be a positive number in milliseconds");this.groupTTL.set(e,t)}getGroupTTL(e){return this.groupTTL.get(e)??null}deleteGroupTTL(e){this.groupTTL.delete(e)}assignToGroup(e,t){const r=this.userToGroup.get(e);if(r&&r!==t)throw new Error(`User ${e} is already assigned to group ${r}`);if(r===t)return;const n=this.groupData.get(e);if(this.isGroupId(e)){for(const[r,n]of this.userToGroup.entries())n===e&&this.userToGroup.set(r,t);this.userToGroup.delete(e)}else this.userToGroup.set(e,t);if(!n)return;const i=this.groupData.get(t);if(i)for(const e of n)i.push(e);else{const e=[];for(const t of n)e.push(t);this.groupData.set(t,e)}this.lastSeen.set(t,Date.now()),this.groupFlags.delete(e),this.groupData.delete(e),this.lastSeen.delete(e),this.groupTTL.delete(e),this.groupFlags.set(t,!0)}getGroupId(e){return this.userToGroup.get(e)||e}hit(e){const t=this.getGroupId(e),r=Date.now();this.groupData.has(t)||(this.groupData.set(t,[]),this.groupFlags.set(t,!1));const n=this.groupData.get(t);if(!n)throw new Error(`No data found for groupId: ${t}`);if(n.push(r),this.lastSeen.set(t,r),null!==this.#p){const e=r-this.getInterval();for(;n.length&&n[0]<e;)n.shift()}null!==this.#f&&"number"==typeof this.#f&&n.length>this.#f&&(n.splice(0,n.length-this.#f),"function"==typeof this.#g&&this.#g(t))}isRateLimited(e){const t=this.getGroupId(e);if(!this.groupData.has(t))return!1;const r=this.groupData.get(t);if(!r)throw new Error(`No data found for groupId: ${t}`);if(null!==this.#p){const e=Date.now()-this.getInterval();let t=0;for(let n=r.length-1;n>=0&&r[n]>e;n--)t++;return null!==this.#c?t>this.getMaxHits():t>0}return null!==this.#c&&r.length>this.getMaxHits()}resetGroup(e){this.groupFlags.delete(e),this.groupData.delete(e),this.lastSeen.delete(e),this.groupTTL.delete(e)}reset(e){return this.resetUserGroup(e)}resetUserGroup(e){this.userToGroup.delete(e)}setData(e,t){if(!Array.isArray(t))throw new Error("timestamps must be an array of numbers.");for(const e of t)if("number"!=typeof e||!Number.isFinite(e))throw new Error("All timestamps must be finite numbers.");this.groupData.has(e)||this.groupFlags.set(e,!1),this.groupData.set(e,t),this.lastSeen.set(e,Date.now())}hasData(e){return this.groupData.has(e)}getData(e){return this.groupData.get(e)||[]}getMaxIdle(){if("number"!=typeof this.#m||!Number.isFinite(this.#m)||this.#m<0)throw new Error("'maxIdle' must be a non-negative finite number.");return this.#m}setMaxIdle(e){if("number"!=typeof e||!Number.isFinite(e)||e<0)throw new Error("'maxIdle' must be a non-negative finite number.");this.#m=e}_cleanup(){const e=Date.now();for(const[t,r]of this.lastSeen.entries())e-r>(this.getGroupTTL(t)??this.getMaxIdle())&&(this.groupFlags.delete(t),this.groupData.delete(t),this.lastSeen.delete(t),this.groupTTL.delete(t),"function"==typeof this.#y&&this.#y(t))}getActiveGroups(){return Array.from(this.groupData.keys())}getAllUserMappings(){return Object.fromEntries(this.userToGroup)}getInterval(){if("number"!=typeof this.#p||!Number.isFinite(this.#p))throw new Error("'interval' is not a valid finite number.");return this.#p}getMaxHits(){if("number"!=typeof this.#c||!Number.isFinite(this.#c))throw new Error("'maxHits' is not a valid finite number.");return this.#c}getTotalHits(e){const t=this.groupData.get(e);return Array.isArray(t)?t.length:0}getLastHit(e){const t=this.groupData.get(e);return t?.length?t[t.length-1]:null}getTimeSinceLastHit(e){const t=this.getLastHit(e);return null!==t?Date.now()-t:null}_calculateAverageSpacing(e){if(!Array.isArray(e)||e.length<2)return null;let t=0;for(let r=1;r<e.length;r++)t+=e[r]-e[r-1];return t/(e.length-1)}getAverageHitSpacing(e){return this._calculateAverageSpacing(this.groupData.get(e))}getMetrics(e){const t=this.groupData.get(e);if(!Array.isArray(t)||0===t.length)return{totalHits:0,lastHit:null,timeSinceLastHit:null,averageHitSpacing:null};const r=t.length,n=t[r-1];return{totalHits:r,lastHit:n,timeSinceLastHit:Date.now()-n,averageHitSpacing:this._calculateAverageSpacing(t)}}destroy(){this.#h&&clearInterval(this.#h),this._cleanup(),this.groupData.clear(),this.lastSeen.clear(),this.userToGroup.clear(),this.groupTTL.clear(),this.groupFlags.clear()}};class D{static getTemplate(){return'\n<div class="notify-overlay hidden">\n <div class="notify-center" id="notifCenter">\n <div class="header">\n <div>Notifications</div>\n <div class="options">\n <button class="clear-all" type="button">\n <svg\n xmlns="http://www.w3.org/2000/svg"\n viewBox="0 0 24 24"\n width="24"\n height="24"\n fill="currentColor"\n >\n <path\n d="M21.6 2.4a1 1 0 0 0-1.4 0L13 9.6l-1.3-1.3a1 1 0 0 0-1.4 0L3 15.6a1 1 0 0 0 0 1.4l4 4a1 1 0 0 0 1.4 0l7.3-7.3a1 1 0 0 0 0-1.4l-1.3-1.3 7.2-7.2a1 1 0 0 0 0-1.4zM6 17l3.5-3.5 1.5 1.5L7.5 18.5 6 17z"\n />\n </svg>\n </button>\n <button class="close">×</button>\n </div>\n </div>\n <div class="list"></div>\n </div>\n</div>\n\n<button class="notify-bell" aria-label="Open notifications">\n <svg\n xmlns="http://www.w3.org/2000/svg"\n width="20"\n height="20"\n fill="currentColor"\n viewBox="0 0 24 24"\n >\n <path\n d="M12 2C10.3 2 9 3.3 9 5v1.1C6.7 7.2 5 9.4 5 12v5l-1 1v1h16v-1l-1-1v-5c0-2.6-1.7-4.8-4-5.9V5c0-1.7-1.3-3-3-3zm0 20c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2z"\n />\n </svg>\n <span class="badge" id="notifBadge">0</span>\n</button>\n '}static insertTemplate(e="afterbegin"){document.body.insertAdjacentHTML(e,D.getTemplate())}#v;#b;#w;#E;#x;#T=0;#L=99;#N=300;#A=!1;#M=new WeakMap;#C(e){if(this.#M.delete(e),!(e instanceof HTMLElement))throw new Error("Invalid HTMLElement to clear.");e.classList.add("removing"),setTimeout((()=>{this.markAsRead(e),e.remove()}),this.#N)}#B(e){this.#T=Math.max(0,e),this.#w.setAttribute("data-value",String(this.#T)),this.#w.textContent=this.#T>this.#L?`${this.#L}+`:String(this.#T)}constructor(e={}){const{center:t=document.getElementById("notifCenter"),badge:r=document.getElementById("notifBadge"),button:n=document.querySelector(".notify-bell"),overlay:i=document.querySelector(".notify-overlay")}=e;if(!(t instanceof HTMLElement))throw new Error(`NotificationCenter: "center" must be an HTMLElement. Got: ${t}`);if(!(i instanceof HTMLElement))throw new Error(`NotificationCenter: "overlay" must be an HTMLElement. Got: ${i}`);if(!(r instanceof HTMLElement))throw new Error(`NotificationCenter: "badge" must be an HTMLElement. Got: ${r}`);if(!(n instanceof HTMLElement))throw new Error(`NotificationCenter: "button" must be an HTMLElement. Got: ${n}`);const o=t?.querySelector(".clear-all"),s=t?.querySelector(".list")??null;if(!(s instanceof HTMLElement))throw new Error(`NotificationCenter: ".list" inside center must be an HTMLElement. Got: ${s}`);this.#v=t,this.#b=s,this.#w=r,this.#E=n,this.#x=i,this.#E.addEventListener("click",(()=>this.toggle())),this.#v.querySelector(".close")?.addEventListener("click",(()=>this.close())),o&&o.addEventListener("click",(()=>this.clear())),this.#x.addEventListener("click",(e=>{e.target===this.#x&&this.close()}))}setMarkAllAsReadOnClose(e){if("boolean"!=typeof e)throw new TypeError("Expected boolean for markAllAsReadOnClose, got "+typeof e);this.#A=e}setRemoveDelay(e){if("number"!=typeof e)throw new Error('NotificationCenter: "ms" must be an number.');this.#N=e}getItemMode(e){const t=this.getItem(e);return t?this.#M.get(t):null}getItem(e){const t=this.#b.children.item(e);if(!(t instanceof HTMLElement))throw new Error(`NotificationCenter: "item" must be an HTMLElement. Got: ${t}`);return t}hasItem(e){return e>=0&&e<this.#b.children.length}markAsRead(e){const t=e instanceof HTMLElement?e:this.getItem(e);t.classList.contains("unread")&&(t.classList.remove("unread"),this.#B(this.#T-1))}add(e,t="text"){const r=document.createElement("div");r.className="item unread";let n=null,i=null,o=null,s=null;if("object"==typeof e&&null!==e?(n=e.title,i=e.message,o=e.avatar,s=e.onClick):i=e,o){const e=document.createElement("div");e.className="avatar",e.style.backgroundImage=`url("${o}")`,r.appendChild(e)}const a=document.createElement("div");if(a.className="content",n){const e=document.createElement("div");e.className="title",e.textContent=n,a.appendChild(e)}const u=document.createElement("div");u.className="message","html"===t?u.innerHTML=i:u.textContent=i,a.appendChild(u),"function"==typeof s&&(r.classList.add("clickable"),r.addEventListener("click",(e=>{e.target instanceof HTMLElement&&!e.target.closest(".notify-close")&&s(e)})));const l=document.createElement("button");l.className="notify-close",l.setAttribute("type","button"),l.innerHTML="&times;",l.addEventListener("click",(e=>{e.stopPropagation(),this.#C(r)})),r.append(a,l),this.#b.prepend(r),this.#M.set(r,t),this.#B(this.#T+1)}remove(e){const t=this.getItem(e);this.#C(t)}clear(){let e=!0;for(;e;){e=!1;const t=Array.from(this.#b.children);for(const r of t)r instanceof HTMLElement&&!r.classList.contains("removing")&&(this.#C(r),e=!0)}}open(){this.#x.classList.remove("hidden"),this.#v.classList.add("open")}close(){if(this.#x.classList.add("hidden"),this.#v.classList.remove("open"),this.#A){const e=this.#b.querySelectorAll(".item.unread");for(const t of e)t instanceof HTMLElement&&this.markAsRead(t)}}toggle(){this.#v.classList.contains("open")?this.close():this.open()}recount(){const e=this.#b.querySelectorAll(".item.unread").length;this.#B(e)}get count(){return this.#T}}const k=D,O=class{#I;#S;#D;#k;#O;#U;constructor(e="top",t="right",r=3e3,n=50,i=300,o=".notify-container"){this.#P(e),this.#R(t),this.#$(r,"baseDuration"),this.#$(n,"extraPerChar"),this.#$(i,"fadeOutDuration"),this.#I=e,this.#S=t,this.#D=r,this.#k=n,this.#O=i;const s=document.querySelector(`${o}.${e}.${t}`);s instanceof HTMLElement?this.#U=s:(this.#U=document.createElement("div"),this.#U.className=`notify-container ${e} ${t}`,document.body.appendChild(this.#U))}getContainer(){if(!(this.#U instanceof HTMLElement))throw new Error("Container is not a valid HTMLElement.");return this.#U}#P(e){if(!["top","bottom"].includes(e))throw new Error(`Invalid vertical direction "${e}". Expected "top" or "bottom".`)}#R(e){if(!["left","right","center"].includes(e))throw new Error(`Invalid horizontal position "${e}". Expected "left", "right" or "center".`)}#$(e,t){if("number"!=typeof e||e<0||!Number.isFinite(e))throw new Error(`Invalid value for "${t}": ${e}. Must be a non-negative finite number.`)}getY(){return this.#I}setY(e){this.#P(e);const t=this.getContainer();t.classList.remove(this.#I),t.classList.add(e),this.#I=e}getX(){return this.#S}setX(e){this.#R(e);const t=this.getContainer();t.classList.remove(this.#S),t.classList.add(e),this.#S=e}getBaseDuration(){return this.#D}setBaseDuration(e){this.#$(e,"baseDuration"),this.#D=e}getExtraPerChar(){return this.#k}setExtraPerChar(e){this.#$(e,"extraPerChar"),this.#k=e}getFadeOutDuration(){return this.#O}setFadeOutDuration(e){this.#$(e,"fadeOutDuration"),this.#O=e}show(e){let t="",r="",n=null,i=!1,o=null;const s=document.createElement("div");if(s.className="notify enter","string"==typeof e)t=e;else{if("object"!=typeof e||null===e||"string"!=typeof e.message)throw new Error("Invalid argument for show(): expected string or { message: string, title?: string, onClick?: function, html?: boolean, avatar?: string }");if(t=e.message,r="string"==typeof e.title?e.title:"",i=!0===e.html,o="string"==typeof e.avatar?e.avatar:null,void 0!==e.onClick){if("function"!=typeof e.onClick)throw new Error("onClick must be a function if defined");n=e.onClick,s.classList.add("clickable")}}const a=document.createElement("button");if(a.innerHTML="&times;",a.className="close",a.setAttribute("aria-label","Close"),a.addEventListener("mouseenter",(()=>{a.style.color="var(--notif-close-color-hover)"})),a.addEventListener("mouseleave",(()=>{a.style.color="var(--notif-close-color)"})),o){const e=document.createElement("img");e.src=o,e.alt="avatar",e.className="avatar",s.appendChild(e)}if(r){const e=document.createElement("strong");e.textContent=r,e.style.display="block",s.appendChild(e)}if(i){const e=document.createElement("div");e.innerHTML=t,s.appendChild(e)}else s.appendChild(document.createTextNode(t));s.appendChild(a),this.getContainer().appendChild(s);const u=this.#D+t.length*this.#k+this.#O;let l=!1;const f=()=>{l||(l=!0,s.classList.remove("enter","show"),s.classList.add("exit"),setTimeout((()=>s.remove()),this.#O))};"function"==typeof n&&s.addEventListener("click",(e=>{e.target!==a&&n(e,f)})),a.addEventListener("click",(e=>{e.stopPropagation(),f()})),setTimeout((()=>{s.classList.remove("enter"),s.classList.add("show")}),1),setTimeout((()=>f()),u)}}})(),window.TinyEssentials=n})();
@@ -0,0 +1,461 @@
1
+ /******/ (() => { // webpackBootstrap
2
+ /******/ "use strict";
3
+ /******/ // The require scope
4
+ /******/ var __webpack_require__ = {};
5
+ /******/
6
+ /************************************************************************/
7
+ /******/ /* webpack/runtime/define property getters */
8
+ /******/ (() => {
9
+ /******/ // define getter functions for harmony exports
10
+ /******/ __webpack_require__.d = (exports, definition) => {
11
+ /******/ for(var key in definition) {
12
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
13
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
14
+ /******/ }
15
+ /******/ }
16
+ /******/ };
17
+ /******/ })();
18
+ /******/
19
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
20
+ /******/ (() => {
21
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
22
+ /******/ })();
23
+ /******/
24
+ /************************************************************************/
25
+ var __webpack_exports__ = {};
26
+
27
+ // EXPORTS
28
+ __webpack_require__.d(__webpack_exports__, {
29
+ TinyNotifyCenter: () => (/* reexport */ libs_TinyNotifyCenter)
30
+ });
31
+
32
+ ;// ./src/v1/libs/TinyNotifyCenter.mjs
33
+ /**
34
+ * Represents a single notification entry.
35
+ *
36
+ * A notification can be provided as a simple string (treated as a plain message),
37
+ * or as an object with additional data such as a title, an avatar image, and a click handler.
38
+ *
39
+ * @typedef {string | {
40
+ * title?: string, // Optional title displayed above the message
41
+ * message: string, // Required message content
42
+ * avatar?: string, // Optional avatar image URL (displayed on the left)
43
+ * onClick?: (e: MouseEvent) => void // Optional click handler for the entire notification
44
+ * }} NotifyData
45
+ */
46
+
47
+ /**
48
+ * A notification center component for displaying interactive alerts in the UI.
49
+ *
50
+ * This class renders a notification overlay on the page and allows dynamically
51
+ * adding, clearing, or interacting with notification items. Notifications can
52
+ * contain plain text or HTML, and optionally support click events, titles, and avatars.
53
+ *
54
+ * Features:
55
+ * - Dynamic rendering of notification UI with `insertTemplate()`
56
+ * - Supports text and HTML content modes
57
+ * - Optional avatars for each notification
58
+ * - Callback support on notification click
59
+ * - Per-notification close buttons
60
+ * - Notification count badge
61
+ *
62
+ * @class
63
+ */
64
+ class TinyNotifyCenter {
65
+ /**
66
+ * Returns the full HTML structure for the notification system as a string.
67
+ *
68
+ * This includes:
69
+ * - A hidden `.notify-overlay` containing the central notification panel (`#notifCenter`),
70
+ * which has a header with a "Notifications" label, a "clear all" button, and a close button.
71
+ * - A `.list` container for dynamically added notifications.
72
+ * - A bell button (`.notify-bell`) to toggle the notification center, with an embedded badge.
73
+ *
74
+ * This template can be inserted into the DOM using `insertAdjacentHTML()` or parsed dynamically
75
+ * into elements using JavaScript or jQuery, depending on the needs of the system.
76
+ *
77
+ * @returns {string} The complete HTML structure for the notification center.
78
+ */
79
+ static getTemplate() {
80
+ return `
81
+ <div class="notify-overlay hidden">
82
+ <div class="notify-center" id="notifCenter">
83
+ <div class="header">
84
+ <div>Notifications</div>
85
+ <div class="options">
86
+ <button class="clear-all" type="button">
87
+ <svg
88
+ xmlns="http://www.w3.org/2000/svg"
89
+ viewBox="0 0 24 24"
90
+ width="24"
91
+ height="24"
92
+ fill="currentColor"
93
+ >
94
+ <path
95
+ d="M21.6 2.4a1 1 0 0 0-1.4 0L13 9.6l-1.3-1.3a1 1 0 0 0-1.4 0L3 15.6a1 1 0 0 0 0 1.4l4 4a1 1 0 0 0 1.4 0l7.3-7.3a1 1 0 0 0 0-1.4l-1.3-1.3 7.2-7.2a1 1 0 0 0 0-1.4zM6 17l3.5-3.5 1.5 1.5L7.5 18.5 6 17z"
96
+ />
97
+ </svg>
98
+ </button>
99
+ <button class="close">×</button>
100
+ </div>
101
+ </div>
102
+ <div class="list"></div>
103
+ </div>
104
+ </div>
105
+
106
+ <button class="notify-bell" aria-label="Open notifications">
107
+ <svg
108
+ xmlns="http://www.w3.org/2000/svg"
109
+ width="20"
110
+ height="20"
111
+ fill="currentColor"
112
+ viewBox="0 0 24 24"
113
+ >
114
+ <path
115
+ d="M12 2C10.3 2 9 3.3 9 5v1.1C6.7 7.2 5 9.4 5 12v5l-1 1v1h16v-1l-1-1v-5c0-2.6-1.7-4.8-4-5.9V5c0-1.7-1.3-3-3-3zm0 20c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2z"
116
+ />
117
+ </svg>
118
+ <span class="badge" id="notifBadge">0</span>
119
+ </button>
120
+ `;
121
+ }
122
+
123
+ /**
124
+ * Inserts the full notification center template into the document body.
125
+ *
126
+ * The structure is injected directly into the DOM using
127
+ * `insertAdjacentHTML`.
128
+ *
129
+ * The `where` parameter allows control over where inside the `document.body`
130
+ * the HTML is inserted:
131
+ * - `'afterbegin'` (default): Inserts right after the opening <body> tag.
132
+ * - `'beforeend'`: Inserts right before the closing </body> tag.
133
+ * - Any valid position accepted by `insertAdjacentHTML`.
134
+ *
135
+ * @param {'beforebegin'|'afterbegin'|'beforeend'|'afterend'} [where='afterbegin']
136
+ * The position relative to `document.body` where the HTML should be inserted.
137
+ */
138
+ static insertTemplate(where = 'afterbegin') {
139
+ document.body.insertAdjacentHTML(where, TinyNotifyCenter.getTemplate());
140
+ }
141
+
142
+ /** @type {HTMLElement} */
143
+ #center;
144
+ /** @type {HTMLElement} */
145
+ #list;
146
+ /** @type {HTMLElement} */
147
+ #badge;
148
+ /** @type {HTMLElement} */
149
+ #button;
150
+ /** @type {HTMLElement} */
151
+ #overlay;
152
+
153
+ #count = 0;
154
+ #maxCount = 99;
155
+ #removeDelay = 300;
156
+ #markAllAsReadOnClose = false;
157
+ #modes = new WeakMap();
158
+
159
+ /** @param {HTMLElement|ChildNode} item */
160
+ #removeItem(item) {
161
+ this.#modes.delete(item);
162
+ if (item instanceof HTMLElement) {
163
+ item.classList.add('removing');
164
+
165
+ setTimeout(() => {
166
+ this.markAsRead(item);
167
+ item.remove();
168
+ }, this.#removeDelay);
169
+ } else throw new Error('Invalid HTMLElement to clear.');
170
+ }
171
+
172
+ /**
173
+ * Update notify count and badge.
174
+ * @param {number} value
175
+ */
176
+ #updateCount(value) {
177
+ this.#count = Math.max(0, value);
178
+ this.#badge.setAttribute('data-value', String(this.#count));
179
+ this.#badge.textContent =
180
+ this.#count > this.#maxCount ? `${this.#maxCount}+` : String(this.#count);
181
+ }
182
+
183
+ /**
184
+ * Options for configuring the NotificationCenter instance.
185
+ *
186
+ * Allows manual specification of the main elements used by the notification center.
187
+ * If not provided, default elements will be selected from the DOM automatically.
188
+ *
189
+ * @param {Object} options - Configuration object.
190
+ * @param {HTMLElement} [options.center=document.getElementById('notifCenter')] - The container element that holds the list of notifications.
191
+ * @param {HTMLElement} [options.badge=document.getElementById('notifBadge')] - The badge element used to display the current notification count.
192
+ * @param {HTMLElement} [options.button=document.querySelector('.notify-bell')] - The button element that toggles the notification center.
193
+ * @param {HTMLElement} [options.overlay=document.querySelector('.notify-overlay')] - The overlay element that covers the screen when the center is visible.
194
+ */
195
+ constructor(options = {}) {
196
+ const {
197
+ center = document.getElementById('notifCenter'),
198
+ badge = document.getElementById('notifBadge'),
199
+ button = document.querySelector('.notify-bell'),
200
+ overlay = document.querySelector('.notify-overlay'),
201
+ } = options;
202
+
203
+ // Element existence and type validation
204
+ if (!(center instanceof HTMLElement))
205
+ throw new Error(`NotificationCenter: "center" must be an HTMLElement. Got: ${center}`);
206
+ if (!(overlay instanceof HTMLElement))
207
+ throw new Error(`NotificationCenter: "overlay" must be an HTMLElement. Got: ${overlay}`);
208
+ if (!(badge instanceof HTMLElement))
209
+ throw new Error(`NotificationCenter: "badge" must be an HTMLElement. Got: ${badge}`);
210
+ if (!(button instanceof HTMLElement))
211
+ throw new Error(`NotificationCenter: "button" must be an HTMLElement. Got: ${button}`);
212
+
213
+ const clearAllBtn = center?.querySelector('.clear-all');
214
+ const list = center?.querySelector('.list') ?? null;
215
+ if (!(list instanceof HTMLElement))
216
+ throw new Error(
217
+ `NotificationCenter: ".list" inside center must be an HTMLElement. Got: ${list}`,
218
+ );
219
+
220
+ this.#center = center;
221
+ this.#list = list;
222
+ this.#badge = badge;
223
+ this.#button = button;
224
+ this.#overlay = overlay;
225
+
226
+ this.#button.addEventListener('click', () => this.toggle());
227
+ this.#center.querySelector('.close')?.addEventListener('click', () => this.close());
228
+ if (clearAllBtn) clearAllBtn.addEventListener('click', () => this.clear());
229
+ this.#overlay.addEventListener('click', (e) => {
230
+ if (e.target === this.#overlay) this.close();
231
+ });
232
+ }
233
+
234
+ /**
235
+ * Enable or disable automatic mark-as-read on close.
236
+ * @param {boolean} value
237
+ */
238
+ setMarkAllAsReadOnClose(value) {
239
+ if (typeof value !== 'boolean')
240
+ throw new TypeError(`Expected boolean for markAllAsReadOnClose, got ${typeof value}`);
241
+ this.#markAllAsReadOnClose = value;
242
+ }
243
+
244
+ /**
245
+ * Define how long the remove animation takes (in ms).
246
+ * @param {number} ms
247
+ */
248
+ setRemoveDelay(ms) {
249
+ if (typeof ms !== 'number') throw new Error(`NotificationCenter: "ms" must be an number.`);
250
+ this.#removeDelay = ms;
251
+ }
252
+
253
+ /**
254
+ * Get rendering mode ('text' or 'html') by index.
255
+ * @param {number} index
256
+ * @returns {'text' | 'html' | null}
257
+ */
258
+ getItemMode(index) {
259
+ const item = this.getItem(index);
260
+ return item ? this.#modes.get(item) : null;
261
+ }
262
+
263
+ /**
264
+ * Get a notify element by index.
265
+ * @param {number} index
266
+ * @returns {HTMLElement}
267
+ */
268
+ getItem(index) {
269
+ const element = this.#list.children.item(index);
270
+ if (!(element instanceof HTMLElement))
271
+ throw new Error(`NotificationCenter: "item" must be an HTMLElement. Got: ${element}`);
272
+ return element;
273
+ }
274
+
275
+ /**
276
+ * Check if a notify exists at the given index.
277
+ * @param {number} index
278
+ * @returns {boolean}
279
+ */
280
+ hasItem(index) {
281
+ return index >= 0 && index < this.#list.children.length;
282
+ }
283
+
284
+ /**
285
+ * Mark a notification index as read.
286
+ * @param {number|HTMLElement} index
287
+ */
288
+ markAsRead(index) {
289
+ const item = index instanceof HTMLElement ? index : this.getItem(index);
290
+ if (item.classList.contains('unread')) {
291
+ item.classList.remove('unread');
292
+ this.#updateCount(this.#count - 1);
293
+ }
294
+ }
295
+
296
+ /**
297
+ * Add a new notify to the center.
298
+ *
299
+ * @param {NotifyData} message - Notification content or a full object with title, avatar, and callback.
300
+ * @param {'text'|'html'} [mode='text'] - How to treat the message content.
301
+ */
302
+ add(message, mode = 'text') {
303
+ const item = document.createElement('div');
304
+ item.className = 'item unread';
305
+
306
+ let titleText = null;
307
+ let messageText = null;
308
+ let avatarUrl = null;
309
+ let onClick = null;
310
+
311
+ if (typeof message === 'object' && message !== null) {
312
+ titleText = message.title;
313
+ messageText = message.message;
314
+ avatarUrl = message.avatar;
315
+ onClick = message.onClick;
316
+ } else {
317
+ messageText = message;
318
+ }
319
+
320
+ // Optional avatar
321
+ if (avatarUrl) {
322
+ const avatarElem = document.createElement('div');
323
+ avatarElem.className = 'avatar';
324
+ avatarElem.style.backgroundImage = `url("${avatarUrl}")`;
325
+ item.appendChild(avatarElem);
326
+ }
327
+
328
+ // Content wrapper
329
+ const contentWrapper = document.createElement('div');
330
+ contentWrapper.className = 'content';
331
+
332
+ // Optional title
333
+ if (titleText) {
334
+ const titleElem = document.createElement('div');
335
+ titleElem.className = 'title';
336
+ titleElem.textContent = titleText;
337
+ contentWrapper.appendChild(titleElem);
338
+ }
339
+
340
+ // Message
341
+ const messageElem = document.createElement('div');
342
+ messageElem.className = 'message';
343
+
344
+ if (mode === 'html') {
345
+ messageElem.innerHTML = messageText;
346
+ } else {
347
+ messageElem.textContent = messageText;
348
+ }
349
+
350
+ contentWrapper.appendChild(messageElem);
351
+
352
+ // Action by clicking (if provided)
353
+ if (typeof onClick === 'function') {
354
+ item.classList.add('clickable');
355
+ item.addEventListener('click', (e) => {
356
+ // Prevents the close button from clicking
357
+ if (e.target instanceof HTMLElement && !e.target.closest('.notify-close')) {
358
+ onClick(e);
359
+ }
360
+ });
361
+ }
362
+
363
+ // Close button
364
+ const closeBtn = document.createElement('button');
365
+ closeBtn.className = 'notify-close';
366
+ closeBtn.setAttribute('type', 'button');
367
+ closeBtn.innerHTML = '&times;';
368
+ closeBtn.addEventListener('click', (e) => {
369
+ e.stopPropagation(); // prevents propagation for the main onClick
370
+ this.#removeItem(item);
371
+ });
372
+
373
+ item.append(contentWrapper, closeBtn);
374
+ this.#list.prepend(item);
375
+ this.#modes.set(item, mode);
376
+ this.#updateCount(this.#count + 1);
377
+ }
378
+
379
+ /**
380
+ * Remove a notify by index.
381
+ * @param {number} index
382
+ */
383
+ remove(index) {
384
+ const item = this.getItem(index);
385
+ this.#removeItem(item);
386
+ }
387
+
388
+ /**
389
+ * Clear all notifications safely.
390
+ */
391
+ clear() {
392
+ let needAgain = true;
393
+ while (needAgain) {
394
+ needAgain = false;
395
+ const items = Array.from(this.#list.children);
396
+ for (const item of items) {
397
+ if (item instanceof HTMLElement && !item.classList.contains('removing')) {
398
+ this.#removeItem(item);
399
+ needAgain = true;
400
+ }
401
+ }
402
+ }
403
+ }
404
+
405
+ /**
406
+ * Open the notify center.
407
+ */
408
+ open() {
409
+ this.#overlay.classList.remove('hidden');
410
+ this.#center.classList.add('open');
411
+ }
412
+
413
+ /**
414
+ * Close the notify center.
415
+ */
416
+ close() {
417
+ this.#overlay.classList.add('hidden');
418
+ this.#center.classList.remove('open');
419
+ if (this.#markAllAsReadOnClose) {
420
+ const items = this.#list.querySelectorAll('.item.unread');
421
+ for (const item of items) {
422
+ if (item instanceof HTMLElement) this.markAsRead(item);
423
+ }
424
+ }
425
+ }
426
+
427
+ /**
428
+ * Toggle open/close state.
429
+ */
430
+ toggle() {
431
+ if (this.#center.classList.contains('open')) this.close();
432
+ else this.open();
433
+ }
434
+
435
+ /**
436
+ * Recalculate the number of notifications based on the actual DOM list.
437
+ */
438
+ recount() {
439
+ const count = this.#list.querySelectorAll('.item.unread').length;
440
+ this.#updateCount(count);
441
+ }
442
+
443
+ /**
444
+ * Get current count.
445
+ * @returns {number}
446
+ */
447
+ get count() {
448
+ return this.#count;
449
+ }
450
+ }
451
+
452
+ /* harmony default export */ const libs_TinyNotifyCenter = (TinyNotifyCenter);
453
+
454
+ ;// ./src/v1/build/TinyNotifyCenter.mjs
455
+
456
+
457
+
458
+
459
+ window.TinyNotifyCenter = __webpack_exports__.TinyNotifyCenter;
460
+ /******/ })()
461
+ ;
@@ -0,0 +1 @@
1
+ (()=>{"use strict";var t={d:(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{TinyNotifyCenter:()=>o});class n{static getTemplate(){return'\n<div class="notify-overlay hidden">\n <div class="notify-center" id="notifCenter">\n <div class="header">\n <div>Notifications</div>\n <div class="options">\n <button class="clear-all" type="button">\n <svg\n xmlns="http://www.w3.org/2000/svg"\n viewBox="0 0 24 24"\n width="24"\n height="24"\n fill="currentColor"\n >\n <path\n d="M21.6 2.4a1 1 0 0 0-1.4 0L13 9.6l-1.3-1.3a1 1 0 0 0-1.4 0L3 15.6a1 1 0 0 0 0 1.4l4 4a1 1 0 0 0 1.4 0l7.3-7.3a1 1 0 0 0 0-1.4l-1.3-1.3 7.2-7.2a1 1 0 0 0 0-1.4zM6 17l3.5-3.5 1.5 1.5L7.5 18.5 6 17z"\n />\n </svg>\n </button>\n <button class="close">×</button>\n </div>\n </div>\n <div class="list"></div>\n </div>\n</div>\n\n<button class="notify-bell" aria-label="Open notifications">\n <svg\n xmlns="http://www.w3.org/2000/svg"\n width="20"\n height="20"\n fill="currentColor"\n viewBox="0 0 24 24"\n >\n <path\n d="M12 2C10.3 2 9 3.3 9 5v1.1C6.7 7.2 5 9.4 5 12v5l-1 1v1h16v-1l-1-1v-5c0-2.6-1.7-4.8-4-5.9V5c0-1.7-1.3-3-3-3zm0 20c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2z"\n />\n </svg>\n <span class="badge" id="notifBadge">0</span>\n</button>\n '}static insertTemplate(t="afterbegin"){document.body.insertAdjacentHTML(t,n.getTemplate())}#t;#e;#n;#o;#s;#i=0;#a=99;#l=300;#r=!1;#c=new WeakMap;#d(t){if(this.#c.delete(t),!(t instanceof HTMLElement))throw new Error("Invalid HTMLElement to clear.");t.classList.add("removing"),setTimeout((()=>{this.markAsRead(t),t.remove()}),this.#l)}#m(t){this.#i=Math.max(0,t),this.#n.setAttribute("data-value",String(this.#i)),this.#n.textContent=this.#i>this.#a?`${this.#a}+`:String(this.#i)}constructor(t={}){const{center:e=document.getElementById("notifCenter"),badge:n=document.getElementById("notifBadge"),button:o=document.querySelector(".notify-bell"),overlay:s=document.querySelector(".notify-overlay")}=t;if(!(e instanceof HTMLElement))throw new Error(`NotificationCenter: "center" must be an HTMLElement. Got: ${e}`);if(!(s instanceof HTMLElement))throw new Error(`NotificationCenter: "overlay" must be an HTMLElement. Got: ${s}`);if(!(n instanceof HTMLElement))throw new Error(`NotificationCenter: "badge" must be an HTMLElement. Got: ${n}`);if(!(o instanceof HTMLElement))throw new Error(`NotificationCenter: "button" must be an HTMLElement. Got: ${o}`);const i=e?.querySelector(".clear-all"),a=e?.querySelector(".list")??null;if(!(a instanceof HTMLElement))throw new Error(`NotificationCenter: ".list" inside center must be an HTMLElement. Got: ${a}`);this.#t=e,this.#e=a,this.#n=n,this.#o=o,this.#s=s,this.#o.addEventListener("click",(()=>this.toggle())),this.#t.querySelector(".close")?.addEventListener("click",(()=>this.close())),i&&i.addEventListener("click",(()=>this.clear())),this.#s.addEventListener("click",(t=>{t.target===this.#s&&this.close()}))}setMarkAllAsReadOnClose(t){if("boolean"!=typeof t)throw new TypeError("Expected boolean for markAllAsReadOnClose, got "+typeof t);this.#r=t}setRemoveDelay(t){if("number"!=typeof t)throw new Error('NotificationCenter: "ms" must be an number.');this.#l=t}getItemMode(t){const e=this.getItem(t);return e?this.#c.get(e):null}getItem(t){const e=this.#e.children.item(t);if(!(e instanceof HTMLElement))throw new Error(`NotificationCenter: "item" must be an HTMLElement. Got: ${e}`);return e}hasItem(t){return t>=0&&t<this.#e.children.length}markAsRead(t){const e=t instanceof HTMLElement?t:this.getItem(t);e.classList.contains("unread")&&(e.classList.remove("unread"),this.#m(this.#i-1))}add(t,e="text"){const n=document.createElement("div");n.className="item unread";let o=null,s=null,i=null,a=null;if("object"==typeof t&&null!==t?(o=t.title,s=t.message,i=t.avatar,a=t.onClick):s=t,i){const t=document.createElement("div");t.className="avatar",t.style.backgroundImage=`url("${i}")`,n.appendChild(t)}const l=document.createElement("div");if(l.className="content",o){const t=document.createElement("div");t.className="title",t.textContent=o,l.appendChild(t)}const r=document.createElement("div");r.className="message","html"===e?r.innerHTML=s:r.textContent=s,l.appendChild(r),"function"==typeof a&&(n.classList.add("clickable"),n.addEventListener("click",(t=>{t.target instanceof HTMLElement&&!t.target.closest(".notify-close")&&a(t)})));const c=document.createElement("button");c.className="notify-close",c.setAttribute("type","button"),c.innerHTML="&times;",c.addEventListener("click",(t=>{t.stopPropagation(),this.#d(n)})),n.append(l,c),this.#e.prepend(n),this.#c.set(n,e),this.#m(this.#i+1)}remove(t){const e=this.getItem(t);this.#d(e)}clear(){let t=!0;for(;t;){t=!1;const e=Array.from(this.#e.children);for(const n of e)n instanceof HTMLElement&&!n.classList.contains("removing")&&(this.#d(n),t=!0)}}open(){this.#s.classList.remove("hidden"),this.#t.classList.add("open")}close(){if(this.#s.classList.add("hidden"),this.#t.classList.remove("open"),this.#r){const t=this.#e.querySelectorAll(".item.unread");for(const e of t)e instanceof HTMLElement&&this.markAsRead(e)}}toggle(){this.#t.classList.contains("open")?this.close():this.open()}recount(){const t=this.#e.querySelectorAll(".item.unread").length;this.#m(t)}get count(){return this.#i}}const o=n;window.TinyNotifyCenter=e.TinyNotifyCenter})();