import{I as b}from"./ItemsListing-e7c9377b.js";import{d as h,a5 as I,r,s as m,o as w,b as e,P as E,a7 as n,a as P,c as T,e as L,M as c}from"./index-e34071c2.js";import{s as p}from"./VCheckbox-081529bb.js";import"./eventbus-edb4a70e.js";import"./VListItem-6fb16d04.js";import"./ListItem-f09faddc.js";import"./Button-d52131a6.js";import"./_plugin-vue_export-helper-c27b6911.js";import"./VMenu-8ea0aa0a.js";import"./VCard-0f63f60c.js";import"./VCardText-2a290ffe.js";import"./VSpacer-b7ae4876.js";/* empty css              */import"./PanelviewItemCompact-8de8744a.js";import"./VAlert-cd8a958f.js";import"./Container-1af89f37.js";import"./Toolbar-bbf3d11a.js";import"./VList-5a526902.js";import"./VToolbar-790d92bd.js";import"./VTextField-df721147.js";import"./VCheckboxBtn-43c6a5b9.js";import"./VInfiniteScroll-311fcdfe.js";import"./layout-4fa46c33.js";import"./VVirtualScroll-8b839030.js";const V=h({name:"Playlists",__name:"LibraryPlaylists",setup(A){const{t:y}=I(),l=r(!1),o=r(m.libraryPlaylistsCount),u=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=m.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&&u.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","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":u.value,icon:"mdi-playlist-play","restore-state":!0,total:o.value},null,8,["update-available","title","extra-menu-items","total"]))}});export{V as default};
