import{B as P}from"./Button-BUjpiwEZ.js";import{C}from"./Container-ClW3AMEw.js";import{L as G}from"./ListItem-C-HNqEeC.js";import{d as I,r as T,v as a,a$ as w,q as S,O as D,P as d,ae as F,c as _,b as r,w as n,o as i,h as o,e as g,x as z,F as h,g as k,V as x,z as E,aB as W,b5 as R,t as p,aW as X,j as V,u as v,a as A,f as j,bg as M,ch as q,p as H}from"./index-CD7iYaFT.js";import{S as J}from"./constants-CXMxJR4j.js";import{V as K}from"./VToolbar-BQejIjUR.js";import{V as Q}from"./VBtn-B0XatuYF.js";import"./index-CBho6rsP.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./VContainer-DFqPxZ0T.js";/* empty css              */const Z={style:{"margin-bottom":"10px"}},ee={class:"line-clamp-1"},te={class:"line-clamp-1"},_e=I({__name:"Players",setup(ae){const u=j(),l=T([]),$=a.subscribe_multi([w.PLAYER_CONFIG_UPDATED],()=>{y()});S($);const b=D(()=>Object.values(a.providers).filter(e=>e.available&&(e.supported_features.includes(d.CREATE_GROUP_PLAYER)||e.supported_features.includes(d.SYNC_PLAYERS))).sort((e,t)=>(e.name||a.providerManifests[e.domain].name).toUpperCase()>(t.name||a.providerManifests[t.domain].name).toUpperCase()?1:-1)),y=async function(){l.value=(await a.getPlayerConfigs()).filter(e=>e.provider!="builtin_player").sort((e,t)=>c(e).localeCompare(c(t)))},B=function(e){a.removePlayer(e).then(()=>{l.value=l.value.filter(t=>t.player_id!=e)})},f=function(e,t){a.getProvider(t)&&u.push(`/settings/editplayer/${e}`)},L=function(e){u.push(`/settings/editplayer/${e}/dsp`)},O=function(e){u.push(`/settings/addgroup/${e.lookup_key}`)},N=function(e){const t=a.players[e];return t?t.type===M.GROUP?t.player_id.startsWith(J)||a.getProvider(t.provider)?.supported_features.includes(d.REMOVE_GROUP_PLAYER):a.getProvider(t.provider)?.supported_features.includes(d.REMOVE_PLAYER):!0},U=function(e){e.enabled=!e.enabled,a.savePlayerConfig(e.player_id,{enabled:e.enabled})},c=function(e){return e.name||a.players[e.player_id]?.name||e.default_name||e.player_id},Y=function(e,t){const s=[{label:"settings.configure",labelArgs:[],action:()=>{f(t.player_id,t.provider)},icon:"mdi-cog",disabled:!a.getProvider(t.provider)},{label:"open_dsp_settings",labelArgs:[],action:()=>{L(t.player_id)},icon:"mdi-equalizer",hide:a.players[t.player_id]?.type===M.GROUP},{label:t.enabled?"settings.disable":"settings.enable",labelArgs:[],action:()=>{U(t)},icon:"mdi-cancel",hide:!a.getProvider(t.provider)},{label:"settings.documentation",labelArgs:[],action:()=>{q(a.getProviderManifest(t.provider)?.documentation||"")},icon:"mdi-bookshelf",disabled:!a.getProviderManifest(t.provider)?.documentation},{label:"settings.delete",labelArgs:[],action:()=>{B(t.player_id)},icon:"mdi-delete",hide:!N(t.player_id)}];H.emit("contextmenu",{items:s,posX:e.clientX,posY:e.clientY})};return F(()=>a.players,e=>{e&&y()},{immediate:!0}),(e,t)=>(i(),_("div",Z,[r(K,{density:"compact",class:"titlebar",color:"transparent",style:{height:"55px"}},{title:n(()=>[R(p(e.$t("settings.players")),1)]),append:n(()=>[b.value.length>0?(i(),o(X,{key:0,scrim:""},{activator:n(({props:s})=>[r(Q,W(s,{color:"accent",variant:"outlined"}),{default:n(()=>[R(p(e.$t("settings.add_group_player")),1)]),_:1},16)]),default:n(()=>[r(z,{density:"compact"},{default:n(()=>[(i(!0),_(h,null,k(b.value,s=>(i(),o(x,{key:s.domain,style:{"padding-top":"0","padding-bottom":"0","margin-bottom":"0"},title:s.name,onClick:m=>O(s)},{prepend:n(()=>[r(E,{domain:s.domain,size:26,class:"media-thumb",style:{"margin-left":"10px"}},null,8,["domain"])]),_:2},1032,["title","onClick"]))),128))]),_:1})]),_:1})):g("",!0)]),_:1}),r(C,null,{default:n(()=>[(i(!0),_(h,null,k(l.value,s=>(i(),o(G,{key:s.player_id,"show-menu-btn":"",link:"",onMenu:m=>Y(m,s),onClick:m=>f(s.player_id,s.provider)},{prepend:n(()=>[r(E,{domain:v(a).getProviderManifest(s.provider)?.domain||"",size:40,class:"listitem-media-thumb"},null,8,["domain"])]),title:n(()=>[A("div",ee,p(c(s)),1)]),subtitle:n(()=>[A("div",te,p(v(a).getProviderManifest(s.provider)?.name||s.provider),1)]),append:n(()=>[s.enabled?v(a).players[s.player_id]?.available?g("",!0):(i(),o(P,{key:1,icon:"",title:e.$t("settings.player_not_available")},{default:n(()=>[r(V,{icon:"mdi-timer-sand"})]),_:1},8,["title"])):(i(),o(P,{key:0,icon:"",title:e.$t("settings.player_disabled")},{default:n(()=>[r(V,{icon:"mdi-cancel"})]),_:1},8,["title"]))]),_:2},1032,["onMenu","onClick"]))),128))]),_:1})]))}});export{_e as default};
