import * as i0 from '@angular/core';
import { EventEmitter, Output, Input, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
import { PropertyFormControl, CustomValidators } from '@aztrix/helpers';
import { PropertyType } from '@aztrix/models';
import * as i1 from '@aztrix/components/property-edit';
import { PropertyEditModule } from '@aztrix/components/property-edit';
import * as i2 from '@aztrix/components/button';
import { ButtonModule } from '@aztrix/components/button';
import * as i3 from '@aztrix/translate';
import { TranslatePipe } from '@aztrix/translate';
import { CommonModule } from '@angular/common';
import { ReactiveFormsModule } from '@angular/forms';
import { ActionFinishedModule } from '@aztrix/components/action-finished';

class SendToEmailComponent {
    constructor() {
        this.didClickSend = new EventEmitter();
        this.form = PropertyFormControl.createByType(PropertyType.EMAIL, CustomValidators.propertyValid);
    }
    sendEmail() {
        this.didClickSend.emit(this.form.value.value);
    }
    ngOnChanges(changes) {
        if (changes.email && this.email) {
            this.form.get('value')?.setValue(this.email);
            this.form.markAsDirty();
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: SendToEmailComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: SendToEmailComponent, selector: "ax-send-to-email", inputs: { hint: "hint", email: "email" }, outputs: { didClickSend: "didClickSend" }, usesOnChanges: true, ngImport: i0, template: "<ax-property-edit [form]=\"form\" [autofocus]=\"false\" [hint]=\"hint\"></ax-property-edit>\n<div class=\"h-button-wrapper\">\n  <button axButton filled color=\"primary\" [disabled]=\"!form.valid\" (click)=\"sendEmail()\">\n    {{ 'label.send' | translate }}\n  </button>\n</div>\n", styles: [":host{display:block;padding:1rem}@media only screen and (min-width: 600px){:host{display:flex;align-items:center}}:host ax-property-edit{flex:1 0 auto;margin-right:1rem}\n"], dependencies: [{ kind: "component", type: i1.PropertyEditComponent, selector: "ax-property-edit", inputs: ["isIndividual", "isProposalSubscribeForm"] }, { kind: "directive", type: i2.ButtonDirective, selector: "[axButton]", inputs: ["color", "labelHideMobile", "smallButton", "bigButton", "fullWidth", "filled", "outline", "icon-button", "hoverLabel", "hover", "lowercase", "disabled"] }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: SendToEmailComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-send-to-email', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ax-property-edit [form]=\"form\" [autofocus]=\"false\" [hint]=\"hint\"></ax-property-edit>\n<div class=\"h-button-wrapper\">\n  <button axButton filled color=\"primary\" [disabled]=\"!form.valid\" (click)=\"sendEmail()\">\n    {{ 'label.send' | translate }}\n  </button>\n</div>\n", styles: [":host{display:block;padding:1rem}@media only screen and (min-width: 600px){:host{display:flex;align-items:center}}:host ax-property-edit{flex:1 0 auto;margin-right:1rem}\n"] }]
        }], propDecorators: { hint: [{
                type: Input
            }], email: [{
                type: Input
            }], didClickSend: [{
                type: Output
            }] } });

class SendToEmailModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: SendToEmailModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: SendToEmailModule, declarations: [SendToEmailComponent], imports: [CommonModule,
            PropertyEditModule,
            TranslatePipe,
            ReactiveFormsModule,
            ButtonModule,
            ActionFinishedModule], exports: [SendToEmailComponent] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: SendToEmailModule, imports: [CommonModule,
            PropertyEditModule,
            ReactiveFormsModule,
            ButtonModule,
            ActionFinishedModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: SendToEmailModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [SendToEmailComponent],
                    imports: [
                        CommonModule,
                        PropertyEditModule,
                        TranslatePipe,
                        ReactiveFormsModule,
                        ButtonModule,
                        ActionFinishedModule,
                    ],
                    exports: [SendToEmailComponent],
                }]
        }] });

/**
 * Generated bundle index. Do not edit.
 */

export { SendToEmailComponent, SendToEmailModule };
//# sourceMappingURL=aztrix-components-send-to-email.mjs.map
