tiny-essentials 1.27.1 → 1.28.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 (60) hide show
  1. package/README.md +1 -0
  2. package/changelog/1/28/0.md +16 -0
  3. package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
  4. package/dist/v1/TinyBasicsEs.min.js +1 -2
  5. package/dist/v1/TinyEssentials.min.js +1 -2
  6. package/dist/v1/TinyIframeEvents.min.js +1 -1
  7. package/dist/v1/TinyLocalStorage.min.js +1 -1
  8. package/dist/v1/TinyMediaPlayer.min.js +1 -1
  9. package/dist/v1/TinyNewWinEvents.min.js +1 -1
  10. package/dist/v1/TinyRadioFm.min.js +1 -1
  11. package/dist/v1/TinySmartScroller.min.js +1 -1
  12. package/dist/v1/TinyUploadClicker.min.js +1 -2
  13. package/dist/v1/basics/extendObjType/Buffer.cjs +13 -0
  14. package/dist/v1/basics/extendObjType/Buffer.d.mts +4 -0
  15. package/dist/v1/basics/extendObjType/Buffer.mjs +8 -0
  16. package/dist/v1/basics/objFilter.cjs +0 -11
  17. package/dist/v1/basics/objFilter.mjs +0 -10
  18. package/dist/v1/index.cjs +0 -2
  19. package/dist/v1/index.d.mts +1 -2
  20. package/dist/v1/index.mjs +1 -2
  21. package/dist/v1/libs/TinyAdvancedRaffle.cjs +7 -205
  22. package/dist/v1/libs/TinyAdvancedRaffle.d.mts +2 -121
  23. package/dist/v1/libs/TinyAdvancedRaffle.mjs +7 -179
  24. package/dist/v1/libs/TinyIframeEvents.cjs +8 -195
  25. package/dist/v1/libs/TinyIframeEvents.d.mts +3 -122
  26. package/dist/v1/libs/TinyIframeEvents.mjs +8 -170
  27. package/dist/v1/libs/TinyLocalStorage.cjs +5 -205
  28. package/dist/v1/libs/TinyLocalStorage.d.mts +3 -130
  29. package/dist/v1/libs/TinyLocalStorage.mjs +5 -178
  30. package/dist/v1/libs/TinyMediaPlayer.cjs +2 -2
  31. package/dist/v1/libs/TinyMediaPlayer.d.mts +2 -2
  32. package/dist/v1/libs/TinyMediaPlayer.mjs +2 -2
  33. package/dist/v1/libs/TinyNewWinEvents.cjs +10 -197
  34. package/dist/v1/libs/TinyNewWinEvents.d.mts +3 -122
  35. package/dist/v1/libs/TinyNewWinEvents.mjs +10 -172
  36. package/dist/v1/libs/TinyRadioFm.cjs +2 -3
  37. package/dist/v1/libs/TinyRadioFm.d.mts +2 -3
  38. package/dist/v1/libs/TinyRadioFm.mjs +2 -3
  39. package/dist/v1/libs/TinySmartScroller.cjs +4 -202
  40. package/dist/v1/libs/TinySmartScroller.d.mts +8 -143
  41. package/dist/v1/libs/TinySmartScroller.mjs +4 -176
  42. package/dist/v1/libs/TinyUploadClicker.cjs +1 -0
  43. package/docs/v1/Exports.md +0 -1
  44. package/docs/v1/README.md +0 -1
  45. package/docs/v1/basics/objFilter.md +1 -1
  46. package/docs/v1/libs/TinyIframeEvents.md +8 -8
  47. package/docs/v1/libs/TinyLocalStorage.md +3 -3
  48. package/docs/v1/libs/TinyNewWinEvents.md +8 -9
  49. package/package.json +6 -5
  50. package/dist/v1/TinyBasicsEs.min.js.LICENSE.txt +0 -8
  51. package/dist/v1/TinyEssentials.min.js.LICENSE.txt +0 -8
  52. package/dist/v1/TinyEvents.min.js +0 -1
  53. package/dist/v1/TinyUploadClicker.min.js.LICENSE.txt +0 -8
  54. package/dist/v1/build/TinyEvents.cjs +0 -7
  55. package/dist/v1/build/TinyEvents.d.mts +0 -3
  56. package/dist/v1/build/TinyEvents.mjs +0 -2
  57. package/dist/v1/libs/TinyEvents.cjs +0 -395
  58. package/dist/v1/libs/TinyEvents.d.mts +0 -164
  59. package/dist/v1/libs/TinyEvents.mjs +0 -360
  60. package/docs/v1/libs/TinyEvents.md +0 -187
@@ -1,2 +1 @@
1
- /*! For license information please see TinyEssentials.min.js.LICENSE.txt */
2
- (()=>{var e={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,s=a(e),o=s[0],l=s[1],u=new i(function(e,t,r){return 3*(t+r)/4-r}(0,o,l)),c=0,h=l>0?o-4:o;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)],u[c++]=t>>16&255,u[c++]=t>>8&255,u[c++]=255&t;return 2===l&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,u[c++]=255&t),1===l&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,u[c++]=t>>8&255,u[c++]=255&t),u},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,s=[],o=16383,a=0,l=n-i;a<l;a+=o)s.push(u(e,a,a+o>l?l:a+o));return 1===i?(t=e[n-1],s.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],s.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),s.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)r[o]=s[o],n[s.charCodeAt(o)]=o;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 l(e){return r[e>>18&63]+r[e>>12&63]+r[e>>6&63]+r[63&e]}function u(e,t,r){for(var n,i=[],s=t;s<r;s+=3)n=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(255&e[s+2]),i.push(l(n));return i.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},251(e,t){t.read=function(e,t,r,n,i){var s,o,a=8*i-n-1,l=(1<<a)-1,u=l>>1,c=-7,h=r?i-1:0,d=r?-1:1,p=e[t+h];for(h+=d,s=p&(1<<-c)-1,p>>=-c,c+=a;c>0;s=256*s+e[t+h],h+=d,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+e[t+h],h+=d,c-=8);if(0===s)s=1-u;else{if(s===l)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,n),s-=u}return(p?-1:1)*o*Math.pow(2,s-n)},t.write=function(e,t,r,n,i,s){var o,a,l,u=8*s-i-1,c=(1<<u)-1,h=c>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:s-1,m=n?1:-1,f=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=c):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),(t+=o+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(o++,l/=2),o+h>=c?(a=0,o=c):o+h>=1?(a=(t*l-1)*Math.pow(2,i),o+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;e[r+p]=255&a,p+=m,a/=256,i-=8);for(o=o<<i|a,u+=i;u>0;e[r+p]=255&o,p+=m,o/=256,u-=8);e[r+p-m]|=128*f}},271(e,t,r){"use strict";var n=r(526),i=r(251),s="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.hp=l,t.IS=50;var o=2147483647;function a(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,l.prototype),t}function l(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 u(e,t,r)}function u(e,t,r){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!l.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|f(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(F(e,Uint8Array)){var t=new Uint8Array(e);return p(t.buffer,t.byteOffset,t.byteLength)}return d(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(F(e,ArrayBuffer)||e&&F(e.buffer,ArrayBuffer))return p(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(F(e,SharedArrayBuffer)||e&&F(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 l.from(n,t,r);var i=function(e){if(l.isBuffer(e)){var t=0|m(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||z(e.length)?a(0):d(e):"Buffer"===e.type&&Array.isArray(e.data)?d(e.data):void 0}(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return l.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 c(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 c(e),a(e<0?0:0|m(e))}function d(e){for(var t=e.length<0?0:0|m(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,l.prototype),n}function m(e){if(e>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function f(e,t){if(l.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||F(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 L(this,t,r);case"utf8":case"utf-8":return C(this,t,r);case"ascii":return M(this,t,r);case"latin1":case"binary":return k(this,t,r);case"base64":return A(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(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 w(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),z(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=l.from(t,n)),l.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 s,o=1,a=e.length,l=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;o=2,a/=2,l/=2,r/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var c=-1;for(s=r;s<a;s++)if(u(e,s)===u(t,-1===c?0:s-c)){if(-1===c&&(c=s),s-c+1===l)return c*o}else-1!==c&&(s-=s-c),c=-1}else for(r+l>a&&(r=a-l),s=r;s>=0;s--){for(var h=!0,d=0;d<l;d++)if(u(e,s+d)!==u(t,d)){h=!1;break}if(h)return s}return-1}function v(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var s=t.length;n>s/2&&(n=s/2);for(var o=0;o<n;++o){var a=parseInt(t.substr(2*o,2),16);if(z(a))return o;e[r+o]=a}return o}function E(e,t,r,n){return B($(t,e.length-r),e,r,n)}function T(e,t,r,n){return B(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function S(e,t,r,n){return B(H(t),e,r,n)}function x(e,t,r,n){return B(function(e,t){for(var r,n,i,s=[],o=0;o<e.length&&!((t-=2)<0);++o)n=(r=e.charCodeAt(o))>>8,i=r%256,s.push(i),s.push(n);return s}(t,e.length-r),e,r,n)}function A(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function C(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var s,o,a,l,u=e[i],c=null,h=u>239?4:u>223?3:u>191?2:1;if(i+h<=r)switch(h){case 1:u<128&&(c=u);break;case 2:128==(192&(s=e[i+1]))&&(l=(31&u)<<6|63&s)>127&&(c=l);break;case 3:s=e[i+1],o=e[i+2],128==(192&s)&&128==(192&o)&&(l=(15&u)<<12|(63&s)<<6|63&o)>2047&&(l<55296||l>57343)&&(c=l);break;case 4:s=e[i+1],o=e[i+2],a=e[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&l<1114112&&(c=l)}null===c?(c=65533,h=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=h}return function(e){var t=e.length;if(t<=I)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=I));return r}(n)}l.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}}(),l.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(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}}),Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}}),l.poolSize=8192,l.from=function(e,t,r){return u(e,t,r)},Object.setPrototypeOf(l.prototype,Uint8Array.prototype),Object.setPrototypeOf(l,Uint8Array),l.alloc=function(e,t,r){return function(e,t,r){return c(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)},l.allocUnsafe=function(e){return h(e)},l.allocUnsafeSlow=function(e){return h(e)},l.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==l.prototype},l.compare=function(e,t){if(F(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),F(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(e)||!l.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,s=Math.min(r,n);i<s;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},l.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}},l.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return l.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=l.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var s=e[r];if(F(s,Uint8Array))i+s.length>n.length?l.from(s).copy(n,i):Uint8Array.prototype.set.call(n,s,i);else{if(!l.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,i)}i+=s.length}return n},l.byteLength=f,l.prototype._isBuffer=!0,l.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},l.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},l.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},l.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?C(this,0,e):g.apply(this,arguments)},l.prototype.toLocaleString=l.prototype.toString,l.prototype.equals=function(e){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===l.compare(this,e)},l.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+">"},s&&(l.prototype[s]=l.prototype.inspect),l.prototype.compare=function(e,t,r,n,i){if(F(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),!l.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 s=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(t>>>=0),a=Math.min(s,o),u=this.slice(n,i),c=e.slice(t,r),h=0;h<a;++h)if(u[h]!==c[h]){s=u[h],o=c[h];break}return s<o?-1:o<s?1:0},l.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},l.prototype.indexOf=function(e,t,r){return w(this,e,t,r,!0)},l.prototype.lastIndexOf=function(e,t,r){return w(this,e,t,r,!1)},l.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 s=!1;;)switch(n){case"hex":return v(this,e,t,r);case"utf8":case"utf-8":return E(this,e,t,r);case"ascii":case"latin1":case"binary":return T(this,e,t,r);case"base64":return S(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function M(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 k(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 L(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",s=t;s<r;++s)i+=W[e[s]];return i}function N(e,t,r){for(var n=e.slice(t,r),i="",s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+256*n[s+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 _(e,t,r,n,i,s){if(!l.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function R(e,t,r,n,i,s){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function j(e,t,r,n,s){return t=+t,r>>>=0,s||R(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function O(e,t,r,n,s){return t=+t,r>>>=0,s||R(e,0,r,8),i.write(e,t,r,n,52,8),r+8}l.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,l.prototype),n},l.prototype.readUintLE=l.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||D(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n},l.prototype.readUintBE=l.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},l.prototype.readUint8=l.prototype.readUInt8=function(e,t){return e>>>=0,t||D(e,1,this.length),this[e]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(e,t){return e>>>=0,t||D(e,2,this.length),this[e]|this[e+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(e,t){return e>>>=0,t||D(e,2,this.length),this[e]<<8|this[e+1]},l.prototype.readUint32LE=l.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]},l.prototype.readUint32BE=l.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])},l.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||D(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},l.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||D(e,t,this.length);for(var n=t,i=1,s=this[e+--n];n>0&&(i*=256);)s+=this[e+--n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},l.prototype.readInt8=function(e,t){return e>>>=0,t||D(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},l.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},l.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},l.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},l.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]},l.prototype.readFloatLE=function(e,t){return e>>>=0,t||D(e,4,this.length),i.read(this,e,!0,23,4)},l.prototype.readFloatBE=function(e,t){return e>>>=0,t||D(e,4,this.length),i.read(this,e,!1,23,4)},l.prototype.readDoubleLE=function(e,t){return e>>>=0,t||D(e,8,this.length),i.read(this,e,!0,52,8)},l.prototype.readDoubleBE=function(e,t){return e>>>=0,t||D(e,8,this.length),i.read(this,e,!1,52,8)},l.prototype.writeUintLE=l.prototype.writeUIntLE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||_(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,s=0;for(this[t]=255&e;++s<r&&(i*=256);)this[t+s]=e/i&255;return t+r},l.prototype.writeUintBE=l.prototype.writeUIntBE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||_(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,s=1;for(this[t+i]=255&e;--i>=0&&(s*=256);)this[t+i]=e/s&255;return t+r},l.prototype.writeUint8=l.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,1,255,0),this[t]=255&e,t+1},l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||_(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},l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||_(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},l.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);_(this,e,t,r,i-1,-i)}var s=0,o=1,a=0;for(this[t]=255&e;++s<r&&(o*=256);)e<0&&0===a&&0!==this[t+s-1]&&(a=1),this[t+s]=(e/o|0)-a&255;return t+r},l.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);_(this,e,t,r,i-1,-i)}var s=r-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o|0)-a&255;return t+r},l.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},l.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},l.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},l.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||_(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},l.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||_(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},l.prototype.writeFloatLE=function(e,t,r){return j(this,e,t,!0,r)},l.prototype.writeFloatBE=function(e,t,r){return j(this,e,t,!1,r)},l.prototype.writeDoubleLE=function(e,t,r){return O(this,e,t,!0,r)},l.prototype.writeDoubleBE=function(e,t,r){return O(this,e,t,!1,r)},l.prototype.copy=function(e,t,r,n){if(!l.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},l.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&&!l.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 s;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(s=t;s<r;++s)this[s]=e;else{var o=l.isBuffer(e)?e:l.from(e,n),a=o.length;if(0===a)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<r-t;++s)this[s+t]=o[s%a]}return this};var P=/[^+/0-9A-Za-z-_]/g;function $(e,t){var r;t=t||1/0;for(var n=e.length,i=null,s=[],o=0;o<n;++o){if((r=e.charCodeAt(o))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.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;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function H(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(P,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function B(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 F(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function z(e){return e!=e}var W=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}()},975(e,t,r){"use strict";var n=r(606);function i(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function s(e,t){for(var r,n="",i=0,s=-1,o=0,a=0;a<=e.length;++a){if(a<e.length)r=e.charCodeAt(a);else{if(47===r)break;r=47}if(47===r){if(s===a-1||1===o);else if(s!==a-1&&2===o){if(n.length<2||2!==i||46!==n.charCodeAt(n.length-1)||46!==n.charCodeAt(n.length-2))if(n.length>2){var l=n.lastIndexOf("/");if(l!==n.length-1){-1===l?(n="",i=0):i=(n=n.slice(0,l)).length-1-n.lastIndexOf("/"),s=a,o=0;continue}}else if(2===n.length||1===n.length){n="",i=0,s=a,o=0;continue}t&&(n.length>0?n+="/..":n="..",i=2)}else n.length>0?n+="/"+e.slice(s+1,a):n=e.slice(s+1,a),i=a-s-1;s=a,o=0}else 46===r&&-1!==o?++o:o=-1}return n}var o={resolve:function(){for(var e,t="",r=!1,o=arguments.length-1;o>=-1&&!r;o--){var a;o>=0?a=arguments[o]:(void 0===e&&(e=n.cwd()),a=e),i(a),0!==a.length&&(t=a+"/"+t,r=47===a.charCodeAt(0))}return t=s(t,!r),r?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(e){if(i(e),0===e.length)return".";var t=47===e.charCodeAt(0),r=47===e.charCodeAt(e.length-1);return 0!==(e=s(e,!t)).length||t||(e="."),e.length>0&&r&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return i(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,t=0;t<arguments.length;++t){var r=arguments[t];i(r),r.length>0&&(void 0===e?e=r:e+="/"+r)}return void 0===e?".":o.normalize(e)},relative:function(e,t){if(i(e),i(t),e===t)return"";if((e=o.resolve(e))===(t=o.resolve(t)))return"";for(var r=1;r<e.length&&47===e.charCodeAt(r);++r);for(var n=e.length,s=n-r,a=1;a<t.length&&47===t.charCodeAt(a);++a);for(var l=t.length-a,u=s<l?s:l,c=-1,h=0;h<=u;++h){if(h===u){if(l>u){if(47===t.charCodeAt(a+h))return t.slice(a+h+1);if(0===h)return t.slice(a+h)}else s>u&&(47===e.charCodeAt(r+h)?c=h:0===h&&(c=0));break}var d=e.charCodeAt(r+h);if(d!==t.charCodeAt(a+h))break;47===d&&(c=h)}var p="";for(h=r+c+1;h<=n;++h)h!==n&&47!==e.charCodeAt(h)||(0===p.length?p+="..":p+="/..");return p.length>0?p+t.slice(a+c):(a+=c,47===t.charCodeAt(a)&&++a,t.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(i(e),0===e.length)return".";for(var t=e.charCodeAt(0),r=47===t,n=-1,s=!0,o=e.length-1;o>=1;--o)if(47===(t=e.charCodeAt(o))){if(!s){n=o;break}}else s=!1;return-1===n?r?"/":".":r&&1===n?"//":e.slice(0,n)},basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');i(e);var r,n=0,s=-1,o=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,l=-1;for(r=e.length-1;r>=0;--r){var u=e.charCodeAt(r);if(47===u){if(!o){n=r+1;break}}else-1===l&&(o=!1,l=r+1),a>=0&&(u===t.charCodeAt(a)?-1===--a&&(s=r):(a=-1,s=l))}return n===s?s=l:-1===s&&(s=e.length),e.slice(n,s)}for(r=e.length-1;r>=0;--r)if(47===e.charCodeAt(r)){if(!o){n=r+1;break}}else-1===s&&(o=!1,s=r+1);return-1===s?"":e.slice(n,s)},extname:function(e){i(e);for(var t=-1,r=0,n=-1,s=!0,o=0,a=e.length-1;a>=0;--a){var l=e.charCodeAt(a);if(47!==l)-1===n&&(s=!1,n=a+1),46===l?-1===t?t=a:1!==o&&(o=1):-1!==t&&(o=-1);else if(!s){r=a+1;break}}return-1===t||-1===n||0===o||1===o&&t===n-1&&t===r+1?"":e.slice(t,n)},format:function(e){if(null===e||"object"!=typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return function(e,t){var r=t.dir||t.root,n=t.base||(t.name||"")+(t.ext||"");return r?r===t.root?r+n:r+"/"+n:n}(0,e)},parse:function(e){i(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return t;var r,n=e.charCodeAt(0),s=47===n;s?(t.root="/",r=1):r=0;for(var o=-1,a=0,l=-1,u=!0,c=e.length-1,h=0;c>=r;--c)if(47!==(n=e.charCodeAt(c)))-1===l&&(u=!1,l=c+1),46===n?-1===o?o=c:1!==h&&(h=1):-1!==o&&(h=-1);else if(!u){a=c+1;break}return-1===o||-1===l||0===h||1===h&&o===l-1&&o===a+1?-1!==l&&(t.base=t.name=0===a&&s?e.slice(1,l):e.slice(a,l)):(0===a&&s?(t.name=e.slice(1,o),t.base=e.slice(1,l)):(t.name=e.slice(a,o),t.base=e.slice(a,l)),t.ext=e.slice(o,l)),a>0?t.dir=e.slice(0,a-1):s&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};o.posix=o,e.exports=o},606(e){var t,r,n=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function o(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var a,l=[],u=!1,c=-1;function h(){u&&a&&(u=!1,a.length?l=a.concat(l):c=-1,l.length&&d())}function d(){if(!u){var e=o(h);u=!0;for(var t=l.length;t;){for(a=l,l=[];++c<t;)a&&a[c].run();c=-1,t=l.length}a=null,u=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{return r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function m(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new p(e,t)),1!==l.length||u||o(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=m,n.addListener=m,n.once=m,n.off=m,n.removeListener=m,n.removeAllListeners=m,n.emit=m,n.prependListener=m,n.prependOnceListener=m,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},133(){},370(){},766(){},911(){}};const t={};function r(n){const i=t[n];if(void 0!==i)return i.exports;const s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var n=0;n<t.length;){var i=t[n++],s=t[n++];r.o(e,i)?0===s&&n++:0===s?Object.defineProperty(e,i,{enumerable:!0,value:t[n++]}):Object.defineProperty(e,i,{enumerable:!0,get:s})}else for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};let n={};(()=>{"use strict";r.r(n),r.d(n,{ColorSafeStringify:()=>K,FuzzySet:()=>jr,MamdaniInferenceSystem:()=>Or,TinyAdvancedRaffle:()=>hr,TinyAfterScrollWatcher:()=>_t,TinyAnalogClock:()=>Ir,TinyArrayComparator:()=>Lr,TinyArrayPaginator:()=>dr,TinyClassManager:()=>$r,TinyClipboard:()=>Ut,TinyColorConverter:()=>Jt,TinyColorValidator:()=>Cr,TinyCookieConsent:()=>gr,TinyDayNightCycle:()=>ur,TinyDomReadyManager:()=>vt,TinyDragDropDetector:()=>le,TinyDragger:()=>bt,TinyElementObserver:()=>it,TinyEvents:()=>zt,TinyGamepad:()=>lr,TinyHtml:()=>yt,TinyI18:()=>br,TinyIframeEvents:()=>nr,TinyInventory:()=>mr,TinyInventoryTrader:()=>fr,TinyLevelUp:()=>i,TinyLoadingScreen:()=>xr,TinyLocalStorage:()=>tr,TinyMediaPlayer:()=>Wr,TinyNeedBar:()=>Er,TinyNewWinEvents:()=>sr,TinyNotifications:()=>Et,TinyNotifyCenter:()=>X,TinyPromiseQueue:()=>J,TinyRadioFm:()=>Br,TinyRateLimiter:()=>G,TinySimpleDice:()=>Sr,TinySmartScroller:()=>qt,TinyTextDiffer:()=>Mr,TinyTextRangeEditor:()=>Vt,TinyTextarea:()=>or,TinyTimeout:()=>Yt,TinyToastNotify:()=>Q,UltraRandomMsgGen:()=>Ft,addAiMarkerShortcut:()=>W,areElsCollBottom:()=>Fe,areElsCollLeft:()=>ze,areElsCollPerfBottom:()=>Ve,areElsCollPerfLeft:()=>Ue,areElsCollPerfRight:()=>Ke,areElsCollPerfTop:()=>qe,areElsCollRight:()=>We,areElsCollTop:()=>Be,areElsColliding:()=>Je,areElsPerfColliding:()=>Ge,arraySortPositions:()=>a,asyncReplace:()=>B,backupFile:()=>Ae,breakdownDuration:()=>d,calculateMarketcap:()=>$,checkObj:()=>S,clearDirectory:()=>me,clearDirectoryAsync:()=>Re,cloneObjTypeOrder:()=>v,compareMarketcap:()=>H,countObj:()=>m,defuzzifyCentroid:()=>Dr,diffArrayList:()=>o,diffStrings:()=>V,dirExists:()=>ge,dirSize:()=>xe,dirSizeAsync:()=>He,documentIsFullScreen:()=>x,ensureCopyFile:()=>we,ensureDirectory:()=>pe,exitFullScreen:()=>M,extendObjType:()=>w,extractMediaId3Tags:()=>Nt,fetchJson:()=>se,fetchText:()=>oe,fileExists:()=>fe,fileSize:()=>Se,fileSizeAsync:()=>$e,formatBytes:()=>O,formatCustomTimer:()=>u,formatDayTimer:()=>h,formatTimer:()=>c,genFibonacciSeq:()=>P,getAge:()=>j,getElsCollDetails:()=>nt,getElsCollDirDepth:()=>rt,getElsCollOverlap:()=>Qe,getElsCollOverlapPos:()=>Ze,getElsColliding:()=>Ye,getElsPerfColliding:()=>Xe,getElsRelativeCenterOffset:()=>tt,getLatestBackupPath:()=>Ce,getPercentage:()=>R,getRectCenter:()=>et,getSimplePerc:()=>_,getTimeDuration:()=>l,installWindowHiddenScript:()=>ae,isDirEmpty:()=>ye,isDirEmptyAsync:()=>je,isFullScreenMode:()=>C,isJsonObject:()=>f,isScreenFilled:()=>A,listDirs:()=>Te,listDirsAsync:()=>Pe,listFiles:()=>Ee,listFilesAsync:()=>Oe,objType:()=>T,offFullScreenChange:()=>N,onFullScreenChange:()=>L,parseMediaMetadata:()=>Dt,readBase64Blob:()=>ee,readFileBlob:()=>Z,readJsonBlob:()=>te,readJsonFile:()=>he,renameFileAddPrefixSuffix:()=>Le,renameFileBatch:()=>Me,renameFileNormalizeCase:()=>Ne,renameFilePadNumbers:()=>De,renameFileRegex:()=>ke,reorderObjTypeOrder:()=>b,requestFullScreen:()=>I,restoreLatestBackup:()=>Ie,ruleOfThree:()=>D,safeTextTrim:()=>q,saveJsonFile:()=>re,shuffleArray:()=>s,toTitleCase:()=>F,toTitleCaseLowerFirst:()=>z,trapezoid:()=>_r,tryDeleteFile:()=>be,valMediaContentMetadata:()=>kt,valMediaContentMetadataPartial:()=>Lt,writeJsonFile:()=>de,writeTextFile:()=>ve});var e={};r.r(e),r.d(e,{iu:()=>Fe,cq:()=>ze,P8:()=>Ve,BO:()=>Ue,eh:()=>Ke,L2:()=>qe,lP:()=>We,Kr:()=>Be,wE:()=>Je,D6:()=>Ge,PN:()=>nt,t_:()=>rt,aI:()=>Qe,ej:()=>Ze,kx:()=>Ye,Pd:()=>Xe,NW:()=>tt,Qv:()=>et});var t={};r.r(t),r.d(t,{areElsCollBottom:()=>Fe,areElsCollLeft:()=>ze,areElsCollPerfBottom:()=>Ve,areElsCollPerfLeft:()=>Ue,areElsCollPerfRight:()=>Ke,areElsCollPerfTop:()=>qe,areElsCollRight:()=>We,areElsCollTop:()=>Be,areElsColliding:()=>Je,areElsPerfColliding:()=>Ge,getElsCollDetails:()=>nt,getElsCollDirDepth:()=>rt,getElsCollOverlap:()=>Qe,getElsCollOverlapPos:()=>Ze,getElsColliding:()=>Ye,getElsPerfColliding:()=>Xe,getElsRelativeCenterOffset:()=>tt,getRectCenter:()=>et});const i=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 s(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 o(e,t){const r=e.filter(e=>!t.includes(e));return{added:t.filter(t=>!e.includes(t)),removed:r}}function a(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 l(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 u(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,s=n>=4,o=n>=3,a=n>=2,l=n>=1,u=n>=0,c={years:i?0:NaN,months:s?0:NaN,days:o?0:NaN,hours:a?0:NaN,minutes:l?0:NaN,seconds:u?0:NaN,total:NaN};let h=e;if(i||s||o){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),c.years++;if(s)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),c.months++;if(o)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),c.days++;h=Math.floor((t.getTime()-r.getTime())/1e3)}a&&(c.hours=Math.floor(h/3600),h%=3600),l&&(c.minutes=Math.floor(h/60),h%=60),u&&(c.seconds=h),s&&(c.years,c.months,c.days),i&&(c.years,c.months,c.days),c.total=+e.toFixed(2).replace(/\.00$/,"");const d=e=>{const t="string"==typeof e?parseInt(e):e;return Number.isNaN(t)?"NaN":String(t).padStart(2,"0")},p=[a?d(c.hours):null,l?d(c.minutes):null,u?d(c.seconds):null].filter(e=>null!==e).join(":");return r.replace(/\{years\}/g,String(c.years)).replace(/\{months\}/g,String(c.months)).replace(/\{days\}/g,String(c.days)).replace(/\{hours\}/g,d(c.hours)).replace(/\{minutes\}/g,d(c.minutes)).replace(/\{seconds\}/g,d(c.seconds)).replace(/\{time\}/g,p).replace(/\{total\}/g,String(c.total)).trim()}function c(e){return u(e,"hours","{hours}:{minutes}:{seconds}")}function h(e){return u(e,"days","{days}d {hours}:{minutes}:{seconds}")}function d(e,t="milliseconds"){e=Math.max(0,Math.floor(e));const r=["milliseconds","seconds","minutes","hours","days","months","years"].indexOf(t),n=r>=6,i=r>=5,s=r>=4,o=r>=3,a=r>=2,l=r>=1,u=r>=0,c={years:n?0:NaN,months:i?0:NaN,days:s?0:NaN,hours:o?0:NaN,minutes:a?0:NaN,seconds:l?0:NaN,milliseconds:u?0:NaN,total:NaN};let h=e;if(n||i||s){const e=new Date(1980,0,1),t=new Date(e.getTime()+h),r=new Date(e);if(n)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),c.years++;if(i)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),c.months++;if(s)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),c.days++;h=t.getTime()-r.getTime()}return o&&(c.hours=Math.floor(h/36e5),h%=36e5),a&&(c.minutes=Math.floor(h/6e4),h%=6e4),l&&(c.seconds=Math.floor(h/1e3),h%=1e3),u&&(c.milliseconds=h),i&&(c.years,c.months,c.days),n&&(c.years,c.months,c.days),c.total=+e,c}var p=r(271);function m(e){return Array.isArray(e)?e.length:f(e)?Object.keys(e).length:0}function f(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}const g="undefined"!=typeof window&&void 0!==window.document,y={items:{},order:[]};function w(e,t){const r=[],n=Array.isArray(e)?e:Object.entries(e);for(const[e,i]of n)if(!y.items.hasOwnProperty(e)){y.items[e]=i;let n="number"==typeof t?t:-1;if(-1===n){const e=y.order.indexOf("object");n=e>-1?e:y.order.length}n=Math.min(Math.max(0,n),y.order.length),y.order.splice(n,0,e),r.push(e)}return r}function b(e){const t=[...y.order];return!!e.every(e=>t.includes(e))&&(y.order=e.slice(),!0)}function v(){return[...y.order]}const E=e=>{if(null===e)return"null";for(const t of y.order)if("function"!=typeof y.items[t]||y.items[t](e))return t;return"unknown"};function T(e,t){if(void 0===e)return null;const r=E(e);return"string"==typeof t?r===t.toLowerCase():r}function S(e){const t={valid:null,type:null};for(const r of y.order)if("function"==typeof y.items[r]){const n=y.items[r](e);if(n){t.valid=n,t.type=r;break}}return t}w([["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)]]),g||w([["buffer",e=>void 0!==p.hp&&p.hp.isBuffer(e)]]),g&&w([["file",e=>"undefined"!=typeof File&&e instanceof File]]),w([["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]]),g&&w([["htmlelement",e=>"undefined"!=typeof HTMLElement&&e instanceof HTMLElement]]),w([["object",e=>f(e)]]);const x=()=>!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitIsFullScreen||document.mozFullScreen),A=()=>window.innerHeight===screen.height&&window.innerWidth===screen.width,C=()=>x()||A(),I=e=>new Promise(async(t,r)=>{const n=document.documentElement;try{n.requestFullscreen?await n.requestFullscreen(e):n.mozRequestFullScreen?n.mozRequestFullScreen(e):n.webkitRequestFullScreen?n.webkitRequestFullScreen(e):n.msRequestFullscreen&&n.msRequestFullscreen(e),t()}catch(e){r(e)}}),M=()=>new Promise((e,t)=>{if(document.exitFullscreen)document.exitFullscreen().then(e).catch(t);else try{if(document.mozCancelFullScreen)document.mozCancelFullScreen();else if(document.webkitCancelFullScreen)document.webkitCancelFullScreen();else{if(!document.msExitFullscreen)throw new Error("Fullscreen API is not supported");document.msExitFullscreen()}e()}catch(e){t(e)}}),k=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],L=(e,t)=>{k.forEach(r=>{document.addEventListener(r,e,t)})},N=(e,t)=>{k.forEach(r=>{document.removeEventListener(r,e,t)})};function D(e,t,r,n=!1){return n?Number(e*t)/r:Number(r*t)/e}function _(e,t){return e*(t/100)}function R(e,t){return 0===t?0:e/t*100}function j(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 s=n.getMonth(),o=r.getMonth(),a=n.getDate(),l=r.getDate();return(s<o||s===o&&a<l)&&i--,Math.abs(i)}return null}function O(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,s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),i);let o=e/Math.pow(1024,s);if(null!==t){const e=t<0?0:t;o=parseFloat(o.toFixed(e))}return{unit:n[s],value:o}}function P({baseValues:e=[0,1],length:t=10,combiner:r=(e,t)=>e+t}={}){if(!Array.isArray(e)||2!==e.length)throw new Error("baseValues must be an array of exactly two numbers");const n=[...e.slice(0,2)];for(let e=2;e<t;e++){const t=r(n[e-2],n[e-1],e);n.push(t)}return n}function $(e,t){if(Number.isNaN(e)||!Number.isFinite(e))throw new TypeError("Original market cap must be a number.");if(Number.isNaN(t)||!Number.isFinite(t))throw new TypeError("Circulating supply must be a number.");if(t<=0)throw new Error("Circulating supply must be greater than zero.");return e/t}function H(e,t,r){if(Number.isNaN(r)||!Number.isFinite(r))throw new TypeError("New market cap must be a number.");const n=$(e,t),i="number"==typeof r?r/t:NaN;return{originalPrice:n,newPrice:i,priceChangePercent:"number"==typeof r?(i-n)/n*100:NaN}}async function B(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())}function F(e){return e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase())}function z(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 W({key:e="a",className:t="detect-made-by-ai"}={}){if("undefined"==typeof HTMLElement)throw new Error("[AiMarkerShortcut] Environment does not support the DOM. This function must be run in a browser.");const r=function(r){if(r.ctrlKey&&r.altKey&&r.key.toLowerCase()===e){if(r.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(t)}};return document.addEventListener("keydown",r),r}function q(e,t,r=.6){if("string"!=typeof e)throw new TypeError("Expected a string for 'text', but received "+typeof e);if(!Number.isInteger(t)||t<=0)throw new TypeError(`Expected 'limit' to be a positive integer, but received ${t}`);if("number"!=typeof r||r<0||r>1)throw new TypeError(`Expected 'safeCutZone' to be a number between 0 and 1, but received ${r}`);let n=e.trim();if(n.length>t){const e=n.lastIndexOf(" ",t);return e>0&&e>=t*r?`${n.substring(0,e).trim()}...`:`${n.substring(0,t).trim()}...`}return n}function V(e,t){const r={added:{},removed:{},modified:{}};for(const n in e)n in t?e[n]!==t[n]&&(r.modified[n]={old:e[n],new:t[n]}):r.removed[n]=e[n];for(const n in t)n in e||(r.added[n]=t[n]);return r}class U{#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={...U.#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={...U.#t.default}}loadColorPreset(e){const t=U.#t[e];if(!t)throw new Error(`Preset "${e}" not found.`);this.#e={...t}}saveColorPreset(e,t){U.#t[e]={...t}}getAvailablePresets(){return Object.keys(U.#t)}}const K=U,J=class{#n=[];#i=!1;#s={};#o=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:s}=e;try{if(s&&this.#o.has(s))return n(new Error("The function was canceled on TinyPromiseQueue.")),this.#o.delete(s),this.#i=!1,void this.#l();i&&s&&await new Promise(e=>{const t=setTimeout(()=>{delete this.#s[s],e(null)},i);this.#s[s]=t}),r(await t())}catch(e){n(e)}finally{this.#i=!1,this.#l()}}}async#u(){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.#l();await Promise.all(e.map(({task:e,resolve:t,reject:r,id:n})=>new Promise(async i=>{if(n&&this.#o.has(n))return this.#o.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.#l()}async#l(){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.#u()}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.#l()}):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.#l()})}cancelTask(e){if("string"!=typeof e)throw new Error('The "id" parameter must be a string.');let t=!1;e in this.#s&&(clearTimeout(this.#s[e]),delete this.#s[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.#o.add(e),t}},G=class{#c=null;#h=null;#d=null;#p=null;#m=null;#f=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 s=e=>"number"==typeof e&&Number.isFinite(e)&&e>=1&&Number.isInteger(e),o=s(e),a=s(t),l=s(r),u=s(n);if(!o&&!a)throw new Error("RateLimiter requires at least one valid option: 'maxHits' or 'interval'.");if(void 0!==e&&!o)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&&!l)throw new Error("'cleanupInterval' must be a positive integer in milliseconds if defined.");if(!u)throw new Error("'maxIdle' must be a positive integer in milliseconds.");if("number"==typeof i&&Number.isFinite(i)&&i>0)this.#c=Math.floor(i);else{if(null!=i)throw new Error("maxMemory must be a positive number or null");this.#c=null}this.#d=o?e:null,this.#p=a?t:null,this.#m=l?r:null,this.#f=n,null!==this.#m&&(this.#h=setInterval(()=>this._cleanup(),this.#m))}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.#c&&"number"==typeof this.#c&&n.length>this.#c&&(n.splice(0,n.length-this.#c),"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.#d?t>this.getMaxHits():t>0}return null!==this.#d&&r.length>this.getMaxHits()}resetGroup(e){this.groupFlags.delete(e),this.groupData.delete(e),this.lastSeen.delete(e),this.groupTTL.delete(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.#f||!Number.isFinite(this.#f)||this.#f<0)throw new Error("'maxIdle' must be a non-negative finite number.");return this.#f}setMaxIdle(e){if("number"!=typeof e||!Number.isFinite(e)||e<0)throw new Error("'maxIdle' must be a non-negative finite number.");this.#f=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.#d||!Number.isFinite(this.#d))throw new Error("'maxHits' is not a valid finite number.");return this.#d}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 Y{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,Y.getTemplate())}#w;#b;#v;#E;#T;#S=0;#x=99;#A=300;#C=!1;#I=new WeakMap;#M(e){if(this.#I.delete(e),!(e instanceof HTMLElement))throw new Error("Invalid HTMLElement to clear.");e.classList.add("removing"),setTimeout(()=>{this.markAsRead(e),e.remove()},this.#A)}#k(e){this.#S=Math.max(0,e),this.#v.setAttribute("data-value",String(this.#S)),this.#v.textContent=this.#S>this.#x?`${this.#x}+`:String(this.#S)}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 s=t?.querySelector(".clear-all"),o=t?.querySelector(".list")??null;if(!(o instanceof HTMLElement))throw new Error(`NotificationCenter: ".list" inside center must be an HTMLElement. Got: ${o}`);this.#w=t,this.#b=o,this.#v=r,this.#E=n,this.#T=i,this.#E.addEventListener("click",()=>this.toggle()),this.#w.querySelector(".close")?.addEventListener("click",()=>this.close()),s&&s.addEventListener("click",()=>this.clear()),this.#T.addEventListener("click",e=>{e.target===this.#T&&this.close()})}setMarkAllAsReadOnClose(e){if("boolean"!=typeof e)throw new TypeError("Expected boolean for markAllAsReadOnClose, got "+typeof e);this.#C=e}setRemoveDelay(e){if("number"!=typeof e)throw new Error('NotificationCenter: "ms" must be an number.');this.#A=e}getItemMode(e){const t=this.getItem(e);return t?this.#I.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.#k(this.#S-1))}add(e,t="text"){const r=document.createElement("div");r.className="item unread";let n=null,i=null,s=null,o=null;if("object"==typeof e&&null!==e?(n=e.title,i=e.message,s=e.avatar,o=e.onClick):i=e,s){const e=document.createElement("div");e.className="avatar",e.style.backgroundImage=`url("${s}")`,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 l=document.createElement("div");l.className="message","html"===t?l.innerHTML=i:l.textContent=i,a.appendChild(l),"function"==typeof o&&(r.classList.add("clickable"),r.addEventListener("click",e=>{e.target instanceof HTMLElement&&!e.target.closest(".notify-close")&&o(e)}));const u=document.createElement("button");u.className="notify-close",u.setAttribute("type","button"),u.innerHTML="&times;",u.addEventListener("click",e=>{e.stopPropagation(),this.#M(r)}),r.append(a,u),this.#b.prepend(r),this.#I.set(r,t),this.#k(this.#S+1)}remove(e){const t=this.getItem(e);this.#M(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.#M(r),e=!0)}}open(){this.#T.classList.remove("hidden"),this.#w.classList.add("open")}close(){if(this.#T.classList.add("hidden"),this.#w.classList.remove("open"),this.#C){const e=this.#b.querySelectorAll(".item.unread");for(const t of e)t instanceof HTMLElement&&this.markAsRead(t)}}toggle(){this.#w.classList.contains("open")?this.close():this.open()}recount(){const e=this.#b.querySelectorAll(".item.unread").length;this.#k(e)}get count(){return this.#S}destroy(){this.#E?.removeEventListener("click",this.toggle),this.#w?.querySelector(".close")?.removeEventListener("click",this.close),this.#w?.querySelector(".clear-all")?.removeEventListener("click",this.clear),this.#T?.removeEventListener("click",this.close),this.clear(),this.#w?.remove(),this.#T?.remove(),this.#E?.remove(),this.#S=0,this.#I=new WeakMap}}const X=Y,Q=class{#L;#N;#D;#_;#R;#j;constructor(e="top",t="right",r=3e3,n=50,i=300,s=".notify-container"){this.#O(e),this.#P(t),this.#$(r,"baseDuration"),this.#$(n,"extraPerChar"),this.#$(i,"fadeOutDuration"),this.#L=e,this.#N=t,this.#D=r,this.#_=n,this.#R=i;const o=document.querySelector(`${s}.${e}.${t}`);o instanceof HTMLElement?this.#j=o:(this.#j=document.createElement("div"),this.#j.className=`notify-container ${e} ${t}`,document.body.appendChild(this.#j))}getContainer(){if(!(this.#j instanceof HTMLElement))throw new Error("Container is not a valid HTMLElement.");return this.#j}#O(e){if(!["top","bottom"].includes(e))throw new Error(`Invalid vertical direction "${e}". Expected "top" or "bottom".`)}#P(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.#L}setY(e){this.#O(e);const t=this.getContainer();t.classList.remove(this.#L),t.classList.add(e),this.#L=e}getX(){return this.#N}setX(e){this.#P(e);const t=this.getContainer();t.classList.remove(this.#N),t.classList.add(e),this.#N=e}getBaseDuration(){return this.#D}setBaseDuration(e){this.#$(e,"baseDuration"),this.#D=e}getExtraPerChar(){return this.#_}setExtraPerChar(e){this.#$(e,"extraPerChar"),this.#_=e}getFadeOutDuration(){return this.#R}setFadeOutDuration(e){this.#$(e,"fadeOutDuration"),this.#R=e}show(e){let t="",r="",n=null,i=!1,s=null;const o=document.createElement("div");if(o.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,s="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,o.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(--notify-close-color-hover)"}),a.addEventListener("mouseleave",()=>{a.style.color="var(--notify-close-color)"}),s){const e=document.createElement("img");e.src=s,e.alt="avatar",e.className="avatar",o.appendChild(e)}if(r){const e=document.createElement("strong");e.textContent=r,e.style.display="block",o.appendChild(e)}if(i){const e=document.createElement("div");e.innerHTML=t,o.appendChild(e)}else o.appendChild(document.createTextNode(t));o.appendChild(a),this.getContainer().appendChild(o);const l=this.#D+t.length*this.#_+this.#R;let u=!1;const c=()=>{u||(u=!0,o.classList.remove("enter","show"),o.classList.add("exit"),setTimeout(()=>o.remove(),this.#R))};"function"==typeof n&&o.addEventListener("click",e=>{e.target!==a&&n(e,c)}),a.addEventListener("click",e=>{e.stopPropagation(),c()}),setTimeout(()=>{o.classList.remove("enter"),o.classList.add("show")},1),setTimeout(()=>c(),l)}destroy(){this.#j instanceof HTMLElement&&(this.#j.querySelectorAll(".notify").forEach(e=>e.remove()),this.#j.parentNode&&this.#j.parentNode.removeChild(this.#j),this.#j=null)}};function Z(e,t){return new Promise((r,n)=>{const i=new FileReader;i.onload=()=>{try{r(i.result)}catch(e){n(e)}},i.onerror=()=>{n(i.error)},i[t](e)})}function ee(e,t=!1){return new Promise((r,n)=>{"string"!=typeof t&&"boolean"!=typeof t&&n(new TypeError("The isDataUrl parameter must be a boolean or a string.")),Z(e,"readAsDataURL").then(e=>{if("string"!=typeof e)throw new TypeError("Expected file content to be a string.");const n=e.match(/^data:(.+);base64,(.*)$/);if(!n||!n[2])throw new Error("Invalid data URL format or missing Base64 content.");const[,i,s]=n;if(!/^[\w/+]+=*$/.test(s))throw new Error("Base64 content is malformed.");if("boolean"==typeof t)return r(t?e:s);if(!/^[\w-]+\/[\w.+-]+$/.test(t))throw new Error(`Invalid MIME type string: ${t}`);return r(`data:${t};base64,${s}`)}).catch(n)})}function te(e){return new Promise((t,r)=>Z(e,"readAsText").then(e=>{if("string"!=typeof e)throw new TypeError("Expected file content to be a string.");const r=e.trim();if(0===r.length)throw new Error("File is empty or contains only whitespace.");const n=JSON.parse(r);if("object"!=typeof n||null===n)throw new Error("Parsed content is not a valid JSON object or array.");t(n)}).catch(r))}function re(e,t,r=2){const n=JSON.stringify(t,null,r),i=new Blob([n],{type:"application/json"}),s=URL.createObjectURL(i),o=document.createElement("a");o.href=s,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(s)}function ne(e,t){if("function"!=typeof t)throw new TypeError('The "onProgress" argument must be a function.');if(!e.body)return e;const r=e.headers.get("content-length"),n=r?parseInt(r,10):0;let i=0;const s=e.body.getReader(),o=new ReadableStream({async start(e){for(;;){const{done:r,value:o}=await s.read();if(r)break;i+=o.byteLength,t(i,n),e.enqueue(o)}e.close()}});return new Response(o,{headers:e.headers,status:e.status,statusText:e.statusText})}async function ie(e,{method:t="GET",body:r,timeout:n=0,retries:i=0,headers:s={},signal:o=null,onProgress:a}={}){if("string"!=typeof e||!e.startsWith("../")&&!e.startsWith("./")&&!e.startsWith("/")&&!e.startsWith("https://")&&!e.startsWith("http://"))throw new Error("Invalid URL: must be a valid http or https address.");if("string"!=typeof t||!t.trim())throw new Error("Invalid method: must be a non-empty string.");if(!o){if("number"!=typeof n||!Number.isFinite(n)||Number.isNaN(n)||n<0)throw new Error("Invalid timeout: must be a positive number.");if("number"!=typeof i||!Number.isFinite(i)||Number.isNaN(i)||i<0)throw new Error("Invalid retries: must be a positive number.")}const l=o?1:i+1;let u=null;for(let c=0;c<l;c++){const l=o?null:new AbortController,h=o||(l?.signal??null),d=!o&&n&&l?setTimeout(()=>l.abort(),n):null;try{const n=await fetch(e,{method:t.toUpperCase(),headers:{Accept:"application/json",...s},body:void 0!==r?f(r)?JSON.stringify(r):r:void 0,signal:h});if(d&&clearTimeout(d),!n.ok)throw new Error(`HTTP error: ${n.status} ${n.statusText}`);return a?ne(n,a):n}catch(e){if(u=e,o)break;c<i&&await new Promise(e=>setTimeout(e,300*(c+1)))}}throw new Error(`Failed to fetch JSON from "${e}"${u?`: ${u.message}`:"."}`)}async function se(e,t){return new Promise((r,n)=>{ie(e,t).then(async e=>{const t=e.headers.get("content-type")||"";if(!t.includes("application/json"))throw new Error(`Unexpected content-type: ${t}`);const n=await e.json();if(!Array.isArray(n)&&!f(n))throw new Error("Received invalid data instead of valid JSON.");return r(n)}).catch(n)})}async function oe(e,t,r){return new Promise((n,i)=>{ie(e,r).then(async e=>{const r=e.headers.get("content-type")||"";if(Array.isArray(t)&&t.length>0&&!t.some(e=>r.includes(e)))throw new Error(`Blocked MIME type: ${r}`);const i=await e.text();return n(i)}).catch(i)})}function ae({element:e=document.body,hiddenClass:t="windowHidden",visibleClass:r="windowVisible",onVisible:n,onHidden:i}={}){if(!(e instanceof Element))throw new TypeError('"element" must be an instance of Element.');if("string"!=typeof t)throw new TypeError('"hiddenClass" must be a string.');if("string"!=typeof r)throw new TypeError('"visibleClass" must be a string.');if(void 0!==n&&"function"!=typeof n)throw new TypeError('"onVisible" must be a function if provided.');if(void 0!==i&&"function"!=typeof i)throw new TypeError('"onHidden" must be a function if provided.');let s="",o="";const a=()=>{e.classList.remove(t),e.classList.remove(r)};let l=null;const u=["visibilitychange","mozvisibilitychange","webkitvisibilitychange","msvisibilitychange"],c=["hidden","mozHidden","webkitHidden","msHidden"];for(let e=0;e<c.length;e++)if(c[e]in document){l=c[e];break}const h=function(u){a();const c=u?.type,h=l&&document[l];["focus","focusin","pageshow"].includes(c)?(e.classList.add(r),n?.({type:c,oldClass:o,oldType:s}),o=r):["blur","focusout","pagehide"].includes(c)||h?(e.classList.add(t),i?.({type:c,oldClass:o,oldType:s}),o=t):(e.classList.add(r),n?.({type:c,oldClass:o,oldType:s}),o=r),s=c};let d=()=>{};if(l){const e=u[c.indexOf(l)];document.addEventListener(e,h),window.addEventListener("focus",h),window.addEventListener("blur",h),d=()=>{document.removeEventListener(e,h),window.removeEventListener("focus",h),window.removeEventListener("blur",h),a()}}else"onfocusin"in document?(document.onfocusin=document.onfocusout=h,d=()=>{document.onfocusin=document.onfocusout=null,a()}):(window.onpageshow=window.onpagehide=window.onfocus=window.onblur=h,d=()=>{window.onpageshow=window.onpagehide=window.onfocus=window.onblur=null,a()});const p=new Event(l&&document[l]?"blur":"focus");return h(p),d}const le=class{#H;#B;#F;#z;#W;#q;#V;constructor(e,t){const{hoverClass:r="dnd-hover",onDrop:n,onEnter:i,onLeave:s}=t;if(!(e instanceof HTMLElement))throw new TypeError('The "target" option must be an instance of HTMLElement.');if("string"!=typeof r)throw new TypeError('The "hoverClass" option must be a string.');if("function"!=typeof n)throw new TypeError('The "onDrop" option must be a function.');if("function"!=typeof i)throw new TypeError('The "onEnter" option must be a function.');if("function"!=typeof s)throw new TypeError('The "onLeave" option must be a function.');this.#H=e,this.#B=r,this.#F=n||(()=>{}),this.#z=i,this.#W=s,this.#q=!1,this.#V=!1,this._handleDragEnter=this._handleDragEnter.bind(this),this._handleDragOver=this._handleDragOver.bind(this),this._handleDragLeave=this._handleDragLeave.bind(this),this._handleDrop=this._handleDrop.bind(this),this.#U()}getTarget(){return this.#H}getHoverClass(){return this.#B}isDragging(){return this.#q}bound(){return this.#V}#U(){if(this.#V)return;const e=this.getTarget();e.addEventListener("dragenter",this._handleDragEnter),e.addEventListener("dragover",this._handleDragOver),e.addEventListener("dragleave",this._handleDragLeave),e.addEventListener("drop",this._handleDrop),this.#V=!0}#K(){if(!this.#V)return;const e=this.getTarget();e.removeEventListener("dragenter",this._handleDragEnter),e.removeEventListener("dragover",this._handleDragOver),e.removeEventListener("dragleave",this._handleDragLeave),e.removeEventListener("drop",this._handleDrop),this.#V=!1}_handleDragEnter(e){if(e.preventDefault(),!this.#q){const t=this.getTarget();this.#q=!0,t.classList.add(this.#B),this.#z(e)}}_handleDragOver(e){e.preventDefault(),e.dataTransfer?e.dataTransfer.dropEffect="copy":console.warn("[TinyDragDropDetector] [handleDragOver] DragOver event missing dataTransfer.")}_handleDragLeave(e){e.preventDefault();const t=this.getTarget();null!==e.relatedTarget&&t.contains(e.relatedTarget)||(this.#q=!1,t.classList.remove(this.#B),this.#W(e))}_handleDrop(e){if(e.preventDefault(),!e.dataTransfer)return void console.warn("[TinyDragDropDetector] [handleDrop] DragOver event missing dataTransfer.");const t=this.getTarget();this.#q=!1,t.classList.remove(this.#B);const r=e.dataTransfer.files;r.length>0&&this.#F(r,e)}destroy(){this.#K(),this.getTarget().classList.remove(this.#B)}};var ue=r(133),ce=r(975);function he(e){if(!(0,ue.existsSync)(e))throw new Error(`File not found: ${e}`);const t=(0,ue.readFileSync)(e,"utf-8");return JSON.parse(t)}function de(e,t,r=2){const n=JSON.stringify(t,null,r);(0,ue.writeFileSync)(e,n,"utf-8")}function pe(e){(0,ue.existsSync)(e)||(0,ue.mkdirSync)(e,{recursive:!0})}function me(e){if(!(0,ue.existsSync)(e))return;const t=(0,ue.readdirSync)(e);for(const r of t){const t=(0,ce.join)(e,r);(0,ue.lstatSync)(t).isDirectory()?(0,ue.rmSync)(t,{recursive:!0,force:!0}):(0,ue.unlinkSync)(t)}}function fe(e){return(0,ue.existsSync)(e)&&(0,ue.lstatSync)(e).isFile()}function ge(e){return(0,ue.existsSync)(e)&&(0,ue.lstatSync)(e).isDirectory()}function ye(e){return 0===(0,ue.readdirSync)(e).length}function we(e,t,r){pe((0,ce.dirname)(t)),(0,ue.copyFileSync)(e,t,r)}function be(e){return!!fe(e)&&((0,ue.unlinkSync)(e),!0)}function ve(e,t,r="utf-8"){pe((0,ce.dirname)(e)),(0,ue.writeFileSync)(e,t,r)}function Ee(e,t=!1){const r={files:[],dirs:[]};if(!ge(e))return r;const n=(0,ue.readdirSync)(e);for(const i of n){const n=(0,ce.join)(e,i);if((0,ue.lstatSync)(n).isDirectory()){if(r.dirs.push(n),t){const e=Ee(n,!0);r.files.push(...e.files),r.dirs.push(...e.dirs)}}else r.files.push(n)}return r}function Te(e,t=!1){const r=[];if(!ge(e))return r;const n=(0,ue.readdirSync)(e);for(const i of n){const n=(0,ce.join)(e,i);(0,ue.lstatSync)(n).isDirectory()&&(r.push(n),t&&r.push(...Te(n,!0)))}return r}function Se(e){return fe(e)?(0,ue.statSync)(e).size:0}function xe(e){let t=0;const r=Ee(e,!0).files;for(const e of r)t+=Se(e);return t}function Ae(e,t="bak"){fe(e)&&we(e,`${e}.${t}.${(new Date).toISOString().replace(/[:.]/g,"-")}`)}function Ce(e,t="bak"){const r=(0,ce.dirname)(e),n=(0,ce.basename)(e),i=(0,ue.readdirSync)(r).filter(e=>e.startsWith(`${n}.${t}.`)).sort().reverse();if(0===i.length)throw new Error(`No backups found for ${e}`);return(0,ce.join)(r,i[0])}function Ie(e,t="bak"){we(Ce(e,t),e)}function Me(e,t,r=[]){if("string"!=typeof e)throw new TypeError("dirPath must be a string");if("function"!=typeof t)throw new TypeError("renameFn must be a function");if(!Array.isArray(r))throw new TypeError("extensions must be an array of strings");if(!(0,ue.existsSync)(e)||!(0,ue.statSync)(e).isDirectory())throw new Error(`Directory not found or invalid: ${e}`);for(const e of r)if("string"!=typeof e||!e.startsWith("."))throw new TypeError(`Invalid extension: ${e}`);const n=Ee(e).files;let i=0;for(const s of n){const n=(0,ce.extname)(s);if(r.length&&!r.includes(n))continue;const o=(0,ce.basename)(s),a=t(o,i++),l=(0,ce.join)(e,a);o!==a&&(0,ue.renameSync)(s,l)}}function ke(e,t,r,n=[]){Me(e,e=>{const n=(0,ce.extname)(e);return`${(0,ce.basename)(e,n).replace(t,r)}${n}`},n)}function Le(e,{prefix:t="",suffix:r=""},n=[]){Me(e,e=>{const n=(0,ce.extname)(e),i=(0,ce.basename)(e,n);return`${t}${i}${r}${n}`},n)}function Ne(e,t="lower",r=[],n=!1){if("string"!=typeof t||!["lower","upper","title"].includes(t))throw new Error(`Invalid mode "${t}". Must be 'lower', 'upper' or 'title'.`);Me(e,e=>{const r=e=>"lower"===t?e.toLowerCase():"upper"===t?e.toUpperCase():"title"===t?F(e):e,i=(0,ce.extname)(e),s=n?r(i):i;return`${r((0,ce.basename)(e,i))}${s}`},r)}function De(e,t=3,r=[]){Me(e,e=>e.replace(/\d+/,e=>e.padStart(t,"0")),r)}var _e=r(370);async function Re(e){if(!(0,ue.existsSync)(e))return;const t=await(0,_e.readdir)(e),r={},n=[];for(const i of t){const t=(0,ce.join)(e,i),s=(0,_e.lstat)(t);s.then(e=>(r[t]=e,e)),n.push(s)}await Promise.all(n);const i=[];for(const e in r)r[e].isDirectory()?i.push((0,_e.rm)(e,{recursive:!0,force:!0})):i.push((0,_e.unlink)(e));await Promise.all(i)}async function je(e){return 0===(await(0,_e.readdir)(e)).length}async function Oe(e,t=!1){const r={files:[],dirs:[]};if(!ge(e))return r;const n=await(0,_e.readdir)(e);for(const i of n){const n=(0,ce.join)(e,i);if((await(0,_e.lstat)(n)).isDirectory()){if(r.dirs.push(n),t){const e=await Oe(n,!0);r.files.push(...e.files),r.dirs.push(...e.dirs)}}else r.files.push(n)}return r}async function Pe(e,t=!1){const r=[];if(!ge(e))return r;const n=await(0,_e.readdir)(e);for(const i of n){const n=(0,ce.join)(e,i);(await(0,_e.lstat)(n)).isDirectory()&&(r.push(n),t&&r.push(...await Pe(n,!0)))}return r}async function $e(e){return fe(e)?(await(0,_e.stat)(e)).size:0}async function He(e){let t=0;const{files:r}=await Oe(e,!0),n=[];for(const e of r){const r=$e(e);r.then(e=>(t+=e,e)),n.push(r)}return await Promise.all(n),t}const Be=(e,t)=>e.bottom<t.top,Fe=(e,t)=>e.top>t.bottom,ze=(e,t)=>e.right<t.left,We=(e,t)=>e.left>t.right,qe=(e,t)=>e.bottom<=t.top,Ve=(e,t)=>e.top>=t.bottom,Ue=(e,t)=>e.right<=t.left,Ke=(e,t)=>e.left>=t.right,Je=(e,t)=>!(ze(e,t)||We(e,t)||Be(e,t)||Fe(e,t)),Ge=(e,t)=>!(Ue(e,t)||Ke(e,t)||qe(e,t)||Ve(e,t)),Ye=(e,t)=>ze(e,t)?"left":We(e,t)?"right":Be(e,t)?"top":Fe(e,t)?"bottom":null,Xe=(e,t)=>Ue(e,t)?"left":Ke(e,t)?"right":qe(e,t)?"top":Ve(e,t)?"bottom":null,Qe=(e,t)=>({overlapLeft:t.right-e.left,overlapRight:e.right-t.left,overlapTop:t.bottom-e.top,overlapBottom:e.bottom-t.top}),Ze=({overlapLeft:e=-1,overlapRight:t=-1,overlapTop:r=-1,overlapBottom:n=-1}={})=>({dirX:e<t?"right":"left",dirY:r<n?"bottom":"top"}),et=e=>({x:e.left+e.width/2,y:e.top+e.height/2});function tt(e,t){const r=e.left+e.width/2,n=e.top+e.height/2;return{x:t.left+t.width/2-r,y:t.top+t.height/2-n}}function rt(e,t){if(!Ge(e,t))return{inDir:null,dirX:null,dirY:null,depthX:0,depthY:0};const{overlapLeft:r,overlapRight:n,overlapTop:i,overlapBottom:s}=Qe(e,t),{dirX:o,dirY:a}=Ze({overlapLeft:r,overlapRight:n,overlapTop:i,overlapBottom:s}),l=Math.min(r,n),u=Math.min(i,s);let c;return c=l<u?o:a,{inDir:c,dirX:o,dirY:a,depthX:l,depthY:u}}function nt(e,t){const r=Ge(e,t),n={in:null,x:null,y:null},i={y:null,x:null},s={top:0,bottom:0,left:0,right:0},{overlapLeft:o,overlapRight:a,overlapTop:l,overlapBottom:u}=Qe(t,e);s.top=l,s.bottom=u,s.left=o,s.right=a;const c=Object.entries(s).filter(([,e])=>e>0).sort((e,t)=>e[1]-t[1]),{dirX:h,dirY:d}=Ze({overlapLeft:a,overlapRight:o,overlapTop:u,overlapBottom:l});return n.y=d,n.x=h,s.bottom<0?i.y="bottom":s.top<0&&(i.y="top"),s.left<0?i.x="left":s.right<0&&(i.x="right"),n.in=r?s.top===s.bottom&&s.bottom===s.left&&s.left===s.right?"center":c.length?c[0][0]:"top":null,{dirs:n,depth:s,isNeg:i}}const it=class{#J;get el(){return this.#J}#G={};get settings(){return this.#G}set settings(e){if("object"!=typeof e||null===e)throw new TypeError("settings must be a non-null object.");this.#G=e}#Y=null;get observer(){return this.#Y}#X=[];get detectors(){return this.#X.map(e=>[e[0],e[1]])}set detectors(e){if(!Array.isArray(e))throw new TypeError("detectors must be an array.");const t=[];for(const[r,n]of e){if("string"!=typeof r)throw new TypeError("Detector name must be a string.");if("function"!=typeof n)throw new TypeError(`Detector handler for "${r}" must be a function.`);t.push([r,n])}this.#X=t}get isActive(){return!!this.#Y}get size(){return this.#X.length}constructor(e,{initDetectors:t=[],initCfg:r={}}={}){this.#J=e,t.length&&(this.detectors=t),r&&(this.settings=r)}clear(){this.#X=[]}start(){if(!this.#J)throw new Error("Cannot start observation: no target element has been set.");this.#Y||(this.#Y=new MutationObserver(e=>{e.forEach((e,t,r)=>this.#X.forEach(n=>n[1](e,t,r)))}),this.#Y.observe(this.#J,this.#G))}stop(){this.#Y&&(this.#Y.disconnect(),this.#Y=null)}add(e,t){this.#Q(e,t),this.#X.push([e,t])}insertAtStart(e,t){this.#Q(e,t),this.#X.unshift([e,t])}insertAt(e,t,r,n="after"){if(this.#Q(t,r),"number"!=typeof e||e<0||e>=this.#X.length)throw new RangeError("Invalid index for insertDetectorAt.");const i="before"===n?e:e+1;this.#X.splice(i,0,[t,r])}removeAt(e){if("number"!=typeof e||e<0||e>=this.#X.length)throw new RangeError("Invalid index for removeDetectorAt.");this.#X.splice(e,1)}removeAround(e,t=0,r=0){if("number"!=typeof e||e<0||e>=this.#X.length)throw new RangeError("Invalid index for removeDetectorsAround.");const n=Math.max(0,e-t),i=t+1+r;this.#X.splice(n,i)}isIndexUsed(e){return e>=0&&e<this.#X.length}hasHandler(e){if("function"!=typeof e)throw new TypeError("Handler must be a function.");return this.#X.some(([t,r])=>r===e)}#Q(e,t){if("string"!=typeof e||!e.trim())throw new TypeError("Detector name must be a non-empty string.");if("function"!=typeof t)throw new TypeError(`Detector handler for "${e}" must be a function.`)}destroy(){this.stop(),this.clear()}},{wE:st,D6:ot,Kr:at,iu:lt,cq:ut,lP:ct}=e,ht=new WeakMap,dt=new WeakMap,pt=new WeakMap,mt=new WeakMap,ft={top:new WeakMap,bottom:new WeakMap,left:new WeakMap,right:new WeakMap};class gt{static Utils={...t};static#Z=1;static get version(){return this.#Z}static#ee=!1;static get elemDebug(){return gt.#ee}static set elemDebug(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean value for elemDebug");gt.#ee=e}static _debugElemError(e,t){if(!gt.#ee)return;const r="[TinyHtml Debug] Element validation error";if(console.groupCollapsed(`${r}${t?" — details below":""}`),console.error(r),"undefined"!=typeof Error&&"function"==typeof Error.captureStackTrace){const e=new Error(r);Error.captureStackTrace(e,gt._debugElemError),console.error(e.stack)}else console.trace(r);if(Array.isArray(e)){const t=e.map((e,t)=>({index:t,typeOf:null===e?"null":typeof e,constructor:e?.constructor?.name??(null===e?"null":"primitive"),summary:"undefined"!=typeof Element&&e instanceof Element?`${e.tagName?.toLowerCase?.()??"element"}#${e.id||""}.${String(e.className||"").trim().replace(/\s+/g,".")}`:e&&"object"==typeof e&&"nodeType"in e?`nodeType:${e.nodeType}`:"",value:e}));console.table(t)}else console.warn('[TinyHtml Debug] "elems" is not an array:',e);arguments.length>1&&(console.error("[TinyHtml Debug] Problematic element:",t),t&&"object"==typeof t&&console.dir(t)),console.groupEnd()}static parseStyle(e){const t={};return e.split(";").forEach(e=>{const[r,n]=e.split(":").map(e=>e&&e.trim());r&&n&&(t[r]=n)}),t}static#te="undefined"!=typeof window&&void 0!==window.document?new it(window.document.documentElement,{initDetectors:[["tinyStyleEvent",e=>{if("attributes"!==e.type||"style"!==e.attributeName||!(e.target instanceof HTMLElement))return;const t=e.oldValue||"",r=e.target.getAttribute("style")||"",n=V(gt.parseStyle(t),gt.parseStyle(r));(Object.keys(n.added).length||Object.keys(n.removed).length||Object.keys(n.modified).length)&&e.target.dispatchEvent(new CustomEvent("tinyhtml.stylechanged",{detail:n}))}],["tinyClassEvent",e=>{if("attributes"!==e.type||"class"!==e.attributeName||!(e.target instanceof HTMLElement))return;const t=e.oldValue||"",r=e.target.className||"",n=o(t.split(/\s+/).filter(Boolean),r.split(/\s+/).filter(Boolean));(n.added.length||n.removed.length)&&e.target.dispatchEvent(new CustomEvent("tinyhtml.classchanged",{detail:n}))}]],initCfg:{attributeOldValue:!0,attributes:!0,subtree:!0,attributeFilter:["style","class"]}}):void 0;static get tinyObserver(){return gt.#te}static async fetchHtmlFile(e,t={method:"GET"}){const r=await fetch(e,t),n=r.headers.get("Content-Type")||"";if(!r.ok)throw new Error(`Failed to fetch: ${r.status} ${r.statusText}`);if(!n.includes("text/html"))throw new Error(`Invalid content type: ${n} (expected text/html)`);const i=await r.text();return gt.htmlToJson(i)}static async fetchHtmlNodes(e,t){const r=await gt.fetchHtmlFile(e,t);return gt.jsonToNodes(r)}static async fetchHtmlTinyElems(e,t){const r=await gt.fetchHtmlNodes(e,t);return gt.toTinyElm(r)}static templateToJson(e){return gt.htmlToJson([...e.content.childNodes].map(e=>e instanceof Element?e.getHTML():e instanceof Text?e.textContent:"").join(""))}static templateToNodes(e){const t=[];return[...e.content.cloneNode(!0).childNodes].map(e=>{if(!(e instanceof Element||e instanceof Text||e instanceof Comment))throw new Error(`Expected only Element nodes in <template>, but found: ${e.constructor.name}`);e instanceof Comment||t.push(e)}),t}static templateToTinyElems(e){return gt.toTinyElm(gt.templateToNodes(e))}static htmlToJson(e){const t=document.createElement("div");t.innerHTML=e.trim();const r=[],n=e=>{if(e instanceof Comment)return null;if(e instanceof Text){const t=e.textContent?.trim();return t||null}if(!(e instanceof Element))return null;const t=e.tagName.toLowerCase(),r={};for(const t of e.attributes)r[gt.getPropName(t.name)]=t.value;const i=Array.from(e.childNodes).map(n).filter(Boolean);return i.length>0?[t,r,...i]:[t,r]};for(const e of t.childNodes){const t=n(e);t&&r.push(t)}return t.innerHTML="",r}static jsonToNodes(e){const t=e=>{if("string"==typeof e)return document.createTextNode(e);if(!Array.isArray(e))return document.createTextNode("");const[r,n,...i]=e,s=document.createElement(r);for(const[e,t]of Object.entries(n))s.setAttribute(gt.getAttrName(e),t);for(const e of i){const r=t(e);r instanceof Comment||s.appendChild(r)}return s};return e.map(t).filter(e=>!(e instanceof Comment))}static jsonToTinyElems(e){return gt.toTinyElm(gt.jsonToNodes(e))}static createFrom(e,t){if("string"!=typeof e)throw new TypeError('The "tagName" must be a string.');if(void 0!==t&&"object"!=typeof t)throw new TypeError('The "attrs" must be a object.');const r=gt.createElement(e);if("object"==typeof t)for(const e in t)r.setAttr(e,t[e]);return r}static createElement(e,t){if("string"!=typeof e)throw new TypeError("[TinyHtml] createElement(): The tagName must be a string.");if(void 0!==t&&"object"!=typeof t)throw new TypeError("[TinyHtml] createElement(): The ops must be a object.");return new gt(document.createElement(e,t))}static createTextNode(e){if("string"!=typeof e)throw new TypeError("[TinyHtml] createTextNode(): The value must be a string.");return new gt(document.createTextNode(e))}static createElementFromHTML(e){const t=document.createElement("template");if(!(e=e.trim()).startsWith("<"))return gt.createTextNode(e);if(t.innerHTML=e,!(t.content.firstChild instanceof Element))throw new Error("The HTML string must contain a valid HTML element.");return new gt(t.content.firstChild)}static createFromHTML(e){const t=document.createElement("template");e=e.trim(),t.innerHTML=e;const r=Array.from(t.content.childNodes);if(!r.every(e=>e instanceof Element||e instanceof Text))throw new Error("The HTML string must contain a valid HTML element.");return new gt(r)}static createFromHtml(e){return gt.createFromHTML(e)}static query(e,t=document){const r=t.querySelector(e);return r?new gt(r):null}querySelector(e){return gt.query(e,gt._preElem(this,"query"))}static queryAll(e,t=document){return new gt(t.querySelectorAll(e))}querySelectorAll(e){return gt.queryAll(e,gt._preElem(this,"queryAll"))}static getById(e){const t=document.getElementById(e);return t?new gt(t):null}static getByClassName(e,t=document){return new gt(t.getElementsByClassName(e))}getElementsByClassName(e){return gt.getByClassName(e,gt._preElem(this,"getByClassName"))}static getByName(e){return new gt(document.getElementsByName(e))}static getByTagNameNS(e,t="http://www.w3.org/1999/xhtml",r=document){return new gt(r.getElementsByTagNameNS(t,e))}getElementsByTagNameNS(e,t="http://www.w3.org/1999/xhtml"){return gt.getByTagNameNS(e,t,gt._preElem(this,"getByTagNameNS"))}get elements(){return[...this.#J]}forEach(e){const t=this.elements.map((e,t)=>this.extract(t));for(const r in t)e(t[r],Number(r),t);return this}get(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");if(!this.#J[e])throw new Error(`No element found at index ${e}.`);return this.#J[e]}extract(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");if(!this.#J[e])throw new Error(`Cannot extract: no element exists at index ${e}.`);return new gt(this.#J[e])}exists(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");return!!this.#J[e]}getAll(){return[...this.#J]}_getElement(e,t){if(!(this.#J[t]instanceof Element||this.#J[t]instanceof Window||this.#J[t]instanceof Document||this.#J[t]instanceof Text))throw gt._debugElemError([...this.#J],this.#J[t]),new Error(`[TinyHtml] Invalid Element in ${e}().`);return this.#J[t]}_getElements(e){if(!this.#J.every(e=>e instanceof Element||e instanceof Window||e instanceof Document||e instanceof Text))throw gt._debugElemError([...this.#J]),new Error(`[TinyHtml] Invalid Element in ${e}().`);return[...this.#J]}static _preElemsTemplate(e,t,r,n){const i=e=>{const i=[];return e.map(s=>(s instanceof gt?s._getElements(t):[s]).map(s=>{let o=!1;for(const e of r)if(s instanceof e){o=!0;break}if(!o)throw gt._debugElemError([...e],s),new Error(`[TinyHtml] Invalid element of the list "${n.join(",")}" in ${t}().`);return i.push(s),s})),i};return Array.isArray(e)?i(e):i([e])}_preElemsTemplate(e,t,r){return gt._preElemsTemplate(this,e,t,r)}static _preElemTemplate(e,t,r,n,i=!1){const s=e=>{const s=e[0],o=s instanceof gt?s._getElements(t):[s];if(o.length>1)throw gt._debugElemError([...e]),new Error(`[TinyHtml] Invalid element amount in ${t}() (Received ${o.length}/1).`);let a=!1;for(const e of r)if(o[0]instanceof e){a=!0;break}if(!i||null!==o[0]&&void 0!==o[0]||(o[0]=null,a=!0),!a)throw gt._debugElemError([...e],o[0]),new Error(`[TinyHtml] Invalid element of the list "${n.join(",")}" in ${t}().`);return o[0]};if(!Array.isArray(e))return s([e]);if(e.length>1)throw gt._debugElemError([...e]),new Error(`[TinyHtml] Invalid element amount in ${t}() (Received ${e.length}/1).`);return s(e)}_preElemTemplate(e,t,r,n=!1){return gt._preElemTemplate(this,e,t,r,n)}static _preElems(e,t){return gt._preElemsTemplate(e,t,[Element],["Element"])}_preElems(e){return gt._preElems(this,e)}static _preElem(e,t){return gt._preElemTemplate(e,t,[Element],["Element"])}_preElem(e){return gt._preElem(this,e)}static _preNodeElems(e,t){return gt._preElemsTemplate(e,t,[Node],["Node"])}_preNodeElems(e){return gt._preNodeElems(this,e)}static _preNodeElem(e,t){return gt._preElemTemplate(e,t,[Node],["Node"])}_preNodeElem(e){return gt._preNodeElem(this,e)}static _preNodeElemWithNull(e,t){return gt._preElemTemplate(e,t,[Node],["Node"],!0)}_preNodeElemWithNull(e){return gt._preNodeElemWithNull(this,e)}static _preHtmlElems(e,t){return gt._preElemsTemplate(e,t,[HTMLElement],["HTMLElement"])}_preHtmlElems(e){return gt._preHtmlElems(this,e)}static _preHtmlElem(e,t){return gt._preElemTemplate(e,t,[HTMLElement],["HTMLElement"])}_preHtmlElem(e){return gt._preHtmlElem(this,e)}static _preInputElems(e,t){return gt._preElemsTemplate(e,t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElems(e){return gt._preInputElems(this,e)}static _preInputElem(e,t){return gt._preElemTemplate(e,t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElem(e){return gt._preInputElem(this,e)}static _preEventTargetElems(e,t){return gt._preElemsTemplate(e,t,[EventTarget],["EventTarget"])}_preEventTargetElems(e){return gt._preEventTargetElems(this,e)}static _preEventTargetElem(e,t){return gt._preElemTemplate(e,t,[EventTarget],["EventTarget"])}_preEventTargetElem(e){return gt._preEventTargetElem(this,e)}static _preElemsAndWindow(e,t){return gt._preElemsTemplate(e,t,[Element,Window],["Element","Window"])}_preElemsAndWindow(e){return gt._preElemsAndWindow(this,e)}static _preElemAndWindow(e,t){return gt._preElemTemplate(e,t,[Element,Window],["Element","Window"])}_preElemAndWindow(e){return gt._preElemAndWindow(this,e)}static _preElemsAndWinAndDoc(e,t){return gt._preElemsTemplate(e,t,[Element,Window,Document],["Element","Window","Document"]).map(e=>e instanceof Document?e.documentElement:e)}_preElemsAndWinAndDoc(e){return gt._preElemsAndWinAndDoc(this,e)}static _preElemAndWinAndDoc(e,t){const r=gt._preElemTemplate(e,t,[Element,Window,Document],["Element","Window","Document"]);return r instanceof Document?r.documentElement:r}_preElemAndWinAndDoc(e){return gt._preElemAndWinAndDoc(this,e)}static _preElemsWithDoc(e,t){return gt._preElemsTemplate(e,t,[Element,Document],["Element","Document"])}_preElemsWithDoc(e){return gt._preElemsWithDoc(this,e)}static _preElemWithDoc(e,t){return gt._preElemTemplate(e,t,[Element,Document],["Element","Document"])}_preElemWithDoc(e){return gt._preElemWithDoc(this,e)}static toTinyElm(e){const t=e=>e.map(e=>e instanceof gt?e:new gt(e));return Array.isArray(e)?t(e):t([e])}static fromTinyElm(e){const t=e=>{const t=[];return e.map(e=>(e instanceof gt?e._getElements("fromTinyElm"):[e]).map(e=>t.push(e))),t};return Array.isArray(e)?t(e):t([e])}static winnow(e,t,r,n=!1){if("boolean"!=typeof n)throw new TypeError('The "not" must be a boolean.');if("function"==typeof t)return gt._preElems(e,r).filter((e,r)=>!!t.call(e,r,e)!==n);if(t instanceof Element)return gt._preElems(e,r).filter(e=>e===t!==n);if(Array.isArray(t)||"string"!=typeof t&&null!=t.length)return gt._preElems(e,r).filter(e=>t.includes(e)!==n);let i=t;return n&&(i=`:not(${i})`),gt._preElems(e,r).filter(e=>1===e.nodeType&&e.matches(i))}static filter(e,t,r=!1){return r&&(t=`:not(${t})`),gt._preElems(e,"filter").filter(e=>1===e.nodeType&&e.matches(t))}static filterOnly(e,t){return gt.winnow(e,t,"filterOnly",!1)}static not(e,t){return gt.winnow(e,t,"not",!0)}not(e){return gt.not(this,e)}static find(e,t){const r=[];for(const n of gt._preElems(e,"find"))r.push(...n.querySelectorAll(t));return[...new Set(r)]}find(e){return gt.find(this,e)}static is(e,t){return gt.winnow(e,t,"is",!1).length>0}is(e){return gt.is(this,e)}static has(e,t){const r="string"==typeof t?[...document.querySelectorAll(t)]:gt._preElems(t,"has");return gt._preElems(e,"has").filter(e=>r.some(t=>e&&e.contains(t)))}has(e){return gt.has(this,e)}static closest(e,t,r){const n=[];for(const i of gt._preElems(e,"closest")){let e=i;for(;e&&e!==r;){if(1===e.nodeType&&("string"==typeof t?e.matches(t):e===t)){n.push(e);break}e=e.parentElement}}return[...new Set(n)]}closest(e,t){return gt.closest(this,e,t)}static isSameDom(e,t){return gt._preNodeElem(e,"isSameDom")===gt._preNodeElem(t,"isSameDom")}isSameDom(e){return gt.isSameDom(this,e)}#re={};get _data(){return{...this.#re}}set _data(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new Error("value must be a non-null object.");this.#re=e}static _dataSelector={public:(e,t)=>{const r=gt._preElem(t,e);let n=dt.get(r);return n||(n={},dt.set(r,n)),n},private:(e,t)=>{if(!(t instanceof gt))throw new Error(`Element must be a TinyHtml instance to execute ${e}().`);return t.#re}};static data(e,t,r=!1){const n=gt._dataSelector[r?"private":"public"]("data",e);if(null==t)return{...n};if("string"!=typeof t)throw new TypeError("The key must be a string.");return n.hasOwnProperty(t)?n[t]:void 0}data(e,t){return gt.data(this,e,t)}static setData(e,t,r,n=!1){const i=gt._dataSelector[n?"private":"public"]("setData",e);if("string"!=typeof t)throw new TypeError("The key must be a string.");return void 0!==r?i[t]=r:gt.removeData(e,t),e}setData(e,t,r=!1){return gt.setData(this,e,t,r)}static hasData(e,t,r=!1){if("string"!=typeof t)throw new TypeError("The key must be a string.");const n=gt._dataSelector[r?"private":"public"]("hasData",e);return Object.prototype.hasOwnProperty.call(n,t)}hasData(e,t=!1){return gt.hasData(this,e,t)}static removeData(e,t,r=!1){if("string"!=typeof t)throw new TypeError("The key must be a string.");return delete gt._dataSelector[r?"private":"public"]("removeData",e)[t]}removeData(e,t=!1){return gt.removeData(this,e,t)}static _getSibling(e,t,r){let n=gt._preNodeElemWithNull(e,r);for(;n&&(n=n[t])&&1!==n.nodeType;);return n instanceof Node?n:null}static _getSiblings(e,t){let r=e;const n=[];for(;r;r=r.nextSibling)1===r.nodeType&&r!==t&&n.push(r);return n}static domDir(e,t,r,n="domDir"){if("string"!=typeof t)throw new TypeError('The "direction" must be a string.');let i=gt._preNodeElemWithNull(e,n);const s=[];for(;i&&(i=i[t]);)if(1===i.nodeType){if(r&&("string"==typeof r?i.matches(r):i===r))break;s.push(i)}return s}static parent(e){let t=gt._preNodeElemWithNull(e,"parent");const r=t?t.parentNode:null;return r&&11!==r.nodeType?r:null}parent(){return gt.parent(this)}static parents(e,t){return gt.domDir(e,"parentNode",t,"parents")}parents(e){return gt.parents(this,e)}static next(e){return gt._getSibling(e,"nextSibling","next")}next(){return gt.next(this)}static prev(e){return gt._getSibling(e,"previousSibling","prev")}prev(){return gt.prev(this)}static nextAll(e){return gt.domDir(e,"nextSibling",void 0,"nextAll")}nextAll(){return gt.nextAll(this)}static prevAll(e){return gt.domDir(e,"previousSibling",void 0,"prevAll")}prevAll(){return gt.prevAll(this)}static nextUntil(e,t){return gt.domDir(e,"nextSibling",t,"nextUtil")}nextUntil(e){return gt.nextUntil(this,e)}static prevUntil(e,t){return gt.domDir(e,"previousSibling",t,"prevUtil")}prevUntil(e){return gt.prevUntil(this,e)}static siblings(e){const t=gt._preNodeElemWithNull(e,"siblings");return gt._getSiblings(t&&t.parentNode?t.parentNode.firstChild:null,t)}siblings(){return gt.siblings(this)}static children(e){const t=gt._preNodeElemWithNull(e,"children");return gt._getSiblings(t?t.firstChild:null)}children(){return gt.children(this)}static contents(e){const t=gt._preNodeElemWithNull(e,"contents");return t instanceof HTMLIFrameElement&&null!=t.contentDocument&&Object.getPrototypeOf(t.contentDocument)?[t.contentDocument]:t instanceof HTMLTemplateElement?Array.from((t.content||t).childNodes):t?Array.from(t.childNodes):[]}contents(){return gt.contents(this)}static clone(e,t=!0){if("boolean"!=typeof t)throw new TypeError('The "deep" must be a boolean.');return gt._preNodeElems(e,"clone").map(e=>e.cloneNode(t))}clone(e){return gt.clone(this,e)[0]}static _appendChecker(e,...t){const r=[];for(const n of t)if(null!=n&&!1!==n)if("string"!=typeof n&&"number"!=typeof n)if(n instanceof Node||n instanceof gt)r.push(...gt._preNodeElems(n,e));else if(Array.isArray(n))r.push(...gt._appendChecker(e,...n));else for(const t in n){const i=n[t];r.push(...gt._appendChecker(e,i))}else r.push(n);return r}static append(e,...t){return gt._preElem(e,"append").append(...gt._appendChecker("append",...t)),e}append(...e){return gt.append(this,...e)}static prepend(e,...t){return gt._preElem(e,"prepend").prepend(...gt._appendChecker("prepend",...t)),e}prepend(...e){return gt.prepend(this,...e)}static before(e,...t){return gt._preElem(e,"before").before(...gt._appendChecker("before",...t)),e}before(...e){return gt.before(this,...e)}static after(e,...t){return gt._preElem(e,"after").after(...gt._appendChecker("after",...t)),e}after(...e){return gt.after(this,...e)}static replaceWith(e,...t){return gt._preElem(e,"replaceWith").replaceWith(...gt._appendChecker("replaceWith",...t)),e}replaceWith(...e){return gt.replaceWith(this,...e)}static appendTo(e,t){const r=gt._preNodeElems(e,"appendTo"),n=gt._preNodeElems(t,"appendTo");return n.forEach((e,t)=>{r.forEach(r=>e.appendChild(t===n.length-1?r:r.cloneNode(!0)))}),e}appendTo(e){return gt.appendTo(this,e)}static prependTo(e,t){const r=gt._preElems(e,"prependTo"),n=gt._preElems(t,"prependTo");return n.forEach((e,t)=>{r.slice().reverse().forEach(r=>e.prepend(t===n.length-1?r:r.cloneNode(!0)))}),e}prependTo(e){return gt.prependTo(this,e)}static insertBefore(e,t,r=null){const n=gt._preNodeElem(e,"insertBefore"),i=gt._preNodeElem(t,"insertBefore"),s=gt._preNodeElemWithNull(r,"insertBefore");if(!i.parentNode)throw new Error("The target element has no parent node to insert before.");return i.parentNode.insertBefore(n,s||i),e}insertBefore(e,t){return gt.insertBefore(this,e,t)}static insertAfter(e,t,r=null){const n=gt._preNodeElem(e,"insertAfter"),i=gt._preNodeElem(t,"insertBefore"),s=gt._preNodeElemWithNull(r,"insertBefore");if(!i.parentNode)throw new Error("The target element has no parent node to insert after.");return i.parentNode.insertBefore(n,s||i.nextSibling),e}insertAfter(e,t){return gt.insertAfter(this,e,t)}static replaceAll(e,t){const r=gt._preNodeElems(e,"replaceAll"),n=gt._preNodeElems(t,"replaceAll");return n.forEach((e,t)=>{const i=e.parentNode;r.forEach(r=>{i&&i.replaceChild(t===n.length-1?r:r.cloneNode(!0),e)})}),e}replaceAll(e){return gt.replaceAll(this,e)}#J;get size(){return this.#J.length}static _elCheck(e){for(const t of e)if(!(t instanceof Element||t instanceof Window||t instanceof Document||t instanceof Text))throw new Error("[TinyHtml] Invalid Target in constructor.")}add(e){return new gt([...this.#J,...gt._selector(e)])}static _selector(e){if(e instanceof gt)throw new Error("[TinyHtml] You are trying to put a TinyHtml inside another TinyHtml in constructor.");const t=e=>Array.from(new Set(e)),r="string"!=typeof e?e:document.querySelectorAll(e);if(Array.isArray(r))return gt._elCheck(r),t(r);if(r instanceof NodeList||r instanceof HTMLCollection){const e=[...r];return gt._elCheck(e),t(e)}{const e=[r];return gt._elCheck(e),t(e)}}constructor(e){this.#J=gt._selector(e),this.#ne=gt.#ie}static isWindow(e){return null!=e&&e===e.window}static css(e){const t=gt._preElem(e,"css");return window.getComputedStyle(t)}css(){return gt.css(this)}static cssString(e,t){const r=gt._preElem(e,"cssString");if("string"!=typeof t)throw new TypeError("The prop must be a string.");const n=window.getComputedStyle(r)[t];return"string"==typeof n?n:"number"==typeof n?n.toString():null}cssString(e){return gt.cssString(this,e)}static cssList(e,t){const r=gt._preElem(e,"cssList");if(!Array.isArray(t))throw new TypeError("The prop must be an array of strings.");const n=window.getComputedStyle(r),i={};for(const e of t)void 0!==e&&(i[e]=n.getPropertyValue(e));return i}cssList(e){return gt.cssList(this,e)}static cssFloat(e,t){const r=gt._preElem(e,"cssFloat");if("string"!=typeof t)throw new TypeError("The prop must be a string.");const n=window.getComputedStyle(r)[t];return parseFloat(n)||0}cssFloat(e){return gt.cssFloat(this,e)}static cssFloats(e,t){const r=gt._preElem(e,"cssFloats");if(!Array.isArray(t))throw new TypeError("The prop must be an array of strings.");const n=window.getComputedStyle(r),i={};for(const e of t)i[e]=parseFloat(n[e])||0;return i}cssFloats(e){return gt.cssFloats(this,e)}static#se={alignContent:"align-content",alignItems:"align-items",alignSelf:"align-self",animationDelay:"animation-delay",animationDirection:"animation-direction",animationDuration:"animation-duration",animationFillMode:"animation-fill-mode",animationIterationCount:"animation-iteration-count",animationName:"animation-name",animationPlayState:"animation-play-state",animationTimingFunction:"animation-timing-function",backfaceVisibility:"backface-visibility",backgroundAttachment:"background-attachment",backgroundBlendMode:"background-blend-mode",backgroundClip:"background-clip",backgroundColor:"background-color",backgroundImage:"background-image",backgroundOrigin:"background-origin",backgroundPosition:"background-position",backgroundRepeat:"background-repeat",backgroundSize:"background-size",borderBottom:"border-bottom",borderBottomColor:"border-bottom-color",borderBottomLeftRadius:"border-bottom-left-radius",borderBottomRightRadius:"border-bottom-right-radius",borderBottomStyle:"border-bottom-style",borderBottomWidth:"border-bottom-width",borderCollapse:"border-collapse",borderColor:"border-color",borderImage:"border-image",borderImageOutset:"border-image-outset",borderImageRepeat:"border-image-repeat",borderImageSlice:"border-image-slice",borderImageSource:"border-image-source",borderImageWidth:"border-image-width",borderLeft:"border-left",borderLeftColor:"border-left-color",borderLeftStyle:"border-left-style",borderLeftWidth:"border-left-width",borderRadius:"border-radius",borderRight:"border-right",borderRightColor:"border-right-color",borderRightStyle:"border-right-style",borderRightWidth:"border-right-width",borderSpacing:"border-spacing",borderStyle:"border-style",borderTop:"border-top",borderTopColor:"border-top-color",borderTopLeftRadius:"border-top-left-radius",borderTopRightRadius:"border-top-right-radius",borderTopStyle:"border-top-style",borderTopWidth:"border-top-width",borderWidth:"border-width",boxDecorationBreak:"box-decoration-break",boxShadow:"box-shadow",boxSizing:"box-sizing",breakAfter:"break-after",breakBefore:"break-before",breakInside:"break-inside",captionSide:"caption-side",caretColor:"caret-color",clipPath:"clip-path",columnCount:"column-count",columnFill:"column-fill",columnGap:"column-gap",columnRule:"column-rule",columnRuleColor:"column-rule-color",columnRuleStyle:"column-rule-style",columnRuleWidth:"column-rule-width",columnSpan:"column-span",columnWidth:"column-width",counterIncrement:"counter-increment",counterReset:"counter-reset",emptyCells:"empty-cells",flexBasis:"flex-basis",flexDirection:"flex-direction",flexFlow:"flex-flow",flexGrow:"flex-grow",flexShrink:"flex-shrink",flexWrap:"flex-wrap",fontFamily:"font-family",fontFeatureSettings:"font-feature-settings",fontKerning:"font-kerning",fontLanguageOverride:"font-language-override",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontSynthesis:"font-synthesis",fontVariant:"font-variant",fontVariantAlternates:"font-variant-alternates",fontVariantCaps:"font-variant-caps",fontVariantEastAsian:"font-variant-east-asian",fontVariantLigatures:"font-variant-ligatures",fontVariantNumeric:"font-variant-numeric",fontVariantPosition:"font-variant-position",fontWeight:"font-weight",gridArea:"grid-area",gridAutoColumns:"grid-auto-columns",gridAutoFlow:"grid-auto-flow",gridAutoRows:"grid-auto-rows",gridColumn:"grid-column",gridColumnEnd:"grid-column-end",gridColumnGap:"grid-column-gap",gridColumnStart:"grid-column-start",gridGap:"grid-gap",gridRow:"grid-row",gridRowEnd:"grid-row-end",gridRowGap:"grid-row-gap",gridRowStart:"grid-row-start",gridTemplate:"grid-template",gridTemplateAreas:"grid-template-areas",gridTemplateColumns:"grid-template-columns",gridTemplateRows:"grid-template-rows",imageRendering:"image-rendering",justifyContent:"justify-content",letterSpacing:"letter-spacing",lineBreak:"line-break",lineHeight:"line-height",listStyle:"list-style",listStyleImage:"list-style-image",listStylePosition:"list-style-position",listStyleType:"list-style-type",marginBottom:"margin-bottom",marginLeft:"margin-left",marginRight:"margin-right",marginTop:"margin-top",maskClip:"mask-clip",maskComposite:"mask-composite",maskImage:"mask-image",maskMode:"mask-mode",maskOrigin:"mask-origin",maskPosition:"mask-position",maskRepeat:"mask-repeat",maskSize:"mask-size",maskType:"mask-type",maxHeight:"max-height",maxWidth:"max-width",minHeight:"min-height",minWidth:"min-width",mixBlendMode:"mix-blend-mode",objectFit:"object-fit",objectPosition:"object-position",offsetAnchor:"offset-anchor",offsetDistance:"offset-distance",offsetPath:"offset-path",offsetRotate:"offset-rotate",outlineColor:"outline-color",outlineOffset:"outline-offset",outlineStyle:"outline-style",outlineWidth:"outline-width",overflowAnchor:"overflow-anchor",overflowWrap:"overflow-wrap",overflowX:"overflow-x",overflowY:"overflow-y",paddingBottom:"padding-bottom",paddingLeft:"padding-left",paddingRight:"padding-right",paddingTop:"padding-top",pageBreakAfter:"page-break-after",pageBreakBefore:"page-break-before",pageBreakInside:"page-break-inside",perspectiveOrigin:"perspective-origin",placeContent:"place-content",placeItems:"place-items",placeSelf:"place-self",pointerEvents:"pointer-events",rowGap:"row-gap",scrollBehavior:"scroll-behavior",scrollMargin:"scroll-margin",scrollMarginBlock:"scroll-margin-block",scrollMarginBlockEnd:"scroll-margin-block-end",scrollMarginBlockStart:"scroll-margin-block-start",scrollMarginBottom:"scroll-margin-bottom",scrollMarginInline:"scroll-margin-inline",scrollMarginInlineEnd:"scroll-margin-inline-end",scrollMarginInlineStart:"scroll-margin-inline-start",scrollMarginLeft:"scroll-margin-left",scrollMarginRight:"scroll-margin-right",scrollMarginTop:"scroll-margin-top",scrollPadding:"scroll-padding",scrollPaddingBlock:"scroll-padding-block",scrollPaddingBlockEnd:"scroll-padding-block-end",scrollPaddingBlockStart:"scroll-padding-block-start",scrollPaddingBottom:"scroll-padding-bottom",scrollPaddingInline:"scroll-padding-inline",scrollPaddingInlineEnd:"scroll-padding-inline-end",scrollPaddingInlineStart:"scroll-padding-inline-start",scrollPaddingLeft:"scroll-padding-left",scrollPaddingRight:"scroll-padding-right",scrollPaddingTop:"scroll-padding-top",scrollSnapAlign:"scroll-snap-align",scrollSnapStop:"scroll-snap-stop",scrollSnapType:"scroll-snap-type",shapeImageThreshold:"shape-image-threshold",shapeMargin:"shape-margin",shapeOutside:"shape-outside",tabSize:"tab-size",tableLayout:"table-layout",textAlign:"text-align",textAlignLast:"text-align-last",textCombineUpright:"text-combine-upright",textDecoration:"text-decoration",textDecorationColor:"text-decoration-color",textDecorationLine:"text-decoration-line",textDecorationStyle:"text-decoration-style",textIndent:"text-indent",textJustify:"text-justify",textOrientation:"text-orientation",textOverflow:"text-overflow",textShadow:"text-shadow",textTransform:"text-transform",transformBox:"transform-box",transformOrigin:"transform-origin",transformStyle:"transform-style",transitionDelay:"transition-delay",transitionDuration:"transition-duration",transitionProperty:"transition-property",transitionTimingFunction:"transition-timing-function",unicodeBidi:"unicode-bidi",userSelect:"user-select",verticalAlign:"vertical-align",whiteSpace:"white-space",willChange:"will-change",wordBreak:"word-break",wordSpacing:"word-spacing",wordWrap:"word-wrap",writingMode:"writing-mode",zIndex:"z-index",WebkitTransform:"-webkit-transform",WebkitTransition:"-webkit-transition",WebkitBoxShadow:"-webkit-box-shadow",MozBoxShadow:"-moz-box-shadow",MozTransform:"-moz-transform",MozTransition:"-moz-transition",msTransform:"-ms-transform",msTransition:"-ms-transition"};static cssPropAliases=new Proxy(gt.#se,{set:(e,t,r)=>(e[t]=r,gt.cssPropRevAliases[r]=t,!0)});static cssPropRevAliases=Object.fromEntries(Object.entries(gt.#se).map(([e,t])=>[t,e]));static toStyleKc(e){return"string"==typeof gt.cssPropAliases[e]?gt.cssPropAliases[e]:e}static toStyleCc(e){return"string"==typeof gt.cssPropRevAliases[e]?gt.cssPropRevAliases[e]:e}static setStyle(e,t,r=null){return gt._preHtmlElems(e,"setStyle").forEach(e=>{if("object"==typeof t)for(const[r,n]of Object.entries(t))e.style.setProperty(gt.toStyleKc(r),"string"==typeof n?n:"number"==typeof n?`${n}px`:String(n));else e.style.setProperty(gt.toStyleKc(t),r)}),e}setStyle(e,t){return gt.setStyle(this,e,t)}static getStyle(e,t){return gt._preHtmlElem(e,"getStyle").style.getPropertyValue(gt.toStyleKc(t))}getStyle(e){return gt.getStyle(this,e)}static style(e,{camelCase:t=!1,rawAttr:r=!1}={}){if("boolean"!=typeof t)throw new TypeError('"camelCase" must be a boolean. Received: '+typeof t);if("boolean"!=typeof r)throw new TypeError('"rawAttr" must be a boolean. Received: '+typeof r);const n=gt._preHtmlElem(e,"style"),i={};if(r){const e=(n.getAttribute("style")||"").split(";");for(const r of e){const[e,n]=r.split(":");if(!e||!n)continue;const s=e.trim(),o=n.trim();i[t?gt.toStyleCc(s):s]=o}}else{const e=n.style;for(let r=0;r<e.length;r++){const n=e[r],s=e.getPropertyValue(n);i[t?gt.toStyleCc(n):n]=s}}return i}style(e){return gt.style(this,e)}static removeStyle(e,t){return gt._preHtmlElems(e,"removeStyle").forEach(e=>{if(Array.isArray(t))for(const r of t)e.style.removeProperty(gt.toStyleKc(r));else e.style.removeProperty(gt.toStyleKc(t))}),e}removeStyle(e){return gt.removeStyle(this,e)}static toggleStyle(e,t,r,n){return gt._preHtmlElems(e,"toggleStyle").forEach(e=>{const i=gt.getStyle(e,t).trim()===gt.toStyleKc(r)?n:r;gt.setStyle(e,t,i)}),e}toggleStyle(e,t,r){return gt.toggleStyle(this,e,t,r)}static clearStyle(e){return gt._preElems(e,"clearStyle").forEach(e=>e.removeAttribute("style")),e}clearStyle(){return gt.clearStyle(this)}static focus(e){return gt._preHtmlElem(e,"focus").focus(),e}focus(){return gt.focus(this)}static blur(e){return gt._preHtmlElem(e,"blur").blur(),e}blur(){return gt.blur(this)}static select(e){const t=gt._preHtmlElem(e,"select");if(!(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement))throw new Error("Element must be an <input> or <textarea> to use select().");return t.select(),e}select(){return gt.select(this)}static boolCheck(e){return void 0!==e&&("true"===e||"1"===e||!0===e||"on"===e||"number"==typeof e&&e>0)}static setWinScrollTop(e){if("number"!=typeof e)throw new TypeError("The value must be a number.");gt.setScrollTop(window,e)}static setWinScrollLeft(e){if("number"!=typeof e)throw new TypeError("The value must be a number.");gt.setScrollLeft(window,e)}static winScrollTop(){return window.scrollY||document.documentElement.scrollTop}static winScrollLeft(){return window.scrollX||document.documentElement.scrollLeft}static winInnerHeight(){return window.innerHeight||document.documentElement.clientHeight}static winInnerWidth(){return window.innerWidth||document.documentElement.clientWidth}static isPageTop(){return 0===window.scrollY}static isPageBottom(){return window.innerHeight+window.scrollY>=document.body.offsetHeight}static getDimension(e,t,r="content"){const n=gt._preElemAndWinAndDoc(e,"getDimension");if("string"!=typeof t)throw new TypeError("The type must be a string.");if("string"!=typeof r)throw new TypeError("The extra must be a string.");const i="width"===t?"Width":"Height";if(gt.isWindow(n))return"margin"===r?n["inner"+i]:n.document.documentElement["client"+i];const s=n;if(9===s.nodeType){const e=s.documentElement;return Math.max(s.body["scroll"+i],e["scroll"+i],s.body["offset"+i],e["offset"+i],e["client"+i])}let o=s.getBoundingClientRect()[t];function a(e){return"width"===t?gt.cssFloat(s,e+"Left")+gt.cssFloat(s,e+"Right"):gt.cssFloat(s,e+"Top")+gt.cssFloat(s,e+"Bottom")}switch(r){case"content":o-=a("padding"),o-=a("border");break;case"padding":o-=a("border");break;case"border":break;case"margin":o+=a("margin")}return o}getDimension(e,t){return gt.getDimension(this,e,t)}static setHeight(e,t){const r=gt._preHtmlElem(e,"setHeight");if("number"!=typeof t&&"string"!=typeof t)throw new TypeError("The value must be a string or number.");return r.style.height="number"==typeof t?`${t}px`:t,e}setHeight(e){return gt.setHeight(this,e)}set height(e){gt.setHeight(this,e)}static setWidth(e,t){const r=gt._preHtmlElem(e,"setWidth");if("number"!=typeof t&&"string"!=typeof t)throw new TypeError("The value must be a string or number.");return r.style.width="number"==typeof t?`${t}px`:t,e}setWidth(e){return gt.setWidth(this,e)}set width(e){gt.setWidth(this,e)}static height(e){const t=gt._preElemAndWinAndDoc(e,"height");return gt.getDimension(t,"height","content")}get height(){return gt.height(this)}static width(e){const t=gt._preElemAndWinAndDoc(e,"width");return gt.getDimension(t,"width","content")}get width(){return gt.width(this)}static innerHeight(e){const t=gt._preElemAndWinAndDoc(e,"innerHeight");return gt.getDimension(t,"height","padding")}innerHeight(){return gt.innerHeight(this)}static innerWidth(e){const t=gt._preElemAndWinAndDoc(e,"innerWidth");return gt.getDimension(t,"width","padding")}innerWidth(){return gt.innerWidth(this)}static outerHeight(e,t=!1){if("boolean"!=typeof t)throw new TypeError('The "includeMargin" must be a boolean.');const r=gt._preElemAndWinAndDoc(e,"outerHeight");return gt.getDimension(r,"height",t?"margin":"border")}outerHeight(e){return gt.outerHeight(this,e)}static outerWidth(e,t=!1){if("boolean"!=typeof t)throw new TypeError('The "includeMargin" must be a boolean.');const r=gt._preElemAndWinAndDoc(e,"outerWidth");return gt.getDimension(r,"width",t?"margin":"border")}outerWidth(e){return gt.outerWidth(this,e)}#ne="";get mainDisplay(){return this.#ne}set mainDisplay(e){if("string"!=typeof e)throw new TypeError("mainDisplay must be a string.");this.#ne=e}static#ie="block";static get defaultDisplay(){return gt.#ie}static set defaultDisplay(e){if("string"!=typeof e)throw new TypeError("defaultDisplay must be a string.");gt.#ie=e}static getAnimateData(e,t){let r=pt.get(e);return r||(r={},pt.set(e,r)),r[t]}static setAnimateData(e,t,r){if(!(e instanceof HTMLElement))throw new TypeError("setAnimateData: el must be an HTMLElement.");if("string"!=typeof t)throw new TypeError("setAnimateData: where must be a string.");if("string"!=typeof r&&"number"!=typeof r)throw new TypeError("setAnimateData: value must be a string or number.");let n=pt.get(e);n||(n={},pt.set(e,n)),n[t]=r}static#oe=!0;static get cancelOldStyleFx(){return gt.#oe}static set cancelOldStyleFx(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean value.");gt.#oe=e}static#ae={slow:{duration:600,easing:"ease"},fast:{duration:200,easing:"ease-out"},_default:{duration:400,easing:"linear"}};static get styleFxSpeeds(){const e={};for(const t in gt.#ae){const r=gt.#ae[t];e[t]="object"==typeof r?{...r}:r}return e}static set styleFxSpeeds(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("styleFxSpeeds must be an object.");for(const[t,r]of Object.entries(e))if("number"!=typeof r&&"object"!=typeof r)throw new TypeError(`styleFxSpeeds["${t}"] must be a number or KeyframeAnimationOptions.`);gt.#ae={};for(const[t,r]of Object.entries(e))gt.setStyleFxSpeed(t,r)}static getStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');const t=gt.#ae[e];return"object"==typeof t?{...t}:t}static setStyleFxSpeed(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("number"!=typeof t&&"object"!=typeof t)throw new TypeError("styleFxSpeed must be a number or KeyframeAnimationOptions");gt.#ae[e]="object"==typeof t?{...t}:t}static deleteStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete gt.#ae[e]}static hasStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(gt.#ae,e)}static#le=["Top","Right","Bottom","Left"];static#ue={slideDown:gt.genStyleFx("show"),slideUp:gt.genStyleFx("hide"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}};static get styleEffects(){return JSON.parse(JSON.stringify(gt.#ue))}static set styleEffects(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("styleEffects must be an object");for(const t in e)for(const[r,n]of Object.entries(e[t]))if(!("string"==typeof n||Array.isArray(n)&&n.every(e=>"string"==typeof e||"number"==typeof e)))throw new TypeError(`Invalid styleEffect["${r}"]`);gt.#ue={};for(const t in e)gt.setStyleEffect(t,e[t])}static getStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');const t=gt.#ue[e];return t?JSON.parse(JSON.stringify(t)):void 0}static setStyleEffect(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError("styleEffect must be an object");const r={};for(const[e,n]of Object.entries(t))if("string"==typeof n)r[e]=n;else{if(!Array.isArray(n)||!n.every(e=>"string"==typeof e||"number"==typeof e))throw new TypeError(`Invalid styleEffect["${e}"]`);r[e]=[...n]}gt.#ue[e]=r}static deleteStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete gt.#ue[e]}static hasStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(gt.#ue,e)}static#ce={slideDown:"slideUp",slideUp:"slideDown",fadeIn:"fadeOut",fadeOut:"fadeIn",fadeTo:"fadeIn"};static get styleEffectInverse(){return{...gt.#ce}}static set styleEffectInverse(e){if("object"!=typeof e||null===e)throw new TypeError("styleEffectInverse must be an object.");for(const[t,r]of Object.entries(e))if("string"!=typeof r)throw new TypeError(`styleEffectInverse["${t}"] must be a string.`);gt.#ce={};for(const[t,r]of Object.entries(e))gt.setStyleEffectInverse(t,r)}static getStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return gt.#ce[e]||null}static setStyleEffectInverse(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("string"!=typeof t)throw new TypeError(`styleEffectInverse["${e}"] must be a string.`);gt.#ce[e]=t}static deleteStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete gt.#ce[e]}static hasStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(gt.#ce,e)}static#he={slideDown:e=>e.height[0]===e.height[1]&&(!e.width||e.width[0]===e.width[1]),slideUp:e=>e.height[0]===e.height[1]&&(!e.width||e.width[0]===e.width[1]),fadeIn:e=>Number(e.opacity[0])===Number(e.opacity[1]),fadeOut:e=>Number(e.opacity[0])===Number(e.opacity[1])};static get styleEffectsRd(){return{...gt.#he}}static set styleEffectsRd(e){if("object"!=typeof e||null===e)throw new TypeError("styleEffectsRd must be an object.");for(const[t,r]of Object.entries(e))if("function"!=typeof r)throw new TypeError(`styleEffectsRd["${t}"] must be a function.`);gt.#he={};for(const[t,r]of Object.entries(e))gt.setStyleEffectRd(t,r)}static getStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return gt.#he[e]||null}static setStyleEffectRd(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("function"!=typeof t)throw new TypeError(`styleEffectsRd["${e}"] must be a function.`);gt.#he[e]=t}static deleteStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete gt.#he[e]}static hasStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(gt.#he,e)}static#de={show:(e,t,r,n)=>{if("height"===r||"width"===r){const i=gt.getAnimateData(e,`orig${r}`)||e.scrollHeight+"px";gt.setAnimateData(e,`orig${r}`,i);const s=n[r];t[r]=[s,i]}else if(r.startsWith("margin")||r.startsWith("padding")){const i=gt.getAnimateData(e,r)||n[r];gt.setAnimateData(e,r,i),t[r]=["0px",i]}else if("opacity"===r){const e=n.opacity;t[r]=[e,1]}else{const i=gt.getAnimateData(e,r)||n[r];gt.setAnimateData(e,r,i),t[r]=[i,n[r]||1]}},hide:(e,t,r,n)=>{if("height"===r||"width"===r){const i=gt.getAnimateData(e,`orig${r}`)||n[r];gt.setAnimateData(e,`orig${r}`,i);const s=n[r];t[r]=[s,0]}else if(r.startsWith("margin")||r.startsWith("padding")){const i=gt.getAnimateData(e,r)||n[r];gt.setAnimateData(e,r,i),t[r]=[n[r],"0px"]}else if("opacity"===r){const e=n.opacity;t[r]=[e,0]}else{const i=gt.getAnimateData(e,r)||n[r];gt.setAnimateData(e,r,i),t[r]=[i,0]}}};static get styleEffectsProps(){return{...gt.#de}}static set styleEffectsProps(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("styleEffectsProps must be an object");for(const[t,r]of Object.entries(e))if("function"!=typeof r)throw new TypeError(`styleEffectsProps["${t}"] must be a function`);gt.#de={};for(const[t,r]of Object.entries(e))gt.setStyleEffectProp(t,r)}static getStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return gt.#de[e]||null}static setStyleEffectProp(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("function"!=typeof t)throw new TypeError(`styleEffectsProps["${e}"] must be a function`);gt.#de[e]=t}static deleteStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete gt.#de[e]}static hasStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(gt.#de,e)}static genStyleFx(e,t=!1){if("string"!=typeof e)throw new TypeError("genStyleFx: type must be a string.");if("boolean"!=typeof t)throw new TypeError("genStyleFx: includeWidth must be a boolean.");let r,n=0;const i={height:e},s=t?1:0;for(;n<4;n+=2-s)r=gt.#le[n],i["margin"+r]=e,i["padding"+r]=e;return t&&(i.opacity=e,i.width=e),i}static applyStyleFx(e,t,r,n){if("string"!=typeof t)throw new TypeError("applyStyleFx: id must be a string.");if("object"!=typeof r||null===r)throw new TypeError("applyStyleFx: props must be a non-null object.");if(void 0!==n&&"number"!=typeof n&&"string"!=typeof n&&("object"!=typeof n||null===n))throw new TypeError("applyStyleFx: ops must be a number, string, KeyframeAnimationOptions, or undefined.");const i=new Map;return gt._preHtmlElems(e,"applyStyleFx").forEach(s=>{const o={};for(const[e,t]of Object.entries(r))if("string"==typeof t&&this.#de[t]){const r=getComputedStyle(s);this.#de[t](s,o,e,r)}else{if("object"!=typeof t)throw new TypeError(`applyStyleFx: invalid action for prop "${e}". Must be string or array.`);o[e]=t}if("function"==typeof gt.#he[t]&&gt.#he[t](o))return void i.set(s,null);const a=[],l=o[Object.keys(o)[0]].length;for(let e=0;e<l;e++){const t={};for(const r in o)t[r]=o[r][e];a.push(t)}i.set(s,gt.animate(e,a,n,t)[0])}),i}applyStyleFx(e,t,r){return gt.applyStyleFx(this,e,t,r)}static getCurrentAnimationId(e){if(!(e instanceof HTMLElement))throw new TypeError("Expected an HTMLElement.");return mt.get(e)?.id??void 0}static animate(e,t,r=gt.#ae._default,n=null,i=gt.#oe){const s="string"==typeof r?gt.#ae[r]??void 0:"number"!=typeof r?{...r}:r;"object"==typeof s&&void 0===s.fill&&(s.fill="forwards");const o=[];return gt._preHtmlElems(e,"animate").forEach(e=>{if(i){const t=mt.get(e);t&&t.animation.cancel()}const r=e.animate(t,s);o.push(r),mt.set(e,{animation:r,id:n??""}),r.addEventListener("finish",()=>{mt.get(e)?.animation===r&&mt.delete(e)})}),o}animate(e,t,r,n){return gt.animate(this,e,t,r,n)}static stop(e){const t=[];return gt._preHtmlElems(e,"stop").forEach(e=>{const r=mt.get(e);r?(r.animation.cancel(),mt.delete(e),t.push(!0)):t.push(!1)}),t}stop(){return gt.stop(this)}static slideDown(e,t){return gt.applyStyleFx(e,"slideDown",this.#ue.slideDown,t??{duration:500,easing:"ease-out"})}slideDown(e){return gt.slideDown(this,e)}static slideUp(e,t){return gt.applyStyleFx(e,"slideUp",this.#ue.slideUp,t??{duration:500,easing:"ease-out"})}slideUp(e){return gt.slideUp(this,e)}static slideToggle(e,t){const r=gt._preHtmlElem(e,"slideToggle"),n=getComputedStyle(r),i=gt.getCurrentAnimationId(r),s="none"===n.display||0===r.offsetHeight;return("string"==typeof i?"slideUp"===i:s)?gt.slideDown(e,t):gt.slideUp(e,t)}slideToggle(e){return gt.slideToggle(this,e)}static fadeIn(e,t){return gt.applyStyleFx(e,"fadeIn",this.#ue.fadeIn,t)}fadeIn(e){return gt.fadeIn(this,e)}static fadeOut(e,t){return gt.applyStyleFx(e,"fadeOut",this.#ue.fadeOut,t)}fadeOut(e){return gt.fadeOut(this,e)}static fadeToggle(e,t){const r=gt._preHtmlElem(e,"fadeToggle"),n=getComputedStyle(r),i=gt.getCurrentAnimationId(r),s="0"===n.opacity||null===r.offsetParent;return("string"==typeof i?"fadeOut"===i:s)?gt.fadeIn(e,t):gt.fadeOut(e,t)}fadeToggle(e){return gt.fadeToggle(this,e)}static fadeTo(e,t,r,n=gt.#ie){if("number"!=typeof t||isNaN(t)||t<0||t>1)throw new TypeError("fadeTo: opacity must be a number between 0 and 1.");if(void 0!==r&&"number"!=typeof r&&"string"!=typeof r&&("object"!=typeof r||null===r))throw new TypeError("fadeTo: ops must be a number, string, KeyframeAnimationOptions, or undefined.");const i=new Map;return gt._preHtmlElems(e,"fadeTo").forEach(s=>{const o=getComputedStyle(s);if(!(e instanceof Element&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length))){const e=gt.getAnimateData(s,"origdisplay");s.style.display="string"==typeof e?e:n}const a=[o.opacity,t].map(e=>({opacity:e}));i.set(s,gt.animate(s,a,r,"fadeTo")[0])}),i}fadeTo(e,t,r=this.#ne){return gt.fadeTo(this,e,t,r)}static offset(e){const t=gt._preElem(e,"offset").getBoundingClientRect(),r=window.scrollY||document.documentElement.scrollTop,n=window.scrollX||document.documentElement.scrollLeft;return{top:t.top+r,left:t.left+n}}offset(){return gt.offset(this)}static position(e){const t=gt._preHtmlElem(e,"position");let r,n,i={top:0,left:0};if("fixed"===window.getComputedStyle(t).position)n=t.getBoundingClientRect();else{n=gt.offset(t),r=t.offsetParent||document.documentElement;const{position:e}=window.getComputedStyle(r);for(;r instanceof HTMLElement&&(r===document.body||r===document.documentElement)&&"static"===e;)r=r.parentNode;if(r instanceof HTMLElement&&r!==t&&1===r.nodeType){const{borderTopWidth:e,borderLeftWidth:t}=gt.cssFloats(r,["borderTopWidth","borderLeftWidth"]);i=gt.offset(r),i.top+=e,i.left+=t}}return{top:n.top-i.top-gt.cssFloat(t,"marginTop"),left:n.left-i.left-gt.cssFloat(t,"marginLeft")}}position(){return gt.position(this)}static offsetParent(e){let t=gt._preHtmlElem(e,"offsetParent").offsetParent;for(;t instanceof HTMLElement&&"static"===window.getComputedStyle(t).position;)t=t.offsetParent;return t instanceof HTMLElement?t:document.documentElement}offsetParent(){return gt.offsetParent(this)}static scrollTop(e){const t=gt._preElemAndWindow(e,"scrollTop");return gt.isWindow(t)?t.pageYOffset:9===t.nodeType?t.defaultView.pageYOffset:t.scrollTop}scrollTop(){return gt.scrollTop(this)}static scrollLeft(e){const t=gt._preElemAndWindow(e,"scrollLeft");return gt.isWindow(t)?t.pageXOffset:9===t.nodeType?t.defaultView.pageXOffset:t.scrollLeft}scrollLeft(){return gt.scrollLeft(this)}static easings={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>e*(2-e),easeInOutQuad:e=>e<.5?2*e*e:(4-2*e)*e-1,easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1};static scrollToXY(e,{targetX:t,targetY:r,duration:n,easing:i,onAnimation:s}={}){if(void 0!==t&&"number"!=typeof t)throw new TypeError("`targetX` must be a number if provided.");if(void 0!==r&&"number"!=typeof r)throw new TypeError("`targetY` must be a number if provided.");if(void 0!==n&&"number"!=typeof n)throw new TypeError("`duration` must be a number if provided.");if(void 0!==i&&"string"!=typeof i)throw new TypeError("`easing` must be a string if provided.");if(void 0!==i&&"function"!=typeof gt.easings[i])throw new TypeError(`Unknown easing function: "${i}".`);if(void 0!==s&&"function"!=typeof s)throw new TypeError("`onAnimation` must be a function if provided.");const o=(e,t,r,n)=>{if(e instanceof Window)window.scrollTo(t,r);else if(9===e.nodeType)e.defaultView.scrollTo(t,r);else{const n=e instanceof Window?window.scrollX:e.scrollLeft,i=e instanceof Window?window.scrollY:e.scrollTop;n!==t&&(e.scrollLeft=t),i!==r&&(e.scrollTop=r)}"function"==typeof s&&s({x:t,y:r,isComplete:n>=1,time:n})};return gt._preElemsAndWindow(e,"scrollToXY").forEach(e=>{const s=e instanceof Window?window.scrollX:e.scrollLeft,a=e instanceof Window?window.scrollY:e.scrollTop,l=t??s,u=r??a,c=l-s,h=u-a,d="string"==typeof i&&gt.easings[i]||null;if("number"!=typeof n||"function"!=typeof d)return o(e,l,u,1);const p=performance.now(),m=n??0;requestAnimationFrame(function t(r){if("function"!=typeof d)return;const n=Math.min(1,(r-p)/m),i=d(n);o(e,s+c*i,a+h*i,n),n<1&&requestAnimationFrame(t)})}),e}scrollToXY({targetX:e,targetY:t,duration:r,easing:n,onAnimation:i}={}){return gt.scrollToXY(this,{targetX:e,targetY:t,duration:r,easing:n,onAnimation:i})}static setScrollTop(e,t){if("number"!=typeof t)throw new TypeError("ScrollTop value must be a number.");return gt.scrollToXY(e,{targetY:t})}setScrollTop(e){return gt.setScrollTop(this,e)}static setScrollLeft(e,t){if("number"!=typeof t)throw new TypeError("ScrollLeft value must be a number.");return gt.scrollToXY(e,{targetX:t})}setScrollLeft(e){return gt.setScrollLeft(this,e)}static borderWidth(e){const t=gt._preElem(e,"borderWidth"),{borderLeftWidth:r,borderRightWidth:n,borderTopWidth:i,borderBottomWidth:s}=gt.cssFloats(t,["borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"]);return{x:r+n,y:i+s,left:r,right:n,top:i,bottom:s}}borderWidth(){return gt.borderWidth(this)}static border(e){const t=gt._preElem(e,"border"),{borderLeft:r,borderRight:n,borderTop:i,borderBottom:s}=gt.cssFloats(t,["borderLeft","borderRight","borderTop","borderBottom"]);return{x:r+n,y:i+s,left:r,right:n,top:i,bottom:s}}border(){return gt.border(this)}static margin(e){const t=gt._preElem(e,"margin"),{marginLeft:r,marginRight:n,marginTop:i,marginBottom:s}=gt.cssFloats(t,["marginLeft","marginRight","marginTop","marginBottom"]);return{x:r+n,y:i+s,left:r,right:n,top:i,bottom:s}}margin(){return gt.margin(this)}static padding(e){const t=gt._preElem(e,"padding"),{paddingLeft:r,paddingRight:n,paddingTop:i,paddingBottom:s}=gt.cssFloats(t,["paddingLeft","paddingRight","paddingTop","paddingBottom"]);return{x:r+n,y:i+s,left:r,right:n,top:i,bottom:s}}padding(){return gt.padding(this)}static#pe=!1;static get classCanWhitespace(){return this.#pe}static set classCanWhitespace(e){if("boolean"!=typeof e)throw new TypeError("classCanWhitespace must be a boolean");this.#pe=e}static addClass(e,...t){const r=[];for(const e of t)if(gt.#pe){const t=e.split(" ");for(const e of t)r.push(e)}else r.push(e);return gt._preElems(e,"addClass").forEach(e=>e.classList.add(...r)),e}addClass(...e){return gt.addClass(this,...e)}static removeClass(e,...t){const r=[];for(const e of t)if(gt.#pe){const t=e.split(" ");for(const e of t)r.push(e)}else r.push(e);return gt._preElems(e,"removeClass").forEach(e=>e.classList.remove(...r)),e}removeClass(...e){return gt.removeClass(this,...e)}static replaceClass(e,t,r){if("string"!=typeof t)throw new TypeError('The "token" parameter must be a string.');if("string"!=typeof r)throw new TypeError('The "newToken" parameter must be a string.');const n=[];return gt._preElems(e,"replaceClass").forEach(e=>n.push(e.classList.replace(t,r))),n}replaceClass(e,t){return gt.replaceClass(this,e,t)[0]}static classItem(e,t){const r=gt._preElem(e,"classItem");if("number"!=typeof t)throw new TypeError('The "index" parameter must be a number.');return r.classList.item(t)}classItem(e){return gt.classItem(this,e)}static toggleClass(e,t,r){if("string"!=typeof t)throw new TypeError('The "token" parameter must be a string.');if(void 0!==r&&"boolean"!=typeof r)throw new TypeError('The "force" parameter must be a boolean.');const n=[];return gt._preElems(e,"toggleClass").forEach(e=>n.push(e.classList.toggle(t,r))),n}toggleClass(e,t){return gt.toggleClass(this,e,t)[0]}static hasClass(e,t){const r=gt._preElem(e,"hasClass");if("string"!=typeof t)throw new TypeError('The "token" parameter must be a string.');return r.classList.contains(t)}hasClass(e){return gt.hasClass(this,e)}static classLength(e){return gt._preElem(e,"classLength").classList.length}classLength(){return gt.classLength(this)}static classList(e){return gt._preElem(e,"classList").classList.values().toArray()}classList(){return gt.classList(this)}static tagName(e){return gt._preElem(e,"tagName").tagName}tagName(){return gt.tagName(this)}static id(e){return gt._preElem(e,"id").id}get id(){return gt.id(this)}set id(e){gt.setAttr(this,"id",e)}static toBigInt(e){const t=gt._preElem(e,"toBigInt"),r=t.textContent?.trim();let n=null;try{n=BigInt(r??"")}catch{n=null}return n}toBigInt(){return gt.toBigInt(this)}static setBigInt(e,t){if("bigint"!=typeof t)throw new Error("Value is not a valid BigInt.");const r=t.toString();return gt._preElems(e,"setBigInt").forEach(e=>e.textContent=r),e}setBigInt(e){return gt.setBigInt(this,e)}static toDate(e){const t=gt._preElem(e,"toDate"),r=t.textContent?.trim();if(!r)return null;const n=new Date(r);return Number.isNaN(n.getTime())?null:n}toDate(){return gt.toDate(this)}static setDate(e,t){if(!(t instanceof Date)||Number.isNaN(t.getTime()))throw new Error("Value is not a valid Date.");const r=t.toISOString();return gt._preElems(e,"setDate").forEach(e=>e.textContent=r),e}setDate(e){return gt.setDate(this,e)}static toJson(e){const t=gt._preElem(e,"toJson"),r=t.textContent?.trim();if(!r)return null;try{return JSON.parse(r)}catch{return null}}toJson(){return gt.toJson(this)}static setJson(e,t,r,n){const i=JSON.stringify(t,r,n);return gt._preElems(e,"setJson").forEach(e=>e.textContent=i),e}setJson(e,t,r){return gt.setJson(this,e,t,r)}static toNumber(e){const t=gt._preElem(e,"toNumber");return"string"==typeof t.textContent?parseFloat(t.textContent.trim()):null}toNumber(){return gt.toNumber(this)}static setNumber(e,t){if("number"!=typeof t)throw new Error("Value is not a valid number.");const r=t.toString();return gt._preElems(e,"setNumber").forEach(e=>e.textContent=r),e}setNumber(e){return gt.setNumber(this,e)}static toBoolean(e){const t=gt._preElem(e,"toBoolean"),r=t.textContent?.trim();return null==r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}toBoolean(){return gt.toBoolean(this)}static setBoolean(e,t){if("boolean"!=typeof t)throw new Error("Value is not a valid boolean.");const r=t.toString();return gt._preElems(e,"setBoolean").forEach(e=>e.textContent=r),e}setBoolean(e){return gt.setBoolean(this,e)}static toString(e){const t=gt._preElem(e,"toString");return"string"==typeof t.textContent?t.textContent:null}toString(){return gt.toString(this)}static setString(e,t){if("string"!=typeof t)throw new Error("Value is not a valid string.");return gt._preElems(e,"setString").forEach(e=>e.textContent=t),e}setString(e){return gt.setString(this,e)}static text(e){return gt._preElem(e,"text").textContent}text(){return gt.text(this)}static setText(e,t){const r=null!=t?String(t):"";return gt._preElems(e,"setText").forEach(e=>e.textContent=r),e}setText(e){return gt.setText(this,e)}static empty(e){return gt._preElems(e,"empty").forEach(e=>e.textContent=""),e}empty(){return gt.empty(this)}static html(e,t){return gt._preElem(e,"html").getHTML(t)}html(e){return gt.html(this,e)}static setHtml(e,t){if("string"!=typeof t)throw new Error("Value is not a valid string.");return gt._preElems(e,"setHtml").forEach(e=>e.innerHTML=t),e}setHtml(e){return gt.setHtml(this,e)}static _valHooks={option:{get:e=>{const t=e.getAttribute("value");return null!=t?t:e.textContent}},select:{get:e=>{const t=e.options,r=e.selectedIndex,n="select-one"===e.type,i=n?r+1:t.length,s=[];let o=r<0?i:n?r:0;for(;o<i;o++){const e=t[o],i=e.parentNode;if((e.selected||o===r)&&!e.disabled&&(!i||!i.disabled||"OPTGROUP"!==i.tagName)){const t=gt._valHooks.option.get(e);if(n)return t;s.push(t)}}return s},set:(e,t)=>{const r=e.options,n=Array.isArray(t)?t.map(String):[String(t)];let i=!1;for(let e=0;e<r.length;e++){const t=r[e],s=gt._valHooks.option.get(t);"string"==typeof s&&(t.selected=n.includes(s))&&(i=!0)}return i||(e.selectedIndex=-1),n}},radio:{get:e=>e.checked?"on":"off",set(e,t){if("boolean"==typeof t){const r=e.closest("label");return t&&r&&r.querySelectorAll('input[type="radio"]').forEach(t=>{t instanceof HTMLInputElement&&t!==e&&(t.checked=!1)}),e.checked=t,t}}},checkbox:{get:e=>e.checked?"on":"off",set(e,t){if("boolean"==typeof t)return e.checked=t,t}}};static setVal(e,t){return gt._preInputElems(e,"setVal").forEach(e=>{if(1!==e.nodeType)return;let r="function"==typeof t?t(e,gt.val(e)):t;null==r?r="":"number"==typeof r?r=String(r):Array.isArray(r)&&(r=((e,t)=>{const r=[];for(let n=0;n<e.length;n++)r.push(t(e[n]));return r})(r,e=>null==e?"":String(e)));const n=gt._valHooks[e.type]||gt._valHooks[e.nodeName.toLowerCase()];if(!n||"function"!=typeof n.set||void 0===n.set(e,r,"value")){if("string"!=typeof r&&"boolean"!=typeof r)throw new Error(`Invalid setValue "${typeof r}" value.`);"string"==typeof r&&(e.value=r)}}),e}setVal(e){return gt.setVal(this,e)}static _valTypes={string:e=>e.value,date:e=>e.valueAsDate,number:e=>e.valueAsNumber};static _getValByType(e,t,r){if("string"!=typeof t)throw new TypeError('The "type" must be a string.');if("string"!=typeof r)throw new TypeError('The "where" must be a string.');if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new Error(`Provided element is not an HTMLInputElement in ${r}().`);if("function"!=typeof gt._valTypes[t])throw new Error(`No handler found for type "${t}" in ${r}().`);return gt._valTypes[t](e)}static _val(e,t,r){const n=gt._preInputElem(e,t),i=gt._valHooks[n.type]||gt._valHooks[n.nodeName.toLowerCase()];if(i&&"function"==typeof i.get){const e=i.get(n,"value",r);if(void 0!==e)return"string"==typeof e?e.replace(/\r/g,""):e}return gt._getValByType(n,r,t)}_val(e,t){return gt._val(this,e,t)}static val(e){return gt._val(e,"val","string")}val(){return gt.val(this)}static valTxt(e){const t=gt._val(e,"valTxt","string");if("string"!=typeof t&&null!==t)throw new Error("Value is not a valid string.");return null==t?"":"string"==typeof t?t.replace(/\r/g,""):t}valTxt(){return gt.valTxt(this)}static _valArr(e,t,r){const n=gt._val(e,t,r);if(!Array.isArray(n))throw new Error(`Value expected an array but got ${typeof n}.`);return n}_valArr(e,t){return gt._valArr(this,e,t)}static valArr(e){return gt._valArr(e,"valArr","string")}valArr(){return gt.valArr(this)}static valNb(e){if(!(gt._preInputElem(e,"valNb")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const t=gt._val(e,"valNb","number");if(Number.isNaN(t))throw new Error("Value is not a valid number.");return t}valNb(){return gt.valNb(this)}static valDate(e){if(!(gt._preInputElem(e,"valDate")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const t=gt._val(e,"valDate","date");if(!(t instanceof Date))throw new Error("Value is not a valid date.");return t}valDate(){return gt.valDate(this)}static valBool(e){const t=gt._preInputElem(e,"valBool");if(!(t instanceof HTMLInputElement))throw new Error("Element must be an input element.");return"on"===gt.val(t)}valBool(){return gt.valBool(this)}static listenForPaste(e,{onFilePaste:t,onTextPaste:r}={}){if(void 0!==t&&"function"!=typeof t)throw new TypeError("onFilePaste must be a function.");if(void 0!==r&&"function"!=typeof r)throw new TypeError("onTextPaste must be a function.");const n=e=>{if(!(e instanceof ClipboardEvent))return;const n=e.clipboardData?.items||[];for(const e of n)if("file"===e.kind){if("function"==typeof t){const r=e.getAsFile();r&&t(e,r)}}else"string"===e.kind&&"function"==typeof r&&e.getAsString(t=>r(e,t))};return gt._preElemsWithDoc(e,"listenForPaste").forEach(e=>gt.on(e,"paste",n)),n}listenForPaste({onFilePaste:e,onTextPaste:t}={}){return gt.listenForPaste(this,{onFilePaste:e,onTextPaste:t})}static hasEventListener(e,t){const r=gt._preEventTargetElem(e,"hasEventListener");if(!ht.has(r))return!1;const n=ht.get(r);return!!(n&&Array.isArray(n[t])&&n[t].length>0)}hasEventListener(e){return gt.hasEventListener(this,e)}static hasExactEventListener(e,t,r){const n=gt._preEventTargetElem(e,"hasExactEventListener");if("function"!=typeof r)throw new TypeError('The "handler" must be a function.');if(!ht.has(n))return!1;const i=ht.get(n);return!(!i||!Array.isArray(i[t]))&&i[t].some(e=>e.handler===r)}hasExactEventListener(e,t){return gt.hasExactEventListener(this,e,t)}static hover(e,t,r,n){return gt.on(e,"mouseenter",t,n),gt.on(e,"mouseleave",r||t,n),e}hover(e,t,r){return gt.hover(this,e,t,r)}static on(e,t,r,n){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const i of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof i)throw new TypeError("The event name must be a string.");gt._preEventTargetElems(e,"on").forEach(e=>{e.addEventListener(i,r,n),ht.has(e)||ht.set(e,{});const t=ht.get(e);t&&(Array.isArray(t[i])||(t[i]=[]),t[i].push({handler:r,options:n}))})}return e}on(e,t,r){return gt.on(this,e,t,r)}static once(e,t,r,n={}){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const i of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof i)throw new TypeError("The event name must be a string.");gt._preEventTargetElems(e,"once").forEach(e=>{const t=n=>{gt.off(e,i,t),"function"==typeof r&&r(n)};gt.on(e,i,t,"boolean"==typeof n?n:{...n,once:!0})})}return e}once(e,t,r={}){return gt.once(this,e,t,r)}static off(e,t,r,n){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const i of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof i)throw new TypeError("The event name must be a string.");gt._preEventTargetElems(e,"off").forEach(e=>{e.removeEventListener(i,r,n);const t=ht.get(e);t&&t[i]&&(t[i]=t[i].filter(e=>e.handler!==r),0===t[i].length&&delete t[i])})}return e}off(e,t,r){return gt.off(this,e,t,r)}static offAll(e,t){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const r of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof r)throw new TypeError("The event name must be a string.");gt._preEventTargetElems(e,"offAll").forEach(e=>{const t=ht.get(e);if(t&&t[r]){for(const n of t[r])e.removeEventListener(r,n.handler,n.options);delete t[r]}})}return e}offAll(e){return gt.offAll(this,e)}static offAllTypes(e,t=null){if(null!==t&&"function"!=typeof t)throw new TypeError('The "filterFn" must be a function.');return gt._preEventTargetElems(e,"offAllTypes").forEach(e=>{const r=ht.get(e);if(r){for(const n in r)for(const i of r[n])("function"!=typeof t||t(i.handler,n))&&e.removeEventListener(n,i.handler,i.options);ht.delete(e)}}),e}offAllTypes(e=null){return gt.offAllTypes(this,e)}static trigger(e,t,r={}){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const n of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof n)throw new TypeError("The event name must be a string.");gt._preEventTargetElems(e,"trigger").forEach(e=>{const t=r instanceof Event||r instanceof CustomEvent?r:new CustomEvent(n,{bubbles:!0,cancelable:!0,detail:r});e.dispatchEvent(t)})}return e}trigger(e,t={}){return gt.trigger(this,e,t)}static#me={for:"htmlFor",class:"className"};static propFix=new Proxy(gt.#me,{set:(e,t,r)=>(e[t]=r,gt.attrFix[r]=t,!0)});static attrFix=Object.fromEntries(Object.entries(gt.#me).map(([e,t])=>[t,e]));static getPropName(e){return"string"==typeof gt.propFix[e]?gt.propFix[e]:e}static getAttrName(e){return"string"==typeof gt.attrFix[e]?gt.attrFix[e]:e}static attrBigInt(e,t){const r=gt._preElem(e,"attrBigInt").getAttribute(gt.getAttrName(t));if(null==r)return null;try{return BigInt(r)}catch{return null}}attrBigInt(e){return gt.attrBigInt(this,e)}static setAttrBigInt(e,t,r){if("bigint"!=typeof r)throw new Error("Value is not a valid BigInt.");return gt.setAttr(e,t,r.toString())}setAttrBigInt(e,t){return gt.setAttrBigInt(this,e,t)}static attrDate(e,t){const r=gt._preElem(e,"attrDate").getAttribute(gt.getAttrName(t));if(!r)return null;const n=new Date(r);return Number.isNaN(n.getTime())?null:n}attrDate(e){return gt.attrDate(this,e)}static setAttrDate(e,t,r){if(!(r instanceof Date)||Number.isNaN(r.getTime()))throw new Error("Value is not a valid Date.");return gt.setAttr(e,t,r.toISOString())}setAttrDate(e,t){return gt.setAttrDate(this,e,t)}static attrJson(e,t){const r=gt._preElem(e,"attrJson").getAttribute(gt.getAttrName(t));if(!r)return null;try{return JSON.parse(r)}catch{return null}}attrJson(e){return gt.attrJson(this,e)}static setAttrJson(e,t,r,n,i){const s=JSON.stringify(r,n,i);return gt.setAttr(e,t,s)}setAttrJson(e,t,r,n){return gt.setAttrJson(this,e,t,r,n)}static attrNumber(e,t){const r=gt._preElem(e,"attrNumber").getAttribute(gt.getAttrName(t));return null!=r?parseFloat(r):null}attrNumber(e){return gt.attrNumber(this,e)}static setAttrNumber(e,t,r){if("number"!=typeof r)throw new Error("Value is not a valid number.");return gt.setAttr(e,t,r.toString())}setAttrNumber(e,t){return gt.setAttrNumber(this,e,t)}static attrBoolean(e,t){const r=gt._preElem(e,"attrBoolean").getAttribute(gt.getAttrName(t));return null===r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}attrBoolean(e){return gt.attrBoolean(this,e)}static setAttrBoolean(e,t,r){if("boolean"!=typeof r)throw new Error("Value is not a valid boolean.");return gt.setAttr(e,t,r.toString())}setAttrBoolean(e,t){return gt.setAttrBoolean(this,e,t)}static attrString(e,t){const r=gt._preElem(e,"attrString").getAttribute(gt.getAttrName(t));return"string"==typeof r?r:null}attrString(e){return gt.attrString(this,e)}static setAttrString(e,t,r){if("string"!=typeof r)throw new Error("Value is not a valid string.");return gt.setAttr(e,t,r)}setAttrString(e,t){return gt.setAttrString(this,e,t)}static attr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return gt._preElem(e,"attr").getAttribute(gt.getAttrName(t))}attr(e){return gt.attr(this,e)}static setAttr(e,t,r=null){const n=gt._preElems(e,"setAttr");if("object"==typeof t&&null!==t)return Object.entries(t).forEach(([e,t])=>n.forEach(r=>{null===t?r.removeAttribute(gt.getAttrName(e)):r.setAttribute(gt.getAttrName(e),String(t))})),e;if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return n.forEach(e=>{null===r?e.removeAttribute(gt.getAttrName(t)):e.setAttribute(gt.getAttrName(t),String(r))}),e}setAttr(e,t){return gt.setAttr(this,e,t)}static removeAttr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return gt._preElems(e,"removeAttr").forEach(e=>e.removeAttribute(gt.getAttrName(t))),e}removeAttr(e){return gt.removeAttr(this,e)}static hasAttr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return gt._preElem(e,"hasAttr").hasAttribute(gt.getAttrName(t))}hasAttr(e){return gt.hasAttr(this,e)}static hasProp(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return!!gt._preElem(e,"hasProp")[gt.getPropName(t)]}hasProp(e){return gt.hasProp(this,e)}static addProp(e,...t){return gt._preElems(e,"addProp").forEach(e=>{t.forEach(t=>{if("string"!=typeof t)throw new TypeError('Each "name" must be a string.');e[gt.getPropName(t)]=!0})}),e}addProp(...e){return gt.addProp(this,...e)}static removeProp(e,...t){return gt._preElems(e,"removeProp").forEach(e=>{t.forEach(t=>{if("string"!=typeof t)throw new TypeError('Each "name" must be a string.');e[gt.getPropName(t)]=!1})}),e}removeProp(...e){return gt.removeProp(this,...e)}static toggleProp(e,t,r){const n=gt._preElems(e,"toggleProp");if(void 0!==r&&"boolean"!=typeof r)throw new TypeError('The "force" must be a boolean.');return(Array.isArray(t)?t:[t]).forEach(e=>{if("string"!=typeof e)throw new TypeError("Each property name must be a string.");n.forEach(t=>{(void 0===r?!t[gt.getPropName(e)]:r)?gt.addProp(t,e):gt.removeProp(t,e)})}),e}toggleProp(e,t){return gt.toggleProp(this,e,t)}static prop(e,t){if("string"!=typeof t)throw new TypeError('Invalid arguments passed to prop(). Expected string for "name".');return gt._preElem(e,"prop")[t]}prop(e){return gt.prop(this,e)}static setProp(e,t,r){if("string"!=typeof t||""===t.trim())throw new Error("Property name must be a non-empty string.");return gt._preElems(e,"setProp").forEach(e=>{e[t]=r}),e}setProp(e,t){return gt.setProp(this,e,t)}static remove(e){return gt._preElems(e,"remove").forEach(e=>e.remove()),e}remove(){return gt.remove(this)}static index(e,t=null){const r=gt._preElem(e,"index");if(!r)return-1;if(!t)return Array.prototype.indexOf.call(r.parentNode?.children||[],r);if(t){const e="string"==typeof t?document.querySelectorAll(t):gt._preElems(t,"index");return Array.prototype.indexOf.call(e,r)}return-1}index(e){return gt.index(this,e)}static _getCustomRect(e,t){const r={height:0,width:0,x:0,y:0,bottom:0,left:0,right:0,top:0,toJSON:function(){throw new Error("Function not implemented.")}};for(const t in e)"number"==typeof e[t]&&(r[t]=e[t]);if("object"!=typeof t||null===t||Array.isArray(t))throw new Error("extraRect must be a non-null object.");const{height:n=0,width:i=0,top:s=0,bottom:o=0,left:a=0,right:l=0}=t;if("number"!=typeof n)throw new Error("extraRect.height must be a number.");if("number"!=typeof i)throw new Error("extraRect.width must be a number.");if("number"!=typeof s)throw new Error("extraRect.top must be a number.");if("number"!=typeof o)throw new Error("extraRect.bottom must be a number.");if("number"!=typeof a)throw new Error("extraRect.left must be a number.");if("number"!=typeof l)throw new Error("extraRect.right must be a number.");return r.height+=n,r.width+=i,r.top+=s,r.bottom+=o,r.left+=a,r.right+=l,r}static isCollWith(e,t,r={}){const n=gt._getCustomRect(gt._preElem(e,"isCollWith").getBoundingClientRect(),r),i=gt._preElem(t,"isCollWith").getBoundingClientRect();return st(n,i)}isCollWith(e,t){return gt.isCollWith(this,e,t)}static isCollPerfWith(e,t,r={}){const n=gt._getCustomRect(gt._preElem(e,"isCollPerfWith").getBoundingClientRect(),r),i=gt._preElem(t,"isCollPerfWith").getBoundingClientRect();return ot(n,i)}isCollPerfWith(e,t){return gt.isCollPerfWith(this,e,t)}static _isCollWithLock(e,t,r,n,i){const s=ft[i];if(e)return s.has(n)||s.set(n,!0),!0;if(s.has(n)){let e=!1;switch(i){case"top":e=at(t,r);break;case"bottom":e=lt(t,r);break;case"left":e=ut(t,r);break;case"right":e=ct(t,r)}return e&&s.delete(n),s.has(n)}return!1}static isCollWithLock(e,t,r,n={}){const i=gt._preElem(e,"isCollWithLock"),s=gt._preElem(t,"isCollWithLock"),o=gt._getCustomRect(i.getBoundingClientRect(),n),a=s.getBoundingClientRect(),l=st(o,a);return gt._isCollWithLock(l,o,a,i,r)}isCollWithLock(e,t,r){return gt.isCollWithLock(this,e,t,r)}static isCollPerfWithLock(e,t,r,n={}){const i=gt._preElem(e,"isCollPerfWithLock"),s=gt._preElem(t,"isCollPerfWithLock"),o=gt._getCustomRect(i.getBoundingClientRect(),n),a=s.getBoundingClientRect(),l=ot(o,a);return gt._isCollWithLock(l,o,a,i,r)}isCollPerfWithLock(e,t,r){return gt.isCollPerfWithLock(this,e,t,r)}static resetCollLock(e){const t=gt._preElem(e,"resetCollLock");let r=!1;for(const e of["top","bottom","left","right"])ft[e].has(t)&&(ft[e].delete(t),r=!0);return r}resetCollLock(){return gt.resetCollLock(this)}static resetCollLockDir(e,t){const r=gt._preElem(e,"resetCollLockDir"),n=ft[t];return!!n.has(r)&&(n.delete(r),!0)}resetCollLockDir(e){return gt.resetCollLockDir(this,e)}static isInViewport(e){const t=gt._preElem(e,"isInViewport");if(!t.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=gt.offset(t).top,n=r+gt.outerHeight(t),i=gt.scrollTop(window),s=i+gt.height(window);return n>i&&r<s}isInViewport(){return gt.isInViewport(this)}static isScrolledIntoView(e){const t=gt._preElem(e,"isScrolledIntoView");if(!t.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=gt.scrollTop(window),n=r+gt.height(window),i=gt.offset(t).top;return i+gt.height(t)<=n&&i>=r}isScrolledIntoView(){return gt.isScrolledIntoView(this)}static isInContainer(e,t){const r=gt._preElem(e,"isInContainer"),n=gt._preElem(t,"isInContainer");if(!r.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const i=r.getBoundingClientRect(),s=n.getBoundingClientRect(),o=i.bottom>s.top&&i.top<s.bottom,a=i.right>s.left&&i.left<s.right;return o&&a}isInContainer(e){return gt.isInContainer(this,e)}static isFullyInContainer(e,t){const r=gt._preElem(e,"isScrolledIntoView"),n=gt._preElem(t,"isInContainer");if(!r.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const i=r.getBoundingClientRect(),s=n.getBoundingClientRect();return i.top>=s.top&&i.bottom<=s.bottom&&i.left>=s.left&&i.right<=s.right}isFullyInContainer(e){return gt.isFullyInContainer(this,e)}static hasScroll(e){const t=gt._preElem(e,"hasScroll");return{v:t.scrollHeight>t.clientHeight,h:t.scrollWidth>t.clientWidth}}hasScroll(){return gt.hasScroll(this)}}const yt=gt;class wt{static Utils={...t,TinyHtml:yt};#fe=!0;#ge=!1;#ye=0;#we=0;#be=!0;#ve=!1;#Ee=!1;#Te=!1;#Se=!1;#xe=!1;#Ae=!1;#Ce=null;#Ie=[];#Me=null;#ke={start:!1,end:!1,collide:!1,move:!1};#Le=null;#H;#Ne="drag-hidden";#De="dragging";#_e="drag-active";#Re="jail-drag-active";#je="jail-drag-disabled";#Oe="dragging-collision";#Pe=9999;constructor(e,t={}){if(!(e instanceof HTMLElement))throw new Error("TinyDragger requires a valid target HTMLElement to initialize.");if(this.#H=e,void 0!==t.jail&&!(t.jail instanceof HTMLElement))throw new Error('The "jail" option must be an HTMLElement if provided.');if(void 0!==t.defaultZIndex&&this.setDefaultZIndex(t.defaultZIndex),void 0!==t.vibration&&!1!==t.vibration&&!f(t.vibration))throw new Error('The "vibration" option must be an object or false.');const r=(e,t)=>{if(void 0!==e&&"boolean"!=typeof e)throw new Error(`The "${t}" option must be a boolean.`)},n=(e,t)=>{if(void 0!==e&&"string"!=typeof e)throw new Error(`The "${t}" option must be a string.`)};r(t.mirrorElem,"mirrorElem"),r(t.collisionByMouse,"collisionByMouse"),r(t.lockInsideJail,"lockInsideJail"),r(t.dropInJailOnly,"dropInJailOnly"),r(t.revertOnDrop,"revertOnDrop"),r(t.multiCollision,"multiCollision"),n(t.classDragging,"classDragging"),n(t.classBodyDragging,"classBodyDragging"),n(t.classJailDragging,"classJailDragging"),n(t.classJailDragDisabled,"classJailDragDisabled"),n(t.classDragCollision,"classDragCollision"),n(t.classHidden,"classHidden"),t.jail instanceof HTMLElement&&(this.#Le=t.jail),this.#ke=Object.assign({start:!1,end:!1,collide:!1,move:!1},f(t.vibration)?t.vibration:{}),"string"==typeof t.classDragging&&(this.#De=t.classDragging),"string"==typeof t.classBodyDragging&&(this.#_e=t.classBodyDragging),"string"==typeof t.classJailDragging&&(this.#Re=t.classJailDragging),"string"==typeof t.classJailDragDisabled&&(this.#je=t.classJailDragDisabled),"string"==typeof t.classHidden&&(this.#Ne=t.classHidden),"string"==typeof t.classDragCollision&&(this.#Oe=t.classDragCollision),"boolean"==typeof t.collisionByMouse&&(this.#xe=t.collisionByMouse),"boolean"==typeof t.mirrorElem&&(this.#be=t.mirrorElem),"boolean"==typeof t.revertOnDrop&&(this.#Te=t.revertOnDrop),"boolean"==typeof t.lockInsideJail&&(this.#Ee=t.lockInsideJail),"boolean"==typeof t.dropInJailOnly&&(this.#Ae=t.dropInJailOnly),"boolean"==typeof t.multiCollision&&(this.#ve=t.multiCollision),this._onMouseDown=this.#$e.bind(this),this._onMouseMove=this.#He.bind(this),this._onMouseUp=this.#Be.bind(this),this._onTouchStart=e=>this.#$e(e.touches[0]),this._onTouchMove=e=>this.#He(e.touches[0]),this._onTouchEnd=e=>this.#Be(e.changedTouches[0]),this.#H.addEventListener("mousedown",this._onMouseDown),this.#H.addEventListener("touchstart",this._onTouchStart,{passive:!1})}enable(){this.#Fe(),this.#Le&&this.#Le.classList.add(this.#je),this.#fe=!0}disable(){this.#Le&&this.#Le.classList.remove(this.#je),this.#fe=!1}addCollidable(e){if(this.#Fe(),!(e instanceof HTMLElement))throw new Error("addCollidable expects an HTMLElement as argument.");this.#Ie.includes(e)||this.#Ie.push(e)}removeCollidable(e){if(this.#Fe(),!(e instanceof HTMLElement))throw new Error("removeCollidable expects an HTMLElement as argument.");this.#Ie=this.#Ie.filter(t=>t!==e)}setVibrationPattern({startPattern:e=!1,endPattern:t=!1,collidePattern:r=!1,movePattern:n=!1}={}){this.#Fe();const i=e=>!1===e||Array.isArray(e)&&e.every(e=>"number"==typeof e);if(!i(e))throw new Error('Invalid "startPattern": must be false or an array of numbers.');if(!i(t))throw new Error('Invalid "endPattern": must be false or an array of numbers.');if(!i(r))throw new Error('Invalid "collidePattern": must be false or an array of numbers.');if(!i(n))throw new Error('Invalid "movePattern": must be false or an array of numbers.');this.#ke={start:e,end:t,collide:r,move:n}}disableVibration(){this.#Fe(),this.#ke={start:!1,end:!1,collide:!1,move:!1}}getOffset(e){if(this.#Fe(),!(e instanceof MouseEvent||e instanceof Touch)||"number"!=typeof e.clientX||"number"!=typeof e.clientY)throw new Error("getOffset expects an event with valid clientX and clientY coordinates.");const t=this.#H.getBoundingClientRect(),{left:r,top:n}=yt.borderWidth(this.#H);return{x:e.clientX-t.left+r,y:e.clientY-t.top+n}}#$e(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#ge||!this.#fe||!this.#H.parentElement)return;if(this.#be){const e=this.#H.cloneNode(!0);if(!(e instanceof HTMLElement))throw new Error("[TinyDragger] INVALID DRAG ELEMENT!");this.#Me=e}else this.#Me=this.#H;this.#Se=!0;const t=this.#H.getBoundingClientRect();Object.assign(this.#Me.style,{position:"absolute",pointerEvents:"none",left:`${this.#H.offsetLeft}px`,top:`${this.#H.offsetTop}px`,width:`${t.width}px`,height:`${t.height}px`,zIndex:this.#Pe}),this.#be&&(this.#H.classList.add(this.#Ne),this.#H.parentElement.appendChild(this.#Me));const{x:r,y:n}=this.getOffset(e);this.#we=r,this.#ye=n,this.#Me.classList.add(this.#De),document.body.classList.add(this.#_e),this.#Le&&this.#Le.classList.add(this.#Re),document.addEventListener("mousemove",this._onMouseMove),document.addEventListener("mouseup",this._onMouseUp),document.addEventListener("touchmove",this._onTouchMove,{passive:!1}),document.addEventListener("touchend",this._onTouchEnd),navigator.vibrate&&Array.isArray(this.#ke.start)&&navigator.vibrate(this.#ke.start),this.checkDragCollision(e),this.#ze("drag")}#We=[];#qe(e){e&&(e.classList.add(this.#Oe),this.#We.push(e))}#Ve(){for(;this.#We.length>0;){const e=this.#We.shift();e&&e.classList.remove(this.#Oe)}this.#Ce&&this.#Ce.classList.remove(this.#Oe)}checkDragCollision(e){const{collidedElements:t}=this.execCollision(e),r=t[0]||null;this.#Ce&&!t.includes(this.#Ce)&&this.#Ve(),t.forEach(e=>this.#qe(e)),this.#Ie.forEach(e=>{t.includes(e)||e.classList.remove(this.#Oe)}),navigator.vibrate&&Array.isArray(this.#ke.collide)&&t.length>0&&navigator.vibrate(this.#ke.collide),this.#Ce=r}#He(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#ge||!this.#Se||!this.#fe||!this.#Me)return;const t=(this.#Me.offsetParent||document.body).getBoundingClientRect();let r=e.clientX-t.left-this.#we,n=e.clientY-t.top-this.#ye;if(this.#Ee&&this.#Le){const e=this.#Le.getBoundingClientRect(),i=this.#Me.getBoundingClientRect(),s=e.left-t.left,o=e.top-t.top,{x:a,y:l}=yt.borderWidth(this.#Le),u=s+e.width-i.width-l,c=o+e.height-i.height-a;r=Math.max(s,Math.min(r,u)),n=Math.max(o,Math.min(n,c))}this.#Me.style.position="absolute",this.#Me.style.left=`${r}px`,this.#Me.style.top=`${n}px`,navigator.vibrate&&Array.isArray(this.#ke.move)&&navigator.vibrate(this.#ke.move),this.checkDragCollision(e),this.#ze("dragging")}execCollision(e){if(this.#ge||!this.#Me)return{inJail:!1,collidedElements:[]};let t=[],r=!0;const n=this.#Le?.getBoundingClientRect();if(this.#xe){const i=e.clientX,s=e.clientY;this.#Ae&&this.#Le&&n&&(r=i>=n.left&&i<=n.right&&s>=n.top&&s<=n.bottom),t=r?this.#ve?this.getAllCollidedElements(i,s):[this.getCollidedElement(i,s)].filter(Boolean):[]}else{const e=this.#Me.getBoundingClientRect();this.#Ae&&this.#Le&&n&&(r=e.left>=n.left&&e.right<=n.right&&e.top>=n.top&&e.bottom<=n.bottom),t=r?this.#ve?this.getAllCollidedElementsByRect(e):[this.getCollidedElementByRect(e)].filter(Boolean):[]}return{inJail:r,collidedElements:t}}#Be(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#ge||!this.#Se)return;if(this.#Se=!1,!this.#Me)return;this.#H.classList.remove(this.#De),document.body.classList.remove(this.#_e),this.#Le&&this.#Le.classList.remove(this.#Re),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd);const{collidedElements:t}=this.execCollision(e);navigator.vibrate&&Array.isArray(this.#ke.end)&&navigator.vibrate(this.#ke.end);const r=this.#Me.style.left,n=this.#Me.style.top;this.#Me&&(this.#be?this.#Me.remove():Object.assign(this.#Me.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#Me=null),this.#Ce&&this.#Ve(),this.#Ce=null,this.#be&&this.#H.classList.remove(this.#Ne),this.#Te||(this.#H.style.left=r,this.#H.style.top=n);const i=new CustomEvent("drop",{detail:{targets:t,first:t[0]||null}});this.#H.dispatchEvent(i)}#Ue(e,t){const r=e.getBoundingClientRect();return!(t.right<r.left||t.left>r.right||t.bottom<r.top||t.top>r.bottom)}getAllCollidedElementsByRect(e){if(this.#Fe(),!(e instanceof DOMRect)||"number"!=typeof e.left||"number"!=typeof e.right||"number"!=typeof e.top||"number"!=typeof e.bottom)throw new Error("getCollidedElementByRect expects a valid DOMRect object.");return this.#Ie.filter(t=>this.#Ue(t,e))}getCollidedElementByRect(e){if(this.#Fe(),!(e instanceof DOMRect)||"number"!=typeof e.left||"number"!=typeof e.right||"number"!=typeof e.top||"number"!=typeof e.bottom)throw new Error("getCollidedElementByRect expects a valid DOMRect object.");return this.#Ie.find(t=>this.#Ue(t,e))||null}#Ke(e,t,r){const n=e.getBoundingClientRect();return t>=n.left&&t<=n.right&&r>=n.top&&r<=n.bottom}getAllCollidedElements(e,t){if(this.#Fe(),"number"!=typeof e||"number"!=typeof t)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#Ie.filter(r=>this.#Ke(r,e,t))}getCollidedElement(e,t){if(this.#Fe(),"number"!=typeof e||"number"!=typeof t)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#Ie.find(r=>this.#Ke(r,e,t))||null}#ze(e){const t=new CustomEvent(e);this.#H.dispatchEvent(t)}getDragging(){return this.#Se}getLockInsideJail(){return this.#Ee}setLockInsideJail(e){if("boolean"!=typeof e)throw new Error("lockInsideJail must be a boolean.");this.#Ee=e}getRevertOnDrop(){return this.#Te}setRevertOnDrop(e){if("boolean"!=typeof e)throw new Error("revertOnDrop must be a boolean.");this.#Te=e}getCollisionByMouse(){return this.#xe}setCollisionByMouse(e){if("boolean"!=typeof e)throw new Error("collisionByMouse must be a boolean.");this.#xe=e}getDropInJailOnly(){return this.#Ae}setDropInJailOnly(e){if("boolean"!=typeof e)throw new Error("dropInJailOnly must be a boolean.");this.#Ae=e}getDefaultZIndex(){return this.#Pe}setDefaultZIndex(e){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("Z-index must be a finite number.");this.#Pe=e}isMirrorEnabled(){return this.#be}setMirrorEnabled(e){if("boolean"!=typeof e)throw new TypeError("Mirror setting must be a boolean.");this.#be=e}getTarget(){return this.#H}getJail(){return this.#Le}getDragProxy(){return this.#Me}getLastCollision(){return this.#Ce}getCollidables(){return[...this.#Ie]}getDragHiddenClass(){return this.#Ne}getClassDragging(){return this.#De}getClassBodyDragging(){return this.#_e}getClassJailDragging(){return this.#Re}getClassJailDragDisabled(){return this.#je}getClassDragCollision(){return this.#Oe}getVibrations(){return{...this.#ke}}getStartVibration(){return this.#ke.start}getEndVibration(){return this.#ke.end}getCollideVibration(){return this.#ke.collide}getMoveVibration(){return this.#ke.move}isEnabled(){return this.#fe}#Fe(){if(this.#ge)throw new Error("This TinyDragger instance has been destroyed and can no longer be used.")}destroy(){this.#ge||(this.disable(),this.#H.removeEventListener("mousedown",this._onMouseDown),this.#H.removeEventListener("touchstart",this._onTouchStart),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd),this.#Ce&&this.#Ve(),this.#Me&&(this.#be?this.#Me.remove():Object.assign(this.#Me.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#Me=null),this.#Ie=[],this.#Se=!1,this.#Ce=null,this.#be&&this.#H.classList.remove(this.#Ne),this.#H.classList.remove(this.#De),document.body.classList.remove(this.#_e),this.#Le&&this.#Le.classList.remove(this.#Re,this.#je),this.#ge=!0)}}const bt=wt,vt=class{#Je=[];#Ge=!1;#Ye=!1;#Xe=[];#Qe(){this.#Ge&&Promise.all(this.#Xe).then(()=>{this.#Ye=!0,this.#Ze(!1)}).catch(e=>{console.error("[TinyDomReadyManager] Promise rejected:",e)})}#Ze(e){this.#Je.filter(t=>t.domOnly===e).sort((e,t)=>t.priority-e.priority).forEach(e=>this.#et(e)),this.#Je=this.#Je.filter(t=>!(t.once&&(!e||t.domOnly)))}#et(e){if("function"==typeof e.filter)try{if(!e.filter())return}catch(e){return void console.warn("[TinyDomReadyManager] Filter error:",e)}try{e.fn()}catch(e){console.error("[TinyDomReadyManager] Handler error:",e)}}_markDomReady(){this.#Ge=!0,this.#Ze(!0),this.#Qe()}init(){if(this.#Ge)throw new Error("[TinyDomReadyManager] init() has already been called.");"interactive"===document.readyState||"complete"===document.readyState?this._markDomReady():document.addEventListener("DOMContentLoaded",()=>this._markDomReady())}addPromise(e){if(!(e instanceof Promise))throw new TypeError("[TinyDomReadyManager] promise must be a valid Promise.");this.#Ye||(this.#Xe.push(e),this.#Ge&&this.#Qe())}onReady(e,{once:t=!0,priority:r=0,filter:n=null,domOnly:i=!1}={}){if("function"!=typeof e)throw new TypeError("[TinyDomReadyManager] fn must be a function.");const s={fn:e,once:t,priority:r,filter:n,domOnly:i};if(i&&this.#Ge)return this.#et(s),void(t||this.#Je.push(s));!i&&this.#Ye?this.#et(s):this.#Je.push(s)}isReady(){return this.#Ye}isDomReady(){return this.#Ge}},Et=class{#tt=!1;#rt=!1;#nt=null;#it=100;#st=null;#ot;constructor({audio:e=null,defaultIcon:t=null,bodyLimit:r=100,defaultOnClick:n=function(e){e.preventDefault(),window.focus&&window.focus(),this.close()}}={}){if(!(e instanceof HTMLAudioElement)&&"string"!=typeof e&&null!==e)throw new TypeError("audio must be an instance of HTMLAudioElement or null.");if(null!==t&&"string"!=typeof t)throw new TypeError("defaultIcon must be a string or null.");if(!Number.isFinite(r)||r<0)throw new TypeError("bodyLimit must be a non-negative number.");if("function"!=typeof n)throw new TypeError("defaultOnClick must be a function.");this.#nt="string"!=typeof e?e:new Audio(e),this.#st=t,this.#it=r,this.#ot=n}requestPerm(){const e=this;return new Promise((t,r)=>{e.isCompatible()?"default"===Notification.permission?Notification.requestPermission().then(r=>{this.#rt=!0,e.#tt="granted"===r,t(e.#tt)}).catch(r):(this.#rt=!0,e.#tt="granted"===Notification.permission,t(e.#tt)):(this.#rt=!0,e.#tt=!1,t(!1))})}isCompatible(){return"Notification"in window}send(e,t={}){if(!this.#rt)throw new Error("You must call requestPerm() before sending a notification.");if("string"!=typeof e)throw new TypeError("title must be a string.");if("object"!=typeof t||null===t)throw new TypeError("config must be a non-null object.");if(!this.#tt)return null;const{icon:r=this.#st||void 0,vibrate:n=[200,100,200]}=t,i={...t};"string"==typeof r&&(i.icon=r),Array.isArray(n)&&(i.vibrate=n),"string"==typeof i.body&&(i.body=q(i.body,this.#it));const s=new Notification(e,i);return s.addEventListener("show",()=>{this.#nt instanceof HTMLAudioElement&&(this.#nt.currentTime=0,this.#nt.play().catch(e=>console.error(e)))}),"function"==typeof this.#ot&&s.addEventListener("click",this.#ot),s}wasPermissionRequested(){return this.#rt}isAllowed(){return this.#tt}getAudio(){return this.#nt}setAudio(e){if(!(e instanceof HTMLAudioElement)&&"string"!=typeof e&&null!==e)throw new TypeError("sound must be an instance of HTMLAudioElement or null.");this.#nt="string"!=typeof e?e:new Audio(e)}getBodyLimit(){return this.#it}setBodyLimit(e){if(!Number.isFinite(e)||e<0)throw new TypeError("bodyLimit must be a non-negative number.");this.#it=e}getDefaultAvatar(){return this.#st}setDefaultAvatar(e){if("string"!=typeof e&&null!==e)throw new TypeError("defaultIcon must be a string or null.");this.#st=e}getDefaultOnClick(){return this.#ot}setDefaultOnClick(e){if("function"!=typeof e)throw new TypeError("defaultOnClick must be a function.");this.#ot=e}},Tt=new Map;class St extends Error{constructor(e,t,r){super(e),this.name="MediaLoadingError",this.url=t,this.stage=r}}const xt=async e=>{const t=(new TextEncoder).encode(e),r=await crypto.subtle.digest("SHA-1",t);return Array.from(new Uint8Array(r)).map(e=>e.toString(16).padStart(2,"0")).join("").substring(0,8)},At=(e,t="image/jpeg")=>{const r=e=>{const t=URL.createObjectURL(e),r=Tt.get(t);return Tt.set(t,"number"==typeof r?r+1:1),t};if(e instanceof Uint8Array)return r(new Blob([e],{type:t}));if("string"==typeof e&&e.startsWith("data:")){const n=e.split(",")[1],i=atob(n),s=new Uint8Array(i.length);for(let e=0;e<i.length;e++)s[e]=i.charCodeAt(e);return r(new Blob([s],{type:t}))}return"string"==typeof e?e:""},Ct=async e=>{if("string"!=typeof e||!e.startsWith("blob:"))return e;try{const t=await fetch(e),r=await t.blob();return await new Promise((e,t)=>{const n=new FileReader;n.onloadend=()=>e(String(n.result)),n.onerror=t,n.readAsDataURL(r)})}catch(t){return console.warn(`[TinyAudioUtils] Failed to convert Blob URL to Base64 on export: ${e}`,t),e}},It=e=>{e&&Array.isArray(e.picture)&&e.picture.forEach(e=>{if("string"==typeof e.data&&e.data.startsWith("blob:")){const t=Tt.get(e.data)??0;t>1?Tt.set(e.data,t-1):Tt.delete(e.data),t<=1&&URL.revokeObjectURL(e.data)}})},Mt=(e,t)=>{const r=e=>t&&void 0===e,n=e=>r(e)||"string"==typeof e||null===e,i=(e,t)=>!!r(e)||!(!Array.isArray(e)||!e.every(t));if(!n(e.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!n(e.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!n(e.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a string or null.');if(!n(e.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(s=e.year,!r(s)&&"number"!=typeof s&&null!==s)throw new TypeError('Invalid metadata: "year" must be a number or null.');var s;if(!i(e.albumartists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "albumartists" must be an array of string.');if(!i(e.genre,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "genre" must be an array of string.');if(!i(e.label,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "label" must be an array of string.');if(!i(e.composer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "composer" must be an array of string.');if(!i(e.artists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "artists" must be an array of string.');if(!i(e.picture,e=>!(void 0!==e.description&&"string"!=typeof e.description||void 0!==e.name&&"string"!=typeof e.name||void 0!==e.type&&"string"!=typeof e.type||"string"!=typeof e.format||!(e.data instanceof Uint8Array||"string"==typeof e.data))))throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');const o=(e,t)=>{if(!r(e)){if(null==e)throw new TypeError(`Invalid metadata: "${t}" is required.`);if("object"!=typeof e)throw new TypeError(`Invalid metadata: "${t}" must be an object or null.`);if("number"!=typeof e.no&&null!==e.no)throw new TypeError(`Invalid metadata: "${t}.no" must be a number or null.`);if("number"!=typeof e.of&&null!==e.of)throw new TypeError(`Invalid metadata: "${t}.of" must be a number or null.`)}};o(e.disk,"disk"),o(e.track,"track")},kt=e=>Mt(e,!1),Lt=e=>Mt(e,!0),Nt=async(e,t)=>{if("string"!=typeof e)throw new TypeError(`Expected url to be a string, but received ${typeof e}.`);if("function"!=typeof t)throw new TypeError(`Expected parseFile to be a function, but received ${typeof t}.`);try{const r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch audio file: ${r.status} ${r.statusText}`);const n=await r.blob(),i=await t(n);if(!i||"object"!=typeof i.common)throw new TypeError('Invalid metadata: "common" property is missing or not an object.');const s=i.common;return Lt(s),{title:s?.title??null,album:s?.album??null,albumartist:s?.albumartist??null,albumartists:s?.albumartists??[],genre:s?.genre??[],label:s?.label??[],composer:s?.composer??[],year:s?.year??null,artist:s?.artist??null,artists:s?.artists??[],disk:s?.disk?{no:s.disk.no,of:s.disk.of}:{no:null,of:null},track:s?.track?{no:s.track.no,of:s.track.of}:{no:null,of:null},picture:s?.picture?.map(e=>({...e,data:At(e.data,e.format)}))??[]}}catch(e){throw e}},Dt=async(e,t={},r={},n=e=>new Promise((e,t)=>t(new TypeError("parseFile library not found."))),i={},s="null")=>{if("string"!=typeof e&&!(e instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(i.onProgress&&"function"!=typeof i.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(i.onError&&"function"!=typeof i.onError)throw new TypeError("callbacks.onError must be a function.");let o,a="";const l=(t,r)=>{i.onProgress&&i.onProgress({event:r,status:"loading",stage:t,url:a||(e instanceof HTMLMediaElement?e.src:"unknown")})},u=(t,r)=>{i.onError&&i.onError({error:t,url:a||(e instanceof HTMLMediaElement?e.src:"unknown"),stage:r})};try{l("INITIALIZING"),"string"==typeof e?(a=e,o=new Audio(a)):(o=e,a=o.src);try{await new Promise((e,t)=>{const r=e=>l("DOWNLOADING",e),n=()=>{s(),e(void 0)},i=e=>{s(),t(new Error(`HTMLMediaElement failed to load: ${e.message||"Unknown error"}`))},s=()=>{o.removeEventListener("progress",r),o.removeEventListener("loadedmetadata",n),o.removeEventListener("error",i)};o.addEventListener("progress",r),o.addEventListener("loadedmetadata",n),o.addEventListener("error",i),o.readyState>=1&&(s(),e(void 0))}),l("METADATA_LOADED")}catch(e){throw new St(e instanceof Error?e.message:"UNKNOWN ERROR",a,"METADATA")}const c={id:r.id||await xt(a),duration:Math.floor(1e3*o.duration),url:a,weight:r.weight??1};let h={};l("EXTRACTING_ID3");try{h=await Nt(a,n)}catch(e){u(e instanceof Error?e:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${a}. Falling back to filename.`)}const d=e=>{try{return(e.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},p={...c,...t,...h,...r,title:h.title||r.title||d(a),artist:h.artist||r.artist||("string"==typeof s?s:String(s()))};return i.onProgress&&i.onProgress({status:"success",stage:"COMPLETE",url:a}),p}catch(e){if(e instanceof St)throw e;{const t=new St(e instanceof Error?e.message:"UNKNOWN ERROR",a,"INITIALIZING");throw u(t,"INITIALIZING"),t}}},_t=class{#at;get scrollTarget(){return this.#at}#lt=null;#ut=[];get afterScrollQueueSize(){return this.#ut.length}#ct=100;#ht=new Set;#dt=new Set;#ge=!1;get destroyed(){return this.#ge}constructor(e,t=100){if(!(e instanceof Element||e instanceof Window))throw new TypeError("scrollTarget must be an Element or the Window object.");this.#at=e,this._checkTimer=this._checkTimer.bind(this),this.#at.addEventListener("scroll",this._checkTimer),this.#ct=t}_checkTimer=()=>{this.#lt&&clearTimeout(this.#lt),this.#lt=setTimeout(()=>{this.#lt=null,this.#pt()},this.#ct)};get inactivityTime(){return this.#ct}set inactivityTime(e){if("number"!=typeof e||e<=0||!Number.isFinite(e))throw new Error("inactivityTime must be a positive number in milliseconds.");this.#ct=e}#pt(){if(!this.#ge){for(const e of this.#dt)"function"==typeof e&&e();for(;this.#ut.length;){const e=this.#ut.pop();"function"==typeof e&&e()}}}doAfterScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.lastScrollTime=Date.now(),this.#ut.push(e)}onStop(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#dt.add(e)}offStop(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#dt.delete(e)}onScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#at.addEventListener("scroll",e),this.#ht.add(e)}offScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ht.has(e)&&(this.#at.removeEventListener("scroll",e),this.#ht.delete(e))}destroy(){if(!this.#ge){this.#ge=!0,this.#at.removeEventListener("scroll",this._checkTimer);for(const e of this.#ht)this.#at.removeEventListener("scroll",e);this.#ht.clear(),this.#dt.clear()}}},Rt=["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","sed","do","eiusmod","tempor","incididunt","ut","labore","et","dolore","magna","aliqua"],jt=["😂","🌈","🤖","💥","🐸","🍕","🦄","🧠","🧬","🚀","🫠","💫","🍩","👾","🎉","🥴","🐙","🧃","🪐","🎈","🧸","👻","🥳","🍭","💖","😺","🌮","🪅","🎮","🥓","🍮"],Ot=["pudding","bean","snuggle","bloop","jelly","unicorn","floof","giggle","bubble","muffin","puff","pickle","goblin","waffle","sprinkle","cupcake","fizzle","marshmallow","duckling","sock","cloud","teacup","nugget","gnome","hug","moonbean","crayon","jiggle","glitter","carrot","goober"],Pt=["wiggles","bounces","flies","splats","scoots","giggles","wigglesnacks","twirls","boops","pops","sings","hugs","floats","glows","flaps","mlems","dances","puddles","nomnoms","wigglejumps","sniffs","tumbles","slides","chirps","burps","sparkles","waddles","rambles","blinks","mews"],$t=["fluffy","silly","yummy","squishy","wobbly","magical","tiny","sleepy","wiggly","bubbly","glittery","fuzzy","jiggly","sparkly","giggly","crunchy","goofy","soft","mushy","sweet","loopy","floaty","bonkers","chewy","ticklish","dreamy","pastel","cozy","teensy","grumbly"],Ht=["Boop!","Wiggle achieved.","Oops, {noun} everywhere!","Tiny {adj} {noun}, big {adj} {noun}.","Snuggle initiated with a {adj} {noun}.","{adj} vibes only, powered by {noun}.","No {noun}, no {noun}.","Bounce first, {verb} later.","Mlem. {verb}. {noun}.","{noun} go brrr and {verb}.","Why not? {noun} did. Then {noun} followed.","A {adj} {noun} just {verb} near the {adj} window.","That {adj} {noun} stole my {noun}!","Look, a {adj} {noun} trying to {verb} again!","Every {noun} deserves a {adj} nap.","The {adj} {noun} is my {adj} spirit animal.","Someone call the {noun}, it’s {verb}ing and {verb}ing again!","Don’t touch the {adj} {noun}. It {verb}s loudly.","{noun} forgot how {noun}s work and just {verb}ed.","There once was a {adj} {noun} who loved to {verb} with a {adj} {noun} all day.","Apparently, {noun}s are banned from {verb}ing and {verb}ing in the {noun} library.","That {adj} noise? Just a {noun} learning to {verb} on a {adj} {noun}.","I saw a {adj} {noun} {verb} so hard, it became a {adj} muffin.","The {adj} {noun} met a {adj} pickle and everything {verb}ed.","{noun}s are like {noun}: {adj}, unpredictable, and wiggly.","Don’t judge a {adj} {noun} by its ability to {verb}, or by its {adj} hat.","All I wanted was peace, but a {adj} {noun} with a {adj} {noun} had other plans.","One {adj} morning, a {adj} {noun} decided it was finally time to {verb}, but halfway through, it tripped on a {noun} and turned into a {adj} marshmallow.","I tried to be {adj} today, but then a {noun} {verb}ed across my {noun} and typed “asdfgh{noun}” repeatedly.","If you think you’ve seen everything, wait until a {adj} {noun} {verb}s on a {noun} wearing {adj} socks with tiny {noun}s.","No one ever believed the stories about the ancient {adj} {noun} who could {verb} with such {adj} grace that entire {noun}s turned pink out of embarrassment.","A curious {adj} {noun} wandered into a {noun} shop, not knowing that its destiny involved twelve {adj} {noun}s, one rubber {noun}, and a suspiciously quiet {adj} llama.","In a land where every {adj} {noun} was made of pudding and the sky was {adj} whipped cream, one brave {adj} {noun} set out to discover the legendary Spoon of {noun}s, facing obstacles like bouncing {noun}s, sassy {noun}s, and the Great Wobble of the {noun}.","Once upon a {adj} time, long before the {noun}s learned to {verb}, there existed a tiny {adj} {noun} who dreamed of swimming in a pool made entirely of {adj} glitter pudding while {verb}ing off-key lullabies to passing {noun}s with monocles.","The Council of {noun}s gathered in {adj} secret when the sacred {adj} {noun} started to {verb} uncontrollably, threatening the entire {adj} dessert-based civilization with spontaneous {noun} jiggles and uncontainable {noun} fits across the {noun}.","Hey... do you ever wonder if {noun}s dream of {noun}s?","Okay but hear me out: what if the {adj} {noun} could actually {verb} backwards?","Can we talk about the {noun} that just {verb}ed and vanished?","So I was talking to a {noun}, and it told me to stop being {adj}. Rude.","Not to alarm you, but there’s a {adj} {noun} behind you doing the {verb}.","Why does this {noun} keep staring at me like I owe it pudding?","Is this a safe space to admit I accidentally {verb}ed a {noun}?","I just walked into the room and someone shouted “{adj} {noun}!” — what did I miss?","Wait... we were supposed to bring a {noun}? No one told me!","Okay but what if the {adj} {noun} has feelings too?","Be honest, do I look like a {noun} that forgot how to {verb}?",'If I say "oops", do I still have to explain why the {noun} is glowing?',"I don’t know what’s going on but I brought snacks and a confused {noun}.","Do you think pudding knows it’s pudding? Just a thought.","Is this about the time I {verb}ed the {adj} {noun} by accident? Because I can explain.","Wait, are we talking about {noun}s or am I on the wrong chat again?",'What is this group even about? I just saw "pudding" and joined.',"Hi! I have no idea what’s happening but I’m here and I brought a {noun}.","I blinked and now there’s a {adj} {noun} in charge of everything.","Can someone please explain why the {noun} is floating and chanting?","Okay who gave the {noun} access to glitter and emotional support pickles?","I came for a calm discussion and now there’s a {adj} battle between {noun}s.","Not sure if I’m early, late, or inside a {noun} dream.","I was gone for 3 minutes and now someone’s riding a {noun} into the pudding realm.","This isn’t the pudding appreciation group, is it? ...oh no.","So... who summoned the {adj} {noun} this time? Be honest.","I came here for vibes and stayed for the {noun}s.","Does anyone else hear faint giggling or is that just the {adj} {noun} again?","I feel like I missed step one, two, and also three of this conversation.","All I asked was “what’s up?” and now I’m emotionally attached to a {noun}.",'Me: "I’ll be normal today." Also me: *{verb}s into a meeting riding a {adj} {noun}*','"It’s just pudding," they said. "It can’t hurt you," they said. They were wrong.',"I said one nice thing to a {noun} and now it follows me everywhere.","Can we take a moment to appreciate how the {adj} {noun} is just vibing?","Who put a tiny hat on the {noun}? Because that’s adorable.","My life has been different ever since the {noun} started {verb}ing.","Raise your hand if you’ve ever been personally attacked by a {adj} {noun}.",'"Don’t be weird," they said. So I became a {noun} instead.',"Do {noun}s have feelings? Asking for a {adj} friend.","I trusted the {noun} and all I got was a glitter-covered sock.","Plot twist: the {adj} {noun} was inside us all along.","The {adj} {noun} {verb} and {verb} all over the {adj} {noun}!","Oops! {noun}s {verb}ed into the {adj} {noun} while {verb}ing crazily.","{adj}, {adj}, and more {adj} {noun}s just {verb}ed by!","Why does the {adj} {noun} keep {verb}ing and {verb}ing without stopping?","Look! A {adj} {noun}, a {adj} {noun}, and a {noun} all {verb}ing together!","Sometimes, the {noun} just {verb}s, then {verb}s again, and never stops being {adj}.","{noun}, {noun}, and {noun} — all {verb}ing and {verb}ing in a {adj} {noun}.","I saw a {adj} {noun} {verb}, then another {noun} {verb}ing with a {adj} {noun}.","The {noun} {verb}s {verb} while the {adj} {noun} {verb}s and the {noun} just {verb}s.","Can a {adj} {noun} {verb} {verb} without a {adj} {noun} watching?","Whoa! The {adj} {noun} just {verb}ed... and then {verb}ed again!","Hey... did you see that {adj} {noun} {verb} over there?","Umm, the {noun} is {verb}ing but also {verb}ing and {verb}ing!","Lol! {noun}s {verb} so {adj}ly, it’s impossible not to giggle.",'"Hey! What’s up?" asked the {adj} {noun}, who {verb}ed loudly.','"I’m just a {adj} {noun} trying to {verb}, you know?"','"Did you see the {adj} {noun} that just {verb}ed in the pudding?"','"No way! The {noun} {verb}s better than me!"','"Wait, the {adj} {noun} said it would {verb}, but it {verb}ed instead!"',"Once upon a {adj} {noun}, a group of {adj} {noun}s {verb}ed through the {adj} forest, singing {adj} songs and eating {noun}s made of pudding.","The legend tells of a {adj} {noun} who could {verb} faster than any {noun} ever seen, leaving trails of {adj} sparkles behind.","Every day, the {adj} {noun} would {verb} around the {adj} meadow, trying to convince the {noun}s to join the grand pudding party.","No one knows why the {adj} {noun} suddenly {verb}ed and then {verb}ed again, but everyone agrees it was the cutest thing they ever saw.","In the kingdom of {adj} {noun}s, only the bravest {noun} dared to {verb} the giant pudding monster, armed with nothing but {adj} smiles and jellybeans.","{adj} {noun} {verb} {verb} {verb} {noun} {verb} {adj} {noun} {verb} {noun}!","{noun} {noun} {verb} {adj} {noun} and then {verb} {verb} the {adj} {noun}.","{verb} the {adj} {noun}, then {verb} the {noun} while {verb}ing {adj}ly.","Can the {adj} {noun} {verb} and {verb} the {adj} {noun} at the same time?","{noun} {verb} {noun} {verb}, but the {adj} {noun} {verb}s better.","Boop! The {adj} {noun} just {verb}ed in the pudding.","Bloop bloop, the {noun} is {verb}ing all over again!","Mlem mlem, a {adj} {noun} {verb}s quietly in the corner.","Splat! {noun} {verb}ed right on the {adj} {noun}.","Yum! A {adj} {noun} just {verb}ed in my mouth.","Do {noun}s really {verb} when nobody’s watching?","Why does the {adj} {noun} always {verb} at midnight?","Can a {noun} be too {adj} to {verb} properly?","Is it normal for a {adj} {noun} to {verb} three times in a row?","Who taught the {noun} to {verb} like that?","Wait, did the {adj} {noun} just {verb} itself?","I can’t believe the {noun} {verb}ed into a {adj} {noun}!","Suddenly, a {adj} {noun} appeared and started to {verb} wildly.","That {noun} was {verb}ing so {adj}ly it broke the pudding meter.","Everyone’s talking about the {adj} {noun} that {verb}ed out of nowhere."];class Bt{static#mt=Rt;static#ft=jt;static#gt=Ot;static#yt=Pt;static#wt=$t;static#bt=Ht;static#vt(e,t){if(!Array.isArray(e))throw new TypeError(`${t} must be an array of strings`);if(!e.every(e=>"string"==typeof e))throw new TypeError(`${t} must contain only strings`);if(0===e.length)throw new Error(`${t} cannot be empty`)}static get defaultWords(){return[...this.#mt]}static set defaultWords(e){this.#vt(e,"defaultWords"),this.#mt=[...e]}static get defaultEmojis(){return[...this.#ft]}static set defaultEmojis(e){this.#vt(e,"defaultEmojis"),this.#ft=[...e]}static get defaultNouns(){return[...this.#gt]}static set defaultNouns(e){this.#vt(e,"defaultNouns"),this.#gt=[...e]}static get defaultVerbs(){return[...this.#yt]}static set defaultVerbs(e){this.#vt(e,"defaultVerbs"),this.#yt=[...e]}static get defaultAdjectives(){return[...this.#wt]}static set defaultAdjectives(e){this.#vt(e,"defaultAdjectives"),this.#wt=[...e]}static get defaultTemplates(){return[...this.#bt]}static set defaultTemplates(e){this.#vt(e,"defaultTemplates"),this.#bt=[...e]}config={minLength:10,maxLength:300,readable:!0,useEmojis:!0,includeNumbers:!0,includeSymbols:!0,allowWeirdSpacing:!1,emojiSet:[],wordSet:[],mode:"mixed",grammar:{templates:[],nouns:[],verbs:[],adjectives:[]},repeatWords:!0,emojiPlacement:"inline",line:{minLength:20,maxLength:120,emojiChance:.3}};constructor(e={}){this.symbols="!@#$%^&*()-_=+[]{}|;:,.<>?/\\~".split("");const{minLength:t,maxLength:r,readable:n,useEmojis:i,includeNumbers:s,includeSymbols:o,allowWeirdSpacing:a,emojiSet:l,wordSet:u,mode:c,grammar:h,repeatWords:d,emojiPlacement:p,paragraphs:m,line:f}=e;if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.minLength must be an integer >= 1");if(void 0!==r&&(!Number.isInteger(r)||r<1))throw new TypeError("config.maxLength must be an integer >= 1");if(void 0!==t&&void 0!==r&&t>r)throw new RangeError("config.minLength cannot be greater than config.maxLength");if(void 0!==n&&"boolean"!=typeof n)throw new TypeError("config.readable must be a boolean");if(void 0!==i&&"boolean"!=typeof i)throw new TypeError("config.useEmojis must be a boolean");if(void 0!==s&&"boolean"!=typeof s)throw new TypeError("config.includeNumbers must be a boolean");if(void 0!==o&&"boolean"!=typeof o)throw new TypeError("config.includeSymbols must be a boolean");if(void 0!==a&&"boolean"!=typeof a)throw new TypeError("config.allowWeirdSpacing must be a boolean");if(void 0!==l&&!Array.isArray(l))throw new TypeError("config.emojiSet must be an array of strings");if(void 0!==u&&!Array.isArray(u))throw new TypeError("config.wordSet must be an array of strings");if(void 0!==c&&!["mixed","readable","chaotic","natural"].includes(c))throw new RangeError('config.mode must be one of: "mixed", "readable", "chaotic", "natural');if(void 0!==h){if("object"!=typeof h||null===h)throw new TypeError("config.grammar must be an object");const{templates:e,nouns:t,verbs:r,adjectives:n}=h;if(void 0!==e&&!Array.isArray(e))throw new TypeError("config.grammar.templates must be an array of strings");if(void 0!==t&&!Array.isArray(t))throw new TypeError("config.grammar.nouns must be an array of strings");if(void 0!==r&&!Array.isArray(r))throw new TypeError("config.grammar.verbs must be an array of strings");if(void 0!==n&&!Array.isArray(n))throw new TypeError("config.grammar.adjectives must be an array of strings")}if(void 0!==d&&"boolean"!=typeof d)throw new TypeError("config.repeatWords must be a boolean");if(void 0!==p&&!["inline","end","none"].includes(p))throw new RangeError('config.emojiPlacement must be one of: "inline", "end", "none"');if(void 0!==m){if("object"!=typeof m)throw new TypeError("config.paragraphs must be an object or null");const{min:e,max:t}=m;if(void 0!==e&&(!Number.isInteger(e)||e<1))throw new TypeError("config.paragraphs.min must be an integer >= 1");if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.paragraphs.max must be an integer >= 1");if(void 0!==e&&void 0!==t&&e>t)throw new RangeError("config.paragraphs.min cannot be greater than config.paragraphs.max")}if(void 0!==f){if("object"!=typeof f||null===f)throw new TypeError("config.line must be an object");const{minLength:e,maxLength:t,emojiChance:r}=f;if(void 0!==e&&(!Number.isInteger(e)||e<1))throw new TypeError("config.line.minLength must be an integer >= 1");if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.line.maxLength must be an integer >= 1");if(void 0!==e&&void 0!==t&&e>t)throw new RangeError("config.line.minLength cannot be greater than config.line.maxLength");if(void 0!==r&&("number"!=typeof r||r<0||r>1))throw new RangeError("config.line.emojiChance must be a number between 0 and 1")}this.config.emojiSet=[...Bt.#ft],this.config.wordSet=[...Bt.#mt],this.config.grammar.templates=[...Bt.#bt],this.config.grammar.nouns=[...Bt.#gt],this.config.grammar.verbs=[...Bt.#yt],this.config.grammar.adjectives=[...Bt.#wt],Object.assign(this.config,e)}configure(e={}){return Object.assign(this.config,e),this}setGrammarTemplates(...e){return this.config.grammar.templates=e.flat(),this}addGrammarTemplates(...e){return this.config.grammar.templates.push(...e.flat()),this}setGrammarNouns(...e){return this.config.grammar.nouns=e.flat(),this}addGrammarNouns(...e){return this.config.grammar.nouns.push(...e.flat()),this}setGrammarVerbs(...e){return this.config.grammar.verbs=e.flat(),this}addGrammarVerbs(...e){return this.config.grammar.verbs.push(...e.flat()),this}setGrammarAdjectives(...e){return this.config.grammar.adjectives=e.flat(),this}addGrammarAdjectives(...e){return this.config.grammar.adjectives.push(...e.flat()),this}removeGrammarTemplates(...e){const t=new Set(e.flat());return this.config.grammar.templates=this.config.grammar.templates.filter(e=>!t.has(e)),this}removeGrammarNouns(...e){const t=new Set(e.flat());return this.config.grammar.nouns=this.config.grammar.nouns.filter(e=>!t.has(e)),this}removeGrammarVerbs(...e){const t=new Set(e.flat());return this.config.grammar.verbs=this.config.grammar.verbs.filter(e=>!t.has(e)),this}removeGrammarAdjectives(...e){const t=new Set(e.flat());return this.config.grammar.adjectives=this.config.grammar.adjectives.filter(e=>!t.has(e)),this}setWords(...e){return this.config.wordSet=e.flat(),this}addWords(...e){return this.config.wordSet.push(...e.flat()),this}removeWords(...e){const t=new Set(e.flat());return this.config.wordSet=this.config.wordSet.filter(e=>!t.has(e)),this}setEmojis(...e){return this.config.emojiSet=e.flat(),this}addEmojis(...e){return this.config.emojiSet.push(...e.flat()),this}removeEmojis(...e){const t=new Set(e.flat());return this.config.emojiSet=this.config.emojiSet.filter(e=>!t.has(e)),this}_getRandomItem(e){return e[Math.floor(Math.random()*e.length)]}_generateChunk(){const{wordSet:e,emojiSet:t,includeNumbers:r,includeSymbols:n,useEmojis:i,readable:s,mode:o,emojiPlacement:a}=this.config;if("natural"===o)return this._generateNaturalSentence();const l=[];return(s||"readable"===o||"mixed"===o)&&l.push(this._getRandomItem(e)),"chaotic"!==o&&"mixed"!==o||l.push(Math.random().toString(36).slice(2)),r&&l.push(Math.floor(99999*Math.random()).toString()),n&&l.push(this._getRandomItem(this.symbols)),"inline"===a&&i&&t.length&&l.push(this._getRandomItem(t)),this._getRandomItem(l)}_generateNaturalSentence(){const{templates:e,nouns:t,verbs:r,adjectives:n}=this.config.grammar;return this._getRandomItem(e).replace(/{noun}/g,()=>this._getRandomItem(t)).replace(/{verb}/g,()=>this._getRandomItem(r)).replace(/{adj}/g,()=>this._getRandomItem(n))}_generateLine(e,t){const{allowWeirdSpacing:r,repeatWords:n,readable:i,emojiSet:s,useEmojis:o,emojiPlacement:a,line:l}=this.config,u=[];for(t??=new Set;u.join(" ").length<e;){let e=this._generateChunk();!n&&t.has(e)||(t.add(e),r&&(Math.random()<.1&&(e="\n"+e),Math.random()<.1&&(e=" "+e),Math.random()<.05&&(e=e.toUpperCase())),u.push(e))}let c=u.join(i?" ":"");return"end"===a&&o&&s.length&&Math.random()<(l?.emojiChance||0)&&(c+=" "+this._getRandomItem(s)),c}_generateParagraphLines(e){const{line:t}=this.config,r=[],n=new Set;let i=0;for(;i<e;){const s=Math.floor(Math.random()*(t.maxLength-t.minLength+1)+t.minLength),o=Math.min(s,e-i);r.push(this._generateLine(o,n)),i+=o}return r}generate(){const{minLength:e,maxLength:t,paragraphs:r}=this.config,n=Math.floor(Math.random()*(t-e+1))+e;if(r&&"object"==typeof r){const e=Math.floor(Math.random()*(r.max-r.min+1))+r.min,t=Math.floor(n/e),i=[];for(let r=0;r<e;r++){const e=this._generateParagraphLines(t);i.push(e.join("\n"))}return i.join("\n\n")}return this._generateParagraphLines(n).join("\n")}}const Ft=Bt,zt=class{#Et=new Map;#Tt=10;#St=!1;#xt(e,t){if("string"==typeof e)return[e];if(Array.isArray(e)&&e.every(e=>"string"==typeof e))return e;throw new TypeError(`${t}(event): event must be a string or string[]`)}setThrowOnMaxListeners(e){if("boolean"!=typeof e)throw new TypeError("setThrowOnMaxListeners(value): value must be a boolean");this.#St=e}getThrowOnMaxListeners(){return this.#St}#At(e,t,{once:r=!1}={}){let n=this.#Et.get(e);Array.isArray(n)||(n=[],this.#Et.set(e,n)),n.unshift({handler:t,config:{once:r}});const i=this.#Tt;if(i>0&&n.length>i){const t=`Possible memory leak detected. ${n.length} "${e}" listeners added. Use setMaxListeners() to increase limit.`;if(this.#St)throw new Error(t);console.warn(t)}}prependListener(e,t){const r=this.#xt(e,"prependListener");if("function"!=typeof t)throw new TypeError("prependListener(event, handler): handler must be a function");for(const e of r)this.#At(e,t)}prependListenerOnce(e,t){const r=this.#xt(e,"prependListenerOnce");if("function"!=typeof t)throw new TypeError("prependListenerOnce(event, handler): handler must be a function");const n=[];for(const e of r){const r=(...n)=>{this.off(e,r),t(...n)};this.#At(e,r,{once:!0}),n.push(r)}return n}#Ct(e,t,{once:r=!1}={}){const n=this.#xt(e,"on");for(const e of n){let n=this.#Et.get(e);Array.isArray(n)||(n=[],this.#Et.set(e,n)),n.push({handler:t,config:{once:r}});const i=this.#Tt;if(i>0&&n.length>i){const t=`Possible memory leak detected. ${n.length} "${e}" listeners added. Use setMaxListeners() to increase limit.`;if(this.#St)throw new Error(t);console.warn(t)}}}on(e,t){if("function"!=typeof t)throw new TypeError("on(event, handler): handler must be a function");return this.#Ct(e,t)}once(e,t){const r=this.#xt(e,"once");if("function"!=typeof t)throw new TypeError("once(event, handler): handler must be a function");const n=[];for(const e of r){const r=(...n)=>{this.off(e,r),t(...n)};this.#Ct(e,r,{once:!0}),n.push(r)}return n}appendListener(e,t){return this.on(e,t)}appendListenerOnce(e,t){return this.once(e,t)}off(e,t){const r=this.#xt(e,"off");if("function"!=typeof t)throw new TypeError("off(event, handler): handler must be a function");for(const e of r){const r=this.#Et.get(e);if(!Array.isArray(r))continue;const n=r.findIndex(e=>e.handler===t);-1!==n&&r.splice(n,1),0===r.length&&this.#Et.delete(e)}}offAll(e){const t=this.#xt(e,"offAll");for(const e of t)this.#Et.delete(e)}offAllTypes(){this.#Et.clear()}removeAllListeners(){return this.offAllTypes()}listenerCount(e){if("string"!=typeof e)throw new TypeError("listenerCount(event): event name must be a string");const t=this.#Et.get(e);return Array.isArray(t)?t.length:0}listeners(e){if("string"!=typeof e)throw new TypeError("listeners(event): event name must be a string");const t=this.#Et.get(e);return Array.isArray(t)?[...t].filter(e=>!e.config.once).map(e=>e.handler):[]}onceListeners(e){if("string"!=typeof e)throw new TypeError("onceListeners(event): event name must be a string");const t=this.#Et.get(e);return Array.isArray(t)?[...t].filter(e=>e.config.once).map(e=>e.handler):[]}allListeners(e){if("string"!=typeof e)throw new TypeError("allListeners(event): event name must be a string");const t=this.#Et.get(e);return Array.isArray(t)?[...t].map(e=>e.handler):[]}eventNames(){return[...this.#Et.keys()]}emit(e,...t){const r=this.#xt(e,"emit"),n=[];for(const e of r){const r=this.#Et.get(e);Array.isArray(r)&&0!==r.length?(r.forEach(e=>e.handler(...t)),n.push(!0)):n.push(!1)}return n}setMaxListeners(e){if(!Number.isInteger(e)||e<0)throw new TypeError("setMaxListeners(n): n must be a non-negative integer");this.#Tt=e}getMaxListeners(){return this.#Tt}};class Wt{static Utils={...t,TinyHtml:yt};#It=new zt;setThrowOnMaxListeners(e){return this.#It.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#It.getThrowOnMaxListeners()}prependListener(e,t){return this.#It.prependListener(e,t)}prependListenerOnce(e,t){return this.#It.prependListenerOnce(e,t)}appendListener(e,t){return this.#It.appendListener(e,t)}appendListenerOnce(e,t){return this.#It.appendListenerOnce(e,t)}on(e,t){return this.#It.on(e,t)}once(e,t){return this.#It.once(e,t)}off(e,t){return this.#It.off(e,t)}offAll(e){return this.#It.offAll(e)}offAllTypes(){return this.#It.offAllTypes()}listenerCount(e){return this.#It.listenerCount(e)}listeners(e){return this.#It.listeners(e)}onceListeners(e){return this.#It.onceListeners(e)}allListeners(e){return this.#It.allListeners(e)}eventNames(){return this.#It.eventNames()}emit(e,...t){return this.#It.emit(e,...t)}setMaxListeners(e){return this.#It.setMaxListeners(e)}getMaxListeners(){return this.#It.getMaxListeners()}#Mt=new WeakMap;#kt=new WeakMap;#Lt=new WeakMap;#Nt=new WeakMap;#Dt=new WeakMap;#_t=new WeakMap;#Rt=null;#jt=null;#Ot=new Set(["IMG","IFRAME","VIDEO"]);#Pt=null;#$t=!1;#Ht=!1;#Bt=!1;#Ft=!1;#zt=!1;#Wt=!1;#qt=!1;#Vt=!1;#Ut="";#Kt=!1;#ge=!1;#Jt=!1;#Gt=!1;#Yt=!1;#Xt=!1;#Qt=0;#Zt=0;#er=0;#tr=0;#rr=0;#nr;#ir;#H;#sr=new Set;constructor(e,{extraScrollBoundary:t=0,autoScrollBottom:r=!0,observeMutations:n=!0,preserveScrollOnLayoutShift:i=!0,debounceTime:s=100,querySelector:o=null,attributeFilter:a=["class","style","src","data-*","height","width"]}={}){if(!(e instanceof Element||e===window))throw new TypeError("TinySmartScroller: 'target' must be a DOM Element or 'window', but got "+typeof e);if("number"!=typeof t||Number.isNaN(t))throw new TypeError(`TinySmartScroller: 'extraScrollBoundary' must be a valid number, received ${t}`);if("boolean"!=typeof r)throw new TypeError("TinySmartScroller: 'autoScrollBottom' must be a boolean, received "+typeof r);if("boolean"!=typeof n)throw new TypeError("TinySmartScroller: 'observeMutations' must be a boolean, received "+typeof n);if("boolean"!=typeof i)throw new TypeError("TinySmartScroller: 'preserveScrollOnLayoutShift' must be a boolean, received "+typeof i);if("number"!=typeof s||s<0||Number.isNaN(s))throw new TypeError(`TinySmartScroller: 'debounceTime' must be a non-negative number, received ${s}`);if(null!==o&&"string"!=typeof o)throw new TypeError("TinySmartScroller: 'querySelector' must be a string or null, received "+typeof o);if(!(null===a||Array.isArray(a)||a instanceof Set))throw new TypeError("TinySmartScroller: 'attributeFilter' must be an array, Set, or null. Got "+typeof a);let l;this.#H=e,this.#ir=e instanceof Window?document.documentElement:e,this.#Kt=e instanceof Window,this.#Gt=r,this.#Yt=n,this.#Xt=i,this.#Qt=s,this.#rr=t,this.#Ut=o||"",this.#nr=new Set(a||void 0),this.#Pt=()=>{this._scrollDataUpdater(),clearTimeout(l),l=setTimeout(()=>this._onScroll(),this.#Qt)},(this.#Kt?window:this.#ir).addEventListener("scroll",this.#Pt,{passive:!0}),this.#Yt&&(this._observeMutations(),this._observeResizes(this.#ir.children)),this._scrollDataUpdater()}getSimpleOnHeight(e=[]){if(!Array.isArray(e))throw new TypeError("getSimpleOnHeight(filter): filter must be an array of tag names");return(t,r,n)=>{if(e.length>0&&!e.includes(t.tagName)||n.now!==n.old)return;const i=r.old;return{height:r.now.height-i.height,width:0}}}addSimpleOnHeight(e){if(!Array.isArray(e))throw new TypeError("addSimpleOnHeight(filter): filter must be an array of tag names");const t=this.getSimpleOnHeight(e);return this.onSize(t),t}getLoadTags(){return Array.from(this.#Ot)}addLoadTag(e){if("string"!=typeof e)throw new TypeError("addLoadTag(tag): tag must be a string");this.#Ot.add(e.toUpperCase())}removeLoadTag(e){if("string"!=typeof e)throw new TypeError("removeLoadTag(tag): tag must be a string");this.#Ot.delete(e.toUpperCase())}hasLoadTag(e){if("string"!=typeof e)throw new TypeError("hasLoadTag(tag): tag must be a string");return this.#Ot.has(e.toUpperCase())}resetLoadTags(e=!1){if("boolean"!=typeof e)throw new TypeError("resetLoadTags(addDefault): addDefault must be a boolean");this.#Ot.clear(),e&&(this.#Ot.add("IMG"),this.#Ot.add("IFRAME"),this.#Ot.add("VIDEO"))}getAttributeFilters(){return Array.from(this.#nr)}addAttributeFilter(e){if("string"!=typeof e)throw new TypeError("addAttributeFilter(attr): attr must be a string");this.#nr.add(e)}removeAttributeFilter(e){if("string"!=typeof e)throw new TypeError("removeAttributeFilter(attr): attr must be a string");this.#nr.delete(e)}hasAttributeFilter(e){if("string"!=typeof e)throw new TypeError("hasAttributeFilter(attr): attr must be a string");return this.#nr.has(e)}resetAttributeFilters(e=!1){if("boolean"!=typeof e)throw new TypeError("resetAttributeFilters(addDefault): addDefault must be a boolean");this.#nr.clear(),e&&["class","style","src","data-*","height","width"].forEach(e=>this.#nr.add(e))}onSize(e){if(!this.#ge){if("function"!=typeof e)throw new TypeError("onSize(handler): handler must be a function");this.#sr.add(e)}}offSize(e){if(!this.#ge){if("function"!=typeof e)throw new TypeError("offSize(handler): handler must be a function");this.#sr.delete(e)}}_scrollDataUpdater(){const e=new Map;return this.#ir.querySelectorAll(this.#Ut||"*").forEach(t=>{const r=this.#Lt.get(t)??!1;this.#Nt.set(t,r);const n=yt.isInContainer(this.#ir,t);this.#Lt.set(t,n),e.set(t,{oldIsVisible:r,isVisible:n})}),e}_onScroll(){if(this.#ge)return;const e=this._scrollDataUpdater(),t=this.#ir,r=t.scrollTop,n=t.scrollHeight,i=t.clientHeight,s={scrollTop:r,scrollHeight:n,clientHeight:i};let o=null,a=null;const l=0===r,u=r+i>=n-1,c=r<=0+this.#rr,h=r+i>=n-1-this.#rr;l&&u?o="all":l?o="top":u&&(o="bottom"),c&&h?a="all":c?a="top":h&&(a="bottom"),this.#Ht=this.#Wt??!1,this.#$t=this.#zt??!1,this.#Bt=this.#qt??!1,this.#Ft=this.#Vt??!1,this.#Wt=l,this.#zt=u,this.#qt=c,this.#Vt=h,this.#Jt=!(this.#Gt&&this.#zt),this.#tr=n-r-i,this.emit("onScrollBoundary",{status:o,...s,scrollCache:e}),this.emit("onExtraScrollBoundary",{status:a,...s,scrollCache:e}),this.#Jt?this.emit("onScrollPause",{...s,scrollCache:e}):this.emit("onAutoScroll",{...s,scrollCache:e})}_fixScroll(e=[]){if(this.#ge)return;if(!Array.isArray(e))throw new TypeError("_fixScroll: targets must be an array of Elements");const t=this.#ir.scrollHeight,r=this.#ir.scrollTop,n=this.#ir.scrollHeight-this.#ir.scrollTop-this.#ir.clientHeight,i=this.#ir.scrollHeight-t,s=()=>{const t={height:0,width:0};for(const r of e){const e=this.#Mt.get(r)||{height:0,width:0},n=this.#kt.get(r)||{height:0,width:0};this.#sr.forEach(i=>{const s=i(r,{old:e,now:n},{old:this.#er,now:this.#Zt});if(this.#Lt.get(r)||this.#Dt.get(r)){if(void 0!==s&&"object"!=typeof s)throw new Error("_fixScroll: size filter must return an object or undefined");if(void 0===s)return;t.height=s.height,t.width=s.width}})}if("number"!=typeof t.height&&t.height<0)throw new Error("_fixScroll: invalid scrollSize.height value");if("number"!=typeof t.width&&t.width<0)throw new Error("_fixScroll: invalid scrollSize.width value");if(0!==t.height||0!==t.width)for(const t of e)this.#Dt.set(t,this.#Lt.get(t)??!1),this.#_t.set(t,this.#Nt.get(t)??!1);return t};if(this.#er>0&&yt.hasScroll(this.#ir).v&&this.#Gt&&this.#Xt&&!this.#zt&&!this.#Wt){const e=s();this.#ir.scrollTop=r+i+e.height,e.width>0&&(this.#ir.scrollLeft=this.#ir.scrollLeft+e.width)}else!this.#Jt&&this.#Gt?(s(),this.scrollToBottom()):this.#Gt||this.#zt||(s(),this.#ir.scrollTop=this.#ir.scrollHeight-this.#ir.clientHeight-n)}_observeMutations(){this.#jt=new MutationObserver(e=>{this.#ge||(this._scrollDataUpdater(),this.#er=this.#Zt,this.#Zt=this.#ir.childElementCount,e.forEach(e=>{e.addedNodes.forEach(e=>{if(e instanceof Element&&1===e.nodeType&&(this._observeResizes([e]),this._listenLoadEvents(e),this.#Ut)){const t=e.querySelectorAll(this.#Ut);this._observeResizes(t),this._listenLoadEvents(t)}})}),this._fixScroll())}),this.#jt.observe(this.#ir,{childList:!0,subtree:!0,attributes:!0,attributeFilter:this.#nr.size>0?Array.from(this.#nr):void 0})}_observeResizes(e){this.#Rt||(this.#Rt=new ResizeObserver(e=>{if(this.#ge)return;this._scrollDataUpdater();const t=[];for(const r of e){const e=r.target,n=this.#kt.get(e);n&&this.#Mt.set(e,n);const{width:i,height:s}=r.contentRect;this.#kt.set(e,{width:i,height:s}),t.push(e)}this._fixScroll(t)})),Array.from(e).forEach(e=>{if(!this.#Rt)throw new Error("_observeResizes: ResizeObserver instance is not initialized");this.#Rt.observe(e)})}_listenLoadEvents(e){this.#ge||(e instanceof NodeList?Array.from(e):[e]).forEach(e=>{this.#Ot.has(e.tagName)&&(e.complete||e.addEventListener("load",()=>{this._scrollDataUpdater(),!this.#Jt&&this.#Gt&&this.scrollToBottom()}))})}get target(){return this.#H}get targetElement(){return this.#ir}getOldSize(e){return this.#Mt.get(e)??null}getNewSize(e){return this.#kt.get(e)??null}wasVisible(e){return this.#Nt.get(e)??!1}isVisible(e){return this.#Lt.get(e)??!1}wasTimedVisible(e){return this.#_t.get(e)??!1}isTimedVisible(e){return this.#Dt.get(e)??!1}setExtraScrollBoundary(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("setExtraScrollBoundary(value): value must be a valid number");this.#rr=e}getExtraScrollBoundary(){return this.#rr}getLastKnownScrollBottomOffset(){return this.#tr}scrollToBottom(){this.#ir.scrollTop=this.#ir.scrollHeight}scrollToTop(){this.#ir.scrollTop=0}isAtCustomBottom(){return this.#Vt}isAtCustomTop(){return this.#qt}isAtBottom(){return this.#zt}isAtTop(){return this.#Wt}isPastAtBottom(){return this.#$t}isPastAtTop(){return this.#Ht}isPastAtCustomTop(){return this.#Bt}isPastAtCustomBottom(){return this.#Ft}isScrollPaused(){return this.#Jt}isWindow(){return this.#Kt}isDestroyed(){return this.#ge}getAutoScrollBottom(){return this.#Gt}getObserveMutations(){return this.#Yt}getPreserveScrollOnLayoutShift(){return this.#Xt}getDebounceTime(){return this.#Qt}getElemAmount(){return this.#Zt}getPrevElemAmount(){return this.#er}getQuerySelector(){return this.#Ut}destroy(){if(this.#ge)return;this.#ge=!0,this.#jt&&(this.#jt.disconnect(),this.#jt=null),this.#Rt&&(this.#Rt.disconnect(),this.#Rt=null);const e=this.#Kt?window:this.#ir;this.#Pt&&e.removeEventListener("scroll",this.#Pt),this.#Mt=new WeakMap,this.#kt=new WeakMap,this.#Lt=new WeakMap,this.#Nt=new WeakMap,this.#Dt=new WeakMap,this.#_t=new WeakMap,this.#It.offAllTypes(),this.#sr.clear(),this.#Ot.clear()}}const qt=Wt,Vt=class{#J;#or;#ar;constructor(e,{openTag:t="[",closeTag:r="]"}={}){if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new TypeError("Element must be an input or textarea.");if("string"!=typeof t)throw new TypeError("openTag must be a string.");if("string"!=typeof r)throw new TypeError("closeTag must be a string.");this.#J=e,this.#or=t,this.#ar=r}getOpenTag(){return this.#or}getCloseTag(){return this.#ar}setOpenTag(e){if("string"!=typeof e)throw new TypeError("Open tag must be a string.");this.#or=e}setCloseTag(e){if("string"!=typeof e)throw new TypeError("Close tag must be a string.");this.#ar=e}ensureFocus(){return document.activeElement!==this.#J&&this.#J.focus(),this}focus(){return this.#J.focus(),this}getSelectionRange(){return{start:this.#J.selectionStart??NaN,end:this.#J.selectionEnd??NaN}}setSelectionRange(e,t,r=!0){if("number"!=typeof e||"number"!=typeof t)throw new TypeError("start and end must be numbers.");if("boolean"!=typeof r)throw new TypeError("preserveScroll must be a boolean.");const n=this.#J.scrollTop,i=this.#J.scrollLeft;return this.#J.setSelectionRange(e,t),r&&(this.#J.scrollTop=n,this.#J.scrollLeft=i),this}getValue(){return this.#J.value}setValue(e){if("string"!=typeof e)throw new TypeError("Value must be a string.");return this.#J.value=e,this}getSelectedText(){const{start:e,end:t}=this.getSelectionRange();return this.#J.value.slice(e,t)}insertText(e,{newCursor:t="end",autoSpacing:r=!1,autoSpaceLeft:n=r,autoSpaceRight:i=r}={}){if("string"!=typeof e)throw new TypeError("Text must be a string.");if(!["start","end","preserve"].includes(t))throw new TypeError("newCursor must be one of 'start', 'end', or 'preserve'.");if("boolean"!=typeof r)throw new TypeError("autoSpacing must be a boolean.");if("boolean"!=typeof n)throw new TypeError("autoSpaceLeft must be a boolean.");if("boolean"!=typeof i)throw new TypeError("autoSpaceRight must be a boolean.");const{start:s,end:o}=this.getSelectionRange(),a=this.#J.value,l=a[s-1]||"",u=a[o]||"",c=`${n&&l&&!/\s/.test(l)?" ":""}${e}${i&&u&&!/\s/.test(u)?" ":""}`,h=a.slice(0,s)+c+a.slice(o);this.setValue(h);let d=s;return"end"===t?d=s+c.length:"preserve"===t&&(d=s),this.setSelectionRange(d,d),this}deleteSelection(){return this.insertText(""),this}transformSelection(e){if("function"!=typeof e)throw new TypeError("transformer must be a function.");const{start:t}=this.getSelectionRange(),r=e(this.getSelectedText());return this.insertText(r),this.setSelectionRange(t,t+r.length),this}surroundSelection(e,t){if("string"!=typeof e||"string"!=typeof t)throw new TypeError("prefix and suffix must be strings.");const r=this.getSelectedText();return this.insertText(`${e}${r}${t}`),this}moveCaret(e){if("number"!=typeof e)throw new TypeError("offset must be a number.");const{start:t}=this.getSelectionRange(),r=Math.max(0,t+e);return this.setSelectionRange(r,r),this}selectAll(){return this.setSelectionRange(0,this.#J.value.length),this}expandSelection(e,t){if("number"!=typeof e||"number"!=typeof t)throw new TypeError("before and after must be numbers.");const{start:r,end:n}=this.getSelectionRange(),i=Math.max(0,r-e),s=Math.min(this.#J.value.length,n+t);return this.setSelectionRange(i,s),this}replaceAll(e,t){if(!(e instanceof RegExp))throw new TypeError("regex must be a RegExp.");if("function"!=typeof t)throw new TypeError("replacer must be a function.");const r=this.#J.value.replace(e,t);return this.setValue(r),this}replaceInSelection(e,t){if(!(e instanceof RegExp))throw new TypeError("regex must be a RegExp.");if("function"!=typeof t)throw new TypeError("replacer must be a function.");const{start:r,end:n}=this.getSelectionRange(),i=this.#J.value,s=i.slice(r,n).replace(e,t),o=i.slice(0,r)+s+i.slice(n);return this.setValue(o),this.setSelectionRange(r,r+s.length),this}toggleCode(e){if("string"!=typeof e)throw new TypeError("codeName must be a string.");const t=this.getSelectedText();if(t.startsWith(e)&&t.endsWith(e)){const r=t.slice(e.length,t.length-e.length);this.insertText(r)}else this.insertText(`${e}${t}${e}`);return this}_insertAttr(e){let t="";if(Array.isArray(e)){if(!e.every(e=>"string"==typeof e))throw new TypeError("All entries in attributes array must be strings.");t=e.map(e=>`${e}`).join(" ")}else{if("object"!=typeof e||null===e)throw new TypeError("attributes must be an object or an array of strings.");t=Object.entries(e).map(([e,t])=>{if("string"!=typeof t)throw new TypeError("All entries in attributes object must be strings.");return`${e}${t.length>0?`="${t}"`:""}`}).join(" ")}return t}wrapWithTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this._insertAttr(t),n=r?`${this.#or}${e} ${r}${this.#ar}`:`${this.#or}${e}${this.#ar}`,i=`${this.#or}/${e}${this.#ar}`;return this.surroundSelection(n,i),this}insertTag(e,t="",r={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");if("string"!=typeof t)throw new TypeError("content must be a string.");const n=this._insertAttr(r),i=n?`${this.#or}${e} ${n}${this.#ar}`:`${this.#or}${e}${this.#ar}`,s=`${this.#or}/${e}${this.#ar}`;return this.insertText(`${i}${t}${s}`),this}insertSelfClosingTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this._insertAttr(t),n=r?`${this.#or}${e} ${r}${this.#ar}`:`${this.#or}${e}${this.#ar}`;return this.insertText(n),this}toggleTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this.getSelectedText(),n=new RegExp(`^\\[${e}(\\s+[^\\]]*)?\\]`),i=new RegExp(`\\[/${e}\\]$`),s=n.test(r),o=i.test(r);if(s&&o){const e=r.replace(n,"").replace(i,"");this.insertText(e)}else{const n=this._insertAttr(t),i=n?`${this.#or}${e} ${n}${this.#ar}`:`${this.#or}${e}${this.#ar}`,s=`${this.#or}/${e}${this.#ar}`;this.insertText(`${i}${r}${s}`)}return this}},Ut=class{#lr=!1;#ur=!1;#cr=null;#hr=null;constructor(){void 0!==navigator.clipboard&&null!==navigator.clipboard&&(this.#ur=!0,this.#cr=e=>navigator.clipboard.writeText(e),this.#hr=e=>navigator.clipboard.write([new ClipboardItem({[e.type]:e})])),this.#lr=void 0!==document.execCommand&&null!==document.execCommand}setCopyText(e){if("function"!=typeof e)throw new TypeError("setCopyText expected a function that returns Promise<void>.");this.#cr=e}setCopyBlob(e){if("function"!=typeof e)throw new TypeError("setCopyBlob expected a function that returns Promise<void>.");this.#hr=e}copyText(e){if("string"!=typeof e)throw new TypeError("copyText expected a string.");if(this.#cr)return this.#cr(e);if(this.#lr){const t=document.body,r=document.createElement("input");return r.style.position="fixed",r.style.opacity="0",r.value=e,t.append(r),r.select(),r.setSelectionRange(0,99999),document.execCommand("Copy"),r.remove(),new Promise(e=>e(void 0))}throw new Error("Clipboard API not found!")}copyBlob(e){if(!(e instanceof Blob))throw new TypeError("copyBlob expected a Blob instance.");return new Promise((t,r)=>{if(this.#hr)return this.#hr(e).then(t).catch(r);throw new Error("Clipboard API not found!")})}_handleBlob(e,t){return t.getType(e)}_handleText(e,t){return this._handleBlob(e,t).then(e=>e.text())}_readData(e=0,t=null,r=null,n=!1){return new Promise((i,s)=>{this._read(e).then(o=>{if(!o)return i(null);const a=[];let l=!0;const u=async(e,i)=>{if(l)if(null!==t&&"custom"!==t||"string"!=typeof r||!(!n&&e.startsWith(r)||n&&e===r))if(null!==t&&"text"!==t||"text/plain"!==e){if(null===t){l=!1;const t=await this._handleBlob(e,i);t&&a.push(t)}}else{l=!1;const t=await this._handleText(e,i);t&&a.push(t)}else{l=!1;const t=await this._handleBlob(e,i);t&&a.push(t)}},c=[],h=e=>{if(!(e instanceof ClipboardItem))throw new Error("Expected ClipboardItem when reading data.");for(const t in e.types)c.push(u(e.types[t],e))};if("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)&&e>-1)h(o),Promise.all(c).then(()=>{a[0]?i(a[0]):i(null)}).catch(s);else if(Array.isArray(o)){for(const e in o)h(o[e]);Promise.all(c).then(()=>i(a)).catch(s)}}).catch(s)})}async readText(e=0){const t=await this._readData(e,"text");if("string"!=typeof t)throw new Error("Failed to read text: expected string result.");return t}async readCustom(e=null,t=!1,r=0){const n=await this._readData(r,"custom",e,t);if(!(n instanceof Blob))throw new Error("Failed to read custom data: expected Blob.");return n}async readAllTexts(){const e=await this._readData(null,"text");if(!Array.isArray(e))throw new Error("Expected array of strings when reading all texts.");if(!e.every(e=>"string"==typeof e))throw new Error("Some values returned were not strings.");return e}async readAllCustom(e=null,t=!1){const r=await this._readData(null,"custom",e,t);if(!Array.isArray(r))throw new Error("Expected array of blobs when reading all custom items.");if(!r.every(e=>e instanceof Blob))throw new Error("Some values returned were not Blob instances.");return r}async readAllData(e=null,t=null){const r=await this._readData(null,e,t);if(!Array.isArray(r))throw new Error("Expected array result when reading all data.");return r}_read(e){return new Promise((t,r)=>{this.#ur||r(new Error("Clipboard API not found!")),navigator.clipboard.read().then(r=>{if("number"==typeof e){if(Number.isNaN(e)||!Number.isFinite(e)||e<0)throw new Error(`Invalid index value: ${e}`);r[e]?t(r[e]):t(null)}t(r)}).catch(r)})}async readIndex(e){const t=await this._read(e);if(null!==t&&!(t instanceof ClipboardItem))throw new Error(`Value at index ${e} is not a ClipboardItem.`);return t}async readAll(){const e=await this._read(null);if(!Array.isArray(e))throw new Error("Expected array result from clipboard read.");for(const t of e)if(!(t instanceof ClipboardItem))throw new Error("Invalid item type found in clipboard result.");return e}isExecCommandAvailable(){return this.#lr}isNavigatorClipboardAvailable(){return this.#ur}getCopyTextFunc(){return this.#cr}getCopyBlobFunc(){return this.#hr}};class Kt{static _rca(e,t,r){let n=127,i=128;void 0===e&&(e=24),void 0===t&&(t="rgb"),!0===r&&(n=55,i=200);const s=2*Math.PI/e,o=[];for(let r=0;r<e;++r){const e=Math.sin(s*r+2)*n+i,a=Math.sin(s*r+0)*n+i,l=Math.sin(s*r+4)*n+i;switch(t){case"hex":o.push({hex:this.rgbToHex(Math.round(e),Math.round(a),Math.round(l))});break;case"rgb":o.push({r:e,g:a,b:l});break;case"hsl":const[t,r,n]=this.rgbaToHsl(Math.round(e),Math.round(a),Math.round(l));o.push({h:t,s:r,l:n})}}return o}static rcaRgb(e,t){return Kt._rca(e,"rgb",t)}static rcaHsl(e,t){return Kt._rca(e,"hsl",t)}static rcaHex(e,t){return Kt._rca(e,"hex",t)}static randomColor(){return`#${Math.floor(16777216*Math.random()).toString(16).padStart(6,"0")}`}static parseInput(e,t){if("string"==typeof e){if((e=e.trim().toLowerCase()).startsWith("#"))return this.hexToRgba(e);if(e.startsWith("rgb"))return this.rgbStringToRgbaArray(e);if(e.startsWith("hsl"))return this.hslStringToRgbaArray(e)}if("number"==typeof e)return this.intToRgba(e);if(Array.isArray(e)&&(3===e.length||4===e.length)&&e.every(e=>"number"==typeof e)){if(t){const[t,r,n,i]=e;if(t<=360&&r<=100&&n<=100)return this.hslToRgba(t,r,n,i)}return[...e,1].slice(0,4)}throw new Error("Unsupported color format.")}static hslToInt(e,t,r){const[n,i,s]=Kt.hslToRgba(e,t,r);return Kt.rgbToInt(n,i,s)}static hslToHex(e,t,r){const[n,i,s]=Kt.hslToRgba(e,t,r);return Kt.rgbToHex(n,i,s)}static hslStringToRgbaArray(e){const t=e.match(/[\d.]+/g)?.map(Number);if(!t||t.length<3)return[0,0,0,1];const[r,n,i,s=1]=t;return this.hslToRgba(r,n,i,s)}static hslToRgba(e,t,r,n=1){r/=100;const i=t=>(t+e/30)%12,s=(t/=100)*Math.min(r,1-r),o=e=>r-s*Math.max(-1,Math.min(i(e)-3,Math.min(9-i(e),1)));return[Math.round(255*o(0)),Math.round(255*o(8)),Math.round(255*o(4)),n]}static hslToRgb(e,t,r,n=1){return Kt.hslToRgba(e,t,r,n).slice(0,3)}static hexToInt(e){return parseInt(e.replace(/^#/,""),16)}static hexToHsl(e){const[t,r,n,i]=Kt.hexToRgba(e);return Kt.rgbaToHsl(t,r,n,i)}static hexToHsla(e){const[t,r,n,i]=Kt.hexToRgba(e);return Kt.rgbaToHsla(t,r,n,i)}static hexToRgba(e){3===(e=e.replace(/^#/,"")).length&&(e=e.split("").map(e=>e+e).join(""));const t=parseInt(e,16);return[t>>16&255,t>>8&255,255&t,1]}static hexToRgb(e){return this.hexToRgba(e).slice(0,3)}static rgbToHex(e,t,r){return"#"+[e,t,r].map(e=>e.toString(16).padStart(2,"0")).join("")}static rgbToInt(e,t,r){return e<<16|t<<8|r}static rgbaToHsla(e,t,r,n=1){e/=255,t/=255,r/=255;const i=Math.max(e,t,r),s=Math.min(e,t,r);let o=0,a=0,l=(i+s)/2;const u=i-s;if(0!==u){switch(a=u/(1-Math.abs(2*l-1)),i){case e:o=(t-r)/u+(t<r?6:0);break;case t:o=(r-e)/u+2;break;case r:o=(e-t)/u+4}o*=60}return[Math.round(o),Math.round(100*a),Math.round(100*l),n]}static rgbaToHsl(e,t,r,n){return this.rgbaToHsla(e,t,r,n).slice(0,3)}static rgbStringToRgbaArray(e){const t=e.match(/[\d.]+/g)?.map(Number);return t?[...t,1].slice(0,4):[]}static intToHsl(e){const[t,r,n,i]=Kt.intToRgba(e);return Kt.rgbaToHsl(t,r,n,i)}static intToHsla(e){const[t,r,n,i]=Kt.intToRgba(e);return Kt.rgbaToHsla(t,r,n,i)}static intToHex(e){return"#"+e.toString(16).padStart(6,"0")}static intToRgba(e){return[e>>16&255,e>>8&255,255&e,1]}#dr="#000000";#pr=[0,0,0,0];#mr;constructor(e=null,t=!1){this.#mr=t,null!=e&&this.setColor(e)}setColor(e){this.#dr=e;const t=this.#mr&&Array.isArray(e)&&e[0]<=360&&e[1]<=100&&e[2]<=100;this.#pr=Kt.parseInput(e,t)}toHslaArray(){const[e,t,r,n]=this.#pr;return Kt.rgbaToHsla(e,t,r,n)}toHslString(){const[e,t,r]=this.#pr,[n,i,s]=Kt.rgbaToHsl(e,t,r);return`hsl(${n}, ${i}%, ${s}%)`}toHslaString(){const[e,t,r,n]=this.#pr,[i,s,o,a]=Kt.rgbaToHsla(e,t,r,n);return`hsla(${i}, ${s}%, ${o}%, ${a??1})`}toRgbaArray(){return[...this.#pr]}toRgbString(){const[e,t,r]=this.#pr;return`rgb(${e}, ${t}, ${r})`}toRgbaString(){const[e,t,r,n]=this.#pr;return`rgba(${e}, ${t}, ${r}, ${n??1})`}toHex(){const[e,t,r]=this.#pr;return Kt.rgbToHex(e,t,r)}toInt(){const[e,t,r]=this.#pr;return Kt.rgbToInt(e,t,r)}getOriginal(){return this.#dr}}const Jt=Kt;class Gt{#fr=!1;#gr;#yr;#wr=null;#br=new Map;constructor({cooldownWatcherTime:e=5e3,allowAutoConfigChange:t=!1}={}){if(!Number.isFinite(e)||e<=0)throw new TypeError("Expected 'cooldownWatcherTime' to be a positive number.");if("boolean"!=typeof t)throw new TypeError("Expected 'allowAutoConfigChange' to be a boolean.");this.#yr=e,this.#gr=t,this.setCooldownWatcherTime(e)}isDestroyed(){return this.#fr}getAllowAutoConfigChange(){return this.#gr}getCooldownWatcherTime(){return this.#yr}setAllowAutoConfigChange(e){if("boolean"!=typeof e)throw new TypeError("Expected 'value' to be a boolean.");this.#gr=e}setCooldownWatcherTime(e){if(this.#fr)throw new Error("TinyTimeout has been destroyed.");if(!Number.isFinite(e)||e<=0)throw new TypeError("Expected 'value' to be a positive number.");this.#yr=e,this.#wr&&clearInterval(this.#wr),this.#wr=setInterval(()=>{this.#br.forEach(e=>{e.now>0&&e.now--})},this.#yr)}set(e,t,r,n=null){if(this.#fr)throw new Error("TinyTimeout has been destroyed.");if("string"!=typeof e||""===e.trim())throw new TypeError("Expected 'id' to be a non-empty string.");if("function"!=typeof t)throw new TypeError("Expected 'callback' to be a function.");if(!Number.isFinite(r)||r<0)throw new TypeError("Expected 'value' to be a non-negative number.");if(null!==n&&(!Number.isFinite(n)||n<0))throw new TypeError("Expected 'limit' to be null or a non-negative number.");let i=this.#br.get(e);(!i||this.#gr&&r!==i.value)&&(i={value:r,now:0},this.#br.set(e,i));const s=i.value*i.now;return i.now++,setTimeout(t,"number"==typeof n?Math.min(s,n):s)}static waitForTrue(e,t=100){if("function"!=typeof e)throw new TypeError("Expected 'getValue' to be a function.");if(!Number.isFinite(t)||t<=0)throw new TypeError("Expected 'checkInterval' to be a positive number.");return new Promise(r=>{const n=setInterval(()=>{e()&&(clearInterval(n),r())},t)})}waitForTrue(e,t=100){if(this.#fr)throw new Error("TinyTimeout has been destroyed.");if("function"!=typeof e)throw new TypeError("Expected 'getValue' to be a function.");if(null!==t&&(!Number.isFinite(t)||t<=0))throw new TypeError("Expected 'checkInterval' to be null or a positive number.");return Gt.waitForTrue(e,t??this.#yr)}destroy(){this.#fr||(this.#fr=!0,this.#wr&&clearInterval(this.#wr),this.#wr=null,this.#br.clear())}}const Yt=Gt,Xt=new Map,Qt=new Map,Zt=new Set(["string","boolean","object","array",String,Boolean,Number,Object,Array,BigInt,Symbol]);class er{#It=new zt;setThrowOnMaxListeners(e){return this.#It.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#It.getThrowOnMaxListeners()}prependListener(e,t){return this.#It.prependListener(e,t)}prependListenerOnce(e,t){return this.#It.prependListenerOnce(e,t)}appendListener(e,t){return this.#It.appendListener(e,t)}appendListenerOnce(e,t){return this.#It.appendListenerOnce(e,t)}on(e,t){return this.#It.on(e,t)}once(e,t){return this.#It.once(e,t)}off(e,t){return this.#It.off(e,t)}offAll(e){return this.#It.offAll(e)}offAllTypes(){return this.#It.offAllTypes()}listenerCount(e){return this.#It.listenerCount(e)}listeners(e){return this.#It.listeners(e)}onceListeners(e){return this.#It.onceListeners(e)}allListeners(e){return this.#It.allListeners(e)}eventNames(){return this.#It.eventNames()}emit(e,...t){return this.#It.emit(e,...t)}setMaxListeners(e){return this.#It.setMaxListeners(e)}getMaxListeners(){return this.#It.getMaxListeners()}static hasJsonType(e){return Xt.has(e)&&Qt.has(e)||Zt.has(e)}static registerJsonType(e,t,r,n=!1){if(Zt.has(e))throw new Error(`Cannot register type "${e}" because it is frozen.`);Xt.set(e,t),Qt.set(e,r),n&&Zt.add(e)}static deleteJsonType(e){if(Zt.has(e))throw new Error(`Cannot remove type "${e}" because it is frozen.`);let t=!1;return Xt.delete(e)&&(t=!0),Qt.delete(e)&&(t=!0),t}static encodeSpecialJson(e){if(void 0===e)return{__undefined__:!0};if(null===e)return{__null__:!0};for(const[t,r]of Xt.entries())if("string"!=typeof t&&e instanceof t||typeof e===t)return r(e,er.encodeSpecialJson);if(Array.isArray(e))return e.map(er.encodeSpecialJson);if(f(e)){const t={};for(const r in e)t[r]=er.encodeSpecialJson(e[r]);return t}return e}static decodeSpecialJson(e){const t=f(e);if(t){if(e.__undefined__)return;if(e.__null__)return null}if(Array.isArray(e))return e.map(er.decodeSpecialJson);if(t){for(const[t,r]of Qt.entries())if(r.check&&r.check(e))return r.decode(e,er.decodeSpecialJson);const t={};for(const r in e)t[r]=er.decodeSpecialJson(e[r]);return t}return e}#vr=window.localStorage;#Er=null;#Z=0;#Tr=e=>this.emit("storage",e);constructor(e){if(void 0!==e&&"string"!=typeof e)throw new TypeError("TinyLocalStorage: dbName must be a string if provided.");"string"==typeof e&&(this.#Er=`LSDB::${e}`),window.addEventListener("storage",this.#Tr)}#Sr(e){if("string"==typeof e&&e.startsWith("LSDB::"))throw new Error(`TinyLocalStorage: Key "${e}" may conflict with reserved dbKeys.`)}updateStorageVersion(e,t){if("string"!=typeof this.#Er)throw new Error("TinyLocalStorage: Database key is not initialized. Set a valid dbName in the constructor.");if("number"!=typeof e||Number.isNaN(e)||e<1)throw new TypeError("TinyLocalStorage: version must be a positive number.");if("function"!=typeof t)throw new TypeError("TinyLocalStorage: onUpgrade must be a function.");const r=parseInt(localStorage.getItem(this.#Er),10)||0;if("number"!=typeof r||Number.isNaN(r)||r<0)throw new TypeError("TinyLocalStorage: saved version in localStorage is not a valid number.");if(e<r)throw new Error(`TinyLocalStorage: Cannot downgrade database version from ${r} to ${e}.`);e>r&&(t(r,e),localStorage.setItem(this.#Er,String(e)),this.#Z=e)}getDbKey(){return this.#Er}getVersion(){return this.#Z}setLocalStorage(e){if(!(e instanceof Storage))throw new TypeError("Argument must be a valid instance of Storage.");this.#vr=e}localStorageExists(){return this.#vr instanceof Storage}#xr(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return er.encodeSpecialJson(t)}setJson(e,t){if(this.#Sr(e),!(f(t)||Array.isArray(t)||t instanceof Map||t instanceof Set))throw new TypeError("The storage value is not a valid JSON-compatible structure.");const r=this.#xr(e,t);return this.emit("setJson",e,t),this.#vr.setItem(e,JSON.stringify(r))}#Ar(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const r=this.#vr.getItem(e),n={obj:()=>({}),array:()=>[],map:()=>new Map,set:()=>new Set},i="function"==typeof n[t]?n[t]():null;let s;try{s=JSON.parse(r)}catch{return i}return{decoded:er.decodeSpecialJson(s),fallback:i}}getJson(e,t){const{decoded:r,fallback:n}=this.#Ar(e,t);return r instanceof Map||r instanceof Set||Array.isArray(r)||f(r)?r:n}setDate(e,t){if(this.#Sr(e),!(t instanceof Date))throw new TypeError("Value must be a Date.");const r=this.#xr(e,t);return this.emit("setDate",e,t),this.#vr.setItem(e,JSON.stringify(r))}getDate(e){const t=this.#Ar(e).decoded;return t instanceof Date?t:null}setRegExp(e,t){if(this.#Sr(e),!(t instanceof RegExp))throw new TypeError("Value must be a RegExp.");const r=this.#xr(e,t);return this.emit("setRegExp",e,t),this.#vr.setItem(e,JSON.stringify(r))}getRegExp(e){const t=this.#Ar(e).decoded;return t instanceof RegExp?t:null}setBigInt(e,t){if(this.#Sr(e),"bigint"!=typeof t)throw new TypeError("Value must be a BigInt.");const r=this.#xr(e,t);return this.emit("setBigInt",e,t),this.#vr.setItem(e,JSON.stringify(r))}getBigInt(e){const t=this.#Ar(e).decoded;return"bigint"==typeof t?t:null}setSymbol(e,t){if(this.#Sr(e),"symbol"!=typeof t)throw new TypeError("Value must be a Symbol.");const r=this.#xr(e,t);return this.emit("setSymbol",e,t),this.#vr.setItem(e,JSON.stringify(r))}getSymbol(e){const t=this.#Ar(e).decoded;return"symbol"==typeof t?t:null}getValue(e){return this.#Ar(e).decoded??null}setItem(e,t){if(this.#Sr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("setItem",e,t),this.#vr.setItem(e,t)}getItem(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.#vr.getItem(e)}setString(e,t){if(this.#Sr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("string"!=typeof t)throw new TypeError("Value must be a string.");return this.emit("setString",e,t),this.#vr.setItem(e,JSON.stringify({__string__:!0,value:t}))}getString(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#vr.getItem(e);try{if(t=JSON.parse(t),!f(t)||!t.__string__||"string"!=typeof t.value)return null;t=t.value}catch{t=null}return"string"==typeof t?t:null}setNumber(e,t){if(this.#Sr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("number"!=typeof t)throw new TypeError("Value must be a number.");return this.emit("setNumber",e,t),this.#vr.setItem(e,String(t))}getNumber(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#vr.getItem(e);return"number"==typeof t||"string"==typeof t&&t.length>0&&(t=parseFloat(t),!Number.isNaN(t))?t:null}setBool(e,t){if(this.#Sr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("boolean"!=typeof t)throw new TypeError("Value must be a boolean.");return this.emit("setBool",e,t),this.#vr.setItem(e,String(t))}getBool(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const t=this.#vr.getItem(e);if("boolean"==typeof t)return t;if("string"==typeof t){if("true"===t)return!0;if("false"===t)return!1}return null}removeItem(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("removeItem",e),this.#vr.removeItem(e)}clearLocalStorage(){return this.#vr.clear()}destroy(){window.removeEventListener("storage",this.#Tr),this.#It.offAllTypes()}}er.registerJsonType(Map,(e,t)=>({__map__:!0,data:Array.from(e.entries()).map(([e,r])=>[e,t(r)])}),{check:e=>e.__map__,decode:(e,t)=>new Map(e.data.map(([e,r])=>[e,t(r)]))},!0),er.registerJsonType(Set,(e,t)=>({__set__:!0,data:Array.from(e).map(t)}),{check:e=>e.__set__,decode:(e,t)=>new Set(e.data.map(t))},!0),er.registerJsonType(Date,e=>({__date__:!0,value:e.toISOString()}),{check:e=>e.__date__,decode:e=>new Date(e.value)},!0),er.registerJsonType(RegExp,e=>({__regexp__:!0,source:e.source,flags:e.flags}),{check:e=>e.__regexp__,decode:e=>new RegExp(e.source,e.flags)},!0),er.registerJsonType("number",e=>({__number__:!0,value:e.toString()}),{check:e=>e.__number__,decode:e=>Number(e.value)},!0),er.registerJsonType("bigint",e=>({__bigint__:!0,value:e.toString()}),{check:e=>e.__bigint__,decode:e=>BigInt(e.value)},!0),er.registerJsonType("symbol",e=>({__symbol__:!0,key:Symbol.keyFor(e)??e.description??null}),{check:e=>e.__symbol__,decode:e=>{const t=e.key;return null!=t?Symbol.for(t):Symbol()}},!0);const tr=er,rr=new WeakMap,nr=class{#It=new zt;setThrowOnMaxListeners(e){return this.#It.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#It.getThrowOnMaxListeners()}prependListener(e,t){return this.#It.prependListener(e,t)}prependListenerOnce(e,t){return this.#It.prependListenerOnce(e,t)}appendListener(e,t){return this.#It.appendListener(e,t)}appendListenerOnce(e,t){return this.#It.appendListenerOnce(e,t)}on(e,t){return this.#It.on(e,t)}once(e,t){return this.#It.once(e,t)}off(e,t){return this.#It.off(e,t)}offAll(e){return this.#It.offAll(e)}offAllTypes(){return this.#It.offAllTypes()}listenerCount(e){return this.#It.listenerCount(e)}listeners(e){return this.#It.listeners(e)}onceListeners(e){return this.#It.onceListeners(e)}allListeners(e){return this.#It.allListeners(e)}eventNames(){return this.#It.eventNames()}setMaxListeners(e){return this.#It.setMaxListeners(e)}getMaxListeners(){return this.#It.getMaxListeners()}#Cr;get targetWindow(){return this.#Cr}#Ir;get targetIframeElement(){return this.#Ir}#Mr;get targetOrigin(){return this.#Mr}#kr;get selfType(){return this.#kr}#fr=!1;#Lr=!1;get ready(){return this.#Lr}onReady(e){this.#Lr?e():this.#It.once(this.#Nr,e)}#Dr=null;#_r=[];#Rr;#jr;#Nr;#Or=null;constructor({targetIframe:e,targetOrigin:t=window.location.origin,secretEventName:r="__tinyIframeEvent__",handshakeEventName:n="__tinyIframeHandshake__",readyEventName:i="__tinyIframeReady__"}={}){if(!(void 0===e||e instanceof HTMLIFrameElement&&e.contentWindow))throw new TypeError('[TinyIframeEvents] Invalid "targetIframe": expected HTMLIFrameElement, received '+typeof e);if("string"!=typeof t)throw new TypeError('[TinyIframeEvents] Invalid "targetOrigin": expected string, received '+typeof t);if(this.#Ir=e,this.#Cr=e?.contentWindow??window.parent,this.#Mr=t,this.#kr=e?"parent":"iframe",this.#Rr=r,this.#jr=n,this.#Nr=i,rr.has(this.#Cr))throw new Error("Duplicate window reference.");this._boundWindowMessage=this.#Pr.bind(this),this._boundPortMessage=this.#$r.bind(this),this.#Hr(),rr.set(this.#Cr,this)}get secretEventName(){return this.#Rr}set secretEventName(e){if("string"!=typeof e)throw new TypeError("TinyIframeEvents: secretEventName must be a string.");this.#Rr=e}get handshakeEventName(){return this.#jr}set handshakeEventName(e){if("string"!=typeof e)throw new TypeError("TinyIframeEvents: handshakeEventName must be a string.");this.#jr=e}get readyEventName(){return this.#Nr}set readyEventName(e){if("string"!=typeof e)throw new TypeError("TinyIframeEvents: readyEventName must be a string.");this.#Nr=e}#Hr(){"parent"===this.#kr?(this.#Or=()=>{if(this.#fr)return;this.#Dr&&this.#Dr.close();const e=new MessageChannel;this.#Dr=e.port1,this.#Dr.onmessage=this._boundPortMessage,this.#Lr=!1,this.#Cr.postMessage({type:this.#jr},this.#Mr,[e.port2])},this.#Ir&&(this.#Ir.addEventListener("load",this.#Or),this.#Or())):window.addEventListener("message",this._boundWindowMessage,!1)}#Pr(e){const t=e.data,r=e.ports;f(t)&&t.type===this.#jr&&0!==r.length&&(this.#Dr=r[0],this.#Dr.onmessage=this._boundPortMessage,window.removeEventListener("message",this._boundWindowMessage),this.#Dr.postMessage({type:`${this.#jr}_ACK`}),this.#Br())}#$r(e){const t=e.data;if(f(t)&&t.type===`${this.#jr}_ACK`)return void this.#Br();if(!f(t)||!t[this.#Rr])return;const r=t.eventName,n=t.payload,i=t.direction;"string"!=typeof r||"iframe"===this.#kr&&"iframe"!==i||"parent"===this.#kr&&"parent"!==i||this.#It.emit(r,n,e)}#Br(){this.#Lr||(this.#Lr=!0,this.#Fr(),this.#It.emit(this.#Nr))}#Fr(){for(;this.#_r.length>0;){const e=this.#_r.shift();e&&this.#Dr&&this.#Dr.postMessage(e)}}emit(e,t){if("string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.#fr)throw new Error("Cannot emit: instance has been destroyed.");const r={[this.#Rr]:!0,eventName:e,payload:t,direction:"parent"===this.#kr?"iframe":"parent"};this.#Lr&&this.#Dr?this.#Dr.postMessage(r):this.#_r.push(r)}isDestroyed(){return this.#fr}destroy(){this.#fr=!0,this.#Lr=!1,window.removeEventListener("message",this._boundWindowMessage),this.#Ir&&this.#Or&&this.#Ir.removeEventListener("load",this.#Or),this.#Dr&&(this.#Dr.close(),this.#Dr=null),this.#It.offAllTypes(),this.#_r=[],rr.delete(this.#Cr)}},ir=new WeakMap,sr=class{#It=new zt;setThrowOnMaxListeners(e){return this.#It.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#It.getThrowOnMaxListeners()}prependListener(e,t){return this.#It.prependListener(e,t)}prependListenerOnce(e,t){return this.#It.prependListenerOnce(e,t)}appendListener(e,t){return this.#It.appendListener(e,t)}appendListenerOnce(e,t){return this.#It.appendListenerOnce(e,t)}on(e,t){return this.#It.on(e,t)}once(e,t){return this.#It.once(e,t)}off(e,t){return this.#It.off(e,t)}offAll(e){return this.#It.offAll(e)}offAllTypes(){return this.#It.offAllTypes()}listenerCount(e){return this.#It.listenerCount(e)}listeners(e){return this.#It.listeners(e)}onceListeners(e){return this.#It.onceListeners(e)}allListeners(e){return this.#It.allListeners(e)}eventNames(){return this.#It.eventNames()}setMaxListeners(e){return this.#It.setMaxListeners(e)}getMaxListeners(){return this.#It.getMaxListeners()}#zr;#Mr;#_r=[];#Lr=!1;#Wr=!1;#qr=null;#Nr="__TNE_READY__";#Vr="__TNE_ROUTE__";get readyEventName(){return this.#Nr}set readyEventName(e){if("string"!=typeof e)throw new TypeError("TinyNewWinEvents: readyEventName must be a string.");this.#Nr=e}get routeEventName(){return this.#Vr}set routeEventName(e){if("string"!=typeof e)throw new TypeError("TinyNewWinEvents: routeEventName must be a string.");this.#Vr=e}constructor({targetOrigin:e,url:t,name:r,features:n}={}){if("string"==typeof r&&"_blank"===r)throw new Error('TinyNewWinEvents: The window name "_blank" is not supported. Please use a custom name to allow tracking.');if(void 0!==e&&"string"!=typeof e)throw new TypeError('TinyNewWinEvents: The "targetOrigin" option must be a string.');if(void 0!==t&&"string"!=typeof t)throw new TypeError('TinyNewWinEvents: The "url" option must be a string.');if(void 0!==n&&"string"!=typeof n)throw new TypeError('TinyNewWinEvents: The "features" option must be a string if provided.');if(void 0===t?this.#zr=window.opener:(this.#zr="string"==typeof t?window.open(t,r,n):t,this.#Wr=!0),!this.#zr||ir.has(this.#zr))throw new Error("Invalid or duplicate window reference.");this.#Mr=e??window.location.origin,this._handleMessage=this.#Ur.bind(this),window.addEventListener("message",this._handleMessage,!1),this.#Wr||(this.#Kr(this.#Nr,null),this.#Jr())}getWin(){return this.#zr}#Ur(e){if(!e.source||this.#zr&&e.source!==this.#zr)return;const{type:t,route:r,payload:n}=e.data||{};if(t===this.#Nr)return this.#Lr=!0,this.#Fr(),this.#Jr(),void(this.#Wr&&this.#Kr(this.#Nr,null));t===this.#Vr&&this.#It.emit(r,n,e)}#Fr(){for(;this.#_r.length;){const e=this.#_r.shift();if(e){const{route:t,payload:r}=e;this.emit(t,r)}}}#Kr(e,t,r=""){this.#zr&&this.#zr.closed||this.#zr?.postMessage({type:e,route:r,payload:t},this.#Mr)}close(){if(!this.#Wr)throw new Error("Only host can close the window.");this.#zr&&!this.#zr.closed&&this.#zr.close()}emit(e,t){if("string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.isDestroyed())throw new Error("Cannot emit: instance has been destroyed.");this.#Lr?this.#Kr(this.#Vr,t,e):this.#_r.push({route:e,payload:t})}isConnected(){return!(!this.#Lr||!this.#zr||this.#zr.closed)}#Jr(){this.#zr&&!this.#qr&&(this.#qr=setInterval(()=>{this.#zr?.closed&&(this.#It.emit("WINDOW_REF_CLOSED"),this.destroy())},500),ir.set(this.#zr,this.#qr))}onClose(e){return this.#It.on("WINDOW_REF_CLOSED",e)}offClose(e){return this.#It.off("WINDOW_REF_CLOSED",e)}isDestroyed(){return!this.#zr}destroy(){this.#zr&&(this.#qr&&(clearInterval(this.#qr),this.#qr=null,ir.delete(this.#zr)),window.removeEventListener("message",this._handleMessage),this.#_r=[],this.#Lr=!1,this.#zr=null,this.#It.offAllTypes())}},or=class{#Gr;#Yr;#Xr;#Qr=0;#Zr=0;#en;#tn=null;#rn=null;get lineHeight(){return this.#Gr}get maxRows(){return this.#Yr-1}get extraHeight(){return this.#Xr}get currentHeight(){return this.#Qr}get currentRows(){return this.#Zr}get textarea(){return this.#en}constructor(e,t={}){if(!(e instanceof HTMLTextAreaElement))throw new Error("TinyTextarea: Provided element is not a <textarea>.");if("object"!=typeof t||null===t)throw new TypeError("TinyTextarea: Options must be an object if provided.");if("maxRows"in t&&"number"!=typeof t.maxRows)throw new TypeError("TinyTextarea: `maxRows` must be a number.");if("extraHeight"in t&&"number"!=typeof t.extraHeight)throw new TypeError("TinyTextarea: `extraHeight` must be a number.");if("onResize"in t&&"function"!=typeof t.onResize)throw new TypeError("TinyTextarea: `onResize` must be a function.");if("onInput"in t&&"function"!=typeof t.onInput)throw new TypeError("TinyTextarea: `onInput` must be a function.");this.#en=e,this.#Yr=(t.maxRows??5)+1,this.#Xr=t.extraHeight??0,this.#tn=t.onResize??null,this.#rn=t.onInput??null,this.#Gr=this.#nn(),e.style.overflowY="hidden",e.style.resize="none",this._handleInput=()=>this.#in(),e.addEventListener("input",this._handleInput),this.#in()}#in(){this.#en.style.height="auto";const e=window.getComputedStyle(this.#en),t=parseFloat(e.paddingTop)||0,r=parseFloat(e.paddingBottom)||0,n=(this.#en.value.match(/\n/g)||[]).length,i=this.#en.scrollHeight,s=this.#Gr*this.#Yr,o=Math.ceil(Math.min(i,s)-t-r+this.#Xr),a=this.#Yr-1,l=n<a?n+1:a;this.#en.style.height=`${o}px`,this.#en.style.overflowY=i>s?"auto":"hidden",this.#Qr=o;const u={breakLines:n,rows:l,height:o,scrollHeight:i,maxHeight:s,lineHeight:this.#Gr,maxRows:a};l!==this.#Zr&&(this.#Zr=l,"function"==typeof this.#tn&&this.#tn({...u})),"function"==typeof this.#rn&&this.#rn(u)}#nn(){const e=window.getComputedStyle(this.#en),t=parseFloat(e.lineHeight);return Number.isNaN(t)?1.2*parseFloat(e.fontSize):t}getData(){return{rows:this.#Zr,height:this.#Qr}}refresh(){this.#in()}destroy(){this.#en.removeEventListener("input",this._handleInput)}};class ar{#fr=!1;#sn=new Set;#on=new Map;#an=new Map;#ln=null;#un=[];#cn={};#hn=[];#dn=null;#pn=null;#mn;#fn;#gn;#yn;#wn;#bn;#vn;#En;#Tn=[];#Sn=0;#xn=0;#An=[];#Cn=0;#In=null;#Mn=new Set;#kn=new Set;#Ln=new Map;#Nn=new Map;#Dn=new Map;static#_n={" ":"Space","\n":"Enter","\r":"Enter","\t":"Tab","-":"Minus",_:"Minus","=":"Equal","+":"Equal","[":"BracketLeft","{":"BracketLeft","]":"BracketRight","}":"BracketRight","\\":"Backslash","|":"Backslash",";":"Semicolon",":":"Semicolon","'":"Quote",'"':"Quote",",":"Comma","<":"Comma",".":"Period",">":"Period","/":"Slash","?":"Slash","`":"Backquote","~":"Backquote"};static addSpecialKey(e,t){if("string"!=typeof e)throw new TypeError("Invalid char type: expected string, got "+typeof e);if(1!==e.length)throw new Error(`Invalid char length: "${e}" (must be exactly one character)`);if("string"!=typeof t)throw new TypeError("Invalid code type: expected string, got "+typeof t);ar.#_n[e]=t}static removeSpecialKey(e){if("string"!=typeof e)throw new TypeError("Invalid char type: expected string, got "+typeof e);if(1!==e.length)throw new Error(`Invalid char length: "${e}" (must be exactly one character)`);delete ar.#_n[e]}static getSpecialKey(e){if("string"!=typeof e)throw new TypeError("Invalid char type: expected string, got "+typeof e);if(1!==e.length)throw new Error(`Invalid char length: "${e}" (must be exactly one character)`);return ar.#_n[e]}static getAllSpecialKeys(){return{...ar.#_n}}static stringToKeys(e){if("string"!=typeof e)throw new TypeError("Invalid text type: expected string, got "+typeof e);if(!e.length)throw new Error("Invalid text: cannot be empty");return Array.from(e).map(e=>{const t=e.toUpperCase();if(t>="A"&&t<="Z")return`Key${t}`;if(t>="0"&&t<="9")return`Digit${t}`;const r=ar.#_n[e];if(void 0!==r)return r;throw new Error(`Unsupported character: "${e}"`)})}constructor({expectedId:e=null,inputMode:t="both",ignoreIds:r=[],deadZone:n=.1,axisActiveSensitivity:i=.3,timeoutComboKeys:s=500,allowMouse:o=!1,elementBase:a=window}={}){if(null!==e&&"string"!=typeof e)throw new TypeError('"expectedId" must be a string or null, received: '+typeof e);if(!["keyboard-only","gamepad-only","both"].includes(t))throw new TypeError(`"inputMode" must be 'keyboard-only', 'gamepad-only', or 'both', received: ${t}`);if(!Array.isArray(r)||!r.every(e=>"string"==typeof e))throw new TypeError('"ignoreIds" must be an array of strings');if("number"!=typeof n||n<0||n>1)throw new RangeError(`"deadZone" must be a number between 0 and 1, received: ${n}`);if("number"!=typeof i||i<0||i>1)throw new RangeError(`"axisActiveSensitivity" must be a number between 0 and 1, received: ${i}`);if("number"!=typeof s||s<0)throw new RangeError(`"timeoutComboKeys" must be a positive number, received: ${s}`);if("boolean"!=typeof o)throw new TypeError('"allowMouse" must be a boolean, received: '+typeof o);if(!(a instanceof Window||a instanceof Element))throw new TypeError('"elementBase" must be a Window or Element instance');this.#yn=e,this.#mn=t,this.#fn=new Set(r),this.#gn=n,this.#wn=o,this.#bn=a,this.#vn=s,this.#En=i,["gamepad-only","both"].includes(this.#mn)&&this.#Rn(),["keyboard-only","both"].includes(this.#mn)&&this.#jn()}#On=e=>this.#Pn(e.gamepad);#$n=e=>this.#Hn(e.gamepad);#Rn(){window.addEventListener("gamepadconnected",this.#On),window.addEventListener("gamepaddisconnected",this.#$n)}#Pn(e){this.#fr||this.#fn.has(e.id)||this.#yn&&e.id!==this.#yn||this.#ln||(this.#ln=e,this.#yn=e.id,this.#Bn(),this.#Fn("connected",{id:e.id,gp:e,timestamp:e.timestamp}))}#Hn(e){this.#fr||this.#ln&&e.id===this.#ln.id&&(this.#ln=null,this.#dn&&(cancelAnimationFrame(this.#dn),this.#dn=null),this.#Fn("disconnected",{id:e.id,gp:e,timestamp:e.timestamp}))}#Bn(){const e=()=>{this.#fr||(this.#zn(),this.#dn=requestAnimationFrame(e))};e()}#zn(){if(this.#fr)return;const e=navigator.getGamepads(),t=Array.from(e).find(e=>e&&e.id===this.#yn);t&&(this.#ln=t,t.buttons.forEach((e,r)=>{const n=`Button${r}`,i=this.#un[r]?.pressed||!1;let s,o,a=!1;e.pressed&&!i?(o=1,s="down"):!e.pressed&&i?(o=0,s="up"):e.pressed&&i&&(o=1,s="hold"),e.pressed&&e.value>0&&e.value<1&&1!==e.value&&(o=e.value,a=!0),"number"==typeof o&&"string"==typeof s&&this.#Wn({key:n,source:"gamepad-button",value:o,value2:NaN,type:s,gp:t,isPressure:a,pressed:e.pressed,prevPressed:i,timestamp:t.timestamp,id:t.id}),this.#un[r]={pressed:e.pressed,value:"number"==typeof o?o:this.#un[r]?.value,value2:NaN}}),t.axes.forEach((e,r)=>{Math.abs(e)<this.#gn&&(e=0);const n=`Axis${r}`;e!==(this.#hn[r]??0)&&this.#Wn({key:n,source:"gamepad-analog",value:e,value2:NaN,type:"change",timestamp:t.timestamp,id:t.id,gp:t}),this.#hn[r]=e}))}#qn=e=>{if(!this.#fr){if(!(e instanceof KeyboardEvent))throw new Error("Expected KeyboardEvent in keydown listener.");this.#sn.has(e.code)||(this.#sn.add(e.code),this.#Wn({event:e,key:e.code,source:"keyboard",value:1,value2:NaN,type:"down",pressed:!0,prevPressed:this.#cn[e.code]?.pressed??!1,id:"native_keyboard",timestamp:e.timeStamp}),this.#cn[e.code]={pressed:!0})}};#Vn=e=>{if(!this.#fr){if(!(e instanceof KeyboardEvent))throw new Error("Expected KeyboardEvent in keyup listener.");this.#sn.has(e.code)&&(this.#sn.delete(e.code),this.#Wn({event:e,key:e.code,source:"keyboard",value:0,value2:NaN,type:"up",pressed:!1,prevPressed:this.#cn[e.code]?.pressed??!1,id:"native_keyboard",timestamp:e.timeStamp}),this.#cn[e.code]={pressed:!1})}};#Un=e=>{if(this.#fr)return;if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mousedown listener.");const t=`Mouse${e.button}`;this.#sn.add(t),this.#Wn({event:e,key:t,source:"mouse",value:1,value2:NaN,type:"down",pressed:!0,prevPressed:this.#cn[t]?.pressed??!1,id:"native_mouse",timestamp:e.timeStamp}),this.#cn[t]={pressed:!0}};#Kn=e=>{if(this.#fr)return;if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mouseup listener.");const t=`Mouse${e.button}`;this.#sn.delete(t),this.#Wn({event:e,key:t,source:"mouse",value:0,value2:NaN,type:"up",pressed:!1,prevPressed:this.#cn[t]?.pressed??!1,id:"native_mouse",timestamp:e.timeStamp}),this.#cn[t]={pressed:!1}};#Jn=e=>{if(!this.#fr){if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mousemove listener.");if(0!==e.movementX||0!==e.movementY){const t="MouseMove",r=this.#cn[t]??{pressed:!1,value:0,value2:0};this.#Wn({event:e,key:t,source:"mouse",value:e.movementX+(r.value??0),value2:e.movementY+(r.value??0),id:"native_mouse",type:"move",pressed:!0,prevPressed:null,timestamp:e.timeStamp}),this.#cn[t]={pressed:!1,value:e.movementX,value2:e.movementY}}}};#jn(){this.#bn.addEventListener("keydown",this.#qn),this.#bn.addEventListener("keyup",this.#Vn),this.#wn&&(this.#bn.addEventListener("mousedown",this.#Un),this.#bn.addEventListener("mouseup",this.#Kn),this.#bn.addEventListener("mousemove",this.#Jn));const e=()=>{this.#fr||(this.#sn.forEach(e=>{const t=e.startsWith("Mouse")?"mouse":"keyboard";this.#Wn({key:e,source:t,id:`native_${t}`,value:1,value2:NaN,type:"hold",pressed:!0,prevPressed:this.#cn[e]?.pressed??!1,timestamp:NaN})}),this.#pn=requestAnimationFrame(e))};e()}#Wn(e){if(this.#fr)return;const t=this.#an.get("input-*")||[],{pressed:r,key:n}=e,i=n.startsWith("Axis"),s="boolean"==typeof r&&r||i&&(e.value>this.#En||e.value<-Math.abs(this.#En)),o=i?`${n}${e.value>0?"+":e.value<0?"-":""}`:n;let a=null;if("move"!==e.type&&"hold"!==e.type){if(s){if(!i&&!this.#Mn.has(n)||i&&!this.#Mn.has(n)&&!this.#Mn.has(`${n}+`)&&!this.#Mn.has(`${n}-`)){0===this.#Cn&&(this.#Cn=Date.now()),this.#Mn.add(o),a=!0,this.#An.push(o),this.#Tn.length<1&&(this.#In&&clearTimeout(this.#In),this.#In=setTimeout(()=>this.resetComboMapped(),this.#vn));const e=this.#an.get("mapped-key-start")??[];for(const t of e)t({key:o,activeTime:this.#Cn})}}else if(!i&&this.#Mn.has(n)||i&&(this.#Mn.has(n)||this.#Mn.has(`${n}+`)||this.#Mn.has(`${n}-`))){this.#Mn.delete(n),this.#Mn.delete(`${n}+`),this.#Mn.delete(`${n}-`),a=!1;const e=this.#an.get("mapped-key-end")??[];for(const t of e)t({key:o,activeTime:this.#Cn})}for(const{sequence:e,callback:t,triggered:r}of this.#Nn.values()){const n=this.#Nn.get(e.join("+"));if(!n)continue;const i=e.every((e,t)=>this.#An[t]===e);i&&!r?(n.triggered=!0,t(this.#Cn)):!i&&r&&(n.triggered=!1)}}for(const[r,l]of this.#on.entries()){const u=e=>"string"==typeof l&&e===l||Array.isArray(l)&&l.findIndex((t,r)=>e===l[r])>-1,c=u(o),h=i&&u(`${n}+`),d=i&&u(`${n}-`);if(c||h||d){if(s&&c){if(a||!this.#kn.has(r)){0===this.#xn&&(this.#xn=Date.now()),this.#kn.add(r),0===this.#Sn&&(this.#Sn=Date.now()),this.#In&&clearTimeout(this.#In),this.#Tn.push(r),this.#In=setTimeout(()=>this.resetComboMapped(),this.#vn);const e=this.#an.get("mapped-input-start")??[];for(const t of e)t({logicalName:r,activeTime:this.#xn,comboTime:this.#Sn})}}else if(!a||this.#kn.has(r)){this.#kn.delete(r),this.#kn.size<1&&(this.#xn=0);const e=this.#an.get("mapped-input-end")??[];for(const t of e)t({logicalName:r,activeTime:this.#xn,comboTime:this.#Sn})}for(const{sequence:e,callback:t,triggered:r}of this.#Ln.values()){const n=this.#Ln.get(e.join("+"));if(!n)continue;const i=Array.from(this.#kn),s=e.every((e,t)=>i[t]===e);s&&!r?(n.triggered=!0,t(this.#xn)):!s&&r&&(n.triggered=!1)}}const p=[];if(i&&0===e.value){const{value:t}=this.#Dn.get(`${n}-`)??{value:0,value2:NaN},{value:r}=this.#Dn.get(`${n}+`)??{value:0,value2:NaN};e.value!==t&&p.push(`${n}-`),e.value!==r&&p.push(`${n}+`)}else p.push(o);p.forEach(n=>{if(!("*"===l||l===n||Array.isArray(l)&&l.includes(n)))return;const i=this.#an.get(`input-${e.type}-${r}`)||[],s=this.#an.get(`input-${r}`)||[];if(s.length<1&&i.length<1&&t.length<1)return;const o={...e,key:n,logicalName:r};for(const e of t)e(o);for(const e of s)e(o);for(const e of i)e(o);this.#Dn.set(n,{value:e.value,value2:e.value2})})}}#Fn(e,t){const r=this.#an.get(e)||[];for(const e of r)e(t)}#Gn(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const n=r.replace("{logicalName}",e);let i=this.#an.get(n);Array.isArray(i)||(i=[],this.#an.set(n,i)),i.push(t)}#Yn(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const n=i=>{this.#Xn(e,n,r),t(i)};this.#Gn(e,n,r)}#Qn(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const n=r.replace("{logicalName}",e),i=this.#an.get(n)??[];i.unshift(t),this.#an.set(n,i)}#Xn(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const n=r.replace("{logicalName}",e),i=this.#an.get(n);Array.isArray(i)&&this.#an.set(n,i.filter(e=>e!==t))}awaitInputMapping({timeout:e=1e4,eventName:t="MappingInput",canMove:r=!1}={}){return new Promise((n,i)=>{if("number"!=typeof e||Number.isNaN(e)||e<0)return i(new TypeError(`Invalid "timeout": expected a positive number, got ${e}`));if("string"!=typeof t||!t.trim())return i(new TypeError(`Invalid "eventName": expected a non-empty string, got ${t}`));if("boolean"!=typeof r)return i(new TypeError(`Invalid "canMove": expected a boolean, got ${r}`));const s={key:null,source:null},o=({key:e,type:i,source:l,gp:u,value:c})=>{(r||"move"!==i)&&(s.key=e,s.source=l,s.gp=u,clearTimeout(a),this.offInputStart(t,o),this.offInputChange(t,o),r&&this.offInputMove(t,o),n(s))},a=setTimeout(()=>n(s),e);this.mapInput(t,"*"),this.onInputStart(t,o),this.onInputChange(t,o),r&&this.onInputMove(t,o)})}mapInput(e,t){if("string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError(`Invalid "physicalInput": expected string or array of strings, got ${JSON.stringify(t)}`);this.#on.set(e,t)}unmapInput(e){if("string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);this.#on.delete(e)}hasMappedInput(e){if("string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);return this.#on.has(e)}getMappedInput(e){if("string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);const t=this.#on.get(e);if(!t)throw new Error(`No physical input mapped for logicalName: "${e}"`);return t}clearMapInputs(){this.#on.clear()}registerInputSequence(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);if("function"!=typeof t)throw new TypeError("'callback' must be a function, got: "+typeof t);if(0===e.length)throw new Error("'sequence' must contain at least one input name.");const r=e.join("+");this.#Ln.set(r,{sequence:e,callback:t,triggered:!1})}unregisterInputSequence(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");this.#Ln.delete(t)}unregisterAllInputSequences(){this.#Ln.clear()}hasInputSequence(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");return this.#Ln.has(t)}registerKeySequence(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);if("function"!=typeof t)throw new TypeError("'callback' must be a function, got: "+typeof t);if(0===e.length)throw new Error("'sequence' must contain at least one input name.");const r=e.join("+");this.#Nn.set(r,{sequence:e,callback:t,triggered:!1})}unregisterKeySequence(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");this.#Nn.delete(t)}unregisterAllKeySequences(){this.#Nn.clear()}hasKeySequence(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");return this.#Nn.has(t)}renewComboMapped(){this.#In&&(clearTimeout(this.#In),this.#In=setTimeout(()=>this.resetComboMapped(),this.#vn))}resetComboMapped(){this.#In&&clearTimeout(this.#In),this.#An=[],this.#In=null,this.#Cn=0,this.#Tn=[],this.#Sn=0}onMappedKeyStart(e){return this.#Gn("",e,"mapped-key-start")}onceMappedKeyStart(e){return this.#Yn("",e,"mapped-key-start")}prependMappedKeyStart(e){return this.#Qn("",e,"mapped-key-start")}offMappedKeyStart(e){return this.#Xn("",e,"mapped-key-start")}offAllMappedKeyStart(){this.#an.delete("mapped-key-start")}onMappedKeyEnd(e){return this.#Gn("",e,"mapped-key-end")}onceMappedKeyEnd(e){return this.#Yn("",e,"mapped-key-end")}prependMappedKeyEnd(e){return this.#Qn("",e,"mapped-key-end")}offMappedKeyEnd(e){return this.#Xn("",e,"mapped-key-end")}offAllMappedKeyEnd(){this.#an.delete("mapped-key-end")}onMappedInputStart(e){return this.#Gn("",e,"mapped-input-start")}onceMappedInputStart(e){return this.#Yn("",e,"mapped-input-start")}prependMappedInputStart(e){return this.#Qn("",e,"mapped-input-start")}offMappedInputStart(e){return this.#Xn("",e,"mapped-input-start")}offAllMappedInputStart(){this.#an.delete("mapped-input-start")}onMappedInputEnd(e){return this.#Gn("",e,"mapped-input-end")}onceMappedInputEnd(e){return this.#Yn("",e,"mapped-input-end")}prependMappedInputEnd(e){return this.#Qn("",e,"mapped-input-end")}offMappedInputEnd(e){return this.#Xn("",e,"mapped-input-end")}offAllMappedInputEnd(){this.#an.delete("mapped-input-end")}onInput(e,t){return this.#Gn(e,t,"input-{logicalName}")}onceInput(e,t){return this.#Yn(e,t,"input-{logicalName}")}prependInput(e,t){return this.#Qn(e,t,"input-{logicalName}")}offInput(e,t){return this.#Xn(e,t,"input-{logicalName}")}onInputStart(e,t){return this.#Gn(e,t,"input-down-{logicalName}")}onceInputStart(e,t){return this.#Yn(e,t,"input-down-{logicalName}")}prependInputStart(e,t){return this.#Qn(e,t,"input-down-{logicalName}")}offInputStart(e,t){return this.#Xn(e,t,"input-down-{logicalName}")}onInputEnd(e,t){return this.#Gn(e,t,"input-up-{logicalName}")}onceInputEnd(e,t){return this.#Yn(e,t,"input-up-{logicalName}")}prependInputEnd(e,t){return this.#Qn(e,t,"input-up-{logicalName}")}offInputEnd(e,t){return this.#Xn(e,t,"input-up-{logicalName}")}onInputHold(e,t){return this.#Gn(e,t,"input-hold-{logicalName}")}onceInputHold(e,t){return this.#Yn(e,t,"input-hold-{logicalName}")}prependInputHold(e,t){return this.#Qn(e,t,"input-hold-{logicalName}")}offInputHold(e,t){return this.#Xn(e,t,"input-hold-{logicalName}")}onInputChange(e,t){return this.#Gn(e,t,"input-change-{logicalName}")}onceInputChange(e,t){return this.#Yn(e,t,"input-change-{logicalName}")}prependInputChange(e,t){return this.#Qn(e,t,"input-change-{logicalName}")}offInputChange(e,t){return this.#Xn(e,t,"input-change-{logicalName}")}onInputMove(e,t){return this.#Gn(e,t,"input-move-{logicalName}")}onceInputMove(e,t){return this.#Yn(e,t,"input-move-{logicalName}")}prependInputMove(e,t){return this.#Qn(e,t,"input-move-{logicalName}")}offInputMove(e,t){return this.#Xn(e,t,"input-move-{logicalName}")}getCalls(e,t="all"){if("string"!=typeof e||""===e.trim())throw new TypeError(`"logicalName" must be a non-empty string, received ${e}`);const r=["all","start","end","hold","change","move"];if(!r.includes(t))throw new TypeError(`"type" must be one of ${r.join(", ")}, received ${t}`);const n=`${{all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t]}${e}`,i=this.#an.get(n);return Array.isArray(i)?[...i]:[]}offAllInputs(e,t="all"){if("string"!=typeof e||""===e.trim())throw new TypeError(`"logicalName" must be a non-empty string, received ${e}`);const r=["all","start","end","hold","change","move"];if(!r.includes(t))throw new TypeError(`"type" must be one of ${r.join(", ")}, received ${t}`);const n={all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t];n&&this.#an.delete(`${n}${e}`)}getCallSize(e,t="all"){if("string"!=typeof e||""===e.trim())throw new TypeError(`"logicalName" must be a non-empty string, received ${e}`);const r=["all","start","end","hold","change","move"];if(!r.includes(t))throw new TypeError(`"type" must be one of ${r.join(", ")}, received ${t}`);const n={all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t],i=this.#an.get(`${n}${e}`);return Array.isArray(i)?i.length:0}#Zn={type:"dual-rumble",params:{startDelay:0,duration:200,weakMagnitude:.5,strongMagnitude:1}};get defaultHapticEffect(){return{type:this.#Zn.type,params:{...this.#Zn.params}}}setDefaultHapticEffect(e,t){if("string"!=typeof e)throw new TypeError(`"type" must be a valid GamepadHapticEffectType string, received ${e}`);if("object"!=typeof t||null===t)throw new TypeError(`"params" must be a non-null object, received ${t}`);this.#Zn.type=e,this.#Zn.params=t}hasHapticEffect(){const e=this.#ln;return!!e&&e.vibrationActuator instanceof GamepadHapticActuator}vibrate(e,t){if(void 0!==e&&("object"!=typeof e||null===e))throw new TypeError(`"params" must be an object if provided, received ${e}`);if(void 0!==t&&"string"!=typeof t)throw new TypeError(`"type" must be a valid GamepadHapticEffectType string if provided, received ${t}`);const r=this.#ln;if(!r)return new Promise(e=>e("complete"));const n=r.vibrationActuator;return n instanceof GamepadHapticActuator?n.playEffect(t??this.#Zn.type,{...this.#Zn.params,...e}):new Promise(e=>e("complete"))}ignoreId(e){if("string"!=typeof e||""===e.trim())throw new TypeError(`"id" must be a non-empty string, received ${e}`);this.#fn.add(e)}unignoreId(e){if("string"!=typeof e||""===e.trim())throw new TypeError(`"id" must be a non-empty string, received ${e}`);this.#fn.delete(e)}onConnected(e){return this.#Gn("",e,"connected")}onceConnected(e){return this.#Yn("",e,"connected")}prependConnected(e){return this.#Qn("",e,"connected")}offConnected(e){return this.#Xn("",e,"connected")}offAllConnected(){this.#an.delete("connected")}onDisconnected(e){return this.#Gn("",e,"disconnected")}onceDisconnected(e){return this.#Yn("",e,"disconnected")}prependDisconnected(e){return this.#Qn("",e,"disconnected")}offDisconnected(e){return this.#Xn("",e,"disconnected")}offAllDisconnected(){this.#an.delete("disconnected")}hasGamepad(){return this.#ln instanceof Gamepad}getGamepad(){if(!this.#ln)throw new Error("No gamepad is currently connected.");return this.#ln}hasLastButtonState(e){return!!this.#un[e]}getLastButtonState(e){if(!this.#un[e])throw new Error(`No last button state found for index ${e}`);return{...this.#un[e]}}exportConfig(){return{expectedId:this.#yn,ignoreIds:Array.from(this.#fn),deadZone:this.#gn,timeoutComboKeys:this.#vn,axisActiveSensitivity:this.#En,inputMap:Array.from(this.#on.entries())}}importConfig(e){if("string"!=typeof e&&("object"!=typeof e||null===e))throw new TypeError(`"json" must be a string or a non-null object, received: ${e}`);const t="string"==typeof e?JSON.parse(e):e;if(void 0!==t.expectedId&&"string"!=typeof t.expectedId&&null!==t.expectedId)throw new TypeError('"expectedId" must be a string or null if provided');if(void 0!==t.ignoreIds&&!Array.isArray(t.ignoreIds))throw new TypeError('"ignoreIds" must be an array if provided');if(void 0!==t.deadZone&&"number"!=typeof t.deadZone)throw new TypeError('"deadZone" must be a number if provided');if(void 0!==t.timeoutComboKeys&&"number"!=typeof t.timeoutComboKeys)throw new TypeError('"timeoutComboKeys" must be a number if provided');if(void 0!==t.axisActiveSensitivity&&"number"!=typeof t.axisActiveSensitivity)throw new TypeError('"axisActiveSensitivity" must be a number if provided');if(void 0!==t.inputMap&&!Array.isArray(t.inputMap))throw new TypeError('"inputMap" must be an array if provided');void 0!==t.expectedId&&(this.#yn=t.expectedId),Array.isArray(t.ignoreIds)&&(this.#fn=new Set(t.ignoreIds)),"number"==typeof t.deadZone&&(this.#gn=t.deadZone),"number"==typeof t.timeoutComboKeys&&(this.#vn=t.timeoutComboKeys),"number"==typeof t.axisActiveSensitivity&&(this.#En=t.axisActiveSensitivity),Array.isArray(t.inputMap)&&(this.#on=new Map(t.inputMap))}get mappedKeyStartCalls(){const e=this.#an.get("mapped-key-start");return Array.isArray(e)?[...e]:[]}get mappedKeyEndCalls(){const e=this.#an.get("mapped-key-end");return Array.isArray(e)?[...e]:[]}get comboMappedKeys(){return[...this.#An]}get comboMappedInputs(){return[...this.#Tn]}get keySequenceSize(){return this.#Nn.size}get keySequences(){const e=[];for(const[,t]of this.#Nn.entries())e.push(t.callback);return e}get activeMappedKeys(){return[...this.#Mn]}get mappedInputStartCalls(){const e=this.#an.get("mapped-input-start");return Array.isArray(e)?[...e]:[]}get mappedInputEndCalls(){const e=this.#an.get("mapped-input-end");return Array.isArray(e)?[...e]:[]}get inputSequenceSize(){return this.#Ln.size}get inputSequences(){const e=[];for(const[,t]of this.#Ln.entries())e.push(t.callback);return e}get activeMappedInputs(){return[...this.#kn]}get mappedInputs(){const e={};for(const[t,r]of this.#on.entries())e[t]=r;return e}get mappedInputSize(){return this.#on.size}get connectedCalls(){const e=this.#an.get("connected");return Array.isArray(e)?[...e]:[]}get disconnectedCalls(){const e=this.#an.get("disconnected");return Array.isArray(e)?[...e]:[]}get ignoredDeviceIds(){return[...this.#fn]}get heldKeys(){return[...this.#sn]}get eventsSize(){let e=0;return this.#an.forEach(t=>{e+=t.length}),e}get callSize(){return this.#an.size}get connectedCallSize(){const e=this.#an.get("connected");return Array.isArray(e)?e.length:0}get disconnectedCallSize(){const e=this.#an.get("disconnected");return Array.isArray(e)?e.length:0}get mappedKeyStartCallSize(){const e=this.#an.get("mapped-key-start");return Array.isArray(e)?e.length:0}get mappedKeyEndCallSize(){const e=this.#an.get("mapped-key-end");return Array.isArray(e)?e.length:0}get mappedInputStartCallSize(){const e=this.#an.get("mapped-input-start");return Array.isArray(e)?e.length:0}get mappedInputEndCallSize(){const e=this.#an.get("mapped-input-end");return Array.isArray(e)?e.length:0}get lastButtonStates(){const e=[];return this.#un.forEach(t=>{e.push({...t})}),e}get lastAxes(){return[...this.#hn]}get inputMode(){return this.#mn}get elementBase(){return this.#bn}get timeComboInputs(){return this.#Sn}get timeComboKeys(){return this.#Cn}get timeMappedInputs(){return this.#xn}get timeoutComboKeys(){return this.#vn}set timeoutComboKeys(e){if("number"!=typeof e||e<0||!Number.isFinite(e))throw new TypeError("Timeout combo keys must be a non-negative finite number.");this.#vn=e}get axisActiveSensitivity(){return this.#En}set axisActiveSensitivity(e){if("number"!=typeof e||e<0||e>1)throw new RangeError("Axis sensitivity must be a number between 0 and 1.");this.#En=e}get deadZone(){return this.#gn}set deadZone(e){if("number"!=typeof e||e<0||e>1)throw new RangeError("Dead zone must be a number between 0 and 1.");this.#gn=e}get expectedId(){return this.#yn}set expectedId(e){if("string"!=typeof e)throw new TypeError("Expected device id be a string.");this.#yn=e}get isDestroyed(){return this.#fr}destroy(){this.#fr||(this.#fr=!0,this.#dn&&cancelAnimationFrame(this.#dn),this.#pn&&cancelAnimationFrame(this.#pn),this.#dn=null,this.#pn=null,["keyboard-only","both"].includes(this.#mn)&&(this.#bn.removeEventListener("keydown",this.#qn),this.#bn.removeEventListener("keyup",this.#Vn),this.#wn&&(this.#bn.removeEventListener("mousedown",this.#Un),this.#bn.removeEventListener("mouseup",this.#Kn),this.#bn.removeEventListener("mousemove",this.#Jn))),["gamepad-only","both"].includes(this.#mn)&&(window.removeEventListener("gamepadconnected",this.#On),window.removeEventListener("gamepaddisconnected",this.#$n)),this.resetComboMapped(),this.#on.clear(),this.#an.clear(),this.#sn.clear(),this.#kn.clear(),this.#Mn.clear(),this.#Ln.clear(),this.#Nn.clear(),this.#fn.clear(),this.#Dn.clear(),this.#un=[],this.#hn=[],this.#cn={},this.#ln=null,this.#yn=null,this.#wn=!1,this.#xn=0)}}const lr=ar,ur=class{#ei=!0;#ti=86400;#ri=3600;#ni=60;#ii=new Map;#si=[];#oi;#ai;#li={main:null};#ui=0;#ci=0;#hi=0;#di="";#pi=1;#mi=1;#fi=1;#fr=!1;#gi=[31,31,31,31,31,31,31,31,31,31,31,31];#yi={default:{},day:{},night:{},hours:{},seasons:{}};#wi={min:60,max:180};#bi=0;get daySize(){return this.#ti}get autoSizeAdjuste(){return this.#ei}set autoSizeAdjuste(e){if("boolean"!=typeof e)throw new TypeError("autoSizeAdjuste must be a boolean.");this.#ei=e}set daySize(e){if("number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("daySize must be a positive finite number.");const t=this.#ri/this.#ti,r=this.#ni/this.#ti;this.#ti=e,this.#ei&&(this.#ri=e*t,this.#ni=e*r)}get hourSize(){return this.#ri}set hourSize(e){if("number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("hourSize must be a positive finite number.");const t=this.#ti/this.#ri,r=this.#ni/this.#ri;this.#ri=e,this.#ei&&(this.#ti=e*t,this.#ni=e*r)}get minuteSize(){return this.#ni}set minuteSize(e){if("number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("minuteSize must be a positive finite number.");const t=this.#ri/this.#ni,r=this.#ti/this.#ni;this.#ni=e,this.#ei&&(this.#ri=e*t,this.#ti=e*r)}get isDestroyed(){return this.#fr}get currentSeconds(){return this.#ui}set currentSeconds(e){if(this._checkDestroyed(),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("currentSeconds must be a finite number, received "+typeof e);if(e<0||e>=this.#ti)throw new RangeError(`currentSeconds must be between 0 and 86399, received ${e}`);this.#ui=Math.floor(e),this.#ci=Math.floor(e/this.#ni),this.#hi=Math.floor(e/this.#ri)}get currentMinutes(){return this.#ci}set currentMinutes(e){if(this._checkDestroyed(),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("currentMinutes must be a finite number, received "+typeof e);if(e<0||e>=1440)throw new RangeError(`currentMinutes must be between 0 and 1439, received ${e}`);this.#ci=Math.floor(e),this.#hi=Math.floor(e/this.#ni),this.#ui=Math.floor(e*this.#ni)}get currentHours(){return this.#hi}set currentHours(e){if(this._checkDestroyed(),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("currentHours must be a finite number, received "+typeof e);if(e<0||e>=24)throw new RangeError(`currentHours must be between 0 and less than 24, received ${e}`);this.#hi=Math.floor(e),this.#ci=Math.floor(e*this.#ni),this.#ui=Math.floor(e*this.#ri)}get moons(){return this.#si.map(e=>this.getMoon(e))}get seasons(){return Array.from(this.#ii.keys())}get dayStart(){return this.#oi}get nightStart(){return this.#ai}get weather(){return{...this.#li}}get currentSeason(){return this.#di}get currentDay(){return this.#pi}get currentMonth(){return this.#mi}get currentYear(){return this.#fi}get monthDays(){return[...this.#gi]}get weatherDuration(){return{...this.#wi}}get weatherTimeLeft(){return this.#bi}set dayStart(e){if(this._checkDestroyed(),"number"!=typeof e||e<1)throw new TypeError("dayStart must be a positive non-zero number, received "+typeof e);this.#oi=e}set nightStart(e){if(this._checkDestroyed(),"number"!=typeof e||e<1)throw new TypeError("nightStart must be a positive non-zero number, received "+typeof e);this.#ai=e}set weather(e){if(this._checkDestroyed(),"object"!=typeof e||null===e||Array.isArray(e)||!Object.values(e).every(e=>"string"==typeof e))throw new TypeError("weather must be a object with strings, received "+typeof e);this.#li=e}set currentSeason(e){if(this._checkDestroyed(),"string"!=typeof e||!this.#ii.has(e))throw new TypeError(`currentSeason must be one of ${Array.from(this.#ii).map(e=>e[0]).join(", ")}, received ${e}`);this.#di=e}set currentDay(e){if(this._checkDestroyed(),"number"!=typeof e||e<1||e>this.#gi[this.#mi-1])throw new TypeError("currentDay must be a valid day number, received "+typeof e);this.#pi=e}set currentMonth(e){if(this._checkDestroyed(),"number"!=typeof e||"number"!=typeof this.#gi[e-1])throw new TypeError("currentMonth must be a valid month number, received "+typeof e);this.#mi=e}set currentYear(e){if(this._checkDestroyed(),"number"!=typeof e||e<1)throw new TypeError("currentYear must be a positive number non-zero, received "+typeof e);this.#fi=e}set monthDays(e){if(this._checkDestroyed(),!Array.isArray(e))throw new TypeError("monthDays must be a array");if(!e.every(e=>"number"==typeof e))throw new TypeError("monthDays must have number values");this.#gi=[...e]}set weatherDuration(e){if(this._checkDestroyed(),"object"!=typeof e||null===e)throw new TypeError("weatherDuration must be a non-null object");if("number"!=typeof e.min||"number"!=typeof e.max)throw new TypeError("weatherDuration.min and weatherDuration.max must be numbers");this.#wi={...e}}set weatherTimeLeft(e){if(this._checkDestroyed(),"number"!=typeof e)throw new TypeError("weatherTimeLeft must be a number, received "+typeof e);this.#bi=e}get weatherConfig(){const e={},t={};for(const t in this.#yi.hours)e[t]={...this.#yi.hours[t]};for(const e in this.#yi.seasons)t[e]={...this.#yi.seasons[e]};return{default:{...this.#yi.default},day:{...this.#yi.day},night:{...this.#yi.night},hours:e,seasons:t}}set weatherConfig(e){if(this._checkDestroyed(),"object"!=typeof e||null===e)throw new TypeError(`weatherConfig must be a non-null object, received ${e}`);const t=["default","day","night","hours","seasons"];for(const r of t)if(!(r in e))throw new TypeError(`weatherConfig is missing required property "${r}".`);const r={},n={},i=(e,t)=>{if("object"!=typeof e||null===e)throw new TypeError(`${t} must be an object, received ${e}`);for(const r in e){const n=typeof e[r];if("number"!==n&&"function"!==n)throw new TypeError(`${t}["${r}"] must be a number or function, received ${n}`)}};for(const t in e.hours)i(e.hours[t],`hours["${t}"]`),r[t]={...e.hours[t]};for(const t in e.seasons)i(e.seasons[t],`seasons["${t}"]`),n[t]={...e.seasons[t]};const s=(e,t)=>(i(e,t),{...e});this.#yi={default:s(e.default,"default"),day:s(e.day,"day"),night:s(e.night,"night"),hours:r,seasons:n}}constructor(e=6,t=18){this.#oi=e,this.#ai=t}addSeason(e,t){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);if(!Array.isArray(t)||!t.every(e=>"number"==typeof e))throw new TypeError("Season values must be an array of numbers");this.#ii.set(e,t)}removeSeason(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);this.#ii.delete(e),this.#di===e&&(this.#di="")}hasSeason(e){if("string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);return this.#ii.has(e)}getSeason(e){if("string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);const t=this.#ii.get(e);if(!t)throw new Error(`Season "${e}" not found`);return[...t]}setTime({hour:e=0,minute:t=0,second:r=0}){this._checkDestroyed(),this.currentSeconds=(e*this.#ri+t*this.#ni+r)%this.#ti}addTime({hours:e=0,minutes:t=0,seconds:r=0}){this._checkDestroyed();let n=this.currentSeconds+e*this.#ri+t*this.#ni+r;for(;n>=this.#ti;)n-=this.#ti,this.nextDay();for(;n<0;)n+=this.#ti,this.prevDay();this.currentSeconds=n,this.updateWeatherTimer((e*this.#ri+t*this.#ni+r)/this.#ni)}getTime({withSeconds:e=!1,hourSize:t=this.#ri,minuteSize:r=this.#ni}={}){const n=Math.floor(this.currentSeconds/t),i=Math.floor(this.currentSeconds%t/r),s=this.currentSeconds%r;return{hour:n,minute:i,second:s,formatted:`${n.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`+(e?`:${s.toString().padStart(2,"0")}`:"")}}isDay(){return this.#oi<this.#ai?this.#ci>=this.#oi*this.#ni&&this.#ci<this.#ai*this.#ni:this.#ci>=this.#oi*this.#ni||this.#ci<this.#ai*this.#ni}minutesUntilDay(){return this.timeUntil(this.#oi,"minutes")}secondsUntilDay(){return this.timeUntil(this.#oi,"seconds")}hoursUntilDay(){return this.timeUntil(this.#oi,"hours")}minutesUntilNight(){return this.timeUntil(this.#ai,"minutes")}secondsUntilNight(){return this.timeUntil(this.#ai,"seconds")}hoursUntilNight(){return this.timeUntil(this.#ai,"hours")}timeUntil(e,t){this._checkDestroyed();let r=e*this.#ri-this.#ui;switch(r<=0&&(r+=this.#ti),t){case"minutes":return r/this.#ni;case"hours":return r/this.#ri;default:return r}}setTo(e){this._checkDestroyed(),"day"===e?this.setTime({hour:this.#oi}):"night"===e&&this.setTime({hour:this.#ai})}nextDay(e=1){this._checkDestroyed();for(let t=0;t<e;t++){this.#pi++;const e=this.#gi[this.#mi-1];if(Number.isNaN(e)||!Number.isFinite(e))throw new Error("Invalid month day count: monthDays must be a finite number.");this.#pi>e&&(this.#pi=1,this.#mi++,this.#mi>this.#gi.length&&(this.#mi=1,this.#fi++)),this.updateSeason(),this.advanceMoons(1)}}prevDay(e=1){this._checkDestroyed();for(let t=0;t<e;t++)this.#pi--,this.#pi<1&&(this.#mi--,this.#mi<1&&(this.#mi=this.#gi.length,this.#fi--),this.#pi=this.#gi[this.#mi-1]||30),this.updateSeason(),this.rewindMoons(1)}updateSeason(){this._checkDestroyed(),this.#ii.forEach((e,t)=>{e.includes(this.#mi)&&(this.#di=t)})}setWeatherConfig(e){this._checkDestroyed(),this.#yi={...this.#yi,...e}}setWeatherDuration(e,t){this._checkDestroyed(),this.#wi.min=e,this.#wi.max=t}updateWeatherTimer(e){this._checkDestroyed(),this.#bi-=e,this.#bi<=0&&this.chooseNewWeather()}forceWeather({where:e="main",type:t,duration:r=null}){this._checkDestroyed();const n=this.#li;n[e]=t,this.weather=n,this.#bi=r??this._randomInRange(this.#wi.min,this.#wi.max)}chooseNewWeather({customWeather:e,where:t="main"}={}){this._checkDestroyed();let r={};const n=e=>{for(const[t,n]of Object.entries(e)){let e=n;"function"==typeof e&&(e=e({hour:Math.floor(this.#ci/this.#ni),minute:this.#ci%this.#ni,currentMinutes:this.#ci,isDay:this.isDay(),season:this.#di,weather:this.#li})),"number"!=typeof e||Number.isNaN(e)||(r[t]=(r[t]||0)+e)}};n(this.#yi.default||{});for(const e in this.#yi.hours){const[t,r]=e.split("-").map(e=>{const[t,r]=e.split(":").map(Number);return t*this.#ni+(r||0)}),i=this.#ci;(t<=r?i>=t&&i<=r:i>=t||i<=r)&&n(this.#yi.hours[e])}this.isDay()&&this.#yi.day?n(this.#yi.day):!this.isDay()&&this.#yi.night&&n(this.#yi.night),this.#yi.seasons?.[this.#di]&&n(this.#yi.seasons[this.#di]),e&&"object"==typeof e&&n(e);const i=Object.entries(r).filter(([,e])=>e>0);if(!i.length)return this.#li[t]=null,null;const s=i.reduce((e,[,t])=>e+t,0);let o=Math.random()*s;for(const[e,r]of i){if(o<r)return this.#li[t]=e,this.#bi=this._randomInRange(this.#wi.min,this.#wi.max),e;o-=r}return this.#li[t]=null,null}_randomInRange(e,t){return Math.floor(Math.random()*(t-e+1))+e}addMoon(e,t,r,n=0){this._checkDestroyed();const i=Math.max(1,t);return this.#si.push({name:e,cycleLength:i,currentPhase:(n%i+i)%i,phaseNames:r}),this.#si.length-1}removeMoon(e){this._checkDestroyed(),this.#si=this.#si.filter(t=>t.name!==e)}advanceMoons(e=1){for(const t in this.#si)this.advanceMoon(parseInt(t),e)}rewindMoons(e=1){for(const t in this.#si)this.rewindMoon(parseInt(t),e)}advanceMoon(e,t=1){this._checkDestroyed();const r=this.#si[e];if(!r)throw new RangeError(`No moon found at index ${e}`);r.currentPhase=(r.currentPhase+t)%r.cycleLength}rewindMoon(e,t=1){this._checkDestroyed();const r=this.#si[e];if(!r)throw new RangeError(`No moon found at index ${e}`);r.currentPhase=(r.currentPhase-t+r.cycleLength)%r.cycleLength}moonExists(e){return!!this.#si[e]}getMoon(e){let t;if("number"==typeof e){if(t=this.#si[e],!t)throw new RangeError(`No moon found at index ${e}`)}else{if(!e||"object"!=typeof e||"string"!=typeof e.name||"number"!=typeof e.cycleLength||"number"!=typeof e.currentPhase)throw new TypeError("Invalid moon reference. Expected a number index or a MoonRaw object, received "+typeof e);t=e}return{name:t.name,phaseIndex:t.currentPhase,phaseName:t.phaseNames?t.phaseNames[t.currentPhase]??String(t.currentPhase):String(t.currentPhase),cycleLength:t.cycleLength}}_checkDestroyed(){if(this.#fr)throw new Error("This instance has been destroyed and can no longer be used.")}destroy(){this.#fr||(this.#ii.clear(),this.#si.length=0,this.#oi=0,this.#ai=0,this.#ui=0,this.#ci=0,this.#hi=0,this.#pi=1,this.#mi=1,this.#fi=1,this.#bi=0,this.#di="",this.#li={main:null},this.#gi=[],this.#yi.default={},this.#yi.day={},this.#yi.night={},this.#yi.hours={},this.#yi.seasons={},this.#wi={min:0,max:0},this.#fr=!0)}};class cr{#It=new zt;#Fn(e,...t){return this.#It.emit(e,...t)}setThrowOnMaxListeners(e){return this.#It.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#It.getThrowOnMaxListeners()}prependListener(e,t){return this.#It.prependListener(e,t)}prependListenerOnce(e,t){return this.#It.prependListenerOnce(e,t)}appendListener(e,t){return this.#It.appendListener(e,t)}appendListenerOnce(e,t){return this.#It.appendListenerOnce(e,t)}on(e,t){return this.#It.on(e,t)}once(e,t){return this.#It.once(e,t)}off(e,t){return this.#It.off(e,t)}offAll(e){return this.#It.offAll(e)}offAllTypes(){return this.#It.offAllTypes()}listenerCount(e){return this.#It.listenerCount(e)}listeners(e){return this.#It.listeners(e)}onceListeners(e){return this.#It.onceListeners(e)}allListeners(e){return this.#It.allListeners(e)}eventNames(){return this.#It.eventNames()}setMaxListeners(e){return this.#It.setMaxListeners(e)}getMaxListeners(){return this.#It.getMaxListeners()}#fr=!1;#vi;#Ei;#Ti=[];#Si=[];#xi=[];#Ai=new Map;#Ci=new Set;#Ii=new Map;#Mi;#ki=new Map;#Li=new Map;get isDestroyed(){return this.#fr}get freq(){return Object.fromEntries(this.#Li)}get size(){return this.#ki.size}get normalization(){return this.#vi}set normalization(e){if(this._checkDestroyed(),"string"!=typeof e||!e.trim())throw new TypeError("normalization must be a non-empty string (e.g., 'relative', 'softmax').");this.#vi=e}get seed(){return this.#Ei}set seed(e){if(this._checkDestroyed(),null!==e&&("number"!=typeof e||!Number.isFinite(e)))throw new TypeError("seed must be a finite number or null.");this.#Ei=e,null!==e&&(this.#Mi=this._makeSeededRng(e))}get globalModifiers(){return[...this.#Ti]}set globalModifiers(e){if(this._checkDestroyed(),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("globalModifiers must be an array of functions (WeightsCallback).");this.#Ti=e}get temporaryModifiers(){return[...this.#Si]}set temporaryModifiers(e){if(this._checkDestroyed(),!Array.isArray(e)||!e.every(e=>e&&"function"==typeof e.fn&&Number.isInteger(e.uses)&&e.uses>0))throw new TypeError("temporaryModifiers must be an array of objects { fn: function, uses: positive integer }.");this.#Si=e}get conditionalRules(){return[...this.#xi]}set conditionalRules(e){if(this._checkDestroyed(),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("conditionalRules must be an array of functions (WeightsCallback).");this.#xi=e}get pitySystems(){return Object.fromEntries(this.#Ai)}set pitySystems(e){if(this._checkDestroyed(),!(e instanceof Map&&[...e.values()].every(e=>e&&"number"==typeof e.threshold&&"number"==typeof e.increment&&"number"==typeof e.cap&&"number"==typeof e.counter&&"number"==typeof e.currentAdd)))throw new TypeError("pitySystems must be a Map<string, Pity> with all numeric fields.");this.#Ai=e}get exclusions(){return Array.from(this.#Ci)}set exclusions(e){if(this._checkDestroyed(),!(e instanceof Set&&[...e].every(e=>"string"==typeof e)))throw new TypeError("exclusions must be a Set<string>.");this.#Ci=e}get groups(){const e={};return this.#Ii.forEach((t,r)=>e[r]=Array.from(t)),e}set groups(e){if(this._checkDestroyed(),!(e instanceof Map&&[...e.values()].every(e=>e instanceof Set&&[...e].every(e=>"string"==typeof e))))throw new TypeError("groups must be a Map<string, Set<string>>.");this.#Ii=e}get rng(){return this.#Mi}set rng(e){if(this._checkDestroyed(),"function"!=typeof e||"number"!=typeof e())throw new TypeError("rng must be a function returning a number (RngGenerator).");this.#Mi=e}get items(){const e={};return this.#ki.forEach((t,r)=>{e[r]={...t,groups:Array.from(t.groups)}}),e}set items(e){if(this._checkDestroyed(),!(e instanceof Map&&[...e.values()].every(e=>e&&"string"==typeof e.id&&"string"==typeof e.label&&"number"==typeof e.baseWeight&&e.groups instanceof Set&&"boolean"==typeof e.locked&&"object"==typeof e.meta)))throw new TypeError("items must be a Map<string, ItemData> with valid item structures.");this.clearList(),this.#ki=e}constructor(e={}){const{rng:t=null,seed:r=null,normalization:n="relative"}=e;this.#vi=n,this.#Ei=r,"function"==typeof t?this.#Mi=t:null!==this.#Ei?this.#Mi=this._makeSeededRng(this.#Ei):this.#Mi=Math.random,this.#Ei=r??null}_checkDestroyed(){if(this.#fr)throw new Error("This instance has been destroyed and can no longer be used.")}hasItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string");return this.#ki.has(e)}addItem(e,t={}){if(this._checkDestroyed(),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");if("object"!=typeof t||null===t)throw new TypeError("opts must be an object");let{weight:r=1,label:n=e,meta:i={},groups:s=[]}=t;if("number"!=typeof r||!Number.isFinite(r)||r<0)throw new TypeError("weight must be a non-negative number");if("string"!=typeof n)throw new TypeError("label must be a string");if("object"!=typeof i||null===i)throw new TypeError("meta must be an object");if(!(Array.isArray(s)||s instanceof Set))throw new TypeError("groups must be an array or a Set of strings");s=Array.isArray(s)?s:[...s];for(const e of s)if("string"!=typeof e)throw new TypeError("groups must contain only strings");const o={id:e,label:n,baseWeight:Math.max(0,Number(r)||0),meta:{...i},groups:new Set(s),locked:!1};this.#ki.set(e,o);for(const t of s)this._ensureGroup(t).add(e);return this.#Fn("itemAdded",o),o}removeItem(e){if(this._checkDestroyed(),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");const t=this.#ki.get(e);if(!t)return!1;for(const r of t.groups){const t=this.#Ii.get(r);t&&t.delete(e)}return this.#ki.delete(e),this.#Fn("itemRemoved",e),this.resetFreq(e),this.resetPity(e),!0}setBaseWeight(e,t){if(this._checkDestroyed(),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");if("number"!=typeof t||!Number.isFinite(t)||t<0)throw new TypeError("weight must be a non-negative number");const r=this.#ki.get(e);if(!r)throw new Error("Item not found");r.baseWeight=Math.max(0,Number(t)||0),this.#Fn("weightChanged",{id:e,weight:r.baseWeight})}getItem(e){if("string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");return this.#ki.get(e)??null}listItems(){return Array.from(this.#ki.values()).map(e=>({...e}))}clearList(){this._checkDestroyed(),this.#ki.clear(),this.clearFreqs(),this.clearPities()}hasGlobalModifier(e){if("function"!=typeof e)throw new TypeError("fn must be a function");return this.#Ti.includes(e)}addGlobalModifier(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");this.#Ti.push(e)}removeGlobalModifier(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");this.#Ti=this.#Ti.filter(t=>t!==e)}hasTemporaryModifier(e){if("function"!=typeof e)throw new TypeError("fn must be a function");return this.#Si.some(t=>t.fn===e)}addTemporaryModifier(e,t=1){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");if("number"!=typeof t||Number.isNaN(t))throw new TypeError("uses must be a number");this.#Si.push({fn:e,uses:Math.max(1,Math.floor(t))})}removeTemporaryModifier(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");const t=this.#Si.length;return this.#Si=this.#Si.filter(t=>t.fn!==e),this.#Si.length!==t}hasConditionalRule(e){if("function"!=typeof e)throw new TypeError("ruleFn must be a function");return this.#xi.includes(e)}addConditionalRule(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("ruleFn must be a function");this.#xi.push(e)}removeConditionalRule(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("ruleFn must be a function");const t=this.#xi.length;return this.#xi=this.#xi.filter(t=>t!==e),this.#xi.length!==t}hasPity(e){if("string"!=typeof e)throw new TypeError("itemId must be a string");return this.#Ai.has(e)}configurePity(e,t){if(this._checkDestroyed(),!this.#ki.has(e))throw new Error("Item not found");if("object"!=typeof t||null===t)throw new TypeError("cfg must be an object");const{threshold:r,increment:n,cap:i=1/0}=t;if("number"!=typeof r||r<=0)throw new TypeError("threshold must be a positive number");if("number"!=typeof n)throw new TypeError("increment must be a number");if("number"!=typeof i)throw new TypeError("cap must be a number");this.#Ai.set(e,{threshold:Math.max(1,r),increment:Number(n)||0,cap:Number(i)||1/0,counter:0,currentAdd:0})}resetPity(e){if(this._checkDestroyed(),"string"!=typeof e||!e.trim())throw new TypeError("itemId must be a non-empty string");const t=this.#Ai.get(e);t&&(t.counter=0,t.currentAdd=0)}clearPities(){this._checkDestroyed(),this.#Ai.clear()}hasExclusion(e){if("string"!=typeof e)throw new TypeError("itemId must be a string");return this.#Ci.has(e)}excludeItem(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#Ci.add(e)}includeItem(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#Ci.delete(e)}_ensureGroup(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("name must be a string");let t=this.#Ii.get(e);return t||(t=new Set,this.#Ii.set(e,t)),t}hasInGroup(e,t){if("string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#Ii.get(t);return!!r&&r.has(e)}addToGroup(e,t){if(this._checkDestroyed(),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#ki.get(e);if(!r)throw new Error("Item missing");r.groups.add(t),this._ensureGroup(t).add(e)}removeFromGroup(e,t){if(this._checkDestroyed(),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#Ii.get(t);r&&r.delete(e);const n=this.#ki.get(e);n&&n.groups.delete(t)}clearFreqs(){this._checkDestroyed(),this.#Li.clear()}resetFreq(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#Li.delete(e)}computeEffectiveWeights(e={}){if(this._checkDestroyed(),"object"!=typeof e||null===e)throw new TypeError("computeEffectiveWeights: parameter 'context' must be a non-null object, got "+typeof e);if("previousDraws"in e&&!Array.isArray(e.previousDraws))throw new TypeError("computeEffectiveWeights: context.previousDraws must be an array if provided, got "+typeof e.previousDraws);if("metadata"in e&&void 0!==e.metadata&&("object"!=typeof e.metadata||null===e.metadata))throw new TypeError("computeEffectiveWeights: context.metadata must be a non-null object if provided, got "+typeof e.metadata);const t=new Map;for(const[e,r]of this.#ki)t.set(e,r.baseWeight);for(const r of this.#Ti){const n=r(t,e);if(n instanceof Map)for(const[e,r]of n)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const r of this.#Si){const n=r.fn(t,e);if(n instanceof Map)for(const[e,r]of n)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const r of this.#xi){const n=r(t,e);if(n instanceof Map)for(const[e,r]of n)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const[e,r]of this.#Ai)if(t.has(e)&&r.counter>r.threshold){r.currentAdd=Math.min(r.cap,r.currentAdd+r.increment);const n=t.get(e);n&&t.set(e,n+r.currentAdd)}for(const e of this.#Ci)t.delete(e);for(const[e,r]of Array.from(t.entries()))r>0||t.delete(e);return t}_weightsToDistribution(e){if(this._checkDestroyed(),!(e instanceof Map))throw new TypeError("_weightsToDistribution: parameter 'weights' must be a Map, got "+typeof e);for(const[t,r]of e){if("string"!=typeof t)throw new TypeError("_weightsToDistribution: weights Map key must be string, got "+typeof t);if("number"!=typeof r||!Number.isFinite(r)||r<0)throw new TypeError(`_weightsToDistribution: weights Map value must be finite non-negative number, got ${r} for key ${t}`)}const t=Array.from(e.entries()).map(([e,t])=>({id:e,weight:t}));if(0===t.length)return[];if("softmax"===this.#vi){const e=Math.max(...t.map(e=>e.weight)),r=t.map(t=>Math.exp(t.weight-e)),n=r.reduce((e,t)=>e+t,0);let i=0;return t.map((e,t)=>{const s=r[t]/n;return i+=s,{id:e.id,weight:e.weight,p:s,cumulative:i}})}{const e=t.reduce((e,t)=>e+t.weight,0);let r=0;return t.map(t=>{const n=t.weight/e;return r+=n,{id:t.id,weight:t.weight,p:n,cumulative:r}})}}drawOne(e={}){if(this._checkDestroyed(),"object"!=typeof e||null===e)throw new TypeError("drawOne: parameter 'opts' must be a non-null object, got "+typeof e);if("previousDraws"in e&&!Array.isArray(e.previousDraws))throw new TypeError("drawOne: opts.previousDraws must be an array if provided, got "+typeof e.previousDraws);if("metadata"in e&&void 0!==e.metadata&&("object"!=typeof e.metadata||null===e.metadata))throw new TypeError("drawOne: opts.metadata must be a non-null object if provided, got "+typeof e.metadata);const t={previousDraws:e.previousDraws??[],metadata:e.metadata??{},activeModifiers:[...this.#Si]},r=this.computeEffectiveWeights(t),n=this._weightsToDistribution(r);if(!n.length)return null;const i=this.#Mi(),s=n.find(e=>i<=e.cumulative)??n[n.length-1];for(const[e,t]of this.#Ai)e===s.id?(t.counter=0,t.currentAdd=0):t.counter++;this._consumeTemporaryModifiers();const o=this.#ki.get(s.id);if(!o)return null;const a={id:o.id,label:o.label,meta:{...o.meta},prob:s.p};return this.#Fn("draw",a),a&&this.#Li.set(a.id,(this.#Li.get(a.id)||0)+1),a}_consumeTemporaryModifiers(){this._checkDestroyed();for(let e=this.#Si.length-1;e>=0;--e){const t=this.#Si[e];t.uses-=1,t.uses<=0&&this.#Si.splice(e,1)}}drawMany(e=1,t={}){if(this._checkDestroyed(),!Number.isInteger(e)||e<=0)throw new TypeError(`drawMany: parameter 'count' must be a positive integer, got ${e}`);if("object"!=typeof t||null===t)throw new TypeError("drawMany: parameter 'opts' must be a non-null object, got "+typeof t);if("withReplacement"in t&&"boolean"!=typeof t.withReplacement)throw new TypeError("drawMany: opts.withReplacement must be boolean if provided, got "+typeof t.withReplacement);if("ensureUnique"in t&&"boolean"!=typeof t.ensureUnique)throw new TypeError("drawMany: opts.ensureUnique must be boolean if provided, got "+typeof t.ensureUnique);if("metadata"in t&&void 0!==t.metadata&&("object"!=typeof t.metadata||null===t.metadata))throw new TypeError("drawMany: opts.metadata must be a non-null object if provided, got "+typeof t.metadata);if("previousDraws"in t&&!Array.isArray(t.previousDraws))throw new TypeError("drawMany: opts.previousDraws must be an array if provided, got "+typeof t.previousDraws);const r=t.withReplacement??!0,n=t.ensureUnique??!1,i=[],s=t.previousDraws??[];if(!r&&n){const r=new Set;for(let n=0;n<e;++n){const e=new Set(this.#Ci);for(const e of r)this.#Ci.add(e);const n=this.drawOne({previousDraws:s,metadata:t.metadata});if(this.#Ci=e,!n)break;i.push(n),r.add(n.id),s.push(n)}return i}for(let n=0;n<e;++n){const e=this.drawOne({previousDraws:s,metadata:t.metadata});if(!e)break;i.push(e),s.push(e),r||this.excludeItem(e.id)}if(!r)for(const e of i)this.includeItem(e.id);return i}exportToJson(){return this._checkDestroyed(),{items:Array.from(this.#ki.values()).map(e=>({id:e.id,label:e.label,baseWeight:e.baseWeight,meta:e.meta,groups:Array.from(e.groups),locked:!1})),pity:Array.from(this.#Ai.entries()),exclusions:Array.from(this.#Ci),normalization:this.#vi,seed:this.#Ei}}loadFromJson(e){if(this._checkDestroyed(),"object"!=typeof e||null===e)throw new TypeError("data must be a non-null object");if(!Array.isArray(e.items)||!Array.isArray(e.pity)||!Array.isArray(e.exclusions))throw new TypeError("data must have items, pity, and exclusions arrays");if("string"!=typeof e.normalization)throw new TypeError("data.normalization must be a string");if(void 0!==e.seed&&null!==e.seed&&"number"!=typeof e.seed)throw new TypeError("data.seed must be a number, null, or undefined");this.clearList();for(const t of e.items){if("object"!=typeof t||null===t)throw new TypeError("Each item must be a non-null object");if("string"!=typeof t.id||!t.id.trim())throw new TypeError("Each item.id must be a non-empty string");if("string"!=typeof t.label)throw new TypeError(`Item with id "${t.id}" has invalid label; must be string`);if("number"!=typeof t.baseWeight||!Number.isFinite(t.baseWeight)||t.baseWeight<0)throw new TypeError(`Item with id "${t.id}" has invalid baseWeight; must be a finite non-negative number`);if(void 0!==t.groups&&!Array.isArray(t.groups))throw new TypeError(`Item with id "${t.id}" has invalid groups; must be an array of strings`);if(t.groups&&!t.groups.every(e=>"string"==typeof e))throw new TypeError(`Item with id "${t.id}" has groups containing non-string values`);if(void 0!==t.meta&&("object"!=typeof t.meta||null===t.meta))throw new TypeError(`Item with id "${t.id}" has invalid meta; must be an object`);this.#ki.set(t.id,{id:t.id,label:t.label,baseWeight:t.baseWeight,meta:t.meta||{},groups:new Set(t.groups||[]),locked:!1});for(const e of t.groups||[])this._ensureGroup(e).add(t.id)}this.pitySystems=new Map(e.pity||[]),this.exclusions=new Set(e.exclusions||[]),this.normalization=e.normalization,void 0!==e.seed&&(this.seed=e.seed)}clone(){this._checkDestroyed();const e=new cr;return e.#vi=this.#vi,e.#Ei=this.#Ei,e.#Ti=[...this.#Ti],e.#Si=this.#Si.map(e=>({fn:e.fn,uses:e.uses})),e.#xi=[...this.#xi],e.#Ai=new Map([...this.#Ai.entries()].map(([e,t])=>[e,{...t}])),e.#Ci=new Set(this.#Ci),e.#Ii=new Map([...this.#Ii.entries()].map(([e,t])=>[e,new Set(t)])),e.#Mi=this.#Mi,e.#ki=new Map([...this.#ki.entries()].map(([e,t])=>[e,{...t,groups:new Set(t.groups),meta:{...t.meta}}])),e.#Li=new Map(this.#Li),e}_makeSeededRng(e){if(this._checkDestroyed(),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("seed must be a finite number");let t=e>>>0;return function(){t+=1831565813;let e=Math.imul(t^t>>>15,1|t);return e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}destroy(){this.#fr||(this.#fr=!0,this.#Ai.clear(),this.#Ci.clear(),this.#Ii.clear(),this.#ki.clear(),this.#Li.clear(),this.#Ti=[],this.#Si=[],this.#xi=[],this.#Ei=null)}}const hr=cr,dr=class{#re;get data(){return this.#re}set data(e){if(!(Array.isArray(e)||e instanceof Set))throw new TypeError("Paginator expects an array or Set as data source.");this.#re=e}get size(){return Array.isArray(this.#re)?this.#re.length:this.#re.size}constructor(e){if(!(Array.isArray(e)||e instanceof Set))throw new TypeError("Paginator expects an array or Set as data source.");this.#re=e}get({page:e,perPage:t,filter:r}){if(!Number.isInteger(e)||e<1)throw new RangeError("Page number must be a positive integer.");if(!Number.isInteger(t)||t<1)throw new RangeError("Items per page must be a positive integer.");const n=Array.isArray(this.#re)?this.#re:Array.from(this.#re);let i=n;if(r)if("function"==typeof r)i=n.filter((e,t,n)=>r(e,t,n));else{if("object"!=typeof r)throw new TypeError("Filter must be an object or a function");i=n.filter(e=>Object.entries(r).every(([t,r])=>{const n=e[t];return r instanceof RegExp?r.test(n):n===r}))}else i=n;const s=i.length,o=Math.max(1,Math.ceil(s/t)),a=Math.min(e,o),l=(a-1)*t,u=l+t,c=a>1,h=a<o;return{items:i.slice(l,u),page:a,perPage:t,totalItems:s,totalPages:o,hasPrev:c,hasNext:h}}};class pr{static#Ni=new Map;static get itemRegistry(){const e={},t=Object.fromEntries(pr.#Ni);for(const r in t)e[r]={...t[r],metadata:{...t[r].metadata}};return e}static defineItem(e){if(!e||"object"!=typeof e)throw new TypeError("Config must be a valid object.");if(!e.id||"string"!=typeof e.id)throw new TypeError("Item must have a valid string 'id'.");if(void 0!==e.weight&&("number"!=typeof e.weight||e.weight<0))throw new TypeError(`weight must be a number >= 0. Received: ${e.weight}`);if(void 0!==e.maxStack&&(!Number.isInteger(e.maxStack)||e.maxStack<=0))throw new TypeError(`maxStack must be a positive integer. Received: ${e.maxStack}`);if(void 0!==e.metadata&&"object"!=typeof e.metadata)throw new TypeError("metadata must be an object.");if(void 0!==e.onUse&&null!==e.onUse&&"function"!=typeof e.onUse)throw new TypeError("onUse must be a function or null.");if(void 0!==e.type&&null!==e.type&&"string"!=typeof e.type)throw new TypeError("type must be a string or null.");pr.#Ni.set(e.id,{id:e.id,weight:e.weight||0,maxStack:e.maxStack||1,metadata:e.metadata||{},type:e.type??null,onUse:"function"==typeof e.onUse?e.onUse:null})}static removeItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");return pr.#Ni.delete(e)}static hasItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");return pr.#Ni.has(e)}static getItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");const t=pr.#Ni.get(e);if(!t)throw new Error(`Item '${e}' not defined in registry.`);return t}#Di=new Map;#It={add:[],remove:[],use:[],set:[]};#ki=[];#_i;#Ri;#ji;#Oi;get maxStack(){return this.#_i}set maxStack(e){if(!Number.isInteger(e)||Number.isFinite(e)&&e<=0)throw new TypeError(`maxStack must be a positive integer. Received: ${e}`);this.#_i=e}get maxSize(){return this.#Ri}set maxSize(e){if(null!==e&&(!Number.isInteger(e)||e<=0))throw new TypeError(`maxSize must be null or a positive integer. Received: ${e}`);this.#Ri=e}get maxSlots(){return this.#ji}set maxSlots(e){if(null!==e&&(!Number.isInteger(e)||e<=0))throw new TypeError(`maxSlots must be null or a positive integer. Received: ${e}`);this.#ji=e}get maxWeight(){return this.#Oi}set maxWeight(e){if(null!==e&&("number"!=typeof e||e<=0))throw new TypeError(`maxWeight must be null or a positive number. Received: ${e}`);this.#Oi=e}get events(){return{add:[...this.#It.add],remove:[...this.#It.remove],use:[...this.#It.use],set:[...this.#It.set]}}get items(){return[...this.#ki].map(e=>e?this.#Pi(e):null)}get specialSlots(){return new Map([...this.#Di.entries()].map(([e,t])=>[e,{type:t.type,item:t.item?this.#Pi(t.item):null}]))}get size(){const e=this.getAllItems();let t=0;for(const r of e)t+=r.quantity;return t}get slotsSize(){return this.getAllItems().length}get weight(){return this.getAllItems().reduce((e,t)=>{const r=pr.getItem(t.id);return e+(r?.weight||0)*t.quantity},0)}_cleanNulls(){let e=this.#ki.length-1;for(;e>=0&&null===this.#ki[e];)e--;this.#ki=this.#ki.slice(0,e+1)}constructor(e={}){if("object"!=typeof e||null===e)throw new TypeError("`options` must be an object.");if(void 0!==e.maxWeight&&null!==e.maxWeight&&"number"!=typeof e.maxWeight)throw new TypeError("`maxWeight` must be a number or null.");if(void 0!==e.maxSlots&&null!==e.maxSlots&&"number"!=typeof e.maxSlots)throw new TypeError("`maxSlots` must be a number or null.");if(void 0!==e.maxSize&&null!==e.maxSize&&"number"!=typeof e.maxSize)throw new TypeError("`maxSize` must be a number or null.");if(void 0!==e.maxStack&&"number"!=typeof e.maxStack)throw new TypeError("`maxStack` must be a number.");if(void 0!==e.specialSlots&&"object"!=typeof e.specialSlots)throw new TypeError("`specialSlots` must be an object if defined.");if(this.#Oi=e.maxWeight??null,this.#ji=e.maxSlots??null,this.#Ri=e.maxSize??null,this.#_i=e.maxStack??1/0,e.specialSlots)for(const t in e.specialSlots){const r=e.specialSlots[t];if("object"!=typeof r||null===r)throw new TypeError("Each `specialSlot` entry must be an object.");if(void 0!==r.type&&null!==r.type&&"string"!=typeof r.type)throw new TypeError("`specialSlot.type` must be a string or null.");this.#Di.set(t,{type:r.type??null,item:null})}}hasSpace({weight:e=0,sizeLength:t=0,slotsLength:r=0}={}){if("number"!=typeof e)throw new TypeError("`weight` must be a number.");if("number"!=typeof t)throw new TypeError("`sizeLength` must be a number.");if("number"!=typeof r)throw new TypeError("`slotsLength` must be a number.");return!(this.areFull(t)||this.areFullSlots(r)||this.isHeavy(e))}isHeavy(e=0){if("number"!=typeof e)throw new TypeError("`extraWeight` must be a number.");return null!==this.#Oi&&this.weight+e>this.#Oi}areFull(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Ri&&this.size+e>this.#Ri}isFull(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Ri&&this.size+e>=this.#Ri}areFullSlots(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#ji&&this.slotsSize+e>this.#ji}isFullSlots(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#ji&&this.slotsSize+e>=this.#ji}#$i(e,t){if("string"!=typeof e)throw new TypeError("`type` must be a string.");if("object"!=typeof t||null===t)throw new TypeError("`payload` must be an object.");if(this.#It[e])for(const r of this.#It[e])r(t)}off(e,t){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");if("function"!=typeof t)throw new TypeError("`callback` must be a function.");if(!this.#It[e])return;const r=this.#It[e],n=r.indexOf(t);-1!==n&&r.splice(n,1)}offAll(e){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");this.#It[e]&&(this.#It[e]=[])}cloneEventCallbacks(e){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");return this.#It[e]?[...this.#It[e]]:[]}onAddItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#It.add.push(e)}onSetItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#It.set.push(e)}onRemoveItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#It.remove.push(e)}onUseItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#It.use.push(e)}compactInventory(){this.#ki=this.#ki.filter((e,t)=>{const r=null!==e;return r||this.#$i("remove",{index:t,item:null,isCollection:!0,specialSlot:null,remove:()=>{}}),r})}addItem({itemId:e,quantity:t=1,metadata:r={},forceSpace:n=!1}){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");if("number"!=typeof t||!Number.isFinite(t)||t<=0)throw new TypeError("`quantity` must be a positive number.");if("object"!=typeof r||null===r)throw new TypeError("`metadata` must be an object.");if("boolean"!=typeof n)throw new TypeError("`forceSpace` must be a boolean.");const i=pr.getItem(e);let s=t;const o=i.maxStack<=this.#_i?i.maxStack:this.#_i,a=[],l=(e,t)=>JSON.stringify(e)===JSON.stringify(t);let u=!0;for(;s>0&&u;){u=!1;for(const t in this.#ki){const c=this.#ki[t];if(c&&c.id===e&&c.quantity<o&&l(c.metadata,r)){const e=Math.min(o-c.quantity,s);if(!n&&!this.hasSpace({weight:i.weight*e,sizeLength:e}))continue;c.quantity+=e,s-=e,u=!0;const r=Number(t),l=a.findIndex(e=>e.index===r);if(l<0?a.push({index:r,quantity:e}):a[l].quantity+=e,this.#$i("add",{item:this.#Pi(c),index:r,isCollection:!0,specialSlot:null,remove:this.#Hi({locationType:"normal",slotIndex:r,forceSpace:n,item:c})}),s<=0)break}}}if(s>0)for(const t in this.#ki)if(null===this.#ki[t]){const l=Math.min(o,s);if(!n&&!this.hasSpace({weight:i.weight*l,sizeLength:l}))continue;const u={id:e,quantity:l,metadata:r};this.#ki[t]=u,s-=l;const c=Number(t),h=a.findIndex(e=>e.index===c);if(h<0?a.push({index:c,quantity:l}):a[h].quantity+=l,this.#$i("add",{item:this.#Pi(u),index:c,isCollection:!0,specialSlot:null,remove:this.#Hi({locationType:"normal",slotIndex:c,forceSpace:n,item:u})}),s<=0)break}for(;s>0;){const t=Math.min(o,s);if(!n&&!this.hasSpace({weight:i.weight*t,sizeLength:t,slotsLength:1}))break;const l={id:e,quantity:t,metadata:r};this.#ki.push(l);const u=this.#ki.length-1,c=a.findIndex(e=>e.index===u);c<0?a.push({index:u,quantity:t}):a[c].quantity+=t,this.#$i("add",{item:this.#Pi(l),index:u,isCollection:!0,specialSlot:null,remove:this.#Hi({locationType:"normal",slotIndex:u,forceSpace:n,item:l})}),s-=t}return{remaining:s,placesAdded:a}}getItemFrom(e){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");if(e<0||e>=this.#ki.length)throw new Error(`Slot index '${e}' out of bounds .`);return this.#ki[e]?this.#Pi(this.#ki[e]):null}setItem({slotIndex:e,item:t,forceSpace:r=!1}){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be a boolean.");const n=t&&"object"==typeof t&&"string"==typeof t.id&&"number"==typeof t.quantity&&!Number.isNaN(t.quantity)&&Number.isFinite(t.quantity)&&t.quantity>-1&&"object"==typeof t.metadata;if(null!==t&&!n)throw new Error("Invalid item type: must be null or a valid InventoryItem.");const i=t?pr.#Ni.get(t.id):null;if(null!==t&&!i)throw new Error(`Item '${t?.id??"unknown"}' not defined in registry.`);if(i&&t){const e=i.maxStack<=this.#_i?i.maxStack:this.#_i;if(t.quantity>e)throw new Error(`Item '${t.id}' exceeds max stack size. Allowed: ${e}, got: ${t.quantity}.`)}if(null!==this.#ji&&(e<0||e>=this.#ji))throw new Error(`Slot index ${e} out of range.`);const s=this.#ki[e]??null,o=s?pr.#Ni.get(s.id)??null:null,a=(e,t)=>t?t.weight*(e?e.quantity:0):0,l=e=>e?e.quantity:0;if(!r&&!this.hasSpace({weight:a(t,i)-a(s,o),sizeLength:l(t)-l(s)}))throw new Error("Inventory is full or overweight.");for(;this.#ki.length<=e;)this.#ki.push(null);this.#ki[e]=t,this._cleanNulls(),this.#$i("set",{index:e,isCollection:!0,item:t?this.#Pi(t):null,specialSlot:null,remove:t?this.#Hi({locationType:"normal",slotIndex:e,forceSpace:r,item:t}):()=>{}})}deleteItem(e,t=!1){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");if("boolean"!=typeof t)throw new TypeError("`forceSpace` must be a boolean.");this.setItem({slotIndex:e,item:null,forceSpace:t})}moveItem(e,t,r=!1){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`fromIndex` must be an integer.");if("number"!=typeof t||!Number.isInteger(t))throw new TypeError("`toIndex` must be an integer.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be a boolean.");const n=this.#ki[e];if(!n)throw new Error(`No item found in slot ${e}.`);this.setItem({slotIndex:t,item:n,forceSpace:r}),this.setItem({slotIndex:e,item:null,forceSpace:r})}removeItem({itemId:e,metadata:t=null,quantity:r=1}){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");if(null!==t&&"object"!=typeof t)throw new TypeError("`metadata` must be an object or null.");if("number"!=typeof r||!Number.isFinite(r)||r<=0)throw new TypeError("`quantity` must be a positive number.");let n=r;const i=(e,t)=>JSON.stringify(e)===JSON.stringify(t);for(let r=0;r<this.#ki.length;r++){const s=this.#ki[r];if(s&&s.id===e&&(null===t||i(s.metadata,t))){const e=Math.min(s.quantity,n);s.quantity-=e,n-=e;const t=Number(r);if(s.quantity<=0&&(this.#ki[r]=null),n<=0)return this._cleanNulls(),this.#$i("remove",{index:t,item:this.#Pi(s),isCollection:!0,specialSlot:null,remove:this.#Hi({locationType:"normal",slotIndex:t,item:s})}),!0}}return this._cleanNulls(),this.#Di.forEach((r,s)=>{if(n>0&&r.item&&r.item.id===e&&(null===t||i(r.item.metadata,t))){const e=Math.min(r.item.quantity,n);r.item.quantity-=e,r.item.quantity<0&&(r.item.quantity=0),n-=e,r.item.quantity<=0&&(r.item=null),this.#Di.set(s,r),this.#$i("remove",{index:null,item:r.item?this.#Pi(r.item):null,isCollection:!1,specialSlot:s,remove:r.item?this.#Hi({locationType:"special",specialSlot:s,item:r.item}):()=>{}})}}),n<=0}#Hi({locationType:e,specialSlot:t,slotIndex:r,item:n,forceSpace:i=!1}){if("normal"!==e&&"special"!==e)throw new TypeError("`locationType` must be 'normal' or 'special'.");if("boolean"!=typeof i)throw new TypeError("`forceSpace` must be boolean.");if(!n||"object"!=typeof n)throw new TypeError("`item` must be an InventoryItem object.");if("special"===e&&t&&"string"!=typeof t)throw new TypeError("`specialSlot` must be a string when locationType is 'special'.");if("normal"===e&&"number"!=typeof r)throw new TypeError("`slotIndex` must be a number when locationType is 'normal'.");return(s=i)=>{if("special"===e&&t){const e=this.#Di.get(t);if(!e?.item)throw new Error(`Special slot '${t}' is empty.`);e.item.quantity>1?(e.item.quantity-=1,this.#Di.set(t,e)):this.setSpecialSlot({slotId:t,item:null,forceSpace:s})}else{if("number"!=typeof r)throw new Error("Invalid remove operation: no valid slotIndex or specialSlot provided.");n.quantity>1?this.setItem({slotIndex:r,item:{...n,quantity:n.quantity-1},forceSpace:s}):this.setItem({slotIndex:r,item:null,forceSpace:s})}}}useItem({slotIndex:e,specialSlot:t,forceSpace:r=!1},...n){if(void 0!==e&&("number"!=typeof e||!Number.isInteger(e)))throw new TypeError("`slotIndex` must be an integer if provided.");if(void 0!==t&&"string"!=typeof t)throw new TypeError("`specialSlot` must be a string if provided.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be boolean.");let i=null,s="normal",o=null;if(t){if(!this.#Di.has(t))throw new Error(`Special slot '${t}' not found.`);i=this.#Di.get(t).item,s="special"}else o=this.#ki,i=o[e??-1]??null,s="normal";if(!i)throw new Error("special"===s?`No item found in special slot '${t}'.`:`No item found in slot ${e} of inventory.`);const a=pr.getItem(i.id);if(a.onUse){const l={inventory:this,item:this.#Pi(i),index:e??null,specialSlot:t??null,isCollection:!!o,itemDef:a,remove:this.#Hi({locationType:s,specialSlot:t,slotIndex:e,forceSpace:r,item:i}),...n},u=a.onUse(l);return this.#$i("use",l),u}return null}hasSpecialSlot(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");return this.#Di.has(e)}getSpecialItem(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(!this.#Di.has(e))throw new Error(`Special slot '${e}' does not exist.`);const t=this.#Di.get(e);return t?.item?this.#Pi(t.item):null}getSpecialSlotType(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(!this.#Di.has(e))throw new Error(`Special slot '${e}' does not exist.`);const t=this.#Di.get(e);return t?.type??null}setSpecialSlot({slotId:e,item:t,forceSpace:r=!1}){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be boolean.");if(!this.#Di.has(e))throw new Error(`Special slot '${e}' not found.`);const n=t&&"object"==typeof t&&"string"==typeof t.id&&"number"==typeof t.quantity&&!Number.isNaN(t.quantity)&&Number.isFinite(t.quantity)&&t.quantity>-1&&"object"==typeof t.metadata;if(null!==t&&!n)throw new Error("Invalid item type: must be null or a valid InventoryItem.");const i=t?pr.#Ni.get(t.id):null;if(null!==t&&!i)throw new Error(`Item '${t?.id??"unknown"}' not defined in registry.`);const s=this.#Di.get(e);if(!s)throw new Error(`Special slot ${e} out of range for slot '${e}'.`);const o=s.item?pr.#Ni.get(s.item.id):null,a=(e,t)=>t?t.weight*(e?1:0):0,l=e=>e?1:0;if(!r&&!this.hasSpace({weight:a(t,i)-a(s.item,o),sizeLength:l(t)-l(s.item)}))throw new Error("Inventory is full or overweight.");s.item=t,this.#$i("set",{index:null,item:t?this.#Pi(t):null,isCollection:!1,specialSlot:e,remove:t?this.#Hi({locationType:"special",specialSlot:e,forceSpace:r,item:t}):()=>{}})}deleteSpecialItem(e,t=!1){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if("boolean"!=typeof t)throw new TypeError("`forceSpace` must be boolean.");this.setSpecialSlot({slotId:e,item:null,forceSpace:t})}equipItem({slotId:e,slotIndex:t,quantity:r=1,forceSpace:n=!1}){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if("number"!=typeof t||!Number.isInteger(t))throw new TypeError("`slotIndex` must be an integer.");if("number"!=typeof r||!Number.isFinite(r)||r<=0)throw new TypeError("`quantity` must be a positive number.");if("boolean"!=typeof n)throw new TypeError("`forceSpace` must be boolean.");if(r<=0||!Number.isFinite(r))throw new Error(`Invalid quantity '${r}'.`);if(!this.#Di.has(e))throw new Error(`Special slot '${e}' does not exist.`);const i=this.getItemFrom(t);if(!i)throw new Error(`No item found in inventory slot ${t}.`);if(i.quantity<r)throw new Error(`Not enough quantity of item '${i.id}' in inventory slot.`);const s=pr.getItem(i.id),o=this.#Di.get(e);if(!o)throw new Error(`Slot '${e}' not defined in registry.`);const a=o.type??null;if(null!==a&&s.type!==a)throw new Error(`Item '${i.id}' cannot be equipped in slot '${e}'.`);const l=Math.min(s.maxStack,this.#_i);if(o.item&&o.item.id===i.id){const t=Math.max(0,l-o.item.quantity);if(t<=0)return r;const n=Math.min(r,t);return this.removeItem({itemId:i.id,quantity:n,metadata:null}),o.item.quantity+=n,this.#Di.set(e,o),r-n}o.item&&this.unequipItem({slotId:e,forceSpace:n});const u=Math.min(r,l);return this.removeItem({itemId:i.id,quantity:u,metadata:null}),o.item={id:i.id,quantity:u,metadata:i.metadata},this.#Di.set(e,o),r-u}unequipItem({slotId:e,quantity:t=null,forceSpace:r=!1}){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(null!==t&&("number"!=typeof t||!Number.isFinite(t)||t<=0))throw new TypeError("`quantity` must be a positive number or null.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be boolean.");if(!this.#Di.has(e))throw new Error(`Special slot '${e}' does not exist.`);const n=this.#Di.get(e);if(!n)throw new Error(`Slot '${e}' not defined in registry.`);if(!n.item)return!1;const i=n.item,s=null===t?i.quantity:t;if(s<=0)throw new Error(`Invalid unequip quantity: ${s}`);if(s>i.quantity)throw new Error(`Not enough items in slot '${e}' to unequip.`);return this.addItem({itemId:i.id,quantity:s,metadata:i.metadata,forceSpace:r}),s===i.quantity?n.item=null:(i.quantity-=s,n.item=i),this.#Di.set(e,n),!0}#Pi(e){if(!e||"object"!=typeof e)throw new TypeError("`item` must be an InventoryItem object.");if("string"!=typeof e.id)throw new TypeError("`item.id` must be a string.");if("number"!=typeof e.quantity||!Number.isFinite(e.quantity))throw new TypeError("`item.quantity` must be a finite number.");if(!e.metadata||"object"!=typeof e.metadata)throw new TypeError("`item.metadata` must be an object.");return{id:e.id,quantity:e.quantity,metadata:{...e.metadata}}}getItemList(){return[...this.#ki].map((e,t)=>[e?this.#Pi(e):null,t]).filter(e=>null!==e[0])}getAllItems(){const e=[...this.#ki].filter(e=>null!==e).map(this.#Pi);return this.#Di.forEach(t=>{const r=t.item;r&&e.push(r)}),e}getItemsByMetadata(e){if("function"!=typeof e)throw new TypeError("`filterFn` must be a function.");return this.getAllItems().filter(t=>{const r=pr.getItem(t.id);return e(r.metadata,t)})}findItem(e){if("function"!=typeof e)throw new TypeError("`predicate` must be a function.");return this.getAllItems().find(e)}findItems(e){if("function"!=typeof e)throw new TypeError("`predicate` must be a function.");return this.getAllItems().filter(e)}getItemCount(e){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");return this.getAllItems().filter(t=>t.id===e).reduce((e,t)=>e+t.quantity,0)}hasItem(e,t=1){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");if("number"!=typeof t||!Number.isFinite(t)||t<0)throw new TypeError("`quantity` must be a non-negative number.");return this.getItemCount(e)>=t}existsItemAt(e){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");return!!this.#ki[e]}clear(){this.clearAllItems(),this.clearAllEvents()}clearAllEvents(){this.#It={add:[],remove:[],use:[],set:[]}}clearAllItems(){this.clearItems(),this.clearSpecialItems()}clearItems(){for(let e=this.#ki.length-1;e>=0;e--)this.#ki[e]&&this.deleteItem(e,!0)}clearSpecialItems(){for(const e of this.#Di.keys()){const t=this.#Di.get(e);t?.item&&this.deleteSpecialItem(e,!0)}}clone(){const e=this.toObject();return pr.fromObject(e)}toObject(){const e={};for(const[t,r]of this.#Di.entries())e[t]={type:r?.type??null,item:r?.item?this.#Pi(r.item):null};return{__schema:"TinyInventory",version:1,maxWeight:this.#Oi,maxSlots:this.#ji,maxSize:this.#Ri,maxStack:this.#_i,items:this.#ki.map(e=>e?this.#Pi(e):null),specialSlots:e}}toJSON(e=0){if("number"!=typeof e||!Number.isFinite(e)||e<0)throw new TypeError("`space` must be a non-negative number.");return JSON.stringify(this.toObject(),null,e)}static fromObject(e){if(!e||"object"!=typeof e)throw new TypeError("Invalid state: expected object.");if("TinyInventory"!==e.__schema||"number"!=typeof e.version)throw new TypeError("Invalid or missing schema header.");if(1!==e.version)throw new TypeError(`Unsupported TinyInventory state version: ${e.version}`);const t={};if(e.specialSlots&&"object"==typeof e.specialSlots)for(const r of Object.keys(e.specialSlots))t[r]={type:e.specialSlots[r]?.type??null};const r=new pr({maxWeight:e.maxWeight??null,maxSlots:e.maxSlots??null,maxSize:e.maxSize??null,maxStack:e.maxStack??null,specialSlots:t});if(Array.isArray(e.items))for(const t in e.items){const n=e.items[t];if(null!==n){const e={id:String(n.id),quantity:Math.max(1,Number(n.quantity)||1),metadata:n.metadata&&"object"==typeof n.metadata?n.metadata:{}};r.setItem({slotIndex:Number(t),item:e,forceSpace:!0})}else r.setItem({slotIndex:Number(t),item:null,forceSpace:!0})}if(e.specialSlots&&"object"==typeof e.specialSlots)for(const[t,n]of Object.entries(e.specialSlots)){if(!r.hasSpecialSlot(t))continue;const e=n?.item;if(e&&e.id){const n={id:String(e.id),quantity:Math.max(1,Number(e.quantity)||1),metadata:e.metadata&&"object"==typeof e.metadata?e.metadata:{}};r.setSpecialSlot({slotId:t,item:n,forceSpace:!0})}}return r}static fromJSON(e){if("string"!=typeof e)throw new TypeError("`json` must be a string.");const t=JSON.parse(e);return pr.fromObject(t)}}const mr=pr,fr=class{#Bi=null;#Fi=null;get sender(){return this.#Bi}get receiver(){return this.#Fi}set sender(e){if(!(e instanceof mr&&this.receiver instanceof mr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Bi=e}set receiver(e){if(!(this.sender instanceof mr&&e instanceof mr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Fi=e}constructor(e,t){if(e||t){if(!(e instanceof mr&&t instanceof mr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.connect(e,t)}}connect(e,t){if(!(e instanceof mr&&t instanceof mr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Bi=e,this.#Fi=t}disconnect(){this.#Bi=null,this.#Fi=null}invert(){const e=this.#Bi,t=this.#Fi;this.#Bi=t,this.#Fi=e}transferItem({slotIndex:e,specialSlot:t,quantity:r=1,receiverSlotIndex:n,forceSpace:i=!1,strict:s=!1}){if(!this.#Bi||!this.#Fi)throw new Error("Sender and receiver inventories must be connected.");let o;if(t){if(o=this.#Bi.getSpecialItem(t),!o)throw new Error(`No item found in sender special slot '${t}'.`)}else{if("number"!=typeof e)throw new Error("Must provide either slotIndex or specialSlot.");if(o=this.#Bi.getItemFrom(e),!o)throw new Error(`No item found in sender slot ${e}.`)}if(o.quantity<r)throw new Error(`Sender does not have enough quantity of '${o.id}' to transfer.`);const a={id:o.id,quantity:r,metadata:o.metadata};let l;if(s)if("number"==typeof n){const e=this.#Fi.existsItemAt(n)?this.#Fi.getItemFrom(n):null;if(e){if(e.id!==a.id)throw new Error(`Receiver slot ${n} contains a different item.`);const t=mr.getItem(e.id).maxStack-e.quantity;if(a.quantity>t)throw new Error(`Strict mode: not enough space in receiver slot ${n}.`)}}else if(this.#Fi.clone().addItem({itemId:a.id,quantity:a.quantity,metadata:a.metadata,forceSpace:i}).remaining>0)throw new Error("Strict mode: not enough space in receiver inventory.");if("number"==typeof n){const e=this.#Fi.existsItemAt(n)?this.#Fi.getItemFrom(n):null;let t=a.quantity;if(e){if(e.id!==a.id)throw new Error(`Receiver slot ${n} contains a different item.`);const r=mr.getItem(e.id).maxStack-e.quantity;t=Math.min(r,a.quantity),t>0&&this.#Fi.setItem({slotIndex:n,item:{...e,quantity:e.quantity+t},forceSpace:i})}else this.#Fi.setItem({slotIndex:n,item:a,forceSpace:i});l={remaining:a.quantity-t}}else l=this.#Fi.addItem({itemId:a.id,quantity:a.quantity,metadata:a.metadata,forceSpace:i});const u=a.quantity-l.remaining;if(u>0)if(t)this.#Bi.unequipItem({slotId:t,quantity:u,forceSpace:i});else if("number"==typeof e){const t=o.quantity-u;this.#Bi.setItem({slotIndex:e,item:t>0?{...o,quantity:t}:null,forceSpace:i})}return l}transferMultiple(e){return e.map(e=>this.transferItem(e))}},gr=class{#zi;#Wi={message:"We use cookies to improve your experience.",acceptText:"Accept All",rejectText:"Reject All",settingsText:"Manage Settings",categories:[],storageKey:"cookie-consent-preferences",onSave:e=>console.log("Preferences saved:",e),animationDuration:400,renderBar:null,renderModal:null};get preferences(){const e=localStorage.getItem(this.#Wi.storageKey);return e?JSON.parse(e):{}}get config(){return{...this.#Wi,categories:[...this.#Wi.categories]}}set config(e){this.validateConfig(e),this.#Wi=Object.assign(this.#Wi,e)}constructor(e){if(!e||"object"!=typeof e)throw new TypeError("Config must be an object.");this.config=e;const t=this.loadPreferences();this.#zi=t??{},t||this.showConsentBar()}validateConfig(e){if(void 0!==e.message&&"string"!=typeof e.message)throw new TypeError("Config.message must be a string.");if(["acceptText","rejectText","settingsText","storageKey"].forEach(t=>{if(void 0!==e[t]&&"string"!=typeof e[t])throw new TypeError(`Config.${t} must be a string.`)}),void 0!==e.categories){if(!Array.isArray(e.categories))throw new TypeError("Config.categories must be an array of Category objects.");e.categories.forEach((e,t)=>this.validateCategory(e,t))}if(void 0!==e.onSave&&"function"!=typeof e.onSave)throw new TypeError("Config.onSave must be a function.");if(void 0!==e.animationDuration&&("number"!=typeof e.animationDuration||e.animationDuration<0))throw new TypeError("Config.animationDuration must be a positive number.");if(void 0!==e.renderBar&&null!==e.renderBar&&"function"!=typeof e.renderBar)throw new TypeError("Config.renderBar must be a function or null.");if(void 0!==e.renderModal&&null!==e.renderModal&&"function"!=typeof e.renderModal)throw new TypeError("Config.renderModal must be a function or null.")}validateCategory(e,t){if(!e||"object"!=typeof e)throw new TypeError(`Category at index ${t} must be an object.`);if("string"!=typeof e.label)throw new TypeError(`Category.label at index ${t} must be a string.`);if("boolean"!=typeof e.required)throw new TypeError(`Category.required at index ${t} must be a boolean.`);if("boolean"!=typeof e.default)throw new TypeError(`Category.default at index ${t} must be a boolean.`)}loadPreferences(){const e=localStorage.getItem(this.#Wi.storageKey);return e?JSON.parse(e):null}removeWithAnimation(e){if(!(e instanceof HTMLElement))throw new TypeError("removeWithAnimation expects an HTMLElement.");e.classList.add("closing"),setTimeout(()=>e.remove(),this.#Wi.animationDuration)}savePreferences(e){if(!e||"object"!=typeof e)throw new TypeError("Preferences must be an object.");localStorage.setItem(this.#Wi.storageKey,JSON.stringify(e)),this.#Wi.onSave(e)}showConsentBar(){const e=document.createElement("div");e.className="cookie-consent-bar",e.innerHTML=this.#Wi.renderBar?this.#Wi.renderBar(this.#Wi):`\n <div><p>${this.#Wi.message}</p></div>\n <div><button class="accept">${this.#Wi.acceptText}</button></div>\n <div><button class="reject">${this.#Wi.rejectText}</button></div>\n <div><button class="settings">${this.#Wi.settingsText}</button></div>\n `,document.body.appendChild(e);const t=e.querySelector(".accept");t instanceof HTMLElement&&(t.onclick=()=>{const t={};this.#Wi.categories.forEach(e=>t[e.label]=!0),this.savePreferences(t),this.removeWithAnimation(e)});const r=e.querySelector(".reject");r instanceof HTMLElement&&(r.onclick=()=>{const t={};this.#Wi.categories.forEach(e=>t[e.label]=e.required),this.savePreferences(t),this.removeWithAnimation(e)});const n=e.querySelector(".settings");n instanceof HTMLElement&&(n.onclick=()=>this.showSettingsModal(e))}showSettingsModal(e){const t=document.createElement("div");t.className="cookie-consent-modal",t.innerHTML=this.#Wi.renderModal?this.#Wi.renderModal(this.#Wi):`\n <div class="modal-content">\n <h2>Cookie Settings</h2>\n <form class="settings-form">\n ${this.#Wi.categories.map(e=>`\n <label>\n <input type="checkbox" name="${e.label}" \n ${e.default?"checked":""} \n ${e.required?"disabled":""}>\n ${e.label}\n </label>\n `).join("")}\n </form>\n <button class="save">Save Preferences</button>\n </div>\n `,document.body.appendChild(t);const r=t.querySelector(".save");r instanceof HTMLElement&&(r.onclick=()=>{const r={};t.querySelectorAll("input[type=checkbox]").forEach(e=>{e instanceof HTMLInputElement&&(r[e.name]=e.checked)}),this.savePreferences(r),this.removeWithAnimation(t),e&&this.removeWithAnimation(e)})}isAllowed(e){if("string"!=typeof e)throw new TypeError("isAllowed expects a string as category.");return!!this.#zi&&!!this.#zi[e]}};var yr=r(911),wr=r(766);const br=class{static async mergeLocaleFiles({files:e,output:t,spaces:r=0}){if("number"!=typeof r||Number.isNaN(r)||r<0)throw new TypeError('mergeLocaleFiles: "spaces" must be a non-negative number');if(!Array.isArray(e)||0===e.length)throw new TypeError('mergeLocaleFiles: "files" must be a non-empty array of file paths');if("string"!=typeof t||!t)throw new TypeError('mergeLocaleFiles: "output" must be a non-empty string path');const n={};for(const t of e){if("string"!=typeof t||!t)throw new TypeError("mergeLocaleFiles: each file path must be a non-empty string");if(!(0,wr.existsSync)(t))throw new Error(`mergeLocaleFiles: file "${t}" does not exist`);const e=await(0,yr.readFile)(t,"utf-8");let r;try{r=JSON.parse(e)}catch(e){throw new Error(`mergeLocaleFiles: file "${t}" is not valid JSON`)}Object.assign(n,r)}await(0,yr.writeFile)(t,JSON.stringify(n,null,r),"utf-8")}#qi;#Vi;#Ui=null;#Ki;#Ji=null;#Gi=new Map;#Yi=new Map;#Xi=new Map;#Qi=new Map;get currentLocale(){return this.#Ui}get defaultLocale(){return this.#Vi}get mode(){return this.#qi}get strict(){return this.#Ki}get basePath(){return this.#Ji}get stats(){const e=[];for(const t of this.#Gi.keys())e.push(this.getStatsForLocale(t));return e}get stringTables(){const e={};for(const[t,r]of this.#Gi.entries())e[t]=this.#Zi(r);return e}get patternTables(){const e={};for(const[t,r]of this.#Yi.entries())e[t]=r.map(e=>({$pattern:new RegExp(e.$pattern.source,e.$pattern.flags),value:this.#Zi(e.value),elseValue:this.#Zi(e.elseValue)}));return e}get helpers(){const e={};for(const[t,r]of this.#Xi.entries())e[t]=r;return e}get regexCache(){const e={};for(const[t,r]of this.#Qi.entries())e[t]=new RegExp(r.source,r.flags);return e}#Zi(e){if(null==e||"string"==typeof e||"function"==typeof e||"number"==typeof e)return e;if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e))return e.map(e=>this.#Zi(e));if("object"==typeof e){const t={};for(const[r,n]of Object.entries(e))t[r]=this.#Zi(n);return t}return e}#es(e){if(void 0!==e&&"string"!=typeof e)throw new TypeError('#resolveOrder: "forceLocale" must be a string if provided');const t=[];return e&&"string"==typeof e&&this.#Gi.has(e)?t.push(e):this.#Ui&&t.push(this.#Ui),t.push(this.#Vi),t}#ts(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError('#resolveExact: "order" must be an array of strings');if("string"!=typeof t||!t)throw new TypeError('#resolveExact: "key" must be a non-empty string');for(const r of e){const e=this.#Gi.get(r);if(e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}}#rs(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError('#resolveByPattern: "order" must be an array of strings');if("string"!=typeof t||!t)throw new TypeError('#resolveByPattern: "key" must be a non-empty string');for(const r of e){const e=this.#Yi.get(r)||[];for(const r of e)return r.$pattern.test(t)?r.value:r.elseValue??void 0}}#ns(e,t){if(null==e){if(this.#Ki)throw new TypeError('#materialize: "value" cannot be null or undefined');return""}if("string"==typeof e)return this.#is(e,t);if("function"==typeof e)return e(t??{},this.#ss());if(e&&"object"==typeof e&&"string"==typeof e.$fn){const r=this.#Xi.get(e.$fn);if("function"!=typeof r){if(this.#Ki)throw new Error(`TinyI18: helper "${e.$fn}" is not registered`);return""}return r({...t??{},args:void 0!==e.args?e.args:void 0},this.#ss())}if(this.#Ki)throw new Error("TinyI18: unsupported entry type");return""}#is(e,t){if("string"!=typeof e)throw new TypeError('#interpolate: "template" must be a string');if(void 0!==t&&(null===t||"object"!=typeof t))throw new TypeError('#interpolate: "params" must be an object if provided');return t&&"object"==typeof t?e.replace(/\{([a-zA-Z0-9_.$-]+)\}/g,(e,r)=>{const n=this.#os(t,r);return null==n?"":String(n)}):e}#os(e,t){if(!e||"object"!=typeof e)throw new TypeError('#dotGet: "obj" must be an object');if("string"!=typeof t||!t)throw new TypeError('#dotGet: "path" must be a non-empty string');const r=t.split(".");let n=e;for(const e of r){if(null==n)return;n=n[e]}return n}#ss(){return{has:e=>this.#Xi.has(e),call:(e,t,r)=>{const n=this.#Xi.get(e);if("function"!=typeof n)throw new Error(`Helper "${e}" not found`);return n(t,r??{})}}}#as(e,t){if("string"!=typeof e||!e)throw new TypeError('#ingestLocale: "locale" must be a non-empty string');if(!t||"object"!=typeof t)throw new TypeError('#ingestLocale: "raw" must be an object');if("string"!=typeof e||!e)throw new TypeError("#ingestLocale: invalid locale");if(!t||"object"!=typeof t)throw new TypeError('#ingestLocale: "raw" must be an object');const r={...this.#Gi.get(e)??{}},n=[...this.#Yi.get(e)??[]],i=(e,t)=>{if(null!=t)if("string"==typeof t||"function"==typeof t||t&&"object"==typeof t&&"string"==typeof t.$fn){if(!e)throw new TypeError("Leaf value requires a key path");r[e]=t}else if(t&&"object"==typeof t){if(t.$pattern instanceof RegExp&&Object.prototype.hasOwnProperty.call(t,"value"))return void n.push({$pattern:t.$pattern,value:t.value,elseValue:t.elseValue});for(const[r,n]of Object.entries(t))i(e?`${e}.${r}`:r,n)}};i("",t),this.#Gi.set(e,r),this.#Yi.set(e,n),this.#Gi.has(this.#Vi)||(this.#Gi.set(this.#Vi,{}),this.#Yi.set(this.#Vi,[]))}#ls(e){if("string"!=typeof e||!e)throw new TypeError('#unloadLocale: "locale" must be a non-empty string');e!==this.#Vi&&(this.#Gi.delete(e),this.#Yi.delete(e))}async#us(e){if("string"!=typeof e||!e)throw new TypeError('#loadLocaleFromFile: "locale" must be a non-empty string');if("string"!=typeof this.#Ji||!this.#Ji)throw new TypeError('#loadLocaleFromFile: "this.#basePath" must be a non-empty string');const t=(0,ce.join)(this.#Ji,`${e}.json`);let r;try{const e=await(0,yr.readFile)(t,"utf8");r=JSON.parse(e)}catch(r){if(!(r instanceof Error))return;if(this.#Ki)throw new Error(`TinyI18: failed to load or parse ${t}: ${r.message}`);return this.#Gi.set(e,{}),void this.#Yi.set(e,[])}const n={...this.#Gi.get(e)??{}},i=[...this.#Yi.get(e)??[]],s=(e,t)=>{if(null!=t){if(t&&"object"==typeof t&&"string"==typeof t.$pattern&&Object.prototype.hasOwnProperty.call(t,"value")){const e=this.#cs(t.$pattern);return void i.push({$pattern:e,value:this.#hs(t.value),elseValue:this.#hs(t.elseValue)})}if("string"==typeof t||t&&"object"==typeof t&&"string"==typeof t.$fn){if(!e)throw new TypeError("Leaf value requires a key path");n[e]=this.#hs(t)}else if(t&&"object"==typeof t)for(const[r,n]of Object.entries(t))s(e?`${e}.${r}`:r,n)}};s("",r),this.#Gi.set(e,n),this.#Yi.set(e,i)}#cs(e){if("string"!=typeof e||!e)throw new TypeError('#safeRegExp: "src" must be a non-empty string');const t=this.#Qi.get(e);if(t)return t;try{const t=new RegExp(e);return this.#Qi.set(e,t),t}catch{if(this.#Ki)throw new Error(`TinyI18: invalid regex "${e}" in file`);return/^$/}}#hs(e){if("string"==typeof e)return e;if(e&&"object"==typeof e&&"string"==typeof e.$fn)return{$fn:String(e.$fn),args:e.args};if(this.#Ki)throw new Error("TinyI18: unsupported value in file JSON");return""}constructor(e){if(!e||"object"!=typeof e)throw new TypeError("TinyI18: options must be an object");const{mode:t,defaultLocale:r,basePath:n,localResources:i,strict:s=!0}=e;if("local"!==t&&"file"!==t)throw new TypeError('TinyI18: "mode" must be "local" or "file"');if("string"!=typeof r||!r)throw new TypeError('TinyI18: "defaultLocale" must be a non-empty string');if("boolean"!=typeof s)throw new TypeError('TinyI18: "strict" must be a boolean');if("file"===t){if("string"!=typeof n||!n)throw new TypeError('TinyI18: "basePath" is required in file mode');this.#Ji=n}if(this.#qi=t,this.#Vi=r,this.#Ki=s,"local"===t&&i&&"object"==typeof i)for(const[e,t]of Object.entries(i))this.#as(e,t);this.#Gi.has(this.#Vi)||(this.#Gi.set(this.#Vi,{}),this.#Yi.set(this.#Vi,[]))}clearRegexCache(){this.#Qi.clear()}registerHelper(e,t){if("string"!=typeof e||!e)throw new TypeError('registerHelper: "name" must be non-empty string');if("function"!=typeof t)throw new TypeError('registerHelper: "fn" must be a function');this.#Xi.set(e,t)}unregisterHelper(e){if("string"!=typeof e||!e)throw new TypeError('unregisterHelper: "name" must be non-empty string');return this.#Xi.delete(e)}loadLocaleLocal(e,t){if("local"!==this.#qi)throw new TypeError('loadLocaleLocal is only available in "local" mode');this.#as(e,t)}async setLocale(e){if(null!==e&&("string"!=typeof e||!e))throw new TypeError('setLocale: "locale" must be string or null');const t=this.#Ui;null!==e&&("file"===this.#qi?await this.#us(e):this.#Gi.has(e)||(this.#Gi.set(e,{}),this.#Yi.set(e,[]))),"file"===this.#qi&&t&&t!==this.#Vi&&t!==e&&this.#ls(t),this.#Ui=e}t(e,t=void 0,r=void 0){return this.get(e,t,r)}get(e,t=void 0,r=void 0){if("string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:n}=r||{},i=this.#es(n);let s=this.#ts(i,e);if(void 0===s){if(this.#Ki)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return this.#ns(s,t)}p(e,t){return this.resolveByPattern(e,t)}resolveByPattern(e,t){if("string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:r}=t||{},n=this.#es(r);let i=this.#rs(n,e);if(void 0===i){if(this.#Ki)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return i}resetToDefaultOnly(){if("file"===this.#qi)for(const e of Array.from(this.#Gi.keys()))e!==this.#Vi&&this.#ls(e);this.#Ui=null}getStatsForLocale(e){if("string"!=typeof e||!e)throw new TypeError('getStatsForLocale: "locale" must be a non-empty string');if(!this.#Gi.has(e))throw new Error(`getStatsForLocale: locale "${e}" is not registered`);return{locale:e,strings:Object.keys(this.#Gi.get(e)??{}).length,patterns:this.#Yi.get(e)?.length??0,isDefault:e===this.#Vi,isCurrent:e===this.#Ui}}};class vr{#ds=new Map;#ps;#ms;#fs;get factors(){const e={};for(let[t,r]of this.#ds.entries())e[t]={...r};return e}get currentPercent(){return this.#ms/this.#ps*100}set maxValue(e){if("number"!=typeof e||Number.isNaN(e)||e<=0)throw new TypeError("maxValue must be a positive number.");this.#ps=e,this.#ms=Math.min(this.#ms,e)}get maxValue(){return this.#ps}get currentValue(){return this.#ms}set infiniteValue(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("infiniteValue must be a number.");this.#fs=e,this.#ms=Math.max(0,e),this.#ms=Math.min(this.#ms,this.#ps)}get infiniteValue(){return this.#fs}constructor(e=100,t=1,r=1){if("number"!=typeof e||Number.isNaN(e)||e<=0)throw new TypeError("maxValue must be a positive number.");this.#ps=e,this.setFactor("main",t,r),this.#ms=e,this.#fs=e}getFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");const t=this.#ds.get(e);if(!t)throw new Error(`Factor with key "${e}" not found.`);return{...t}}hasFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");return this.#ds.has(e)}setFactor(e,t,r=1){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");if("number"!=typeof t||Number.isNaN(t))throw new TypeError("Amount must be a valid number.");if("number"!=typeof r||Number.isNaN(r))throw new TypeError("Multiplier must be a valid number.");this.#ds.set(e,{amount:t,multiplier:r})}removeFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");return this.#ds.delete(e)}#gs(e){const t=this.#fs;return this.#fs-=e,this.#ms=Math.max(0,this.#ms-e),{prevValue:t,removedTotal:e,removedPercent:e/this.#ps*100,currentPercent:this.currentPercent,remainingValue:this.#ms,infiniteRemaining:this.#fs}}tick(){let e=0;for(let[t,r]of this.#ds.entries())e+=r.amount*r.multiplier;return this.#gs(e)}tickWithTempFactor(e){if("object"!=typeof e||null===e)throw new TypeError("You must provide a valid factor object.");if("number"!=typeof e.amount||Number.isNaN(e.amount))throw new TypeError('Temp factor "amount" must be a valid number.');if("multiplier"in e&&("number"!=typeof e.multiplier||Number.isNaN(e.multiplier)))throw new TypeError('Temp factor "multiplier" must be a valid number if provided.');let t=0;for(let[e,r]of this.#ds.entries())t+=r.amount*r.multiplier;return e&&(t+=e.amount*(e.multiplier??1)),this.#gs(t)}tickSingleFactor(e){if("object"!=typeof e||null===e)throw new TypeError("You must provide a valid factor object.");if("number"!=typeof e.amount||Number.isNaN(e.amount))throw new TypeError('Temp factor "amount" must be a valid number.');if("multiplier"in e&&("number"!=typeof e.multiplier||Number.isNaN(e.multiplier)))throw new TypeError('Temp factor "multiplier" must be a valid number if provided.');if(!e)throw new Error("You must provide a factor to apply.");const t=e.amount*(e.multiplier??1);return this.#gs(t)}toJSON(){return{maxValue:this.#ps,currentValue:this.#ms,infiniteValue:this.#fs,factors:this.factors}}static fromJSON(e){const t=new vr(e.maxValue,0,0);t.infiniteValue=e.infiniteValue,t.#ds.clear();for(const[r,n]of Object.entries(e.factors))t.setFactor(r,n.amount,n.multiplier);return t}clone(){return vr.fromJSON(this.toJSON())}clearFactors(){this.#ds.clear()}}const Er=vr;class Tr{static _safeEvaluate(e){if(!/^[\d+\-*/%.()\s^]+$/.test(e))throw new Error(`Invalid characters in expression: "${e}"`);const t=e.replace(/\^/g,"**");try{return Function(`"use strict"; return (${t})`)()}catch(t){if(!(t instanceof Error))throw new Error("Unknown Error");throw new Error(`Invalid expression "${e}": ${t.message}`)}}static replaceValues(e,t){let r=0;return e.replace(/(\d*)d(\d+)/g,(e,n)=>{const i=n?Number(n):1;let s=0;for(let e=0;e<i;e++){const e=t[r++];s+=void 0!==e?e:0}return String(s)})}static tokenizeValues(e,t){const r=Tr.replaceValues(e,t),n=[],i=/\d+|[()+\-*/]/g;let s;for(;null!==(s=i.exec(r));)/^\d+$/.test(s[0])?n.push(Number(s[0])):n.push(s[0]);return{tokens:n,text:r}}static parseString(e){if("string"!=typeof e)throw new TypeError("Input must be a string.");const t=e.split(",").map(e=>e.trim()).filter(Boolean),r=[],n=[];if(t.forEach((e,t)=>{const i=/\b(?:(\d+)?d(\d+))\b/g;let s;const o=[],a=e.replace(/\(([^()]+?\|[^()]+?)\)/g,(e,t)=>{const r="string"==typeof t?t.split("|").map(e=>e.trim()).filter(Boolean):[];if(0===r.length)throw new Error(`Invalid random-choice group: "${e}"`);return r[Math.floor(Math.random()*r.length)]});for(;null!==(s=i.exec(a));){const e=parseInt(s[1]||"1",10),r=parseInt(s[2],10);if(isNaN(r))throw new Error(`Invalid dice sides in expression "${s[0]}" at position ${t+1}.`);o.push({count:e,sides:r})}if(0===o.length&&Number.isNaN(parseFloat(a)))throw new Error(`Invalid dice expression at position ${t+1}: "${e}"`);r.push(...o),n.push({index:t,original:e,expression:a})}),0===r.length)throw new Error("Invalid dice amount.");return{sides:r,modifiers:n}}static applyModifiers(e,t){if(!Array.isArray(e)||!e.every(e=>"number"==typeof e&&!Number.isNaN(e)||f(e)&&"number"==typeof e.value&&!Number.isNaN(e.value)&&"number"==typeof e.sides&&!Number.isNaN(e.sides)))throw new TypeError("Bases must be a valid numbers.");if(!Array.isArray(t))throw new TypeError("Modifiers must be an array of modifier objects.");let r=0;const n=[],i=[...e];for(const e in t){const s=t[e];if("string"!=typeof s.expression)throw new Error("Each modifier must include an expression string.");const o=s.original,a=s.expression,l=[],u=[],c=[],h=e=>e.match(/\(\s*[^()]+\|\s*[^()]+\s*\)|\b\d*d\d+\b|[-+]?\d+(?:\.\d+)?|[+\-*/%^()]/g)||[],d=h(a),p=h(o),m=[...d],g=[],y=a.replace(/\b\d*d\d+\b/g,e=>{const t=e.split("d"),r=()=>{for(const t in d)if(d[t]===e&&g.indexOf(t)<0){g.push(t),c.push(Number(t));break}},n=e=>{if(e.value>e.sides)throw new Error(`Invalid dice roll: value (${e.value}) must be between 1 and ${e.sides}.`)};if(0===t[0].trim().length){const t=i.shift(),s="number"==typeof t?t:f(t)?t.value:0;f(t)&&n(t),l.push([s]);for(const t in m)if(m[t]===e){m[t]=String(s),u.push(Number(t));break}return r(),s}const s=[],o=Number(t[0]),a=["("];let h="(";for(let e=0;e<o;e++){const t=i.shift(),r="number"==typeof t?t:f(t)?t.value:0;f(t)&&n(t),a.push(String(r));const l=e<o-1?" + ":")";a.push(l),h+=`${r}${l}`,s.push(r)}for(const t in m){const r=Number(t);if(m[r]===e){m.splice(r,1,...a);let e=1;for(let t=0;t<o;t++)u.push(r+t+e),e++;break}}return l.push(s),r(),h});let w;try{w=Tr._safeEvaluate(y)}catch(e){if(!(e instanceof Error))throw new Error("Unknown Error");throw new Error(`Error evaluating expression "${y}" (from "${a}"): ${e.message}`)}n.push({rawTokensP:d,rawTokens:p,tokens:m,rawDiceTokenSlots:c,diceTokenSlots:u,dicesResult:l,total:w}),r+=w}return{final:r,steps:n}}static rollArrayIndex(e){const t=Array.isArray(e),r=e instanceof Set;if(!t&&!r)throw new TypeError("rollArrayIndex expects an array or Set.");return Math.floor(Math.random()*(t?e.length:e.size))}#ps;#ys;get maxValue(){return this.#ps}set maxValue(e){if(!Number.isInteger(e)||e<0)throw new TypeError("maxValue must be an integer greater than -1.");this.#ps=e}get allowZero(){return this.#ys}set allowZero(e){if("boolean"!=typeof e)throw new TypeError("allowZero must be a boolean.");this.#ys=e}constructor({maxValue:e,allowZero:t=!0}){if("boolean"!=typeof t)throw new TypeError("allowZero must be an boolean.");if(!Number.isInteger(e)||e<0)throw new TypeError("maxValue must be an integer greater than -1.");this.#ps=e,this.#ys=t}roll(){const e=this.#ys?0:1;return Math.floor(Math.random()*(this.#ps-e+1))+e}}const Sr=Tr,xr=class{#T=null;get overlay(){return this.#T}#ws=null;get messageElement(){return this.#ws}#j;get container(){return this.#j}#bs={fadeIn:null,fadeOut:null,zIndex:9999};get options(){return{...this.#bs}}set options(e){if("object"!=typeof e||null===e)throw new TypeError("options must be an object");if(void 0!==e.fadeIn&&null!==e.fadeIn&&("number"!=typeof e.fadeIn||e.fadeIn<0))throw new TypeError("fadeIn must be a non-negative number or null");if(void 0!==e.fadeOut&&null!==e.fadeOut&&("number"!=typeof e.fadeOut||e.fadeOut<0))throw new TypeError("fadeOut must be a non-negative number or null");if(void 0!==e.zIndex&&("number"!=typeof e.zIndex||!Number.isInteger(e.zIndex)))throw new TypeError("zIndex must be an integer number");this.#bs={fadeIn:e.fadeIn??null,fadeOut:e.fadeOut??null,zIndex:e.zIndex??9999}}#vs="none";get status(){return this.#vs}#Es="";get defaultMessage(){return this.#Es}set defaultMessage(e){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("defaultMessage must be a string or an HTMLElement");this.#Es=e}#Ts=null;get message(){return this.#Ts}#Ss=!1;get allowHtmlText(){return this.#Ss}set allowHtmlText(e){if("boolean"!=typeof e)throw new TypeError("allowHtmlText must be a boolean");this.#Ss=e}#xs=null;get fadeInTimeout(){return null!==this.#xs}#As=null;get fadeOutTimeout(){return null!==this.#As}get visible(){return!!this.#T}#Cs=null;get onChange(){return this.#Cs}set onChange(e){if(null!==e&&"function"!=typeof e)throw new TypeError("onChange must be a function or null");this.#Cs=e}_emitChange(){"function"==typeof this.#Cs&&this.#Cs(this.#vs)}constructor(e=document.body){if(!(e instanceof HTMLElement))throw new TypeError("container must be an HTMLElement");this.#j=e}_updateMessage(e=this.#Es){if(!this.#ws)throw new Error("messageElement is not initialized");if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");if(this.#Ts=e,"string"==typeof e)this.#Ss?this.#ws.innerHTML=e:this.#ws.textContent=e;else{if(!this.#Ss)throw new Error("HTMLElement messages require allowHtmlText = true");this.#ws.textContent="",this.#ws.appendChild(e)}}_removeOldClasses(){this.#T?.classList.remove("active"),this.#T?.classList.remove("fadeIn"),this.#T?.classList.remove("fadeOut")}start(e=this.#Es){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");if(!this.#T){this.#T=document.createElement("div"),this.#T.classList.add("loading-overlay"),this.#T.style.zIndex=String(this.#bs.zIndex);const t=document.createElement("div");t.classList.add("loading-container");const r=document.createElement("div");r.classList.add("loading-content");const n=document.createElement("div");n.classList.add("loading-spinner"),this.#ws=document.createElement("div"),this.#ws.classList.add("loading-message"),r.appendChild(n),r.appendChild(this.#ws),t.appendChild(r),this.#T.appendChild(t),this.#j.appendChild(this.#T),this._removeOldClasses(),this.#vs="fadeIn",this.#T.classList.add("fadeIn"),this._emitChange();const i=()=>{this._removeOldClasses(),this.#xs=null,this.#vs="active",this.#T?.classList.add("active"),this._emitChange()};return"number"==typeof this.#bs.fadeIn?(this.#xs&&clearTimeout(this.#xs),this.#xs=setTimeout(i,this.#bs.fadeIn)):i(),this._updateMessage(e),!0}return this.#ws&&this._updateMessage(e),!1}update(e=this.#Es){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");return!!this.#ws&&(this._updateMessage(e),!0)}stop(){if(this.#T){this._removeOldClasses(),this.#vs="fadeOut",this.#T.classList.add("fadeOut"),this._emitChange();const e=()=>{this._removeOldClasses(),this.#As=null,this.#vs="none",this.#T?.remove(),this.#T=null,this.#ws=null,this.#Ts=null,this._emitChange()};return"number"==typeof this.#bs.fadeOut?(this.#As&&clearTimeout(this.#As),this.#As=setTimeout(e,this.#bs.fadeOut)):e(),!0}return!1}};class Ar{static#Is=/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;static#Ms=/^#([A-Fa-f0-9]{8})$/;static#ks="(0|1|0?\\.\\d+)";static#Ls="(0|[1-9]\\d?|1\\d{2}|2[0-4]\\d|25[0-5])";static#Ns="(0|[1-9]\\d?|[1-2]\\d{2}|3[0-5]\\d|360)";static#Ds="(0|[1-9]?\\d|100)";static#_s=new RegExp(`^rgb\\(\\s*${Ar.#Ls}\\s*,\\s*${Ar.#Ls}\\s*,\\s*${Ar.#Ls}\\s*\\)$`);static#Rs=new RegExp(`^rgba\\(\\s*${Ar.#Ls}\\s*,\\s*${Ar.#Ls}\\s*,\\s*${Ar.#Ls}\\s*,\\s*${Ar.#ks}\\s*\\)$`);static#js=new RegExp(`^hsl\\(\\s*${Ar.#Ns}\\s*,\\s*${Ar.#Ds}%\\s*,\\s*${Ar.#Ds}%\\s*\\)$`);static#Os=new RegExp(`^hsla\\(\\s*${Ar.#Ns}\\s*,\\s*${Ar.#Ds}%\\s*,\\s*${Ar.#Ds}%\\s*,\\s*${Ar.#ks}\\s*\\)$`);static#Ps=new RegExp(`^hwb\\(\\s*${Ar.#Ns}(deg|grad|rad|turn)?\\s*${Ar.#Ds}%\\s*${Ar.#Ds}%\\s*\\)$`);static#$s="(-?\\d+)";static#Hs=new RegExp(`^lab\\(\\s*${Ar.#Ds}%?\\s*${Ar.#$s}%?\\s*${Ar.#$s}%?\\s*\\)$`);static#Bs=new RegExp(`^lch\\(\\s*${Ar.#Ds}%?\\s*${Ar.#Ds}%?\\s*${Ar.#Ns}(deg|grad|rad|turn)?\\s*\\)$`);static#Fs=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);static#zs=new Set(["transparent","currentColor"]);static getNames(){return Array.from(Ar.#Fs)}static addName(e){const t=Ar.#Fs.size;return Ar.#Fs.add(e.toLowerCase()),Ar.#Fs.size>t}static removeName(e){return Ar.#Fs.delete(e.toLowerCase())}static hasName(e){return Ar.#Fs.has(e.toLowerCase())}static getSpecialNames(){return Array.from(Ar.#zs)}static addSpecialName(e){const t=Ar.#zs.size;return Ar.#zs.add(e),Ar.#zs.size>t}static removeSpecialName(e){return Ar.#zs.delete(e)}static hasSpecialName(e){return Ar.#zs.has(e)}#Ws;get code(){return this.#Ws}#qs;get type(){return this.#qs}constructor(e){this.#Ws=e,this.#qs=Ar.isColor(this.#Ws)}static isHex(e){if("string"!=typeof e)throw new TypeError("isHex: input must be a string.");return Ar.#Is.test(e.trim())}isHex(){return Ar.isHex(this.#Ws)}static isHexa(e){if("string"!=typeof e)throw new TypeError("isHexa: input must be a string.");return Ar.#Ms.test(e.trim())}isHexa(){return Ar.isHexa(this.#Ws)}static isRgb(e){if("string"!=typeof e)throw new TypeError("isRgb: input must be a string.");return Ar.#_s.test(e.trim())}isRgb(){return Ar.isRgb(this.#Ws)}static isRgba(e){if("string"!=typeof e)throw new TypeError("isRgba: input must be a string.");return Ar.#Rs.test(e.trim())}isRgba(){return Ar.isRgba(this.#Ws)}static isHsl(e){if("string"!=typeof e)throw new TypeError("isHsl: input must be a string.");return Ar.#js.test(e.trim())}isHsl(){return Ar.isHsl(this.#Ws)}static isHsla(e){if("string"!=typeof e)throw new TypeError("isHsla: input must be a string.");return Ar.#Os.test(e.trim())}isHsla(){return Ar.isHsla(this.#Ws)}static isHwb(e){if("string"!=typeof e)throw new TypeError("isHwb: input must be a string.");return Ar.#Ps.test(e.trim())}isHwb(){return Ar.isHwb(this.#Ws)}static isLab(e){if("string"!=typeof e)throw new TypeError("isLab: input must be a string.");return Ar.#Hs.test(e.trim())}isLab(){return Ar.isLab(this.#Ws)}static isLch(e){if("string"!=typeof e)throw new TypeError("isLch: input must be a string.");return Ar.#Bs.test(e.trim())}isLch(){return Ar.isLch(this.#Ws)}static isName(e){if("string"!=typeof e)throw new TypeError("isName: input must be a string.");return Ar.#Fs.has(e.trim().toLowerCase())}isName(){return Ar.isName(this.#Ws)}static isSpecialName(e){if("string"!=typeof e)throw new TypeError("isSpecialName: input must be a string.");return Ar.#zs.has(e.trim())}isSpecialName(){return Ar.isSpecialName(this.#Ws)}static isColor(e){if("string"!=typeof e)throw new TypeError("isColor: input must be a string.");return Ar.isHex(e)?"hex":Ar.isHexa(e)?"hexa":Ar.isRgb(e)?"rgb":Ar.isRgba(e)?"rgba":Ar.isHsl(e)?"hsl":Ar.isHsla(e)?"hsla":Ar.isHwb(e)?"hwb":Ar.isLab(e)?"lab":Ar.isLch(e)?"lch":Ar.isName(e)?"name":Ar.isSpecialName(e)?"specialName":null}parse(){switch(this.#qs){case"hex":return Ar.parseHex(this.code);case"hexa":return Ar.parseHexa(this.code);case"rgb":return Ar.parseRgb(this.code);case"rgba":return Ar.parseRgba(this.code);case"hsl":return Ar.parseHsl(this.code);case"hsla":return Ar.parseHsla(this.code);case"hwb":return Ar.parseHwb(this.code);case"lab":return Ar.parseLab(this.code);case"lch":return Ar.parseLch(this.code);case"name":case"specialName":return this.#Ws.trim().toLowerCase();default:return null}}static parseHex(e){if("string"!=typeof e)throw new TypeError("parseHex: input must be a string.");const t=new RegExp(Ar.#Is,"gm").exec(e.trim());return t?t[1]:null}parseHex(){return Ar.parseHex(this.#Ws)}static parseHexa(e){if("string"!=typeof e)throw new TypeError("parseHexa: input must be a string.");const t=new RegExp(Ar.#Ms,"gm").exec(e.trim());return t?t[1]:null}parseHexa(){return Ar.parseHexa(this.#Ws)}static parseRgb(e){if("string"!=typeof e)throw new TypeError("parseRgb: input must be a string.");const t=new RegExp(Ar.#_s,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseRgb(){return Ar.parseRgb(this.#Ws)}static parseRgba(e){if("string"!=typeof e)throw new TypeError("parseRgba: input must be a string.");const t=new RegExp(Ar.#Rs,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])]:null}parseRgba(){return Ar.parseRgba(this.#Ws)}static parseHsl(e){if("string"!=typeof e)throw new TypeError("parseHsl: input must be a string.");const t=new RegExp(Ar.#js,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseHsl(){return Ar.parseHsl(this.#Ws)}static parseHsla(e){if("string"!=typeof e)throw new TypeError("parseHsla: input must be a string.");const t=new RegExp(Ar.#Os,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])]:null}parseHsla(){return Ar.parseHsla(this.#Ws)}static parseHwb(e){if("string"!=typeof e)throw new TypeError("parseHwb: input must be a string.");const t=new RegExp(Ar.#Ps,"gm").exec(e.trim());return t?[parseFloat(t[1]),t[2]??null,parseFloat(t[3]),parseFloat(t[4])]:null}parseHwb(){return Ar.parseHwb(this.#Ws)}static parseLab(e){if("string"!=typeof e)throw new TypeError("parseLab: input must be a string.");const t=new RegExp(Ar.#Hs,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseLab(){return Ar.parseLab(this.#Ws)}static parseLch(e){if("string"!=typeof e)throw new TypeError("parseLch: input must be a string.");const t=new RegExp(Ar.#Bs,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),t[4]??null]:null}parseLch(){return Ar.parseLch(this.#Ws)}}const Cr=Ar,Ir=class{#Vs;#Us;#Ks;#Wi;#dn=null;_getDate(){const e=new Date,t=e.getSeconds(),r=e.getMinutes(),n=e.getHours();return{now:e,s:t,m:r,h:n}}constructor(e={}){this.#Wi={bgColor:"#f0f0f0",borderColor:"#333",borderWidth:8,markColor:"#333",hourHandColor:"#000",minuteHandColor:"#444",secondHandColor:"#d81c1c",textColor:"#000",skinUrl:null,showNumbers:!0,showSeconds:!0,size:800,sizeAdjust:.04,padding:45,angleDistance:.95,pwH:.008,phH:.08,pwM:.005,phM:.03,...e},this.#Vs=document.createElement("div"),this.#Vs.className="analog-clock-container",this.#Vs.style.position="relative",this.#Vs.style.borderRadius="50%",this.#Vs.style.overflow="hidden",this.#Vs.style.boxSizing="border-box",this.#Ks=document.createElement("div"),this.#Ks.style.position="absolute",this.#Ks.style.inset="0",this.#Ks.style.backgroundSize="cover",this.#Ks.style.backgroundPosition="center",this.#Ks.style.zIndex="0",this.#Us=document.createElement("div"),this.#Us.style.position="absolute",this.#Us.style.inset="0",this.#Us.style.zIndex="1",this.#Us.style.pointerEvents="none";const t=document.createElement("div");t.style.position="absolute",t.style.inset="0",t.style.zIndex="2",t.style.pointerEvents="none",t.innerHTML='\n <div class="hand hour-hand"></div>\n <div class="hand minute-hand"></div>\n <div class="hand second-hand"></div>\n <div class="center-pin"></div>\n ',this.#Vs.appendChild(this.#Ks),this.#Vs.appendChild(this.#Us),this.#Vs.appendChild(t);const r=document.createElement("style");r.textContent="\n .analog-clock-container .hand {\n position: absolute;\n bottom: 50%;\n left: 50%;\n transform-origin: bottom center;\n border-radius: 4px;\n transform: translateX(-50%) rotate(0deg);\n z-index: 5;\n }\n .analog-clock-container .center-pin {\n position: absolute;\n top: 50%; left: 50%;\n width: 12px; height: 12px;\n background: #333;\n border-radius: 50%;\n transform: translate(-50%, -50%);\n z-index: 10;\n }\n .analog-clock-container .clock-mark {\n position: absolute;\n top: 50%; left: 50%;\n background: currentColor;\n transform-origin: center center;\n }\n .analog-clock-container .clock-number {\n position: absolute;\n top: 50%; left: 50%;\n transform: translate(-50%, -50%);\n font-family: sans-serif;\n font-weight: bold;\n text-align: center;\n line-height: 1;\n }\n ",this.#Vs.appendChild(r),this._applyConfig(),this._renderFace(),this._startTicker()}_applyConfig(){const e=this.#Vs.style,t=this.#Wi;e.width=`${t.size}px`,e.height=`${t.size}px`,e.border=`${t.borderWidth}px solid ${t.borderColor}`,e.backgroundColor=t.bgColor,t.skinUrl?(this.#Ks.style.backgroundImage=`url(${t.skinUrl})`,this.#Ks.style.display="block"):this.#Ks.style.display="none";const r=e=>{const t=this.#Vs.querySelector(e);if(!(t instanceof HTMLDivElement))throw new Error(`TinyAnalogClock: Element ${e} not found.`);return t},n=r(".hour-hand");n.style.backgroundColor=t.hourHandColor,n.style.width=.025*t.size+"px",n.style.height=.25*t.size+"px",n.style.marginLeft=.025*t.size/-2+"px",n.style.bottom="50%",n.style.left="50%",n.style.transformOrigin="bottom center";const i=r(".minute-hand");i.style.backgroundColor=t.minuteHandColor,i.style.width=.015*t.size+"px",i.style.height=.35*t.size+"px",i.style.marginLeft=.015*t.size/-2+"px";const s=r(".second-hand");t.showSeconds?(s.style.display="block",s.style.backgroundColor=t.secondHandColor,s.style.width=.005*t.size+"px",s.style.height=.4*t.size+"px",s.style.marginLeft=.005*t.size/-2+"px"):s.style.display="none",r(".center-pin").style.background=t.borderColor}_renderFace(){this.#Us.innerHTML="";const e=this.#Wi.size/2-this.#Wi.borderWidth;for(let t=0;t<60;t++){const r=t%5==0,n=document.createElement("div");n.className="clock-mark";const i=r?this.#Wi.size*this.#Wi.pwH:this.#Wi.size*this.#Wi.pwM,s=r?this.#Wi.size*this.#Wi.phH:this.#Wi.size*this.#Wi.phM,o=this.#Wi.markColor;n.style.width=`${i}px`,n.style.height=`${s}px`,n.style.color=o;const a=e-this.#Wi.padding-s/2;n.style.transform=`translate(-50%, -50%) rotate(${6*t}deg) translate(0, -${a}px)`,this.#Us.appendChild(n)}if(this.#Wi.showNumbers)for(let t=1;t<=12;t++){const r=30*t*(Math.PI/180),n=e*this.#Wi.angleDistance,i=e+Math.sin(r)*n,s=e-Math.cos(r)*n,o=document.createElement("div");o.className="clock-number",o.innerText=t.toString(),o.style.left=`${i}px`,o.style.top=`${s}px`,o.style.color=this.#Wi.textColor,o.style.fontSize=this.#Wi.size*this.#Wi.sizeAdjust+"px",this.#Us.appendChild(o)}}_startTicker(){if(this.#dn)return;const e=()=>{const{s:t,m:r,h:n}=this._getDate(),i=6*t,s=6*r+.1*t,o=n%12*30+.5*r,a=e=>{const t=this.#Vs.querySelector(e);if(!(t instanceof HTMLDivElement))throw new Error(`${e} not found.`);return t};this.#Vs.querySelector(".second-hand")&&(a(".second-hand").style.transform=`rotate(${i}deg)`),a(".minute-hand").style.transform=`rotate(${s}deg)`,a(".hour-hand").style.transform=`rotate(${o}deg)`,this.#dn=requestAnimationFrame(e)};e()}get element(){return this.#Vs}set size(e){if("number"!=typeof e||e<=0||isNaN(e))throw new Error(`TinyAnalogClock: 'size' must be a positive number. Received: ${e}`);this.#Wi.size=e,this._applyConfig(),this._renderFace()}get size(){return this.#Wi.size}set skinUrl(e){if(null!==e&&"string"!=typeof e)throw new Error("TinyAnalogClock: 'skin' must be a URL string or null. Received type: "+typeof e);this.#Wi.skinUrl=e,this._applyConfig()}get skinUrl(){return this.#Wi.skinUrl}set borderColor(e){if("string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'borderColor' must be a non-empty string. Received: ${e}`);this.#Wi.borderColor=e,this._applyConfig(),this._renderFace()}get borderColor(){return this.#Wi.borderColor}set markColor(e){if("string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'markColor' must be a non-empty string. Received: ${e}`);this.#Wi.markColor=e,this._applyConfig(),this._renderFace()}get markColor(){return this.#Wi.markColor}set textColor(e){if("string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'textColor' must be a non-empty string. Received: ${e}`);this.#Wi.textColor=e,this._applyConfig(),this._renderFace()}get textColor(){return this.#Wi.textColor}set showNumbers(e){if("boolean"!=typeof e)throw new Error("TinyAnalogClock: 'showNumbers' must be a boolean. Received type: "+typeof e);this.#Wi.showNumbers=e,this._renderFace()}get showNumbers(){return this.#Wi.showNumbers}set bgColor(e){if("string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'bgColor' must be a non-empty string.");this.#Wi.bgColor=e,this._applyConfig()}get bgColor(){return this.#Wi.bgColor}set borderWidth(e){if("number"!=typeof e||e<0)throw new Error("TinyAnalogClock: 'borderWidth' must be a non-negative number.");this.#Wi.borderWidth=e,this._applyConfig(),this._renderFace()}get borderWidth(){return this.#Wi.borderWidth}set hourHandColor(e){if("string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'hourHandColor' must be a non-empty string.");this.#Wi.hourHandColor=e,this._applyConfig()}get hourHandColor(){return this.#Wi.hourHandColor}set minuteHandColor(e){if("string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'minuteHandColor' must be a non-empty string.");this.#Wi.minuteHandColor=e,this._applyConfig()}get minuteHandColor(){return this.#Wi.minuteHandColor}set secondHandColor(e){if("string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'secondHandColor' must be a non-empty string.");this.#Wi.secondHandColor=e,this._applyConfig()}get secondHandColor(){return this.#Wi.secondHandColor}set showSeconds(e){if("boolean"!=typeof e)throw new Error("TinyAnalogClock: 'showSeconds' must be a boolean.");this.#Wi.showSeconds=e,this._applyConfig()}get showSeconds(){return this.#Wi.showSeconds}set sizeAdjust(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'sizeAdjust' must be a positive number.");this.#Wi.sizeAdjust=e,this._renderFace()}get sizeAdjust(){return this.#Wi.sizeAdjust}set padding(e){if("number"!=typeof e||e<0)throw new Error("TinyAnalogClock: 'padding' must be a non-negative number.");this.#Wi.padding=e,this._renderFace()}get padding(){return this.#Wi.padding}set angleDistance(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'angleDistance' must be a positive number.");this.#Wi.angleDistance=e,this._renderFace()}get angleDistance(){return this.#Wi.angleDistance}set pwH(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'pwH' must be a positive number.");this.#Wi.pwH=e,this._renderFace()}get pwH(){return this.#Wi.pwH}set phH(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'phH' must be a positive number.");this.#Wi.phH=e,this._renderFace()}get phH(){return this.#Wi.phH}set pwM(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'pwM' must be a positive number.");this.#Wi.pwM=e,this._renderFace()}get pwM(){return this.#Wi.pwM}set phM(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'phM' must be a positive number.");this.#Wi.phM=e,this._renderFace()}get phM(){return this.#Wi.phM}destroy(){this.#dn&&(cancelAnimationFrame(this.#dn),this.#dn=null),this.#Vs.remove()}},Mr=class{#Js=[];#ge=!1;get history(){return[...this.#Js]}set history(e){if(!Array.isArray(e))throw new TypeError("History data must be provided as an array.");if(!e.every(e=>"string"==typeof e))throw new TypeError("All items in the history array must be strings.");this.#Js=[...e]}get size(){return this.#Js.length}constructor(e=[]){this.history=e}#Gs(){if(this.#ge)throw new Error("Cannot perform operations on a destroyed TinyTextDiffer instance.")}#Ys(e){if("number"!=typeof e)throw new TypeError("The provided index must be a valid number.")}#Xs(e){if("string"!=typeof e)throw new TypeError("The provided text must be a valid string.")}get(e){if(this.#Gs(),this.#Ys(e),void 0===this.#Js[e])throw new Error(`No text version found at index ${e}.`);return this.#Js[e]}has(e){return this.#Gs(),this.#Ys(e),void 0!==this.#Js[e]}add(e){this.#Gs(),this.#Xs(e),this.#Js.push(e)}remove(){return this.#Gs(),this.#Js.pop()}addAt(e,t){this.#Gs(),this.#Ys(e),this.#Xs(t),this.#Js.splice(e,0,t)}removeAt(e){this.#Gs(),this.#Ys(e);const t=this.#Js.length;return this.#Js.splice(e,1),t!==this.#Js.length}clear(){this.#Gs(),this.#Js=[]}compare(...e){this.#Gs();const t=e.length;if(0===t||t%2!=0)throw new Error("The compare method requires an even number of indices to form comparison pairs.");const r=[];for(let n=0;n<t;n+=2){const i=n+1;if(i>t-1)continue;this.#Ys(e[n]),this.#Ys(e[i]);const s=this.#Js[e[n]],o=this.#Js[e[i]];r.push(this._computeDiff(s,o))}return r}_computeDiff(e,t){const r=e.length,n=t.length,i=Array(r+1).fill(null).map(()=>Array(n+1).fill(0));let s=1,o=1;for(s=1;s<=r;s++)for(o=1;o<=n;o++)e[s-1]===t[o-1]?i[s][o]=i[s-1][o-1]+1:i[s][o]=Math.max(i[s-1][o],i[s][o-1]);s=r,o=n;const a=[];for(;s>0||o>0;)s>0&&o>0&&e[s-1]===t[o-1]?(a.unshift({value:e[s-1],type:"normal"}),s--,o--):o>0&&(0===s||i[s][o-1]>=i[s-1][o])?(a.unshift({value:t[o-1],type:"added"}),o--):s>0&&(0===o||i[s][o-1]<i[s-1][o])&&(a.unshift({value:e[s-1],type:"deleted"}),s--);return a.reduce((e,t)=>{const r=e.length-1;return e.length>0&&e[r].type===t.type?e[r].value+=t.value:e.push(t),e},[])}destroy(){this.#ge||(this.#Js=[],this.#ge=!0)}};class kr{static generateHash(e){const t="object"==typeof e?JSON.stringify(e):String(e);let r=0;for(let e=0,n=t.length;e<n;e++)r=(r<<5)-r+t.charCodeAt(e),r|=0;return r.toString(36)}#Qs=[];get oldArray(){return this.#Qs}set oldArray(e){if(!Array.isArray(e))throw new TypeError("The provided oldArray must be a valid Array.");this.#Qs=e}constructor(e){void 0!==e&&(this.oldArray=e)}_generateHash(e){return kr.generateHash(e)}compare(e){if(!Array.isArray(e))throw new TypeError("The provided newArray must be a valid Array.");const t={oldItemsMap:new Map,affectedItems:[]};for(const e of this.#Qs){const r=this._generateHash(e);t.oldItemsMap.set(r,e)}for(const r of e){const e=this._generateHash(r);t.oldItemsMap.has(e)?t.oldItemsMap.delete(e):t.affectedItems.push({item:r,status:"added"})}for(const e of t.oldItemsMap.values())t.affectedItems.push({item:e,status:"deleted"});return t.affectedItems}}const Lr=kr,Nr=e=>{if(!Array.isArray(e))throw new TypeError("Parameter 'sets' must be an array.");if(!e.every(e=>e instanceof jr))throw new TypeError("All elements in the array must be instances of FuzzySet.")},Dr=(e,t,r=.5)=>{Rr(e,"object","defuzzifyCentroid.fuzzyOutput");for(const t in e)Rr(e[t],"number",`fuzzyOutput['${t}']`);Nr(t),Rr(r,"number","defuzzifyCentroid.step");let n=0,i=0;for(let s=0;s<=100;s+=r){let r=0;t.forEach(t=>{const n=e[t.name]||0,i=Math.min(n,t.calculate(s));r=Math.max(r,i)}),n+=s*r,i+=r}return 0===i?0:n/i},_r=(e,t,r,n,i,s=!1)=>{if(s){if(e<=t||e>=i)return 0;if(e>=r&&e<=n)return 1}const o=t===r?1:(e-t)/(r-t),a=n===i?1:(i-e)/(i-n),l=Math.max(0,Math.min(o,1,a));return isNaN(l)?0:l},Rr=(e,t,r)=>{if(typeof e!==t)throw new TypeError(`Parameter '${r}' must be a ${t}.`)};class jr{static trapezoid(e,t,r,n,i,s=!1){return _r(e,t,r,n,i,s)}#Zs="";#eo=0;#to=0;#ro=0;#no=0;#io=!1;get name(){return this.#Zs}set name(e){Rr(e,"string","FuzzySet.name"),this.#Zs=e}get a(){return this.#eo}set a(e){Rr(e,"number","FuzzySet.a"),this.#eo=e}get b(){return this.#to}set b(e){Rr(e,"number","FuzzySet.b"),this.#to=e}get c(){return this.#ro}set c(e){Rr(e,"number","FuzzySet.c"),this.#ro=e}get d(){return this.#no}set d(e){Rr(e,"number","FuzzySet.d"),this.#no=e}get optimize(){return this.#io}set optimize(e){Rr(e,"boolean","FuzzySet.optimize"),this.#io=e}constructor(e,t,r,n,i,s=!1){this.name=e,this.a=t,this.b=r,this.c=n,this.d=i,this.optimize=s}calculate(e){return Rr(e,"number","calculate.x"),jr.trapezoid(e,this.#eo,this.#to,this.#ro,this.#no,this.#io)}}class Or{#so=new Map;addVariable(e,t){Rr(e,"string","addVariable.name"),Nr(t),this.#so.set(e,t)}removeVariable(e){return Rr(e,"string","removeVariable.name"),this.#so.delete(e)}getVariable(e){Rr(e,"string","getVariable.name");const t=this.#so.get(e);if(!t)throw new Error(`Linguistic variable '${e}' not found in the inference system.`);return[...t]}hasVariable(e){return Rr(e,"string","hasVariable.name"),this.#so.has(e)}fuzzify(e,t){Rr(e,"string","fuzzify.varName"),Rr(t,"number","fuzzify.value");const r=this.#so.get(e)||[],n={};return r.forEach(e=>{n[e.name]=e.calculate(t)}),n}}class Pr{#oo=new Set;get appliedPlugins(){if(this.#ao)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return[...this.#oo]}#lo=[];get appliedPluginClasses(){if(this.#ao)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return[...this.#lo]}get size(){if(this.#ao)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return this.#lo.length}#uo;get currentClass(){if(this.#ao)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return this.#uo}#ao=!1;get used(){return this.#ao}constructor(e,t=[]){this.#uo=e,this.#lo=[...t,e]}#co(e,t,r){if(this.#ao)throw new Error("[TinyClassManager] Cannot reuse a consumed manager instance.");if(this.#oo.has(e))throw new Error(`[TinyClassManager] Plugin conflict: "${e}" is already installed.`);for(const r of t)if(!this.#oo.has(r))throw new Error(`[TinyClassManager] Missing Dependency: "${e}" requires "${r}" to be installed first.`);const n=new Pr(r,this.#lo);return this.#oo.forEach(e=>n.#oo.add(e)),n.#oo.add(e),this.#ao=!0,this.#oo.clear(),this.#lo=[],n}use(e){const t=e.dependencies||[],r=e.apply(this.#uo,this.appliedPluginClasses);return this.#co(e.name,t,r)}insert(e){const t=e(this.#uo,this.appliedPluginClasses),r=t._tinyDepName;if(!r)throw new Error("[TinyClassManager] Plugin class must define a static '_tinyDepName' property.");const n=t._tinyDeps??[];if(!Array.isArray(n)||!n.every(e=>"string"==typeof e))throw new Error("[TinyClassManager] Plugin class must define a static array of strings in '_tinyDepName' property.");return this.#co(r,n,t)}build(){if(this.#ao)throw new Error("[TinyClassManager] Cannot build from an already finalized manager.");return this.#ao=!0,this.#oo.clear(),this.#lo=[],this.#uo}}const $r=Pr;class Hr extends zt{static async parseContent(e,t,r,n,i){return Dt(e,t,r,n,i,Hr.#ho)}static#ho="Unknown Artist";static get unknownArtist(){return Hr.#ho}static set unknownArtist(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("unknownArtist must have an string or function.");Hr.#ho=e}get size(){return this.#do.length+this.#po.length}get musicSize(){return this.#do.length}get voiceSize(){return this.#po.length}get customPosSize(){return this.#mo.length}get tasksSize(){return this.#fo.length}get cycleCacheSize(){return this.#go.size}#do=[];get musicList(){return structuredClone(this.#do)}#po=[];get voiceList(){return structuredClone(this.#po)}#mo=[];get customPositions(){return structuredClone(this.#mo)}#fo=[];get scheduledTasks(){return structuredClone(this.#fo)}get allList(){return[...this.musicList,...this.voiceList]}#Ei=0;get seed(){return this.#Ei}set seed(e){if("number"!=typeof e)throw new TypeError("Seed must be a number.");this.#Ei=e,this.#go.clear(),this.emit("seedChanged",{seed:e})}#yo=Date.now();get anchorDate(){return this.#yo}#go=new Map;#Wi={mode:"playlist",voiceMode:"playlist",silenceDuration:0,queryLimit:1e5,voiceAfterMusic:!0,voiceMin:0,voiceMax:1,musicMaxConsecutive:0,voiceMaxConsecutive:0};get config(){return structuredClone(this.#Wi)}set config(e){this.#wo(e),this.#Wi=structuredClone(e),this.#go.clear(),this.emit("configChanged",{config:this.config})}#wo(e){if("object"!=typeof e||null===e)throw new TypeError("Configuration must be a valid object.");const t=["playlist","random"];if(void 0!==e.mode&&!t.includes(e.mode))throw new TypeError(`Invalid mode: "${e.mode}". Must be one of: ${t.join(", ")}.`);if(void 0!==e.voiceMode&&!t.includes(e.voiceMode))throw new TypeError(`Invalid voiceMode: "${e.voiceMode}". Must be one of: ${t.join(", ")}.`);if(void 0!==e.silenceDuration&&("number"!=typeof e.silenceDuration||e.silenceDuration<0))throw new TypeError("silenceDuration must be a non-negative number.");if(void 0!==e.queryLimit&&("number"!=typeof e.queryLimit||e.queryLimit<=0))throw new TypeError("queryLimit must be a positive number.");if(void 0!==e.voiceAfterMusic&&"boolean"!=typeof e.voiceAfterMusic)throw new TypeError("voiceAfterMusic must be a boolean.");if(void 0!==e.voiceMin&&("number"!=typeof e.voiceMin||e.voiceMin<0))throw new TypeError("voiceMin must be a non-negative number.");if(void 0!==e.voiceMax&&("number"!=typeof e.voiceMax||e.voiceMax<0))throw new TypeError("voiceMax must be a non-negative number.");if(void 0!==e.musicMaxConsecutive&&("number"!=typeof e.musicMaxConsecutive||e.musicMaxConsecutive<-1))throw new TypeError("musicMaxConsecutive must be a number >= -1.");if(void 0!==e.voiceMaxConsecutive&&("number"!=typeof e.voiceMaxConsecutive||e.voiceMaxConsecutive<-1))throw new TypeError("voiceMaxConsecutive must be a number >= -1.");const r=e.voiceMin??this.#Wi.voiceMin,n=e.voiceMax??this.#Wi.voiceMax;if(n<r)throw new RangeError(`Logical error: voiceMax (${n}) cannot be less than voiceMin (${r}).`)}constructor(e=null,t=0){if(super(),null!==e&&"object"!=typeof e)throw new TypeError("initialData must be an object or null.");if("number"!=typeof t)throw new TypeError("seed must be a number.");this.#Ei=t,e?this.#bo(e):this.#yo=Date.now()}add(e,t,r=!0){if(!["music","voice","custom"].includes(e))throw new TypeError('Type must be "music", "voice", or "custom".');if(!t||"string"!=typeof t.id||"number"!=typeof t.duration)throw new TypeError("Content must have a string ID and a valid numerical duration in milliseconds.");if("boolean"!=typeof r)throw new TypeError("smartQueue must be a boolean.");"music"===e?(this.#do.push(t),this.#go.clear()):"voice"===e?(this.#po.push(t),this.#go.clear()):"custom"===e&&this.#vo(t,r),this.#Eo(Date.now()),this.emit("contentAdded",{type:e,data:structuredClone(t)})}scheduleTask(e,t,r,n,i=!0){if("number"!=typeof e||isNaN(e))throw new TypeError("timestamp must be a valid number.");if(!["add","remove","move"].includes(t))throw new TypeError('action must be "add", "remove", or "move".');if(!["music","voice"].includes(r))throw new TypeError('type must be "music" or "voice".');if("boolean"!=typeof i)throw new TypeError("smartQueue must be a boolean.");if("add"===t){if("object"!=typeof n||null===n||"string"!=typeof n.id||"number"!=typeof n.duration)throw new TypeError('Payload for "add" must be a MediaContent object (id: string, duration: number).')}else if("remove"===t){if("string"!=typeof n)throw new TypeError('Payload for "remove" must be a string (the content ID).')}else if("move"===t&&("object"!=typeof n||null===n||"string"!=typeof n.id||"number"!=typeof n.newIndex))throw new TypeError('Payload for "move" must be a ScheduledMovePayload (id: string, newIndex: number).');let s=e;if(i){const t=this.#To(e,e);t&&(s=t.absoluteEnd)}const o={timestamp:s,action:t,type:r,payload:n};this.#fo.push(o),this.#Eo(Date.now()),this.emit("taskScheduled",structuredClone(o))}remove(e){if("string"!=typeof e)throw new TypeError("id must be a string.");this.#do.filter(t=>t.id===e).forEach(e=>It(e)),this.#po.filter(t=>t.id===e).forEach(e=>It(e)),this.#mo.filter(t=>t.content?.id===e).forEach(e=>It(e.content));const t=t=>t.id!==e&&t.content?.id!==e;this.#do=this.#do.filter(t),this.#po=this.#po.filter(t),this.#mo=this.#mo.filter(t),this.#fo=this.#fo.filter(t=>"add"===t.action&&"object"==typeof t.payload&&null!==t.payload&&"id"in t.payload?t.payload.id!==e||(It(t.payload),!1):t.payload!==e),this.#go.clear(),this.emit("contentRemoved",{id:e})}setConfig(e){this.#wo(e);const t={...this.#Wi,...e};this.#wo(t),this.#Wi=t,this.#go.clear(),this.emit("configChanged",{config:this.config})}getCurrentEvent(){const e=Date.now();return this.#Eo(e),this.#To(e,e)}queryTimeline(e,t=10){if("number"!=typeof t||isNaN(t))throw new TypeError("Invalid query limit value. Ensure it is a number.");if(t>this.#Wi.queryLimit||t<=0)throw new RangeError(`Invalid query limit. Ensure it is > 0 and <= ${this.#Wi.queryLimit}.`);const r=new Hr(JSON.parse(this._exportState())),n=[];let i=e;for(let s=0;s<t;s++){r.#Eo(i);const t=r.#So(i,e);if(!t)break;n.push(t),i=t.absoluteEnd}return r.destroy(!1),this.emit("timelineQueried",{targetDate:e,limit:t,resultCount:n.length}),n}searchCustomPositions(){return this.#Eo(Date.now()),[...this.#mo]}async _processListForExport(e){return Promise.all(e.map(async e=>{const t=structuredClone(e);return t.picture&&Array.isArray(t.picture)&&(t.picture=await Promise.all(t.picture.map(async e=>({...e,data:await Ct(e.data)})))),t}))}_exportState(){return JSON.stringify({music:this.#do,voice:this.#po,custom:this.#mo,tasks:this.#fo,seed:this.#Ei,anchorDate:this.#yo,config:this.#Wi})}async exportState(){const e=await this._processListForExport(this.#do),t=await this._processListForExport(this.#po),r=await Promise.all(this.#mo.map(async e=>{const t=await this._processListForExport([e.content]);return{...e,content:t[0]}})),n=await Promise.all(this.#fo.map(async e=>{if("add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload){const t=await this._processListForExport([e.payload]);return{...e,payload:t[0]}}return e}));return JSON.stringify({music:e,voice:t,custom:r,tasks:n,seed:this.#Ei,anchorDate:this.#yo,config:this.#Wi})}importState(e){let t;if("string"==typeof e)try{t=JSON.parse(e)}catch{throw new TypeError("Provided string is not valid JSON.")}else{if("object"!=typeof e||null===e)throw new TypeError("Import data must be a valid JSON string or an object.");t=e}this.#bo(t),this.emit("stateImported",{data:structuredClone(t)})}_prng(e){return function(){let t=e+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}#xo(e,t,r,n=0){if(0===e.length)return[];if("random"!==r)return[...e];const i=e.map(e=>({...e,weight:e.weight??1})),s=this._prng(t),o=[];let a=null,l=0;for(;i.length>0;){let e=i;-1!==n&&null!==a&&l>n&&(e=i.filter(e=>e.id!==a),0===e.length&&(e=i));const t=e.reduce((e,t)=>e+t.weight,0);if(t<=0){o.push(...e);break}const r=s()*t;let u=0,c=null,h=-1;for(let t=0;t<e.length;t++)if(u+=e[t].weight,r<=u){c=e[t],h=i.findIndex(e=>c&&e.id===c.id);break}c&&-1!==h||(c=e[0],h=i.findIndex(e=>c&&e.id===c.id)),o.push(c),i.splice(h,1),c.id===a?l++:(a=c.id,l=1)}return o}#Ao(e){const t=this.#Ei+e,r=this._prng(10*t),n=this.#xo(this.#do,t+1,this.#Wi.mode,this.#Wi.musicMaxConsecutive),i=this.#xo(this.#po,t+2,this.#Wi.voiceMode,this.#Wi.voiceMaxConsecutive),s=[];let o=0,a=0;for(let e=0;e<n.length;e++){const t=n[e];if(s.push({...t,cycleStart:o,cycleEnd:o+t.duration}),o+=t.duration+this.#Wi.silenceDuration,this.#Wi.voiceAfterMusic&&i.length>0){const e=this.#Wi.voiceMax-this.#Wi.voiceMin+1,t=Math.floor(r()*e)+this.#Wi.voiceMin;for(let e=0;e<t;e++){const e=i[a%i.length];a++,s.push({...e,cycleStart:o,cycleEnd:o+e.duration}),o+=e.duration+this.#Wi.silenceDuration}}}return{items:s,duration:o}}#Co(e){if(0===this.#do.length)return null;let t=this.#yo,r=0;for(;;){if(r>this.#Wi.queryLimit)throw new Error("Safety limit hit during cycle location.");let n=this.#go.get(r);if(n||(n=this.#Ao(r),this.#go.set(r,n)),0===n.duration)return null;if(e>=t&&e<t+n.duration)return{block:n,startTimestamp:t,loopIndex:r};t+=n.duration,r++}}#So(e,t){const r=this.#mo.filter(t=>t.intendedTimestamp+t.content.duration>e).sort((e,t)=>e.intendedTimestamp-t.intendedTimestamp)[0];let n=null;if(r){const e=Math.max(t,r.intendedTimestamp);n=this.#Io(r.content,r.intendedTimestamp,e,!0)}const i=this.#Mo(e,t);return i||n?i?n?n.absoluteStart<=i.absoluteStart?n:(n.absoluteStart<i.absoluteEnd&&(i.absoluteEnd=n.absoluteStart,i.duration=i.absoluteEnd-i.absoluteStart,i.remainingTime=Math.max(0,i.absoluteEnd-t),i.progress=Math.min(1,i.elapsedTime/i.duration)),i):i:n:null}#Mo(e,t){let r=this.#Co(e);if(!r)return null;const{block:n,startTimestamp:i}=r,s=e-i;let o,a=n.items.find(e=>e.cycleEnd>s);if(a)o=i+a.cycleStart;else{if(r=this.#Co(i+n.duration),!r||0===r.block.items.length)return null;a=r.block.items[0],o=r.startTimestamp+a.cycleStart}const l=Math.max(t,o);return this.#Io(a,o,l,!1)}#To(e,t){const r=this.#mo.find(t=>e>=t.intendedTimestamp&&e<t.intendedTimestamp+t.content.duration);if(r)return this.#Io(r.content,r.intendedTimestamp,t,!0);const n=this.#Co(e);if(!n)return null;const{block:i,startTimestamp:s}=n,o=e-s,a=i.items.find(e=>o>=e.cycleStart&&o<e.cycleEnd);return a?this.#Io(a,s+a.cycleStart,t,!1):null}#Io(e,t,r,n){const i=r-t;return{id:e.id,title:e.title,artist:e.artist,duration:e.duration,url:e.url,absoluteStart:t,absoluteEnd:t+e.duration,elapsedTime:i,remainingTime:e.duration-i,progress:Math.min(1,i/e.duration),isCustom:n}}#vo(e,t){let r=e.timestamp||Date.now();const n=e.duration;if(t){const e=this.#To(r,r);e&&(r=e.absoluteEnd)}const i=[...this.#mo].sort((e,t)=>e.intendedTimestamp-t.intendedTimestamp);let s=r;if(i.some(e=>r<e.intendedTimestamp+e.content.duration&&r+n>e.intendedTimestamp)){const e=[];let t=Date.now();for(const r of i)r.intendedTimestamp>t&&e.push({start:t,end:r.intendedTimestamp}),t=Math.max(t,r.intendedTimestamp+r.content.duration+this.#Wi.silenceDuration);e.push({start:t,end:1/0});let o=1/0;for(const t of e)if(t.end-t.start>=n){let e=null;if(r>=t.start&&r+n<=t.end?e=r:r<t.start?e=t.start:r>t.end&&(e=t.end-n),null!==e){const t=Math.abs(r-e);t<o&&(o=t,s=e)}}}this.#mo.push({content:e,intendedTimestamp:s,originalTimestamp:e.timestamp||Date.now()})}#Eo(e){const t=this.#fo.filter(t=>t.timestamp<=e);this.#fo=this.#fo.filter(t=>t.timestamp>e);const r=this.#mo.filter(t=>t.intendedTimestamp+t.content.duration<=e);this.#mo=this.#mo.filter(t=>t.intendedTimestamp+t.content.duration>e);let n=!1;r.forEach(e=>{It(e.content),this.#Ei+=e.content.id.length,n=!0,this.emit("customPositionExpired",{contentId:e.content.id})}),t.length>0&&t.sort((e,t)=>e.timestamp-t.timestamp).forEach(e=>{const t="music"===e.type?this.#do:this.#po;if("add"===e.action)t.push(e.payload);else if("remove"===e.action){const r=e.payload,n=t.findIndex(e=>e.id===r);if(-1!==n){const[e]=t.splice(n,1);It(e)}}else if("move"===e.action){const r=e.payload,n=t.findIndex(e=>e.id===r.id);if(-1!==n){const[e]=t.splice(n,1);t.splice(r.newIndex,0,e)}}this.#yo=e.timestamp,this.#Ei+=1,n=!0,this.emit("taskExecuted",structuredClone(e))}),n&&this.#go.clear()}#bo(e){this.#do.forEach(e=>It(e)),this.#po.forEach(e=>It(e)),this.#mo.forEach(e=>It(e.content)),this.#fo.forEach(e=>{"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload&&It(e.payload)});const t=e=>e.map(e=>{const t={...e};return t.picture&&Array.isArray(t.picture)&&(t.picture=t.picture.map(e=>({...e,data:At(e.data,e.format)}))),t});this.#do=t(e.music),this.#po=t(e.voice),this.#Ei=e.seed||0,this.#yo=e.anchorDate||Date.now(),this.#Wi={...this.#Wi,...e.config||{}},this.#mo=e.custom.map(e=>({...e,content:t([e.content])[0]})),this.#fo=e.tasks.map(e=>"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload?{...e,payload:t([e.payload])[0]}:e)}destroy(e=!0){e&&(this.#do.forEach(e=>It(e)),this.#po.forEach(e=>It(e)),this.#mo.forEach(e=>It(e.content)),this.#fo.forEach(e=>{"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload&&It(e.payload)})),this.#do=[],this.#po=[],this.#mo=[],this.#fo=[],this.#go.clear(),this.emit("destroyed",{timestamp:Date.now()}),this.removeAllListeners()}}const Br=Hr;class Fr{constructor(){if(new.target===Fr)throw new Error("BaseMediaAdapter is an abstract class and cannot be instantiated directly.")}canHandle(e){throw new Error('Method "canHandle" must be implemented by the subclass.')}async play(e){throw new Error('Method "play" must be implemented by the subclass.')}async pause(){throw new Error('Method "pause" must be implemented by the subclass.')}async stop(){throw new Error('Method "stop" must be implemented by the subclass.')}async seek(e){throw new Error('Method "seek" must be implemented by the subclass.')}getCurrentTime(){throw new Error('Method "getCurrentTime" must be implemented by the subclass.')}setVolume(e){throw new Error('Method "setVolume" must be implemented by the subclass.')}}class zr extends zt{static BaseMediaAdapter=Fr;static#ho="Unknown Artist";static get unknownArtist(){return zr.#ho}static set unknownArtist(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("unknownArtist must have an string or function.");zr.#ho=e}static async parseContent(e,t,r,n,i){return Dt(e,t,r,n,i,zr.#ho)}#ko=new Map;#Lo=[];#No=-1;#Do="NONE";#_o=!1;#Ro=!1;#jo=1;#Oo;#Po;constructor(e={}){super(),this.#Oo=Boolean(e.persistVolume),this.#Po="string"==typeof e.volumeStorageKey?e.volumeStorageKey:"tiny_media_player_volume",this.#Oo&&this.#$o()}#$o(){try{if("undefined"!=typeof window&&window.localStorage){const e=window.localStorage.getItem(this.#Po);if(null!==e){const t=parseFloat(e);!isNaN(t)&&t>=0&&t<=1&&(this.#jo=t)}}}catch(e){console.warn("[TinyMediaPlayer] Failed to read volume from localStorage.",e)}}#Ho(){try{this.#Oo&&"undefined"!=typeof window&&window.localStorage&&window.localStorage.setItem(this.#Po,this.#jo.toString())}catch(e){console.warn("[TinyMediaPlayer] Failed to save volume to localStorage.",e)}}_getWeightedRandomIndex(){if(0===this.#Lo.length)return-1;if(1===this.#Lo.length)return 0;let e=0;for(let t=0;t<this.#Lo.length;t++){if(t===this.#No)continue;const r=this.#Lo[t];e+="number"==typeof r.weight&&r.weight>0?r.weight:1}let t=Math.random()*e;for(let e=0;e<this.#Lo.length;e++){if(e===this.#No)continue;const r=this.#Lo[e],n="number"==typeof r.weight&&r.weight>0?r.weight:1;if(t<n)return e;t-=n}return this.#No===this.#Lo.length-1?0:this.#Lo.length-1}get playlist(){return[...this.#Lo]}set playlist(e){if(!Array.isArray(e))throw new TypeError("Playlist must be an array of MediaContent objects.");e.forEach(e=>kt(e));const t=this.#Ro;let r=null;if(-1!==this.#No&&this.#Lo.length>0)try{r=this.#Bo()}catch(e){}this.#Lo=e,this.emit("playlistUpdate",this.playlist),0===this.#Lo.length?this.#No=-1:(this.#No>=this.#Lo.length||-1===this.#No)&&(this.#No=0),this.emit("trackChange",this.#No),t&&(async()=>{try{r&&await r.stop(),-1!==this.#No&&await this.play()}catch(e){console.warn("[TinyMediaPlayer] Background transition error on playlist update:",e)}})()}get currentIndex(){return this.#No}set currentIndex(e){if("number"!=typeof e)throw new TypeError("Current index must be a number.");if(e<-1||e>=this.#Lo.length&&this.#Lo.length>0)throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);if(this.#No===e)return;const t=this.#Ro;let r=null;if(-1!==this.#No&&this.#Lo.length>0)try{r=this.#Bo()}catch(e){}this.#No=e,this.emit("trackChange",this.#No),t&&(async()=>{try{r&&await r.stop(),-1!==this.#No&&await this.play()}catch(e){console.warn("[TinyMediaPlayer] Background transition error on index update:",e)}})()}get loopMode(){return this.#Do}set loopMode(e){const t=["NONE","TRACK","PLAYLIST"];if(!t.includes(e))throw new TypeError(`Loop mode must be one of: ${t.join(", ")}.`);this.#Do=e,this.emit("loopModeChange",this.#Do)}get isRandom(){return this.#_o}set isRandom(e){if("boolean"!=typeof e)throw new TypeError("Random mode state must be a boolean.");this.#_o=e,this.emit("randomModeChange",this.#_o)}get isPlaying(){return this.#Ro}get volume(){return this.#jo}set volume(e){if("number"!=typeof e)throw new TypeError("Volume must be a number.");if(e<0||e>1)throw new RangeError("Volume must be tightly constrained between 0.0 and 1.0.");if(this.#jo=e,this.#Ho(),this.emit("volumeChange",this.#jo),-1!==this.#No&&this.#Lo.length>0)try{const e=this.#Bo();e&&e.setVolume(this.#jo)}catch(e){}}get persistVolume(){return this.#Oo}set persistVolume(e){if("boolean"!=typeof e)throw new TypeError("Persist volume parameter must be a boolean.");this.#Oo=e,e&&this.#Ho()}get volumeStorageKey(){return this.#Po}set volumeStorageKey(e){if("string"!=typeof e)throw new TypeError("Volume storage key must be a string.");if(""===e.trim())throw new TypeError("Volume storage key cannot be an empty string.");const t=this.#Po;this.#Po=e;try{this.#Oo&&"undefined"!=typeof window&&window.localStorage&&(window.localStorage.removeItem(t),this.#Ho())}catch(e){console.warn("[TinyMediaPlayer] Failed to migrate volume storage key.",e)}}registerAdapter(e,t){if("string"!=typeof e)throw new TypeError("Adapter ID must be a string.");if(!(t instanceof Fr))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");this.#ko.set(e,t)}#Bo(){if(-1===this.#No||0===this.#Lo.length)return null;const e=this.#Lo[this.#No];for(const t of this.#ko.values())if(t.canHandle(e))return t;throw new Error(`No compatible adapter found for content ID: ${e.id}.`)}addTrack(e){if(!e||"object"!=typeof e||"string"!=typeof e.url)throw new TypeError("Track content must be a valid MediaContent object containing a URL.");const t={id:"",title:"",artist:"",url:"",duration:0,weight:1,title:null,album:null,albumartist:null,albumartists:[],genre:[],label:[],composer:[],year:null,artist:null,artists:[],disk:{no:null,of:null},track:{no:null,of:null},picture:[],...e};kt(t);const r=this.#Lo.push(t);return-1===this.#No&&(this.#No=0,this.emit("trackChange",this.#No)),this.emit("playlistUpdate",this.playlist),r}existsTrack(e){if("number"!=typeof e)throw new TypeError("Index must be a number.");return e>=0&&e<this.#Lo.length}getTrack(e){if("number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);return this.#Lo[e]}async removeTrack(e){if("number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);e===this.#No?(await this.stop(),this.#Lo.splice(e,1),0===this.#Lo.length?this.#No=-1:this.#No>=this.#Lo.length&&(this.#No=0),this.emit("trackChange",this.#No)):(this.#Lo.splice(e,1),e<this.#No&&(this.#No-=1,this.emit("trackChange",this.#No))),this.emit("playlistUpdate",this.playlist)}searchTrack(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("Search query must be a string or a boolean evaluation function.");const t=[];for(let r=0;r<this.#Lo.length;r++){const n=this.#Lo[r];let i=!1;if("function"==typeof e)i=Boolean(e(n));else{const t=e.toLowerCase(),r=n.title&&n.title.toLowerCase().includes(t),s=n.artist&&n.artist.toLowerCase().includes(t),o=n.album&&n.album.toLowerCase().includes(t);i=Boolean(r||s||o)}i&&t.push({track:n,index:r})}return t}async clearPlaylist(){await this.stop(),this.#Lo=[],this.#No=-1,this.emit("playlistUpdate",this.playlist),this.emit("trackChange",this.#No)}async play(){const e=this.#Bo();e&&(e.setVolume(this.#jo),await e.play(this.#Lo[this.#No]),this.#Ro=!0,this.emit("play",this.#No))}async pause(){const e=this.#Bo();e&&(await e.pause(),this.#Ro=!1,this.emit("pause",this.#No))}async stop(){const e=this.#Bo();e&&(await e.stop(),this.#Ro=!1,this.emit("stop",this.#No))}async next(){if(0!==this.#Lo.length)if(await this.stop(),"TRACK"!==this.#Do){if(this.#_o)this.#No=this._getWeightedRandomIndex();else{let e=this.#No+1;if(e>=this.#Lo.length){if("PLAYLIST"!==this.#Do)return;e=0}this.#No=e}this.emit("trackChange",this.#No),await this.play()}else await this.play()}async prev(){if(0!==this.#Lo.length){if(await this.stop(),this.#_o)this.#No=this._getWeightedRandomIndex();else{let e=this.#No-1;if(e<0){if("PLAYLIST"!==this.#Do)return;e=this.#Lo.length-1}this.#No=e}this.emit("trackChange",this.#No),await this.play()}}async seek(e){if("number"!=typeof e)throw new TypeError("Seek time must be a number in milliseconds.");if(e<0)throw new RangeError("Seek time cannot be negative.");const t=this.#Bo();t&&(await t.seek(e),this.emit("seek",e))}async step(e){if("number"!=typeof e)throw new TypeError("Step amount must be a number in milliseconds.");const t=this.#Bo();if(!t)return;let r=t.getCurrentTime()+e;r<0&&(r=0),await this.seek(r)}}const Wr=zr})(),window.TinyEssentials=n})();
1
+ (()=>{var e={7(e){"use strict";var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise(function(r,n){function i(r){e.removeListener(t,o),n(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}f(e,t,o,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&f(e,"error",t,{once:!0})}(e,i)})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,r,n){var i,o,s,u;if(a(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),void 0===s)s=o[t]=r,++e._eventsCount;else if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=l(e))>0&&s.length>i&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,u=c,console&&console.warn&&console.warn(u)}return e}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=c.bind(n);return i.listener=r,n.wrapFn=i,i}function d(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):p(i,i.length)}function m(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function f(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function i(o){n.once&&e.removeEventListener(t,i),r(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return l(this)},o.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var l=o[e];if(void 0===l)return!1;if("function"==typeof l)n(l,this,t);else{var u=l.length,c=p(l,u);for(r=0;r<u;++r)n(c[r],this,t)}return!0},o.prototype.addListener=function(e,t){return u(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return u(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,h(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,h(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,n,i,o,s;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},o.prototype.listeners=function(e){return d(this,e,!0)},o.prototype.rawListeners=function(e){return d(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},o.prototype.listenerCount=m,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},975(e,t,r){"use strict";var n=r(606);function i(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function o(e,t){for(var r,n="",i=0,o=-1,s=0,a=0;a<=e.length;++a){if(a<e.length)r=e.charCodeAt(a);else{if(47===r)break;r=47}if(47===r){if(o===a-1||1===s);else if(o!==a-1&&2===s){if(n.length<2||2!==i||46!==n.charCodeAt(n.length-1)||46!==n.charCodeAt(n.length-2))if(n.length>2){var l=n.lastIndexOf("/");if(l!==n.length-1){-1===l?(n="",i=0):i=(n=n.slice(0,l)).length-1-n.lastIndexOf("/"),o=a,s=0;continue}}else if(2===n.length||1===n.length){n="",i=0,o=a,s=0;continue}t&&(n.length>0?n+="/..":n="..",i=2)}else n.length>0?n+="/"+e.slice(o+1,a):n=e.slice(o+1,a),i=a-o-1;o=a,s=0}else 46===r&&-1!==s?++s:s=-1}return n}var s={resolve:function(){for(var e,t="",r=!1,s=arguments.length-1;s>=-1&&!r;s--){var a;s>=0?a=arguments[s]:(void 0===e&&(e=n.cwd()),a=e),i(a),0!==a.length&&(t=a+"/"+t,r=47===a.charCodeAt(0))}return t=o(t,!r),r?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(e){if(i(e),0===e.length)return".";var t=47===e.charCodeAt(0),r=47===e.charCodeAt(e.length-1);return 0!==(e=o(e,!t)).length||t||(e="."),e.length>0&&r&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return i(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,t=0;t<arguments.length;++t){var r=arguments[t];i(r),r.length>0&&(void 0===e?e=r:e+="/"+r)}return void 0===e?".":s.normalize(e)},relative:function(e,t){if(i(e),i(t),e===t)return"";if((e=s.resolve(e))===(t=s.resolve(t)))return"";for(var r=1;r<e.length&&47===e.charCodeAt(r);++r);for(var n=e.length,o=n-r,a=1;a<t.length&&47===t.charCodeAt(a);++a);for(var l=t.length-a,u=o<l?o:l,c=-1,h=0;h<=u;++h){if(h===u){if(l>u){if(47===t.charCodeAt(a+h))return t.slice(a+h+1);if(0===h)return t.slice(a+h)}else o>u&&(47===e.charCodeAt(r+h)?c=h:0===h&&(c=0));break}var d=e.charCodeAt(r+h);if(d!==t.charCodeAt(a+h))break;47===d&&(c=h)}var m="";for(h=r+c+1;h<=n;++h)h!==n&&47!==e.charCodeAt(h)||(0===m.length?m+="..":m+="/..");return m.length>0?m+t.slice(a+c):(a+=c,47===t.charCodeAt(a)&&++a,t.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(i(e),0===e.length)return".";for(var t=e.charCodeAt(0),r=47===t,n=-1,o=!0,s=e.length-1;s>=1;--s)if(47===(t=e.charCodeAt(s))){if(!o){n=s;break}}else o=!1;return-1===n?r?"/":".":r&&1===n?"//":e.slice(0,n)},basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');i(e);var r,n=0,o=-1,s=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,l=-1;for(r=e.length-1;r>=0;--r){var u=e.charCodeAt(r);if(47===u){if(!s){n=r+1;break}}else-1===l&&(s=!1,l=r+1),a>=0&&(u===t.charCodeAt(a)?-1===--a&&(o=r):(a=-1,o=l))}return n===o?o=l:-1===o&&(o=e.length),e.slice(n,o)}for(r=e.length-1;r>=0;--r)if(47===e.charCodeAt(r)){if(!s){n=r+1;break}}else-1===o&&(s=!1,o=r+1);return-1===o?"":e.slice(n,o)},extname:function(e){i(e);for(var t=-1,r=0,n=-1,o=!0,s=0,a=e.length-1;a>=0;--a){var l=e.charCodeAt(a);if(47!==l)-1===n&&(o=!1,n=a+1),46===l?-1===t?t=a:1!==s&&(s=1):-1!==t&&(s=-1);else if(!o){r=a+1;break}}return-1===t||-1===n||0===s||1===s&&t===n-1&&t===r+1?"":e.slice(t,n)},format:function(e){if(null===e||"object"!=typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return function(e,t){var r=t.dir||t.root,n=t.base||(t.name||"")+(t.ext||"");return r?r===t.root?r+n:r+"/"+n:n}(0,e)},parse:function(e){i(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return t;var r,n=e.charCodeAt(0),o=47===n;o?(t.root="/",r=1):r=0;for(var s=-1,a=0,l=-1,u=!0,c=e.length-1,h=0;c>=r;--c)if(47!==(n=e.charCodeAt(c)))-1===l&&(u=!1,l=c+1),46===n?-1===s?s=c:1!==h&&(h=1):-1!==s&&(h=-1);else if(!u){a=c+1;break}return-1===s||-1===l||0===h||1===h&&s===l-1&&s===a+1?-1!==l&&(t.base=t.name=0===a&&o?e.slice(1,l):e.slice(a,l)):(0===a&&o?(t.name=e.slice(1,s),t.base=e.slice(1,l)):(t.name=e.slice(a,s),t.base=e.slice(a,l)),t.ext=e.slice(s,l)),a>0?t.dir=e.slice(0,a-1):o&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};s.posix=s,e.exports=s},606(e){var t,r,n=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(e){r=o}}();var a,l=[],u=!1,c=-1;function h(){u&&a&&(u=!1,a.length?l=a.concat(l):c=-1,l.length&&d())}function d(){if(!u){var e=s(h);u=!0;for(var t=l.length;t;){for(a=l,l=[];++c<t;)a&&a[c].run();c=-1,t=l.length}a=null,u=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{return r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function p(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new m(e,t)),1!==l.length||u||s(d)},m.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=p,n.addListener=p,n.once=p,n.off=p,n.removeListener=p,n.removeAllListeners=p,n.emit=p,n.prependListener=p,n.prependOnceListener=p,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},133(){},370(){},766(){},911(){}};const t={};function r(n){const i=t[n];if(void 0!==i)return i.exports;const o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var n=0;n<t.length;){var i=t[n++],o=t[n++];r.o(e,i)?0===o&&n++:0===o?Object.defineProperty(e,i,{enumerable:!0,value:t[n++]}):Object.defineProperty(e,i,{enumerable:!0,get:o})}else for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};let n={};(()=>{"use strict";r.r(n),r.d(n,{ColorSafeStringify:()=>K,FuzzySet:()=>Hr,MamdaniInferenceSystem:()=>Pr,TinyAdvancedRaffle:()=>dr,TinyAfterScrollWatcher:()=>_t,TinyAnalogClock:()=>kr,TinyArrayComparator:()=>Lr,TinyArrayPaginator:()=>mr,TinyClassManager:()=>Or,TinyClipboard:()=>Vt,TinyColorConverter:()=>Jt,TinyColorValidator:()=>Ir,TinyCookieConsent:()=>yr,TinyDayNightCycle:()=>cr,TinyDomReadyManager:()=>bt,TinyDragDropDetector:()=>ae,TinyDragger:()=>wt,TinyElementObserver:()=>nt,TinyGamepad:()=>ur,TinyHtml:()=>gt,TinyI18:()=>vr,TinyIframeEvents:()=>nr,TinyInventory:()=>fr,TinyInventoryTrader:()=>gr,TinyLevelUp:()=>i,TinyLoadingScreen:()=>Cr,TinyLocalStorage:()=>er,TinyMediaPlayer:()=>qr,TinyNeedBar:()=>Tr,TinyNewWinEvents:()=>sr,TinyNotifications:()=>vt,TinyNotifyCenter:()=>Y,TinyPromiseQueue:()=>J,TinyRadioFm:()=>Br,TinyRateLimiter:()=>U,TinySimpleDice:()=>xr,TinySmartScroller:()=>Wt,TinyTextDiffer:()=>Mr,TinyTextRangeEditor:()=>qt,TinyTextarea:()=>ar,TinyTimeout:()=>Gt,TinyToastNotify:()=>X,UltraRandomMsgGen:()=>Ft,addAiMarkerShortcut:()=>z,areElsCollBottom:()=>Fe,areElsCollLeft:()=>Be,areElsCollPerfBottom:()=>qe,areElsCollPerfLeft:()=>Ve,areElsCollPerfRight:()=>Ke,areElsCollPerfTop:()=>We,areElsCollRight:()=>ze,areElsCollTop:()=>Oe,areElsColliding:()=>Je,areElsPerfColliding:()=>Ue,arraySortPositions:()=>a,asyncReplace:()=>O,backupFile:()=>xe,breakdownDuration:()=>d,calculateMarketcap:()=>P,checkObj:()=>T,clearDirectory:()=>me,clearDirectoryAsync:()=>De,cloneObjTypeOrder:()=>b,compareMarketcap:()=>$,countObj:()=>m,defuzzifyCentroid:()=>Dr,diffArrayList:()=>s,diffStrings:()=>q,dirExists:()=>fe,dirSize:()=>Se,dirSizeAsync:()=>$e,documentIsFullScreen:()=>S,ensureCopyFile:()=>ye,ensureDirectory:()=>de,exitFullScreen:()=>I,extendObjType:()=>y,extractMediaId3Tags:()=>Nt,fetchJson:()=>ie,fetchText:()=>oe,fileExists:()=>pe,fileSize:()=>Te,fileSizeAsync:()=>Pe,formatBytes:()=>R,formatCustomTimer:()=>u,formatDayTimer:()=>h,formatTimer:()=>c,genFibonacciSeq:()=>H,getAge:()=>j,getElsCollDetails:()=>rt,getElsCollDirDepth:()=>tt,getElsCollOverlap:()=>Xe,getElsCollOverlapPos:()=>Qe,getElsColliding:()=>Ge,getElsPerfColliding:()=>Ye,getElsRelativeCenterOffset:()=>et,getLatestBackupPath:()=>Ce,getPercentage:()=>D,getRectCenter:()=>Ze,getSimplePerc:()=>_,getTimeDuration:()=>l,installWindowHiddenScript:()=>se,isDirEmpty:()=>ge,isDirEmptyAsync:()=>je,isFullScreenMode:()=>C,isJsonObject:()=>p,isScreenFilled:()=>x,listDirs:()=>Ee,listDirsAsync:()=>He,listFiles:()=>ve,listFilesAsync:()=>Re,objType:()=>E,offFullScreenChange:()=>N,onFullScreenChange:()=>M,parseMediaMetadata:()=>Lt,readBase64Blob:()=>Z,readFileBlob:()=>Q,readJsonBlob:()=>ee,readJsonFile:()=>ce,renameFileAddPrefixSuffix:()=>Me,renameFileBatch:()=>Ie,renameFileNormalizeCase:()=>Ne,renameFilePadNumbers:()=>Le,renameFileRegex:()=>ke,reorderObjTypeOrder:()=>w,requestFullScreen:()=>A,restoreLatestBackup:()=>Ae,ruleOfThree:()=>L,safeTextTrim:()=>W,saveJsonFile:()=>te,shuffleArray:()=>o,toTitleCase:()=>F,toTitleCaseLowerFirst:()=>B,trapezoid:()=>jr,tryDeleteFile:()=>we,valMediaContentMetadata:()=>kt,valMediaContentMetadataPartial:()=>Mt,writeJsonFile:()=>he,writeTextFile:()=>be});var e={};r.r(e),r.d(e,{iu:()=>Fe,cq:()=>Be,P8:()=>qe,BO:()=>Ve,eh:()=>Ke,L2:()=>We,lP:()=>ze,Kr:()=>Oe,wE:()=>Je,D6:()=>Ue,PN:()=>rt,t_:()=>tt,aI:()=>Xe,ej:()=>Qe,kx:()=>Ge,Pd:()=>Ye,NW:()=>et,Qv:()=>Ze});var t={};r.r(t),r.d(t,{areElsCollBottom:()=>Fe,areElsCollLeft:()=>Be,areElsCollPerfBottom:()=>qe,areElsCollPerfLeft:()=>Ve,areElsCollPerfRight:()=>Ke,areElsCollPerfTop:()=>We,areElsCollRight:()=>ze,areElsCollTop:()=>Oe,areElsColliding:()=>Je,areElsPerfColliding:()=>Ue,getElsCollDetails:()=>rt,getElsCollDirDepth:()=>tt,getElsCollOverlap:()=>Xe,getElsCollOverlapPos:()=>Qe,getElsColliding:()=>Ge,getElsPerfColliding:()=>Ye,getElsRelativeCenterOffset:()=>et,getRectCenter:()=>Ze});const i=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 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,t){const r=e.filter(e=>!t.includes(e));return{added:t.filter(t=>!e.includes(t)),removed:r}}function a(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 l(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 u(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,l=n>=1,u=n>=0,c={years:i?0:NaN,months:o?0:NaN,days:s?0:NaN,hours:a?0:NaN,minutes:l?0:NaN,seconds:u?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),c.years++;if(o)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),c.months++;if(s)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),c.days++;h=Math.floor((t.getTime()-r.getTime())/1e3)}a&&(c.hours=Math.floor(h/3600),h%=3600),l&&(c.minutes=Math.floor(h/60),h%=60),u&&(c.seconds=h),o&&(c.years,c.months,c.days),i&&(c.years,c.months,c.days),c.total=+e.toFixed(2).replace(/\.00$/,"");const d=e=>{const t="string"==typeof e?parseInt(e):e;return Number.isNaN(t)?"NaN":String(t).padStart(2,"0")},m=[a?d(c.hours):null,l?d(c.minutes):null,u?d(c.seconds):null].filter(e=>null!==e).join(":");return r.replace(/\{years\}/g,String(c.years)).replace(/\{months\}/g,String(c.months)).replace(/\{days\}/g,String(c.days)).replace(/\{hours\}/g,d(c.hours)).replace(/\{minutes\}/g,d(c.minutes)).replace(/\{seconds\}/g,d(c.seconds)).replace(/\{time\}/g,m).replace(/\{total\}/g,String(c.total)).trim()}function c(e){return u(e,"hours","{hours}:{minutes}:{seconds}")}function h(e){return u(e,"days","{days}d {hours}:{minutes}:{seconds}")}function d(e,t="milliseconds"){e=Math.max(0,Math.floor(e));const r=["milliseconds","seconds","minutes","hours","days","months","years"].indexOf(t),n=r>=6,i=r>=5,o=r>=4,s=r>=3,a=r>=2,l=r>=1,u=r>=0,c={years:n?0:NaN,months:i?0:NaN,days:o?0:NaN,hours:s?0:NaN,minutes:a?0:NaN,seconds:l?0:NaN,milliseconds:u?0:NaN,total:NaN};let h=e;if(n||i||o){const e=new Date(1980,0,1),t=new Date(e.getTime()+h),r=new Date(e);if(n)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),c.years++;if(i)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),c.months++;if(o)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),c.days++;h=t.getTime()-r.getTime()}return s&&(c.hours=Math.floor(h/36e5),h%=36e5),a&&(c.minutes=Math.floor(h/6e4),h%=6e4),l&&(c.seconds=Math.floor(h/1e3),h%=1e3),u&&(c.milliseconds=h),i&&(c.years,c.months,c.days),n&&(c.years,c.months,c.days),c.total=+e,c}function m(e){return Array.isArray(e)?e.length:p(e)?Object.keys(e).length:0}function p(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}const f="undefined"!=typeof window&&void 0!==window.document,g={items:{},order:[]};function y(e,t){const r=[],n=Array.isArray(e)?e:Object.entries(e);for(const[e,i]of n)if(!g.items.hasOwnProperty(e)){g.items[e]=i;let n="number"==typeof t?t:-1;if(-1===n){const e=g.order.indexOf("object");n=e>-1?e:g.order.length}n=Math.min(Math.max(0,n),g.order.length),g.order.splice(n,0,e),r.push(e)}return r}function w(e){const t=[...g.order];return!!e.every(e=>t.includes(e))&&(g.order=e.slice(),!0)}function b(){return[...g.order]}const v=e=>{if(null===e)return"null";for(const t of g.order)if("function"!=typeof g.items[t]||g.items[t](e))return t;return"unknown"};function E(e,t){if(void 0===e)return null;const r=v(e);return"string"==typeof t?r===t.toLowerCase():r}function T(e){const t={valid:null,type:null};for(const r of g.order)if("function"==typeof g.items[r]){const n=g.items[r](e);if(n){t.valid=n,t.type=r;break}}return t}y([["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)]]),f&&y([["file",e=>"undefined"!=typeof File&&e instanceof File]]),y([["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]]),f&&y([["htmlelement",e=>"undefined"!=typeof HTMLElement&&e instanceof HTMLElement]]),y([["object",e=>p(e)]]);const S=()=>!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitIsFullScreen||document.mozFullScreen),x=()=>window.innerHeight===screen.height&&window.innerWidth===screen.width,C=()=>S()||x(),A=e=>new Promise(async(t,r)=>{const n=document.documentElement;try{n.requestFullscreen?await n.requestFullscreen(e):n.mozRequestFullScreen?n.mozRequestFullScreen(e):n.webkitRequestFullScreen?n.webkitRequestFullScreen(e):n.msRequestFullscreen&&n.msRequestFullscreen(e),t()}catch(e){r(e)}}),I=()=>new Promise((e,t)=>{if(document.exitFullscreen)document.exitFullscreen().then(e).catch(t);else try{if(document.mozCancelFullScreen)document.mozCancelFullScreen();else if(document.webkitCancelFullScreen)document.webkitCancelFullScreen();else{if(!document.msExitFullscreen)throw new Error("Fullscreen API is not supported");document.msExitFullscreen()}e()}catch(e){t(e)}}),k=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],M=(e,t)=>{k.forEach(r=>{document.addEventListener(r,e,t)})},N=(e,t)=>{k.forEach(r=>{document.removeEventListener(r,e,t)})};function L(e,t,r,n=!1){return n?Number(e*t)/r:Number(r*t)/e}function _(e,t){return e*(t/100)}function D(e,t){return 0===t?0:e/t*100}function j(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(),l=r.getDate();return(o<s||o===s&&a<l)&&i--,Math.abs(i)}return null}function R(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 H({baseValues:e=[0,1],length:t=10,combiner:r=(e,t)=>e+t}={}){if(!Array.isArray(e)||2!==e.length)throw new Error("baseValues must be an array of exactly two numbers");const n=[...e.slice(0,2)];for(let e=2;e<t;e++){const t=r(n[e-2],n[e-1],e);n.push(t)}return n}function P(e,t){if(Number.isNaN(e)||!Number.isFinite(e))throw new TypeError("Original market cap must be a number.");if(Number.isNaN(t)||!Number.isFinite(t))throw new TypeError("Circulating supply must be a number.");if(t<=0)throw new Error("Circulating supply must be greater than zero.");return e/t}function $(e,t,r){if(Number.isNaN(r)||!Number.isFinite(r))throw new TypeError("New market cap must be a number.");const n=P(e,t),i="number"==typeof r?r/t:NaN;return{originalPrice:n,newPrice:i,priceChangePercent:"number"==typeof r?(i-n)/n*100:NaN}}async function O(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())}function F(e){return e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase())}function B(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 z({key:e="a",className:t="detect-made-by-ai"}={}){if("undefined"==typeof HTMLElement)throw new Error("[AiMarkerShortcut] Environment does not support the DOM. This function must be run in a browser.");const r=function(r){if(r.ctrlKey&&r.altKey&&r.key.toLowerCase()===e){if(r.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(t)}};return document.addEventListener("keydown",r),r}function W(e,t,r=.6){if("string"!=typeof e)throw new TypeError("Expected a string for 'text', but received "+typeof e);if(!Number.isInteger(t)||t<=0)throw new TypeError(`Expected 'limit' to be a positive integer, but received ${t}`);if("number"!=typeof r||r<0||r>1)throw new TypeError(`Expected 'safeCutZone' to be a number between 0 and 1, but received ${r}`);let n=e.trim();if(n.length>t){const e=n.lastIndexOf(" ",t);return e>0&&e>=t*r?`${n.substring(0,e).trim()}...`:`${n.substring(0,t).trim()}...`}return n}function q(e,t){const r={added:{},removed:{},modified:{}};for(const n in e)n in t?e[n]!==t[n]&&(r.modified[n]={old:e[n],new:t[n]}):r.removed[n]=e[n];for(const n in t)n in e||(r.added[n]=t[n]);return r}class V{#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={...V.#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={...V.#t.default}}loadColorPreset(e){const t=V.#t[e];if(!t)throw new Error(`Preset "${e}" not found.`);this.#e={...t}}saveColorPreset(e,t){V.#t[e]={...t}}getAvailablePresets(){return Object.keys(V.#t)}}const K=V,J=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.#l();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.#l()}}}async#u(){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.#l();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.#l()}async#l(){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.#u()}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.#l()}):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.#l()})}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}},U=class{#c=null;#h=null;#d=null;#m=null;#p=null;#f=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),l=o(r),u=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&&!l)throw new Error("'cleanupInterval' must be a positive integer in milliseconds if defined.");if(!u)throw new Error("'maxIdle' must be a positive integer in milliseconds.");if("number"==typeof i&&Number.isFinite(i)&&i>0)this.#c=Math.floor(i);else{if(null!=i)throw new Error("maxMemory must be a positive number or null");this.#c=null}this.#d=s?e:null,this.#m=a?t:null,this.#p=l?r:null,this.#f=n,null!==this.#p&&(this.#h=setInterval(()=>this._cleanup(),this.#p))}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.#m){const e=r-this.getInterval();for(;n.length&&n[0]<e;)n.shift()}null!==this.#c&&"number"==typeof this.#c&&n.length>this.#c&&(n.splice(0,n.length-this.#c),"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.#m){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.#d?t>this.getMaxHits():t>0}return null!==this.#d&&r.length>this.getMaxHits()}resetGroup(e){this.groupFlags.delete(e),this.groupData.delete(e),this.lastSeen.delete(e),this.groupTTL.delete(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.#f||!Number.isFinite(this.#f)||this.#f<0)throw new Error("'maxIdle' must be a non-negative finite number.");return this.#f}setMaxIdle(e){if("number"!=typeof e||!Number.isFinite(e)||e<0)throw new Error("'maxIdle' must be a non-negative finite number.");this.#f=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.#m||!Number.isFinite(this.#m))throw new Error("'interval' is not a valid finite number.");return this.#m}getMaxHits(){if("number"!=typeof this.#d||!Number.isFinite(this.#d))throw new Error("'maxHits' is not a valid finite number.");return this.#d}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 G{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,G.getTemplate())}#w;#b;#v;#E;#T;#S=0;#x=99;#C=300;#A=!1;#I=new WeakMap;#k(e){if(this.#I.delete(e),!(e instanceof HTMLElement))throw new Error("Invalid HTMLElement to clear.");e.classList.add("removing"),setTimeout(()=>{this.markAsRead(e),e.remove()},this.#C)}#M(e){this.#S=Math.max(0,e),this.#v.setAttribute("data-value",String(this.#S)),this.#v.textContent=this.#S>this.#x?`${this.#x}+`:String(this.#S)}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.#w=t,this.#b=s,this.#v=r,this.#E=n,this.#T=i,this.#E.addEventListener("click",()=>this.toggle()),this.#w.querySelector(".close")?.addEventListener("click",()=>this.close()),o&&o.addEventListener("click",()=>this.clear()),this.#T.addEventListener("click",e=>{e.target===this.#T&&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.#C=e}getItemMode(e){const t=this.getItem(e);return t?this.#I.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.#M(this.#S-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 l=document.createElement("div");l.className="message","html"===t?l.innerHTML=i:l.textContent=i,a.appendChild(l),"function"==typeof s&&(r.classList.add("clickable"),r.addEventListener("click",e=>{e.target instanceof HTMLElement&&!e.target.closest(".notify-close")&&s(e)}));const u=document.createElement("button");u.className="notify-close",u.setAttribute("type","button"),u.innerHTML="&times;",u.addEventListener("click",e=>{e.stopPropagation(),this.#k(r)}),r.append(a,u),this.#b.prepend(r),this.#I.set(r,t),this.#M(this.#S+1)}remove(e){const t=this.getItem(e);this.#k(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.#k(r),e=!0)}}open(){this.#T.classList.remove("hidden"),this.#w.classList.add("open")}close(){if(this.#T.classList.add("hidden"),this.#w.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.#w.classList.contains("open")?this.close():this.open()}recount(){const e=this.#b.querySelectorAll(".item.unread").length;this.#M(e)}get count(){return this.#S}destroy(){this.#E?.removeEventListener("click",this.toggle),this.#w?.querySelector(".close")?.removeEventListener("click",this.close),this.#w?.querySelector(".clear-all")?.removeEventListener("click",this.clear),this.#T?.removeEventListener("click",this.close),this.clear(),this.#w?.remove(),this.#T?.remove(),this.#E?.remove(),this.#S=0,this.#I=new WeakMap}}const Y=G,X=class{#N;#L;#_;#D;#j;#R;constructor(e="top",t="right",r=3e3,n=50,i=300,o=".notify-container"){this.#H(e),this.#P(t),this.#$(r,"baseDuration"),this.#$(n,"extraPerChar"),this.#$(i,"fadeOutDuration"),this.#N=e,this.#L=t,this.#_=r,this.#D=n,this.#j=i;const s=document.querySelector(`${o}.${e}.${t}`);s instanceof HTMLElement?this.#R=s:(this.#R=document.createElement("div"),this.#R.className=`notify-container ${e} ${t}`,document.body.appendChild(this.#R))}getContainer(){if(!(this.#R instanceof HTMLElement))throw new Error("Container is not a valid HTMLElement.");return this.#R}#H(e){if(!["top","bottom"].includes(e))throw new Error(`Invalid vertical direction "${e}". Expected "top" or "bottom".`)}#P(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.#N}setY(e){this.#H(e);const t=this.getContainer();t.classList.remove(this.#N),t.classList.add(e),this.#N=e}getX(){return this.#L}setX(e){this.#P(e);const t=this.getContainer();t.classList.remove(this.#L),t.classList.add(e),this.#L=e}getBaseDuration(){return this.#_}setBaseDuration(e){this.#$(e,"baseDuration"),this.#_=e}getExtraPerChar(){return this.#D}setExtraPerChar(e){this.#$(e,"extraPerChar"),this.#D=e}getFadeOutDuration(){return this.#j}setFadeOutDuration(e){this.#$(e,"fadeOutDuration"),this.#j=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(--notify-close-color-hover)"}),a.addEventListener("mouseleave",()=>{a.style.color="var(--notify-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 l=this.#_+t.length*this.#D+this.#j;let u=!1;const c=()=>{u||(u=!0,s.classList.remove("enter","show"),s.classList.add("exit"),setTimeout(()=>s.remove(),this.#j))};"function"==typeof n&&s.addEventListener("click",e=>{e.target!==a&&n(e,c)}),a.addEventListener("click",e=>{e.stopPropagation(),c()}),setTimeout(()=>{s.classList.remove("enter"),s.classList.add("show")},1),setTimeout(()=>c(),l)}destroy(){this.#R instanceof HTMLElement&&(this.#R.querySelectorAll(".notify").forEach(e=>e.remove()),this.#R.parentNode&&this.#R.parentNode.removeChild(this.#R),this.#R=null)}};function Q(e,t){return new Promise((r,n)=>{const i=new FileReader;i.onload=()=>{try{r(i.result)}catch(e){n(e)}},i.onerror=()=>{n(i.error)},i[t](e)})}function Z(e,t=!1){return new Promise((r,n)=>{"string"!=typeof t&&"boolean"!=typeof t&&n(new TypeError("The isDataUrl parameter must be a boolean or a string.")),Q(e,"readAsDataURL").then(e=>{if("string"!=typeof e)throw new TypeError("Expected file content to be a string.");const n=e.match(/^data:(.+);base64,(.*)$/);if(!n||!n[2])throw new Error("Invalid data URL format or missing Base64 content.");const[,i,o]=n;if(!/^[\w/+]+=*$/.test(o))throw new Error("Base64 content is malformed.");if("boolean"==typeof t)return r(t?e:o);if(!/^[\w-]+\/[\w.+-]+$/.test(t))throw new Error(`Invalid MIME type string: ${t}`);return r(`data:${t};base64,${o}`)}).catch(n)})}function ee(e){return new Promise((t,r)=>Q(e,"readAsText").then(e=>{if("string"!=typeof e)throw new TypeError("Expected file content to be a string.");const r=e.trim();if(0===r.length)throw new Error("File is empty or contains only whitespace.");const n=JSON.parse(r);if("object"!=typeof n||null===n)throw new Error("Parsed content is not a valid JSON object or array.");t(n)}).catch(r))}function te(e,t,r=2){const n=JSON.stringify(t,null,r),i=new Blob([n],{type:"application/json"}),o=URL.createObjectURL(i),s=document.createElement("a");s.href=o,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(o)}function re(e,t){if("function"!=typeof t)throw new TypeError('The "onProgress" argument must be a function.');if(!e.body)return e;const r=e.headers.get("content-length"),n=r?parseInt(r,10):0;let i=0;const o=e.body.getReader(),s=new ReadableStream({async start(e){for(;;){const{done:r,value:s}=await o.read();if(r)break;i+=s.byteLength,t(i,n),e.enqueue(s)}e.close()}});return new Response(s,{headers:e.headers,status:e.status,statusText:e.statusText})}async function ne(e,{method:t="GET",body:r,timeout:n=0,retries:i=0,headers:o={},signal:s=null,onProgress:a}={}){if("string"!=typeof e||!e.startsWith("../")&&!e.startsWith("./")&&!e.startsWith("/")&&!e.startsWith("https://")&&!e.startsWith("http://"))throw new Error("Invalid URL: must be a valid http or https address.");if("string"!=typeof t||!t.trim())throw new Error("Invalid method: must be a non-empty string.");if(!s){if("number"!=typeof n||!Number.isFinite(n)||Number.isNaN(n)||n<0)throw new Error("Invalid timeout: must be a positive number.");if("number"!=typeof i||!Number.isFinite(i)||Number.isNaN(i)||i<0)throw new Error("Invalid retries: must be a positive number.")}const l=s?1:i+1;let u=null;for(let c=0;c<l;c++){const l=s?null:new AbortController,h=s||(l?.signal??null),d=!s&&n&&l?setTimeout(()=>l.abort(),n):null;try{const n=await fetch(e,{method:t.toUpperCase(),headers:{Accept:"application/json",...o},body:void 0!==r?p(r)?JSON.stringify(r):r:void 0,signal:h});if(d&&clearTimeout(d),!n.ok)throw new Error(`HTTP error: ${n.status} ${n.statusText}`);return a?re(n,a):n}catch(e){if(u=e,s)break;c<i&&await new Promise(e=>setTimeout(e,300*(c+1)))}}throw new Error(`Failed to fetch JSON from "${e}"${u?`: ${u.message}`:"."}`)}async function ie(e,t){return new Promise((r,n)=>{ne(e,t).then(async e=>{const t=e.headers.get("content-type")||"";if(!t.includes("application/json"))throw new Error(`Unexpected content-type: ${t}`);const n=await e.json();if(!Array.isArray(n)&&!p(n))throw new Error("Received invalid data instead of valid JSON.");return r(n)}).catch(n)})}async function oe(e,t,r){return new Promise((n,i)=>{ne(e,r).then(async e=>{const r=e.headers.get("content-type")||"";if(Array.isArray(t)&&t.length>0&&!t.some(e=>r.includes(e)))throw new Error(`Blocked MIME type: ${r}`);const i=await e.text();return n(i)}).catch(i)})}function se({element:e=document.body,hiddenClass:t="windowHidden",visibleClass:r="windowVisible",onVisible:n,onHidden:i}={}){if(!(e instanceof Element))throw new TypeError('"element" must be an instance of Element.');if("string"!=typeof t)throw new TypeError('"hiddenClass" must be a string.');if("string"!=typeof r)throw new TypeError('"visibleClass" must be a string.');if(void 0!==n&&"function"!=typeof n)throw new TypeError('"onVisible" must be a function if provided.');if(void 0!==i&&"function"!=typeof i)throw new TypeError('"onHidden" must be a function if provided.');let o="",s="";const a=()=>{e.classList.remove(t),e.classList.remove(r)};let l=null;const u=["visibilitychange","mozvisibilitychange","webkitvisibilitychange","msvisibilitychange"],c=["hidden","mozHidden","webkitHidden","msHidden"];for(let e=0;e<c.length;e++)if(c[e]in document){l=c[e];break}const h=function(u){a();const c=u?.type,h=l&&document[l];["focus","focusin","pageshow"].includes(c)?(e.classList.add(r),n?.({type:c,oldClass:s,oldType:o}),s=r):["blur","focusout","pagehide"].includes(c)||h?(e.classList.add(t),i?.({type:c,oldClass:s,oldType:o}),s=t):(e.classList.add(r),n?.({type:c,oldClass:s,oldType:o}),s=r),o=c};let d=()=>{};if(l){const e=u[c.indexOf(l)];document.addEventListener(e,h),window.addEventListener("focus",h),window.addEventListener("blur",h),d=()=>{document.removeEventListener(e,h),window.removeEventListener("focus",h),window.removeEventListener("blur",h),a()}}else"onfocusin"in document?(document.onfocusin=document.onfocusout=h,d=()=>{document.onfocusin=document.onfocusout=null,a()}):(window.onpageshow=window.onpagehide=window.onfocus=window.onblur=h,d=()=>{window.onpageshow=window.onpagehide=window.onfocus=window.onblur=null,a()});const m=new Event(l&&document[l]?"blur":"focus");return h(m),d}const ae=class{#O;#F;#B;#z;#W;#q;#V;constructor(e,t){const{hoverClass:r="dnd-hover",onDrop:n,onEnter:i,onLeave:o}=t;if(!(e instanceof HTMLElement))throw new TypeError('The "target" option must be an instance of HTMLElement.');if("string"!=typeof r)throw new TypeError('The "hoverClass" option must be a string.');if("function"!=typeof n)throw new TypeError('The "onDrop" option must be a function.');if("function"!=typeof i)throw new TypeError('The "onEnter" option must be a function.');if("function"!=typeof o)throw new TypeError('The "onLeave" option must be a function.');this.#O=e,this.#F=r,this.#B=n||(()=>{}),this.#z=i,this.#W=o,this.#q=!1,this.#V=!1,this._handleDragEnter=this._handleDragEnter.bind(this),this._handleDragOver=this._handleDragOver.bind(this),this._handleDragLeave=this._handleDragLeave.bind(this),this._handleDrop=this._handleDrop.bind(this),this.#K()}getTarget(){return this.#O}getHoverClass(){return this.#F}isDragging(){return this.#q}bound(){return this.#V}#K(){if(this.#V)return;const e=this.getTarget();e.addEventListener("dragenter",this._handleDragEnter),e.addEventListener("dragover",this._handleDragOver),e.addEventListener("dragleave",this._handleDragLeave),e.addEventListener("drop",this._handleDrop),this.#V=!0}#J(){if(!this.#V)return;const e=this.getTarget();e.removeEventListener("dragenter",this._handleDragEnter),e.removeEventListener("dragover",this._handleDragOver),e.removeEventListener("dragleave",this._handleDragLeave),e.removeEventListener("drop",this._handleDrop),this.#V=!1}_handleDragEnter(e){if(e.preventDefault(),!this.#q){const t=this.getTarget();this.#q=!0,t.classList.add(this.#F),this.#z(e)}}_handleDragOver(e){e.preventDefault(),e.dataTransfer?e.dataTransfer.dropEffect="copy":console.warn("[TinyDragDropDetector] [handleDragOver] DragOver event missing dataTransfer.")}_handleDragLeave(e){e.preventDefault();const t=this.getTarget();null!==e.relatedTarget&&t.contains(e.relatedTarget)||(this.#q=!1,t.classList.remove(this.#F),this.#W(e))}_handleDrop(e){if(e.preventDefault(),!e.dataTransfer)return void console.warn("[TinyDragDropDetector] [handleDrop] DragOver event missing dataTransfer.");const t=this.getTarget();this.#q=!1,t.classList.remove(this.#F);const r=e.dataTransfer.files;r.length>0&&this.#B(r,e)}destroy(){this.#J(),this.getTarget().classList.remove(this.#F)}};var le=r(133),ue=r(975);function ce(e){if(!(0,le.existsSync)(e))throw new Error(`File not found: ${e}`);const t=(0,le.readFileSync)(e,"utf-8");return JSON.parse(t)}function he(e,t,r=2){const n=JSON.stringify(t,null,r);(0,le.writeFileSync)(e,n,"utf-8")}function de(e){(0,le.existsSync)(e)||(0,le.mkdirSync)(e,{recursive:!0})}function me(e){if(!(0,le.existsSync)(e))return;const t=(0,le.readdirSync)(e);for(const r of t){const t=(0,ue.join)(e,r);(0,le.lstatSync)(t).isDirectory()?(0,le.rmSync)(t,{recursive:!0,force:!0}):(0,le.unlinkSync)(t)}}function pe(e){return(0,le.existsSync)(e)&&(0,le.lstatSync)(e).isFile()}function fe(e){return(0,le.existsSync)(e)&&(0,le.lstatSync)(e).isDirectory()}function ge(e){return 0===(0,le.readdirSync)(e).length}function ye(e,t,r){de((0,ue.dirname)(t)),(0,le.copyFileSync)(e,t,r)}function we(e){return!!pe(e)&&((0,le.unlinkSync)(e),!0)}function be(e,t,r="utf-8"){de((0,ue.dirname)(e)),(0,le.writeFileSync)(e,t,r)}function ve(e,t=!1){const r={files:[],dirs:[]};if(!fe(e))return r;const n=(0,le.readdirSync)(e);for(const i of n){const n=(0,ue.join)(e,i);if((0,le.lstatSync)(n).isDirectory()){if(r.dirs.push(n),t){const e=ve(n,!0);r.files.push(...e.files),r.dirs.push(...e.dirs)}}else r.files.push(n)}return r}function Ee(e,t=!1){const r=[];if(!fe(e))return r;const n=(0,le.readdirSync)(e);for(const i of n){const n=(0,ue.join)(e,i);(0,le.lstatSync)(n).isDirectory()&&(r.push(n),t&&r.push(...Ee(n,!0)))}return r}function Te(e){return pe(e)?(0,le.statSync)(e).size:0}function Se(e){let t=0;const r=ve(e,!0).files;for(const e of r)t+=Te(e);return t}function xe(e,t="bak"){pe(e)&&ye(e,`${e}.${t}.${(new Date).toISOString().replace(/[:.]/g,"-")}`)}function Ce(e,t="bak"){const r=(0,ue.dirname)(e),n=(0,ue.basename)(e),i=(0,le.readdirSync)(r).filter(e=>e.startsWith(`${n}.${t}.`)).sort().reverse();if(0===i.length)throw new Error(`No backups found for ${e}`);return(0,ue.join)(r,i[0])}function Ae(e,t="bak"){ye(Ce(e,t),e)}function Ie(e,t,r=[]){if("string"!=typeof e)throw new TypeError("dirPath must be a string");if("function"!=typeof t)throw new TypeError("renameFn must be a function");if(!Array.isArray(r))throw new TypeError("extensions must be an array of strings");if(!(0,le.existsSync)(e)||!(0,le.statSync)(e).isDirectory())throw new Error(`Directory not found or invalid: ${e}`);for(const e of r)if("string"!=typeof e||!e.startsWith("."))throw new TypeError(`Invalid extension: ${e}`);const n=ve(e).files;let i=0;for(const o of n){const n=(0,ue.extname)(o);if(r.length&&!r.includes(n))continue;const s=(0,ue.basename)(o),a=t(s,i++),l=(0,ue.join)(e,a);s!==a&&(0,le.renameSync)(o,l)}}function ke(e,t,r,n=[]){Ie(e,e=>{const n=(0,ue.extname)(e);return`${(0,ue.basename)(e,n).replace(t,r)}${n}`},n)}function Me(e,{prefix:t="",suffix:r=""},n=[]){Ie(e,e=>{const n=(0,ue.extname)(e),i=(0,ue.basename)(e,n);return`${t}${i}${r}${n}`},n)}function Ne(e,t="lower",r=[],n=!1){if("string"!=typeof t||!["lower","upper","title"].includes(t))throw new Error(`Invalid mode "${t}". Must be 'lower', 'upper' or 'title'.`);Ie(e,e=>{const r=e=>"lower"===t?e.toLowerCase():"upper"===t?e.toUpperCase():"title"===t?F(e):e,i=(0,ue.extname)(e),o=n?r(i):i;return`${r((0,ue.basename)(e,i))}${o}`},r)}function Le(e,t=3,r=[]){Ie(e,e=>e.replace(/\d+/,e=>e.padStart(t,"0")),r)}var _e=r(370);async function De(e){if(!(0,le.existsSync)(e))return;const t=await(0,_e.readdir)(e),r={},n=[];for(const i of t){const t=(0,ue.join)(e,i),o=(0,_e.lstat)(t);o.then(e=>(r[t]=e,e)),n.push(o)}await Promise.all(n);const i=[];for(const e in r)r[e].isDirectory()?i.push((0,_e.rm)(e,{recursive:!0,force:!0})):i.push((0,_e.unlink)(e));await Promise.all(i)}async function je(e){return 0===(await(0,_e.readdir)(e)).length}async function Re(e,t=!1){const r={files:[],dirs:[]};if(!fe(e))return r;const n=await(0,_e.readdir)(e);for(const i of n){const n=(0,ue.join)(e,i);if((await(0,_e.lstat)(n)).isDirectory()){if(r.dirs.push(n),t){const e=await Re(n,!0);r.files.push(...e.files),r.dirs.push(...e.dirs)}}else r.files.push(n)}return r}async function He(e,t=!1){const r=[];if(!fe(e))return r;const n=await(0,_e.readdir)(e);for(const i of n){const n=(0,ue.join)(e,i);(await(0,_e.lstat)(n)).isDirectory()&&(r.push(n),t&&r.push(...await He(n,!0)))}return r}async function Pe(e){return pe(e)?(await(0,_e.stat)(e)).size:0}async function $e(e){let t=0;const{files:r}=await Re(e,!0),n=[];for(const e of r){const r=Pe(e);r.then(e=>(t+=e,e)),n.push(r)}return await Promise.all(n),t}const Oe=(e,t)=>e.bottom<t.top,Fe=(e,t)=>e.top>t.bottom,Be=(e,t)=>e.right<t.left,ze=(e,t)=>e.left>t.right,We=(e,t)=>e.bottom<=t.top,qe=(e,t)=>e.top>=t.bottom,Ve=(e,t)=>e.right<=t.left,Ke=(e,t)=>e.left>=t.right,Je=(e,t)=>!(Be(e,t)||ze(e,t)||Oe(e,t)||Fe(e,t)),Ue=(e,t)=>!(Ve(e,t)||Ke(e,t)||We(e,t)||qe(e,t)),Ge=(e,t)=>Be(e,t)?"left":ze(e,t)?"right":Oe(e,t)?"top":Fe(e,t)?"bottom":null,Ye=(e,t)=>Ve(e,t)?"left":Ke(e,t)?"right":We(e,t)?"top":qe(e,t)?"bottom":null,Xe=(e,t)=>({overlapLeft:t.right-e.left,overlapRight:e.right-t.left,overlapTop:t.bottom-e.top,overlapBottom:e.bottom-t.top}),Qe=({overlapLeft:e=-1,overlapRight:t=-1,overlapTop:r=-1,overlapBottom:n=-1}={})=>({dirX:e<t?"right":"left",dirY:r<n?"bottom":"top"}),Ze=e=>({x:e.left+e.width/2,y:e.top+e.height/2});function et(e,t){const r=e.left+e.width/2,n=e.top+e.height/2;return{x:t.left+t.width/2-r,y:t.top+t.height/2-n}}function tt(e,t){if(!Ue(e,t))return{inDir:null,dirX:null,dirY:null,depthX:0,depthY:0};const{overlapLeft:r,overlapRight:n,overlapTop:i,overlapBottom:o}=Xe(e,t),{dirX:s,dirY:a}=Qe({overlapLeft:r,overlapRight:n,overlapTop:i,overlapBottom:o}),l=Math.min(r,n),u=Math.min(i,o);let c;return c=l<u?s:a,{inDir:c,dirX:s,dirY:a,depthX:l,depthY:u}}function rt(e,t){const r=Ue(e,t),n={in:null,x:null,y:null},i={y:null,x:null},o={top:0,bottom:0,left:0,right:0},{overlapLeft:s,overlapRight:a,overlapTop:l,overlapBottom:u}=Xe(t,e);o.top=l,o.bottom=u,o.left=s,o.right=a;const c=Object.entries(o).filter(([,e])=>e>0).sort((e,t)=>e[1]-t[1]),{dirX:h,dirY:d}=Qe({overlapLeft:a,overlapRight:s,overlapTop:u,overlapBottom:l});return n.y=d,n.x=h,o.bottom<0?i.y="bottom":o.top<0&&(i.y="top"),o.left<0?i.x="left":o.right<0&&(i.x="right"),n.in=r?o.top===o.bottom&&o.bottom===o.left&&o.left===o.right?"center":c.length?c[0][0]:"top":null,{dirs:n,depth:o,isNeg:i}}const nt=class{#U;get el(){return this.#U}#G={};get settings(){return this.#G}set settings(e){if("object"!=typeof e||null===e)throw new TypeError("settings must be a non-null object.");this.#G=e}#Y=null;get observer(){return this.#Y}#X=[];get detectors(){return this.#X.map(e=>[e[0],e[1]])}set detectors(e){if(!Array.isArray(e))throw new TypeError("detectors must be an array.");const t=[];for(const[r,n]of e){if("string"!=typeof r)throw new TypeError("Detector name must be a string.");if("function"!=typeof n)throw new TypeError(`Detector handler for "${r}" must be a function.`);t.push([r,n])}this.#X=t}get isActive(){return!!this.#Y}get size(){return this.#X.length}constructor(e,{initDetectors:t=[],initCfg:r={}}={}){this.#U=e,t.length&&(this.detectors=t),r&&(this.settings=r)}clear(){this.#X=[]}start(){if(!this.#U)throw new Error("Cannot start observation: no target element has been set.");this.#Y||(this.#Y=new MutationObserver(e=>{e.forEach((e,t,r)=>this.#X.forEach(n=>n[1](e,t,r)))}),this.#Y.observe(this.#U,this.#G))}stop(){this.#Y&&(this.#Y.disconnect(),this.#Y=null)}add(e,t){this.#Q(e,t),this.#X.push([e,t])}insertAtStart(e,t){this.#Q(e,t),this.#X.unshift([e,t])}insertAt(e,t,r,n="after"){if(this.#Q(t,r),"number"!=typeof e||e<0||e>=this.#X.length)throw new RangeError("Invalid index for insertDetectorAt.");const i="before"===n?e:e+1;this.#X.splice(i,0,[t,r])}removeAt(e){if("number"!=typeof e||e<0||e>=this.#X.length)throw new RangeError("Invalid index for removeDetectorAt.");this.#X.splice(e,1)}removeAround(e,t=0,r=0){if("number"!=typeof e||e<0||e>=this.#X.length)throw new RangeError("Invalid index for removeDetectorsAround.");const n=Math.max(0,e-t),i=t+1+r;this.#X.splice(n,i)}isIndexUsed(e){return e>=0&&e<this.#X.length}hasHandler(e){if("function"!=typeof e)throw new TypeError("Handler must be a function.");return this.#X.some(([t,r])=>r===e)}#Q(e,t){if("string"!=typeof e||!e.trim())throw new TypeError("Detector name must be a non-empty string.");if("function"!=typeof t)throw new TypeError(`Detector handler for "${e}" must be a function.`)}destroy(){this.stop(),this.clear()}},{wE:it,D6:ot,Kr:st,iu:at,cq:lt,lP:ut}=e,ct=new WeakMap,ht=new WeakMap,dt=new WeakMap,mt=new WeakMap,pt={top:new WeakMap,bottom:new WeakMap,left:new WeakMap,right:new WeakMap};class ft{static Utils={...t};static#Z=1;static get version(){return this.#Z}static#ee=!1;static get elemDebug(){return ft.#ee}static set elemDebug(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean value for elemDebug");ft.#ee=e}static _debugElemError(e,t){if(!ft.#ee)return;const r="[TinyHtml Debug] Element validation error";if(console.groupCollapsed(`${r}${t?" — details below":""}`),console.error(r),"undefined"!=typeof Error&&"function"==typeof Error.captureStackTrace){const e=new Error(r);Error.captureStackTrace(e,ft._debugElemError),console.error(e.stack)}else console.trace(r);if(Array.isArray(e)){const t=e.map((e,t)=>({index:t,typeOf:null===e?"null":typeof e,constructor:e?.constructor?.name??(null===e?"null":"primitive"),summary:"undefined"!=typeof Element&&e instanceof Element?`${e.tagName?.toLowerCase?.()??"element"}#${e.id||""}.${String(e.className||"").trim().replace(/\s+/g,".")}`:e&&"object"==typeof e&&"nodeType"in e?`nodeType:${e.nodeType}`:"",value:e}));console.table(t)}else console.warn('[TinyHtml Debug] "elems" is not an array:',e);arguments.length>1&&(console.error("[TinyHtml Debug] Problematic element:",t),t&&"object"==typeof t&&console.dir(t)),console.groupEnd()}static parseStyle(e){const t={};return e.split(";").forEach(e=>{const[r,n]=e.split(":").map(e=>e&&e.trim());r&&n&&(t[r]=n)}),t}static#te="undefined"!=typeof window&&void 0!==window.document?new nt(window.document.documentElement,{initDetectors:[["tinyStyleEvent",e=>{if("attributes"!==e.type||"style"!==e.attributeName||!(e.target instanceof HTMLElement))return;const t=e.oldValue||"",r=e.target.getAttribute("style")||"",n=q(ft.parseStyle(t),ft.parseStyle(r));(Object.keys(n.added).length||Object.keys(n.removed).length||Object.keys(n.modified).length)&&e.target.dispatchEvent(new CustomEvent("tinyhtml.stylechanged",{detail:n}))}],["tinyClassEvent",e=>{if("attributes"!==e.type||"class"!==e.attributeName||!(e.target instanceof HTMLElement))return;const t=e.oldValue||"",r=e.target.className||"",n=s(t.split(/\s+/).filter(Boolean),r.split(/\s+/).filter(Boolean));(n.added.length||n.removed.length)&&e.target.dispatchEvent(new CustomEvent("tinyhtml.classchanged",{detail:n}))}]],initCfg:{attributeOldValue:!0,attributes:!0,subtree:!0,attributeFilter:["style","class"]}}):void 0;static get tinyObserver(){return ft.#te}static async fetchHtmlFile(e,t={method:"GET"}){const r=await fetch(e,t),n=r.headers.get("Content-Type")||"";if(!r.ok)throw new Error(`Failed to fetch: ${r.status} ${r.statusText}`);if(!n.includes("text/html"))throw new Error(`Invalid content type: ${n} (expected text/html)`);const i=await r.text();return ft.htmlToJson(i)}static async fetchHtmlNodes(e,t){const r=await ft.fetchHtmlFile(e,t);return ft.jsonToNodes(r)}static async fetchHtmlTinyElems(e,t){const r=await ft.fetchHtmlNodes(e,t);return ft.toTinyElm(r)}static templateToJson(e){return ft.htmlToJson([...e.content.childNodes].map(e=>e instanceof Element?e.getHTML():e instanceof Text?e.textContent:"").join(""))}static templateToNodes(e){const t=[];return[...e.content.cloneNode(!0).childNodes].map(e=>{if(!(e instanceof Element||e instanceof Text||e instanceof Comment))throw new Error(`Expected only Element nodes in <template>, but found: ${e.constructor.name}`);e instanceof Comment||t.push(e)}),t}static templateToTinyElems(e){return ft.toTinyElm(ft.templateToNodes(e))}static htmlToJson(e){const t=document.createElement("div");t.innerHTML=e.trim();const r=[],n=e=>{if(e instanceof Comment)return null;if(e instanceof Text){const t=e.textContent?.trim();return t||null}if(!(e instanceof Element))return null;const t=e.tagName.toLowerCase(),r={};for(const t of e.attributes)r[ft.getPropName(t.name)]=t.value;const i=Array.from(e.childNodes).map(n).filter(Boolean);return i.length>0?[t,r,...i]:[t,r]};for(const e of t.childNodes){const t=n(e);t&&r.push(t)}return t.innerHTML="",r}static jsonToNodes(e){const t=e=>{if("string"==typeof e)return document.createTextNode(e);if(!Array.isArray(e))return document.createTextNode("");const[r,n,...i]=e,o=document.createElement(r);for(const[e,t]of Object.entries(n))o.setAttribute(ft.getAttrName(e),t);for(const e of i){const r=t(e);r instanceof Comment||o.appendChild(r)}return o};return e.map(t).filter(e=>!(e instanceof Comment))}static jsonToTinyElems(e){return ft.toTinyElm(ft.jsonToNodes(e))}static createFrom(e,t){if("string"!=typeof e)throw new TypeError('The "tagName" must be a string.');if(void 0!==t&&"object"!=typeof t)throw new TypeError('The "attrs" must be a object.');const r=ft.createElement(e);if("object"==typeof t)for(const e in t)r.setAttr(e,t[e]);return r}static createElement(e,t){if("string"!=typeof e)throw new TypeError("[TinyHtml] createElement(): The tagName must be a string.");if(void 0!==t&&"object"!=typeof t)throw new TypeError("[TinyHtml] createElement(): The ops must be a object.");return new ft(document.createElement(e,t))}static createTextNode(e){if("string"!=typeof e)throw new TypeError("[TinyHtml] createTextNode(): The value must be a string.");return new ft(document.createTextNode(e))}static createElementFromHTML(e){const t=document.createElement("template");if(!(e=e.trim()).startsWith("<"))return ft.createTextNode(e);if(t.innerHTML=e,!(t.content.firstChild instanceof Element))throw new Error("The HTML string must contain a valid HTML element.");return new ft(t.content.firstChild)}static createFromHTML(e){const t=document.createElement("template");e=e.trim(),t.innerHTML=e;const r=Array.from(t.content.childNodes);if(!r.every(e=>e instanceof Element||e instanceof Text))throw new Error("The HTML string must contain a valid HTML element.");return new ft(r)}static createFromHtml(e){return ft.createFromHTML(e)}static query(e,t=document){const r=t.querySelector(e);return r?new ft(r):null}querySelector(e){return ft.query(e,ft._preElem(this,"query"))}static queryAll(e,t=document){return new ft(t.querySelectorAll(e))}querySelectorAll(e){return ft.queryAll(e,ft._preElem(this,"queryAll"))}static getById(e){const t=document.getElementById(e);return t?new ft(t):null}static getByClassName(e,t=document){return new ft(t.getElementsByClassName(e))}getElementsByClassName(e){return ft.getByClassName(e,ft._preElem(this,"getByClassName"))}static getByName(e){return new ft(document.getElementsByName(e))}static getByTagNameNS(e,t="http://www.w3.org/1999/xhtml",r=document){return new ft(r.getElementsByTagNameNS(t,e))}getElementsByTagNameNS(e,t="http://www.w3.org/1999/xhtml"){return ft.getByTagNameNS(e,t,ft._preElem(this,"getByTagNameNS"))}get elements(){return[...this.#U]}forEach(e){const t=this.elements.map((e,t)=>this.extract(t));for(const r in t)e(t[r],Number(r),t);return this}get(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");if(!this.#U[e])throw new Error(`No element found at index ${e}.`);return this.#U[e]}extract(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");if(!this.#U[e])throw new Error(`Cannot extract: no element exists at index ${e}.`);return new ft(this.#U[e])}exists(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");return!!this.#U[e]}getAll(){return[...this.#U]}_getElement(e,t){if(!(this.#U[t]instanceof Element||this.#U[t]instanceof Window||this.#U[t]instanceof Document||this.#U[t]instanceof Text))throw ft._debugElemError([...this.#U],this.#U[t]),new Error(`[TinyHtml] Invalid Element in ${e}().`);return this.#U[t]}_getElements(e){if(!this.#U.every(e=>e instanceof Element||e instanceof Window||e instanceof Document||e instanceof Text))throw ft._debugElemError([...this.#U]),new Error(`[TinyHtml] Invalid Element in ${e}().`);return[...this.#U]}static _preElemsTemplate(e,t,r,n){const i=e=>{const i=[];return e.map(o=>(o instanceof ft?o._getElements(t):[o]).map(o=>{let s=!1;for(const e of r)if(o instanceof e){s=!0;break}if(!s)throw ft._debugElemError([...e],o),new Error(`[TinyHtml] Invalid element of the list "${n.join(",")}" in ${t}().`);return i.push(o),o})),i};return Array.isArray(e)?i(e):i([e])}_preElemsTemplate(e,t,r){return ft._preElemsTemplate(this,e,t,r)}static _preElemTemplate(e,t,r,n,i=!1){const o=e=>{const o=e[0],s=o instanceof ft?o._getElements(t):[o];if(s.length>1)throw ft._debugElemError([...e]),new Error(`[TinyHtml] Invalid element amount in ${t}() (Received ${s.length}/1).`);let a=!1;for(const e of r)if(s[0]instanceof e){a=!0;break}if(!i||null!==s[0]&&void 0!==s[0]||(s[0]=null,a=!0),!a)throw ft._debugElemError([...e],s[0]),new Error(`[TinyHtml] Invalid element of the list "${n.join(",")}" in ${t}().`);return s[0]};if(!Array.isArray(e))return o([e]);if(e.length>1)throw ft._debugElemError([...e]),new Error(`[TinyHtml] Invalid element amount in ${t}() (Received ${e.length}/1).`);return o(e)}_preElemTemplate(e,t,r,n=!1){return ft._preElemTemplate(this,e,t,r,n)}static _preElems(e,t){return ft._preElemsTemplate(e,t,[Element],["Element"])}_preElems(e){return ft._preElems(this,e)}static _preElem(e,t){return ft._preElemTemplate(e,t,[Element],["Element"])}_preElem(e){return ft._preElem(this,e)}static _preNodeElems(e,t){return ft._preElemsTemplate(e,t,[Node],["Node"])}_preNodeElems(e){return ft._preNodeElems(this,e)}static _preNodeElem(e,t){return ft._preElemTemplate(e,t,[Node],["Node"])}_preNodeElem(e){return ft._preNodeElem(this,e)}static _preNodeElemWithNull(e,t){return ft._preElemTemplate(e,t,[Node],["Node"],!0)}_preNodeElemWithNull(e){return ft._preNodeElemWithNull(this,e)}static _preHtmlElems(e,t){return ft._preElemsTemplate(e,t,[HTMLElement],["HTMLElement"])}_preHtmlElems(e){return ft._preHtmlElems(this,e)}static _preHtmlElem(e,t){return ft._preElemTemplate(e,t,[HTMLElement],["HTMLElement"])}_preHtmlElem(e){return ft._preHtmlElem(this,e)}static _preInputElems(e,t){return ft._preElemsTemplate(e,t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElems(e){return ft._preInputElems(this,e)}static _preInputElem(e,t){return ft._preElemTemplate(e,t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElem(e){return ft._preInputElem(this,e)}static _preEventTargetElems(e,t){return ft._preElemsTemplate(e,t,[EventTarget],["EventTarget"])}_preEventTargetElems(e){return ft._preEventTargetElems(this,e)}static _preEventTargetElem(e,t){return ft._preElemTemplate(e,t,[EventTarget],["EventTarget"])}_preEventTargetElem(e){return ft._preEventTargetElem(this,e)}static _preElemsAndWindow(e,t){return ft._preElemsTemplate(e,t,[Element,Window],["Element","Window"])}_preElemsAndWindow(e){return ft._preElemsAndWindow(this,e)}static _preElemAndWindow(e,t){return ft._preElemTemplate(e,t,[Element,Window],["Element","Window"])}_preElemAndWindow(e){return ft._preElemAndWindow(this,e)}static _preElemsAndWinAndDoc(e,t){return ft._preElemsTemplate(e,t,[Element,Window,Document],["Element","Window","Document"]).map(e=>e instanceof Document?e.documentElement:e)}_preElemsAndWinAndDoc(e){return ft._preElemsAndWinAndDoc(this,e)}static _preElemAndWinAndDoc(e,t){const r=ft._preElemTemplate(e,t,[Element,Window,Document],["Element","Window","Document"]);return r instanceof Document?r.documentElement:r}_preElemAndWinAndDoc(e){return ft._preElemAndWinAndDoc(this,e)}static _preElemsWithDoc(e,t){return ft._preElemsTemplate(e,t,[Element,Document],["Element","Document"])}_preElemsWithDoc(e){return ft._preElemsWithDoc(this,e)}static _preElemWithDoc(e,t){return ft._preElemTemplate(e,t,[Element,Document],["Element","Document"])}_preElemWithDoc(e){return ft._preElemWithDoc(this,e)}static toTinyElm(e){const t=e=>e.map(e=>e instanceof ft?e:new ft(e));return Array.isArray(e)?t(e):t([e])}static fromTinyElm(e){const t=e=>{const t=[];return e.map(e=>(e instanceof ft?e._getElements("fromTinyElm"):[e]).map(e=>t.push(e))),t};return Array.isArray(e)?t(e):t([e])}static winnow(e,t,r,n=!1){if("boolean"!=typeof n)throw new TypeError('The "not" must be a boolean.');if("function"==typeof t)return ft._preElems(e,r).filter((e,r)=>!!t.call(e,r,e)!==n);if(t instanceof Element)return ft._preElems(e,r).filter(e=>e===t!==n);if(Array.isArray(t)||"string"!=typeof t&&null!=t.length)return ft._preElems(e,r).filter(e=>t.includes(e)!==n);let i=t;return n&&(i=`:not(${i})`),ft._preElems(e,r).filter(e=>1===e.nodeType&&e.matches(i))}static filter(e,t,r=!1){return r&&(t=`:not(${t})`),ft._preElems(e,"filter").filter(e=>1===e.nodeType&&e.matches(t))}static filterOnly(e,t){return ft.winnow(e,t,"filterOnly",!1)}static not(e,t){return ft.winnow(e,t,"not",!0)}not(e){return ft.not(this,e)}static find(e,t){const r=[];for(const n of ft._preElems(e,"find"))r.push(...n.querySelectorAll(t));return[...new Set(r)]}find(e){return ft.find(this,e)}static is(e,t){return ft.winnow(e,t,"is",!1).length>0}is(e){return ft.is(this,e)}static has(e,t){const r="string"==typeof t?[...document.querySelectorAll(t)]:ft._preElems(t,"has");return ft._preElems(e,"has").filter(e=>r.some(t=>e&&e.contains(t)))}has(e){return ft.has(this,e)}static closest(e,t,r){const n=[];for(const i of ft._preElems(e,"closest")){let e=i;for(;e&&e!==r;){if(1===e.nodeType&&("string"==typeof t?e.matches(t):e===t)){n.push(e);break}e=e.parentElement}}return[...new Set(n)]}closest(e,t){return ft.closest(this,e,t)}static isSameDom(e,t){return ft._preNodeElem(e,"isSameDom")===ft._preNodeElem(t,"isSameDom")}isSameDom(e){return ft.isSameDom(this,e)}#re={};get _data(){return{...this.#re}}set _data(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new Error("value must be a non-null object.");this.#re=e}static _dataSelector={public:(e,t)=>{const r=ft._preElem(t,e);let n=ht.get(r);return n||(n={},ht.set(r,n)),n},private:(e,t)=>{if(!(t instanceof ft))throw new Error(`Element must be a TinyHtml instance to execute ${e}().`);return t.#re}};static data(e,t,r=!1){const n=ft._dataSelector[r?"private":"public"]("data",e);if(null==t)return{...n};if("string"!=typeof t)throw new TypeError("The key must be a string.");return n.hasOwnProperty(t)?n[t]:void 0}data(e,t){return ft.data(this,e,t)}static setData(e,t,r,n=!1){const i=ft._dataSelector[n?"private":"public"]("setData",e);if("string"!=typeof t)throw new TypeError("The key must be a string.");return void 0!==r?i[t]=r:ft.removeData(e,t),e}setData(e,t,r=!1){return ft.setData(this,e,t,r)}static hasData(e,t,r=!1){if("string"!=typeof t)throw new TypeError("The key must be a string.");const n=ft._dataSelector[r?"private":"public"]("hasData",e);return Object.prototype.hasOwnProperty.call(n,t)}hasData(e,t=!1){return ft.hasData(this,e,t)}static removeData(e,t,r=!1){if("string"!=typeof t)throw new TypeError("The key must be a string.");return delete ft._dataSelector[r?"private":"public"]("removeData",e)[t]}removeData(e,t=!1){return ft.removeData(this,e,t)}static _getSibling(e,t,r){let n=ft._preNodeElemWithNull(e,r);for(;n&&(n=n[t])&&1!==n.nodeType;);return n instanceof Node?n:null}static _getSiblings(e,t){let r=e;const n=[];for(;r;r=r.nextSibling)1===r.nodeType&&r!==t&&n.push(r);return n}static domDir(e,t,r,n="domDir"){if("string"!=typeof t)throw new TypeError('The "direction" must be a string.');let i=ft._preNodeElemWithNull(e,n);const o=[];for(;i&&(i=i[t]);)if(1===i.nodeType){if(r&&("string"==typeof r?i.matches(r):i===r))break;o.push(i)}return o}static parent(e){let t=ft._preNodeElemWithNull(e,"parent");const r=t?t.parentNode:null;return r&&11!==r.nodeType?r:null}parent(){return ft.parent(this)}static parents(e,t){return ft.domDir(e,"parentNode",t,"parents")}parents(e){return ft.parents(this,e)}static next(e){return ft._getSibling(e,"nextSibling","next")}next(){return ft.next(this)}static prev(e){return ft._getSibling(e,"previousSibling","prev")}prev(){return ft.prev(this)}static nextAll(e){return ft.domDir(e,"nextSibling",void 0,"nextAll")}nextAll(){return ft.nextAll(this)}static prevAll(e){return ft.domDir(e,"previousSibling",void 0,"prevAll")}prevAll(){return ft.prevAll(this)}static nextUntil(e,t){return ft.domDir(e,"nextSibling",t,"nextUtil")}nextUntil(e){return ft.nextUntil(this,e)}static prevUntil(e,t){return ft.domDir(e,"previousSibling",t,"prevUtil")}prevUntil(e){return ft.prevUntil(this,e)}static siblings(e){const t=ft._preNodeElemWithNull(e,"siblings");return ft._getSiblings(t&&t.parentNode?t.parentNode.firstChild:null,t)}siblings(){return ft.siblings(this)}static children(e){const t=ft._preNodeElemWithNull(e,"children");return ft._getSiblings(t?t.firstChild:null)}children(){return ft.children(this)}static contents(e){const t=ft._preNodeElemWithNull(e,"contents");return t instanceof HTMLIFrameElement&&null!=t.contentDocument&&Object.getPrototypeOf(t.contentDocument)?[t.contentDocument]:t instanceof HTMLTemplateElement?Array.from((t.content||t).childNodes):t?Array.from(t.childNodes):[]}contents(){return ft.contents(this)}static clone(e,t=!0){if("boolean"!=typeof t)throw new TypeError('The "deep" must be a boolean.');return ft._preNodeElems(e,"clone").map(e=>e.cloneNode(t))}clone(e){return ft.clone(this,e)[0]}static _appendChecker(e,...t){const r=[];for(const n of t)if(null!=n&&!1!==n)if("string"!=typeof n&&"number"!=typeof n)if(n instanceof Node||n instanceof ft)r.push(...ft._preNodeElems(n,e));else if(Array.isArray(n))r.push(...ft._appendChecker(e,...n));else for(const t in n){const i=n[t];r.push(...ft._appendChecker(e,i))}else r.push(n);return r}static append(e,...t){return ft._preElem(e,"append").append(...ft._appendChecker("append",...t)),e}append(...e){return ft.append(this,...e)}static prepend(e,...t){return ft._preElem(e,"prepend").prepend(...ft._appendChecker("prepend",...t)),e}prepend(...e){return ft.prepend(this,...e)}static before(e,...t){return ft._preElem(e,"before").before(...ft._appendChecker("before",...t)),e}before(...e){return ft.before(this,...e)}static after(e,...t){return ft._preElem(e,"after").after(...ft._appendChecker("after",...t)),e}after(...e){return ft.after(this,...e)}static replaceWith(e,...t){return ft._preElem(e,"replaceWith").replaceWith(...ft._appendChecker("replaceWith",...t)),e}replaceWith(...e){return ft.replaceWith(this,...e)}static appendTo(e,t){const r=ft._preNodeElems(e,"appendTo"),n=ft._preNodeElems(t,"appendTo");return n.forEach((e,t)=>{r.forEach(r=>e.appendChild(t===n.length-1?r:r.cloneNode(!0)))}),e}appendTo(e){return ft.appendTo(this,e)}static prependTo(e,t){const r=ft._preElems(e,"prependTo"),n=ft._preElems(t,"prependTo");return n.forEach((e,t)=>{r.slice().reverse().forEach(r=>e.prepend(t===n.length-1?r:r.cloneNode(!0)))}),e}prependTo(e){return ft.prependTo(this,e)}static insertBefore(e,t,r=null){const n=ft._preNodeElem(e,"insertBefore"),i=ft._preNodeElem(t,"insertBefore"),o=ft._preNodeElemWithNull(r,"insertBefore");if(!i.parentNode)throw new Error("The target element has no parent node to insert before.");return i.parentNode.insertBefore(n,o||i),e}insertBefore(e,t){return ft.insertBefore(this,e,t)}static insertAfter(e,t,r=null){const n=ft._preNodeElem(e,"insertAfter"),i=ft._preNodeElem(t,"insertBefore"),o=ft._preNodeElemWithNull(r,"insertBefore");if(!i.parentNode)throw new Error("The target element has no parent node to insert after.");return i.parentNode.insertBefore(n,o||i.nextSibling),e}insertAfter(e,t){return ft.insertAfter(this,e,t)}static replaceAll(e,t){const r=ft._preNodeElems(e,"replaceAll"),n=ft._preNodeElems(t,"replaceAll");return n.forEach((e,t)=>{const i=e.parentNode;r.forEach(r=>{i&&i.replaceChild(t===n.length-1?r:r.cloneNode(!0),e)})}),e}replaceAll(e){return ft.replaceAll(this,e)}#U;get size(){return this.#U.length}static _elCheck(e){for(const t of e)if(!(t instanceof Element||t instanceof Window||t instanceof Document||t instanceof Text))throw new Error("[TinyHtml] Invalid Target in constructor.")}add(e){return new ft([...this.#U,...ft._selector(e)])}static _selector(e){if(e instanceof ft)throw new Error("[TinyHtml] You are trying to put a TinyHtml inside another TinyHtml in constructor.");const t=e=>Array.from(new Set(e)),r="string"!=typeof e?e:document.querySelectorAll(e);if(Array.isArray(r))return ft._elCheck(r),t(r);if(r instanceof NodeList||r instanceof HTMLCollection){const e=[...r];return ft._elCheck(e),t(e)}{const e=[r];return ft._elCheck(e),t(e)}}constructor(e){this.#U=ft._selector(e),this.#ne=ft.#ie}static isWindow(e){return null!=e&&e===e.window}static css(e){const t=ft._preElem(e,"css");return window.getComputedStyle(t)}css(){return ft.css(this)}static cssString(e,t){const r=ft._preElem(e,"cssString");if("string"!=typeof t)throw new TypeError("The prop must be a string.");const n=window.getComputedStyle(r)[t];return"string"==typeof n?n:"number"==typeof n?n.toString():null}cssString(e){return ft.cssString(this,e)}static cssList(e,t){const r=ft._preElem(e,"cssList");if(!Array.isArray(t))throw new TypeError("The prop must be an array of strings.");const n=window.getComputedStyle(r),i={};for(const e of t)void 0!==e&&(i[e]=n.getPropertyValue(e));return i}cssList(e){return ft.cssList(this,e)}static cssFloat(e,t){const r=ft._preElem(e,"cssFloat");if("string"!=typeof t)throw new TypeError("The prop must be a string.");const n=window.getComputedStyle(r)[t];return parseFloat(n)||0}cssFloat(e){return ft.cssFloat(this,e)}static cssFloats(e,t){const r=ft._preElem(e,"cssFloats");if(!Array.isArray(t))throw new TypeError("The prop must be an array of strings.");const n=window.getComputedStyle(r),i={};for(const e of t)i[e]=parseFloat(n[e])||0;return i}cssFloats(e){return ft.cssFloats(this,e)}static#oe={alignContent:"align-content",alignItems:"align-items",alignSelf:"align-self",animationDelay:"animation-delay",animationDirection:"animation-direction",animationDuration:"animation-duration",animationFillMode:"animation-fill-mode",animationIterationCount:"animation-iteration-count",animationName:"animation-name",animationPlayState:"animation-play-state",animationTimingFunction:"animation-timing-function",backfaceVisibility:"backface-visibility",backgroundAttachment:"background-attachment",backgroundBlendMode:"background-blend-mode",backgroundClip:"background-clip",backgroundColor:"background-color",backgroundImage:"background-image",backgroundOrigin:"background-origin",backgroundPosition:"background-position",backgroundRepeat:"background-repeat",backgroundSize:"background-size",borderBottom:"border-bottom",borderBottomColor:"border-bottom-color",borderBottomLeftRadius:"border-bottom-left-radius",borderBottomRightRadius:"border-bottom-right-radius",borderBottomStyle:"border-bottom-style",borderBottomWidth:"border-bottom-width",borderCollapse:"border-collapse",borderColor:"border-color",borderImage:"border-image",borderImageOutset:"border-image-outset",borderImageRepeat:"border-image-repeat",borderImageSlice:"border-image-slice",borderImageSource:"border-image-source",borderImageWidth:"border-image-width",borderLeft:"border-left",borderLeftColor:"border-left-color",borderLeftStyle:"border-left-style",borderLeftWidth:"border-left-width",borderRadius:"border-radius",borderRight:"border-right",borderRightColor:"border-right-color",borderRightStyle:"border-right-style",borderRightWidth:"border-right-width",borderSpacing:"border-spacing",borderStyle:"border-style",borderTop:"border-top",borderTopColor:"border-top-color",borderTopLeftRadius:"border-top-left-radius",borderTopRightRadius:"border-top-right-radius",borderTopStyle:"border-top-style",borderTopWidth:"border-top-width",borderWidth:"border-width",boxDecorationBreak:"box-decoration-break",boxShadow:"box-shadow",boxSizing:"box-sizing",breakAfter:"break-after",breakBefore:"break-before",breakInside:"break-inside",captionSide:"caption-side",caretColor:"caret-color",clipPath:"clip-path",columnCount:"column-count",columnFill:"column-fill",columnGap:"column-gap",columnRule:"column-rule",columnRuleColor:"column-rule-color",columnRuleStyle:"column-rule-style",columnRuleWidth:"column-rule-width",columnSpan:"column-span",columnWidth:"column-width",counterIncrement:"counter-increment",counterReset:"counter-reset",emptyCells:"empty-cells",flexBasis:"flex-basis",flexDirection:"flex-direction",flexFlow:"flex-flow",flexGrow:"flex-grow",flexShrink:"flex-shrink",flexWrap:"flex-wrap",fontFamily:"font-family",fontFeatureSettings:"font-feature-settings",fontKerning:"font-kerning",fontLanguageOverride:"font-language-override",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontSynthesis:"font-synthesis",fontVariant:"font-variant",fontVariantAlternates:"font-variant-alternates",fontVariantCaps:"font-variant-caps",fontVariantEastAsian:"font-variant-east-asian",fontVariantLigatures:"font-variant-ligatures",fontVariantNumeric:"font-variant-numeric",fontVariantPosition:"font-variant-position",fontWeight:"font-weight",gridArea:"grid-area",gridAutoColumns:"grid-auto-columns",gridAutoFlow:"grid-auto-flow",gridAutoRows:"grid-auto-rows",gridColumn:"grid-column",gridColumnEnd:"grid-column-end",gridColumnGap:"grid-column-gap",gridColumnStart:"grid-column-start",gridGap:"grid-gap",gridRow:"grid-row",gridRowEnd:"grid-row-end",gridRowGap:"grid-row-gap",gridRowStart:"grid-row-start",gridTemplate:"grid-template",gridTemplateAreas:"grid-template-areas",gridTemplateColumns:"grid-template-columns",gridTemplateRows:"grid-template-rows",imageRendering:"image-rendering",justifyContent:"justify-content",letterSpacing:"letter-spacing",lineBreak:"line-break",lineHeight:"line-height",listStyle:"list-style",listStyleImage:"list-style-image",listStylePosition:"list-style-position",listStyleType:"list-style-type",marginBottom:"margin-bottom",marginLeft:"margin-left",marginRight:"margin-right",marginTop:"margin-top",maskClip:"mask-clip",maskComposite:"mask-composite",maskImage:"mask-image",maskMode:"mask-mode",maskOrigin:"mask-origin",maskPosition:"mask-position",maskRepeat:"mask-repeat",maskSize:"mask-size",maskType:"mask-type",maxHeight:"max-height",maxWidth:"max-width",minHeight:"min-height",minWidth:"min-width",mixBlendMode:"mix-blend-mode",objectFit:"object-fit",objectPosition:"object-position",offsetAnchor:"offset-anchor",offsetDistance:"offset-distance",offsetPath:"offset-path",offsetRotate:"offset-rotate",outlineColor:"outline-color",outlineOffset:"outline-offset",outlineStyle:"outline-style",outlineWidth:"outline-width",overflowAnchor:"overflow-anchor",overflowWrap:"overflow-wrap",overflowX:"overflow-x",overflowY:"overflow-y",paddingBottom:"padding-bottom",paddingLeft:"padding-left",paddingRight:"padding-right",paddingTop:"padding-top",pageBreakAfter:"page-break-after",pageBreakBefore:"page-break-before",pageBreakInside:"page-break-inside",perspectiveOrigin:"perspective-origin",placeContent:"place-content",placeItems:"place-items",placeSelf:"place-self",pointerEvents:"pointer-events",rowGap:"row-gap",scrollBehavior:"scroll-behavior",scrollMargin:"scroll-margin",scrollMarginBlock:"scroll-margin-block",scrollMarginBlockEnd:"scroll-margin-block-end",scrollMarginBlockStart:"scroll-margin-block-start",scrollMarginBottom:"scroll-margin-bottom",scrollMarginInline:"scroll-margin-inline",scrollMarginInlineEnd:"scroll-margin-inline-end",scrollMarginInlineStart:"scroll-margin-inline-start",scrollMarginLeft:"scroll-margin-left",scrollMarginRight:"scroll-margin-right",scrollMarginTop:"scroll-margin-top",scrollPadding:"scroll-padding",scrollPaddingBlock:"scroll-padding-block",scrollPaddingBlockEnd:"scroll-padding-block-end",scrollPaddingBlockStart:"scroll-padding-block-start",scrollPaddingBottom:"scroll-padding-bottom",scrollPaddingInline:"scroll-padding-inline",scrollPaddingInlineEnd:"scroll-padding-inline-end",scrollPaddingInlineStart:"scroll-padding-inline-start",scrollPaddingLeft:"scroll-padding-left",scrollPaddingRight:"scroll-padding-right",scrollPaddingTop:"scroll-padding-top",scrollSnapAlign:"scroll-snap-align",scrollSnapStop:"scroll-snap-stop",scrollSnapType:"scroll-snap-type",shapeImageThreshold:"shape-image-threshold",shapeMargin:"shape-margin",shapeOutside:"shape-outside",tabSize:"tab-size",tableLayout:"table-layout",textAlign:"text-align",textAlignLast:"text-align-last",textCombineUpright:"text-combine-upright",textDecoration:"text-decoration",textDecorationColor:"text-decoration-color",textDecorationLine:"text-decoration-line",textDecorationStyle:"text-decoration-style",textIndent:"text-indent",textJustify:"text-justify",textOrientation:"text-orientation",textOverflow:"text-overflow",textShadow:"text-shadow",textTransform:"text-transform",transformBox:"transform-box",transformOrigin:"transform-origin",transformStyle:"transform-style",transitionDelay:"transition-delay",transitionDuration:"transition-duration",transitionProperty:"transition-property",transitionTimingFunction:"transition-timing-function",unicodeBidi:"unicode-bidi",userSelect:"user-select",verticalAlign:"vertical-align",whiteSpace:"white-space",willChange:"will-change",wordBreak:"word-break",wordSpacing:"word-spacing",wordWrap:"word-wrap",writingMode:"writing-mode",zIndex:"z-index",WebkitTransform:"-webkit-transform",WebkitTransition:"-webkit-transition",WebkitBoxShadow:"-webkit-box-shadow",MozBoxShadow:"-moz-box-shadow",MozTransform:"-moz-transform",MozTransition:"-moz-transition",msTransform:"-ms-transform",msTransition:"-ms-transition"};static cssPropAliases=new Proxy(ft.#oe,{set:(e,t,r)=>(e[t]=r,ft.cssPropRevAliases[r]=t,!0)});static cssPropRevAliases=Object.fromEntries(Object.entries(ft.#oe).map(([e,t])=>[t,e]));static toStyleKc(e){return"string"==typeof ft.cssPropAliases[e]?ft.cssPropAliases[e]:e}static toStyleCc(e){return"string"==typeof ft.cssPropRevAliases[e]?ft.cssPropRevAliases[e]:e}static setStyle(e,t,r=null){return ft._preHtmlElems(e,"setStyle").forEach(e=>{if("object"==typeof t)for(const[r,n]of Object.entries(t))e.style.setProperty(ft.toStyleKc(r),"string"==typeof n?n:"number"==typeof n?`${n}px`:String(n));else e.style.setProperty(ft.toStyleKc(t),r)}),e}setStyle(e,t){return ft.setStyle(this,e,t)}static getStyle(e,t){return ft._preHtmlElem(e,"getStyle").style.getPropertyValue(ft.toStyleKc(t))}getStyle(e){return ft.getStyle(this,e)}static style(e,{camelCase:t=!1,rawAttr:r=!1}={}){if("boolean"!=typeof t)throw new TypeError('"camelCase" must be a boolean. Received: '+typeof t);if("boolean"!=typeof r)throw new TypeError('"rawAttr" must be a boolean. Received: '+typeof r);const n=ft._preHtmlElem(e,"style"),i={};if(r){const e=(n.getAttribute("style")||"").split(";");for(const r of e){const[e,n]=r.split(":");if(!e||!n)continue;const o=e.trim(),s=n.trim();i[t?ft.toStyleCc(o):o]=s}}else{const e=n.style;for(let r=0;r<e.length;r++){const n=e[r],o=e.getPropertyValue(n);i[t?ft.toStyleCc(n):n]=o}}return i}style(e){return ft.style(this,e)}static removeStyle(e,t){return ft._preHtmlElems(e,"removeStyle").forEach(e=>{if(Array.isArray(t))for(const r of t)e.style.removeProperty(ft.toStyleKc(r));else e.style.removeProperty(ft.toStyleKc(t))}),e}removeStyle(e){return ft.removeStyle(this,e)}static toggleStyle(e,t,r,n){return ft._preHtmlElems(e,"toggleStyle").forEach(e=>{const i=ft.getStyle(e,t).trim()===ft.toStyleKc(r)?n:r;ft.setStyle(e,t,i)}),e}toggleStyle(e,t,r){return ft.toggleStyle(this,e,t,r)}static clearStyle(e){return ft._preElems(e,"clearStyle").forEach(e=>e.removeAttribute("style")),e}clearStyle(){return ft.clearStyle(this)}static focus(e){return ft._preHtmlElem(e,"focus").focus(),e}focus(){return ft.focus(this)}static blur(e){return ft._preHtmlElem(e,"blur").blur(),e}blur(){return ft.blur(this)}static select(e){const t=ft._preHtmlElem(e,"select");if(!(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement))throw new Error("Element must be an <input> or <textarea> to use select().");return t.select(),e}select(){return ft.select(this)}static boolCheck(e){return void 0!==e&&("true"===e||"1"===e||!0===e||"on"===e||"number"==typeof e&&e>0)}static setWinScrollTop(e){if("number"!=typeof e)throw new TypeError("The value must be a number.");ft.setScrollTop(window,e)}static setWinScrollLeft(e){if("number"!=typeof e)throw new TypeError("The value must be a number.");ft.setScrollLeft(window,e)}static winScrollTop(){return window.scrollY||document.documentElement.scrollTop}static winScrollLeft(){return window.scrollX||document.documentElement.scrollLeft}static winInnerHeight(){return window.innerHeight||document.documentElement.clientHeight}static winInnerWidth(){return window.innerWidth||document.documentElement.clientWidth}static isPageTop(){return 0===window.scrollY}static isPageBottom(){return window.innerHeight+window.scrollY>=document.body.offsetHeight}static getDimension(e,t,r="content"){const n=ft._preElemAndWinAndDoc(e,"getDimension");if("string"!=typeof t)throw new TypeError("The type must be a string.");if("string"!=typeof r)throw new TypeError("The extra must be a string.");const i="width"===t?"Width":"Height";if(ft.isWindow(n))return"margin"===r?n["inner"+i]:n.document.documentElement["client"+i];const o=n;if(9===o.nodeType){const e=o.documentElement;return Math.max(o.body["scroll"+i],e["scroll"+i],o.body["offset"+i],e["offset"+i],e["client"+i])}let s=o.getBoundingClientRect()[t];function a(e){return"width"===t?ft.cssFloat(o,e+"Left")+ft.cssFloat(o,e+"Right"):ft.cssFloat(o,e+"Top")+ft.cssFloat(o,e+"Bottom")}switch(r){case"content":s-=a("padding"),s-=a("border");break;case"padding":s-=a("border");break;case"border":break;case"margin":s+=a("margin")}return s}getDimension(e,t){return ft.getDimension(this,e,t)}static setHeight(e,t){const r=ft._preHtmlElem(e,"setHeight");if("number"!=typeof t&&"string"!=typeof t)throw new TypeError("The value must be a string or number.");return r.style.height="number"==typeof t?`${t}px`:t,e}setHeight(e){return ft.setHeight(this,e)}set height(e){ft.setHeight(this,e)}static setWidth(e,t){const r=ft._preHtmlElem(e,"setWidth");if("number"!=typeof t&&"string"!=typeof t)throw new TypeError("The value must be a string or number.");return r.style.width="number"==typeof t?`${t}px`:t,e}setWidth(e){return ft.setWidth(this,e)}set width(e){ft.setWidth(this,e)}static height(e){const t=ft._preElemAndWinAndDoc(e,"height");return ft.getDimension(t,"height","content")}get height(){return ft.height(this)}static width(e){const t=ft._preElemAndWinAndDoc(e,"width");return ft.getDimension(t,"width","content")}get width(){return ft.width(this)}static innerHeight(e){const t=ft._preElemAndWinAndDoc(e,"innerHeight");return ft.getDimension(t,"height","padding")}innerHeight(){return ft.innerHeight(this)}static innerWidth(e){const t=ft._preElemAndWinAndDoc(e,"innerWidth");return ft.getDimension(t,"width","padding")}innerWidth(){return ft.innerWidth(this)}static outerHeight(e,t=!1){if("boolean"!=typeof t)throw new TypeError('The "includeMargin" must be a boolean.');const r=ft._preElemAndWinAndDoc(e,"outerHeight");return ft.getDimension(r,"height",t?"margin":"border")}outerHeight(e){return ft.outerHeight(this,e)}static outerWidth(e,t=!1){if("boolean"!=typeof t)throw new TypeError('The "includeMargin" must be a boolean.');const r=ft._preElemAndWinAndDoc(e,"outerWidth");return ft.getDimension(r,"width",t?"margin":"border")}outerWidth(e){return ft.outerWidth(this,e)}#ne="";get mainDisplay(){return this.#ne}set mainDisplay(e){if("string"!=typeof e)throw new TypeError("mainDisplay must be a string.");this.#ne=e}static#ie="block";static get defaultDisplay(){return ft.#ie}static set defaultDisplay(e){if("string"!=typeof e)throw new TypeError("defaultDisplay must be a string.");ft.#ie=e}static getAnimateData(e,t){let r=dt.get(e);return r||(r={},dt.set(e,r)),r[t]}static setAnimateData(e,t,r){if(!(e instanceof HTMLElement))throw new TypeError("setAnimateData: el must be an HTMLElement.");if("string"!=typeof t)throw new TypeError("setAnimateData: where must be a string.");if("string"!=typeof r&&"number"!=typeof r)throw new TypeError("setAnimateData: value must be a string or number.");let n=dt.get(e);n||(n={},dt.set(e,n)),n[t]=r}static#se=!0;static get cancelOldStyleFx(){return ft.#se}static set cancelOldStyleFx(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean value.");ft.#se=e}static#ae={slow:{duration:600,easing:"ease"},fast:{duration:200,easing:"ease-out"},_default:{duration:400,easing:"linear"}};static get styleFxSpeeds(){const e={};for(const t in ft.#ae){const r=ft.#ae[t];e[t]="object"==typeof r?{...r}:r}return e}static set styleFxSpeeds(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("styleFxSpeeds must be an object.");for(const[t,r]of Object.entries(e))if("number"!=typeof r&&"object"!=typeof r)throw new TypeError(`styleFxSpeeds["${t}"] must be a number or KeyframeAnimationOptions.`);ft.#ae={};for(const[t,r]of Object.entries(e))ft.setStyleFxSpeed(t,r)}static getStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');const t=ft.#ae[e];return"object"==typeof t?{...t}:t}static setStyleFxSpeed(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("number"!=typeof t&&"object"!=typeof t)throw new TypeError("styleFxSpeed must be a number or KeyframeAnimationOptions");ft.#ae[e]="object"==typeof t?{...t}:t}static deleteStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete ft.#ae[e]}static hasStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(ft.#ae,e)}static#le=["Top","Right","Bottom","Left"];static#ue={slideDown:ft.genStyleFx("show"),slideUp:ft.genStyleFx("hide"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}};static get styleEffects(){return JSON.parse(JSON.stringify(ft.#ue))}static set styleEffects(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("styleEffects must be an object");for(const t in e)for(const[r,n]of Object.entries(e[t]))if(!("string"==typeof n||Array.isArray(n)&&n.every(e=>"string"==typeof e||"number"==typeof e)))throw new TypeError(`Invalid styleEffect["${r}"]`);ft.#ue={};for(const t in e)ft.setStyleEffect(t,e[t])}static getStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');const t=ft.#ue[e];return t?JSON.parse(JSON.stringify(t)):void 0}static setStyleEffect(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError("styleEffect must be an object");const r={};for(const[e,n]of Object.entries(t))if("string"==typeof n)r[e]=n;else{if(!Array.isArray(n)||!n.every(e=>"string"==typeof e||"number"==typeof e))throw new TypeError(`Invalid styleEffect["${e}"]`);r[e]=[...n]}ft.#ue[e]=r}static deleteStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete ft.#ue[e]}static hasStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(ft.#ue,e)}static#ce={slideDown:"slideUp",slideUp:"slideDown",fadeIn:"fadeOut",fadeOut:"fadeIn",fadeTo:"fadeIn"};static get styleEffectInverse(){return{...ft.#ce}}static set styleEffectInverse(e){if("object"!=typeof e||null===e)throw new TypeError("styleEffectInverse must be an object.");for(const[t,r]of Object.entries(e))if("string"!=typeof r)throw new TypeError(`styleEffectInverse["${t}"] must be a string.`);ft.#ce={};for(const[t,r]of Object.entries(e))ft.setStyleEffectInverse(t,r)}static getStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return ft.#ce[e]||null}static setStyleEffectInverse(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("string"!=typeof t)throw new TypeError(`styleEffectInverse["${e}"] must be a string.`);ft.#ce[e]=t}static deleteStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete ft.#ce[e]}static hasStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(ft.#ce,e)}static#he={slideDown:e=>e.height[0]===e.height[1]&&(!e.width||e.width[0]===e.width[1]),slideUp:e=>e.height[0]===e.height[1]&&(!e.width||e.width[0]===e.width[1]),fadeIn:e=>Number(e.opacity[0])===Number(e.opacity[1]),fadeOut:e=>Number(e.opacity[0])===Number(e.opacity[1])};static get styleEffectsRd(){return{...ft.#he}}static set styleEffectsRd(e){if("object"!=typeof e||null===e)throw new TypeError("styleEffectsRd must be an object.");for(const[t,r]of Object.entries(e))if("function"!=typeof r)throw new TypeError(`styleEffectsRd["${t}"] must be a function.`);ft.#he={};for(const[t,r]of Object.entries(e))ft.setStyleEffectRd(t,r)}static getStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return ft.#he[e]||null}static setStyleEffectRd(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("function"!=typeof t)throw new TypeError(`styleEffectsRd["${e}"] must be a function.`);ft.#he[e]=t}static deleteStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete ft.#he[e]}static hasStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(ft.#he,e)}static#de={show:(e,t,r,n)=>{if("height"===r||"width"===r){const i=ft.getAnimateData(e,`orig${r}`)||e.scrollHeight+"px";ft.setAnimateData(e,`orig${r}`,i);const o=n[r];t[r]=[o,i]}else if(r.startsWith("margin")||r.startsWith("padding")){const i=ft.getAnimateData(e,r)||n[r];ft.setAnimateData(e,r,i),t[r]=["0px",i]}else if("opacity"===r){const e=n.opacity;t[r]=[e,1]}else{const i=ft.getAnimateData(e,r)||n[r];ft.setAnimateData(e,r,i),t[r]=[i,n[r]||1]}},hide:(e,t,r,n)=>{if("height"===r||"width"===r){const i=ft.getAnimateData(e,`orig${r}`)||n[r];ft.setAnimateData(e,`orig${r}`,i);const o=n[r];t[r]=[o,0]}else if(r.startsWith("margin")||r.startsWith("padding")){const i=ft.getAnimateData(e,r)||n[r];ft.setAnimateData(e,r,i),t[r]=[n[r],"0px"]}else if("opacity"===r){const e=n.opacity;t[r]=[e,0]}else{const i=ft.getAnimateData(e,r)||n[r];ft.setAnimateData(e,r,i),t[r]=[i,0]}}};static get styleEffectsProps(){return{...ft.#de}}static set styleEffectsProps(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("styleEffectsProps must be an object");for(const[t,r]of Object.entries(e))if("function"!=typeof r)throw new TypeError(`styleEffectsProps["${t}"] must be a function`);ft.#de={};for(const[t,r]of Object.entries(e))ft.setStyleEffectProp(t,r)}static getStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return ft.#de[e]||null}static setStyleEffectProp(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("function"!=typeof t)throw new TypeError(`styleEffectsProps["${e}"] must be a function`);ft.#de[e]=t}static deleteStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete ft.#de[e]}static hasStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(ft.#de,e)}static genStyleFx(e,t=!1){if("string"!=typeof e)throw new TypeError("genStyleFx: type must be a string.");if("boolean"!=typeof t)throw new TypeError("genStyleFx: includeWidth must be a boolean.");let r,n=0;const i={height:e},o=t?1:0;for(;n<4;n+=2-o)r=ft.#le[n],i["margin"+r]=e,i["padding"+r]=e;return t&&(i.opacity=e,i.width=e),i}static applyStyleFx(e,t,r,n){if("string"!=typeof t)throw new TypeError("applyStyleFx: id must be a string.");if("object"!=typeof r||null===r)throw new TypeError("applyStyleFx: props must be a non-null object.");if(void 0!==n&&"number"!=typeof n&&"string"!=typeof n&&("object"!=typeof n||null===n))throw new TypeError("applyStyleFx: ops must be a number, string, KeyframeAnimationOptions, or undefined.");const i=new Map;return ft._preHtmlElems(e,"applyStyleFx").forEach(o=>{const s={};for(const[e,t]of Object.entries(r))if("string"==typeof t&&this.#de[t]){const r=getComputedStyle(o);this.#de[t](o,s,e,r)}else{if("object"!=typeof t)throw new TypeError(`applyStyleFx: invalid action for prop "${e}". Must be string or array.`);s[e]=t}if("function"==typeof ft.#he[t]&&ft.#he[t](s))return void i.set(o,null);const a=[],l=s[Object.keys(s)[0]].length;for(let e=0;e<l;e++){const t={};for(const r in s)t[r]=s[r][e];a.push(t)}i.set(o,ft.animate(e,a,n,t)[0])}),i}applyStyleFx(e,t,r){return ft.applyStyleFx(this,e,t,r)}static getCurrentAnimationId(e){if(!(e instanceof HTMLElement))throw new TypeError("Expected an HTMLElement.");return mt.get(e)?.id??void 0}static animate(e,t,r=ft.#ae._default,n=null,i=ft.#se){const o="string"==typeof r?ft.#ae[r]??void 0:"number"!=typeof r?{...r}:r;"object"==typeof o&&void 0===o.fill&&(o.fill="forwards");const s=[];return ft._preHtmlElems(e,"animate").forEach(e=>{if(i){const t=mt.get(e);t&&t.animation.cancel()}const r=e.animate(t,o);s.push(r),mt.set(e,{animation:r,id:n??""}),r.addEventListener("finish",()=>{mt.get(e)?.animation===r&&mt.delete(e)})}),s}animate(e,t,r,n){return ft.animate(this,e,t,r,n)}static stop(e){const t=[];return ft._preHtmlElems(e,"stop").forEach(e=>{const r=mt.get(e);r?(r.animation.cancel(),mt.delete(e),t.push(!0)):t.push(!1)}),t}stop(){return ft.stop(this)}static slideDown(e,t){return ft.applyStyleFx(e,"slideDown",this.#ue.slideDown,t??{duration:500,easing:"ease-out"})}slideDown(e){return ft.slideDown(this,e)}static slideUp(e,t){return ft.applyStyleFx(e,"slideUp",this.#ue.slideUp,t??{duration:500,easing:"ease-out"})}slideUp(e){return ft.slideUp(this,e)}static slideToggle(e,t){const r=ft._preHtmlElem(e,"slideToggle"),n=getComputedStyle(r),i=ft.getCurrentAnimationId(r),o="none"===n.display||0===r.offsetHeight;return("string"==typeof i?"slideUp"===i:o)?ft.slideDown(e,t):ft.slideUp(e,t)}slideToggle(e){return ft.slideToggle(this,e)}static fadeIn(e,t){return ft.applyStyleFx(e,"fadeIn",this.#ue.fadeIn,t)}fadeIn(e){return ft.fadeIn(this,e)}static fadeOut(e,t){return ft.applyStyleFx(e,"fadeOut",this.#ue.fadeOut,t)}fadeOut(e){return ft.fadeOut(this,e)}static fadeToggle(e,t){const r=ft._preHtmlElem(e,"fadeToggle"),n=getComputedStyle(r),i=ft.getCurrentAnimationId(r),o="0"===n.opacity||null===r.offsetParent;return("string"==typeof i?"fadeOut"===i:o)?ft.fadeIn(e,t):ft.fadeOut(e,t)}fadeToggle(e){return ft.fadeToggle(this,e)}static fadeTo(e,t,r,n=ft.#ie){if("number"!=typeof t||isNaN(t)||t<0||t>1)throw new TypeError("fadeTo: opacity must be a number between 0 and 1.");if(void 0!==r&&"number"!=typeof r&&"string"!=typeof r&&("object"!=typeof r||null===r))throw new TypeError("fadeTo: ops must be a number, string, KeyframeAnimationOptions, or undefined.");const i=new Map;return ft._preHtmlElems(e,"fadeTo").forEach(o=>{const s=getComputedStyle(o);if(!(e instanceof Element&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length))){const e=ft.getAnimateData(o,"origdisplay");o.style.display="string"==typeof e?e:n}const a=[s.opacity,t].map(e=>({opacity:e}));i.set(o,ft.animate(o,a,r,"fadeTo")[0])}),i}fadeTo(e,t,r=this.#ne){return ft.fadeTo(this,e,t,r)}static offset(e){const t=ft._preElem(e,"offset").getBoundingClientRect(),r=window.scrollY||document.documentElement.scrollTop,n=window.scrollX||document.documentElement.scrollLeft;return{top:t.top+r,left:t.left+n}}offset(){return ft.offset(this)}static position(e){const t=ft._preHtmlElem(e,"position");let r,n,i={top:0,left:0};if("fixed"===window.getComputedStyle(t).position)n=t.getBoundingClientRect();else{n=ft.offset(t),r=t.offsetParent||document.documentElement;const{position:e}=window.getComputedStyle(r);for(;r instanceof HTMLElement&&(r===document.body||r===document.documentElement)&&"static"===e;)r=r.parentNode;if(r instanceof HTMLElement&&r!==t&&1===r.nodeType){const{borderTopWidth:e,borderLeftWidth:t}=ft.cssFloats(r,["borderTopWidth","borderLeftWidth"]);i=ft.offset(r),i.top+=e,i.left+=t}}return{top:n.top-i.top-ft.cssFloat(t,"marginTop"),left:n.left-i.left-ft.cssFloat(t,"marginLeft")}}position(){return ft.position(this)}static offsetParent(e){let t=ft._preHtmlElem(e,"offsetParent").offsetParent;for(;t instanceof HTMLElement&&"static"===window.getComputedStyle(t).position;)t=t.offsetParent;return t instanceof HTMLElement?t:document.documentElement}offsetParent(){return ft.offsetParent(this)}static scrollTop(e){const t=ft._preElemAndWindow(e,"scrollTop");return ft.isWindow(t)?t.pageYOffset:9===t.nodeType?t.defaultView.pageYOffset:t.scrollTop}scrollTop(){return ft.scrollTop(this)}static scrollLeft(e){const t=ft._preElemAndWindow(e,"scrollLeft");return ft.isWindow(t)?t.pageXOffset:9===t.nodeType?t.defaultView.pageXOffset:t.scrollLeft}scrollLeft(){return ft.scrollLeft(this)}static easings={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>e*(2-e),easeInOutQuad:e=>e<.5?2*e*e:(4-2*e)*e-1,easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1};static scrollToXY(e,{targetX:t,targetY:r,duration:n,easing:i,onAnimation:o}={}){if(void 0!==t&&"number"!=typeof t)throw new TypeError("`targetX` must be a number if provided.");if(void 0!==r&&"number"!=typeof r)throw new TypeError("`targetY` must be a number if provided.");if(void 0!==n&&"number"!=typeof n)throw new TypeError("`duration` must be a number if provided.");if(void 0!==i&&"string"!=typeof i)throw new TypeError("`easing` must be a string if provided.");if(void 0!==i&&"function"!=typeof ft.easings[i])throw new TypeError(`Unknown easing function: "${i}".`);if(void 0!==o&&"function"!=typeof o)throw new TypeError("`onAnimation` must be a function if provided.");const s=(e,t,r,n)=>{if(e instanceof Window)window.scrollTo(t,r);else if(9===e.nodeType)e.defaultView.scrollTo(t,r);else{const n=e instanceof Window?window.scrollX:e.scrollLeft,i=e instanceof Window?window.scrollY:e.scrollTop;n!==t&&(e.scrollLeft=t),i!==r&&(e.scrollTop=r)}"function"==typeof o&&o({x:t,y:r,isComplete:n>=1,time:n})};return ft._preElemsAndWindow(e,"scrollToXY").forEach(e=>{const o=e instanceof Window?window.scrollX:e.scrollLeft,a=e instanceof Window?window.scrollY:e.scrollTop,l=t??o,u=r??a,c=l-o,h=u-a,d="string"==typeof i&&ft.easings[i]||null;if("number"!=typeof n||"function"!=typeof d)return s(e,l,u,1);const m=performance.now(),p=n??0;requestAnimationFrame(function t(r){if("function"!=typeof d)return;const n=Math.min(1,(r-m)/p),i=d(n);s(e,o+c*i,a+h*i,n),n<1&&requestAnimationFrame(t)})}),e}scrollToXY({targetX:e,targetY:t,duration:r,easing:n,onAnimation:i}={}){return ft.scrollToXY(this,{targetX:e,targetY:t,duration:r,easing:n,onAnimation:i})}static setScrollTop(e,t){if("number"!=typeof t)throw new TypeError("ScrollTop value must be a number.");return ft.scrollToXY(e,{targetY:t})}setScrollTop(e){return ft.setScrollTop(this,e)}static setScrollLeft(e,t){if("number"!=typeof t)throw new TypeError("ScrollLeft value must be a number.");return ft.scrollToXY(e,{targetX:t})}setScrollLeft(e){return ft.setScrollLeft(this,e)}static borderWidth(e){const t=ft._preElem(e,"borderWidth"),{borderLeftWidth:r,borderRightWidth:n,borderTopWidth:i,borderBottomWidth:o}=ft.cssFloats(t,["borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"]);return{x:r+n,y:i+o,left:r,right:n,top:i,bottom:o}}borderWidth(){return ft.borderWidth(this)}static border(e){const t=ft._preElem(e,"border"),{borderLeft:r,borderRight:n,borderTop:i,borderBottom:o}=ft.cssFloats(t,["borderLeft","borderRight","borderTop","borderBottom"]);return{x:r+n,y:i+o,left:r,right:n,top:i,bottom:o}}border(){return ft.border(this)}static margin(e){const t=ft._preElem(e,"margin"),{marginLeft:r,marginRight:n,marginTop:i,marginBottom:o}=ft.cssFloats(t,["marginLeft","marginRight","marginTop","marginBottom"]);return{x:r+n,y:i+o,left:r,right:n,top:i,bottom:o}}margin(){return ft.margin(this)}static padding(e){const t=ft._preElem(e,"padding"),{paddingLeft:r,paddingRight:n,paddingTop:i,paddingBottom:o}=ft.cssFloats(t,["paddingLeft","paddingRight","paddingTop","paddingBottom"]);return{x:r+n,y:i+o,left:r,right:n,top:i,bottom:o}}padding(){return ft.padding(this)}static#me=!1;static get classCanWhitespace(){return this.#me}static set classCanWhitespace(e){if("boolean"!=typeof e)throw new TypeError("classCanWhitespace must be a boolean");this.#me=e}static addClass(e,...t){const r=[];for(const e of t)if(ft.#me){const t=e.split(" ");for(const e of t)r.push(e)}else r.push(e);return ft._preElems(e,"addClass").forEach(e=>e.classList.add(...r)),e}addClass(...e){return ft.addClass(this,...e)}static removeClass(e,...t){const r=[];for(const e of t)if(ft.#me){const t=e.split(" ");for(const e of t)r.push(e)}else r.push(e);return ft._preElems(e,"removeClass").forEach(e=>e.classList.remove(...r)),e}removeClass(...e){return ft.removeClass(this,...e)}static replaceClass(e,t,r){if("string"!=typeof t)throw new TypeError('The "token" parameter must be a string.');if("string"!=typeof r)throw new TypeError('The "newToken" parameter must be a string.');const n=[];return ft._preElems(e,"replaceClass").forEach(e=>n.push(e.classList.replace(t,r))),n}replaceClass(e,t){return ft.replaceClass(this,e,t)[0]}static classItem(e,t){const r=ft._preElem(e,"classItem");if("number"!=typeof t)throw new TypeError('The "index" parameter must be a number.');return r.classList.item(t)}classItem(e){return ft.classItem(this,e)}static toggleClass(e,t,r){if("string"!=typeof t)throw new TypeError('The "token" parameter must be a string.');if(void 0!==r&&"boolean"!=typeof r)throw new TypeError('The "force" parameter must be a boolean.');const n=[];return ft._preElems(e,"toggleClass").forEach(e=>n.push(e.classList.toggle(t,r))),n}toggleClass(e,t){return ft.toggleClass(this,e,t)[0]}static hasClass(e,t){const r=ft._preElem(e,"hasClass");if("string"!=typeof t)throw new TypeError('The "token" parameter must be a string.');return r.classList.contains(t)}hasClass(e){return ft.hasClass(this,e)}static classLength(e){return ft._preElem(e,"classLength").classList.length}classLength(){return ft.classLength(this)}static classList(e){return ft._preElem(e,"classList").classList.values().toArray()}classList(){return ft.classList(this)}static tagName(e){return ft._preElem(e,"tagName").tagName}tagName(){return ft.tagName(this)}static id(e){return ft._preElem(e,"id").id}get id(){return ft.id(this)}set id(e){ft.setAttr(this,"id",e)}static toBigInt(e){const t=ft._preElem(e,"toBigInt"),r=t.textContent?.trim();let n=null;try{n=BigInt(r??"")}catch{n=null}return n}toBigInt(){return ft.toBigInt(this)}static setBigInt(e,t){if("bigint"!=typeof t)throw new Error("Value is not a valid BigInt.");const r=t.toString();return ft._preElems(e,"setBigInt").forEach(e=>e.textContent=r),e}setBigInt(e){return ft.setBigInt(this,e)}static toDate(e){const t=ft._preElem(e,"toDate"),r=t.textContent?.trim();if(!r)return null;const n=new Date(r);return Number.isNaN(n.getTime())?null:n}toDate(){return ft.toDate(this)}static setDate(e,t){if(!(t instanceof Date)||Number.isNaN(t.getTime()))throw new Error("Value is not a valid Date.");const r=t.toISOString();return ft._preElems(e,"setDate").forEach(e=>e.textContent=r),e}setDate(e){return ft.setDate(this,e)}static toJson(e){const t=ft._preElem(e,"toJson"),r=t.textContent?.trim();if(!r)return null;try{return JSON.parse(r)}catch{return null}}toJson(){return ft.toJson(this)}static setJson(e,t,r,n){const i=JSON.stringify(t,r,n);return ft._preElems(e,"setJson").forEach(e=>e.textContent=i),e}setJson(e,t,r){return ft.setJson(this,e,t,r)}static toNumber(e){const t=ft._preElem(e,"toNumber");return"string"==typeof t.textContent?parseFloat(t.textContent.trim()):null}toNumber(){return ft.toNumber(this)}static setNumber(e,t){if("number"!=typeof t)throw new Error("Value is not a valid number.");const r=t.toString();return ft._preElems(e,"setNumber").forEach(e=>e.textContent=r),e}setNumber(e){return ft.setNumber(this,e)}static toBoolean(e){const t=ft._preElem(e,"toBoolean"),r=t.textContent?.trim();return null==r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}toBoolean(){return ft.toBoolean(this)}static setBoolean(e,t){if("boolean"!=typeof t)throw new Error("Value is not a valid boolean.");const r=t.toString();return ft._preElems(e,"setBoolean").forEach(e=>e.textContent=r),e}setBoolean(e){return ft.setBoolean(this,e)}static toString(e){const t=ft._preElem(e,"toString");return"string"==typeof t.textContent?t.textContent:null}toString(){return ft.toString(this)}static setString(e,t){if("string"!=typeof t)throw new Error("Value is not a valid string.");return ft._preElems(e,"setString").forEach(e=>e.textContent=t),e}setString(e){return ft.setString(this,e)}static text(e){return ft._preElem(e,"text").textContent}text(){return ft.text(this)}static setText(e,t){const r=null!=t?String(t):"";return ft._preElems(e,"setText").forEach(e=>e.textContent=r),e}setText(e){return ft.setText(this,e)}static empty(e){return ft._preElems(e,"empty").forEach(e=>e.textContent=""),e}empty(){return ft.empty(this)}static html(e,t){return ft._preElem(e,"html").getHTML(t)}html(e){return ft.html(this,e)}static setHtml(e,t){if("string"!=typeof t)throw new Error("Value is not a valid string.");return ft._preElems(e,"setHtml").forEach(e=>e.innerHTML=t),e}setHtml(e){return ft.setHtml(this,e)}static _valHooks={option:{get:e=>{const t=e.getAttribute("value");return null!=t?t:e.textContent}},select:{get:e=>{const t=e.options,r=e.selectedIndex,n="select-one"===e.type,i=n?r+1:t.length,o=[];let s=r<0?i:n?r:0;for(;s<i;s++){const e=t[s],i=e.parentNode;if((e.selected||s===r)&&!e.disabled&&(!i||!i.disabled||"OPTGROUP"!==i.tagName)){const t=ft._valHooks.option.get(e);if(n)return t;o.push(t)}}return o},set:(e,t)=>{const r=e.options,n=Array.isArray(t)?t.map(String):[String(t)];let i=!1;for(let e=0;e<r.length;e++){const t=r[e],o=ft._valHooks.option.get(t);"string"==typeof o&&(t.selected=n.includes(o))&&(i=!0)}return i||(e.selectedIndex=-1),n}},radio:{get:e=>e.checked?"on":"off",set(e,t){if("boolean"==typeof t){const r=e.closest("label");return t&&r&&r.querySelectorAll('input[type="radio"]').forEach(t=>{t instanceof HTMLInputElement&&t!==e&&(t.checked=!1)}),e.checked=t,t}}},checkbox:{get:e=>e.checked?"on":"off",set(e,t){if("boolean"==typeof t)return e.checked=t,t}}};static setVal(e,t){return ft._preInputElems(e,"setVal").forEach(e=>{if(1!==e.nodeType)return;let r="function"==typeof t?t(e,ft.val(e)):t;null==r?r="":"number"==typeof r?r=String(r):Array.isArray(r)&&(r=((e,t)=>{const r=[];for(let n=0;n<e.length;n++)r.push(t(e[n]));return r})(r,e=>null==e?"":String(e)));const n=ft._valHooks[e.type]||ft._valHooks[e.nodeName.toLowerCase()];if(!n||"function"!=typeof n.set||void 0===n.set(e,r,"value")){if("string"!=typeof r&&"boolean"!=typeof r)throw new Error(`Invalid setValue "${typeof r}" value.`);"string"==typeof r&&(e.value=r)}}),e}setVal(e){return ft.setVal(this,e)}static _valTypes={string:e=>e.value,date:e=>e.valueAsDate,number:e=>e.valueAsNumber};static _getValByType(e,t,r){if("string"!=typeof t)throw new TypeError('The "type" must be a string.');if("string"!=typeof r)throw new TypeError('The "where" must be a string.');if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new Error(`Provided element is not an HTMLInputElement in ${r}().`);if("function"!=typeof ft._valTypes[t])throw new Error(`No handler found for type "${t}" in ${r}().`);return ft._valTypes[t](e)}static _val(e,t,r){const n=ft._preInputElem(e,t),i=ft._valHooks[n.type]||ft._valHooks[n.nodeName.toLowerCase()];if(i&&"function"==typeof i.get){const e=i.get(n,"value",r);if(void 0!==e)return"string"==typeof e?e.replace(/\r/g,""):e}return ft._getValByType(n,r,t)}_val(e,t){return ft._val(this,e,t)}static val(e){return ft._val(e,"val","string")}val(){return ft.val(this)}static valTxt(e){const t=ft._val(e,"valTxt","string");if("string"!=typeof t&&null!==t)throw new Error("Value is not a valid string.");return null==t?"":"string"==typeof t?t.replace(/\r/g,""):t}valTxt(){return ft.valTxt(this)}static _valArr(e,t,r){const n=ft._val(e,t,r);if(!Array.isArray(n))throw new Error(`Value expected an array but got ${typeof n}.`);return n}_valArr(e,t){return ft._valArr(this,e,t)}static valArr(e){return ft._valArr(e,"valArr","string")}valArr(){return ft.valArr(this)}static valNb(e){if(!(ft._preInputElem(e,"valNb")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const t=ft._val(e,"valNb","number");if(Number.isNaN(t))throw new Error("Value is not a valid number.");return t}valNb(){return ft.valNb(this)}static valDate(e){if(!(ft._preInputElem(e,"valDate")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const t=ft._val(e,"valDate","date");if(!(t instanceof Date))throw new Error("Value is not a valid date.");return t}valDate(){return ft.valDate(this)}static valBool(e){const t=ft._preInputElem(e,"valBool");if(!(t instanceof HTMLInputElement))throw new Error("Element must be an input element.");return"on"===ft.val(t)}valBool(){return ft.valBool(this)}static listenForPaste(e,{onFilePaste:t,onTextPaste:r}={}){if(void 0!==t&&"function"!=typeof t)throw new TypeError("onFilePaste must be a function.");if(void 0!==r&&"function"!=typeof r)throw new TypeError("onTextPaste must be a function.");const n=e=>{if(!(e instanceof ClipboardEvent))return;const n=e.clipboardData?.items||[];for(const e of n)if("file"===e.kind){if("function"==typeof t){const r=e.getAsFile();r&&t(e,r)}}else"string"===e.kind&&"function"==typeof r&&e.getAsString(t=>r(e,t))};return ft._preElemsWithDoc(e,"listenForPaste").forEach(e=>ft.on(e,"paste",n)),n}listenForPaste({onFilePaste:e,onTextPaste:t}={}){return ft.listenForPaste(this,{onFilePaste:e,onTextPaste:t})}static hasEventListener(e,t){const r=ft._preEventTargetElem(e,"hasEventListener");if(!ct.has(r))return!1;const n=ct.get(r);return!!(n&&Array.isArray(n[t])&&n[t].length>0)}hasEventListener(e){return ft.hasEventListener(this,e)}static hasExactEventListener(e,t,r){const n=ft._preEventTargetElem(e,"hasExactEventListener");if("function"!=typeof r)throw new TypeError('The "handler" must be a function.');if(!ct.has(n))return!1;const i=ct.get(n);return!(!i||!Array.isArray(i[t]))&&i[t].some(e=>e.handler===r)}hasExactEventListener(e,t){return ft.hasExactEventListener(this,e,t)}static hover(e,t,r,n){return ft.on(e,"mouseenter",t,n),ft.on(e,"mouseleave",r||t,n),e}hover(e,t,r){return ft.hover(this,e,t,r)}static on(e,t,r,n){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const i of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof i)throw new TypeError("The event name must be a string.");ft._preEventTargetElems(e,"on").forEach(e=>{e.addEventListener(i,r,n),ct.has(e)||ct.set(e,{});const t=ct.get(e);t&&(Array.isArray(t[i])||(t[i]=[]),t[i].push({handler:r,options:n}))})}return e}on(e,t,r){return ft.on(this,e,t,r)}static once(e,t,r,n={}){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const i of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof i)throw new TypeError("The event name must be a string.");ft._preEventTargetElems(e,"once").forEach(e=>{const t=n=>{ft.off(e,i,t),"function"==typeof r&&r(n)};ft.on(e,i,t,"boolean"==typeof n?n:{...n,once:!0})})}return e}once(e,t,r={}){return ft.once(this,e,t,r)}static off(e,t,r,n){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const i of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof i)throw new TypeError("The event name must be a string.");ft._preEventTargetElems(e,"off").forEach(e=>{e.removeEventListener(i,r,n);const t=ct.get(e);t&&t[i]&&(t[i]=t[i].filter(e=>e.handler!==r),0===t[i].length&&delete t[i])})}return e}off(e,t,r){return ft.off(this,e,t,r)}static offAll(e,t){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const r of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof r)throw new TypeError("The event name must be a string.");ft._preEventTargetElems(e,"offAll").forEach(e=>{const t=ct.get(e);if(t&&t[r]){for(const n of t[r])e.removeEventListener(r,n.handler,n.options);delete t[r]}})}return e}offAll(e){return ft.offAll(this,e)}static offAllTypes(e,t=null){if(null!==t&&"function"!=typeof t)throw new TypeError('The "filterFn" must be a function.');return ft._preEventTargetElems(e,"offAllTypes").forEach(e=>{const r=ct.get(e);if(r){for(const n in r)for(const i of r[n])("function"!=typeof t||t(i.handler,n))&&e.removeEventListener(n,i.handler,i.options);ct.delete(e)}}),e}offAllTypes(e=null){return ft.offAllTypes(this,e)}static trigger(e,t,r={}){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const n of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof n)throw new TypeError("The event name must be a string.");ft._preEventTargetElems(e,"trigger").forEach(e=>{const t=r instanceof Event||r instanceof CustomEvent?r:new CustomEvent(n,{bubbles:!0,cancelable:!0,detail:r});e.dispatchEvent(t)})}return e}trigger(e,t={}){return ft.trigger(this,e,t)}static#pe={for:"htmlFor",class:"className"};static propFix=new Proxy(ft.#pe,{set:(e,t,r)=>(e[t]=r,ft.attrFix[r]=t,!0)});static attrFix=Object.fromEntries(Object.entries(ft.#pe).map(([e,t])=>[t,e]));static getPropName(e){return"string"==typeof ft.propFix[e]?ft.propFix[e]:e}static getAttrName(e){return"string"==typeof ft.attrFix[e]?ft.attrFix[e]:e}static attrBigInt(e,t){const r=ft._preElem(e,"attrBigInt").getAttribute(ft.getAttrName(t));if(null==r)return null;try{return BigInt(r)}catch{return null}}attrBigInt(e){return ft.attrBigInt(this,e)}static setAttrBigInt(e,t,r){if("bigint"!=typeof r)throw new Error("Value is not a valid BigInt.");return ft.setAttr(e,t,r.toString())}setAttrBigInt(e,t){return ft.setAttrBigInt(this,e,t)}static attrDate(e,t){const r=ft._preElem(e,"attrDate").getAttribute(ft.getAttrName(t));if(!r)return null;const n=new Date(r);return Number.isNaN(n.getTime())?null:n}attrDate(e){return ft.attrDate(this,e)}static setAttrDate(e,t,r){if(!(r instanceof Date)||Number.isNaN(r.getTime()))throw new Error("Value is not a valid Date.");return ft.setAttr(e,t,r.toISOString())}setAttrDate(e,t){return ft.setAttrDate(this,e,t)}static attrJson(e,t){const r=ft._preElem(e,"attrJson").getAttribute(ft.getAttrName(t));if(!r)return null;try{return JSON.parse(r)}catch{return null}}attrJson(e){return ft.attrJson(this,e)}static setAttrJson(e,t,r,n,i){const o=JSON.stringify(r,n,i);return ft.setAttr(e,t,o)}setAttrJson(e,t,r,n){return ft.setAttrJson(this,e,t,r,n)}static attrNumber(e,t){const r=ft._preElem(e,"attrNumber").getAttribute(ft.getAttrName(t));return null!=r?parseFloat(r):null}attrNumber(e){return ft.attrNumber(this,e)}static setAttrNumber(e,t,r){if("number"!=typeof r)throw new Error("Value is not a valid number.");return ft.setAttr(e,t,r.toString())}setAttrNumber(e,t){return ft.setAttrNumber(this,e,t)}static attrBoolean(e,t){const r=ft._preElem(e,"attrBoolean").getAttribute(ft.getAttrName(t));return null===r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}attrBoolean(e){return ft.attrBoolean(this,e)}static setAttrBoolean(e,t,r){if("boolean"!=typeof r)throw new Error("Value is not a valid boolean.");return ft.setAttr(e,t,r.toString())}setAttrBoolean(e,t){return ft.setAttrBoolean(this,e,t)}static attrString(e,t){const r=ft._preElem(e,"attrString").getAttribute(ft.getAttrName(t));return"string"==typeof r?r:null}attrString(e){return ft.attrString(this,e)}static setAttrString(e,t,r){if("string"!=typeof r)throw new Error("Value is not a valid string.");return ft.setAttr(e,t,r)}setAttrString(e,t){return ft.setAttrString(this,e,t)}static attr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return ft._preElem(e,"attr").getAttribute(ft.getAttrName(t))}attr(e){return ft.attr(this,e)}static setAttr(e,t,r=null){const n=ft._preElems(e,"setAttr");if("object"==typeof t&&null!==t)return Object.entries(t).forEach(([e,t])=>n.forEach(r=>{null===t?r.removeAttribute(ft.getAttrName(e)):r.setAttribute(ft.getAttrName(e),String(t))})),e;if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return n.forEach(e=>{null===r?e.removeAttribute(ft.getAttrName(t)):e.setAttribute(ft.getAttrName(t),String(r))}),e}setAttr(e,t){return ft.setAttr(this,e,t)}static removeAttr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return ft._preElems(e,"removeAttr").forEach(e=>e.removeAttribute(ft.getAttrName(t))),e}removeAttr(e){return ft.removeAttr(this,e)}static hasAttr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return ft._preElem(e,"hasAttr").hasAttribute(ft.getAttrName(t))}hasAttr(e){return ft.hasAttr(this,e)}static hasProp(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return!!ft._preElem(e,"hasProp")[ft.getPropName(t)]}hasProp(e){return ft.hasProp(this,e)}static addProp(e,...t){return ft._preElems(e,"addProp").forEach(e=>{t.forEach(t=>{if("string"!=typeof t)throw new TypeError('Each "name" must be a string.');e[ft.getPropName(t)]=!0})}),e}addProp(...e){return ft.addProp(this,...e)}static removeProp(e,...t){return ft._preElems(e,"removeProp").forEach(e=>{t.forEach(t=>{if("string"!=typeof t)throw new TypeError('Each "name" must be a string.');e[ft.getPropName(t)]=!1})}),e}removeProp(...e){return ft.removeProp(this,...e)}static toggleProp(e,t,r){const n=ft._preElems(e,"toggleProp");if(void 0!==r&&"boolean"!=typeof r)throw new TypeError('The "force" must be a boolean.');return(Array.isArray(t)?t:[t]).forEach(e=>{if("string"!=typeof e)throw new TypeError("Each property name must be a string.");n.forEach(t=>{(void 0===r?!t[ft.getPropName(e)]:r)?ft.addProp(t,e):ft.removeProp(t,e)})}),e}toggleProp(e,t){return ft.toggleProp(this,e,t)}static prop(e,t){if("string"!=typeof t)throw new TypeError('Invalid arguments passed to prop(). Expected string for "name".');return ft._preElem(e,"prop")[t]}prop(e){return ft.prop(this,e)}static setProp(e,t,r){if("string"!=typeof t||""===t.trim())throw new Error("Property name must be a non-empty string.");return ft._preElems(e,"setProp").forEach(e=>{e[t]=r}),e}setProp(e,t){return ft.setProp(this,e,t)}static remove(e){return ft._preElems(e,"remove").forEach(e=>e.remove()),e}remove(){return ft.remove(this)}static index(e,t=null){const r=ft._preElem(e,"index");if(!r)return-1;if(!t)return Array.prototype.indexOf.call(r.parentNode?.children||[],r);if(t){const e="string"==typeof t?document.querySelectorAll(t):ft._preElems(t,"index");return Array.prototype.indexOf.call(e,r)}return-1}index(e){return ft.index(this,e)}static _getCustomRect(e,t){const r={height:0,width:0,x:0,y:0,bottom:0,left:0,right:0,top:0,toJSON:function(){throw new Error("Function not implemented.")}};for(const t in e)"number"==typeof e[t]&&(r[t]=e[t]);if("object"!=typeof t||null===t||Array.isArray(t))throw new Error("extraRect must be a non-null object.");const{height:n=0,width:i=0,top:o=0,bottom:s=0,left:a=0,right:l=0}=t;if("number"!=typeof n)throw new Error("extraRect.height must be a number.");if("number"!=typeof i)throw new Error("extraRect.width must be a number.");if("number"!=typeof o)throw new Error("extraRect.top must be a number.");if("number"!=typeof s)throw new Error("extraRect.bottom must be a number.");if("number"!=typeof a)throw new Error("extraRect.left must be a number.");if("number"!=typeof l)throw new Error("extraRect.right must be a number.");return r.height+=n,r.width+=i,r.top+=o,r.bottom+=s,r.left+=a,r.right+=l,r}static isCollWith(e,t,r={}){const n=ft._getCustomRect(ft._preElem(e,"isCollWith").getBoundingClientRect(),r),i=ft._preElem(t,"isCollWith").getBoundingClientRect();return it(n,i)}isCollWith(e,t){return ft.isCollWith(this,e,t)}static isCollPerfWith(e,t,r={}){const n=ft._getCustomRect(ft._preElem(e,"isCollPerfWith").getBoundingClientRect(),r),i=ft._preElem(t,"isCollPerfWith").getBoundingClientRect();return ot(n,i)}isCollPerfWith(e,t){return ft.isCollPerfWith(this,e,t)}static _isCollWithLock(e,t,r,n,i){const o=pt[i];if(e)return o.has(n)||o.set(n,!0),!0;if(o.has(n)){let e=!1;switch(i){case"top":e=st(t,r);break;case"bottom":e=at(t,r);break;case"left":e=lt(t,r);break;case"right":e=ut(t,r)}return e&&o.delete(n),o.has(n)}return!1}static isCollWithLock(e,t,r,n={}){const i=ft._preElem(e,"isCollWithLock"),o=ft._preElem(t,"isCollWithLock"),s=ft._getCustomRect(i.getBoundingClientRect(),n),a=o.getBoundingClientRect(),l=it(s,a);return ft._isCollWithLock(l,s,a,i,r)}isCollWithLock(e,t,r){return ft.isCollWithLock(this,e,t,r)}static isCollPerfWithLock(e,t,r,n={}){const i=ft._preElem(e,"isCollPerfWithLock"),o=ft._preElem(t,"isCollPerfWithLock"),s=ft._getCustomRect(i.getBoundingClientRect(),n),a=o.getBoundingClientRect(),l=ot(s,a);return ft._isCollWithLock(l,s,a,i,r)}isCollPerfWithLock(e,t,r){return ft.isCollPerfWithLock(this,e,t,r)}static resetCollLock(e){const t=ft._preElem(e,"resetCollLock");let r=!1;for(const e of["top","bottom","left","right"])pt[e].has(t)&&(pt[e].delete(t),r=!0);return r}resetCollLock(){return ft.resetCollLock(this)}static resetCollLockDir(e,t){const r=ft._preElem(e,"resetCollLockDir"),n=pt[t];return!!n.has(r)&&(n.delete(r),!0)}resetCollLockDir(e){return ft.resetCollLockDir(this,e)}static isInViewport(e){const t=ft._preElem(e,"isInViewport");if(!t.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=ft.offset(t).top,n=r+ft.outerHeight(t),i=ft.scrollTop(window),o=i+ft.height(window);return n>i&&r<o}isInViewport(){return ft.isInViewport(this)}static isScrolledIntoView(e){const t=ft._preElem(e,"isScrolledIntoView");if(!t.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=ft.scrollTop(window),n=r+ft.height(window),i=ft.offset(t).top;return i+ft.height(t)<=n&&i>=r}isScrolledIntoView(){return ft.isScrolledIntoView(this)}static isInContainer(e,t){const r=ft._preElem(e,"isInContainer"),n=ft._preElem(t,"isInContainer");if(!r.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const i=r.getBoundingClientRect(),o=n.getBoundingClientRect(),s=i.bottom>o.top&&i.top<o.bottom,a=i.right>o.left&&i.left<o.right;return s&&a}isInContainer(e){return ft.isInContainer(this,e)}static isFullyInContainer(e,t){const r=ft._preElem(e,"isScrolledIntoView"),n=ft._preElem(t,"isInContainer");if(!r.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const i=r.getBoundingClientRect(),o=n.getBoundingClientRect();return i.top>=o.top&&i.bottom<=o.bottom&&i.left>=o.left&&i.right<=o.right}isFullyInContainer(e){return ft.isFullyInContainer(this,e)}static hasScroll(e){const t=ft._preElem(e,"hasScroll");return{v:t.scrollHeight>t.clientHeight,h:t.scrollWidth>t.clientWidth}}hasScroll(){return ft.hasScroll(this)}}const gt=ft;class yt{static Utils={...t,TinyHtml:gt};#fe=!0;#ge=!1;#ye=0;#we=0;#be=!0;#ve=!1;#Ee=!1;#Te=!1;#Se=!1;#xe=!1;#Ce=!1;#Ae=null;#Ie=[];#ke=null;#Me={start:!1,end:!1,collide:!1,move:!1};#Ne=null;#O;#Le="drag-hidden";#_e="dragging";#De="drag-active";#je="jail-drag-active";#Re="jail-drag-disabled";#He="dragging-collision";#Pe=9999;constructor(e,t={}){if(!(e instanceof HTMLElement))throw new Error("TinyDragger requires a valid target HTMLElement to initialize.");if(this.#O=e,void 0!==t.jail&&!(t.jail instanceof HTMLElement))throw new Error('The "jail" option must be an HTMLElement if provided.');if(void 0!==t.defaultZIndex&&this.setDefaultZIndex(t.defaultZIndex),void 0!==t.vibration&&!1!==t.vibration&&!p(t.vibration))throw new Error('The "vibration" option must be an object or false.');const r=(e,t)=>{if(void 0!==e&&"boolean"!=typeof e)throw new Error(`The "${t}" option must be a boolean.`)},n=(e,t)=>{if(void 0!==e&&"string"!=typeof e)throw new Error(`The "${t}" option must be a string.`)};r(t.mirrorElem,"mirrorElem"),r(t.collisionByMouse,"collisionByMouse"),r(t.lockInsideJail,"lockInsideJail"),r(t.dropInJailOnly,"dropInJailOnly"),r(t.revertOnDrop,"revertOnDrop"),r(t.multiCollision,"multiCollision"),n(t.classDragging,"classDragging"),n(t.classBodyDragging,"classBodyDragging"),n(t.classJailDragging,"classJailDragging"),n(t.classJailDragDisabled,"classJailDragDisabled"),n(t.classDragCollision,"classDragCollision"),n(t.classHidden,"classHidden"),t.jail instanceof HTMLElement&&(this.#Ne=t.jail),this.#Me=Object.assign({start:!1,end:!1,collide:!1,move:!1},p(t.vibration)?t.vibration:{}),"string"==typeof t.classDragging&&(this.#_e=t.classDragging),"string"==typeof t.classBodyDragging&&(this.#De=t.classBodyDragging),"string"==typeof t.classJailDragging&&(this.#je=t.classJailDragging),"string"==typeof t.classJailDragDisabled&&(this.#Re=t.classJailDragDisabled),"string"==typeof t.classHidden&&(this.#Le=t.classHidden),"string"==typeof t.classDragCollision&&(this.#He=t.classDragCollision),"boolean"==typeof t.collisionByMouse&&(this.#xe=t.collisionByMouse),"boolean"==typeof t.mirrorElem&&(this.#be=t.mirrorElem),"boolean"==typeof t.revertOnDrop&&(this.#Te=t.revertOnDrop),"boolean"==typeof t.lockInsideJail&&(this.#Ee=t.lockInsideJail),"boolean"==typeof t.dropInJailOnly&&(this.#Ce=t.dropInJailOnly),"boolean"==typeof t.multiCollision&&(this.#ve=t.multiCollision),this._onMouseDown=this.#$e.bind(this),this._onMouseMove=this.#Oe.bind(this),this._onMouseUp=this.#Fe.bind(this),this._onTouchStart=e=>this.#$e(e.touches[0]),this._onTouchMove=e=>this.#Oe(e.touches[0]),this._onTouchEnd=e=>this.#Fe(e.changedTouches[0]),this.#O.addEventListener("mousedown",this._onMouseDown),this.#O.addEventListener("touchstart",this._onTouchStart,{passive:!1})}enable(){this.#Be(),this.#Ne&&this.#Ne.classList.add(this.#Re),this.#fe=!0}disable(){this.#Ne&&this.#Ne.classList.remove(this.#Re),this.#fe=!1}addCollidable(e){if(this.#Be(),!(e instanceof HTMLElement))throw new Error("addCollidable expects an HTMLElement as argument.");this.#Ie.includes(e)||this.#Ie.push(e)}removeCollidable(e){if(this.#Be(),!(e instanceof HTMLElement))throw new Error("removeCollidable expects an HTMLElement as argument.");this.#Ie=this.#Ie.filter(t=>t!==e)}setVibrationPattern({startPattern:e=!1,endPattern:t=!1,collidePattern:r=!1,movePattern:n=!1}={}){this.#Be();const i=e=>!1===e||Array.isArray(e)&&e.every(e=>"number"==typeof e);if(!i(e))throw new Error('Invalid "startPattern": must be false or an array of numbers.');if(!i(t))throw new Error('Invalid "endPattern": must be false or an array of numbers.');if(!i(r))throw new Error('Invalid "collidePattern": must be false or an array of numbers.');if(!i(n))throw new Error('Invalid "movePattern": must be false or an array of numbers.');this.#Me={start:e,end:t,collide:r,move:n}}disableVibration(){this.#Be(),this.#Me={start:!1,end:!1,collide:!1,move:!1}}getOffset(e){if(this.#Be(),!(e instanceof MouseEvent||e instanceof Touch)||"number"!=typeof e.clientX||"number"!=typeof e.clientY)throw new Error("getOffset expects an event with valid clientX and clientY coordinates.");const t=this.#O.getBoundingClientRect(),{left:r,top:n}=gt.borderWidth(this.#O);return{x:e.clientX-t.left+r,y:e.clientY-t.top+n}}#$e(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#ge||!this.#fe||!this.#O.parentElement)return;if(this.#be){const e=this.#O.cloneNode(!0);if(!(e instanceof HTMLElement))throw new Error("[TinyDragger] INVALID DRAG ELEMENT!");this.#ke=e}else this.#ke=this.#O;this.#Se=!0;const t=this.#O.getBoundingClientRect();Object.assign(this.#ke.style,{position:"absolute",pointerEvents:"none",left:`${this.#O.offsetLeft}px`,top:`${this.#O.offsetTop}px`,width:`${t.width}px`,height:`${t.height}px`,zIndex:this.#Pe}),this.#be&&(this.#O.classList.add(this.#Le),this.#O.parentElement.appendChild(this.#ke));const{x:r,y:n}=this.getOffset(e);this.#we=r,this.#ye=n,this.#ke.classList.add(this.#_e),document.body.classList.add(this.#De),this.#Ne&&this.#Ne.classList.add(this.#je),document.addEventListener("mousemove",this._onMouseMove),document.addEventListener("mouseup",this._onMouseUp),document.addEventListener("touchmove",this._onTouchMove,{passive:!1}),document.addEventListener("touchend",this._onTouchEnd),navigator.vibrate&&Array.isArray(this.#Me.start)&&navigator.vibrate(this.#Me.start),this.checkDragCollision(e),this.#ze("drag")}#We=[];#qe(e){e&&(e.classList.add(this.#He),this.#We.push(e))}#Ve(){for(;this.#We.length>0;){const e=this.#We.shift();e&&e.classList.remove(this.#He)}this.#Ae&&this.#Ae.classList.remove(this.#He)}checkDragCollision(e){const{collidedElements:t}=this.execCollision(e),r=t[0]||null;this.#Ae&&!t.includes(this.#Ae)&&this.#Ve(),t.forEach(e=>this.#qe(e)),this.#Ie.forEach(e=>{t.includes(e)||e.classList.remove(this.#He)}),navigator.vibrate&&Array.isArray(this.#Me.collide)&&t.length>0&&navigator.vibrate(this.#Me.collide),this.#Ae=r}#Oe(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#ge||!this.#Se||!this.#fe||!this.#ke)return;const t=(this.#ke.offsetParent||document.body).getBoundingClientRect();let r=e.clientX-t.left-this.#we,n=e.clientY-t.top-this.#ye;if(this.#Ee&&this.#Ne){const e=this.#Ne.getBoundingClientRect(),i=this.#ke.getBoundingClientRect(),o=e.left-t.left,s=e.top-t.top,{x:a,y:l}=gt.borderWidth(this.#Ne),u=o+e.width-i.width-l,c=s+e.height-i.height-a;r=Math.max(o,Math.min(r,u)),n=Math.max(s,Math.min(n,c))}this.#ke.style.position="absolute",this.#ke.style.left=`${r}px`,this.#ke.style.top=`${n}px`,navigator.vibrate&&Array.isArray(this.#Me.move)&&navigator.vibrate(this.#Me.move),this.checkDragCollision(e),this.#ze("dragging")}execCollision(e){if(this.#ge||!this.#ke)return{inJail:!1,collidedElements:[]};let t=[],r=!0;const n=this.#Ne?.getBoundingClientRect();if(this.#xe){const i=e.clientX,o=e.clientY;this.#Ce&&this.#Ne&&n&&(r=i>=n.left&&i<=n.right&&o>=n.top&&o<=n.bottom),t=r?this.#ve?this.getAllCollidedElements(i,o):[this.getCollidedElement(i,o)].filter(Boolean):[]}else{const e=this.#ke.getBoundingClientRect();this.#Ce&&this.#Ne&&n&&(r=e.left>=n.left&&e.right<=n.right&&e.top>=n.top&&e.bottom<=n.bottom),t=r?this.#ve?this.getAllCollidedElementsByRect(e):[this.getCollidedElementByRect(e)].filter(Boolean):[]}return{inJail:r,collidedElements:t}}#Fe(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#ge||!this.#Se)return;if(this.#Se=!1,!this.#ke)return;this.#O.classList.remove(this.#_e),document.body.classList.remove(this.#De),this.#Ne&&this.#Ne.classList.remove(this.#je),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd);const{collidedElements:t}=this.execCollision(e);navigator.vibrate&&Array.isArray(this.#Me.end)&&navigator.vibrate(this.#Me.end);const r=this.#ke.style.left,n=this.#ke.style.top;this.#ke&&(this.#be?this.#ke.remove():Object.assign(this.#ke.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#ke=null),this.#Ae&&this.#Ve(),this.#Ae=null,this.#be&&this.#O.classList.remove(this.#Le),this.#Te||(this.#O.style.left=r,this.#O.style.top=n);const i=new CustomEvent("drop",{detail:{targets:t,first:t[0]||null}});this.#O.dispatchEvent(i)}#Ke(e,t){const r=e.getBoundingClientRect();return!(t.right<r.left||t.left>r.right||t.bottom<r.top||t.top>r.bottom)}getAllCollidedElementsByRect(e){if(this.#Be(),!(e instanceof DOMRect)||"number"!=typeof e.left||"number"!=typeof e.right||"number"!=typeof e.top||"number"!=typeof e.bottom)throw new Error("getCollidedElementByRect expects a valid DOMRect object.");return this.#Ie.filter(t=>this.#Ke(t,e))}getCollidedElementByRect(e){if(this.#Be(),!(e instanceof DOMRect)||"number"!=typeof e.left||"number"!=typeof e.right||"number"!=typeof e.top||"number"!=typeof e.bottom)throw new Error("getCollidedElementByRect expects a valid DOMRect object.");return this.#Ie.find(t=>this.#Ke(t,e))||null}#Je(e,t,r){const n=e.getBoundingClientRect();return t>=n.left&&t<=n.right&&r>=n.top&&r<=n.bottom}getAllCollidedElements(e,t){if(this.#Be(),"number"!=typeof e||"number"!=typeof t)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#Ie.filter(r=>this.#Je(r,e,t))}getCollidedElement(e,t){if(this.#Be(),"number"!=typeof e||"number"!=typeof t)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#Ie.find(r=>this.#Je(r,e,t))||null}#ze(e){const t=new CustomEvent(e);this.#O.dispatchEvent(t)}getDragging(){return this.#Se}getLockInsideJail(){return this.#Ee}setLockInsideJail(e){if("boolean"!=typeof e)throw new Error("lockInsideJail must be a boolean.");this.#Ee=e}getRevertOnDrop(){return this.#Te}setRevertOnDrop(e){if("boolean"!=typeof e)throw new Error("revertOnDrop must be a boolean.");this.#Te=e}getCollisionByMouse(){return this.#xe}setCollisionByMouse(e){if("boolean"!=typeof e)throw new Error("collisionByMouse must be a boolean.");this.#xe=e}getDropInJailOnly(){return this.#Ce}setDropInJailOnly(e){if("boolean"!=typeof e)throw new Error("dropInJailOnly must be a boolean.");this.#Ce=e}getDefaultZIndex(){return this.#Pe}setDefaultZIndex(e){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("Z-index must be a finite number.");this.#Pe=e}isMirrorEnabled(){return this.#be}setMirrorEnabled(e){if("boolean"!=typeof e)throw new TypeError("Mirror setting must be a boolean.");this.#be=e}getTarget(){return this.#O}getJail(){return this.#Ne}getDragProxy(){return this.#ke}getLastCollision(){return this.#Ae}getCollidables(){return[...this.#Ie]}getDragHiddenClass(){return this.#Le}getClassDragging(){return this.#_e}getClassBodyDragging(){return this.#De}getClassJailDragging(){return this.#je}getClassJailDragDisabled(){return this.#Re}getClassDragCollision(){return this.#He}getVibrations(){return{...this.#Me}}getStartVibration(){return this.#Me.start}getEndVibration(){return this.#Me.end}getCollideVibration(){return this.#Me.collide}getMoveVibration(){return this.#Me.move}isEnabled(){return this.#fe}#Be(){if(this.#ge)throw new Error("This TinyDragger instance has been destroyed and can no longer be used.")}destroy(){this.#ge||(this.disable(),this.#O.removeEventListener("mousedown",this._onMouseDown),this.#O.removeEventListener("touchstart",this._onTouchStart),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd),this.#Ae&&this.#Ve(),this.#ke&&(this.#be?this.#ke.remove():Object.assign(this.#ke.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#ke=null),this.#Ie=[],this.#Se=!1,this.#Ae=null,this.#be&&this.#O.classList.remove(this.#Le),this.#O.classList.remove(this.#_e),document.body.classList.remove(this.#De),this.#Ne&&this.#Ne.classList.remove(this.#je,this.#Re),this.#ge=!0)}}const wt=yt,bt=class{#Ue=[];#Ge=!1;#Ye=!1;#Xe=[];#Qe(){this.#Ge&&Promise.all(this.#Xe).then(()=>{this.#Ye=!0,this.#Ze(!1)}).catch(e=>{console.error("[TinyDomReadyManager] Promise rejected:",e)})}#Ze(e){this.#Ue.filter(t=>t.domOnly===e).sort((e,t)=>t.priority-e.priority).forEach(e=>this.#et(e)),this.#Ue=this.#Ue.filter(t=>!(t.once&&(!e||t.domOnly)))}#et(e){if("function"==typeof e.filter)try{if(!e.filter())return}catch(e){return void console.warn("[TinyDomReadyManager] Filter error:",e)}try{e.fn()}catch(e){console.error("[TinyDomReadyManager] Handler error:",e)}}_markDomReady(){this.#Ge=!0,this.#Ze(!0),this.#Qe()}init(){if(this.#Ge)throw new Error("[TinyDomReadyManager] init() has already been called.");"interactive"===document.readyState||"complete"===document.readyState?this._markDomReady():document.addEventListener("DOMContentLoaded",()=>this._markDomReady())}addPromise(e){if(!(e instanceof Promise))throw new TypeError("[TinyDomReadyManager] promise must be a valid Promise.");this.#Ye||(this.#Xe.push(e),this.#Ge&&this.#Qe())}onReady(e,{once:t=!0,priority:r=0,filter:n=null,domOnly:i=!1}={}){if("function"!=typeof e)throw new TypeError("[TinyDomReadyManager] fn must be a function.");const o={fn:e,once:t,priority:r,filter:n,domOnly:i};if(i&&this.#Ge)return this.#et(o),void(t||this.#Ue.push(o));!i&&this.#Ye?this.#et(o):this.#Ue.push(o)}isReady(){return this.#Ye}isDomReady(){return this.#Ge}},vt=class{#tt=!1;#rt=!1;#nt=null;#it=100;#ot=null;#st;constructor({audio:e=null,defaultIcon:t=null,bodyLimit:r=100,defaultOnClick:n=function(e){e.preventDefault(),window.focus&&window.focus(),this.close()}}={}){if(!(e instanceof HTMLAudioElement)&&"string"!=typeof e&&null!==e)throw new TypeError("audio must be an instance of HTMLAudioElement or null.");if(null!==t&&"string"!=typeof t)throw new TypeError("defaultIcon must be a string or null.");if(!Number.isFinite(r)||r<0)throw new TypeError("bodyLimit must be a non-negative number.");if("function"!=typeof n)throw new TypeError("defaultOnClick must be a function.");this.#nt="string"!=typeof e?e:new Audio(e),this.#ot=t,this.#it=r,this.#st=n}requestPerm(){const e=this;return new Promise((t,r)=>{e.isCompatible()?"default"===Notification.permission?Notification.requestPermission().then(r=>{this.#rt=!0,e.#tt="granted"===r,t(e.#tt)}).catch(r):(this.#rt=!0,e.#tt="granted"===Notification.permission,t(e.#tt)):(this.#rt=!0,e.#tt=!1,t(!1))})}isCompatible(){return"Notification"in window}send(e,t={}){if(!this.#rt)throw new Error("You must call requestPerm() before sending a notification.");if("string"!=typeof e)throw new TypeError("title must be a string.");if("object"!=typeof t||null===t)throw new TypeError("config must be a non-null object.");if(!this.#tt)return null;const{icon:r=this.#ot||void 0,vibrate:n=[200,100,200]}=t,i={...t};"string"==typeof r&&(i.icon=r),Array.isArray(n)&&(i.vibrate=n),"string"==typeof i.body&&(i.body=W(i.body,this.#it));const o=new Notification(e,i);return o.addEventListener("show",()=>{this.#nt instanceof HTMLAudioElement&&(this.#nt.currentTime=0,this.#nt.play().catch(e=>console.error(e)))}),"function"==typeof this.#st&&o.addEventListener("click",this.#st),o}wasPermissionRequested(){return this.#rt}isAllowed(){return this.#tt}getAudio(){return this.#nt}setAudio(e){if(!(e instanceof HTMLAudioElement)&&"string"!=typeof e&&null!==e)throw new TypeError("sound must be an instance of HTMLAudioElement or null.");this.#nt="string"!=typeof e?e:new Audio(e)}getBodyLimit(){return this.#it}setBodyLimit(e){if(!Number.isFinite(e)||e<0)throw new TypeError("bodyLimit must be a non-negative number.");this.#it=e}getDefaultAvatar(){return this.#ot}setDefaultAvatar(e){if("string"!=typeof e&&null!==e)throw new TypeError("defaultIcon must be a string or null.");this.#ot=e}getDefaultOnClick(){return this.#st}setDefaultOnClick(e){if("function"!=typeof e)throw new TypeError("defaultOnClick must be a function.");this.#st=e}},Et=new Map;class Tt extends Error{constructor(e,t,r){super(e),this.name="MediaLoadingError",this.url=t,this.stage=r}}const St=async e=>{const t=(new TextEncoder).encode(e),r=await crypto.subtle.digest("SHA-1",t);return Array.from(new Uint8Array(r)).map(e=>e.toString(16).padStart(2,"0")).join("").substring(0,8)},xt=(e,t="image/jpeg")=>{const r=e=>{const t=URL.createObjectURL(e),r=Et.get(t);return Et.set(t,"number"==typeof r?r+1:1),t};if(e instanceof Uint8Array)return r(new Blob([e],{type:t}));if("string"==typeof e&&e.startsWith("data:")){const n=e.split(",")[1],i=atob(n),o=new Uint8Array(i.length);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return r(new Blob([o],{type:t}))}return"string"==typeof e?e:""},Ct=async e=>{if("string"!=typeof e||!e.startsWith("blob:"))return e;try{const t=await fetch(e),r=await t.blob();return await new Promise((e,t)=>{const n=new FileReader;n.onloadend=()=>e(String(n.result)),n.onerror=t,n.readAsDataURL(r)})}catch(t){return console.warn(`[TinyAudioUtils] Failed to convert Blob URL to Base64 on export: ${e}`,t),e}},At=e=>{e&&Array.isArray(e.picture)&&e.picture.forEach(e=>{if("string"==typeof e.data&&e.data.startsWith("blob:")){const t=Et.get(e.data)??0;t>1?Et.set(e.data,t-1):Et.delete(e.data),t<=1&&URL.revokeObjectURL(e.data)}})},It=(e,t)=>{const r=e=>t&&void 0===e,n=e=>r(e)||"string"==typeof e||null===e,i=(e,t)=>!!r(e)||!(!Array.isArray(e)||!e.every(t));if(!n(e.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!n(e.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!n(e.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a string or null.');if(!n(e.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(o=e.year,!r(o)&&"number"!=typeof o&&null!==o)throw new TypeError('Invalid metadata: "year" must be a number or null.');var o;if(!i(e.albumartists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "albumartists" must be an array of string.');if(!i(e.genre,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "genre" must be an array of string.');if(!i(e.label,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "label" must be an array of string.');if(!i(e.composer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "composer" must be an array of string.');if(!i(e.artists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "artists" must be an array of string.');if(!i(e.picture,e=>!(void 0!==e.description&&"string"!=typeof e.description||void 0!==e.name&&"string"!=typeof e.name||void 0!==e.type&&"string"!=typeof e.type||"string"!=typeof e.format||!(e.data instanceof Uint8Array||"string"==typeof e.data))))throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');const s=(e,t)=>{if(!r(e)){if(null==e)throw new TypeError(`Invalid metadata: "${t}" is required.`);if("object"!=typeof e)throw new TypeError(`Invalid metadata: "${t}" must be an object or null.`);if("number"!=typeof e.no&&null!==e.no)throw new TypeError(`Invalid metadata: "${t}.no" must be a number or null.`);if("number"!=typeof e.of&&null!==e.of)throw new TypeError(`Invalid metadata: "${t}.of" must be a number or null.`)}};s(e.disk,"disk"),s(e.track,"track")},kt=e=>It(e,!1),Mt=e=>It(e,!0),Nt=async(e,t)=>{if("string"!=typeof e)throw new TypeError(`Expected url to be a string, but received ${typeof e}.`);if("function"!=typeof t)throw new TypeError(`Expected parseFile to be a function, but received ${typeof t}.`);try{const r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch audio file: ${r.status} ${r.statusText}`);const n=await r.blob(),i=await t(n);if(!i||"object"!=typeof i.common)throw new TypeError('Invalid metadata: "common" property is missing or not an object.');const o=i.common;return Mt(o),{title:o?.title??null,album:o?.album??null,albumartist:o?.albumartist??null,albumartists:o?.albumartists??[],genre:o?.genre??[],label:o?.label??[],composer:o?.composer??[],year:o?.year??null,artist:o?.artist??null,artists:o?.artists??[],disk:o?.disk?{no:o.disk.no,of:o.disk.of}:{no:null,of:null},track:o?.track?{no:o.track.no,of:o.track.of}:{no:null,of:null},picture:o?.picture?.map(e=>({...e,data:xt(e.data,e.format)}))??[]}}catch(e){throw e}},Lt=async(e,t={},r={},n=e=>new Promise((e,t)=>t(new TypeError("parseFile library not found."))),i={},o="null")=>{if("string"!=typeof e&&!(e instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(i.onProgress&&"function"!=typeof i.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(i.onError&&"function"!=typeof i.onError)throw new TypeError("callbacks.onError must be a function.");let s,a="";const l=(t,r)=>{i.onProgress&&i.onProgress({event:r,status:"loading",stage:t,url:a||(e instanceof HTMLMediaElement?e.src:"unknown")})},u=(t,r)=>{i.onError&&i.onError({error:t,url:a||(e instanceof HTMLMediaElement?e.src:"unknown"),stage:r})};try{l("INITIALIZING"),"string"==typeof e?(a=e,s=new Audio(a)):(s=e,a=s.src);try{await new Promise((e,t)=>{const r=e=>l("DOWNLOADING",e),n=()=>{o(),e(void 0)},i=e=>{o(),t(new Error(`HTMLMediaElement failed to load: ${e.message||"Unknown error"}`))},o=()=>{s.removeEventListener("progress",r),s.removeEventListener("loadedmetadata",n),s.removeEventListener("error",i)};s.addEventListener("progress",r),s.addEventListener("loadedmetadata",n),s.addEventListener("error",i),s.readyState>=1&&(o(),e(void 0))}),l("METADATA_LOADED")}catch(e){throw new Tt(e instanceof Error?e.message:"UNKNOWN ERROR",a,"METADATA")}const c={id:r.id||await St(a),duration:Math.floor(1e3*s.duration),url:a,weight:r.weight??1};let h={};l("EXTRACTING_ID3");try{h=await Nt(a,n)}catch(e){u(e instanceof Error?e:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${a}. Falling back to filename.`)}const d=e=>{try{return(e.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},m={...c,...t,...h,...r,title:h.title||r.title||d(a),artist:h.artist||r.artist||("string"==typeof o?o:String(o()))};return i.onProgress&&i.onProgress({status:"success",stage:"COMPLETE",url:a}),m}catch(e){if(e instanceof Tt)throw e;{const t=new Tt(e instanceof Error?e.message:"UNKNOWN ERROR",a,"INITIALIZING");throw u(t,"INITIALIZING"),t}}},_t=class{#at;get scrollTarget(){return this.#at}#lt=null;#ut=[];get afterScrollQueueSize(){return this.#ut.length}#ct=100;#ht=new Set;#dt=new Set;#ge=!1;get destroyed(){return this.#ge}constructor(e,t=100){if(!(e instanceof Element||e instanceof Window))throw new TypeError("scrollTarget must be an Element or the Window object.");this.#at=e,this._checkTimer=this._checkTimer.bind(this),this.#at.addEventListener("scroll",this._checkTimer),this.#ct=t}_checkTimer=()=>{this.#lt&&clearTimeout(this.#lt),this.#lt=setTimeout(()=>{this.#lt=null,this.#mt()},this.#ct)};get inactivityTime(){return this.#ct}set inactivityTime(e){if("number"!=typeof e||e<=0||!Number.isFinite(e))throw new Error("inactivityTime must be a positive number in milliseconds.");this.#ct=e}#mt(){if(!this.#ge){for(const e of this.#dt)"function"==typeof e&&e();for(;this.#ut.length;){const e=this.#ut.pop();"function"==typeof e&&e()}}}doAfterScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.lastScrollTime=Date.now(),this.#ut.push(e)}onStop(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#dt.add(e)}offStop(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#dt.delete(e)}onScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#at.addEventListener("scroll",e),this.#ht.add(e)}offScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ht.has(e)&&(this.#at.removeEventListener("scroll",e),this.#ht.delete(e))}destroy(){if(!this.#ge){this.#ge=!0,this.#at.removeEventListener("scroll",this._checkTimer);for(const e of this.#ht)this.#at.removeEventListener("scroll",e);this.#ht.clear(),this.#dt.clear()}}},Dt=["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","sed","do","eiusmod","tempor","incididunt","ut","labore","et","dolore","magna","aliqua"],jt=["😂","🌈","🤖","💥","🐸","🍕","🦄","🧠","🧬","🚀","🫠","💫","🍩","👾","🎉","🥴","🐙","🧃","🪐","🎈","🧸","👻","🥳","🍭","💖","😺","🌮","🪅","🎮","🥓","🍮"],Rt=["pudding","bean","snuggle","bloop","jelly","unicorn","floof","giggle","bubble","muffin","puff","pickle","goblin","waffle","sprinkle","cupcake","fizzle","marshmallow","duckling","sock","cloud","teacup","nugget","gnome","hug","moonbean","crayon","jiggle","glitter","carrot","goober"],Ht=["wiggles","bounces","flies","splats","scoots","giggles","wigglesnacks","twirls","boops","pops","sings","hugs","floats","glows","flaps","mlems","dances","puddles","nomnoms","wigglejumps","sniffs","tumbles","slides","chirps","burps","sparkles","waddles","rambles","blinks","mews"],Pt=["fluffy","silly","yummy","squishy","wobbly","magical","tiny","sleepy","wiggly","bubbly","glittery","fuzzy","jiggly","sparkly","giggly","crunchy","goofy","soft","mushy","sweet","loopy","floaty","bonkers","chewy","ticklish","dreamy","pastel","cozy","teensy","grumbly"],$t=["Boop!","Wiggle achieved.","Oops, {noun} everywhere!","Tiny {adj} {noun}, big {adj} {noun}.","Snuggle initiated with a {adj} {noun}.","{adj} vibes only, powered by {noun}.","No {noun}, no {noun}.","Bounce first, {verb} later.","Mlem. {verb}. {noun}.","{noun} go brrr and {verb}.","Why not? {noun} did. Then {noun} followed.","A {adj} {noun} just {verb} near the {adj} window.","That {adj} {noun} stole my {noun}!","Look, a {adj} {noun} trying to {verb} again!","Every {noun} deserves a {adj} nap.","The {adj} {noun} is my {adj} spirit animal.","Someone call the {noun}, it’s {verb}ing and {verb}ing again!","Don’t touch the {adj} {noun}. It {verb}s loudly.","{noun} forgot how {noun}s work and just {verb}ed.","There once was a {adj} {noun} who loved to {verb} with a {adj} {noun} all day.","Apparently, {noun}s are banned from {verb}ing and {verb}ing in the {noun} library.","That {adj} noise? Just a {noun} learning to {verb} on a {adj} {noun}.","I saw a {adj} {noun} {verb} so hard, it became a {adj} muffin.","The {adj} {noun} met a {adj} pickle and everything {verb}ed.","{noun}s are like {noun}: {adj}, unpredictable, and wiggly.","Don’t judge a {adj} {noun} by its ability to {verb}, or by its {adj} hat.","All I wanted was peace, but a {adj} {noun} with a {adj} {noun} had other plans.","One {adj} morning, a {adj} {noun} decided it was finally time to {verb}, but halfway through, it tripped on a {noun} and turned into a {adj} marshmallow.","I tried to be {adj} today, but then a {noun} {verb}ed across my {noun} and typed “asdfgh{noun}” repeatedly.","If you think you’ve seen everything, wait until a {adj} {noun} {verb}s on a {noun} wearing {adj} socks with tiny {noun}s.","No one ever believed the stories about the ancient {adj} {noun} who could {verb} with such {adj} grace that entire {noun}s turned pink out of embarrassment.","A curious {adj} {noun} wandered into a {noun} shop, not knowing that its destiny involved twelve {adj} {noun}s, one rubber {noun}, and a suspiciously quiet {adj} llama.","In a land where every {adj} {noun} was made of pudding and the sky was {adj} whipped cream, one brave {adj} {noun} set out to discover the legendary Spoon of {noun}s, facing obstacles like bouncing {noun}s, sassy {noun}s, and the Great Wobble of the {noun}.","Once upon a {adj} time, long before the {noun}s learned to {verb}, there existed a tiny {adj} {noun} who dreamed of swimming in a pool made entirely of {adj} glitter pudding while {verb}ing off-key lullabies to passing {noun}s with monocles.","The Council of {noun}s gathered in {adj} secret when the sacred {adj} {noun} started to {verb} uncontrollably, threatening the entire {adj} dessert-based civilization with spontaneous {noun} jiggles and uncontainable {noun} fits across the {noun}.","Hey... do you ever wonder if {noun}s dream of {noun}s?","Okay but hear me out: what if the {adj} {noun} could actually {verb} backwards?","Can we talk about the {noun} that just {verb}ed and vanished?","So I was talking to a {noun}, and it told me to stop being {adj}. Rude.","Not to alarm you, but there’s a {adj} {noun} behind you doing the {verb}.","Why does this {noun} keep staring at me like I owe it pudding?","Is this a safe space to admit I accidentally {verb}ed a {noun}?","I just walked into the room and someone shouted “{adj} {noun}!” — what did I miss?","Wait... we were supposed to bring a {noun}? No one told me!","Okay but what if the {adj} {noun} has feelings too?","Be honest, do I look like a {noun} that forgot how to {verb}?",'If I say "oops", do I still have to explain why the {noun} is glowing?',"I don’t know what’s going on but I brought snacks and a confused {noun}.","Do you think pudding knows it’s pudding? Just a thought.","Is this about the time I {verb}ed the {adj} {noun} by accident? Because I can explain.","Wait, are we talking about {noun}s or am I on the wrong chat again?",'What is this group even about? I just saw "pudding" and joined.',"Hi! I have no idea what’s happening but I’m here and I brought a {noun}.","I blinked and now there’s a {adj} {noun} in charge of everything.","Can someone please explain why the {noun} is floating and chanting?","Okay who gave the {noun} access to glitter and emotional support pickles?","I came for a calm discussion and now there’s a {adj} battle between {noun}s.","Not sure if I’m early, late, or inside a {noun} dream.","I was gone for 3 minutes and now someone’s riding a {noun} into the pudding realm.","This isn’t the pudding appreciation group, is it? ...oh no.","So... who summoned the {adj} {noun} this time? Be honest.","I came here for vibes and stayed for the {noun}s.","Does anyone else hear faint giggling or is that just the {adj} {noun} again?","I feel like I missed step one, two, and also three of this conversation.","All I asked was “what’s up?” and now I’m emotionally attached to a {noun}.",'Me: "I’ll be normal today." Also me: *{verb}s into a meeting riding a {adj} {noun}*','"It’s just pudding," they said. "It can’t hurt you," they said. They were wrong.',"I said one nice thing to a {noun} and now it follows me everywhere.","Can we take a moment to appreciate how the {adj} {noun} is just vibing?","Who put a tiny hat on the {noun}? Because that’s adorable.","My life has been different ever since the {noun} started {verb}ing.","Raise your hand if you’ve ever been personally attacked by a {adj} {noun}.",'"Don’t be weird," they said. So I became a {noun} instead.',"Do {noun}s have feelings? Asking for a {adj} friend.","I trusted the {noun} and all I got was a glitter-covered sock.","Plot twist: the {adj} {noun} was inside us all along.","The {adj} {noun} {verb} and {verb} all over the {adj} {noun}!","Oops! {noun}s {verb}ed into the {adj} {noun} while {verb}ing crazily.","{adj}, {adj}, and more {adj} {noun}s just {verb}ed by!","Why does the {adj} {noun} keep {verb}ing and {verb}ing without stopping?","Look! A {adj} {noun}, a {adj} {noun}, and a {noun} all {verb}ing together!","Sometimes, the {noun} just {verb}s, then {verb}s again, and never stops being {adj}.","{noun}, {noun}, and {noun} — all {verb}ing and {verb}ing in a {adj} {noun}.","I saw a {adj} {noun} {verb}, then another {noun} {verb}ing with a {adj} {noun}.","The {noun} {verb}s {verb} while the {adj} {noun} {verb}s and the {noun} just {verb}s.","Can a {adj} {noun} {verb} {verb} without a {adj} {noun} watching?","Whoa! The {adj} {noun} just {verb}ed... and then {verb}ed again!","Hey... did you see that {adj} {noun} {verb} over there?","Umm, the {noun} is {verb}ing but also {verb}ing and {verb}ing!","Lol! {noun}s {verb} so {adj}ly, it’s impossible not to giggle.",'"Hey! What’s up?" asked the {adj} {noun}, who {verb}ed loudly.','"I’m just a {adj} {noun} trying to {verb}, you know?"','"Did you see the {adj} {noun} that just {verb}ed in the pudding?"','"No way! The {noun} {verb}s better than me!"','"Wait, the {adj} {noun} said it would {verb}, but it {verb}ed instead!"',"Once upon a {adj} {noun}, a group of {adj} {noun}s {verb}ed through the {adj} forest, singing {adj} songs and eating {noun}s made of pudding.","The legend tells of a {adj} {noun} who could {verb} faster than any {noun} ever seen, leaving trails of {adj} sparkles behind.","Every day, the {adj} {noun} would {verb} around the {adj} meadow, trying to convince the {noun}s to join the grand pudding party.","No one knows why the {adj} {noun} suddenly {verb}ed and then {verb}ed again, but everyone agrees it was the cutest thing they ever saw.","In the kingdom of {adj} {noun}s, only the bravest {noun} dared to {verb} the giant pudding monster, armed with nothing but {adj} smiles and jellybeans.","{adj} {noun} {verb} {verb} {verb} {noun} {verb} {adj} {noun} {verb} {noun}!","{noun} {noun} {verb} {adj} {noun} and then {verb} {verb} the {adj} {noun}.","{verb} the {adj} {noun}, then {verb} the {noun} while {verb}ing {adj}ly.","Can the {adj} {noun} {verb} and {verb} the {adj} {noun} at the same time?","{noun} {verb} {noun} {verb}, but the {adj} {noun} {verb}s better.","Boop! The {adj} {noun} just {verb}ed in the pudding.","Bloop bloop, the {noun} is {verb}ing all over again!","Mlem mlem, a {adj} {noun} {verb}s quietly in the corner.","Splat! {noun} {verb}ed right on the {adj} {noun}.","Yum! A {adj} {noun} just {verb}ed in my mouth.","Do {noun}s really {verb} when nobody’s watching?","Why does the {adj} {noun} always {verb} at midnight?","Can a {noun} be too {adj} to {verb} properly?","Is it normal for a {adj} {noun} to {verb} three times in a row?","Who taught the {noun} to {verb} like that?","Wait, did the {adj} {noun} just {verb} itself?","I can’t believe the {noun} {verb}ed into a {adj} {noun}!","Suddenly, a {adj} {noun} appeared and started to {verb} wildly.","That {noun} was {verb}ing so {adj}ly it broke the pudding meter.","Everyone’s talking about the {adj} {noun} that {verb}ed out of nowhere."];class Ot{static#pt=Dt;static#ft=jt;static#gt=Rt;static#yt=Ht;static#wt=Pt;static#bt=$t;static#vt(e,t){if(!Array.isArray(e))throw new TypeError(`${t} must be an array of strings`);if(!e.every(e=>"string"==typeof e))throw new TypeError(`${t} must contain only strings`);if(0===e.length)throw new Error(`${t} cannot be empty`)}static get defaultWords(){return[...this.#pt]}static set defaultWords(e){this.#vt(e,"defaultWords"),this.#pt=[...e]}static get defaultEmojis(){return[...this.#ft]}static set defaultEmojis(e){this.#vt(e,"defaultEmojis"),this.#ft=[...e]}static get defaultNouns(){return[...this.#gt]}static set defaultNouns(e){this.#vt(e,"defaultNouns"),this.#gt=[...e]}static get defaultVerbs(){return[...this.#yt]}static set defaultVerbs(e){this.#vt(e,"defaultVerbs"),this.#yt=[...e]}static get defaultAdjectives(){return[...this.#wt]}static set defaultAdjectives(e){this.#vt(e,"defaultAdjectives"),this.#wt=[...e]}static get defaultTemplates(){return[...this.#bt]}static set defaultTemplates(e){this.#vt(e,"defaultTemplates"),this.#bt=[...e]}config={minLength:10,maxLength:300,readable:!0,useEmojis:!0,includeNumbers:!0,includeSymbols:!0,allowWeirdSpacing:!1,emojiSet:[],wordSet:[],mode:"mixed",grammar:{templates:[],nouns:[],verbs:[],adjectives:[]},repeatWords:!0,emojiPlacement:"inline",line:{minLength:20,maxLength:120,emojiChance:.3}};constructor(e={}){this.symbols="!@#$%^&*()-_=+[]{}|;:,.<>?/\\~".split("");const{minLength:t,maxLength:r,readable:n,useEmojis:i,includeNumbers:o,includeSymbols:s,allowWeirdSpacing:a,emojiSet:l,wordSet:u,mode:c,grammar:h,repeatWords:d,emojiPlacement:m,paragraphs:p,line:f}=e;if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.minLength must be an integer >= 1");if(void 0!==r&&(!Number.isInteger(r)||r<1))throw new TypeError("config.maxLength must be an integer >= 1");if(void 0!==t&&void 0!==r&&t>r)throw new RangeError("config.minLength cannot be greater than config.maxLength");if(void 0!==n&&"boolean"!=typeof n)throw new TypeError("config.readable must be a boolean");if(void 0!==i&&"boolean"!=typeof i)throw new TypeError("config.useEmojis must be a boolean");if(void 0!==o&&"boolean"!=typeof o)throw new TypeError("config.includeNumbers must be a boolean");if(void 0!==s&&"boolean"!=typeof s)throw new TypeError("config.includeSymbols must be a boolean");if(void 0!==a&&"boolean"!=typeof a)throw new TypeError("config.allowWeirdSpacing must be a boolean");if(void 0!==l&&!Array.isArray(l))throw new TypeError("config.emojiSet must be an array of strings");if(void 0!==u&&!Array.isArray(u))throw new TypeError("config.wordSet must be an array of strings");if(void 0!==c&&!["mixed","readable","chaotic","natural"].includes(c))throw new RangeError('config.mode must be one of: "mixed", "readable", "chaotic", "natural');if(void 0!==h){if("object"!=typeof h||null===h)throw new TypeError("config.grammar must be an object");const{templates:e,nouns:t,verbs:r,adjectives:n}=h;if(void 0!==e&&!Array.isArray(e))throw new TypeError("config.grammar.templates must be an array of strings");if(void 0!==t&&!Array.isArray(t))throw new TypeError("config.grammar.nouns must be an array of strings");if(void 0!==r&&!Array.isArray(r))throw new TypeError("config.grammar.verbs must be an array of strings");if(void 0!==n&&!Array.isArray(n))throw new TypeError("config.grammar.adjectives must be an array of strings")}if(void 0!==d&&"boolean"!=typeof d)throw new TypeError("config.repeatWords must be a boolean");if(void 0!==m&&!["inline","end","none"].includes(m))throw new RangeError('config.emojiPlacement must be one of: "inline", "end", "none"');if(void 0!==p){if("object"!=typeof p)throw new TypeError("config.paragraphs must be an object or null");const{min:e,max:t}=p;if(void 0!==e&&(!Number.isInteger(e)||e<1))throw new TypeError("config.paragraphs.min must be an integer >= 1");if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.paragraphs.max must be an integer >= 1");if(void 0!==e&&void 0!==t&&e>t)throw new RangeError("config.paragraphs.min cannot be greater than config.paragraphs.max")}if(void 0!==f){if("object"!=typeof f||null===f)throw new TypeError("config.line must be an object");const{minLength:e,maxLength:t,emojiChance:r}=f;if(void 0!==e&&(!Number.isInteger(e)||e<1))throw new TypeError("config.line.minLength must be an integer >= 1");if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.line.maxLength must be an integer >= 1");if(void 0!==e&&void 0!==t&&e>t)throw new RangeError("config.line.minLength cannot be greater than config.line.maxLength");if(void 0!==r&&("number"!=typeof r||r<0||r>1))throw new RangeError("config.line.emojiChance must be a number between 0 and 1")}this.config.emojiSet=[...Ot.#ft],this.config.wordSet=[...Ot.#pt],this.config.grammar.templates=[...Ot.#bt],this.config.grammar.nouns=[...Ot.#gt],this.config.grammar.verbs=[...Ot.#yt],this.config.grammar.adjectives=[...Ot.#wt],Object.assign(this.config,e)}configure(e={}){return Object.assign(this.config,e),this}setGrammarTemplates(...e){return this.config.grammar.templates=e.flat(),this}addGrammarTemplates(...e){return this.config.grammar.templates.push(...e.flat()),this}setGrammarNouns(...e){return this.config.grammar.nouns=e.flat(),this}addGrammarNouns(...e){return this.config.grammar.nouns.push(...e.flat()),this}setGrammarVerbs(...e){return this.config.grammar.verbs=e.flat(),this}addGrammarVerbs(...e){return this.config.grammar.verbs.push(...e.flat()),this}setGrammarAdjectives(...e){return this.config.grammar.adjectives=e.flat(),this}addGrammarAdjectives(...e){return this.config.grammar.adjectives.push(...e.flat()),this}removeGrammarTemplates(...e){const t=new Set(e.flat());return this.config.grammar.templates=this.config.grammar.templates.filter(e=>!t.has(e)),this}removeGrammarNouns(...e){const t=new Set(e.flat());return this.config.grammar.nouns=this.config.grammar.nouns.filter(e=>!t.has(e)),this}removeGrammarVerbs(...e){const t=new Set(e.flat());return this.config.grammar.verbs=this.config.grammar.verbs.filter(e=>!t.has(e)),this}removeGrammarAdjectives(...e){const t=new Set(e.flat());return this.config.grammar.adjectives=this.config.grammar.adjectives.filter(e=>!t.has(e)),this}setWords(...e){return this.config.wordSet=e.flat(),this}addWords(...e){return this.config.wordSet.push(...e.flat()),this}removeWords(...e){const t=new Set(e.flat());return this.config.wordSet=this.config.wordSet.filter(e=>!t.has(e)),this}setEmojis(...e){return this.config.emojiSet=e.flat(),this}addEmojis(...e){return this.config.emojiSet.push(...e.flat()),this}removeEmojis(...e){const t=new Set(e.flat());return this.config.emojiSet=this.config.emojiSet.filter(e=>!t.has(e)),this}_getRandomItem(e){return e[Math.floor(Math.random()*e.length)]}_generateChunk(){const{wordSet:e,emojiSet:t,includeNumbers:r,includeSymbols:n,useEmojis:i,readable:o,mode:s,emojiPlacement:a}=this.config;if("natural"===s)return this._generateNaturalSentence();const l=[];return(o||"readable"===s||"mixed"===s)&&l.push(this._getRandomItem(e)),"chaotic"!==s&&"mixed"!==s||l.push(Math.random().toString(36).slice(2)),r&&l.push(Math.floor(99999*Math.random()).toString()),n&&l.push(this._getRandomItem(this.symbols)),"inline"===a&&i&&t.length&&l.push(this._getRandomItem(t)),this._getRandomItem(l)}_generateNaturalSentence(){const{templates:e,nouns:t,verbs:r,adjectives:n}=this.config.grammar;return this._getRandomItem(e).replace(/{noun}/g,()=>this._getRandomItem(t)).replace(/{verb}/g,()=>this._getRandomItem(r)).replace(/{adj}/g,()=>this._getRandomItem(n))}_generateLine(e,t){const{allowWeirdSpacing:r,repeatWords:n,readable:i,emojiSet:o,useEmojis:s,emojiPlacement:a,line:l}=this.config,u=[];for(t??=new Set;u.join(" ").length<e;){let e=this._generateChunk();!n&&t.has(e)||(t.add(e),r&&(Math.random()<.1&&(e="\n"+e),Math.random()<.1&&(e=" "+e),Math.random()<.05&&(e=e.toUpperCase())),u.push(e))}let c=u.join(i?" ":"");return"end"===a&&s&&o.length&&Math.random()<(l?.emojiChance||0)&&(c+=" "+this._getRandomItem(o)),c}_generateParagraphLines(e){const{line:t}=this.config,r=[],n=new Set;let i=0;for(;i<e;){const o=Math.floor(Math.random()*(t.maxLength-t.minLength+1)+t.minLength),s=Math.min(o,e-i);r.push(this._generateLine(s,n)),i+=s}return r}generate(){const{minLength:e,maxLength:t,paragraphs:r}=this.config,n=Math.floor(Math.random()*(t-e+1))+e;if(r&&"object"==typeof r){const e=Math.floor(Math.random()*(r.max-r.min+1))+r.min,t=Math.floor(n/e),i=[];for(let r=0;r<e;r++){const e=this._generateParagraphLines(t);i.push(e.join("\n"))}return i.join("\n\n")}return this._generateParagraphLines(n).join("\n")}}const Ft=Ot;var Bt=r(7);class zt extends Bt.EventEmitter{static Utils={...t,TinyHtml:gt};#Et=new WeakMap;#Tt=new WeakMap;#St=new WeakMap;#xt=new WeakMap;#Ct=new WeakMap;#At=new WeakMap;#It=null;#kt=null;#Mt=new Set(["IMG","IFRAME","VIDEO"]);#Nt=null;#Lt=!1;#_t=!1;#Dt=!1;#jt=!1;#Rt=!1;#Ht=!1;#Pt=!1;#$t=!1;#Ot="";#Ft=!1;#ge=!1;#Bt=!1;#zt=!1;#Wt=!1;#qt=!1;#Vt=0;#Kt=0;#Jt=0;#Ut=0;#Gt=0;#Yt;#Xt;#O;#Qt=new Set;constructor(e,{extraScrollBoundary:t=0,autoScrollBottom:r=!0,observeMutations:n=!0,preserveScrollOnLayoutShift:i=!0,debounceTime:o=100,querySelector:s=null,attributeFilter:a=["class","style","src","data-*","height","width"]}={}){if(super(),!(e instanceof Element||e===window))throw new TypeError("TinySmartScroller: 'target' must be a DOM Element or 'window', but got "+typeof e);if("number"!=typeof t||Number.isNaN(t))throw new TypeError(`TinySmartScroller: 'extraScrollBoundary' must be a valid number, received ${t}`);if("boolean"!=typeof r)throw new TypeError("TinySmartScroller: 'autoScrollBottom' must be a boolean, received "+typeof r);if("boolean"!=typeof n)throw new TypeError("TinySmartScroller: 'observeMutations' must be a boolean, received "+typeof n);if("boolean"!=typeof i)throw new TypeError("TinySmartScroller: 'preserveScrollOnLayoutShift' must be a boolean, received "+typeof i);if("number"!=typeof o||o<0||Number.isNaN(o))throw new TypeError(`TinySmartScroller: 'debounceTime' must be a non-negative number, received ${o}`);if(null!==s&&"string"!=typeof s)throw new TypeError("TinySmartScroller: 'querySelector' must be a string or null, received "+typeof s);if(!(null===a||Array.isArray(a)||a instanceof Set))throw new TypeError("TinySmartScroller: 'attributeFilter' must be an array, Set, or null. Got "+typeof a);let l;this.#O=e,this.#Xt=e instanceof Window?document.documentElement:e,this.#Ft=e instanceof Window,this.#zt=r,this.#Wt=n,this.#qt=i,this.#Vt=o,this.#Gt=t,this.#Ot=s||"",this.#Yt=new Set(a||void 0),this.#Nt=()=>{this._scrollDataUpdater(),clearTimeout(l),l=setTimeout(()=>this._onScroll(),this.#Vt)},(this.#Ft?window:this.#Xt).addEventListener("scroll",this.#Nt,{passive:!0}),this.#Wt&&(this._observeMutations(),this._observeResizes(this.#Xt.children)),this._scrollDataUpdater()}getSimpleOnHeight(e=[]){if(!Array.isArray(e))throw new TypeError("getSimpleOnHeight(filter): filter must be an array of tag names");return(t,r,n)=>{if(e.length>0&&!e.includes(t.tagName)||n.now!==n.old)return;const i=r.old;return{height:r.now.height-i.height,width:0}}}addSimpleOnHeight(e){if(!Array.isArray(e))throw new TypeError("addSimpleOnHeight(filter): filter must be an array of tag names");const t=this.getSimpleOnHeight(e);return this.onSize(t),t}getLoadTags(){return Array.from(this.#Mt)}addLoadTag(e){if("string"!=typeof e)throw new TypeError("addLoadTag(tag): tag must be a string");this.#Mt.add(e.toUpperCase())}removeLoadTag(e){if("string"!=typeof e)throw new TypeError("removeLoadTag(tag): tag must be a string");this.#Mt.delete(e.toUpperCase())}hasLoadTag(e){if("string"!=typeof e)throw new TypeError("hasLoadTag(tag): tag must be a string");return this.#Mt.has(e.toUpperCase())}resetLoadTags(e=!1){if("boolean"!=typeof e)throw new TypeError("resetLoadTags(addDefault): addDefault must be a boolean");this.#Mt.clear(),e&&(this.#Mt.add("IMG"),this.#Mt.add("IFRAME"),this.#Mt.add("VIDEO"))}getAttributeFilters(){return Array.from(this.#Yt)}addAttributeFilter(e){if("string"!=typeof e)throw new TypeError("addAttributeFilter(attr): attr must be a string");this.#Yt.add(e)}removeAttributeFilter(e){if("string"!=typeof e)throw new TypeError("removeAttributeFilter(attr): attr must be a string");this.#Yt.delete(e)}hasAttributeFilter(e){if("string"!=typeof e)throw new TypeError("hasAttributeFilter(attr): attr must be a string");return this.#Yt.has(e)}resetAttributeFilters(e=!1){if("boolean"!=typeof e)throw new TypeError("resetAttributeFilters(addDefault): addDefault must be a boolean");this.#Yt.clear(),e&&["class","style","src","data-*","height","width"].forEach(e=>this.#Yt.add(e))}onSize(e){if(!this.#ge){if("function"!=typeof e)throw new TypeError("onSize(handler): handler must be a function");this.#Qt.add(e)}}offSize(e){if(!this.#ge){if("function"!=typeof e)throw new TypeError("offSize(handler): handler must be a function");this.#Qt.delete(e)}}_scrollDataUpdater(){const e=new Map;return this.#Xt.querySelectorAll(this.#Ot||"*").forEach(t=>{const r=this.#St.get(t)??!1;this.#xt.set(t,r);const n=gt.isInContainer(this.#Xt,t);this.#St.set(t,n),e.set(t,{oldIsVisible:r,isVisible:n})}),e}_onScroll(){if(this.#ge)return;const e=this._scrollDataUpdater(),t=this.#Xt,r=t.scrollTop,n=t.scrollHeight,i=t.clientHeight,o={scrollTop:r,scrollHeight:n,clientHeight:i};let s=null,a=null;const l=0===r,u=r+i>=n-1,c=r<=0+this.#Gt,h=r+i>=n-1-this.#Gt;l&&u?s="all":l?s="top":u&&(s="bottom"),c&&h?a="all":c?a="top":h&&(a="bottom"),this.#_t=this.#Ht??!1,this.#Lt=this.#Rt??!1,this.#Dt=this.#Pt??!1,this.#jt=this.#$t??!1,this.#Ht=l,this.#Rt=u,this.#Pt=c,this.#$t=h,this.#Bt=!(this.#zt&&this.#Rt),this.#Ut=n-r-i,this.emit("onScrollBoundary",{status:s,...o,scrollCache:e}),this.emit("onExtraScrollBoundary",{status:a,...o,scrollCache:e}),this.#Bt?this.emit("onScrollPause",{...o,scrollCache:e}):this.emit("onAutoScroll",{...o,scrollCache:e})}_fixScroll(e=[]){if(this.#ge)return;if(!Array.isArray(e))throw new TypeError("_fixScroll: targets must be an array of Elements");const t=this.#Xt.scrollHeight,r=this.#Xt.scrollTop,n=this.#Xt.scrollHeight-this.#Xt.scrollTop-this.#Xt.clientHeight,i=this.#Xt.scrollHeight-t,o=()=>{const t={height:0,width:0};for(const r of e){const e=this.#Et.get(r)||{height:0,width:0},n=this.#Tt.get(r)||{height:0,width:0};this.#Qt.forEach(i=>{const o=i(r,{old:e,now:n},{old:this.#Jt,now:this.#Kt});if(this.#St.get(r)||this.#Ct.get(r)){if(void 0!==o&&"object"!=typeof o)throw new Error("_fixScroll: size filter must return an object or undefined");if(void 0===o)return;t.height=o.height,t.width=o.width}})}if("number"!=typeof t.height&&t.height<0)throw new Error("_fixScroll: invalid scrollSize.height value");if("number"!=typeof t.width&&t.width<0)throw new Error("_fixScroll: invalid scrollSize.width value");if(0!==t.height||0!==t.width)for(const t of e)this.#Ct.set(t,this.#St.get(t)??!1),this.#At.set(t,this.#xt.get(t)??!1);return t};if(this.#Jt>0&&gt.hasScroll(this.#Xt).v&&this.#zt&&this.#qt&&!this.#Rt&&!this.#Ht){const e=o();this.#Xt.scrollTop=r+i+e.height,e.width>0&&(this.#Xt.scrollLeft=this.#Xt.scrollLeft+e.width)}else!this.#Bt&&this.#zt?(o(),this.scrollToBottom()):this.#zt||this.#Rt||(o(),this.#Xt.scrollTop=this.#Xt.scrollHeight-this.#Xt.clientHeight-n)}_observeMutations(){this.#kt=new MutationObserver(e=>{this.#ge||(this._scrollDataUpdater(),this.#Jt=this.#Kt,this.#Kt=this.#Xt.childElementCount,e.forEach(e=>{e.addedNodes.forEach(e=>{if(e instanceof Element&&1===e.nodeType&&(this._observeResizes([e]),this._listenLoadEvents(e),this.#Ot)){const t=e.querySelectorAll(this.#Ot);this._observeResizes(t),this._listenLoadEvents(t)}})}),this._fixScroll())}),this.#kt.observe(this.#Xt,{childList:!0,subtree:!0,attributes:!0,attributeFilter:this.#Yt.size>0?Array.from(this.#Yt):void 0})}_observeResizes(e){this.#It||(this.#It=new ResizeObserver(e=>{if(this.#ge)return;this._scrollDataUpdater();const t=[];for(const r of e){const e=r.target,n=this.#Tt.get(e);n&&this.#Et.set(e,n);const{width:i,height:o}=r.contentRect;this.#Tt.set(e,{width:i,height:o}),t.push(e)}this._fixScroll(t)})),Array.from(e).forEach(e=>{if(!this.#It)throw new Error("_observeResizes: ResizeObserver instance is not initialized");this.#It.observe(e)})}_listenLoadEvents(e){this.#ge||(e instanceof NodeList?Array.from(e):[e]).forEach(e=>{this.#Mt.has(e.tagName)&&(e.complete||e.addEventListener("load",()=>{this._scrollDataUpdater(),!this.#Bt&&this.#zt&&this.scrollToBottom()}))})}get target(){return this.#O}get targetElement(){return this.#Xt}getOldSize(e){return this.#Et.get(e)??null}getNewSize(e){return this.#Tt.get(e)??null}wasVisible(e){return this.#xt.get(e)??!1}isVisible(e){return this.#St.get(e)??!1}wasTimedVisible(e){return this.#At.get(e)??!1}isTimedVisible(e){return this.#Ct.get(e)??!1}setExtraScrollBoundary(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("setExtraScrollBoundary(value): value must be a valid number");this.#Gt=e}getExtraScrollBoundary(){return this.#Gt}getLastKnownScrollBottomOffset(){return this.#Ut}scrollToBottom(){this.#Xt.scrollTop=this.#Xt.scrollHeight}scrollToTop(){this.#Xt.scrollTop=0}isAtCustomBottom(){return this.#$t}isAtCustomTop(){return this.#Pt}isAtBottom(){return this.#Rt}isAtTop(){return this.#Ht}isPastAtBottom(){return this.#Lt}isPastAtTop(){return this.#_t}isPastAtCustomTop(){return this.#Dt}isPastAtCustomBottom(){return this.#jt}isScrollPaused(){return this.#Bt}isWindow(){return this.#Ft}isDestroyed(){return this.#ge}getAutoScrollBottom(){return this.#zt}getObserveMutations(){return this.#Wt}getPreserveScrollOnLayoutShift(){return this.#qt}getDebounceTime(){return this.#Vt}getElemAmount(){return this.#Kt}getPrevElemAmount(){return this.#Jt}getQuerySelector(){return this.#Ot}destroy(){if(this.#ge)return;this.#ge=!0,this.#kt&&(this.#kt.disconnect(),this.#kt=null),this.#It&&(this.#It.disconnect(),this.#It=null);const e=this.#Ft?window:this.#Xt;this.#Nt&&e.removeEventListener("scroll",this.#Nt),this.#Et=new WeakMap,this.#Tt=new WeakMap,this.#St=new WeakMap,this.#xt=new WeakMap,this.#Ct=new WeakMap,this.#At=new WeakMap,this.removeAllListeners(),this.#Qt.clear(),this.#Mt.clear()}}const Wt=zt,qt=class{#U;#Zt;#er;constructor(e,{openTag:t="[",closeTag:r="]"}={}){if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new TypeError("Element must be an input or textarea.");if("string"!=typeof t)throw new TypeError("openTag must be a string.");if("string"!=typeof r)throw new TypeError("closeTag must be a string.");this.#U=e,this.#Zt=t,this.#er=r}getOpenTag(){return this.#Zt}getCloseTag(){return this.#er}setOpenTag(e){if("string"!=typeof e)throw new TypeError("Open tag must be a string.");this.#Zt=e}setCloseTag(e){if("string"!=typeof e)throw new TypeError("Close tag must be a string.");this.#er=e}ensureFocus(){return document.activeElement!==this.#U&&this.#U.focus(),this}focus(){return this.#U.focus(),this}getSelectionRange(){return{start:this.#U.selectionStart??NaN,end:this.#U.selectionEnd??NaN}}setSelectionRange(e,t,r=!0){if("number"!=typeof e||"number"!=typeof t)throw new TypeError("start and end must be numbers.");if("boolean"!=typeof r)throw new TypeError("preserveScroll must be a boolean.");const n=this.#U.scrollTop,i=this.#U.scrollLeft;return this.#U.setSelectionRange(e,t),r&&(this.#U.scrollTop=n,this.#U.scrollLeft=i),this}getValue(){return this.#U.value}setValue(e){if("string"!=typeof e)throw new TypeError("Value must be a string.");return this.#U.value=e,this}getSelectedText(){const{start:e,end:t}=this.getSelectionRange();return this.#U.value.slice(e,t)}insertText(e,{newCursor:t="end",autoSpacing:r=!1,autoSpaceLeft:n=r,autoSpaceRight:i=r}={}){if("string"!=typeof e)throw new TypeError("Text must be a string.");if(!["start","end","preserve"].includes(t))throw new TypeError("newCursor must be one of 'start', 'end', or 'preserve'.");if("boolean"!=typeof r)throw new TypeError("autoSpacing must be a boolean.");if("boolean"!=typeof n)throw new TypeError("autoSpaceLeft must be a boolean.");if("boolean"!=typeof i)throw new TypeError("autoSpaceRight must be a boolean.");const{start:o,end:s}=this.getSelectionRange(),a=this.#U.value,l=a[o-1]||"",u=a[s]||"",c=`${n&&l&&!/\s/.test(l)?" ":""}${e}${i&&u&&!/\s/.test(u)?" ":""}`,h=a.slice(0,o)+c+a.slice(s);this.setValue(h);let d=o;return"end"===t?d=o+c.length:"preserve"===t&&(d=o),this.setSelectionRange(d,d),this}deleteSelection(){return this.insertText(""),this}transformSelection(e){if("function"!=typeof e)throw new TypeError("transformer must be a function.");const{start:t}=this.getSelectionRange(),r=e(this.getSelectedText());return this.insertText(r),this.setSelectionRange(t,t+r.length),this}surroundSelection(e,t){if("string"!=typeof e||"string"!=typeof t)throw new TypeError("prefix and suffix must be strings.");const r=this.getSelectedText();return this.insertText(`${e}${r}${t}`),this}moveCaret(e){if("number"!=typeof e)throw new TypeError("offset must be a number.");const{start:t}=this.getSelectionRange(),r=Math.max(0,t+e);return this.setSelectionRange(r,r),this}selectAll(){return this.setSelectionRange(0,this.#U.value.length),this}expandSelection(e,t){if("number"!=typeof e||"number"!=typeof t)throw new TypeError("before and after must be numbers.");const{start:r,end:n}=this.getSelectionRange(),i=Math.max(0,r-e),o=Math.min(this.#U.value.length,n+t);return this.setSelectionRange(i,o),this}replaceAll(e,t){if(!(e instanceof RegExp))throw new TypeError("regex must be a RegExp.");if("function"!=typeof t)throw new TypeError("replacer must be a function.");const r=this.#U.value.replace(e,t);return this.setValue(r),this}replaceInSelection(e,t){if(!(e instanceof RegExp))throw new TypeError("regex must be a RegExp.");if("function"!=typeof t)throw new TypeError("replacer must be a function.");const{start:r,end:n}=this.getSelectionRange(),i=this.#U.value,o=i.slice(r,n).replace(e,t),s=i.slice(0,r)+o+i.slice(n);return this.setValue(s),this.setSelectionRange(r,r+o.length),this}toggleCode(e){if("string"!=typeof e)throw new TypeError("codeName must be a string.");const t=this.getSelectedText();if(t.startsWith(e)&&t.endsWith(e)){const r=t.slice(e.length,t.length-e.length);this.insertText(r)}else this.insertText(`${e}${t}${e}`);return this}_insertAttr(e){let t="";if(Array.isArray(e)){if(!e.every(e=>"string"==typeof e))throw new TypeError("All entries in attributes array must be strings.");t=e.map(e=>`${e}`).join(" ")}else{if("object"!=typeof e||null===e)throw new TypeError("attributes must be an object or an array of strings.");t=Object.entries(e).map(([e,t])=>{if("string"!=typeof t)throw new TypeError("All entries in attributes object must be strings.");return`${e}${t.length>0?`="${t}"`:""}`}).join(" ")}return t}wrapWithTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this._insertAttr(t),n=r?`${this.#Zt}${e} ${r}${this.#er}`:`${this.#Zt}${e}${this.#er}`,i=`${this.#Zt}/${e}${this.#er}`;return this.surroundSelection(n,i),this}insertTag(e,t="",r={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");if("string"!=typeof t)throw new TypeError("content must be a string.");const n=this._insertAttr(r),i=n?`${this.#Zt}${e} ${n}${this.#er}`:`${this.#Zt}${e}${this.#er}`,o=`${this.#Zt}/${e}${this.#er}`;return this.insertText(`${i}${t}${o}`),this}insertSelfClosingTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this._insertAttr(t),n=r?`${this.#Zt}${e} ${r}${this.#er}`:`${this.#Zt}${e}${this.#er}`;return this.insertText(n),this}toggleTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this.getSelectedText(),n=new RegExp(`^\\[${e}(\\s+[^\\]]*)?\\]`),i=new RegExp(`\\[/${e}\\]$`),o=n.test(r),s=i.test(r);if(o&&s){const e=r.replace(n,"").replace(i,"");this.insertText(e)}else{const n=this._insertAttr(t),i=n?`${this.#Zt}${e} ${n}${this.#er}`:`${this.#Zt}${e}${this.#er}`,o=`${this.#Zt}/${e}${this.#er}`;this.insertText(`${i}${r}${o}`)}return this}},Vt=class{#tr=!1;#rr=!1;#nr=null;#ir=null;constructor(){void 0!==navigator.clipboard&&null!==navigator.clipboard&&(this.#rr=!0,this.#nr=e=>navigator.clipboard.writeText(e),this.#ir=e=>navigator.clipboard.write([new ClipboardItem({[e.type]:e})])),this.#tr=void 0!==document.execCommand&&null!==document.execCommand}setCopyText(e){if("function"!=typeof e)throw new TypeError("setCopyText expected a function that returns Promise<void>.");this.#nr=e}setCopyBlob(e){if("function"!=typeof e)throw new TypeError("setCopyBlob expected a function that returns Promise<void>.");this.#ir=e}copyText(e){if("string"!=typeof e)throw new TypeError("copyText expected a string.");if(this.#nr)return this.#nr(e);if(this.#tr){const t=document.body,r=document.createElement("input");return r.style.position="fixed",r.style.opacity="0",r.value=e,t.append(r),r.select(),r.setSelectionRange(0,99999),document.execCommand("Copy"),r.remove(),new Promise(e=>e(void 0))}throw new Error("Clipboard API not found!")}copyBlob(e){if(!(e instanceof Blob))throw new TypeError("copyBlob expected a Blob instance.");return new Promise((t,r)=>{if(this.#ir)return this.#ir(e).then(t).catch(r);throw new Error("Clipboard API not found!")})}_handleBlob(e,t){return t.getType(e)}_handleText(e,t){return this._handleBlob(e,t).then(e=>e.text())}_readData(e=0,t=null,r=null,n=!1){return new Promise((i,o)=>{this._read(e).then(s=>{if(!s)return i(null);const a=[];let l=!0;const u=async(e,i)=>{if(l)if(null!==t&&"custom"!==t||"string"!=typeof r||!(!n&&e.startsWith(r)||n&&e===r))if(null!==t&&"text"!==t||"text/plain"!==e){if(null===t){l=!1;const t=await this._handleBlob(e,i);t&&a.push(t)}}else{l=!1;const t=await this._handleText(e,i);t&&a.push(t)}else{l=!1;const t=await this._handleBlob(e,i);t&&a.push(t)}},c=[],h=e=>{if(!(e instanceof ClipboardItem))throw new Error("Expected ClipboardItem when reading data.");for(const t in e.types)c.push(u(e.types[t],e))};if("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)&&e>-1)h(s),Promise.all(c).then(()=>{a[0]?i(a[0]):i(null)}).catch(o);else if(Array.isArray(s)){for(const e in s)h(s[e]);Promise.all(c).then(()=>i(a)).catch(o)}}).catch(o)})}async readText(e=0){const t=await this._readData(e,"text");if("string"!=typeof t)throw new Error("Failed to read text: expected string result.");return t}async readCustom(e=null,t=!1,r=0){const n=await this._readData(r,"custom",e,t);if(!(n instanceof Blob))throw new Error("Failed to read custom data: expected Blob.");return n}async readAllTexts(){const e=await this._readData(null,"text");if(!Array.isArray(e))throw new Error("Expected array of strings when reading all texts.");if(!e.every(e=>"string"==typeof e))throw new Error("Some values returned were not strings.");return e}async readAllCustom(e=null,t=!1){const r=await this._readData(null,"custom",e,t);if(!Array.isArray(r))throw new Error("Expected array of blobs when reading all custom items.");if(!r.every(e=>e instanceof Blob))throw new Error("Some values returned were not Blob instances.");return r}async readAllData(e=null,t=null){const r=await this._readData(null,e,t);if(!Array.isArray(r))throw new Error("Expected array result when reading all data.");return r}_read(e){return new Promise((t,r)=>{this.#rr||r(new Error("Clipboard API not found!")),navigator.clipboard.read().then(r=>{if("number"==typeof e){if(Number.isNaN(e)||!Number.isFinite(e)||e<0)throw new Error(`Invalid index value: ${e}`);r[e]?t(r[e]):t(null)}t(r)}).catch(r)})}async readIndex(e){const t=await this._read(e);if(null!==t&&!(t instanceof ClipboardItem))throw new Error(`Value at index ${e} is not a ClipboardItem.`);return t}async readAll(){const e=await this._read(null);if(!Array.isArray(e))throw new Error("Expected array result from clipboard read.");for(const t of e)if(!(t instanceof ClipboardItem))throw new Error("Invalid item type found in clipboard result.");return e}isExecCommandAvailable(){return this.#tr}isNavigatorClipboardAvailable(){return this.#rr}getCopyTextFunc(){return this.#nr}getCopyBlobFunc(){return this.#ir}};class Kt{static _rca(e,t,r){let n=127,i=128;void 0===e&&(e=24),void 0===t&&(t="rgb"),!0===r&&(n=55,i=200);const o=2*Math.PI/e,s=[];for(let r=0;r<e;++r){const e=Math.sin(o*r+2)*n+i,a=Math.sin(o*r+0)*n+i,l=Math.sin(o*r+4)*n+i;switch(t){case"hex":s.push({hex:this.rgbToHex(Math.round(e),Math.round(a),Math.round(l))});break;case"rgb":s.push({r:e,g:a,b:l});break;case"hsl":const[t,r,n]=this.rgbaToHsl(Math.round(e),Math.round(a),Math.round(l));s.push({h:t,s:r,l:n})}}return s}static rcaRgb(e,t){return Kt._rca(e,"rgb",t)}static rcaHsl(e,t){return Kt._rca(e,"hsl",t)}static rcaHex(e,t){return Kt._rca(e,"hex",t)}static randomColor(){return`#${Math.floor(16777216*Math.random()).toString(16).padStart(6,"0")}`}static parseInput(e,t){if("string"==typeof e){if((e=e.trim().toLowerCase()).startsWith("#"))return this.hexToRgba(e);if(e.startsWith("rgb"))return this.rgbStringToRgbaArray(e);if(e.startsWith("hsl"))return this.hslStringToRgbaArray(e)}if("number"==typeof e)return this.intToRgba(e);if(Array.isArray(e)&&(3===e.length||4===e.length)&&e.every(e=>"number"==typeof e)){if(t){const[t,r,n,i]=e;if(t<=360&&r<=100&&n<=100)return this.hslToRgba(t,r,n,i)}return[...e,1].slice(0,4)}throw new Error("Unsupported color format.")}static hslToInt(e,t,r){const[n,i,o]=Kt.hslToRgba(e,t,r);return Kt.rgbToInt(n,i,o)}static hslToHex(e,t,r){const[n,i,o]=Kt.hslToRgba(e,t,r);return Kt.rgbToHex(n,i,o)}static hslStringToRgbaArray(e){const t=e.match(/[\d.]+/g)?.map(Number);if(!t||t.length<3)return[0,0,0,1];const[r,n,i,o=1]=t;return this.hslToRgba(r,n,i,o)}static hslToRgba(e,t,r,n=1){r/=100;const i=t=>(t+e/30)%12,o=(t/=100)*Math.min(r,1-r),s=e=>r-o*Math.max(-1,Math.min(i(e)-3,Math.min(9-i(e),1)));return[Math.round(255*s(0)),Math.round(255*s(8)),Math.round(255*s(4)),n]}static hslToRgb(e,t,r,n=1){return Kt.hslToRgba(e,t,r,n).slice(0,3)}static hexToInt(e){return parseInt(e.replace(/^#/,""),16)}static hexToHsl(e){const[t,r,n,i]=Kt.hexToRgba(e);return Kt.rgbaToHsl(t,r,n,i)}static hexToHsla(e){const[t,r,n,i]=Kt.hexToRgba(e);return Kt.rgbaToHsla(t,r,n,i)}static hexToRgba(e){3===(e=e.replace(/^#/,"")).length&&(e=e.split("").map(e=>e+e).join(""));const t=parseInt(e,16);return[t>>16&255,t>>8&255,255&t,1]}static hexToRgb(e){return this.hexToRgba(e).slice(0,3)}static rgbToHex(e,t,r){return"#"+[e,t,r].map(e=>e.toString(16).padStart(2,"0")).join("")}static rgbToInt(e,t,r){return e<<16|t<<8|r}static rgbaToHsla(e,t,r,n=1){e/=255,t/=255,r/=255;const i=Math.max(e,t,r),o=Math.min(e,t,r);let s=0,a=0,l=(i+o)/2;const u=i-o;if(0!==u){switch(a=u/(1-Math.abs(2*l-1)),i){case e:s=(t-r)/u+(t<r?6:0);break;case t:s=(r-e)/u+2;break;case r:s=(e-t)/u+4}s*=60}return[Math.round(s),Math.round(100*a),Math.round(100*l),n]}static rgbaToHsl(e,t,r,n){return this.rgbaToHsla(e,t,r,n).slice(0,3)}static rgbStringToRgbaArray(e){const t=e.match(/[\d.]+/g)?.map(Number);return t?[...t,1].slice(0,4):[]}static intToHsl(e){const[t,r,n,i]=Kt.intToRgba(e);return Kt.rgbaToHsl(t,r,n,i)}static intToHsla(e){const[t,r,n,i]=Kt.intToRgba(e);return Kt.rgbaToHsla(t,r,n,i)}static intToHex(e){return"#"+e.toString(16).padStart(6,"0")}static intToRgba(e){return[e>>16&255,e>>8&255,255&e,1]}#or="#000000";#sr=[0,0,0,0];#ar;constructor(e=null,t=!1){this.#ar=t,null!=e&&this.setColor(e)}setColor(e){this.#or=e;const t=this.#ar&&Array.isArray(e)&&e[0]<=360&&e[1]<=100&&e[2]<=100;this.#sr=Kt.parseInput(e,t)}toHslaArray(){const[e,t,r,n]=this.#sr;return Kt.rgbaToHsla(e,t,r,n)}toHslString(){const[e,t,r]=this.#sr,[n,i,o]=Kt.rgbaToHsl(e,t,r);return`hsl(${n}, ${i}%, ${o}%)`}toHslaString(){const[e,t,r,n]=this.#sr,[i,o,s,a]=Kt.rgbaToHsla(e,t,r,n);return`hsla(${i}, ${o}%, ${s}%, ${a??1})`}toRgbaArray(){return[...this.#sr]}toRgbString(){const[e,t,r]=this.#sr;return`rgb(${e}, ${t}, ${r})`}toRgbaString(){const[e,t,r,n]=this.#sr;return`rgba(${e}, ${t}, ${r}, ${n??1})`}toHex(){const[e,t,r]=this.#sr;return Kt.rgbToHex(e,t,r)}toInt(){const[e,t,r]=this.#sr;return Kt.rgbToInt(e,t,r)}getOriginal(){return this.#or}}const Jt=Kt;class Ut{#lr=!1;#ur;#cr;#hr=null;#dr=new Map;constructor({cooldownWatcherTime:e=5e3,allowAutoConfigChange:t=!1}={}){if(!Number.isFinite(e)||e<=0)throw new TypeError("Expected 'cooldownWatcherTime' to be a positive number.");if("boolean"!=typeof t)throw new TypeError("Expected 'allowAutoConfigChange' to be a boolean.");this.#cr=e,this.#ur=t,this.setCooldownWatcherTime(e)}isDestroyed(){return this.#lr}getAllowAutoConfigChange(){return this.#ur}getCooldownWatcherTime(){return this.#cr}setAllowAutoConfigChange(e){if("boolean"!=typeof e)throw new TypeError("Expected 'value' to be a boolean.");this.#ur=e}setCooldownWatcherTime(e){if(this.#lr)throw new Error("TinyTimeout has been destroyed.");if(!Number.isFinite(e)||e<=0)throw new TypeError("Expected 'value' to be a positive number.");this.#cr=e,this.#hr&&clearInterval(this.#hr),this.#hr=setInterval(()=>{this.#dr.forEach(e=>{e.now>0&&e.now--})},this.#cr)}set(e,t,r,n=null){if(this.#lr)throw new Error("TinyTimeout has been destroyed.");if("string"!=typeof e||""===e.trim())throw new TypeError("Expected 'id' to be a non-empty string.");if("function"!=typeof t)throw new TypeError("Expected 'callback' to be a function.");if(!Number.isFinite(r)||r<0)throw new TypeError("Expected 'value' to be a non-negative number.");if(null!==n&&(!Number.isFinite(n)||n<0))throw new TypeError("Expected 'limit' to be null or a non-negative number.");let i=this.#dr.get(e);(!i||this.#ur&&r!==i.value)&&(i={value:r,now:0},this.#dr.set(e,i));const o=i.value*i.now;return i.now++,setTimeout(t,"number"==typeof n?Math.min(o,n):o)}static waitForTrue(e,t=100){if("function"!=typeof e)throw new TypeError("Expected 'getValue' to be a function.");if(!Number.isFinite(t)||t<=0)throw new TypeError("Expected 'checkInterval' to be a positive number.");return new Promise(r=>{const n=setInterval(()=>{e()&&(clearInterval(n),r())},t)})}waitForTrue(e,t=100){if(this.#lr)throw new Error("TinyTimeout has been destroyed.");if("function"!=typeof e)throw new TypeError("Expected 'getValue' to be a function.");if(null!==t&&(!Number.isFinite(t)||t<=0))throw new TypeError("Expected 'checkInterval' to be null or a positive number.");return Ut.waitForTrue(e,t??this.#cr)}destroy(){this.#lr||(this.#lr=!0,this.#hr&&clearInterval(this.#hr),this.#hr=null,this.#dr.clear())}}const Gt=Ut,Yt=new Map,Xt=new Map,Qt=new Set(["string","boolean","object","array",String,Boolean,Number,Object,Array,BigInt,Symbol]);class Zt extends Bt.EventEmitter{static hasJsonType(e){return Yt.has(e)&&Xt.has(e)||Qt.has(e)}static registerJsonType(e,t,r,n=!1){if(Qt.has(e))throw new Error(`Cannot register type "${e}" because it is frozen.`);Yt.set(e,t),Xt.set(e,r),n&&Qt.add(e)}static deleteJsonType(e){if(Qt.has(e))throw new Error(`Cannot remove type "${e}" because it is frozen.`);let t=!1;return Yt.delete(e)&&(t=!0),Xt.delete(e)&&(t=!0),t}static encodeSpecialJson(e){if(void 0===e)return{__undefined__:!0};if(null===e)return{__null__:!0};for(const[t,r]of Yt.entries())if("string"!=typeof t&&e instanceof t||typeof e===t)return r(e,Zt.encodeSpecialJson);if(Array.isArray(e))return e.map(Zt.encodeSpecialJson);if(p(e)){const t={};for(const r in e)t[r]=Zt.encodeSpecialJson(e[r]);return t}return e}static decodeSpecialJson(e){const t=p(e);if(t){if(e.__undefined__)return;if(e.__null__)return null}if(Array.isArray(e))return e.map(Zt.decodeSpecialJson);if(t){for(const[t,r]of Xt.entries())if(r.check&&r.check(e))return r.decode(e,Zt.decodeSpecialJson);const t={};for(const r in e)t[r]=Zt.decodeSpecialJson(e[r]);return t}return e}#mr=window.localStorage;#pr=null;#Z=0;#fr=e=>this.emit("storage",e);constructor(e){if(super(),void 0!==e&&"string"!=typeof e)throw new TypeError("TinyLocalStorage: dbName must be a string if provided.");"string"==typeof e&&(this.#pr=`LSDB::${e}`),window.addEventListener("storage",this.#fr)}#gr(e){if("string"==typeof e&&e.startsWith("LSDB::"))throw new Error(`TinyLocalStorage: Key "${e}" may conflict with reserved dbKeys.`)}updateStorageVersion(e,t){if("string"!=typeof this.#pr)throw new Error("TinyLocalStorage: Database key is not initialized. Set a valid dbName in the constructor.");if("number"!=typeof e||Number.isNaN(e)||e<1)throw new TypeError("TinyLocalStorage: version must be a positive number.");if("function"!=typeof t)throw new TypeError("TinyLocalStorage: onUpgrade must be a function.");const r=parseInt(localStorage.getItem(this.#pr),10)||0;if("number"!=typeof r||Number.isNaN(r)||r<0)throw new TypeError("TinyLocalStorage: saved version in localStorage is not a valid number.");if(e<r)throw new Error(`TinyLocalStorage: Cannot downgrade database version from ${r} to ${e}.`);e>r&&(t(r,e),localStorage.setItem(this.#pr,String(e)),this.#Z=e)}getDbKey(){return this.#pr}getVersion(){return this.#Z}setLocalStorage(e){if(!(e instanceof Storage))throw new TypeError("Argument must be a valid instance of Storage.");this.#mr=e}localStorageExists(){return this.#mr instanceof Storage}#yr(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return Zt.encodeSpecialJson(t)}setJson(e,t){if(this.#gr(e),!(p(t)||Array.isArray(t)||t instanceof Map||t instanceof Set))throw new TypeError("The storage value is not a valid JSON-compatible structure.");const r=this.#yr(e,t);return this.emit("setJson",e,t),this.#mr.setItem(e,JSON.stringify(r))}#wr(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const r=this.#mr.getItem(e),n={obj:()=>({}),array:()=>[],map:()=>new Map,set:()=>new Set},i="function"==typeof n[t]?n[t]():null;let o;try{o=JSON.parse(r)}catch{return i}return{decoded:Zt.decodeSpecialJson(o),fallback:i}}getJson(e,t){const{decoded:r,fallback:n}=this.#wr(e,t);return r instanceof Map||r instanceof Set||Array.isArray(r)||p(r)?r:n}setDate(e,t){if(this.#gr(e),!(t instanceof Date))throw new TypeError("Value must be a Date.");const r=this.#yr(e,t);return this.emit("setDate",e,t),this.#mr.setItem(e,JSON.stringify(r))}getDate(e){const t=this.#wr(e).decoded;return t instanceof Date?t:null}setRegExp(e,t){if(this.#gr(e),!(t instanceof RegExp))throw new TypeError("Value must be a RegExp.");const r=this.#yr(e,t);return this.emit("setRegExp",e,t),this.#mr.setItem(e,JSON.stringify(r))}getRegExp(e){const t=this.#wr(e).decoded;return t instanceof RegExp?t:null}setBigInt(e,t){if(this.#gr(e),"bigint"!=typeof t)throw new TypeError("Value must be a BigInt.");const r=this.#yr(e,t);return this.emit("setBigInt",e,t),this.#mr.setItem(e,JSON.stringify(r))}getBigInt(e){const t=this.#wr(e).decoded;return"bigint"==typeof t?t:null}setSymbol(e,t){if(this.#gr(e),"symbol"!=typeof t)throw new TypeError("Value must be a Symbol.");const r=this.#yr(e,t);return this.emit("setSymbol",e,t),this.#mr.setItem(e,JSON.stringify(r))}getSymbol(e){const t=this.#wr(e).decoded;return"symbol"==typeof t?t:null}getValue(e){return this.#wr(e).decoded??null}setItem(e,t){if(this.#gr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("setItem",e,t),this.#mr.setItem(e,t)}getItem(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.#mr.getItem(e)}setString(e,t){if(this.#gr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("string"!=typeof t)throw new TypeError("Value must be a string.");return this.emit("setString",e,t),this.#mr.setItem(e,JSON.stringify({__string__:!0,value:t}))}getString(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#mr.getItem(e);try{if(t=JSON.parse(t),!p(t)||!t.__string__||"string"!=typeof t.value)return null;t=t.value}catch{t=null}return"string"==typeof t?t:null}setNumber(e,t){if(this.#gr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("number"!=typeof t)throw new TypeError("Value must be a number.");return this.emit("setNumber",e,t),this.#mr.setItem(e,String(t))}getNumber(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#mr.getItem(e);return"number"==typeof t||"string"==typeof t&&t.length>0&&(t=parseFloat(t),!Number.isNaN(t))?t:null}setBool(e,t){if(this.#gr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("boolean"!=typeof t)throw new TypeError("Value must be a boolean.");return this.emit("setBool",e,t),this.#mr.setItem(e,String(t))}getBool(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const t=this.#mr.getItem(e);if("boolean"==typeof t)return t;if("string"==typeof t){if("true"===t)return!0;if("false"===t)return!1}return null}removeItem(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("removeItem",e),this.#mr.removeItem(e)}clearLocalStorage(){return this.#mr.clear()}destroy(){window.removeEventListener("storage",this.#fr),this.removeAllListeners()}}Zt.registerJsonType(Map,(e,t)=>({__map__:!0,data:Array.from(e.entries()).map(([e,r])=>[e,t(r)])}),{check:e=>e.__map__,decode:(e,t)=>new Map(e.data.map(([e,r])=>[e,t(r)]))},!0),Zt.registerJsonType(Set,(e,t)=>({__set__:!0,data:Array.from(e).map(t)}),{check:e=>e.__set__,decode:(e,t)=>new Set(e.data.map(t))},!0),Zt.registerJsonType(Date,e=>({__date__:!0,value:e.toISOString()}),{check:e=>e.__date__,decode:e=>new Date(e.value)},!0),Zt.registerJsonType(RegExp,e=>({__regexp__:!0,source:e.source,flags:e.flags}),{check:e=>e.__regexp__,decode:e=>new RegExp(e.source,e.flags)},!0),Zt.registerJsonType("number",e=>({__number__:!0,value:e.toString()}),{check:e=>e.__number__,decode:e=>Number(e.value)},!0),Zt.registerJsonType("bigint",e=>({__bigint__:!0,value:e.toString()}),{check:e=>e.__bigint__,decode:e=>BigInt(e.value)},!0),Zt.registerJsonType("symbol",e=>({__symbol__:!0,key:Symbol.keyFor(e)??e.description??null}),{check:e=>e.__symbol__,decode:e=>{const t=e.key;return null!=t?Symbol.for(t):Symbol()}},!0);const er=Zt,tr=new WeakMap;class rr extends Bt.EventEmitter{#br;get targetWindow(){return this.#br}#vr;get targetIframeElement(){return this.#vr}#Er;get targetOrigin(){return this.#Er}#Tr;get selfType(){return this.#Tr}#lr=!1;#Sr=!1;get ready(){return this.#Sr}onReady(e){this.#Sr?e():this.once(this.#xr,e)}#Cr=null;#Ar=[];#Ir;#kr;#xr;#Mr=null;constructor({targetIframe:e,targetOrigin:t=window.location.origin,secretEventName:r="__tinyIframeEvent__",handshakeEventName:n="__tinyIframeHandshake__",readyEventName:i="__tinyIframeReady__"}={}){if(super(),!(void 0===e||e instanceof HTMLIFrameElement&&e.contentWindow))throw new TypeError('[TinyIframeEvents] Invalid "targetIframe": expected HTMLIFrameElement, received '+typeof e);if("string"!=typeof t)throw new TypeError('[TinyIframeEvents] Invalid "targetOrigin": expected string, received '+typeof t);if(this.#vr=e,this.#br=e?.contentWindow??window.parent,this.#Er=t,this.#Tr=e?"parent":"iframe",this.#Ir=r,this.#kr=n,this.#xr=i,tr.has(this.#br))throw new Error("Duplicate window reference.");this._boundWindowMessage=this.#Nr.bind(this),this._boundPortMessage=this.#Lr.bind(this),this.#_r(),tr.set(this.#br,this)}get secretEventName(){return this.#Ir}set secretEventName(e){if("string"!=typeof e)throw new TypeError("TinyIframeEvents: secretEventName must be a string.");this.#Ir=e}get handshakeEventName(){return this.#kr}set handshakeEventName(e){if("string"!=typeof e)throw new TypeError("TinyIframeEvents: handshakeEventName must be a string.");this.#kr=e}get readyEventName(){return this.#xr}set readyEventName(e){if("string"!=typeof e)throw new TypeError("TinyIframeEvents: readyEventName must be a string.");this.#xr=e}#_r(){"parent"===this.#Tr?(this.#Mr=()=>{if(this.#lr)return;this.#Cr&&this.#Cr.close();const e=new MessageChannel;this.#Cr=e.port1,this.#Cr.onmessage=this._boundPortMessage,this.#Sr=!1,this.#br.postMessage({type:this.#kr},this.#Er,[e.port2])},this.#vr&&(this.#vr.addEventListener("load",this.#Mr),this.#Mr())):window.addEventListener("message",this._boundWindowMessage,!1)}#Nr(e){const t=e.data,r=e.ports;p(t)&&t.type===this.#kr&&0!==r.length&&(this.#Cr=r[0],this.#Cr.onmessage=this._boundPortMessage,window.removeEventListener("message",this._boundWindowMessage),this.#Cr.postMessage({type:`${this.#kr}_ACK`}),this.#Dr())}#Lr(e){const t=e.data;if(p(t)&&t.type===`${this.#kr}_ACK`)return void this.#Dr();if(!p(t)||!t[this.#Ir])return;const r=t.eventName,n=t.payload,i=t.direction;"string"!=typeof r||"iframe"===this.#Tr&&"iframe"!==i||"parent"===this.#Tr&&"parent"!==i||this.emit(`win:${r}`,n,e)}#Dr(){this.#Sr||(this.#Sr=!0,this.#jr(),this.emit(this.#xr))}#jr(){for(;this.#Ar.length>0;){const e=this.#Ar.shift();e&&this.#Cr&&this.#Cr.postMessage(e)}}winEmit(e,t){if("string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.#lr)throw new Error("Cannot emit: instance has been destroyed.");const r={[this.#Ir]:!0,eventName:e,payload:t,direction:"parent"===this.#Tr?"iframe":"parent"};this.#Sr&&this.#Cr?this.#Cr.postMessage(r):this.#Ar.push(r)}isDestroyed(){return this.#lr}destroy(){this.#lr=!0,this.#Sr=!1,window.removeEventListener("message",this._boundWindowMessage),this.#vr&&this.#Mr&&this.#vr.removeEventListener("load",this.#Mr),this.#Cr&&(this.#Cr.close(),this.#Cr=null),this.removeAllListeners(),this.#Ar=[],tr.delete(this.#br)}}const nr=rr,ir=new WeakMap;class or extends Bt.EventEmitter{#Rr;#Er;#Ar=[];#Sr=!1;#Hr=!1;#Pr=null;#xr="__TNE_READY__";#$r="__TNE_ROUTE__";get readyEventName(){return this.#xr}set readyEventName(e){if("string"!=typeof e)throw new TypeError("TinyNewWinEvents: readyEventName must be a string.");this.#xr=e}get routeEventName(){return this.#$r}set routeEventName(e){if("string"!=typeof e)throw new TypeError("TinyNewWinEvents: routeEventName must be a string.");this.#$r=e}constructor({targetOrigin:e,url:t,name:r,features:n}={}){if(super(),"string"==typeof r&&"_blank"===r)throw new Error('TinyNewWinEvents: The window name "_blank" is not supported. Please use a custom name to allow tracking.');if(void 0!==e&&"string"!=typeof e)throw new TypeError('TinyNewWinEvents: The "targetOrigin" option must be a string.');if(void 0!==t&&"string"!=typeof t)throw new TypeError('TinyNewWinEvents: The "url" option must be a string.');if(void 0!==n&&"string"!=typeof n)throw new TypeError('TinyNewWinEvents: The "features" option must be a string if provided.');if(void 0===t?this.#Rr=window.opener:(this.#Rr="string"==typeof t?window.open(t,r,n):t,this.#Hr=!0),!this.#Rr||ir.has(this.#Rr))throw new Error("Invalid or duplicate window reference.");this.#Er=e??window.location.origin,this._handleMessage=this.#Or.bind(this),window.addEventListener("message",this._handleMessage,!1),this.#Hr||(this.#Fr(this.#xr,null),this.#Br())}getWin(){return this.#Rr}#Or(e){if(!e.source||this.#Rr&&e.source!==this.#Rr)return;const{type:t,route:r,payload:n}=e.data||{};if(t===this.#xr)return this.#Sr=!0,this.#jr(),this.#Br(),void(this.#Hr&&this.#Fr(this.#xr,null));t===this.#$r&&this.emit(`win:${r}`,n,e)}#jr(){for(;this.#Ar.length;){const e=this.#Ar.shift();if(e){const{route:t,payload:r}=e;this.winEmit(t,r)}}}#Fr(e,t,r=""){this.#Rr&&this.#Rr.closed||this.#Rr?.postMessage({type:e,route:r,payload:t},this.#Er)}close(){if(!this.#Hr)throw new Error("Only host can close the window.");this.#Rr&&!this.#Rr.closed&&this.#Rr.close()}winEmit(e,t){if("string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.isDestroyed())throw new Error("Cannot emit: instance has been destroyed.");this.#Sr?this.#Fr(this.#$r,t,e):this.#Ar.push({route:e,payload:t})}isConnected(){return!(!this.#Sr||!this.#Rr||this.#Rr.closed)}#Br(){this.#Rr&&!this.#Pr&&(this.#Pr=setInterval(()=>{this.#Rr?.closed&&(this.emit("WINDOW_REF_CLOSED"),this.destroy())},500),ir.set(this.#Rr,this.#Pr))}onClose(e){this.on("WINDOW_REF_CLOSED",e)}offClose(e){this.off("WINDOW_REF_CLOSED",e)}isDestroyed(){return!this.#Rr}destroy(){this.#Rr&&(this.#Pr&&(clearInterval(this.#Pr),this.#Pr=null,ir.delete(this.#Rr)),window.removeEventListener("message",this._handleMessage),this.#Ar=[],this.#Sr=!1,this.#Rr=null,this.removeAllListeners())}}const sr=or,ar=class{#zr;#Wr;#qr;#Vr=0;#Kr=0;#Jr;#Ur=null;#Gr=null;get lineHeight(){return this.#zr}get maxRows(){return this.#Wr-1}get extraHeight(){return this.#qr}get currentHeight(){return this.#Vr}get currentRows(){return this.#Kr}get textarea(){return this.#Jr}constructor(e,t={}){if(!(e instanceof HTMLTextAreaElement))throw new Error("TinyTextarea: Provided element is not a <textarea>.");if("object"!=typeof t||null===t)throw new TypeError("TinyTextarea: Options must be an object if provided.");if("maxRows"in t&&"number"!=typeof t.maxRows)throw new TypeError("TinyTextarea: `maxRows` must be a number.");if("extraHeight"in t&&"number"!=typeof t.extraHeight)throw new TypeError("TinyTextarea: `extraHeight` must be a number.");if("onResize"in t&&"function"!=typeof t.onResize)throw new TypeError("TinyTextarea: `onResize` must be a function.");if("onInput"in t&&"function"!=typeof t.onInput)throw new TypeError("TinyTextarea: `onInput` must be a function.");this.#Jr=e,this.#Wr=(t.maxRows??5)+1,this.#qr=t.extraHeight??0,this.#Ur=t.onResize??null,this.#Gr=t.onInput??null,this.#zr=this.#Yr(),e.style.overflowY="hidden",e.style.resize="none",this._handleInput=()=>this.#Xr(),e.addEventListener("input",this._handleInput),this.#Xr()}#Xr(){this.#Jr.style.height="auto";const e=window.getComputedStyle(this.#Jr),t=parseFloat(e.paddingTop)||0,r=parseFloat(e.paddingBottom)||0,n=(this.#Jr.value.match(/\n/g)||[]).length,i=this.#Jr.scrollHeight,o=this.#zr*this.#Wr,s=Math.ceil(Math.min(i,o)-t-r+this.#qr),a=this.#Wr-1,l=n<a?n+1:a;this.#Jr.style.height=`${s}px`,this.#Jr.style.overflowY=i>o?"auto":"hidden",this.#Vr=s;const u={breakLines:n,rows:l,height:s,scrollHeight:i,maxHeight:o,lineHeight:this.#zr,maxRows:a};l!==this.#Kr&&(this.#Kr=l,"function"==typeof this.#Ur&&this.#Ur({...u})),"function"==typeof this.#Gr&&this.#Gr(u)}#Yr(){const e=window.getComputedStyle(this.#Jr),t=parseFloat(e.lineHeight);return Number.isNaN(t)?1.2*parseFloat(e.fontSize):t}getData(){return{rows:this.#Kr,height:this.#Vr}}refresh(){this.#Xr()}destroy(){this.#Jr.removeEventListener("input",this._handleInput)}};class lr{#lr=!1;#Qr=new Set;#Zr=new Map;#en=new Map;#tn=null;#rn=[];#nn={};#in=[];#on=null;#sn=null;#an;#ln;#un;#cn;#hn;#dn;#mn;#pn;#fn=[];#gn=0;#yn=0;#wn=[];#bn=0;#vn=null;#En=new Set;#Tn=new Set;#Sn=new Map;#xn=new Map;#Cn=new Map;static#An={" ":"Space","\n":"Enter","\r":"Enter","\t":"Tab","-":"Minus",_:"Minus","=":"Equal","+":"Equal","[":"BracketLeft","{":"BracketLeft","]":"BracketRight","}":"BracketRight","\\":"Backslash","|":"Backslash",";":"Semicolon",":":"Semicolon","'":"Quote",'"':"Quote",",":"Comma","<":"Comma",".":"Period",">":"Period","/":"Slash","?":"Slash","`":"Backquote","~":"Backquote"};static addSpecialKey(e,t){if("string"!=typeof e)throw new TypeError("Invalid char type: expected string, got "+typeof e);if(1!==e.length)throw new Error(`Invalid char length: "${e}" (must be exactly one character)`);if("string"!=typeof t)throw new TypeError("Invalid code type: expected string, got "+typeof t);lr.#An[e]=t}static removeSpecialKey(e){if("string"!=typeof e)throw new TypeError("Invalid char type: expected string, got "+typeof e);if(1!==e.length)throw new Error(`Invalid char length: "${e}" (must be exactly one character)`);delete lr.#An[e]}static getSpecialKey(e){if("string"!=typeof e)throw new TypeError("Invalid char type: expected string, got "+typeof e);if(1!==e.length)throw new Error(`Invalid char length: "${e}" (must be exactly one character)`);return lr.#An[e]}static getAllSpecialKeys(){return{...lr.#An}}static stringToKeys(e){if("string"!=typeof e)throw new TypeError("Invalid text type: expected string, got "+typeof e);if(!e.length)throw new Error("Invalid text: cannot be empty");return Array.from(e).map(e=>{const t=e.toUpperCase();if(t>="A"&&t<="Z")return`Key${t}`;if(t>="0"&&t<="9")return`Digit${t}`;const r=lr.#An[e];if(void 0!==r)return r;throw new Error(`Unsupported character: "${e}"`)})}constructor({expectedId:e=null,inputMode:t="both",ignoreIds:r=[],deadZone:n=.1,axisActiveSensitivity:i=.3,timeoutComboKeys:o=500,allowMouse:s=!1,elementBase:a=window}={}){if(null!==e&&"string"!=typeof e)throw new TypeError('"expectedId" must be a string or null, received: '+typeof e);if(!["keyboard-only","gamepad-only","both"].includes(t))throw new TypeError(`"inputMode" must be 'keyboard-only', 'gamepad-only', or 'both', received: ${t}`);if(!Array.isArray(r)||!r.every(e=>"string"==typeof e))throw new TypeError('"ignoreIds" must be an array of strings');if("number"!=typeof n||n<0||n>1)throw new RangeError(`"deadZone" must be a number between 0 and 1, received: ${n}`);if("number"!=typeof i||i<0||i>1)throw new RangeError(`"axisActiveSensitivity" must be a number between 0 and 1, received: ${i}`);if("number"!=typeof o||o<0)throw new RangeError(`"timeoutComboKeys" must be a positive number, received: ${o}`);if("boolean"!=typeof s)throw new TypeError('"allowMouse" must be a boolean, received: '+typeof s);if(!(a instanceof Window||a instanceof Element))throw new TypeError('"elementBase" must be a Window or Element instance');this.#cn=e,this.#an=t,this.#ln=new Set(r),this.#un=n,this.#hn=s,this.#dn=a,this.#mn=o,this.#pn=i,["gamepad-only","both"].includes(this.#an)&&this.#In(),["keyboard-only","both"].includes(this.#an)&&this.#kn()}#Mn=e=>this.#Nn(e.gamepad);#Ln=e=>this.#_n(e.gamepad);#In(){window.addEventListener("gamepadconnected",this.#Mn),window.addEventListener("gamepaddisconnected",this.#Ln)}#Nn(e){this.#lr||this.#ln.has(e.id)||this.#cn&&e.id!==this.#cn||this.#tn||(this.#tn=e,this.#cn=e.id,this.#Dn(),this.#jn("connected",{id:e.id,gp:e,timestamp:e.timestamp}))}#_n(e){this.#lr||this.#tn&&e.id===this.#tn.id&&(this.#tn=null,this.#on&&(cancelAnimationFrame(this.#on),this.#on=null),this.#jn("disconnected",{id:e.id,gp:e,timestamp:e.timestamp}))}#Dn(){const e=()=>{this.#lr||(this.#Rn(),this.#on=requestAnimationFrame(e))};e()}#Rn(){if(this.#lr)return;const e=navigator.getGamepads(),t=Array.from(e).find(e=>e&&e.id===this.#cn);t&&(this.#tn=t,t.buttons.forEach((e,r)=>{const n=`Button${r}`,i=this.#rn[r]?.pressed||!1;let o,s,a=!1;e.pressed&&!i?(s=1,o="down"):!e.pressed&&i?(s=0,o="up"):e.pressed&&i&&(s=1,o="hold"),e.pressed&&e.value>0&&e.value<1&&1!==e.value&&(s=e.value,a=!0),"number"==typeof s&&"string"==typeof o&&this.#Hn({key:n,source:"gamepad-button",value:s,value2:NaN,type:o,gp:t,isPressure:a,pressed:e.pressed,prevPressed:i,timestamp:t.timestamp,id:t.id}),this.#rn[r]={pressed:e.pressed,value:"number"==typeof s?s:this.#rn[r]?.value,value2:NaN}}),t.axes.forEach((e,r)=>{Math.abs(e)<this.#un&&(e=0);const n=`Axis${r}`;e!==(this.#in[r]??0)&&this.#Hn({key:n,source:"gamepad-analog",value:e,value2:NaN,type:"change",timestamp:t.timestamp,id:t.id,gp:t}),this.#in[r]=e}))}#Pn=e=>{if(!this.#lr){if(!(e instanceof KeyboardEvent))throw new Error("Expected KeyboardEvent in keydown listener.");this.#Qr.has(e.code)||(this.#Qr.add(e.code),this.#Hn({event:e,key:e.code,source:"keyboard",value:1,value2:NaN,type:"down",pressed:!0,prevPressed:this.#nn[e.code]?.pressed??!1,id:"native_keyboard",timestamp:e.timeStamp}),this.#nn[e.code]={pressed:!0})}};#$n=e=>{if(!this.#lr){if(!(e instanceof KeyboardEvent))throw new Error("Expected KeyboardEvent in keyup listener.");this.#Qr.has(e.code)&&(this.#Qr.delete(e.code),this.#Hn({event:e,key:e.code,source:"keyboard",value:0,value2:NaN,type:"up",pressed:!1,prevPressed:this.#nn[e.code]?.pressed??!1,id:"native_keyboard",timestamp:e.timeStamp}),this.#nn[e.code]={pressed:!1})}};#On=e=>{if(this.#lr)return;if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mousedown listener.");const t=`Mouse${e.button}`;this.#Qr.add(t),this.#Hn({event:e,key:t,source:"mouse",value:1,value2:NaN,type:"down",pressed:!0,prevPressed:this.#nn[t]?.pressed??!1,id:"native_mouse",timestamp:e.timeStamp}),this.#nn[t]={pressed:!0}};#Fn=e=>{if(this.#lr)return;if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mouseup listener.");const t=`Mouse${e.button}`;this.#Qr.delete(t),this.#Hn({event:e,key:t,source:"mouse",value:0,value2:NaN,type:"up",pressed:!1,prevPressed:this.#nn[t]?.pressed??!1,id:"native_mouse",timestamp:e.timeStamp}),this.#nn[t]={pressed:!1}};#Bn=e=>{if(!this.#lr){if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mousemove listener.");if(0!==e.movementX||0!==e.movementY){const t="MouseMove",r=this.#nn[t]??{pressed:!1,value:0,value2:0};this.#Hn({event:e,key:t,source:"mouse",value:e.movementX+(r.value??0),value2:e.movementY+(r.value??0),id:"native_mouse",type:"move",pressed:!0,prevPressed:null,timestamp:e.timeStamp}),this.#nn[t]={pressed:!1,value:e.movementX,value2:e.movementY}}}};#kn(){this.#dn.addEventListener("keydown",this.#Pn),this.#dn.addEventListener("keyup",this.#$n),this.#hn&&(this.#dn.addEventListener("mousedown",this.#On),this.#dn.addEventListener("mouseup",this.#Fn),this.#dn.addEventListener("mousemove",this.#Bn));const e=()=>{this.#lr||(this.#Qr.forEach(e=>{const t=e.startsWith("Mouse")?"mouse":"keyboard";this.#Hn({key:e,source:t,id:`native_${t}`,value:1,value2:NaN,type:"hold",pressed:!0,prevPressed:this.#nn[e]?.pressed??!1,timestamp:NaN})}),this.#sn=requestAnimationFrame(e))};e()}#Hn(e){if(this.#lr)return;const t=this.#en.get("input-*")||[],{pressed:r,key:n}=e,i=n.startsWith("Axis"),o="boolean"==typeof r&&r||i&&(e.value>this.#pn||e.value<-Math.abs(this.#pn)),s=i?`${n}${e.value>0?"+":e.value<0?"-":""}`:n;let a=null;if("move"!==e.type&&"hold"!==e.type){if(o){if(!i&&!this.#En.has(n)||i&&!this.#En.has(n)&&!this.#En.has(`${n}+`)&&!this.#En.has(`${n}-`)){0===this.#bn&&(this.#bn=Date.now()),this.#En.add(s),a=!0,this.#wn.push(s),this.#fn.length<1&&(this.#vn&&clearTimeout(this.#vn),this.#vn=setTimeout(()=>this.resetComboMapped(),this.#mn));const e=this.#en.get("mapped-key-start")??[];for(const t of e)t({key:s,activeTime:this.#bn})}}else if(!i&&this.#En.has(n)||i&&(this.#En.has(n)||this.#En.has(`${n}+`)||this.#En.has(`${n}-`))){this.#En.delete(n),this.#En.delete(`${n}+`),this.#En.delete(`${n}-`),a=!1;const e=this.#en.get("mapped-key-end")??[];for(const t of e)t({key:s,activeTime:this.#bn})}for(const{sequence:e,callback:t,triggered:r}of this.#xn.values()){const n=this.#xn.get(e.join("+"));if(!n)continue;const i=e.every((e,t)=>this.#wn[t]===e);i&&!r?(n.triggered=!0,t(this.#bn)):!i&&r&&(n.triggered=!1)}}for(const[r,l]of this.#Zr.entries()){const u=e=>"string"==typeof l&&e===l||Array.isArray(l)&&l.findIndex((t,r)=>e===l[r])>-1,c=u(s),h=i&&u(`${n}+`),d=i&&u(`${n}-`);if(c||h||d){if(o&&c){if(a||!this.#Tn.has(r)){0===this.#yn&&(this.#yn=Date.now()),this.#Tn.add(r),0===this.#gn&&(this.#gn=Date.now()),this.#vn&&clearTimeout(this.#vn),this.#fn.push(r),this.#vn=setTimeout(()=>this.resetComboMapped(),this.#mn);const e=this.#en.get("mapped-input-start")??[];for(const t of e)t({logicalName:r,activeTime:this.#yn,comboTime:this.#gn})}}else if(!a||this.#Tn.has(r)){this.#Tn.delete(r),this.#Tn.size<1&&(this.#yn=0);const e=this.#en.get("mapped-input-end")??[];for(const t of e)t({logicalName:r,activeTime:this.#yn,comboTime:this.#gn})}for(const{sequence:e,callback:t,triggered:r}of this.#Sn.values()){const n=this.#Sn.get(e.join("+"));if(!n)continue;const i=Array.from(this.#Tn),o=e.every((e,t)=>i[t]===e);o&&!r?(n.triggered=!0,t(this.#yn)):!o&&r&&(n.triggered=!1)}}const m=[];if(i&&0===e.value){const{value:t}=this.#Cn.get(`${n}-`)??{value:0,value2:NaN},{value:r}=this.#Cn.get(`${n}+`)??{value:0,value2:NaN};e.value!==t&&m.push(`${n}-`),e.value!==r&&m.push(`${n}+`)}else m.push(s);m.forEach(n=>{if(!("*"===l||l===n||Array.isArray(l)&&l.includes(n)))return;const i=this.#en.get(`input-${e.type}-${r}`)||[],o=this.#en.get(`input-${r}`)||[];if(o.length<1&&i.length<1&&t.length<1)return;const s={...e,key:n,logicalName:r};for(const e of t)e(s);for(const e of o)e(s);for(const e of i)e(s);this.#Cn.set(n,{value:e.value,value2:e.value2})})}}#jn(e,t){const r=this.#en.get(e)||[];for(const e of r)e(t)}#zn(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const n=r.replace("{logicalName}",e);let i=this.#en.get(n);Array.isArray(i)||(i=[],this.#en.set(n,i)),i.push(t)}#Wn(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const n=i=>{this.#qn(e,n,r),t(i)};this.#zn(e,n,r)}#Vn(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const n=r.replace("{logicalName}",e),i=this.#en.get(n)??[];i.unshift(t),this.#en.set(n,i)}#qn(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const n=r.replace("{logicalName}",e),i=this.#en.get(n);Array.isArray(i)&&this.#en.set(n,i.filter(e=>e!==t))}awaitInputMapping({timeout:e=1e4,eventName:t="MappingInput",canMove:r=!1}={}){return new Promise((n,i)=>{if("number"!=typeof e||Number.isNaN(e)||e<0)return i(new TypeError(`Invalid "timeout": expected a positive number, got ${e}`));if("string"!=typeof t||!t.trim())return i(new TypeError(`Invalid "eventName": expected a non-empty string, got ${t}`));if("boolean"!=typeof r)return i(new TypeError(`Invalid "canMove": expected a boolean, got ${r}`));const o={key:null,source:null},s=({key:e,type:i,source:l,gp:u,value:c})=>{(r||"move"!==i)&&(o.key=e,o.source=l,o.gp=u,clearTimeout(a),this.offInputStart(t,s),this.offInputChange(t,s),r&&this.offInputMove(t,s),n(o))},a=setTimeout(()=>n(o),e);this.mapInput(t,"*"),this.onInputStart(t,s),this.onInputChange(t,s),r&&this.onInputMove(t,s)})}mapInput(e,t){if("string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError(`Invalid "physicalInput": expected string or array of strings, got ${JSON.stringify(t)}`);this.#Zr.set(e,t)}unmapInput(e){if("string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);this.#Zr.delete(e)}hasMappedInput(e){if("string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);return this.#Zr.has(e)}getMappedInput(e){if("string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);const t=this.#Zr.get(e);if(!t)throw new Error(`No physical input mapped for logicalName: "${e}"`);return t}clearMapInputs(){this.#Zr.clear()}registerInputSequence(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);if("function"!=typeof t)throw new TypeError("'callback' must be a function, got: "+typeof t);if(0===e.length)throw new Error("'sequence' must contain at least one input name.");const r=e.join("+");this.#Sn.set(r,{sequence:e,callback:t,triggered:!1})}unregisterInputSequence(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");this.#Sn.delete(t)}unregisterAllInputSequences(){this.#Sn.clear()}hasInputSequence(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");return this.#Sn.has(t)}registerKeySequence(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);if("function"!=typeof t)throw new TypeError("'callback' must be a function, got: "+typeof t);if(0===e.length)throw new Error("'sequence' must contain at least one input name.");const r=e.join("+");this.#xn.set(r,{sequence:e,callback:t,triggered:!1})}unregisterKeySequence(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");this.#xn.delete(t)}unregisterAllKeySequences(){this.#xn.clear()}hasKeySequence(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");return this.#xn.has(t)}renewComboMapped(){this.#vn&&(clearTimeout(this.#vn),this.#vn=setTimeout(()=>this.resetComboMapped(),this.#mn))}resetComboMapped(){this.#vn&&clearTimeout(this.#vn),this.#wn=[],this.#vn=null,this.#bn=0,this.#fn=[],this.#gn=0}onMappedKeyStart(e){return this.#zn("",e,"mapped-key-start")}onceMappedKeyStart(e){return this.#Wn("",e,"mapped-key-start")}prependMappedKeyStart(e){return this.#Vn("",e,"mapped-key-start")}offMappedKeyStart(e){return this.#qn("",e,"mapped-key-start")}offAllMappedKeyStart(){this.#en.delete("mapped-key-start")}onMappedKeyEnd(e){return this.#zn("",e,"mapped-key-end")}onceMappedKeyEnd(e){return this.#Wn("",e,"mapped-key-end")}prependMappedKeyEnd(e){return this.#Vn("",e,"mapped-key-end")}offMappedKeyEnd(e){return this.#qn("",e,"mapped-key-end")}offAllMappedKeyEnd(){this.#en.delete("mapped-key-end")}onMappedInputStart(e){return this.#zn("",e,"mapped-input-start")}onceMappedInputStart(e){return this.#Wn("",e,"mapped-input-start")}prependMappedInputStart(e){return this.#Vn("",e,"mapped-input-start")}offMappedInputStart(e){return this.#qn("",e,"mapped-input-start")}offAllMappedInputStart(){this.#en.delete("mapped-input-start")}onMappedInputEnd(e){return this.#zn("",e,"mapped-input-end")}onceMappedInputEnd(e){return this.#Wn("",e,"mapped-input-end")}prependMappedInputEnd(e){return this.#Vn("",e,"mapped-input-end")}offMappedInputEnd(e){return this.#qn("",e,"mapped-input-end")}offAllMappedInputEnd(){this.#en.delete("mapped-input-end")}onInput(e,t){return this.#zn(e,t,"input-{logicalName}")}onceInput(e,t){return this.#Wn(e,t,"input-{logicalName}")}prependInput(e,t){return this.#Vn(e,t,"input-{logicalName}")}offInput(e,t){return this.#qn(e,t,"input-{logicalName}")}onInputStart(e,t){return this.#zn(e,t,"input-down-{logicalName}")}onceInputStart(e,t){return this.#Wn(e,t,"input-down-{logicalName}")}prependInputStart(e,t){return this.#Vn(e,t,"input-down-{logicalName}")}offInputStart(e,t){return this.#qn(e,t,"input-down-{logicalName}")}onInputEnd(e,t){return this.#zn(e,t,"input-up-{logicalName}")}onceInputEnd(e,t){return this.#Wn(e,t,"input-up-{logicalName}")}prependInputEnd(e,t){return this.#Vn(e,t,"input-up-{logicalName}")}offInputEnd(e,t){return this.#qn(e,t,"input-up-{logicalName}")}onInputHold(e,t){return this.#zn(e,t,"input-hold-{logicalName}")}onceInputHold(e,t){return this.#Wn(e,t,"input-hold-{logicalName}")}prependInputHold(e,t){return this.#Vn(e,t,"input-hold-{logicalName}")}offInputHold(e,t){return this.#qn(e,t,"input-hold-{logicalName}")}onInputChange(e,t){return this.#zn(e,t,"input-change-{logicalName}")}onceInputChange(e,t){return this.#Wn(e,t,"input-change-{logicalName}")}prependInputChange(e,t){return this.#Vn(e,t,"input-change-{logicalName}")}offInputChange(e,t){return this.#qn(e,t,"input-change-{logicalName}")}onInputMove(e,t){return this.#zn(e,t,"input-move-{logicalName}")}onceInputMove(e,t){return this.#Wn(e,t,"input-move-{logicalName}")}prependInputMove(e,t){return this.#Vn(e,t,"input-move-{logicalName}")}offInputMove(e,t){return this.#qn(e,t,"input-move-{logicalName}")}getCalls(e,t="all"){if("string"!=typeof e||""===e.trim())throw new TypeError(`"logicalName" must be a non-empty string, received ${e}`);const r=["all","start","end","hold","change","move"];if(!r.includes(t))throw new TypeError(`"type" must be one of ${r.join(", ")}, received ${t}`);const n=`${{all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t]}${e}`,i=this.#en.get(n);return Array.isArray(i)?[...i]:[]}offAllInputs(e,t="all"){if("string"!=typeof e||""===e.trim())throw new TypeError(`"logicalName" must be a non-empty string, received ${e}`);const r=["all","start","end","hold","change","move"];if(!r.includes(t))throw new TypeError(`"type" must be one of ${r.join(", ")}, received ${t}`);const n={all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t];n&&this.#en.delete(`${n}${e}`)}getCallSize(e,t="all"){if("string"!=typeof e||""===e.trim())throw new TypeError(`"logicalName" must be a non-empty string, received ${e}`);const r=["all","start","end","hold","change","move"];if(!r.includes(t))throw new TypeError(`"type" must be one of ${r.join(", ")}, received ${t}`);const n={all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t],i=this.#en.get(`${n}${e}`);return Array.isArray(i)?i.length:0}#Kn={type:"dual-rumble",params:{startDelay:0,duration:200,weakMagnitude:.5,strongMagnitude:1}};get defaultHapticEffect(){return{type:this.#Kn.type,params:{...this.#Kn.params}}}setDefaultHapticEffect(e,t){if("string"!=typeof e)throw new TypeError(`"type" must be a valid GamepadHapticEffectType string, received ${e}`);if("object"!=typeof t||null===t)throw new TypeError(`"params" must be a non-null object, received ${t}`);this.#Kn.type=e,this.#Kn.params=t}hasHapticEffect(){const e=this.#tn;return!!e&&e.vibrationActuator instanceof GamepadHapticActuator}vibrate(e,t){if(void 0!==e&&("object"!=typeof e||null===e))throw new TypeError(`"params" must be an object if provided, received ${e}`);if(void 0!==t&&"string"!=typeof t)throw new TypeError(`"type" must be a valid GamepadHapticEffectType string if provided, received ${t}`);const r=this.#tn;if(!r)return new Promise(e=>e("complete"));const n=r.vibrationActuator;return n instanceof GamepadHapticActuator?n.playEffect(t??this.#Kn.type,{...this.#Kn.params,...e}):new Promise(e=>e("complete"))}ignoreId(e){if("string"!=typeof e||""===e.trim())throw new TypeError(`"id" must be a non-empty string, received ${e}`);this.#ln.add(e)}unignoreId(e){if("string"!=typeof e||""===e.trim())throw new TypeError(`"id" must be a non-empty string, received ${e}`);this.#ln.delete(e)}onConnected(e){return this.#zn("",e,"connected")}onceConnected(e){return this.#Wn("",e,"connected")}prependConnected(e){return this.#Vn("",e,"connected")}offConnected(e){return this.#qn("",e,"connected")}offAllConnected(){this.#en.delete("connected")}onDisconnected(e){return this.#zn("",e,"disconnected")}onceDisconnected(e){return this.#Wn("",e,"disconnected")}prependDisconnected(e){return this.#Vn("",e,"disconnected")}offDisconnected(e){return this.#qn("",e,"disconnected")}offAllDisconnected(){this.#en.delete("disconnected")}hasGamepad(){return this.#tn instanceof Gamepad}getGamepad(){if(!this.#tn)throw new Error("No gamepad is currently connected.");return this.#tn}hasLastButtonState(e){return!!this.#rn[e]}getLastButtonState(e){if(!this.#rn[e])throw new Error(`No last button state found for index ${e}`);return{...this.#rn[e]}}exportConfig(){return{expectedId:this.#cn,ignoreIds:Array.from(this.#ln),deadZone:this.#un,timeoutComboKeys:this.#mn,axisActiveSensitivity:this.#pn,inputMap:Array.from(this.#Zr.entries())}}importConfig(e){if("string"!=typeof e&&("object"!=typeof e||null===e))throw new TypeError(`"json" must be a string or a non-null object, received: ${e}`);const t="string"==typeof e?JSON.parse(e):e;if(void 0!==t.expectedId&&"string"!=typeof t.expectedId&&null!==t.expectedId)throw new TypeError('"expectedId" must be a string or null if provided');if(void 0!==t.ignoreIds&&!Array.isArray(t.ignoreIds))throw new TypeError('"ignoreIds" must be an array if provided');if(void 0!==t.deadZone&&"number"!=typeof t.deadZone)throw new TypeError('"deadZone" must be a number if provided');if(void 0!==t.timeoutComboKeys&&"number"!=typeof t.timeoutComboKeys)throw new TypeError('"timeoutComboKeys" must be a number if provided');if(void 0!==t.axisActiveSensitivity&&"number"!=typeof t.axisActiveSensitivity)throw new TypeError('"axisActiveSensitivity" must be a number if provided');if(void 0!==t.inputMap&&!Array.isArray(t.inputMap))throw new TypeError('"inputMap" must be an array if provided');void 0!==t.expectedId&&(this.#cn=t.expectedId),Array.isArray(t.ignoreIds)&&(this.#ln=new Set(t.ignoreIds)),"number"==typeof t.deadZone&&(this.#un=t.deadZone),"number"==typeof t.timeoutComboKeys&&(this.#mn=t.timeoutComboKeys),"number"==typeof t.axisActiveSensitivity&&(this.#pn=t.axisActiveSensitivity),Array.isArray(t.inputMap)&&(this.#Zr=new Map(t.inputMap))}get mappedKeyStartCalls(){const e=this.#en.get("mapped-key-start");return Array.isArray(e)?[...e]:[]}get mappedKeyEndCalls(){const e=this.#en.get("mapped-key-end");return Array.isArray(e)?[...e]:[]}get comboMappedKeys(){return[...this.#wn]}get comboMappedInputs(){return[...this.#fn]}get keySequenceSize(){return this.#xn.size}get keySequences(){const e=[];for(const[,t]of this.#xn.entries())e.push(t.callback);return e}get activeMappedKeys(){return[...this.#En]}get mappedInputStartCalls(){const e=this.#en.get("mapped-input-start");return Array.isArray(e)?[...e]:[]}get mappedInputEndCalls(){const e=this.#en.get("mapped-input-end");return Array.isArray(e)?[...e]:[]}get inputSequenceSize(){return this.#Sn.size}get inputSequences(){const e=[];for(const[,t]of this.#Sn.entries())e.push(t.callback);return e}get activeMappedInputs(){return[...this.#Tn]}get mappedInputs(){const e={};for(const[t,r]of this.#Zr.entries())e[t]=r;return e}get mappedInputSize(){return this.#Zr.size}get connectedCalls(){const e=this.#en.get("connected");return Array.isArray(e)?[...e]:[]}get disconnectedCalls(){const e=this.#en.get("disconnected");return Array.isArray(e)?[...e]:[]}get ignoredDeviceIds(){return[...this.#ln]}get heldKeys(){return[...this.#Qr]}get eventsSize(){let e=0;return this.#en.forEach(t=>{e+=t.length}),e}get callSize(){return this.#en.size}get connectedCallSize(){const e=this.#en.get("connected");return Array.isArray(e)?e.length:0}get disconnectedCallSize(){const e=this.#en.get("disconnected");return Array.isArray(e)?e.length:0}get mappedKeyStartCallSize(){const e=this.#en.get("mapped-key-start");return Array.isArray(e)?e.length:0}get mappedKeyEndCallSize(){const e=this.#en.get("mapped-key-end");return Array.isArray(e)?e.length:0}get mappedInputStartCallSize(){const e=this.#en.get("mapped-input-start");return Array.isArray(e)?e.length:0}get mappedInputEndCallSize(){const e=this.#en.get("mapped-input-end");return Array.isArray(e)?e.length:0}get lastButtonStates(){const e=[];return this.#rn.forEach(t=>{e.push({...t})}),e}get lastAxes(){return[...this.#in]}get inputMode(){return this.#an}get elementBase(){return this.#dn}get timeComboInputs(){return this.#gn}get timeComboKeys(){return this.#bn}get timeMappedInputs(){return this.#yn}get timeoutComboKeys(){return this.#mn}set timeoutComboKeys(e){if("number"!=typeof e||e<0||!Number.isFinite(e))throw new TypeError("Timeout combo keys must be a non-negative finite number.");this.#mn=e}get axisActiveSensitivity(){return this.#pn}set axisActiveSensitivity(e){if("number"!=typeof e||e<0||e>1)throw new RangeError("Axis sensitivity must be a number between 0 and 1.");this.#pn=e}get deadZone(){return this.#un}set deadZone(e){if("number"!=typeof e||e<0||e>1)throw new RangeError("Dead zone must be a number between 0 and 1.");this.#un=e}get expectedId(){return this.#cn}set expectedId(e){if("string"!=typeof e)throw new TypeError("Expected device id be a string.");this.#cn=e}get isDestroyed(){return this.#lr}destroy(){this.#lr||(this.#lr=!0,this.#on&&cancelAnimationFrame(this.#on),this.#sn&&cancelAnimationFrame(this.#sn),this.#on=null,this.#sn=null,["keyboard-only","both"].includes(this.#an)&&(this.#dn.removeEventListener("keydown",this.#Pn),this.#dn.removeEventListener("keyup",this.#$n),this.#hn&&(this.#dn.removeEventListener("mousedown",this.#On),this.#dn.removeEventListener("mouseup",this.#Fn),this.#dn.removeEventListener("mousemove",this.#Bn))),["gamepad-only","both"].includes(this.#an)&&(window.removeEventListener("gamepadconnected",this.#Mn),window.removeEventListener("gamepaddisconnected",this.#Ln)),this.resetComboMapped(),this.#Zr.clear(),this.#en.clear(),this.#Qr.clear(),this.#Tn.clear(),this.#En.clear(),this.#Sn.clear(),this.#xn.clear(),this.#ln.clear(),this.#Cn.clear(),this.#rn=[],this.#in=[],this.#nn={},this.#tn=null,this.#cn=null,this.#hn=!1,this.#yn=0)}}const ur=lr,cr=class{#Jn=!0;#Un=86400;#Gn=3600;#Yn=60;#Xn=new Map;#Qn=[];#Zn;#ei;#ti={main:null};#ri=0;#ni=0;#ii=0;#oi="";#si=1;#ai=1;#li=1;#lr=!1;#ui=[31,31,31,31,31,31,31,31,31,31,31,31];#ci={default:{},day:{},night:{},hours:{},seasons:{}};#hi={min:60,max:180};#di=0;get daySize(){return this.#Un}get autoSizeAdjuste(){return this.#Jn}set autoSizeAdjuste(e){if("boolean"!=typeof e)throw new TypeError("autoSizeAdjuste must be a boolean.");this.#Jn=e}set daySize(e){if("number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("daySize must be a positive finite number.");const t=this.#Gn/this.#Un,r=this.#Yn/this.#Un;this.#Un=e,this.#Jn&&(this.#Gn=e*t,this.#Yn=e*r)}get hourSize(){return this.#Gn}set hourSize(e){if("number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("hourSize must be a positive finite number.");const t=this.#Un/this.#Gn,r=this.#Yn/this.#Gn;this.#Gn=e,this.#Jn&&(this.#Un=e*t,this.#Yn=e*r)}get minuteSize(){return this.#Yn}set minuteSize(e){if("number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("minuteSize must be a positive finite number.");const t=this.#Gn/this.#Yn,r=this.#Un/this.#Yn;this.#Yn=e,this.#Jn&&(this.#Gn=e*t,this.#Un=e*r)}get isDestroyed(){return this.#lr}get currentSeconds(){return this.#ri}set currentSeconds(e){if(this._checkDestroyed(),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("currentSeconds must be a finite number, received "+typeof e);if(e<0||e>=this.#Un)throw new RangeError(`currentSeconds must be between 0 and 86399, received ${e}`);this.#ri=Math.floor(e),this.#ni=Math.floor(e/this.#Yn),this.#ii=Math.floor(e/this.#Gn)}get currentMinutes(){return this.#ni}set currentMinutes(e){if(this._checkDestroyed(),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("currentMinutes must be a finite number, received "+typeof e);if(e<0||e>=1440)throw new RangeError(`currentMinutes must be between 0 and 1439, received ${e}`);this.#ni=Math.floor(e),this.#ii=Math.floor(e/this.#Yn),this.#ri=Math.floor(e*this.#Yn)}get currentHours(){return this.#ii}set currentHours(e){if(this._checkDestroyed(),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("currentHours must be a finite number, received "+typeof e);if(e<0||e>=24)throw new RangeError(`currentHours must be between 0 and less than 24, received ${e}`);this.#ii=Math.floor(e),this.#ni=Math.floor(e*this.#Yn),this.#ri=Math.floor(e*this.#Gn)}get moons(){return this.#Qn.map(e=>this.getMoon(e))}get seasons(){return Array.from(this.#Xn.keys())}get dayStart(){return this.#Zn}get nightStart(){return this.#ei}get weather(){return{...this.#ti}}get currentSeason(){return this.#oi}get currentDay(){return this.#si}get currentMonth(){return this.#ai}get currentYear(){return this.#li}get monthDays(){return[...this.#ui]}get weatherDuration(){return{...this.#hi}}get weatherTimeLeft(){return this.#di}set dayStart(e){if(this._checkDestroyed(),"number"!=typeof e||e<1)throw new TypeError("dayStart must be a positive non-zero number, received "+typeof e);this.#Zn=e}set nightStart(e){if(this._checkDestroyed(),"number"!=typeof e||e<1)throw new TypeError("nightStart must be a positive non-zero number, received "+typeof e);this.#ei=e}set weather(e){if(this._checkDestroyed(),"object"!=typeof e||null===e||Array.isArray(e)||!Object.values(e).every(e=>"string"==typeof e))throw new TypeError("weather must be a object with strings, received "+typeof e);this.#ti=e}set currentSeason(e){if(this._checkDestroyed(),"string"!=typeof e||!this.#Xn.has(e))throw new TypeError(`currentSeason must be one of ${Array.from(this.#Xn).map(e=>e[0]).join(", ")}, received ${e}`);this.#oi=e}set currentDay(e){if(this._checkDestroyed(),"number"!=typeof e||e<1||e>this.#ui[this.#ai-1])throw new TypeError("currentDay must be a valid day number, received "+typeof e);this.#si=e}set currentMonth(e){if(this._checkDestroyed(),"number"!=typeof e||"number"!=typeof this.#ui[e-1])throw new TypeError("currentMonth must be a valid month number, received "+typeof e);this.#ai=e}set currentYear(e){if(this._checkDestroyed(),"number"!=typeof e||e<1)throw new TypeError("currentYear must be a positive number non-zero, received "+typeof e);this.#li=e}set monthDays(e){if(this._checkDestroyed(),!Array.isArray(e))throw new TypeError("monthDays must be a array");if(!e.every(e=>"number"==typeof e))throw new TypeError("monthDays must have number values");this.#ui=[...e]}set weatherDuration(e){if(this._checkDestroyed(),"object"!=typeof e||null===e)throw new TypeError("weatherDuration must be a non-null object");if("number"!=typeof e.min||"number"!=typeof e.max)throw new TypeError("weatherDuration.min and weatherDuration.max must be numbers");this.#hi={...e}}set weatherTimeLeft(e){if(this._checkDestroyed(),"number"!=typeof e)throw new TypeError("weatherTimeLeft must be a number, received "+typeof e);this.#di=e}get weatherConfig(){const e={},t={};for(const t in this.#ci.hours)e[t]={...this.#ci.hours[t]};for(const e in this.#ci.seasons)t[e]={...this.#ci.seasons[e]};return{default:{...this.#ci.default},day:{...this.#ci.day},night:{...this.#ci.night},hours:e,seasons:t}}set weatherConfig(e){if(this._checkDestroyed(),"object"!=typeof e||null===e)throw new TypeError(`weatherConfig must be a non-null object, received ${e}`);const t=["default","day","night","hours","seasons"];for(const r of t)if(!(r in e))throw new TypeError(`weatherConfig is missing required property "${r}".`);const r={},n={},i=(e,t)=>{if("object"!=typeof e||null===e)throw new TypeError(`${t} must be an object, received ${e}`);for(const r in e){const n=typeof e[r];if("number"!==n&&"function"!==n)throw new TypeError(`${t}["${r}"] must be a number or function, received ${n}`)}};for(const t in e.hours)i(e.hours[t],`hours["${t}"]`),r[t]={...e.hours[t]};for(const t in e.seasons)i(e.seasons[t],`seasons["${t}"]`),n[t]={...e.seasons[t]};const o=(e,t)=>(i(e,t),{...e});this.#ci={default:o(e.default,"default"),day:o(e.day,"day"),night:o(e.night,"night"),hours:r,seasons:n}}constructor(e=6,t=18){this.#Zn=e,this.#ei=t}addSeason(e,t){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);if(!Array.isArray(t)||!t.every(e=>"number"==typeof e))throw new TypeError("Season values must be an array of numbers");this.#Xn.set(e,t)}removeSeason(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);this.#Xn.delete(e),this.#oi===e&&(this.#oi="")}hasSeason(e){if("string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);return this.#Xn.has(e)}getSeason(e){if("string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);const t=this.#Xn.get(e);if(!t)throw new Error(`Season "${e}" not found`);return[...t]}setTime({hour:e=0,minute:t=0,second:r=0}){this._checkDestroyed(),this.currentSeconds=(e*this.#Gn+t*this.#Yn+r)%this.#Un}addTime({hours:e=0,minutes:t=0,seconds:r=0}){this._checkDestroyed();let n=this.currentSeconds+e*this.#Gn+t*this.#Yn+r;for(;n>=this.#Un;)n-=this.#Un,this.nextDay();for(;n<0;)n+=this.#Un,this.prevDay();this.currentSeconds=n,this.updateWeatherTimer((e*this.#Gn+t*this.#Yn+r)/this.#Yn)}getTime({withSeconds:e=!1,hourSize:t=this.#Gn,minuteSize:r=this.#Yn}={}){const n=Math.floor(this.currentSeconds/t),i=Math.floor(this.currentSeconds%t/r),o=this.currentSeconds%r;return{hour:n,minute:i,second:o,formatted:`${n.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`+(e?`:${o.toString().padStart(2,"0")}`:"")}}isDay(){return this.#Zn<this.#ei?this.#ni>=this.#Zn*this.#Yn&&this.#ni<this.#ei*this.#Yn:this.#ni>=this.#Zn*this.#Yn||this.#ni<this.#ei*this.#Yn}minutesUntilDay(){return this.timeUntil(this.#Zn,"minutes")}secondsUntilDay(){return this.timeUntil(this.#Zn,"seconds")}hoursUntilDay(){return this.timeUntil(this.#Zn,"hours")}minutesUntilNight(){return this.timeUntil(this.#ei,"minutes")}secondsUntilNight(){return this.timeUntil(this.#ei,"seconds")}hoursUntilNight(){return this.timeUntil(this.#ei,"hours")}timeUntil(e,t){this._checkDestroyed();let r=e*this.#Gn-this.#ri;switch(r<=0&&(r+=this.#Un),t){case"minutes":return r/this.#Yn;case"hours":return r/this.#Gn;default:return r}}setTo(e){this._checkDestroyed(),"day"===e?this.setTime({hour:this.#Zn}):"night"===e&&this.setTime({hour:this.#ei})}nextDay(e=1){this._checkDestroyed();for(let t=0;t<e;t++){this.#si++;const e=this.#ui[this.#ai-1];if(Number.isNaN(e)||!Number.isFinite(e))throw new Error("Invalid month day count: monthDays must be a finite number.");this.#si>e&&(this.#si=1,this.#ai++,this.#ai>this.#ui.length&&(this.#ai=1,this.#li++)),this.updateSeason(),this.advanceMoons(1)}}prevDay(e=1){this._checkDestroyed();for(let t=0;t<e;t++)this.#si--,this.#si<1&&(this.#ai--,this.#ai<1&&(this.#ai=this.#ui.length,this.#li--),this.#si=this.#ui[this.#ai-1]||30),this.updateSeason(),this.rewindMoons(1)}updateSeason(){this._checkDestroyed(),this.#Xn.forEach((e,t)=>{e.includes(this.#ai)&&(this.#oi=t)})}setWeatherConfig(e){this._checkDestroyed(),this.#ci={...this.#ci,...e}}setWeatherDuration(e,t){this._checkDestroyed(),this.#hi.min=e,this.#hi.max=t}updateWeatherTimer(e){this._checkDestroyed(),this.#di-=e,this.#di<=0&&this.chooseNewWeather()}forceWeather({where:e="main",type:t,duration:r=null}){this._checkDestroyed();const n=this.#ti;n[e]=t,this.weather=n,this.#di=r??this._randomInRange(this.#hi.min,this.#hi.max)}chooseNewWeather({customWeather:e,where:t="main"}={}){this._checkDestroyed();let r={};const n=e=>{for(const[t,n]of Object.entries(e)){let e=n;"function"==typeof e&&(e=e({hour:Math.floor(this.#ni/this.#Yn),minute:this.#ni%this.#Yn,currentMinutes:this.#ni,isDay:this.isDay(),season:this.#oi,weather:this.#ti})),"number"!=typeof e||Number.isNaN(e)||(r[t]=(r[t]||0)+e)}};n(this.#ci.default||{});for(const e in this.#ci.hours){const[t,r]=e.split("-").map(e=>{const[t,r]=e.split(":").map(Number);return t*this.#Yn+(r||0)}),i=this.#ni;(t<=r?i>=t&&i<=r:i>=t||i<=r)&&n(this.#ci.hours[e])}this.isDay()&&this.#ci.day?n(this.#ci.day):!this.isDay()&&this.#ci.night&&n(this.#ci.night),this.#ci.seasons?.[this.#oi]&&n(this.#ci.seasons[this.#oi]),e&&"object"==typeof e&&n(e);const i=Object.entries(r).filter(([,e])=>e>0);if(!i.length)return this.#ti[t]=null,null;const o=i.reduce((e,[,t])=>e+t,0);let s=Math.random()*o;for(const[e,r]of i){if(s<r)return this.#ti[t]=e,this.#di=this._randomInRange(this.#hi.min,this.#hi.max),e;s-=r}return this.#ti[t]=null,null}_randomInRange(e,t){return Math.floor(Math.random()*(t-e+1))+e}addMoon(e,t,r,n=0){this._checkDestroyed();const i=Math.max(1,t);return this.#Qn.push({name:e,cycleLength:i,currentPhase:(n%i+i)%i,phaseNames:r}),this.#Qn.length-1}removeMoon(e){this._checkDestroyed(),this.#Qn=this.#Qn.filter(t=>t.name!==e)}advanceMoons(e=1){for(const t in this.#Qn)this.advanceMoon(parseInt(t),e)}rewindMoons(e=1){for(const t in this.#Qn)this.rewindMoon(parseInt(t),e)}advanceMoon(e,t=1){this._checkDestroyed();const r=this.#Qn[e];if(!r)throw new RangeError(`No moon found at index ${e}`);r.currentPhase=(r.currentPhase+t)%r.cycleLength}rewindMoon(e,t=1){this._checkDestroyed();const r=this.#Qn[e];if(!r)throw new RangeError(`No moon found at index ${e}`);r.currentPhase=(r.currentPhase-t+r.cycleLength)%r.cycleLength}moonExists(e){return!!this.#Qn[e]}getMoon(e){let t;if("number"==typeof e){if(t=this.#Qn[e],!t)throw new RangeError(`No moon found at index ${e}`)}else{if(!e||"object"!=typeof e||"string"!=typeof e.name||"number"!=typeof e.cycleLength||"number"!=typeof e.currentPhase)throw new TypeError("Invalid moon reference. Expected a number index or a MoonRaw object, received "+typeof e);t=e}return{name:t.name,phaseIndex:t.currentPhase,phaseName:t.phaseNames?t.phaseNames[t.currentPhase]??String(t.currentPhase):String(t.currentPhase),cycleLength:t.cycleLength}}_checkDestroyed(){if(this.#lr)throw new Error("This instance has been destroyed and can no longer be used.")}destroy(){this.#lr||(this.#Xn.clear(),this.#Qn.length=0,this.#Zn=0,this.#ei=0,this.#ri=0,this.#ni=0,this.#ii=0,this.#si=1,this.#ai=1,this.#li=1,this.#di=0,this.#oi="",this.#ti={main:null},this.#ui=[],this.#ci.default={},this.#ci.day={},this.#ci.night={},this.#ci.hours={},this.#ci.seasons={},this.#hi={min:0,max:0},this.#lr=!0)}};class hr extends Bt.EventEmitter{#lr=!1;#mi;#pi;#fi=[];#gi=[];#yi=[];#wi=new Map;#bi=new Set;#vi=new Map;#Ei;#Ti=new Map;#Si=new Map;get isDestroyed(){return this.#lr}get freq(){return Object.fromEntries(this.#Si)}get size(){return this.#Ti.size}get normalization(){return this.#mi}set normalization(e){if(this._checkDestroyed(),"string"!=typeof e||!e.trim())throw new TypeError("normalization must be a non-empty string (e.g., 'relative', 'softmax').");this.#mi=e}get seed(){return this.#pi}set seed(e){if(this._checkDestroyed(),null!==e&&("number"!=typeof e||!Number.isFinite(e)))throw new TypeError("seed must be a finite number or null.");this.#pi=e,null!==e&&(this.#Ei=this._makeSeededRng(e))}get globalModifiers(){return[...this.#fi]}set globalModifiers(e){if(this._checkDestroyed(),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("globalModifiers must be an array of functions (WeightsCallback).");this.#fi=e}get temporaryModifiers(){return[...this.#gi]}set temporaryModifiers(e){if(this._checkDestroyed(),!Array.isArray(e)||!e.every(e=>e&&"function"==typeof e.fn&&Number.isInteger(e.uses)&&e.uses>0))throw new TypeError("temporaryModifiers must be an array of objects { fn: function, uses: positive integer }.");this.#gi=e}get conditionalRules(){return[...this.#yi]}set conditionalRules(e){if(this._checkDestroyed(),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("conditionalRules must be an array of functions (WeightsCallback).");this.#yi=e}get pitySystems(){return Object.fromEntries(this.#wi)}set pitySystems(e){if(this._checkDestroyed(),!(e instanceof Map&&[...e.values()].every(e=>e&&"number"==typeof e.threshold&&"number"==typeof e.increment&&"number"==typeof e.cap&&"number"==typeof e.counter&&"number"==typeof e.currentAdd)))throw new TypeError("pitySystems must be a Map<string, Pity> with all numeric fields.");this.#wi=e}get exclusions(){return Array.from(this.#bi)}set exclusions(e){if(this._checkDestroyed(),!(e instanceof Set&&[...e].every(e=>"string"==typeof e)))throw new TypeError("exclusions must be a Set<string>.");this.#bi=e}get groups(){const e={};return this.#vi.forEach((t,r)=>e[r]=Array.from(t)),e}set groups(e){if(this._checkDestroyed(),!(e instanceof Map&&[...e.values()].every(e=>e instanceof Set&&[...e].every(e=>"string"==typeof e))))throw new TypeError("groups must be a Map<string, Set<string>>.");this.#vi=e}get rng(){return this.#Ei}set rng(e){if(this._checkDestroyed(),"function"!=typeof e||"number"!=typeof e())throw new TypeError("rng must be a function returning a number (RngGenerator).");this.#Ei=e}get items(){const e={};return this.#Ti.forEach((t,r)=>{e[r]={...t,groups:Array.from(t.groups)}}),e}set items(e){if(this._checkDestroyed(),!(e instanceof Map&&[...e.values()].every(e=>e&&"string"==typeof e.id&&"string"==typeof e.label&&"number"==typeof e.baseWeight&&e.groups instanceof Set&&"boolean"==typeof e.locked&&"object"==typeof e.meta)))throw new TypeError("items must be a Map<string, ItemData> with valid item structures.");this.clearList(),this.#Ti=e}constructor(e={}){super();const{rng:t=null,seed:r=null,normalization:n="relative"}=e;this.#mi=n,this.#pi=r,"function"==typeof t?this.#Ei=t:null!==this.#pi?this.#Ei=this._makeSeededRng(this.#pi):this.#Ei=Math.random,this.#pi=r??null}_checkDestroyed(){if(this.#lr)throw new Error("This instance has been destroyed and can no longer be used.")}hasItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string");return this.#Ti.has(e)}addItem(e,t={}){if(this._checkDestroyed(),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");if("object"!=typeof t||null===t)throw new TypeError("opts must be an object");let{weight:r=1,label:n=e,meta:i={},groups:o=[]}=t;if("number"!=typeof r||!Number.isFinite(r)||r<0)throw new TypeError("weight must be a non-negative number");if("string"!=typeof n)throw new TypeError("label must be a string");if("object"!=typeof i||null===i)throw new TypeError("meta must be an object");if(!(Array.isArray(o)||o instanceof Set))throw new TypeError("groups must be an array or a Set of strings");o=Array.isArray(o)?o:[...o];for(const e of o)if("string"!=typeof e)throw new TypeError("groups must contain only strings");const s={id:e,label:n,baseWeight:Math.max(0,Number(r)||0),meta:{...i},groups:new Set(o),locked:!1};this.#Ti.set(e,s);for(const t of o)this._ensureGroup(t).add(e);return this.emit("itemAdded",s),s}removeItem(e){if(this._checkDestroyed(),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");const t=this.#Ti.get(e);if(!t)return!1;for(const r of t.groups){const t=this.#vi.get(r);t&&t.delete(e)}return this.#Ti.delete(e),this.emit("itemRemoved",e),this.resetFreq(e),this.resetPity(e),!0}setBaseWeight(e,t){if(this._checkDestroyed(),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");if("number"!=typeof t||!Number.isFinite(t)||t<0)throw new TypeError("weight must be a non-negative number");const r=this.#Ti.get(e);if(!r)throw new Error("Item not found");r.baseWeight=Math.max(0,Number(t)||0),this.emit("weightChanged",{id:e,weight:r.baseWeight})}getItem(e){if("string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");return this.#Ti.get(e)??null}listItems(){return Array.from(this.#Ti.values()).map(e=>({...e}))}clearList(){this._checkDestroyed(),this.#Ti.clear(),this.clearFreqs(),this.clearPities()}hasGlobalModifier(e){if("function"!=typeof e)throw new TypeError("fn must be a function");return this.#fi.includes(e)}addGlobalModifier(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");this.#fi.push(e)}removeGlobalModifier(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");this.#fi=this.#fi.filter(t=>t!==e)}hasTemporaryModifier(e){if("function"!=typeof e)throw new TypeError("fn must be a function");return this.#gi.some(t=>t.fn===e)}addTemporaryModifier(e,t=1){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");if("number"!=typeof t||Number.isNaN(t))throw new TypeError("uses must be a number");this.#gi.push({fn:e,uses:Math.max(1,Math.floor(t))})}removeTemporaryModifier(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");const t=this.#gi.length;return this.#gi=this.#gi.filter(t=>t.fn!==e),this.#gi.length!==t}hasConditionalRule(e){if("function"!=typeof e)throw new TypeError("ruleFn must be a function");return this.#yi.includes(e)}addConditionalRule(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("ruleFn must be a function");this.#yi.push(e)}removeConditionalRule(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("ruleFn must be a function");const t=this.#yi.length;return this.#yi=this.#yi.filter(t=>t!==e),this.#yi.length!==t}hasPity(e){if("string"!=typeof e)throw new TypeError("itemId must be a string");return this.#wi.has(e)}configurePity(e,t){if(this._checkDestroyed(),!this.#Ti.has(e))throw new Error("Item not found");if("object"!=typeof t||null===t)throw new TypeError("cfg must be an object");const{threshold:r,increment:n,cap:i=1/0}=t;if("number"!=typeof r||r<=0)throw new TypeError("threshold must be a positive number");if("number"!=typeof n)throw new TypeError("increment must be a number");if("number"!=typeof i)throw new TypeError("cap must be a number");this.#wi.set(e,{threshold:Math.max(1,r),increment:Number(n)||0,cap:Number(i)||1/0,counter:0,currentAdd:0})}resetPity(e){if(this._checkDestroyed(),"string"!=typeof e||!e.trim())throw new TypeError("itemId must be a non-empty string");const t=this.#wi.get(e);t&&(t.counter=0,t.currentAdd=0)}clearPities(){this._checkDestroyed(),this.#wi.clear()}hasExclusion(e){if("string"!=typeof e)throw new TypeError("itemId must be a string");return this.#bi.has(e)}excludeItem(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#bi.add(e)}includeItem(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#bi.delete(e)}_ensureGroup(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("name must be a string");let t=this.#vi.get(e);return t||(t=new Set,this.#vi.set(e,t)),t}hasInGroup(e,t){if("string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#vi.get(t);return!!r&&r.has(e)}addToGroup(e,t){if(this._checkDestroyed(),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#Ti.get(e);if(!r)throw new Error("Item missing");r.groups.add(t),this._ensureGroup(t).add(e)}removeFromGroup(e,t){if(this._checkDestroyed(),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#vi.get(t);r&&r.delete(e);const n=this.#Ti.get(e);n&&n.groups.delete(t)}clearFreqs(){this._checkDestroyed(),this.#Si.clear()}resetFreq(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#Si.delete(e)}computeEffectiveWeights(e={}){if(this._checkDestroyed(),"object"!=typeof e||null===e)throw new TypeError("computeEffectiveWeights: parameter 'context' must be a non-null object, got "+typeof e);if("previousDraws"in e&&!Array.isArray(e.previousDraws))throw new TypeError("computeEffectiveWeights: context.previousDraws must be an array if provided, got "+typeof e.previousDraws);if("metadata"in e&&void 0!==e.metadata&&("object"!=typeof e.metadata||null===e.metadata))throw new TypeError("computeEffectiveWeights: context.metadata must be a non-null object if provided, got "+typeof e.metadata);const t=new Map;for(const[e,r]of this.#Ti)t.set(e,r.baseWeight);for(const r of this.#fi){const n=r(t,e);if(n instanceof Map)for(const[e,r]of n)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const r of this.#gi){const n=r.fn(t,e);if(n instanceof Map)for(const[e,r]of n)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const r of this.#yi){const n=r(t,e);if(n instanceof Map)for(const[e,r]of n)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const[e,r]of this.#wi)if(t.has(e)&&r.counter>r.threshold){r.currentAdd=Math.min(r.cap,r.currentAdd+r.increment);const n=t.get(e);n&&t.set(e,n+r.currentAdd)}for(const e of this.#bi)t.delete(e);for(const[e,r]of Array.from(t.entries()))r>0||t.delete(e);return t}_weightsToDistribution(e){if(this._checkDestroyed(),!(e instanceof Map))throw new TypeError("_weightsToDistribution: parameter 'weights' must be a Map, got "+typeof e);for(const[t,r]of e){if("string"!=typeof t)throw new TypeError("_weightsToDistribution: weights Map key must be string, got "+typeof t);if("number"!=typeof r||!Number.isFinite(r)||r<0)throw new TypeError(`_weightsToDistribution: weights Map value must be finite non-negative number, got ${r} for key ${t}`)}const t=Array.from(e.entries()).map(([e,t])=>({id:e,weight:t}));if(0===t.length)return[];if("softmax"===this.#mi){const e=Math.max(...t.map(e=>e.weight)),r=t.map(t=>Math.exp(t.weight-e)),n=r.reduce((e,t)=>e+t,0);let i=0;return t.map((e,t)=>{const o=r[t]/n;return i+=o,{id:e.id,weight:e.weight,p:o,cumulative:i}})}{const e=t.reduce((e,t)=>e+t.weight,0);let r=0;return t.map(t=>{const n=t.weight/e;return r+=n,{id:t.id,weight:t.weight,p:n,cumulative:r}})}}drawOne(e={}){if(this._checkDestroyed(),"object"!=typeof e||null===e)throw new TypeError("drawOne: parameter 'opts' must be a non-null object, got "+typeof e);if("previousDraws"in e&&!Array.isArray(e.previousDraws))throw new TypeError("drawOne: opts.previousDraws must be an array if provided, got "+typeof e.previousDraws);if("metadata"in e&&void 0!==e.metadata&&("object"!=typeof e.metadata||null===e.metadata))throw new TypeError("drawOne: opts.metadata must be a non-null object if provided, got "+typeof e.metadata);const t={previousDraws:e.previousDraws??[],metadata:e.metadata??{},activeModifiers:[...this.#gi]},r=this.computeEffectiveWeights(t),n=this._weightsToDistribution(r);if(!n.length)return null;const i=this.#Ei(),o=n.find(e=>i<=e.cumulative)??n[n.length-1];for(const[e,t]of this.#wi)e===o.id?(t.counter=0,t.currentAdd=0):t.counter++;this._consumeTemporaryModifiers();const s=this.#Ti.get(o.id);if(!s)return null;const a={id:s.id,label:s.label,meta:{...s.meta},prob:o.p};return this.emit("draw",a),a&&this.#Si.set(a.id,(this.#Si.get(a.id)||0)+1),a}_consumeTemporaryModifiers(){this._checkDestroyed();for(let e=this.#gi.length-1;e>=0;--e){const t=this.#gi[e];t.uses-=1,t.uses<=0&&this.#gi.splice(e,1)}}drawMany(e=1,t={}){if(this._checkDestroyed(),!Number.isInteger(e)||e<=0)throw new TypeError(`drawMany: parameter 'count' must be a positive integer, got ${e}`);if("object"!=typeof t||null===t)throw new TypeError("drawMany: parameter 'opts' must be a non-null object, got "+typeof t);if("withReplacement"in t&&"boolean"!=typeof t.withReplacement)throw new TypeError("drawMany: opts.withReplacement must be boolean if provided, got "+typeof t.withReplacement);if("ensureUnique"in t&&"boolean"!=typeof t.ensureUnique)throw new TypeError("drawMany: opts.ensureUnique must be boolean if provided, got "+typeof t.ensureUnique);if("metadata"in t&&void 0!==t.metadata&&("object"!=typeof t.metadata||null===t.metadata))throw new TypeError("drawMany: opts.metadata must be a non-null object if provided, got "+typeof t.metadata);if("previousDraws"in t&&!Array.isArray(t.previousDraws))throw new TypeError("drawMany: opts.previousDraws must be an array if provided, got "+typeof t.previousDraws);const r=t.withReplacement??!0,n=t.ensureUnique??!1,i=[],o=t.previousDraws??[];if(!r&&n){const r=new Set;for(let n=0;n<e;++n){const e=new Set(this.#bi);for(const e of r)this.#bi.add(e);const n=this.drawOne({previousDraws:o,metadata:t.metadata});if(this.#bi=e,!n)break;i.push(n),r.add(n.id),o.push(n)}return i}for(let n=0;n<e;++n){const e=this.drawOne({previousDraws:o,metadata:t.metadata});if(!e)break;i.push(e),o.push(e),r||this.excludeItem(e.id)}if(!r)for(const e of i)this.includeItem(e.id);return i}exportToJson(){return this._checkDestroyed(),{items:Array.from(this.#Ti.values()).map(e=>({id:e.id,label:e.label,baseWeight:e.baseWeight,meta:e.meta,groups:Array.from(e.groups),locked:!1})),pity:Array.from(this.#wi.entries()),exclusions:Array.from(this.#bi),normalization:this.#mi,seed:this.#pi}}loadFromJson(e){if(this._checkDestroyed(),"object"!=typeof e||null===e)throw new TypeError("data must be a non-null object");if(!Array.isArray(e.items)||!Array.isArray(e.pity)||!Array.isArray(e.exclusions))throw new TypeError("data must have items, pity, and exclusions arrays");if("string"!=typeof e.normalization)throw new TypeError("data.normalization must be a string");if(void 0!==e.seed&&null!==e.seed&&"number"!=typeof e.seed)throw new TypeError("data.seed must be a number, null, or undefined");this.clearList();for(const t of e.items){if("object"!=typeof t||null===t)throw new TypeError("Each item must be a non-null object");if("string"!=typeof t.id||!t.id.trim())throw new TypeError("Each item.id must be a non-empty string");if("string"!=typeof t.label)throw new TypeError(`Item with id "${t.id}" has invalid label; must be string`);if("number"!=typeof t.baseWeight||!Number.isFinite(t.baseWeight)||t.baseWeight<0)throw new TypeError(`Item with id "${t.id}" has invalid baseWeight; must be a finite non-negative number`);if(void 0!==t.groups&&!Array.isArray(t.groups))throw new TypeError(`Item with id "${t.id}" has invalid groups; must be an array of strings`);if(t.groups&&!t.groups.every(e=>"string"==typeof e))throw new TypeError(`Item with id "${t.id}" has groups containing non-string values`);if(void 0!==t.meta&&("object"!=typeof t.meta||null===t.meta))throw new TypeError(`Item with id "${t.id}" has invalid meta; must be an object`);this.#Ti.set(t.id,{id:t.id,label:t.label,baseWeight:t.baseWeight,meta:t.meta||{},groups:new Set(t.groups||[]),locked:!1});for(const e of t.groups||[])this._ensureGroup(e).add(t.id)}this.pitySystems=new Map(e.pity||[]),this.exclusions=new Set(e.exclusions||[]),this.normalization=e.normalization,void 0!==e.seed&&(this.seed=e.seed)}clone(){this._checkDestroyed();const e=new hr;return e.#mi=this.#mi,e.#pi=this.#pi,e.#fi=[...this.#fi],e.#gi=this.#gi.map(e=>({fn:e.fn,uses:e.uses})),e.#yi=[...this.#yi],e.#wi=new Map([...this.#wi.entries()].map(([e,t])=>[e,{...t}])),e.#bi=new Set(this.#bi),e.#vi=new Map([...this.#vi.entries()].map(([e,t])=>[e,new Set(t)])),e.#Ei=this.#Ei,e.#Ti=new Map([...this.#Ti.entries()].map(([e,t])=>[e,{...t,groups:new Set(t.groups),meta:{...t.meta}}])),e.#Si=new Map(this.#Si),e}_makeSeededRng(e){if(this._checkDestroyed(),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("seed must be a finite number");let t=e>>>0;return function(){t+=1831565813;let e=Math.imul(t^t>>>15,1|t);return e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}destroy(){this.#lr||(this.#lr=!0,this.#wi.clear(),this.#bi.clear(),this.#vi.clear(),this.#Ti.clear(),this.#Si.clear(),this.#fi=[],this.#gi=[],this.#yi=[],this.#pi=null)}}const dr=hr,mr=class{#re;get data(){return this.#re}set data(e){if(!(Array.isArray(e)||e instanceof Set))throw new TypeError("Paginator expects an array or Set as data source.");this.#re=e}get size(){return Array.isArray(this.#re)?this.#re.length:this.#re.size}constructor(e){if(!(Array.isArray(e)||e instanceof Set))throw new TypeError("Paginator expects an array or Set as data source.");this.#re=e}get({page:e,perPage:t,filter:r}){if(!Number.isInteger(e)||e<1)throw new RangeError("Page number must be a positive integer.");if(!Number.isInteger(t)||t<1)throw new RangeError("Items per page must be a positive integer.");const n=Array.isArray(this.#re)?this.#re:Array.from(this.#re);let i=n;if(r)if("function"==typeof r)i=n.filter((e,t,n)=>r(e,t,n));else{if("object"!=typeof r)throw new TypeError("Filter must be an object or a function");i=n.filter(e=>Object.entries(r).every(([t,r])=>{const n=e[t];return r instanceof RegExp?r.test(n):n===r}))}else i=n;const o=i.length,s=Math.max(1,Math.ceil(o/t)),a=Math.min(e,s),l=(a-1)*t,u=l+t,c=a>1,h=a<s;return{items:i.slice(l,u),page:a,perPage:t,totalItems:o,totalPages:s,hasPrev:c,hasNext:h}}};class pr{static#xi=new Map;static get itemRegistry(){const e={},t=Object.fromEntries(pr.#xi);for(const r in t)e[r]={...t[r],metadata:{...t[r].metadata}};return e}static defineItem(e){if(!e||"object"!=typeof e)throw new TypeError("Config must be a valid object.");if(!e.id||"string"!=typeof e.id)throw new TypeError("Item must have a valid string 'id'.");if(void 0!==e.weight&&("number"!=typeof e.weight||e.weight<0))throw new TypeError(`weight must be a number >= 0. Received: ${e.weight}`);if(void 0!==e.maxStack&&(!Number.isInteger(e.maxStack)||e.maxStack<=0))throw new TypeError(`maxStack must be a positive integer. Received: ${e.maxStack}`);if(void 0!==e.metadata&&"object"!=typeof e.metadata)throw new TypeError("metadata must be an object.");if(void 0!==e.onUse&&null!==e.onUse&&"function"!=typeof e.onUse)throw new TypeError("onUse must be a function or null.");if(void 0!==e.type&&null!==e.type&&"string"!=typeof e.type)throw new TypeError("type must be a string or null.");pr.#xi.set(e.id,{id:e.id,weight:e.weight||0,maxStack:e.maxStack||1,metadata:e.metadata||{},type:e.type??null,onUse:"function"==typeof e.onUse?e.onUse:null})}static removeItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");return pr.#xi.delete(e)}static hasItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");return pr.#xi.has(e)}static getItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");const t=pr.#xi.get(e);if(!t)throw new Error(`Item '${e}' not defined in registry.`);return t}#Ci=new Map;#Ai={add:[],remove:[],use:[],set:[]};#Ti=[];#Ii;#ki;#Mi;#Ni;get maxStack(){return this.#Ii}set maxStack(e){if(!Number.isInteger(e)||Number.isFinite(e)&&e<=0)throw new TypeError(`maxStack must be a positive integer. Received: ${e}`);this.#Ii=e}get maxSize(){return this.#ki}set maxSize(e){if(null!==e&&(!Number.isInteger(e)||e<=0))throw new TypeError(`maxSize must be null or a positive integer. Received: ${e}`);this.#ki=e}get maxSlots(){return this.#Mi}set maxSlots(e){if(null!==e&&(!Number.isInteger(e)||e<=0))throw new TypeError(`maxSlots must be null or a positive integer. Received: ${e}`);this.#Mi=e}get maxWeight(){return this.#Ni}set maxWeight(e){if(null!==e&&("number"!=typeof e||e<=0))throw new TypeError(`maxWeight must be null or a positive number. Received: ${e}`);this.#Ni=e}get events(){return{add:[...this.#Ai.add],remove:[...this.#Ai.remove],use:[...this.#Ai.use],set:[...this.#Ai.set]}}get items(){return[...this.#Ti].map(e=>e?this.#Li(e):null)}get specialSlots(){return new Map([...this.#Ci.entries()].map(([e,t])=>[e,{type:t.type,item:t.item?this.#Li(t.item):null}]))}get size(){const e=this.getAllItems();let t=0;for(const r of e)t+=r.quantity;return t}get slotsSize(){return this.getAllItems().length}get weight(){return this.getAllItems().reduce((e,t)=>{const r=pr.getItem(t.id);return e+(r?.weight||0)*t.quantity},0)}_cleanNulls(){let e=this.#Ti.length-1;for(;e>=0&&null===this.#Ti[e];)e--;this.#Ti=this.#Ti.slice(0,e+1)}constructor(e={}){if("object"!=typeof e||null===e)throw new TypeError("`options` must be an object.");if(void 0!==e.maxWeight&&null!==e.maxWeight&&"number"!=typeof e.maxWeight)throw new TypeError("`maxWeight` must be a number or null.");if(void 0!==e.maxSlots&&null!==e.maxSlots&&"number"!=typeof e.maxSlots)throw new TypeError("`maxSlots` must be a number or null.");if(void 0!==e.maxSize&&null!==e.maxSize&&"number"!=typeof e.maxSize)throw new TypeError("`maxSize` must be a number or null.");if(void 0!==e.maxStack&&"number"!=typeof e.maxStack)throw new TypeError("`maxStack` must be a number.");if(void 0!==e.specialSlots&&"object"!=typeof e.specialSlots)throw new TypeError("`specialSlots` must be an object if defined.");if(this.#Ni=e.maxWeight??null,this.#Mi=e.maxSlots??null,this.#ki=e.maxSize??null,this.#Ii=e.maxStack??1/0,e.specialSlots)for(const t in e.specialSlots){const r=e.specialSlots[t];if("object"!=typeof r||null===r)throw new TypeError("Each `specialSlot` entry must be an object.");if(void 0!==r.type&&null!==r.type&&"string"!=typeof r.type)throw new TypeError("`specialSlot.type` must be a string or null.");this.#Ci.set(t,{type:r.type??null,item:null})}}hasSpace({weight:e=0,sizeLength:t=0,slotsLength:r=0}={}){if("number"!=typeof e)throw new TypeError("`weight` must be a number.");if("number"!=typeof t)throw new TypeError("`sizeLength` must be a number.");if("number"!=typeof r)throw new TypeError("`slotsLength` must be a number.");return!(this.areFull(t)||this.areFullSlots(r)||this.isHeavy(e))}isHeavy(e=0){if("number"!=typeof e)throw new TypeError("`extraWeight` must be a number.");return null!==this.#Ni&&this.weight+e>this.#Ni}areFull(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#ki&&this.size+e>this.#ki}isFull(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#ki&&this.size+e>=this.#ki}areFullSlots(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Mi&&this.slotsSize+e>this.#Mi}isFullSlots(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Mi&&this.slotsSize+e>=this.#Mi}#_i(e,t){if("string"!=typeof e)throw new TypeError("`type` must be a string.");if("object"!=typeof t||null===t)throw new TypeError("`payload` must be an object.");if(this.#Ai[e])for(const r of this.#Ai[e])r(t)}off(e,t){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");if("function"!=typeof t)throw new TypeError("`callback` must be a function.");if(!this.#Ai[e])return;const r=this.#Ai[e],n=r.indexOf(t);-1!==n&&r.splice(n,1)}offAll(e){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");this.#Ai[e]&&(this.#Ai[e]=[])}cloneEventCallbacks(e){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");return this.#Ai[e]?[...this.#Ai[e]]:[]}onAddItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Ai.add.push(e)}onSetItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Ai.set.push(e)}onRemoveItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Ai.remove.push(e)}onUseItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Ai.use.push(e)}compactInventory(){this.#Ti=this.#Ti.filter((e,t)=>{const r=null!==e;return r||this.#_i("remove",{index:t,item:null,isCollection:!0,specialSlot:null,remove:()=>{}}),r})}addItem({itemId:e,quantity:t=1,metadata:r={},forceSpace:n=!1}){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");if("number"!=typeof t||!Number.isFinite(t)||t<=0)throw new TypeError("`quantity` must be a positive number.");if("object"!=typeof r||null===r)throw new TypeError("`metadata` must be an object.");if("boolean"!=typeof n)throw new TypeError("`forceSpace` must be a boolean.");const i=pr.getItem(e);let o=t;const s=i.maxStack<=this.#Ii?i.maxStack:this.#Ii,a=[],l=(e,t)=>JSON.stringify(e)===JSON.stringify(t);let u=!0;for(;o>0&&u;){u=!1;for(const t in this.#Ti){const c=this.#Ti[t];if(c&&c.id===e&&c.quantity<s&&l(c.metadata,r)){const e=Math.min(s-c.quantity,o);if(!n&&!this.hasSpace({weight:i.weight*e,sizeLength:e}))continue;c.quantity+=e,o-=e,u=!0;const r=Number(t),l=a.findIndex(e=>e.index===r);if(l<0?a.push({index:r,quantity:e}):a[l].quantity+=e,this.#_i("add",{item:this.#Li(c),index:r,isCollection:!0,specialSlot:null,remove:this.#Di({locationType:"normal",slotIndex:r,forceSpace:n,item:c})}),o<=0)break}}}if(o>0)for(const t in this.#Ti)if(null===this.#Ti[t]){const l=Math.min(s,o);if(!n&&!this.hasSpace({weight:i.weight*l,sizeLength:l}))continue;const u={id:e,quantity:l,metadata:r};this.#Ti[t]=u,o-=l;const c=Number(t),h=a.findIndex(e=>e.index===c);if(h<0?a.push({index:c,quantity:l}):a[h].quantity+=l,this.#_i("add",{item:this.#Li(u),index:c,isCollection:!0,specialSlot:null,remove:this.#Di({locationType:"normal",slotIndex:c,forceSpace:n,item:u})}),o<=0)break}for(;o>0;){const t=Math.min(s,o);if(!n&&!this.hasSpace({weight:i.weight*t,sizeLength:t,slotsLength:1}))break;const l={id:e,quantity:t,metadata:r};this.#Ti.push(l);const u=this.#Ti.length-1,c=a.findIndex(e=>e.index===u);c<0?a.push({index:u,quantity:t}):a[c].quantity+=t,this.#_i("add",{item:this.#Li(l),index:u,isCollection:!0,specialSlot:null,remove:this.#Di({locationType:"normal",slotIndex:u,forceSpace:n,item:l})}),o-=t}return{remaining:o,placesAdded:a}}getItemFrom(e){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");if(e<0||e>=this.#Ti.length)throw new Error(`Slot index '${e}' out of bounds .`);return this.#Ti[e]?this.#Li(this.#Ti[e]):null}setItem({slotIndex:e,item:t,forceSpace:r=!1}){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be a boolean.");const n=t&&"object"==typeof t&&"string"==typeof t.id&&"number"==typeof t.quantity&&!Number.isNaN(t.quantity)&&Number.isFinite(t.quantity)&&t.quantity>-1&&"object"==typeof t.metadata;if(null!==t&&!n)throw new Error("Invalid item type: must be null or a valid InventoryItem.");const i=t?pr.#xi.get(t.id):null;if(null!==t&&!i)throw new Error(`Item '${t?.id??"unknown"}' not defined in registry.`);if(i&&t){const e=i.maxStack<=this.#Ii?i.maxStack:this.#Ii;if(t.quantity>e)throw new Error(`Item '${t.id}' exceeds max stack size. Allowed: ${e}, got: ${t.quantity}.`)}if(null!==this.#Mi&&(e<0||e>=this.#Mi))throw new Error(`Slot index ${e} out of range.`);const o=this.#Ti[e]??null,s=o?pr.#xi.get(o.id)??null:null,a=(e,t)=>t?t.weight*(e?e.quantity:0):0,l=e=>e?e.quantity:0;if(!r&&!this.hasSpace({weight:a(t,i)-a(o,s),sizeLength:l(t)-l(o)}))throw new Error("Inventory is full or overweight.");for(;this.#Ti.length<=e;)this.#Ti.push(null);this.#Ti[e]=t,this._cleanNulls(),this.#_i("set",{index:e,isCollection:!0,item:t?this.#Li(t):null,specialSlot:null,remove:t?this.#Di({locationType:"normal",slotIndex:e,forceSpace:r,item:t}):()=>{}})}deleteItem(e,t=!1){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");if("boolean"!=typeof t)throw new TypeError("`forceSpace` must be a boolean.");this.setItem({slotIndex:e,item:null,forceSpace:t})}moveItem(e,t,r=!1){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`fromIndex` must be an integer.");if("number"!=typeof t||!Number.isInteger(t))throw new TypeError("`toIndex` must be an integer.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be a boolean.");const n=this.#Ti[e];if(!n)throw new Error(`No item found in slot ${e}.`);this.setItem({slotIndex:t,item:n,forceSpace:r}),this.setItem({slotIndex:e,item:null,forceSpace:r})}removeItem({itemId:e,metadata:t=null,quantity:r=1}){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");if(null!==t&&"object"!=typeof t)throw new TypeError("`metadata` must be an object or null.");if("number"!=typeof r||!Number.isFinite(r)||r<=0)throw new TypeError("`quantity` must be a positive number.");let n=r;const i=(e,t)=>JSON.stringify(e)===JSON.stringify(t);for(let r=0;r<this.#Ti.length;r++){const o=this.#Ti[r];if(o&&o.id===e&&(null===t||i(o.metadata,t))){const e=Math.min(o.quantity,n);o.quantity-=e,n-=e;const t=Number(r);if(o.quantity<=0&&(this.#Ti[r]=null),n<=0)return this._cleanNulls(),this.#_i("remove",{index:t,item:this.#Li(o),isCollection:!0,specialSlot:null,remove:this.#Di({locationType:"normal",slotIndex:t,item:o})}),!0}}return this._cleanNulls(),this.#Ci.forEach((r,o)=>{if(n>0&&r.item&&r.item.id===e&&(null===t||i(r.item.metadata,t))){const e=Math.min(r.item.quantity,n);r.item.quantity-=e,r.item.quantity<0&&(r.item.quantity=0),n-=e,r.item.quantity<=0&&(r.item=null),this.#Ci.set(o,r),this.#_i("remove",{index:null,item:r.item?this.#Li(r.item):null,isCollection:!1,specialSlot:o,remove:r.item?this.#Di({locationType:"special",specialSlot:o,item:r.item}):()=>{}})}}),n<=0}#Di({locationType:e,specialSlot:t,slotIndex:r,item:n,forceSpace:i=!1}){if("normal"!==e&&"special"!==e)throw new TypeError("`locationType` must be 'normal' or 'special'.");if("boolean"!=typeof i)throw new TypeError("`forceSpace` must be boolean.");if(!n||"object"!=typeof n)throw new TypeError("`item` must be an InventoryItem object.");if("special"===e&&t&&"string"!=typeof t)throw new TypeError("`specialSlot` must be a string when locationType is 'special'.");if("normal"===e&&"number"!=typeof r)throw new TypeError("`slotIndex` must be a number when locationType is 'normal'.");return(o=i)=>{if("special"===e&&t){const e=this.#Ci.get(t);if(!e?.item)throw new Error(`Special slot '${t}' is empty.`);e.item.quantity>1?(e.item.quantity-=1,this.#Ci.set(t,e)):this.setSpecialSlot({slotId:t,item:null,forceSpace:o})}else{if("number"!=typeof r)throw new Error("Invalid remove operation: no valid slotIndex or specialSlot provided.");n.quantity>1?this.setItem({slotIndex:r,item:{...n,quantity:n.quantity-1},forceSpace:o}):this.setItem({slotIndex:r,item:null,forceSpace:o})}}}useItem({slotIndex:e,specialSlot:t,forceSpace:r=!1},...n){if(void 0!==e&&("number"!=typeof e||!Number.isInteger(e)))throw new TypeError("`slotIndex` must be an integer if provided.");if(void 0!==t&&"string"!=typeof t)throw new TypeError("`specialSlot` must be a string if provided.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be boolean.");let i=null,o="normal",s=null;if(t){if(!this.#Ci.has(t))throw new Error(`Special slot '${t}' not found.`);i=this.#Ci.get(t).item,o="special"}else s=this.#Ti,i=s[e??-1]??null,o="normal";if(!i)throw new Error("special"===o?`No item found in special slot '${t}'.`:`No item found in slot ${e} of inventory.`);const a=pr.getItem(i.id);if(a.onUse){const l={inventory:this,item:this.#Li(i),index:e??null,specialSlot:t??null,isCollection:!!s,itemDef:a,remove:this.#Di({locationType:o,specialSlot:t,slotIndex:e,forceSpace:r,item:i}),...n},u=a.onUse(l);return this.#_i("use",l),u}return null}hasSpecialSlot(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");return this.#Ci.has(e)}getSpecialItem(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(!this.#Ci.has(e))throw new Error(`Special slot '${e}' does not exist.`);const t=this.#Ci.get(e);return t?.item?this.#Li(t.item):null}getSpecialSlotType(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(!this.#Ci.has(e))throw new Error(`Special slot '${e}' does not exist.`);const t=this.#Ci.get(e);return t?.type??null}setSpecialSlot({slotId:e,item:t,forceSpace:r=!1}){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be boolean.");if(!this.#Ci.has(e))throw new Error(`Special slot '${e}' not found.`);const n=t&&"object"==typeof t&&"string"==typeof t.id&&"number"==typeof t.quantity&&!Number.isNaN(t.quantity)&&Number.isFinite(t.quantity)&&t.quantity>-1&&"object"==typeof t.metadata;if(null!==t&&!n)throw new Error("Invalid item type: must be null or a valid InventoryItem.");const i=t?pr.#xi.get(t.id):null;if(null!==t&&!i)throw new Error(`Item '${t?.id??"unknown"}' not defined in registry.`);const o=this.#Ci.get(e);if(!o)throw new Error(`Special slot ${e} out of range for slot '${e}'.`);const s=o.item?pr.#xi.get(o.item.id):null,a=(e,t)=>t?t.weight*(e?1:0):0,l=e=>e?1:0;if(!r&&!this.hasSpace({weight:a(t,i)-a(o.item,s),sizeLength:l(t)-l(o.item)}))throw new Error("Inventory is full or overweight.");o.item=t,this.#_i("set",{index:null,item:t?this.#Li(t):null,isCollection:!1,specialSlot:e,remove:t?this.#Di({locationType:"special",specialSlot:e,forceSpace:r,item:t}):()=>{}})}deleteSpecialItem(e,t=!1){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if("boolean"!=typeof t)throw new TypeError("`forceSpace` must be boolean.");this.setSpecialSlot({slotId:e,item:null,forceSpace:t})}equipItem({slotId:e,slotIndex:t,quantity:r=1,forceSpace:n=!1}){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if("number"!=typeof t||!Number.isInteger(t))throw new TypeError("`slotIndex` must be an integer.");if("number"!=typeof r||!Number.isFinite(r)||r<=0)throw new TypeError("`quantity` must be a positive number.");if("boolean"!=typeof n)throw new TypeError("`forceSpace` must be boolean.");if(r<=0||!Number.isFinite(r))throw new Error(`Invalid quantity '${r}'.`);if(!this.#Ci.has(e))throw new Error(`Special slot '${e}' does not exist.`);const i=this.getItemFrom(t);if(!i)throw new Error(`No item found in inventory slot ${t}.`);if(i.quantity<r)throw new Error(`Not enough quantity of item '${i.id}' in inventory slot.`);const o=pr.getItem(i.id),s=this.#Ci.get(e);if(!s)throw new Error(`Slot '${e}' not defined in registry.`);const a=s.type??null;if(null!==a&&o.type!==a)throw new Error(`Item '${i.id}' cannot be equipped in slot '${e}'.`);const l=Math.min(o.maxStack,this.#Ii);if(s.item&&s.item.id===i.id){const t=Math.max(0,l-s.item.quantity);if(t<=0)return r;const n=Math.min(r,t);return this.removeItem({itemId:i.id,quantity:n,metadata:null}),s.item.quantity+=n,this.#Ci.set(e,s),r-n}s.item&&this.unequipItem({slotId:e,forceSpace:n});const u=Math.min(r,l);return this.removeItem({itemId:i.id,quantity:u,metadata:null}),s.item={id:i.id,quantity:u,metadata:i.metadata},this.#Ci.set(e,s),r-u}unequipItem({slotId:e,quantity:t=null,forceSpace:r=!1}){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(null!==t&&("number"!=typeof t||!Number.isFinite(t)||t<=0))throw new TypeError("`quantity` must be a positive number or null.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be boolean.");if(!this.#Ci.has(e))throw new Error(`Special slot '${e}' does not exist.`);const n=this.#Ci.get(e);if(!n)throw new Error(`Slot '${e}' not defined in registry.`);if(!n.item)return!1;const i=n.item,o=null===t?i.quantity:t;if(o<=0)throw new Error(`Invalid unequip quantity: ${o}`);if(o>i.quantity)throw new Error(`Not enough items in slot '${e}' to unequip.`);return this.addItem({itemId:i.id,quantity:o,metadata:i.metadata,forceSpace:r}),o===i.quantity?n.item=null:(i.quantity-=o,n.item=i),this.#Ci.set(e,n),!0}#Li(e){if(!e||"object"!=typeof e)throw new TypeError("`item` must be an InventoryItem object.");if("string"!=typeof e.id)throw new TypeError("`item.id` must be a string.");if("number"!=typeof e.quantity||!Number.isFinite(e.quantity))throw new TypeError("`item.quantity` must be a finite number.");if(!e.metadata||"object"!=typeof e.metadata)throw new TypeError("`item.metadata` must be an object.");return{id:e.id,quantity:e.quantity,metadata:{...e.metadata}}}getItemList(){return[...this.#Ti].map((e,t)=>[e?this.#Li(e):null,t]).filter(e=>null!==e[0])}getAllItems(){const e=[...this.#Ti].filter(e=>null!==e).map(this.#Li);return this.#Ci.forEach(t=>{const r=t.item;r&&e.push(r)}),e}getItemsByMetadata(e){if("function"!=typeof e)throw new TypeError("`filterFn` must be a function.");return this.getAllItems().filter(t=>{const r=pr.getItem(t.id);return e(r.metadata,t)})}findItem(e){if("function"!=typeof e)throw new TypeError("`predicate` must be a function.");return this.getAllItems().find(e)}findItems(e){if("function"!=typeof e)throw new TypeError("`predicate` must be a function.");return this.getAllItems().filter(e)}getItemCount(e){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");return this.getAllItems().filter(t=>t.id===e).reduce((e,t)=>e+t.quantity,0)}hasItem(e,t=1){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");if("number"!=typeof t||!Number.isFinite(t)||t<0)throw new TypeError("`quantity` must be a non-negative number.");return this.getItemCount(e)>=t}existsItemAt(e){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");return!!this.#Ti[e]}clear(){this.clearAllItems(),this.clearAllEvents()}clearAllEvents(){this.#Ai={add:[],remove:[],use:[],set:[]}}clearAllItems(){this.clearItems(),this.clearSpecialItems()}clearItems(){for(let e=this.#Ti.length-1;e>=0;e--)this.#Ti[e]&&this.deleteItem(e,!0)}clearSpecialItems(){for(const e of this.#Ci.keys()){const t=this.#Ci.get(e);t?.item&&this.deleteSpecialItem(e,!0)}}clone(){const e=this.toObject();return pr.fromObject(e)}toObject(){const e={};for(const[t,r]of this.#Ci.entries())e[t]={type:r?.type??null,item:r?.item?this.#Li(r.item):null};return{__schema:"TinyInventory",version:1,maxWeight:this.#Ni,maxSlots:this.#Mi,maxSize:this.#ki,maxStack:this.#Ii,items:this.#Ti.map(e=>e?this.#Li(e):null),specialSlots:e}}toJSON(e=0){if("number"!=typeof e||!Number.isFinite(e)||e<0)throw new TypeError("`space` must be a non-negative number.");return JSON.stringify(this.toObject(),null,e)}static fromObject(e){if(!e||"object"!=typeof e)throw new TypeError("Invalid state: expected object.");if("TinyInventory"!==e.__schema||"number"!=typeof e.version)throw new TypeError("Invalid or missing schema header.");if(1!==e.version)throw new TypeError(`Unsupported TinyInventory state version: ${e.version}`);const t={};if(e.specialSlots&&"object"==typeof e.specialSlots)for(const r of Object.keys(e.specialSlots))t[r]={type:e.specialSlots[r]?.type??null};const r=new pr({maxWeight:e.maxWeight??null,maxSlots:e.maxSlots??null,maxSize:e.maxSize??null,maxStack:e.maxStack??null,specialSlots:t});if(Array.isArray(e.items))for(const t in e.items){const n=e.items[t];if(null!==n){const e={id:String(n.id),quantity:Math.max(1,Number(n.quantity)||1),metadata:n.metadata&&"object"==typeof n.metadata?n.metadata:{}};r.setItem({slotIndex:Number(t),item:e,forceSpace:!0})}else r.setItem({slotIndex:Number(t),item:null,forceSpace:!0})}if(e.specialSlots&&"object"==typeof e.specialSlots)for(const[t,n]of Object.entries(e.specialSlots)){if(!r.hasSpecialSlot(t))continue;const e=n?.item;if(e&&e.id){const n={id:String(e.id),quantity:Math.max(1,Number(e.quantity)||1),metadata:e.metadata&&"object"==typeof e.metadata?e.metadata:{}};r.setSpecialSlot({slotId:t,item:n,forceSpace:!0})}}return r}static fromJSON(e){if("string"!=typeof e)throw new TypeError("`json` must be a string.");const t=JSON.parse(e);return pr.fromObject(t)}}const fr=pr,gr=class{#ji=null;#Ri=null;get sender(){return this.#ji}get receiver(){return this.#Ri}set sender(e){if(!(e instanceof fr&&this.receiver instanceof fr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#ji=e}set receiver(e){if(!(this.sender instanceof fr&&e instanceof fr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Ri=e}constructor(e,t){if(e||t){if(!(e instanceof fr&&t instanceof fr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.connect(e,t)}}connect(e,t){if(!(e instanceof fr&&t instanceof fr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#ji=e,this.#Ri=t}disconnect(){this.#ji=null,this.#Ri=null}invert(){const e=this.#ji,t=this.#Ri;this.#ji=t,this.#Ri=e}transferItem({slotIndex:e,specialSlot:t,quantity:r=1,receiverSlotIndex:n,forceSpace:i=!1,strict:o=!1}){if(!this.#ji||!this.#Ri)throw new Error("Sender and receiver inventories must be connected.");let s;if(t){if(s=this.#ji.getSpecialItem(t),!s)throw new Error(`No item found in sender special slot '${t}'.`)}else{if("number"!=typeof e)throw new Error("Must provide either slotIndex or specialSlot.");if(s=this.#ji.getItemFrom(e),!s)throw new Error(`No item found in sender slot ${e}.`)}if(s.quantity<r)throw new Error(`Sender does not have enough quantity of '${s.id}' to transfer.`);const a={id:s.id,quantity:r,metadata:s.metadata};let l;if(o)if("number"==typeof n){const e=this.#Ri.existsItemAt(n)?this.#Ri.getItemFrom(n):null;if(e){if(e.id!==a.id)throw new Error(`Receiver slot ${n} contains a different item.`);const t=fr.getItem(e.id).maxStack-e.quantity;if(a.quantity>t)throw new Error(`Strict mode: not enough space in receiver slot ${n}.`)}}else if(this.#Ri.clone().addItem({itemId:a.id,quantity:a.quantity,metadata:a.metadata,forceSpace:i}).remaining>0)throw new Error("Strict mode: not enough space in receiver inventory.");if("number"==typeof n){const e=this.#Ri.existsItemAt(n)?this.#Ri.getItemFrom(n):null;let t=a.quantity;if(e){if(e.id!==a.id)throw new Error(`Receiver slot ${n} contains a different item.`);const r=fr.getItem(e.id).maxStack-e.quantity;t=Math.min(r,a.quantity),t>0&&this.#Ri.setItem({slotIndex:n,item:{...e,quantity:e.quantity+t},forceSpace:i})}else this.#Ri.setItem({slotIndex:n,item:a,forceSpace:i});l={remaining:a.quantity-t}}else l=this.#Ri.addItem({itemId:a.id,quantity:a.quantity,metadata:a.metadata,forceSpace:i});const u=a.quantity-l.remaining;if(u>0)if(t)this.#ji.unequipItem({slotId:t,quantity:u,forceSpace:i});else if("number"==typeof e){const t=s.quantity-u;this.#ji.setItem({slotIndex:e,item:t>0?{...s,quantity:t}:null,forceSpace:i})}return l}transferMultiple(e){return e.map(e=>this.transferItem(e))}},yr=class{#Hi;#Pi={message:"We use cookies to improve your experience.",acceptText:"Accept All",rejectText:"Reject All",settingsText:"Manage Settings",categories:[],storageKey:"cookie-consent-preferences",onSave:e=>console.log("Preferences saved:",e),animationDuration:400,renderBar:null,renderModal:null};get preferences(){const e=localStorage.getItem(this.#Pi.storageKey);return e?JSON.parse(e):{}}get config(){return{...this.#Pi,categories:[...this.#Pi.categories]}}set config(e){this.validateConfig(e),this.#Pi=Object.assign(this.#Pi,e)}constructor(e){if(!e||"object"!=typeof e)throw new TypeError("Config must be an object.");this.config=e;const t=this.loadPreferences();this.#Hi=t??{},t||this.showConsentBar()}validateConfig(e){if(void 0!==e.message&&"string"!=typeof e.message)throw new TypeError("Config.message must be a string.");if(["acceptText","rejectText","settingsText","storageKey"].forEach(t=>{if(void 0!==e[t]&&"string"!=typeof e[t])throw new TypeError(`Config.${t} must be a string.`)}),void 0!==e.categories){if(!Array.isArray(e.categories))throw new TypeError("Config.categories must be an array of Category objects.");e.categories.forEach((e,t)=>this.validateCategory(e,t))}if(void 0!==e.onSave&&"function"!=typeof e.onSave)throw new TypeError("Config.onSave must be a function.");if(void 0!==e.animationDuration&&("number"!=typeof e.animationDuration||e.animationDuration<0))throw new TypeError("Config.animationDuration must be a positive number.");if(void 0!==e.renderBar&&null!==e.renderBar&&"function"!=typeof e.renderBar)throw new TypeError("Config.renderBar must be a function or null.");if(void 0!==e.renderModal&&null!==e.renderModal&&"function"!=typeof e.renderModal)throw new TypeError("Config.renderModal must be a function or null.")}validateCategory(e,t){if(!e||"object"!=typeof e)throw new TypeError(`Category at index ${t} must be an object.`);if("string"!=typeof e.label)throw new TypeError(`Category.label at index ${t} must be a string.`);if("boolean"!=typeof e.required)throw new TypeError(`Category.required at index ${t} must be a boolean.`);if("boolean"!=typeof e.default)throw new TypeError(`Category.default at index ${t} must be a boolean.`)}loadPreferences(){const e=localStorage.getItem(this.#Pi.storageKey);return e?JSON.parse(e):null}removeWithAnimation(e){if(!(e instanceof HTMLElement))throw new TypeError("removeWithAnimation expects an HTMLElement.");e.classList.add("closing"),setTimeout(()=>e.remove(),this.#Pi.animationDuration)}savePreferences(e){if(!e||"object"!=typeof e)throw new TypeError("Preferences must be an object.");localStorage.setItem(this.#Pi.storageKey,JSON.stringify(e)),this.#Pi.onSave(e)}showConsentBar(){const e=document.createElement("div");e.className="cookie-consent-bar",e.innerHTML=this.#Pi.renderBar?this.#Pi.renderBar(this.#Pi):`\n <div><p>${this.#Pi.message}</p></div>\n <div><button class="accept">${this.#Pi.acceptText}</button></div>\n <div><button class="reject">${this.#Pi.rejectText}</button></div>\n <div><button class="settings">${this.#Pi.settingsText}</button></div>\n `,document.body.appendChild(e);const t=e.querySelector(".accept");t instanceof HTMLElement&&(t.onclick=()=>{const t={};this.#Pi.categories.forEach(e=>t[e.label]=!0),this.savePreferences(t),this.removeWithAnimation(e)});const r=e.querySelector(".reject");r instanceof HTMLElement&&(r.onclick=()=>{const t={};this.#Pi.categories.forEach(e=>t[e.label]=e.required),this.savePreferences(t),this.removeWithAnimation(e)});const n=e.querySelector(".settings");n instanceof HTMLElement&&(n.onclick=()=>this.showSettingsModal(e))}showSettingsModal(e){const t=document.createElement("div");t.className="cookie-consent-modal",t.innerHTML=this.#Pi.renderModal?this.#Pi.renderModal(this.#Pi):`\n <div class="modal-content">\n <h2>Cookie Settings</h2>\n <form class="settings-form">\n ${this.#Pi.categories.map(e=>`\n <label>\n <input type="checkbox" name="${e.label}" \n ${e.default?"checked":""} \n ${e.required?"disabled":""}>\n ${e.label}\n </label>\n `).join("")}\n </form>\n <button class="save">Save Preferences</button>\n </div>\n `,document.body.appendChild(t);const r=t.querySelector(".save");r instanceof HTMLElement&&(r.onclick=()=>{const r={};t.querySelectorAll("input[type=checkbox]").forEach(e=>{e instanceof HTMLInputElement&&(r[e.name]=e.checked)}),this.savePreferences(r),this.removeWithAnimation(t),e&&this.removeWithAnimation(e)})}isAllowed(e){if("string"!=typeof e)throw new TypeError("isAllowed expects a string as category.");return!!this.#Hi&&!!this.#Hi[e]}};var wr=r(911),br=r(766);const vr=class{static async mergeLocaleFiles({files:e,output:t,spaces:r=0}){if("number"!=typeof r||Number.isNaN(r)||r<0)throw new TypeError('mergeLocaleFiles: "spaces" must be a non-negative number');if(!Array.isArray(e)||0===e.length)throw new TypeError('mergeLocaleFiles: "files" must be a non-empty array of file paths');if("string"!=typeof t||!t)throw new TypeError('mergeLocaleFiles: "output" must be a non-empty string path');const n={};for(const t of e){if("string"!=typeof t||!t)throw new TypeError("mergeLocaleFiles: each file path must be a non-empty string");if(!(0,br.existsSync)(t))throw new Error(`mergeLocaleFiles: file "${t}" does not exist`);const e=await(0,wr.readFile)(t,"utf-8");let r;try{r=JSON.parse(e)}catch(e){throw new Error(`mergeLocaleFiles: file "${t}" is not valid JSON`)}Object.assign(n,r)}await(0,wr.writeFile)(t,JSON.stringify(n,null,r),"utf-8")}#$i;#Oi;#Fi=null;#Bi;#zi=null;#Wi=new Map;#qi=new Map;#Vi=new Map;#Ki=new Map;get currentLocale(){return this.#Fi}get defaultLocale(){return this.#Oi}get mode(){return this.#$i}get strict(){return this.#Bi}get basePath(){return this.#zi}get stats(){const e=[];for(const t of this.#Wi.keys())e.push(this.getStatsForLocale(t));return e}get stringTables(){const e={};for(const[t,r]of this.#Wi.entries())e[t]=this.#Ji(r);return e}get patternTables(){const e={};for(const[t,r]of this.#qi.entries())e[t]=r.map(e=>({$pattern:new RegExp(e.$pattern.source,e.$pattern.flags),value:this.#Ji(e.value),elseValue:this.#Ji(e.elseValue)}));return e}get helpers(){const e={};for(const[t,r]of this.#Vi.entries())e[t]=r;return e}get regexCache(){const e={};for(const[t,r]of this.#Ki.entries())e[t]=new RegExp(r.source,r.flags);return e}#Ji(e){if(null==e||"string"==typeof e||"function"==typeof e||"number"==typeof e)return e;if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e))return e.map(e=>this.#Ji(e));if("object"==typeof e){const t={};for(const[r,n]of Object.entries(e))t[r]=this.#Ji(n);return t}return e}#Ui(e){if(void 0!==e&&"string"!=typeof e)throw new TypeError('#resolveOrder: "forceLocale" must be a string if provided');const t=[];return e&&"string"==typeof e&&this.#Wi.has(e)?t.push(e):this.#Fi&&t.push(this.#Fi),t.push(this.#Oi),t}#Gi(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError('#resolveExact: "order" must be an array of strings');if("string"!=typeof t||!t)throw new TypeError('#resolveExact: "key" must be a non-empty string');for(const r of e){const e=this.#Wi.get(r);if(e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}}#Yi(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError('#resolveByPattern: "order" must be an array of strings');if("string"!=typeof t||!t)throw new TypeError('#resolveByPattern: "key" must be a non-empty string');for(const r of e){const e=this.#qi.get(r)||[];for(const r of e)return r.$pattern.test(t)?r.value:r.elseValue??void 0}}#Xi(e,t){if(null==e){if(this.#Bi)throw new TypeError('#materialize: "value" cannot be null or undefined');return""}if("string"==typeof e)return this.#Qi(e,t);if("function"==typeof e)return e(t??{},this.#Zi());if(e&&"object"==typeof e&&"string"==typeof e.$fn){const r=this.#Vi.get(e.$fn);if("function"!=typeof r){if(this.#Bi)throw new Error(`TinyI18: helper "${e.$fn}" is not registered`);return""}return r({...t??{},args:void 0!==e.args?e.args:void 0},this.#Zi())}if(this.#Bi)throw new Error("TinyI18: unsupported entry type");return""}#Qi(e,t){if("string"!=typeof e)throw new TypeError('#interpolate: "template" must be a string');if(void 0!==t&&(null===t||"object"!=typeof t))throw new TypeError('#interpolate: "params" must be an object if provided');return t&&"object"==typeof t?e.replace(/\{([a-zA-Z0-9_.$-]+)\}/g,(e,r)=>{const n=this.#eo(t,r);return null==n?"":String(n)}):e}#eo(e,t){if(!e||"object"!=typeof e)throw new TypeError('#dotGet: "obj" must be an object');if("string"!=typeof t||!t)throw new TypeError('#dotGet: "path" must be a non-empty string');const r=t.split(".");let n=e;for(const e of r){if(null==n)return;n=n[e]}return n}#Zi(){return{has:e=>this.#Vi.has(e),call:(e,t,r)=>{const n=this.#Vi.get(e);if("function"!=typeof n)throw new Error(`Helper "${e}" not found`);return n(t,r??{})}}}#to(e,t){if("string"!=typeof e||!e)throw new TypeError('#ingestLocale: "locale" must be a non-empty string');if(!t||"object"!=typeof t)throw new TypeError('#ingestLocale: "raw" must be an object');if("string"!=typeof e||!e)throw new TypeError("#ingestLocale: invalid locale");if(!t||"object"!=typeof t)throw new TypeError('#ingestLocale: "raw" must be an object');const r={...this.#Wi.get(e)??{}},n=[...this.#qi.get(e)??[]],i=(e,t)=>{if(null!=t)if("string"==typeof t||"function"==typeof t||t&&"object"==typeof t&&"string"==typeof t.$fn){if(!e)throw new TypeError("Leaf value requires a key path");r[e]=t}else if(t&&"object"==typeof t){if(t.$pattern instanceof RegExp&&Object.prototype.hasOwnProperty.call(t,"value"))return void n.push({$pattern:t.$pattern,value:t.value,elseValue:t.elseValue});for(const[r,n]of Object.entries(t))i(e?`${e}.${r}`:r,n)}};i("",t),this.#Wi.set(e,r),this.#qi.set(e,n),this.#Wi.has(this.#Oi)||(this.#Wi.set(this.#Oi,{}),this.#qi.set(this.#Oi,[]))}#ro(e){if("string"!=typeof e||!e)throw new TypeError('#unloadLocale: "locale" must be a non-empty string');e!==this.#Oi&&(this.#Wi.delete(e),this.#qi.delete(e))}async#no(e){if("string"!=typeof e||!e)throw new TypeError('#loadLocaleFromFile: "locale" must be a non-empty string');if("string"!=typeof this.#zi||!this.#zi)throw new TypeError('#loadLocaleFromFile: "this.#basePath" must be a non-empty string');const t=(0,ue.join)(this.#zi,`${e}.json`);let r;try{const e=await(0,wr.readFile)(t,"utf8");r=JSON.parse(e)}catch(r){if(!(r instanceof Error))return;if(this.#Bi)throw new Error(`TinyI18: failed to load or parse ${t}: ${r.message}`);return this.#Wi.set(e,{}),void this.#qi.set(e,[])}const n={...this.#Wi.get(e)??{}},i=[...this.#qi.get(e)??[]],o=(e,t)=>{if(null!=t){if(t&&"object"==typeof t&&"string"==typeof t.$pattern&&Object.prototype.hasOwnProperty.call(t,"value")){const e=this.#io(t.$pattern);return void i.push({$pattern:e,value:this.#oo(t.value),elseValue:this.#oo(t.elseValue)})}if("string"==typeof t||t&&"object"==typeof t&&"string"==typeof t.$fn){if(!e)throw new TypeError("Leaf value requires a key path");n[e]=this.#oo(t)}else if(t&&"object"==typeof t)for(const[r,n]of Object.entries(t))o(e?`${e}.${r}`:r,n)}};o("",r),this.#Wi.set(e,n),this.#qi.set(e,i)}#io(e){if("string"!=typeof e||!e)throw new TypeError('#safeRegExp: "src" must be a non-empty string');const t=this.#Ki.get(e);if(t)return t;try{const t=new RegExp(e);return this.#Ki.set(e,t),t}catch{if(this.#Bi)throw new Error(`TinyI18: invalid regex "${e}" in file`);return/^$/}}#oo(e){if("string"==typeof e)return e;if(e&&"object"==typeof e&&"string"==typeof e.$fn)return{$fn:String(e.$fn),args:e.args};if(this.#Bi)throw new Error("TinyI18: unsupported value in file JSON");return""}constructor(e){if(!e||"object"!=typeof e)throw new TypeError("TinyI18: options must be an object");const{mode:t,defaultLocale:r,basePath:n,localResources:i,strict:o=!0}=e;if("local"!==t&&"file"!==t)throw new TypeError('TinyI18: "mode" must be "local" or "file"');if("string"!=typeof r||!r)throw new TypeError('TinyI18: "defaultLocale" must be a non-empty string');if("boolean"!=typeof o)throw new TypeError('TinyI18: "strict" must be a boolean');if("file"===t){if("string"!=typeof n||!n)throw new TypeError('TinyI18: "basePath" is required in file mode');this.#zi=n}if(this.#$i=t,this.#Oi=r,this.#Bi=o,"local"===t&&i&&"object"==typeof i)for(const[e,t]of Object.entries(i))this.#to(e,t);this.#Wi.has(this.#Oi)||(this.#Wi.set(this.#Oi,{}),this.#qi.set(this.#Oi,[]))}clearRegexCache(){this.#Ki.clear()}registerHelper(e,t){if("string"!=typeof e||!e)throw new TypeError('registerHelper: "name" must be non-empty string');if("function"!=typeof t)throw new TypeError('registerHelper: "fn" must be a function');this.#Vi.set(e,t)}unregisterHelper(e){if("string"!=typeof e||!e)throw new TypeError('unregisterHelper: "name" must be non-empty string');return this.#Vi.delete(e)}loadLocaleLocal(e,t){if("local"!==this.#$i)throw new TypeError('loadLocaleLocal is only available in "local" mode');this.#to(e,t)}async setLocale(e){if(null!==e&&("string"!=typeof e||!e))throw new TypeError('setLocale: "locale" must be string or null');const t=this.#Fi;null!==e&&("file"===this.#$i?await this.#no(e):this.#Wi.has(e)||(this.#Wi.set(e,{}),this.#qi.set(e,[]))),"file"===this.#$i&&t&&t!==this.#Oi&&t!==e&&this.#ro(t),this.#Fi=e}t(e,t=void 0,r=void 0){return this.get(e,t,r)}get(e,t=void 0,r=void 0){if("string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:n}=r||{},i=this.#Ui(n);let o=this.#Gi(i,e);if(void 0===o){if(this.#Bi)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return this.#Xi(o,t)}p(e,t){return this.resolveByPattern(e,t)}resolveByPattern(e,t){if("string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:r}=t||{},n=this.#Ui(r);let i=this.#Yi(n,e);if(void 0===i){if(this.#Bi)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return i}resetToDefaultOnly(){if("file"===this.#$i)for(const e of Array.from(this.#Wi.keys()))e!==this.#Oi&&this.#ro(e);this.#Fi=null}getStatsForLocale(e){if("string"!=typeof e||!e)throw new TypeError('getStatsForLocale: "locale" must be a non-empty string');if(!this.#Wi.has(e))throw new Error(`getStatsForLocale: locale "${e}" is not registered`);return{locale:e,strings:Object.keys(this.#Wi.get(e)??{}).length,patterns:this.#qi.get(e)?.length??0,isDefault:e===this.#Oi,isCurrent:e===this.#Fi}}};class Er{#so=new Map;#ao;#lo;#uo;get factors(){const e={};for(let[t,r]of this.#so.entries())e[t]={...r};return e}get currentPercent(){return this.#lo/this.#ao*100}set maxValue(e){if("number"!=typeof e||Number.isNaN(e)||e<=0)throw new TypeError("maxValue must be a positive number.");this.#ao=e,this.#lo=Math.min(this.#lo,e)}get maxValue(){return this.#ao}get currentValue(){return this.#lo}set infiniteValue(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("infiniteValue must be a number.");this.#uo=e,this.#lo=Math.max(0,e),this.#lo=Math.min(this.#lo,this.#ao)}get infiniteValue(){return this.#uo}constructor(e=100,t=1,r=1){if("number"!=typeof e||Number.isNaN(e)||e<=0)throw new TypeError("maxValue must be a positive number.");this.#ao=e,this.setFactor("main",t,r),this.#lo=e,this.#uo=e}getFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");const t=this.#so.get(e);if(!t)throw new Error(`Factor with key "${e}" not found.`);return{...t}}hasFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");return this.#so.has(e)}setFactor(e,t,r=1){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");if("number"!=typeof t||Number.isNaN(t))throw new TypeError("Amount must be a valid number.");if("number"!=typeof r||Number.isNaN(r))throw new TypeError("Multiplier must be a valid number.");this.#so.set(e,{amount:t,multiplier:r})}removeFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");return this.#so.delete(e)}#co(e){const t=this.#uo;return this.#uo-=e,this.#lo=Math.max(0,this.#lo-e),{prevValue:t,removedTotal:e,removedPercent:e/this.#ao*100,currentPercent:this.currentPercent,remainingValue:this.#lo,infiniteRemaining:this.#uo}}tick(){let e=0;for(let[t,r]of this.#so.entries())e+=r.amount*r.multiplier;return this.#co(e)}tickWithTempFactor(e){if("object"!=typeof e||null===e)throw new TypeError("You must provide a valid factor object.");if("number"!=typeof e.amount||Number.isNaN(e.amount))throw new TypeError('Temp factor "amount" must be a valid number.');if("multiplier"in e&&("number"!=typeof e.multiplier||Number.isNaN(e.multiplier)))throw new TypeError('Temp factor "multiplier" must be a valid number if provided.');let t=0;for(let[e,r]of this.#so.entries())t+=r.amount*r.multiplier;return e&&(t+=e.amount*(e.multiplier??1)),this.#co(t)}tickSingleFactor(e){if("object"!=typeof e||null===e)throw new TypeError("You must provide a valid factor object.");if("number"!=typeof e.amount||Number.isNaN(e.amount))throw new TypeError('Temp factor "amount" must be a valid number.');if("multiplier"in e&&("number"!=typeof e.multiplier||Number.isNaN(e.multiplier)))throw new TypeError('Temp factor "multiplier" must be a valid number if provided.');if(!e)throw new Error("You must provide a factor to apply.");const t=e.amount*(e.multiplier??1);return this.#co(t)}toJSON(){return{maxValue:this.#ao,currentValue:this.#lo,infiniteValue:this.#uo,factors:this.factors}}static fromJSON(e){const t=new Er(e.maxValue,0,0);t.infiniteValue=e.infiniteValue,t.#so.clear();for(const[r,n]of Object.entries(e.factors))t.setFactor(r,n.amount,n.multiplier);return t}clone(){return Er.fromJSON(this.toJSON())}clearFactors(){this.#so.clear()}}const Tr=Er;class Sr{static _safeEvaluate(e){if(!/^[\d+\-*/%.()\s^]+$/.test(e))throw new Error(`Invalid characters in expression: "${e}"`);const t=e.replace(/\^/g,"**");try{return Function(`"use strict"; return (${t})`)()}catch(t){if(!(t instanceof Error))throw new Error("Unknown Error");throw new Error(`Invalid expression "${e}": ${t.message}`)}}static replaceValues(e,t){let r=0;return e.replace(/(\d*)d(\d+)/g,(e,n)=>{const i=n?Number(n):1;let o=0;for(let e=0;e<i;e++){const e=t[r++];o+=void 0!==e?e:0}return String(o)})}static tokenizeValues(e,t){const r=Sr.replaceValues(e,t),n=[],i=/\d+|[()+\-*/]/g;let o;for(;null!==(o=i.exec(r));)/^\d+$/.test(o[0])?n.push(Number(o[0])):n.push(o[0]);return{tokens:n,text:r}}static parseString(e){if("string"!=typeof e)throw new TypeError("Input must be a string.");const t=e.split(",").map(e=>e.trim()).filter(Boolean),r=[],n=[];if(t.forEach((e,t)=>{const i=/\b(?:(\d+)?d(\d+))\b/g;let o;const s=[],a=e.replace(/\(([^()]+?\|[^()]+?)\)/g,(e,t)=>{const r="string"==typeof t?t.split("|").map(e=>e.trim()).filter(Boolean):[];if(0===r.length)throw new Error(`Invalid random-choice group: "${e}"`);return r[Math.floor(Math.random()*r.length)]});for(;null!==(o=i.exec(a));){const e=parseInt(o[1]||"1",10),r=parseInt(o[2],10);if(isNaN(r))throw new Error(`Invalid dice sides in expression "${o[0]}" at position ${t+1}.`);s.push({count:e,sides:r})}if(0===s.length&&Number.isNaN(parseFloat(a)))throw new Error(`Invalid dice expression at position ${t+1}: "${e}"`);r.push(...s),n.push({index:t,original:e,expression:a})}),0===r.length)throw new Error("Invalid dice amount.");return{sides:r,modifiers:n}}static applyModifiers(e,t){if(!Array.isArray(e)||!e.every(e=>"number"==typeof e&&!Number.isNaN(e)||p(e)&&"number"==typeof e.value&&!Number.isNaN(e.value)&&"number"==typeof e.sides&&!Number.isNaN(e.sides)))throw new TypeError("Bases must be a valid numbers.");if(!Array.isArray(t))throw new TypeError("Modifiers must be an array of modifier objects.");let r=0;const n=[],i=[...e];for(const e in t){const o=t[e];if("string"!=typeof o.expression)throw new Error("Each modifier must include an expression string.");const s=o.original,a=o.expression,l=[],u=[],c=[],h=e=>e.match(/\(\s*[^()]+\|\s*[^()]+\s*\)|\b\d*d\d+\b|[-+]?\d+(?:\.\d+)?|[+\-*/%^()]/g)||[],d=h(a),m=h(s),f=[...d],g=[],y=a.replace(/\b\d*d\d+\b/g,e=>{const t=e.split("d"),r=()=>{for(const t in d)if(d[t]===e&&g.indexOf(t)<0){g.push(t),c.push(Number(t));break}},n=e=>{if(e.value>e.sides)throw new Error(`Invalid dice roll: value (${e.value}) must be between 1 and ${e.sides}.`)};if(0===t[0].trim().length){const t=i.shift(),o="number"==typeof t?t:p(t)?t.value:0;p(t)&&n(t),l.push([o]);for(const t in f)if(f[t]===e){f[t]=String(o),u.push(Number(t));break}return r(),o}const o=[],s=Number(t[0]),a=["("];let h="(";for(let e=0;e<s;e++){const t=i.shift(),r="number"==typeof t?t:p(t)?t.value:0;p(t)&&n(t),a.push(String(r));const l=e<s-1?" + ":")";a.push(l),h+=`${r}${l}`,o.push(r)}for(const t in f){const r=Number(t);if(f[r]===e){f.splice(r,1,...a);let e=1;for(let t=0;t<s;t++)u.push(r+t+e),e++;break}}return l.push(o),r(),h});let w;try{w=Sr._safeEvaluate(y)}catch(e){if(!(e instanceof Error))throw new Error("Unknown Error");throw new Error(`Error evaluating expression "${y}" (from "${a}"): ${e.message}`)}n.push({rawTokensP:d,rawTokens:m,tokens:f,rawDiceTokenSlots:c,diceTokenSlots:u,dicesResult:l,total:w}),r+=w}return{final:r,steps:n}}static rollArrayIndex(e){const t=Array.isArray(e),r=e instanceof Set;if(!t&&!r)throw new TypeError("rollArrayIndex expects an array or Set.");return Math.floor(Math.random()*(t?e.length:e.size))}#ao;#ho;get maxValue(){return this.#ao}set maxValue(e){if(!Number.isInteger(e)||e<0)throw new TypeError("maxValue must be an integer greater than -1.");this.#ao=e}get allowZero(){return this.#ho}set allowZero(e){if("boolean"!=typeof e)throw new TypeError("allowZero must be a boolean.");this.#ho=e}constructor({maxValue:e,allowZero:t=!0}){if("boolean"!=typeof t)throw new TypeError("allowZero must be an boolean.");if(!Number.isInteger(e)||e<0)throw new TypeError("maxValue must be an integer greater than -1.");this.#ao=e,this.#ho=t}roll(){const e=this.#ho?0:1;return Math.floor(Math.random()*(this.#ao-e+1))+e}}const xr=Sr,Cr=class{#T=null;get overlay(){return this.#T}#do=null;get messageElement(){return this.#do}#R;get container(){return this.#R}#mo={fadeIn:null,fadeOut:null,zIndex:9999};get options(){return{...this.#mo}}set options(e){if("object"!=typeof e||null===e)throw new TypeError("options must be an object");if(void 0!==e.fadeIn&&null!==e.fadeIn&&("number"!=typeof e.fadeIn||e.fadeIn<0))throw new TypeError("fadeIn must be a non-negative number or null");if(void 0!==e.fadeOut&&null!==e.fadeOut&&("number"!=typeof e.fadeOut||e.fadeOut<0))throw new TypeError("fadeOut must be a non-negative number or null");if(void 0!==e.zIndex&&("number"!=typeof e.zIndex||!Number.isInteger(e.zIndex)))throw new TypeError("zIndex must be an integer number");this.#mo={fadeIn:e.fadeIn??null,fadeOut:e.fadeOut??null,zIndex:e.zIndex??9999}}#po="none";get status(){return this.#po}#fo="";get defaultMessage(){return this.#fo}set defaultMessage(e){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("defaultMessage must be a string or an HTMLElement");this.#fo=e}#go=null;get message(){return this.#go}#yo=!1;get allowHtmlText(){return this.#yo}set allowHtmlText(e){if("boolean"!=typeof e)throw new TypeError("allowHtmlText must be a boolean");this.#yo=e}#wo=null;get fadeInTimeout(){return null!==this.#wo}#bo=null;get fadeOutTimeout(){return null!==this.#bo}get visible(){return!!this.#T}#vo=null;get onChange(){return this.#vo}set onChange(e){if(null!==e&&"function"!=typeof e)throw new TypeError("onChange must be a function or null");this.#vo=e}_emitChange(){"function"==typeof this.#vo&&this.#vo(this.#po)}constructor(e=document.body){if(!(e instanceof HTMLElement))throw new TypeError("container must be an HTMLElement");this.#R=e}_updateMessage(e=this.#fo){if(!this.#do)throw new Error("messageElement is not initialized");if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");if(this.#go=e,"string"==typeof e)this.#yo?this.#do.innerHTML=e:this.#do.textContent=e;else{if(!this.#yo)throw new Error("HTMLElement messages require allowHtmlText = true");this.#do.textContent="",this.#do.appendChild(e)}}_removeOldClasses(){this.#T?.classList.remove("active"),this.#T?.classList.remove("fadeIn"),this.#T?.classList.remove("fadeOut")}start(e=this.#fo){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");if(!this.#T){this.#T=document.createElement("div"),this.#T.classList.add("loading-overlay"),this.#T.style.zIndex=String(this.#mo.zIndex);const t=document.createElement("div");t.classList.add("loading-container");const r=document.createElement("div");r.classList.add("loading-content");const n=document.createElement("div");n.classList.add("loading-spinner"),this.#do=document.createElement("div"),this.#do.classList.add("loading-message"),r.appendChild(n),r.appendChild(this.#do),t.appendChild(r),this.#T.appendChild(t),this.#R.appendChild(this.#T),this._removeOldClasses(),this.#po="fadeIn",this.#T.classList.add("fadeIn"),this._emitChange();const i=()=>{this._removeOldClasses(),this.#wo=null,this.#po="active",this.#T?.classList.add("active"),this._emitChange()};return"number"==typeof this.#mo.fadeIn?(this.#wo&&clearTimeout(this.#wo),this.#wo=setTimeout(i,this.#mo.fadeIn)):i(),this._updateMessage(e),!0}return this.#do&&this._updateMessage(e),!1}update(e=this.#fo){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");return!!this.#do&&(this._updateMessage(e),!0)}stop(){if(this.#T){this._removeOldClasses(),this.#po="fadeOut",this.#T.classList.add("fadeOut"),this._emitChange();const e=()=>{this._removeOldClasses(),this.#bo=null,this.#po="none",this.#T?.remove(),this.#T=null,this.#do=null,this.#go=null,this._emitChange()};return"number"==typeof this.#mo.fadeOut?(this.#bo&&clearTimeout(this.#bo),this.#bo=setTimeout(e,this.#mo.fadeOut)):e(),!0}return!1}};class Ar{static#Eo=/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;static#To=/^#([A-Fa-f0-9]{8})$/;static#So="(0|1|0?\\.\\d+)";static#xo="(0|[1-9]\\d?|1\\d{2}|2[0-4]\\d|25[0-5])";static#Co="(0|[1-9]\\d?|[1-2]\\d{2}|3[0-5]\\d|360)";static#Ao="(0|[1-9]?\\d|100)";static#Io=new RegExp(`^rgb\\(\\s*${Ar.#xo}\\s*,\\s*${Ar.#xo}\\s*,\\s*${Ar.#xo}\\s*\\)$`);static#ko=new RegExp(`^rgba\\(\\s*${Ar.#xo}\\s*,\\s*${Ar.#xo}\\s*,\\s*${Ar.#xo}\\s*,\\s*${Ar.#So}\\s*\\)$`);static#Mo=new RegExp(`^hsl\\(\\s*${Ar.#Co}\\s*,\\s*${Ar.#Ao}%\\s*,\\s*${Ar.#Ao}%\\s*\\)$`);static#No=new RegExp(`^hsla\\(\\s*${Ar.#Co}\\s*,\\s*${Ar.#Ao}%\\s*,\\s*${Ar.#Ao}%\\s*,\\s*${Ar.#So}\\s*\\)$`);static#Lo=new RegExp(`^hwb\\(\\s*${Ar.#Co}(deg|grad|rad|turn)?\\s*${Ar.#Ao}%\\s*${Ar.#Ao}%\\s*\\)$`);static#_o="(-?\\d+)";static#Do=new RegExp(`^lab\\(\\s*${Ar.#Ao}%?\\s*${Ar.#_o}%?\\s*${Ar.#_o}%?\\s*\\)$`);static#jo=new RegExp(`^lch\\(\\s*${Ar.#Ao}%?\\s*${Ar.#Ao}%?\\s*${Ar.#Co}(deg|grad|rad|turn)?\\s*\\)$`);static#Ro=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);static#Ho=new Set(["transparent","currentColor"]);static getNames(){return Array.from(Ar.#Ro)}static addName(e){const t=Ar.#Ro.size;return Ar.#Ro.add(e.toLowerCase()),Ar.#Ro.size>t}static removeName(e){return Ar.#Ro.delete(e.toLowerCase())}static hasName(e){return Ar.#Ro.has(e.toLowerCase())}static getSpecialNames(){return Array.from(Ar.#Ho)}static addSpecialName(e){const t=Ar.#Ho.size;return Ar.#Ho.add(e),Ar.#Ho.size>t}static removeSpecialName(e){return Ar.#Ho.delete(e)}static hasSpecialName(e){return Ar.#Ho.has(e)}#Po;get code(){return this.#Po}#$o;get type(){return this.#$o}constructor(e){this.#Po=e,this.#$o=Ar.isColor(this.#Po)}static isHex(e){if("string"!=typeof e)throw new TypeError("isHex: input must be a string.");return Ar.#Eo.test(e.trim())}isHex(){return Ar.isHex(this.#Po)}static isHexa(e){if("string"!=typeof e)throw new TypeError("isHexa: input must be a string.");return Ar.#To.test(e.trim())}isHexa(){return Ar.isHexa(this.#Po)}static isRgb(e){if("string"!=typeof e)throw new TypeError("isRgb: input must be a string.");return Ar.#Io.test(e.trim())}isRgb(){return Ar.isRgb(this.#Po)}static isRgba(e){if("string"!=typeof e)throw new TypeError("isRgba: input must be a string.");return Ar.#ko.test(e.trim())}isRgba(){return Ar.isRgba(this.#Po)}static isHsl(e){if("string"!=typeof e)throw new TypeError("isHsl: input must be a string.");return Ar.#Mo.test(e.trim())}isHsl(){return Ar.isHsl(this.#Po)}static isHsla(e){if("string"!=typeof e)throw new TypeError("isHsla: input must be a string.");return Ar.#No.test(e.trim())}isHsla(){return Ar.isHsla(this.#Po)}static isHwb(e){if("string"!=typeof e)throw new TypeError("isHwb: input must be a string.");return Ar.#Lo.test(e.trim())}isHwb(){return Ar.isHwb(this.#Po)}static isLab(e){if("string"!=typeof e)throw new TypeError("isLab: input must be a string.");return Ar.#Do.test(e.trim())}isLab(){return Ar.isLab(this.#Po)}static isLch(e){if("string"!=typeof e)throw new TypeError("isLch: input must be a string.");return Ar.#jo.test(e.trim())}isLch(){return Ar.isLch(this.#Po)}static isName(e){if("string"!=typeof e)throw new TypeError("isName: input must be a string.");return Ar.#Ro.has(e.trim().toLowerCase())}isName(){return Ar.isName(this.#Po)}static isSpecialName(e){if("string"!=typeof e)throw new TypeError("isSpecialName: input must be a string.");return Ar.#Ho.has(e.trim())}isSpecialName(){return Ar.isSpecialName(this.#Po)}static isColor(e){if("string"!=typeof e)throw new TypeError("isColor: input must be a string.");return Ar.isHex(e)?"hex":Ar.isHexa(e)?"hexa":Ar.isRgb(e)?"rgb":Ar.isRgba(e)?"rgba":Ar.isHsl(e)?"hsl":Ar.isHsla(e)?"hsla":Ar.isHwb(e)?"hwb":Ar.isLab(e)?"lab":Ar.isLch(e)?"lch":Ar.isName(e)?"name":Ar.isSpecialName(e)?"specialName":null}parse(){switch(this.#$o){case"hex":return Ar.parseHex(this.code);case"hexa":return Ar.parseHexa(this.code);case"rgb":return Ar.parseRgb(this.code);case"rgba":return Ar.parseRgba(this.code);case"hsl":return Ar.parseHsl(this.code);case"hsla":return Ar.parseHsla(this.code);case"hwb":return Ar.parseHwb(this.code);case"lab":return Ar.parseLab(this.code);case"lch":return Ar.parseLch(this.code);case"name":case"specialName":return this.#Po.trim().toLowerCase();default:return null}}static parseHex(e){if("string"!=typeof e)throw new TypeError("parseHex: input must be a string.");const t=new RegExp(Ar.#Eo,"gm").exec(e.trim());return t?t[1]:null}parseHex(){return Ar.parseHex(this.#Po)}static parseHexa(e){if("string"!=typeof e)throw new TypeError("parseHexa: input must be a string.");const t=new RegExp(Ar.#To,"gm").exec(e.trim());return t?t[1]:null}parseHexa(){return Ar.parseHexa(this.#Po)}static parseRgb(e){if("string"!=typeof e)throw new TypeError("parseRgb: input must be a string.");const t=new RegExp(Ar.#Io,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseRgb(){return Ar.parseRgb(this.#Po)}static parseRgba(e){if("string"!=typeof e)throw new TypeError("parseRgba: input must be a string.");const t=new RegExp(Ar.#ko,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])]:null}parseRgba(){return Ar.parseRgba(this.#Po)}static parseHsl(e){if("string"!=typeof e)throw new TypeError("parseHsl: input must be a string.");const t=new RegExp(Ar.#Mo,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseHsl(){return Ar.parseHsl(this.#Po)}static parseHsla(e){if("string"!=typeof e)throw new TypeError("parseHsla: input must be a string.");const t=new RegExp(Ar.#No,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])]:null}parseHsla(){return Ar.parseHsla(this.#Po)}static parseHwb(e){if("string"!=typeof e)throw new TypeError("parseHwb: input must be a string.");const t=new RegExp(Ar.#Lo,"gm").exec(e.trim());return t?[parseFloat(t[1]),t[2]??null,parseFloat(t[3]),parseFloat(t[4])]:null}parseHwb(){return Ar.parseHwb(this.#Po)}static parseLab(e){if("string"!=typeof e)throw new TypeError("parseLab: input must be a string.");const t=new RegExp(Ar.#Do,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseLab(){return Ar.parseLab(this.#Po)}static parseLch(e){if("string"!=typeof e)throw new TypeError("parseLch: input must be a string.");const t=new RegExp(Ar.#jo,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),t[4]??null]:null}parseLch(){return Ar.parseLch(this.#Po)}}const Ir=Ar,kr=class{#Oo;#Fo;#Bo;#Pi;#on=null;_getDate(){const e=new Date,t=e.getSeconds(),r=e.getMinutes(),n=e.getHours();return{now:e,s:t,m:r,h:n}}constructor(e={}){this.#Pi={bgColor:"#f0f0f0",borderColor:"#333",borderWidth:8,markColor:"#333",hourHandColor:"#000",minuteHandColor:"#444",secondHandColor:"#d81c1c",textColor:"#000",skinUrl:null,showNumbers:!0,showSeconds:!0,size:800,sizeAdjust:.04,padding:45,angleDistance:.95,pwH:.008,phH:.08,pwM:.005,phM:.03,...e},this.#Oo=document.createElement("div"),this.#Oo.className="analog-clock-container",this.#Oo.style.position="relative",this.#Oo.style.borderRadius="50%",this.#Oo.style.overflow="hidden",this.#Oo.style.boxSizing="border-box",this.#Bo=document.createElement("div"),this.#Bo.style.position="absolute",this.#Bo.style.inset="0",this.#Bo.style.backgroundSize="cover",this.#Bo.style.backgroundPosition="center",this.#Bo.style.zIndex="0",this.#Fo=document.createElement("div"),this.#Fo.style.position="absolute",this.#Fo.style.inset="0",this.#Fo.style.zIndex="1",this.#Fo.style.pointerEvents="none";const t=document.createElement("div");t.style.position="absolute",t.style.inset="0",t.style.zIndex="2",t.style.pointerEvents="none",t.innerHTML='\n <div class="hand hour-hand"></div>\n <div class="hand minute-hand"></div>\n <div class="hand second-hand"></div>\n <div class="center-pin"></div>\n ',this.#Oo.appendChild(this.#Bo),this.#Oo.appendChild(this.#Fo),this.#Oo.appendChild(t);const r=document.createElement("style");r.textContent="\n .analog-clock-container .hand {\n position: absolute;\n bottom: 50%;\n left: 50%;\n transform-origin: bottom center;\n border-radius: 4px;\n transform: translateX(-50%) rotate(0deg);\n z-index: 5;\n }\n .analog-clock-container .center-pin {\n position: absolute;\n top: 50%; left: 50%;\n width: 12px; height: 12px;\n background: #333;\n border-radius: 50%;\n transform: translate(-50%, -50%);\n z-index: 10;\n }\n .analog-clock-container .clock-mark {\n position: absolute;\n top: 50%; left: 50%;\n background: currentColor;\n transform-origin: center center;\n }\n .analog-clock-container .clock-number {\n position: absolute;\n top: 50%; left: 50%;\n transform: translate(-50%, -50%);\n font-family: sans-serif;\n font-weight: bold;\n text-align: center;\n line-height: 1;\n }\n ",this.#Oo.appendChild(r),this._applyConfig(),this._renderFace(),this._startTicker()}_applyConfig(){const e=this.#Oo.style,t=this.#Pi;e.width=`${t.size}px`,e.height=`${t.size}px`,e.border=`${t.borderWidth}px solid ${t.borderColor}`,e.backgroundColor=t.bgColor,t.skinUrl?(this.#Bo.style.backgroundImage=`url(${t.skinUrl})`,this.#Bo.style.display="block"):this.#Bo.style.display="none";const r=e=>{const t=this.#Oo.querySelector(e);if(!(t instanceof HTMLDivElement))throw new Error(`TinyAnalogClock: Element ${e} not found.`);return t},n=r(".hour-hand");n.style.backgroundColor=t.hourHandColor,n.style.width=.025*t.size+"px",n.style.height=.25*t.size+"px",n.style.marginLeft=.025*t.size/-2+"px",n.style.bottom="50%",n.style.left="50%",n.style.transformOrigin="bottom center";const i=r(".minute-hand");i.style.backgroundColor=t.minuteHandColor,i.style.width=.015*t.size+"px",i.style.height=.35*t.size+"px",i.style.marginLeft=.015*t.size/-2+"px";const o=r(".second-hand");t.showSeconds?(o.style.display="block",o.style.backgroundColor=t.secondHandColor,o.style.width=.005*t.size+"px",o.style.height=.4*t.size+"px",o.style.marginLeft=.005*t.size/-2+"px"):o.style.display="none",r(".center-pin").style.background=t.borderColor}_renderFace(){this.#Fo.innerHTML="";const e=this.#Pi.size/2-this.#Pi.borderWidth;for(let t=0;t<60;t++){const r=t%5==0,n=document.createElement("div");n.className="clock-mark";const i=r?this.#Pi.size*this.#Pi.pwH:this.#Pi.size*this.#Pi.pwM,o=r?this.#Pi.size*this.#Pi.phH:this.#Pi.size*this.#Pi.phM,s=this.#Pi.markColor;n.style.width=`${i}px`,n.style.height=`${o}px`,n.style.color=s;const a=e-this.#Pi.padding-o/2;n.style.transform=`translate(-50%, -50%) rotate(${6*t}deg) translate(0, -${a}px)`,this.#Fo.appendChild(n)}if(this.#Pi.showNumbers)for(let t=1;t<=12;t++){const r=30*t*(Math.PI/180),n=e*this.#Pi.angleDistance,i=e+Math.sin(r)*n,o=e-Math.cos(r)*n,s=document.createElement("div");s.className="clock-number",s.innerText=t.toString(),s.style.left=`${i}px`,s.style.top=`${o}px`,s.style.color=this.#Pi.textColor,s.style.fontSize=this.#Pi.size*this.#Pi.sizeAdjust+"px",this.#Fo.appendChild(s)}}_startTicker(){if(this.#on)return;const e=()=>{const{s:t,m:r,h:n}=this._getDate(),i=6*t,o=6*r+.1*t,s=n%12*30+.5*r,a=e=>{const t=this.#Oo.querySelector(e);if(!(t instanceof HTMLDivElement))throw new Error(`${e} not found.`);return t};this.#Oo.querySelector(".second-hand")&&(a(".second-hand").style.transform=`rotate(${i}deg)`),a(".minute-hand").style.transform=`rotate(${o}deg)`,a(".hour-hand").style.transform=`rotate(${s}deg)`,this.#on=requestAnimationFrame(e)};e()}get element(){return this.#Oo}set size(e){if("number"!=typeof e||e<=0||isNaN(e))throw new Error(`TinyAnalogClock: 'size' must be a positive number. Received: ${e}`);this.#Pi.size=e,this._applyConfig(),this._renderFace()}get size(){return this.#Pi.size}set skinUrl(e){if(null!==e&&"string"!=typeof e)throw new Error("TinyAnalogClock: 'skin' must be a URL string or null. Received type: "+typeof e);this.#Pi.skinUrl=e,this._applyConfig()}get skinUrl(){return this.#Pi.skinUrl}set borderColor(e){if("string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'borderColor' must be a non-empty string. Received: ${e}`);this.#Pi.borderColor=e,this._applyConfig(),this._renderFace()}get borderColor(){return this.#Pi.borderColor}set markColor(e){if("string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'markColor' must be a non-empty string. Received: ${e}`);this.#Pi.markColor=e,this._applyConfig(),this._renderFace()}get markColor(){return this.#Pi.markColor}set textColor(e){if("string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'textColor' must be a non-empty string. Received: ${e}`);this.#Pi.textColor=e,this._applyConfig(),this._renderFace()}get textColor(){return this.#Pi.textColor}set showNumbers(e){if("boolean"!=typeof e)throw new Error("TinyAnalogClock: 'showNumbers' must be a boolean. Received type: "+typeof e);this.#Pi.showNumbers=e,this._renderFace()}get showNumbers(){return this.#Pi.showNumbers}set bgColor(e){if("string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'bgColor' must be a non-empty string.");this.#Pi.bgColor=e,this._applyConfig()}get bgColor(){return this.#Pi.bgColor}set borderWidth(e){if("number"!=typeof e||e<0)throw new Error("TinyAnalogClock: 'borderWidth' must be a non-negative number.");this.#Pi.borderWidth=e,this._applyConfig(),this._renderFace()}get borderWidth(){return this.#Pi.borderWidth}set hourHandColor(e){if("string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'hourHandColor' must be a non-empty string.");this.#Pi.hourHandColor=e,this._applyConfig()}get hourHandColor(){return this.#Pi.hourHandColor}set minuteHandColor(e){if("string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'minuteHandColor' must be a non-empty string.");this.#Pi.minuteHandColor=e,this._applyConfig()}get minuteHandColor(){return this.#Pi.minuteHandColor}set secondHandColor(e){if("string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'secondHandColor' must be a non-empty string.");this.#Pi.secondHandColor=e,this._applyConfig()}get secondHandColor(){return this.#Pi.secondHandColor}set showSeconds(e){if("boolean"!=typeof e)throw new Error("TinyAnalogClock: 'showSeconds' must be a boolean.");this.#Pi.showSeconds=e,this._applyConfig()}get showSeconds(){return this.#Pi.showSeconds}set sizeAdjust(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'sizeAdjust' must be a positive number.");this.#Pi.sizeAdjust=e,this._renderFace()}get sizeAdjust(){return this.#Pi.sizeAdjust}set padding(e){if("number"!=typeof e||e<0)throw new Error("TinyAnalogClock: 'padding' must be a non-negative number.");this.#Pi.padding=e,this._renderFace()}get padding(){return this.#Pi.padding}set angleDistance(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'angleDistance' must be a positive number.");this.#Pi.angleDistance=e,this._renderFace()}get angleDistance(){return this.#Pi.angleDistance}set pwH(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'pwH' must be a positive number.");this.#Pi.pwH=e,this._renderFace()}get pwH(){return this.#Pi.pwH}set phH(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'phH' must be a positive number.");this.#Pi.phH=e,this._renderFace()}get phH(){return this.#Pi.phH}set pwM(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'pwM' must be a positive number.");this.#Pi.pwM=e,this._renderFace()}get pwM(){return this.#Pi.pwM}set phM(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'phM' must be a positive number.");this.#Pi.phM=e,this._renderFace()}get phM(){return this.#Pi.phM}destroy(){this.#on&&(cancelAnimationFrame(this.#on),this.#on=null),this.#Oo.remove()}},Mr=class{#zo=[];#ge=!1;get history(){return[...this.#zo]}set history(e){if(!Array.isArray(e))throw new TypeError("History data must be provided as an array.");if(!e.every(e=>"string"==typeof e))throw new TypeError("All items in the history array must be strings.");this.#zo=[...e]}get size(){return this.#zo.length}constructor(e=[]){this.history=e}#Wo(){if(this.#ge)throw new Error("Cannot perform operations on a destroyed TinyTextDiffer instance.")}#qo(e){if("number"!=typeof e)throw new TypeError("The provided index must be a valid number.")}#Vo(e){if("string"!=typeof e)throw new TypeError("The provided text must be a valid string.")}get(e){if(this.#Wo(),this.#qo(e),void 0===this.#zo[e])throw new Error(`No text version found at index ${e}.`);return this.#zo[e]}has(e){return this.#Wo(),this.#qo(e),void 0!==this.#zo[e]}add(e){this.#Wo(),this.#Vo(e),this.#zo.push(e)}remove(){return this.#Wo(),this.#zo.pop()}addAt(e,t){this.#Wo(),this.#qo(e),this.#Vo(t),this.#zo.splice(e,0,t)}removeAt(e){this.#Wo(),this.#qo(e);const t=this.#zo.length;return this.#zo.splice(e,1),t!==this.#zo.length}clear(){this.#Wo(),this.#zo=[]}compare(...e){this.#Wo();const t=e.length;if(0===t||t%2!=0)throw new Error("The compare method requires an even number of indices to form comparison pairs.");const r=[];for(let n=0;n<t;n+=2){const i=n+1;if(i>t-1)continue;this.#qo(e[n]),this.#qo(e[i]);const o=this.#zo[e[n]],s=this.#zo[e[i]];r.push(this._computeDiff(o,s))}return r}_computeDiff(e,t){const r=e.length,n=t.length,i=Array(r+1).fill(null).map(()=>Array(n+1).fill(0));let o=1,s=1;for(o=1;o<=r;o++)for(s=1;s<=n;s++)e[o-1]===t[s-1]?i[o][s]=i[o-1][s-1]+1:i[o][s]=Math.max(i[o-1][s],i[o][s-1]);o=r,s=n;const a=[];for(;o>0||s>0;)o>0&&s>0&&e[o-1]===t[s-1]?(a.unshift({value:e[o-1],type:"normal"}),o--,s--):s>0&&(0===o||i[o][s-1]>=i[o-1][s])?(a.unshift({value:t[s-1],type:"added"}),s--):o>0&&(0===s||i[o][s-1]<i[o-1][s])&&(a.unshift({value:e[o-1],type:"deleted"}),o--);return a.reduce((e,t)=>{const r=e.length-1;return e.length>0&&e[r].type===t.type?e[r].value+=t.value:e.push(t),e},[])}destroy(){this.#ge||(this.#zo=[],this.#ge=!0)}};class Nr{static generateHash(e){const t="object"==typeof e?JSON.stringify(e):String(e);let r=0;for(let e=0,n=t.length;e<n;e++)r=(r<<5)-r+t.charCodeAt(e),r|=0;return r.toString(36)}#Ko=[];get oldArray(){return this.#Ko}set oldArray(e){if(!Array.isArray(e))throw new TypeError("The provided oldArray must be a valid Array.");this.#Ko=e}constructor(e){void 0!==e&&(this.oldArray=e)}_generateHash(e){return Nr.generateHash(e)}compare(e){if(!Array.isArray(e))throw new TypeError("The provided newArray must be a valid Array.");const t={oldItemsMap:new Map,affectedItems:[]};for(const e of this.#Ko){const r=this._generateHash(e);t.oldItemsMap.set(r,e)}for(const r of e){const e=this._generateHash(r);t.oldItemsMap.has(e)?t.oldItemsMap.delete(e):t.affectedItems.push({item:r,status:"added"})}for(const e of t.oldItemsMap.values())t.affectedItems.push({item:e,status:"deleted"});return t.affectedItems}}const Lr=Nr,_r=e=>{if(!Array.isArray(e))throw new TypeError("Parameter 'sets' must be an array.");if(!e.every(e=>e instanceof Hr))throw new TypeError("All elements in the array must be instances of FuzzySet.")},Dr=(e,t,r=.5)=>{Rr(e,"object","defuzzifyCentroid.fuzzyOutput");for(const t in e)Rr(e[t],"number",`fuzzyOutput['${t}']`);_r(t),Rr(r,"number","defuzzifyCentroid.step");let n=0,i=0;for(let o=0;o<=100;o+=r){let r=0;t.forEach(t=>{const n=e[t.name]||0,i=Math.min(n,t.calculate(o));r=Math.max(r,i)}),n+=o*r,i+=r}return 0===i?0:n/i},jr=(e,t,r,n,i,o=!1)=>{if(o){if(e<=t||e>=i)return 0;if(e>=r&&e<=n)return 1}const s=t===r?1:(e-t)/(r-t),a=n===i?1:(i-e)/(i-n),l=Math.max(0,Math.min(s,1,a));return isNaN(l)?0:l},Rr=(e,t,r)=>{if(typeof e!==t)throw new TypeError(`Parameter '${r}' must be a ${t}.`)};class Hr{static trapezoid(e,t,r,n,i,o=!1){return jr(e,t,r,n,i,o)}#Jo="";#Uo=0;#Go=0;#Yo=0;#Xo=0;#Qo=!1;get name(){return this.#Jo}set name(e){Rr(e,"string","FuzzySet.name"),this.#Jo=e}get a(){return this.#Uo}set a(e){Rr(e,"number","FuzzySet.a"),this.#Uo=e}get b(){return this.#Go}set b(e){Rr(e,"number","FuzzySet.b"),this.#Go=e}get c(){return this.#Yo}set c(e){Rr(e,"number","FuzzySet.c"),this.#Yo=e}get d(){return this.#Xo}set d(e){Rr(e,"number","FuzzySet.d"),this.#Xo=e}get optimize(){return this.#Qo}set optimize(e){Rr(e,"boolean","FuzzySet.optimize"),this.#Qo=e}constructor(e,t,r,n,i,o=!1){this.name=e,this.a=t,this.b=r,this.c=n,this.d=i,this.optimize=o}calculate(e){return Rr(e,"number","calculate.x"),Hr.trapezoid(e,this.#Uo,this.#Go,this.#Yo,this.#Xo,this.#Qo)}}class Pr{#Zo=new Map;addVariable(e,t){Rr(e,"string","addVariable.name"),_r(t),this.#Zo.set(e,t)}removeVariable(e){return Rr(e,"string","removeVariable.name"),this.#Zo.delete(e)}getVariable(e){Rr(e,"string","getVariable.name");const t=this.#Zo.get(e);if(!t)throw new Error(`Linguistic variable '${e}' not found in the inference system.`);return[...t]}hasVariable(e){return Rr(e,"string","hasVariable.name"),this.#Zo.has(e)}fuzzify(e,t){Rr(e,"string","fuzzify.varName"),Rr(t,"number","fuzzify.value");const r=this.#Zo.get(e)||[],n={};return r.forEach(e=>{n[e.name]=e.calculate(t)}),n}}class $r{#es=new Set;get appliedPlugins(){if(this.#ts)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return[...this.#es]}#rs=[];get appliedPluginClasses(){if(this.#ts)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return[...this.#rs]}get size(){if(this.#ts)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return this.#rs.length}#ns;get currentClass(){if(this.#ts)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return this.#ns}#ts=!1;get used(){return this.#ts}constructor(e,t=[]){this.#ns=e,this.#rs=[...t,e]}#is(e,t,r){if(this.#ts)throw new Error("[TinyClassManager] Cannot reuse a consumed manager instance.");if(this.#es.has(e))throw new Error(`[TinyClassManager] Plugin conflict: "${e}" is already installed.`);for(const r of t)if(!this.#es.has(r))throw new Error(`[TinyClassManager] Missing Dependency: "${e}" requires "${r}" to be installed first.`);const n=new $r(r,this.#rs);return this.#es.forEach(e=>n.#es.add(e)),n.#es.add(e),this.#ts=!0,this.#es.clear(),this.#rs=[],n}use(e){const t=e.dependencies||[],r=e.apply(this.#ns,this.appliedPluginClasses);return this.#is(e.name,t,r)}insert(e){const t=e(this.#ns,this.appliedPluginClasses),r=t._tinyDepName;if(!r)throw new Error("[TinyClassManager] Plugin class must define a static '_tinyDepName' property.");const n=t._tinyDeps??[];if(!Array.isArray(n)||!n.every(e=>"string"==typeof e))throw new Error("[TinyClassManager] Plugin class must define a static array of strings in '_tinyDepName' property.");return this.#is(r,n,t)}build(){if(this.#ts)throw new Error("[TinyClassManager] Cannot build from an already finalized manager.");return this.#ts=!0,this.#es.clear(),this.#rs=[],this.#ns}}const Or=$r;class Fr extends Bt.EventEmitter{static async parseContent(e,t,r,n,i){return Lt(e,t,r,n,i,Fr.#os)}static#os="Unknown Artist";static get unknownArtist(){return Fr.#os}static set unknownArtist(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("unknownArtist must have an string or function.");Fr.#os=e}get size(){return this.#ss.length+this.#as.length}get musicSize(){return this.#ss.length}get voiceSize(){return this.#as.length}get customPosSize(){return this.#ls.length}get tasksSize(){return this.#us.length}get cycleCacheSize(){return this.#cs.size}#ss=[];get musicList(){return structuredClone(this.#ss)}#as=[];get voiceList(){return structuredClone(this.#as)}#ls=[];get customPositions(){return structuredClone(this.#ls)}#us=[];get scheduledTasks(){return structuredClone(this.#us)}get allList(){return[...this.musicList,...this.voiceList]}#pi=0;get seed(){return this.#pi}set seed(e){if("number"!=typeof e)throw new TypeError("Seed must be a number.");this.#pi=e,this.#cs.clear(),this.emit("seedChanged",{seed:e})}#hs=Date.now();get anchorDate(){return this.#hs}#cs=new Map;#Pi={mode:"playlist",voiceMode:"playlist",silenceDuration:0,queryLimit:1e5,voiceAfterMusic:!0,voiceMin:0,voiceMax:1,musicMaxConsecutive:0,voiceMaxConsecutive:0};get config(){return structuredClone(this.#Pi)}set config(e){this.#ds(e),this.#Pi=structuredClone(e),this.#cs.clear(),this.emit("configChanged",{config:this.config})}#ds(e){if("object"!=typeof e||null===e)throw new TypeError("Configuration must be a valid object.");const t=["playlist","random"];if(void 0!==e.mode&&!t.includes(e.mode))throw new TypeError(`Invalid mode: "${e.mode}". Must be one of: ${t.join(", ")}.`);if(void 0!==e.voiceMode&&!t.includes(e.voiceMode))throw new TypeError(`Invalid voiceMode: "${e.voiceMode}". Must be one of: ${t.join(", ")}.`);if(void 0!==e.silenceDuration&&("number"!=typeof e.silenceDuration||e.silenceDuration<0))throw new TypeError("silenceDuration must be a non-negative number.");if(void 0!==e.queryLimit&&("number"!=typeof e.queryLimit||e.queryLimit<=0))throw new TypeError("queryLimit must be a positive number.");if(void 0!==e.voiceAfterMusic&&"boolean"!=typeof e.voiceAfterMusic)throw new TypeError("voiceAfterMusic must be a boolean.");if(void 0!==e.voiceMin&&("number"!=typeof e.voiceMin||e.voiceMin<0))throw new TypeError("voiceMin must be a non-negative number.");if(void 0!==e.voiceMax&&("number"!=typeof e.voiceMax||e.voiceMax<0))throw new TypeError("voiceMax must be a non-negative number.");if(void 0!==e.musicMaxConsecutive&&("number"!=typeof e.musicMaxConsecutive||e.musicMaxConsecutive<-1))throw new TypeError("musicMaxConsecutive must be a number >= -1.");if(void 0!==e.voiceMaxConsecutive&&("number"!=typeof e.voiceMaxConsecutive||e.voiceMaxConsecutive<-1))throw new TypeError("voiceMaxConsecutive must be a number >= -1.");const r=e.voiceMin??this.#Pi.voiceMin,n=e.voiceMax??this.#Pi.voiceMax;if(n<r)throw new RangeError(`Logical error: voiceMax (${n}) cannot be less than voiceMin (${r}).`)}constructor(e=null,t=0){if(super(),null!==e&&"object"!=typeof e)throw new TypeError("initialData must be an object or null.");if("number"!=typeof t)throw new TypeError("seed must be a number.");this.#pi=t,e?this.#ms(e):this.#hs=Date.now()}add(e,t,r=!0){if(!["music","voice","custom"].includes(e))throw new TypeError('Type must be "music", "voice", or "custom".');if(!t||"string"!=typeof t.id||"number"!=typeof t.duration)throw new TypeError("Content must have a string ID and a valid numerical duration in milliseconds.");if("boolean"!=typeof r)throw new TypeError("smartQueue must be a boolean.");"music"===e?(this.#ss.push(t),this.#cs.clear()):"voice"===e?(this.#as.push(t),this.#cs.clear()):"custom"===e&&this.#ps(t,r),this.#fs(Date.now()),this.emit("contentAdded",{type:e,data:structuredClone(t)})}scheduleTask(e,t,r,n,i=!0){if("number"!=typeof e||isNaN(e))throw new TypeError("timestamp must be a valid number.");if(!["add","remove","move"].includes(t))throw new TypeError('action must be "add", "remove", or "move".');if(!["music","voice"].includes(r))throw new TypeError('type must be "music" or "voice".');if("boolean"!=typeof i)throw new TypeError("smartQueue must be a boolean.");if("add"===t){if("object"!=typeof n||null===n||"string"!=typeof n.id||"number"!=typeof n.duration)throw new TypeError('Payload for "add" must be a MediaContent object (id: string, duration: number).')}else if("remove"===t){if("string"!=typeof n)throw new TypeError('Payload for "remove" must be a string (the content ID).')}else if("move"===t&&("object"!=typeof n||null===n||"string"!=typeof n.id||"number"!=typeof n.newIndex))throw new TypeError('Payload for "move" must be a ScheduledMovePayload (id: string, newIndex: number).');let o=e;if(i){const t=this.#gs(e,e);t&&(o=t.absoluteEnd)}const s={timestamp:o,action:t,type:r,payload:n};this.#us.push(s),this.#fs(Date.now()),this.emit("taskScheduled",structuredClone(s))}remove(e){if("string"!=typeof e)throw new TypeError("id must be a string.");this.#ss.filter(t=>t.id===e).forEach(e=>At(e)),this.#as.filter(t=>t.id===e).forEach(e=>At(e)),this.#ls.filter(t=>t.content?.id===e).forEach(e=>At(e.content));const t=t=>t.id!==e&&t.content?.id!==e;this.#ss=this.#ss.filter(t),this.#as=this.#as.filter(t),this.#ls=this.#ls.filter(t),this.#us=this.#us.filter(t=>"add"===t.action&&"object"==typeof t.payload&&null!==t.payload&&"id"in t.payload?t.payload.id!==e||(At(t.payload),!1):t.payload!==e),this.#cs.clear(),this.emit("contentRemoved",{id:e})}setConfig(e){this.#ds(e);const t={...this.#Pi,...e};this.#ds(t),this.#Pi=t,this.#cs.clear(),this.emit("configChanged",{config:this.config})}getCurrentEvent(){const e=Date.now();return this.#fs(e),this.#gs(e,e)}queryTimeline(e,t=10){if("number"!=typeof t||isNaN(t))throw new TypeError("Invalid query limit value. Ensure it is a number.");if(t>this.#Pi.queryLimit||t<=0)throw new RangeError(`Invalid query limit. Ensure it is > 0 and <= ${this.#Pi.queryLimit}.`);const r=new Fr(JSON.parse(this._exportState())),n=[];let i=e;for(let o=0;o<t;o++){r.#fs(i);const t=r.#ys(i,e);if(!t)break;n.push(t),i=t.absoluteEnd}return r.destroy(!1),this.emit("timelineQueried",{targetDate:e,limit:t,resultCount:n.length}),n}searchCustomPositions(){return this.#fs(Date.now()),[...this.#ls]}async _processListForExport(e){return Promise.all(e.map(async e=>{const t=structuredClone(e);return t.picture&&Array.isArray(t.picture)&&(t.picture=await Promise.all(t.picture.map(async e=>({...e,data:await Ct(e.data)})))),t}))}_exportState(){return JSON.stringify({music:this.#ss,voice:this.#as,custom:this.#ls,tasks:this.#us,seed:this.#pi,anchorDate:this.#hs,config:this.#Pi})}async exportState(){const e=await this._processListForExport(this.#ss),t=await this._processListForExport(this.#as),r=await Promise.all(this.#ls.map(async e=>{const t=await this._processListForExport([e.content]);return{...e,content:t[0]}})),n=await Promise.all(this.#us.map(async e=>{if("add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload){const t=await this._processListForExport([e.payload]);return{...e,payload:t[0]}}return e}));return JSON.stringify({music:e,voice:t,custom:r,tasks:n,seed:this.#pi,anchorDate:this.#hs,config:this.#Pi})}importState(e){let t;if("string"==typeof e)try{t=JSON.parse(e)}catch{throw new TypeError("Provided string is not valid JSON.")}else{if("object"!=typeof e||null===e)throw new TypeError("Import data must be a valid JSON string or an object.");t=e}this.#ms(t),this.emit("stateImported",{data:structuredClone(t)})}_prng(e){return function(){let t=e+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}#ws(e,t,r,n=0){if(0===e.length)return[];if("random"!==r)return[...e];const i=e.map(e=>({...e,weight:e.weight??1})),o=this._prng(t),s=[];let a=null,l=0;for(;i.length>0;){let e=i;-1!==n&&null!==a&&l>n&&(e=i.filter(e=>e.id!==a),0===e.length&&(e=i));const t=e.reduce((e,t)=>e+t.weight,0);if(t<=0){s.push(...e);break}const r=o()*t;let u=0,c=null,h=-1;for(let t=0;t<e.length;t++)if(u+=e[t].weight,r<=u){c=e[t],h=i.findIndex(e=>c&&e.id===c.id);break}c&&-1!==h||(c=e[0],h=i.findIndex(e=>c&&e.id===c.id)),s.push(c),i.splice(h,1),c.id===a?l++:(a=c.id,l=1)}return s}#bs(e){const t=this.#pi+e,r=this._prng(10*t),n=this.#ws(this.#ss,t+1,this.#Pi.mode,this.#Pi.musicMaxConsecutive),i=this.#ws(this.#as,t+2,this.#Pi.voiceMode,this.#Pi.voiceMaxConsecutive),o=[];let s=0,a=0;for(let e=0;e<n.length;e++){const t=n[e];if(o.push({...t,cycleStart:s,cycleEnd:s+t.duration}),s+=t.duration+this.#Pi.silenceDuration,this.#Pi.voiceAfterMusic&&i.length>0){const e=this.#Pi.voiceMax-this.#Pi.voiceMin+1,t=Math.floor(r()*e)+this.#Pi.voiceMin;for(let e=0;e<t;e++){const e=i[a%i.length];a++,o.push({...e,cycleStart:s,cycleEnd:s+e.duration}),s+=e.duration+this.#Pi.silenceDuration}}}return{items:o,duration:s}}#vs(e){if(0===this.#ss.length)return null;let t=this.#hs,r=0;for(;;){if(r>this.#Pi.queryLimit)throw new Error("Safety limit hit during cycle location.");let n=this.#cs.get(r);if(n||(n=this.#bs(r),this.#cs.set(r,n)),0===n.duration)return null;if(e>=t&&e<t+n.duration)return{block:n,startTimestamp:t,loopIndex:r};t+=n.duration,r++}}#ys(e,t){const r=this.#ls.filter(t=>t.intendedTimestamp+t.content.duration>e).sort((e,t)=>e.intendedTimestamp-t.intendedTimestamp)[0];let n=null;if(r){const e=Math.max(t,r.intendedTimestamp);n=this.#Es(r.content,r.intendedTimestamp,e,!0)}const i=this.#Ts(e,t);return i||n?i?n?n.absoluteStart<=i.absoluteStart?n:(n.absoluteStart<i.absoluteEnd&&(i.absoluteEnd=n.absoluteStart,i.duration=i.absoluteEnd-i.absoluteStart,i.remainingTime=Math.max(0,i.absoluteEnd-t),i.progress=Math.min(1,i.elapsedTime/i.duration)),i):i:n:null}#Ts(e,t){let r=this.#vs(e);if(!r)return null;const{block:n,startTimestamp:i}=r,o=e-i;let s,a=n.items.find(e=>e.cycleEnd>o);if(a)s=i+a.cycleStart;else{if(r=this.#vs(i+n.duration),!r||0===r.block.items.length)return null;a=r.block.items[0],s=r.startTimestamp+a.cycleStart}const l=Math.max(t,s);return this.#Es(a,s,l,!1)}#gs(e,t){const r=this.#ls.find(t=>e>=t.intendedTimestamp&&e<t.intendedTimestamp+t.content.duration);if(r)return this.#Es(r.content,r.intendedTimestamp,t,!0);const n=this.#vs(e);if(!n)return null;const{block:i,startTimestamp:o}=n,s=e-o,a=i.items.find(e=>s>=e.cycleStart&&s<e.cycleEnd);return a?this.#Es(a,o+a.cycleStart,t,!1):null}#Es(e,t,r,n){const i=r-t;return{id:e.id,title:e.title,artist:e.artist,duration:e.duration,url:e.url,absoluteStart:t,absoluteEnd:t+e.duration,elapsedTime:i,remainingTime:e.duration-i,progress:Math.min(1,i/e.duration),isCustom:n}}#ps(e,t){let r=e.timestamp||Date.now();const n=e.duration;if(t){const e=this.#gs(r,r);e&&(r=e.absoluteEnd)}const i=[...this.#ls].sort((e,t)=>e.intendedTimestamp-t.intendedTimestamp);let o=r;if(i.some(e=>r<e.intendedTimestamp+e.content.duration&&r+n>e.intendedTimestamp)){const e=[];let t=Date.now();for(const r of i)r.intendedTimestamp>t&&e.push({start:t,end:r.intendedTimestamp}),t=Math.max(t,r.intendedTimestamp+r.content.duration+this.#Pi.silenceDuration);e.push({start:t,end:1/0});let s=1/0;for(const t of e)if(t.end-t.start>=n){let e=null;if(r>=t.start&&r+n<=t.end?e=r:r<t.start?e=t.start:r>t.end&&(e=t.end-n),null!==e){const t=Math.abs(r-e);t<s&&(s=t,o=e)}}}this.#ls.push({content:e,intendedTimestamp:o,originalTimestamp:e.timestamp||Date.now()})}#fs(e){const t=this.#us.filter(t=>t.timestamp<=e);this.#us=this.#us.filter(t=>t.timestamp>e);const r=this.#ls.filter(t=>t.intendedTimestamp+t.content.duration<=e);this.#ls=this.#ls.filter(t=>t.intendedTimestamp+t.content.duration>e);let n=!1;r.forEach(e=>{At(e.content),this.#pi+=e.content.id.length,n=!0,this.emit("customPositionExpired",{contentId:e.content.id})}),t.length>0&&t.sort((e,t)=>e.timestamp-t.timestamp).forEach(e=>{const t="music"===e.type?this.#ss:this.#as;if("add"===e.action)t.push(e.payload);else if("remove"===e.action){const r=e.payload,n=t.findIndex(e=>e.id===r);if(-1!==n){const[e]=t.splice(n,1);At(e)}}else if("move"===e.action){const r=e.payload,n=t.findIndex(e=>e.id===r.id);if(-1!==n){const[e]=t.splice(n,1);t.splice(r.newIndex,0,e)}}this.#hs=e.timestamp,this.#pi+=1,n=!0,this.emit("taskExecuted",structuredClone(e))}),n&&this.#cs.clear()}#ms(e){this.#ss.forEach(e=>At(e)),this.#as.forEach(e=>At(e)),this.#ls.forEach(e=>At(e.content)),this.#us.forEach(e=>{"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload&&At(e.payload)});const t=e=>e.map(e=>{const t={...e};return t.picture&&Array.isArray(t.picture)&&(t.picture=t.picture.map(e=>({...e,data:xt(e.data,e.format)}))),t});this.#ss=t(e.music),this.#as=t(e.voice),this.#pi=e.seed||0,this.#hs=e.anchorDate||Date.now(),this.#Pi={...this.#Pi,...e.config||{}},this.#ls=e.custom.map(e=>({...e,content:t([e.content])[0]})),this.#us=e.tasks.map(e=>"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload?{...e,payload:t([e.payload])[0]}:e)}destroy(e=!0){e&&(this.#ss.forEach(e=>At(e)),this.#as.forEach(e=>At(e)),this.#ls.forEach(e=>At(e.content)),this.#us.forEach(e=>{"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload&&At(e.payload)})),this.#ss=[],this.#as=[],this.#ls=[],this.#us=[],this.#cs.clear(),this.emit("destroyed",{timestamp:Date.now()}),this.removeAllListeners()}}const Br=Fr;class zr{constructor(){if(new.target===zr)throw new Error("BaseMediaAdapter is an abstract class and cannot be instantiated directly.")}canHandle(e){throw new Error('Method "canHandle" must be implemented by the subclass.')}async play(e){throw new Error('Method "play" must be implemented by the subclass.')}async pause(){throw new Error('Method "pause" must be implemented by the subclass.')}async stop(){throw new Error('Method "stop" must be implemented by the subclass.')}async seek(e){throw new Error('Method "seek" must be implemented by the subclass.')}getCurrentTime(){throw new Error('Method "getCurrentTime" must be implemented by the subclass.')}setVolume(e){throw new Error('Method "setVolume" must be implemented by the subclass.')}}class Wr extends Bt.EventEmitter{static BaseMediaAdapter=zr;static#os="Unknown Artist";static get unknownArtist(){return Wr.#os}static set unknownArtist(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("unknownArtist must have an string or function.");Wr.#os=e}static async parseContent(e,t,r,n,i){return Lt(e,t,r,n,i,Wr.#os)}#Ss=new Map;#xs=[];#Cs=-1;#As="NONE";#Is=!1;#ks=!1;#Ms=1;#Ns;#Ls;constructor(e={}){super(),this.#Ns=Boolean(e.persistVolume),this.#Ls="string"==typeof e.volumeStorageKey?e.volumeStorageKey:"tiny_media_player_volume",this.#Ns&&this.#_s()}#_s(){try{if("undefined"!=typeof window&&window.localStorage){const e=window.localStorage.getItem(this.#Ls);if(null!==e){const t=parseFloat(e);!isNaN(t)&&t>=0&&t<=1&&(this.#Ms=t)}}}catch(e){console.warn("[TinyMediaPlayer] Failed to read volume from localStorage.",e)}}#Ds(){try{this.#Ns&&"undefined"!=typeof window&&window.localStorage&&window.localStorage.setItem(this.#Ls,this.#Ms.toString())}catch(e){console.warn("[TinyMediaPlayer] Failed to save volume to localStorage.",e)}}_getWeightedRandomIndex(){if(0===this.#xs.length)return-1;if(1===this.#xs.length)return 0;let e=0;for(let t=0;t<this.#xs.length;t++){if(t===this.#Cs)continue;const r=this.#xs[t];e+="number"==typeof r.weight&&r.weight>0?r.weight:1}let t=Math.random()*e;for(let e=0;e<this.#xs.length;e++){if(e===this.#Cs)continue;const r=this.#xs[e],n="number"==typeof r.weight&&r.weight>0?r.weight:1;if(t<n)return e;t-=n}return this.#Cs===this.#xs.length-1?0:this.#xs.length-1}get playlist(){return[...this.#xs]}set playlist(e){if(!Array.isArray(e))throw new TypeError("Playlist must be an array of MediaContent objects.");e.forEach(e=>kt(e));const t=this.#ks;let r=null;if(-1!==this.#Cs&&this.#xs.length>0)try{r=this.#js()}catch(e){}this.#xs=e,this.emit("playlistUpdate",this.playlist),0===this.#xs.length?this.#Cs=-1:(this.#Cs>=this.#xs.length||-1===this.#Cs)&&(this.#Cs=0),this.emit("trackChange",this.#Cs),t&&(async()=>{try{r&&await r.stop(),-1!==this.#Cs&&await this.play()}catch(e){console.warn("[TinyMediaPlayer] Background transition error on playlist update:",e)}})()}get currentIndex(){return this.#Cs}set currentIndex(e){if("number"!=typeof e)throw new TypeError("Current index must be a number.");if(e<-1||e>=this.#xs.length&&this.#xs.length>0)throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);if(this.#Cs===e)return;const t=this.#ks;let r=null;if(-1!==this.#Cs&&this.#xs.length>0)try{r=this.#js()}catch(e){}this.#Cs=e,this.emit("trackChange",this.#Cs),t&&(async()=>{try{r&&await r.stop(),-1!==this.#Cs&&await this.play()}catch(e){console.warn("[TinyMediaPlayer] Background transition error on index update:",e)}})()}get loopMode(){return this.#As}set loopMode(e){const t=["NONE","TRACK","PLAYLIST"];if(!t.includes(e))throw new TypeError(`Loop mode must be one of: ${t.join(", ")}.`);this.#As=e,this.emit("loopModeChange",this.#As)}get isRandom(){return this.#Is}set isRandom(e){if("boolean"!=typeof e)throw new TypeError("Random mode state must be a boolean.");this.#Is=e,this.emit("randomModeChange",this.#Is)}get isPlaying(){return this.#ks}get volume(){return this.#Ms}set volume(e){if("number"!=typeof e)throw new TypeError("Volume must be a number.");if(e<0||e>1)throw new RangeError("Volume must be tightly constrained between 0.0 and 1.0.");if(this.#Ms=e,this.#Ds(),this.emit("volumeChange",this.#Ms),-1!==this.#Cs&&this.#xs.length>0)try{const e=this.#js();e&&e.setVolume(this.#Ms)}catch(e){}}get persistVolume(){return this.#Ns}set persistVolume(e){if("boolean"!=typeof e)throw new TypeError("Persist volume parameter must be a boolean.");this.#Ns=e,e&&this.#Ds()}get volumeStorageKey(){return this.#Ls}set volumeStorageKey(e){if("string"!=typeof e)throw new TypeError("Volume storage key must be a string.");if(""===e.trim())throw new TypeError("Volume storage key cannot be an empty string.");const t=this.#Ls;this.#Ls=e;try{this.#Ns&&"undefined"!=typeof window&&window.localStorage&&(window.localStorage.removeItem(t),this.#Ds())}catch(e){console.warn("[TinyMediaPlayer] Failed to migrate volume storage key.",e)}}registerAdapter(e,t){if("string"!=typeof e)throw new TypeError("Adapter ID must be a string.");if(!(t instanceof zr))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");this.#Ss.set(e,t)}#js(){if(-1===this.#Cs||0===this.#xs.length)return null;const e=this.#xs[this.#Cs];for(const t of this.#Ss.values())if(t.canHandle(e))return t;throw new Error(`No compatible adapter found for content ID: ${e.id}.`)}addTrack(e){if(!e||"object"!=typeof e||"string"!=typeof e.url)throw new TypeError("Track content must be a valid MediaContent object containing a URL.");const t={id:"",title:"",artist:"",url:"",duration:0,weight:1,title:null,album:null,albumartist:null,albumartists:[],genre:[],label:[],composer:[],year:null,artist:null,artists:[],disk:{no:null,of:null},track:{no:null,of:null},picture:[],...e};kt(t);const r=this.#xs.push(t);return-1===this.#Cs&&(this.#Cs=0,this.emit("trackChange",this.#Cs)),this.emit("playlistUpdate",this.playlist),r}existsTrack(e){if("number"!=typeof e)throw new TypeError("Index must be a number.");return e>=0&&e<this.#xs.length}getTrack(e){if("number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);return this.#xs[e]}async removeTrack(e){if("number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);e===this.#Cs?(await this.stop(),this.#xs.splice(e,1),0===this.#xs.length?this.#Cs=-1:this.#Cs>=this.#xs.length&&(this.#Cs=0),this.emit("trackChange",this.#Cs)):(this.#xs.splice(e,1),e<this.#Cs&&(this.#Cs-=1,this.emit("trackChange",this.#Cs))),this.emit("playlistUpdate",this.playlist)}searchTrack(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("Search query must be a string or a boolean evaluation function.");const t=[];for(let r=0;r<this.#xs.length;r++){const n=this.#xs[r];let i=!1;if("function"==typeof e)i=Boolean(e(n));else{const t=e.toLowerCase(),r=n.title&&n.title.toLowerCase().includes(t),o=n.artist&&n.artist.toLowerCase().includes(t),s=n.album&&n.album.toLowerCase().includes(t);i=Boolean(r||o||s)}i&&t.push({track:n,index:r})}return t}async clearPlaylist(){await this.stop(),this.#xs=[],this.#Cs=-1,this.emit("playlistUpdate",this.playlist),this.emit("trackChange",this.#Cs)}async play(){const e=this.#js();e&&(e.setVolume(this.#Ms),await e.play(this.#xs[this.#Cs]),this.#ks=!0,this.emit("play",this.#Cs))}async pause(){const e=this.#js();e&&(await e.pause(),this.#ks=!1,this.emit("pause",this.#Cs))}async stop(){const e=this.#js();e&&(await e.stop(),this.#ks=!1,this.emit("stop",this.#Cs))}async next(){if(0!==this.#xs.length)if(await this.stop(),"TRACK"!==this.#As){if(this.#Is)this.#Cs=this._getWeightedRandomIndex();else{let e=this.#Cs+1;if(e>=this.#xs.length){if("PLAYLIST"!==this.#As)return;e=0}this.#Cs=e}this.emit("trackChange",this.#Cs),await this.play()}else await this.play()}async prev(){if(0!==this.#xs.length){if(await this.stop(),this.#Is)this.#Cs=this._getWeightedRandomIndex();else{let e=this.#Cs-1;if(e<0){if("PLAYLIST"!==this.#As)return;e=this.#xs.length-1}this.#Cs=e}this.emit("trackChange",this.#Cs),await this.play()}}async seek(e){if("number"!=typeof e)throw new TypeError("Seek time must be a number in milliseconds.");if(e<0)throw new RangeError("Seek time cannot be negative.");const t=this.#js();t&&(await t.seek(e),this.emit("seek",e))}async step(e){if("number"!=typeof e)throw new TypeError("Step amount must be a number in milliseconds.");const t=this.#js();if(!t)return;let r=t.getCurrentTime()+e;r<0&&(r=0),await this.seek(r)}}const qr=Wr})(),window.TinyEssentials=n})();