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