import * as i0 from '@angular/core';
import { Injectable, ViewChildren, ChangeDetectionStrategy, ViewEncapsulation, Component, inject, Injector, Directive, signal, DestroyRef, ViewChild, Inject, booleanAttribute, Input, ContentChildren, EventEmitter, Output, forwardRef, computed, NgModule } from '@angular/core';
import * as i1$1 from '@fundamental-ngx/core/dialog';
import { DialogComponent, DialogHeaderComponent, DialogBodyComponent, DialogFooterComponent, DialogService } from '@fundamental-ngx/core/dialog';
import * as i1 from '@fundamental-ngx/platform/form';
import { FormGeneratorComponent, BaseDynamicFormGeneratorControl, PlatformMultiInputComponent, SelectComponent, FormGeneratorService } from '@fundamental-ngx/platform/form';
import { take, observeOn, startWith as startWith$1, takeUntil, map } from 'rxjs/operators';
import { FdDate } from '@fundamental-ngx/core/datetime';
import { isSelectItem, FDP_PRESET_MANAGED_COMPONENT } from '@fundamental-ngx/platform/shared';
import * as i1$3 from '@fundamental-ngx/platform/table';
import { FilterableColumnDataType, getFilterStrategiesBasedOnDataType, FILTER_STRATEGY, ArrayTableDataProvider, TableDataSource, ResetButtonComponent, TableComponent, TableToolbarComponent, TableToolbarActionsComponent, TableColumnComponent, RESETTABLE_TOKEN, FilterType } from '@fundamental-ngx/platform/table';
import { selectStrategy, TemplateDirective } from '@fundamental-ngx/cdk/utils';
import { CdkScrollable } from '@angular/cdk/overlay';
import * as i1$2 from '@angular/forms';
import { FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
import { BarLeftDirective, BarElementDirective, ButtonBarComponent, BarRightDirective } from '@fundamental-ngx/core/bar';
import { BusyIndicatorComponent } from '@fundamental-ngx/core/busy-indicator';
import { ButtonComponent } from '@fundamental-ngx/core/button';
import { LayoutGridComponent, LayoutGridRowDirective, LayoutGridColDirective } from '@fundamental-ngx/core/layout-grid';
import { ScrollbarDirective } from '@fundamental-ngx/core/scrollbar';
import { TitleComponent } from '@fundamental-ngx/core/title';
import { resolveTranslationSyncFn, FdTranslatePipe, TranslationResolver, FD_LANGUAGE } from '@fundamental-ngx/i18n';
import * as i2 from 'rxjs';
import { asyncScheduler, firstValueFrom, BehaviorSubject, startWith, Subscription, Subject, filter, debounceTime } from 'rxjs';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { IconComponent } from '@fundamental-ngx/core/icon';
import { TableInitialStateDirective, FdpCellDef, FdpTableCell, TableDataSourceDirective, TableHeaderResizerDirective } from '@fundamental-ngx/platform/table-helpers';
import { NgTemplateOutlet } from '@angular/common';
import { ToolbarComponent, ToolbarSeparatorComponent, ToolbarSpacerDirective, ToolbarItemDirective } from '@fundamental-ngx/core/toolbar';
import { SearchFieldComponent } from '@fundamental-ngx/platform/search-field';

class SmartFilterBarService {
    /** @hidden */
    constructor(_fgService) {
        this._fgService = _fgService;
        /** @hidden */
        this._customFilterConditions = new Map();
    }
    /**
     * Adds custom filter type to the smart filter bar.
     * @param options Configuration options.
     * @returns true if component was added successfully.
     */
    addCustomFilter(options) {
        if (!options.conditionComponent && options.rendererComponent) {
            options.conditionComponent = options.rendererComponent;
        }
        if (!options.conditionComponent) {
            return false;
        }
        const result = this._fgService.addComponent(options.conditionComponent, options.types);
        if (result) {
            this._customFilterConditions.set(options.conditionComponent, options);
        }
        if (result && options.rendererComponent) {
            this._fgService.addComponent(options.rendererComponent, options.types.map((t) => `${t}-renderer`));
        }
        return result;
    }
    /**
     * Returns provided configuration object of the custom filter.
     * @param type Filter type.
     * @returns Configuration object.
     */
    getCustomFilterConfiguration(type) {
        const componentDefinition = this._fgService.getComponentDefinitionByType(type);
        if (!componentDefinition) {
            return undefined;
        }
        return this._customFilterConditions.get(componentDefinition.component);
    }
    /**
     * Returns applicable condition options of the filter.
     * @param type Filter type.
     * @param dataType Filter data type.
     * @returns Array of applicable condition options.
     */
    getApplicableFilterConditions(type, dataType = FilterableColumnDataType.STRING) {
        const componentDefinition = this._fgService.getComponentDefinitionByType(type);
        const defaultConditions = getFilterStrategiesBasedOnDataType(dataType);
        if (!componentDefinition) {
            return defaultConditions;
        }
        const filterDefinition = this._customFilterConditions.get(componentDefinition.component);
        return filterDefinition?.filterStrategies || defaultConditions;
    }
    /** @hidden */
    async getDisplayValue(condition, filterType) {
        const configuration = this.getCustomFilterConfiguration(filterType);
        if (configuration?.valueRenderer) {
            const obj = configuration?.valueRenderer(condition);
            const strategy = selectStrategy(obj);
            let returnValue;
            await strategy.createSubscription(obj, (value) => {
                returnValue = value;
            });
            return returnValue;
        }
        const value1 = this._normalizeValue(condition.value);
        const value2 = this._normalizeValue(condition.value2);
        switch (condition.operator) {
            case 'equalTo':
                return `=${value1}`;
            case 'contains':
                return `*${value1}*`;
            case 'between':
                return `${value1}...${value2}`;
            case 'beginsWith':
                return `${value1}*`;
            case 'endsWith':
                return `*${value1}`;
            case 'greaterThan':
                return `>${value1}`;
            case 'greaterThanOrEqualTo':
                return `>=${value1}`;
            case 'lessThan':
                return `<${value1}`;
            case 'lessThanOrEqualTo':
                return `<=${value1}`;
            case 'after':
                return `>${value1}`;
            case 'onOrAfter':
                return `>=${value1}`;
            case 'before':
                return `<${value1}`;
            case 'beforeOrOn':
                return `<=${value1}`;
            default:
                return `${value1}`;
        }
    }
    /**
     * Method for normalizing generated conditions to display in human-readable format.
     * @returns Formatted array of conditions.
     * @param formItem
     * @param conditions
     */
    async normalizeConditions(formItem, conditions) {
        const normalizedConditions = [];
        for (const condition of conditions) {
            const newCondition = Object.assign({}, condition);
            newCondition.displayValue = await this.getDisplayValue(newCondition, formItem.guiOptions?.additionalData.type);
            normalizedConditions.push(newCondition);
        }
        return normalizedConditions;
    }
    /**
     * Returns formatted condition variants.
     */
    async getConditionFieldSelectedVariants(formItem, conditions) {
        return (await this.normalizeConditions(formItem, conditions)).map((c) => {
            if (isSelectItem(c)) {
                return c;
            }
            const condition = {
                label: c.displayValue,
                value: c
            };
            return condition;
        });
    }
    /**
     * Transforms collection filter into smart filter bar condition.
     */
    transformCollectionFilter(filterGroup) {
        return filterGroup.filters.map((filter) => {
            const condition = {
                operator: filter.strategy,
                value: filter.value,
                value2: filter.value2
            };
            return condition;
        });
    }
    /**
     * @hidden
     * Normalizes condition value.
     * @param value
     * @returns
     */
    _normalizeValue(value) {
        if (Array.isArray(value)) {
            return value.map((v) => this._normalizeValue(v)).join(', ');
        }
        if (isSelectItem(value)) {
            return value.label;
        }
        if (value instanceof FdDate) {
            return value.toDateString();
        }
        return value;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SmartFilterBarService, deps: [{ token: i1.FormGeneratorService }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SmartFilterBarService }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SmartFilterBarService, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i1.FormGeneratorService }] });

/** @hidden */
function getSelectItemValue(item) {
    if (Array.isArray(item)) {
        item = item.map((i) => getSelectItemValue(i));
    }
    return isSelectItem(item) ? item.value : item;
}

