import{_ as y}from"./ItemsListing.vue_vue_type_style_index_0_lang-a1cd4f47.js";import{v as b,O as h,r as c,o as v,L as a,an as s,b as g,y as D,z as I,x as E,M as n,ao as l,ag as k,V as T,K as w}from"./index-b12bd80e.js";import"./ListviewItem-96050575.js";import"./VBadge-ee40611b.js";import"./Container-559ac507.js";import"./forwardRefs-ccde8f15.js";import"./VMenu-29f14170.js";/* empty css              */import"./VInput-07934be9.js";import"./VSlideGroup-59a451fd.js";import"./VCard-ff384e61.js";import"./VCardText-a5346cc1.js";import"./VTooltip-7261e542.js";import"./PanelviewItem.vue_vue_type_style_index_0_lang-9e7798b1.js";import"./contextmenu-1ea20272.js";import"./Alert-49bdea68.js";import"./VAlert-b44bc40e.js";import"./VToolbar-4a427573.js";import"./VTextField-7036077f.js";import"./VVirtualScroll-36f43258.js";const J=b({__name:"LibraryRadios",setup(A){const{t:o}=h(),d=c([]),r=c(!1),m={name:"sort_name",recent:"timestamp_added DESC"};v(()=>{const t=a.subscribe_multi([s.MEDIA_ITEM_ADDED,s.MEDIA_ITEM_UPDATED,s.MEDIA_ITEM_DELETED],e=>{var i;(i=e.object_id)!=null&&i.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,"builtin").then(e=>{var u;const i=prompt(o("enter_name"),e.name);e.name=i||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:"builtin",remotely_accessible:!0}]),a.addItemToLibrary(e).then(()=>T.go(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(w)("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{J as default};
