import{C as R}from"./Container-BWpo4_AD.js";import{Q as f,x as u,o as b,a4 as p,aY as h,b as y,Z as g,S as d,G as M,$ as k,R as w,a9 as B,a8 as I,B as c,U as m,bl as C,W as N}from"./index-DxANhO1k.js";import{W as V}from"./WidgetRow-DqIYoO3J.js";import{T as E}from"./Toolbar-C8FmMECG.js";import{b as U}from"./VBtn-BKDLm-Pz.js";import{_ as $}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./VContainer-Dt14Bz2c.js";/* empty css              */import"./PanelviewItemCompact-CK0jmgCV.js";import"./MediaItemThumb-CFMeVmOC.js";import"./VCheckbox-DjCmGFGI.js";import"./VCheckboxBtn-CJJKU0Jh.js";import"./VToolbar-CF24PT7R.js";import"./VAlert-C_Jv1M-3.js";const x=f({__name:"HomeWidgetRows",props:{editMode:{type:Boolean,default:!1}},setup(_){const s=u([]),i=async function(){const e=localStorage.getItem("widgetRowSettings"),o=e?JSON.parse(e):{},t=await p.getRecommendations(),n=[];let r=0;for(const a of t){r++;const S=o[a.uri]||{position:r,enabled:!0},v=a.translation_key?I(`recommendations.${a.translation_key}`,a.name):a.name;n.push({...a,settings:S,title:v}),s.value=n}};b(()=>{i();const e=p.subscribe(h.MEDIA_ITEM_PLAYED,async o=>{o.data&&!o.data.is_playing&&i()});y(e)});const l=function(e,o){for(const r of s.value)if(r.uri===e){r.settings=o;break}const t=localStorage.getItem("widgetRowSettings"),n=t?JSON.parse(t):{};n[e]=o,localStorage.setItem("widgetRowSettings",JSON.stringify(n))};return(e,o)=>(d(!0),g(M,null,k(s.value.filter(t=>t.settings.enabled||e.editMode).sort((t,n)=>t.settings.position-n.settings.position),t=>(d(),g("div",{key:t.uri},[s.value.length?(d(),w(V,{key:0,"widget-row":t,"edit-mode":e.editMode,"onUpdate:settings":n=>l(t.uri,n)},null,8,["widget-row","edit-mode","onUpdate:settings"])):B("",!0)]))),128))}}),T=f({__name:"HomeView",setup(_){const s=u(localStorage.getItem("frontend.settings.hide_settings")=="true"),i=u(!1),l={label:"homescreen_edit",icon:"mdi-pencil",action:()=>{i.value=!i.value}};return(e,o)=>(d(),g("div",null,[c(E,{title:"Music Assistant","show-loading":!0,"enforce-overflow-menu":!0,"menu-items":s.value?[l]:[{label:"settings.settings",icon:"mdi-cog-outline",action:()=>{e.$router.push({path:"settings"})}},l]},null,8,["menu-items"]),c(R,{variant:"panel"},{default:m(()=>[(d(),w(C,null,{fallback:m(()=>[c(U,{indeterminate:""})]),default:m(()=>[N("div",null,[c(x,{"edit-mode":i.value},null,8,["edit-mode"])])]),_:1}))]),_:1})]))}}),q=$(T,[["__scopeId","data-v-fc1209ac"]]);export{q as default};