class SmartFilterBarConditionsDialogComponent {
    /** @hidden */
    constructor(_dialogRef, _cdr, _smartFilterBarService) {
        this._dialogRef = _dialogRef;
        this._cdr = _cdr;
        this._smartFilterBarService = _smartFilterBarService;
        /** Available condition operator options. */
        this.conditionOperatorOptions = [];
        /** @hidden */
        this._formItems = [];
        /** @hidden */
        this.loaded = false;
        /** @hidden */
        this._conditionLabelKeys = {
            contains: 'filterConditionContains',
            equalTo: 'filterConditionEqualTo',
            between: 'filterConditionBetween',
            beginsWith: 'filterConditionBeginsWith',
            endsWith: 'filterConditionEndsWith',
            lessThan: 'filterConditionLessThan',
            lessThanOrEqualTo: 'filterConditionLessThanOrEqualTo',
            greaterThan: 'filterConditionGreaterThan',
            greaterThanOrEqualTo: 'filterConditionGreaterThanOrEqualTo',
            after: 'filterConditionAfter',
            onOrAfter: 'filterConditionOnOrAfter',
            before: 'filterConditionBefore',
            beforeOrOn: 'filterConditionBeforeOrOn'
        };
        /** @hidden */
        this._submittedForms = [];
        /** @hidden */
        this.resolveTranslation = resolveTranslationSyncFn();
        this._init();
    }
    /**
     * Adds empty condition.
     */
    addCondition() {
        this._formItems.push(this._generateFormGeneratorItems());
    }
    /**
     * Removes condition at defined index
     * @param index Index of the condition in the array.
     */
    removeCondition(index) {
        this._formItems.splice(index, 1);
        if (this._formItems.length === 0) {
            this.addCondition();
        }
    }
    /**
     * Submits all condition forms.
     */
    applyConditions() {
        this._cdr.detectChanges();
        this._submittedForms = [];
        this.formGenerators.toArray().forEach((formGenerator) => formGenerator.submit());
    }
    /**
     * @hidden
     * Callback function when form generator form has been submitted.
     * Will close dialog in case if all forms are valid.
     * @param form Form generator form value.
     */
    _onFormSubmitted(form) {
        this._submittedForms.push(form);
        if (this._submittedForms.length !== this.formGenerators.length) {
            return;
        }
        const formsResult = this._submittedForms.map((f) => {
            f.value = f.value1 !== undefined ? f.value1 : f.value;
            return f;
        });
        this._dialogRef.close(formsResult.filter((c) => c.value !== undefined && c.value !== null));
    }
    /** @hidden */
    _cancel() {
        this._dialogRef.dismiss();
    }
    /** @hidden */
    _init() {
        this.config = this._dialogRef.data;
        this.conditionOperatorOptions = this._getApplicableConditionOperators();
        this._addExistingConditions(getSelectItemValue(this.config.conditions));
        if (this.config.conditions.length === 0) {
            // Add first empty condition
            this.addCondition();
        }
        this.loaded = true;
        this._cdr.markForCheck();
    }
    /**
     * @hidden
     * Returns applicable condition options of the filter.
     * @returns Array of applicable condition options.
     */
    _getApplicableConditionOperators() {
        const strategy = this._smartFilterBarService.getApplicableFilterConditions(this.config.filterType, this.config.dataType);
        const labelsConfig = { ...this._conditionLabelKeys };
        for (const strategyItem of Object.keys(this._conditionLabelKeys)) {
            const translationKey = 'platformSmartFilterBar.' + labelsConfig[strategyItem];
            labelsConfig[strategyItem] = this.resolveTranslation(translationKey);
        }
        return strategy.map((s) => ({
            label: labelsConfig[s],
            value: s
        }));
    }
    /**
     * Transforms filter conditions into form generator form items array.
     * @param conditions existing smart filter bar filter conditions.
     */
    _addExistingConditions(conditions) {
        conditions.forEach((condition) => {
            const conditionGroup = this._generateFormGeneratorItems(condition);
            this._formItems.push(conditionGroup);
        });
    }
    /** @hidden */
    _generateFormGeneratorItems(condition) {
        return [
            {
                name: 'operator',
                message: 'operator',
                default: condition
                    ? this.conditionOperatorOptions.find((o) => o.value === condition.operator)?.value
                    : this.conditionOperatorOptions[0].value,
                type: 'select',
                choices: this.conditionOperatorOptions,
                required: true,
                guiOptions: {
                    inline: false,
                    column: 1,
                    noLabelLayout: true
                }
            },
            {
                name: 'value',
                message: 'value',
                default: condition?.value,
                type: this.config.filterType,
                choices: this.config.choices,
                placeholder: this.resolveTranslation('platformSmartFilterBar.filterConditionValuePlaceholder'),
                controlType: this.config.controlType,
                when: (value) => value.operator !== FILTER_STRATEGY.BETWEEN,
                onchange: (value, _, control) => {
                    control.parent?.get('value1')?.setValue(value, { emitEvent: false });
                },
                guiOptions: {
                    inline: false,
                    column: 2,
                    noLabelLayout: true
                }
            },
            {
                name: 'value1',
                message: 'value1',
                default: condition?.value,
                type: this.config.filterType,
                choices: this.config.choices,
                placeholder: this.resolveTranslation('platformSmartFilterBar.filterConditionValueFromPlaceholder'),
                controlType: this.config.controlType,
                when: (value) => value.operator === FILTER_STRATEGY.BETWEEN,
                onchange: (value, _, control) => {
                    control.parent?.get('value')?.setValue(value, { emitEvent: false });
                },
                guiOptions: {
                    inline: false,
                    column: 2,
                    noLabelLayout: true
                }
            },
            {
                name: 'value2',
                message: 'value2',
                default: condition?.value2,
                type: this.config.filterType,
                choices: this.config.choices,
                placeholder: this.resolveTranslation('platformSmartFilterBar.filterConditionValueToPlaceholder'),
                required: true,
                controlType: this.config.controlType,
                when: (value) => value?.operator === FILTER_STRATEGY.BETWEEN,
                guiOptions: {
                    inline: false,
                    column: 3,
                    noLabelLayout: true
                }
            }
        ];
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SmartFilterBarConditionsDialogComponent, deps: [{ token: i1$1.DialogRef }, { token: i0.ChangeDetectorRef }, { token: SmartFilterBarService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.0", type: SmartFilterBarConditionsDialogComponent, isStandalone: true, selector: "fdp-smart-filter-bar-conditions-dialog", viewQueries: [{ propertyName: "formGenerators", predicate: FormGeneratorComponent, descendants: true }], ngImport: i0, template: "<fd-dialog class=\"fdp-smart-filter-bar__conditions-dialog\">\n    <fd-dialog-header>\n        <ng-template fdkTemplate=\"header\">\n            <div fd-bar-left>\n                <fd-bar-element>\n                    <h4 [headerSize]=\"4\" fd-title>{{ config.header }}</h4>\n                </fd-bar-element>\n            </div>\n        </ng-template>\n    </fd-dialog-header>\n    <fd-dialog-body>\n        @if (loaded) {\n            <form>\n                @for (condition of _formItems; track condition; let i = $index) {\n                    <fd-layout-grid>\n                        <div fdLayoutGridRow>\n                            <div colGrow fdLayoutGridCol>\n                                <!-- wrapping \"formSubmitted\" event payload as any, because it's type is more generic than we're expecting -->\n                                <fdp-form-generator\n                                    (formSubmitted)=\"_onFormSubmitted($any($event))\"\n                                    [formItems]=\"condition\"\n                                    [unifiedLayout]=\"false\"\n                                    columnLayout=\"XL3-L3-M3-S3\"\n                                    [noAdditionalContent]=\"true\"\n                                ></fdp-form-generator>\n                            </div>\n                            <div class=\"fdp-smart-filter-bar__actions-column\" colGrow fdLayoutGridCol>\n                                <button\n                                    fd-button\n                                    (click)=\"removeCondition(i)\"\n                                    fdType=\"transparent\"\n                                    glyph=\"decline\"\n                                    [title]=\"\n                                        'platformSmartFilterBar.defineConditionsRemoveConditionButtonTitle'\n                                            | fdTranslate\n                                    \"\n                                    type=\"button\"\n                                ></button>\n                            </div>\n                        </div>\n                    </fd-layout-grid>\n                }\n                <fd-layout-grid>\n                    <div fdLayoutGridRow>\n                        <div colGrow fdLayoutGridCol>&nbsp;</div>\n                        <div class=\"fdp-smart-filter-bar__actions-column\" fdLayoutGridCol>\n                            <button\n                                fd-button\n                                (click)=\"addCondition()\"\n                                [label]=\"'platformSmartFilterBar.defineConditionsAddConditionButtonLabel' | fdTranslate\"\n                            ></button>\n                        </div>\n                    </div>\n                </fd-layout-grid>\n            </form>\n        } @else {\n            <div [style.text-align]=\"'center'\" [style.margin.rem]=\"1\">\n                <fd-busy-indicator [loading]=\"true\"></fd-busy-indicator>\n            </div>\n        }\n    </fd-dialog-body>\n    <fd-dialog-footer>\n        <fd-button-bar\n            (click)=\"applyConditions()\"\n            fdType=\"emphasized\"\n            [label]=\"'platformSmartFilterBar.defineConditionsSubmitButtonLabel' | fdTranslate\"\n        >\n        </fd-button-bar>\n        <fd-button-bar\n            (click)=\"_cancel()\"\n            fdType=\"transparent\"\n            [label]=\"'platformSmartFilterBar.defineConditionsCancelButton' | fdTranslate\"\n        ></fd-button-bar>\n    </fd-dialog-footer>\n</fd-dialog>\n", dependencies: [{ kind: "component", type: DialogComponent, selector: "fd-dialog", inputs: ["class", "dialogRef", "dialogConfig"] }, { kind: "component", type: DialogHeaderComponent, selector: "fd-dialog-header" }, { kind: "directive", type: TemplateDirective, selector: "[fdkTemplate]", inputs: ["fdkTemplate"] }, { kind: "directive", type: BarLeftDirective, selector: "[fd-bar-left]" }, { kind: "directive", type: BarElementDirective, selector: "fd-bar-element", inputs: ["fullWidth"] }, { kind: "component", type: TitleComponent, selector: "[fd-title], [fdTitle]", inputs: ["headerSize", "wrap"], exportAs: ["fd-title"] }, { kind: "component", type: DialogBodyComponent, selector: "fd-dialog-body", inputs: ["disablePaddings"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$2.NgForm, selector: "form:not([ngNoForm]):not([formGroup]):not([formArray]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: LayoutGridComponent, selector: "fd-layout-grid, [fdLayoutGrid]", inputs: ["noGap", "noHorizontalGap", "noVerticalGap"] }, { kind: "directive", type: LayoutGridRowDirective, selector: "[fd-layout-grid-row], [fdLayoutGridRow]" }, { kind: "directive", type: LayoutGridColDirective, selector: "[fd-layout-grid-col], [fdLayoutGridCol]", inputs: ["fdLayoutGridCol", "colGrow", "colMd", "colLg", "colXl", "colOffset", "colOffsetMd", "colOffsetLg", "colOffsetXl"] }, { kind: "component", type: FormGeneratorComponent, selector: "fdp-form-generator", inputs: ["formName", "formItems", "mainTitle", "hideMainTItle", "hint", "columnLayout", "labelColumnLayout", "fieldColumnLayout", "gapColumnLayout", "unifiedLayout", "inlineColumnLayout", "noAdditionalContent"], outputs: ["formCreated", "formSubmitted", "formSubmittedStatus"] }, { kind: "component", type: ButtonComponent, selector: "button[fd-button], a[fd-button], span[fd-button]", inputs: ["id"], exportAs: ["fd-button"] }, { kind: "component", type: DialogFooterComponent, selector: "fd-dialog-footer" }, { kind: "component", type: ButtonBarComponent, selector: "fd-button-bar", inputs: ["fullWidth", "fdType", "title", "ariaLabelledby", "id"] }, { kind: "component", type: BusyIndicatorComponent, selector: "fd-busy-indicator", inputs: ["loading", "size", "block", "ariaLabel", "ariaValueText", "title", "label", "ariaLive"] }, { kind: "pipe", type: FdTranslatePipe, name: "fdTranslate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SmartFilterBarConditionsDialogComponent, decorators: [{
            type: Component,
            args: [{ selector: 'fdp-smart-filter-bar-conditions-dialog', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, imports: [
                        DialogComponent,
                        DialogHeaderComponent,
                        TemplateDirective,
                        BarLeftDirective,
                        BarElementDirective,
                        TitleComponent,
                        CdkScrollable,
                        ScrollbarDirective,
                        DialogBodyComponent,
                        FormsModule,
                        LayoutGridComponent,
                        LayoutGridRowDirective,
                        LayoutGridColDirective,
                        FormGeneratorComponent,
                        ButtonComponent,
                        DialogFooterComponent,
                        ButtonBarComponent,
                        BusyIndicatorComponent,
                        FdTranslatePipe
                    ], template: "<fd-dialog class=\"fdp-smart-filter-bar__conditions-dialog\">\n    <fd-dialog-header>\n        <ng-template fdkTemplate=\"header\">\n            <div fd-bar-left>\n                <fd-bar-element>\n                    <h4 [headerSize]=\"4\" fd-title>{{ config.header }}</h4>\n                </fd-bar-element>\n            </div>\n        </ng-template>\n    </fd-dialog-header>\n    <fd-dialog-body>\n        @if (loaded) {\n            <form>\n                @for (condition of _formItems; track condition; let i = $index) {\n                    <fd-layout-grid>\n                        <div fdLayoutGridRow>\n                            <div colGrow fdLayoutGridCol>\n                                <!-- wrapping \"formSubmitted\" event payload as any, because it's type is more generic than we're expecting -->\n                                <fdp-form-generator\n                                    (formSubmitted)=\"_onFormSubmitted($any($event))\"\n                                    [formItems]=\"condition\"\n                                    [unifiedLayout]=\"false\"\n                                    columnLayout=\"XL3-L3-M3-S3\"\n                                    [noAdditionalContent]=\"true\"\n                                ></fdp-form-generator>\n                            </div>\n                            <div class=\"fdp-smart-filter-bar__actions-column\" colGrow fdLayoutGridCol>\n                                <button\n                                    fd-button\n                                    (click)=\"removeCondition(i)\"\n                                    fdType=\"transparent\"\n                                    glyph=\"decline\"\n                                    [title]=\"\n                                        'platformSmartFilterBar.defineConditionsRemoveConditionButtonTitle'\n                                            | fdTranslate\n                                    \"\n                                    type=\"button\"\n                                ></button>\n                            </div>\n                        </div>\n                    </fd-layout-grid>\n                }\n                <fd-layout-grid>\n                    <div fdLayoutGridRow>\n                        <div colGrow fdLayoutGridCol>&nbsp;</div>\n                        <div class=\"fdp-smart-filter-bar__actions-column\" fdLayoutGridCol>\n                            <button\n                                fd-button\n                                (click)=\"addCondition()\"\n                                [label]=\"'platformSmartFilterBar.defineConditionsAddConditionButtonLabel' | fdTranslate\"\n                            ></button>\n                        </div>\n                    </div>\n                </fd-layout-grid>\n            </form>\n        } @else {\n            <div [style.text-align]=\"'center'\" [style.margin.rem]=\"1\">\n                <fd-busy-indicator [loading]=\"true\"></fd-busy-indicator>\n            </div>\n        }\n    </fd-dialog-body>\n    <fd-dialog-footer>\n        <fd-button-bar\n            (click)=\"applyConditions()\"\n            fdType=\"emphasized\"\n            [label]=\"'platformSmartFilterBar.defineConditionsSubmitButtonLabel' | fdTranslate\"\n        >\n        </fd-button-bar>\n        <fd-button-bar\n            (click)=\"_cancel()\"\n            fdType=\"transparent\"\n            [label]=\"'platformSmartFilterBar.defineConditionsCancelButton' | fdTranslate\"\n        ></fd-button-bar>\n    </fd-dialog-footer>\n</fd-dialog>\n" }]
        }], ctorParameters: () => [{ type: i1$1.DialogRef }, { type: i0.ChangeDetectorRef }, { type: SmartFilterBarService }], propDecorators: { formGenerators: [{
                type: ViewChildren,
                args: [FormGeneratorComponent]
            }] } });

class BaseSmartFilterBarConditionField extends BaseDynamicFormGeneratorControl {
    constructor() {
        super(...arguments);
        this._dialogService = inject(DialogService);
        this._smartFilterBarService = inject(SmartFilterBarService);
        this._injector = inject(Injector);
        /**
         * Method for opening conditions configuration dialog.
         */
        this.openConditionsDialog = () => {
            const currentValue = this.getField().value;
            const dialogData = {
                header: this.formItem.message,
                dataType: this.formItem.guiOptions?.additionalData.dataType,
                filterType: this.formItem.guiOptions?.additionalData.type,
                conditions: currentValue || [],
                choices: this.formItem.guiOptions?.additionalData.choices,
                controlType: this.formItem.guiOptions?.additionalData.controlType
            };
            const dialogRef = this._dialogService.open(SmartFilterBarConditionsDialogComponent, {
                data: dialogData,
                width: '67.5rem',
                minHeight: '30%'
            }, this._injector);
            dialogRef.afterClosed.pipe(take(1)).subscribe({
                next: async (conditions) => {
                    const field = this.getField();
                    const normalizedConditions = await this._smartFilterBarService.getConditionFieldSelectedVariants(this.formItem, conditions);
                    field.setValue(normalizedConditions);
                },
                // eslint-disable-next-line @typescript-eslint/no-unused-vars
                error: (_) => { }
            });
        };
    }
    /**
     * Method for retrieving current form control of the generated form.
     * @returns Found form control.
     */
    getField() {
        return this.form.get(`${this.formGroupName}.${this.name}`);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: BaseSmartFilterBarConditionField, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
    static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.0", type: BaseSmartFilterBarConditionField, isStandalone: true, usesInheritance: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: BaseSmartFilterBarConditionField, decorators: [{
            type: Directive
        }] });

class SmartFilterBarConditionFieldComponent extends BaseSmartFilterBarConditionField {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SmartFilterBarConditionFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.1.0", type: SmartFilterBarConditionFieldComponent, isStandalone: true, selector: "fdp-smart-filter-bar-condition-field", usesInheritance: true, ngImport: i0, template: "<ng-container [formGroup]=\"form\">\n    <ng-container [formGroupName]=\"formGroupName\">\n        <fdp-multi-input\n            [id]=\"id\"\n            [addOnButtonClickFn]=\"openConditionsDialog\"\n            [dataSource]=\"formItem.choices || []\"\n            [formControlName]=\"name\"\n            [name]=\"name\"\n            [placeholder]=\"formItem.placeholder || formItem.message\"\n            [validationStrategy]=\"['submitted']\"\n            displayKey=\"displayValue\"\n            [glyphAriaLabel]=\"'platformSmartFilterBar.manageFieldConditions' | fdTranslate\"\n        >\n        </fdp-multi-input>\n    </ng-container>\n</ng-container>\n", dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i1$2.FormGroupName, selector: "[formGroupName]", inputs: ["formGroupName"] }, { kind: "component", type: PlatformMultiInputComponent, selector: "fdp-multi-input", inputs: ["tokenHiddenId", "type", "autofocus", "glyphAriaLabel", "addonIconTitle", "selected", "selectionMode", "hasByLine", "disabled", "fillControlMode", "triggers", "closeOnOutsideClick", "addOnButtonClickFn", "displayFn"], outputs: ["selectionChange"] }, { kind: "pipe", type: FdTranslatePipe, name: "fdTranslate" }], encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SmartFilterBarConditionFieldComponent, decorators: [{
            type: Component,
            args: [{ selector: 'fdp-smart-filter-bar-condition-field', encapsulation: ViewEncapsulation.None, imports: [FormsModule, ReactiveFormsModule, PlatformMultiInputComponent, FdTranslatePipe], template: "<ng-container [formGroup]=\"form\">\n    <ng-container [formGroupName]=\"formGroupName\">\n        <fdp-multi-input\n            [id]=\"id\"\n            [addOnButtonClickFn]=\"openConditionsDialog\"\n            [dataSource]=\"formItem.choices || []\"\n            [formControlName]=\"name\"\n            [name]=\"name\"\n            [placeholder]=\"formItem.placeholder || formItem.message\"\n            [validationStrategy]=\"['submitted']\"\n            displayKey=\"displayValue\"\n            [glyphAriaLabel]=\"'platformSmartFilterBar.manageFieldConditions' | fdTranslate\"\n        >\n        </fdp-multi-input>\n    </ng-container>\n</ng-container>\n" }]
        }] });

