import{l as y,Q as _,r as o,o as d,L as i,P as v,ai as r,b,y as h,z as E,x as w,M as p,aj as l,K as T}from"./index-ebe4cd91.js";import{_ as I}from"./ItemsListing.vue_vue_type_style_index_0_lang-1ef061d8.js";import"./ListviewItem-5151f17f.js";import"./MediaItemThumb.vue_vue_type_style_index_0_lang-bf2386aa.js";import"./ListItem-a20c73ec.js";import"./VImg-b5692565.js";import"./VMenu-86ca5efe.js";import"./index-bda4e7b4.js";import"./VListItem-0df8c60b.js";import"./VCheckboxBtn-fcc73f36.js";import"./VCard-46ebf6a3.js";/* empty css                             */import"./PanelviewItem.vue_vue_type_style_index_0_lang-516932fb.js";import"./contextmenu-b7cc1c45.js";import"./eventbus-d154090d.js";import"./Alert-d031836e.js";import"./Container-1375a850.js";/* empty css              */import"./VToolbar-76e5fae8.js";import"./VTextField-034239e4.js";import"./VBadge-0ad57746.js";import"./VRow-03e92c8f.js";const q=y({__name:"LibraryPlaylists",setup(A){const{t:u}=_(),m=o([]),s=o(!1),n=o([]),c=async function(t){if(t.refresh){for(i.startSync([p.PLAYLIST]),await l(250);i.syncTasks.value.length>0&&i.syncTasks.value.filter(e=>e.media_types.includes(p.PLAYLIST)).length!=0;)await l(500);await l(500)}return s.value=!1,await i.getLibraryPlaylists(t.favoritesOnly||void 0,t.search,t.limit,t.offset,t.sortBy)};d(()=>{for(const e of Object.values(i.providers).filter(a=>a.available&&a.supported_features.includes(v.PLAYLIST_CREATE)))n.value.push({label:"create_playlist",labelArgs:[e.name],action:()=>{f(e.instance_id)},icon:"mdi-sync"});const t=i.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")&&(s.value=!0)});b(t)});const f=async function(t){const e=prompt(u("new_playlist_name"));e&&await i.createPlaylist(e,t).then(()=>location.reload()).catch(a=>alert(a))};return(t,e)=>(h(),E(I,{itemtype:"playlists",items:m.value,"show-duration":!1,"show-provider":!0,"show-favorites-only-filter":!0,"load-data":c,"show-library":!0,"sort-keys":["sort_name","timestamp_added DESC"],"update-available":s.value,title:w(T)("bp4")?t.$t("playlists"):"","allow-key-hooks":!0,"show-search-button":!0,"context-menu-items":n.value},null,8,["items","update-available","title","context-menu-items"]))}});export{q as default};
