"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[64303],{19478(e,t,n){n.r(t),n.d(t,{RadiosSidePanel:()=>R,default:()=>S});var a=n(274934),i=n(977872),o=n(602086),r=n(843871),s=n(938984),d=n(950804),l=n(571829),m=n(630849),c=n(761801),u=n(115114),_=n(835655),p=n(250820),h=n(829540),b=n(535322),A=n(561614),g=n(795206),f=n(781663),x=n(875922),v=n(801820),C=n(483064),w=n(855554);const k=({device:e,radio:t})=>`${e._id}-${t.name}`,y=e=>{const[t,n]=e.split("-");return{device_id:t,radio_name:n}},O=({deviceRadios:e,radios:t,onRemoveDeviceRadio:n,onSelectMeshingParents:_})=>{const f=(0,i.wA)(),v=(0,m.I)(),C=(0,o.useMemo)(()=>l.I.reduce((e,n)=>(t[n]&&e.radios.push(t[n]),e),{radios:[]}),[t]),w=(0,o.useMemo)(()=>d.A.object().shape({...(0,p.m)(e.filter(x.A.tx_power).flatMap(({radio:e})=>e),!0)}),[e]);return(0,a.jsx)(r.l1,{initialValues:C,onSubmit:async(t,{resetForm:n})=>{try{await(e=>{if(!e.length||!t.radios?.length)return Promise.resolve();const n=t.radios.reduce((t,n,a)=>{const i=n.type,o=(({type:e,name:t,...n},a)=>({radio:e,...Object.entries(n).reduce((e,[t,i])=>{let o=i;return void 0===o||"tx_power"===t&&n.tx_power_mode!==A.PB.CUSTOM||"tx_power_mode"===t&&o===A.PB.CUSTOM&&void 0===n.tx_power||a[t]===o||("ht"===t&&(o=i.toString()),e[t]=o),e},{})}))(n,C.radios[a]);return t[i]=((e,t)=>Object.entries(e).reduce((e,[n,a])=>{if(void 0===a)return e;const i=t.filter(e=>!x.A[n]||x.A[n](e));if(!i.length)return e;const o=i.map(k).sort().join(" ");return e[o]={...e[o],[n]:a},e},{}))(o,e.filter(({radio:{radio:e}})=>e===i)),t},{}),a={},i=(e,t,n,a)=>({id:e,data:{radio_table:[{radio_identifiers:t,...a,radio:n}]}});return l.I.forEach(e=>{const t=n[e];t&&Object.entries(t).forEach(([t,n])=>{const o=t.split(" ").map(y),r=[...new Set(o.map(({device_id:e})=>e).sort())],s=r.join(" ");if(a[s]&&!a[s]?.data?.radio_table.some(t=>t.radio===e)){const t=i(r,o,e,n);a[s]={...t,data:{radio_table:[...a[s]?.data?.radio_table||[],...t.data.radio_table]}}}else a[s]=i(r,o,e,n)})}),Promise.all(Object.values(a).map(e=>f((0,g.Nc)(e))))})(e)}catch(e){v(e)}finally{n({values:t})}},enableReinitialize:!0,validationSchema:w,children:({handleSubmit:i,handleReset:o,dirty:r,isValid:d})=>(0,a.jsxs)(a.Fragment,{children:[l.I.filter(e=>!!t[e]).map((t,i)=>(0,a.jsx)(b.A,{type:b.I.ACCORDION,items:[{id:t,label:(0,a.jsx)(s.A,{weight:"bold",size:"medium",children:(0,a.jsx)(c.A,{radio:t})}),openByDefault:!0,renderContent:()=>(0,a.jsx)(h.sG,{radioType:t,radioIdx:i,deviceRadios:e.filter(({radio:e})=>e.radio===t),onRemoveDeviceRadio:n,onSelectMeshingParents:_,hideTitle:!0,showDeviceList:!0,mode:h.Hm.ONLY_RADIO,showKeyRadioMetrics:!0,defaultKeyRadioMetricsExpanded:e.length<=1})}]},t)),(0,a.jsx)(u.A,{isDirty:r,isInvalid:!d,onFormSubmit:i,onFormCancel:o})]})})},R=()=>{const e=(0,i.wA)(),t=(0,i.d4)(v.mK),n=(0,i.d4)(v.If),r=n.map(e=>Object.fromEntries(Object.entries((0,_.S)(e.radio)).map(([t,n])=>!x.A[t]||x.A[t](e)?[t,n]:[t,C.Q]))).reduce((e,t)=>{return{...e,[t.type]:e[t.type]?(n=e[t.type],a=t,[...new Set([...Object.keys(n),...Object.keys(a)])].reduce((e,t)=>{if(h.eu.includes(t))return e;const i=n[t]!==C.Q?n[t]:a[t],o=i===(a[t]!==C.Q?a[t]:i)?i:void 0;return o===C.Q?e:{...e,[t]:o}},{})):t};var n,a},{}),s=(0,o.useCallback)(t=>{const a=t.map(f.R);e((0,w.V)(n.filter(({id:e})=>!a.includes(e)).map(({id:e})=>e)))},[e,n]),d=(0,o.useCallback)(()=>{e((0,w.V)([...new Set([...n.filter(({parentId:e})=>!e).map(({id:e})=>e),...n.flatMap(({parentId:e})=>Object.values(t).filter(t=>!t.parentId&&t.id===e).map(({id:e})=>e))])]))},[e,n,t]);return(0,o.useEffect)(()=>()=>{e((0,w.V)([]))},[e]),(0,a.jsx)(O,{deviceRadios:n,radios:r,onRemoveDeviceRadio:s,onSelectMeshingParents:d})},S=R},535322(e,t,n){n.d(t,{A:()=>p,I:()=>a});var a,i=n(274934),o=n(814557),r=n(158885),s=n(247816),d=n(565527),l=n(309130),m=n(100978),c=n(291508);!function(e){e.ACCORDION="accordion",e.BUTTON_LIST="buttonList"}(a||(a={}));const u=(0,s.A)(m.A,(0,c.A)("marginBottom","isButtonList","margin","flex","width","padding","nested","background"))`
  background-color: ${({background:e,nested:t,theme:{themeName:n}})=>e||o.Ay[n===d.S.DARK?`desktop-color-neutral-${t?"00":"01"}-${d.S.DARK}`:`desktop-color-neutral-${t?"01":"00"}-${d.S.LIGHT}`]};
  padding: ${({isButtonList:e,padding:t})=>t||(e?`0 ${l.Ln}`:l.Ln)};
  margin-bottom: ${({marginBottom:e})=>e||l.Ln};
  ${({margin:e})=>e?`margin: ${e};`:""}
  border-radius: 8px;
  flex-direction: column;
  width: ${({width:e="100%"})=>e};
  flex: ${({flex:e=0})=>e};
  > :last-child {
    margin-bottom: 0;
  }
  thead {
    tr {
      height: 32px !important;
    }
    th {
      text-transform: none;
    }
  }
  ${({isButtonList:e})=>e?`\n    > div {\n      display: flex;\n      height: 48px;\n      border-bottom: ${({theme:{themeName:e}})=>o.Ay[`desktop-border-divider-${e}`]};\n      &:last-child {\n        border-bottom: none;\n      }\n    }\n  `:""}
