import{_ as y}from"./ItemsListing.vue_vue_type_style_index_0_lang-cfe67ae4.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-5804982a.js";import"./ListviewItem-8b7ae6a6.js";import"./VBadge-3d00ada8.js";import"./Container-d5ee1f41.js";import"./forwardRefs-03519353.js";import"./VMenu-18f2572a.js";/* empty css              */import"./VInput-fe7a35fc.js";import"./VSlideGroup-711de993.js";import"./VCard-cc8044ef.js";import"./VCardText-963b2439.js";import"./VTooltip-5622a67d.js";import"./PanelviewItem.vue_vue_type_style_index_0_lang-04756f0a.js";import"./contextmenu-95007cdc.js";import"./Alert-38a1b933.js";import"./VAlert-8600f5db.js";import"./VToolbar-ce6590ba.js";import"./VTextField-b58cde95.js";import"./VVirtualScroll-72995e2a.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};
