/**
 * @fileoverview added by tsickle
 * Generated from: lib/user/profile/components/ch-password/ch-password.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import * as tslib_1 from "tslib";
import { ToastService } from './../../../../widgets/entry-components/toast/services/toast.service';
import { ChBaseComponent } from './../ch-base/ch-base.component';
import { PrevRouteService } from './../../../../routing/services/prev-route.service';
import { Component, Output, EventEmitter } from '@angular/core';
import { Router } from '@angular/router';
import { Storage } from '@ionic/storage';
import { FormGroup, FormControl } from '@angular/forms';
/** @type {?} */
var PW = { type: 'password', icon: 'eye' };
/** @type {?} */
var TEXT = { type: 'text', icon: 'eye-off' };
var ChPasswordComponent = /** @class */ (function (_super) {
    tslib_1.__extends(ChPasswordComponent, _super);
    function ChPasswordComponent(prevRouteService, router, storage, toastService) {
        var _this = _super.call(this, prevRouteService, router, storage) || this;
        _this.toastService = toastService;
        _this.inputs = [PW, PW, PW];
        _this.callSave = new EventEmitter();
        return _this;
    }
    /**
     * @return {?}
     */
    ChPasswordComponent.prototype.ngOnInit = /**
     * @return {?}
     */
    function () {
        this.reset();
    };
    /**
     * @return {?}
     */
    ChPasswordComponent.prototype.reset = /**
     * @return {?}
     */
    function () {
        this.inputs = [PW, PW, PW];
        this.form = this.resetForm();
    };
    /**
     * @return {?}
     */
    ChPasswordComponent.prototype.resetForm = /**
     * @return {?}
     */
    function () {
        return new FormGroup({
            newPassword: new FormControl(''),
            reNewPassword: new FormControl('')
        });
    };
    /**
     * @return {?}
     */
    ChPasswordComponent.prototype.reAuthenticate = /**
     * @return {?}
     */
    function () {
        this.setMustRelogin();
        if (this.form.value.newPassword === this.form.value.reNewPassword) {
            this.callSave.emit(this.form.value.reNewPassword);
        }
        else {
            this.toastService.presentToast('PASSWORD_MISSMATCH');
        }
    };
    /**
     * @param {?} index
     * @return {?}
     */
    ChPasswordComponent.prototype.togglePwVisibility = /**
     * @param {?} index
     * @return {?}
     */
    function (index) {
        this.inputs[index] = (this.inputs[index] === PW) ? TEXT : PW;
    };
    ChPasswordComponent.decorators = [
        { type: Component, args: [{
                    selector: 'inc-ch-password',
                    template: "<div *ngIf=\"mustLoginAgain\" text-center>\r\n    <h5>{{'NEED_LOGIN' | translate}}</h5>\r\n    <ion-button id=\"login-forpw\" [routerLink]=\"['/login', currentRoute]\">{{'LOGIN' | translate}}\r\n    </ion-button>\r\n</div>\r\n<ion-list *ngIf=\"!mustLoginAgain\">\r\n    <form [formGroup]=\"form\" (ngSubmit)=\"reAuthenticate()\">\r\n        <ion-text>\r\n            <h5>{{'EDIT_PASSWORD' | translate}}</h5>\r\n        </ion-text>\r\n        <ion-item>\r\n            <ion-label position=\"floating\">{{'NEW_PW' | translate}}\r\n                <span class=\"required\">*</span>\r\n            </ion-label>\r\n            <ion-input id=\"newPassword\" formControlName=\"newPassword\" [type]=\"inputs[0].type\" name=\"password\" required\r\n                minlength=\"6\">\r\n            </ion-input>\r\n            <ion-icon slot=\"end\" id=\"eye2\" [name]=\"inputs[0].icon\" (click)=\"togglePwVisibility(0)\">\r\n            </ion-icon>\r\n        </ion-item>\r\n        <ion-item>\r\n            <ion-label position=\"floating\">{{'NEW_PW_CONFIRM' | translate}}\r\n                <span class=\"required\">*</span>\r\n            </ion-label>\r\n            <ion-input id=\"reNewPassword\" formControlName=\"reNewPassword\" [type]=\"inputs[1].type\" name=\"password\"\r\n                required minlength=\"6\">\r\n            </ion-input>\r\n            <ion-icon slot=\"end\" id=\"eye3\" [name]=\"inputs[1].icon\" (click)=\"togglePwVisibility(1)\">\r\n            </ion-icon>\r\n        </ion-item>\r\n        <div class=\"ion-float-right ion-margin-top\">\r\n            <ion-button id=\"pwreset\" type=\"reset\" fill=\"outline\" (click)=\"reset()\" class=\"ion-margin-end\">\r\n                <ion-icon slot=\"start\" name=\"refresh\"></ion-icon>\r\n                {{'AGAIN_BUTTON' | translate}}\r\n            </ion-button>\r\n            <ion-button id=\"submitpw\" type=\"submit\" color=\"primary\" [disabled]=\"form.invalid\">\r\n                <ion-icon slot=\"start\" name=\"save\"></ion-icon>\r\n                {{'READY_BUTTON' | translate}}\r\n            </ion-button>\r\n        </div>\r\n    </form>\r\n</ion-list>",
                    styles: [""]
                }] }
    ];
    /** @nocollapse */
    ChPasswordComponent.ctorParameters = function () { return [
        { type: PrevRouteService },
        { type: Router },
        { type: Storage },
        { type: ToastService }
    ]; };
    ChPasswordComponent.propDecorators = {
        callSave: [{ type: Output }]
    };
    return ChPasswordComponent;
}(ChBaseComponent));
export { ChPasswordComponent };
if (false) {
    /** @type {?} */
    ChPasswordComponent.prototype.inputs;
    /** @type {?} */
    ChPasswordComponent.prototype.callSave;
    /**
     * @type {?}
     * @private
     */
    ChPasswordComponent.prototype.toastService;
}
//# sourceMappingURL=data:application/json;base64, 