tiny-essentials 1.28.4 → 1.28.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/changelog/1/28/5.md +31 -0
  2. package/dist/v1/TinyBasicsEs.min.js +1 -1
  3. package/dist/v1/TinyEssentials.min.js +1 -1
  4. package/dist/v1/TinyMediaPlayer.min.js +1 -1
  5. package/dist/v1/TinyTimeout.min.js +1 -1
  6. package/dist/v1/TinyUploadClicker.min.js +1 -1
  7. package/dist/v1/basics/index.cjs +4 -0
  8. package/dist/v1/basics/index.d.mts +3 -2
  9. package/dist/v1/basics/index.mjs +3 -2
  10. package/dist/v1/basics/mediaContent.cjs +1 -0
  11. package/dist/v1/basics/mediaContent.d.mts +4 -0
  12. package/dist/v1/basics/mediaContent.mjs +1 -0
  13. package/dist/v1/basics/objChecker.cjs +16 -0
  14. package/dist/v1/basics/objChecker.d.mts +12 -0
  15. package/dist/v1/basics/objChecker.mjs +14 -0
  16. package/dist/v1/basics/objFilter.cjs +0 -2
  17. package/dist/v1/basics/objFilter.d.mts +0 -2
  18. package/dist/v1/basics/objFilter.mjs +1 -2
  19. package/dist/v1/basics/promiseUtils.cjs +101 -0
  20. package/dist/v1/basics/promiseUtils.d.mts +31 -0
  21. package/dist/v1/basics/promiseUtils.mjs +89 -0
  22. package/dist/v1/index.cjs +4 -0
  23. package/dist/v1/index.d.mts +3 -2
  24. package/dist/v1/index.mjs +3 -2
  25. package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.cjs +268 -0
  26. package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.d.mts +118 -0
  27. package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.mjs +237 -0
  28. package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.cjs +265 -0
  29. package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.d.mts +118 -0
  30. package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.mjs +234 -0
  31. package/dist/v1/libs/TinyMediaPlayer/Youtube.cjs +671 -0
  32. package/dist/v1/libs/TinyMediaPlayer/Youtube.d.mts +259 -0
  33. package/dist/v1/libs/TinyMediaPlayer/Youtube.mjs +597 -0
  34. package/dist/v1/libs/TinyMediaPlayer/docs/YouTubePlayer.cjs +546 -0
  35. package/dist/v1/libs/TinyMediaPlayer/docs/YouTubePlayer.d.mts +657 -0
  36. package/dist/v1/libs/TinyMediaPlayer/docs/YouTubePlayer.mjs +480 -0
  37. package/dist/v1/libs/TinyMediaPlayer/index.cjs +165 -0
  38. package/dist/v1/libs/TinyMediaPlayer/index.d.mts +102 -0
  39. package/dist/v1/libs/TinyMediaPlayer/index.mjs +144 -0
  40. package/dist/v1/libs/TinyMediaPlayer.cjs +589 -103
  41. package/dist/v1/libs/TinyMediaPlayer.d.mts +150 -65
  42. package/dist/v1/libs/TinyMediaPlayer.mjs +535 -93
  43. package/dist/v1/libs/TinyTimeout.cjs +4 -14
  44. package/dist/v1/libs/TinyTimeout.d.mts +1 -0
  45. package/dist/v1/libs/TinyTimeout.mjs +4 -13
  46. package/docs/v1/basics/mediaContent.md +1 -1
  47. package/docs/v1/basics/objChecker.md +13 -0
  48. package/docs/v1/basics/promiseUtils.md +32 -0
  49. package/docs/v1/libs/TinyMediaPlayer.md +239 -32
  50. package/docs/v1/libs/TinyTimeout.md +1 -14
  51. package/package.json +21 -1