class SmartFilterBarOptionsDataProvider extends ArrayTableDataProvider {
    /** @hidden */
    constructor(items) {
        super(items);
    }
    /**
     * Filters rows depending on applied filter.
     * @param option filter visibility category.
     */
    filter(option) {
        let items;
        switch (option) {
            case 'visible':
                items = this._getVisibleItems();
                break;
            case 'active':
                items = this._getActiveItems();
                break;
            case 'visibleAndActive':
                items = this._getVisibleAndActiveItems();
                break;
            case 'mandatory':
                items = this._getMandatoryItems();
                break;
            case 'all':
            default:
                items = this._getAllItems();
                break;
        }
        this.items$.next(items);
    }
    /** @hidden */
    _getAllItems() {
        return this.items;
    }
    /** @hidden */
    _getVisibleItems() {
        return this.items.filter((i) => i.visible);
    }
    /** @hidden */
    _getActiveItems() {
        return this.items.filter((i) => i.active);
    }
    /** @hidden */
    _getVisibleAndActiveItems() {
        return this.items.filter((i) => i.visible || i.active);
    }
    /** @hidden */
    _getMandatoryItems() {
        return this.items.filter((i) => i.mandatory);
    }
}

class SmartFilterBarSettingsDialogComponent {
    /** @hidden */
    constructor(_dialogRef, _language$, _cdr) {
        this._dialogRef = _dialogRef;
        this._language$ = _language$;
        this._cdr = _cdr;
        /** @hidden */
        this._filterVisibilityOptions = [];
        /** @hidden */
        this.loaded = false;
        /** Indicates when reset command is available */
        this.isResetAvailable$ = signal(false, ...(ngDevMode ? [{ debugName: "isResetAvailable$" }] : []));
        /** @hidden */
        this._categoryLabelKeys = {
            all: 'settingsCategoryAll',
            visible: 'settingsCategoryVisible',
            active: 'settingsCategoryActive',
            visibleAndActive: 'settingsCategoryVisibleAndActive',
            mandatory: 'settingsCategoryMandatory'
        };
        /** @hidden */
        this._selectedFilters = [];
        /**
         * @hidden
         * An RxJS Subject that will kill the data stream upon component’s destruction (for unsubscribing)
         */
        this._destroyRef = inject(DestroyRef);
        /** @hidden */
        this._translationResolver = new TranslationResolver();
        this.setInitialTableState();
        this._init();
    }
    /** @hidden */
    ngAfterViewInit() {
        this.setSelectedFilters();
    }
    /**
     * Checks the checkbox in the table row if the field is selected.
     */
    setSelectedFilters() {
        this._sourceSubscription?.unsubscribe();
        this._sourceSubscription = this.source
            .open()
            .pipe(observeOn(asyncScheduler), takeUntilDestroyed(this._destroyRef))
            .subscribe((items) => {
            items.forEach((field, index) => {
                if (field.visible) {
                    this.table.toggleSelectableRow(index);
                }
            });
        });
    }
    /**
     * Resets filters selection.
     */
    reset() {
        this.setInitialTableState();
        this.setSelectedFilters();
    }
    /**
     * Sets initial state of the table.
     */
    setInitialTableState() {
        this._availableFields = this._dialogRef.data.fields
            .filter((c) => c.filterable)
            .map((c) => ({
            label: c.label,
            active: !!this._dialogRef.data.filterBy.find((f) => f.field === c.name),
            mandatory: c.required,
            visible: this._dialogRef.data.selectedFilters.includes(c.name),
            key: c.key,
            name: c.name
        }));
        this.source = new TableDataSource(new SmartFilterBarOptionsDataProvider(this._availableFields));
    }
    /** @hidden */
    _cancel() {
        this._dialogRef.dismiss();
    }
    /** @hidden */
    _confirm() {
        this._dialogRef.close(this._selectedFilters);
    }
    /** @hidden */
    _onRowSelectionChange(event) {
        this._selectedFilters = event.selection.map((c) => c.name);
        this.isResetAvailable$.set(true);
    }
    /** @hidden */
    _onFilterVisibilityChange(event) {
        if (!this.table) {
            return;
        }
        this.source.dataProvider.filter(event.payload);
        this.source.fetch(this.table.getTableState());
    }
    /** @hidden */
    async _init() {
        await this._transformVisibilityLabels();
        this.loaded = true;
        this._cdr.markForCheck();
    }
    /**
     * Transforms visibility options into appropriate select item object.
     */
    async _transformVisibilityLabels() {
        const lang = await firstValueFrom(this._language$);
        const labels = { ...this._categoryLabelKeys };
        for (const strategyItem in labels) {
            if (Object.prototype.hasOwnProperty.call(labels, strategyItem)) {
                const translationKey = ('platformSmartFilterBar.' +
                    labels[strategyItem]);
                labels[strategyItem] = this._translationResolver.resolve(lang, translationKey);
            }
        }
        for (const [selectValue, selectLabel] of Object.entries(labels)) {
            this._filterVisibilityOptions.push({
                label: selectLabel,
                value: selectValue
            });
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SmartFilterBarSettingsDialogComponent, deps: [{ token: i1$1.DialogRef }, { token: FD_LANGUAGE }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.0", type: SmartFilterBarSettingsDialogComponent, isStandalone: true, selector: "fdp-smart-filter-bar-settings-dialog", providers: [{ provide: RESETTABLE_TOKEN, useExisting: SmartFilterBarSettingsDialogComponent }], viewQueries: [{ propertyName: "table", first: true, predicate: ["table"], descendants: true }], ngImport: i0, template: "<fd-dialog class=\"fdp-table-p13-filtering-dialog\">\n    <fd-dialog-header>\n        <ng-template fdkTemplate=\"header\">\n            <div fd-bar-left>\n                <fd-bar-element>\n                    <h4 [headerSize]=\"4\" fd-title>\n                        {{ 'platformSmartFilterBar.selectFiltersHeader' | fdTranslate }}\n                    </h4>\n                </fd-bar-element>\n            </div>\n            <div fd-bar-right>\n                <fd-bar-element>\n                    <fdp-table-reset-button></fdp-table-reset-button>\n                </fd-bar-element>\n            </div>\n        </ng-template>\n    </fd-dialog-header>\n    <fd-dialog-body>\n        @if (loaded) {\n            <fdp-table\n                #table\n                (rowSelectionChange)=\"_onRowSelectionChange($event)\"\n                [dataSource]=\"source\"\n                selectionMode=\"multiple\"\n            >\n                <fdp-table-toolbar\n                    [hideItemCount]=\"false\"\n                    [title]=\"'platformSmartFilterBar.selectFiltersAvailableFiltersText' | fdTranslate\"\n                >\n                    <fdp-table-toolbar-actions>\n                        <fdp-select\n                            (selectionChange)=\"_onFilterVisibilityChange($event)\"\n                            [list]=\"_filterVisibilityOptions\"\n                            [value]=\"_filterVisibilityOptions[0].value\"\n                        >\n                        </fdp-select>\n                    </fdp-table-toolbar-actions>\n                </fdp-table-toolbar>\n                <fdp-column\n                    align=\"start\"\n                    key=\"label\"\n                    [label]=\"'platformSmartFilterBar.selectFiltersFilterColumnLabel' | fdTranslate\"\n                    name=\"label\"\n                ></fdp-column>\n                <fdp-column\n                    align=\"center\"\n                    key=\"active\"\n                    [label]=\"'platformSmartFilterBar.selectFiltersActiveColumnLabel' | fdTranslate\"\n                    name=\"active\"\n                    width=\"150px\"\n                >\n                    <fdp-table-cell *fdpCellDef=\"let item\">\n                        @if (item.active) {\n                            <fd-icon glyph=\"accept\"></fd-icon>\n                        }\n                    </fdp-table-cell>\n                </fdp-column>\n            </fdp-table>\n        } @else {\n            <div [style.text-align]=\"'center'\" [style.margin.rem]=\"1\">\n                <fd-busy-indicator [loading]=\"true\"></fd-busy-indicator>\n            </div>\n        }\n    </fd-dialog-body>\n    <fd-dialog-footer>\n        <fd-button-bar\n            (click)=\"_confirm()\"\n            fdType=\"emphasized\"\n            [label]=\"'platformSmartFilterBar.selectFiltersSubmitButtonLabel' | fdTranslate\"\n        ></fd-button-bar>\n        <fd-button-bar\n            (click)=\"_cancel()\"\n            fdType=\"transparent\"\n            [label]=\"'platformSmartFilterBar.selectFiltersCancelButton' | fdTranslate\"\n        ></fd-button-bar>\n    </fd-dialog-footer>\n</fd-dialog>\n", dependencies: [{ kind: "component", type: DialogComponent, selector: "fd-dialog", inputs: ["class", "dialogRef", "dialogConfig"] }, { kind: "component", type: DialogHeaderComponent, selector: "fd-dialog-header" }, { kind: "directive", type: TemplateDirective, selector: "[fdkTemplate]", inputs: ["fdkTemplate"] }, { kind: "directive", type: BarLeftDirective, selector: "[fd-bar-left]" }, { kind: "directive", type: BarElementDirective, selector: "fd-bar-element", inputs: ["fullWidth"] }, { kind: "component", type: TitleComponent, selector: "[fd-title], [fdTitle]", inputs: ["headerSize", "wrap"], exportAs: ["fd-title"] }, { kind: "directive", type: BarRightDirective, selector: "[fd-bar-right]" }, { kind: "component", type: ResetButtonComponent, selector: "fdp-table-reset-button" }, { kind: "component", type: DialogBodyComponent, selector: "fd-dialog-body", inputs: ["disablePaddings"] }, { kind: "component", type: TableComponent, selector: "fdp-table", inputs: ["name", "id", "enableDragResize", "fixed", "freezeColumnsTo", "freezeEndColumnsTo", "pageScrolling", "showGrowingButton", "showItemsCount", "pageSize", "pageScrollingThreshold", "bodyHeight", "emptyTableMessage", "noVisibleColumnsMessage", "noHorizontalBorders", "outerScroll", "noVerticalBorders", "noBorders", "noBodyBorders", "noOuterBorders", "noBorderX", "noBorderY", "relationKey", "expandedStateKey", "hasChildrenKey", "rowNavigatable", "highlightNavigatedRow", "rowsActivable", "selectedKey", "selectableKey", "trackBy", "rowComparator", "rowsClass", "editableRowSkeleton", "expandOnInit", "rowHeight", "secondaryRowHeight", "loadPagesBefore", "nonInteractiveHeader", "selectionMode", "enableTristateMode", "semanticHighlighting", "forceCheckedAllState", "ariaLabelledBy", "minimumColumnWidth", "showTableFooter", "nonFrozenColumnsMinWidth", "loading"], outputs: ["presetChanged", "rowSelectionChange", "sortChange", "filterChange", "groupChange", "columnsChange", "pageChange", "columnFreeze", "rowToggleOpenState", "cellActivate", "rowActivate", "rowNavigate", "emptyRowAdded", "save", "cancel", "tableScrolled", "tableRowsSet", "allRowsExpanded", "allRowsCollapsed", "cellFocused"] }, { kind: "directive", type: TableInitialStateDirective, selector: "[fdpTableInitialState],    fdp-table", inputs: ["initialVisibleColumns", "initialSortBy", "initialFilterBy", "initialGroupBy", "initialPage", "state"] }, { kind: "component", type: TableToolbarComponent, selector: "fdp-table-toolbar", inputs: ["shouldOverflow", "title", "searchFieldAriaLabel", "hideItemCount", "hideSearchInput", "searchFieldPlaceholder", "showExpandCollapseButtons", "searchSuggestions", "editMode", "disableRefresh", "disableSearch", "headingLevel", "searchFieldInputText"], outputs: ["searchFieldInputChange"] }, { kind: "component", type: TableToolbarActionsComponent, selector: "fdp-table-toolbar-actions" }, { kind: "component", type: SelectComponent, selector: "fdp-select", inputs: ["value", "inline"] }, { kind: "component", type: TableColumnComponent, selector: "fdp-column", inputs: ["name", "key", "label", "footerLabel", "footerCellTemplate", "align", "sortable", "filterable", "visible", "dataType", "filterSelectOptions", "groupable", "freezable", "endFreezable", "nonInteractive", "width", "noWrap", "applyText", "role", "announceEmptyCell"] }, { kind: "directive", type: FdpCellDef, selector: "[fdpCellDef]", inputs: ["fdpCellDefAs"] }, { kind: "directive", type: FdpTableCell, selector: "fdp-table-cell" }, { kind: "component", type: IconComponent, selector: "fd-icon", inputs: ["glyph", "font", "color", "background", "class", "ariaLabel", "ariaHidden"], outputs: ["ariaHiddenChange"] }, { kind: "component", type: DialogFooterComponent, selector: "fd-dialog-footer" }, { kind: "component", type: ButtonBarComponent, selector: "fd-button-bar", inputs: ["fullWidth", "fdType", "title", "ariaLabelledby", "id"] }, { kind: "component", type: BusyIndicatorComponent, selector: "fd-busy-indicator", inputs: ["loading", "size", "block", "ariaLabel", "ariaValueText", "title", "label", "ariaLive"] }, { kind: "pipe", type: FdTranslatePipe, name: "fdTranslate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SmartFilterBarSettingsDialogComponent, decorators: [{
            type: Component,
            args: [{ selector: 'fdp-smart-filter-bar-settings-dialog', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, providers: [{ provide: RESETTABLE_TOKEN, useExisting: SmartFilterBarSettingsDialogComponent }], imports: [
                        DialogComponent,
                        DialogHeaderComponent,
                        TemplateDirective,
                        BarLeftDirective,
                        BarElementDirective,
                        TitleComponent,
                        BarRightDirective,
                        ResetButtonComponent,
                        CdkScrollable,
                        ScrollbarDirective,
                        DialogBodyComponent,
                        TableDataSourceDirective,
                        TableHeaderResizerDirective,
                        TableComponent,
                        TableInitialStateDirective,
                        TableToolbarComponent,
                        TableToolbarActionsComponent,
                        SelectComponent,
                        TableColumnComponent,
                        FdpCellDef,
                        FdpTableCell,
                        IconComponent,
                        DialogFooterComponent,
                        ButtonBarComponent,
                        BusyIndicatorComponent,
                        FdTranslatePipe
                    ], template: "<fd-dialog class=\"fdp-table-p13-filtering-dialog\">\n    <fd-dialog-header>\n        <ng-template fdkTemplate=\"header\">\n            <div fd-bar-left>\n                <fd-bar-element>\n                    <h4 [headerSize]=\"4\" fd-title>\n                        {{ 'platformSmartFilterBar.selectFiltersHeader' | fdTranslate }}\n                    </h4>\n                </fd-bar-element>\n            </div>\n            <div fd-bar-right>\n                <fd-bar-element>\n                    <fdp-table-reset-button></fdp-table-reset-button>\n                </fd-bar-element>\n            </div>\n        </ng-template>\n    </fd-dialog-header>\n    <fd-dialog-body>\n        @if (loaded) {\n            <fdp-table\n                #table\n                (rowSelectionChange)=\"_onRowSelectionChange($event)\"\n                [dataSource]=\"source\"\n                selectionMode=\"multiple\"\n            >\n                <fdp-table-toolbar\n                    [hideItemCount]=\"false\"\n                    [title]=\"'platformSmartFilterBar.selectFiltersAvailableFiltersText' | fdTranslate\"\n                >\n                    <fdp-table-toolbar-actions>\n                        <fdp-select\n                            (selectionChange)=\"_onFilterVisibilityChange($event)\"\n                            [list]=\"_filterVisibilityOptions\"\n                            [value]=\"_filterVisibilityOptions[0].value\"\n                        >\n                        </fdp-select>\n                    </fdp-table-toolbar-actions>\n                </fdp-table-toolbar>\n                <fdp-column\n                    align=\"start\"\n                    key=\"label\"\n                    [label]=\"'platformSmartFilterBar.selectFiltersFilterColumnLabel' | fdTranslate\"\n                    name=\"label\"\n                ></fdp-column>\n                <fdp-column\n                    align=\"center\"\n                    key=\"active\"\n                    [label]=\"'platformSmartFilterBar.selectFiltersActiveColumnLabel' | fdTranslate\"\n                    name=\"active\"\n                    width=\"150px\"\n                >\n                    <fdp-table-cell *fdpCellDef=\"let item\">\n                        @if (item.active) {\n                            <fd-icon glyph=\"accept\"></fd-icon>\n                        }\n                    </fdp-table-cell>\n                </fdp-column>\n            </fdp-table>\n        } @else {\n            <div [style.text-align]=\"'center'\" [style.margin.rem]=\"1\">\n                <fd-busy-indicator [loading]=\"true\"></fd-busy-indicator>\n            </div>\n        }\n    </fd-dialog-body>\n    <fd-dialog-footer>\n        <fd-button-bar\n            (click)=\"_confirm()\"\n            fdType=\"emphasized\"\n            [label]=\"'platformSmartFilterBar.selectFiltersSubmitButtonLabel' | fdTranslate\"\n        ></fd-button-bar>\n        <fd-button-bar\n            (click)=\"_cancel()\"\n            fdType=\"transparent\"\n            [label]=\"'platformSmartFilterBar.selectFiltersCancelButton' | fdTranslate\"\n        ></fd-button-bar>\n    </fd-dialog-footer>\n</fd-dialog>\n" }]
        }], ctorParameters: () => [{ type: i1$1.DialogRef }, { type: i2.Observable, decorators: [{
                    type: Inject,
                    args: [FD_LANGUAGE]
                }] }, { type: i0.ChangeDetectorRef }], propDecorators: { table: [{
                type: ViewChild,
                args: ['table']
            }] } });

const SMART_FILTER_BAR_RENDERER_COMPONENT = 'smart-filter-condition-renderer';

class SmartFilterBarFieldDefinitionDirective {
    constructor() {
        /** Condition strategy */
        this.conditionStrategy = 'or';
        /** Whether this field can be filtered. Default value is true. */
        this.smartFilterBarFilterable = true;
        /** Whether this field filter is mandatory. */
        this.required = false;
        /** Whether this field filter is selected by default. */
        this.defaultSelected = false;
        /** Whether this field has autocomplete options */
        this.hasOptions = false;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SmartFilterBarFieldDefinitionDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
    static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "21.1.0", type: SmartFilterBarFieldDefinitionDirective, isStandalone: true, selector: "[fdpSmartFilterBarFieldDefinition], [fdp-smart-filter-bar-field-definition]", inputs: { key: "key", name: "name", label: "label", filterType: "filterType", dataType: "dataType", customFilterType: "customFilterType", conditionStrategy: "conditionStrategy", smartFilterBarFilterable: ["smartFilterBarFilterable", "smartFilterBarFilterable", booleanAttribute], required: ["required", "required", booleanAttribute], defaultSelected: ["defaultSelected", "defaultSelected", booleanAttribute], hasOptions: ["hasOptions", "hasOptions", booleanAttribute] }, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SmartFilterBarFieldDefinitionDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[fdpSmartFilterBarFieldDefinition], [fdp-smart-filter-bar-field-definition]',
                    standalone: true
                }]
        }], propDecorators: { key: [{
                type: Input
            }], name: [{
                type: Input
            }], label: [{
                type: Input
            }], filterType: [{
                type: Input
            }], dataType: [{
                type: Input
            }], customFilterType: [{
                type: Input
            }], conditionStrategy: [{
                type: Input
            }], smartFilterBarFilterable: [{
                type: Input,
                args: [{ transform: booleanAttribute }]
            }], required: [{
                type: Input,
                args: [{ transform: booleanAttribute }]
            }], defaultSelected: [{
                type: Input,
                args: [{ transform: booleanAttribute }]
            }], hasOptions: [{
                type: Input,
                args: [{ transform: booleanAttribute }]
            }] } });

