tiny-essentials 1.28.17 → 1.28.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/changelog/1/28/18.md +14 -0
  2. package/dist/v1/TinyEssentials.min.js +1 -1
  3. package/dist/v1/TinyRadioFm.min.js +1 -1
  4. package/dist/v1/css/TinyCookieConsent.min.css +1 -0
  5. package/dist/v1/css/TinyCookieConsent.min.css.map +1 -0
  6. package/dist/v1/css/TinyDraggerExample.min.css +1 -0
  7. package/dist/v1/css/TinyDraggerExample.min.css.map +1 -0
  8. package/dist/v1/css/TinyLoadingScreen.min.css +1 -0
  9. package/dist/v1/css/TinyLoadingScreen.min.css.map +1 -0
  10. package/dist/v1/css/TinyNotify.min.css +1 -0
  11. package/dist/v1/css/TinyNotify.min.css.map +1 -0
  12. package/dist/v1/css/aiMarker.min.css +1 -0
  13. package/dist/v1/css/aiMarker.min.css.map +1 -0
  14. package/dist/v1/libs/media/TinyRadioFm.cjs +83 -40
  15. package/dist/v1/libs/media/TinyRadioFm.d.mts +7 -2
  16. package/dist/v1/libs/media/TinyRadioFm.d.mts.map +1 -1
  17. package/dist/v1/libs/media/TinyRadioFm.mjs +77 -38
  18. package/dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.cjs +699 -0
  19. package/dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.d.mts +290 -0
  20. package/dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.d.mts.map +1 -0
  21. package/dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.mjs +590 -0
  22. package/dist/v1/webTemplates/bootstrap/5.3/scss/input/Placeholder-Colors-Fix.scss +64 -0
  23. package/dist/v1/webTemplates/bootstrap/5.3/scss/spacing/Spacing-Plus.scss +31 -0
  24. package/docs/v1/Exports.md +10 -0
  25. package/docs/v1/README.md +7 -1
  26. package/docs/v1/libs/media/TinyRadioFm.md +40 -11
  27. package/docs/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.md +162 -0
  28. package/package.json +13 -8
