import{_ as y}from"./ItemsListing.vue_vue_type_style_index_0_lang-74e3dc20.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-b687f95a.js";import"./ListviewItem-8b992256.js";import"./VBadge-84e3406b.js";import"./Container-dc894acd.js";import"./forwardRefs-7be90dc2.js";import"./VMenu-b634019c.js";/* empty css              */import"./VInput-5b197ccd.js";import"./VSlideGroup-b576aa37.js";import"./VCard-b98fe47e.js";import"./VCardText-6774ea5e.js";import"./VTooltip-3ef94159.js";import"./PanelviewItem.vue_vue_type_style_index_0_lang-a3a9dd78.js";import"./contextmenu-521b5304.js";import"./Alert-19e36349.js";import"./VAlert-56af8987.js";import"./VToolbar-b7f10b15.js";import"./VTextField-0c2ec62d.js";import"./VVirtualScroll-84259ceb.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};
