import{I as f}from"./ItemsListing-9a3a53ae.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,a9 as n}from"./index-9299e1c1.js";import"./VCheckbox-75b4c12a.js";import"./eventbus-fb52ce0b.js";import"./VListItem-748fc7af.js";import"./VCheckboxBtn-ad9d405a.js";import"./VList-6d58de6a.js";import"./VCardText-7bb4efb6.js";import"./VCard-6d87d169.js";import"./VMenu-02b91385.js";import"./_plugin-vue_export-helper-c27b6911.js";import"./ListItem-50af6ebb.js";import"./Button-784539f4.js";import"./VSpacer-caa12be4.js";/* empty css              */import"./PanelviewItemCompact-c5d1faef.js";import"./VAlert-708f5408.js";import"./Container-ff473259.js";import"./Toolbar-eb89f7db.js";import"./VToolbar-2949cae0.js";import"./VTextField-9151d790.js";import"./VInfiniteScroll-dfad6ac1.js";import"./layout-0bba43de.js";import"./VVirtualScroll-1c00b40c.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};
