"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[27148],{341699(e,t,i){i.d(t,{HV:()=>l,pm:()=>r,vF:()=>n});var s=i(726831);const n=e=>`${s.A.fabricsOrchestration}?orchestrationId=${e?.template_id||""}&orgId=${e?.organization_id||""}`,l=e=>`${s.A.fabricsDeviceTemplates}/${e?.template_id||""}?orgId=${e?.organization_id||""}`,r=()=>`${s.A.fabricsOrchestration}`},637084(e,t,i){i.d(t,{A:()=>v});var s=i(274934),n=i(602086),l=i(843871),r=i(977872),c=i(418398),o=i(396489),a=i.n(o),d=i(205521),h=i(232410),u=i(933671),A=i(260288),m=i(619619),b=i(702147),x=i(507792),S=i(621309);const g=(0,l.bk)({enableReinitialize:!0,mapPropsToValues:({powerSupervisor:e,device:t})=>({powerSupervisor:(0,m.f)(e,(0,x.lD)(t,e))}),handleSubmit:(e,{resetForm:t})=>t({values:e}),validationSchema:b.Ay}),v=(0,c.Zz)((0,r.Ng)((e,{device:{mac:t}})=>({powerSupervisor:(0,h.x0)(t)(e)})))(g(({powerSupervisor:e,device:t,setFormDirty:i,setFormInvalid:l,validateForm:c,values:o,resetForm:h,initialValues:m,dirty:b,isValid:x,formName:g=A.r8})=>{const v=(0,r.wA)();return(0,n.useEffect)(()=>(v((0,d.uo)({[g]:()=>({})})),v((0,d.Oo)({[g]:()=>{a()(o,m)||c().then(t=>{Object.keys(t).length||v((0,S.A)(e?.id,o.powerSupervisor))})}})),v((0,d.rW)({[g]:h})),()=>{v((0,d.uo)({[g]:null})),v((0,d.Oo)({[g]:null})),v((0,d.rW)({[g]:null}))}),[v,h,o.powerSupervisor,g,c,e?.id,o,m]),(0,n.useEffect)(()=>{i?.(g,b),l?.(g,!x)},[i,b,l,x,g]),(0,s.jsx)(u.A,{device:t})}))},419685(e,t,i){i.d(t,{A:()=>_});var s=i(274934),n=i(602086),l=i(262356),r=i(179102),c=i(221835),o=i(266824),a=i(247816),d=i(977872),h=i(669439),u=i(309130),A=i(793442),m=i(100978),b=i(470070),x=i(291935),S=i(598990),g=i(6276),v=i(341699);const O=(0,a.A)("div")`
  width: 100%;
  margin-bottom: ${u.Ln};
