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