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