import{C as R}from"./Container-Br6JH6Pm.js";import{U as v,c as C,a6 as _,bg as P,aU as h,ak as S,a0 as m,X as o,ah as U,F as u,Y as d,ab as w,E as I,ad as B,ar as E,a2 as $,aq as A,I as b,a1 as M,W as g,a4 as N,x as f,o as T,aY as W,b as D,aa as O,b6 as Y,bn as H}from"./index-B-lUZalq.js";import{W as L}from"./WidgetRow-DXupbFci.js";import{a as F}from"./PlayerCard-5XdZCTyl.js";import{V as J}from"./VToolbar-RljK0PC9.js";import{a as j,b as q}from"./VBtn-BPJ1JKW-.js";import{_ as V}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{T as x}from"./Toolbar-BvxWbi_E.js";import"./Button-kSJGA_Pw.js";import"./VContainer-DB65WVbe.js";/* empty css              */import"./PanelviewItemCompact-CIDxIfoQ.js";import"./MediaItemThumb-DapaMoP4.js";import"./NowPlayingBadge.vue_vue_type_style_index_0_lang-DnroVGI-.js";import"./VInput-BWBQqjuk.js";import"./VAlert-QHTIcuEJ.js";import"./VSlider-BCIrn4it.js";const z={class:"mr-3"},G={key:0},X=v({__name:"PlayersWidgetRow",props:{settings:{},editMode:{type:Boolean}},emits:["update:settings"],setup(y,{emit:n}){const a=C(()=>Object.values(_.players).filter(e=>P(e)).sort((e,t)=>e.name.toUpperCase()>t.name?.toUpperCase()?1:-1).sort((e,t)=>s(e)-s(t))),p=n;function c(e){N.activePlayerId=e.player_id}function s(e){return e.playback_state==h.PLAYING?0:e.playback_state==h.PAUSED?1:e.current_media&&e.powered?3:e.current_media?4:99}return(e,t)=>{const i=S("swiper-slide"),r=S("swiper");return o(),m("div",{class:U(`widget-row ${e.settings&&!e.settings.enabled?"disabled":""}`)},[u(J,{class:"header",color:"transparent"},{prepend:d(()=>[u(E,{icon:"mdi-speaker"})]),title:d(()=>[I("span",z,B(e.$t("players")),1)]),append:d(()=>[e.editMode?(o(),m("div",G,[u(j,{icon:e.settings.enabled?"mdi-checkbox-marked":"mdi-checkbox-blank-outline",onClick:t[0]||(t[0]=l=>p("update:settings",{...e.settings,enabled:!e.settings.enabled}))},null,8,["icon"])])):w("",!0)]),_:1}),u(r,{"slides-per-view":"auto","space-between":15,"free-mode":!1,navigation:!$(A)({breakpoint:"mobile"}),mousewheel:{forceToAxis:!0,releaseOnEdges:!0}},{default:d(()=>[(o(!0),m(b,null,M(a.value,l=>(o(),g(i,{key:l.player_id},{default:d(()=>[(o(),g(F,{id:l.player_id,key:l.player_id,player:l,"show-volume-control":!1,"show-menu-button":!1,"show-sub-players":!1,"show-sync-controls":!1,style:{width:"305px",height:"70px"},onClick:k=>c(l)},null,8,["id","player","onClick"]))]),_:2},1024))),128))]),_:1},8,["navigation"])],2)}}}),K=V(X,[["__scopeId","data-v-955fe413"]]),Q=v({__name:"HomeWidgetRows",props:{editMode:{type:Boolean,default:!1}},setup(y){const n=f([]),a=f({}),p=async function(){const s=localStorage.getItem("widgetRowSettings");a.value=s?JSON.parse(s):{players:{position:0,enabled:!0}};const e=await _.getRecommendations(),t=[];let i=0;for(const r of e){i++;const l=a.value[r.uri]||{position:i,enabled:!0},k=r.translation_key?O(`recommendations.${r.translation_key}`,r.name):r.name;t.push({...r,settings:l,title:k}),n.value=t}};T(()=>{p();const s=_.subscribe(W.MEDIA_ITEM_PLAYED,async e=>{e.data&&!e.data.is_playing&&p()});D(s)});const c=function(s,e){for(const t of n.value)if(t.uri===s){t.settings=e;break}a.value[s]=e,localStorage.setItem("widgetRowSettings",JSON.stringify(a.value))};return(s,e)=>(o(),m(b,null,[a.value.players?.enabled||s.editMode?(o(),g(K,{key:0,settings:a.value.players,"edit-mode":s.editMode,"onUpdate:settings":e[0]||(e[0]=t=>c("players",t))},null,8,["settings","edit-mode"])):w("",!0),(o(!0),m(b,null,M(n.value.filter(t=>t.items.length&&(t.settings.enabled||s.editMode)).sort((t,i)=>t.settings.position-i.settings.position),t=>(o(),m("div",{key:t.uri},[n.value.length?(o(),g(L,{key:0,"widget-row":t,"edit-mode":s.editMode,"onUpdate:settings":i=>c(t.uri,i)},null,8,["widget-row","edit-mode","onUpdate:settings"])):w("",!0)]))),128))],64))}}),Z=v({__name:"HomeView",setup(y){const n=f(localStorage.getItem("frontend.settings.hide_settings")=="true"),a=f(!1),p=C(()=>[{label:"settings.settings",icon:"mdi-cog-outline",action:()=>{Y.push({path:"settings"})},hide:n.value},{label:a.value?"homescreen_edit_disable":"homescreen_edit_enable",icon:"mdi-pencil",action:()=>{a.value=!a.value}}]);return(c,s)=>(o(),m("div",null,[u(x,{title:"Music Assistant","show-loading":!0,"enforce-overflow-menu":!0,"menu-items":p.value},null,8,["menu-items"]),u(R,{variant:"panel"},{default:d(()=>[(o(),g(H,null,{fallback:d(()=>[u(q,{indeterminate:""})]),default:d(()=>[I("div",null,[u(Q,{"edit-mode":a.value},null,8,["edit-mode"])])]),_:1}))]),_:1})]))}}),we=V(Z,[["__scopeId","data-v-d5f47ad5"]]);export{we as default};