class SmartFilterBarSubjectDirective {
    /** @hidden */
    constructor(_subject) {
        this._subject = _subject;
        /** @hidden */
        this._fieldDefinitionsSubject = new BehaviorSubject([]);
        /**
         * Observable of available fields.
         */
        this.fieldsStream = this._fieldDefinitionsSubject.asObservable();
        /** @hidden */
        this._destroyRef = inject(DestroyRef);
    }
    /** @hidden */
    ngAfterViewInit() {
        this._fieldDefinitions.changes.pipe(startWith(null), takeUntilDestroyed(this._destroyRef)).subscribe(() => {
            this._fieldDefinitionsSubject.next(this._fieldDefinitions.map((d) => this._transformSubjectField(d)));
        });
    }
    /**
     * Retrieves data source of the subject.
     * @returns Subject's data source.
     */
    getDataSource() {
        return this._subject.getDataSource();
    }
    /**
     * Retrieves available fields of the subject.
     * @returns Available fields of the subject.
     */
    getSubjectFields() {
        return this._fieldDefinitions.toArray().map((f) => this._transformSubjectField(f));
    }
    /** Get available field variants */
    getFieldVariants(field) {
        return this.getDataSource().dataProvider.getFieldOptions(field);
    }
    /** @hidden */
    getDefaultFields() {
        return this.getSubjectFields()
            ?.filter((f) => f.filterable && f.defaultSelected)
            .map((f) => f.name);
    }
    /** Get subject state */
    getState() {
        return this._subject.getTableState();
    }
    /**
     * @returns Subject component.
     */
    getSubject() {
        return this._subject;
    }
    /** @hidden */
    _transformSubjectField(column) {
        return {
            key: column.key,
            name: column.name,
            label: column.label,
            filterType: column.filterType,
            filterable: column.smartFilterBarFilterable,
            dataType: column.dataType,
            required: column.required,
            customFilterType: column.customFilterType,
            defaultSelected: column.defaultSelected,
            hasOptions: column.hasOptions,
            conditionStrategy: column.conditionStrategy
        };
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SmartFilterBarSubjectDirective, deps: [{ token: i1$3.Table }], target: i0.ɵɵFactoryTarget.Directive }); }
    static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.0", type: SmartFilterBarSubjectDirective, isStandalone: true, selector: "[fdpSmartFilterBarSubject], [fdp-smart-filter-bar-subject]", queries: [{ propertyName: "_fieldDefinitions", predicate: SmartFilterBarFieldDefinitionDirective }], exportAs: ["fdp-smart-filter-bar-subject"], ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SmartFilterBarSubjectDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[fdpSmartFilterBarSubject], [fdp-smart-filter-bar-subject]',
                    exportAs: 'fdp-smart-filter-bar-subject',
                    standalone: true
                }]
        }], ctorParameters: () => [{ type: i1$3.Table }], propDecorators: { _fieldDefinitions: [{
                type: ContentChildren,
                args: [SmartFilterBarFieldDefinitionDirective]
            }] } });

