import{_ as y}from"./ItemsListing.vue_vue_type_style_index_0_lang-02893598.js";import{d as f,k as v,r as o,o as E,b as s,P as b,ah as l,a as h,c as D,e as w,M as p,ai as r}from"./index-0ae84607.js";import"./ListviewItem-156d947d.js";import"./VBadge-bfb26993.js";import"./Container-eb92362b.js";import"./forwardRefs-d0d7c5bd.js";import"./Button-a1dfd3f5.js";import"./VMenu-f26d3a19.js";/* empty css              */import"./VInput-00e20677.js";import"./VSlideGroup-18f8a11f.js";import"./VCard-e96ab32b.js";import"./VCardText-b1a0de89.js";import"./VTooltip-054ea37d.js";import"./PanelviewItem.vue_vue_type_style_index_0_lang-a0b4c306.js";import"./contextmenu-5ae46870.js";import"./Alert-ee4ff93d.js";import"./VAlert-212471f5.js";import"./VToolbar-b7dd8339.js";import"./VTextField-4bf39c0d.js";import"./VVirtualScroll-06bbaaf5.js";import"./layout-f3684635.js";const G=f({name:"Playlists",__name:"LibraryPlaylists",setup(T){const{t:c}=v(),d=o([]),i=o(!1),n=o([]),m={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&&!i.value){for(s.startSync([p.PLAYLIST]),await r(250);s.syncTasks.value.length>0&&s.syncTasks.value.filter(e=>e.media_types.includes(p.PLAYLIST)).length!=0;)await r(500);await r(500)}return i.value=!1,await s.getLibraryPlaylists(t.favoritesOnly||void 0,t.search,t.limit,t.offset,m[t.sortBy])};E(()=>{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_on",labelArgs:[e.name],action:()=>{u(e.instance_id)},icon:"mdi-playlist-plus"});const t=s.subscribe_multi([l.MEDIA_ITEM_ADDED,l.MEDIA_ITEM_UPDATED,l.MEDIA_ITEM_DELETED],e=>{var a;(a=e.object_id)!=null&&a.startsWith("library://playlist")&&(i.value=!0)});h(t)});const u=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)=>(D(),w(y,{itemtype:"playlists",items:d.value,"show-duration":!1,"show-provider":!0,"show-favorites-only-filter":!0,"load-paged-data":_,"show-library":!0,"sort-keys":Object.keys(m),"update-available":i.value,title: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{G as default};
