"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[9854],{595778(e,r,i){i.d(r,{I:()=>t,U:()=>s});var o=i(241365);const t=(0,i(419284).Wj)(o.Ay["blue-0"]),s=100},637084(e,r,i){i.d(r,{A:()=>x});var o=i(274934),t=i(602086),s=i(843871),n=i(977872),l=i(418398),c=i(205521),a=i(232410),d=i(1469),u=i(260288),h=i(619619),m=i(876809),v=i(113454),A=i(621309);const _=(0,s.bk)({enableReinitialize:!0,mapPropsToValues:({powerSupervisor:e,device:r})=>({powerSupervisor:(0,h.f)(e,(0,v.lD)(r,e))}),handleSubmit:(e,{resetForm:r})=>r({values:e}),validationSchema:m.A}),x=(0,l.Zz)((0,n.Ng)((e,{device:{mac:r}})=>({powerSupervisor:(0,a.x0)(r)(e)})))(_(({powerSupervisor:e,device:r,setFormDirty:i,setFormInvalid:s,validateForm:l,values:a,resetForm:h,dirty:m,isValid:v,formName:_=u.r8})=>{const x=(0,n.wA)();return(0,t.useEffect)(()=>(x((0,c.uo)({[_]:()=>({})})),x((0,c.Oo)({[_]:()=>{l().then(r=>{Object.keys(r).length||x((0,A.A)(e?.id,a.powerSupervisor))})}})),x((0,c.rW)({[_]:h})),()=>{x((0,c.uo)({[_]:null})),x((0,c.Oo)({[_]:null})),x((0,c.rW)({[_]:null}))}),[x,h,a.powerSupervisor,_,l,e?.id]),(0,t.useEffect)(()=>{i?.(_,m),s?.(_,!v)},[i,m,s,v,_]),(0,o.jsx)(d.A,{device:r})}))},876809(e,r,i){i.d(r,{A:()=>s,q:()=>t});var o=i(950804);const t=o.A.object().shape({power_sources:o.A.array().transform(e=>e.filter(e=>e.power_source_mac)).of(o.A.object().shape({client_psu_index:o.A.number().required(),power_source_mac:o.A.string().label("COMMON_POWER_SOURCE").required(),power_source_index:o.A.string().label("COMMON_OUTLET").required()})).label("COMMON_POWER_SOURCE").min(1)}).optional(),s=o.A.object().shape({powerSupervisor:t})},554598(e,r,i){i.d(r,{A:()=>d});var o=i(274934),t=i(725989),s=i(938984),n=i(470070),l=i(100978),c=i(595778),a=i(662986);const d=({value:e=c.U,onChange:r})=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(l.A,{flexDirection:"column",width:"100%",children:[(0,o.jsx)(l.A,{flexDirection:"row",alignItems:"center",children:(0,o.jsx)(s.A,{variant:"caption",children:(0,o.jsx)(n.sA,{id:"COMMON_BRIGHTNESS"})})}),(0,o.jsx)(t.A,{value:e,minValue:1,onChange:r})]}),(0,o.jsx)(l.A,{flexDirection:"column",children:(0,o.jsx)(s.A,{variant:"body-primary",children:(0,a.A)(e)})})]})},785616(e,r,i){i.d(r,{A:()=>_});var o=i(274934),t=i(602086),s=i(60927),n=i(419284),l=i(100978),c=i(420528),a=i(247816),d=i(291508);const u=(0,a.A)(l.A)`
  cursor: pointer;
`,h=(0,a.A)("div",(0,d.A)("color"))`
  background-color: ${({color:e})=>e};
  border-radius: 3px;
  width: 34px;
  height: 20px;
