import{l as f,Q as d,r as m,o as _,L as a,ai as s,b as y,y as b,z as h,x as v,M as i,aj as n,K as k}from"./index-ebe4cd91.js";import{_ as T}from"./ItemsListing.vue_vue_type_style_index_0_lang-1ef061d8.js";import"./ListviewItem-5151f17f.js";import"./MediaItemThumb.vue_vue_type_style_index_0_lang-bf2386aa.js";import"./ListItem-a20c73ec.js";import"./VImg-b5692565.js";import"./VMenu-86ca5efe.js";import"./index-bda4e7b4.js";import"./VListItem-0df8c60b.js";import"./VCheckboxBtn-fcc73f36.js";import"./VCard-46ebf6a3.js";/* empty css                             */import"./PanelviewItem.vue_vue_type_style_index_0_lang-516932fb.js";import"./contextmenu-b7cc1c45.js";import"./eventbus-d154090d.js";import"./Alert-d031836e.js";import"./Container-1375a850.js";/* empty css              */import"./VToolbar-76e5fae8.js";import"./VTextField-034239e4.js";import"./VBadge-0ad57746.js";import"./VRow-03e92c8f.js";const q=f({__name:"LibraryTracks",setup(E){const{t:l}=d(),u=m([]),r=m(!1);_(()=>{const t=a.subscribe_multi([s.MEDIA_ITEM_ADDED,s.MEDIA_ITEM_UPDATED,s.MEDIA_ITEM_DELETED],e=>{var o;(o=e.object_id)!=null&&o.startsWith("library://track")&&(r.value=!0)});y(t)});const c=async function(t){if(t.favoritesOnly=t.favoritesOnly||void 0,t.refresh){for(a.startSync([i.TRACK]),await n(250);a.syncTasks.value.length>0&&a.syncTasks.value.filter(e=>e.media_types.includes(i.TRACK)).length!=0;)await n(500);await n(500)}return r.value=!1,await a.getLibraryTracks(t.favoritesOnly,t.search,t.limit,t.offset,t.sortBy)},p=async function(){const t=prompt(l("enter_url"));t&&a.getItem(i.TRACK,t,"url").then(e=>{const o=prompt(l("enter_name"),e.name);e.name=o||e.name,a.addItemToLibrary(e).then(()=>r.value=!0)}).catch(e=>alert(e))};return(t,e)=>(b(),h(T,{itemtype:"tracks",items:u.value,"show-provider":!1,"show-favorites-only-filter":!0,"show-track-number":!1,"load-data":c,"sort-keys":["sort_name","timestamp_added DESC","sort_artist","duration"],"show-album":!1,"update-available":r.value,title:v(k)("bp4")?t.$t("tracks"):"","show-search-button":!0,"allow-key-hooks":!0,"context-menu-items":[{label:"add_url_item",labelArgs:[],action:()=>{p()},icon:"mdi-link-plus"}]},null,8,["items","update-available","title","context-menu-items"]))}});export{q as default};
