import * as i0 from '@angular/core';
import { EventEmitter, Component, Output, Input, NgModule } from '@angular/core';
import * as i3 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i1 from '@angular/forms';
import { Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { TargetS3PProtocolConfiguration } from '@iotize/tap/service/impl/target';
import * as i2 from '@ionic/angular';
import { IonicModule } from '@ionic/angular';

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 */ /** @nocollapse */ TapS3pConfigurationFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: TapS3pConfigurationFormComponent, deps: [{ token: i1.FormBuilder }], target: i0.ɵɵFactoryTarget.Component });
/** @nocollapse */ /** @nocollapse */ TapS3pConfigurationFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.0", type: TapS3pConfigurationFormComponent, selector: "tap-s3p-configuration-form", inputs: { values: "values" }, outputs: { valueChanges: "valueChanges" }, ngImport: i0, template: "<form [formGroup]=\"form\">\n  <ion-item>\n    <ion-label> Mode </ion-label>\n    <ion-select slot=\"end\" [formControlName]=\"'mode'\">\n      <ion-select-option *ngFor=\"let mode of modes\" [value]=\"mode.value\">\n        {{ mode.title }}\n      </ion-select-option>\n    </ion-select>\n  </ion-item>\n  <ion-item>\n    <ion-label> Delay </ion-label>\n    <ion-input type=\"number\" slot=\"end\" [formControlName]=\"'delay'\"></ion-input>\n  </ion-item>\n</form>\n", styles: ["ion-input{text-align:right}\n"], components: [{ type: i2.IonItem, selector: "ion-item", inputs: ["button", "color", "counter", "detail", "detailIcon", "disabled", "download", "fill", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "shape", "target", "type"] }, { type: i2.IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { type: i2.IonSelect, selector: "ion-select", inputs: ["cancelText", "compareWith", "disabled", "interface", "interfaceOptions", "mode", "multiple", "name", "okText", "placeholder", "selectedText", "value"] }, { type: i2.IonSelectOption, selector: "ion-select-option", inputs: ["disabled", "value"] }, { type: i2.IonInput, selector: "ion-input", inputs: ["accept", "autocapitalize", "autocomplete", "autocorrect", "autofocus", "clearInput", "clearOnEdit", "color", "debounce", "disabled", "enterkeyhint", "inputmode", "max", "maxlength", "min", "minlength", "mode", "multiple", "name", "pattern", "placeholder", "readonly", "required", "size", "spellcheck", "step", "type", "value"] }], directives: [{ type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i2.SelectValueAccessor, selector: "ion-range, ion-select, ion-radio-group, ion-segment, ion-datetime" }, { type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NumericValueAccessor, selector: "ion-input[type=number]" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: TapS3pConfigurationFormComponent, decorators: [{
            type: Component,
            args: [{ selector: 'tap-s3p-configuration-form', template: "<form [formGroup]=\"form\">\n  <ion-item>\n    <ion-label> Mode </ion-label>\n    <ion-select slot=\"end\" [formControlName]=\"'mode'\">\n      <ion-select-option *ngFor=\"let mode of modes\" [value]=\"mode.value\">\n        {{ mode.title }}\n      </ion-select-option>\n    </ion-select>\n  </ion-item>\n  <ion-item>\n    <ion-label> Delay </ion-label>\n    <ion-input type=\"number\" slot=\"end\" [formControlName]=\"'delay'\"></ion-input>\n  </ion-item>\n</form>\n", styles: ["ion-input{text-align:right}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.FormBuilder }]; }, propDecorators: { valueChanges: [{
                type: Output
            }], values: [{
                type: Input
            }] } });

class TapTargetS3PModule {
}
/** @nocollapse */ /** @nocollapse */ TapTargetS3PModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: TapTargetS3PModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
/** @nocollapse */ /** @nocollapse */ TapTargetS3PModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: TapTargetS3PModule, declarations: [TapS3pConfigurationFormComponent], imports: [CommonModule, IonicModule, FormsModule, ReactiveFormsModule], exports: [TapS3pConfigurationFormComponent] });
/** @nocollapse */ /** @nocollapse */ TapTargetS3PModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: TapTargetS3PModule, imports: [[CommonModule, IonicModule, FormsModule, ReactiveFormsModule]] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: TapTargetS3PModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [TapS3pConfigurationFormComponent],
                    exports: [TapS3pConfigurationFormComponent],
                    imports: [CommonModule, IonicModule, FormsModule, ReactiveFormsModule],
                }]
        }] });

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

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