import{_ as y}from"./ItemsListing.vue_vue_type_style_index_0_lang-d2bd3bdf.js";import{v as h,Q as v,r as c,o as b,L as a,an as i,b as g,y as D,z as I,x as E,M as n,ao as l,ag as k,K as T}from"./index-2ed92f93.js";import"./ListviewItem-ccf2487f.js";import"./VBadge-37788c48.js";import"./Container-49aaa795.js";import"./forwardRefs-b2545869.js";import"./VMenu-16697a26.js";/* empty css              */import"./VCheckboxBtn-f2c5d38b.js";import"./VSlideGroup-dd4dc020.js";import"./VCard-c4a81832.js";import"./VCardText-2fda0657.js";import"./VTooltip-11295f6e.js";import"./PanelviewItem.vue_vue_type_style_index_0_lang-12716644.js";import"./contextmenu-66a55ea8.js";import"./Alert-d5f867ed.js";import"./VAlert-85a681b8.js";import"./VToolbar-25636a36.js";import"./VTextField-e0cdad59.js";import"./VVirtualScroll-63a0b7fb.js";const F=h({__name:"LibraryRadios",setup(w){const{t:o}=v(),d=c([]),r=c(!1),m={name:"sort_name",recent:"timestamp_added DESC"};b(()=>{const t=a.subscribe_multi([i.MEDIA_ITEM_ADDED,i.MEDIA_ITEM_UPDATED,i.MEDIA_ITEM_DELETED],e=>{var s;(s=e.object_id)!=null&&s.startsWith("library://radio")&&(r.value=!0)});g(t)});const f=async function(t){if(t.refresh&&!r.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 r.value=!1,await a.getLibraryRadios(t.favoritesOnly||void 0,t.search,t.limit,t.offset,m[t.sortBy])},_=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,"url").then(e=>{var u;const s=prompt(o("enter_name"),e.name);e.name=s||e.name;const p=prompt(o("image_url"),(u=e.metadata.images)!=null&&u.length?e.metadata.images[0].path:"");p&&(e.metadata.images=[{type:k.THUMB,path:p,provider:"url"}]),a.addItemToLibrary(e).then(()=>r.value=!0)}).catch(e=>alert(e))}};return(t,e)=>(D(),I(y,{itemtype:"radios",items:d.value,"show-duration":!1,"show-provider":!1,"show-favorites-only-filter":!0,"load-paged-data":f,"sort-keys":Object.keys(m),"update-available":r.value,title:E(T)("bp4")?t.$t("radios"):"","show-search-button":!0,"allow-key-hooks":!0,"context-menu-items":[{label:"add_url_item",labelArgs:[],action:()=>{_()},icon:"mdi-link-plus"}]},null,8,["items","sort-keys","update-available","title","context-menu-items"]))}});export{F as default};
