"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(949147),I=t(853801),m=t(959341),o=t(895424),s=t(222190),M=t(459449),i=t(48925),E=t(655524),O=t(675359),l=t(742920),T=t(38671),A=t(398300),D=t(845030),N=t(675291),c=t(169568),S=t(210484),d=t(566723),u=t(592510),L=t(641777),C=t(606081);const P=e=>"number"==typeof e&&e>-1?e/1e3:void 0,p=e=>{if(e._id===m.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(360847),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(329109);const g="wifi-speed-limit-form",v=({activeItem:e})=>{const _=(0,n.useDispatch)(),t=e._id===m.R6,{formatMessage:P}=(0,M.tz)(),F=(0,r.m)({schema:R,defaultValues:p(e)}),W=(0,C.S)(c.v.SETTINGS_WIFI_SPEED_LIMIT_PROFILES);(0,I.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,E.$6)(n):(0,E.G4)(e._id,n)).then(e=>{_((0,E.Ik)(void 0,{crudCacheStrategy:{type:u.e.CACHE}})),_((0,D.SQ)(!1)),t&&_((0,D.XP)({id:e._id,type:A.H.WIFI_SPEED_LIMIT_PROFILE}))}).then(()=>{F.reset()}).catch(e=>{const a=(0,T.F)(e)?e:void 0;_((0,O.ox)({icon:l.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(L.A,{isDisabled:W},a.createElement("form",{onSubmit:v,id:g},a.createElement(N.A,{feature:c.v.SETTINGS_WIFI_SPEED_LIMIT_PROFILES,renderWarning:({children:e})=>a.createElement(S.A,{style:{marginBottom:d.Ln}},a.createElement(i.A,null,e))}),a.createElement(i.A,null,a.createElement(o.A,{autoFocus:!0,control:F.control,name:"name",label:a.createElement(M.sA,{id:"COMMON_NAME"})}),a.createElement(s.A,{control:F.control,name:"qos_rate_max_down",tooltip:a.createElement(M.sA,{id:"SETTINGS_PROFILES_WIFI_SPEED_LIMIT_FORM_DESCRIPTION_LIMIT_BANDWIDTH_DOWNLOAD",values:{minMbps:h,maxMbps:f}}),label:a.createElement(M.sA,{id:"COMMON_DOWNLOAD_BANDWIDTH_LIMIT"}),placeholder:P({id:"COMMON_UNLIMITED"}),contentAfter:a.createElement(M.sA,{id:"COMMON_SPEED_METRICS_MBPS"})}),a.createElement(s.A,{control:F.control,name:"qos_rate_max_up",tooltip:a.createElement(M.sA,{id:"SETTINGS_PROFILES_WIFI_SPEED_LIMIT_FORM_DESCRIPTION_LIMIT_BANDWIDTH_UPLOAD",values:{minMbps:h,maxMbps:f}}),label:a.createElement(M.sA,{id:"COMMON_UPLOAD_BANDWIDTH_LIMIT"}),contentAfter:a.createElement(M.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})))}}}]);