`,_=(0,s.A)(r.A,(0,c.A)("marginBottom","margin","flex","padding","nested","background"))`
  background-color: ${({background:e,nested:t,theme:{themeName:n}})=>e||o.Ay[n===d.S.DARK?`desktop-color-neutral-${t?"00":"01"}-${d.S.DARK}`:`desktop-color-neutral-${t?"01":"00"}-${d.S.LIGHT}`]};
  margin-bottom: ${({theme:e,marginBottom:t})=>t||e.spacing["spacing-l"]};
  ${({margin:e})=>e?`margin: ${e};`:""}
  ${({padding:e})=>e?`padding: ${e};`:""}
  border-radius: 8px;
  flex-direction: column;
  flex: ${({flex:e=0})=>e};
  > :last-child {
    margin-bottom: 0;
  }
  thead {
    tr {
      height: 32px !important;
    }
    th {
      text-transform: none;
    }
  }
  > li {
    > div:first-child {
      background: ${({background:e,theme:{themeName:t}})=>e||o.Ay[t===d.S.DARK?`desktop-color-neutral-01-${d.S.DARK}`:`desktop-color-neutral-00-${d.S.LIGHT}`]};
      height: 48px;
      padding: 0 ${l.Ln};
    }
    > div:nth-child(2) {
      margin-bottom: 0;
      padding: 0;
      > div {
        padding: 0 ${l.Ln} ${l.Ln};
      }
    }
  }
