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