import{M as g,l as o,m as v,w as m,J as d,Q as s,$ as a,S as n,q as h,V as y,O as b,K as w,r as _,o as x,a3 as f,ai as k,aC as $,P as S}from"./index-966f7f24.js";import{f as C,a as L}from"./utils-6f3c77d7.js";import{b as T,a as B}from"./VCard-f534a22a.js";import{V as N}from"./VTable-b03b9a91.js";import{_ as M}from"./_plugin-vue_export-helper-c27b6911.js";import{V as Z}from"./VToolbar-4fa32985.js";import{V as j}from"./VDivider-b2a222eb.js";import{V as F}from"./VProgressCircular-22d71813.js";import"./VImg-be0bd66e.js";import"./VAvatar-0bab3ea1.js";import"./index-6b660d06.js";import"./resizeObserver-b8ff4a76.js";const P={class:"bg-primary"},U={class:"min-w-36 px-6 py-3"},W={class:"min-w-36 px-6 py-3"},q={class:"w-36 px-6 py-3"},A={class:"w-36 px-6 py-3"},E={class:"px-6 py-4"},I={class:"px-6 py-4"},J={class:"px-6 py-4"},K={key:0},O={class:"px-6 py-4"},Q=g({__name:"DeviceSessionLog",props:{sessionLog:{}},setup(V){function u(e){const i=new Date(e.end+"Z").getTime(),t=new Date(e.start+"Z").getTime();let c=i-t;return L(c/1e3)}return(e,i)=>(o(),v(T,{class:"md:m-4 w-full rounded-md elevation-2"},{default:m(()=>[d(B,null,{default:m(()=>[d(N,{class:"sm:m-4 border"},{default:m(()=>[s("thead",P,[s("tr",null,[s("th",U,a(e.$t("sessionlog.start")),1),s("th",W,a(e.$t("sessionlog.duration")),1),s("th",q,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:"border-b text-center odd:bg-surface even:bg-subgroup"},[s("td",E,a(e.$d(new Date(t.start+"Z"),"long")),1),s("td",I,a(u(t)),1),s("td",J,[t.consumed_energy!=0?(o(),n("span",K,a((t.solar_consumed_energy/t.consumed_energy*100).toFixed(0))+"% ",1)):y("",!0)]),s("td",O,a(b(C)(t.consumed_energy,"kWh")),1)]))),128))])]),_:1})]),_:1})]),_:1}))}});const z=M(Q,[["__scopeId","data-v-1a5d5f8f"]]),G=["value"],H={class:"v-full flex min-h-screen justify-center p-4 bg-background"},R={key:0,class:"flex h-full w-full justify-items-center"},X={key:1},de=g({__name:"SessionLog",setup(V){const u=_(),e=_(),i=_(!1),t=_(""),c=async function(l){i.value=!0,u.value=l!=""?await f.getDeviceSessionLog(l):[],i.value=!1},D=function(l){console.log(l.target.value),c(l.target.value)};return x(async()=>{e.value=await f.getAllDevices(!0),e.value.length>0&&(t.value=e.value[0].id,c(e.value[0].id))}),(l,p)=>(o(),n("div",null,[d(Z,{color:"transparent",title:b(S)("bp2")?l.$t("app.sessionlog"):""},{append:m(()=>[k(s("select",{"onUpdate:modelValue":p[0]||(p[0]=r=>t.value=r),class:"select m-2 w-full max-w-xs bg-surface",onChange:p[1]||(p[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,G))),128))],544),[[$,t.value]])]),_:1},8,["title"]),d(j),s("div",H,[i.value?(o(),n("div",R,[d(F,{indeterminate:"",color:"primary"})])):(o(),n("div",X,[u.value?(o(),v(z,{key:0,"session-log":u.value},null,8,["session-log"])):y("",!0)]))])]))}});export{de as default};
