tiny-essentials 1.25.1 → 1.25.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog/1/25/2.md +9 -0
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyIframeEvents.min.js +1 -1
- package/dist/v1/basics/array.cjs +5 -4
- package/dist/v1/basics/array.d.mts +7 -6
- package/dist/v1/basics/array.mjs +5 -4
- package/dist/v1/libs/TinyIframeEvents.cjs +266 -94
- package/dist/v1/libs/TinyIframeEvents.d.mts +119 -26
- package/dist/v1/libs/TinyIframeEvents.mjs +224 -86
- package/docs/v1/basics/array.md +2 -2
- package/docs/v1/libs/TinyIframeEvents.md +61 -32
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see TinyEssentials.min.js.LICENSE.txt */
|
|
2
|
-
(()=>{var e={133:()=>{},251:(e,t)=>{t.read=function(e,t,r,n,i){var o,s,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,o=p&(1<<-c)-1,p>>=-c,c+=a;c>0;o=256*o+e[t+h],h+=d,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=n;c>0;s=256*s+e[t+h],h+=d,c-=8);if(0===o)o=1-u;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=u}return(p?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,l,u=8*o-i-1,c=(1<<u)-1,h=c>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(s++,l/=2),s+h>=c?(a=0,s=c):s+h>=1?(a=(t*l-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[r+p]=255&a,p+=f,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;e[r+p]=255&s,p+=f,s/=256,u-=8);e[r+p-f]|=128*m}},287:(e,t,r)=>{"use strict";var n=r(526),i=r(251),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.hp=l,t.IS=50;var s=2147483647;function a(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,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|m(e,t),n=a(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(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|f(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||W(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|f(e))}function d(e){for(var t=e.length<0?0:0|f(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 f(e){if(e>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function m(e,t){if(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 B(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 k(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 L(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),W(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 o,s=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;s=2,a/=2,l/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var c=-1;for(o=r;o<a;o++)if(u(e,o)===u(t,-1===c?0:o-c)){if(-1===c&&(c=o),o-c+1===l)return c*s}else-1!==c&&(o-=o-c),c=-1}else for(r+l>a&&(r=a-l),o=r;o>=0;o--){for(var h=!0,d=0;d<l;d++)if(u(e,o+d)!==u(t,d)){h=!1;break}if(h)return o}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 o=t.length;n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(W(a))return s;e[r+s]=a}return s}function E(e,t,r,n){return P($(t,e.length-r),e,r,n)}function T(e,t,r,n){return P(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 P(B(t),e,r,n)}function x(e,t,r,n){return P(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function 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 o,s,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&(o=e[i+1]))&&(l=(31&u)<<6|63&o)>127&&(c=l);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(l=(15&u)<<12|(63&o)<<6|63&s)>2047&&(l<55296||l>57343)&&(c=l);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&u)<<18|(63&o)<<12|(63&s)<<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,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},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 o=e[r];if(F(o,Uint8Array))i+o.length>n.length?l.from(o).copy(n,i):Uint8Array.prototype.set.call(n,o,i);else{if(!l.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i)}i+=o.length}return n},l.byteLength=m,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+">"},o&&(l.prototype[o]=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 o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),c=e.slice(t,r),h=0;h<a;++h)if(u[h]!==c[h]){o=u[h],s=c[h];break}return o<s?-1:s<o?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 o=!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(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!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 L(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 k(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=t;o<r;++o)i+=z[e[o]];return i}function N(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function _(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 D(e,t,r,n,i,o){if(!l.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function j(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(e,t,r,n,o){return t=+t,r>>>=0,o||j(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function O(e,t,r,n,o){return t=+t,r>>>=0,o||j(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||_(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},l.prototype.readUintBE=l.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||_(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||_(e,1,this.length),this[e]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(e,t){return e>>>=0,t||_(e,2,this.length),this[e]|this[e+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(e,t){return e>>>=0,t||_(e,2,this.length),this[e]<<8|this[e+1]},l.prototype.readUint32LE=l.prototype.readUInt32LE=function(e,t){return e>>>=0,t||_(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||_(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||_(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},l.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||_(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},l.prototype.readInt8=function(e,t){return e>>>=0,t||_(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},l.prototype.readInt16LE=function(e,t){e>>>=0,t||_(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||_(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||_(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||_(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||_(e,4,this.length),i.read(this,e,!0,23,4)},l.prototype.readFloatBE=function(e,t){return e>>>=0,t||_(e,4,this.length),i.read(this,e,!1,23,4)},l.prototype.readDoubleLE=function(e,t){return e>>>=0,t||_(e,8,this.length),i.read(this,e,!0,52,8)},l.prototype.readDoubleBE=function(e,t){return e>>>=0,t||_(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||D(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},l.prototype.writeUintBE=l.prototype.writeUIntBE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||D(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},l.prototype.writeUint8=l.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||D(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||D(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||D(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||D(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||D(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);D(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},l.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);D(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},l.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||D(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||D(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||D(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||D(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||D(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 R(this,e,t,!0,r)},l.prototype.writeFloatBE=function(e,t,r){return R(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 o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var s=l.isBuffer(e)?e:l.from(e,n),a=s.length;if(0===a)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<r-t;++o)this[o+t]=s[o%a]}return this};var H=/[^+/0-9A-Za-z-_]/g;function $(e,t){var r;t=t||1/0;for(var n=e.length,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function B(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(H,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function P(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 W(e){return e!=e}var z=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}()},370:()=>{},526:(e,t)=>{"use strict";t.byteLength=function(e){var t=a(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,o=a(e),s=o[0],l=o[1],u=new i(function(e,t,r){return 3*(t+r)/4-r}(0,s,l)),c=0,h=l>0?s-4:s;for(r=0;r<h;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],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,o=[],s=16383,a=0,l=n-i;a<l;a+=s)o.push(u(e,a,a+s>l?l:a+s));return 1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function 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=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),i.push(l(n));return i.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},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 p(e,t){this.fun=e,this.array=t}function f(){}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||s(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=f,n.addListener=f,n.once=f,n.off=f,n.removeListener=f,n.removeAllListeners=f,n.emit=f,n.prependListener=f,n.prependOnceListener=f,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}},766:()=>{},911:()=>{},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 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,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}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";r.r(n),r.d(n,{ColorSafeStringify:()=>U,TinyAdvancedRaffle:()=>Zt,TinyAfterScrollWatcher:()=>Et,TinyAnalogClock:()=>mr,TinyArrayPaginator:()=>er,TinyClipboard:()=>jt,TinyColorConverter:()=>Ot,TinyColorValidator:()=>fr,TinyCookieConsent:()=>ir,TinyDayNightCycle:()=>Xt,TinyDomReadyManager:()=>bt,TinyDragDropDetector:()=>ae,TinyDragger:()=>wt,TinyElementObserver:()=>nt,TinyEvents:()=>kt,TinyGamepad:()=>Yt,TinyHtml:()=>gt,TinyI18:()=>ar,TinyIframeEvents:()=>Vt,TinyInventory:()=>rr,TinyInventoryTrader:()=>nr,TinyLevelUp:()=>t,TinyLoadingScreen:()=>dr,TinyLocalStorage:()=>zt,TinyNeedBar:()=>ur,TinyNewWinEvents:()=>Kt,TinyNotifications:()=>vt,TinyNotifyCenter:()=>Y,TinyPromiseQueue:()=>K,TinyRateLimiter:()=>J,TinySimpleDice:()=>hr,TinySmartScroller:()=>_t,TinyTextDiffer:()=>gr,TinyTextRangeEditor:()=>Dt,TinyTextarea:()=>Jt,TinyTimeout:()=>$t,TinyToastNotify:()=>X,UltraRandomMsgGen:()=>Lt,addAiMarkerShortcut:()=>W,areElsCollBottom:()=>Pe,areElsCollLeft:()=>Fe,areElsCollPerfBottom:()=>qe,areElsCollPerfLeft:()=>Ve,areElsCollPerfRight:()=>Ue,areElsCollPerfTop:()=>ze,areElsCollRight:()=>We,areElsCollTop:()=>Be,areElsColliding:()=>Ke,areElsPerfColliding:()=>Je,arraySortPositions:()=>s,asyncReplace:()=>B,backupFile:()=>xe,breakdownDuration:()=>h,calculateMarketcap:()=>H,checkObj:()=>T,clearDirectory:()=>pe,clearDirectoryAsync:()=>De,cloneObjTypeOrder:()=>b,compareMarketcap:()=>$,countObj:()=>p,diffArrayList:()=>o,diffStrings:()=>q,dirExists:()=>me,dirSize:()=>Se,dirSizeAsync:()=>$e,documentIsFullScreen:()=>S,ensureCopyFile:()=>ye,ensureDirectory:()=>de,exitFullScreen:()=>I,extendObjType:()=>y,fetchJson:()=>ie,fetchText:()=>oe,fileExists:()=>fe,fileSize:()=>Te,fileSizeAsync:()=>He,formatBytes:()=>R,formatCustomTimer:()=>l,formatDayTimer:()=>c,formatTimer:()=>u,genFibonacciSeq:()=>O,getAge:()=>j,getElsCollDetails:()=>rt,getElsCollDirDepth:()=>tt,getElsCollOverlap:()=>Xe,getElsCollOverlapPos:()=>Qe,getElsColliding:()=>Ge,getElsPerfColliding:()=>Ye,getElsRelativeCenterOffset:()=>et,getLatestBackupPath:()=>Ae,getPercentage:()=>D,getRectCenter:()=>Ze,getSimplePerc:()=>_,getTimeDuration:()=>a,installWindowHiddenScript:()=>se,isDirEmpty:()=>ge,isDirEmptyAsync:()=>je,isFullScreenMode:()=>A,isJsonObject:()=>f,isScreenFilled:()=>x,listDirs:()=>Ee,listDirsAsync:()=>Oe,listFiles:()=>ve,listFilesAsync:()=>Re,objType:()=>E,offFullScreenChange:()=>k,onFullScreenChange:()=>L,readBase64Blob:()=>Z,readFileBlob:()=>Q,readJsonBlob:()=>ee,readJsonFile:()=>ce,renameFileAddPrefixSuffix:()=>Le,renameFileBatch:()=>Ie,renameFileNormalizeCase:()=>ke,renameFilePadNumbers:()=>Ne,renameFileRegex:()=>Me,reorderObjTypeOrder:()=>w,requestFullScreen:()=>C,restoreLatestBackup:()=>Ce,ruleOfThree:()=>N,safeTextTrim:()=>z,saveJsonFile:()=>te,shuffleArray:()=>i,toTitleCase:()=>P,toTitleCaseLowerFirst:()=>F,tryDeleteFile:()=>we,writeJsonFile:()=>he,writeTextFile:()=>be});var e={};r.r(e),r.d(e,{areElsCollBottom:()=>Pe,areElsCollLeft:()=>Fe,areElsCollPerfBottom:()=>qe,areElsCollPerfLeft:()=>Ve,areElsCollPerfRight:()=>Ue,areElsCollPerfTop:()=>ze,areElsCollRight:()=>We,areElsCollTop:()=>Be,areElsColliding:()=>Ke,areElsPerfColliding:()=>Je,getElsCollDetails:()=>rt,getElsCollDirDepth:()=>tt,getElsCollOverlap:()=>Xe,getElsCollOverlapPos:()=>Qe,getElsColliding:()=>Ge,getElsPerfColliding:()=>Ye,getElsRelativeCenterOffset:()=>et,getRectCenter:()=>Ze});const t=class{constructor(e,t){if("number"!=typeof e||Number.isNaN(e))throw new Error("giveExp must be a valid number");if("number"!=typeof t||Number.isNaN(t))throw new Error("expLevel must be a valid number");this.giveExp=e,this.expLevel=t}createUser(){return{exp:0,level:1,totalExp:0}}validateUser(e){if("number"!=typeof e.exp||Number.isNaN(e.exp))throw new Error("exp must be a valid number");if("number"!=typeof e.level||Number.isNaN(e.level))throw new Error("level must be a valid number");if(e.level<1)throw new Error("level must be at least 1");if("number"!=typeof e.totalExp||Number.isNaN(e.totalExp))throw new Error("totalExp must be a valid number")}isValidUser(e){return!("number"!=typeof e.exp||Number.isNaN(e.exp)||"number"!=typeof e.level||Number.isNaN(e.level)||e.level<1||"number"!=typeof e.totalExp||Number.isNaN(e.totalExp))}getGiveExpBase(){if("number"!=typeof this.giveExp||Number.isNaN(this.giveExp))throw new Error("giveExp must be a valid number");return this.giveExp}getExpLevelBase(){if("number"!=typeof this.expLevel||Number.isNaN(this.expLevel))throw new Error("expLevel must be a valid number");return this.expLevel}expValidator(e){const t=this.getExpLevelBase();this.validateUser(e);let r=0;const n=t*e.level;return e.exp>=n&&(e.level++,r=e.exp-n,e.exp=0,r>0)?this.give(e,r,"extra"):e.exp<1&&e.level>1&&(e.level--,r=Math.abs(e.exp),e.exp=t*e.level,r>0)?this.remove(e,r,"extra"):e}getTotalExp(e){this.validateUser(e);let t=0;for(let r=1;r<=e.level;r++)t+=this.getExpLevelBase()*r;return t+=e.exp,t}expGenerator(e=1){if("number"!=typeof e||Number.isNaN(e))throw new Error("multi must be a valid number");return Math.floor(Math.random()*this.getGiveExpBase())*e}getMissingExp(e){return this.getProgress(e)-e.exp}progress(e){return this.getProgress(e)}getProgress(e){return this.validateUser(e),this.getExpLevelBase()*e.level}set(e,t){if("number"!=typeof t||Number.isNaN(t))throw new Error("value must be a valid number");return e.exp=t,this.expValidator(e),e.totalExp=this.getTotalExp(e),e}give(e,t=0,r="add",n=1){if("number"!=typeof n||Number.isNaN(n))throw new Error("multi must be a valid number");if("number"!=typeof t||Number.isNaN(t))throw new Error("extraExp must be a valid number");if("string"!=typeof r)throw new Error("type must be a valid string");return"add"===r?e.exp+=this.expGenerator(n)+t:"extra"===r&&(e.exp+=t),this.expValidator(e),e.totalExp=this.getTotalExp(e),e}remove(e,t=0,r="add",n=1){if("number"!=typeof n||Number.isNaN(n))throw new Error("multi must be a valid number");if("number"!=typeof t||Number.isNaN(t))throw new Error("extraExp must be a valid number");if("string"!=typeof r)throw new Error("type must be a valid string");return"add"===r?e.exp-=this.expGenerator(n)+t:"extra"===r&&(e.exp-=t),this.expValidator(e),e.totalExp=this.getTotalExp(e),e}};function i(e){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 s(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 a(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 l(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")},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 u(e){return l(e,"hours","{hours}:{minutes}:{seconds}")}function c(e){return l(e,"days","{days}d {hours}:{minutes}:{seconds}")}function h(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}var d=r(287);function p(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 m="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)]]),m||y([["buffer",e=>void 0!==d.hp&&d.hp.isBuffer(e)]]),m&&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]]),m&&y([["htmlelement",e=>"undefined"!=typeof HTMLElement&&e instanceof HTMLElement]]),y([["object",e=>f(e)]]);const S=()=>!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitIsFullScreen||document.mozFullScreen),x=()=>window.innerHeight===screen.height&&window.innerWidth===screen.width,A=()=>S()||x(),C=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)}}),M=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],L=(e,t)=>{M.forEach(r=>{document.addEventListener(r,e,t)})},k=(e,t)=>{M.forEach(r=>{document.removeEventListener(r,e,t)})};function N(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 O({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 H(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=H(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 P(e){return e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase())}function F(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 z(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:"[0m",key:"[36m",string:"[32m",string_url:"[34m",string_bool:"[35m",string_number:"[33m",number:"[33m",boolean:"[35m",null:"[1;30m",special:"[31m",func:"[90m"},solarized:{reset:"[0m",key:"[38;5;37m",string:"[38;5;136m",string_url:"[38;5;33m",string_bool:"[38;5;166m",string_number:"[38;5;136m",number:"[38;5;136m",boolean:"[38;5;166m",null:"[38;5;241m",special:"[38;5;160m",func:"[38;5;244m"},monokai:{reset:"[0m",key:"[38;5;81m",string:"[38;5;114m",string_url:"[38;5;75m",string_bool:"[38;5;204m",string_number:"[38;5;221m",number:"[38;5;221m",boolean:"[38;5;204m",null:"[38;5;241m",special:"[38;5;160m",func:"[38;5;102m"}};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 U=V,K=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}},J=class{#c=null;#h=null;#d=null;#p=null;#f=null;#m=null;groupData=new Map;lastSeen=new Map;userToGroup=new Map;groupFlags=new Map;groupTTL=new Map;#g=null;setOnMemoryExceeded(e){if("function"!=typeof e)throw new Error("onMemoryExceeded must be a function");this.#g=e}clearOnMemoryExceeded(){this.#g=null}#y=null;setOnGroupExpired(e){if("function"!=typeof e)throw new Error("onGroupExpired must be a function");this.#y=e}clearOnGroupExpired(){this.#y=null}constructor({maxHits:e,interval:t,cleanupInterval:r,maxIdle:n=3e5,maxMemory:i=1e5}){const o=e=>"number"==typeof e&&Number.isFinite(e)&&e>=1&&Number.isInteger(e),s=o(e),a=o(t),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.#p=a?t:null,this.#f=l?r:null,this.#m=n,null!==this.#f&&(this.#h=setInterval(()=>this._cleanup(),this.#f))}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.#m||!Number.isFinite(this.#m)||this.#m<0)throw new Error("'maxIdle' must be a non-negative finite number.");return this.#m}setMaxIdle(e){if("number"!=typeof e||!Number.isFinite(e)||e<0)throw new Error("'maxIdle' must be a non-negative finite number.");this.#m=e}_cleanup(){const e=Date.now();for(const[t,r]of this.lastSeen.entries())e-r>(this.getGroupTTL(t)??this.getMaxIdle())&&(this.groupFlags.delete(t),this.groupData.delete(t),this.lastSeen.delete(t),this.groupTTL.delete(t),"function"==typeof this.#y&&this.#y(t))}getActiveGroups(){return Array.from(this.groupData.keys())}getAllUserMappings(){return Object.fromEntries(this.userToGroup)}getInterval(){if("number"!=typeof this.#p||!Number.isFinite(this.#p))throw new Error("'interval' is not a valid finite number.");return this.#p}getMaxHits(){if("number"!=typeof this.#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;#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)}#L(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.#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.#L(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="×",u.addEventListener("click",e=>{e.stopPropagation(),this.#M(r)}),r.append(a,u),this.#b.prepend(r),this.#I.set(r,t),this.#L(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.#L(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{#k;#N;#_;#D;#j;#R;constructor(e="top",t="right",r=3e3,n=50,i=300,o=".notify-container"){this.#O(e),this.#H(t),this.#$(r,"baseDuration"),this.#$(n,"extraPerChar"),this.#$(i,"fadeOutDuration"),this.#k=e,this.#N=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}#O(e){if(!["top","bottom"].includes(e))throw new Error(`Invalid vertical direction "${e}". Expected "top" or "bottom".`)}#H(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.#k}setY(e){this.#O(e);const t=this.getContainer();t.classList.remove(this.#k),t.classList.add(e),this.#k=e}getX(){return this.#N}setX(e){this.#H(e);const t=this.getContainer();t.classList.remove(this.#N),t.classList.add(e),this.#N=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="×",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?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?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)&&!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)=>{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 p=new Event(l&&document[l]?"blur":"focus");return h(p),d}const ae=class{#B;#P;#F;#W;#z;#q;#V;#U;constructor(e={}){const{target:t,fullscreen:r=!0,hoverClass:n="dnd-hover",onDrop:i,onEnter:o,onLeave:s}=e;if("boolean"!=typeof r)throw new TypeError('The "fullscreen" option must be a boolean.');const a=r?document.body:t||document.body;if(!(a instanceof HTMLElement))throw new TypeError('The "target" option must be an instance of HTMLElement.');if("string"!=typeof n)throw new TypeError('The "hoverClass" option must be a string.');if("function"!=typeof i)throw new TypeError('The "onDrop" option must be a function.');if("function"!=typeof o)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.#B=a,this.#P=r,this.#F=n,this.#W=i||(()=>{}),this.#z=o,this.#q=s,this.#V=!1,this.#U=!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.#B}getHoverClass(){return this.#F}isFullScreen(){return this.#P}isDragging(){return this.#V}bound(){return this.#U}#K(){if(this.#U)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.#U=!0}#J(){if(!this.#U)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.#U=!1}_handleDragEnter(e){if(e.preventDefault(),!this.#V){const t=this.getTarget();this.#V=!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.#V=!1,t.classList.remove(this.#F),this.#q(e))}_handleDrop(e){if(e.preventDefault(),!e.dataTransfer)return void console.warn("[TinyDragDropDetector] [handleDrop] DragOver event missing dataTransfer.");const t=this.getTarget();this.#V=!1,t.classList.remove(this.#F);const r=e.dataTransfer.files;r.length>0&&this.#W(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 pe(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 fe(e){return(0,le.existsSync)(e)&&(0,le.lstatSync)(e).isFile()}function me(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!!fe(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(!me(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(!me(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 fe(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"){fe(e)&&ye(e,`${e}.${t}.${(new Date).toISOString().replace(/[:.]/g,"-")}`)}function Ae(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 Ce(e,t="bak"){ye(Ae(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 Me(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 Le(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 ke(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?P(e):e,i=(0,ue.extname)(e),o=n?r(i):i;return`${r((0,ue.basename)(e,i))}${o}`},r)}function Ne(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(!me(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 Oe(e,t=!1){const r=[];if(!me(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 Oe(n,!0)))}return r}async function He(e){return fe(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=He(e);r.then(e=>(t+=e,e)),n.push(r)}return await Promise.all(n),t}const Be=(e,t)=>e.bottom<t.top,Pe=(e,t)=>e.top>t.bottom,Fe=(e,t)=>e.right<t.left,We=(e,t)=>e.left>t.right,ze=(e,t)=>e.bottom<=t.top,qe=(e,t)=>e.top>=t.bottom,Ve=(e,t)=>e.right<=t.left,Ue=(e,t)=>e.left>=t.right,Ke=(e,t)=>!(Fe(e,t)||We(e,t)||Be(e,t)||Pe(e,t)),Je=(e,t)=>!(Ve(e,t)||Ue(e,t)||ze(e,t)||qe(e,t)),Ge=(e,t)=>Fe(e,t)?"left":We(e,t)?"right":Be(e,t)?"top":Pe(e,t)?"bottom":null,Ye=(e,t)=>Ve(e,t)?"left":Ue(e,t)?"right":ze(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(!Je(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=Je(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{#G;get el(){return this.#G}set el(e){if(this.#G)throw new Error("The observed element has already been set and cannot be reassigned.");if(void 0!==e&&!(e instanceof Element))throw new TypeError("The observed element must be a valid DOM Element.");this.#G=e}#Y={};get settings(){return this.#Y}set settings(e){if("object"!=typeof e||null===e)throw new TypeError("settings must be a non-null object.");this.#Y=e}#X=null;get observer(){return this.#X}#Q=[];get detectors(){return this.#Q.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.#Q=t}get isActive(){return!!this.#X}get size(){return this.#Q.length}constructor({el:e,initDetectors:t=[],initCfg:r={}}={}){this.el=e,t.length&&(this.detectors=t),r&&(this.settings=r)}clear(){this.#Q=[]}start(){if(!this.#G)throw new Error("Cannot start observation: no target element has been set.");this.#X||(this.#X=new MutationObserver(e=>{e.forEach((e,t,r)=>this.#Q.forEach(n=>n[1](e,t,r)))}),this.#X.observe(this.#G,this.#Y))}stop(){this.#X&&(this.#X.disconnect(),this.#X=null)}add(e,t){this.#Z(e,t),this.#Q.push([e,t])}insertAtStart(e,t){this.#Z(e,t),this.#Q.unshift([e,t])}insertAt(e,t,r,n="after"){if(this.#Z(t,r),"number"!=typeof e||e<0||e>=this.#Q.length)throw new RangeError("Invalid index for insertDetectorAt.");const i="before"===n?e:e+1;this.#Q.splice(i,0,[t,r])}removeAt(e){if("number"!=typeof e||e<0||e>=this.#Q.length)throw new RangeError("Invalid index for removeDetectorAt.");this.#Q.splice(e,1)}removeAround(e,t=0,r=0){if("number"!=typeof e||e<0||e>=this.#Q.length)throw new RangeError("Invalid index for removeDetectorsAround.");const n=Math.max(0,e-t),i=t+1+r;this.#Q.splice(n,i)}isIndexUsed(e){return e>=0&&e<this.#Q.length}hasHandler(e){if("function"!=typeof e)throw new TypeError("Handler must be a function.");return this.#Q.some(([t,r])=>r===e)}#Z(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()}},{areElsColliding:it,areElsPerfColliding:ot,areElsCollTop:st,areElsCollBottom:at,areElsCollLeft:lt,areElsCollRight:ut}=e,ct=new WeakMap,ht=new WeakMap,dt=new WeakMap,pt=new WeakMap,ft={top:new WeakMap,bottom:new WeakMap,left:new WeakMap,right:new WeakMap};class mt{static Utils={...e};static#ee=1;static get version(){return this.#ee}static#te=!1;static get elemDebug(){return mt.#te}static set elemDebug(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean value for elemDebug");mt.#te=e}static _debugElemError(e,t){if(!mt.#te)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,mt._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#re=!0;static get autoStartElemObserver(){return mt.#re}static set autoStartElemObserver(e){if("boolean"!=typeof e)throw new TypeError("autoStartElemObserver must be a boolean.");mt.#re=e}static#ne=new nt({el:"undefined"!=typeof window&&void 0!==window.document?window.document.documentElement:void 0,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(mt.parseStyle(t),mt.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"]}});static get tinyObserver(){return mt.#ne}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 mt.htmlToJson(i)}static async fetchHtmlNodes(e,t){const r=await mt.fetchHtmlFile(e,t);return mt.jsonToNodes(r)}static async fetchHtmlTinyElems(e,t){const r=await mt.fetchHtmlNodes(e,t);return mt.toTinyElm(r)}static templateToJson(e){return mt.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 mt.toTinyElm(mt.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[mt.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(mt.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 mt.toTinyElm(mt.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=mt.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 mt(document.createElement(e,t))}static createTextNode(e){if("string"!=typeof e)throw new TypeError("[TinyHtml] createTextNode(): The value must be a string.");return new mt(document.createTextNode(e))}static createElementFromHTML(e){const t=document.createElement("template");if(!(e=e.trim()).startsWith("<"))return mt.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 mt(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 mt(r)}static createFromHtml(e){return mt.createFromHTML(e)}static query(e,t=document){const r=t.querySelector(e);return r?new mt(r):null}querySelector(e){return mt.query(e,mt._preElem(this,"query"))}static queryAll(e,t=document){return new mt(t.querySelectorAll(e))}querySelectorAll(e){return mt.queryAll(e,mt._preElem(this,"queryAll"))}static getById(e){const t=document.getElementById(e);return t?new mt(t):null}static getByClassName(e,t=document){return new mt(t.getElementsByClassName(e))}getElementsByClassName(e){return mt.getByClassName(e,mt._preElem(this,"getByClassName"))}static getByName(e){return new mt(document.getElementsByName(e))}static getByTagNameNS(e,t="http://www.w3.org/1999/xhtml",r=document){return new mt(r.getElementsByTagNameNS(t,e))}getElementsByTagNameNS(e,t="http://www.w3.org/1999/xhtml"){return mt.getByTagNameNS(e,t,mt._preElem(this,"getByTagNameNS"))}get elements(){return[...this.#G]}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.#G[e])throw new Error(`No element found at index ${e}.`);return this.#G[e]}extract(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");if(!this.#G[e])throw new Error(`Cannot extract: no element exists at index ${e}.`);return new mt(this.#G[e])}exists(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");return!!this.#G[e]}getAll(){return[...this.#G]}_getElement(e,t){if(!(this.#G[t]instanceof Element||this.#G[t]instanceof Window||this.#G[t]instanceof Document||this.#G[t]instanceof Text))throw mt._debugElemError([...this.#G],this.#G[t]),new Error(`[TinyHtml] Invalid Element in ${e}().`);return this.#G[t]}_getElements(e){if(!this.#G.every(e=>e instanceof Element||e instanceof Window||e instanceof Document||e instanceof Text))throw mt._debugElemError([...this.#G]),new Error(`[TinyHtml] Invalid Element in ${e}().`);return[...this.#G]}static _preElemsTemplate(e,t,r,n){const i=e=>{const i=[];return e.map(o=>(o instanceof mt?o._getElements(t):[o]).map(o=>{let s=!1;for(const e of r)if(o instanceof e){s=!0;break}if(!s)throw mt._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 mt._preElemsTemplate(this,e,t,r)}static _preElemTemplate(e,t,r,n,i=!1){const o=e=>{const o=e[0],s=o instanceof mt?o._getElements(t):[o];if(s.length>1)throw mt._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 mt._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 mt._debugElemError([...e]),new Error(`[TinyHtml] Invalid element amount in ${t}() (Received ${e.length}/1).`);return o(e)}_preElemTemplate(e,t,r,n=!1){return mt._preElemTemplate(this,e,t,r,n)}static _preElems(e,t){return mt._preElemsTemplate(e,t,[Element],["Element"])}_preElems(e){return mt._preElems(this,e)}static _preElem(e,t){return mt._preElemTemplate(e,t,[Element],["Element"])}_preElem(e){return mt._preElem(this,e)}static _preNodeElems(e,t){return mt._preElemsTemplate(e,t,[Node],["Node"])}_preNodeElems(e){return mt._preNodeElems(this,e)}static _preNodeElem(e,t){return mt._preElemTemplate(e,t,[Node],["Node"])}_preNodeElem(e){return mt._preNodeElem(this,e)}static _preNodeElemWithNull(e,t){return mt._preElemTemplate(e,t,[Node],["Node"],!0)}_preNodeElemWithNull(e){return mt._preNodeElemWithNull(this,e)}static _preHtmlElems(e,t){return mt._preElemsTemplate(e,t,[HTMLElement],["HTMLElement"])}_preHtmlElems(e){return mt._preHtmlElems(this,e)}static _preHtmlElem(e,t){return mt._preElemTemplate(e,t,[HTMLElement],["HTMLElement"])}_preHtmlElem(e){return mt._preHtmlElem(this,e)}static _preInputElems(e,t){return mt._preElemsTemplate(e,t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElems(e){return mt._preInputElems(this,e)}static _preInputElem(e,t){return mt._preElemTemplate(e,t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElem(e){return mt._preInputElem(this,e)}static _preEventTargetElems(e,t){return mt._preElemsTemplate(e,t,[EventTarget],["EventTarget"])}_preEventTargetElems(e){return mt._preEventTargetElems(this,e)}static _preEventTargetElem(e,t){return mt._preElemTemplate(e,t,[EventTarget],["EventTarget"])}_preEventTargetElem(e){return mt._preEventTargetElem(this,e)}static _preElemsAndWindow(e,t){return mt._preElemsTemplate(e,t,[Element,Window],["Element","Window"])}_preElemsAndWindow(e){return mt._preElemsAndWindow(this,e)}static _preElemAndWindow(e,t){return mt._preElemTemplate(e,t,[Element,Window],["Element","Window"])}_preElemAndWindow(e){return mt._preElemAndWindow(this,e)}static _preElemsAndWinAndDoc(e,t){return mt._preElemsTemplate(e,t,[Element,Window,Document],["Element","Window","Document"]).map(e=>e instanceof Document?e.documentElement:e)}_preElemsAndWinAndDoc(e){return mt._preElemsAndWinAndDoc(this,e)}static _preElemAndWinAndDoc(e,t){const r=mt._preElemTemplate(e,t,[Element,Window,Document],["Element","Window","Document"]);return r instanceof Document?r.documentElement:r}_preElemAndWinAndDoc(e){return mt._preElemAndWinAndDoc(this,e)}static _preElemsWithDoc(e,t){return mt._preElemsTemplate(e,t,[Element,Document],["Element","Document"])}_preElemsWithDoc(e){return mt._preElemsWithDoc(this,e)}static _preElemWithDoc(e,t){return mt._preElemTemplate(e,t,[Element,Document],["Element","Document"])}_preElemWithDoc(e){return mt._preElemWithDoc(this,e)}static toTinyElm(e){const t=e=>e.map(e=>e instanceof mt?e:new mt(e));return Array.isArray(e)?t(e):t([e])}static fromTinyElm(e){const t=e=>{const t=[];return e.map(e=>(e instanceof mt?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 mt._preElems(e,r).filter((e,r)=>!!t.call(e,r,e)!==n);if(t instanceof Element)return mt._preElems(e,r).filter(e=>e===t!==n);if(Array.isArray(t)||"string"!=typeof t&&null!=t.length)return mt._preElems(e,r).filter(e=>t.includes(e)!==n);let i=t;return n&&(i=`:not(${i})`),mt._preElems(e,r).filter(e=>1===e.nodeType&&e.matches(i))}static filter(e,t,r=!1){return r&&(t=`:not(${t})`),mt._preElems(e,"filter").filter(e=>1===e.nodeType&&e.matches(t))}static filterOnly(e,t){return mt.winnow(e,t,"filterOnly",!1)}static not(e,t){return mt.winnow(e,t,"not",!0)}not(e){return mt.not(this,e)}static find(e,t){const r=[];for(const n of mt._preElems(e,"find"))r.push(...n.querySelectorAll(t));return[...new Set(r)]}find(e){return mt.find(this,e)}static is(e,t){return mt.winnow(e,t,"is",!1).length>0}is(e){return mt.is(this,e)}static has(e,t){const r="string"==typeof t?[...document.querySelectorAll(t)]:mt._preElems(t,"has");return mt._preElems(e,"has").filter(e=>r.some(t=>e&&e.contains(t)))}has(e){return mt.has(this,e)}static closest(e,t,r){const n=[];for(const i of mt._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 mt.closest(this,e,t)}static isSameDom(e,t){return mt._preNodeElem(e,"isSameDom")===mt._preNodeElem(t,"isSameDom")}isSameDom(e){return mt.isSameDom(this,e)}#ie={};get _data(){return{...this.#ie}}set _data(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new Error("value must be a non-null object.");this.#ie=e}static _dataSelector={public:(e,t)=>{const r=mt._preElem(t,e);let n=ht.get(r);return n||(n={},ht.set(r,n)),n},private:(e,t)=>{if(!(t instanceof mt))throw new Error(`Element must be a TinyHtml instance to execute ${e}().`);return t.#ie}};static data(e,t,r=!1){const n=mt._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 mt.data(this,e,t)}static setData(e,t,r,n=!1){const i=mt._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:mt.removeData(e,t),e}setData(e,t,r=!1){return mt.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=mt._dataSelector[r?"private":"public"]("hasData",e);return Object.prototype.hasOwnProperty.call(n,t)}hasData(e,t=!1){return mt.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 mt._dataSelector[r?"private":"public"]("removeData",e)[t]}removeData(e,t=!1){return mt.removeData(this,e,t)}static _getSibling(e,t,r){let n=mt._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=mt._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=mt._preNodeElemWithNull(e,"parent");const r=t?t.parentNode:null;return r&&11!==r.nodeType?r:null}parent(){return mt.parent(this)}static parents(e,t){return mt.domDir(e,"parentNode",t,"parents")}parents(e){return mt.parents(this,e)}static next(e){return mt._getSibling(e,"nextSibling","next")}next(){return mt.next(this)}static prev(e){return mt._getSibling(e,"previousSibling","prev")}prev(){return mt.prev(this)}static nextAll(e){return mt.domDir(e,"nextSibling",void 0,"nextAll")}nextAll(){return mt.nextAll(this)}static prevAll(e){return mt.domDir(e,"previousSibling",void 0,"prevAll")}prevAll(){return mt.prevAll(this)}static nextUntil(e,t){return mt.domDir(e,"nextSibling",t,"nextUtil")}nextUntil(e){return mt.nextUntil(this,e)}static prevUntil(e,t){return mt.domDir(e,"previousSibling",t,"prevUtil")}prevUntil(e){return mt.prevUntil(this,e)}static siblings(e){const t=mt._preNodeElemWithNull(e,"siblings");return mt._getSiblings(t&&t.parentNode?t.parentNode.firstChild:null,t)}siblings(){return mt.siblings(this)}static children(e){const t=mt._preNodeElemWithNull(e,"children");return mt._getSiblings(t?t.firstChild:null)}children(){return mt.children(this)}static contents(e){const t=mt._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 mt.contents(this)}static clone(e,t=!0){if("boolean"!=typeof t)throw new TypeError('The "deep" must be a boolean.');return mt._preNodeElems(e,"clone").map(e=>e.cloneNode(t))}clone(e){return mt.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 mt)r.push(...mt._preNodeElems(n,e));else if(Array.isArray(n))r.push(...mt._appendChecker(e,...n));else for(const t in n){const i=n[t];r.push(...mt._appendChecker(e,i))}else r.push(n);return r}static append(e,...t){return mt._preElem(e,"append").append(...mt._appendChecker("append",...t)),e}append(...e){return mt.append(this,...e)}static prepend(e,...t){return mt._preElem(e,"prepend").prepend(...mt._appendChecker("prepend",...t)),e}prepend(...e){return mt.prepend(this,...e)}static before(e,...t){return mt._preElem(e,"before").before(...mt._appendChecker("before",...t)),e}before(...e){return mt.before(this,...e)}static after(e,...t){return mt._preElem(e,"after").after(...mt._appendChecker("after",...t)),e}after(...e){return mt.after(this,...e)}static replaceWith(e,...t){return mt._preElem(e,"replaceWith").replaceWith(...mt._appendChecker("replaceWith",...t)),e}replaceWith(...e){return mt.replaceWith(this,...e)}static appendTo(e,t){const r=mt._preNodeElems(e,"appendTo"),n=mt._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 mt.appendTo(this,e)}static prependTo(e,t){const r=mt._preElems(e,"prependTo"),n=mt._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 mt.prependTo(this,e)}static insertBefore(e,t,r=null){const n=mt._preNodeElem(e,"insertBefore"),i=mt._preNodeElem(t,"insertBefore"),o=mt._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 mt.insertBefore(this,e,t)}static insertAfter(e,t,r=null){const n=mt._preNodeElem(e,"insertAfter"),i=mt._preNodeElem(t,"insertBefore"),o=mt._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 mt.insertAfter(this,e,t)}static replaceAll(e,t){const r=mt._preNodeElems(e,"replaceAll"),n=mt._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 mt.replaceAll(this,e)}#G;get size(){return this.#G.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 mt([...this.#G,...mt._selector(e)])}static _selector(e){if(e instanceof mt)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 mt._elCheck(r),t(r);if(r instanceof NodeList||r instanceof HTMLCollection){const e=[...r];return mt._elCheck(e),t(e)}{const e=[r];return mt._elCheck(e),t(e)}}constructor(e){this.#G=mt._selector(e),this.#oe=mt.#se}static isWindow(e){return null!=e&&e===e.window}static css(e){const t=mt._preElem(e,"css");return window.getComputedStyle(t)}css(){return mt.css(this)}static cssString(e,t){const r=mt._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 mt.cssString(this,e)}static cssList(e,t){const r=mt._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 mt.cssList(this,e)}static cssFloat(e,t){const r=mt._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 mt.cssFloat(this,e)}static cssFloats(e,t){const r=mt._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 mt.cssFloats(this,e)}static#ae={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(mt.#ae,{set:(e,t,r)=>(e[t]=r,mt.cssPropRevAliases[r]=t,!0)});static cssPropRevAliases=Object.fromEntries(Object.entries(mt.#ae).map(([e,t])=>[t,e]));static toStyleKc(e){return"string"==typeof mt.cssPropAliases[e]?mt.cssPropAliases[e]:e}static toStyleCc(e){return"string"==typeof mt.cssPropRevAliases[e]?mt.cssPropRevAliases[e]:e}static setStyle(e,t,r=null){return mt._preHtmlElems(e,"setStyle").forEach(e=>{if("object"==typeof t)for(const[r,n]of Object.entries(t))e.style.setProperty(mt.toStyleKc(r),"string"==typeof n?n:"number"==typeof n?`${n}px`:String(n));else e.style.setProperty(mt.toStyleKc(t),r)}),e}setStyle(e,t){return mt.setStyle(this,e,t)}static getStyle(e,t){return mt._preHtmlElem(e,"getStyle").style.getPropertyValue(mt.toStyleKc(t))}getStyle(e){return mt.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=mt._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?mt.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?mt.toStyleCc(n):n]=o}}return i}style(e){return mt.style(this,e)}static removeStyle(e,t){return mt._preHtmlElems(e,"removeStyle").forEach(e=>{if(Array.isArray(t))for(const r of t)e.style.removeProperty(mt.toStyleKc(r));else e.style.removeProperty(mt.toStyleKc(t))}),e}removeStyle(e){return mt.removeStyle(this,e)}static toggleStyle(e,t,r,n){return mt._preHtmlElems(e,"toggleStyle").forEach(e=>{const i=mt.getStyle(e,t).trim()===mt.toStyleKc(r)?n:r;mt.setStyle(e,t,i)}),e}toggleStyle(e,t,r){return mt.toggleStyle(this,e,t,r)}static clearStyle(e){return mt._preElems(e,"clearStyle").forEach(e=>e.removeAttribute("style")),e}clearStyle(){return mt.clearStyle(this)}static focus(e){return mt._preHtmlElem(e,"focus").focus(),e}focus(){return mt.focus(this)}static blur(e){return mt._preHtmlElem(e,"blur").blur(),e}blur(){return mt.blur(this)}static select(e){const t=mt._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 mt.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.");mt.setScrollTop(window,e)}static setWinScrollLeft(e){if("number"!=typeof e)throw new TypeError("The value must be a number.");mt.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=mt._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(mt.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?mt.cssFloat(o,e+"Left")+mt.cssFloat(o,e+"Right"):mt.cssFloat(o,e+"Top")+mt.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 mt.getDimension(this,e,t)}static setHeight(e,t){const r=mt._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 mt.setHeight(this,e)}set height(e){mt.setHeight(this,e)}static setWidth(e,t){const r=mt._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 mt.setWidth(this,e)}set width(e){mt.setWidth(this,e)}static height(e){const t=mt._preElemAndWinAndDoc(e,"height");return mt.getDimension(t,"height","content")}get height(){return mt.height(this)}static width(e){const t=mt._preElemAndWinAndDoc(e,"width");return mt.getDimension(t,"width","content")}get width(){return mt.width(this)}static innerHeight(e){const t=mt._preElemAndWinAndDoc(e,"innerHeight");return mt.getDimension(t,"height","padding")}innerHeight(){return mt.innerHeight(this)}static innerWidth(e){const t=mt._preElemAndWinAndDoc(e,"innerWidth");return mt.getDimension(t,"width","padding")}innerWidth(){return mt.innerWidth(this)}static outerHeight(e,t=!1){if("boolean"!=typeof t)throw new TypeError('The "includeMargin" must be a boolean.');const r=mt._preElemAndWinAndDoc(e,"outerHeight");return mt.getDimension(r,"height",t?"margin":"border")}outerHeight(e){return mt.outerHeight(this,e)}static outerWidth(e,t=!1){if("boolean"!=typeof t)throw new TypeError('The "includeMargin" must be a boolean.');const r=mt._preElemAndWinAndDoc(e,"outerWidth");return mt.getDimension(r,"width",t?"margin":"border")}outerWidth(e){return mt.outerWidth(this,e)}#oe="";get mainDisplay(){return this.#oe}set mainDisplay(e){if("string"!=typeof e)throw new TypeError("mainDisplay must be a string.");this.#oe=e}static#se="block";static get defaultDisplay(){return mt.#se}static set defaultDisplay(e){if("string"!=typeof e)throw new TypeError("defaultDisplay must be a string.");mt.#se=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#le=!0;static get cancelOldStyleFx(){return mt.#le}static set cancelOldStyleFx(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean value.");mt.#le=e}static#ue={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 mt.#ue){const r=mt.#ue[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.`);mt.#ue={};for(const[t,r]of Object.entries(e))mt.setStyleFxSpeed(t,r)}static getStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');const t=mt.#ue[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");mt.#ue[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 mt.#ue[e]}static hasStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(mt.#ue,e)}static#ce=["Top","Right","Bottom","Left"];static#he={slideDown:mt.genStyleFx("show"),slideUp:mt.genStyleFx("hide"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}};static get styleEffects(){return JSON.parse(JSON.stringify(mt.#he))}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}"]`);mt.#he={};for(const t in e)mt.setStyleEffect(t,e[t])}static getStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');const t=mt.#he[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]}mt.#he[e]=r}static deleteStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete mt.#he[e]}static hasStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(mt.#he,e)}static#de={slideDown:"slideUp",slideUp:"slideDown",fadeIn:"fadeOut",fadeOut:"fadeIn",fadeTo:"fadeIn"};static get styleEffectInverse(){return{...mt.#de}}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.`);mt.#de={};for(const[t,r]of Object.entries(e))mt.setStyleEffectInverse(t,r)}static getStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return mt.#de[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.`);mt.#de[e]=t}static deleteStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete mt.#de[e]}static hasStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(mt.#de,e)}static#pe={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{...mt.#pe}}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.`);mt.#pe={};for(const[t,r]of Object.entries(e))mt.setStyleEffectRd(t,r)}static getStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return mt.#pe[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.`);mt.#pe[e]=t}static deleteStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete mt.#pe[e]}static hasStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(mt.#pe,e)}static#fe={show:(e,t,r,n)=>{if("height"===r||"width"===r){const i=mt.getAnimateData(e,`orig${r}`)||e.scrollHeight+"px";mt.setAnimateData(e,`orig${r}`,i);const o=n[r];t[r]=[o,i]}else if(r.startsWith("margin")||r.startsWith("padding")){const i=mt.getAnimateData(e,r)||n[r];mt.setAnimateData(e,r,i),t[r]=["0px",i]}else if("opacity"===r){const e=n.opacity;t[r]=[e,1]}else{const i=mt.getAnimateData(e,r)||n[r];mt.setAnimateData(e,r,i),t[r]=[i,n[r]||1]}},hide:(e,t,r,n)=>{if("height"===r||"width"===r){const i=mt.getAnimateData(e,`orig${r}`)||n[r];mt.setAnimateData(e,`orig${r}`,i);const o=n[r];t[r]=[o,0]}else if(r.startsWith("margin")||r.startsWith("padding")){const i=mt.getAnimateData(e,r)||n[r];mt.setAnimateData(e,r,i),t[r]=[n[r],"0px"]}else if("opacity"===r){const e=n.opacity;t[r]=[e,0]}else{const i=mt.getAnimateData(e,r)||n[r];mt.setAnimateData(e,r,i),t[r]=[i,0]}}};static get styleEffectsProps(){return{...mt.#fe}}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`);mt.#fe={};for(const[t,r]of Object.entries(e))mt.setStyleEffectProp(t,r)}static getStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return mt.#fe[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`);mt.#fe[e]=t}static deleteStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete mt.#fe[e]}static hasStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(mt.#fe,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=mt.#ce[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 mt._preHtmlElems(e,"applyStyleFx").forEach(o=>{const s={};for(const[e,t]of Object.entries(r))if("string"==typeof t&&this.#fe[t]){const r=getComputedStyle(o);this.#fe[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 mt.#pe[t]&&mt.#pe[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,mt.animate(e,a,n,t)[0])}),i}applyStyleFx(e,t,r){return mt.applyStyleFx(this,e,t,r)}static getCurrentAnimationId(e){if(!(e instanceof HTMLElement))throw new TypeError("Expected an HTMLElement.");return pt.get(e)?.id??void 0}static animate(e,t,r=mt.#ue._default,n=null,i=mt.#le){const o="string"==typeof r?mt.#ue[r]??void 0:"number"!=typeof r?{...r}:r;"object"==typeof o&&void 0===o.fill&&(o.fill="forwards");const s=[];return mt._preHtmlElems(e,"animate").forEach(e=>{if(i){const t=pt.get(e);t&&t.animation.cancel()}const r=e.animate(t,o);s.push(r),pt.set(e,{animation:r,id:n??""}),r.addEventListener("finish",()=>{pt.get(e)?.animation===r&&pt.delete(e)})}),s}animate(e,t,r,n){return mt.animate(this,e,t,r,n)}static stop(e){const t=[];return mt._preHtmlElems(e,"stop").forEach(e=>{const r=pt.get(e);r?(r.animation.cancel(),pt.delete(e),t.push(!0)):t.push(!1)}),t}stop(){return mt.stop(this)}static slideDown(e,t){return mt.applyStyleFx(e,"slideDown",this.#he.slideDown,t??{duration:500,easing:"ease-out"})}slideDown(e){return mt.slideDown(this,e)}static slideUp(e,t){return mt.applyStyleFx(e,"slideUp",this.#he.slideUp,t??{duration:500,easing:"ease-out"})}slideUp(e){return mt.slideUp(this,e)}static slideToggle(e,t){const r=mt._preHtmlElem(e,"slideToggle"),n=getComputedStyle(r),i=mt.getCurrentAnimationId(r),o="none"===n.display||0===r.offsetHeight;return("string"==typeof i?"slideUp"===i:o)?mt.slideDown(e,t):mt.slideUp(e,t)}slideToggle(e){return mt.slideToggle(this,e)}static fadeIn(e,t){return mt.applyStyleFx(e,"fadeIn",this.#he.fadeIn,t)}fadeIn(e){return mt.fadeIn(this,e)}static fadeOut(e,t){return mt.applyStyleFx(e,"fadeOut",this.#he.fadeOut,t)}fadeOut(e){return mt.fadeOut(this,e)}static fadeToggle(e,t){const r=mt._preHtmlElem(e,"fadeToggle"),n=getComputedStyle(r),i=mt.getCurrentAnimationId(r),o="0"===n.opacity||null===r.offsetParent;return("string"==typeof i?"fadeOut"===i:o)?mt.fadeIn(e,t):mt.fadeOut(e,t)}fadeToggle(e){return mt.fadeToggle(this,e)}static fadeTo(e,t,r,n=mt.#se){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 mt._preHtmlElems(e,"fadeTo").forEach(o=>{const s=getComputedStyle(o);if(!(e instanceof Element&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length))){const e=mt.getAnimateData(o,"origdisplay");o.style.display="string"==typeof e?e:n}const a=[s.opacity,t].map(e=>({opacity:e}));i.set(o,mt.animate(o,a,r,"fadeTo")[0])}),i}fadeTo(e,t,r=this.#oe){return mt.fadeTo(this,e,t,r)}static offset(e){const t=mt._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 mt.offset(this)}static position(e){const t=mt._preHtmlElem(e,"position");let r,n,i={top:0,left:0};if("fixed"===window.getComputedStyle(t).position)n=t.getBoundingClientRect();else{n=mt.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}=mt.cssFloats(r,["borderTopWidth","borderLeftWidth"]);i=mt.offset(r),i.top+=e,i.left+=t}}return{top:n.top-i.top-mt.cssFloat(t,"marginTop"),left:n.left-i.left-mt.cssFloat(t,"marginLeft")}}position(){return mt.position(this)}static offsetParent(e){let t=mt._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 mt.offsetParent(this)}static scrollTop(e){const t=mt._preElemAndWindow(e,"scrollTop");return mt.isWindow(t)?t.pageYOffset:9===t.nodeType?t.defaultView.pageYOffset:t.scrollTop}scrollTop(){return mt.scrollTop(this)}static scrollLeft(e){const t=mt._preElemAndWindow(e,"scrollLeft");return mt.isWindow(t)?t.pageXOffset:9===t.nodeType?t.defaultView.pageXOffset:t.scrollLeft}scrollLeft(){return mt.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 mt.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 mt._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&&mt.easings[i]||null;if("number"!=typeof n||"function"!=typeof d)return s(e,l,u,1);const p=performance.now(),f=n??0;requestAnimationFrame(function t(r){if("function"!=typeof d)return;const n=Math.min(1,(r-p)/f),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 mt.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 mt.scrollToXY(e,{targetY:t})}setScrollTop(e){return mt.setScrollTop(this,e)}static setScrollLeft(e,t){if("number"!=typeof t)throw new TypeError("ScrollLeft value must be a number.");return mt.scrollToXY(e,{targetX:t})}setScrollLeft(e){return mt.setScrollLeft(this,e)}static borderWidth(e){const t=mt._preElem(e,"borderWidth"),{borderLeftWidth:r,borderRightWidth:n,borderTopWidth:i,borderBottomWidth:o}=mt.cssFloats(t,["borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"]);return{x:r+n,y:i+o,left:r,right:n,top:i,bottom:o}}borderWidth(){return mt.borderWidth(this)}static border(e){const t=mt._preElem(e,"border"),{borderLeft:r,borderRight:n,borderTop:i,borderBottom:o}=mt.cssFloats(t,["borderLeft","borderRight","borderTop","borderBottom"]);return{x:r+n,y:i+o,left:r,right:n,top:i,bottom:o}}border(){return mt.border(this)}static margin(e){const t=mt._preElem(e,"margin"),{marginLeft:r,marginRight:n,marginTop:i,marginBottom:o}=mt.cssFloats(t,["marginLeft","marginRight","marginTop","marginBottom"]);return{x:r+n,y:i+o,left:r,right:n,top:i,bottom:o}}margin(){return mt.margin(this)}static padding(e){const t=mt._preElem(e,"padding"),{paddingLeft:r,paddingRight:n,paddingTop:i,paddingBottom:o}=mt.cssFloats(t,["paddingLeft","paddingRight","paddingTop","paddingBottom"]);return{x:r+n,y:i+o,left:r,right:n,top:i,bottom:o}}padding(){return mt.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(mt.#me){const t=e.split(" ");for(const e of t)r.push(e)}else r.push(e);return mt._preElems(e,"addClass").forEach(e=>e.classList.add(...r)),e}addClass(...e){return mt.addClass(this,...e)}static removeClass(e,...t){const r=[];for(const e of t)if(mt.#me){const t=e.split(" ");for(const e of t)r.push(e)}else r.push(e);return mt._preElems(e,"removeClass").forEach(e=>e.classList.remove(...r)),e}removeClass(...e){return mt.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 mt._preElems(e,"replaceClass").forEach(e=>n.push(e.classList.replace(t,r))),n}replaceClass(e,t){return mt.replaceClass(this,e,t)[0]}static classItem(e,t){const r=mt._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 mt.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 mt._preElems(e,"toggleClass").forEach(e=>n.push(e.classList.toggle(t,r))),n}toggleClass(e,t){return mt.toggleClass(this,e,t)[0]}static hasClass(e,t){const r=mt._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 mt.hasClass(this,e)}static classLength(e){return mt._preElem(e,"classLength").classList.length}classLength(){return mt.classLength(this)}static classList(e){return mt._preElem(e,"classList").classList.values().toArray()}classList(){return mt.classList(this)}static tagName(e){return mt._preElem(e,"tagName").tagName}tagName(){return mt.tagName(this)}static id(e){return mt._preElem(e,"id").id}get id(){return mt.id(this)}set id(e){mt.setAttr(this,"id",e)}static toBigInt(e){const t=mt._preElem(e,"toBigInt"),r=t.textContent?.trim();let n=null;try{n=BigInt(r??"")}catch{n=null}return n}toBigInt(){return mt.toBigInt(this)}static setBigInt(e,t){if("bigint"!=typeof t)throw new Error("Value is not a valid BigInt.");const r=t.toString();return mt._preElems(e,"setBigInt").forEach(e=>e.textContent=r),e}setBigInt(e){return mt.setBigInt(this,e)}static toDate(e){const t=mt._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 mt.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 mt._preElems(e,"setDate").forEach(e=>e.textContent=r),e}setDate(e){return mt.setDate(this,e)}static toJson(e){const t=mt._preElem(e,"toJson"),r=t.textContent?.trim();if(!r)return null;try{return JSON.parse(r)}catch{return null}}toJson(){return mt.toJson(this)}static setJson(e,t,r,n){const i=JSON.stringify(t,r,n);return mt._preElems(e,"setJson").forEach(e=>e.textContent=i),e}setJson(e,t,r){return mt.setJson(this,e,t,r)}static toNumber(e){const t=mt._preElem(e,"toNumber");return"string"==typeof t.textContent?parseFloat(t.textContent.trim()):null}toNumber(){return mt.toNumber(this)}static setNumber(e,t){if("number"!=typeof t)throw new Error("Value is not a valid number.");const r=t.toString();return mt._preElems(e,"setNumber").forEach(e=>e.textContent=r),e}setNumber(e){return mt.setNumber(this,e)}static toBoolean(e){const t=mt._preElem(e,"toBoolean"),r=t.textContent?.trim();return null==r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}toBoolean(){return mt.toBoolean(this)}static setBoolean(e,t){if("boolean"!=typeof t)throw new Error("Value is not a valid boolean.");const r=t.toString();return mt._preElems(e,"setBoolean").forEach(e=>e.textContent=r),e}setBoolean(e){return mt.setBoolean(this,e)}static toString(e){const t=mt._preElem(e,"toString");return"string"==typeof t.textContent?t.textContent:null}toString(){return mt.toString(this)}static setString(e,t){if("string"!=typeof t)throw new Error("Value is not a valid string.");return mt._preElems(e,"setString").forEach(e=>e.textContent=t),e}setString(e){return mt.setString(this,e)}static text(e){return mt._preElem(e,"text").textContent}text(){return mt.text(this)}static setText(e,t){const r=null!=t?String(t):"";return mt._preElems(e,"setText").forEach(e=>e.textContent=r),e}setText(e){return mt.setText(this,e)}static empty(e){return mt._preElems(e,"empty").forEach(e=>e.textContent=""),e}empty(){return mt.empty(this)}static html(e,t){return mt._preElem(e,"html").getHTML(t)}html(e){return mt.html(this,e)}static setHtml(e,t){if("string"!=typeof t)throw new Error("Value is not a valid string.");return mt._preElems(e,"setHtml").forEach(e=>e.innerHTML=t),e}setHtml(e){return mt.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=mt._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=mt._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 mt._preInputElems(e,"setVal").forEach(e=>{if(1!==e.nodeType)return;let r="function"==typeof t?t(e,mt.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=mt._valHooks[e.type]||mt._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 mt.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 mt._valTypes[t])throw new Error(`No handler found for type "${t}" in ${r}().`);return mt._valTypes[t](e)}static _val(e,t,r){const n=mt._preInputElem(e,t),i=mt._valHooks[n.type]||mt._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 mt._getValByType(n,r,t)}_val(e,t){return mt._val(this,e,t)}static val(e){return mt._val(e,"val","string")}val(){return mt.val(this)}static valTxt(e){const t=mt._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 mt.valTxt(this)}static _valArr(e,t,r){const n=mt._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 mt._valArr(this,e,t)}static valArr(e){return mt._valArr(e,"valArr","string")}valArr(){return mt.valArr(this)}static valNb(e){if(!(mt._preInputElem(e,"valNb")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const t=mt._val(e,"valNb","number");if(Number.isNaN(t))throw new Error("Value is not a valid number.");return t}valNb(){return mt.valNb(this)}static valDate(e){if(!(mt._preInputElem(e,"valDate")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const t=mt._val(e,"valDate","date");if(!(t instanceof Date))throw new Error("Value is not a valid date.");return t}valDate(){return mt.valDate(this)}static valBool(e){const t=mt._preInputElem(e,"valBool");if(!(t instanceof HTMLInputElement))throw new Error("Element must be an input element.");return"on"===mt.val(t)}valBool(){return mt.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 mt._preElemsWithDoc(e,"listenForPaste").forEach(e=>mt.on(e,"paste",n)),n}listenForPaste({onFilePaste:e,onTextPaste:t}={}){return mt.listenForPaste(this,{onFilePaste:e,onTextPaste:t})}static hasEventListener(e,t){const r=mt._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 mt.hasEventListener(this,e)}static hasExactEventListener(e,t,r){const n=mt._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 mt.hasExactEventListener(this,e,t)}static hover(e,t,r,n){return mt.on(e,"mouseenter",t,n),mt.on(e,"mouseleave",r||t,n),e}hover(e,t,r){return mt.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.");mt._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 mt.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.");mt._preEventTargetElems(e,"once").forEach(e=>{const t=n=>{mt.off(e,i,t),"function"==typeof r&&r(n)};mt.on(e,i,t,"boolean"==typeof n?n:{...n,once:!0})})}return e}once(e,t,r={}){return mt.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.");mt._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 mt.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.");mt._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 mt.offAll(this,e)}static offAllTypes(e,t=null){if(null!==t&&"function"!=typeof t)throw new TypeError('The "filterFn" must be a function.');return mt._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 mt.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.");mt._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 mt.trigger(this,e,t)}static#ge={for:"htmlFor",class:"className"};static propFix=new Proxy(mt.#ge,{set:(e,t,r)=>(e[t]=r,mt.attrFix[r]=t,!0)});static attrFix=Object.fromEntries(Object.entries(mt.#ge).map(([e,t])=>[t,e]));static getPropName(e){return"string"==typeof mt.propFix[e]?mt.propFix[e]:e}static getAttrName(e){return"string"==typeof mt.attrFix[e]?mt.attrFix[e]:e}static attrBigInt(e,t){const r=mt._preElem(e,"attrBigInt").getAttribute(mt.getAttrName(t));if(null==r)return null;try{return BigInt(r)}catch{return null}}attrBigInt(e){return mt.attrBigInt(this,e)}static setAttrBigInt(e,t,r){if("bigint"!=typeof r)throw new Error("Value is not a valid BigInt.");return mt.setAttr(e,t,r.toString())}setAttrBigInt(e,t){return mt.setAttrBigInt(this,e,t)}static attrDate(e,t){const r=mt._preElem(e,"attrDate").getAttribute(mt.getAttrName(t));if(!r)return null;const n=new Date(r);return Number.isNaN(n.getTime())?null:n}attrDate(e){return mt.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 mt.setAttr(e,t,r.toISOString())}setAttrDate(e,t){return mt.setAttrDate(this,e,t)}static attrJson(e,t){const r=mt._preElem(e,"attrJson").getAttribute(mt.getAttrName(t));if(!r)return null;try{return JSON.parse(r)}catch{return null}}attrJson(e){return mt.attrJson(this,e)}static setAttrJson(e,t,r,n,i){const o=JSON.stringify(r,n,i);return mt.setAttr(e,t,o)}setAttrJson(e,t,r,n){return mt.setAttrJson(this,e,t,r,n)}static attrNumber(e,t){const r=mt._preElem(e,"attrNumber").getAttribute(mt.getAttrName(t));return null!=r?parseFloat(r):null}attrNumber(e){return mt.attrNumber(this,e)}static setAttrNumber(e,t,r){if("number"!=typeof r)throw new Error("Value is not a valid number.");return mt.setAttr(e,t,r.toString())}setAttrNumber(e,t){return mt.setAttrNumber(this,e,t)}static attrBoolean(e,t){const r=mt._preElem(e,"attrBoolean").getAttribute(mt.getAttrName(t));return null===r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}attrBoolean(e){return mt.attrBoolean(this,e)}static setAttrBoolean(e,t,r){if("boolean"!=typeof r)throw new Error("Value is not a valid boolean.");return mt.setAttr(e,t,r.toString())}setAttrBoolean(e,t){return mt.setAttrBoolean(this,e,t)}static attrString(e,t){const r=mt._preElem(e,"attrString").getAttribute(mt.getAttrName(t));return"string"==typeof r?r:null}attrString(e){return mt.attrString(this,e)}static setAttrString(e,t,r){if("string"!=typeof r)throw new Error("Value is not a valid string.");return mt.setAttr(e,t,r)}setAttrString(e,t){return mt.setAttrString(this,e,t)}static attr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return mt._preElem(e,"attr").getAttribute(mt.getAttrName(t))}attr(e){return mt.attr(this,e)}static setAttr(e,t,r=null){const n=mt._preElems(e,"setAttr");if("object"==typeof t&&null!==t)return Object.entries(t).forEach(([e,t])=>n.forEach(r=>{null===t?r.removeAttribute(mt.getAttrName(e)):r.setAttribute(mt.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(mt.getAttrName(t)):e.setAttribute(mt.getAttrName(t),String(r))}),e}setAttr(e,t){return mt.setAttr(this,e,t)}static removeAttr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return mt._preElems(e,"removeAttr").forEach(e=>e.removeAttribute(mt.getAttrName(t))),e}removeAttr(e){return mt.removeAttr(this,e)}static hasAttr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return mt._preElem(e,"hasAttr").hasAttribute(mt.getAttrName(t))}hasAttr(e){return mt.hasAttr(this,e)}static hasProp(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return!!mt._preElem(e,"hasProp")[mt.getPropName(t)]}hasProp(e){return mt.hasProp(this,e)}static addProp(e,...t){return mt._preElems(e,"addProp").forEach(e=>{t.forEach(t=>{if("string"!=typeof t)throw new TypeError('Each "name" must be a string.');e[mt.getPropName(t)]=!0})}),e}addProp(...e){return mt.addProp(this,...e)}static removeProp(e,...t){return mt._preElems(e,"removeProp").forEach(e=>{t.forEach(t=>{if("string"!=typeof t)throw new TypeError('Each "name" must be a string.');e[mt.getPropName(t)]=!1})}),e}removeProp(...e){return mt.removeProp(this,...e)}static toggleProp(e,t,r){const n=mt._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[mt.getPropName(e)]:r)?mt.addProp(t,e):mt.removeProp(t,e)})}),e}toggleProp(e,t){return mt.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 mt._preElem(e,"prop")[t]}prop(e){return mt.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 mt._preElems(e,"setProp").forEach(e=>{e[t]=r}),e}setProp(e,t){return mt.setProp(this,e,t)}static remove(e){return mt._preElems(e,"remove").forEach(e=>e.remove()),e}remove(){return mt.remove(this)}static index(e,t=null){const r=mt._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):mt._preElems(t,"index");return Array.prototype.indexOf.call(e,r)}return-1}index(e){return mt.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=mt._getCustomRect(mt._preElem(e,"isCollWith").getBoundingClientRect(),r),i=mt._preElem(t,"isCollWith").getBoundingClientRect();return it(n,i)}isCollWith(e,t){return mt.isCollWith(this,e,t)}static isCollPerfWith(e,t,r={}){const n=mt._getCustomRect(mt._preElem(e,"isCollPerfWith").getBoundingClientRect(),r),i=mt._preElem(t,"isCollPerfWith").getBoundingClientRect();return ot(n,i)}isCollPerfWith(e,t){return mt.isCollPerfWith(this,e,t)}static _isCollWithLock(e,t,r,n,i){const o=ft[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=mt._preElem(e,"isCollWithLock"),o=mt._preElem(t,"isCollWithLock"),s=mt._getCustomRect(i.getBoundingClientRect(),n),a=o.getBoundingClientRect(),l=it(s,a);return mt._isCollWithLock(l,s,a,i,r)}isCollWithLock(e,t,r){return mt.isCollWithLock(this,e,t,r)}static isCollPerfWithLock(e,t,r,n={}){const i=mt._preElem(e,"isCollPerfWithLock"),o=mt._preElem(t,"isCollPerfWithLock"),s=mt._getCustomRect(i.getBoundingClientRect(),n),a=o.getBoundingClientRect(),l=ot(s,a);return mt._isCollWithLock(l,s,a,i,r)}isCollPerfWithLock(e,t,r){return mt.isCollPerfWithLock(this,e,t,r)}static resetCollLock(e){const t=mt._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 mt.resetCollLock(this)}static resetCollLockDir(e,t){const r=mt._preElem(e,"resetCollLockDir"),n=ft[t];return!!n.has(r)&&(n.delete(r),!0)}resetCollLockDir(e){return mt.resetCollLockDir(this,e)}static isInViewport(e){const t=mt._preElem(e,"isInViewport");if(!t.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=mt.offset(t).top,n=r+mt.outerHeight(t),i=mt.scrollTop(window),o=i+mt.height(window);return n>i&&r<o}isInViewport(){return mt.isInViewport(this)}static isScrolledIntoView(e){const t=mt._preElem(e,"isScrolledIntoView");if(!t.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=mt.scrollTop(window),n=r+mt.height(window),i=mt.offset(t).top;return i+mt.height(t)<=n&&i>=r}isScrolledIntoView(){return mt.isScrolledIntoView(this)}static isInContainer(e,t){const r=mt._preElem(e,"isInContainer"),n=mt._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 mt.isInContainer(this,e)}static isFullyInContainer(e,t){const r=mt._preElem(e,"isScrolledIntoView"),n=mt._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 mt.isFullyInContainer(this,e)}static hasScroll(e){const t=mt._preElem(e,"hasScroll");return{v:t.scrollHeight>t.clientHeight,h:t.scrollWidth>t.clientWidth}}hasScroll(){return mt.hasScroll(this)}}const gt=mt;class yt{static Utils={...e,TinyHtml:gt};#ye=!0;#we=!1;#be=0;#ve=0;#Ee=!0;#Te=!1;#Se=!1;#xe=!1;#Ae=!1;#Ce=!1;#Ie=!1;#Me=null;#Le=[];#ke=null;#Ne={start:!1,end:!1,collide:!1,move:!1};#_e=null;#B;#De="drag-hidden";#je="dragging";#Re="drag-active";#Oe="jail-drag-active";#He="jail-drag-disabled";#$e="dragging-collision";#Be=9999;constructor(e,t={}){const r=e instanceof gt?e.get(0):e;if(!(r instanceof HTMLElement))throw new Error("TinyDragger requires a valid target HTMLElement to initialize.");if(this.#B=r,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 n=(e,t)=>{if(void 0!==e&&"boolean"!=typeof e)throw new Error(`The "${t}" option must be a boolean.`)},i=(e,t)=>{if(void 0!==e&&"string"!=typeof e)throw new Error(`The "${t}" option must be a string.`)};n(t.mirrorElem,"mirrorElem"),n(t.collisionByMouse,"collisionByMouse"),n(t.lockInsideJail,"lockInsideJail"),n(t.dropInJailOnly,"dropInJailOnly"),n(t.revertOnDrop,"revertOnDrop"),n(t.multiCollision,"multiCollision"),i(t.classDragging,"classDragging"),i(t.classBodyDragging,"classBodyDragging"),i(t.classJailDragging,"classJailDragging"),i(t.classJailDragDisabled,"classJailDragDisabled"),i(t.classDragCollision,"classDragCollision"),i(t.classHidden,"classHidden"),t.jail instanceof HTMLElement&&(this.#_e=t.jail),this.#Ne=Object.assign({start:!1,end:!1,collide:!1,move:!1},f(t.vibration)?t.vibration:{}),"string"==typeof t.classDragging&&(this.#je=t.classDragging),"string"==typeof t.classBodyDragging&&(this.#Re=t.classBodyDragging),"string"==typeof t.classJailDragging&&(this.#Oe=t.classJailDragging),"string"==typeof t.classJailDragDisabled&&(this.#He=t.classJailDragDisabled),"string"==typeof t.classHidden&&(this.#De=t.classHidden),"string"==typeof t.classDragCollision&&(this.#$e=t.classDragCollision),"boolean"==typeof t.collisionByMouse&&(this.#Ce=t.collisionByMouse),"boolean"==typeof t.mirrorElem&&(this.#Ee=t.mirrorElem),"boolean"==typeof t.revertOnDrop&&(this.#xe=t.revertOnDrop),"boolean"==typeof t.lockInsideJail&&(this.#Se=t.lockInsideJail),"boolean"==typeof t.dropInJailOnly&&(this.#Ie=t.dropInJailOnly),"boolean"==typeof t.multiCollision&&(this.#Te=t.multiCollision),this._onMouseDown=this.#Pe.bind(this),this._onMouseMove=this.#Fe.bind(this),this._onMouseUp=this.#We.bind(this),this._onTouchStart=e=>this.#Pe(e.touches[0]),this._onTouchMove=e=>this.#Fe(e.touches[0]),this._onTouchEnd=e=>this.#We(e.changedTouches[0]),this.#B.addEventListener("mousedown",this._onMouseDown),this.#B.addEventListener("touchstart",this._onTouchStart,{passive:!1})}enable(){this.#ze(),this.#_e&&this.#_e.classList.add(this.#He),this.#ye=!0}disable(){this.#_e&&this.#_e.classList.remove(this.#He),this.#ye=!1}addCollidable(e){if(this.#ze(),!(e instanceof HTMLElement))throw new Error("addCollidable expects an HTMLElement as argument.");this.#Le.includes(e)||this.#Le.push(e)}removeCollidable(e){if(this.#ze(),!(e instanceof HTMLElement))throw new Error("removeCollidable expects an HTMLElement as argument.");this.#Le=this.#Le.filter(t=>t!==e)}setVibrationPattern({startPattern:e=!1,endPattern:t=!1,collidePattern:r=!1,movePattern:n=!1}={}){this.#ze();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.#Ne={start:e,end:t,collide:r,move:n}}disableVibration(){this.#ze(),this.#Ne={start:!1,end:!1,collide:!1,move:!1}}getOffset(e){if(this.#ze(),!(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.#B.getBoundingClientRect(),{left:r,top:n}=gt.borderWidth(this.#B);return{x:e.clientX-t.left+r,y:e.clientY-t.top+n}}#Pe(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#we||!this.#ye||!this.#B.parentElement)return;if(this.#Ee){const e=this.#B.cloneNode(!0);if(!(e instanceof HTMLElement))throw new Error("[TinyDragger] INVALID DRAG ELEMENT!");this.#ke=e}else this.#ke=this.#B;this.#Ae=!0;const t=this.#B.getBoundingClientRect();Object.assign(this.#ke.style,{position:"absolute",pointerEvents:"none",left:`${this.#B.offsetLeft}px`,top:`${this.#B.offsetTop}px`,width:`${t.width}px`,height:`${t.height}px`,zIndex:this.#Be}),this.#Ee&&(this.#B.classList.add(this.#De),this.#B.parentElement.appendChild(this.#ke));const{x:r,y:n}=this.getOffset(e);this.#ve=r,this.#be=n,this.#ke.classList.add(this.#je),document.body.classList.add(this.#Re),this.#_e&&this.#_e.classList.add(this.#Oe),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.#Ne.start)&&navigator.vibrate(this.#Ne.start),this.checkDragCollision(e),this.#qe("drag")}#Ve=[];#Ue(e){e&&(e.classList.add(this.#$e),this.#Ve.push(e))}#Ke(){for(;this.#Ve.length>0;){const e=this.#Ve.shift();e&&e.classList.remove(this.#$e)}this.#Me&&this.#Me.classList.remove(this.#$e)}checkDragCollision(e){const{collidedElements:t}=this.execCollision(e),r=t[0]||null;this.#Me&&!t.includes(this.#Me)&&this.#Ke(),t.forEach(e=>this.#Ue(e)),this.#Le.forEach(e=>{t.includes(e)||e.classList.remove(this.#$e)}),navigator.vibrate&&Array.isArray(this.#Ne.collide)&&t.length>0&&navigator.vibrate(this.#Ne.collide),this.#Me=r}#Fe(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#we||!this.#Ae||!this.#ye||!this.#ke)return;const t=(this.#ke.offsetParent||document.body).getBoundingClientRect();let r=e.clientX-t.left-this.#ve,n=e.clientY-t.top-this.#be;if(this.#Se&&this.#_e){const e=this.#_e.getBoundingClientRect(),i=this.#ke.getBoundingClientRect(),o=e.left-t.left,s=e.top-t.top,{x:a,y:l}=gt.borderWidth(this.#_e),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.#Ne.move)&&navigator.vibrate(this.#Ne.move),this.checkDragCollision(e),this.#qe("dragging")}execCollision(e){if(this.#we||!this.#ke)return{inJail:!1,collidedElements:[]};let t=[],r=!0;const n=this.#_e?.getBoundingClientRect();if(this.#Ce){const i=e.clientX,o=e.clientY;this.#Ie&&this.#_e&&n&&(r=i>=n.left&&i<=n.right&&o>=n.top&&o<=n.bottom),t=r?this.#Te?this.getAllCollidedElements(i,o):[this.getCollidedElement(i,o)].filter(Boolean):[]}else{const e=this.#ke.getBoundingClientRect();this.#Ie&&this.#_e&&n&&(r=e.left>=n.left&&e.right<=n.right&&e.top>=n.top&&e.bottom<=n.bottom),t=r?this.#Te?this.getAllCollidedElementsByRect(e):[this.getCollidedElementByRect(e)].filter(Boolean):[]}return{inJail:r,collidedElements:t}}#We(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#we||!this.#Ae)return;if(this.#Ae=!1,!this.#ke)return;this.#B.classList.remove(this.#je),document.body.classList.remove(this.#Re),this.#_e&&this.#_e.classList.remove(this.#Oe),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.#Ne.end)&&navigator.vibrate(this.#Ne.end);const r=this.#ke.style.left,n=this.#ke.style.top;this.#ke&&(this.#Ee?this.#ke.remove():Object.assign(this.#ke.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#ke=null),this.#Me&&this.#Ke(),this.#Me=null,this.#Ee&&this.#B.classList.remove(this.#De),this.#xe||(this.#B.style.left=r,this.#B.style.top=n);const i=new CustomEvent("drop",{detail:{targets:t,first:t[0]||null}});this.#B.dispatchEvent(i)}#Je(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.#ze(),!(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.#Le.filter(t=>this.#Je(t,e))}getCollidedElementByRect(e){if(this.#ze(),!(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.#Le.find(t=>this.#Je(t,e))||null}#Ge(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.#ze(),"number"!=typeof e||"number"!=typeof t)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#Le.filter(r=>this.#Ge(r,e,t))}getCollidedElement(e,t){if(this.#ze(),"number"!=typeof e||"number"!=typeof t)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#Le.find(r=>this.#Ge(r,e,t))||null}#qe(e){const t=new CustomEvent(e);this.#B.dispatchEvent(t)}getDragging(){return this.#Ae}getLockInsideJail(){return this.#Se}setLockInsideJail(e){if("boolean"!=typeof e)throw new Error("lockInsideJail must be a boolean.");this.#Se=e}getRevertOnDrop(){return this.#xe}setRevertOnDrop(e){if("boolean"!=typeof e)throw new Error("revertOnDrop must be a boolean.");this.#xe=e}getCollisionByMouse(){return this.#Ce}setCollisionByMouse(e){if("boolean"!=typeof e)throw new Error("collisionByMouse must be a boolean.");this.#Ce=e}getDropInJailOnly(){return this.#Ie}setDropInJailOnly(e){if("boolean"!=typeof e)throw new Error("dropInJailOnly must be a boolean.");this.#Ie=e}getDefaultZIndex(){return this.#Be}setDefaultZIndex(e){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("Z-index must be a finite number.");this.#Be=e}isMirrorEnabled(){return this.#Ee}setMirrorEnabled(e){if("boolean"!=typeof e)throw new TypeError("Mirror setting must be a boolean.");this.#Ee=e}getTarget(){return this.#B}getJail(){return this.#_e}getDragProxy(){return this.#ke}getLastCollision(){return this.#Me}getCollidables(){return[...this.#Le]}getDragHiddenClass(){return this.#De}getClassDragging(){return this.#je}getClassBodyDragging(){return this.#Re}getClassJailDragging(){return this.#Oe}getClassJailDragDisabled(){return this.#He}getClassDragCollision(){return this.#$e}getVibrations(){return{...this.#Ne}}getStartVibration(){return this.#Ne.start}getEndVibration(){return this.#Ne.end}getCollideVibration(){return this.#Ne.collide}getMoveVibration(){return this.#Ne.move}isEnabled(){return this.#ye}#ze(){if(this.#we)throw new Error("This TinyDragger instance has been destroyed and can no longer be used.")}destroy(){this.#we||(this.disable(),this.#B.removeEventListener("mousedown",this._onMouseDown),this.#B.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.#Me&&this.#Ke(),this.#ke&&(this.#Ee?this.#ke.remove():Object.assign(this.#ke.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#ke=null),this.#Le=[],this.#Ae=!1,this.#Me=null,this.#Ee&&this.#B.classList.remove(this.#De),this.#B.classList.remove(this.#je),document.body.classList.remove(this.#Re),this.#_e&&this.#_e.classList.remove(this.#Oe,this.#He),this.#we=!0)}}const wt=yt,bt=class{#Ye=[];#Xe=!1;#Qe=!1;#Ze=[];#et(){this.#Xe&&Promise.all(this.#Ze).then(()=>{this.#Qe=!0,this.#tt(!1)}).catch(e=>{console.error("[TinyDomReadyManager] Promise rejected:",e)})}#tt(e){this.#Ye.filter(t=>t.domOnly===e).sort((e,t)=>t.priority-e.priority).forEach(e=>this.#rt(e)),this.#Ye=this.#Ye.filter(t=>!(t.once&&(!e||t.domOnly)))}#rt(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.#Xe=!0,this.#tt(!0),this.#et()}init(){if(this.#Xe)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.#Qe||(this.#Ze.push(e),this.#Xe&&this.#et())}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.#Xe)return this.#rt(o),void(t||this.#Ye.push(o));!i&&this.#Qe?this.#rt(o):this.#Ye.push(o)}isReady(){return this.#Qe}isDomReady(){return this.#Xe}},vt=class{#nt=!1;#it=!1;#ot=null;#st=100;#at=null;#lt;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.#ot="string"!=typeof e?e:new Audio(e),this.#at=t,this.#st=r,this.#lt=n}requestPerm(){const e=this;return new Promise((t,r)=>{e.isCompatible()?"default"===Notification.permission?Notification.requestPermission().then(r=>{this.#it=!0,e.#nt="granted"===r,t(e.#nt)}).catch(r):(this.#it=!0,e.#nt="granted"===Notification.permission,t(e.#nt)):(this.#it=!0,e.#nt=!1,t(!1))})}isCompatible(){return"Notification"in window}send(e,t={}){if(!this.#it)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.#nt)return null;const{icon:r=this.#at||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=z(i.body,this.#st));const o=new Notification(e,i);return o.addEventListener("show",()=>{this.#ot instanceof HTMLAudioElement&&(this.#ot.currentTime=0,this.#ot.play().catch(e=>console.error(e)))}),"function"==typeof this.#lt&&o.addEventListener("click",this.#lt),o}wasPermissionRequested(){return this.#it}isAllowed(){return this.#nt}getAudio(){return this.#ot}setAudio(e){if(!(e instanceof HTMLAudioElement)&&"string"!=typeof e&&null!==e)throw new TypeError("sound must be an instance of HTMLAudioElement or null.");this.#ot="string"!=typeof e?e:new Audio(e)}getBodyLimit(){return this.#st}setBodyLimit(e){if(!Number.isFinite(e)||e<0)throw new TypeError("bodyLimit must be a non-negative number.");this.#st=e}getDefaultAvatar(){return this.#at}setDefaultAvatar(e){if("string"!=typeof e&&null!==e)throw new TypeError("defaultIcon must be a string or null.");this.#at=e}getDefaultOnClick(){return this.#lt}setDefaultOnClick(e){if("function"!=typeof e)throw new TypeError("defaultOnClick must be a function.");this.#lt=e}},Et=class{#ut;#ct=null;#ht=[];#dt=100;#pt=new Set;#ft=new Set;#we=!1;constructor(e=window,t=100){if(!(e instanceof Element||e instanceof Window))throw new TypeError("scrollTarget must be an Element or the Window object.");this.#ut=e,this._checkTimer=this._checkTimer.bind(this),this.#ut.addEventListener("scroll",this._checkTimer),this.#dt=t}_checkTimer=()=>{this.#ct&&clearTimeout(this.#ct),this.#ct=setTimeout(()=>{this.#ct=null,this.#mt()},this.#dt)};get inactivityTime(){return this.#dt}set inactivityTime(e){if("number"!=typeof e||e<=0||!Number.isFinite(e))throw new Error("inactivityTime must be a positive number in milliseconds.");this.#dt=e}#mt(){if(!this.#we){for(const e of this.#ft)"function"==typeof e&&e();for(;this.#ht.length;){const e=this.#ht.pop();"function"==typeof e&&e()}}}doAfterScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.lastScrollTime=Date.now(),this.#ht.push(e)}onStop(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ft.add(e)}offStop(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ft.delete(e)}onScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ut.addEventListener("scroll",e),this.#pt.add(e)}offScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#pt.has(e)&&(this.#ut.removeEventListener("scroll",e),this.#pt.delete(e))}destroy(){if(!this.#we){this.#we=!0,this.#ut.removeEventListener("scroll",this._checkTimer);for(const e of this.#pt)this.#ut.removeEventListener("scroll",e);this.#pt.clear(),this.#ft.clear()}}},Tt=["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","sed","do","eiusmod","tempor","incididunt","ut","labore","et","dolore","magna","aliqua"],St=["😂","🌈","🤖","💥","🐸","🍕","🦄","🧠","🧬","🚀","🫠","💫","🍩","👾","🎉","🥴","🐙","🧃","🪐","🎈","🧸","👻","🥳","🍭","💖","😺","🌮","🪅","🎮","🥓","🍮"],xt=["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"],At=["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"],Ct=["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"],It=["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 Mt{static#gt=Tt;static#yt=St;static#wt=xt;static#bt=At;static#vt=Ct;static#Et=It;static#Tt(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.#gt]}static set defaultWords(e){this.#Tt(e,"defaultWords"),this.#gt=[...e]}static get defaultEmojis(){return[...this.#yt]}static set defaultEmojis(e){this.#Tt(e,"defaultEmojis"),this.#yt=[...e]}static get defaultNouns(){return[...this.#wt]}static set defaultNouns(e){this.#Tt(e,"defaultNouns"),this.#wt=[...e]}static get defaultVerbs(){return[...this.#bt]}static set defaultVerbs(e){this.#Tt(e,"defaultVerbs"),this.#bt=[...e]}static get defaultAdjectives(){return[...this.#vt]}static set defaultAdjectives(e){this.#Tt(e,"defaultAdjectives"),this.#vt=[...e]}static get defaultTemplates(){return[...this.#Et]}static set defaultTemplates(e){this.#Tt(e,"defaultTemplates"),this.#Et=[...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:p,paragraphs:f,line:m}=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!==p&&!["inline","end","none"].includes(p))throw new RangeError('config.emojiPlacement must be one of: "inline", "end", "none"');if(void 0!==f){if("object"!=typeof f)throw new TypeError("config.paragraphs must be an object or null");const{min:e,max:t}=f;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!==m){if("object"!=typeof m||null===m)throw new TypeError("config.line must be an object");const{minLength:e,maxLength:t,emojiChance:r}=m;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=[...Mt.#yt],this.config.wordSet=[...Mt.#gt],this.config.grammar.templates=[...Mt.#Et],this.config.grammar.nouns=[...Mt.#wt],this.config.grammar.verbs=[...Mt.#bt],this.config.grammar.adjectives=[...Mt.#vt],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 Lt=Mt,kt=class{#St=new Map;#xt=10;#At=!1;#Ct(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.#At=e}getThrowOnMaxListeners(){return this.#At}#It(e,t,{once:r=!1}={}){let n=this.#St.get(e);Array.isArray(n)||(n=[],this.#St.set(e,n)),n.unshift({handler:t,config:{once:r}});const i=this.#xt;if(i>0&&n.length>i){const t=`Possible memory leak detected. ${n.length} "${e}" listeners added. Use setMaxListeners() to increase limit.`;if(this.#At)throw new Error(t);console.warn(t)}}prependListener(e,t){const r=this.#Ct(e,"prependListener");if("function"!=typeof t)throw new TypeError("prependListener(event, handler): handler must be a function");for(const e of r)this.#It(e,t)}prependListenerOnce(e,t){const r=this.#Ct(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.#It(e,r,{once:!0}),n.push(r)}return n}#Mt(e,t,{once:r=!1}={}){const n=this.#Ct(e,"on");for(const e of n){let n=this.#St.get(e);Array.isArray(n)||(n=[],this.#St.set(e,n)),n.push({handler:t,config:{once:r}});const i=this.#xt;if(i>0&&n.length>i){const t=`Possible memory leak detected. ${n.length} "${e}" listeners added. Use setMaxListeners() to increase limit.`;if(this.#At)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.#Mt(e,t)}once(e,t){const r=this.#Ct(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.#Mt(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.#Ct(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.#St.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.#St.delete(e)}}offAll(e){const t=this.#Ct(e,"offAll");for(const e of t)this.#St.delete(e)}offAllTypes(){this.#St.clear()}listenerCount(e){if("string"!=typeof e)throw new TypeError("listenerCount(event): event name must be a string");const t=this.#St.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.#St.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.#St.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.#St.get(e);return Array.isArray(t)?[...t].map(e=>e.handler):[]}eventNames(){return[...this.#St.keys()]}emit(e,...t){const r=this.#Ct(e,"emit"),n=[];for(const e of r){const r=this.#St.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.#xt=e}getMaxListeners(){return this.#xt}};class Nt{static Utils={...e,TinyHtml:gt};#Lt=new kt;setThrowOnMaxListeners(e){return this.#Lt.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#Lt.getThrowOnMaxListeners()}prependListener(e,t){return this.#Lt.prependListener(e,t)}prependListenerOnce(e,t){return this.#Lt.prependListenerOnce(e,t)}appendListener(e,t){return this.#Lt.appendListener(e,t)}appendListenerOnce(e,t){return this.#Lt.appendListenerOnce(e,t)}on(e,t){return this.#Lt.on(e,t)}once(e,t){return this.#Lt.once(e,t)}off(e,t){return this.#Lt.off(e,t)}offAll(e){return this.#Lt.offAll(e)}offAllTypes(){return this.#Lt.offAllTypes()}listenerCount(e){return this.#Lt.listenerCount(e)}listeners(e){return this.#Lt.listeners(e)}onceListeners(e){return this.#Lt.onceListeners(e)}allListeners(e){return this.#Lt.allListeners(e)}eventNames(){return this.#Lt.eventNames()}emit(e,...t){return this.#Lt.emit(e,...t)}setMaxListeners(e){return this.#Lt.setMaxListeners(e)}getMaxListeners(){return this.#Lt.getMaxListeners()}#kt=new WeakMap;#Nt=new WeakMap;#_t=new WeakMap;#Dt=new WeakMap;#jt=new WeakMap;#Rt=new WeakMap;#Ot=null;#Ht=null;#$t=new Set(["IMG","IFRAME","VIDEO"]);#Bt=null;#Pt=!1;#Ft=!1;#Wt=!1;#zt=!1;#qt=!1;#Vt=!1;#Ut=!1;#Kt=!1;#Jt="";#Gt=!1;#we=!1;#Yt=!1;#Xt=!1;#Qt=!1;#Zt=!1;#er=0;#tr=0;#rr=0;#nr=0;#ir=0;#or;#B;#sr=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(!(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.#B=e instanceof Window?document.documentElement:e,this.#Gt=e instanceof Window,this.#Xt=r,this.#Qt=n,this.#Zt=i,this.#er=o,this.#ir=t,this.#Jt=s||"",this.#or=new Set(a||void 0),this.#Bt=()=>{this._scrollDataUpdater(),clearTimeout(l),l=setTimeout(()=>this._onScroll(),this.#er)},(this.#Gt?window:this.#B).addEventListener("scroll",this.#Bt,{passive:!0}),this.#Qt&&(this._observeMutations(),this._observeResizes(this.#B.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.#$t)}addLoadTag(e){if("string"!=typeof e)throw new TypeError("addLoadTag(tag): tag must be a string");this.#$t.add(e.toUpperCase())}removeLoadTag(e){if("string"!=typeof e)throw new TypeError("removeLoadTag(tag): tag must be a string");this.#$t.delete(e.toUpperCase())}hasLoadTag(e){if("string"!=typeof e)throw new TypeError("hasLoadTag(tag): tag must be a string");return this.#$t.has(e.toUpperCase())}resetLoadTags(e=!1){if("boolean"!=typeof e)throw new TypeError("resetLoadTags(addDefault): addDefault must be a boolean");this.#$t.clear(),e&&(this.#$t.add("IMG"),this.#$t.add("IFRAME"),this.#$t.add("VIDEO"))}getAttributeFilters(){return Array.from(this.#or)}addAttributeFilter(e){if("string"!=typeof e)throw new TypeError("addAttributeFilter(attr): attr must be a string");this.#or.add(e)}removeAttributeFilter(e){if("string"!=typeof e)throw new TypeError("removeAttributeFilter(attr): attr must be a string");this.#or.delete(e)}hasAttributeFilter(e){if("string"!=typeof e)throw new TypeError("hasAttributeFilter(attr): attr must be a string");return this.#or.has(e)}resetAttributeFilters(e=!1){if("boolean"!=typeof e)throw new TypeError("resetAttributeFilters(addDefault): addDefault must be a boolean");this.#or.clear(),e&&["class","style","src","data-*","height","width"].forEach(e=>this.#or.add(e))}onSize(e){if(!this.#we){if("function"!=typeof e)throw new TypeError("onSize(handler): handler must be a function");this.#sr.add(e)}}offSize(e){if(!this.#we){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.#B.querySelectorAll(this.#Jt||"*").forEach(t=>{const r=this.#_t.get(t)??!1;this.#Dt.set(t,r);const n=gt.isInContainer(this.#B,t);this.#_t.set(t,n),e.set(t,{oldIsVisible:r,isVisible:n})}),e}_onScroll(){if(this.#we)return;const e=this._scrollDataUpdater(),t=this.#B,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.#ir,h=r+i>=n-1-this.#ir;l&&u?s="all":l?s="top":u&&(s="bottom"),c&&h?a="all":c?a="top":h&&(a="bottom"),this.#Ft=this.#Vt??!1,this.#Pt=this.#qt??!1,this.#Wt=this.#Ut??!1,this.#zt=this.#Kt??!1,this.#Vt=l,this.#qt=u,this.#Ut=c,this.#Kt=h,this.#Yt=!(this.#Xt&&this.#qt),this.#nr=n-r-i,this.emit("onScrollBoundary",{status:s,...o,scrollCache:e}),this.emit("onExtraScrollBoundary",{status:a,...o,scrollCache:e}),this.#Yt?this.emit("onScrollPause",{...o,scrollCache:e}):this.emit("onAutoScroll",{...o,scrollCache:e})}_fixScroll(e=[]){if(this.#we)return;if(!Array.isArray(e))throw new TypeError("_fixScroll: targets must be an array of Elements");const t=this.#B.scrollHeight,r=this.#B.scrollTop,n=this.#B.scrollHeight-this.#B.scrollTop-this.#B.clientHeight,i=this.#B.scrollHeight-t,o=()=>{const t={height:0,width:0};for(const r of e){const e=this.#kt.get(r)||{height:0,width:0},n=this.#Nt.get(r)||{height:0,width:0};this.#sr.forEach(i=>{const o=i(r,{old:e,now:n},{old:this.#rr,now:this.#tr});if(this.#_t.get(r)||this.#jt.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.#jt.set(t,this.#_t.get(t)??!1),this.#Rt.set(t,this.#Dt.get(t)??!1);return t};if(this.#rr>0&>.hasScroll(this.#B).v&&this.#Xt&&this.#Zt&&!this.#qt&&!this.#Vt){const e=o();this.#B.scrollTop=r+i+e.height,e.width>0&&(this.#B.scrollLeft=this.#B.scrollLeft+e.width)}else!this.#Yt&&this.#Xt?(o(),this.scrollToBottom()):this.#Xt||this.#qt||(o(),this.#B.scrollTop=this.#B.scrollHeight-this.#B.clientHeight-n)}_observeMutations(){this.#Ht=new MutationObserver(e=>{this.#we||(this._scrollDataUpdater(),this.#rr=this.#tr,this.#tr=this.#B.childElementCount,e.forEach(e=>{e.addedNodes.forEach(e=>{if(e instanceof Element&&1===e.nodeType&&(this._observeResizes([e]),this._listenLoadEvents(e),this.#Jt)){const t=e.querySelectorAll(this.#Jt);this._observeResizes(t),this._listenLoadEvents(t)}})}),this._fixScroll())}),this.#Ht.observe(this.#B,{childList:!0,subtree:!0,attributes:!0,attributeFilter:this.#or.size>0?Array.from(this.#or):void 0})}_observeResizes(e){this.#Ot||(this.#Ot=new ResizeObserver(e=>{if(this.#we)return;this._scrollDataUpdater();const t=[];for(const r of e){const e=r.target,n=this.#Nt.get(e);n&&this.#kt.set(e,n);const{width:i,height:o}=r.contentRect;this.#Nt.set(e,{width:i,height:o}),t.push(e)}this._fixScroll(t)})),Array.from(e).forEach(e=>{if(!this.#Ot)throw new Error("_observeResizes: ResizeObserver instance is not initialized");this.#Ot.observe(e)})}_listenLoadEvents(e){this.#we||(e instanceof NodeList?Array.from(e):[e]).forEach(e=>{this.#$t.has(e.tagName)&&(e.complete||e.addEventListener("load",()=>{this._scrollDataUpdater(),!this.#Yt&&this.#Xt&&this.scrollToBottom()}))})}get target(){return this.#B}getOldSize(e){return this.#kt.get(e)??null}getNewSize(e){return this.#Nt.get(e)??null}wasVisible(e){return this.#Dt.get(e)??!1}isVisible(e){return this.#_t.get(e)??!1}wasTimedVisible(e){return this.#Rt.get(e)??!1}isTimedVisible(e){return this.#jt.get(e)??!1}setExtraScrollBoundary(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("setExtraScrollBoundary(value): value must be a valid number");this.#ir=e}getExtraScrollBoundary(){return this.#ir}getLastKnownScrollBottomOffset(){return this.#nr}scrollToBottom(){this.#B.scrollTop=this.#B.scrollHeight}scrollToTop(){this.#B.scrollTop=0}isAtCustomBottom(){return this.#Kt}isAtCustomTop(){return this.#Ut}isAtBottom(){return this.#qt}isAtTop(){return this.#Vt}isPastAtBottom(){return this.#Pt}isPastAtTop(){return this.#Ft}isPastAtCustomTop(){return this.#Wt}isPastAtCustomBottom(){return this.#zt}isScrollPaused(){return this.#Yt}isWindow(){return this.#Gt}isDestroyed(){return this.#we}getAutoScrollBottom(){return this.#Xt}getObserveMutations(){return this.#Qt}getPreserveScrollOnLayoutShift(){return this.#Zt}getDebounceTime(){return this.#er}getElemAmount(){return this.#tr}getPrevElemAmount(){return this.#rr}getQuerySelector(){return this.#Jt}destroy(){if(this.#we)return;this.#we=!0,this.#Ht&&(this.#Ht.disconnect(),this.#Ht=null),this.#Ot&&(this.#Ot.disconnect(),this.#Ot=null);const e=this.#Gt?window:this.#B;this.#Bt&&e.removeEventListener("scroll",this.#Bt),this.#kt=new WeakMap,this.#Nt=new WeakMap,this.#_t=new WeakMap,this.#Dt=new WeakMap,this.#jt=new WeakMap,this.#Rt=new WeakMap,this.#Lt.offAllTypes(),this.#sr.clear(),this.#$t.clear()}}const _t=Nt,Dt=class{#G;#ar;#lr;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.#G=e,this.#ar=t,this.#lr=r}getOpenTag(){return this.#ar}getCloseTag(){return this.#lr}setOpenTag(e){if("string"!=typeof e)throw new TypeError("Open tag must be a string.");this.#ar=e}setCloseTag(e){if("string"!=typeof e)throw new TypeError("Close tag must be a string.");this.#lr=e}ensureFocus(){return document.activeElement!==this.#G&&this.#G.focus(),this}focus(){return this.#G.focus(),this}getSelectionRange(){return{start:this.#G.selectionStart??NaN,end:this.#G.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.#G.scrollTop,i=this.#G.scrollLeft;return this.#G.setSelectionRange(e,t),r&&(this.#G.scrollTop=n,this.#G.scrollLeft=i),this}getValue(){return this.#G.value}setValue(e){if("string"!=typeof e)throw new TypeError("Value must be a string.");return this.#G.value=e,this}getSelectedText(){const{start:e,end:t}=this.getSelectionRange();return this.#G.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.#G.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.#G.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.#G.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.#G.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.#G.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.#ar}${e} ${r}${this.#lr}`:`${this.#ar}${e}${this.#lr}`,i=`${this.#ar}/${e}${this.#lr}`;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.#ar}${e} ${n}${this.#lr}`:`${this.#ar}${e}${this.#lr}`,o=`${this.#ar}/${e}${this.#lr}`;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.#ar}${e} ${r}${this.#lr}`:`${this.#ar}${e}${this.#lr}`;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.#ar}${e} ${n}${this.#lr}`:`${this.#ar}${e}${this.#lr}`,o=`${this.#ar}/${e}${this.#lr}`;this.insertText(`${i}${r}${o}`)}return this}},jt=class{#ur=!1;#cr=!1;#hr=null;#dr=null;constructor(){void 0!==navigator.clipboard&&null!==navigator.clipboard&&(this.#cr=!0,this.#hr=e=>navigator.clipboard.writeText(e),this.#dr=e=>navigator.clipboard.write([new ClipboardItem({[e.type]:e})])),this.#ur=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.#hr=e}setCopyBlob(e){if("function"!=typeof e)throw new TypeError("setCopyBlob expected a function that returns Promise<void>.");this.#dr=e}copyText(e){if("string"!=typeof e)throw new TypeError("copyText expected a string.");if(this.#hr)return this.#hr(e);if(this.#ur){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.#dr)return this.#dr(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.#cr||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.#ur}isNavigatorClipboardAvailable(){return this.#cr}getCopyTextFunc(){return this.#hr}getCopyBlobFunc(){return this.#dr}};class Rt{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 Rt._rca(e,"rgb",t)}static rcaHsl(e,t){return Rt._rca(e,"hsl",t)}static rcaHex(e,t){return Rt._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]=Rt.hslToRgba(e,t,r);return Rt.rgbToInt(n,i,o)}static hslToHex(e,t,r){const[n,i,o]=Rt.hslToRgba(e,t,r);return Rt.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 Rt.hslToRgba(e,t,r,n).slice(0,3)}static hexToInt(e){return parseInt(e.replace(/^#/,""),16)}static hexToHsl(e){const[t,r,n,i]=Rt.hexToRgba(e);return Rt.rgbaToHsl(t,r,n,i)}static hexToHsla(e){const[t,r,n,i]=Rt.hexToRgba(e);return Rt.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]=Rt.intToRgba(e);return Rt.rgbaToHsl(t,r,n,i)}static intToHsla(e){const[t,r,n,i]=Rt.intToRgba(e);return Rt.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]}#pr="#000000";#fr=[0,0,0,0];#mr;constructor(e=null,t=!1){this.#mr=t,null!=e&&this.setColor(e)}setColor(e){this.#pr=e;const t=this.#mr&&Array.isArray(e)&&e[0]<=360&&e[1]<=100&&e[2]<=100;this.#fr=Rt.parseInput(e,t)}toHslaArray(){const[e,t,r,n]=this.#fr;return Rt.rgbaToHsla(e,t,r,n)}toHslString(){const[e,t,r]=this.#fr,[n,i,o]=Rt.rgbaToHsl(e,t,r);return`hsl(${n}, ${i}%, ${o}%)`}toHslaString(){const[e,t,r,n]=this.#fr,[i,o,s,a]=Rt.rgbaToHsla(e,t,r,n);return`hsla(${i}, ${o}%, ${s}%, ${a??1})`}toRgbaArray(){return[...this.#fr]}toRgbString(){const[e,t,r]=this.#fr;return`rgb(${e}, ${t}, ${r})`}toRgbaString(){const[e,t,r,n]=this.#fr;return`rgba(${e}, ${t}, ${r}, ${n??1})`}toHex(){const[e,t,r]=this.#fr;return Rt.rgbToHex(e,t,r)}toInt(){const[e,t,r]=this.#fr;return Rt.rgbToInt(e,t,r)}getOriginal(){return this.#pr}}const Ot=Rt;class Ht{#gr=!1;#yr;#wr;#br=null;#vr=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.#wr=e,this.#yr=t,this.setCooldownWatcherTime(e)}isDestroyed(){return this.#gr}getAllowAutoConfigChange(){return this.#yr}getCooldownWatcherTime(){return this.#wr}setAllowAutoConfigChange(e){if("boolean"!=typeof e)throw new TypeError("Expected 'value' to be a boolean.");this.#yr=e}setCooldownWatcherTime(e){if(this.#gr)throw new Error("TinyTimeout has been destroyed.");if(!Number.isFinite(e)||e<=0)throw new TypeError("Expected 'value' to be a positive number.");this.#wr=e,this.#br&&clearInterval(this.#br),this.#br=setInterval(()=>{this.#vr.forEach(e=>{e.now>0&&e.now--})},this.#wr)}set(e,t,r,n=null){if(this.#gr)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.#vr.get(e);(!i||this.#yr&&r!==i.value)&&(i={value:r,now:0},this.#vr.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.#gr)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 Ht.waitForTrue(e,t??this.#wr)}destroy(){this.#gr||(this.#gr=!0,this.#br&&clearInterval(this.#br),this.#br=null,this.#vr.clear())}}const $t=Ht,Bt=new Map,Pt=new Map,Ft=new Set(["string","boolean","object","array",String,Boolean,Number,Object,Array,BigInt,Symbol]);class Wt{#Lt=new kt;setThrowOnMaxListeners(e){return this.#Lt.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#Lt.getThrowOnMaxListeners()}prependListener(e,t){return this.#Lt.prependListener(e,t)}prependListenerOnce(e,t){return this.#Lt.prependListenerOnce(e,t)}appendListener(e,t){return this.#Lt.appendListener(e,t)}appendListenerOnce(e,t){return this.#Lt.appendListenerOnce(e,t)}on(e,t){return this.#Lt.on(e,t)}once(e,t){return this.#Lt.once(e,t)}off(e,t){return this.#Lt.off(e,t)}offAll(e){return this.#Lt.offAll(e)}offAllTypes(){return this.#Lt.offAllTypes()}listenerCount(e){return this.#Lt.listenerCount(e)}listeners(e){return this.#Lt.listeners(e)}onceListeners(e){return this.#Lt.onceListeners(e)}allListeners(e){return this.#Lt.allListeners(e)}eventNames(){return this.#Lt.eventNames()}emit(e,...t){return this.#Lt.emit(e,...t)}setMaxListeners(e){return this.#Lt.setMaxListeners(e)}getMaxListeners(){return this.#Lt.getMaxListeners()}static hasJsonType(e){return Bt.has(e)&&Pt.has(e)||Ft.has(e)}static registerJsonType(e,t,r,n=!1){if(Ft.has(e))throw new Error(`Cannot register type "${e}" because it is frozen.`);Bt.set(e,t),Pt.set(e,r),n&&Ft.add(e)}static deleteJsonType(e){if(Ft.has(e))throw new Error(`Cannot remove type "${e}" because it is frozen.`);let t=!1;return Bt.delete(e)&&(t=!0),Pt.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 Bt.entries())if("string"!=typeof t&&e instanceof t||typeof e===t)return r(e,Wt.encodeSpecialJson);if(Array.isArray(e))return e.map(Wt.encodeSpecialJson);if(f(e)){const t={};for(const r in e)t[r]=Wt.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(Wt.decodeSpecialJson);if(t){for(const[t,r]of Pt.entries())if(r.check&&r.check(e))return r.decode(e,Wt.decodeSpecialJson);const t={};for(const r in e)t[r]=Wt.decodeSpecialJson(e[r]);return t}return e}#Er=window.localStorage;#Tr=null;#ee=0;#Sr=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.#Tr=`LSDB::${e}`),window.addEventListener("storage",this.#Sr)}#xr(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.#Tr)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.#Tr),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.#Tr,String(e)),this.#ee=e)}getDbKey(){return this.#Tr}getVersion(){return this.#ee}setLocalStorage(e){if(!(e instanceof Storage))throw new TypeError("Argument must be a valid instance of Storage.");this.#Er=e}localStorageExists(){return this.#Er instanceof Storage}#Ar(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return Wt.encodeSpecialJson(t)}setJson(e,t){if(this.#xr(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.#Ar(e,t);return this.emit("setJson",e,t),this.#Er.setItem(e,JSON.stringify(r))}#Cr(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const r=this.#Er.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:Wt.decodeSpecialJson(o),fallback:i}}getJson(e,t){const{decoded:r,fallback:n}=this.#Cr(e,t);return r instanceof Map||r instanceof Set||Array.isArray(r)||f(r)?r:n}setDate(e,t){if(this.#xr(e),!(t instanceof Date))throw new TypeError("Value must be a Date.");const r=this.#Ar(e,t);return this.emit("setDate",e,t),this.#Er.setItem(e,JSON.stringify(r))}getDate(e){const t=this.#Cr(e).decoded;return t instanceof Date?t:null}setRegExp(e,t){if(this.#xr(e),!(t instanceof RegExp))throw new TypeError("Value must be a RegExp.");const r=this.#Ar(e,t);return this.emit("setRegExp",e,t),this.#Er.setItem(e,JSON.stringify(r))}getRegExp(e){const t=this.#Cr(e).decoded;return t instanceof RegExp?t:null}setBigInt(e,t){if(this.#xr(e),"bigint"!=typeof t)throw new TypeError("Value must be a BigInt.");const r=this.#Ar(e,t);return this.emit("setBigInt",e,t),this.#Er.setItem(e,JSON.stringify(r))}getBigInt(e){const t=this.#Cr(e).decoded;return"bigint"==typeof t?t:null}setSymbol(e,t){if(this.#xr(e),"symbol"!=typeof t)throw new TypeError("Value must be a Symbol.");const r=this.#Ar(e,t);return this.emit("setSymbol",e,t),this.#Er.setItem(e,JSON.stringify(r))}getSymbol(e){const t=this.#Cr(e).decoded;return"symbol"==typeof t?t:null}getValue(e){return this.#Cr(e).decoded??null}setItem(e,t){if(this.#xr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("setItem",e,t),this.#Er.setItem(e,t)}getItem(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.#Er.getItem(e)}setString(e,t){if(this.#xr(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.#Er.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.#Er.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.#xr(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.#Er.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.#Er.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.#xr(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.#Er.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.#Er.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.#Er.removeItem(e)}clearLocalStorage(){return this.#Er.clear()}destroy(){window.removeEventListener("storage",this.#Sr),this.#Lt.offAllTypes()}}Wt.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),Wt.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),Wt.registerJsonType(Date,e=>({__date__:!0,value:e.toISOString()}),{check:e=>e.__date__,decode:e=>new Date(e.value)},!0),Wt.registerJsonType(RegExp,e=>({__regexp__:!0,source:e.source,flags:e.flags}),{check:e=>e.__regexp__,decode:e=>new RegExp(e.source,e.flags)},!0),Wt.registerJsonType("number",e=>({__number__:!0,value:e.toString()}),{check:e=>e.__number__,decode:e=>Number(e.value)},!0),Wt.registerJsonType("bigint",e=>({__bigint__:!0,value:e.toString()}),{check:e=>e.__bigint__,decode:e=>BigInt(e.value)},!0),Wt.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 zt=Wt,qt=new WeakMap,Vt=class{#Lt=new kt;setThrowOnMaxListeners(e){return this.#Lt.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#Lt.getThrowOnMaxListeners()}prependListener(e,t){return this.#Lt.prependListener(e,t)}prependListenerOnce(e,t){return this.#Lt.prependListenerOnce(e,t)}appendListener(e,t){return this.#Lt.appendListener(e,t)}appendListenerOnce(e,t){return this.#Lt.appendListenerOnce(e,t)}on(e,t){return this.#Lt.on(e,t)}once(e,t){return this.#Lt.once(e,t)}off(e,t){return this.#Lt.off(e,t)}offAll(e){return this.#Lt.offAll(e)}offAllTypes(){return this.#Lt.offAllTypes()}listenerCount(e){return this.#Lt.listenerCount(e)}listeners(e){return this.#Lt.listeners(e)}onceListeners(e){return this.#Lt.onceListeners(e)}allListeners(e){return this.#Lt.allListeners(e)}eventNames(){return this.#Lt.eventNames()}setMaxListeners(e){return this.#Lt.setMaxListeners(e)}getMaxListeners(){return this.#Lt.getMaxListeners()}#Ir;#Mr;#Lr;#gr=!1;#kr=!1;#Nr=[];#_r="__tinyIframeEvent__";get secretEventName(){return this.#_r}set secretEventName(e){if("string"!=typeof e)throw new TypeError("TinyIframeEvents: secretEventName must be a string.");this.#_r=e}constructor({targetIframe:e,targetOrigin:t}={}){if(!(void 0===e||e instanceof HTMLIFrameElement&&e.contentWindow))throw new TypeError('[TinyIframeEvents] Invalid "targetIframe" provided: expected a HTML Iframe Element, received '+typeof e);if(void 0!==t&&"string"!=typeof t)throw new TypeError('[TinyIframeEvents] Invalid "targetOrigin" provided: expected a string, received '+typeof t);if(this.#Ir=e?.contentWindow??window.parent,this.#Mr=t??window.location.origin,this.#Lr=e?"parent":"iframe",qt.has(this.#Ir))throw new Error("Duplicate window reference.");this._boundOnMessage=this.#Dr.bind(this),this._boundOnceMessage=this.#jr.bind(this),"complete"===this.#Ir.document.readyState||"interactive"===this.#Ir.document.readyState?this.#jr():(this.#Ir.addEventListener("load",this._boundOnceMessage,!1),this.#Ir.addEventListener("DOMContentLoaded",this._boundOnceMessage,!1)),window.addEventListener("message",this._boundOnMessage,!1),qt.set(this.#Ir,this)}#jr(){this.#kr||(this.#kr=!0,this.#Rr())}#Dr(e){const{data:t,source:r}=e;if(!f(t)||!t[this.#_r])return;const{eventName:n,payload:i,direction:o}=t;r===this.#Ir&&("iframe"===this.#Lr&&"iframe"!==o||"parent"===this.#Lr&&"parent"!==o||this.#Lt.emit(n,i,e))}emit(e,t){if("string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.#gr)throw new Error("Cannot emit: instance has been destroyed.");const r={[this.#_r]:!0,eventName:e,payload:t,direction:"parent"===this.#Lr?"iframe":"parent"};this.#kr?this.#Ir.postMessage(r,this.#Mr):this.#Nr.push(r)}#Rr(){for(;this.#Nr.length;){const e=this.#Nr.shift();e&&this.#Ir.postMessage(e,this.#Mr)}}isDestroyed(){return this.#gr}destroy(){this.#gr=!0,window.removeEventListener("message",this._boundOnMessage),this.#Ir.removeEventListener("load",this._boundOnceMessage,!1),this.#Ir.removeEventListener("DOMContentLoaded",this._boundOnceMessage,!1),this.#Lt.offAllTypes(),this.#Nr=[],qt.delete(this.#Ir)}},Ut=new WeakMap,Kt=class{#Lt=new kt;setThrowOnMaxListeners(e){return this.#Lt.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#Lt.getThrowOnMaxListeners()}prependListener(e,t){return this.#Lt.prependListener(e,t)}prependListenerOnce(e,t){return this.#Lt.prependListenerOnce(e,t)}appendListener(e,t){return this.#Lt.appendListener(e,t)}appendListenerOnce(e,t){return this.#Lt.appendListenerOnce(e,t)}on(e,t){return this.#Lt.on(e,t)}once(e,t){return this.#Lt.once(e,t)}off(e,t){return this.#Lt.off(e,t)}offAll(e){return this.#Lt.offAll(e)}offAllTypes(){return this.#Lt.offAllTypes()}listenerCount(e){return this.#Lt.listenerCount(e)}listeners(e){return this.#Lt.listeners(e)}onceListeners(e){return this.#Lt.onceListeners(e)}allListeners(e){return this.#Lt.allListeners(e)}eventNames(){return this.#Lt.eventNames()}setMaxListeners(e){return this.#Lt.setMaxListeners(e)}getMaxListeners(){return this.#Lt.getMaxListeners()}#Or;#Mr;#Nr=[];#kr=!1;#Hr=!1;#$r=null;#Br="__TNE_READY__";#Pr="__TNE_ROUTE__";get readyEventName(){return this.#Br}set readyEventName(e){if("string"!=typeof e)throw new TypeError("TinyNewWinEvents: readyEventName must be a string.");this.#Br=e}get routeEventName(){return this.#Pr}set routeEventName(e){if("string"!=typeof e)throw new TypeError("TinyNewWinEvents: routeEventName must be a string.");this.#Pr=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.#Or=window.opener:(this.#Or="string"==typeof t?window.open(t,r,n):t,this.#Hr=!0),!this.#Or||Ut.has(this.#Or))throw new Error("Invalid or duplicate window reference.");this.#Mr=e??window.location.origin,this._handleMessage=this.#Fr.bind(this),window.addEventListener("message",this._handleMessage,!1),this.#Hr||(this.#Wr(this.#Br,null),this.#zr())}getWin(){return this.#Or}#Fr(e){if(!e.source||this.#Or&&e.source!==this.#Or)return;const{type:t,route:r,payload:n}=e.data||{};if(t===this.#Br)return this.#kr=!0,this.#Rr(),this.#zr(),void(this.#Hr&&this.#Wr(this.#Br,null));t===this.#Pr&&this.#Lt.emit(r,n,e)}#Rr(){for(;this.#Nr.length;){const e=this.#Nr.shift();if(e){const{route:t,payload:r}=e;this.emit(t,r)}}}#Wr(e,t,r=""){this.#Or&&this.#Or.closed||this.#Or?.postMessage({type:e,route:r,payload:t},this.#Mr)}close(){if(!this.#Hr)throw new Error("Only host can close the window.");this.#Or&&!this.#Or.closed&&this.#Or.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.#kr?this.#Wr(this.#Pr,t,e):this.#Nr.push({route:e,payload:t})}isConnected(){return!(!this.#kr||!this.#Or||this.#Or.closed)}#zr(){this.#Or&&!this.#$r&&(this.#$r=setInterval(()=>{this.#Or?.closed&&(this.#Lt.emit("WINDOW_REF_CLOSED"),this.destroy())},500),Ut.set(this.#Or,this.#$r))}onClose(e){return this.#Lt.on("WINDOW_REF_CLOSED",e)}offClose(e){return this.#Lt.off("WINDOW_REF_CLOSED",e)}isDestroyed(){return!this.#Or}destroy(){this.#Or&&(this.#$r&&(clearInterval(this.#$r),this.#$r=null,Ut.delete(this.#Or)),window.removeEventListener("message",this._handleMessage),this.#Nr=[],this.#kr=!1,this.#Or=null,this.#Lt.offAllTypes())}},Jt=class{#qr;#Vr;#Ur;#Kr=0;#Jr=0;#Gr;#Yr=null;#Xr=null;get lineHeight(){return this.#qr}get maxRows(){return this.#Vr-1}get extraHeight(){return this.#Ur}get currentHeight(){return this.#Kr}get currentRows(){return this.#Jr}get textarea(){return this.#Gr}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.#Gr=e,this.#Vr=(t.maxRows??5)+1,this.#Ur=t.extraHeight??0,this.#Yr=t.onResize??null,this.#Xr=t.onInput??null,this.#qr=this.#Qr(),e.style.overflowY="hidden",e.style.resize="none",this._handleInput=()=>this.#Zr(),e.addEventListener("input",this._handleInput),this.#Zr()}#Zr(){this.#Gr.style.height="auto";const e=window.getComputedStyle(this.#Gr),t=parseFloat(e.paddingTop)||0,r=parseFloat(e.paddingBottom)||0,n=(this.#Gr.value.match(/\n/g)||[]).length,i=this.#Gr.scrollHeight,o=this.#qr*this.#Vr,s=Math.ceil(Math.min(i,o)-t-r+this.#Ur),a=this.#Vr-1,l=n<a?n+1:a;this.#Gr.style.height=`${s}px`,this.#Gr.style.overflowY=i>o?"auto":"hidden",this.#Kr=s;const u={breakLines:n,rows:l,height:s,scrollHeight:i,maxHeight:o,lineHeight:this.#qr,maxRows:a};l!==this.#Jr&&(this.#Jr=l,"function"==typeof this.#Yr&&this.#Yr({...u})),"function"==typeof this.#Xr&&this.#Xr(u)}#Qr(){const e=window.getComputedStyle(this.#Gr),t=parseFloat(e.lineHeight);return Number.isNaN(t)?1.2*parseFloat(e.fontSize):t}getData(){return{rows:this.#Jr,height:this.#Kr}}refresh(){this.#Zr()}destroy(){this.#Gr.removeEventListener("input",this._handleInput)}};class Gt{#gr=!1;#en=new Set;#tn=new Map;#rn=new Map;#nn=null;#in=[];#on={};#sn=[];#an=null;#ln=null;#un;#cn;#hn;#dn;#pn;#fn;#mn;#gn;#yn=[];#wn=0;#bn=0;#vn=[];#En=0;#Tn=null;#Sn=new Set;#xn=new Set;#An=new Map;#Cn=new Map;#In=new Map;static#Mn={" ":"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);Gt.#Mn[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 Gt.#Mn[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 Gt.#Mn[e]}static getAllSpecialKeys(){return{...Gt.#Mn}}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=Gt.#Mn[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.#dn=e,this.#un=t,this.#cn=new Set(r),this.#hn=n,this.#pn=s,this.#fn=a,this.#mn=o,this.#gn=i,["gamepad-only","both"].includes(this.#un)&&this.#Ln(),["keyboard-only","both"].includes(this.#un)&&this.#kn()}#Nn=e=>this.#_n(e.gamepad);#Dn=e=>this.#jn(e.gamepad);#Ln(){window.addEventListener("gamepadconnected",this.#Nn),window.addEventListener("gamepaddisconnected",this.#Dn)}#_n(e){this.#gr||this.#cn.has(e.id)||this.#dn&&e.id!==this.#dn||this.#nn||(this.#nn=e,this.#dn=e.id,this.#Rn(),this.#On("connected",{id:e.id,gp:e,timestamp:e.timestamp}))}#jn(e){this.#gr||this.#nn&&e.id===this.#nn.id&&(this.#nn=null,this.#an&&(cancelAnimationFrame(this.#an),this.#an=null),this.#On("disconnected",{id:e.id,gp:e,timestamp:e.timestamp}))}#Rn(){const e=()=>{this.#gr||(this.#Hn(),this.#an=requestAnimationFrame(e))};e()}#Hn(){if(this.#gr)return;const e=navigator.getGamepads(),t=Array.from(e).find(e=>e&&e.id===this.#dn);t&&(this.#nn=t,t.buttons.forEach((e,r)=>{const n=`Button${r}`,i=this.#in[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.#$n({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.#in[r]={pressed:e.pressed,value:"number"==typeof s?s:this.#in[r]?.value,value2:NaN}}),t.axes.forEach((e,r)=>{Math.abs(e)<this.#hn&&(e=0);const n=`Axis${r}`;e!==(this.#sn[r]??0)&&this.#$n({key:n,source:"gamepad-analog",value:e,value2:NaN,type:"change",timestamp:t.timestamp,id:t.id,gp:t}),this.#sn[r]=e}))}#Bn=e=>{if(!this.#gr){if(!(e instanceof KeyboardEvent))throw new Error("Expected KeyboardEvent in keydown listener.");this.#en.has(e.code)||(this.#en.add(e.code),this.#$n({event:e,key:e.code,source:"keyboard",value:1,value2:NaN,type:"down",pressed:!0,prevPressed:this.#on[e.code]?.pressed??!1,id:"native_keyboard",timestamp:e.timeStamp}),this.#on[e.code]={pressed:!0})}};#Pn=e=>{if(!this.#gr){if(!(e instanceof KeyboardEvent))throw new Error("Expected KeyboardEvent in keyup listener.");this.#en.has(e.code)&&(this.#en.delete(e.code),this.#$n({event:e,key:e.code,source:"keyboard",value:0,value2:NaN,type:"up",pressed:!1,prevPressed:this.#on[e.code]?.pressed??!1,id:"native_keyboard",timestamp:e.timeStamp}),this.#on[e.code]={pressed:!1})}};#Fn=e=>{if(this.#gr)return;if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mousedown listener.");const t=`Mouse${e.button}`;this.#en.add(t),this.#$n({event:e,key:t,source:"mouse",value:1,value2:NaN,type:"down",pressed:!0,prevPressed:this.#on[t]?.pressed??!1,id:"native_mouse",timestamp:e.timeStamp}),this.#on[t]={pressed:!0}};#Wn=e=>{if(this.#gr)return;if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mouseup listener.");const t=`Mouse${e.button}`;this.#en.delete(t),this.#$n({event:e,key:t,source:"mouse",value:0,value2:NaN,type:"up",pressed:!1,prevPressed:this.#on[t]?.pressed??!1,id:"native_mouse",timestamp:e.timeStamp}),this.#on[t]={pressed:!1}};#zn=e=>{if(!this.#gr){if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mousemove listener.");if(0!==e.movementX||0!==e.movementY){const t="MouseMove",r=this.#on[t]??{pressed:!1,value:0,value2:0};this.#$n({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.#on[t]={pressed:!1,value:e.movementX,value2:e.movementY}}}};#kn(){this.#fn.addEventListener("keydown",this.#Bn),this.#fn.addEventListener("keyup",this.#Pn),this.#pn&&(this.#fn.addEventListener("mousedown",this.#Fn),this.#fn.addEventListener("mouseup",this.#Wn),this.#fn.addEventListener("mousemove",this.#zn));const e=()=>{this.#gr||(this.#en.forEach(e=>{const t=e.startsWith("Mouse")?"mouse":"keyboard";this.#$n({key:e,source:t,id:`native_${t}`,value:1,value2:NaN,type:"hold",pressed:!0,prevPressed:this.#on[e]?.pressed??!1,timestamp:NaN})}),this.#ln=requestAnimationFrame(e))};e()}#$n(e){if(this.#gr)return;const t=this.#rn.get("input-*")||[],{pressed:r,key:n}=e,i=n.startsWith("Axis"),o="boolean"==typeof r&&r||i&&(e.value>this.#gn||e.value<-Math.abs(this.#gn)),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.#Sn.has(n)||i&&!this.#Sn.has(n)&&!this.#Sn.has(`${n}+`)&&!this.#Sn.has(`${n}-`)){0===this.#En&&(this.#En=Date.now()),this.#Sn.add(s),a=!0,this.#vn.push(s),this.#yn.length<1&&(this.#Tn&&clearTimeout(this.#Tn),this.#Tn=setTimeout(()=>this.resetComboMapped(),this.#mn));const e=this.#rn.get("mapped-key-start")??[];for(const t of e)t({key:s,activeTime:this.#En})}}else if(!i&&this.#Sn.has(n)||i&&(this.#Sn.has(n)||this.#Sn.has(`${n}+`)||this.#Sn.has(`${n}-`))){this.#Sn.delete(n),this.#Sn.delete(`${n}+`),this.#Sn.delete(`${n}-`),a=!1;const e=this.#rn.get("mapped-key-end")??[];for(const t of e)t({key:s,activeTime:this.#En})}for(const{sequence:e,callback:t,triggered:r}of this.#Cn.values()){const n=this.#Cn.get(e.join("+"));if(!n)continue;const i=e.every((e,t)=>this.#vn[t]===e);i&&!r?(n.triggered=!0,t(this.#En)):!i&&r&&(n.triggered=!1)}}for(const[r,l]of this.#tn.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.#xn.has(r)){0===this.#bn&&(this.#bn=Date.now()),this.#xn.add(r),0===this.#wn&&(this.#wn=Date.now()),this.#Tn&&clearTimeout(this.#Tn),this.#yn.push(r),this.#Tn=setTimeout(()=>this.resetComboMapped(),this.#mn);const e=this.#rn.get("mapped-input-start")??[];for(const t of e)t({logicalName:r,activeTime:this.#bn,comboTime:this.#wn})}}else if(!a||this.#xn.has(r)){this.#xn.delete(r),this.#xn.size<1&&(this.#bn=0);const e=this.#rn.get("mapped-input-end")??[];for(const t of e)t({logicalName:r,activeTime:this.#bn,comboTime:this.#wn})}for(const{sequence:e,callback:t,triggered:r}of this.#An.values()){const n=this.#An.get(e.join("+"));if(!n)continue;const i=Array.from(this.#xn),o=e.every((e,t)=>i[t]===e);o&&!r?(n.triggered=!0,t(this.#bn)):!o&&r&&(n.triggered=!1)}}const p=[];if(i&&0===e.value){const{value:t}=this.#In.get(`${n}-`)??{value:0,value2:NaN},{value:r}=this.#In.get(`${n}+`)??{value:0,value2:NaN};e.value!==t&&p.push(`${n}-`),e.value!==r&&p.push(`${n}+`)}else p.push(s);p.forEach(n=>{if(!("*"===l||l===n||Array.isArray(l)&&l.includes(n)))return;const i=this.#rn.get(`input-${e.type}-${r}`)||[],o=this.#rn.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.#In.set(n,{value:e.value,value2:e.value2})})}}#On(e,t){const r=this.#rn.get(e)||[];for(const e of r)e(t)}#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);let i=this.#rn.get(n);Array.isArray(i)||(i=[],this.#rn.set(n,i)),i.push(t)}#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=i=>{this.#Un(e,n,r),t(i)};this.#qn(e,n,r)}#Kn(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.#rn.get(n)??[];i.unshift(t),this.#rn.set(n,i)}#Un(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.#rn.get(n);Array.isArray(i)&&this.#rn.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.#tn.set(e,t)}unmapInput(e){if("string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);this.#tn.delete(e)}hasMappedInput(e){if("string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);return this.#tn.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.#tn.get(e);if(!t)throw new Error(`No physical input mapped for logicalName: "${e}"`);return t}clearMapInputs(){this.#tn.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.#An.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.#An.delete(t)}unregisterAllInputSequences(){this.#An.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.#An.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.#Cn.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.#Cn.delete(t)}unregisterAllKeySequences(){this.#Cn.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.#Cn.has(t)}renewComboMapped(){this.#Tn&&(clearTimeout(this.#Tn),this.#Tn=setTimeout(()=>this.resetComboMapped(),this.#mn))}resetComboMapped(){this.#Tn&&clearTimeout(this.#Tn),this.#vn=[],this.#Tn=null,this.#En=0,this.#yn=[],this.#wn=0}onMappedKeyStart(e){return this.#qn("",e,"mapped-key-start")}onceMappedKeyStart(e){return this.#Vn("",e,"mapped-key-start")}prependMappedKeyStart(e){return this.#Kn("",e,"mapped-key-start")}offMappedKeyStart(e){return this.#Un("",e,"mapped-key-start")}offAllMappedKeyStart(){this.#rn.delete("mapped-key-start")}onMappedKeyEnd(e){return this.#qn("",e,"mapped-key-end")}onceMappedKeyEnd(e){return this.#Vn("",e,"mapped-key-end")}prependMappedKeyEnd(e){return this.#Kn("",e,"mapped-key-end")}offMappedKeyEnd(e){return this.#Un("",e,"mapped-key-end")}offAllMappedKeyEnd(){this.#rn.delete("mapped-key-end")}onMappedInputStart(e){return this.#qn("",e,"mapped-input-start")}onceMappedInputStart(e){return this.#Vn("",e,"mapped-input-start")}prependMappedInputStart(e){return this.#Kn("",e,"mapped-input-start")}offMappedInputStart(e){return this.#Un("",e,"mapped-input-start")}offAllMappedInputStart(){this.#rn.delete("mapped-input-start")}onMappedInputEnd(e){return this.#qn("",e,"mapped-input-end")}onceMappedInputEnd(e){return this.#Vn("",e,"mapped-input-end")}prependMappedInputEnd(e){return this.#Kn("",e,"mapped-input-end")}offMappedInputEnd(e){return this.#Un("",e,"mapped-input-end")}offAllMappedInputEnd(){this.#rn.delete("mapped-input-end")}onInput(e,t){return this.#qn(e,t,"input-{logicalName}")}onceInput(e,t){return this.#Vn(e,t,"input-{logicalName}")}prependInput(e,t){return this.#Kn(e,t,"input-{logicalName}")}offInput(e,t){return this.#Un(e,t,"input-{logicalName}")}onInputStart(e,t){return this.#qn(e,t,"input-down-{logicalName}")}onceInputStart(e,t){return this.#Vn(e,t,"input-down-{logicalName}")}prependInputStart(e,t){return this.#Kn(e,t,"input-down-{logicalName}")}offInputStart(e,t){return this.#Un(e,t,"input-down-{logicalName}")}onInputEnd(e,t){return this.#qn(e,t,"input-up-{logicalName}")}onceInputEnd(e,t){return this.#Vn(e,t,"input-up-{logicalName}")}prependInputEnd(e,t){return this.#Kn(e,t,"input-up-{logicalName}")}offInputEnd(e,t){return this.#Un(e,t,"input-up-{logicalName}")}onInputHold(e,t){return this.#qn(e,t,"input-hold-{logicalName}")}onceInputHold(e,t){return this.#Vn(e,t,"input-hold-{logicalName}")}prependInputHold(e,t){return this.#Kn(e,t,"input-hold-{logicalName}")}offInputHold(e,t){return this.#Un(e,t,"input-hold-{logicalName}")}onInputChange(e,t){return this.#qn(e,t,"input-change-{logicalName}")}onceInputChange(e,t){return this.#Vn(e,t,"input-change-{logicalName}")}prependInputChange(e,t){return this.#Kn(e,t,"input-change-{logicalName}")}offInputChange(e,t){return this.#Un(e,t,"input-change-{logicalName}")}onInputMove(e,t){return this.#qn(e,t,"input-move-{logicalName}")}onceInputMove(e,t){return this.#Vn(e,t,"input-move-{logicalName}")}prependInputMove(e,t){return this.#Kn(e,t,"input-move-{logicalName}")}offInputMove(e,t){return this.#Un(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.#rn.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.#rn.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.#rn.get(`${n}${e}`);return Array.isArray(i)?i.length:0}#Jn={type:"dual-rumble",params:{startDelay:0,duration:200,weakMagnitude:.5,strongMagnitude:1}};get defaultHapticEffect(){return{type:this.#Jn.type,params:{...this.#Jn.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.#Jn.type=e,this.#Jn.params=t}hasHapticEffect(){const e=this.#nn;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.#nn;if(!r)return new Promise(e=>e("complete"));const n=r.vibrationActuator;return n instanceof GamepadHapticActuator?n.playEffect(t??this.#Jn.type,{...this.#Jn.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.#cn.add(e)}unignoreId(e){if("string"!=typeof e||""===e.trim())throw new TypeError(`"id" must be a non-empty string, received ${e}`);this.#cn.delete(e)}onConnected(e){return this.#qn("",e,"connected")}onceConnected(e){return this.#Vn("",e,"connected")}prependConnected(e){return this.#Kn("",e,"connected")}offConnected(e){return this.#Un("",e,"connected")}offAllConnected(){this.#rn.delete("connected")}onDisconnected(e){return this.#qn("",e,"disconnected")}onceDisconnected(e){return this.#Vn("",e,"disconnected")}prependDisconnected(e){return this.#Kn("",e,"disconnected")}offDisconnected(e){return this.#Un("",e,"disconnected")}offAllDisconnected(){this.#rn.delete("disconnected")}hasGamepad(){return this.#nn instanceof Gamepad}getGamepad(){if(!this.#nn)throw new Error("No gamepad is currently connected.");return this.#nn}hasLastButtonState(e){return!!this.#in[e]}getLastButtonState(e){if(!this.#in[e])throw new Error(`No last button state found for index ${e}`);return{...this.#in[e]}}exportConfig(){return{expectedId:this.#dn,ignoreIds:Array.from(this.#cn),deadZone:this.#hn,timeoutComboKeys:this.#mn,axisActiveSensitivity:this.#gn,inputMap:Array.from(this.#tn.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.#dn=t.expectedId),Array.isArray(t.ignoreIds)&&(this.#cn=new Set(t.ignoreIds)),"number"==typeof t.deadZone&&(this.#hn=t.deadZone),"number"==typeof t.timeoutComboKeys&&(this.#mn=t.timeoutComboKeys),"number"==typeof t.axisActiveSensitivity&&(this.#gn=t.axisActiveSensitivity),Array.isArray(t.inputMap)&&(this.#tn=new Map(t.inputMap))}get mappedKeyStartCalls(){const e=this.#rn.get("mapped-key-start");return Array.isArray(e)?[...e]:[]}get mappedKeyEndCalls(){const e=this.#rn.get("mapped-key-end");return Array.isArray(e)?[...e]:[]}get comboMappedKeys(){return[...this.#vn]}get comboMappedInputs(){return[...this.#yn]}get keySequenceSize(){return this.#Cn.size}get keySequences(){const e=[];for(const[,t]of this.#Cn.entries())e.push(t.callback);return e}get activeMappedKeys(){return[...this.#Sn]}get mappedInputStartCalls(){const e=this.#rn.get("mapped-input-start");return Array.isArray(e)?[...e]:[]}get mappedInputEndCalls(){const e=this.#rn.get("mapped-input-end");return Array.isArray(e)?[...e]:[]}get inputSequenceSize(){return this.#An.size}get inputSequences(){const e=[];for(const[,t]of this.#An.entries())e.push(t.callback);return e}get activeMappedInputs(){return[...this.#xn]}get mappedInputs(){const e={};for(const[t,r]of this.#tn.entries())e[t]=r;return e}get mappedInputSize(){return this.#tn.size}get connectedCalls(){const e=this.#rn.get("connected");return Array.isArray(e)?[...e]:[]}get disconnectedCalls(){const e=this.#rn.get("disconnected");return Array.isArray(e)?[...e]:[]}get ignoredDeviceIds(){return[...this.#cn]}get heldKeys(){return[...this.#en]}get eventsSize(){let e=0;return this.#rn.forEach(t=>{e+=t.length}),e}get callSize(){return this.#rn.size}get connectedCallSize(){const e=this.#rn.get("connected");return Array.isArray(e)?e.length:0}get disconnectedCallSize(){const e=this.#rn.get("disconnected");return Array.isArray(e)?e.length:0}get mappedKeyStartCallSize(){const e=this.#rn.get("mapped-key-start");return Array.isArray(e)?e.length:0}get mappedKeyEndCallSize(){const e=this.#rn.get("mapped-key-end");return Array.isArray(e)?e.length:0}get mappedInputStartCallSize(){const e=this.#rn.get("mapped-input-start");return Array.isArray(e)?e.length:0}get mappedInputEndCallSize(){const e=this.#rn.get("mapped-input-end");return Array.isArray(e)?e.length:0}get lastButtonStates(){const e=[];return this.#in.forEach(t=>{e.push({...t})}),e}get lastAxes(){return[...this.#sn]}get inputMode(){return this.#un}get elementBase(){return this.#fn}get timeComboInputs(){return this.#wn}get timeComboKeys(){return this.#En}get timeMappedInputs(){return this.#bn}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.#gn}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.#gn=e}get deadZone(){return this.#hn}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.#hn=e}get expectedId(){return this.#dn}set expectedId(e){if("string"!=typeof e)throw new TypeError("Expected device id be a string.");this.#dn=e}get isDestroyed(){return this.#gr}destroy(){this.#gr||(this.#gr=!0,this.#an&&cancelAnimationFrame(this.#an),this.#ln&&cancelAnimationFrame(this.#ln),this.#an=null,this.#ln=null,["keyboard-only","both"].includes(this.#un)&&(this.#fn.removeEventListener("keydown",this.#Bn),this.#fn.removeEventListener("keyup",this.#Pn),this.#pn&&(this.#fn.removeEventListener("mousedown",this.#Fn),this.#fn.removeEventListener("mouseup",this.#Wn),this.#fn.removeEventListener("mousemove",this.#zn))),["gamepad-only","both"].includes(this.#un)&&(window.removeEventListener("gamepadconnected",this.#Nn),window.removeEventListener("gamepaddisconnected",this.#Dn)),this.resetComboMapped(),this.#tn.clear(),this.#rn.clear(),this.#en.clear(),this.#xn.clear(),this.#Sn.clear(),this.#An.clear(),this.#Cn.clear(),this.#cn.clear(),this.#In.clear(),this.#in=[],this.#sn=[],this.#on={},this.#nn=null,this.#dn=null,this.#pn=!1,this.#bn=0)}}const Yt=Gt,Xt=class{#Gn=!0;#Yn=86400;#Xn=3600;#Qn=60;#Zn=new Map;#ei=[];#ti;#ri;#ni={main:null};#ii=0;#oi=0;#si=0;#ai="";#li=1;#ui=1;#ci=1;#gr=!1;#hi=[31,31,31,31,31,31,31,31,31,31,31,31];#di={default:{},day:{},night:{},hours:{},seasons:{}};#pi={min:60,max:180};#fi=0;get daySize(){return this.#Yn}get autoSizeAdjuste(){return this.#Gn}set autoSizeAdjuste(e){if("boolean"!=typeof e)throw new TypeError("autoSizeAdjuste must be a boolean.");this.#Gn=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.#Xn/this.#Yn,r=this.#Qn/this.#Yn;this.#Yn=e,this.#Gn&&(this.#Xn=e*t,this.#Qn=e*r)}get hourSize(){return this.#Xn}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.#Yn/this.#Xn,r=this.#Qn/this.#Xn;this.#Xn=e,this.#Gn&&(this.#Yn=e*t,this.#Qn=e*r)}get minuteSize(){return this.#Qn}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.#Xn/this.#Qn,r=this.#Yn/this.#Qn;this.#Qn=e,this.#Gn&&(this.#Xn=e*t,this.#Yn=e*r)}get isDestroyed(){return this.#gr}get currentSeconds(){return this.#ii}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.#Yn)throw new RangeError(`currentSeconds must be between 0 and 86399, received ${e}`);this.#ii=Math.floor(e),this.#oi=Math.floor(e/this.#Qn),this.#si=Math.floor(e/this.#Xn)}get currentMinutes(){return this.#oi}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.#oi=Math.floor(e),this.#si=Math.floor(e/this.#Qn),this.#ii=Math.floor(e*this.#Qn)}get currentHours(){return this.#si}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.#si=Math.floor(e),this.#oi=Math.floor(e*this.#Qn),this.#ii=Math.floor(e*this.#Xn)}get moons(){return this.#ei.map(e=>this.getMoon(e))}get seasons(){return Array.from(this.#Zn.keys())}get dayStart(){return this.#ti}get nightStart(){return this.#ri}get weather(){return{...this.#ni}}get currentSeason(){return this.#ai}get currentDay(){return this.#li}get currentMonth(){return this.#ui}get currentYear(){return this.#ci}get monthDays(){return[...this.#hi]}get weatherDuration(){return{...this.#pi}}get weatherTimeLeft(){return this.#fi}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.#ti=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.#ri=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.#ni=e}set currentSeason(e){if(this._checkDestroyed(),"string"!=typeof e||!this.#Zn.has(e))throw new TypeError(`currentSeason must be one of ${Array.from(this.#Zn).map(e=>e[0]).join(", ")}, received ${e}`);this.#ai=e}set currentDay(e){if(this._checkDestroyed(),"number"!=typeof e||e<1||e>this.#hi[this.#ui-1])throw new TypeError("currentDay must be a valid day number, received "+typeof e);this.#li=e}set currentMonth(e){if(this._checkDestroyed(),"number"!=typeof e||"number"!=typeof this.#hi[e-1])throw new TypeError("currentMonth must be a valid month number, received "+typeof e);this.#ui=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.#ci=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.#hi=[...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.#pi={...e}}set weatherTimeLeft(e){if(this._checkDestroyed(),"number"!=typeof e)throw new TypeError("weatherTimeLeft must be a number, received "+typeof e);this.#fi=e}get weatherConfig(){const e={},t={};for(const t in this.#di.hours)e[t]={...this.#di.hours[t]};for(const e in this.#di.seasons)t[e]={...this.#di.seasons[e]};return{default:{...this.#di.default},day:{...this.#di.day},night:{...this.#di.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.#di={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.#ti=e,this.#ri=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.#Zn.set(e,t)}removeSeason(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);this.#Zn.delete(e),this.#ai===e&&(this.#ai="")}hasSeason(e){if("string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);return this.#Zn.has(e)}getSeason(e){if("string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);const t=this.#Zn.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.#Xn+t*this.#Qn+r)%this.#Yn}addTime({hours:e=0,minutes:t=0,seconds:r=0}){this._checkDestroyed();let n=this.currentSeconds+e*this.#Xn+t*this.#Qn+r;for(;n>=this.#Yn;)n-=this.#Yn,this.nextDay();for(;n<0;)n+=this.#Yn,this.prevDay();this.currentSeconds=n,this.updateWeatherTimer((e*this.#Xn+t*this.#Qn+r)/this.#Qn)}getTime({withSeconds:e=!1,hourSize:t=this.#Xn,minuteSize:r=this.#Qn}={}){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.#ti<this.#ri?this.#oi>=this.#ti*this.#Qn&&this.#oi<this.#ri*this.#Qn:this.#oi>=this.#ti*this.#Qn||this.#oi<this.#ri*this.#Qn}minutesUntilDay(){return this.timeUntil(this.#ti,"minutes")}secondsUntilDay(){return this.timeUntil(this.#ti,"seconds")}hoursUntilDay(){return this.timeUntil(this.#ti,"hours")}minutesUntilNight(){return this.timeUntil(this.#ri,"minutes")}secondsUntilNight(){return this.timeUntil(this.#ri,"seconds")}hoursUntilNight(){return this.timeUntil(this.#ri,"hours")}timeUntil(e,t){this._checkDestroyed();let r=e*this.#Xn-this.#ii;switch(r<=0&&(r+=this.#Yn),t){case"minutes":return r/this.#Qn;case"hours":return r/this.#Xn;default:return r}}setTo(e){this._checkDestroyed(),"day"===e?this.setTime({hour:this.#ti}):"night"===e&&this.setTime({hour:this.#ri})}nextDay(e=1){this._checkDestroyed();for(let t=0;t<e;t++){this.#li++;const e=this.#hi[this.#ui-1];if(Number.isNaN(e)||!Number.isFinite(e))throw new Error("Invalid month day count: monthDays must be a finite number.");this.#li>e&&(this.#li=1,this.#ui++,this.#ui>this.#hi.length&&(this.#ui=1,this.#ci++)),this.updateSeason(),this.advanceMoons(1)}}prevDay(e=1){this._checkDestroyed();for(let t=0;t<e;t++)this.#li--,this.#li<1&&(this.#ui--,this.#ui<1&&(this.#ui=this.#hi.length,this.#ci--),this.#li=this.#hi[this.#ui-1]||30),this.updateSeason(),this.rewindMoons(1)}updateSeason(){this._checkDestroyed(),this.#Zn.forEach((e,t)=>{e.includes(this.#ui)&&(this.#ai=t)})}setWeatherConfig(e){this._checkDestroyed(),this.#di={...this.#di,...e}}setWeatherDuration(e,t){this._checkDestroyed(),this.#pi.min=e,this.#pi.max=t}updateWeatherTimer(e){this._checkDestroyed(),this.#fi-=e,this.#fi<=0&&this.chooseNewWeather()}forceWeather({where:e="main",type:t,duration:r=null}){this._checkDestroyed();const n=this.#ni;n[e]=t,this.weather=n,this.#fi=r??this._randomInRange(this.#pi.min,this.#pi.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.#oi/this.#Qn),minute:this.#oi%this.#Qn,currentMinutes:this.#oi,isDay:this.isDay(),season:this.#ai,weather:this.#ni})),"number"!=typeof e||Number.isNaN(e)||(r[t]=(r[t]||0)+e)}};n(this.#di.default||{});for(const e in this.#di.hours){const[t,r]=e.split("-").map(e=>{const[t,r]=e.split(":").map(Number);return t*this.#Qn+(r||0)}),i=this.#oi;(t<=r?i>=t&&i<=r:i>=t||i<=r)&&n(this.#di.hours[e])}this.isDay()&&this.#di.day?n(this.#di.day):!this.isDay()&&this.#di.night&&n(this.#di.night),this.#di.seasons?.[this.#ai]&&n(this.#di.seasons[this.#ai]),e&&"object"==typeof e&&n(e);const i=Object.entries(r).filter(([,e])=>e>0);if(!i.length)return this.#ni[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.#ni[t]=e,this.#fi=this._randomInRange(this.#pi.min,this.#pi.max),e;s-=r}return this.#ni[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.#ei.push({name:e,cycleLength:i,currentPhase:(n%i+i)%i,phaseNames:r}),this.#ei.length-1}removeMoon(e){this._checkDestroyed(),this.#ei=this.#ei.filter(t=>t.name!==e)}advanceMoons(e=1){for(const t in this.#ei)this.advanceMoon(parseInt(t),e)}rewindMoons(e=1){for(const t in this.#ei)this.rewindMoon(parseInt(t),e)}advanceMoon(e,t=1){this._checkDestroyed();const r=this.#ei[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.#ei[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.#ei[e]}getMoon(e){let t;if("number"==typeof e){if(t=this.#ei[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.#gr)throw new Error("This instance has been destroyed and can no longer be used.")}destroy(){this.#gr||(this.#Zn.clear(),this.#ei.length=0,this.#ti=0,this.#ri=0,this.#ii=0,this.#oi=0,this.#si=0,this.#li=1,this.#ui=1,this.#ci=1,this.#fi=0,this.#ai="",this.#ni={main:null},this.#hi=[],this.#di.default={},this.#di.day={},this.#di.night={},this.#di.hours={},this.#di.seasons={},this.#pi={min:0,max:0},this.#gr=!0)}};class Qt{#Lt=new kt;#On(e,...t){return this.#Lt.emit(e,...t)}setThrowOnMaxListeners(e){return this.#Lt.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#Lt.getThrowOnMaxListeners()}prependListener(e,t){return this.#Lt.prependListener(e,t)}prependListenerOnce(e,t){return this.#Lt.prependListenerOnce(e,t)}appendListener(e,t){return this.#Lt.appendListener(e,t)}appendListenerOnce(e,t){return this.#Lt.appendListenerOnce(e,t)}on(e,t){return this.#Lt.on(e,t)}once(e,t){return this.#Lt.once(e,t)}off(e,t){return this.#Lt.off(e,t)}offAll(e){return this.#Lt.offAll(e)}offAllTypes(){return this.#Lt.offAllTypes()}listenerCount(e){return this.#Lt.listenerCount(e)}listeners(e){return this.#Lt.listeners(e)}onceListeners(e){return this.#Lt.onceListeners(e)}allListeners(e){return this.#Lt.allListeners(e)}eventNames(){return this.#Lt.eventNames()}setMaxListeners(e){return this.#Lt.setMaxListeners(e)}getMaxListeners(){return this.#Lt.getMaxListeners()}#gr=!1;#mi;#gi;#yi=[];#wi=[];#bi=[];#vi=new Map;#Ei=new Set;#Ti=new Map;#Si;#xi=new Map;#Ai=new Map;get isDestroyed(){return this.#gr}get freq(){return Object.fromEntries(this.#Ai)}get size(){return this.#xi.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.#gi}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.#gi=e,null!==e&&(this.#Si=this._makeSeededRng(e))}get globalModifiers(){return[...this.#yi]}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.#yi=e}get temporaryModifiers(){return[...this.#wi]}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.#wi=e}get conditionalRules(){return[...this.#bi]}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.#bi=e}get pitySystems(){return Object.fromEntries(this.#vi)}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.#vi=e}get exclusions(){return Array.from(this.#Ei)}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.#Ei=e}get groups(){const e={};return this.#Ti.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.#Ti=e}get rng(){return this.#Si}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.#Si=e}get items(){const e={};return this.#xi.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.#xi=e}constructor(e={}){const{rng:t=null,seed:r=null,normalization:n="relative"}=e;this.#mi=n,this.#gi=r,"function"==typeof t?this.#Si=t:null!==this.#gi?this.#Si=this._makeSeededRng(this.#gi):this.#Si=Math.random,this.#gi=r??null}_checkDestroyed(){if(this.#gr)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.#xi.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.#xi.set(e,s);for(const t of o)this._ensureGroup(t).add(e);return this.#On("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.#xi.get(e);if(!t)return!1;for(const r of t.groups){const t=this.#Ti.get(r);t&&t.delete(e)}return this.#xi.delete(e),this.#On("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.#xi.get(e);if(!r)throw new Error("Item not found");r.baseWeight=Math.max(0,Number(t)||0),this.#On("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.#xi.get(e)??null}listItems(){return Array.from(this.#xi.values()).map(e=>({...e}))}clearList(){this._checkDestroyed(),this.#xi.clear(),this.clearFreqs(),this.clearPities()}hasGlobalModifier(e){if("function"!=typeof e)throw new TypeError("fn must be a function");return this.#yi.includes(e)}addGlobalModifier(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");this.#yi.push(e)}removeGlobalModifier(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");this.#yi=this.#yi.filter(t=>t!==e)}hasTemporaryModifier(e){if("function"!=typeof e)throw new TypeError("fn must be a function");return this.#wi.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.#wi.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.#wi.length;return this.#wi=this.#wi.filter(t=>t.fn!==e),this.#wi.length!==t}hasConditionalRule(e){if("function"!=typeof e)throw new TypeError("ruleFn must be a function");return this.#bi.includes(e)}addConditionalRule(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("ruleFn must be a function");this.#bi.push(e)}removeConditionalRule(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("ruleFn must be a function");const t=this.#bi.length;return this.#bi=this.#bi.filter(t=>t!==e),this.#bi.length!==t}hasPity(e){if("string"!=typeof e)throw new TypeError("itemId must be a string");return this.#vi.has(e)}configurePity(e,t){if(this._checkDestroyed(),!this.#xi.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.#vi.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.#vi.get(e);t&&(t.counter=0,t.currentAdd=0)}clearPities(){this._checkDestroyed(),this.#vi.clear()}hasExclusion(e){if("string"!=typeof e)throw new TypeError("itemId must be a string");return this.#Ei.has(e)}excludeItem(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#Ei.add(e)}includeItem(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#Ei.delete(e)}_ensureGroup(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("name must be a string");let t=this.#Ti.get(e);return t||(t=new Set,this.#Ti.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.#Ti.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.#xi.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.#Ti.get(t);r&&r.delete(e);const n=this.#xi.get(e);n&&n.groups.delete(t)}clearFreqs(){this._checkDestroyed(),this.#Ai.clear()}resetFreq(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#Ai.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.#xi)t.set(e,r.baseWeight);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 r of this.#wi){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.#bi){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.#vi)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.#Ei)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.#wi]},r=this.computeEffectiveWeights(t),n=this._weightsToDistribution(r);if(!n.length)return null;const i=this.#Si(),o=n.find(e=>i<=e.cumulative)??n[n.length-1];for(const[e,t]of this.#vi)e===o.id?(t.counter=0,t.currentAdd=0):t.counter++;this._consumeTemporaryModifiers();const s=this.#xi.get(o.id);if(!s)return null;const a={id:s.id,label:s.label,meta:{...s.meta},prob:o.p};return this.#On("draw",a),a&&this.#Ai.set(a.id,(this.#Ai.get(a.id)||0)+1),a}_consumeTemporaryModifiers(){this._checkDestroyed();for(let e=this.#wi.length-1;e>=0;--e){const t=this.#wi[e];t.uses-=1,t.uses<=0&&this.#wi.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.#Ei);for(const e of r)this.#Ei.add(e);const n=this.drawOne({previousDraws:o,metadata:t.metadata});if(this.#Ei=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.#xi.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.#vi.entries()),exclusions:Array.from(this.#Ei),normalization:this.#mi,seed:this.#gi}}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.#xi.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 Qt;return e.#mi=this.#mi,e.#gi=this.#gi,e.#yi=[...this.#yi],e.#wi=this.#wi.map(e=>({fn:e.fn,uses:e.uses})),e.#bi=[...this.#bi],e.#vi=new Map([...this.#vi.entries()].map(([e,t])=>[e,{...t}])),e.#Ei=new Set(this.#Ei),e.#Ti=new Map([...this.#Ti.entries()].map(([e,t])=>[e,new Set(t)])),e.#Si=this.#Si,e.#xi=new Map([...this.#xi.entries()].map(([e,t])=>[e,{...t,groups:new Set(t.groups),meta:{...t.meta}}])),e.#Ai=new Map(this.#Ai),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.#gr||(this.#gr=!0,this.#vi.clear(),this.#Ei.clear(),this.#Ti.clear(),this.#xi.clear(),this.#Ai.clear(),this.#yi=[],this.#wi=[],this.#bi=[],this.#gi=null)}}const Zt=Qt,er=class{#ie;get data(){return this.#ie}set data(e){if(!(Array.isArray(e)||e instanceof Set))throw new TypeError("Paginator expects an array or Set as data source.");this.#ie=e}get size(){return Array.isArray(this.#ie)?this.#ie.length:this.#ie.size}constructor(e){if(!(Array.isArray(e)||e instanceof Set))throw new TypeError("Paginator expects an array or Set as data source.");this.#ie=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.#ie)?this.#ie:Array.from(this.#ie);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 tr{static#Ci=new Map;static get itemRegistry(){const e={},t=Object.fromEntries(tr.#Ci);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.");tr.#Ci.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 tr.#Ci.delete(e)}static hasItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");return tr.#Ci.has(e)}static getItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");const t=tr.#Ci.get(e);if(!t)throw new Error(`Item '${e}' not defined in registry.`);return t}#Ii=new Map;#Lt={add:[],remove:[],use:[],set:[]};#xi=[];#Mi;#Li;#ki;#Ni;get maxStack(){return this.#Mi}set maxStack(e){if(!Number.isInteger(e)||Number.isFinite(e)&&e<=0)throw new TypeError(`maxStack must be a positive integer. Received: ${e}`);this.#Mi=e}get maxSize(){return this.#Li}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.#Li=e}get maxSlots(){return this.#ki}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.#ki=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.#Lt.add],remove:[...this.#Lt.remove],use:[...this.#Lt.use],set:[...this.#Lt.set]}}get items(){return[...this.#xi].map(e=>e?this.#_i(e):null)}get specialSlots(){return new Map([...this.#Ii.entries()].map(([e,t])=>[e,{type:t.type,item:t.item?this.#_i(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=tr.getItem(t.id);return e+(r?.weight||0)*t.quantity},0)}_cleanNulls(){let e=this.#xi.length-1;for(;e>=0&&null===this.#xi[e];)e--;this.#xi=this.#xi.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.#ki=e.maxSlots??null,this.#Li=e.maxSize??null,this.#Mi=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.#Ii.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.#Li&&this.size+e>this.#Li}isFull(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Li&&this.size+e>=this.#Li}areFullSlots(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#ki&&this.slotsSize+e>this.#ki}isFullSlots(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#ki&&this.slotsSize+e>=this.#ki}#Di(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.#Lt[e])for(const r of this.#Lt[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.#Lt[e])return;const r=this.#Lt[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.#Lt[e]&&(this.#Lt[e]=[])}cloneEventCallbacks(e){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");return this.#Lt[e]?[...this.#Lt[e]]:[]}onAddItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Lt.add.push(e)}onSetItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Lt.set.push(e)}onRemoveItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Lt.remove.push(e)}onUseItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Lt.use.push(e)}compactInventory(){this.#xi=this.#xi.filter((e,t)=>{const r=null!==e;return r||this.#Di("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=tr.getItem(e);let o=t;const s=i.maxStack<=this.#Mi?i.maxStack:this.#Mi,a=[],l=(e,t)=>JSON.stringify(e)===JSON.stringify(t);let u=!0;for(;o>0&&u;){u=!1;for(const t in this.#xi){const c=this.#xi[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.#Di("add",{item:this.#_i(c),index:r,isCollection:!0,specialSlot:null,remove:this.#ji({locationType:"normal",slotIndex:r,forceSpace:n,item:c})}),o<=0)break}}}if(o>0)for(const t in this.#xi)if(null===this.#xi[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.#xi[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.#Di("add",{item:this.#_i(u),index:c,isCollection:!0,specialSlot:null,remove:this.#ji({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.#xi.push(l);const u=this.#xi.length-1,c=a.findIndex(e=>e.index===u);c<0?a.push({index:u,quantity:t}):a[c].quantity+=t,this.#Di("add",{item:this.#_i(l),index:u,isCollection:!0,specialSlot:null,remove:this.#ji({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.#xi.length)throw new Error(`Slot index '${e}' out of bounds .`);return this.#xi[e]?this.#_i(this.#xi[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?tr.#Ci.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.#Mi?i.maxStack:this.#Mi;if(t.quantity>e)throw new Error(`Item '${t.id}' exceeds max stack size. Allowed: ${e}, got: ${t.quantity}.`)}if(null!==this.#ki&&(e<0||e>=this.#ki))throw new Error(`Slot index ${e} out of range.`);const o=this.#xi[e]??null,s=o?tr.#Ci.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.#xi.length<=e;)this.#xi.push(null);this.#xi[e]=t,this._cleanNulls(),this.#Di("set",{index:e,isCollection:!0,item:t?this.#_i(t):null,specialSlot:null,remove:t?this.#ji({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.#xi[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.#xi.length;r++){const o=this.#xi[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.#xi[r]=null),n<=0)return this._cleanNulls(),this.#Di("remove",{index:t,item:this.#_i(o),isCollection:!0,specialSlot:null,remove:this.#ji({locationType:"normal",slotIndex:t,item:o})}),!0}}return this._cleanNulls(),this.#Ii.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.#Ii.set(o,r),this.#Di("remove",{index:null,item:r.item?this.#_i(r.item):null,isCollection:!1,specialSlot:o,remove:r.item?this.#ji({locationType:"special",specialSlot:o,item:r.item}):()=>{}})}}),n<=0}#ji({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.#Ii.get(t);if(!e?.item)throw new Error(`Special slot '${t}' is empty.`);e.item.quantity>1?(e.item.quantity-=1,this.#Ii.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.#Ii.has(t))throw new Error(`Special slot '${t}' not found.`);i=this.#Ii.get(t).item,o="special"}else s=this.#xi,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=tr.getItem(i.id);if(a.onUse){const l={inventory:this,item:this.#_i(i),index:e??null,specialSlot:t??null,isCollection:!!s,itemDef:a,remove:this.#ji({locationType:o,specialSlot:t,slotIndex:e,forceSpace:r,item:i}),...n},u=a.onUse(l);return this.#Di("use",l),u}return null}hasSpecialSlot(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");return this.#Ii.has(e)}getSpecialItem(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(!this.#Ii.has(e))throw new Error(`Special slot '${e}' does not exist.`);const t=this.#Ii.get(e);return t?.item?this.#_i(t.item):null}getSpecialSlotType(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(!this.#Ii.has(e))throw new Error(`Special slot '${e}' does not exist.`);const t=this.#Ii.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.#Ii.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?tr.#Ci.get(t.id):null;if(null!==t&&!i)throw new Error(`Item '${t?.id??"unknown"}' not defined in registry.`);const o=this.#Ii.get(e);if(!o)throw new Error(`Special slot ${e} out of range for slot '${e}'.`);const s=o.item?tr.#Ci.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.#Di("set",{index:null,item:t?this.#_i(t):null,isCollection:!1,specialSlot:e,remove:t?this.#ji({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.#Ii.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=tr.getItem(i.id),s=this.#Ii.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.#Mi);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.#Ii.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.#Ii.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.#Ii.has(e))throw new Error(`Special slot '${e}' does not exist.`);const n=this.#Ii.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.#Ii.set(e,n),!0}#_i(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.#xi].map((e,t)=>[e?this.#_i(e):null,t]).filter(e=>null!==e[0])}getAllItems(){const e=[...this.#xi].filter(e=>null!==e).map(this.#_i);return this.#Ii.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=tr.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.#xi[e]}clear(){this.clearAllItems(),this.clearAllEvents()}clearAllEvents(){this.#Lt={add:[],remove:[],use:[],set:[]}}clearAllItems(){this.clearItems(),this.clearSpecialItems()}clearItems(){for(let e=this.#xi.length-1;e>=0;e--)this.#xi[e]&&this.deleteItem(e,!0)}clearSpecialItems(){for(const e of this.#Ii.keys()){const t=this.#Ii.get(e);t?.item&&this.deleteSpecialItem(e,!0)}}clone(){const e=this.toObject();return tr.fromObject(e)}toObject(){const e={};for(const[t,r]of this.#Ii.entries())e[t]={type:r?.type??null,item:r?.item?this.#_i(r.item):null};return{__schema:"TinyInventory",version:1,maxWeight:this.#Ni,maxSlots:this.#ki,maxSize:this.#Li,maxStack:this.#Mi,items:this.#xi.map(e=>e?this.#_i(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 tr({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 tr.fromObject(t)}}const rr=tr,nr=class{#Ri=null;#Oi=null;get sender(){return this.#Ri}get receiver(){return this.#Oi}set sender(e){if(!(e instanceof rr&&this.receiver instanceof rr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Ri=e}set receiver(e){if(!(this.sender instanceof rr&&e instanceof rr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Oi=e}constructor(e,t){if(e||t){if(!(e instanceof rr&&t instanceof rr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.connect(e,t)}}connect(e,t){if(!(e instanceof rr&&t instanceof rr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Ri=e,this.#Oi=t}disconnect(){this.#Ri=null,this.#Oi=null}invert(){const e=this.#Ri,t=this.#Oi;this.#Ri=t,this.#Oi=e}transferItem({slotIndex:e,specialSlot:t,quantity:r=1,receiverSlotIndex:n,forceSpace:i=!1,strict:o=!1}){if(!this.#Ri||!this.#Oi)throw new Error("Sender and receiver inventories must be connected.");let s;if(t){if(s=this.#Ri.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.#Ri.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.#Oi.existsItemAt(n)?this.#Oi.getItemFrom(n):null;if(e){if(e.id!==a.id)throw new Error(`Receiver slot ${n} contains a different item.`);const t=rr.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.#Oi.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.#Oi.existsItemAt(n)?this.#Oi.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=rr.getItem(e.id).maxStack-e.quantity;t=Math.min(r,a.quantity),t>0&&this.#Oi.setItem({slotIndex:n,item:{...e,quantity:e.quantity+t},forceSpace:i})}else this.#Oi.setItem({slotIndex:n,item:a,forceSpace:i});l={remaining:a.quantity-t}}else l=this.#Oi.addItem({itemId:a.id,quantity:a.quantity,metadata:a.metadata,forceSpace:i});const u=a.quantity-l.remaining;if(u>0)if(t)this.#Ri.unequipItem({slotId:t,quantity:u,forceSpace:i});else if("number"==typeof e){const t=s.quantity-u;this.#Ri.setItem({slotIndex:e,item:t>0?{...s,quantity:t}:null,forceSpace:i})}return l}transferMultiple(e){return e.map(e=>this.transferItem(e))}},ir=class{#Hi;#$i={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.#$i.storageKey);return e?JSON.parse(e):{}}get config(){return{...this.#$i,categories:[...this.#$i.categories]}}set config(e){this.validateConfig(e),this.#$i=Object.assign(this.#$i,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.#$i.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.#$i.animationDuration)}savePreferences(e){if(!e||"object"!=typeof e)throw new TypeError("Preferences must be an object.");localStorage.setItem(this.#$i.storageKey,JSON.stringify(e)),this.#$i.onSave(e)}showConsentBar(){const e=document.createElement("div");e.className="cookie-consent-bar",e.innerHTML=this.#$i.renderBar?this.#$i.renderBar(this.#$i):`\n <div><p>${this.#$i.message}</p></div>\n <div><button class="accept">${this.#$i.acceptText}</button></div>\n <div><button class="reject">${this.#$i.rejectText}</button></div>\n <div><button class="settings">${this.#$i.settingsText}</button></div>\n `,document.body.appendChild(e);const t=e.querySelector(".accept");t instanceof HTMLElement&&(t.onclick=()=>{const t={};this.#$i.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.#$i.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.#$i.renderModal?this.#$i.renderModal(this.#$i):`\n <div class="modal-content">\n <h2>Cookie Settings</h2>\n <form class="settings-form">\n ${this.#$i.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 or=r(911),sr=r(766);const ar=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,sr.existsSync)(t))throw new Error(`mergeLocaleFiles: file "${t}" does not exist`);const e=await(0,or.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,or.writeFile)(t,JSON.stringify(n,null,r),"utf-8")}#Bi;#Pi;#Fi=null;#Wi;#zi=null;#qi=new Map;#Vi=new Map;#Ui=new Map;#Ki=new Map;get currentLocale(){return this.#Fi}get defaultLocale(){return this.#Pi}get mode(){return this.#Bi}get strict(){return this.#Wi}get basePath(){return this.#zi}get stats(){const e=[];for(const t of this.#qi.keys())e.push(this.getStatsForLocale(t));return e}get stringTables(){const e={};for(const[t,r]of this.#qi.entries())e[t]=this.#Ji(r);return e}get patternTables(){const e={};for(const[t,r]of this.#Vi.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.#Ui.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}#Gi(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.#qi.has(e)?t.push(e):this.#Fi&&t.push(this.#Fi),t.push(this.#Pi),t}#Yi(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.#qi.get(r);if(e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}}#Xi(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.#Vi.get(r)||[];for(const r of e)return r.$pattern.test(t)?r.value:r.elseValue??void 0}}#Qi(e,t){if(null==e){if(this.#Wi)throw new TypeError('#materialize: "value" cannot be null or undefined');return""}if("string"==typeof e)return this.#Zi(e,t);if("function"==typeof e)return e(t??{},this.#eo());if(e&&"object"==typeof e&&"string"==typeof e.$fn){const r=this.#Ui.get(e.$fn);if("function"!=typeof r){if(this.#Wi)throw new Error(`TinyI18: helper "${e.$fn}" is not registered`);return""}return r({...t??{},args:void 0!==e.args?e.args:void 0},this.#eo())}if(this.#Wi)throw new Error("TinyI18: unsupported entry type");return""}#Zi(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.#to(t,r);return null==n?"":String(n)}):e}#to(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}#eo(){return{has:e=>this.#Ui.has(e),call:(e,t,r)=>{const n=this.#Ui.get(e);if("function"!=typeof n)throw new Error(`Helper "${e}" not found`);return n(t,r??{})}}}#ro(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.#qi.get(e)??{}},n=[...this.#Vi.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.#qi.set(e,r),this.#Vi.set(e,n),this.#qi.has(this.#Pi)||(this.#qi.set(this.#Pi,{}),this.#Vi.set(this.#Pi,[]))}#no(e){if("string"!=typeof e||!e)throw new TypeError('#unloadLocale: "locale" must be a non-empty string');e!==this.#Pi&&(this.#qi.delete(e),this.#Vi.delete(e))}async#io(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,or.readFile)(t,"utf8");r=JSON.parse(e)}catch(r){if(!(r instanceof Error))return;if(this.#Wi)throw new Error(`TinyI18: failed to load or parse ${t}: ${r.message}`);return this.#qi.set(e,{}),void this.#Vi.set(e,[])}const n={...this.#qi.get(e)??{}},i=[...this.#Vi.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.#oo(t.$pattern);return void i.push({$pattern:e,value:this.#so(t.value),elseValue:this.#so(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.#so(t)}else if(t&&"object"==typeof t)for(const[r,n]of Object.entries(t))o(e?`${e}.${r}`:r,n)}};o("",r),this.#qi.set(e,n),this.#Vi.set(e,i)}#oo(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.#Wi)throw new Error(`TinyI18: invalid regex "${e}" in file`);return/^$/}}#so(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.#Wi)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.#Bi=t,this.#Pi=r,this.#Wi=o,"local"===t&&i&&"object"==typeof i)for(const[e,t]of Object.entries(i))this.#ro(e,t);this.#qi.has(this.#Pi)||(this.#qi.set(this.#Pi,{}),this.#Vi.set(this.#Pi,[]))}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.#Ui.set(e,t)}unregisterHelper(e){if("string"!=typeof e||!e)throw new TypeError('unregisterHelper: "name" must be non-empty string');return this.#Ui.delete(e)}loadLocaleLocal(e,t){if("local"!==this.#Bi)throw new TypeError('loadLocaleLocal is only available in "local" mode');this.#ro(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.#Bi?await this.#io(e):this.#qi.has(e)||(this.#qi.set(e,{}),this.#Vi.set(e,[]))),"file"===this.#Bi&&t&&t!==this.#Pi&&t!==e&&this.#no(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.#Gi(n);let o=this.#Yi(i,e);if(void 0===o){if(this.#Wi)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return this.#Qi(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.#Gi(r);let i=this.#Xi(n,e);if(void 0===i){if(this.#Wi)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return i}resetToDefaultOnly(){if("file"===this.#Bi)for(const e of Array.from(this.#qi.keys()))e!==this.#Pi&&this.#no(e);this.#Fi=null}getStatsForLocale(e){if("string"!=typeof e||!e)throw new TypeError('getStatsForLocale: "locale" must be a non-empty string');if(!this.#qi.has(e))throw new Error(`getStatsForLocale: locale "${e}" is not registered`);return{locale:e,strings:Object.keys(this.#qi.get(e)??{}).length,patterns:this.#Vi.get(e)?.length??0,isDefault:e===this.#Pi,isCurrent:e===this.#Fi}}};class lr{#ao=new Map;#lo;#uo;#co;get factors(){const e={};for(let[t,r]of this.#ao.entries())e[t]={...r};return e}get currentPercent(){return this.#uo/this.#lo*100}set maxValue(e){if("number"!=typeof e||Number.isNaN(e)||e<=0)throw new TypeError("maxValue must be a positive number.");this.#lo=e,this.#uo=Math.min(this.#uo,e)}get maxValue(){return this.#lo}get currentValue(){return this.#uo}set infiniteValue(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("infiniteValue must be a number.");this.#co=e,this.#uo=Math.max(0,e),this.#uo=Math.min(this.#uo,this.#lo)}get infiniteValue(){return this.#co}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.#lo=e,this.setFactor("main",t,r),this.#uo=e,this.#co=e}getFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");const t=this.#ao.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.#ao.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.#ao.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.#ao.delete(e)}#ho(e){const t=this.#co;return this.#co-=e,this.#uo=Math.max(0,this.#uo-e),{prevValue:t,removedTotal:e,removedPercent:e/this.#lo*100,currentPercent:this.currentPercent,remainingValue:this.#uo,infiniteRemaining:this.#co}}tick(){let e=0;for(let[t,r]of this.#ao.entries())e+=r.amount*r.multiplier;return this.#ho(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.#ao.entries())t+=r.amount*r.multiplier;return e&&(t+=e.amount*(e.multiplier??1)),this.#ho(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.#ho(t)}toJSON(){return{maxValue:this.#lo,currentValue:this.#uo,infiniteValue:this.#co,factors:this.factors}}static fromJSON(e){const t=new lr(e.maxValue,0,0);t.infiniteValue=e.infiniteValue,t.#ao.clear();for(const[r,n]of Object.entries(e.factors))t.setFactor(r,n.amount,n.multiplier);return t}clone(){return lr.fromJSON(this.toJSON())}clearFactors(){this.#ao.clear()}}const ur=lr;class cr{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=cr.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)||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 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),p=h(s),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(),o="number"==typeof t?t:f(t)?t.value:0;f(t)&&n(t),l.push([o]);for(const t in m)if(m[t]===e){m[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:f(t)?t.value:0;f(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 m){const r=Number(t);if(m[r]===e){m.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=cr._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))}#lo;#do;get maxValue(){return this.#lo}set maxValue(e){if(!Number.isInteger(e)||e<0)throw new TypeError("maxValue must be an integer greater than -1.");this.#lo=e}get allowZero(){return this.#do}set allowZero(e){if("boolean"!=typeof e)throw new TypeError("allowZero must be a boolean.");this.#do=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.#lo=e,this.#do=t}roll(){const e=this.#do?0:1;return Math.floor(Math.random()*(this.#lo-e+1))+e}}const hr=cr,dr=class{#T=null;get overlay(){return this.#T}#po=null;get messageElement(){return this.#po}#R;get container(){return this.#R}#fo={fadeIn:null,fadeOut:null,zIndex:9999};get options(){return{...this.#fo}}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.#fo={fadeIn:e.fadeIn??null,fadeOut:e.fadeOut??null,zIndex:e.zIndex??9999}}#mo="none";get status(){return this.#mo}#go="";get defaultMessage(){return this.#go}set defaultMessage(e){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("defaultMessage must be a string or an HTMLElement");this.#go=e}#yo=null;get message(){return this.#yo}#wo=!1;get allowHtmlText(){return this.#wo}set allowHtmlText(e){if("boolean"!=typeof e)throw new TypeError("allowHtmlText must be a boolean");this.#wo=e}#bo=null;get fadeInTimeout(){return null!==this.#bo}#vo=null;get fadeOutTimeout(){return null!==this.#vo}get visible(){return!!this.#T}#Eo=null;get onChange(){return this.#Eo}set onChange(e){if(null!==e&&"function"!=typeof e)throw new TypeError("onChange must be a function or null");this.#Eo=e}_emitChange(){"function"==typeof this.#Eo&&this.#Eo(this.#mo)}constructor(e=document.body){if(!(e instanceof HTMLElement))throw new TypeError("container must be an HTMLElement");this.#R=e}_updateMessage(e=this.#go){if(!this.#po)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.#yo=e,"string"==typeof e)this.#wo?this.#po.innerHTML=e:this.#po.textContent=e;else{if(!this.#wo)throw new Error("HTMLElement messages require allowHtmlText = true");this.#po.textContent="",this.#po.appendChild(e)}}_removeOldClasses(){this.#T?.classList.remove("active"),this.#T?.classList.remove("fadeIn"),this.#T?.classList.remove("fadeOut")}start(e=this.#go){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.#fo.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.#po=document.createElement("div"),this.#po.classList.add("loading-message"),r.appendChild(n),r.appendChild(this.#po),t.appendChild(r),this.#T.appendChild(t),this.#R.appendChild(this.#T),this._removeOldClasses(),this.#mo="fadeIn",this.#T.classList.add("fadeIn"),this._emitChange();const i=()=>{this._removeOldClasses(),this.#bo=null,this.#mo="active",this.#T?.classList.add("active"),this._emitChange()};return"number"==typeof this.#fo.fadeIn?(this.#bo&&clearTimeout(this.#bo),this.#bo=setTimeout(i,this.#fo.fadeIn)):i(),this._updateMessage(e),!0}return this.#po&&this._updateMessage(e),!1}update(e=this.#go){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");return!!this.#po&&(this._updateMessage(e),!0)}stop(){if(this.#T){this._removeOldClasses(),this.#mo="fadeOut",this.#T.classList.add("fadeOut"),this._emitChange();const e=()=>{this._removeOldClasses(),this.#vo=null,this.#mo="none",this.#T?.remove(),this.#T=null,this.#po=null,this.#yo=null,this._emitChange()};return"number"==typeof this.#fo.fadeOut?(this.#vo&&clearTimeout(this.#vo),this.#vo=setTimeout(e,this.#fo.fadeOut)):e(),!0}return!1}};class pr{static#To=/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;static#So=/^#([A-Fa-f0-9]{8})$/;static#xo="(0|1|0?\\.\\d+)";static#Ao="(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#Io="(0|[1-9]?\\d|100)";static#Mo=new RegExp(`^rgb\\(\\s*${pr.#Ao}\\s*,\\s*${pr.#Ao}\\s*,\\s*${pr.#Ao}\\s*\\)$`);static#Lo=new RegExp(`^rgba\\(\\s*${pr.#Ao}\\s*,\\s*${pr.#Ao}\\s*,\\s*${pr.#Ao}\\s*,\\s*${pr.#xo}\\s*\\)$`);static#ko=new RegExp(`^hsl\\(\\s*${pr.#Co}\\s*,\\s*${pr.#Io}%\\s*,\\s*${pr.#Io}%\\s*\\)$`);static#No=new RegExp(`^hsla\\(\\s*${pr.#Co}\\s*,\\s*${pr.#Io}%\\s*,\\s*${pr.#Io}%\\s*,\\s*${pr.#xo}\\s*\\)$`);static#_o=new RegExp(`^hwb\\(\\s*${pr.#Co}(deg|grad|rad|turn)?\\s*${pr.#Io}%\\s*${pr.#Io}%\\s*\\)$`);static#Do="(-?\\d+)";static#jo=new RegExp(`^lab\\(\\s*${pr.#Io}%?\\s*${pr.#Do}%?\\s*${pr.#Do}%?\\s*\\)$`);static#Ro=new RegExp(`^lch\\(\\s*${pr.#Io}%?\\s*${pr.#Io}%?\\s*${pr.#Co}(deg|grad|rad|turn)?\\s*\\)$`);static#Oo=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(pr.#Oo)}static addName(e){const t=pr.#Oo.size;return pr.#Oo.add(e.toLowerCase()),pr.#Oo.size>t}static removeName(e){return pr.#Oo.delete(e.toLowerCase())}static hasName(e){return pr.#Oo.has(e.toLowerCase())}static getSpecialNames(){return Array.from(pr.#Ho)}static addSpecialName(e){const t=pr.#Ho.size;return pr.#Ho.add(e),pr.#Ho.size>t}static removeSpecialName(e){return pr.#Ho.delete(e)}static hasSpecialName(e){return pr.#Ho.has(e)}#$o;get code(){return this.#$o}#Bo;get type(){return this.#Bo}constructor(e){this.#$o=e,this.#Bo=pr.isColor(this.#$o)}static isHex(e){if("string"!=typeof e)throw new TypeError("isHex: input must be a string.");return pr.#To.test(e.trim())}isHex(){return pr.isHex(this.#$o)}static isHexa(e){if("string"!=typeof e)throw new TypeError("isHexa: input must be a string.");return pr.#So.test(e.trim())}isHexa(){return pr.isHexa(this.#$o)}static isRgb(e){if("string"!=typeof e)throw new TypeError("isRgb: input must be a string.");return pr.#Mo.test(e.trim())}isRgb(){return pr.isRgb(this.#$o)}static isRgba(e){if("string"!=typeof e)throw new TypeError("isRgba: input must be a string.");return pr.#Lo.test(e.trim())}isRgba(){return pr.isRgba(this.#$o)}static isHsl(e){if("string"!=typeof e)throw new TypeError("isHsl: input must be a string.");return pr.#ko.test(e.trim())}isHsl(){return pr.isHsl(this.#$o)}static isHsla(e){if("string"!=typeof e)throw new TypeError("isHsla: input must be a string.");return pr.#No.test(e.trim())}isHsla(){return pr.isHsla(this.#$o)}static isHwb(e){if("string"!=typeof e)throw new TypeError("isHwb: input must be a string.");return pr.#_o.test(e.trim())}isHwb(){return pr.isHwb(this.#$o)}static isLab(e){if("string"!=typeof e)throw new TypeError("isLab: input must be a string.");return pr.#jo.test(e.trim())}isLab(){return pr.isLab(this.#$o)}static isLch(e){if("string"!=typeof e)throw new TypeError("isLch: input must be a string.");return pr.#Ro.test(e.trim())}isLch(){return pr.isLch(this.#$o)}static isName(e){if("string"!=typeof e)throw new TypeError("isName: input must be a string.");return pr.#Oo.has(e.trim().toLowerCase())}isName(){return pr.isName(this.#$o)}static isSpecialName(e){if("string"!=typeof e)throw new TypeError("isSpecialName: input must be a string.");return pr.#Ho.has(e.trim())}isSpecialName(){return pr.isSpecialName(this.#$o)}static isColor(e){if("string"!=typeof e)throw new TypeError("isColor: input must be a string.");return pr.isHex(e)?"hex":pr.isHexa(e)?"hexa":pr.isRgb(e)?"rgb":pr.isRgba(e)?"rgba":pr.isHsl(e)?"hsl":pr.isHsla(e)?"hsla":pr.isHwb(e)?"hwb":pr.isLab(e)?"lab":pr.isLch(e)?"lch":pr.isName(e)?"name":pr.isSpecialName(e)?"specialName":null}parse(){switch(this.#Bo){case"hex":return pr.parseHex(this.code);case"hexa":return pr.parseHexa(this.code);case"rgb":return pr.parseRgb(this.code);case"rgba":return pr.parseRgba(this.code);case"hsl":return pr.parseHsl(this.code);case"hsla":return pr.parseHsla(this.code);case"hwb":return pr.parseHwb(this.code);case"lab":return pr.parseLab(this.code);case"lch":return pr.parseLch(this.code);case"name":case"specialName":return this.#$o.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(pr.#To,"gm").exec(e.trim());return t?t[1]:null}parseHex(){return pr.parseHex(this.#$o)}static parseHexa(e){if("string"!=typeof e)throw new TypeError("parseHexa: input must be a string.");const t=new RegExp(pr.#So,"gm").exec(e.trim());return t?t[1]:null}parseHexa(){return pr.parseHexa(this.#$o)}static parseRgb(e){if("string"!=typeof e)throw new TypeError("parseRgb: input must be a string.");const t=new RegExp(pr.#Mo,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseRgb(){return pr.parseRgb(this.#$o)}static parseRgba(e){if("string"!=typeof e)throw new TypeError("parseRgba: input must be a string.");const t=new RegExp(pr.#Lo,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])]:null}parseRgba(){return pr.parseRgba(this.#$o)}static parseHsl(e){if("string"!=typeof e)throw new TypeError("parseHsl: input must be a string.");const t=new RegExp(pr.#ko,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseHsl(){return pr.parseHsl(this.#$o)}static parseHsla(e){if("string"!=typeof e)throw new TypeError("parseHsla: input must be a string.");const t=new RegExp(pr.#No,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])]:null}parseHsla(){return pr.parseHsla(this.#$o)}static parseHwb(e){if("string"!=typeof e)throw new TypeError("parseHwb: input must be a string.");const t=new RegExp(pr.#_o,"gm").exec(e.trim());return t?[parseFloat(t[1]),t[2]??null,parseFloat(t[3]),parseFloat(t[4])]:null}parseHwb(){return pr.parseHwb(this.#$o)}static parseLab(e){if("string"!=typeof e)throw new TypeError("parseLab: input must be a string.");const t=new RegExp(pr.#jo,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseLab(){return pr.parseLab(this.#$o)}static parseLch(e){if("string"!=typeof e)throw new TypeError("parseLch: input must be a string.");const t=new RegExp(pr.#Ro,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),t[4]??null]:null}parseLch(){return pr.parseLch(this.#$o)}}const fr=pr,mr=class{#Po;#Fo;#Wo;#$i;#an=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.#$i={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.#Po=document.createElement("div"),this.#Po.className="analog-clock-container",this.#Po.style.position="relative",this.#Po.style.borderRadius="50%",this.#Po.style.overflow="hidden",this.#Po.style.boxSizing="border-box",this.#Wo=document.createElement("div"),this.#Wo.style.position="absolute",this.#Wo.style.inset="0",this.#Wo.style.backgroundSize="cover",this.#Wo.style.backgroundPosition="center",this.#Wo.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.#Po.appendChild(this.#Wo),this.#Po.appendChild(this.#Fo),this.#Po.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.#Po.appendChild(r),this._applyConfig(),this._renderFace(),this._startTicker()}_applyConfig(){const e=this.#Po.style,t=this.#$i;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.#Wo.style.backgroundImage=`url(${t.skinUrl})`,this.#Wo.style.display="block"):this.#Wo.style.display="none";const r=e=>{const t=this.#Po.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.#$i.size/2-this.#$i.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.#$i.size*this.#$i.pwH:this.#$i.size*this.#$i.pwM,o=r?this.#$i.size*this.#$i.phH:this.#$i.size*this.#$i.phM,s=this.#$i.markColor;n.style.width=`${i}px`,n.style.height=`${o}px`,n.style.color=s;const a=e-this.#$i.padding-o/2;n.style.transform=`translate(-50%, -50%) rotate(${6*t}deg) translate(0, -${a}px)`,this.#Fo.appendChild(n)}if(this.#$i.showNumbers)for(let t=1;t<=12;t++){const r=30*t*(Math.PI/180),n=e*this.#$i.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.#$i.textColor,s.style.fontSize=this.#$i.size*this.#$i.sizeAdjust+"px",this.#Fo.appendChild(s)}}_startTicker(){if(this.#an)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.#Po.querySelector(e);if(!(t instanceof HTMLDivElement))throw new Error(`${e} not found.`);return t};this.#Po.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.#an=requestAnimationFrame(e)};e()}get element(){return this.#Po}set size(e){if("number"!=typeof e||e<=0||isNaN(e))throw new Error(`TinyAnalogClock: 'size' must be a positive number. Received: ${e}`);this.#$i.size=e,this._applyConfig(),this._renderFace()}get size(){return this.#$i.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.#$i.skinUrl=e,this._applyConfig()}get skinUrl(){return this.#$i.skinUrl}set borderColor(e){if("string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'borderColor' must be a non-empty string. Received: ${e}`);this.#$i.borderColor=e,this._applyConfig(),this._renderFace()}get borderColor(){return this.#$i.borderColor}set markColor(e){if("string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'markColor' must be a non-empty string. Received: ${e}`);this.#$i.markColor=e,this._applyConfig(),this._renderFace()}get markColor(){return this.#$i.markColor}set textColor(e){if("string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'textColor' must be a non-empty string. Received: ${e}`);this.#$i.textColor=e,this._applyConfig(),this._renderFace()}get textColor(){return this.#$i.textColor}set showNumbers(e){if("boolean"!=typeof e)throw new Error("TinyAnalogClock: 'showNumbers' must be a boolean. Received type: "+typeof e);this.#$i.showNumbers=e,this._renderFace()}get showNumbers(){return this.#$i.showNumbers}set bgColor(e){if("string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'bgColor' must be a non-empty string.");this.#$i.bgColor=e,this._applyConfig()}get bgColor(){return this.#$i.bgColor}set borderWidth(e){if("number"!=typeof e||e<0)throw new Error("TinyAnalogClock: 'borderWidth' must be a non-negative number.");this.#$i.borderWidth=e,this._applyConfig(),this._renderFace()}get borderWidth(){return this.#$i.borderWidth}set hourHandColor(e){if("string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'hourHandColor' must be a non-empty string.");this.#$i.hourHandColor=e,this._applyConfig()}get hourHandColor(){return this.#$i.hourHandColor}set minuteHandColor(e){if("string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'minuteHandColor' must be a non-empty string.");this.#$i.minuteHandColor=e,this._applyConfig()}get minuteHandColor(){return this.#$i.minuteHandColor}set secondHandColor(e){if("string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'secondHandColor' must be a non-empty string.");this.#$i.secondHandColor=e,this._applyConfig()}get secondHandColor(){return this.#$i.secondHandColor}set showSeconds(e){if("boolean"!=typeof e)throw new Error("TinyAnalogClock: 'showSeconds' must be a boolean.");this.#$i.showSeconds=e,this._applyConfig()}get showSeconds(){return this.#$i.showSeconds}set sizeAdjust(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'sizeAdjust' must be a positive number.");this.#$i.sizeAdjust=e,this._renderFace()}get sizeAdjust(){return this.#$i.sizeAdjust}set padding(e){if("number"!=typeof e||e<0)throw new Error("TinyAnalogClock: 'padding' must be a non-negative number.");this.#$i.padding=e,this._renderFace()}get padding(){return this.#$i.padding}set angleDistance(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'angleDistance' must be a positive number.");this.#$i.angleDistance=e,this._renderFace()}get angleDistance(){return this.#$i.angleDistance}set pwH(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'pwH' must be a positive number.");this.#$i.pwH=e,this._renderFace()}get pwH(){return this.#$i.pwH}set phH(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'phH' must be a positive number.");this.#$i.phH=e,this._renderFace()}get phH(){return this.#$i.phH}set pwM(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'pwM' must be a positive number.");this.#$i.pwM=e,this._renderFace()}get pwM(){return this.#$i.pwM}set phM(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'phM' must be a positive number.");this.#$i.phM=e,this._renderFace()}get phM(){return this.#$i.phM}destroy(){this.#an&&(cancelAnimationFrame(this.#an),this.#an=null),this.#Po.remove()}},gr=class{#zo=[];#we=!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}#qo(){if(this.#we)throw new Error("Cannot perform operations on a destroyed TinyTextDiffer instance.")}#Vo(e){if("number"!=typeof e)throw new TypeError("The provided index must be a valid number.")}#Uo(e){if("string"!=typeof e)throw new TypeError("The provided text must be a valid string.")}get(e){if(this.#qo(),this.#Vo(e),void 0===this.#zo[e])throw new Error(`No text version found at index ${e}.`);return this.#zo[e]}has(e){return this.#qo(),this.#Vo(e),void 0!==this.#zo[e]}add(e){this.#qo(),this.#Uo(e),this.#zo.push(e)}remove(){return this.#qo(),this.#zo.pop()}addAt(e,t){this.#qo(),this.#Vo(e),this.#Uo(t),this.#zo.splice(e,0,t)}removeAt(e){this.#qo(),this.#Vo(e);const t=this.#zo.length;return this.#zo.splice(e,1),t!==this.#zo.length}clear(){this.#qo(),this.#zo=[]}compare(...e){this.#qo();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.#Vo(e[n]),this.#Vo(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.#we||(this.#zo=[],this.#we=!0)}}})(),window.TinyEssentials=n})();
|
|
2
|
+
(()=>{var e={133:()=>{},251:(e,t)=>{t.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,l=(1<<a)-1,u=l>>1,h=-7,c=r?i-1:0,d=r?-1:1,p=e[t+c];for(c+=d,o=p&(1<<-h)-1,p>>=-h,h+=a;h>0;o=256*o+e[t+c],c+=d,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+e[t+c],c+=d,h-=8);if(0===o)o=1-u;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=u}return(p?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,l,u=8*o-i-1,h=(1<<u)-1,c=h>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+c>=1?d/l:d*Math.pow(2,1-c))*l>=2&&(s++,l/=2),s+c>=h?(a=0,s=h):s+c>=1?(a=(t*l-1)*Math.pow(2,i),s+=c):(a=t*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;e[r+p]=255&a,p+=f,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;e[r+p]=255&s,p+=f,s/=256,u-=8);e[r+p-f]|=128*m}},287:(e,t,r)=>{"use strict";var n=r(526),i=r(251),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.hp=l,t.IS=50;var s=2147483647;function a(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,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 c(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|m(e,t),n=a(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(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|f(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||W(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 h(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 c(e){return h(e),a(e<0?0:0|f(e))}function d(e){for(var t=e.length<0?0:0|f(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 f(e){if(e>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function m(e,t){if(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 B(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 k(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 L(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),W(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 o,s=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;s=2,a/=2,l/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var h=-1;for(o=r;o<a;o++)if(u(e,o)===u(t,-1===h?0:o-h)){if(-1===h&&(h=o),o-h+1===l)return h*s}else-1!==h&&(o-=o-h),h=-1}else for(r+l>a&&(r=a-l),o=r;o>=0;o--){for(var c=!0,d=0;d<l;d++)if(u(e,o+d)!==u(t,d)){c=!1;break}if(c)return o}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 o=t.length;n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(W(a))return s;e[r+s]=a}return s}function E(e,t,r,n){return P($(t,e.length-r),e,r,n)}function T(e,t,r,n){return P(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 P(B(t),e,r,n)}function x(e,t,r,n){return P(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function 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 o,s,a,l,u=e[i],h=null,c=u>239?4:u>223?3:u>191?2:1;if(i+c<=r)switch(c){case 1:u<128&&(h=u);break;case 2:128==(192&(o=e[i+1]))&&(l=(31&u)<<6|63&o)>127&&(h=l);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(l=(15&u)<<12|(63&o)<<6|63&s)>2047&&(l<55296||l>57343)&&(h=l);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&l<1114112&&(h=l)}null===h?(h=65533,c=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=c}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 h(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 c(e)},l.allocUnsafeSlow=function(e){return c(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,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},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 o=e[r];if(F(o,Uint8Array))i+o.length>n.length?l.from(o).copy(n,i):Uint8Array.prototype.set.call(n,o,i);else{if(!l.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i)}i+=o.length}return n},l.byteLength=m,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+">"},o&&(l.prototype[o]=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 o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),h=e.slice(t,r),c=0;c<a;++c)if(u[c]!==h[c]){o=u[c],s=h[c];break}return o<s?-1:s<o?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 o=!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(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!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 L(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 k(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=t;o<r;++o)i+=z[e[o]];return i}function N(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function _(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 D(e,t,r,n,i,o){if(!l.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function j(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(e,t,r,n,o){return t=+t,r>>>=0,o||j(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function O(e,t,r,n,o){return t=+t,r>>>=0,o||j(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||_(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},l.prototype.readUintBE=l.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||_(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||_(e,1,this.length),this[e]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(e,t){return e>>>=0,t||_(e,2,this.length),this[e]|this[e+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(e,t){return e>>>=0,t||_(e,2,this.length),this[e]<<8|this[e+1]},l.prototype.readUint32LE=l.prototype.readUInt32LE=function(e,t){return e>>>=0,t||_(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||_(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||_(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},l.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||_(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},l.prototype.readInt8=function(e,t){return e>>>=0,t||_(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},l.prototype.readInt16LE=function(e,t){e>>>=0,t||_(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||_(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||_(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||_(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||_(e,4,this.length),i.read(this,e,!0,23,4)},l.prototype.readFloatBE=function(e,t){return e>>>=0,t||_(e,4,this.length),i.read(this,e,!1,23,4)},l.prototype.readDoubleLE=function(e,t){return e>>>=0,t||_(e,8,this.length),i.read(this,e,!0,52,8)},l.prototype.readDoubleBE=function(e,t){return e>>>=0,t||_(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||D(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},l.prototype.writeUintBE=l.prototype.writeUIntBE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||D(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},l.prototype.writeUint8=l.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||D(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||D(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||D(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||D(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||D(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);D(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},l.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);D(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},l.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||D(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||D(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||D(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||D(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||D(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 R(this,e,t,!0,r)},l.prototype.writeFloatBE=function(e,t,r){return R(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 o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var s=l.isBuffer(e)?e:l.from(e,n),a=s.length;if(0===a)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<r-t;++o)this[o+t]=s[o%a]}return this};var H=/[^+/0-9A-Za-z-_]/g;function $(e,t){var r;t=t||1/0;for(var n=e.length,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function B(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(H,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function P(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 W(e){return e!=e}var z=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}()},370:()=>{},526:(e,t)=>{"use strict";t.byteLength=function(e){var t=a(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,o=a(e),s=o[0],l=o[1],u=new i(function(e,t,r){return 3*(t+r)/4-r}(0,s,l)),h=0,c=l>0?s-4:s;for(r=0;r<c;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[h++]=t>>16&255,u[h++]=t>>8&255,u[h++]=255&t;return 2===l&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,u[h++]=255&t),1===l&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,u[h++]=t>>8&255,u[h++]=255&t),u},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],s=16383,a=0,l=n-i;a<l;a+=s)o.push(u(e,a,a+s>l?l:a+s));return 1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function 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=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),i.push(l(n));return i.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},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,h=-1;function c(){u&&a&&(u=!1,a.length?l=a.concat(l):h=-1,l.length&&d())}function d(){if(!u){var e=s(c);u=!0;for(var t=l.length;t;){for(a=l,l=[];++h<t;)a&&a[h].run();h=-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 p(e,t){this.fun=e,this.array=t}function f(){}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||s(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=f,n.addListener=f,n.once=f,n.off=f,n.removeListener=f,n.removeAllListeners=f,n.emit=f,n.prependListener=f,n.prependOnceListener=f,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}},766:()=>{},911:()=>{},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,h=-1,c=0;c<=u;++c){if(c===u){if(l>u){if(47===t.charCodeAt(a+c))return t.slice(a+c+1);if(0===c)return t.slice(a+c)}else o>u&&(47===e.charCodeAt(r+c)?h=c:0===c&&(h=0));break}var d=e.charCodeAt(r+c);if(d!==t.charCodeAt(a+c))break;47===d&&(h=c)}var p="";for(c=r+h+1;c<=n;++c)c!==n&&47!==e.charCodeAt(c)||(0===p.length?p+="..":p+="/..");return p.length>0?p+t.slice(a+h):(a+=h,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,h=e.length-1,c=0;h>=r;--h)if(47!==(n=e.charCodeAt(h)))-1===l&&(u=!1,l=h+1),46===n?-1===s?s=h:1!==c&&(c=1):-1!==s&&(c=-1);else if(!u){a=h+1;break}return-1===s||-1===l||0===c||1===c&&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}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";r.r(n),r.d(n,{ColorSafeStringify:()=>U,TinyAdvancedRaffle:()=>Zt,TinyAfterScrollWatcher:()=>Et,TinyAnalogClock:()=>mr,TinyArrayPaginator:()=>er,TinyClipboard:()=>jt,TinyColorConverter:()=>Ot,TinyColorValidator:()=>fr,TinyCookieConsent:()=>ir,TinyDayNightCycle:()=>Xt,TinyDomReadyManager:()=>bt,TinyDragDropDetector:()=>ae,TinyDragger:()=>wt,TinyElementObserver:()=>nt,TinyEvents:()=>kt,TinyGamepad:()=>Yt,TinyHtml:()=>gt,TinyI18:()=>ar,TinyIframeEvents:()=>Vt,TinyInventory:()=>rr,TinyInventoryTrader:()=>nr,TinyLevelUp:()=>t,TinyLoadingScreen:()=>dr,TinyLocalStorage:()=>zt,TinyNeedBar:()=>ur,TinyNewWinEvents:()=>Kt,TinyNotifications:()=>vt,TinyNotifyCenter:()=>Y,TinyPromiseQueue:()=>K,TinyRateLimiter:()=>J,TinySimpleDice:()=>cr,TinySmartScroller:()=>_t,TinyTextDiffer:()=>gr,TinyTextRangeEditor:()=>Dt,TinyTextarea:()=>Jt,TinyTimeout:()=>$t,TinyToastNotify:()=>X,UltraRandomMsgGen:()=>Lt,addAiMarkerShortcut:()=>W,areElsCollBottom:()=>Pe,areElsCollLeft:()=>Fe,areElsCollPerfBottom:()=>qe,areElsCollPerfLeft:()=>Ve,areElsCollPerfRight:()=>Ue,areElsCollPerfTop:()=>ze,areElsCollRight:()=>We,areElsCollTop:()=>Be,areElsColliding:()=>Ke,areElsPerfColliding:()=>Je,arraySortPositions:()=>s,asyncReplace:()=>B,backupFile:()=>xe,breakdownDuration:()=>c,calculateMarketcap:()=>H,checkObj:()=>T,clearDirectory:()=>pe,clearDirectoryAsync:()=>De,cloneObjTypeOrder:()=>b,compareMarketcap:()=>$,countObj:()=>p,diffArrayList:()=>o,diffStrings:()=>q,dirExists:()=>me,dirSize:()=>Se,dirSizeAsync:()=>$e,documentIsFullScreen:()=>S,ensureCopyFile:()=>ye,ensureDirectory:()=>de,exitFullScreen:()=>I,extendObjType:()=>y,fetchJson:()=>ie,fetchText:()=>oe,fileExists:()=>fe,fileSize:()=>Te,fileSizeAsync:()=>He,formatBytes:()=>R,formatCustomTimer:()=>l,formatDayTimer:()=>h,formatTimer:()=>u,genFibonacciSeq:()=>O,getAge:()=>j,getElsCollDetails:()=>rt,getElsCollDirDepth:()=>tt,getElsCollOverlap:()=>Xe,getElsCollOverlapPos:()=>Qe,getElsColliding:()=>Ge,getElsPerfColliding:()=>Ye,getElsRelativeCenterOffset:()=>et,getLatestBackupPath:()=>Ae,getPercentage:()=>D,getRectCenter:()=>Ze,getSimplePerc:()=>_,getTimeDuration:()=>a,installWindowHiddenScript:()=>se,isDirEmpty:()=>ge,isDirEmptyAsync:()=>je,isFullScreenMode:()=>A,isJsonObject:()=>f,isScreenFilled:()=>x,listDirs:()=>Ee,listDirsAsync:()=>Oe,listFiles:()=>ve,listFilesAsync:()=>Re,objType:()=>E,offFullScreenChange:()=>k,onFullScreenChange:()=>L,readBase64Blob:()=>Z,readFileBlob:()=>Q,readJsonBlob:()=>ee,readJsonFile:()=>he,renameFileAddPrefixSuffix:()=>Le,renameFileBatch:()=>Ie,renameFileNormalizeCase:()=>ke,renameFilePadNumbers:()=>Ne,renameFileRegex:()=>Me,reorderObjTypeOrder:()=>w,requestFullScreen:()=>C,restoreLatestBackup:()=>Ce,ruleOfThree:()=>N,safeTextTrim:()=>z,saveJsonFile:()=>te,shuffleArray:()=>i,toTitleCase:()=>P,toTitleCaseLowerFirst:()=>F,tryDeleteFile:()=>we,writeJsonFile:()=>ce,writeTextFile:()=>be});var e={};r.r(e),r.d(e,{areElsCollBottom:()=>Pe,areElsCollLeft:()=>Fe,areElsCollPerfBottom:()=>qe,areElsCollPerfLeft:()=>Ve,areElsCollPerfRight:()=>Ue,areElsCollPerfTop:()=>ze,areElsCollRight:()=>We,areElsCollTop:()=>Be,areElsColliding:()=>Ke,areElsPerfColliding:()=>Je,getElsCollDetails:()=>rt,getElsCollDirDepth:()=>tt,getElsCollOverlap:()=>Xe,getElsCollOverlapPos:()=>Qe,getElsColliding:()=>Ge,getElsPerfColliding:()=>Ye,getElsRelativeCenterOffset:()=>et,getRectCenter:()=>Ze});const t=class{constructor(e,t){if("number"!=typeof e||Number.isNaN(e))throw new Error("giveExp must be a valid number");if("number"!=typeof t||Number.isNaN(t))throw new Error("expLevel must be a valid number");this.giveExp=e,this.expLevel=t}createUser(){return{exp:0,level:1,totalExp:0}}validateUser(e){if("number"!=typeof e.exp||Number.isNaN(e.exp))throw new Error("exp must be a valid number");if("number"!=typeof e.level||Number.isNaN(e.level))throw new Error("level must be a valid number");if(e.level<1)throw new Error("level must be at least 1");if("number"!=typeof e.totalExp||Number.isNaN(e.totalExp))throw new Error("totalExp must be a valid number")}isValidUser(e){return!("number"!=typeof e.exp||Number.isNaN(e.exp)||"number"!=typeof e.level||Number.isNaN(e.level)||e.level<1||"number"!=typeof e.totalExp||Number.isNaN(e.totalExp))}getGiveExpBase(){if("number"!=typeof this.giveExp||Number.isNaN(this.giveExp))throw new Error("giveExp must be a valid number");return this.giveExp}getExpLevelBase(){if("number"!=typeof this.expLevel||Number.isNaN(this.expLevel))throw new Error("expLevel must be a valid number");return this.expLevel}expValidator(e){const t=this.getExpLevelBase();this.validateUser(e);let r=0;const n=t*e.level;return e.exp>=n&&(e.level++,r=e.exp-n,e.exp=0,r>0)?this.give(e,r,"extra"):e.exp<1&&e.level>1&&(e.level--,r=Math.abs(e.exp),e.exp=t*e.level,r>0)?this.remove(e,r,"extra"):e}getTotalExp(e){this.validateUser(e);let t=0;for(let r=1;r<=e.level;r++)t+=this.getExpLevelBase()*r;return t+=e.exp,t}expGenerator(e=1){if("number"!=typeof e||Number.isNaN(e))throw new Error("multi must be a valid number");return Math.floor(Math.random()*this.getGiveExpBase())*e}getMissingExp(e){return this.getProgress(e)-e.exp}progress(e){return this.getProgress(e)}getProgress(e){return this.validateUser(e),this.getExpLevelBase()*e.level}set(e,t){if("number"!=typeof t||Number.isNaN(t))throw new Error("value must be a valid number");return e.exp=t,this.expValidator(e),e.totalExp=this.getTotalExp(e),e}give(e,t=0,r="add",n=1){if("number"!=typeof n||Number.isNaN(n))throw new Error("multi must be a valid number");if("number"!=typeof t||Number.isNaN(t))throw new Error("extraExp must be a valid number");if("string"!=typeof r)throw new Error("type must be a valid string");return"add"===r?e.exp+=this.expGenerator(n)+t:"extra"===r&&(e.exp+=t),this.expValidator(e),e.totalExp=this.getTotalExp(e),e}remove(e,t=0,r="add",n=1){if("number"!=typeof n||Number.isNaN(n))throw new Error("multi must be a valid number");if("number"!=typeof t||Number.isNaN(t))throw new Error("extraExp must be a valid number");if("string"!=typeof r)throw new Error("type must be a valid string");return"add"===r?e.exp-=this.expGenerator(n)+t:"extra"===r&&(e.exp-=t),this.expValidator(e),e.totalExp=this.getTotalExp(e),e}};function i(e){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 s(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 a(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 l(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,h={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 c=e;if(i||o||s){const e=new Date(1980,0,1),t=new Date(e.getTime()+1e3*c),r=new Date(e);if(i)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),h.years++;if(o)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),h.months++;if(s)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),h.days++;c=Math.floor((t.getTime()-r.getTime())/1e3)}a&&(h.hours=Math.floor(c/3600),c%=3600),l&&(h.minutes=Math.floor(c/60),c%=60),u&&(h.seconds=c),o&&(h.years,h.months,h.days),i&&(h.years,h.months,h.days),h.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(h.hours):null,l?d(h.minutes):null,u?d(h.seconds):null].filter(e=>null!==e).join(":");return r.replace(/\{years\}/g,String(h.years)).replace(/\{months\}/g,String(h.months)).replace(/\{days\}/g,String(h.days)).replace(/\{hours\}/g,d(h.hours)).replace(/\{minutes\}/g,d(h.minutes)).replace(/\{seconds\}/g,d(h.seconds)).replace(/\{time\}/g,p).replace(/\{total\}/g,String(h.total)).trim()}function u(e){return l(e,"hours","{hours}:{minutes}:{seconds}")}function h(e){return l(e,"days","{days}d {hours}:{minutes}:{seconds}")}function c(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,h={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 c=e;if(n||i||o){const e=new Date(1980,0,1),t=new Date(e.getTime()+c),r=new Date(e);if(n)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),h.years++;if(i)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),h.months++;if(o)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),h.days++;c=t.getTime()-r.getTime()}return s&&(h.hours=Math.floor(c/36e5),c%=36e5),a&&(h.minutes=Math.floor(c/6e4),c%=6e4),l&&(h.seconds=Math.floor(c/1e3),c%=1e3),u&&(h.milliseconds=c),i&&(h.years,h.months,h.days),n&&(h.years,h.months,h.days),h.total=+e,h}var d=r(287);function p(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 m="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)]]),m||y([["buffer",e=>void 0!==d.hp&&d.hp.isBuffer(e)]]),m&&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]]),m&&y([["htmlelement",e=>"undefined"!=typeof HTMLElement&&e instanceof HTMLElement]]),y([["object",e=>f(e)]]);const S=()=>!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitIsFullScreen||document.mozFullScreen),x=()=>window.innerHeight===screen.height&&window.innerWidth===screen.width,A=()=>S()||x(),C=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)}}),M=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],L=(e,t)=>{M.forEach(r=>{document.addEventListener(r,e,t)})},k=(e,t)=>{M.forEach(r=>{document.removeEventListener(r,e,t)})};function N(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 O({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 H(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=H(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 P(e){return e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase())}function F(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 z(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:"[0m",key:"[36m",string:"[32m",string_url:"[34m",string_bool:"[35m",string_number:"[33m",number:"[33m",boolean:"[35m",null:"[1;30m",special:"[31m",func:"[90m"},solarized:{reset:"[0m",key:"[38;5;37m",string:"[38;5;136m",string_url:"[38;5;33m",string_bool:"[38;5;166m",string_number:"[38;5;136m",number:"[38;5;136m",boolean:"[38;5;166m",null:"[38;5;241m",special:"[38;5;160m",func:"[38;5;244m"},monokai:{reset:"[0m",key:"[38;5;81m",string:"[38;5;114m",string_url:"[38;5;75m",string_bool:"[38;5;204m",string_number:"[38;5;221m",number:"[38;5;221m",boolean:"[38;5;204m",null:"[38;5;241m",special:"[38;5;160m",func:"[38;5;102m"}};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 U=V,K=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}},J=class{#h=null;#c=null;#d=null;#p=null;#f=null;#m=null;groupData=new Map;lastSeen=new Map;userToGroup=new Map;groupFlags=new Map;groupTTL=new Map;#g=null;setOnMemoryExceeded(e){if("function"!=typeof e)throw new Error("onMemoryExceeded must be a function");this.#g=e}clearOnMemoryExceeded(){this.#g=null}#y=null;setOnGroupExpired(e){if("function"!=typeof e)throw new Error("onGroupExpired must be a function");this.#y=e}clearOnGroupExpired(){this.#y=null}constructor({maxHits:e,interval:t,cleanupInterval:r,maxIdle:n=3e5,maxMemory:i=1e5}){const o=e=>"number"==typeof e&&Number.isFinite(e)&&e>=1&&Number.isInteger(e),s=o(e),a=o(t),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.#h=Math.floor(i);else{if(null!=i)throw new Error("maxMemory must be a positive number or null");this.#h=null}this.#d=s?e:null,this.#p=a?t:null,this.#f=l?r:null,this.#m=n,null!==this.#f&&(this.#c=setInterval(()=>this._cleanup(),this.#f))}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.#h&&"number"==typeof this.#h&&n.length>this.#h&&(n.splice(0,n.length-this.#h),"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.#m||!Number.isFinite(this.#m)||this.#m<0)throw new Error("'maxIdle' must be a non-negative finite number.");return this.#m}setMaxIdle(e){if("number"!=typeof e||!Number.isFinite(e)||e<0)throw new Error("'maxIdle' must be a non-negative finite number.");this.#m=e}_cleanup(){const e=Date.now();for(const[t,r]of this.lastSeen.entries())e-r>(this.getGroupTTL(t)??this.getMaxIdle())&&(this.groupFlags.delete(t),this.groupData.delete(t),this.lastSeen.delete(t),this.groupTTL.delete(t),"function"==typeof this.#y&&this.#y(t))}getActiveGroups(){return Array.from(this.groupData.keys())}getAllUserMappings(){return Object.fromEntries(this.userToGroup)}getInterval(){if("number"!=typeof this.#p||!Number.isFinite(this.#p))throw new Error("'interval' is not a valid finite number.");return this.#p}getMaxHits(){if("number"!=typeof this.#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.#c&&clearInterval(this.#c),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;#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)}#L(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.#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.#L(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="×",u.addEventListener("click",e=>{e.stopPropagation(),this.#M(r)}),r.append(a,u),this.#b.prepend(r),this.#I.set(r,t),this.#L(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.#L(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{#k;#N;#_;#D;#j;#R;constructor(e="top",t="right",r=3e3,n=50,i=300,o=".notify-container"){this.#O(e),this.#H(t),this.#$(r,"baseDuration"),this.#$(n,"extraPerChar"),this.#$(i,"fadeOutDuration"),this.#k=e,this.#N=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}#O(e){if(!["top","bottom"].includes(e))throw new Error(`Invalid vertical direction "${e}". Expected "top" or "bottom".`)}#H(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.#k}setY(e){this.#O(e);const t=this.getContainer();t.classList.remove(this.#k),t.classList.add(e),this.#k=e}getX(){return this.#N}setX(e){this.#H(e);const t=this.getContainer();t.classList.remove(this.#N),t.classList.add(e),this.#N=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="×",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 h=()=>{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,h)}),a.addEventListener("click",e=>{e.stopPropagation(),h()}),setTimeout(()=>{s.classList.remove("enter"),s.classList.add("show")},1),setTimeout(()=>h(),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 h=0;h<l;h++){const l=s?null:new AbortController,c=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?f(r)?JSON.stringify(r):r:void 0,signal:c});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;h<i&&await new Promise(e=>setTimeout(e,300*(h+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)&&!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)=>{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"],h=["hidden","mozHidden","webkitHidden","msHidden"];for(let e=0;e<h.length;e++)if(h[e]in document){l=h[e];break}const c=function(u){a();const h=u?.type,c=l&&document[l];["focus","focusin","pageshow"].includes(h)?(e.classList.add(r),n?.({type:h,oldClass:s,oldType:o}),s=r):["blur","focusout","pagehide"].includes(h)||c?(e.classList.add(t),i?.({type:h,oldClass:s,oldType:o}),s=t):(e.classList.add(r),n?.({type:h,oldClass:s,oldType:o}),s=r),o=h};let d=()=>{};if(l){const e=u[h.indexOf(l)];document.addEventListener(e,c),window.addEventListener("focus",c),window.addEventListener("blur",c),d=()=>{document.removeEventListener(e,c),window.removeEventListener("focus",c),window.removeEventListener("blur",c),a()}}else"onfocusin"in document?(document.onfocusin=document.onfocusout=c,d=()=>{document.onfocusin=document.onfocusout=null,a()}):(window.onpageshow=window.onpagehide=window.onfocus=window.onblur=c,d=()=>{window.onpageshow=window.onpagehide=window.onfocus=window.onblur=null,a()});const p=new Event(l&&document[l]?"blur":"focus");return c(p),d}const ae=class{#B;#P;#F;#W;#z;#q;#V;#U;constructor(e={}){const{target:t,fullscreen:r=!0,hoverClass:n="dnd-hover",onDrop:i,onEnter:o,onLeave:s}=e;if("boolean"!=typeof r)throw new TypeError('The "fullscreen" option must be a boolean.');const a=r?document.body:t||document.body;if(!(a instanceof HTMLElement))throw new TypeError('The "target" option must be an instance of HTMLElement.');if("string"!=typeof n)throw new TypeError('The "hoverClass" option must be a string.');if("function"!=typeof i)throw new TypeError('The "onDrop" option must be a function.');if("function"!=typeof o)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.#B=a,this.#P=r,this.#F=n,this.#W=i||(()=>{}),this.#z=o,this.#q=s,this.#V=!1,this.#U=!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.#B}getHoverClass(){return this.#F}isFullScreen(){return this.#P}isDragging(){return this.#V}bound(){return this.#U}#K(){if(this.#U)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.#U=!0}#J(){if(!this.#U)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.#U=!1}_handleDragEnter(e){if(e.preventDefault(),!this.#V){const t=this.getTarget();this.#V=!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.#V=!1,t.classList.remove(this.#F),this.#q(e))}_handleDrop(e){if(e.preventDefault(),!e.dataTransfer)return void console.warn("[TinyDragDropDetector] [handleDrop] DragOver event missing dataTransfer.");const t=this.getTarget();this.#V=!1,t.classList.remove(this.#F);const r=e.dataTransfer.files;r.length>0&&this.#W(r,e)}destroy(){this.#J(),this.getTarget().classList.remove(this.#F)}};var le=r(133),ue=r(975);function he(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 ce(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 pe(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 fe(e){return(0,le.existsSync)(e)&&(0,le.lstatSync)(e).isFile()}function me(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!!fe(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(!me(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(!me(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 fe(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"){fe(e)&&ye(e,`${e}.${t}.${(new Date).toISOString().replace(/[:.]/g,"-")}`)}function Ae(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 Ce(e,t="bak"){ye(Ae(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 Me(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 Le(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 ke(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?P(e):e,i=(0,ue.extname)(e),o=n?r(i):i;return`${r((0,ue.basename)(e,i))}${o}`},r)}function Ne(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(!me(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 Oe(e,t=!1){const r=[];if(!me(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 Oe(n,!0)))}return r}async function He(e){return fe(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=He(e);r.then(e=>(t+=e,e)),n.push(r)}return await Promise.all(n),t}const Be=(e,t)=>e.bottom<t.top,Pe=(e,t)=>e.top>t.bottom,Fe=(e,t)=>e.right<t.left,We=(e,t)=>e.left>t.right,ze=(e,t)=>e.bottom<=t.top,qe=(e,t)=>e.top>=t.bottom,Ve=(e,t)=>e.right<=t.left,Ue=(e,t)=>e.left>=t.right,Ke=(e,t)=>!(Fe(e,t)||We(e,t)||Be(e,t)||Pe(e,t)),Je=(e,t)=>!(Ve(e,t)||Ue(e,t)||ze(e,t)||qe(e,t)),Ge=(e,t)=>Fe(e,t)?"left":We(e,t)?"right":Be(e,t)?"top":Pe(e,t)?"bottom":null,Ye=(e,t)=>Ve(e,t)?"left":Ue(e,t)?"right":ze(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(!Je(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 h;return h=l<u?s:a,{inDir:h,dirX:s,dirY:a,depthX:l,depthY:u}}function rt(e,t){const r=Je(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 h=Object.entries(o).filter(([,e])=>e>0).sort((e,t)=>e[1]-t[1]),{dirX:c,dirY:d}=Qe({overlapLeft:a,overlapRight:s,overlapTop:u,overlapBottom:l});return n.y=d,n.x=c,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":h.length?h[0][0]:"top":null,{dirs:n,depth:o,isNeg:i}}const nt=class{#G;get el(){return this.#G}set el(e){if(this.#G)throw new Error("The observed element has already been set and cannot be reassigned.");if(void 0!==e&&!(e instanceof Element))throw new TypeError("The observed element must be a valid DOM Element.");this.#G=e}#Y={};get settings(){return this.#Y}set settings(e){if("object"!=typeof e||null===e)throw new TypeError("settings must be a non-null object.");this.#Y=e}#X=null;get observer(){return this.#X}#Q=[];get detectors(){return this.#Q.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.#Q=t}get isActive(){return!!this.#X}get size(){return this.#Q.length}constructor({el:e,initDetectors:t=[],initCfg:r={}}={}){this.el=e,t.length&&(this.detectors=t),r&&(this.settings=r)}clear(){this.#Q=[]}start(){if(!this.#G)throw new Error("Cannot start observation: no target element has been set.");this.#X||(this.#X=new MutationObserver(e=>{e.forEach((e,t,r)=>this.#Q.forEach(n=>n[1](e,t,r)))}),this.#X.observe(this.#G,this.#Y))}stop(){this.#X&&(this.#X.disconnect(),this.#X=null)}add(e,t){this.#Z(e,t),this.#Q.push([e,t])}insertAtStart(e,t){this.#Z(e,t),this.#Q.unshift([e,t])}insertAt(e,t,r,n="after"){if(this.#Z(t,r),"number"!=typeof e||e<0||e>=this.#Q.length)throw new RangeError("Invalid index for insertDetectorAt.");const i="before"===n?e:e+1;this.#Q.splice(i,0,[t,r])}removeAt(e){if("number"!=typeof e||e<0||e>=this.#Q.length)throw new RangeError("Invalid index for removeDetectorAt.");this.#Q.splice(e,1)}removeAround(e,t=0,r=0){if("number"!=typeof e||e<0||e>=this.#Q.length)throw new RangeError("Invalid index for removeDetectorsAround.");const n=Math.max(0,e-t),i=t+1+r;this.#Q.splice(n,i)}isIndexUsed(e){return e>=0&&e<this.#Q.length}hasHandler(e){if("function"!=typeof e)throw new TypeError("Handler must be a function.");return this.#Q.some(([t,r])=>r===e)}#Z(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()}},{areElsColliding:it,areElsPerfColliding:ot,areElsCollTop:st,areElsCollBottom:at,areElsCollLeft:lt,areElsCollRight:ut}=e,ht=new WeakMap,ct=new WeakMap,dt=new WeakMap,pt=new WeakMap,ft={top:new WeakMap,bottom:new WeakMap,left:new WeakMap,right:new WeakMap};class mt{static Utils={...e};static#ee=1;static get version(){return this.#ee}static#te=!1;static get elemDebug(){return mt.#te}static set elemDebug(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean value for elemDebug");mt.#te=e}static _debugElemError(e,t){if(!mt.#te)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,mt._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#re=!0;static get autoStartElemObserver(){return mt.#re}static set autoStartElemObserver(e){if("boolean"!=typeof e)throw new TypeError("autoStartElemObserver must be a boolean.");mt.#re=e}static#ne=new nt({el:"undefined"!=typeof window&&void 0!==window.document?window.document.documentElement:void 0,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(mt.parseStyle(t),mt.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"]}});static get tinyObserver(){return mt.#ne}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 mt.htmlToJson(i)}static async fetchHtmlNodes(e,t){const r=await mt.fetchHtmlFile(e,t);return mt.jsonToNodes(r)}static async fetchHtmlTinyElems(e,t){const r=await mt.fetchHtmlNodes(e,t);return mt.toTinyElm(r)}static templateToJson(e){return mt.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 mt.toTinyElm(mt.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[mt.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(mt.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 mt.toTinyElm(mt.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=mt.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 mt(document.createElement(e,t))}static createTextNode(e){if("string"!=typeof e)throw new TypeError("[TinyHtml] createTextNode(): The value must be a string.");return new mt(document.createTextNode(e))}static createElementFromHTML(e){const t=document.createElement("template");if(!(e=e.trim()).startsWith("<"))return mt.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 mt(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 mt(r)}static createFromHtml(e){return mt.createFromHTML(e)}static query(e,t=document){const r=t.querySelector(e);return r?new mt(r):null}querySelector(e){return mt.query(e,mt._preElem(this,"query"))}static queryAll(e,t=document){return new mt(t.querySelectorAll(e))}querySelectorAll(e){return mt.queryAll(e,mt._preElem(this,"queryAll"))}static getById(e){const t=document.getElementById(e);return t?new mt(t):null}static getByClassName(e,t=document){return new mt(t.getElementsByClassName(e))}getElementsByClassName(e){return mt.getByClassName(e,mt._preElem(this,"getByClassName"))}static getByName(e){return new mt(document.getElementsByName(e))}static getByTagNameNS(e,t="http://www.w3.org/1999/xhtml",r=document){return new mt(r.getElementsByTagNameNS(t,e))}getElementsByTagNameNS(e,t="http://www.w3.org/1999/xhtml"){return mt.getByTagNameNS(e,t,mt._preElem(this,"getByTagNameNS"))}get elements(){return[...this.#G]}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.#G[e])throw new Error(`No element found at index ${e}.`);return this.#G[e]}extract(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");if(!this.#G[e])throw new Error(`Cannot extract: no element exists at index ${e}.`);return new mt(this.#G[e])}exists(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");return!!this.#G[e]}getAll(){return[...this.#G]}_getElement(e,t){if(!(this.#G[t]instanceof Element||this.#G[t]instanceof Window||this.#G[t]instanceof Document||this.#G[t]instanceof Text))throw mt._debugElemError([...this.#G],this.#G[t]),new Error(`[TinyHtml] Invalid Element in ${e}().`);return this.#G[t]}_getElements(e){if(!this.#G.every(e=>e instanceof Element||e instanceof Window||e instanceof Document||e instanceof Text))throw mt._debugElemError([...this.#G]),new Error(`[TinyHtml] Invalid Element in ${e}().`);return[...this.#G]}static _preElemsTemplate(e,t,r,n){const i=e=>{const i=[];return e.map(o=>(o instanceof mt?o._getElements(t):[o]).map(o=>{let s=!1;for(const e of r)if(o instanceof e){s=!0;break}if(!s)throw mt._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 mt._preElemsTemplate(this,e,t,r)}static _preElemTemplate(e,t,r,n,i=!1){const o=e=>{const o=e[0],s=o instanceof mt?o._getElements(t):[o];if(s.length>1)throw mt._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 mt._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 mt._debugElemError([...e]),new Error(`[TinyHtml] Invalid element amount in ${t}() (Received ${e.length}/1).`);return o(e)}_preElemTemplate(e,t,r,n=!1){return mt._preElemTemplate(this,e,t,r,n)}static _preElems(e,t){return mt._preElemsTemplate(e,t,[Element],["Element"])}_preElems(e){return mt._preElems(this,e)}static _preElem(e,t){return mt._preElemTemplate(e,t,[Element],["Element"])}_preElem(e){return mt._preElem(this,e)}static _preNodeElems(e,t){return mt._preElemsTemplate(e,t,[Node],["Node"])}_preNodeElems(e){return mt._preNodeElems(this,e)}static _preNodeElem(e,t){return mt._preElemTemplate(e,t,[Node],["Node"])}_preNodeElem(e){return mt._preNodeElem(this,e)}static _preNodeElemWithNull(e,t){return mt._preElemTemplate(e,t,[Node],["Node"],!0)}_preNodeElemWithNull(e){return mt._preNodeElemWithNull(this,e)}static _preHtmlElems(e,t){return mt._preElemsTemplate(e,t,[HTMLElement],["HTMLElement"])}_preHtmlElems(e){return mt._preHtmlElems(this,e)}static _preHtmlElem(e,t){return mt._preElemTemplate(e,t,[HTMLElement],["HTMLElement"])}_preHtmlElem(e){return mt._preHtmlElem(this,e)}static _preInputElems(e,t){return mt._preElemsTemplate(e,t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElems(e){return mt._preInputElems(this,e)}static _preInputElem(e,t){return mt._preElemTemplate(e,t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElem(e){return mt._preInputElem(this,e)}static _preEventTargetElems(e,t){return mt._preElemsTemplate(e,t,[EventTarget],["EventTarget"])}_preEventTargetElems(e){return mt._preEventTargetElems(this,e)}static _preEventTargetElem(e,t){return mt._preElemTemplate(e,t,[EventTarget],["EventTarget"])}_preEventTargetElem(e){return mt._preEventTargetElem(this,e)}static _preElemsAndWindow(e,t){return mt._preElemsTemplate(e,t,[Element,Window],["Element","Window"])}_preElemsAndWindow(e){return mt._preElemsAndWindow(this,e)}static _preElemAndWindow(e,t){return mt._preElemTemplate(e,t,[Element,Window],["Element","Window"])}_preElemAndWindow(e){return mt._preElemAndWindow(this,e)}static _preElemsAndWinAndDoc(e,t){return mt._preElemsTemplate(e,t,[Element,Window,Document],["Element","Window","Document"]).map(e=>e instanceof Document?e.documentElement:e)}_preElemsAndWinAndDoc(e){return mt._preElemsAndWinAndDoc(this,e)}static _preElemAndWinAndDoc(e,t){const r=mt._preElemTemplate(e,t,[Element,Window,Document],["Element","Window","Document"]);return r instanceof Document?r.documentElement:r}_preElemAndWinAndDoc(e){return mt._preElemAndWinAndDoc(this,e)}static _preElemsWithDoc(e,t){return mt._preElemsTemplate(e,t,[Element,Document],["Element","Document"])}_preElemsWithDoc(e){return mt._preElemsWithDoc(this,e)}static _preElemWithDoc(e,t){return mt._preElemTemplate(e,t,[Element,Document],["Element","Document"])}_preElemWithDoc(e){return mt._preElemWithDoc(this,e)}static toTinyElm(e){const t=e=>e.map(e=>e instanceof mt?e:new mt(e));return Array.isArray(e)?t(e):t([e])}static fromTinyElm(e){const t=e=>{const t=[];return e.map(e=>(e instanceof mt?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 mt._preElems(e,r).filter((e,r)=>!!t.call(e,r,e)!==n);if(t instanceof Element)return mt._preElems(e,r).filter(e=>e===t!==n);if(Array.isArray(t)||"string"!=typeof t&&null!=t.length)return mt._preElems(e,r).filter(e=>t.includes(e)!==n);let i=t;return n&&(i=`:not(${i})`),mt._preElems(e,r).filter(e=>1===e.nodeType&&e.matches(i))}static filter(e,t,r=!1){return r&&(t=`:not(${t})`),mt._preElems(e,"filter").filter(e=>1===e.nodeType&&e.matches(t))}static filterOnly(e,t){return mt.winnow(e,t,"filterOnly",!1)}static not(e,t){return mt.winnow(e,t,"not",!0)}not(e){return mt.not(this,e)}static find(e,t){const r=[];for(const n of mt._preElems(e,"find"))r.push(...n.querySelectorAll(t));return[...new Set(r)]}find(e){return mt.find(this,e)}static is(e,t){return mt.winnow(e,t,"is",!1).length>0}is(e){return mt.is(this,e)}static has(e,t){const r="string"==typeof t?[...document.querySelectorAll(t)]:mt._preElems(t,"has");return mt._preElems(e,"has").filter(e=>r.some(t=>e&&e.contains(t)))}has(e){return mt.has(this,e)}static closest(e,t,r){const n=[];for(const i of mt._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 mt.closest(this,e,t)}static isSameDom(e,t){return mt._preNodeElem(e,"isSameDom")===mt._preNodeElem(t,"isSameDom")}isSameDom(e){return mt.isSameDom(this,e)}#ie={};get _data(){return{...this.#ie}}set _data(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new Error("value must be a non-null object.");this.#ie=e}static _dataSelector={public:(e,t)=>{const r=mt._preElem(t,e);let n=ct.get(r);return n||(n={},ct.set(r,n)),n},private:(e,t)=>{if(!(t instanceof mt))throw new Error(`Element must be a TinyHtml instance to execute ${e}().`);return t.#ie}};static data(e,t,r=!1){const n=mt._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 mt.data(this,e,t)}static setData(e,t,r,n=!1){const i=mt._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:mt.removeData(e,t),e}setData(e,t,r=!1){return mt.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=mt._dataSelector[r?"private":"public"]("hasData",e);return Object.prototype.hasOwnProperty.call(n,t)}hasData(e,t=!1){return mt.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 mt._dataSelector[r?"private":"public"]("removeData",e)[t]}removeData(e,t=!1){return mt.removeData(this,e,t)}static _getSibling(e,t,r){let n=mt._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=mt._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=mt._preNodeElemWithNull(e,"parent");const r=t?t.parentNode:null;return r&&11!==r.nodeType?r:null}parent(){return mt.parent(this)}static parents(e,t){return mt.domDir(e,"parentNode",t,"parents")}parents(e){return mt.parents(this,e)}static next(e){return mt._getSibling(e,"nextSibling","next")}next(){return mt.next(this)}static prev(e){return mt._getSibling(e,"previousSibling","prev")}prev(){return mt.prev(this)}static nextAll(e){return mt.domDir(e,"nextSibling",void 0,"nextAll")}nextAll(){return mt.nextAll(this)}static prevAll(e){return mt.domDir(e,"previousSibling",void 0,"prevAll")}prevAll(){return mt.prevAll(this)}static nextUntil(e,t){return mt.domDir(e,"nextSibling",t,"nextUtil")}nextUntil(e){return mt.nextUntil(this,e)}static prevUntil(e,t){return mt.domDir(e,"previousSibling",t,"prevUtil")}prevUntil(e){return mt.prevUntil(this,e)}static siblings(e){const t=mt._preNodeElemWithNull(e,"siblings");return mt._getSiblings(t&&t.parentNode?t.parentNode.firstChild:null,t)}siblings(){return mt.siblings(this)}static children(e){const t=mt._preNodeElemWithNull(e,"children");return mt._getSiblings(t?t.firstChild:null)}children(){return mt.children(this)}static contents(e){const t=mt._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 mt.contents(this)}static clone(e,t=!0){if("boolean"!=typeof t)throw new TypeError('The "deep" must be a boolean.');return mt._preNodeElems(e,"clone").map(e=>e.cloneNode(t))}clone(e){return mt.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 mt)r.push(...mt._preNodeElems(n,e));else if(Array.isArray(n))r.push(...mt._appendChecker(e,...n));else for(const t in n){const i=n[t];r.push(...mt._appendChecker(e,i))}else r.push(n);return r}static append(e,...t){return mt._preElem(e,"append").append(...mt._appendChecker("append",...t)),e}append(...e){return mt.append(this,...e)}static prepend(e,...t){return mt._preElem(e,"prepend").prepend(...mt._appendChecker("prepend",...t)),e}prepend(...e){return mt.prepend(this,...e)}static before(e,...t){return mt._preElem(e,"before").before(...mt._appendChecker("before",...t)),e}before(...e){return mt.before(this,...e)}static after(e,...t){return mt._preElem(e,"after").after(...mt._appendChecker("after",...t)),e}after(...e){return mt.after(this,...e)}static replaceWith(e,...t){return mt._preElem(e,"replaceWith").replaceWith(...mt._appendChecker("replaceWith",...t)),e}replaceWith(...e){return mt.replaceWith(this,...e)}static appendTo(e,t){const r=mt._preNodeElems(e,"appendTo"),n=mt._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 mt.appendTo(this,e)}static prependTo(e,t){const r=mt._preElems(e,"prependTo"),n=mt._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 mt.prependTo(this,e)}static insertBefore(e,t,r=null){const n=mt._preNodeElem(e,"insertBefore"),i=mt._preNodeElem(t,"insertBefore"),o=mt._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 mt.insertBefore(this,e,t)}static insertAfter(e,t,r=null){const n=mt._preNodeElem(e,"insertAfter"),i=mt._preNodeElem(t,"insertBefore"),o=mt._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 mt.insertAfter(this,e,t)}static replaceAll(e,t){const r=mt._preNodeElems(e,"replaceAll"),n=mt._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 mt.replaceAll(this,e)}#G;get size(){return this.#G.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 mt([...this.#G,...mt._selector(e)])}static _selector(e){if(e instanceof mt)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 mt._elCheck(r),t(r);if(r instanceof NodeList||r instanceof HTMLCollection){const e=[...r];return mt._elCheck(e),t(e)}{const e=[r];return mt._elCheck(e),t(e)}}constructor(e){this.#G=mt._selector(e),this.#oe=mt.#se}static isWindow(e){return null!=e&&e===e.window}static css(e){const t=mt._preElem(e,"css");return window.getComputedStyle(t)}css(){return mt.css(this)}static cssString(e,t){const r=mt._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 mt.cssString(this,e)}static cssList(e,t){const r=mt._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 mt.cssList(this,e)}static cssFloat(e,t){const r=mt._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 mt.cssFloat(this,e)}static cssFloats(e,t){const r=mt._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 mt.cssFloats(this,e)}static#ae={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(mt.#ae,{set:(e,t,r)=>(e[t]=r,mt.cssPropRevAliases[r]=t,!0)});static cssPropRevAliases=Object.fromEntries(Object.entries(mt.#ae).map(([e,t])=>[t,e]));static toStyleKc(e){return"string"==typeof mt.cssPropAliases[e]?mt.cssPropAliases[e]:e}static toStyleCc(e){return"string"==typeof mt.cssPropRevAliases[e]?mt.cssPropRevAliases[e]:e}static setStyle(e,t,r=null){return mt._preHtmlElems(e,"setStyle").forEach(e=>{if("object"==typeof t)for(const[r,n]of Object.entries(t))e.style.setProperty(mt.toStyleKc(r),"string"==typeof n?n:"number"==typeof n?`${n}px`:String(n));else e.style.setProperty(mt.toStyleKc(t),r)}),e}setStyle(e,t){return mt.setStyle(this,e,t)}static getStyle(e,t){return mt._preHtmlElem(e,"getStyle").style.getPropertyValue(mt.toStyleKc(t))}getStyle(e){return mt.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=mt._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?mt.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?mt.toStyleCc(n):n]=o}}return i}style(e){return mt.style(this,e)}static removeStyle(e,t){return mt._preHtmlElems(e,"removeStyle").forEach(e=>{if(Array.isArray(t))for(const r of t)e.style.removeProperty(mt.toStyleKc(r));else e.style.removeProperty(mt.toStyleKc(t))}),e}removeStyle(e){return mt.removeStyle(this,e)}static toggleStyle(e,t,r,n){return mt._preHtmlElems(e,"toggleStyle").forEach(e=>{const i=mt.getStyle(e,t).trim()===mt.toStyleKc(r)?n:r;mt.setStyle(e,t,i)}),e}toggleStyle(e,t,r){return mt.toggleStyle(this,e,t,r)}static clearStyle(e){return mt._preElems(e,"clearStyle").forEach(e=>e.removeAttribute("style")),e}clearStyle(){return mt.clearStyle(this)}static focus(e){return mt._preHtmlElem(e,"focus").focus(),e}focus(){return mt.focus(this)}static blur(e){return mt._preHtmlElem(e,"blur").blur(),e}blur(){return mt.blur(this)}static select(e){const t=mt._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 mt.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.");mt.setScrollTop(window,e)}static setWinScrollLeft(e){if("number"!=typeof e)throw new TypeError("The value must be a number.");mt.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=mt._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(mt.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?mt.cssFloat(o,e+"Left")+mt.cssFloat(o,e+"Right"):mt.cssFloat(o,e+"Top")+mt.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 mt.getDimension(this,e,t)}static setHeight(e,t){const r=mt._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 mt.setHeight(this,e)}set height(e){mt.setHeight(this,e)}static setWidth(e,t){const r=mt._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 mt.setWidth(this,e)}set width(e){mt.setWidth(this,e)}static height(e){const t=mt._preElemAndWinAndDoc(e,"height");return mt.getDimension(t,"height","content")}get height(){return mt.height(this)}static width(e){const t=mt._preElemAndWinAndDoc(e,"width");return mt.getDimension(t,"width","content")}get width(){return mt.width(this)}static innerHeight(e){const t=mt._preElemAndWinAndDoc(e,"innerHeight");return mt.getDimension(t,"height","padding")}innerHeight(){return mt.innerHeight(this)}static innerWidth(e){const t=mt._preElemAndWinAndDoc(e,"innerWidth");return mt.getDimension(t,"width","padding")}innerWidth(){return mt.innerWidth(this)}static outerHeight(e,t=!1){if("boolean"!=typeof t)throw new TypeError('The "includeMargin" must be a boolean.');const r=mt._preElemAndWinAndDoc(e,"outerHeight");return mt.getDimension(r,"height",t?"margin":"border")}outerHeight(e){return mt.outerHeight(this,e)}static outerWidth(e,t=!1){if("boolean"!=typeof t)throw new TypeError('The "includeMargin" must be a boolean.');const r=mt._preElemAndWinAndDoc(e,"outerWidth");return mt.getDimension(r,"width",t?"margin":"border")}outerWidth(e){return mt.outerWidth(this,e)}#oe="";get mainDisplay(){return this.#oe}set mainDisplay(e){if("string"!=typeof e)throw new TypeError("mainDisplay must be a string.");this.#oe=e}static#se="block";static get defaultDisplay(){return mt.#se}static set defaultDisplay(e){if("string"!=typeof e)throw new TypeError("defaultDisplay must be a string.");mt.#se=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#le=!0;static get cancelOldStyleFx(){return mt.#le}static set cancelOldStyleFx(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean value.");mt.#le=e}static#ue={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 mt.#ue){const r=mt.#ue[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.`);mt.#ue={};for(const[t,r]of Object.entries(e))mt.setStyleFxSpeed(t,r)}static getStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');const t=mt.#ue[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");mt.#ue[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 mt.#ue[e]}static hasStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(mt.#ue,e)}static#he=["Top","Right","Bottom","Left"];static#ce={slideDown:mt.genStyleFx("show"),slideUp:mt.genStyleFx("hide"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}};static get styleEffects(){return JSON.parse(JSON.stringify(mt.#ce))}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}"]`);mt.#ce={};for(const t in e)mt.setStyleEffect(t,e[t])}static getStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');const t=mt.#ce[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]}mt.#ce[e]=r}static deleteStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete mt.#ce[e]}static hasStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(mt.#ce,e)}static#de={slideDown:"slideUp",slideUp:"slideDown",fadeIn:"fadeOut",fadeOut:"fadeIn",fadeTo:"fadeIn"};static get styleEffectInverse(){return{...mt.#de}}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.`);mt.#de={};for(const[t,r]of Object.entries(e))mt.setStyleEffectInverse(t,r)}static getStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return mt.#de[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.`);mt.#de[e]=t}static deleteStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete mt.#de[e]}static hasStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(mt.#de,e)}static#pe={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{...mt.#pe}}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.`);mt.#pe={};for(const[t,r]of Object.entries(e))mt.setStyleEffectRd(t,r)}static getStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return mt.#pe[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.`);mt.#pe[e]=t}static deleteStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete mt.#pe[e]}static hasStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(mt.#pe,e)}static#fe={show:(e,t,r,n)=>{if("height"===r||"width"===r){const i=mt.getAnimateData(e,`orig${r}`)||e.scrollHeight+"px";mt.setAnimateData(e,`orig${r}`,i);const o=n[r];t[r]=[o,i]}else if(r.startsWith("margin")||r.startsWith("padding")){const i=mt.getAnimateData(e,r)||n[r];mt.setAnimateData(e,r,i),t[r]=["0px",i]}else if("opacity"===r){const e=n.opacity;t[r]=[e,1]}else{const i=mt.getAnimateData(e,r)||n[r];mt.setAnimateData(e,r,i),t[r]=[i,n[r]||1]}},hide:(e,t,r,n)=>{if("height"===r||"width"===r){const i=mt.getAnimateData(e,`orig${r}`)||n[r];mt.setAnimateData(e,`orig${r}`,i);const o=n[r];t[r]=[o,0]}else if(r.startsWith("margin")||r.startsWith("padding")){const i=mt.getAnimateData(e,r)||n[r];mt.setAnimateData(e,r,i),t[r]=[n[r],"0px"]}else if("opacity"===r){const e=n.opacity;t[r]=[e,0]}else{const i=mt.getAnimateData(e,r)||n[r];mt.setAnimateData(e,r,i),t[r]=[i,0]}}};static get styleEffectsProps(){return{...mt.#fe}}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`);mt.#fe={};for(const[t,r]of Object.entries(e))mt.setStyleEffectProp(t,r)}static getStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return mt.#fe[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`);mt.#fe[e]=t}static deleteStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete mt.#fe[e]}static hasStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(mt.#fe,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=mt.#he[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 mt._preHtmlElems(e,"applyStyleFx").forEach(o=>{const s={};for(const[e,t]of Object.entries(r))if("string"==typeof t&&this.#fe[t]){const r=getComputedStyle(o);this.#fe[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 mt.#pe[t]&&mt.#pe[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,mt.animate(e,a,n,t)[0])}),i}applyStyleFx(e,t,r){return mt.applyStyleFx(this,e,t,r)}static getCurrentAnimationId(e){if(!(e instanceof HTMLElement))throw new TypeError("Expected an HTMLElement.");return pt.get(e)?.id??void 0}static animate(e,t,r=mt.#ue._default,n=null,i=mt.#le){const o="string"==typeof r?mt.#ue[r]??void 0:"number"!=typeof r?{...r}:r;"object"==typeof o&&void 0===o.fill&&(o.fill="forwards");const s=[];return mt._preHtmlElems(e,"animate").forEach(e=>{if(i){const t=pt.get(e);t&&t.animation.cancel()}const r=e.animate(t,o);s.push(r),pt.set(e,{animation:r,id:n??""}),r.addEventListener("finish",()=>{pt.get(e)?.animation===r&&pt.delete(e)})}),s}animate(e,t,r,n){return mt.animate(this,e,t,r,n)}static stop(e){const t=[];return mt._preHtmlElems(e,"stop").forEach(e=>{const r=pt.get(e);r?(r.animation.cancel(),pt.delete(e),t.push(!0)):t.push(!1)}),t}stop(){return mt.stop(this)}static slideDown(e,t){return mt.applyStyleFx(e,"slideDown",this.#ce.slideDown,t??{duration:500,easing:"ease-out"})}slideDown(e){return mt.slideDown(this,e)}static slideUp(e,t){return mt.applyStyleFx(e,"slideUp",this.#ce.slideUp,t??{duration:500,easing:"ease-out"})}slideUp(e){return mt.slideUp(this,e)}static slideToggle(e,t){const r=mt._preHtmlElem(e,"slideToggle"),n=getComputedStyle(r),i=mt.getCurrentAnimationId(r),o="none"===n.display||0===r.offsetHeight;return("string"==typeof i?"slideUp"===i:o)?mt.slideDown(e,t):mt.slideUp(e,t)}slideToggle(e){return mt.slideToggle(this,e)}static fadeIn(e,t){return mt.applyStyleFx(e,"fadeIn",this.#ce.fadeIn,t)}fadeIn(e){return mt.fadeIn(this,e)}static fadeOut(e,t){return mt.applyStyleFx(e,"fadeOut",this.#ce.fadeOut,t)}fadeOut(e){return mt.fadeOut(this,e)}static fadeToggle(e,t){const r=mt._preHtmlElem(e,"fadeToggle"),n=getComputedStyle(r),i=mt.getCurrentAnimationId(r),o="0"===n.opacity||null===r.offsetParent;return("string"==typeof i?"fadeOut"===i:o)?mt.fadeIn(e,t):mt.fadeOut(e,t)}fadeToggle(e){return mt.fadeToggle(this,e)}static fadeTo(e,t,r,n=mt.#se){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 mt._preHtmlElems(e,"fadeTo").forEach(o=>{const s=getComputedStyle(o);if(!(e instanceof Element&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length))){const e=mt.getAnimateData(o,"origdisplay");o.style.display="string"==typeof e?e:n}const a=[s.opacity,t].map(e=>({opacity:e}));i.set(o,mt.animate(o,a,r,"fadeTo")[0])}),i}fadeTo(e,t,r=this.#oe){return mt.fadeTo(this,e,t,r)}static offset(e){const t=mt._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 mt.offset(this)}static position(e){const t=mt._preHtmlElem(e,"position");let r,n,i={top:0,left:0};if("fixed"===window.getComputedStyle(t).position)n=t.getBoundingClientRect();else{n=mt.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}=mt.cssFloats(r,["borderTopWidth","borderLeftWidth"]);i=mt.offset(r),i.top+=e,i.left+=t}}return{top:n.top-i.top-mt.cssFloat(t,"marginTop"),left:n.left-i.left-mt.cssFloat(t,"marginLeft")}}position(){return mt.position(this)}static offsetParent(e){let t=mt._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 mt.offsetParent(this)}static scrollTop(e){const t=mt._preElemAndWindow(e,"scrollTop");return mt.isWindow(t)?t.pageYOffset:9===t.nodeType?t.defaultView.pageYOffset:t.scrollTop}scrollTop(){return mt.scrollTop(this)}static scrollLeft(e){const t=mt._preElemAndWindow(e,"scrollLeft");return mt.isWindow(t)?t.pageXOffset:9===t.nodeType?t.defaultView.pageXOffset:t.scrollLeft}scrollLeft(){return mt.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 mt.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 mt._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,h=l-o,c=u-a,d="string"==typeof i&&mt.easings[i]||null;if("number"!=typeof n||"function"!=typeof d)return s(e,l,u,1);const p=performance.now(),f=n??0;requestAnimationFrame(function t(r){if("function"!=typeof d)return;const n=Math.min(1,(r-p)/f),i=d(n);s(e,o+h*i,a+c*i,n),n<1&&requestAnimationFrame(t)})}),e}scrollToXY({targetX:e,targetY:t,duration:r,easing:n,onAnimation:i}={}){return mt.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 mt.scrollToXY(e,{targetY:t})}setScrollTop(e){return mt.setScrollTop(this,e)}static setScrollLeft(e,t){if("number"!=typeof t)throw new TypeError("ScrollLeft value must be a number.");return mt.scrollToXY(e,{targetX:t})}setScrollLeft(e){return mt.setScrollLeft(this,e)}static borderWidth(e){const t=mt._preElem(e,"borderWidth"),{borderLeftWidth:r,borderRightWidth:n,borderTopWidth:i,borderBottomWidth:o}=mt.cssFloats(t,["borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"]);return{x:r+n,y:i+o,left:r,right:n,top:i,bottom:o}}borderWidth(){return mt.borderWidth(this)}static border(e){const t=mt._preElem(e,"border"),{borderLeft:r,borderRight:n,borderTop:i,borderBottom:o}=mt.cssFloats(t,["borderLeft","borderRight","borderTop","borderBottom"]);return{x:r+n,y:i+o,left:r,right:n,top:i,bottom:o}}border(){return mt.border(this)}static margin(e){const t=mt._preElem(e,"margin"),{marginLeft:r,marginRight:n,marginTop:i,marginBottom:o}=mt.cssFloats(t,["marginLeft","marginRight","marginTop","marginBottom"]);return{x:r+n,y:i+o,left:r,right:n,top:i,bottom:o}}margin(){return mt.margin(this)}static padding(e){const t=mt._preElem(e,"padding"),{paddingLeft:r,paddingRight:n,paddingTop:i,paddingBottom:o}=mt.cssFloats(t,["paddingLeft","paddingRight","paddingTop","paddingBottom"]);return{x:r+n,y:i+o,left:r,right:n,top:i,bottom:o}}padding(){return mt.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(mt.#me){const t=e.split(" ");for(const e of t)r.push(e)}else r.push(e);return mt._preElems(e,"addClass").forEach(e=>e.classList.add(...r)),e}addClass(...e){return mt.addClass(this,...e)}static removeClass(e,...t){const r=[];for(const e of t)if(mt.#me){const t=e.split(" ");for(const e of t)r.push(e)}else r.push(e);return mt._preElems(e,"removeClass").forEach(e=>e.classList.remove(...r)),e}removeClass(...e){return mt.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 mt._preElems(e,"replaceClass").forEach(e=>n.push(e.classList.replace(t,r))),n}replaceClass(e,t){return mt.replaceClass(this,e,t)[0]}static classItem(e,t){const r=mt._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 mt.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 mt._preElems(e,"toggleClass").forEach(e=>n.push(e.classList.toggle(t,r))),n}toggleClass(e,t){return mt.toggleClass(this,e,t)[0]}static hasClass(e,t){const r=mt._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 mt.hasClass(this,e)}static classLength(e){return mt._preElem(e,"classLength").classList.length}classLength(){return mt.classLength(this)}static classList(e){return mt._preElem(e,"classList").classList.values().toArray()}classList(){return mt.classList(this)}static tagName(e){return mt._preElem(e,"tagName").tagName}tagName(){return mt.tagName(this)}static id(e){return mt._preElem(e,"id").id}get id(){return mt.id(this)}set id(e){mt.setAttr(this,"id",e)}static toBigInt(e){const t=mt._preElem(e,"toBigInt"),r=t.textContent?.trim();let n=null;try{n=BigInt(r??"")}catch{n=null}return n}toBigInt(){return mt.toBigInt(this)}static setBigInt(e,t){if("bigint"!=typeof t)throw new Error("Value is not a valid BigInt.");const r=t.toString();return mt._preElems(e,"setBigInt").forEach(e=>e.textContent=r),e}setBigInt(e){return mt.setBigInt(this,e)}static toDate(e){const t=mt._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 mt.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 mt._preElems(e,"setDate").forEach(e=>e.textContent=r),e}setDate(e){return mt.setDate(this,e)}static toJson(e){const t=mt._preElem(e,"toJson"),r=t.textContent?.trim();if(!r)return null;try{return JSON.parse(r)}catch{return null}}toJson(){return mt.toJson(this)}static setJson(e,t,r,n){const i=JSON.stringify(t,r,n);return mt._preElems(e,"setJson").forEach(e=>e.textContent=i),e}setJson(e,t,r){return mt.setJson(this,e,t,r)}static toNumber(e){const t=mt._preElem(e,"toNumber");return"string"==typeof t.textContent?parseFloat(t.textContent.trim()):null}toNumber(){return mt.toNumber(this)}static setNumber(e,t){if("number"!=typeof t)throw new Error("Value is not a valid number.");const r=t.toString();return mt._preElems(e,"setNumber").forEach(e=>e.textContent=r),e}setNumber(e){return mt.setNumber(this,e)}static toBoolean(e){const t=mt._preElem(e,"toBoolean"),r=t.textContent?.trim();return null==r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}toBoolean(){return mt.toBoolean(this)}static setBoolean(e,t){if("boolean"!=typeof t)throw new Error("Value is not a valid boolean.");const r=t.toString();return mt._preElems(e,"setBoolean").forEach(e=>e.textContent=r),e}setBoolean(e){return mt.setBoolean(this,e)}static toString(e){const t=mt._preElem(e,"toString");return"string"==typeof t.textContent?t.textContent:null}toString(){return mt.toString(this)}static setString(e,t){if("string"!=typeof t)throw new Error("Value is not a valid string.");return mt._preElems(e,"setString").forEach(e=>e.textContent=t),e}setString(e){return mt.setString(this,e)}static text(e){return mt._preElem(e,"text").textContent}text(){return mt.text(this)}static setText(e,t){const r=null!=t?String(t):"";return mt._preElems(e,"setText").forEach(e=>e.textContent=r),e}setText(e){return mt.setText(this,e)}static empty(e){return mt._preElems(e,"empty").forEach(e=>e.textContent=""),e}empty(){return mt.empty(this)}static html(e,t){return mt._preElem(e,"html").getHTML(t)}html(e){return mt.html(this,e)}static setHtml(e,t){if("string"!=typeof t)throw new Error("Value is not a valid string.");return mt._preElems(e,"setHtml").forEach(e=>e.innerHTML=t),e}setHtml(e){return mt.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=mt._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=mt._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 mt._preInputElems(e,"setVal").forEach(e=>{if(1!==e.nodeType)return;let r="function"==typeof t?t(e,mt.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=mt._valHooks[e.type]||mt._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 mt.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 mt._valTypes[t])throw new Error(`No handler found for type "${t}" in ${r}().`);return mt._valTypes[t](e)}static _val(e,t,r){const n=mt._preInputElem(e,t),i=mt._valHooks[n.type]||mt._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 mt._getValByType(n,r,t)}_val(e,t){return mt._val(this,e,t)}static val(e){return mt._val(e,"val","string")}val(){return mt.val(this)}static valTxt(e){const t=mt._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 mt.valTxt(this)}static _valArr(e,t,r){const n=mt._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 mt._valArr(this,e,t)}static valArr(e){return mt._valArr(e,"valArr","string")}valArr(){return mt.valArr(this)}static valNb(e){if(!(mt._preInputElem(e,"valNb")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const t=mt._val(e,"valNb","number");if(Number.isNaN(t))throw new Error("Value is not a valid number.");return t}valNb(){return mt.valNb(this)}static valDate(e){if(!(mt._preInputElem(e,"valDate")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const t=mt._val(e,"valDate","date");if(!(t instanceof Date))throw new Error("Value is not a valid date.");return t}valDate(){return mt.valDate(this)}static valBool(e){const t=mt._preInputElem(e,"valBool");if(!(t instanceof HTMLInputElement))throw new Error("Element must be an input element.");return"on"===mt.val(t)}valBool(){return mt.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 mt._preElemsWithDoc(e,"listenForPaste").forEach(e=>mt.on(e,"paste",n)),n}listenForPaste({onFilePaste:e,onTextPaste:t}={}){return mt.listenForPaste(this,{onFilePaste:e,onTextPaste:t})}static hasEventListener(e,t){const r=mt._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 mt.hasEventListener(this,e)}static hasExactEventListener(e,t,r){const n=mt._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 mt.hasExactEventListener(this,e,t)}static hover(e,t,r,n){return mt.on(e,"mouseenter",t,n),mt.on(e,"mouseleave",r||t,n),e}hover(e,t,r){return mt.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.");mt._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 mt.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.");mt._preEventTargetElems(e,"once").forEach(e=>{const t=n=>{mt.off(e,i,t),"function"==typeof r&&r(n)};mt.on(e,i,t,"boolean"==typeof n?n:{...n,once:!0})})}return e}once(e,t,r={}){return mt.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.");mt._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 mt.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.");mt._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 mt.offAll(this,e)}static offAllTypes(e,t=null){if(null!==t&&"function"!=typeof t)throw new TypeError('The "filterFn" must be a function.');return mt._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 mt.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.");mt._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 mt.trigger(this,e,t)}static#ge={for:"htmlFor",class:"className"};static propFix=new Proxy(mt.#ge,{set:(e,t,r)=>(e[t]=r,mt.attrFix[r]=t,!0)});static attrFix=Object.fromEntries(Object.entries(mt.#ge).map(([e,t])=>[t,e]));static getPropName(e){return"string"==typeof mt.propFix[e]?mt.propFix[e]:e}static getAttrName(e){return"string"==typeof mt.attrFix[e]?mt.attrFix[e]:e}static attrBigInt(e,t){const r=mt._preElem(e,"attrBigInt").getAttribute(mt.getAttrName(t));if(null==r)return null;try{return BigInt(r)}catch{return null}}attrBigInt(e){return mt.attrBigInt(this,e)}static setAttrBigInt(e,t,r){if("bigint"!=typeof r)throw new Error("Value is not a valid BigInt.");return mt.setAttr(e,t,r.toString())}setAttrBigInt(e,t){return mt.setAttrBigInt(this,e,t)}static attrDate(e,t){const r=mt._preElem(e,"attrDate").getAttribute(mt.getAttrName(t));if(!r)return null;const n=new Date(r);return Number.isNaN(n.getTime())?null:n}attrDate(e){return mt.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 mt.setAttr(e,t,r.toISOString())}setAttrDate(e,t){return mt.setAttrDate(this,e,t)}static attrJson(e,t){const r=mt._preElem(e,"attrJson").getAttribute(mt.getAttrName(t));if(!r)return null;try{return JSON.parse(r)}catch{return null}}attrJson(e){return mt.attrJson(this,e)}static setAttrJson(e,t,r,n,i){const o=JSON.stringify(r,n,i);return mt.setAttr(e,t,o)}setAttrJson(e,t,r,n){return mt.setAttrJson(this,e,t,r,n)}static attrNumber(e,t){const r=mt._preElem(e,"attrNumber").getAttribute(mt.getAttrName(t));return null!=r?parseFloat(r):null}attrNumber(e){return mt.attrNumber(this,e)}static setAttrNumber(e,t,r){if("number"!=typeof r)throw new Error("Value is not a valid number.");return mt.setAttr(e,t,r.toString())}setAttrNumber(e,t){return mt.setAttrNumber(this,e,t)}static attrBoolean(e,t){const r=mt._preElem(e,"attrBoolean").getAttribute(mt.getAttrName(t));return null===r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}attrBoolean(e){return mt.attrBoolean(this,e)}static setAttrBoolean(e,t,r){if("boolean"!=typeof r)throw new Error("Value is not a valid boolean.");return mt.setAttr(e,t,r.toString())}setAttrBoolean(e,t){return mt.setAttrBoolean(this,e,t)}static attrString(e,t){const r=mt._preElem(e,"attrString").getAttribute(mt.getAttrName(t));return"string"==typeof r?r:null}attrString(e){return mt.attrString(this,e)}static setAttrString(e,t,r){if("string"!=typeof r)throw new Error("Value is not a valid string.");return mt.setAttr(e,t,r)}setAttrString(e,t){return mt.setAttrString(this,e,t)}static attr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return mt._preElem(e,"attr").getAttribute(mt.getAttrName(t))}attr(e){return mt.attr(this,e)}static setAttr(e,t,r=null){const n=mt._preElems(e,"setAttr");if("object"==typeof t&&null!==t)return Object.entries(t).forEach(([e,t])=>n.forEach(r=>{null===t?r.removeAttribute(mt.getAttrName(e)):r.setAttribute(mt.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(mt.getAttrName(t)):e.setAttribute(mt.getAttrName(t),String(r))}),e}setAttr(e,t){return mt.setAttr(this,e,t)}static removeAttr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return mt._preElems(e,"removeAttr").forEach(e=>e.removeAttribute(mt.getAttrName(t))),e}removeAttr(e){return mt.removeAttr(this,e)}static hasAttr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return mt._preElem(e,"hasAttr").hasAttribute(mt.getAttrName(t))}hasAttr(e){return mt.hasAttr(this,e)}static hasProp(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return!!mt._preElem(e,"hasProp")[mt.getPropName(t)]}hasProp(e){return mt.hasProp(this,e)}static addProp(e,...t){return mt._preElems(e,"addProp").forEach(e=>{t.forEach(t=>{if("string"!=typeof t)throw new TypeError('Each "name" must be a string.');e[mt.getPropName(t)]=!0})}),e}addProp(...e){return mt.addProp(this,...e)}static removeProp(e,...t){return mt._preElems(e,"removeProp").forEach(e=>{t.forEach(t=>{if("string"!=typeof t)throw new TypeError('Each "name" must be a string.');e[mt.getPropName(t)]=!1})}),e}removeProp(...e){return mt.removeProp(this,...e)}static toggleProp(e,t,r){const n=mt._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[mt.getPropName(e)]:r)?mt.addProp(t,e):mt.removeProp(t,e)})}),e}toggleProp(e,t){return mt.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 mt._preElem(e,"prop")[t]}prop(e){return mt.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 mt._preElems(e,"setProp").forEach(e=>{e[t]=r}),e}setProp(e,t){return mt.setProp(this,e,t)}static remove(e){return mt._preElems(e,"remove").forEach(e=>e.remove()),e}remove(){return mt.remove(this)}static index(e,t=null){const r=mt._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):mt._preElems(t,"index");return Array.prototype.indexOf.call(e,r)}return-1}index(e){return mt.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=mt._getCustomRect(mt._preElem(e,"isCollWith").getBoundingClientRect(),r),i=mt._preElem(t,"isCollWith").getBoundingClientRect();return it(n,i)}isCollWith(e,t){return mt.isCollWith(this,e,t)}static isCollPerfWith(e,t,r={}){const n=mt._getCustomRect(mt._preElem(e,"isCollPerfWith").getBoundingClientRect(),r),i=mt._preElem(t,"isCollPerfWith").getBoundingClientRect();return ot(n,i)}isCollPerfWith(e,t){return mt.isCollPerfWith(this,e,t)}static _isCollWithLock(e,t,r,n,i){const o=ft[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=mt._preElem(e,"isCollWithLock"),o=mt._preElem(t,"isCollWithLock"),s=mt._getCustomRect(i.getBoundingClientRect(),n),a=o.getBoundingClientRect(),l=it(s,a);return mt._isCollWithLock(l,s,a,i,r)}isCollWithLock(e,t,r){return mt.isCollWithLock(this,e,t,r)}static isCollPerfWithLock(e,t,r,n={}){const i=mt._preElem(e,"isCollPerfWithLock"),o=mt._preElem(t,"isCollPerfWithLock"),s=mt._getCustomRect(i.getBoundingClientRect(),n),a=o.getBoundingClientRect(),l=ot(s,a);return mt._isCollWithLock(l,s,a,i,r)}isCollPerfWithLock(e,t,r){return mt.isCollPerfWithLock(this,e,t,r)}static resetCollLock(e){const t=mt._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 mt.resetCollLock(this)}static resetCollLockDir(e,t){const r=mt._preElem(e,"resetCollLockDir"),n=ft[t];return!!n.has(r)&&(n.delete(r),!0)}resetCollLockDir(e){return mt.resetCollLockDir(this,e)}static isInViewport(e){const t=mt._preElem(e,"isInViewport");if(!t.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=mt.offset(t).top,n=r+mt.outerHeight(t),i=mt.scrollTop(window),o=i+mt.height(window);return n>i&&r<o}isInViewport(){return mt.isInViewport(this)}static isScrolledIntoView(e){const t=mt._preElem(e,"isScrolledIntoView");if(!t.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=mt.scrollTop(window),n=r+mt.height(window),i=mt.offset(t).top;return i+mt.height(t)<=n&&i>=r}isScrolledIntoView(){return mt.isScrolledIntoView(this)}static isInContainer(e,t){const r=mt._preElem(e,"isInContainer"),n=mt._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 mt.isInContainer(this,e)}static isFullyInContainer(e,t){const r=mt._preElem(e,"isScrolledIntoView"),n=mt._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 mt.isFullyInContainer(this,e)}static hasScroll(e){const t=mt._preElem(e,"hasScroll");return{v:t.scrollHeight>t.clientHeight,h:t.scrollWidth>t.clientWidth}}hasScroll(){return mt.hasScroll(this)}}const gt=mt;class yt{static Utils={...e,TinyHtml:gt};#ye=!0;#we=!1;#be=0;#ve=0;#Ee=!0;#Te=!1;#Se=!1;#xe=!1;#Ae=!1;#Ce=!1;#Ie=!1;#Me=null;#Le=[];#ke=null;#Ne={start:!1,end:!1,collide:!1,move:!1};#_e=null;#B;#De="drag-hidden";#je="dragging";#Re="drag-active";#Oe="jail-drag-active";#He="jail-drag-disabled";#$e="dragging-collision";#Be=9999;constructor(e,t={}){const r=e instanceof gt?e.get(0):e;if(!(r instanceof HTMLElement))throw new Error("TinyDragger requires a valid target HTMLElement to initialize.");if(this.#B=r,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 n=(e,t)=>{if(void 0!==e&&"boolean"!=typeof e)throw new Error(`The "${t}" option must be a boolean.`)},i=(e,t)=>{if(void 0!==e&&"string"!=typeof e)throw new Error(`The "${t}" option must be a string.`)};n(t.mirrorElem,"mirrorElem"),n(t.collisionByMouse,"collisionByMouse"),n(t.lockInsideJail,"lockInsideJail"),n(t.dropInJailOnly,"dropInJailOnly"),n(t.revertOnDrop,"revertOnDrop"),n(t.multiCollision,"multiCollision"),i(t.classDragging,"classDragging"),i(t.classBodyDragging,"classBodyDragging"),i(t.classJailDragging,"classJailDragging"),i(t.classJailDragDisabled,"classJailDragDisabled"),i(t.classDragCollision,"classDragCollision"),i(t.classHidden,"classHidden"),t.jail instanceof HTMLElement&&(this.#_e=t.jail),this.#Ne=Object.assign({start:!1,end:!1,collide:!1,move:!1},f(t.vibration)?t.vibration:{}),"string"==typeof t.classDragging&&(this.#je=t.classDragging),"string"==typeof t.classBodyDragging&&(this.#Re=t.classBodyDragging),"string"==typeof t.classJailDragging&&(this.#Oe=t.classJailDragging),"string"==typeof t.classJailDragDisabled&&(this.#He=t.classJailDragDisabled),"string"==typeof t.classHidden&&(this.#De=t.classHidden),"string"==typeof t.classDragCollision&&(this.#$e=t.classDragCollision),"boolean"==typeof t.collisionByMouse&&(this.#Ce=t.collisionByMouse),"boolean"==typeof t.mirrorElem&&(this.#Ee=t.mirrorElem),"boolean"==typeof t.revertOnDrop&&(this.#xe=t.revertOnDrop),"boolean"==typeof t.lockInsideJail&&(this.#Se=t.lockInsideJail),"boolean"==typeof t.dropInJailOnly&&(this.#Ie=t.dropInJailOnly),"boolean"==typeof t.multiCollision&&(this.#Te=t.multiCollision),this._onMouseDown=this.#Pe.bind(this),this._onMouseMove=this.#Fe.bind(this),this._onMouseUp=this.#We.bind(this),this._onTouchStart=e=>this.#Pe(e.touches[0]),this._onTouchMove=e=>this.#Fe(e.touches[0]),this._onTouchEnd=e=>this.#We(e.changedTouches[0]),this.#B.addEventListener("mousedown",this._onMouseDown),this.#B.addEventListener("touchstart",this._onTouchStart,{passive:!1})}enable(){this.#ze(),this.#_e&&this.#_e.classList.add(this.#He),this.#ye=!0}disable(){this.#_e&&this.#_e.classList.remove(this.#He),this.#ye=!1}addCollidable(e){if(this.#ze(),!(e instanceof HTMLElement))throw new Error("addCollidable expects an HTMLElement as argument.");this.#Le.includes(e)||this.#Le.push(e)}removeCollidable(e){if(this.#ze(),!(e instanceof HTMLElement))throw new Error("removeCollidable expects an HTMLElement as argument.");this.#Le=this.#Le.filter(t=>t!==e)}setVibrationPattern({startPattern:e=!1,endPattern:t=!1,collidePattern:r=!1,movePattern:n=!1}={}){this.#ze();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.#Ne={start:e,end:t,collide:r,move:n}}disableVibration(){this.#ze(),this.#Ne={start:!1,end:!1,collide:!1,move:!1}}getOffset(e){if(this.#ze(),!(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.#B.getBoundingClientRect(),{left:r,top:n}=gt.borderWidth(this.#B);return{x:e.clientX-t.left+r,y:e.clientY-t.top+n}}#Pe(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#we||!this.#ye||!this.#B.parentElement)return;if(this.#Ee){const e=this.#B.cloneNode(!0);if(!(e instanceof HTMLElement))throw new Error("[TinyDragger] INVALID DRAG ELEMENT!");this.#ke=e}else this.#ke=this.#B;this.#Ae=!0;const t=this.#B.getBoundingClientRect();Object.assign(this.#ke.style,{position:"absolute",pointerEvents:"none",left:`${this.#B.offsetLeft}px`,top:`${this.#B.offsetTop}px`,width:`${t.width}px`,height:`${t.height}px`,zIndex:this.#Be}),this.#Ee&&(this.#B.classList.add(this.#De),this.#B.parentElement.appendChild(this.#ke));const{x:r,y:n}=this.getOffset(e);this.#ve=r,this.#be=n,this.#ke.classList.add(this.#je),document.body.classList.add(this.#Re),this.#_e&&this.#_e.classList.add(this.#Oe),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.#Ne.start)&&navigator.vibrate(this.#Ne.start),this.checkDragCollision(e),this.#qe("drag")}#Ve=[];#Ue(e){e&&(e.classList.add(this.#$e),this.#Ve.push(e))}#Ke(){for(;this.#Ve.length>0;){const e=this.#Ve.shift();e&&e.classList.remove(this.#$e)}this.#Me&&this.#Me.classList.remove(this.#$e)}checkDragCollision(e){const{collidedElements:t}=this.execCollision(e),r=t[0]||null;this.#Me&&!t.includes(this.#Me)&&this.#Ke(),t.forEach(e=>this.#Ue(e)),this.#Le.forEach(e=>{t.includes(e)||e.classList.remove(this.#$e)}),navigator.vibrate&&Array.isArray(this.#Ne.collide)&&t.length>0&&navigator.vibrate(this.#Ne.collide),this.#Me=r}#Fe(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#we||!this.#Ae||!this.#ye||!this.#ke)return;const t=(this.#ke.offsetParent||document.body).getBoundingClientRect();let r=e.clientX-t.left-this.#ve,n=e.clientY-t.top-this.#be;if(this.#Se&&this.#_e){const e=this.#_e.getBoundingClientRect(),i=this.#ke.getBoundingClientRect(),o=e.left-t.left,s=e.top-t.top,{x:a,y:l}=gt.borderWidth(this.#_e),u=o+e.width-i.width-l,h=s+e.height-i.height-a;r=Math.max(o,Math.min(r,u)),n=Math.max(s,Math.min(n,h))}this.#ke.style.position="absolute",this.#ke.style.left=`${r}px`,this.#ke.style.top=`${n}px`,navigator.vibrate&&Array.isArray(this.#Ne.move)&&navigator.vibrate(this.#Ne.move),this.checkDragCollision(e),this.#qe("dragging")}execCollision(e){if(this.#we||!this.#ke)return{inJail:!1,collidedElements:[]};let t=[],r=!0;const n=this.#_e?.getBoundingClientRect();if(this.#Ce){const i=e.clientX,o=e.clientY;this.#Ie&&this.#_e&&n&&(r=i>=n.left&&i<=n.right&&o>=n.top&&o<=n.bottom),t=r?this.#Te?this.getAllCollidedElements(i,o):[this.getCollidedElement(i,o)].filter(Boolean):[]}else{const e=this.#ke.getBoundingClientRect();this.#Ie&&this.#_e&&n&&(r=e.left>=n.left&&e.right<=n.right&&e.top>=n.top&&e.bottom<=n.bottom),t=r?this.#Te?this.getAllCollidedElementsByRect(e):[this.getCollidedElementByRect(e)].filter(Boolean):[]}return{inJail:r,collidedElements:t}}#We(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#we||!this.#Ae)return;if(this.#Ae=!1,!this.#ke)return;this.#B.classList.remove(this.#je),document.body.classList.remove(this.#Re),this.#_e&&this.#_e.classList.remove(this.#Oe),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.#Ne.end)&&navigator.vibrate(this.#Ne.end);const r=this.#ke.style.left,n=this.#ke.style.top;this.#ke&&(this.#Ee?this.#ke.remove():Object.assign(this.#ke.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#ke=null),this.#Me&&this.#Ke(),this.#Me=null,this.#Ee&&this.#B.classList.remove(this.#De),this.#xe||(this.#B.style.left=r,this.#B.style.top=n);const i=new CustomEvent("drop",{detail:{targets:t,first:t[0]||null}});this.#B.dispatchEvent(i)}#Je(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.#ze(),!(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.#Le.filter(t=>this.#Je(t,e))}getCollidedElementByRect(e){if(this.#ze(),!(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.#Le.find(t=>this.#Je(t,e))||null}#Ge(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.#ze(),"number"!=typeof e||"number"!=typeof t)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#Le.filter(r=>this.#Ge(r,e,t))}getCollidedElement(e,t){if(this.#ze(),"number"!=typeof e||"number"!=typeof t)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#Le.find(r=>this.#Ge(r,e,t))||null}#qe(e){const t=new CustomEvent(e);this.#B.dispatchEvent(t)}getDragging(){return this.#Ae}getLockInsideJail(){return this.#Se}setLockInsideJail(e){if("boolean"!=typeof e)throw new Error("lockInsideJail must be a boolean.");this.#Se=e}getRevertOnDrop(){return this.#xe}setRevertOnDrop(e){if("boolean"!=typeof e)throw new Error("revertOnDrop must be a boolean.");this.#xe=e}getCollisionByMouse(){return this.#Ce}setCollisionByMouse(e){if("boolean"!=typeof e)throw new Error("collisionByMouse must be a boolean.");this.#Ce=e}getDropInJailOnly(){return this.#Ie}setDropInJailOnly(e){if("boolean"!=typeof e)throw new Error("dropInJailOnly must be a boolean.");this.#Ie=e}getDefaultZIndex(){return this.#Be}setDefaultZIndex(e){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("Z-index must be a finite number.");this.#Be=e}isMirrorEnabled(){return this.#Ee}setMirrorEnabled(e){if("boolean"!=typeof e)throw new TypeError("Mirror setting must be a boolean.");this.#Ee=e}getTarget(){return this.#B}getJail(){return this.#_e}getDragProxy(){return this.#ke}getLastCollision(){return this.#Me}getCollidables(){return[...this.#Le]}getDragHiddenClass(){return this.#De}getClassDragging(){return this.#je}getClassBodyDragging(){return this.#Re}getClassJailDragging(){return this.#Oe}getClassJailDragDisabled(){return this.#He}getClassDragCollision(){return this.#$e}getVibrations(){return{...this.#Ne}}getStartVibration(){return this.#Ne.start}getEndVibration(){return this.#Ne.end}getCollideVibration(){return this.#Ne.collide}getMoveVibration(){return this.#Ne.move}isEnabled(){return this.#ye}#ze(){if(this.#we)throw new Error("This TinyDragger instance has been destroyed and can no longer be used.")}destroy(){this.#we||(this.disable(),this.#B.removeEventListener("mousedown",this._onMouseDown),this.#B.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.#Me&&this.#Ke(),this.#ke&&(this.#Ee?this.#ke.remove():Object.assign(this.#ke.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#ke=null),this.#Le=[],this.#Ae=!1,this.#Me=null,this.#Ee&&this.#B.classList.remove(this.#De),this.#B.classList.remove(this.#je),document.body.classList.remove(this.#Re),this.#_e&&this.#_e.classList.remove(this.#Oe,this.#He),this.#we=!0)}}const wt=yt,bt=class{#Ye=[];#Xe=!1;#Qe=!1;#Ze=[];#et(){this.#Xe&&Promise.all(this.#Ze).then(()=>{this.#Qe=!0,this.#tt(!1)}).catch(e=>{console.error("[TinyDomReadyManager] Promise rejected:",e)})}#tt(e){this.#Ye.filter(t=>t.domOnly===e).sort((e,t)=>t.priority-e.priority).forEach(e=>this.#rt(e)),this.#Ye=this.#Ye.filter(t=>!(t.once&&(!e||t.domOnly)))}#rt(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.#Xe=!0,this.#tt(!0),this.#et()}init(){if(this.#Xe)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.#Qe||(this.#Ze.push(e),this.#Xe&&this.#et())}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.#Xe)return this.#rt(o),void(t||this.#Ye.push(o));!i&&this.#Qe?this.#rt(o):this.#Ye.push(o)}isReady(){return this.#Qe}isDomReady(){return this.#Xe}},vt=class{#nt=!1;#it=!1;#ot=null;#st=100;#at=null;#lt;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.#ot="string"!=typeof e?e:new Audio(e),this.#at=t,this.#st=r,this.#lt=n}requestPerm(){const e=this;return new Promise((t,r)=>{e.isCompatible()?"default"===Notification.permission?Notification.requestPermission().then(r=>{this.#it=!0,e.#nt="granted"===r,t(e.#nt)}).catch(r):(this.#it=!0,e.#nt="granted"===Notification.permission,t(e.#nt)):(this.#it=!0,e.#nt=!1,t(!1))})}isCompatible(){return"Notification"in window}send(e,t={}){if(!this.#it)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.#nt)return null;const{icon:r=this.#at||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=z(i.body,this.#st));const o=new Notification(e,i);return o.addEventListener("show",()=>{this.#ot instanceof HTMLAudioElement&&(this.#ot.currentTime=0,this.#ot.play().catch(e=>console.error(e)))}),"function"==typeof this.#lt&&o.addEventListener("click",this.#lt),o}wasPermissionRequested(){return this.#it}isAllowed(){return this.#nt}getAudio(){return this.#ot}setAudio(e){if(!(e instanceof HTMLAudioElement)&&"string"!=typeof e&&null!==e)throw new TypeError("sound must be an instance of HTMLAudioElement or null.");this.#ot="string"!=typeof e?e:new Audio(e)}getBodyLimit(){return this.#st}setBodyLimit(e){if(!Number.isFinite(e)||e<0)throw new TypeError("bodyLimit must be a non-negative number.");this.#st=e}getDefaultAvatar(){return this.#at}setDefaultAvatar(e){if("string"!=typeof e&&null!==e)throw new TypeError("defaultIcon must be a string or null.");this.#at=e}getDefaultOnClick(){return this.#lt}setDefaultOnClick(e){if("function"!=typeof e)throw new TypeError("defaultOnClick must be a function.");this.#lt=e}},Et=class{#ut;#ht=null;#ct=[];#dt=100;#pt=new Set;#ft=new Set;#we=!1;constructor(e=window,t=100){if(!(e instanceof Element||e instanceof Window))throw new TypeError("scrollTarget must be an Element or the Window object.");this.#ut=e,this._checkTimer=this._checkTimer.bind(this),this.#ut.addEventListener("scroll",this._checkTimer),this.#dt=t}_checkTimer=()=>{this.#ht&&clearTimeout(this.#ht),this.#ht=setTimeout(()=>{this.#ht=null,this.#mt()},this.#dt)};get inactivityTime(){return this.#dt}set inactivityTime(e){if("number"!=typeof e||e<=0||!Number.isFinite(e))throw new Error("inactivityTime must be a positive number in milliseconds.");this.#dt=e}#mt(){if(!this.#we){for(const e of this.#ft)"function"==typeof e&&e();for(;this.#ct.length;){const e=this.#ct.pop();"function"==typeof e&&e()}}}doAfterScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.lastScrollTime=Date.now(),this.#ct.push(e)}onStop(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ft.add(e)}offStop(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ft.delete(e)}onScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ut.addEventListener("scroll",e),this.#pt.add(e)}offScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#pt.has(e)&&(this.#ut.removeEventListener("scroll",e),this.#pt.delete(e))}destroy(){if(!this.#we){this.#we=!0,this.#ut.removeEventListener("scroll",this._checkTimer);for(const e of this.#pt)this.#ut.removeEventListener("scroll",e);this.#pt.clear(),this.#ft.clear()}}},Tt=["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","sed","do","eiusmod","tempor","incididunt","ut","labore","et","dolore","magna","aliqua"],St=["😂","🌈","🤖","💥","🐸","🍕","🦄","🧠","🧬","🚀","🫠","💫","🍩","👾","🎉","🥴","🐙","🧃","🪐","🎈","🧸","👻","🥳","🍭","💖","😺","🌮","🪅","🎮","🥓","🍮"],xt=["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"],At=["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"],Ct=["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"],It=["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 Mt{static#gt=Tt;static#yt=St;static#wt=xt;static#bt=At;static#vt=Ct;static#Et=It;static#Tt(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.#gt]}static set defaultWords(e){this.#Tt(e,"defaultWords"),this.#gt=[...e]}static get defaultEmojis(){return[...this.#yt]}static set defaultEmojis(e){this.#Tt(e,"defaultEmojis"),this.#yt=[...e]}static get defaultNouns(){return[...this.#wt]}static set defaultNouns(e){this.#Tt(e,"defaultNouns"),this.#wt=[...e]}static get defaultVerbs(){return[...this.#bt]}static set defaultVerbs(e){this.#Tt(e,"defaultVerbs"),this.#bt=[...e]}static get defaultAdjectives(){return[...this.#vt]}static set defaultAdjectives(e){this.#Tt(e,"defaultAdjectives"),this.#vt=[...e]}static get defaultTemplates(){return[...this.#Et]}static set defaultTemplates(e){this.#Tt(e,"defaultTemplates"),this.#Et=[...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:h,grammar:c,repeatWords:d,emojiPlacement:p,paragraphs:f,line:m}=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!==h&&!["mixed","readable","chaotic","natural"].includes(h))throw new RangeError('config.mode must be one of: "mixed", "readable", "chaotic", "natural');if(void 0!==c){if("object"!=typeof c||null===c)throw new TypeError("config.grammar must be an object");const{templates:e,nouns:t,verbs:r,adjectives:n}=c;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!==f){if("object"!=typeof f)throw new TypeError("config.paragraphs must be an object or null");const{min:e,max:t}=f;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!==m){if("object"!=typeof m||null===m)throw new TypeError("config.line must be an object");const{minLength:e,maxLength:t,emojiChance:r}=m;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=[...Mt.#yt],this.config.wordSet=[...Mt.#gt],this.config.grammar.templates=[...Mt.#Et],this.config.grammar.nouns=[...Mt.#wt],this.config.grammar.verbs=[...Mt.#bt],this.config.grammar.adjectives=[...Mt.#vt],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 h=u.join(i?" ":"");return"end"===a&&s&&o.length&&Math.random()<(l?.emojiChance||0)&&(h+=" "+this._getRandomItem(o)),h}_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 Lt=Mt,kt=class{#St=new Map;#xt=10;#At=!1;#Ct(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.#At=e}getThrowOnMaxListeners(){return this.#At}#It(e,t,{once:r=!1}={}){let n=this.#St.get(e);Array.isArray(n)||(n=[],this.#St.set(e,n)),n.unshift({handler:t,config:{once:r}});const i=this.#xt;if(i>0&&n.length>i){const t=`Possible memory leak detected. ${n.length} "${e}" listeners added. Use setMaxListeners() to increase limit.`;if(this.#At)throw new Error(t);console.warn(t)}}prependListener(e,t){const r=this.#Ct(e,"prependListener");if("function"!=typeof t)throw new TypeError("prependListener(event, handler): handler must be a function");for(const e of r)this.#It(e,t)}prependListenerOnce(e,t){const r=this.#Ct(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.#It(e,r,{once:!0}),n.push(r)}return n}#Mt(e,t,{once:r=!1}={}){const n=this.#Ct(e,"on");for(const e of n){let n=this.#St.get(e);Array.isArray(n)||(n=[],this.#St.set(e,n)),n.push({handler:t,config:{once:r}});const i=this.#xt;if(i>0&&n.length>i){const t=`Possible memory leak detected. ${n.length} "${e}" listeners added. Use setMaxListeners() to increase limit.`;if(this.#At)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.#Mt(e,t)}once(e,t){const r=this.#Ct(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.#Mt(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.#Ct(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.#St.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.#St.delete(e)}}offAll(e){const t=this.#Ct(e,"offAll");for(const e of t)this.#St.delete(e)}offAllTypes(){this.#St.clear()}listenerCount(e){if("string"!=typeof e)throw new TypeError("listenerCount(event): event name must be a string");const t=this.#St.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.#St.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.#St.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.#St.get(e);return Array.isArray(t)?[...t].map(e=>e.handler):[]}eventNames(){return[...this.#St.keys()]}emit(e,...t){const r=this.#Ct(e,"emit"),n=[];for(const e of r){const r=this.#St.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.#xt=e}getMaxListeners(){return this.#xt}};class Nt{static Utils={...e,TinyHtml:gt};#Lt=new kt;setThrowOnMaxListeners(e){return this.#Lt.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#Lt.getThrowOnMaxListeners()}prependListener(e,t){return this.#Lt.prependListener(e,t)}prependListenerOnce(e,t){return this.#Lt.prependListenerOnce(e,t)}appendListener(e,t){return this.#Lt.appendListener(e,t)}appendListenerOnce(e,t){return this.#Lt.appendListenerOnce(e,t)}on(e,t){return this.#Lt.on(e,t)}once(e,t){return this.#Lt.once(e,t)}off(e,t){return this.#Lt.off(e,t)}offAll(e){return this.#Lt.offAll(e)}offAllTypes(){return this.#Lt.offAllTypes()}listenerCount(e){return this.#Lt.listenerCount(e)}listeners(e){return this.#Lt.listeners(e)}onceListeners(e){return this.#Lt.onceListeners(e)}allListeners(e){return this.#Lt.allListeners(e)}eventNames(){return this.#Lt.eventNames()}emit(e,...t){return this.#Lt.emit(e,...t)}setMaxListeners(e){return this.#Lt.setMaxListeners(e)}getMaxListeners(){return this.#Lt.getMaxListeners()}#kt=new WeakMap;#Nt=new WeakMap;#_t=new WeakMap;#Dt=new WeakMap;#jt=new WeakMap;#Rt=new WeakMap;#Ot=null;#Ht=null;#$t=new Set(["IMG","IFRAME","VIDEO"]);#Bt=null;#Pt=!1;#Ft=!1;#Wt=!1;#zt=!1;#qt=!1;#Vt=!1;#Ut=!1;#Kt=!1;#Jt="";#Gt=!1;#we=!1;#Yt=!1;#Xt=!1;#Qt=!1;#Zt=!1;#er=0;#tr=0;#rr=0;#nr=0;#ir=0;#or;#B;#sr=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(!(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.#B=e instanceof Window?document.documentElement:e,this.#Gt=e instanceof Window,this.#Xt=r,this.#Qt=n,this.#Zt=i,this.#er=o,this.#ir=t,this.#Jt=s||"",this.#or=new Set(a||void 0),this.#Bt=()=>{this._scrollDataUpdater(),clearTimeout(l),l=setTimeout(()=>this._onScroll(),this.#er)},(this.#Gt?window:this.#B).addEventListener("scroll",this.#Bt,{passive:!0}),this.#Qt&&(this._observeMutations(),this._observeResizes(this.#B.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.#$t)}addLoadTag(e){if("string"!=typeof e)throw new TypeError("addLoadTag(tag): tag must be a string");this.#$t.add(e.toUpperCase())}removeLoadTag(e){if("string"!=typeof e)throw new TypeError("removeLoadTag(tag): tag must be a string");this.#$t.delete(e.toUpperCase())}hasLoadTag(e){if("string"!=typeof e)throw new TypeError("hasLoadTag(tag): tag must be a string");return this.#$t.has(e.toUpperCase())}resetLoadTags(e=!1){if("boolean"!=typeof e)throw new TypeError("resetLoadTags(addDefault): addDefault must be a boolean");this.#$t.clear(),e&&(this.#$t.add("IMG"),this.#$t.add("IFRAME"),this.#$t.add("VIDEO"))}getAttributeFilters(){return Array.from(this.#or)}addAttributeFilter(e){if("string"!=typeof e)throw new TypeError("addAttributeFilter(attr): attr must be a string");this.#or.add(e)}removeAttributeFilter(e){if("string"!=typeof e)throw new TypeError("removeAttributeFilter(attr): attr must be a string");this.#or.delete(e)}hasAttributeFilter(e){if("string"!=typeof e)throw new TypeError("hasAttributeFilter(attr): attr must be a string");return this.#or.has(e)}resetAttributeFilters(e=!1){if("boolean"!=typeof e)throw new TypeError("resetAttributeFilters(addDefault): addDefault must be a boolean");this.#or.clear(),e&&["class","style","src","data-*","height","width"].forEach(e=>this.#or.add(e))}onSize(e){if(!this.#we){if("function"!=typeof e)throw new TypeError("onSize(handler): handler must be a function");this.#sr.add(e)}}offSize(e){if(!this.#we){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.#B.querySelectorAll(this.#Jt||"*").forEach(t=>{const r=this.#_t.get(t)??!1;this.#Dt.set(t,r);const n=gt.isInContainer(this.#B,t);this.#_t.set(t,n),e.set(t,{oldIsVisible:r,isVisible:n})}),e}_onScroll(){if(this.#we)return;const e=this._scrollDataUpdater(),t=this.#B,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,h=r<=0+this.#ir,c=r+i>=n-1-this.#ir;l&&u?s="all":l?s="top":u&&(s="bottom"),h&&c?a="all":h?a="top":c&&(a="bottom"),this.#Ft=this.#Vt??!1,this.#Pt=this.#qt??!1,this.#Wt=this.#Ut??!1,this.#zt=this.#Kt??!1,this.#Vt=l,this.#qt=u,this.#Ut=h,this.#Kt=c,this.#Yt=!(this.#Xt&&this.#qt),this.#nr=n-r-i,this.emit("onScrollBoundary",{status:s,...o,scrollCache:e}),this.emit("onExtraScrollBoundary",{status:a,...o,scrollCache:e}),this.#Yt?this.emit("onScrollPause",{...o,scrollCache:e}):this.emit("onAutoScroll",{...o,scrollCache:e})}_fixScroll(e=[]){if(this.#we)return;if(!Array.isArray(e))throw new TypeError("_fixScroll: targets must be an array of Elements");const t=this.#B.scrollHeight,r=this.#B.scrollTop,n=this.#B.scrollHeight-this.#B.scrollTop-this.#B.clientHeight,i=this.#B.scrollHeight-t,o=()=>{const t={height:0,width:0};for(const r of e){const e=this.#kt.get(r)||{height:0,width:0},n=this.#Nt.get(r)||{height:0,width:0};this.#sr.forEach(i=>{const o=i(r,{old:e,now:n},{old:this.#rr,now:this.#tr});if(this.#_t.get(r)||this.#jt.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.#jt.set(t,this.#_t.get(t)??!1),this.#Rt.set(t,this.#Dt.get(t)??!1);return t};if(this.#rr>0&>.hasScroll(this.#B).v&&this.#Xt&&this.#Zt&&!this.#qt&&!this.#Vt){const e=o();this.#B.scrollTop=r+i+e.height,e.width>0&&(this.#B.scrollLeft=this.#B.scrollLeft+e.width)}else!this.#Yt&&this.#Xt?(o(),this.scrollToBottom()):this.#Xt||this.#qt||(o(),this.#B.scrollTop=this.#B.scrollHeight-this.#B.clientHeight-n)}_observeMutations(){this.#Ht=new MutationObserver(e=>{this.#we||(this._scrollDataUpdater(),this.#rr=this.#tr,this.#tr=this.#B.childElementCount,e.forEach(e=>{e.addedNodes.forEach(e=>{if(e instanceof Element&&1===e.nodeType&&(this._observeResizes([e]),this._listenLoadEvents(e),this.#Jt)){const t=e.querySelectorAll(this.#Jt);this._observeResizes(t),this._listenLoadEvents(t)}})}),this._fixScroll())}),this.#Ht.observe(this.#B,{childList:!0,subtree:!0,attributes:!0,attributeFilter:this.#or.size>0?Array.from(this.#or):void 0})}_observeResizes(e){this.#Ot||(this.#Ot=new ResizeObserver(e=>{if(this.#we)return;this._scrollDataUpdater();const t=[];for(const r of e){const e=r.target,n=this.#Nt.get(e);n&&this.#kt.set(e,n);const{width:i,height:o}=r.contentRect;this.#Nt.set(e,{width:i,height:o}),t.push(e)}this._fixScroll(t)})),Array.from(e).forEach(e=>{if(!this.#Ot)throw new Error("_observeResizes: ResizeObserver instance is not initialized");this.#Ot.observe(e)})}_listenLoadEvents(e){this.#we||(e instanceof NodeList?Array.from(e):[e]).forEach(e=>{this.#$t.has(e.tagName)&&(e.complete||e.addEventListener("load",()=>{this._scrollDataUpdater(),!this.#Yt&&this.#Xt&&this.scrollToBottom()}))})}get target(){return this.#B}getOldSize(e){return this.#kt.get(e)??null}getNewSize(e){return this.#Nt.get(e)??null}wasVisible(e){return this.#Dt.get(e)??!1}isVisible(e){return this.#_t.get(e)??!1}wasTimedVisible(e){return this.#Rt.get(e)??!1}isTimedVisible(e){return this.#jt.get(e)??!1}setExtraScrollBoundary(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("setExtraScrollBoundary(value): value must be a valid number");this.#ir=e}getExtraScrollBoundary(){return this.#ir}getLastKnownScrollBottomOffset(){return this.#nr}scrollToBottom(){this.#B.scrollTop=this.#B.scrollHeight}scrollToTop(){this.#B.scrollTop=0}isAtCustomBottom(){return this.#Kt}isAtCustomTop(){return this.#Ut}isAtBottom(){return this.#qt}isAtTop(){return this.#Vt}isPastAtBottom(){return this.#Pt}isPastAtTop(){return this.#Ft}isPastAtCustomTop(){return this.#Wt}isPastAtCustomBottom(){return this.#zt}isScrollPaused(){return this.#Yt}isWindow(){return this.#Gt}isDestroyed(){return this.#we}getAutoScrollBottom(){return this.#Xt}getObserveMutations(){return this.#Qt}getPreserveScrollOnLayoutShift(){return this.#Zt}getDebounceTime(){return this.#er}getElemAmount(){return this.#tr}getPrevElemAmount(){return this.#rr}getQuerySelector(){return this.#Jt}destroy(){if(this.#we)return;this.#we=!0,this.#Ht&&(this.#Ht.disconnect(),this.#Ht=null),this.#Ot&&(this.#Ot.disconnect(),this.#Ot=null);const e=this.#Gt?window:this.#B;this.#Bt&&e.removeEventListener("scroll",this.#Bt),this.#kt=new WeakMap,this.#Nt=new WeakMap,this.#_t=new WeakMap,this.#Dt=new WeakMap,this.#jt=new WeakMap,this.#Rt=new WeakMap,this.#Lt.offAllTypes(),this.#sr.clear(),this.#$t.clear()}}const _t=Nt,Dt=class{#G;#ar;#lr;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.#G=e,this.#ar=t,this.#lr=r}getOpenTag(){return this.#ar}getCloseTag(){return this.#lr}setOpenTag(e){if("string"!=typeof e)throw new TypeError("Open tag must be a string.");this.#ar=e}setCloseTag(e){if("string"!=typeof e)throw new TypeError("Close tag must be a string.");this.#lr=e}ensureFocus(){return document.activeElement!==this.#G&&this.#G.focus(),this}focus(){return this.#G.focus(),this}getSelectionRange(){return{start:this.#G.selectionStart??NaN,end:this.#G.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.#G.scrollTop,i=this.#G.scrollLeft;return this.#G.setSelectionRange(e,t),r&&(this.#G.scrollTop=n,this.#G.scrollLeft=i),this}getValue(){return this.#G.value}setValue(e){if("string"!=typeof e)throw new TypeError("Value must be a string.");return this.#G.value=e,this}getSelectedText(){const{start:e,end:t}=this.getSelectionRange();return this.#G.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.#G.value,l=a[o-1]||"",u=a[s]||"",h=`${n&&l&&!/\s/.test(l)?" ":""}${e}${i&&u&&!/\s/.test(u)?" ":""}`,c=a.slice(0,o)+h+a.slice(s);this.setValue(c);let d=o;return"end"===t?d=o+h.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.#G.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.#G.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.#G.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.#G.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.#ar}${e} ${r}${this.#lr}`:`${this.#ar}${e}${this.#lr}`,i=`${this.#ar}/${e}${this.#lr}`;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.#ar}${e} ${n}${this.#lr}`:`${this.#ar}${e}${this.#lr}`,o=`${this.#ar}/${e}${this.#lr}`;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.#ar}${e} ${r}${this.#lr}`:`${this.#ar}${e}${this.#lr}`;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.#ar}${e} ${n}${this.#lr}`:`${this.#ar}${e}${this.#lr}`,o=`${this.#ar}/${e}${this.#lr}`;this.insertText(`${i}${r}${o}`)}return this}},jt=class{#ur=!1;#hr=!1;#cr=null;#dr=null;constructor(){void 0!==navigator.clipboard&&null!==navigator.clipboard&&(this.#hr=!0,this.#cr=e=>navigator.clipboard.writeText(e),this.#dr=e=>navigator.clipboard.write([new ClipboardItem({[e.type]:e})])),this.#ur=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.#dr=e}copyText(e){if("string"!=typeof e)throw new TypeError("copyText expected a string.");if(this.#cr)return this.#cr(e);if(this.#ur){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.#dr)return this.#dr(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)}},h=[],c=e=>{if(!(e instanceof ClipboardItem))throw new Error("Expected ClipboardItem when reading data.");for(const t in e.types)h.push(u(e.types[t],e))};if("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)&&e>-1)c(s),Promise.all(h).then(()=>{a[0]?i(a[0]):i(null)}).catch(o);else if(Array.isArray(s)){for(const e in s)c(s[e]);Promise.all(h).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.#hr||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.#ur}isNavigatorClipboardAvailable(){return this.#hr}getCopyTextFunc(){return this.#cr}getCopyBlobFunc(){return this.#dr}};class Rt{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 Rt._rca(e,"rgb",t)}static rcaHsl(e,t){return Rt._rca(e,"hsl",t)}static rcaHex(e,t){return Rt._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]=Rt.hslToRgba(e,t,r);return Rt.rgbToInt(n,i,o)}static hslToHex(e,t,r){const[n,i,o]=Rt.hslToRgba(e,t,r);return Rt.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 Rt.hslToRgba(e,t,r,n).slice(0,3)}static hexToInt(e){return parseInt(e.replace(/^#/,""),16)}static hexToHsl(e){const[t,r,n,i]=Rt.hexToRgba(e);return Rt.rgbaToHsl(t,r,n,i)}static hexToHsla(e){const[t,r,n,i]=Rt.hexToRgba(e);return Rt.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]=Rt.intToRgba(e);return Rt.rgbaToHsl(t,r,n,i)}static intToHsla(e){const[t,r,n,i]=Rt.intToRgba(e);return Rt.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]}#pr="#000000";#fr=[0,0,0,0];#mr;constructor(e=null,t=!1){this.#mr=t,null!=e&&this.setColor(e)}setColor(e){this.#pr=e;const t=this.#mr&&Array.isArray(e)&&e[0]<=360&&e[1]<=100&&e[2]<=100;this.#fr=Rt.parseInput(e,t)}toHslaArray(){const[e,t,r,n]=this.#fr;return Rt.rgbaToHsla(e,t,r,n)}toHslString(){const[e,t,r]=this.#fr,[n,i,o]=Rt.rgbaToHsl(e,t,r);return`hsl(${n}, ${i}%, ${o}%)`}toHslaString(){const[e,t,r,n]=this.#fr,[i,o,s,a]=Rt.rgbaToHsla(e,t,r,n);return`hsla(${i}, ${o}%, ${s}%, ${a??1})`}toRgbaArray(){return[...this.#fr]}toRgbString(){const[e,t,r]=this.#fr;return`rgb(${e}, ${t}, ${r})`}toRgbaString(){const[e,t,r,n]=this.#fr;return`rgba(${e}, ${t}, ${r}, ${n??1})`}toHex(){const[e,t,r]=this.#fr;return Rt.rgbToHex(e,t,r)}toInt(){const[e,t,r]=this.#fr;return Rt.rgbToInt(e,t,r)}getOriginal(){return this.#pr}}const Ot=Rt;class Ht{#gr=!1;#yr;#wr;#br=null;#vr=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.#wr=e,this.#yr=t,this.setCooldownWatcherTime(e)}isDestroyed(){return this.#gr}getAllowAutoConfigChange(){return this.#yr}getCooldownWatcherTime(){return this.#wr}setAllowAutoConfigChange(e){if("boolean"!=typeof e)throw new TypeError("Expected 'value' to be a boolean.");this.#yr=e}setCooldownWatcherTime(e){if(this.#gr)throw new Error("TinyTimeout has been destroyed.");if(!Number.isFinite(e)||e<=0)throw new TypeError("Expected 'value' to be a positive number.");this.#wr=e,this.#br&&clearInterval(this.#br),this.#br=setInterval(()=>{this.#vr.forEach(e=>{e.now>0&&e.now--})},this.#wr)}set(e,t,r,n=null){if(this.#gr)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.#vr.get(e);(!i||this.#yr&&r!==i.value)&&(i={value:r,now:0},this.#vr.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.#gr)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 Ht.waitForTrue(e,t??this.#wr)}destroy(){this.#gr||(this.#gr=!0,this.#br&&clearInterval(this.#br),this.#br=null,this.#vr.clear())}}const $t=Ht,Bt=new Map,Pt=new Map,Ft=new Set(["string","boolean","object","array",String,Boolean,Number,Object,Array,BigInt,Symbol]);class Wt{#Lt=new kt;setThrowOnMaxListeners(e){return this.#Lt.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#Lt.getThrowOnMaxListeners()}prependListener(e,t){return this.#Lt.prependListener(e,t)}prependListenerOnce(e,t){return this.#Lt.prependListenerOnce(e,t)}appendListener(e,t){return this.#Lt.appendListener(e,t)}appendListenerOnce(e,t){return this.#Lt.appendListenerOnce(e,t)}on(e,t){return this.#Lt.on(e,t)}once(e,t){return this.#Lt.once(e,t)}off(e,t){return this.#Lt.off(e,t)}offAll(e){return this.#Lt.offAll(e)}offAllTypes(){return this.#Lt.offAllTypes()}listenerCount(e){return this.#Lt.listenerCount(e)}listeners(e){return this.#Lt.listeners(e)}onceListeners(e){return this.#Lt.onceListeners(e)}allListeners(e){return this.#Lt.allListeners(e)}eventNames(){return this.#Lt.eventNames()}emit(e,...t){return this.#Lt.emit(e,...t)}setMaxListeners(e){return this.#Lt.setMaxListeners(e)}getMaxListeners(){return this.#Lt.getMaxListeners()}static hasJsonType(e){return Bt.has(e)&&Pt.has(e)||Ft.has(e)}static registerJsonType(e,t,r,n=!1){if(Ft.has(e))throw new Error(`Cannot register type "${e}" because it is frozen.`);Bt.set(e,t),Pt.set(e,r),n&&Ft.add(e)}static deleteJsonType(e){if(Ft.has(e))throw new Error(`Cannot remove type "${e}" because it is frozen.`);let t=!1;return Bt.delete(e)&&(t=!0),Pt.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 Bt.entries())if("string"!=typeof t&&e instanceof t||typeof e===t)return r(e,Wt.encodeSpecialJson);if(Array.isArray(e))return e.map(Wt.encodeSpecialJson);if(f(e)){const t={};for(const r in e)t[r]=Wt.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(Wt.decodeSpecialJson);if(t){for(const[t,r]of Pt.entries())if(r.check&&r.check(e))return r.decode(e,Wt.decodeSpecialJson);const t={};for(const r in e)t[r]=Wt.decodeSpecialJson(e[r]);return t}return e}#Er=window.localStorage;#Tr=null;#ee=0;#Sr=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.#Tr=`LSDB::${e}`),window.addEventListener("storage",this.#Sr)}#xr(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.#Tr)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.#Tr),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.#Tr,String(e)),this.#ee=e)}getDbKey(){return this.#Tr}getVersion(){return this.#ee}setLocalStorage(e){if(!(e instanceof Storage))throw new TypeError("Argument must be a valid instance of Storage.");this.#Er=e}localStorageExists(){return this.#Er instanceof Storage}#Ar(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return Wt.encodeSpecialJson(t)}setJson(e,t){if(this.#xr(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.#Ar(e,t);return this.emit("setJson",e,t),this.#Er.setItem(e,JSON.stringify(r))}#Cr(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const r=this.#Er.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:Wt.decodeSpecialJson(o),fallback:i}}getJson(e,t){const{decoded:r,fallback:n}=this.#Cr(e,t);return r instanceof Map||r instanceof Set||Array.isArray(r)||f(r)?r:n}setDate(e,t){if(this.#xr(e),!(t instanceof Date))throw new TypeError("Value must be a Date.");const r=this.#Ar(e,t);return this.emit("setDate",e,t),this.#Er.setItem(e,JSON.stringify(r))}getDate(e){const t=this.#Cr(e).decoded;return t instanceof Date?t:null}setRegExp(e,t){if(this.#xr(e),!(t instanceof RegExp))throw new TypeError("Value must be a RegExp.");const r=this.#Ar(e,t);return this.emit("setRegExp",e,t),this.#Er.setItem(e,JSON.stringify(r))}getRegExp(e){const t=this.#Cr(e).decoded;return t instanceof RegExp?t:null}setBigInt(e,t){if(this.#xr(e),"bigint"!=typeof t)throw new TypeError("Value must be a BigInt.");const r=this.#Ar(e,t);return this.emit("setBigInt",e,t),this.#Er.setItem(e,JSON.stringify(r))}getBigInt(e){const t=this.#Cr(e).decoded;return"bigint"==typeof t?t:null}setSymbol(e,t){if(this.#xr(e),"symbol"!=typeof t)throw new TypeError("Value must be a Symbol.");const r=this.#Ar(e,t);return this.emit("setSymbol",e,t),this.#Er.setItem(e,JSON.stringify(r))}getSymbol(e){const t=this.#Cr(e).decoded;return"symbol"==typeof t?t:null}getValue(e){return this.#Cr(e).decoded??null}setItem(e,t){if(this.#xr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("setItem",e,t),this.#Er.setItem(e,t)}getItem(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.#Er.getItem(e)}setString(e,t){if(this.#xr(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.#Er.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.#Er.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.#xr(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.#Er.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.#Er.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.#xr(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.#Er.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.#Er.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.#Er.removeItem(e)}clearLocalStorage(){return this.#Er.clear()}destroy(){window.removeEventListener("storage",this.#Sr),this.#Lt.offAllTypes()}}Wt.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),Wt.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),Wt.registerJsonType(Date,e=>({__date__:!0,value:e.toISOString()}),{check:e=>e.__date__,decode:e=>new Date(e.value)},!0),Wt.registerJsonType(RegExp,e=>({__regexp__:!0,source:e.source,flags:e.flags}),{check:e=>e.__regexp__,decode:e=>new RegExp(e.source,e.flags)},!0),Wt.registerJsonType("number",e=>({__number__:!0,value:e.toString()}),{check:e=>e.__number__,decode:e=>Number(e.value)},!0),Wt.registerJsonType("bigint",e=>({__bigint__:!0,value:e.toString()}),{check:e=>e.__bigint__,decode:e=>BigInt(e.value)},!0),Wt.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 zt=Wt,qt=new WeakMap,Vt=class{#Lt=new kt;setThrowOnMaxListeners(e){return this.#Lt.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#Lt.getThrowOnMaxListeners()}prependListener(e,t){return this.#Lt.prependListener(e,t)}prependListenerOnce(e,t){return this.#Lt.prependListenerOnce(e,t)}appendListener(e,t){return this.#Lt.appendListener(e,t)}appendListenerOnce(e,t){return this.#Lt.appendListenerOnce(e,t)}on(e,t){return this.#Lt.on(e,t)}once(e,t){return this.#Lt.once(e,t)}off(e,t){return this.#Lt.off(e,t)}offAll(e){return this.#Lt.offAll(e)}offAllTypes(){return this.#Lt.offAllTypes()}listenerCount(e){return this.#Lt.listenerCount(e)}listeners(e){return this.#Lt.listeners(e)}onceListeners(e){return this.#Lt.onceListeners(e)}allListeners(e){return this.#Lt.allListeners(e)}eventNames(){return this.#Lt.eventNames()}setMaxListeners(e){return this.#Lt.setMaxListeners(e)}getMaxListeners(){return this.#Lt.getMaxListeners()}#Ir;get targetWindow(){return this.#Ir}#Mr;get targetIframeElement(){return this.#Mr}#Lr;get targetOrigin(){return this.#Lr}#kr;get selfType(){return this.#kr}#gr=!1;#Nr=!1;get ready(){return this.#Nr}onReady(e){this.#Nr?e():this.#Lt.once(this.#_r,e)}#Dr=null;#jr=[];#Rr;#Or;#_r;#Hr=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.#Mr=e,this.#Ir=e?.contentWindow??window.parent,this.#Lr=t,this.#kr=e?"parent":"iframe",this.#Rr=r,this.#Or=n,this.#_r=i,qt.has(this.#Ir))throw new Error("Duplicate window reference.");this._boundWindowMessage=this.#$r.bind(this),this._boundPortMessage=this.#Br.bind(this),this.#Pr(),qt.set(this.#Ir,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.#Or}set handshakeEventName(e){if("string"!=typeof e)throw new TypeError("TinyIframeEvents: handshakeEventName must be a string.");this.#Or=e}get readyEventName(){return this.#_r}set readyEventName(e){if("string"!=typeof e)throw new TypeError("TinyIframeEvents: readyEventName must be a string.");this.#_r=e}#Pr(){"parent"===this.#kr?(this.#Hr=()=>{if(this.#gr)return;this.#Dr&&this.#Dr.close();const e=new MessageChannel;this.#Dr=e.port1,this.#Dr.onmessage=this._boundPortMessage,this.#Nr=!1,this.#Ir.postMessage({type:this.#Or},this.#Lr,[e.port2])},this.#Mr&&(this.#Mr.addEventListener("load",this.#Hr),this.#Hr())):window.addEventListener("message",this._boundWindowMessage,!1)}#$r(e){const t=e.data,r=e.ports;f(t)&&t.type===this.#Or&&0!==r.length&&(this.#Dr=r[0],this.#Dr.onmessage=this._boundPortMessage,window.removeEventListener("message",this._boundWindowMessage),this.#Dr.postMessage({type:`${this.#Or}_ACK`}),this.#Fr())}#Br(e){const t=e.data;if(f(t)&&t.type===`${this.#Or}_ACK`)return void this.#Fr();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.#Lt.emit(r,n,e)}#Fr(){this.#Nr||(this.#Nr=!0,this.#Wr(),this.#Lt.emit(this.#_r))}#Wr(){for(;this.#jr.length>0;){const e=this.#jr.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.#gr)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.#Nr&&this.#Dr?this.#Dr.postMessage(r):this.#jr.push(r)}isDestroyed(){return this.#gr}destroy(){this.#gr=!0,this.#Nr=!1,window.removeEventListener("message",this._boundWindowMessage),this.#Mr&&this.#Hr&&this.#Mr.removeEventListener("load",this.#Hr),this.#Dr&&(this.#Dr.close(),this.#Dr=null),this.#Lt.offAllTypes(),this.#jr=[],qt.delete(this.#Ir)}},Ut=new WeakMap,Kt=class{#Lt=new kt;setThrowOnMaxListeners(e){return this.#Lt.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#Lt.getThrowOnMaxListeners()}prependListener(e,t){return this.#Lt.prependListener(e,t)}prependListenerOnce(e,t){return this.#Lt.prependListenerOnce(e,t)}appendListener(e,t){return this.#Lt.appendListener(e,t)}appendListenerOnce(e,t){return this.#Lt.appendListenerOnce(e,t)}on(e,t){return this.#Lt.on(e,t)}once(e,t){return this.#Lt.once(e,t)}off(e,t){return this.#Lt.off(e,t)}offAll(e){return this.#Lt.offAll(e)}offAllTypes(){return this.#Lt.offAllTypes()}listenerCount(e){return this.#Lt.listenerCount(e)}listeners(e){return this.#Lt.listeners(e)}onceListeners(e){return this.#Lt.onceListeners(e)}allListeners(e){return this.#Lt.allListeners(e)}eventNames(){return this.#Lt.eventNames()}setMaxListeners(e){return this.#Lt.setMaxListeners(e)}getMaxListeners(){return this.#Lt.getMaxListeners()}#zr;#Lr;#jr=[];#Nr=!1;#qr=!1;#Vr=null;#_r="__TNE_READY__";#Ur="__TNE_ROUTE__";get readyEventName(){return this.#_r}set readyEventName(e){if("string"!=typeof e)throw new TypeError("TinyNewWinEvents: readyEventName must be a string.");this.#_r=e}get routeEventName(){return this.#Ur}set routeEventName(e){if("string"!=typeof e)throw new TypeError("TinyNewWinEvents: routeEventName must be a string.");this.#Ur=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.#qr=!0),!this.#zr||Ut.has(this.#zr))throw new Error("Invalid or duplicate window reference.");this.#Lr=e??window.location.origin,this._handleMessage=this.#Kr.bind(this),window.addEventListener("message",this._handleMessage,!1),this.#qr||(this.#Jr(this.#_r,null),this.#Gr())}getWin(){return this.#zr}#Kr(e){if(!e.source||this.#zr&&e.source!==this.#zr)return;const{type:t,route:r,payload:n}=e.data||{};if(t===this.#_r)return this.#Nr=!0,this.#Wr(),this.#Gr(),void(this.#qr&&this.#Jr(this.#_r,null));t===this.#Ur&&this.#Lt.emit(r,n,e)}#Wr(){for(;this.#jr.length;){const e=this.#jr.shift();if(e){const{route:t,payload:r}=e;this.emit(t,r)}}}#Jr(e,t,r=""){this.#zr&&this.#zr.closed||this.#zr?.postMessage({type:e,route:r,payload:t},this.#Lr)}close(){if(!this.#qr)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.#Nr?this.#Jr(this.#Ur,t,e):this.#jr.push({route:e,payload:t})}isConnected(){return!(!this.#Nr||!this.#zr||this.#zr.closed)}#Gr(){this.#zr&&!this.#Vr&&(this.#Vr=setInterval(()=>{this.#zr?.closed&&(this.#Lt.emit("WINDOW_REF_CLOSED"),this.destroy())},500),Ut.set(this.#zr,this.#Vr))}onClose(e){return this.#Lt.on("WINDOW_REF_CLOSED",e)}offClose(e){return this.#Lt.off("WINDOW_REF_CLOSED",e)}isDestroyed(){return!this.#zr}destroy(){this.#zr&&(this.#Vr&&(clearInterval(this.#Vr),this.#Vr=null,Ut.delete(this.#zr)),window.removeEventListener("message",this._handleMessage),this.#jr=[],this.#Nr=!1,this.#zr=null,this.#Lt.offAllTypes())}},Jt=class{#Yr;#Xr;#Qr;#Zr=0;#en=0;#tn;#rn=null;#nn=null;get lineHeight(){return this.#Yr}get maxRows(){return this.#Xr-1}get extraHeight(){return this.#Qr}get currentHeight(){return this.#Zr}get currentRows(){return this.#en}get textarea(){return this.#tn}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.#tn=e,this.#Xr=(t.maxRows??5)+1,this.#Qr=t.extraHeight??0,this.#rn=t.onResize??null,this.#nn=t.onInput??null,this.#Yr=this.#in(),e.style.overflowY="hidden",e.style.resize="none",this._handleInput=()=>this.#on(),e.addEventListener("input",this._handleInput),this.#on()}#on(){this.#tn.style.height="auto";const e=window.getComputedStyle(this.#tn),t=parseFloat(e.paddingTop)||0,r=parseFloat(e.paddingBottom)||0,n=(this.#tn.value.match(/\n/g)||[]).length,i=this.#tn.scrollHeight,o=this.#Yr*this.#Xr,s=Math.ceil(Math.min(i,o)-t-r+this.#Qr),a=this.#Xr-1,l=n<a?n+1:a;this.#tn.style.height=`${s}px`,this.#tn.style.overflowY=i>o?"auto":"hidden",this.#Zr=s;const u={breakLines:n,rows:l,height:s,scrollHeight:i,maxHeight:o,lineHeight:this.#Yr,maxRows:a};l!==this.#en&&(this.#en=l,"function"==typeof this.#rn&&this.#rn({...u})),"function"==typeof this.#nn&&this.#nn(u)}#in(){const e=window.getComputedStyle(this.#tn),t=parseFloat(e.lineHeight);return Number.isNaN(t)?1.2*parseFloat(e.fontSize):t}getData(){return{rows:this.#en,height:this.#Zr}}refresh(){this.#on()}destroy(){this.#tn.removeEventListener("input",this._handleInput)}};class Gt{#gr=!1;#sn=new Set;#an=new Map;#ln=new Map;#un=null;#hn=[];#cn={};#dn=[];#pn=null;#fn=null;#mn;#gn;#yn;#wn;#bn;#vn;#En;#Tn;#Sn=[];#xn=0;#An=0;#Cn=[];#In=0;#Mn=null;#Ln=new Set;#kn=new Set;#Nn=new Map;#_n=new Map;#Dn=new Map;static#jn={" ":"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);Gt.#jn[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 Gt.#jn[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 Gt.#jn[e]}static getAllSpecialKeys(){return{...Gt.#jn}}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=Gt.#jn[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.#wn=e,this.#mn=t,this.#gn=new Set(r),this.#yn=n,this.#bn=s,this.#vn=a,this.#En=o,this.#Tn=i,["gamepad-only","both"].includes(this.#mn)&&this.#Rn(),["keyboard-only","both"].includes(this.#mn)&&this.#On()}#Hn=e=>this.#$n(e.gamepad);#Bn=e=>this.#Pn(e.gamepad);#Rn(){window.addEventListener("gamepadconnected",this.#Hn),window.addEventListener("gamepaddisconnected",this.#Bn)}#$n(e){this.#gr||this.#gn.has(e.id)||this.#wn&&e.id!==this.#wn||this.#un||(this.#un=e,this.#wn=e.id,this.#Fn(),this.#Wn("connected",{id:e.id,gp:e,timestamp:e.timestamp}))}#Pn(e){this.#gr||this.#un&&e.id===this.#un.id&&(this.#un=null,this.#pn&&(cancelAnimationFrame(this.#pn),this.#pn=null),this.#Wn("disconnected",{id:e.id,gp:e,timestamp:e.timestamp}))}#Fn(){const e=()=>{this.#gr||(this.#zn(),this.#pn=requestAnimationFrame(e))};e()}#zn(){if(this.#gr)return;const e=navigator.getGamepads(),t=Array.from(e).find(e=>e&&e.id===this.#wn);t&&(this.#un=t,t.buttons.forEach((e,r)=>{const n=`Button${r}`,i=this.#hn[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.#qn({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.#hn[r]={pressed:e.pressed,value:"number"==typeof s?s:this.#hn[r]?.value,value2:NaN}}),t.axes.forEach((e,r)=>{Math.abs(e)<this.#yn&&(e=0);const n=`Axis${r}`;e!==(this.#dn[r]??0)&&this.#qn({key:n,source:"gamepad-analog",value:e,value2:NaN,type:"change",timestamp:t.timestamp,id:t.id,gp:t}),this.#dn[r]=e}))}#Vn=e=>{if(!this.#gr){if(!(e instanceof KeyboardEvent))throw new Error("Expected KeyboardEvent in keydown listener.");this.#sn.has(e.code)||(this.#sn.add(e.code),this.#qn({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})}};#Un=e=>{if(!this.#gr){if(!(e instanceof KeyboardEvent))throw new Error("Expected KeyboardEvent in keyup listener.");this.#sn.has(e.code)&&(this.#sn.delete(e.code),this.#qn({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})}};#Kn=e=>{if(this.#gr)return;if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mousedown listener.");const t=`Mouse${e.button}`;this.#sn.add(t),this.#qn({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}};#Jn=e=>{if(this.#gr)return;if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mouseup listener.");const t=`Mouse${e.button}`;this.#sn.delete(t),this.#qn({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}};#Gn=e=>{if(!this.#gr){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.#qn({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}}}};#On(){this.#vn.addEventListener("keydown",this.#Vn),this.#vn.addEventListener("keyup",this.#Un),this.#bn&&(this.#vn.addEventListener("mousedown",this.#Kn),this.#vn.addEventListener("mouseup",this.#Jn),this.#vn.addEventListener("mousemove",this.#Gn));const e=()=>{this.#gr||(this.#sn.forEach(e=>{const t=e.startsWith("Mouse")?"mouse":"keyboard";this.#qn({key:e,source:t,id:`native_${t}`,value:1,value2:NaN,type:"hold",pressed:!0,prevPressed:this.#cn[e]?.pressed??!1,timestamp:NaN})}),this.#fn=requestAnimationFrame(e))};e()}#qn(e){if(this.#gr)return;const t=this.#ln.get("input-*")||[],{pressed:r,key:n}=e,i=n.startsWith("Axis"),o="boolean"==typeof r&&r||i&&(e.value>this.#Tn||e.value<-Math.abs(this.#Tn)),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.#Ln.has(n)||i&&!this.#Ln.has(n)&&!this.#Ln.has(`${n}+`)&&!this.#Ln.has(`${n}-`)){0===this.#In&&(this.#In=Date.now()),this.#Ln.add(s),a=!0,this.#Cn.push(s),this.#Sn.length<1&&(this.#Mn&&clearTimeout(this.#Mn),this.#Mn=setTimeout(()=>this.resetComboMapped(),this.#En));const e=this.#ln.get("mapped-key-start")??[];for(const t of e)t({key:s,activeTime:this.#In})}}else if(!i&&this.#Ln.has(n)||i&&(this.#Ln.has(n)||this.#Ln.has(`${n}+`)||this.#Ln.has(`${n}-`))){this.#Ln.delete(n),this.#Ln.delete(`${n}+`),this.#Ln.delete(`${n}-`),a=!1;const e=this.#ln.get("mapped-key-end")??[];for(const t of e)t({key:s,activeTime:this.#In})}for(const{sequence:e,callback:t,triggered:r}of this.#_n.values()){const n=this.#_n.get(e.join("+"));if(!n)continue;const i=e.every((e,t)=>this.#Cn[t]===e);i&&!r?(n.triggered=!0,t(this.#In)):!i&&r&&(n.triggered=!1)}}for(const[r,l]of this.#an.entries()){const u=e=>"string"==typeof l&&e===l||Array.isArray(l)&&l.findIndex((t,r)=>e===l[r])>-1,h=u(s),c=i&&u(`${n}+`),d=i&&u(`${n}-`);if(h||c||d){if(o&&h){if(a||!this.#kn.has(r)){0===this.#An&&(this.#An=Date.now()),this.#kn.add(r),0===this.#xn&&(this.#xn=Date.now()),this.#Mn&&clearTimeout(this.#Mn),this.#Sn.push(r),this.#Mn=setTimeout(()=>this.resetComboMapped(),this.#En);const e=this.#ln.get("mapped-input-start")??[];for(const t of e)t({logicalName:r,activeTime:this.#An,comboTime:this.#xn})}}else if(!a||this.#kn.has(r)){this.#kn.delete(r),this.#kn.size<1&&(this.#An=0);const e=this.#ln.get("mapped-input-end")??[];for(const t of e)t({logicalName:r,activeTime:this.#An,comboTime:this.#xn})}for(const{sequence:e,callback:t,triggered:r}of this.#Nn.values()){const n=this.#Nn.get(e.join("+"));if(!n)continue;const i=Array.from(this.#kn),o=e.every((e,t)=>i[t]===e);o&&!r?(n.triggered=!0,t(this.#An)):!o&&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(s);p.forEach(n=>{if(!("*"===l||l===n||Array.isArray(l)&&l.includes(n)))return;const i=this.#ln.get(`input-${e.type}-${r}`)||[],o=this.#ln.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.#Dn.set(n,{value:e.value,value2:e.value2})})}}#Wn(e,t){const r=this.#ln.get(e)||[];for(const e of r)e(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=r.replace("{logicalName}",e);let i=this.#ln.get(n);Array.isArray(i)||(i=[],this.#ln.set(n,i)),i.push(t)}#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=i=>{this.#Qn(e,n,r),t(i)};this.#Yn(e,n,r)}#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),i=this.#ln.get(n)??[];i.unshift(t),this.#ln.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.#ln.get(n);Array.isArray(i)&&this.#ln.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:h})=>{(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.#an.set(e,t)}unmapInput(e){if("string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);this.#an.delete(e)}hasMappedInput(e){if("string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);return this.#an.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.#an.get(e);if(!t)throw new Error(`No physical input mapped for logicalName: "${e}"`);return t}clearMapInputs(){this.#an.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.#Nn.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.#Nn.delete(t)}unregisterAllInputSequences(){this.#Nn.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.#Nn.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.#_n.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.#_n.delete(t)}unregisterAllKeySequences(){this.#_n.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.#_n.has(t)}renewComboMapped(){this.#Mn&&(clearTimeout(this.#Mn),this.#Mn=setTimeout(()=>this.resetComboMapped(),this.#En))}resetComboMapped(){this.#Mn&&clearTimeout(this.#Mn),this.#Cn=[],this.#Mn=null,this.#In=0,this.#Sn=[],this.#xn=0}onMappedKeyStart(e){return this.#Yn("",e,"mapped-key-start")}onceMappedKeyStart(e){return this.#Xn("",e,"mapped-key-start")}prependMappedKeyStart(e){return this.#Zn("",e,"mapped-key-start")}offMappedKeyStart(e){return this.#Qn("",e,"mapped-key-start")}offAllMappedKeyStart(){this.#ln.delete("mapped-key-start")}onMappedKeyEnd(e){return this.#Yn("",e,"mapped-key-end")}onceMappedKeyEnd(e){return this.#Xn("",e,"mapped-key-end")}prependMappedKeyEnd(e){return this.#Zn("",e,"mapped-key-end")}offMappedKeyEnd(e){return this.#Qn("",e,"mapped-key-end")}offAllMappedKeyEnd(){this.#ln.delete("mapped-key-end")}onMappedInputStart(e){return this.#Yn("",e,"mapped-input-start")}onceMappedInputStart(e){return this.#Xn("",e,"mapped-input-start")}prependMappedInputStart(e){return this.#Zn("",e,"mapped-input-start")}offMappedInputStart(e){return this.#Qn("",e,"mapped-input-start")}offAllMappedInputStart(){this.#ln.delete("mapped-input-start")}onMappedInputEnd(e){return this.#Yn("",e,"mapped-input-end")}onceMappedInputEnd(e){return this.#Xn("",e,"mapped-input-end")}prependMappedInputEnd(e){return this.#Zn("",e,"mapped-input-end")}offMappedInputEnd(e){return this.#Qn("",e,"mapped-input-end")}offAllMappedInputEnd(){this.#ln.delete("mapped-input-end")}onInput(e,t){return this.#Yn(e,t,"input-{logicalName}")}onceInput(e,t){return this.#Xn(e,t,"input-{logicalName}")}prependInput(e,t){return this.#Zn(e,t,"input-{logicalName}")}offInput(e,t){return this.#Qn(e,t,"input-{logicalName}")}onInputStart(e,t){return this.#Yn(e,t,"input-down-{logicalName}")}onceInputStart(e,t){return this.#Xn(e,t,"input-down-{logicalName}")}prependInputStart(e,t){return this.#Zn(e,t,"input-down-{logicalName}")}offInputStart(e,t){return this.#Qn(e,t,"input-down-{logicalName}")}onInputEnd(e,t){return this.#Yn(e,t,"input-up-{logicalName}")}onceInputEnd(e,t){return this.#Xn(e,t,"input-up-{logicalName}")}prependInputEnd(e,t){return this.#Zn(e,t,"input-up-{logicalName}")}offInputEnd(e,t){return this.#Qn(e,t,"input-up-{logicalName}")}onInputHold(e,t){return this.#Yn(e,t,"input-hold-{logicalName}")}onceInputHold(e,t){return this.#Xn(e,t,"input-hold-{logicalName}")}prependInputHold(e,t){return this.#Zn(e,t,"input-hold-{logicalName}")}offInputHold(e,t){return this.#Qn(e,t,"input-hold-{logicalName}")}onInputChange(e,t){return this.#Yn(e,t,"input-change-{logicalName}")}onceInputChange(e,t){return this.#Xn(e,t,"input-change-{logicalName}")}prependInputChange(e,t){return this.#Zn(e,t,"input-change-{logicalName}")}offInputChange(e,t){return this.#Qn(e,t,"input-change-{logicalName}")}onInputMove(e,t){return this.#Yn(e,t,"input-move-{logicalName}")}onceInputMove(e,t){return this.#Xn(e,t,"input-move-{logicalName}")}prependInputMove(e,t){return this.#Zn(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.#ln.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.#ln.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.#ln.get(`${n}${e}`);return Array.isArray(i)?i.length:0}#ei={type:"dual-rumble",params:{startDelay:0,duration:200,weakMagnitude:.5,strongMagnitude:1}};get defaultHapticEffect(){return{type:this.#ei.type,params:{...this.#ei.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.#ei.type=e,this.#ei.params=t}hasHapticEffect(){const e=this.#un;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.#un;if(!r)return new Promise(e=>e("complete"));const n=r.vibrationActuator;return n instanceof GamepadHapticActuator?n.playEffect(t??this.#ei.type,{...this.#ei.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.#gn.add(e)}unignoreId(e){if("string"!=typeof e||""===e.trim())throw new TypeError(`"id" must be a non-empty string, received ${e}`);this.#gn.delete(e)}onConnected(e){return this.#Yn("",e,"connected")}onceConnected(e){return this.#Xn("",e,"connected")}prependConnected(e){return this.#Zn("",e,"connected")}offConnected(e){return this.#Qn("",e,"connected")}offAllConnected(){this.#ln.delete("connected")}onDisconnected(e){return this.#Yn("",e,"disconnected")}onceDisconnected(e){return this.#Xn("",e,"disconnected")}prependDisconnected(e){return this.#Zn("",e,"disconnected")}offDisconnected(e){return this.#Qn("",e,"disconnected")}offAllDisconnected(){this.#ln.delete("disconnected")}hasGamepad(){return this.#un instanceof Gamepad}getGamepad(){if(!this.#un)throw new Error("No gamepad is currently connected.");return this.#un}hasLastButtonState(e){return!!this.#hn[e]}getLastButtonState(e){if(!this.#hn[e])throw new Error(`No last button state found for index ${e}`);return{...this.#hn[e]}}exportConfig(){return{expectedId:this.#wn,ignoreIds:Array.from(this.#gn),deadZone:this.#yn,timeoutComboKeys:this.#En,axisActiveSensitivity:this.#Tn,inputMap:Array.from(this.#an.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.#wn=t.expectedId),Array.isArray(t.ignoreIds)&&(this.#gn=new Set(t.ignoreIds)),"number"==typeof t.deadZone&&(this.#yn=t.deadZone),"number"==typeof t.timeoutComboKeys&&(this.#En=t.timeoutComboKeys),"number"==typeof t.axisActiveSensitivity&&(this.#Tn=t.axisActiveSensitivity),Array.isArray(t.inputMap)&&(this.#an=new Map(t.inputMap))}get mappedKeyStartCalls(){const e=this.#ln.get("mapped-key-start");return Array.isArray(e)?[...e]:[]}get mappedKeyEndCalls(){const e=this.#ln.get("mapped-key-end");return Array.isArray(e)?[...e]:[]}get comboMappedKeys(){return[...this.#Cn]}get comboMappedInputs(){return[...this.#Sn]}get keySequenceSize(){return this.#_n.size}get keySequences(){const e=[];for(const[,t]of this.#_n.entries())e.push(t.callback);return e}get activeMappedKeys(){return[...this.#Ln]}get mappedInputStartCalls(){const e=this.#ln.get("mapped-input-start");return Array.isArray(e)?[...e]:[]}get mappedInputEndCalls(){const e=this.#ln.get("mapped-input-end");return Array.isArray(e)?[...e]:[]}get inputSequenceSize(){return this.#Nn.size}get inputSequences(){const e=[];for(const[,t]of this.#Nn.entries())e.push(t.callback);return e}get activeMappedInputs(){return[...this.#kn]}get mappedInputs(){const e={};for(const[t,r]of this.#an.entries())e[t]=r;return e}get mappedInputSize(){return this.#an.size}get connectedCalls(){const e=this.#ln.get("connected");return Array.isArray(e)?[...e]:[]}get disconnectedCalls(){const e=this.#ln.get("disconnected");return Array.isArray(e)?[...e]:[]}get ignoredDeviceIds(){return[...this.#gn]}get heldKeys(){return[...this.#sn]}get eventsSize(){let e=0;return this.#ln.forEach(t=>{e+=t.length}),e}get callSize(){return this.#ln.size}get connectedCallSize(){const e=this.#ln.get("connected");return Array.isArray(e)?e.length:0}get disconnectedCallSize(){const e=this.#ln.get("disconnected");return Array.isArray(e)?e.length:0}get mappedKeyStartCallSize(){const e=this.#ln.get("mapped-key-start");return Array.isArray(e)?e.length:0}get mappedKeyEndCallSize(){const e=this.#ln.get("mapped-key-end");return Array.isArray(e)?e.length:0}get mappedInputStartCallSize(){const e=this.#ln.get("mapped-input-start");return Array.isArray(e)?e.length:0}get mappedInputEndCallSize(){const e=this.#ln.get("mapped-input-end");return Array.isArray(e)?e.length:0}get lastButtonStates(){const e=[];return this.#hn.forEach(t=>{e.push({...t})}),e}get lastAxes(){return[...this.#dn]}get inputMode(){return this.#mn}get elementBase(){return this.#vn}get timeComboInputs(){return this.#xn}get timeComboKeys(){return this.#In}get timeMappedInputs(){return this.#An}get timeoutComboKeys(){return this.#En}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.#En=e}get axisActiveSensitivity(){return this.#Tn}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.#Tn=e}get deadZone(){return this.#yn}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.#yn=e}get expectedId(){return this.#wn}set expectedId(e){if("string"!=typeof e)throw new TypeError("Expected device id be a string.");this.#wn=e}get isDestroyed(){return this.#gr}destroy(){this.#gr||(this.#gr=!0,this.#pn&&cancelAnimationFrame(this.#pn),this.#fn&&cancelAnimationFrame(this.#fn),this.#pn=null,this.#fn=null,["keyboard-only","both"].includes(this.#mn)&&(this.#vn.removeEventListener("keydown",this.#Vn),this.#vn.removeEventListener("keyup",this.#Un),this.#bn&&(this.#vn.removeEventListener("mousedown",this.#Kn),this.#vn.removeEventListener("mouseup",this.#Jn),this.#vn.removeEventListener("mousemove",this.#Gn))),["gamepad-only","both"].includes(this.#mn)&&(window.removeEventListener("gamepadconnected",this.#Hn),window.removeEventListener("gamepaddisconnected",this.#Bn)),this.resetComboMapped(),this.#an.clear(),this.#ln.clear(),this.#sn.clear(),this.#kn.clear(),this.#Ln.clear(),this.#Nn.clear(),this.#_n.clear(),this.#gn.clear(),this.#Dn.clear(),this.#hn=[],this.#dn=[],this.#cn={},this.#un=null,this.#wn=null,this.#bn=!1,this.#An=0)}}const Yt=Gt,Xt=class{#ti=!0;#ri=86400;#ni=3600;#ii=60;#oi=new Map;#si=[];#ai;#li;#ui={main:null};#hi=0;#ci=0;#di=0;#pi="";#fi=1;#mi=1;#gi=1;#gr=!1;#yi=[31,31,31,31,31,31,31,31,31,31,31,31];#wi={default:{},day:{},night:{},hours:{},seasons:{}};#bi={min:60,max:180};#vi=0;get daySize(){return this.#ri}get autoSizeAdjuste(){return this.#ti}set autoSizeAdjuste(e){if("boolean"!=typeof e)throw new TypeError("autoSizeAdjuste must be a boolean.");this.#ti=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.#ni/this.#ri,r=this.#ii/this.#ri;this.#ri=e,this.#ti&&(this.#ni=e*t,this.#ii=e*r)}get hourSize(){return this.#ni}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.#ri/this.#ni,r=this.#ii/this.#ni;this.#ni=e,this.#ti&&(this.#ri=e*t,this.#ii=e*r)}get minuteSize(){return this.#ii}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.#ni/this.#ii,r=this.#ri/this.#ii;this.#ii=e,this.#ti&&(this.#ni=e*t,this.#ri=e*r)}get isDestroyed(){return this.#gr}get currentSeconds(){return this.#hi}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.#ri)throw new RangeError(`currentSeconds must be between 0 and 86399, received ${e}`);this.#hi=Math.floor(e),this.#ci=Math.floor(e/this.#ii),this.#di=Math.floor(e/this.#ni)}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.#di=Math.floor(e/this.#ii),this.#hi=Math.floor(e*this.#ii)}get currentHours(){return this.#di}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.#di=Math.floor(e),this.#ci=Math.floor(e*this.#ii),this.#hi=Math.floor(e*this.#ni)}get moons(){return this.#si.map(e=>this.getMoon(e))}get seasons(){return Array.from(this.#oi.keys())}get dayStart(){return this.#ai}get nightStart(){return this.#li}get weather(){return{...this.#ui}}get currentSeason(){return this.#pi}get currentDay(){return this.#fi}get currentMonth(){return this.#mi}get currentYear(){return this.#gi}get monthDays(){return[...this.#yi]}get weatherDuration(){return{...this.#bi}}get weatherTimeLeft(){return this.#vi}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.#ai=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.#li=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.#ui=e}set currentSeason(e){if(this._checkDestroyed(),"string"!=typeof e||!this.#oi.has(e))throw new TypeError(`currentSeason must be one of ${Array.from(this.#oi).map(e=>e[0]).join(", ")}, received ${e}`);this.#pi=e}set currentDay(e){if(this._checkDestroyed(),"number"!=typeof e||e<1||e>this.#yi[this.#mi-1])throw new TypeError("currentDay must be a valid day number, received "+typeof e);this.#fi=e}set currentMonth(e){if(this._checkDestroyed(),"number"!=typeof e||"number"!=typeof this.#yi[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.#gi=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.#yi=[...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.#bi={...e}}set weatherTimeLeft(e){if(this._checkDestroyed(),"number"!=typeof e)throw new TypeError("weatherTimeLeft must be a number, received "+typeof e);this.#vi=e}get weatherConfig(){const e={},t={};for(const t in this.#wi.hours)e[t]={...this.#wi.hours[t]};for(const e in this.#wi.seasons)t[e]={...this.#wi.seasons[e]};return{default:{...this.#wi.default},day:{...this.#wi.day},night:{...this.#wi.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.#wi={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.#ai=e,this.#li=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.#oi.set(e,t)}removeSeason(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);this.#oi.delete(e),this.#pi===e&&(this.#pi="")}hasSeason(e){if("string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);return this.#oi.has(e)}getSeason(e){if("string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);const t=this.#oi.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.#ni+t*this.#ii+r)%this.#ri}addTime({hours:e=0,minutes:t=0,seconds:r=0}){this._checkDestroyed();let n=this.currentSeconds+e*this.#ni+t*this.#ii+r;for(;n>=this.#ri;)n-=this.#ri,this.nextDay();for(;n<0;)n+=this.#ri,this.prevDay();this.currentSeconds=n,this.updateWeatherTimer((e*this.#ni+t*this.#ii+r)/this.#ii)}getTime({withSeconds:e=!1,hourSize:t=this.#ni,minuteSize:r=this.#ii}={}){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.#ai<this.#li?this.#ci>=this.#ai*this.#ii&&this.#ci<this.#li*this.#ii:this.#ci>=this.#ai*this.#ii||this.#ci<this.#li*this.#ii}minutesUntilDay(){return this.timeUntil(this.#ai,"minutes")}secondsUntilDay(){return this.timeUntil(this.#ai,"seconds")}hoursUntilDay(){return this.timeUntil(this.#ai,"hours")}minutesUntilNight(){return this.timeUntil(this.#li,"minutes")}secondsUntilNight(){return this.timeUntil(this.#li,"seconds")}hoursUntilNight(){return this.timeUntil(this.#li,"hours")}timeUntil(e,t){this._checkDestroyed();let r=e*this.#ni-this.#hi;switch(r<=0&&(r+=this.#ri),t){case"minutes":return r/this.#ii;case"hours":return r/this.#ni;default:return r}}setTo(e){this._checkDestroyed(),"day"===e?this.setTime({hour:this.#ai}):"night"===e&&this.setTime({hour:this.#li})}nextDay(e=1){this._checkDestroyed();for(let t=0;t<e;t++){this.#fi++;const e=this.#yi[this.#mi-1];if(Number.isNaN(e)||!Number.isFinite(e))throw new Error("Invalid month day count: monthDays must be a finite number.");this.#fi>e&&(this.#fi=1,this.#mi++,this.#mi>this.#yi.length&&(this.#mi=1,this.#gi++)),this.updateSeason(),this.advanceMoons(1)}}prevDay(e=1){this._checkDestroyed();for(let t=0;t<e;t++)this.#fi--,this.#fi<1&&(this.#mi--,this.#mi<1&&(this.#mi=this.#yi.length,this.#gi--),this.#fi=this.#yi[this.#mi-1]||30),this.updateSeason(),this.rewindMoons(1)}updateSeason(){this._checkDestroyed(),this.#oi.forEach((e,t)=>{e.includes(this.#mi)&&(this.#pi=t)})}setWeatherConfig(e){this._checkDestroyed(),this.#wi={...this.#wi,...e}}setWeatherDuration(e,t){this._checkDestroyed(),this.#bi.min=e,this.#bi.max=t}updateWeatherTimer(e){this._checkDestroyed(),this.#vi-=e,this.#vi<=0&&this.chooseNewWeather()}forceWeather({where:e="main",type:t,duration:r=null}){this._checkDestroyed();const n=this.#ui;n[e]=t,this.weather=n,this.#vi=r??this._randomInRange(this.#bi.min,this.#bi.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.#ii),minute:this.#ci%this.#ii,currentMinutes:this.#ci,isDay:this.isDay(),season:this.#pi,weather:this.#ui})),"number"!=typeof e||Number.isNaN(e)||(r[t]=(r[t]||0)+e)}};n(this.#wi.default||{});for(const e in this.#wi.hours){const[t,r]=e.split("-").map(e=>{const[t,r]=e.split(":").map(Number);return t*this.#ii+(r||0)}),i=this.#ci;(t<=r?i>=t&&i<=r:i>=t||i<=r)&&n(this.#wi.hours[e])}this.isDay()&&this.#wi.day?n(this.#wi.day):!this.isDay()&&this.#wi.night&&n(this.#wi.night),this.#wi.seasons?.[this.#pi]&&n(this.#wi.seasons[this.#pi]),e&&"object"==typeof e&&n(e);const i=Object.entries(r).filter(([,e])=>e>0);if(!i.length)return this.#ui[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.#ui[t]=e,this.#vi=this._randomInRange(this.#bi.min,this.#bi.max),e;s-=r}return this.#ui[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.#gr)throw new Error("This instance has been destroyed and can no longer be used.")}destroy(){this.#gr||(this.#oi.clear(),this.#si.length=0,this.#ai=0,this.#li=0,this.#hi=0,this.#ci=0,this.#di=0,this.#fi=1,this.#mi=1,this.#gi=1,this.#vi=0,this.#pi="",this.#ui={main:null},this.#yi=[],this.#wi.default={},this.#wi.day={},this.#wi.night={},this.#wi.hours={},this.#wi.seasons={},this.#bi={min:0,max:0},this.#gr=!0)}};class Qt{#Lt=new kt;#Wn(e,...t){return this.#Lt.emit(e,...t)}setThrowOnMaxListeners(e){return this.#Lt.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#Lt.getThrowOnMaxListeners()}prependListener(e,t){return this.#Lt.prependListener(e,t)}prependListenerOnce(e,t){return this.#Lt.prependListenerOnce(e,t)}appendListener(e,t){return this.#Lt.appendListener(e,t)}appendListenerOnce(e,t){return this.#Lt.appendListenerOnce(e,t)}on(e,t){return this.#Lt.on(e,t)}once(e,t){return this.#Lt.once(e,t)}off(e,t){return this.#Lt.off(e,t)}offAll(e){return this.#Lt.offAll(e)}offAllTypes(){return this.#Lt.offAllTypes()}listenerCount(e){return this.#Lt.listenerCount(e)}listeners(e){return this.#Lt.listeners(e)}onceListeners(e){return this.#Lt.onceListeners(e)}allListeners(e){return this.#Lt.allListeners(e)}eventNames(){return this.#Lt.eventNames()}setMaxListeners(e){return this.#Lt.setMaxListeners(e)}getMaxListeners(){return this.#Lt.getMaxListeners()}#gr=!1;#Ei;#Ti;#Si=[];#xi=[];#Ai=[];#Ci=new Map;#Ii=new Set;#Mi=new Map;#Li;#ki=new Map;#Ni=new Map;get isDestroyed(){return this.#gr}get freq(){return Object.fromEntries(this.#Ni)}get size(){return this.#ki.size}get normalization(){return this.#Ei}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.#Ei=e}get seed(){return this.#Ti}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.#Ti=e,null!==e&&(this.#Li=this._makeSeededRng(e))}get globalModifiers(){return[...this.#Si]}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.#Si=e}get temporaryModifiers(){return[...this.#xi]}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.#xi=e}get conditionalRules(){return[...this.#Ai]}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.#Ai=e}get pitySystems(){return Object.fromEntries(this.#Ci)}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.#Ci=e}get exclusions(){return Array.from(this.#Ii)}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.#Ii=e}get groups(){const e={};return this.#Mi.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.#Mi=e}get rng(){return this.#Li}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.#Li=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.#Ei=n,this.#Ti=r,"function"==typeof t?this.#Li=t:null!==this.#Ti?this.#Li=this._makeSeededRng(this.#Ti):this.#Li=Math.random,this.#Ti=r??null}_checkDestroyed(){if(this.#gr)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: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.#ki.set(e,s);for(const t of o)this._ensureGroup(t).add(e);return this.#Wn("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.#ki.get(e);if(!t)return!1;for(const r of t.groups){const t=this.#Mi.get(r);t&&t.delete(e)}return this.#ki.delete(e),this.#Wn("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.#Wn("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.#Si.includes(e)}addGlobalModifier(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");this.#Si.push(e)}removeGlobalModifier(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");this.#Si=this.#Si.filter(t=>t!==e)}hasTemporaryModifier(e){if("function"!=typeof e)throw new TypeError("fn must be a function");return this.#xi.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.#xi.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.#xi.length;return this.#xi=this.#xi.filter(t=>t.fn!==e),this.#xi.length!==t}hasConditionalRule(e){if("function"!=typeof e)throw new TypeError("ruleFn must be a function");return this.#Ai.includes(e)}addConditionalRule(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("ruleFn must be a function");this.#Ai.push(e)}removeConditionalRule(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("ruleFn must be a function");const t=this.#Ai.length;return this.#Ai=this.#Ai.filter(t=>t!==e),this.#Ai.length!==t}hasPity(e){if("string"!=typeof e)throw new TypeError("itemId must be a string");return this.#Ci.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.#Ci.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.#Ci.get(e);t&&(t.counter=0,t.currentAdd=0)}clearPities(){this._checkDestroyed(),this.#Ci.clear()}hasExclusion(e){if("string"!=typeof e)throw new TypeError("itemId must be a string");return this.#Ii.has(e)}excludeItem(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#Ii.add(e)}includeItem(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#Ii.delete(e)}_ensureGroup(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("name must be a string");let t=this.#Mi.get(e);return t||(t=new Set,this.#Mi.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.#Mi.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.#Mi.get(t);r&&r.delete(e);const n=this.#ki.get(e);n&&n.groups.delete(t)}clearFreqs(){this._checkDestroyed(),this.#Ni.clear()}resetFreq(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#Ni.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.#Si){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.#xi){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.#Ai){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.#Ci)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.#Ii)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.#Ei){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.#xi]},r=this.computeEffectiveWeights(t),n=this._weightsToDistribution(r);if(!n.length)return null;const i=this.#Li(),o=n.find(e=>i<=e.cumulative)??n[n.length-1];for(const[e,t]of this.#Ci)e===o.id?(t.counter=0,t.currentAdd=0):t.counter++;this._consumeTemporaryModifiers();const s=this.#ki.get(o.id);if(!s)return null;const a={id:s.id,label:s.label,meta:{...s.meta},prob:o.p};return this.#Wn("draw",a),a&&this.#Ni.set(a.id,(this.#Ni.get(a.id)||0)+1),a}_consumeTemporaryModifiers(){this._checkDestroyed();for(let e=this.#xi.length-1;e>=0;--e){const t=this.#xi[e];t.uses-=1,t.uses<=0&&this.#xi.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.#Ii);for(const e of r)this.#Ii.add(e);const n=this.drawOne({previousDraws:o,metadata:t.metadata});if(this.#Ii=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.#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.#Ci.entries()),exclusions:Array.from(this.#Ii),normalization:this.#Ei,seed:this.#Ti}}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 Qt;return e.#Ei=this.#Ei,e.#Ti=this.#Ti,e.#Si=[...this.#Si],e.#xi=this.#xi.map(e=>({fn:e.fn,uses:e.uses})),e.#Ai=[...this.#Ai],e.#Ci=new Map([...this.#Ci.entries()].map(([e,t])=>[e,{...t}])),e.#Ii=new Set(this.#Ii),e.#Mi=new Map([...this.#Mi.entries()].map(([e,t])=>[e,new Set(t)])),e.#Li=this.#Li,e.#ki=new Map([...this.#ki.entries()].map(([e,t])=>[e,{...t,groups:new Set(t.groups),meta:{...t.meta}}])),e.#Ni=new Map(this.#Ni),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.#gr||(this.#gr=!0,this.#Ci.clear(),this.#Ii.clear(),this.#Mi.clear(),this.#ki.clear(),this.#Ni.clear(),this.#Si=[],this.#xi=[],this.#Ai=[],this.#Ti=null)}}const Zt=Qt,er=class{#ie;get data(){return this.#ie}set data(e){if(!(Array.isArray(e)||e instanceof Set))throw new TypeError("Paginator expects an array or Set as data source.");this.#ie=e}get size(){return Array.isArray(this.#ie)?this.#ie.length:this.#ie.size}constructor(e){if(!(Array.isArray(e)||e instanceof Set))throw new TypeError("Paginator expects an array or Set as data source.");this.#ie=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.#ie)?this.#ie:Array.from(this.#ie);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,h=a>1,c=a<s;return{items:i.slice(l,u),page:a,perPage:t,totalItems:o,totalPages:s,hasPrev:h,hasNext:c}}};class tr{static#_i=new Map;static get itemRegistry(){const e={},t=Object.fromEntries(tr.#_i);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.");tr.#_i.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 tr.#_i.delete(e)}static hasItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");return tr.#_i.has(e)}static getItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");const t=tr.#_i.get(e);if(!t)throw new Error(`Item '${e}' not defined in registry.`);return t}#Di=new Map;#Lt={add:[],remove:[],use:[],set:[]};#ki=[];#ji;#Ri;#Oi;#Hi;get maxStack(){return this.#ji}set maxStack(e){if(!Number.isInteger(e)||Number.isFinite(e)&&e<=0)throw new TypeError(`maxStack must be a positive integer. Received: ${e}`);this.#ji=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.#Oi}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.#Oi=e}get maxWeight(){return this.#Hi}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.#Hi=e}get events(){return{add:[...this.#Lt.add],remove:[...this.#Lt.remove],use:[...this.#Lt.use],set:[...this.#Lt.set]}}get items(){return[...this.#ki].map(e=>e?this.#$i(e):null)}get specialSlots(){return new Map([...this.#Di.entries()].map(([e,t])=>[e,{type:t.type,item:t.item?this.#$i(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=tr.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.#Hi=e.maxWeight??null,this.#Oi=e.maxSlots??null,this.#Ri=e.maxSize??null,this.#ji=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.#Hi&&this.weight+e>this.#Hi}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.#Oi&&this.slotsSize+e>this.#Oi}isFullSlots(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Oi&&this.slotsSize+e>=this.#Oi}#Bi(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.#Lt[e])for(const r of this.#Lt[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.#Lt[e])return;const r=this.#Lt[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.#Lt[e]&&(this.#Lt[e]=[])}cloneEventCallbacks(e){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");return this.#Lt[e]?[...this.#Lt[e]]:[]}onAddItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Lt.add.push(e)}onSetItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Lt.set.push(e)}onRemoveItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Lt.remove.push(e)}onUseItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Lt.use.push(e)}compactInventory(){this.#ki=this.#ki.filter((e,t)=>{const r=null!==e;return r||this.#Bi("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=tr.getItem(e);let o=t;const s=i.maxStack<=this.#ji?i.maxStack:this.#ji,a=[],l=(e,t)=>JSON.stringify(e)===JSON.stringify(t);let u=!0;for(;o>0&&u;){u=!1;for(const t in this.#ki){const h=this.#ki[t];if(h&&h.id===e&&h.quantity<s&&l(h.metadata,r)){const e=Math.min(s-h.quantity,o);if(!n&&!this.hasSpace({weight:i.weight*e,sizeLength:e}))continue;h.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.#Bi("add",{item:this.#$i(h),index:r,isCollection:!0,specialSlot:null,remove:this.#Pi({locationType:"normal",slotIndex:r,forceSpace:n,item:h})}),o<=0)break}}}if(o>0)for(const t in this.#ki)if(null===this.#ki[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.#ki[t]=u,o-=l;const h=Number(t),c=a.findIndex(e=>e.index===h);if(c<0?a.push({index:h,quantity:l}):a[c].quantity+=l,this.#Bi("add",{item:this.#$i(u),index:h,isCollection:!0,specialSlot:null,remove:this.#Pi({locationType:"normal",slotIndex:h,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.#ki.push(l);const u=this.#ki.length-1,h=a.findIndex(e=>e.index===u);h<0?a.push({index:u,quantity:t}):a[h].quantity+=t,this.#Bi("add",{item:this.#$i(l),index:u,isCollection:!0,specialSlot:null,remove:this.#Pi({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.#ki.length)throw new Error(`Slot index '${e}' out of bounds .`);return this.#ki[e]?this.#$i(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?tr.#_i.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.#ji?i.maxStack:this.#ji;if(t.quantity>e)throw new Error(`Item '${t.id}' exceeds max stack size. Allowed: ${e}, got: ${t.quantity}.`)}if(null!==this.#Oi&&(e<0||e>=this.#Oi))throw new Error(`Slot index ${e} out of range.`);const o=this.#ki[e]??null,s=o?tr.#_i.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.#ki.length<=e;)this.#ki.push(null);this.#ki[e]=t,this._cleanNulls(),this.#Bi("set",{index:e,isCollection:!0,item:t?this.#$i(t):null,specialSlot:null,remove:t?this.#Pi({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 o=this.#ki[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.#ki[r]=null),n<=0)return this._cleanNulls(),this.#Bi("remove",{index:t,item:this.#$i(o),isCollection:!0,specialSlot:null,remove:this.#Pi({locationType:"normal",slotIndex:t,item:o})}),!0}}return this._cleanNulls(),this.#Di.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.#Di.set(o,r),this.#Bi("remove",{index:null,item:r.item?this.#$i(r.item):null,isCollection:!1,specialSlot:o,remove:r.item?this.#Pi({locationType:"special",specialSlot:o,item:r.item}):()=>{}})}}),n<=0}#Pi({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.#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: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.#Di.has(t))throw new Error(`Special slot '${t}' not found.`);i=this.#Di.get(t).item,o="special"}else s=this.#ki,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=tr.getItem(i.id);if(a.onUse){const l={inventory:this,item:this.#$i(i),index:e??null,specialSlot:t??null,isCollection:!!s,itemDef:a,remove:this.#Pi({locationType:o,specialSlot:t,slotIndex:e,forceSpace:r,item:i}),...n},u=a.onUse(l);return this.#Bi("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.#$i(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?tr.#_i.get(t.id):null;if(null!==t&&!i)throw new Error(`Item '${t?.id??"unknown"}' not defined in registry.`);const o=this.#Di.get(e);if(!o)throw new Error(`Special slot ${e} out of range for slot '${e}'.`);const s=o.item?tr.#_i.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.#Bi("set",{index:null,item:t?this.#$i(t):null,isCollection:!1,specialSlot:e,remove:t?this.#Pi({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 o=tr.getItem(i.id),s=this.#Di.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.#ji);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.#Di.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.#Di.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.#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,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.#Di.set(e,n),!0}#$i(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.#$i(e):null,t]).filter(e=>null!==e[0])}getAllItems(){const e=[...this.#ki].filter(e=>null!==e).map(this.#$i);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=tr.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.#Lt={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 tr.fromObject(e)}toObject(){const e={};for(const[t,r]of this.#Di.entries())e[t]={type:r?.type??null,item:r?.item?this.#$i(r.item):null};return{__schema:"TinyInventory",version:1,maxWeight:this.#Hi,maxSlots:this.#Oi,maxSize:this.#Ri,maxStack:this.#ji,items:this.#ki.map(e=>e?this.#$i(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 tr({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 tr.fromObject(t)}}const rr=tr,nr=class{#Fi=null;#Wi=null;get sender(){return this.#Fi}get receiver(){return this.#Wi}set sender(e){if(!(e instanceof rr&&this.receiver instanceof rr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Fi=e}set receiver(e){if(!(this.sender instanceof rr&&e instanceof rr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Wi=e}constructor(e,t){if(e||t){if(!(e instanceof rr&&t instanceof rr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.connect(e,t)}}connect(e,t){if(!(e instanceof rr&&t instanceof rr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Fi=e,this.#Wi=t}disconnect(){this.#Fi=null,this.#Wi=null}invert(){const e=this.#Fi,t=this.#Wi;this.#Fi=t,this.#Wi=e}transferItem({slotIndex:e,specialSlot:t,quantity:r=1,receiverSlotIndex:n,forceSpace:i=!1,strict:o=!1}){if(!this.#Fi||!this.#Wi)throw new Error("Sender and receiver inventories must be connected.");let s;if(t){if(s=this.#Fi.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.#Fi.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.#Wi.existsItemAt(n)?this.#Wi.getItemFrom(n):null;if(e){if(e.id!==a.id)throw new Error(`Receiver slot ${n} contains a different item.`);const t=rr.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.#Wi.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.#Wi.existsItemAt(n)?this.#Wi.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=rr.getItem(e.id).maxStack-e.quantity;t=Math.min(r,a.quantity),t>0&&this.#Wi.setItem({slotIndex:n,item:{...e,quantity:e.quantity+t},forceSpace:i})}else this.#Wi.setItem({slotIndex:n,item:a,forceSpace:i});l={remaining:a.quantity-t}}else l=this.#Wi.addItem({itemId:a.id,quantity:a.quantity,metadata:a.metadata,forceSpace:i});const u=a.quantity-l.remaining;if(u>0)if(t)this.#Fi.unequipItem({slotId:t,quantity:u,forceSpace:i});else if("number"==typeof e){const t=s.quantity-u;this.#Fi.setItem({slotIndex:e,item:t>0?{...s,quantity:t}:null,forceSpace:i})}return l}transferMultiple(e){return e.map(e=>this.transferItem(e))}},ir=class{#zi;#qi={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.#qi.storageKey);return e?JSON.parse(e):{}}get config(){return{...this.#qi,categories:[...this.#qi.categories]}}set config(e){this.validateConfig(e),this.#qi=Object.assign(this.#qi,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.#qi.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.#qi.animationDuration)}savePreferences(e){if(!e||"object"!=typeof e)throw new TypeError("Preferences must be an object.");localStorage.setItem(this.#qi.storageKey,JSON.stringify(e)),this.#qi.onSave(e)}showConsentBar(){const e=document.createElement("div");e.className="cookie-consent-bar",e.innerHTML=this.#qi.renderBar?this.#qi.renderBar(this.#qi):`\n <div><p>${this.#qi.message}</p></div>\n <div><button class="accept">${this.#qi.acceptText}</button></div>\n <div><button class="reject">${this.#qi.rejectText}</button></div>\n <div><button class="settings">${this.#qi.settingsText}</button></div>\n `,document.body.appendChild(e);const t=e.querySelector(".accept");t instanceof HTMLElement&&(t.onclick=()=>{const t={};this.#qi.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.#qi.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.#qi.renderModal?this.#qi.renderModal(this.#qi):`\n <div class="modal-content">\n <h2>Cookie Settings</h2>\n <form class="settings-form">\n ${this.#qi.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 or=r(911),sr=r(766);const ar=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,sr.existsSync)(t))throw new Error(`mergeLocaleFiles: file "${t}" does not exist`);const e=await(0,or.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,or.writeFile)(t,JSON.stringify(n,null,r),"utf-8")}#Vi;#Ui;#Ki=null;#Ji;#Gi=null;#Yi=new Map;#Xi=new Map;#Qi=new Map;#Zi=new Map;get currentLocale(){return this.#Ki}get defaultLocale(){return this.#Ui}get mode(){return this.#Vi}get strict(){return this.#Ji}get basePath(){return this.#Gi}get stats(){const e=[];for(const t of this.#Yi.keys())e.push(this.getStatsForLocale(t));return e}get stringTables(){const e={};for(const[t,r]of this.#Yi.entries())e[t]=this.#eo(r);return e}get patternTables(){const e={};for(const[t,r]of this.#Xi.entries())e[t]=r.map(e=>({$pattern:new RegExp(e.$pattern.source,e.$pattern.flags),value:this.#eo(e.value),elseValue:this.#eo(e.elseValue)}));return e}get helpers(){const e={};for(const[t,r]of this.#Qi.entries())e[t]=r;return e}get regexCache(){const e={};for(const[t,r]of this.#Zi.entries())e[t]=new RegExp(r.source,r.flags);return e}#eo(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.#eo(e));if("object"==typeof e){const t={};for(const[r,n]of Object.entries(e))t[r]=this.#eo(n);return t}return e}#to(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.#Yi.has(e)?t.push(e):this.#Ki&&t.push(this.#Ki),t.push(this.#Ui),t}#ro(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.#Yi.get(r);if(e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}}#no(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.#Xi.get(r)||[];for(const r of e)return r.$pattern.test(t)?r.value:r.elseValue??void 0}}#io(e,t){if(null==e){if(this.#Ji)throw new TypeError('#materialize: "value" cannot be null or undefined');return""}if("string"==typeof e)return this.#oo(e,t);if("function"==typeof e)return e(t??{},this.#so());if(e&&"object"==typeof e&&"string"==typeof e.$fn){const r=this.#Qi.get(e.$fn);if("function"!=typeof r){if(this.#Ji)throw new Error(`TinyI18: helper "${e.$fn}" is not registered`);return""}return r({...t??{},args:void 0!==e.args?e.args:void 0},this.#so())}if(this.#Ji)throw new Error("TinyI18: unsupported entry type");return""}#oo(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.#ao(t,r);return null==n?"":String(n)}):e}#ao(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}#so(){return{has:e=>this.#Qi.has(e),call:(e,t,r)=>{const n=this.#Qi.get(e);if("function"!=typeof n)throw new Error(`Helper "${e}" not found`);return n(t,r??{})}}}#lo(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.#Yi.get(e)??{}},n=[...this.#Xi.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.#Yi.set(e,r),this.#Xi.set(e,n),this.#Yi.has(this.#Ui)||(this.#Yi.set(this.#Ui,{}),this.#Xi.set(this.#Ui,[]))}#uo(e){if("string"!=typeof e||!e)throw new TypeError('#unloadLocale: "locale" must be a non-empty string');e!==this.#Ui&&(this.#Yi.delete(e),this.#Xi.delete(e))}async#ho(e){if("string"!=typeof e||!e)throw new TypeError('#loadLocaleFromFile: "locale" must be a non-empty string');if("string"!=typeof this.#Gi||!this.#Gi)throw new TypeError('#loadLocaleFromFile: "this.#basePath" must be a non-empty string');const t=(0,ue.join)(this.#Gi,`${e}.json`);let r;try{const e=await(0,or.readFile)(t,"utf8");r=JSON.parse(e)}catch(r){if(!(r instanceof Error))return;if(this.#Ji)throw new Error(`TinyI18: failed to load or parse ${t}: ${r.message}`);return this.#Yi.set(e,{}),void this.#Xi.set(e,[])}const n={...this.#Yi.get(e)??{}},i=[...this.#Xi.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.#co(t.$pattern);return void i.push({$pattern:e,value:this.#do(t.value),elseValue:this.#do(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.#do(t)}else if(t&&"object"==typeof t)for(const[r,n]of Object.entries(t))o(e?`${e}.${r}`:r,n)}};o("",r),this.#Yi.set(e,n),this.#Xi.set(e,i)}#co(e){if("string"!=typeof e||!e)throw new TypeError('#safeRegExp: "src" must be a non-empty string');const t=this.#Zi.get(e);if(t)return t;try{const t=new RegExp(e);return this.#Zi.set(e,t),t}catch{if(this.#Ji)throw new Error(`TinyI18: invalid regex "${e}" in file`);return/^$/}}#do(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.#Ji)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.#Gi=n}if(this.#Vi=t,this.#Ui=r,this.#Ji=o,"local"===t&&i&&"object"==typeof i)for(const[e,t]of Object.entries(i))this.#lo(e,t);this.#Yi.has(this.#Ui)||(this.#Yi.set(this.#Ui,{}),this.#Xi.set(this.#Ui,[]))}clearRegexCache(){this.#Zi.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.#Qi.set(e,t)}unregisterHelper(e){if("string"!=typeof e||!e)throw new TypeError('unregisterHelper: "name" must be non-empty string');return this.#Qi.delete(e)}loadLocaleLocal(e,t){if("local"!==this.#Vi)throw new TypeError('loadLocaleLocal is only available in "local" mode');this.#lo(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.#Ki;null!==e&&("file"===this.#Vi?await this.#ho(e):this.#Yi.has(e)||(this.#Yi.set(e,{}),this.#Xi.set(e,[]))),"file"===this.#Vi&&t&&t!==this.#Ui&&t!==e&&this.#uo(t),this.#Ki=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.#to(n);let o=this.#ro(i,e);if(void 0===o){if(this.#Ji)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return this.#io(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.#to(r);let i=this.#no(n,e);if(void 0===i){if(this.#Ji)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return i}resetToDefaultOnly(){if("file"===this.#Vi)for(const e of Array.from(this.#Yi.keys()))e!==this.#Ui&&this.#uo(e);this.#Ki=null}getStatsForLocale(e){if("string"!=typeof e||!e)throw new TypeError('getStatsForLocale: "locale" must be a non-empty string');if(!this.#Yi.has(e))throw new Error(`getStatsForLocale: locale "${e}" is not registered`);return{locale:e,strings:Object.keys(this.#Yi.get(e)??{}).length,patterns:this.#Xi.get(e)?.length??0,isDefault:e===this.#Ui,isCurrent:e===this.#Ki}}};class lr{#po=new Map;#fo;#mo;#go;get factors(){const e={};for(let[t,r]of this.#po.entries())e[t]={...r};return e}get currentPercent(){return this.#mo/this.#fo*100}set maxValue(e){if("number"!=typeof e||Number.isNaN(e)||e<=0)throw new TypeError("maxValue must be a positive number.");this.#fo=e,this.#mo=Math.min(this.#mo,e)}get maxValue(){return this.#fo}get currentValue(){return this.#mo}set infiniteValue(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("infiniteValue must be a number.");this.#go=e,this.#mo=Math.max(0,e),this.#mo=Math.min(this.#mo,this.#fo)}get infiniteValue(){return this.#go}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.#fo=e,this.setFactor("main",t,r),this.#mo=e,this.#go=e}getFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");const t=this.#po.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.#po.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.#po.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.#po.delete(e)}#yo(e){const t=this.#go;return this.#go-=e,this.#mo=Math.max(0,this.#mo-e),{prevValue:t,removedTotal:e,removedPercent:e/this.#fo*100,currentPercent:this.currentPercent,remainingValue:this.#mo,infiniteRemaining:this.#go}}tick(){let e=0;for(let[t,r]of this.#po.entries())e+=r.amount*r.multiplier;return this.#yo(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.#po.entries())t+=r.amount*r.multiplier;return e&&(t+=e.amount*(e.multiplier??1)),this.#yo(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.#yo(t)}toJSON(){return{maxValue:this.#fo,currentValue:this.#mo,infiniteValue:this.#go,factors:this.factors}}static fromJSON(e){const t=new lr(e.maxValue,0,0);t.infiniteValue=e.infiniteValue,t.#po.clear();for(const[r,n]of Object.entries(e.factors))t.setFactor(r,n.amount,n.multiplier);return t}clone(){return lr.fromJSON(this.toJSON())}clearFactors(){this.#po.clear()}}const ur=lr;class hr{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=hr.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)||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 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=[],h=[],c=e=>e.match(/\(\s*[^()]+\|\s*[^()]+\s*\)|\b\d*d\d+\b|[-+]?\d+(?:\.\d+)?|[+\-*/%^()]/g)||[],d=c(a),p=c(s),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),h.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:f(t)?t.value:0;f(t)&&n(t),l.push([o]);for(const t in m)if(m[t]===e){m[t]=String(o),u.push(Number(t));break}return r(),o}const o=[],s=Number(t[0]),a=["("];let c="(";for(let e=0;e<s;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<s-1?" + ":")";a.push(l),c+=`${r}${l}`,o.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<s;t++)u.push(r+t+e),e++;break}}return l.push(o),r(),c});let w;try{w=hr._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:h,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))}#fo;#wo;get maxValue(){return this.#fo}set maxValue(e){if(!Number.isInteger(e)||e<0)throw new TypeError("maxValue must be an integer greater than -1.");this.#fo=e}get allowZero(){return this.#wo}set allowZero(e){if("boolean"!=typeof e)throw new TypeError("allowZero must be a boolean.");this.#wo=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.#fo=e,this.#wo=t}roll(){const e=this.#wo?0:1;return Math.floor(Math.random()*(this.#fo-e+1))+e}}const cr=hr,dr=class{#T=null;get overlay(){return this.#T}#bo=null;get messageElement(){return this.#bo}#R;get container(){return this.#R}#vo={fadeIn:null,fadeOut:null,zIndex:9999};get options(){return{...this.#vo}}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.#vo={fadeIn:e.fadeIn??null,fadeOut:e.fadeOut??null,zIndex:e.zIndex??9999}}#Eo="none";get status(){return this.#Eo}#To="";get defaultMessage(){return this.#To}set defaultMessage(e){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("defaultMessage must be a string or an HTMLElement");this.#To=e}#So=null;get message(){return this.#So}#xo=!1;get allowHtmlText(){return this.#xo}set allowHtmlText(e){if("boolean"!=typeof e)throw new TypeError("allowHtmlText must be a boolean");this.#xo=e}#Ao=null;get fadeInTimeout(){return null!==this.#Ao}#Co=null;get fadeOutTimeout(){return null!==this.#Co}get visible(){return!!this.#T}#Io=null;get onChange(){return this.#Io}set onChange(e){if(null!==e&&"function"!=typeof e)throw new TypeError("onChange must be a function or null");this.#Io=e}_emitChange(){"function"==typeof this.#Io&&this.#Io(this.#Eo)}constructor(e=document.body){if(!(e instanceof HTMLElement))throw new TypeError("container must be an HTMLElement");this.#R=e}_updateMessage(e=this.#To){if(!this.#bo)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.#So=e,"string"==typeof e)this.#xo?this.#bo.innerHTML=e:this.#bo.textContent=e;else{if(!this.#xo)throw new Error("HTMLElement messages require allowHtmlText = true");this.#bo.textContent="",this.#bo.appendChild(e)}}_removeOldClasses(){this.#T?.classList.remove("active"),this.#T?.classList.remove("fadeIn"),this.#T?.classList.remove("fadeOut")}start(e=this.#To){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.#vo.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.#bo=document.createElement("div"),this.#bo.classList.add("loading-message"),r.appendChild(n),r.appendChild(this.#bo),t.appendChild(r),this.#T.appendChild(t),this.#R.appendChild(this.#T),this._removeOldClasses(),this.#Eo="fadeIn",this.#T.classList.add("fadeIn"),this._emitChange();const i=()=>{this._removeOldClasses(),this.#Ao=null,this.#Eo="active",this.#T?.classList.add("active"),this._emitChange()};return"number"==typeof this.#vo.fadeIn?(this.#Ao&&clearTimeout(this.#Ao),this.#Ao=setTimeout(i,this.#vo.fadeIn)):i(),this._updateMessage(e),!0}return this.#bo&&this._updateMessage(e),!1}update(e=this.#To){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");return!!this.#bo&&(this._updateMessage(e),!0)}stop(){if(this.#T){this._removeOldClasses(),this.#Eo="fadeOut",this.#T.classList.add("fadeOut"),this._emitChange();const e=()=>{this._removeOldClasses(),this.#Co=null,this.#Eo="none",this.#T?.remove(),this.#T=null,this.#bo=null,this.#So=null,this._emitChange()};return"number"==typeof this.#vo.fadeOut?(this.#Co&&clearTimeout(this.#Co),this.#Co=setTimeout(e,this.#vo.fadeOut)):e(),!0}return!1}};class pr{static#Mo=/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;static#Lo=/^#([A-Fa-f0-9]{8})$/;static#ko="(0|1|0?\\.\\d+)";static#No="(0|[1-9]\\d?|1\\d{2}|2[0-4]\\d|25[0-5])";static#_o="(0|[1-9]\\d?|[1-2]\\d{2}|3[0-5]\\d|360)";static#Do="(0|[1-9]?\\d|100)";static#jo=new RegExp(`^rgb\\(\\s*${pr.#No}\\s*,\\s*${pr.#No}\\s*,\\s*${pr.#No}\\s*\\)$`);static#Ro=new RegExp(`^rgba\\(\\s*${pr.#No}\\s*,\\s*${pr.#No}\\s*,\\s*${pr.#No}\\s*,\\s*${pr.#ko}\\s*\\)$`);static#Oo=new RegExp(`^hsl\\(\\s*${pr.#_o}\\s*,\\s*${pr.#Do}%\\s*,\\s*${pr.#Do}%\\s*\\)$`);static#Ho=new RegExp(`^hsla\\(\\s*${pr.#_o}\\s*,\\s*${pr.#Do}%\\s*,\\s*${pr.#Do}%\\s*,\\s*${pr.#ko}\\s*\\)$`);static#$o=new RegExp(`^hwb\\(\\s*${pr.#_o}(deg|grad|rad|turn)?\\s*${pr.#Do}%\\s*${pr.#Do}%\\s*\\)$`);static#Bo="(-?\\d+)";static#Po=new RegExp(`^lab\\(\\s*${pr.#Do}%?\\s*${pr.#Bo}%?\\s*${pr.#Bo}%?\\s*\\)$`);static#Fo=new RegExp(`^lch\\(\\s*${pr.#Do}%?\\s*${pr.#Do}%?\\s*${pr.#_o}(deg|grad|rad|turn)?\\s*\\)$`);static#Wo=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#zo=new Set(["transparent","currentColor"]);static getNames(){return Array.from(pr.#Wo)}static addName(e){const t=pr.#Wo.size;return pr.#Wo.add(e.toLowerCase()),pr.#Wo.size>t}static removeName(e){return pr.#Wo.delete(e.toLowerCase())}static hasName(e){return pr.#Wo.has(e.toLowerCase())}static getSpecialNames(){return Array.from(pr.#zo)}static addSpecialName(e){const t=pr.#zo.size;return pr.#zo.add(e),pr.#zo.size>t}static removeSpecialName(e){return pr.#zo.delete(e)}static hasSpecialName(e){return pr.#zo.has(e)}#qo;get code(){return this.#qo}#Vo;get type(){return this.#Vo}constructor(e){this.#qo=e,this.#Vo=pr.isColor(this.#qo)}static isHex(e){if("string"!=typeof e)throw new TypeError("isHex: input must be a string.");return pr.#Mo.test(e.trim())}isHex(){return pr.isHex(this.#qo)}static isHexa(e){if("string"!=typeof e)throw new TypeError("isHexa: input must be a string.");return pr.#Lo.test(e.trim())}isHexa(){return pr.isHexa(this.#qo)}static isRgb(e){if("string"!=typeof e)throw new TypeError("isRgb: input must be a string.");return pr.#jo.test(e.trim())}isRgb(){return pr.isRgb(this.#qo)}static isRgba(e){if("string"!=typeof e)throw new TypeError("isRgba: input must be a string.");return pr.#Ro.test(e.trim())}isRgba(){return pr.isRgba(this.#qo)}static isHsl(e){if("string"!=typeof e)throw new TypeError("isHsl: input must be a string.");return pr.#Oo.test(e.trim())}isHsl(){return pr.isHsl(this.#qo)}static isHsla(e){if("string"!=typeof e)throw new TypeError("isHsla: input must be a string.");return pr.#Ho.test(e.trim())}isHsla(){return pr.isHsla(this.#qo)}static isHwb(e){if("string"!=typeof e)throw new TypeError("isHwb: input must be a string.");return pr.#$o.test(e.trim())}isHwb(){return pr.isHwb(this.#qo)}static isLab(e){if("string"!=typeof e)throw new TypeError("isLab: input must be a string.");return pr.#Po.test(e.trim())}isLab(){return pr.isLab(this.#qo)}static isLch(e){if("string"!=typeof e)throw new TypeError("isLch: input must be a string.");return pr.#Fo.test(e.trim())}isLch(){return pr.isLch(this.#qo)}static isName(e){if("string"!=typeof e)throw new TypeError("isName: input must be a string.");return pr.#Wo.has(e.trim().toLowerCase())}isName(){return pr.isName(this.#qo)}static isSpecialName(e){if("string"!=typeof e)throw new TypeError("isSpecialName: input must be a string.");return pr.#zo.has(e.trim())}isSpecialName(){return pr.isSpecialName(this.#qo)}static isColor(e){if("string"!=typeof e)throw new TypeError("isColor: input must be a string.");return pr.isHex(e)?"hex":pr.isHexa(e)?"hexa":pr.isRgb(e)?"rgb":pr.isRgba(e)?"rgba":pr.isHsl(e)?"hsl":pr.isHsla(e)?"hsla":pr.isHwb(e)?"hwb":pr.isLab(e)?"lab":pr.isLch(e)?"lch":pr.isName(e)?"name":pr.isSpecialName(e)?"specialName":null}parse(){switch(this.#Vo){case"hex":return pr.parseHex(this.code);case"hexa":return pr.parseHexa(this.code);case"rgb":return pr.parseRgb(this.code);case"rgba":return pr.parseRgba(this.code);case"hsl":return pr.parseHsl(this.code);case"hsla":return pr.parseHsla(this.code);case"hwb":return pr.parseHwb(this.code);case"lab":return pr.parseLab(this.code);case"lch":return pr.parseLch(this.code);case"name":case"specialName":return this.#qo.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(pr.#Mo,"gm").exec(e.trim());return t?t[1]:null}parseHex(){return pr.parseHex(this.#qo)}static parseHexa(e){if("string"!=typeof e)throw new TypeError("parseHexa: input must be a string.");const t=new RegExp(pr.#Lo,"gm").exec(e.trim());return t?t[1]:null}parseHexa(){return pr.parseHexa(this.#qo)}static parseRgb(e){if("string"!=typeof e)throw new TypeError("parseRgb: input must be a string.");const t=new RegExp(pr.#jo,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseRgb(){return pr.parseRgb(this.#qo)}static parseRgba(e){if("string"!=typeof e)throw new TypeError("parseRgba: input must be a string.");const t=new RegExp(pr.#Ro,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])]:null}parseRgba(){return pr.parseRgba(this.#qo)}static parseHsl(e){if("string"!=typeof e)throw new TypeError("parseHsl: input must be a string.");const t=new RegExp(pr.#Oo,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseHsl(){return pr.parseHsl(this.#qo)}static parseHsla(e){if("string"!=typeof e)throw new TypeError("parseHsla: input must be a string.");const t=new RegExp(pr.#Ho,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])]:null}parseHsla(){return pr.parseHsla(this.#qo)}static parseHwb(e){if("string"!=typeof e)throw new TypeError("parseHwb: input must be a string.");const t=new RegExp(pr.#$o,"gm").exec(e.trim());return t?[parseFloat(t[1]),t[2]??null,parseFloat(t[3]),parseFloat(t[4])]:null}parseHwb(){return pr.parseHwb(this.#qo)}static parseLab(e){if("string"!=typeof e)throw new TypeError("parseLab: input must be a string.");const t=new RegExp(pr.#Po,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseLab(){return pr.parseLab(this.#qo)}static parseLch(e){if("string"!=typeof e)throw new TypeError("parseLch: input must be a string.");const t=new RegExp(pr.#Fo,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),t[4]??null]:null}parseLch(){return pr.parseLch(this.#qo)}}const fr=pr,mr=class{#Uo;#Ko;#Jo;#qi;#pn=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.#qi={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.#Uo=document.createElement("div"),this.#Uo.className="analog-clock-container",this.#Uo.style.position="relative",this.#Uo.style.borderRadius="50%",this.#Uo.style.overflow="hidden",this.#Uo.style.boxSizing="border-box",this.#Jo=document.createElement("div"),this.#Jo.style.position="absolute",this.#Jo.style.inset="0",this.#Jo.style.backgroundSize="cover",this.#Jo.style.backgroundPosition="center",this.#Jo.style.zIndex="0",this.#Ko=document.createElement("div"),this.#Ko.style.position="absolute",this.#Ko.style.inset="0",this.#Ko.style.zIndex="1",this.#Ko.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.#Uo.appendChild(this.#Jo),this.#Uo.appendChild(this.#Ko),this.#Uo.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.#Uo.appendChild(r),this._applyConfig(),this._renderFace(),this._startTicker()}_applyConfig(){const e=this.#Uo.style,t=this.#qi;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.#Jo.style.backgroundImage=`url(${t.skinUrl})`,this.#Jo.style.display="block"):this.#Jo.style.display="none";const r=e=>{const t=this.#Uo.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.#Ko.innerHTML="";const e=this.#qi.size/2-this.#qi.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.#qi.size*this.#qi.pwH:this.#qi.size*this.#qi.pwM,o=r?this.#qi.size*this.#qi.phH:this.#qi.size*this.#qi.phM,s=this.#qi.markColor;n.style.width=`${i}px`,n.style.height=`${o}px`,n.style.color=s;const a=e-this.#qi.padding-o/2;n.style.transform=`translate(-50%, -50%) rotate(${6*t}deg) translate(0, -${a}px)`,this.#Ko.appendChild(n)}if(this.#qi.showNumbers)for(let t=1;t<=12;t++){const r=30*t*(Math.PI/180),n=e*this.#qi.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.#qi.textColor,s.style.fontSize=this.#qi.size*this.#qi.sizeAdjust+"px",this.#Ko.appendChild(s)}}_startTicker(){if(this.#pn)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.#Uo.querySelector(e);if(!(t instanceof HTMLDivElement))throw new Error(`${e} not found.`);return t};this.#Uo.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.#pn=requestAnimationFrame(e)};e()}get element(){return this.#Uo}set size(e){if("number"!=typeof e||e<=0||isNaN(e))throw new Error(`TinyAnalogClock: 'size' must be a positive number. Received: ${e}`);this.#qi.size=e,this._applyConfig(),this._renderFace()}get size(){return this.#qi.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.#qi.skinUrl=e,this._applyConfig()}get skinUrl(){return this.#qi.skinUrl}set borderColor(e){if("string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'borderColor' must be a non-empty string. Received: ${e}`);this.#qi.borderColor=e,this._applyConfig(),this._renderFace()}get borderColor(){return this.#qi.borderColor}set markColor(e){if("string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'markColor' must be a non-empty string. Received: ${e}`);this.#qi.markColor=e,this._applyConfig(),this._renderFace()}get markColor(){return this.#qi.markColor}set textColor(e){if("string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'textColor' must be a non-empty string. Received: ${e}`);this.#qi.textColor=e,this._applyConfig(),this._renderFace()}get textColor(){return this.#qi.textColor}set showNumbers(e){if("boolean"!=typeof e)throw new Error("TinyAnalogClock: 'showNumbers' must be a boolean. Received type: "+typeof e);this.#qi.showNumbers=e,this._renderFace()}get showNumbers(){return this.#qi.showNumbers}set bgColor(e){if("string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'bgColor' must be a non-empty string.");this.#qi.bgColor=e,this._applyConfig()}get bgColor(){return this.#qi.bgColor}set borderWidth(e){if("number"!=typeof e||e<0)throw new Error("TinyAnalogClock: 'borderWidth' must be a non-negative number.");this.#qi.borderWidth=e,this._applyConfig(),this._renderFace()}get borderWidth(){return this.#qi.borderWidth}set hourHandColor(e){if("string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'hourHandColor' must be a non-empty string.");this.#qi.hourHandColor=e,this._applyConfig()}get hourHandColor(){return this.#qi.hourHandColor}set minuteHandColor(e){if("string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'minuteHandColor' must be a non-empty string.");this.#qi.minuteHandColor=e,this._applyConfig()}get minuteHandColor(){return this.#qi.minuteHandColor}set secondHandColor(e){if("string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'secondHandColor' must be a non-empty string.");this.#qi.secondHandColor=e,this._applyConfig()}get secondHandColor(){return this.#qi.secondHandColor}set showSeconds(e){if("boolean"!=typeof e)throw new Error("TinyAnalogClock: 'showSeconds' must be a boolean.");this.#qi.showSeconds=e,this._applyConfig()}get showSeconds(){return this.#qi.showSeconds}set sizeAdjust(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'sizeAdjust' must be a positive number.");this.#qi.sizeAdjust=e,this._renderFace()}get sizeAdjust(){return this.#qi.sizeAdjust}set padding(e){if("number"!=typeof e||e<0)throw new Error("TinyAnalogClock: 'padding' must be a non-negative number.");this.#qi.padding=e,this._renderFace()}get padding(){return this.#qi.padding}set angleDistance(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'angleDistance' must be a positive number.");this.#qi.angleDistance=e,this._renderFace()}get angleDistance(){return this.#qi.angleDistance}set pwH(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'pwH' must be a positive number.");this.#qi.pwH=e,this._renderFace()}get pwH(){return this.#qi.pwH}set phH(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'phH' must be a positive number.");this.#qi.phH=e,this._renderFace()}get phH(){return this.#qi.phH}set pwM(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'pwM' must be a positive number.");this.#qi.pwM=e,this._renderFace()}get pwM(){return this.#qi.pwM}set phM(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'phM' must be a positive number.");this.#qi.phM=e,this._renderFace()}get phM(){return this.#qi.phM}destroy(){this.#pn&&(cancelAnimationFrame(this.#pn),this.#pn=null),this.#Uo.remove()}},gr=class{#Go=[];#we=!1;get history(){return[...this.#Go]}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.#Go=[...e]}get size(){return this.#Go.length}constructor(e=[]){this.history=e}#Yo(){if(this.#we)throw new Error("Cannot perform operations on a destroyed TinyTextDiffer instance.")}#Xo(e){if("number"!=typeof e)throw new TypeError("The provided index must be a valid number.")}#Qo(e){if("string"!=typeof e)throw new TypeError("The provided text must be a valid string.")}get(e){if(this.#Yo(),this.#Xo(e),void 0===this.#Go[e])throw new Error(`No text version found at index ${e}.`);return this.#Go[e]}has(e){return this.#Yo(),this.#Xo(e),void 0!==this.#Go[e]}add(e){this.#Yo(),this.#Qo(e),this.#Go.push(e)}remove(){return this.#Yo(),this.#Go.pop()}addAt(e,t){this.#Yo(),this.#Xo(e),this.#Qo(t),this.#Go.splice(e,0,t)}removeAt(e){this.#Yo(),this.#Xo(e);const t=this.#Go.length;return this.#Go.splice(e,1),t!==this.#Go.length}clear(){this.#Yo(),this.#Go=[]}compare(...e){this.#Yo();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.#Xo(e[n]),this.#Xo(e[i]);const o=this.#Go[e[n]],s=this.#Go[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.#we||(this.#Go=[],this.#we=!0)}}})(),window.TinyEssentials=n})();
|