import { Component, Input, Output, EventEmitter, ChangeDetectorRef, } from '@angular/core';
import { FormBuilder } from '@angular/forms';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "@angular/common";
import * as i3 from "../../../tags-input/tags-input-field.component";
export class AutoLinkingComponentClass {
    constructor(formBuilder, changeDetectionRef) {
        this.formBuilder = formBuilder;
        this.changeDetectionRef = changeDetectionRef;
        this.allLabels = [];
        this.endpointLabels = [];
        this.excludedLabels = [];
        this.optionsConfig = {};
        this.submitAutoLinkingRules = new EventEmitter();
        this.autoLinkingForm = this.formBuilder.group({
            endpointLabels: [[]],
            excludedLabels: [[]],
        }, { validator: this.atLeastOneRequired });
    }
    ngAfterViewInit() {
        this.autoLinkingForm.patchValue({
            endpointLabels: this.endpointLabels,
            excludedLabels: this.excludedLabels,
        });
        this.optionsConfig.optionsSubject.next(this.allLabels);
        this.submitAutoLinkingRules.emit({ data: this.autoLinkingForm, status: 'success' });
        this.changeDetectionRef.detectChanges();
    }
    tagsChanges() {
        this.submitAutoLinkingRules.emit({ data: this.autoLinkingForm, status: 'success' });
    }
    atLeastOneRequired(group) {
        if (group) {
            if (group.controls['endpointLabels'].value.length || group.controls['excludedLabels'].value.length) {
                return null;
            }
        }
        return { 'error': true };
    }
}
AutoLinkingComponentClass.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AutoLinkingComponentClass, deps: [{ token: i1.FormBuilder }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
AutoLinkingComponentClass.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: AutoLinkingComponentClass, selector: "epom-popup-auto-linking", inputs: { allLabels: "allLabels", endpointLabels: "endpointLabels", excludedLabels: "excludedLabels", optionsConfig: "optionsConfig" }, outputs: { submitAutoLinkingRules: "submitAutoLinkingRules" }, ngImport: i0, template: "<div class=\"row row-space-40 auto-linking-form\">\n  <form [formGroup]=\"autoLinkingForm\" [ngClass]=\"{'form-submitted': !autoLinkingForm.valid}\" >\n    <div class=\"col-md-12 \">\n      <div class=\"form-group\" [attr.data-qa]=\"'Endpoint Labels'\">\n        <label class=\"control-label\">Endpoint Labels</label>\n        <tags-input\n          class=\"form-control input-lg tags-control\"\n          [formControl]=\"autoLinkingForm.get('endpointLabels')\"\n          [separator]=\"';'\"\n          [connectedTagsList]=\"excludedLabelsTag.tagsArrayOutput\"\n          [optionsConfig] = \"optionsConfig\"\n          (onTagsChanged)= \"tagsChanges()\"\n          #endpointLabelsTag\n        >\n        </tags-input>\n      </div>\n    </div>\n    <div class=\"col-md-12\">\n      <div class=\"form-group\" [attr.data-qa]=\"'Exclude Labels'\">\n        <label class=\"control-label\">Exclude Labels</label>\n        <tags-input\n          class=\"form-control input-lg tags-control\"\n          [formControl]=\"autoLinkingForm.get('excludedLabels')\"\n          [separator]=\"';'\"\n          [optionsConfig] = \"optionsConfig\"\n          [connectedTagsList]=\"endpointLabelsTag.tagsArrayOutput\"\n          (onTagsChanged)= \"tagsChanges()\"\n          #excludedLabelsTag\n        >\n        </tags-input>\n      </div>\n    </div>\n  </form>\n</div>\n", dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i3.TagsInputFieldComponent, selector: "tags-input", inputs: ["maxTags", "separator", "removeLastOnBackspace", "canDeleteTags", "disable", "placeholder", "connectedTagsList", "optionsConfig"], outputs: ["onTagsChanged", "onMaxTagsReached"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AutoLinkingComponentClass, decorators: [{
            type: Component,
            args: [{ selector: 'epom-popup-auto-linking', template: "<div class=\"row row-space-40 auto-linking-form\">\n  <form [formGroup]=\"autoLinkingForm\" [ngClass]=\"{'form-submitted': !autoLinkingForm.valid}\" >\n    <div class=\"col-md-12 \">\n      <div class=\"form-group\" [attr.data-qa]=\"'Endpoint Labels'\">\n        <label class=\"control-label\">Endpoint Labels</label>\n        <tags-input\n          class=\"form-control input-lg tags-control\"\n          [formControl]=\"autoLinkingForm.get('endpointLabels')\"\n          [separator]=\"';'\"\n          [connectedTagsList]=\"excludedLabelsTag.tagsArrayOutput\"\n          [optionsConfig] = \"optionsConfig\"\n          (onTagsChanged)= \"tagsChanges()\"\n          #endpointLabelsTag\n        >\n        </tags-input>\n      </div>\n    </div>\n    <div class=\"col-md-12\">\n      <div class=\"form-group\" [attr.data-qa]=\"'Exclude Labels'\">\n        <label class=\"control-label\">Exclude Labels</label>\n        <tags-input\n          class=\"form-control input-lg tags-control\"\n          [formControl]=\"autoLinkingForm.get('excludedLabels')\"\n          [separator]=\"';'\"\n          [optionsConfig] = \"optionsConfig\"\n          [connectedTagsList]=\"endpointLabelsTag.tagsArrayOutput\"\n          (onTagsChanged)= \"tagsChanges()\"\n          #excludedLabelsTag\n        >\n        </tags-input>\n      </div>\n    </div>\n  </form>\n</div>\n" }]
        }], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { allLabels: [{
                type: Input,
                args: ['allLabels']
            }], endpointLabels: [{
                type: Input,
                args: ['endpointLabels']
            }], excludedLabels: [{
                type: Input,
                args: ['excludedLabels']
            }], optionsConfig: [{
                type: Input,
                args: ['optionsConfig']
            }], submitAutoLinkingRules: [{
                type: Output,
                args: ['submitAutoLinkingRules']
            }] } });
//# sourceMappingURL=data:application/json;base64, 