/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import { Component, Input } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms';
import { Store } from '@ngrx/store';
import { AuthService } from '../auth.service';
import { Login } from '../ngrx/actions';
import { pluck } from 'rxjs/operators';
var SignInComponent = /** @class */ (function () {
    function SignInComponent(fb, store, auth) {
        this.fb = fb;
        this.store = store;
        this.auth = auth;
    }
    /**
     * @return {?}
     */
    SignInComponent.prototype.ngOnInit = /**
     * @return {?}
     */
    function () {
        this.form = this.fb.group({
            user: ['', Validators.required],
            password: ['', Validators.required]
        });
        this.loginError$ = this.auth.state$.pipe(pluck('error'));
    };
    /**
     * @return {?}
     */
    SignInComponent.prototype.submitForm = /**
     * @return {?}
     */
    function () {
        if (this.form.invalid) {
            return;
        }
        this.store.dispatch(new Login({
            user: this.form.value.user.toLowerCase(),
            password: this.form.value.password
        }));
    };
    SignInComponent.decorators = [
        { type: Component, args: [{
                    selector: 'bidi-sign-in',
                    template: "<div class=\"sing-in \">\n  <div class=\"miscleanea\"></div>\n  <div class=\"miscleanea\" style=\"    left: 0;\n  width: 39%;\n  bottom: -147px;\"></div>\n  <div class=\"columns is-uppercase\">\n    <div class=\"column is-narrow is-offset-1\">\n      <p class=\"is-ff-black\">{{title}}</p>\n      <p class=\"is-ff-light\">{{subtitle}}</p>\n    </div>\n  </div>\n  <div class=\"columns\">\n\n    <div class=\"column is-7 is-offset-5\">\n      <div class=\"form-container fade-in\">\n        <form [formGroup]=\"form\" (ngSubmit)=\"submitForm()\">\n          <div class=\"field\">\n            <div class=\"control\">\n              <input\n                class=\"form-control\"\n                formControlName=\"user\"\n                type=\"text\"\n                placeholder=\"escribe tu usuario\">\n            </div>\n            <div\n              *ngIf=\"form.controls['user'].invalid && (form.controls['user'].dirty || form.controls['user'].touched)\"\n            >\n              <div *ngIf=\"form.controls['user'].errors.required\" class=\"error-alert has-text-centered is-size-7\">\n                El nombre de usuario es obligatorio.\n              </div>\n            </div>\n          </div>\n          <div class=\"field\">\n            <div class=\"control\">\n              <input\n                class=\"form-control\"\n                type=\"password\"\n                formControlName=\"password\"\n                placeholder=\"escribe tu contrase\u00F1a\">\n            </div>\n            <div\n              *ngIf=\"form.controls['password'].invalid && (form.controls['password'].dirty || form.controls['password'].touched)\"\n            >\n              <div *ngIf=\"form.controls['password'].errors.required\" class=\"error-alert has-text-centered is-size-7\">\n                La contrase\u00F1a es obligatoria.\n              </div>\n            </div>\n          </div>\n          <div class=\"control has-text-centered\">\n\n            <div class=\"buttons\">\n              <button type=\"submit\" [disabled]=\"form.invalid\" class=\"button is-circle-medium is-white\">\n                <svg style=\"fill: #00F699;\" width=\"24\" height=\"24\" xmlns=\"http://www.w3.org/2000/svg\"\n                     fill-rule=\"evenodd\" clip-rule=\"evenodd\">\n                  <path d=\"M21 6.285l-11.16 12.733-6.84-6.018 1.319-1.49 5.341 4.686 9.865-11.196 1.475 1.285z\"/>\n                </svg>\n              </button>\n            </div>\n\n          </div>\n        </form>\n        <span\n          *ngIf=\"loginError$ | async\"\n          class=\"error has-background-danger has-text-light is-size-6 is-uppercase has-text-centered\"\n        >\n          Ha ocurrido un error, intenta nuevamente\n        </span>\n      </div>\n\n    </div>\n  </div>\n</div>\n",
                    styles: [""]
                }] }
    ];
    /** @nocollapse */
    SignInComponent.ctorParameters = function () { return [
        { type: FormBuilder },
        { type: Store },
        { type: AuthService }
    ]; };
    SignInComponent.propDecorators = {
        title: [{ type: Input }],
        subtitle: [{ type: Input }]
    };
    return SignInComponent;
}());
export { SignInComponent };
if (false) {
    /** @type {?} */
    SignInComponent.prototype.form;
    /** @type {?} */
    SignInComponent.prototype.loginError$;
    /** @type {?} */
    SignInComponent.prototype.title;
    /** @type {?} */
    SignInComponent.prototype.subtitle;
    /**
     * @type {?}
     * @private
     */
    SignInComponent.prototype.fb;
    /**
     * @type {?}
     * @private
     */
    SignInComponent.prototype.store;
    /**
     * @type {?}
     * @private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