import { jsx as _jsx } from "react/jsx-runtime";
import { useDashboardSelector } from "../../../../model/react/DashboardStoreProvider.js";
import { selectInsightsMap } from "../../../../model/store/insights/insightsSelectors.js";
// Sometimes this component is rendered even before insights are ready, which blows up.
// Since the behavior is nearly impossible to replicate reliably, let's be defensive here and not render
// anything until the insights "catch up".
export function DashboardWidgetInsightGuard(props) {
    const { widget, Component } = props;
    const insights = useDashboardSelector(selectInsightsMap);
    const insight = insights.get(widget.insight);
    return _jsx(Component, { ...props, insight: insight });
}
//# sourceMappingURL=DashboardWidgetInsightGuard.js.map