import{I as f}from"./ItemsListing-efdefe10.js";import{d as v,a6 as b,r as o,s as h,o as I,b as e,P as w,a8 as r,a as E,c as P,e as T,M as u,aq as n}from"./index-2e87fa03.js";import"./VCheckbox-386509eb.js";import"./eventbus-0b29a02c.js";import"./VListItem-89fd7b1a.js";import"./VCheckboxBtn-95584b13.js";import"./VList-a4b75488.js";import"./VCardText-064374a3.js";import"./VCard-c125380f.js";import"./VMenu-148e092d.js";import"./_plugin-vue_export-helper-c27b6911.js";import"./ListItem-db7cb046.js";import"./Button-74c30473.js";import"./VSpacer-f5f551d9.js";/* empty css              */import"./PanelviewItemCompact-a679900d.js";import"./VAlert-d83244d0.js";import"./Container-a429dbf0.js";import"./Toolbar-0e15c31f.js";import"./VToolbar-00d7489e.js";import"./VTextField-6302d32d.js";import"./VInfiniteScroll-72c5f022.js";import"./layout-61f409b8.js";import"./VVirtualScroll-9a54f195.js";const Q=v({name:"Playlists",__name:"LibraryPlaylists",setup(L){const{t:c}=b(),l=o(!1),p=o(h.libraryPlaylistsCount),m=o([]),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"],y=async function(t){if(t.refresh&&!l.value){for(e.startSync([u.PLAYLIST]),await n(250);e.syncTasks.value.length>0&&e.syncTasks.value.filter(a=>a.media_types.includes(u.PLAYLIST)).length!=0;)await n(500);await n(500)}return l.value=!1,p.value=await e.getLibraryPlaylistsCount(t.favoritesOnly||!1),await e.getLibraryPlaylists(t.favoritesOnly||void 0,t.search,t.limit,t.offset,t.sortBy)};I(()=>{const t=[];for(const s of Object.values(e.providers).filter(i=>i.available&&i.supported_features.includes(w.PLAYLIST_CREATE)))t.push({label:"create_playlist_on",labelArgs:[s.name],action:()=>{_(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([r.MEDIA_ITEM_ADDED,r.MEDIA_ITEM_UPDATED,r.MEDIA_ITEM_DELETED],s=>{var i;(i=s.object_id)!=null&&i.startsWith("library://playlist")&&(l.value=!0)});E(a)});const _=async function(t){const a=prompt(c("new_playlist_name"));a&&await e.createPlaylist(a,t).then(()=>location.reload()).catch(s=>alert(s))};return(t,a)=>(P(),T(f,{itemtype:"playlists","show-duration":!1,"show-provider":!0,"show-favorites-only-filter":!0,"load-paged-data":y,"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:p.value},null,8,["update-available","title","extra-menu-items","total"]))}});export{Q as default};
