"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[57257],{531984(e,t,n){n.d(t,{w:()=>s});var o=n(602086),a=n(977872),i=n(205521);const s=e=>{const t=(0,a.wA)();(0,o.useEffect)(()=>{t((0,i.SQ)(e))},[t,e])}},762542(e,t,n){n.d(t,{y:()=>a});var o=n(531984);const a=e=>(0,o.w)(e.formState.isDirty)},796091(e,t,n){n.d(t,{A:()=>r});var o=n(274934),a=n(833466),i=n(309130),s=n(100978);const r=e=>(0,o.jsx)(s.A,{paddingTop:i.YC,paddingBottom:i.YC,gap:i.Ln,rowGap:i.YC,flexWrap:"wrap",minHeight:a.b,alignItems:"center",...e})},89469(e,t,n){n.d(t,{A:()=>r});var o=n(274934),a=n(602086),i=n(309130),s=n(100978);const r=(0,a.forwardRef)((e,t)=>(0,o.jsx)(s.A,{ref:t,flexDirection:"column",gap:i.kc,width:"100%",...e}))},756782(e,t,n){n.d(t,{A:()=>M});var o=n(274934),a=n(814557),i=n(602086),s=n(938984),r=n(247816),l=n(309130),d=n(590979),m=n(147045),c=n(291508),u=n(304151),_=n(100978),A=n(535322),I=n(89469);const p=(0,r.A)(A.A,(0,c.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,[m.L]:r,titleAction:c,isOutlined:A})=>{const M=(e=>i.Children.toArray(e).length>0)(e);return(0,o.jsx)(p,{marginBottom:"none",...d.A.addDataTestId(r??""),isOutlined:A,children:(0,o.jsxs)(_.A,{flexDirection:"column",...M&&{gap:l.Ln},width:"100%",children:[t?(0,o.jsxs)(_.A,{alignItems:"center",gap:l.YC,justifyContent:"space-between",width:"100%",children:[(0,o.jsxs)(_.A,{gap:l.YC,alignItems:"center",children:[(0,o.jsx)(s.A,{variant:"heading-medium",children:t}),n?(0,o.jsx)(u.A,{description:n,portal:!0,...a}):null]}),c?(0,o.jsx)(_.A,{children:c}):null]}):null,M?(0,o.jsx)(I.A,{children:e}):null]})})}},594492(e,t,n){n.d(t,{A:()=>c});var o=n(274934),a=n(602086),i=n(599110),s=n(247816),r=n(309130),l=n(470070),d=n(291508);const m=(0,s.A)("footer",(0,d.A)("hasFormResetButton"))`
  display: flex;
  justify-content: ${({hasFormResetButton:e})=>e?"space-between":"flex-end"};
  padding: ${r.S2} ${r.fS};
  gap: ${r.kc};
`,c=({allowCancel:e,isDirty:t,isInvalid:n,isSubmitting:s,onFormSubmit:r,onFormReset:d,onFormCancel:c,className:u,submitButtonText:_,customButton:A,applyButton:I,applyButtonFirst:p,hideCancelButton:M,form:O})=>{const h=(0,a.useMemo)(()=>I||(0,o.jsx)(i.A,{name:"submit",variant:"primary",type:"submit",onClick:r,disabled:!t||n||s,form:O,children:(0,o.jsx)(l.sA,{id:_||"COMMON_ACTION_APPLY_CHANGES"})}),[I,O,t,n,s,r,_]);return(0,o.jsxs)(m,{className:u,hasFormResetButton:!!d,children:[p?h:A,M?null:(0,o.jsx)(i.A,{name:"cancel",variant:"default",type:"button",onClick:c,disabled:!e&&!t,children:(0,o.jsx)(l.sA,{id:"COMMON_ACTION_CANCEL"})}),d?(0,o.jsx)(i.A,{name:"reset",variant:"default",type:"button",onClick:d,disabled:!t,children:(0,o.jsx)(l.sA,{id:"COMMON_ACTION_RESET_TO_DEFAULT"})}):null,p?A:h]})}},115114(e,t,n){n.d(t,{A:()=>m});var o=n(274934),a=n(232932),i=n(247816),s=n(409844),r=n(594492);const l=(0,i.A)("div")`
  height: 66px;
`,d=s.AH`
  padding: 0px !important;
