import{I as _}from"./ItemsListing-BGUL9QyB.js";import{x as v,r as l,H as p,o as b,I as a,af as n,b as k,y as T,D as E,n as c,G as h,F as w,M as m,aj as u}from"./index-CFvoaD7J.js";import{_ as D}from"./AddManualLink.vue_vue_type_script_setup_true_lang-PFO36K-v.js";import"./ItemContextMenu.vue_vue_type_style_index_0_scoped_4409cede_lang-41DbVClm.js";import"./ProviderIcon.vue_vue_type_script_setup_true_lang-Ji67J6Pu.js";import"./VListItem-CSPID7yq.js";import"./VChip-Ccz1-bmn.js";import"./VList-fGk9SRdf.js";import"./VCardText-CpOuj25H.js";import"./VCard-DxLPF-Ra.js";import"./VMenu-9pSrU4Fo.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./eventbus-CGRXT3Tn.js";import"./ListItem-nYGtvGaY.js";import"./VCheckbox-B5r7QKHZ.js";import"./VCheckboxBtn-CRgZyCzV.js";import"./VTooltip-DC73AT2B.js";import"./VSpacer-UYEiyhN7.js";/* empty css              */import"./PanelviewItemCompact-BQIsDE0n.js";import"./Container-BDz3QMuX.js";import"./VContainer-CzfHAKpA.js";import"./Toolbar-DNen7a-V.js";import"./VToolbar-Da4d1W_R.js";import"./VTextField-DF4u_eMy.js";import"./VInfiniteScroll-D1yVLjQf.js";import"./layout-BeGdxe2Y.js";import"./VRow-BC1No8oB.js";import"./VVirtualScroll-BDBVEoUv.js";import"./VAlert-CIiIOQza.js";import"./VDialog-CdvGeqlS.js";const ot=v({name:"Tracks",__name:"LibraryTracks",setup(A){const o=l(!1),s=l(p.libraryTracksCount),i=l(!1),d=["name","name_desc","sort_name","sort_name_desc","duration","duration_desc","timestamp_added","timestamp_added_desc","last_played","last_played_desc","play_count","play_count_desc"];b(()=>{const t=a.subscribe_multi([n.MEDIA_ITEM_ADDED,n.MEDIA_ITEM_UPDATED,n.MEDIA_ITEM_DELETED],e=>{var r;(r=e.object_id)!=null&&r.startsWith("library://track")&&(o.value=!0)});k(t)});const f=async function(t){if(t.favoritesOnly=t.favoritesOnly||void 0,t.refresh&&!o.value){for(a.startSync([m.TRACK]),await u(250);a.syncTasks.value.length>0&&a.syncTasks.value.filter(e=>e.media_types.includes(m.TRACK)).length!=0;)await u(500);await u(500)}return o.value=!1,y(t),await a.getLibraryTracks(t.favoritesOnly,t.search,t.limit,t.offset,t.sortBy)},y=async function(t){if(!t.favoritesOnly){s.value=p.libraryTracksCount;return}s.value=await a.getLibraryTracksCount(t.favoritesOnly||!1)};return(t,e)=>(T(),E(w,null,[c(_,{itemtype:"tracks","show-provider":!1,"show-favorites-only-filter":!0,"show-track-number":!1,"load-paged-data":f,"sort-keys":d,"show-album":!0,"update-available":o.value,title:t.$t("tracks"),"show-search-button":!0,"allow-key-hooks":!0,"extra-menu-items":[{label:"add_url_item",labelArgs:[],action:()=>{i.value=!0},icon:"mdi-playlist-plus"}],icon:"mdi-music-note","restore-state":!0,total:s.value},null,8,["update-available","title","extra-menu-items","total"]),c(D,{modelValue:i.value,"onUpdate:modelValue":e[0]||(e[0]=r=>i.value=r),type:h(m).RADIO},null,8,["modelValue","type"])],64))}});export{ot as default};
