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