// (C) 2024-2026 GoodData Corporation
import { useEffect, useMemo } from "react";
import { queryMetricsAndFacts, } from "../../model/queries/metricsAndFacts.js";
import { useDashboardQueryProcessing } from "../../model/react/useDashboardQueryProcessing.js";
/**
 * @internal
 */
export function useMetricsAndFacts() {
    const { run: getMetricsAndFacts, result: metricsAndFacts, status: metricsAndFactsLoadingStatus, error: metricsAndFactsLoadingError, } = useDashboardQueryProcessing({
        queryCreator: queryMetricsAndFacts,
    });
    useEffect(() => {
        getMetricsAndFacts();
    }, [getMetricsAndFacts]);
    const metricsAndFactsLoading = useMemo(() => {
        return metricsAndFactsLoadingStatus === "pending" || metricsAndFactsLoadingStatus === "running";
    }, [metricsAndFactsLoadingStatus]);
    return {
        metricsAndFacts,
        metricsAndFactsLoading,
        metricsAndFactsLoadingError,
    };
}
