import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2025-2026 GoodData Corporation
import { useEffect } from "react";
import { widgetRef } from "@gooddata/sdk-model";
import { queryDateDatasetsForInsight, } from "../../../../model/queries/insights.js";
import { useDashboardSelector } from "../../../../model/react/DashboardStoreProvider.js";
import { useDashboardQueryProcessing } from "../../../../model/react/useDashboardQueryProcessing.js";
import { selectIsWidgetLoadingAdditionalDataByWidgetRef } from "../../../../model/store/ui/uiSelectors.js";
import { DateDatasetFilter } from "../../common/configuration/DateDatasetFilter.js";
import { useDateDatasetFilter } from "../../common/configuration/useDateDatasetFilter.js";
export function RichTextDateDataSetFilter({ widget }) {
    const { status, run: queryDateDatasets, result, } = useDashboardQueryProcessing({
        queryCreator: queryDateDatasetsForInsight,
    });
    const isLoadingAdditionalData = useDashboardSelector(selectIsWidgetLoadingAdditionalDataByWidgetRef(widgetRef(widget)));
    useEffect(() => {
        queryDateDatasets();
    }, [queryDateDatasets]);
    const { handleDateDatasetChanged, shouldOpenDateDatasetPicker } = useDateDatasetFilter(result?.dateDatasets);
    return (_jsx(DateDatasetFilter, { widget: widget, dateFilterCheckboxDisabled: false, isDatasetsLoading: status === "running" || status === "pending" || isLoadingAdditionalData, relatedDateDatasets: result?.dateDatasetsOrdered, isLoadingAdditionalData: isLoadingAdditionalData, shouldOpenDateDatasetPicker: shouldOpenDateDatasetPicker, onDateDatasetChanged: handleDateDatasetChanged }));
}
//# sourceMappingURL=RichTextDateDataSetFilter.js.map