tiny-essentials 1.28.2 → 1.28.4

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.
@@ -1 +1 @@
1
- (()=>{var e={7(e){"use strict";var t,r="object"==typeof Reflect?Reflect:null,i=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var n=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,e.exports.once=function(e,t){return new Promise(function(r,i){function n(r){e.removeListener(t,s),i(r)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",n),r([].slice.call(arguments))}f(e,t,s,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&f(e,"error",t,{once:!0})}(e,n)})},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function u(e,t,r,i){var n,s,o,u;if(a(r),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]),void 0===o)o=s[t]=r,++e._eventsCount;else if("function"==typeof o?o=s[t]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(n=l(e))>0&&o.length>n&&!o.warned){o.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=o.length,u=h,console&&console.warn&&console.warn(u)}return e}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function c(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},n=h.bind(i);return n.listener=r,i.wrapFn=n,n}function d(e,t,r){var i=e._events;if(void 0===i)return[];var n=i[t];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(n):p(n,n.length)}function m(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}function f(e,t,r,i){if("function"==typeof e.on)i.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function n(s){i.once&&e.removeEventListener(t,n),r(s)})}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");o=e}}),s.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return l(this)},s.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n="error"===e,s=this._events;if(void 0!==s)n=n&&void 0===s.error;else if(!n)return!1;if(n){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var l=s[e];if(void 0===l)return!1;if("function"==typeof l)i(l,this,t);else{var u=l.length,h=p(l,u);for(r=0;r<u;++r)i(h[r],this,t)}return!0},s.prototype.addListener=function(e,t){return u(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return u(this,e,t,!0)},s.prototype.once=function(e,t){return a(t),this.on(e,c(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,c(this,e,t)),this},s.prototype.removeListener=function(e,t){var r,i,n,s,o;if(a(t),void 0===(i=this._events))return this;if(void 0===(r=i[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(n=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,n=s;break}if(n<0)return this;0===n?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,n),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,r,i;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var n,s=Object.keys(r);for(i=0;i<s.length;++i)"removeListener"!==(n=s[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},s.prototype.listeners=function(e){return d(this,e,!0)},s.prototype.rawListeners=function(e){return d(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},s.prototype.listenerCount=m,s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},975(e,t,r){"use strict";var i=r(606);function n(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function s(e,t){for(var r,i="",n=0,s=-1,o=0,a=0;a<=e.length;++a){if(a<e.length)r=e.charCodeAt(a);else{if(47===r)break;r=47}if(47===r){if(s===a-1||1===o);else if(s!==a-1&&2===o){if(i.length<2||2!==n||46!==i.charCodeAt(i.length-1)||46!==i.charCodeAt(i.length-2))if(i.length>2){var l=i.lastIndexOf("/");if(l!==i.length-1){-1===l?(i="",n=0):n=(i=i.slice(0,l)).length-1-i.lastIndexOf("/"),s=a,o=0;continue}}else if(2===i.length||1===i.length){i="",n=0,s=a,o=0;continue}t&&(i.length>0?i+="/..":i="..",n=2)}else i.length>0?i+="/"+e.slice(s+1,a):i=e.slice(s+1,a),n=a-s-1;s=a,o=0}else 46===r&&-1!==o?++o:o=-1}return i}var o={resolve:function(){for(var e,t="",r=!1,o=arguments.length-1;o>=-1&&!r;o--){var a;o>=0?a=arguments[o]:(void 0===e&&(e=i.cwd()),a=e),n(a),0!==a.length&&(t=a+"/"+t,r=47===a.charCodeAt(0))}return t=s(t,!r),r?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(e){if(n(e),0===e.length)return".";var t=47===e.charCodeAt(0),r=47===e.charCodeAt(e.length-1);return 0!==(e=s(e,!t)).length||t||(e="."),e.length>0&&r&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return n(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];n(r),r.length>0&&(void 0===e?e=r:e+="/"+r)}return void 0===e?".":o.normalize(e)},relative:function(e,t){if(n(e),n(t),e===t)return"";if((e=o.resolve(e))===(t=o.resolve(t)))return"";for(var r=1;r<e.length&&47===e.charCodeAt(r);++r);for(var i=e.length,s=i-r,a=1;a<t.length&&47===t.charCodeAt(a);++a);for(var l=t.length-a,u=s<l?s: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 s>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 m="";for(c=r+h+1;c<=i;++c)c!==i&&47!==e.charCodeAt(c)||(0===m.length?m+="..":m+="/..");return m.length>0?m+t.slice(a+h):(a+=h,47===t.charCodeAt(a)&&++a,t.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(n(e),0===e.length)return".";for(var t=e.charCodeAt(0),r=47===t,i=-1,s=!0,o=e.length-1;o>=1;--o)if(47===(t=e.charCodeAt(o))){if(!s){i=o;break}}else s=!1;return-1===i?r?"/":".":r&&1===i?"//":e.slice(0,i)},basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');n(e);var r,i=0,s=-1,o=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,l=-1;for(r=e.length-1;r>=0;--r){var u=e.charCodeAt(r);if(47===u){if(!o){i=r+1;break}}else-1===l&&(o=!1,l=r+1),a>=0&&(u===t.charCodeAt(a)?-1===--a&&(s=r):(a=-1,s=l))}return i===s?s=l:-1===s&&(s=e.length),e.slice(i,s)}for(r=e.length-1;r>=0;--r)if(47===e.charCodeAt(r)){if(!o){i=r+1;break}}else-1===s&&(o=!1,s=r+1);return-1===s?"":e.slice(i,s)},extname:function(e){n(e);for(var t=-1,r=0,i=-1,s=!0,o=0,a=e.length-1;a>=0;--a){var l=e.charCodeAt(a);if(47!==l)-1===i&&(s=!1,i=a+1),46===l?-1===t?t=a:1!==o&&(o=1):-1!==t&&(o=-1);else if(!s){r=a+1;break}}return-1===t||-1===i||0===o||1===o&&t===i-1&&t===r+1?"":e.slice(t,i)},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,i=t.base||(t.name||"")+(t.ext||"");return r?r===t.root?r+i:r+"/"+i:i}(0,e)},parse:function(e){n(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return t;var r,i=e.charCodeAt(0),s=47===i;s?(t.root="/",r=1):r=0;for(var o=-1,a=0,l=-1,u=!0,h=e.length-1,c=0;h>=r;--h)if(47!==(i=e.charCodeAt(h)))-1===l&&(u=!1,l=h+1),46===i?-1===o?o=h:1!==c&&(c=1):-1!==o&&(c=-1);else if(!u){a=h+1;break}return-1===o||-1===l||0===c||1===c&&o===l-1&&o===a+1?-1!==l&&(t.base=t.name=0===a&&s?e.slice(1,l):e.slice(a,l)):(0===a&&s?(t.name=e.slice(1,o),t.base=e.slice(1,l)):(t.name=e.slice(a,o),t.base=e.slice(a,l)),t.ext=e.slice(o,l)),a>0?t.dir=e.slice(0,a-1):s&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};o.posix=o,e.exports=o},606(e){var t,r,i=e.exports={};function n(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function o(e){if(t===setTimeout)return setTimeout(e,0);if((t===n||!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:n}catch(e){t=n}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();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=o(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===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{return r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function p(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new m(e,t)),1!==l.length||u||o(d)},m.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=p,i.addListener=p,i.once=p,i.off=p,i.removeListener=p,i.removeAllListeners=p,i.emit=p,i.prependListener=p,i.prependOnceListener=p,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},133(){},370(){},766(){},911(){}};const t={};function r(i){const n=t[i];if(void 0!==n)return n.exports;const s=t[i]={exports:{}};return e[i](s,s.exports,r),s.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var i=0;i<t.length;){var n=t[i++],s=t[i++];r.o(e,n)?0===s&&i++:0===s?Object.defineProperty(e,n,{enumerable:!0,value:t[i++]}):Object.defineProperty(e,n,{enumerable:!0,get:s})}else 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=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};let i={};(()=>{"use strict";r.r(i),r.d(i,{ColorSafeStringify:()=>U,FuzzySet:()=>oi,MamdaniInferenceSystem:()=>ai,TinyAdvancedRaffle:()=>_r,TinyAfterScrollWatcher:()=>qt,TinyAnalogClock:()=>Xr,TinyArrayComparator:()=>ti,TinyArrayPaginator:()=>jr,TinyClassManager:()=>ui,TinyClipboard:()=>sr,TinyColorConverter:()=>ar,TinyColorValidator:()=>Gr,TinyCookieConsent:()=>Hr,TinyDayNightCycle:()=>Nr,TinyDomReadyManager:()=>It,TinyDragDropDetector:()=>me,TinyDragger:()=>Ct,TinyElementObserver:()=>ht,TinyGamepad:()=>Dr,TinyHtml:()=>St,TinyI18:()=>zr,TinyIframeEvents:()=>vr,TinyInventory:()=>Pr,TinyInventoryTrader:()=>$r,TinyLevelUp:()=>n,TinyLoadingScreen:()=>Jr,TinyLocalStorage:()=>yr,TinyMediaPlayer:()=>yi,TinyNeedBar:()=>qr,TinyNewWinEvents:()=>xr,TinyNotifications:()=>Dt,TinyNotifyCenter:()=>te,TinyPromiseQueue:()=>G,TinyRadioFm:()=>di,TinyRateLimiter:()=>Q,TinySimpleDice:()=>Kr,TinySmartScroller:()=>ir,TinyTextDiffer:()=>Zr,TinyTextRangeEditor:()=>nr,TinyTextarea:()=>Ar,TinyTimeout:()=>hr,TinyToastNotify:()=>ie,UltraRandomMsgGen:()=>Zt,addAiMarkerShortcut:()=>W,areElsCollBottom:()=>Ke,areElsCollLeft:()=>Je,areElsCollPerfBottom:()=>Ye,areElsCollPerfLeft:()=>Xe,areElsCollPerfRight:()=>Qe,areElsCollPerfTop:()=>Ge,areElsCollRight:()=>Ue,areElsCollTop:()=>Ve,areElsColliding:()=>Ze,areElsPerfColliding:()=>et,arraySortPositions:()=>l,asyncReplace:()=>F,backupFile:()=>Ne,breakdownDuration:()=>m,calculateMarketcap:()=>H,checkObj:()=>S,clearDirectory:()=>be,clearDirectoryAsync:()=>Oe,cloneObjTypeOrder:()=>v,compareMarketcap:()=>O,countObj:()=>p,createCheckDestroyed:()=>Y,defuzzifyCentroid:()=>ii,diffArrayList:()=>a,diffObjList:()=>V,diffStrings:()=>K,dirExists:()=>Ee,dirSize:()=>Me,dirSizeAsync:()=>qe,documentIsFullScreen:()=>x,ensureCopyFile:()=>Se,ensureDirectory:()=>we,exitFullScreen:()=>D,extendObjType:()=>w,extractMediaId3Tags:()=>Bt,fetchJson:()=>ue,fetchText:()=>he,fileExists:()=>ve,fileSize:()=>De,fileSizeAsync:()=>We,formatBytes:()=>P,formatCustomTimer:()=>h,formatDayTimer:()=>d,formatTimer:()=>c,genFibonacciSeq:()=>$,getAge:()=>R,getElsCollDetails:()=>lt,getElsCollDirDepth:()=>at,getElsCollOverlap:()=>it,getElsCollOverlapPos:()=>nt,getElsColliding:()=>tt,getElsPerfColliding:()=>rt,getElsRelativeCenterOffset:()=>ot,getLatestBackupPath:()=>ke,getPercentage:()=>j,getRectCenter:()=>st,getSimplePerc:()=>_,getTimeDuration:()=>u,installWindowHiddenScript:()=>ce,isDirEmpty:()=>Te,isDirEmptyAsync:()=>Fe,isFullScreenMode:()=>C,isJsonObject:()=>f,isScreenFilled:()=>A,listDirs:()=>Ie,listDirsAsync:()=>ze,listFiles:()=>Ce,listFilesAsync:()=>Be,multiplyArrayBlocks:()=>o,objType:()=>T,offFullScreenChange:()=>k,onFullScreenChange:()=>N,parseMediaMetadata:()=>zt,readBase64Blob:()=>se,readFileBlob:()=>ne,readJsonBlob:()=>oe,readJsonFile:()=>ye,renameFileAddPrefixSuffix:()=>Re,renameFileBatch:()=>_e,renameFileNormalizeCase:()=>Pe,renameFilePadNumbers:()=>$e,renameFileRegex:()=>je,reorderObjTypeOrder:()=>b,requestFullScreen:()=>I,restoreLatestBackup:()=>Le,ruleOfThree:()=>L,safeTextTrim:()=>q,saveJsonFile:()=>ae,shuffleArray:()=>s,toTitleCase:()=>B,toTitleCaseLowerFirst:()=>z,trapezoid:()=>ni,tryDeleteFile:()=>xe,valMediaContentMetadata:()=>Ot,valMediaContentMetadataPartial:()=>Ft,writeJsonFile:()=>ge,writeTextFile:()=>Ae});var e={};r.r(e),r.d(e,{iu:()=>Ke,cq:()=>Je,P8:()=>Ye,BO:()=>Xe,eh:()=>Qe,L2:()=>Ge,lP:()=>Ue,Kr:()=>Ve,wE:()=>Ze,D6:()=>et,PN:()=>lt,t_:()=>at,aI:()=>it,ej:()=>nt,kx:()=>tt,Pd:()=>rt,NW:()=>ot,Qv:()=>st});var t={};r.r(t),r.d(t,{areElsCollBottom:()=>Ke,areElsCollLeft:()=>Je,areElsCollPerfBottom:()=>Ye,areElsCollPerfLeft:()=>Xe,areElsCollPerfRight:()=>Qe,areElsCollPerfTop:()=>Ge,areElsCollRight:()=>Ue,areElsCollTop:()=>Ve,areElsColliding:()=>Ze,areElsPerfColliding:()=>et,getElsCollDetails:()=>lt,getElsCollDirDepth:()=>at,getElsCollOverlap:()=>it,getElsCollOverlapPos:()=>nt,getElsColliding:()=>tt,getElsPerfColliding:()=>rt,getElsRelativeCenterOffset:()=>ot,getRectCenter:()=>st});const n=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 i=t*e.level;return e.exp>=i&&(e.level++,r=e.exp-i,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",i=1){if("number"!=typeof i||Number.isNaN(i))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(i)+t:"extra"===r&&(e.exp+=t),this.expValidator(e),e.totalExp=this.getTotalExp(e),e}remove(e,t=0,r="add",i=1){if("number"!=typeof i||Number.isNaN(i))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(i)+t:"extra"===r&&(e.exp-=t),this.expValidator(e),e.totalExp=this.getTotalExp(e),e}};function s(e){if(!Array.isArray(e))throw new TypeError("Argument 'items' must be an array.");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){if(!Array.isArray(e))throw new TypeError("Argument 'phases' must be an array.");if(!Array.isArray(t))throw new TypeError("Argument 'counts' must be an array.");if(e.length!==t.length)throw new RangeError("The 'phases' and 'counts' arrays must have the same length.");const r=[];for(let i=0;i<e.length;i++){if("number"!=typeof t[i]||Number.isNaN(t[i]))throw new TypeError(`Element at counts[${i}] must be a valid number.`);for(let n=0;n<t[i];n++)r.push(e[i])}return r}function a(e,t){if(!Array.isArray(e))throw new TypeError("Argument 'oldItems' must be an array.");if(!Array.isArray(t))throw new TypeError("Argument 'newItems' must be an array.");const r=e.filter(e=>!t.includes(e));return{added:t.filter(t=>!e.includes(t)),removed:r}}function l(e,t=!1){if(null!=e&&"string"!=typeof e)throw new TypeError("Argument 'item' must be a string or null.");if("boolean"!=typeof t)throw new TypeError("Argument 'isReverse' must be a boolean.");return t?function(t,r){return(e?t[e]:t)>(e?r[e]:r)?-1:(e?t[e]:t)<(e?r[e]:r)?1:0}:function(t,r){return(e?t[e]:t)<(e?r[e]:r)?-1:(e?t[e]:t)>(e?r[e]:r)?1:0}}function u(e=new Date,t="asSeconds",r=null){if(!(e instanceof Date))throw new TypeError("The 'timeData' argument must be an instance of Date.");if("string"!=typeof t)throw new TypeError("The 'durationType' argument must be a string.");const i=["asMilliseconds","asSeconds","asMinutes","asHours","asDays"];if(!i.includes(t))throw new RangeError(`The 'durationType' must be one of: ${i.join(", ")}.`);if(null!==r&&!(r instanceof Date))throw new TypeError("The 'now' argument must be an instance of Date or null.");const n=r instanceof Date?r:new Date,s=e.getTime()-n.getTime();switch(t){case"asMilliseconds":return s;case"asSeconds":default:return s/1e3;case"asMinutes":return s/6e4;case"asHours":return s/36e5;case"asDays":return s/864e5}}function h(e,t="seconds",r="{time}"){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'totalSeconds' argument must be a valid number.");if("string"!=typeof t)throw new TypeError("The 'level' argument must be a string.");const i=["seconds","minutes","hours","days","months","years"];if(!i.includes(t))throw new RangeError(`The 'level' must be one of: ${i.join(", ")}.`);if("string"!=typeof r)throw new TypeError("The 'format' argument must be a string.");e=Math.max(0,Math.floor(e));const n=i.indexOf(t),s=n>=5,o=n>=4,a=n>=3,l=n>=2,u=n>=1,h=n>=0,c={years:s?0:NaN,months:o?0:NaN,days:a?0:NaN,hours:l?0:NaN,minutes:u?0:NaN,seconds:h?0:NaN,total:NaN};let d=e;if(s||o||a){const e=new Date(1980,0,1),t=new Date(e.getTime()+1e3*d),r=new Date(e);if(s)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(a)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),c.days++;d=Math.floor((t.getTime()-r.getTime())/1e3)}l&&(c.hours=Math.floor(d/3600),d%=3600),u&&(c.minutes=Math.floor(d/60),d%=60),h&&(c.seconds=d),c.total=+e.toFixed(2).replace(/\.00$/,"");const m=e=>{const t="string"==typeof e?parseInt(e):e;return Number.isNaN(t)?"NaN":String(t).padStart(2,"0")},p=[l?m(c.hours):null,u?m(c.minutes):null,h?m(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,m(c.hours)).replace(/\{minutes\}/g,m(c.minutes)).replace(/\{seconds\}/g,m(c.seconds)).replace(/\{time\}/g,p).replace(/\{total\}/g,String(c.total)).trim()}function c(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'seconds' argument must be a valid number.");return h(e,"hours","{hours}:{minutes}:{seconds}")}function d(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'seconds' argument must be a valid number.");return h(e,"days","{days}d {hours}:{minutes}:{seconds}")}function m(e,t="milliseconds"){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'totalMs' argument must be a valid number.");if("string"!=typeof t)throw new TypeError("The 'level' argument must be a string.");const r=["milliseconds","seconds","minutes","hours","days","months","years"];if(!r.includes(t))throw new RangeError(`The 'level' must be one of: ${r.join(", ")}.`);e=Math.max(0,Math.floor(e));const i=r.indexOf(t),n=i>=6,s=i>=5,o=i>=4,a=i>=3,l=i>=2,u=i>=1,h=i>=0,c={years:n?0:NaN,months:s?0:NaN,days:o?0:NaN,hours:a?0:NaN,minutes:l?0:NaN,seconds:u?0:NaN,milliseconds:h?0:NaN,total:NaN};let d=e;if(n||s||o){const e=new Date(1980,0,1),t=new Date(e.getTime()+d),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(s)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),c.months++;if(o)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),c.days++;d=t.getTime()-r.getTime()}return a&&(c.hours=Math.floor(d/36e5),d%=36e5),l&&(c.minutes=Math.floor(d/6e4),d%=6e4),u&&(c.seconds=Math.floor(d/1e3),d%=1e3),h&&(c.milliseconds=d),c.total=+e,c}function p(e){if(!Array.isArray(e)&&!f(e))throw new TypeError("Argument must be either an Array or a pure JSON Object.");return Array.isArray(e)?e.length:Object.keys(e).length}function f(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}const y="undefined"!=typeof window&&void 0!==window.document,g={items:{},order:[]};function w(e,t){if("object"!=typeof e||null===e)throw new TypeError("Argument 'newItems' must be an object or an array.");if(void 0!==t&&"number"!=typeof t)throw new TypeError("Argument 'index' must be a number.");const r=[],i=Array.isArray(e)?e:Object.entries(e);for(const e of i){if(!Array.isArray(e)||e.length<2)throw new TypeError("Each item in 'newItems' array must be a [key, function] pair.");const[i,n]=e;if("string"!=typeof i)throw new TypeError("Validator key must be a string.");if("function"!=typeof n)throw new TypeError(`Validator for key '${i}' must be a function.`);if(!g.items.hasOwnProperty(i)){g.items[i]=n;let e="number"==typeof t?t:-1;if(-1===e){const t=g.order.indexOf("object");e=t>-1?t:g.order.length}e=Math.min(Math.max(0,e),g.order.length),g.order.splice(e,0,i),r.push(i)}}return r}function b(e){if(!Array.isArray(e))throw new TypeError("Argument 'newOrder' must be an array of strings.");if(!e.every(e=>"string"==typeof e))throw new TypeError("All elements in 'newOrder' must be strings.");const t=[...g.order];return!!e.every(e=>t.includes(e))&&(g.order=e.slice(),!0)}function v(){return[...g.order]}const E=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 T(e,t){if(void 0===e)return null;if(void 0!==t&&"string"!=typeof t)throw new TypeError("Argument 'type' must be a string.");const r=E(e);return"string"==typeof t?r===t.toLowerCase():r}function S(e){const t={valid:null,type:null};for(const r of g.order)if("function"==typeof g.items[r]){const i=g.items[r](e);if(i){t.valid=i,t.type=r;break}}return t}w([["undefined",e=>void 0===e],["null",e=>null===e],["boolean",e=>"boolean"==typeof e],["number",e=>"number"==typeof e&&!Number.isNaN(e)],["bigint",e=>"bigint"==typeof e],["string",e=>"string"==typeof e],["symbol",e=>"symbol"==typeof e],["function",e=>"function"==typeof e],["array",e=>Array.isArray(e)]]),y&&w([["file",e=>"undefined"!=typeof File&&e instanceof File]]),w([["date",e=>e instanceof Date],["regexp",e=>e instanceof RegExp],["map",e=>e instanceof Map],["set",e=>e instanceof Set],["weakmap",e=>e instanceof WeakMap],["weakset",e=>e instanceof WeakSet],["promise",e=>e instanceof Promise]]),y&&w([["htmlelement",e=>"undefined"!=typeof HTMLElement&&e instanceof HTMLElement]]),w([["object",e=>f(e)]]);const x=()=>!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitIsFullScreen||document.mozFullScreen),A=()=>window.innerHeight===screen.height&&window.innerWidth===screen.width,C=()=>x()||A(),I=e=>new Promise(async(t,r)=>{const i=document.documentElement;try{i.requestFullscreen?await i.requestFullscreen(e):i.mozRequestFullScreen?i.mozRequestFullScreen(e):i.webkitRequestFullScreen?i.webkitRequestFullScreen(e):i.msRequestFullscreen&&i.msRequestFullscreen(e),t()}catch(e){r(e)}}),D=()=>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"],N=(e,t)=>{M.forEach(r=>{document.addEventListener(r,e,t)})},k=(e,t)=>{M.forEach(r=>{document.removeEventListener(r,e,t)})};function L(e,t,r,i=!1){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("val1 must be a finite number.");if("number"!=typeof t||!Number.isFinite(t))throw new TypeError("val2 must be a finite number.");if("number"!=typeof r||!Number.isFinite(r))throw new TypeError("val3 must be a finite number.");if("boolean"!=typeof i)throw new TypeError("inverse must be a boolean.");return i?Number(e*t)/r:Number(r*t)/e}function _(e,t){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("price must be a finite number.");if("number"!=typeof t||!Number.isFinite(t))throw new TypeError("percentage must be a finite number.");return e*(t/100)}function j(e,t){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("part must be a finite number.");if("number"!=typeof t||!Number.isFinite(t))throw new TypeError("total must be a finite number.");return 0===t?0:e/t*100}function R(e=0,t=null){if("number"!=typeof e&&"string"!=typeof e&&!(e instanceof Date))throw new TypeError("timeData must be a number, string, or Date object.");if(null!==t&&!(t instanceof Date))throw new TypeError("now must be a Date object or null.");const r=new Date(e);if(Number.isNaN(r.getTime()))return null;const i=t instanceof Date?t:new Date;let n=i.getFullYear()-r.getFullYear();const s=i.getMonth(),o=r.getMonth(),a=i.getDate(),l=r.getDate();return(s<o||s===o&&a<l)&&n--,Math.abs(n)}function P(e,t=null,r=null){if("number"!=typeof e||!Number.isFinite(e)||e<0)throw new TypeError("bytes must be a positive number.");if(0===e)return{unit:"Bytes",value:0};if(null!==t&&("number"!=typeof t||!Number.isFinite(t)))throw new TypeError("decimals must be a number or null.");const i=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"];if(null!==r){if("string"!=typeof r)throw new TypeError("maxUnit must be a string or null.");if(!i.includes(r))throw new RangeError(`maxUnit must be one of: ${i.join(", ")}`)}const n=r&&i.includes(r)?i.indexOf(r):i.length-1,s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),n);let o=e/Math.pow(1024,s);if(null!==t){const e=t<0?0:t;o=parseFloat(o.toFixed(e))}return{unit:i[s],value:o}}function $({baseValues:e=[0,1],length:t=10,combiner:r=(e,t)=>e+t}={}){if(!Array.isArray(e)||2!==e.length||!e.every(e=>"number"==typeof e))throw new Error("baseValues must be an array of exactly two numbers.");if("number"!=typeof t||!Number.isInteger(t))throw new RangeError("length must be an integer.");if("function"!=typeof r)throw new TypeError("combiner must be a function.");const i=[...e.slice(0,2)];for(let e=2;e<t;e++){const t=r(i[e-2],i[e-1],e);i.push(t)}return i}function H(e,t){if("number"!=typeof e||Number.isNaN(e)||!Number.isFinite(e))throw new TypeError("Original market cap must be a finite number.");if("number"!=typeof t||Number.isNaN(t)||!Number.isFinite(t))throw new TypeError("Circulating supply must be a finite number.");if(t<=0)throw new RangeError("Circulating supply must be greater than zero.");return e/t}function O(e,t,r){if("number"!=typeof r||Number.isNaN(r)||!Number.isFinite(r))throw new TypeError("New market cap must be a finite number.");const i=H(e,t),n="number"==typeof r?r/t:NaN;return{originalPrice:i,newPrice:n,priceChangePercent:"number"==typeof r?(n-i)/i*100:NaN}}async function F(e,t,r){if("string"!=typeof e)throw new TypeError("Expected a string for 'str', but received "+typeof e);if(!(t instanceof RegExp))throw new TypeError("Expected a RegExp for 'regex', but received "+typeof t);if("function"!=typeof r)throw new TypeError("Expected a function for 'asyncFn', but received "+typeof r);const i=[];e.replace(t,(e,...t)=>(i.push(r(e,...t)),e));const n=await Promise.all(i);return e.replace(t,()=>n.shift())}function B(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str', but received "+typeof e);return e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase())}function z(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str', but received "+typeof 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.");if("string"!=typeof e)throw new TypeError("Expected a string for 'config.key', but received "+typeof e);if("string"!=typeof t)throw new TypeError("Expected a string for 'config.className', but received "+typeof t);const r=function(r){if(r.ctrlKey&&r.altKey&&r.key.toLowerCase()===e){if(r.preventDefault(),!document.body)return void console.warn("[AiMarkerShortcut] <body> element not found. Cannot toggle class. Ensure the DOM is fully loaded when using the shortcut.");document.body.classList.toggle(t)}};return document.addEventListener("keydown",r),r}function q(e,t,r=.6){if("string"!=typeof e)throw new TypeError("Expected a string for 'text', but received "+typeof e);if(!Number.isInteger(t)||t<=0)throw new TypeError(`Expected 'limit' to be a positive integer, but received ${t}`);if("number"!=typeof r||r<0||r>1)throw new TypeError(`Expected 'safeCutZone' to be a number between 0 and 1, but received ${r}`);let i=e.trim();if(i.length>t){const e=i.lastIndexOf(" ",t);return e>0&&e>=t*r?`${i.substring(0,e).trim()}...`:`${i.substring(0,t).trim()}...`}return i}function V(e,t){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("Expected an object for 'oldStrings', but received "+(null===e?"null":typeof e));if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError("Expected an object for 'newStrings', but received "+(null===t?"null":typeof t));const r={added:{},removed:{},modified:{}};for(const i in e)i in t?e[i]!==t[i]&&(r.modified[i]={old:e[i],new:t[i]}):r.removed[i]=e[i];for(const i in t)i in e||(r.added[i]=t[i]);return r}const K=V;class J{#e;static#t={default:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""},solarized:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""},monokai:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""}};constructor(e={}){this.#e={...J.#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 i=`___KEY${r.length}___`;return r.push({marker:i,key:t}),`${i}:`})).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:i,key:n}of r){const r=new RegExp(i,"g");e=e.replace(r,`${t.key}"${n}"${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={...J.#t.default}}loadColorPreset(e){const t=J.#t[e];if(!t)throw new Error(`Preset "${e}" not found.`);this.#e={...t}}saveColorPreset(e,t){J.#t[e]={...t}}getAvailablePresets(){return Object.keys(J.#t)}}const U=J,G=class{#i=[];#n=!1;#s={};#o=new Set;isRunning(){return this.#n}async#a(e){if(e&&"function"==typeof e.task&&"function"==typeof e.resolve&&"function"==typeof e.reject){const{task:t,resolve:r,reject:i,delay:n,id:s}=e;try{if(s&&this.#o.has(s))return i(new Error("The function was canceled on TinyPromiseQueue.")),this.#o.delete(s),this.#n=!1,void this.#l();n&&s&&await new Promise(e=>{const t=setTimeout(()=>{delete this.#s[s],e(null)},n);this.#s[s]=t}),r(await t())}catch(e){i(e)}finally{this.#n=!1,this.#l()}}}async#u(){const e=[];for(;this.#i.length&&"POINT_MARKER"===this.#i[0]?.marker;)e.push(this.#i.shift());if(0===e.length)return this.#n=!1,void this.#l();await Promise.all(e.map(({task:e,resolve:t,reject:r,id:i})=>new Promise(async n=>{if(i&&this.#o.has(i))return this.#o.delete(i),r(new Error("The function was canceled on TinyPromiseQueue.")),void n(!0);await e().then(t).catch(r),n(!0)}))),this.#n=!1,this.#l()}async#l(){if(!this.#n&&0!==this.#i.length)if(this.#n=!0,"string"!=typeof this.#i[0]?.marker||"POINT_MARKER"!==this.#i[0]?.marker){const e=this.#i.shift();this.#a(e)}else this.#u()}getIndexById(e){return this.#i.findIndex(t=>t.id===e)}getQueuedIds(){return this.#i.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.#i.length||t>=this.#i.length)return;const[r]=this.#i.splice(e,1);this.#i.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.#n?new Promise((r,i)=>{this.#i.push({marker:"POINT_MARKER",task:e,resolve:r,reject:i,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((i,n)=>{this.#i.push({task:e,resolve:i,reject:n,id:r,delay:t}),this.#l()})}cancelTask(e){if("string"!=typeof e)throw new Error('The "id" parameter must be a string.');let t=!1;e in this.#s&&(clearTimeout(this.#s[e]),delete this.#s[e],t=!0);const r=this.getIndexById(e);if(-1!==r){const[e]=this.#i.splice(r,1);e?.reject?.(new Error("The function was canceled on TinyPromiseQueue.")),t=!0}return t&&this.#o.add(e),t}},Y=e=>t=>{if(t)throw new Error(`This ${e} instance has been destroyed and can no longer be used.`)},X=Y("TinyRateLimiter"),Q=class{#h=!1;get destroyed(){return this.#h}#c=null;#d=null;#m=null;#p=null;#f=null;#y=null;groupData=new Map;lastSeen=new Map;userToGroup=new Map;groupFlags=new Map;groupTTL=new Map;#g=null;setOnMemoryExceeded(e){if(X(this.#h),"function"!=typeof e)throw new Error("onMemoryExceeded must be a function");this.#g=e}clearOnMemoryExceeded(){X(this.#h),this.#g=null}#w=null;setOnGroupExpired(e){if(X(this.#h),"function"!=typeof e)throw new Error("onGroupExpired must be a function");this.#w=e}clearOnGroupExpired(){X(this.#h),this.#w=null}constructor({maxHits:e,interval:t,cleanupInterval:r,maxIdle:i=3e5,maxMemory:n=1e5}){const s=e=>"number"==typeof e&&Number.isFinite(e)&&e>=1&&Number.isInteger(e),o=s(e),a=s(t),l=s(r),u=s(i);if(!o&&!a)throw new Error("RateLimiter requires at least one valid option: 'maxHits' or 'interval'.");if(void 0!==e&&!o)throw new Error("'maxHits' must be a positive integer if defined.");if(void 0!==t&&!a)throw new Error("'interval' must be a positive integer in milliseconds if defined.");if(void 0!==r&&!l)throw new Error("'cleanupInterval' must be a positive integer in milliseconds if defined.");if(!u)throw new Error("'maxIdle' must be a positive integer in milliseconds.");if("number"==typeof n&&Number.isFinite(n)&&n>0)this.#c=Math.floor(n);else{if(null!=n)throw new Error("maxMemory must be a positive number or null");this.#c=null}this.#m=o?e:null,this.#p=a?t:null,this.#f=l?r:null,this.#y=i,null!==this.#f&&(this.#d=setInterval(()=>this._cleanup(),this.#f))}isGroupId(e){X(this.#h);const t=this.groupFlags.get(e);return"boolean"==typeof t&&t}getUsersInGroup(e){X(this.#h);const t=[];for(const[r,i]of this.userToGroup.entries())i===e&&t.push(r);return t}setGroupTTL(e,t){if(X(this.#h),"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 X(this.#h),this.groupTTL.get(e)??null}deleteGroupTTL(e){X(this.#h),this.groupTTL.delete(e)}assignToGroup(e,t){X(this.#h);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 i=this.groupData.get(e);if(this.isGroupId(e)){for(const[r,i]of this.userToGroup.entries())i===e&&this.userToGroup.set(r,t);this.userToGroup.delete(e)}else this.userToGroup.set(e,t);if(!i)return;const n=this.groupData.get(t);if(n)for(const e of i)n.push(e);else{const e=[];for(const t of i)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 X(this.#h),this.userToGroup.get(e)||e}hit(e){X(this.#h);const t=this.getGroupId(e),r=Date.now();this.groupData.has(t)||(this.groupData.set(t,[]),this.groupFlags.set(t,!1));const i=this.groupData.get(t);if(!i)throw new Error(`No data found for groupId: ${t}`);if(i.push(r),this.lastSeen.set(t,r),null!==this.#p){const e=r-this.getInterval();for(;i.length&&i[0]<e;)i.shift()}null!==this.#c&&"number"==typeof this.#c&&i.length>this.#c&&(i.splice(0,i.length-this.#c),"function"==typeof this.#g&&this.#g(t))}isRateLimited(e){X(this.#h);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 i=r.length-1;i>=0&&r[i]>e;i--)t++;return null!==this.#m?t>this.getMaxHits():t>0}return null!==this.#m&&r.length>this.getMaxHits()}resetGroup(e){X(this.#h),this.groupFlags.delete(e),this.groupData.delete(e),this.lastSeen.delete(e),this.groupTTL.delete(e)}resetUserGroup(e){X(this.#h),this.userToGroup.delete(e)}setData(e,t){if(X(this.#h),!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 X(this.#h),this.groupData.has(e)}getData(e){return X(this.#h),this.groupData.get(e)||[]}getMaxIdle(){if(X(this.#h),"number"!=typeof this.#y||!Number.isFinite(this.#y)||this.#y<0)throw new Error("'maxIdle' must be a non-negative finite number.");return this.#y}setMaxIdle(e){if(X(this.#h),"number"!=typeof e||!Number.isFinite(e)||e<0)throw new Error("'maxIdle' must be a non-negative finite number.");this.#y=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.#w&&this.#w(t))}getActiveGroups(){return X(this.#h),Array.from(this.groupData.keys())}getAllUserMappings(){return X(this.#h),Object.fromEntries(this.userToGroup)}getInterval(){if(X(this.#h),"number"!=typeof this.#p||!Number.isFinite(this.#p))throw new Error("'interval' is not a valid finite number.");return this.#p}getMaxHits(){if(X(this.#h),"number"!=typeof this.#m||!Number.isFinite(this.#m))throw new Error("'maxHits' is not a valid finite number.");return this.#m}getTotalHits(e){X(this.#h);const t=this.groupData.get(e);return Array.isArray(t)?t.length:0}getLastHit(e){X(this.#h);const t=this.groupData.get(e);return t?.length?t[t.length-1]:null}getTimeSinceLastHit(e){X(this.#h);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 X(this.#h),this._calculateAverageSpacing(this.groupData.get(e))}getMetrics(e){X(this.#h);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,i=t[r-1];return{totalHits:r,lastHit:i,timeSinceLastHit:Date.now()-i,averageHitSpacing:this._calculateAverageSpacing(t)}}destroy(){this.destroyed||(this.#d&&clearInterval(this.#d),this._cleanup(),this.groupData.clear(),this.lastSeen.clear(),this.userToGroup.clear(),this.groupTTL.clear(),this.groupFlags.clear(),this.#h=!0)}},Z=Y("TinyNotifyCenter");class ee{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,ee.getTemplate())}#h=!1;get destroyed(){return this.#h}#b;#v;#E;#T;#S;#x=0;#A=99;#C=300;#I=!1;#D=new WeakMap;#M(e){if(this.#D.delete(e),!(e instanceof HTMLElement))throw new Error("Invalid HTMLElement to clear.");e.classList.add("removing"),setTimeout(()=>{this.markAsRead(e),e.remove()},this.#C)}#N(e){this.#x=Math.max(0,e),this.#E.setAttribute("data-value",String(this.#x)),this.#E.textContent=this.#x>this.#A?`${this.#A}+`:String(this.#x)}constructor(e={}){const{center:t=document.getElementById("notifCenter"),badge:r=document.getElementById("notifBadge"),button:i=document.querySelector(".notify-bell"),overlay:n=document.querySelector(".notify-overlay")}=e;if(!(t instanceof HTMLElement))throw new Error(`NotificationCenter: "center" must be an HTMLElement. Got: ${t}`);if(!(n instanceof HTMLElement))throw new Error(`NotificationCenter: "overlay" must be an HTMLElement. Got: ${n}`);if(!(r instanceof HTMLElement))throw new Error(`NotificationCenter: "badge" must be an HTMLElement. Got: ${r}`);if(!(i instanceof HTMLElement))throw new Error(`NotificationCenter: "button" must be an HTMLElement. Got: ${i}`);const s=t?.querySelector(".clear-all"),o=t?.querySelector(".list")??null;if(!(o instanceof HTMLElement))throw new Error(`NotificationCenter: ".list" inside center must be an HTMLElement. Got: ${o}`);this.#b=t,this.#v=o,this.#E=r,this.#T=i,this.#S=n,this.#T.addEventListener("click",()=>this.toggle()),this.#b.querySelector(".close")?.addEventListener("click",()=>this.close()),s&&s.addEventListener("click",()=>this.clear()),this.#S.addEventListener("click",e=>{e.target===this.#S&&this.close()})}setMarkAllAsReadOnClose(e){if(Z(this.#h),"boolean"!=typeof e)throw new TypeError("Expected boolean for markAllAsReadOnClose, got "+typeof e);this.#I=e}setRemoveDelay(e){if(Z(this.#h),"number"!=typeof e)throw new Error('NotificationCenter: "ms" must be an number.');this.#C=e}getItemMode(e){Z(this.#h);const t=this.getItem(e);return t?this.#D.get(t):null}getItem(e){Z(this.#h);const t=this.#v.children.item(e);if(!(t instanceof HTMLElement))throw new Error(`NotificationCenter: "item" must be an HTMLElement. Got: ${t}`);return t}hasItem(e){return Z(this.#h),e>=0&&e<this.#v.children.length}markAsRead(e){Z(this.#h);const t=e instanceof HTMLElement?e:this.getItem(e);t.classList.contains("unread")&&(t.classList.remove("unread"),this.#N(this.#x-1))}add(e,t="text"){Z(this.#h);const r=document.createElement("div");r.className="item unread";let i=null,n=null,s=null,o=null;if("object"==typeof e&&null!==e?(i=e.title,n=e.message,s=e.avatar,o=e.onClick):n=e,s){const e=document.createElement("div");e.className="avatar",e.style.backgroundImage=`url("${s}")`,r.appendChild(e)}const a=document.createElement("div");if(a.className="content",i){const e=document.createElement("div");e.className="title",e.textContent=i,a.appendChild(e)}const l=document.createElement("div");l.className="message","html"===t?l.innerHTML=n:l.textContent=n,a.appendChild(l),"function"==typeof o&&(r.classList.add("clickable"),r.addEventListener("click",e=>{e.target instanceof HTMLElement&&!e.target.closest(".notify-close")&&o(e)}));const u=document.createElement("button");u.className="notify-close",u.setAttribute("type","button"),u.innerHTML="&times;",u.addEventListener("click",e=>{e.stopPropagation(),this.#M(r)}),r.append(a,u),this.#v.prepend(r),this.#D.set(r,t),this.#N(this.#x+1)}remove(e){Z(this.#h);const t=this.getItem(e);this.#M(t)}clear(){Z(this.#h);let e=!0;for(;e;){e=!1;const t=Array.from(this.#v.children);for(const r of t)r instanceof HTMLElement&&!r.classList.contains("removing")&&(this.#M(r),e=!0)}}open(){Z(this.#h),this.#S.classList.remove("hidden"),this.#b.classList.add("open")}close(){if(Z(this.#h),this.#S.classList.add("hidden"),this.#b.classList.remove("open"),this.#I){const e=this.#v.querySelectorAll(".item.unread");for(const t of e)t instanceof HTMLElement&&this.markAsRead(t)}}toggle(){Z(this.#h),this.#b.classList.contains("open")?this.close():this.open()}recount(){Z(this.#h);const e=this.#v.querySelectorAll(".item.unread").length;this.#N(e)}get count(){return this.#x}destroy(){this.#h||(this.#T?.removeEventListener("click",this.toggle),this.#b?.querySelector(".close")?.removeEventListener("click",this.close),this.#b?.querySelector(".clear-all")?.removeEventListener("click",this.clear),this.#S?.removeEventListener("click",this.close),this.clear(),this.#b?.remove(),this.#S?.remove(),this.#T?.remove(),this.#x=0,this.#D=new WeakMap,this.#h=!0)}}const te=ee,re=Y("TinyToastNotify"),ie=class{#k;#L;#_;#j;#R;#P;#h=!1;get destroyed(){return this.#h}constructor(e="top",t="right",r=3e3,i=50,n=300,s=".notify-container"){this.#$(e),this.#H(t),this.#O(r,"baseDuration"),this.#O(i,"extraPerChar"),this.#O(n,"fadeOutDuration"),this.#k=e,this.#L=t,this.#_=r,this.#j=i,this.#R=n;const o=document.querySelector(`${s}.${e}.${t}`);o instanceof HTMLElement?this.#P=o:(this.#P=document.createElement("div"),this.#P.className=`notify-container ${e} ${t}`,document.body.appendChild(this.#P))}getContainer(){if(re(this.#h),!(this.#P instanceof HTMLElement))throw new Error("Container is not a valid HTMLElement.");return this.#P}#$(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".`)}#O(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 re(this.#h),this.#k}setY(e){re(this.#h),this.#$(e);const t=this.getContainer();t.classList.remove(this.#k),t.classList.add(e),this.#k=e}getX(){return re(this.#h),this.#L}setX(e){re(this.#h),this.#H(e);const t=this.getContainer();t.classList.remove(this.#L),t.classList.add(e),this.#L=e}getBaseDuration(){return re(this.#h),this.#_}setBaseDuration(e){re(this.#h),this.#O(e,"baseDuration"),this.#_=e}getExtraPerChar(){return re(this.#h),this.#j}setExtraPerChar(e){re(this.#h),this.#O(e,"extraPerChar"),this.#j=e}getFadeOutDuration(){return re(this.#h),this.#R}setFadeOutDuration(e){re(this.#h),this.#O(e,"fadeOutDuration"),this.#R=e}show(e){re(this.#h);let t="",r="",i=null,n=!1,s=null;const o=document.createElement("div");if(o.className="notify enter","string"==typeof e)t=e;else{if("object"!=typeof e||null===e||"string"!=typeof e.message)throw new Error("Invalid argument for show(): expected string or { message: string, title?: string, onClick?: function, html?: boolean, avatar?: string }");if(t=e.message,r="string"==typeof e.title?e.title:"",n=!0===e.html,s="string"==typeof e.avatar?e.avatar:null,void 0!==e.onClick){if("function"!=typeof e.onClick)throw new Error("onClick must be a function if defined");i=e.onClick,o.classList.add("clickable")}}const a=document.createElement("button");if(a.innerHTML="&times;",a.className="close",a.setAttribute("aria-label","Close"),a.addEventListener("mouseenter",()=>{a.style.color="var(--notify-close-color-hover)"}),a.addEventListener("mouseleave",()=>{a.style.color="var(--notify-close-color)"}),s){const e=document.createElement("img");e.src=s,e.alt="avatar",e.className="avatar",o.appendChild(e)}if(r){const e=document.createElement("strong");e.textContent=r,e.style.display="block",o.appendChild(e)}if(n){const e=document.createElement("div");e.innerHTML=t,o.appendChild(e)}else o.appendChild(document.createTextNode(t));o.appendChild(a),this.getContainer().appendChild(o);const l=this.#_+t.length*this.#j+this.#R;let u=!1;const h=()=>{u||(u=!0,o.classList.remove("enter","show"),o.classList.add("exit"),setTimeout(()=>o.remove(),this.#R))};"function"==typeof i&&o.addEventListener("click",e=>{e.target!==a&&i(e,h)}),a.addEventListener("click",e=>{e.stopPropagation(),h()}),setTimeout(()=>{o.classList.remove("enter"),o.classList.add("show")},1),setTimeout(()=>h(),l)}destroy(){this.#h||this.#P instanceof HTMLElement&&(this.#P.querySelectorAll(".notify").forEach(e=>e.remove()),this.#P.parentNode&&this.#P.parentNode.removeChild(this.#P),this.#P=null,this.#h=!0)}};function ne(e,t){if(!(e instanceof Blob))return Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'));const r=["readAsArrayBuffer","readAsDataURL","readAsText","readAsBinaryString"];return"string"==typeof t&&r.includes(t)?new Promise((r,i)=>{const n=new FileReader;n.onload=()=>{try{r(n.result)}catch(e){i(e)}},n.onerror=()=>{i(n.error)},n[t](e)}):Promise.reject(new TypeError(`The "method" argument must be one of: ${r.join(", ")}.`))}function se(e,t=!1){return e instanceof Blob?"string"!=typeof t&&"boolean"!=typeof t?Promise.reject(new TypeError("The isDataUrl parameter must be a boolean or a string.")):new Promise((r,i)=>{ne(e,"readAsDataURL").then(e=>{if("string"!=typeof e)throw new TypeError("Expected file content to be a string.");const i=e.match(/^data:(.+);base64,(.*)$/);if(!i||!i[2])throw new Error("Invalid data URL format or missing Base64 content.");const[,n,s]=i;if(!/^[\w/+]+=*$/.test(s))throw new Error("Base64 content is malformed.");if("boolean"==typeof t)return r(t?e:s);if(!/^[\w-]+\/[\w.+-]+$/.test(t))throw new Error(`Invalid MIME type string: ${t}`);return r(`data:${t};base64,${s}`)}).catch(i)}):Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'))}function oe(e){return e instanceof Blob?new Promise((t,r)=>ne(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 i=JSON.parse(r);if("object"!=typeof i||null===i)throw new Error("Parsed content is not a valid JSON object or array.");t(i)}).catch(r)):Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'))}function ae(e,t,r=2){if("string"!=typeof e)throw new TypeError('The "filename" argument must be a string.');if("number"!=typeof r||!Number.isInteger(r)||r<0)throw new TypeError('The "spaces" argument must be a non-negative integer.');const i=JSON.stringify(t,null,r),n=new Blob([i],{type:"application/json"}),s=URL.createObjectURL(n),o=document.createElement("a");o.href=s,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(s)}function le(e,t,r=e=>({headers:e.headers,status:e.status,statusText:e.statusText})){if(!(e instanceof Response))throw new TypeError('The "response" argument must be an instance of Response.');if("function"!=typeof t)throw new TypeError('The "onProgress" argument must be a function.');if(!e.body)return e;const i=e.headers.get("content-length"),n=i?parseInt(i,10):0;let s=0;const o=e.body.getReader(),a=new ReadableStream({async start(e){for(;;){const{done:r,value:i}=await o.read();if(r)break;s+=i.byteLength,t(s,n),e.enqueue(i)}e.close()}});return new Response(a,r(e))}async function ue(e,t,r){return"string"!=typeof e?Promise.reject(new TypeError('The "url" argument must be a string.')):void 0!==t&&"object"!=typeof t?Promise.reject(new TypeError('The "options" argument must be an object.')):void 0!==r&&"function"!=typeof r?Promise.reject(new TypeError('The "onProgress" option must be a function.')):new Promise((i,n)=>{fetch(e,t??void 0).then(async e=>{const t=r?le(e,r):e,n=t.headers.get("content-type")||"";if(!n.includes("application/json"))throw new Error(`Unexpected content-type: ${n}`);const s=await t.json();if(!Array.isArray(s)&&!f(s))throw new Error("Received invalid data instead of valid JSON.");return i(s)}).catch(n)})}async function he(e,t,r,i){return"string"!=typeof e?Promise.reject(new TypeError('The "url" argument must be a string.')):void 0===t||Array.isArray(t)?void 0!==r&&"object"!=typeof r?Promise.reject(new TypeError('The "options" argument must be an object.')):void 0!==i&&"function"!=typeof i?Promise.reject(new TypeError('The "onProgress" option must be a function.')):new Promise((n,s)=>{fetch(e,r??void 0).then(async e=>{const r=i?le(e,i):e,s=r.headers.get("content-type")||"";if(Array.isArray(t)&&t.length>0&&!t.some(e=>s.includes(e)))throw new Error(`Blocked MIME type: ${s}`);const o=await r.text();return n(o)}).catch(s)}):Promise.reject(new TypeError('The "allowedMimeTypes" argument must be an array of strings.'))}function ce(e={}){if(null===e||"object"!=typeof e)throw new TypeError('The "settings" argument must be an object.');const{element:t=document.body,hiddenClass:r="windowHidden",visibleClass:i="windowVisible",onVisible:n,onHidden:s}=e;if(!(t instanceof Element))throw new TypeError('"element" must be an instance of Element.');if("string"!=typeof r)throw new TypeError('"hiddenClass" must be a string.');if("string"!=typeof i)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!==s&&"function"!=typeof s)throw new TypeError('"onHidden" must be a function if provided.');let o="",a="";const l=()=>{t.classList.remove(r),t.classList.remove(i)};let u=null;const h=["visibilitychange","mozvisibilitychange","webkitvisibilitychange","msvisibilitychange"],c=["hidden","mozHidden","webkitHidden","msHidden"];for(let e=0;e<c.length;e++)if(c[e]in document){u=c[e];break}const d=function(e){l();const h=e?.type,c=u&&document[u];["focus","focusin","pageshow"].includes(h)?(t.classList.add(i),n?.({type:h,oldClass:a,oldType:o}),a=i):["blur","focusout","pagehide"].includes(h)||c?(t.classList.add(r),s?.({type:h,oldClass:a,oldType:o}),a=r):(t.classList.add(i),n?.({type:h,oldClass:a,oldType:o}),a=i),o=h};let m=()=>{};if(u){const e=h[c.indexOf(u)];document.addEventListener(e,d),window.addEventListener("focus",d),window.addEventListener("blur",d),m=()=>{document.removeEventListener(e,d),window.removeEventListener("focus",d),window.removeEventListener("blur",d),l()}}else"onfocusin"in document?(document.onfocusin=document.onfocusout=d,m=()=>{document.onfocusin=document.onfocusout=null,l()}):(window.onpageshow=window.onpagehide=window.onfocus=window.onblur=d,m=()=>{window.onpageshow=window.onpagehide=window.onfocus=window.onblur=null,l()});const p=new Event(u&&document[u]?"blur":"focus");return d(p),m}const de=Y("TinyDragDropDetector"),me=class{#F;#B;#z;#W;#q;#V;#K;#h=!1;get destroyed(){return this.#h}constructor(e,t){const{hoverClass:r="dnd-hover",onDrop:i,onEnter:n,onLeave:s}=t;if(!(e instanceof HTMLElement))throw new TypeError('The "target" option must be an instance of HTMLElement.');if("string"!=typeof r)throw new TypeError('The "hoverClass" option must be a string.');if("function"!=typeof i)throw new TypeError('The "onDrop" option must be a function.');if("function"!=typeof n)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.#F=e,this.#B=r,this.#z=i||(()=>{}),this.#W=n,this.#q=s,this.#V=!1,this.#K=!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.#J()}getTarget(){return de(this.#h),this.#F}getHoverClass(){return de(this.#h),this.#B}isDragging(){return de(this.#h),this.#V}bound(){return de(this.#h),this.#K}#J(){if(this.#K)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.#K=!0}#U(){if(!this.#K)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.#K=!1}_handleDragEnter(e){if(e.preventDefault(),!this.#V){const t=this.getTarget();this.#V=!0,t.classList.add(this.#B),this.#W(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.#B),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.#B);const r=e.dataTransfer.files;r.length>0&&this.#z(r,e)}destroy(){this.#h||(this.#U(),this.getTarget().classList.remove(this.#B),this.#h=!0)}};var pe=r(133),fe=r(975);function ye(e){if(!(0,pe.existsSync)(e))throw new Error(`File not found: ${e}`);const t=(0,pe.readFileSync)(e,"utf-8");return JSON.parse(t)}function ge(e,t,r=2){const i=JSON.stringify(t,null,r);(0,pe.writeFileSync)(e,i,"utf-8")}function we(e){(0,pe.existsSync)(e)||(0,pe.mkdirSync)(e,{recursive:!0})}function be(e){if(!(0,pe.existsSync)(e))return;const t=(0,pe.readdirSync)(e);for(const r of t){const t=(0,fe.join)(e,r);(0,pe.lstatSync)(t).isDirectory()?(0,pe.rmSync)(t,{recursive:!0,force:!0}):(0,pe.unlinkSync)(t)}}function ve(e){return(0,pe.existsSync)(e)&&(0,pe.lstatSync)(e).isFile()}function Ee(e){return(0,pe.existsSync)(e)&&(0,pe.lstatSync)(e).isDirectory()}function Te(e){return 0===(0,pe.readdirSync)(e).length}function Se(e,t,r){we((0,fe.dirname)(t)),(0,pe.copyFileSync)(e,t,r)}function xe(e){return!!ve(e)&&((0,pe.unlinkSync)(e),!0)}function Ae(e,t,r="utf-8"){we((0,fe.dirname)(e)),(0,pe.writeFileSync)(e,t,r)}function Ce(e,t=!1){const r={files:[],dirs:[]};if(!Ee(e))return r;const i=(0,pe.readdirSync)(e);for(const n of i){const i=(0,fe.join)(e,n);if((0,pe.lstatSync)(i).isDirectory()){if(r.dirs.push(i),t){const e=Ce(i,!0);r.files.push(...e.files),r.dirs.push(...e.dirs)}}else r.files.push(i)}return r}function Ie(e,t=!1){const r=[];if(!Ee(e))return r;const i=(0,pe.readdirSync)(e);for(const n of i){const i=(0,fe.join)(e,n);(0,pe.lstatSync)(i).isDirectory()&&(r.push(i),t&&r.push(...Ie(i,!0)))}return r}function De(e){return ve(e)?(0,pe.statSync)(e).size:0}function Me(e){let t=0;const r=Ce(e,!0).files;for(const e of r)t+=De(e);return t}function Ne(e,t="bak"){ve(e)&&Se(e,`${e}.${t}.${(new Date).toISOString().replace(/[:.]/g,"-")}`)}function ke(e,t="bak"){const r=(0,fe.dirname)(e),i=(0,fe.basename)(e),n=(0,pe.readdirSync)(r).filter(e=>e.startsWith(`${i}.${t}.`)).sort().reverse();if(0===n.length)throw new Error(`No backups found for ${e}`);return(0,fe.join)(r,n[0])}function Le(e,t="bak"){Se(ke(e,t),e)}function _e(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,pe.existsSync)(e)||!(0,pe.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 i=Ce(e).files;let n=0;for(const s of i){const i=(0,fe.extname)(s);if(r.length&&!r.includes(i))continue;const o=(0,fe.basename)(s),a=t(o,n++),l=(0,fe.join)(e,a);o!==a&&(0,pe.renameSync)(s,l)}}function je(e,t,r,i=[]){_e(e,e=>{const i=(0,fe.extname)(e);return`${(0,fe.basename)(e,i).replace(t,r)}${i}`},i)}function Re(e,{prefix:t="",suffix:r=""},i=[]){_e(e,e=>{const i=(0,fe.extname)(e),n=(0,fe.basename)(e,i);return`${t}${n}${r}${i}`},i)}function Pe(e,t="lower",r=[],i=!1){if("string"!=typeof t||!["lower","upper","title"].includes(t))throw new Error(`Invalid mode "${t}". Must be 'lower', 'upper' or 'title'.`);_e(e,e=>{const r=e=>"lower"===t?e.toLowerCase():"upper"===t?e.toUpperCase():"title"===t?B(e):e,n=(0,fe.extname)(e),s=i?r(n):n;return`${r((0,fe.basename)(e,n))}${s}`},r)}function $e(e,t=3,r=[]){_e(e,e=>e.replace(/\d+/,e=>e.padStart(t,"0")),r)}var He=r(370);async function Oe(e){if(!(0,pe.existsSync)(e))return;const t=await(0,He.readdir)(e),r={},i=[];for(const n of t){const t=(0,fe.join)(e,n),s=(0,He.lstat)(t);s.then(e=>(r[t]=e,e)),i.push(s)}await Promise.all(i);const n=[];for(const e in r)r[e].isDirectory()?n.push((0,He.rm)(e,{recursive:!0,force:!0})):n.push((0,He.unlink)(e));await Promise.all(n)}async function Fe(e){return 0===(await(0,He.readdir)(e)).length}async function Be(e,t=!1){const r={files:[],dirs:[]};if(!Ee(e))return r;const i=await(0,He.readdir)(e);for(const n of i){const i=(0,fe.join)(e,n);if((await(0,He.lstat)(i)).isDirectory()){if(r.dirs.push(i),t){const e=await Be(i,!0);r.files.push(...e.files),r.dirs.push(...e.dirs)}}else r.files.push(i)}return r}async function ze(e,t=!1){const r=[];if(!Ee(e))return r;const i=await(0,He.readdir)(e);for(const n of i){const i=(0,fe.join)(e,n);(await(0,He.lstat)(i)).isDirectory()&&(r.push(i),t&&r.push(...await ze(i,!0)))}return r}async function We(e){return ve(e)?(await(0,He.stat)(e)).size:0}async function qe(e){let t=0;const{files:r}=await Be(e,!0),i=[];for(const e of r){const r=We(e);r.then(e=>(t+=e,e)),i.push(r)}return await Promise.all(i),t}const Ve=(e,t)=>e.bottom<t.top,Ke=(e,t)=>e.top>t.bottom,Je=(e,t)=>e.right<t.left,Ue=(e,t)=>e.left>t.right,Ge=(e,t)=>e.bottom<=t.top,Ye=(e,t)=>e.top>=t.bottom,Xe=(e,t)=>e.right<=t.left,Qe=(e,t)=>e.left>=t.right,Ze=(e,t)=>!(Je(e,t)||Ue(e,t)||Ve(e,t)||Ke(e,t)),et=(e,t)=>!(Xe(e,t)||Qe(e,t)||Ge(e,t)||Ye(e,t)),tt=(e,t)=>Je(e,t)?"left":Ue(e,t)?"right":Ve(e,t)?"top":Ke(e,t)?"bottom":null,rt=(e,t)=>Xe(e,t)?"left":Qe(e,t)?"right":Ge(e,t)?"top":Ye(e,t)?"bottom":null,it=(e,t)=>({overlapLeft:t.right-e.left,overlapRight:e.right-t.left,overlapTop:t.bottom-e.top,overlapBottom:e.bottom-t.top}),nt=({overlapLeft:e=-1,overlapRight:t=-1,overlapTop:r=-1,overlapBottom:i=-1}={})=>({dirX:e<t?"right":"left",dirY:r<i?"bottom":"top"}),st=e=>({x:e.left+e.width/2,y:e.top+e.height/2});function ot(e,t){const r=e.left+e.width/2,i=e.top+e.height/2;return{x:t.left+t.width/2-r,y:t.top+t.height/2-i}}function at(e,t){if(!et(e,t))return{inDir:null,dirX:null,dirY:null,depthX:0,depthY:0};const{overlapLeft:r,overlapRight:i,overlapTop:n,overlapBottom:s}=it(e,t),{dirX:o,dirY:a}=nt({overlapLeft:r,overlapRight:i,overlapTop:n,overlapBottom:s}),l=Math.min(r,i),u=Math.min(n,s);let h;return h=l<u?o:a,{inDir:h,dirX:o,dirY:a,depthX:l,depthY:u}}function lt(e,t){const r=et(e,t),i={in:null,x:null,y:null},n={y:null,x:null},s={top:0,bottom:0,left:0,right:0},{overlapLeft:o,overlapRight:a,overlapTop:l,overlapBottom:u}=it(t,e);s.top=l,s.bottom=u,s.left=o,s.right=a;const h=Object.entries(s).filter(([,e])=>e>0).sort((e,t)=>e[1]-t[1]),{dirX:c,dirY:d}=nt({overlapLeft:a,overlapRight:o,overlapTop:u,overlapBottom:l});return i.y=d,i.x=c,s.bottom<0?n.y="bottom":s.top<0&&(n.y="top"),s.left<0?n.x="left":s.right<0&&(n.x="right"),i.in=r?s.top===s.bottom&&s.bottom===s.left&&s.left===s.right?"center":h.length?h[0][0]:"top":null,{dirs:i,depth:s,isNeg:n}}const ut=Y("TinyElementObserver"),ht=class{#h=!1;get destroyed(){return this.#h}#G;get el(){return ut(this.#h),this.#G}#Y={};get settings(){return ut(this.#h),this.#Y}set settings(e){if(ut(this.#h),"object"!=typeof e||null===e)throw new TypeError("settings must be a non-null object.");this.#Y=e}#X=null;get observer(){return ut(this.#h),this.#X}#Q=[];get detectors(){return ut(this.#h),this.#Q.map(e=>[e[0],e[1]])}set detectors(e){if(ut(this.#h),!Array.isArray(e))throw new TypeError("detectors must be an array.");const t=[];for(const[r,i]of e){if("string"!=typeof r)throw new TypeError("Detector name must be a string.");if("function"!=typeof i)throw new TypeError(`Detector handler for "${r}" must be a function.`);t.push([r,i])}this.#Q=t}get isActive(){return ut(this.#h),!!this.#X}get size(){return ut(this.#h),this.#Q.length}constructor(e,{initDetectors:t=[],initCfg:r={}}={}){this.#G=e,t.length&&(this.detectors=t),r&&(this.settings=r)}clear(){ut(this.#h),this.#Q=[]}start(){if(ut(this.#h),!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(i=>i[1](e,t,r)))}),this.#X.observe(this.#G,this.#Y))}stop(){ut(this.#h),this.#X&&(this.#X.disconnect(),this.#X=null)}add(e,t){ut(this.#h),this.#Z(e,t),this.#Q.push([e,t])}insertAtStart(e,t){ut(this.#h),this.#Z(e,t),this.#Q.unshift([e,t])}insertAt(e,t,r,i="after"){if(ut(this.#h),this.#Z(t,r),"number"!=typeof e||e<0||e>=this.#Q.length)throw new RangeError("Invalid index for insertDetectorAt.");const n="before"===i?e:e+1;this.#Q.splice(n,0,[t,r])}removeAt(e){if(ut(this.#h),"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(ut(this.#h),"number"!=typeof e||e<0||e>=this.#Q.length)throw new RangeError("Invalid index for removeDetectorsAround.");const i=Math.max(0,e-t),n=t+1+r;this.#Q.splice(i,n)}isIndexUsed(e){return ut(this.#h),e>=0&&e<this.#Q.length}hasHandler(e){if(ut(this.#h),"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.#h||(this.stop(),this.clear(),this.#h=!0)}},{wE:ct,D6:dt,Kr:mt,iu:pt,cq:ft,lP:yt}=e,gt=new WeakMap,wt=new WeakMap,bt=new WeakMap,vt=new WeakMap,Et={top:new WeakMap,bottom:new WeakMap,left:new WeakMap,right:new WeakMap};class Tt{static Utils={...t};static#ee=1;static get version(){return this.#ee}static#te=!1;static get elemDebug(){return Tt.#te}static set elemDebug(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean value for elemDebug");Tt.#te=e}static _debugElemError(e,t){if(!Tt.#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,Tt._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,i]=e.split(":").map(e=>e&&e.trim());r&&i&&(t[r]=i)}),t}static#re="undefined"!=typeof window&&void 0!==window.document?new ht(window.document.documentElement,{initDetectors:[["tinyStyleEvent",e=>{if("attributes"!==e.type||"style"!==e.attributeName||!(e.target instanceof HTMLElement))return;const t=e.oldValue||"",r=e.target.getAttribute("style")||"",i=V(Tt.parseStyle(t),Tt.parseStyle(r));(Object.keys(i.added).length||Object.keys(i.removed).length||Object.keys(i.modified).length)&&e.target.dispatchEvent(new CustomEvent("tinyhtml.stylechanged",{detail:i}))}],["tinyClassEvent",e=>{if("attributes"!==e.type||"class"!==e.attributeName||!(e.target instanceof HTMLElement))return;const t=e.oldValue||"",r=e.target.className||"",i=a(t.split(/\s+/).filter(Boolean),r.split(/\s+/).filter(Boolean));(i.added.length||i.removed.length)&&e.target.dispatchEvent(new CustomEvent("tinyhtml.classchanged",{detail:i}))}]],initCfg:{attributeOldValue:!0,attributes:!0,subtree:!0,attributeFilter:["style","class"]}}):void 0;static get tinyObserver(){return Tt.#re}static async fetchHtmlFile(e,t={method:"GET"}){const r=await fetch(e,t),i=r.headers.get("Content-Type")||"";if(!r.ok)throw new Error(`Failed to fetch: ${r.status} ${r.statusText}`);if(!i.includes("text/html"))throw new Error(`Invalid content type: ${i} (expected text/html)`);const n=await r.text();return Tt.htmlToJson(n)}static async fetchHtmlNodes(e,t){const r=await Tt.fetchHtmlFile(e,t);return Tt.jsonToNodes(r)}static async fetchHtmlTinyElems(e,t){const r=await Tt.fetchHtmlNodes(e,t);return Tt.toTinyElm(r)}static templateToJson(e){return Tt.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 Tt.toTinyElm(Tt.templateToNodes(e))}static htmlToJson(e){const t=document.createElement("div");t.innerHTML=e.trim();const r=[],i=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[Tt.getPropName(t.name)]=t.value;const n=Array.from(e.childNodes).map(i).filter(Boolean);return n.length>0?[t,r,...n]:[t,r]};for(const e of t.childNodes){const t=i(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,i,...n]=e,s=document.createElement(r);for(const[e,t]of Object.entries(i))s.setAttribute(Tt.getAttrName(e),t);for(const e of n){const r=t(e);r instanceof Comment||s.appendChild(r)}return s};return e.map(t).filter(e=>!(e instanceof Comment))}static jsonToTinyElems(e){return Tt.toTinyElm(Tt.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=Tt.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 Tt(document.createElement(e,t))}static createTextNode(e){if("string"!=typeof e)throw new TypeError("[TinyHtml] createTextNode(): The value must be a string.");return new Tt(document.createTextNode(e))}static createElementFromHTML(e){const t=document.createElement("template");if(!(e=e.trim()).startsWith("<"))return Tt.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 Tt(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 Tt(r)}static createFromHtml(e){return Tt.createFromHTML(e)}static query(e,t=document){const r=t.querySelector(e);return r?new Tt(r):null}querySelector(e){return Tt.query(e,Tt._preElem(this,"query"))}static queryAll(e,t=document){return new Tt(t.querySelectorAll(e))}querySelectorAll(e){return Tt.queryAll(e,Tt._preElem(this,"queryAll"))}static getById(e){const t=document.getElementById(e);return t?new Tt(t):null}static getByClassName(e,t=document){return new Tt(t.getElementsByClassName(e))}getElementsByClassName(e){return Tt.getByClassName(e,Tt._preElem(this,"getByClassName"))}static getByName(e){return new Tt(document.getElementsByName(e))}static getByTagNameNS(e,t="http://www.w3.org/1999/xhtml",r=document){return new Tt(r.getElementsByTagNameNS(t,e))}getElementsByTagNameNS(e,t="http://www.w3.org/1999/xhtml"){return Tt.getByTagNameNS(e,t,Tt._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 Tt(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 Tt._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 Tt._debugElemError([...this.#G]),new Error(`[TinyHtml] Invalid Element in ${e}().`);return[...this.#G]}static _preElemsTemplate(e,t,r,i){const n=e=>{const n=[];return e.map(s=>(s instanceof Tt?s._getElements(t):[s]).map(s=>{let o=!1;for(const e of r)if(s instanceof e){o=!0;break}if(!o)throw Tt._debugElemError([...e],s),new Error(`[TinyHtml] Invalid element of the list "${i.join(",")}" in ${t}().`);return n.push(s),s})),n};return Array.isArray(e)?n(e):n([e])}_preElemsTemplate(e,t,r){return Tt._preElemsTemplate(this,e,t,r)}static _preElemTemplate(e,t,r,i,n=!1){const s=e=>{const s=e[0],o=s instanceof Tt?s._getElements(t):[s];if(o.length>1)throw Tt._debugElemError([...e]),new Error(`[TinyHtml] Invalid element amount in ${t}() (Received ${o.length}/1).`);let a=!1;for(const e of r)if(o[0]instanceof e){a=!0;break}if(!n||null!==o[0]&&void 0!==o[0]||(o[0]=null,a=!0),!a)throw Tt._debugElemError([...e],o[0]),new Error(`[TinyHtml] Invalid element of the list "${i.join(",")}" in ${t}().`);return o[0]};if(!Array.isArray(e))return s([e]);if(e.length>1)throw Tt._debugElemError([...e]),new Error(`[TinyHtml] Invalid element amount in ${t}() (Received ${e.length}/1).`);return s(e)}_preElemTemplate(e,t,r,i=!1){return Tt._preElemTemplate(this,e,t,r,i)}static _preElems(e,t){return Tt._preElemsTemplate(e,t,[Element],["Element"])}_preElems(e){return Tt._preElems(this,e)}static _preElem(e,t){return Tt._preElemTemplate(e,t,[Element],["Element"])}_preElem(e){return Tt._preElem(this,e)}static _preNodeElems(e,t){return Tt._preElemsTemplate(e,t,[Node],["Node"])}_preNodeElems(e){return Tt._preNodeElems(this,e)}static _preNodeElem(e,t){return Tt._preElemTemplate(e,t,[Node],["Node"])}_preNodeElem(e){return Tt._preNodeElem(this,e)}static _preNodeElemWithNull(e,t){return Tt._preElemTemplate(e,t,[Node],["Node"],!0)}_preNodeElemWithNull(e){return Tt._preNodeElemWithNull(this,e)}static _preHtmlElems(e,t){return Tt._preElemsTemplate(e,t,[HTMLElement],["HTMLElement"])}_preHtmlElems(e){return Tt._preHtmlElems(this,e)}static _preHtmlElem(e,t){return Tt._preElemTemplate(e,t,[HTMLElement],["HTMLElement"])}_preHtmlElem(e){return Tt._preHtmlElem(this,e)}static _preInputElems(e,t){return Tt._preElemsTemplate(e,t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElems(e){return Tt._preInputElems(this,e)}static _preInputElem(e,t){return Tt._preElemTemplate(e,t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElem(e){return Tt._preInputElem(this,e)}static _preEventTargetElems(e,t){return Tt._preElemsTemplate(e,t,[EventTarget],["EventTarget"])}_preEventTargetElems(e){return Tt._preEventTargetElems(this,e)}static _preEventTargetElem(e,t){return Tt._preElemTemplate(e,t,[EventTarget],["EventTarget"])}_preEventTargetElem(e){return Tt._preEventTargetElem(this,e)}static _preElemsAndWindow(e,t){return Tt._preElemsTemplate(e,t,[Element,Window],["Element","Window"])}_preElemsAndWindow(e){return Tt._preElemsAndWindow(this,e)}static _preElemAndWindow(e,t){return Tt._preElemTemplate(e,t,[Element,Window],["Element","Window"])}_preElemAndWindow(e){return Tt._preElemAndWindow(this,e)}static _preElemsAndWinAndDoc(e,t){return Tt._preElemsTemplate(e,t,[Element,Window,Document],["Element","Window","Document"]).map(e=>e instanceof Document?e.documentElement:e)}_preElemsAndWinAndDoc(e){return Tt._preElemsAndWinAndDoc(this,e)}static _preElemAndWinAndDoc(e,t){const r=Tt._preElemTemplate(e,t,[Element,Window,Document],["Element","Window","Document"]);return r instanceof Document?r.documentElement:r}_preElemAndWinAndDoc(e){return Tt._preElemAndWinAndDoc(this,e)}static _preElemsWithDoc(e,t){return Tt._preElemsTemplate(e,t,[Element,Document],["Element","Document"])}_preElemsWithDoc(e){return Tt._preElemsWithDoc(this,e)}static _preElemWithDoc(e,t){return Tt._preElemTemplate(e,t,[Element,Document],["Element","Document"])}_preElemWithDoc(e){return Tt._preElemWithDoc(this,e)}static toTinyElm(e){const t=e=>e.map(e=>e instanceof Tt?e:new Tt(e));return Array.isArray(e)?t(e):t([e])}static fromTinyElm(e){const t=e=>{const t=[];return e.map(e=>(e instanceof Tt?e._getElements("fromTinyElm"):[e]).map(e=>t.push(e))),t};return Array.isArray(e)?t(e):t([e])}static winnow(e,t,r,i=!1){if("boolean"!=typeof i)throw new TypeError('The "not" must be a boolean.');if("function"==typeof t)return Tt._preElems(e,r).filter((e,r)=>!!t.call(e,r,e)!==i);if(t instanceof Element)return Tt._preElems(e,r).filter(e=>e===t!==i);if(Array.isArray(t)||"string"!=typeof t&&null!=t.length)return Tt._preElems(e,r).filter(e=>t.includes(e)!==i);let n=t;return i&&(n=`:not(${n})`),Tt._preElems(e,r).filter(e=>1===e.nodeType&&e.matches(n))}static filter(e,t,r=!1){return r&&(t=`:not(${t})`),Tt._preElems(e,"filter").filter(e=>1===e.nodeType&&e.matches(t))}static filterOnly(e,t){return Tt.winnow(e,t,"filterOnly",!1)}static not(e,t){return Tt.winnow(e,t,"not",!0)}not(e){return Tt.not(this,e)}static find(e,t){const r=[];for(const i of Tt._preElems(e,"find"))r.push(...i.querySelectorAll(t));return[...new Set(r)]}find(e){return Tt.find(this,e)}static is(e,t){return Tt.winnow(e,t,"is",!1).length>0}is(e){return Tt.is(this,e)}static has(e,t){const r="string"==typeof t?[...document.querySelectorAll(t)]:Tt._preElems(t,"has");return Tt._preElems(e,"has").filter(e=>r.some(t=>e&&e.contains(t)))}has(e){return Tt.has(this,e)}static closest(e,t,r){const i=[];for(const n of Tt._preElems(e,"closest")){let e=n;for(;e&&e!==r;){if(1===e.nodeType&&("string"==typeof t?e.matches(t):e===t)){i.push(e);break}e=e.parentElement}}return[...new Set(i)]}closest(e,t){return Tt.closest(this,e,t)}static isSameDom(e,t){return Tt._preNodeElem(e,"isSameDom")===Tt._preNodeElem(t,"isSameDom")}isSameDom(e){return Tt.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=Tt._preElem(t,e);let i=wt.get(r);return i||(i={},wt.set(r,i)),i},private:(e,t)=>{if(!(t instanceof Tt))throw new Error(`Element must be a TinyHtml instance to execute ${e}().`);return t.#ie}};static data(e,t,r=!1){const i=Tt._dataSelector[r?"private":"public"]("data",e);if(null==t)return{...i};if("string"!=typeof t)throw new TypeError("The key must be a string.");return i.hasOwnProperty(t)?i[t]:void 0}data(e,t){return Tt.data(this,e,t)}static setData(e,t,r,i=!1){const n=Tt._dataSelector[i?"private":"public"]("setData",e);if("string"!=typeof t)throw new TypeError("The key must be a string.");return void 0!==r?n[t]=r:Tt.removeData(e,t),e}setData(e,t,r=!1){return Tt.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 i=Tt._dataSelector[r?"private":"public"]("hasData",e);return Object.prototype.hasOwnProperty.call(i,t)}hasData(e,t=!1){return Tt.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 Tt._dataSelector[r?"private":"public"]("removeData",e)[t]}removeData(e,t=!1){return Tt.removeData(this,e,t)}static _getSibling(e,t,r){let i=Tt._preNodeElemWithNull(e,r);for(;i&&(i=i[t])&&1!==i.nodeType;);return i instanceof Node?i:null}static _getSiblings(e,t){let r=e;const i=[];for(;r;r=r.nextSibling)1===r.nodeType&&r!==t&&i.push(r);return i}static domDir(e,t,r,i="domDir"){if("string"!=typeof t)throw new TypeError('The "direction" must be a string.');let n=Tt._preNodeElemWithNull(e,i);const s=[];for(;n&&(n=n[t]);)if(1===n.nodeType){if(r&&("string"==typeof r?n.matches(r):n===r))break;s.push(n)}return s}static parent(e){let t=Tt._preNodeElemWithNull(e,"parent");const r=t?t.parentNode:null;return r&&11!==r.nodeType?r:null}parent(){return Tt.parent(this)}static parents(e,t){return Tt.domDir(e,"parentNode",t,"parents")}parents(e){return Tt.parents(this,e)}static next(e){return Tt._getSibling(e,"nextSibling","next")}next(){return Tt.next(this)}static prev(e){return Tt._getSibling(e,"previousSibling","prev")}prev(){return Tt.prev(this)}static nextAll(e){return Tt.domDir(e,"nextSibling",void 0,"nextAll")}nextAll(){return Tt.nextAll(this)}static prevAll(e){return Tt.domDir(e,"previousSibling",void 0,"prevAll")}prevAll(){return Tt.prevAll(this)}static nextUntil(e,t){return Tt.domDir(e,"nextSibling",t,"nextUtil")}nextUntil(e){return Tt.nextUntil(this,e)}static prevUntil(e,t){return Tt.domDir(e,"previousSibling",t,"prevUtil")}prevUntil(e){return Tt.prevUntil(this,e)}static siblings(e){const t=Tt._preNodeElemWithNull(e,"siblings");return Tt._getSiblings(t&&t.parentNode?t.parentNode.firstChild:null,t)}siblings(){return Tt.siblings(this)}static children(e){const t=Tt._preNodeElemWithNull(e,"children");return Tt._getSiblings(t?t.firstChild:null)}children(){return Tt.children(this)}static contents(e){const t=Tt._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 Tt.contents(this)}static clone(e,t=!0){if("boolean"!=typeof t)throw new TypeError('The "deep" must be a boolean.');return Tt._preNodeElems(e,"clone").map(e=>e.cloneNode(t))}clone(e){return Tt.clone(this,e)[0]}static _appendChecker(e,...t){const r=[];for(const i of t)if(null!=i&&!1!==i)if("string"!=typeof i&&"number"!=typeof i)if(i instanceof Node||i instanceof Tt)r.push(...Tt._preNodeElems(i,e));else if(Array.isArray(i))r.push(...Tt._appendChecker(e,...i));else for(const t in i){const n=i[t];r.push(...Tt._appendChecker(e,n))}else r.push(i);return r}static append(e,...t){return Tt._preElem(e,"append").append(...Tt._appendChecker("append",...t)),e}append(...e){return Tt.append(this,...e)}static prepend(e,...t){return Tt._preElem(e,"prepend").prepend(...Tt._appendChecker("prepend",...t)),e}prepend(...e){return Tt.prepend(this,...e)}static before(e,...t){return Tt._preElem(e,"before").before(...Tt._appendChecker("before",...t)),e}before(...e){return Tt.before(this,...e)}static after(e,...t){return Tt._preElem(e,"after").after(...Tt._appendChecker("after",...t)),e}after(...e){return Tt.after(this,...e)}static replaceWith(e,...t){return Tt._preElem(e,"replaceWith").replaceWith(...Tt._appendChecker("replaceWith",...t)),e}replaceWith(...e){return Tt.replaceWith(this,...e)}static appendTo(e,t){const r=Tt._preNodeElems(e,"appendTo"),i=Tt._preNodeElems(t,"appendTo");return i.forEach((e,t)=>{r.forEach(r=>e.appendChild(t===i.length-1?r:r.cloneNode(!0)))}),e}appendTo(e){return Tt.appendTo(this,e)}static prependTo(e,t){const r=Tt._preElems(e,"prependTo"),i=Tt._preElems(t,"prependTo");return i.forEach((e,t)=>{r.slice().reverse().forEach(r=>e.prepend(t===i.length-1?r:r.cloneNode(!0)))}),e}prependTo(e){return Tt.prependTo(this,e)}static insertBefore(e,t,r=null){const i=Tt._preNodeElem(e,"insertBefore"),n=Tt._preNodeElem(t,"insertBefore"),s=Tt._preNodeElemWithNull(r,"insertBefore");if(!n.parentNode)throw new Error("The target element has no parent node to insert before.");return n.parentNode.insertBefore(i,s||n),e}insertBefore(e,t){return Tt.insertBefore(this,e,t)}static insertAfter(e,t,r=null){const i=Tt._preNodeElem(e,"insertAfter"),n=Tt._preNodeElem(t,"insertBefore"),s=Tt._preNodeElemWithNull(r,"insertBefore");if(!n.parentNode)throw new Error("The target element has no parent node to insert after.");return n.parentNode.insertBefore(i,s||n.nextSibling),e}insertAfter(e,t){return Tt.insertAfter(this,e,t)}static replaceAll(e,t){const r=Tt._preNodeElems(e,"replaceAll"),i=Tt._preNodeElems(t,"replaceAll");return i.forEach((e,t)=>{const n=e.parentNode;r.forEach(r=>{n&&n.replaceChild(t===i.length-1?r:r.cloneNode(!0),e)})}),e}replaceAll(e){return Tt.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 Tt([...this.#G,...Tt._selector(e)])}static _selector(e){if(e instanceof Tt)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 Tt._elCheck(r),t(r);if(r instanceof NodeList||r instanceof HTMLCollection){const e=[...r];return Tt._elCheck(e),t(e)}{const e=[r];return Tt._elCheck(e),t(e)}}constructor(e){this.#G=Tt._selector(e),this.#ne=Tt.#se}static isWindow(e){return null!=e&&e===e.window}static css(e){const t=Tt._preElem(e,"css");return window.getComputedStyle(t)}css(){return Tt.css(this)}static cssString(e,t){const r=Tt._preElem(e,"cssString");if("string"!=typeof t)throw new TypeError("The prop must be a string.");const i=window.getComputedStyle(r)[t];return"string"==typeof i?i:"number"==typeof i?i.toString():null}cssString(e){return Tt.cssString(this,e)}static cssList(e,t){const r=Tt._preElem(e,"cssList");if(!Array.isArray(t))throw new TypeError("The prop must be an array of strings.");const i=window.getComputedStyle(r),n={};for(const e of t)void 0!==e&&(n[e]=i.getPropertyValue(e));return n}cssList(e){return Tt.cssList(this,e)}static cssFloat(e,t){const r=Tt._preElem(e,"cssFloat");if("string"!=typeof t)throw new TypeError("The prop must be a string.");const i=window.getComputedStyle(r)[t];return parseFloat(i)||0}cssFloat(e){return Tt.cssFloat(this,e)}static cssFloats(e,t){const r=Tt._preElem(e,"cssFloats");if(!Array.isArray(t))throw new TypeError("The prop must be an array of strings.");const i=window.getComputedStyle(r),n={};for(const e of t)n[e]=parseFloat(i[e])||0;return n}cssFloats(e){return Tt.cssFloats(this,e)}static#oe={alignContent:"align-content",alignItems:"align-items",alignSelf:"align-self",animationDelay:"animation-delay",animationDirection:"animation-direction",animationDuration:"animation-duration",animationFillMode:"animation-fill-mode",animationIterationCount:"animation-iteration-count",animationName:"animation-name",animationPlayState:"animation-play-state",animationTimingFunction:"animation-timing-function",backfaceVisibility:"backface-visibility",backgroundAttachment:"background-attachment",backgroundBlendMode:"background-blend-mode",backgroundClip:"background-clip",backgroundColor:"background-color",backgroundImage:"background-image",backgroundOrigin:"background-origin",backgroundPosition:"background-position",backgroundRepeat:"background-repeat",backgroundSize:"background-size",borderBottom:"border-bottom",borderBottomColor:"border-bottom-color",borderBottomLeftRadius:"border-bottom-left-radius",borderBottomRightRadius:"border-bottom-right-radius",borderBottomStyle:"border-bottom-style",borderBottomWidth:"border-bottom-width",borderCollapse:"border-collapse",borderColor:"border-color",borderImage:"border-image",borderImageOutset:"border-image-outset",borderImageRepeat:"border-image-repeat",borderImageSlice:"border-image-slice",borderImageSource:"border-image-source",borderImageWidth:"border-image-width",borderLeft:"border-left",borderLeftColor:"border-left-color",borderLeftStyle:"border-left-style",borderLeftWidth:"border-left-width",borderRadius:"border-radius",borderRight:"border-right",borderRightColor:"border-right-color",borderRightStyle:"border-right-style",borderRightWidth:"border-right-width",borderSpacing:"border-spacing",borderStyle:"border-style",borderTop:"border-top",borderTopColor:"border-top-color",borderTopLeftRadius:"border-top-left-radius",borderTopRightRadius:"border-top-right-radius",borderTopStyle:"border-top-style",borderTopWidth:"border-top-width",borderWidth:"border-width",boxDecorationBreak:"box-decoration-break",boxShadow:"box-shadow",boxSizing:"box-sizing",breakAfter:"break-after",breakBefore:"break-before",breakInside:"break-inside",captionSide:"caption-side",caretColor:"caret-color",clipPath:"clip-path",columnCount:"column-count",columnFill:"column-fill",columnGap:"column-gap",columnRule:"column-rule",columnRuleColor:"column-rule-color",columnRuleStyle:"column-rule-style",columnRuleWidth:"column-rule-width",columnSpan:"column-span",columnWidth:"column-width",counterIncrement:"counter-increment",counterReset:"counter-reset",emptyCells:"empty-cells",flexBasis:"flex-basis",flexDirection:"flex-direction",flexFlow:"flex-flow",flexGrow:"flex-grow",flexShrink:"flex-shrink",flexWrap:"flex-wrap",fontFamily:"font-family",fontFeatureSettings:"font-feature-settings",fontKerning:"font-kerning",fontLanguageOverride:"font-language-override",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontSynthesis:"font-synthesis",fontVariant:"font-variant",fontVariantAlternates:"font-variant-alternates",fontVariantCaps:"font-variant-caps",fontVariantEastAsian:"font-variant-east-asian",fontVariantLigatures:"font-variant-ligatures",fontVariantNumeric:"font-variant-numeric",fontVariantPosition:"font-variant-position",fontWeight:"font-weight",gridArea:"grid-area",gridAutoColumns:"grid-auto-columns",gridAutoFlow:"grid-auto-flow",gridAutoRows:"grid-auto-rows",gridColumn:"grid-column",gridColumnEnd:"grid-column-end",gridColumnGap:"grid-column-gap",gridColumnStart:"grid-column-start",gridGap:"grid-gap",gridRow:"grid-row",gridRowEnd:"grid-row-end",gridRowGap:"grid-row-gap",gridRowStart:"grid-row-start",gridTemplate:"grid-template",gridTemplateAreas:"grid-template-areas",gridTemplateColumns:"grid-template-columns",gridTemplateRows:"grid-template-rows",imageRendering:"image-rendering",justifyContent:"justify-content",letterSpacing:"letter-spacing",lineBreak:"line-break",lineHeight:"line-height",listStyle:"list-style",listStyleImage:"list-style-image",listStylePosition:"list-style-position",listStyleType:"list-style-type",marginBottom:"margin-bottom",marginLeft:"margin-left",marginRight:"margin-right",marginTop:"margin-top",maskClip:"mask-clip",maskComposite:"mask-composite",maskImage:"mask-image",maskMode:"mask-mode",maskOrigin:"mask-origin",maskPosition:"mask-position",maskRepeat:"mask-repeat",maskSize:"mask-size",maskType:"mask-type",maxHeight:"max-height",maxWidth:"max-width",minHeight:"min-height",minWidth:"min-width",mixBlendMode:"mix-blend-mode",objectFit:"object-fit",objectPosition:"object-position",offsetAnchor:"offset-anchor",offsetDistance:"offset-distance",offsetPath:"offset-path",offsetRotate:"offset-rotate",outlineColor:"outline-color",outlineOffset:"outline-offset",outlineStyle:"outline-style",outlineWidth:"outline-width",overflowAnchor:"overflow-anchor",overflowWrap:"overflow-wrap",overflowX:"overflow-x",overflowY:"overflow-y",paddingBottom:"padding-bottom",paddingLeft:"padding-left",paddingRight:"padding-right",paddingTop:"padding-top",pageBreakAfter:"page-break-after",pageBreakBefore:"page-break-before",pageBreakInside:"page-break-inside",perspectiveOrigin:"perspective-origin",placeContent:"place-content",placeItems:"place-items",placeSelf:"place-self",pointerEvents:"pointer-events",rowGap:"row-gap",scrollBehavior:"scroll-behavior",scrollMargin:"scroll-margin",scrollMarginBlock:"scroll-margin-block",scrollMarginBlockEnd:"scroll-margin-block-end",scrollMarginBlockStart:"scroll-margin-block-start",scrollMarginBottom:"scroll-margin-bottom",scrollMarginInline:"scroll-margin-inline",scrollMarginInlineEnd:"scroll-margin-inline-end",scrollMarginInlineStart:"scroll-margin-inline-start",scrollMarginLeft:"scroll-margin-left",scrollMarginRight:"scroll-margin-right",scrollMarginTop:"scroll-margin-top",scrollPadding:"scroll-padding",scrollPaddingBlock:"scroll-padding-block",scrollPaddingBlockEnd:"scroll-padding-block-end",scrollPaddingBlockStart:"scroll-padding-block-start",scrollPaddingBottom:"scroll-padding-bottom",scrollPaddingInline:"scroll-padding-inline",scrollPaddingInlineEnd:"scroll-padding-inline-end",scrollPaddingInlineStart:"scroll-padding-inline-start",scrollPaddingLeft:"scroll-padding-left",scrollPaddingRight:"scroll-padding-right",scrollPaddingTop:"scroll-padding-top",scrollSnapAlign:"scroll-snap-align",scrollSnapStop:"scroll-snap-stop",scrollSnapType:"scroll-snap-type",shapeImageThreshold:"shape-image-threshold",shapeMargin:"shape-margin",shapeOutside:"shape-outside",tabSize:"tab-size",tableLayout:"table-layout",textAlign:"text-align",textAlignLast:"text-align-last",textCombineUpright:"text-combine-upright",textDecoration:"text-decoration",textDecorationColor:"text-decoration-color",textDecorationLine:"text-decoration-line",textDecorationStyle:"text-decoration-style",textIndent:"text-indent",textJustify:"text-justify",textOrientation:"text-orientation",textOverflow:"text-overflow",textShadow:"text-shadow",textTransform:"text-transform",transformBox:"transform-box",transformOrigin:"transform-origin",transformStyle:"transform-style",transitionDelay:"transition-delay",transitionDuration:"transition-duration",transitionProperty:"transition-property",transitionTimingFunction:"transition-timing-function",unicodeBidi:"unicode-bidi",userSelect:"user-select",verticalAlign:"vertical-align",whiteSpace:"white-space",willChange:"will-change",wordBreak:"word-break",wordSpacing:"word-spacing",wordWrap:"word-wrap",writingMode:"writing-mode",zIndex:"z-index",WebkitTransform:"-webkit-transform",WebkitTransition:"-webkit-transition",WebkitBoxShadow:"-webkit-box-shadow",MozBoxShadow:"-moz-box-shadow",MozTransform:"-moz-transform",MozTransition:"-moz-transition",msTransform:"-ms-transform",msTransition:"-ms-transition"};static cssPropAliases=new Proxy(Tt.#oe,{set:(e,t,r)=>(e[t]=r,Tt.cssPropRevAliases[r]=t,!0)});static cssPropRevAliases=Object.fromEntries(Object.entries(Tt.#oe).map(([e,t])=>[t,e]));static toStyleKc(e){return"string"==typeof Tt.cssPropAliases[e]?Tt.cssPropAliases[e]:e}static toStyleCc(e){return"string"==typeof Tt.cssPropRevAliases[e]?Tt.cssPropRevAliases[e]:e}static setStyle(e,t,r=null){return Tt._preHtmlElems(e,"setStyle").forEach(e=>{if("object"==typeof t)for(const[r,i]of Object.entries(t))e.style.setProperty(Tt.toStyleKc(r),"string"==typeof i?i:"number"==typeof i?`${i}px`:String(i));else e.style.setProperty(Tt.toStyleKc(t),r)}),e}setStyle(e,t){return Tt.setStyle(this,e,t)}static getStyle(e,t){return Tt._preHtmlElem(e,"getStyle").style.getPropertyValue(Tt.toStyleKc(t))}getStyle(e){return Tt.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 i=Tt._preHtmlElem(e,"style"),n={};if(r){const e=(i.getAttribute("style")||"").split(";");for(const r of e){const[e,i]=r.split(":");if(!e||!i)continue;const s=e.trim(),o=i.trim();n[t?Tt.toStyleCc(s):s]=o}}else{const e=i.style;for(let r=0;r<e.length;r++){const i=e[r],s=e.getPropertyValue(i);n[t?Tt.toStyleCc(i):i]=s}}return n}style(e){return Tt.style(this,e)}static removeStyle(e,t){return Tt._preHtmlElems(e,"removeStyle").forEach(e=>{if(Array.isArray(t))for(const r of t)e.style.removeProperty(Tt.toStyleKc(r));else e.style.removeProperty(Tt.toStyleKc(t))}),e}removeStyle(e){return Tt.removeStyle(this,e)}static toggleStyle(e,t,r,i){return Tt._preHtmlElems(e,"toggleStyle").forEach(e=>{const n=Tt.getStyle(e,t).trim()===Tt.toStyleKc(r)?i:r;Tt.setStyle(e,t,n)}),e}toggleStyle(e,t,r){return Tt.toggleStyle(this,e,t,r)}static clearStyle(e){return Tt._preElems(e,"clearStyle").forEach(e=>e.removeAttribute("style")),e}clearStyle(){return Tt.clearStyle(this)}static focus(e){return Tt._preHtmlElem(e,"focus").focus(),e}focus(){return Tt.focus(this)}static blur(e){return Tt._preHtmlElem(e,"blur").blur(),e}blur(){return Tt.blur(this)}static select(e){const t=Tt._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 Tt.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.");Tt.setScrollTop(window,e)}static setWinScrollLeft(e){if("number"!=typeof e)throw new TypeError("The value must be a number.");Tt.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 i=Tt._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 n="width"===t?"Width":"Height";if(Tt.isWindow(i))return"margin"===r?i["inner"+n]:i.document.documentElement["client"+n];const s=i;if(9===s.nodeType){const e=s.documentElement;return Math.max(s.body["scroll"+n],e["scroll"+n],s.body["offset"+n],e["offset"+n],e["client"+n])}let o=s.getBoundingClientRect()[t];function a(e){return"width"===t?Tt.cssFloat(s,e+"Left")+Tt.cssFloat(s,e+"Right"):Tt.cssFloat(s,e+"Top")+Tt.cssFloat(s,e+"Bottom")}switch(r){case"content":o-=a("padding"),o-=a("border");break;case"padding":o-=a("border");break;case"border":break;case"margin":o+=a("margin")}return o}getDimension(e,t){return Tt.getDimension(this,e,t)}static setHeight(e,t){const r=Tt._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 Tt.setHeight(this,e)}set height(e){Tt.setHeight(this,e)}static setWidth(e,t){const r=Tt._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 Tt.setWidth(this,e)}set width(e){Tt.setWidth(this,e)}static height(e){const t=Tt._preElemAndWinAndDoc(e,"height");return Tt.getDimension(t,"height","content")}get height(){return Tt.height(this)}static width(e){const t=Tt._preElemAndWinAndDoc(e,"width");return Tt.getDimension(t,"width","content")}get width(){return Tt.width(this)}static innerHeight(e){const t=Tt._preElemAndWinAndDoc(e,"innerHeight");return Tt.getDimension(t,"height","padding")}innerHeight(){return Tt.innerHeight(this)}static innerWidth(e){const t=Tt._preElemAndWinAndDoc(e,"innerWidth");return Tt.getDimension(t,"width","padding")}innerWidth(){return Tt.innerWidth(this)}static outerHeight(e,t=!1){if("boolean"!=typeof t)throw new TypeError('The "includeMargin" must be a boolean.');const r=Tt._preElemAndWinAndDoc(e,"outerHeight");return Tt.getDimension(r,"height",t?"margin":"border")}outerHeight(e){return Tt.outerHeight(this,e)}static outerWidth(e,t=!1){if("boolean"!=typeof t)throw new TypeError('The "includeMargin" must be a boolean.');const r=Tt._preElemAndWinAndDoc(e,"outerWidth");return Tt.getDimension(r,"width",t?"margin":"border")}outerWidth(e){return Tt.outerWidth(this,e)}#ne="";get mainDisplay(){return this.#ne}set mainDisplay(e){if("string"!=typeof e)throw new TypeError("mainDisplay must be a string.");this.#ne=e}static#se="block";static get defaultDisplay(){return Tt.#se}static set defaultDisplay(e){if("string"!=typeof e)throw new TypeError("defaultDisplay must be a string.");Tt.#se=e}static getAnimateData(e,t){let r=bt.get(e);return r||(r={},bt.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 i=bt.get(e);i||(i={},bt.set(e,i)),i[t]=r}static#ae=!0;static get cancelOldStyleFx(){return Tt.#ae}static set cancelOldStyleFx(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean value.");Tt.#ae=e}static#le={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 Tt.#le){const r=Tt.#le[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.`);Tt.#le={};for(const[t,r]of Object.entries(e))Tt.setStyleFxSpeed(t,r)}static getStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');const t=Tt.#le[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");Tt.#le[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 Tt.#le[e]}static hasStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(Tt.#le,e)}static#ue=["Top","Right","Bottom","Left"];static#he={slideDown:Tt.genStyleFx("show"),slideUp:Tt.genStyleFx("hide"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}};static get styleEffects(){return JSON.parse(JSON.stringify(Tt.#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,i]of Object.entries(e[t]))if(!("string"==typeof i||Array.isArray(i)&&i.every(e=>"string"==typeof e||"number"==typeof e)))throw new TypeError(`Invalid styleEffect["${r}"]`);Tt.#he={};for(const t in e)Tt.setStyleEffect(t,e[t])}static getStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');const t=Tt.#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,i]of Object.entries(t))if("string"==typeof i)r[e]=i;else{if(!Array.isArray(i)||!i.every(e=>"string"==typeof e||"number"==typeof e))throw new TypeError(`Invalid styleEffect["${e}"]`);r[e]=[...i]}Tt.#he[e]=r}static deleteStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete Tt.#he[e]}static hasStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(Tt.#he,e)}static#ce={slideDown:"slideUp",slideUp:"slideDown",fadeIn:"fadeOut",fadeOut:"fadeIn",fadeTo:"fadeIn"};static get styleEffectInverse(){return{...Tt.#ce}}static set styleEffectInverse(e){if("object"!=typeof e||null===e)throw new TypeError("styleEffectInverse must be an object.");for(const[t,r]of Object.entries(e))if("string"!=typeof r)throw new TypeError(`styleEffectInverse["${t}"] must be a string.`);Tt.#ce={};for(const[t,r]of Object.entries(e))Tt.setStyleEffectInverse(t,r)}static getStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Tt.#ce[e]||null}static setStyleEffectInverse(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("string"!=typeof t)throw new TypeError(`styleEffectInverse["${e}"] must be a string.`);Tt.#ce[e]=t}static deleteStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete Tt.#ce[e]}static hasStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(Tt.#ce,e)}static#de={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{...Tt.#de}}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.`);Tt.#de={};for(const[t,r]of Object.entries(e))Tt.setStyleEffectRd(t,r)}static getStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Tt.#de[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.`);Tt.#de[e]=t}static deleteStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete Tt.#de[e]}static hasStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(Tt.#de,e)}static#me={show:(e,t,r,i)=>{if("height"===r||"width"===r){const n=Tt.getAnimateData(e,`orig${r}`)||e.scrollHeight+"px";Tt.setAnimateData(e,`orig${r}`,n);const s=i[r];t[r]=[s,n]}else if(r.startsWith("margin")||r.startsWith("padding")){const n=Tt.getAnimateData(e,r)||i[r];Tt.setAnimateData(e,r,n),t[r]=["0px",n]}else if("opacity"===r){const e=i.opacity;t[r]=[e,1]}else{const n=Tt.getAnimateData(e,r)||i[r];Tt.setAnimateData(e,r,n),t[r]=[n,i[r]||1]}},hide:(e,t,r,i)=>{if("height"===r||"width"===r){const n=Tt.getAnimateData(e,`orig${r}`)||i[r];Tt.setAnimateData(e,`orig${r}`,n);const s=i[r];t[r]=[s,0]}else if(r.startsWith("margin")||r.startsWith("padding")){const n=Tt.getAnimateData(e,r)||i[r];Tt.setAnimateData(e,r,n),t[r]=[i[r],"0px"]}else if("opacity"===r){const e=i.opacity;t[r]=[e,0]}else{const n=Tt.getAnimateData(e,r)||i[r];Tt.setAnimateData(e,r,n),t[r]=[n,0]}}};static get styleEffectsProps(){return{...Tt.#me}}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`);Tt.#me={};for(const[t,r]of Object.entries(e))Tt.setStyleEffectProp(t,r)}static getStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Tt.#me[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`);Tt.#me[e]=t}static deleteStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete Tt.#me[e]}static hasStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(Tt.#me,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,i=0;const n={height:e},s=t?1:0;for(;i<4;i+=2-s)r=Tt.#ue[i],n["margin"+r]=e,n["padding"+r]=e;return t&&(n.opacity=e,n.width=e),n}static applyStyleFx(e,t,r,i){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!==i&&"number"!=typeof i&&"string"!=typeof i&&("object"!=typeof i||null===i))throw new TypeError("applyStyleFx: ops must be a number, string, KeyframeAnimationOptions, or undefined.");const n=new Map;return Tt._preHtmlElems(e,"applyStyleFx").forEach(s=>{const o={};for(const[e,t]of Object.entries(r))if("string"==typeof t&&this.#me[t]){const r=getComputedStyle(s);this.#me[t](s,o,e,r)}else{if("object"!=typeof t)throw new TypeError(`applyStyleFx: invalid action for prop "${e}". Must be string or array.`);o[e]=t}if("function"==typeof Tt.#de[t]&&Tt.#de[t](o))return void n.set(s,null);const a=[],l=o[Object.keys(o)[0]].length;for(let e=0;e<l;e++){const t={};for(const r in o)t[r]=o[r][e];a.push(t)}n.set(s,Tt.animate(e,a,i,t)[0])}),n}applyStyleFx(e,t,r){return Tt.applyStyleFx(this,e,t,r)}static getCurrentAnimationId(e){if(!(e instanceof HTMLElement))throw new TypeError("Expected an HTMLElement.");return vt.get(e)?.id??void 0}static animate(e,t,r=Tt.#le._default,i=null,n=Tt.#ae){const s="string"==typeof r?Tt.#le[r]??void 0:"number"!=typeof r?{...r}:r;"object"==typeof s&&void 0===s.fill&&(s.fill="forwards");const o=[];return Tt._preHtmlElems(e,"animate").forEach(e=>{if(n){const t=vt.get(e);t&&t.animation.cancel()}const r=e.animate(t,s);o.push(r),vt.set(e,{animation:r,id:i??""}),r.addEventListener("finish",()=>{vt.get(e)?.animation===r&&vt.delete(e)})}),o}animate(e,t,r,i){return Tt.animate(this,e,t,r,i)}static stop(e){const t=[];return Tt._preHtmlElems(e,"stop").forEach(e=>{const r=vt.get(e);r?(r.animation.cancel(),vt.delete(e),t.push(!0)):t.push(!1)}),t}stop(){return Tt.stop(this)}static slideDown(e,t){return Tt.applyStyleFx(e,"slideDown",this.#he.slideDown,t??{duration:500,easing:"ease-out"})}slideDown(e){return Tt.slideDown(this,e)}static slideUp(e,t){return Tt.applyStyleFx(e,"slideUp",this.#he.slideUp,t??{duration:500,easing:"ease-out"})}slideUp(e){return Tt.slideUp(this,e)}static slideToggle(e,t){const r=Tt._preHtmlElem(e,"slideToggle"),i=getComputedStyle(r),n=Tt.getCurrentAnimationId(r),s="none"===i.display||0===r.offsetHeight;return("string"==typeof n?"slideUp"===n:s)?Tt.slideDown(e,t):Tt.slideUp(e,t)}slideToggle(e){return Tt.slideToggle(this,e)}static fadeIn(e,t){return Tt.applyStyleFx(e,"fadeIn",this.#he.fadeIn,t)}fadeIn(e){return Tt.fadeIn(this,e)}static fadeOut(e,t){return Tt.applyStyleFx(e,"fadeOut",this.#he.fadeOut,t)}fadeOut(e){return Tt.fadeOut(this,e)}static fadeToggle(e,t){const r=Tt._preHtmlElem(e,"fadeToggle"),i=getComputedStyle(r),n=Tt.getCurrentAnimationId(r),s="0"===i.opacity||null===r.offsetParent;return("string"==typeof n?"fadeOut"===n:s)?Tt.fadeIn(e,t):Tt.fadeOut(e,t)}fadeToggle(e){return Tt.fadeToggle(this,e)}static fadeTo(e,t,r,i=Tt.#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 n=new Map;return Tt._preHtmlElems(e,"fadeTo").forEach(s=>{const o=getComputedStyle(s);if(!(e instanceof Element&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length))){const e=Tt.getAnimateData(s,"origdisplay");s.style.display="string"==typeof e?e:i}const a=[o.opacity,t].map(e=>({opacity:e}));n.set(s,Tt.animate(s,a,r,"fadeTo")[0])}),n}fadeTo(e,t,r=this.#ne){return Tt.fadeTo(this,e,t,r)}static offset(e){const t=Tt._preElem(e,"offset").getBoundingClientRect(),r=window.scrollY||document.documentElement.scrollTop,i=window.scrollX||document.documentElement.scrollLeft;return{top:t.top+r,left:t.left+i}}offset(){return Tt.offset(this)}static position(e){const t=Tt._preHtmlElem(e,"position");let r,i,n={top:0,left:0};if("fixed"===window.getComputedStyle(t).position)i=t.getBoundingClientRect();else{i=Tt.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}=Tt.cssFloats(r,["borderTopWidth","borderLeftWidth"]);n=Tt.offset(r),n.top+=e,n.left+=t}}return{top:i.top-n.top-Tt.cssFloat(t,"marginTop"),left:i.left-n.left-Tt.cssFloat(t,"marginLeft")}}position(){return Tt.position(this)}static offsetParent(e){let t=Tt._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 Tt.offsetParent(this)}static scrollTop(e){const t=Tt._preElemAndWindow(e,"scrollTop");return Tt.isWindow(t)?t.pageYOffset:9===t.nodeType?t.defaultView.pageYOffset:t.scrollTop}scrollTop(){return Tt.scrollTop(this)}static scrollLeft(e){const t=Tt._preElemAndWindow(e,"scrollLeft");return Tt.isWindow(t)?t.pageXOffset:9===t.nodeType?t.defaultView.pageXOffset:t.scrollLeft}scrollLeft(){return Tt.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:i,easing:n,onAnimation:s}={}){if(void 0!==t&&"number"!=typeof t)throw new TypeError("`targetX` must be a number if provided.");if(void 0!==r&&"number"!=typeof r)throw new TypeError("`targetY` must be a number if provided.");if(void 0!==i&&"number"!=typeof i)throw new TypeError("`duration` must be a number if provided.");if(void 0!==n&&"string"!=typeof n)throw new TypeError("`easing` must be a string if provided.");if(void 0!==n&&"function"!=typeof Tt.easings[n])throw new TypeError(`Unknown easing function: "${n}".`);if(void 0!==s&&"function"!=typeof s)throw new TypeError("`onAnimation` must be a function if provided.");const o=(e,t,r,i)=>{if(e instanceof Window)window.scrollTo(t,r);else if(9===e.nodeType)e.defaultView.scrollTo(t,r);else{const i=e instanceof Window?window.scrollX:e.scrollLeft,n=e instanceof Window?window.scrollY:e.scrollTop;i!==t&&(e.scrollLeft=t),n!==r&&(e.scrollTop=r)}"function"==typeof s&&s({x:t,y:r,isComplete:i>=1,time:i})};return Tt._preElemsAndWindow(e,"scrollToXY").forEach(e=>{const s=e instanceof Window?window.scrollX:e.scrollLeft,a=e instanceof Window?window.scrollY:e.scrollTop,l=t??s,u=r??a,h=l-s,c=u-a,d="string"==typeof n&&Tt.easings[n]||null;if("number"!=typeof i||"function"!=typeof d)return o(e,l,u,1);const m=performance.now(),p=i??0;requestAnimationFrame(function t(r){if("function"!=typeof d)return;const i=Math.min(1,(r-m)/p),n=d(i);o(e,s+h*n,a+c*n,i),i<1&&requestAnimationFrame(t)})}),e}scrollToXY({targetX:e,targetY:t,duration:r,easing:i,onAnimation:n}={}){return Tt.scrollToXY(this,{targetX:e,targetY:t,duration:r,easing:i,onAnimation:n})}static setScrollTop(e,t){if("number"!=typeof t)throw new TypeError("ScrollTop value must be a number.");return Tt.scrollToXY(e,{targetY:t})}setScrollTop(e){return Tt.setScrollTop(this,e)}static setScrollLeft(e,t){if("number"!=typeof t)throw new TypeError("ScrollLeft value must be a number.");return Tt.scrollToXY(e,{targetX:t})}setScrollLeft(e){return Tt.setScrollLeft(this,e)}static borderWidth(e){const t=Tt._preElem(e,"borderWidth"),{borderLeftWidth:r,borderRightWidth:i,borderTopWidth:n,borderBottomWidth:s}=Tt.cssFloats(t,["borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"]);return{x:r+i,y:n+s,left:r,right:i,top:n,bottom:s}}borderWidth(){return Tt.borderWidth(this)}static border(e){const t=Tt._preElem(e,"border"),{borderLeft:r,borderRight:i,borderTop:n,borderBottom:s}=Tt.cssFloats(t,["borderLeft","borderRight","borderTop","borderBottom"]);return{x:r+i,y:n+s,left:r,right:i,top:n,bottom:s}}border(){return Tt.border(this)}static margin(e){const t=Tt._preElem(e,"margin"),{marginLeft:r,marginRight:i,marginTop:n,marginBottom:s}=Tt.cssFloats(t,["marginLeft","marginRight","marginTop","marginBottom"]);return{x:r+i,y:n+s,left:r,right:i,top:n,bottom:s}}margin(){return Tt.margin(this)}static padding(e){const t=Tt._preElem(e,"padding"),{paddingLeft:r,paddingRight:i,paddingTop:n,paddingBottom:s}=Tt.cssFloats(t,["paddingLeft","paddingRight","paddingTop","paddingBottom"]);return{x:r+i,y:n+s,left:r,right:i,top:n,bottom:s}}padding(){return Tt.padding(this)}static#pe=!1;static get classCanWhitespace(){return this.#pe}static set classCanWhitespace(e){if("boolean"!=typeof e)throw new TypeError("classCanWhitespace must be a boolean");this.#pe=e}static addClass(e,...t){const r=[];for(const e of t)if(Tt.#pe){const t=e.split(" ");for(const e of t)r.push(e)}else r.push(e);return Tt._preElems(e,"addClass").forEach(e=>e.classList.add(...r)),e}addClass(...e){return Tt.addClass(this,...e)}static removeClass(e,...t){const r=[];for(const e of t)if(Tt.#pe){const t=e.split(" ");for(const e of t)r.push(e)}else r.push(e);return Tt._preElems(e,"removeClass").forEach(e=>e.classList.remove(...r)),e}removeClass(...e){return Tt.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 i=[];return Tt._preElems(e,"replaceClass").forEach(e=>i.push(e.classList.replace(t,r))),i}replaceClass(e,t){return Tt.replaceClass(this,e,t)[0]}static classItem(e,t){const r=Tt._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 Tt.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 i=[];return Tt._preElems(e,"toggleClass").forEach(e=>i.push(e.classList.toggle(t,r))),i}toggleClass(e,t){return Tt.toggleClass(this,e,t)[0]}static hasClass(e,t){const r=Tt._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 Tt.hasClass(this,e)}static classLength(e){return Tt._preElem(e,"classLength").classList.length}classLength(){return Tt.classLength(this)}static classList(e){return Tt._preElem(e,"classList").classList.values().toArray()}classList(){return Tt.classList(this)}static tagName(e){return Tt._preElem(e,"tagName").tagName}tagName(){return Tt.tagName(this)}static id(e){return Tt._preElem(e,"id").id}get id(){return Tt.id(this)}set id(e){Tt.setAttr(this,"id",e)}static toBigInt(e){const t=Tt._preElem(e,"toBigInt"),r=t.textContent?.trim();let i=null;try{i=BigInt(r??"")}catch{i=null}return i}toBigInt(){return Tt.toBigInt(this)}static setBigInt(e,t){if("bigint"!=typeof t)throw new Error("Value is not a valid BigInt.");const r=t.toString();return Tt._preElems(e,"setBigInt").forEach(e=>e.textContent=r),e}setBigInt(e){return Tt.setBigInt(this,e)}static toDate(e){const t=Tt._preElem(e,"toDate"),r=t.textContent?.trim();if(!r)return null;const i=new Date(r);return Number.isNaN(i.getTime())?null:i}toDate(){return Tt.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 Tt._preElems(e,"setDate").forEach(e=>e.textContent=r),e}setDate(e){return Tt.setDate(this,e)}static toJson(e){const t=Tt._preElem(e,"toJson"),r=t.textContent?.trim();if(!r)return null;try{return JSON.parse(r)}catch{return null}}toJson(){return Tt.toJson(this)}static setJson(e,t,r,i){const n=JSON.stringify(t,r,i);return Tt._preElems(e,"setJson").forEach(e=>e.textContent=n),e}setJson(e,t,r){return Tt.setJson(this,e,t,r)}static toNumber(e){const t=Tt._preElem(e,"toNumber");return"string"==typeof t.textContent?parseFloat(t.textContent.trim()):null}toNumber(){return Tt.toNumber(this)}static setNumber(e,t){if("number"!=typeof t)throw new Error("Value is not a valid number.");const r=t.toString();return Tt._preElems(e,"setNumber").forEach(e=>e.textContent=r),e}setNumber(e){return Tt.setNumber(this,e)}static toBoolean(e){const t=Tt._preElem(e,"toBoolean"),r=t.textContent?.trim();return null==r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}toBoolean(){return Tt.toBoolean(this)}static setBoolean(e,t){if("boolean"!=typeof t)throw new Error("Value is not a valid boolean.");const r=t.toString();return Tt._preElems(e,"setBoolean").forEach(e=>e.textContent=r),e}setBoolean(e){return Tt.setBoolean(this,e)}static toString(e){const t=Tt._preElem(e,"toString");return"string"==typeof t.textContent?t.textContent:null}toString(){return Tt.toString(this)}static setString(e,t){if("string"!=typeof t)throw new Error("Value is not a valid string.");return Tt._preElems(e,"setString").forEach(e=>e.textContent=t),e}setString(e){return Tt.setString(this,e)}static text(e){return Tt._preElem(e,"text").textContent}text(){return Tt.text(this)}static setText(e,t){const r=null!=t?String(t):"";return Tt._preElems(e,"setText").forEach(e=>e.textContent=r),e}setText(e){return Tt.setText(this,e)}static empty(e){return Tt._preElems(e,"empty").forEach(e=>e.textContent=""),e}empty(){return Tt.empty(this)}static html(e,t){return Tt._preElem(e,"html").getHTML(t)}html(e){return Tt.html(this,e)}static setHtml(e,t){if("string"!=typeof t)throw new Error("Value is not a valid string.");return Tt._preElems(e,"setHtml").forEach(e=>e.innerHTML=t),e}setHtml(e){return Tt.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,i="select-one"===e.type,n=i?r+1:t.length,s=[];let o=r<0?n:i?r:0;for(;o<n;o++){const e=t[o],n=e.parentNode;if((e.selected||o===r)&&!e.disabled&&(!n||!n.disabled||"OPTGROUP"!==n.tagName)){const t=Tt._valHooks.option.get(e);if(i)return t;s.push(t)}}return s},set:(e,t)=>{const r=e.options,i=Array.isArray(t)?t.map(String):[String(t)];let n=!1;for(let e=0;e<r.length;e++){const t=r[e],s=Tt._valHooks.option.get(t);"string"==typeof s&&(t.selected=i.includes(s))&&(n=!0)}return n||(e.selectedIndex=-1),i}},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 Tt._preInputElems(e,"setVal").forEach(e=>{if(1!==e.nodeType)return;let r="function"==typeof t?t(e,Tt.val(e)):t;null==r?r="":"number"==typeof r?r=String(r):Array.isArray(r)&&(r=((e,t)=>{const r=[];for(let i=0;i<e.length;i++)r.push(t(e[i]));return r})(r,e=>null==e?"":String(e)));const i=Tt._valHooks[e.type]||Tt._valHooks[e.nodeName.toLowerCase()];if(!i||"function"!=typeof i.set||void 0===i.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 Tt.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 Tt._valTypes[t])throw new Error(`No handler found for type "${t}" in ${r}().`);return Tt._valTypes[t](e)}static _val(e,t,r){const i=Tt._preInputElem(e,t),n=Tt._valHooks[i.type]||Tt._valHooks[i.nodeName.toLowerCase()];if(n&&"function"==typeof n.get){const e=n.get(i,"value",r);if(void 0!==e)return"string"==typeof e?e.replace(/\r/g,""):e}return Tt._getValByType(i,r,t)}_val(e,t){return Tt._val(this,e,t)}static val(e){return Tt._val(e,"val","string")}val(){return Tt.val(this)}static valTxt(e){const t=Tt._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 Tt.valTxt(this)}static _valArr(e,t,r){const i=Tt._val(e,t,r);if(!Array.isArray(i))throw new Error(`Value expected an array but got ${typeof i}.`);return i}_valArr(e,t){return Tt._valArr(this,e,t)}static valArr(e){return Tt._valArr(e,"valArr","string")}valArr(){return Tt.valArr(this)}static valNb(e){if(!(Tt._preInputElem(e,"valNb")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const t=Tt._val(e,"valNb","number");if(Number.isNaN(t))throw new Error("Value is not a valid number.");return t}valNb(){return Tt.valNb(this)}static valDate(e){if(!(Tt._preInputElem(e,"valDate")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const t=Tt._val(e,"valDate","date");if(!(t instanceof Date))throw new Error("Value is not a valid date.");return t}valDate(){return Tt.valDate(this)}static valBool(e){const t=Tt._preInputElem(e,"valBool");if(!(t instanceof HTMLInputElement))throw new Error("Element must be an input element.");return"on"===Tt.val(t)}valBool(){return Tt.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 i=e=>{if(!(e instanceof ClipboardEvent))return;const i=e.clipboardData?.items||[];for(const e of i)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 Tt._preElemsWithDoc(e,"listenForPaste").forEach(e=>Tt.on(e,"paste",i)),i}listenForPaste({onFilePaste:e,onTextPaste:t}={}){return Tt.listenForPaste(this,{onFilePaste:e,onTextPaste:t})}static hasEventListener(e,t){const r=Tt._preEventTargetElem(e,"hasEventListener");if(!gt.has(r))return!1;const i=gt.get(r);return!!(i&&Array.isArray(i[t])&&i[t].length>0)}hasEventListener(e){return Tt.hasEventListener(this,e)}static hasExactEventListener(e,t,r){const i=Tt._preEventTargetElem(e,"hasExactEventListener");if("function"!=typeof r)throw new TypeError('The "handler" must be a function.');if(!gt.has(i))return!1;const n=gt.get(i);return!(!n||!Array.isArray(n[t]))&&n[t].some(e=>e.handler===r)}hasExactEventListener(e,t){return Tt.hasExactEventListener(this,e,t)}static hover(e,t,r,i){return Tt.on(e,"mouseenter",t,i),Tt.on(e,"mouseleave",r||t,i),e}hover(e,t,r){return Tt.hover(this,e,t,r)}static on(e,t,r,i){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.");Tt._preEventTargetElems(e,"on").forEach(e=>{e.addEventListener(n,r,i),gt.has(e)||gt.set(e,{});const t=gt.get(e);t&&(Array.isArray(t[n])||(t[n]=[]),t[n].push({handler:r,options:i}))})}return e}on(e,t,r){return Tt.on(this,e,t,r)}static once(e,t,r,i={}){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.");Tt._preEventTargetElems(e,"once").forEach(e=>{const t=i=>{Tt.off(e,n,t),"function"==typeof r&&r(i)};Tt.on(e,n,t,"boolean"==typeof i?i:{...i,once:!0})})}return e}once(e,t,r={}){return Tt.once(this,e,t,r)}static off(e,t,r,i){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.");Tt._preEventTargetElems(e,"off").forEach(e=>{e.removeEventListener(n,r,i);const t=gt.get(e);t&&t[n]&&(t[n]=t[n].filter(e=>e.handler!==r),0===t[n].length&&delete t[n])})}return e}off(e,t,r){return Tt.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.");Tt._preEventTargetElems(e,"offAll").forEach(e=>{const t=gt.get(e);if(t&&t[r]){for(const i of t[r])e.removeEventListener(r,i.handler,i.options);delete t[r]}})}return e}offAll(e){return Tt.offAll(this,e)}static offAllTypes(e,t=null){if(null!==t&&"function"!=typeof t)throw new TypeError('The "filterFn" must be a function.');return Tt._preEventTargetElems(e,"offAllTypes").forEach(e=>{const r=gt.get(e);if(r){for(const i in r)for(const n of r[i])("function"!=typeof t||t(n.handler,i))&&e.removeEventListener(i,n.handler,n.options);gt.delete(e)}}),e}offAllTypes(e=null){return Tt.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 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.");Tt._preEventTargetElems(e,"trigger").forEach(e=>{const t=r instanceof Event||r instanceof CustomEvent?r:new CustomEvent(i,{bubbles:!0,cancelable:!0,detail:r});e.dispatchEvent(t)})}return e}trigger(e,t={}){return Tt.trigger(this,e,t)}static#fe={for:"htmlFor",class:"className"};static propFix=new Proxy(Tt.#fe,{set:(e,t,r)=>(e[t]=r,Tt.attrFix[r]=t,!0)});static attrFix=Object.fromEntries(Object.entries(Tt.#fe).map(([e,t])=>[t,e]));static getPropName(e){return"string"==typeof Tt.propFix[e]?Tt.propFix[e]:e}static getAttrName(e){return"string"==typeof Tt.attrFix[e]?Tt.attrFix[e]:e}static attrBigInt(e,t){const r=Tt._preElem(e,"attrBigInt").getAttribute(Tt.getAttrName(t));if(null==r)return null;try{return BigInt(r)}catch{return null}}attrBigInt(e){return Tt.attrBigInt(this,e)}static setAttrBigInt(e,t,r){if("bigint"!=typeof r)throw new Error("Value is not a valid BigInt.");return Tt.setAttr(e,t,r.toString())}setAttrBigInt(e,t){return Tt.setAttrBigInt(this,e,t)}static attrDate(e,t){const r=Tt._preElem(e,"attrDate").getAttribute(Tt.getAttrName(t));if(!r)return null;const i=new Date(r);return Number.isNaN(i.getTime())?null:i}attrDate(e){return Tt.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 Tt.setAttr(e,t,r.toISOString())}setAttrDate(e,t){return Tt.setAttrDate(this,e,t)}static attrJson(e,t){const r=Tt._preElem(e,"attrJson").getAttribute(Tt.getAttrName(t));if(!r)return null;try{return JSON.parse(r)}catch{return null}}attrJson(e){return Tt.attrJson(this,e)}static setAttrJson(e,t,r,i,n){const s=JSON.stringify(r,i,n);return Tt.setAttr(e,t,s)}setAttrJson(e,t,r,i){return Tt.setAttrJson(this,e,t,r,i)}static attrNumber(e,t){const r=Tt._preElem(e,"attrNumber").getAttribute(Tt.getAttrName(t));return null!=r?parseFloat(r):null}attrNumber(e){return Tt.attrNumber(this,e)}static setAttrNumber(e,t,r){if("number"!=typeof r)throw new Error("Value is not a valid number.");return Tt.setAttr(e,t,r.toString())}setAttrNumber(e,t){return Tt.setAttrNumber(this,e,t)}static attrBoolean(e,t){const r=Tt._preElem(e,"attrBoolean").getAttribute(Tt.getAttrName(t));return null===r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}attrBoolean(e){return Tt.attrBoolean(this,e)}static setAttrBoolean(e,t,r){if("boolean"!=typeof r)throw new Error("Value is not a valid boolean.");return Tt.setAttr(e,t,r.toString())}setAttrBoolean(e,t){return Tt.setAttrBoolean(this,e,t)}static attrString(e,t){const r=Tt._preElem(e,"attrString").getAttribute(Tt.getAttrName(t));return"string"==typeof r?r:null}attrString(e){return Tt.attrString(this,e)}static setAttrString(e,t,r){if("string"!=typeof r)throw new Error("Value is not a valid string.");return Tt.setAttr(e,t,r)}setAttrString(e,t){return Tt.setAttrString(this,e,t)}static attr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return Tt._preElem(e,"attr").getAttribute(Tt.getAttrName(t))}attr(e){return Tt.attr(this,e)}static setAttr(e,t,r=null){const i=Tt._preElems(e,"setAttr");if("object"==typeof t&&null!==t)return Object.entries(t).forEach(([e,t])=>i.forEach(r=>{null===t?r.removeAttribute(Tt.getAttrName(e)):r.setAttribute(Tt.getAttrName(e),String(t))})),e;if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return i.forEach(e=>{null===r?e.removeAttribute(Tt.getAttrName(t)):e.setAttribute(Tt.getAttrName(t),String(r))}),e}setAttr(e,t){return Tt.setAttr(this,e,t)}static removeAttr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return Tt._preElems(e,"removeAttr").forEach(e=>e.removeAttribute(Tt.getAttrName(t))),e}removeAttr(e){return Tt.removeAttr(this,e)}static hasAttr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return Tt._preElem(e,"hasAttr").hasAttribute(Tt.getAttrName(t))}hasAttr(e){return Tt.hasAttr(this,e)}static hasProp(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return!!Tt._preElem(e,"hasProp")[Tt.getPropName(t)]}hasProp(e){return Tt.hasProp(this,e)}static addProp(e,...t){return Tt._preElems(e,"addProp").forEach(e=>{t.forEach(t=>{if("string"!=typeof t)throw new TypeError('Each "name" must be a string.');e[Tt.getPropName(t)]=!0})}),e}addProp(...e){return Tt.addProp(this,...e)}static removeProp(e,...t){return Tt._preElems(e,"removeProp").forEach(e=>{t.forEach(t=>{if("string"!=typeof t)throw new TypeError('Each "name" must be a string.');e[Tt.getPropName(t)]=!1})}),e}removeProp(...e){return Tt.removeProp(this,...e)}static toggleProp(e,t,r){const i=Tt._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.");i.forEach(t=>{(void 0===r?!t[Tt.getPropName(e)]:r)?Tt.addProp(t,e):Tt.removeProp(t,e)})}),e}toggleProp(e,t){return Tt.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 Tt._preElem(e,"prop")[t]}prop(e){return Tt.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 Tt._preElems(e,"setProp").forEach(e=>{e[t]=r}),e}setProp(e,t){return Tt.setProp(this,e,t)}static remove(e){return Tt._preElems(e,"remove").forEach(e=>e.remove()),e}remove(){return Tt.remove(this)}static index(e,t=null){const r=Tt._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):Tt._preElems(t,"index");return Array.prototype.indexOf.call(e,r)}return-1}index(e){return Tt.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:i=0,width:n=0,top:s=0,bottom:o=0,left:a=0,right:l=0}=t;if("number"!=typeof i)throw new Error("extraRect.height must be a number.");if("number"!=typeof n)throw new Error("extraRect.width must be a number.");if("number"!=typeof s)throw new Error("extraRect.top must be a number.");if("number"!=typeof o)throw new Error("extraRect.bottom must be a number.");if("number"!=typeof a)throw new Error("extraRect.left must be a number.");if("number"!=typeof l)throw new Error("extraRect.right must be a number.");return r.height+=i,r.width+=n,r.top+=s,r.bottom+=o,r.left+=a,r.right+=l,r}static isCollWith(e,t,r={}){const i=Tt._getCustomRect(Tt._preElem(e,"isCollWith").getBoundingClientRect(),r),n=Tt._preElem(t,"isCollWith").getBoundingClientRect();return ct(i,n)}isCollWith(e,t){return Tt.isCollWith(this,e,t)}static isCollPerfWith(e,t,r={}){const i=Tt._getCustomRect(Tt._preElem(e,"isCollPerfWith").getBoundingClientRect(),r),n=Tt._preElem(t,"isCollPerfWith").getBoundingClientRect();return dt(i,n)}isCollPerfWith(e,t){return Tt.isCollPerfWith(this,e,t)}static _isCollWithLock(e,t,r,i,n){const s=Et[n];if(e)return s.has(i)||s.set(i,!0),!0;if(s.has(i)){let e=!1;switch(n){case"top":e=mt(t,r);break;case"bottom":e=pt(t,r);break;case"left":e=ft(t,r);break;case"right":e=yt(t,r)}return e&&s.delete(i),s.has(i)}return!1}static isCollWithLock(e,t,r,i={}){const n=Tt._preElem(e,"isCollWithLock"),s=Tt._preElem(t,"isCollWithLock"),o=Tt._getCustomRect(n.getBoundingClientRect(),i),a=s.getBoundingClientRect(),l=ct(o,a);return Tt._isCollWithLock(l,o,a,n,r)}isCollWithLock(e,t,r){return Tt.isCollWithLock(this,e,t,r)}static isCollPerfWithLock(e,t,r,i={}){const n=Tt._preElem(e,"isCollPerfWithLock"),s=Tt._preElem(t,"isCollPerfWithLock"),o=Tt._getCustomRect(n.getBoundingClientRect(),i),a=s.getBoundingClientRect(),l=dt(o,a);return Tt._isCollWithLock(l,o,a,n,r)}isCollPerfWithLock(e,t,r){return Tt.isCollPerfWithLock(this,e,t,r)}static resetCollLock(e){const t=Tt._preElem(e,"resetCollLock");let r=!1;for(const e of["top","bottom","left","right"])Et[e].has(t)&&(Et[e].delete(t),r=!0);return r}resetCollLock(){return Tt.resetCollLock(this)}static resetCollLockDir(e,t){const r=Tt._preElem(e,"resetCollLockDir"),i=Et[t];return!!i.has(r)&&(i.delete(r),!0)}resetCollLockDir(e){return Tt.resetCollLockDir(this,e)}static isInViewport(e){const t=Tt._preElem(e,"isInViewport");if(!t.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=Tt.offset(t).top,i=r+Tt.outerHeight(t),n=Tt.scrollTop(window),s=n+Tt.height(window);return i>n&&r<s}isInViewport(){return Tt.isInViewport(this)}static isScrolledIntoView(e){const t=Tt._preElem(e,"isScrolledIntoView");if(!t.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=Tt.scrollTop(window),i=r+Tt.height(window),n=Tt.offset(t).top;return n+Tt.height(t)<=i&&n>=r}isScrolledIntoView(){return Tt.isScrolledIntoView(this)}static isInContainer(e,t){const r=Tt._preElem(e,"isInContainer"),i=Tt._preElem(t,"isInContainer");if(!r.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const n=r.getBoundingClientRect(),s=i.getBoundingClientRect(),o=n.bottom>s.top&&n.top<s.bottom,a=n.right>s.left&&n.left<s.right;return o&&a}isInContainer(e){return Tt.isInContainer(this,e)}static isFullyInContainer(e,t){const r=Tt._preElem(e,"isScrolledIntoView"),i=Tt._preElem(t,"isInContainer");if(!r.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const n=r.getBoundingClientRect(),s=i.getBoundingClientRect();return n.top>=s.top&&n.bottom<=s.bottom&&n.left>=s.left&&n.right<=s.right}isFullyInContainer(e){return Tt.isFullyInContainer(this,e)}static hasScroll(e){const t=Tt._preElem(e,"hasScroll");return{v:t.scrollHeight>t.clientHeight,h:t.scrollWidth>t.clientWidth}}hasScroll(){return Tt.hasScroll(this)}}const St=Tt,xt=Y("TinyDragger");class At{static Utils={...t,TinyHtml:St};#ye=!0;#h=!1;#ge=0;#we=0;#be=!0;#ve=!1;#Ee=!1;#Te=!1;#Se=!1;#xe=!1;#Ae=!1;#Ce=null;#Ie=[];#De=null;#Me={start:!1,end:!1,collide:!1,move:!1};#Ne=null;#F;#ke="drag-hidden";#Le="dragging";#_e="drag-active";#je="jail-drag-active";#Re="jail-drag-disabled";#Pe="dragging-collision";#$e=9999;constructor(e,t={}){if(!(e instanceof HTMLElement))throw new Error("TinyDragger requires a valid target HTMLElement to initialize.");if(this.#F=e,void 0!==t.jail&&!(t.jail instanceof HTMLElement))throw new Error('The "jail" option must be an HTMLElement if provided.');if(void 0!==t.defaultZIndex&&this.setDefaultZIndex(t.defaultZIndex),void 0!==t.vibration&&!1!==t.vibration&&!f(t.vibration))throw new Error('The "vibration" option must be an object or false.');const r=(e,t)=>{if(void 0!==e&&"boolean"!=typeof e)throw new Error(`The "${t}" option must be a boolean.`)},i=(e,t)=>{if(void 0!==e&&"string"!=typeof e)throw new Error(`The "${t}" option must be a string.`)};r(t.mirrorElem,"mirrorElem"),r(t.collisionByMouse,"collisionByMouse"),r(t.lockInsideJail,"lockInsideJail"),r(t.dropInJailOnly,"dropInJailOnly"),r(t.revertOnDrop,"revertOnDrop"),r(t.multiCollision,"multiCollision"),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.#Ne=t.jail),this.#Me=Object.assign({start:!1,end:!1,collide:!1,move:!1},f(t.vibration)?t.vibration:{}),"string"==typeof t.classDragging&&(this.#Le=t.classDragging),"string"==typeof t.classBodyDragging&&(this.#_e=t.classBodyDragging),"string"==typeof t.classJailDragging&&(this.#je=t.classJailDragging),"string"==typeof t.classJailDragDisabled&&(this.#Re=t.classJailDragDisabled),"string"==typeof t.classHidden&&(this.#ke=t.classHidden),"string"==typeof t.classDragCollision&&(this.#Pe=t.classDragCollision),"boolean"==typeof t.collisionByMouse&&(this.#xe=t.collisionByMouse),"boolean"==typeof t.mirrorElem&&(this.#be=t.mirrorElem),"boolean"==typeof t.revertOnDrop&&(this.#Te=t.revertOnDrop),"boolean"==typeof t.lockInsideJail&&(this.#Ee=t.lockInsideJail),"boolean"==typeof t.dropInJailOnly&&(this.#Ae=t.dropInJailOnly),"boolean"==typeof t.multiCollision&&(this.#ve=t.multiCollision),this._onMouseDown=this.#He.bind(this),this._onMouseMove=this.#Oe.bind(this),this._onMouseUp=this.#Fe.bind(this),this._onTouchStart=e=>this.#He(e.touches[0]),this._onTouchMove=e=>this.#Oe(e.touches[0]),this._onTouchEnd=e=>this.#Fe(e.changedTouches[0]),this.#F.addEventListener("mousedown",this._onMouseDown),this.#F.addEventListener("touchstart",this._onTouchStart,{passive:!1})}enable(){xt(this.#h),this.#Ne&&this.#Ne.classList.add(this.#Re),this.#ye=!0}disable(){xt(this.#h),this.#Ne&&this.#Ne.classList.remove(this.#Re),this.#ye=!1}addCollidable(e){if(xt(this.#h),!(e instanceof HTMLElement))throw new Error("addCollidable expects an HTMLElement as argument.");this.#Ie.includes(e)||this.#Ie.push(e)}removeCollidable(e){if(xt(this.#h),!(e instanceof HTMLElement))throw new Error("removeCollidable expects an HTMLElement as argument.");this.#Ie=this.#Ie.filter(t=>t!==e)}setVibrationPattern({startPattern:e=!1,endPattern:t=!1,collidePattern:r=!1,movePattern:i=!1}={}){xt(this.#h);const n=e=>!1===e||Array.isArray(e)&&e.every(e=>"number"==typeof e);if(!n(e))throw new Error('Invalid "startPattern": must be false or an array of numbers.');if(!n(t))throw new Error('Invalid "endPattern": must be false or an array of numbers.');if(!n(r))throw new Error('Invalid "collidePattern": must be false or an array of numbers.');if(!n(i))throw new Error('Invalid "movePattern": must be false or an array of numbers.');this.#Me={start:e,end:t,collide:r,move:i}}disableVibration(){xt(this.#h),this.#Me={start:!1,end:!1,collide:!1,move:!1}}getOffset(e){if(xt(this.#h),!(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.#F.getBoundingClientRect(),{left:r,top:i}=St.borderWidth(this.#F);return{x:e.clientX-t.left+r,y:e.clientY-t.top+i}}#He(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#h||!this.#ye||!this.#F.parentElement)return;if(this.#be){const e=this.#F.cloneNode(!0);if(!(e instanceof HTMLElement))throw new Error("[TinyDragger] INVALID DRAG ELEMENT!");this.#De=e}else this.#De=this.#F;this.#Se=!0;const t=this.#F.getBoundingClientRect();Object.assign(this.#De.style,{position:"absolute",pointerEvents:"none",left:`${this.#F.offsetLeft}px`,top:`${this.#F.offsetTop}px`,width:`${t.width}px`,height:`${t.height}px`,zIndex:this.#$e}),this.#be&&(this.#F.classList.add(this.#ke),this.#F.parentElement.appendChild(this.#De));const{x:r,y:i}=this.getOffset(e);this.#we=r,this.#ge=i,this.#De.classList.add(this.#Le),document.body.classList.add(this.#_e),this.#Ne&&this.#Ne.classList.add(this.#je),document.addEventListener("mousemove",this._onMouseMove),document.addEventListener("mouseup",this._onMouseUp),document.addEventListener("touchmove",this._onTouchMove,{passive:!1}),document.addEventListener("touchend",this._onTouchEnd),navigator.vibrate&&Array.isArray(this.#Me.start)&&navigator.vibrate(this.#Me.start),this.checkDragCollision(e),this.#Be("drag")}#ze=[];#We(e){e&&(e.classList.add(this.#Pe),this.#ze.push(e))}#qe(){for(;this.#ze.length>0;){const e=this.#ze.shift();e&&e.classList.remove(this.#Pe)}this.#Ce&&this.#Ce.classList.remove(this.#Pe)}checkDragCollision(e){xt(this.#h);const{collidedElements:t}=this.execCollision(e),r=t[0]||null;this.#Ce&&!t.includes(this.#Ce)&&this.#qe(),t.forEach(e=>this.#We(e)),this.#Ie.forEach(e=>{t.includes(e)||e.classList.remove(this.#Pe)}),navigator.vibrate&&Array.isArray(this.#Me.collide)&&t.length>0&&navigator.vibrate(this.#Me.collide),this.#Ce=r}#Oe(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#h||!this.#Se||!this.#ye||!this.#De)return;const t=(this.#De.offsetParent||document.body).getBoundingClientRect();let r=e.clientX-t.left-this.#we,i=e.clientY-t.top-this.#ge;if(this.#Ee&&this.#Ne){const e=this.#Ne.getBoundingClientRect(),n=this.#De.getBoundingClientRect(),s=e.left-t.left,o=e.top-t.top,{x:a,y:l}=St.borderWidth(this.#Ne),u=s+e.width-n.width-l,h=o+e.height-n.height-a;r=Math.max(s,Math.min(r,u)),i=Math.max(o,Math.min(i,h))}this.#De.style.position="absolute",this.#De.style.left=`${r}px`,this.#De.style.top=`${i}px`,navigator.vibrate&&Array.isArray(this.#Me.move)&&navigator.vibrate(this.#Me.move),this.checkDragCollision(e),this.#Be("dragging")}execCollision(e){if(xt(this.#h),this.#h||!this.#De)return{inJail:!1,collidedElements:[]};let t=[],r=!0;const i=this.#Ne?.getBoundingClientRect();if(this.#xe){const n=e.clientX,s=e.clientY;this.#Ae&&this.#Ne&&i&&(r=n>=i.left&&n<=i.right&&s>=i.top&&s<=i.bottom),t=r?this.#ve?this.getAllCollidedElements(n,s):[this.getCollidedElement(n,s)].filter(Boolean):[]}else{const e=this.#De.getBoundingClientRect();this.#Ae&&this.#Ne&&i&&(r=e.left>=i.left&&e.right<=i.right&&e.top>=i.top&&e.bottom<=i.bottom),t=r?this.#ve?this.getAllCollidedElementsByRect(e):[this.getCollidedElementByRect(e)].filter(Boolean):[]}return{inJail:r,collidedElements:t}}#Fe(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#h||!this.#Se)return;if(this.#Se=!1,!this.#De)return;this.#F.classList.remove(this.#Le),document.body.classList.remove(this.#_e),this.#Ne&&this.#Ne.classList.remove(this.#je),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd);const{collidedElements:t}=this.execCollision(e);navigator.vibrate&&Array.isArray(this.#Me.end)&&navigator.vibrate(this.#Me.end);const r=this.#De.style.left,i=this.#De.style.top;this.#De&&(this.#be?this.#De.remove():Object.assign(this.#De.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#De=null),this.#Ce&&this.#qe(),this.#Ce=null,this.#be&&this.#F.classList.remove(this.#ke),this.#Te||(this.#F.style.left=r,this.#F.style.top=i);const n=new CustomEvent("drop",{detail:{targets:t,first:t[0]||null}});this.#F.dispatchEvent(n)}#Ve(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(xt(this.#h),!(e instanceof DOMRect)||"number"!=typeof e.left||"number"!=typeof e.right||"number"!=typeof e.top||"number"!=typeof e.bottom)throw new Error("getCollidedElementByRect expects a valid DOMRect object.");return this.#Ie.filter(t=>this.#Ve(t,e))}getCollidedElementByRect(e){if(xt(this.#h),!(e instanceof DOMRect)||"number"!=typeof e.left||"number"!=typeof e.right||"number"!=typeof e.top||"number"!=typeof e.bottom)throw new Error("getCollidedElementByRect expects a valid DOMRect object.");return this.#Ie.find(t=>this.#Ve(t,e))||null}#Ke(e,t,r){const i=e.getBoundingClientRect();return t>=i.left&&t<=i.right&&r>=i.top&&r<=i.bottom}getAllCollidedElements(e,t){if(xt(this.#h),"number"!=typeof e||"number"!=typeof t)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#Ie.filter(r=>this.#Ke(r,e,t))}getCollidedElement(e,t){if(xt(this.#h),"number"!=typeof e||"number"!=typeof t)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#Ie.find(r=>this.#Ke(r,e,t))||null}#Be(e){const t=new CustomEvent(e);this.#F.dispatchEvent(t)}getDragging(){return xt(this.#h),this.#Se}getLockInsideJail(){return xt(this.#h),this.#Ee}setLockInsideJail(e){if(xt(this.#h),"boolean"!=typeof e)throw new Error("lockInsideJail must be a boolean.");this.#Ee=e}getRevertOnDrop(){return xt(this.#h),this.#Te}setRevertOnDrop(e){if(xt(this.#h),"boolean"!=typeof e)throw new Error("revertOnDrop must be a boolean.");this.#Te=e}getCollisionByMouse(){return xt(this.#h),this.#xe}setCollisionByMouse(e){if(xt(this.#h),"boolean"!=typeof e)throw new Error("collisionByMouse must be a boolean.");this.#xe=e}getDropInJailOnly(){return xt(this.#h),this.#Ae}setDropInJailOnly(e){if(xt(this.#h),"boolean"!=typeof e)throw new Error("dropInJailOnly must be a boolean.");this.#Ae=e}getDefaultZIndex(){return xt(this.#h),this.#$e}setDefaultZIndex(e){if(xt(this.#h),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("Z-index must be a finite number.");this.#$e=e}isMirrorEnabled(){return xt(this.#h),this.#be}setMirrorEnabled(e){if(xt(this.#h),"boolean"!=typeof e)throw new TypeError("Mirror setting must be a boolean.");this.#be=e}getTarget(){return xt(this.#h),this.#F}getJail(){return xt(this.#h),this.#Ne}getDragProxy(){return xt(this.#h),this.#De}getLastCollision(){return xt(this.#h),this.#Ce}getCollidables(){return xt(this.#h),[...this.#Ie]}getDragHiddenClass(){return xt(this.#h),this.#ke}getClassDragging(){return xt(this.#h),this.#Le}getClassBodyDragging(){return xt(this.#h),this.#_e}getClassJailDragging(){return xt(this.#h),this.#je}getClassJailDragDisabled(){return xt(this.#h),this.#Re}getClassDragCollision(){return xt(this.#h),this.#Pe}getVibrations(){return xt(this.#h),{...this.#Me}}getStartVibration(){return xt(this.#h),this.#Me.start}getEndVibration(){return xt(this.#h),this.#Me.end}getCollideVibration(){return xt(this.#h),this.#Me.collide}getMoveVibration(){return xt(this.#h),this.#Me.move}isEnabled(){return xt(this.#h),this.#ye}destroy(){this.#h||(this.disable(),this.#F.removeEventListener("mousedown",this._onMouseDown),this.#F.removeEventListener("touchstart",this._onTouchStart),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd),this.#Ce&&this.#qe(),this.#De&&(this.#be?this.#De.remove():Object.assign(this.#De.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#De=null),this.#Ie=[],this.#Se=!1,this.#Ce=null,this.#be&&this.#F.classList.remove(this.#ke),this.#F.classList.remove(this.#Le),document.body.classList.remove(this.#_e),this.#Ne&&this.#Ne.classList.remove(this.#je,this.#Re),this.#h=!0)}}const Ct=At,It=class{#Je=[];#Ue=!1;#Ge=!1;#Ye=[];#Xe(){this.#Ue&&Promise.all(this.#Ye).then(()=>{this.#Ge=!0,this.#Qe(!1)}).catch(e=>{console.error("[TinyDomReadyManager] Promise rejected:",e)})}#Qe(e){this.#Je.filter(t=>t.domOnly===e).sort((e,t)=>t.priority-e.priority).forEach(e=>this.#Ze(e)),this.#Je=this.#Je.filter(t=>!(t.once&&(!e||t.domOnly)))}#Ze(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.#Ue=!0,this.#Qe(!0),this.#Xe()}init(){if(this.#Ue)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.#Ge||(this.#Ye.push(e),this.#Ue&&this.#Xe())}onReady(e,{once:t=!0,priority:r=0,filter:i=null,domOnly:n=!1}={}){if("function"!=typeof e)throw new TypeError("[TinyDomReadyManager] fn must be a function.");const s={fn:e,once:t,priority:r,filter:i,domOnly:n};if(n&&this.#Ue)return this.#Ze(s),void(t||this.#Je.push(s));!n&&this.#Ge?this.#Ze(s):this.#Je.push(s)}isReady(){return this.#Ge}isDomReady(){return this.#Ue}},Dt=class{#et=!1;#tt=!1;#rt=null;#it=100;#nt=null;#st;constructor({audio:e=null,defaultIcon:t=null,bodyLimit:r=100,defaultOnClick:i=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 i)throw new TypeError("defaultOnClick must be a function.");this.#rt="string"!=typeof e?e:new Audio(e),this.#nt=t,this.#it=r,this.#st=i}requestPerm(){const e=this;return new Promise((t,r)=>{e.isCompatible()?"default"===Notification.permission?Notification.requestPermission().then(r=>{this.#tt=!0,e.#et="granted"===r,t(e.#et)}).catch(r):(this.#tt=!0,e.#et="granted"===Notification.permission,t(e.#et)):(this.#tt=!0,e.#et=!1,t(!1))})}isCompatible(){return"Notification"in window}send(e,t={}){if(!this.#tt)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.#et)return null;const{icon:r=this.#nt||void 0,vibrate:i=[200,100,200]}=t,n={...t};"string"==typeof r&&(n.icon=r),Array.isArray(i)&&(n.vibrate=i),"string"==typeof n.body&&(n.body=q(n.body,this.#it));const s=new Notification(e,n);return s.addEventListener("show",()=>{this.#rt instanceof HTMLAudioElement&&(this.#rt.currentTime=0,this.#rt.play().catch(e=>console.error(e)))}),"function"==typeof this.#st&&s.addEventListener("click",this.#st),s}wasPermissionRequested(){return this.#tt}isAllowed(){return this.#et}getAudio(){return this.#rt}setAudio(e){if(!(e instanceof HTMLAudioElement)&&"string"!=typeof e&&null!==e)throw new TypeError("sound must be an instance of HTMLAudioElement or null.");this.#rt="string"!=typeof e?e:new Audio(e)}getBodyLimit(){return this.#it}setBodyLimit(e){if(!Number.isFinite(e)||e<0)throw new TypeError("bodyLimit must be a non-negative number.");this.#it=e}getDefaultAvatar(){return this.#nt}setDefaultAvatar(e){if("string"!=typeof e&&null!==e)throw new TypeError("defaultIcon must be a string or null.");this.#nt=e}getDefaultOnClick(){return this.#st}setDefaultOnClick(e){if("function"!=typeof e)throw new TypeError("defaultOnClick must be a function.");this.#st=e}},Mt=(e,t)=>{if("string"!=typeof t)throw new TypeError('Expected "name" to be a string.');if("string"!=typeof e)throw new TypeError(`Expected "${t}" to be a string, but received ${typeof e}.`)},Nt=(e,t)=>{if("string"!=typeof t)throw new TypeError('Expected "name" to be a string.');if("function"!=typeof e)throw new TypeError(`Expected "${t}" to be a function, but received ${typeof e}.`)},kt=(e,t)=>{if("string"!=typeof t)throw new TypeError('Expected "name" to be a string.');if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError(`Expected "${t}" to be a plain object, but received ${null===e?"null":Array.isArray(e)?"array":typeof e}.`)},Lt=new Map;class _t extends Error{constructor(e,t,r){if(Mt(e,"message"),Mt(t,"url"),"string"!=typeof r)throw new TypeError(`Expected "stage" to be a string, but received ${typeof r}.`);super(e),this.name="MediaLoadingError",this.url=t,this.stage=r}}const jt=async e=>{Mt(e,"str");const t=(new TextEncoder).encode(e),r=await crypto.subtle.digest("SHA-1",t);return Array.from(new Uint8Array(r)).map(e=>e.toString(16).padStart(2,"0")).join("").substring(0,8)},Rt=(e,t="image/jpeg")=>{if(!(e instanceof Uint8Array)&&"string"!=typeof e)throw new TypeError(`Expected "data" to be an instance of Uint8Array or a string, but received ${typeof e}.`);Mt(t,"format");const r=e=>{const t=URL.createObjectURL(e),r=Lt.get(t);return Lt.set(t,"number"==typeof r?r+1:1),t};if(e instanceof Uint8Array)return r(new Blob([e],{type:t}));if("string"==typeof e&&e.startsWith("data:")){const i=e.split(",")[1],n=atob(i),s=new Uint8Array(n.length);for(let e=0;e<n.length;e++)s[e]=n.charCodeAt(e);return r(new Blob([s],{type:t}))}return"string"==typeof e?e:""},Pt=async e=>{if(Mt(e,"url"),!e.startsWith("blob:"))return e;try{const t=await fetch(e),r=await t.blob();return await new Promise((e,t)=>{const i=new FileReader;i.onloadend=()=>e(String(i.result)),i.onerror=t,i.readAsDataURL(r)})}catch(t){return console.warn(`[TinyAudioUtils] Failed to convert Blob URL to Base64 on export: ${e}`,t),e}},$t=e=>{kt(e,"content"),e&&Array.isArray(e.picture)&&e.picture.forEach(e=>{if("string"==typeof e.data&&e.data.startsWith("blob:")){const t=Lt.get(e.data)??0;t>1?Lt.set(e.data,t-1):Lt.delete(e.data),t<=1&&URL.revokeObjectURL(e.data)}})},Ht=(e,t)=>{if(kt(e,"common"),"boolean"!=typeof t)throw new TypeError('Expected "isPartial" to be a boolean.');const r=e=>t&&void 0===e,i=e=>r(e)||"string"==typeof e||null===e,n=(e,t)=>(Nt(t,"valueValidator"),!!r(e)||!(!Array.isArray(e)||!e.every(t)));if(!i(e.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!i(e.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!i(e.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a string or null.');if(!i(e.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(s=e.year,!r(s)&&"number"!=typeof s&&null!==s)throw new TypeError('Invalid metadata: "year" must be a number or null.');var s;if(!n(e.albumartists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "albumartists" must be an array of string.');if(!n(e.genre,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "genre" must be an array of string.');if(!n(e.label,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "label" must be an array of string.');if(!n(e.composer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "composer" must be an array of string.');if(!n(e.artists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "artists" must be an array of string.');if(!n(e.picture,e=>e&&"object"==typeof e&&(void 0===e.description||"string"==typeof e.description)&&(void 0===e.name||"string"==typeof e.name)&&(void 0===e.type||"string"==typeof e.type)&&"string"==typeof e.format&&(e.data instanceof Uint8Array||"string"==typeof e.data)))throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');const o=(e,t)=>{if(Mt(e,"name"),!r(t)){if(null==t)throw new TypeError(`Invalid metadata: "${e}" is required.`);if("object"!=typeof t)throw new TypeError(`Invalid metadata: "${e}" must be an object or null.`);if("number"!=typeof t.no&&null!==t.no)throw new TypeError(`Invalid metadata: "${e}.no" must be a number or null.`);if("number"!=typeof t.of&&null!==t.of)throw new TypeError(`Invalid metadata: "${e}.of" must be a number or null.`)}};o("disk",e.disk),o("track",e.track)},Ot=e=>(kt(e,"common"),Ht(e,!1)),Ft=e=>(kt(e,"common"),Ht(e,!0)),Bt=async(e,t)=>{Mt(e,"url"),Nt(t,"parseFile");try{const r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch audio file: ${r.status} ${r.statusText}`);const i=await r.blob(),n=await t(i);if(!n||"object"!=typeof n.common)throw new TypeError('Invalid metadata: "common" property is missing or not an object.');const s=n.common;return Ft(s),{title:s?.title??null,album:s?.album??null,albumartist:s?.albumartist??null,albumartists:s?.albumartists??[],genre:s?.genre??[],label:s?.label??[],composer:s?.composer??[],year:s?.year??null,artist:s?.artist??null,artists:s?.artists??[],disk:s?.disk?{no:s.disk.no,of:s.disk.of}:{no:null,of:null},track:s?.track?{no:s.track.no,of:s.track.of}:{no:null,of:null},picture:s?.picture?.map(e=>({...e,data:Rt(e.data,e.format)}))??[]}}catch(e){throw e}},zt=async(e,t={},r={},i=e=>{if(!(e instanceof Blob))throw new TypeError('Expected "data" to be a Blob.');return new Promise((e,t)=>t(new TypeError("parseFile library not found.")))},n={},s="null")=>{if("string"!=typeof e&&!(e instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(kt(t,"defaultMetadata"),kt(r,"metadata"),Nt(i,"parseFile"),kt(n,"callbacks"),n.onProgress&&"function"!=typeof n.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(n.onError&&"function"!=typeof n.onError)throw new TypeError("callbacks.onError must be a function.");if("string"!=typeof s&&"function"!=typeof s)throw new TypeError("unknownArtist must be a string or a function returning a string.");let o,a="";const l=(t,r)=>{if(Mt(t,"stage"),void 0!==r&&!(r instanceof Event))throw new TypeError('Expected "event" to be an Event or undefined.');n.onProgress&&n.onProgress({event:r,status:"loading",stage:t,url:a||(e instanceof HTMLMediaElement?e.src:"unknown")})},u=(t,r)=>{if(!(t instanceof Error))throw new TypeError('Expected "error" to be an Error.');Mt(r,"stage"),n.onError&&n.onError({error:t,url:a||(e instanceof HTMLMediaElement?e.src:"unknown"),stage:r})};try{l("INITIALIZING"),"string"==typeof e?(a=e,o=new Audio(a)):(o=e,a=o.src);try{await new Promise((e,t)=>{const r=e=>l("DOWNLOADING",e),i=()=>{s(),e(void 0)},n=e=>{s(),t(new Error(`HTMLMediaElement failed to load: ${e.message||"Unknown error"}`))},s=()=>{o.removeEventListener("progress",r),o.removeEventListener("loadedmetadata",i),o.removeEventListener("error",n)};o.addEventListener("progress",r),o.addEventListener("loadedmetadata",i),o.addEventListener("error",n),o.readyState>=1&&(s(),e(void 0))}),l("METADATA_LOADED")}catch(e){throw new _t(e instanceof Error?e.message:"UNKNOWN ERROR",a,"METADATA")}const h={id:r.id||await jt(a),duration:Math.floor(1e3*o.duration),url:a,weight:r.weight??1};let c={};l("EXTRACTING_ID3");try{c=await Bt(a,i)}catch(e){u(e instanceof Error?e:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${a}. Falling back to filename.`)}const d=e=>{Mt(e,"url");try{return(e.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},m={...h,...t,...c,...r,title:c.title||r.title||d(a),artist:c.artist||r.artist||("string"==typeof s?s:String(s()))};return n.onProgress&&n.onProgress({status:"success",stage:"COMPLETE",url:a}),m}catch(e){if(e instanceof _t)throw e;{const t=new _t(e instanceof Error?e.message:"UNKNOWN ERROR",a,"INITIALIZING");throw u(t,"INITIALIZING"),t}}},Wt=Y("TinyAfterScrollWatcher"),qt=class{#ot;get scrollTarget(){return Wt(this.#h),this.#ot}#at=null;#lt=[];get afterScrollQueueSize(){return Wt(this.#h),this.#lt.length}#ut=100;#ht=new Set;#ct=new Set;#h=!1;get destroyed(){return this.#h}constructor(e,t=100){if(!(e instanceof Element||e instanceof Window))throw new TypeError("scrollTarget must be an Element or the Window object.");this.#ot=e,this._checkTimer=this._checkTimer.bind(this),this.#ot.addEventListener("scroll",this._checkTimer),this.#ut=t}_checkTimer=()=>{this.#at&&clearTimeout(this.#at),this.#at=setTimeout(()=>{this.#at=null,this.#dt()},this.#ut)};get inactivityTime(){return Wt(this.#h),this.#ut}set inactivityTime(e){if(Wt(this.#h),"number"!=typeof e||e<=0||!Number.isFinite(e))throw new Error("inactivityTime must be a positive number in milliseconds.");this.#ut=e}#dt(){if(!this.#h){for(const e of this.#ct)"function"==typeof e&&e();for(;this.#lt.length;){const e=this.#lt.pop();"function"==typeof e&&e()}}}doAfterScroll(e){if(Wt(this.#h),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.lastScrollTime=Date.now(),this.#lt.push(e)}onStop(e){if(Wt(this.#h),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ct.add(e)}offStop(e){if(Wt(this.#h),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ct.delete(e)}onScroll(e){if(Wt(this.#h),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ot.addEventListener("scroll",e),this.#ht.add(e)}offScroll(e){if(Wt(this.#h),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ht.has(e)&&(this.#ot.removeEventListener("scroll",e),this.#ht.delete(e))}destroy(){if(!this.#h){this.#ot.removeEventListener("scroll",this._checkTimer);for(const e of this.#ht)this.#ot.removeEventListener("scroll",e);this.#ht.clear(),this.#ct.clear(),this.#h=!0}}},Vt=Y("UltraRandomMsgGen"),Kt=["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","sed","do","eiusmod","tempor","incididunt","ut","labore","et","dolore","magna","aliqua"],Jt=["😂","🌈","🤖","💥","🐸","🍕","🦄","🧠","🧬","🚀","🫠","💫","🍩","👾","🎉","🥴","🐙","🧃","🪐","🎈","🧸","👻","🥳","🍭","💖","😺","🌮","🪅","🎮","🥓","🍮","🍬","🍓","🍒","🥝","🥑","🍄","🌊","☁️","🌟","🌙","🧚","🐾","🐥","🐼","🐨","🐳","✨","🧁","🌸","🍃","💎","🎐","🎀","🫧","☄️","🛸","🔮"],Ut=["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"],Gt=["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"],Yt=["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"],Xt=["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.","In the glow of the {adj} moon, the {noun} began to {verb}.","A sprinkle of {adj} dust made the {noun} {verb} through the air.","The {noun} whispered a {adj} secret that made everyone {verb}.","Everything felt {adj} and {adj}, especially when the {noun} {verb}ed.","The {noun} is {verb}ing! The {noun} is {verb}ing! AAAAA!","Glitch in the {noun}: the {adj} {noun} just {verb}ed out of existence.","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 Qt{static#mt=Kt;static#pt=Jt;static#ft=Ut;static#yt=Gt;static#gt=Yt;static#wt=Xt;static#bt(e,t){if(!Array.isArray(e))throw new TypeError(`${t} must be an array of strings`);if(!e.every(e=>"string"==typeof e))throw new TypeError(`${t} must contain only strings`);if(0===e.length)throw new Error(`${t} cannot be empty`)}static get defaultWords(){return[...this.#mt]}static set defaultWords(e){this.#bt(e,"defaultWords"),this.#mt=[...e]}static get defaultEmojis(){return[...this.#pt]}static set defaultEmojis(e){this.#bt(e,"defaultEmojis"),this.#pt=[...e]}static get defaultNouns(){return[...this.#ft]}static set defaultNouns(e){this.#bt(e,"defaultNouns"),this.#ft=[...e]}static get defaultVerbs(){return[...this.#yt]}static set defaultVerbs(e){this.#bt(e,"defaultVerbs"),this.#yt=[...e]}static get defaultAdjectives(){return[...this.#gt]}static set defaultAdjectives(e){this.#bt(e,"defaultAdjectives"),this.#gt=[...e]}static get defaultTemplates(){return[...this.#wt]}static set defaultTemplates(e){this.#bt(e,"defaultTemplates"),this.#wt=[...e]}#h=!1;get destroyed(){return this.#h}#vt={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}};get config(){return Vt(this.#h),structuredClone(this.#vt)}#Et="!@#$%^&*()-_=+[]{}|;:,.<>?/\\~".split("");get symbols(){return Vt(this.#h),structuredClone(this.#Et)}constructor(e={}){const{minLength:t,maxLength:r,readable:i,useEmojis:n,includeNumbers:s,includeSymbols:o,allowWeirdSpacing:a,emojiSet:l,wordSet:u,mode:h,grammar:c,repeatWords:d,emojiPlacement:m,paragraphs:p,line:f}=e;if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.minLength must be an integer >= 1");if(void 0!==r&&(!Number.isInteger(r)||r<1))throw new TypeError("config.maxLength must be an integer >= 1");if(void 0!==t&&void 0!==r&&t>r)throw new RangeError("config.minLength cannot be greater than config.maxLength");if(void 0!==i&&"boolean"!=typeof i)throw new TypeError("config.readable must be a boolean");if(void 0!==n&&"boolean"!=typeof n)throw new TypeError("config.useEmojis must be a boolean");if(void 0!==s&&"boolean"!=typeof s)throw new TypeError("config.includeNumbers must be a boolean");if(void 0!==o&&"boolean"!=typeof o)throw new TypeError("config.includeSymbols must be a boolean");if(void 0!==a&&"boolean"!=typeof a)throw new TypeError("config.allowWeirdSpacing must be a boolean");if(void 0!==l&&!Array.isArray(l))throw new TypeError("config.emojiSet must be an array of strings");if(void 0!==u&&!Array.isArray(u))throw new TypeError("config.wordSet must be an array of strings");if(void 0!==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:i}=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!==i&&!Array.isArray(i))throw new TypeError("config.grammar.adjectives must be an array of strings")}if(void 0!==d&&"boolean"!=typeof d)throw new TypeError("config.repeatWords must be a boolean");if(void 0!==m&&!["inline","end","none"].includes(m))throw new RangeError('config.emojiPlacement must be one of: "inline", "end", "none"');if(void 0!==p){if("object"!=typeof p)throw new TypeError("config.paragraphs must be an object or null");const{min:e,max:t}=p;if(void 0!==e&&(!Number.isInteger(e)||e<1))throw new TypeError("config.paragraphs.min must be an integer >= 1");if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.paragraphs.max must be an integer >= 1");if(void 0!==e&&void 0!==t&&e>t)throw new RangeError("config.paragraphs.min cannot be greater than config.paragraphs.max")}if(void 0!==f){if("object"!=typeof f||null===f)throw new TypeError("config.line must be an object");const{minLength:e,maxLength:t,emojiChance:r}=f;if(void 0!==e&&(!Number.isInteger(e)||e<1))throw new TypeError("config.line.minLength must be an integer >= 1");if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.line.maxLength must be an integer >= 1");if(void 0!==e&&void 0!==t&&e>t)throw new RangeError("config.line.minLength cannot be greater than config.line.maxLength");if(void 0!==r&&("number"!=typeof r||r<0||r>1))throw new RangeError("config.line.emojiChance must be a number between 0 and 1")}this.#vt.emojiSet=[...Qt.#pt],this.#vt.wordSet=[...Qt.#mt],this.#vt.grammar.templates=[...Qt.#wt],this.#vt.grammar.nouns=[...Qt.#ft],this.#vt.grammar.verbs=[...Qt.#yt],this.#vt.grammar.adjectives=[...Qt.#gt],Object.assign(this.#vt,e)}configure(e={}){return Vt(this.#h),Object.assign(this.#vt,e),this}setGrammarTemplates(...e){return Vt(this.#h),this.#vt.grammar.templates=e.flat(),this}addGrammarTemplates(...e){return Vt(this.#h),this.#vt.grammar.templates.push(...e.flat()),this}setGrammarNouns(...e){return Vt(this.#h),this.#vt.grammar.nouns=e.flat(),this}addGrammarNouns(...e){return Vt(this.#h),this.#vt.grammar.nouns.push(...e.flat()),this}setGrammarVerbs(...e){return Vt(this.#h),this.#vt.grammar.verbs=e.flat(),this}addGrammarVerbs(...e){return Vt(this.#h),this.#vt.grammar.verbs.push(...e.flat()),this}setGrammarAdjectives(...e){return Vt(this.#h),this.#vt.grammar.adjectives=e.flat(),this}addGrammarAdjectives(...e){return Vt(this.#h),this.#vt.grammar.adjectives.push(...e.flat()),this}removeGrammarTemplates(...e){Vt(this.#h);const t=new Set(e.flat());return this.#vt.grammar.templates=this.#vt.grammar.templates.filter(e=>!t.has(e)),this}removeGrammarNouns(...e){Vt(this.#h);const t=new Set(e.flat());return this.#vt.grammar.nouns=this.#vt.grammar.nouns.filter(e=>!t.has(e)),this}removeGrammarVerbs(...e){Vt(this.#h);const t=new Set(e.flat());return this.#vt.grammar.verbs=this.#vt.grammar.verbs.filter(e=>!t.has(e)),this}removeGrammarAdjectives(...e){Vt(this.#h);const t=new Set(e.flat());return this.#vt.grammar.adjectives=this.#vt.grammar.adjectives.filter(e=>!t.has(e)),this}setWords(...e){return Vt(this.#h),this.#vt.wordSet=e.flat(),this}addWords(...e){return Vt(this.#h),this.#vt.wordSet.push(...e.flat()),this}removeWords(...e){Vt(this.#h);const t=new Set(e.flat());return this.#vt.wordSet=this.#vt.wordSet.filter(e=>!t.has(e)),this}setEmojis(...e){return Vt(this.#h),this.#vt.emojiSet=e.flat(),this}addEmojis(...e){return Vt(this.#h),this.#vt.emojiSet.push(...e.flat()),this}removeEmojis(...e){Vt(this.#h);const t=new Set(e.flat());return this.#vt.emojiSet=this.#vt.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:i,useEmojis:n,readable:s,mode:o,emojiPlacement:a}=this.#vt;if("natural"===o)return this._generateNaturalSentence();const l=[];return(s||"readable"===o||"mixed"===o)&&l.push(this._getRandomItem(e)),"chaotic"!==o&&"mixed"!==o||l.push(Math.random().toString(36).slice(2)),r&&l.push(Math.floor(99999*Math.random()).toString()),i&&l.push(this._getRandomItem(this.#Et)),"inline"===a&&n&&t.length&&l.push(this._getRandomItem(t)),this._getRandomItem(l)}_generateNaturalSentence(){const{templates:e,nouns:t,verbs:r,adjectives:i}=this.#vt.grammar;return this._getRandomItem(e).replace(/{noun}/g,()=>this._getRandomItem(t)).replace(/{verb}/g,()=>this._getRandomItem(r)).replace(/{adj}/g,()=>this._getRandomItem(i))}_generateLine(e,t){const{allowWeirdSpacing:r,repeatWords:i,readable:n,emojiSet:s,useEmojis:o,emojiPlacement:a,line:l}=this.#vt,u=[];for(t??=new Set;u.join(" ").length<e;){let e=this._generateChunk();!i&&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(n?" ":"");return"end"===a&&o&&s.length&&Math.random()<(l?.emojiChance||0)&&(h+=" "+this._getRandomItem(s)),h}_generateParagraphLines(e){const{line:t}=this.#vt,r=[],i=new Set;let n=0;for(;n<e;){const s=Math.floor(Math.random()*(t.maxLength-t.minLength+1)+t.minLength),o=Math.min(s,e-n);r.push(this._generateLine(o,i)),n+=o}return r}generate(){Vt(this.#h);const{minLength:e,maxLength:t,paragraphs:r}=this.#vt,i=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(i/e),n=[];for(let r=0;r<e;r++){const e=this._generateParagraphLines(t);n.push(e.join("\n"))}return n.join("\n\n")}return this._generateParagraphLines(i).join("\n")}destroy(){this.destroyed||(this.#Et=[],this.#vt.emojiSet=[],this.#vt.wordSet=[],this.#vt.grammar.templates=[],this.#vt.grammar.nouns=[],this.#vt.grammar.verbs=[],this.#vt.grammar.adjectives=[],this.#h=!0)}}const Zt=Qt;var er=r(7);const tr=Y("TinySmartScroller");class rr extends er.EventEmitter{static Utils={...t,TinyHtml:St};#Tt=new WeakMap;#St=new WeakMap;#xt=new WeakMap;#At=new WeakMap;#Ct=new WeakMap;#It=new WeakMap;#Dt=null;#Mt=null;#Nt=new Set(["IMG","IFRAME","VIDEO"]);#kt=null;#Lt=!1;#_t=!1;#jt=!1;#Rt=!1;#Pt=!1;#$t=!1;#Ht=!1;#Ot=!1;#Ft="";#Bt=!1;#h=!1;#zt=!1;#Wt=!1;#qt=!1;#Vt=!1;#Kt=0;#Jt=0;#Ut=0;#Gt=0;#Yt=0;#Xt;#Qt;#F;#Zt=new Set;constructor(e,{extraScrollBoundary:t=0,autoScrollBottom:r=!0,observeMutations:i=!0,preserveScrollOnLayoutShift:n=!0,debounceTime:s=100,querySelector:o=null,attributeFilter:a=["class","style","src","data-*","height","width"]}={}){if(super(),!(e instanceof Element||e===window))throw new TypeError("TinySmartScroller: 'target' must be a DOM Element or 'window', but got "+typeof e);if("number"!=typeof t||Number.isNaN(t))throw new TypeError(`TinySmartScroller: 'extraScrollBoundary' must be a valid number, received ${t}`);if("boolean"!=typeof r)throw new TypeError("TinySmartScroller: 'autoScrollBottom' must be a boolean, received "+typeof r);if("boolean"!=typeof i)throw new TypeError("TinySmartScroller: 'observeMutations' must be a boolean, received "+typeof i);if("boolean"!=typeof n)throw new TypeError("TinySmartScroller: 'preserveScrollOnLayoutShift' must be a boolean, received "+typeof n);if("number"!=typeof s||s<0||Number.isNaN(s))throw new TypeError(`TinySmartScroller: 'debounceTime' must be a non-negative number, received ${s}`);if(null!==o&&"string"!=typeof o)throw new TypeError("TinySmartScroller: 'querySelector' must be a string or null, received "+typeof o);if(!(null===a||Array.isArray(a)||a instanceof Set))throw new TypeError("TinySmartScroller: 'attributeFilter' must be an array, Set, or null. Got "+typeof a);let l;this.#F=e,this.#Qt=e instanceof Window?document.documentElement:e,this.#Bt=e instanceof Window,this.#Wt=r,this.#qt=i,this.#Vt=n,this.#Kt=s,this.#Yt=t,this.#Ft=o||"",this.#Xt=new Set(a||void 0),this.#kt=()=>{this._scrollDataUpdater(),clearTimeout(l),l=setTimeout(()=>this._onScroll(),this.#Kt)},(this.#Bt?window:this.#Qt).addEventListener("scroll",this.#kt,{passive:!0}),this.#qt&&(this._observeMutations(),this._observeResizes(this.#Qt.children)),this._scrollDataUpdater()}getSimpleOnHeight(e=[]){if(tr(this.#h),!Array.isArray(e))throw new TypeError("getSimpleOnHeight(filter): filter must be an array of tag names");return(t,r,i)=>{if(e.length>0&&!e.includes(t.tagName)||i.now!==i.old)return;const n=r.old;return{height:r.now.height-n.height,width:0}}}addSimpleOnHeight(e){if(tr(this.#h),!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 tr(this.#h),Array.from(this.#Nt)}addLoadTag(e){if(tr(this.#h),"string"!=typeof e)throw new TypeError("addLoadTag(tag): tag must be a string");this.#Nt.add(e.toUpperCase())}removeLoadTag(e){if(tr(this.#h),"string"!=typeof e)throw new TypeError("removeLoadTag(tag): tag must be a string");this.#Nt.delete(e.toUpperCase())}hasLoadTag(e){if(tr(this.#h),"string"!=typeof e)throw new TypeError("hasLoadTag(tag): tag must be a string");return this.#Nt.has(e.toUpperCase())}resetLoadTags(e=!1){if(tr(this.#h),"boolean"!=typeof e)throw new TypeError("resetLoadTags(addDefault): addDefault must be a boolean");this.#Nt.clear(),e&&(this.#Nt.add("IMG"),this.#Nt.add("IFRAME"),this.#Nt.add("VIDEO"))}getAttributeFilters(){return tr(this.#h),Array.from(this.#Xt)}addAttributeFilter(e){if(tr(this.#h),"string"!=typeof e)throw new TypeError("addAttributeFilter(attr): attr must be a string");this.#Xt.add(e)}removeAttributeFilter(e){if(tr(this.#h),"string"!=typeof e)throw new TypeError("removeAttributeFilter(attr): attr must be a string");this.#Xt.delete(e)}hasAttributeFilter(e){if(tr(this.#h),"string"!=typeof e)throw new TypeError("hasAttributeFilter(attr): attr must be a string");return this.#Xt.has(e)}resetAttributeFilters(e=!1){if(tr(this.#h),"boolean"!=typeof e)throw new TypeError("resetAttributeFilters(addDefault): addDefault must be a boolean");this.#Xt.clear(),e&&["class","style","src","data-*","height","width"].forEach(e=>this.#Xt.add(e))}onSize(e){if(tr(this.#h),"function"!=typeof e)throw new TypeError("onSize(handler): handler must be a function");this.#Zt.add(e)}offSize(e){if(tr(this.#h),"function"!=typeof e)throw new TypeError("offSize(handler): handler must be a function");this.#Zt.delete(e)}_scrollDataUpdater(){const e=new Map;return this.#Qt.querySelectorAll(this.#Ft||"*").forEach(t=>{const r=this.#xt.get(t)??!1;this.#At.set(t,r);const i=St.isInContainer(this.#Qt,t);this.#xt.set(t,i),e.set(t,{oldIsVisible:r,isVisible:i})}),e}_onScroll(){if(this.#h)return;const e=this._scrollDataUpdater(),t=this.#Qt,r=t.scrollTop,i=t.scrollHeight,n=t.clientHeight,s={scrollTop:r,scrollHeight:i,clientHeight:n};let o=null,a=null;const l=0===r,u=r+n>=i-1,h=r<=0+this.#Yt,c=r+n>=i-1-this.#Yt;l&&u?o="all":l?o="top":u&&(o="bottom"),h&&c?a="all":h?a="top":c&&(a="bottom"),this.#_t=this.#$t??!1,this.#Lt=this.#Pt??!1,this.#jt=this.#Ht??!1,this.#Rt=this.#Ot??!1,this.#$t=l,this.#Pt=u,this.#Ht=h,this.#Ot=c,this.#zt=!(this.#Wt&&this.#Pt),this.#Gt=i-r-n,this.emit("onScrollBoundary",{status:o,...s,scrollCache:e}),this.emit("onExtraScrollBoundary",{status:a,...s,scrollCache:e}),this.#zt?this.emit("onScrollPause",{...s,scrollCache:e}):this.emit("onAutoScroll",{...s,scrollCache:e})}_fixScroll(e=[]){if(this.#h)return;if(!Array.isArray(e))throw new TypeError("_fixScroll: targets must be an array of Elements");const t=this.#Qt.scrollHeight,r=this.#Qt.scrollTop,i=this.#Qt.scrollHeight-this.#Qt.scrollTop-this.#Qt.clientHeight,n=this.#Qt.scrollHeight-t,s=()=>{const t={height:0,width:0};for(const r of e){const e=this.#Tt.get(r)||{height:0,width:0},i=this.#St.get(r)||{height:0,width:0};this.#Zt.forEach(n=>{const s=n(r,{old:e,now:i},{old:this.#Ut,now:this.#Jt});if(this.#xt.get(r)||this.#Ct.get(r)){if(void 0!==s&&"object"!=typeof s)throw new Error("_fixScroll: size filter must return an object or undefined");if(void 0===s)return;t.height=s.height,t.width=s.width}})}if("number"!=typeof t.height&&t.height<0)throw new Error("_fixScroll: invalid scrollSize.height value");if("number"!=typeof t.width&&t.width<0)throw new Error("_fixScroll: invalid scrollSize.width value");if(0!==t.height||0!==t.width)for(const t of e)this.#Ct.set(t,this.#xt.get(t)??!1),this.#It.set(t,this.#At.get(t)??!1);return t};if(this.#Ut>0&&St.hasScroll(this.#Qt).v&&this.#Wt&&this.#Vt&&!this.#Pt&&!this.#$t){const e=s();this.#Qt.scrollTop=r+n+e.height,e.width>0&&(this.#Qt.scrollLeft=this.#Qt.scrollLeft+e.width)}else!this.#zt&&this.#Wt?(s(),this.scrollToBottom()):this.#Wt||this.#Pt||(s(),this.#Qt.scrollTop=this.#Qt.scrollHeight-this.#Qt.clientHeight-i)}_observeMutations(){this.#Mt=new MutationObserver(e=>{this.#h||(this._scrollDataUpdater(),this.#Ut=this.#Jt,this.#Jt=this.#Qt.childElementCount,e.forEach(e=>{e.addedNodes.forEach(e=>{if(e instanceof Element&&1===e.nodeType&&(this._observeResizes([e]),this._listenLoadEvents(e),this.#Ft)){const t=e.querySelectorAll(this.#Ft);this._observeResizes(t),this._listenLoadEvents(t)}})}),this._fixScroll())}),this.#Mt.observe(this.#Qt,{childList:!0,subtree:!0,attributes:!0,attributeFilter:this.#Xt.size>0?Array.from(this.#Xt):void 0})}_observeResizes(e){this.#Dt||(this.#Dt=new ResizeObserver(e=>{if(this.#h)return;this._scrollDataUpdater();const t=[];for(const r of e){const e=r.target,i=this.#St.get(e);i&&this.#Tt.set(e,i);const{width:n,height:s}=r.contentRect;this.#St.set(e,{width:n,height:s}),t.push(e)}this._fixScroll(t)})),Array.from(e).forEach(e=>{if(!this.#Dt)throw new Error("_observeResizes: ResizeObserver instance is not initialized");this.#Dt.observe(e)})}_listenLoadEvents(e){this.#h||(e instanceof NodeList?Array.from(e):[e]).forEach(e=>{this.#Nt.has(e.tagName)&&(e.complete||e.addEventListener("load",()=>{this._scrollDataUpdater(),!this.#zt&&this.#Wt&&this.scrollToBottom()}))})}get target(){return this.#F}get targetElement(){return this.#Qt}getOldSize(e){return tr(this.#h),this.#Tt.get(e)??null}getNewSize(e){return tr(this.#h),this.#St.get(e)??null}wasVisible(e){return tr(this.#h),this.#At.get(e)??!1}isVisible(e){return tr(this.#h),this.#xt.get(e)??!1}wasTimedVisible(e){return tr(this.#h),this.#It.get(e)??!1}isTimedVisible(e){return tr(this.#h),this.#Ct.get(e)??!1}setExtraScrollBoundary(e){if(tr(this.#h),"number"!=typeof e||Number.isNaN(e))throw new TypeError("setExtraScrollBoundary(value): value must be a valid number");this.#Yt=e}getExtraScrollBoundary(){return tr(this.#h),this.#Yt}getLastKnownScrollBottomOffset(){return tr(this.#h),this.#Gt}scrollToBottom(){tr(this.#h),this.#Qt.scrollTop=this.#Qt.scrollHeight}scrollToTop(){tr(this.#h),this.#Qt.scrollTop=0}isAtCustomBottom(){return tr(this.#h),this.#Ot}isAtCustomTop(){return tr(this.#h),this.#Ht}isAtBottom(){return tr(this.#h),this.#Pt}isAtTop(){return tr(this.#h),this.#$t}isPastAtBottom(){return tr(this.#h),this.#Lt}isPastAtTop(){return tr(this.#h),this.#_t}isPastAtCustomTop(){return tr(this.#h),this.#jt}isPastAtCustomBottom(){return tr(this.#h),this.#Rt}isScrollPaused(){return tr(this.#h),this.#zt}isWindow(){return tr(this.#h),this.#Bt}isDestroyed(){return this.#h}getAutoScrollBottom(){return tr(this.#h),this.#Wt}getObserveMutations(){return tr(this.#h),this.#qt}getPreserveScrollOnLayoutShift(){return tr(this.#h),this.#Vt}getDebounceTime(){return tr(this.#h),this.#Kt}getElemAmount(){return tr(this.#h),this.#Jt}getPrevElemAmount(){return tr(this.#h),this.#Ut}getQuerySelector(){return tr(this.#h),this.#Ft}destroy(){if(this.#h)return;this.#Mt&&(this.#Mt.disconnect(),this.#Mt=null),this.#Dt&&(this.#Dt.disconnect(),this.#Dt=null);const e=this.#Bt?window:this.#Qt;this.#kt&&e.removeEventListener("scroll",this.#kt),this.#Tt=new WeakMap,this.#St=new WeakMap,this.#xt=new WeakMap,this.#At=new WeakMap,this.#Ct=new WeakMap,this.#It=new WeakMap,this.removeAllListeners(),this.#Zt.clear(),this.#Nt.clear(),this.#h=!0}}const ir=rr,nr=class{#G;#er;#tr;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.#er=t,this.#tr=r}getOpenTag(){return this.#er}getCloseTag(){return this.#tr}setOpenTag(e){if("string"!=typeof e)throw new TypeError("Open tag must be a string.");this.#er=e}setCloseTag(e){if("string"!=typeof e)throw new TypeError("Close tag must be a string.");this.#tr=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 i=this.#G.scrollTop,n=this.#G.scrollLeft;return this.#G.setSelectionRange(e,t),r&&(this.#G.scrollTop=i,this.#G.scrollLeft=n),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:i=r,autoSpaceRight:n=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 i)throw new TypeError("autoSpaceLeft must be a boolean.");if("boolean"!=typeof n)throw new TypeError("autoSpaceRight must be a boolean.");const{start:s,end:o}=this.getSelectionRange(),a=this.#G.value,l=a[s-1]||"",u=a[o]||"",h=`${i&&l&&!/\s/.test(l)?" ":""}${e}${n&&u&&!/\s/.test(u)?" ":""}`,c=a.slice(0,s)+h+a.slice(o);this.setValue(c);let d=s;return"end"===t?d=s+h.length:"preserve"===t&&(d=s),this.setSelectionRange(d,d),this}deleteSelection(){return this.insertText(""),this}transformSelection(e){if("function"!=typeof e)throw new TypeError("transformer must be a function.");const{start:t}=this.getSelectionRange(),r=e(this.getSelectedText());return this.insertText(r),this.setSelectionRange(t,t+r.length),this}surroundSelection(e,t){if("string"!=typeof e||"string"!=typeof t)throw new TypeError("prefix and suffix must be strings.");const r=this.getSelectedText();return this.insertText(`${e}${r}${t}`),this}moveCaret(e){if("number"!=typeof e)throw new TypeError("offset must be a number.");const{start:t}=this.getSelectionRange(),r=Math.max(0,t+e);return this.setSelectionRange(r,r),this}selectAll(){return this.setSelectionRange(0,this.#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:i}=this.getSelectionRange(),n=Math.max(0,r-e),s=Math.min(this.#G.value.length,i+t);return this.setSelectionRange(n,s),this}replaceAll(e,t){if(!(e instanceof RegExp))throw new TypeError("regex must be a RegExp.");if("function"!=typeof t)throw new TypeError("replacer must be a function.");const r=this.#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:i}=this.getSelectionRange(),n=this.#G.value,s=n.slice(r,i).replace(e,t),o=n.slice(0,r)+s+n.slice(i);return this.setValue(o),this.setSelectionRange(r,r+s.length),this}toggleCode(e){if("string"!=typeof e)throw new TypeError("codeName must be a string.");const t=this.getSelectedText();if(t.startsWith(e)&&t.endsWith(e)){const r=t.slice(e.length,t.length-e.length);this.insertText(r)}else this.insertText(`${e}${t}${e}`);return this}_insertAttr(e){let t="";if(Array.isArray(e)){if(!e.every(e=>"string"==typeof e))throw new TypeError("All entries in attributes array must be strings.");t=e.map(e=>`${e}`).join(" ")}else{if("object"!=typeof e||null===e)throw new TypeError("attributes must be an object or an array of strings.");t=Object.entries(e).map(([e,t])=>{if("string"!=typeof t)throw new TypeError("All entries in attributes object must be strings.");return`${e}${t.length>0?`="${t}"`:""}`}).join(" ")}return t}wrapWithTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this._insertAttr(t),i=r?`${this.#er}${e} ${r}${this.#tr}`:`${this.#er}${e}${this.#tr}`,n=`${this.#er}/${e}${this.#tr}`;return this.surroundSelection(i,n),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 i=this._insertAttr(r),n=i?`${this.#er}${e} ${i}${this.#tr}`:`${this.#er}${e}${this.#tr}`,s=`${this.#er}/${e}${this.#tr}`;return this.insertText(`${n}${t}${s}`),this}insertSelfClosingTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this._insertAttr(t),i=r?`${this.#er}${e} ${r}${this.#tr}`:`${this.#er}${e}${this.#tr}`;return this.insertText(i),this}toggleTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this.getSelectedText(),i=new RegExp(`^\\[${e}(\\s+[^\\]]*)?\\]`),n=new RegExp(`\\[/${e}\\]$`),s=i.test(r),o=n.test(r);if(s&&o){const e=r.replace(i,"").replace(n,"");this.insertText(e)}else{const i=this._insertAttr(t),n=i?`${this.#er}${e} ${i}${this.#tr}`:`${this.#er}${e}${this.#tr}`,s=`${this.#er}/${e}${this.#tr}`;this.insertText(`${n}${r}${s}`)}return this}},sr=class{#rr=!1;#ir=!1;#nr=null;#sr=null;constructor(){void 0!==navigator.clipboard&&null!==navigator.clipboard&&(this.#ir=!0,this.#nr=e=>navigator.clipboard.writeText(e),this.#sr=e=>navigator.clipboard.write([new ClipboardItem({[e.type]:e})])),this.#rr=void 0!==document.execCommand&&null!==document.execCommand}setCopyText(e){if("function"!=typeof e)throw new TypeError("setCopyText expected a function that returns Promise<void>.");this.#nr=e}setCopyBlob(e){if("function"!=typeof e)throw new TypeError("setCopyBlob expected a function that returns Promise<void>.");this.#sr=e}copyText(e){if("string"!=typeof e)throw new TypeError("copyText expected a string.");if(this.#nr)return this.#nr(e);if(this.#rr){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.#sr)return this.#sr(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,i=!1){return new Promise((n,s)=>{this._read(e).then(o=>{if(!o)return n(null);const a=[];let l=!0;const u=async(e,n)=>{if(l)if(null!==t&&"custom"!==t||"string"!=typeof r||!(!i&&e.startsWith(r)||i&&e===r))if(null!==t&&"text"!==t||"text/plain"!==e){if(null===t){l=!1;const t=await this._handleBlob(e,n);t&&a.push(t)}}else{l=!1;const t=await this._handleText(e,n);t&&a.push(t)}else{l=!1;const t=await this._handleBlob(e,n);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(o),Promise.all(h).then(()=>{a[0]?n(a[0]):n(null)}).catch(s);else if(Array.isArray(o)){for(const e in o)c(o[e]);Promise.all(h).then(()=>n(a)).catch(s)}}).catch(s)})}async readText(e=0){const t=await this._readData(e,"text");if("string"!=typeof t)throw new Error("Failed to read text: expected string result.");return t}async readCustom(e=null,t=!1,r=0){const i=await this._readData(r,"custom",e,t);if(!(i instanceof Blob))throw new Error("Failed to read custom data: expected Blob.");return i}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.#ir||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.#rr}isNavigatorClipboardAvailable(){return this.#ir}getCopyTextFunc(){return this.#nr}getCopyBlobFunc(){return this.#sr}};class or{static _rca(e,t,r){let i=127,n=128;void 0===e&&(e=24),void 0===t&&(t="rgb"),!0===r&&(i=55,n=200);const s=2*Math.PI/e,o=[];for(let r=0;r<e;++r){const e=Math.sin(s*r+2)*i+n,a=Math.sin(s*r+0)*i+n,l=Math.sin(s*r+4)*i+n;switch(t){case"hex":o.push({hex:this.rgbToHex(Math.round(e),Math.round(a),Math.round(l))});break;case"rgb":o.push({r:e,g:a,b:l});break;case"hsl":const[t,r,i]=this.rgbaToHsl(Math.round(e),Math.round(a),Math.round(l));o.push({h:t,s:r,l:i})}}return o}static rcaRgb(e,t){return or._rca(e,"rgb",t)}static rcaHsl(e,t){return or._rca(e,"hsl",t)}static rcaHex(e,t){return or._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,i,n]=e;if(t<=360&&r<=100&&i<=100)return this.hslToRgba(t,r,i,n)}return[...e,1].slice(0,4)}throw new Error("Unsupported color format.")}static hslToInt(e,t,r){const[i,n,s]=or.hslToRgba(e,t,r);return or.rgbToInt(i,n,s)}static hslToHex(e,t,r){const[i,n,s]=or.hslToRgba(e,t,r);return or.rgbToHex(i,n,s)}static hslStringToRgbaArray(e){const t=e.match(/[\d.]+/g)?.map(Number);if(!t||t.length<3)return[0,0,0,1];const[r,i,n,s=1]=t;return this.hslToRgba(r,i,n,s)}static hslToRgba(e,t,r,i=1){r/=100;const n=t=>(t+e/30)%12,s=(t/=100)*Math.min(r,1-r),o=e=>r-s*Math.max(-1,Math.min(n(e)-3,Math.min(9-n(e),1)));return[Math.round(255*o(0)),Math.round(255*o(8)),Math.round(255*o(4)),i]}static hslToRgb(e,t,r,i=1){return or.hslToRgba(e,t,r,i).slice(0,3)}static hexToInt(e){return parseInt(e.replace(/^#/,""),16)}static hexToHsl(e){const[t,r,i,n]=or.hexToRgba(e);return or.rgbaToHsl(t,r,i,n)}static hexToHsla(e){const[t,r,i,n]=or.hexToRgba(e);return or.rgbaToHsla(t,r,i,n)}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,i=1){e/=255,t/=255,r/=255;const n=Math.max(e,t,r),s=Math.min(e,t,r);let o=0,a=0,l=(n+s)/2;const u=n-s;if(0!==u){switch(a=u/(1-Math.abs(2*l-1)),n){case e:o=(t-r)/u+(t<r?6:0);break;case t:o=(r-e)/u+2;break;case r:o=(e-t)/u+4}o*=60}return[Math.round(o),Math.round(100*a),Math.round(100*l),i]}static rgbaToHsl(e,t,r,i){return this.rgbaToHsla(e,t,r,i).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,i,n]=or.intToRgba(e);return or.rgbaToHsl(t,r,i,n)}static intToHsla(e){const[t,r,i,n]=or.intToRgba(e);return or.rgbaToHsla(t,r,i,n)}static intToHex(e){return"#"+e.toString(16).padStart(6,"0")}static intToRgba(e){return[e>>16&255,e>>8&255,255&e,1]}#or="#000000";#ar=[0,0,0,0];#lr;constructor(e=null,t=!1){this.#lr=t,null!=e&&this.setColor(e)}setColor(e){this.#or=e;const t=this.#lr&&Array.isArray(e)&&e[0]<=360&&e[1]<=100&&e[2]<=100;this.#ar=or.parseInput(e,t)}toHslaArray(){const[e,t,r,i]=this.#ar;return or.rgbaToHsla(e,t,r,i)}toHslString(){const[e,t,r]=this.#ar,[i,n,s]=or.rgbaToHsl(e,t,r);return`hsl(${i}, ${n}%, ${s}%)`}toHslaString(){const[e,t,r,i]=this.#ar,[n,s,o,a]=or.rgbaToHsla(e,t,r,i);return`hsla(${n}, ${s}%, ${o}%, ${a??1})`}toRgbaArray(){return[...this.#ar]}toRgbString(){const[e,t,r]=this.#ar;return`rgb(${e}, ${t}, ${r})`}toRgbaString(){const[e,t,r,i]=this.#ar;return`rgba(${e}, ${t}, ${r}, ${i??1})`}toHex(){const[e,t,r]=this.#ar;return or.rgbToHex(e,t,r)}toInt(){const[e,t,r]=this.#ar;return or.rgbToInt(e,t,r)}getOriginal(){return this.#or}}const ar=or,lr=Y("TinyTimeout");class ur{#ur=!1;#hr;#cr;#dr=null;#mr=new Map;constructor({cooldownWatcherTime:e=5e3,allowAutoConfigChange:t=!1}={}){if(!Number.isFinite(e)||e<=0)throw new TypeError("Expected 'cooldownWatcherTime' to be a positive number.");if("boolean"!=typeof t)throw new TypeError("Expected 'allowAutoConfigChange' to be a boolean.");this.#cr=e,this.#hr=t,this.setCooldownWatcherTime(e)}isDestroyed(){return this.#ur}getAllowAutoConfigChange(){return lr(this.#ur),this.#hr}getCooldownWatcherTime(){return lr(this.#ur),this.#cr}setAllowAutoConfigChange(e){if(lr(this.#ur),"boolean"!=typeof e)throw new TypeError("Expected 'value' to be a boolean.");this.#hr=e}setCooldownWatcherTime(e){if(lr(this.#ur),this.#ur)throw new Error("TinyTimeout has been destroyed.");if(!Number.isFinite(e)||e<=0)throw new TypeError("Expected 'value' to be a positive number.");this.#cr=e,this.#dr&&clearInterval(this.#dr),this.#dr=setInterval(()=>{this.#mr.forEach(e=>{e.now>0&&e.now--})},this.#cr)}set(e,t,r,i=null){if(lr(this.#ur),this.#ur)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!==i&&(!Number.isFinite(i)||i<0))throw new TypeError("Expected 'limit' to be null or a non-negative number.");let n=this.#mr.get(e);(!n||this.#hr&&r!==n.value)&&(n={value:r,now:0},this.#mr.set(e,n));const s=n.value*n.now;return n.now++,setTimeout(t,"number"==typeof i?Math.min(s,i):s)}static waitForTrue(e,t=100){if("function"!=typeof e)throw new TypeError("Expected 'getValue' to be a function.");if(!Number.isFinite(t)||t<=0)throw new TypeError("Expected 'checkInterval' to be a positive number.");return new Promise(r=>{const i=setInterval(()=>{e()&&(clearInterval(i),r())},t)})}waitForTrue(e,t=100){if(lr(this.#ur),this.#ur)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 ur.waitForTrue(e,t??this.#cr)}destroy(){this.#ur||(this.#dr&&clearInterval(this.#dr),this.#dr=null,this.#mr.clear(),this.#ur=!0)}}const hr=ur,cr=Y("TinyLocalStorage"),dr=new Map,mr=new Map,pr=new Set(["string","boolean","object","array",String,Boolean,Number,Object,Array,BigInt,Symbol]);class fr extends er.EventEmitter{static hasJsonType(e){return dr.has(e)&&mr.has(e)||pr.has(e)}static registerJsonType(e,t,r,i=!1){if(pr.has(e))throw new Error(`Cannot register type "${e}" because it is frozen.`);dr.set(e,t),mr.set(e,r),i&&pr.add(e)}static deleteJsonType(e){if(pr.has(e))throw new Error(`Cannot remove type "${e}" because it is frozen.`);let t=!1;return dr.delete(e)&&(t=!0),mr.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 dr.entries())if("string"!=typeof t&&e instanceof t||typeof e===t)return r(e,fr.encodeSpecialJson);if(Array.isArray(e))return e.map(fr.encodeSpecialJson);if(f(e)){const t={};for(const r in e)t[r]=fr.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(fr.decodeSpecialJson);if(t){for(const[t,r]of mr.entries())if(r.check&&r.check(e))return r.decode(e,fr.decodeSpecialJson);const t={};for(const r in e)t[r]=fr.decodeSpecialJson(e[r]);return t}return e}#h=!1;get destroyed(){return this.#h}#pr=window.localStorage;#fr=null;#ee=0;#yr=e=>this.emit("storage",e);constructor(e){if(super(),void 0!==e&&"string"!=typeof e)throw new TypeError("TinyLocalStorage: dbName must be a string if provided.");"string"==typeof e&&(this.#fr=`LSDB::${e}`),window.addEventListener("storage",this.#yr)}#gr(e){if("string"==typeof e&&e.startsWith("LSDB::"))throw new Error(`TinyLocalStorage: Key "${e}" may conflict with reserved dbKeys.`)}updateStorageVersion(e,t){if(cr(this.#h),"string"!=typeof this.#fr)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.#fr),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.#fr,String(e)),this.#ee=e)}getDbKey(){return cr(this.#h),this.#fr}getVersion(){return cr(this.#h),this.#ee}setLocalStorage(e){if(cr(this.#h),!(e instanceof Storage))throw new TypeError("Argument must be a valid instance of Storage.");this.#pr=e}localStorageExists(){return cr(this.#h),this.#pr instanceof Storage}#wr(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return fr.encodeSpecialJson(t)}setJson(e,t){if(cr(this.#h),this.#gr(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.#wr(e,t);return this.emit("setJson",e,t),this.#pr.setItem(e,JSON.stringify(r))}#br(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const r=this.#pr.getItem(e),i={obj:()=>({}),array:()=>[],map:()=>new Map,set:()=>new Set},n="function"==typeof i[t]?i[t]():null;let s;try{s=JSON.parse(r)}catch{return n}return{decoded:fr.decodeSpecialJson(s),fallback:n}}getJson(e,t){cr(this.#h);const{decoded:r,fallback:i}=this.#br(e,t);return r instanceof Map||r instanceof Set||Array.isArray(r)||f(r)?r:i}setDate(e,t){if(cr(this.#h),this.#gr(e),!(t instanceof Date))throw new TypeError("Value must be a Date.");const r=this.#wr(e,t);return this.emit("setDate",e,t),this.#pr.setItem(e,JSON.stringify(r))}getDate(e){cr(this.#h);const t=this.#br(e).decoded;return t instanceof Date?t:null}setRegExp(e,t){if(cr(this.#h),this.#gr(e),!(t instanceof RegExp))throw new TypeError("Value must be a RegExp.");const r=this.#wr(e,t);return this.emit("setRegExp",e,t),this.#pr.setItem(e,JSON.stringify(r))}getRegExp(e){cr(this.#h);const t=this.#br(e).decoded;return t instanceof RegExp?t:null}setBigInt(e,t){if(cr(this.#h),this.#gr(e),"bigint"!=typeof t)throw new TypeError("Value must be a BigInt.");const r=this.#wr(e,t);return this.emit("setBigInt",e,t),this.#pr.setItem(e,JSON.stringify(r))}getBigInt(e){cr(this.#h);const t=this.#br(e).decoded;return"bigint"==typeof t?t:null}setSymbol(e,t){if(cr(this.#h),this.#gr(e),"symbol"!=typeof t)throw new TypeError("Value must be a Symbol.");const r=this.#wr(e,t);return this.emit("setSymbol",e,t),this.#pr.setItem(e,JSON.stringify(r))}getSymbol(e){cr(this.#h);const t=this.#br(e).decoded;return"symbol"==typeof t?t:null}getValue(e){return cr(this.#h),this.#br(e).decoded??null}setItem(e,t){if(cr(this.#h),this.#gr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("setItem",e,t),this.#pr.setItem(e,t)}getItem(e){if(cr(this.#h),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.#pr.getItem(e)}setString(e,t){if(cr(this.#h),this.#gr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("string"!=typeof t)throw new TypeError("Value must be a string.");return this.emit("setString",e,t),this.#pr.setItem(e,JSON.stringify({__string__:!0,value:t}))}getString(e){if(cr(this.#h),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#pr.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(cr(this.#h),this.#gr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("number"!=typeof t)throw new TypeError("Value must be a number.");return this.emit("setNumber",e,t),this.#pr.setItem(e,String(t))}getNumber(e){if(cr(this.#h),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#pr.getItem(e);return"number"==typeof t||"string"==typeof t&&t.length>0&&(t=parseFloat(t),!Number.isNaN(t))?t:null}setBool(e,t){if(cr(this.#h),this.#gr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("boolean"!=typeof t)throw new TypeError("Value must be a boolean.");return this.emit("setBool",e,t),this.#pr.setItem(e,String(t))}getBool(e){if(cr(this.#h),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const t=this.#pr.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(cr(this.#h),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("removeItem",e),this.#pr.removeItem(e)}clearLocalStorage(){return cr(this.#h),this.#pr.clear()}destroy(){this.#h||(window.removeEventListener("storage",this.#yr),this.removeAllListeners(),this.#h=!0)}}fr.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),fr.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),fr.registerJsonType(Date,e=>({__date__:!0,value:e.toISOString()}),{check:e=>e.__date__,decode:e=>new Date(e.value)},!0),fr.registerJsonType(RegExp,e=>({__regexp__:!0,source:e.source,flags:e.flags}),{check:e=>e.__regexp__,decode:e=>new RegExp(e.source,e.flags)},!0),fr.registerJsonType("number",e=>({__number__:!0,value:e.toString()}),{check:e=>e.__number__,decode:e=>Number(e.value)},!0),fr.registerJsonType("bigint",e=>({__bigint__:!0,value:e.toString()}),{check:e=>e.__bigint__,decode:e=>BigInt(e.value)},!0),fr.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 yr=fr,gr=Y("TinyIframeEvents"),wr=new WeakMap;class br extends er.EventEmitter{#vr;get targetWindow(){return gr(this.#ur),this.#vr}#Er;get targetIframeElement(){return gr(this.#ur),this.#Er}#Tr;get targetOrigin(){return gr(this.#ur),this.#Tr}#Sr;get selfType(){return gr(this.#ur),this.#Sr}#ur=!1;#xr=!1;get ready(){return gr(this.#ur),this.#xr}onReady(e){gr(this.#ur),this.#xr?e():this.once(this.#Ar,e)}#Cr=null;#Ir=[];#Dr;#Mr;#Ar;#Nr=null;constructor({targetIframe:e,targetOrigin:t=window.location.origin,secretEventName:r="__tinyIframeEvent__",handshakeEventName:i="__tinyIframeHandshake__",readyEventName:n="__tinyIframeReady__"}={}){if(super(),!(void 0===e||e instanceof HTMLIFrameElement&&e.contentWindow))throw new TypeError('[TinyIframeEvents] Invalid "targetIframe": expected HTMLIFrameElement, received '+typeof e);if("string"!=typeof t)throw new TypeError('[TinyIframeEvents] Invalid "targetOrigin": expected string, received '+typeof t);if(this.#Er=e,this.#vr=e?.contentWindow??window.parent,this.#Tr=t,this.#Sr=e?"parent":"iframe",this.#Dr=r,this.#Mr=i,this.#Ar=n,wr.has(this.#vr))throw new Error("Duplicate window reference.");this._boundWindowMessage=this.#kr.bind(this),this._boundPortMessage=this.#Lr.bind(this),this.#_r(),wr.set(this.#vr,this)}get secretEventName(){return gr(this.#ur),this.#Dr}set secretEventName(e){if(gr(this.#ur),"string"!=typeof e)throw new TypeError("TinyIframeEvents: secretEventName must be a string.");this.#Dr=e}get handshakeEventName(){return gr(this.#ur),this.#Mr}set handshakeEventName(e){if(gr(this.#ur),"string"!=typeof e)throw new TypeError("TinyIframeEvents: handshakeEventName must be a string.");this.#Mr=e}get readyEventName(){return gr(this.#ur),this.#Ar}set readyEventName(e){if(gr(this.#ur),"string"!=typeof e)throw new TypeError("TinyIframeEvents: readyEventName must be a string.");this.#Ar=e}#_r(){"parent"===this.#Sr?(this.#Nr=()=>{if(this.#ur)return;this.#Cr&&this.#Cr.close();const e=new MessageChannel;this.#Cr=e.port1,this.#Cr.onmessage=this._boundPortMessage,this.#xr=!1,this.#vr.postMessage({type:this.#Mr},this.#Tr,[e.port2])},this.#Er&&(this.#Er.addEventListener("load",this.#Nr),this.#Nr())):window.addEventListener("message",this._boundWindowMessage,!1)}#kr(e){const t=e.data,r=e.ports;f(t)&&t.type===this.#Mr&&0!==r.length&&(this.#Cr=r[0],this.#Cr.onmessage=this._boundPortMessage,window.removeEventListener("message",this._boundWindowMessage),this.#Cr.postMessage({type:`${this.#Mr}_ACK`}),this.#jr())}#Lr(e){const t=e.data;if(f(t)&&t.type===`${this.#Mr}_ACK`)return void this.#jr();if(!f(t)||!t[this.#Dr])return;const r=t.eventName,i=t.payload,n=t.direction;"string"!=typeof r||"iframe"===this.#Sr&&"iframe"!==n||"parent"===this.#Sr&&"parent"!==n||this.emit(`win:${r}`,i,e)}#jr(){this.#xr||(this.#xr=!0,this.#Rr(),this.emit(this.#Ar))}#Rr(){for(;this.#Ir.length>0;){const e=this.#Ir.shift();e&&this.#Cr&&this.#Cr.postMessage(e)}}winEmit(e,t){if(gr(this.#ur),"string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.#ur)throw new Error("Cannot emit: instance has been destroyed.");const r={[this.#Dr]:!0,eventName:e,payload:t,direction:"parent"===this.#Sr?"iframe":"parent"};this.#xr&&this.#Cr?this.#Cr.postMessage(r):this.#Ir.push(r)}isDestroyed(){return this.#ur}destroy(){this.#ur||(this.#xr=!1,window.removeEventListener("message",this._boundWindowMessage),this.#Er&&this.#Nr&&this.#Er.removeEventListener("load",this.#Nr),this.#Cr&&(this.#Cr.close(),this.#Cr=null),this.removeAllListeners(),this.#Ir=[],wr.delete(this.#vr),this.#ur=!0)}}const vr=br,Er=Y("TinyNewWinEvents"),Tr=new WeakMap;class Sr extends er.EventEmitter{#Pr;#Tr;#Ir=[];#xr=!1;#$r=!1;#Hr=null;#Ar="__TNE_READY__";#Or="__TNE_ROUTE__";#h=!1;get destroyed(){return this.#h}get readyEventName(){return Er(this.#h),this.#Ar}set readyEventName(e){if(Er(this.#h),"string"!=typeof e)throw new TypeError("TinyNewWinEvents: readyEventName must be a string.");this.#Ar=e}get routeEventName(){return Er(this.#h),this.#Or}set routeEventName(e){if(Er(this.#h),"string"!=typeof e)throw new TypeError("TinyNewWinEvents: routeEventName must be a string.");this.#Or=e}constructor({targetOrigin:e,url:t,name:r,features:i}={}){if(super(),"string"==typeof r&&"_blank"===r)throw new Error('TinyNewWinEvents: The window name "_blank" is not supported. Please use a custom name to allow tracking.');if(void 0!==e&&"string"!=typeof e)throw new TypeError('TinyNewWinEvents: The "targetOrigin" option must be a string.');if(void 0!==t&&"string"!=typeof t)throw new TypeError('TinyNewWinEvents: The "url" option must be a string.');if(void 0!==i&&"string"!=typeof i)throw new TypeError('TinyNewWinEvents: The "features" option must be a string if provided.');if(void 0===t?this.#Pr=window.opener:(this.#Pr="string"==typeof t?window.open(t,r,i):t,this.#$r=!0),!this.#Pr||Tr.has(this.#Pr))throw new Error("Invalid or duplicate window reference.");this.#Tr=e??window.location.origin,this._handleMessage=this.#Fr.bind(this),window.addEventListener("message",this._handleMessage,!1),this.#$r||(this.#Br(this.#Ar,null),this.#zr())}getWin(){return Er(this.#h),this.#Pr}#Fr(e){if(!e.source||this.#Pr&&e.source!==this.#Pr)return;const{type:t,route:r,payload:i}=e.data||{};if(t===this.#Ar)return this.#xr=!0,this.#Rr(),this.#zr(),void(this.#$r&&this.#Br(this.#Ar,null));t===this.#Or&&this.emit(`win:${r}`,i,e)}#Rr(){for(;this.#Ir.length;){const e=this.#Ir.shift();if(e){const{route:t,payload:r}=e;this.winEmit(t,r)}}}#Br(e,t,r=""){this.#Pr&&this.#Pr.closed||this.#Pr?.postMessage({type:e,route:r,payload:t},this.#Tr)}close(){if(Er(this.#h),!this.#$r)throw new Error("Only host can close the window.");this.#Pr&&!this.#Pr.closed&&this.#Pr.close()}winEmit(e,t){if(Er(this.#h),"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.#xr?this.#Br(this.#Or,t,e):this.#Ir.push({route:e,payload:t})}isConnected(){return Er(this.#h),!(!this.#xr||!this.#Pr||this.#Pr.closed)}#zr(){this.#Pr&&!this.#Hr&&(this.#Hr=setInterval(()=>{this.#Pr?.closed&&(this.emit("WINDOW_REF_CLOSED"),this.destroy())},500),Tr.set(this.#Pr,this.#Hr))}onClose(e){Er(this.#h),this.on("WINDOW_REF_CLOSED",e)}offClose(e){Er(this.#h),this.off("WINDOW_REF_CLOSED",e)}isDestroyed(){return!this.#Pr}destroy(){this.#Pr&&(this.#Hr&&(clearInterval(this.#Hr),this.#Hr=null,Tr.delete(this.#Pr)),window.removeEventListener("message",this._handleMessage),this.#Ir=[],this.#xr=!1,this.#Pr=null,this.removeAllListeners(),this.#h=!0)}}const xr=Sr,Ar=class{#h=!1;get destroyed(){return this.#h}#Wr;#qr;#Vr;#Kr=0;#Jr=0;#Ur;#Gr=null;#Yr=null;get lineHeight(){return this.#Wr}get maxRows(){return this.#qr-1}get extraHeight(){return this.#Vr}get currentHeight(){return this.#Kr}get currentRows(){return this.#Jr}get textarea(){return this.#Ur}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.#Ur=e,this.#qr=(t.maxRows??5)+1,this.#Vr=t.extraHeight??0,this.#Gr=t.onResize??null,this.#Yr=t.onInput??null,this.#Wr=this.#Xr(),e.style.overflowY="hidden",e.style.resize="none",this._handleInput=()=>this.#Qr(),e.addEventListener("input",this._handleInput),this.#Qr()}#Qr(){this.#Ur.style.height="auto";const e=window.getComputedStyle(this.#Ur),t=parseFloat(e.paddingTop)||0,r=parseFloat(e.paddingBottom)||0,i=(this.#Ur.value.match(/\n/g)||[]).length,n=this.#Ur.scrollHeight,s=this.#Wr*this.#qr,o=Math.ceil(Math.min(n,s)-t-r+this.#Vr),a=this.#qr-1,l=i<a?i+1:a;this.#Ur.style.height=`${o}px`,this.#Ur.style.overflowY=n>s?"auto":"hidden",this.#Kr=o;const u={breakLines:i,rows:l,height:o,scrollHeight:n,maxHeight:s,lineHeight:this.#Wr,maxRows:a};l!==this.#Jr&&(this.#Jr=l,"function"==typeof this.#Gr&&this.#Gr({...u})),"function"==typeof this.#Yr&&this.#Yr(u)}#Xr(){const e=window.getComputedStyle(this.#Ur),t=parseFloat(e.lineHeight);return Number.isNaN(t)?1.2*parseFloat(e.fontSize):t}getData(){return{rows:this.#Jr,height:this.#Kr}}refresh(){this.#Qr()}destroy(){this.destroyed||(this.#Ur.removeEventListener("input",this._handleInput),this.#h=!0)}},Cr=Y("TinyGamepad");class Ir{#ur=!1;#Zr=new Set;#ei=new Map;#ti=new Map;#ri=null;#ii=[];#ni={};#si=[];#oi=null;#ai=null;#li;#ui;#hi;#ci;#di;#mi;#pi;#fi;#yi=[];#gi=0;#wi=0;#bi=[];#vi=0;#Ei=null;#Ti=new Set;#Si=new Set;#xi=new Map;#Ai=new Map;#Ci=new Map;static#Ii={" ":"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);Ir.#Ii[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 Ir.#Ii[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 Ir.#Ii[e]}static getAllSpecialKeys(){return{...Ir.#Ii}}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=Ir.#Ii[e];if(void 0!==r)return r;throw new Error(`Unsupported character: "${e}"`)})}constructor({expectedId:e=null,inputMode:t="both",ignoreIds:r=[],deadZone:i=.1,axisActiveSensitivity:n=.3,timeoutComboKeys:s=500,allowMouse:o=!1,elementBase:a=window}={}){if(null!==e&&"string"!=typeof e)throw new TypeError('"expectedId" must be a string or null, received: '+typeof e);if(!["keyboard-only","gamepad-only","both"].includes(t))throw new TypeError(`"inputMode" must be 'keyboard-only', 'gamepad-only', or 'both', received: ${t}`);if(!Array.isArray(r)||!r.every(e=>"string"==typeof e))throw new TypeError('"ignoreIds" must be an array of strings');if("number"!=typeof i||i<0||i>1)throw new RangeError(`"deadZone" must be a number between 0 and 1, received: ${i}`);if("number"!=typeof n||n<0||n>1)throw new RangeError(`"axisActiveSensitivity" must be a number between 0 and 1, received: ${n}`);if("number"!=typeof s||s<0)throw new RangeError(`"timeoutComboKeys" must be a positive number, received: ${s}`);if("boolean"!=typeof o)throw new TypeError('"allowMouse" must be a boolean, received: '+typeof o);if(!(a instanceof Window||a instanceof Element))throw new TypeError('"elementBase" must be a Window or Element instance');this.#ci=e,this.#li=t,this.#ui=new Set(r),this.#hi=i,this.#di=o,this.#mi=a,this.#pi=s,this.#fi=n,["gamepad-only","both"].includes(this.#li)&&this.#Di(),["keyboard-only","both"].includes(this.#li)&&this.#Mi()}#Ni=e=>this.#ki(e.gamepad);#Li=e=>this.#_i(e.gamepad);#Di(){window.addEventListener("gamepadconnected",this.#Ni),window.addEventListener("gamepaddisconnected",this.#Li)}#ki(e){this.#ur||this.#ui.has(e.id)||this.#ci&&e.id!==this.#ci||this.#ri||(this.#ri=e,this.#ci=e.id,this.#ji(),this.#Ri("connected",{id:e.id,gp:e,timestamp:e.timestamp}))}#_i(e){this.#ur||this.#ri&&e.id===this.#ri.id&&(this.#ri=null,this.#oi&&(cancelAnimationFrame(this.#oi),this.#oi=null),this.#Ri("disconnected",{id:e.id,gp:e,timestamp:e.timestamp}))}#ji(){const e=()=>{this.#ur||(this.#Pi(),this.#oi=requestAnimationFrame(e))};e()}#Pi(){if(this.#ur)return;const e=navigator.getGamepads(),t=Array.from(e).find(e=>e&&e.id===this.#ci);t&&(this.#ri=t,t.buttons.forEach((e,r)=>{const i=`Button${r}`,n=this.#ii[r]?.pressed||!1;let s,o,a=!1;e.pressed&&!n?(o=1,s="down"):!e.pressed&&n?(o=0,s="up"):e.pressed&&n&&(o=1,s="hold"),e.pressed&&e.value>0&&e.value<1&&1!==e.value&&(o=e.value,a=!0),"number"==typeof o&&"string"==typeof s&&this.#$i({key:i,source:"gamepad-button",value:o,value2:NaN,type:s,gp:t,isPressure:a,pressed:e.pressed,prevPressed:n,timestamp:t.timestamp,id:t.id}),this.#ii[r]={pressed:e.pressed,value:"number"==typeof o?o:this.#ii[r]?.value,value2:NaN}}),t.axes.forEach((e,r)=>{Math.abs(e)<this.#hi&&(e=0);const i=`Axis${r}`;e!==(this.#si[r]??0)&&this.#$i({key:i,source:"gamepad-analog",value:e,value2:NaN,type:"change",timestamp:t.timestamp,id:t.id,gp:t}),this.#si[r]=e}))}#Hi=e=>{if(!this.#ur){if(!(e instanceof KeyboardEvent))throw new Error("Expected KeyboardEvent in keydown listener.");this.#Zr.has(e.code)||(this.#Zr.add(e.code),this.#$i({event:e,key:e.code,source:"keyboard",value:1,value2:NaN,type:"down",pressed:!0,prevPressed:this.#ni[e.code]?.pressed??!1,id:"native_keyboard",timestamp:e.timeStamp}),this.#ni[e.code]={pressed:!0})}};#Oi=e=>{if(!this.#ur){if(!(e instanceof KeyboardEvent))throw new Error("Expected KeyboardEvent in keyup listener.");this.#Zr.has(e.code)&&(this.#Zr.delete(e.code),this.#$i({event:e,key:e.code,source:"keyboard",value:0,value2:NaN,type:"up",pressed:!1,prevPressed:this.#ni[e.code]?.pressed??!1,id:"native_keyboard",timestamp:e.timeStamp}),this.#ni[e.code]={pressed:!1})}};#Fi=e=>{if(this.#ur)return;if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mousedown listener.");const t=`Mouse${e.button}`;this.#Zr.add(t),this.#$i({event:e,key:t,source:"mouse",value:1,value2:NaN,type:"down",pressed:!0,prevPressed:this.#ni[t]?.pressed??!1,id:"native_mouse",timestamp:e.timeStamp}),this.#ni[t]={pressed:!0}};#Bi=e=>{if(this.#ur)return;if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mouseup listener.");const t=`Mouse${e.button}`;this.#Zr.delete(t),this.#$i({event:e,key:t,source:"mouse",value:0,value2:NaN,type:"up",pressed:!1,prevPressed:this.#ni[t]?.pressed??!1,id:"native_mouse",timestamp:e.timeStamp}),this.#ni[t]={pressed:!1}};#zi=e=>{if(!this.#ur){if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mousemove listener.");if(0!==e.movementX||0!==e.movementY){const t="MouseMove",r=this.#ni[t]??{pressed:!1,value:0,value2:0};this.#$i({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.#ni[t]={pressed:!1,value:e.movementX,value2:e.movementY}}}};#Mi(){this.#mi.addEventListener("keydown",this.#Hi),this.#mi.addEventListener("keyup",this.#Oi),this.#di&&(this.#mi.addEventListener("mousedown",this.#Fi),this.#mi.addEventListener("mouseup",this.#Bi),this.#mi.addEventListener("mousemove",this.#zi));const e=()=>{this.#ur||(this.#Zr.forEach(e=>{const t=e.startsWith("Mouse")?"mouse":"keyboard";this.#$i({key:e,source:t,id:`native_${t}`,value:1,value2:NaN,type:"hold",pressed:!0,prevPressed:this.#ni[e]?.pressed??!1,timestamp:NaN})}),this.#ai=requestAnimationFrame(e))};e()}#$i(e){if(this.#ur)return;const t=this.#ti.get("input-*")||[],{pressed:r,key:i}=e,n=i.startsWith("Axis"),s="boolean"==typeof r&&r||n&&(e.value>this.#fi||e.value<-Math.abs(this.#fi)),o=n?`${i}${e.value>0?"+":e.value<0?"-":""}`:i;let a=null;if("move"!==e.type&&"hold"!==e.type){if(s){if(!n&&!this.#Ti.has(i)||n&&!this.#Ti.has(i)&&!this.#Ti.has(`${i}+`)&&!this.#Ti.has(`${i}-`)){0===this.#vi&&(this.#vi=Date.now()),this.#Ti.add(o),a=!0,this.#bi.push(o),this.#yi.length<1&&(this.#Ei&&clearTimeout(this.#Ei),this.#Ei=setTimeout(()=>this.resetComboMapped(),this.#pi));const e=this.#ti.get("mapped-key-start")??[];for(const t of e)t({key:o,activeTime:this.#vi})}}else if(!n&&this.#Ti.has(i)||n&&(this.#Ti.has(i)||this.#Ti.has(`${i}+`)||this.#Ti.has(`${i}-`))){this.#Ti.delete(i),this.#Ti.delete(`${i}+`),this.#Ti.delete(`${i}-`),a=!1;const e=this.#ti.get("mapped-key-end")??[];for(const t of e)t({key:o,activeTime:this.#vi})}for(const{sequence:e,callback:t,triggered:r}of this.#Ai.values()){const i=this.#Ai.get(e.join("+"));if(!i)continue;const n=e.every((e,t)=>this.#bi[t]===e);n&&!r?(i.triggered=!0,t(this.#vi)):!n&&r&&(i.triggered=!1)}}for(const[r,l]of this.#ei.entries()){const u=e=>"string"==typeof l&&e===l||Array.isArray(l)&&l.findIndex((t,r)=>e===l[r])>-1,h=u(o),c=n&&u(`${i}+`),d=n&&u(`${i}-`);if(h||c||d){if(s&&h){if(a||!this.#Si.has(r)){0===this.#wi&&(this.#wi=Date.now()),this.#Si.add(r),0===this.#gi&&(this.#gi=Date.now()),this.#Ei&&clearTimeout(this.#Ei),this.#yi.push(r),this.#Ei=setTimeout(()=>this.resetComboMapped(),this.#pi);const e=this.#ti.get("mapped-input-start")??[];for(const t of e)t({logicalName:r,activeTime:this.#wi,comboTime:this.#gi})}}else if(!a||this.#Si.has(r)){this.#Si.delete(r),this.#Si.size<1&&(this.#wi=0);const e=this.#ti.get("mapped-input-end")??[];for(const t of e)t({logicalName:r,activeTime:this.#wi,comboTime:this.#gi})}for(const{sequence:e,callback:t,triggered:r}of this.#xi.values()){const i=this.#xi.get(e.join("+"));if(!i)continue;const n=Array.from(this.#Si),s=e.every((e,t)=>n[t]===e);s&&!r?(i.triggered=!0,t(this.#wi)):!s&&r&&(i.triggered=!1)}}const m=[];if(n&&0===e.value){const{value:t}=this.#Ci.get(`${i}-`)??{value:0,value2:NaN},{value:r}=this.#Ci.get(`${i}+`)??{value:0,value2:NaN};e.value!==t&&m.push(`${i}-`),e.value!==r&&m.push(`${i}+`)}else m.push(o);m.forEach(i=>{if(!("*"===l||l===i||Array.isArray(l)&&l.includes(i)))return;const n=this.#ti.get(`input-${e.type}-${r}`)||[],s=this.#ti.get(`input-${r}`)||[];if(s.length<1&&n.length<1&&t.length<1)return;const o={...e,key:i,logicalName:r};for(const e of t)e(o);for(const e of s)e(o);for(const e of n)e(o);this.#Ci.set(i,{value:e.value,value2:e.value2})})}}#Ri(e,t){const r=this.#ti.get(e)||[];for(const e of r)e(t)}#Wi(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 i=r.replace("{logicalName}",e);let n=this.#ti.get(i);Array.isArray(n)||(n=[],this.#ti.set(i,n)),n.push(t)}#qi(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 i=n=>{this.#Vi(e,i,r),t(n)};this.#Wi(e,i,r)}#Ki(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 i=r.replace("{logicalName}",e),n=this.#ti.get(i)??[];n.unshift(t),this.#ti.set(i,n)}#Vi(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 i=r.replace("{logicalName}",e),n=this.#ti.get(i);Array.isArray(n)&&this.#ti.set(i,n.filter(e=>e!==t))}awaitInputMapping({timeout:e=1e4,eventName:t="MappingInput",canMove:r=!1}={}){return Cr(this.#ur),new Promise((i,n)=>{if("number"!=typeof e||Number.isNaN(e)||e<0)return n(new TypeError(`Invalid "timeout": expected a positive number, got ${e}`));if("string"!=typeof t||!t.trim())return n(new TypeError(`Invalid "eventName": expected a non-empty string, got ${t}`));if("boolean"!=typeof r)return n(new TypeError(`Invalid "canMove": expected a boolean, got ${r}`));const s={key:null,source:null},o=({key:e,type:n,source:l,gp:u,value:h})=>{(r||"move"!==n)&&(s.key=e,s.source=l,s.gp=u,clearTimeout(a),this.offInputStart(t,o),this.offInputChange(t,o),r&&this.offInputMove(t,o),i(s))},a=setTimeout(()=>i(s),e);this.mapInput(t,"*"),this.onInputStart(t,o),this.onInputChange(t,o),r&&this.onInputMove(t,o)})}mapInput(e,t){if(Cr(this.#ur),"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.#ei.set(e,t)}unmapInput(e){if(Cr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);this.#ei.delete(e)}hasMappedInput(e){if(Cr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);return this.#ei.has(e)}getMappedInput(e){if(Cr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);const t=this.#ei.get(e);if(!t)throw new Error(`No physical input mapped for logicalName: "${e}"`);return t}clearMapInputs(){Cr(this.#ur),this.#ei.clear()}registerInputSequence(e,t){if(Cr(this.#ur),!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.#xi.set(r,{sequence:e,callback:t,triggered:!1})}unregisterInputSequence(e){if(Cr(this.#ur),!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.#xi.delete(t)}unregisterAllInputSequences(){Cr(this.#ur),this.#xi.clear()}hasInputSequence(e){if(Cr(this.#ur),!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.#xi.has(t)}registerKeySequence(e,t){if(Cr(this.#ur),!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.#Ai.set(r,{sequence:e,callback:t,triggered:!1})}unregisterKeySequence(e){if(Cr(this.#ur),!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.#Ai.delete(t)}unregisterAllKeySequences(){Cr(this.#ur),this.#Ai.clear()}hasKeySequence(e){if(Cr(this.#ur),!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.#Ai.has(t)}renewComboMapped(){Cr(this.#ur),this.#Ei&&(clearTimeout(this.#Ei),this.#Ei=setTimeout(()=>this.resetComboMapped(),this.#pi))}resetComboMapped(){Cr(this.#ur),this.#Ei&&clearTimeout(this.#Ei),this.#bi=[],this.#Ei=null,this.#vi=0,this.#yi=[],this.#gi=0}onMappedKeyStart(e){return Cr(this.#ur),this.#Wi("",e,"mapped-key-start")}onceMappedKeyStart(e){return Cr(this.#ur),this.#qi("",e,"mapped-key-start")}prependMappedKeyStart(e){return Cr(this.#ur),this.#Ki("",e,"mapped-key-start")}offMappedKeyStart(e){return Cr(this.#ur),this.#Vi("",e,"mapped-key-start")}offAllMappedKeyStart(){Cr(this.#ur),this.#ti.delete("mapped-key-start")}onMappedKeyEnd(e){return Cr(this.#ur),this.#Wi("",e,"mapped-key-end")}onceMappedKeyEnd(e){return Cr(this.#ur),this.#qi("",e,"mapped-key-end")}prependMappedKeyEnd(e){return Cr(this.#ur),this.#Ki("",e,"mapped-key-end")}offMappedKeyEnd(e){return Cr(this.#ur),this.#Vi("",e,"mapped-key-end")}offAllMappedKeyEnd(){Cr(this.#ur),this.#ti.delete("mapped-key-end")}onMappedInputStart(e){return Cr(this.#ur),this.#Wi("",e,"mapped-input-start")}onceMappedInputStart(e){return Cr(this.#ur),this.#qi("",e,"mapped-input-start")}prependMappedInputStart(e){return Cr(this.#ur),this.#Ki("",e,"mapped-input-start")}offMappedInputStart(e){return Cr(this.#ur),this.#Vi("",e,"mapped-input-start")}offAllMappedInputStart(){Cr(this.#ur),this.#ti.delete("mapped-input-start")}onMappedInputEnd(e){return Cr(this.#ur),this.#Wi("",e,"mapped-input-end")}onceMappedInputEnd(e){return Cr(this.#ur),this.#qi("",e,"mapped-input-end")}prependMappedInputEnd(e){return Cr(this.#ur),this.#Ki("",e,"mapped-input-end")}offMappedInputEnd(e){return Cr(this.#ur),this.#Vi("",e,"mapped-input-end")}offAllMappedInputEnd(){Cr(this.#ur),this.#ti.delete("mapped-input-end")}onInput(e,t){return Cr(this.#ur),this.#Wi(e,t,"input-{logicalName}")}onceInput(e,t){return Cr(this.#ur),this.#qi(e,t,"input-{logicalName}")}prependInput(e,t){return Cr(this.#ur),this.#Ki(e,t,"input-{logicalName}")}offInput(e,t){return Cr(this.#ur),this.#Vi(e,t,"input-{logicalName}")}onInputStart(e,t){return Cr(this.#ur),this.#Wi(e,t,"input-down-{logicalName}")}onceInputStart(e,t){return Cr(this.#ur),this.#qi(e,t,"input-down-{logicalName}")}prependInputStart(e,t){return Cr(this.#ur),this.#Ki(e,t,"input-down-{logicalName}")}offInputStart(e,t){return Cr(this.#ur),this.#Vi(e,t,"input-down-{logicalName}")}onInputEnd(e,t){return Cr(this.#ur),this.#Wi(e,t,"input-up-{logicalName}")}onceInputEnd(e,t){return Cr(this.#ur),this.#qi(e,t,"input-up-{logicalName}")}prependInputEnd(e,t){return Cr(this.#ur),this.#Ki(e,t,"input-up-{logicalName}")}offInputEnd(e,t){return Cr(this.#ur),this.#Vi(e,t,"input-up-{logicalName}")}onInputHold(e,t){return Cr(this.#ur),this.#Wi(e,t,"input-hold-{logicalName}")}onceInputHold(e,t){return Cr(this.#ur),this.#qi(e,t,"input-hold-{logicalName}")}prependInputHold(e,t){return Cr(this.#ur),this.#Ki(e,t,"input-hold-{logicalName}")}offInputHold(e,t){return Cr(this.#ur),this.#Vi(e,t,"input-hold-{logicalName}")}onInputChange(e,t){return Cr(this.#ur),this.#Wi(e,t,"input-change-{logicalName}")}onceInputChange(e,t){return Cr(this.#ur),this.#qi(e,t,"input-change-{logicalName}")}prependInputChange(e,t){return Cr(this.#ur),this.#Ki(e,t,"input-change-{logicalName}")}offInputChange(e,t){return Cr(this.#ur),this.#Vi(e,t,"input-change-{logicalName}")}onInputMove(e,t){return Cr(this.#ur),this.#Wi(e,t,"input-move-{logicalName}")}onceInputMove(e,t){return Cr(this.#ur),this.#qi(e,t,"input-move-{logicalName}")}prependInputMove(e,t){return Cr(this.#ur),this.#Ki(e,t,"input-move-{logicalName}")}offInputMove(e,t){return Cr(this.#ur),this.#Vi(e,t,"input-move-{logicalName}")}getCalls(e,t="all"){if(Cr(this.#ur),"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 i=`${{all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t]}${e}`,n=this.#ti.get(i);return Array.isArray(n)?[...n]:[]}offAllInputs(e,t="all"){if(Cr(this.#ur),"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 i={all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t];i&&this.#ti.delete(`${i}${e}`)}getCallSize(e,t="all"){if(Cr(this.#ur),"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 i={all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t],n=this.#ti.get(`${i}${e}`);return Array.isArray(n)?n.length:0}#Ji={type:"dual-rumble",params:{startDelay:0,duration:200,weakMagnitude:.5,strongMagnitude:1}};get defaultHapticEffect(){return Cr(this.#ur),{type:this.#Ji.type,params:{...this.#Ji.params}}}setDefaultHapticEffect(e,t){if(Cr(this.#ur),"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.#Ji.type=e,this.#Ji.params=t}hasHapticEffect(){Cr(this.#ur);const e=this.#ri;return!!e&&e.vibrationActuator instanceof GamepadHapticActuator}vibrate(e,t){if(Cr(this.#ur),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.#ri;if(!r)return new Promise(e=>e("complete"));const i=r.vibrationActuator;return i instanceof GamepadHapticActuator?i.playEffect(t??this.#Ji.type,{...this.#Ji.params,...e}):new Promise(e=>e("complete"))}ignoreId(e){if(Cr(this.#ur),"string"!=typeof e||""===e.trim())throw new TypeError(`"id" must be a non-empty string, received ${e}`);this.#ui.add(e)}unignoreId(e){if(Cr(this.#ur),"string"!=typeof e||""===e.trim())throw new TypeError(`"id" must be a non-empty string, received ${e}`);this.#ui.delete(e)}onConnected(e){return Cr(this.#ur),this.#Wi("",e,"connected")}onceConnected(e){return Cr(this.#ur),this.#qi("",e,"connected")}prependConnected(e){return Cr(this.#ur),this.#Ki("",e,"connected")}offConnected(e){return Cr(this.#ur),this.#Vi("",e,"connected")}offAllConnected(){Cr(this.#ur),this.#ti.delete("connected")}onDisconnected(e){return Cr(this.#ur),this.#Wi("",e,"disconnected")}onceDisconnected(e){return Cr(this.#ur),this.#qi("",e,"disconnected")}prependDisconnected(e){return Cr(this.#ur),this.#Ki("",e,"disconnected")}offDisconnected(e){return Cr(this.#ur),this.#Vi("",e,"disconnected")}offAllDisconnected(){Cr(this.#ur),this.#ti.delete("disconnected")}hasGamepad(){return Cr(this.#ur),this.#ri instanceof Gamepad}getGamepad(){if(Cr(this.#ur),!this.#ri)throw new Error("No gamepad is currently connected.");return this.#ri}hasLastButtonState(e){return Cr(this.#ur),!!this.#ii[e]}getLastButtonState(e){if(Cr(this.#ur),!this.#ii[e])throw new Error(`No last button state found for index ${e}`);return{...this.#ii[e]}}exportConfig(){return Cr(this.#ur),{expectedId:this.#ci,ignoreIds:Array.from(this.#ui),deadZone:this.#hi,timeoutComboKeys:this.#pi,axisActiveSensitivity:this.#fi,inputMap:Array.from(this.#ei.entries())}}importConfig(e){if(Cr(this.#ur),"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.#ci=t.expectedId),Array.isArray(t.ignoreIds)&&(this.#ui=new Set(t.ignoreIds)),"number"==typeof t.deadZone&&(this.#hi=t.deadZone),"number"==typeof t.timeoutComboKeys&&(this.#pi=t.timeoutComboKeys),"number"==typeof t.axisActiveSensitivity&&(this.#fi=t.axisActiveSensitivity),Array.isArray(t.inputMap)&&(this.#ei=new Map(t.inputMap))}get mappedKeyStartCalls(){Cr(this.#ur);const e=this.#ti.get("mapped-key-start");return Array.isArray(e)?[...e]:[]}get mappedKeyEndCalls(){Cr(this.#ur);const e=this.#ti.get("mapped-key-end");return Array.isArray(e)?[...e]:[]}get comboMappedKeys(){return Cr(this.#ur),[...this.#bi]}get comboMappedInputs(){return Cr(this.#ur),[...this.#yi]}get keySequenceSize(){return Cr(this.#ur),this.#Ai.size}get keySequences(){Cr(this.#ur);const e=[];for(const[,t]of this.#Ai.entries())e.push(t.callback);return e}get activeMappedKeys(){return Cr(this.#ur),[...this.#Ti]}get mappedInputStartCalls(){Cr(this.#ur);const e=this.#ti.get("mapped-input-start");return Array.isArray(e)?[...e]:[]}get mappedInputEndCalls(){Cr(this.#ur);const e=this.#ti.get("mapped-input-end");return Array.isArray(e)?[...e]:[]}get inputSequenceSize(){return Cr(this.#ur),this.#xi.size}get inputSequences(){Cr(this.#ur);const e=[];for(const[,t]of this.#xi.entries())e.push(t.callback);return e}get activeMappedInputs(){return Cr(this.#ur),[...this.#Si]}get mappedInputs(){Cr(this.#ur);const e={};for(const[t,r]of this.#ei.entries())e[t]=r;return e}get mappedInputSize(){return Cr(this.#ur),this.#ei.size}get connectedCalls(){Cr(this.#ur);const e=this.#ti.get("connected");return Array.isArray(e)?[...e]:[]}get disconnectedCalls(){Cr(this.#ur);const e=this.#ti.get("disconnected");return Array.isArray(e)?[...e]:[]}get ignoredDeviceIds(){return Cr(this.#ur),[...this.#ui]}get heldKeys(){return Cr(this.#ur),[...this.#Zr]}get eventsSize(){Cr(this.#ur);let e=0;return this.#ti.forEach(t=>{e+=t.length}),e}get callSize(){return Cr(this.#ur),this.#ti.size}get connectedCallSize(){Cr(this.#ur);const e=this.#ti.get("connected");return Array.isArray(e)?e.length:0}get disconnectedCallSize(){Cr(this.#ur);const e=this.#ti.get("disconnected");return Array.isArray(e)?e.length:0}get mappedKeyStartCallSize(){Cr(this.#ur);const e=this.#ti.get("mapped-key-start");return Array.isArray(e)?e.length:0}get mappedKeyEndCallSize(){Cr(this.#ur);const e=this.#ti.get("mapped-key-end");return Array.isArray(e)?e.length:0}get mappedInputStartCallSize(){Cr(this.#ur);const e=this.#ti.get("mapped-input-start");return Array.isArray(e)?e.length:0}get mappedInputEndCallSize(){Cr(this.#ur);const e=this.#ti.get("mapped-input-end");return Array.isArray(e)?e.length:0}get lastButtonStates(){Cr(this.#ur);const e=[];return this.#ii.forEach(t=>{e.push({...t})}),e}get lastAxes(){return Cr(this.#ur),[...this.#si]}get inputMode(){return Cr(this.#ur),this.#li}get elementBase(){return Cr(this.#ur),this.#mi}get timeComboInputs(){return Cr(this.#ur),this.#gi}get timeComboKeys(){return Cr(this.#ur),this.#vi}get timeMappedInputs(){return Cr(this.#ur),this.#wi}get timeoutComboKeys(){return Cr(this.#ur),this.#pi}set timeoutComboKeys(e){if(Cr(this.#ur),"number"!=typeof e||e<0||!Number.isFinite(e))throw new TypeError("Timeout combo keys must be a non-negative finite number.");this.#pi=e}get axisActiveSensitivity(){return Cr(this.#ur),this.#fi}set axisActiveSensitivity(e){if(Cr(this.#ur),"number"!=typeof e||e<0||e>1)throw new RangeError("Axis sensitivity must be a number between 0 and 1.");this.#fi=e}get deadZone(){return Cr(this.#ur),this.#hi}set deadZone(e){if(Cr(this.#ur),"number"!=typeof e||e<0||e>1)throw new RangeError("Dead zone must be a number between 0 and 1.");this.#hi=e}get expectedId(){return Cr(this.#ur),this.#ci}set expectedId(e){if(Cr(this.#ur),"string"!=typeof e)throw new TypeError("Expected device id be a string.");this.#ci=e}get isDestroyed(){return this.#ur}destroy(){this.#ur||(this.#oi&&cancelAnimationFrame(this.#oi),this.#ai&&cancelAnimationFrame(this.#ai),this.#oi=null,this.#ai=null,["keyboard-only","both"].includes(this.#li)&&(this.#mi.removeEventListener("keydown",this.#Hi),this.#mi.removeEventListener("keyup",this.#Oi),this.#di&&(this.#mi.removeEventListener("mousedown",this.#Fi),this.#mi.removeEventListener("mouseup",this.#Bi),this.#mi.removeEventListener("mousemove",this.#zi))),["gamepad-only","both"].includes(this.#li)&&(window.removeEventListener("gamepadconnected",this.#Ni),window.removeEventListener("gamepaddisconnected",this.#Li)),this.resetComboMapped(),this.#ei.clear(),this.#ti.clear(),this.#Zr.clear(),this.#Si.clear(),this.#Ti.clear(),this.#xi.clear(),this.#Ai.clear(),this.#ui.clear(),this.#Ci.clear(),this.#ii=[],this.#si=[],this.#ni={},this.#ri=null,this.#ci=null,this.#di=!1,this.#wi=0,this.#ur=!0)}}const Dr=Ir,Mr=Y("TinyDayNightCycle"),Nr=class{#Ui=!0;#Gi=86400;#Yi=3600;#Xi=60;#Qi=new Map;#Zi=[];#en;#tn;#rn={main:null};#in=0;#nn=0;#sn=0;#on="";#an=1;#ln=1;#un=1;#ur=!1;#hn=[31,31,31,31,31,31,31,31,31,31,31,31];#cn={default:{},day:{},night:{},hours:{},seasons:{}};#dn={min:60,max:180};#mn=0;get daySize(){return Mr(this.#ur),this.#Gi}get autoSizeAdjuste(){return Mr(this.#ur),this.#Ui}set autoSizeAdjuste(e){if(Mr(this.#ur),"boolean"!=typeof e)throw new TypeError("autoSizeAdjuste must be a boolean.");this.#Ui=e}set daySize(e){if(Mr(this.#ur),"number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("daySize must be a positive finite number.");const t=this.#Yi/this.#Gi,r=this.#Xi/this.#Gi;this.#Gi=e,this.#Ui&&(this.#Yi=e*t,this.#Xi=e*r)}get hourSize(){return Mr(this.#ur),this.#Yi}set hourSize(e){if(Mr(this.#ur),"number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("hourSize must be a positive finite number.");const t=this.#Gi/this.#Yi,r=this.#Xi/this.#Yi;this.#Yi=e,this.#Ui&&(this.#Gi=e*t,this.#Xi=e*r)}get minuteSize(){return Mr(this.#ur),this.#Xi}set minuteSize(e){if(Mr(this.#ur),"number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("minuteSize must be a positive finite number.");const t=this.#Yi/this.#Xi,r=this.#Gi/this.#Xi;this.#Xi=e,this.#Ui&&(this.#Yi=e*t,this.#Gi=e*r)}get isDestroyed(){return this.#ur}get currentSeconds(){return Mr(this.#ur),this.#in}set currentSeconds(e){if(Mr(this.#ur),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("currentSeconds must be a finite number, received "+typeof e);if(e<0||e>=this.#Gi)throw new RangeError(`currentSeconds must be between 0 and 86399, received ${e}`);this.#in=Math.floor(e),this.#nn=Math.floor(e/this.#Xi),this.#sn=Math.floor(e/this.#Yi)}get currentMinutes(){return Mr(this.#ur),this.#nn}set currentMinutes(e){if(Mr(this.#ur),"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.#nn=Math.floor(e),this.#sn=Math.floor(e/this.#Xi),this.#in=Math.floor(e*this.#Xi)}get currentHours(){return Mr(this.#ur),this.#sn}set currentHours(e){if(Mr(this.#ur),"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.#sn=Math.floor(e),this.#nn=Math.floor(e*this.#Xi),this.#in=Math.floor(e*this.#Yi)}get moons(){return Mr(this.#ur),this.#Zi.map(e=>this.getMoon(e))}get seasons(){return Mr(this.#ur),Array.from(this.#Qi.keys())}get dayStart(){return Mr(this.#ur),this.#en}get nightStart(){return Mr(this.#ur),this.#tn}get weather(){return Mr(this.#ur),{...this.#rn}}get currentSeason(){return Mr(this.#ur),this.#on}get currentDay(){return Mr(this.#ur),this.#an}get currentMonth(){return Mr(this.#ur),this.#ln}get currentYear(){return Mr(this.#ur),this.#un}get monthDays(){return Mr(this.#ur),[...this.#hn]}get weatherDuration(){return Mr(this.#ur),{...this.#dn}}get weatherTimeLeft(){return Mr(this.#ur),this.#mn}set dayStart(e){if(Mr(this.#ur),"number"!=typeof e||e<1)throw new TypeError("dayStart must be a positive non-zero number, received "+typeof e);this.#en=e}set nightStart(e){if(Mr(this.#ur),"number"!=typeof e||e<1)throw new TypeError("nightStart must be a positive non-zero number, received "+typeof e);this.#tn=e}set weather(e){if(Mr(this.#ur),"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.#rn=e}set currentSeason(e){if(Mr(this.#ur),"string"!=typeof e||!this.#Qi.has(e))throw new TypeError(`currentSeason must be one of ${Array.from(this.#Qi).map(e=>e[0]).join(", ")}, received ${e}`);this.#on=e}set currentDay(e){if(Mr(this.#ur),"number"!=typeof e||e<1||e>this.#hn[this.#ln-1])throw new TypeError("currentDay must be a valid day number, received "+typeof e);this.#an=e}set currentMonth(e){if(Mr(this.#ur),"number"!=typeof e||"number"!=typeof this.#hn[e-1])throw new TypeError("currentMonth must be a valid month number, received "+typeof e);this.#ln=e}set currentYear(e){if(Mr(this.#ur),"number"!=typeof e||e<1)throw new TypeError("currentYear must be a positive number non-zero, received "+typeof e);this.#un=e}set monthDays(e){if(Mr(this.#ur),!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.#hn=[...e]}set weatherDuration(e){if(Mr(this.#ur),"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.#dn={...e}}set weatherTimeLeft(e){if(Mr(this.#ur),"number"!=typeof e)throw new TypeError("weatherTimeLeft must be a number, received "+typeof e);this.#mn=e}get weatherConfig(){Mr(this.#ur);const e={},t={};for(const t in this.#cn.hours)e[t]={...this.#cn.hours[t]};for(const e in this.#cn.seasons)t[e]={...this.#cn.seasons[e]};return{default:{...this.#cn.default},day:{...this.#cn.day},night:{...this.#cn.night},hours:e,seasons:t}}set weatherConfig(e){if(Mr(this.#ur),"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={},i={},n=(e,t)=>{if("object"!=typeof e||null===e)throw new TypeError(`${t} must be an object, received ${e}`);for(const r in e){const i=typeof e[r];if("number"!==i&&"function"!==i)throw new TypeError(`${t}["${r}"] must be a number or function, received ${i}`)}};for(const t in e.hours)n(e.hours[t],`hours["${t}"]`),r[t]={...e.hours[t]};for(const t in e.seasons)n(e.seasons[t],`seasons["${t}"]`),i[t]={...e.seasons[t]};const s=(e,t)=>(n(e,t),{...e});this.#cn={default:s(e.default,"default"),day:s(e.day,"day"),night:s(e.night,"night"),hours:r,seasons:i}}constructor(e=6,t=18){this.#en=e,this.#tn=t}addSeason(e,t){if(Mr(this.#ur),"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.#Qi.set(e,t)}removeSeason(e){if(Mr(this.#ur),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);this.#Qi.delete(e),this.#on===e&&(this.#on="")}hasSeason(e){if(Mr(this.#ur),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);return this.#Qi.has(e)}getSeason(e){if(Mr(this.#ur),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);const t=this.#Qi.get(e);if(!t)throw new Error(`Season "${e}" not found`);return[...t]}setTime({hour:e=0,minute:t=0,second:r=0}){Mr(this.#ur),this.currentSeconds=(e*this.#Yi+t*this.#Xi+r)%this.#Gi}addTime({hours:e=0,minutes:t=0,seconds:r=0}){Mr(this.#ur);let i=this.currentSeconds+e*this.#Yi+t*this.#Xi+r;for(;i>=this.#Gi;)i-=this.#Gi,this.nextDay();for(;i<0;)i+=this.#Gi,this.prevDay();this.currentSeconds=i,this.updateWeatherTimer((e*this.#Yi+t*this.#Xi+r)/this.#Xi)}getTime({withSeconds:e=!1,hourSize:t=this.#Yi,minuteSize:r=this.#Xi}={}){Mr(this.#ur);const i=Math.floor(this.currentSeconds/t),n=Math.floor(this.currentSeconds%t/r),s=this.currentSeconds%r;return{hour:i,minute:n,second:s,formatted:`${i.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`+(e?`:${s.toString().padStart(2,"0")}`:"")}}isDay(){return Mr(this.#ur),this.#en<this.#tn?this.#nn>=this.#en*this.#Xi&&this.#nn<this.#tn*this.#Xi:this.#nn>=this.#en*this.#Xi||this.#nn<this.#tn*this.#Xi}minutesUntilDay(){return this.timeUntil(this.#en,"minutes")}secondsUntilDay(){return this.timeUntil(this.#en,"seconds")}hoursUntilDay(){return this.timeUntil(this.#en,"hours")}minutesUntilNight(){return this.timeUntil(this.#tn,"minutes")}secondsUntilNight(){return this.timeUntil(this.#tn,"seconds")}hoursUntilNight(){return this.timeUntil(this.#tn,"hours")}timeUntil(e,t){Mr(this.#ur);let r=e*this.#Yi-this.#in;switch(r<=0&&(r+=this.#Gi),t){case"minutes":return r/this.#Xi;case"hours":return r/this.#Yi;default:return r}}setTo(e){Mr(this.#ur),"day"===e?this.setTime({hour:this.#en}):"night"===e&&this.setTime({hour:this.#tn})}nextDay(e=1){Mr(this.#ur);for(let t=0;t<e;t++){this.#an++;const e=this.#hn[this.#ln-1];if(Number.isNaN(e)||!Number.isFinite(e))throw new Error("Invalid month day count: monthDays must be a finite number.");this.#an>e&&(this.#an=1,this.#ln++,this.#ln>this.#hn.length&&(this.#ln=1,this.#un++)),this.updateSeason(),this.advanceMoons(1)}}prevDay(e=1){Mr(this.#ur);for(let t=0;t<e;t++)this.#an--,this.#an<1&&(this.#ln--,this.#ln<1&&(this.#ln=this.#hn.length,this.#un--),this.#an=this.#hn[this.#ln-1]||30),this.updateSeason(),this.rewindMoons(1)}updateSeason(){Mr(this.#ur),this.#Qi.forEach((e,t)=>{e.includes(this.#ln)&&(this.#on=t)})}setWeatherConfig(e){Mr(this.#ur),this.#cn={...this.#cn,...e}}setWeatherDuration(e,t){Mr(this.#ur),this.#dn.min=e,this.#dn.max=t}updateWeatherTimer(e){Mr(this.#ur),this.#mn-=e,this.#mn<=0&&this.chooseNewWeather()}forceWeather({where:e="main",type:t,duration:r=null}){Mr(this.#ur);const i=this.#rn;i[e]=t,this.weather=i,this.#mn=r??this._randomInRange(this.#dn.min,this.#dn.max)}chooseNewWeather({customWeather:e,where:t="main"}={}){Mr(this.#ur);let r={};const i=e=>{for(const[t,i]of Object.entries(e)){let e=i;"function"==typeof e&&(e=e({hour:Math.floor(this.#nn/this.#Xi),minute:this.#nn%this.#Xi,currentMinutes:this.#nn,isDay:this.isDay(),season:this.#on,weather:this.#rn})),"number"!=typeof e||Number.isNaN(e)||(r[t]=(r[t]||0)+e)}};i(this.#cn.default||{});for(const e in this.#cn.hours){const[t,r]=e.split("-").map(e=>{const[t,r]=e.split(":").map(Number);return t*this.#Xi+(r||0)}),n=this.#nn;(t<=r?n>=t&&n<=r:n>=t||n<=r)&&i(this.#cn.hours[e])}this.isDay()&&this.#cn.day?i(this.#cn.day):!this.isDay()&&this.#cn.night&&i(this.#cn.night),this.#cn.seasons?.[this.#on]&&i(this.#cn.seasons[this.#on]),e&&"object"==typeof e&&i(e);const n=Object.entries(r).filter(([,e])=>e>0);if(!n.length)return this.#rn[t]=null,null;const s=n.reduce((e,[,t])=>e+t,0);let o=Math.random()*s;for(const[e,r]of n){if(o<r)return this.#rn[t]=e,this.#mn=this._randomInRange(this.#dn.min,this.#dn.max),e;o-=r}return this.#rn[t]=null,null}_randomInRange(e,t){return Math.floor(Math.random()*(t-e+1))+e}addMoon(e,t,r,i=0){Mr(this.#ur);const n=Math.max(1,t);return this.#Zi.push({name:e,cycleLength:n,currentPhase:(i%n+n)%n,phaseNames:r}),this.#Zi.length-1}removeMoon(e){Mr(this.#ur),this.#Zi=this.#Zi.filter(t=>t.name!==e)}advanceMoons(e=1){for(const t in this.#Zi)this.advanceMoon(parseInt(t),e)}rewindMoons(e=1){for(const t in this.#Zi)this.rewindMoon(parseInt(t),e)}advanceMoon(e,t=1){Mr(this.#ur);const r=this.#Zi[e];if(!r)throw new RangeError(`No moon found at index ${e}`);r.currentPhase=(r.currentPhase+t)%r.cycleLength}rewindMoon(e,t=1){Mr(this.#ur);const r=this.#Zi[e];if(!r)throw new RangeError(`No moon found at index ${e}`);r.currentPhase=(r.currentPhase-t+r.cycleLength)%r.cycleLength}moonExists(e){return Mr(this.#ur),!!this.#Zi[e]}getMoon(e){let t;if(Mr(this.#ur),"number"==typeof e){if(t=this.#Zi[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}}destroy(){this.#ur||(this.#Qi.clear(),this.#Zi.length=0,this.#en=0,this.#tn=0,this.#in=0,this.#nn=0,this.#sn=0,this.#an=1,this.#ln=1,this.#un=1,this.#mn=0,this.#on="",this.#rn={main:null},this.#hn=[],this.#cn.default={},this.#cn.day={},this.#cn.night={},this.#cn.hours={},this.#cn.seasons={},this.#dn={min:0,max:0},this.#ur=!0)}},kr=Y("TinyAdvancedRaffle");class Lr extends er.EventEmitter{#ur=!1;#pn;#fn;#yn=[];#gn=[];#wn=[];#bn=new Map;#vn=new Set;#En=new Map;#Tn;#Sn=new Map;#xn=new Map;get isDestroyed(){return this.#ur}get freq(){return kr(this.#ur),Object.fromEntries(this.#xn)}get size(){return kr(this.#ur),this.#Sn.size}get normalization(){return kr(this.#ur),this.#pn}set normalization(e){if(kr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError("normalization must be a non-empty string (e.g., 'relative', 'softmax').");this.#pn=e}get seed(){return kr(this.#ur),this.#fn}set seed(e){if(kr(this.#ur),null!==e&&("number"!=typeof e||!Number.isFinite(e)))throw new TypeError("seed must be a finite number or null.");this.#fn=e,null!==e&&(this.#Tn=this._makeSeededRng(e))}get globalModifiers(){return kr(this.#ur),[...this.#yn]}set globalModifiers(e){if(kr(this.#ur),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("globalModifiers must be an array of functions (WeightsCallback).");this.#yn=e}get temporaryModifiers(){return kr(this.#ur),[...this.#gn]}set temporaryModifiers(e){if(kr(this.#ur),!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.#gn=e}get conditionalRules(){return kr(this.#ur),[...this.#wn]}set conditionalRules(e){if(kr(this.#ur),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("conditionalRules must be an array of functions (WeightsCallback).");this.#wn=e}get pitySystems(){return kr(this.#ur),Object.fromEntries(this.#bn)}set pitySystems(e){if(kr(this.#ur),!(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.#bn=e}get exclusions(){return kr(this.#ur),Array.from(this.#vn)}set exclusions(e){if(kr(this.#ur),!(e instanceof Set&&[...e].every(e=>"string"==typeof e)))throw new TypeError("exclusions must be a Set<string>.");this.#vn=e}get groups(){kr(this.#ur);const e={};return this.#En.forEach((t,r)=>e[r]=Array.from(t)),e}set groups(e){if(kr(this.#ur),!(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.#En=e}get rng(){return kr(this.#ur),this.#Tn}set rng(e){if(kr(this.#ur),"function"!=typeof e||"number"!=typeof e())throw new TypeError("rng must be a function returning a number (RngGenerator).");this.#Tn=e}get items(){kr(this.#ur);const e={};return this.#Sn.forEach((t,r)=>{e[r]={...t,groups:Array.from(t.groups)}}),e}set items(e){if(kr(this.#ur),!(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.#Sn=e}constructor(e={}){super();const{rng:t=null,seed:r=null,normalization:i="relative"}=e;this.#pn=i,this.#fn=r,"function"==typeof t?this.#Tn=t:null!==this.#fn?this.#Tn=this._makeSeededRng(this.#fn):this.#Tn=Math.random,this.#fn=r??null}hasItem(e){if(kr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#Sn.has(e)}addItem(e,t={}){if(kr(this.#ur),"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:i=e,meta:n={},groups:s=[]}=t;if("number"!=typeof r||!Number.isFinite(r)||r<0)throw new TypeError("weight must be a non-negative number");if("string"!=typeof i)throw new TypeError("label must be a string");if("object"!=typeof n||null===n)throw new TypeError("meta must be an object");if(!(Array.isArray(s)||s instanceof Set))throw new TypeError("groups must be an array or a Set of strings");s=Array.isArray(s)?s:[...s];for(const e of s)if("string"!=typeof e)throw new TypeError("groups must contain only strings");const o={id:e,label:i,baseWeight:Math.max(0,Number(r)||0),meta:{...n},groups:new Set(s),locked:!1};this.#Sn.set(e,o);for(const t of s)this._ensureGroup(t).add(e);return this.emit("itemAdded",o),o}removeItem(e){if(kr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");const t=this.#Sn.get(e);if(!t)return!1;for(const r of t.groups){const t=this.#En.get(r);t&&t.delete(e)}return this.#Sn.delete(e),this.emit("itemRemoved",e),this.resetFreq(e),this.resetPity(e),!0}setBaseWeight(e,t){if(kr(this.#ur),"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.#Sn.get(e);if(!r)throw new Error("Item not found");r.baseWeight=Math.max(0,Number(t)||0),this.emit("weightChanged",{id:e,weight:r.baseWeight})}getItem(e){if(kr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");return this.#Sn.get(e)??null}listItems(){return kr(this.#ur),Array.from(this.#Sn.values()).map(e=>({...e}))}clearList(){kr(this.#ur),this.#Sn.clear(),this.clearFreqs(),this.clearPities()}hasGlobalModifier(e){if(kr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");return this.#yn.includes(e)}addGlobalModifier(e){if(kr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");this.#yn.push(e)}removeGlobalModifier(e){if(kr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");this.#yn=this.#yn.filter(t=>t!==e)}hasTemporaryModifier(e){if(kr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");return this.#gn.some(t=>t.fn===e)}addTemporaryModifier(e,t=1){if(kr(this.#ur),"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.#gn.push({fn:e,uses:Math.max(1,Math.floor(t))})}removeTemporaryModifier(e){if(kr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");const t=this.#gn.length;return this.#gn=this.#gn.filter(t=>t.fn!==e),this.#gn.length!==t}hasConditionalRule(e){if(kr(this.#ur),"function"!=typeof e)throw new TypeError("ruleFn must be a function");return this.#wn.includes(e)}addConditionalRule(e){if(kr(this.#ur),"function"!=typeof e)throw new TypeError("ruleFn must be a function");this.#wn.push(e)}removeConditionalRule(e){if(kr(this.#ur),"function"!=typeof e)throw new TypeError("ruleFn must be a function");const t=this.#wn.length;return this.#wn=this.#wn.filter(t=>t!==e),this.#wn.length!==t}hasPity(e){if(kr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#bn.has(e)}configurePity(e,t){if(kr(this.#ur),!this.#Sn.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:i,cap:n=1/0}=t;if("number"!=typeof r||r<=0)throw new TypeError("threshold must be a positive number");if("number"!=typeof i)throw new TypeError("increment must be a number");if("number"!=typeof n)throw new TypeError("cap must be a number");this.#bn.set(e,{threshold:Math.max(1,r),increment:Number(i)||0,cap:Number(n)||1/0,counter:0,currentAdd:0})}resetPity(e){if(kr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError("itemId must be a non-empty string");const t=this.#bn.get(e);t&&(t.counter=0,t.currentAdd=0)}clearPities(){kr(this.#ur),this.#bn.clear()}hasExclusion(e){if(kr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#vn.has(e)}excludeItem(e){if(kr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#vn.add(e)}includeItem(e){if(kr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#vn.delete(e)}_ensureGroup(e){if(kr(this.#ur),"string"!=typeof e)throw new TypeError("name must be a string");let t=this.#En.get(e);return t||(t=new Set,this.#En.set(e,t)),t}hasInGroup(e,t){if(kr(this.#ur),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#En.get(t);return!!r&&r.has(e)}addToGroup(e,t){if(kr(this.#ur),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#Sn.get(e);if(!r)throw new Error("Item missing");r.groups.add(t),this._ensureGroup(t).add(e)}removeFromGroup(e,t){if(kr(this.#ur),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#En.get(t);r&&r.delete(e);const i=this.#Sn.get(e);i&&i.groups.delete(t)}clearFreqs(){kr(this.#ur),this.#xn.clear()}resetFreq(e){if(kr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#xn.delete(e)}computeEffectiveWeights(e={}){if(kr(this.#ur),"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.#Sn)t.set(e,r.baseWeight);for(const r of this.#yn){const i=r(t,e);if(i instanceof Map)for(const[e,r]of i)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const r of this.#gn){const i=r.fn(t,e);if(i instanceof Map)for(const[e,r]of i)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const r of this.#wn){const i=r(t,e);if(i instanceof Map)for(const[e,r]of i)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const[e,r]of this.#bn)if(t.has(e)&&r.counter>r.threshold){r.currentAdd=Math.min(r.cap,r.currentAdd+r.increment);const i=t.get(e);i&&t.set(e,i+r.currentAdd)}for(const e of this.#vn)t.delete(e);for(const[e,r]of Array.from(t.entries()))r>0||t.delete(e);return t}_weightsToDistribution(e){if(!(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.#pn){const e=Math.max(...t.map(e=>e.weight)),r=t.map(t=>Math.exp(t.weight-e)),i=r.reduce((e,t)=>e+t,0);let n=0;return t.map((e,t)=>{const s=r[t]/i;return n+=s,{id:e.id,weight:e.weight,p:s,cumulative:n}})}{const e=t.reduce((e,t)=>e+t.weight,0);let r=0;return t.map(t=>{const i=t.weight/e;return r+=i,{id:t.id,weight:t.weight,p:i,cumulative:r}})}}drawOne(e={}){if(kr(this.#ur),"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.#gn]},r=this.computeEffectiveWeights(t),i=this._weightsToDistribution(r);if(!i.length)return null;const n=this.#Tn(),s=i.find(e=>n<=e.cumulative)??i[i.length-1];for(const[e,t]of this.#bn)e===s.id?(t.counter=0,t.currentAdd=0):t.counter++;this._consumeTemporaryModifiers();const o=this.#Sn.get(s.id);if(!o)return null;const a={id:o.id,label:o.label,meta:{...o.meta},prob:s.p};return this.emit("draw",a),a&&this.#xn.set(a.id,(this.#xn.get(a.id)||0)+1),a}_consumeTemporaryModifiers(){for(let e=this.#gn.length-1;e>=0;--e){const t=this.#gn[e];t.uses-=1,t.uses<=0&&this.#gn.splice(e,1)}}drawMany(e=1,t={}){if(kr(this.#ur),!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,i=t.ensureUnique??!1,n=[],s=t.previousDraws??[];if(!r&&i){const r=new Set;for(let i=0;i<e;++i){const e=new Set(this.#vn);for(const e of r)this.#vn.add(e);const i=this.drawOne({previousDraws:s,metadata:t.metadata});if(this.#vn=e,!i)break;n.push(i),r.add(i.id),s.push(i)}return n}for(let i=0;i<e;++i){const e=this.drawOne({previousDraws:s,metadata:t.metadata});if(!e)break;n.push(e),s.push(e),r||this.excludeItem(e.id)}if(!r)for(const e of n)this.includeItem(e.id);return n}exportToJson(){return kr(this.#ur),{items:Array.from(this.#Sn.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.#bn.entries()),exclusions:Array.from(this.#vn),normalization:this.#pn,seed:this.#fn}}loadFromJson(e){if(kr(this.#ur),"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.#Sn.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(){kr(this.#ur);const e=new Lr;return e.#pn=this.#pn,e.#fn=this.#fn,e.#yn=[...this.#yn],e.#gn=this.#gn.map(e=>({fn:e.fn,uses:e.uses})),e.#wn=[...this.#wn],e.#bn=new Map([...this.#bn.entries()].map(([e,t])=>[e,{...t}])),e.#vn=new Set(this.#vn),e.#En=new Map([...this.#En.entries()].map(([e,t])=>[e,new Set(t)])),e.#Tn=this.#Tn,e.#Sn=new Map([...this.#Sn.entries()].map(([e,t])=>[e,{...t,groups:new Set(t.groups),meta:{...t.meta}}])),e.#xn=new Map(this.#xn),e}_makeSeededRng(e){if("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.#ur||(this.#bn.clear(),this.#vn.clear(),this.#En.clear(),this.#Sn.clear(),this.#xn.clear(),this.#yn=[],this.#gn=[],this.#wn=[],this.#fn=null,this.#ur=!0)}}const _r=Lr,jr=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 i=Array.isArray(this.#ie)?this.#ie:Array.from(this.#ie);let n=i;if(r)if("function"==typeof r)n=i.filter((e,t,i)=>r(e,t,i));else{if("object"!=typeof r)throw new TypeError("Filter must be an object or a function");n=i.filter(e=>Object.entries(r).every(([t,r])=>{const i=e[t];return r instanceof RegExp?r.test(i):i===r}))}else n=i;const s=n.length,o=Math.max(1,Math.ceil(s/t)),a=Math.min(e,o),l=(a-1)*t,u=l+t,h=a>1,c=a<o;return{items:n.slice(l,u),page:a,perPage:t,totalItems:s,totalPages:o,hasPrev:h,hasNext:c}}};class Rr{static#An=new Map;static get itemRegistry(){const e={},t=Object.fromEntries(Rr.#An);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.");Rr.#An.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 Rr.#An.delete(e)}static hasItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");return Rr.#An.has(e)}static getItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");const t=Rr.#An.get(e);if(!t)throw new Error(`Item '${e}' not defined in registry.`);return t}#Cn=new Map;#In={add:[],remove:[],use:[],set:[]};#Sn=[];#Dn;#Mn;#Nn;#kn;get maxStack(){return this.#Dn}set maxStack(e){if(!Number.isInteger(e)||Number.isFinite(e)&&e<=0)throw new TypeError(`maxStack must be a positive integer. Received: ${e}`);this.#Dn=e}get maxSize(){return this.#Mn}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.#Mn=e}get maxSlots(){return this.#Nn}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.#Nn=e}get maxWeight(){return this.#kn}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.#kn=e}get events(){return{add:[...this.#In.add],remove:[...this.#In.remove],use:[...this.#In.use],set:[...this.#In.set]}}get items(){return[...this.#Sn].map(e=>e?this.#Ln(e):null)}get specialSlots(){return new Map([...this.#Cn.entries()].map(([e,t])=>[e,{type:t.type,item:t.item?this.#Ln(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=Rr.getItem(t.id);return e+(r?.weight||0)*t.quantity},0)}_cleanNulls(){let e=this.#Sn.length-1;for(;e>=0&&null===this.#Sn[e];)e--;this.#Sn=this.#Sn.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.#kn=e.maxWeight??null,this.#Nn=e.maxSlots??null,this.#Mn=e.maxSize??null,this.#Dn=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.#Cn.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.#kn&&this.weight+e>this.#kn}areFull(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Mn&&this.size+e>this.#Mn}isFull(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Mn&&this.size+e>=this.#Mn}areFullSlots(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Nn&&this.slotsSize+e>this.#Nn}isFullSlots(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Nn&&this.slotsSize+e>=this.#Nn}#_n(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.#In[e])for(const r of this.#In[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.#In[e])return;const r=this.#In[e],i=r.indexOf(t);-1!==i&&r.splice(i,1)}offAll(e){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");this.#In[e]&&(this.#In[e]=[])}cloneEventCallbacks(e){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");return this.#In[e]?[...this.#In[e]]:[]}onAddItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#In.add.push(e)}onSetItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#In.set.push(e)}onRemoveItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#In.remove.push(e)}onUseItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#In.use.push(e)}compactInventory(){this.#Sn=this.#Sn.filter((e,t)=>{const r=null!==e;return r||this.#_n("remove",{index:t,item:null,isCollection:!0,specialSlot:null,remove:()=>{}}),r})}addItem({itemId:e,quantity:t=1,metadata:r={},forceSpace:i=!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 i)throw new TypeError("`forceSpace` must be a boolean.");const n=Rr.getItem(e);let s=t;const o=n.maxStack<=this.#Dn?n.maxStack:this.#Dn,a=[],l=(e,t)=>JSON.stringify(e)===JSON.stringify(t);let u=!0;for(;s>0&&u;){u=!1;for(const t in this.#Sn){const h=this.#Sn[t];if(h&&h.id===e&&h.quantity<o&&l(h.metadata,r)){const e=Math.min(o-h.quantity,s);if(!i&&!this.hasSpace({weight:n.weight*e,sizeLength:e}))continue;h.quantity+=e,s-=e,u=!0;const r=Number(t),l=a.findIndex(e=>e.index===r);if(l<0?a.push({index:r,quantity:e}):a[l].quantity+=e,this.#_n("add",{item:this.#Ln(h),index:r,isCollection:!0,specialSlot:null,remove:this.#jn({locationType:"normal",slotIndex:r,forceSpace:i,item:h})}),s<=0)break}}}if(s>0)for(const t in this.#Sn)if(null===this.#Sn[t]){const l=Math.min(o,s);if(!i&&!this.hasSpace({weight:n.weight*l,sizeLength:l}))continue;const u={id:e,quantity:l,metadata:r};this.#Sn[t]=u,s-=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.#_n("add",{item:this.#Ln(u),index:h,isCollection:!0,specialSlot:null,remove:this.#jn({locationType:"normal",slotIndex:h,forceSpace:i,item:u})}),s<=0)break}for(;s>0;){const t=Math.min(o,s);if(!i&&!this.hasSpace({weight:n.weight*t,sizeLength:t,slotsLength:1}))break;const l={id:e,quantity:t,metadata:r};this.#Sn.push(l);const u=this.#Sn.length-1,h=a.findIndex(e=>e.index===u);h<0?a.push({index:u,quantity:t}):a[h].quantity+=t,this.#_n("add",{item:this.#Ln(l),index:u,isCollection:!0,specialSlot:null,remove:this.#jn({locationType:"normal",slotIndex:u,forceSpace:i,item:l})}),s-=t}return{remaining:s,placesAdded:a}}getItemFrom(e){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");if(e<0||e>=this.#Sn.length)throw new Error(`Slot index '${e}' out of bounds .`);return this.#Sn[e]?this.#Ln(this.#Sn[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 i=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&&!i)throw new Error("Invalid item type: must be null or a valid InventoryItem.");const n=t?Rr.#An.get(t.id):null;if(null!==t&&!n)throw new Error(`Item '${t?.id??"unknown"}' not defined in registry.`);if(n&&t){const e=n.maxStack<=this.#Dn?n.maxStack:this.#Dn;if(t.quantity>e)throw new Error(`Item '${t.id}' exceeds max stack size. Allowed: ${e}, got: ${t.quantity}.`)}if(null!==this.#Nn&&(e<0||e>=this.#Nn))throw new Error(`Slot index ${e} out of range.`);const s=this.#Sn[e]??null,o=s?Rr.#An.get(s.id)??null:null,a=(e,t)=>t?t.weight*(e?e.quantity:0):0,l=e=>e?e.quantity:0;if(!r&&!this.hasSpace({weight:a(t,n)-a(s,o),sizeLength:l(t)-l(s)}))throw new Error("Inventory is full or overweight.");for(;this.#Sn.length<=e;)this.#Sn.push(null);this.#Sn[e]=t,this._cleanNulls(),this.#_n("set",{index:e,isCollection:!0,item:t?this.#Ln(t):null,specialSlot:null,remove:t?this.#jn({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 i=this.#Sn[e];if(!i)throw new Error(`No item found in slot ${e}.`);this.setItem({slotIndex:t,item:i,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 i=r;const n=(e,t)=>JSON.stringify(e)===JSON.stringify(t);for(let r=0;r<this.#Sn.length;r++){const s=this.#Sn[r];if(s&&s.id===e&&(null===t||n(s.metadata,t))){const e=Math.min(s.quantity,i);s.quantity-=e,i-=e;const t=Number(r);if(s.quantity<=0&&(this.#Sn[r]=null),i<=0)return this._cleanNulls(),this.#_n("remove",{index:t,item:this.#Ln(s),isCollection:!0,specialSlot:null,remove:this.#jn({locationType:"normal",slotIndex:t,item:s})}),!0}}return this._cleanNulls(),this.#Cn.forEach((r,s)=>{if(i>0&&r.item&&r.item.id===e&&(null===t||n(r.item.metadata,t))){const e=Math.min(r.item.quantity,i);r.item.quantity-=e,r.item.quantity<0&&(r.item.quantity=0),i-=e,r.item.quantity<=0&&(r.item=null),this.#Cn.set(s,r),this.#_n("remove",{index:null,item:r.item?this.#Ln(r.item):null,isCollection:!1,specialSlot:s,remove:r.item?this.#jn({locationType:"special",specialSlot:s,item:r.item}):()=>{}})}}),i<=0}#jn({locationType:e,specialSlot:t,slotIndex:r,item:i,forceSpace:n=!1}){if("normal"!==e&&"special"!==e)throw new TypeError("`locationType` must be 'normal' or 'special'.");if("boolean"!=typeof n)throw new TypeError("`forceSpace` must be boolean.");if(!i||"object"!=typeof i)throw new TypeError("`item` must be an InventoryItem object.");if("special"===e&&t&&"string"!=typeof t)throw new TypeError("`specialSlot` must be a string when locationType is 'special'.");if("normal"===e&&"number"!=typeof r)throw new TypeError("`slotIndex` must be a number when locationType is 'normal'.");return(s=n)=>{if("special"===e&&t){const e=this.#Cn.get(t);if(!e?.item)throw new Error(`Special slot '${t}' is empty.`);e.item.quantity>1?(e.item.quantity-=1,this.#Cn.set(t,e)):this.setSpecialSlot({slotId:t,item:null,forceSpace:s})}else{if("number"!=typeof r)throw new Error("Invalid remove operation: no valid slotIndex or specialSlot provided.");i.quantity>1?this.setItem({slotIndex:r,item:{...i,quantity:i.quantity-1},forceSpace:s}):this.setItem({slotIndex:r,item:null,forceSpace:s})}}}useItem({slotIndex:e,specialSlot:t,forceSpace:r=!1},...i){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 n=null,s="normal",o=null;if(t){if(!this.#Cn.has(t))throw new Error(`Special slot '${t}' not found.`);n=this.#Cn.get(t).item,s="special"}else o=this.#Sn,n=o[e??-1]??null,s="normal";if(!n)throw new Error("special"===s?`No item found in special slot '${t}'.`:`No item found in slot ${e} of inventory.`);const a=Rr.getItem(n.id);if(a.onUse){const l={inventory:this,item:this.#Ln(n),index:e??null,specialSlot:t??null,isCollection:!!o,itemDef:a,remove:this.#jn({locationType:s,specialSlot:t,slotIndex:e,forceSpace:r,item:n}),...i},u=a.onUse(l);return this.#_n("use",l),u}return null}hasSpecialSlot(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");return this.#Cn.has(e)}getSpecialItem(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(!this.#Cn.has(e))throw new Error(`Special slot '${e}' does not exist.`);const t=this.#Cn.get(e);return t?.item?this.#Ln(t.item):null}getSpecialSlotType(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(!this.#Cn.has(e))throw new Error(`Special slot '${e}' does not exist.`);const t=this.#Cn.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.#Cn.has(e))throw new Error(`Special slot '${e}' not found.`);const i=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&&!i)throw new Error("Invalid item type: must be null or a valid InventoryItem.");const n=t?Rr.#An.get(t.id):null;if(null!==t&&!n)throw new Error(`Item '${t?.id??"unknown"}' not defined in registry.`);const s=this.#Cn.get(e);if(!s)throw new Error(`Special slot ${e} out of range for slot '${e}'.`);const o=s.item?Rr.#An.get(s.item.id):null,a=(e,t)=>t?t.weight*(e?1:0):0,l=e=>e?1:0;if(!r&&!this.hasSpace({weight:a(t,n)-a(s.item,o),sizeLength:l(t)-l(s.item)}))throw new Error("Inventory is full or overweight.");s.item=t,this.#_n("set",{index:null,item:t?this.#Ln(t):null,isCollection:!1,specialSlot:e,remove:t?this.#jn({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:i=!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 i)throw new TypeError("`forceSpace` must be boolean.");if(r<=0||!Number.isFinite(r))throw new Error(`Invalid quantity '${r}'.`);if(!this.#Cn.has(e))throw new Error(`Special slot '${e}' does not exist.`);const n=this.getItemFrom(t);if(!n)throw new Error(`No item found in inventory slot ${t}.`);if(n.quantity<r)throw new Error(`Not enough quantity of item '${n.id}' in inventory slot.`);const s=Rr.getItem(n.id),o=this.#Cn.get(e);if(!o)throw new Error(`Slot '${e}' not defined in registry.`);const a=o.type??null;if(null!==a&&s.type!==a)throw new Error(`Item '${n.id}' cannot be equipped in slot '${e}'.`);const l=Math.min(s.maxStack,this.#Dn);if(o.item&&o.item.id===n.id){const t=Math.max(0,l-o.item.quantity);if(t<=0)return r;const i=Math.min(r,t);return this.removeItem({itemId:n.id,quantity:i,metadata:null}),o.item.quantity+=i,this.#Cn.set(e,o),r-i}o.item&&this.unequipItem({slotId:e,forceSpace:i});const u=Math.min(r,l);return this.removeItem({itemId:n.id,quantity:u,metadata:null}),o.item={id:n.id,quantity:u,metadata:n.metadata},this.#Cn.set(e,o),r-u}unequipItem({slotId:e,quantity:t=null,forceSpace:r=!1}){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(null!==t&&("number"!=typeof t||!Number.isFinite(t)||t<=0))throw new TypeError("`quantity` must be a positive number or null.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be boolean.");if(!this.#Cn.has(e))throw new Error(`Special slot '${e}' does not exist.`);const i=this.#Cn.get(e);if(!i)throw new Error(`Slot '${e}' not defined in registry.`);if(!i.item)return!1;const n=i.item,s=null===t?n.quantity:t;if(s<=0)throw new Error(`Invalid unequip quantity: ${s}`);if(s>n.quantity)throw new Error(`Not enough items in slot '${e}' to unequip.`);return this.addItem({itemId:n.id,quantity:s,metadata:n.metadata,forceSpace:r}),s===n.quantity?i.item=null:(n.quantity-=s,i.item=n),this.#Cn.set(e,i),!0}#Ln(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.#Sn].map((e,t)=>[e?this.#Ln(e):null,t]).filter(e=>null!==e[0])}getAllItems(){const e=[...this.#Sn].filter(e=>null!==e).map(this.#Ln);return this.#Cn.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=Rr.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.#Sn[e]}clear(){this.clearAllItems(),this.clearAllEvents()}clearAllEvents(){this.#In={add:[],remove:[],use:[],set:[]}}clearAllItems(){this.clearItems(),this.clearSpecialItems()}clearItems(){for(let e=this.#Sn.length-1;e>=0;e--)this.#Sn[e]&&this.deleteItem(e,!0)}clearSpecialItems(){for(const e of this.#Cn.keys()){const t=this.#Cn.get(e);t?.item&&this.deleteSpecialItem(e,!0)}}clone(){const e=this.toObject();return Rr.fromObject(e)}toObject(){const e={};for(const[t,r]of this.#Cn.entries())e[t]={type:r?.type??null,item:r?.item?this.#Ln(r.item):null};return{__schema:"TinyInventory",version:1,maxWeight:this.#kn,maxSlots:this.#Nn,maxSize:this.#Mn,maxStack:this.#Dn,items:this.#Sn.map(e=>e?this.#Ln(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 Rr({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 i=e.items[t];if(null!==i){const e={id:String(i.id),quantity:Math.max(1,Number(i.quantity)||1),metadata:i.metadata&&"object"==typeof i.metadata?i.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,i]of Object.entries(e.specialSlots)){if(!r.hasSpecialSlot(t))continue;const e=i?.item;if(e&&e.id){const i={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:i,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 Rr.fromObject(t)}}const Pr=Rr,$r=class{#Rn=null;#Pn=null;get sender(){return this.#Rn}get receiver(){return this.#Pn}set sender(e){if(!(e instanceof Pr&&this.receiver instanceof Pr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Rn=e}set receiver(e){if(!(this.sender instanceof Pr&&e instanceof Pr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Pn=e}constructor(e,t){if(e||t){if(!(e instanceof Pr&&t instanceof Pr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.connect(e,t)}}connect(e,t){if(!(e instanceof Pr&&t instanceof Pr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Rn=e,this.#Pn=t}disconnect(){this.#Rn=null,this.#Pn=null}invert(){const e=this.#Rn,t=this.#Pn;this.#Rn=t,this.#Pn=e}transferItem({slotIndex:e,specialSlot:t,quantity:r=1,receiverSlotIndex:i,forceSpace:n=!1,strict:s=!1}){if(!this.#Rn||!this.#Pn)throw new Error("Sender and receiver inventories must be connected.");let o;if(t){if(o=this.#Rn.getSpecialItem(t),!o)throw new Error(`No item found in sender special slot '${t}'.`)}else{if("number"!=typeof e)throw new Error("Must provide either slotIndex or specialSlot.");if(o=this.#Rn.getItemFrom(e),!o)throw new Error(`No item found in sender slot ${e}.`)}if(o.quantity<r)throw new Error(`Sender does not have enough quantity of '${o.id}' to transfer.`);const a={id:o.id,quantity:r,metadata:o.metadata};let l;if(s)if("number"==typeof i){const e=this.#Pn.existsItemAt(i)?this.#Pn.getItemFrom(i):null;if(e){if(e.id!==a.id)throw new Error(`Receiver slot ${i} contains a different item.`);const t=Pr.getItem(e.id).maxStack-e.quantity;if(a.quantity>t)throw new Error(`Strict mode: not enough space in receiver slot ${i}.`)}}else if(this.#Pn.clone().addItem({itemId:a.id,quantity:a.quantity,metadata:a.metadata,forceSpace:n}).remaining>0)throw new Error("Strict mode: not enough space in receiver inventory.");if("number"==typeof i){const e=this.#Pn.existsItemAt(i)?this.#Pn.getItemFrom(i):null;let t=a.quantity;if(e){if(e.id!==a.id)throw new Error(`Receiver slot ${i} contains a different item.`);const r=Pr.getItem(e.id).maxStack-e.quantity;t=Math.min(r,a.quantity),t>0&&this.#Pn.setItem({slotIndex:i,item:{...e,quantity:e.quantity+t},forceSpace:n})}else this.#Pn.setItem({slotIndex:i,item:a,forceSpace:n});l={remaining:a.quantity-t}}else l=this.#Pn.addItem({itemId:a.id,quantity:a.quantity,metadata:a.metadata,forceSpace:n});const u=a.quantity-l.remaining;if(u>0)if(t)this.#Rn.unequipItem({slotId:t,quantity:u,forceSpace:n});else if("number"==typeof e){const t=o.quantity-u;this.#Rn.setItem({slotIndex:e,item:t>0?{...o,quantity:t}:null,forceSpace:n})}return l}transferMultiple(e){return e.map(e=>this.transferItem(e))}},Hr=class{#$n;#vt={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.#vt.storageKey);return e?JSON.parse(e):{}}get config(){return{...this.#vt,categories:[...this.#vt.categories]}}set config(e){this.validateConfig(e),this.#vt=Object.assign(this.#vt,e)}constructor(e){if(!e||"object"!=typeof e)throw new TypeError("Config must be an object.");this.config=e;const t=this.loadPreferences();this.#$n=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.#vt.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.#vt.animationDuration)}savePreferences(e){if(!e||"object"!=typeof e)throw new TypeError("Preferences must be an object.");localStorage.setItem(this.#vt.storageKey,JSON.stringify(e)),this.#vt.onSave(e)}showConsentBar(){const e=document.createElement("div");e.className="cookie-consent-bar",e.innerHTML=this.#vt.renderBar?this.#vt.renderBar(this.#vt):`\n <div><p>${this.#vt.message}</p></div>\n <div><button class="accept">${this.#vt.acceptText}</button></div>\n <div><button class="reject">${this.#vt.rejectText}</button></div>\n <div><button class="settings">${this.#vt.settingsText}</button></div>\n `,document.body.appendChild(e);const t=e.querySelector(".accept");t instanceof HTMLElement&&(t.onclick=()=>{const t={};this.#vt.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.#vt.categories.forEach(e=>t[e.label]=e.required),this.savePreferences(t),this.removeWithAnimation(e)});const i=e.querySelector(".settings");i instanceof HTMLElement&&(i.onclick=()=>this.showSettingsModal(e))}showSettingsModal(e){const t=document.createElement("div");t.className="cookie-consent-modal",t.innerHTML=this.#vt.renderModal?this.#vt.renderModal(this.#vt):`\n <div class="modal-content">\n <h2>Cookie Settings</h2>\n <form class="settings-form">\n ${this.#vt.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.#$n&&!!this.#$n[e]}};var Or=r(911),Fr=r(766);const Br=Y("TinyI18"),zr=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 i={};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,Fr.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(i,r)}await(0,Or.writeFile)(t,JSON.stringify(i,null,r),"utf-8")}#h=!1;get destroyed(){return this.#h}#Hn;#On;#Fn=null;#Bn;#zn=null;#Wn=new Map;#qn=new Map;#Vn=new Map;#Kn=new Map;get currentLocale(){return Br(this.#h),this.#Fn}get defaultLocale(){return Br(this.#h),this.#On}get mode(){return Br(this.#h),this.#Hn}get strict(){return Br(this.#h),this.#Bn}get basePath(){return Br(this.#h),this.#zn}get stats(){Br(this.#h);const e=[];for(const t of this.#Wn.keys())e.push(this.getStatsForLocale(t));return e}get stringTables(){Br(this.#h);const e={};for(const[t,r]of this.#Wn.entries())e[t]=this.#Jn(r);return e}get patternTables(){Br(this.#h);const e={};for(const[t,r]of this.#qn.entries())e[t]=r.map(e=>({$pattern:new RegExp(e.$pattern.source,e.$pattern.flags),value:this.#Jn(e.value),elseValue:this.#Jn(e.elseValue)}));return e}get helpers(){Br(this.#h);const e={};for(const[t,r]of this.#Vn.entries())e[t]=r;return e}get regexCache(){Br(this.#h);const e={};for(const[t,r]of this.#Kn.entries())e[t]=new RegExp(r.source,r.flags);return e}#Jn(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.#Jn(e));if("object"==typeof e){const t={};for(const[r,i]of Object.entries(e))t[r]=this.#Jn(i);return t}return e}#Un(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.#Wn.has(e)?t.push(e):this.#Fn&&t.push(this.#Fn),t.push(this.#On),t}#Gn(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.#Wn.get(r);if(e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}}#Yn(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.#qn.get(r)||[];for(const r of e)return r.$pattern.test(t)?r.value:r.elseValue??void 0}}#Xn(e,t){if(null==e){if(this.#Bn)throw new TypeError('#materialize: "value" cannot be null or undefined');return""}if("string"==typeof e)return this.#Qn(e,t);if("function"==typeof e)return e(t??{},this.#Zn());if(e&&"object"==typeof e&&"string"==typeof e.$fn){const r=this.#Vn.get(e.$fn);if("function"!=typeof r){if(this.#Bn)throw new Error(`TinyI18: helper "${e.$fn}" is not registered`);return""}return r({...t??{},args:void 0!==e.args?e.args:void 0},this.#Zn())}if(this.#Bn)throw new Error("TinyI18: unsupported entry type");return""}#Qn(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 i=this.#es(t,r);return null==i?"":String(i)}):e}#es(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 i=e;for(const e of r){if(null==i)return;i=i[e]}return i}#Zn(){return{has:e=>this.#Vn.has(e),call:(e,t,r)=>{const i=this.#Vn.get(e);if("function"!=typeof i)throw new Error(`Helper "${e}" not found`);return i(t,r??{})}}}#ts(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.#Wn.get(e)??{}},i=[...this.#qn.get(e)??[]],n=(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 i.push({$pattern:t.$pattern,value:t.value,elseValue:t.elseValue});for(const[r,i]of Object.entries(t))n(e?`${e}.${r}`:r,i)}};n("",t),this.#Wn.set(e,r),this.#qn.set(e,i),this.#Wn.has(this.#On)||(this.#Wn.set(this.#On,{}),this.#qn.set(this.#On,[]))}#rs(e){if("string"!=typeof e||!e)throw new TypeError('#unloadLocale: "locale" must be a non-empty string');e!==this.#On&&(this.#Wn.delete(e),this.#qn.delete(e))}async#is(e){if("string"!=typeof e||!e)throw new TypeError('#loadLocaleFromFile: "locale" must be a non-empty string');if("string"!=typeof this.#zn||!this.#zn)throw new TypeError('#loadLocaleFromFile: "this.#basePath" must be a non-empty string');const t=(0,fe.join)(this.#zn,`${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.#Bn)throw new Error(`TinyI18: failed to load or parse ${t}: ${r.message}`);return this.#Wn.set(e,{}),void this.#qn.set(e,[])}const i={...this.#Wn.get(e)??{}},n=[...this.#qn.get(e)??[]],s=(e,t)=>{if(null!=t){if(t&&"object"==typeof t&&"string"==typeof t.$pattern&&Object.prototype.hasOwnProperty.call(t,"value")){const e=this.#ns(t.$pattern);return void n.push({$pattern:e,value:this.#ss(t.value),elseValue:this.#ss(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");i[e]=this.#ss(t)}else if(t&&"object"==typeof t)for(const[r,i]of Object.entries(t))s(e?`${e}.${r}`:r,i)}};s("",r),this.#Wn.set(e,i),this.#qn.set(e,n)}#ns(e){if("string"!=typeof e||!e)throw new TypeError('#safeRegExp: "src" must be a non-empty string');const t=this.#Kn.get(e);if(t)return t;try{const t=new RegExp(e);return this.#Kn.set(e,t),t}catch{if(this.#Bn)throw new Error(`TinyI18: invalid regex "${e}" in file`);return/^$/}}#ss(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.#Bn)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:i,localResources:n,strict:s=!0}=e;if("local"!==t&&"file"!==t)throw new TypeError('TinyI18: "mode" must be "local" or "file"');if("string"!=typeof r||!r)throw new TypeError('TinyI18: "defaultLocale" must be a non-empty string');if("boolean"!=typeof s)throw new TypeError('TinyI18: "strict" must be a boolean');if("file"===t){if("string"!=typeof i||!i)throw new TypeError('TinyI18: "basePath" is required in file mode');this.#zn=i}if(this.#Hn=t,this.#On=r,this.#Bn=s,"local"===t&&n&&"object"==typeof n)for(const[e,t]of Object.entries(n))this.#ts(e,t);this.#Wn.has(this.#On)||(this.#Wn.set(this.#On,{}),this.#qn.set(this.#On,[]))}clearRegexCache(){Br(this.#h),this.#Kn.clear()}registerHelper(e,t){if(Br(this.#h),"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.#Vn.set(e,t)}unregisterHelper(e){if(Br(this.#h),"string"!=typeof e||!e)throw new TypeError('unregisterHelper: "name" must be non-empty string');return this.#Vn.delete(e)}loadLocaleLocal(e,t){if(Br(this.#h),"local"!==this.#Hn)throw new TypeError('loadLocaleLocal is only available in "local" mode');this.#ts(e,t)}async setLocale(e){if(Br(this.#h),null!==e&&("string"!=typeof e||!e))throw new TypeError('setLocale: "locale" must be string or null');const t=this.#Fn;null!==e&&("file"===this.#Hn?await this.#is(e):this.#Wn.has(e)||(this.#Wn.set(e,{}),this.#qn.set(e,[]))),"file"===this.#Hn&&t&&t!==this.#On&&t!==e&&this.#rs(t),this.#Fn=e}t(e,t=void 0,r=void 0){return this.get(e,t,r)}get(e,t=void 0,r=void 0){if(Br(this.#h),"string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:i}=r||{},n=this.#Un(i);let s=this.#Gn(n,e);if(void 0===s){if(this.#Bn)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return this.#Xn(s,t)}p(e,t){return this.resolveByPattern(e,t)}resolveByPattern(e,t){if(Br(this.#h),"string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:r}=t||{},i=this.#Un(r);let n=this.#Yn(i,e);if(void 0===n){if(this.#Bn)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return n}resetToDefaultOnly(){if(Br(this.#h),"file"===this.#Hn)for(const e of Array.from(this.#Wn.keys()))e!==this.#On&&this.#rs(e);this.#Fn=null}getStatsForLocale(e){if(Br(this.#h),"string"!=typeof e||!e)throw new TypeError('getStatsForLocale: "locale" must be a non-empty string');if(!this.#Wn.has(e))throw new Error(`getStatsForLocale: locale "${e}" is not registered`);return{locale:e,strings:Object.keys(this.#Wn.get(e)??{}).length,patterns:this.#qn.get(e)?.length??0,isDefault:e===this.#On,isCurrent:e===this.#Fn}}destroy(){this.#h||(this.#Wn.clear(),this.#qn.clear(),this.#Vn.clear(),this.#Kn.clear(),this.#Fn=null,this.#zn=null,this.#h=!0)}};class Wr{#os=new Map;#as;#ls;#us;get factors(){const e={};for(let[t,r]of this.#os.entries())e[t]={...r};return e}get currentPercent(){return this.#ls/this.#as*100}set maxValue(e){if("number"!=typeof e||Number.isNaN(e)||e<=0)throw new TypeError("maxValue must be a positive number.");this.#as=e,this.#ls=Math.min(this.#ls,e)}get maxValue(){return this.#as}get currentValue(){return this.#ls}set infiniteValue(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("infiniteValue must be a number.");this.#us=e,this.#ls=Math.max(0,e),this.#ls=Math.min(this.#ls,this.#as)}get infiniteValue(){return this.#us}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.#as=e,this.setFactor("main",t,r),this.#ls=e,this.#us=e}getFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");const t=this.#os.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.#os.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.#os.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.#os.delete(e)}#hs(e){const t=this.#us;return this.#us-=e,this.#ls=Math.max(0,this.#ls-e),{prevValue:t,removedTotal:e,removedPercent:e/this.#as*100,currentPercent:this.currentPercent,remainingValue:this.#ls,infiniteRemaining:this.#us}}tick(){let e=0;for(let[t,r]of this.#os.entries())e+=r.amount*r.multiplier;return this.#hs(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.#os.entries())t+=r.amount*r.multiplier;return e&&(t+=e.amount*(e.multiplier??1)),this.#hs(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.#hs(t)}toJSON(){return{maxValue:this.#as,currentValue:this.#ls,infiniteValue:this.#us,factors:this.factors}}static fromJSON(e){const t=new Wr(e.maxValue,0,0);t.infiniteValue=e.infiniteValue,t.#os.clear();for(const[r,i]of Object.entries(e.factors))t.setFactor(r,i.amount,i.multiplier);return t}clone(){return Wr.fromJSON(this.toJSON())}clearFactors(){this.#os.clear()}}const qr=Wr;class Vr{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,i)=>{const n=i?Number(i):1;let s=0;for(let e=0;e<n;e++){const e=t[r++];s+=void 0!==e?e:0}return String(s)})}static tokenizeValues(e,t){const r=Vr.replaceValues(e,t),i=[],n=/\d+|[()+\-*/]/g;let s;for(;null!==(s=n.exec(r));)/^\d+$/.test(s[0])?i.push(Number(s[0])):i.push(s[0]);return{tokens:i,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=[],i=[];if(t.forEach((e,t)=>{const n=/\b(?:(\d+)?d(\d+))\b/g;let s;const o=[],a=e.replace(/\(([^()]+?\|[^()]+?)\)/g,(e,t)=>{const r="string"==typeof t?t.split("|").map(e=>e.trim()).filter(Boolean):[];if(0===r.length)throw new Error(`Invalid random-choice group: "${e}"`);return r[Math.floor(Math.random()*r.length)]});for(;null!==(s=n.exec(a));){const e=parseInt(s[1]||"1",10),r=parseInt(s[2],10);if(isNaN(r))throw new Error(`Invalid dice sides in expression "${s[0]}" at position ${t+1}.`);o.push({count:e,sides:r})}if(0===o.length&&Number.isNaN(parseFloat(a)))throw new Error(`Invalid dice expression at position ${t+1}: "${e}"`);r.push(...o),i.push({index:t,original:e,expression:a})}),0===r.length)throw new Error("Invalid dice amount.");return{sides:r,modifiers:i}}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 i=[],n=[...e];for(const e in t){const s=t[e];if("string"!=typeof s.expression)throw new Error("Each modifier must include an expression string.");const o=s.original,a=s.expression,l=[],u=[],h=[],c=e=>e.match(/\(\s*[^()]+\|\s*[^()]+\s*\)|\b\d*d\d+\b|[-+]?\d+(?:\.\d+)?|[+\-*/%^()]/g)||[],d=c(a),m=c(o),p=[...d],y=[],g=a.replace(/\b\d*d\d+\b/g,e=>{const t=e.split("d"),r=()=>{for(const t in d)if(d[t]===e&&y.indexOf(t)<0){y.push(t),h.push(Number(t));break}},i=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=n.shift(),s="number"==typeof t?t:f(t)?t.value:0;f(t)&&i(t),l.push([s]);for(const t in p)if(p[t]===e){p[t]=String(s),u.push(Number(t));break}return r(),s}const s=[],o=Number(t[0]),a=["("];let c="(";for(let e=0;e<o;e++){const t=n.shift(),r="number"==typeof t?t:f(t)?t.value:0;f(t)&&i(t),a.push(String(r));const l=e<o-1?" + ":")";a.push(l),c+=`${r}${l}`,s.push(r)}for(const t in p){const r=Number(t);if(p[r]===e){p.splice(r,1,...a);let e=1;for(let t=0;t<o;t++)u.push(r+t+e),e++;break}}return l.push(s),r(),c});let w;try{w=Vr._safeEvaluate(g)}catch(e){if(!(e instanceof Error))throw new Error("Unknown Error");throw new Error(`Error evaluating expression "${g}" (from "${a}"): ${e.message}`)}i.push({rawTokensP:d,rawTokens:m,tokens:p,rawDiceTokenSlots:h,diceTokenSlots:u,dicesResult:l,total:w}),r+=w}return{final:r,steps:i}}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))}#as;#cs;get maxValue(){return this.#as}set maxValue(e){if(!Number.isInteger(e)||e<0)throw new TypeError("maxValue must be an integer greater than -1.");this.#as=e}get allowZero(){return this.#cs}set allowZero(e){if("boolean"!=typeof e)throw new TypeError("allowZero must be a boolean.");this.#cs=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.#as=e,this.#cs=t}roll(){const e=this.#cs?0:1;return Math.floor(Math.random()*(this.#as-e+1))+e}}const Kr=Vr,Jr=class{#S=null;get overlay(){return this.#S}#ds=null;get messageElement(){return this.#ds}#P;get container(){return this.#P}#ms={fadeIn:null,fadeOut:null,zIndex:9999};get options(){return{...this.#ms}}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.#ms={fadeIn:e.fadeIn??null,fadeOut:e.fadeOut??null,zIndex:e.zIndex??9999}}#ps="none";get status(){return this.#ps}#fs="";get defaultMessage(){return this.#fs}set defaultMessage(e){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("defaultMessage must be a string or an HTMLElement");this.#fs=e}#ys=null;get message(){return this.#ys}#gs=!1;get allowHtmlText(){return this.#gs}set allowHtmlText(e){if("boolean"!=typeof e)throw new TypeError("allowHtmlText must be a boolean");this.#gs=e}#ws=null;get fadeInTimeout(){return null!==this.#ws}#bs=null;get fadeOutTimeout(){return null!==this.#bs}get visible(){return!!this.#S}#vs=null;get onChange(){return this.#vs}set onChange(e){if(null!==e&&"function"!=typeof e)throw new TypeError("onChange must be a function or null");this.#vs=e}_emitChange(){"function"==typeof this.#vs&&this.#vs(this.#ps)}constructor(e=document.body){if(!(e instanceof HTMLElement))throw new TypeError("container must be an HTMLElement");this.#P=e}_updateMessage(e=this.#fs){if(!this.#ds)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.#ys=e,"string"==typeof e)this.#gs?this.#ds.innerHTML=e:this.#ds.textContent=e;else{if(!this.#gs)throw new Error("HTMLElement messages require allowHtmlText = true");this.#ds.textContent="",this.#ds.appendChild(e)}}_removeOldClasses(){this.#S?.classList.remove("active"),this.#S?.classList.remove("fadeIn"),this.#S?.classList.remove("fadeOut")}start(e=this.#fs){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");if(!this.#S){this.#S=document.createElement("div"),this.#S.classList.add("loading-overlay"),this.#S.style.zIndex=String(this.#ms.zIndex);const t=document.createElement("div");t.classList.add("loading-container");const r=document.createElement("div");r.classList.add("loading-content");const i=document.createElement("div");i.classList.add("loading-spinner"),this.#ds=document.createElement("div"),this.#ds.classList.add("loading-message"),r.appendChild(i),r.appendChild(this.#ds),t.appendChild(r),this.#S.appendChild(t),this.#P.appendChild(this.#S),this._removeOldClasses(),this.#ps="fadeIn",this.#S.classList.add("fadeIn"),this._emitChange();const n=()=>{this._removeOldClasses(),this.#ws=null,this.#ps="active",this.#S?.classList.add("active"),this._emitChange()};return"number"==typeof this.#ms.fadeIn?(this.#ws&&clearTimeout(this.#ws),this.#ws=setTimeout(n,this.#ms.fadeIn)):n(),this._updateMessage(e),!0}return this.#ds&&this._updateMessage(e),!1}update(e=this.#fs){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");return!!this.#ds&&(this._updateMessage(e),!0)}stop(){if(this.#S){this._removeOldClasses(),this.#ps="fadeOut",this.#S.classList.add("fadeOut"),this._emitChange();const e=()=>{this._removeOldClasses(),this.#bs=null,this.#ps="none",this.#S?.remove(),this.#S=null,this.#ds=null,this.#ys=null,this._emitChange()};return"number"==typeof this.#ms.fadeOut?(this.#bs&&clearTimeout(this.#bs),this.#bs=setTimeout(e,this.#ms.fadeOut)):e(),!0}return!1}};class Ur{static#Es=/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;static#Ts=/^#([A-Fa-f0-9]{8})$/;static#Ss="(0|1|0?\\.\\d+)";static#xs="(0|[1-9]\\d?|1\\d{2}|2[0-4]\\d|25[0-5])";static#As="(0|[1-9]\\d?|[1-2]\\d{2}|3[0-5]\\d|360)";static#Cs="(0|[1-9]?\\d|100)";static#Is=new RegExp(`^rgb\\(\\s*${Ur.#xs}\\s*,\\s*${Ur.#xs}\\s*,\\s*${Ur.#xs}\\s*\\)$`);static#Ds=new RegExp(`^rgba\\(\\s*${Ur.#xs}\\s*,\\s*${Ur.#xs}\\s*,\\s*${Ur.#xs}\\s*,\\s*${Ur.#Ss}\\s*\\)$`);static#Ms=new RegExp(`^hsl\\(\\s*${Ur.#As}\\s*,\\s*${Ur.#Cs}%\\s*,\\s*${Ur.#Cs}%\\s*\\)$`);static#Ns=new RegExp(`^hsla\\(\\s*${Ur.#As}\\s*,\\s*${Ur.#Cs}%\\s*,\\s*${Ur.#Cs}%\\s*,\\s*${Ur.#Ss}\\s*\\)$`);static#ks=new RegExp(`^hwb\\(\\s*${Ur.#As}(deg|grad|rad|turn)?\\s*${Ur.#Cs}%\\s*${Ur.#Cs}%\\s*\\)$`);static#Ls="(-?\\d+)";static#_s=new RegExp(`^lab\\(\\s*${Ur.#Cs}%?\\s*${Ur.#Ls}%?\\s*${Ur.#Ls}%?\\s*\\)$`);static#js=new RegExp(`^lch\\(\\s*${Ur.#Cs}%?\\s*${Ur.#Cs}%?\\s*${Ur.#As}(deg|grad|rad|turn)?\\s*\\)$`);static#Rs=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#Ps=new Set(["transparent","currentColor"]);static getNames(){return Array.from(Ur.#Rs)}static addName(e){const t=Ur.#Rs.size;return Ur.#Rs.add(e.toLowerCase()),Ur.#Rs.size>t}static removeName(e){return Ur.#Rs.delete(e.toLowerCase())}static hasName(e){return Ur.#Rs.has(e.toLowerCase())}static getSpecialNames(){return Array.from(Ur.#Ps)}static addSpecialName(e){const t=Ur.#Ps.size;return Ur.#Ps.add(e),Ur.#Ps.size>t}static removeSpecialName(e){return Ur.#Ps.delete(e)}static hasSpecialName(e){return Ur.#Ps.has(e)}#$s;get code(){return this.#$s}#Hs;get type(){return this.#Hs}constructor(e){this.#$s=e,this.#Hs=Ur.isColor(this.#$s)}static isHex(e){if("string"!=typeof e)throw new TypeError("isHex: input must be a string.");return Ur.#Es.test(e.trim())}isHex(){return Ur.isHex(this.#$s)}static isHexa(e){if("string"!=typeof e)throw new TypeError("isHexa: input must be a string.");return Ur.#Ts.test(e.trim())}isHexa(){return Ur.isHexa(this.#$s)}static isRgb(e){if("string"!=typeof e)throw new TypeError("isRgb: input must be a string.");return Ur.#Is.test(e.trim())}isRgb(){return Ur.isRgb(this.#$s)}static isRgba(e){if("string"!=typeof e)throw new TypeError("isRgba: input must be a string.");return Ur.#Ds.test(e.trim())}isRgba(){return Ur.isRgba(this.#$s)}static isHsl(e){if("string"!=typeof e)throw new TypeError("isHsl: input must be a string.");return Ur.#Ms.test(e.trim())}isHsl(){return Ur.isHsl(this.#$s)}static isHsla(e){if("string"!=typeof e)throw new TypeError("isHsla: input must be a string.");return Ur.#Ns.test(e.trim())}isHsla(){return Ur.isHsla(this.#$s)}static isHwb(e){if("string"!=typeof e)throw new TypeError("isHwb: input must be a string.");return Ur.#ks.test(e.trim())}isHwb(){return Ur.isHwb(this.#$s)}static isLab(e){if("string"!=typeof e)throw new TypeError("isLab: input must be a string.");return Ur.#_s.test(e.trim())}isLab(){return Ur.isLab(this.#$s)}static isLch(e){if("string"!=typeof e)throw new TypeError("isLch: input must be a string.");return Ur.#js.test(e.trim())}isLch(){return Ur.isLch(this.#$s)}static isName(e){if("string"!=typeof e)throw new TypeError("isName: input must be a string.");return Ur.#Rs.has(e.trim().toLowerCase())}isName(){return Ur.isName(this.#$s)}static isSpecialName(e){if("string"!=typeof e)throw new TypeError("isSpecialName: input must be a string.");return Ur.#Ps.has(e.trim())}isSpecialName(){return Ur.isSpecialName(this.#$s)}static isColor(e){if("string"!=typeof e)throw new TypeError("isColor: input must be a string.");return Ur.isHex(e)?"hex":Ur.isHexa(e)?"hexa":Ur.isRgb(e)?"rgb":Ur.isRgba(e)?"rgba":Ur.isHsl(e)?"hsl":Ur.isHsla(e)?"hsla":Ur.isHwb(e)?"hwb":Ur.isLab(e)?"lab":Ur.isLch(e)?"lch":Ur.isName(e)?"name":Ur.isSpecialName(e)?"specialName":null}parse(){switch(this.#Hs){case"hex":return Ur.parseHex(this.code);case"hexa":return Ur.parseHexa(this.code);case"rgb":return Ur.parseRgb(this.code);case"rgba":return Ur.parseRgba(this.code);case"hsl":return Ur.parseHsl(this.code);case"hsla":return Ur.parseHsla(this.code);case"hwb":return Ur.parseHwb(this.code);case"lab":return Ur.parseLab(this.code);case"lch":return Ur.parseLch(this.code);case"name":case"specialName":return this.#$s.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(Ur.#Es,"gm").exec(e.trim());return t?t[1]:null}parseHex(){return Ur.parseHex(this.#$s)}static parseHexa(e){if("string"!=typeof e)throw new TypeError("parseHexa: input must be a string.");const t=new RegExp(Ur.#Ts,"gm").exec(e.trim());return t?t[1]:null}parseHexa(){return Ur.parseHexa(this.#$s)}static parseRgb(e){if("string"!=typeof e)throw new TypeError("parseRgb: input must be a string.");const t=new RegExp(Ur.#Is,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseRgb(){return Ur.parseRgb(this.#$s)}static parseRgba(e){if("string"!=typeof e)throw new TypeError("parseRgba: input must be a string.");const t=new RegExp(Ur.#Ds,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])]:null}parseRgba(){return Ur.parseRgba(this.#$s)}static parseHsl(e){if("string"!=typeof e)throw new TypeError("parseHsl: input must be a string.");const t=new RegExp(Ur.#Ms,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseHsl(){return Ur.parseHsl(this.#$s)}static parseHsla(e){if("string"!=typeof e)throw new TypeError("parseHsla: input must be a string.");const t=new RegExp(Ur.#Ns,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])]:null}parseHsla(){return Ur.parseHsla(this.#$s)}static parseHwb(e){if("string"!=typeof e)throw new TypeError("parseHwb: input must be a string.");const t=new RegExp(Ur.#ks,"gm").exec(e.trim());return t?[parseFloat(t[1]),t[2]??null,parseFloat(t[3]),parseFloat(t[4])]:null}parseHwb(){return Ur.parseHwb(this.#$s)}static parseLab(e){if("string"!=typeof e)throw new TypeError("parseLab: input must be a string.");const t=new RegExp(Ur.#_s,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseLab(){return Ur.parseLab(this.#$s)}static parseLch(e){if("string"!=typeof e)throw new TypeError("parseLch: input must be a string.");const t=new RegExp(Ur.#js,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),t[4]??null]:null}parseLch(){return Ur.parseLch(this.#$s)}}const Gr=Ur,Yr=Y("TinyAnalogClock"),Xr=class{#Os;#Fs;#Bs;#vt;#oi=null;#h=!1;get destroyed(){return this.#h}_getDate(){const e=new Date,t=e.getSeconds(),r=e.getMinutes(),i=e.getHours();return{now:e,s:t,m:r,h:i}}constructor(e={}){this.#vt={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.#Os=document.createElement("div"),this.#Os.className="analog-clock-container",this.#Os.style.position="relative",this.#Os.style.borderRadius="50%",this.#Os.style.overflow="hidden",this.#Os.style.boxSizing="border-box",this.#Bs=document.createElement("div"),this.#Bs.style.position="absolute",this.#Bs.style.inset="0",this.#Bs.style.backgroundSize="cover",this.#Bs.style.backgroundPosition="center",this.#Bs.style.zIndex="0",this.#Fs=document.createElement("div"),this.#Fs.style.position="absolute",this.#Fs.style.inset="0",this.#Fs.style.zIndex="1",this.#Fs.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.#Os.appendChild(this.#Bs),this.#Os.appendChild(this.#Fs),this.#Os.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.#Os.appendChild(r),this._applyConfig(),this._renderFace(),this._startTicker()}_applyConfig(){const e=this.#Os.style,t=this.#vt;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.#Bs.style.backgroundImage=`url(${t.skinUrl})`,this.#Bs.style.display="block"):this.#Bs.style.display="none";const r=e=>{const t=this.#Os.querySelector(e);if(!(t instanceof HTMLDivElement))throw new Error(`TinyAnalogClock: Element ${e} not found.`);return t},i=r(".hour-hand");i.style.backgroundColor=t.hourHandColor,i.style.width=.025*t.size+"px",i.style.height=.25*t.size+"px",i.style.marginLeft=.025*t.size/-2+"px",i.style.bottom="50%",i.style.left="50%",i.style.transformOrigin="bottom center";const n=r(".minute-hand");n.style.backgroundColor=t.minuteHandColor,n.style.width=.015*t.size+"px",n.style.height=.35*t.size+"px",n.style.marginLeft=.015*t.size/-2+"px";const s=r(".second-hand");t.showSeconds?(s.style.display="block",s.style.backgroundColor=t.secondHandColor,s.style.width=.005*t.size+"px",s.style.height=.4*t.size+"px",s.style.marginLeft=.005*t.size/-2+"px"):s.style.display="none",r(".center-pin").style.background=t.borderColor}_renderFace(){this.#Fs.innerHTML="";const e=this.#vt.size/2-this.#vt.borderWidth;for(let t=0;t<60;t++){const r=t%5==0,i=document.createElement("div");i.className="clock-mark";const n=r?this.#vt.size*this.#vt.pwH:this.#vt.size*this.#vt.pwM,s=r?this.#vt.size*this.#vt.phH:this.#vt.size*this.#vt.phM,o=this.#vt.markColor;i.style.width=`${n}px`,i.style.height=`${s}px`,i.style.color=o;const a=e-this.#vt.padding-s/2;i.style.transform=`translate(-50%, -50%) rotate(${6*t}deg) translate(0, -${a}px)`,this.#Fs.appendChild(i)}if(this.#vt.showNumbers)for(let t=1;t<=12;t++){const r=30*t*(Math.PI/180),i=e*this.#vt.angleDistance,n=e+Math.sin(r)*i,s=e-Math.cos(r)*i,o=document.createElement("div");o.className="clock-number",o.innerText=t.toString(),o.style.left=`${n}px`,o.style.top=`${s}px`,o.style.color=this.#vt.textColor,o.style.fontSize=this.#vt.size*this.#vt.sizeAdjust+"px",this.#Fs.appendChild(o)}}_startTicker(){if(this.#oi)return;const e=()=>{const{s:t,m:r,h:i}=this._getDate(),n=6*t,s=6*r+.1*t,o=i%12*30+.5*r,a=e=>{const t=this.#Os.querySelector(e);if(!(t instanceof HTMLDivElement))throw new Error(`${e} not found.`);return t};this.#Os.querySelector(".second-hand")&&(a(".second-hand").style.transform=`rotate(${n}deg)`),a(".minute-hand").style.transform=`rotate(${s}deg)`,a(".hour-hand").style.transform=`rotate(${o}deg)`,this.#oi=requestAnimationFrame(e)};e()}get element(){return Yr(this.#h),this.#Os}set size(e){if(Yr(this.#h),"number"!=typeof e||e<=0||isNaN(e))throw new Error(`TinyAnalogClock: 'size' must be a positive number. Received: ${e}`);this.#vt.size=e,this._applyConfig(),this._renderFace()}get size(){return Yr(this.#h),this.#vt.size}set skinUrl(e){if(Yr(this.#h),null!==e&&"string"!=typeof e)throw new Error("TinyAnalogClock: 'skin' must be a URL string or null. Received type: "+typeof e);this.#vt.skinUrl=e,this._applyConfig()}get skinUrl(){return Yr(this.#h),this.#vt.skinUrl}set borderColor(e){if(Yr(this.#h),"string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'borderColor' must be a non-empty string. Received: ${e}`);this.#vt.borderColor=e,this._applyConfig(),this._renderFace()}get borderColor(){return Yr(this.#h),this.#vt.borderColor}set markColor(e){if(Yr(this.#h),"string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'markColor' must be a non-empty string. Received: ${e}`);this.#vt.markColor=e,this._applyConfig(),this._renderFace()}get markColor(){return Yr(this.#h),this.#vt.markColor}set textColor(e){if(Yr(this.#h),"string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'textColor' must be a non-empty string. Received: ${e}`);this.#vt.textColor=e,this._applyConfig(),this._renderFace()}get textColor(){return Yr(this.#h),this.#vt.textColor}set showNumbers(e){if(Yr(this.#h),"boolean"!=typeof e)throw new Error("TinyAnalogClock: 'showNumbers' must be a boolean. Received type: "+typeof e);this.#vt.showNumbers=e,this._renderFace()}get showNumbers(){return Yr(this.#h),this.#vt.showNumbers}set bgColor(e){if(Yr(this.#h),"string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'bgColor' must be a non-empty string.");this.#vt.bgColor=e,this._applyConfig()}get bgColor(){return Yr(this.#h),this.#vt.bgColor}set borderWidth(e){if(Yr(this.#h),"number"!=typeof e||e<0)throw new Error("TinyAnalogClock: 'borderWidth' must be a non-negative number.");this.#vt.borderWidth=e,this._applyConfig(),this._renderFace()}get borderWidth(){return Yr(this.#h),this.#vt.borderWidth}set hourHandColor(e){if(Yr(this.#h),"string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'hourHandColor' must be a non-empty string.");this.#vt.hourHandColor=e,this._applyConfig()}get hourHandColor(){return Yr(this.#h),this.#vt.hourHandColor}set minuteHandColor(e){if(Yr(this.#h),"string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'minuteHandColor' must be a non-empty string.");this.#vt.minuteHandColor=e,this._applyConfig()}get minuteHandColor(){return Yr(this.#h),this.#vt.minuteHandColor}set secondHandColor(e){if(Yr(this.#h),"string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'secondHandColor' must be a non-empty string.");this.#vt.secondHandColor=e,this._applyConfig()}get secondHandColor(){return Yr(this.#h),this.#vt.secondHandColor}set showSeconds(e){if(Yr(this.#h),"boolean"!=typeof e)throw new Error("TinyAnalogClock: 'showSeconds' must be a boolean.");this.#vt.showSeconds=e,this._applyConfig()}get showSeconds(){return Yr(this.#h),this.#vt.showSeconds}set sizeAdjust(e){if(Yr(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'sizeAdjust' must be a positive number.");this.#vt.sizeAdjust=e,this._renderFace()}get sizeAdjust(){return Yr(this.#h),this.#vt.sizeAdjust}set padding(e){if(Yr(this.#h),"number"!=typeof e||e<0)throw new Error("TinyAnalogClock: 'padding' must be a non-negative number.");this.#vt.padding=e,this._renderFace()}get padding(){return Yr(this.#h),this.#vt.padding}set angleDistance(e){if(Yr(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'angleDistance' must be a positive number.");this.#vt.angleDistance=e,this._renderFace()}get angleDistance(){return Yr(this.#h),this.#vt.angleDistance}set pwH(e){if(Yr(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'pwH' must be a positive number.");this.#vt.pwH=e,this._renderFace()}get pwH(){return Yr(this.#h),this.#vt.pwH}set phH(e){if(Yr(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'phH' must be a positive number.");this.#vt.phH=e,this._renderFace()}get phH(){return Yr(this.#h),this.#vt.phH}set pwM(e){if(Yr(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'pwM' must be a positive number.");this.#vt.pwM=e,this._renderFace()}get pwM(){return Yr(this.#h),this.#vt.pwM}set phM(e){if(Yr(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'phM' must be a positive number.");this.#vt.phM=e,this._renderFace()}get phM(){return Yr(this.#h),this.#vt.phM}destroy(){this.#h||(this.#oi&&(cancelAnimationFrame(this.#oi),this.#oi=null),this.#Os.remove(),this.#h=!0)}},Qr=Y("TinyTextDiffer"),Zr=class{#zs=[];#h=!1;get destroyed(){return this.#h}get history(){return Qr(this.#h),[...this.#zs]}set history(e){if(Qr(this.#h),!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.#zs=[...e]}get size(){return Qr(this.#h),this.#zs.length}constructor(e=[]){this.history=e}#Ws(e){if("number"!=typeof e)throw new TypeError("The provided index must be a valid number.")}#qs(e){if("string"!=typeof e)throw new TypeError("The provided text must be a valid string.")}get(e){if(Qr(this.#h),this.#Ws(e),void 0===this.#zs[e])throw new Error(`No text version found at index ${e}.`);return this.#zs[e]}has(e){return Qr(this.#h),this.#Ws(e),void 0!==this.#zs[e]}add(e){Qr(this.#h),this.#qs(e),this.#zs.push(e)}remove(){return Qr(this.#h),this.#zs.pop()}addAt(e,t){Qr(this.#h),this.#Ws(e),this.#qs(t),this.#zs.splice(e,0,t)}removeAt(e){Qr(this.#h),this.#Ws(e);const t=this.#zs.length;return this.#zs.splice(e,1),t!==this.#zs.length}clear(){Qr(this.#h),this.#zs=[]}compare(...e){Qr(this.#h);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 i=0;i<t;i+=2){const n=i+1;if(n>t-1)continue;this.#Ws(e[i]),this.#Ws(e[n]);const s=this.#zs[e[i]],o=this.#zs[e[n]];r.push(this._computeDiff(s,o))}return r}_computeDiff(e,t){const r=e.length,i=t.length,n=Array(r+1).fill(null).map(()=>Array(i+1).fill(0));let s=1,o=1;for(s=1;s<=r;s++)for(o=1;o<=i;o++)e[s-1]===t[o-1]?n[s][o]=n[s-1][o-1]+1:n[s][o]=Math.max(n[s-1][o],n[s][o-1]);s=r,o=i;const a=[];for(;s>0||o>0;)s>0&&o>0&&e[s-1]===t[o-1]?(a.unshift({value:e[s-1],type:"normal"}),s--,o--):o>0&&(0===s||n[s][o-1]>=n[s-1][o])?(a.unshift({value:t[o-1],type:"added"}),o--):s>0&&(0===o||n[s][o-1]<n[s-1][o])&&(a.unshift({value:e[s-1],type:"deleted"}),s--);return a.reduce((e,t)=>{const r=e.length-1;return e.length>0&&e[r].type===t.type?e[r].value+=t.value:e.push(t),e},[])}destroy(){this.#h||(this.#zs=[],this.#h=!0)}};class ei{static generateHash(e){const t="object"==typeof e?JSON.stringify(e):String(e);let r=0;for(let e=0,i=t.length;e<i;e++)r=(r<<5)-r+t.charCodeAt(e),r|=0;return r.toString(36)}#Vs=[];get oldArray(){return this.#Vs}set oldArray(e){if(!Array.isArray(e))throw new TypeError("The provided oldArray must be a valid Array.");this.#Vs=e}constructor(e){void 0!==e&&(this.oldArray=e)}_generateHash(e){return ei.generateHash(e)}compare(e){if(!Array.isArray(e))throw new TypeError("The provided newArray must be a valid Array.");const t={oldItemsMap:new Map,affectedItems:[]};for(const e of this.#Vs){const r=this._generateHash(e);t.oldItemsMap.set(r,e)}for(const r of e){const e=this._generateHash(r);t.oldItemsMap.has(e)?t.oldItemsMap.delete(e):t.affectedItems.push({item:r,status:"added"})}for(const e of t.oldItemsMap.values())t.affectedItems.push({item:e,status:"deleted"});return t.affectedItems}}const ti=ei,ri=e=>{if(!Array.isArray(e))throw new TypeError("Parameter 'sets' must be an array.");if(!e.every(e=>e instanceof oi))throw new TypeError("All elements in the array must be instances of FuzzySet.")},ii=(e,t,r=.5)=>{si(e,"object","defuzzifyCentroid.fuzzyOutput");for(const t in e)si(e[t],"number",`fuzzyOutput['${t}']`);ri(t),si(r,"number","defuzzifyCentroid.step");let i=0,n=0;for(let s=0;s<=100;s+=r){let r=0;t.forEach(t=>{const i=e[t.name]||0,n=Math.min(i,t.calculate(s));r=Math.max(r,n)}),i+=s*r,n+=r}return 0===n?0:i/n},ni=(e,t,r,i,n,s=!1)=>{if(s){if(e<=t||e>=n)return 0;if(e>=r&&e<=i)return 1}const o=t===r?1:(e-t)/(r-t),a=i===n?1:(n-e)/(n-i),l=Math.max(0,Math.min(o,1,a));return isNaN(l)?0:l},si=(e,t,r)=>{if(typeof e!==t)throw new TypeError(`Parameter '${r}' must be a ${t}.`)};class oi{static trapezoid(e,t,r,i,n,s=!1){return ni(e,t,r,i,n,s)}#Ks="";#Js=0;#Us=0;#Gs=0;#Ys=0;#Xs=!1;get name(){return this.#Ks}set name(e){si(e,"string","FuzzySet.name"),this.#Ks=e}get a(){return this.#Js}set a(e){si(e,"number","FuzzySet.a"),this.#Js=e}get b(){return this.#Us}set b(e){si(e,"number","FuzzySet.b"),this.#Us=e}get c(){return this.#Gs}set c(e){si(e,"number","FuzzySet.c"),this.#Gs=e}get d(){return this.#Ys}set d(e){si(e,"number","FuzzySet.d"),this.#Ys=e}get optimize(){return this.#Xs}set optimize(e){si(e,"boolean","FuzzySet.optimize"),this.#Xs=e}constructor(e,t,r,i,n,s=!1){this.name=e,this.a=t,this.b=r,this.c=i,this.d=n,this.optimize=s}calculate(e){return si(e,"number","calculate.x"),oi.trapezoid(e,this.#Js,this.#Us,this.#Gs,this.#Ys,this.#Xs)}}class ai{#Qs=new Map;addVariable(e,t){si(e,"string","addVariable.name"),ri(t),this.#Qs.set(e,t)}removeVariable(e){return si(e,"string","removeVariable.name"),this.#Qs.delete(e)}getVariable(e){si(e,"string","getVariable.name");const t=this.#Qs.get(e);if(!t)throw new Error(`Linguistic variable '${e}' not found in the inference system.`);return[...t]}hasVariable(e){return si(e,"string","hasVariable.name"),this.#Qs.has(e)}fuzzify(e,t){si(e,"string","fuzzify.varName"),si(t,"number","fuzzify.value");const r=this.#Qs.get(e)||[],i={};return r.forEach(e=>{i[e.name]=e.calculate(t)}),i}}class li{#Zs=new Set;get appliedPlugins(){if(this.#eo)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return[...this.#Zs]}#to=[];get appliedPluginClasses(){if(this.#eo)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return[...this.#to]}get size(){if(this.#eo)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return this.#to.length}#ro;get currentClass(){if(this.#eo)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return this.#ro}#eo=!1;get used(){return this.#eo}constructor(e,t=[]){this.#ro=e,this.#to=[...t,e]}#io(e,t,r){if(this.#eo)throw new Error("[TinyClassManager] Cannot reuse a consumed manager instance.");if(this.#Zs.has(e))throw new Error(`[TinyClassManager] Plugin conflict: "${e}" is already installed.`);for(const r of t)if(!this.#Zs.has(r))throw new Error(`[TinyClassManager] Missing Dependency: "${e}" requires "${r}" to be installed first.`);const i=new li(r,this.#to);return this.#Zs.forEach(e=>i.#Zs.add(e)),i.#Zs.add(e),this.#eo=!0,this.#Zs.clear(),this.#to=[],i}use(e){const t=e.dependencies||[],r=e.apply(this.#ro,this.appliedPluginClasses);return this.#io(e.name,t,r)}insert(e){const t=e(this.#ro,this.appliedPluginClasses),r=t._tinyDepName;if(!r)throw new Error("[TinyClassManager] Plugin class must define a static '_tinyDepName' property.");const i=t._tinyDeps??[];if(!Array.isArray(i)||!i.every(e=>"string"==typeof e))throw new Error("[TinyClassManager] Plugin class must define a static array of strings in '_tinyDepName' property.");return this.#io(r,i,t)}build(){if(this.#eo)throw new Error("[TinyClassManager] Cannot build from an already finalized manager.");return this.#eo=!0,this.#Zs.clear(),this.#to=[],this.#ro}}const ui=li,hi=Y("TinyRadioFm");class ci extends er.EventEmitter{static async parseContent(e,t,r,i,n){return zt(e,t,r,i,n,ci.#no)}static#no="Unknown Artist";static get unknownArtist(){return ci.#no}static set unknownArtist(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("unknownArtist must have an string or function.");ci.#no=e}#h=!1;get destroyed(){return this.#h}get size(){return hi(this.#h),this.#so.length+this.#oo.length}get musicSize(){return hi(this.#h),this.#so.length}get voiceSize(){return hi(this.#h),this.#oo.length}get customPosSize(){return hi(this.#h),this.#ao.length}get tasksSize(){return hi(this.#h),this.#lo.length}get cycleCacheSize(){return hi(this.#h),this.#uo.size}#so=[];get musicList(){return hi(this.#h),structuredClone(this.#so)}#oo=[];get voiceList(){return hi(this.#h),structuredClone(this.#oo)}#ao=[];get customPositions(){return hi(this.#h),structuredClone(this.#ao)}#lo=[];get scheduledTasks(){return hi(this.#h),structuredClone(this.#lo)}get allList(){return hi(this.#h),[...this.musicList,...this.voiceList]}#fn=0;get seed(){return hi(this.#h),this.#fn}set seed(e){if(hi(this.#h),"number"!=typeof e)throw new TypeError("Seed must be a number.");this.#fn=e,this.#uo.clear(),this.emit("seedChanged",{seed:e})}#ho=Date.now();get anchorDate(){return hi(this.#h),this.#ho}#uo=new Map;#vt={mode:"playlist",voiceMode:"playlist",silenceDuration:0,queryLimit:1e5,voiceAfterMusic:!0,voiceMin:0,voiceMax:1,musicMaxConsecutive:0,voiceMaxConsecutive:0};get config(){return hi(this.#h),structuredClone(this.#vt)}set config(e){hi(this.#h),this.#co(e),this.#vt=structuredClone(e),this.#uo.clear(),this.emit("configChanged",{config:this.config})}#co(e){if("object"!=typeof e||null===e)throw new TypeError("Configuration must be a valid object.");const t=["playlist","random"];if(void 0!==e.mode&&!t.includes(e.mode))throw new TypeError(`Invalid mode: "${e.mode}". Must be one of: ${t.join(", ")}.`);if(void 0!==e.voiceMode&&!t.includes(e.voiceMode))throw new TypeError(`Invalid voiceMode: "${e.voiceMode}". Must be one of: ${t.join(", ")}.`);if(void 0!==e.silenceDuration&&("number"!=typeof e.silenceDuration||e.silenceDuration<0))throw new TypeError("silenceDuration must be a non-negative number.");if(void 0!==e.queryLimit&&("number"!=typeof e.queryLimit||e.queryLimit<=0))throw new TypeError("queryLimit must be a positive number.");if(void 0!==e.voiceAfterMusic&&"boolean"!=typeof e.voiceAfterMusic)throw new TypeError("voiceAfterMusic must be a boolean.");if(void 0!==e.voiceMin&&("number"!=typeof e.voiceMin||e.voiceMin<0))throw new TypeError("voiceMin must be a non-negative number.");if(void 0!==e.voiceMax&&("number"!=typeof e.voiceMax||e.voiceMax<0))throw new TypeError("voiceMax must be a non-negative number.");if(void 0!==e.musicMaxConsecutive&&("number"!=typeof e.musicMaxConsecutive||e.musicMaxConsecutive<-1))throw new TypeError("musicMaxConsecutive must be a number >= -1.");if(void 0!==e.voiceMaxConsecutive&&("number"!=typeof e.voiceMaxConsecutive||e.voiceMaxConsecutive<-1))throw new TypeError("voiceMaxConsecutive must be a number >= -1.");const r=e.voiceMin??this.#vt.voiceMin,i=e.voiceMax??this.#vt.voiceMax;if(i<r)throw new RangeError(`Logical error: voiceMax (${i}) cannot be less than voiceMin (${r}).`)}constructor(e=null,t=0){if(super(),null!==e&&"object"!=typeof e)throw new TypeError("initialData must be an object or null.");if("number"!=typeof t)throw new TypeError("seed must be a number.");this.#fn=t,e?this.#do(e):this.#ho=Date.now()}add(e,t,r=!0){if(hi(this.#h),!["music","voice","custom"].includes(e))throw new TypeError('Type must be "music", "voice", or "custom".');if(!t||"string"!=typeof t.id||"number"!=typeof t.duration)throw new TypeError("Content must have a string ID and a valid numerical duration in milliseconds.");if("boolean"!=typeof r)throw new TypeError("smartQueue must be a boolean.");"music"===e?(this.#so.push(t),this.#uo.clear()):"voice"===e?(this.#oo.push(t),this.#uo.clear()):"custom"===e&&this.#mo(t,r),this.#po(Date.now()),this.emit("contentAdded",{type:e,data:structuredClone(t)})}scheduleTask(e,t,r,i,n=!0){if(hi(this.#h),"number"!=typeof e||isNaN(e))throw new TypeError("timestamp must be a valid number.");if(!["add","remove","move"].includes(t))throw new TypeError('action must be "add", "remove", or "move".');if(!["music","voice"].includes(r))throw new TypeError('type must be "music" or "voice".');if("boolean"!=typeof n)throw new TypeError("smartQueue must be a boolean.");if("add"===t){if("object"!=typeof i||null===i||"string"!=typeof i.id||"number"!=typeof i.duration)throw new TypeError('Payload for "add" must be a MediaContent object (id: string, duration: number).')}else if("remove"===t){if("string"!=typeof i)throw new TypeError('Payload for "remove" must be a string (the content ID).')}else if("move"===t&&("object"!=typeof i||null===i||"string"!=typeof i.id||"number"!=typeof i.newIndex))throw new TypeError('Payload for "move" must be a ScheduledMovePayload (id: string, newIndex: number).');let s=e;if(n){const t=this.#fo(e,e);t&&(s=t.absoluteEnd)}const o={timestamp:s,action:t,type:r,payload:i};this.#lo.push(o),this.#po(Date.now()),this.emit("taskScheduled",structuredClone(o))}remove(e){if(hi(this.#h),"string"!=typeof e)throw new TypeError("id must be a string.");this.#so.filter(t=>t.id===e).forEach(e=>$t(e)),this.#oo.filter(t=>t.id===e).forEach(e=>$t(e)),this.#ao.filter(t=>t.content?.id===e).forEach(e=>$t(e.content));const t=t=>t.id!==e&&t.content?.id!==e;this.#so=this.#so.filter(t),this.#oo=this.#oo.filter(t),this.#ao=this.#ao.filter(t),this.#lo=this.#lo.filter(t=>"add"===t.action&&"object"==typeof t.payload&&null!==t.payload&&"id"in t.payload?t.payload.id!==e||($t(t.payload),!1):t.payload!==e),this.#uo.clear(),this.emit("contentRemoved",{id:e})}setConfig(e){hi(this.#h),this.#co(e);const t={...this.#vt,...e};this.#co(t),this.#vt=t,this.#uo.clear(),this.emit("configChanged",{config:this.config})}getCurrentEvent(){hi(this.#h);const e=Date.now();return this.#po(e),this.#fo(e,e)}queryTimeline(e,t=10){if(hi(this.#h),"number"!=typeof t||isNaN(t))throw new TypeError("Invalid query limit value. Ensure it is a number.");if(t>this.#vt.queryLimit||t<=0)throw new RangeError(`Invalid query limit. Ensure it is > 0 and <= ${this.#vt.queryLimit}.`);const r=new ci(JSON.parse(this._exportState())),i=[];let n=e;for(let s=0;s<t;s++){r.#po(n);const t=r.#yo(n,e);if(!t)break;i.push(t),n=t.absoluteEnd}return r.destroy(!1),this.emit("timelineQueried",{targetDate:e,limit:t,resultCount:i.length}),i}searchCustomPositions(){return hi(this.#h),this.#po(Date.now()),[...this.#ao]}async _processListForExport(e){return Promise.all(e.map(async e=>{const t=structuredClone(e);return t.picture&&Array.isArray(t.picture)&&(t.picture=await Promise.all(t.picture.map(async e=>"string"==typeof e.data&&e.data.startsWith("blob:")?{...e,data:await Pt(e.data)}:e))),t}))}_exportState(){return JSON.stringify({music:this.#so,voice:this.#oo,custom:this.#ao,tasks:this.#lo,seed:this.#fn,anchorDate:this.#ho,config:this.#vt})}async exportState(){hi(this.#h);const e=await this._processListForExport(this.#so),t=await this._processListForExport(this.#oo),r=await Promise.all(this.#ao.map(async e=>{const t=await this._processListForExport([e.content]);return{...e,content:t[0]}})),i=await Promise.all(this.#lo.map(async e=>{if("add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload){const t=await this._processListForExport([e.payload]);return{...e,payload:t[0]}}return e}));return JSON.stringify({music:e,voice:t,custom:r,tasks:i,seed:this.#fn,anchorDate:this.#ho,config:this.#vt})}importState(e){let t;if(hi(this.#h),"string"==typeof e)try{t=JSON.parse(e)}catch{throw new TypeError("Provided string is not valid JSON.")}else{if("object"!=typeof e||null===e)throw new TypeError("Import data must be a valid JSON string or an object.");t=e}this.#do(t),this.emit("stateImported",{data:structuredClone(t)})}_prng(e){return function(){let t=e+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}#go(e,t,r,i=0){if(0===e.length)return[];if("random"!==r)return[...e];const n=e.map(e=>({...e,weight:e.weight??1})),s=this._prng(t),o=[];let a=null,l=0;for(;n.length>0;){let e=n;-1!==i&&null!==a&&l>i&&(e=n.filter(e=>e.id!==a),0===e.length&&(e=n));const t=e.reduce((e,t)=>e+t.weight,0);if(t<=0){o.push(...e);break}const r=s()*t;let u=0,h=null,c=-1;for(let t=0;t<e.length;t++)if(u+=e[t].weight,r<=u){h=e[t],c=n.findIndex(e=>h&&e.id===h.id);break}h&&-1!==c||(h=e[0],c=n.findIndex(e=>h&&e.id===h.id)),o.push(h),n.splice(c,1),h.id===a?l++:(a=h.id,l=1)}return o}#wo(e){const t=this.#fn+e,r=this._prng(10*t),i=this.#go(this.#so,t+1,this.#vt.mode,this.#vt.musicMaxConsecutive),n=this.#go(this.#oo,t+2,this.#vt.voiceMode,this.#vt.voiceMaxConsecutive),s=[];let o=0,a=0;for(let e=0;e<i.length;e++){const t=i[e];if(s.push({...t,cycleStart:o,cycleEnd:o+t.duration}),o+=t.duration+this.#vt.silenceDuration,this.#vt.voiceAfterMusic&&n.length>0){const e=this.#vt.voiceMax-this.#vt.voiceMin+1,t=Math.floor(r()*e)+this.#vt.voiceMin;for(let e=0;e<t;e++){const e=n[a%n.length];a++,s.push({...e,cycleStart:o,cycleEnd:o+e.duration}),o+=e.duration+this.#vt.silenceDuration}}}return{items:s,duration:o}}#bo(e){if(0===this.#so.length)return null;let t=this.#ho,r=0;for(;;){if(r>this.#vt.queryLimit)throw new Error("Safety limit hit during cycle location.");let i=this.#uo.get(r);if(i||(i=this.#wo(r),this.#uo.set(r,i)),0===i.duration)return null;if(e>=t&&e<t+i.duration)return{block:i,startTimestamp:t,loopIndex:r};t+=i.duration,r++}}#yo(e,t){const r=this.#ao.filter(t=>t.intendedTimestamp+t.content.duration>e).sort((e,t)=>e.intendedTimestamp-t.intendedTimestamp)[0];let i=null;if(r){const e=Math.max(t,r.intendedTimestamp);i=this.#vo(r.content,r.intendedTimestamp,e,!0)}const n=this.#Eo(e,t);return n||i?n?i?i.absoluteStart<=n.absoluteStart?i:(i.absoluteStart<n.absoluteEnd&&(n.absoluteEnd=i.absoluteStart,n.duration=n.absoluteEnd-n.absoluteStart,n.remainingTime=Math.max(0,n.absoluteEnd-t),n.progress=Math.min(1,n.elapsedTime/n.duration)),n):n:i:null}#Eo(e,t){let r=this.#bo(e);if(!r)return null;const{block:i,startTimestamp:n}=r,s=e-n;let o,a=i.items.find(e=>e.cycleEnd>s);if(a)o=n+a.cycleStart;else{if(r=this.#bo(n+i.duration),!r||0===r.block.items.length)return null;a=r.block.items[0],o=r.startTimestamp+a.cycleStart}const l=Math.max(t,o);return this.#vo(a,o,l,!1)}#fo(e,t){const r=this.#ao.find(t=>e>=t.intendedTimestamp&&e<t.intendedTimestamp+t.content.duration);if(r)return this.#vo(r.content,r.intendedTimestamp,t,!0);const i=this.#bo(e);if(!i)return null;const{block:n,startTimestamp:s}=i,o=e-s,a=n.items.find(e=>o>=e.cycleStart&&o<e.cycleEnd);return a?this.#vo(a,s+a.cycleStart,t,!1):null}#vo(e,t,r,i){const n=r-t;return{id:e.id,title:e.title,artist:e.artist,duration:e.duration,url:e.url,absoluteStart:t,absoluteEnd:t+e.duration,elapsedTime:n,remainingTime:e.duration-n,progress:Math.min(1,n/e.duration),isCustom:i}}#mo(e,t){let r=e.timestamp||Date.now();const i=e.duration;if(t){const e=this.#fo(r,r);e&&(r=e.absoluteEnd)}const n=[...this.#ao].sort((e,t)=>e.intendedTimestamp-t.intendedTimestamp);let s=r;if(n.some(e=>r<e.intendedTimestamp+e.content.duration&&r+i>e.intendedTimestamp)){const e=[];let t=Date.now();for(const r of n)r.intendedTimestamp>t&&e.push({start:t,end:r.intendedTimestamp}),t=Math.max(t,r.intendedTimestamp+r.content.duration+this.#vt.silenceDuration);e.push({start:t,end:1/0});let o=1/0;for(const t of e)if(t.end-t.start>=i){let e=null;if(r>=t.start&&r+i<=t.end?e=r:r<t.start?e=t.start:r>t.end&&(e=t.end-i),null!==e){const t=Math.abs(r-e);t<o&&(o=t,s=e)}}}this.#ao.push({content:e,intendedTimestamp:s,originalTimestamp:e.timestamp||Date.now()})}#po(e){const t=this.#lo.filter(t=>t.timestamp<=e);this.#lo=this.#lo.filter(t=>t.timestamp>e);const r=this.#ao.filter(t=>t.intendedTimestamp+t.content.duration<=e);this.#ao=this.#ao.filter(t=>t.intendedTimestamp+t.content.duration>e);let i=!1;r.forEach(e=>{$t(e.content),this.#fn+=e.content.id.length,i=!0,this.emit("customPositionExpired",{contentId:e.content.id})}),t.length>0&&t.sort((e,t)=>e.timestamp-t.timestamp).forEach(e=>{const t="music"===e.type?this.#so:this.#oo;if("add"===e.action)t.push(e.payload);else if("remove"===e.action){const r=e.payload,i=t.findIndex(e=>e.id===r);if(-1!==i){const[e]=t.splice(i,1);$t(e)}}else if("move"===e.action){const r=e.payload,i=t.findIndex(e=>e.id===r.id);if(-1!==i){const[e]=t.splice(i,1);t.splice(r.newIndex,0,e)}}this.#ho=e.timestamp,this.#fn+=1,i=!0,this.emit("taskExecuted",structuredClone(e))}),i&&this.#uo.clear()}#do(e){this.#so.forEach(e=>$t(e)),this.#oo.forEach(e=>$t(e)),this.#ao.forEach(e=>$t(e.content)),this.#lo.forEach(e=>{"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload&&$t(e.payload)});const t=e=>e.map(e=>{const t={...e};return t.picture&&Array.isArray(t.picture)&&(t.picture=t.picture.map(e=>{const t="string"==typeof e.data&&e.data.startsWith("data:"),r=e.data instanceof Uint8Array;return t||r?{...e,data:Rt(e.data,e.format)}:e})),t});this.#so=t(e.music),this.#oo=t(e.voice),this.#fn=e.seed||0,this.#ho=e.anchorDate||Date.now(),this.#vt={...this.#vt,...e.config||{}},this.#ao=e.custom.map(e=>({...e,content:t([e.content])[0]})),this.#lo=e.tasks.map(e=>"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload?{...e,payload:t([e.payload])[0]}:e)}destroy(e=!0){this.#h||(e&&(this.#so.forEach(e=>$t(e)),this.#oo.forEach(e=>$t(e)),this.#ao.forEach(e=>$t(e.content)),this.#lo.forEach(e=>{"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload&&$t(e.payload)})),this.#so=[],this.#oo=[],this.#ao=[],this.#lo=[],this.#uo.clear(),this.emit("destroyed",{timestamp:Date.now()}),this.removeAllListeners(),this.#h=!0)}}const di=ci,mi=Y("TinyMediaPlayer");class pi{constructor(){if(new.target===pi)throw new Error("BaseMediaAdapter is an abstract class and cannot be instantiated directly.")}canHandle(e){throw new Error('Method "canHandle" must be implemented by the subclass.')}async play(e){throw new Error('Method "play" must be implemented by the subclass.')}async pause(){throw new Error('Method "pause" must be implemented by the subclass.')}async stop(){throw new Error('Method "stop" must be implemented by the subclass.')}async seek(e){throw new Error('Method "seek" must be implemented by the subclass.')}getCurrentTime(){throw new Error('Method "getCurrentTime" must be implemented by the subclass.')}setVolume(e){throw new Error('Method "setVolume" must be implemented by the subclass.')}}class fi extends er.EventEmitter{static BaseMediaAdapter=pi;static#no="Unknown Artist";static get unknownArtist(){return fi.#no}static set unknownArtist(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("unknownArtist must have an string or function.");fi.#no=e}static async parseContent(e,t,r,i,n){return zt(e,t,r,i,n,fi.#no)}#h=!1;get destroyed(){return this.#h}#To=new Map;#So=[];#xo=-1;#Ao="NONE";#Co=!1;#Io=!1;#Do=1;#Mo;#No;constructor(e={}){super(),this.#Mo=Boolean(e.persistVolume),this.#No="string"==typeof e.volumeStorageKey?e.volumeStorageKey:"tiny_media_player_volume",this.#Mo&&this.#ko()}#ko(){try{if("undefined"!=typeof window&&window.localStorage){const e=window.localStorage.getItem(this.#No);if(null!==e){const t=parseFloat(e);!isNaN(t)&&t>=0&&t<=1&&(this.#Do=t)}}}catch(e){console.warn("[TinyMediaPlayer] Failed to read volume from localStorage.",e)}}#Lo(){try{this.#Mo&&"undefined"!=typeof window&&window.localStorage&&window.localStorage.setItem(this.#No,this.#Do.toString())}catch(e){console.warn("[TinyMediaPlayer] Failed to save volume to localStorage.",e)}}_getWeightedRandomIndex(){if(0===this.#So.length)return-1;if(1===this.#So.length)return 0;let e=0;for(let t=0;t<this.#So.length;t++){if(t===this.#xo)continue;const r=this.#So[t];e+="number"==typeof r.weight&&r.weight>0?r.weight:1}let t=Math.random()*e;for(let e=0;e<this.#So.length;e++){if(e===this.#xo)continue;const r=this.#So[e],i="number"==typeof r.weight&&r.weight>0?r.weight:1;if(t<i)return e;t-=i}return this.#xo===this.#So.length-1?0:this.#So.length-1}get playlist(){return mi(this.#h),[...this.#So]}set playlist(e){if(mi(this.#h),!Array.isArray(e))throw new TypeError("Playlist must be an array of MediaContent objects.");e.forEach(e=>Ot(e));const t=this.#Io;let r=null;if(-1!==this.#xo&&this.#So.length>0)try{r=this.#_o()}catch(e){}this.#So=e,this.emit("playlistUpdate",this.playlist),0===this.#So.length?this.#xo=-1:(this.#xo>=this.#So.length||-1===this.#xo)&&(this.#xo=0),this.emit("trackChange",this.#xo),t&&(async()=>{try{r&&await r.stop(),-1!==this.#xo&&await this.play()}catch(e){console.warn("[TinyMediaPlayer] Background transition error on playlist update:",e)}})()}get currentIndex(){return mi(this.#h),this.#xo}set currentIndex(e){if(mi(this.#h),"number"!=typeof e)throw new TypeError("Current index must be a number.");if(e<-1||e>=this.#So.length&&this.#So.length>0)throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);if(this.#xo===e)return;const t=this.#Io;let r=null;if(-1!==this.#xo&&this.#So.length>0)try{r=this.#_o()}catch(e){}this.#xo=e,this.emit("trackChange",this.#xo),t&&(async()=>{try{r&&await r.stop(),-1!==this.#xo&&await this.play()}catch(e){console.warn("[TinyMediaPlayer] Background transition error on index update:",e)}})()}get loopMode(){return mi(this.#h),this.#Ao}set loopMode(e){mi(this.#h);const t=["NONE","TRACK","PLAYLIST"];if(!t.includes(e))throw new TypeError(`Loop mode must be one of: ${t.join(", ")}.`);this.#Ao=e,this.emit("loopModeChange",this.#Ao)}get isRandom(){return mi(this.#h),this.#Co}set isRandom(e){if(mi(this.#h),"boolean"!=typeof e)throw new TypeError("Random mode state must be a boolean.");this.#Co=e,this.emit("randomModeChange",this.#Co)}get isPlaying(){return mi(this.#h),this.#Io}get volume(){return mi(this.#h),this.#Do}set volume(e){if(mi(this.#h),"number"!=typeof e)throw new TypeError("Volume must be a number.");if(e<0||e>1)throw new RangeError("Volume must be tightly constrained between 0.0 and 1.0.");if(this.#Do=e,this.#Lo(),this.emit("volumeChange",this.#Do),-1!==this.#xo&&this.#So.length>0)try{const e=this.#_o();e&&e.setVolume(this.#Do)}catch(e){}}get persistVolume(){return mi(this.#h),this.#Mo}set persistVolume(e){if(mi(this.#h),"boolean"!=typeof e)throw new TypeError("Persist volume parameter must be a boolean.");this.#Mo=e,e&&this.#Lo()}get volumeStorageKey(){return mi(this.#h),this.#No}set volumeStorageKey(e){if(mi(this.#h),"string"!=typeof e)throw new TypeError("Volume storage key must be a string.");if(""===e.trim())throw new TypeError("Volume storage key cannot be an empty string.");const t=this.#No;this.#No=e;try{this.#Mo&&"undefined"!=typeof window&&window.localStorage&&(window.localStorage.removeItem(t),this.#Lo())}catch(e){console.warn("[TinyMediaPlayer] Failed to migrate volume storage key.",e)}}registerAdapter(e,t){if(mi(this.#h),"string"!=typeof e)throw new TypeError("Adapter ID must be a string.");if(!(t instanceof pi))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");this.#To.set(e,t)}#_o(){if(-1===this.#xo||0===this.#So.length)return null;const e=this.#So[this.#xo];for(const t of this.#To.values())if(t.canHandle(e))return t;throw new Error(`No compatible adapter found for content ID: ${e.id}.`)}addTrack(e){if(mi(this.#h),!e||"object"!=typeof e||"string"!=typeof e.url)throw new TypeError("Track content must be a valid MediaContent object containing a URL.");const t={id:"",title:"",artist:"",url:"",duration:0,weight:1,title:null,album:null,albumartist:null,albumartists:[],genre:[],label:[],composer:[],year:null,artist:null,artists:[],disk:{no:null,of:null},track:{no:null,of:null},picture:[],...e};Ot(t);const r=this.#So.push(t);return-1===this.#xo&&(this.#xo=0,this.emit("trackChange",this.#xo)),this.emit("playlistUpdate",this.playlist),r}existsTrack(e){if(mi(this.#h),"number"!=typeof e)throw new TypeError("Index must be a number.");return e>=0&&e<this.#So.length}getTrack(e){if(mi(this.#h),"number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);return this.#So[e]}async removeTrack(e){if(mi(this.#h),"number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);e===this.#xo?(await this.stop(),this.#So.splice(e,1),0===this.#So.length?this.#xo=-1:this.#xo>=this.#So.length&&(this.#xo=0),this.emit("trackChange",this.#xo)):(this.#So.splice(e,1),e<this.#xo&&(this.#xo-=1,this.emit("trackChange",this.#xo))),this.emit("playlistUpdate",this.playlist)}searchTrack(e){if(mi(this.#h),"string"!=typeof e&&"function"!=typeof e)throw new TypeError("Search query must be a string or a boolean evaluation function.");const t=[];for(let r=0;r<this.#So.length;r++){const i=this.#So[r];let n=!1;if("function"==typeof e)n=Boolean(e(i));else{const t=e.toLowerCase(),r=i.title&&i.title.toLowerCase().includes(t),s=i.artist&&i.artist.toLowerCase().includes(t),o=i.album&&i.album.toLowerCase().includes(t);n=Boolean(r||s||o)}n&&t.push({track:i,index:r})}return t}async clearPlaylist(){mi(this.#h),await this.stop(),this.#So=[],this.#xo=-1,this.emit("playlistUpdate",this.playlist),this.emit("trackChange",this.#xo)}async play(){mi(this.#h);const e=this.#_o();e&&(e.setVolume(this.#Do),await e.play(this.#So[this.#xo]),this.#Io=!0,this.emit("play",this.#xo))}async pause(){mi(this.#h);const e=this.#_o();e&&(await e.pause(),this.#Io=!1,this.emit("pause",this.#xo))}async stop(){mi(this.#h);const e=this.#_o();e&&(await e.stop(),this.#Io=!1,this.emit("stop",this.#xo))}async next(){if(mi(this.#h),0!==this.#So.length)if(await this.stop(),"TRACK"!==this.#Ao){if(this.#Co)this.#xo=this._getWeightedRandomIndex();else{let e=this.#xo+1;if(e>=this.#So.length){if("PLAYLIST"!==this.#Ao)return;e=0}this.#xo=e}this.emit("trackChange",this.#xo),await this.play()}else await this.play()}async prev(){if(mi(this.#h),0!==this.#So.length){if(await this.stop(),this.#Co)this.#xo=this._getWeightedRandomIndex();else{let e=this.#xo-1;if(e<0){if("PLAYLIST"!==this.#Ao)return;e=this.#So.length-1}this.#xo=e}this.emit("trackChange",this.#xo),await this.play()}}async seek(e){if(mi(this.#h),"number"!=typeof e)throw new TypeError("Seek time must be a number in milliseconds.");if(e<0)throw new RangeError("Seek time cannot be negative.");const t=this.#_o();t&&(await t.seek(e),this.emit("seek",e))}async step(e){if(mi(this.#h),"number"!=typeof e)throw new TypeError("Step amount must be a number in milliseconds.");const t=this.#_o();if(!t)return;let r=t.getCurrentTime()+e;r<0&&(r=0),await this.seek(r)}async destroy(){if(!this.#h){try{this.#Io&&await this.stop()}catch(e){console.warn("[TinyMediaPlayer] Non-fatal error during playback termination:",e)}this.#So=[],this.#xo=-1,this.#Io=!1,this.#To.clear(),this.removeAllListeners(),this.#h=!0}}}const yi=fi})(),window.TinyEssentials=i})();
1
+ (()=>{var e={7(e){"use strict";var t,r="object"==typeof Reflect?Reflect:null,i=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var n=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,e.exports.once=function(e,t){return new Promise(function(r,i){function n(r){e.removeListener(t,s),i(r)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",n),r([].slice.call(arguments))}f(e,t,s,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&f(e,"error",t,{once:!0})}(e,n)})},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function u(e,t,r,i){var n,s,o,u;if(a(r),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]),void 0===o)o=s[t]=r,++e._eventsCount;else if("function"==typeof o?o=s[t]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(n=l(e))>0&&o.length>n&&!o.warned){o.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=o.length,u=h,console&&console.warn&&console.warn(u)}return e}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function c(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},n=h.bind(i);return n.listener=r,i.wrapFn=n,n}function d(e,t,r){var i=e._events;if(void 0===i)return[];var n=i[t];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(n):p(n,n.length)}function m(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}function f(e,t,r,i){if("function"==typeof e.on)i.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function n(s){i.once&&e.removeEventListener(t,n),r(s)})}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");o=e}}),s.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return l(this)},s.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n="error"===e,s=this._events;if(void 0!==s)n=n&&void 0===s.error;else if(!n)return!1;if(n){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var l=s[e];if(void 0===l)return!1;if("function"==typeof l)i(l,this,t);else{var u=l.length,h=p(l,u);for(r=0;r<u;++r)i(h[r],this,t)}return!0},s.prototype.addListener=function(e,t){return u(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return u(this,e,t,!0)},s.prototype.once=function(e,t){return a(t),this.on(e,c(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,c(this,e,t)),this},s.prototype.removeListener=function(e,t){var r,i,n,s,o;if(a(t),void 0===(i=this._events))return this;if(void 0===(r=i[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(n=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,n=s;break}if(n<0)return this;0===n?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,n),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,r,i;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var n,s=Object.keys(r);for(i=0;i<s.length;++i)"removeListener"!==(n=s[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},s.prototype.listeners=function(e){return d(this,e,!0)},s.prototype.rawListeners=function(e){return d(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},s.prototype.listenerCount=m,s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},975(e,t,r){"use strict";var i=r(606);function n(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function s(e,t){for(var r,i="",n=0,s=-1,o=0,a=0;a<=e.length;++a){if(a<e.length)r=e.charCodeAt(a);else{if(47===r)break;r=47}if(47===r){if(s===a-1||1===o);else if(s!==a-1&&2===o){if(i.length<2||2!==n||46!==i.charCodeAt(i.length-1)||46!==i.charCodeAt(i.length-2))if(i.length>2){var l=i.lastIndexOf("/");if(l!==i.length-1){-1===l?(i="",n=0):n=(i=i.slice(0,l)).length-1-i.lastIndexOf("/"),s=a,o=0;continue}}else if(2===i.length||1===i.length){i="",n=0,s=a,o=0;continue}t&&(i.length>0?i+="/..":i="..",n=2)}else i.length>0?i+="/"+e.slice(s+1,a):i=e.slice(s+1,a),n=a-s-1;s=a,o=0}else 46===r&&-1!==o?++o:o=-1}return i}var o={resolve:function(){for(var e,t="",r=!1,o=arguments.length-1;o>=-1&&!r;o--){var a;o>=0?a=arguments[o]:(void 0===e&&(e=i.cwd()),a=e),n(a),0!==a.length&&(t=a+"/"+t,r=47===a.charCodeAt(0))}return t=s(t,!r),r?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(e){if(n(e),0===e.length)return".";var t=47===e.charCodeAt(0),r=47===e.charCodeAt(e.length-1);return 0!==(e=s(e,!t)).length||t||(e="."),e.length>0&&r&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return n(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];n(r),r.length>0&&(void 0===e?e=r:e+="/"+r)}return void 0===e?".":o.normalize(e)},relative:function(e,t){if(n(e),n(t),e===t)return"";if((e=o.resolve(e))===(t=o.resolve(t)))return"";for(var r=1;r<e.length&&47===e.charCodeAt(r);++r);for(var i=e.length,s=i-r,a=1;a<t.length&&47===t.charCodeAt(a);++a);for(var l=t.length-a,u=s<l?s: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 s>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 m="";for(c=r+h+1;c<=i;++c)c!==i&&47!==e.charCodeAt(c)||(0===m.length?m+="..":m+="/..");return m.length>0?m+t.slice(a+h):(a+=h,47===t.charCodeAt(a)&&++a,t.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(n(e),0===e.length)return".";for(var t=e.charCodeAt(0),r=47===t,i=-1,s=!0,o=e.length-1;o>=1;--o)if(47===(t=e.charCodeAt(o))){if(!s){i=o;break}}else s=!1;return-1===i?r?"/":".":r&&1===i?"//":e.slice(0,i)},basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');n(e);var r,i=0,s=-1,o=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,l=-1;for(r=e.length-1;r>=0;--r){var u=e.charCodeAt(r);if(47===u){if(!o){i=r+1;break}}else-1===l&&(o=!1,l=r+1),a>=0&&(u===t.charCodeAt(a)?-1===--a&&(s=r):(a=-1,s=l))}return i===s?s=l:-1===s&&(s=e.length),e.slice(i,s)}for(r=e.length-1;r>=0;--r)if(47===e.charCodeAt(r)){if(!o){i=r+1;break}}else-1===s&&(o=!1,s=r+1);return-1===s?"":e.slice(i,s)},extname:function(e){n(e);for(var t=-1,r=0,i=-1,s=!0,o=0,a=e.length-1;a>=0;--a){var l=e.charCodeAt(a);if(47!==l)-1===i&&(s=!1,i=a+1),46===l?-1===t?t=a:1!==o&&(o=1):-1!==t&&(o=-1);else if(!s){r=a+1;break}}return-1===t||-1===i||0===o||1===o&&t===i-1&&t===r+1?"":e.slice(t,i)},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,i=t.base||(t.name||"")+(t.ext||"");return r?r===t.root?r+i:r+"/"+i:i}(0,e)},parse:function(e){n(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return t;var r,i=e.charCodeAt(0),s=47===i;s?(t.root="/",r=1):r=0;for(var o=-1,a=0,l=-1,u=!0,h=e.length-1,c=0;h>=r;--h)if(47!==(i=e.charCodeAt(h)))-1===l&&(u=!1,l=h+1),46===i?-1===o?o=h:1!==c&&(c=1):-1!==o&&(c=-1);else if(!u){a=h+1;break}return-1===o||-1===l||0===c||1===c&&o===l-1&&o===a+1?-1!==l&&(t.base=t.name=0===a&&s?e.slice(1,l):e.slice(a,l)):(0===a&&s?(t.name=e.slice(1,o),t.base=e.slice(1,l)):(t.name=e.slice(a,o),t.base=e.slice(a,l)),t.ext=e.slice(o,l)),a>0?t.dir=e.slice(0,a-1):s&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};o.posix=o,e.exports=o},606(e){var t,r,i=e.exports={};function n(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function o(e){if(t===setTimeout)return setTimeout(e,0);if((t===n||!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:n}catch(e){t=n}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();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=o(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===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{return r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function p(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new m(e,t)),1!==l.length||u||o(d)},m.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=p,i.addListener=p,i.once=p,i.off=p,i.removeListener=p,i.removeAllListeners=p,i.emit=p,i.prependListener=p,i.prependOnceListener=p,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},133(){},370(){},766(){},911(){}};const t={};function r(i){const n=t[i];if(void 0!==n)return n.exports;const s=t[i]={exports:{}};return e[i](s,s.exports,r),s.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var i=0;i<t.length;){var n=t[i++],s=t[i++];r.o(e,n)?0===s&&i++:0===s?Object.defineProperty(e,n,{enumerable:!0,value:t[i++]}):Object.defineProperty(e,n,{enumerable:!0,get:s})}else 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=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};let i={};(()=>{"use strict";r.r(i),r.d(i,{ColorSafeStringify:()=>G,FuzzySet:()=>ai,MamdaniInferenceSystem:()=>li,TinyAdvancedRaffle:()=>jr,TinyAfterScrollWatcher:()=>Vt,TinyAnalogClock:()=>Qr,TinyArrayComparator:()=>ri,TinyArrayPaginator:()=>Rr,TinyClassManager:()=>hi,TinyClipboard:()=>or,TinyColorConverter:()=>lr,TinyColorValidator:()=>Yr,TinyCookieConsent:()=>Or,TinyDayNightCycle:()=>kr,TinyDomReadyManager:()=>Dt,TinyDragDropDetector:()=>pe,TinyDragger:()=>It,TinyElementObserver:()=>ct,TinyGamepad:()=>Mr,TinyHtml:()=>xt,TinyI18:()=>Wr,TinyIframeEvents:()=>Er,TinyInventory:()=>$r,TinyInventoryTrader:()=>Hr,TinyLevelUp:()=>n,TinyLoadingScreen:()=>Ur,TinyLocalStorage:()=>gr,TinyMediaPlayer:()=>gi,TinyNeedBar:()=>Vr,TinyNewWinEvents:()=>Ar,TinyNotifications:()=>Mt,TinyNotifyCenter:()=>re,TinyPromiseQueue:()=>Y,TinyRadioFm:()=>mi,TinyRateLimiter:()=>Z,TinySimpleDice:()=>Jr,TinySmartScroller:()=>nr,TinyTextDiffer:()=>ei,TinyTextRangeEditor:()=>sr,TinyTextarea:()=>Cr,TinyTimeout:()=>cr,TinyToastNotify:()=>ne,UltraRandomMsgGen:()=>er,addAiMarkerShortcut:()=>q,areElsCollBottom:()=>Je,areElsCollLeft:()=>Ue,areElsCollPerfBottom:()=>Xe,areElsCollPerfLeft:()=>Qe,areElsCollPerfRight:()=>Ze,areElsCollPerfTop:()=>Ye,areElsCollRight:()=>Ge,areElsCollTop:()=>Ke,areElsColliding:()=>et,areElsPerfColliding:()=>tt,arraySortPositions:()=>l,asyncReplace:()=>B,backupFile:()=>ke,breakdownDuration:()=>m,calculateMarketcap:()=>O,checkObj:()=>x,clearDirectory:()=>ve,clearDirectoryAsync:()=>Fe,cloneObjTypeOrder:()=>v,compareMarketcap:()=>F,countObj:()=>p,createCheckDestroyed:()=>X,defuzzifyCentroid:()=>ni,diffArrayList:()=>a,diffObjList:()=>K,diffStrings:()=>J,dirExists:()=>Te,dirSize:()=>Ne,dirSizeAsync:()=>Ve,documentIsFullScreen:()=>A,ensureCopyFile:()=>xe,ensureDirectory:()=>be,exitFullScreen:()=>M,extendObjType:()=>w,extractMediaId3Tags:()=>zt,fetchJson:()=>he,fetchText:()=>ce,fileExists:()=>Ee,fileSize:()=>Me,fileSizeAsync:()=>qe,formatBytes:()=>$,formatCustomTimer:()=>h,formatDayTimer:()=>d,formatTimer:()=>c,genFibonacciSeq:()=>H,getAge:()=>P,getElsCollDetails:()=>ut,getElsCollDirDepth:()=>lt,getElsCollOverlap:()=>nt,getElsCollOverlapPos:()=>st,getElsColliding:()=>rt,getElsPerfColliding:()=>it,getElsRelativeCenterOffset:()=>at,getLatestBackupPath:()=>Le,getPercentage:()=>R,getRectCenter:()=>ot,getSimplePerc:()=>j,getTimeDuration:()=>u,installWindowHiddenScript:()=>de,isDirEmpty:()=>Se,isDirEmptyAsync:()=>Be,isFullScreenMode:()=>I,isJsonObject:()=>f,isObjType:()=>T,isScreenFilled:()=>C,listDirs:()=>De,listDirsAsync:()=>We,listFiles:()=>Ie,listFilesAsync:()=>ze,multiplyArrayBlocks:()=>o,objType:()=>S,objTypeName:()=>E,offFullScreenChange:()=>L,onFullScreenChange:()=>k,parseMediaMetadata:()=>Wt,readBase64Blob:()=>oe,readFileBlob:()=>se,readJsonBlob:()=>ae,readJsonFile:()=>ge,renameFileAddPrefixSuffix:()=>Pe,renameFileBatch:()=>je,renameFileNormalizeCase:()=>$e,renameFilePadNumbers:()=>He,renameFileRegex:()=>Re,reorderObjTypeOrder:()=>b,requestFullScreen:()=>D,restoreLatestBackup:()=>_e,ruleOfThree:()=>_,safeTextTrim:()=>V,saveJsonFile:()=>le,shuffleArray:()=>s,toTitleCase:()=>z,toTitleCaseLowerFirst:()=>W,trapezoid:()=>si,tryDeleteFile:()=>Ae,valMediaContentMetadata:()=>Ft,valMediaContentMetadataPartial:()=>Bt,writeJsonFile:()=>we,writeTextFile:()=>Ce});var e={};r.r(e),r.d(e,{iu:()=>Je,cq:()=>Ue,P8:()=>Xe,BO:()=>Qe,eh:()=>Ze,L2:()=>Ye,lP:()=>Ge,Kr:()=>Ke,wE:()=>et,D6:()=>tt,PN:()=>ut,t_:()=>lt,aI:()=>nt,ej:()=>st,kx:()=>rt,Pd:()=>it,NW:()=>at,Qv:()=>ot});var t={};r.r(t),r.d(t,{areElsCollBottom:()=>Je,areElsCollLeft:()=>Ue,areElsCollPerfBottom:()=>Xe,areElsCollPerfLeft:()=>Qe,areElsCollPerfRight:()=>Ze,areElsCollPerfTop:()=>Ye,areElsCollRight:()=>Ge,areElsCollTop:()=>Ke,areElsColliding:()=>et,areElsPerfColliding:()=>tt,getElsCollDetails:()=>ut,getElsCollDirDepth:()=>lt,getElsCollOverlap:()=>nt,getElsCollOverlapPos:()=>st,getElsColliding:()=>rt,getElsPerfColliding:()=>it,getElsRelativeCenterOffset:()=>at,getRectCenter:()=>ot});const n=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 i=t*e.level;return e.exp>=i&&(e.level++,r=e.exp-i,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",i=1){if("number"!=typeof i||Number.isNaN(i))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(i)+t:"extra"===r&&(e.exp+=t),this.expValidator(e),e.totalExp=this.getTotalExp(e),e}remove(e,t=0,r="add",i=1){if("number"!=typeof i||Number.isNaN(i))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(i)+t:"extra"===r&&(e.exp-=t),this.expValidator(e),e.totalExp=this.getTotalExp(e),e}};function s(e){if(!Array.isArray(e))throw new TypeError("Argument 'items' must be an array.");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){if(!Array.isArray(e))throw new TypeError("Argument 'phases' must be an array.");if(!Array.isArray(t))throw new TypeError("Argument 'counts' must be an array.");if(e.length!==t.length)throw new RangeError("The 'phases' and 'counts' arrays must have the same length.");const r=[];for(let i=0;i<e.length;i++){if("number"!=typeof t[i]||Number.isNaN(t[i]))throw new TypeError(`Element at counts[${i}] must be a valid number.`);for(let n=0;n<t[i];n++)r.push(e[i])}return r}function a(e,t){if(!Array.isArray(e))throw new TypeError("Argument 'oldItems' must be an array.");if(!Array.isArray(t))throw new TypeError("Argument 'newItems' must be an array.");const r=e.filter(e=>!t.includes(e));return{added:t.filter(t=>!e.includes(t)),removed:r}}function l(e,t=!1){if(null!=e&&"string"!=typeof e)throw new TypeError("Argument 'item' must be a string or null.");if("boolean"!=typeof t)throw new TypeError("Argument 'isReverse' must be a boolean.");return t?function(t,r){return(e?t[e]:t)>(e?r[e]:r)?-1:(e?t[e]:t)<(e?r[e]:r)?1:0}:function(t,r){return(e?t[e]:t)<(e?r[e]:r)?-1:(e?t[e]:t)>(e?r[e]:r)?1:0}}function u(e=new Date,t="asSeconds",r=null){if(!(e instanceof Date))throw new TypeError("The 'timeData' argument must be an instance of Date.");if("string"!=typeof t)throw new TypeError("The 'durationType' argument must be a string.");const i=["asMilliseconds","asSeconds","asMinutes","asHours","asDays"];if(!i.includes(t))throw new RangeError(`The 'durationType' must be one of: ${i.join(", ")}.`);if(null!==r&&!(r instanceof Date))throw new TypeError("The 'now' argument must be an instance of Date or null.");const n=r instanceof Date?r:new Date,s=e.getTime()-n.getTime();switch(t){case"asMilliseconds":return s;case"asSeconds":default:return s/1e3;case"asMinutes":return s/6e4;case"asHours":return s/36e5;case"asDays":return s/864e5}}function h(e,t="seconds",r="{time}"){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'totalSeconds' argument must be a valid number.");if("string"!=typeof t)throw new TypeError("The 'level' argument must be a string.");const i=["seconds","minutes","hours","days","months","years"];if(!i.includes(t))throw new RangeError(`The 'level' must be one of: ${i.join(", ")}.`);if("string"!=typeof r)throw new TypeError("The 'format' argument must be a string.");e=Math.max(0,Math.floor(e));const n=i.indexOf(t),s=n>=5,o=n>=4,a=n>=3,l=n>=2,u=n>=1,h=n>=0,c={years:s?0:NaN,months:o?0:NaN,days:a?0:NaN,hours:l?0:NaN,minutes:u?0:NaN,seconds:h?0:NaN,total:NaN};let d=e;if(s||o||a){const e=new Date(1980,0,1),t=new Date(e.getTime()+1e3*d),r=new Date(e);if(s)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(a)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),c.days++;d=Math.floor((t.getTime()-r.getTime())/1e3)}l&&(c.hours=Math.floor(d/3600),d%=3600),u&&(c.minutes=Math.floor(d/60),d%=60),h&&(c.seconds=d),c.total=+e.toFixed(2).replace(/\.00$/,"");const m=e=>{const t="string"==typeof e?parseInt(e):e;return Number.isNaN(t)?"NaN":String(t).padStart(2,"0")},p=[l?m(c.hours):null,u?m(c.minutes):null,h?m(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,m(c.hours)).replace(/\{minutes\}/g,m(c.minutes)).replace(/\{seconds\}/g,m(c.seconds)).replace(/\{time\}/g,p).replace(/\{total\}/g,String(c.total)).trim()}function c(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'seconds' argument must be a valid number.");return h(e,"hours","{hours}:{minutes}:{seconds}")}function d(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'seconds' argument must be a valid number.");return h(e,"days","{days}d {hours}:{minutes}:{seconds}")}function m(e,t="milliseconds"){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'totalMs' argument must be a valid number.");if("string"!=typeof t)throw new TypeError("The 'level' argument must be a string.");const r=["milliseconds","seconds","minutes","hours","days","months","years"];if(!r.includes(t))throw new RangeError(`The 'level' must be one of: ${r.join(", ")}.`);e=Math.max(0,Math.floor(e));const i=r.indexOf(t),n=i>=6,s=i>=5,o=i>=4,a=i>=3,l=i>=2,u=i>=1,h=i>=0,c={years:n?0:NaN,months:s?0:NaN,days:o?0:NaN,hours:a?0:NaN,minutes:l?0:NaN,seconds:u?0:NaN,milliseconds:h?0:NaN,total:NaN};let d=e;if(n||s||o){const e=new Date(1980,0,1),t=new Date(e.getTime()+d),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(s)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),c.months++;if(o)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),c.days++;d=t.getTime()-r.getTime()}return a&&(c.hours=Math.floor(d/36e5),d%=36e5),l&&(c.minutes=Math.floor(d/6e4),d%=6e4),u&&(c.seconds=Math.floor(d/1e3),d%=1e3),h&&(c.milliseconds=d),c.total=+e,c}function p(e){if(!Array.isArray(e)&&!f(e))throw new TypeError("Argument must be either an Array or a pure JSON Object.");return Array.isArray(e)?e.length:Object.keys(e).length}function f(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}const y="undefined"!=typeof window&&void 0!==window.document,g={items:{},order:[]};function w(e,t){if("object"!=typeof e||null===e)throw new TypeError("Argument 'newItems' must be an object or an array.");if(void 0!==t&&"number"!=typeof t)throw new TypeError("Argument 'index' must be a number.");const r=[],i=Array.isArray(e)?e:Object.entries(e);for(const e of i){if(!Array.isArray(e)||e.length<2)throw new TypeError("Each item in 'newItems' array must be a [key, function] pair.");const[i,n]=e;if("string"!=typeof i)throw new TypeError("Validator key must be a string.");if("function"!=typeof n)throw new TypeError(`Validator for key '${i}' must be a function.`);if(!g.items.hasOwnProperty(i)){g.items[i]=n;let e="number"==typeof t?t:-1;if(-1===e){const t=g.order.indexOf("object");e=t>-1?t:g.order.length}e=Math.min(Math.max(0,e),g.order.length),g.order.splice(e,0,i),r.push(i)}}return r}function b(e){if(!Array.isArray(e))throw new TypeError("Argument 'newOrder' must be an array of strings.");if(!e.every(e=>"string"==typeof e))throw new TypeError("All elements in 'newOrder' must be strings.");const t=[...g.order];return!!e.every(e=>t.includes(e))&&(g.order=e.slice(),!0)}function v(){return[...g.order]}const E=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 T(e,t){if("string"!=typeof t)throw new TypeError("Argument 'type' must be a string.");return E(e)===t.toLowerCase()}function S(e,t){if(void 0===e)return null;if(void 0!==t&&"string"!=typeof t)throw new TypeError("Argument 'type' must be a string.");const r=E(e);return"string"==typeof t?r===t.toLowerCase():r}function x(e){const t={valid:null,type:null};for(const r of g.order)if("function"==typeof g.items[r]){const i=g.items[r](e);if(i){t.valid=i,t.type=r;break}}return t}w([["undefined",e=>void 0===e],["null",e=>null===e],["boolean",e=>"boolean"==typeof e],["number",e=>"number"==typeof e&&!Number.isNaN(e)],["bigint",e=>"bigint"==typeof e],["string",e=>"string"==typeof e],["symbol",e=>"symbol"==typeof e],["function",e=>"function"==typeof e],["array",e=>Array.isArray(e)]]),y&&w([["file",e=>"undefined"!=typeof File&&e instanceof File]]),w([["date",e=>e instanceof Date],["regexp",e=>e instanceof RegExp],["map",e=>e instanceof Map],["set",e=>e instanceof Set],["weakmap",e=>e instanceof WeakMap],["weakset",e=>e instanceof WeakSet],["promise",e=>e instanceof Promise]]),y&&w([["htmlelement",e=>"undefined"!=typeof HTMLElement&&e instanceof HTMLElement]]),w([["object",e=>f(e)]]);const A=()=>!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitIsFullScreen||document.mozFullScreen),C=()=>window.innerHeight===screen.height&&window.innerWidth===screen.width,I=()=>A()||C(),D=e=>new Promise(async(t,r)=>{const i=document.documentElement;try{i.requestFullscreen?await i.requestFullscreen(e):i.mozRequestFullScreen?i.mozRequestFullScreen(e):i.webkitRequestFullScreen?i.webkitRequestFullScreen(e):i.msRequestFullscreen&&i.msRequestFullscreen(e),t()}catch(e){r(e)}}),M=()=>new Promise((e,t)=>{if(document.exitFullscreen)document.exitFullscreen().then(e).catch(t);else try{if(document.mozCancelFullScreen)document.mozCancelFullScreen();else if(document.webkitCancelFullScreen)document.webkitCancelFullScreen();else{if(!document.msExitFullscreen)throw new Error("Fullscreen API is not supported");document.msExitFullscreen()}e()}catch(e){t(e)}}),N=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],k=(e,t)=>{N.forEach(r=>{document.addEventListener(r,e,t)})},L=(e,t)=>{N.forEach(r=>{document.removeEventListener(r,e,t)})};function _(e,t,r,i=!1){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("val1 must be a finite number.");if("number"!=typeof t||!Number.isFinite(t))throw new TypeError("val2 must be a finite number.");if("number"!=typeof r||!Number.isFinite(r))throw new TypeError("val3 must be a finite number.");if("boolean"!=typeof i)throw new TypeError("inverse must be a boolean.");return i?Number(e*t)/r:Number(r*t)/e}function j(e,t){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("price must be a finite number.");if("number"!=typeof t||!Number.isFinite(t))throw new TypeError("percentage must be a finite number.");return e*(t/100)}function R(e,t){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("part must be a finite number.");if("number"!=typeof t||!Number.isFinite(t))throw new TypeError("total must be a finite number.");return 0===t?0:e/t*100}function P(e=0,t=null){if("number"!=typeof e&&"string"!=typeof e&&!(e instanceof Date))throw new TypeError("timeData must be a number, string, or Date object.");if(null!==t&&!(t instanceof Date))throw new TypeError("now must be a Date object or null.");const r=new Date(e);if(Number.isNaN(r.getTime()))return null;const i=t instanceof Date?t:new Date;let n=i.getFullYear()-r.getFullYear();const s=i.getMonth(),o=r.getMonth(),a=i.getDate(),l=r.getDate();return(s<o||s===o&&a<l)&&n--,Math.abs(n)}function $(e,t=null,r=null){if("number"!=typeof e||!Number.isFinite(e)||e<0)throw new TypeError("bytes must be a positive number.");if(0===e)return{unit:"Bytes",value:0};if(null!==t&&("number"!=typeof t||!Number.isFinite(t)))throw new TypeError("decimals must be a number or null.");const i=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"];if(null!==r){if("string"!=typeof r)throw new TypeError("maxUnit must be a string or null.");if(!i.includes(r))throw new RangeError(`maxUnit must be one of: ${i.join(", ")}`)}const n=r&&i.includes(r)?i.indexOf(r):i.length-1,s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),n);let o=e/Math.pow(1024,s);if(null!==t){const e=t<0?0:t;o=parseFloat(o.toFixed(e))}return{unit:i[s],value:o}}function H({baseValues:e=[0,1],length:t=10,combiner:r=(e,t)=>e+t}={}){if(!Array.isArray(e)||2!==e.length||!e.every(e=>"number"==typeof e))throw new Error("baseValues must be an array of exactly two numbers.");if("number"!=typeof t||!Number.isInteger(t))throw new RangeError("length must be an integer.");if("function"!=typeof r)throw new TypeError("combiner must be a function.");const i=[...e.slice(0,2)];for(let e=2;e<t;e++){const t=r(i[e-2],i[e-1],e);i.push(t)}return i}function O(e,t){if("number"!=typeof e||Number.isNaN(e)||!Number.isFinite(e))throw new TypeError("Original market cap must be a finite number.");if("number"!=typeof t||Number.isNaN(t)||!Number.isFinite(t))throw new TypeError("Circulating supply must be a finite number.");if(t<=0)throw new RangeError("Circulating supply must be greater than zero.");return e/t}function F(e,t,r){if("number"!=typeof r||Number.isNaN(r)||!Number.isFinite(r))throw new TypeError("New market cap must be a finite number.");const i=O(e,t),n="number"==typeof r?r/t:NaN;return{originalPrice:i,newPrice:n,priceChangePercent:"number"==typeof r?(n-i)/i*100:NaN}}async function B(e,t,r){if("string"!=typeof e)throw new TypeError("Expected a string for 'str', but received "+typeof e);if(!(t instanceof RegExp))throw new TypeError("Expected a RegExp for 'regex', but received "+typeof t);if("function"!=typeof r)throw new TypeError("Expected a function for 'asyncFn', but received "+typeof r);const i=[];e.replace(t,(e,...t)=>(i.push(r(e,...t)),e));const n=await Promise.all(i);return e.replace(t,()=>n.shift())}function z(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str', but received "+typeof e);return e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase())}function W(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str', but received "+typeof 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 q({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.");if("string"!=typeof e)throw new TypeError("Expected a string for 'config.key', but received "+typeof e);if("string"!=typeof t)throw new TypeError("Expected a string for 'config.className', but received "+typeof t);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 V(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 i=e.trim();if(i.length>t){const e=i.lastIndexOf(" ",t);return e>0&&e>=t*r?`${i.substring(0,e).trim()}...`:`${i.substring(0,t).trim()}...`}return i}function K(e,t){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("Expected an object for 'oldStrings', but received "+(null===e?"null":typeof e));if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError("Expected an object for 'newStrings', but received "+(null===t?"null":typeof t));const r={added:{},removed:{},modified:{}};for(const i in e)i in t?e[i]!==t[i]&&(r.modified[i]={old:e[i],new:t[i]}):r.removed[i]=e[i];for(const i in t)i in e||(r.added[i]=t[i]);return r}const J=K;class U{#e;static#t={default:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""},solarized:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""},monokai:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""}};constructor(e={}){this.#e={...U.#t.default,...e}}#r(e,t){const r=[];e=(e=(e=e.replace(/(?<!")\b(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b(?!")/g,`${t.number}$1${t.reset}`)).replace(/"([^"]+)":/g,(e,t)=>{const i=`___KEY${r.length}___`;return r.push({marker:i,key:t}),`${i}:`})).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:i,key:n}of r){const r=new RegExp(i,"g");e=e.replace(r,`${t.key}"${n}"${t.reset}`)}return(e=(e=(e=(e=e.replace(/(?<!")\b(true|false)\b(?!")/g,`${t.boolean}$1${t.reset}`)).replace(/(?<!")\bnull\b(?!")/g,`${t.null}null${t.reset}`)).replace(/\[Circular\]/g,`${t.special}[Circular]${t.reset}`)).replace(/\[undefined\]/g,`${t.special}[undefined]${t.reset}`)).replace(/"function.*?[^\\]"/gs,`${t.func}$&${t.reset}`)}colorize(e,t={}){const r={...this.#e,...t};return this.#r(e,r)}getColors(){return{...this.#e}}updateColors(e){Object.assign(this.#e,e)}resetColors(){this.#e={...U.#t.default}}loadColorPreset(e){const t=U.#t[e];if(!t)throw new Error(`Preset "${e}" not found.`);this.#e={...t}}saveColorPreset(e,t){U.#t[e]={...t}}getAvailablePresets(){return Object.keys(U.#t)}}const G=U,Y=class{#i=[];#n=!1;#s={};#o=new Set;isRunning(){return this.#n}async#a(e){if(e&&"function"==typeof e.task&&"function"==typeof e.resolve&&"function"==typeof e.reject){const{task:t,resolve:r,reject:i,delay:n,id:s}=e;try{if(s&&this.#o.has(s))return i(new Error("The function was canceled on TinyPromiseQueue.")),this.#o.delete(s),this.#n=!1,void this.#l();n&&s&&await new Promise(e=>{const t=setTimeout(()=>{delete this.#s[s],e(null)},n);this.#s[s]=t}),r(await t())}catch(e){i(e)}finally{this.#n=!1,this.#l()}}}async#u(){const e=[];for(;this.#i.length&&"POINT_MARKER"===this.#i[0]?.marker;)e.push(this.#i.shift());if(0===e.length)return this.#n=!1,void this.#l();await Promise.all(e.map(({task:e,resolve:t,reject:r,id:i})=>new Promise(async n=>{if(i&&this.#o.has(i))return this.#o.delete(i),r(new Error("The function was canceled on TinyPromiseQueue.")),void n(!0);await e().then(t).catch(r),n(!0)}))),this.#n=!1,this.#l()}async#l(){if(!this.#n&&0!==this.#i.length)if(this.#n=!0,"string"!=typeof this.#i[0]?.marker||"POINT_MARKER"!==this.#i[0]?.marker){const e=this.#i.shift();this.#a(e)}else this.#u()}getIndexById(e){return this.#i.findIndex(t=>t.id===e)}getQueuedIds(){return this.#i.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.#i.length||t>=this.#i.length)return;const[r]=this.#i.splice(e,1);this.#i.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.#n?new Promise((r,i)=>{this.#i.push({marker:"POINT_MARKER",task:e,resolve:r,reject:i,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((i,n)=>{this.#i.push({task:e,resolve:i,reject:n,id:r,delay:t}),this.#l()})}cancelTask(e){if("string"!=typeof e)throw new Error('The "id" parameter must be a string.');let t=!1;e in this.#s&&(clearTimeout(this.#s[e]),delete this.#s[e],t=!0);const r=this.getIndexById(e);if(-1!==r){const[e]=this.#i.splice(r,1);e?.reject?.(new Error("The function was canceled on TinyPromiseQueue.")),t=!0}return t&&this.#o.add(e),t}},X=e=>t=>{if(t)throw new Error(`This ${e} instance has been destroyed and can no longer be used.`)},Q=X("TinyRateLimiter"),Z=class{#h=!1;get destroyed(){return this.#h}#c=null;#d=null;#m=null;#p=null;#f=null;#y=null;groupData=new Map;lastSeen=new Map;userToGroup=new Map;groupFlags=new Map;groupTTL=new Map;#g=null;setOnMemoryExceeded(e){if(Q(this.#h),"function"!=typeof e)throw new Error("onMemoryExceeded must be a function");this.#g=e}clearOnMemoryExceeded(){Q(this.#h),this.#g=null}#w=null;setOnGroupExpired(e){if(Q(this.#h),"function"!=typeof e)throw new Error("onGroupExpired must be a function");this.#w=e}clearOnGroupExpired(){Q(this.#h),this.#w=null}constructor({maxHits:e,interval:t,cleanupInterval:r,maxIdle:i=3e5,maxMemory:n=1e5}){const s=e=>"number"==typeof e&&Number.isFinite(e)&&e>=1&&Number.isInteger(e),o=s(e),a=s(t),l=s(r),u=s(i);if(!o&&!a)throw new Error("RateLimiter requires at least one valid option: 'maxHits' or 'interval'.");if(void 0!==e&&!o)throw new Error("'maxHits' must be a positive integer if defined.");if(void 0!==t&&!a)throw new Error("'interval' must be a positive integer in milliseconds if defined.");if(void 0!==r&&!l)throw new Error("'cleanupInterval' must be a positive integer in milliseconds if defined.");if(!u)throw new Error("'maxIdle' must be a positive integer in milliseconds.");if("number"==typeof n&&Number.isFinite(n)&&n>0)this.#c=Math.floor(n);else{if(null!=n)throw new Error("maxMemory must be a positive number or null");this.#c=null}this.#m=o?e:null,this.#p=a?t:null,this.#f=l?r:null,this.#y=i,null!==this.#f&&(this.#d=setInterval(()=>this._cleanup(),this.#f))}isGroupId(e){Q(this.#h);const t=this.groupFlags.get(e);return"boolean"==typeof t&&t}getUsersInGroup(e){Q(this.#h);const t=[];for(const[r,i]of this.userToGroup.entries())i===e&&t.push(r);return t}setGroupTTL(e,t){if(Q(this.#h),"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 Q(this.#h),this.groupTTL.get(e)??null}deleteGroupTTL(e){Q(this.#h),this.groupTTL.delete(e)}assignToGroup(e,t){Q(this.#h);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 i=this.groupData.get(e);if(this.isGroupId(e)){for(const[r,i]of this.userToGroup.entries())i===e&&this.userToGroup.set(r,t);this.userToGroup.delete(e)}else this.userToGroup.set(e,t);if(!i)return;const n=this.groupData.get(t);if(n)for(const e of i)n.push(e);else{const e=[];for(const t of i)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 Q(this.#h),this.userToGroup.get(e)||e}hit(e){Q(this.#h);const t=this.getGroupId(e),r=Date.now();this.groupData.has(t)||(this.groupData.set(t,[]),this.groupFlags.set(t,!1));const i=this.groupData.get(t);if(!i)throw new Error(`No data found for groupId: ${t}`);if(i.push(r),this.lastSeen.set(t,r),null!==this.#p){const e=r-this.getInterval();for(;i.length&&i[0]<e;)i.shift()}null!==this.#c&&"number"==typeof this.#c&&i.length>this.#c&&(i.splice(0,i.length-this.#c),"function"==typeof this.#g&&this.#g(t))}isRateLimited(e){Q(this.#h);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 i=r.length-1;i>=0&&r[i]>e;i--)t++;return null!==this.#m?t>this.getMaxHits():t>0}return null!==this.#m&&r.length>this.getMaxHits()}resetGroup(e){Q(this.#h),this.groupFlags.delete(e),this.groupData.delete(e),this.lastSeen.delete(e),this.groupTTL.delete(e)}resetUserGroup(e){Q(this.#h),this.userToGroup.delete(e)}setData(e,t){if(Q(this.#h),!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 Q(this.#h),this.groupData.has(e)}getData(e){return Q(this.#h),this.groupData.get(e)||[]}getMaxIdle(){if(Q(this.#h),"number"!=typeof this.#y||!Number.isFinite(this.#y)||this.#y<0)throw new Error("'maxIdle' must be a non-negative finite number.");return this.#y}setMaxIdle(e){if(Q(this.#h),"number"!=typeof e||!Number.isFinite(e)||e<0)throw new Error("'maxIdle' must be a non-negative finite number.");this.#y=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.#w&&this.#w(t))}getActiveGroups(){return Q(this.#h),Array.from(this.groupData.keys())}getAllUserMappings(){return Q(this.#h),Object.fromEntries(this.userToGroup)}getInterval(){if(Q(this.#h),"number"!=typeof this.#p||!Number.isFinite(this.#p))throw new Error("'interval' is not a valid finite number.");return this.#p}getMaxHits(){if(Q(this.#h),"number"!=typeof this.#m||!Number.isFinite(this.#m))throw new Error("'maxHits' is not a valid finite number.");return this.#m}getTotalHits(e){Q(this.#h);const t=this.groupData.get(e);return Array.isArray(t)?t.length:0}getLastHit(e){Q(this.#h);const t=this.groupData.get(e);return t?.length?t[t.length-1]:null}getTimeSinceLastHit(e){Q(this.#h);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 Q(this.#h),this._calculateAverageSpacing(this.groupData.get(e))}getMetrics(e){Q(this.#h);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,i=t[r-1];return{totalHits:r,lastHit:i,timeSinceLastHit:Date.now()-i,averageHitSpacing:this._calculateAverageSpacing(t)}}destroy(){this.destroyed||(this.#d&&clearInterval(this.#d),this._cleanup(),this.groupData.clear(),this.lastSeen.clear(),this.userToGroup.clear(),this.groupTTL.clear(),this.groupFlags.clear(),this.#h=!0)}},ee=X("TinyNotifyCenter");class te{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,te.getTemplate())}#h=!1;get destroyed(){return this.#h}#b;#v;#E;#T;#S;#x=0;#A=99;#C=300;#I=!1;#D=new WeakMap;#M(e){if(this.#D.delete(e),!(e instanceof HTMLElement))throw new Error("Invalid HTMLElement to clear.");e.classList.add("removing"),setTimeout(()=>{this.markAsRead(e),e.remove()},this.#C)}#N(e){this.#x=Math.max(0,e),this.#E.setAttribute("data-value",String(this.#x)),this.#E.textContent=this.#x>this.#A?`${this.#A}+`:String(this.#x)}constructor(e={}){const{center:t=document.getElementById("notifCenter"),badge:r=document.getElementById("notifBadge"),button:i=document.querySelector(".notify-bell"),overlay:n=document.querySelector(".notify-overlay")}=e;if(!(t instanceof HTMLElement))throw new Error(`NotificationCenter: "center" must be an HTMLElement. Got: ${t}`);if(!(n instanceof HTMLElement))throw new Error(`NotificationCenter: "overlay" must be an HTMLElement. Got: ${n}`);if(!(r instanceof HTMLElement))throw new Error(`NotificationCenter: "badge" must be an HTMLElement. Got: ${r}`);if(!(i instanceof HTMLElement))throw new Error(`NotificationCenter: "button" must be an HTMLElement. Got: ${i}`);const s=t?.querySelector(".clear-all"),o=t?.querySelector(".list")??null;if(!(o instanceof HTMLElement))throw new Error(`NotificationCenter: ".list" inside center must be an HTMLElement. Got: ${o}`);this.#b=t,this.#v=o,this.#E=r,this.#T=i,this.#S=n,this.#T.addEventListener("click",()=>this.toggle()),this.#b.querySelector(".close")?.addEventListener("click",()=>this.close()),s&&s.addEventListener("click",()=>this.clear()),this.#S.addEventListener("click",e=>{e.target===this.#S&&this.close()})}setMarkAllAsReadOnClose(e){if(ee(this.#h),"boolean"!=typeof e)throw new TypeError("Expected boolean for markAllAsReadOnClose, got "+typeof e);this.#I=e}setRemoveDelay(e){if(ee(this.#h),"number"!=typeof e)throw new Error('NotificationCenter: "ms" must be an number.');this.#C=e}getItemMode(e){ee(this.#h);const t=this.getItem(e);return t?this.#D.get(t):null}getItem(e){ee(this.#h);const t=this.#v.children.item(e);if(!(t instanceof HTMLElement))throw new Error(`NotificationCenter: "item" must be an HTMLElement. Got: ${t}`);return t}hasItem(e){return ee(this.#h),e>=0&&e<this.#v.children.length}markAsRead(e){ee(this.#h);const t=e instanceof HTMLElement?e:this.getItem(e);t.classList.contains("unread")&&(t.classList.remove("unread"),this.#N(this.#x-1))}add(e,t="text"){ee(this.#h);const r=document.createElement("div");r.className="item unread";let i=null,n=null,s=null,o=null;if("object"==typeof e&&null!==e?(i=e.title,n=e.message,s=e.avatar,o=e.onClick):n=e,s){const e=document.createElement("div");e.className="avatar",e.style.backgroundImage=`url("${s}")`,r.appendChild(e)}const a=document.createElement("div");if(a.className="content",i){const e=document.createElement("div");e.className="title",e.textContent=i,a.appendChild(e)}const l=document.createElement("div");l.className="message","html"===t?l.innerHTML=n:l.textContent=n,a.appendChild(l),"function"==typeof o&&(r.classList.add("clickable"),r.addEventListener("click",e=>{e.target instanceof HTMLElement&&!e.target.closest(".notify-close")&&o(e)}));const u=document.createElement("button");u.className="notify-close",u.setAttribute("type","button"),u.innerHTML="&times;",u.addEventListener("click",e=>{e.stopPropagation(),this.#M(r)}),r.append(a,u),this.#v.prepend(r),this.#D.set(r,t),this.#N(this.#x+1)}remove(e){ee(this.#h);const t=this.getItem(e);this.#M(t)}clear(){ee(this.#h);let e=!0;for(;e;){e=!1;const t=Array.from(this.#v.children);for(const r of t)r instanceof HTMLElement&&!r.classList.contains("removing")&&(this.#M(r),e=!0)}}open(){ee(this.#h),this.#S.classList.remove("hidden"),this.#b.classList.add("open")}close(){if(ee(this.#h),this.#S.classList.add("hidden"),this.#b.classList.remove("open"),this.#I){const e=this.#v.querySelectorAll(".item.unread");for(const t of e)t instanceof HTMLElement&&this.markAsRead(t)}}toggle(){ee(this.#h),this.#b.classList.contains("open")?this.close():this.open()}recount(){ee(this.#h);const e=this.#v.querySelectorAll(".item.unread").length;this.#N(e)}get count(){return this.#x}destroy(){this.#h||(this.#T?.removeEventListener("click",this.toggle),this.#b?.querySelector(".close")?.removeEventListener("click",this.close),this.#b?.querySelector(".clear-all")?.removeEventListener("click",this.clear),this.#S?.removeEventListener("click",this.close),this.clear(),this.#b?.remove(),this.#S?.remove(),this.#T?.remove(),this.#x=0,this.#D=new WeakMap,this.#h=!0)}}const re=te,ie=X("TinyToastNotify"),ne=class{#k;#L;#_;#j;#R;#P;#h=!1;get destroyed(){return this.#h}constructor(e="top",t="right",r=3e3,i=50,n=300,s=".notify-container"){this.#$(e),this.#H(t),this.#O(r,"baseDuration"),this.#O(i,"extraPerChar"),this.#O(n,"fadeOutDuration"),this.#k=e,this.#L=t,this.#_=r,this.#j=i,this.#R=n;const o=document.querySelector(`${s}.${e}.${t}`);o instanceof HTMLElement?this.#P=o:(this.#P=document.createElement("div"),this.#P.className=`notify-container ${e} ${t}`,document.body.appendChild(this.#P))}getContainer(){if(ie(this.#h),!(this.#P instanceof HTMLElement))throw new Error("Container is not a valid HTMLElement.");return this.#P}#$(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".`)}#O(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 ie(this.#h),this.#k}setY(e){ie(this.#h),this.#$(e);const t=this.getContainer();t.classList.remove(this.#k),t.classList.add(e),this.#k=e}getX(){return ie(this.#h),this.#L}setX(e){ie(this.#h),this.#H(e);const t=this.getContainer();t.classList.remove(this.#L),t.classList.add(e),this.#L=e}getBaseDuration(){return ie(this.#h),this.#_}setBaseDuration(e){ie(this.#h),this.#O(e,"baseDuration"),this.#_=e}getExtraPerChar(){return ie(this.#h),this.#j}setExtraPerChar(e){ie(this.#h),this.#O(e,"extraPerChar"),this.#j=e}getFadeOutDuration(){return ie(this.#h),this.#R}setFadeOutDuration(e){ie(this.#h),this.#O(e,"fadeOutDuration"),this.#R=e}show(e){ie(this.#h);let t="",r="",i=null,n=!1,s=null;const o=document.createElement("div");if(o.className="notify enter","string"==typeof e)t=e;else{if("object"!=typeof e||null===e||"string"!=typeof e.message)throw new Error("Invalid argument for show(): expected string or { message: string, title?: string, onClick?: function, html?: boolean, avatar?: string }");if(t=e.message,r="string"==typeof e.title?e.title:"",n=!0===e.html,s="string"==typeof e.avatar?e.avatar:null,void 0!==e.onClick){if("function"!=typeof e.onClick)throw new Error("onClick must be a function if defined");i=e.onClick,o.classList.add("clickable")}}const a=document.createElement("button");if(a.innerHTML="&times;",a.className="close",a.setAttribute("aria-label","Close"),a.addEventListener("mouseenter",()=>{a.style.color="var(--notify-close-color-hover)"}),a.addEventListener("mouseleave",()=>{a.style.color="var(--notify-close-color)"}),s){const e=document.createElement("img");e.src=s,e.alt="avatar",e.className="avatar",o.appendChild(e)}if(r){const e=document.createElement("strong");e.textContent=r,e.style.display="block",o.appendChild(e)}if(n){const e=document.createElement("div");e.innerHTML=t,o.appendChild(e)}else o.appendChild(document.createTextNode(t));o.appendChild(a),this.getContainer().appendChild(o);const l=this.#_+t.length*this.#j+this.#R;let u=!1;const h=()=>{u||(u=!0,o.classList.remove("enter","show"),o.classList.add("exit"),setTimeout(()=>o.remove(),this.#R))};"function"==typeof i&&o.addEventListener("click",e=>{e.target!==a&&i(e,h)}),a.addEventListener("click",e=>{e.stopPropagation(),h()}),setTimeout(()=>{o.classList.remove("enter"),o.classList.add("show")},1),setTimeout(()=>h(),l)}destroy(){this.#h||this.#P instanceof HTMLElement&&(this.#P.querySelectorAll(".notify").forEach(e=>e.remove()),this.#P.parentNode&&this.#P.parentNode.removeChild(this.#P),this.#P=null,this.#h=!0)}};function se(e,t){if(!(e instanceof Blob))return Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'));const r=["readAsArrayBuffer","readAsDataURL","readAsText","readAsBinaryString"];return"string"==typeof t&&r.includes(t)?new Promise((r,i)=>{const n=new FileReader;n.onload=()=>{try{r(n.result)}catch(e){i(e)}},n.onerror=()=>{i(n.error)},n[t](e)}):Promise.reject(new TypeError(`The "method" argument must be one of: ${r.join(", ")}.`))}function oe(e,t=!1){return e instanceof Blob?"string"!=typeof t&&"boolean"!=typeof t?Promise.reject(new TypeError("The isDataUrl parameter must be a boolean or a string.")):new Promise((r,i)=>{se(e,"readAsDataURL").then(e=>{if("string"!=typeof e)throw new TypeError("Expected file content to be a string.");const i=e.match(/^data:(.+);base64,(.*)$/);if(!i||!i[2])throw new Error("Invalid data URL format or missing Base64 content.");const[,n,s]=i;if(!/^[\w/+]+=*$/.test(s))throw new Error("Base64 content is malformed.");if("boolean"==typeof t)return r(t?e:s);if(!/^[\w-]+\/[\w.+-]+$/.test(t))throw new Error(`Invalid MIME type string: ${t}`);return r(`data:${t};base64,${s}`)}).catch(i)}):Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'))}function ae(e){return e instanceof Blob?new Promise((t,r)=>se(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 i=JSON.parse(r);if("object"!=typeof i||null===i)throw new Error("Parsed content is not a valid JSON object or array.");t(i)}).catch(r)):Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'))}function le(e,t,r=2){if("string"!=typeof e)throw new TypeError('The "filename" argument must be a string.');if("number"!=typeof r||!Number.isInteger(r)||r<0)throw new TypeError('The "spaces" argument must be a non-negative integer.');const i=JSON.stringify(t,null,r),n=new Blob([i],{type:"application/json"}),s=URL.createObjectURL(n),o=document.createElement("a");o.href=s,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(s)}function ue(e,t,r=e=>({headers:e.headers,status:e.status,statusText:e.statusText})){if(!(e instanceof Response))throw new TypeError('The "response" argument must be an instance of Response.');if("function"!=typeof t)throw new TypeError('The "onProgress" argument must be a function.');if(!e.body)return e;const i=e.headers.get("content-length"),n=i?parseInt(i,10):0;let s=0;const o=e.body.getReader(),a=new ReadableStream({async start(e){for(;;){const{done:r,value:i}=await o.read();if(r)break;s+=i.byteLength,t(s,n),e.enqueue(i)}e.close()}});return new Response(a,r(e))}async function he(e,t,r){return"string"!=typeof e?Promise.reject(new TypeError('The "url" argument must be a string.')):void 0!==t&&"object"!=typeof t?Promise.reject(new TypeError('The "options" argument must be an object.')):void 0!==r&&"function"!=typeof r?Promise.reject(new TypeError('The "onProgress" option must be a function.')):new Promise((i,n)=>{fetch(e,t??void 0).then(async e=>{const t=r?ue(e,r):e,n=t.headers.get("content-type")||"";if(!n.includes("application/json"))throw new Error(`Unexpected content-type: ${n}`);const s=await t.json();if(!Array.isArray(s)&&!f(s))throw new Error("Received invalid data instead of valid JSON.");return i(s)}).catch(n)})}async function ce(e,t,r,i){return"string"!=typeof e?Promise.reject(new TypeError('The "url" argument must be a string.')):void 0===t||Array.isArray(t)?void 0!==r&&"object"!=typeof r?Promise.reject(new TypeError('The "options" argument must be an object.')):void 0!==i&&"function"!=typeof i?Promise.reject(new TypeError('The "onProgress" option must be a function.')):new Promise((n,s)=>{fetch(e,r??void 0).then(async e=>{const r=i?ue(e,i):e,s=r.headers.get("content-type")||"";if(Array.isArray(t)&&t.length>0&&!t.some(e=>s.includes(e)))throw new Error(`Blocked MIME type: ${s}`);const o=await r.text();return n(o)}).catch(s)}):Promise.reject(new TypeError('The "allowedMimeTypes" argument must be an array of strings.'))}function de(e={}){if(null===e||"object"!=typeof e)throw new TypeError('The "settings" argument must be an object.');const{element:t=document.body,hiddenClass:r="windowHidden",visibleClass:i="windowVisible",onVisible:n,onHidden:s}=e;if(!(t instanceof Element))throw new TypeError('"element" must be an instance of Element.');if("string"!=typeof r)throw new TypeError('"hiddenClass" must be a string.');if("string"!=typeof i)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!==s&&"function"!=typeof s)throw new TypeError('"onHidden" must be a function if provided.');let o="",a="";const l=()=>{t.classList.remove(r),t.classList.remove(i)};let u=null;const h=["visibilitychange","mozvisibilitychange","webkitvisibilitychange","msvisibilitychange"],c=["hidden","mozHidden","webkitHidden","msHidden"];for(let e=0;e<c.length;e++)if(c[e]in document){u=c[e];break}const d=function(e){l();const h=e?.type,c=u&&document[u];["focus","focusin","pageshow"].includes(h)?(t.classList.add(i),n?.({type:h,oldClass:a,oldType:o}),a=i):["blur","focusout","pagehide"].includes(h)||c?(t.classList.add(r),s?.({type:h,oldClass:a,oldType:o}),a=r):(t.classList.add(i),n?.({type:h,oldClass:a,oldType:o}),a=i),o=h};let m=()=>{};if(u){const e=h[c.indexOf(u)];document.addEventListener(e,d),window.addEventListener("focus",d),window.addEventListener("blur",d),m=()=>{document.removeEventListener(e,d),window.removeEventListener("focus",d),window.removeEventListener("blur",d),l()}}else"onfocusin"in document?(document.onfocusin=document.onfocusout=d,m=()=>{document.onfocusin=document.onfocusout=null,l()}):(window.onpageshow=window.onpagehide=window.onfocus=window.onblur=d,m=()=>{window.onpageshow=window.onpagehide=window.onfocus=window.onblur=null,l()});const p=new Event(u&&document[u]?"blur":"focus");return d(p),m}const me=X("TinyDragDropDetector"),pe=class{#F;#B;#z;#W;#q;#V;#K;#h=!1;get destroyed(){return this.#h}constructor(e,t){const{hoverClass:r="dnd-hover",onDrop:i,onEnter:n,onLeave:s}=t;if(!(e instanceof HTMLElement))throw new TypeError('The "target" option must be an instance of HTMLElement.');if("string"!=typeof r)throw new TypeError('The "hoverClass" option must be a string.');if("function"!=typeof i)throw new TypeError('The "onDrop" option must be a function.');if("function"!=typeof n)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.#F=e,this.#B=r,this.#z=i||(()=>{}),this.#W=n,this.#q=s,this.#V=!1,this.#K=!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.#J()}getTarget(){return me(this.#h),this.#F}getHoverClass(){return me(this.#h),this.#B}isDragging(){return me(this.#h),this.#V}bound(){return me(this.#h),this.#K}#J(){if(this.#K)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.#K=!0}#U(){if(!this.#K)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.#K=!1}_handleDragEnter(e){if(e.preventDefault(),!this.#V){const t=this.getTarget();this.#V=!0,t.classList.add(this.#B),this.#W(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.#B),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.#B);const r=e.dataTransfer.files;r.length>0&&this.#z(r,e)}destroy(){this.#h||(this.#U(),this.getTarget().classList.remove(this.#B),this.#h=!0)}};var fe=r(133),ye=r(975);function ge(e){if(!(0,fe.existsSync)(e))throw new Error(`File not found: ${e}`);const t=(0,fe.readFileSync)(e,"utf-8");return JSON.parse(t)}function we(e,t,r=2){const i=JSON.stringify(t,null,r);(0,fe.writeFileSync)(e,i,"utf-8")}function be(e){(0,fe.existsSync)(e)||(0,fe.mkdirSync)(e,{recursive:!0})}function ve(e){if(!(0,fe.existsSync)(e))return;const t=(0,fe.readdirSync)(e);for(const r of t){const t=(0,ye.join)(e,r);(0,fe.lstatSync)(t).isDirectory()?(0,fe.rmSync)(t,{recursive:!0,force:!0}):(0,fe.unlinkSync)(t)}}function Ee(e){return(0,fe.existsSync)(e)&&(0,fe.lstatSync)(e).isFile()}function Te(e){return(0,fe.existsSync)(e)&&(0,fe.lstatSync)(e).isDirectory()}function Se(e){return 0===(0,fe.readdirSync)(e).length}function xe(e,t,r){be((0,ye.dirname)(t)),(0,fe.copyFileSync)(e,t,r)}function Ae(e){return!!Ee(e)&&((0,fe.unlinkSync)(e),!0)}function Ce(e,t,r="utf-8"){be((0,ye.dirname)(e)),(0,fe.writeFileSync)(e,t,r)}function Ie(e,t=!1){const r={files:[],dirs:[]};if(!Te(e))return r;const i=(0,fe.readdirSync)(e);for(const n of i){const i=(0,ye.join)(e,n);if((0,fe.lstatSync)(i).isDirectory()){if(r.dirs.push(i),t){const e=Ie(i,!0);r.files.push(...e.files),r.dirs.push(...e.dirs)}}else r.files.push(i)}return r}function De(e,t=!1){const r=[];if(!Te(e))return r;const i=(0,fe.readdirSync)(e);for(const n of i){const i=(0,ye.join)(e,n);(0,fe.lstatSync)(i).isDirectory()&&(r.push(i),t&&r.push(...De(i,!0)))}return r}function Me(e){return Ee(e)?(0,fe.statSync)(e).size:0}function Ne(e){let t=0;const r=Ie(e,!0).files;for(const e of r)t+=Me(e);return t}function ke(e,t="bak"){Ee(e)&&xe(e,`${e}.${t}.${(new Date).toISOString().replace(/[:.]/g,"-")}`)}function Le(e,t="bak"){const r=(0,ye.dirname)(e),i=(0,ye.basename)(e),n=(0,fe.readdirSync)(r).filter(e=>e.startsWith(`${i}.${t}.`)).sort().reverse();if(0===n.length)throw new Error(`No backups found for ${e}`);return(0,ye.join)(r,n[0])}function _e(e,t="bak"){xe(Le(e,t),e)}function je(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,fe.existsSync)(e)||!(0,fe.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 i=Ie(e).files;let n=0;for(const s of i){const i=(0,ye.extname)(s);if(r.length&&!r.includes(i))continue;const o=(0,ye.basename)(s),a=t(o,n++),l=(0,ye.join)(e,a);o!==a&&(0,fe.renameSync)(s,l)}}function Re(e,t,r,i=[]){je(e,e=>{const i=(0,ye.extname)(e);return`${(0,ye.basename)(e,i).replace(t,r)}${i}`},i)}function Pe(e,{prefix:t="",suffix:r=""},i=[]){je(e,e=>{const i=(0,ye.extname)(e),n=(0,ye.basename)(e,i);return`${t}${n}${r}${i}`},i)}function $e(e,t="lower",r=[],i=!1){if("string"!=typeof t||!["lower","upper","title"].includes(t))throw new Error(`Invalid mode "${t}". Must be 'lower', 'upper' or 'title'.`);je(e,e=>{const r=e=>"lower"===t?e.toLowerCase():"upper"===t?e.toUpperCase():"title"===t?z(e):e,n=(0,ye.extname)(e),s=i?r(n):n;return`${r((0,ye.basename)(e,n))}${s}`},r)}function He(e,t=3,r=[]){je(e,e=>e.replace(/\d+/,e=>e.padStart(t,"0")),r)}var Oe=r(370);async function Fe(e){if(!(0,fe.existsSync)(e))return;const t=await(0,Oe.readdir)(e),r={},i=[];for(const n of t){const t=(0,ye.join)(e,n),s=(0,Oe.lstat)(t);s.then(e=>(r[t]=e,e)),i.push(s)}await Promise.all(i);const n=[];for(const e in r)r[e].isDirectory()?n.push((0,Oe.rm)(e,{recursive:!0,force:!0})):n.push((0,Oe.unlink)(e));await Promise.all(n)}async function Be(e){return 0===(await(0,Oe.readdir)(e)).length}async function ze(e,t=!1){const r={files:[],dirs:[]};if(!Te(e))return r;const i=await(0,Oe.readdir)(e);for(const n of i){const i=(0,ye.join)(e,n);if((await(0,Oe.lstat)(i)).isDirectory()){if(r.dirs.push(i),t){const e=await ze(i,!0);r.files.push(...e.files),r.dirs.push(...e.dirs)}}else r.files.push(i)}return r}async function We(e,t=!1){const r=[];if(!Te(e))return r;const i=await(0,Oe.readdir)(e);for(const n of i){const i=(0,ye.join)(e,n);(await(0,Oe.lstat)(i)).isDirectory()&&(r.push(i),t&&r.push(...await We(i,!0)))}return r}async function qe(e){return Ee(e)?(await(0,Oe.stat)(e)).size:0}async function Ve(e){let t=0;const{files:r}=await ze(e,!0),i=[];for(const e of r){const r=qe(e);r.then(e=>(t+=e,e)),i.push(r)}return await Promise.all(i),t}const Ke=(e,t)=>e.bottom<t.top,Je=(e,t)=>e.top>t.bottom,Ue=(e,t)=>e.right<t.left,Ge=(e,t)=>e.left>t.right,Ye=(e,t)=>e.bottom<=t.top,Xe=(e,t)=>e.top>=t.bottom,Qe=(e,t)=>e.right<=t.left,Ze=(e,t)=>e.left>=t.right,et=(e,t)=>!(Ue(e,t)||Ge(e,t)||Ke(e,t)||Je(e,t)),tt=(e,t)=>!(Qe(e,t)||Ze(e,t)||Ye(e,t)||Xe(e,t)),rt=(e,t)=>Ue(e,t)?"left":Ge(e,t)?"right":Ke(e,t)?"top":Je(e,t)?"bottom":null,it=(e,t)=>Qe(e,t)?"left":Ze(e,t)?"right":Ye(e,t)?"top":Xe(e,t)?"bottom":null,nt=(e,t)=>({overlapLeft:t.right-e.left,overlapRight:e.right-t.left,overlapTop:t.bottom-e.top,overlapBottom:e.bottom-t.top}),st=({overlapLeft:e=-1,overlapRight:t=-1,overlapTop:r=-1,overlapBottom:i=-1}={})=>({dirX:e<t?"right":"left",dirY:r<i?"bottom":"top"}),ot=e=>({x:e.left+e.width/2,y:e.top+e.height/2});function at(e,t){const r=e.left+e.width/2,i=e.top+e.height/2;return{x:t.left+t.width/2-r,y:t.top+t.height/2-i}}function lt(e,t){if(!tt(e,t))return{inDir:null,dirX:null,dirY:null,depthX:0,depthY:0};const{overlapLeft:r,overlapRight:i,overlapTop:n,overlapBottom:s}=nt(e,t),{dirX:o,dirY:a}=st({overlapLeft:r,overlapRight:i,overlapTop:n,overlapBottom:s}),l=Math.min(r,i),u=Math.min(n,s);let h;return h=l<u?o:a,{inDir:h,dirX:o,dirY:a,depthX:l,depthY:u}}function ut(e,t){const r=tt(e,t),i={in:null,x:null,y:null},n={y:null,x:null},s={top:0,bottom:0,left:0,right:0},{overlapLeft:o,overlapRight:a,overlapTop:l,overlapBottom:u}=nt(t,e);s.top=l,s.bottom=u,s.left=o,s.right=a;const h=Object.entries(s).filter(([,e])=>e>0).sort((e,t)=>e[1]-t[1]),{dirX:c,dirY:d}=st({overlapLeft:a,overlapRight:o,overlapTop:u,overlapBottom:l});return i.y=d,i.x=c,s.bottom<0?n.y="bottom":s.top<0&&(n.y="top"),s.left<0?n.x="left":s.right<0&&(n.x="right"),i.in=r?s.top===s.bottom&&s.bottom===s.left&&s.left===s.right?"center":h.length?h[0][0]:"top":null,{dirs:i,depth:s,isNeg:n}}const ht=X("TinyElementObserver"),ct=class{#h=!1;get destroyed(){return this.#h}#G;get el(){return ht(this.#h),this.#G}#Y={};get settings(){return ht(this.#h),this.#Y}set settings(e){if(ht(this.#h),"object"!=typeof e||null===e)throw new TypeError("settings must be a non-null object.");this.#Y=e}#X=null;get observer(){return ht(this.#h),this.#X}#Q=[];get detectors(){return ht(this.#h),this.#Q.map(e=>[e[0],e[1]])}set detectors(e){if(ht(this.#h),!Array.isArray(e))throw new TypeError("detectors must be an array.");const t=[];for(const[r,i]of e){if("string"!=typeof r)throw new TypeError("Detector name must be a string.");if("function"!=typeof i)throw new TypeError(`Detector handler for "${r}" must be a function.`);t.push([r,i])}this.#Q=t}get isActive(){return ht(this.#h),!!this.#X}get size(){return ht(this.#h),this.#Q.length}constructor(e,{initDetectors:t=[],initCfg:r={}}={}){this.#G=e,t.length&&(this.detectors=t),r&&(this.settings=r)}clear(){ht(this.#h),this.#Q=[]}start(){if(ht(this.#h),!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(i=>i[1](e,t,r)))}),this.#X.observe(this.#G,this.#Y))}stop(){ht(this.#h),this.#X&&(this.#X.disconnect(),this.#X=null)}add(e,t){ht(this.#h),this.#Z(e,t),this.#Q.push([e,t])}insertAtStart(e,t){ht(this.#h),this.#Z(e,t),this.#Q.unshift([e,t])}insertAt(e,t,r,i="after"){if(ht(this.#h),this.#Z(t,r),"number"!=typeof e||e<0||e>=this.#Q.length)throw new RangeError("Invalid index for insertDetectorAt.");const n="before"===i?e:e+1;this.#Q.splice(n,0,[t,r])}removeAt(e){if(ht(this.#h),"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(ht(this.#h),"number"!=typeof e||e<0||e>=this.#Q.length)throw new RangeError("Invalid index for removeDetectorsAround.");const i=Math.max(0,e-t),n=t+1+r;this.#Q.splice(i,n)}isIndexUsed(e){return ht(this.#h),e>=0&&e<this.#Q.length}hasHandler(e){if(ht(this.#h),"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.#h||(this.stop(),this.clear(),this.#h=!0)}},{wE:dt,D6:mt,Kr:pt,iu:ft,cq:yt,lP:gt}=e,wt=new WeakMap,bt=new WeakMap,vt=new WeakMap,Et=new WeakMap,Tt={top:new WeakMap,bottom:new WeakMap,left:new WeakMap,right:new WeakMap};class St{static Utils={...t};static#ee=1;static get version(){return this.#ee}static#te=!1;static get elemDebug(){return St.#te}static set elemDebug(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean value for elemDebug");St.#te=e}static _debugElemError(e,t){if(!St.#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,St._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,i]=e.split(":").map(e=>e&&e.trim());r&&i&&(t[r]=i)}),t}static#re="undefined"!=typeof window&&void 0!==window.document?new ct(window.document.documentElement,{initDetectors:[["tinyStyleEvent",e=>{if("attributes"!==e.type||"style"!==e.attributeName||!(e.target instanceof HTMLElement))return;const t=e.oldValue||"",r=e.target.getAttribute("style")||"",i=K(St.parseStyle(t),St.parseStyle(r));(Object.keys(i.added).length||Object.keys(i.removed).length||Object.keys(i.modified).length)&&e.target.dispatchEvent(new CustomEvent("tinyhtml.stylechanged",{detail:i}))}],["tinyClassEvent",e=>{if("attributes"!==e.type||"class"!==e.attributeName||!(e.target instanceof HTMLElement))return;const t=e.oldValue||"",r=e.target.className||"",i=a(t.split(/\s+/).filter(Boolean),r.split(/\s+/).filter(Boolean));(i.added.length||i.removed.length)&&e.target.dispatchEvent(new CustomEvent("tinyhtml.classchanged",{detail:i}))}]],initCfg:{attributeOldValue:!0,attributes:!0,subtree:!0,attributeFilter:["style","class"]}}):void 0;static get tinyObserver(){return St.#re}static async fetchHtmlFile(e,t={method:"GET"}){const r=await fetch(e,t),i=r.headers.get("Content-Type")||"";if(!r.ok)throw new Error(`Failed to fetch: ${r.status} ${r.statusText}`);if(!i.includes("text/html"))throw new Error(`Invalid content type: ${i} (expected text/html)`);const n=await r.text();return St.htmlToJson(n)}static async fetchHtmlNodes(e,t){const r=await St.fetchHtmlFile(e,t);return St.jsonToNodes(r)}static async fetchHtmlTinyElems(e,t){const r=await St.fetchHtmlNodes(e,t);return St.toTinyElm(r)}static templateToJson(e){return St.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 St.toTinyElm(St.templateToNodes(e))}static htmlToJson(e){const t=document.createElement("div");t.innerHTML=e.trim();const r=[],i=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[St.getPropName(t.name)]=t.value;const n=Array.from(e.childNodes).map(i).filter(Boolean);return n.length>0?[t,r,...n]:[t,r]};for(const e of t.childNodes){const t=i(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,i,...n]=e,s=document.createElement(r);for(const[e,t]of Object.entries(i))s.setAttribute(St.getAttrName(e),t);for(const e of n){const r=t(e);r instanceof Comment||s.appendChild(r)}return s};return e.map(t).filter(e=>!(e instanceof Comment))}static jsonToTinyElems(e){return St.toTinyElm(St.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=St.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 St(document.createElement(e,t))}static createTextNode(e){if("string"!=typeof e)throw new TypeError("[TinyHtml] createTextNode(): The value must be a string.");return new St(document.createTextNode(e))}static createElementFromHTML(e){const t=document.createElement("template");if(!(e=e.trim()).startsWith("<"))return St.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 St(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 St(r)}static createFromHtml(e){return St.createFromHTML(e)}static query(e,t=document){const r=t.querySelector(e);return r?new St(r):null}querySelector(e){return St.query(e,St._preElem(this,"query"))}static queryAll(e,t=document){return new St(t.querySelectorAll(e))}querySelectorAll(e){return St.queryAll(e,St._preElem(this,"queryAll"))}static getById(e){const t=document.getElementById(e);return t?new St(t):null}static getByClassName(e,t=document){return new St(t.getElementsByClassName(e))}getElementsByClassName(e){return St.getByClassName(e,St._preElem(this,"getByClassName"))}static getByName(e){return new St(document.getElementsByName(e))}static getByTagNameNS(e,t="http://www.w3.org/1999/xhtml",r=document){return new St(r.getElementsByTagNameNS(t,e))}getElementsByTagNameNS(e,t="http://www.w3.org/1999/xhtml"){return St.getByTagNameNS(e,t,St._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 St(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 St._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 St._debugElemError([...this.#G]),new Error(`[TinyHtml] Invalid Element in ${e}().`);return[...this.#G]}static _preElemsTemplate(e,t,r,i){const n=e=>{const n=[];return e.map(s=>(s instanceof St?s._getElements(t):[s]).map(s=>{let o=!1;for(const e of r)if(s instanceof e){o=!0;break}if(!o)throw St._debugElemError([...e],s),new Error(`[TinyHtml] Invalid element of the list "${i.join(",")}" in ${t}().`);return n.push(s),s})),n};return Array.isArray(e)?n(e):n([e])}_preElemsTemplate(e,t,r){return St._preElemsTemplate(this,e,t,r)}static _preElemTemplate(e,t,r,i,n=!1){const s=e=>{const s=e[0],o=s instanceof St?s._getElements(t):[s];if(o.length>1)throw St._debugElemError([...e]),new Error(`[TinyHtml] Invalid element amount in ${t}() (Received ${o.length}/1).`);let a=!1;for(const e of r)if(o[0]instanceof e){a=!0;break}if(!n||null!==o[0]&&void 0!==o[0]||(o[0]=null,a=!0),!a)throw St._debugElemError([...e],o[0]),new Error(`[TinyHtml] Invalid element of the list "${i.join(",")}" in ${t}().`);return o[0]};if(!Array.isArray(e))return s([e]);if(e.length>1)throw St._debugElemError([...e]),new Error(`[TinyHtml] Invalid element amount in ${t}() (Received ${e.length}/1).`);return s(e)}_preElemTemplate(e,t,r,i=!1){return St._preElemTemplate(this,e,t,r,i)}static _preElems(e,t){return St._preElemsTemplate(e,t,[Element],["Element"])}_preElems(e){return St._preElems(this,e)}static _preElem(e,t){return St._preElemTemplate(e,t,[Element],["Element"])}_preElem(e){return St._preElem(this,e)}static _preNodeElems(e,t){return St._preElemsTemplate(e,t,[Node],["Node"])}_preNodeElems(e){return St._preNodeElems(this,e)}static _preNodeElem(e,t){return St._preElemTemplate(e,t,[Node],["Node"])}_preNodeElem(e){return St._preNodeElem(this,e)}static _preNodeElemWithNull(e,t){return St._preElemTemplate(e,t,[Node],["Node"],!0)}_preNodeElemWithNull(e){return St._preNodeElemWithNull(this,e)}static _preHtmlElems(e,t){return St._preElemsTemplate(e,t,[HTMLElement],["HTMLElement"])}_preHtmlElems(e){return St._preHtmlElems(this,e)}static _preHtmlElem(e,t){return St._preElemTemplate(e,t,[HTMLElement],["HTMLElement"])}_preHtmlElem(e){return St._preHtmlElem(this,e)}static _preInputElems(e,t){return St._preElemsTemplate(e,t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElems(e){return St._preInputElems(this,e)}static _preInputElem(e,t){return St._preElemTemplate(e,t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElem(e){return St._preInputElem(this,e)}static _preEventTargetElems(e,t){return St._preElemsTemplate(e,t,[EventTarget],["EventTarget"])}_preEventTargetElems(e){return St._preEventTargetElems(this,e)}static _preEventTargetElem(e,t){return St._preElemTemplate(e,t,[EventTarget],["EventTarget"])}_preEventTargetElem(e){return St._preEventTargetElem(this,e)}static _preElemsAndWindow(e,t){return St._preElemsTemplate(e,t,[Element,Window],["Element","Window"])}_preElemsAndWindow(e){return St._preElemsAndWindow(this,e)}static _preElemAndWindow(e,t){return St._preElemTemplate(e,t,[Element,Window],["Element","Window"])}_preElemAndWindow(e){return St._preElemAndWindow(this,e)}static _preElemsAndWinAndDoc(e,t){return St._preElemsTemplate(e,t,[Element,Window,Document],["Element","Window","Document"]).map(e=>e instanceof Document?e.documentElement:e)}_preElemsAndWinAndDoc(e){return St._preElemsAndWinAndDoc(this,e)}static _preElemAndWinAndDoc(e,t){const r=St._preElemTemplate(e,t,[Element,Window,Document],["Element","Window","Document"]);return r instanceof Document?r.documentElement:r}_preElemAndWinAndDoc(e){return St._preElemAndWinAndDoc(this,e)}static _preElemsWithDoc(e,t){return St._preElemsTemplate(e,t,[Element,Document],["Element","Document"])}_preElemsWithDoc(e){return St._preElemsWithDoc(this,e)}static _preElemWithDoc(e,t){return St._preElemTemplate(e,t,[Element,Document],["Element","Document"])}_preElemWithDoc(e){return St._preElemWithDoc(this,e)}static toTinyElm(e){const t=e=>e.map(e=>e instanceof St?e:new St(e));return Array.isArray(e)?t(e):t([e])}static fromTinyElm(e){const t=e=>{const t=[];return e.map(e=>(e instanceof St?e._getElements("fromTinyElm"):[e]).map(e=>t.push(e))),t};return Array.isArray(e)?t(e):t([e])}static winnow(e,t,r,i=!1){if("boolean"!=typeof i)throw new TypeError('The "not" must be a boolean.');if("function"==typeof t)return St._preElems(e,r).filter((e,r)=>!!t.call(e,r,e)!==i);if(t instanceof Element)return St._preElems(e,r).filter(e=>e===t!==i);if(Array.isArray(t)||"string"!=typeof t&&null!=t.length)return St._preElems(e,r).filter(e=>t.includes(e)!==i);let n=t;return i&&(n=`:not(${n})`),St._preElems(e,r).filter(e=>1===e.nodeType&&e.matches(n))}static filter(e,t,r=!1){return r&&(t=`:not(${t})`),St._preElems(e,"filter").filter(e=>1===e.nodeType&&e.matches(t))}static filterOnly(e,t){return St.winnow(e,t,"filterOnly",!1)}static not(e,t){return St.winnow(e,t,"not",!0)}not(e){return St.not(this,e)}static find(e,t){const r=[];for(const i of St._preElems(e,"find"))r.push(...i.querySelectorAll(t));return[...new Set(r)]}find(e){return St.find(this,e)}static is(e,t){return St.winnow(e,t,"is",!1).length>0}is(e){return St.is(this,e)}static has(e,t){const r="string"==typeof t?[...document.querySelectorAll(t)]:St._preElems(t,"has");return St._preElems(e,"has").filter(e=>r.some(t=>e&&e.contains(t)))}has(e){return St.has(this,e)}static closest(e,t,r){const i=[];for(const n of St._preElems(e,"closest")){let e=n;for(;e&&e!==r;){if(1===e.nodeType&&("string"==typeof t?e.matches(t):e===t)){i.push(e);break}e=e.parentElement}}return[...new Set(i)]}closest(e,t){return St.closest(this,e,t)}static isSameDom(e,t){return St._preNodeElem(e,"isSameDom")===St._preNodeElem(t,"isSameDom")}isSameDom(e){return St.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=St._preElem(t,e);let i=bt.get(r);return i||(i={},bt.set(r,i)),i},private:(e,t)=>{if(!(t instanceof St))throw new Error(`Element must be a TinyHtml instance to execute ${e}().`);return t.#ie}};static data(e,t,r=!1){const i=St._dataSelector[r?"private":"public"]("data",e);if(null==t)return{...i};if("string"!=typeof t)throw new TypeError("The key must be a string.");return i.hasOwnProperty(t)?i[t]:void 0}data(e,t){return St.data(this,e,t)}static setData(e,t,r,i=!1){const n=St._dataSelector[i?"private":"public"]("setData",e);if("string"!=typeof t)throw new TypeError("The key must be a string.");return void 0!==r?n[t]=r:St.removeData(e,t),e}setData(e,t,r=!1){return St.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 i=St._dataSelector[r?"private":"public"]("hasData",e);return Object.prototype.hasOwnProperty.call(i,t)}hasData(e,t=!1){return St.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 St._dataSelector[r?"private":"public"]("removeData",e)[t]}removeData(e,t=!1){return St.removeData(this,e,t)}static _getSibling(e,t,r){let i=St._preNodeElemWithNull(e,r);for(;i&&(i=i[t])&&1!==i.nodeType;);return i instanceof Node?i:null}static _getSiblings(e,t){let r=e;const i=[];for(;r;r=r.nextSibling)1===r.nodeType&&r!==t&&i.push(r);return i}static domDir(e,t,r,i="domDir"){if("string"!=typeof t)throw new TypeError('The "direction" must be a string.');let n=St._preNodeElemWithNull(e,i);const s=[];for(;n&&(n=n[t]);)if(1===n.nodeType){if(r&&("string"==typeof r?n.matches(r):n===r))break;s.push(n)}return s}static parent(e){let t=St._preNodeElemWithNull(e,"parent");const r=t?t.parentNode:null;return r&&11!==r.nodeType?r:null}parent(){return St.parent(this)}static parents(e,t){return St.domDir(e,"parentNode",t,"parents")}parents(e){return St.parents(this,e)}static next(e){return St._getSibling(e,"nextSibling","next")}next(){return St.next(this)}static prev(e){return St._getSibling(e,"previousSibling","prev")}prev(){return St.prev(this)}static nextAll(e){return St.domDir(e,"nextSibling",void 0,"nextAll")}nextAll(){return St.nextAll(this)}static prevAll(e){return St.domDir(e,"previousSibling",void 0,"prevAll")}prevAll(){return St.prevAll(this)}static nextUntil(e,t){return St.domDir(e,"nextSibling",t,"nextUtil")}nextUntil(e){return St.nextUntil(this,e)}static prevUntil(e,t){return St.domDir(e,"previousSibling",t,"prevUtil")}prevUntil(e){return St.prevUntil(this,e)}static siblings(e){const t=St._preNodeElemWithNull(e,"siblings");return St._getSiblings(t&&t.parentNode?t.parentNode.firstChild:null,t)}siblings(){return St.siblings(this)}static children(e){const t=St._preNodeElemWithNull(e,"children");return St._getSiblings(t?t.firstChild:null)}children(){return St.children(this)}static contents(e){const t=St._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 St.contents(this)}static clone(e,t=!0){if("boolean"!=typeof t)throw new TypeError('The "deep" must be a boolean.');return St._preNodeElems(e,"clone").map(e=>e.cloneNode(t))}clone(e){return St.clone(this,e)[0]}static _appendChecker(e,...t){const r=[];for(const i of t)if(null!=i&&!1!==i)if("string"!=typeof i&&"number"!=typeof i)if(i instanceof Node||i instanceof St)r.push(...St._preNodeElems(i,e));else if(Array.isArray(i))r.push(...St._appendChecker(e,...i));else for(const t in i){const n=i[t];r.push(...St._appendChecker(e,n))}else r.push(i);return r}static append(e,...t){return St._preElem(e,"append").append(...St._appendChecker("append",...t)),e}append(...e){return St.append(this,...e)}static prepend(e,...t){return St._preElem(e,"prepend").prepend(...St._appendChecker("prepend",...t)),e}prepend(...e){return St.prepend(this,...e)}static before(e,...t){return St._preElem(e,"before").before(...St._appendChecker("before",...t)),e}before(...e){return St.before(this,...e)}static after(e,...t){return St._preElem(e,"after").after(...St._appendChecker("after",...t)),e}after(...e){return St.after(this,...e)}static replaceWith(e,...t){return St._preElem(e,"replaceWith").replaceWith(...St._appendChecker("replaceWith",...t)),e}replaceWith(...e){return St.replaceWith(this,...e)}static appendTo(e,t){const r=St._preNodeElems(e,"appendTo"),i=St._preNodeElems(t,"appendTo");return i.forEach((e,t)=>{r.forEach(r=>e.appendChild(t===i.length-1?r:r.cloneNode(!0)))}),e}appendTo(e){return St.appendTo(this,e)}static prependTo(e,t){const r=St._preElems(e,"prependTo"),i=St._preElems(t,"prependTo");return i.forEach((e,t)=>{r.slice().reverse().forEach(r=>e.prepend(t===i.length-1?r:r.cloneNode(!0)))}),e}prependTo(e){return St.prependTo(this,e)}static insertBefore(e,t,r=null){const i=St._preNodeElem(e,"insertBefore"),n=St._preNodeElem(t,"insertBefore"),s=St._preNodeElemWithNull(r,"insertBefore");if(!n.parentNode)throw new Error("The target element has no parent node to insert before.");return n.parentNode.insertBefore(i,s||n),e}insertBefore(e,t){return St.insertBefore(this,e,t)}static insertAfter(e,t,r=null){const i=St._preNodeElem(e,"insertAfter"),n=St._preNodeElem(t,"insertBefore"),s=St._preNodeElemWithNull(r,"insertBefore");if(!n.parentNode)throw new Error("The target element has no parent node to insert after.");return n.parentNode.insertBefore(i,s||n.nextSibling),e}insertAfter(e,t){return St.insertAfter(this,e,t)}static replaceAll(e,t){const r=St._preNodeElems(e,"replaceAll"),i=St._preNodeElems(t,"replaceAll");return i.forEach((e,t)=>{const n=e.parentNode;r.forEach(r=>{n&&n.replaceChild(t===i.length-1?r:r.cloneNode(!0),e)})}),e}replaceAll(e){return St.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 St([...this.#G,...St._selector(e)])}static _selector(e){if(e instanceof St)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 St._elCheck(r),t(r);if(r instanceof NodeList||r instanceof HTMLCollection){const e=[...r];return St._elCheck(e),t(e)}{const e=[r];return St._elCheck(e),t(e)}}constructor(e){this.#G=St._selector(e),this.#ne=St.#se}static isWindow(e){return null!=e&&e===e.window}static css(e){const t=St._preElem(e,"css");return window.getComputedStyle(t)}css(){return St.css(this)}static cssString(e,t){const r=St._preElem(e,"cssString");if("string"!=typeof t)throw new TypeError("The prop must be a string.");const i=window.getComputedStyle(r)[t];return"string"==typeof i?i:"number"==typeof i?i.toString():null}cssString(e){return St.cssString(this,e)}static cssList(e,t){const r=St._preElem(e,"cssList");if(!Array.isArray(t))throw new TypeError("The prop must be an array of strings.");const i=window.getComputedStyle(r),n={};for(const e of t)void 0!==e&&(n[e]=i.getPropertyValue(e));return n}cssList(e){return St.cssList(this,e)}static cssFloat(e,t){const r=St._preElem(e,"cssFloat");if("string"!=typeof t)throw new TypeError("The prop must be a string.");const i=window.getComputedStyle(r)[t];return parseFloat(i)||0}cssFloat(e){return St.cssFloat(this,e)}static cssFloats(e,t){const r=St._preElem(e,"cssFloats");if(!Array.isArray(t))throw new TypeError("The prop must be an array of strings.");const i=window.getComputedStyle(r),n={};for(const e of t)n[e]=parseFloat(i[e])||0;return n}cssFloats(e){return St.cssFloats(this,e)}static#oe={alignContent:"align-content",alignItems:"align-items",alignSelf:"align-self",animationDelay:"animation-delay",animationDirection:"animation-direction",animationDuration:"animation-duration",animationFillMode:"animation-fill-mode",animationIterationCount:"animation-iteration-count",animationName:"animation-name",animationPlayState:"animation-play-state",animationTimingFunction:"animation-timing-function",backfaceVisibility:"backface-visibility",backgroundAttachment:"background-attachment",backgroundBlendMode:"background-blend-mode",backgroundClip:"background-clip",backgroundColor:"background-color",backgroundImage:"background-image",backgroundOrigin:"background-origin",backgroundPosition:"background-position",backgroundRepeat:"background-repeat",backgroundSize:"background-size",borderBottom:"border-bottom",borderBottomColor:"border-bottom-color",borderBottomLeftRadius:"border-bottom-left-radius",borderBottomRightRadius:"border-bottom-right-radius",borderBottomStyle:"border-bottom-style",borderBottomWidth:"border-bottom-width",borderCollapse:"border-collapse",borderColor:"border-color",borderImage:"border-image",borderImageOutset:"border-image-outset",borderImageRepeat:"border-image-repeat",borderImageSlice:"border-image-slice",borderImageSource:"border-image-source",borderImageWidth:"border-image-width",borderLeft:"border-left",borderLeftColor:"border-left-color",borderLeftStyle:"border-left-style",borderLeftWidth:"border-left-width",borderRadius:"border-radius",borderRight:"border-right",borderRightColor:"border-right-color",borderRightStyle:"border-right-style",borderRightWidth:"border-right-width",borderSpacing:"border-spacing",borderStyle:"border-style",borderTop:"border-top",borderTopColor:"border-top-color",borderTopLeftRadius:"border-top-left-radius",borderTopRightRadius:"border-top-right-radius",borderTopStyle:"border-top-style",borderTopWidth:"border-top-width",borderWidth:"border-width",boxDecorationBreak:"box-decoration-break",boxShadow:"box-shadow",boxSizing:"box-sizing",breakAfter:"break-after",breakBefore:"break-before",breakInside:"break-inside",captionSide:"caption-side",caretColor:"caret-color",clipPath:"clip-path",columnCount:"column-count",columnFill:"column-fill",columnGap:"column-gap",columnRule:"column-rule",columnRuleColor:"column-rule-color",columnRuleStyle:"column-rule-style",columnRuleWidth:"column-rule-width",columnSpan:"column-span",columnWidth:"column-width",counterIncrement:"counter-increment",counterReset:"counter-reset",emptyCells:"empty-cells",flexBasis:"flex-basis",flexDirection:"flex-direction",flexFlow:"flex-flow",flexGrow:"flex-grow",flexShrink:"flex-shrink",flexWrap:"flex-wrap",fontFamily:"font-family",fontFeatureSettings:"font-feature-settings",fontKerning:"font-kerning",fontLanguageOverride:"font-language-override",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontSynthesis:"font-synthesis",fontVariant:"font-variant",fontVariantAlternates:"font-variant-alternates",fontVariantCaps:"font-variant-caps",fontVariantEastAsian:"font-variant-east-asian",fontVariantLigatures:"font-variant-ligatures",fontVariantNumeric:"font-variant-numeric",fontVariantPosition:"font-variant-position",fontWeight:"font-weight",gridArea:"grid-area",gridAutoColumns:"grid-auto-columns",gridAutoFlow:"grid-auto-flow",gridAutoRows:"grid-auto-rows",gridColumn:"grid-column",gridColumnEnd:"grid-column-end",gridColumnGap:"grid-column-gap",gridColumnStart:"grid-column-start",gridGap:"grid-gap",gridRow:"grid-row",gridRowEnd:"grid-row-end",gridRowGap:"grid-row-gap",gridRowStart:"grid-row-start",gridTemplate:"grid-template",gridTemplateAreas:"grid-template-areas",gridTemplateColumns:"grid-template-columns",gridTemplateRows:"grid-template-rows",imageRendering:"image-rendering",justifyContent:"justify-content",letterSpacing:"letter-spacing",lineBreak:"line-break",lineHeight:"line-height",listStyle:"list-style",listStyleImage:"list-style-image",listStylePosition:"list-style-position",listStyleType:"list-style-type",marginBottom:"margin-bottom",marginLeft:"margin-left",marginRight:"margin-right",marginTop:"margin-top",maskClip:"mask-clip",maskComposite:"mask-composite",maskImage:"mask-image",maskMode:"mask-mode",maskOrigin:"mask-origin",maskPosition:"mask-position",maskRepeat:"mask-repeat",maskSize:"mask-size",maskType:"mask-type",maxHeight:"max-height",maxWidth:"max-width",minHeight:"min-height",minWidth:"min-width",mixBlendMode:"mix-blend-mode",objectFit:"object-fit",objectPosition:"object-position",offsetAnchor:"offset-anchor",offsetDistance:"offset-distance",offsetPath:"offset-path",offsetRotate:"offset-rotate",outlineColor:"outline-color",outlineOffset:"outline-offset",outlineStyle:"outline-style",outlineWidth:"outline-width",overflowAnchor:"overflow-anchor",overflowWrap:"overflow-wrap",overflowX:"overflow-x",overflowY:"overflow-y",paddingBottom:"padding-bottom",paddingLeft:"padding-left",paddingRight:"padding-right",paddingTop:"padding-top",pageBreakAfter:"page-break-after",pageBreakBefore:"page-break-before",pageBreakInside:"page-break-inside",perspectiveOrigin:"perspective-origin",placeContent:"place-content",placeItems:"place-items",placeSelf:"place-self",pointerEvents:"pointer-events",rowGap:"row-gap",scrollBehavior:"scroll-behavior",scrollMargin:"scroll-margin",scrollMarginBlock:"scroll-margin-block",scrollMarginBlockEnd:"scroll-margin-block-end",scrollMarginBlockStart:"scroll-margin-block-start",scrollMarginBottom:"scroll-margin-bottom",scrollMarginInline:"scroll-margin-inline",scrollMarginInlineEnd:"scroll-margin-inline-end",scrollMarginInlineStart:"scroll-margin-inline-start",scrollMarginLeft:"scroll-margin-left",scrollMarginRight:"scroll-margin-right",scrollMarginTop:"scroll-margin-top",scrollPadding:"scroll-padding",scrollPaddingBlock:"scroll-padding-block",scrollPaddingBlockEnd:"scroll-padding-block-end",scrollPaddingBlockStart:"scroll-padding-block-start",scrollPaddingBottom:"scroll-padding-bottom",scrollPaddingInline:"scroll-padding-inline",scrollPaddingInlineEnd:"scroll-padding-inline-end",scrollPaddingInlineStart:"scroll-padding-inline-start",scrollPaddingLeft:"scroll-padding-left",scrollPaddingRight:"scroll-padding-right",scrollPaddingTop:"scroll-padding-top",scrollSnapAlign:"scroll-snap-align",scrollSnapStop:"scroll-snap-stop",scrollSnapType:"scroll-snap-type",shapeImageThreshold:"shape-image-threshold",shapeMargin:"shape-margin",shapeOutside:"shape-outside",tabSize:"tab-size",tableLayout:"table-layout",textAlign:"text-align",textAlignLast:"text-align-last",textCombineUpright:"text-combine-upright",textDecoration:"text-decoration",textDecorationColor:"text-decoration-color",textDecorationLine:"text-decoration-line",textDecorationStyle:"text-decoration-style",textIndent:"text-indent",textJustify:"text-justify",textOrientation:"text-orientation",textOverflow:"text-overflow",textShadow:"text-shadow",textTransform:"text-transform",transformBox:"transform-box",transformOrigin:"transform-origin",transformStyle:"transform-style",transitionDelay:"transition-delay",transitionDuration:"transition-duration",transitionProperty:"transition-property",transitionTimingFunction:"transition-timing-function",unicodeBidi:"unicode-bidi",userSelect:"user-select",verticalAlign:"vertical-align",whiteSpace:"white-space",willChange:"will-change",wordBreak:"word-break",wordSpacing:"word-spacing",wordWrap:"word-wrap",writingMode:"writing-mode",zIndex:"z-index",WebkitTransform:"-webkit-transform",WebkitTransition:"-webkit-transition",WebkitBoxShadow:"-webkit-box-shadow",MozBoxShadow:"-moz-box-shadow",MozTransform:"-moz-transform",MozTransition:"-moz-transition",msTransform:"-ms-transform",msTransition:"-ms-transition"};static cssPropAliases=new Proxy(St.#oe,{set:(e,t,r)=>(e[t]=r,St.cssPropRevAliases[r]=t,!0)});static cssPropRevAliases=Object.fromEntries(Object.entries(St.#oe).map(([e,t])=>[t,e]));static toStyleKc(e){return"string"==typeof St.cssPropAliases[e]?St.cssPropAliases[e]:e}static toStyleCc(e){return"string"==typeof St.cssPropRevAliases[e]?St.cssPropRevAliases[e]:e}static setStyle(e,t,r=null){return St._preHtmlElems(e,"setStyle").forEach(e=>{if("object"==typeof t)for(const[r,i]of Object.entries(t))e.style.setProperty(St.toStyleKc(r),"string"==typeof i?i:"number"==typeof i?`${i}px`:String(i));else e.style.setProperty(St.toStyleKc(t),r)}),e}setStyle(e,t){return St.setStyle(this,e,t)}static getStyle(e,t){return St._preHtmlElem(e,"getStyle").style.getPropertyValue(St.toStyleKc(t))}getStyle(e){return St.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 i=St._preHtmlElem(e,"style"),n={};if(r){const e=(i.getAttribute("style")||"").split(";");for(const r of e){const[e,i]=r.split(":");if(!e||!i)continue;const s=e.trim(),o=i.trim();n[t?St.toStyleCc(s):s]=o}}else{const e=i.style;for(let r=0;r<e.length;r++){const i=e[r],s=e.getPropertyValue(i);n[t?St.toStyleCc(i):i]=s}}return n}style(e){return St.style(this,e)}static removeStyle(e,t){return St._preHtmlElems(e,"removeStyle").forEach(e=>{if(Array.isArray(t))for(const r of t)e.style.removeProperty(St.toStyleKc(r));else e.style.removeProperty(St.toStyleKc(t))}),e}removeStyle(e){return St.removeStyle(this,e)}static toggleStyle(e,t,r,i){return St._preHtmlElems(e,"toggleStyle").forEach(e=>{const n=St.getStyle(e,t).trim()===St.toStyleKc(r)?i:r;St.setStyle(e,t,n)}),e}toggleStyle(e,t,r){return St.toggleStyle(this,e,t,r)}static clearStyle(e){return St._preElems(e,"clearStyle").forEach(e=>e.removeAttribute("style")),e}clearStyle(){return St.clearStyle(this)}static focus(e){return St._preHtmlElem(e,"focus").focus(),e}focus(){return St.focus(this)}static blur(e){return St._preHtmlElem(e,"blur").blur(),e}blur(){return St.blur(this)}static select(e){const t=St._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 St.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.");St.setScrollTop(window,e)}static setWinScrollLeft(e){if("number"!=typeof e)throw new TypeError("The value must be a number.");St.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 i=St._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 n="width"===t?"Width":"Height";if(St.isWindow(i))return"margin"===r?i["inner"+n]:i.document.documentElement["client"+n];const s=i;if(9===s.nodeType){const e=s.documentElement;return Math.max(s.body["scroll"+n],e["scroll"+n],s.body["offset"+n],e["offset"+n],e["client"+n])}let o=s.getBoundingClientRect()[t];function a(e){return"width"===t?St.cssFloat(s,e+"Left")+St.cssFloat(s,e+"Right"):St.cssFloat(s,e+"Top")+St.cssFloat(s,e+"Bottom")}switch(r){case"content":o-=a("padding"),o-=a("border");break;case"padding":o-=a("border");break;case"border":break;case"margin":o+=a("margin")}return o}getDimension(e,t){return St.getDimension(this,e,t)}static setHeight(e,t){const r=St._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 St.setHeight(this,e)}set height(e){St.setHeight(this,e)}static setWidth(e,t){const r=St._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 St.setWidth(this,e)}set width(e){St.setWidth(this,e)}static height(e){const t=St._preElemAndWinAndDoc(e,"height");return St.getDimension(t,"height","content")}get height(){return St.height(this)}static width(e){const t=St._preElemAndWinAndDoc(e,"width");return St.getDimension(t,"width","content")}get width(){return St.width(this)}static innerHeight(e){const t=St._preElemAndWinAndDoc(e,"innerHeight");return St.getDimension(t,"height","padding")}innerHeight(){return St.innerHeight(this)}static innerWidth(e){const t=St._preElemAndWinAndDoc(e,"innerWidth");return St.getDimension(t,"width","padding")}innerWidth(){return St.innerWidth(this)}static outerHeight(e,t=!1){if("boolean"!=typeof t)throw new TypeError('The "includeMargin" must be a boolean.');const r=St._preElemAndWinAndDoc(e,"outerHeight");return St.getDimension(r,"height",t?"margin":"border")}outerHeight(e){return St.outerHeight(this,e)}static outerWidth(e,t=!1){if("boolean"!=typeof t)throw new TypeError('The "includeMargin" must be a boolean.');const r=St._preElemAndWinAndDoc(e,"outerWidth");return St.getDimension(r,"width",t?"margin":"border")}outerWidth(e){return St.outerWidth(this,e)}#ne="";get mainDisplay(){return this.#ne}set mainDisplay(e){if("string"!=typeof e)throw new TypeError("mainDisplay must be a string.");this.#ne=e}static#se="block";static get defaultDisplay(){return St.#se}static set defaultDisplay(e){if("string"!=typeof e)throw new TypeError("defaultDisplay must be a string.");St.#se=e}static getAnimateData(e,t){let r=vt.get(e);return r||(r={},vt.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 i=vt.get(e);i||(i={},vt.set(e,i)),i[t]=r}static#ae=!0;static get cancelOldStyleFx(){return St.#ae}static set cancelOldStyleFx(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean value.");St.#ae=e}static#le={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 St.#le){const r=St.#le[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.`);St.#le={};for(const[t,r]of Object.entries(e))St.setStyleFxSpeed(t,r)}static getStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');const t=St.#le[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");St.#le[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 St.#le[e]}static hasStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(St.#le,e)}static#ue=["Top","Right","Bottom","Left"];static#he={slideDown:St.genStyleFx("show"),slideUp:St.genStyleFx("hide"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}};static get styleEffects(){return JSON.parse(JSON.stringify(St.#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,i]of Object.entries(e[t]))if(!("string"==typeof i||Array.isArray(i)&&i.every(e=>"string"==typeof e||"number"==typeof e)))throw new TypeError(`Invalid styleEffect["${r}"]`);St.#he={};for(const t in e)St.setStyleEffect(t,e[t])}static getStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');const t=St.#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,i]of Object.entries(t))if("string"==typeof i)r[e]=i;else{if(!Array.isArray(i)||!i.every(e=>"string"==typeof e||"number"==typeof e))throw new TypeError(`Invalid styleEffect["${e}"]`);r[e]=[...i]}St.#he[e]=r}static deleteStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete St.#he[e]}static hasStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(St.#he,e)}static#ce={slideDown:"slideUp",slideUp:"slideDown",fadeIn:"fadeOut",fadeOut:"fadeIn",fadeTo:"fadeIn"};static get styleEffectInverse(){return{...St.#ce}}static set styleEffectInverse(e){if("object"!=typeof e||null===e)throw new TypeError("styleEffectInverse must be an object.");for(const[t,r]of Object.entries(e))if("string"!=typeof r)throw new TypeError(`styleEffectInverse["${t}"] must be a string.`);St.#ce={};for(const[t,r]of Object.entries(e))St.setStyleEffectInverse(t,r)}static getStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return St.#ce[e]||null}static setStyleEffectInverse(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("string"!=typeof t)throw new TypeError(`styleEffectInverse["${e}"] must be a string.`);St.#ce[e]=t}static deleteStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete St.#ce[e]}static hasStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(St.#ce,e)}static#de={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{...St.#de}}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.`);St.#de={};for(const[t,r]of Object.entries(e))St.setStyleEffectRd(t,r)}static getStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return St.#de[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.`);St.#de[e]=t}static deleteStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete St.#de[e]}static hasStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(St.#de,e)}static#me={show:(e,t,r,i)=>{if("height"===r||"width"===r){const n=St.getAnimateData(e,`orig${r}`)||e.scrollHeight+"px";St.setAnimateData(e,`orig${r}`,n);const s=i[r];t[r]=[s,n]}else if(r.startsWith("margin")||r.startsWith("padding")){const n=St.getAnimateData(e,r)||i[r];St.setAnimateData(e,r,n),t[r]=["0px",n]}else if("opacity"===r){const e=i.opacity;t[r]=[e,1]}else{const n=St.getAnimateData(e,r)||i[r];St.setAnimateData(e,r,n),t[r]=[n,i[r]||1]}},hide:(e,t,r,i)=>{if("height"===r||"width"===r){const n=St.getAnimateData(e,`orig${r}`)||i[r];St.setAnimateData(e,`orig${r}`,n);const s=i[r];t[r]=[s,0]}else if(r.startsWith("margin")||r.startsWith("padding")){const n=St.getAnimateData(e,r)||i[r];St.setAnimateData(e,r,n),t[r]=[i[r],"0px"]}else if("opacity"===r){const e=i.opacity;t[r]=[e,0]}else{const n=St.getAnimateData(e,r)||i[r];St.setAnimateData(e,r,n),t[r]=[n,0]}}};static get styleEffectsProps(){return{...St.#me}}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`);St.#me={};for(const[t,r]of Object.entries(e))St.setStyleEffectProp(t,r)}static getStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return St.#me[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`);St.#me[e]=t}static deleteStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete St.#me[e]}static hasStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(St.#me,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,i=0;const n={height:e},s=t?1:0;for(;i<4;i+=2-s)r=St.#ue[i],n["margin"+r]=e,n["padding"+r]=e;return t&&(n.opacity=e,n.width=e),n}static applyStyleFx(e,t,r,i){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!==i&&"number"!=typeof i&&"string"!=typeof i&&("object"!=typeof i||null===i))throw new TypeError("applyStyleFx: ops must be a number, string, KeyframeAnimationOptions, or undefined.");const n=new Map;return St._preHtmlElems(e,"applyStyleFx").forEach(s=>{const o={};for(const[e,t]of Object.entries(r))if("string"==typeof t&&this.#me[t]){const r=getComputedStyle(s);this.#me[t](s,o,e,r)}else{if("object"!=typeof t)throw new TypeError(`applyStyleFx: invalid action for prop "${e}". Must be string or array.`);o[e]=t}if("function"==typeof St.#de[t]&&St.#de[t](o))return void n.set(s,null);const a=[],l=o[Object.keys(o)[0]].length;for(let e=0;e<l;e++){const t={};for(const r in o)t[r]=o[r][e];a.push(t)}n.set(s,St.animate(e,a,i,t)[0])}),n}applyStyleFx(e,t,r){return St.applyStyleFx(this,e,t,r)}static getCurrentAnimationId(e){if(!(e instanceof HTMLElement))throw new TypeError("Expected an HTMLElement.");return Et.get(e)?.id??void 0}static animate(e,t,r=St.#le._default,i=null,n=St.#ae){const s="string"==typeof r?St.#le[r]??void 0:"number"!=typeof r?{...r}:r;"object"==typeof s&&void 0===s.fill&&(s.fill="forwards");const o=[];return St._preHtmlElems(e,"animate").forEach(e=>{if(n){const t=Et.get(e);t&&t.animation.cancel()}const r=e.animate(t,s);o.push(r),Et.set(e,{animation:r,id:i??""}),r.addEventListener("finish",()=>{Et.get(e)?.animation===r&&Et.delete(e)})}),o}animate(e,t,r,i){return St.animate(this,e,t,r,i)}static stop(e){const t=[];return St._preHtmlElems(e,"stop").forEach(e=>{const r=Et.get(e);r?(r.animation.cancel(),Et.delete(e),t.push(!0)):t.push(!1)}),t}stop(){return St.stop(this)}static slideDown(e,t){return St.applyStyleFx(e,"slideDown",this.#he.slideDown,t??{duration:500,easing:"ease-out"})}slideDown(e){return St.slideDown(this,e)}static slideUp(e,t){return St.applyStyleFx(e,"slideUp",this.#he.slideUp,t??{duration:500,easing:"ease-out"})}slideUp(e){return St.slideUp(this,e)}static slideToggle(e,t){const r=St._preHtmlElem(e,"slideToggle"),i=getComputedStyle(r),n=St.getCurrentAnimationId(r),s="none"===i.display||0===r.offsetHeight;return("string"==typeof n?"slideUp"===n:s)?St.slideDown(e,t):St.slideUp(e,t)}slideToggle(e){return St.slideToggle(this,e)}static fadeIn(e,t){return St.applyStyleFx(e,"fadeIn",this.#he.fadeIn,t)}fadeIn(e){return St.fadeIn(this,e)}static fadeOut(e,t){return St.applyStyleFx(e,"fadeOut",this.#he.fadeOut,t)}fadeOut(e){return St.fadeOut(this,e)}static fadeToggle(e,t){const r=St._preHtmlElem(e,"fadeToggle"),i=getComputedStyle(r),n=St.getCurrentAnimationId(r),s="0"===i.opacity||null===r.offsetParent;return("string"==typeof n?"fadeOut"===n:s)?St.fadeIn(e,t):St.fadeOut(e,t)}fadeToggle(e){return St.fadeToggle(this,e)}static fadeTo(e,t,r,i=St.#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 n=new Map;return St._preHtmlElems(e,"fadeTo").forEach(s=>{const o=getComputedStyle(s);if(!(e instanceof Element&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length))){const e=St.getAnimateData(s,"origdisplay");s.style.display="string"==typeof e?e:i}const a=[o.opacity,t].map(e=>({opacity:e}));n.set(s,St.animate(s,a,r,"fadeTo")[0])}),n}fadeTo(e,t,r=this.#ne){return St.fadeTo(this,e,t,r)}static offset(e){const t=St._preElem(e,"offset").getBoundingClientRect(),r=window.scrollY||document.documentElement.scrollTop,i=window.scrollX||document.documentElement.scrollLeft;return{top:t.top+r,left:t.left+i}}offset(){return St.offset(this)}static position(e){const t=St._preHtmlElem(e,"position");let r,i,n={top:0,left:0};if("fixed"===window.getComputedStyle(t).position)i=t.getBoundingClientRect();else{i=St.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}=St.cssFloats(r,["borderTopWidth","borderLeftWidth"]);n=St.offset(r),n.top+=e,n.left+=t}}return{top:i.top-n.top-St.cssFloat(t,"marginTop"),left:i.left-n.left-St.cssFloat(t,"marginLeft")}}position(){return St.position(this)}static offsetParent(e){let t=St._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 St.offsetParent(this)}static scrollTop(e){const t=St._preElemAndWindow(e,"scrollTop");return St.isWindow(t)?t.pageYOffset:9===t.nodeType?t.defaultView.pageYOffset:t.scrollTop}scrollTop(){return St.scrollTop(this)}static scrollLeft(e){const t=St._preElemAndWindow(e,"scrollLeft");return St.isWindow(t)?t.pageXOffset:9===t.nodeType?t.defaultView.pageXOffset:t.scrollLeft}scrollLeft(){return St.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:i,easing:n,onAnimation:s}={}){if(void 0!==t&&"number"!=typeof t)throw new TypeError("`targetX` must be a number if provided.");if(void 0!==r&&"number"!=typeof r)throw new TypeError("`targetY` must be a number if provided.");if(void 0!==i&&"number"!=typeof i)throw new TypeError("`duration` must be a number if provided.");if(void 0!==n&&"string"!=typeof n)throw new TypeError("`easing` must be a string if provided.");if(void 0!==n&&"function"!=typeof St.easings[n])throw new TypeError(`Unknown easing function: "${n}".`);if(void 0!==s&&"function"!=typeof s)throw new TypeError("`onAnimation` must be a function if provided.");const o=(e,t,r,i)=>{if(e instanceof Window)window.scrollTo(t,r);else if(9===e.nodeType)e.defaultView.scrollTo(t,r);else{const i=e instanceof Window?window.scrollX:e.scrollLeft,n=e instanceof Window?window.scrollY:e.scrollTop;i!==t&&(e.scrollLeft=t),n!==r&&(e.scrollTop=r)}"function"==typeof s&&s({x:t,y:r,isComplete:i>=1,time:i})};return St._preElemsAndWindow(e,"scrollToXY").forEach(e=>{const s=e instanceof Window?window.scrollX:e.scrollLeft,a=e instanceof Window?window.scrollY:e.scrollTop,l=t??s,u=r??a,h=l-s,c=u-a,d="string"==typeof n&&St.easings[n]||null;if("number"!=typeof i||"function"!=typeof d)return o(e,l,u,1);const m=performance.now(),p=i??0;requestAnimationFrame(function t(r){if("function"!=typeof d)return;const i=Math.min(1,(r-m)/p),n=d(i);o(e,s+h*n,a+c*n,i),i<1&&requestAnimationFrame(t)})}),e}scrollToXY({targetX:e,targetY:t,duration:r,easing:i,onAnimation:n}={}){return St.scrollToXY(this,{targetX:e,targetY:t,duration:r,easing:i,onAnimation:n})}static setScrollTop(e,t){if("number"!=typeof t)throw new TypeError("ScrollTop value must be a number.");return St.scrollToXY(e,{targetY:t})}setScrollTop(e){return St.setScrollTop(this,e)}static setScrollLeft(e,t){if("number"!=typeof t)throw new TypeError("ScrollLeft value must be a number.");return St.scrollToXY(e,{targetX:t})}setScrollLeft(e){return St.setScrollLeft(this,e)}static borderWidth(e){const t=St._preElem(e,"borderWidth"),{borderLeftWidth:r,borderRightWidth:i,borderTopWidth:n,borderBottomWidth:s}=St.cssFloats(t,["borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"]);return{x:r+i,y:n+s,left:r,right:i,top:n,bottom:s}}borderWidth(){return St.borderWidth(this)}static border(e){const t=St._preElem(e,"border"),{borderLeft:r,borderRight:i,borderTop:n,borderBottom:s}=St.cssFloats(t,["borderLeft","borderRight","borderTop","borderBottom"]);return{x:r+i,y:n+s,left:r,right:i,top:n,bottom:s}}border(){return St.border(this)}static margin(e){const t=St._preElem(e,"margin"),{marginLeft:r,marginRight:i,marginTop:n,marginBottom:s}=St.cssFloats(t,["marginLeft","marginRight","marginTop","marginBottom"]);return{x:r+i,y:n+s,left:r,right:i,top:n,bottom:s}}margin(){return St.margin(this)}static padding(e){const t=St._preElem(e,"padding"),{paddingLeft:r,paddingRight:i,paddingTop:n,paddingBottom:s}=St.cssFloats(t,["paddingLeft","paddingRight","paddingTop","paddingBottom"]);return{x:r+i,y:n+s,left:r,right:i,top:n,bottom:s}}padding(){return St.padding(this)}static#pe=!1;static get classCanWhitespace(){return this.#pe}static set classCanWhitespace(e){if("boolean"!=typeof e)throw new TypeError("classCanWhitespace must be a boolean");this.#pe=e}static addClass(e,...t){const r=[];for(const e of t)if(St.#pe){const t=e.split(" ");for(const e of t)r.push(e)}else r.push(e);return St._preElems(e,"addClass").forEach(e=>e.classList.add(...r)),e}addClass(...e){return St.addClass(this,...e)}static removeClass(e,...t){const r=[];for(const e of t)if(St.#pe){const t=e.split(" ");for(const e of t)r.push(e)}else r.push(e);return St._preElems(e,"removeClass").forEach(e=>e.classList.remove(...r)),e}removeClass(...e){return St.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 i=[];return St._preElems(e,"replaceClass").forEach(e=>i.push(e.classList.replace(t,r))),i}replaceClass(e,t){return St.replaceClass(this,e,t)[0]}static classItem(e,t){const r=St._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 St.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 i=[];return St._preElems(e,"toggleClass").forEach(e=>i.push(e.classList.toggle(t,r))),i}toggleClass(e,t){return St.toggleClass(this,e,t)[0]}static hasClass(e,t){const r=St._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 St.hasClass(this,e)}static classLength(e){return St._preElem(e,"classLength").classList.length}classLength(){return St.classLength(this)}static classList(e){return St._preElem(e,"classList").classList.values().toArray()}classList(){return St.classList(this)}static tagName(e){return St._preElem(e,"tagName").tagName}tagName(){return St.tagName(this)}static id(e){return St._preElem(e,"id").id}get id(){return St.id(this)}set id(e){St.setAttr(this,"id",e)}static toBigInt(e){const t=St._preElem(e,"toBigInt"),r=t.textContent?.trim();let i=null;try{i=BigInt(r??"")}catch{i=null}return i}toBigInt(){return St.toBigInt(this)}static setBigInt(e,t){if("bigint"!=typeof t)throw new Error("Value is not a valid BigInt.");const r=t.toString();return St._preElems(e,"setBigInt").forEach(e=>e.textContent=r),e}setBigInt(e){return St.setBigInt(this,e)}static toDate(e){const t=St._preElem(e,"toDate"),r=t.textContent?.trim();if(!r)return null;const i=new Date(r);return Number.isNaN(i.getTime())?null:i}toDate(){return St.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 St._preElems(e,"setDate").forEach(e=>e.textContent=r),e}setDate(e){return St.setDate(this,e)}static toJson(e){const t=St._preElem(e,"toJson"),r=t.textContent?.trim();if(!r)return null;try{return JSON.parse(r)}catch{return null}}toJson(){return St.toJson(this)}static setJson(e,t,r,i){const n=JSON.stringify(t,r,i);return St._preElems(e,"setJson").forEach(e=>e.textContent=n),e}setJson(e,t,r){return St.setJson(this,e,t,r)}static toNumber(e){const t=St._preElem(e,"toNumber");return"string"==typeof t.textContent?parseFloat(t.textContent.trim()):null}toNumber(){return St.toNumber(this)}static setNumber(e,t){if("number"!=typeof t)throw new Error("Value is not a valid number.");const r=t.toString();return St._preElems(e,"setNumber").forEach(e=>e.textContent=r),e}setNumber(e){return St.setNumber(this,e)}static toBoolean(e){const t=St._preElem(e,"toBoolean"),r=t.textContent?.trim();return null==r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}toBoolean(){return St.toBoolean(this)}static setBoolean(e,t){if("boolean"!=typeof t)throw new Error("Value is not a valid boolean.");const r=t.toString();return St._preElems(e,"setBoolean").forEach(e=>e.textContent=r),e}setBoolean(e){return St.setBoolean(this,e)}static toString(e){const t=St._preElem(e,"toString");return"string"==typeof t.textContent?t.textContent:null}toString(){return St.toString(this)}static setString(e,t){if("string"!=typeof t)throw new Error("Value is not a valid string.");return St._preElems(e,"setString").forEach(e=>e.textContent=t),e}setString(e){return St.setString(this,e)}static text(e){return St._preElem(e,"text").textContent}text(){return St.text(this)}static setText(e,t){const r=null!=t?String(t):"";return St._preElems(e,"setText").forEach(e=>e.textContent=r),e}setText(e){return St.setText(this,e)}static empty(e){return St._preElems(e,"empty").forEach(e=>e.textContent=""),e}empty(){return St.empty(this)}static html(e,t){return St._preElem(e,"html").getHTML(t)}html(e){return St.html(this,e)}static setHtml(e,t){if("string"!=typeof t)throw new Error("Value is not a valid string.");return St._preElems(e,"setHtml").forEach(e=>e.innerHTML=t),e}setHtml(e){return St.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,i="select-one"===e.type,n=i?r+1:t.length,s=[];let o=r<0?n:i?r:0;for(;o<n;o++){const e=t[o],n=e.parentNode;if((e.selected||o===r)&&!e.disabled&&(!n||!n.disabled||"OPTGROUP"!==n.tagName)){const t=St._valHooks.option.get(e);if(i)return t;s.push(t)}}return s},set:(e,t)=>{const r=e.options,i=Array.isArray(t)?t.map(String):[String(t)];let n=!1;for(let e=0;e<r.length;e++){const t=r[e],s=St._valHooks.option.get(t);"string"==typeof s&&(t.selected=i.includes(s))&&(n=!0)}return n||(e.selectedIndex=-1),i}},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 St._preInputElems(e,"setVal").forEach(e=>{if(1!==e.nodeType)return;let r="function"==typeof t?t(e,St.val(e)):t;null==r?r="":"number"==typeof r?r=String(r):Array.isArray(r)&&(r=((e,t)=>{const r=[];for(let i=0;i<e.length;i++)r.push(t(e[i]));return r})(r,e=>null==e?"":String(e)));const i=St._valHooks[e.type]||St._valHooks[e.nodeName.toLowerCase()];if(!i||"function"!=typeof i.set||void 0===i.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 St.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 St._valTypes[t])throw new Error(`No handler found for type "${t}" in ${r}().`);return St._valTypes[t](e)}static _val(e,t,r){const i=St._preInputElem(e,t),n=St._valHooks[i.type]||St._valHooks[i.nodeName.toLowerCase()];if(n&&"function"==typeof n.get){const e=n.get(i,"value",r);if(void 0!==e)return"string"==typeof e?e.replace(/\r/g,""):e}return St._getValByType(i,r,t)}_val(e,t){return St._val(this,e,t)}static val(e){return St._val(e,"val","string")}val(){return St.val(this)}static valTxt(e){const t=St._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 St.valTxt(this)}static _valArr(e,t,r){const i=St._val(e,t,r);if(!Array.isArray(i))throw new Error(`Value expected an array but got ${typeof i}.`);return i}_valArr(e,t){return St._valArr(this,e,t)}static valArr(e){return St._valArr(e,"valArr","string")}valArr(){return St.valArr(this)}static valNb(e){if(!(St._preInputElem(e,"valNb")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const t=St._val(e,"valNb","number");if(Number.isNaN(t))throw new Error("Value is not a valid number.");return t}valNb(){return St.valNb(this)}static valDate(e){if(!(St._preInputElem(e,"valDate")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const t=St._val(e,"valDate","date");if(!(t instanceof Date))throw new Error("Value is not a valid date.");return t}valDate(){return St.valDate(this)}static valBool(e){const t=St._preInputElem(e,"valBool");if(!(t instanceof HTMLInputElement))throw new Error("Element must be an input element.");return"on"===St.val(t)}valBool(){return St.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 i=e=>{if(!(e instanceof ClipboardEvent))return;const i=e.clipboardData?.items||[];for(const e of i)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 St._preElemsWithDoc(e,"listenForPaste").forEach(e=>St.on(e,"paste",i)),i}listenForPaste({onFilePaste:e,onTextPaste:t}={}){return St.listenForPaste(this,{onFilePaste:e,onTextPaste:t})}static hasEventListener(e,t){const r=St._preEventTargetElem(e,"hasEventListener");if(!wt.has(r))return!1;const i=wt.get(r);return!!(i&&Array.isArray(i[t])&&i[t].length>0)}hasEventListener(e){return St.hasEventListener(this,e)}static hasExactEventListener(e,t,r){const i=St._preEventTargetElem(e,"hasExactEventListener");if("function"!=typeof r)throw new TypeError('The "handler" must be a function.');if(!wt.has(i))return!1;const n=wt.get(i);return!(!n||!Array.isArray(n[t]))&&n[t].some(e=>e.handler===r)}hasExactEventListener(e,t){return St.hasExactEventListener(this,e,t)}static hover(e,t,r,i){return St.on(e,"mouseenter",t,i),St.on(e,"mouseleave",r||t,i),e}hover(e,t,r){return St.hover(this,e,t,r)}static on(e,t,r,i){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.");St._preEventTargetElems(e,"on").forEach(e=>{e.addEventListener(n,r,i),wt.has(e)||wt.set(e,{});const t=wt.get(e);t&&(Array.isArray(t[n])||(t[n]=[]),t[n].push({handler:r,options:i}))})}return e}on(e,t,r){return St.on(this,e,t,r)}static once(e,t,r,i={}){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.");St._preEventTargetElems(e,"once").forEach(e=>{const t=i=>{St.off(e,n,t),"function"==typeof r&&r(i)};St.on(e,n,t,"boolean"==typeof i?i:{...i,once:!0})})}return e}once(e,t,r={}){return St.once(this,e,t,r)}static off(e,t,r,i){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.");St._preEventTargetElems(e,"off").forEach(e=>{e.removeEventListener(n,r,i);const t=wt.get(e);t&&t[n]&&(t[n]=t[n].filter(e=>e.handler!==r),0===t[n].length&&delete t[n])})}return e}off(e,t,r){return St.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.");St._preEventTargetElems(e,"offAll").forEach(e=>{const t=wt.get(e);if(t&&t[r]){for(const i of t[r])e.removeEventListener(r,i.handler,i.options);delete t[r]}})}return e}offAll(e){return St.offAll(this,e)}static offAllTypes(e,t=null){if(null!==t&&"function"!=typeof t)throw new TypeError('The "filterFn" must be a function.');return St._preEventTargetElems(e,"offAllTypes").forEach(e=>{const r=wt.get(e);if(r){for(const i in r)for(const n of r[i])("function"!=typeof t||t(n.handler,i))&&e.removeEventListener(i,n.handler,n.options);wt.delete(e)}}),e}offAllTypes(e=null){return St.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 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.");St._preEventTargetElems(e,"trigger").forEach(e=>{const t=r instanceof Event||r instanceof CustomEvent?r:new CustomEvent(i,{bubbles:!0,cancelable:!0,detail:r});e.dispatchEvent(t)})}return e}trigger(e,t={}){return St.trigger(this,e,t)}static#fe={for:"htmlFor",class:"className"};static propFix=new Proxy(St.#fe,{set:(e,t,r)=>(e[t]=r,St.attrFix[r]=t,!0)});static attrFix=Object.fromEntries(Object.entries(St.#fe).map(([e,t])=>[t,e]));static getPropName(e){return"string"==typeof St.propFix[e]?St.propFix[e]:e}static getAttrName(e){return"string"==typeof St.attrFix[e]?St.attrFix[e]:e}static attrBigInt(e,t){const r=St._preElem(e,"attrBigInt").getAttribute(St.getAttrName(t));if(null==r)return null;try{return BigInt(r)}catch{return null}}attrBigInt(e){return St.attrBigInt(this,e)}static setAttrBigInt(e,t,r){if("bigint"!=typeof r)throw new Error("Value is not a valid BigInt.");return St.setAttr(e,t,r.toString())}setAttrBigInt(e,t){return St.setAttrBigInt(this,e,t)}static attrDate(e,t){const r=St._preElem(e,"attrDate").getAttribute(St.getAttrName(t));if(!r)return null;const i=new Date(r);return Number.isNaN(i.getTime())?null:i}attrDate(e){return St.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 St.setAttr(e,t,r.toISOString())}setAttrDate(e,t){return St.setAttrDate(this,e,t)}static attrJson(e,t){const r=St._preElem(e,"attrJson").getAttribute(St.getAttrName(t));if(!r)return null;try{return JSON.parse(r)}catch{return null}}attrJson(e){return St.attrJson(this,e)}static setAttrJson(e,t,r,i,n){const s=JSON.stringify(r,i,n);return St.setAttr(e,t,s)}setAttrJson(e,t,r,i){return St.setAttrJson(this,e,t,r,i)}static attrNumber(e,t){const r=St._preElem(e,"attrNumber").getAttribute(St.getAttrName(t));return null!=r?parseFloat(r):null}attrNumber(e){return St.attrNumber(this,e)}static setAttrNumber(e,t,r){if("number"!=typeof r)throw new Error("Value is not a valid number.");return St.setAttr(e,t,r.toString())}setAttrNumber(e,t){return St.setAttrNumber(this,e,t)}static attrBoolean(e,t){const r=St._preElem(e,"attrBoolean").getAttribute(St.getAttrName(t));return null===r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}attrBoolean(e){return St.attrBoolean(this,e)}static setAttrBoolean(e,t,r){if("boolean"!=typeof r)throw new Error("Value is not a valid boolean.");return St.setAttr(e,t,r.toString())}setAttrBoolean(e,t){return St.setAttrBoolean(this,e,t)}static attrString(e,t){const r=St._preElem(e,"attrString").getAttribute(St.getAttrName(t));return"string"==typeof r?r:null}attrString(e){return St.attrString(this,e)}static setAttrString(e,t,r){if("string"!=typeof r)throw new Error("Value is not a valid string.");return St.setAttr(e,t,r)}setAttrString(e,t){return St.setAttrString(this,e,t)}static attr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return St._preElem(e,"attr").getAttribute(St.getAttrName(t))}attr(e){return St.attr(this,e)}static setAttr(e,t,r=null){const i=St._preElems(e,"setAttr");if("object"==typeof t&&null!==t)return Object.entries(t).forEach(([e,t])=>i.forEach(r=>{null===t?r.removeAttribute(St.getAttrName(e)):r.setAttribute(St.getAttrName(e),String(t))})),e;if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return i.forEach(e=>{null===r?e.removeAttribute(St.getAttrName(t)):e.setAttribute(St.getAttrName(t),String(r))}),e}setAttr(e,t){return St.setAttr(this,e,t)}static removeAttr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return St._preElems(e,"removeAttr").forEach(e=>e.removeAttribute(St.getAttrName(t))),e}removeAttr(e){return St.removeAttr(this,e)}static hasAttr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return St._preElem(e,"hasAttr").hasAttribute(St.getAttrName(t))}hasAttr(e){return St.hasAttr(this,e)}static hasProp(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return!!St._preElem(e,"hasProp")[St.getPropName(t)]}hasProp(e){return St.hasProp(this,e)}static addProp(e,...t){return St._preElems(e,"addProp").forEach(e=>{t.forEach(t=>{if("string"!=typeof t)throw new TypeError('Each "name" must be a string.');e[St.getPropName(t)]=!0})}),e}addProp(...e){return St.addProp(this,...e)}static removeProp(e,...t){return St._preElems(e,"removeProp").forEach(e=>{t.forEach(t=>{if("string"!=typeof t)throw new TypeError('Each "name" must be a string.');e[St.getPropName(t)]=!1})}),e}removeProp(...e){return St.removeProp(this,...e)}static toggleProp(e,t,r){const i=St._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.");i.forEach(t=>{(void 0===r?!t[St.getPropName(e)]:r)?St.addProp(t,e):St.removeProp(t,e)})}),e}toggleProp(e,t){return St.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 St._preElem(e,"prop")[t]}prop(e){return St.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 St._preElems(e,"setProp").forEach(e=>{e[t]=r}),e}setProp(e,t){return St.setProp(this,e,t)}static remove(e){return St._preElems(e,"remove").forEach(e=>e.remove()),e}remove(){return St.remove(this)}static index(e,t=null){const r=St._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):St._preElems(t,"index");return Array.prototype.indexOf.call(e,r)}return-1}index(e){return St.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:i=0,width:n=0,top:s=0,bottom:o=0,left:a=0,right:l=0}=t;if("number"!=typeof i)throw new Error("extraRect.height must be a number.");if("number"!=typeof n)throw new Error("extraRect.width must be a number.");if("number"!=typeof s)throw new Error("extraRect.top must be a number.");if("number"!=typeof o)throw new Error("extraRect.bottom must be a number.");if("number"!=typeof a)throw new Error("extraRect.left must be a number.");if("number"!=typeof l)throw new Error("extraRect.right must be a number.");return r.height+=i,r.width+=n,r.top+=s,r.bottom+=o,r.left+=a,r.right+=l,r}static isCollWith(e,t,r={}){const i=St._getCustomRect(St._preElem(e,"isCollWith").getBoundingClientRect(),r),n=St._preElem(t,"isCollWith").getBoundingClientRect();return dt(i,n)}isCollWith(e,t){return St.isCollWith(this,e,t)}static isCollPerfWith(e,t,r={}){const i=St._getCustomRect(St._preElem(e,"isCollPerfWith").getBoundingClientRect(),r),n=St._preElem(t,"isCollPerfWith").getBoundingClientRect();return mt(i,n)}isCollPerfWith(e,t){return St.isCollPerfWith(this,e,t)}static _isCollWithLock(e,t,r,i,n){const s=Tt[n];if(e)return s.has(i)||s.set(i,!0),!0;if(s.has(i)){let e=!1;switch(n){case"top":e=pt(t,r);break;case"bottom":e=ft(t,r);break;case"left":e=yt(t,r);break;case"right":e=gt(t,r)}return e&&s.delete(i),s.has(i)}return!1}static isCollWithLock(e,t,r,i={}){const n=St._preElem(e,"isCollWithLock"),s=St._preElem(t,"isCollWithLock"),o=St._getCustomRect(n.getBoundingClientRect(),i),a=s.getBoundingClientRect(),l=dt(o,a);return St._isCollWithLock(l,o,a,n,r)}isCollWithLock(e,t,r){return St.isCollWithLock(this,e,t,r)}static isCollPerfWithLock(e,t,r,i={}){const n=St._preElem(e,"isCollPerfWithLock"),s=St._preElem(t,"isCollPerfWithLock"),o=St._getCustomRect(n.getBoundingClientRect(),i),a=s.getBoundingClientRect(),l=mt(o,a);return St._isCollWithLock(l,o,a,n,r)}isCollPerfWithLock(e,t,r){return St.isCollPerfWithLock(this,e,t,r)}static resetCollLock(e){const t=St._preElem(e,"resetCollLock");let r=!1;for(const e of["top","bottom","left","right"])Tt[e].has(t)&&(Tt[e].delete(t),r=!0);return r}resetCollLock(){return St.resetCollLock(this)}static resetCollLockDir(e,t){const r=St._preElem(e,"resetCollLockDir"),i=Tt[t];return!!i.has(r)&&(i.delete(r),!0)}resetCollLockDir(e){return St.resetCollLockDir(this,e)}static isInViewport(e){const t=St._preElem(e,"isInViewport");if(!t.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=St.offset(t).top,i=r+St.outerHeight(t),n=St.scrollTop(window),s=n+St.height(window);return i>n&&r<s}isInViewport(){return St.isInViewport(this)}static isScrolledIntoView(e){const t=St._preElem(e,"isScrolledIntoView");if(!t.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=St.scrollTop(window),i=r+St.height(window),n=St.offset(t).top;return n+St.height(t)<=i&&n>=r}isScrolledIntoView(){return St.isScrolledIntoView(this)}static isInContainer(e,t){const r=St._preElem(e,"isInContainer"),i=St._preElem(t,"isInContainer");if(!r.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const n=r.getBoundingClientRect(),s=i.getBoundingClientRect(),o=n.bottom>s.top&&n.top<s.bottom,a=n.right>s.left&&n.left<s.right;return o&&a}isInContainer(e){return St.isInContainer(this,e)}static isFullyInContainer(e,t){const r=St._preElem(e,"isScrolledIntoView"),i=St._preElem(t,"isInContainer");if(!r.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const n=r.getBoundingClientRect(),s=i.getBoundingClientRect();return n.top>=s.top&&n.bottom<=s.bottom&&n.left>=s.left&&n.right<=s.right}isFullyInContainer(e){return St.isFullyInContainer(this,e)}static hasScroll(e){const t=St._preElem(e,"hasScroll");return{v:t.scrollHeight>t.clientHeight,h:t.scrollWidth>t.clientWidth}}hasScroll(){return St.hasScroll(this)}}const xt=St,At=X("TinyDragger");class Ct{static Utils={...t,TinyHtml:xt};#ye=!0;#h=!1;#ge=0;#we=0;#be=!0;#ve=!1;#Ee=!1;#Te=!1;#Se=!1;#xe=!1;#Ae=!1;#Ce=null;#Ie=[];#De=null;#Me={start:!1,end:!1,collide:!1,move:!1};#Ne=null;#F;#ke="drag-hidden";#Le="dragging";#_e="drag-active";#je="jail-drag-active";#Re="jail-drag-disabled";#Pe="dragging-collision";#$e=9999;constructor(e,t={}){if(!(e instanceof HTMLElement))throw new Error("TinyDragger requires a valid target HTMLElement to initialize.");if(this.#F=e,void 0!==t.jail&&!(t.jail instanceof HTMLElement))throw new Error('The "jail" option must be an HTMLElement if provided.');if(void 0!==t.defaultZIndex&&this.setDefaultZIndex(t.defaultZIndex),void 0!==t.vibration&&!1!==t.vibration&&!f(t.vibration))throw new Error('The "vibration" option must be an object or false.');const r=(e,t)=>{if(void 0!==e&&"boolean"!=typeof e)throw new Error(`The "${t}" option must be a boolean.`)},i=(e,t)=>{if(void 0!==e&&"string"!=typeof e)throw new Error(`The "${t}" option must be a string.`)};r(t.mirrorElem,"mirrorElem"),r(t.collisionByMouse,"collisionByMouse"),r(t.lockInsideJail,"lockInsideJail"),r(t.dropInJailOnly,"dropInJailOnly"),r(t.revertOnDrop,"revertOnDrop"),r(t.multiCollision,"multiCollision"),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.#Ne=t.jail),this.#Me=Object.assign({start:!1,end:!1,collide:!1,move:!1},f(t.vibration)?t.vibration:{}),"string"==typeof t.classDragging&&(this.#Le=t.classDragging),"string"==typeof t.classBodyDragging&&(this.#_e=t.classBodyDragging),"string"==typeof t.classJailDragging&&(this.#je=t.classJailDragging),"string"==typeof t.classJailDragDisabled&&(this.#Re=t.classJailDragDisabled),"string"==typeof t.classHidden&&(this.#ke=t.classHidden),"string"==typeof t.classDragCollision&&(this.#Pe=t.classDragCollision),"boolean"==typeof t.collisionByMouse&&(this.#xe=t.collisionByMouse),"boolean"==typeof t.mirrorElem&&(this.#be=t.mirrorElem),"boolean"==typeof t.revertOnDrop&&(this.#Te=t.revertOnDrop),"boolean"==typeof t.lockInsideJail&&(this.#Ee=t.lockInsideJail),"boolean"==typeof t.dropInJailOnly&&(this.#Ae=t.dropInJailOnly),"boolean"==typeof t.multiCollision&&(this.#ve=t.multiCollision),this._onMouseDown=this.#He.bind(this),this._onMouseMove=this.#Oe.bind(this),this._onMouseUp=this.#Fe.bind(this),this._onTouchStart=e=>this.#He(e.touches[0]),this._onTouchMove=e=>this.#Oe(e.touches[0]),this._onTouchEnd=e=>this.#Fe(e.changedTouches[0]),this.#F.addEventListener("mousedown",this._onMouseDown),this.#F.addEventListener("touchstart",this._onTouchStart,{passive:!1})}enable(){At(this.#h),this.#Ne&&this.#Ne.classList.add(this.#Re),this.#ye=!0}disable(){At(this.#h),this.#Ne&&this.#Ne.classList.remove(this.#Re),this.#ye=!1}addCollidable(e){if(At(this.#h),!(e instanceof HTMLElement))throw new Error("addCollidable expects an HTMLElement as argument.");this.#Ie.includes(e)||this.#Ie.push(e)}removeCollidable(e){if(At(this.#h),!(e instanceof HTMLElement))throw new Error("removeCollidable expects an HTMLElement as argument.");this.#Ie=this.#Ie.filter(t=>t!==e)}setVibrationPattern({startPattern:e=!1,endPattern:t=!1,collidePattern:r=!1,movePattern:i=!1}={}){At(this.#h);const n=e=>!1===e||Array.isArray(e)&&e.every(e=>"number"==typeof e);if(!n(e))throw new Error('Invalid "startPattern": must be false or an array of numbers.');if(!n(t))throw new Error('Invalid "endPattern": must be false or an array of numbers.');if(!n(r))throw new Error('Invalid "collidePattern": must be false or an array of numbers.');if(!n(i))throw new Error('Invalid "movePattern": must be false or an array of numbers.');this.#Me={start:e,end:t,collide:r,move:i}}disableVibration(){At(this.#h),this.#Me={start:!1,end:!1,collide:!1,move:!1}}getOffset(e){if(At(this.#h),!(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.#F.getBoundingClientRect(),{left:r,top:i}=xt.borderWidth(this.#F);return{x:e.clientX-t.left+r,y:e.clientY-t.top+i}}#He(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#h||!this.#ye||!this.#F.parentElement)return;if(this.#be){const e=this.#F.cloneNode(!0);if(!(e instanceof HTMLElement))throw new Error("[TinyDragger] INVALID DRAG ELEMENT!");this.#De=e}else this.#De=this.#F;this.#Se=!0;const t=this.#F.getBoundingClientRect();Object.assign(this.#De.style,{position:"absolute",pointerEvents:"none",left:`${this.#F.offsetLeft}px`,top:`${this.#F.offsetTop}px`,width:`${t.width}px`,height:`${t.height}px`,zIndex:this.#$e}),this.#be&&(this.#F.classList.add(this.#ke),this.#F.parentElement.appendChild(this.#De));const{x:r,y:i}=this.getOffset(e);this.#we=r,this.#ge=i,this.#De.classList.add(this.#Le),document.body.classList.add(this.#_e),this.#Ne&&this.#Ne.classList.add(this.#je),document.addEventListener("mousemove",this._onMouseMove),document.addEventListener("mouseup",this._onMouseUp),document.addEventListener("touchmove",this._onTouchMove,{passive:!1}),document.addEventListener("touchend",this._onTouchEnd),navigator.vibrate&&Array.isArray(this.#Me.start)&&navigator.vibrate(this.#Me.start),this.checkDragCollision(e),this.#Be("drag")}#ze=[];#We(e){e&&(e.classList.add(this.#Pe),this.#ze.push(e))}#qe(){for(;this.#ze.length>0;){const e=this.#ze.shift();e&&e.classList.remove(this.#Pe)}this.#Ce&&this.#Ce.classList.remove(this.#Pe)}checkDragCollision(e){At(this.#h);const{collidedElements:t}=this.execCollision(e),r=t[0]||null;this.#Ce&&!t.includes(this.#Ce)&&this.#qe(),t.forEach(e=>this.#We(e)),this.#Ie.forEach(e=>{t.includes(e)||e.classList.remove(this.#Pe)}),navigator.vibrate&&Array.isArray(this.#Me.collide)&&t.length>0&&navigator.vibrate(this.#Me.collide),this.#Ce=r}#Oe(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#h||!this.#Se||!this.#ye||!this.#De)return;const t=(this.#De.offsetParent||document.body).getBoundingClientRect();let r=e.clientX-t.left-this.#we,i=e.clientY-t.top-this.#ge;if(this.#Ee&&this.#Ne){const e=this.#Ne.getBoundingClientRect(),n=this.#De.getBoundingClientRect(),s=e.left-t.left,o=e.top-t.top,{x:a,y:l}=xt.borderWidth(this.#Ne),u=s+e.width-n.width-l,h=o+e.height-n.height-a;r=Math.max(s,Math.min(r,u)),i=Math.max(o,Math.min(i,h))}this.#De.style.position="absolute",this.#De.style.left=`${r}px`,this.#De.style.top=`${i}px`,navigator.vibrate&&Array.isArray(this.#Me.move)&&navigator.vibrate(this.#Me.move),this.checkDragCollision(e),this.#Be("dragging")}execCollision(e){if(At(this.#h),this.#h||!this.#De)return{inJail:!1,collidedElements:[]};let t=[],r=!0;const i=this.#Ne?.getBoundingClientRect();if(this.#xe){const n=e.clientX,s=e.clientY;this.#Ae&&this.#Ne&&i&&(r=n>=i.left&&n<=i.right&&s>=i.top&&s<=i.bottom),t=r?this.#ve?this.getAllCollidedElements(n,s):[this.getCollidedElement(n,s)].filter(Boolean):[]}else{const e=this.#De.getBoundingClientRect();this.#Ae&&this.#Ne&&i&&(r=e.left>=i.left&&e.right<=i.right&&e.top>=i.top&&e.bottom<=i.bottom),t=r?this.#ve?this.getAllCollidedElementsByRect(e):[this.getCollidedElementByRect(e)].filter(Boolean):[]}return{inJail:r,collidedElements:t}}#Fe(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#h||!this.#Se)return;if(this.#Se=!1,!this.#De)return;this.#F.classList.remove(this.#Le),document.body.classList.remove(this.#_e),this.#Ne&&this.#Ne.classList.remove(this.#je),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd);const{collidedElements:t}=this.execCollision(e);navigator.vibrate&&Array.isArray(this.#Me.end)&&navigator.vibrate(this.#Me.end);const r=this.#De.style.left,i=this.#De.style.top;this.#De&&(this.#be?this.#De.remove():Object.assign(this.#De.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#De=null),this.#Ce&&this.#qe(),this.#Ce=null,this.#be&&this.#F.classList.remove(this.#ke),this.#Te||(this.#F.style.left=r,this.#F.style.top=i);const n=new CustomEvent("drop",{detail:{targets:t,first:t[0]||null}});this.#F.dispatchEvent(n)}#Ve(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(At(this.#h),!(e instanceof DOMRect)||"number"!=typeof e.left||"number"!=typeof e.right||"number"!=typeof e.top||"number"!=typeof e.bottom)throw new Error("getCollidedElementByRect expects a valid DOMRect object.");return this.#Ie.filter(t=>this.#Ve(t,e))}getCollidedElementByRect(e){if(At(this.#h),!(e instanceof DOMRect)||"number"!=typeof e.left||"number"!=typeof e.right||"number"!=typeof e.top||"number"!=typeof e.bottom)throw new Error("getCollidedElementByRect expects a valid DOMRect object.");return this.#Ie.find(t=>this.#Ve(t,e))||null}#Ke(e,t,r){const i=e.getBoundingClientRect();return t>=i.left&&t<=i.right&&r>=i.top&&r<=i.bottom}getAllCollidedElements(e,t){if(At(this.#h),"number"!=typeof e||"number"!=typeof t)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#Ie.filter(r=>this.#Ke(r,e,t))}getCollidedElement(e,t){if(At(this.#h),"number"!=typeof e||"number"!=typeof t)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#Ie.find(r=>this.#Ke(r,e,t))||null}#Be(e){const t=new CustomEvent(e);this.#F.dispatchEvent(t)}getDragging(){return At(this.#h),this.#Se}getLockInsideJail(){return At(this.#h),this.#Ee}setLockInsideJail(e){if(At(this.#h),"boolean"!=typeof e)throw new Error("lockInsideJail must be a boolean.");this.#Ee=e}getRevertOnDrop(){return At(this.#h),this.#Te}setRevertOnDrop(e){if(At(this.#h),"boolean"!=typeof e)throw new Error("revertOnDrop must be a boolean.");this.#Te=e}getCollisionByMouse(){return At(this.#h),this.#xe}setCollisionByMouse(e){if(At(this.#h),"boolean"!=typeof e)throw new Error("collisionByMouse must be a boolean.");this.#xe=e}getDropInJailOnly(){return At(this.#h),this.#Ae}setDropInJailOnly(e){if(At(this.#h),"boolean"!=typeof e)throw new Error("dropInJailOnly must be a boolean.");this.#Ae=e}getDefaultZIndex(){return At(this.#h),this.#$e}setDefaultZIndex(e){if(At(this.#h),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("Z-index must be a finite number.");this.#$e=e}isMirrorEnabled(){return At(this.#h),this.#be}setMirrorEnabled(e){if(At(this.#h),"boolean"!=typeof e)throw new TypeError("Mirror setting must be a boolean.");this.#be=e}getTarget(){return At(this.#h),this.#F}getJail(){return At(this.#h),this.#Ne}getDragProxy(){return At(this.#h),this.#De}getLastCollision(){return At(this.#h),this.#Ce}getCollidables(){return At(this.#h),[...this.#Ie]}getDragHiddenClass(){return At(this.#h),this.#ke}getClassDragging(){return At(this.#h),this.#Le}getClassBodyDragging(){return At(this.#h),this.#_e}getClassJailDragging(){return At(this.#h),this.#je}getClassJailDragDisabled(){return At(this.#h),this.#Re}getClassDragCollision(){return At(this.#h),this.#Pe}getVibrations(){return At(this.#h),{...this.#Me}}getStartVibration(){return At(this.#h),this.#Me.start}getEndVibration(){return At(this.#h),this.#Me.end}getCollideVibration(){return At(this.#h),this.#Me.collide}getMoveVibration(){return At(this.#h),this.#Me.move}isEnabled(){return At(this.#h),this.#ye}destroy(){this.#h||(this.disable(),this.#F.removeEventListener("mousedown",this._onMouseDown),this.#F.removeEventListener("touchstart",this._onTouchStart),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd),this.#Ce&&this.#qe(),this.#De&&(this.#be?this.#De.remove():Object.assign(this.#De.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#De=null),this.#Ie=[],this.#Se=!1,this.#Ce=null,this.#be&&this.#F.classList.remove(this.#ke),this.#F.classList.remove(this.#Le),document.body.classList.remove(this.#_e),this.#Ne&&this.#Ne.classList.remove(this.#je,this.#Re),this.#h=!0)}}const It=Ct,Dt=class{#Je=[];#Ue=!1;#Ge=!1;#Ye=[];#Xe(){this.#Ue&&Promise.all(this.#Ye).then(()=>{this.#Ge=!0,this.#Qe(!1)}).catch(e=>{console.error("[TinyDomReadyManager] Promise rejected:",e)})}#Qe(e){this.#Je.filter(t=>t.domOnly===e).sort((e,t)=>t.priority-e.priority).forEach(e=>this.#Ze(e)),this.#Je=this.#Je.filter(t=>!(t.once&&(!e||t.domOnly)))}#Ze(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.#Ue=!0,this.#Qe(!0),this.#Xe()}init(){if(this.#Ue)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.#Ge||(this.#Ye.push(e),this.#Ue&&this.#Xe())}onReady(e,{once:t=!0,priority:r=0,filter:i=null,domOnly:n=!1}={}){if("function"!=typeof e)throw new TypeError("[TinyDomReadyManager] fn must be a function.");const s={fn:e,once:t,priority:r,filter:i,domOnly:n};if(n&&this.#Ue)return this.#Ze(s),void(t||this.#Je.push(s));!n&&this.#Ge?this.#Ze(s):this.#Je.push(s)}isReady(){return this.#Ge}isDomReady(){return this.#Ue}},Mt=class{#et=!1;#tt=!1;#rt=null;#it=100;#nt=null;#st;constructor({audio:e=null,defaultIcon:t=null,bodyLimit:r=100,defaultOnClick:i=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 i)throw new TypeError("defaultOnClick must be a function.");this.#rt="string"!=typeof e?e:new Audio(e),this.#nt=t,this.#it=r,this.#st=i}requestPerm(){const e=this;return new Promise((t,r)=>{e.isCompatible()?"default"===Notification.permission?Notification.requestPermission().then(r=>{this.#tt=!0,e.#et="granted"===r,t(e.#et)}).catch(r):(this.#tt=!0,e.#et="granted"===Notification.permission,t(e.#et)):(this.#tt=!0,e.#et=!1,t(!1))})}isCompatible(){return"Notification"in window}send(e,t={}){if(!this.#tt)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.#et)return null;const{icon:r=this.#nt||void 0,vibrate:i=[200,100,200]}=t,n={...t};"string"==typeof r&&(n.icon=r),Array.isArray(i)&&(n.vibrate=i),"string"==typeof n.body&&(n.body=V(n.body,this.#it));const s=new Notification(e,n);return s.addEventListener("show",()=>{this.#rt instanceof HTMLAudioElement&&(this.#rt.currentTime=0,this.#rt.play().catch(e=>console.error(e)))}),"function"==typeof this.#st&&s.addEventListener("click",this.#st),s}wasPermissionRequested(){return this.#tt}isAllowed(){return this.#et}getAudio(){return this.#rt}setAudio(e){if(!(e instanceof HTMLAudioElement)&&"string"!=typeof e&&null!==e)throw new TypeError("sound must be an instance of HTMLAudioElement or null.");this.#rt="string"!=typeof e?e:new Audio(e)}getBodyLimit(){return this.#it}setBodyLimit(e){if(!Number.isFinite(e)||e<0)throw new TypeError("bodyLimit must be a non-negative number.");this.#it=e}getDefaultAvatar(){return this.#nt}setDefaultAvatar(e){if("string"!=typeof e&&null!==e)throw new TypeError("defaultIcon must be a string or null.");this.#nt=e}getDefaultOnClick(){return this.#st}setDefaultOnClick(e){if("function"!=typeof e)throw new TypeError("defaultOnClick must be a function.");this.#st=e}},Nt=(e,t)=>{if("string"!=typeof t)throw new TypeError('Expected "name" to be a string.');if("string"!=typeof e)throw new TypeError(`Expected "${t}" to be a string, but received ${typeof e}.`)},kt=(e,t)=>{if("string"!=typeof t)throw new TypeError('Expected "name" to be a string.');if("function"!=typeof e)throw new TypeError(`Expected "${t}" to be a function, but received ${typeof e}.`)},Lt=(e,t)=>{if("string"!=typeof t)throw new TypeError('Expected "name" to be a string.');if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError(`Expected "${t}" to be a plain object, but received ${null===e?"null":Array.isArray(e)?"array":typeof e}.`)},_t=new Map;class jt extends Error{constructor(e,t,r){if(Nt(e,"message"),Nt(t,"url"),"string"!=typeof r)throw new TypeError(`Expected "stage" to be a string, but received ${typeof r}.`);super(e),this.name="MediaLoadingError",this.url=t,this.stage=r}}const Rt=async e=>{Nt(e,"str");const t=(new TextEncoder).encode(e),r=await crypto.subtle.digest("SHA-1",t);return Array.from(new Uint8Array(r)).map(e=>e.toString(16).padStart(2,"0")).join("").substring(0,8)},Pt=(e,t="image/jpeg")=>{if(!(e instanceof Uint8Array)&&"string"!=typeof e)throw new TypeError(`Expected "data" to be an instance of Uint8Array or a string, but received ${typeof e}.`);Nt(t,"format");const r=e=>{const t=URL.createObjectURL(e),r=_t.get(t);return _t.set(t,"number"==typeof r?r+1:1),t};if(e instanceof Uint8Array)return r(new Blob([e],{type:t}));if("string"==typeof e&&e.startsWith("data:")){const i=e.split(",")[1],n=atob(i),s=new Uint8Array(n.length);for(let e=0;e<n.length;e++)s[e]=n.charCodeAt(e);return r(new Blob([s],{type:t}))}return"string"==typeof e?e:""},$t=async e=>{if(Nt(e,"url"),!e.startsWith("blob:"))return e;try{const t=await fetch(e),r=await t.blob();return await new Promise((e,t)=>{const i=new FileReader;i.onloadend=()=>e(String(i.result)),i.onerror=t,i.readAsDataURL(r)})}catch(t){return console.warn(`[TinyAudioUtils] Failed to convert Blob URL to Base64 on export: ${e}`,t),e}},Ht=e=>{Lt(e,"content"),e&&Array.isArray(e.picture)&&e.picture.forEach(e=>{if("string"==typeof e.data&&e.data.startsWith("blob:")){const t=_t.get(e.data)??0;t>1?_t.set(e.data,t-1):_t.delete(e.data),t<=1&&URL.revokeObjectURL(e.data)}})},Ot=(e,t)=>{if(Lt(e,"common"),"boolean"!=typeof t)throw new TypeError('Expected "isPartial" to be a boolean.');const r=e=>t&&void 0===e,i=e=>r(e)||"string"==typeof e||null===e,n=(e,t)=>(kt(t,"valueValidator"),!!r(e)||!(!Array.isArray(e)||!e.every(t)));if(!i(e.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!i(e.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!i(e.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a string or null.');if(!i(e.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(s=e.year,!r(s)&&"number"!=typeof s&&null!==s)throw new TypeError('Invalid metadata: "year" must be a number or null.');var s;if(!n(e.albumartists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "albumartists" must be an array of string.');if(!n(e.genre,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "genre" must be an array of string.');if(!n(e.label,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "label" must be an array of string.');if(!n(e.composer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "composer" must be an array of string.');if(!n(e.artists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "artists" must be an array of string.');if(!n(e.picture,e=>e&&"object"==typeof e&&(void 0===e.description||"string"==typeof e.description)&&(void 0===e.name||"string"==typeof e.name)&&(void 0===e.type||"string"==typeof e.type)&&"string"==typeof e.format&&(e.data instanceof Uint8Array||"string"==typeof e.data)))throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');const o=(e,t)=>{if(Nt(e,"name"),!r(t)){if(null==t)throw new TypeError(`Invalid metadata: "${e}" is required.`);if("object"!=typeof t)throw new TypeError(`Invalid metadata: "${e}" must be an object or null.`);if("number"!=typeof t.no&&null!==t.no)throw new TypeError(`Invalid metadata: "${e}.no" must be a number or null.`);if("number"!=typeof t.of&&null!==t.of)throw new TypeError(`Invalid metadata: "${e}.of" must be a number or null.`)}};o("disk",e.disk),o("track",e.track)},Ft=e=>(Lt(e,"common"),Ot(e,!1)),Bt=e=>(Lt(e,"common"),Ot(e,!0)),zt=async(e,t)=>{Nt(e,"url"),kt(t,"parseFile");try{const r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch audio file: ${r.status} ${r.statusText}`);const i=await r.blob(),n=await t(i);if(!n||"object"!=typeof n.common)throw new TypeError('Invalid metadata: "common" property is missing or not an object.');const s=n.common;return Bt(s),{title:s?.title??null,album:s?.album??null,albumartist:s?.albumartist??null,albumartists:s?.albumartists??[],genre:s?.genre??[],label:s?.label??[],composer:s?.composer??[],year:s?.year??null,artist:s?.artist??null,artists:s?.artists??[],disk:s?.disk?{no:s.disk.no,of:s.disk.of}:{no:null,of:null},track:s?.track?{no:s.track.no,of:s.track.of}:{no:null,of:null},picture:s?.picture?.map(e=>({...e,data:Pt(e.data,e.format)}))??[]}}catch(e){throw e}},Wt=async(e,t={},r={},i=e=>{if(!(e instanceof Blob))throw new TypeError('Expected "data" to be a Blob.');return new Promise((e,t)=>t(new TypeError("parseFile library not found.")))},n={},s="null")=>{if("string"!=typeof e&&!(e instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(Lt(t,"defaultMetadata"),Lt(r,"metadata"),kt(i,"parseFile"),Lt(n,"callbacks"),n.onProgress&&"function"!=typeof n.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(n.onError&&"function"!=typeof n.onError)throw new TypeError("callbacks.onError must be a function.");if("string"!=typeof s&&"function"!=typeof s)throw new TypeError("unknownArtist must be a string or a function returning a string.");let o,a="";const l=(t,r)=>{if(Nt(t,"stage"),void 0!==r&&!(r instanceof Event))throw new TypeError('Expected "event" to be an Event or undefined.');n.onProgress&&n.onProgress({event:r,status:"loading",stage:t,url:a||(e instanceof HTMLMediaElement?e.src:"unknown")})},u=(t,r)=>{if(!(t instanceof Error))throw new TypeError('Expected "error" to be an Error.');Nt(r,"stage"),n.onError&&n.onError({error:t,url:a||(e instanceof HTMLMediaElement?e.src:"unknown"),stage:r})};try{l("INITIALIZING"),"string"==typeof e?(a=e,o=new Audio(a)):(o=e,a=o.src);try{await new Promise((e,t)=>{const r=e=>l("DOWNLOADING",e),i=()=>{s(),e(void 0)},n=e=>{s(),t(new Error(`HTMLMediaElement failed to load: ${e.message||"Unknown error"}`))},s=()=>{o.removeEventListener("progress",r),o.removeEventListener("loadedmetadata",i),o.removeEventListener("error",n)};o.addEventListener("progress",r),o.addEventListener("loadedmetadata",i),o.addEventListener("error",n),o.readyState>=1&&(s(),e(void 0))}),l("METADATA_LOADED")}catch(e){throw new jt(e instanceof Error?e.message:"UNKNOWN ERROR",a,"METADATA")}const h={id:r.id||await Rt(a),duration:Math.floor(1e3*o.duration),url:a,weight:r.weight??1};let c={};l("EXTRACTING_ID3");try{c=await zt(a,i)}catch(e){u(e instanceof Error?e:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${a}. Falling back to filename.`)}const d=e=>{Nt(e,"url");try{return(e.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},m={...h,...t,...c,...r,title:c.title||r.title||d(a),artist:c.artist||r.artist||("string"==typeof s?s:String(s()))};return n.onProgress&&n.onProgress({status:"success",stage:"COMPLETE",url:a}),m}catch(e){if(e instanceof jt)throw e;{const t=new jt(e instanceof Error?e.message:"UNKNOWN ERROR",a,"INITIALIZING");throw u(t,"INITIALIZING"),t}}},qt=X("TinyAfterScrollWatcher"),Vt=class{#ot;get scrollTarget(){return qt(this.#h),this.#ot}#at=null;#lt=[];get afterScrollQueueSize(){return qt(this.#h),this.#lt.length}#ut=100;#ht=new Set;#ct=new Set;#h=!1;get destroyed(){return this.#h}constructor(e,t=100){if(!(e instanceof Element||e instanceof Window))throw new TypeError("scrollTarget must be an Element or the Window object.");this.#ot=e,this._checkTimer=this._checkTimer.bind(this),this.#ot.addEventListener("scroll",this._checkTimer),this.#ut=t}_checkTimer=()=>{this.#at&&clearTimeout(this.#at),this.#at=setTimeout(()=>{this.#at=null,this.#dt()},this.#ut)};get inactivityTime(){return qt(this.#h),this.#ut}set inactivityTime(e){if(qt(this.#h),"number"!=typeof e||e<=0||!Number.isFinite(e))throw new Error("inactivityTime must be a positive number in milliseconds.");this.#ut=e}#dt(){if(!this.#h){for(const e of this.#ct)"function"==typeof e&&e();for(;this.#lt.length;){const e=this.#lt.pop();"function"==typeof e&&e()}}}doAfterScroll(e){if(qt(this.#h),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.lastScrollTime=Date.now(),this.#lt.push(e)}onStop(e){if(qt(this.#h),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ct.add(e)}offStop(e){if(qt(this.#h),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ct.delete(e)}onScroll(e){if(qt(this.#h),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ot.addEventListener("scroll",e),this.#ht.add(e)}offScroll(e){if(qt(this.#h),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ht.has(e)&&(this.#ot.removeEventListener("scroll",e),this.#ht.delete(e))}destroy(){if(!this.#h){this.#ot.removeEventListener("scroll",this._checkTimer);for(const e of this.#ht)this.#ot.removeEventListener("scroll",e);this.#ht.clear(),this.#ct.clear(),this.#h=!0}}},Kt=X("UltraRandomMsgGen"),Jt=["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","sed","do","eiusmod","tempor","incididunt","ut","labore","et","dolore","magna","aliqua"],Ut=["😂","🌈","🤖","💥","🐸","🍕","🦄","🧠","🧬","🚀","🫠","💫","🍩","👾","🎉","🥴","🐙","🧃","🪐","🎈","🧸","👻","🥳","🍭","💖","😺","🌮","🪅","🎮","🥓","🍮","🍬","🍓","🍒","🥝","🥑","🍄","🌊","☁️","🌟","🌙","🧚","🐾","🐥","🐼","🐨","🐳","✨","🧁","🌸","🍃","💎","🎐","🎀","🫧","☄️","🛸","🔮"],Gt=["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"],Yt=["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"],Xt=["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"],Qt=["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.","In the glow of the {adj} moon, the {noun} began to {verb}.","A sprinkle of {adj} dust made the {noun} {verb} through the air.","The {noun} whispered a {adj} secret that made everyone {verb}.","Everything felt {adj} and {adj}, especially when the {noun} {verb}ed.","The {noun} is {verb}ing! The {noun} is {verb}ing! AAAAA!","Glitch in the {noun}: the {adj} {noun} just {verb}ed out of existence.","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 Zt{static#mt=Jt;static#pt=Ut;static#ft=Gt;static#yt=Yt;static#gt=Xt;static#wt=Qt;static#bt(e,t){if(!Array.isArray(e))throw new TypeError(`${t} must be an array of strings`);if(!e.every(e=>"string"==typeof e))throw new TypeError(`${t} must contain only strings`);if(0===e.length)throw new Error(`${t} cannot be empty`)}static get defaultWords(){return[...this.#mt]}static set defaultWords(e){this.#bt(e,"defaultWords"),this.#mt=[...e]}static get defaultEmojis(){return[...this.#pt]}static set defaultEmojis(e){this.#bt(e,"defaultEmojis"),this.#pt=[...e]}static get defaultNouns(){return[...this.#ft]}static set defaultNouns(e){this.#bt(e,"defaultNouns"),this.#ft=[...e]}static get defaultVerbs(){return[...this.#yt]}static set defaultVerbs(e){this.#bt(e,"defaultVerbs"),this.#yt=[...e]}static get defaultAdjectives(){return[...this.#gt]}static set defaultAdjectives(e){this.#bt(e,"defaultAdjectives"),this.#gt=[...e]}static get defaultTemplates(){return[...this.#wt]}static set defaultTemplates(e){this.#bt(e,"defaultTemplates"),this.#wt=[...e]}#h=!1;get destroyed(){return this.#h}#vt={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}};get config(){return Kt(this.#h),structuredClone(this.#vt)}#Et="!@#$%^&*()-_=+[]{}|;:,.<>?/\\~".split("");get symbols(){return Kt(this.#h),structuredClone(this.#Et)}constructor(e={}){const{minLength:t,maxLength:r,readable:i,useEmojis:n,includeNumbers:s,includeSymbols:o,allowWeirdSpacing:a,emojiSet:l,wordSet:u,mode:h,grammar:c,repeatWords:d,emojiPlacement:m,paragraphs:p,line:f}=e;if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.minLength must be an integer >= 1");if(void 0!==r&&(!Number.isInteger(r)||r<1))throw new TypeError("config.maxLength must be an integer >= 1");if(void 0!==t&&void 0!==r&&t>r)throw new RangeError("config.minLength cannot be greater than config.maxLength");if(void 0!==i&&"boolean"!=typeof i)throw new TypeError("config.readable must be a boolean");if(void 0!==n&&"boolean"!=typeof n)throw new TypeError("config.useEmojis must be a boolean");if(void 0!==s&&"boolean"!=typeof s)throw new TypeError("config.includeNumbers must be a boolean");if(void 0!==o&&"boolean"!=typeof o)throw new TypeError("config.includeSymbols must be a boolean");if(void 0!==a&&"boolean"!=typeof a)throw new TypeError("config.allowWeirdSpacing must be a boolean");if(void 0!==l&&!Array.isArray(l))throw new TypeError("config.emojiSet must be an array of strings");if(void 0!==u&&!Array.isArray(u))throw new TypeError("config.wordSet must be an array of strings");if(void 0!==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:i}=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!==i&&!Array.isArray(i))throw new TypeError("config.grammar.adjectives must be an array of strings")}if(void 0!==d&&"boolean"!=typeof d)throw new TypeError("config.repeatWords must be a boolean");if(void 0!==m&&!["inline","end","none"].includes(m))throw new RangeError('config.emojiPlacement must be one of: "inline", "end", "none"');if(void 0!==p){if("object"!=typeof p)throw new TypeError("config.paragraphs must be an object or null");const{min:e,max:t}=p;if(void 0!==e&&(!Number.isInteger(e)||e<1))throw new TypeError("config.paragraphs.min must be an integer >= 1");if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.paragraphs.max must be an integer >= 1");if(void 0!==e&&void 0!==t&&e>t)throw new RangeError("config.paragraphs.min cannot be greater than config.paragraphs.max")}if(void 0!==f){if("object"!=typeof f||null===f)throw new TypeError("config.line must be an object");const{minLength:e,maxLength:t,emojiChance:r}=f;if(void 0!==e&&(!Number.isInteger(e)||e<1))throw new TypeError("config.line.minLength must be an integer >= 1");if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.line.maxLength must be an integer >= 1");if(void 0!==e&&void 0!==t&&e>t)throw new RangeError("config.line.minLength cannot be greater than config.line.maxLength");if(void 0!==r&&("number"!=typeof r||r<0||r>1))throw new RangeError("config.line.emojiChance must be a number between 0 and 1")}this.#vt.emojiSet=[...Zt.#pt],this.#vt.wordSet=[...Zt.#mt],this.#vt.grammar.templates=[...Zt.#wt],this.#vt.grammar.nouns=[...Zt.#ft],this.#vt.grammar.verbs=[...Zt.#yt],this.#vt.grammar.adjectives=[...Zt.#gt],Object.assign(this.#vt,e)}configure(e={}){return Kt(this.#h),Object.assign(this.#vt,e),this}setGrammarTemplates(...e){return Kt(this.#h),this.#vt.grammar.templates=e.flat(),this}addGrammarTemplates(...e){return Kt(this.#h),this.#vt.grammar.templates.push(...e.flat()),this}setGrammarNouns(...e){return Kt(this.#h),this.#vt.grammar.nouns=e.flat(),this}addGrammarNouns(...e){return Kt(this.#h),this.#vt.grammar.nouns.push(...e.flat()),this}setGrammarVerbs(...e){return Kt(this.#h),this.#vt.grammar.verbs=e.flat(),this}addGrammarVerbs(...e){return Kt(this.#h),this.#vt.grammar.verbs.push(...e.flat()),this}setGrammarAdjectives(...e){return Kt(this.#h),this.#vt.grammar.adjectives=e.flat(),this}addGrammarAdjectives(...e){return Kt(this.#h),this.#vt.grammar.adjectives.push(...e.flat()),this}removeGrammarTemplates(...e){Kt(this.#h);const t=new Set(e.flat());return this.#vt.grammar.templates=this.#vt.grammar.templates.filter(e=>!t.has(e)),this}removeGrammarNouns(...e){Kt(this.#h);const t=new Set(e.flat());return this.#vt.grammar.nouns=this.#vt.grammar.nouns.filter(e=>!t.has(e)),this}removeGrammarVerbs(...e){Kt(this.#h);const t=new Set(e.flat());return this.#vt.grammar.verbs=this.#vt.grammar.verbs.filter(e=>!t.has(e)),this}removeGrammarAdjectives(...e){Kt(this.#h);const t=new Set(e.flat());return this.#vt.grammar.adjectives=this.#vt.grammar.adjectives.filter(e=>!t.has(e)),this}setWords(...e){return Kt(this.#h),this.#vt.wordSet=e.flat(),this}addWords(...e){return Kt(this.#h),this.#vt.wordSet.push(...e.flat()),this}removeWords(...e){Kt(this.#h);const t=new Set(e.flat());return this.#vt.wordSet=this.#vt.wordSet.filter(e=>!t.has(e)),this}setEmojis(...e){return Kt(this.#h),this.#vt.emojiSet=e.flat(),this}addEmojis(...e){return Kt(this.#h),this.#vt.emojiSet.push(...e.flat()),this}removeEmojis(...e){Kt(this.#h);const t=new Set(e.flat());return this.#vt.emojiSet=this.#vt.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:i,useEmojis:n,readable:s,mode:o,emojiPlacement:a}=this.#vt;if("natural"===o)return this._generateNaturalSentence();const l=[];return(s||"readable"===o||"mixed"===o)&&l.push(this._getRandomItem(e)),"chaotic"!==o&&"mixed"!==o||l.push(Math.random().toString(36).slice(2)),r&&l.push(Math.floor(99999*Math.random()).toString()),i&&l.push(this._getRandomItem(this.#Et)),"inline"===a&&n&&t.length&&l.push(this._getRandomItem(t)),this._getRandomItem(l)}_generateNaturalSentence(){const{templates:e,nouns:t,verbs:r,adjectives:i}=this.#vt.grammar;return this._getRandomItem(e).replace(/{noun}/g,()=>this._getRandomItem(t)).replace(/{verb}/g,()=>this._getRandomItem(r)).replace(/{adj}/g,()=>this._getRandomItem(i))}_generateLine(e,t){const{allowWeirdSpacing:r,repeatWords:i,readable:n,emojiSet:s,useEmojis:o,emojiPlacement:a,line:l}=this.#vt,u=[];for(t??=new Set;u.join(" ").length<e;){let e=this._generateChunk();!i&&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(n?" ":"");return"end"===a&&o&&s.length&&Math.random()<(l?.emojiChance||0)&&(h+=" "+this._getRandomItem(s)),h}_generateParagraphLines(e){const{line:t}=this.#vt,r=[],i=new Set;let n=0;for(;n<e;){const s=Math.floor(Math.random()*(t.maxLength-t.minLength+1)+t.minLength),o=Math.min(s,e-n);r.push(this._generateLine(o,i)),n+=o}return r}generate(){Kt(this.#h);const{minLength:e,maxLength:t,paragraphs:r}=this.#vt,i=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(i/e),n=[];for(let r=0;r<e;r++){const e=this._generateParagraphLines(t);n.push(e.join("\n"))}return n.join("\n\n")}return this._generateParagraphLines(i).join("\n")}destroy(){this.destroyed||(this.#Et=[],this.#vt.emojiSet=[],this.#vt.wordSet=[],this.#vt.grammar.templates=[],this.#vt.grammar.nouns=[],this.#vt.grammar.verbs=[],this.#vt.grammar.adjectives=[],this.#h=!0)}}const er=Zt;var tr=r(7);const rr=X("TinySmartScroller");class ir extends tr.EventEmitter{static Utils={...t,TinyHtml:xt};#Tt=new WeakMap;#St=new WeakMap;#xt=new WeakMap;#At=new WeakMap;#Ct=new WeakMap;#It=new WeakMap;#Dt=null;#Mt=null;#Nt=new Set(["IMG","IFRAME","VIDEO"]);#kt=null;#Lt=!1;#_t=!1;#jt=!1;#Rt=!1;#Pt=!1;#$t=!1;#Ht=!1;#Ot=!1;#Ft="";#Bt=!1;#h=!1;#zt=!1;#Wt=!1;#qt=!1;#Vt=!1;#Kt=0;#Jt=0;#Ut=0;#Gt=0;#Yt=0;#Xt;#Qt;#F;#Zt=new Set;constructor(e,{extraScrollBoundary:t=0,autoScrollBottom:r=!0,observeMutations:i=!0,preserveScrollOnLayoutShift:n=!0,debounceTime:s=100,querySelector:o=null,attributeFilter:a=["class","style","src","data-*","height","width"]}={}){if(super(),!(e instanceof Element||e===window))throw new TypeError("TinySmartScroller: 'target' must be a DOM Element or 'window', but got "+typeof e);if("number"!=typeof t||Number.isNaN(t))throw new TypeError(`TinySmartScroller: 'extraScrollBoundary' must be a valid number, received ${t}`);if("boolean"!=typeof r)throw new TypeError("TinySmartScroller: 'autoScrollBottom' must be a boolean, received "+typeof r);if("boolean"!=typeof i)throw new TypeError("TinySmartScroller: 'observeMutations' must be a boolean, received "+typeof i);if("boolean"!=typeof n)throw new TypeError("TinySmartScroller: 'preserveScrollOnLayoutShift' must be a boolean, received "+typeof n);if("number"!=typeof s||s<0||Number.isNaN(s))throw new TypeError(`TinySmartScroller: 'debounceTime' must be a non-negative number, received ${s}`);if(null!==o&&"string"!=typeof o)throw new TypeError("TinySmartScroller: 'querySelector' must be a string or null, received "+typeof o);if(!(null===a||Array.isArray(a)||a instanceof Set))throw new TypeError("TinySmartScroller: 'attributeFilter' must be an array, Set, or null. Got "+typeof a);let l;this.#F=e,this.#Qt=e instanceof Window?document.documentElement:e,this.#Bt=e instanceof Window,this.#Wt=r,this.#qt=i,this.#Vt=n,this.#Kt=s,this.#Yt=t,this.#Ft=o||"",this.#Xt=new Set(a||void 0),this.#kt=()=>{this._scrollDataUpdater(),clearTimeout(l),l=setTimeout(()=>this._onScroll(),this.#Kt)},(this.#Bt?window:this.#Qt).addEventListener("scroll",this.#kt,{passive:!0}),this.#qt&&(this._observeMutations(),this._observeResizes(this.#Qt.children)),this._scrollDataUpdater()}getSimpleOnHeight(e=[]){if(rr(this.#h),!Array.isArray(e))throw new TypeError("getSimpleOnHeight(filter): filter must be an array of tag names");return(t,r,i)=>{if(e.length>0&&!e.includes(t.tagName)||i.now!==i.old)return;const n=r.old;return{height:r.now.height-n.height,width:0}}}addSimpleOnHeight(e){if(rr(this.#h),!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 rr(this.#h),Array.from(this.#Nt)}addLoadTag(e){if(rr(this.#h),"string"!=typeof e)throw new TypeError("addLoadTag(tag): tag must be a string");this.#Nt.add(e.toUpperCase())}removeLoadTag(e){if(rr(this.#h),"string"!=typeof e)throw new TypeError("removeLoadTag(tag): tag must be a string");this.#Nt.delete(e.toUpperCase())}hasLoadTag(e){if(rr(this.#h),"string"!=typeof e)throw new TypeError("hasLoadTag(tag): tag must be a string");return this.#Nt.has(e.toUpperCase())}resetLoadTags(e=!1){if(rr(this.#h),"boolean"!=typeof e)throw new TypeError("resetLoadTags(addDefault): addDefault must be a boolean");this.#Nt.clear(),e&&(this.#Nt.add("IMG"),this.#Nt.add("IFRAME"),this.#Nt.add("VIDEO"))}getAttributeFilters(){return rr(this.#h),Array.from(this.#Xt)}addAttributeFilter(e){if(rr(this.#h),"string"!=typeof e)throw new TypeError("addAttributeFilter(attr): attr must be a string");this.#Xt.add(e)}removeAttributeFilter(e){if(rr(this.#h),"string"!=typeof e)throw new TypeError("removeAttributeFilter(attr): attr must be a string");this.#Xt.delete(e)}hasAttributeFilter(e){if(rr(this.#h),"string"!=typeof e)throw new TypeError("hasAttributeFilter(attr): attr must be a string");return this.#Xt.has(e)}resetAttributeFilters(e=!1){if(rr(this.#h),"boolean"!=typeof e)throw new TypeError("resetAttributeFilters(addDefault): addDefault must be a boolean");this.#Xt.clear(),e&&["class","style","src","data-*","height","width"].forEach(e=>this.#Xt.add(e))}onSize(e){if(rr(this.#h),"function"!=typeof e)throw new TypeError("onSize(handler): handler must be a function");this.#Zt.add(e)}offSize(e){if(rr(this.#h),"function"!=typeof e)throw new TypeError("offSize(handler): handler must be a function");this.#Zt.delete(e)}_scrollDataUpdater(){const e=new Map;return this.#Qt.querySelectorAll(this.#Ft||"*").forEach(t=>{const r=this.#xt.get(t)??!1;this.#At.set(t,r);const i=xt.isInContainer(this.#Qt,t);this.#xt.set(t,i),e.set(t,{oldIsVisible:r,isVisible:i})}),e}_onScroll(){if(this.#h)return;const e=this._scrollDataUpdater(),t=this.#Qt,r=t.scrollTop,i=t.scrollHeight,n=t.clientHeight,s={scrollTop:r,scrollHeight:i,clientHeight:n};let o=null,a=null;const l=0===r,u=r+n>=i-1,h=r<=0+this.#Yt,c=r+n>=i-1-this.#Yt;l&&u?o="all":l?o="top":u&&(o="bottom"),h&&c?a="all":h?a="top":c&&(a="bottom"),this.#_t=this.#$t??!1,this.#Lt=this.#Pt??!1,this.#jt=this.#Ht??!1,this.#Rt=this.#Ot??!1,this.#$t=l,this.#Pt=u,this.#Ht=h,this.#Ot=c,this.#zt=!(this.#Wt&&this.#Pt),this.#Gt=i-r-n,this.emit("onScrollBoundary",{status:o,...s,scrollCache:e}),this.emit("onExtraScrollBoundary",{status:a,...s,scrollCache:e}),this.#zt?this.emit("onScrollPause",{...s,scrollCache:e}):this.emit("onAutoScroll",{...s,scrollCache:e})}_fixScroll(e=[]){if(this.#h)return;if(!Array.isArray(e))throw new TypeError("_fixScroll: targets must be an array of Elements");const t=this.#Qt.scrollHeight,r=this.#Qt.scrollTop,i=this.#Qt.scrollHeight-this.#Qt.scrollTop-this.#Qt.clientHeight,n=this.#Qt.scrollHeight-t,s=()=>{const t={height:0,width:0};for(const r of e){const e=this.#Tt.get(r)||{height:0,width:0},i=this.#St.get(r)||{height:0,width:0};this.#Zt.forEach(n=>{const s=n(r,{old:e,now:i},{old:this.#Ut,now:this.#Jt});if(this.#xt.get(r)||this.#Ct.get(r)){if(void 0!==s&&"object"!=typeof s)throw new Error("_fixScroll: size filter must return an object or undefined");if(void 0===s)return;t.height=s.height,t.width=s.width}})}if("number"!=typeof t.height&&t.height<0)throw new Error("_fixScroll: invalid scrollSize.height value");if("number"!=typeof t.width&&t.width<0)throw new Error("_fixScroll: invalid scrollSize.width value");if(0!==t.height||0!==t.width)for(const t of e)this.#Ct.set(t,this.#xt.get(t)??!1),this.#It.set(t,this.#At.get(t)??!1);return t};if(this.#Ut>0&&xt.hasScroll(this.#Qt).v&&this.#Wt&&this.#Vt&&!this.#Pt&&!this.#$t){const e=s();this.#Qt.scrollTop=r+n+e.height,e.width>0&&(this.#Qt.scrollLeft=this.#Qt.scrollLeft+e.width)}else!this.#zt&&this.#Wt?(s(),this.scrollToBottom()):this.#Wt||this.#Pt||(s(),this.#Qt.scrollTop=this.#Qt.scrollHeight-this.#Qt.clientHeight-i)}_observeMutations(){this.#Mt=new MutationObserver(e=>{this.#h||(this._scrollDataUpdater(),this.#Ut=this.#Jt,this.#Jt=this.#Qt.childElementCount,e.forEach(e=>{e.addedNodes.forEach(e=>{if(e instanceof Element&&1===e.nodeType&&(this._observeResizes([e]),this._listenLoadEvents(e),this.#Ft)){const t=e.querySelectorAll(this.#Ft);this._observeResizes(t),this._listenLoadEvents(t)}})}),this._fixScroll())}),this.#Mt.observe(this.#Qt,{childList:!0,subtree:!0,attributes:!0,attributeFilter:this.#Xt.size>0?Array.from(this.#Xt):void 0})}_observeResizes(e){this.#Dt||(this.#Dt=new ResizeObserver(e=>{if(this.#h)return;this._scrollDataUpdater();const t=[];for(const r of e){const e=r.target,i=this.#St.get(e);i&&this.#Tt.set(e,i);const{width:n,height:s}=r.contentRect;this.#St.set(e,{width:n,height:s}),t.push(e)}this._fixScroll(t)})),Array.from(e).forEach(e=>{if(!this.#Dt)throw new Error("_observeResizes: ResizeObserver instance is not initialized");this.#Dt.observe(e)})}_listenLoadEvents(e){this.#h||(e instanceof NodeList?Array.from(e):[e]).forEach(e=>{this.#Nt.has(e.tagName)&&(e.complete||e.addEventListener("load",()=>{this._scrollDataUpdater(),!this.#zt&&this.#Wt&&this.scrollToBottom()}))})}get target(){return this.#F}get targetElement(){return this.#Qt}getOldSize(e){return rr(this.#h),this.#Tt.get(e)??null}getNewSize(e){return rr(this.#h),this.#St.get(e)??null}wasVisible(e){return rr(this.#h),this.#At.get(e)??!1}isVisible(e){return rr(this.#h),this.#xt.get(e)??!1}wasTimedVisible(e){return rr(this.#h),this.#It.get(e)??!1}isTimedVisible(e){return rr(this.#h),this.#Ct.get(e)??!1}setExtraScrollBoundary(e){if(rr(this.#h),"number"!=typeof e||Number.isNaN(e))throw new TypeError("setExtraScrollBoundary(value): value must be a valid number");this.#Yt=e}getExtraScrollBoundary(){return rr(this.#h),this.#Yt}getLastKnownScrollBottomOffset(){return rr(this.#h),this.#Gt}scrollToBottom(){rr(this.#h),this.#Qt.scrollTop=this.#Qt.scrollHeight}scrollToTop(){rr(this.#h),this.#Qt.scrollTop=0}isAtCustomBottom(){return rr(this.#h),this.#Ot}isAtCustomTop(){return rr(this.#h),this.#Ht}isAtBottom(){return rr(this.#h),this.#Pt}isAtTop(){return rr(this.#h),this.#$t}isPastAtBottom(){return rr(this.#h),this.#Lt}isPastAtTop(){return rr(this.#h),this.#_t}isPastAtCustomTop(){return rr(this.#h),this.#jt}isPastAtCustomBottom(){return rr(this.#h),this.#Rt}isScrollPaused(){return rr(this.#h),this.#zt}isWindow(){return rr(this.#h),this.#Bt}isDestroyed(){return this.#h}getAutoScrollBottom(){return rr(this.#h),this.#Wt}getObserveMutations(){return rr(this.#h),this.#qt}getPreserveScrollOnLayoutShift(){return rr(this.#h),this.#Vt}getDebounceTime(){return rr(this.#h),this.#Kt}getElemAmount(){return rr(this.#h),this.#Jt}getPrevElemAmount(){return rr(this.#h),this.#Ut}getQuerySelector(){return rr(this.#h),this.#Ft}destroy(){if(this.#h)return;this.#Mt&&(this.#Mt.disconnect(),this.#Mt=null),this.#Dt&&(this.#Dt.disconnect(),this.#Dt=null);const e=this.#Bt?window:this.#Qt;this.#kt&&e.removeEventListener("scroll",this.#kt),this.#Tt=new WeakMap,this.#St=new WeakMap,this.#xt=new WeakMap,this.#At=new WeakMap,this.#Ct=new WeakMap,this.#It=new WeakMap,this.removeAllListeners(),this.#Zt.clear(),this.#Nt.clear(),this.#h=!0}}const nr=ir,sr=class{#G;#er;#tr;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.#er=t,this.#tr=r}getOpenTag(){return this.#er}getCloseTag(){return this.#tr}setOpenTag(e){if("string"!=typeof e)throw new TypeError("Open tag must be a string.");this.#er=e}setCloseTag(e){if("string"!=typeof e)throw new TypeError("Close tag must be a string.");this.#tr=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 i=this.#G.scrollTop,n=this.#G.scrollLeft;return this.#G.setSelectionRange(e,t),r&&(this.#G.scrollTop=i,this.#G.scrollLeft=n),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:i=r,autoSpaceRight:n=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 i)throw new TypeError("autoSpaceLeft must be a boolean.");if("boolean"!=typeof n)throw new TypeError("autoSpaceRight must be a boolean.");const{start:s,end:o}=this.getSelectionRange(),a=this.#G.value,l=a[s-1]||"",u=a[o]||"",h=`${i&&l&&!/\s/.test(l)?" ":""}${e}${n&&u&&!/\s/.test(u)?" ":""}`,c=a.slice(0,s)+h+a.slice(o);this.setValue(c);let d=s;return"end"===t?d=s+h.length:"preserve"===t&&(d=s),this.setSelectionRange(d,d),this}deleteSelection(){return this.insertText(""),this}transformSelection(e){if("function"!=typeof e)throw new TypeError("transformer must be a function.");const{start:t}=this.getSelectionRange(),r=e(this.getSelectedText());return this.insertText(r),this.setSelectionRange(t,t+r.length),this}surroundSelection(e,t){if("string"!=typeof e||"string"!=typeof t)throw new TypeError("prefix and suffix must be strings.");const r=this.getSelectedText();return this.insertText(`${e}${r}${t}`),this}moveCaret(e){if("number"!=typeof e)throw new TypeError("offset must be a number.");const{start:t}=this.getSelectionRange(),r=Math.max(0,t+e);return this.setSelectionRange(r,r),this}selectAll(){return this.setSelectionRange(0,this.#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:i}=this.getSelectionRange(),n=Math.max(0,r-e),s=Math.min(this.#G.value.length,i+t);return this.setSelectionRange(n,s),this}replaceAll(e,t){if(!(e instanceof RegExp))throw new TypeError("regex must be a RegExp.");if("function"!=typeof t)throw new TypeError("replacer must be a function.");const r=this.#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:i}=this.getSelectionRange(),n=this.#G.value,s=n.slice(r,i).replace(e,t),o=n.slice(0,r)+s+n.slice(i);return this.setValue(o),this.setSelectionRange(r,r+s.length),this}toggleCode(e){if("string"!=typeof e)throw new TypeError("codeName must be a string.");const t=this.getSelectedText();if(t.startsWith(e)&&t.endsWith(e)){const r=t.slice(e.length,t.length-e.length);this.insertText(r)}else this.insertText(`${e}${t}${e}`);return this}_insertAttr(e){let t="";if(Array.isArray(e)){if(!e.every(e=>"string"==typeof e))throw new TypeError("All entries in attributes array must be strings.");t=e.map(e=>`${e}`).join(" ")}else{if("object"!=typeof e||null===e)throw new TypeError("attributes must be an object or an array of strings.");t=Object.entries(e).map(([e,t])=>{if("string"!=typeof t)throw new TypeError("All entries in attributes object must be strings.");return`${e}${t.length>0?`="${t}"`:""}`}).join(" ")}return t}wrapWithTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this._insertAttr(t),i=r?`${this.#er}${e} ${r}${this.#tr}`:`${this.#er}${e}${this.#tr}`,n=`${this.#er}/${e}${this.#tr}`;return this.surroundSelection(i,n),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 i=this._insertAttr(r),n=i?`${this.#er}${e} ${i}${this.#tr}`:`${this.#er}${e}${this.#tr}`,s=`${this.#er}/${e}${this.#tr}`;return this.insertText(`${n}${t}${s}`),this}insertSelfClosingTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this._insertAttr(t),i=r?`${this.#er}${e} ${r}${this.#tr}`:`${this.#er}${e}${this.#tr}`;return this.insertText(i),this}toggleTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this.getSelectedText(),i=new RegExp(`^\\[${e}(\\s+[^\\]]*)?\\]`),n=new RegExp(`\\[/${e}\\]$`),s=i.test(r),o=n.test(r);if(s&&o){const e=r.replace(i,"").replace(n,"");this.insertText(e)}else{const i=this._insertAttr(t),n=i?`${this.#er}${e} ${i}${this.#tr}`:`${this.#er}${e}${this.#tr}`,s=`${this.#er}/${e}${this.#tr}`;this.insertText(`${n}${r}${s}`)}return this}},or=class{#rr=!1;#ir=!1;#nr=null;#sr=null;constructor(){void 0!==navigator.clipboard&&null!==navigator.clipboard&&(this.#ir=!0,this.#nr=e=>navigator.clipboard.writeText(e),this.#sr=e=>navigator.clipboard.write([new ClipboardItem({[e.type]:e})])),this.#rr=void 0!==document.execCommand&&null!==document.execCommand}setCopyText(e){if("function"!=typeof e)throw new TypeError("setCopyText expected a function that returns Promise<void>.");this.#nr=e}setCopyBlob(e){if("function"!=typeof e)throw new TypeError("setCopyBlob expected a function that returns Promise<void>.");this.#sr=e}copyText(e){if("string"!=typeof e)throw new TypeError("copyText expected a string.");if(this.#nr)return this.#nr(e);if(this.#rr){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.#sr)return this.#sr(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,i=!1){return new Promise((n,s)=>{this._read(e).then(o=>{if(!o)return n(null);const a=[];let l=!0;const u=async(e,n)=>{if(l)if(null!==t&&"custom"!==t||"string"!=typeof r||!(!i&&e.startsWith(r)||i&&e===r))if(null!==t&&"text"!==t||"text/plain"!==e){if(null===t){l=!1;const t=await this._handleBlob(e,n);t&&a.push(t)}}else{l=!1;const t=await this._handleText(e,n);t&&a.push(t)}else{l=!1;const t=await this._handleBlob(e,n);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(o),Promise.all(h).then(()=>{a[0]?n(a[0]):n(null)}).catch(s);else if(Array.isArray(o)){for(const e in o)c(o[e]);Promise.all(h).then(()=>n(a)).catch(s)}}).catch(s)})}async readText(e=0){const t=await this._readData(e,"text");if("string"!=typeof t)throw new Error("Failed to read text: expected string result.");return t}async readCustom(e=null,t=!1,r=0){const i=await this._readData(r,"custom",e,t);if(!(i instanceof Blob))throw new Error("Failed to read custom data: expected Blob.");return i}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.#ir||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.#rr}isNavigatorClipboardAvailable(){return this.#ir}getCopyTextFunc(){return this.#nr}getCopyBlobFunc(){return this.#sr}};class ar{static _rca(e,t,r){let i=127,n=128;void 0===e&&(e=24),void 0===t&&(t="rgb"),!0===r&&(i=55,n=200);const s=2*Math.PI/e,o=[];for(let r=0;r<e;++r){const e=Math.sin(s*r+2)*i+n,a=Math.sin(s*r+0)*i+n,l=Math.sin(s*r+4)*i+n;switch(t){case"hex":o.push({hex:this.rgbToHex(Math.round(e),Math.round(a),Math.round(l))});break;case"rgb":o.push({r:e,g:a,b:l});break;case"hsl":const[t,r,i]=this.rgbaToHsl(Math.round(e),Math.round(a),Math.round(l));o.push({h:t,s:r,l:i})}}return o}static rcaRgb(e,t){return ar._rca(e,"rgb",t)}static rcaHsl(e,t){return ar._rca(e,"hsl",t)}static rcaHex(e,t){return ar._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,i,n]=e;if(t<=360&&r<=100&&i<=100)return this.hslToRgba(t,r,i,n)}return[...e,1].slice(0,4)}throw new Error("Unsupported color format.")}static hslToInt(e,t,r){const[i,n,s]=ar.hslToRgba(e,t,r);return ar.rgbToInt(i,n,s)}static hslToHex(e,t,r){const[i,n,s]=ar.hslToRgba(e,t,r);return ar.rgbToHex(i,n,s)}static hslStringToRgbaArray(e){const t=e.match(/[\d.]+/g)?.map(Number);if(!t||t.length<3)return[0,0,0,1];const[r,i,n,s=1]=t;return this.hslToRgba(r,i,n,s)}static hslToRgba(e,t,r,i=1){r/=100;const n=t=>(t+e/30)%12,s=(t/=100)*Math.min(r,1-r),o=e=>r-s*Math.max(-1,Math.min(n(e)-3,Math.min(9-n(e),1)));return[Math.round(255*o(0)),Math.round(255*o(8)),Math.round(255*o(4)),i]}static hslToRgb(e,t,r,i=1){return ar.hslToRgba(e,t,r,i).slice(0,3)}static hexToInt(e){return parseInt(e.replace(/^#/,""),16)}static hexToHsl(e){const[t,r,i,n]=ar.hexToRgba(e);return ar.rgbaToHsl(t,r,i,n)}static hexToHsla(e){const[t,r,i,n]=ar.hexToRgba(e);return ar.rgbaToHsla(t,r,i,n)}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,i=1){e/=255,t/=255,r/=255;const n=Math.max(e,t,r),s=Math.min(e,t,r);let o=0,a=0,l=(n+s)/2;const u=n-s;if(0!==u){switch(a=u/(1-Math.abs(2*l-1)),n){case e:o=(t-r)/u+(t<r?6:0);break;case t:o=(r-e)/u+2;break;case r:o=(e-t)/u+4}o*=60}return[Math.round(o),Math.round(100*a),Math.round(100*l),i]}static rgbaToHsl(e,t,r,i){return this.rgbaToHsla(e,t,r,i).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,i,n]=ar.intToRgba(e);return ar.rgbaToHsl(t,r,i,n)}static intToHsla(e){const[t,r,i,n]=ar.intToRgba(e);return ar.rgbaToHsla(t,r,i,n)}static intToHex(e){return"#"+e.toString(16).padStart(6,"0")}static intToRgba(e){return[e>>16&255,e>>8&255,255&e,1]}#or="#000000";#ar=[0,0,0,0];#lr;constructor(e=null,t=!1){this.#lr=t,null!=e&&this.setColor(e)}setColor(e){this.#or=e;const t=this.#lr&&Array.isArray(e)&&e[0]<=360&&e[1]<=100&&e[2]<=100;this.#ar=ar.parseInput(e,t)}toHslaArray(){const[e,t,r,i]=this.#ar;return ar.rgbaToHsla(e,t,r,i)}toHslString(){const[e,t,r]=this.#ar,[i,n,s]=ar.rgbaToHsl(e,t,r);return`hsl(${i}, ${n}%, ${s}%)`}toHslaString(){const[e,t,r,i]=this.#ar,[n,s,o,a]=ar.rgbaToHsla(e,t,r,i);return`hsla(${n}, ${s}%, ${o}%, ${a??1})`}toRgbaArray(){return[...this.#ar]}toRgbString(){const[e,t,r]=this.#ar;return`rgb(${e}, ${t}, ${r})`}toRgbaString(){const[e,t,r,i]=this.#ar;return`rgba(${e}, ${t}, ${r}, ${i??1})`}toHex(){const[e,t,r]=this.#ar;return ar.rgbToHex(e,t,r)}toInt(){const[e,t,r]=this.#ar;return ar.rgbToInt(e,t,r)}getOriginal(){return this.#or}}const lr=ar,ur=X("TinyTimeout");class hr{#ur=!1;#hr;#cr;#dr=null;#mr=new Map;constructor({cooldownWatcherTime:e=5e3,allowAutoConfigChange:t=!1}={}){if(!Number.isFinite(e)||e<=0)throw new TypeError("Expected 'cooldownWatcherTime' to be a positive number.");if("boolean"!=typeof t)throw new TypeError("Expected 'allowAutoConfigChange' to be a boolean.");this.#cr=e,this.#hr=t,this.setCooldownWatcherTime(e)}isDestroyed(){return this.#ur}getAllowAutoConfigChange(){return ur(this.#ur),this.#hr}getCooldownWatcherTime(){return ur(this.#ur),this.#cr}setAllowAutoConfigChange(e){if(ur(this.#ur),"boolean"!=typeof e)throw new TypeError("Expected 'value' to be a boolean.");this.#hr=e}setCooldownWatcherTime(e){if(ur(this.#ur),this.#ur)throw new Error("TinyTimeout has been destroyed.");if(!Number.isFinite(e)||e<=0)throw new TypeError("Expected 'value' to be a positive number.");this.#cr=e,this.#dr&&clearInterval(this.#dr),this.#dr=setInterval(()=>{this.#mr.forEach(e=>{e.now>0&&e.now--})},this.#cr)}set(e,t,r,i=null){if(ur(this.#ur),this.#ur)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!==i&&(!Number.isFinite(i)||i<0))throw new TypeError("Expected 'limit' to be null or a non-negative number.");let n=this.#mr.get(e);(!n||this.#hr&&r!==n.value)&&(n={value:r,now:0},this.#mr.set(e,n));const s=n.value*n.now;return n.now++,setTimeout(t,"number"==typeof i?Math.min(s,i):s)}static waitForTrue(e,t=100){if("function"!=typeof e)throw new TypeError("Expected 'getValue' to be a function.");if(!Number.isFinite(t)||t<=0)throw new TypeError("Expected 'checkInterval' to be a positive number.");return new Promise(r=>{const i=setInterval(()=>{e()&&(clearInterval(i),r())},t)})}waitForTrue(e,t=100){if(ur(this.#ur),this.#ur)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 hr.waitForTrue(e,t??this.#cr)}destroy(){this.#ur||(this.#dr&&clearInterval(this.#dr),this.#dr=null,this.#mr.clear(),this.#ur=!0)}}const cr=hr,dr=X("TinyLocalStorage"),mr=new Map,pr=new Map,fr=new Set(["string","boolean","object","array",String,Boolean,Number,Object,Array,BigInt,Symbol]);class yr extends tr.EventEmitter{static hasJsonType(e){return mr.has(e)&&pr.has(e)||fr.has(e)}static registerJsonType(e,t,r,i=!1){if(fr.has(e))throw new Error(`Cannot register type "${e}" because it is frozen.`);mr.set(e,t),pr.set(e,r),i&&fr.add(e)}static deleteJsonType(e){if(fr.has(e))throw new Error(`Cannot remove type "${e}" because it is frozen.`);let t=!1;return mr.delete(e)&&(t=!0),pr.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 mr.entries())if("string"!=typeof t&&e instanceof t||typeof e===t)return r(e,yr.encodeSpecialJson);if(Array.isArray(e))return e.map(yr.encodeSpecialJson);if(f(e)){const t={};for(const r in e)t[r]=yr.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(yr.decodeSpecialJson);if(t){for(const[t,r]of pr.entries())if(r.check&&r.check(e))return r.decode(e,yr.decodeSpecialJson);const t={};for(const r in e)t[r]=yr.decodeSpecialJson(e[r]);return t}return e}#h=!1;get destroyed(){return this.#h}#pr=window.localStorage;#fr=null;#ee=0;#yr=e=>this.emit("storage",e);constructor(e){if(super(),void 0!==e&&"string"!=typeof e)throw new TypeError("TinyLocalStorage: dbName must be a string if provided.");"string"==typeof e&&(this.#fr=`LSDB::${e}`),window.addEventListener("storage",this.#yr)}#gr(e){if("string"==typeof e&&e.startsWith("LSDB::"))throw new Error(`TinyLocalStorage: Key "${e}" may conflict with reserved dbKeys.`)}updateStorageVersion(e,t){if(dr(this.#h),"string"!=typeof this.#fr)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.#fr),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.#fr,String(e)),this.#ee=e)}getDbKey(){return dr(this.#h),this.#fr}getVersion(){return dr(this.#h),this.#ee}setLocalStorage(e){if(dr(this.#h),!(e instanceof Storage))throw new TypeError("Argument must be a valid instance of Storage.");this.#pr=e}localStorageExists(){return dr(this.#h),this.#pr instanceof Storage}#wr(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return yr.encodeSpecialJson(t)}setJson(e,t){if(dr(this.#h),this.#gr(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.#wr(e,t);return this.emit("setJson",e,t),this.#pr.setItem(e,JSON.stringify(r))}#br(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const r=this.#pr.getItem(e),i={obj:()=>({}),array:()=>[],map:()=>new Map,set:()=>new Set},n="function"==typeof i[t]?i[t]():null;let s;try{s=JSON.parse(r)}catch{return n}return{decoded:yr.decodeSpecialJson(s),fallback:n}}getJson(e,t){dr(this.#h);const{decoded:r,fallback:i}=this.#br(e,t);return r instanceof Map||r instanceof Set||Array.isArray(r)||f(r)?r:i}setDate(e,t){if(dr(this.#h),this.#gr(e),!(t instanceof Date))throw new TypeError("Value must be a Date.");const r=this.#wr(e,t);return this.emit("setDate",e,t),this.#pr.setItem(e,JSON.stringify(r))}getDate(e){dr(this.#h);const t=this.#br(e).decoded;return t instanceof Date?t:null}setRegExp(e,t){if(dr(this.#h),this.#gr(e),!(t instanceof RegExp))throw new TypeError("Value must be a RegExp.");const r=this.#wr(e,t);return this.emit("setRegExp",e,t),this.#pr.setItem(e,JSON.stringify(r))}getRegExp(e){dr(this.#h);const t=this.#br(e).decoded;return t instanceof RegExp?t:null}setBigInt(e,t){if(dr(this.#h),this.#gr(e),"bigint"!=typeof t)throw new TypeError("Value must be a BigInt.");const r=this.#wr(e,t);return this.emit("setBigInt",e,t),this.#pr.setItem(e,JSON.stringify(r))}getBigInt(e){dr(this.#h);const t=this.#br(e).decoded;return"bigint"==typeof t?t:null}setSymbol(e,t){if(dr(this.#h),this.#gr(e),"symbol"!=typeof t)throw new TypeError("Value must be a Symbol.");const r=this.#wr(e,t);return this.emit("setSymbol",e,t),this.#pr.setItem(e,JSON.stringify(r))}getSymbol(e){dr(this.#h);const t=this.#br(e).decoded;return"symbol"==typeof t?t:null}getValue(e){return dr(this.#h),this.#br(e).decoded??null}setItem(e,t){if(dr(this.#h),this.#gr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("setItem",e,t),this.#pr.setItem(e,t)}getItem(e){if(dr(this.#h),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.#pr.getItem(e)}setString(e,t){if(dr(this.#h),this.#gr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("string"!=typeof t)throw new TypeError("Value must be a string.");return this.emit("setString",e,t),this.#pr.setItem(e,JSON.stringify({__string__:!0,value:t}))}getString(e){if(dr(this.#h),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#pr.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(dr(this.#h),this.#gr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("number"!=typeof t)throw new TypeError("Value must be a number.");return this.emit("setNumber",e,t),this.#pr.setItem(e,String(t))}getNumber(e){if(dr(this.#h),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#pr.getItem(e);return"number"==typeof t||"string"==typeof t&&t.length>0&&(t=parseFloat(t),!Number.isNaN(t))?t:null}setBool(e,t){if(dr(this.#h),this.#gr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("boolean"!=typeof t)throw new TypeError("Value must be a boolean.");return this.emit("setBool",e,t),this.#pr.setItem(e,String(t))}getBool(e){if(dr(this.#h),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const t=this.#pr.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(dr(this.#h),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("removeItem",e),this.#pr.removeItem(e)}clearLocalStorage(){return dr(this.#h),this.#pr.clear()}destroy(){this.#h||(window.removeEventListener("storage",this.#yr),this.removeAllListeners(),this.#h=!0)}}yr.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),yr.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),yr.registerJsonType(Date,e=>({__date__:!0,value:e.toISOString()}),{check:e=>e.__date__,decode:e=>new Date(e.value)},!0),yr.registerJsonType(RegExp,e=>({__regexp__:!0,source:e.source,flags:e.flags}),{check:e=>e.__regexp__,decode:e=>new RegExp(e.source,e.flags)},!0),yr.registerJsonType("number",e=>({__number__:!0,value:e.toString()}),{check:e=>e.__number__,decode:e=>Number(e.value)},!0),yr.registerJsonType("bigint",e=>({__bigint__:!0,value:e.toString()}),{check:e=>e.__bigint__,decode:e=>BigInt(e.value)},!0),yr.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 gr=yr,wr=X("TinyIframeEvents"),br=new WeakMap;class vr extends tr.EventEmitter{#vr;get targetWindow(){return wr(this.#ur),this.#vr}#Er;get targetIframeElement(){return wr(this.#ur),this.#Er}#Tr;get targetOrigin(){return wr(this.#ur),this.#Tr}#Sr;get selfType(){return wr(this.#ur),this.#Sr}#ur=!1;#xr=!1;get ready(){return wr(this.#ur),this.#xr}onReady(e){wr(this.#ur),this.#xr?e():this.once(this.#Ar,e)}#Cr=null;#Ir=[];#Dr;#Mr;#Ar;#Nr=null;constructor({targetIframe:e,targetOrigin:t=window.location.origin,secretEventName:r="__tinyIframeEvent__",handshakeEventName:i="__tinyIframeHandshake__",readyEventName:n="__tinyIframeReady__"}={}){if(super(),!(void 0===e||e instanceof HTMLIFrameElement&&e.contentWindow))throw new TypeError('[TinyIframeEvents] Invalid "targetIframe": expected HTMLIFrameElement, received '+typeof e);if("string"!=typeof t)throw new TypeError('[TinyIframeEvents] Invalid "targetOrigin": expected string, received '+typeof t);if(this.#Er=e,this.#vr=e?.contentWindow??window.parent,this.#Tr=t,this.#Sr=e?"parent":"iframe",this.#Dr=r,this.#Mr=i,this.#Ar=n,br.has(this.#vr))throw new Error("Duplicate window reference.");this._boundWindowMessage=this.#kr.bind(this),this._boundPortMessage=this.#Lr.bind(this),this.#_r(),br.set(this.#vr,this)}get secretEventName(){return wr(this.#ur),this.#Dr}set secretEventName(e){if(wr(this.#ur),"string"!=typeof e)throw new TypeError("TinyIframeEvents: secretEventName must be a string.");this.#Dr=e}get handshakeEventName(){return wr(this.#ur),this.#Mr}set handshakeEventName(e){if(wr(this.#ur),"string"!=typeof e)throw new TypeError("TinyIframeEvents: handshakeEventName must be a string.");this.#Mr=e}get readyEventName(){return wr(this.#ur),this.#Ar}set readyEventName(e){if(wr(this.#ur),"string"!=typeof e)throw new TypeError("TinyIframeEvents: readyEventName must be a string.");this.#Ar=e}#_r(){"parent"===this.#Sr?(this.#Nr=()=>{if(this.#ur)return;this.#Cr&&this.#Cr.close();const e=new MessageChannel;this.#Cr=e.port1,this.#Cr.onmessage=this._boundPortMessage,this.#xr=!1,this.#vr.postMessage({type:this.#Mr},this.#Tr,[e.port2])},this.#Er&&(this.#Er.addEventListener("load",this.#Nr),this.#Nr())):window.addEventListener("message",this._boundWindowMessage,!1)}#kr(e){const t=e.data,r=e.ports;f(t)&&t.type===this.#Mr&&0!==r.length&&(this.#Cr=r[0],this.#Cr.onmessage=this._boundPortMessage,window.removeEventListener("message",this._boundWindowMessage),this.#Cr.postMessage({type:`${this.#Mr}_ACK`}),this.#jr())}#Lr(e){const t=e.data;if(f(t)&&t.type===`${this.#Mr}_ACK`)return void this.#jr();if(!f(t)||!t[this.#Dr])return;const r=t.eventName,i=t.payload,n=t.direction;"string"!=typeof r||"iframe"===this.#Sr&&"iframe"!==n||"parent"===this.#Sr&&"parent"!==n||this.emit(`win:${r}`,i,e)}#jr(){this.#xr||(this.#xr=!0,this.#Rr(),this.emit(this.#Ar))}#Rr(){for(;this.#Ir.length>0;){const e=this.#Ir.shift();e&&this.#Cr&&this.#Cr.postMessage(e)}}winEmit(e,t){if(wr(this.#ur),"string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.#ur)throw new Error("Cannot emit: instance has been destroyed.");const r={[this.#Dr]:!0,eventName:e,payload:t,direction:"parent"===this.#Sr?"iframe":"parent"};this.#xr&&this.#Cr?this.#Cr.postMessage(r):this.#Ir.push(r)}isDestroyed(){return this.#ur}destroy(){this.#ur||(this.#xr=!1,window.removeEventListener("message",this._boundWindowMessage),this.#Er&&this.#Nr&&this.#Er.removeEventListener("load",this.#Nr),this.#Cr&&(this.#Cr.close(),this.#Cr=null),this.removeAllListeners(),this.#Ir=[],br.delete(this.#vr),this.#ur=!0)}}const Er=vr,Tr=X("TinyNewWinEvents"),Sr=new WeakMap;class xr extends tr.EventEmitter{#Pr;#Tr;#Ir=[];#xr=!1;#$r=!1;#Hr=null;#Ar="__TNE_READY__";#Or="__TNE_ROUTE__";#h=!1;get destroyed(){return this.#h}get readyEventName(){return Tr(this.#h),this.#Ar}set readyEventName(e){if(Tr(this.#h),"string"!=typeof e)throw new TypeError("TinyNewWinEvents: readyEventName must be a string.");this.#Ar=e}get routeEventName(){return Tr(this.#h),this.#Or}set routeEventName(e){if(Tr(this.#h),"string"!=typeof e)throw new TypeError("TinyNewWinEvents: routeEventName must be a string.");this.#Or=e}constructor({targetOrigin:e,url:t,name:r,features:i}={}){if(super(),"string"==typeof r&&"_blank"===r)throw new Error('TinyNewWinEvents: The window name "_blank" is not supported. Please use a custom name to allow tracking.');if(void 0!==e&&"string"!=typeof e)throw new TypeError('TinyNewWinEvents: The "targetOrigin" option must be a string.');if(void 0!==t&&"string"!=typeof t)throw new TypeError('TinyNewWinEvents: The "url" option must be a string.');if(void 0!==i&&"string"!=typeof i)throw new TypeError('TinyNewWinEvents: The "features" option must be a string if provided.');if(void 0===t?this.#Pr=window.opener:(this.#Pr="string"==typeof t?window.open(t,r,i):t,this.#$r=!0),!this.#Pr||Sr.has(this.#Pr))throw new Error("Invalid or duplicate window reference.");this.#Tr=e??window.location.origin,this._handleMessage=this.#Fr.bind(this),window.addEventListener("message",this._handleMessage,!1),this.#$r||(this.#Br(this.#Ar,null),this.#zr())}getWin(){return Tr(this.#h),this.#Pr}#Fr(e){if(!e.source||this.#Pr&&e.source!==this.#Pr)return;const{type:t,route:r,payload:i}=e.data||{};if(t===this.#Ar)return this.#xr=!0,this.#Rr(),this.#zr(),void(this.#$r&&this.#Br(this.#Ar,null));t===this.#Or&&this.emit(`win:${r}`,i,e)}#Rr(){for(;this.#Ir.length;){const e=this.#Ir.shift();if(e){const{route:t,payload:r}=e;this.winEmit(t,r)}}}#Br(e,t,r=""){this.#Pr&&this.#Pr.closed||this.#Pr?.postMessage({type:e,route:r,payload:t},this.#Tr)}close(){if(Tr(this.#h),!this.#$r)throw new Error("Only host can close the window.");this.#Pr&&!this.#Pr.closed&&this.#Pr.close()}winEmit(e,t){if(Tr(this.#h),"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.#xr?this.#Br(this.#Or,t,e):this.#Ir.push({route:e,payload:t})}isConnected(){return Tr(this.#h),!(!this.#xr||!this.#Pr||this.#Pr.closed)}#zr(){this.#Pr&&!this.#Hr&&(this.#Hr=setInterval(()=>{this.#Pr?.closed&&(this.emit("WINDOW_REF_CLOSED"),this.destroy())},500),Sr.set(this.#Pr,this.#Hr))}onClose(e){Tr(this.#h),this.on("WINDOW_REF_CLOSED",e)}offClose(e){Tr(this.#h),this.off("WINDOW_REF_CLOSED",e)}isDestroyed(){return!this.#Pr}destroy(){this.#Pr&&(this.#Hr&&(clearInterval(this.#Hr),this.#Hr=null,Sr.delete(this.#Pr)),window.removeEventListener("message",this._handleMessage),this.#Ir=[],this.#xr=!1,this.#Pr=null,this.removeAllListeners(),this.#h=!0)}}const Ar=xr,Cr=class{#h=!1;get destroyed(){return this.#h}#Wr;#qr;#Vr;#Kr=0;#Jr=0;#Ur;#Gr=null;#Yr=null;get lineHeight(){return this.#Wr}get maxRows(){return this.#qr-1}get extraHeight(){return this.#Vr}get currentHeight(){return this.#Kr}get currentRows(){return this.#Jr}get textarea(){return this.#Ur}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.#Ur=e,this.#qr=(t.maxRows??5)+1,this.#Vr=t.extraHeight??0,this.#Gr=t.onResize??null,this.#Yr=t.onInput??null,this.#Wr=this.#Xr(),e.style.overflowY="hidden",e.style.resize="none",this._handleInput=()=>this.#Qr(),e.addEventListener("input",this._handleInput),this.#Qr()}#Qr(){this.#Ur.style.height="auto";const e=window.getComputedStyle(this.#Ur),t=parseFloat(e.paddingTop)||0,r=parseFloat(e.paddingBottom)||0,i=(this.#Ur.value.match(/\n/g)||[]).length,n=this.#Ur.scrollHeight,s=this.#Wr*this.#qr,o=Math.ceil(Math.min(n,s)-t-r+this.#Vr),a=this.#qr-1,l=i<a?i+1:a;this.#Ur.style.height=`${o}px`,this.#Ur.style.overflowY=n>s?"auto":"hidden",this.#Kr=o;const u={breakLines:i,rows:l,height:o,scrollHeight:n,maxHeight:s,lineHeight:this.#Wr,maxRows:a};l!==this.#Jr&&(this.#Jr=l,"function"==typeof this.#Gr&&this.#Gr({...u})),"function"==typeof this.#Yr&&this.#Yr(u)}#Xr(){const e=window.getComputedStyle(this.#Ur),t=parseFloat(e.lineHeight);return Number.isNaN(t)?1.2*parseFloat(e.fontSize):t}getData(){return{rows:this.#Jr,height:this.#Kr}}refresh(){this.#Qr()}destroy(){this.destroyed||(this.#Ur.removeEventListener("input",this._handleInput),this.#h=!0)}},Ir=X("TinyGamepad");class Dr{#ur=!1;#Zr=new Set;#ei=new Map;#ti=new Map;#ri=null;#ii=[];#ni={};#si=[];#oi=null;#ai=null;#li;#ui;#hi;#ci;#di;#mi;#pi;#fi;#yi=[];#gi=0;#wi=0;#bi=[];#vi=0;#Ei=null;#Ti=new Set;#Si=new Set;#xi=new Map;#Ai=new Map;#Ci=new Map;static#Ii={" ":"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);Dr.#Ii[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 Dr.#Ii[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 Dr.#Ii[e]}static getAllSpecialKeys(){return{...Dr.#Ii}}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=Dr.#Ii[e];if(void 0!==r)return r;throw new Error(`Unsupported character: "${e}"`)})}constructor({expectedId:e=null,inputMode:t="both",ignoreIds:r=[],deadZone:i=.1,axisActiveSensitivity:n=.3,timeoutComboKeys:s=500,allowMouse:o=!1,elementBase:a=window}={}){if(null!==e&&"string"!=typeof e)throw new TypeError('"expectedId" must be a string or null, received: '+typeof e);if(!["keyboard-only","gamepad-only","both"].includes(t))throw new TypeError(`"inputMode" must be 'keyboard-only', 'gamepad-only', or 'both', received: ${t}`);if(!Array.isArray(r)||!r.every(e=>"string"==typeof e))throw new TypeError('"ignoreIds" must be an array of strings');if("number"!=typeof i||i<0||i>1)throw new RangeError(`"deadZone" must be a number between 0 and 1, received: ${i}`);if("number"!=typeof n||n<0||n>1)throw new RangeError(`"axisActiveSensitivity" must be a number between 0 and 1, received: ${n}`);if("number"!=typeof s||s<0)throw new RangeError(`"timeoutComboKeys" must be a positive number, received: ${s}`);if("boolean"!=typeof o)throw new TypeError('"allowMouse" must be a boolean, received: '+typeof o);if(!(a instanceof Window||a instanceof Element))throw new TypeError('"elementBase" must be a Window or Element instance');this.#ci=e,this.#li=t,this.#ui=new Set(r),this.#hi=i,this.#di=o,this.#mi=a,this.#pi=s,this.#fi=n,["gamepad-only","both"].includes(this.#li)&&this.#Di(),["keyboard-only","both"].includes(this.#li)&&this.#Mi()}#Ni=e=>this.#ki(e.gamepad);#Li=e=>this.#_i(e.gamepad);#Di(){window.addEventListener("gamepadconnected",this.#Ni),window.addEventListener("gamepaddisconnected",this.#Li)}#ki(e){this.#ur||this.#ui.has(e.id)||this.#ci&&e.id!==this.#ci||this.#ri||(this.#ri=e,this.#ci=e.id,this.#ji(),this.#Ri("connected",{id:e.id,gp:e,timestamp:e.timestamp}))}#_i(e){this.#ur||this.#ri&&e.id===this.#ri.id&&(this.#ri=null,this.#oi&&(cancelAnimationFrame(this.#oi),this.#oi=null),this.#Ri("disconnected",{id:e.id,gp:e,timestamp:e.timestamp}))}#ji(){const e=()=>{this.#ur||(this.#Pi(),this.#oi=requestAnimationFrame(e))};e()}#Pi(){if(this.#ur)return;const e=navigator.getGamepads(),t=Array.from(e).find(e=>e&&e.id===this.#ci);t&&(this.#ri=t,t.buttons.forEach((e,r)=>{const i=`Button${r}`,n=this.#ii[r]?.pressed||!1;let s,o,a=!1;e.pressed&&!n?(o=1,s="down"):!e.pressed&&n?(o=0,s="up"):e.pressed&&n&&(o=1,s="hold"),e.pressed&&e.value>0&&e.value<1&&1!==e.value&&(o=e.value,a=!0),"number"==typeof o&&"string"==typeof s&&this.#$i({key:i,source:"gamepad-button",value:o,value2:NaN,type:s,gp:t,isPressure:a,pressed:e.pressed,prevPressed:n,timestamp:t.timestamp,id:t.id}),this.#ii[r]={pressed:e.pressed,value:"number"==typeof o?o:this.#ii[r]?.value,value2:NaN}}),t.axes.forEach((e,r)=>{Math.abs(e)<this.#hi&&(e=0);const i=`Axis${r}`;e!==(this.#si[r]??0)&&this.#$i({key:i,source:"gamepad-analog",value:e,value2:NaN,type:"change",timestamp:t.timestamp,id:t.id,gp:t}),this.#si[r]=e}))}#Hi=e=>{if(!this.#ur){if(!(e instanceof KeyboardEvent))throw new Error("Expected KeyboardEvent in keydown listener.");this.#Zr.has(e.code)||(this.#Zr.add(e.code),this.#$i({event:e,key:e.code,source:"keyboard",value:1,value2:NaN,type:"down",pressed:!0,prevPressed:this.#ni[e.code]?.pressed??!1,id:"native_keyboard",timestamp:e.timeStamp}),this.#ni[e.code]={pressed:!0})}};#Oi=e=>{if(!this.#ur){if(!(e instanceof KeyboardEvent))throw new Error("Expected KeyboardEvent in keyup listener.");this.#Zr.has(e.code)&&(this.#Zr.delete(e.code),this.#$i({event:e,key:e.code,source:"keyboard",value:0,value2:NaN,type:"up",pressed:!1,prevPressed:this.#ni[e.code]?.pressed??!1,id:"native_keyboard",timestamp:e.timeStamp}),this.#ni[e.code]={pressed:!1})}};#Fi=e=>{if(this.#ur)return;if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mousedown listener.");const t=`Mouse${e.button}`;this.#Zr.add(t),this.#$i({event:e,key:t,source:"mouse",value:1,value2:NaN,type:"down",pressed:!0,prevPressed:this.#ni[t]?.pressed??!1,id:"native_mouse",timestamp:e.timeStamp}),this.#ni[t]={pressed:!0}};#Bi=e=>{if(this.#ur)return;if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mouseup listener.");const t=`Mouse${e.button}`;this.#Zr.delete(t),this.#$i({event:e,key:t,source:"mouse",value:0,value2:NaN,type:"up",pressed:!1,prevPressed:this.#ni[t]?.pressed??!1,id:"native_mouse",timestamp:e.timeStamp}),this.#ni[t]={pressed:!1}};#zi=e=>{if(!this.#ur){if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mousemove listener.");if(0!==e.movementX||0!==e.movementY){const t="MouseMove",r=this.#ni[t]??{pressed:!1,value:0,value2:0};this.#$i({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.#ni[t]={pressed:!1,value:e.movementX,value2:e.movementY}}}};#Mi(){this.#mi.addEventListener("keydown",this.#Hi),this.#mi.addEventListener("keyup",this.#Oi),this.#di&&(this.#mi.addEventListener("mousedown",this.#Fi),this.#mi.addEventListener("mouseup",this.#Bi),this.#mi.addEventListener("mousemove",this.#zi));const e=()=>{this.#ur||(this.#Zr.forEach(e=>{const t=e.startsWith("Mouse")?"mouse":"keyboard";this.#$i({key:e,source:t,id:`native_${t}`,value:1,value2:NaN,type:"hold",pressed:!0,prevPressed:this.#ni[e]?.pressed??!1,timestamp:NaN})}),this.#ai=requestAnimationFrame(e))};e()}#$i(e){if(this.#ur)return;const t=this.#ti.get("input-*")||[],{pressed:r,key:i}=e,n=i.startsWith("Axis"),s="boolean"==typeof r&&r||n&&(e.value>this.#fi||e.value<-Math.abs(this.#fi)),o=n?`${i}${e.value>0?"+":e.value<0?"-":""}`:i;let a=null;if("move"!==e.type&&"hold"!==e.type){if(s){if(!n&&!this.#Ti.has(i)||n&&!this.#Ti.has(i)&&!this.#Ti.has(`${i}+`)&&!this.#Ti.has(`${i}-`)){0===this.#vi&&(this.#vi=Date.now()),this.#Ti.add(o),a=!0,this.#bi.push(o),this.#yi.length<1&&(this.#Ei&&clearTimeout(this.#Ei),this.#Ei=setTimeout(()=>this.resetComboMapped(),this.#pi));const e=this.#ti.get("mapped-key-start")??[];for(const t of e)t({key:o,activeTime:this.#vi})}}else if(!n&&this.#Ti.has(i)||n&&(this.#Ti.has(i)||this.#Ti.has(`${i}+`)||this.#Ti.has(`${i}-`))){this.#Ti.delete(i),this.#Ti.delete(`${i}+`),this.#Ti.delete(`${i}-`),a=!1;const e=this.#ti.get("mapped-key-end")??[];for(const t of e)t({key:o,activeTime:this.#vi})}for(const{sequence:e,callback:t,triggered:r}of this.#Ai.values()){const i=this.#Ai.get(e.join("+"));if(!i)continue;const n=e.every((e,t)=>this.#bi[t]===e);n&&!r?(i.triggered=!0,t(this.#vi)):!n&&r&&(i.triggered=!1)}}for(const[r,l]of this.#ei.entries()){const u=e=>"string"==typeof l&&e===l||Array.isArray(l)&&l.findIndex((t,r)=>e===l[r])>-1,h=u(o),c=n&&u(`${i}+`),d=n&&u(`${i}-`);if(h||c||d){if(s&&h){if(a||!this.#Si.has(r)){0===this.#wi&&(this.#wi=Date.now()),this.#Si.add(r),0===this.#gi&&(this.#gi=Date.now()),this.#Ei&&clearTimeout(this.#Ei),this.#yi.push(r),this.#Ei=setTimeout(()=>this.resetComboMapped(),this.#pi);const e=this.#ti.get("mapped-input-start")??[];for(const t of e)t({logicalName:r,activeTime:this.#wi,comboTime:this.#gi})}}else if(!a||this.#Si.has(r)){this.#Si.delete(r),this.#Si.size<1&&(this.#wi=0);const e=this.#ti.get("mapped-input-end")??[];for(const t of e)t({logicalName:r,activeTime:this.#wi,comboTime:this.#gi})}for(const{sequence:e,callback:t,triggered:r}of this.#xi.values()){const i=this.#xi.get(e.join("+"));if(!i)continue;const n=Array.from(this.#Si),s=e.every((e,t)=>n[t]===e);s&&!r?(i.triggered=!0,t(this.#wi)):!s&&r&&(i.triggered=!1)}}const m=[];if(n&&0===e.value){const{value:t}=this.#Ci.get(`${i}-`)??{value:0,value2:NaN},{value:r}=this.#Ci.get(`${i}+`)??{value:0,value2:NaN};e.value!==t&&m.push(`${i}-`),e.value!==r&&m.push(`${i}+`)}else m.push(o);m.forEach(i=>{if(!("*"===l||l===i||Array.isArray(l)&&l.includes(i)))return;const n=this.#ti.get(`input-${e.type}-${r}`)||[],s=this.#ti.get(`input-${r}`)||[];if(s.length<1&&n.length<1&&t.length<1)return;const o={...e,key:i,logicalName:r};for(const e of t)e(o);for(const e of s)e(o);for(const e of n)e(o);this.#Ci.set(i,{value:e.value,value2:e.value2})})}}#Ri(e,t){const r=this.#ti.get(e)||[];for(const e of r)e(t)}#Wi(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 i=r.replace("{logicalName}",e);let n=this.#ti.get(i);Array.isArray(n)||(n=[],this.#ti.set(i,n)),n.push(t)}#qi(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 i=n=>{this.#Vi(e,i,r),t(n)};this.#Wi(e,i,r)}#Ki(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 i=r.replace("{logicalName}",e),n=this.#ti.get(i)??[];n.unshift(t),this.#ti.set(i,n)}#Vi(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 i=r.replace("{logicalName}",e),n=this.#ti.get(i);Array.isArray(n)&&this.#ti.set(i,n.filter(e=>e!==t))}awaitInputMapping({timeout:e=1e4,eventName:t="MappingInput",canMove:r=!1}={}){return Ir(this.#ur),new Promise((i,n)=>{if("number"!=typeof e||Number.isNaN(e)||e<0)return n(new TypeError(`Invalid "timeout": expected a positive number, got ${e}`));if("string"!=typeof t||!t.trim())return n(new TypeError(`Invalid "eventName": expected a non-empty string, got ${t}`));if("boolean"!=typeof r)return n(new TypeError(`Invalid "canMove": expected a boolean, got ${r}`));const s={key:null,source:null},o=({key:e,type:n,source:l,gp:u,value:h})=>{(r||"move"!==n)&&(s.key=e,s.source=l,s.gp=u,clearTimeout(a),this.offInputStart(t,o),this.offInputChange(t,o),r&&this.offInputMove(t,o),i(s))},a=setTimeout(()=>i(s),e);this.mapInput(t,"*"),this.onInputStart(t,o),this.onInputChange(t,o),r&&this.onInputMove(t,o)})}mapInput(e,t){if(Ir(this.#ur),"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.#ei.set(e,t)}unmapInput(e){if(Ir(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);this.#ei.delete(e)}hasMappedInput(e){if(Ir(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);return this.#ei.has(e)}getMappedInput(e){if(Ir(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);const t=this.#ei.get(e);if(!t)throw new Error(`No physical input mapped for logicalName: "${e}"`);return t}clearMapInputs(){Ir(this.#ur),this.#ei.clear()}registerInputSequence(e,t){if(Ir(this.#ur),!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.#xi.set(r,{sequence:e,callback:t,triggered:!1})}unregisterInputSequence(e){if(Ir(this.#ur),!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.#xi.delete(t)}unregisterAllInputSequences(){Ir(this.#ur),this.#xi.clear()}hasInputSequence(e){if(Ir(this.#ur),!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.#xi.has(t)}registerKeySequence(e,t){if(Ir(this.#ur),!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.#Ai.set(r,{sequence:e,callback:t,triggered:!1})}unregisterKeySequence(e){if(Ir(this.#ur),!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.#Ai.delete(t)}unregisterAllKeySequences(){Ir(this.#ur),this.#Ai.clear()}hasKeySequence(e){if(Ir(this.#ur),!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.#Ai.has(t)}renewComboMapped(){Ir(this.#ur),this.#Ei&&(clearTimeout(this.#Ei),this.#Ei=setTimeout(()=>this.resetComboMapped(),this.#pi))}resetComboMapped(){Ir(this.#ur),this.#Ei&&clearTimeout(this.#Ei),this.#bi=[],this.#Ei=null,this.#vi=0,this.#yi=[],this.#gi=0}onMappedKeyStart(e){return Ir(this.#ur),this.#Wi("",e,"mapped-key-start")}onceMappedKeyStart(e){return Ir(this.#ur),this.#qi("",e,"mapped-key-start")}prependMappedKeyStart(e){return Ir(this.#ur),this.#Ki("",e,"mapped-key-start")}offMappedKeyStart(e){return Ir(this.#ur),this.#Vi("",e,"mapped-key-start")}offAllMappedKeyStart(){Ir(this.#ur),this.#ti.delete("mapped-key-start")}onMappedKeyEnd(e){return Ir(this.#ur),this.#Wi("",e,"mapped-key-end")}onceMappedKeyEnd(e){return Ir(this.#ur),this.#qi("",e,"mapped-key-end")}prependMappedKeyEnd(e){return Ir(this.#ur),this.#Ki("",e,"mapped-key-end")}offMappedKeyEnd(e){return Ir(this.#ur),this.#Vi("",e,"mapped-key-end")}offAllMappedKeyEnd(){Ir(this.#ur),this.#ti.delete("mapped-key-end")}onMappedInputStart(e){return Ir(this.#ur),this.#Wi("",e,"mapped-input-start")}onceMappedInputStart(e){return Ir(this.#ur),this.#qi("",e,"mapped-input-start")}prependMappedInputStart(e){return Ir(this.#ur),this.#Ki("",e,"mapped-input-start")}offMappedInputStart(e){return Ir(this.#ur),this.#Vi("",e,"mapped-input-start")}offAllMappedInputStart(){Ir(this.#ur),this.#ti.delete("mapped-input-start")}onMappedInputEnd(e){return Ir(this.#ur),this.#Wi("",e,"mapped-input-end")}onceMappedInputEnd(e){return Ir(this.#ur),this.#qi("",e,"mapped-input-end")}prependMappedInputEnd(e){return Ir(this.#ur),this.#Ki("",e,"mapped-input-end")}offMappedInputEnd(e){return Ir(this.#ur),this.#Vi("",e,"mapped-input-end")}offAllMappedInputEnd(){Ir(this.#ur),this.#ti.delete("mapped-input-end")}onInput(e,t){return Ir(this.#ur),this.#Wi(e,t,"input-{logicalName}")}onceInput(e,t){return Ir(this.#ur),this.#qi(e,t,"input-{logicalName}")}prependInput(e,t){return Ir(this.#ur),this.#Ki(e,t,"input-{logicalName}")}offInput(e,t){return Ir(this.#ur),this.#Vi(e,t,"input-{logicalName}")}onInputStart(e,t){return Ir(this.#ur),this.#Wi(e,t,"input-down-{logicalName}")}onceInputStart(e,t){return Ir(this.#ur),this.#qi(e,t,"input-down-{logicalName}")}prependInputStart(e,t){return Ir(this.#ur),this.#Ki(e,t,"input-down-{logicalName}")}offInputStart(e,t){return Ir(this.#ur),this.#Vi(e,t,"input-down-{logicalName}")}onInputEnd(e,t){return Ir(this.#ur),this.#Wi(e,t,"input-up-{logicalName}")}onceInputEnd(e,t){return Ir(this.#ur),this.#qi(e,t,"input-up-{logicalName}")}prependInputEnd(e,t){return Ir(this.#ur),this.#Ki(e,t,"input-up-{logicalName}")}offInputEnd(e,t){return Ir(this.#ur),this.#Vi(e,t,"input-up-{logicalName}")}onInputHold(e,t){return Ir(this.#ur),this.#Wi(e,t,"input-hold-{logicalName}")}onceInputHold(e,t){return Ir(this.#ur),this.#qi(e,t,"input-hold-{logicalName}")}prependInputHold(e,t){return Ir(this.#ur),this.#Ki(e,t,"input-hold-{logicalName}")}offInputHold(e,t){return Ir(this.#ur),this.#Vi(e,t,"input-hold-{logicalName}")}onInputChange(e,t){return Ir(this.#ur),this.#Wi(e,t,"input-change-{logicalName}")}onceInputChange(e,t){return Ir(this.#ur),this.#qi(e,t,"input-change-{logicalName}")}prependInputChange(e,t){return Ir(this.#ur),this.#Ki(e,t,"input-change-{logicalName}")}offInputChange(e,t){return Ir(this.#ur),this.#Vi(e,t,"input-change-{logicalName}")}onInputMove(e,t){return Ir(this.#ur),this.#Wi(e,t,"input-move-{logicalName}")}onceInputMove(e,t){return Ir(this.#ur),this.#qi(e,t,"input-move-{logicalName}")}prependInputMove(e,t){return Ir(this.#ur),this.#Ki(e,t,"input-move-{logicalName}")}offInputMove(e,t){return Ir(this.#ur),this.#Vi(e,t,"input-move-{logicalName}")}getCalls(e,t="all"){if(Ir(this.#ur),"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 i=`${{all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t]}${e}`,n=this.#ti.get(i);return Array.isArray(n)?[...n]:[]}offAllInputs(e,t="all"){if(Ir(this.#ur),"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 i={all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t];i&&this.#ti.delete(`${i}${e}`)}getCallSize(e,t="all"){if(Ir(this.#ur),"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 i={all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t],n=this.#ti.get(`${i}${e}`);return Array.isArray(n)?n.length:0}#Ji={type:"dual-rumble",params:{startDelay:0,duration:200,weakMagnitude:.5,strongMagnitude:1}};get defaultHapticEffect(){return Ir(this.#ur),{type:this.#Ji.type,params:{...this.#Ji.params}}}setDefaultHapticEffect(e,t){if(Ir(this.#ur),"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.#Ji.type=e,this.#Ji.params=t}hasHapticEffect(){Ir(this.#ur);const e=this.#ri;return!!e&&e.vibrationActuator instanceof GamepadHapticActuator}vibrate(e,t){if(Ir(this.#ur),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.#ri;if(!r)return new Promise(e=>e("complete"));const i=r.vibrationActuator;return i instanceof GamepadHapticActuator?i.playEffect(t??this.#Ji.type,{...this.#Ji.params,...e}):new Promise(e=>e("complete"))}ignoreId(e){if(Ir(this.#ur),"string"!=typeof e||""===e.trim())throw new TypeError(`"id" must be a non-empty string, received ${e}`);this.#ui.add(e)}unignoreId(e){if(Ir(this.#ur),"string"!=typeof e||""===e.trim())throw new TypeError(`"id" must be a non-empty string, received ${e}`);this.#ui.delete(e)}onConnected(e){return Ir(this.#ur),this.#Wi("",e,"connected")}onceConnected(e){return Ir(this.#ur),this.#qi("",e,"connected")}prependConnected(e){return Ir(this.#ur),this.#Ki("",e,"connected")}offConnected(e){return Ir(this.#ur),this.#Vi("",e,"connected")}offAllConnected(){Ir(this.#ur),this.#ti.delete("connected")}onDisconnected(e){return Ir(this.#ur),this.#Wi("",e,"disconnected")}onceDisconnected(e){return Ir(this.#ur),this.#qi("",e,"disconnected")}prependDisconnected(e){return Ir(this.#ur),this.#Ki("",e,"disconnected")}offDisconnected(e){return Ir(this.#ur),this.#Vi("",e,"disconnected")}offAllDisconnected(){Ir(this.#ur),this.#ti.delete("disconnected")}hasGamepad(){return Ir(this.#ur),this.#ri instanceof Gamepad}getGamepad(){if(Ir(this.#ur),!this.#ri)throw new Error("No gamepad is currently connected.");return this.#ri}hasLastButtonState(e){return Ir(this.#ur),!!this.#ii[e]}getLastButtonState(e){if(Ir(this.#ur),!this.#ii[e])throw new Error(`No last button state found for index ${e}`);return{...this.#ii[e]}}exportConfig(){return Ir(this.#ur),{expectedId:this.#ci,ignoreIds:Array.from(this.#ui),deadZone:this.#hi,timeoutComboKeys:this.#pi,axisActiveSensitivity:this.#fi,inputMap:Array.from(this.#ei.entries())}}importConfig(e){if(Ir(this.#ur),"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.#ci=t.expectedId),Array.isArray(t.ignoreIds)&&(this.#ui=new Set(t.ignoreIds)),"number"==typeof t.deadZone&&(this.#hi=t.deadZone),"number"==typeof t.timeoutComboKeys&&(this.#pi=t.timeoutComboKeys),"number"==typeof t.axisActiveSensitivity&&(this.#fi=t.axisActiveSensitivity),Array.isArray(t.inputMap)&&(this.#ei=new Map(t.inputMap))}get mappedKeyStartCalls(){Ir(this.#ur);const e=this.#ti.get("mapped-key-start");return Array.isArray(e)?[...e]:[]}get mappedKeyEndCalls(){Ir(this.#ur);const e=this.#ti.get("mapped-key-end");return Array.isArray(e)?[...e]:[]}get comboMappedKeys(){return Ir(this.#ur),[...this.#bi]}get comboMappedInputs(){return Ir(this.#ur),[...this.#yi]}get keySequenceSize(){return Ir(this.#ur),this.#Ai.size}get keySequences(){Ir(this.#ur);const e=[];for(const[,t]of this.#Ai.entries())e.push(t.callback);return e}get activeMappedKeys(){return Ir(this.#ur),[...this.#Ti]}get mappedInputStartCalls(){Ir(this.#ur);const e=this.#ti.get("mapped-input-start");return Array.isArray(e)?[...e]:[]}get mappedInputEndCalls(){Ir(this.#ur);const e=this.#ti.get("mapped-input-end");return Array.isArray(e)?[...e]:[]}get inputSequenceSize(){return Ir(this.#ur),this.#xi.size}get inputSequences(){Ir(this.#ur);const e=[];for(const[,t]of this.#xi.entries())e.push(t.callback);return e}get activeMappedInputs(){return Ir(this.#ur),[...this.#Si]}get mappedInputs(){Ir(this.#ur);const e={};for(const[t,r]of this.#ei.entries())e[t]=r;return e}get mappedInputSize(){return Ir(this.#ur),this.#ei.size}get connectedCalls(){Ir(this.#ur);const e=this.#ti.get("connected");return Array.isArray(e)?[...e]:[]}get disconnectedCalls(){Ir(this.#ur);const e=this.#ti.get("disconnected");return Array.isArray(e)?[...e]:[]}get ignoredDeviceIds(){return Ir(this.#ur),[...this.#ui]}get heldKeys(){return Ir(this.#ur),[...this.#Zr]}get eventsSize(){Ir(this.#ur);let e=0;return this.#ti.forEach(t=>{e+=t.length}),e}get callSize(){return Ir(this.#ur),this.#ti.size}get connectedCallSize(){Ir(this.#ur);const e=this.#ti.get("connected");return Array.isArray(e)?e.length:0}get disconnectedCallSize(){Ir(this.#ur);const e=this.#ti.get("disconnected");return Array.isArray(e)?e.length:0}get mappedKeyStartCallSize(){Ir(this.#ur);const e=this.#ti.get("mapped-key-start");return Array.isArray(e)?e.length:0}get mappedKeyEndCallSize(){Ir(this.#ur);const e=this.#ti.get("mapped-key-end");return Array.isArray(e)?e.length:0}get mappedInputStartCallSize(){Ir(this.#ur);const e=this.#ti.get("mapped-input-start");return Array.isArray(e)?e.length:0}get mappedInputEndCallSize(){Ir(this.#ur);const e=this.#ti.get("mapped-input-end");return Array.isArray(e)?e.length:0}get lastButtonStates(){Ir(this.#ur);const e=[];return this.#ii.forEach(t=>{e.push({...t})}),e}get lastAxes(){return Ir(this.#ur),[...this.#si]}get inputMode(){return Ir(this.#ur),this.#li}get elementBase(){return Ir(this.#ur),this.#mi}get timeComboInputs(){return Ir(this.#ur),this.#gi}get timeComboKeys(){return Ir(this.#ur),this.#vi}get timeMappedInputs(){return Ir(this.#ur),this.#wi}get timeoutComboKeys(){return Ir(this.#ur),this.#pi}set timeoutComboKeys(e){if(Ir(this.#ur),"number"!=typeof e||e<0||!Number.isFinite(e))throw new TypeError("Timeout combo keys must be a non-negative finite number.");this.#pi=e}get axisActiveSensitivity(){return Ir(this.#ur),this.#fi}set axisActiveSensitivity(e){if(Ir(this.#ur),"number"!=typeof e||e<0||e>1)throw new RangeError("Axis sensitivity must be a number between 0 and 1.");this.#fi=e}get deadZone(){return Ir(this.#ur),this.#hi}set deadZone(e){if(Ir(this.#ur),"number"!=typeof e||e<0||e>1)throw new RangeError("Dead zone must be a number between 0 and 1.");this.#hi=e}get expectedId(){return Ir(this.#ur),this.#ci}set expectedId(e){if(Ir(this.#ur),"string"!=typeof e)throw new TypeError("Expected device id be a string.");this.#ci=e}get isDestroyed(){return this.#ur}destroy(){this.#ur||(this.#oi&&cancelAnimationFrame(this.#oi),this.#ai&&cancelAnimationFrame(this.#ai),this.#oi=null,this.#ai=null,["keyboard-only","both"].includes(this.#li)&&(this.#mi.removeEventListener("keydown",this.#Hi),this.#mi.removeEventListener("keyup",this.#Oi),this.#di&&(this.#mi.removeEventListener("mousedown",this.#Fi),this.#mi.removeEventListener("mouseup",this.#Bi),this.#mi.removeEventListener("mousemove",this.#zi))),["gamepad-only","both"].includes(this.#li)&&(window.removeEventListener("gamepadconnected",this.#Ni),window.removeEventListener("gamepaddisconnected",this.#Li)),this.resetComboMapped(),this.#ei.clear(),this.#ti.clear(),this.#Zr.clear(),this.#Si.clear(),this.#Ti.clear(),this.#xi.clear(),this.#Ai.clear(),this.#ui.clear(),this.#Ci.clear(),this.#ii=[],this.#si=[],this.#ni={},this.#ri=null,this.#ci=null,this.#di=!1,this.#wi=0,this.#ur=!0)}}const Mr=Dr,Nr=X("TinyDayNightCycle"),kr=class{#Ui=!0;#Gi=86400;#Yi=3600;#Xi=60;#Qi=new Map;#Zi=[];#en;#tn;#rn={main:null};#in=0;#nn=0;#sn=0;#on="";#an=1;#ln=1;#un=1;#ur=!1;#hn=[31,31,31,31,31,31,31,31,31,31,31,31];#cn={default:{},day:{},night:{},hours:{},seasons:{}};#dn={min:60,max:180};#mn=0;get daySize(){return Nr(this.#ur),this.#Gi}get autoSizeAdjuste(){return Nr(this.#ur),this.#Ui}set autoSizeAdjuste(e){if(Nr(this.#ur),"boolean"!=typeof e)throw new TypeError("autoSizeAdjuste must be a boolean.");this.#Ui=e}set daySize(e){if(Nr(this.#ur),"number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("daySize must be a positive finite number.");const t=this.#Yi/this.#Gi,r=this.#Xi/this.#Gi;this.#Gi=e,this.#Ui&&(this.#Yi=e*t,this.#Xi=e*r)}get hourSize(){return Nr(this.#ur),this.#Yi}set hourSize(e){if(Nr(this.#ur),"number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("hourSize must be a positive finite number.");const t=this.#Gi/this.#Yi,r=this.#Xi/this.#Yi;this.#Yi=e,this.#Ui&&(this.#Gi=e*t,this.#Xi=e*r)}get minuteSize(){return Nr(this.#ur),this.#Xi}set minuteSize(e){if(Nr(this.#ur),"number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("minuteSize must be a positive finite number.");const t=this.#Yi/this.#Xi,r=this.#Gi/this.#Xi;this.#Xi=e,this.#Ui&&(this.#Yi=e*t,this.#Gi=e*r)}get isDestroyed(){return this.#ur}get currentSeconds(){return Nr(this.#ur),this.#in}set currentSeconds(e){if(Nr(this.#ur),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("currentSeconds must be a finite number, received "+typeof e);if(e<0||e>=this.#Gi)throw new RangeError(`currentSeconds must be between 0 and 86399, received ${e}`);this.#in=Math.floor(e),this.#nn=Math.floor(e/this.#Xi),this.#sn=Math.floor(e/this.#Yi)}get currentMinutes(){return Nr(this.#ur),this.#nn}set currentMinutes(e){if(Nr(this.#ur),"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.#nn=Math.floor(e),this.#sn=Math.floor(e/this.#Xi),this.#in=Math.floor(e*this.#Xi)}get currentHours(){return Nr(this.#ur),this.#sn}set currentHours(e){if(Nr(this.#ur),"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.#sn=Math.floor(e),this.#nn=Math.floor(e*this.#Xi),this.#in=Math.floor(e*this.#Yi)}get moons(){return Nr(this.#ur),this.#Zi.map(e=>this.getMoon(e))}get seasons(){return Nr(this.#ur),Array.from(this.#Qi.keys())}get dayStart(){return Nr(this.#ur),this.#en}get nightStart(){return Nr(this.#ur),this.#tn}get weather(){return Nr(this.#ur),{...this.#rn}}get currentSeason(){return Nr(this.#ur),this.#on}get currentDay(){return Nr(this.#ur),this.#an}get currentMonth(){return Nr(this.#ur),this.#ln}get currentYear(){return Nr(this.#ur),this.#un}get monthDays(){return Nr(this.#ur),[...this.#hn]}get weatherDuration(){return Nr(this.#ur),{...this.#dn}}get weatherTimeLeft(){return Nr(this.#ur),this.#mn}set dayStart(e){if(Nr(this.#ur),"number"!=typeof e||e<1)throw new TypeError("dayStart must be a positive non-zero number, received "+typeof e);this.#en=e}set nightStart(e){if(Nr(this.#ur),"number"!=typeof e||e<1)throw new TypeError("nightStart must be a positive non-zero number, received "+typeof e);this.#tn=e}set weather(e){if(Nr(this.#ur),"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.#rn=e}set currentSeason(e){if(Nr(this.#ur),"string"!=typeof e||!this.#Qi.has(e))throw new TypeError(`currentSeason must be one of ${Array.from(this.#Qi).map(e=>e[0]).join(", ")}, received ${e}`);this.#on=e}set currentDay(e){if(Nr(this.#ur),"number"!=typeof e||e<1||e>this.#hn[this.#ln-1])throw new TypeError("currentDay must be a valid day number, received "+typeof e);this.#an=e}set currentMonth(e){if(Nr(this.#ur),"number"!=typeof e||"number"!=typeof this.#hn[e-1])throw new TypeError("currentMonth must be a valid month number, received "+typeof e);this.#ln=e}set currentYear(e){if(Nr(this.#ur),"number"!=typeof e||e<1)throw new TypeError("currentYear must be a positive number non-zero, received "+typeof e);this.#un=e}set monthDays(e){if(Nr(this.#ur),!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.#hn=[...e]}set weatherDuration(e){if(Nr(this.#ur),"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.#dn={...e}}set weatherTimeLeft(e){if(Nr(this.#ur),"number"!=typeof e)throw new TypeError("weatherTimeLeft must be a number, received "+typeof e);this.#mn=e}get weatherConfig(){Nr(this.#ur);const e={},t={};for(const t in this.#cn.hours)e[t]={...this.#cn.hours[t]};for(const e in this.#cn.seasons)t[e]={...this.#cn.seasons[e]};return{default:{...this.#cn.default},day:{...this.#cn.day},night:{...this.#cn.night},hours:e,seasons:t}}set weatherConfig(e){if(Nr(this.#ur),"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={},i={},n=(e,t)=>{if("object"!=typeof e||null===e)throw new TypeError(`${t} must be an object, received ${e}`);for(const r in e){const i=typeof e[r];if("number"!==i&&"function"!==i)throw new TypeError(`${t}["${r}"] must be a number or function, received ${i}`)}};for(const t in e.hours)n(e.hours[t],`hours["${t}"]`),r[t]={...e.hours[t]};for(const t in e.seasons)n(e.seasons[t],`seasons["${t}"]`),i[t]={...e.seasons[t]};const s=(e,t)=>(n(e,t),{...e});this.#cn={default:s(e.default,"default"),day:s(e.day,"day"),night:s(e.night,"night"),hours:r,seasons:i}}constructor(e=6,t=18){this.#en=e,this.#tn=t}addSeason(e,t){if(Nr(this.#ur),"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.#Qi.set(e,t)}removeSeason(e){if(Nr(this.#ur),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);this.#Qi.delete(e),this.#on===e&&(this.#on="")}hasSeason(e){if(Nr(this.#ur),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);return this.#Qi.has(e)}getSeason(e){if(Nr(this.#ur),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);const t=this.#Qi.get(e);if(!t)throw new Error(`Season "${e}" not found`);return[...t]}setTime({hour:e=0,minute:t=0,second:r=0}){Nr(this.#ur),this.currentSeconds=(e*this.#Yi+t*this.#Xi+r)%this.#Gi}addTime({hours:e=0,minutes:t=0,seconds:r=0}){Nr(this.#ur);let i=this.currentSeconds+e*this.#Yi+t*this.#Xi+r;for(;i>=this.#Gi;)i-=this.#Gi,this.nextDay();for(;i<0;)i+=this.#Gi,this.prevDay();this.currentSeconds=i,this.updateWeatherTimer((e*this.#Yi+t*this.#Xi+r)/this.#Xi)}getTime({withSeconds:e=!1,hourSize:t=this.#Yi,minuteSize:r=this.#Xi}={}){Nr(this.#ur);const i=Math.floor(this.currentSeconds/t),n=Math.floor(this.currentSeconds%t/r),s=this.currentSeconds%r;return{hour:i,minute:n,second:s,formatted:`${i.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`+(e?`:${s.toString().padStart(2,"0")}`:"")}}isDay(){return Nr(this.#ur),this.#en<this.#tn?this.#nn>=this.#en*this.#Xi&&this.#nn<this.#tn*this.#Xi:this.#nn>=this.#en*this.#Xi||this.#nn<this.#tn*this.#Xi}minutesUntilDay(){return this.timeUntil(this.#en,"minutes")}secondsUntilDay(){return this.timeUntil(this.#en,"seconds")}hoursUntilDay(){return this.timeUntil(this.#en,"hours")}minutesUntilNight(){return this.timeUntil(this.#tn,"minutes")}secondsUntilNight(){return this.timeUntil(this.#tn,"seconds")}hoursUntilNight(){return this.timeUntil(this.#tn,"hours")}timeUntil(e,t){Nr(this.#ur);let r=e*this.#Yi-this.#in;switch(r<=0&&(r+=this.#Gi),t){case"minutes":return r/this.#Xi;case"hours":return r/this.#Yi;default:return r}}setTo(e){Nr(this.#ur),"day"===e?this.setTime({hour:this.#en}):"night"===e&&this.setTime({hour:this.#tn})}nextDay(e=1){Nr(this.#ur);for(let t=0;t<e;t++){this.#an++;const e=this.#hn[this.#ln-1];if(Number.isNaN(e)||!Number.isFinite(e))throw new Error("Invalid month day count: monthDays must be a finite number.");this.#an>e&&(this.#an=1,this.#ln++,this.#ln>this.#hn.length&&(this.#ln=1,this.#un++)),this.updateSeason(),this.advanceMoons(1)}}prevDay(e=1){Nr(this.#ur);for(let t=0;t<e;t++)this.#an--,this.#an<1&&(this.#ln--,this.#ln<1&&(this.#ln=this.#hn.length,this.#un--),this.#an=this.#hn[this.#ln-1]||30),this.updateSeason(),this.rewindMoons(1)}updateSeason(){Nr(this.#ur),this.#Qi.forEach((e,t)=>{e.includes(this.#ln)&&(this.#on=t)})}setWeatherConfig(e){Nr(this.#ur),this.#cn={...this.#cn,...e}}setWeatherDuration(e,t){Nr(this.#ur),this.#dn.min=e,this.#dn.max=t}updateWeatherTimer(e){Nr(this.#ur),this.#mn-=e,this.#mn<=0&&this.chooseNewWeather()}forceWeather({where:e="main",type:t,duration:r=null}){Nr(this.#ur);const i=this.#rn;i[e]=t,this.weather=i,this.#mn=r??this._randomInRange(this.#dn.min,this.#dn.max)}chooseNewWeather({customWeather:e,where:t="main"}={}){Nr(this.#ur);let r={};const i=e=>{for(const[t,i]of Object.entries(e)){let e=i;"function"==typeof e&&(e=e({hour:Math.floor(this.#nn/this.#Xi),minute:this.#nn%this.#Xi,currentMinutes:this.#nn,isDay:this.isDay(),season:this.#on,weather:this.#rn})),"number"!=typeof e||Number.isNaN(e)||(r[t]=(r[t]||0)+e)}};i(this.#cn.default||{});for(const e in this.#cn.hours){const[t,r]=e.split("-").map(e=>{const[t,r]=e.split(":").map(Number);return t*this.#Xi+(r||0)}),n=this.#nn;(t<=r?n>=t&&n<=r:n>=t||n<=r)&&i(this.#cn.hours[e])}this.isDay()&&this.#cn.day?i(this.#cn.day):!this.isDay()&&this.#cn.night&&i(this.#cn.night),this.#cn.seasons?.[this.#on]&&i(this.#cn.seasons[this.#on]),e&&"object"==typeof e&&i(e);const n=Object.entries(r).filter(([,e])=>e>0);if(!n.length)return this.#rn[t]=null,null;const s=n.reduce((e,[,t])=>e+t,0);let o=Math.random()*s;for(const[e,r]of n){if(o<r)return this.#rn[t]=e,this.#mn=this._randomInRange(this.#dn.min,this.#dn.max),e;o-=r}return this.#rn[t]=null,null}_randomInRange(e,t){return Math.floor(Math.random()*(t-e+1))+e}addMoon(e,t,r,i=0){Nr(this.#ur);const n=Math.max(1,t);return this.#Zi.push({name:e,cycleLength:n,currentPhase:(i%n+n)%n,phaseNames:r}),this.#Zi.length-1}removeMoon(e){Nr(this.#ur),this.#Zi=this.#Zi.filter(t=>t.name!==e)}advanceMoons(e=1){for(const t in this.#Zi)this.advanceMoon(parseInt(t),e)}rewindMoons(e=1){for(const t in this.#Zi)this.rewindMoon(parseInt(t),e)}advanceMoon(e,t=1){Nr(this.#ur);const r=this.#Zi[e];if(!r)throw new RangeError(`No moon found at index ${e}`);r.currentPhase=(r.currentPhase+t)%r.cycleLength}rewindMoon(e,t=1){Nr(this.#ur);const r=this.#Zi[e];if(!r)throw new RangeError(`No moon found at index ${e}`);r.currentPhase=(r.currentPhase-t+r.cycleLength)%r.cycleLength}moonExists(e){return Nr(this.#ur),!!this.#Zi[e]}getMoon(e){let t;if(Nr(this.#ur),"number"==typeof e){if(t=this.#Zi[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}}destroy(){this.#ur||(this.#Qi.clear(),this.#Zi.length=0,this.#en=0,this.#tn=0,this.#in=0,this.#nn=0,this.#sn=0,this.#an=1,this.#ln=1,this.#un=1,this.#mn=0,this.#on="",this.#rn={main:null},this.#hn=[],this.#cn.default={},this.#cn.day={},this.#cn.night={},this.#cn.hours={},this.#cn.seasons={},this.#dn={min:0,max:0},this.#ur=!0)}},Lr=X("TinyAdvancedRaffle");class _r extends tr.EventEmitter{#ur=!1;#pn;#fn;#yn=[];#gn=[];#wn=[];#bn=new Map;#vn=new Set;#En=new Map;#Tn;#Sn=new Map;#xn=new Map;get isDestroyed(){return this.#ur}get freq(){return Lr(this.#ur),Object.fromEntries(this.#xn)}get size(){return Lr(this.#ur),this.#Sn.size}get normalization(){return Lr(this.#ur),this.#pn}set normalization(e){if(Lr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError("normalization must be a non-empty string (e.g., 'relative', 'softmax').");this.#pn=e}get seed(){return Lr(this.#ur),this.#fn}set seed(e){if(Lr(this.#ur),null!==e&&("number"!=typeof e||!Number.isFinite(e)))throw new TypeError("seed must be a finite number or null.");this.#fn=e,null!==e&&(this.#Tn=this._makeSeededRng(e))}get globalModifiers(){return Lr(this.#ur),[...this.#yn]}set globalModifiers(e){if(Lr(this.#ur),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("globalModifiers must be an array of functions (WeightsCallback).");this.#yn=e}get temporaryModifiers(){return Lr(this.#ur),[...this.#gn]}set temporaryModifiers(e){if(Lr(this.#ur),!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.#gn=e}get conditionalRules(){return Lr(this.#ur),[...this.#wn]}set conditionalRules(e){if(Lr(this.#ur),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("conditionalRules must be an array of functions (WeightsCallback).");this.#wn=e}get pitySystems(){return Lr(this.#ur),Object.fromEntries(this.#bn)}set pitySystems(e){if(Lr(this.#ur),!(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.#bn=e}get exclusions(){return Lr(this.#ur),Array.from(this.#vn)}set exclusions(e){if(Lr(this.#ur),!(e instanceof Set&&[...e].every(e=>"string"==typeof e)))throw new TypeError("exclusions must be a Set<string>.");this.#vn=e}get groups(){Lr(this.#ur);const e={};return this.#En.forEach((t,r)=>e[r]=Array.from(t)),e}set groups(e){if(Lr(this.#ur),!(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.#En=e}get rng(){return Lr(this.#ur),this.#Tn}set rng(e){if(Lr(this.#ur),"function"!=typeof e||"number"!=typeof e())throw new TypeError("rng must be a function returning a number (RngGenerator).");this.#Tn=e}get items(){Lr(this.#ur);const e={};return this.#Sn.forEach((t,r)=>{e[r]={...t,groups:Array.from(t.groups)}}),e}set items(e){if(Lr(this.#ur),!(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.#Sn=e}constructor(e={}){super();const{rng:t=null,seed:r=null,normalization:i="relative"}=e;this.#pn=i,this.#fn=r,"function"==typeof t?this.#Tn=t:null!==this.#fn?this.#Tn=this._makeSeededRng(this.#fn):this.#Tn=Math.random,this.#fn=r??null}hasItem(e){if(Lr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#Sn.has(e)}addItem(e,t={}){if(Lr(this.#ur),"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:i=e,meta:n={},groups:s=[]}=t;if("number"!=typeof r||!Number.isFinite(r)||r<0)throw new TypeError("weight must be a non-negative number");if("string"!=typeof i)throw new TypeError("label must be a string");if("object"!=typeof n||null===n)throw new TypeError("meta must be an object");if(!(Array.isArray(s)||s instanceof Set))throw new TypeError("groups must be an array or a Set of strings");s=Array.isArray(s)?s:[...s];for(const e of s)if("string"!=typeof e)throw new TypeError("groups must contain only strings");const o={id:e,label:i,baseWeight:Math.max(0,Number(r)||0),meta:{...n},groups:new Set(s),locked:!1};this.#Sn.set(e,o);for(const t of s)this._ensureGroup(t).add(e);return this.emit("itemAdded",o),o}removeItem(e){if(Lr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");const t=this.#Sn.get(e);if(!t)return!1;for(const r of t.groups){const t=this.#En.get(r);t&&t.delete(e)}return this.#Sn.delete(e),this.emit("itemRemoved",e),this.resetFreq(e),this.resetPity(e),!0}setBaseWeight(e,t){if(Lr(this.#ur),"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.#Sn.get(e);if(!r)throw new Error("Item not found");r.baseWeight=Math.max(0,Number(t)||0),this.emit("weightChanged",{id:e,weight:r.baseWeight})}getItem(e){if(Lr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");return this.#Sn.get(e)??null}listItems(){return Lr(this.#ur),Array.from(this.#Sn.values()).map(e=>({...e}))}clearList(){Lr(this.#ur),this.#Sn.clear(),this.clearFreqs(),this.clearPities()}hasGlobalModifier(e){if(Lr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");return this.#yn.includes(e)}addGlobalModifier(e){if(Lr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");this.#yn.push(e)}removeGlobalModifier(e){if(Lr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");this.#yn=this.#yn.filter(t=>t!==e)}hasTemporaryModifier(e){if(Lr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");return this.#gn.some(t=>t.fn===e)}addTemporaryModifier(e,t=1){if(Lr(this.#ur),"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.#gn.push({fn:e,uses:Math.max(1,Math.floor(t))})}removeTemporaryModifier(e){if(Lr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");const t=this.#gn.length;return this.#gn=this.#gn.filter(t=>t.fn!==e),this.#gn.length!==t}hasConditionalRule(e){if(Lr(this.#ur),"function"!=typeof e)throw new TypeError("ruleFn must be a function");return this.#wn.includes(e)}addConditionalRule(e){if(Lr(this.#ur),"function"!=typeof e)throw new TypeError("ruleFn must be a function");this.#wn.push(e)}removeConditionalRule(e){if(Lr(this.#ur),"function"!=typeof e)throw new TypeError("ruleFn must be a function");const t=this.#wn.length;return this.#wn=this.#wn.filter(t=>t!==e),this.#wn.length!==t}hasPity(e){if(Lr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#bn.has(e)}configurePity(e,t){if(Lr(this.#ur),!this.#Sn.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:i,cap:n=1/0}=t;if("number"!=typeof r||r<=0)throw new TypeError("threshold must be a positive number");if("number"!=typeof i)throw new TypeError("increment must be a number");if("number"!=typeof n)throw new TypeError("cap must be a number");this.#bn.set(e,{threshold:Math.max(1,r),increment:Number(i)||0,cap:Number(n)||1/0,counter:0,currentAdd:0})}resetPity(e){if(Lr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError("itemId must be a non-empty string");const t=this.#bn.get(e);t&&(t.counter=0,t.currentAdd=0)}clearPities(){Lr(this.#ur),this.#bn.clear()}hasExclusion(e){if(Lr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#vn.has(e)}excludeItem(e){if(Lr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#vn.add(e)}includeItem(e){if(Lr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#vn.delete(e)}_ensureGroup(e){if(Lr(this.#ur),"string"!=typeof e)throw new TypeError("name must be a string");let t=this.#En.get(e);return t||(t=new Set,this.#En.set(e,t)),t}hasInGroup(e,t){if(Lr(this.#ur),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#En.get(t);return!!r&&r.has(e)}addToGroup(e,t){if(Lr(this.#ur),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#Sn.get(e);if(!r)throw new Error("Item missing");r.groups.add(t),this._ensureGroup(t).add(e)}removeFromGroup(e,t){if(Lr(this.#ur),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#En.get(t);r&&r.delete(e);const i=this.#Sn.get(e);i&&i.groups.delete(t)}clearFreqs(){Lr(this.#ur),this.#xn.clear()}resetFreq(e){if(Lr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#xn.delete(e)}computeEffectiveWeights(e={}){if(Lr(this.#ur),"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.#Sn)t.set(e,r.baseWeight);for(const r of this.#yn){const i=r(t,e);if(i instanceof Map)for(const[e,r]of i)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const r of this.#gn){const i=r.fn(t,e);if(i instanceof Map)for(const[e,r]of i)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const r of this.#wn){const i=r(t,e);if(i instanceof Map)for(const[e,r]of i)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const[e,r]of this.#bn)if(t.has(e)&&r.counter>r.threshold){r.currentAdd=Math.min(r.cap,r.currentAdd+r.increment);const i=t.get(e);i&&t.set(e,i+r.currentAdd)}for(const e of this.#vn)t.delete(e);for(const[e,r]of Array.from(t.entries()))r>0||t.delete(e);return t}_weightsToDistribution(e){if(!(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.#pn){const e=Math.max(...t.map(e=>e.weight)),r=t.map(t=>Math.exp(t.weight-e)),i=r.reduce((e,t)=>e+t,0);let n=0;return t.map((e,t)=>{const s=r[t]/i;return n+=s,{id:e.id,weight:e.weight,p:s,cumulative:n}})}{const e=t.reduce((e,t)=>e+t.weight,0);let r=0;return t.map(t=>{const i=t.weight/e;return r+=i,{id:t.id,weight:t.weight,p:i,cumulative:r}})}}drawOne(e={}){if(Lr(this.#ur),"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.#gn]},r=this.computeEffectiveWeights(t),i=this._weightsToDistribution(r);if(!i.length)return null;const n=this.#Tn(),s=i.find(e=>n<=e.cumulative)??i[i.length-1];for(const[e,t]of this.#bn)e===s.id?(t.counter=0,t.currentAdd=0):t.counter++;this._consumeTemporaryModifiers();const o=this.#Sn.get(s.id);if(!o)return null;const a={id:o.id,label:o.label,meta:{...o.meta},prob:s.p};return this.emit("draw",a),a&&this.#xn.set(a.id,(this.#xn.get(a.id)||0)+1),a}_consumeTemporaryModifiers(){for(let e=this.#gn.length-1;e>=0;--e){const t=this.#gn[e];t.uses-=1,t.uses<=0&&this.#gn.splice(e,1)}}drawMany(e=1,t={}){if(Lr(this.#ur),!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,i=t.ensureUnique??!1,n=[],s=t.previousDraws??[];if(!r&&i){const r=new Set;for(let i=0;i<e;++i){const e=new Set(this.#vn);for(const e of r)this.#vn.add(e);const i=this.drawOne({previousDraws:s,metadata:t.metadata});if(this.#vn=e,!i)break;n.push(i),r.add(i.id),s.push(i)}return n}for(let i=0;i<e;++i){const e=this.drawOne({previousDraws:s,metadata:t.metadata});if(!e)break;n.push(e),s.push(e),r||this.excludeItem(e.id)}if(!r)for(const e of n)this.includeItem(e.id);return n}exportToJson(){return Lr(this.#ur),{items:Array.from(this.#Sn.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.#bn.entries()),exclusions:Array.from(this.#vn),normalization:this.#pn,seed:this.#fn}}loadFromJson(e){if(Lr(this.#ur),"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.#Sn.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(){Lr(this.#ur);const e=new _r;return e.#pn=this.#pn,e.#fn=this.#fn,e.#yn=[...this.#yn],e.#gn=this.#gn.map(e=>({fn:e.fn,uses:e.uses})),e.#wn=[...this.#wn],e.#bn=new Map([...this.#bn.entries()].map(([e,t])=>[e,{...t}])),e.#vn=new Set(this.#vn),e.#En=new Map([...this.#En.entries()].map(([e,t])=>[e,new Set(t)])),e.#Tn=this.#Tn,e.#Sn=new Map([...this.#Sn.entries()].map(([e,t])=>[e,{...t,groups:new Set(t.groups),meta:{...t.meta}}])),e.#xn=new Map(this.#xn),e}_makeSeededRng(e){if("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.#ur||(this.#bn.clear(),this.#vn.clear(),this.#En.clear(),this.#Sn.clear(),this.#xn.clear(),this.#yn=[],this.#gn=[],this.#wn=[],this.#fn=null,this.#ur=!0)}}const jr=_r,Rr=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 i=Array.isArray(this.#ie)?this.#ie:Array.from(this.#ie);let n=i;if(r)if("function"==typeof r)n=i.filter((e,t,i)=>r(e,t,i));else{if("object"!=typeof r)throw new TypeError("Filter must be an object or a function");n=i.filter(e=>Object.entries(r).every(([t,r])=>{const i=e[t];return r instanceof RegExp?r.test(i):i===r}))}else n=i;const s=n.length,o=Math.max(1,Math.ceil(s/t)),a=Math.min(e,o),l=(a-1)*t,u=l+t,h=a>1,c=a<o;return{items:n.slice(l,u),page:a,perPage:t,totalItems:s,totalPages:o,hasPrev:h,hasNext:c}}};class Pr{static#An=new Map;static get itemRegistry(){const e={},t=Object.fromEntries(Pr.#An);for(const r in t)e[r]={...t[r],metadata:{...t[r].metadata}};return e}static defineItem(e){if(!e||"object"!=typeof e)throw new TypeError("Config must be a valid object.");if(!e.id||"string"!=typeof e.id)throw new TypeError("Item must have a valid string 'id'.");if(void 0!==e.weight&&("number"!=typeof e.weight||e.weight<0))throw new TypeError(`weight must be a number >= 0. Received: ${e.weight}`);if(void 0!==e.maxStack&&(!Number.isInteger(e.maxStack)||e.maxStack<=0))throw new TypeError(`maxStack must be a positive integer. Received: ${e.maxStack}`);if(void 0!==e.metadata&&"object"!=typeof e.metadata)throw new TypeError("metadata must be an object.");if(void 0!==e.onUse&&null!==e.onUse&&"function"!=typeof e.onUse)throw new TypeError("onUse must be a function or null.");if(void 0!==e.type&&null!==e.type&&"string"!=typeof e.type)throw new TypeError("type must be a string or null.");Pr.#An.set(e.id,{id:e.id,weight:e.weight||0,maxStack:e.maxStack||1,metadata:e.metadata||{},type:e.type??null,onUse:"function"==typeof e.onUse?e.onUse:null})}static removeItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");return Pr.#An.delete(e)}static hasItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");return Pr.#An.has(e)}static getItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");const t=Pr.#An.get(e);if(!t)throw new Error(`Item '${e}' not defined in registry.`);return t}#Cn=new Map;#In={add:[],remove:[],use:[],set:[]};#Sn=[];#Dn;#Mn;#Nn;#kn;get maxStack(){return this.#Dn}set maxStack(e){if(!Number.isInteger(e)||Number.isFinite(e)&&e<=0)throw new TypeError(`maxStack must be a positive integer. Received: ${e}`);this.#Dn=e}get maxSize(){return this.#Mn}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.#Mn=e}get maxSlots(){return this.#Nn}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.#Nn=e}get maxWeight(){return this.#kn}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.#kn=e}get events(){return{add:[...this.#In.add],remove:[...this.#In.remove],use:[...this.#In.use],set:[...this.#In.set]}}get items(){return[...this.#Sn].map(e=>e?this.#Ln(e):null)}get specialSlots(){return new Map([...this.#Cn.entries()].map(([e,t])=>[e,{type:t.type,item:t.item?this.#Ln(t.item):null}]))}get size(){const e=this.getAllItems();let t=0;for(const r of e)t+=r.quantity;return t}get slotsSize(){return this.getAllItems().length}get weight(){return this.getAllItems().reduce((e,t)=>{const r=Pr.getItem(t.id);return e+(r?.weight||0)*t.quantity},0)}_cleanNulls(){let e=this.#Sn.length-1;for(;e>=0&&null===this.#Sn[e];)e--;this.#Sn=this.#Sn.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.#kn=e.maxWeight??null,this.#Nn=e.maxSlots??null,this.#Mn=e.maxSize??null,this.#Dn=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.#Cn.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.#kn&&this.weight+e>this.#kn}areFull(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Mn&&this.size+e>this.#Mn}isFull(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Mn&&this.size+e>=this.#Mn}areFullSlots(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Nn&&this.slotsSize+e>this.#Nn}isFullSlots(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Nn&&this.slotsSize+e>=this.#Nn}#_n(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.#In[e])for(const r of this.#In[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.#In[e])return;const r=this.#In[e],i=r.indexOf(t);-1!==i&&r.splice(i,1)}offAll(e){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");this.#In[e]&&(this.#In[e]=[])}cloneEventCallbacks(e){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");return this.#In[e]?[...this.#In[e]]:[]}onAddItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#In.add.push(e)}onSetItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#In.set.push(e)}onRemoveItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#In.remove.push(e)}onUseItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#In.use.push(e)}compactInventory(){this.#Sn=this.#Sn.filter((e,t)=>{const r=null!==e;return r||this.#_n("remove",{index:t,item:null,isCollection:!0,specialSlot:null,remove:()=>{}}),r})}addItem({itemId:e,quantity:t=1,metadata:r={},forceSpace:i=!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 i)throw new TypeError("`forceSpace` must be a boolean.");const n=Pr.getItem(e);let s=t;const o=n.maxStack<=this.#Dn?n.maxStack:this.#Dn,a=[],l=(e,t)=>JSON.stringify(e)===JSON.stringify(t);let u=!0;for(;s>0&&u;){u=!1;for(const t in this.#Sn){const h=this.#Sn[t];if(h&&h.id===e&&h.quantity<o&&l(h.metadata,r)){const e=Math.min(o-h.quantity,s);if(!i&&!this.hasSpace({weight:n.weight*e,sizeLength:e}))continue;h.quantity+=e,s-=e,u=!0;const r=Number(t),l=a.findIndex(e=>e.index===r);if(l<0?a.push({index:r,quantity:e}):a[l].quantity+=e,this.#_n("add",{item:this.#Ln(h),index:r,isCollection:!0,specialSlot:null,remove:this.#jn({locationType:"normal",slotIndex:r,forceSpace:i,item:h})}),s<=0)break}}}if(s>0)for(const t in this.#Sn)if(null===this.#Sn[t]){const l=Math.min(o,s);if(!i&&!this.hasSpace({weight:n.weight*l,sizeLength:l}))continue;const u={id:e,quantity:l,metadata:r};this.#Sn[t]=u,s-=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.#_n("add",{item:this.#Ln(u),index:h,isCollection:!0,specialSlot:null,remove:this.#jn({locationType:"normal",slotIndex:h,forceSpace:i,item:u})}),s<=0)break}for(;s>0;){const t=Math.min(o,s);if(!i&&!this.hasSpace({weight:n.weight*t,sizeLength:t,slotsLength:1}))break;const l={id:e,quantity:t,metadata:r};this.#Sn.push(l);const u=this.#Sn.length-1,h=a.findIndex(e=>e.index===u);h<0?a.push({index:u,quantity:t}):a[h].quantity+=t,this.#_n("add",{item:this.#Ln(l),index:u,isCollection:!0,specialSlot:null,remove:this.#jn({locationType:"normal",slotIndex:u,forceSpace:i,item:l})}),s-=t}return{remaining:s,placesAdded:a}}getItemFrom(e){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");if(e<0||e>=this.#Sn.length)throw new Error(`Slot index '${e}' out of bounds .`);return this.#Sn[e]?this.#Ln(this.#Sn[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 i=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&&!i)throw new Error("Invalid item type: must be null or a valid InventoryItem.");const n=t?Pr.#An.get(t.id):null;if(null!==t&&!n)throw new Error(`Item '${t?.id??"unknown"}' not defined in registry.`);if(n&&t){const e=n.maxStack<=this.#Dn?n.maxStack:this.#Dn;if(t.quantity>e)throw new Error(`Item '${t.id}' exceeds max stack size. Allowed: ${e}, got: ${t.quantity}.`)}if(null!==this.#Nn&&(e<0||e>=this.#Nn))throw new Error(`Slot index ${e} out of range.`);const s=this.#Sn[e]??null,o=s?Pr.#An.get(s.id)??null:null,a=(e,t)=>t?t.weight*(e?e.quantity:0):0,l=e=>e?e.quantity:0;if(!r&&!this.hasSpace({weight:a(t,n)-a(s,o),sizeLength:l(t)-l(s)}))throw new Error("Inventory is full or overweight.");for(;this.#Sn.length<=e;)this.#Sn.push(null);this.#Sn[e]=t,this._cleanNulls(),this.#_n("set",{index:e,isCollection:!0,item:t?this.#Ln(t):null,specialSlot:null,remove:t?this.#jn({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 i=this.#Sn[e];if(!i)throw new Error(`No item found in slot ${e}.`);this.setItem({slotIndex:t,item:i,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 i=r;const n=(e,t)=>JSON.stringify(e)===JSON.stringify(t);for(let r=0;r<this.#Sn.length;r++){const s=this.#Sn[r];if(s&&s.id===e&&(null===t||n(s.metadata,t))){const e=Math.min(s.quantity,i);s.quantity-=e,i-=e;const t=Number(r);if(s.quantity<=0&&(this.#Sn[r]=null),i<=0)return this._cleanNulls(),this.#_n("remove",{index:t,item:this.#Ln(s),isCollection:!0,specialSlot:null,remove:this.#jn({locationType:"normal",slotIndex:t,item:s})}),!0}}return this._cleanNulls(),this.#Cn.forEach((r,s)=>{if(i>0&&r.item&&r.item.id===e&&(null===t||n(r.item.metadata,t))){const e=Math.min(r.item.quantity,i);r.item.quantity-=e,r.item.quantity<0&&(r.item.quantity=0),i-=e,r.item.quantity<=0&&(r.item=null),this.#Cn.set(s,r),this.#_n("remove",{index:null,item:r.item?this.#Ln(r.item):null,isCollection:!1,specialSlot:s,remove:r.item?this.#jn({locationType:"special",specialSlot:s,item:r.item}):()=>{}})}}),i<=0}#jn({locationType:e,specialSlot:t,slotIndex:r,item:i,forceSpace:n=!1}){if("normal"!==e&&"special"!==e)throw new TypeError("`locationType` must be 'normal' or 'special'.");if("boolean"!=typeof n)throw new TypeError("`forceSpace` must be boolean.");if(!i||"object"!=typeof i)throw new TypeError("`item` must be an InventoryItem object.");if("special"===e&&t&&"string"!=typeof t)throw new TypeError("`specialSlot` must be a string when locationType is 'special'.");if("normal"===e&&"number"!=typeof r)throw new TypeError("`slotIndex` must be a number when locationType is 'normal'.");return(s=n)=>{if("special"===e&&t){const e=this.#Cn.get(t);if(!e?.item)throw new Error(`Special slot '${t}' is empty.`);e.item.quantity>1?(e.item.quantity-=1,this.#Cn.set(t,e)):this.setSpecialSlot({slotId:t,item:null,forceSpace:s})}else{if("number"!=typeof r)throw new Error("Invalid remove operation: no valid slotIndex or specialSlot provided.");i.quantity>1?this.setItem({slotIndex:r,item:{...i,quantity:i.quantity-1},forceSpace:s}):this.setItem({slotIndex:r,item:null,forceSpace:s})}}}useItem({slotIndex:e,specialSlot:t,forceSpace:r=!1},...i){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 n=null,s="normal",o=null;if(t){if(!this.#Cn.has(t))throw new Error(`Special slot '${t}' not found.`);n=this.#Cn.get(t).item,s="special"}else o=this.#Sn,n=o[e??-1]??null,s="normal";if(!n)throw new Error("special"===s?`No item found in special slot '${t}'.`:`No item found in slot ${e} of inventory.`);const a=Pr.getItem(n.id);if(a.onUse){const l={inventory:this,item:this.#Ln(n),index:e??null,specialSlot:t??null,isCollection:!!o,itemDef:a,remove:this.#jn({locationType:s,specialSlot:t,slotIndex:e,forceSpace:r,item:n}),...i},u=a.onUse(l);return this.#_n("use",l),u}return null}hasSpecialSlot(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");return this.#Cn.has(e)}getSpecialItem(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(!this.#Cn.has(e))throw new Error(`Special slot '${e}' does not exist.`);const t=this.#Cn.get(e);return t?.item?this.#Ln(t.item):null}getSpecialSlotType(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(!this.#Cn.has(e))throw new Error(`Special slot '${e}' does not exist.`);const t=this.#Cn.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.#Cn.has(e))throw new Error(`Special slot '${e}' not found.`);const i=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&&!i)throw new Error("Invalid item type: must be null or a valid InventoryItem.");const n=t?Pr.#An.get(t.id):null;if(null!==t&&!n)throw new Error(`Item '${t?.id??"unknown"}' not defined in registry.`);const s=this.#Cn.get(e);if(!s)throw new Error(`Special slot ${e} out of range for slot '${e}'.`);const o=s.item?Pr.#An.get(s.item.id):null,a=(e,t)=>t?t.weight*(e?1:0):0,l=e=>e?1:0;if(!r&&!this.hasSpace({weight:a(t,n)-a(s.item,o),sizeLength:l(t)-l(s.item)}))throw new Error("Inventory is full or overweight.");s.item=t,this.#_n("set",{index:null,item:t?this.#Ln(t):null,isCollection:!1,specialSlot:e,remove:t?this.#jn({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:i=!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 i)throw new TypeError("`forceSpace` must be boolean.");if(r<=0||!Number.isFinite(r))throw new Error(`Invalid quantity '${r}'.`);if(!this.#Cn.has(e))throw new Error(`Special slot '${e}' does not exist.`);const n=this.getItemFrom(t);if(!n)throw new Error(`No item found in inventory slot ${t}.`);if(n.quantity<r)throw new Error(`Not enough quantity of item '${n.id}' in inventory slot.`);const s=Pr.getItem(n.id),o=this.#Cn.get(e);if(!o)throw new Error(`Slot '${e}' not defined in registry.`);const a=o.type??null;if(null!==a&&s.type!==a)throw new Error(`Item '${n.id}' cannot be equipped in slot '${e}'.`);const l=Math.min(s.maxStack,this.#Dn);if(o.item&&o.item.id===n.id){const t=Math.max(0,l-o.item.quantity);if(t<=0)return r;const i=Math.min(r,t);return this.removeItem({itemId:n.id,quantity:i,metadata:null}),o.item.quantity+=i,this.#Cn.set(e,o),r-i}o.item&&this.unequipItem({slotId:e,forceSpace:i});const u=Math.min(r,l);return this.removeItem({itemId:n.id,quantity:u,metadata:null}),o.item={id:n.id,quantity:u,metadata:n.metadata},this.#Cn.set(e,o),r-u}unequipItem({slotId:e,quantity:t=null,forceSpace:r=!1}){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(null!==t&&("number"!=typeof t||!Number.isFinite(t)||t<=0))throw new TypeError("`quantity` must be a positive number or null.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be boolean.");if(!this.#Cn.has(e))throw new Error(`Special slot '${e}' does not exist.`);const i=this.#Cn.get(e);if(!i)throw new Error(`Slot '${e}' not defined in registry.`);if(!i.item)return!1;const n=i.item,s=null===t?n.quantity:t;if(s<=0)throw new Error(`Invalid unequip quantity: ${s}`);if(s>n.quantity)throw new Error(`Not enough items in slot '${e}' to unequip.`);return this.addItem({itemId:n.id,quantity:s,metadata:n.metadata,forceSpace:r}),s===n.quantity?i.item=null:(n.quantity-=s,i.item=n),this.#Cn.set(e,i),!0}#Ln(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.#Sn].map((e,t)=>[e?this.#Ln(e):null,t]).filter(e=>null!==e[0])}getAllItems(){const e=[...this.#Sn].filter(e=>null!==e).map(this.#Ln);return this.#Cn.forEach(t=>{const r=t.item;r&&e.push(r)}),e}getItemsByMetadata(e){if("function"!=typeof e)throw new TypeError("`filterFn` must be a function.");return this.getAllItems().filter(t=>{const r=Pr.getItem(t.id);return e(r.metadata,t)})}findItem(e){if("function"!=typeof e)throw new TypeError("`predicate` must be a function.");return this.getAllItems().find(e)}findItems(e){if("function"!=typeof e)throw new TypeError("`predicate` must be a function.");return this.getAllItems().filter(e)}getItemCount(e){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");return this.getAllItems().filter(t=>t.id===e).reduce((e,t)=>e+t.quantity,0)}hasItem(e,t=1){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");if("number"!=typeof t||!Number.isFinite(t)||t<0)throw new TypeError("`quantity` must be a non-negative number.");return this.getItemCount(e)>=t}existsItemAt(e){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");return!!this.#Sn[e]}clear(){this.clearAllItems(),this.clearAllEvents()}clearAllEvents(){this.#In={add:[],remove:[],use:[],set:[]}}clearAllItems(){this.clearItems(),this.clearSpecialItems()}clearItems(){for(let e=this.#Sn.length-1;e>=0;e--)this.#Sn[e]&&this.deleteItem(e,!0)}clearSpecialItems(){for(const e of this.#Cn.keys()){const t=this.#Cn.get(e);t?.item&&this.deleteSpecialItem(e,!0)}}clone(){const e=this.toObject();return Pr.fromObject(e)}toObject(){const e={};for(const[t,r]of this.#Cn.entries())e[t]={type:r?.type??null,item:r?.item?this.#Ln(r.item):null};return{__schema:"TinyInventory",version:1,maxWeight:this.#kn,maxSlots:this.#Nn,maxSize:this.#Mn,maxStack:this.#Dn,items:this.#Sn.map(e=>e?this.#Ln(e):null),specialSlots:e}}toJSON(e=0){if("number"!=typeof e||!Number.isFinite(e)||e<0)throw new TypeError("`space` must be a non-negative number.");return JSON.stringify(this.toObject(),null,e)}static fromObject(e){if(!e||"object"!=typeof e)throw new TypeError("Invalid state: expected object.");if("TinyInventory"!==e.__schema||"number"!=typeof e.version)throw new TypeError("Invalid or missing schema header.");if(1!==e.version)throw new TypeError(`Unsupported TinyInventory state version: ${e.version}`);const t={};if(e.specialSlots&&"object"==typeof e.specialSlots)for(const r of Object.keys(e.specialSlots))t[r]={type:e.specialSlots[r]?.type??null};const r=new Pr({maxWeight:e.maxWeight??null,maxSlots:e.maxSlots??null,maxSize:e.maxSize??null,maxStack:e.maxStack??null,specialSlots:t});if(Array.isArray(e.items))for(const t in e.items){const i=e.items[t];if(null!==i){const e={id:String(i.id),quantity:Math.max(1,Number(i.quantity)||1),metadata:i.metadata&&"object"==typeof i.metadata?i.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,i]of Object.entries(e.specialSlots)){if(!r.hasSpecialSlot(t))continue;const e=i?.item;if(e&&e.id){const i={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:i,forceSpace:!0})}}return r}static fromJSON(e){if("string"!=typeof e)throw new TypeError("`json` must be a string.");const t=JSON.parse(e);return Pr.fromObject(t)}}const $r=Pr,Hr=class{#Rn=null;#Pn=null;get sender(){return this.#Rn}get receiver(){return this.#Pn}set sender(e){if(!(e instanceof $r&&this.receiver instanceof $r))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Rn=e}set receiver(e){if(!(this.sender instanceof $r&&e instanceof $r))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Pn=e}constructor(e,t){if(e||t){if(!(e instanceof $r&&t instanceof $r))throw new Error("Both sender and receiver must be TinyInventory instances.");this.connect(e,t)}}connect(e,t){if(!(e instanceof $r&&t instanceof $r))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Rn=e,this.#Pn=t}disconnect(){this.#Rn=null,this.#Pn=null}invert(){const e=this.#Rn,t=this.#Pn;this.#Rn=t,this.#Pn=e}transferItem({slotIndex:e,specialSlot:t,quantity:r=1,receiverSlotIndex:i,forceSpace:n=!1,strict:s=!1}){if(!this.#Rn||!this.#Pn)throw new Error("Sender and receiver inventories must be connected.");let o;if(t){if(o=this.#Rn.getSpecialItem(t),!o)throw new Error(`No item found in sender special slot '${t}'.`)}else{if("number"!=typeof e)throw new Error("Must provide either slotIndex or specialSlot.");if(o=this.#Rn.getItemFrom(e),!o)throw new Error(`No item found in sender slot ${e}.`)}if(o.quantity<r)throw new Error(`Sender does not have enough quantity of '${o.id}' to transfer.`);const a={id:o.id,quantity:r,metadata:o.metadata};let l;if(s)if("number"==typeof i){const e=this.#Pn.existsItemAt(i)?this.#Pn.getItemFrom(i):null;if(e){if(e.id!==a.id)throw new Error(`Receiver slot ${i} contains a different item.`);const t=$r.getItem(e.id).maxStack-e.quantity;if(a.quantity>t)throw new Error(`Strict mode: not enough space in receiver slot ${i}.`)}}else if(this.#Pn.clone().addItem({itemId:a.id,quantity:a.quantity,metadata:a.metadata,forceSpace:n}).remaining>0)throw new Error("Strict mode: not enough space in receiver inventory.");if("number"==typeof i){const e=this.#Pn.existsItemAt(i)?this.#Pn.getItemFrom(i):null;let t=a.quantity;if(e){if(e.id!==a.id)throw new Error(`Receiver slot ${i} contains a different item.`);const r=$r.getItem(e.id).maxStack-e.quantity;t=Math.min(r,a.quantity),t>0&&this.#Pn.setItem({slotIndex:i,item:{...e,quantity:e.quantity+t},forceSpace:n})}else this.#Pn.setItem({slotIndex:i,item:a,forceSpace:n});l={remaining:a.quantity-t}}else l=this.#Pn.addItem({itemId:a.id,quantity:a.quantity,metadata:a.metadata,forceSpace:n});const u=a.quantity-l.remaining;if(u>0)if(t)this.#Rn.unequipItem({slotId:t,quantity:u,forceSpace:n});else if("number"==typeof e){const t=o.quantity-u;this.#Rn.setItem({slotIndex:e,item:t>0?{...o,quantity:t}:null,forceSpace:n})}return l}transferMultiple(e){return e.map(e=>this.transferItem(e))}},Or=class{#$n;#vt={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.#vt.storageKey);return e?JSON.parse(e):{}}get config(){return{...this.#vt,categories:[...this.#vt.categories]}}set config(e){this.validateConfig(e),this.#vt=Object.assign(this.#vt,e)}constructor(e){if(!e||"object"!=typeof e)throw new TypeError("Config must be an object.");this.config=e;const t=this.loadPreferences();this.#$n=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.#vt.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.#vt.animationDuration)}savePreferences(e){if(!e||"object"!=typeof e)throw new TypeError("Preferences must be an object.");localStorage.setItem(this.#vt.storageKey,JSON.stringify(e)),this.#vt.onSave(e)}showConsentBar(){const e=document.createElement("div");e.className="cookie-consent-bar",e.innerHTML=this.#vt.renderBar?this.#vt.renderBar(this.#vt):`\n <div><p>${this.#vt.message}</p></div>\n <div><button class="accept">${this.#vt.acceptText}</button></div>\n <div><button class="reject">${this.#vt.rejectText}</button></div>\n <div><button class="settings">${this.#vt.settingsText}</button></div>\n `,document.body.appendChild(e);const t=e.querySelector(".accept");t instanceof HTMLElement&&(t.onclick=()=>{const t={};this.#vt.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.#vt.categories.forEach(e=>t[e.label]=e.required),this.savePreferences(t),this.removeWithAnimation(e)});const i=e.querySelector(".settings");i instanceof HTMLElement&&(i.onclick=()=>this.showSettingsModal(e))}showSettingsModal(e){const t=document.createElement("div");t.className="cookie-consent-modal",t.innerHTML=this.#vt.renderModal?this.#vt.renderModal(this.#vt):`\n <div class="modal-content">\n <h2>Cookie Settings</h2>\n <form class="settings-form">\n ${this.#vt.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.#$n&&!!this.#$n[e]}};var Fr=r(911),Br=r(766);const zr=X("TinyI18"),Wr=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 i={};for(const t of e){if("string"!=typeof t||!t)throw new TypeError("mergeLocaleFiles: each file path must be a non-empty string");if(!(0,Br.existsSync)(t))throw new Error(`mergeLocaleFiles: file "${t}" does not exist`);const e=await(0,Fr.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(i,r)}await(0,Fr.writeFile)(t,JSON.stringify(i,null,r),"utf-8")}#h=!1;get destroyed(){return this.#h}#Hn;#On;#Fn=null;#Bn;#zn=null;#Wn=new Map;#qn=new Map;#Vn=new Map;#Kn=new Map;get currentLocale(){return zr(this.#h),this.#Fn}get defaultLocale(){return zr(this.#h),this.#On}get mode(){return zr(this.#h),this.#Hn}get strict(){return zr(this.#h),this.#Bn}get basePath(){return zr(this.#h),this.#zn}get stats(){zr(this.#h);const e=[];for(const t of this.#Wn.keys())e.push(this.getStatsForLocale(t));return e}get stringTables(){zr(this.#h);const e={};for(const[t,r]of this.#Wn.entries())e[t]=this.#Jn(r);return e}get patternTables(){zr(this.#h);const e={};for(const[t,r]of this.#qn.entries())e[t]=r.map(e=>({$pattern:new RegExp(e.$pattern.source,e.$pattern.flags),value:this.#Jn(e.value),elseValue:this.#Jn(e.elseValue)}));return e}get helpers(){zr(this.#h);const e={};for(const[t,r]of this.#Vn.entries())e[t]=r;return e}get regexCache(){zr(this.#h);const e={};for(const[t,r]of this.#Kn.entries())e[t]=new RegExp(r.source,r.flags);return e}#Jn(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.#Jn(e));if("object"==typeof e){const t={};for(const[r,i]of Object.entries(e))t[r]=this.#Jn(i);return t}return e}#Un(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.#Wn.has(e)?t.push(e):this.#Fn&&t.push(this.#Fn),t.push(this.#On),t}#Gn(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.#Wn.get(r);if(e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}}#Yn(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.#qn.get(r)||[];for(const r of e)return r.$pattern.test(t)?r.value:r.elseValue??void 0}}#Xn(e,t){if(null==e){if(this.#Bn)throw new TypeError('#materialize: "value" cannot be null or undefined');return""}if("string"==typeof e)return this.#Qn(e,t);if("function"==typeof e)return e(t??{},this.#Zn());if(e&&"object"==typeof e&&"string"==typeof e.$fn){const r=this.#Vn.get(e.$fn);if("function"!=typeof r){if(this.#Bn)throw new Error(`TinyI18: helper "${e.$fn}" is not registered`);return""}return r({...t??{},args:void 0!==e.args?e.args:void 0},this.#Zn())}if(this.#Bn)throw new Error("TinyI18: unsupported entry type");return""}#Qn(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 i=this.#es(t,r);return null==i?"":String(i)}):e}#es(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 i=e;for(const e of r){if(null==i)return;i=i[e]}return i}#Zn(){return{has:e=>this.#Vn.has(e),call:(e,t,r)=>{const i=this.#Vn.get(e);if("function"!=typeof i)throw new Error(`Helper "${e}" not found`);return i(t,r??{})}}}#ts(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.#Wn.get(e)??{}},i=[...this.#qn.get(e)??[]],n=(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 i.push({$pattern:t.$pattern,value:t.value,elseValue:t.elseValue});for(const[r,i]of Object.entries(t))n(e?`${e}.${r}`:r,i)}};n("",t),this.#Wn.set(e,r),this.#qn.set(e,i),this.#Wn.has(this.#On)||(this.#Wn.set(this.#On,{}),this.#qn.set(this.#On,[]))}#rs(e){if("string"!=typeof e||!e)throw new TypeError('#unloadLocale: "locale" must be a non-empty string');e!==this.#On&&(this.#Wn.delete(e),this.#qn.delete(e))}async#is(e){if("string"!=typeof e||!e)throw new TypeError('#loadLocaleFromFile: "locale" must be a non-empty string');if("string"!=typeof this.#zn||!this.#zn)throw new TypeError('#loadLocaleFromFile: "this.#basePath" must be a non-empty string');const t=(0,ye.join)(this.#zn,`${e}.json`);let r;try{const e=await(0,Fr.readFile)(t,"utf8");r=JSON.parse(e)}catch(r){if(!(r instanceof Error))return;if(this.#Bn)throw new Error(`TinyI18: failed to load or parse ${t}: ${r.message}`);return this.#Wn.set(e,{}),void this.#qn.set(e,[])}const i={...this.#Wn.get(e)??{}},n=[...this.#qn.get(e)??[]],s=(e,t)=>{if(null!=t){if(t&&"object"==typeof t&&"string"==typeof t.$pattern&&Object.prototype.hasOwnProperty.call(t,"value")){const e=this.#ns(t.$pattern);return void n.push({$pattern:e,value:this.#ss(t.value),elseValue:this.#ss(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");i[e]=this.#ss(t)}else if(t&&"object"==typeof t)for(const[r,i]of Object.entries(t))s(e?`${e}.${r}`:r,i)}};s("",r),this.#Wn.set(e,i),this.#qn.set(e,n)}#ns(e){if("string"!=typeof e||!e)throw new TypeError('#safeRegExp: "src" must be a non-empty string');const t=this.#Kn.get(e);if(t)return t;try{const t=new RegExp(e);return this.#Kn.set(e,t),t}catch{if(this.#Bn)throw new Error(`TinyI18: invalid regex "${e}" in file`);return/^$/}}#ss(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.#Bn)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:i,localResources:n,strict:s=!0}=e;if("local"!==t&&"file"!==t)throw new TypeError('TinyI18: "mode" must be "local" or "file"');if("string"!=typeof r||!r)throw new TypeError('TinyI18: "defaultLocale" must be a non-empty string');if("boolean"!=typeof s)throw new TypeError('TinyI18: "strict" must be a boolean');if("file"===t){if("string"!=typeof i||!i)throw new TypeError('TinyI18: "basePath" is required in file mode');this.#zn=i}if(this.#Hn=t,this.#On=r,this.#Bn=s,"local"===t&&n&&"object"==typeof n)for(const[e,t]of Object.entries(n))this.#ts(e,t);this.#Wn.has(this.#On)||(this.#Wn.set(this.#On,{}),this.#qn.set(this.#On,[]))}clearRegexCache(){zr(this.#h),this.#Kn.clear()}registerHelper(e,t){if(zr(this.#h),"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.#Vn.set(e,t)}unregisterHelper(e){if(zr(this.#h),"string"!=typeof e||!e)throw new TypeError('unregisterHelper: "name" must be non-empty string');return this.#Vn.delete(e)}loadLocaleLocal(e,t){if(zr(this.#h),"local"!==this.#Hn)throw new TypeError('loadLocaleLocal is only available in "local" mode');this.#ts(e,t)}async setLocale(e){if(zr(this.#h),null!==e&&("string"!=typeof e||!e))throw new TypeError('setLocale: "locale" must be string or null');const t=this.#Fn;null!==e&&("file"===this.#Hn?await this.#is(e):this.#Wn.has(e)||(this.#Wn.set(e,{}),this.#qn.set(e,[]))),"file"===this.#Hn&&t&&t!==this.#On&&t!==e&&this.#rs(t),this.#Fn=e}t(e,t=void 0,r=void 0){return this.get(e,t,r)}get(e,t=void 0,r=void 0){if(zr(this.#h),"string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:i}=r||{},n=this.#Un(i);let s=this.#Gn(n,e);if(void 0===s){if(this.#Bn)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return this.#Xn(s,t)}p(e,t){return this.resolveByPattern(e,t)}resolveByPattern(e,t){if(zr(this.#h),"string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:r}=t||{},i=this.#Un(r);let n=this.#Yn(i,e);if(void 0===n){if(this.#Bn)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return n}resetToDefaultOnly(){if(zr(this.#h),"file"===this.#Hn)for(const e of Array.from(this.#Wn.keys()))e!==this.#On&&this.#rs(e);this.#Fn=null}getStatsForLocale(e){if(zr(this.#h),"string"!=typeof e||!e)throw new TypeError('getStatsForLocale: "locale" must be a non-empty string');if(!this.#Wn.has(e))throw new Error(`getStatsForLocale: locale "${e}" is not registered`);return{locale:e,strings:Object.keys(this.#Wn.get(e)??{}).length,patterns:this.#qn.get(e)?.length??0,isDefault:e===this.#On,isCurrent:e===this.#Fn}}destroy(){this.#h||(this.#Wn.clear(),this.#qn.clear(),this.#Vn.clear(),this.#Kn.clear(),this.#Fn=null,this.#zn=null,this.#h=!0)}};class qr{#os=new Map;#as;#ls;#us;get factors(){const e={};for(let[t,r]of this.#os.entries())e[t]={...r};return e}get currentPercent(){return this.#ls/this.#as*100}set maxValue(e){if("number"!=typeof e||Number.isNaN(e)||e<=0)throw new TypeError("maxValue must be a positive number.");this.#as=e,this.#ls=Math.min(this.#ls,e)}get maxValue(){return this.#as}get currentValue(){return this.#ls}set infiniteValue(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("infiniteValue must be a number.");this.#us=e,this.#ls=Math.max(0,e),this.#ls=Math.min(this.#ls,this.#as)}get infiniteValue(){return this.#us}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.#as=e,this.setFactor("main",t,r),this.#ls=e,this.#us=e}getFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");const t=this.#os.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.#os.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.#os.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.#os.delete(e)}#hs(e){const t=this.#us;return this.#us-=e,this.#ls=Math.max(0,this.#ls-e),{prevValue:t,removedTotal:e,removedPercent:e/this.#as*100,currentPercent:this.currentPercent,remainingValue:this.#ls,infiniteRemaining:this.#us}}tick(){let e=0;for(let[t,r]of this.#os.entries())e+=r.amount*r.multiplier;return this.#hs(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.#os.entries())t+=r.amount*r.multiplier;return e&&(t+=e.amount*(e.multiplier??1)),this.#hs(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.#hs(t)}toJSON(){return{maxValue:this.#as,currentValue:this.#ls,infiniteValue:this.#us,factors:this.factors}}static fromJSON(e){const t=new qr(e.maxValue,0,0);t.infiniteValue=e.infiniteValue,t.#os.clear();for(const[r,i]of Object.entries(e.factors))t.setFactor(r,i.amount,i.multiplier);return t}clone(){return qr.fromJSON(this.toJSON())}clearFactors(){this.#os.clear()}}const Vr=qr;class Kr{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,i)=>{const n=i?Number(i):1;let s=0;for(let e=0;e<n;e++){const e=t[r++];s+=void 0!==e?e:0}return String(s)})}static tokenizeValues(e,t){const r=Kr.replaceValues(e,t),i=[],n=/\d+|[()+\-*/]/g;let s;for(;null!==(s=n.exec(r));)/^\d+$/.test(s[0])?i.push(Number(s[0])):i.push(s[0]);return{tokens:i,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=[],i=[];if(t.forEach((e,t)=>{const n=/\b(?:(\d+)?d(\d+))\b/g;let s;const o=[],a=e.replace(/\(([^()]+?\|[^()]+?)\)/g,(e,t)=>{const r="string"==typeof t?t.split("|").map(e=>e.trim()).filter(Boolean):[];if(0===r.length)throw new Error(`Invalid random-choice group: "${e}"`);return r[Math.floor(Math.random()*r.length)]});for(;null!==(s=n.exec(a));){const e=parseInt(s[1]||"1",10),r=parseInt(s[2],10);if(isNaN(r))throw new Error(`Invalid dice sides in expression "${s[0]}" at position ${t+1}.`);o.push({count:e,sides:r})}if(0===o.length&&Number.isNaN(parseFloat(a)))throw new Error(`Invalid dice expression at position ${t+1}: "${e}"`);r.push(...o),i.push({index:t,original:e,expression:a})}),0===r.length)throw new Error("Invalid dice amount.");return{sides:r,modifiers:i}}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 i=[],n=[...e];for(const e in t){const s=t[e];if("string"!=typeof s.expression)throw new Error("Each modifier must include an expression string.");const o=s.original,a=s.expression,l=[],u=[],h=[],c=e=>e.match(/\(\s*[^()]+\|\s*[^()]+\s*\)|\b\d*d\d+\b|[-+]?\d+(?:\.\d+)?|[+\-*/%^()]/g)||[],d=c(a),m=c(o),p=[...d],y=[],g=a.replace(/\b\d*d\d+\b/g,e=>{const t=e.split("d"),r=()=>{for(const t in d)if(d[t]===e&&y.indexOf(t)<0){y.push(t),h.push(Number(t));break}},i=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=n.shift(),s="number"==typeof t?t:f(t)?t.value:0;f(t)&&i(t),l.push([s]);for(const t in p)if(p[t]===e){p[t]=String(s),u.push(Number(t));break}return r(),s}const s=[],o=Number(t[0]),a=["("];let c="(";for(let e=0;e<o;e++){const t=n.shift(),r="number"==typeof t?t:f(t)?t.value:0;f(t)&&i(t),a.push(String(r));const l=e<o-1?" + ":")";a.push(l),c+=`${r}${l}`,s.push(r)}for(const t in p){const r=Number(t);if(p[r]===e){p.splice(r,1,...a);let e=1;for(let t=0;t<o;t++)u.push(r+t+e),e++;break}}return l.push(s),r(),c});let w;try{w=Kr._safeEvaluate(g)}catch(e){if(!(e instanceof Error))throw new Error("Unknown Error");throw new Error(`Error evaluating expression "${g}" (from "${a}"): ${e.message}`)}i.push({rawTokensP:d,rawTokens:m,tokens:p,rawDiceTokenSlots:h,diceTokenSlots:u,dicesResult:l,total:w}),r+=w}return{final:r,steps:i}}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))}#as;#cs;get maxValue(){return this.#as}set maxValue(e){if(!Number.isInteger(e)||e<0)throw new TypeError("maxValue must be an integer greater than -1.");this.#as=e}get allowZero(){return this.#cs}set allowZero(e){if("boolean"!=typeof e)throw new TypeError("allowZero must be a boolean.");this.#cs=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.#as=e,this.#cs=t}roll(){const e=this.#cs?0:1;return Math.floor(Math.random()*(this.#as-e+1))+e}}const Jr=Kr,Ur=class{#S=null;get overlay(){return this.#S}#ds=null;get messageElement(){return this.#ds}#P;get container(){return this.#P}#ms={fadeIn:null,fadeOut:null,zIndex:9999};get options(){return{...this.#ms}}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.#ms={fadeIn:e.fadeIn??null,fadeOut:e.fadeOut??null,zIndex:e.zIndex??9999}}#ps="none";get status(){return this.#ps}#fs="";get defaultMessage(){return this.#fs}set defaultMessage(e){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("defaultMessage must be a string or an HTMLElement");this.#fs=e}#ys=null;get message(){return this.#ys}#gs=!1;get allowHtmlText(){return this.#gs}set allowHtmlText(e){if("boolean"!=typeof e)throw new TypeError("allowHtmlText must be a boolean");this.#gs=e}#ws=null;get fadeInTimeout(){return null!==this.#ws}#bs=null;get fadeOutTimeout(){return null!==this.#bs}get visible(){return!!this.#S}#vs=null;get onChange(){return this.#vs}set onChange(e){if(null!==e&&"function"!=typeof e)throw new TypeError("onChange must be a function or null");this.#vs=e}_emitChange(){"function"==typeof this.#vs&&this.#vs(this.#ps)}constructor(e=document.body){if(!(e instanceof HTMLElement))throw new TypeError("container must be an HTMLElement");this.#P=e}_updateMessage(e=this.#fs){if(!this.#ds)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.#ys=e,"string"==typeof e)this.#gs?this.#ds.innerHTML=e:this.#ds.textContent=e;else{if(!this.#gs)throw new Error("HTMLElement messages require allowHtmlText = true");this.#ds.textContent="",this.#ds.appendChild(e)}}_removeOldClasses(){this.#S?.classList.remove("active"),this.#S?.classList.remove("fadeIn"),this.#S?.classList.remove("fadeOut")}start(e=this.#fs){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");if(!this.#S){this.#S=document.createElement("div"),this.#S.classList.add("loading-overlay"),this.#S.style.zIndex=String(this.#ms.zIndex);const t=document.createElement("div");t.classList.add("loading-container");const r=document.createElement("div");r.classList.add("loading-content");const i=document.createElement("div");i.classList.add("loading-spinner"),this.#ds=document.createElement("div"),this.#ds.classList.add("loading-message"),r.appendChild(i),r.appendChild(this.#ds),t.appendChild(r),this.#S.appendChild(t),this.#P.appendChild(this.#S),this._removeOldClasses(),this.#ps="fadeIn",this.#S.classList.add("fadeIn"),this._emitChange();const n=()=>{this._removeOldClasses(),this.#ws=null,this.#ps="active",this.#S?.classList.add("active"),this._emitChange()};return"number"==typeof this.#ms.fadeIn?(this.#ws&&clearTimeout(this.#ws),this.#ws=setTimeout(n,this.#ms.fadeIn)):n(),this._updateMessage(e),!0}return this.#ds&&this._updateMessage(e),!1}update(e=this.#fs){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");return!!this.#ds&&(this._updateMessage(e),!0)}stop(){if(this.#S){this._removeOldClasses(),this.#ps="fadeOut",this.#S.classList.add("fadeOut"),this._emitChange();const e=()=>{this._removeOldClasses(),this.#bs=null,this.#ps="none",this.#S?.remove(),this.#S=null,this.#ds=null,this.#ys=null,this._emitChange()};return"number"==typeof this.#ms.fadeOut?(this.#bs&&clearTimeout(this.#bs),this.#bs=setTimeout(e,this.#ms.fadeOut)):e(),!0}return!1}};class Gr{static#Es=/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;static#Ts=/^#([A-Fa-f0-9]{8})$/;static#Ss="(0|1|0?\\.\\d+)";static#xs="(0|[1-9]\\d?|1\\d{2}|2[0-4]\\d|25[0-5])";static#As="(0|[1-9]\\d?|[1-2]\\d{2}|3[0-5]\\d|360)";static#Cs="(0|[1-9]?\\d|100)";static#Is=new RegExp(`^rgb\\(\\s*${Gr.#xs}\\s*,\\s*${Gr.#xs}\\s*,\\s*${Gr.#xs}\\s*\\)$`);static#Ds=new RegExp(`^rgba\\(\\s*${Gr.#xs}\\s*,\\s*${Gr.#xs}\\s*,\\s*${Gr.#xs}\\s*,\\s*${Gr.#Ss}\\s*\\)$`);static#Ms=new RegExp(`^hsl\\(\\s*${Gr.#As}\\s*,\\s*${Gr.#Cs}%\\s*,\\s*${Gr.#Cs}%\\s*\\)$`);static#Ns=new RegExp(`^hsla\\(\\s*${Gr.#As}\\s*,\\s*${Gr.#Cs}%\\s*,\\s*${Gr.#Cs}%\\s*,\\s*${Gr.#Ss}\\s*\\)$`);static#ks=new RegExp(`^hwb\\(\\s*${Gr.#As}(deg|grad|rad|turn)?\\s*${Gr.#Cs}%\\s*${Gr.#Cs}%\\s*\\)$`);static#Ls="(-?\\d+)";static#_s=new RegExp(`^lab\\(\\s*${Gr.#Cs}%?\\s*${Gr.#Ls}%?\\s*${Gr.#Ls}%?\\s*\\)$`);static#js=new RegExp(`^lch\\(\\s*${Gr.#Cs}%?\\s*${Gr.#Cs}%?\\s*${Gr.#As}(deg|grad|rad|turn)?\\s*\\)$`);static#Rs=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#Ps=new Set(["transparent","currentColor"]);static getNames(){return Array.from(Gr.#Rs)}static addName(e){const t=Gr.#Rs.size;return Gr.#Rs.add(e.toLowerCase()),Gr.#Rs.size>t}static removeName(e){return Gr.#Rs.delete(e.toLowerCase())}static hasName(e){return Gr.#Rs.has(e.toLowerCase())}static getSpecialNames(){return Array.from(Gr.#Ps)}static addSpecialName(e){const t=Gr.#Ps.size;return Gr.#Ps.add(e),Gr.#Ps.size>t}static removeSpecialName(e){return Gr.#Ps.delete(e)}static hasSpecialName(e){return Gr.#Ps.has(e)}#$s;get code(){return this.#$s}#Hs;get type(){return this.#Hs}constructor(e){this.#$s=e,this.#Hs=Gr.isColor(this.#$s)}static isHex(e){if("string"!=typeof e)throw new TypeError("isHex: input must be a string.");return Gr.#Es.test(e.trim())}isHex(){return Gr.isHex(this.#$s)}static isHexa(e){if("string"!=typeof e)throw new TypeError("isHexa: input must be a string.");return Gr.#Ts.test(e.trim())}isHexa(){return Gr.isHexa(this.#$s)}static isRgb(e){if("string"!=typeof e)throw new TypeError("isRgb: input must be a string.");return Gr.#Is.test(e.trim())}isRgb(){return Gr.isRgb(this.#$s)}static isRgba(e){if("string"!=typeof e)throw new TypeError("isRgba: input must be a string.");return Gr.#Ds.test(e.trim())}isRgba(){return Gr.isRgba(this.#$s)}static isHsl(e){if("string"!=typeof e)throw new TypeError("isHsl: input must be a string.");return Gr.#Ms.test(e.trim())}isHsl(){return Gr.isHsl(this.#$s)}static isHsla(e){if("string"!=typeof e)throw new TypeError("isHsla: input must be a string.");return Gr.#Ns.test(e.trim())}isHsla(){return Gr.isHsla(this.#$s)}static isHwb(e){if("string"!=typeof e)throw new TypeError("isHwb: input must be a string.");return Gr.#ks.test(e.trim())}isHwb(){return Gr.isHwb(this.#$s)}static isLab(e){if("string"!=typeof e)throw new TypeError("isLab: input must be a string.");return Gr.#_s.test(e.trim())}isLab(){return Gr.isLab(this.#$s)}static isLch(e){if("string"!=typeof e)throw new TypeError("isLch: input must be a string.");return Gr.#js.test(e.trim())}isLch(){return Gr.isLch(this.#$s)}static isName(e){if("string"!=typeof e)throw new TypeError("isName: input must be a string.");return Gr.#Rs.has(e.trim().toLowerCase())}isName(){return Gr.isName(this.#$s)}static isSpecialName(e){if("string"!=typeof e)throw new TypeError("isSpecialName: input must be a string.");return Gr.#Ps.has(e.trim())}isSpecialName(){return Gr.isSpecialName(this.#$s)}static isColor(e){if("string"!=typeof e)throw new TypeError("isColor: input must be a string.");return Gr.isHex(e)?"hex":Gr.isHexa(e)?"hexa":Gr.isRgb(e)?"rgb":Gr.isRgba(e)?"rgba":Gr.isHsl(e)?"hsl":Gr.isHsla(e)?"hsla":Gr.isHwb(e)?"hwb":Gr.isLab(e)?"lab":Gr.isLch(e)?"lch":Gr.isName(e)?"name":Gr.isSpecialName(e)?"specialName":null}parse(){switch(this.#Hs){case"hex":return Gr.parseHex(this.code);case"hexa":return Gr.parseHexa(this.code);case"rgb":return Gr.parseRgb(this.code);case"rgba":return Gr.parseRgba(this.code);case"hsl":return Gr.parseHsl(this.code);case"hsla":return Gr.parseHsla(this.code);case"hwb":return Gr.parseHwb(this.code);case"lab":return Gr.parseLab(this.code);case"lch":return Gr.parseLch(this.code);case"name":case"specialName":return this.#$s.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(Gr.#Es,"gm").exec(e.trim());return t?t[1]:null}parseHex(){return Gr.parseHex(this.#$s)}static parseHexa(e){if("string"!=typeof e)throw new TypeError("parseHexa: input must be a string.");const t=new RegExp(Gr.#Ts,"gm").exec(e.trim());return t?t[1]:null}parseHexa(){return Gr.parseHexa(this.#$s)}static parseRgb(e){if("string"!=typeof e)throw new TypeError("parseRgb: input must be a string.");const t=new RegExp(Gr.#Is,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseRgb(){return Gr.parseRgb(this.#$s)}static parseRgba(e){if("string"!=typeof e)throw new TypeError("parseRgba: input must be a string.");const t=new RegExp(Gr.#Ds,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])]:null}parseRgba(){return Gr.parseRgba(this.#$s)}static parseHsl(e){if("string"!=typeof e)throw new TypeError("parseHsl: input must be a string.");const t=new RegExp(Gr.#Ms,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseHsl(){return Gr.parseHsl(this.#$s)}static parseHsla(e){if("string"!=typeof e)throw new TypeError("parseHsla: input must be a string.");const t=new RegExp(Gr.#Ns,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])]:null}parseHsla(){return Gr.parseHsla(this.#$s)}static parseHwb(e){if("string"!=typeof e)throw new TypeError("parseHwb: input must be a string.");const t=new RegExp(Gr.#ks,"gm").exec(e.trim());return t?[parseFloat(t[1]),t[2]??null,parseFloat(t[3]),parseFloat(t[4])]:null}parseHwb(){return Gr.parseHwb(this.#$s)}static parseLab(e){if("string"!=typeof e)throw new TypeError("parseLab: input must be a string.");const t=new RegExp(Gr.#_s,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseLab(){return Gr.parseLab(this.#$s)}static parseLch(e){if("string"!=typeof e)throw new TypeError("parseLch: input must be a string.");const t=new RegExp(Gr.#js,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),t[4]??null]:null}parseLch(){return Gr.parseLch(this.#$s)}}const Yr=Gr,Xr=X("TinyAnalogClock"),Qr=class{#Os;#Fs;#Bs;#vt;#oi=null;#h=!1;get destroyed(){return this.#h}_getDate(){const e=new Date,t=e.getSeconds(),r=e.getMinutes(),i=e.getHours();return{now:e,s:t,m:r,h:i}}constructor(e={}){this.#vt={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.#Os=document.createElement("div"),this.#Os.className="analog-clock-container",this.#Os.style.position="relative",this.#Os.style.borderRadius="50%",this.#Os.style.overflow="hidden",this.#Os.style.boxSizing="border-box",this.#Bs=document.createElement("div"),this.#Bs.style.position="absolute",this.#Bs.style.inset="0",this.#Bs.style.backgroundSize="cover",this.#Bs.style.backgroundPosition="center",this.#Bs.style.zIndex="0",this.#Fs=document.createElement("div"),this.#Fs.style.position="absolute",this.#Fs.style.inset="0",this.#Fs.style.zIndex="1",this.#Fs.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.#Os.appendChild(this.#Bs),this.#Os.appendChild(this.#Fs),this.#Os.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.#Os.appendChild(r),this._applyConfig(),this._renderFace(),this._startTicker()}_applyConfig(){const e=this.#Os.style,t=this.#vt;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.#Bs.style.backgroundImage=`url(${t.skinUrl})`,this.#Bs.style.display="block"):this.#Bs.style.display="none";const r=e=>{const t=this.#Os.querySelector(e);if(!(t instanceof HTMLDivElement))throw new Error(`TinyAnalogClock: Element ${e} not found.`);return t},i=r(".hour-hand");i.style.backgroundColor=t.hourHandColor,i.style.width=.025*t.size+"px",i.style.height=.25*t.size+"px",i.style.marginLeft=.025*t.size/-2+"px",i.style.bottom="50%",i.style.left="50%",i.style.transformOrigin="bottom center";const n=r(".minute-hand");n.style.backgroundColor=t.minuteHandColor,n.style.width=.015*t.size+"px",n.style.height=.35*t.size+"px",n.style.marginLeft=.015*t.size/-2+"px";const s=r(".second-hand");t.showSeconds?(s.style.display="block",s.style.backgroundColor=t.secondHandColor,s.style.width=.005*t.size+"px",s.style.height=.4*t.size+"px",s.style.marginLeft=.005*t.size/-2+"px"):s.style.display="none",r(".center-pin").style.background=t.borderColor}_renderFace(){this.#Fs.innerHTML="";const e=this.#vt.size/2-this.#vt.borderWidth;for(let t=0;t<60;t++){const r=t%5==0,i=document.createElement("div");i.className="clock-mark";const n=r?this.#vt.size*this.#vt.pwH:this.#vt.size*this.#vt.pwM,s=r?this.#vt.size*this.#vt.phH:this.#vt.size*this.#vt.phM,o=this.#vt.markColor;i.style.width=`${n}px`,i.style.height=`${s}px`,i.style.color=o;const a=e-this.#vt.padding-s/2;i.style.transform=`translate(-50%, -50%) rotate(${6*t}deg) translate(0, -${a}px)`,this.#Fs.appendChild(i)}if(this.#vt.showNumbers)for(let t=1;t<=12;t++){const r=30*t*(Math.PI/180),i=e*this.#vt.angleDistance,n=e+Math.sin(r)*i,s=e-Math.cos(r)*i,o=document.createElement("div");o.className="clock-number",o.innerText=t.toString(),o.style.left=`${n}px`,o.style.top=`${s}px`,o.style.color=this.#vt.textColor,o.style.fontSize=this.#vt.size*this.#vt.sizeAdjust+"px",this.#Fs.appendChild(o)}}_startTicker(){if(this.#oi)return;const e=()=>{const{s:t,m:r,h:i}=this._getDate(),n=6*t,s=6*r+.1*t,o=i%12*30+.5*r,a=e=>{const t=this.#Os.querySelector(e);if(!(t instanceof HTMLDivElement))throw new Error(`${e} not found.`);return t};this.#Os.querySelector(".second-hand")&&(a(".second-hand").style.transform=`rotate(${n}deg)`),a(".minute-hand").style.transform=`rotate(${s}deg)`,a(".hour-hand").style.transform=`rotate(${o}deg)`,this.#oi=requestAnimationFrame(e)};e()}get element(){return Xr(this.#h),this.#Os}set size(e){if(Xr(this.#h),"number"!=typeof e||e<=0||isNaN(e))throw new Error(`TinyAnalogClock: 'size' must be a positive number. Received: ${e}`);this.#vt.size=e,this._applyConfig(),this._renderFace()}get size(){return Xr(this.#h),this.#vt.size}set skinUrl(e){if(Xr(this.#h),null!==e&&"string"!=typeof e)throw new Error("TinyAnalogClock: 'skin' must be a URL string or null. Received type: "+typeof e);this.#vt.skinUrl=e,this._applyConfig()}get skinUrl(){return Xr(this.#h),this.#vt.skinUrl}set borderColor(e){if(Xr(this.#h),"string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'borderColor' must be a non-empty string. Received: ${e}`);this.#vt.borderColor=e,this._applyConfig(),this._renderFace()}get borderColor(){return Xr(this.#h),this.#vt.borderColor}set markColor(e){if(Xr(this.#h),"string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'markColor' must be a non-empty string. Received: ${e}`);this.#vt.markColor=e,this._applyConfig(),this._renderFace()}get markColor(){return Xr(this.#h),this.#vt.markColor}set textColor(e){if(Xr(this.#h),"string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'textColor' must be a non-empty string. Received: ${e}`);this.#vt.textColor=e,this._applyConfig(),this._renderFace()}get textColor(){return Xr(this.#h),this.#vt.textColor}set showNumbers(e){if(Xr(this.#h),"boolean"!=typeof e)throw new Error("TinyAnalogClock: 'showNumbers' must be a boolean. Received type: "+typeof e);this.#vt.showNumbers=e,this._renderFace()}get showNumbers(){return Xr(this.#h),this.#vt.showNumbers}set bgColor(e){if(Xr(this.#h),"string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'bgColor' must be a non-empty string.");this.#vt.bgColor=e,this._applyConfig()}get bgColor(){return Xr(this.#h),this.#vt.bgColor}set borderWidth(e){if(Xr(this.#h),"number"!=typeof e||e<0)throw new Error("TinyAnalogClock: 'borderWidth' must be a non-negative number.");this.#vt.borderWidth=e,this._applyConfig(),this._renderFace()}get borderWidth(){return Xr(this.#h),this.#vt.borderWidth}set hourHandColor(e){if(Xr(this.#h),"string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'hourHandColor' must be a non-empty string.");this.#vt.hourHandColor=e,this._applyConfig()}get hourHandColor(){return Xr(this.#h),this.#vt.hourHandColor}set minuteHandColor(e){if(Xr(this.#h),"string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'minuteHandColor' must be a non-empty string.");this.#vt.minuteHandColor=e,this._applyConfig()}get minuteHandColor(){return Xr(this.#h),this.#vt.minuteHandColor}set secondHandColor(e){if(Xr(this.#h),"string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'secondHandColor' must be a non-empty string.");this.#vt.secondHandColor=e,this._applyConfig()}get secondHandColor(){return Xr(this.#h),this.#vt.secondHandColor}set showSeconds(e){if(Xr(this.#h),"boolean"!=typeof e)throw new Error("TinyAnalogClock: 'showSeconds' must be a boolean.");this.#vt.showSeconds=e,this._applyConfig()}get showSeconds(){return Xr(this.#h),this.#vt.showSeconds}set sizeAdjust(e){if(Xr(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'sizeAdjust' must be a positive number.");this.#vt.sizeAdjust=e,this._renderFace()}get sizeAdjust(){return Xr(this.#h),this.#vt.sizeAdjust}set padding(e){if(Xr(this.#h),"number"!=typeof e||e<0)throw new Error("TinyAnalogClock: 'padding' must be a non-negative number.");this.#vt.padding=e,this._renderFace()}get padding(){return Xr(this.#h),this.#vt.padding}set angleDistance(e){if(Xr(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'angleDistance' must be a positive number.");this.#vt.angleDistance=e,this._renderFace()}get angleDistance(){return Xr(this.#h),this.#vt.angleDistance}set pwH(e){if(Xr(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'pwH' must be a positive number.");this.#vt.pwH=e,this._renderFace()}get pwH(){return Xr(this.#h),this.#vt.pwH}set phH(e){if(Xr(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'phH' must be a positive number.");this.#vt.phH=e,this._renderFace()}get phH(){return Xr(this.#h),this.#vt.phH}set pwM(e){if(Xr(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'pwM' must be a positive number.");this.#vt.pwM=e,this._renderFace()}get pwM(){return Xr(this.#h),this.#vt.pwM}set phM(e){if(Xr(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'phM' must be a positive number.");this.#vt.phM=e,this._renderFace()}get phM(){return Xr(this.#h),this.#vt.phM}destroy(){this.#h||(this.#oi&&(cancelAnimationFrame(this.#oi),this.#oi=null),this.#Os.remove(),this.#h=!0)}},Zr=X("TinyTextDiffer"),ei=class{#zs=[];#h=!1;get destroyed(){return this.#h}get history(){return Zr(this.#h),[...this.#zs]}set history(e){if(Zr(this.#h),!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.#zs=[...e]}get size(){return Zr(this.#h),this.#zs.length}constructor(e=[]){this.history=e}#Ws(e){if("number"!=typeof e)throw new TypeError("The provided index must be a valid number.")}#qs(e){if("string"!=typeof e)throw new TypeError("The provided text must be a valid string.")}get(e){if(Zr(this.#h),this.#Ws(e),void 0===this.#zs[e])throw new Error(`No text version found at index ${e}.`);return this.#zs[e]}has(e){return Zr(this.#h),this.#Ws(e),void 0!==this.#zs[e]}add(e){Zr(this.#h),this.#qs(e),this.#zs.push(e)}remove(){return Zr(this.#h),this.#zs.pop()}addAt(e,t){Zr(this.#h),this.#Ws(e),this.#qs(t),this.#zs.splice(e,0,t)}removeAt(e){Zr(this.#h),this.#Ws(e);const t=this.#zs.length;return this.#zs.splice(e,1),t!==this.#zs.length}clear(){Zr(this.#h),this.#zs=[]}compare(...e){Zr(this.#h);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 i=0;i<t;i+=2){const n=i+1;if(n>t-1)continue;this.#Ws(e[i]),this.#Ws(e[n]);const s=this.#zs[e[i]],o=this.#zs[e[n]];r.push(this._computeDiff(s,o))}return r}_computeDiff(e,t){const r=e.length,i=t.length,n=Array(r+1).fill(null).map(()=>Array(i+1).fill(0));let s=1,o=1;for(s=1;s<=r;s++)for(o=1;o<=i;o++)e[s-1]===t[o-1]?n[s][o]=n[s-1][o-1]+1:n[s][o]=Math.max(n[s-1][o],n[s][o-1]);s=r,o=i;const a=[];for(;s>0||o>0;)s>0&&o>0&&e[s-1]===t[o-1]?(a.unshift({value:e[s-1],type:"normal"}),s--,o--):o>0&&(0===s||n[s][o-1]>=n[s-1][o])?(a.unshift({value:t[o-1],type:"added"}),o--):s>0&&(0===o||n[s][o-1]<n[s-1][o])&&(a.unshift({value:e[s-1],type:"deleted"}),s--);return a.reduce((e,t)=>{const r=e.length-1;return e.length>0&&e[r].type===t.type?e[r].value+=t.value:e.push(t),e},[])}destroy(){this.#h||(this.#zs=[],this.#h=!0)}};class ti{static generateHash(e){const t="object"==typeof e?JSON.stringify(e):String(e);let r=0;for(let e=0,i=t.length;e<i;e++)r=(r<<5)-r+t.charCodeAt(e),r|=0;return r.toString(36)}#Vs=[];get oldArray(){return this.#Vs}set oldArray(e){if(!Array.isArray(e))throw new TypeError("The provided oldArray must be a valid Array.");this.#Vs=e}constructor(e){void 0!==e&&(this.oldArray=e)}_generateHash(e){return ti.generateHash(e)}compare(e){if(!Array.isArray(e))throw new TypeError("The provided newArray must be a valid Array.");const t={oldItemsMap:new Map,affectedItems:[]};for(const e of this.#Vs){const r=this._generateHash(e);t.oldItemsMap.set(r,e)}for(const r of e){const e=this._generateHash(r);t.oldItemsMap.has(e)?t.oldItemsMap.delete(e):t.affectedItems.push({item:r,status:"added"})}for(const e of t.oldItemsMap.values())t.affectedItems.push({item:e,status:"deleted"});return t.affectedItems}}const ri=ti,ii=e=>{if(!Array.isArray(e))throw new TypeError("Parameter 'sets' must be an array.");if(!e.every(e=>e instanceof ai))throw new TypeError("All elements in the array must be instances of FuzzySet.")},ni=(e,t,r=.5)=>{oi(e,"object","defuzzifyCentroid.fuzzyOutput");for(const t in e)oi(e[t],"number",`fuzzyOutput['${t}']`);ii(t),oi(r,"number","defuzzifyCentroid.step");let i=0,n=0;for(let s=0;s<=100;s+=r){let r=0;t.forEach(t=>{const i=e[t.name]||0,n=Math.min(i,t.calculate(s));r=Math.max(r,n)}),i+=s*r,n+=r}return 0===n?0:i/n},si=(e,t,r,i,n,s=!1)=>{if(s){if(e<=t||e>=n)return 0;if(e>=r&&e<=i)return 1}const o=t===r?1:(e-t)/(r-t),a=i===n?1:(n-e)/(n-i),l=Math.max(0,Math.min(o,1,a));return isNaN(l)?0:l},oi=(e,t,r)=>{if(typeof e!==t)throw new TypeError(`Parameter '${r}' must be a ${t}.`)};class ai{static trapezoid(e,t,r,i,n,s=!1){return si(e,t,r,i,n,s)}#Ks="";#Js=0;#Us=0;#Gs=0;#Ys=0;#Xs=!1;get name(){return this.#Ks}set name(e){oi(e,"string","FuzzySet.name"),this.#Ks=e}get a(){return this.#Js}set a(e){oi(e,"number","FuzzySet.a"),this.#Js=e}get b(){return this.#Us}set b(e){oi(e,"number","FuzzySet.b"),this.#Us=e}get c(){return this.#Gs}set c(e){oi(e,"number","FuzzySet.c"),this.#Gs=e}get d(){return this.#Ys}set d(e){oi(e,"number","FuzzySet.d"),this.#Ys=e}get optimize(){return this.#Xs}set optimize(e){oi(e,"boolean","FuzzySet.optimize"),this.#Xs=e}constructor(e,t,r,i,n,s=!1){this.name=e,this.a=t,this.b=r,this.c=i,this.d=n,this.optimize=s}calculate(e){return oi(e,"number","calculate.x"),ai.trapezoid(e,this.#Js,this.#Us,this.#Gs,this.#Ys,this.#Xs)}}class li{#Qs=new Map;addVariable(e,t){oi(e,"string","addVariable.name"),ii(t),this.#Qs.set(e,t)}removeVariable(e){return oi(e,"string","removeVariable.name"),this.#Qs.delete(e)}getVariable(e){oi(e,"string","getVariable.name");const t=this.#Qs.get(e);if(!t)throw new Error(`Linguistic variable '${e}' not found in the inference system.`);return[...t]}hasVariable(e){return oi(e,"string","hasVariable.name"),this.#Qs.has(e)}fuzzify(e,t){oi(e,"string","fuzzify.varName"),oi(t,"number","fuzzify.value");const r=this.#Qs.get(e)||[],i={};return r.forEach(e=>{i[e.name]=e.calculate(t)}),i}}class ui{#Zs=new Set;get appliedPlugins(){if(this.#eo)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return[...this.#Zs]}#to=[];get appliedPluginClasses(){if(this.#eo)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return[...this.#to]}get size(){if(this.#eo)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return this.#to.length}#ro;get currentClass(){if(this.#eo)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return this.#ro}#eo=!1;get used(){return this.#eo}constructor(e,t=[]){this.#ro=e,this.#to=[...t,e]}#io(e,t,r){if(this.#eo)throw new Error("[TinyClassManager] Cannot reuse a consumed manager instance.");if(this.#Zs.has(e))throw new Error(`[TinyClassManager] Plugin conflict: "${e}" is already installed.`);for(const r of t)if(!this.#Zs.has(r))throw new Error(`[TinyClassManager] Missing Dependency: "${e}" requires "${r}" to be installed first.`);const i=new ui(r,this.#to);return this.#Zs.forEach(e=>i.#Zs.add(e)),i.#Zs.add(e),this.#eo=!0,this.#Zs.clear(),this.#to=[],i}use(e){const t=e.dependencies||[],r=e.apply(this.#ro,this.appliedPluginClasses);return this.#io(e.name,t,r)}insert(e){const t=e(this.#ro,this.appliedPluginClasses),r=t._tinyDepName;if(!r)throw new Error("[TinyClassManager] Plugin class must define a static '_tinyDepName' property.");const i=t._tinyDeps??[];if(!Array.isArray(i)||!i.every(e=>"string"==typeof e))throw new Error("[TinyClassManager] Plugin class must define a static array of strings in '_tinyDepName' property.");return this.#io(r,i,t)}build(){if(this.#eo)throw new Error("[TinyClassManager] Cannot build from an already finalized manager.");return this.#eo=!0,this.#Zs.clear(),this.#to=[],this.#ro}}const hi=ui,ci=X("TinyRadioFm");class di extends tr.EventEmitter{static async parseContent(e,t,r,i,n){return Wt(e,t,r,i,n,di.#no)}static#no="Unknown Artist";static get unknownArtist(){return di.#no}static set unknownArtist(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("unknownArtist must have an string or function.");di.#no=e}#h=!1;get destroyed(){return this.#h}get size(){return ci(this.#h),this.#so.length+this.#oo.length}get musicSize(){return ci(this.#h),this.#so.length}get voiceSize(){return ci(this.#h),this.#oo.length}get customPosSize(){return ci(this.#h),this.#ao.length}get tasksSize(){return ci(this.#h),this.#lo.length}get cycleCacheSize(){return ci(this.#h),this.#uo.size}#so=[];get musicList(){return ci(this.#h),structuredClone(this.#so)}#oo=[];get voiceList(){return ci(this.#h),structuredClone(this.#oo)}#ao=[];get customPositions(){return ci(this.#h),structuredClone(this.#ao)}#lo=[];get scheduledTasks(){return ci(this.#h),structuredClone(this.#lo)}get allList(){return ci(this.#h),[...this.musicList,...this.voiceList]}#fn=0;get seed(){return ci(this.#h),this.#fn}set seed(e){if(ci(this.#h),"number"!=typeof e)throw new TypeError("Seed must be a number.");this.#fn=e,this.#uo.clear(),this.emit("seedChanged",{seed:e})}#ho=Date.now();get anchorDate(){return ci(this.#h),this.#ho}#uo=new Map;#vt={mode:"playlist",voiceMode:"playlist",silenceDuration:0,queryLimit:1e5,voiceAfterMusic:!0,voiceMin:0,voiceMax:1,musicMaxConsecutive:0,voiceMaxConsecutive:0};get config(){return ci(this.#h),structuredClone(this.#vt)}set config(e){ci(this.#h),this.#co(e),this.#vt=structuredClone(e),this.#uo.clear(),this.emit("configChanged",{config:this.config})}#co(e){if("object"!=typeof e||null===e)throw new TypeError("Configuration must be a valid object.");const t=["playlist","random"];if(void 0!==e.mode&&!t.includes(e.mode))throw new TypeError(`Invalid mode: "${e.mode}". Must be one of: ${t.join(", ")}.`);if(void 0!==e.voiceMode&&!t.includes(e.voiceMode))throw new TypeError(`Invalid voiceMode: "${e.voiceMode}". Must be one of: ${t.join(", ")}.`);if(void 0!==e.silenceDuration&&("number"!=typeof e.silenceDuration||e.silenceDuration<0))throw new TypeError("silenceDuration must be a non-negative number.");if(void 0!==e.queryLimit&&("number"!=typeof e.queryLimit||e.queryLimit<=0))throw new TypeError("queryLimit must be a positive number.");if(void 0!==e.voiceAfterMusic&&"boolean"!=typeof e.voiceAfterMusic)throw new TypeError("voiceAfterMusic must be a boolean.");if(void 0!==e.voiceMin&&("number"!=typeof e.voiceMin||e.voiceMin<0))throw new TypeError("voiceMin must be a non-negative number.");if(void 0!==e.voiceMax&&("number"!=typeof e.voiceMax||e.voiceMax<0))throw new TypeError("voiceMax must be a non-negative number.");if(void 0!==e.musicMaxConsecutive&&("number"!=typeof e.musicMaxConsecutive||e.musicMaxConsecutive<-1))throw new TypeError("musicMaxConsecutive must be a number >= -1.");if(void 0!==e.voiceMaxConsecutive&&("number"!=typeof e.voiceMaxConsecutive||e.voiceMaxConsecutive<-1))throw new TypeError("voiceMaxConsecutive must be a number >= -1.");const r=e.voiceMin??this.#vt.voiceMin,i=e.voiceMax??this.#vt.voiceMax;if(i<r)throw new RangeError(`Logical error: voiceMax (${i}) cannot be less than voiceMin (${r}).`)}constructor(e=null,t=0){if(super(),null!==e&&"object"!=typeof e)throw new TypeError("initialData must be an object or null.");if("number"!=typeof t)throw new TypeError("seed must be a number.");this.#fn=t,e?this.#do(e):this.#ho=Date.now()}add(e,t,r=!0){if(ci(this.#h),!["music","voice","custom"].includes(e))throw new TypeError('Type must be "music", "voice", or "custom".');if(!t||"string"!=typeof t.id||"number"!=typeof t.duration)throw new TypeError("Content must have a string ID and a valid numerical duration in milliseconds.");if("boolean"!=typeof r)throw new TypeError("smartQueue must be a boolean.");"music"===e?(this.#so.push(t),this.#uo.clear()):"voice"===e?(this.#oo.push(t),this.#uo.clear()):"custom"===e&&this.#mo(t,r),this.#po(Date.now()),this.emit("contentAdded",{type:e,data:structuredClone(t)})}scheduleTask(e,t,r,i,n=!0){if(ci(this.#h),"number"!=typeof e||isNaN(e))throw new TypeError("timestamp must be a valid number.");if(!["add","remove","move"].includes(t))throw new TypeError('action must be "add", "remove", or "move".');if(!["music","voice"].includes(r))throw new TypeError('type must be "music" or "voice".');if("boolean"!=typeof n)throw new TypeError("smartQueue must be a boolean.");if("add"===t){if("object"!=typeof i||null===i||"string"!=typeof i.id||"number"!=typeof i.duration)throw new TypeError('Payload for "add" must be a MediaContent object (id: string, duration: number).')}else if("remove"===t){if("string"!=typeof i)throw new TypeError('Payload for "remove" must be a string (the content ID).')}else if("move"===t&&("object"!=typeof i||null===i||"string"!=typeof i.id||"number"!=typeof i.newIndex))throw new TypeError('Payload for "move" must be a ScheduledMovePayload (id: string, newIndex: number).');let s=e;if(n){const t=this.#fo(e,e);t&&(s=t.absoluteEnd)}const o={timestamp:s,action:t,type:r,payload:i};this.#lo.push(o),this.#po(Date.now()),this.emit("taskScheduled",structuredClone(o))}remove(e){if(ci(this.#h),"string"!=typeof e)throw new TypeError("id must be a string.");this.#so.filter(t=>t.id===e).forEach(e=>Ht(e)),this.#oo.filter(t=>t.id===e).forEach(e=>Ht(e)),this.#ao.filter(t=>t.content?.id===e).forEach(e=>Ht(e.content));const t=t=>t.id!==e&&t.content?.id!==e;this.#so=this.#so.filter(t),this.#oo=this.#oo.filter(t),this.#ao=this.#ao.filter(t),this.#lo=this.#lo.filter(t=>"add"===t.action&&"object"==typeof t.payload&&null!==t.payload&&"id"in t.payload?t.payload.id!==e||(Ht(t.payload),!1):t.payload!==e),this.#uo.clear(),this.emit("contentRemoved",{id:e})}setConfig(e){ci(this.#h),this.#co(e);const t={...this.#vt,...e};this.#co(t),this.#vt=t,this.#uo.clear(),this.emit("configChanged",{config:this.config})}getCurrentEvent(){ci(this.#h);const e=Date.now();return this.#po(e),this.#fo(e,e)}queryTimeline(e,t=10){if(ci(this.#h),"number"!=typeof t||isNaN(t))throw new TypeError("Invalid query limit value. Ensure it is a number.");if(t>this.#vt.queryLimit||t<=0)throw new RangeError(`Invalid query limit. Ensure it is > 0 and <= ${this.#vt.queryLimit}.`);const r=new di(JSON.parse(this._exportState())),i=[];let n=e;for(let s=0;s<t;s++){r.#po(n);const t=r.#yo(n,e);if(!t)break;i.push(t),n=t.absoluteEnd}return r.destroy(!1),this.emit("timelineQueried",{targetDate:e,limit:t,resultCount:i.length}),i}searchCustomPositions(){return ci(this.#h),this.#po(Date.now()),[...this.#ao]}async _processListForExport(e){return Promise.all(e.map(async e=>{const t=structuredClone(e);return t.picture&&Array.isArray(t.picture)&&(t.picture=await Promise.all(t.picture.map(async e=>"string"==typeof e.data&&e.data.startsWith("blob:")?{...e,data:await $t(e.data)}:e))),t}))}_exportState(){return JSON.stringify({music:this.#so,voice:this.#oo,custom:this.#ao,tasks:this.#lo,seed:this.#fn,anchorDate:this.#ho,config:this.#vt})}async exportState(){ci(this.#h);const e=await this._processListForExport(this.#so),t=await this._processListForExport(this.#oo),r=await Promise.all(this.#ao.map(async e=>{const t=await this._processListForExport([e.content]);return{...e,content:t[0]}})),i=await Promise.all(this.#lo.map(async e=>{if("add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload){const t=await this._processListForExport([e.payload]);return{...e,payload:t[0]}}return e}));return JSON.stringify({music:e,voice:t,custom:r,tasks:i,seed:this.#fn,anchorDate:this.#ho,config:this.#vt})}importState(e){let t;if(ci(this.#h),"string"==typeof e)try{t=JSON.parse(e)}catch{throw new TypeError("Provided string is not valid JSON.")}else{if("object"!=typeof e||null===e)throw new TypeError("Import data must be a valid JSON string or an object.");t=e}this.#do(t),this.emit("stateImported",{data:structuredClone(t)})}_prng(e){return function(){let t=e+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}#go(e,t,r,i=0){if(0===e.length)return[];if("random"!==r)return[...e];const n=e.map(e=>({...e,weight:e.weight??1})),s=this._prng(t),o=[];let a=null,l=0;for(;n.length>0;){let e=n;-1!==i&&null!==a&&l>i&&(e=n.filter(e=>e.id!==a),0===e.length&&(e=n));const t=e.reduce((e,t)=>e+t.weight,0);if(t<=0){o.push(...e);break}const r=s()*t;let u=0,h=null,c=-1;for(let t=0;t<e.length;t++)if(u+=e[t].weight,r<=u){h=e[t],c=n.findIndex(e=>h&&e.id===h.id);break}h&&-1!==c||(h=e[0],c=n.findIndex(e=>h&&e.id===h.id)),o.push(h),n.splice(c,1),h.id===a?l++:(a=h.id,l=1)}return o}#wo(e){const t=this.#fn+e,r=this._prng(10*t),i=this.#go(this.#so,t+1,this.#vt.mode,this.#vt.musicMaxConsecutive),n=this.#go(this.#oo,t+2,this.#vt.voiceMode,this.#vt.voiceMaxConsecutive),s=[];let o=0,a=0;for(let e=0;e<i.length;e++){const t=i[e];if(s.push({...t,cycleStart:o,cycleEnd:o+t.duration}),o+=t.duration+this.#vt.silenceDuration,this.#vt.voiceAfterMusic&&n.length>0){const e=this.#vt.voiceMax-this.#vt.voiceMin+1,t=Math.floor(r()*e)+this.#vt.voiceMin;for(let e=0;e<t;e++){const e=n[a%n.length];a++,s.push({...e,cycleStart:o,cycleEnd:o+e.duration}),o+=e.duration+this.#vt.silenceDuration}}}return{items:s,duration:o}}#bo(e){if(0===this.#so.length)return null;let t=this.#ho,r=0;for(;;){if(r>this.#vt.queryLimit)throw new Error("Safety limit hit during cycle location.");let i=this.#uo.get(r);if(i||(i=this.#wo(r),this.#uo.set(r,i)),0===i.duration)return null;if(e>=t&&e<t+i.duration)return{block:i,startTimestamp:t,loopIndex:r};t+=i.duration,r++}}#yo(e,t){const r=this.#ao.filter(t=>t.intendedTimestamp+t.content.duration>e).sort((e,t)=>e.intendedTimestamp-t.intendedTimestamp)[0];let i=null;if(r){const e=Math.max(t,r.intendedTimestamp);i=this.#vo(r.content,r.intendedTimestamp,e,!0)}const n=this.#Eo(e,t);return n||i?n?i?i.absoluteStart<=n.absoluteStart?i:(i.absoluteStart<n.absoluteEnd&&(n.absoluteEnd=i.absoluteStart,n.duration=n.absoluteEnd-n.absoluteStart,n.remainingTime=Math.max(0,n.absoluteEnd-t),n.progress=Math.min(1,n.elapsedTime/n.duration)),n):n:i:null}#Eo(e,t){let r=this.#bo(e);if(!r)return null;const{block:i,startTimestamp:n}=r,s=e-n;let o,a=i.items.find(e=>e.cycleEnd>s);if(a)o=n+a.cycleStart;else{if(r=this.#bo(n+i.duration),!r||0===r.block.items.length)return null;a=r.block.items[0],o=r.startTimestamp+a.cycleStart}const l=Math.max(t,o);return this.#vo(a,o,l,!1)}#fo(e,t){const r=this.#ao.find(t=>e>=t.intendedTimestamp&&e<t.intendedTimestamp+t.content.duration);if(r)return this.#vo(r.content,r.intendedTimestamp,t,!0);const i=this.#bo(e);if(!i)return null;const{block:n,startTimestamp:s}=i,o=e-s,a=n.items.find(e=>o>=e.cycleStart&&o<e.cycleEnd);return a?this.#vo(a,s+a.cycleStart,t,!1):null}#vo(e,t,r,i){const n=r-t;return{id:e.id,title:e.title,artist:e.artist,duration:e.duration,url:e.url,absoluteStart:t,absoluteEnd:t+e.duration,elapsedTime:n,remainingTime:e.duration-n,progress:Math.min(1,n/e.duration),isCustom:i}}#mo(e,t){let r=e.timestamp||Date.now();const i=e.duration;if(t){const e=this.#fo(r,r);e&&(r=e.absoluteEnd)}const n=[...this.#ao].sort((e,t)=>e.intendedTimestamp-t.intendedTimestamp);let s=r;if(n.some(e=>r<e.intendedTimestamp+e.content.duration&&r+i>e.intendedTimestamp)){const e=[];let t=Date.now();for(const r of n)r.intendedTimestamp>t&&e.push({start:t,end:r.intendedTimestamp}),t=Math.max(t,r.intendedTimestamp+r.content.duration+this.#vt.silenceDuration);e.push({start:t,end:1/0});let o=1/0;for(const t of e)if(t.end-t.start>=i){let e=null;if(r>=t.start&&r+i<=t.end?e=r:r<t.start?e=t.start:r>t.end&&(e=t.end-i),null!==e){const t=Math.abs(r-e);t<o&&(o=t,s=e)}}}this.#ao.push({content:e,intendedTimestamp:s,originalTimestamp:e.timestamp||Date.now()})}#po(e){const t=this.#lo.filter(t=>t.timestamp<=e);this.#lo=this.#lo.filter(t=>t.timestamp>e);const r=this.#ao.filter(t=>t.intendedTimestamp+t.content.duration<=e);this.#ao=this.#ao.filter(t=>t.intendedTimestamp+t.content.duration>e);let i=!1;r.forEach(e=>{Ht(e.content),this.#fn+=e.content.id.length,i=!0,this.emit("customPositionExpired",{contentId:e.content.id})}),t.length>0&&t.sort((e,t)=>e.timestamp-t.timestamp).forEach(e=>{const t="music"===e.type?this.#so:this.#oo;if("add"===e.action)t.push(e.payload);else if("remove"===e.action){const r=e.payload,i=t.findIndex(e=>e.id===r);if(-1!==i){const[e]=t.splice(i,1);Ht(e)}}else if("move"===e.action){const r=e.payload,i=t.findIndex(e=>e.id===r.id);if(-1!==i){const[e]=t.splice(i,1);t.splice(r.newIndex,0,e)}}this.#ho=e.timestamp,this.#fn+=1,i=!0,this.emit("taskExecuted",structuredClone(e))}),i&&this.#uo.clear()}#do(e){this.#so.forEach(e=>Ht(e)),this.#oo.forEach(e=>Ht(e)),this.#ao.forEach(e=>Ht(e.content)),this.#lo.forEach(e=>{"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload&&Ht(e.payload)});const t=e=>e.map(e=>{const t={...e};return t.picture&&Array.isArray(t.picture)&&(t.picture=t.picture.map(e=>{const t="string"==typeof e.data&&e.data.startsWith("data:"),r=e.data instanceof Uint8Array;return t||r?{...e,data:Pt(e.data,e.format)}:e})),t});this.#so=t(e.music),this.#oo=t(e.voice),this.#fn=e.seed||0,this.#ho=e.anchorDate||Date.now(),this.#vt={...this.#vt,...e.config||{}},this.#ao=e.custom.map(e=>({...e,content:t([e.content])[0]})),this.#lo=e.tasks.map(e=>"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload?{...e,payload:t([e.payload])[0]}:e)}destroy(e=!0){this.#h||(e&&(this.#so.forEach(e=>Ht(e)),this.#oo.forEach(e=>Ht(e)),this.#ao.forEach(e=>Ht(e.content)),this.#lo.forEach(e=>{"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload&&Ht(e.payload)})),this.#so=[],this.#oo=[],this.#ao=[],this.#lo=[],this.#uo.clear(),this.emit("destroyed",{timestamp:Date.now()}),this.removeAllListeners(),this.#h=!0)}}const mi=di,pi=X("TinyMediaPlayer");class fi{constructor(){if(new.target===fi)throw new Error("BaseMediaAdapter is an abstract class and cannot be instantiated directly.")}canHandle(e){throw new Error('Method "canHandle" must be implemented by the subclass.')}async play(e){throw new Error('Method "play" must be implemented by the subclass.')}async pause(){throw new Error('Method "pause" must be implemented by the subclass.')}async stop(){throw new Error('Method "stop" must be implemented by the subclass.')}async seek(e){throw new Error('Method "seek" must be implemented by the subclass.')}getCurrentTime(){throw new Error('Method "getCurrentTime" must be implemented by the subclass.')}setVolume(e){throw new Error('Method "setVolume" must be implemented by the subclass.')}}class yi extends tr.EventEmitter{static BaseMediaAdapter=fi;static#no="Unknown Artist";static get unknownArtist(){return yi.#no}static set unknownArtist(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("unknownArtist must have an string or function.");yi.#no=e}static async parseContent(e,t,r,i,n){return Wt(e,t,r,i,n,yi.#no)}#h=!1;get destroyed(){return this.#h}#To=new Map;#So=[];#xo=-1;#Ao="NONE";#Co=!1;#Io=!1;#Do=1;#Mo;#No;constructor(e={}){super(),this.#Mo=Boolean(e.persistVolume),this.#No="string"==typeof e.volumeStorageKey?e.volumeStorageKey:"tiny_media_player_volume",this.#Mo&&this.#ko()}#ko(){try{if("undefined"!=typeof window&&window.localStorage){const e=window.localStorage.getItem(this.#No);if(null!==e){const t=parseFloat(e);!isNaN(t)&&t>=0&&t<=1&&(this.#Do=t)}}}catch(e){console.warn("[TinyMediaPlayer] Failed to read volume from localStorage.",e)}}#Lo(){try{this.#Mo&&"undefined"!=typeof window&&window.localStorage&&window.localStorage.setItem(this.#No,this.#Do.toString())}catch(e){console.warn("[TinyMediaPlayer] Failed to save volume to localStorage.",e)}}_getWeightedRandomIndex(){if(0===this.#So.length)return-1;if(1===this.#So.length)return 0;let e=0;for(let t=0;t<this.#So.length;t++){if(t===this.#xo)continue;const r=this.#So[t];e+="number"==typeof r.weight&&r.weight>0?r.weight:1}let t=Math.random()*e;for(let e=0;e<this.#So.length;e++){if(e===this.#xo)continue;const r=this.#So[e],i="number"==typeof r.weight&&r.weight>0?r.weight:1;if(t<i)return e;t-=i}return this.#xo===this.#So.length-1?0:this.#So.length-1}get playlist(){return pi(this.#h),[...this.#So]}set playlist(e){if(pi(this.#h),!Array.isArray(e))throw new TypeError("Playlist must be an array of MediaContent objects.");e.forEach(e=>Ft(e));const t=this.#Io;let r=null;if(-1!==this.#xo&&this.#So.length>0)try{r=this.#_o()}catch(e){}this.#So=e,this.emit("playlistUpdate",this.playlist),0===this.#So.length?this.#xo=-1:(this.#xo>=this.#So.length||-1===this.#xo)&&(this.#xo=0),this.emit("trackChange",this.#xo),t&&(async()=>{try{r&&await r.stop(),-1!==this.#xo&&await this.play()}catch(e){console.warn("[TinyMediaPlayer] Background transition error on playlist update:",e)}})()}get currentIndex(){return pi(this.#h),this.#xo}set currentIndex(e){if(pi(this.#h),"number"!=typeof e)throw new TypeError("Current index must be a number.");if(e<-1||e>=this.#So.length&&this.#So.length>0)throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);if(this.#xo===e)return;const t=this.#Io;let r=null;if(-1!==this.#xo&&this.#So.length>0)try{r=this.#_o()}catch(e){}this.#xo=e,this.emit("trackChange",this.#xo),t&&(async()=>{try{r&&await r.stop(),-1!==this.#xo&&await this.play()}catch(e){console.warn("[TinyMediaPlayer] Background transition error on index update:",e)}})()}get loopMode(){return pi(this.#h),this.#Ao}set loopMode(e){pi(this.#h);const t=["NONE","TRACK","PLAYLIST"];if(!t.includes(e))throw new TypeError(`Loop mode must be one of: ${t.join(", ")}.`);this.#Ao=e,this.emit("loopModeChange",this.#Ao)}get isRandom(){return pi(this.#h),this.#Co}set isRandom(e){if(pi(this.#h),"boolean"!=typeof e)throw new TypeError("Random mode state must be a boolean.");this.#Co=e,this.emit("randomModeChange",this.#Co)}get isPlaying(){return pi(this.#h),this.#Io}get volume(){return pi(this.#h),this.#Do}set volume(e){if(pi(this.#h),"number"!=typeof e)throw new TypeError("Volume must be a number.");if(e<0||e>1)throw new RangeError("Volume must be tightly constrained between 0.0 and 1.0.");if(this.#Do=e,this.#Lo(),this.emit("volumeChange",this.#Do),-1!==this.#xo&&this.#So.length>0)try{const e=this.#_o();e&&e.setVolume(this.#Do)}catch(e){}}get persistVolume(){return pi(this.#h),this.#Mo}set persistVolume(e){if(pi(this.#h),"boolean"!=typeof e)throw new TypeError("Persist volume parameter must be a boolean.");this.#Mo=e,e&&this.#Lo()}get volumeStorageKey(){return pi(this.#h),this.#No}set volumeStorageKey(e){if(pi(this.#h),"string"!=typeof e)throw new TypeError("Volume storage key must be a string.");if(""===e.trim())throw new TypeError("Volume storage key cannot be an empty string.");const t=this.#No;this.#No=e;try{this.#Mo&&"undefined"!=typeof window&&window.localStorage&&(window.localStorage.removeItem(t),this.#Lo())}catch(e){console.warn("[TinyMediaPlayer] Failed to migrate volume storage key.",e)}}registerAdapter(e,t){if(pi(this.#h),"string"!=typeof e)throw new TypeError("Adapter ID must be a string.");if(!(t instanceof fi))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");this.#To.set(e,t)}#_o(){if(-1===this.#xo||0===this.#So.length)return null;const e=this.#So[this.#xo];for(const t of this.#To.values())if(t.canHandle(e))return t;throw new Error(`No compatible adapter found for content ID: ${e.id}.`)}addTrack(e){if(pi(this.#h),!e||"object"!=typeof e||"string"!=typeof e.url)throw new TypeError("Track content must be a valid MediaContent object containing a URL.");const t={id:"",title:"",artist:"",url:"",duration:0,weight:1,title:null,album:null,albumartist:null,albumartists:[],genre:[],label:[],composer:[],year:null,artist:null,artists:[],disk:{no:null,of:null},track:{no:null,of:null},picture:[],...e};Ft(t);const r=this.#So.push(t);return-1===this.#xo&&(this.#xo=0,this.emit("trackChange",this.#xo)),this.emit("playlistUpdate",this.playlist),r}existsTrack(e){if(pi(this.#h),"number"!=typeof e)throw new TypeError("Index must be a number.");return e>=0&&e<this.#So.length}getTrack(e){if(pi(this.#h),"number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);return this.#So[e]}async removeTrack(e){if(pi(this.#h),"number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);e===this.#xo?(await this.stop(),this.#So.splice(e,1),0===this.#So.length?this.#xo=-1:this.#xo>=this.#So.length&&(this.#xo=0),this.emit("trackChange",this.#xo)):(this.#So.splice(e,1),e<this.#xo&&(this.#xo-=1,this.emit("trackChange",this.#xo))),this.emit("playlistUpdate",this.playlist)}searchTrack(e){if(pi(this.#h),"string"!=typeof e&&"function"!=typeof e)throw new TypeError("Search query must be a string or a boolean evaluation function.");const t=[];for(let r=0;r<this.#So.length;r++){const i=this.#So[r];let n=!1;if("function"==typeof e)n=Boolean(e(i));else{const t=e.toLowerCase(),r=i.title&&i.title.toLowerCase().includes(t),s=i.artist&&i.artist.toLowerCase().includes(t),o=i.album&&i.album.toLowerCase().includes(t);n=Boolean(r||s||o)}n&&t.push({track:i,index:r})}return t}async clearPlaylist(){pi(this.#h),await this.stop(),this.#So=[],this.#xo=-1,this.emit("playlistUpdate",this.playlist),this.emit("trackChange",this.#xo)}async play(){pi(this.#h);const e=this.#_o();e&&(e.setVolume(this.#Do),await e.play(this.#So[this.#xo]),this.#Io=!0,this.emit("play",this.#xo))}async pause(){pi(this.#h);const e=this.#_o();e&&(await e.pause(),this.#Io=!1,this.emit("pause",this.#xo))}async stop(){pi(this.#h);const e=this.#_o();e&&(await e.stop(),this.#Io=!1,this.emit("stop",this.#xo))}async next(){if(pi(this.#h),0!==this.#So.length)if(await this.stop(),"TRACK"!==this.#Ao){if(this.#Co)this.#xo=this._getWeightedRandomIndex();else{let e=this.#xo+1;if(e>=this.#So.length){if("PLAYLIST"!==this.#Ao)return;e=0}this.#xo=e}this.emit("trackChange",this.#xo),await this.play()}else await this.play()}async prev(){if(pi(this.#h),0!==this.#So.length){if(await this.stop(),this.#Co)this.#xo=this._getWeightedRandomIndex();else{let e=this.#xo-1;if(e<0){if("PLAYLIST"!==this.#Ao)return;e=this.#So.length-1}this.#xo=e}this.emit("trackChange",this.#xo),await this.play()}}async seek(e){if(pi(this.#h),"number"!=typeof e)throw new TypeError("Seek time must be a number in milliseconds.");if(e<0)throw new RangeError("Seek time cannot be negative.");const t=this.#_o();t&&(await t.seek(e),this.emit("seek",e))}async step(e){if(pi(this.#h),"number"!=typeof e)throw new TypeError("Step amount must be a number in milliseconds.");const t=this.#_o();if(!t)return;let r=t.getCurrentTime()+e;r<0&&(r=0),await this.seek(r)}async destroy(){if(!this.#h){try{this.#Io&&await this.stop()}catch(e){console.warn("[TinyMediaPlayer] Non-fatal error during playback termination:",e)}this.#So=[],this.#xo=-1,this.#Io=!1,this.#To.clear(),this.removeAllListeners(),this.#h=!0}}}const gi=yi})(),window.TinyEssentials=i})();