import{_}from"./ItemsListing.vue_vue_type_style_index_0_lang-e3f0c114.js";import{y as d,R as v,r as o,o as b,N as s,P as h,ap as r,b as E,A as w,B as T,z as A,O as u,aq as l,M as I}from"./index-9b822783.js";import"./ListviewItem-030e11e6.js";import"./VBadge-c9fb58c5.js";import"./Container-05be0da0.js";import"./forwardRefs-af0663a3.js";import"./VMenu-8029677e.js";/* empty css              */import"./VInput-c159036c.js";import"./VSlideGroup-d3ac8eca.js";import"./VCard-0d72f9dd.js";import"./VCardText-bc96863a.js";import"./VTooltip-5955b4ca.js";import"./PanelviewItem.vue_vue_type_style_index_0_lang-846c4785.js";import"./contextmenu-b55bad56.js";import"./Alert-112324b3.js";import"./VAlert-fddf489c.js";import"./VToolbar-79c684b4.js";import"./VTextField-7d804c49.js";import"./VVirtualScroll-a3d1c1c9.js";import"./layout-71937d76.js";const W=d({__name:"LibraryPlaylists",setup(k){const{t:c}=v(),m=o([]),i=o(!1),n=o([]),p={name:"sort_name",recent:"timestamp_added DESC"},y=async function(t){if(t.refresh&&!i.value){for(s.startSync([u.PLAYLIST]),await l(250);s.syncTasks.value.length>0&&s.syncTasks.value.filter(e=>e.media_types.includes(u.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,p[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_on",labelArgs:[e.name],action:()=>{f(e.instance_id)},icon:"mdi-playlist-plus"});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(_,{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(p),"update-available":i.value,title:A(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};
