import { __decorate, __metadata } from "tslib";
import { ChangeDetectionStrategy, Component, forwardRef, Inject, ViewChild, ViewEncapsulation } from "@angular/core";
import { MatIconModule } from "@angular/material/icon";
import { MatTooltipModule } from "@angular/material/tooltip";
import { OTranslatePipe } from "../../../../../pipes/o-translate.pipe";
import { OTableBase } from "../../../o-table-base.class";
import { OMatSortHeader } from "../../sort/o-mat-sort-header";
import { OTableHeaderColumnFilterIconComponent } from "../table-header-column-filter-icon/o-table-header-column-filter-icon.component";
import { OTableColumnResizerComponent } from "../table-column-resizer/o-table-column-resizer.component";
import { BooleanInputConverter } from "../../../../../decorators/input-converter";
import * as i0 from "@angular/core";
import * as i1 from "@angular/material/icon";
import * as i2 from "@angular/material/tooltip";
import * as i3 from "../../../o-table-base.class";
export const DEFAULT_INPUTS_O_TABLE_HEADER = [
    'column',
    'columnFilters: column-filters',
    'showHeaderTooltip: show-header-tooltip',
];
export class OTableHeaderComponent {
    set columnFilterIcon(value) {
        this._columnFilterIcon = value;
    }
    constructor(table) {
        this.table = table;
        this.columnFilters = [];
        this.showHeaderTooltip = false;
        this.resizable = this.table.resizable;
    }
    isModeColumnFilterable(column) {
        return this.table.isColumnFiltersActive && this.table.isColumnFilterable(column);
    }
    setFilterIconHintVisible(visible) {
        if (this._columnFilterIcon) {
            this._columnFilterIcon.filterIconHintVisible.next(visible);
        }
    }
    ngAfterViewInit() {
        this.table.registerTableHeaders(this);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: OTableHeaderComponent, deps: [{ token: forwardRef(() => OTableBase) }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: OTableHeaderComponent, isStandalone: true, selector: "o-table-header", inputs: { column: "column", columnFilters: ["column-filters", "columnFilters"], showHeaderTooltip: ["show-header-tooltip", "showHeaderTooltip"] }, host: { listeners: { "mouseenter": "setFilterIconHintVisible(true)", "mouseleave": "setFilterIconHintVisible(false)" }, properties: { "class.o-table-header": "true" } }, viewQueries: [{ propertyName: "columnFilterIcon", first: true, predicate: ["columnFilterIcon"], descendants: true }, { propertyName: "matSortHeader", first: true, predicate: OMatSortHeader, descendants: true }], ngImport: i0, template: "@if (isModeColumnFilterable(column)) {\n  <o-table-header-column-filter-icon #columnFilterIcon [column]=\"column\" [column-filters]=\"columnFilters\">\n  </o-table-header-column-filter-icon>\n}\n\n@if (column.orderable) {\n  <span o-mat-sort-header [matTooltip]=\"showHeaderTooltip && !column.headerTooltip ? (column.title | oTranslate) :\n                  (column.headerTooltip && !column.headerTooltipIcon) ? (column.headerTooltip | oTranslate) : null\" matTooltipPosition=\"below\"\n    [matTooltipClass]=\"column.headerTooltipClass\">\n    {{ column.title | oTranslate }}\n    @if (column.headerTooltip && column.headerTooltipIcon) {\n      <mat-icon class=\"o-table-header-icon\" [matTooltip]=\"column.headerTooltip | oTranslate\"\n        matTooltipPosition=\"below\" [matTooltipClass]=\"column.headerTooltipClass\">\n        {{ column.headerTooltipIcon }}\n      </mat-icon>\n    }\n  </span>\n}\n\n@if (!column.orderable) {\n  <span class=\"header-title-container o-flex\" [matTooltip]=\"showHeaderTooltip && !column.headerTooltip ? (column.title | oTranslate) :\n                  (column.headerTooltip && !column.headerTooltipIcon) ? (column.headerTooltip | oTranslate) : null\" matTooltipPosition=\"below\"\n    [matTooltipClass]=\"column.headerTooltipClass\">\n    {{ column.title | oTranslate }}\n    @if (column.headerTooltip && column.headerTooltipIcon) {\n      <mat-icon class=\"o-table-header-icon\" [matTooltip]=\"column.headerTooltip | oTranslate\"\n        matTooltipPosition=\"below\" [matTooltipClass]=\"column.headerTooltipClass\">\n        {{ column.headerTooltipIcon }}\n      </mat-icon>\n    }\n  </span>\n}\n\n@if (resizable) {\n  <o-table-column-resizer [column]=\"column\"></o-table-column-resizer>\n}\n", styles: [".o-table-header{display:flex;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.o-table-header .o-table-header-icon{color:#0009;width:18px;height:18px;font-size:18px;cursor:pointer;vertical-align:middle;margin-left:8px;margin-right:8px}.o-table-header span[o-mat-sort-header]{flex:1;min-width:0}.o-table-header span[o-mat-sort-header]:not(:has(+.o-table-column-resizer)){padding-right:6px}\n"], dependencies: [{ kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i2.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "pipe", type: OTranslatePipe, name: "oTranslate" }, { kind: "component", type: OMatSortHeader, selector: "[o-mat-sort-header]", inputs: ["disabled"], exportAs: ["oMatSortHeader"] }, { kind: "component", type: OTableHeaderColumnFilterIconComponent, selector: "o-table-header-column-filter-icon", inputs: ["column", "column-filters"] }, { kind: "component", type: OTableColumnResizerComponent, selector: "o-table-column-resizer", inputs: ["column"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
__decorate([
    BooleanInputConverter(),
    __metadata("design:type", Boolean)
], OTableHeaderComponent.prototype, "showHeaderTooltip", void 0);
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: OTableHeaderComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [MatIconModule, MatTooltipModule, OTranslatePipe, OMatSortHeader, OTableHeaderColumnFilterIconComponent, OTableColumnResizerComponent], selector: 'o-table-header', inputs: DEFAULT_INPUTS_O_TABLE_HEADER, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, host: {
                        '[class.o-table-header]': 'true',
                        '(mouseenter)': 'setFilterIconHintVisible(true)',
                        '(mouseleave)': 'setFilterIconHintVisible(false)'
                    }, template: "@if (isModeColumnFilterable(column)) {\n  <o-table-header-column-filter-icon #columnFilterIcon [column]=\"column\" [column-filters]=\"columnFilters\">\n  </o-table-header-column-filter-icon>\n}\n\n@if (column.orderable) {\n  <span o-mat-sort-header [matTooltip]=\"showHeaderTooltip && !column.headerTooltip ? (column.title | oTranslate) :\n                  (column.headerTooltip && !column.headerTooltipIcon) ? (column.headerTooltip | oTranslate) : null\" matTooltipPosition=\"below\"\n    [matTooltipClass]=\"column.headerTooltipClass\">\n    {{ column.title | oTranslate }}\n    @if (column.headerTooltip && column.headerTooltipIcon) {\n      <mat-icon class=\"o-table-header-icon\" [matTooltip]=\"column.headerTooltip | oTranslate\"\n        matTooltipPosition=\"below\" [matTooltipClass]=\"column.headerTooltipClass\">\n        {{ column.headerTooltipIcon }}\n      </mat-icon>\n    }\n  </span>\n}\n\n@if (!column.orderable) {\n  <span class=\"header-title-container o-flex\" [matTooltip]=\"showHeaderTooltip && !column.headerTooltip ? (column.title | oTranslate) :\n                  (column.headerTooltip && !column.headerTooltipIcon) ? (column.headerTooltip | oTranslate) : null\" matTooltipPosition=\"below\"\n    [matTooltipClass]=\"column.headerTooltipClass\">\n    {{ column.title | oTranslate }}\n    @if (column.headerTooltip && column.headerTooltipIcon) {\n      <mat-icon class=\"o-table-header-icon\" [matTooltip]=\"column.headerTooltip | oTranslate\"\n        matTooltipPosition=\"below\" [matTooltipClass]=\"column.headerTooltipClass\">\n        {{ column.headerTooltipIcon }}\n      </mat-icon>\n    }\n  </span>\n}\n\n@if (resizable) {\n  <o-table-column-resizer [column]=\"column\"></o-table-column-resizer>\n}\n", styles: [".o-table-header{display:flex;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.o-table-header .o-table-header-icon{color:#0009;width:18px;height:18px;font-size:18px;cursor:pointer;vertical-align:middle;margin-left:8px;margin-right:8px}.o-table-header span[o-mat-sort-header]{flex:1;min-width:0}.o-table-header span[o-mat-sort-header]:not(:has(+.o-table-column-resizer)){padding-right:6px}\n"] }]
        }], ctorParameters: () => [{ type: i3.OTableBase, decorators: [{
                    type: Inject,
                    args: [forwardRef(() => OTableBase)]
                }] }], propDecorators: { columnFilterIcon: [{
                type: ViewChild,
                args: ['columnFilterIcon']
            }], matSortHeader: [{
                type: ViewChild,
                args: [OMatSortHeader]
            }], showHeaderTooltip: [] } });
//# sourceMappingURL=data:application/json;base64, 