"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[95703],{333316(e,t,n){n.d(t,{A:()=>i});const i=(0,n(602086).createContext)({isStandalone:!0,header:[null,()=>{}],footer:[null,()=>{}]})},232932(e,t,n){n.d(t,{A:()=>E});var i=n(602086),a=n(333316);function E(e){const{children:t}=e,{isStandalone:n,footer:[,E]}=(0,i.useContext)(a.A);return(0,i.useLayoutEffect)(()=>{if(!n)return E(t),()=>E(null)},[n,t]),i.createElement(i.Fragment,null,n&&t)}},554844(e,t,n){var i;n.d(t,{OK:()=>E,t3:()=>i,tI:()=>s,vx:()=>a}),function(e){e[e.NONE=0]="NONE",e[e.ONE=1]="ONE",e[e.TWO=2]="TWO",e[e.THREE=3]="THREE",e[e.FOUR=4]="FOUR",e[e.FIVE=5]="FIVE",e[e.SIX=6]="SIX",e[e.SEVEN=7]="SEVEN",e[e.EIGHT=8]="EIGHT",e[e.NINE=9]="NINE",e[e.TEN=10]="TEN",e[e.ELEVEN=11]="ELEVEN",e[e.TWELVE=12]="TWELVE",e[e.THIRTEEN=13]="THIRTEEN"}(i||(i={}));const a={[i.NONE]:"COMMON_NONE",[i.ONE]:"COMMON_TUNNEL_TYPE_1",[i.TWO]:"COMMON_TUNNEL_TYPE_2",[i.THREE]:"COMMON_TUNNEL_TYPE_3",[i.FOUR]:"COMMON_TUNNEL_TYPE_4",[i.FIVE]:"COMMON_TUNNEL_TYPE_5",[i.SIX]:"COMMON_TUNNEL_TYPE_6",[i.SEVEN]:"COMMON_TUNNEL_TYPE_7",[i.EIGHT]:"COMMON_TUNNEL_TYPE_8",[i.NINE]:"COMMON_TUNNEL_TYPE_9",[i.TEN]:"COMMON_TUNNEL_TYPE_10",[i.ELEVEN]:"COMMON_TUNNEL_TYPE_11",[i.TWELVE]:"COMMON_TUNNEL_TYPE_12",[i.THIRTEEN]:"COMMON_TUNNEL_TYPE_13"};var E;!function(e){e[e.NONE=0]="NONE",e[e.ONE=1]="ONE",e[e.TWO=2]="TWO",e[e.THREE=3]="THREE",e[e.FOUR=4]="FOUR",e[e.FIVE=5]="FIVE",e[e.SIX=6]="SIX",e[e.SEVEN=7]="SEVEN",e[e.EIGHT=8]="EIGHT",e[e.NINE=9]="NINE",e[e.TEN=10]="TEN",e[e.ELEVEN=11]="ELEVEN",e[e.TWELVE=12]="TWELVE",e[e.THIRTEEN=13]="THIRTEEN",e[e.FOURTEEN=14]="FOURTEEN",e[e.FIFTEEN=15]="FIFTEEN"}(E||(E={}));const s={[E.NONE]:"COMMON_NONE",[E.ONE]:"COMMON_TUNNEL_MEDIUM_TYPE_1",[E.TWO]:"COMMON_TUNNEL_MEDIUM_TYPE_2",[E.THREE]:"COMMON_TUNNEL_MEDIUM_TYPE_3",[E.FOUR]:"COMMON_TUNNEL_MEDIUM_TYPE_4",[E.FIVE]:"COMMON_TUNNEL_MEDIUM_TYPE_5",[E.SIX]:"COMMON_TUNNEL_MEDIUM_TYPE_6",[E.SEVEN]:"COMMON_TUNNEL_MEDIUM_TYPE_7",[E.EIGHT]:"COMMON_TUNNEL_MEDIUM_TYPE_8",[E.NINE]:"COMMON_TUNNEL_MEDIUM_TYPE_9",[E.TEN]:"COMMON_TUNNEL_MEDIUM_TYPE_10",[E.ELEVEN]:"COMMON_TUNNEL_MEDIUM_TYPE_11",[E.TWELVE]:"COMMON_TUNNEL_MEDIUM_TYPE_12",[E.THIRTEEN]:"COMMON_TUNNEL_MEDIUM_TYPE_13",[E.FOURTEEN]:"COMMON_TUNNEL_MEDIUM_TYPE_14",[E.FIFTEEN]:"COMMON_TUNNEL_MEDIUM_TYPE_15"}},593091(e,t,n){n.d(t,{A:()=>E});var i=n(843871),a=n(531984);const E=()=>{const{dirty:e}=(0,i.j7)();return(0,a.w)(e),null}},531984(e,t,n){n.d(t,{w:()=>s});var i=n(602086),a=n(977872),E=n(205521);const s=e=>{const t=(0,a.wA)();(0,i.useEffect)(()=>{t((0,E.SQ)(e))},[t,e])}},535322(e,t,n){n.d(t,{A:()=>m,I:()=>i});var i,a=n(274934),E=n(814557),s=n(158885),l=n(247816),d=n(565527),N=n(309130),o=n(100978),r=n(291508);!function(e){e.ACCORDION="accordion",e.BUTTON_LIST="buttonList"}(i||(i={}));const _=(0,l.A)(o.A,(0,r.A)("marginBottom","isButtonList","margin","flex","width","padding","nested","background"))`
  background-color: ${({background:e,nested:t,theme:{themeName:n}})=>e||E.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 ${N.Ln}`:N.Ln)};
  margin-bottom: ${({marginBottom:e})=>e||N.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}})=>E.Ay[`desktop-border-divider-${e}`]};\n      &:last-child {\n        border-bottom: none;\n      }\n    }\n  `:""}