`,C=()=>{const e=(0,d.d4)(x.zu);return{isOrchestrated:(0,n.useMemo)(()=>(0,g.A)(e),[e]),globalSwitchSettings:e}},j=({globalSwitchSettings:e,children:t})=>{const i=(0,d.wA)(),l=(0,n.useCallback)(()=>{i((0,S.Np)("global_network")).then(e=>{(e?.data?.setting_keys||[]).length>0&&i((0,S.Uc)(void 0,{resolveWithExisting:!1}))})},[i]);return(0,s.jsx)(h.A,{placement:"top start",description:(0,s.jsxs)(m.A,{flexDirection:"column",width:"100%",children:[(0,s.jsx)(b.sA,{id:"COMMON_GLOBAL_SWITCH_SETTINGS_MANAGED_BY_FABRIC"}),(0,s.jsxs)(m.A,{gap:u.YC,alignItems:"baseline",children:[(0,s.jsx)(A.A,{id:"COMMON_VIEW_IN_SITE_MANAGER",href:(0,v.vF)(e.cloud_template)}),(0,s.jsx)(r.A,{style:{textTransform:"lowercase"},size:"small",children:(0,s.jsx)(b.sA,{id:"COMMON_OR"})}),(0,s.jsx)(o.A,{variant:"destructive",fontSize:"inherit",onClick:l,children:(0,s.jsx)(b.sA,{id:"COMMON_DETACH"})})]})]}),children:(0,s.jsx)("div",{children:t})})},_={Toggle:({isGlobalSwitchSettingsEnabled:e,setGlobalSwitchSettingsEnabled:t,noStyledRow:i})=>{const{isOrchestrated:c,globalSwitchSettings:o}=C(),a=(0,n.useCallback)(({target:{checked:e}})=>{t(e)},[t]),d=(0,s.jsx)(l.A,{full:!0,checked:e,onChange:a,disabled:c,children:(0,s.jsx)(m.A,{width:"100%",alignItems:"center",children:(0,s.jsx)(r.A,{size:"medium",color:c?"disabled":void 0,children:(0,s.jsx)(b.sA,{id:"COMMON_GLOBAL_SWITCH_SETTINGS"})})})}),h=i?d:(0,s.jsx)(O,{children:d});return c?(0,s.jsx)(j,{globalSwitchSettings:o,children:h}):h},Checkbox:({isGlobalSwitchSettingsEnabled:e,setGlobalSwitchSettingsEnabled:t,onChange:i,noStyledRow:l})=>{const{isOrchestrated:o,globalSwitchSettings:a}=C(),d=(0,n.useCallback)(({target:{checked:e}})=>{t(e),i?.(e)},[i,t]),h=(0,s.jsx)(c.A,{id:"global-switch-settings-checkbox",checked:e,onChange:d,disabled:o,children:(0,s.jsx)(r.A,{size:"medium",color:o?"disabled":void 0,children:(0,s.jsx)(b.sA,{id:"COMMON_GLOBAL_SWITCH_SETTINGS"})})}),u=l?h:(0,s.jsx)(O,{children:h});return o?(0,s.jsx)(j,{globalSwitchSettings:a,children:u}):u}}},527148(e,t,i){i.r(t),i.d(t,{default:()=>I});var s=i(274934),n=i(418398),l=i(977872),r=i(602086),c=i(478961),o=i(630849),a=i(376892),d=i(535322),h=i(700444),u=i(446863),A=i(795206),m=i(291935),b=i(159469),x=i(598990),S=i(167933),g=i(637084),v=i(115114),O=i(322784),C=i(532635),j=i(269935),_=i(795928),w=i(419685);const I=(0,n.Zz)((0,c.A)([_.UH,O.q,j.h]))(({activeItem:e,setFormDirty:t,setFormInvalid:i,isDirty:n,isInvalid:c})=>{const I=(0,l.d4)(u.n0),p=(0,l.d4)(u.Lq),f=(0,l.d4)(u.H5),E=(0,l.wA)(),y=(0,o.I)(),N=(0,l.d4)(m.zu),[D,M]=(0,r.useState)(!N.switch_exclusions?.includes(e.mac)),k=(0,l.d4)(S.pB),F=D!==!N.switch_exclusions?.includes(e.mac),T=n||F;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(_.Ay,{activeItem:e,label:"COMMON_DEVICE_NAME",setFormDirty:t,setFormInvalid:i}),(0,s.jsx)(d.A,{type:d.I.ACCORDION,items:[{id:O.q,openByDefault:!0,label:(0,s.jsx)(a.A,{id:"COMMON_ADVANCED"}),renderContent:()=>(0,s.jsxs)(s.Fragment,{children:[k?(0,s.jsx)(w.A.Checkbox,{isGlobalSwitchSettingsEnabled:D,setGlobalSwitchSettingsEnabled:M}):null,(0,s.jsx)(O.A,{activeItem:e,setFormDirty:t,setFormInvalid:i,isGlobalSwitchSettingsEnabled:k?D:void 0})]})}]}),(0,s.jsx)(g.A,{device:e,setFormDirty:t,setFormInvalid:i}),(0,s.jsx)(d.A,{type:d.I.ACCORDION,items:[{id:j.h,openByDefault:!0,label:(0,s.jsx)(a.A,{id:"DEVICE_PROPERTY_HEADER_TOUCHSCREEN"}),renderContent:()=>(0,s.jsx)(j.A,{activeItem:e,setFormDirty:t,setFormInvalid:i})}]}),(0,s.jsx)(d.A,{type:d.I.ACCORDION,items:[{id:C.f,openByDefault:!0,label:(0,s.jsx)(a.A,{id:"COMMON_ACTION_MANAGE"}),renderContent:()=>(0,s.jsx)(C.A,{activeItem:e})}]}),(0,s.jsx)(v.A,{isDirty:T,isInvalid:c,onFormSubmit:async()=>{if(k&&F){const t=N.switch_exclusions.filter(t=>t!==e.mac);D||t.push(e.mac);try{await E((0,x.OD)({...N,switch_exclusions:t}))}catch{return void E((0,h.ox)({icon:b.C.danger,message:"DEVICE_NOTICE_SAVE_ERROR"}))}}const t=Object.entries(I).reduce((e,[t,i])=>{if("function"==typeof i){const t=i();if("object"==typeof t&&t&&Object.keys(t).length)return{...e,...t}}return e},{});k&&D&&delete t.jumboframe_enabled;const{lcm:i,...s}=t;E((0,A.ex)(s,e._id,e.mac,{extend:!0})).then(()=>{Object.values(p).forEach(e=>{"function"==typeof e&&e()})}).catch(y)},onFormCancel:()=>{k&&M(!N.switch_exclusions?.includes(e.mac)),Object.values(f).forEach(e=>{"function"==typeof e&&e()})}})]})})}}]);