import{Q as T,x as w,a4 as a,aS as Y,b as I,c as S,a6 as P,w as D,Z as h,B as r,U as n,S as o,al as k,aa as d,G,$ as O,R as u,a9 as U,ak as A,a0 as m,W as B,bn as x,ay as F,bT as z,a3 as X}from"./index-orrnp8a1.js";import{_ as j}from"./ProviderIcon.vue_vue_type_style_index_0_lang-DgYavPcK.js";import{B as E,L as q}from"./ListItem-BOpEb2vA.js";import{C}from"./Container-C-MxRHLg.js";import{V as Q}from"./VToolbar-BlKUHnwt.js";import{a as W}from"./VBtn-BJolvyKt.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./VContainer-DvR1uhzJ.js";/* empty css              */const Z={style:{"margin-bottom":"10px"}},H={class:"line-clamp-1"},J={class:"line-clamp-1"},de=T({__name:"Players",setup(K){const c=x(),l=w([]),V=a.subscribe_multi([Y.PLAYER_CONFIG_UPDATED],()=>{_()});I(V),S(()=>Object.values(a.players).filter(e=>{var t;return e.available&&((t=a.getProvider(e.provider))==null?void 0:t.supported_features.includes(P.SYNC_PLAYERS))}));const _=async function(){l.value=(await a.getPlayerConfigs()).sort((e,t)=>p(e).localeCompare(p(t)))},$=function(e){a.removePlayerConfig(e),l.value=l.value.filter(t=>t.player_id!=e)},b=function(e,t){a.getProvider(t)&&c.push(`/settings/editplayer/${e}`)},M=function(e){c.push(`/settings/editplayer/${e}/dsp`)},N=function(e){c.push("/settings/addgroup")},L=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},R=function(e,t){var s,v,y,g;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:()=>{M(t.player_id)},icon:"mdi-equalizer",hide:((s=a.players[t.player_id])==null?void 0:s.type)===F.GROUP},{label:t.enabled?"settings.disable":"settings.enable",labelArgs:[],action:()=>{L(t)},icon:"mdi-cancel",hide:!a.getProvider(t.provider)},{label:"settings.documentation",labelArgs:[],action:()=>{var f;z(((f=a.getProviderManifest(t.provider))==null?void 0:f.documentation)||"")},icon:"mdi-bookshelf",disabled:!((v=a.getProviderManifest(t.provider))!=null&&v.documentation)},{label:"settings.delete",labelArgs:[],action:()=>{$(t.player_id)},icon:"mdi-delete",hide:!(!((y=a.players[t.player_id])!=null&&y.available)||(g=a.getProvider(t.provider))!=null&&g.supported_features.includes(P.REMOVE_PLAYER))}];X.emit("contextmenu",{items:i,posX:e.clientX,posY:e.clientY})};return D(()=>a.players,e=>{e&&_()},{immediate:!0}),(e,t)=>(o(),h("div",Z,[r(Q,{density:"compact",class:"titlebar",color:"transparent",style:{height:"55px"}},{title:n(()=>[k(d(e.$t("settings.players")),1)]),append:n(()=>[r(W,{color:"accent",variant:"outlined",onClick:N},{default:n(()=>[k(d(e.$t("settings.add_group_player")),1)]),_:1})]),_:1}),r(C,null,{default:n(()=>[(o(!0),h(G,null,O(l.value,i=>(o(),u(q,{key:i.player_id,"show-menu-btn":"",link:"",onMenu:s=>R(s,i),onClick:s=>b(i.player_id,i.provider)},{prepend:n(()=>{var s;return[r(j,{domain:((s=m(a).getProviderManifest(i.provider))==null?void 0:s.domain)||"",size:40,class:"listitem-media-thumb"},null,8,["domain"])]}),title:n(()=>[B("div",H,d(p(i)),1)]),subtitle:n(()=>{var s;return[B("div",J,d(((s=m(a).getProviderManifest(i.provider))==null?void 0:s.name)||i.provider),1)]}),append:n(()=>{var s;return[i.enabled?(s=m(a).players[i.player_id])!=null&&s.available?U("",!0):(o(),u(E,{key:1,icon:"",title:e.$t("settings.player_not_available")},{default:n(()=>[r(A,{icon:"mdi-timer-sand"})]),_:1},8,["title"])):(o(),u(E,{key:0,icon:"",title:e.$t("settings.player_disabled")},{default:n(()=>[r(A,{icon:"mdi-cancel"})]),_:1},8,["title"]))]}),_:2},1032,["onMenu","onClick"]))),128))]),_:1})]))}});export{de as default};