class SmartFilterBarToolbarItemDirective {
    /** @hidden */
    constructor(templateRef) {
        this.templateRef = templateRef;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SmartFilterBarToolbarItemDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive }); }
    static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.0", type: SmartFilterBarToolbarItemDirective, isStandalone: true, selector: "[fdpSmartFilterBarToolbarItem]", ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SmartFilterBarToolbarItemDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[fdpSmartFilterBarToolbarItem]',
                    standalone: true
                }]
        }], ctorParameters: () => [{ type: i0.TemplateRef }] });

class SmartFilterBar {
    constructor() {
        /** Component name used in Preset managed component. */
        this.name = 'platformSmartFilterBar';
        /** Event emitted when smart filter bar configuration has been changed. */
        this.presetChanged = new EventEmitter();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SmartFilterBar, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
    static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.0", type: SmartFilterBar, isStandalone: true, inputs: { name: "name" }, outputs: { presetChanged: "presetChanged" }, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SmartFilterBar, decorators: [{
            type: Directive
        }], propDecorators: { name: [{
                type: Input
            }], presetChanged: [{
                type: Output
            }] } });

const defaultColumnsLayout = 'XL4-L3-M2-S1';
function getColumnsNumber(layout) {
    return Math.max(...layout.split('-').map((part) => {
        const matchArray = part.match(/\d+/);
        return matchArray ? parseInt(matchArray[0], 10) : 1;
    }));
}
/**
 * Default dialog configuration.
 */
