import{l as d,N as _,r as o,o as v,J as s,P as b,ai as r,b as h,v as E,x as w,q as I,M as c,aj as l,I as T}from"./index-e5db0b73.js";import{_ as k}from"./ItemsListing.vue_vue_type_style_index_0_lang-6fa46e09.js";import"./ListviewItem-7c178b7a.js";import"./VBadge-efd00f67.js";import"./ListItem-ac3869d3.js";import"./VImg-7a057c50.js";import"./VMenu-d9833a31.js";import"./VCheckboxBtn-46446b67.js";import"./VCard-c9b9f4e9.js";import"./VTooltip-71530943.js";import"./PanelviewItem.vue_vue_type_style_index_0_lang-221d4edc.js";import"./contextmenu-8eac6b44.js";import"./Alert-1172b8fb.js";import"./Container-238e2d02.js";import"./VToolbar-4e8dded4.js";import"./VTextField-46667b30.js";import"./VVirtualScroll-01555b84.js";const K=d({__name:"LibraryPlaylists",setup(A){const{t:p}=_(),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([c.PLAYLIST]),await l(250);s.syncTasks.value.length>0&&s.syncTasks.value.filter(e=>e.media_types.includes(c.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])};v(()=>{for(const e of Object.values(s.providers).filter(a=>a.available&&a.supported_features.includes(b.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)});h(t)});const f=async function(t){const e=prompt(p("new_playlist_name"));e&&await s.createPlaylist(e,t).then(()=>location.reload()).catch(a=>alert(a))};return(t,e)=>(E(),w(k,{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:I(T)("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{K as default};