@@ -1 +1 @@
1
- (()=>{"use strict";var t={958(t,e,r){r.d(e,{TinyRadioFm:()=>C});var i=r.cjs(function(t,e){var r,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var n=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,i){function o(r){t.removeListener(e,n),i(r)}function n(){"function"==typeof t.removeListener&&t.removeListener("error",o),r([].slice.call(arguments))}y(t,e,n,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&y(t,"error",e,{once:!0})}(t,o)})},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var s=10;function c(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function l(t){return void 0===t._maxListeners?a.defaultMaxListeners:t._maxListeners}function u(t,e,r,i){var o,n,a,s;if(c(r),void 0===(n=t._events)?(n=t._events=Object.create(null),t._eventsCount=0):(void 0!==n.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),n=t._events),a=n[e]),void 0===a)a=n[e]=r,++t._eventsCount;else if("function"==typeof a?a=n[e]=i?[r,a]:[a,r]:i?a.unshift(r):a.push(r),(o=l(t))>0&&a.length>o&&!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 i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},o=d.bind(i);return o.listener=r,i.wrapFn=o,o}function f(t,e,r){var i=t._events;if(void 0===i)return[];var o=i[e];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]: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}(o):h(o,o.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),i=0;i<e;++i)r[i]=t[i];return r}function y(t,e,r,i){if("function"==typeof t.on)i.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 o(n){i.once&&t.removeEventListener(e,o),r(n)})}}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(t){if("number"!=typeof t||t<0||n(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||n(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 l(this)},a.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var i="error"===t,n=this._events;if(void 0!==n)i=i&&void 0===n.error;else if(!i)return!1;if(i){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 c=n[t];if(void 0===c)return!1;if("function"==typeof c)o(c,this,e);else{var l=c.length,u=h(c,l);for(r=0;r<l;++r)o(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 c(e),this.on(t,m(this,t,e)),this},a.prototype.prependOnceListener=function(t,e){return c(e),this.prependListener(t,m(this,t,e)),this},a.prototype.removeListener=function(t,e){var r,i,o,n,a;if(c(e),void 0===(i=this._events))return this;if(void 0===(r=i[t]))return this;if(r===e||r.listener===e)0===--this._eventsCount?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(o=-1,n=r.length-1;n>=0;n--)if(r[n]===e||r[n].listener===e){a=r[n].listener,o=n;break}if(o<0)return this;0===o?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,o),1===r.length&&(i[t]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",t,a||e)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(t){var e,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[t]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[t]),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(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(i=e.length-1;i>=0;i--)this.removeListener(t,e[i]);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 o(t){if(!Array.isArray(t)&&!n(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 n(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&"[object Object]"===Object.prototype.toString.call(t)}function a(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)}function s(t,e){if(void 0!==e.obj&&"function"!=typeof e.obj)throw new TypeError("filter.obj must be a function if provided.");if(void 0!==e.value&&"function"!=typeof e.value)throw new TypeError("filter.value must be a function if provided.");if(void 0!==e.array&&"function"!=typeof e.array)throw new TypeError("filter.array must be a function if provided.");let r;r=t instanceof Map?new Map:t instanceof Set?new Set:{};const i=(o=t)instanceof Map?Array.from(o.entries()):o instanceof Set?Array.from(o.values()).map(t=>[void 0,t]):Object.entries(o);var o;const n=(t,r)=>{const i=[];for(let o=0;o<t.length;o++){const c=t[o];if(Array.isArray(c))i.push(n(c,r));else if(a(c)){const r=s(c,e);(void 0===e.obj||e.obj(r,o,t))&&i.push(r)}else(void 0===e.value||e.value([r,c],o,t))&&i.push(c)}return i};for(let t=0;t<i.length;t++){const[o,c]=i[t];if(Array.isArray(c)){const a=n(c,o);(void 0===e.array||e.array([o,a],t,i))&&(r instanceof Map||r instanceof Set?r instanceof Map?r.set(o,a):r.add(a):r[o]=a)}else if(a(c)){const n=s(c,e);(void 0===e.obj||e.obj(n,t,i))&&(r instanceof Map?r.set(o,n):r instanceof Set?r.add(n):r[o]=n)}else(void 0===e.value||e.value([o,c],t,i))&&(r instanceof Map?r.set(o,c):r instanceof Set?r.add(c):r[o]=c)}return r}const c=(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}.`)},l=(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}.`)},u=(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}.`)},d=(t,e=!1)=>!e&&void 0===t,m=(t,e=!1)=>d(t,e)||"string"==typeof t||!e&&null===t,f=(t,e=!1)=>d(t,e)||"number"==typeof t||!e&&null===t,p=(t,e=!1)=>d(t,e)||"boolean"==typeof t||!e&&null===t,h=(t,e)=>!!d(t)||(l(e,"valueValidator"),Array.isArray(t)&&t.every(e)),y=new Map;class v extends Error{constructor(t,e,r){if(c(t,"message"),c(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 g=async t=>{c(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)},w=(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}.`);c(e,"format");const r=t=>{const e=URL.createObjectURL(t),r=y.get(e);return y.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 i=t.split(",")[1],o=atob(i),n=new Uint8Array(o.length);for(let t=0;t<o.length;t++)n[t]=o.charCodeAt(t);return r(new Blob([n],{type:e}))}return"string"==typeof t?t:""},b=async t=>{if(c(t,"url"),!t.startsWith("blob:"))return t;try{const e=await fetch(t),r=await e.blob();return await new Promise((t,e)=>{const i=new FileReader;i.onloadend=()=>t(String(i.result)),i.onerror=e,i.readAsDataURL(r)})}catch(e){return console.warn(`[TinyAudioUtils] Failed to convert Blob URL to Base64 on export: ${t}`,e),t}},E=t=>{u(t,"content"),t&&Array.isArray(t.picture)&&t.picture.forEach(t=>{if("string"==typeof t.data&&t.data.startsWith("blob:")){const e=y.get(t.data)??0;e>1?y.set(t.data,e-1):y.delete(t.data),e<=1&&URL.revokeObjectURL(t.data)}})},T=(t,e=!1)=>{if(n(t)){if(4!==o(t)){if(e)return!1;throw new TypeError("Invalid fetch data: Object must be an MediaContentFetchData.")}I(t.common),u(t.native,"_fetchData.native"),u(t.format,"_fetchData.format"),u(t.quality,"_fetchData.quality");for(const r in t.native){const i=t.native[r];if(!h(i,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},I=t=>{if(u(t,"common"),T(t._fetchData),!m(t.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!m(t.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!m(t.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a a string or null.');if(!m(t.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(!p(t.compilation))throw new TypeError('Invalid metadata: "compilation" must be a boolean or null.');if(!p(t.podcast))throw new TypeError('Invalid metadata: "podcast" must be a boolean or null.');if(!p(t.gapless))throw new TypeError('Invalid metadata: "gapless" must be a boolean or null.');if(!p(t.showMovement))throw new TypeError('Invalid metadata: "showMovement" must be a boolean or null.');if(!f(t.averageLevel))throw new TypeError('Invalid metadata: "averageLevel" must be a number or null.');if(!f(t.peakLevel))throw new TypeError('Invalid metadata: "peakLevel" must be a number or null.');if(!f(t.hdVideo))throw new TypeError('Invalid metadata: "hdVideo" must be a number or null.');if(!f(t.stik))throw new TypeError('Invalid metadata: "stik" must be a number or null.');if(!f(t.playCounter))throw new TypeError('Invalid metadata: "playCounter" must be a number or null.');if(!f(t.tvSeason))throw new TypeError('Invalid metadata: "tvSeason" must be a number or null.');if(!f(t.tvEpisode))throw new TypeError('Invalid metadata: "tvEpisode" must be a number or null.');if(!f(t.year))throw new TypeError('Invalid metadata: "year" must be a number or null.');if(!f(t.bpm))throw new TypeError('Invalid metadata: "bpm" must be a number or null.');if(!f(t.originalyear))throw new TypeError('Invalid metadata: "originalyear" must be a number or null.');if(!f(t.movementTotal))throw new TypeError('Invalid metadata: "movementTotal" must be a number or null.');if(!m(t.date))throw new TypeError('Invalid metadata: "date" must be a string or null.');if(!m(t.originaldate))throw new TypeError('Invalid metadata: "originaldate" must be a string or null.');if(!m(t.releasedate))throw new TypeError('Invalid metadata: "releasedate" must be a string or null.');if(!m(t.albumsort))throw new TypeError('Invalid metadata: "albumsort" must be a string or null.');if(!m(t.titlesort))throw new TypeError('Invalid metadata: "titlesort" must be a string or null.');if(!m(t.work))throw new TypeError('Invalid metadata: "work" must be a string or null.');if(!m(t.artistsort))throw new TypeError('Invalid metadata: "artistsort" must be a string or null.');if(!m(t.albumartistsort))throw new TypeError('Invalid metadata: "albumartistsort" must be a string or null.');if(!m(t.composersort))throw new TypeError('Invalid metadata: "composersort" must be a string or null.');if(!m(t.grouping))throw new TypeError('Invalid metadata: "grouping" must be a string or null.');if(!m(t.longDescription))throw new TypeError('Invalid metadata: "longDescription" must be a string or null.');if(!m(t.totaltracks))throw new TypeError('Invalid metadata: "totaltracks" must be a string or null.');if(!m(t.totaldiscs))throw new TypeError('Invalid metadata: "totaldiscs" must be a string or null.');if(!m(t.mood))throw new TypeError('Invalid metadata: "mood" must be a string or null.');if(!m(t.media))throw new TypeError('Invalid metadata: "media" must be a string or null.');if(!m(t.tvShow))throw new TypeError('Invalid metadata: "tvShow" must be a string or null.');if(!m(t.tvShowSort))throw new TypeError('Invalid metadata: "tvShowSort" must be a string or null.');if(!m(t.tvEpisodeId))throw new TypeError('Invalid metadata: "tvEpisodeId" must be a string or null.');if(!m(t.tvNetwork))throw new TypeError('Invalid metadata: "tvNetwork" must be a string or null.');if(!m(t.podcasturl))throw new TypeError('Invalid metadata: "podcasturl" must be a string or null.');if(!m(t.releasestatus))throw new TypeError('Invalid metadata: "releasestatus" must be a string or null.');if(!m(t.releasecountry))throw new TypeError('Invalid metadata: "releasecountry" must be a string or null.');if(!m(t.script))throw new TypeError('Invalid metadata: "script" must be a string or null.');if(!m(t.language))throw new TypeError('Invalid metadata: "language" must be a string or null.');if(!m(t.copyright))throw new TypeError('Invalid metadata: "copyright" must be a string or null.');if(!m(t.license))throw new TypeError('Invalid metadata: "license" must be a string or null.');if(!m(t.encodedby))throw new TypeError('Invalid metadata: "encodedby" must be a string or null.');if(!m(t.encodersettings))throw new TypeError('Invalid metadata: "encodersettings" must be a string or null.');if(!m(t.barcode))throw new TypeError('Invalid metadata: "barcode" must be a string or null.');if(!m(t.asin))throw new TypeError('Invalid metadata: "asin" must be a string or null.');if(!m(t.website))throw new TypeError('Invalid metadata: "website" must be a string or null.');if(!m(t.originalalbum))throw new TypeError('Invalid metadata: "originalalbum" must be a string or null.');if(!m(t.originalartist))throw new TypeError('Invalid metadata: "originalartist" must be a string or null.');if(!m(t.key))throw new TypeError('Invalid metadata: "key" must be a string or null.');if(!m(t.movement))throw new TypeError('Invalid metadata: "movement" must be a string or null.');if(!m(t.podcastId))throw new TypeError('Invalid metadata: "podcastId" must be a string or null.');if(!h(t.albumartists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "albumartists" must be an array of strings.');if(!h(t.genre,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "genre" must be an array of strings.');if(!h(t.label,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "label" must be an array of strings.');if(!h(t.composer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "composer" must be an array of strings.');if(!h(t.artists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "artists" must be an array of strings.');if(!h(t.lyricist,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "lyricist" must be an array of strings.');if(!h(t.writer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "writer" must be an array of strings.');if(!h(t.conductor,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "conductor" must be an array of strings.');if(!h(t.remixer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "remixer" must be an array of strings.');if(!h(t.arranger,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "arranger" must be an array of strings.');if(!h(t.engineer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "engineer" must be an array of strings.');if(!h(t.publisher,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "publisher" must be an array of strings.');if(!h(t.producer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "producer" must be an array of strings.');if(!h(t.djmixer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "djmixer" must be an array of strings.');if(!h(t.mixer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "mixer" must be an array of strings.');if(!h(t.technician,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "technician" must be an array of strings.');if(!h(t.subtitle,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "subtitle" must be an array of strings.');if(!h(t.description,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "description" must be an array of strings.');if(!h(t.discsubtitle,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "discsubtitle" must be an array of strings.');if(!h(t.releasetype,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "releasetype" must be an array of strings.');if(!h(t.isrc,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "isrc" must be an array of strings.');if(!h(t.performer_instrument,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "performer_instrument" must be an array of strings.');if(!h(t.notes,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "notes" must be an array of strings.');if(!h(t.category,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "category" must be an array of strings.');if(!h(t.keywords,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "keywords" must be an array of strings.');if(!h(t.catalognumber,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "catalognumber" must be an array of strings.');if(!h(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(!h(t.comment,t=>null!==t&&"object"==typeof t&&m(t.descriptor)&&m(t.language)&&m(t.text)))throw new TypeError('Invalid metadata: "comment" must be an array of valid IComment objects.');if(!h(t.lyrics,t=>null!==t&&"object"==typeof t&&m(t.text)&&m(t.descriptor)&&m(t.language)&&(!Array.isArray(t)||h(t.syncText,t=>null!==t&&"object"==typeof t&&m(t.text)&&f(t.timestamp)))&&(t=>void 0===t||null!==t&&"object"==typeof t&&f(t.notSynchronized)&&f(t.mpegFrameNumber)&&f(t.milliseconds))(t.timeStampFormat)&&(t=>void 0===t||null!==t&&"object"==typeof t&&f(t.other)&&f(t.lyrics)&&f(t.text)&&f(t.movement_part)&&f(t.events)&&f(t.chord)&&f(t.trivia_pop))(t.contentType)))throw new TypeError('Invalid metadata: "lyrics" must be an array of valid ILyricsTag objects.');if(!h(t.rating,t=>null!==t&&"object"==typeof t&&m(t.source)&&f(t.rating)))throw new TypeError('Invalid metadata: "rating" must be an array of valid IRating objects.');const e=(t,e)=>{if(!d(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)},L=async(t,e,r=!0)=>{c(t,"url"),l(e,"parseFile");const i=await fetch(t);if(!i.ok)throw new Error(`Failed to fetch audio file: ${i.status} ${i.statusText}`);const n=await i.blob(),a=await e(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"]),T(a);const u=a.common;I(u);const d=u?.picture?.map(t=>({...t,data:r?w(t.data,t.format):t.data}))??[];a.common={...a.common,picture:d.map(t=>({...t,data:""}))},r&&Object.keys(a.native).forEach(t=>{a.native[t]=a.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(d[e])return{...t,value:{...t.value,data:""}}}return t})});const m=s({title:u?.title,album:u?.album,albumartist:u?.albumartist,albumartists:u?.albumartists,genre:u?.genre,label:u?.label,composer:u?.composer,year:u?.year,artist:u?.artist,artists:u?.artists,disk:u?.disk?{no:u.disk.no,of:u.disk.of}:void 0,track:u?.track?{no:u.track.no,of:u.track.of}:void 0,movementIndex:u?.movementIndex?{no:u.movementIndex.no,of:u.movementIndex.of}:void 0,picture:d,date:u?.date,originaldate:u?.originaldate,originalyear:u?.originalyear,releasedate:u?.releasedate,comment:u?.comment,lyrics:u?.lyrics,albumsort:u?.albumsort,titlesort:u?.titlesort,work:u?.work,artistsort:u?.artistsort,albumartistsort:u?.albumartistsort,composersort:u?.composersort,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,subtitle:u?.subtitle,description:u?.description,longDescription:u?.longDescription,discsubtitle:u?.discsubtitle,totaltracks:u?.totaltracks,totaldiscs:u?.totaldiscs,movementTotal:u?.movementTotal,compilation:u?.compilation,rating:u?.rating,bpm:u?.bpm,mood:u?.mood,media:u?.media,catalognumber:u?.catalognumber,tvShow:u?.tvShow,tvShowSort:u?.tvShowSort,tvSeason:u?.tvSeason,tvEpisode:u?.tvEpisode,tvEpisodeId:u?.tvEpisodeId,tvNetwork:u?.tvNetwork,podcast:u?.podcast,podcasturl:u?.podcasturl,releasestatus:u?.releasestatus,releasetype:u?.releasetype,releasecountry:u?.releasecountry,script:u?.script,language:u?.language,copyright:u?.copyright,license:u?.license,encodedby:u?.encodedby,encodersettings:u?.encodersettings,gapless:u?.gapless,barcode:u?.barcode,isrc:u?.isrc,asin:u?.asin,website:u?.website,performer_instrument:u?.performer_instrument,averageLevel:u?.averageLevel,peakLevel:u?.peakLevel,notes:u?.notes,originalalbum:u?.originalalbum,originalartist:u?.originalartist,key:u?.key,category:u?.category,hdVideo:u?.hdVideo,keywords:u?.keywords,movement:u?.movement,podcastId:u?.podcastId,showMovement:u?.showMovement,stik:u?.stik,playCounter:u?.playCounter},{value:([t,e])=>null!=e,obj:t=>o(t)>0,array:([t,e])=>e.length>0});return m._fetchData=a,m},M=t=>{if(t)throw new Error("This TinyRadioFm instance has been destroyed and can no longer be used.")};class x extends i.EventEmitter{static async parseContent(t,e,r,i,o,a=!0){return(async(t,e={},r={},i=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.")))},o={},a=!0,s="null")=>{if("string"!=typeof t&&!(t instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(u(e,"defaultMetadata"),u(r,"metadata"),l(i,"parseFile"),u(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 s&&"function"!=typeof s)throw new TypeError("unknownArtist must be a string or a function returning a string.");let d,m="";const f=(e,r)=>{if(c(e,"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:e,url:m||(t instanceof HTMLMediaElement?t.src:"unknown")})},p=(e,r)=>{if(!(e instanceof Error))throw new TypeError('Expected "error" to be an Error.');c(r,"stage"),o.onError&&o.onError({error:e instanceof Error?e:new Error(String(e)),url:m||(t instanceof HTMLMediaElement?t.src:"unknown"),stage:r})};try{f("INITIALIZING"),"string"==typeof t?(m=t,d=new Audio(m)):(d=t,m=d.src);try{await new Promise((t,e)=>{const r=t=>f("DOWNLOADING",t),i=()=>{n(),t(void 0)},o=t=>{n(),e(new Error(`HTMLMediaElement failed to load: ${t.message||"Unknown error"}`))},n=()=>{d.removeEventListener("progress",r),d.removeEventListener("loadedmetadata",i),d.removeEventListener("error",o)};d.addEventListener("progress",r),d.addEventListener("loadedmetadata",i),d.addEventListener("error",o),d.readyState>=1&&(n(),t(void 0))}),f("METADATA_LOADED")}catch(t){throw new v(t instanceof Error?t.message:"UNKNOWN ERROR",m,"METADATA")}const l={id:r.id||await g(m),duration:Math.floor(1e3*d.duration),url:m,weight:r.weight??1};let u={};f("EXTRACTING_ID3");try{u=await L(m,i,a)}catch(t){p(t instanceof Error?t:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${m}. Falling back to filename.`)}const h=t=>{c(t,"url");try{return(t.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},y=t=>{const e={...t};return n(e._fetchData)&&(n(u._fetchData)&&(e._fetchData={...u._fetchData}),n(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},w={...l,...y(e),...u,...y(r),title:u.title||r.title||h(m),artist:u.artist||r.artist||("string"==typeof s?s:String(s()))};return o.onProgress&&o.onProgress({status:"success",stage:"COMPLETE",url:m}),w}catch(t){if(t instanceof v)throw t;const e=new v(t instanceof Error?t.message:"UNKNOWN ERROR",m,"INITIALIZING");throw p(e,"INITIALIZING"),e}})(t,e,r,i,o,a,x.#t)}static#t="Unknown Artist";static get unknownArtist(){return x.#t}static set unknownArtist(t){if("string"!=typeof t&&"function"!=typeof t)throw new TypeError("unknownArtist must have an string or function.");x.#t=t}#e=!1;get destroyed(){return this.#e}get size(){return M(this.#e),this.#r.length+this.#i.length}get musicSize(){return M(this.#e),this.#r.length}get voiceSize(){return M(this.#e),this.#i.length}get customPosSize(){return M(this.#e),this.#o.length}get tasksSize(){return M(this.#e),this.#n.length}get cycleCacheSize(){return M(this.#e),this.#a.size}#r=[];get musicList(){return M(this.#e),structuredClone(this.#r)}#i=[];get voiceList(){return M(this.#e),structuredClone(this.#i)}#o=[];get customPositions(){return M(this.#e),structuredClone(this.#o)}#n=[];get scheduledTasks(){return M(this.#e),structuredClone(this.#n)}get allList(){return M(this.#e),[...this.musicList,...this.voiceList]}#s=0;get seed(){return M(this.#e),this.#s}set seed(t){if(M(this.#e),"number"!=typeof t)throw new TypeError("Seed must be a number.");this.#s=t,this.#a.clear(),this.emit("seedChanged",{seed:t})}#c=Date.now();get anchorDate(){return M(this.#e),this.#c}#a=new Map;#l={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 M(this.#e),structuredClone(this.#l)}set config(t){M(this.#e),this.#u(t),this.#l=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 i=t.voiceMin??this.#l.voiceMin,o=t.voiceMax??this.#l.voiceMax;if(o<i)throw new RangeError(`Logical error: voiceMax (${o}) cannot be less than voiceMin (${i}).`);const n=t.musicMinConsecutive??this.#l.musicMinConsecutive,a=t.musicMaxConsecutive??this.#l.musicMaxConsecutive;if(-1!==a&&n>a)throw new RangeError(`Logical error: musicMinConsecutive (${n}) cannot be greater than musicMaxConsecutive (${a}).`)}#d=!0;get optimizeMediaMemory(){return M(this.#e),this.#d}set optimizeMediaMemory(t){if(M(this.#e),"boolean"!=typeof t)throw new TypeError("optimizeMediaMemory must be a boolean.");this.#d=t}#m=!0;get optimizePictureMemory(){return M(this.#e),this.#m}set optimizePictureMemory(t){if(M(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.#c=Date.now()}_ccBase64ToBlobUrl(t){this.#d&&"string"==typeof t.url&&t.url.startsWith("data:")&&(t.url=w(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:w(t.data,t.format)}}return t}))}async _rcblobUrlToBase64(t){this.#d&&"string"==typeof t.url&&t.url.startsWith("blob:")&&(t.url=await b(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 b(t.data)}:t)))}add(t,e,r=!0){if(M(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.");I(e);const i=structuredClone(e);this._ccBase64ToBlobUrl(i),"music"===t?(this.#r.push(i),this.#a.clear()):"voice"===t?(this.#i.push(i),this.#a.clear()):"custom"===t&&this.#p(i,r),this.#h(Date.now()),this.emit("contentAdded",{type:t,data:structuredClone(i)})}scheduleTask(t,e,r,i,o=!0){if(M(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 o)throw new TypeError("smartQueue must be a boolean.");if("add"===e){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"===e){if("string"!=typeof i)throw new TypeError('Payload for "remove" must be a string (the content ID).')}else if("move"===e&&("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 a=t;if(o){const e=this.#y(t,t);e&&(a=e.absoluteEnd)}n(i)&&"number"!=typeof i.newIndex&&I(i);const s={timestamp:a,action:e,type:r,payload:i};this.#n.push(s),this.#h(Date.now()),this.emit("taskScheduled",structuredClone(s))}remove(t){if(M(this.#e),"string"!=typeof t)throw new TypeError("id must be a string.");this.#r.filter(e=>e.id===t).forEach(t=>E(t)),this.#i.filter(e=>e.id===t).forEach(t=>E(t)),this.#o.filter(e=>e.content?.id===t).forEach(t=>E(t.content));const e=e=>e.id!==t&&e.content?.id!==t;this.#r=this.#r.filter(e),this.#i=this.#i.filter(e),this.#o=this.#o.filter(e),this.#n=this.#n.filter(e=>"add"===e.action&&"object"==typeof e.payload&&null!==e.payload&&"id"in e.payload?e.payload.id!==t||(E(e.payload),!1):e.payload!==t),this.#a.clear(),this.emit("contentRemoved",{id:t})}setConfig(t){M(this.#e),this.#u(t);const e={...this.#l,...t};this.#u(e),this.#l=e,this.#a.clear(),this.emit("configChanged",{config:this.config})}getCurrentEvent(){M(this.#e);const t=Date.now();return this.#h(t),this.#y(t,t)}queryTimeline(t,e=10){if(M(this.#e),"number"!=typeof e||isNaN(e))throw new TypeError("Invalid query limit value. Ensure it is a number.");if(e>this.#l.queryLimit||e<=0)throw new RangeError(`Invalid query limit. Ensure it is > 0 and <= ${this.#l.queryLimit}.`);const r=new x(JSON.parse(this._exportState())),i=[];let o=t;for(let n=0;n<e;n++){r.#h(o);const e=r.#v(o,t);if(!e)break;i.push(e),o=e.absoluteEnd}return r.destroy(!1),this.emit("timelineQueried",{targetDate:t,limit:e,resultCount:i.length}),i}searchCustomPositions(){return M(this.#e),this.#h(Date.now()),[...this.#o]}async _processListForExport(t){return Promise.all(t.map(async t=>{I(t);const e=structuredClone(t);return await this._rcblobUrlToBase64(e),e}))}_exportState(){return JSON.stringify({music:this.#r,voice:this.#i,custom:this.#o,tasks:this.#n,seed:this.#s,anchorDate:this.#c,config:this.#l})}async exportState(){M(this.#e);const t=await this._processListForExport(this.#r),e=await this._processListForExport(this.#i),r=await Promise.all(this.#o.map(async t=>{const e=await this._processListForExport([t.content]);return{...t,content:e[0]}})),i=await Promise.all(this.#n.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:i,seed:this.#s,anchorDate:this.#c,config:this.#l})}importState(t){let e;if(M(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,i=0,o=0,n=null,a=0){if(0===t.length)return{items:[],lastId:n,consecutiveCount:a};if("random"!==r){const e=[...t],r=e[e.length-1];return{items:e,lastId:r.id,consecutiveCount:n===r.id?a+1:1}}const s=t.map(t=>({...t,weight:t.weight??1})),c=this._prng(e),l=[];let u=n,d=a;for(;s.length>0;){let t=null,e=-1;if(null!==u&&d<i&&(e=s.findIndex(t=>t.id===u),-1!==e?t=s[e]:l.length>0&&(t=l[l.length-1])),!t){let r=s;null!==u&&-1!==o&&d>=o&&(r=s.filter(t=>t.id!==u)),0===r.length&&(r=s);const i=r.reduce((t,e)=>t+e.weight,0);if(i<=0)t=r[0],e=s.findIndex(e=>e.id===t?.id);else{const o=c()*i;let n=0;for(let i=0;i<r.length;i++)if(n+=r[i].weight,o<=n){t=r[i],e=s.findIndex(e=>e.id===t?.id);break}}}t||(t=s[0],e=0),l.push(t),-1!==e&&s.splice(e,1),t.id===u?d++:(u=t.id,d=1)}return{items:l,lastId:u,consecutiveCount:d}}#w(t){const e=this.#s+t,r=this._prng(10*e);let i=null,o=0,n=null,a=0;if(t>0){const e=this.#a.get(t-1);e&&(i=e.lastMusicId??null,o=e.musicConsecutiveCount??0,n=e.lastVoiceId??null,a=e.voiceConsecutiveCount??0)}const s=this.#g(this.#r,e+1,this.#l.mode,this.#l.musicMinConsecutive,this.#l.musicMaxConsecutive,i,o),c=s.items,l=this.#g(this.#i,e+2,this.#l.voiceMode,this.#l.voiceMinConsecutive,this.#l.voiceMaxConsecutive,n,a),u=l.items,d=[];let m=0,f=0;for(let t=0;t<c.length;t++){const e=c[t];if(d.push({...e,cycleStart:m,cycleEnd:m+e.duration}),m+=e.duration+this.#l.silenceDuration,this.#l.voiceAfterMusic&&u.length>0){const t=this.#l.voiceMax-this.#l.voiceMin+1,e=Math.floor(r()*t)+this.#l.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.#l.silenceDuration}}}return{items:d,duration:m,lastMusicId:s.lastId,musicConsecutiveCount:s.consecutiveCount,lastVoiceId:l.lastId,voiceConsecutiveCount:l.consecutiveCount}}#b(t){if(0===this.#r.length)return null;let e=this.#c,r=0;for(;;){if(r>this.#l.queryLimit)throw new Error("Safety limit hit during cycle location.");let i=this.#a.get(r);if(i||(i=this.#w(r),this.#a.set(r,i)),0===i.duration)return null;if(t>=e&&t<e+i.duration)return{block:i,startTimestamp:e,loopIndex:r};e+=i.duration,r++}}#v(t,e){const r=this.#o.filter(e=>e.intendedTimestamp+e.content.duration>t).sort((t,e)=>t.intendedTimestamp-e.intendedTimestamp)[0];let i=null;if(r){const t=Math.max(e,r.intendedTimestamp);i=this.#E(r.content,r.intendedTimestamp,t,!0)}const o=this.#T(t,e);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-e),o.progress=Math.min(1,o.elapsedTime/o.duration)),o):o:i:null}#T(t,e){let r=this.#b(t);if(!r)return null;const{block:i,startTimestamp:o}=r,n=t-o;let a,s=i.items.find(t=>t.cycleEnd>n);if(s)a=o+s.cycleStart;else{if(r=this.#b(o+i.duration),!r||0===r.block.items.length)return null;s=r.block.items[0],a=r.startTimestamp+s.cycleStart}const c=Math.max(e,a);return this.#E(s,a,c,!1)}#y(t,e){const r=this.#o.find(e=>t>=e.intendedTimestamp&&t<e.intendedTimestamp+e.content.duration);if(r)return this.#E(r.content,r.intendedTimestamp,e,!0);const i=this.#b(t);if(!i)return null;const{block:o,startTimestamp:n}=i,a=t-n,s=o.items.find(t=>a>=t.cycleStart&&a<t.cycleEnd);return s?this.#E(s,n+s.cycleStart,e,!1):null}#E(t,e,r,i){const o=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:o,remainingTime:t.duration-o,progress:Math.min(1,o/t.duration),isCustom:i}}#p(t,e){let r=t.timestamp||Date.now();const i=t.duration;if(e){const t=this.#y(r,r);t&&(r=t.absoluteEnd)}const o=[...this.#o].sort((t,e)=>t.intendedTimestamp-e.intendedTimestamp);let n=r;if(o.some(t=>r<t.intendedTimestamp+t.content.duration&&r+i>t.intendedTimestamp)){const t=[];let e=Date.now();for(const r of o)r.intendedTimestamp>e&&t.push({start:e,end:r.intendedTimestamp}),e=Math.max(e,r.intendedTimestamp+r.content.duration+this.#l.silenceDuration);t.push({start:e,end:1/0});let a=1/0;for(const e of t)if(e.end-e.start>=i){let t=null;if(r>=e.start&&r+i<=e.end?t=r:r<e.start?t=e.start:r>e.end&&(t=e.end-i),null!==t){const e=Math.abs(r-t);e<a&&(a=e,n=t)}}}this.#o.push({content:t,intendedTimestamp:n,originalTimestamp:t.timestamp||Date.now()})}#h(t){const e=this.#n.filter(e=>e.timestamp<=t);this.#n=this.#n.filter(e=>e.timestamp>t);const r=this.#o.filter(e=>e.intendedTimestamp+e.content.duration<=t);this.#o=this.#o.filter(e=>e.intendedTimestamp+e.content.duration>t);let i=!1;r.forEach(t=>{E(t.content),this.#s+=t.content.id.length,i=!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.#i;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);E(t)}}else if("move"===t.action){const r=t.payload,i=e.findIndex(t=>t.id===r.id);if(-1!==i){const[t]=e.splice(i,1);e.splice(r.newIndex,0,t)}}this.#c=t.timestamp,this.#s+=1,i=!0,this.emit("taskExecuted",structuredClone(t))}),i&&this.#a.clear()}#f(t){this.#r.forEach(t=>E(t)),this.#i.forEach(t=>E(t)),this.#o.forEach(t=>E(t.content)),this.#n.forEach(t=>{"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload&&E(t.payload)});const e=t=>t.map(t=>{I(t);const e=structuredClone(t);return this._ccBase64ToBlobUrl(e),e});this.#r=e(t.music),this.#i=e(t.voice),this.#s=t.seed||0,this.#c=t.anchorDate||Date.now(),this.#l={...this.#l,...t.config||{}},this.#o=t.custom.map(t=>({...t,content:e([t.content])[0]})),this.#n=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=>E(t)),this.#i.forEach(t=>E(t)),this.#o.forEach(t=>E(t.content)),this.#n.forEach(t=>{"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload&&E(t.payload)})),this.#r=[],this.#i=[],this.#o=[],this.#n=[],this.#a.clear(),this.emit("destroyed",{timestamp:Date.now()}),this.removeAllListeners(),this.#e=!0)}}const C=x}};const e={};function r(i){const o=e[i];if(void 0!==o)return o.exports;const n=e[i]={exports:{}};return t[i](n,n.exports,r),n.exports}r.d=(t,e)=>{if(Array.isArray(e))for(var i=0;i<e.length;){var o=e[i++],n=e[i++];r.o(t,o)?0===n&&i++:0===n?Object.defineProperty(t,o,{enumerable:!0,value:e[i++]}):Object.defineProperty(t,o,{enumerable:!0,get:n})}else for(var o in e)r.o(e,o)&&!r.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},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 i=r(958);window.TinyRadioFm=i.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})();
@@ -1 +1,2 @@
1
1
  .cookie-consent-bar{position:fixed;bottom:0;left:0;width:100%;background:#222;color:#fff;display:flex;justify-content:space-between;gap:10px;z-index:1000;box-shadow:0 -2px 5px rgba(0,0,0,.3);animation:tinyCookieConsentSlideUp var(--tiny-cookie-animation, 0.5s) ease forwards;transform:translateY(100%);opacity:0}.cookie-consent-bar>div{display:flex;padding-top:15px;padding-bottom:15px}.cookie-consent-bar>div:first-child{margin-left:15px;flex-grow:1}.cookie-consent-bar>div:last-child{margin-right:15px}.cookie-consent-bar>div p{margin:0}.cookie-consent-bar>div button{padding:8px 14px;border:none;cursor:pointer;border-radius:4px;transition:transform .2s ease,background .3s ease}.cookie-consent-bar>div button:hover{transform:translateY(-2px);filter:brightness(1.1)}.cookie-consent-bar>div button:active{transform:scale(0.95)}.cookie-consent-bar>div button.accept{background:#4caf50;color:#fff}.cookie-consent-bar>div button.reject{background:#f44336;color:#fff}.cookie-consent-bar>div button.settings{background:#2196f3;color:#fff}.cookie-consent-bar.closing{animation:tinyCookieConsentSlideDown var(--tiny-cookie-animation, 0.4s) ease forwards !important}@media(max-width: 600px){.cookie-consent-bar{flex-direction:column;align-items:stretch;text-align:center}.cookie-consent-bar>div{padding-top:0px;padding-bottom:0px;margin:0;justify-content:center;flex-wrap:wrap}.cookie-consent-bar>div:first-child{margin:10px 0}.cookie-consent-bar>div:last-child{margin:10px 0}.cookie-consent-bar>div button{flex:1;min-width:100px;margin:5px}}.cookie-consent-modal{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,.6);display:flex;align-items:center;justify-content:center;z-index:2000;opacity:0;animation:tinyCookieConsentFadeIn var(--tiny-cookie-animation, 0.4s) ease forwards}.cookie-consent-modal .modal-content{background:#fff;padding:20px;border-radius:8px;width:300px;transform:scale(0.9);opacity:0;animation:tinyCookieConsentScaleIn var(--tiny-cookie-animation, 0.4s) ease forwards}.cookie-consent-modal h2{margin-top:0}.cookie-consent-modal label{display:block;margin-bottom:10px}.cookie-consent-modal button.save{margin-top:15px;width:100%;background:#4caf50;color:#fff;border:none;padding:10px;cursor:pointer;border-radius:4px;transition:background .3s ease,transform .2s ease}.cookie-consent-modal button.save:hover{filter:brightness(1.1);transform:translateY(-2px)}.cookie-consent-modal button.save:active{transform:scale(0.95)}.cookie-consent-modal.closing{animation:tinyCookieConsentFadeOut var(--tiny-cookie-animation, 0.4s) ease forwards !important}.cookie-consent-modal.closing .modal-content{animation:tinyCookieConsentScaleOut var(--tiny-cookie-animation, 0.4s) ease forwards !important}@keyframes tinyCookieConsentSlideUp{to{transform:translateY(0);opacity:1}}@keyframes tinyCookieConsentSlideDown{from{transform:translateY(0%);opacity:1}to{transform:translateY(100%);opacity:0}}@keyframes tinyCookieConsentFadeIn{to{opacity:1}}@keyframes tinyCookieConsentFadeOut{from{opacity:1}to{opacity:0}}@keyframes tinyCookieConsentScaleIn{to{opacity:1;transform:scale(1)}}@keyframes tinyCookieConsentScaleOut{from{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(0.9)}}
2
+ /* # sourceMappingURL=TinyCookieConsent.min.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sourceRoot":"","sources":["../../../src/v1/scss"],"names":[],"mappings":"AACA,oBACE,eACA,SACA,OACA,WACA,gBACA,WACA,aACA,8BACA,SACA,aACA,qCAGA,oFACA,2BACA,UAEA,wBACE,aACA,iBACA,oBAEA,oCACE,iBACA,YAGF,mCACE,kBAGF,0BACE,SAGF,+BACE,iBACA,YACA,eACA,kBACA,WACE,uCAGF,qCACE,2BACA,uBAGF,sCACE,sBAIJ,sCACE,mBACA,WAGF,sCACE,mBACA,WAGF,wCACE,mBACA,WAKJ,4BACE,iGAIF,yBA7EF,oBA8EI,sBACA,oBACA,kBAEA,wBACE,gBACA,mBACA,SACA,uBACA,eAEA,oCACE,cAGF,mCACE,cAGF,+BACE,OACA,gBACA,YAOR,sBACE,eACA,MACA,OACA,QACA,SACA,0BACA,aACA,mBACA,uBACA,aACA,UACA,mFAEA,qCACE,gBACA,aACA,kBACA,YACA,qBACA,UACA,oFAGF,yBACE,aAGF,4BACE,cACA,mBAGF,kCACE,gBACA,WACA,mBACA,WACA,YACA,aACA,eACA,kBACA,WACE,uCAGF,wCACE,uBACA,2BAGF,yCACE,sBAKJ,8BACE,+FAGF,6CACE,gGAKJ,oCACE,GACE,wBACA,WAIJ,sCACE,KACE,yBACA,UAEF,GACE,2BACA,WAIJ,mCACE,GACE,WAIJ,oCACE,KACE,UAEF,GACE,WAIJ,oCACE,GACE,UACA,oBAIJ,qCACE,KACE,UACA,mBAEF,GACE,UACA","sourcesContent":["/* Consent Bar */\n.cookie-consent-bar {\n position: fixed;\n bottom: 0;\n left: 0;\n width: 100%;\n background: #222;\n color: white;\n display: flex;\n justify-content: space-between;\n gap: 10px;\n z-index: 1000;\n box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.3);\n\n /* Animation when appearing */\n animation: tinyCookieConsentSlideUp var(--tiny-cookie-animation, 0.5s) ease forwards;\n transform: translateY(100%);\n opacity: 0;\n\n > div {\n display: flex;\n padding-top: 15px;\n padding-bottom: 15px;\n\n &:first-child {\n margin-left: 15px;\n flex-grow: 1;\n }\n\n &:last-child {\n margin-right: 15px;\n }\n\n p {\n margin: 0;\n }\n\n button {\n padding: 8px 14px;\n border: none;\n cursor: pointer;\n border-radius: 4px;\n transition:\n transform 0.2s ease,\n background 0.3s ease;\n\n &:hover {\n transform: translateY(-2px);\n filter: brightness(1.1);\n }\n\n &:active {\n transform: scale(0.95);\n }\n }\n\n button.accept {\n background: #4caf50;\n color: white;\n }\n\n button.reject {\n background: #f44336;\n color: white;\n }\n\n button.settings {\n background: #2196f3;\n color: white;\n }\n }\n\n /* Exit animation */\n &.closing {\n animation: tinyCookieConsentSlideDown var(--tiny-cookie-animation, 0.4s) ease forwards !important;\n }\n\n /* Responsive behavior for small screens */\n @media (max-width: 600px) {\n flex-direction: column;\n align-items: stretch;\n text-align: center;\n\n > div {\n padding-top: 0px;\n padding-bottom: 0px;\n margin: 0;\n justify-content: center;\n flex-wrap: wrap;\n\n &:first-child {\n margin: 10px 0;\n }\n\n &:last-child {\n margin: 10px 0;\n }\n\n button {\n flex: 1;\n min-width: 100px;\n margin: 5px;\n }\n }\n }\n}\n\n/* Modal */\n.cookie-consent-modal {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.6);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 2000;\n opacity: 0;\n animation: tinyCookieConsentFadeIn var(--tiny-cookie-animation, 0.4s) ease forwards;\n\n .modal-content {\n background: white;\n padding: 20px;\n border-radius: 8px;\n width: 300px;\n transform: scale(0.9);\n opacity: 0;\n animation: tinyCookieConsentScaleIn var(--tiny-cookie-animation, 0.4s) ease forwards;\n }\n\n h2 {\n margin-top: 0;\n }\n\n label {\n display: block;\n margin-bottom: 10px;\n }\n\n button.save {\n margin-top: 15px;\n width: 100%;\n background: #4caf50;\n color: white;\n border: none;\n padding: 10px;\n cursor: pointer;\n border-radius: 4px;\n transition:\n background 0.3s ease,\n transform 0.2s ease;\n\n &:hover {\n filter: brightness(1.1);\n transform: translateY(-2px);\n }\n\n &:active {\n transform: scale(0.95);\n }\n }\n\n /* Exit animation */\n &.closing {\n animation: tinyCookieConsentFadeOut var(--tiny-cookie-animation, 0.4s) ease forwards !important;\n }\n\n &.closing .modal-content {\n animation: tinyCookieConsentScaleOut var(--tiny-cookie-animation, 0.4s) ease forwards !important;\n }\n}\n\n/* Keyframes */\n@keyframes tinyCookieConsentSlideUp {\n to {\n transform: translateY(0);\n opacity: 1;\n }\n}\n\n@keyframes tinyCookieConsentSlideDown {\n from {\n transform: translateY(0%);\n opacity: 1;\n }\n to {\n transform: translateY(100%);\n opacity: 0;\n }\n}\n\n@keyframes tinyCookieConsentFadeIn {\n to {\n opacity: 1;\n }\n}\n\n@keyframes tinyCookieConsentFadeOut {\n from {\n opacity: 1;\n }\n to {\n opacity: 0;\n }\n}\n\n@keyframes tinyCookieConsentScaleIn {\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n@keyframes tinyCookieConsentScaleOut {\n from {\n opacity: 1;\n transform: scale(1);\n }\n to {\n opacity: 0;\n transform: scale(0.9);\n }\n}\n"]}
@@ -1 +1,2 @@
1
1
  .dragging{opacity:.7;outline:2px dashed #3aa;z-index:9999}.dragging-collision{outline:2px dashed #33aa43}body.drag-active{cursor:grabbing !important}.jail-drag-active{outline:2px dashed #f90}.drag-hidden{opacity:0 !important}
2
+ /* # sourceMappingURL=TinyDraggerExample.min.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sourceRoot":"","sources":["../../../src/v1/scss"],"names":[],"mappings":"AAAA,UACE,WACA,wBACA,aAGF,oBACE,2BAGF,iBACE,2BAGF,kBACE,wBAGF,aACE","sourcesContent":[".dragging {\n opacity: 0.7;\n outline: 2px dashed #3aa;\n z-index: 9999;\n}\n\n.dragging-collision {\n outline: 2px dashed rgb(51, 170, 67);\n}\n\nbody.drag-active {\n cursor: grabbing !important;\n}\n\n.jail-drag-active {\n outline: 2px dashed #f90;\n}\n\n.drag-hidden {\n opacity: 0 !important;\n}\n"]}
@@ -1 +1,2 @@
1
1
  .loading-overlay{position:absolute;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.6);display:absolute;justify-content:center;align-items:center;z-index:9999}.loading-overlay .loading-container{height:100%;width:100%;display:flex;align-items:center}.loading-overlay .loading-content{text-align:center;color:#fff;font-family:Arial,sans-serif;margin:auto}.loading-overlay .loading-spinner{position:relative;border:4px solid rgba(255,255,255,.3);border-top:4px solid #fff;border-radius:50%;width:50px;height:50px;margin:0 auto 15px;animation:loading-spin 1s linear infinite}.loading-overlay .loading-spinner::after{content:"";position:absolute;top:50%;left:50%;width:20px;height:20px;transform:translate(-50%, -50%);border-radius:50%;background:rgba(0,0,0,0);pointer-events:none}.loading-overlay .loading-message{font-size:1.2em;user-select:none !important}@keyframes loading-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}
2
+ /* # sourceMappingURL=TinyLoadingScreen.min.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sourceRoot":"","sources":["../../../src/v1/scss"],"names":[],"mappings":"AAAA,iBACE,kBACA,MACA,OACA,WACA,YACA,0BACA,iBACA,uBACA,mBACA,aAEA,oCACE,YACA,WACA,aACA,mBAGF,kCACE,kBACA,WACA,6BACA,YAGF,kCACE,kBACA,sCACA,0BACA,kBACA,WACA,YACA,mBACA,0CAEA,yCACE,WACA,kBACA,QACA,SACA,WACA,YACA,gCACA,kBACA,yBACA,oBAIJ,kCACE,gBACA,4BAGF,wBACE,GACE,uBAEF,KACE","sourcesContent":[".loading-overlay {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.6);\n display: absolute;\n justify-content: center;\n align-items: center;\n z-index: 9999;\n\n .loading-container {\n height: 100%;\n width: 100%;\n display: flex;\n align-items: center;\n }\n\n .loading-content {\n text-align: center;\n color: #fff;\n font-family: Arial, sans-serif;\n margin: auto;\n }\n\n .loading-spinner {\n position: relative;\n border: 4px solid rgba(255, 255, 255, 0.3);\n border-top: 4px solid #fff;\n border-radius: 50%;\n width: 50px;\n height: 50px;\n margin: 0 auto 15px;\n animation: loading-spin 1s linear infinite;\n\n &::after {\n content: '';\n position: absolute;\n top: 50%;\n left: 50%;\n width: 20px; /* tamanho do “buraco” */\n height: 20px; /* tamanho do “buraco” */\n transform: translate(-50%, -50%);\n border-radius: 50%;\n background: transparent; /* vazio, mas depois pode receber ícone */\n pointer-events: none; /* não interfere no spinner */\n }\n }\n\n .loading-message {\n font-size: 1.2em;\n user-select: none !important;\n }\n\n @keyframes loading-spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n}\n"]}
@@ -1 +1,2 @@
1
1
  :root{--notify-width: clamp(280px, 90vw, 400px);--notify-spacing: 1rem;--notify-z-index: 1000;--notify-transition: opacity 0.3s ease, transform 0.3s ease;--notify-padding: 1rem;--notify-border-radius: 0.75rem;--notify-font-size: 1rem;--notify-font-family: sans-serif;--notify-color-bg: #ffffff;--notify-color-text: #333333;--notify-color-shadow: rgba(0, 0, 0, 0.1);--notify-close-size: 1.25rem;--notify-close-color: #444;--notify-close-color-hover: #000;--notif-center-remove-transition: opacity 0.3s ease, transform 0.3s ease;--notif-center-bg-transition: background 0.2s ease;--notif-center-transform: transform 0.3s ease;--notif-center-width: clamp(300px, 90vw, 400px);--notif-center-height: 100vh;--notif-center-bg: rgba(255, 255, 255, 0.85);--notif-center-blur: 12px;--notif-center-shadow: rgba(0, 0, 0, 0.2);--notif-center-x-padding: 1rem;--notif-center-y-padding: 1rem;--notif-center-z-index: 1050;--notif-border: #000;--notif-unread-border: #bd0b0b;--notif-border-unread: ;--notif-item-close: #666;--notif-item-close-hover: #000;--notif-item-bg: #ffffff;--notif-item-unread-bg: #ffffff;--notif-item-text: #222;--notif-item-radius: 0.75rem;--notif-item-padding: 1rem;--notif-item-shadow: rgba(0, 0, 0, 0.1);--notif-close-size: 1.5rem;--notif-close-color: #444;--notif-close-color-hover: #000;--notif-bell-size: 3rem;--notif-bell-bg: #ffffff;--notif-bell-color: #333;--notif-bell-shadow: rgba(0, 0, 0, 0.2);--notif-bell-z-index: 1040;--notif-bell-radius: 50%;--notif-bell-hover-bg: #f0f0f0;--notif-badge-bg: #d32f2f;--notif-badge-color: #ffffff;--notif-badge-size: 1.25rem;--notif-badge-font-size: 0.75rem;--notif-badge-border: none}.notify-container{position:fixed;display:flex;gap:var(--notify-spacing);width:var(--notify-width);z-index:var(--notify-z-index);pointer-events:none}.notify-container.left{left:var(--notify-spacing);align-items:flex-start}.notify-container.right{right:var(--notify-spacing);align-items:flex-end}.notify-container.center{left:50%;transform:translateX(-50%);align-items:center}.notify-container.top{flex-direction:column;top:var(--notify-spacing)}.notify-container.top .notify.enter{transform:translateY(-10px)}.notify-container.top .notify.exit{transform:translateY(-10px)}.notify-container.bottom{flex-direction:column-reverse;bottom:var(--notify-spacing)}.notify-container.bottom .notify.enter{transform:translateY(10px)}.notify-container.bottom .notify.exit{transform:translateY(10px)}.notify-container .notify{position:relative;background-color:var(--notify-color-bg);color:var(--notify-color-text);box-shadow:0 4px 8px var(--notify-color-shadow);border-radius:var(--notify-border-radius);padding:var(--notify-padding);font-size:var(--notify-font-size);font-family:var(--notify-font-family);width:100%;pointer-events:auto;transition:var(--notify-transition);opacity:1}.notify-container .notify .avatar{width:2rem;height:2rem;border-radius:50%;object-fit:cover;float:left;margin-right:.5rem}.notify-container .notify .close{position:absolute;top:.5rem;right:.75rem;background:rgba(0,0,0,0);border:none;font-size:var(--notify-close-size);cursor:pointer;line-height:1;color:var(--notify-close-color);padding:0;margin:0}.notify-container .notify .close:hover{color:var(--notify-close-color-hover)}.notify-container .notify.clickable{cursor:pointer}.notify-container .notify.clickable:hover{background-color:var(--notify-color-bg-hover, rgba(0, 0, 0, 0.05))}.notify-container .notify.enter{opacity:0}.notify-container .notify.show{opacity:1;transform:translateY(0)}.notify-container .notify.exit{opacity:0}.notify-overlay{position:fixed;inset:0;background-color:rgba(0,0,0,.35);display:flex;justify-content:flex-end;align-items:flex-start;padding:1rem;z-index:var(--notif-center-z-index);transition:var(--notif-center-bg-transition)}.notify-overlay.hidden{background-color:rgba(0,0,0,0);pointer-events:none}.notify-overlay .notify-center{position:fixed;top:0;right:0;width:var(--notif-center-width);height:var(--notif-center-height);background-color:var(--notif-center-bg);backdrop-filter:blur(var(--notif-center-blur));box-shadow:-4px 0 12px var(--notif-center-shadow);padding-top:var(--notif-center-y-padding);padding-bottom:var(--notif-center-y-padding);padding-left:var(--notif-center-x-padding);padding-right:var(--notif-center-x-padding);display:flex;flex-direction:column;z-index:var(--notif-center-z-index);transform:translateX(100%);transition:var(--notif-center-transform)}.notify-overlay .notify-center.open{transform:translateX(0%)}.notify-overlay .notify-center .header{display:flex;justify-content:space-between;align-items:center}.notify-overlay .notify-center .options{display:flex}.notify-overlay .notify-center .options>button{background:none;border:none;font-size:var(--notif-close-size);color:var(--notif-close-color);cursor:pointer}.notify-overlay .notify-center .options>button>svg{align-items:center;display:flex}.notify-overlay .notify-center .options>button:hover{color:var(--notif-close-color-hover)}.notify-overlay .notify-center .list{flex:1;overflow-y:auto;display:flex;flex-direction:column;gap:1rem;scrollbar-width:thin;scrollbar-color:#999 rgba(0,0,0,0)}.notify-overlay .notify-center .list::-webkit-scrollbar{width:6px}.notify-overlay .notify-center .list::-webkit-scrollbar-thumb{background:#aaa;border-radius:3px}.notify-overlay .notify-center .item{display:flex;justify-content:space-between;align-items:flex-start;background-color:var(--notif-item-bg);color:var(--notif-item-text);border-radius:var(--notif-item-radius);padding:var(--notif-item-padding);box-shadow:0 2px 6px var(--notif-item-shadow);font-size:.95rem;transition:var(--notif-center-remove-transition);border-left-style:solid;border-left-color:var(--notif-border)}.notify-overlay .notify-center .item .avatar{width:40px;height:40px;flex-shrink:0;border-radius:50%;background-size:cover;background-position:center;margin-right:10px}.notify-overlay .notify-center .item.unread{background-color:var(--notif-item-unread-bg);border-left-color:var(--notif-unread-border)}.notify-overlay .notify-center .item.removing{opacity:0;transform:translateY(-10px);pointer-events:none !important}.notify-overlay .notify-center .item.clickable{cursor:pointer}.notify-overlay .notify-center .item.clickable:hover{background-color:var(--notif-hover, rgba(0, 0, 0, 0.05))}.notify-overlay .notify-center .item .content{flex-grow:1;display:flex;flex-direction:column}.notify-overlay .notify-center .item .title{font-weight:bold;margin-bottom:.25rem}.notify-overlay .notify-center .item .message{font-size:.95rem}.notify-overlay .notify-center .item .notify-close{background:none;border:none;font-size:1.25rem;line-height:1;color:var(--notif-item-close);cursor:pointer;padding:.25rem}.notify-overlay .notify-center .item .notify-close:hover{color:var(--notif-item-close-hover)}@media(max-width: 600px){.notify-center{border-radius:0;width:100vw;padding:0px !important}.notify-center .header{padding-top:var(--notif-center-y-padding)}.notify-center .header,.notify-center .list{padding-left:var(--notif-center-x-padding);padding-right:var(--notif-center-x-padding)}}.notify-bell{position:fixed;bottom:1.5rem;right:1.5rem;width:var(--notif-bell-size);height:var(--notif-bell-size);background-color:var(--notif-bell-bg);color:var(--notif-bell-color);border:none;border-radius:var(--notif-bell-radius);box-shadow:0 4px 8px var(--notif-bell-shadow);display:flex;align-items:center;justify-content:center;cursor:pointer;z-index:var(--notif-bell-z-index);font-size:1.4rem;transition:var(--notif-center-bg-transition)}.notify-bell:hover{background-color:var(--notif-bell-hover-bg)}.notify-bell .badge{position:absolute;top:0;right:0;transform:translate(25%, -25%);background-color:var(--notif-badge-bg);color:var(--notif-badge-color);border:var(--notif-badge-border);border-radius:999px;min-width:var(--notif-badge-size);height:var(--notif-badge-size);font-size:var(--notif-badge-font-size);font-weight:bold;display:flex;align-items:center;justify-content:center;padding:0 .3em;pointer-events:none}.notify-bell .badge[data-value="0"]{display:none}
2
+ /* # sourceMappingURL=TinyNotify.min.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sourceRoot":"","sources":["../../../src/v1/scss"],"names":[],"mappings":"AAAA,MAEE,0CACA,uBACA,uBACA,4DAEA,uBACA,gCACA,yBACA,iCAEA,2BACA,6BACA,0CAEA,6BACA,2BACA,iCAGA,yEACA,mDACA,8CACA,gDACA,6BACA,6CACA,0BACA,0CAEA,+BACA,+BACA,6BAEA,qBACA,+BACA,wBACA,yBACA,+BACA,yBACA,gCACA,wBACA,6BACA,2BACA,wCAEA,2BACA,0BACA,gCAGA,wBACA,yBACA,yBACA,wCACA,2BACA,yBACA,+BAGA,0BACA,6BACA,4BACA,iCACA,2BAKF,kBACE,eACA,aACA,0BACA,0BACA,8BACA,oBAGA,uBACE,2BACA,uBAGF,wBACE,4BACA,qBAGF,yBACE,SACA,2BACA,mBAIF,sBACE,sBACA,0BAGE,oCACE,4BAGF,mCACE,4BAKN,yBACE,8BACA,6BAGE,uCACE,2BAGF,sCACE,2BAKN,0BACE,kBACA,wCACA,+BACA,gDACA,0CACA,8BACA,kCACA,sCACA,WACA,oBACA,oCACA,UAEA,kCACE,WACA,YACA,kBACA,iBACA,WACA,mBAGF,iCACE,kBACA,UACA,aACA,yBACA,YACA,mCACA,eACA,cACA,gCACA,UACA,SAEA,uCACE,sCAIJ,oCACE,eAGF,0CACE,mEAIF,gCACE,UAGF,+BACE,UACA,wBAGF,+BACE,UAON,gBACE,eACA,QACA,iCACA,aACA,yBACA,uBACA,aACA,oCACA,6CAEA,uBACE,+BACA,oBAGF,+BACE,eACA,MACA,QACA,gCACA,kCACA,wCACA,+CACA,kDACA,0CACA,6CACA,2CACA,4CACA,aACA,sBACA,oCACA,2BACA,yCAEA,oCACE,yBAGF,uCACE,aACA,8BACA,mBAGF,wCACE,aAEA,+CACE,gBACA,YACA,kCACA,+BACA,eACA,mDACE,mBACA,aAEF,qDACE,qCAKN,qCACE,OACA,gBACA,aACA,sBACA,SACA,qBACA,mCAEA,wDACE,UAGF,8DACE,gBACA,kBAIJ,qCACE,aACA,8BACA,uBACA,sCACA,6BACA,uCACA,kCACA,8CACA,iBACA,iDACA,wBACA,sCAEA,6CACE,WACA,YACA,cACA,kBACA,sBACA,2BACA,kBAGF,4CACE,6CACA,6CAGF,8CACE,UACA,4BACA,+BAGF,+CACE,eAGF,qDACE,yDAGF,8CACE,YACA,aACA,sBAGF,4CACE,iBACA,qBAGF,8CACE,iBAGF,mDACE,gBACA,YACA,kBACA,cACA,8BACA,eACA,eAEA,yDACE,oCAOV,yBACE,eACE,gBACA,YACA,uBAEA,uBACE,0CAGF,4CAEE,2CACA,6CAON,aACE,eACA,cACA,aACA,6BACA,8BACA,sCACA,8BACA,YACA,uCACA,8CACA,aACA,mBACA,uBACA,eACA,kCACA,iBACA,6CAEA,mBACE,4CAGF,oBACE,kBACA,MACA,QACA,+BACA,uCACA,+BACA,iCACA,oBACA,kCACA,+BACA,uCACA,iBACA,aACA,mBACA,uBACA,eACA,oBAEA,oCACE","sourcesContent":[":root {\n // Notify\n --notify-width: clamp(280px, 90vw, 400px);\n --notify-spacing: 1rem;\n --notify-z-index: 1000;\n --notify-transition: opacity 0.3s ease, transform 0.3s ease;\n\n --notify-padding: 1rem;\n --notify-border-radius: 0.75rem;\n --notify-font-size: 1rem;\n --notify-font-family: sans-serif;\n\n --notify-color-bg: #ffffff;\n --notify-color-text: #333333;\n --notify-color-shadow: rgba(0, 0, 0, 0.1);\n\n --notify-close-size: 1.25rem;\n --notify-close-color: #444;\n --notify-close-color-hover: #000;\n\n // Notif Center\n --notif-center-remove-transition: opacity 0.3s ease, transform 0.3s ease;\n --notif-center-bg-transition: background 0.2s ease;\n --notif-center-transform: transform 0.3s ease;\n --notif-center-width: clamp(300px, 90vw, 400px);\n --notif-center-height: 100vh;\n --notif-center-bg: rgba(255, 255, 255, 0.85);\n --notif-center-blur: 12px;\n --notif-center-shadow: rgba(0, 0, 0, 0.2);\n\n --notif-center-x-padding: 1rem;\n --notif-center-y-padding: 1rem;\n --notif-center-z-index: 1050;\n\n --notif-border: #000;\n --notif-unread-border: #bd0b0b;\n --notif-border-unread: ;\n --notif-item-close: #666;\n --notif-item-close-hover: #000;\n --notif-item-bg: #ffffff;\n --notif-item-unread-bg: #ffffff;\n --notif-item-text: #222;\n --notif-item-radius: 0.75rem;\n --notif-item-padding: 1rem;\n --notif-item-shadow: rgba(0, 0, 0, 0.1);\n\n --notif-close-size: 1.5rem;\n --notif-close-color: #444;\n --notif-close-color-hover: #000;\n\n // Bell\n --notif-bell-size: 3rem;\n --notif-bell-bg: #ffffff;\n --notif-bell-color: #333;\n --notif-bell-shadow: rgba(0, 0, 0, 0.2);\n --notif-bell-z-index: 1040;\n --notif-bell-radius: 50%;\n --notif-bell-hover-bg: #f0f0f0;\n\n // Badge\n --notif-badge-bg: #d32f2f;\n --notif-badge-color: #ffffff;\n --notif-badge-size: 1.25rem;\n --notif-badge-font-size: 0.75rem;\n --notif-badge-border: none;\n}\n\n/* Notification container */\n\n.notify-container {\n position: fixed;\n display: flex;\n gap: var(--notify-spacing);\n width: var(--notify-width);\n z-index: var(--notify-z-index);\n pointer-events: none; // prevents click on container\n\n // Horizontal position\n &.left {\n left: var(--notify-spacing);\n align-items: flex-start;\n }\n\n &.right {\n right: var(--notify-spacing);\n align-items: flex-end;\n }\n\n &.center {\n left: 50%;\n transform: translateX(-50%);\n align-items: center;\n }\n\n // Vertical position\n &.top {\n flex-direction: column;\n top: var(--notify-spacing);\n\n .notify {\n &.enter {\n transform: translateY(-10px); // vem de cima\n }\n\n &.exit {\n transform: translateY(-10px); // sai para cima\n }\n }\n }\n\n &.bottom {\n flex-direction: column-reverse;\n bottom: var(--notify-spacing);\n\n .notify {\n &.enter {\n transform: translateY(10px); // vem de baixo\n }\n\n &.exit {\n transform: translateY(10px); // sai para baixo\n }\n }\n }\n\n .notify {\n position: relative;\n background-color: var(--notify-color-bg);\n color: var(--notify-color-text);\n box-shadow: 0 4px 8px var(--notify-color-shadow);\n border-radius: var(--notify-border-radius);\n padding: var(--notify-padding);\n font-size: var(--notify-font-size);\n font-family: var(--notify-font-family);\n width: 100%;\n pointer-events: auto; // allows individual click\n transition: var(--notify-transition);\n opacity: 1;\n\n .avatar {\n width: 2rem;\n height: 2rem;\n border-radius: 50%;\n object-fit: cover;\n float: left;\n margin-right: 0.5rem;\n }\n\n .close {\n position: absolute;\n top: 0.5rem;\n right: 0.75rem;\n background: transparent;\n border: none;\n font-size: var(--notify-close-size);\n cursor: pointer;\n line-height: 1;\n color: var(--notify-close-color);\n padding: 0;\n margin: 0;\n\n &:hover {\n color: var(--notify-close-color-hover);\n }\n }\n\n &.clickable {\n cursor: pointer;\n }\n\n &.clickable:hover {\n background-color: var(--notify-color-bg-hover, rgba(0, 0, 0, 0.05));\n }\n\n // Input/output animations (optional)\n &.enter {\n opacity: 0;\n }\n\n &.show {\n opacity: 1;\n transform: translateY(0);\n }\n\n &.exit {\n opacity: 0;\n }\n }\n}\n\n/* Notification center */\n\n.notify-overlay {\n position: fixed;\n inset: 0;\n background-color: rgba(0, 0, 0, 0.35);\n display: flex;\n justify-content: flex-end;\n align-items: flex-start;\n padding: 1rem;\n z-index: var(--notif-center-z-index);\n transition: var(--notif-center-bg-transition);\n\n &.hidden {\n background-color: transparent;\n pointer-events: none;\n }\n\n .notify-center {\n position: fixed;\n top: 0;\n right: 0;\n width: var(--notif-center-width);\n height: var(--notif-center-height);\n background-color: var(--notif-center-bg);\n backdrop-filter: blur(var(--notif-center-blur));\n box-shadow: -4px 0 12px var(--notif-center-shadow);\n padding-top: var(--notif-center-y-padding);\n padding-bottom: var(--notif-center-y-padding);\n padding-left: var(--notif-center-x-padding);\n padding-right: var(--notif-center-x-padding);\n display: flex;\n flex-direction: column;\n z-index: var(--notif-center-z-index);\n transform: translateX(100%);\n transition: var(--notif-center-transform);\n\n &.open {\n transform: translateX(0%);\n }\n\n .header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n\n .options {\n display: flex;\n\n > button {\n background: none;\n border: none;\n font-size: var(--notif-close-size);\n color: var(--notif-close-color);\n cursor: pointer;\n > svg {\n align-items: center;\n display: flex;\n }\n &:hover {\n color: var(--notif-close-color-hover);\n }\n }\n }\n\n .list {\n flex: 1;\n overflow-y: auto;\n display: flex;\n flex-direction: column;\n gap: 1rem;\n scrollbar-width: thin;\n scrollbar-color: #999 transparent;\n\n &::-webkit-scrollbar {\n width: 6px;\n }\n\n &::-webkit-scrollbar-thumb {\n background: #aaa;\n border-radius: 3px;\n }\n }\n\n .item {\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n background-color: var(--notif-item-bg);\n color: var(--notif-item-text);\n border-radius: var(--notif-item-radius);\n padding: var(--notif-item-padding);\n box-shadow: 0 2px 6px var(--notif-item-shadow);\n font-size: 0.95rem;\n transition: var(--notif-center-remove-transition);\n border-left-style: solid;\n border-left-color: var(--notif-border);\n\n .avatar {\n width: 40px;\n height: 40px;\n flex-shrink: 0;\n border-radius: 50%;\n background-size: cover;\n background-position: center;\n margin-right: 10px;\n }\n\n &.unread {\n background-color: var(--notif-item-unread-bg);\n border-left-color: var(--notif-unread-border);\n }\n\n &.removing {\n opacity: 0;\n transform: translateY(-10px);\n pointer-events: none !important;\n }\n\n &.clickable {\n cursor: pointer;\n }\n\n &.clickable:hover {\n background-color: var(--notif-hover, rgba(0, 0, 0, 0.05));\n }\n\n .content {\n flex-grow: 1;\n display: flex;\n flex-direction: column;\n }\n\n .title {\n font-weight: bold;\n margin-bottom: 0.25rem;\n }\n\n .message {\n font-size: 0.95rem;\n }\n\n .notify-close {\n background: none;\n border: none;\n font-size: 1.25rem;\n line-height: 1;\n color: var(--notif-item-close);\n cursor: pointer;\n padding: 0.25rem;\n\n &:hover {\n color: var(--notif-item-close-hover);\n }\n }\n }\n }\n}\n\n@media (max-width: 600px) {\n .notify-center {\n border-radius: 0;\n width: 100vw;\n padding: 0px !important;\n\n .header {\n padding-top: var(--notif-center-y-padding);\n }\n\n .header,\n .list {\n padding-left: var(--notif-center-x-padding);\n padding-right: var(--notif-center-x-padding);\n }\n }\n}\n\n/* Notification bell */\n\n.notify-bell {\n position: fixed;\n bottom: 1.5rem;\n right: 1.5rem;\n width: var(--notif-bell-size);\n height: var(--notif-bell-size);\n background-color: var(--notif-bell-bg);\n color: var(--notif-bell-color);\n border: none;\n border-radius: var(--notif-bell-radius);\n box-shadow: 0 4px 8px var(--notif-bell-shadow);\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n z-index: var(--notif-bell-z-index);\n font-size: 1.4rem;\n transition: var(--notif-center-bg-transition);\n\n &:hover {\n background-color: var(--notif-bell-hover-bg);\n }\n\n .badge {\n position: absolute;\n top: 0;\n right: 0;\n transform: translate(25%, -25%);\n background-color: var(--notif-badge-bg);\n color: var(--notif-badge-color);\n border: var(--notif-badge-border);\n border-radius: 999px;\n min-width: var(--notif-badge-size);\n height: var(--notif-badge-size);\n font-size: var(--notif-badge-font-size);\n font-weight: bold;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0 0.3em;\n pointer-events: none;\n\n &[data-value='0'] {\n display: none;\n }\n }\n}\n"]}
@@ -1 +1,2 @@
1
1
  :root{--ai-text-color: yellow;--semi-ai-text-color: deepskyblue;--ai-text-shadow-color: #000}ai,semi-ai{display:inline}body.detect-made-by-ai .made-by-ai,body.detect-made-by-ai .made-by-semi-ai,body.detect-made-by-ai ai,body.detect-made-by-ai semi-ai{text-shadow:-1px -1px 0 var(--ai-text-shadow-color),1px -1px 0 var(--ai-text-shadow-color),-1px 1px 0 var(--ai-text-shadow-color),1px 1px 0 var(--ai-text-shadow-color)}body.detect-made-by-ai .made-by-ai,body.detect-made-by-ai ai{color:var(--ai-text-color)}body.detect-made-by-ai .made-by-semi-ai,body.detect-made-by-ai semi-ai{color:var(--semi-ai-text-color)}
2
+ /* # sourceMappingURL=aiMarker.min.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sourceRoot":"","sources":["../../../src/v1/scss"],"names":[],"mappings":"AAAA,MACE,wBACA,kCACA,6BAGF,WAEE,eAIA,oIAIE,YACE,4JAMJ,6DAEE,2BAEF,uEAEE","sourcesContent":[":root {\n --ai-text-color: yellow;\n --semi-ai-text-color: deepskyblue;\n --ai-text-shadow-color: #000;\n}\n\nai,\nsemi-ai {\n display: inline;\n}\n\nbody.detect-made-by-ai {\n .made-by-ai,\n .made-by-semi-ai,\n ai,\n semi-ai {\n text-shadow:\n -1px -1px 0 var(--ai-text-shadow-color),\n 1px -1px 0 var(--ai-text-shadow-color),\n -1px 1px 0 var(--ai-text-shadow-color),\n 1px 1px 0 var(--ai-text-shadow-color);\n }\n\n .made-by-ai,\n ai {\n color: var(--ai-text-color);\n }\n .made-by-semi-ai,\n semi-ai {\n color: var(--semi-ai-text-color);\n }\n}\n"]}
@@ -4,6 +4,7 @@ var events = require('events');
4
4
  var mediaContent = require('../../basics/mediaContent.cjs');
5
5
  var tools = require('../utils/tools.cjs');
6
6
  var objChecker = require('../../basics/objChecker.cjs');
7
+ var TinyAdvancedRaffle = require('../math/TinyAdvancedRaffle.cjs');
7
8
 
8
9
  const checkDestroy = tools.createCheckDestroyed('TinyRadioFm');
9
10
 
@@ -85,12 +86,13 @@ const checkDestroy = tools.createCheckDestroyed('TinyRadioFm');
85
86
  * @property {number} silenceDuration - Gap in ms between tracks.
86
87
  * @property {number} queryLimit - Safety lock for max items processed.
87
88
  * @property {boolean} voiceAfterMusic - Whether to play voice messages after music tracks.
89
+ * @property {number} voiceWeight - Weight used to calculate the probability of a voice block occurring.
88
90
  * @property {number} voiceMin - Minimum amount of voice messages to play if voiceAfterMusic is true.
89
91
  * @property {number} voiceMax - Maximum amount of voice messages to play.
90
92
  * @property {number} musicMaxConsecutive - Max times a music track can repeat consecutively (-1 = unlimited, 0 = strictly no repetition).
91
93
  * @property {number} musicMinConsecutive - Min times a music track must repeat consecutively (1 = no mandatory repetition).
92
94
  * @property {number} voiceMaxConsecutive - Max times a voice track can repeat consecutively (-1 = unlimited, 0 = strictly no repetition).
93
- * @property {number} voiceMinConsecutive - Min times a voice track must repeat consecutively (1 = no mandatory repetition).
95
+ * @property {number} voiceMinConsecutive - Min times a voice track can repeat consecutively (1 = no mandatory repetition).
94
96
  */
95
97
 
96
98
  //////////////////////////////////////////////////////////////////
@@ -358,6 +360,7 @@ class TinyRadioFm extends events.EventEmitter {
358
360
  voiceAfterMusic: true,
359
361
  voiceMin: 0,
360
362
  voiceMax: 1,
363
+ voiceWeight: 1,
361
364
  musicMaxConsecutive: 0,
362
365
  musicMinConsecutive: 0,
363
366
  voiceMaxConsecutive: 0,
@@ -435,6 +438,7 @@ class TinyRadioFm extends events.EventEmitter {
435
438
  }
436
439
  };
437
440
 
441
+ checkRange(config.voiceWeight, 'voiceWeight');
438
442
  checkRange(config.voiceMin, 'voiceMin');
439
443
  checkRange(config.voiceMax, 'voiceMax');
440
444
  checkRange(config.musicMinConsecutive, 'musicMinConsecutive');
@@ -992,11 +996,6 @@ class TinyRadioFm extends events.EventEmitter {
992
996
  };
993
997
  }
994
998
 
995
- /**
996
- * Pool of available items for weighted selection.
997
- * @type {Array<MediaContent & { weight: number }>}
998
- */
999
- const pool = list.map((item) => ({ ...item, weight: item.weight ?? 1 }));
1000
999
  const random = this._prng(currentSeed);
1001
1000
 
1002
1001
  /**
@@ -1009,6 +1008,30 @@ class TinyRadioFm extends events.EventEmitter {
1009
1008
  let lastId = initialLastId;
1010
1009
  let consecutiveCount = initialConsecutiveCount;
1011
1010
 
1011
+ // Initializes TinyAdvancedRaffle specifically for this sequence generation
1012
+ const raffle = new TinyAdvancedRaffle({
1013
+ rng: random,
1014
+ normalization: 'relative',
1015
+ });
1016
+
1017
+ // We keep the pool as an array to respect the original structure and support possible
1018
+ // duplicate IDs, if they occur (even though it is rare).
1019
+
1020
+ /** @type {MediaContent[]} */
1021
+ const pool = [...list];
1022
+
1023
+ // Registers all items in the Raffle system
1024
+ pool.forEach((item) => {
1025
+ const itemWeight = item.weight ?? 1;
1026
+ const existing = raffle.getItem(item.id);
1027
+ if (!existing) {
1028
+ raffle.addItem(item.id, { weight: itemWeight });
1029
+ } else {
1030
+ // If the ID already exists, we add its weight to maintain the correct proportion
1031
+ raffle.setBaseWeight(item.id, existing.baseWeight + itemWeight);
1032
+ }
1033
+ });
1034
+
1012
1035
  while (pool.length > 0) {
1013
1036
  /** @type {MediaContent|null} */
1014
1037
  let selectedItem = null;
@@ -1026,35 +1049,32 @@ class TinyRadioFm extends events.EventEmitter {
1026
1049
  }
1027
1050
  }
1028
1051
 
1029
- // 2. Maximum repetition logic and random draw
1052
+ // 2. Maximum repetition logic and drawing using the Raffle
1030
1053
  if (!selectedItem) {
1031
- let validPool = pool;
1054
+ let excludedId = null;
1032
1055
 
1033
1056
  if (lastId !== null && maxConsecutive !== -1 && consecutiveCount >= maxConsecutive) {
1034
- validPool = pool.filter((item) => item.id !== lastId);
1035
- }
1036
-
1037
- if (validPool.length === 0) {
1038
- validPool = pool;
1057
+ // Checks if there are other different items in the pool before preventing the last one
1058
+ const hasOtherItems = pool.some((item) => item.id !== lastId);
1059
+ if (hasOtherItems) {
1060
+ raffle.excludeItem(lastId);
1061
+ excludedId = lastId;
1062
+ }
1039
1063
  }
1040
1064
 
1041
- const totalWeight = validPool.reduce((sum, item) => sum + item.weight, 0);
1065
+ const drawResult = raffle.drawOne();
1042
1066
 
1043
- if (totalWeight <= 0) {
1044
- selectedItem = validPool[0];
1045
- selectedIndex = pool.findIndex((p) => p.id === selectedItem?.id);
1046
- } else {
1047
- const r = random() * totalWeight;
1048
- let sum = 0;
1049
- for (let i = 0; i < validPool.length; i++) {
1050
- sum += validPool[i].weight;
1051
- if (r <= sum) {
1052
- selectedItem = validPool[i];
1053
- selectedIndex = pool.findIndex((p) => p.id === selectedItem?.id);
1054
- break;
1055
- }
1067
+ if (drawResult) {
1068
+ selectedIndex = pool.findIndex((item) => item.id === drawResult.id);
1069
+ if (selectedIndex !== -1) {
1070
+ selectedItem = pool[selectedIndex];
1056
1071
  }
1057
1072
  }
1073
+
1074
+ // Removes the exclusion to avoid breaking future draws
1075
+ if (excludedId) {
1076
+ raffle.includeItem(excludedId);
1077
+ }
1058
1078
  }
1059
1079
 
1060
1080
  // Safety fallback
@@ -1065,8 +1085,23 @@ class TinyRadioFm extends events.EventEmitter {
1065
1085
 
1066
1086
  sequence.push(selectedItem);
1067
1087
 
1088
+ // Updates the pool and the Raffle after the item has been drawn and used
1068
1089
  if (selectedIndex !== -1) {
1069
1090
  pool.splice(selectedIndex, 1);
1091
+
1092
+ // If this item is no longer in the pool permanently, remove it from the Raffle
1093
+ const stillInPool = pool.some((item) => item.id === selectedItem.id);
1094
+ if (!stillInPool) {
1095
+ raffle.removeItem(selectedItem.id);
1096
+ } else {
1097
+ // If it still exists, we reduce the weight proportionally to continue the draw fairly
1098
+ const existing = raffle.getItem(selectedItem.id);
1099
+ if (existing) {
1100
+ const newWeight = Math.max(0, existing.baseWeight - (selectedItem.weight ?? 1));
1101
+ if (newWeight <= 0) raffle.removeItem(selectedItem.id);
1102
+ else raffle.setBaseWeight(selectedItem.id, newWeight);
1103
+ }
1104
+ }
1070
1105
  }
1071
1106
 
1072
1107
  if (selectedItem.id === lastId) {
@@ -1077,6 +1112,8 @@ class TinyRadioFm extends events.EventEmitter {
1077
1112
  }
1078
1113
  }
1079
1114
 
1115
+ raffle.destroy(); // Ensures memory is cleared at the end of each cycle
1116
+
1080
1117
  return { items: sequence, lastId, consecutiveCount };
1081
1118
  }
1082
1119
 
@@ -1146,19 +1183,25 @@ class TinyRadioFm extends events.EventEmitter {
1146
1183
  cycleDuration += music.duration + this.#config.silenceDuration;
1147
1184
 
1148
1185
  if (this.#config.voiceAfterMusic && voiceSeq.length > 0) {
1149
- const range = this.#config.voiceMax - this.#config.voiceMin + 1;
1150
- const voiceAmount = Math.floor(mixRandom() * range) + this.#config.voiceMin;
1151
-
1152
- for (let v = 0; v < voiceAmount; v++) {
1153
- const voice = voiceSeq[voiceCursor % voiceSeq.length];
1154
- voiceCursor++;
1155
-
1156
- block.push({
1157
- ...voice,
1158
- cycleStart: cycleDuration,
1159
- cycleEnd: cycleDuration + voice.duration,
1160
- });
1161
- cycleDuration += voice.duration + this.#config.silenceDuration;
1186
+ // Calculate chance based on weight: P = W / (W + 1)
1187
+ const voiceChance = this.#config.voiceWeight / (this.#config.voiceWeight + 1);
1188
+
1189
+ // Only proceed if the random roll is less than the calculated chance
1190
+ if (mixRandom() < voiceChance) {
1191
+ const range = this.#config.voiceMax - this.#config.voiceMin + 1;
1192
+ const voiceAmount = Math.floor(mixRandom() * range) + this.#config.voiceMin;
1193
+
1194
+ for (let v = 0; v < voiceAmount; v++) {
1195
+ const voice = voiceSeq[voiceCursor % voiceSeq.length];
1196
+ voiceCursor++;
1197
+
1198
+ block.push({
1199
+ ...voice,
1200
+ cycleStart: cycleDuration,
1201
+ cycleEnd: cycleDuration + voice.duration,
1202
+ });
1203
+ cycleDuration += voice.duration + this.#config.silenceDuration;
1204
+ }
1162
1205
  }
1163
1206
  }
1164
1207
  }