import{C as P}from"./Container-CEbFgC5b.js";import{d as y,O as S,v as w,bk as $,aV as h,N as C,c as m,o,n as x,b as u,w as c,e as _,a as V,t as B,F as b,g as M,h as g,s as I,r as v,m as U,a$ as E,q as N,$ as T,br as A}from"./index-Bn2Tzsay.js";import{W as D}from"./WidgetRow-QNz25d2y.js";import{a as O}from"./PlayerCard-85PtdNO1.js";import{V as W}from"./VToolbar-Z0nE2qFc.js";import{V as H,b as L}from"./VBtn-BQk37KYJ.js";import{_ as R}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{T as F}from"./Toolbar-Ba4dAxS1.js";import"./index-CBho6rsP.js";import"./VContainer-CRIwFZfO.js";/* empty css              */import"./PanelviewItemCompact-By5cXXTW.js";import"./NowPlayingBadge.vue_vue_type_style_index_0_lang-DCLVCnPO.js";import"./VInput-C_1AW61Q.js";import"./MediaItemThumb-B7hfZSf2.js";import"./VAlert-Bj5fXNhB.js";import"./Button-r9Wpw3CQ.js";import"./VSlider-DnweLLtQ.js";const J={class:"mr-3"},Y={key:0},j=y({__name:"PlayersWidgetRow",props:{settings:{},editMode:{type:Boolean}},emits:["update:settings"],setup(s,{emit:n}){const i=S(()=>Object.values(w.players).filter(e=>$(e)).sort((e,t)=>e.name.toUpperCase()>t.name?.toUpperCase()?1:-1).sort((e,t)=>a(e)-a(t))),p=n;function f(e){I.activePlayerId=e.player_id}function a(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 r=C("swiper-slide"),l=C("swiper");return o(),m("div",{class:x(`widget-row ${s.settings&&!s.settings.enabled?"disabled":""}`)},[u(W,{class:"header",color:"transparent"},{title:c(()=>[V("span",J,B(e.$t("players")),1)]),append:c(()=>[s.editMode?(o(),m("div",Y,[u(H,{icon:s.settings.enabled?"mdi-checkbox-marked":"mdi-checkbox-blank-outline",onClick:t[0]||(t[0]=d=>p("update:settings",{...s.settings,enabled:!s.settings.enabled}))},null,8,["icon"])])):_("",!0)]),_:1}),u(l,{"slides-per-view":"auto","space-between":15,"free-mode":!1,navigation:!1,mousewheel:{forceToAxis:!0,releaseOnEdges:!0}},{default:c(()=>[(o(!0),m(b,null,M(i.value,d=>(o(),g(r,{key:d.player_id},{default:c(()=>[(o(),g(O,{id:d.player_id,key:d.player_id,player:d,"show-volume-control":!1,"show-menu-button":!1,"show-sub-players":!1,"show-sync-controls":!1,style:{width:"305px"},onClick:k=>f(d)},null,8,["id","player","onClick"]))]),_:2},1024))),128))]),_:1})],2)}}}),q=R(j,[["__scopeId","data-v-771a3548"]]),z=y({__name:"HomeWidgetRows",props:{editMode:{type:Boolean,default:!1}},setup(s){const n=v([]),i=v({}),p=async function(){const a=localStorage.getItem("widgetRowSettings");i.value=a?JSON.parse(a):{players:{position:0,enabled:!0}};const e=await w.getRecommendations(),t=[];let r=0;for(const l of e){r++;const d=i.value[l.uri]||{position:r,enabled:!0},k=l.translation_key?T(`recommendations.${l.translation_key}`,l.name):l.name;t.push({...l,settings:d,title:k}),n.value=t}};U(()=>{p();const a=w.subscribe(E.MEDIA_ITEM_PLAYED,async e=>{e.data&&!e.data.is_playing&&p()});N(a)});const f=function(a,e){for(const t of n.value)if(t.uri===a){t.settings=e;break}i.value[a]=e,localStorage.setItem("widgetRowSettings",JSON.stringify(i.value))};return(a,e)=>(o(),m(b,null,[i.value.players?.enabled||s.editMode?(o(),g(q,{key:0,settings:i.value.players,"edit-mode":s.editMode,"onUpdate:settings":e[0]||(e[0]=t=>f("players",t))},null,8,["settings","edit-mode"])):_("",!0),(o(!0),m(b,null,M(n.value.filter(t=>t.items.length&&(t.settings.enabled||s.editMode)).sort((t,r)=>t.settings.position-r.settings.position),t=>(o(),m("div",{key:t.uri},[n.value.length?(o(),g(D,{key:0,"widget-row":t,"edit-mode":s.editMode,"onUpdate:settings":r=>f(t.uri,r)},null,8,["widget-row","edit-mode","onUpdate:settings"])):_("",!0)]))),128))],64))}}),G=y({__name:"HomeView",setup(s){const n=v(!1),i=S(()=>[{label:n.value?"homescreen_edit_disable":"homescreen_edit_enable",icon:"mdi-pencil",action:()=>{n.value=!n.value}}]);return(p,f)=>(o(),m("div",null,[u(F,{"show-loading":!0,"enforce-overflow-menu":!0,"menu-items":i.value,home:!0,color:"background",class:"editButton"},null,8,["menu-items"]),u(P,{variant:"comfortable"},{default:c(()=>[(o(),g(A,null,{fallback:c(()=>[u(L,{indeterminate:""})]),default:c(()=>[V("div",null,[u(z,{"edit-mode":n.value},null,8,["edit-mode"])])]),_:1}))]),_:1})]))}}),fe=R(G,[["__scopeId","data-v-d7f1cb62"]]);export{fe as default};