`,O=(0,l.A)(s.A,(0,r.A)("marginBottom","margin","flex","padding","nested","background"))`
  background-color: ${({background:e,nested:t,theme:{themeName:n}})=>e||E.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||E.Ay[t===d.S.DARK?`desktop-color-neutral-01-${d.S.DARK}`:`desktop-color-neutral-00-${d.S.LIGHT}`]};
      height: 48px;
      padding: 0 ${N.Ln};
    }
    > div:nth-child(2) {
      margin-bottom: 0;
      padding: 0;
      > div {
        padding: 0 ${N.Ln} ${N.Ln};
      }
    }
  }
`,m=({type:e,marginBottom:t,margin:n,padding:E,flex:s,width:l,nested:d,...N})=>"items"in N?(0,a.jsx)(O,{marginBottom:t,margin:n,padding:E,flex:s,nested:d,...N}):(0,a.jsx)(_,{nested:d,width:l,marginBottom:t,margin:n,padding:E,flex:s,isButtonList:e===i.BUTTON_LIST,...N,children:N.children})},89469(e,t,n){n.d(t,{A:()=>l});var i=n(274934),a=n(602086),E=n(309130),s=n(100978);const l=(0,a.forwardRef)((e,t)=>(0,i.jsx)(s.A,{ref:t,flexDirection:"column",gap:E.kc,width:"100%",...e}))},756782(e,t,n){n.d(t,{A:()=>M});var i=n(274934),a=n(814557),E=n(602086),s=n(938984),l=n(247816),d=n(309130),N=n(590979),o=n(147045),r=n(291508),_=n(304151),O=n(100978),m=n(535322),T=n(89469);const u=(0,l.A)(m.A,(0,r.A)("isOutlined"))`
  border: ${({theme:{themeName:e},isOutlined:t})=>`1px solid ${t?a.Ay[`desktop-color-ublue-06-${e}`]:"transparent"}`};
`,M=({children:e,title:t,tooltip:n,tooltipProps:a,[o.L]:l,titleAction:r,isOutlined:m})=>{const M=(e=>E.Children.toArray(e).length>0)(e);return(0,i.jsx)(u,{marginBottom:"none",...N.A.addDataTestId(l??""),isOutlined:m,children:(0,i.jsxs)(O.A,{flexDirection:"column",...M&&{gap:d.Ln},width:"100%",children:[t?(0,i.jsxs)(O.A,{alignItems:"center",gap:d.YC,justifyContent:"space-between",width:"100%",children:[(0,i.jsxs)(O.A,{gap:d.YC,alignItems:"center",children:[(0,i.jsx)(s.A,{variant:"heading-medium",children:t}),n?(0,i.jsx)(_.A,{description:n,portal:!0,...a}):null]}),r?(0,i.jsx)(O.A,{children:r}):null]}):null,M?(0,i.jsx)(T.A,{children:e}):null]})})}},594492(e,t,n){n.d(t,{A:()=>r});var i=n(274934),a=n(602086),E=n(599110),s=n(247816),l=n(309130),d=n(470070),N=n(291508);const o=(0,s.A)("footer",(0,N.A)("hasFormResetButton"))`
  display: flex;
  justify-content: ${({hasFormResetButton:e})=>e?"space-between":"flex-end"};
  padding: ${l.S2} ${l.fS};
  gap: ${l.kc};
