import { Component, ViewEncapsulation } from '@angular/core';
import { MAT_SELECT_CONFIG } from '@angular/material/select';
import { CommonFilterService } from './../common-filter/common-filter.service';
import { CommonFilterComponent } from './../common-filter/common-filter.component';
import { AxExpTextList } from '../../enlighten-lib/ax-expression/ax-exp-text-list';
import { AxOperator } from '../../enlighten-lib/filters/ax-operator';
import * as i0 from "@angular/core";
import * as i1 from "./../common-filter/common-filter.service";
import * as i2 from "@angular/material/form-field";
import * as i3 from "@angular/material/select";
import * as i4 from "@angular/material/tooltip";
import * as i5 from "@angular/forms";
import * as i6 from "../../axo-search-bar/axo-search-bar.component";
import * as i7 from "@angular/common";
import * as i8 from "@angular/material/core";
import * as i9 from "../filter-footer/filter-footer.component";
import * as i10 from "@angular/material/icon";
function ReferenceListFilterComponent_ng_container_5_mat_option_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "mat-option", 10, 11);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const series_r2 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵproperty("matTooltip", series_r2.label)("value", series_r2.id);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1(" ", series_r2.title, " ");
} }
function ReferenceListFilterComponent_ng_container_5_mat_option_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "mat-option", 10, 11);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const series_r2 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵproperty("matTooltip", series_r2)("value", series_r2);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1(" ", series_r2, " ");
} }
function ReferenceListFilterComponent_ng_container_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, ReferenceListFilterComponent_ng_container_5_mat_option_1_Template, 3, 3, "mat-option", 9);
    i0.ɵɵtemplate(2, ReferenceListFilterComponent_ng_container_5_mat_option_2_Template, 3, 3, "mat-option", 9);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r1.screenType === ctx_r1.screenTypes.dataViewBuilder || ctx_r1.screenType === ctx_r1.screenTypes.dataView);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r1.screenType !== ctx_r1.screenTypes.dataViewBuilder && ctx_r1.screenType !== ctx_r1.screenTypes.dataView);
} }
export class ReferenceListFilterComponent extends CommonFilterComponent {
    constructor(_commonFilterService) {
        super(_commonFilterService);
    }
    /**
     * ngOnChanges use to change the current page object
     */
    // eslint-disable-next-line @angular-eslint/use-lifecycle-interface
    ngOnChanges(changes) {
        super.ngOnChanges(changes);
    }
    /**
     * On init life cycle hook
     */
    ngOnInit() {
        super.ngOnInit();
        this.setDisplayValue();
        this.expression.comparisonOperator = new AxOperator({ text: 'In', value: 'IN' });
        this.stringOperators = AxOperator.getStringOperator();
        this.getSeriesList();
    }
    /**
     * Get called after view render
     */
    ngAfterViewInit() {
        super.ngAfterViewInit();
    }
    /**
     * THis will reset Filter value.
     */
    resetFilter() {
        this.expressionValue = new AxExpTextList(this.defaultValue);
        this.expression.value = this.expressionValue;
    }
    /**
     * Set Expression value
     *
     * @overridden
     */
    setExpressionValue() {
        this.expressionValue = this.expression.value ? this.expression.value : new AxExpTextList();
    }
    /**
     * This function clear the filter value.
     *
     * @overridden
     */
    clearValue() {
        this.expressionValue = new AxExpTextList();
        this.expression.value = this.expressionValue;
    }
    /**
     * Set Default Value
     *
     * @overridden
     */
    setDefaultValue() {
        this.defaultValue = new AxExpTextList(this.expressionValue);
    }
    /**
     * Apply parent value parent value change
     *
     *
     */
    applyParentFilter() {
        this.expressionValue.value = [];
        this.pageIndex = 0;
        this.seriesList = [];
        this.getSeriesList();
    }
    /**
     * Clear Values
     *
     */
    clearAllValue() {
        this.expressionValue.value = [];
        this.filterValueChanged();
        this.applyFilterEvent.emit();
    }
    setDisplayValue() {
        this.addEllipsesToDisplayValue(this.expression.field.label);
    }
}
ReferenceListFilterComponent.ɵfac = function ReferenceListFilterComponent_Factory(t) { return new (t || ReferenceListFilterComponent)(i0.ɵɵdirectiveInject(i1.CommonFilterService)); };
ReferenceListFilterComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ReferenceListFilterComponent, selectors: [["lib-reference-list-filter"]], features: [i0.ɵɵProvidersFeature([
            {
                provide: MAT_SELECT_CONFIG,
                useValue: { overlayPanelClass: 'custom-multi-select-overlay-panel' },
            },
        ]), i0.ɵɵInheritDefinitionFeature, i0.ɵɵNgOnChangesFeature], decls: 9, vars: 7, consts: [[1, "fields", "flex"], ["appearance", "none"], ["panelClass", "multi-select-panel", "multiple", "", 1, "multi-select-dropdown", 3, "placeholder", "matTooltip", "ngModel", "ngModelChange", "selectionChange"], ["multiSelectList", ""], [3, "searchText", "searchTextChanged"], [4, "ngFor", "ngForOf"], [1, "hidden"], [3, "isFilterValue", "clearAllValue", "applyFilter", "closeFilter"], [1, "down-arrow", 3, "svgIcon", "click"], ["class", "radio-button  filter-mat-option", 3, "matTooltip", "value", 4, "ngIf"], [1, "radio-button", "filter-mat-option", 3, "matTooltip", "value"], ["matOption", ""]], template: function ReferenceListFilterComponent_Template(rf, ctx) { if (rf & 1) {
        const _r9 = i0.ɵɵgetCurrentView();
        i0.ɵɵelementStart(0, "div", 0);
        i0.ɵɵelementStart(1, "mat-form-field", 1);
        i0.ɵɵelementStart(2, "mat-select", 2, 3);
        i0.ɵɵlistener("ngModelChange", function ReferenceListFilterComponent_Template_mat_select_ngModelChange_2_listener($event) { return ctx.expressionValue.value = $event; })("selectionChange", function ReferenceListFilterComponent_Template_mat_select_selectionChange_2_listener() { return ctx.filterValueChanged(); });
        i0.ɵɵelementStart(4, "axo-search-bar", 4);
        i0.ɵɵlistener("searchTextChanged", function ReferenceListFilterComponent_Template_axo_search_bar_searchTextChanged_4_listener($event) { return ctx.searchTextChanged($event); });
        i0.ɵɵelementEnd();
        i0.ɵɵtemplate(5, ReferenceListFilterComponent_ng_container_5_Template, 3, 2, "ng-container", 5);
        i0.ɵɵelement(6, "mat-option", 6);
        i0.ɵɵelementStart(7, "lib-filter-footer", 7);
        i0.ɵɵlistener("clearAllValue", function ReferenceListFilterComponent_Template_lib_filter_footer_clearAllValue_7_listener() { return ctx.clearAllValue(); })("applyFilter", function ReferenceListFilterComponent_Template_lib_filter_footer_applyFilter_7_listener() { return ctx.applyFilter(); })("closeFilter", function ReferenceListFilterComponent_Template_lib_filter_footer_closeFilter_7_listener() { i0.ɵɵrestoreView(_r9); const _r0 = i0.ɵɵreference(3); return _r0.close(); });
        i0.ɵɵelementEnd();
        i0.ɵɵelementEnd();
        i0.ɵɵelementEnd();
        i0.ɵɵelementStart(8, "mat-icon", 8);
        i0.ɵɵlistener("click", function ReferenceListFilterComponent_Template_mat_icon_click_8_listener() { i0.ɵɵrestoreView(_r9); const _r0 = i0.ɵɵreference(3); return _r0.open(); });
        i0.ɵɵelementEnd();
        i0.ɵɵelementEnd();
    } if (rf & 2) {
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("placeholder", ctx.displayValue)("matTooltip", ctx.toolTipValue)("ngModel", ctx.expressionValue.value);
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("searchText", ctx.searchText);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngForOf", ctx.seriesList);
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("isFilterValue", ctx.seriesList && ctx.seriesList.length);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("svgIcon", "axo_arrow");
    } }, directives: [i2.MatFormField, i3.MatSelect, i4.MatTooltip, i5.NgControlStatus, i5.NgModel, i6.AxoSearchBarComponent, i7.NgForOf, i8.MatOption, i9.FilterFooterComponent, i10.MatIcon, i7.NgIf], styles: [".custom-multi-select-overlay-panel .calender-filter-option{justify-content:space-between;display:flex;position:sticky;bottom:0;background:#fff}.custom-multi-select-overlay-panel .calender-filter{position:relative;top:13px;padding:2px 10px 1px;width:400px}.custom-multi-select-overlay-panel .apply-filters{color:#7963ed!important;font-size:11px!important;font-weight:700;vertical-align:middle}.custom-multi-select-overlay-panel .apply-clear-button{cursor:pointer}\n"], encapsulation: 2 });
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ReferenceListFilterComponent, [{
        type: Component,
        args: [{ selector: 'lib-reference-list-filter', encapsulation: ViewEncapsulation.None, providers: [
                    {
                        provide: MAT_SELECT_CONFIG,
                        useValue: { overlayPanelClass: 'custom-multi-select-overlay-panel' },
                    },
                ], template: "<div class=\"fields flex\" >\n  <mat-form-field appearance=\"none\">\n    <mat-select class=\"multi-select-dropdown\"\n    [placeholder]=\"displayValue\"\n    [matTooltip]=\"toolTipValue\"\n    [(ngModel)]=\"expressionValue.value\"\n    (selectionChange)=\"filterValueChanged()\"\n    panelClass=\"multi-select-panel\"\n    multiple\n    #multiSelectList >\n    <!-- Search bar for filter value   -->\n    <axo-search-bar [searchText]=\"searchText\" (searchTextChanged)=\"searchTextChanged($event)\"></axo-search-bar>\n\n    <ng-container *ngFor=\"let series of seriesList\">\n      <mat-option *ngIf=\"screenType === screenTypes.dataViewBuilder || screenType === screenTypes.dataView\"  class=\"radio-button  filter-mat-option\" [matTooltip]=\"series.label\"\n          #matOption\n          [value]=\"series.id\">\n          {{series.title}}\n      </mat-option>\n       <!-- For Enlighten reporting -->\n       <mat-option *ngIf=\"this.screenType !== screenTypes.dataViewBuilder && this.screenType !== screenTypes.dataView\" class=\"radio-button  filter-mat-option\" [matTooltip]=\"series\" [value]=\"series\"\n       #matOption >\n        {{series}}\n      </mat-option>\n    </ng-container>\n    <!-- this option is for opening the dropdown even if series is empty -->\n    <mat-option class=\"hidden\"></mat-option>\n    <!-- Filter dropdown footer -->\n    <lib-filter-footer\n      [isFilterValue]=\"(seriesList && seriesList.length)\"\n      (clearAllValue)=\"clearAllValue()\"\n      (applyFilter)=\"applyFilter()\"\n      (closeFilter)=\"multiSelectList.close()\"\n      >\n    </lib-filter-footer>\n  </mat-select>\n \n  </mat-form-field>\n  <mat-icon class=\"down-arrow\" [svgIcon]=\"'axo_arrow'\" (click)=\"multiSelectList.open()\"></mat-icon>\n  </div>\n", styles: [".custom-multi-select-overlay-panel .calender-filter-option{justify-content:space-between;display:flex;position:sticky;bottom:0;background:#fff}.custom-multi-select-overlay-panel .calender-filter{position:relative;top:13px;padding:2px 10px 1px;width:400px}.custom-multi-select-overlay-panel .apply-filters{color:#7963ed!important;font-size:11px!important;font-weight:700;vertical-align:middle}.custom-multi-select-overlay-panel .apply-clear-button{cursor:pointer}\n"] }]
    }], function () { return [{ type: i1.CommonFilterService }]; }, null); })();
//# sourceMappingURL=data:application/json;base64, 