import{I as f}from"./ItemsListing-6e3c9168.js";import{d as v,a4 as b,r as l,o as h,b as a,P as I,a6 as r,a as w,c as E,e as T,M as m}from"./index-0272dc54.js";import{n}from"./utils-a32c3776.js";import"./eventbus-e44cf169.js";import"./VListItem-a3b7f8b7.js";import"./ListItem-ab5df53d.js";import"./Button-7bab5496.js";import"./_plugin-vue_export-helper-c27b6911.js";import"./VTextField-0a661ba3.js";import"./VVirtualScroll-c94c27f1.js";import"./VMenu-30df3a7b.js";import"./VCard-88cdf1d8.js";import"./VCardText-41d932c2.js";import"./VSpacer-39969d39.js";/* empty css              */import"./Alert-4069c5b8.js";import"./VAlert-fb48582c.js";import"./Container-3f082c46.js";import"./Toolbar-b074e682.js";import"./VList-21f55857.js";import"./VToolbar-3145d715.js";import"./VInfiniteScroll-d471d074.js";import"./layout-e087828e.js";import"./VChip-e0012620.js";const N=v({name:"Playlists",__name:"LibraryPlaylists",setup(A){const{t:u}=b(),c=l([]),o=l(!1),p=l([]),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&&!o.value){for(a.startSync([m.PLAYLIST]),await n(250);a.syncTasks.value.length>0&&a.syncTasks.value.filter(e=>e.media_types.includes(m.PLAYLIST)).length!=0;)await n(500);await n(500)}return o.value=!1,await a.getLibraryPlaylists(t.favoritesOnly||void 0,t.search,t.limit,t.offset,t.sortBy)};h(()=>{const t=[];for(const s of Object.values(a.providers).filter(i=>i.available&&i.supported_features.includes(I.PLAYLIST_CREATE)))t.push({label:"create_playlist_on",labelArgs:[s.name],action:()=>{y(s.instance_id)},icon:"mdi-playlist-plus"});t.length&&p.value.push({label:"create_playlist_on",icon:"mdi-playlist-plus",subItems:t});const e=a.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")&&(o.value=!0)});w(e)});const y=async function(t){const e=prompt(u("new_playlist_name"));e&&await a.createPlaylist(e,t).then(()=>location.reload()).catch(s=>alert(s))};return(t,e)=>(E(),T(f,{itemtype:"playlists",items:c.value,"show-duration":!1,"show-provider":!0,"show-favorites-only-filter":!0,"load-paged-data":_,"show-library":!0,"sort-keys":d,"update-available":o.value,title:t.$t("playlists"),"allow-key-hooks":!0,"show-search-button":!0,"extra-menu-items":p.value,icon:"mdi-playlist-play","restore-state":!0},null,8,["items","update-available","title","extra-menu-items"]))}});export{N as default};
