"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[43622,89965],{137625:(e,t,n)=>{n.d(t,{A:()=>d});var a=n(296540),i=n(353899),o=n(132196),r=n(372737),s=n(566723),l=n(699784);const d=({children:e=null,title:t,titleValues:n,message:d,messageValues:m,handleConfirm:c=()=>null,handleClose:u=()=>null,handleCancel:_,isOpen:p,buttonVariant:b="primary",cancelButtonVariant:h="tertiary",cancelButtonMessage:g="COMMON_ACTION_CANCEL",buttonMessage:A="COMMON_ACTION_CONFIRM",buttonDisabled:f=!1,position:v="top",showHeaderClose:C=!1,contentClassName:E="",body:k,titleBody:w,className:y,rootClose:O=!1,footerActions:x})=>{const N=(0,a.useCallback)(e=>{p&&(e.stopPropagation(),e.key===r.U.ENTER?c():e.key===r.U.ESCAPE&&u(!1))},[p,c,u]);(0,a.useEffect)(()=>(window.addEventListener("keydown",N,!0),()=>{window.removeEventListener("keydown",N,!0)}),[N]);const S=(0,a.useCallback)(()=>{u(!1),_?.()},[u,_]),R=(0,a.useCallback)(()=>{u(!1),c()},[u,c]),$=(0,a.useMemo)(()=>[{text:a.createElement(l.sA,{id:g}),variant:h,onClick:S},{text:a.createElement(l.sA,{id:A}),disabled:f,variant:b,onClick:R}],[A,b,g,h,S,R,f]),I=(0,a.useCallback)(()=>{u(!1)},[u]),M=o.AH`
    ${t?"":`margin-top: ${s.xO}`}
  `;return a.createElement(i.A,{title:t?a.createElement(l.sA,{id:t,values:n}):w||null,...d?{body:a.createElement(a.Fragment,null,a.createElement(l.sA,{id:d,values:m}),k)}:{body:k},position:v,portal:!0,actions:x||$,showHeaderClose:C,contentClassName:o.AH`
        ${M}
        ${E}
      `,onRequestClose:I,isOpen:p,allowOverflow:!0,rootClose:O,className:y},e)}},307330:(e,t,n)=>{n.d(t,{I:()=>i});var a=n(564985);const i=[a.sx.RADIO_NG,a.sx.RADIO_NA,a.sx.RADIO_6E,a.sx.RADIO_AD]},327769:(e,t,n)=>{n.r(t),n.d(t,{RadiosSidePanel:()=>N,default:()=>S});var a=n(469733),i=n(296540),o=n(951272),r=n(927099),s=n(870443),l=n(307330),d=n(96512),m=n(280062),c=n(329109),u=n(885358),_=n(605689),p=n(227902),b=n(689965),h=n(564985),g=n(171073),A=n(33249),f=n(397910),v=n(318408),C=n(126067),E=n(990417),k=n(255029),w=n(452269);const y=({device:e,radio:t})=>`${e._id}-${t.name}`,O=e=>{const[t,n]=e.split("-");return{device_id:t,radio_name:n}},x=({deviceRadios:e,radios:t,onRemoveDeviceRadio:n,onSelectMeshingParents:u})=>{const A=(0,a.useDispatch)(),f=(0,d.I)(),v=(0,i.useMemo)(()=>l.I.reduce((e,n)=>(t[n]&&e.radios.push(t[n]),e),{radios:[]}),[t]),E=(0,i.useMemo)(()=>s.A.object().shape({...(0,_.m)(e.filter(C.A.tx_power).map(({radio:e})=>e).flat())}),[e]);return i.createElement(o.l1,{initialValues:v,onSubmit:async(t,{resetForm:n})=>{const a=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!==h.PB.CUSTOM||"tx_power_mode"===t&&o===h.PB.CUSTOM&&void 0===n.tx_power||a[t]===o||("ht"===t&&(o=i.toString()),e[t]=o),e},{})}))(n,v.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=>!C.A[n]||C.A[n](e));if(!i.length)return e;const o=i.map(y).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(O),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=>A((0,g.Nc)(e))))};try{await a(e)}catch(e){f(e)}finally{n({values:t})}},enableReinitialize:!0,validationSchema:E},({handleSubmit:a,handleReset:o,dirty:s,isValid:d})=>i.createElement(i.Fragment,null,l.I.filter(e=>!!t[e]).map((t,a)=>i.createElement(b.A,{key:t,type:b.I.ACCORDION,items:[{id:t,label:i.createElement(r.A,{weight:"bold",size:"body"},i.createElement(m.A,{radio:t})),openByDefault:!0,renderContent:()=>i.createElement(p.sG,{radioType:t,radioIdx:a,deviceRadios:e.filter(({radio:e})=>e.radio===t),onRemoveDeviceRadio:n,onSelectMeshingParents:u,hideTitle:!0,showDeviceList:!0,mode:p.Hm.ONLY_RADIO,showKeyRadioMetrics:!0,defaultKeyRadioMetricsExpanded:e.length<=1})}]})),i.createElement(c.A,{isDirty:s,isInvalid:!d,onFormSubmit:a,onFormCancel:o})))},N=()=>{const e=(0,a.useDispatch)(),t=(0,a.useSelector)(A.G),n=(0,a.useSelector)(E.mK),o=(0,a.useSelector)(t===f.o.CHANNEL_AI?E.If:E.yk),r=o.map(e=>Object.fromEntries(Object.entries((0,u.S)(e.radio)).map(([t,n])=>!C.A[t]||C.A[t](e)?[t,n]:[t,k.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(p.eu.includes(t))return e;const i=n[t]!==k.Q?n[t]:a[t],o=i===(a[t]!==k.Q?a[t]:i)?i:void 0;return o===k.Q?e:{...e,[t]:o}},{})):t};var n,a},{});const s=(0,i.useCallback)(t=>{const n=t.map(v.R);e((0,w.V)(o.filter(({id:e})=>!n.includes(e)).map(({id:e})=>e)))},[e,o]),l=(0,i.useCallback)(()=>{e((0,w.V)([...new Set([...o.filter(({parentId:e})=>!e).map(({id:e})=>e),...o.flatMap(({parentId:e})=>Object.values(n).filter(t=>!t.parentId&&t.id===e).map(({id:e})=>e))])]))},[e,o,n]);return(0,i.useEffect)(()=>()=>{e((0,w.V)([]))},[e]),i.createElement(x,{deviceRadios:o,radios:r,onRemoveDeviceRadio:s,onSelectMeshingParents:l})},S=N},329109:(e,t,n)=>{n.d(t,{A:()=>m});var a=n(296540),i=n(691441),o=n(71479),r=n(132196),s=n(373229);const l=(0,o.A)("div")`
  height: 66px;
