"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[7109],{607109:(e,_,t)=>{t.r(_),t.d(_,{default:()=>v});var a=t(296540),n=t(469733),r=t(570868),I=t(959341),m=t(895424),o=t(222190),s=t(459449),M=t(48925),i=t(655524),E=t(675359),O=t(742920),l=t(38671),T=t(398300),A=t(845030),D=t(675291),N=t(169568),c=t(210484),S=t(566723),d=t(592510),u=t(641777),L=t(606081),C=t(853801);const P=e=>"number"==typeof e&&e>-1?e/1e3:void 0,p=e=>{if(e._id===I.R6)return{name:"",downloadSpeed:void 0,uploadSpeed:void 0};const _=e;return{name:_.name||"",qos_rate_max_down:P(_.qos_rate_max_down),qos_rate_max_up:P(_.qos_rate_max_up)}},x=e=>{const _=Number(e);return _?Math.max(Math.round(1e3*_),-1):-1};var F=t(407814),W=t(263963);const f=100,h=.002,R=F.Ik({name:F.Yj().max(64,{message:(0,W.rn)("SETTINGS_COMMON_FIELD_SHOULD_NOT_EXCEED_MAX_LENGTH",{name:(0,W.rn)("COMMON_NAME"),limit:64})}),qos_rate_max_down:F.ai().min(h,{message:(0,W.rn)("COMMON_VALIDATION_MIN",{name:(0,W.rn)("COMMON_DOWNLOAD_BANDWIDTH_LIMIT"),min:h})}).max(f,{message:(0,W.rn)("COMMON_VALIDATION_MAX",{name:(0,W.rn)("COMMON_DOWNLOAD_BANDWIDTH_LIMIT"),max:f})}).nullish(),qos_rate_max_up:F.ai().min(h,{message:(0,W.rn)("COMMON_VALIDATION_MIN",{name:(0,W.rn)("COMMON_UPLOAD_BANDWIDTH_LIMIT"),min:h})}).max(f,{message:(0,W.rn)("COMMON_VALIDATION_MAX",{name:(0,W.rn)("COMMON_UPLOAD_BANDWIDTH_LIMIT"),max:f})}).nullish()});var b=t(414523);const g="wifi-speed-limit-form",v=({activeItem:e})=>{const _=(0,n.useDispatch)(),t=e._id===I.R6,{formatMessage:P}=(0,s.tz)(),F=(0,r.m)({schema:R,defaultValues:p(e)}),W=(0,L.S)(N.v.SETTINGS_WIFI_SPEED_LIMIT_PROFILES);(0,C.y)(F);const v=F.handleSubmit(async a=>{const n={name:a.name,qos_rate_max_down:x(a.qos_rate_max_down),qos_rate_max_up:x(a.qos_rate_max_up)};return _(t?(0,i.$6)(n):(0,i.G4)(e._id,n)).then(e=>{_((0,i.Ik)(void 0,{crudCacheStrategy:{type:d.e.CACHE}})),_((0,A.SQ)(!1)),t&&_((0,A.XP)({id:e._id,type:T.H.WIFI_SPEED_LIMIT_PROFILE}))}).then(()=>{F.reset()}).catch(e=>{const a=(0,l.F)(e)?e:void 0;_((0,E.ox)({icon:O.C.danger,message:t?"SETTINGS_PROFILES_WIFI_SPEED_LIMIT_CREATE_FAILURE_TOAST":"SETTINGS_PROFILES_WIFI_SPEED_LIMIT_UPDATE_FAILURE_TOAST",values:{name:n.name},errorMessage:a?.msg,errorValues:a}))})});return a.createElement(u.A,{isDisabled:W},a.createElement("form",{onSubmit:v,id:g},a.createElement(D.A,{feature:N.v.SETTINGS_WIFI_SPEED_LIMIT_PROFILES,renderWarning:({children:e})=>a.createElement(c.A,{style:{marginBottom:S.Ln}},a.createElement(M.A,null,e))}),a.createElement(M.A,null,a.createElement(m.A,{autoFocus:!0,control:F.control,name:"name",label:a.createElement(s.sA,{id:"COMMON_NAME"})}),a.createElement(o.A,{control:F.control,name:"qos_rate_max_down",tooltip:a.createElement(s.sA,{id:"SETTINGS_PROFILES_WIFI_SPEED_LIMIT_FORM_DESCRIPTION_LIMIT_BANDWIDTH_DOWNLOAD",values:{minMbps:h,maxMbps:f}}),label:a.createElement(s.sA,{id:"COMMON_DOWNLOAD_BANDWIDTH_LIMIT"}),placeholder:P({id:"COMMON_UNLIMITED"}),contentAfter:a.createElement(s.sA,{id:"COMMON_SPEED_METRICS_MBPS"})}),a.createElement(o.A,{control:F.control,name:"qos_rate_max_up",tooltip:a.createElement(s.sA,{id:"SETTINGS_PROFILES_WIFI_SPEED_LIMIT_FORM_DESCRIPTION_LIMIT_BANDWIDTH_UPLOAD",values:{minMbps:h,maxMbps:f}}),label:a.createElement(s.sA,{id:"COMMON_UPLOAD_BANDWIDTH_LIMIT"}),contentAfter:a.createElement(s.sA,{id:"COMMON_SPEED_METRICS_MBPS"}),placeholder:P({id:"COMMON_UNLIMITED"})})),a.createElement(b.A,{onFormCancel:()=>F.reset(),isDirty:F.formState.isDirty||t&&!W,hideCancelButton:!F.formState.isDirty,submitButtonText:t?"COMMON_ACTION_ADD":void 0,form:g,isSubmitting:F.formState.isSubmitting})))}}}]);