"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[24602],{688094(e,t,a){a.d(t,{t2:()=>c,Kg:()=>r,hJ:()=>_,ut:()=>m,g0:()=>E,gh:()=>l,fH:()=>A});var s=a(691189),n=a(294201);const o=`${a(771805).J}/cmd/lte`,i=e=>e&&e.data&&e.data[0],l=e=>e&&e.apiMsg,r=({mac:e,username:t,password:a,token:l})=>r=>r((0,s.Xj)(n.A.AUTH_DEVICE,o,{mac:e,ubic_username:t,x_ubic_password:a,ubic_2fa_token:l||void 0})).then(i),c=e=>t=>t((0,s.Xj)(n.A.ACTIVATE_TRIAL,o,e)),A=e=>t=>t((0,s.Xj)(n.A.UPDATE_DEVICE,o,e)),E=e=>t=>t((0,s.Xj)(n.A.CHECK_PAYMENT_PAST_DUE,o,e)).then(i),m=e=>t=>t((0,s.Xj)(n.A.PAYMENT_METHODS,o,e)).then(i),_=({macOrMacs:e,username:t,password:a,token:l})=>r=>r((0,s.Xj)(n.A.CHECK_SUBSCRIPTION,o,{macs:"string"==typeof e?[e]:e,ubic_username:t,x_ubic_password:a,ubic_2fa_token:l})).then(i)},685375(e,t,a){var s;a.d(t,{f:()=>s}),function(e){e.API_ERROR_LTE_DEVICE_UNAUTHORIZED="API_ERROR_LTE_DEVICE_UNAUTHORIZED",e.API_ERROR_INCORRECT_CREDENTIALS="API_ERROR_INCORRECT_CREDENTIALS",e.API_ERROR_TOKEN_2FA_REQUIRED="API_ERROR_TOKEN_2FA_REQUIRED",e.API_ERROR_INVALID_2FA_TOKEN="API_ERROR_INVALID_2FA_TOKEN"}(s||(s={}))},372382(e,t,a){a.d(t,{A:()=>l});var s=a(296540),n=a(951272),o=a(86838),i=a(79760);const l=({fieldName:e,validationMessageProps:t={}})=>{const{errors:a,touched:l,submitCount:r}=(0,n.j7)(),c=(0,i.t$)(e,a,l,r);return c?s.createElement(o.A,{isInvalid:!0,style:{padding:0},...t,label:c}):null}},748598(e,t,a){a.d(t,{A:()=>f});var s=a(296540),n=a(82960),o=a(217439),i=a(822336),l=a(438628),r=a(71479),c=a(382389),A=a(132196),E=a(574137),m=a(566723),_=a(372382),d=a(143811),u=a(294303),p=a(916537),h=a(923831);const T=A.AH`
  height: 100%;
`,R=(0,r.A)("div")`
  margin-top: ${m.Ln};
  text-align: left;
  line-height: 18px;
  font-size: ${({theme:{fontSizes:e}})=>e[0]}px;
`,C=(0,r.A)("div")`
  margin-top: ${m.ew};
  display: flex;
  justify-content: center;
`,I=(0,r.A)("div")`
  width: 34px;
  height: 47px;
  text-align: center;
  line-height: 45px;
  border: ${({theme:{themeName:e}})=>i.Ay[`desktop-border-divider-${e}`]};
  font-size: 30px;
  font-weight: ${i.Ay["desktop-font-weight-semibold"]};
  margin: 0 ${({theme:{space:e}})=>e[3]}px;
  cursor: text;
`,g=(0,r.A)(d.A)`
  position: absolute;
  width: 284px;
  height: 47px;
  left: calc(50% - 142px);
  opacity: 0;

  input {
    width: 100% !important;
    height: 100% !important;
    border: none;
  }
`,O=(0,r.A)(u.A)`
  margin-top: ${m.S2};
  margin-bottom: ${m.xO};
  text-align: left;
`,S=(0,r.A)(o.A)`
  flex: 1;
  margin-left: ${m.xO};
`,b=(0,r.A)("input")`
  display: none;
