import{I as f}from"./ItemsListing-2655a521.js";import{d as v,ae as b,r as l,o as h,b as a,P as E,ag as r,a as D,c as I,e as w,M as d,ah as m}from"./index-1fa25223.js";import"./ListviewItem-fa4b6d44.js";import"./helpers-f9fbf435.js";import"./Container-55c3ff81.js";import"./VListItem-53d44b85.js";import"./_plugin-vue_export-helper-c27b6911.js";/* empty css              */import"./VLabel-148b546a.js";import"./VList-f519ecda.js";import"./VCard-99bbc2f5.js";import"./VCardText-bbb7eb1a.js";import"./VMenu-85495654.js";import"./ListItem-9f85535e.js";import"./Button-0d671d73.js";import"./VTooltip-c87f5f44.js";import"./VCheckboxBtn-4c4cfeff.js";import"./PanelviewItem-f1eef939.js";import"./Alert-501a5edb.js";import"./VAlert-034cbd55.js";import"./Toolbar-77a90b60.js";import"./VBadge-3b97e665.js";import"./VToolbar-a7b4dbd4.js";import"./ItemContextMenu.vue_vue_type_style_index_0_scoped_be40882c_lang-79825e42.js";import"./eventbus-d154090d.js";import"./VTextField-46c02b72.js";import"./VVirtualScroll-f6a01209.js";import"./layout-6738e727.js";const Z=v({name:"Playlists",__name:"LibraryPlaylists",setup(T){const{t:c}=b(),u=l([]),o=l(!1),n=l([]),p={name:"name",name_desc:"name DESC",sort_name:"sort_name",sort_name_desc:"sort_name DESC",timestamp_added:"timestamp_added",timestamp_added_desc:"timestamp_added DESC",timestamp_modified:"timestamp_modified",timestamp_modified_desc:"timestamp_modified DESC",last_played:"last_played",last_played_desc:"last_played DESC",play_count:"play_count",play_count_desc:"play_count DESC"},_=async function(t){if(t.refresh&&!o.value){for(a.startSync([d.PLAYLIST]),await m(250);a.syncTasks.value.length>0&&a.syncTasks.value.filter(e=>e.media_types.includes(d.PLAYLIST)).length!=0;)await m(500);await m(500)}return o.value=!1,await a.getLibraryPlaylists(t.favoritesOnly||void 0,t.search,t.limit,t.offset,p[t.sortBy])};h(()=>{const t=[];for(const s of Object.values(a.providers).filter(i=>i.available&&i.supported_features.includes(E.PLAYLIST_CREATE)))t.push({label:"create_playlist_on",labelArgs:[s.name],action:()=>{y(s.instance_id)},icon:"mdi-playlist-plus"});t.length&&n.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)});D(e)});const y=async function(t){const e=prompt(c("new_playlist_name"));e&&await a.createPlaylist(e,t).then(()=>location.reload()).catch(s=>alert(s))};return(t,e)=>(I(),w(f,{itemtype:"playlists",items:u.value,"show-duration":!1,"show-provider":!0,"show-favorites-only-filter":!0,"load-paged-data":_,"show-library":!0,"sort-keys":Object.keys(p),"update-available":o.value,title:t.$t("playlists"),"allow-key-hooks":!0,"show-search-button":!0,"extra-menu-items":n.value,icon:"mdi-playlist-play"},null,8,["items","sort-keys","update-available","title","extra-menu-items"]))}});export{Z as default};