`,p=({type:e,marginBottom:t,margin:n,padding:o,flex:r,width:s,nested:d,...l})=>"items"in l?(0,i.jsx)(_,{marginBottom:t,margin:n,padding:o,flex:r,nested:d,...l}):(0,i.jsx)(u,{nested:d,width:s,marginBottom:t,margin:n,padding:o,flex:r,isButtonList:e===a.BUTTON_LIST,...l,children:l.children})},796091(e,t,n){n.d(t,{A:()=>s});var a=n(274934),i=n(833466),o=n(309130),r=n(100978);const s=e=>(0,a.jsx)(r.A,{paddingTop:o.YC,paddingBottom:o.YC,gap:o.Ln,rowGap:o.YC,flexWrap:"wrap",minHeight:i.b,alignItems:"center",...e})},250266(e,t,n){n.d(t,{A:()=>m});var a=n(274934),i=n(602086),o=n(696264),r=n(409844),s=n(521376),d=n(309130),l=n(470070);const m=({children:e=null,title:t,titleValues:n,message:m,messageValues:c,handleConfirm:u=()=>null,handleClose:_=()=>null,handleCancel:p,isOpen:h,buttonVariant:b="primary",cancelButtonVariant:A="tertiary",cancelButtonMessage:g="COMMON_ACTION_CANCEL",buttonMessage:f="COMMON_ACTION_CONFIRM",buttonDisabled:x=!1,position:v="top",offset:C,showHeaderClose:w=!1,contentClassName:k="",body:y,titleBody:O,className:R,rootClose:S=!1,footerActions:j})=>{const $=(0,i.useCallback)(e=>{h&&(e.stopPropagation(),e.key===s.U.ENTER?u():e.key===s.U.ESCAPE&&_(!1))},[h,u,_]);(0,i.useEffect)(()=>(window.addEventListener("keydown",$,!0),()=>{window.removeEventListener("keydown",$,!0)}),[$]);const N=(0,i.useCallback)(()=>{_(!1),p?.()},[_,p]),E=(0,i.useCallback)(()=>{_(!1),u()},[_,u]),I=(0,i.useMemo)(()=>[{text:(0,a.jsx)(l.sA,{id:g}),variant:A,onClick:N},{text:(0,a.jsx)(l.sA,{id:f}),disabled:x,variant:b,onClick:E}],[f,b,g,A,N,E,x]),M=(0,i.useCallback)(()=>{_(!1)},[_]),B=r.AH`
    ${t?"":`margin-top: ${d.xO}`}
  `;return(0,a.jsx)(o.A,{title:t?(0,a.jsx)(l.sA,{id:t,values:n}):O||null,...m?{body:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.sA,{id:m,values:c}),y]})}:{body:y},position:v,portal:!0,offset:C,actions:j||I,showHeaderClose:w,contentClassName:r.AH`
        ${B}
        ${k}
      `,onRequestClose:M,isOpen:h,allowOverflow:!0,rootClose:S,className:R,children:e})}},594492(e,t,n){n.d(t,{A:()=>c});var a=n(274934),i=n(602086),o=n(599110),r=n(247816),s=n(309130),d=n(470070),l=n(291508);const m=(0,r.A)("footer",(0,l.A)("hasFormResetButton"))`
  display: flex;
  justify-content: ${({hasFormResetButton:e})=>e?"space-between":"flex-end"};
  padding: ${s.S2} ${s.fS};
  gap: ${s.kc};
`,c=({allowCancel:e,isDirty:t,isInvalid:n,isSubmitting:r,onFormSubmit:s,onFormReset:l,onFormCancel:c,className:u,submitButtonText:_,customButton:p,applyButton:h,applyButtonFirst:b,hideCancelButton:A,form:g})=>{const f=(0,i.useMemo)(()=>h||(0,a.jsx)(o.A,{name:"submit",variant:"primary",type:"submit",onClick:s,disabled:!t||n||r,form:g,children:(0,a.jsx)(d.sA,{id:_||"COMMON_ACTION_APPLY_CHANGES"})}),[h,g,t,n,r,s,_]);return(0,a.jsxs)(m,{className:u,hasFormResetButton:!!l,children:[b?f:p,A?null:(0,a.jsx)(o.A,{name:"cancel",variant:"default",type:"button",onClick:c,disabled:!e&&!t,children:(0,a.jsx)(d.sA,{id:"COMMON_ACTION_CANCEL"})}),l?(0,a.jsx)(o.A,{name:"reset",variant:"default",type:"button",onClick:l,disabled:!t,children:(0,a.jsx)(d.sA,{id:"COMMON_ACTION_RESET_TO_DEFAULT"})}):null,b?p:f]})}},115114(e,t,n){n.d(t,{A:()=>m});var a=n(274934),i=n(232932),o=n(247816),r=n(409844),s=n(594492);const d=(0,o.A)("div")`
  height: 66px;
`,l=r.AH`
  padding: 0px !important;