`,f=(0,n.Zz)(p.j4,c.b)(({values:{sso2FA:e,ssoToken:t="",ssoUsername:a,ssoPassword:n,tos:o},hideOwnerDetailsText:i=!1,setFieldValue:r,handleSubmit:m,isSubmitting:f,isValid:N,dirty:x,showTOS:U})=>{const{colors:{text:k}}=(0,c.u)(),{formatMessage:v}=(0,p.tz)(),D=f||(e?6!==t.length:!(N&&x&&(!U||o))),[L,w]=(0,s.useState)(!1),P=(0,s.useCallback)(()=>{w(!0)},[]),y=(0,s.useCallback)(()=>{w(!1)},[]),V=(0,s.useCallback)(e=>{e?.preventDefault?.(),e?.stopPropagation?.(),D||m()},[D,m]);(0,s.useEffect)(()=>{f||6!==t.length||V()},[t]);const M=[...new Array(6)].map((e,a)=>{const n=t[a]||"",o=L&&t.length===a;return s.createElement(I,{key:`sso-token-char-${a.toString()}`,className:o?(i=k,A.AH`
  border-color: ${E.hu};
  position: relative;

  &:after {
    position: absolute;
    display: block;
    content: '';
    width: 1px;
    height: 36px;
    top: 5px;
    left: 4px;
    background: ${i};

    animation: ${A.i7`
            0% {
                opacity: 1;
            }
            69% {
                opacity: 1;
            }
            70% {
                opacity: 0;
            }
            100% {
                opacity: 0;
            }
        `} 1.2s ease 0s infinite;
  }
`):void 0},n);var i});return s.createElement("form",{onSubmit:V,autoComplete:"off"},e?s.createElement(s.Fragment,null,s.createElement(C,null,M,s.createElement(g,{name:"ssoToken",maxLength:"6",onFocus:P,onBlur:y,containerWrapperClassName:T,inputContentClassName:T})),s.createElement(_.A,{fieldName:"ssoToken"})):s.createElement(s.Fragment,null,s.createElement(u.A,{flexDirection:"column",alignItems:"flex-start"},s.createElement(l.A,{label:v({id:"LTE_SSO_LOGIN_LABEL_EMAIL_OR_USERNAME"}),name:"ssoUsername",value:a,onChange:e=>r("ssoUsername",e.target.value||""),full:!0}),s.createElement(_.A,{fieldName:"ssoUsername"})),s.createElement(u.A,{flexDirection:"column",alignItems:"flex-start"},s.createElement(l.A,{label:v({id:"COMMON_PASSWORD"}),name:"ssoPassword",value:n,type:"password",onChange:e=>r("ssoPassword",e.target.value||""),full:!0}),s.createElement(_.A,{fieldName:"ssoPassword"})),i?null:s.createElement(R,null,s.createElement(p.sA,{id:"DEVICE_ULTE_SETUP_ACCOUNT_DETAILS"})),U?s.createElement(O,{justifyContent:"space-between",alignItems:"center"},s.createElement(d.A,{label:"DEVICE_ULTE_SETUP_LABEL_ACCEPT_TOS",name:"tos",type:"checkbox"}),s.createElement(S,null,s.createElement(p.sA,{id:"DEVICE_ULTE_SETUP_LABEL_ACCEPT_TOS",values:{link:s.createElement("a",{href:h.Ay.LEGAL_USE_TOS,target:"_blank",rel:"noopener noreferrer"},s.createElement(p.sA,{id:"COMMON_TOS"}))}}))):null),s.createElement(b,{type:"submit"}))})},431253(e,t,a){a.d(t,{A:()=>R});var s=a(296540),n=a(822336),o=a(793336),i=a(350312),l=a(71479),r=a(566723),c=a(705426),A=a(311785);const E=(0,l.A)(c.A,(0,A.A)("originalSize"))`
  ${({originalSize:e})=>e?"":"width: 500px;"}
  padding: 24px;
`,m=(0,l.A)("header",(0,A.A)("onRequestClose"))`
  position: relative;
  text-align: center;
`,_=(0,l.A)("div")`
  font-size: ${({theme:{fontSizes:e}})=>e[3]}px;
  font-weight: ${n.Ay["desktop-font-weight-semibold"]};
  margin-bottom: ${({theme:{space:e}})=>e[4]}px;
`,d=(0,l.A)("div")`
  width: 345px;
  line-height: 18px;
  margin: 0 auto ${({theme:{space:e}})=>e[5]}px;
`,u=(0,l.A)(i.A)`
  position: absolute;
  top: 0;
  left: 0;
  cursor: pointer;
  color: ${({theme:{colors:{subtleText:e}}})=>e};
  width: 16px;
  height: 16px;
`,p=(0,l.A)(o.A)`
  position: absolute;
  top: 0;
  right: 0;
  cursor: pointer;
  color: ${({theme:{colors:{subtleText:e}}})=>e};
`,h=(0,l.A)("div")`
  max-height: 340px;
  overflow: auto;
`,T=(0,l.A)("div")`
  text-align: center;
  width: 100%;
  min-height: ${r.ZH};
  line-height: 18px;
  margin: 0 auto 8px;
