import { Component, EventEmitter, Input, Output } from '@angular/core';
import { FormControl } from '@angular/forms';
import { OverlayService } from '@aztrix/components/overlay';
import { CustomValidators } from '@aztrix/helpers';
import { first } from 'rxjs';
import * as i0 from "@angular/core";
import * as i1 from "@aztrix/components/overlay";
import * as i2 from "@angular/common";
import * as i3 from "@aztrix/components/button";
import * as i4 from "@aztrix/components/value-edit";
import * as i5 from "@aztrix/components/login-value-form-error";
import * as i6 from "@aztrix/helpers";
export class RetryVerificationComponent {
    constructor(_overlay) {
        this._overlay = _overlay;
        this.form = new FormControl('', [CustomValidators.validateLoginValue()]);
        this.verificationValueChanges = new EventEmitter();
        this._mobileForm = new FormControl();
        this._emailForm = new FormControl();
    }
    ngOnInit() {
        this._mobileForm.valueChanges.subscribe((value) => {
            this.form.setValue(value);
        });
        this._emailForm.valueChanges.subscribe((value) => {
            this.form.setValue(value);
        });
    }
    resendVerification() {
        this.retryVerification(this.form.value)
            .pipe(first())
            .subscribe(() => {
            this.verificationValueChanges.next(this.form.value);
            this._overlay.closeModal();
        });
    }
}
RetryVerificationComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: RetryVerificationComponent, deps: [{ token: i1.OverlayService }], target: i0.ɵɵFactoryTarget.Component });
RetryVerificationComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.5", type: RetryVerificationComponent, selector: "ax-retry-verification", inputs: { form: "form", verificationType: "verificationType", retryVerification: "retryVerification" }, outputs: { verificationValueChanges: "verificationValueChanges" }, ngImport: i0, template: "<ax-value-edit\n  [form]=\"form\"\n  [autofocus]=\"false\"\n  [required]=\"true\"\n  [hint]=\"\n    'proposal.agreement.verification.property'\n      | translate: {propertyType: verificationType | propertyTypeLabel}\n  \"\n  [type]=\"verificationType.includes('MOBILE') ? 'PHONE' : verificationType\"\n  [label]=\"verificationType | propertyTypeLabel\"\n  [errorsTemplate]=\"errorsTemplate\"\n></ax-value-edit>\n<div class=\"h-button-wrapper\">\n  <button [disabled]=\"form.invalid\" axButton filled (click)=\"resendVerification()\" color=\"primary\">\n    {{ 'agreement.verification.send' | translate }}\n  </button>\n</div>\n\n<ng-template #errorsTemplate>\n  <ax-login-value-form-error\n    *ngIf=\"form.touched\"\n    [form]=\"form\"\n    [propertyType]=\"verificationType\"\n  ></ax-login-value-form-error>\n</ng-template>\n", styles: [":host{padding:1rem;display:block}\n"], dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.ButtonDirective, selector: "[axButton]", inputs: ["color", "labelHideMobile", "smallButton", "bigButton", "fullWidth", "filled", "outline", "icon-button", "hoverLabel", "hover", "lowercase", "disabled"] }, { kind: "component", type: i4.ValueEditComponent, selector: "ax-value-edit", inputs: ["type", "numberConfig"] }, { kind: "component", type: i5.LoginValueFormErrorComponent, selector: "ax-login-value-form-error", inputs: ["form", "propertyType"] }, { kind: "pipe", type: i6.PropertyTypeLabelPipe, name: "propertyTypeLabel" }, { kind: "pipe", type: i6.TranslatePipe, name: "translate" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: RetryVerificationComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-retry-verification', template: "<ax-value-edit\n  [form]=\"form\"\n  [autofocus]=\"false\"\n  [required]=\"true\"\n  [hint]=\"\n    'proposal.agreement.verification.property'\n      | translate: {propertyType: verificationType | propertyTypeLabel}\n  \"\n  [type]=\"verificationType.includes('MOBILE') ? 'PHONE' : verificationType\"\n  [label]=\"verificationType | propertyTypeLabel\"\n  [errorsTemplate]=\"errorsTemplate\"\n></ax-value-edit>\n<div class=\"h-button-wrapper\">\n  <button [disabled]=\"form.invalid\" axButton filled (click)=\"resendVerification()\" color=\"primary\">\n    {{ 'agreement.verification.send' | translate }}\n  </button>\n</div>\n\n<ng-template #errorsTemplate>\n  <ax-login-value-form-error\n    *ngIf=\"form.touched\"\n    [form]=\"form\"\n    [propertyType]=\"verificationType\"\n  ></ax-login-value-form-error>\n</ng-template>\n", styles: [":host{padding:1rem;display:block}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.OverlayService }]; }, propDecorators: { form: [{
                type: Input
            }], verificationType: [{
                type: Input
            }], retryVerification: [{
                type: Input
            }], verificationValueChanges: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 