import{d as Y,av as D,r as I,b as a,a9 as R,a as T,x as F,P as y,H as x,c as o,h as P,f as r,w as s,D as h,t as d,F as O,i as S,e as u,u as m,g as k,j}from"./index-BcUYXcPq.js";import{_ as q}from"./ProviderIcon.vue_vue_type_script_setup_true_lang-B54PMsCQ.js";import{B as A}from"./Button-70QbWoUa.js";import{L as z}from"./ListItem-Cq4V-Lz8.js";import{C}from"./Container-BixSAZes.js";import{e as G}from"./eventbus-CGRXT3Tn.js";import{V as U}from"./VToolbar-B-HEXsGH.js";import{q as X,r as E}from"./VListItem-DC0X47Q4.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./VContainer-CoH7hbKx.js";/* empty css              */const H={style:{"margin-bottom":"10px"}},J={class:"line-clamp-1"},K={class:"line-clamp-1"},de=Y({__name:"Players",setup(Q){const c=D(),l=I([]),V=a.subscribe_multi([R.PLAYER_CONFIG_UPDATED],()=>{_()});T(V),F(()=>Object.values(a.players).filter(e=>{var t;return e.available&&((t=a.getProvider(e.provider))==null?void 0:t.supported_features.includes(y.SYNC_PLAYERS))}));const _=async function(){l.value=(await a.getPlayerConfigs()).sort((e,t)=>p(e).localeCompare(p(t)))},w=function(e){a.removePlayerConfig(e),l.value=l.value.filter(t=>t.player_id!=e)},b=function(e,t){t in a.providers&&c.push(`/settings/editplayer/${e}`)},B=function(e){c.push(`/settings/editplayer/${e}/dsp`)},M=function(e){c.push("/settings/addgroup")},N=function(e){e.enabled=!e.enabled,a.savePlayerConfig(e.player_id,{enabled:e.enabled})},p=function(e){var t;return e.name||((t=a.players[e.player_id])==null?void 0:t.display_name)||e.default_name||e.player_id},$=function(e){window.open(e,"_blank")},L=function(e,t){var n,v,f;const i=[{label:"settings.configure",labelArgs:[],action:()=>{b(t.player_id,t.provider)},icon:"mdi-cog",disabled:!a.getProvider(t.provider)},{label:"open_dsp_settings",labelArgs:[],action:()=>{B(t.player_id)},icon:"mdi-equalizer"},{label:t.enabled?"settings.disable":"settings.enable",labelArgs:[],action:()=>{N(t)},icon:"mdi-cancel",hide:!a.getProvider(t.provider)},{label:"settings.documentation",labelArgs:[],action:()=>{var g;$(((g=a.getProviderManifest(t.provider))==null?void 0:g.documentation)||"")},icon:"mdi-bookshelf",disabled:!((n=a.getProviderManifest(t.provider))!=null&&n.documentation)},{label:"settings.delete",labelArgs:[],action:()=>{w(t.player_id)},icon:"mdi-delete",hide:!(!((v=a.players[t.player_id])!=null&&v.available)||(f=a.getProvider(t.provider))!=null&&f.supported_features.includes(y.REMOVE_PLAYER))}];G.emit("contextmenu",{items:i,posX:e.clientX,posY:e.clientY})};return x(()=>a.players,e=>{e&&_()},{immediate:!0}),(e,t)=>(o(),P("div",H,[r(U,{density:"compact",class:"titlebar",color:"transparent",style:{height:"55px"}},{title:s(()=>[h(d(e.$t("settings.players")),1)]),append:s(()=>[r(X,{color:"accent",variant:"outlined",onClick:M},{default:s(()=>[h(d(e.$t("settings.add_group_player")),1)]),_:1})]),_:1}),r(C,null,{default:s(()=>[(o(!0),P(O,null,S(l.value,i=>(o(),u(z,{key:i.player_id,"show-menu-btn":"",link:"",onMenu:n=>L(n,i),onClick:n=>b(i.player_id,i.provider)},{prepend:s(()=>{var n;return[r(q,{domain:((n=m(a).getProviderManifest(i.provider))==null?void 0:n.domain)||"",size:40,class:"listitem-media-thumb"},null,8,["domain"])]}),title:s(()=>[k("div",J,d(p(i)),1)]),subtitle:s(()=>{var n;return[k("div",K,d(((n=m(a).getProviderManifest(i.provider))==null?void 0:n.name)||i.provider),1)]}),append:s(()=>{var n;return[i.enabled?(n=m(a).players[i.player_id])!=null&&n.available?j("",!0):(o(),u(A,{key:1,icon:"",title:e.$t("settings.player_not_available")},{default:s(()=>[r(E,{icon:"mdi-timer-sand"})]),_:1},8,["title"])):(o(),u(A,{key:0,icon:"",title:e.$t("settings.player_disabled")},{default:s(()=>[r(E,{icon:"mdi-cancel"})]),_:1},8,["title"]))]}),_:2},1032,["onMenu","onClick"]))),128))]),_:1})]))}});export{de as default};