`,m=({color:e})=>(0,o.jsxs)(u,{width:"55px",height:"24px",padding:"2px 0",alignItems:"center",justifyContent:"space-between",flexShrink:0,children:[(0,o.jsx)(h,{color:e}),(0,o.jsx)(c.A,{})]});var v=i(595778);const A=[{id:"hue",channel:"hue"}],_=({value:e,onChange:r})=>{const i=(0,t.useCallback)(e=>{r((0,n.E6)(e.toString())||v.I)},[r]),c=e||v.I;return(0,o.jsx)(l.A,{flexDirection:"column",children:(0,o.jsx)(s.A,{value:c,onChange:i,sliders:A,colorSpace:"hex",children:(0,o.jsx)("span",{children:(0,o.jsx)(m,{color:c})})})})}},663216(e,r,i){i.d(r,{Ay:()=>O,Cg:()=>b});var o=i(274934),t=i(418398),s=i(977872),n=i(602086),l=i(487763),c=i(843871),a=i(950804),d=i(586566),u=i(309130),h=i(120197),m=i(100978),v=i(205521),A=i(470070),_=i(857780),x=i(595778),p=i(554598),j=i(785616);const b="screen",f=(0,c.bk)({enableReinitialize:!0,isInitialValid:!0,mapPropsToValues:({activeItem:e,formName:r=b})=>({[r]:{led_override:e.led_override||_.c_.ON,led_override_color_brightness:e.led_override_color_brightness||x.U,led_override_color:e.led_override_color||x.I}}),validationSchema:a.A.object().shape({led_override:a.A.string(),led_override_color_brightness:a.A.number(),led_override_color:a.A.string()}),handleSubmit:(e,{resetForm:r})=>{r({values:e})}}),O=(0,t.Zz)(f)(({activeItem:e,setFormDirty:r,values:i,dirty:t,resetForm:c,setFieldValue:a,formName:f=b,disableLedOverrideColor:O,disableLedBrightnessField:g})=>{const C=(0,s.wA)(),y=(0,d.lp)(e);(0,n.useEffect)(()=>{r(f,t)},[r,t,f]),(0,n.useEffect)(()=>(C((0,v.uo)({[f]:()=>{const e=(0,l.A)(i,f);return{...i[f],...e}}})),C((0,v.Oo)({[f]:()=>{c({values:i})}})),C((0,v.rW)({[f]:c})),()=>{C((0,v.uo)({[f]:null})),C((0,v.Oo)({[f]:null})),C((0,v.rW)({[f]:null}))}),[C,f,c,i]);const I=(0,n.useCallback)(e=>{a(`${f}.led_override_color`,e)},[a,f]);return(0,o.jsxs)(m.A,{alignItems:"center",marginBottom:u.Ln,gap:u.Ln,children:[(0,o.jsx)(m.A,{children:(0,o.jsx)(h.A,{name:"led_override",type:"realCheckbox",checked:i[f].led_override===_.c_.ON,onChange:({target:{checked:e}})=>{a(`${f}.led_override`,e?_.c_.ON:_.c_.OFF)},children:(0,o.jsx)(A.sA,{id:"COMMON_LED"})})}),y&&!O?(0,o.jsx)(j.A,{value:i[f].led_override_color||x.I,onChange:I}):null,!g&&y?(0,o.jsx)(p.A,{value:i[f].led_override_color_brightness??x.U,onChange:e=>{a(`${f}.led_override_color_brightness`,e)}}):null]})})},309854(e,r,i){i.r(r),i.d(r,{default:()=>F});var o=i(274934),t=i(418398),s=i(977872),n=i(602086),l=i(159469),c=i(478961),a=i(630849),d=i(586566),u=i(309130),h=i(376892),m=i(100978),v=i(535322),A=i(700444),_=i(291935),x=i(598990),p=i(446863),j=i(956978),b=i(795206),f=i(637084),O=i(115114),g=i(604355),C=i(419685),y=i(322784),I=i(663216),w=i(532635),D=i(795928);const F=(0,t.Zz)((0,c.A)([D.UH,I.Cg,y.q,w.f]))(({activeItem:e,setFormDirty:r,setFormInvalid:i,isDirty:t,isInvalid:c})=>{const F=(0,s.d4)(p.Lq),S=(0,s.d4)(p.H5),E=(0,s.d4)(p.n0),N=(0,s.wA)(),k=(0,a.I)(),M=(0,s.d4)(_.zu),[R,U]=(0,n.useState)(!M.switch_exclusions?.includes(e.mac)),L=t||R!==!M.switch_exclusions?.includes(e.mac);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(D.Ay,{activeItem:e,setFormDirty:r,setFormInvalid:i}),(0,o.jsx)(v.A,{type:v.I.ACCORDION,items:[{id:I.Cg,openByDefault:!0,label:(0,o.jsx)(h.A,{id:"COMMON_LED"}),renderContent:()=>(0,o.jsx)(I.Ay,{activeItem:e,setFormDirty:r})}]}),(0,o.jsx)(v.A,{type:v.I.ACCORDION,items:[{id:y.q,openByDefault:!0,label:(0,o.jsx)(h.A,{id:"COMMON_ADVANCED"}),renderContent:()=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(m.A,{flexDirection:"column",gap:u.Ln,children:[(0,d.$F)(e)?(0,o.jsx)(g.A,{hardware_offload:e.hardware_offload,setFormDirty:r,setFormInvalid:i}):null,(0,j.Dh3)(e)?null:(0,o.jsx)(C.A.Checkbox,{isGlobalSwitchSettingsEnabled:R,setGlobalSwitchSettingsEnabled:U})]}),(0,o.jsx)(y.A,{activeItem:e,setFormDirty:r,setFormInvalid:i,isGlobalSwitchSettingsEnabled:R})]})}]}),(0,o.jsx)(f.A,{device:e,setFormDirty:r,setFormInvalid:i}),(0,o.jsx)(v.A,{type:v.I.ACCORDION,items:[{id:w.f,openByDefault:!0,label:(0,o.jsx)(h.A,{id:"COMMON_ACTION_MANAGE"}),renderContent:()=>(0,o.jsx)(w.A,{activeItem:e})}]}),(0,o.jsx)(O.A,{isDirty:L,isInvalid:c,onFormSubmit:async()=>{if(R!==!M.switch_exclusions?.includes(e.mac)){const r=M.switch_exclusions.filter(r=>r!==e.mac);R||r.push(e.mac);try{await N((0,x.OD)({...M,switch_exclusions:r}))}catch{return void N((0,A.ox)({icon:l.C.danger,message:"DEVICE_NOTICE_SAVE_ERROR"}))}}const r=Object.entries(E).reduce((e,[r,i])=>{if("function"==typeof i){const r=i();if("object"==typeof r&&r&&Object.keys(r).length)return{...e,...r}}return e},{});N((0,b.ex)(r,e._id,e.mac,{extend:!0})).then(()=>{Object.values(F).forEach(e=>{"function"==typeof e&&e()})}).catch(k)},onFormCancel:()=>{Object.values(S).forEach(e=>{"function"==typeof e&&e()})}})]})})}}]);