// (C) 2020-2026 GoodData Corporation
import { isLocalIdRef, } from "@gooddata/sdk-model";
import { getDisabledOptionProps, getDisplayFormTitle, hasMatchingTargetDashboardAttributeFilterDisplayForm, isDateIntersectionAttribute, } from "../drillFiltersConfigUtils.js";
import { messages } from "../messages.js";
export function mapIntersectionAttributeToOption({ insightAttribute, allCatalogDisplayFormsMap, allCatalogDateAttributeDisplayForms, targetDashboardAttributeFilters, isDrillToDashboard, intl, }) {
    const displayFormRef = insightAttribute.attribute.displayForm;
    const isDateAttribute = isDateIntersectionAttribute(displayFormRef, allCatalogDateAttributeDisplayForms);
    const hasMatchingTargetFilter = isLocalIdRef(displayFormRef) ||
        hasMatchingTargetDashboardAttributeFilterDisplayForm(displayFormRef, targetDashboardAttributeFilters);
    return {
        id: insightAttribute.attribute.localIdentifier,
        title: getDisplayFormTitle({
            displayFormRef,
            allCatalogDisplayFormsMap,
        }),
        ...getDisabledOptionProps(isDrillToDashboard && (isDateAttribute || !hasMatchingTargetFilter), intl.formatMessage(isDateAttribute
            ? messages.drillToDashboardDateIntersectionTooltip
            : messages.drillToDashboardDashboardFilterTooltip), false),
    };
}
//# sourceMappingURL=mapIntersectionAttributeToOption.js.map