import{B as g}from"./Button-kSJGA_Pw.js";import{C as I}from"./Container-Br6JH6Pm.js";import{L as N}from"./ListItem-LV_WU--g.js";import{U as T,x as w,a6 as a,aY as C,b as D,c as x,a8 as m,w as F,a0 as _,X as r,F as i,Y as s,W as o,ab as P,a9 as z,I as h,a1 as k,Z as X,ac as E,G as S,as as V,ad as d,at as W,ar as M,a2 as b,E as R,bH as j,bb as A,cc as q,a5 as H}from"./index-B-lUZalq.js";import{V as Z}from"./VToolbar-RljK0PC9.js";import{a as J}from"./VBtn-BPJ1JKW-.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./VContainer-DB65WVbe.js";/* empty css              */const K={style:{"margin-bottom":"10px"}},Q={class:"line-clamp-1"},ee={class:"line-clamp-1"},pe=T({__name:"Players",setup(te){const c=j(),l=w([]),$=a.subscribe_multi([C.PLAYER_CONFIG_UPDATED],()=>{y()});D($);const v=x(()=>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)=>p(e).localeCompare(p(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)&&c.push(`/settings/editplayer/${e}`)},L=function(e){c.push(`/settings/editplayer/${e}/dsp`)},U=function(e){c.push(`/settings/addgroup/${e.lookup_key}`)},G=function(e){const t=a.players[e];return t?t.type===A.GROUP?a.getProvider(t.provider)?.supported_features.includes(m.REMOVE_GROUP_PLAYER):a.getProvider(t.provider)?.supported_features.includes(m.REMOVE_PLAYER):!0},O=function(e){e.enabled=!e.enabled,a.savePlayerConfig(e.player_id,{enabled:e.enabled})},p=function(e){return e.name||a.players[e.player_id]?.name||e.default_name||e.player_id},Y=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===A.GROUP},{label:t.enabled?"settings.disable":"settings.enable",labelArgs:[],action:()=>{O(t)},icon:"mdi-cancel",hide:!a.getProvider(t.provider)},{label:"settings.documentation",labelArgs:[],action:()=>{q(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:!G(t.player_id)}];H.emit("contextmenu",{items:n,posX:e.clientX,posY:e.clientY})};return F(()=>a.players,e=>{e&&y()},{immediate:!0}),(e,t)=>(r(),_("div",K,[i(Z,{density:"compact",class:"titlebar",color:"transparent",style:{height:"55px"}},{title:s(()=>[V(d(e.$t("settings.players")),1)]),append:s(()=>[v.value.length>0?(r(),o(W,{key:0,scrim:""},{activator:s(({props:n})=>[i(J,S(n,{color:"accent",variant:"outlined"}),{default:s(()=>[V(d(e.$t("settings.add_group_player")),1)]),_:1},16)]),default:s(()=>[i(z,{density:"compact"},{default:s(()=>[(r(!0),_(h,null,k(v.value,n=>(r(),o(X,{key:n.domain,style:{"padding-top":"0","padding-bottom":"0","margin-bottom":"0"},title:n.name,onClick:u=>U(n)},{prepend:s(()=>[i(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}),i(I,null,{default:s(()=>[(r(!0),_(h,null,k(l.value,n=>(r(),o(N,{key:n.player_id,"show-menu-btn":"",link:"",onMenu:u=>Y(u,n),onClick:u=>f(n.player_id,n.provider)},{prepend:s(()=>[i(E,{domain:b(a).getProviderManifest(n.provider)?.domain||"",size:40,class:"listitem-media-thumb"},null,8,["domain"])]),title:s(()=>[R("div",Q,d(p(n)),1)]),subtitle:s(()=>[R("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):(r(),o(g,{key:1,icon:"",title:e.$t("settings.player_not_available")},{default:s(()=>[i(M,{icon:"mdi-timer-sand"})]),_:1},8,["title"])):(r(),o(g,{key:0,icon:"",title:e.$t("settings.player_disabled")},{default:s(()=>[i(M,{icon:"mdi-cancel"})]),_:1},8,["title"]))]),_:2},1032,["onMenu","onClick"]))),128))]),_:1})]))}});export{pe as default};