`,R=({headerBackButtonAction:e,headerTitle:t,headerSubTitle:a,onClose:n,actions:o,children:i,originalSize:l=!1,...r})=>{const c=s.createElement(m,null,e?s.createElement(u,{actionable:!0,onClick:e}):null,s.createElement(_,null,t),s.createElement(p,{actionable:!0,onClick:n}),a?s.createElement(d,null,a):null);return s.createElement(E,{onRequestClose:n,originalSize:l,size:"small",header:c,actions:o,...r},s.createElement(h,null,s.createElement(T,null,i)))}},724602(e,t,a){a.r(t),a.d(t,{default:()=>S});var s=a(82960),n=a(469733),o=a(951272),i=a(742920),l=a(870443),r=a(675359),c=a(126457),A=a(811569),E=a(417378),m=a(685375),_=a(688094),d=a(198494),u=a(367370),p=a(902786),h=a(532419),T=a(953141),R=a(296540),C=a(916537),I=a(431253),g=a(748598);const O=(0,o.bk)({enableReinitialize:!0,isInitialValid:!0,mapPropsToValues:({ssoUsername:e=""})=>({ssoUsername:e,ssoPassword:"",ssoToken:"",tos:!1,sso2FA:!1,openRemoteController:!1}),validationSchema:l.A.object().shape({ssoUsername:l.A.string().label("LTE_SSO_LOGIN_LABEL_EMAIL_OR_USERNAME").required(),ssoPassword:l.A.string().label("COMMON_PASSWORD").required(),tos:l.A.boolean(),ssoToken:l.A.string(),sso2FA:l.A.boolean(),openRemoteController:l.A.boolean()}),handleSubmit:({ssoUsername:e,ssoPassword:t,ssoToken:a},{props:{macs:s,devices:n,checkLteSubscription:o,createToast:l,formatMessage:r,fetchInfo:c,hideModal:A,showLteDeviceUnavailable:E},setFieldValue:_,setErrors:d,setSubmitting:u})=>{u(!0),o({username:e||void 0,password:t||void 0,token:a||void 0,macOrMacs:s}).then(async({user_uuid:e})=>{n.some(t=>!(0,p._D)(t,e))?E():(await c(),A())}).catch(({apiMsg:e})=>{switch(T.API_STRING_TRANSLATION[e]){case m.f.API_ERROR_INCORRECT_CREDENTIALS:d({ssoUsername:r({id:"DEVICE_SSO_ACTIONS_AUTH_INVALID_ERROR"}),ssoPassword:r({id:"DEVICE_SSO_ACTIONS_AUTH_INVALID_ERROR"})});break;case m.f.API_ERROR_INVALID_2FA_TOKEN:d({ssoToken:r({id:"DEVICE_SSO_ACTIONS_AUTH_INVALID_ERROR"})}),_("ssoToken","");break;case m.f.API_ERROR_TOKEN_2FA_REQUIRED:_("sso2FA",!0);break;default:l({type:i.C.danger,message:"DEVICE_SSO_ACTIONS_AUTH_ERROR"})}u(!1)})}}),S=(0,s.Zz)((0,n.connect)((e,{macs:t})=>{const a=(0,d.Pk)(e);return{env:(0,E.S$)(e),ssoUsername:(0,d.rU)(e)||a,ssoUuid:a,devices:(0,h.ID)(e).filter(({mac:e})=>t.includes(e))}},{hideModal:c.AS,createToast:r.ox,checkLteSubscription:_.hJ,fetchInfo:u.N,showLteDeviceUnavailable:A.Zo}),O)(({isValid:e,dirty:t,isSubmitting:a,setFieldValue:s,hideModal:n,values:{sso2FA:o,ssoToken:i=""},values:l,handleSubmit:r,errors:c})=>{const A=a||(o?6!==i.length:!(e&&t)),E=(0,R.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),A||r()},[A]),m=(0,R.useCallback)(()=>{o&&s("sso2FA",!1)},[o,s]),_=[{text:R.createElement(C.sA,{id:"COMMON_ACTION_CANCEL"}),onClick:n},{text:R.createElement(C.sA,{id:"COMMON_ACTION_VERIFY"}),onClick:E,variant:"primary",disabled:A,loader:a?"spinner":void 0,type:"submit"}];return R.createElement(I.A,{onClose:n,headerTitle:R.createElement(C.sA,{id:"LTE_SUBSCRIPTION_ACCOUNT_HEADER"}),headerSubTitle:R.createElement(C.sA,{id:o?"LTE_SUBSCRIPTION_ACCOUNT_SUB_HEADER_2FA":"LTE_SUBSCRIPTION_ACCOUNT_SUB_HEADER"}),headerBackButtonAction:o?m:void 0,actions:_,originalSize:!0},R.createElement(g.A,{handleSubmit:r,setFieldValue:s,values:l,errors:c,isSubmitting:a,isValid:e,dirty:t,hideOwnerDetailsText:!0}))})}}]);