import{_ as d}from"./ItemsListing.vue_vue_type_style_index_0_lang-8114fc79.js";import{v as _,Q as v,r as o,o as b,L as s,P as h,ak as r,b as E,y as w,z as T,x as k,M as p,al as l,K as I}from"./index-20675090.js";import"./ListviewItem-ea07a19b.js";import"./VBadge-778cac01.js";import"./ListItem-e092a77b.js";import"./forwardRefs-67412654.js";import"./VMenu-ae4158ef.js";import"./VCheckboxBtn-bbfa74a1.js";import"./VSlideGroup-14bb6bf6.js";import"./VCard-30020028.js";import"./VCardText-5e149cd1.js";import"./VTooltip-cf009865.js";import"./PanelviewItem.vue_vue_type_style_index_0_lang-4e768a3d.js";import"./contextmenu-ec90c658.js";import"./Alert-daf9024b.js";import"./Container-e8fef44d.js";/* empty css              */import"./VToolbar-7174c765.js";import"./VTextField-8bb22937.js";import"./VVirtualScroll-b47ffb64.js";const W=_({__name:"LibraryPlaylists",setup(A){const{t:c}=v(),m=o([]),i=o(!1),n=o([]),u={name:"sort_name",recent:"timestamp_added DESC"},y=async function(t){if(t.refresh&&!i.value){for(s.startSync([p.PLAYLIST]),await l(250);s.syncTasks.value.length>0&&s.syncTasks.value.filter(e=>e.media_types.includes(p.PLAYLIST)).length!=0;)await l(500);await l(500)}return i.value=!1,await s.getLibraryPlaylists(t.favoritesOnly||void 0,t.search,t.limit,t.offset,u[t.sortBy])};b(()=>{for(const e of Object.values(s.providers).filter(a=>a.available&&a.supported_features.includes(h.PLAYLIST_CREATE)))n.value.push({label:"create_playlist",labelArgs:[e.name],action:()=>{f(e.instance_id)},icon:"mdi-sync"});const t=s.subscribe_multi([r.MEDIA_ITEM_ADDED,r.MEDIA_ITEM_UPDATED,r.MEDIA_ITEM_DELETED],e=>{var a;(a=e.object_id)!=null&&a.startsWith("library://playlist")&&(i.value=!0)});E(t)});const f=async function(t){const e=prompt(c("new_playlist_name"));e&&await s.createPlaylist(e,t).then(()=>location.reload()).catch(a=>alert(a))};return(t,e)=>(w(),T(d,{itemtype:"playlists",items:m.value,"show-duration":!1,"show-provider":!0,"show-favorites-only-filter":!0,"load-paged-data":y,"show-library":!0,"sort-keys":Object.keys(u),"update-available":i.value,title:k(I)("bp4")?t.$t("playlists"):"","allow-key-hooks":!0,"show-search-button":!0,"context-menu-items":n.value},null,8,["items","sort-keys","update-available","title","context-menu-items"]))}});export{W as default};
