import{l as _,N as f,r as m,o as y,J as a,ai as o,b,v as k,x as v,q as h,M as n,aj as i,I as T}from"./index-e5db0b73.js";import{_ as E}from"./ItemsListing.vue_vue_type_style_index_0_lang-6fa46e09.js";import"./ListviewItem-7c178b7a.js";import"./VBadge-efd00f67.js";import"./ListItem-ac3869d3.js";import"./VImg-7a057c50.js";import"./VMenu-d9833a31.js";import"./VCheckboxBtn-46446b67.js";import"./VCard-c9b9f4e9.js";import"./VTooltip-71530943.js";import"./PanelviewItem.vue_vue_type_style_index_0_lang-221d4edc.js";import"./contextmenu-8eac6b44.js";import"./Alert-1172b8fb.js";import"./Container-238e2d02.js";import"./VToolbar-4e8dded4.js";import"./VTextField-46667b30.js";import"./VVirtualScroll-01555b84.js";const J=_({__name:"LibraryTracks",setup(D){const{t:l}=f(),c=m([]),r=m(!1),u={name:"sort_name",recent:"timestamp_added DESC",artist:"sort_artist, sort_name",album:"albums.sort_name, tracks.sort_name",duration:"duration",duration_desc:"duration DESC"};y(()=>{const t=a.subscribe_multi([o.MEDIA_ITEM_ADDED,o.MEDIA_ITEM_UPDATED,o.MEDIA_ITEM_DELETED],e=>{var s;(s=e.object_id)!=null&&s.startsWith("library://track")&&(r.value=!0)});b(t)});const p=async function(t){if(t.favoritesOnly=t.favoritesOnly||void 0,t.refresh&&!r.value){for(a.startSync([n.TRACK]),await i(250);a.syncTasks.value.length>0&&a.syncTasks.value.filter(e=>e.media_types.includes(n.TRACK)).length!=0;)await i(500);await i(500)}return r.value=!1,await a.getLibraryTracks(t.favoritesOnly,t.search,t.limit,t.offset,u[t.sortBy])},d=async function(){const t=prompt(l("enter_url"));t&&a.getItem(n.TRACK,t,"url").then(e=>{const s=prompt(l("enter_name"),e.name);e.name=s||e.name,a.addItemToLibrary(e).then(()=>r.value=!0)}).catch(e=>alert(e))};return(t,e)=>(k(),v(E,{itemtype:"tracks",items:c.value,"show-provider":!1,"show-favorites-only-filter":!0,"show-track-number":!1,"load-paged-data":p,"sort-keys":Object.keys(u),"show-album":!0,"update-available":r.value,title:h(T)("bp4")?t.$t("tracks"):"","show-search-button":!0,"allow-key-hooks":!0,"context-menu-items":[{label:"add_url_item",labelArgs:[],action:()=>{d()},icon:"mdi-link-plus"}]},null,8,["items","sort-keys","update-available","title","context-menu-items"]))}});export{J as default};
