import{B as g}from"./Button-aYXDVBuV.js";import{C as T}from"./Container-C2H2nkE9.js";import{L as w}from"./ListItem-9a22IUe_.js";import{d as I,i as Y,m as a,a_ as C,l as D,N as F,P as m,ad as x,c as _,o as i,b as r,w as s,e as o,q as P,n as z,F as h,r as k,V as q,v as E,aA as S,b4 as V,t as d,aW as W,g as A,u as b,a as M,bJ as X,be as R,ce as j,k as J}from"./index-DkwJyNnc.js";import{V as H}from"./VToolbar-DS_w-ycX.js";import{a as K}from"./VBtn-Bgp7shVZ.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./VContainer-D1a7FIB6.js";/* empty css              */const Q={style:{"margin-bottom":"10px"}},Z={class:"line-clamp-1"},ee={class:"line-clamp-1"},ce=I({__name:"Players",setup(te){const p=X(),l=Y([]),$=a.subscribe_multi([C.PLAYER_CONFIG_UPDATED],()=>{y()});D($);const v=F(()=>Object.values(a.providers).filter(e=>e.available&&e.supported_features.includes(m.CREATE_GROUP_PLAYER)).sort((e,t)=>(e.name||a.providerManifests[e.domain].name).toUpperCase()>(t.name||a.providerManifests[t.domain].name).toUpperCase()?1:-1)),y=async function(){l.value=(await a.getPlayerConfigs()).filter(e=>e.provider!="builtin_player").sort((e,t)=>c(e).localeCompare(c(t)))},B=function(e){a.removePlayer(e).then(()=>{l.value=l.value.filter(t=>t.player_id!=e)})},f=function(e,t){a.getProvider(t)&&p.push(`/settings/editplayer/${e}`)},L=function(e){p.push(`/settings/editplayer/${e}/dsp`)},N=function(e){p.push(`/settings/addgroup/${e.lookup_key}`)},O=function(e){const t=a.players[e];return t?t.type===R.GROUP?a.getProvider(t.provider)?.supported_features.includes(m.REMOVE_GROUP_PLAYER):a.getProvider(t.provider)?.supported_features.includes(m.REMOVE_PLAYER):!0},U=function(e){e.enabled=!e.enabled,a.savePlayerConfig(e.player_id,{enabled:e.enabled})},c=function(e){return e.name||a.players[e.player_id]?.name||e.default_name||e.player_id},G=function(e,t){const n=[{label:"settings.configure",labelArgs:[],action:()=>{f(t.player_id,t.provider)},icon:"mdi-cog",disabled:!a.getProvider(t.provider)},{label:"open_dsp_settings",labelArgs:[],action:()=>{L(t.player_id)},icon:"mdi-equalizer",hide:a.players[t.player_id]?.type===R.GROUP},{label:t.enabled?"settings.disable":"settings.enable",labelArgs:[],action:()=>{U(t)},icon:"mdi-cancel",hide:!a.getProvider(t.provider)},{label:"settings.documentation",labelArgs:[],action:()=>{j(a.getProviderManifest(t.provider)?.documentation||"")},icon:"mdi-bookshelf",disabled:!a.getProviderManifest(t.provider)?.documentation},{label:"settings.delete",labelArgs:[],action:()=>{B(t.player_id)},icon:"mdi-delete",hide:!O(t.player_id)}];J.emit("contextmenu",{items:n,posX:e.clientX,posY:e.clientY})};return x(()=>a.players,e=>{e&&y()},{immediate:!0}),(e,t)=>(i(),_("div",Q,[r(H,{density:"compact",class:"titlebar",color:"transparent",style:{height:"55px"}},{title:s(()=>[V(d(e.$t("settings.players")),1)]),append:s(()=>[v.value.length>0?(i(),o(W,{key:0,scrim:""},{activator:s(({props:n})=>[r(K,S(n,{color:"accent",variant:"outlined"}),{default:s(()=>[V(d(e.$t("settings.add_group_player")),1)]),_:1},16)]),default:s(()=>[r(z,{density:"compact"},{default:s(()=>[(i(!0),_(h,null,k(v.value,n=>(i(),o(q,{key:n.domain,style:{"padding-top":"0","padding-bottom":"0","margin-bottom":"0"},title:n.name,onClick:u=>N(n)},{prepend:s(()=>[r(E,{domain:n.domain,size:26,class:"media-thumb",style:{"margin-left":"10px"}},null,8,["domain"])]),_:2},1032,["title","onClick"]))),128))]),_:1})]),_:1})):P("",!0)]),_:1}),r(T,null,{default:s(()=>[(i(!0),_(h,null,k(l.value,n=>(i(),o(w,{key:n.player_id,"show-menu-btn":"",link:"",onMenu:u=>G(u,n),onClick:u=>f(n.player_id,n.provider)},{prepend:s(()=>[r(E,{domain:b(a).getProviderManifest(n.provider)?.domain||"",size:40,class:"listitem-media-thumb"},null,8,["domain"])]),title:s(()=>[M("div",Z,d(c(n)),1)]),subtitle:s(()=>[M("div",ee,d(b(a).getProviderManifest(n.provider)?.name||n.provider),1)]),append:s(()=>[n.enabled?b(a).players[n.player_id]?.available?P("",!0):(i(),o(g,{key:1,icon:"",title:e.$t("settings.player_not_available")},{default:s(()=>[r(A,{icon:"mdi-timer-sand"})]),_:1},8,["title"])):(i(),o(g,{key:0,icon:"",title:e.$t("settings.player_disabled")},{default:s(()=>[r(A,{icon:"mdi-cancel"})]),_:1},8,["title"]))]),_:2},1032,["onMenu","onClick"]))),128))]),_:1})]))}});export{ce as default};
