"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[49786],{531984(e,t,n){n.d(t,{w:()=>r});var o=n(602086),a=n(977872),s=n(205521);const r=e=>{const t=(0,a.wA)();(0,o.useEffect)(()=>{t((0,s.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:()=>i});var o=n(274934),a=n(833466),s=n(309130),r=n(100978);const i=e=>(0,o.jsx)(r.A,{paddingTop:s.YC,paddingBottom:s.YC,gap:s.Ln,rowGap:s.YC,flexWrap:"wrap",minHeight:a.b,alignItems:"center",...e})},89469(e,t,n){n.d(t,{A:()=>i});var o=n(274934),a=n(602086),s=n(309130),r=n(100978);const i=(0,a.forwardRef)((e,t)=>(0,o.jsx)(r.A,{ref:t,flexDirection:"column",gap:s.kc,width:"100%",...e}))},756782(e,t,n){n.d(t,{A:()=>O});var o=n(274934),a=n(505817),s=n(602086),r=n(179102),i=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,i.A)(A.A,(0,c.A)("isOutlined"))`
  border: ${({theme:{themeName:e},isOutlined:t})=>`1px solid ${t?a.Ay[`desktop-color-ublue-06-${e}`]:"transparent"}`};
`,O=({children:e,title:t,tooltip:n,tooltipProps:a,[m.L]:i,titleAction:c,isOutlined:A})=>{const O=(e=>s.Children.toArray(e).length>0)(e);return(0,o.jsx)(p,{marginBottom:"none",...d.A.addDataTestId(i??""),isOutlined:A,children:(0,o.jsxs)(_.A,{flexDirection:"column",...O&&{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)(r.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,O?(0,o.jsx)(I.A,{children:e}):null]})})}},115114(e,t,n){n.d(t,{A:()=>m});var o=n(274934),a=n(388294),s=n(247816),r=n(409844),i=n(751636);const l=(0,s.A)("div")`
  height: 66px;
`,d=r.AH`
  padding: 0px !important;
`,m=({isDirty:e,onFormSubmit:t,onFormCancel:n,isInvalid:s,...r})=>e?(0,o.jsx)(a.A,{children:(0,o.jsx)(i.A,{isDirty:e,onFormCancel:n,onFormSubmit:t,isInvalid:s,className:d,...r})}):(0,o.jsx)(l,{})},751636(e,t,n){n.d(t,{A:()=>m});var o=n(274934),a=n(526744),s=n(470070),r=n(247816),i=n(291508),l=n(309130);const d=(0,r.A)("footer",(0,i.A)("hasFormResetButton"))`
  display: flex;
  justify-content: ${({hasFormResetButton:e})=>e?"space-between":"flex-end"};
  padding: ${l.S2} ${l.fS};
  gap: ${l.kc};
