import{d as R,aj as T,r as Y,b as n,af as F,a as G,z as I,P as y,J as U,c as i,g as p,f as r,w as s,H as v,t as c,e as l,G as j,F as P,h as C,j as h,u as m,i as k}from"./index-2dd0c7d2.js";import{C as z,_ as V}from"./Container-fdf4c1f5.js";import{B as M}from"./Button-69b906cf.js";import{L as D}from"./ListItem-87435fbb.js";import{e as O}from"./eventbus-d154090d.js";import{w as S,V as x,q as w}from"./VListItem-cb387084.js";import{V as X}from"./VCard-907b4685.js";import{V as q}from"./VMenu-97c1c955.js";import{V as H}from"./VToolbar-6047eebf.js";import"./_plugin-vue_export-helper-c27b6911.js";/* empty css              */import"./VCardText-0ed41581.js";const J={style:{"margin-bottom":"10px"}},W={class:"line-clamp-1"},K={class:"line-clamp-1"},ue=R({__name:"Players",setup(Q){const _=T(),d=Y([]),A=n.subscribe_multi([F.PLAYER_CONFIG_UPDATED],()=>{b()});G(A);const f=I(()=>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)))},E=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}`)},$=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:()=>{E(a.player_id)},icon:"mdi-delete"}];O.emit("contextmenu",{items:t,posX:e.clientX,posY:e.clientY})};return U(()=>n.players,e=>{e&&b()},{immediate:!0}),(e,a)=>(i(),p("div",J,[r(H,{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(q,{key:0,scrim:""},{activator:s(({props:t})=>[r(S,j(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=>$(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(z,null,{default:s(()=>[(i(!0),p(P,null,C(d.value,t=>(i(),l(D,{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",W,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(M,{key:1,icon:"",title:e.$t("settings.player_not_available")},{default:s(()=>[r(w,{icon:"mdi-timer-sand"})]),_:1},8,["title"])):(i(),l(M,{key:0,icon:"",title:e.$t("settings.player_disabled")},{default:s(()=>[r(w,{icon:"mdi-cancel"})]),_:1},8,["title"]))]}),_:2},1032,["onMenu","onClick"]))),128))]),_:1})]))}});export{ue as default};
