import{al as r,M as n,L as o,v as t,am as c,P as p}from"./index-0b85ac09.js";import{e as s}from"./eventbus-d154090d.js";const u=function(a){var e;for(const i of a.provider_mappings)if(i.available&&((e=o.providers[i.provider_instance])!=null&&e.available))return!0;return!1},f=function(a){var e;for(const i of a.provider_mappings)if((e=o.providers[i.provider_instance])!=null&&e.supported_features.includes(p.SIMILAR_TRACKS))return!0;return!1},y=function(a,e){const i=[];if(a.length==0||!u(a[0]))return i;let l=r.PLAY,d=r.NEXT;return(a.length>10||[n.ALBUM,n.PLAYLIST].includes(a[0].media_type))&&(l=r.REPLACE,d=r.REPLACE_NEXT),a.length==1&&e&&e.uri!=a[0].uri&&(e.media_type==n.PLAYLIST&&i.push({label:"play_playlist_from",action:()=>{o.playMedia(e,r.REPLACE,!1,a[0].item_id)},icon:"mdi-play-circle-outline",labelArgs:[]}),e.media_type==n.ALBUM&&i.push({label:"play_album_from",action:()=>{o.playMedia(e,r.REPLACE,!1,a[0].item_id)},icon:"mdi-play-circle-outline",labelArgs:[]})),i.push({label:"play_now",action:()=>{o.playMedia(a,l)},icon:"mdi-play-circle-outline",labelArgs:[]}),f(a[0])&&i.push({label:"play_radio",action:()=>{o.playMedia(a,l,!0)},icon:"mdi-radio-tower",labelArgs:[]}),(a.length===1||a[0].media_type===n.TRACK)&&i.push({label:"play_next",action:()=>{o.playMedia(a,d)},icon:"mdi-skip-next-circle-outline",labelArgs:[]}),i.push({label:"add_queue",action:()=>{o.playMedia(a,r.ADD)},icon:"mdi-playlist-plus",labelArgs:[]}),i},g=function(a,e){const i=[];if(a.length==0)return i;if(a.length===1&&a[0]!==e&&u(a[0])&&i.push({label:"show_info",labelArgs:[],action:()=>{var l;t.push({name:a[0].media_type,params:{itemId:a[0].item_id,provider:a[0].provider},query:{album:"album"in a[0]?(l=a[0].album)==null?void 0:l.uri:""}})},icon:"mdi-information-outline"}),a.length===1&&u(a[0])&&"artists"in a[0]&&a[0].artists.length===1)for(const l of a[0].artists)i.push({label:"goto_artist",labelArgs:[l.name],action:()=>{t.push({name:"artist",params:{itemId:l.item_id,provider:l.provider}})},icon:"mdi-account-music"});if(a.length===1&&u(a[0])&&"album"in a[0]&&a[0].album&&i.push({label:"goto_album",labelArgs:[a[0].album.name],action:()=>{t.push({name:"album",params:{itemId:a[0].album.item_id,provider:a[0].album.provider}})},icon:"mdi-album"}),a.length===1&&(a[0]==e||!u(a[0]))&&i.push({label:"refresh_item",labelArgs:[],action:async()=>{await o.refreshItem(a[0]),t.go(0)},icon:"mdi-refresh"}),a[0].provider!="library"&&u(a[0])&&i.push({label:"add_library",labelArgs:[],action:()=>{for(const l of a)o.addItemToLibrary(l)},icon:"mdi-bookshelf"}),a[0].provider=="library"&&i.push({label:"remove_library",labelArgs:[],action:()=>{if(confirm(c("confirm_library_remove"))){for(const l of a)o.removeItemFromLibrary(l.media_type,l.item_id);a[0].item_id==(e==null?void 0:e.item_id)?t.go(-1):t.go(0)}},icon:"mdi-bookshelf"}),a[0].favorite||i.push({label:"favorites_add",labelArgs:[],action:()=>{for(const l of a)o.addItemToFavorites(l),l.favorite=!0},icon:"mdi-heart-outline"}),a[0].favorite&&i.push({label:"favorites_remove",labelArgs:[],action:()=>{for(const l of a)o.removeItemFromFavorites(l.media_type,l.item_id),l.favorite=!1},icon:"mdi-heart"}),e&&e.media_type===n.PLAYLIST){const l=e;a[0].media_type===n.TRACK&&l.is_editable&&i.push({label:"remove_playlist",labelArgs:[],action:()=>{o.removePlaylistTracks(l.item_id,a.map(d=>d.position))},icon:"mdi-minus-circle-outline"})}return a[0].media_type==="track"&&i.push({label:"add_playlist",labelArgs:[],action:()=>{s.emit("playlistdialog",{items:a,parentItem:e})},icon:"mdi-plus-circle-outline"}),i};export{g as a,y as g,u as i};
