import { Component, forwardRef } from '@angular/core';
import { gettext, PRODUCT_EXPERIENCE_EVENT_SOURCE } from '@c8y/ngx-components';
import { BsModalRef } from 'ngx-bootstrap/modal';
import { PRODUCT_EXPERIENCE_DEVICE_PROFILE } from './device-profile.model';
import { DeviceProfileService } from './device-profile.service';
import * as i0 from "@angular/core";
import * as i1 from "ngx-bootstrap/modal";
import * as i2 from "./device-profile.service";
import * as i3 from "@c8y/ngx-components";
import * as i4 from "@angular/forms";
import * as i5 from "ngx-bootstrap/popover";
export class AddDeviceProfileComponent {
    constructor(modal, deviceProfileService) {
        this.modal = modal;
        this.deviceProfileService = deviceProfileService;
        this.DEVICE_TYPE_POPOVER = gettext('The device profile will be available for assignments on devices of the specified type. Otherwise, it will be available for all device types.');
        this.PRODUCT_EXPERIENCE = PRODUCT_EXPERIENCE_DEVICE_PROFILE;
        this.deviceProfile = {
            name: '',
            type: 'c8y_Profile',
            c8y_Filter: {},
            c8y_DeviceProfile: {}
        };
        this.result = new Promise((resolve, reject) => {
            this._save = resolve;
            this._cancel = reject;
        });
    }
    async create() {
        const mo = (await this.deviceProfileService.createDeviceProfile(this.deviceProfile)).data;
        this._save(mo.id);
    }
    close() {
        this._cancel();
        this.modal.hide();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: AddDeviceProfileComponent, deps: [{ token: i1.BsModalRef }, { token: i2.DeviceProfileService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.9", type: AddDeviceProfileComponent, selector: "c8y-add-device-profile", providers: [
            {
                provide: PRODUCT_EXPERIENCE_EVENT_SOURCE,
                useExisting: forwardRef(() => AddDeviceProfileComponent)
            }
        ], ngImport: i0, template: "<div class=\"viewport-modal\">\n  <div class=\"modal-header dialog-header\">\n    <i [c8yIcon]=\"'c8y-device-profile'\"></i>\n    <div\n      class=\"modal-title\"\n      id=\"addDeviceProfileModalTitle\"\n      translate\n    >\n      Add device profile\n    </div>\n  </div>\n\n  <form\n    #createDeviceProfile=\"ngForm\"\n    (ngSubmit)=\"createDeviceProfile.form.valid && create()\"\n  >\n    <div class=\"modal-inner-scroll\">\n      <div\n        class=\"modal-body\"\n        id=\"addDeviceProfileModalDescription\"\n      >\n        <c8y-form-group>\n          <label\n            for=\"name\"\n            translate\n          >\n            Name\n          </label>\n          <input\n            class=\"form-control\"\n            id=\"name\"\n            placeholder=\"{{ 'e.g. My device profile' | translate }}\"\n            name=\"name\"\n            type=\"text\"\n            autocomplete=\"off\"\n            required\n            [(ngModel)]=\"deviceProfile.name\"\n            data-cy=\"add-device-profile--device-profile-name\"\n          />\n        </c8y-form-group>\n        <c8y-form-group>\n          <label>\n            {{ 'Device type' | translate }}\n            <button\n              class=\"btn-help btn-help--sm\"\n              [attr.aria-label]=\"'Help' | translate\"\n              popover=\"{{ DEVICE_TYPE_POPOVER | translate }}\"\n              placement=\"right\"\n              triggers=\"focus\"\n              type=\"button\"\n            ></button>\n          </label>\n          <input\n            class=\"form-control\"\n            id=\"deviceType\"\n            placeholder=\"{{ 'e.g.' | translate }} c8y_Linux\"\n            name=\"deviceType\"\n            [(ngModel)]=\"deviceProfile.c8y_Filter.type\"\n            data-cy=\"add-device-profile--device-type\"\n          />\n        </c8y-form-group>\n      </div>\n    </div>\n    <div class=\"modal-footer\">\n      <button\n        class=\"btn btn-default\"\n        title=\"{{ 'Cancel' | translate }}\"\n        type=\"button\"\n        (click)=\"close()\"\n        c8yProductExperience\n        inherit\n        suppressDataOverriding\n        [actionData]=\"{ action: PRODUCT_EXPERIENCE.ACTIONS.CANCEL }\"\n      >\n        {{ 'Cancel' | translate }}\n      </button>\n\n      <button\n        class=\"btn btn-primary\"\n        title=\"{{ 'Continue' | translate }}\"\n        type=\"submit\"\n        [disabled]=\"createDeviceProfile.form.invalid\"\n        c8yProductExperience\n        inherit\n        suppressDataOverriding\n        [actionData]=\"{ action: PRODUCT_EXPERIENCE.ACTIONS.CREATE }\"\n      >\n        {{ 'Continue' | translate }}\n      </button>\n    </div>\n  </form>\n</div>\n", dependencies: [{ kind: "directive", type: i3.IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "directive", type: i3.C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: i4.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i4.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i4.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i4.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i3.FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "directive", type: i3.RequiredInputPlaceholderDirective, selector: "input[required], input[formControlName]" }, { kind: "directive", type: i3.ProductExperienceDirective, selector: "[c8yProductExperience]", inputs: ["actionName", "actionData", "inherit", "suppressDataOverriding"] }, { kind: "directive", type: i5.PopoverDirective, selector: "[popover]", inputs: ["adaptivePosition", "boundariesElement", "popover", "popoverContext", "popoverTitle", "placement", "outsideClick", "triggers", "container", "containerClass", "isOpen", "delay"], outputs: ["onShown", "onHidden"], exportAs: ["bs-popover"] }, { kind: "pipe", type: i3.C8yTranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: AddDeviceProfileComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-add-device-profile', providers: [
                        {
                            provide: PRODUCT_EXPERIENCE_EVENT_SOURCE,
                            useExisting: forwardRef(() => AddDeviceProfileComponent)
                        }
                    ], template: "<div class=\"viewport-modal\">\n  <div class=\"modal-header dialog-header\">\n    <i [c8yIcon]=\"'c8y-device-profile'\"></i>\n    <div\n      class=\"modal-title\"\n      id=\"addDeviceProfileModalTitle\"\n      translate\n    >\n      Add device profile\n    </div>\n  </div>\n\n  <form\n    #createDeviceProfile=\"ngForm\"\n    (ngSubmit)=\"createDeviceProfile.form.valid && create()\"\n  >\n    <div class=\"modal-inner-scroll\">\n      <div\n        class=\"modal-body\"\n        id=\"addDeviceProfileModalDescription\"\n      >\n        <c8y-form-group>\n          <label\n            for=\"name\"\n            translate\n          >\n            Name\n          </label>\n          <input\n            class=\"form-control\"\n            id=\"name\"\n            placeholder=\"{{ 'e.g. My device profile' | translate }}\"\n            name=\"name\"\n            type=\"text\"\n            autocomplete=\"off\"\n            required\n            [(ngModel)]=\"deviceProfile.name\"\n            data-cy=\"add-device-profile--device-profile-name\"\n          />\n        </c8y-form-group>\n        <c8y-form-group>\n          <label>\n            {{ 'Device type' | translate }}\n            <button\n              class=\"btn-help btn-help--sm\"\n              [attr.aria-label]=\"'Help' | translate\"\n              popover=\"{{ DEVICE_TYPE_POPOVER | translate }}\"\n              placement=\"right\"\n              triggers=\"focus\"\n              type=\"button\"\n            ></button>\n          </label>\n          <input\n            class=\"form-control\"\n            id=\"deviceType\"\n            placeholder=\"{{ 'e.g.' | translate }} c8y_Linux\"\n            name=\"deviceType\"\n            [(ngModel)]=\"deviceProfile.c8y_Filter.type\"\n            data-cy=\"add-device-profile--device-type\"\n          />\n        </c8y-form-group>\n      </div>\n    </div>\n    <div class=\"modal-footer\">\n      <button\n        class=\"btn btn-default\"\n        title=\"{{ 'Cancel' | translate }}\"\n        type=\"button\"\n        (click)=\"close()\"\n        c8yProductExperience\n        inherit\n        suppressDataOverriding\n        [actionData]=\"{ action: PRODUCT_EXPERIENCE.ACTIONS.CANCEL }\"\n      >\n        {{ 'Cancel' | translate }}\n      </button>\n\n      <button\n        class=\"btn btn-primary\"\n        title=\"{{ 'Continue' | translate }}\"\n        type=\"submit\"\n        [disabled]=\"createDeviceProfile.form.invalid\"\n        c8yProductExperience\n        inherit\n        suppressDataOverriding\n        [actionData]=\"{ action: PRODUCT_EXPERIENCE.ACTIONS.CREATE }\"\n      >\n        {{ 'Continue' | translate }}\n      </button>\n    </div>\n  </form>\n</div>\n" }]
        }], ctorParameters: () => [{ type: i1.BsModalRef }, { type: i2.DeviceProfileService }] });
//# sourceMappingURL=data:application/json;base64, 