import{l as y,J as v,r as l,B as r,O as o,U as b,ag as E,b as p,o as I,af as i,q as A,v as D}from"./index-e9211ef1.js";import{_ as M}from"./ItemsListing.vue_vue_type_script_setup_true_lang-436cf3d3.js";import"./ListviewItem-b7a4258b.js";import"./MediaItemThumb.vue_vue_type_style_index_0_lang-278977b5.js";import"./VMenu-bc0cce60.js";import"./VDivider-336c24cd.js";import"./VBtn-68784d55.js";import"./VListItem-230d1393.js";import"./Container-349a0ac0.js";/* empty css              */import"./VDialog-5f240a62.js";import"./VCard-138864fc.js";import"./VToolbar-daf2b89f.js";import"./VSelect-04a129eb.js";/* empty css                             */import"./PanelviewItem.vue_vue_type_style_index_0_lang-fefd2afe.js";import"./Alert-55091fd0.js";import"./VSpacer-bdf2f653.js";import"./VBadge-9fa94f29.js";import"./VRow-e8f3e51e.js";const z=y({__name:"LibraryPlaylists",setup(T){const{t:n}=v(),m=l([]),s=l(!1);r.topBarContextMenuItems=[{label:"sync_now",labelArgs:[n("playlists")],action:()=>{o.startSync([b.PLAYLIST])},icon:"mdi-sync"}];for(const e of Object.values(o.providers).filter(t=>t.available&&t.supported_features.includes(E.PLAYLIST_CREATE)))r.topBarContextMenuItems.push({label:"create_playlist",labelArgs:[e.name],action:()=>{c(e.instance_id)},icon:"mdi-sync"});p(()=>{r.topBarContextMenuItems=[]});const u=async function(e,t,a,d,_=!0){const f=_||void 0;return s.value=!1,await o.getLibraryPlaylists(f,d,t,e,a)};I(()=>{const e=o.subscribe_multi([i.MEDIA_ITEM_ADDED,i.MEDIA_ITEM_UPDATED,i.MEDIA_ITEM_DELETED],t=>{var a;(a=t.object_id)!=null&&a.startsWith("library://playlist")&&(s.value=!0)});p(e)});const c=async function(e){const t=prompt(n("new_playlist_name"));t&&await o.createPlaylist(t,e).then(()=>location.reload()).catch(a=>alert(a))};return(e,t)=>(A(),D(M,{itemtype:"playlists",items:m.value,"show-duration":!1,"show-provider":!0,"show-favorites-only-filter":!0,"load-data":u,"show-library":!0,"sort-keys":["sort_name","timestamp_added DESC"],"update-available":s.value,onRefreshClicked:t[0]||(t[0]=a=>s.value=!1)},null,8,["items","update-available"]))}});export{z as default};
