"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[76696],{637084(e,t,r){r.d(t,{A:()=>O});var i=r(274934),s=r(602086),n=r(843871),o=r(977872),a=r(418398),l=r(396489),c=r.n(l),u=r(205521),d=r(232410),m=r(933671),A=r(260288),v=r(619619),p=r(702147),f=r(507792),y=r(621309);const I=(0,n.bk)({enableReinitialize:!0,mapPropsToValues:({powerSupervisor:e,device:t})=>({powerSupervisor:(0,v.f)(e,(0,f.lD)(t,e))}),handleSubmit:(e,{resetForm:t})=>t({values:e}),validationSchema:p.Ay}),O=(0,a.Zz)((0,o.Ng)((e,{device:{mac:t}})=>({powerSupervisor:(0,d.x0)(t)(e)})))(I(({powerSupervisor:e,device:t,setFormDirty:r,setFormInvalid:n,validateForm:a,values:l,resetForm:d,initialValues:v,dirty:p,isValid:f,formName:I=A.r8})=>{const O=(0,o.wA)();return(0,s.useEffect)(()=>(O((0,u.uo)({[I]:()=>({})})),O((0,u.Oo)({[I]:()=>{c()(l,v)||a().then(t=>{Object.keys(t).length||O((0,y.A)(e?.id,l.powerSupervisor))})}})),O((0,u.rW)({[I]:d})),()=>{O((0,u.uo)({[I]:null})),O((0,u.Oo)({[I]:null})),O((0,u.rW)({[I]:null}))}),[O,d,l.powerSupervisor,I,a,e?.id,l,v]),(0,s.useEffect)(()=>{r?.(I,p),n?.(I,!f)},[r,p,n,f,I]),(0,i.jsx)(m.A,{device:t})}))},476696(e,t,r){r.r(t),r.d(t,{default:()=>O});var i,s=r(274934),n=r(418398),o=r(977872),a=r(478961),l=r(630849),c=r(376892),u=r(535322),d=r(446863),m=r(795206),A=r(637084),v=r(115114),p=r(322784),f=r(532635),y=r(269935),I=r(795928);!function(e){e.NAME="name",e.PORTS="ports",e.MANAGE="manage"}(i||(i={}));const O=(0,n.Zz)((0,a.A)([i.NAME,y.h,p.q,i.MANAGE]))(({activeItem:e,setFormDirty:t,setFormInvalid:r,isDirty:n,isInvalid:a})=>{const O=(0,o.d4)(d.Lq),j=(0,o.d4)(d.H5),N=(0,o.d4)(d.n0),D=(0,o.wA)(),F=(0,l.I)();return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(I.Ay,{activeItem:e,setFormDirty:t,setFormInvalid:r,formName:i.NAME}),(0,s.jsx)(u.A,{type:u.I.ACCORDION,items:[{id:y.h,openByDefault:!0,label:(0,s.jsx)(c.A,{id:"COMMON_LED"}),renderContent:()=>(0,s.jsx)(y.A,{activeItem:e,setFormDirty:t,setFormInvalid:r})}]}),(0,s.jsx)(u.A,{type:u.I.ACCORDION,items:[{id:p.q,openByDefault:!0,label:(0,s.jsx)(c.A,{id:"COMMON_ADVANCED"}),renderContent:()=>(0,s.jsx)(p.A,{activeItem:e,setFormDirty:t,setFormInvalid:r})}]}),(0,s.jsx)(A.A,{device:e,setFormDirty:t,setFormInvalid:r}),(0,s.jsx)(u.A,{type:u.I.ACCORDION,items:[{id:i.MANAGE,openByDefault:!0,label:(0,s.jsx)(c.A,{id:"COMMON_ACTION_MANAGE"}),renderContent:()=>(0,s.jsx)(f.A,{activeItem:e})}]}),(0,s.jsx)(v.A,{isDirty:n,isInvalid:a,onFormSubmit:async()=>{const t=Object.entries(N).reduce((e,[t,r])=>{if("function"==typeof r){const t=r();if("object"==typeof t&&t&&Object.keys(t).length)return{...e,...t}}return e},{});D((0,m.ex)(t,e._id,e.mac,{extend:!0})).then(()=>{Object.values(O).forEach(e=>{"function"==typeof e&&e()})}).catch(F)},onFormCancel:()=>{Object.values(j).forEach(e=>{"function"==typeof e&&e()})}})]})})}}]);