const dialogConfig = {
    responsivePadding: true,
    verticalPadding: true,
    minWidth: '30rem',
    /** 88px it's the header + footer height */
    bodyMinHeight: 'calc(50vh - 5.5rem)'
};
const smartFilterBarProvider$1 = {
    provide: SmartFilterBar,
    useExisting: forwardRef(() => SmartFilterBarComponent)
};
class SmartFilterBarComponent extends SmartFilterBar {
    /**
     * Subject which will provide configuration data: data source, columns definitions, etc.
     */
    set subject(value) {
        this._setSubject(value);
    }
    get subject() {
        return this._subject;
    }
    /** Loading state. */
    get loading() {
        return this._subject?.getDataSource() ? this._subject.getDataSource().isDataLoading : true;
    }
    /** @hidden */
    constructor(_dialogService, _fgService, _injector, _destroyRef) {
        super();
        this._dialogService = _dialogService;
        this._fgService = _fgService;
        this._injector = _injector;
        this._destroyRef = _destroyRef;
        /**
         * Whether smart filter bar background should be transparent.
         */
        this.transparent = false;
        /**
         * Columns layout.
         */
        this.filtersColumnLayout = defaultColumnsLayout;
        /**
         * Whether to update filters when they are selected. Otherwise, filters will be applied only by pressing "Go" button.
         */
        this.liveUpdate = false;
        /**
         * Whether to hide Toolbar.
         */
        this.hideToolbar = false;
        /**
         * Event emitted when the selected filters have been changed.
         */
        this.smartFiltersChanged = new EventEmitter();
        /**
         * Event emitted when selected filters has been applied (User clicked on Go button).
         */
        this.smartFiltersApplied = new EventEmitter();
        /**
         * Event emitted when search input field value has been changed.
         */
        this.searchInputChanged = new EventEmitter();
        /**
         * Calculated array of filters to apply for the subject's data source.
         */
        this.filterBy = [];
        /** Whether the filters section should be shown. */
        this.showFilterBar$ = signal(true, ...(ngDevMode ? [{ debugName: "showFilterBar$" }] : []));
        /** @Hidden */
        this._toolbarItems = [];
        /** @hidden */
        this._formItems = signal(null, ...(ngDevMode ? [{ debugName: "_formItems" }] : []));
        /** Selected filters. */
        this.selectedFilters$ = signal([], ...(ngDevMode ? [{ debugName: "selectedFilters$" }] : []));
        /** Selected filters count. */
        this.selectedFiltersCount$ = computed(() => this.selectedFilters$().length, ...(ngDevMode ? [{ debugName: "selectedFiltersCount$" }] : []));
        /** @hidden */
        this._subscriptions = new Subscription();
        /** @hidden */
        this._subjectSubscriptions = new Subscription();
        /** @hidden */
        this._formGeneratorReady = new BehaviorSubject(false);
        /** @hidden */
        this._ignorePresetChange = false;
        /** @hidden */
        this._refresh$ = new Subject();
        /**
         * @hidden
         * Smart filter bar service may be provided by parent component that adds custom configuration, so we need to check if it's provided.
         */
        this._smartFilterBarService = inject(SmartFilterBarService, { optional: true, skipSelf: true }) ??
            inject(SmartFilterBarService, { self: true });
        this._fgService.addComponent(SmartFilterBarConditionFieldComponent, [SMART_FILTER_BAR_RENDERER_COMPONENT]);
    }
    /** @hidden */
    ngAfterViewInit() {
        this._subscriptions.add(this._toolbarItemRefs.changes.pipe(startWith$1(null)).subscribe(() => {
            this._toolbarItems = this._toolbarItemRefs.toArray().map((ref) => ref.templateRef);
        }));
    }
    /** @hidden */
    ngOnDestroy() {
        this._subscriptions.unsubscribe();
        this._unsubscribeFromSubject();
        this._refresh$.next();
        this._refresh$.complete();
    }
    /**
     * Transforms condition value into human-readable text.
     * @param condition Smart filter bar condition.
     * @param filterType Condition filter type.
     */
    async getDisplayValue(condition, filterType) {
        return this._smartFilterBarService.getDisplayValue(condition, filterType);
    }
    /** Open Filtering Settings Dialog */
    showFilteringSettings() {
        const columns = this._getSubjectDefinitions();
        const dialogData = {
            fields: columns,
            filterBy: this.filterBy,
            selectedFilters: this.selectedFilters$()
        };
        const dialogRef = this._dialogService.open(SmartFilterBarSettingsDialogComponent, {
            ...dialogConfig,
            disablePaddings: true,
            width: '50rem',
            data: dialogData
        }, this._injector);
        dialogRef.afterClosed.pipe(take(1)).subscribe({
            next: (selectedFilters) => {
                this._setSelectedFilters(selectedFilters);
            },
            error: () => { }
        });
    }
    /** Callback function when search query changed. */
    onSearchInputChange(event) {
        this.search = event;
        this.searchInputChanged.emit(event);
    }
    /** Clear search query. */
    cancelSearch() {
        this.search = undefined;
        if (this.liveUpdate) {
            this.submitForm();
        }
    }
    /**
     * Submits filters and search form.
     */
    submitForm() {
        this._formGenerator.submit();
    }
    /** Method for setting predefined configuration. */
    async setPreset(data) {
        this._ignorePresetChange = true;
        data.filterBy = data.filterBy || [];
        this.filterBy = data.filterBy;
        this.search = data.search;
        this._refresh$.next();
        this._refresh$.complete();
        this._refresh$ = new Subject();
        this._formGeneratorReady
            .pipe(filter((value) => value), takeUntil(this._refresh$))
            .subscribe(async () => {
            // Reset form
            this._fgService.resetForm(this._formGenerator.form);
            // Set new data
            for (const filterBy of this.filterBy) {
                const control = this._fgService.getFormControl(this._formGenerator.form, filterBy.field);
                if (!control) {
                    continue;
                }
                const formItem = control.formItem;
                const condition = this._smartFilterBarService.transformCollectionFilter(filterBy);
                const selectedConditions = await this._smartFilterBarService.getConditionFieldSelectedVariants(formItem, condition);
                control?.setValue(selectedConditions);
            }
            this._setSelectedFilters(this.filterBy.map((filterBy) => filterBy.field));
            const source = this.subject.getDataSource();
            source.dataProvider.setFilters(this.filterBy, this.search);
            this.subject.getSubject().fetch();
        });
    }
    /** Returns current preset configuration. */
    getCurrentPreset() {
        return {
            search: this.search,
            filterBy: this.filterBy
        };
    }
    /**
     * @hidden
     * Callback function when form generator form has been successfully validated and submitted.
     */
    _onFormSubmitted(event) {
        const conditions = this._generateCollectionFilterGroups(event);
        this._applyFiltering(conditions);
    }
    /**
     * @hidden
     * Callback method when form has been created.
     * Populates selected filters array with user-defined default filters.
     */
    _onFormCreated() {
        if (this.subject) {
            this._setSelectedFilters([...this.subject.getDefaultFields(), ...this.selectedFilters$()]);
        }
        this._formGenerator.form.valueChanges
            .pipe(debounceTime(50), takeUntilDestroyed(this._destroyRef))
            .subscribe(async () => {
            const conditions = await this.getFormattedConditions();
            this.smartFiltersChanged.emit({ filterBy: conditions, search: this.search, subject: this.subject });
            if (!this.liveUpdate) {
                return;
            }
            this._applyFiltering(conditions);
        });
        this._formGeneratorReady.next(true);
    }
    /**
     * Toggles Smart Filter Bar filters section.
     */
    toggleFilterBar() {
        this.showFilterBar$.update((show) => !show);
    }
    /**
     * Formats raw filters object into array of grouped filters.
     * @returns Array of grouped filters.
     */
    async getFormattedConditions() {
        const formValue = await this._fgService.getFormValue(this._formGenerator.form);
        return this._generateCollectionFilterGroups(formValue);
    }
    /** @hidden */
    _generateCollectionFilterGroups(value) {
        const collectionFilterGroups = [];
        const columns = this._getSubjectDefinitions();
        Object.entries(value)
            .filter(([, fieldConditions]) => !!fieldConditions)
            .forEach(([fieldName, fieldConditions]) => {
            const column = columns.find((c) => c.name === fieldName);
            const filterGroup = {
                filters: [],
                strategy: column.conditionStrategy,
                field: column.key
            };
            fieldConditions.forEach((condition) => {
                filterGroup.filters.push({
                    strategy: condition.operator,
                    field: column.key,
                    value: condition.value,
                    value2: condition.value2,
                    type: column.dataType
                });
            });
            collectionFilterGroups.push(filterGroup);
        });
        // Remove empty filter objects.
        return collectionFilterGroups.filter((filterGroup) => filterGroup.filters?.length > 0);
    }
    /** @hidden */
    _setSubject(subject) {
        if (!subject) {
            return;
        }
        this._subject = subject;
        this.unsubscribeFromSubject();
        this._listenToSubjectColumns();
    }
    /** @hidden */
    unsubscribeFromSubject() {
        if (!this._subject) {
            return;
        }
        this._subjectSubscriptions.unsubscribe();
    }
    /** @hidden */
    _listenToSubjectColumns() {
        this._subjectSubscriptions = new Subscription();
        this._subjectSubscriptions.add(this._subject.fieldsStream.subscribe(async (columns) => {
            await this._generateForm(columns.filter((c) => c.filterable));
        }));
    }
    /**
     * @hidden
     * Generates form items to be consumed by form generator component.
     * @param columns columns definition
     */
    async _generateForm(columns) {
        const items = [];
        const columnsNumber = getColumnsNumber(this.filtersColumnLayout ?? '');
        let currentColumn = 1;
        if (columns.length === 0) {
            return;
        }
        columns.forEach((column) => {
            let item = this._generateBaseFieldItem(column);
            if (column.required) {
                this.selectedFilters$.update((filters) => {
                    filters.push(column.name);
                    return filters;
                });
            }
            switch (column.filterType) {
                case FilterType.SINGLE:
                case FilterType.CATEGORY:
                    item.guiOptions.additionalData.type = 'select';
                    item.guiOptions.inline = false;
                    break;
                case FilterType.MULTI:
                    item.guiOptions.additionalData.type = 'multi-input';
                    break;
                case FilterType.CUSTOM:
                    item = this._generateCustomFilterFieldItem(column, item);
                    break;
                case FilterType.INPUT:
                default:
                    item = this._generateInputFieldItem(column, item);
                    break;
            }
            item.guiOptions.column = currentColumn;
            currentColumn += 1;
            if (currentColumn > columnsNumber) {
                currentColumn = 1;
            }
            items.push(item);
        });
        this._formItems.set(items);
    }
    /** @hidden */
    _generateCustomFilterFieldItem(column, item) {
        if (!column.customFilterType) {
            return item;
        }
        item.guiOptions.additionalData.type = column.customFilterType;
        item.guiOptions.additionalData = Object.assign(item.guiOptions.additionalData, this._smartFilterBarService.getCustomFilterConfiguration(column.customFilterType));
        item.type = item.guiOptions.additionalData.rendererComponent
            ? `${item.guiOptions.additionalData.type}-renderer`
            : item.type;
        item.transformer = item.guiOptions.additionalData.valueTransformer;
        return item;
    }
    /**
     * @hidden
     * Generates form item based on data type.
     * @param column
     * @param item
     * @returns
     */
    _generateInputFieldItem(column, item) {
        switch (column.dataType) {
            case FilterableColumnDataType.DATE:
                item.guiOptions.additionalData.type = 'datepicker';
                break;
            case FilterableColumnDataType.NUMBER:
                item.guiOptions.additionalData.controlType = 'number';
                break;
            case FilterableColumnDataType.BOOLEAN:
            case FilterableColumnDataType.STRING:
            default:
                item.guiOptions.additionalData.controlType = 'text';
                break;
        }
        return item;
    }
    /**
     * @hidden
     * Generates base form item object to be consumed by form generator component.
     * @param column column definition
     * @returns base form item object.
     */
    _generateBaseFieldItem(column) {
        return {
            name: column.name,
            message: column.label,
            required: column.required,
            type: SMART_FILTER_BAR_RENDERER_COMPONENT,
            placeholder: ' ',
            validators: column.required ? [Validators.required] : [],
            choices: column.hasOptions ? this._getFilterDefaultOptions(column.key, column.filterType) : undefined,
            transformer: (itemValue) => getSelectItemValue(itemValue),
            guiOptions: {
                additionalData: {
                    type: 'input',
                    dataType: column.dataType,
                    filterType: column.filterType,
                    controlType: 'text',
                    choices: column.hasOptions ? this._getFilterAvailableOptions(column.key) : undefined
                }
            },
            when: () => this.selectedFilters$().includes(column.name)
        };
    }
    /**
     * @hidden
     * Retrieves available options for particular column by using data source method.
     * @param column property name of the data source items.
     * @returns {Observable<SelectItem[]>} Observable with the array of available options.
     */
    _getFilterAvailableOptions(column) {
        return () => this._getFieldVariants(column);
    }
    /** @hidden */
    _getFilterDefaultOptions(column, filterType) {
        return async () => {
            const variants = await firstValueFrom(this._getFieldVariants(column).pipe(take(1)));
            const availableDefaultConditions = [];
            for (const option of variants) {
                const condition = {
                    value: option.value,
                    operator: 'equalTo'
                };
                condition.displayValue = await this.getDisplayValue(condition, filterType);
                availableDefaultConditions.push(condition);
            }
            return availableDefaultConditions;
        };
    }
    /** @hidden */
    _getFieldVariants(column) {
        return this.subject.getFieldVariants(column).pipe(take(1), map((data) => data.filter((item, index) => data.findIndex((_item) => _item.value === item.value) === index)));
    }
    /** @hidden */
    _getSubjectDefinitions() {
        return this.subject?.getSubjectFields() || [];
    }
    /**
     * @hidden
     * Sets provided filters directly to the data source.
     * @param filters array of filters.
     */
    _applyFiltering(filters) {
        // Apply outside filtering and force subject to fetch new data.
        const source = this.subject.getDataSource();
        this.filterBy = filters;
        source.dataProvider.setFilters(filters, this.search);
        this.subject.getSubject().fetch();
        const emittedValue = { search: this.search, filterBy: this.filterBy };
        this.smartFiltersApplied.emit({ ...emittedValue, subject: this._subject });
        if (!this._ignorePresetChange) {
            this.presetChanged.emit(emittedValue);
        }
        this._ignorePresetChange = false;
    }
    /** @hidden */
    _unsubscribeFromSubject() {
        this._subjectSubscriptions.unsubscribe();
        this._subjectSubscriptions = new Subscription();
    }
    /** @hidden */
    _setSelectedFilters(filters) {
        this.selectedFilters$.set(filters.filter((f, i) => filters.indexOf(f) === i));
        this._formGenerator.refreshStepsVisibility();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SmartFilterBarComponent, deps: [{ token: i1$1.DialogService }, { token: i1.FormGeneratorService }, { token: i0.Injector }, { token: i0.DestroyRef }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.0", type: SmartFilterBarComponent, isStandalone: true, selector: "fdp-smart-filter-bar", inputs: { subject: "subject", transparent: ["transparent", "transparent", booleanAttribute], filtersColumnLayout: "filtersColumnLayout", liveUpdate: ["liveUpdate", "liveUpdate", booleanAttribute], hideToolbar: ["hideToolbar", "hideToolbar", booleanAttribute] }, outputs: { smartFiltersChanged: "smartFiltersChanged", smartFiltersApplied: "smartFiltersApplied", searchInputChanged: "searchInputChanged" }, host: { properties: { "class.fdp-smart-filter-bar--transparent": "transparent" }, classAttribute: "fdp-smart-filter-bar" }, providers: [
            smartFilterBarProvider$1,
            SmartFilterBarService,
            FormGeneratorService,
            {
                provide: FDP_PRESET_MANAGED_COMPONENT,
                useExisting: SmartFilterBarComponent
            }
        ], queries: [{ propertyName: "_toolbarItemRefs", predicate: SmartFilterBarToolbarItemDirective }], viewQueries: [{ propertyName: "_formGenerator", first: true, predicate: FormGeneratorComponent, descendants: true }], usesInheritance: true, ngImport: i0, template: "@if (!hideToolbar) {\n    <fd-toolbar [shouldOverflow]=\"true\" fdType=\"transparent\">\n        @if (_toolbarItems) {\n            @for (template of _toolbarItems; track template) {\n                <div fd-toolbar-item>\n                    <ng-template [ngTemplateOutlet]=\"template\"></ng-template>\n                </div>\n            }\n            <fd-toolbar-separator></fd-toolbar-separator>\n        }\n        <fdp-search-field\n            fd-toolbar-item\n            (inputChange)=\"onSearchInputChange($event)\"\n            (searchSubmit)=\"submitForm()\"\n            (cancelSearch)=\"cancelSearch()\"\n            [disabled]=\"loading\"\n            [disableRefresh]=\"true\"\n            [placeholder]=\"'platformSmartFilterBar.searchPlaceholder' | fdTranslate\"\n        ></fdp-search-field>\n        <fd-toolbar-spacer></fd-toolbar-spacer>\n        @if (!liveUpdate) {\n            <button\n                fd-button\n                (click)=\"submitForm()\"\n                fdType=\"emphasized\"\n                fd-toolbar-item\n                [disabled]=\"loading\"\n                [label]=\"'platformSmartFilterBar.submitButtonLabel' | fdTranslate\"\n            ></button>\n        }\n        <button\n            fd-button\n            (click)=\"submitForm()\"\n            fd-toolbar-item\n            glyph=\"synchronize\"\n            [disabled]=\"loading\"\n            [ariaLabel]=\"'platformSmartFilterBar.refreshButtonAriaLabel' | fdTranslate\"\n        ></button>\n        <button\n            fd-button\n            (click)=\"showFilteringSettings()\"\n            [label]=\"\n                'platformSmartFilterBar.filtersButtonLabel' | fdTranslate: { filtersCount: selectedFiltersCount$() }\n            \"\n            fd-toolbar-item\n            [disabled]=\"loading\"\n        ></button>\n        <button\n            fd-button\n            (click)=\"toggleFilterBar()\"\n            [label]=\"\n                (showFilterBar$()\n                    ? 'platformSmartFilterBar.hideFiltersButtonLabel'\n                    : 'platformSmartFilterBar.showFiltersButtonLabel'\n                ) | fdTranslate\n            \"\n            fdType=\"transparent\"\n            fd-toolbar-item\n            [disabled]=\"loading\"\n        ></button>\n    </fd-toolbar>\n}\n@if (_formItems(); as formItems) {\n    <div class=\"fdp-smart-filter-bar__filters\" fd-toolbar-item [hidden]=\"!showFilterBar$()\">\n        <fdp-form-generator\n            (formCreated)=\"_onFormCreated()\"\n            (formSubmitted)=\"_onFormSubmitted($event)\"\n            [noAdditionalContent]=\"true\"\n            [formItems]=\"formItems\"\n            [columnLayout]=\"filtersColumnLayout\"\n        ></fdp-form-generator>\n    </div>\n}\n", styles: [".fdp-smart-filter-bar{display:block;box-shadow:var(--sapContent_HeaderShadow);background-color:var(--sapObjectHeader_Background)}.fdp-smart-filter-bar--transparent{background-color:var(--sapToolbar_Background);box-shadow:none}.fdp-smart-filter-bar .fd-toolbar--title{height:3rem;min-height:3rem;border-bottom:none;padding:.5rem}@media(min-width:600px){.fdp-smart-filter-bar .fd-toolbar--title{padding-left:2rem;padding-right:2rem}}.fdp-smart-filter-bar .fd-toolbar fdp-search-field{min-width:15.5rem}.fdp-smart-filter-bar .fdp-smart-filter-bar__filters{padding-left:.5rem;padding-right:.5rem}@media(min-width:600px){.fdp-smart-filter-bar .fdp-smart-filter-bar__filters{padding-left:2rem;padding-right:2rem}}.fdp-smart-filter-bar .fd-container.fd-form-layout-grid-container{padding:0}.fdp-smart-filter-bar .fd-container.fd-form-layout-grid-container .fd-row .fd-form-group{padding-left:.25rem!important;padding-right:.25rem!important}.fdp-smart-filter-bar__conditions-dialog .fdp-smart-filter-bar__actions-column{min-width:auto;flex:0 0 auto}.fdp-smart-filter-bar__conditions-dialog .fd-popover-custom{display:block}.fdp-smart-filter-bar__conditions-dialog .fd-dialog__body{padding:0 .5rem;background-color:var(--sapBackgroundColor, #f7f7f7)}.fdp-smart-filter-bar__conditions-dialog .fd-container.fd-form-layout-grid-container,.fdp-smart-filter-bar__conditions-dialog .fd-container.fd-form-layout-grid-container .fd-row .fd-form-group{padding-top:0!important;padding-bottom:0!important}.fdp-smart-filter-bar .fd-toolbar{--fdToolbar_Border: none}\n"], dependencies: [{ kind: "component", type: ToolbarComponent, selector: "fd-toolbar", inputs: ["titleId", "class", "shouldOverflow", "fdType", "title", "active", "clearBorder", "forceOverflow", "tabindex", "headingLevel", "ariaLabel", "ariaLabelledBy"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: ToolbarSeparatorComponent, selector: "fd-toolbar-separator" }, { kind: "component", type: SearchFieldComponent, selector: "fdp-search-field", inputs: ["categoryMode", "appearance", "placeholder", "mobile", "mobileConfig", "disableRefresh", "disableSearch", "suggestions", "dataSource", "inputText", "categories", "currentCategory", "categoryLabel", "hideCategoryLabel", "isLoading", "forceSearchButton", "disableSuggestionsFoundAnnouncer"], outputs: ["inputChange", "searchSubmit", "cancelSearch", "isOpenChange"] }, { kind: "directive", type: ToolbarSpacerDirective, selector: "fd-toolbar-spacer", inputs: ["width", "class", "fixed"] }, { kind: "component", type: ButtonComponent, selector: "button[fd-button], a[fd-button], span[fd-button]", inputs: ["id"], exportAs: ["fd-button"] }, { kind: "directive", type: ToolbarItemDirective, selector: "[fd-toolbar-item], [fdOverflowGroup], [fdOverflowPriority]", inputs: ["fdOverflowPriority", "fdOverflowGroup"] }, { kind: "component", type: FormGeneratorComponent, selector: "fdp-form-generator", inputs: ["formName", "formItems", "mainTitle", "hideMainTItle", "hint", "columnLayout", "labelColumnLayout", "fieldColumnLayout", "gapColumnLayout", "unifiedLayout", "inlineColumnLayout", "noAdditionalContent"], outputs: ["formCreated", "formSubmitted", "formSubmittedStatus"] }, { kind: "pipe", type: FdTranslatePipe, name: "fdTranslate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: SmartFilterBarComponent, decorators: [{
            type: Component,
            args: [{ selector: 'fdp-smart-filter-bar', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
                        smartFilterBarProvider$1,
                        SmartFilterBarService,
                        FormGeneratorService,
                        {
                            provide: FDP_PRESET_MANAGED_COMPONENT,
                            useExisting: SmartFilterBarComponent
                        }
                    ], host: {
                        class: 'fdp-smart-filter-bar',
                        '[class.fdp-smart-filter-bar--transparent]': 'transparent'
                    }, imports: [
                        ToolbarComponent,
                        NgTemplateOutlet,
                        ToolbarSeparatorComponent,
                        SearchFieldComponent,
                        ToolbarSpacerDirective,
                        ButtonComponent,
                        ToolbarItemDirective,
                        FormGeneratorComponent,
                        FdTranslatePipe
                    ], template: "@if (!hideToolbar) {\n    <fd-toolbar [shouldOverflow]=\"true\" fdType=\"transparent\">\n        @if (_toolbarItems) {\n            @for (template of _toolbarItems; track template) {\n                <div fd-toolbar-item>\n                    <ng-template [ngTemplateOutlet]=\"template\"></ng-template>\n                </div>\n            }\n            <fd-toolbar-separator></fd-toolbar-separator>\n        }\n        <fdp-search-field\n            fd-toolbar-item\n            (inputChange)=\"onSearchInputChange($event)\"\n            (searchSubmit)=\"submitForm()\"\n            (cancelSearch)=\"cancelSearch()\"\n            [disabled]=\"loading\"\n            [disableRefresh]=\"true\"\n            [placeholder]=\"'platformSmartFilterBar.searchPlaceholder' | fdTranslate\"\n        ></fdp-search-field>\n        <fd-toolbar-spacer></fd-toolbar-spacer>\n        @if (!liveUpdate) {\n            <button\n                fd-button\n                (click)=\"submitForm()\"\n                fdType=\"emphasized\"\n                fd-toolbar-item\n                [disabled]=\"loading\"\n                [label]=\"'platformSmartFilterBar.submitButtonLabel' | fdTranslate\"\n            ></button>\n        }\n        <button\n            fd-button\n            (click)=\"submitForm()\"\n            fd-toolbar-item\n            glyph=\"synchronize\"\n            [disabled]=\"loading\"\n            [ariaLabel]=\"'platformSmartFilterBar.refreshButtonAriaLabel' | fdTranslate\"\n        ></button>\n        <button\n            fd-button\n            (click)=\"showFilteringSettings()\"\n            [label]=\"\n                'platformSmartFilterBar.filtersButtonLabel' | fdTranslate: { filtersCount: selectedFiltersCount$() }\n            \"\n            fd-toolbar-item\n            [disabled]=\"loading\"\n        ></button>\n        <button\n            fd-button\n            (click)=\"toggleFilterBar()\"\n            [label]=\"\n                (showFilterBar$()\n                    ? 'platformSmartFilterBar.hideFiltersButtonLabel'\n                    : 'platformSmartFilterBar.showFiltersButtonLabel'\n                ) | fdTranslate\n            \"\n            fdType=\"transparent\"\n            fd-toolbar-item\n            [disabled]=\"loading\"\n        ></button>\n    </fd-toolbar>\n}\n@if (_formItems(); as formItems) {\n    <div class=\"fdp-smart-filter-bar__filters\" fd-toolbar-item [hidden]=\"!showFilterBar$()\">\n        <fdp-form-generator\n            (formCreated)=\"_onFormCreated()\"\n            (formSubmitted)=\"_onFormSubmitted($event)\"\n            [noAdditionalContent]=\"true\"\n            [formItems]=\"formItems\"\n            [columnLayout]=\"filtersColumnLayout\"\n        ></fdp-form-generator>\n    </div>\n}\n", styles: [".fdp-smart-filter-bar{display:block;box-shadow:var(--sapContent_HeaderShadow);background-color:var(--sapObjectHeader_Background)}.fdp-smart-filter-bar--transparent{background-color:var(--sapToolbar_Background);box-shadow:none}.fdp-smart-filter-bar .fd-toolbar--title{height:3rem;min-height:3rem;border-bottom:none;padding:.5rem}@media(min-width:600px){.fdp-smart-filter-bar .fd-toolbar--title{padding-left:2rem;padding-right:2rem}}.fdp-smart-filter-bar .fd-toolbar fdp-search-field{min-width:15.5rem}.fdp-smart-filter-bar .fdp-smart-filter-bar__filters{padding-left:.5rem;padding-right:.5rem}@media(min-width:600px){.fdp-smart-filter-bar .fdp-smart-filter-bar__filters{padding-left:2rem;padding-right:2rem}}.fdp-smart-filter-bar .fd-container.fd-form-layout-grid-container{padding:0}.fdp-smart-filter-bar .fd-container.fd-form-layout-grid-container .fd-row .fd-form-group{padding-left:.25rem!important;padding-right:.25rem!important}.fdp-smart-filter-bar__conditions-dialog .fdp-smart-filter-bar__actions-column{min-width:auto;flex:0 0 auto}.fdp-smart-filter-bar__conditions-dialog .fd-popover-custom{display:block}.fdp-smart-filter-bar__conditions-dialog .fd-dialog__body{padding:0 .5rem;background-color:var(--sapBackgroundColor, #f7f7f7)}.fdp-smart-filter-bar__conditions-dialog .fd-container.fd-form-layout-grid-container,.fdp-smart-filter-bar__conditions-dialog .fd-container.fd-form-layout-grid-container .fd-row .fd-form-group{padding-top:0!important;padding-bottom:0!important}.fdp-smart-filter-bar .fd-toolbar{--fdToolbar_Border: none}\n"] }]
        }], ctorParameters: () => [{ type: i1$1.DialogService }, { type: i1.FormGeneratorService }, { type: i0.Injector }, { type: i0.DestroyRef }], propDecorators: { _formGenerator: [{
                type: ViewChild,
                args: [FormGeneratorComponent]
            }], subject: [{
                type: Input
            }], transparent: [{
                type: Input,
                args: [{ transform: booleanAttribute }]
            }], filtersColumnLayout: [{
                type: Input
            }], liveUpdate: [{
                type: Input,
                args: [{ transform: booleanAttribute }]
            }], hideToolbar: [{
                type: Input,
                args: [{ transform: booleanAttribute }]
            }], smartFiltersChanged: [{
                type: Output
            }], smartFiltersApplied: [{
                type: Output
            }], searchInputChanged: [{
                type: Output
            }], _toolbarItemRefs: [{
                type: ContentChildren,
                args: [SmartFilterBarToolbarItemDirective]
            }] } });