`,d=r.AH`
  padding: 0px !important;
`,m=({isDirty:e,onFormSubmit:t,onFormCancel:n,isInvalid:o,...r})=>e?a.createElement(i.A,null,a.createElement(s.A,{isDirty:e,onFormCancel:n,onFormSubmit:t,isInvalid:o,className:d,...r})):a.createElement(l,null)},372737:(e,t,n)=>{var a;n.d(t,{U:()=>a}),function(e){e.ARROW_DOWN="ArrowDown",e.ARROW_UP="ArrowUp",e.ENTER="Enter",e.ESCAPE="Escape"}(a||(a={}))},373229:(e,t,n)=>{n.d(t,{A:()=>d});var a=n(296540),i=n(758649),o=n(71479),r=n(566723),s=n(699784);const l=(0,o.A)("footer",{shouldForwardProp:e=>"hasFormResetButton"!==e})`
  display: flex;
  justify-content: ${({hasFormResetButton:e})=>e?"space-between":"flex-end"};
  padding: ${r.S2} ${r.fS};
  gap: ${r.kc};
`,d=({allowCancel:e,isDirty:t,isInvalid:n,isSubmitting:o,onFormSubmit:r,onFormReset:d,onFormCancel:m,className:c,submitButtonText:u,customButton:_,applyButton:p,applyButtonFirst:b,hideCancelButton:h,form:g})=>{const A=(0,a.useMemo)(()=>p||a.createElement(i.A,{name:"submit",variant:"primary",type:"submit",onClick:r,disabled:!t||n||o,form:g},a.createElement(s.sA,{id:u||"COMMON_ACTION_APPLY_CHANGES"})),[p,g,t,n,o,r,u]);return a.createElement(l,{className:c,hasFormResetButton:!!d},b?A:_,h?null:a.createElement(i.A,{name:"cancel",variant:"default",type:"button",onClick:m,disabled:!e&&!t},a.createElement(s.sA,{id:"COMMON_ACTION_CANCEL"})),d?a.createElement(i.A,{name:"reset",variant:"default",type:"button",onClick:d,disabled:!t},a.createElement(s.sA,{id:"COMMON_ACTION_RESET_TO_DEFAULTS"})):null,b?_:A)}},689965:(e,t,n)=>{n.d(t,{A:()=>_,I:()=>a});var a,i=n(296540),o=n(822336),r=n(427853),s=n(71479),l=n(825032),d=n(566723),m=n(294303);!function(e){e.ACCORDION="accordion",e.BUTTON_LIST="buttonList"}(a||(a={}));const c=(0,s.A)(m.A,{shouldForwardProp:e=>!["marginBottom","isButtonList","margin","flex","width","padding","nested","background"].includes(e)})`
  background-color: ${({background:e,nested:t,theme:{themeName:n}})=>e||o.Ay[n===l.S.DARK?`desktop-color-neutral-${t?"00":"01"}-dark`:`desktop-color-neutral-${t?"01":"00"}-light`]};
  padding: ${({theme:e,isButtonList:t,padding:n})=>n||(t?`0 ${e.spacing["spacing-l"]}`:e.spacing["spacing-l"])};
  margin-bottom: ${({theme:e,marginBottom:t})=>t||e.spacing["spacing-l"]};
  ${({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  `:""}
`,u=(0,s.A)(r.A,{shouldForwardProp:e=>!["marginBottom","margin","flex","padding","nested","background"].includes(e)})`
  background-color: ${({background:e,nested:t,theme:{themeName:n}})=>e||o.Ay[n===l.S.DARK?`desktop-color-neutral-${t?"00":"01"}-dark`:`desktop-color-neutral-${t?"01":"00"}-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===l.S.DARK?"desktop-color-neutral-01-dark":"desktop-color-neutral-00-light"]};
      height: 48px;
      padding: 0 ${d.Ln};
    }
    > div:nth-child(2) {
      margin-bottom: 0;
      padding: 0 ${d.Ln} ${d.Ln};
      > div {
        padding: 0;
      }
    }
  }
