import{_ as f}from"./ItemsListing.vue_vue_type_style_index_0_lang-02893598.js";import{d as h,k as b,r as c,o as D,b as a,ah as r,a as v,c as E,e as g,M as n,ai as l,a7 as I,D as k}from"./index-0ae84607.js";import"./ListviewItem-156d947d.js";import"./VBadge-bfb26993.js";import"./Container-eb92362b.js";import"./forwardRefs-d0d7c5bd.js";import"./Button-a1dfd3f5.js";import"./VMenu-f26d3a19.js";/* empty css              */import"./VInput-00e20677.js";import"./VSlideGroup-18f8a11f.js";import"./VCard-e96ab32b.js";import"./VCardText-b1a0de89.js";import"./VTooltip-054ea37d.js";import"./PanelviewItem.vue_vue_type_style_index_0_lang-a0b4c306.js";import"./contextmenu-5ae46870.js";import"./Alert-ee4ff93d.js";import"./VAlert-212471f5.js";import"./VToolbar-b7dd8339.js";import"./VTextField-4bf39c0d.js";import"./VVirtualScroll-06bbaaf5.js";import"./layout-f3684635.js";const N=h({name:"Radios",__name:"LibraryRadios",setup(T){const{t:s}=b(),u=c([]),o=c(!1),m={name:"name",name_desc:"name DESC",sort_name:"sort_name",sort_name_desc:"sort_name DESC",timestamp_added:"timestamp_added",timestamp_added_desc:"timestamp_added DESC",last_played:"last_played",last_played_desc:"last_played DESC",play_count:"play_count",play_count_desc:"play_count DESC"};D(()=>{const t=a.subscribe_multi([r.MEDIA_ITEM_ADDED,r.MEDIA_ITEM_UPDATED,r.MEDIA_ITEM_DELETED],e=>{var i;(i=e.object_id)!=null&&i.startsWith("library://radio")&&(o.value=!0)});v(t)});const _=async function(t){if(t.refresh&&!o.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 o.value=!1,await a.getLibraryRadios(t.favoritesOnly||void 0,t.search,t.limit,t.offset,m[t.sortBy])},y=async function(){const t=prompt(s("enter_url"));if(t){if(!(t!=null&&t.startsWith("http"))){alert(s("invalid_input"));return}a.getItem(n.RADIO,t,"builtin").then(e=>{var d;const i=prompt(s("enter_name"),e.name);e.name=i||e.name,delete e.sort_name;const p=prompt(s("image_url"),(d=e.metadata.images)!=null&&d.length?e.metadata.images[0].path:"");p&&(e.metadata.images=[{type:I.THUMB,path:p,provider:"builtin",remotely_accessible:!0}]),a.addItemToLibrary(e).then(()=>k.go(0))}).catch(e=>alert(e))}};return(t,e)=>(E(),g(f,{itemtype:"radios",items:u.value,"show-duration":!1,"show-provider":!1,"show-favorites-only-filter":!0,"load-paged-data":_,"sort-keys":Object.keys(m),"update-available":o.value,title:t.$t("radios"),"show-search-button":!0,"allow-key-hooks":!0,"context-menu-items":[{label:"add_url_item",labelArgs:[],action:()=>{y()},icon:"mdi-link-plus"}]},null,8,["items","sort-keys","update-available","title","context-menu-items"]))}});export{N as default};
