import { ɵɵelementStart, ɵɵtext, ɵɵelementEnd, ɵɵproperty, ɵɵadvance, ɵɵtextInterpolate1, EventEmitter, ɵɵdirectiveInject, ɵɵdefineComponent, ɵɵtemplate, ɵɵelement, ɵsetClassMetadata, Component, Output, Input, ɵɵdefineNgModule, ɵɵdefineInjector, ɵɵsetNgModuleScope, NgModule } from '@angular/core';
import { NgForOf, CommonModule } from '@angular/common';
import { Validators, FormBuilder, ɵangular_packages_forms_forms_ba, NgControlStatusGroup, FormGroupDirective, NgControlStatus, FormControlName, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { TargetS3PProtocolConfiguration } from '@iotize/tap/service/impl/target';
import { IonItem, IonLabel, IonSelect, SelectValueAccessor, IonInput, NumericValueAccessor, IonSelectOption, IonicModule } from '@ionic/angular';

function TapS3pConfigurationFormComponent_ion_select_option_5_Template(rf, ctx) { if (rf & 1) {
    ɵɵelementStart(0, "ion-select-option", 4);
    ɵɵtext(1);
    ɵɵelementEnd();
} if (rf & 2) {
    const mode_r1 = ctx.$implicit;
    ɵɵproperty("value", mode_r1.value);
    ɵɵadvance(1);
    ɵɵtextInterpolate1(" ", mode_r1.title, " ");
} }
class TapS3pConfigurationFormComponent {
    constructor(formBuilder) {
        this.valueChanges = new EventEmitter();
        this.modes = [
            {
                title: 'Indexed',
                value: TargetS3PProtocolConfiguration.Mode.INDEXED,
            },
            {
                title: 'Emulation',
                value: TargetS3PProtocolConfiguration.Mode.EMULATION,
            },
        ];
        this.form = formBuilder.group({
            mode: [
                TargetS3PProtocolConfiguration.Mode.INDEXED,
                [Validators.required],
            ],
            delay: [1, [Validators.required, Validators.min(1), Validators.max(255)]],
        });
        this.form.valueChanges.subscribe((event) => {
            // if (this.form.valid){
            this.valueChanges.emit(event);
            // }
        });
    }
    set values(obs) {
        var _a;
        (_a = this.valueSub) === null || _a === void 0 ? void 0 : _a.unsubscribe();
        this.valueSub = obs === null || obs === void 0 ? void 0 : obs.subscribe((newValue) => {
            this.form.setValue(newValue, {
                emitEvent: false,
            });
        });
    }
}
/** @nocollapse */ TapS3pConfigurationFormComponent.ɵfac = function TapS3pConfigurationFormComponent_Factory(t) { return new (t || TapS3pConfigurationFormComponent)(ɵɵdirectiveInject(FormBuilder)); };
/** @nocollapse */ TapS3pConfigurationFormComponent.ɵcmp = ɵɵdefineComponent({ type: TapS3pConfigurationFormComponent, selectors: [["tap-s3p-configuration-form"]], inputs: { values: "values" }, outputs: { valueChanges: "valueChanges" }, decls: 10, vars: 4, consts: [[3, "formGroup"], ["slot", "end", 3, "formControlName"], [3, "value", 4, "ngFor", "ngForOf"], ["type", "number", "slot", "end", 3, "formControlName"], [3, "value"]], template: function TapS3pConfigurationFormComponent_Template(rf, ctx) { if (rf & 1) {
        ɵɵelementStart(0, "form", 0);
        ɵɵelementStart(1, "ion-item");
        ɵɵelementStart(2, "ion-label");
        ɵɵtext(3, " Mode ");
        ɵɵelementEnd();
        ɵɵelementStart(4, "ion-select", 1);
        ɵɵtemplate(5, TapS3pConfigurationFormComponent_ion_select_option_5_Template, 2, 2, "ion-select-option", 2);
        ɵɵelementEnd();
        ɵɵelementEnd();
        ɵɵelementStart(6, "ion-item");
        ɵɵelementStart(7, "ion-label");
        ɵɵtext(8, " Delay ");
        ɵɵelementEnd();
        ɵɵelement(9, "ion-input", 3);
        ɵɵelementEnd();
        ɵɵelementEnd();
    } if (rf & 2) {
        ɵɵproperty("formGroup", ctx.form);
        ɵɵadvance(4);
        ɵɵproperty("formControlName", "mode");
        ɵɵadvance(1);
        ɵɵproperty("ngForOf", ctx.modes);
        ɵɵadvance(4);
        ɵɵproperty("formControlName", "delay");
    } }, directives: [ɵangular_packages_forms_forms_ba, NgControlStatusGroup, FormGroupDirective, IonItem, IonLabel, IonSelect, SelectValueAccessor, NgControlStatus, FormControlName, NgForOf, IonInput, NumericValueAccessor, IonSelectOption], styles: ["ion-input[_ngcontent-%COMP%]{text-align:right}"] });
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(TapS3pConfigurationFormComponent, [{
        type: Component,
        args: [{
                selector: 'tap-s3p-configuration-form',
                templateUrl: './tap-s3p-configuration-form.component.html',
                styleUrls: ['./tap-s3p-configuration-form.component.scss'],
            }]
    }], function () { return [{ type: FormBuilder }]; }, { valueChanges: [{
            type: Output
        }], values: [{
            type: Input
        }] }); })();

class TapTargetS3PModule {
}
/** @nocollapse */ TapTargetS3PModule.ɵfac = function TapTargetS3PModule_Factory(t) { return new (t || TapTargetS3PModule)(); };
/** @nocollapse */ TapTargetS3PModule.ɵmod = ɵɵdefineNgModule({ type: TapTargetS3PModule });
/** @nocollapse */ TapTargetS3PModule.ɵinj = ɵɵdefineInjector({ imports: [[CommonModule, IonicModule, FormsModule, ReactiveFormsModule]] });
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && ɵɵsetNgModuleScope(TapTargetS3PModule, { declarations: [TapS3pConfigurationFormComponent], imports: [CommonModule, IonicModule, FormsModule, ReactiveFormsModule], exports: [TapS3pConfigurationFormComponent] }); })();
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵsetClassMetadata(TapTargetS3PModule, [{
        type: NgModule,
        args: [{
                declarations: [TapS3pConfigurationFormComponent],
                exports: [TapS3pConfigurationFormComponent],
                imports: [CommonModule, IonicModule, FormsModule, ReactiveFormsModule],
            }]
    }], null, null); })();

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

export { TapS3pConfigurationFormComponent, TapTargetS3PModule };
//# sourceMappingURL=iotize-ionic-target-s3p.js.map
