import{k as v,d as h,w as _,o as n,c,b as s,y as o,z as a,$ as u,s as d,v as D,F as k,V as w,C as y,B as p,I as C,K as f,M as L}from"./index-DPl16C00.js";import{f as S,a as $}from"./utils-D98hIld_.js";import{b as B,a as T}from"./VCard-CJTiHjO-.js";import{V as N}from"./VTable-Cuh47MPV.js";import{_ as F}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{V as Z}from"./VToolbar-CbiRZXlD.js";import{V as j}from"./VDivider-Dr0TEagO.js";import{V as M}from"./forwardRefs-BQ8_JL2J.js";import{V as U}from"./VSelect-Dtf2lpH6.js";import"./index-w-dkzpPh.js";import"./VImg-B-97Yzkt.js";import"./VTextField-BpJ2unt4.js";import"./VInput-qFshDEqa.js";import"./group-bVGzOFiw.js";import"./scopeId-C7DHxJXu.js";import"./VCheckboxBtn-BS0WhS02.js";import"./VSelectionControl-MTkDIXZh.js";const W={class:"bg-primary"},z={class:"col-energy-min pa-6 py-3"},A={class:"col-energy-min pa-6 py-3"},E={class:"col-energy-min pa-6 py-3"},I={class:"col-energy-min pa-6 py-3"},K={class:"px-6 py-4"},P={class:"px-6 py-4"},q={class:"px-6 py-4"},G={key:0},H={class:"px-6 py-4"},J=v({__name:"DeviceSessionLog",props:{sessionLog:{}},setup(V){function m(t){const r=new Date(t.end+"Z").getTime(),e=new Date(t.start+"Z").getTime();let i=r-e;return $(i/1e3)}return(t,r)=>(n(),h(B,{class:"elevation-2 md:ma-4 w-full rounded-md"},{default:_(()=>[c(T,null,{default:_(()=>[c(N,{class:"sm:ma-4 border"},{default:_(()=>[s("thead",W,[s("tr",null,[s("th",z,o(a(u)("sessionlog.start")),1),s("th",A,o(a(u)("sessionlog.duration")),1),s("th",E,o(a(u)("consumed_solar_energy")),1),s("th",I,o(a(u)("consumed_energy")),1)])]),s("tbody",null,[(n(!0),d(k,null,D(t.sessionLog,(e,i)=>(n(),d("tr",{key:i,class:"odd:bg-surface even:bg-subgroup border-b text-center"},[s("td",K,o(a(w)(new Date(e.start+"Z"),"long")),1),s("td",P,o(m(e)),1),s("td",q,[e.consumed_energy!=0?(n(),d("span",G,o((e.solar_consumed_energy/e.consumed_energy*100).toFixed(0))+"% ",1)):y("",!0)]),s("td",H,o(a(S)(e.consumed_energy,"kWh")),1)]))),128))])]),_:1})]),_:1})]),_:1}))}}),O=F(J,[["__scopeId","data-v-69ed9d26"]]),Q={class:"pa-4 v-full bg-background d-flex min-height-screen justify-center"},R={key:0,class:"d-flex h-100 w-100 justify-center"},X={key:1},fe=v({__name:"SessionLog",setup(V){const m=p(),t=p(),r=p(!1),e=p(""),i=async function(l){r.value=!0,m.value=l!=""?await f.getDeviceSessionLog(l):[],r.value=!1},b=function(l){console.log(l),i(l)};return C(async()=>{t.value=await f.getAllDevices(!0),t.value.length>0&&(e.value=t.value[0].id,i(t.value[0].id))}),(l,g)=>(n(),d("div",null,[c(Z,{color:"transparent",title:a(L)("bp2")?a(u)("app.sessionlog"):""},{append:_(()=>[c(U,{modelValue:e.value,"onUpdate:modelValue":[g[0]||(g[0]=x=>e.value=x),b],class:"bg-surface ma-2",items:t.value?t.value:[],"item-title":"name","item-value":"id"},null,8,["modelValue","items"])]),_:1},8,["title"]),c(j),s("div",Q,[r.value?(n(),d("div",R,[c(M,{indeterminate:"",color:"primary"})])):(n(),d("div",X,[m.value?(n(),h(O,{key:0,"session-log":m.value},null,8,["session-log"])):y("",!0)]))])]))}});export{fe as default};
