import{p as E,l as T,r as d,m as a,C as x,ay as B,Q as I,t as g,E as w,w as n,K as F,I as f,G as C,H as _,J as O,F as P,V as k}from"./index-5a44a053.js";import{b as D,a as R,V as S}from"./VCard-2565a0b7.js";import{m as K,c as N}from"./transition-1df78eef.js";import{e as U,f as j,d as h}from"./VTextField-f153c512.js";import{f as G}from"./forwardRefs-a329760c.js";import{a as $}from"./VBtn-bc6fd420.js";import{V as H}from"./VTable-f296e4c8.js";import"./VImg-1aa5363e.js";import"./index-cc451665.js";import"./VProgressCircular-e11c7d5f.js";import"./resizeObserver-115493a9.js";const J=E({...K(),...U()},"VForm"),L=T()({name:"VForm",props:J(),emits:{"update:modelValue":i=>!0,submit:i=>!0},setup(i,p){let{slots:m,emit:v}=p;const o=j(i),s=d();function b(r){r.preventDefault(),o.reset()}function V(r){const t=r,e=o.validate();t.then=e.then.bind(e),t.catch=e.catch.bind(e),t.finally=e.finally.bind(e),v("submit",t),t.defaultPrevented||e.then(l=>{var c;let{valid:u}=l;u&&((c=s.value)==null||c.submit())}),t.preventDefault()}return N(()=>{var r;return a("form",{ref:s,class:["v-form",i.class],style:i.style,novalidate:!0,onReset:b,onSubmit:V},[(r=m.default)==null?void 0:r.call(m,o)])}),G(o,s)}}),Q=f("br",null,null,-1),q=f("br",null,null,-1),z={class:"px-6 py-4 border"},A={class:"px-6 py-4 border"},se=x({__name:"EditDeviceConfig",props:{deviceId:{}},setup(i){const p=B(),m=d({}),v=d({}),o=d(""),s=d(0),b=d(0),V=i;I(()=>V.deviceId,async t=>{if(t){console.log("Edit Device: "+t);const e=await k.getDeviceConfig(t);m.value=e,o.value=e.name,s.value=e.nominal_power;const l=new Set(["id","name","type","nominal_power"]),u=Object.keys(e).filter(y=>!l.has(y)),c={};u.forEach(y=>{c[y]=e[y]}),v.value=c}},{immediate:!0});const r=async function(){const t={name:o.value,nominal_power:s.value};await k.saveDeviceConfig(V.deviceId,t),p.push({name:"devicessettings"})};return(t,e)=>(g(),w(F,null,[a(D,{class:"p-4 m-4 rounded-md elevation-2"},{default:n(()=>[a(R,null,{default:n(()=>[a(L,null,{default:n(()=>[a(h,{modelValue:o.value,"onUpdate:modelValue":e[0]||(e[0]=l=>o.value=l),label:t.$t("settings.name"),type:"input"},null,8,["modelValue","label"]),a(h,{modelValue:s.value,"onUpdate:modelValue":e[1]||(e[1]=l=>s.value=l),label:t.$t("settings.nominal_power"),type:"number"},null,8,["modelValue","label"]),a(h,{modelValue:b.value,"onUpdate:modelValue":e[2]||(e[2]=l=>b.value=l),label:t.$t("settings.switch_on_delay"),type:"number"},null,8,["modelValue","label"]),a($,{block:"",color:"primary",onClick:r},{default:n(()=>[C(_(t.$t("settings.save")),1)]),_:1})]),_:1}),Q,a($,{block:"",onClick:e[3]||(e[3]=l=>O(p).back())},{default:n(()=>[C(_(t.$t("close")),1)]),_:1})]),_:1})]),_:1}),q,a(D,{class:"p-4 m-4 rounded-md elevation-2"},{default:n(()=>[a(S,null,{default:n(()=>[C("Values which can only be edit in the energy_assistant.yaml file")]),_:1}),a(R,null,{default:n(()=>[a(H,{class:"m-4 border rounded-md"},{default:n(()=>[f("tbody",null,[(g(!0),w(F,null,P(v.value,(l,u)=>(g(),w("tr",{key:u,class:"text-left border"},[f("td",z,_(u),1),f("td",A,_(l),1)]))),128))])]),_:1})]),_:1})]),_:1})],64))}});export{se as default};
