import{B as h,q as o,t as y,w as f,m as p,H as e,G as a,I as n,$ as _,D as l,E as x,aw as k,M as b,J as w,r as g,o as L,R as v,a8 as S,ax as C,V as $}from"./index-5ee1411a.js";import{f as B,a as T}from"./utils-6f3c77d7.js";import{b as N,a as M}from"./VCard-8ba7cfc2.js";import{V as Z}from"./VTable-3f843f69.js";import{_ as j}from"./_plugin-vue_export-helper-c27b6911.js";import{V as E,a as F}from"./VToolbar-55156e00.js";import{V as I}from"./VProgressCircular-4762adb7.js";import"./transition-cd9cc606.js";import"./VImg-71612e97.js";import"./index-a55adddd.js";import"./resizeObserver-5499429a.js";const U={class:"bg-primary"},W={class:"px-6 py-3 min-w-36"},q={class:"px-6 py-3 min-w-36"},A={class:"px-6 py-3 w-36"},G={class:"px-6 py-3 w-36"},H={class:"px-6 py-4"},J={class:"px-6 py-4"},P={class:"px-6 py-4"},R={key:0},z={class:"px-6 py-4"},K=h({__name:"DeviceSessionLog",props:{sessionLog:{}},setup(D){function u(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:"w-full rounded-md elevation-2 md:m-4"},{default:f(()=>[p(M,null,{default:f(()=>[p(Z,{class:"border sm:m-4"},{default:f(()=>[e("thead",U,[e("tr",null,[e("th",W,a(n(_)("sessionlog.start")),1),e("th",q,a(n(_)("sessionlog.duration")),1),e("th",A,a(n(_)("consumed_solar_energy")),1),e("th",G,a(n(_)("consumed_energy")),1)])]),e("tbody",null,[(o(!0),l(w,null,x(t.sessionLog,(s,c)=>(o(),l("tr",{key:c,class:"text-center border-b odd:bg-surface even:bg-subgroup"},[e("td",H,a(n(k)(new Date(s.start+"Z"),"long")),1),e("td",J,a(u(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}))}});const O=j(K,[["__scopeId","data-v-ab3fdd1c"]]),Q=["value"],X={class:"v-full bg-background flex min-h-screen justify-center p-4"},Y={key:0,class:"flex h-full w-full justify-items-center"},ee={key:1},_e=h({__name:"SessionLog",setup(D){const u=g(),t=g(),i=g(!1),s=g(""),c=async function(d){i.value=!0,u.value=d!=""?await v.getDeviceSessionLog(d):[],i.value=!1},V=function(d){console.log(d.target.value),c(d.target.value)};return L(async()=>{t.value=await v.getAllDevices(!0),t.value.length>0&&(s.value=t.value[0].id,c(t.value[0].id))}),(d,m)=>(o(),l("div",null,[p(E,{color:"transparent",title:n($)("bp2")?n(_)("app.sessionlog"):""},{append:f(()=>[S(e("select",{"onUpdate:modelValue":m[0]||(m[0]=r=>s.value=r),class:"select bg-surface m-2 w-full max-w-xs",onChange:m[1]||(m[1]=r=>V(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),[[C,s.value]])]),_:1},8,["title"]),p(F),e("div",X,[i.value?(o(),l("div",Y,[p(I,{indeterminate:"",color:"primary"})])):(o(),l("div",ee,[u.value?(o(),y(O,{key:0,"session-log":u.value},null,8,["session-log"])):b("",!0)]))])]))}});export{_e as default};
