import{I as b}from"./ItemsListing-nJ4gZwpG.js";import{x as h,ae as I,r,H as u,o as w,I as e,P as E,ag as n,b as P,y as T,z as L,M as c,aj as p}from"./index-B55Az6uZ.js";import"./ItemContextMenu.vue_vue_type_style_index_0_scoped_3a9a25e3_lang-bhWnvEZi.js";import"./ProviderIcon.vue_vue_type_script_setup_true_lang-DmwHlomN.js";import"./VListItem-CTt5-rrr.js";import"./VChip-USL2zd6t.js";import"./VList-BbG08zRJ.js";import"./VCardText-6y4Yo2hg.js";import"./VCard-Ba6kturx.js";import"./VMenu-BJOay2FN.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./eventbus-CGRXT3Tn.js";import"./ListItem-BIOYzg71.js";import"./VCheckbox-BXkbvEGB.js";import"./VCheckboxBtn-gndQvl0N.js";import"./VTooltip-B2xVdDYJ.js";import"./VSpacer-Bt_rBx5Q.js";/* empty css              */import"./PanelviewItemCompact-BTMAfeVs.js";import"./Container-DwLI_eNo.js";import"./VContainer-Bwbf98oq.js";import"./Toolbar-CnjrHAL9.js";import"./VToolbar-Cw0gv67a.js";import"./VTextField-DVCLCsz9.js";import"./VInfiniteScroll-08LzEGPu.js";import"./layout-CXuYJmUE.js";import"./VRow-DsoK3S8F.js";import"./VVirtualScroll-Ds3B_Lds.js";import"./VAlert-DmQ6rEG3.js";const at=h({name:"Playlists",__name:"LibraryPlaylists",setup(A){const{t:y}=I(),l=r(!1),o=r(u.libraryPlaylistsCount),m=r([]),d=["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"],_=async function(t){if(t.refresh&&!l.value){for(e.startSync([c.PLAYLIST]),await p(250);e.syncTasks.value.length>0&&e.syncTasks.value.filter(a=>a.media_types.includes(c.PLAYLIST)).length!=0;)await p(500);await p(500)}return l.value=!1,f(t),await e.getLibraryPlaylists(t.favoritesOnly||void 0,t.search,t.limit,t.offset,t.sortBy)},f=async function(t){if(!t.favoritesOnly){o.value=u.libraryPlaylistsCount;return}o.value=await e.getLibraryPlaylistsCount(t.favoritesOnly||!1)};w(()=>{const t=[];for(const s of Object.values(e.providers).filter(i=>i.available&&i.supported_features.includes(E.PLAYLIST_CREATE)))t.push({label:"create_playlist_on",labelArgs:[s.name],action:()=>{v(s.instance_id)},icon:"mdi-playlist-plus"});t.length&&m.value.push({label:"create_playlist_on",icon:"mdi-playlist-plus",subItems:t});const a=e.subscribe_multi([n.MEDIA_ITEM_ADDED,n.MEDIA_ITEM_UPDATED,n.MEDIA_ITEM_DELETED],s=>{var i;(i=s.object_id)!=null&&i.startsWith("library://playlist")&&(l.value=!0)});P(a)});const v=async function(t){const a=prompt(y("new_playlist_name"));a&&await e.createPlaylist(a,t).then(()=>location.reload()).catch(s=>alert(s))};return(t,a)=>(T(),L(b,{itemtype:"playlists",path:"libraryplaylists","show-duration":!1,"show-provider":!0,"show-favorites-only-filter":!0,"load-paged-data":_,"show-library":!0,"sort-keys":d,"update-available":l.value,title:t.$t("playlists"),"allow-key-hooks":!0,"show-search-button":!0,"extra-menu-items":m.value,icon:"mdi-playlist-play","restore-state":!0,total:o.value},null,8,["update-available","title","extra-menu-items","total"]))}});export{at as default};