`,m=({isDirty:e,onFormSubmit:t,onFormCancel:n,isInvalid:i,...s})=>e?(0,o.jsx)(a.A,{children:(0,o.jsx)(r.A,{isDirty:e,onFormCancel:n,onFormSubmit:t,isInvalid:i,className:d,...s})}):(0,o.jsx)(l,{})},957257(e,t,n){n.r(t),n.d(t,{default:()=>W});var o=n(274934),a=n(977872),i=n(42220),s=n(244081),r=n(159469),l=n(464920),d=n(762542),m=n(988646),c=n(23964),u=n(670241),_=n(635891),A=n(16805),I=n(877840),p=n(436417),M=n(449339),O=n(309130),h=n(756782),x=n(205521),N=n(700444),g=n(470070),C=n(233313),f=n(632991),S=n(969288),T=n(897166),E=n(625133),b=n(796091),v=n(100978),D=n(918071),j=n(115114);const y=e=>"number"==typeof e&&e>-1?{enabled:!0,value:e/1e3}:{enabled:!1},L=e=>{const t=Number(e);return t?Math.max(Math.round(1e3*t),-1):-1};var w=n(241792),F=n(260334);const P=100,B=.002,R=w.Ik({name:w.Yj().max(64,{message:(0,F.rn)("SETTINGS_COMMON_FIELD_SHOULD_NOT_EXCEED_MAX_LENGTH",{name:(0,F.rn)("COMMON_NAME"),limit:64})}),download_limit:w.KC([w.Ik({enabled:w.eu(!1)}),w.Ik({enabled:w.eu(!0),value:w.ai().min(B,{message:(0,F.rn)("COMMON_VALIDATION_MIN",{name:(0,F.rn)("COMMON_DOWNLOAD_BANDWIDTH_LIMIT"),min:B})}).max(P,{message:(0,F.rn)("COMMON_VALIDATION_MAX",{name:(0,F.rn)("COMMON_DOWNLOAD_BANDWIDTH_LIMIT"),max:P})})})]),upload_limit:w.KC([w.Ik({enabled:w.eu(!1)}),w.Ik({enabled:w.eu(!0),value:w.ai().min(B,{message:(0,F.rn)("COMMON_VALIDATION_MIN",{name:(0,F.rn)("COMMON_UPLOAD_BANDWIDTH_LIMIT"),min:B})}).max(P,{message:(0,F.rn)("COMMON_VALIDATION_MAX",{name:(0,F.rn)("COMMON_UPLOAD_BANDWIDTH_LIMIT"),max:P})})})])}),k="wifi-speed-limit-form",W=({activeItem:e})=>{const t=(0,a.wA)(),n=(0,a.d4)(T.EL),w=e._id===S.R6,F=(e=>{const t=e;return{name:t?.name||"",download_limit:y(t?.qos_rate_max_down),upload_limit:y(t?.qos_rate_max_up)}})(e),W=(0,p.m)({schema:R,defaultValues:F}),H=(0,i.FH)({control:W.control,name:"download_limit.enabled"}),U=(0,i.FH)({control:W.control,name:"upload_limit.enabled"}),V=(0,m.S)(u.v.SETTINGS_WIFI_SPEED_LIMIT_PROFILES);(0,d.y)(W);const G=W.handleSubmit(async n=>{const o={name:n.name,qos_rate_max_down:L(n.download_limit.enabled?n.download_limit.value:void 0),qos_rate_max_up:L(n.upload_limit.enabled?n.upload_limit.value:void 0)};return t(w?(0,f.$6)(o):(0,f.G4)(e._id,o,void 0,{resolveWithExisting:!1})).then(async e=>{await t((0,f.Ik)(void 0,{crudCacheStrategy:{type:s.e.CACHE},resolveWithExisting:!1})),t((0,x.SQ)(!1)),w&&t((0,x.XP)({id:e._id,type:M.H.WIFI_SPEED_LIMIT_PROFILE}))}).then(()=>{W.reset()}).catch(e=>{const n=(0,l.F)(e)?e:void 0;t((0,N.ox)({icon:r.C.danger,message:w?"SETTINGS_PROFILES_WIFI_SPEED_LIMIT_CREATE_FAILURE_TOAST":"SETTINGS_PROFILES_WIFI_SPEED_LIMIT_UPDATE_FAILURE_TOAST",values:{name:o.name},errorMessage:n?.msg,errorValues:n}))})});return(0,o.jsx)(I.A,{isDisabled:V||n,children:(0,o.jsxs)("form",{onSubmit:G,id:k,children:[(0,o.jsx)(c.A,{feature:u.v.SETTINGS_WIFI_SPEED_LIMIT_PROFILES,renderWarning:({children:e})=>(0,o.jsx)(C.A,{style:{marginBottom:O.Ln},children:(0,o.jsx)(h.A,{children:e})})}),(0,o.jsxs)(h.A,{children:[(0,o.jsx)(_.A,{autoFocus:!0,control:W.control,name:"name",label:(0,o.jsx)(g.sA,{id:"COMMON_NAME"})}),(0,o.jsx)(b.A,{children:(0,o.jsx)(E.A,{control:W.control,name:"download_limit.enabled",tooltip:(0,o.jsx)(g.sA,{id:"SETTINGS_PROFILES_WIFI_SPEED_LIMIT_FORM_DESCRIPTION_LIMIT_BANDWIDTH_DOWNLOAD",values:{minMbps:B,maxMbps:P}}),children:(0,o.jsx)(g.sA,{id:"COMMON_DOWNLOAD_BANDWIDTH_LIMIT"})})}),H?(0,o.jsx)(v.A,{width:D.G,children:(0,o.jsx)(A.A,{control:W.control,name:"download_limit.value",contentAfter:(0,o.jsx)(g.sA,{id:"COMMON_SPEED_METRICS_MBPS"})})}):null,(0,o.jsx)(b.A,{children:(0,o.jsx)(E.A,{control:W.control,name:"upload_limit.enabled",tooltip:(0,o.jsx)(g.sA,{id:"SETTINGS_PROFILES_WIFI_SPEED_LIMIT_FORM_DESCRIPTION_LIMIT_BANDWIDTH_UPLOAD",values:{minMbps:B,maxMbps:P}}),children:(0,o.jsx)(g.sA,{id:"COMMON_UPLOAD_BANDWIDTH_LIMIT"})})}),U?(0,o.jsx)(v.A,{width:D.G,children:(0,o.jsx)(A.A,{control:W.control,name:"upload_limit.value",contentAfter:(0,o.jsx)(g.sA,{id:"COMMON_SPEED_METRICS_MBPS"})})}):null]}),(0,o.jsx)(j.A,{onFormCancel:()=>W.reset(),isDirty:W.formState.isDirty||w&&!V,hideCancelButton:!W.formState.isDirty,submitButtonText:w?"COMMON_ACTION_ADD":void 0,form:k,isSubmitting:W.formState.isSubmitting})]})})}},833466(e,t,n){n.d(t,{b:()=>o});const o=32},918071(e,t,n){n.d(t,{G:()=>o});const o=165},436417(e,t,n){n.d(t,{m:()=>r});var o=n(602086),a=n(42220),i=n(369289),s=n(721533);function r({schema:e,defaultValues:t,presets:n}){const r=(0,o.useMemo)(()=>n?(0,i.A)(n,e=>e.defaultValues):{},[n]),l=(0,o.useMemo)(()=>({...t,...r}),[r,t]),d=(0,a.mN)({resolver:(0,s.u)(e),shouldFocusError:!0,defaultValues:l,shouldUseNativeValidation:!1,mode:"onTouched"}),m=(0,o.useRef)(l);m.current=l;const c=(0,o.useCallback)((...e)=>{const[t,...n]=e;return d.reset(t?{...t,...r}:m.current,...n)},[r,d]);return{...d,reset:c,formState:{...d.formState,isDirty:!!Object.keys(d.formState.dirtyFields).length,isSubmitting:d.formState.isSubmitting},handleSubmit:(...e)=>d.handleSubmit(e[0],(t,...n)=>{const o=Object.keys(t)[0];if(o)try{const e=document.getElementsByName(o)?.[0];e?.scrollIntoView?.({behavior:"smooth",block:"center"}),e?.focus?.({preventScroll:!0})}catch{}e[1]?.(t,...n)})}}},260334(e,t,n){n.d(t,{L_:()=>m,MS:()=>d,rn:()=>l});var o=n(602086),a=n(949812),i=n(765282),s=n(470070);const r="{::}",l=(e,t)=>`${e}${r}${JSON.stringify(t??{})}`,d=(e,t)=>{if("string"!=typeof t)return;const[n,...o]=t.split(r);if(!n||!o.length)return t;let a={};try{a=Object.fromEntries(Object.entries(JSON.parse(o.join(r))).map(([t,n])=>[t,"string"==typeof n?d(e,n):n]))}catch{}return e.formatMessage({id:n},a)};function m(){const{formatMessage:e}=(0,s.tz)();return(0,o.useCallback)(t=>d({formatMessage:e},t),[e])}a.pJ((e,t)=>e.message?{message:e.message}:e.code===i.eq.too_small&&"string"===e.type?{message:l("COMMON_MIN_CHARS",{min:Number(e.minimum)})}:e.code===i.eq.too_big&&"string"===e.type?{message:l("COMMON_MAX_CHARS",{name:l("COMMON_VALUE"),max:Number(e.maximum)})}:e.code===i.eq.invalid_type&&"array"===e.expected&&"undefined"===e.received?{message:l("COMMON_SELECT_AT_LEAST_ONE_ITEM")}:e.code===i.eq.too_small&&"array"===e.type?{message:l("COMMON_ADD_AT_LEAST_X_ITEMS",{min:Number(e.minimum)})}:e.code===i.eq.invalid_type&&"undefined"===e.received?{message:l("COMMON_VALIDATION_VALUE_REQUIRED")}:e.code===i.eq.invalid_type&&"number"===e.expected?{message:l("COMMON_VALIDATION_PLEASE_ENTER_A_NUMBER")}:{message:t.defaultError})},625133(e,t,n){n.d(t,{A:()=>m});var o=n(274934),a=n(42220),i=n(762705),s=n(309130),r=n(304151),l=n(100978),d=n(184931);const m=function({control:e,name:t,children:n,tooltip:m,tooltipProps:c,onToggle:u,renderCheckbox:_,inputClassName:A}){const I=(0,d.mQ)();return(0,o.jsx)(a.xI,{control:e,name:t,render:({field:e})=>{const t=(0,o.jsx)(i.A,{id:e.name,onChange:({target:{checked:t}})=>{e.onChange(t),u?.(t)},checked:!!e.value,disabled:I,inputClassName:A,children:n});return(0,o.jsxs)(l.A,{gap:s.YC,alignItems:"center",children:[_?_(t,e):t,m?(0,o.jsx)(r.A,{description:m,...c}):null]})}})}},16805(e,t,n){n.d(t,{A:()=>d});var o=n(274934),a=n(42220),i=n(843615),s=n(309130),r=n(260334),l=n(184931);const d=function({control:e,name:t,label:n,placeholder:d,tooltip:m,tooltipProps:c,contentAfter:u,arrowSize:_,min:A,max:I,step:p,value:M,iconBefore:O,onAfterChange:h,onChange:x}){const N=(0,l.mQ)(),g=(0,r.L_)();return(0,o.jsx)(a.xI,{control:e,name:t,render:({field:{ref:e,...r},fieldState:l,formState:C})=>(0,o.jsx)(i.A,{type:"number",variant:"secondary",width:"100%",...r,value:M??r.value??"",onChange:e=>{x?x(e,C):r.onChange(e.target.value?.length?+e.target.value:null),h?.(e)},disabled:N,invalid:l.invalid?g((0,a.Jt)(C.errors,t)?.message)||!0:void 0,labelTooltip:m,labelTooltipProps:{style:{opacity:N?s.xN:void 0,...c?.style},...c},label:n,placeholder:d,arrowSize:_,contentAfter:u,iconBefore:O,step:p,min:A,max:I})})}},635891(e,t,n){n.d(t,{A:()=>m});var o=n(274934),a=n(42220),i=n(843615),s=n(95032),r=n(309130),l=n(260334),d=n(184931);const m=function({control:e,name:t,label:n,placeholder:m,tooltip:c,tooltipProps:u,autoFocus:_,motif:A,onChange:I,onBlur:p,onAfterChange:M,onPaste:O,onKeyDown:h,passwordToggle:x,type:N,helperMessage:g,autoComplete:C,contentBefore:f,contentAfter:S,onFocus:T,value:E,invalid:b}){const v=(0,d.mQ)(),D=(0,d.Im)(),j=(0,d.q)(),y=(0,l.L_)();return(0,o.jsx)(a.xI,{control:e,name:t,render:({field:e,fieldState:l,formState:d})=>(0,o.jsx)(i.A,{type:N||(x?"password":"text"),variant:"secondary",width:"100%",autoFocus:_,...e,onChange:t=>{I?I(t,e,d):e.onChange(t),M?.(t)},onBlur:t=>{p?p(t,e,d):e.onBlur()},onFocus:T,onPaste:O,disabled:v,value:E??e.value?.toString(),invalid:b||(l.invalid?(0,o.jsxs)(s.A,{variant:"inherit",style:{overflowWrap:"break-word"},children:[y((0,a.Jt)(d.errors,t)?.message)||!0," "]}):void 0),label:n,placeholder:m,labelTooltip:c,labelTooltipProps:{style:{opacity:D?r.xN:void 0,pointerEvents:j?"none":void 0,...u?.style},...u},motif:A,passwordToggle:x,helperMessage:g,autoComplete:C,onKeyDown:h,contentBefore:f,contentAfter:S})})}}}]);