import{I as f}from"./ItemsListing-7bf0c0b0.js";import{d as v,a5 as b,r as o,s as h,o as I,b as e,P as w,a7 as r,a as E,c as P,e as T,M as u}from"./index-103db515.js";import{s as n}from"./VCheckbox-ddd5d7c4.js";import"./eventbus-6e1536e2.js";import"./VListItem-ab7a82e2.js";import"./ListItem-91f42136.js";import"./Button-412f73ce.js";import"./_plugin-vue_export-helper-c27b6911.js";import"./VMenu-482e7fbc.js";import"./VCard-d4f085fd.js";import"./VCardText-1a59cac1.js";import"./VSpacer-adcb10ea.js";/* empty css              */import"./PanelviewItemCompact-5ede3757.js";import"./VAlert-4165d2e6.js";import"./Container-d98651c4.js";import"./Toolbar-908bc969.js";import"./VList-cac73f62.js";import"./VToolbar-dcf67568.js";import"./VTextField-73438668.js";import"./VCheckboxBtn-19bafbc9.js";import"./VInfiniteScroll-c2610a44.js";import"./layout-e7ad5131.js";import"./VVirtualScroll-b23fb9a8.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};
