import{I as f}from"./ItemsListing-496384e5.js";import{d as b,a9 as h,r as p,o as v,b as a,ab as i,a as T,c as k,e as g,M as n,ap as l,ah as I,V as E}from"./index-bf0eaf20.js";import"./ItemContextMenu.vue_vue_type_style_index_0_scoped_d4387993_lang-b7e5044b.js";import"./eventbus-b340f869.js";import"./VListItem-223b492d.js";import"./VLabel-e07a3413.js";import"./VList-21e2a257.js";import"./VCardText-8a9fa9c7.js";import"./VCard-97256dbd.js";import"./VMenu-71b97cab.js";import"./_plugin-vue_export-helper-c27b6911.js";import"./ListItem-b1725b5d.js";import"./Button-574f04d4.js";import"./PanelviewItemCompact-cb3303f4.js";import"./VCheckboxBtn-f3296201.js";import"./VSpacer-36b6f8a9.js";/* empty css              */import"./VAlert-e2b3a5a6.js";import"./Container-88f21350.js";import"./Toolbar-1985c49b.js";import"./VToolbar-219721ba.js";import"./VTextField-ad1ef579.js";import"./VVirtualScroll-837eb7b9.js";import"./VInfiniteScroll-71aa3856.js";import"./layout-8db27034.js";const X=b({name:"Tracks",__name:"LibraryTracks",setup(w){const{t:r}=h(),u=p([]),s=p(!1),d=["name","name_desc","sort_name","sort_name_desc","artist","year","year_desc","album","duration","duration_desc","timestamp_added","timestamp_added_desc","last_played","last_played_desc","play_count","play_count_desc"];v(()=>{const t=a.subscribe_multi([i.MEDIA_ITEM_ADDED,i.MEDIA_ITEM_UPDATED,i.MEDIA_ITEM_DELETED],e=>{var o;(o=e.object_id)!=null&&o.startsWith("library://track")&&(s.value=!0)});T(t)});const _=async function(t){if(t.favoritesOnly=t.favoritesOnly||void 0,t.refresh&&!s.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 s.value=!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 c;const o=prompt(r("enter_name"),e.name);e.name=o||e.name,delete e.sort_name;const m=prompt(r("image_url"),(c=e.metadata.images)!=null&&c.length?e.metadata.images[0].path:"");m&&(e.metadata.images=[{type:I.THUMB,path:m,provider:"builtin",remotely_accessible:!0}]),a.addItemToLibrary(e).then(()=>E.go(0))}).catch(e=>alert(e))}};return(t,e)=>(k(),g(f,{itemtype:"tracks",items:u.value,"show-provider":!1,"show-favorites-only-filter":!0,"show-track-number":!1,"load-paged-data":_,"sort-keys":d,"show-album":!0,"update-available":s.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},null,8,["items","update-available","title","context-menu-items"]))}});export{X as default};
