tiny-essentials 1.28.16 → 1.28.18

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
- (()=>{"use strict";var e={314(e,t,r){r.d(t,{TinyMediaPlayer:()=>L});var o=r.cjs(function(e,t){var r,o="object"==typeof Reflect?Reflect:null,n=o&&"function"==typeof o.apply?o.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};r=o&&"function"==typeof o.ownKeys?o.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,e.exports.once=function(e,t){return new Promise(function(r,o){function n(r){e.removeListener(t,i),o(r)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",n),r([].slice.call(arguments))}f(e,t,i,{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 a=10;function l(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function d(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function u(e,t,r,o){var n,i,s,a;if(l(r),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),s=i[t]),void 0===s)s=i[t]=r,++e._eventsCount;else if("function"==typeof s?s=i[t]=o?[r,s]:[s,r]:o?s.unshift(r):s.push(r),(n=d(e))>0&&s.length>n&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,console&&console.warn&&console.warn(a)}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 m(e,t,r){var o={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},n=h.bind(o);return n.listener=r,o.wrapFn=n,n}function p(e,t,r){var o=e._events;if(void 0===o)return[];var n=o[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):y(n,n.length)}function c(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 y(e,t){for(var r=new Array(t),o=0;o<t;++o)r[o]=e[o];return r}function f(e,t,r,o){if("function"==typeof e.on)o.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(i){o.once&&e.removeEventListener(t,n),r(i)})}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=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||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return d(this)},s.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var o="error"===e,i=this._events;if(void 0!==i)o=o&&void 0===i.error;else if(!o)return!1;if(o){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var l=i[e];if(void 0===l)return!1;if("function"==typeof l)n(l,this,t);else{var d=l.length,u=y(l,d);for(r=0;r<d;++r)n(u[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 l(t),this.on(e,m(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,m(this,e,t)),this},s.prototype.removeListener=function(e,t){var r,o,n,i,s;if(l(t),void 0===(o=this._events))return this;if(void 0===(r=o[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(n=-1,i=r.length-1;i>=0;i--)if(r[i]===t||r[i].listener===t){s=r[i].listener,n=i;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&&(o[e]=r[0]),void 0!==o.removeListener&&this.emit("removeListener",e,s||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,r,o;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,i=Object.keys(r);for(o=0;o<i.length;++o)"removeListener"!==(n=i[o])&&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(o=t.length-1;o>=0;o--)this.removeListener(e,t[o]);return this},s.prototype.listeners=function(e){return p(this,e,!0)},s.prototype.rawListeners=function(e){return p(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):c.call(e,t)},s.prototype.listenerCount=c,s.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}});function n(e){if(!Array.isArray(e)&&!i(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 i(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}function s(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}const a=["chrome","firefox","ie","edge","safari","opera","yandex","other"];class l extends o.EventEmitter{#e;#t;#r;#o;#n;#i=new Map([["log",""],["info",""],["warn",""],["error",""],["debug",""],["reset",""],["black",""],["red",""],["green",""],["yellow",""],["blue",""],["magenta",""],["cyan",""],["white",""],["gray",""]]);#s=new Map([["log","[_log_LOG_reset_]"],["info","[_info_INFO_reset_]"],["warn","[_warn_WARN_reset_]"],["error","[_error_ERROR_reset_]"],["debug","[_debug_DEBUG_reset_]"]]);constructor({logger:e,id:t,debugMode:r,canEmitLogs:o=!1,useLogColors:n=!1}){if(super(),!s(e))throw new TypeError("Logger must be an object that implements the Console interface.");if("string"!=typeof t)throw new TypeError("Logger instance id must be a string.");if("boolean"!=typeof r)throw new TypeError("debugMode must be a boolean.");if("boolean"!=typeof o)throw new TypeError("canEmitLogs must be a boolean.");if("boolean"!=typeof n)throw new TypeError("useLogColors must be a boolean.");this.#t=t,this.#e=e,this.#o=r,this.#r=o,this.#n="firefox"!==function(e=[]){const t=function(e=[]){if(!Array.isArray(e))throw new TypeError('The "disable" argument must be an array.');for(const t of e)if(!a.includes(t))throw new TypeError(`Invalid browser name provided in disable array: ${t}`);const t={chrome:0,firefox:0,ie:0,edge:0,safari:0,opera:0,yandex:0,other:0};t[function(){const e=navigator.userAgent;return-1!==e.indexOf("Chrome")?"chrome":-1!==e.indexOf("Firefox")?"firefox":-1!==e.indexOf("MSIE")?"ie":-1!==e.indexOf("Edge")?"edge":-1!==e.indexOf("Safari")?"safari":-1!==e.indexOf("Opera")?"opera":-1!==e.indexOf("YaBrowser")?"yandex":"other"}()]++;const r=function(){const e=(Array.prototype.slice.call(window.getComputedStyle(document.documentElement,"")).join("").match(/-(moz|webkit|ms)-/)??["",""])[1];return"moz"===e?"gecko":"webkit"===e?"webkit":"ms"===e?"trident":"other"}();"gecko"===r?e.indexOf("firefox")<0&&t.firefox++:"webkit"===r?(e.indexOf("chrome")<0&&t.chrome++,e.indexOf("safari")<0&&t.safari++,e.indexOf("opera")<0&&t.opera++,e.indexOf("edge")<0&&t.edge++):"trident"===r?e.indexOf("ie")<0&&t.ie++:e.indexOf("other")<0&&t.other++;const o=function(){const e=!!window.opr&&!!opr.addons||!!window.opera||navigator.userAgent.indexOf(" OPR/")>=0,t="undefined"!=typeof InstallTrigger,r=/constructor/i.test(window.HTMLElement)||"[object SafariRemoteNotification]"===(!window.safari||"undefined"!=typeof safari&&safari.pushNotification).toString(),o=!!document.documentMode,n=!o&&!!window.StyleMedia,i=!!window.chrome;return{isOpera:e,isFirefox:t,isSafari:r,isIE:o,isEdge:n,isChrome:i,isBlink:(i||e)&&!!window.CSS}}();return o.isOpera&&e.indexOf("opera")<0&&t.opera++,o.isFirefox&&e.indexOf("firefox")<0&&t.firefox++,o.isSafari&&e.indexOf("safari")<0&&t.safari++,o.isIE&&e.indexOf("ie")<0&&t.ie++,o.isEdge&&e.indexOf("edge")<0&&t.edge++,o.isChrome&&e.indexOf("chrome")<0&&t.chrome++,t}(e);return Object.keys(t).reduce((e,r)=>t[r]>t[e]?r:e)}()&&n,this.log("info","Emit logs of debug mode set to: "+(this.#o?"ON":"OFF")),this.log("info","Custom logger assigned.")}get logId(){return this.#t}get canEmitLogs(){return this.#r}get useLogColors(){return this.#n}set useLogColors(e){if("boolean"!=typeof e)throw new TypeError("useLogColors must be a boolean.");this.#n=e,this.log("info","Log Colors usage mode set to: "+(this.#n?"ON":"OFF")),this.emit("setDebugMode",e)}get debugMode(){return this.#o}set debugMode(e){if("boolean"!=typeof e)throw new TypeError("debugMode must be a boolean.");this.#o=e,this.log("info","Debug mode set to: "+(this.#o?"ON":"OFF")),this.emit("setDebugMode",e)}_addLogColor(e,t){this.#i.set(e,t)}_removeLogColor(e){this.#i.delete(e)}_addLogPrefix(e,t){this.#s.set(e,t)}_removeLogPrefix(e){this.#s.delete(e)}#a(e){if("string"!=typeof e)return e;let t=e;for(const[e,r]of this.#s){const o=new RegExp(`\\:${e}\\:`,"g");t=t.replace(o,r)}for(const[e,r]of this.#i){const o=new RegExp(`\\_${e}\\_`,"g");t=t.replace(o,this.#n?r:"")}return t}logClear(){if(this.#o)return this.#r&&this.emit("debug:clear"),this.#e.clear?this.#e.clear():console.clear()}logGroupEnd(){if(this.#o)return this.#r&&this.emit("debug:groupEnd"),this.#e.groupEnd?this.#e.groupEnd():console.groupEnd()}logLabel(e,t){if(!this.#o)return;const r=["count","countReset","time","timeEnd","profile","profileEnd","timeStamp"];if(!r.includes(e))throw new TypeError(`Invalid logType. Expected one of: ${r.join(", ")}`);if(void 0!==t&&"string"!=typeof t)throw new TypeError("The label must be a string.");const o=this.#e[e]?this.#e[e]:console[e];if(!o)throw new TypeError(`The log type "${e}" is not supported by the provided logger or console.`);return this.#r&&this.emit("debug:logLabel",e,t),o(t)}logTimeLabel(e,...t){if(this.#o)return this.#r&&this.emit("debug:timeLog",e,...t),this.#e.timeLog?this.#e.timeLog(e,...t):console.timeLog(e,...t)}logAssert(e,...t){if(this.#o)return this.#r&&this.emit("debug:assert",e,...t),this.#e.assert?this.#e.assert(e,...t):console.assert(e,...t)}logDir(e,t){if(this.#o)return this.#r&&this.emit("debug:dir",e,t),this.#e.dir?this.#e.dir(e,t):console.dir(e,t)}logTable(e,t){if(this.#o){if(!(void 0===t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("Properties must be an array of strings.");return this.#r&&this.emit("debug:table",e,t),this.#e.table?this.#e.table(e,t):console.table(e,t)}}log(e,t,...r){if(!this.#o)return;const o=["log","info","warn","error","debug","dirxml","group","groupCollapsed","trace"];if(!o.includes(e))throw new TypeError(`Invalid logType. Expected one of: ${o.join(", ")}`);if("string"!=typeof t)throw new TypeError("The message must be a string.");let n=this.#t,i=t;n=this.#a(n),i=this.#a(i);const s=this.#e[e]?this.#e[e]:console[e];return s?(this.#r&&this.emit("debug:log",n,i,...r),s(n,i,...r)):(this.#r&&this.emit("debug:log",n,i,...r),console.log(n,i,...r))}}const d=l,u=(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}.`)},h=(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}.`)},m=(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}.`)},p=(e,t=!1)=>!t&&void 0===e,c=(e,t=!1)=>p(e,t)||"string"==typeof e||!t&&null===e,y=(e,t=!1)=>p(e,t)||"number"==typeof e||!t&&null===e,f=(e,t=!1)=>p(e,t)||"boolean"==typeof e||!t&&null===e,g=(e,t)=>!!p(e)||(h(t,"valueValidator"),Array.isArray(e)&&e.every(t)),w=new Map;class b extends Error{constructor(e,t,r){if(u(e,"message"),u(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 v=async e=>{u(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)},E=(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}.`);u(t,"format");const r=e=>{const t=URL.createObjectURL(e),r=w.get(t);return w.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 o=e.split(",")[1],n=atob(o),i=new Uint8Array(n.length);for(let e=0;e<n.length;e++)i[e]=n.charCodeAt(e);return r(new Blob([i],{type:t}))}return"string"==typeof e?e:""},T=(e,t=!1)=>{if(i(e)){if(4!==n(e)){if(t)return!1;throw new TypeError("Invalid fetch data: Object must be an MediaContentFetchData.")}I(e.common),m(e.native,"_fetchData.native"),m(e.format,"_fetchData.format"),m(e.quality,"_fetchData.quality");for(const r in e.native){const o=e.native[r];if(!g(o,e=>"string"==typeof e.id)){if(t)return!1;throw new TypeError(`Invalid native data: "${r}" must be an array of native fetch data.`)}}}return!0},I=e=>{if(m(e,"common"),T(e._fetchData),!c(e.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!c(e.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!c(e.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a a string or null.');if(!c(e.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(!f(e.compilation))throw new TypeError('Invalid metadata: "compilation" must be a boolean or null.');if(!f(e.podcast))throw new TypeError('Invalid metadata: "podcast" must be a boolean or null.');if(!f(e.gapless))throw new TypeError('Invalid metadata: "gapless" must be a boolean or null.');if(!f(e.showMovement))throw new TypeError('Invalid metadata: "showMovement" must be a boolean or null.');if(!y(e.averageLevel))throw new TypeError('Invalid metadata: "averageLevel" must be a number or null.');if(!y(e.peakLevel))throw new TypeError('Invalid metadata: "peakLevel" must be a number or null.');if(!y(e.hdVideo))throw new TypeError('Invalid metadata: "hdVideo" must be a number or null.');if(!y(e.stik))throw new TypeError('Invalid metadata: "stik" must be a number or null.');if(!y(e.playCounter))throw new TypeError('Invalid metadata: "playCounter" must be a number or null.');if(!y(e.tvSeason))throw new TypeError('Invalid metadata: "tvSeason" must be a number or null.');if(!y(e.tvEpisode))throw new TypeError('Invalid metadata: "tvEpisode" must be a number or null.');if(!y(e.year))throw new TypeError('Invalid metadata: "year" must be a number or null.');if(!y(e.bpm))throw new TypeError('Invalid metadata: "bpm" must be a number or null.');if(!y(e.originalyear))throw new TypeError('Invalid metadata: "originalyear" must be a number or null.');if(!y(e.movementTotal))throw new TypeError('Invalid metadata: "movementTotal" must be a number or null.');if(!c(e.date))throw new TypeError('Invalid metadata: "date" must be a string or null.');if(!c(e.originaldate))throw new TypeError('Invalid metadata: "originaldate" must be a string or null.');if(!c(e.releasedate))throw new TypeError('Invalid metadata: "releasedate" must be a string or null.');if(!c(e.albumsort))throw new TypeError('Invalid metadata: "albumsort" must be a string or null.');if(!c(e.titlesort))throw new TypeError('Invalid metadata: "titlesort" must be a string or null.');if(!c(e.work))throw new TypeError('Invalid metadata: "work" must be a string or null.');if(!c(e.artistsort))throw new TypeError('Invalid metadata: "artistsort" must be a string or null.');if(!c(e.albumartistsort))throw new TypeError('Invalid metadata: "albumartistsort" must be a string or null.');if(!c(e.composersort))throw new TypeError('Invalid metadata: "composersort" must be a string or null.');if(!c(e.grouping))throw new TypeError('Invalid metadata: "grouping" must be a string or null.');if(!c(e.longDescription))throw new TypeError('Invalid metadata: "longDescription" must be a string or null.');if(!c(e.totaltracks))throw new TypeError('Invalid metadata: "totaltracks" must be a string or null.');if(!c(e.totaldiscs))throw new TypeError('Invalid metadata: "totaldiscs" must be a string or null.');if(!c(e.mood))throw new TypeError('Invalid metadata: "mood" must be a string or null.');if(!c(e.media))throw new TypeError('Invalid metadata: "media" must be a string or null.');if(!c(e.tvShow))throw new TypeError('Invalid metadata: "tvShow" must be a string or null.');if(!c(e.tvShowSort))throw new TypeError('Invalid metadata: "tvShowSort" must be a string or null.');if(!c(e.tvEpisodeId))throw new TypeError('Invalid metadata: "tvEpisodeId" must be a string or null.');if(!c(e.tvNetwork))throw new TypeError('Invalid metadata: "tvNetwork" must be a string or null.');if(!c(e.podcasturl))throw new TypeError('Invalid metadata: "podcasturl" must be a string or null.');if(!c(e.releasestatus))throw new TypeError('Invalid metadata: "releasestatus" must be a string or null.');if(!c(e.releasecountry))throw new TypeError('Invalid metadata: "releasecountry" must be a string or null.');if(!c(e.script))throw new TypeError('Invalid metadata: "script" must be a string or null.');if(!c(e.language))throw new TypeError('Invalid metadata: "language" must be a string or null.');if(!c(e.copyright))throw new TypeError('Invalid metadata: "copyright" must be a string or null.');if(!c(e.license))throw new TypeError('Invalid metadata: "license" must be a string or null.');if(!c(e.encodedby))throw new TypeError('Invalid metadata: "encodedby" must be a string or null.');if(!c(e.encodersettings))throw new TypeError('Invalid metadata: "encodersettings" must be a string or null.');if(!c(e.barcode))throw new TypeError('Invalid metadata: "barcode" must be a string or null.');if(!c(e.asin))throw new TypeError('Invalid metadata: "asin" must be a string or null.');if(!c(e.website))throw new TypeError('Invalid metadata: "website" must be a string or null.');if(!c(e.originalalbum))throw new TypeError('Invalid metadata: "originalalbum" must be a string or null.');if(!c(e.originalartist))throw new TypeError('Invalid metadata: "originalartist" must be a string or null.');if(!c(e.key))throw new TypeError('Invalid metadata: "key" must be a string or null.');if(!c(e.movement))throw new TypeError('Invalid metadata: "movement" must be a string or null.');if(!c(e.podcastId))throw new TypeError('Invalid metadata: "podcastId" must be a string or null.');if(!g(e.albumartists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "albumartists" must be an array of strings.');if(!g(e.genre,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "genre" must be an array of strings.');if(!g(e.label,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "label" must be an array of strings.');if(!g(e.composer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "composer" must be an array of strings.');if(!g(e.artists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "artists" must be an array of strings.');if(!g(e.lyricist,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "lyricist" must be an array of strings.');if(!g(e.writer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "writer" must be an array of strings.');if(!g(e.conductor,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "conductor" must be an array of strings.');if(!g(e.remixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "remixer" must be an array of strings.');if(!g(e.arranger,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "arranger" must be an array of strings.');if(!g(e.engineer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "engineer" must be an array of strings.');if(!g(e.publisher,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "publisher" must be an array of strings.');if(!g(e.producer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "producer" must be an array of strings.');if(!g(e.djmixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "djmixer" must be an array of strings.');if(!g(e.mixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "mixer" must be an array of strings.');if(!g(e.technician,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "technician" must be an array of strings.');if(!g(e.subtitle,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "subtitle" must be an array of strings.');if(!g(e.description,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "description" must be an array of strings.');if(!g(e.discsubtitle,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "discsubtitle" must be an array of strings.');if(!g(e.releasetype,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "releasetype" must be an array of strings.');if(!g(e.isrc,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "isrc" must be an array of strings.');if(!g(e.performer_instrument,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "performer_instrument" must be an array of strings.');if(!g(e.notes,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "notes" must be an array of strings.');if(!g(e.category,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "category" must be an array of strings.');if(!g(e.keywords,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "keywords" must be an array of strings.');if(!g(e.catalognumber,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "catalognumber" must be an array of strings.');if(!g(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.');if(!g(e.comment,e=>null!==e&&"object"==typeof e&&c(e.descriptor)&&c(e.language)&&c(e.text)))throw new TypeError('Invalid metadata: "comment" must be an array of valid IComment objects.');if(!g(e.lyrics,e=>null!==e&&"object"==typeof e&&c(e.text)&&c(e.descriptor)&&c(e.language)&&(!Array.isArray(e)||g(e.syncText,e=>null!==e&&"object"==typeof e&&c(e.text)&&y(e.timestamp)))&&(e=>void 0===e||null!==e&&"object"==typeof e&&y(e.notSynchronized)&&y(e.mpegFrameNumber)&&y(e.milliseconds))(e.timeStampFormat)&&(e=>void 0===e||null!==e&&"object"==typeof e&&y(e.other)&&y(e.lyrics)&&y(e.text)&&y(e.movement_part)&&y(e.events)&&y(e.chord)&&y(e.trivia_pop))(e.contentType)))throw new TypeError('Invalid metadata: "lyrics" must be an array of valid ILyricsTag objects.');if(!g(e.rating,e=>null!==e&&"object"==typeof e&&c(e.source)&&y(e.rating)))throw new TypeError('Invalid metadata: "rating" must be an array of valid IRating objects.');const t=(e,t)=>{if(!p(t)&&null!==t){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.`)}};t("disk",e.disk),t("track",e.track),t("movementIndex",e.movementIndex)},x=e=>t=>{if(t)throw new Error(`This ${e} instance has been destroyed and can no longer be used.`)},A=x("BaseMediaAdapter");class k extends o.EventEmitter{constructor(){if(new.target===k)throw new Error("BaseMediaAdapter is an abstract class and cannot be instantiated directly.");super()}#l=!1;get destroyed(){return this.#l}static getThumbnailUrl(e){if("string"!=typeof e||""===e.trim())throw new TypeError('The "trackId" must be a non-empty string.');return""}static canHandle(e){throw new Error('Method "canHandle" must be implemented by the subclass.')}isReady(){throw A(this.#l),new Error('Method "isReady" must be implemented by the subclass.')}isPaused(){throw A(this.#l),new Error('Method "isPaused" must be implemented by the subclass.')}isEnded(){throw A(this.#l),new Error('Method "isEnded" must be implemented by the subclass.')}async waitIsReady(){throw A(this.#l),new Error('Method "waitIsReady" must be implemented by the subclass.')}canHandle(e){return A(this.#l),k.canHandle(e)}async play(e){throw A(this.#l),new Error('Method "play" must be implemented by the subclass.')}async pause(){throw A(this.#l),new Error('Method "pause" must be implemented by the subclass.')}async stop(){throw A(this.#l),new Error('Method "stop" must be implemented by the subclass.')}async seek(e){throw A(this.#l),new Error('Method "seek" must be implemented by the subclass.')}isMuted(){throw A(this.#l),new Error('Method "isMuted" must be implemented by the subclass.')}async mute(){throw A(this.#l),new Error('Method "mute" must be implemented by the subclass.')}async unMute(){throw A(this.#l),new Error('Method "unMute" must be implemented by the subclass.')}getCurrentTime(){throw A(this.#l),new Error('Method "getCurrentTime" must be implemented by the subclass.')}getTotalDuration(){throw A(this.#l),new Error('Method "getTotalDuration" must be implemented by the subclass.')}getRemainingTime(){throw A(this.#l),new Error('Method "getRemainingTime" must be implemented by the subclass.')}getPlaybackPercentage(){throw A(this.#l),new Error('Method "getPlaybackPercentage" must be implemented by the subclass.')}getTimeData(){throw A(this.#l),new Error('Method "getTimeData" must be implemented by the subclass.')}setVolume(e){throw A(this.#l),new Error('Method "setVolume" must be implemented by the subclass.')}getVolume(){throw A(this.#l),new Error('Method "getVolume" must be implemented by the subclass.')}async getContentData(){throw A(this.#l),new Error('Method "getContentData" must be implemented by the subclass.')}destroy(){this.#l||(this.removeAllListeners(),this.#l=!0,this.emit("destroyed"))}}const M=x("TinyMediaPlayer");class C extends d{static BaseMediaAdapter=k;static#d="Unknown Artist";static get unknownArtist(){return C.#d}static set unknownArtist(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("unknownArtist must be a string or a function.");C.#d=e}static async parseContent(e,t,r,o,s,a){return(async(e,t={},r={},o=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.")))},s={},a=!0,l="null")=>{if("string"!=typeof e&&!(e instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(m(t,"defaultMetadata"),m(r,"metadata"),h(o,"parseFile"),m(s,"callbacks"),s.onProgress&&"function"!=typeof s.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(s.onError&&"function"!=typeof s.onError)throw new TypeError("callbacks.onError must be a function.");if("string"!=typeof l&&"function"!=typeof l)throw new TypeError("unknownArtist must be a string or a function returning a string.");let d,p="";const c=(t,r)=>{if(u(t,"stage"),void 0!==r&&!(r instanceof Event))throw new TypeError('Expected "event" to be an Event or undefined.');s.onProgress&&s.onProgress({event:r,status:"loading",stage:t,url:p||(e instanceof HTMLMediaElement?e.src:"unknown")})},y=(t,r)=>{if(!(t instanceof Error))throw new TypeError('Expected "error" to be an Error.');u(r,"stage"),s.onError&&s.onError({error:t instanceof Error?t:new Error(String(t)),url:p||(e instanceof HTMLMediaElement?e.src:"unknown"),stage:r})};try{c("INITIALIZING"),"string"==typeof e?(p=e,d=new Audio(p)):(d=e,p=d.src);try{await new Promise((e,t)=>{const r=e=>c("DOWNLOADING",e),o=()=>{i(),e(void 0)},n=e=>{i(),t(new Error(`HTMLMediaElement failed to load: ${e.message||"Unknown error"}`))},i=()=>{d.removeEventListener("progress",r),d.removeEventListener("loadedmetadata",o),d.removeEventListener("error",n)};d.addEventListener("progress",r),d.addEventListener("loadedmetadata",o),d.addEventListener("error",n),d.readyState>=1&&(i(),e(void 0))}),c("METADATA_LOADED")}catch(e){throw new b(e instanceof Error?e.message:"UNKNOWN ERROR",p,"METADATA")}const m={id:r.id||await v(p),duration:Math.floor(1e3*d.duration),url:p,weight:r.weight??1};let f={};c("EXTRACTING_ID3");try{f=await(async(e,t,r=!0)=>{u(e,"url"),h(t,"parseFile");const o=await fetch(e);if(!o.ok)throw new Error(`Failed to fetch audio file: ${o.status} ${o.statusText}`);const s=await o.blob(),a=await t(s);if(!a||"object"!=typeof a.common)throw new TypeError('Invalid metadata: "common" property is missing.');void 0!==typeof a.common["performer:instrument"]&&(a.common.performer_instrument=a.common["performer:instrument"]),T(a);const l=a.common;I(l);const d=([e,t])=>Array.isArray(t)?t.length>0:i(t)?n(Object.fromEntries(Object.entries(t).filter(d)))>0:null!==t,m=l?.picture?.map(e=>({...e,data:r?E(e.data,e.format):e.data}))??[];a.common={...a.common,picture:m.map(e=>({...e,data:""}))},r&&Object.keys(a.native).forEach(e=>{a.native[e]=a.native[e].map(e=>{if(e.value&&"object"==typeof e.value&&e.value.data instanceof Uint8Array){const t=l?.picture?.findIndex(t=>t.data===e.value.data&&t.format===e.value.format&&t.description===e.value.description&&t.name===e.value.name)??-1;if(m[t])return{...e,value:{...e.value,data:""}}}return e})});const p=Object.fromEntries(Object.entries({title:l?.title??null,album:l?.album??null,albumartist:l?.albumartist??null,albumartists:l?.albumartists??[],genre:l?.genre??[],label:l?.label??[],composer:l?.composer??[],year:l?.year??null,artist:l?.artist??null,artists:l?.artists??[],disk:l?.disk?{no:l.disk.no,of:l.disk.of}:null,track:l?.track?{no:l.track.no,of:l.track.of}:null,movementIndex:l?.movementIndex?{no:l.movementIndex.no,of:l.movementIndex.of}:null,picture:m,date:l?.date??null,originaldate:l?.originaldate??null,originalyear:l?.originalyear??null,releasedate:l?.releasedate??null,comment:l?.comment??[],lyrics:l?.lyrics??[],albumsort:l?.albumsort??null,titlesort:l?.titlesort??null,work:l?.work??null,artistsort:l?.artistsort??null,albumartistsort:l?.albumartistsort??null,composersort:l?.composersort??null,lyricist:l?.lyricist??[],writer:l?.writer??[],conductor:l?.conductor??[],remixer:l?.remixer??[],arranger:l?.arranger??[],engineer:l?.engineer??[],publisher:l?.publisher??[],producer:l?.producer??[],djmixer:l?.djmixer??[],mixer:l?.mixer??[],technician:l?.technician??[],grouping:l?.grouping??null,subtitle:l?.subtitle??[],description:l?.description??[],longDescription:l?.longDescription??null,discsubtitle:l?.discsubtitle??[],totaltracks:l?.totaltracks??null,totaldiscs:l?.totaldiscs??null,movementTotal:l?.movementTotal??null,compilation:l?.compilation??null,rating:l?.rating??[],bpm:l?.bpm??null,mood:l?.mood??null,media:l?.media??null,catalognumber:l?.catalognumber??[],tvShow:l?.tvShow??null,tvShowSort:l?.tvShowSort??null,tvSeason:l?.tvSeason??null,tvEpisode:l?.tvEpisode??null,tvEpisodeId:l?.tvEpisodeId??null,tvNetwork:l?.tvNetwork??null,podcast:l?.podcast??null,podcasturl:l?.podcasturl??null,releasestatus:l?.releasestatus??null,releasetype:l?.releasetype??[],releasecountry:l?.releasecountry??null,script:l?.script??null,language:l?.language??null,copyright:l?.copyright??null,license:l?.license??null,encodedby:l?.encodedby??null,encodersettings:l?.encodersettings??null,gapless:l?.gapless??null,barcode:l?.barcode??null,isrc:l?.isrc??[],asin:l?.asin??null,website:l?.website??null,performer_instrument:l?.performer_instrument??[],averageLevel:l?.averageLevel??null,peakLevel:l?.peakLevel??null,notes:l?.notes??[],originalalbum:l?.originalalbum??null,originalartist:l?.originalartist??null,key:l?.key??null,category:l?.category??[],hdVideo:l?.hdVideo??null,keywords:l?.keywords??[],movement:l?.movement??null,podcastId:l?.podcastId??null,showMovement:l?.showMovement??null,stik:l?.stik??null,playCounter:l?.playCounter??null}).filter(d));return p._fetchData=a,p})(p,o,a)}catch(e){y(e instanceof Error?e:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${p}. Falling back to filename.`)}const g=e=>{u(e,"url");try{return(e.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},w=e=>{const t={...e};return i(t._fetchData)&&(i(f._fetchData)&&(t._fetchData={...f._fetchData}),i(e._fetchData)&&(void 0!==e._fetchData.common&&(t._fetchData.common=e._fetchData.common),void 0!==e._fetchData.native&&(t._fetchData.native=e._fetchData.native),void 0!==e._fetchData.format&&(t._fetchData.format=e._fetchData.format),void 0!==e._fetchData.quality&&(t._fetchData.quality=e._fetchData.quality))),t},x={...m,...w(t),...f,...w(r),title:f.title||r.title||g(p),artist:f.artist||r.artist||("string"==typeof l?l:String(l()))};return s.onProgress&&s.onProgress({status:"success",stage:"COMPLETE",url:p}),x}catch(e){if(e instanceof b)throw e;const t=new b(e instanceof Error?e.message:"UNKNOWN ERROR",p,"INITIALIZING");throw y(t,"INITIALIZING"),t}})(e,t,r,o,s,a,C.#d)}#l=!1;get destroyed(){return this.#l}#u=new Set;#h=new WeakMap;#m=[];#p=-1;#c="NONE";#y=!1;#f=!1;#g=!1;#w=1;#b;#v;#E;#T=!1;#I;#x;#A=null;#k=null;#M=300;get fadeVolumeSpeed(){return M(this.#l),this.#M}set fadeVolumeSpeed(e){if(M(this.#l),"number"!=typeof e)throw new TypeError("fadeVolumeSpeed must be a number.");if(e<0)throw new RangeError("fadeVolumeSpeed cannot be negative.");this.#M=e,this.emit("fadeVolumeSpeedChange",this.#M)}#C=2e3;get prevClickTimeoutDuration(){return M(this.#l),this.#C}set prevClickTimeoutDuration(e){if(M(this.#l),"number"!=typeof e)throw new TypeError("prevClickTimeoutDuration must be a number.");if(e<0)throw new RangeError("prevClickTimeoutDuration cannot be negative.");this.#C=e,this.emit("prevClickTimeoutDurationChange",this.#C)}get repeatCurrentOnPrev(){return M(this.#l),this.#E}set repeatCurrentOnPrev(e){if(M(this.#l),"boolean"!=typeof e)throw new TypeError("repeatCurrentOnPrev must be a boolean.");this.#E=e,this.emit("repeatCurrentOnPrevChange",this.#E)}get smoothPlayPauseVolume(){return M(this.#l),this.#I}set smoothPlayPauseVolume(e){if(M(this.#l),"boolean"!=typeof e)throw new TypeError("smoothPlayPauseVolume must be a boolean.");this.#I=e,this.emit("smoothPlayPauseVolumeChange",this.#I)}get smoothStopVolume(){return M(this.#l),this.#x}set smoothStopVolume(e){if(M(this.#l),"boolean"!=typeof e)throw new TypeError("smoothStopVolume must be a boolean.");this.#x=e,this.emit("smoothStopVolumeChange",this.#x)}constructor(e={}){if(!s(e))throw new TypeError("Options must be a non-null object.");if(super({id:"[_blue_TinyMediaPlayer_reset_] :debug:",logger:e.logger??console,debugMode:e.debugMode??!1,useLogColors:e.useLogColors??!1}),void 0!==e.persistVolume){if("boolean"!=typeof e.persistVolume)throw new TypeError("persistVolume must be a boolean.");this.#b=e.persistVolume}else this.#b=!1;if(void 0!==e.volumeStorageKey){if("string"!=typeof e.volumeStorageKey)throw new TypeError("volumeStorageKey must be a string.");this.#v=e.volumeStorageKey}else this.#v="tiny_media_player_volume";if(void 0!==e.repeatCurrentOnPrev){if("boolean"!=typeof e.repeatCurrentOnPrev)throw new TypeError("repeatCurrentOnPrev must be a boolean.");this.#E=e.repeatCurrentOnPrev}else this.#E=!1;if(void 0!==e.smoothPlayPauseVolume){if("boolean"!=typeof e.smoothPlayPauseVolume)throw new TypeError("smoothPlayPauseVolume must be a boolean.");this.#I=e.smoothPlayPauseVolume}else this.#I=!1;if(void 0!==e.smoothStopVolume){if("boolean"!=typeof e.smoothStopVolume)throw new TypeError("smoothStopVolume must be a boolean.");this.#x=e.smoothStopVolume}else this.#x=!1;this.#b&&this.#L(),this.log("info","Instance initialized.",{options:e})}#L(){try{if("undefined"!=typeof window&&window.localStorage){const e=window.localStorage.getItem(this.#v);if(null!==e){const t=parseFloat(e);!isNaN(t)&&t>=0&&t<=1&&(this.#w=t,this.log("info",`Volume loaded from storage: ${this.#w}`))}}}catch(e){console.warn("[TinyMediaPlayer] Failed to read volume from localStorage.",e)}}#P(){try{this.#b&&"undefined"!=typeof window&&window.localStorage&&(window.localStorage.setItem(this.#v,this.#w.toString()),this.log("info",`Volume saved to storage: ${this.#w}`))}catch(e){console.warn("[TinyMediaPlayer] Failed to save volume to localStorage.",e)}}_getWeightedRandomIndex(){if(0===this.#m.length)return-1;if(1===this.#m.length)return 0;let e=0;for(let t=0;t<this.#m.length;t++){if(t===this.#p)continue;const r=this.#m[t];e+="number"==typeof r.weight&&r.weight>0?r.weight:1}let t=Math.random()*e;for(let e=0;e<this.#m.length;e++){if(e===this.#p)continue;const r=this.#m[e],o="number"==typeof r.weight&&r.weight>0?r.weight:1;if(t<o)return e;t-=o}return this.#p===this.#m.length-1?0:this.#m.length-1}async#S(e){this.#A&&this.#A.abort(),this.#A=new AbortController;const{signal:t}=this.#A,r=this.#_();if(!r)return;const o=r.getVolume(),n=performance.now(),i=this.#M;return this.log("info",`Starting volume fade: ${o} -> ${e}`),new Promise(s=>{const a=l=>{if(t.aborted)return this.log("info","Volume fade aborted."),s();const d=l-n,u=Math.min(d/i,1),h=o+(e-o)*u,m=Math.max(0,Math.min(1,h));r.setVolume(m),u<1?requestAnimationFrame(a):(r.setVolume(e),this.log("info",`Volume fade completed: ${e}`),s())};requestAnimationFrame(a)})}get playlist(){return M(this.#l),[...this.#m]}set playlist(e){if(M(this.#l),!Array.isArray(e))throw new TypeError("Playlist must be an array of MediaContent objects.");e.forEach(e=>I(e));const t=this.#f;let r=null;if(-1!==this.#p&&this.#m.length>0)try{r=this.#_()}catch(e){}this.#m=e,this.log("info",`Playlist updated. New size: ${this.#m.length}`),this.emit("playlistUpdate",this.playlist),0===this.#m.length?this.#p=-1:(this.#p>=this.#m.length||-1===this.#p)&&(this.#p=0),this.emit("trackChange",this.#p),t&&(async()=>{try{r&&await r.stop(),-1!==this.#p&&await this.play()}catch(e){this.log("error","Background transition error on playlist update:",e),console.warn("[TinyMediaPlayer] Background transition error on playlist update:",e)}})()}get currentIndex(){return M(this.#l),this.#p}set currentIndex(e){if(M(this.#l),"number"!=typeof e)throw new TypeError("Current index must be a number.");if(e<-1||e>=this.#m.length&&this.#m.length>0)throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);if(this.#p===e)return;this.log("info",`Index change requested: ${this.#p} -> ${e}`);const t=this.#f;let r=null;if(-1!==this.#p&&this.#m.length>0)try{r=this.#_()}catch(e){}this.#p=e,this.emit("trackChange",this.#p),t&&(async()=>{try{r&&await r.stop(),-1!==this.#p&&await this.play()}catch(e){this.log("error","Background transition error on index update:",e),console.warn("[TinyMediaPlayer] Background transition error on index update:",e)}})()}get loopMode(){return M(this.#l),this.#c}set loopMode(e){M(this.#l);const t=["NONE","TRACK","PLAYLIST"];if(!t.includes(e))throw new TypeError(`Loop mode must be one of: ${t.join(", ")}.`);this.#c=e,this.log("info",`Loop mode changed to: ${this.#c}`),this.emit("loopModeChange",this.#c)}get isRandom(){return M(this.#l),this.#y}set isRandom(e){if(M(this.#l),"boolean"!=typeof e)throw new TypeError("Random mode state must be a boolean.");this.#y=e,this.log("info",`Random mode: ${this.#y}`),this.emit("randomModeChange",this.#y)}get isPlaying(){return M(this.#l),this.#f}get volume(){return M(this.#l),this.#w}set volume(e){if(M(this.#l),"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.#A&&this.#A.abort(),this.log("info",`Volume changed: ${this.#w} -> ${e}`),this.#w=e,this.#P(),this.emit("volumeChange",this.#w),-1!==this.#p&&this.#m.length>0)try{const e=this.#_();e&&e.setVolume(this.#w)}catch(e){}}get persistVolume(){return M(this.#l),this.#b}set persistVolume(e){if(M(this.#l),"boolean"!=typeof e)throw new TypeError("Persist volume parameter must be a boolean.");this.#b=e,this.log("info",`Persist volume: ${this.#b}`),e&&this.#P()}get volumeStorageKey(){return M(this.#l),this.#v}set volumeStorageKey(e){if(M(this.#l),"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.#v;this.#v=e;try{this.#b&&"undefined"!=typeof window&&window.localStorage&&(window.localStorage.removeItem(t),this.#P())}catch(e){console.warn("[TinyMediaPlayer] Failed to migrate volume storage key.",e)}}get isMuted(){return M(this.#l),this.#g}async mute(){M(this.#l);const e=this.#_();e&&(await e.mute(),this.#g=!0,this.emit("muteChange",this.#g),this.log("info","Playback muted successfully."))}async unMute(){M(this.#l);const e=this.#_();e&&(await e.unMute(),this.#g=!1,this.emit("muteChange",this.#g),this.log("info","Playback unmuted successfully."))}get adapters(){return Array.from(this.#u)}get adaptersSize(){return this.#u.size}static#O=["timeupdate","ended"];static get defaultAdapterEventNames(){return structuredClone(C.#O)}static set defaultAdapterEventNames(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError("TinyMediaPlayer.defaultAdapterEventNames must be an array of strings.");C.#O=[...e]}#V=new Set(C.defaultAdapterEventNames);#R(e){const t=this.#h.get(e);t&&(this.#V.forEach(r=>{const o=t.get(r);o&&e.off(r,o)}),t.clear(),this.#h.delete(e))}registerAdapter(e){if(M(this.#l),!(e instanceof k))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");this.log("info","Registering new adapter:",e);const t=new Map;this.#h.set(e,t),this.#V.forEach(t=>{this.#j(e,t)}),this.#u.add(e)}removeAdapter(e){if(M(this.#l),!(e instanceof k))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");return this.log("info","Removing adapter:",e),this.#R(e),this.#u.delete(e)}destroyAdapter(e){if(M(this.#l),!(e instanceof k))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");this.log("info","Destroying adapter:",e),this.#R(e);const t=this.#u.delete(e);return t&&e.destroy(),t}hasAdapter(e){if(M(this.#l),!(e instanceof k))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");return this.#u.has(e)}destroyAllAdapters(){M(this.#l),this.log("info","Destroying all adapters."),this.#u.forEach(e=>{this.#R(e),e.destroy()}),this.#u.clear()}clearAdapters(){M(this.#l),this.log("info","Clearing all adapters."),this.#u.forEach(e=>this.#R(e)),this.#u.clear()}getMediaAdapter(e){if(!s(e))throw new TypeError("Content must be a valid object.");for(const t of this.#u.values())if(t.canHandle(e))return t;return null}#_(){if(-1===this.#p||0===this.#m.length)return null;const e=this.#m[this.#p],t=this.getMediaAdapter(e);if(t)return t;const r=`No compatible adapter found for content ID: ${e.id}.`;throw this.log("error",r),new Error(r)}addAdapterEvent(e){if(M(this.#l),"string"!=typeof e)throw new TypeError("Event name must be a string.");this.#V.has(e)||(this.log("info",`Adding adapter event listener: ${e}`),this.#V.add(e),this.#u.forEach(t=>{this.#j(t,e)}))}removeAdapterEvent(e){if(M(this.#l),"string"!=typeof e)throw new TypeError("Event name must be a string.");this.#V.has(e)&&(this.log("info",`Removing adapter event listener: ${e}`),this.#V.delete(e),this.#u.forEach(t=>{this.#N(t,e)}))}resetAdapterEvents(){M(this.#l);const e=C.defaultAdapterEventNames,t=Array.from(this.#V);for(const r of t)e.includes(r)||this.removeAdapterEvent(r);for(const t of e)this.#V.has(t)||this.addAdapterEvent(t)}#j(e,t){const r=this.#h.get(e);if(!r)return;const o=(...e)=>{this.#l||("timeupdate"!==t&&this.log("debug",`Adapter event triggered: ${t}`,...e),this.emit(t,...e))};e.on(t,o),r.set(t,o)}#N(e,t){const r=this.#h.get(e);if(!r)return;const o=r.get(t);o&&(e.off(t,o),r.delete(t))}addTrack(e){if(M(this.#l),!s(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,...e};I(t);const r=this.#m.push(t);return this.log("info",`Track added. New length: ${r}`,t),-1===this.#p&&(this.#p=0,this.emit("trackChange",this.#p)),this.emit("playlistUpdate",this.playlist),r}existsTrack(e){if(M(this.#l),"number"!=typeof e)throw new TypeError("Index must be a number.");return e>=0&&e<this.#m.length}getTrack(e){if(M(this.#l),"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.#m[e]}async removeTrack(e){if(M(this.#l),"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.`);this.log("info",`Removing track at index: ${e}`),e===this.#p?(await this.stop(),this.#m.splice(e,1),0===this.#m.length?this.#p=-1:this.#p>=this.#m.length&&(this.#p=0),this.emit("trackChange",this.#p)):(this.#m.splice(e,1),e<this.#p&&(this.#p-=1,this.emit("trackChange",this.#p))),this.emit("playlistUpdate",this.playlist)}searchTrack(e){if(M(this.#l),"string"!=typeof e&&"function"!=typeof e)throw new TypeError("Search query must be a string or a boolean evaluation function.");this.log("info","Searching playlist...",{query:e});const t=[];for(let r=0;r<this.#m.length;r++){const o=this.#m[r];let n=!1;if("function"==typeof e)n=Boolean(e(o));else{const t=e.toLowerCase(),r=o.title&&o.title.toLowerCase().includes(t),i=o.artist&&o.artist.toLowerCase().includes(t),s=o.album&&o.album.toLowerCase().includes(t);n=Boolean(r||i||s)}n&&t.push({track:o,index:r})}return this.log("info",`Search completed. Found ${t.length} results.`),t}async clearPlaylist(){M(this.#l),this.log("info","Clearing entire playlist."),await this.stop(),this.#m=[],this.#p=-1,this.emit("playlistUpdate",this.playlist),this.emit("trackChange",this.#p)}async play(){M(this.#l),this.log("info",`Attempting to play track at index: ${this.#p}`);const e=this.#_();if(e){this.#I?await this.#S(this.#w):e.setVolume(this.#w);try{await e.play(this.#m[this.#p]),this.#g&&await e.mute(),this.#f=!0,this.log("info","Playback started successfully."),this.emit("play",this.#p)}catch(e){throw this.log("error","Failed to play track:",e),e}}else this.log("error","Failed to play track:",`Active adapter not found for track at index ${this.#p}.`)}async pause(){M(this.#l),this.log("info","Attempting to pause playback.");const e=this.#_();e&&(this.#I&&await this.#S(0),await e.pause(),this.#f=!1,this.log("info","Playback paused."),this.emit("pause",this.#p))}async stop(){M(this.#l),this.log("info","Attempting to stop playback.");const e=this.#_();e&&(this.#x&&await this.#S(0),await e.stop(),this.#f=!1,this.log("info","Playback stopped."),this.emit("stop",this.#p))}async next(){if(M(this.#l),0!==this.#m.length){if(this.log("info","Next track requested."),await this.stop(),"TRACK"===this.#c)return this.log("info","Loop mode: TRACK. Repeating current track."),void await this.play();if(this.#y)this.#p=this._getWeightedRandomIndex(),this.log("info",`Random mode: Selected index ${this.#p}`);else{let e=this.#p+1;if(e>=this.#m.length){if("PLAYLIST"!==this.#c)return void this.log("info","End of playlist reached. Stopping.");e=0,this.log("info","Loop mode: PLAYLIST. Returning to start.")}this.#p=e}this.emit("trackChange",this.#p),await this.play()}}async prev(){if(M(this.#l),0!==this.#m.length){if(this.#E&&!this.#T)return this.log("info",'UX: Repeat current track on first "prev" click.'),this.#T=!0,this.#k&&clearTimeout(this.#k),this.#k=setTimeout(()=>{this.#T=!1,this.#k=null},2e3),await this.stop(),void await this.play();if(this.#k&&(clearTimeout(this.#k),this.#k=null),this.#T=!1,this.log("info","Previous track requested."),await this.stop(),this.#y)this.#p=this._getWeightedRandomIndex(),this.log("info",`Random mode: Selected index ${this.#p}`);else{let e=this.#p-1;if(e<0){if("PLAYLIST"!==this.#c)return void this.log("info","Start of playlist reached. Stopping.");e=this.#m.length-1,this.log("info","Loop mode: PLAYLIST. Returning to end.")}this.#p=e}this.emit("trackChange",this.#p),await this.play()}}async skipTo(e){if(M(this.#l),"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.`);this.log("info",`Skipping to index: ${e}`),await this.stop(),this.#p=e,this.emit("trackChange",this.#p),await this.play()}async seek(e){if(M(this.#l),"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.");this.log("info",`Seeking to: ${e}ms`);const t=this.#_();t&&(await t.seek(e),this.emit("seek",e))}async step(e){if(M(this.#l),"number"!=typeof e)throw new TypeError("Step amount must be a number in milliseconds.");this.log("info",`Stepping by: ${e}ms`);const t=this.#_();if(!t)return;let r=t.getCurrentTime()+e;r<0&&(r=0),await this.seek(r)}getCurrentTime(){M(this.#l);try{const e=this.#_();return e?e.getCurrentTime():0}catch{return 0}}getTotalDuration(){M(this.#l);try{const e=this.#_();return e?e.getTotalDuration():0}catch{return 0}}getRemainingTime(){M(this.#l);try{const e=this.#_();return e?e.getRemainingTime():0}catch{return 0}}getPlaybackPercentage(){M(this.#l);try{const e=this.#_();return e?e.getPlaybackPercentage():0}catch{return 0}}get isPaused(){M(this.#l);try{const e=this.#_();return!!e&&e.isPaused()}catch{return!1}}get isEnded(){M(this.#l);try{const e=this.#_();return!e||e.isEnded()}catch{return!0}}async getContentData(){M(this.#l);const e={id:"",createdAt:"",artistId:"",artistName:"",description:"",title:"",duration:0,avatar:"",url:""};try{const t=this.#_();return t?t.getContentData():e}catch{return e}}async waitIsReady(){M(this.#l);const e=this.#_();if(e)return e.waitIsReady()}async destroy(){if(!this.#l){this.log("info","Destroying TinyMediaPlayer instance.");try{this.#f&&await this.stop()}catch(e){this.log("error","Non-fatal error during playback termination:",e),console.warn("[TinyMediaPlayer] Non-fatal error during playback termination:",e)}this.#k&&clearTimeout(this.#k),this.#m=[],this.#p=-1,this.#f=!1,this.#T=!1,this.destroyAllAdapters(),this.removeAllListeners(),this.#V.clear(),this.#l=!0,this.emit("destroyed")}}}const L=C}};const t={};function r(o){const n=t[o];if(void 0!==n)return n.exports;const i=t[o]={exports:{}};return e[o](i,i.exports,r),i.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var o=0;o<t.length;){var n=t[o++],i=t[o++];r.o(e,n)?0===i&&o++:0===i?Object.defineProperty(e,n,{enumerable:!0,value:t[o++]}):Object.defineProperty(e,n,{enumerable:!0,get:i})}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.cjs=e=>{const t={exports:{}};return e.call(t.exports,t,t.exports),t.exports};let o=r(314);window.TinyMediaPlayer=o.TinyMediaPlayer})();
1
+ (()=>{"use strict";var e={206(e,t,r){r.d(t,{TinyMediaPlayer:()=>S});var o=r.cjs(function(e,t){var r,o="object"==typeof Reflect?Reflect:null,i=o&&"function"==typeof o.apply?o.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};r=o&&"function"==typeof o.ownKeys?o.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 a(){a.init.call(this)}e.exports=a,e.exports.once=function(e,t){return new Promise(function(r,o){function i(r){e.removeListener(t,n),o(r)}function n(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}f(e,t,n,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&f(e,"error",t,{once:!0})}(e,i)})},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var s=10;function l(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function d(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function u(e,t,r,o){var i,n,a,s;if(l(r),void 0===(n=e._events)?(n=e._events=Object.create(null),e._eventsCount=0):(void 0!==n.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),n=e._events),a=n[t]),void 0===a)a=n[t]=r,++e._eventsCount;else if("function"==typeof a?a=n[t]=o?[r,a]:[a,r]:o?a.unshift(r):a.push(r),(i=d(e))>0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,s=u,console&&console.warn&&console.warn(s)}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 m(e,t,r){var o={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=h.bind(o);return i.listener=r,o.wrapFn=i,i}function p(e,t,r){var o=e._events;if(void 0===o)return[];var i=o[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):y(i,i.length)}function c(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 y(e,t){for(var r=new Array(t),o=0;o<t;++o)r[o]=e[o];return r}function f(e,t,r,o){if("function"==typeof e.on)o.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function i(n){o.once&&e.removeEventListener(t,i),r(n)})}}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return s},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+".");s=e}}),a.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},a.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},a.prototype.getMaxListeners=function(){return d(this)},a.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var o="error"===e,n=this._events;if(void 0!==n)o=o&&void 0===n.error;else if(!o)return!1;if(o){var a;if(t.length>0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var l=n[e];if(void 0===l)return!1;if("function"==typeof l)i(l,this,t);else{var d=l.length,u=y(l,d);for(r=0;r<d;++r)i(u[r],this,t)}return!0},a.prototype.addListener=function(e,t){return u(this,e,t,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(e,t){return u(this,e,t,!0)},a.prototype.once=function(e,t){return l(t),this.on(e,m(this,e,t)),this},a.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,m(this,e,t)),this},a.prototype.removeListener=function(e,t){var r,o,i,n,a;if(l(t),void 0===(o=this._events))return this;if(void 0===(r=o[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,n=r.length-1;n>=0;n--)if(r[n]===t||r[n].listener===t){a=r[n].listener,i=n;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(o[e]=r[0]),void 0!==o.removeListener&&this.emit("removeListener",e,a||t)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(e){var t,r,o;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var i,n=Object.keys(r);for(o=0;o<n.length;++o)"removeListener"!==(i=n[o])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(o=t.length-1;o>=0;o--)this.removeListener(e,t[o]);return this},a.prototype.listeners=function(e){return p(this,e,!0)},a.prototype.rawListeners=function(e){return p(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):c.call(e,t)},a.prototype.listenerCount=c,a.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}});function i(e){if(!Array.isArray(e)&&!n(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 n(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}function a(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}const s=["chrome","firefox","ie","edge","safari","opera","yandex","other"];class l extends o.EventEmitter{#e;#t;#r;#o;#i;#n=new Map([["log",""],["info",""],["warn",""],["error",""],["debug",""],["reset",""],["black",""],["red",""],["green",""],["yellow",""],["blue",""],["magenta",""],["cyan",""],["white",""],["gray",""]]);#a=new Map([["log","[_log_LOG_reset_]"],["info","[_info_INFO_reset_]"],["warn","[_warn_WARN_reset_]"],["error","[_error_ERROR_reset_]"],["debug","[_debug_DEBUG_reset_]"]]);constructor({logger:e,id:t,debugMode:r,canEmitLogs:o=!1,useLogColors:i=!1}){if(super(),!a(e))throw new TypeError("Logger must be an object that implements the Console interface.");if("string"!=typeof t)throw new TypeError("Logger instance id must be a string.");if("boolean"!=typeof r)throw new TypeError("debugMode must be a boolean.");if("boolean"!=typeof o)throw new TypeError("canEmitLogs must be a boolean.");if("boolean"!=typeof i)throw new TypeError("useLogColors must be a boolean.");this.#t=t,this.#e=e,this.#o=r,this.#r=o,this.#i="firefox"!==function(e=[]){const t=function(e=[]){if(!Array.isArray(e))throw new TypeError('The "disable" argument must be an array.');for(const t of e)if(!s.includes(t))throw new TypeError(`Invalid browser name provided in disable array: ${t}`);const t={chrome:0,firefox:0,ie:0,edge:0,safari:0,opera:0,yandex:0,other:0};t[function(){const e=navigator.userAgent;return-1!==e.indexOf("Chrome")?"chrome":-1!==e.indexOf("Firefox")?"firefox":-1!==e.indexOf("MSIE")?"ie":-1!==e.indexOf("Edge")?"edge":-1!==e.indexOf("Safari")?"safari":-1!==e.indexOf("Opera")?"opera":-1!==e.indexOf("YaBrowser")?"yandex":"other"}()]++;const r=function(){const e=(Array.prototype.slice.call(window.getComputedStyle(document.documentElement,"")).join("").match(/-(moz|webkit|ms)-/)??["",""])[1];return"moz"===e?"gecko":"webkit"===e?"webkit":"ms"===e?"trident":"other"}();"gecko"===r?e.indexOf("firefox")<0&&t.firefox++:"webkit"===r?(e.indexOf("chrome")<0&&t.chrome++,e.indexOf("safari")<0&&t.safari++,e.indexOf("opera")<0&&t.opera++,e.indexOf("edge")<0&&t.edge++):"trident"===r?e.indexOf("ie")<0&&t.ie++:e.indexOf("other")<0&&t.other++;const o=function(){const e=!!window.opr&&!!opr.addons||!!window.opera||navigator.userAgent.indexOf(" OPR/")>=0,t="undefined"!=typeof InstallTrigger,r=/constructor/i.test(window.HTMLElement)||"[object SafariRemoteNotification]"===(!window.safari||"undefined"!=typeof safari&&safari.pushNotification).toString(),o=!!document.documentMode,i=!o&&!!window.StyleMedia,n=!!window.chrome;return{isOpera:e,isFirefox:t,isSafari:r,isIE:o,isEdge:i,isChrome:n,isBlink:(n||e)&&!!window.CSS}}();return o.isOpera&&e.indexOf("opera")<0&&t.opera++,o.isFirefox&&e.indexOf("firefox")<0&&t.firefox++,o.isSafari&&e.indexOf("safari")<0&&t.safari++,o.isIE&&e.indexOf("ie")<0&&t.ie++,o.isEdge&&e.indexOf("edge")<0&&t.edge++,o.isChrome&&e.indexOf("chrome")<0&&t.chrome++,t}(e);return Object.keys(t).reduce((e,r)=>t[r]>t[e]?r:e)}()&&i,this.log("info","Emit logs of debug mode set to: "+(this.#o?"ON":"OFF")),this.log("info","Custom logger assigned.")}get logId(){return this.#t}get canEmitLogs(){return this.#r}get useLogColors(){return this.#i}set useLogColors(e){if("boolean"!=typeof e)throw new TypeError("useLogColors must be a boolean.");this.#i=e,this.log("info","Log Colors usage mode set to: "+(this.#i?"ON":"OFF")),this.emit("setDebugMode",e)}get debugMode(){return this.#o}set debugMode(e){if("boolean"!=typeof e)throw new TypeError("debugMode must be a boolean.");this.#o=e,this.log("info","Debug mode set to: "+(this.#o?"ON":"OFF")),this.emit("setDebugMode",e)}_addLogColor(e,t){this.#n.set(e,t)}_removeLogColor(e){this.#n.delete(e)}_addLogPrefix(e,t){this.#a.set(e,t)}_removeLogPrefix(e){this.#a.delete(e)}#s(e){if("string"!=typeof e)return e;let t=e;for(const[e,r]of this.#a){const o=new RegExp(`\\:${e}\\:`,"g");t=t.replace(o,r)}for(const[e,r]of this.#n){const o=new RegExp(`\\_${e}\\_`,"g");t=t.replace(o,this.#i?r:"")}return t}logClear(){if(this.#o)return this.#r&&this.emit("debug:clear"),this.#e.clear?this.#e.clear():console.clear()}logGroupEnd(){if(this.#o)return this.#r&&this.emit("debug:groupEnd"),this.#e.groupEnd?this.#e.groupEnd():console.groupEnd()}logLabel(e,t){if(!this.#o)return;const r=["count","countReset","time","timeEnd","profile","profileEnd","timeStamp"];if(!r.includes(e))throw new TypeError(`Invalid logType. Expected one of: ${r.join(", ")}`);if(void 0!==t&&"string"!=typeof t)throw new TypeError("The label must be a string.");const o=this.#e[e]?this.#e[e]:console[e];if(!o)throw new TypeError(`The log type "${e}" is not supported by the provided logger or console.`);return this.#r&&this.emit("debug:logLabel",e,t),o(t)}logTimeLabel(e,...t){if(this.#o)return this.#r&&this.emit("debug:timeLog",e,...t),this.#e.timeLog?this.#e.timeLog(e,...t):console.timeLog(e,...t)}logAssert(e,...t){if(this.#o)return this.#r&&this.emit("debug:assert",e,...t),this.#e.assert?this.#e.assert(e,...t):console.assert(e,...t)}logDir(e,t){if(this.#o)return this.#r&&this.emit("debug:dir",e,t),this.#e.dir?this.#e.dir(e,t):console.dir(e,t)}logTable(e,t){if(this.#o){if(!(void 0===t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("Properties must be an array of strings.");return this.#r&&this.emit("debug:table",e,t),this.#e.table?this.#e.table(e,t):console.table(e,t)}}log(e,t,...r){if(!this.#o)return;const o=["log","info","warn","error","debug","dirxml","group","groupCollapsed","trace"];if(!o.includes(e))throw new TypeError(`Invalid logType. Expected one of: ${o.join(", ")}`);if("string"!=typeof t)throw new TypeError("The message must be a string.");let i=this.#t,n=t;i=this.#s(i),n=this.#s(n);const a=this.#e[e]?this.#e[e]:console[e];return a?(this.#r&&this.emit("debug:log",i,n,...r),a(i,n,...r)):(this.#r&&this.emit("debug:log",i,n,...r),console.log(i,n,...r))}}const d=l;function u(e,t){if(void 0!==t.obj&&"function"!=typeof t.obj)throw new TypeError("filter.obj must be a function if provided.");if(void 0!==t.value&&"function"!=typeof t.value)throw new TypeError("filter.value must be a function if provided.");if(void 0!==t.array&&"function"!=typeof t.array)throw new TypeError("filter.array must be a function if provided.");let r;r=e instanceof Map?new Map:e instanceof Set?new Set:{};const o=(i=e)instanceof Map?Array.from(i.entries()):i instanceof Set?Array.from(i.values()).map(e=>[void 0,e]):Object.entries(i);var i;const n=(e,r)=>{const o=[];for(let i=0;i<e.length;i++){const s=e[i];if(Array.isArray(s))o.push(n(s,r));else if(a(s)){const r=u(s,t);(void 0===t.obj||t.obj(r,i,e))&&o.push(r)}else(void 0===t.value||t.value([r,s],i,e))&&o.push(s)}return o};for(let e=0;e<o.length;e++){const[i,s]=o[e];if(Array.isArray(s)){const a=n(s,i);(void 0===t.array||t.array([i,a],e,o))&&(r instanceof Map||r instanceof Set?r instanceof Map?r.set(i,a):r.add(a):r[i]=a)}else if(a(s)){const n=u(s,t);(void 0===t.obj||t.obj(n,e,o))&&(r instanceof Map?r.set(i,n):r instanceof Set?r.add(n):r[i]=n)}else(void 0===t.value||t.value([i,s],e,o))&&(r instanceof Map?r.set(i,s):r instanceof Set?r.add(s):r[i]=s)}return r}const h=(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}.`)},m=(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}.`)},p=(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}.`)},c=(e,t=!1)=>!t&&void 0===e,y=(e,t=!1)=>c(e,t)||"string"==typeof e||!t&&null===e,f=(e,t=!1)=>c(e,t)||"number"==typeof e||!t&&null===e,g=(e,t=!1)=>c(e,t)||"boolean"==typeof e||!t&&null===e,w=(e,t)=>!!c(e)||(m(t,"valueValidator"),Array.isArray(e)&&e.every(t)),b=new Map;class v extends Error{constructor(e,t,r){if(h(e,"message"),h(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 E=async e=>{h(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)},T=(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}.`);h(t,"format");const r=e=>{const t=URL.createObjectURL(e),r=b.get(t);return b.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 o=e.split(",")[1],i=atob(o),n=new Uint8Array(i.length);for(let e=0;e<i.length;e++)n[e]=i.charCodeAt(e);return r(new Blob([n],{type:t}))}return"string"==typeof e?e:""},I=(e,t=!1)=>{if(n(e)){if(4!==i(e)){if(t)return!1;throw new TypeError("Invalid fetch data: Object must be an MediaContentFetchData.")}x(e.common),p(e.native,"_fetchData.native"),p(e.format,"_fetchData.format"),p(e.quality,"_fetchData.quality");for(const r in e.native){const o=e.native[r];if(!w(o,e=>"string"==typeof e.id)){if(t)return!1;throw new TypeError(`Invalid native data: "${r}" must be an array of native fetch data.`)}}}return!0},x=e=>{if(p(e,"common"),I(e._fetchData),!y(e.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!y(e.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!y(e.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a a string or null.');if(!y(e.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(!g(e.compilation))throw new TypeError('Invalid metadata: "compilation" must be a boolean or null.');if(!g(e.podcast))throw new TypeError('Invalid metadata: "podcast" must be a boolean or null.');if(!g(e.gapless))throw new TypeError('Invalid metadata: "gapless" must be a boolean or null.');if(!g(e.showMovement))throw new TypeError('Invalid metadata: "showMovement" must be a boolean or null.');if(!f(e.averageLevel))throw new TypeError('Invalid metadata: "averageLevel" must be a number or null.');if(!f(e.peakLevel))throw new TypeError('Invalid metadata: "peakLevel" must be a number or null.');if(!f(e.hdVideo))throw new TypeError('Invalid metadata: "hdVideo" must be a number or null.');if(!f(e.stik))throw new TypeError('Invalid metadata: "stik" must be a number or null.');if(!f(e.playCounter))throw new TypeError('Invalid metadata: "playCounter" must be a number or null.');if(!f(e.tvSeason))throw new TypeError('Invalid metadata: "tvSeason" must be a number or null.');if(!f(e.tvEpisode))throw new TypeError('Invalid metadata: "tvEpisode" must be a number or null.');if(!f(e.year))throw new TypeError('Invalid metadata: "year" must be a number or null.');if(!f(e.bpm))throw new TypeError('Invalid metadata: "bpm" must be a number or null.');if(!f(e.originalyear))throw new TypeError('Invalid metadata: "originalyear" must be a number or null.');if(!f(e.movementTotal))throw new TypeError('Invalid metadata: "movementTotal" must be a number or null.');if(!y(e.date))throw new TypeError('Invalid metadata: "date" must be a string or null.');if(!y(e.originaldate))throw new TypeError('Invalid metadata: "originaldate" must be a string or null.');if(!y(e.releasedate))throw new TypeError('Invalid metadata: "releasedate" must be a string or null.');if(!y(e.albumsort))throw new TypeError('Invalid metadata: "albumsort" must be a string or null.');if(!y(e.titlesort))throw new TypeError('Invalid metadata: "titlesort" must be a string or null.');if(!y(e.work))throw new TypeError('Invalid metadata: "work" must be a string or null.');if(!y(e.artistsort))throw new TypeError('Invalid metadata: "artistsort" must be a string or null.');if(!y(e.albumartistsort))throw new TypeError('Invalid metadata: "albumartistsort" must be a string or null.');if(!y(e.composersort))throw new TypeError('Invalid metadata: "composersort" must be a string or null.');if(!y(e.grouping))throw new TypeError('Invalid metadata: "grouping" must be a string or null.');if(!y(e.longDescription))throw new TypeError('Invalid metadata: "longDescription" must be a string or null.');if(!y(e.totaltracks))throw new TypeError('Invalid metadata: "totaltracks" must be a string or null.');if(!y(e.totaldiscs))throw new TypeError('Invalid metadata: "totaldiscs" must be a string or null.');if(!y(e.mood))throw new TypeError('Invalid metadata: "mood" must be a string or null.');if(!y(e.media))throw new TypeError('Invalid metadata: "media" must be a string or null.');if(!y(e.tvShow))throw new TypeError('Invalid metadata: "tvShow" must be a string or null.');if(!y(e.tvShowSort))throw new TypeError('Invalid metadata: "tvShowSort" must be a string or null.');if(!y(e.tvEpisodeId))throw new TypeError('Invalid metadata: "tvEpisodeId" must be a string or null.');if(!y(e.tvNetwork))throw new TypeError('Invalid metadata: "tvNetwork" must be a string or null.');if(!y(e.podcasturl))throw new TypeError('Invalid metadata: "podcasturl" must be a string or null.');if(!y(e.releasestatus))throw new TypeError('Invalid metadata: "releasestatus" must be a string or null.');if(!y(e.releasecountry))throw new TypeError('Invalid metadata: "releasecountry" must be a string or null.');if(!y(e.script))throw new TypeError('Invalid metadata: "script" must be a string or null.');if(!y(e.language))throw new TypeError('Invalid metadata: "language" must be a string or null.');if(!y(e.copyright))throw new TypeError('Invalid metadata: "copyright" must be a string or null.');if(!y(e.license))throw new TypeError('Invalid metadata: "license" must be a string or null.');if(!y(e.encodedby))throw new TypeError('Invalid metadata: "encodedby" must be a string or null.');if(!y(e.encodersettings))throw new TypeError('Invalid metadata: "encodersettings" must be a string or null.');if(!y(e.barcode))throw new TypeError('Invalid metadata: "barcode" must be a string or null.');if(!y(e.asin))throw new TypeError('Invalid metadata: "asin" must be a string or null.');if(!y(e.website))throw new TypeError('Invalid metadata: "website" must be a string or null.');if(!y(e.originalalbum))throw new TypeError('Invalid metadata: "originalalbum" must be a string or null.');if(!y(e.originalartist))throw new TypeError('Invalid metadata: "originalartist" must be a string or null.');if(!y(e.key))throw new TypeError('Invalid metadata: "key" must be a string or null.');if(!y(e.movement))throw new TypeError('Invalid metadata: "movement" must be a string or null.');if(!y(e.podcastId))throw new TypeError('Invalid metadata: "podcastId" must be a string or null.');if(!w(e.albumartists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "albumartists" must be an array of strings.');if(!w(e.genre,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "genre" must be an array of strings.');if(!w(e.label,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "label" must be an array of strings.');if(!w(e.composer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "composer" must be an array of strings.');if(!w(e.artists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "artists" must be an array of strings.');if(!w(e.lyricist,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "lyricist" must be an array of strings.');if(!w(e.writer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "writer" must be an array of strings.');if(!w(e.conductor,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "conductor" must be an array of strings.');if(!w(e.remixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "remixer" must be an array of strings.');if(!w(e.arranger,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "arranger" must be an array of strings.');if(!w(e.engineer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "engineer" must be an array of strings.');if(!w(e.publisher,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "publisher" must be an array of strings.');if(!w(e.producer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "producer" must be an array of strings.');if(!w(e.djmixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "djmixer" must be an array of strings.');if(!w(e.mixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "mixer" must be an array of strings.');if(!w(e.technician,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "technician" must be an array of strings.');if(!w(e.subtitle,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "subtitle" must be an array of strings.');if(!w(e.description,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "description" must be an array of strings.');if(!w(e.discsubtitle,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "discsubtitle" must be an array of strings.');if(!w(e.releasetype,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "releasetype" must be an array of strings.');if(!w(e.isrc,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "isrc" must be an array of strings.');if(!w(e.performer_instrument,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "performer_instrument" must be an array of strings.');if(!w(e.notes,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "notes" must be an array of strings.');if(!w(e.category,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "category" must be an array of strings.');if(!w(e.keywords,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "keywords" must be an array of strings.');if(!w(e.catalognumber,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "catalognumber" must be an array of strings.');if(!w(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.');if(!w(e.comment,e=>null!==e&&"object"==typeof e&&y(e.descriptor)&&y(e.language)&&y(e.text)))throw new TypeError('Invalid metadata: "comment" must be an array of valid IComment objects.');if(!w(e.lyrics,e=>null!==e&&"object"==typeof e&&y(e.text)&&y(e.descriptor)&&y(e.language)&&(!Array.isArray(e)||w(e.syncText,e=>null!==e&&"object"==typeof e&&y(e.text)&&f(e.timestamp)))&&(e=>void 0===e||null!==e&&"object"==typeof e&&f(e.notSynchronized)&&f(e.mpegFrameNumber)&&f(e.milliseconds))(e.timeStampFormat)&&(e=>void 0===e||null!==e&&"object"==typeof e&&f(e.other)&&f(e.lyrics)&&f(e.text)&&f(e.movement_part)&&f(e.events)&&f(e.chord)&&f(e.trivia_pop))(e.contentType)))throw new TypeError('Invalid metadata: "lyrics" must be an array of valid ILyricsTag objects.');if(!w(e.rating,e=>null!==e&&"object"==typeof e&&y(e.source)&&f(e.rating)))throw new TypeError('Invalid metadata: "rating" must be an array of valid IRating objects.');const t=(e,t)=>{if(!c(t)&&null!==t){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.`)}};t("disk",e.disk),t("track",e.track),t("movementIndex",e.movementIndex)},A=async(e,t,r=!0)=>{h(e,"url"),m(t,"parseFile");const o=await fetch(e);if(!o.ok)throw new Error(`Failed to fetch audio file: ${o.status} ${o.statusText}`);const n=await o.blob(),a=await t(n);if(!a||"object"!=typeof a.common)throw new TypeError('Invalid metadata: "common" property is missing.');void 0!==typeof a.common["performer:instrument"]&&(a.common.performer_instrument=a.common["performer:instrument"]),I(a);const s=a.common;x(s);const l=s?.picture?.map(e=>({...e,data:r?T(e.data,e.format):e.data}))??[];a.common={...a.common,picture:l.map(e=>({...e,data:""}))},r&&Object.keys(a.native).forEach(e=>{a.native[e]=a.native[e].map(e=>{if(e.value&&"object"==typeof e.value&&e.value.data instanceof Uint8Array){const t=s?.picture?.findIndex(t=>t.data===e.value.data&&t.format===e.value.format&&t.description===e.value.description&&t.name===e.value.name)??-1;if(l[t])return{...e,value:{...e.value,data:""}}}return e})});const d=u({title:s?.title,album:s?.album,albumartist:s?.albumartist,albumartists:s?.albumartists,genre:s?.genre,label:s?.label,composer:s?.composer,year:s?.year,artist:s?.artist,artists:s?.artists,disk:s?.disk?{no:s.disk.no,of:s.disk.of}:void 0,track:s?.track?{no:s.track.no,of:s.track.of}:void 0,movementIndex:s?.movementIndex?{no:s.movementIndex.no,of:s.movementIndex.of}:void 0,picture:l,date:s?.date,originaldate:s?.originaldate,originalyear:s?.originalyear,releasedate:s?.releasedate,comment:s?.comment,lyrics:s?.lyrics,albumsort:s?.albumsort,titlesort:s?.titlesort,work:s?.work,artistsort:s?.artistsort,albumartistsort:s?.albumartistsort,composersort:s?.composersort,lyricist:s?.lyricist,writer:s?.writer,conductor:s?.conductor,remixer:s?.remixer,arranger:s?.arranger,engineer:s?.engineer,publisher:s?.publisher,producer:s?.producer,djmixer:s?.djmixer,mixer:s?.mixer,technician:s?.technician,grouping:s?.grouping,subtitle:s?.subtitle,description:s?.description,longDescription:s?.longDescription,discsubtitle:s?.discsubtitle,totaltracks:s?.totaltracks,totaldiscs:s?.totaldiscs,movementTotal:s?.movementTotal,compilation:s?.compilation,rating:s?.rating,bpm:s?.bpm,mood:s?.mood,media:s?.media,catalognumber:s?.catalognumber,tvShow:s?.tvShow,tvShowSort:s?.tvShowSort,tvSeason:s?.tvSeason,tvEpisode:s?.tvEpisode,tvEpisodeId:s?.tvEpisodeId,tvNetwork:s?.tvNetwork,podcast:s?.podcast,podcasturl:s?.podcasturl,releasestatus:s?.releasestatus,releasetype:s?.releasetype,releasecountry:s?.releasecountry,script:s?.script,language:s?.language,copyright:s?.copyright,license:s?.license,encodedby:s?.encodedby,encodersettings:s?.encodersettings,gapless:s?.gapless,barcode:s?.barcode,isrc:s?.isrc,asin:s?.asin,website:s?.website,performer_instrument:s?.performer_instrument,averageLevel:s?.averageLevel,peakLevel:s?.peakLevel,notes:s?.notes,originalalbum:s?.originalalbum,originalartist:s?.originalartist,key:s?.key,category:s?.category,hdVideo:s?.hdVideo,keywords:s?.keywords,movement:s?.movement,podcastId:s?.podcastId,showMovement:s?.showMovement,stik:s?.stik,playCounter:s?.playCounter},{value:([e,t])=>null!=t,obj:e=>i(e)>0,array:([e,t])=>t.length>0});return d._fetchData=a,d},k=e=>t=>{if(t)throw new Error(`This ${e} instance has been destroyed and can no longer be used.`)},M=k("BaseMediaAdapter");class C extends o.EventEmitter{constructor(){if(new.target===C)throw new Error("BaseMediaAdapter is an abstract class and cannot be instantiated directly.");super()}#l=!1;get destroyed(){return this.#l}static getThumbnailUrl(e){if("string"!=typeof e||""===e.trim())throw new TypeError('The "trackId" must be a non-empty string.');return""}static canHandle(e){throw new Error('Method "canHandle" must be implemented by the subclass.')}isReady(){throw M(this.#l),new Error('Method "isReady" must be implemented by the subclass.')}isPaused(){throw M(this.#l),new Error('Method "isPaused" must be implemented by the subclass.')}isEnded(){throw M(this.#l),new Error('Method "isEnded" must be implemented by the subclass.')}async waitIsReady(){throw M(this.#l),new Error('Method "waitIsReady" must be implemented by the subclass.')}canHandle(e){return M(this.#l),C.canHandle(e)}async play(e){throw M(this.#l),new Error('Method "play" must be implemented by the subclass.')}async pause(){throw M(this.#l),new Error('Method "pause" must be implemented by the subclass.')}async stop(){throw M(this.#l),new Error('Method "stop" must be implemented by the subclass.')}async seek(e){throw M(this.#l),new Error('Method "seek" must be implemented by the subclass.')}isMuted(){throw M(this.#l),new Error('Method "isMuted" must be implemented by the subclass.')}async mute(){throw M(this.#l),new Error('Method "mute" must be implemented by the subclass.')}async unMute(){throw M(this.#l),new Error('Method "unMute" must be implemented by the subclass.')}getCurrentTime(){throw M(this.#l),new Error('Method "getCurrentTime" must be implemented by the subclass.')}getTotalDuration(){throw M(this.#l),new Error('Method "getTotalDuration" must be implemented by the subclass.')}getRemainingTime(){throw M(this.#l),new Error('Method "getRemainingTime" must be implemented by the subclass.')}getPlaybackPercentage(){throw M(this.#l),new Error('Method "getPlaybackPercentage" must be implemented by the subclass.')}getTimeData(){throw M(this.#l),new Error('Method "getTimeData" must be implemented by the subclass.')}setVolume(e){throw M(this.#l),new Error('Method "setVolume" must be implemented by the subclass.')}getVolume(){throw M(this.#l),new Error('Method "getVolume" must be implemented by the subclass.')}async getContentData(){throw M(this.#l),new Error('Method "getContentData" must be implemented by the subclass.')}destroy(){this.#l||(this.removeAllListeners(),this.#l=!0,this.emit("destroyed"))}}const L=k("TinyMediaPlayer");class P extends d{static BaseMediaAdapter=C;static#d="Unknown Artist";static get unknownArtist(){return P.#d}static set unknownArtist(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("unknownArtist must be a string or a function.");P.#d=e}static async parseContent(e,t,r,o,i,a){return(async(e,t={},r={},o=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.")))},i={},a=!0,s="null")=>{if("string"!=typeof e&&!(e instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(p(t,"defaultMetadata"),p(r,"metadata"),m(o,"parseFile"),p(i,"callbacks"),i.onProgress&&"function"!=typeof i.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(i.onError&&"function"!=typeof i.onError)throw new TypeError("callbacks.onError must be a function.");if("string"!=typeof s&&"function"!=typeof s)throw new TypeError("unknownArtist must be a string or a function returning a string.");let l,d="";const u=(t,r)=>{if(h(t,"stage"),void 0!==r&&!(r instanceof Event))throw new TypeError('Expected "event" to be an Event or undefined.');i.onProgress&&i.onProgress({event:r,status:"loading",stage:t,url:d||(e instanceof HTMLMediaElement?e.src:"unknown")})},c=(t,r)=>{if(!(t instanceof Error))throw new TypeError('Expected "error" to be an Error.');h(r,"stage"),i.onError&&i.onError({error:t instanceof Error?t:new Error(String(t)),url:d||(e instanceof HTMLMediaElement?e.src:"unknown"),stage:r})};try{u("INITIALIZING"),"string"==typeof e?(d=e,l=new Audio(d)):(l=e,d=l.src);try{await new Promise((e,t)=>{const r=e=>u("DOWNLOADING",e),o=()=>{n(),e(void 0)},i=e=>{n(),t(new Error(`HTMLMediaElement failed to load: ${e.message||"Unknown error"}`))},n=()=>{l.removeEventListener("progress",r),l.removeEventListener("loadedmetadata",o),l.removeEventListener("error",i)};l.addEventListener("progress",r),l.addEventListener("loadedmetadata",o),l.addEventListener("error",i),l.readyState>=1&&(n(),e(void 0))}),u("METADATA_LOADED")}catch(e){throw new v(e instanceof Error?e.message:"UNKNOWN ERROR",d,"METADATA")}const m={id:r.id||await E(d),duration:Math.floor(1e3*l.duration),url:d,weight:r.weight??1};let p={};u("EXTRACTING_ID3");try{p=await A(d,o,a)}catch(e){c(e instanceof Error?e:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${d}. Falling back to filename.`)}const y=e=>{h(e,"url");try{return(e.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},f=e=>{const t={...e};return n(t._fetchData)&&(n(p._fetchData)&&(t._fetchData={...p._fetchData}),n(e._fetchData)&&(void 0!==e._fetchData.common&&(t._fetchData.common=e._fetchData.common),void 0!==e._fetchData.native&&(t._fetchData.native=e._fetchData.native),void 0!==e._fetchData.format&&(t._fetchData.format=e._fetchData.format),void 0!==e._fetchData.quality&&(t._fetchData.quality=e._fetchData.quality))),t},g={...m,...f(t),...p,...f(r),title:p.title||r.title||y(d),artist:p.artist||r.artist||("string"==typeof s?s:String(s()))};return i.onProgress&&i.onProgress({status:"success",stage:"COMPLETE",url:d}),g}catch(e){if(e instanceof v)throw e;const t=new v(e instanceof Error?e.message:"UNKNOWN ERROR",d,"INITIALIZING");throw c(t,"INITIALIZING"),t}})(e,t,r,o,i,a,P.#d)}#l=!1;get destroyed(){return this.#l}#u=new Set;#h=new WeakMap;#m=[];#p=-1;#c="NONE";#y=!1;#f=!1;#g=!1;#w=1;#b;#v;#E;#T=!1;#I;#x;#A=null;#k=null;#M=300;get fadeVolumeSpeed(){return L(this.#l),this.#M}set fadeVolumeSpeed(e){if(L(this.#l),"number"!=typeof e)throw new TypeError("fadeVolumeSpeed must be a number.");if(e<0)throw new RangeError("fadeVolumeSpeed cannot be negative.");this.#M=e,this.emit("fadeVolumeSpeedChange",this.#M)}#C=2e3;get prevClickTimeoutDuration(){return L(this.#l),this.#C}set prevClickTimeoutDuration(e){if(L(this.#l),"number"!=typeof e)throw new TypeError("prevClickTimeoutDuration must be a number.");if(e<0)throw new RangeError("prevClickTimeoutDuration cannot be negative.");this.#C=e,this.emit("prevClickTimeoutDurationChange",this.#C)}get repeatCurrentOnPrev(){return L(this.#l),this.#E}set repeatCurrentOnPrev(e){if(L(this.#l),"boolean"!=typeof e)throw new TypeError("repeatCurrentOnPrev must be a boolean.");this.#E=e,this.emit("repeatCurrentOnPrevChange",this.#E)}get smoothPlayPauseVolume(){return L(this.#l),this.#I}set smoothPlayPauseVolume(e){if(L(this.#l),"boolean"!=typeof e)throw new TypeError("smoothPlayPauseVolume must be a boolean.");this.#I=e,this.emit("smoothPlayPauseVolumeChange",this.#I)}get smoothStopVolume(){return L(this.#l),this.#x}set smoothStopVolume(e){if(L(this.#l),"boolean"!=typeof e)throw new TypeError("smoothStopVolume must be a boolean.");this.#x=e,this.emit("smoothStopVolumeChange",this.#x)}constructor(e={}){if(!a(e))throw new TypeError("Options must be a non-null object.");if(super({id:"[_blue_TinyMediaPlayer_reset_] :debug:",logger:e.logger??console,debugMode:e.debugMode??!1,useLogColors:e.useLogColors??!1}),void 0!==e.persistVolume){if("boolean"!=typeof e.persistVolume)throw new TypeError("persistVolume must be a boolean.");this.#b=e.persistVolume}else this.#b=!1;if(void 0!==e.volumeStorageKey){if("string"!=typeof e.volumeStorageKey)throw new TypeError("volumeStorageKey must be a string.");this.#v=e.volumeStorageKey}else this.#v="tiny_media_player_volume";if(void 0!==e.repeatCurrentOnPrev){if("boolean"!=typeof e.repeatCurrentOnPrev)throw new TypeError("repeatCurrentOnPrev must be a boolean.");this.#E=e.repeatCurrentOnPrev}else this.#E=!1;if(void 0!==e.smoothPlayPauseVolume){if("boolean"!=typeof e.smoothPlayPauseVolume)throw new TypeError("smoothPlayPauseVolume must be a boolean.");this.#I=e.smoothPlayPauseVolume}else this.#I=!1;if(void 0!==e.smoothStopVolume){if("boolean"!=typeof e.smoothStopVolume)throw new TypeError("smoothStopVolume must be a boolean.");this.#x=e.smoothStopVolume}else this.#x=!1;this.#b&&this.#L(),this.log("info","Instance initialized.",{options:e})}#L(){try{if("undefined"!=typeof window&&window.localStorage){const e=window.localStorage.getItem(this.#v);if(null!==e){const t=parseFloat(e);!isNaN(t)&&t>=0&&t<=1&&(this.#w=t,this.log("info",`Volume loaded from storage: ${this.#w}`))}}}catch(e){console.warn("[TinyMediaPlayer] Failed to read volume from localStorage.",e)}}#P(){try{this.#b&&"undefined"!=typeof window&&window.localStorage&&(window.localStorage.setItem(this.#v,this.#w.toString()),this.log("info",`Volume saved to storage: ${this.#w}`))}catch(e){console.warn("[TinyMediaPlayer] Failed to save volume to localStorage.",e)}}_getWeightedRandomIndex(){if(0===this.#m.length)return-1;if(1===this.#m.length)return 0;let e=0;for(let t=0;t<this.#m.length;t++){if(t===this.#p)continue;const r=this.#m[t];e+="number"==typeof r.weight&&r.weight>0?r.weight:1}let t=Math.random()*e;for(let e=0;e<this.#m.length;e++){if(e===this.#p)continue;const r=this.#m[e],o="number"==typeof r.weight&&r.weight>0?r.weight:1;if(t<o)return e;t-=o}return this.#p===this.#m.length-1?0:this.#m.length-1}async#S(e){this.#A&&this.#A.abort(),this.#A=new AbortController;const{signal:t}=this.#A,r=this.#_();if(!r)return;const o=r.getVolume(),i=performance.now(),n=this.#M;return this.log("info",`Starting volume fade: ${o} -> ${e}`),new Promise(a=>{const s=l=>{if(t.aborted)return this.log("info","Volume fade aborted."),a();const d=l-i,u=Math.min(d/n,1),h=o+(e-o)*u,m=Math.max(0,Math.min(1,h));r.setVolume(m),u<1?requestAnimationFrame(s):(r.setVolume(e),this.log("info",`Volume fade completed: ${e}`),a())};requestAnimationFrame(s)})}get playlist(){return L(this.#l),[...this.#m]}set playlist(e){if(L(this.#l),!Array.isArray(e))throw new TypeError("Playlist must be an array of MediaContent objects.");e.forEach(e=>x(e));const t=this.#f;let r=null;if(-1!==this.#p&&this.#m.length>0)try{r=this.#_()}catch(e){}this.#m=e,this.log("info",`Playlist updated. New size: ${this.#m.length}`),this.emit("playlistUpdate",this.playlist),0===this.#m.length?this.#p=-1:(this.#p>=this.#m.length||-1===this.#p)&&(this.#p=0),this.emit("trackChange",this.#p),t&&(async()=>{try{r&&await r.stop(),-1!==this.#p&&await this.play()}catch(e){this.log("error","Background transition error on playlist update:",e),console.warn("[TinyMediaPlayer] Background transition error on playlist update:",e)}})()}get currentIndex(){return L(this.#l),this.#p}set currentIndex(e){if(L(this.#l),"number"!=typeof e)throw new TypeError("Current index must be a number.");if(e<-1||e>=this.#m.length&&this.#m.length>0)throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);if(this.#p===e)return;this.log("info",`Index change requested: ${this.#p} -> ${e}`);const t=this.#f;let r=null;if(-1!==this.#p&&this.#m.length>0)try{r=this.#_()}catch(e){}this.#p=e,this.emit("trackChange",this.#p),t&&(async()=>{try{r&&await r.stop(),-1!==this.#p&&await this.play()}catch(e){this.log("error","Background transition error on index update:",e),console.warn("[TinyMediaPlayer] Background transition error on index update:",e)}})()}get loopMode(){return L(this.#l),this.#c}set loopMode(e){L(this.#l);const t=["NONE","TRACK","PLAYLIST"];if(!t.includes(e))throw new TypeError(`Loop mode must be one of: ${t.join(", ")}.`);this.#c=e,this.log("info",`Loop mode changed to: ${this.#c}`),this.emit("loopModeChange",this.#c)}get isRandom(){return L(this.#l),this.#y}set isRandom(e){if(L(this.#l),"boolean"!=typeof e)throw new TypeError("Random mode state must be a boolean.");this.#y=e,this.log("info",`Random mode: ${this.#y}`),this.emit("randomModeChange",this.#y)}get isPlaying(){return L(this.#l),this.#f}get volume(){return L(this.#l),this.#w}set volume(e){if(L(this.#l),"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.#A&&this.#A.abort(),this.log("info",`Volume changed: ${this.#w} -> ${e}`),this.#w=e,this.#P(),this.emit("volumeChange",this.#w),-1!==this.#p&&this.#m.length>0)try{const e=this.#_();e&&e.setVolume(this.#w)}catch(e){}}get persistVolume(){return L(this.#l),this.#b}set persistVolume(e){if(L(this.#l),"boolean"!=typeof e)throw new TypeError("Persist volume parameter must be a boolean.");this.#b=e,this.log("info",`Persist volume: ${this.#b}`),e&&this.#P()}get volumeStorageKey(){return L(this.#l),this.#v}set volumeStorageKey(e){if(L(this.#l),"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.#v;this.#v=e;try{this.#b&&"undefined"!=typeof window&&window.localStorage&&(window.localStorage.removeItem(t),this.#P())}catch(e){console.warn("[TinyMediaPlayer] Failed to migrate volume storage key.",e)}}get isMuted(){return L(this.#l),this.#g}async mute(){L(this.#l);const e=this.#_();e&&(await e.mute(),this.#g=!0,this.emit("muteChange",this.#g),this.log("info","Playback muted successfully."))}async unMute(){L(this.#l);const e=this.#_();e&&(await e.unMute(),this.#g=!1,this.emit("muteChange",this.#g),this.log("info","Playback unmuted successfully."))}get adapters(){return Array.from(this.#u)}get adaptersSize(){return this.#u.size}static#O=["timeupdate","ended"];static get defaultAdapterEventNames(){return structuredClone(P.#O)}static set defaultAdapterEventNames(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError("TinyMediaPlayer.defaultAdapterEventNames must be an array of strings.");P.#O=[...e]}#V=new Set(P.defaultAdapterEventNames);#R(e){const t=this.#h.get(e);t&&(this.#V.forEach(r=>{const o=t.get(r);o&&e.off(r,o)}),t.clear(),this.#h.delete(e))}registerAdapter(e){if(L(this.#l),!(e instanceof C))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");this.log("info","Registering new adapter:",e);const t=new Map;this.#h.set(e,t),this.#V.forEach(t=>{this.#j(e,t)}),this.#u.add(e)}removeAdapter(e){if(L(this.#l),!(e instanceof C))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");return this.log("info","Removing adapter:",e),this.#R(e),this.#u.delete(e)}destroyAdapter(e){if(L(this.#l),!(e instanceof C))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");this.log("info","Destroying adapter:",e),this.#R(e);const t=this.#u.delete(e);return t&&e.destroy(),t}hasAdapter(e){if(L(this.#l),!(e instanceof C))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");return this.#u.has(e)}destroyAllAdapters(){L(this.#l),this.log("info","Destroying all adapters."),this.#u.forEach(e=>{this.#R(e),e.destroy()}),this.#u.clear()}clearAdapters(){L(this.#l),this.log("info","Clearing all adapters."),this.#u.forEach(e=>this.#R(e)),this.#u.clear()}getMediaAdapter(e){if(!a(e))throw new TypeError("Content must be a valid object.");for(const t of this.#u.values())if(t.canHandle(e))return t;return null}#_(){if(-1===this.#p||0===this.#m.length)return null;const e=this.#m[this.#p],t=this.getMediaAdapter(e);if(t)return t;const r=`No compatible adapter found for content ID: ${e.id}.`;throw this.log("error",r),new Error(r)}addAdapterEvent(e){if(L(this.#l),"string"!=typeof e)throw new TypeError("Event name must be a string.");this.#V.has(e)||(this.log("info",`Adding adapter event listener: ${e}`),this.#V.add(e),this.#u.forEach(t=>{this.#j(t,e)}))}removeAdapterEvent(e){if(L(this.#l),"string"!=typeof e)throw new TypeError("Event name must be a string.");this.#V.has(e)&&(this.log("info",`Removing adapter event listener: ${e}`),this.#V.delete(e),this.#u.forEach(t=>{this.#N(t,e)}))}resetAdapterEvents(){L(this.#l);const e=P.defaultAdapterEventNames,t=Array.from(this.#V);for(const r of t)e.includes(r)||this.removeAdapterEvent(r);for(const t of e)this.#V.has(t)||this.addAdapterEvent(t)}#j(e,t){const r=this.#h.get(e);if(!r)return;const o=(...e)=>{this.#l||("timeupdate"!==t&&this.log("debug",`Adapter event triggered: ${t}`,...e),this.emit(t,...e))};e.on(t,o),r.set(t,o)}#N(e,t){const r=this.#h.get(e);if(!r)return;const o=r.get(t);o&&(e.off(t,o),r.delete(t))}addTrack(e){if(L(this.#l),!a(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,...e};x(t);const r=this.#m.push(t);return this.log("info",`Track added. New length: ${r}`,t),-1===this.#p&&(this.#p=0,this.emit("trackChange",this.#p)),this.emit("playlistUpdate",this.playlist),r}existsTrack(e){if(L(this.#l),"number"!=typeof e)throw new TypeError("Index must be a number.");return e>=0&&e<this.#m.length}getTrack(e){if(L(this.#l),"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.#m[e]}async removeTrack(e){if(L(this.#l),"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.`);this.log("info",`Removing track at index: ${e}`),e===this.#p?(await this.stop(),this.#m.splice(e,1),0===this.#m.length?this.#p=-1:this.#p>=this.#m.length&&(this.#p=0),this.emit("trackChange",this.#p)):(this.#m.splice(e,1),e<this.#p&&(this.#p-=1,this.emit("trackChange",this.#p))),this.emit("playlistUpdate",this.playlist)}searchTrack(e){if(L(this.#l),"string"!=typeof e&&"function"!=typeof e)throw new TypeError("Search query must be a string or a boolean evaluation function.");this.log("info","Searching playlist...",{query:e});const t=[];for(let r=0;r<this.#m.length;r++){const o=this.#m[r];let i=!1;if("function"==typeof e)i=Boolean(e(o));else{const t=e.toLowerCase(),r=o.title&&o.title.toLowerCase().includes(t),n=o.artist&&o.artist.toLowerCase().includes(t),a=o.album&&o.album.toLowerCase().includes(t);i=Boolean(r||n||a)}i&&t.push({track:o,index:r})}return this.log("info",`Search completed. Found ${t.length} results.`),t}async clearPlaylist(){L(this.#l),this.log("info","Clearing entire playlist."),await this.stop(),this.#m=[],this.#p=-1,this.emit("playlistUpdate",this.playlist),this.emit("trackChange",this.#p)}async play(){L(this.#l),this.log("info",`Attempting to play track at index: ${this.#p}`);const e=this.#_();if(e){this.#I?await this.#S(this.#w):e.setVolume(this.#w);try{await e.play(this.#m[this.#p]),this.#g&&await e.mute(),this.#f=!0,this.log("info","Playback started successfully."),this.emit("play",this.#p)}catch(e){throw this.log("error","Failed to play track:",e),e}}else this.log("error","Failed to play track:",`Active adapter not found for track at index ${this.#p}.`)}async pause(){L(this.#l),this.log("info","Attempting to pause playback.");const e=this.#_();e&&(this.#I&&await this.#S(0),await e.pause(),this.#f=!1,this.log("info","Playback paused."),this.emit("pause",this.#p))}async stop(){L(this.#l),this.log("info","Attempting to stop playback.");const e=this.#_();e&&(this.#x&&await this.#S(0),await e.stop(),this.#f=!1,this.log("info","Playback stopped."),this.emit("stop",this.#p))}async next(){if(L(this.#l),0!==this.#m.length){if(this.log("info","Next track requested."),await this.stop(),"TRACK"===this.#c)return this.log("info","Loop mode: TRACK. Repeating current track."),void await this.play();if(this.#y)this.#p=this._getWeightedRandomIndex(),this.log("info",`Random mode: Selected index ${this.#p}`);else{let e=this.#p+1;if(e>=this.#m.length){if("PLAYLIST"!==this.#c)return void this.log("info","End of playlist reached. Stopping.");e=0,this.log("info","Loop mode: PLAYLIST. Returning to start.")}this.#p=e}this.emit("trackChange",this.#p),await this.play()}}async prev(){if(L(this.#l),0!==this.#m.length){if(this.#E&&!this.#T)return this.log("info",'UX: Repeat current track on first "prev" click.'),this.#T=!0,this.#k&&clearTimeout(this.#k),this.#k=setTimeout(()=>{this.#T=!1,this.#k=null},2e3),await this.stop(),void await this.play();if(this.#k&&(clearTimeout(this.#k),this.#k=null),this.#T=!1,this.log("info","Previous track requested."),await this.stop(),this.#y)this.#p=this._getWeightedRandomIndex(),this.log("info",`Random mode: Selected index ${this.#p}`);else{let e=this.#p-1;if(e<0){if("PLAYLIST"!==this.#c)return void this.log("info","Start of playlist reached. Stopping.");e=this.#m.length-1,this.log("info","Loop mode: PLAYLIST. Returning to end.")}this.#p=e}this.emit("trackChange",this.#p),await this.play()}}async skipTo(e){if(L(this.#l),"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.`);this.log("info",`Skipping to index: ${e}`),await this.stop(),this.#p=e,this.emit("trackChange",this.#p),await this.play()}async seek(e){if(L(this.#l),"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.");this.log("info",`Seeking to: ${e}ms`);const t=this.#_();t&&(await t.seek(e),this.emit("seek",e))}async step(e){if(L(this.#l),"number"!=typeof e)throw new TypeError("Step amount must be a number in milliseconds.");this.log("info",`Stepping by: ${e}ms`);const t=this.#_();if(!t)return;let r=t.getCurrentTime()+e;r<0&&(r=0),await this.seek(r)}getCurrentTime(){L(this.#l);try{const e=this.#_();return e?e.getCurrentTime():0}catch{return 0}}getTotalDuration(){L(this.#l);try{const e=this.#_();return e?e.getTotalDuration():0}catch{return 0}}getRemainingTime(){L(this.#l);try{const e=this.#_();return e?e.getRemainingTime():0}catch{return 0}}getPlaybackPercentage(){L(this.#l);try{const e=this.#_();return e?e.getPlaybackPercentage():0}catch{return 0}}get isPaused(){L(this.#l);try{const e=this.#_();return!!e&&e.isPaused()}catch{return!1}}get isEnded(){L(this.#l);try{const e=this.#_();return!e||e.isEnded()}catch{return!0}}async getContentData(){L(this.#l);const e={id:"",createdAt:"",artistId:"",artistName:"",description:"",title:"",duration:0,avatar:"",url:""};try{const t=this.#_();return t?t.getContentData():e}catch{return e}}async waitIsReady(){L(this.#l);const e=this.#_();if(e)return e.waitIsReady()}async destroy(){if(!this.#l){this.log("info","Destroying TinyMediaPlayer instance.");try{this.#f&&await this.stop()}catch(e){this.log("error","Non-fatal error during playback termination:",e),console.warn("[TinyMediaPlayer] Non-fatal error during playback termination:",e)}this.#k&&clearTimeout(this.#k),this.#m=[],this.#p=-1,this.#f=!1,this.#T=!1,this.destroyAllAdapters(),this.removeAllListeners(),this.#V.clear(),this.#l=!0,this.emit("destroyed")}}}const S=P}};const t={};function r(o){const i=t[o];if(void 0!==i)return i.exports;const n=t[o]={exports:{}};return e[o](n,n.exports,r),n.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var o=0;o<t.length;){var i=t[o++],n=t[o++];r.o(e,i)?0===n&&o++:0===n?Object.defineProperty(e,i,{enumerable:!0,value:t[o++]}):Object.defineProperty(e,i,{enumerable:!0,get:n})}else for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.cjs=e=>{const t={exports:{}};return e.call(t.exports,t,t.exports),t.exports};let o=r(206);window.TinyMediaPlayer=o.TinyMediaPlayer})();
@@ -1 +1 @@
1
- (()=>{"use strict";var t={294(t,e,r){r.d(e,{TinyRadioFm:()=>L});var n=r.cjs(function(t,e){var r,n="object"==typeof Reflect?Reflect:null,i=n&&"function"==typeof n.apply?n.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};r=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var o=Number.isNaN||function(t){return t!=t};function a(){a.init.call(this)}t.exports=a,t.exports.once=function(t,e){return new Promise(function(r,n){function i(r){t.removeListener(e,o),n(r)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",i),r([].slice.call(arguments))}y(t,e,o,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&y(t,"error",e,{once:!0})}(t,i)})},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var s=10;function l(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function c(t){return void 0===t._maxListeners?a.defaultMaxListeners:t._maxListeners}function u(t,e,r,n){var i,o,a,s;if(l(r),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),a=o[e]),void 0===a)a=o[e]=r,++t._eventsCount;else if("function"==typeof a?a=o[e]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),(i=c(t))>0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=a.length,s=u,console&&console.warn&&console.warn(s)}return t}function d(){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 m(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=d.bind(n);return i.listener=r,n.wrapFn=i,i}function f(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(i):h(i,i.length)}function p(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function h(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function y(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,function i(o){n.once&&t.removeEventListener(e,i),r(o)})}}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(t){if("number"!=typeof t||t<0||o(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");s=t}}),a.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},a.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||o(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},a.prototype.getMaxListeners=function(){return c(this)},a.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var n="error"===t,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var a;if(e.length>0&&(a=e[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var l=o[t];if(void 0===l)return!1;if("function"==typeof l)i(l,this,e);else{var c=l.length,u=h(l,c);for(r=0;r<c;++r)i(u[r],this,e)}return!0},a.prototype.addListener=function(t,e){return u(this,t,e,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(t,e){return u(this,t,e,!0)},a.prototype.once=function(t,e){return l(e),this.on(t,m(this,t,e)),this},a.prototype.prependOnceListener=function(t,e){return l(e),this.prependListener(t,m(this,t,e)),this},a.prototype.removeListener=function(t,e){var r,n,i,o,a;if(l(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0===--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===e||r[o].listener===e){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,i),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,a||e)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},a.prototype.listeners=function(t){return f(this,t,!0)},a.prototype.rawListeners=function(t){return f(this,t,!1)},a.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):p.call(t,e)},a.prototype.listenerCount=p,a.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}});function i(t){if(!Array.isArray(t)&&!o(t))throw new TypeError("Argument must be either an Array or a pure JSON Object.");return Array.isArray(t)?t.length:Object.keys(t).length}function o(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&"[object Object]"===Object.prototype.toString.call(t)}const a=(t,e)=>{if("string"!=typeof e)throw new TypeError('Expected "name" to be a string.');if("string"!=typeof t)throw new TypeError(`Expected "${e}" to be a string, but received ${typeof t}.`)},s=(t,e)=>{if("string"!=typeof e)throw new TypeError('Expected "name" to be a string.');if("function"!=typeof t)throw new TypeError(`Expected "${e}" to be a function, but received ${typeof t}.`)},l=(t,e)=>{if("string"!=typeof e)throw new TypeError('Expected "name" to be a string.');if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError(`Expected "${e}" to be a plain object, but received ${null===t?"null":Array.isArray(t)?"array":typeof t}.`)},c=(t,e=!1)=>!e&&void 0===t,u=(t,e=!1)=>c(t,e)||"string"==typeof t||!e&&null===t,d=(t,e=!1)=>c(t,e)||"number"==typeof t||!e&&null===t,m=(t,e=!1)=>c(t,e)||"boolean"==typeof t||!e&&null===t,f=(t,e)=>!!c(t)||(s(e,"valueValidator"),Array.isArray(t)&&t.every(e)),p=new Map;class h extends Error{constructor(t,e,r){if(a(t,"message"),a(e,"url"),"string"!=typeof r)throw new TypeError(`Expected "stage" to be a string, but received ${typeof r}.`);super(t),this.name="MediaLoadingError",this.url=e,this.stage=r}}const y=async t=>{a(t,"str");const e=(new TextEncoder).encode(t),r=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(r)).map(t=>t.toString(16).padStart(2,"0")).join("").substring(0,8)},v=(t,e="image/jpeg")=>{if(!(t instanceof Uint8Array)&&"string"!=typeof t)throw new TypeError(`Expected "data" to be an instance of Uint8Array or a string, but received ${typeof t}.`);a(e,"format");const r=t=>{const e=URL.createObjectURL(t),r=p.get(e);return p.set(e,"number"==typeof r?r+1:1),e};if(t instanceof Uint8Array)return r(new Blob([t],{type:e}));if("string"==typeof t&&t.startsWith("data:")){const n=t.split(",")[1],i=atob(n),o=new Uint8Array(i.length);for(let t=0;t<i.length;t++)o[t]=i.charCodeAt(t);return r(new Blob([o],{type:e}))}return"string"==typeof t?t:""},g=async t=>{if(a(t,"url"),!t.startsWith("blob:"))return t;try{const e=await fetch(t),r=await e.blob();return await new Promise((t,e)=>{const n=new FileReader;n.onloadend=()=>t(String(n.result)),n.onerror=e,n.readAsDataURL(r)})}catch(e){return console.warn(`[TinyAudioUtils] Failed to convert Blob URL to Base64 on export: ${t}`,e),t}},w=t=>{l(t,"content"),t&&Array.isArray(t.picture)&&t.picture.forEach(t=>{if("string"==typeof t.data&&t.data.startsWith("blob:")){const e=p.get(t.data)??0;e>1?p.set(t.data,e-1):p.delete(t.data),e<=1&&URL.revokeObjectURL(t.data)}})},b=(t,e=!1)=>{if(o(t)){if(4!==i(t)){if(e)return!1;throw new TypeError("Invalid fetch data: Object must be an MediaContentFetchData.")}E(t.common),l(t.native,"_fetchData.native"),l(t.format,"_fetchData.format"),l(t.quality,"_fetchData.quality");for(const r in t.native){const n=t.native[r];if(!f(n,t=>"string"==typeof t.id)){if(e)return!1;throw new TypeError(`Invalid native data: "${r}" must be an array of native fetch data.`)}}}return!0},E=t=>{if(l(t,"common"),b(t._fetchData),!u(t.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!u(t.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!u(t.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a a string or null.');if(!u(t.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(!m(t.compilation))throw new TypeError('Invalid metadata: "compilation" must be a boolean or null.');if(!m(t.podcast))throw new TypeError('Invalid metadata: "podcast" must be a boolean or null.');if(!m(t.gapless))throw new TypeError('Invalid metadata: "gapless" must be a boolean or null.');if(!m(t.showMovement))throw new TypeError('Invalid metadata: "showMovement" must be a boolean or null.');if(!d(t.averageLevel))throw new TypeError('Invalid metadata: "averageLevel" must be a number or null.');if(!d(t.peakLevel))throw new TypeError('Invalid metadata: "peakLevel" must be a number or null.');if(!d(t.hdVideo))throw new TypeError('Invalid metadata: "hdVideo" must be a number or null.');if(!d(t.stik))throw new TypeError('Invalid metadata: "stik" must be a number or null.');if(!d(t.playCounter))throw new TypeError('Invalid metadata: "playCounter" must be a number or null.');if(!d(t.tvSeason))throw new TypeError('Invalid metadata: "tvSeason" must be a number or null.');if(!d(t.tvEpisode))throw new TypeError('Invalid metadata: "tvEpisode" must be a number or null.');if(!d(t.year))throw new TypeError('Invalid metadata: "year" must be a number or null.');if(!d(t.bpm))throw new TypeError('Invalid metadata: "bpm" must be a number or null.');if(!d(t.originalyear))throw new TypeError('Invalid metadata: "originalyear" must be a number or null.');if(!d(t.movementTotal))throw new TypeError('Invalid metadata: "movementTotal" must be a number or null.');if(!u(t.date))throw new TypeError('Invalid metadata: "date" must be a string or null.');if(!u(t.originaldate))throw new TypeError('Invalid metadata: "originaldate" must be a string or null.');if(!u(t.releasedate))throw new TypeError('Invalid metadata: "releasedate" must be a string or null.');if(!u(t.albumsort))throw new TypeError('Invalid metadata: "albumsort" must be a string or null.');if(!u(t.titlesort))throw new TypeError('Invalid metadata: "titlesort" must be a string or null.');if(!u(t.work))throw new TypeError('Invalid metadata: "work" must be a string or null.');if(!u(t.artistsort))throw new TypeError('Invalid metadata: "artistsort" must be a string or null.');if(!u(t.albumartistsort))throw new TypeError('Invalid metadata: "albumartistsort" must be a string or null.');if(!u(t.composersort))throw new TypeError('Invalid metadata: "composersort" must be a string or null.');if(!u(t.grouping))throw new TypeError('Invalid metadata: "grouping" must be a string or null.');if(!u(t.longDescription))throw new TypeError('Invalid metadata: "longDescription" must be a string or null.');if(!u(t.totaltracks))throw new TypeError('Invalid metadata: "totaltracks" must be a string or null.');if(!u(t.totaldiscs))throw new TypeError('Invalid metadata: "totaldiscs" must be a string or null.');if(!u(t.mood))throw new TypeError('Invalid metadata: "mood" must be a string or null.');if(!u(t.media))throw new TypeError('Invalid metadata: "media" must be a string or null.');if(!u(t.tvShow))throw new TypeError('Invalid metadata: "tvShow" must be a string or null.');if(!u(t.tvShowSort))throw new TypeError('Invalid metadata: "tvShowSort" must be a string or null.');if(!u(t.tvEpisodeId))throw new TypeError('Invalid metadata: "tvEpisodeId" must be a string or null.');if(!u(t.tvNetwork))throw new TypeError('Invalid metadata: "tvNetwork" must be a string or null.');if(!u(t.podcasturl))throw new TypeError('Invalid metadata: "podcasturl" must be a string or null.');if(!u(t.releasestatus))throw new TypeError('Invalid metadata: "releasestatus" must be a string or null.');if(!u(t.releasecountry))throw new TypeError('Invalid metadata: "releasecountry" must be a string or null.');if(!u(t.script))throw new TypeError('Invalid metadata: "script" must be a string or null.');if(!u(t.language))throw new TypeError('Invalid metadata: "language" must be a string or null.');if(!u(t.copyright))throw new TypeError('Invalid metadata: "copyright" must be a string or null.');if(!u(t.license))throw new TypeError('Invalid metadata: "license" must be a string or null.');if(!u(t.encodedby))throw new TypeError('Invalid metadata: "encodedby" must be a string or null.');if(!u(t.encodersettings))throw new TypeError('Invalid metadata: "encodersettings" must be a string or null.');if(!u(t.barcode))throw new TypeError('Invalid metadata: "barcode" must be a string or null.');if(!u(t.asin))throw new TypeError('Invalid metadata: "asin" must be a string or null.');if(!u(t.website))throw new TypeError('Invalid metadata: "website" must be a string or null.');if(!u(t.originalalbum))throw new TypeError('Invalid metadata: "originalalbum" must be a string or null.');if(!u(t.originalartist))throw new TypeError('Invalid metadata: "originalartist" must be a string or null.');if(!u(t.key))throw new TypeError('Invalid metadata: "key" must be a string or null.');if(!u(t.movement))throw new TypeError('Invalid metadata: "movement" must be a string or null.');if(!u(t.podcastId))throw new TypeError('Invalid metadata: "podcastId" must be a string or null.');if(!f(t.albumartists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "albumartists" must be an array of strings.');if(!f(t.genre,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "genre" must be an array of strings.');if(!f(t.label,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "label" must be an array of strings.');if(!f(t.composer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "composer" must be an array of strings.');if(!f(t.artists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "artists" must be an array of strings.');if(!f(t.lyricist,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "lyricist" must be an array of strings.');if(!f(t.writer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "writer" must be an array of strings.');if(!f(t.conductor,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "conductor" must be an array of strings.');if(!f(t.remixer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "remixer" must be an array of strings.');if(!f(t.arranger,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "arranger" must be an array of strings.');if(!f(t.engineer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "engineer" must be an array of strings.');if(!f(t.publisher,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "publisher" must be an array of strings.');if(!f(t.producer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "producer" must be an array of strings.');if(!f(t.djmixer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "djmixer" must be an array of strings.');if(!f(t.mixer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "mixer" must be an array of strings.');if(!f(t.technician,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "technician" must be an array of strings.');if(!f(t.subtitle,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "subtitle" must be an array of strings.');if(!f(t.description,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "description" must be an array of strings.');if(!f(t.discsubtitle,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "discsubtitle" must be an array of strings.');if(!f(t.releasetype,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "releasetype" must be an array of strings.');if(!f(t.isrc,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "isrc" must be an array of strings.');if(!f(t.performer_instrument,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "performer_instrument" must be an array of strings.');if(!f(t.notes,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "notes" must be an array of strings.');if(!f(t.category,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "category" must be an array of strings.');if(!f(t.keywords,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "keywords" must be an array of strings.');if(!f(t.catalognumber,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "catalognumber" must be an array of strings.');if(!f(t.picture,t=>t&&"object"==typeof t&&(void 0===t.description||"string"==typeof t.description)&&(void 0===t.name||"string"==typeof t.name)&&(void 0===t.type||"string"==typeof t.type)&&"string"==typeof t.format&&(t.data instanceof Uint8Array||"string"==typeof t.data)))throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');if(!f(t.comment,t=>null!==t&&"object"==typeof t&&u(t.descriptor)&&u(t.language)&&u(t.text)))throw new TypeError('Invalid metadata: "comment" must be an array of valid IComment objects.');if(!f(t.lyrics,t=>null!==t&&"object"==typeof t&&u(t.text)&&u(t.descriptor)&&u(t.language)&&(!Array.isArray(t)||f(t.syncText,t=>null!==t&&"object"==typeof t&&u(t.text)&&d(t.timestamp)))&&(t=>void 0===t||null!==t&&"object"==typeof t&&d(t.notSynchronized)&&d(t.mpegFrameNumber)&&d(t.milliseconds))(t.timeStampFormat)&&(t=>void 0===t||null!==t&&"object"==typeof t&&d(t.other)&&d(t.lyrics)&&d(t.text)&&d(t.movement_part)&&d(t.events)&&d(t.chord)&&d(t.trivia_pop))(t.contentType)))throw new TypeError('Invalid metadata: "lyrics" must be an array of valid ILyricsTag objects.');if(!f(t.rating,t=>null!==t&&"object"==typeof t&&u(t.source)&&d(t.rating)))throw new TypeError('Invalid metadata: "rating" must be an array of valid IRating objects.');const e=(t,e)=>{if(!c(e)&&null!==e){if("object"!=typeof e)throw new TypeError(`Invalid metadata: "${t}" must be an object or null.`);if("number"!=typeof e.no&&null!==e.no)throw new TypeError(`Invalid metadata: "${t}.no" must be a number or null.`);if("number"!=typeof e.of&&null!==e.of)throw new TypeError(`Invalid metadata: "${t}.of" must be a number or null.`)}};e("disk",t.disk),e("track",t.track),e("movementIndex",t.movementIndex)},T=t=>{if(t)throw new Error("This TinyRadioFm instance has been destroyed and can no longer be used.")};class I extends n.EventEmitter{static async parseContent(t,e,r,n,c,u=!0){return(async(t,e={},r={},n=t=>{if(!(t instanceof Blob))throw new TypeError('Expected "data" to be a Blob.');return new Promise((t,e)=>e(new TypeError("parseFile library not found.")))},c={},u=!0,d="null")=>{if("string"!=typeof t&&!(t instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(l(e,"defaultMetadata"),l(r,"metadata"),s(n,"parseFile"),l(c,"callbacks"),c.onProgress&&"function"!=typeof c.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(c.onError&&"function"!=typeof c.onError)throw new TypeError("callbacks.onError must be a function.");if("string"!=typeof d&&"function"!=typeof d)throw new TypeError("unknownArtist must be a string or a function returning a string.");let m,f="";const p=(e,r)=>{if(a(e,"stage"),void 0!==r&&!(r instanceof Event))throw new TypeError('Expected "event" to be an Event or undefined.');c.onProgress&&c.onProgress({event:r,status:"loading",stage:e,url:f||(t instanceof HTMLMediaElement?t.src:"unknown")})},g=(e,r)=>{if(!(e instanceof Error))throw new TypeError('Expected "error" to be an Error.');a(r,"stage"),c.onError&&c.onError({error:e instanceof Error?e:new Error(String(e)),url:f||(t instanceof HTMLMediaElement?t.src:"unknown"),stage:r})};try{p("INITIALIZING"),"string"==typeof t?(f=t,m=new Audio(f)):(m=t,f=m.src);try{await new Promise((t,e)=>{const r=t=>p("DOWNLOADING",t),n=()=>{o(),t(void 0)},i=t=>{o(),e(new Error(`HTMLMediaElement failed to load: ${t.message||"Unknown error"}`))},o=()=>{m.removeEventListener("progress",r),m.removeEventListener("loadedmetadata",n),m.removeEventListener("error",i)};m.addEventListener("progress",r),m.addEventListener("loadedmetadata",n),m.addEventListener("error",i),m.readyState>=1&&(o(),t(void 0))}),p("METADATA_LOADED")}catch(t){throw new h(t instanceof Error?t.message:"UNKNOWN ERROR",f,"METADATA")}const l={id:r.id||await y(f),duration:Math.floor(1e3*m.duration),url:f,weight:r.weight??1};let w={};p("EXTRACTING_ID3");try{w=await(async(t,e,r=!0)=>{a(t,"url"),s(e,"parseFile");const n=await fetch(t);if(!n.ok)throw new Error(`Failed to fetch audio file: ${n.status} ${n.statusText}`);const l=await n.blob(),c=await e(l);if(!c||"object"!=typeof c.common)throw new TypeError('Invalid metadata: "common" property is missing.');void 0!==typeof c.common["performer:instrument"]&&(c.common.performer_instrument=c.common["performer:instrument"]),b(c);const u=c.common;E(u);const d=([t,e])=>Array.isArray(e)?e.length>0:o(e)?i(Object.fromEntries(Object.entries(e).filter(d)))>0:null!==e,m=u?.picture?.map(t=>({...t,data:r?v(t.data,t.format):t.data}))??[];c.common={...c.common,picture:m.map(t=>({...t,data:""}))},r&&Object.keys(c.native).forEach(t=>{c.native[t]=c.native[t].map(t=>{if(t.value&&"object"==typeof t.value&&t.value.data instanceof Uint8Array){const e=u?.picture?.findIndex(e=>e.data===t.value.data&&e.format===t.value.format&&e.description===t.value.description&&e.name===t.value.name)??-1;if(m[e])return{...t,value:{...t.value,data:""}}}return t})});const f=Object.fromEntries(Object.entries({title:u?.title??null,album:u?.album??null,albumartist:u?.albumartist??null,albumartists:u?.albumartists??[],genre:u?.genre??[],label:u?.label??[],composer:u?.composer??[],year:u?.year??null,artist:u?.artist??null,artists:u?.artists??[],disk:u?.disk?{no:u.disk.no,of:u.disk.of}:null,track:u?.track?{no:u.track.no,of:u.track.of}:null,movementIndex:u?.movementIndex?{no:u.movementIndex.no,of:u.movementIndex.of}:null,picture:m,date:u?.date??null,originaldate:u?.originaldate??null,originalyear:u?.originalyear??null,releasedate:u?.releasedate??null,comment:u?.comment??[],lyrics:u?.lyrics??[],albumsort:u?.albumsort??null,titlesort:u?.titlesort??null,work:u?.work??null,artistsort:u?.artistsort??null,albumartistsort:u?.albumartistsort??null,composersort:u?.composersort??null,lyricist:u?.lyricist??[],writer:u?.writer??[],conductor:u?.conductor??[],remixer:u?.remixer??[],arranger:u?.arranger??[],engineer:u?.engineer??[],publisher:u?.publisher??[],producer:u?.producer??[],djmixer:u?.djmixer??[],mixer:u?.mixer??[],technician:u?.technician??[],grouping:u?.grouping??null,subtitle:u?.subtitle??[],description:u?.description??[],longDescription:u?.longDescription??null,discsubtitle:u?.discsubtitle??[],totaltracks:u?.totaltracks??null,totaldiscs:u?.totaldiscs??null,movementTotal:u?.movementTotal??null,compilation:u?.compilation??null,rating:u?.rating??[],bpm:u?.bpm??null,mood:u?.mood??null,media:u?.media??null,catalognumber:u?.catalognumber??[],tvShow:u?.tvShow??null,tvShowSort:u?.tvShowSort??null,tvSeason:u?.tvSeason??null,tvEpisode:u?.tvEpisode??null,tvEpisodeId:u?.tvEpisodeId??null,tvNetwork:u?.tvNetwork??null,podcast:u?.podcast??null,podcasturl:u?.podcasturl??null,releasestatus:u?.releasestatus??null,releasetype:u?.releasetype??[],releasecountry:u?.releasecountry??null,script:u?.script??null,language:u?.language??null,copyright:u?.copyright??null,license:u?.license??null,encodedby:u?.encodedby??null,encodersettings:u?.encodersettings??null,gapless:u?.gapless??null,barcode:u?.barcode??null,isrc:u?.isrc??[],asin:u?.asin??null,website:u?.website??null,performer_instrument:u?.performer_instrument??[],averageLevel:u?.averageLevel??null,peakLevel:u?.peakLevel??null,notes:u?.notes??[],originalalbum:u?.originalalbum??null,originalartist:u?.originalartist??null,key:u?.key??null,category:u?.category??[],hdVideo:u?.hdVideo??null,keywords:u?.keywords??[],movement:u?.movement??null,podcastId:u?.podcastId??null,showMovement:u?.showMovement??null,stik:u?.stik??null,playCounter:u?.playCounter??null}).filter(d));return f._fetchData=c,f})(f,n,u)}catch(t){g(t instanceof Error?t:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${f}. Falling back to filename.`)}const T=t=>{a(t,"url");try{return(t.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},I=t=>{const e={...t};return o(e._fetchData)&&(o(w._fetchData)&&(e._fetchData={...w._fetchData}),o(t._fetchData)&&(void 0!==t._fetchData.common&&(e._fetchData.common=t._fetchData.common),void 0!==t._fetchData.native&&(e._fetchData.native=t._fetchData.native),void 0!==t._fetchData.format&&(e._fetchData.format=t._fetchData.format),void 0!==t._fetchData.quality&&(e._fetchData.quality=t._fetchData.quality))),e},L={...l,...I(e),...w,...I(r),title:w.title||r.title||T(f),artist:w.artist||r.artist||("string"==typeof d?d:String(d()))};return c.onProgress&&c.onProgress({status:"success",stage:"COMPLETE",url:f}),L}catch(t){if(t instanceof h)throw t;const e=new h(t instanceof Error?t.message:"UNKNOWN ERROR",f,"INITIALIZING");throw g(e,"INITIALIZING"),e}})(t,e,r,n,c,u,I.#t)}static#t="Unknown Artist";static get unknownArtist(){return I.#t}static set unknownArtist(t){if("string"!=typeof t&&"function"!=typeof t)throw new TypeError("unknownArtist must have an string or function.");I.#t=t}#e=!1;get destroyed(){return this.#e}get size(){return T(this.#e),this.#r.length+this.#n.length}get musicSize(){return T(this.#e),this.#r.length}get voiceSize(){return T(this.#e),this.#n.length}get customPosSize(){return T(this.#e),this.#i.length}get tasksSize(){return T(this.#e),this.#o.length}get cycleCacheSize(){return T(this.#e),this.#a.size}#r=[];get musicList(){return T(this.#e),structuredClone(this.#r)}#n=[];get voiceList(){return T(this.#e),structuredClone(this.#n)}#i=[];get customPositions(){return T(this.#e),structuredClone(this.#i)}#o=[];get scheduledTasks(){return T(this.#e),structuredClone(this.#o)}get allList(){return T(this.#e),[...this.musicList,...this.voiceList]}#s=0;get seed(){return T(this.#e),this.#s}set seed(t){if(T(this.#e),"number"!=typeof t)throw new TypeError("Seed must be a number.");this.#s=t,this.#a.clear(),this.emit("seedChanged",{seed:t})}#l=Date.now();get anchorDate(){return T(this.#e),this.#l}#a=new Map;#c={mode:"playlist",voiceMode:"playlist",silenceDuration:0,queryLimit:1e5,voiceAfterMusic:!0,voiceMin:0,voiceMax:1,musicMaxConsecutive:0,musicMinConsecutive:0,voiceMaxConsecutive:0,voiceMinConsecutive:0};get config(){return T(this.#e),structuredClone(this.#c)}set config(t){T(this.#e),this.#u(t),this.#c=structuredClone(t),this.#a.clear(),this.emit("configChanged",{config:this.config})}#u(t){if("object"!=typeof t||null===t)throw new TypeError("Configuration must be a valid object.");const e=["playlist","random"];if(void 0!==t.mode&&!e.includes(t.mode))throw new TypeError(`Invalid mode: "${t.mode}". Must be one of: ${e.join(", ")}.`);if(void 0!==t.voiceMode&&!e.includes(t.voiceMode))throw new TypeError(`Invalid voiceMode: "${t.voiceMode}". Must be one of: ${e.join(", ")}.`);if(void 0!==t.silenceDuration&&("number"!=typeof t.silenceDuration||t.silenceDuration<0))throw new TypeError("silenceDuration must be a non-negative number.");if(void 0!==t.queryLimit&&("number"!=typeof t.queryLimit||t.queryLimit<=0))throw new TypeError("queryLimit must be a positive number.");if(void 0!==t.voiceAfterMusic&&"boolean"!=typeof t.voiceAfterMusic)throw new TypeError("voiceAfterMusic must be a boolean.");const r=(t,e)=>{if(void 0!==t&&("number"!=typeof t||t<0))throw new TypeError(`${e} must be a non-negative number.`)};r(t.voiceMin,"voiceMin"),r(t.voiceMax,"voiceMax"),r(t.musicMinConsecutive,"musicMinConsecutive"),r(t.musicMaxConsecutive,"musicMaxConsecutive"),r(t.voiceMinConsecutive,"voiceMinConsecutive"),r(t.voiceMaxConsecutive,"voiceMaxConsecutive");const n=t.voiceMin??this.#c.voiceMin,i=t.voiceMax??this.#c.voiceMax;if(i<n)throw new RangeError(`Logical error: voiceMax (${i}) cannot be less than voiceMin (${n}).`);const o=t.musicMinConsecutive??this.#c.musicMinConsecutive,a=t.musicMaxConsecutive??this.#c.musicMaxConsecutive;if(-1!==a&&o>a)throw new RangeError(`Logical error: musicMinConsecutive (${o}) cannot be greater than musicMaxConsecutive (${a}).`)}#d=!0;get optimizeMediaMemory(){return T(this.#e),this.#d}set optimizeMediaMemory(t){if(T(this.#e),"boolean"!=typeof t)throw new TypeError("optimizeMediaMemory must be a boolean.");this.#d=t}#m=!0;get optimizePictureMemory(){return T(this.#e),this.#m}set optimizePictureMemory(t){if(T(this.#e),"boolean"!=typeof t)throw new TypeError("optimizePictureMemory must be a boolean.");this.#m=t}constructor(t=null,e=0){if(super(),null!==t&&"object"!=typeof t)throw new TypeError("initialData must be an object or null.");if("number"!=typeof e)throw new TypeError("seed must be a number.");this.#s=e,t?this.#f(t):this.#l=Date.now()}_ccBase64ToBlobUrl(t){this.#d&&"string"==typeof t.url&&t.url.startsWith("data:")&&(t.url=v(t.url)),t.picture&&Array.isArray(t.picture)&&(t.picture=t.picture.map(t=>{if(this.#m){const e="string"==typeof t.data&&t.data.startsWith("data:"),r=t.data instanceof Uint8Array;if(e||r)return{...t,data:v(t.data,t.format)}}return t}))}async _rcblobUrlToBase64(t){this.#d&&"string"==typeof t.url&&t.url.startsWith("blob:")&&(t.url=await g(t.url)),this.#m&&t.picture&&Array.isArray(t.picture)&&(t.picture=await Promise.all(t.picture.map(async t=>"string"==typeof t.data&&t.data.startsWith("blob:")?{...t,data:await g(t.data)}:t)))}add(t,e,r=!0){if(T(this.#e),!["music","voice","custom"].includes(t))throw new TypeError('Type must be "music", "voice", or "custom".');if(!e||"string"!=typeof e.id||"number"!=typeof e.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.");E(e);const n=structuredClone(e);this._ccBase64ToBlobUrl(n),"music"===t?(this.#r.push(n),this.#a.clear()):"voice"===t?(this.#n.push(n),this.#a.clear()):"custom"===t&&this.#p(n,r),this.#h(Date.now()),this.emit("contentAdded",{type:t,data:structuredClone(n)})}scheduleTask(t,e,r,n,i=!0){if(T(this.#e),"number"!=typeof t||isNaN(t))throw new TypeError("timestamp must be a valid number.");if(!["add","remove","move"].includes(e))throw new TypeError('action must be "add", "remove", or "move".');if(!["music","voice"].includes(r))throw new TypeError('type must be "music" or "voice".');if("boolean"!=typeof i)throw new TypeError("smartQueue must be a boolean.");if("add"===e){if("object"!=typeof n||null===n||"string"!=typeof n.id||"number"!=typeof n.duration)throw new TypeError('Payload for "add" must be a MediaContent object (id: string, duration: number).')}else if("remove"===e){if("string"!=typeof n)throw new TypeError('Payload for "remove" must be a string (the content ID).')}else if("move"===e&&("object"!=typeof n||null===n||"string"!=typeof n.id||"number"!=typeof n.newIndex))throw new TypeError('Payload for "move" must be a ScheduledMovePayload (id: string, newIndex: number).');let a=t;if(i){const e=this.#y(t,t);e&&(a=e.absoluteEnd)}o(n)&&"number"!=typeof n.newIndex&&E(n);const s={timestamp:a,action:e,type:r,payload:n};this.#o.push(s),this.#h(Date.now()),this.emit("taskScheduled",structuredClone(s))}remove(t){if(T(this.#e),"string"!=typeof t)throw new TypeError("id must be a string.");this.#r.filter(e=>e.id===t).forEach(t=>w(t)),this.#n.filter(e=>e.id===t).forEach(t=>w(t)),this.#i.filter(e=>e.content?.id===t).forEach(t=>w(t.content));const e=e=>e.id!==t&&e.content?.id!==t;this.#r=this.#r.filter(e),this.#n=this.#n.filter(e),this.#i=this.#i.filter(e),this.#o=this.#o.filter(e=>"add"===e.action&&"object"==typeof e.payload&&null!==e.payload&&"id"in e.payload?e.payload.id!==t||(w(e.payload),!1):e.payload!==t),this.#a.clear(),this.emit("contentRemoved",{id:t})}setConfig(t){T(this.#e),this.#u(t);const e={...this.#c,...t};this.#u(e),this.#c=e,this.#a.clear(),this.emit("configChanged",{config:this.config})}getCurrentEvent(){T(this.#e);const t=Date.now();return this.#h(t),this.#y(t,t)}queryTimeline(t,e=10){if(T(this.#e),"number"!=typeof e||isNaN(e))throw new TypeError("Invalid query limit value. Ensure it is a number.");if(e>this.#c.queryLimit||e<=0)throw new RangeError(`Invalid query limit. Ensure it is > 0 and <= ${this.#c.queryLimit}.`);const r=new I(JSON.parse(this._exportState())),n=[];let i=t;for(let o=0;o<e;o++){r.#h(i);const e=r.#v(i,t);if(!e)break;n.push(e),i=e.absoluteEnd}return r.destroy(!1),this.emit("timelineQueried",{targetDate:t,limit:e,resultCount:n.length}),n}searchCustomPositions(){return T(this.#e),this.#h(Date.now()),[...this.#i]}async _processListForExport(t){return Promise.all(t.map(async t=>{E(t);const e=structuredClone(t);return await this._rcblobUrlToBase64(e),e}))}_exportState(){return JSON.stringify({music:this.#r,voice:this.#n,custom:this.#i,tasks:this.#o,seed:this.#s,anchorDate:this.#l,config:this.#c})}async exportState(){T(this.#e);const t=await this._processListForExport(this.#r),e=await this._processListForExport(this.#n),r=await Promise.all(this.#i.map(async t=>{const e=await this._processListForExport([t.content]);return{...t,content:e[0]}})),n=await Promise.all(this.#o.map(async t=>{if("add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload){const e=await this._processListForExport([t.payload]);return{...t,payload:e[0]}}return t}));return JSON.stringify({music:t,voice:e,custom:r,tasks:n,seed:this.#s,anchorDate:this.#l,config:this.#c})}importState(t){let e;if(T(this.#e),"string"==typeof t)try{e=JSON.parse(t)}catch{throw new TypeError("Provided string is not valid JSON.")}else{if("object"!=typeof t||null===t)throw new TypeError("Import data must be a valid JSON string or an object.");e=t}this.#f(e),this.emit("stateImported",{data:structuredClone(e)})}_prng(t){return function(){let e=t+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}#g(t,e,r,n=0,i=0,o=null,a=0){if(0===t.length)return{items:[],lastId:o,consecutiveCount:a};if("random"!==r){const e=[...t],r=e[e.length-1];return{items:e,lastId:r.id,consecutiveCount:o===r.id?a+1:1}}const s=t.map(t=>({...t,weight:t.weight??1})),l=this._prng(e),c=[];let u=o,d=a;for(;s.length>0;){let t=null,e=-1;if(null!==u&&d<n&&(e=s.findIndex(t=>t.id===u),-1!==e?t=s[e]:c.length>0&&(t=c[c.length-1])),!t){let r=s;null!==u&&-1!==i&&d>=i&&(r=s.filter(t=>t.id!==u)),0===r.length&&(r=s);const n=r.reduce((t,e)=>t+e.weight,0);if(n<=0)t=r[0],e=s.findIndex(e=>e.id===t?.id);else{const i=l()*n;let o=0;for(let n=0;n<r.length;n++)if(o+=r[n].weight,i<=o){t=r[n],e=s.findIndex(e=>e.id===t?.id);break}}}t||(t=s[0],e=0),c.push(t),-1!==e&&s.splice(e,1),t.id===u?d++:(u=t.id,d=1)}return{items:c,lastId:u,consecutiveCount:d}}#w(t){const e=this.#s+t,r=this._prng(10*e);let n=null,i=0,o=null,a=0;if(t>0){const e=this.#a.get(t-1);e&&(n=e.lastMusicId??null,i=e.musicConsecutiveCount??0,o=e.lastVoiceId??null,a=e.voiceConsecutiveCount??0)}const s=this.#g(this.#r,e+1,this.#c.mode,this.#c.musicMinConsecutive,this.#c.musicMaxConsecutive,n,i),l=s.items,c=this.#g(this.#n,e+2,this.#c.voiceMode,this.#c.voiceMinConsecutive,this.#c.voiceMaxConsecutive,o,a),u=c.items,d=[];let m=0,f=0;for(let t=0;t<l.length;t++){const e=l[t];if(d.push({...e,cycleStart:m,cycleEnd:m+e.duration}),m+=e.duration+this.#c.silenceDuration,this.#c.voiceAfterMusic&&u.length>0){const t=this.#c.voiceMax-this.#c.voiceMin+1,e=Math.floor(r()*t)+this.#c.voiceMin;for(let t=0;t<e;t++){const t=u[f%u.length];f++,d.push({...t,cycleStart:m,cycleEnd:m+t.duration}),m+=t.duration+this.#c.silenceDuration}}}return{items:d,duration:m,lastMusicId:s.lastId,musicConsecutiveCount:s.consecutiveCount,lastVoiceId:c.lastId,voiceConsecutiveCount:c.consecutiveCount}}#b(t){if(0===this.#r.length)return null;let e=this.#l,r=0;for(;;){if(r>this.#c.queryLimit)throw new Error("Safety limit hit during cycle location.");let n=this.#a.get(r);if(n||(n=this.#w(r),this.#a.set(r,n)),0===n.duration)return null;if(t>=e&&t<e+n.duration)return{block:n,startTimestamp:e,loopIndex:r};e+=n.duration,r++}}#v(t,e){const r=this.#i.filter(e=>e.intendedTimestamp+e.content.duration>t).sort((t,e)=>t.intendedTimestamp-e.intendedTimestamp)[0];let n=null;if(r){const t=Math.max(e,r.intendedTimestamp);n=this.#E(r.content,r.intendedTimestamp,t,!0)}const i=this.#T(t,e);return i||n?i?n?n.absoluteStart<=i.absoluteStart?n:(n.absoluteStart<i.absoluteEnd&&(i.absoluteEnd=n.absoluteStart,i.duration=i.absoluteEnd-i.absoluteStart,i.remainingTime=Math.max(0,i.absoluteEnd-e),i.progress=Math.min(1,i.elapsedTime/i.duration)),i):i:n:null}#T(t,e){let r=this.#b(t);if(!r)return null;const{block:n,startTimestamp:i}=r,o=t-i;let a,s=n.items.find(t=>t.cycleEnd>o);if(s)a=i+s.cycleStart;else{if(r=this.#b(i+n.duration),!r||0===r.block.items.length)return null;s=r.block.items[0],a=r.startTimestamp+s.cycleStart}const l=Math.max(e,a);return this.#E(s,a,l,!1)}#y(t,e){const r=this.#i.find(e=>t>=e.intendedTimestamp&&t<e.intendedTimestamp+e.content.duration);if(r)return this.#E(r.content,r.intendedTimestamp,e,!0);const n=this.#b(t);if(!n)return null;const{block:i,startTimestamp:o}=n,a=t-o,s=i.items.find(t=>a>=t.cycleStart&&a<t.cycleEnd);return s?this.#E(s,o+s.cycleStart,e,!1):null}#E(t,e,r,n){const i=r-e;return{id:t.id,title:t.title,artist:t.artist,duration:t.duration,url:t.url,absoluteStart:e,absoluteEnd:e+t.duration,elapsedTime:i,remainingTime:t.duration-i,progress:Math.min(1,i/t.duration),isCustom:n}}#p(t,e){let r=t.timestamp||Date.now();const n=t.duration;if(e){const t=this.#y(r,r);t&&(r=t.absoluteEnd)}const i=[...this.#i].sort((t,e)=>t.intendedTimestamp-e.intendedTimestamp);let o=r;if(i.some(t=>r<t.intendedTimestamp+t.content.duration&&r+n>t.intendedTimestamp)){const t=[];let e=Date.now();for(const r of i)r.intendedTimestamp>e&&t.push({start:e,end:r.intendedTimestamp}),e=Math.max(e,r.intendedTimestamp+r.content.duration+this.#c.silenceDuration);t.push({start:e,end:1/0});let a=1/0;for(const e of t)if(e.end-e.start>=n){let t=null;if(r>=e.start&&r+n<=e.end?t=r:r<e.start?t=e.start:r>e.end&&(t=e.end-n),null!==t){const e=Math.abs(r-t);e<a&&(a=e,o=t)}}}this.#i.push({content:t,intendedTimestamp:o,originalTimestamp:t.timestamp||Date.now()})}#h(t){const e=this.#o.filter(e=>e.timestamp<=t);this.#o=this.#o.filter(e=>e.timestamp>t);const r=this.#i.filter(e=>e.intendedTimestamp+e.content.duration<=t);this.#i=this.#i.filter(e=>e.intendedTimestamp+e.content.duration>t);let n=!1;r.forEach(t=>{w(t.content),this.#s+=t.content.id.length,n=!0,this.emit("customPositionExpired",{contentId:t.content.id})}),e.length>0&&e.sort((t,e)=>t.timestamp-e.timestamp).forEach(t=>{const e="music"===t.type?this.#r:this.#n;if("add"===t.action)e.push(t.payload);else if("remove"===t.action){const r=e.findIndex(e=>e.id===t.payload);if(-1!==r){const[t]=e.splice(r,1);w(t)}}else if("move"===t.action){const r=t.payload,n=e.findIndex(t=>t.id===r.id);if(-1!==n){const[t]=e.splice(n,1);e.splice(r.newIndex,0,t)}}this.#l=t.timestamp,this.#s+=1,n=!0,this.emit("taskExecuted",structuredClone(t))}),n&&this.#a.clear()}#f(t){this.#r.forEach(t=>w(t)),this.#n.forEach(t=>w(t)),this.#i.forEach(t=>w(t.content)),this.#o.forEach(t=>{"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload&&w(t.payload)});const e=t=>t.map(t=>{E(t);const e=structuredClone(t);return this._ccBase64ToBlobUrl(e),e});this.#r=e(t.music),this.#n=e(t.voice),this.#s=t.seed||0,this.#l=t.anchorDate||Date.now(),this.#c={...this.#c,...t.config||{}},this.#i=t.custom.map(t=>({...t,content:e([t.content])[0]})),this.#o=t.tasks.map(t=>"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload?{...t,payload:e([t.payload])[0]}:t)}destroy(t=!0){this.#e||(t&&(this.#r.forEach(t=>w(t)),this.#n.forEach(t=>w(t)),this.#i.forEach(t=>w(t.content)),this.#o.forEach(t=>{"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload&&w(t.payload)})),this.#r=[],this.#n=[],this.#i=[],this.#o=[],this.#a.clear(),this.emit("destroyed",{timestamp:Date.now()}),this.removeAllListeners(),this.#e=!0)}}const L=I}};const e={};function r(n){const i=e[n];if(void 0!==i)return i.exports;const o=e[n]={exports:{}};return t[n](o,o.exports,r),o.exports}r.d=(t,e)=>{if(Array.isArray(e))for(var n=0;n<e.length;){var i=e[n++],o=e[n++];r.o(t,i)?0===o&&n++:0===o?Object.defineProperty(t,i,{enumerable:!0,value:e[n++]}):Object.defineProperty(t,i,{enumerable:!0,get:o})}else for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.cjs=t=>{const e={exports:{}};return t.call(e.exports,e,e.exports),e.exports};let n=r(294);window.TinyRadioFm=n.TinyRadioFm})();
1
+ (()=>{"use strict";var e={450(e,t,r){r.d(t,{TinyRadioFm:()=>k});var i=r.cjs(function(e,t){var r,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};r=i&&"function"==typeof i.ownKeys?i.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 o(r){e.removeListener(t,n),i(r)}function n(){"function"==typeof e.removeListener&&e.removeListener("error",o),r([].slice.call(arguments))}y(e,t,n,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&y(e,"error",t,{once:!0})}(e,o)})},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var a=10;function u(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 d(e,t,r,i){var o,n,s,a;if(u(r),void 0===(n=e._events)?(n=e._events=Object.create(null),e._eventsCount=0):(void 0!==n.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),n=e._events),s=n[t]),void 0===s)s=n[t]=r,++e._eventsCount;else if("function"==typeof s?s=n[t]=i?[r,s]:[s,r]:i?s.unshift(r):s.push(r),(o=l(e))>0&&s.length>o&&!s.warned){s.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");d.name="MaxListenersExceededWarning",d.emitter=e,d.type=t,d.count=s.length,a=d,console&&console.warn&&console.warn(a)}return e}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function m(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=c.bind(i);return o.listener=r,i.wrapFn=o,o}function f(e,t,r){var i=e._events;if(void 0===i)return[];var o=i[t];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]: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}(o):p(o,o.length)}function h(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 y(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 o(n){i.once&&e.removeEventListener(t,o),r(n)})}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return a},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+".");a=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 i="error"===e,n=this._events;if(void 0!==n)i=i&&void 0===n.error;else if(!i)return!1;if(i){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=n[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var l=u.length,d=p(u,l);for(r=0;r<l;++r)o(d[r],this,t)}return!0},s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)},s.prototype.once=function(e,t){return u(t),this.on(e,m(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return u(t),this.prependListener(e,m(this,e,t)),this},s.prototype.removeListener=function(e,t){var r,i,o,n,s;if(u(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(o=-1,n=r.length-1;n>=0;n--)if(r[n]===t||r[n].listener===t){s=r[n].listener,o=n;break}if(o<0)return this;0===o?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,o),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,s||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 o,n=Object.keys(r);for(i=0;i<n.length;++i)"removeListener"!==(o=n[i])&&this.removeAllListeners(o);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 f(this,e,!0)},s.prototype.rawListeners=function(e){return f(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h,s.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}});function o(e){if(!Array.isArray(e)&&!n(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 n(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}function s(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function a(e,t){if(void 0!==t.obj&&"function"!=typeof t.obj)throw new TypeError("filter.obj must be a function if provided.");if(void 0!==t.value&&"function"!=typeof t.value)throw new TypeError("filter.value must be a function if provided.");if(void 0!==t.array&&"function"!=typeof t.array)throw new TypeError("filter.array must be a function if provided.");let r;r=e instanceof Map?new Map:e instanceof Set?new Set:{};const i=(o=e)instanceof Map?Array.from(o.entries()):o instanceof Set?Array.from(o.values()).map(e=>[void 0,e]):Object.entries(o);var o;const n=(e,r)=>{const i=[];for(let o=0;o<e.length;o++){const u=e[o];if(Array.isArray(u))i.push(n(u,r));else if(s(u)){const r=a(u,t);(void 0===t.obj||t.obj(r,o,e))&&i.push(r)}else(void 0===t.value||t.value([r,u],o,e))&&i.push(u)}return i};for(let e=0;e<i.length;e++){const[o,u]=i[e];if(Array.isArray(u)){const s=n(u,o);(void 0===t.array||t.array([o,s],e,i))&&(r instanceof Map||r instanceof Set?r instanceof Map?r.set(o,s):r.add(s):r[o]=s)}else if(s(u)){const n=a(u,t);(void 0===t.obj||t.obj(n,e,i))&&(r instanceof Map?r.set(o,n):r instanceof Set?r.add(n):r[o]=n)}else(void 0===t.value||t.value([o,u],e,i))&&(r instanceof Map?r.set(o,u):r instanceof Set?r.add(u):r[o]=u)}return r}const u=(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}.`)},l=(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}.`)},d=(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}.`)},c=(e,t=!1)=>!t&&void 0===e,m=(e,t=!1)=>c(e,t)||"string"==typeof e||!t&&null===e,f=(e,t=!1)=>c(e,t)||"number"==typeof e||!t&&null===e,h=(e,t=!1)=>c(e,t)||"boolean"==typeof e||!t&&null===e,p=(e,t)=>!!c(e)||(l(t,"valueValidator"),Array.isArray(e)&&e.every(t)),y=new Map;class g extends Error{constructor(e,t,r){if(u(e,"message"),u(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 w=async e=>{u(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)},b=(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}.`);u(t,"format");const r=e=>{const t=URL.createObjectURL(e),r=y.get(t);return y.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],o=atob(i),n=new Uint8Array(o.length);for(let e=0;e<o.length;e++)n[e]=o.charCodeAt(e);return r(new Blob([n],{type:t}))}return"string"==typeof e?e:""},v=async e=>{if(u(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}},E=e=>{d(e,"content"),e&&Array.isArray(e.picture)&&e.picture.forEach(e=>{if("string"==typeof e.data&&e.data.startsWith("blob:")){const t=y.get(e.data)??0;t>1?y.set(e.data,t-1):y.delete(e.data),t<=1&&URL.revokeObjectURL(e.data)}})},T=(e,t=!1)=>{if(n(e)){if(4!==o(e)){if(t)return!1;throw new TypeError("Invalid fetch data: Object must be an MediaContentFetchData.")}M(e.common),d(e.native,"_fetchData.native"),d(e.format,"_fetchData.format"),d(e.quality,"_fetchData.quality");for(const r in e.native){const i=e.native[r];if(!p(i,e=>"string"==typeof e.id)){if(t)return!1;throw new TypeError(`Invalid native data: "${r}" must be an array of native fetch data.`)}}}return!0},M=e=>{if(d(e,"common"),T(e._fetchData),!m(e.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!m(e.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!m(e.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a a string or null.');if(!m(e.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(!h(e.compilation))throw new TypeError('Invalid metadata: "compilation" must be a boolean or null.');if(!h(e.podcast))throw new TypeError('Invalid metadata: "podcast" must be a boolean or null.');if(!h(e.gapless))throw new TypeError('Invalid metadata: "gapless" must be a boolean or null.');if(!h(e.showMovement))throw new TypeError('Invalid metadata: "showMovement" must be a boolean or null.');if(!f(e.averageLevel))throw new TypeError('Invalid metadata: "averageLevel" must be a number or null.');if(!f(e.peakLevel))throw new TypeError('Invalid metadata: "peakLevel" must be a number or null.');if(!f(e.hdVideo))throw new TypeError('Invalid metadata: "hdVideo" must be a number or null.');if(!f(e.stik))throw new TypeError('Invalid metadata: "stik" must be a number or null.');if(!f(e.playCounter))throw new TypeError('Invalid metadata: "playCounter" must be a number or null.');if(!f(e.tvSeason))throw new TypeError('Invalid metadata: "tvSeason" must be a number or null.');if(!f(e.tvEpisode))throw new TypeError('Invalid metadata: "tvEpisode" must be a number or null.');if(!f(e.year))throw new TypeError('Invalid metadata: "year" must be a number or null.');if(!f(e.bpm))throw new TypeError('Invalid metadata: "bpm" must be a number or null.');if(!f(e.originalyear))throw new TypeError('Invalid metadata: "originalyear" must be a number or null.');if(!f(e.movementTotal))throw new TypeError('Invalid metadata: "movementTotal" must be a number or null.');if(!m(e.date))throw new TypeError('Invalid metadata: "date" must be a string or null.');if(!m(e.originaldate))throw new TypeError('Invalid metadata: "originaldate" must be a string or null.');if(!m(e.releasedate))throw new TypeError('Invalid metadata: "releasedate" must be a string or null.');if(!m(e.albumsort))throw new TypeError('Invalid metadata: "albumsort" must be a string or null.');if(!m(e.titlesort))throw new TypeError('Invalid metadata: "titlesort" must be a string or null.');if(!m(e.work))throw new TypeError('Invalid metadata: "work" must be a string or null.');if(!m(e.artistsort))throw new TypeError('Invalid metadata: "artistsort" must be a string or null.');if(!m(e.albumartistsort))throw new TypeError('Invalid metadata: "albumartistsort" must be a string or null.');if(!m(e.composersort))throw new TypeError('Invalid metadata: "composersort" must be a string or null.');if(!m(e.grouping))throw new TypeError('Invalid metadata: "grouping" must be a string or null.');if(!m(e.longDescription))throw new TypeError('Invalid metadata: "longDescription" must be a string or null.');if(!m(e.totaltracks))throw new TypeError('Invalid metadata: "totaltracks" must be a string or null.');if(!m(e.totaldiscs))throw new TypeError('Invalid metadata: "totaldiscs" must be a string or null.');if(!m(e.mood))throw new TypeError('Invalid metadata: "mood" must be a string or null.');if(!m(e.media))throw new TypeError('Invalid metadata: "media" must be a string or null.');if(!m(e.tvShow))throw new TypeError('Invalid metadata: "tvShow" must be a string or null.');if(!m(e.tvShowSort))throw new TypeError('Invalid metadata: "tvShowSort" must be a string or null.');if(!m(e.tvEpisodeId))throw new TypeError('Invalid metadata: "tvEpisodeId" must be a string or null.');if(!m(e.tvNetwork))throw new TypeError('Invalid metadata: "tvNetwork" must be a string or null.');if(!m(e.podcasturl))throw new TypeError('Invalid metadata: "podcasturl" must be a string or null.');if(!m(e.releasestatus))throw new TypeError('Invalid metadata: "releasestatus" must be a string or null.');if(!m(e.releasecountry))throw new TypeError('Invalid metadata: "releasecountry" must be a string or null.');if(!m(e.script))throw new TypeError('Invalid metadata: "script" must be a string or null.');if(!m(e.language))throw new TypeError('Invalid metadata: "language" must be a string or null.');if(!m(e.copyright))throw new TypeError('Invalid metadata: "copyright" must be a string or null.');if(!m(e.license))throw new TypeError('Invalid metadata: "license" must be a string or null.');if(!m(e.encodedby))throw new TypeError('Invalid metadata: "encodedby" must be a string or null.');if(!m(e.encodersettings))throw new TypeError('Invalid metadata: "encodersettings" must be a string or null.');if(!m(e.barcode))throw new TypeError('Invalid metadata: "barcode" must be a string or null.');if(!m(e.asin))throw new TypeError('Invalid metadata: "asin" must be a string or null.');if(!m(e.website))throw new TypeError('Invalid metadata: "website" must be a string or null.');if(!m(e.originalalbum))throw new TypeError('Invalid metadata: "originalalbum" must be a string or null.');if(!m(e.originalartist))throw new TypeError('Invalid metadata: "originalartist" must be a string or null.');if(!m(e.key))throw new TypeError('Invalid metadata: "key" must be a string or null.');if(!m(e.movement))throw new TypeError('Invalid metadata: "movement" must be a string or null.');if(!m(e.podcastId))throw new TypeError('Invalid metadata: "podcastId" must be a string or null.');if(!p(e.albumartists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "albumartists" must be an array of strings.');if(!p(e.genre,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "genre" must be an array of strings.');if(!p(e.label,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "label" must be an array of strings.');if(!p(e.composer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "composer" must be an array of strings.');if(!p(e.artists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "artists" must be an array of strings.');if(!p(e.lyricist,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "lyricist" must be an array of strings.');if(!p(e.writer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "writer" must be an array of strings.');if(!p(e.conductor,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "conductor" must be an array of strings.');if(!p(e.remixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "remixer" must be an array of strings.');if(!p(e.arranger,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "arranger" must be an array of strings.');if(!p(e.engineer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "engineer" must be an array of strings.');if(!p(e.publisher,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "publisher" must be an array of strings.');if(!p(e.producer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "producer" must be an array of strings.');if(!p(e.djmixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "djmixer" must be an array of strings.');if(!p(e.mixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "mixer" must be an array of strings.');if(!p(e.technician,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "technician" must be an array of strings.');if(!p(e.subtitle,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "subtitle" must be an array of strings.');if(!p(e.description,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "description" must be an array of strings.');if(!p(e.discsubtitle,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "discsubtitle" must be an array of strings.');if(!p(e.releasetype,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "releasetype" must be an array of strings.');if(!p(e.isrc,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "isrc" must be an array of strings.');if(!p(e.performer_instrument,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "performer_instrument" must be an array of strings.');if(!p(e.notes,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "notes" must be an array of strings.');if(!p(e.category,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "category" must be an array of strings.');if(!p(e.keywords,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "keywords" must be an array of strings.');if(!p(e.catalognumber,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "catalognumber" must be an array of strings.');if(!p(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.');if(!p(e.comment,e=>null!==e&&"object"==typeof e&&m(e.descriptor)&&m(e.language)&&m(e.text)))throw new TypeError('Invalid metadata: "comment" must be an array of valid IComment objects.');if(!p(e.lyrics,e=>null!==e&&"object"==typeof e&&m(e.text)&&m(e.descriptor)&&m(e.language)&&(!Array.isArray(e)||p(e.syncText,e=>null!==e&&"object"==typeof e&&m(e.text)&&f(e.timestamp)))&&(e=>void 0===e||null!==e&&"object"==typeof e&&f(e.notSynchronized)&&f(e.mpegFrameNumber)&&f(e.milliseconds))(e.timeStampFormat)&&(e=>void 0===e||null!==e&&"object"==typeof e&&f(e.other)&&f(e.lyrics)&&f(e.text)&&f(e.movement_part)&&f(e.events)&&f(e.chord)&&f(e.trivia_pop))(e.contentType)))throw new TypeError('Invalid metadata: "lyrics" must be an array of valid ILyricsTag objects.');if(!p(e.rating,e=>null!==e&&"object"==typeof e&&m(e.source)&&f(e.rating)))throw new TypeError('Invalid metadata: "rating" must be an array of valid IRating objects.');const t=(e,t)=>{if(!c(t)&&null!==t){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.`)}};t("disk",e.disk),t("track",e.track),t("movementIndex",e.movementIndex)},I=async(e,t,r=!0)=>{u(e,"url"),l(t,"parseFile");const i=await fetch(e);if(!i.ok)throw new Error(`Failed to fetch audio file: ${i.status} ${i.statusText}`);const n=await i.blob(),s=await t(n);if(!s||"object"!=typeof s.common)throw new TypeError('Invalid metadata: "common" property is missing.');void 0!==typeof s.common["performer:instrument"]&&(s.common.performer_instrument=s.common["performer:instrument"]),T(s);const d=s.common;M(d);const c=d?.picture?.map(e=>({...e,data:r?b(e.data,e.format):e.data}))??[];s.common={...s.common,picture:c.map(e=>({...e,data:""}))},r&&Object.keys(s.native).forEach(e=>{s.native[e]=s.native[e].map(e=>{if(e.value&&"object"==typeof e.value&&e.value.data instanceof Uint8Array){const t=d?.picture?.findIndex(t=>t.data===e.value.data&&t.format===e.value.format&&t.description===e.value.description&&t.name===e.value.name)??-1;if(c[t])return{...e,value:{...e.value,data:""}}}return e})});const m=a({title:d?.title,album:d?.album,albumartist:d?.albumartist,albumartists:d?.albumartists,genre:d?.genre,label:d?.label,composer:d?.composer,year:d?.year,artist:d?.artist,artists:d?.artists,disk:d?.disk?{no:d.disk.no,of:d.disk.of}:void 0,track:d?.track?{no:d.track.no,of:d.track.of}:void 0,movementIndex:d?.movementIndex?{no:d.movementIndex.no,of:d.movementIndex.of}:void 0,picture:c,date:d?.date,originaldate:d?.originaldate,originalyear:d?.originalyear,releasedate:d?.releasedate,comment:d?.comment,lyrics:d?.lyrics,albumsort:d?.albumsort,titlesort:d?.titlesort,work:d?.work,artistsort:d?.artistsort,albumartistsort:d?.albumartistsort,composersort:d?.composersort,lyricist:d?.lyricist,writer:d?.writer,conductor:d?.conductor,remixer:d?.remixer,arranger:d?.arranger,engineer:d?.engineer,publisher:d?.publisher,producer:d?.producer,djmixer:d?.djmixer,mixer:d?.mixer,technician:d?.technician,grouping:d?.grouping,subtitle:d?.subtitle,description:d?.description,longDescription:d?.longDescription,discsubtitle:d?.discsubtitle,totaltracks:d?.totaltracks,totaldiscs:d?.totaldiscs,movementTotal:d?.movementTotal,compilation:d?.compilation,rating:d?.rating,bpm:d?.bpm,mood:d?.mood,media:d?.media,catalognumber:d?.catalognumber,tvShow:d?.tvShow,tvShowSort:d?.tvShowSort,tvSeason:d?.tvSeason,tvEpisode:d?.tvEpisode,tvEpisodeId:d?.tvEpisodeId,tvNetwork:d?.tvNetwork,podcast:d?.podcast,podcasturl:d?.podcasturl,releasestatus:d?.releasestatus,releasetype:d?.releasetype,releasecountry:d?.releasecountry,script:d?.script,language:d?.language,copyright:d?.copyright,license:d?.license,encodedby:d?.encodedby,encodersettings:d?.encodersettings,gapless:d?.gapless,barcode:d?.barcode,isrc:d?.isrc,asin:d?.asin,website:d?.website,performer_instrument:d?.performer_instrument,averageLevel:d?.averageLevel,peakLevel:d?.peakLevel,notes:d?.notes,originalalbum:d?.originalalbum,originalartist:d?.originalartist,key:d?.key,category:d?.category,hdVideo:d?.hdVideo,keywords:d?.keywords,movement:d?.movement,podcastId:d?.podcastId,showMovement:d?.showMovement,stik:d?.stik,playCounter:d?.playCounter},{value:([e,t])=>null!=t,obj:e=>o(e)>0,array:([e,t])=>t.length>0});return m._fetchData=s,m},D=e=>t=>{if(t)throw new Error(`This ${e} instance has been destroyed and can no longer be used.`)},x=D("TinyAdvancedRaffle");class L extends i.EventEmitter{#e=!1;#t;#r;#i=[];#o=[];#n=[];#s=new Map;#a=new Set;#u=new Map;#l;#d=new Map;#c=new Map;get isDestroyed(){return this.#e}get freq(){return x(this.#e),Object.fromEntries(this.#c)}get size(){return x(this.#e),this.#d.size}get normalization(){return x(this.#e),this.#t}set normalization(e){if(x(this.#e),"string"!=typeof e||!e.trim())throw new TypeError("normalization must be a non-empty string (e.g., 'relative', 'softmax').");this.#t=e}get seed(){return x(this.#e),this.#r}set seed(e){if(x(this.#e),null!==e&&("number"!=typeof e||!Number.isFinite(e)))throw new TypeError("seed must be a finite number or null.");this.#r=e,null!==e&&(this.#l=this._makeSeededRng(e))}get globalModifiers(){return x(this.#e),[...this.#i]}set globalModifiers(e){if(x(this.#e),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("globalModifiers must be an array of functions (WeightsCallback).");this.#i=e}get temporaryModifiers(){return x(this.#e),[...this.#o]}set temporaryModifiers(e){if(x(this.#e),!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.#o=e}get conditionalRules(){return x(this.#e),[...this.#n]}set conditionalRules(e){if(x(this.#e),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("conditionalRules must be an array of functions (WeightsCallback).");this.#n=e}get pitySystems(){return x(this.#e),Object.fromEntries(this.#s)}set pitySystems(e){if(x(this.#e),!(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.#s=e}get exclusions(){return x(this.#e),Array.from(this.#a)}set exclusions(e){if(x(this.#e),!(e instanceof Set&&[...e].every(e=>"string"==typeof e)))throw new TypeError("exclusions must be a Set<string>.");this.#a=e}get groups(){x(this.#e);const e={};return this.#u.forEach((t,r)=>e[r]=Array.from(t)),e}set groups(e){if(x(this.#e),!(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.#u=e}get rng(){return x(this.#e),this.#l}set rng(e){if(x(this.#e),"function"!=typeof e||"number"!=typeof e())throw new TypeError("rng must be a function returning a number (RngGenerator).");this.#l=e}get items(){x(this.#e);const e={};return this.#d.forEach((t,r)=>{e[r]={...t,groups:Array.from(t.groups)}}),e}set items(e){if(x(this.#e),!(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.#d=e}constructor(e={}){super();const{rng:t=null,seed:r=null,normalization:i="relative"}=e;this.#t=i,this.#r=r,"function"==typeof t?this.#l=t:null!==this.#r?this.#l=this._makeSeededRng(this.#r):this.#l=Math.random,this.#r=r??null}hasItem(e){if(x(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#d.has(e)}addItem(e,t={}){if(x(this.#e),"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:o={},groups:n=[]}=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 o||null===o)throw new TypeError("meta must be an object");if(!(Array.isArray(n)||n instanceof Set))throw new TypeError("groups must be an array or a Set of strings");n=Array.isArray(n)?n:[...n];for(const e of n)if("string"!=typeof e)throw new TypeError("groups must contain only strings");const s={id:e,label:i,baseWeight:Math.max(0,Number(r)||0),meta:{...o},groups:new Set(n),locked:!1};this.#d.set(e,s);for(const t of n)this._ensureGroup(t).add(e);return this.emit("itemAdded",s),s}removeItem(e){if(x(this.#e),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");const t=this.#d.get(e);if(!t)return!1;for(const r of t.groups){const t=this.#u.get(r);t&&t.delete(e)}return this.#d.delete(e),this.emit("itemRemoved",e),this.resetFreq(e),this.resetPity(e),!0}setBaseWeight(e,t){if(x(this.#e),"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.#d.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(x(this.#e),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");return this.#d.get(e)??null}listItems(){return x(this.#e),Array.from(this.#d.values()).map(e=>({...e}))}clearList(){x(this.#e),this.#d.clear(),this.clearFreqs(),this.clearPities()}hasGlobalModifier(e){if(x(this.#e),"function"!=typeof e)throw new TypeError("fn must be a function");return this.#i.includes(e)}addGlobalModifier(e){if(x(this.#e),"function"!=typeof e)throw new TypeError("fn must be a function");this.#i.push(e)}removeGlobalModifier(e){if(x(this.#e),"function"!=typeof e)throw new TypeError("fn must be a function");this.#i=this.#i.filter(t=>t!==e)}hasTemporaryModifier(e){if(x(this.#e),"function"!=typeof e)throw new TypeError("fn must be a function");return this.#o.some(t=>t.fn===e)}addTemporaryModifier(e,t=1){if(x(this.#e),"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.#o.push({fn:e,uses:Math.max(1,Math.floor(t))})}removeTemporaryModifier(e){if(x(this.#e),"function"!=typeof e)throw new TypeError("fn must be a function");const t=this.#o.length;return this.#o=this.#o.filter(t=>t.fn!==e),this.#o.length!==t}hasConditionalRule(e){if(x(this.#e),"function"!=typeof e)throw new TypeError("ruleFn must be a function");return this.#n.includes(e)}addConditionalRule(e){if(x(this.#e),"function"!=typeof e)throw new TypeError("ruleFn must be a function");this.#n.push(e)}removeConditionalRule(e){if(x(this.#e),"function"!=typeof e)throw new TypeError("ruleFn must be a function");const t=this.#n.length;return this.#n=this.#n.filter(t=>t!==e),this.#n.length!==t}hasPity(e){if(x(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#s.has(e)}configurePity(e,t){if(x(this.#e),!this.#d.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:o=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 o)throw new TypeError("cap must be a number");this.#s.set(e,{threshold:Math.max(1,r),increment:Number(i)||0,cap:Number(o)||1/0,counter:0,currentAdd:0})}resetPity(e){if(x(this.#e),"string"!=typeof e||!e.trim())throw new TypeError("itemId must be a non-empty string");const t=this.#s.get(e);t&&(t.counter=0,t.currentAdd=0)}clearPities(){x(this.#e),this.#s.clear()}hasExclusion(e){if(x(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#a.has(e)}excludeItem(e){if(x(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#a.add(e)}includeItem(e){if(x(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#a.delete(e)}_ensureGroup(e){if(x(this.#e),"string"!=typeof e)throw new TypeError("name must be a string");let t=this.#u.get(e);return t||(t=new Set,this.#u.set(e,t)),t}hasInGroup(e,t){if(x(this.#e),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#u.get(t);return!!r&&r.has(e)}addToGroup(e,t){if(x(this.#e),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#d.get(e);if(!r)throw new Error("Item missing");r.groups.add(t),this._ensureGroup(t).add(e)}removeFromGroup(e,t){if(x(this.#e),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#u.get(t);r&&r.delete(e);const i=this.#d.get(e);i&&i.groups.delete(t)}clearFreqs(){x(this.#e),this.#c.clear()}resetFreq(e){if(x(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#c.delete(e)}computeEffectiveWeights(e={}){if(x(this.#e),"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.#d)t.set(e,r.baseWeight);for(const r of this.#i){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.#o){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.#n){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.#s)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.#a)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.#t){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 o=0;return t.map((e,t)=>{const n=r[t]/i;return o+=n,{id:e.id,weight:e.weight,p:n,cumulative:o}})}{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(x(this.#e),"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.#o]},r=this.computeEffectiveWeights(t),i=this._weightsToDistribution(r);if(!i.length)return null;const o=this.#l(),n=i.find(e=>o<=e.cumulative)??i[i.length-1];for(const[e,t]of this.#s)e===n.id?(t.counter=0,t.currentAdd=0):t.counter++;this._consumeTemporaryModifiers();const s=this.#d.get(n.id);if(!s)return null;const a={id:s.id,label:s.label,meta:{...s.meta},prob:n.p};return this.emit("draw",a),a&&this.#c.set(a.id,(this.#c.get(a.id)||0)+1),a}_consumeTemporaryModifiers(){for(let e=this.#o.length-1;e>=0;--e){const t=this.#o[e];t.uses-=1,t.uses<=0&&this.#o.splice(e,1)}}drawMany(e=1,t={}){if(x(this.#e),!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,o=[],n=t.previousDraws??[];if(!r&&i){const r=new Set;for(let i=0;i<e;++i){const e=new Set(this.#a);for(const e of r)this.#a.add(e);const i=this.drawOne({previousDraws:n,metadata:t.metadata});if(this.#a=e,!i)break;o.push(i),r.add(i.id),n.push(i)}return o}for(let i=0;i<e;++i){const e=this.drawOne({previousDraws:n,metadata:t.metadata});if(!e)break;o.push(e),n.push(e),r||this.excludeItem(e.id)}if(!r)for(const e of o)this.includeItem(e.id);return o}exportToJson(){return x(this.#e),{items:Array.from(this.#d.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.#s.entries()),exclusions:Array.from(this.#a),normalization:this.#t,seed:this.#r}}loadFromJson(e){if(x(this.#e),"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.#d.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(){x(this.#e);const e=new L;return e.#t=this.#t,e.#r=this.#r,e.#i=[...this.#i],e.#o=this.#o.map(e=>({fn:e.fn,uses:e.uses})),e.#n=[...this.#n],e.#s=new Map([...this.#s.entries()].map(([e,t])=>[e,{...t}])),e.#a=new Set(this.#a),e.#u=new Map([...this.#u.entries()].map(([e,t])=>[e,new Set(t)])),e.#l=this.#l,e.#d=new Map([...this.#d.entries()].map(([e,t])=>[e,{...t,groups:new Set(t.groups),meta:{...t.meta}}])),e.#c=new Map(this.#c),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.#e||(this.#s.clear(),this.#a.clear(),this.#u.clear(),this.#d.clear(),this.#c.clear(),this.#i=[],this.#o=[],this.#n=[],this.#r=null,this.#e=!0)}}const A=L,C=D("TinyRadioFm");class S extends i.EventEmitter{static async parseContent(e,t,r,i,o,s=!0){return(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.")))},o={},s=!0,a="null")=>{if("string"!=typeof e&&!(e instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(d(t,"defaultMetadata"),d(r,"metadata"),l(i,"parseFile"),d(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 a&&"function"!=typeof a)throw new TypeError("unknownArtist must be a string or a function returning a string.");let c,m="";const f=(t,r)=>{if(u(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:m||(e instanceof HTMLMediaElement?e.src:"unknown")})},h=(t,r)=>{if(!(t instanceof Error))throw new TypeError('Expected "error" to be an Error.');u(r,"stage"),o.onError&&o.onError({error:t instanceof Error?t:new Error(String(t)),url:m||(e instanceof HTMLMediaElement?e.src:"unknown"),stage:r})};try{f("INITIALIZING"),"string"==typeof e?(m=e,c=new Audio(m)):(c=e,m=c.src);try{await new Promise((e,t)=>{const r=e=>f("DOWNLOADING",e),i=()=>{n(),e(void 0)},o=e=>{n(),t(new Error(`HTMLMediaElement failed to load: ${e.message||"Unknown error"}`))},n=()=>{c.removeEventListener("progress",r),c.removeEventListener("loadedmetadata",i),c.removeEventListener("error",o)};c.addEventListener("progress",r),c.addEventListener("loadedmetadata",i),c.addEventListener("error",o),c.readyState>=1&&(n(),e(void 0))}),f("METADATA_LOADED")}catch(e){throw new g(e instanceof Error?e.message:"UNKNOWN ERROR",m,"METADATA")}const l={id:r.id||await w(m),duration:Math.floor(1e3*c.duration),url:m,weight:r.weight??1};let d={};f("EXTRACTING_ID3");try{d=await I(m,i,s)}catch(e){h(e instanceof Error?e:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${m}. Falling back to filename.`)}const p=e=>{u(e,"url");try{return(e.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},y=e=>{const t={...e};return n(t._fetchData)&&(n(d._fetchData)&&(t._fetchData={...d._fetchData}),n(e._fetchData)&&(void 0!==e._fetchData.common&&(t._fetchData.common=e._fetchData.common),void 0!==e._fetchData.native&&(t._fetchData.native=e._fetchData.native),void 0!==e._fetchData.format&&(t._fetchData.format=e._fetchData.format),void 0!==e._fetchData.quality&&(t._fetchData.quality=e._fetchData.quality))),t},b={...l,...y(t),...d,...y(r),title:d.title||r.title||p(m),artist:d.artist||r.artist||("string"==typeof a?a:String(a()))};return o.onProgress&&o.onProgress({status:"success",stage:"COMPLETE",url:m}),b}catch(e){if(e instanceof g)throw e;const t=new g(e instanceof Error?e.message:"UNKNOWN ERROR",m,"INITIALIZING");throw h(t,"INITIALIZING"),t}})(e,t,r,i,o,s,S.#m)}static#m="Unknown Artist";static get unknownArtist(){return S.#m}static set unknownArtist(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("unknownArtist must have an string or function.");S.#m=e}#f=!1;get destroyed(){return this.#f}get size(){return C(this.#f),this.#h.length+this.#p.length}get musicSize(){return C(this.#f),this.#h.length}get voiceSize(){return C(this.#f),this.#p.length}get customPosSize(){return C(this.#f),this.#y.length}get tasksSize(){return C(this.#f),this.#g.length}get cycleCacheSize(){return C(this.#f),this.#w.size}#h=[];get musicList(){return C(this.#f),structuredClone(this.#h)}#p=[];get voiceList(){return C(this.#f),structuredClone(this.#p)}#y=[];get customPositions(){return C(this.#f),structuredClone(this.#y)}#g=[];get scheduledTasks(){return C(this.#f),structuredClone(this.#g)}get allList(){return C(this.#f),[...this.musicList,...this.voiceList]}#r=0;get seed(){return C(this.#f),this.#r}set seed(e){if(C(this.#f),"number"!=typeof e)throw new TypeError("Seed must be a number.");this.#r=e,this.#w.clear(),this.emit("seedChanged",{seed:e})}#b=Date.now();get anchorDate(){return C(this.#f),this.#b}#w=new Map;#v={mode:"playlist",voiceMode:"playlist",silenceDuration:0,queryLimit:1e5,voiceAfterMusic:!0,voiceMin:0,voiceMax:1,voiceWeight:1,musicMaxConsecutive:0,musicMinConsecutive:0,voiceMaxConsecutive:0,voiceMinConsecutive:0};get config(){return C(this.#f),structuredClone(this.#v)}set config(e){C(this.#f),this.#E(e),this.#v=structuredClone(e),this.#w.clear(),this.emit("configChanged",{config:this.config})}#E(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.");const r=(e,t)=>{if(void 0!==e&&("number"!=typeof e||e<0))throw new TypeError(`${t} must be a non-negative number.`)};r(e.voiceWeight,"voiceWeight"),r(e.voiceMin,"voiceMin"),r(e.voiceMax,"voiceMax"),r(e.musicMinConsecutive,"musicMinConsecutive"),r(e.musicMaxConsecutive,"musicMaxConsecutive"),r(e.voiceMinConsecutive,"voiceMinConsecutive"),r(e.voiceMaxConsecutive,"voiceMaxConsecutive");const i=e.voiceMin??this.#v.voiceMin,o=e.voiceMax??this.#v.voiceMax;if(o<i)throw new RangeError(`Logical error: voiceMax (${o}) cannot be less than voiceMin (${i}).`);const n=e.musicMinConsecutive??this.#v.musicMinConsecutive,s=e.musicMaxConsecutive??this.#v.musicMaxConsecutive;if(-1!==s&&n>s)throw new RangeError(`Logical error: musicMinConsecutive (${n}) cannot be greater than musicMaxConsecutive (${s}).`)}#T=!0;get optimizeMediaMemory(){return C(this.#f),this.#T}set optimizeMediaMemory(e){if(C(this.#f),"boolean"!=typeof e)throw new TypeError("optimizeMediaMemory must be a boolean.");this.#T=e}#M=!0;get optimizePictureMemory(){return C(this.#f),this.#M}set optimizePictureMemory(e){if(C(this.#f),"boolean"!=typeof e)throw new TypeError("optimizePictureMemory must be a boolean.");this.#M=e}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.#r=t,e?this.#I(e):this.#b=Date.now()}_ccBase64ToBlobUrl(e){this.#T&&"string"==typeof e.url&&e.url.startsWith("data:")&&(e.url=b(e.url)),e.picture&&Array.isArray(e.picture)&&(e.picture=e.picture.map(e=>{if(this.#M){const t="string"==typeof e.data&&e.data.startsWith("data:"),r=e.data instanceof Uint8Array;if(t||r)return{...e,data:b(e.data,e.format)}}return e}))}async _rcblobUrlToBase64(e){this.#T&&"string"==typeof e.url&&e.url.startsWith("blob:")&&(e.url=await v(e.url)),this.#M&&e.picture&&Array.isArray(e.picture)&&(e.picture=await Promise.all(e.picture.map(async e=>"string"==typeof e.data&&e.data.startsWith("blob:")?{...e,data:await v(e.data)}:e)))}add(e,t,r=!0){if(C(this.#f),!["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.");M(t);const i=structuredClone(t);this._ccBase64ToBlobUrl(i),"music"===e?(this.#h.push(i),this.#w.clear()):"voice"===e?(this.#p.push(i),this.#w.clear()):"custom"===e&&this.#D(i,r),this.#x(Date.now()),this.emit("contentAdded",{type:e,data:structuredClone(i)})}scheduleTask(e,t,r,i,o=!0){if(C(this.#f),"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 o)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(o){const t=this.#L(e,e);t&&(s=t.absoluteEnd)}n(i)&&"number"!=typeof i.newIndex&&M(i);const a={timestamp:s,action:t,type:r,payload:i};this.#g.push(a),this.#x(Date.now()),this.emit("taskScheduled",structuredClone(a))}remove(e){if(C(this.#f),"string"!=typeof e)throw new TypeError("id must be a string.");this.#h.filter(t=>t.id===e).forEach(e=>E(e)),this.#p.filter(t=>t.id===e).forEach(e=>E(e)),this.#y.filter(t=>t.content?.id===e).forEach(e=>E(e.content));const t=t=>t.id!==e&&t.content?.id!==e;this.#h=this.#h.filter(t),this.#p=this.#p.filter(t),this.#y=this.#y.filter(t),this.#g=this.#g.filter(t=>"add"===t.action&&"object"==typeof t.payload&&null!==t.payload&&"id"in t.payload?t.payload.id!==e||(E(t.payload),!1):t.payload!==e),this.#w.clear(),this.emit("contentRemoved",{id:e})}setConfig(e){C(this.#f),this.#E(e);const t={...this.#v,...e};this.#E(t),this.#v=t,this.#w.clear(),this.emit("configChanged",{config:this.config})}getCurrentEvent(){C(this.#f);const e=Date.now();return this.#x(e),this.#L(e,e)}queryTimeline(e,t=10){if(C(this.#f),"number"!=typeof t||isNaN(t))throw new TypeError("Invalid query limit value. Ensure it is a number.");if(t>this.#v.queryLimit||t<=0)throw new RangeError(`Invalid query limit. Ensure it is > 0 and <= ${this.#v.queryLimit}.`);const r=new S(JSON.parse(this._exportState())),i=[];let o=e;for(let n=0;n<t;n++){r.#x(o);const t=r.#A(o,e);if(!t)break;i.push(t),o=t.absoluteEnd}return r.destroy(!1),this.emit("timelineQueried",{targetDate:e,limit:t,resultCount:i.length}),i}searchCustomPositions(){return C(this.#f),this.#x(Date.now()),[...this.#y]}async _processListForExport(e){return Promise.all(e.map(async e=>{M(e);const t=structuredClone(e);return await this._rcblobUrlToBase64(t),t}))}_exportState(){return JSON.stringify({music:this.#h,voice:this.#p,custom:this.#y,tasks:this.#g,seed:this.#r,anchorDate:this.#b,config:this.#v})}async exportState(){C(this.#f);const e=await this._processListForExport(this.#h),t=await this._processListForExport(this.#p),r=await Promise.all(this.#y.map(async e=>{const t=await this._processListForExport([e.content]);return{...e,content:t[0]}})),i=await Promise.all(this.#g.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.#r,anchorDate:this.#b,config:this.#v})}importState(e){let t;if(C(this.#f),"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.#I(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}}#C(e,t,r,i=0,o=0,n=null,s=0){if(0===e.length)return{items:[],lastId:n,consecutiveCount:s};if("random"!==r){const t=[...e],r=t[t.length-1];return{items:t,lastId:r.id,consecutiveCount:n===r.id?s+1:1}}const a=this._prng(t),u=[];let l=n,d=s;const c=new A({rng:a,normalization:"relative"}),m=[...e];for(m.forEach(e=>{const t=e.weight??1,r=c.getItem(e.id);r?c.setBaseWeight(e.id,r.baseWeight+t):c.addItem(e.id,{weight:t})});m.length>0;){let e=null,t=-1;if(null!==l&&d<i&&(t=m.findIndex(e=>e.id===l),-1!==t?e=m[t]:u.length>0&&(e=u[u.length-1])),!e){let r=null;null!==l&&-1!==o&&d>=o&&m.some(e=>e.id!==l)&&(c.excludeItem(l),r=l);const i=c.drawOne();i&&(t=m.findIndex(e=>e.id===i.id),-1!==t&&(e=m[t])),r&&c.includeItem(r)}if(e||(e=m[0],t=0),u.push(e),-1!==t)if(m.splice(t,1),m.some(t=>t.id===e.id)){const t=c.getItem(e.id);if(t){const r=Math.max(0,t.baseWeight-(e.weight??1));r<=0?c.removeItem(e.id):c.setBaseWeight(e.id,r)}}else c.removeItem(e.id);e.id===l?d++:(l=e.id,d=1)}return c.destroy(),{items:u,lastId:l,consecutiveCount:d}}#S(e){const t=this.#r+e,r=this._prng(10*t);let i=null,o=0,n=null,s=0;if(e>0){const t=this.#w.get(e-1);t&&(i=t.lastMusicId??null,o=t.musicConsecutiveCount??0,n=t.lastVoiceId??null,s=t.voiceConsecutiveCount??0)}const a=this.#C(this.#h,t+1,this.#v.mode,this.#v.musicMinConsecutive,this.#v.musicMaxConsecutive,i,o),u=a.items,l=this.#C(this.#p,t+2,this.#v.voiceMode,this.#v.voiceMinConsecutive,this.#v.voiceMaxConsecutive,n,s),d=l.items,c=[];let m=0,f=0;for(let e=0;e<u.length;e++){const t=u[e];if(c.push({...t,cycleStart:m,cycleEnd:m+t.duration}),m+=t.duration+this.#v.silenceDuration,this.#v.voiceAfterMusic&&d.length>0){const e=this.#v.voiceWeight/(this.#v.voiceWeight+1);if(r()<e){const e=this.#v.voiceMax-this.#v.voiceMin+1,t=Math.floor(r()*e)+this.#v.voiceMin;for(let e=0;e<t;e++){const e=d[f%d.length];f++,c.push({...e,cycleStart:m,cycleEnd:m+e.duration}),m+=e.duration+this.#v.silenceDuration}}}}return{items:c,duration:m,lastMusicId:a.lastId,musicConsecutiveCount:a.consecutiveCount,lastVoiceId:l.lastId,voiceConsecutiveCount:l.consecutiveCount}}#k(e){if(0===this.#h.length)return null;let t=this.#b,r=0;for(;;){if(r>this.#v.queryLimit)throw new Error("Safety limit hit during cycle location.");let i=this.#w.get(r);if(i||(i=this.#S(r),this.#w.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++}}#A(e,t){const r=this.#y.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.#j(r.content,r.intendedTimestamp,e,!0)}const o=this.#_(e,t);return o||i?o?i?i.absoluteStart<=o.absoluteStart?i:(i.absoluteStart<o.absoluteEnd&&(o.absoluteEnd=i.absoluteStart,o.duration=o.absoluteEnd-o.absoluteStart,o.remainingTime=Math.max(0,o.absoluteEnd-t),o.progress=Math.min(1,o.elapsedTime/o.duration)),o):o:i:null}#_(e,t){let r=this.#k(e);if(!r)return null;const{block:i,startTimestamp:o}=r,n=e-o;let s,a=i.items.find(e=>e.cycleEnd>n);if(a)s=o+a.cycleStart;else{if(r=this.#k(o+i.duration),!r||0===r.block.items.length)return null;a=r.block.items[0],s=r.startTimestamp+a.cycleStart}const u=Math.max(t,s);return this.#j(a,s,u,!1)}#L(e,t){const r=this.#y.find(t=>e>=t.intendedTimestamp&&e<t.intendedTimestamp+t.content.duration);if(r)return this.#j(r.content,r.intendedTimestamp,t,!0);const i=this.#k(e);if(!i)return null;const{block:o,startTimestamp:n}=i,s=e-n,a=o.items.find(e=>s>=e.cycleStart&&s<e.cycleEnd);return a?this.#j(a,n+a.cycleStart,t,!1):null}#j(e,t,r,i){const o=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:o,remainingTime:e.duration-o,progress:Math.min(1,o/e.duration),isCustom:i}}#D(e,t){let r=e.timestamp||Date.now();const i=e.duration;if(t){const e=this.#L(r,r);e&&(r=e.absoluteEnd)}const o=[...this.#y].sort((e,t)=>e.intendedTimestamp-t.intendedTimestamp);let n=r;if(o.some(e=>r<e.intendedTimestamp+e.content.duration&&r+i>e.intendedTimestamp)){const e=[];let t=Date.now();for(const r of o)r.intendedTimestamp>t&&e.push({start:t,end:r.intendedTimestamp}),t=Math.max(t,r.intendedTimestamp+r.content.duration+this.#v.silenceDuration);e.push({start:t,end:1/0});let s=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<s&&(s=t,n=e)}}}this.#y.push({content:e,intendedTimestamp:n,originalTimestamp:e.timestamp||Date.now()})}#x(e){const t=this.#g.filter(t=>t.timestamp<=e);this.#g=this.#g.filter(t=>t.timestamp>e);const r=this.#y.filter(t=>t.intendedTimestamp+t.content.duration<=e);this.#y=this.#y.filter(t=>t.intendedTimestamp+t.content.duration>e);let i=!1;r.forEach(e=>{E(e.content),this.#r+=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.#h:this.#p;if("add"===e.action)t.push(e.payload);else if("remove"===e.action){const r=t.findIndex(t=>t.id===e.payload);if(-1!==r){const[e]=t.splice(r,1);E(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.#b=e.timestamp,this.#r+=1,i=!0,this.emit("taskExecuted",structuredClone(e))}),i&&this.#w.clear()}#I(e){this.#h.forEach(e=>E(e)),this.#p.forEach(e=>E(e)),this.#y.forEach(e=>E(e.content)),this.#g.forEach(e=>{"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload&&E(e.payload)});const t=e=>e.map(e=>{M(e);const t=structuredClone(e);return this._ccBase64ToBlobUrl(t),t});this.#h=t(e.music),this.#p=t(e.voice),this.#r=e.seed||0,this.#b=e.anchorDate||Date.now(),this.#v={...this.#v,...e.config||{}},this.#y=e.custom.map(e=>({...e,content:t([e.content])[0]})),this.#g=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.#f||(e&&(this.#h.forEach(e=>E(e)),this.#p.forEach(e=>E(e)),this.#y.forEach(e=>E(e.content)),this.#g.forEach(e=>{"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload&&E(e.payload)})),this.#h=[],this.#p=[],this.#y=[],this.#g=[],this.#w.clear(),this.emit("destroyed",{timestamp:Date.now()}),this.removeAllListeners(),this.#f=!0)}}const k=S}};const t={};function r(i){const o=t[i];if(void 0!==o)return o.exports;const n=t[i]={exports:{}};return e[i](n,n.exports,r),n.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var i=0;i<t.length;){var o=t[i++],n=t[i++];r.o(e,o)?0===n&&i++:0===n?Object.defineProperty(e,o,{enumerable:!0,value:t[i++]}):Object.defineProperty(e,o,{enumerable:!0,get:n})}else for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.cjs=e=>{const t={exports:{}};return e.call(t.exports,t,t.exports),t.exports};let i=r(450);window.TinyRadioFm=i.TinyRadioFm})();
@@ -12,6 +12,7 @@ var collision = require('./collision.cjs');
12
12
  var mediaContent = require('./mediaContent.cjs');
13
13
  var promiseUtils = require('./promiseUtils.cjs');
14
14
  var browserDetector = require('./browserDetector.cjs');
15
+ var jsonFilter = require('./jsonFilter.cjs');
15
16
 
16
17
 
17
18
 
@@ -92,3 +93,6 @@ exports.getBrowserCssPrefix = browserDetector.getBrowserCssPrefix;
92
93
  exports.getBrowserPings = browserDetector.getBrowserPings;
93
94
  exports.getDuckTyping = browserDetector.getDuckTyping;
94
95
  exports.isBrowserAgent = browserDetector.isBrowserAgent;
96
+ exports.jsonFilter = jsonFilter.jsonFilter;
97
+ exports.jsonFilterByKeys = jsonFilter.jsonFilterByKeys;
98
+ exports.jsonFilterRecursive = jsonFilter.jsonFilterRecursive;
@@ -10,5 +10,6 @@ import { areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areEl
10
10
  import { extractMediaId3Tags, parseMediaMetadata, valMediaContentMetadata, valFetchMediaContent } from './mediaContent.mjs';
11
11
  import { createSingletonTask, waitForTrue } from './promiseUtils.mjs';
12
12
  import { browserIs, getBrowserCssPrefix, getBrowserPings, getDuckTyping, isBrowserAgent } from './browserDetector.mjs';
13
- export { getUserTimeFormat, getBrowserPings, isBrowserAgent, getBrowserCssPrefix, getDuckTyping, browserIs, isValidObj, createSingletonTask, waitForTrue, multiplyArrayBlocks, valMediaContentMetadata, valFetchMediaContent, parseMediaMetadata, extractMediaId3Tags, diffStrings, diffObjList, diffArrayList, breakdownDuration, calculateMarketcap, compareMarketcap, getPercentage, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, safeTextTrim, installWindowHiddenScript, genFibonacciSeq, fetchJson, fetchText, readJsonBlob, readFileBlob, readBase64Blob, saveJsonFile, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, isObjType, objTypeName, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst, };
13
+ import { jsonFilter, jsonFilterRecursive, jsonFilterByKeys } from './jsonFilter.mjs';
14
+ export { jsonFilter, jsonFilterRecursive, jsonFilterByKeys, getUserTimeFormat, getBrowserPings, isBrowserAgent, getBrowserCssPrefix, getDuckTyping, browserIs, isValidObj, createSingletonTask, waitForTrue, multiplyArrayBlocks, valMediaContentMetadata, valFetchMediaContent, parseMediaMetadata, extractMediaId3Tags, diffStrings, diffObjList, diffArrayList, breakdownDuration, calculateMarketcap, compareMarketcap, getPercentage, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, safeTextTrim, installWindowHiddenScript, genFibonacciSeq, fetchJson, fetchText, readJsonBlob, readFileBlob, readBase64Blob, saveJsonFile, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, isObjType, objTypeName, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst, };
14
15
  //# sourceMappingURL=index.d.mts.map