import{I as h}from"./ItemsListing-08846369.js";import{d as v,a5 as g,r as p,s as u,o as I,b as a,a7 as n,a as w,c as T,e as D,M as c,ac as E}from"./index-a1b8d248.js";import{s as l}from"./VCheckbox-5797eb11.js";import"./eventbus-142801ce.js";import"./VListItem-99589506.js";import"./ListItem-8ce3726a.js";import"./Button-36db0a16.js";import"./_plugin-vue_export-helper-c27b6911.js";import"./VMenu-a4b04473.js";import"./VCard-62364c90.js";import"./VCardText-426e9876.js";import"./VSpacer-c665d1ef.js";/* empty css              */import"./PanelviewItemCompact-412c96c5.js";import"./VAlert-11c8d9d0.js";import"./Container-6ba8cd4d.js";import"./Toolbar-e7daca02.js";import"./VList-db9ad95c.js";import"./VToolbar-69b0039c.js";import"./VTextField-11675678.js";import"./VCheckboxBtn-b34ea085.js";import"./VInfiniteScroll-b88bd748.js";import"./layout-2c6f8b0d.js";import"./VVirtualScroll-abd3c2c6.js";const X=v({name:"Radios",__name:"LibraryRadios",setup(M){const{t:o}=g(),s=p(!1),r=p(u.libraryRadiosCount),_=["name","name_desc","sort_name","sort_name_desc","timestamp_added","timestamp_added_desc","last_played","last_played_desc","play_count","play_count_desc"];I(()=>{const t=a.subscribe_multi([n.MEDIA_ITEM_ADDED,n.MEDIA_ITEM_UPDATED,n.MEDIA_ITEM_DELETED],e=>{var i;(i=e.object_id)!=null&&i.startsWith("library://radio")&&(s.value=!0)});w(t)});const y=async function(t){if(t.refresh&&!s.value){for(a.startSync([c.RADIO]),await l(250);a.syncTasks.value.length>0&&a.syncTasks.value.filter(e=>e.media_types.includes(c.RADIO)).length!=0;)await l(500);await l(500)}return s.value=!1,f(t),await a.getLibraryRadios(t.favoritesOnly||void 0,t.search,t.limit,t.offset,t.sortBy)},f=async function(t){if(!t.favoritesOnly){r.value=u.libraryRadiosCount;return}r.value=await a.getLibraryRadiosCount(t.favoritesOnly||!1)},b=async function(){const t=prompt(o("enter_url"));if(t){if(!(t!=null&&t.startsWith("http"))){alert(o("invalid_input"));return}a.getRadio(t,"builtin").then(e=>{var d;const i=prompt(o("enter_name"),e.name);e.name=i||e.name,delete e.sort_name;const m=prompt(o("image_url"),(d=e.metadata.images)!=null&&d.length?e.metadata.images[0].path:"");m&&(e.metadata.images=[{type:E.THUMB,path:m,provider:"builtin",remotely_accessible:!0}]),a.addItemToLibrary(e).then(()=>window.location.reload())}).catch(e=>alert(e))}};return(t,e)=>(T(),D(h,{itemtype:"radios","show-duration":!1,"show-provider":!1,"show-favorites-only-filter":!0,"load-paged-data":y,"sort-keys":_,"update-available":s.value,title:t.$t("radios"),"show-search-button":!0,"allow-key-hooks":!0,"extra-menu-items":[{label:"add_url_item",labelArgs:[],action:()=>{b()},icon:"mdi-playlist-plus"}],icon:"mdi-access-point","restore-state":!0,total:r.value},null,8,["update-available","title","extra-menu-items","total"]))}});export{X as default};
