import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2020-2026 GoodData Corporation
import { useCallback, useState } from "react";
import { useRichTextExportData, useVisualizationExportData } from "../../export/useExportData.js";
import { ViewModeDashboardRichText } from "./ViewModeDashboardRichText.js";
export function ExportModeDashboardRichText(props) {
    const { onLoadingChanged, onError } = props;
    const [isVisualizationInitializing, setIsVisualizationInitializing] = useState(true);
    const [error, setError] = useState(undefined);
    const exportDataText = useVisualizationExportData(props.exportData, isVisualizationInitializing, !!error);
    const exportRichText = useRichTextExportData();
    const onLoadingChangedHandler = useCallback((loading) => {
        setIsVisualizationInitializing(loading.isLoading);
        onLoadingChanged?.(loading);
    }, [onLoadingChanged]);
    const onErrorHandler = useCallback((error) => {
        setIsVisualizationInitializing(false);
        setError(error);
        onError?.(error);
    }, [onError]);
    return (_jsx("div", { ...exportDataText, className: "gd-rich-text-widget-export-container", children: _jsx(ViewModeDashboardRichText, { ...props, richTextExportData: exportRichText, onLoadingChanged: onLoadingChangedHandler, onError: onErrorHandler }) }));
}
