function match(n){return{require:"?ngModel",restrict:"A",link:function(t,i,r,u){function f(){var n=e(t);return angular.isObject(n)&&n.hasOwnProperty("$viewValue")&&(n=n.$viewValue),n}if(u&&r.match){var e=n(r.match),o=n(r.matchCaseless),s=n(r.notMatch),h=n(r.matchIgnoreEmpty);t.$watch(f,function(){u.$$parseAndValidate()});u.$validators.match=function(n,i){var u=n||i,e=f(),c=s(t),r;return h(t)&&!i?!0:(r=o(t)?angular.lowercase(u)===angular.lowercase(e):u===e,r^=c,!!r)}}}}}angular.module("cnApplication.UserValidation").directive("match",match);angular.module("cnApplication.Repositories").factory("PasswordRepository",["$http",function(n){var t="",i=window.location.hostname;return t=i.indexOf("www.realestate.com.au")!=-1?"/connect/":"",{requestPasswordReset:function(i,r,u){return n({method:"POST",url:t+"/forgotpassword",data:JSON.stringify({userId:i,mobEmail:r,captchaResponse:u}),headers:{"Content-Type":"application/json; charset=utf-8"}})},resetPassword:function(i){return n({method:"POST",url:t+"/passwordreset",data:JSON.stringify(i),headers:{"Content-Type":"application/json; charset=utf-8"}})},ForgetPasswordReset:function(i){return n({method:"POST",url:t+"/forgetpasswordreset",data:JSON.stringify({email1:i}),headers:{"Content-Type":"application/json; charset=utf-8"}})},registernewuser:function(i,r,u,f){return n({method:"POST",url:t+"/registernewuser",data:JSON.stringify({fname:i,cnumber:r,email:u,state:f}),headers:{"Content-Type":"application/json; charset=utf-8"}})},changePassword:function(i){return n({method:"POST",url:t+"/changepassword",data:JSON.stringify(i),headers:{"Content-Type":"application/json; charset=utf-8"}})},changePasswordREA:function(i){return n({method:"POST",url:t+"/changepasswordrea",data:JSON.stringify(i),headers:{"Content-Type":"application/json; charset=utf-8"}})}}}]);angular.module("cnApplication.Controllers").controller("PasswordViewModel",["$scope","$window","PasswordRepository",function(n,t,i){n.AsyncSubmitOngoing=!1;n.TimeSpan=[];n.requestPasswordReset=function(){var u=t.grecaptcha.getResponse(),r;if(u==""){$(".alert #errorMessages").html("To keep your details safe we have a few security measures in place. Please check the box below to confirm you’re not a robot!");$(".alert").fadeIn();return}n.frmForgotPassword.$valid?(i.requestPasswordReset(n.UserId,n.MobEmail,u).then(function(t){console.log(t);n.AsyncSubmitOngoing=!1;var i="We've sent instructions to your email/mobile with further instructions to reset your password.";t.data.ResultStatus?$('form[name="frmForgotPassword"]').fadeOut():i=t.data.ErrorMessage;$(".alert #errorMessages").html(i);$(".alert").fadeIn();$(".alert").addClass("successAlert")},function(){n.AsyncSubmitOngoing=!1;$(".alert #errorMessages").html("Something went wrong. Please try again or contact us.");$(".alert").fadeIn()}),t.grecaptcha.reset(),n.AsyncSubmitOngoing=!0):(r="",n.frmForgotPassword.UserId.$invalid&&(r=r+'<p class="err-msg">Please enter your username and registered email id or mobile number.<\/p>'),$(".alert #errorMessages").html(r),$(".alert").fadeIn())};n.requestHand=function(){n.frmNeedHand.$valid&&(i.registernewuser(n.FName,n.CNumber,n.Email,n.State).then(function(){n.AsyncSubmitOngoing=!1;$("#needHand").modal("hide");$("#congrats").modal("show")},function(){n.AsyncSubmitOngoing=!1;$(".alert #errorMessages").html("Something went wrong. Please try again or contact us.");$(".alert").fadeIn()}),t.grecaptcha.reset(),n.AsyncSubmitOngoing=!0)};n.ForgetPasswordReset=function(){n.frmForgetPassword.$valid&&i.ForgetPasswordReset(n.email1).then(function(t){n.AsyncSubmitOngoing=!1;var i="We've sent instructions to your email address with further instructions to reset your password.";t.data.results?(n.AsyncSubmitOngoing=!1,$('form[name="frmForgetPassword"]').fadeOut(),$(".alert #errorMessages").html(i),$(".alert #errorMessages").html("We've sent instructions to your email address with further instructions to reset your password."),$(".alert").fadeIn(),$(".alert").addClass("successAlert")):i=t.data.ErrorMessage;$(".alert #errorMessages").html(i);$(".alert").fadeIn()})};n.resetPassword=function(){if(n.frmResetPassword.$valid)i.resetPassword(n.passwordResetRequest).then(function(t){n.AsyncSubmitOngoing=!1;var i="Your password has been reset.";t.data.ResultStatus?$('form[name="frmResetPassword"]').fadeOut():i=t.data.ErrorMessage;$(".alert #errorMessages").html(i);$(".alert").fadeIn();$(".alert").addClass("successAlert")},function(){n.AsyncSubmitOngoing=!1;$(".alert #errorMessages").html("Something went wrong. Please try again or contact us.");$(".alert").fadeIn()}),n.AsyncSubmitOngoing=!0;else{var t="";n.frmResetPassword.password.$error.required?t=t+'<p class="err-msg">Please enter your new password.<\/p>':n.frmResetPassword.password.$error.minlength||n.frmResetPassword.password.$error.maxlength?t=t+'<p class="err-msg">Please enter a new password that\'s between 8 and 20 characters long.<\/p>':n.frmResetPassword.password.$error.pattern?t=t+'<p class="err-msg">Please enter a new password that has at least one lower and uppercase letter, and at least one number and symbol, before you continue.<\/p>':n.frmResetPassword.confirmPassword.$error.required?t=t+"<p class=\"err-msg\">Please confirm your new password by clicking 'Submit' .<\/p>":n.frmResetPassword.confirmPassword.$error.match&&(t=t+'<p class="err-msg">Please make sure that your new password matches when you confirm it.<\/p>');$(".alert #errorMessages").html(t);$(".alert").fadeIn()}};n.changePassword=function(){if(n.frmChangePassword.$valid)i.changePassword(n.changePasswordRequest).then(function(t){n.AsyncSubmitOngoing=!1;var i="Your password has been updated.";t.data.ResultStatus?($('form[name="frmChangePassword"]').fadeOut(),$(".alert #errorMessages").html(i),$(".alert").fadeIn(),$(".alert").addClass("successAlert")):(i=t.data.ErrorMessage,$(".alert #errorMessages").html(i),$(".alert").fadeIn())},function(){n.AsyncSubmitOngoing=!1;$(".alert #errorMessages").html("Something went wrong. Please try again or contact us.");$(".alert").fadeIn()}),n.AsyncSubmitOngoing=!0;else{var t="";n.frmChangePassword.password.$error.required?t=t+'<p class="err-msg">Please enter your new password.<\/p>':n.frmChangePassword.password.$error.minlength||n.frmChangePassword.password.$error.maxlength?t=t+'<p class="err-msg">Please enter a new password that\'s between 8 and 20 characters long.<\/p>':n.frmChangePassword.password.$error.pattern?t=t+'<p class="err-msg">Please enter a new password that has at least one lower and uppercase letter, and at least one number and symbol, before you continue.<\/p>':n.frmChangePassword.confirmPassword.$error.required?t=t+"<p class=\"err-msg\">Please confirm your new password by clicking 'Submit' .<\/p>":n.frmChangePassword.confirmPassword.$error.match&&(t=t+'<p class="err-msg">Please make sure that your new password matches when you confirm it.<\/p>');$(".alert #errorMessages").html(t);$(".alert").fadeIn()}};n.changePasswordREA=function(){if(n.frmChangePasswordREA.$valid)i.changePasswordREA(n.changePasswordRequest).then(function(t){n.AsyncSubmitOngoing=!1;var i="Your password has been updated.";t.data.ResultStatus?($('form[name="frmChangePasswordREA"]').fadeOut(),$(".alert #errorMessages").html(i),$(".alert").fadeIn(),$(".alert").addClass("successAlert")):(i=t.data.ErrorMessage,$(".alert #errorMessages").html(i),$(".alert").fadeIn())},function(){n.AsyncSubmitOngoing=!1;$(".alert #errorMessages").html("Something went wrong. Please try again or contact us.");$(".alert").fadeIn()}),n.AsyncSubmitOngoing=!0;else{var t="";n.frmChangePasswordREA.password.$error.required?t=t+'<p class="err-msg">Please enter your new password.<\/p>':n.frmChangePasswordREA.password.$error.minlength||n.frmChangePasswordREA.password.$error.maxlength?t=t+'<p class="err-msg">Please enter a new password that\'s between 8 and 20 characters long.<\/p>':n.frmChangePasswordREA.password.$error.pattern?t=t+'<p class="err-msg">Please enter a new password that has at least one lower or uppercase letter, and at least one number or symbol, before you continue.<\/p>':n.frmChangePasswordREA.confirmPassword.$error.required?t=t+"<p class=\"err-msg\">Please confirm your new password by clicking 'Submit' .<\/p>":n.frmChangePasswordREA.confirmPassword.$error.match&&(t=t+'<p class="err-msg">Please make sure that your new password matches when you confirm it.<\/p>');$(".alert #errorMessages").html(t);$(".alert").fadeIn()}}}])