// (C) 2025-2026 GoodData Corporation
import { useEffect, useMemo, useState } from "react";
import { fillMissingTitles } from "@gooddata/sdk-ui";
import { useDashboardSelector } from "../../../model/react/DashboardStoreProvider.js";
import { selectCatalogDateDatasets } from "../../../model/store/catalog/catalogSelectors.js";
import { selectEnableComparisonInAlerting, selectLocale, } from "../../../model/store/config/configSelectors.js";
import { getSupportedInsightMeasuresByInsight } from "../DefaultAlertingDialog/utils/items.js";
/**
 * Hook that calculates supported alertable measures for an insight.
 *
 * @param insight - The insight to check for alertable measures
 * @returns Array of supported measures that can be used for alerting
 * @internal
 */
export const useGetSupportedMeasures = (insight) => {
    const catalogDateDatasets = useDashboardSelector(selectCatalogDateDatasets);
    const canManageComparison = useDashboardSelector(selectEnableComparisonInAlerting);
    const locale = useDashboardSelector(selectLocale);
    const [effectiveInsight, setEffectiveInsight] = useState(undefined);
    useEffect(() => {
        if (insight) {
            void fillMissingTitles(insight, locale, 9999).then(setEffectiveInsight);
        }
    }, [insight, locale]);
    return useMemo(() => getSupportedInsightMeasuresByInsight(effectiveInsight, catalogDateDatasets, canManageComparison), [effectiveInsight, catalogDateDatasets, canManageComparison]);
};
//# sourceMappingURL=useGetSupportedMeasures.js.map