function RegisterViewModel(){var a=this;a.userName=ko.observable("").extend({validateStringLength:{min:ApplicationSettings.minUserNameLength,max:ApplicationSettings.maxUserNameLength,validateOnInitiate:!1}});a.password=ko.observable("").extend({validateStringLength:{min:ApplicationSettings.minPasswordLength,max:ApplicationSettings.maxPasswordLength,validateOnInitiate:!1}});a.password2=ko.observable("");a.email=ko.observable("").extend({validateEmail:{validateOnInitiate:!1}});a.name=ko.observable("").extend({validateStringLength:{min:ApplicationSettings.minNameLength,
max:ApplicationSettings.maxNameLength,validateOnInitiate:!1}});a.lastName=ko.observable("").extend({validateStringLength:{min:ApplicationSettings.minNameLength,max:ApplicationSettings.maxNameLength,validateOnInitiate:!1}});a.address=ko.observable("").extend({validateStringLength:{min:ApplicationSettings.minDefaultLength,max:ApplicationSettings.maxDefaultLength,validateOnInitiate:!1}});a.city=ko.observable("").extend({validateStringLength:{min:ApplicationSettings.minDefaultLength,max:ApplicationSettings.maxDefaultLength,
validateOnInitiate:!1}});a.zipCode=ko.observable("").extend({validateStringLength:{min:ApplicationSettings.minDefaultLength,max:ApplicationSettings.maxDefaultLength,validateOnInitiate:!1}});a.country=ko.observable("").extend({validateStringLength:{min:ApplicationSettings.minDefaultLength,max:ApplicationSettings.maxDefaultLength,validateOnInitiate:!1}});a.bankName=ko.observable("").extend({validateStringLength:{min:ApplicationSettings.minDefaultLength,max:ApplicationSettings.maxDefaultLength,validateOnInitiate:!1}});
a.accountNumber=ko.observable("").extend({validateStringLength:{min:ApplicationSettings.minDefaultLength,max:ApplicationSettings.maxDefaultLength,validateOnInitiate:!1}});a.bankNumber=ko.observable("").extend({validateStringLength:{min:ApplicationSettings.minDefaultLength,max:ApplicationSettings.maxDefaultLength,validateOnInitiate:!1}});a.userExist=ko.observable(!1);a.userName.subscribe(function(){a.userExist(!1)});a.theSamePassword=ko.computed(function(){return a.password()==a.password2()});a.isPasswordNotValid=
ko.computed(function(){return!a.theSamePassword()||!a.password.isValid()?!0:!1});a.registerValid=ko.computed(function(){return a.userName.isValid()&&!a.isPasswordNotValid()&&a.email.isValid()&&a.name.isValid()&&a.lastName.isValid()&&a.address.isValid()&&a.city.isValid()&&a.zipCode.isValid()&&a.country.isValid()&&a.bankName.isValid()&&a.accountNumber.isValid()&&a.bankNumber.isValid()&&""!=a.userName()&&""!=a.password()&&""!=a.email()&&""!=a.name()&&""!=a.lastName()?!0:!1});a.register=function(c){MainViewModel.checkInternetConnection()&&
(Overlay.create(!0,Culture.translations().stringMsgRegistering),ServiceDataProvider.register(c).done(function(){setTimeout(function(){Overlay.destroy();setTimeout(function(){Settings.userName("");Settings.password("");MainViewModel.userName(c.userProfile.UserName);MainViewModel.password(c.userProfile.Password);MainViewModel.logInCommandToHome()},1)},2E3)}).always(function(b){Log(b);if(this.state()==ASyncState.Resolved)b=Culture.translations().stringMsgRegisteringInSucceeded;else switch(b){case 3001:b=
Culture.translations().stringErrorMsgRegisteringInFailedUserExist;a.userName.isValid(!1);a.userExist(!0);break;default:b=Culture.translations().stringErrorMsgRegisteringInFailed}Overlay.hideLoader();Overlay.showTextOnlyLoader(b)}).fail(function(){setTimeout(function(){Overlay.destroy()},2E3)}))};a.registerCommand=function(){a.register({userProfile:{UserName:a.userName(),Password:a.password(),Email:a.email(),Name:a.name(),LastName:a.lastName(),Address:a.address(),City:a.city(),ZipCode:a.zipCode(),
Country:a.country(),BankName:a.bankName(),AccountNumber:a.accountNumber(),BankNumber:a.bankNumber()}})}};
