import{B as h,q as y,w as g,t as o,m as p,G as e,I as a,J as n,$ as m,E as l,F as x,aw as k,M as b,K as w,r as f,o as C,R as v,V as L,a8 as S,ax as $}from"./index-Cp3-A7ao.js";import{f as B,a as T}from"./utils-D98hIld_.js";import{b as N,a as F}from"./VCard-D5wKeDng.js";import{V as M}from"./VTable-MDvxnV4n.js";import{_ as Z}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{V as j,a as E}from"./VToolbar-jYZfQvPG.js";import{V as I}from"./VProgressCircular-DvjORuMu.js";import"./transition-BAtvBeuS.js";import"./VImg-tOz2PgiP.js";import"./index-DkrqsE6v.js";import"./resizeObserver-BoHHG32A.js";const U={class:"bg-primary"},W={class:"min-w-36 px-6 py-3"},q={class:"min-w-36 px-6 py-3"},A={class:"w-36 px-6 py-3"},G={class:"w-36 px-6 py-3"},J={class:"px-6 py-4"},K={class:"px-6 py-4"},P={class:"px-6 py-4"},R={key:0},z={class:"px-6 py-4"},H=h({__name:"DeviceSessionLog",props:{sessionLog:{}},setup(V){function d(t){const i=new Date(t.end+"Z").getTime(),s=new Date(t.start+"Z").getTime();let c=i-s;return T(c/1e3)}return(t,i)=>(o(),y(N,{class:"elevation-2 md:ma-4 w-full rounded-md"},{default:g(()=>[p(F,null,{default:g(()=>[p(M,{class:"sm:ma-4 border"},{default:g(()=>[e("thead",U,[e("tr",null,[e("th",W,a(n(m)("sessionlog.start")),1),e("th",q,a(n(m)("sessionlog.duration")),1),e("th",A,a(n(m)("consumed_solar_energy")),1),e("th",G,a(n(m)("consumed_energy")),1)])]),e("tbody",null,[(o(!0),l(w,null,x(t.sessionLog,(s,c)=>(o(),l("tr",{key:c,class:"odd:bg-surface even:bg-subgroup border-b text-center"},[e("td",J,a(n(k)(new Date(s.start+"Z"),"long")),1),e("td",K,a(d(s)),1),e("td",P,[s.consumed_energy!=0?(o(),l("span",R,a((s.solar_consumed_energy/s.consumed_energy*100).toFixed(0))+"% ",1)):b("",!0)]),e("td",z,a(n(B)(s.consumed_energy,"kWh")),1)]))),128))])]),_:1})]),_:1})]),_:1}))}}),O=Z(H,[["__scopeId","data-v-86bf3fdd"]]),Q=["value"],X={class:"pa-4 v-full bg-background flex min-h-screen justify-center"},Y={key:0,class:"flex h-full w-full justify-items-center"},ee={key:1},me=h({__name:"SessionLog",setup(V){const d=f(),t=f(),i=f(!1),s=f(""),c=async function(u){i.value=!0,d.value=u!=""?await v.getDeviceSessionLog(u):[],i.value=!1},D=function(u){console.log(u.target.value),c(u.target.value)};return C(async()=>{t.value=await v.getAllDevices(!0),t.value.length>0&&(s.value=t.value[0].id,c(t.value[0].id))}),(u,_)=>(o(),l("div",null,[p(j,{color:"transparent",title:n(L)("bp2")?n(m)("app.sessionlog"):""},{append:g(()=>[S(e("select",{"onUpdate:modelValue":_[0]||(_[0]=r=>s.value=r),class:"select bg-surface ma-2 w-full max-w-xs",onChange:_[1]||(_[1]=r=>D(r))},[(o(!0),l(w,null,x(t.value,r=>(o(),l("option",{key:r.id,value:r.id},a(r.name),9,Q))),128))],544),[[$,s.value]])]),_:1},8,["title"]),p(E),e("div",X,[i.value?(o(),l("div",Y,[p(I,{indeterminate:"",color:"primary"})])):(o(),l("div",ee,[d.value?(o(),y(O,{key:0,"session-log":d.value},null,8,["session-log"])):b("",!0)]))])]))}});export{me as default};
