import{v as D,aa as F,r as G,L as t,ak as U,b as x,c as I,w as Y,ae as z,y as o,E as f,l as r,A as n,R as g,N as p,z as l,n as O,F as P,G as C,I as h,P as k,af as S,x as d,B as V}from"./index-20675090.js";import{L as A,_ as E,B}from"./ListItem-e092a77b.js";import{C as j}from"./Container-e8fef44d.js";import{j as W,k as N}from"./forwardRefs-67412654.js";import{V as q}from"./VCard-30020028.js";import{e as H}from"./VMenu-ae4158ef.js";import{V as J}from"./VToolbar-7174c765.js";/* empty css              */import"./VCardText-5e149cd1.js";const K={style:{"margin-bottom":"10px"}},Q={class:"line-clamp-1"},X={class:"line-clamp-1"},de=D({__name:"Players",setup(Z){const y=F(),c=G([]),$=t.subscribe_multi([U.PLAYER_CONFIG_UPDATED],()=>{v()});x($);const b=I(()=>Object.values(t.providers).filter(e=>e.available&&e.supported_features.includes(k.PLAYER_GROUP_CREATE)||e.supported_features.includes(k.SYNC_PLAYERS)).sort((e,i)=>(e.name||t.providerManifests[e.domain].name).toUpperCase()>(i.name||t.providerManifests[i.domain].name).toUpperCase()?1:-1)),v=async function(){c.value=(await t.getPlayerConfigs()).sort((e,i)=>m(e).localeCompare(m(i)))},w=function(e){t.removePlayerConfig(e),c.value=c.value.filter(i=>i.player_id!=e)},u=function(e){e in t.players&&y.push(`/settings/editplayer/${e}`)},L=function(e){y.push(`/settings/addgroup/${e}`)},M=function(e){e.enabled=!e.enabled,t.savePlayerConfig(e.player_id,{enabled:e.enabled})},m=function(e){var i;return e.name||((i=t.players[e.player_id])==null?void 0:i.display_name)||e.default_name||e.player_id},R=function(e){window.open(e,"_blank")};return Y(()=>t.players,e=>{e&&v()},{immediate:!0}),(e,i)=>{const T=z("hold");return o(),f("div",K,[r(J,{density:"compact",class:"titlebar",color:"transparent",style:{height:"55px"}},{title:n(()=>[g(p(e.$t("settings.players")),1)]),append:n(()=>[b.value.length?(o(),l(H,{key:0},{activator:n(({props:a})=>[r(W,O(a,{color:"accent",variant:"outlined"}),{default:n(()=>[g(p(e.$t("settings.add_group_player")),1)]),_:2},1040)]),default:n(()=>[r(q,{density:"compact"},{default:n(()=>[(o(!0),f(P,null,C(b.value,a=>(o(),l(A,{key:a.instance_id,density:"compact",style:{"padding-top":"0","padding-bottom":"0","margin-bottom":"0"},title:a.name,onClick:_=>L(a.instance_id)},{prepend:n(()=>[r(E,{domain:a.domain,size:26,class:"media-thumb",style:{"margin-left":"10px"}},null,8,["domain"])]),_:2},1032,["title","onClick"]))),128))]),_:1})]),_:1})):h("",!0)]),_:1}),r(j,null,{default:n(()=>[(o(!0),f(P,null,C(c.value,a=>{var _;return S((o(),l(A,{key:a.player_id,link:"","context-menu-items":[{label:"settings.configure",labelArgs:[],action:()=>{u(a.player_id)},icon:"mdi-cog"},{label:a.enabled?"settings.disable":"settings.enable",labelArgs:[],action:()=>{M(a)},icon:"mdi-cancel"},{label:"settings.documentation",labelArgs:[],action:()=>{var s;R((s=d(t).getProviderManifest(a.provider))==null?void 0:s.documentation)},icon:"mdi-bookshelf",disabled:!((_=d(t).getProviderManifest(a.provider))!=null&&_.documentation)},{label:"settings.delete",labelArgs:[],action:()=>{w(a.player_id)},icon:"mdi-delete"}],onClick:s=>u(a.player_id)},{prepend:n(()=>{var s;return[r(E,{domain:(s=d(t).getProviderManifest(a.provider))==null?void 0:s.domain,size:40,class:"listitem-media-thumb"},null,8,["domain"])]}),title:n(()=>[V("div",Q,p(m(a)),1)]),subtitle:n(()=>{var s;return[V("div",X,p(((s=d(t).getProviderManifest(a.provider))==null?void 0:s.name)||a.provider),1)]}),append:n(()=>{var s;return[a.enabled?(s=d(t).players[a.player_id])!=null&&s.available?h("",!0):(o(),l(B,{key:1,icon:"",title:e.$t("settings.player_not_available")},{default:n(()=>[r(N,{icon:"mdi-timer-sand"})]),_:1},8,["title"])):(o(),l(B,{key:0,icon:"",title:e.$t("settings.player_disabled")},{default:n(()=>[r(N,{icon:"mdi-cancel"})]),_:1},8,["title"]))]}),_:2},1032,["context-menu-items","onClick"])),[[T,()=>{u(a.player_id)}]])}),128))]),_:1})])}}});export{de as default};
