/**
 * @fileoverview added by tsickle
 * Generated from: lib/user/login/login.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import * as tslib_1 from "tslib";
import { Component, HostListener, Input, Output, EventEmitter } from '@angular/core';
import { Storage } from '@ionic/storage';
import { TranslateService } from '../../shared/translate/services/translate.service';
import { FormGroup, FormControl, Validators } from '@angular/forms';
import { EMAIL_REGEX } from '../../shared/regular-expressions/regex';
import { AlertController } from '@ionic/angular';
import { TranslatePipe } from '../../shared/translate/pipes/translate.pipe';
var LoginComponent = /** @class */ (function () {
    function LoginComponent(storage, translateService, alertController, translate) {
        this.storage = storage;
        this.translateService = translateService;
        this.alertController = alertController;
        this.translate = translate;
        this.imgError = false;
        this.loginConfig = {
            title: 'INCLOUDED',
            version: '',
            versionLink: ''
        };
        this.callLogin = new EventEmitter();
        this.callPasswordReminder = new EventEmitter();
    }
    /**
     * @return {?}
     */
    LoginComponent.prototype.onKeydownHandler = /**
     * @return {?}
     */
    function () {
        this.login();
    };
    /**
     * @return {?}
     */
    LoginComponent.prototype.ngOnInit = /**
     * @return {?}
     */
    function () {
        var _this = this;
        this.selectedLanguage = this.translateService.selectedLanguage;
        this.initLoginForm();
        this.storage.remove('user');
        this.storage.remove('role');
        this.storage.get('isRememberMe').then((/**
         * @param {?} result
         * @return {?}
         */
        function (result) {
            _this.loginForm.controls.isRememberMe.setValue(result);
        }));
    };
    /**
     * @return {?}
     */
    LoginComponent.prototype.initLoginForm = /**
     * @return {?}
     */
    function () {
        this.loginForm = new FormGroup({
            email: new FormControl('', [Validators.required, Validators.pattern(EMAIL_REGEX)]),
            password: new FormControl('', Validators.required),
            isRememberMe: new FormControl(false)
        });
    };
    /**
     * @param {?} event
     * @return {?}
     */
    LoginComponent.prototype.isRememberMeChange = /**
     * @param {?} event
     * @return {?}
     */
    function (event) {
        this.storage.remove('isRememberMe');
        if (event.detail.checked) {
            this.storage.set('isRememberMe', true);
        }
    };
    /**
     * @param {?} event
     * @return {?}
     */
    LoginComponent.prototype.changeLanguage = /**
     * @param {?} event
     * @return {?}
     */
    function (event) {
        this.selectedLanguage = event.detail.value;
        this.translateService.use(this.selectedLanguage);
    };
    /**
     * @param {?} event
     * @return {?}
     */
    LoginComponent.prototype.onImgError = /**
     * @param {?} event
     * @return {?}
     */
    function (event) {
        if (event) {
            this.imgError = true;
        }
    };
    /**
     * @return {?}
     */
    LoginComponent.prototype.login = /**
     * @return {?}
     */
    function () {
        if (this.loginForm.invalid) {
            return;
        }
        this.callLogin.emit(this.loginForm.value);
    };
    /**
     * @return {?}
     */
    LoginComponent.prototype.passwordReminder = /**
     * @return {?}
     */
    function () {
        return tslib_1.__awaiter(this, void 0, void 0, function () {
            var alert;
            var _this = this;
            return tslib_1.__generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.alertController.create({
                            header: this.translate.transform('PReminder'),
                            message: this.translate.transform('PReminderMessage'),
                            inputs: [
                                {
                                    name: 'email',
                                    type: 'text',
                                    placeholder: 'email'
                                }
                            ],
                            buttons: [
                                {
                                    text: this.translate.transform('CANCEL_BUTTON'),
                                    role: 'cancel',
                                    handler: (/**
                                     * @param {?} data
                                     * @return {?}
                                     */
                                    function (data) {
                                        console.log('Cancel clicked');
                                    })
                                },
                                {
                                    text: this.translate.transform('SEND'),
                                    handler: (/**
                                     * @param {?} data
                                     * @return {?}
                                     */
                                    function (data) {
                                        _this.callPasswordReminder.emit(data.email);
                                    })
                                }
                            ]
                        })];
                    case 1:
                        alert = _a.sent();
                        return [4 /*yield*/, alert.present()];
                    case 2:
                        _a.sent();
                        return [2 /*return*/];
                }
            });
        });
    };
    LoginComponent.decorators = [
        { type: Component, args: [{
                    selector: 'inc-login',
                    template: "<div class=\"logo\" *ngIf=\"!imgError\">\r\n  <ion-img class=\"logo\" alt=\"logo\" src=\"assets/images/logo.PNG\" (ionError)=\"onImgError($event)\"></ion-img>\r\n</div>\r\n<h4 class=\"title\">{{loginConfig.title | translate}} </h4>\r\n<ion-card id=\"alertCard\" class=\"alert no-box\" *ngIf=\"alertMessage\">\r\n  {{alertMessage | translate}}\r\n</ion-card>\r\n<ion-grid class=\"ion-no-padding\">\r\n  <ion-row>\r\n    <ion-col size=\"6\">\r\n      <ion-item lines=\"none\">\r\n        <ion-button color=\"medium\" fill=\"outline\" class=\"ion-no-margin\">\r\n          <ion-icon slot=\"icon-only\" color=\"primary\" name=\"globe\"></ion-icon>\r\n        </ion-button>\r\n        <ion-select multiple=\"false\" style=\"max-width: initial\" cancelText=\"{{'CANCEL_BUTTON' | translate}}\"\r\n          okText=\"{{'READY_BUTTON' | translate}}\" (ionChange)=\"changeLanguage($event)\" [value]=\"selectedLanguage\">\r\n          <ion-select-option value=\"en\">{{'LANGUAGE_EN' | translate}}</ion-select-option>\r\n          <ion-select-option value=\"hu\">{{'LANGUAGE_HU' | translate}}</ion-select-option>\r\n        </ion-select>\r\n      </ion-item>\r\n    </ion-col>\r\n  </ion-row>\r\n</ion-grid>\r\n\r\n<form [formGroup]=\"loginForm\" (ngSubmit)=\"login()\">\r\n  <ion-item class=\"ion-margin-bottom\">\r\n    <ion-input id=\"email\" autofocus formControlName=\"email\" type=\"email\" name=\"email\"\r\n      placeholder=\"{{'EMAIL' | translate}}*\">\r\n    </ion-input>\r\n  </ion-item>\r\n  <ion-item class=\"ion-margin-bottom\">\r\n    <ion-input id=\"password\" formControlName=\"password\" type=\"password\" name=\"password\"\r\n      placeholder=\"{{'PASSWORD' | translate}}*\">\r\n    </ion-input>\r\n  </ion-item>\r\n  <ion-item lines=\"none\">\r\n    <ion-checkbox id=\"isRememberMe\" formControlName=\"isRememberMe\" (ionChange)=\"isRememberMeChange($event)\">\r\n    </ion-checkbox>\r\n    <ion-label>&nbsp;{{'STAY' | translate}}</ion-label>\r\n  </ion-item>\r\n  <ion-button id=\"loginButton\" type=\"submit\" expand=\"block\" class=\"ion-margin-top ion-margin-bottom\">\r\n    {{'SIGN_IN' | translate}}\r\n  </ion-button>\r\n  <ion-button class=\"pwd-reminder\" fill=\"clear\" color=\"secondary\" (click)=\"passwordReminder()\" >\r\n    {{'FORGOT' | translate}}\r\n  </ion-button>\r\n</form>\r\n<ion-text color=\"secondary\" class=\"ion-text-center\">\r\n  <h6>\r\n    <a href=\"{{loginConfig.versionLink}}\" target=\"_blank\" *ngIf=\"loginConfig.versionLink; else elseBlock\"\r\n      style=\"color: var(--ion-color-secondary);\">\r\n      {{loginConfig.version}} <ion-icon slot=\"icon-only\" name=\"open\"></ion-icon>\r\n    </a>\r\n    <ng-template #elseBlock>{{loginConfig.version}}</ng-template>\r\n  </h6>\r\n</ion-text>",
                    styles: [".logo{display:flex;justify-content:center}.logo ion-img{max-width:300px;width:100%}.title{color:#000;margin-bottom:16px;text-align:center;text-transform:capitalize}.pwd-reminder{text-decoration:underline;text-transform:unset}.alert{text-align:center;margin:0 -16px 16px;color:#b93524;background-color:#f5dbd7;border:1px solid #f5b0b6;border-radius:0;height:50px;line-height:50px;box-shadow:none}"]
                }] }
    ];
    /** @nocollapse */
    LoginComponent.ctorParameters = function () { return [
        { type: Storage },
        { type: TranslateService },
        { type: AlertController },
        { type: TranslatePipe }
    ]; };
    LoginComponent.propDecorators = {
        alertMessage: [{ type: Input }],
        loginConfig: [{ type: Input }],
        callLogin: [{ type: Output }],
        callPasswordReminder: [{ type: Output }],
        onKeydownHandler: [{ type: HostListener, args: ['document:keydown.enter',] }]
    };
    return LoginComponent;
}());
export { LoginComponent };
if (false) {
    /** @type {?} */
    LoginComponent.prototype.imgError;
    /** @type {?} */
    LoginComponent.prototype.loginForm;
    /** @type {?} */
    LoginComponent.prototype.selectedLanguage;
    /** @type {?} */
    LoginComponent.prototype.alertMessage;
    /** @type {?} */
    LoginComponent.prototype.loginConfig;
    /** @type {?} */
    LoginComponent.prototype.callLogin;
    /** @type {?} */
    LoginComponent.prototype.callPasswordReminder;
    /** @type {?} */
    LoginComponent.prototype.storage;
    /**
     * @type {?}
     * @private
     */
    LoginComponent.prototype.translateService;
    /**
     * @type {?}
     * @private
     */
    LoginComponent.prototype.alertController;
    /**
     * @type {?}
     * @private
     */
    LoginComponent.prototype.translate;
}
//# sourceMappingURL=data:application/json;base64, 