import{I as f}from"./ItemsListing-2b5a8c5f.js";import{d as h,a6 as b,r as u,s as v,o as g,b as a,a8 as i,a as I,c as D,e as E,M as n,ap as l,ah as T,V as w}from"./index-894ae36a.js";import"./VCheckbox-4fd4d9b8.js";import"./eventbus-f225a5d6.js";import"./VListItem-4174a915.js";import"./VCheckboxBtn-24370bba.js";import"./VList-48dd7d0f.js";import"./VCardText-f53aa54e.js";import"./VCard-3391db98.js";import"./VMenu-6b993280.js";import"./_plugin-vue_export-helper-c27b6911.js";import"./ListItem-8a38a33e.js";import"./Button-f6514084.js";import"./VSpacer-46dc65f8.js";/* empty css              */import"./PanelviewItemCompact-b99e3c0c.js";import"./VAlert-a768baba.js";import"./Container-0e8820c0.js";import"./Toolbar-43508ce0.js";import"./VToolbar-92b7b4d6.js";import"./VTextField-d7aa64d7.js";import"./VInfiniteScroll-3988a0eb.js";import"./layout-ca8c09ab.js";import"./VVirtualScroll-3adad00e.js";const X=h({name:"Radios",__name:"LibraryRadios",setup(A){const{t:o}=b(),s=u(!1),m=u(v.libraryRadiosCount),c=["name","name_desc","sort_name","sort_name_desc","timestamp_added","timestamp_added_desc","last_played","last_played_desc","play_count","play_count_desc"];g(()=>{const t=a.subscribe_multi([i.MEDIA_ITEM_ADDED,i.MEDIA_ITEM_UPDATED,i.MEDIA_ITEM_DELETED],e=>{var r;(r=e.object_id)!=null&&r.startsWith("library://radio")&&(s.value=!0)});I(t)});const _=async function(t){if(t.refresh&&!s.value){for(a.startSync([n.RADIO]),await l(250);a.syncTasks.value.length>0&&a.syncTasks.value.filter(e=>e.media_types.includes(n.RADIO)).length!=0;)await l(500);await l(500)}return s.value=!1,m.value=await a.getLibraryRadiosCount(t.favoritesOnly||!1),await a.getLibraryRadios(t.favoritesOnly||void 0,t.search,t.limit,t.offset,t.sortBy)},y=async function(){const t=prompt(o("enter_url"));if(t){if(!(t!=null&&t.startsWith("http"))){alert(o("invalid_input"));return}a.getItem(n.RADIO,t,"builtin").then(e=>{var d;const r=prompt(o("enter_name"),e.name);e.name=r||e.name,delete e.sort_name;const p=prompt(o("image_url"),(d=e.metadata.images)!=null&&d.length?e.metadata.images[0].path:"");p&&(e.metadata.images=[{type:T.THUMB,path:p,provider:"builtin",remotely_accessible:!0}]),a.addItemToLibrary(e).then(()=>w.go(0))}).catch(e=>alert(e))}};return(t,e)=>(D(),E(f,{itemtype:"radios","show-duration":!1,"show-provider":!1,"show-favorites-only-filter":!0,"load-paged-data":_,"sort-keys":c,"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:()=>{y()},icon:"mdi-playlist-plus"}],icon:"mdi-access-point","restore-state":!0,total:m.value},null,8,["update-available","title","extra-menu-items","total"]))}});export{X as default};
