import{I as f}from"./ItemsListing-BPCoDFMa.js";import{Q as b,aQ as v,x as r,a2 as m,a4 as e,a5 as h,o as I,a6 as w,aS as n,b as E,R as P,S as T}from"./index-orrnp8a1.js";import"./MediaItemThumb-BFLLxiOJ.js";import"./ProviderIcon.vue_vue_type_style_index_0_lang-DgYavPcK.js";import"./VChip-DzIcRFdM.js";import"./VBtn-BJolvyKt.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./ListItem-BOpEb2vA.js";import"./VCheckbox-BaanYS4J.js";import"./VCheckboxBtn-CICj8ZxL.js";import"./PanelviewItemCompact-Bf1Qb2IB.js";import"./VSpacer-FMK5QbR9.js";/* empty css              */import"./Container-C-MxRHLg.js";import"./VContainer-DvR1uhzJ.js";import"./Toolbar-CE2HDv9i.js";import"./VToolbar-BlKUHnwt.js";import"./VTextField-DaF8PfrV.js";import"./VInfiniteScroll-CDme3Tib.js";import"./layout-BTr25AHs.js";import"./VRow-C4MwkXJh.js";import"./VVirtualScroll-Q9Rc10mA.js";import"./VAlert-BhQ3L7Kc.js";const J=b({name:"Playlists",__name:"LibraryPlaylists",setup(A){const{t:u}=v(),o=r(!1),l=r(m.libraryPlaylistsCount),p=r([{label:"sync_now",icon:"mdi-sync",action:()=>{e.startSync([h.PLAYLIST])},overflowAllowed:!0,disabled:e.syncTasks.value.length>0}]),c=["name","name_desc","sort_name","sort_name_desc","timestamp_added","timestamp_added_desc","timestamp_modified","timestamp_modified_desc","last_played","last_played_desc","play_count","play_count_desc"],y=async function(t){return o.value=!1,d(t),await e.getLibraryPlaylists(t.favoritesOnly||void 0,t.search,t.limit,t.offset,t.sortBy)},d=async function(t){if(!t.favoritesOnly){l.value=m.libraryPlaylistsCount;return}l.value=await e.getLibraryPlaylistsCount(t.favoritesOnly||!1)};I(()=>{const t=[];for(const a of Object.values(e.providers).filter(i=>i.available&&i.supported_features.includes(w.PLAYLIST_CREATE)))t.push({label:"create_playlist_on",labelArgs:[a.name],action:()=>{_(a.instance_id)},icon:"mdi-playlist-plus"});t.length&&p.value.push({label:"create_playlist_on",icon:"mdi-playlist-plus",subItems:t});const s=e.subscribe_multi([n.MEDIA_ITEM_ADDED,n.MEDIA_ITEM_UPDATED,n.MEDIA_ITEM_DELETED],a=>{var i;(i=a.object_id)!=null&&i.startsWith("library://playlist")&&(o.value=!0)});E(s)});const _=async function(t){const s=prompt(u("new_playlist_name"));s&&await e.createPlaylist(s,t).then(()=>location.reload()).catch(a=>alert(a))};return(t,s)=>(T(),P(f,{itemtype:"playlists",path:"libraryplaylists","show-duration":!1,"show-provider":!0,"show-favorites-only-filter":!0,"load-paged-data":y,"show-library":!0,"sort-keys":c,"update-available":o.value,title:t.$t("playlists"),"allow-key-hooks":!0,"show-search-button":!0,"extra-menu-items":p.value,icon:"mdi-playlist-play","restore-state":!0,total:l.value},null,8,["update-available","title","extra-menu-items","total"]))}});export{J as default};