const smartFilterBarProvider = {
    provide: SmartFilterBar,
    useExisting: forwardRef(() => SmartFilterBarComponent)
};

const components = [
    SmartFilterBarComponent,
    SmartFilterBarSettingsDialogComponent,
    SmartFilterBarFieldDefinitionDirective,
    SmartFilterBarSubjectDirective,
    SmartFilterBarConditionsDialogComponent,
    SmartFilterBarConditionFieldComponent,
    SmartFilterBarToolbarItemDirective
];
/**
 * @deprecated
 * Use direct imports of components and directives.
 */
class PlatformSmartFilterBarModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: PlatformSmartFilterBarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.1.0", ngImport: i0, type: PlatformSmartFilterBarModule, imports: [SmartFilterBarComponent,
            SmartFilterBarSettingsDialogComponent,
            SmartFilterBarFieldDefinitionDirective,
            SmartFilterBarSubjectDirective,
            SmartFilterBarConditionsDialogComponent,
            SmartFilterBarConditionFieldComponent,
            SmartFilterBarToolbarItemDirective], exports: [SmartFilterBarComponent,
            SmartFilterBarSettingsDialogComponent,
            SmartFilterBarFieldDefinitionDirective,
            SmartFilterBarSubjectDirective,
            SmartFilterBarConditionsDialogComponent,
            SmartFilterBarConditionFieldComponent,
            SmartFilterBarToolbarItemDirective] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: PlatformSmartFilterBarModule, imports: [SmartFilterBarComponent,
            SmartFilterBarSettingsDialogComponent,
            SmartFilterBarConditionsDialogComponent,
            SmartFilterBarConditionFieldComponent] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: PlatformSmartFilterBarModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [...components],
                    exports: [...components]
                }]
        }] });

/**
 * Generated bundle index. Do not edit.
 */

export { BaseSmartFilterBarConditionField, PlatformSmartFilterBarModule, SMART_FILTER_BAR_RENDERER_COMPONENT, SmartFilterBar, SmartFilterBarComponent, SmartFilterBarConditionFieldComponent, SmartFilterBarConditionsDialogComponent, SmartFilterBarFieldDefinitionDirective, SmartFilterBarService, SmartFilterBarSettingsDialogComponent, SmartFilterBarSubjectDirective, SmartFilterBarToolbarItemDirective, smartFilterBarProvider };
//# sourceMappingURL=fundamental-ngx-platform-smart-filter-bar.mjs.map
