import{d as F,ak as I,r as R,b as a,a7 as T,a as S,x,P as g,K as C,c as r,h as P,f as o,w as i,W as h,t as d,e as c,j as k,F as D,i as O,u as p,g as w}from"./index-CLKg64ON.js";import{_ as j,e as G}from"./eventbus-D-xzWv8v.js";import{B as E}from"./Button-F8l3l_P8.js";import{L as U}from"./ListItem-f79Nhqh7.js";import{C as W}from"./Container-ZPskS02H.js";import{V as X}from"./VToolbar-DSn0RyUD.js";import{s as z,w as V}from"./VListItem-B_TSjQ1y.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";/* empty css              */const K={style:{"margin-bottom":"10px"}},q={class:"line-clamp-1"},H={class:"line-clamp-1"},oe=F({__name:"Players",setup(J){const m=I(),l=R([]),A=a.subscribe_multi([T.PLAYER_CONFIG_UPDATED],()=>{_()});S(A);const B=x(()=>Object.values(a.players).filter(e=>{var t;return e.available&&((t=a.getProvider(e.provider))==null?void 0:t.supported_features.includes(g.SYNC_PLAYERS))})),_=async function(){l.value=(await a.getPlayerConfigs()).sort((e,t)=>u(e).localeCompare(u(t)))},M=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}`)},N=function(e){m.push("/settings/addgroup")},L=function(e){e.enabled=!e.enabled,a.savePlayerConfig(e.player_id,{enabled:e.enabled})},u=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")},Y=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:()=>{L(t)},icon:"mdi-cancel",hide:!a.getProvider(t.provider)},{label:"settings.documentation",labelArgs:[],action:()=>{var y;$(((y=a.getProviderManifest(t.provider))==null?void 0:y.documentation)||"")},icon:"mdi-bookshelf",disabled:!((n=a.getProviderManifest(t.provider))!=null&&n.documentation)},{label:"settings.delete",labelArgs:[],action:()=>{M(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(g.REMOVE_PLAYER))}];G.emit("contextmenu",{items:s,posX:e.clientX,posY:e.clientY})};return C(()=>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(()=>[B.value.length?(r(),c(z,{key:0,color:"accent",variant:"outlined",onClick:N},{default:i(()=>[h(d(e.$t("settings.add_group_player")),1)]),_:1})):k("",!0)]),_:1}),o(W,null,{default:i(()=>[(r(!0),P(D,null,O(l.value,s=>(r(),c(U,{key:s.player_id,"show-menu-btn":"",link:"",onMenu:n=>Y(n,s),onClick:n=>v(s.player_id,s.provider)},{prepend:i(()=>{var n;return[o(j,{domain:((n=p(a).getProviderManifest(s.provider))==null?void 0:n.domain)||"",size:40,class:"listitem-media-thumb"},null,8,["domain"])]}),title:i(()=>[w("div",q,d(u(s)),1)]),subtitle:i(()=>{var n;return[w("div",H,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?k("",!0):(r(),c(E,{key:1,icon:"",title:e.$t("settings.player_not_available")},{default:i(()=>[o(V,{icon:"mdi-timer-sand"})]),_:1},8,["title"])):(r(),c(E,{key:0,icon:"",title:e.$t("settings.player_disabled")},{default:i(()=>[o(V,{icon:"mdi-cancel"})]),_:1},8,["title"]))]}),_:2},1032,["onMenu","onClick"]))),128))]),_:1})]))}});export{oe as default};