`,r=({allowCancel:e,isDirty:t,isInvalid:n,isSubmitting:s,onFormSubmit:l,onFormReset:N,onFormCancel:r,className:_,submitButtonText:O,customButton:m,applyButton:T,applyButtonFirst:u,hideCancelButton:M,form:c})=>{const A=(0,a.useMemo)(()=>T||(0,i.jsx)(E.A,{name:"submit",variant:"primary",type:"submit",onClick:l,disabled:!t||n||s,form:c,children:(0,i.jsx)(d.sA,{id:O||"COMMON_ACTION_APPLY_CHANGES"})}),[T,c,t,n,s,l,O]);return(0,i.jsxs)(o,{className:_,hasFormResetButton:!!N,children:[u?A:m,M?null:(0,i.jsx)(E.A,{name:"cancel",variant:"default",type:"button",onClick:r,disabled:!e&&!t,children:(0,i.jsx)(d.sA,{id:"COMMON_ACTION_CANCEL"})}),N?(0,i.jsx)(E.A,{name:"reset",variant:"default",type:"button",onClick:N,disabled:!t,children:(0,i.jsx)(d.sA,{id:"COMMON_ACTION_RESET_TO_DEFAULT"})}):null,u?m:A]})}},115114(e,t,n){n.d(t,{A:()=>o});var i=n(274934),a=n(232932),E=n(247816),s=n(409844),l=n(594492);const d=(0,E.A)("div")`
  height: 66px;
`,N=s.AH`
  padding: 0px !important;
