(()=>{function e(a,n,o,t,e,r){var i={minlength:r("Password must have at least 8 characters and no more than 32."),required:r("Required"),password_missmatch:r("Passwords do not match."),maxlength:r("Password must have at least 8 characters and no more than 32."),password_strength:r("Your password is not strong enough. Please include numbers, lower and upper case characters"),remote_error:r("Server error occurred."),email:r("Invalid email address."),password_change:r("Your password is expired. Please set a new password."),password_reset_token_expired:r("Password reset link expired. Please enter your email address to receive a new one."),tfa_pin_invalid:r("The code you entered is invalid. Please try again."),pattern_newPassword:window.c8yConfig.validation.password.message,internationalPhoneNumber:r('Must be a valid phone number (only digits, spaces, slashes ("/"), dashes ("-"), and plus ("+") allowed, for example: +49 9 876 543 210).'),phone_number_error:r("Could not update phone number."),pinAlreadySent:r("The verification code was already sent. For a new verification code, please click on the link above.")},r={password_changed:r("Password changed. You can now log in using new password."),password_reset_requested:r("Password reset request has been sent. Please check your email."),resend_sms:r("Verification code SMS resent.")},d={LOGIN:"login",PASSWORD_RESET:"password_reset",NEW_PASSWORD:"new_password",PHONE_NUMBER:"phone_number",SMS_TOKEN:"sms_token"},c={};function s(e){return e&&e.recoverPassword?d.NEW_PASSWORD:d.LOGIN}function l(e){var r,s=e.headers("passwordresettoken");return s&&(o.setRecoverPassToken(s),r={form:d.NEW_PASSWORD,msg:["warning",i,"password_change"]}),e.headers("tfatokenexpired")&&(r={form:d.SMS_TOKEN}),e.headers("pinalreadysent")&&(r={form:d.SMS_TOKEN,msg:["warning",i,"pinAlreadySent"]}),e.headers("NoPhoneHeader")&&!o.isSupportUser()&&(r={form:d.PHONE_NUMBER,keepCredentials:!0}),e.action=r,n.reject(e)}return c[d.NEW_PASSWORD]=function(e,r){var s=e.newPassword,e=e.newPasswordConfirm,a=s.$modelValue===e.$modelValue,r=!r||!r.enforcePasswordStrength||"GREEN"===(r.passwordStrength||"").toUpperCase();e.$dirty&&e.$setValidity("password_missmatch",a);s.$dirty&&(s.$error.pattern||s.$error.required?s.$setValidity("password_strength",!0):s.$setValidity("password_strength",r))},{MESSAGES:{ERROR:i,SUCCESS:r},FORMS:d,initializing:o.initializing.then(s,s),login:function(e,r,s,a){return t.login(e,r,s,a).catch(l)},showTenant:function(){return e.getFlag("isLocal")||e.getFlag("showTenant")},resetPassword:o.resetPasword,changePassword:o.changePasswordWithResetToken,savePhoneNumber:t.savePhoneNumber,verifyTFACode:o.verifyTFACode,resendTFASms:function(){return o.verifyTFACode("0").catch(function(e){return 403===e.status?e:n.reject(e)})},validateForm:function(e,r){var s=e.$name.replace("form_",""),s=c[s]||_.noop;return a(_.partial(s,e,r),10)},mustEnforcePasswordStrength:o.mustEnforcePasswordStrength,getPasswordMinGreenLength:o.getPasswordMinGreenLength,getLoginOptions:o.getLoginOptions}}e.$inject=["$timeout","$q","c8yAuth","c8yUser","c8yBase","gettext"],angular.module("c8y.ui").factory("c8yLoginService",e)})();