`,_=({type:e,marginBottom:t,margin:n,padding:o,flex:r,width:s,nested:l,...d})=>"items"in d?i.createElement(u,{marginBottom:t,margin:n,padding:o,flex:r,nested:l,...d}):i.createElement(c,{nested:l,width:s,marginBottom:t,margin:n,padding:o,flex:r,isButtonList:e===a.BUTTON_LIST,...d},d.children)},821580:(e,t,n)=>{n.d(t,{A:()=>s});var a=n(296540),i=n(454195),o=n(566723),r=n(294303);const s=e=>a.createElement(r.A,{paddingTop:o.YC,paddingBottom:o.YC,gap:o.Ln,rowGap:o.YC,flexWrap:"wrap",minHeight:i.b,alignItems:"center",...e})},885358:(e,t,n)=>{n.d(t,{J:()=>_,S:()=>u});var a=n(296540),i=n(943805),o=n(564985),r=n(170459),s=n(803167),l=n(430126),d=n(661010),m=n(605689),c=n(94017);const u=({antenna_id:e,antenna_gain:t,name:n,radio:a,ht:i,channel:r,tx_power_mode:l,tx_power:m,min_txpower:u,vwire_enabled:_,min_rssi_enabled:p,min_rssi:b,hard_noise_floor_enabled:h,sens_level_enabled:g,sens_level:A,assisted_roaming_enabled:f,assisted_roaming_rssi:v})=>({antenna_id:e,antenna_gain:t,name:n,type:a,ht:+i||s.L[a],channel:Number(r)||c.YQ,tx_power_mode:l||o.PB.AUTO,tx_power:m||u||0,vwire_enabled:_??!0,min_rssi_enabled:p||!1,min_rssi:+b||d.XN.DEFAULT,assisted_roaming_enabled:f||!1,assisted_roaming_rssi:v??d.Wh.DEFAULT,hard_noise_floor_enabled:h||!1,sens_level_enabled:g,sens_level:A}),_=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,uplinkMeshEnable: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,l.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,uplinkMeshEnable:i,uplinkPriority1:o,uplinkPriority2:s,radios:l,...d}=t,m={...d};return o&&(m.mesh_uplink_1=o,s&&(m.mesh_uplink_2=s)),m.mesh_sta_vap_enabled=t.uplinkMeshEnable,m.radio_table=l.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:l,...d}=a,m={...d,sens_level_enabled:l,sens_level:s,radio:o,name:i};return"custom"!==d.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.assisted_roaming_enabled||delete m.assisted_roaming_rssi,m.sens_level_enabled||delete m.sens_level,e&&(delete m.channel,delete m.ht),m})({isChannelWidthHidden:n[t.type],antenna:(0,r.Jj)(i,a.name)?i:null,minRssiStrictModeSupported:(0,r.Wg)(a)},t)}),m},[e.radio_table,e.model,e.antenna_table,n]),validationSchema:(0,m.m)(e.radio_table)}}}}]);