`,o=({isDirty:e,onFormSubmit:t,onFormCancel:n,isInvalid:E,...s})=>e?(0,i.jsx)(a.A,{children:(0,i.jsx)(l.A,{isDirty:e,onFormCancel:n,onFormSubmit:t,isInvalid:E,className:N,...s})}):(0,i.jsx)(d,{})},195703(e,t,n){n.r(t),n.d(t,{default:()=>P});var i=n(274934),a=n(977872),E=n(602086),s=n(843871),l=n(159469),d=n(464920),N=n(593091),o=n(449339),r=n(309130),_=n(115114),O=n(100978),m=n(205521),T=n(700444),u=n(970746),M=n(741417),c=n(554844),A=n(845665),p=n(591256),I=n(897166),L=n(969288),x=n(950804),h=n(470070),b=n(126578),C=n(570866),g=n(756782),U=n(164487),S=n(120197);const R=({disabled:e})=>{const{setValues:t,values:n}=(0,s.j7)(),a=(0,E.useCallback)((e,i)=>{t({...n,vlan:i,tunnel_type:n.tunnel_type===c.t3.NONE?c.t3.THIRTEEN:n.tunnel_type,tunnel_medium_type:n.tunnel_medium_type===c.OK.NONE?c.OK.SIX:n.tunnel_medium_type})},[t,n]);return(0,i.jsx)(S.A,{width:162,name:"vlan",disabled:e,type:"number",variant:"secondary",label:(0,i.jsx)(U.A,{htmlFor:"vlan",tooltip:(0,i.jsx)(h.sA,{id:"SETTINGS_NETWORKS_FORM_FIELD_VLAN_ID_DESCRIPTION"}),children:(0,i.jsx)(h.sA,{id:"COMMON_VLAN_ID"})}),onChange:a})},f=({disabled:e})=>(0,i.jsx)(S.A,{full:!0,name:"name",variant:"secondary",disabled:e,label:(0,i.jsx)(h.sA,{id:"COMMON_LABEL_USERNAME"})}),y=[c.t3.NONE,c.t3.ONE,c.t3.TWO,c.t3.THREE,c.t3.FOUR,c.t3.FIVE,c.t3.SIX,c.t3.SEVEN,c.t3.EIGHT,c.t3.NINE,c.t3.TEN,c.t3.ELEVEN,c.t3.TWELVE,c.t3.THIRTEEN].map(e=>({value:e,label:c.vx[e],values:{id:e}})),v=({disabled:e})=>(0,i.jsx)(S.A,{full:!0,name:"tunnel_type",type:"dropdown",variant:"secondary",disabled:e,options:y,translateOptions:!0,label:(0,i.jsx)(h.sA,{id:"COMMON_TUNNEL_TYPE"}),portal:!0}),j=[c.OK.NONE,c.OK.ONE,c.OK.TWO,c.OK.THREE,c.OK.FOUR,c.OK.FIVE,c.OK.SIX,c.OK.SEVEN,c.OK.EIGHT,c.OK.NINE,c.OK.TEN,c.OK.ELEVEN,c.OK.TWELVE,c.OK.THIRTEEN,c.OK.FOURTEEN,c.OK.FIFTEEN].map(e=>({value:e,label:c.tI[e],values:{id:e}})),F=({disabled:e})=>(0,i.jsx)(S.A,{full:!0,name:"tunnel_medium_type",type:"dropdown",variant:"secondary",disabled:e,options:j,translateOptions:!0,label:(0,i.jsx)(h.sA,{id:"COMMON_TUNNEL_MEDIUM_TYPE"}),portal:!0,validated:!0}),D=({disabled:e})=>(0,i.jsx)(S.A,{full:!0,passwordToggle:!0,type:"password",name:"password",variant:"secondary",disabled:e,label:(0,i.jsx)(h.sA,{id:"COMMON_PASSWORD"})}),V=({disabled:e})=>(0,i.jsxs)(g.A,{children:[(0,i.jsx)(f,{disabled:e}),(0,i.jsx)(D,{disabled:e}),(0,i.jsx)(R,{disabled:e}),(0,i.jsx)(v,{disabled:e}),(0,i.jsx)(F,{disabled:e})]}),P=({activeItem:e})=>{const t=e?._id===L.R6?void 0:e,n=(0,a.wA)(),g=(0,a.d4)(I.EL),U=(0,a.d4)(p.eI),S=(0,a.d4)(u.Of),R=(0,E.useMemo)(()=>({name:t?.name||"",password:t?.x_password||"",vlan:t?.vlan,tunnel_medium_type:t?.tunnel_medium_type||c.OK.NONE,tunnel_type:t?.tunnel_type||c.t3.NONE}),[t]),f=(0,E.useCallback)((e,{setSubmitting:i})=>{i(!0);const a={...t,name:e.name,x_password:e.password,vlan:e.vlan,tunnel_type:e.tunnel_type===c.t3.NONE?void 0:e.tunnel_type,tunnel_medium_type:e.tunnel_medium_type===c.OK.NONE?void 0:e.tunnel_medium_type};return n(t?._id?(0,A.cH)([a],{failureToast:null}):(0,A.T4)([{...a,filter_ids:[],group_policy:M.d.GLOBAL}],{failureToast:null})).then(e=>{n((0,m.SQ)(!1)),n((0,m.XP)({type:o.H.RADIUS_USER,id:e?.[0]?._id}))}).then(()=>{n((0,A.xL)())}).catch(t=>{const i=(0,d.F)(t)?t:void 0;n((0,T.ox)({errorMessage:i?.msg,errorValues:i,icon:l.C.danger,message:"SETTINGS_GATEWAY_RADIUS_CREATE_USER_FORM_ERROR_MESSAGE",values:{name:e.name}}))}).finally(()=>{i(!1)})},[n,t]),y=(0,E.useMemo)(()=>((e,t)=>x.A.object().shape({name:x.A.string().label("COMMON_LABEL_USERNAME").max(48).test({name:"isUsernameValid",message:(0,i.jsx)(h.sA,{id:"SETTINGS_RADIUS_USER_NAME_VALIDATION"}),test:e=>!e?.match(C.l6)}).test({name:"isUsernameUnique",message:(0,i.jsx)(h.sA,{id:"SETTINGS_VALIDATION_MUST_BE_UNIQUE",values:{field:(0,i.jsx)(h.sA,{id:"COMMON_LABEL_USERNAME"})}}),test:e=>!t.some(({name:t})=>t===e)}),password:x.A.string().label("COMMON_PASSWORD").test({name:"isPasswordFourCharactersLong",message:(0,i.jsx)(h.sA,{id:"SETTINGS_VALIDATION_PASSWORD_X_CHARACTERS_LONG",values:{length:4}}),test:e=>(e?.length||0)>=4}).required(),vlan:x.A.number().label("COMMON_VLAN_ID").integer().min(b.C.MIN_VLAN).max(e?b.C.MAX_VLAN_UDM:b.C.MAX_VLAN).nullable(),tunnel_type:x.A.number().oneOf(Object.values(c.t3)),tunnel_medium_type:x.A.number().label("COMMON_TUNNEL_MEDIUM_TYPE").oneOf(Object.values(c.OK)).when("tunnel_type",{is:e=>e!==c.t3.NONE,then:x.A.number().min(c.OK.ONE)})}))(U,t?._id?S.filter(({_id:e})=>e!==t._id):S),[U,t,S]);return(0,i.jsx)(s.l1,{initialValues:R,onSubmit:f,enableReinitialize:!0,validationSchema:y,children:({dirty:e,resetForm:n,submitForm:a})=>(0,i.jsxs)("form",{onSubmit:a,style:{height:"100%"},children:[(0,i.jsx)(N.A,{}),(0,i.jsx)(O.A,{flexDirection:"column",gap:r.Ln,children:(0,i.jsx)(V,{disabled:g})}),(0,i.jsx)(_.A,{onFormCancel:n,isDirty:e,onFormSubmit:a,hideCancelButton:!e,submitButtonText:t?void 0:"COMMON_ACTION_ADD"})]})},e?._id)}}}]);