// (C) 2024-2026 GoodData Corporation
import { compact } from "lodash-es";
import { DashboardAttributeFilterConfigModeValues, DashboardDateFilterConfigModeValues, dashboardAttributeFilterItemLocalIdentifier, isDashboardAttributeFilterItem, isDashboardCommonDateFilter, isDashboardDateFilter, } from "@gooddata/sdk-model";
import { useFiltersNamings } from "../../../../_staging/sharedHooks/useFiltersNamings.js";
import { useDashboardSelector } from "../../../../model/react/DashboardStoreProvider.js";
import { selectEffectiveAttributeFiltersModeMap } from "../../../../model/store/tabs/attributeFilterConfigs/attributeFilterConfigsSelectors.js";
import { selectEffectiveDateFilterMode } from "../../../../model/store/tabs/dateFilterConfig/dateFilterConfigSelectors.js";
import { selectEffectiveDateFiltersModeMap } from "../../../../model/store/tabs/dateFilterConfigs/dateFilterConfigsSelectors.js";
export const useFiltersForDashboardScheduledExportInfo = ({ effectiveFilters = [], }) => {
    // Remove hidden dashboard filters, we don't want to display them.
    const commonDateFilterMode = useDashboardSelector(selectEffectiveDateFilterMode);
    const dateFiltersModeMap = useDashboardSelector(selectEffectiveDateFiltersModeMap);
    const attributeFiltersModeMap = useDashboardSelector(selectEffectiveAttributeFiltersModeMap);
    const filtersToDisplay = removeHiddenFilters(effectiveFilters, commonDateFilterMode, dateFiltersModeMap, attributeFiltersModeMap);
    return compact(useFiltersNamings(filtersToDisplay));
};
const removeHiddenFilters = (filters, commonDateFilterMode, dateFiltersModeMap, attributeFiltersModeMap) => {
    return filters.filter((filter) => {
        if (isDashboardCommonDateFilter(filter)) {
            return commonDateFilterMode !== DashboardDateFilterConfigModeValues.HIDDEN;
        }
        else if (isDashboardDateFilter(filter) && filter.dateFilter.localIdentifier) {
            const mode = dateFiltersModeMap.get(filter.dateFilter.localIdentifier);
            return mode !== DashboardDateFilterConfigModeValues.HIDDEN;
        }
        else if (isDashboardAttributeFilterItem(filter)) {
            const localIdentifier = dashboardAttributeFilterItemLocalIdentifier(filter);
            const mode = localIdentifier ? attributeFiltersModeMap.get(localIdentifier) : undefined;
            return mode !== DashboardAttributeFilterConfigModeValues.HIDDEN;
        }
        return true;
    });
};
//# sourceMappingURL=useFiltersForDashboardScheduledExportInfo.js.map