import { Component, forwardRef, Input } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { AGGREGATIONS, AGGREGATION_ICONS, AGGREGATION_TEXTS } from '../../../aggregation/aggregation.model';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { TooltipModule } from 'ngx-bootstrap/tooltip';
import { IconDirective } from '../../../common/icon.directive';
import { NgFor, NgClass } from '@angular/common';
import { C8yTranslatePipe } from '../../../i18n/c8y-translate.pipe';
import * as i0 from "@angular/core";
import * as i1 from "ngx-bootstrap/dropdown";
import * as i2 from "ngx-bootstrap/tooltip";
export class AggregationPickerComponent {
    constructor() {
        /**
         * Configuration for disabling specific types of aggregation.
         * By default no aggregation type is disabled.
         */
        this.disabledAggregations = {};
        this.AGGREGATIONS = AGGREGATIONS;
        this.AGGREGATION_ICONS = AGGREGATION_ICONS;
        this.AGGREGATION_TEXTS = AGGREGATION_TEXTS;
        this.touched = false;
        this.disabled = false;
        // eslint-disable-next-line @typescript-eslint/no-empty-function
        this.onChange = _ => { };
        // eslint-disable-next-line @typescript-eslint/no-empty-function
        this.onTouched = () => { };
    }
    writeValue(value) {
        this.value = value;
    }
    registerOnChange(fn) {
        this.onChange = fn;
    }
    registerOnTouched(onTouched) {
        this.onTouched = onTouched;
    }
    markAsTouched() {
        if (!this.touched) {
            this.onTouched();
            this.touched = true;
        }
    }
    setDisabledState(disabled) {
        this.disabled = disabled;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: AggregationPickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: AggregationPickerComponent, isStandalone: true, selector: "c8y-aggregation-picker", inputs: { disabledAggregations: "disabledAggregations" }, providers: [
            {
                provide: NG_VALUE_ACCESSOR,
                useExisting: forwardRef(() => AggregationPickerComponent),
                multi: true
            }
        ], ngImport: i0, template: "<div\n  class=\"dropdown\"\n  style=\"border: 0; margin-left: -1px\"\n  #dropdown=\"bs-dropdown\"\n  dropdown\n  [insideClick]=\"true\"\n  [isDisabled]=\"disabled\"\n>\n  <button\n    class=\"dropdown-toggle form-control p-t-0 p-b-0 l-h-1 d-flex a-i-center\"\n    [attr.aria-label]=\"(value ? AGGREGATION_TEXTS[value] : AGGREGATION_TEXTS.undefined) | translate\"\n    tooltip=\"{{\n      (value\n        ? AGGREGATION_TEXTS[value]\n        : disabled\n          ? AGGREGATION_TEXTS.disabled\n          : AGGREGATION_TEXTS.undefined\n      ) | translate\n    }}\"\n    placement=\"top\"\n    container=\"body\"\n    type=\"button\"\n    [adaptivePosition]=\"false\"\n    [delay]=\"500\"\n    dropdownToggle\n  >\n    <i\n      class=\"icon-14\"\n      [c8yIcon]=\"value ? AGGREGATION_ICONS[value] : AGGREGATION_ICONS.undefined\"\n    ></i>\n    <span class=\"caret m-r-8 m-l-4\"></span>\n  </button>\n\n  <ul\n    class=\"dropdown-menu dropdown-menu-right--xs\"\n    *dropdownMenu\n  >\n    <li\n      *ngFor=\"let aggregation of AGGREGATIONS\"\n      [ngClass]=\"{\n        active: aggregation.id === value,\n        disabled: disabledAggregations[aggregation.id]\n      }\"\n    >\n      <button\n        class=\"\"\n        (click)=\"onChange(aggregation.id); dropdown.isOpen = false\"\n        [disabled]=\"disabledAggregations[aggregation.id]\"\n      >\n        <i\n          class=\"icon-14\"\n          [c8yIcon]=\"\n            aggregation.id ? AGGREGATION_ICONS[aggregation.id] : AGGREGATION_ICONS.undefined\n          \"\n        ></i>\n        <span>{{ aggregation.title | translate }}</span>\n      </button>\n    </li>\n  </ul>\n</div>\n", dependencies: [{ kind: "ngmodule", type: BsDropdownModule }, { kind: "directive", type: i1.BsDropdownMenuDirective, selector: "[bsDropdownMenu],[dropdownMenu]", exportAs: ["bs-dropdown-menu"] }, { kind: "directive", type: i1.BsDropdownToggleDirective, selector: "[bsDropdownToggle],[dropdownToggle]", exportAs: ["bs-dropdown-toggle"] }, { kind: "directive", type: i1.BsDropdownDirective, selector: "[bsDropdown], [dropdown]", inputs: ["placement", "triggers", "container", "dropup", "autoClose", "isAnimated", "insideClick", "isDisabled", "isOpen"], outputs: ["isOpenChange", "onShown", "onHidden"], exportAs: ["bs-dropdown"] }, { kind: "ngmodule", type: TooltipModule }, { kind: "directive", type: i2.TooltipDirective, selector: "[tooltip], [tooltipHtml]", inputs: ["adaptivePosition", "tooltip", "placement", "triggers", "container", "containerClass", "boundariesElement", "isOpen", "isDisabled", "delay", "tooltipHtml", "tooltipPlacement", "tooltipIsOpen", "tooltipEnable", "tooltipAppendToBody", "tooltipAnimation", "tooltipClass", "tooltipContext", "tooltipPopupDelay", "tooltipFadeDuration", "tooltipTrigger"], outputs: ["tooltipChange", "onShown", "onHidden", "tooltipStateChanged"], exportAs: ["bs-tooltip"] }, { kind: "directive", type: IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: AggregationPickerComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-aggregation-picker', providers: [
                        {
                            provide: NG_VALUE_ACCESSOR,
                            useExisting: forwardRef(() => AggregationPickerComponent),
                            multi: true
                        }
                    ], standalone: true, imports: [BsDropdownModule, TooltipModule, IconDirective, NgFor, NgClass, C8yTranslatePipe], template: "<div\n  class=\"dropdown\"\n  style=\"border: 0; margin-left: -1px\"\n  #dropdown=\"bs-dropdown\"\n  dropdown\n  [insideClick]=\"true\"\n  [isDisabled]=\"disabled\"\n>\n  <button\n    class=\"dropdown-toggle form-control p-t-0 p-b-0 l-h-1 d-flex a-i-center\"\n    [attr.aria-label]=\"(value ? AGGREGATION_TEXTS[value] : AGGREGATION_TEXTS.undefined) | translate\"\n    tooltip=\"{{\n      (value\n        ? AGGREGATION_TEXTS[value]\n        : disabled\n          ? AGGREGATION_TEXTS.disabled\n          : AGGREGATION_TEXTS.undefined\n      ) | translate\n    }}\"\n    placement=\"top\"\n    container=\"body\"\n    type=\"button\"\n    [adaptivePosition]=\"false\"\n    [delay]=\"500\"\n    dropdownToggle\n  >\n    <i\n      class=\"icon-14\"\n      [c8yIcon]=\"value ? AGGREGATION_ICONS[value] : AGGREGATION_ICONS.undefined\"\n    ></i>\n    <span class=\"caret m-r-8 m-l-4\"></span>\n  </button>\n\n  <ul\n    class=\"dropdown-menu dropdown-menu-right--xs\"\n    *dropdownMenu\n  >\n    <li\n      *ngFor=\"let aggregation of AGGREGATIONS\"\n      [ngClass]=\"{\n        active: aggregation.id === value,\n        disabled: disabledAggregations[aggregation.id]\n      }\"\n    >\n      <button\n        class=\"\"\n        (click)=\"onChange(aggregation.id); dropdown.isOpen = false\"\n        [disabled]=\"disabledAggregations[aggregation.id]\"\n      >\n        <i\n          class=\"icon-14\"\n          [c8yIcon]=\"\n            aggregation.id ? AGGREGATION_ICONS[aggregation.id] : AGGREGATION_ICONS.undefined\n          \"\n        ></i>\n        <span>{{ aggregation.title | translate }}</span>\n      </button>\n    </li>\n  </ul>\n</div>\n" }]
        }], propDecorators: { disabledAggregations: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 