`,m=({isDirty:e,onFormSubmit:t,onFormCancel:n,isInvalid:o,...r})=>e?(0,a.jsx)(i.A,{children:(0,a.jsx)(s.A,{isDirty:e,onFormCancel:n,onFormSubmit:t,isInvalid:o,className:l,...r})}):(0,a.jsx)(d,{})},835655(e,t,n){n.d(t,{J:()=>_,S:()=>u});var a=n(602086),i=n(345272),o=n(561614),r=n(927316),s=n(634268),d=n(432001),l=n(308833),m=n(250820),c=n(98334);const u=({antenna_id:e,antenna_gain:t,name:n,radio:a,ht:i,channel:r,tx_power_mode:d,tx_power:m,min_txpower:u,vwire_enabled:_,min_rssi_enabled:p,min_rssi:h,hard_noise_floor_enabled:b,sens_level_enabled:A,sens_level:g})=>({antenna_id:e,antenna_gain:t,name:n,type:a,ht:+i||s.L[a],channel:Number(r)||c.YQ,tx_power_mode:d||o.PB.AUTO,tx_power:m||u||0,vwire_enabled:_??!0,min_rssi_enabled:p||!1,min_rssi:+h||l.X.DEFAULT,hard_noise_floor_enabled:b||!1,sens_level_enabled:A,sens_level:g}),_=e=>{const t=(0,a.useMemo)(()=>({...(()=>{const t=(e.radio_table||[]).find(({radio:e})=>e===i.A.NA.type)?.vwire_enabled??!0,n=e.mesh_sta_vap_enabled??!0,a=t||n;return{radios:(e.support_wifi6e?e.radio_table:e.radio_table?.filter(({radio:e})=>e!==o.sx.RADIO_6E))?.map(u)?.sort(r.j3),atf_enabled:e.atf_enabled||!1,meshingEnabled:a,uplinkMeshEnabled:n,uplinkPriority1:e.mesh_uplink_1||"",uplinkPriority2:e.mesh_uplink_2||""}})()}),[e.radio_table,e.mesh_sta_vap_enabled,e.mesh_uplink_1,e.mesh_uplink_2,e.atf_enabled,e.support_wifi6e]),n=(0,a.useMemo)(()=>e.radio_table?.reduce((t,{radio:n})=>(t[n]=(0,d.k)({wifi_caps:e.wifi_caps,hide_ch_width:e.hide_ch_width},n),t),{}),[e.radio_table,e.wifi_caps,e.hide_ch_width]);return{initialValues:t,getSubmitData:(0,a.useCallback)(t=>{const{meshingEnabled:a,uplinkMeshEnabled:i,uplinkPriority1:o,uplinkPriority2:s,radios:d,...l}=t,m={...l};return o&&(m.mesh_uplink_1=o,s&&(m.mesh_uplink_2=s)),m.mesh_sta_vap_enabled=t.uplinkMeshEnabled,m.radio_table=d.map(t=>{const a=(e.radio_table||[]).find(({name:e})=>e===t.name),i=(0,r.kb)({model:e.model},a.antenna_id)?null:(0,r.Sb)(e.antenna_table||[],a.antenna_id);return(({isChannelWidthHidden:e,antenna:t,minRssiStrictModeSupported:n},a)=>{const{name:i,type:o,sens_level:s,sens_level_enabled:d,...l}=a,m={...l,sens_level_enabled:d,sens_level:s,radio:o,name:i};return"custom"!==l.tx_power_mode&&delete m.tx_power,m.antenna_id&&t?m.antenna_gain=(0,r.pK)(t,i):delete m.antenna_id,n||m.min_rssi_enabled||delete m.hard_noise_floor_enabled,m.min_rssi_enabled||delete m.min_rssi,m.sens_level_enabled||delete m.sens_level,e&&(delete m.channel,delete m.ht),m})({isChannelWidthHidden:n[t.type],antenna:i&&a&&(0,r.Jj)(i,a.name)?i:null,minRssiStrictModeSupported:a&&(0,r.Wg)(a)},t)}),m},[e.radio_table,e.model,e.antenna_table,n]),validationSchema:(0,m.m)(e.radio_table)}}},521376(e,t,n){var a;n.d(t,{U:()=>a}),function(e){e.ARROW_LEFT="ArrowLeft",e.ARROW_RIGHT="ArrowRight",e.ARROW_DOWN="ArrowDown",e.ARROW_UP="ArrowUp",e.ENTER="Enter",e.ESCAPE="Escape",e.BACKSPACE="Backspace",e.DELETE="Delete",e.TAB="Tab"}(a||(a={}))},571829(e,t,n){n.d(t,{I:()=>i});var a=n(561614);const i=[a.sx.RADIO_NG,a.sx.RADIO_NA,a.sx.RADIO_6E,a.sx.RADIO_AD]}}]);