"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[98456],{637084(e,t,s){s.d(t,{A:()=>A});var i=s(274934),r=s(602086),o=s(843871),n=s(977872),c=s(418398),a=s(205521),l=s(232410),u=s(1469),d=s(260288),m=s(619619),p=s(876809),f=s(113454),h=s(621309);const v=(0,o.bk)({enableReinitialize:!0,mapPropsToValues:({powerSupervisor:e,device:t})=>({powerSupervisor:(0,m.f)(e,(0,f.lD)(t,e))}),handleSubmit:(e,{resetForm:t})=>t({values:e}),validationSchema:p.A}),A=(0,c.Zz)((0,n.Ng)((e,{device:{mac:t}})=>({powerSupervisor:(0,l.x0)(t)(e)})))(v(({powerSupervisor:e,device:t,setFormDirty:s,setFormInvalid:o,validateForm:c,values:l,resetForm:m,dirty:p,isValid:f,formName:v=d.r8})=>{const A=(0,n.wA)();return(0,r.useEffect)(()=>(A((0,a.uo)({[v]:()=>({})})),A((0,a.Oo)({[v]:()=>{c().then(t=>{Object.keys(t).length||A((0,h.A)(e?.id,l.powerSupervisor))})}})),A((0,a.rW)({[v]:m})),()=>{A((0,a.uo)({[v]:null})),A((0,a.Oo)({[v]:null})),A((0,a.rW)({[v]:null}))}),[A,m,l.powerSupervisor,v,c,e?.id]),(0,r.useEffect)(()=>{s?.(v,p),o?.(v,!f)},[s,p,o,f,v]),(0,i.jsx)(u.A,{device:t})}))},876809(e,t,s){s.d(t,{A:()=>o,q:()=>r});var i=s(950804);const r=i.A.object().shape({power_sources:i.A.array().transform(e=>e.filter(e=>e.power_source_mac)).of(i.A.object().shape({client_psu_index:i.A.number().required(),power_source_mac:i.A.string().label("COMMON_POWER_SOURCE").required(),power_source_index:i.A.string().label("COMMON_OUTLET").required()})).label("COMMON_POWER_SOURCE").min(1)}).optional(),o=i.A.object().shape({powerSupervisor:r})},998456(e,t,s){s.r(t),s.d(t,{default:()=>I});var i=s(274934),r=s(418398),o=s(977872),n=s(602086),c=s(244081),a=s(159469),l=s(478961),u=s(630849),d=s(586566),m=s(309130),p=s(376892),f=s(100978),h=s(535322),v=s(700444),A=s(291935),b=s(598990),_=s(446863),w=s(795206),x=s(637084),O=s(115114),C=s(604355),j=s(419685),y=s(322784),S=s(532635),E=s(795928);const I=(0,r.Zz)((0,l.A)([E.UH,y.q]))(({activeItem:e,setFormDirty:t,setFormInvalid:s,isDirty:r,isInvalid:l})=>{const I=(0,o.d4)(_.n0),F=(0,o.d4)(_.Lq),D=(0,o.d4)(_.H5),g=(0,o.d4)(A.zu),{_id:N,mac:k}=e,[R,M]=(0,n.useState)(!g.switch_exclusions?.includes(k)),q=(0,o.wA)(),U=r||R!==!g.switch_exclusions?.includes(k),T=(0,u.I)();(0,n.useEffect)(()=>{q((0,b.Uc)(void 0,{crudCacheStrategy:{type:c.e.CACHE}}))},[q]);const V=(0,n.useCallback)(async()=>{const e=Object.entries(I).reduce((e,[t,s])=>{if("function"==typeof s){const t=s();if("object"==typeof t&&t&&Object.keys(t).length)return{...e,...t}}return e},{});R&&delete e.jumboframe_enabled;try{const e=[];if(R!==!g.switch_exclusions?.includes(k)){const t=g.switch_exclusions.filter(e=>e!==k);R||t.push(k),e.push({...g,switch_exclusions:t})}e.length&&await q((0,b.h3)(e))}catch{return void q((0,v.ox)({icon:a.C.danger,message:"DEVICE_NOTICE_SAVE_ERROR"}))}q((0,w.ex)(e,N,k,{extend:!0})).then(({data:t=[e]})=>{Object.values(F).forEach(e=>{"function"==typeof e&&e(t[0])})}).catch(T)},[I,R,q,N,k,T,g,F]),z=(0,n.useCallback)(()=>{M(!g.switch_exclusions?.includes(k)),Object.values(D).forEach(e=>{"function"==typeof e&&e()})},[k,g.switch_exclusions,D]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(E.Ay,{activeItem:e,setFormDirty:t,setFormInvalid:s}),(0,i.jsx)(h.A,{type:h.I.ACCORDION,items:[{id:y.q,openByDefault:!0,label:(0,i.jsx)(p.A,{id:"COMMON_SERVICES"}),renderContent:()=>(0,i.jsxs)(f.A,{flexDirection:"column",gap:m.Ln,children:[(0,d.$F)(e)?(0,i.jsx)(C.A,{hardware_offload:e.hardware_offload,setFormDirty:t,setFormInvalid:s}):null,(0,i.jsxs)("div",{children:[(0,i.jsx)(j.A.Checkbox,{isGlobalSwitchSettingsEnabled:R,setGlobalSwitchSettingsEnabled:M}),(0,i.jsx)(y.A,{activeItem:e,setFormDirty:t,setFormInvalid:s,isGlobalSwitchSettingsEnabled:R})]})]})}]}),(0,i.jsx)(x.A,{device:e,setFormDirty:t,setFormInvalid:s}),(0,i.jsx)(h.A,{type:h.I.ACCORDION,items:[{id:S.f,openByDefault:!0,label:(0,i.jsx)(p.A,{id:"COMMON_ACTION_MANAGE"}),renderContent:()=>(0,i.jsx)(S.A,{activeItem:e,hideRemove:!0})}]}),(0,i.jsx)(O.A,{isDirty:U,isInvalid:l,onFormSubmit:V,onFormCancel:z})]})})}}]);