`,m=({allowCancel:e,isDirty:t,isInvalid:n,isSubmitting:r,onFormSubmit:i,onFormReset:l,onFormCancel:m,className:c,submitButtonText:u,customButton:_,applyButton:A,hideCancelButton:I,form:p,testConfigFooter:O})=>(0,o.jsx)(d,{className:c,hasFormResetButton:!!l,children:O||(0,o.jsxs)(o.Fragment,{children:[_,I?null:(0,o.jsx)(a.A,{name:"cancel",variant:"default",type:"button",onClick:m,disabled:!e&&!t,children:(0,o.jsx)(s.sA,{id:"COMMON_ACTION_CANCEL"})}),l?(0,o.jsx)(a.A,{name:"reset",variant:"default",type:"button",onClick:l,disabled:!t,children:(0,o.jsx)(s.sA,{id:"COMMON_ACTION_RESET_TO_DEFAULT"})}):null,A||(0,o.jsx)(a.A,{name:"submit",variant:"primary",type:"submit",onClick:i,disabled:!t||n||r,form:p,children:(0,o.jsx)(s.sA,{id:u||"COMMON_ACTION_APPLY_CHANGES"})})]})})},749786(e,t,n){n.r(t),n.d(t,{default:()=>k});var o=n(274934),a=n(977872),s=n(42220),r=n(244081),i=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(121713),O=n(449339),f=n(309130),M=n(756782),g=n(205521),h=n(700444),N=n(470070),x=n(233313),C=n(632991),S=n(969288),T=n(897166),E=n(625133),D=n(796091),b=n(100978),v=n(918071),L=n(115114),y=n(157889),j=n(241792),w=n(260334);const F=100,P=.002,B=j.Ik({name:j.Yj().max(64,{message:(0,w.rn)("SETTINGS_COMMON_FIELD_SHOULD_NOT_EXCEED_MAX_LENGTH",{name:(0,w.rn)("COMMON_NAME"),limit:64})}),download_limit:j.KC([j.Ik({enabled:j.eu(!1)}),j.Ik({enabled:j.eu(!0),value:j.ai().min(P,{message:(0,w.rn)("COMMON_VALIDATION_MIN",{name:(0,w.rn)("COMMON_DOWNLOAD_BANDWIDTH_LIMIT"),min:P})}).max(F,{message:(0,w.rn)("COMMON_VALIDATION_MAX",{name:(0,w.rn)("COMMON_DOWNLOAD_BANDWIDTH_LIMIT"),max:F})})})]),upload_limit:j.KC([j.Ik({enabled:j.eu(!1)}),j.Ik({enabled:j.eu(!0),value:j.ai().min(P,{message:(0,w.rn)("COMMON_VALIDATION_MIN",{name:(0,w.rn)("COMMON_UPLOAD_BANDWIDTH_LIMIT"),min:P})}).max(F,{message:(0,w.rn)("COMMON_VALIDATION_MAX",{name:(0,w.rn)("COMMON_UPLOAD_BANDWIDTH_LIMIT"),max:F})})})])}),R="wifi-speed-limit-form",k=({activeItem:e})=>{const t=(0,a.wA)(),n=(0,a.d4)(T.EL),j=e._id===S.R6,w=(0,y.wY)(e),k=(0,p.m)({schema:B,defaultValues:w}),W=(0,s.FH)({control:k.control,name:"download_limit.enabled"}),H=(0,s.FH)({control:k.control,name:"upload_limit.enabled"}),V=(0,m.S)(u.v.SETTINGS_WIFI_SPEED_LIMIT_PROFILES);(0,d.y)(k);const U=k.handleSubmit(async n=>{const o={name:n.name,qos_rate_max_down:(0,y.xS)(n.download_limit.enabled?n.download_limit.value:void 0),qos_rate_max_up:(0,y.xS)(n.upload_limit.enabled?n.upload_limit.value:void 0)};return t(j?(0,C.$6)(o):(0,C.G4)(e._id,o,void 0,{resolveWithExisting:!1})).then(async e=>{await t((0,C.Ik)(void 0,{crudCacheStrategy:{type:r.e.CACHE},resolveWithExisting:!1})),t((0,g.SQ)(!1)),j&&t((0,g.XP)({id:e._id,type:O.H.WIFI_SPEED_LIMIT_PROFILE}))}).then(()=>{k.reset()}).catch(e=>{const n=(0,l.F)(e)?e:void 0;t((0,h.ox)({icon:i.C.danger,message:j?"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:U,id:R,children:[(0,o.jsx)(c.A,{feature:u.v.SETTINGS_WIFI_SPEED_LIMIT_PROFILES,renderWarning:({children:e})=>(0,o.jsx)(x.A,{style:{marginBottom:f.Ln},children:(0,o.jsx)(M.A,{children:e})})}),(0,o.jsxs)(M.A,{children:[(0,o.jsx)(_.A,{autoFocus:!0,control:k.control,name:"name",label:(0,o.jsx)(N.sA,{id:"COMMON_NAME"})}),(0,o.jsx)(D.A,{children:(0,o.jsx)(E.A,{control:k.control,name:"download_limit.enabled",tooltip:(0,o.jsx)(N.sA,{id:"SETTINGS_PROFILES_WIFI_SPEED_LIMIT_FORM_DESCRIPTION_LIMIT_BANDWIDTH_DOWNLOAD",values:{minMbps:P,maxMbps:F}}),children:(0,o.jsx)(N.sA,{id:"COMMON_DOWNLOAD_BANDWIDTH_LIMIT"})})}),W?(0,o.jsx)(b.A,{width:v.G,children:(0,o.jsx)(A.A,{control:k.control,name:"download_limit.value",contentAfter:(0,o.jsx)(N.sA,{id:"COMMON_SPEED_METRICS_MBPS"})})}):null,(0,o.jsx)(D.A,{children:(0,o.jsx)(E.A,{control:k.control,name:"upload_limit.enabled",tooltip:(0,o.jsx)(N.sA,{id:"SETTINGS_PROFILES_WIFI_SPEED_LIMIT_FORM_DESCRIPTION_LIMIT_BANDWIDTH_UPLOAD",values:{minMbps:P,maxMbps:F}}),children:(0,o.jsx)(N.sA,{id:"COMMON_UPLOAD_BANDWIDTH_LIMIT"})})}),H?(0,o.jsx)(b.A,{width:v.G,children:(0,o.jsx)(A.A,{control:k.control,name:"upload_limit.value",contentAfter:(0,o.jsx)(N.sA,{id:"COMMON_SPEED_METRICS_MBPS"})})}):null]}),(0,o.jsx)(L.A,{onFormCancel:()=>k.reset(),isDirty:k.formState.isDirty||j&&!V,hideCancelButton:!k.formState.isDirty,submitButtonText:j?"COMMON_ACTION_ADD":void 0,form:R,isSubmitting:k.formState.isSubmitting})]})})}},157889(e,t,n){n.d(t,{bn:()=>r,wY:()=>a,xS:()=>s});const o=e=>"number"==typeof e&&e>-1?{enabled:!0,value:e/1e3}:{enabled:!1},a=e=>{const t=e;return{name:t?.name||"",download_limit:o(t?.qos_rate_max_down),upload_limit:o(t?.qos_rate_max_up)}},s=e=>{const t=Number(e);return t?Math.max(Math.round(1e3*t),-1):-1},r=e=>!!e.attr_no_delete},833466(e,t,n){n.d(t,{b:()=>o});const o=32},918071(e,t,n){n.d(t,{G:()=>o});const o=165},121713(e,t,n){n.d(t,{m:()=>A});var o=n(602086),a=n(977872),s=n(42220),r=n(369289),i=n(721533),l=n(700444),d=n(159469),m=n(260334);const c=(e,t=[])=>{if(!e||"object"!=typeof e)return[];const n=e;return[...Object.keys(n).filter(e=>"ref"!==e).flatMap(e=>c(n[e],[...t,e])),..."string"==typeof n.message&&n.message?[{path:n.ref?.name??t.join("."),message:n.message}]:[]]},u=e=>[...Array.from(document.getElementsByName(e)),document.getElementById(e),document.querySelector(`label[for="${e}"]`),document.querySelector(`[data-field-error="${e}"]`)].find(e=>e instanceof HTMLElement&&null!==e.offsetParent)??null,_=e=>{const t=(e.split(".").pop()??e).replaceAll(/([a-z0-9])([A-Z])/g,"$1 $2").replaceAll(/[_-]+/g," ").trim().toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):e};function A({schema:e,defaultValues:t,presets:n,mode:A="onTouched"}){const I=(0,a.wA)(),p=(0,m.L_)(),O=(0,o.useMemo)(()=>n?(0,r.A)(n,e=>e.defaultValues):{},[n]),f=(0,o.useMemo)(()=>({...t,...O}),[O,t]),M=(0,s.mN)({resolver:(0,i.u)(e),shouldFocusError:!0,defaultValues:f,shouldUseNativeValidation:!1,mode:A}),g=(0,o.useRef)(f);g.current=f;const h=(0,o.useRef)(null),{submitCount:N}=M.formState;(0,o.useEffect)(()=>{const e=h.current;if(h.current=null,!e)return;const t=c(e),n=t[0],o=n?.path??Object.keys(e)[0];if(o)try{const e=t.map(e=>u(e.path)).find(Boolean)??(t.length?null:u(o));if(e)e.scrollIntoView?.({behavior:"smooth",block:"center"}),e.focus?.({preventScroll:!0});else{const e=n&&p(n.message);I((0,l.ox)(n&&e?{icon:d.C.danger,title:"COMMON_VALIDATION_HIDDEN_FIELDS_TITLE",translateTitle:!0,message:"COMMON_VALIDATION_HIDDEN_FIELDS_DETAIL",values:{field:_(n.path),message:e}}:{icon:d.C.danger,message:"COMMON_VALIDATION_HIDDEN_FIELDS_TITLE"}))}}catch{}},[N,I,p]);const x=(0,o.useCallback)((...e)=>{const[t,...n]=e;return M.reset(t?{...t,...O}:g.current,...n)},[O,M]);return{...M,reset:x,formState:{...M.formState,isDirty:!!Object.keys(M.formState.dirtyFields).length,isSubmitting:M.formState.isSubmitting,defaultValues:M.formState.defaultValues},handleSubmit:(...e)=>M.handleSubmit(e[0],(t,...n)=>{h.current=t,e[1]?.(t,...n)})}}},260334(e,t,n){n.d(t,{L_:()=>m,MS:()=>d,rn:()=>l});var o=n(602086),a=n(949812),s=n(765282),r=n(470070);const i="{::}",l=(e,t)=>`${e}${i}${JSON.stringify(t??{})}`,d=(e,t)=>{if("string"!=typeof t)return;const[n,...o]=t.split(i);if(!n||!o.length)return t;let a={};try{a=Object.fromEntries(Object.entries(JSON.parse(o.join(i))).map(([t,n])=>[t,"string"==typeof n?d(e,n):n]))}catch{}return e.formatMessage({id:n},a)};function m(){const{formatMessage:e}=(0,r.tz)();return(0,o.useCallback)(t=>d({formatMessage:e},t),[e])}a.pJ((e,t)=>e.message?{message:e.message}:e.code===s.eq.too_small&&"string"===e.type?{message:l("COMMON_MIN_CHARS",{min:Number(e.minimum)})}:e.code===s.eq.too_big&&"string"===e.type?{message:l("COMMON_MAX_CHARS",{name:l("COMMON_VALUE"),max:Number(e.maximum)})}:e.code===s.eq.invalid_type&&"array"===e.expected&&"undefined"===e.received?{message:l("COMMON_SELECT_AT_LEAST_ONE_ITEM")}:e.code===s.eq.too_small&&"array"===e.type?{message:l("COMMON_ADD_AT_LEAST_X_ITEMS",{min:Number(e.minimum)})}:e.code===s.eq.invalid_type&&"undefined"===e.received?{message:l("COMMON_VALIDATION_VALUE_REQUIRED")}:e.code===s.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),s=n(221835),r=n(309130),i=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,isDisabled:I,isChecked:p}){const O=(0,d.mQ)()||I;return(0,o.jsx)(a.xI,{control:e,name:t,render:({field:e})=>{const t=(0,o.jsx)(s.A,{id:e.name,onChange:({target:{checked:t}})=>{e.onChange(t),u?.(t)},checked:p??!!e.value,disabled:O,inputClassName:A,children:n});return(0,o.jsxs)(l.A,{gap:r.YC,alignItems:"center",children:[_?_(t,e):t,m?(0,o.jsx)(i.A,{description:m,...c}):null]})}})}},16805(e,t,n){n.d(t,{A:()=>d});var o=n(274934),a=n(42220),s=n(699709),r=n(309130),i=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:O,variant:f="secondary",iconBefore:M,onAfterChange:g,onChange:h}){const N=(0,l.mQ)(),x=(0,i.L_)();return(0,o.jsx)(a.xI,{control:e,name:t,render:({field:{ref:e,...i},fieldState:l,formState:C})=>(0,o.jsx)(s.A,{type:"number",variant:f,width:"100%",...i,value:O??i.value??"",onChange:e=>{h?h(e,C):i.onChange(e.target.value?.length?+e.target.value:null),g?.(e)},disabled:N,invalid:l.invalid?x((0,a.Jt)(C.errors,t)?.message)||!0:void 0,labelTooltip:m,labelTooltipProps:{style:{opacity:N?r.xN:void 0,...c?.style},...c},label:n,placeholder:d,arrowSize:_,contentAfter:u,iconBefore:M,step:p,min:A,max:I})})}},635891(e,t,n){n.d(t,{A:()=>m});var o=n(274934),a=n(42220),s=n(699709),r=n(775250),i=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:O,onPaste:f,onKeyDown:M,passwordToggle:g,type:h,helperMessage:N,autoComplete:x,contentBefore:C,contentAfter:S,onFocus:T,value:E,invalid:D}){const b=(0,d.mQ)(),v=(0,d.Im)(),L=(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)(s.A,{type:h||(g?"password":"text"),variant:"secondary",width:"100%",autoFocus:_,...e,onChange:t=>{I?I(t,e,d):e.onChange(t),O?.(t)},onBlur:t=>{p?p(t,e,d):e.onBlur()},onFocus:T,onPaste:f,disabled:b,value:E??e.value?.toString(),invalid:D||(l.invalid?(0,o.jsxs)(r.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:v?i.xN:void 0,pointerEvents:L?"none":void 0,...u?.style},...u},motif:A,passwordToggle:g,helperMessage:N,autoComplete:x,onKeyDown:M,contentBefore:C,contentAfter:S})})}}}]);