import{_ as y}from"./ItemsListing.vue_vue_type_style_index_0_lang-7fc10190.js";import{v as h,Q as v,r as c,o as b,L as a,al as i,b as g,y as D,z as I,x as E,M as n,am as l,ag as k,K as T}from"./index-3053b8a0.js";import"./ListviewItem-72b197ce.js";import"./VBadge-8491964b.js";import"./Container-c68e3d11.js";import"./forwardRefs-0f883695.js";import"./VMenu-c1b42799.js";/* empty css              */import"./VCheckboxBtn-1d21707b.js";import"./VSlideGroup-e1d3104d.js";import"./VCard-2d8a440d.js";import"./VCardText-197cfd2e.js";import"./VTooltip-cd5b17c3.js";import"./PanelviewItem.vue_vue_type_style_index_0_lang-c1d34c1c.js";import"./contextmenu-e2a33e90.js";import"./Alert-55f2ffb8.js";import"./VToolbar-9817dcd3.js";import"./VTextField-b7863fc2.js";import"./VVirtualScroll-bc1f8e5c.js";const q=h({__name:"LibraryRadios",setup(w){const{t:s}=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 o;(o=e.object_id)!=null&&o.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(s("enter_url"));if(t){if(!(t!=null&&t.startsWith("http"))){alert(s("invalid_input"));return}a.getItem(n.RADIO,t,"url").then(e=>{var u;const o=prompt(s("enter_name"),e.name);e.name=o||e.name;const p=prompt(s("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{q as default};
