import{I as f}from"./ItemsListing-9a3a53ae.js";import{d as b,a6 as h,r as p,s as v,o as T,b as a,a8 as i,a as k,c as g,e as I,M as n,a9 as l,aj as w,V as E}from"./index-9299e1c1.js";import"./VCheckbox-75b4c12a.js";import"./eventbus-fb52ce0b.js";import"./VListItem-748fc7af.js";import"./VCheckboxBtn-ad9d405a.js";import"./VList-6d58de6a.js";import"./VCardText-7bb4efb6.js";import"./VCard-6d87d169.js";import"./VMenu-02b91385.js";import"./_plugin-vue_export-helper-c27b6911.js";import"./ListItem-50af6ebb.js";import"./Button-784539f4.js";import"./VSpacer-caa12be4.js";/* empty css              */import"./PanelviewItemCompact-c5d1faef.js";import"./VAlert-708f5408.js";import"./Container-ff473259.js";import"./Toolbar-eb89f7db.js";import"./VToolbar-2949cae0.js";import"./VTextField-9151d790.js";import"./VInfiniteScroll-dfad6ac1.js";import"./layout-0bba43de.js";import"./VVirtualScroll-1c00b40c.js";const X=b({name:"Tracks",__name:"LibraryTracks",setup(A){const{t:r}=h(),o=p(!1),m=p(v.libraryTracksCount),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"];T(()=>{const t=a.subscribe_multi([i.MEDIA_ITEM_ADDED,i.MEDIA_ITEM_UPDATED,i.MEDIA_ITEM_DELETED],e=>{var s;(s=e.object_id)!=null&&s.startsWith("library://track")&&(o.value=!0)});k(t)});const _=async function(t){if(t.favoritesOnly=t.favoritesOnly||void 0,t.refresh&&!o.value){for(a.startSync([n.TRACK]),await l(250);a.syncTasks.value.length>0&&a.syncTasks.value.filter(e=>e.media_types.includes(n.TRACK)).length!=0;)await l(500);await l(500)}return o.value=!1,m.value=await a.getLibraryTracksCount(t.favoritesOnly||!1),await a.getLibraryTracks(t.favoritesOnly,t.search,t.limit,t.offset,t.sortBy)},y=async function(){const t=prompt(r("enter_url"));if(t){if(!(t!=null&&t.startsWith("http"))){alert(r("invalid_input"));return}a.getItem(n.TRACK,t,"builtin").then(e=>{var u;const s=prompt(r("enter_name"),e.name);e.name=s||e.name,delete e.sort_name;const c=prompt(r("image_url"),(u=e.metadata.images)!=null&&u.length?e.metadata.images[0].path:"");c&&(e.metadata.images=[{type:w.THUMB,path:c,provider:"builtin",remotely_accessible:!0}]),a.addItemToLibrary(e).then(()=>E.go(0))}).catch(e=>alert(e))}};return(t,e)=>(g(),I(f,{itemtype:"tracks","show-provider":!1,"show-favorites-only-filter":!0,"show-track-number":!1,"load-paged-data":_,"sort-keys":d,"show-album":!0,"update-available":o.value,title:t.$t("tracks"),"show-search-button":!0,"allow-key-hooks":!0,"context-menu-items":[{label:"add_url_item",labelArgs:[],action:()=>{y()},icon:"mdi-link-plus"}],icon:"mdi-music-note","restore-state":!0,total:m.value},null,8,["update-available","title","context-menu-items","total"]))}});export{X as default};
