'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "useImageExport", {
    enumerable: true,
    get: function() {
        return useImageExport;
    }
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _imageexportutils = require("./image-export-utils");
const _utilities = require("./utilities");
const useImageExport = (componentRef, hideLegends, isChartCartesian = true)=>{
    const cartesianChartRef = _react.useRef(null);
    const chartContainerRef = _react.useRef(null);
    const legendsRef = _react.useRef(null);
    const isRTL = (0, _utilities.useRtl)();
    _react.useImperativeHandle(componentRef, ()=>{
        var _cartesianChartRef_current;
        const chartContainer = isChartCartesian ? (_cartesianChartRef_current = cartesianChartRef.current) === null || _cartesianChartRef_current === void 0 ? void 0 : _cartesianChartRef_current.chartContainer : chartContainerRef.current;
        return {
            chartContainer: chartContainer !== null && chartContainer !== void 0 ? chartContainer : null,
            toImage: (opts)=>{
                var _legendsRef_current;
                return (0, _imageexportutils.exportChartsAsImage)([
                    {
                        container: chartContainer
                    }
                ], hideLegends ? undefined : (_legendsRef_current = legendsRef.current) === null || _legendsRef_current === void 0 ? void 0 : _legendsRef_current.toSVG, isRTL, opts);
            }
        };
    }, [
        hideLegends,
        isChartCartesian,
        isRTL
    ]);
    return {
        cartesianChartRef,
        chartContainerRef,
        legendsRef
    };
};
