import { SelectionModel } from '@angular/cdk/collections';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Inject, Injector, ViewChild } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
import { MatListModule, MatSelectionList } from '@angular/material/list';
import { OTranslatePipe } from '../../../../pipes/o-translate.pipe';
import { DialogService } from '../../../../services/dialog.service';
import * as i0 from "@angular/core";
import * as i1 from "@angular/material/dialog";
import * as i2 from "@angular/material/button";
import * as i3 from "@angular/material/list";
export class OLoadFilterDialogComponent {
    constructor(dialogRef, data, injector) {
        this.dialogRef = dialogRef;
        this.injector = injector;
        this.filters = [];
        this.onDelete = new EventEmitter();
        this.loadFilters(data);
        this.dialogService = this.injector.get(DialogService);
        try {
            this.cd = this.injector.get(ChangeDetectorRef);
        }
        catch (e) {
        }
    }
    ngOnInit() {
        this.filterList.selectedOptions = new SelectionModel(false);
    }
    loadFilters(filters) {
        this.filters = filters;
    }
    getSelectedFilterName() {
        const selected = this.filterList.selectedOptions.selected;
        return selected.length ? selected[0].value : void 0;
    }
    removeFilter(filterName) {
        this.dialogService.confirm('CONFIRM', 'TABLE.DIALOG.CONFIRM_REMOVE_FILTER').then(result => {
            if (result) {
                this.onDelete.emit(filterName);
                this.cd.detectChanges();
            }
        });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: OLoadFilterDialogComponent, deps: [{ token: i1.MatDialogRef }, { token: MAT_DIALOG_DATA }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: OLoadFilterDialogComponent, isStandalone: true, selector: "o-load-filter-dialog", viewQueries: [{ propertyName: "filterList", first: true, predicate: MatSelectionList, descendants: true, static: true }], ngImport: i0, template: "<span mat-dialog-title>{{ 'TABLE.BUTTONS.FILTER_LOAD' | oTranslate }}</span>\n<mat-dialog-content class=\"o-flex-column\">\n  <div mat-subheader>{{ 'TABLE.DIALOG.LOAD_FILTER' | oTranslate }}</div>\n  <mat-selection-list #filterList class=\"o-table-load-filter-dialog-list\">\n    @for (filter of filters ; track filter) {\n      <mat-list-option [value]=\"filter.name\" checkboxPosition=\"before\">\n        <span matListItemTitle class=\"o-table-load-filter-dialog-list-title\">{{ filter.name }}</span>\n        <span matListItemLine>{{ filter.description }}</span>\n      </mat-list-option>\n    }\n    @if (filters.length === 0) {\n      <mat-list-item>\n        <span class=\"empty-filter-list\">{{ 'TABLE.DIALOG.EMPTY_FILTER_LIST' | oTranslate }}</span>\n      </mat-list-item>\n    }\n  </mat-selection-list>\n</mat-dialog-content>\n\n<mat-dialog-actions align=\"end\">\n  <button type=\"button\" mat-stroked-button [disabled]=\"filterList.selectedOptions.selected.length!==1\"\n  (click)=\"removeFilter(filterList.selectedOptions.selected[0].value)\" class=\"o-button-danger\">{{ 'DELETE' | oTranslate }}</button>\n  <span class=\"o-flex\"></span>\n  <button type=\"button\" mat-stroked-button [mat-dialog-close]=\"false\" class=\"o-button-default cancel\">{{ 'CANCEL' | oTranslate }}</button>\n  <button type=\"button\" mat-stroked-button [mat-dialog-close]=\"true\" [disabled]=\"filterList.selectedOptions.selected.length!==1\"\n    class=\"o-button-primary\">\n    {{'TABLE.BUTTONS.APPLY' | oTranslate }}\n  </button>\n</mat-dialog-actions>\n", dependencies: [{ kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i2.MatButton, selector: "    button[mat-button], button[mat-raised-button], button[mat-flat-button],    button[mat-stroked-button]  ", exportAs: ["matButton"] }, { kind: "ngmodule", type: MatDialogModule }, { kind: "directive", type: i1.MatDialogClose, selector: "[mat-dialog-close], [matDialogClose]", inputs: ["aria-label", "type", "mat-dialog-close", "matDialogClose"], exportAs: ["matDialogClose"] }, { kind: "directive", type: i1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { kind: "directive", type: i1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "directive", type: i1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "ngmodule", type: MatListModule }, { kind: "component", type: i3.MatSelectionList, selector: "mat-selection-list", inputs: ["color", "compareWith", "multiple", "hideSingleSelectionIndicator", "disabled"], outputs: ["selectionChange"], exportAs: ["matSelectionList"] }, { kind: "component", type: i3.MatListItem, selector: "mat-list-item, a[mat-list-item], button[mat-list-item]", inputs: ["activated"], exportAs: ["matListItem"] }, { kind: "component", type: i3.MatListOption, selector: "mat-list-option", inputs: ["togglePosition", "checkboxPosition", "color", "value", "selected"], outputs: ["selectedChange"], exportAs: ["matListOption"] }, { kind: "directive", type: i3.MatListSubheaderCssMatStyler, selector: "[mat-subheader], [matSubheader]" }, { kind: "directive", type: i3.MatListItemLine, selector: "[matListItemLine]" }, { kind: "directive", type: i3.MatListItemTitle, selector: "[matListItemTitle]" }, { kind: "pipe", type: OTranslatePipe, name: "oTranslate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: OLoadFilterDialogComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [MatButtonModule, MatDialogModule, MatListModule, OTranslatePipe], selector: 'o-load-filter-dialog', changeDetection: ChangeDetectionStrategy.OnPush, template: "<span mat-dialog-title>{{ 'TABLE.BUTTONS.FILTER_LOAD' | oTranslate }}</span>\n<mat-dialog-content class=\"o-flex-column\">\n  <div mat-subheader>{{ 'TABLE.DIALOG.LOAD_FILTER' | oTranslate }}</div>\n  <mat-selection-list #filterList class=\"o-table-load-filter-dialog-list\">\n    @for (filter of filters ; track filter) {\n      <mat-list-option [value]=\"filter.name\" checkboxPosition=\"before\">\n        <span matListItemTitle class=\"o-table-load-filter-dialog-list-title\">{{ filter.name }}</span>\n        <span matListItemLine>{{ filter.description }}</span>\n      </mat-list-option>\n    }\n    @if (filters.length === 0) {\n      <mat-list-item>\n        <span class=\"empty-filter-list\">{{ 'TABLE.DIALOG.EMPTY_FILTER_LIST' | oTranslate }}</span>\n      </mat-list-item>\n    }\n  </mat-selection-list>\n</mat-dialog-content>\n\n<mat-dialog-actions align=\"end\">\n  <button type=\"button\" mat-stroked-button [disabled]=\"filterList.selectedOptions.selected.length!==1\"\n  (click)=\"removeFilter(filterList.selectedOptions.selected[0].value)\" class=\"o-button-danger\">{{ 'DELETE' | oTranslate }}</button>\n  <span class=\"o-flex\"></span>\n  <button type=\"button\" mat-stroked-button [mat-dialog-close]=\"false\" class=\"o-button-default cancel\">{{ 'CANCEL' | oTranslate }}</button>\n  <button type=\"button\" mat-stroked-button [mat-dialog-close]=\"true\" [disabled]=\"filterList.selectedOptions.selected.length!==1\"\n    class=\"o-button-primary\">\n    {{'TABLE.BUTTONS.APPLY' | oTranslate }}\n  </button>\n</mat-dialog-actions>\n" }]
        }], ctorParameters: () => [{ type: i1.MatDialogRef }, { type: undefined, decorators: [{
                    type: Inject,
                    args: [MAT_DIALOG_DATA]
                }] }, { type: i0.Injector }], propDecorators: { filterList: [{
                type: ViewChild,
                args: [MatSelectionList, { static: true }]
            }] } });
//# sourceMappingURL=data:application/json;base64, 