@@ -0,0 +1,31 @@
1
+ ## 📦 Libraries
2
+
3
+ ### ✨ New Features
4
+ - **`basics/promiseUtils.mjs`**: Added `createSingletonTask`, a utility that creates a wrapper to ensure an asynchronous function is only executed once at a time. If a task is already in progress, subsequent calls will wait for the existing promise to resolve.
5
+ - **`basics/objChecker.mjs`**: Added `isValidObj`.
6
+
7
+ ### 🛠️ Improvements & Refactors
8
+ - **`libs/TinyTimeout.mjs`**: The `static` version of `waitForTrue` has been deprecated and migrated to `basics/promiseUtils.mjs`.
9
+ - *Note: The instance method remains available and will continue to function as expected.*
10
+
11
+ ### ⚠️ Breaking Changes
12
+ - **`basics/objFilter.mjs`**: Removed aliases `countObj` and `isJsonObject`.
13
+ - **Action Required**: Please import these functions directly from `basics/objChecker.mjs` from now on.
14
+
15
+ ---
16
+
17
+ ## 🎬 TinyMediaPlayer
18
+
19
+ ### ⚠️ Breaking Changes
20
+ - **`registerAdapter`**: The method no longer accepts an `Id` parameter. You must now pass the adapter directly; the ID will be automatically managed and stored internally within the instance.
21
+
22
+ ### ✨ New Features
23
+ - **New Adapters**:
24
+ - `HtmlVideoAdapter` 📹
25
+ - `HtmlAudioAdapter` 🎵
26
+ - `YoutubeMediaAdapter` 📺
27
+ - **New Methods**: `removeAdapter`, `destroyAdapter`, `hasAdapter`, `getMediaAdapter`, `destroyAllAdapters`, and `clearAdapters`.
28
+ - **New Properties/Options**: `repeatCurrentOnPrev`, `smoothPlayPauseVolume`, `smoothStopVolume`, `adapters`, `adaptersSize`, `fadeVolumeSpeed`, and `prevClickTimeoutDuration`.
29
+ - **New Getters**:
30
+ - `adapters`: Returns an array of the current list of adapters.
31
+ - `adaptersSize`: Returns the total number of installed instances.
@@ -1 +1 @@
1
- (()=>{"use strict";const e={d:(t,r)=>{if(Array.isArray(r))for(var n=0;n<r.length;){var o=r[n++],i=r[n++];e.o(t,o)?0===i&&n++:0===i?Object.defineProperty(t,o,{enumerable:!0,value:r[n++]}):Object.defineProperty(t,o,{enumerable:!0,get:i})}else for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}};let t={};function r(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 n(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 n=0;n<e.length;n++){if("number"!=typeof t[n]||Number.isNaN(t[n]))throw new TypeError(`Element at counts[${n}] must be a valid number.`);for(let o=0;o<t[n];o++)r.push(e[n])}return r}function o(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 i(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 a(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 n=["asMilliseconds","asSeconds","asMinutes","asHours","asDays"];if(!n.includes(t))throw new RangeError(`The 'durationType' must be one of: ${n.join(", ")}.`);if(null!==r&&!(r instanceof Date))throw new TypeError("The 'now' argument must be an instance of Date or null.");const o=r instanceof Date?r:new Date,i=e.getTime()-o.getTime();switch(t){case"asMilliseconds":return i;case"asSeconds":default:return i/1e3;case"asMinutes":return i/6e4;case"asHours":return i/36e5;case"asDays":return i/864e5}}function s(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 n=["seconds","minutes","hours","days","months","years"];if(!n.includes(t))throw new RangeError(`The 'level' must be one of: ${n.join(", ")}.`);if("string"!=typeof r)throw new TypeError("The 'format' argument must be a string.");e=Math.max(0,Math.floor(e));const o=n.indexOf(t),i=o>=5,a=o>=4,s=o>=3,l=o>=2,u=o>=1,c=o>=0,f={years:i?0:NaN,months:a?0:NaN,days:s?0:NaN,hours:l?0:NaN,minutes:u?0:NaN,seconds:c?0:NaN,total:NaN};let m=e;if(i||a||s){const e=new Date(1980,0,1),t=new Date(e.getTime()+1e3*m),r=new Date(e);if(i)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),f.years++;if(a)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),f.months++;if(s)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),f.days++;m=Math.floor((t.getTime()-r.getTime())/1e3)}l&&(f.hours=Math.floor(m/3600),m%=3600),u&&(f.minutes=Math.floor(m/60),m%=60),c&&(f.seconds=m),f.total=+e.toFixed(2).replace(/\.00$/,"");const p=e=>{const t="string"==typeof e?parseInt(e):e;return Number.isNaN(t)?"NaN":String(t).padStart(2,"0")},d=[l?p(f.hours):null,u?p(f.minutes):null,c?p(f.seconds):null].filter(e=>null!==e).join(":");return r.replace(/\{years\}/g,String(f.years)).replace(/\{months\}/g,String(f.months)).replace(/\{days\}/g,String(f.days)).replace(/\{hours\}/g,p(f.hours)).replace(/\{minutes\}/g,p(f.minutes)).replace(/\{seconds\}/g,p(f.seconds)).replace(/\{time\}/g,d).replace(/\{total\}/g,String(f.total)).trim()}function l(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'seconds' argument must be a valid number.");return s(e,"hours","{hours}:{minutes}:{seconds}")}function u(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'seconds' argument must be a valid number.");return s(e,"days","{days}d {hours}:{minutes}:{seconds}")}function c(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 n=r.indexOf(t),o=n>=6,i=n>=5,a=n>=4,s=n>=3,l=n>=2,u=n>=1,c=n>=0,f={years:o?0:NaN,months:i?0:NaN,days:a?0:NaN,hours:s?0:NaN,minutes:l?0:NaN,seconds:u?0:NaN,milliseconds:c?0:NaN,total:NaN};let m=e;if(o||i||a){const e=new Date(1980,0,1),t=new Date(e.getTime()+m),r=new Date(e);if(o)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),f.years++;if(i)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),f.months++;if(a)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),f.days++;m=t.getTime()-r.getTime()}return s&&(f.hours=Math.floor(m/36e5),m%=36e5),l&&(f.minutes=Math.floor(m/6e4),m%=6e4),u&&(f.seconds=Math.floor(m/1e3),m%=1e3),c&&(f.milliseconds=m),f.total=+e,f}function f(e){if(!Array.isArray(e)&&!m(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 m(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}function p(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,n)=>{const o=new FileReader;o.onload=()=>{try{r(o.result)}catch(e){n(e)}},o.onerror=()=>{n(o.error)},o[t](e)}):Promise.reject(new TypeError(`The "method" argument must be one of: ${r.join(", ")}.`))}function d(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,n)=>{p(e,"readAsDataURL").then(e=>{if("string"!=typeof e)throw new TypeError("Expected file content to be a string.");const n=e.match(/^data:(.+);base64,(.*)$/);if(!n||!n[2])throw new Error("Invalid data URL format or missing Base64 content.");const[,o,i]=n;if(!/^[\w/+]+=*$/.test(i))throw new Error("Base64 content is malformed.");if("boolean"==typeof t)return r(t?e:i);if(!/^[\w-]+\/[\w.+-]+$/.test(t))throw new Error(`Invalid MIME type string: ${t}`);return r(`data:${t};base64,${i}`)}).catch(n)}):Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'))}function y(e){return e instanceof Blob?new Promise((t,r)=>p(e,"readAsText").then(e=>{if("string"!=typeof e)throw new TypeError("Expected file content to be a string.");const r=e.trim();if(0===r.length)throw new Error("File is empty or contains only whitespace.");const n=JSON.parse(r);if("object"!=typeof n||null===n)throw new Error("Parsed content is not a valid JSON object or array.");t(n)}).catch(r)):Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'))}function w(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 n=JSON.stringify(t,null,r),o=new Blob([n],{type:"application/json"}),i=URL.createObjectURL(o),a=document.createElement("a");a.href=i,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}function b(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 n=e.headers.get("content-length"),o=n?parseInt(n,10):0;let i=0;const a=e.body.getReader(),s=new ReadableStream({async start(e){for(;;){const{done:r,value:n}=await a.read();if(r)break;i+=n.byteLength,t(i,o),e.enqueue(n)}e.close()}});return new Response(s,r(e))}async function g(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((n,o)=>{fetch(e,t??void 0).then(async e=>{const t=r?b(e,r):e,o=t.headers.get("content-type")||"";if(!o.includes("application/json"))throw new Error(`Unexpected content-type: ${o}`);const i=await t.json();if(!Array.isArray(i)&&!m(i))throw new Error("Received invalid data instead of valid JSON.");return n(i)}).catch(o)})}async function h(e,t,r,n){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!==n&&"function"!=typeof n?Promise.reject(new TypeError('The "onProgress" option must be a function.')):new Promise((o,i)=>{fetch(e,r??void 0).then(async e=>{const r=n?b(e,n):e,i=r.headers.get("content-type")||"";if(Array.isArray(t)&&t.length>0&&!t.some(e=>i.includes(e)))throw new Error(`Blocked MIME type: ${i}`);const a=await r.text();return o(a)}).catch(i)}):Promise.reject(new TypeError('The "allowedMimeTypes" argument must be an array of strings.'))}function E(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:n="windowVisible",onVisible:o,onHidden:i}=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 n)throw new TypeError('"visibleClass" must be a string.');if(void 0!==o&&"function"!=typeof o)throw new TypeError('"onVisible" must be a function if provided.');if(void 0!==i&&"function"!=typeof i)throw new TypeError('"onHidden" must be a function if provided.');let a="",s="";const l=()=>{t.classList.remove(r),t.classList.remove(n)};let u=null;const c=["visibilitychange","mozvisibilitychange","webkitvisibilitychange","msvisibilitychange"],f=["hidden","mozHidden","webkitHidden","msHidden"];for(let e=0;e<f.length;e++)if(f[e]in document){u=f[e];break}const m=function(e){l();const c=e?.type,f=u&&document[u];["focus","focusin","pageshow"].includes(c)?(t.classList.add(n),o?.({type:c,oldClass:s,oldType:a}),s=n):["blur","focusout","pagehide"].includes(c)||f?(t.classList.add(r),i?.({type:c,oldClass:s,oldType:a}),s=r):(t.classList.add(n),o?.({type:c,oldClass:s,oldType:a}),s=n),a=c};let p=()=>{};if(u){const e=c[f.indexOf(u)];document.addEventListener(e,m),window.addEventListener("focus",m),window.addEventListener("blur",m),p=()=>{document.removeEventListener(e,m),window.removeEventListener("focus",m),window.removeEventListener("blur",m),l()}}else"onfocusin"in document?(document.onfocusin=document.onfocusout=m,p=()=>{document.onfocusin=document.onfocusout=null,l()}):(window.onpageshow=window.onpagehide=window.onfocus=window.onblur=m,p=()=>{window.onpageshow=window.onpagehide=window.onfocus=window.onblur=null,l()});const d=new Event(u&&document[u]?"blur":"focus");return m(d),p}e.r(t),e.d(t,{addAiMarkerShortcut:()=>X,areElsCollBottom:()=>Q,areElsCollLeft:()=>ee,areElsCollPerfBottom:()=>ne,areElsCollPerfLeft:()=>oe,areElsCollPerfRight:()=>ie,areElsCollPerfTop:()=>re,areElsCollRight:()=>te,areElsCollTop:()=>_,areElsColliding:()=>ae,areElsPerfColliding:()=>se,arraySortPositions:()=>i,asyncReplace:()=>J,breakdownDuration:()=>c,calculateMarketcap:()=>q,cloneObjTypeOrder:()=>M,compareMarketcap:()=>z,countObj:()=>f,diffArrayList:()=>o,diffObjList:()=>K,diffStrings:()=>Z,documentIsFullScreen:()=>D,exitFullScreen:()=>P,extendObjType:()=>N,extractMediaId3Tags:()=>je,fetchJson:()=>g,fetchText:()=>h,formatBytes:()=>Y,formatCustomTimer:()=>s,formatDayTimer:()=>u,formatTimer:()=>l,genFibonacciSeq:()=>H,getAge:()=>U,getElsCollDetails:()=>ye,getElsCollDirDepth:()=>de,getElsCollOverlap:()=>ce,getElsCollOverlapPos:()=>fe,getElsColliding:()=>le,getElsPerfColliding:()=>ue,getElsRelativeCenterOffset:()=>pe,getPercentage:()=>$,getRectCenter:()=>me,getSimplePerc:()=>B,getTimeDuration:()=>a,installWindowHiddenScript:()=>E,isFullScreenMode:()=>k,isJsonObject:()=>m,isObjType:()=>F,isScreenFilled:()=>L,multiplyArrayBlocks:()=>n,objType:()=>x,objTypeName:()=>j,offFullScreenChange:()=>O,onFullScreenChange:()=>I,parseMediaMetadata:()=>Fe,readBase64Blob:()=>d,readFileBlob:()=>p,readJsonBlob:()=>y,reorderObjTypeOrder:()=>A,requestFullScreen:()=>S,ruleOfThree:()=>R,safeTextTrim:()=>G,saveJsonFile:()=>w,shuffleArray:()=>r,toTitleCase:()=>V,toTitleCaseLowerFirst:()=>W,valMediaContentMetadata:()=>Ae,valMediaContentMetadataPartial:()=>Me});const T="undefined"!=typeof window&&void 0!==window.document,v={items:{},order:[]};function N(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=[],n=Array.isArray(e)?e:Object.entries(e);for(const e of n){if(!Array.isArray(e)||e.length<2)throw new TypeError("Each item in 'newItems' array must be a [key, function] pair.");const[n,o]=e;if("string"!=typeof n)throw new TypeError("Validator key must be a string.");if("function"!=typeof o)throw new TypeError(`Validator for key '${n}' must be a function.`);if(!v.items.hasOwnProperty(n)){v.items[n]=o;let e="number"==typeof t?t:-1;if(-1===e){const t=v.order.indexOf("object");e=t>-1?t:v.order.length}e=Math.min(Math.max(0,e),v.order.length),v.order.splice(e,0,n),r.push(n)}}return r}function A(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=[...v.order];return!!e.every(e=>t.includes(e))&&(v.order=e.slice(),!0)}function M(){return[...v.order]}const j=e=>{if(null===e)return"null";for(const t of v.order)if("function"!=typeof v.items[t]||v.items[t](e))return t;return"unknown"};function F(e,t){if("string"!=typeof t)throw new TypeError("Argument 'type' must be a string.");return j(e)===t.toLowerCase()}function x(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=j(e);return"string"==typeof t?r===t.toLowerCase():r}N([["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)]]),T&&N([["file",e=>"undefined"!=typeof File&&e instanceof File]]),N([["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]]),T&&N([["htmlelement",e=>"undefined"!=typeof HTMLElement&&e instanceof HTMLElement]]),N([["object",e=>m(e)]]);const D=()=>!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitIsFullScreen||document.mozFullScreen),L=()=>window.innerHeight===screen.height&&window.innerWidth===screen.width,k=()=>D()||L(),S=e=>new Promise(async(t,r)=>{const n=document.documentElement;try{n.requestFullscreen?await n.requestFullscreen(e):n.mozRequestFullScreen?n.mozRequestFullScreen(e):n.webkitRequestFullScreen?n.webkitRequestFullScreen(e):n.msRequestFullscreen&&n.msRequestFullscreen(e),t()}catch(e){r(e)}}),P=()=>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)}}),C=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],I=(e,t)=>{C.forEach(r=>{document.addEventListener(r,e,t)})},O=(e,t)=>{C.forEach(r=>{document.removeEventListener(r,e,t)})};function R(e,t,r,n=!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 n)throw new TypeError("inverse must be a boolean.");return n?Number(e*t)/r:Number(r*t)/e}function B(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 $(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 U(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 n=t instanceof Date?t:new Date;let o=n.getFullYear()-r.getFullYear();const i=n.getMonth(),a=r.getMonth(),s=n.getDate(),l=r.getDate();return(i<a||i===a&&s<l)&&o--,Math.abs(o)}function Y(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 n=["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(!n.includes(r))throw new RangeError(`maxUnit must be one of: ${n.join(", ")}`)}const o=r&&n.includes(r)?n.indexOf(r):n.length-1,i=Math.min(Math.floor(Math.log(e)/Math.log(1024)),o);let a=e/Math.pow(1024,i);if(null!==t){const e=t<0?0:t;a=parseFloat(a.toFixed(e))}return{unit:n[i],value:a}}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 n=[...e.slice(0,2)];for(let e=2;e<t;e++){const t=r(n[e-2],n[e-1],e);n.push(t)}return n}function q(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 z(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 n=q(e,t),o="number"==typeof r?r/t:NaN;return{originalPrice:n,newPrice:o,priceChangePercent:"number"==typeof r?(o-n)/n*100:NaN}}async function J(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 n=[];e.replace(t,(e,...t)=>(n.push(r(e,...t)),e));const o=await Promise.all(n);return e.replace(t,()=>o.shift())}function V(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 X({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 G(e,t,r=.6){if("string"!=typeof e)throw new TypeError("Expected a string for 'text', but received "+typeof e);if(!Number.isInteger(t)||t<=0)throw new TypeError(`Expected 'limit' to be a positive integer, but received ${t}`);if("number"!=typeof r||r<0||r>1)throw new TypeError(`Expected 'safeCutZone' to be a number between 0 and 1, but received ${r}`);let n=e.trim();if(n.length>t){const e=n.lastIndexOf(" ",t);return e>0&&e>=t*r?`${n.substring(0,e).trim()}...`:`${n.substring(0,t).trim()}...`}return n}function 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 n in e)n in t?e[n]!==t[n]&&(r.modified[n]={old:e[n],new:t[n]}):r.removed[n]=e[n];for(const n in t)n in e||(r.added[n]=t[n]);return r}const Z=K,_=(e,t)=>e.bottom<t.top,Q=(e,t)=>e.top>t.bottom,ee=(e,t)=>e.right<t.left,te=(e,t)=>e.left>t.right,re=(e,t)=>e.bottom<=t.top,ne=(e,t)=>e.top>=t.bottom,oe=(e,t)=>e.right<=t.left,ie=(e,t)=>e.left>=t.right,ae=(e,t)=>!(ee(e,t)||te(e,t)||_(e,t)||Q(e,t)),se=(e,t)=>!(oe(e,t)||ie(e,t)||re(e,t)||ne(e,t)),le=(e,t)=>ee(e,t)?"left":te(e,t)?"right":_(e,t)?"top":Q(e,t)?"bottom":null,ue=(e,t)=>oe(e,t)?"left":ie(e,t)?"right":re(e,t)?"top":ne(e,t)?"bottom":null,ce=(e,t)=>({overlapLeft:t.right-e.left,overlapRight:e.right-t.left,overlapTop:t.bottom-e.top,overlapBottom:e.bottom-t.top}),fe=({overlapLeft:e=-1,overlapRight:t=-1,overlapTop:r=-1,overlapBottom:n=-1}={})=>({dirX:e<t?"right":"left",dirY:r<n?"bottom":"top"}),me=e=>({x:e.left+e.width/2,y:e.top+e.height/2});function pe(e,t){const r=e.left+e.width/2,n=e.top+e.height/2;return{x:t.left+t.width/2-r,y:t.top+t.height/2-n}}function de(e,t){if(!se(e,t))return{inDir:null,dirX:null,dirY:null,depthX:0,depthY:0};const{overlapLeft:r,overlapRight:n,overlapTop:o,overlapBottom:i}=ce(e,t),{dirX:a,dirY:s}=fe({overlapLeft:r,overlapRight:n,overlapTop:o,overlapBottom:i}),l=Math.min(r,n),u=Math.min(o,i);let c;return c=l<u?a:s,{inDir:c,dirX:a,dirY:s,depthX:l,depthY:u}}function ye(e,t){const r=se(e,t),n={in:null,x:null,y:null},o={y:null,x:null},i={top:0,bottom:0,left:0,right:0},{overlapLeft:a,overlapRight:s,overlapTop:l,overlapBottom:u}=ce(t,e);i.top=l,i.bottom=u,i.left=a,i.right=s;const c=Object.entries(i).filter(([,e])=>e>0).sort((e,t)=>e[1]-t[1]),{dirX:f,dirY:m}=fe({overlapLeft:s,overlapRight:a,overlapTop:u,overlapBottom:l});return n.y=m,n.x=f,i.bottom<0?o.y="bottom":i.top<0&&(o.y="top"),i.left<0?o.x="left":i.right<0&&(o.x="right"),n.in=r?i.top===i.bottom&&i.bottom===i.left&&i.left===i.right?"center":c.length?c[0][0]:"top":null,{dirs:n,depth:i,isNeg:o}}const we=(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}.`)},be=(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}.`)},ge=(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}.`)},he=new Map;class Ee extends Error{constructor(e,t,r){if(we(e,"message"),we(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 Te=async e=>{we(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)},ve=(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}.`);we(t,"format");const r=e=>{const t=URL.createObjectURL(e),r=he.get(t);return he.set(t,"number"==typeof r?r+1:1),t};if(e instanceof Uint8Array)return r(new Blob([e],{type:t}));if("string"==typeof e&&e.startsWith("data:")){const n=e.split(",")[1],o=atob(n),i=new Uint8Array(o.length);for(let e=0;e<o.length;e++)i[e]=o.charCodeAt(e);return r(new Blob([i],{type:t}))}return"string"==typeof e?e:""},Ne=(e,t)=>{if(ge(e,"common"),"boolean"!=typeof t)throw new TypeError('Expected "isPartial" to be a boolean.');const r=e=>t&&void 0===e,n=e=>r(e)||"string"==typeof e||null===e,o=(e,t)=>(be(t,"valueValidator"),!!r(e)||!(!Array.isArray(e)||!e.every(t)));if(!n(e.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!n(e.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!n(e.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a string or null.');if(!n(e.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(i=e.year,!r(i)&&"number"!=typeof i&&null!==i)throw new TypeError('Invalid metadata: "year" must be a number or null.');var i;if(!o(e.albumartists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "albumartists" must be an array of string.');if(!o(e.genre,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "genre" must be an array of string.');if(!o(e.label,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "label" must be an array of string.');if(!o(e.composer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "composer" must be an array of string.');if(!o(e.artists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "artists" must be an array of string.');if(!o(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 a=(e,t)=>{if(we(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.`)}};a("disk",e.disk),a("track",e.track)},Ae=e=>(ge(e,"common"),Ne(e,!1)),Me=e=>(ge(e,"common"),Ne(e,!0)),je=async(e,t)=>{we(e,"url"),be(t,"parseFile");try{const r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch audio file: ${r.status} ${r.statusText}`);const n=await r.blob(),o=await t(n);if(!o||"object"!=typeof o.common)throw new TypeError('Invalid metadata: "common" property is missing or not an object.');const i=o.common;return Me(i),{title:i?.title??null,album:i?.album??null,albumartist:i?.albumartist??null,albumartists:i?.albumartists??[],genre:i?.genre??[],label:i?.label??[],composer:i?.composer??[],year:i?.year??null,artist:i?.artist??null,artists:i?.artists??[],disk:i?.disk?{no:i.disk.no,of:i.disk.of}:{no:null,of:null},track:i?.track?{no:i.track.no,of:i.track.of}:{no:null,of:null},picture:i?.picture?.map(e=>({...e,data:ve(e.data,e.format)}))??[]}}catch(e){throw e}},Fe=async(e,t={},r={},n=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.")))},o={},i="null")=>{if("string"!=typeof e&&!(e instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(ge(t,"defaultMetadata"),ge(r,"metadata"),be(n,"parseFile"),ge(o,"callbacks"),o.onProgress&&"function"!=typeof o.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(o.onError&&"function"!=typeof o.onError)throw new TypeError("callbacks.onError must be a function.");if("string"!=typeof i&&"function"!=typeof i)throw new TypeError("unknownArtist must be a string or a function returning a string.");let a,s="";const l=(t,r)=>{if(we(t,"stage"),void 0!==r&&!(r instanceof Event))throw new TypeError('Expected "event" to be an Event or undefined.');o.onProgress&&o.onProgress({event:r,status:"loading",stage:t,url:s||(e instanceof HTMLMediaElement?e.src:"unknown")})},u=(t,r)=>{if(!(t instanceof Error))throw new TypeError('Expected "error" to be an Error.');we(r,"stage"),o.onError&&o.onError({error:t,url:s||(e instanceof HTMLMediaElement?e.src:"unknown"),stage:r})};try{l("INITIALIZING"),"string"==typeof e?(s=e,a=new Audio(s)):(a=e,s=a.src);try{await new Promise((e,t)=>{const r=e=>l("DOWNLOADING",e),n=()=>{i(),e(void 0)},o=e=>{i(),t(new Error(`HTMLMediaElement failed to load: ${e.message||"Unknown error"}`))},i=()=>{a.removeEventListener("progress",r),a.removeEventListener("loadedmetadata",n),a.removeEventListener("error",o)};a.addEventListener("progress",r),a.addEventListener("loadedmetadata",n),a.addEventListener("error",o),a.readyState>=1&&(i(),e(void 0))}),l("METADATA_LOADED")}catch(e){throw new Ee(e instanceof Error?e.message:"UNKNOWN ERROR",s,"METADATA")}const c={id:r.id||await Te(s),duration:Math.floor(1e3*a.duration),url:s,weight:r.weight??1};let f={};l("EXTRACTING_ID3");try{f=await je(s,n)}catch(e){u(e instanceof Error?e:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${s}. Falling back to filename.`)}const m=e=>{we(e,"url");try{return(e.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},p={...c,...t,...f,...r,title:f.title||r.title||m(s),artist:f.artist||r.artist||("string"==typeof i?i:String(i()))};return o.onProgress&&o.onProgress({status:"success",stage:"COMPLETE",url:s}),p}catch(e){if(e instanceof Ee)throw e;{const t=new Ee(e instanceof Error?e.message:"UNKNOWN ERROR",s,"INITIALIZING");throw u(t,"INITIALIZING"),t}}};window.TinyBasicsEs=t})();
1
+ (()=>{"use strict";const e={d:(t,r)=>{if(Array.isArray(r))for(var n=0;n<r.length;){var o=r[n++],i=r[n++];e.o(t,o)?0===i&&n++:0===i?Object.defineProperty(t,o,{enumerable:!0,value:r[n++]}):Object.defineProperty(t,o,{enumerable:!0,get:i})}else for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}};let t={};function r(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 n(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 n=0;n<e.length;n++){if("number"!=typeof t[n]||Number.isNaN(t[n]))throw new TypeError(`Element at counts[${n}] must be a valid number.`);for(let o=0;o<t[n];o++)r.push(e[n])}return r}function o(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 i(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 a(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 n=["asMilliseconds","asSeconds","asMinutes","asHours","asDays"];if(!n.includes(t))throw new RangeError(`The 'durationType' must be one of: ${n.join(", ")}.`);if(null!==r&&!(r instanceof Date))throw new TypeError("The 'now' argument must be an instance of Date or null.");const o=r instanceof Date?r:new Date,i=e.getTime()-o.getTime();switch(t){case"asMilliseconds":return i;case"asSeconds":default:return i/1e3;case"asMinutes":return i/6e4;case"asHours":return i/36e5;case"asDays":return i/864e5}}function s(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 n=["seconds","minutes","hours","days","months","years"];if(!n.includes(t))throw new RangeError(`The 'level' must be one of: ${n.join(", ")}.`);if("string"!=typeof r)throw new TypeError("The 'format' argument must be a string.");e=Math.max(0,Math.floor(e));const o=n.indexOf(t),i=o>=5,a=o>=4,s=o>=3,l=o>=2,u=o>=1,c=o>=0,f={years:i?0:NaN,months:a?0:NaN,days:s?0:NaN,hours:l?0:NaN,minutes:u?0:NaN,seconds:c?0:NaN,total:NaN};let m=e;if(i||a||s){const e=new Date(1980,0,1),t=new Date(e.getTime()+1e3*m),r=new Date(e);if(i)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),f.years++;if(a)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),f.months++;if(s)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),f.days++;m=Math.floor((t.getTime()-r.getTime())/1e3)}l&&(f.hours=Math.floor(m/3600),m%=3600),u&&(f.minutes=Math.floor(m/60),m%=60),c&&(f.seconds=m),f.total=+e.toFixed(2).replace(/\.00$/,"");const p=e=>{const t="string"==typeof e?parseInt(e):e;return Number.isNaN(t)?"NaN":String(t).padStart(2,"0")},d=[l?p(f.hours):null,u?p(f.minutes):null,c?p(f.seconds):null].filter(e=>null!==e).join(":");return r.replace(/\{years\}/g,String(f.years)).replace(/\{months\}/g,String(f.months)).replace(/\{days\}/g,String(f.days)).replace(/\{hours\}/g,p(f.hours)).replace(/\{minutes\}/g,p(f.minutes)).replace(/\{seconds\}/g,p(f.seconds)).replace(/\{time\}/g,d).replace(/\{total\}/g,String(f.total)).trim()}function l(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'seconds' argument must be a valid number.");return s(e,"hours","{hours}:{minutes}:{seconds}")}function u(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'seconds' argument must be a valid number.");return s(e,"days","{days}d {hours}:{minutes}:{seconds}")}function c(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 n=r.indexOf(t),o=n>=6,i=n>=5,a=n>=4,s=n>=3,l=n>=2,u=n>=1,c=n>=0,f={years:o?0:NaN,months:i?0:NaN,days:a?0:NaN,hours:s?0:NaN,minutes:l?0:NaN,seconds:u?0:NaN,milliseconds:c?0:NaN,total:NaN};let m=e;if(o||i||a){const e=new Date(1980,0,1),t=new Date(e.getTime()+m),r=new Date(e);if(o)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),f.years++;if(i)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),f.months++;if(a)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),f.days++;m=t.getTime()-r.getTime()}return s&&(f.hours=Math.floor(m/36e5),m%=36e5),l&&(f.minutes=Math.floor(m/6e4),m%=6e4),u&&(f.seconds=Math.floor(m/1e3),m%=1e3),c&&(f.milliseconds=m),f.total=+e,f}function f(e){if(!Array.isArray(e)&&!m(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 m(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}function p(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function d(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,n)=>{const o=new FileReader;o.onload=()=>{try{r(o.result)}catch(e){n(e)}},o.onerror=()=>{n(o.error)},o[t](e)}):Promise.reject(new TypeError(`The "method" argument must be one of: ${r.join(", ")}.`))}function y(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,n)=>{d(e,"readAsDataURL").then(e=>{if("string"!=typeof e)throw new TypeError("Expected file content to be a string.");const n=e.match(/^data:(.+);base64,(.*)$/);if(!n||!n[2])throw new Error("Invalid data URL format or missing Base64 content.");const[,o,i]=n;if(!/^[\w/+]+=*$/.test(i))throw new Error("Base64 content is malformed.");if("boolean"==typeof t)return r(t?e:i);if(!/^[\w-]+\/[\w.+-]+$/.test(t))throw new Error(`Invalid MIME type string: ${t}`);return r(`data:${t};base64,${i}`)}).catch(n)}):Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'))}function w(e){return e instanceof Blob?new Promise((t,r)=>d(e,"readAsText").then(e=>{if("string"!=typeof e)throw new TypeError("Expected file content to be a string.");const r=e.trim();if(0===r.length)throw new Error("File is empty or contains only whitespace.");const n=JSON.parse(r);if("object"!=typeof n||null===n)throw new Error("Parsed content is not a valid JSON object or array.");t(n)}).catch(r)):Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'))}function b(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 n=JSON.stringify(t,null,r),o=new Blob([n],{type:"application/json"}),i=URL.createObjectURL(o),a=document.createElement("a");a.href=i,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}function g(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 n=e.headers.get("content-length"),o=n?parseInt(n,10):0;let i=0;const a=e.body.getReader(),s=new ReadableStream({async start(e){for(;;){const{done:r,value:n}=await a.read();if(r)break;i+=n.byteLength,t(i,o),e.enqueue(n)}e.close()}});return new Response(s,r(e))}async function h(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((n,o)=>{fetch(e,t??void 0).then(async e=>{const t=r?g(e,r):e,o=t.headers.get("content-type")||"";if(!o.includes("application/json"))throw new Error(`Unexpected content-type: ${o}`);const i=await t.json();if(!Array.isArray(i)&&!m(i))throw new Error("Received invalid data instead of valid JSON.");return n(i)}).catch(o)})}async function E(e,t,r,n){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!==n&&"function"!=typeof n?Promise.reject(new TypeError('The "onProgress" option must be a function.')):new Promise((o,i)=>{fetch(e,r??void 0).then(async e=>{const r=n?g(e,n):e,i=r.headers.get("content-type")||"";if(Array.isArray(t)&&t.length>0&&!t.some(e=>i.includes(e)))throw new Error(`Blocked MIME type: ${i}`);const a=await r.text();return o(a)}).catch(i)}):Promise.reject(new TypeError('The "allowedMimeTypes" argument must be an array of strings.'))}function T(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:n="windowVisible",onVisible:o,onHidden:i}=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 n)throw new TypeError('"visibleClass" must be a string.');if(void 0!==o&&"function"!=typeof o)throw new TypeError('"onVisible" must be a function if provided.');if(void 0!==i&&"function"!=typeof i)throw new TypeError('"onHidden" must be a function if provided.');let a="",s="";const l=()=>{t.classList.remove(r),t.classList.remove(n)};let u=null;const c=["visibilitychange","mozvisibilitychange","webkitvisibilitychange","msvisibilitychange"],f=["hidden","mozHidden","webkitHidden","msHidden"];for(let e=0;e<f.length;e++)if(f[e]in document){u=f[e];break}const m=function(e){l();const c=e?.type,f=u&&document[u];["focus","focusin","pageshow"].includes(c)?(t.classList.add(n),o?.({type:c,oldClass:s,oldType:a}),s=n):["blur","focusout","pagehide"].includes(c)||f?(t.classList.add(r),i?.({type:c,oldClass:s,oldType:a}),s=r):(t.classList.add(n),o?.({type:c,oldClass:s,oldType:a}),s=n),a=c};let p=()=>{};if(u){const e=c[f.indexOf(u)];document.addEventListener(e,m),window.addEventListener("focus",m),window.addEventListener("blur",m),p=()=>{document.removeEventListener(e,m),window.removeEventListener("focus",m),window.removeEventListener("blur",m),l()}}else"onfocusin"in document?(document.onfocusin=document.onfocusout=m,p=()=>{document.onfocusin=document.onfocusout=null,l()}):(window.onpageshow=window.onpagehide=window.onfocus=window.onblur=m,p=()=>{window.onpageshow=window.onpagehide=window.onfocus=window.onblur=null,l()});const d=new Event(u&&document[u]?"blur":"focus");return m(d),p}e.r(t),e.d(t,{addAiMarkerShortcut:()=>G,areElsCollBottom:()=>ee,areElsCollLeft:()=>te,areElsCollPerfBottom:()=>oe,areElsCollPerfLeft:()=>ie,areElsCollPerfRight:()=>ae,areElsCollPerfTop:()=>ne,areElsCollRight:()=>re,areElsCollTop:()=>Q,areElsColliding:()=>se,areElsPerfColliding:()=>le,arraySortPositions:()=>i,asyncReplace:()=>J,breakdownDuration:()=>c,calculateMarketcap:()=>z,cloneObjTypeOrder:()=>F,compareMarketcap:()=>V,countObj:()=>f,createSingletonTask:()=>ke,diffArrayList:()=>o,diffObjList:()=>Z,diffStrings:()=>_,documentIsFullScreen:()=>k,exitFullScreen:()=>I,extendObjType:()=>A,extractMediaId3Tags:()=>je,fetchJson:()=>h,fetchText:()=>E,formatBytes:()=>H,formatCustomTimer:()=>s,formatDayTimer:()=>u,formatTimer:()=>l,genFibonacciSeq:()=>q,getAge:()=>Y,getElsCollDetails:()=>we,getElsCollDirDepth:()=>ye,getElsCollOverlap:()=>fe,getElsCollOverlapPos:()=>me,getElsColliding:()=>ue,getElsPerfColliding:()=>ce,getElsRelativeCenterOffset:()=>de,getPercentage:()=>U,getRectCenter:()=>pe,getSimplePerc:()=>$,getTimeDuration:()=>a,installWindowHiddenScript:()=>T,isFullScreenMode:()=>P,isJsonObject:()=>m,isObjType:()=>x,isScreenFilled:()=>L,isValidObj:()=>p,multiplyArrayBlocks:()=>n,objType:()=>D,objTypeName:()=>j,offFullScreenChange:()=>R,onFullScreenChange:()=>O,parseMediaMetadata:()=>xe,readBase64Blob:()=>y,readFileBlob:()=>d,readJsonBlob:()=>w,reorderObjTypeOrder:()=>M,requestFullScreen:()=>S,ruleOfThree:()=>B,safeTextTrim:()=>K,saveJsonFile:()=>b,shuffleArray:()=>r,toTitleCase:()=>W,toTitleCaseLowerFirst:()=>X,valMediaContentMetadata:()=>Me,valMediaContentMetadataPartial:()=>Fe,waitForTrue:()=>De});const v="undefined"!=typeof window&&void 0!==window.document,N={items:{},order:[]};function A(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=[],n=Array.isArray(e)?e:Object.entries(e);for(const e of n){if(!Array.isArray(e)||e.length<2)throw new TypeError("Each item in 'newItems' array must be a [key, function] pair.");const[n,o]=e;if("string"!=typeof n)throw new TypeError("Validator key must be a string.");if("function"!=typeof o)throw new TypeError(`Validator for key '${n}' must be a function.`);if(!N.items.hasOwnProperty(n)){N.items[n]=o;let e="number"==typeof t?t:-1;if(-1===e){const t=N.order.indexOf("object");e=t>-1?t:N.order.length}e=Math.min(Math.max(0,e),N.order.length),N.order.splice(e,0,n),r.push(n)}}return r}function M(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=[...N.order];return!!e.every(e=>t.includes(e))&&(N.order=e.slice(),!0)}function F(){return[...N.order]}const j=e=>{if(null===e)return"null";for(const t of N.order)if("function"!=typeof N.items[t]||N.items[t](e))return t;return"unknown"};function x(e,t){if("string"!=typeof t)throw new TypeError("Argument 'type' must be a string.");return j(e)===t.toLowerCase()}function D(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=j(e);return"string"==typeof t?r===t.toLowerCase():r}A([["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)]]),v&&A([["file",e=>"undefined"!=typeof File&&e instanceof File]]),A([["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]]),v&&A([["htmlelement",e=>"undefined"!=typeof HTMLElement&&e instanceof HTMLElement]]),A([["object",e=>m(e)]]);const k=()=>!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitIsFullScreen||document.mozFullScreen),L=()=>window.innerHeight===screen.height&&window.innerWidth===screen.width,P=()=>k()||L(),S=e=>new Promise(async(t,r)=>{const n=document.documentElement;try{n.requestFullscreen?await n.requestFullscreen(e):n.mozRequestFullScreen?n.mozRequestFullScreen(e):n.webkitRequestFullScreen?n.webkitRequestFullScreen(e):n.msRequestFullscreen&&n.msRequestFullscreen(e),t()}catch(e){r(e)}}),I=()=>new Promise((e,t)=>{if(document.exitFullscreen)document.exitFullscreen().then(e).catch(t);else try{if(document.mozCancelFullScreen)document.mozCancelFullScreen();else if(document.webkitCancelFullScreen)document.webkitCancelFullScreen();else{if(!document.msExitFullscreen)throw new Error("Fullscreen API is not supported");document.msExitFullscreen()}e()}catch(e){t(e)}}),C=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],O=(e,t)=>{C.forEach(r=>{document.addEventListener(r,e,t)})},R=(e,t)=>{C.forEach(r=>{document.removeEventListener(r,e,t)})};function B(e,t,r,n=!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 n)throw new TypeError("inverse must be a boolean.");return n?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 U(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 Y(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 n=t instanceof Date?t:new Date;let o=n.getFullYear()-r.getFullYear();const i=n.getMonth(),a=r.getMonth(),s=n.getDate(),l=r.getDate();return(i<a||i===a&&s<l)&&o--,Math.abs(o)}function H(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 n=["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(!n.includes(r))throw new RangeError(`maxUnit must be one of: ${n.join(", ")}`)}const o=r&&n.includes(r)?n.indexOf(r):n.length-1,i=Math.min(Math.floor(Math.log(e)/Math.log(1024)),o);let a=e/Math.pow(1024,i);if(null!==t){const e=t<0?0:t;a=parseFloat(a.toFixed(e))}return{unit:n[i],value:a}}function q({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 n=[...e.slice(0,2)];for(let e=2;e<t;e++){const t=r(n[e-2],n[e-1],e);n.push(t)}return n}function z(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 V(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 n=z(e,t),o="number"==typeof r?r/t:NaN;return{originalPrice:n,newPrice:o,priceChangePercent:"number"==typeof r?(o-n)/n*100:NaN}}async function J(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 n=[];e.replace(t,(e,...t)=>(n.push(r(e,...t)),e));const o=await Promise.all(n);return e.replace(t,()=>o.shift())}function W(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 X(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 G({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 K(e,t,r=.6){if("string"!=typeof e)throw new TypeError("Expected a string for 'text', but received "+typeof e);if(!Number.isInteger(t)||t<=0)throw new TypeError(`Expected 'limit' to be a positive integer, but received ${t}`);if("number"!=typeof r||r<0||r>1)throw new TypeError(`Expected 'safeCutZone' to be a number between 0 and 1, but received ${r}`);let n=e.trim();if(n.length>t){const e=n.lastIndexOf(" ",t);return e>0&&e>=t*r?`${n.substring(0,e).trim()}...`:`${n.substring(0,t).trim()}...`}return n}function Z(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 n in e)n in t?e[n]!==t[n]&&(r.modified[n]={old:e[n],new:t[n]}):r.removed[n]=e[n];for(const n in t)n in e||(r.added[n]=t[n]);return r}const _=Z,Q=(e,t)=>e.bottom<t.top,ee=(e,t)=>e.top>t.bottom,te=(e,t)=>e.right<t.left,re=(e,t)=>e.left>t.right,ne=(e,t)=>e.bottom<=t.top,oe=(e,t)=>e.top>=t.bottom,ie=(e,t)=>e.right<=t.left,ae=(e,t)=>e.left>=t.right,se=(e,t)=>!(te(e,t)||re(e,t)||Q(e,t)||ee(e,t)),le=(e,t)=>!(ie(e,t)||ae(e,t)||ne(e,t)||oe(e,t)),ue=(e,t)=>te(e,t)?"left":re(e,t)?"right":Q(e,t)?"top":ee(e,t)?"bottom":null,ce=(e,t)=>ie(e,t)?"left":ae(e,t)?"right":ne(e,t)?"top":oe(e,t)?"bottom":null,fe=(e,t)=>({overlapLeft:t.right-e.left,overlapRight:e.right-t.left,overlapTop:t.bottom-e.top,overlapBottom:e.bottom-t.top}),me=({overlapLeft:e=-1,overlapRight:t=-1,overlapTop:r=-1,overlapBottom:n=-1}={})=>({dirX:e<t?"right":"left",dirY:r<n?"bottom":"top"}),pe=e=>({x:e.left+e.width/2,y:e.top+e.height/2});function de(e,t){const r=e.left+e.width/2,n=e.top+e.height/2;return{x:t.left+t.width/2-r,y:t.top+t.height/2-n}}function ye(e,t){if(!le(e,t))return{inDir:null,dirX:null,dirY:null,depthX:0,depthY:0};const{overlapLeft:r,overlapRight:n,overlapTop:o,overlapBottom:i}=fe(e,t),{dirX:a,dirY:s}=me({overlapLeft:r,overlapRight:n,overlapTop:o,overlapBottom:i}),l=Math.min(r,n),u=Math.min(o,i);let c;return c=l<u?a:s,{inDir:c,dirX:a,dirY:s,depthX:l,depthY:u}}function we(e,t){const r=le(e,t),n={in:null,x:null,y:null},o={y:null,x:null},i={top:0,bottom:0,left:0,right:0},{overlapLeft:a,overlapRight:s,overlapTop:l,overlapBottom:u}=fe(t,e);i.top=l,i.bottom=u,i.left=a,i.right=s;const c=Object.entries(i).filter(([,e])=>e>0).sort((e,t)=>e[1]-t[1]),{dirX:f,dirY:m}=me({overlapLeft:s,overlapRight:a,overlapTop:u,overlapBottom:l});return n.y=m,n.x=f,i.bottom<0?o.y="bottom":i.top<0&&(o.y="top"),i.left<0?o.x="left":i.right<0&&(o.x="right"),n.in=r?i.top===i.bottom&&i.bottom===i.left&&i.left===i.right?"center":c.length?c[0][0]:"top":null,{dirs:n,depth:i,isNeg:o}}const be=(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}.`)},ge=(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}.`)},he=(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}.`)},Ee=new Map;class Te extends Error{constructor(e,t,r){if(be(e,"message"),be(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 ve=async e=>{be(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)},Ne=(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}.`);be(t,"format");const r=e=>{const t=URL.createObjectURL(e),r=Ee.get(t);return Ee.set(t,"number"==typeof r?r+1:1),t};if(e instanceof Uint8Array)return r(new Blob([e],{type:t}));if("string"==typeof e&&e.startsWith("data:")){const n=e.split(",")[1],o=atob(n),i=new Uint8Array(o.length);for(let e=0;e<o.length;e++)i[e]=o.charCodeAt(e);return r(new Blob([i],{type:t}))}return"string"==typeof e?e:""},Ae=(e,t)=>{if(he(e,"common"),"boolean"!=typeof t)throw new TypeError('Expected "isPartial" to be a boolean.');const r=e=>t&&void 0===e,n=e=>r(e)||"string"==typeof e||null===e,o=(e,t)=>(ge(t,"valueValidator"),!!r(e)||!(!Array.isArray(e)||!e.every(t)));if(!n(e.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!n(e.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!n(e.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a string or null.');if(!n(e.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(i=e.year,!r(i)&&"number"!=typeof i&&null!==i)throw new TypeError('Invalid metadata: "year" must be a number or null.');var i;if(!o(e.albumartists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "albumartists" must be an array of string.');if(!o(e.genre,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "genre" must be an array of string.');if(!o(e.label,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "label" must be an array of string.');if(!o(e.composer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "composer" must be an array of string.');if(!o(e.artists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "artists" must be an array of string.');if(!o(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 a=(e,t)=>{if(be(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.`)}};a("disk",e.disk),a("track",e.track)},Me=e=>(he(e,"common"),Ae(e,!1)),Fe=e=>(he(e,"common"),Ae(e,!0)),je=async(e,t)=>{be(e,"url"),ge(t,"parseFile");try{const r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch audio file: ${r.status} ${r.statusText}`);const n=await r.blob(),o=await t(n);if(!o||"object"!=typeof o.common)throw new TypeError('Invalid metadata: "common" property is missing or not an object.');const i=o.common;return Fe(i),{title:i?.title??null,album:i?.album??null,albumartist:i?.albumartist??null,albumartists:i?.albumartists??[],genre:i?.genre??[],label:i?.label??[],composer:i?.composer??[],year:i?.year??null,artist:i?.artist??null,artists:i?.artists??[],disk:i?.disk?{no:i.disk.no,of:i.disk.of}:{no:null,of:null},track:i?.track?{no:i.track.no,of:i.track.of}:{no:null,of:null},picture:i?.picture?.map(e=>({...e,data:Ne(e.data,e.format)}))??[]}}catch(e){throw e}},xe=async(e,t={},r={},n=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.")))},o={},i="null")=>{if("string"!=typeof e&&!(e instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(he(t,"defaultMetadata"),he(r,"metadata"),ge(n,"parseFile"),he(o,"callbacks"),o.onProgress&&"function"!=typeof o.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(o.onError&&"function"!=typeof o.onError)throw new TypeError("callbacks.onError must be a function.");if("string"!=typeof i&&"function"!=typeof i)throw new TypeError("unknownArtist must be a string or a function returning a string.");let a,s="";const l=(t,r)=>{if(be(t,"stage"),void 0!==r&&!(r instanceof Event))throw new TypeError('Expected "event" to be an Event or undefined.');o.onProgress&&o.onProgress({event:r,status:"loading",stage:t,url:s||(e instanceof HTMLMediaElement?e.src:"unknown")})},u=(t,r)=>{if(!(t instanceof Error))throw new TypeError('Expected "error" to be an Error.');be(r,"stage"),o.onError&&o.onError({error:t,url:s||(e instanceof HTMLMediaElement?e.src:"unknown"),stage:r})};try{l("INITIALIZING"),"string"==typeof e?(s=e,a=new Audio(s)):(a=e,s=a.src);try{await new Promise((e,t)=>{const r=e=>l("DOWNLOADING",e),n=()=>{i(),e(void 0)},o=e=>{i(),t(new Error(`HTMLMediaElement failed to load: ${e.message||"Unknown error"}`))},i=()=>{a.removeEventListener("progress",r),a.removeEventListener("loadedmetadata",n),a.removeEventListener("error",o)};a.addEventListener("progress",r),a.addEventListener("loadedmetadata",n),a.addEventListener("error",o),a.readyState>=1&&(i(),e(void 0))}),l("METADATA_LOADED")}catch(e){throw new Te(e instanceof Error?e.message:"UNKNOWN ERROR",s,"METADATA")}const c={id:r.id||await ve(s),duration:Math.floor(1e3*a.duration),url:s,weight:r.weight??1};let f={};l("EXTRACTING_ID3");try{f=await je(s,n)}catch(e){u(e instanceof Error?e:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${s}. Falling back to filename.`)}const m=e=>{be(e,"url");try{return(e.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},p={...c,...t,...f,...r,title:f.title||r.title||m(s),artist:f.artist||r.artist||("string"==typeof i?i:String(i()))};return o.onProgress&&o.onProgress({status:"success",stage:"COMPLETE",url:s}),p}catch(e){if(e instanceof Te)throw e;{const t=new Te(e instanceof Error?e.message:"UNKNOWN ERROR",s,"INITIALIZING");throw u(t,"INITIALIZING"),t}}},De=(e,t=100)=>{if("function"!=typeof e)throw new TypeError("Expected 'getValue' to be a function.");if(!Number.isFinite(t)||t<=0)throw new TypeError("Expected 'checkInterval' to be a positive number.");return new Promise(r=>{const n=setInterval(()=>{e()&&(clearInterval(n),r())},t)})},ke=e=>{if("function"!=typeof e)throw new TypeError('The argument "baseFunction" must be a function.');let t=null;return{callback:async(...r)=>(null!==t||(t=(async()=>{try{const n=await e(...r);return t=null,n}catch(e){throw t=null,e}})()),t),getActivePromise:()=>t,resetActivePromise:()=>{t=null}}};window.TinyBasicsEs=t})();