/* @oracle/oraclejet-preact: undefined */
'use strict';

var jsxRuntime = require('preact/jsx-runtime');
var PRIVATE_Chart_themes_ChartStyles_css = require('./PRIVATE_Chart/themes/ChartStyles.css.js');
var TrackResizeContainer = require('./TrackResizeContainer-96619aba.js');
var useTextDimensions = require('./useTextDimensions-b94e8899.js');
var useCssVars = require('./useCssVars-99ce6e96.js');
var hooks = require('preact/hooks');
var Gridlines = require('./Gridlines-a64f52a4.js');
var useId = require('./useId-6c0eeb27.js');
var Axis = require('./Axis-6d1bb36a.js');
var useChartViewport = require('./useChartViewport-f23f2397.js');
var layoutUtils$1 = require('./layoutUtils-0615d614.js');
var useChartNav = require('./useChartNav-03cfc71a.js');
var mergeProps = require('./mergeProps-e3da7237.js');
var ScrollBar = require('./ScrollBar-dc5cf205.js');
var useSelectDrill = require('./useSelectDrill-7a60b9e6.js');
var useUser = require('./useUser-c85f9587.js');
var useTestId = require('./useTestId-32c35bff.js');
var cssUtils = require('./cssUtils-dd39857c.js');
var useChartContextMenu = require('./useChartContextMenu-deb506be.js');
var useChartDnd = require('./useChartDnd-765ad341.js');
var eventsUtils = require('./eventsUtils-1abb6028.js');
require('./accUtils-dcffb3de.js');
var layoutUtils = require('./layoutUtils-c2c02501.js');
var useTooltip = require('./useTooltip-cf4a15f3.js');
require('./logger-2b636482.js');
require('./LayerHost-8ec73638.js');
require('preact/compat');


require('./hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentVariants.css.js');
require('./tooltipUtils-d461919d.js');
var useChartMarquee = require('./useChartMarquee-7ffcda9e.js');
var useVisTouchResponse = require('./useVisTouchResponse-376e11d5.js');
var stringUtils = require('./stringUtils-4e4a6b2b.js');
var useOverviewContext = require('./useOverviewContext-1732a3f1.js');
var scale = require('./scale-22a7b539.js');
var OverviewSlidingWindow = require('./OverviewSlidingWindow-7719ad86.js');
var PRIVATE_VisOverview_themes_VisOverview_css = require('./PRIVATE_VisOverview/themes/VisOverview.css.js');

function getNextGroup(info, viewportEndIndex, isGroupNavigable) {
    const groupIndex = info.groupIndex + 1;
    if (groupIndex >= viewportEndIndex) {
        return;
    }
    if (isGroupNavigable(groupIndex)) {
        return { groupIndex };
    }
    return getNextGroup({ groupIndex }, viewportEndIndex, isGroupNavigable);
}
function getPreviousGroup(info, isGroupNavigable) {
    const groupIndex = info.groupIndex - 1;
    if (groupIndex < 0) {
        return;
    }
    if (isGroupNavigable(groupIndex)) {
        return { groupIndex };
    }
    return getPreviousGroup({ groupIndex }, isGroupNavigable);
}
function getGroupNavUtil(groups, renderedGroups, xIndexExtent, drilling, isRtl) {
    const isGroupNavigable = (groupIndex) => {
        const groupsDrilling = groups[renderedGroups[groupIndex]].drilling;
        return (drilling === 'on' || drilling === 'groupsOnly') && groupsDrilling != 'off';
    };
    const getDefaultNavGroup = (info) => {
        if (xIndexExtent.startIndex > renderedGroups[info.groupIndex]) {
            info.groupIndex = 0;
            return info;
        }
        else if (xIndexExtent.endIndex < renderedGroups[info.groupIndex]) {
            info.groupIndex = renderedGroups.length - 1;
            return info;
        }
        return;
    };
    const getNextNavGroup = (info, arrow) => {
        let nextGroup = getDefaultNavGroup(info);
        if (nextGroup)
            return nextGroup;
        if (arrow === 'ArrowRight') {
            nextGroup = isRtl
                ? getPreviousGroup(info, isGroupNavigable)
                : getNextGroup(info, renderedGroups.length, isGroupNavigable);
        }
        else {
            nextGroup = isRtl
                ? getNextGroup(info, renderedGroups.length, isGroupNavigable)
                : getPreviousGroup(info, isGroupNavigable);
        }
        return nextGroup || info;
    };
    return { getDefaultNavGroup, getNextNavGroup };
}

/**
 * @license
 * Copyright (c) %FIRST_YEAR% %CURRENT_YEAR%, Oracle and/or its affiliates.
 * Licensed under The Universal Permissive License (UPL), Version 1.0
 * as shown at https://oss.oracle.com/licenses/upl/
 * @ignore
 */
function useTextTruncation({ getTextAndBounds, width, isRtl }) {
    const [text, setText] = hooks.useState();
    const bounds = hooks.useRef();
    const { tooltipContent, tooltipProps } = useTooltip.useTooltip({
        text,
        position: 'top-start',
        offset: layoutUtils.calculateOffset(isRtl, width, bounds.current)
    });
    const onPointerMove = (event) => {
        const textAndBounds = getTextAndBounds(event.target);
        if (textAndBounds) {
            bounds.current = textAndBounds.bounds;
            setText(textAndBounds.text);
        }
        else {
            setText(undefined);
        }
    };
    return {
        tooltipContent,
        tooltipProps: mergeProps.mergeProps({ onPointerMove }, tooltipProps)
    };
}

/**
 * @license
 * Copyright (c) %FIRST_YEAR% %CURRENT_YEAR%, Oracle and/or its affiliates.
 * Licensed under The Universal Permissive License (UPL), Version 1.0
 * as shown at https://oss.oracle.com/licenses/upl/
 * @ignore
 */
function getWindowCoords(isRtl, xViewportExtent, xAxisExtent, yViewportExtent, yAxisExtent, plotAreaSpace) {
    const xDomain = [xAxisExtent.min, xAxisExtent.max];
    const xRange = (isRtl
        ? [plotAreaSpace.x + plotAreaSpace.width, plotAreaSpace.x]
        : [plotAreaSpace.x, plotAreaSpace.x + plotAreaSpace.width]);
    const xScale = new scale.ScaleLinear(xDomain, xRange);
    const yDomain = [yAxisExtent.min, yAxisExtent.max];
    const yRange = [plotAreaSpace.y + plotAreaSpace.height, plotAreaSpace.y];
    const yScale = new scale.ScaleLinear(yDomain, yRange);
    const windowX = xScale.transform(xViewportExtent.viewportMin);
    const windowWidth = Math.abs(xScale.transform(xViewportExtent.viewportMax) - xScale.transform(xViewportExtent.viewportMin));
    return {
        windowX: isRtl ? windowX - windowWidth : windowX + 0.5,
        windowWidth: windowWidth - 0.5,
        windowY: yScale.transform(yViewportExtent.viewportMax),
        windowHeight: Math.abs(yScale.transform(yViewportExtent.viewportMax) - yScale.transform(yViewportExtent.viewportMin)),
        xScale,
        yScale
    };
}

function OverviewBackground({ x, width, height, y, windowX, windowHeight, windowWidth, windowY }) {
    return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("rect", { x: x, y: y, width: Math.max(0, windowX - x), height: height, class: PRIVATE_VisOverview_themes_VisOverview_css.styles.overviewBackground }), jsxRuntime.jsx("rect", { x: windowX + windowWidth, width: Math.max(0, x + width - windowX - windowWidth), y: y, height: height, class: PRIVATE_VisOverview_themes_VisOverview_css.styles.overviewBackground }), jsxRuntime.jsx("rect", { x: windowX, y: y, height: Math.max(0, windowY - y), width: windowWidth, class: PRIVATE_VisOverview_themes_VisOverview_css.styles.overviewBackground }), jsxRuntime.jsx("rect", { x: windowX, y: windowY + windowHeight, width: windowWidth, class: PRIVATE_VisOverview_themes_VisOverview_css.styles.overviewBackground, height: Math.max(y + height - windowY - windowHeight, 0) })] }));
}

function getRenderer(xAxisExtent, isRtl, overviewXScale, plotAreaSpace, windowCoords, hasHandles, onViewportChange) {
    return {
        slidingWindow: (jsxRuntime.jsx(OverviewSlidingWindow.OverviewSlidingWindow, { ...plotAreaSpace, ...windowCoords, hasHandles: hasHandles, onWindowDimsChange: (props) => {
                layoutUtils$1.updateViewportFromOverview(xAxisExtent, isRtl, windowCoords.windowX, windowCoords.windowWidth, props.deltaX, props.deltaWidth, overviewXScale, onViewportChange);
            } })),
        background: jsxRuntime.jsx(OverviewBackground, { ...plotAreaSpace, ...windowCoords })
    };
}

const OVERVIEW_GAP = 10;
const chartVars = cssUtils.getChartVars();
function ChartWithDimensions({ width, height, selectedIds, hiddenIds, hideAndShowBehavior = 'none', orientation = 'vertical', xAxis, yAxis, plotArea, dragMode = 'user', series, groups, isStacked = false, getDataItem, selectionMode = 'none', drilling = 'off', dataCursorPosition, onSelectionChange, isDataCursorEnabled, dataCursorStyle, onViewportChange, onDataCursorPositionChange, onItemDrill, onGroupDrill, onItemHover, onItemFocus, datatip, zoomAndScroll = 'off', offset, getNavUtil, getDataItemPos, getGapRatio, valueFormats, findNearest, getMarkerInfo, isRtl, children, testId, renderGridLinesInFront, isDataXAxis, contextMenuConfig, overview = 'off', defaultOverviewContentRenderer, isOverview, yAxisSize, overviewRenderer, ...props }) {
    const testIdProps = useTestId.useTestId(testId);
    const rootRef = hooks.useRef(null);
    const isTestEnv = testIdProps['data-testid'] !== undefined;
    const isHoriz = orientation === 'horizontal';
    const { xAxisPosition, yAxisPosition } = layoutUtils$1.getAxesPosition(yAxis, isHoriz, isRtl);
    const { resolvedVars, cssContent } = useCssVars.useCssVars(chartVars);
    const colors = Array.from(Array(12)).map((_, index) => {
        return resolvedVars[`color${index + 1}`];
    });
    const { textMeasureContent, getTextDimensions } = useTextDimensions.useTextDimensions();
    let availSpace = layoutUtils$1.getAvailSpace(width, height);
    if (isOverview && yAxisSize) {
        const w = availSpace.width - yAxisSize;
        const gaps = layoutUtils$1.getOuterGaps(w, height);
        availSpace.width -= yAxisSize - 2 * gaps.width;
        availSpace.x += yAxisSize - gaps.width;
    }
    const isTimeAxis = xAxis?.timeAxisType != null;
    const updatedSpace = layoutUtils$1.getScrollBarSpace(isTimeAxis, availSpace, zoomAndScroll, xAxisPosition, overview);
    let scrollDims = updatedSpace.scrollDims;
    availSpace = updatedSpace.availSpace;
    const { locale } = useUser.useUser();
    const { x, y, width: _width, height: _height } = availSpace;
    const labelFontSize = resolvedVars['labelFontSize'];
    const layoutInfo = hooks.useMemo(() => {
        const hiddenSet = new Set(hiddenIds);
        return layoutUtils$1.getLayoutInfo(series, groups, getDataItem, xAxis, yAxis, { x, y, width: _width, height: _height }, // availSpace
        hiddenSet, hideAndShowBehavior, isHoriz, isRtl, isStacked, labelFontSize, offset, locale, getTextDimensions, isTestEnv, isDataXAxis);
    }, [
        x,
        y,
        _width,
        _height,
        getDataItem,
        getTextDimensions,
        groups,
        hiddenIds,
        hideAndShowBehavior,
        isDataXAxis,
        isHoriz,
        isRtl,
        isStacked,
        isTestEnv,
        locale,
        offset,
        labelFontSize,
        series,
        xAxis,
        yAxis
    ]);
    const { xProps, xScale, xViewportExtent, xAxisExtent, xIndexExtent, xAxisMinExtent, yViewportExtent, yAxisExtent, groupWidth, yProps, yScale, yMaxDim, yMajorTicks, xMajorTicks, yMinorTicks, xMinorTicks, plotAreaSpace, xSpace, ySpace, idToDataMap, formatAxisLabel, formatYValue } = layoutInfo;
    scrollDims = layoutUtils$1.updateScrollBarSpace(scrollDims, xAxisPosition === 'bottom', isRtl, yMaxDim);
    const gapRatio = getGapRatio(xIndexExtent.startIndex, xIndexExtent.endIndex);
    const getNextChartItem = getNavUtil(xIndexExtent.startIndex, xIndexExtent.endIndex);
    const renderedGroupsIndex = xProps.tickLabels.map(({ index }) => index + xIndexExtent.startIndex);
    const { getNextNavGroup, getDefaultNavGroup } = getGroupNavUtil(groups, renderedGroupsIndex, xIndexExtent, // TODO : JET-71301 | Scatter should have different nav utils call.
    drilling, isRtl);
    const { ignoreSelectPointerUp, cursor, yAxisCursor, marqueeProps, marqueeContent, toggleButtonContent, isPointInsideMarquee, dragMode: mode } = useChartMarquee.useChartMarquee({
        plotAreaSpace,
        xSpace,
        ySpace,
        dragMode,
        chartWidth: width,
        isMultiSelection: selectionMode === 'multiple',
        onViewportChange,
        isZoomScroll: zoomAndScroll === 'live',
        xAxisExtent,
        xScale,
        selectedIds,
        getDataById: (id) => idToDataMap.get(id),
        onSelectionChange,
        viewportMax: xViewportExtent.viewportMax,
        viewportMin: xViewportExtent.viewportMin,
        isRtl,
        xAxisMinExtent
    });
    const { touchResponse, touchResponseStyle } = useVisTouchResponse.useVisTouchResponse({
        type: 'auto',
        supportsTouchDragGestures: mode !== 'off',
        rootRef
    });
    const { activeId, focusedItemInfo, hoveredItemInfo, focusedGroupInfo, navProps, onFocusUpdate } = useChartNav.useChartNav({
        rootRef,
        getNextChartItem,
        getNextNavGroup,
        getDefaultNavGroup,
        touchResponse,
        onItemHover,
        onItemFocus,
        drilling,
        xIndexExtent
    });
    const onContextMenuDismissed = (gesture) => {
        if (gesture === 'keyboard') {
            onFocusUpdate();
        }
    };
    const getTextAndBounds = (target) => {
        if (target != rootRef.current) {
            const dataSet = eventsUtils.getElementData(rootRef, target);
            const text = dataSet?.['ojText'];
            if (!text) {
                return;
            }
            if (text === xAxis?.title) {
                return {
                    text,
                    bounds: xProps.titleProps?.dims
                };
            }
            else if (text === yAxis?.title) {
                return {
                    text,
                    bounds: yProps.titleProps?.dims
                };
            }
            else if (dataSet?.['ojGroupIndex']) {
                const index = parseInt(dataSet['ojGroupIndex']);
                return {
                    bounds: xProps.tickLabels[index].dims,
                    text: text
                };
            }
        }
        if (target === rootRef.current && focusedGroupInfo.isFocusVisible) {
            const group = groups[focusedGroupInfo.groupIndex];
            return {
                bounds: xProps.tickLabels[focusedGroupInfo.groupIndex].dims,
                text: group.name || group.id
            };
        }
        return;
    };
    const { tooltipContent, tooltipProps } = useTextTruncation({
        getTextAndBounds,
        width,
        isRtl
    });
    const viewportProps = useChartViewport.useChartViewport({
        rootRef,
        width,
        height,
        xViewportExtent,
        yViewportExtent,
        xAxisExtent,
        yAxisExtent,
        xScale,
        yScale,
        plotAreaSpace,
        isRtl,
        isHoriz,
        zoomAndScroll,
        onViewportChange
    });
    const ignoreAsTrigger = (target) => {
        if (!target) {
            return false;
        }
        const dataset = eventsUtils.getElementData(rootRef, target);
        if ((dataset &&
            (dataset['ojPrivateObject'] === 'marquee' ||
                dataset['ojPrivateObject'] === 'dragModeControls' ||
                dataset['ojPrivateObject'] === 'scrollBar')) ||
            ignoreSelectPointerUp) {
            return true;
        }
        return false;
    };
    const { selectDrillProps, selectionContent } = useSelectDrill.useSelectDrill({
        selectionMode,
        selection: [...selectedIds],
        onChange: onSelectionChange,
        rootRef,
        drilling,
        onItemDrill,
        onGroupDrill,
        focusedGroupInfo,
        focusedItemInfo,
        groups,
        getDataItem,
        getDataById: (id) => idToDataMap.get(id),
        ignoreAsTrigger
    });
    const findNearestData = findNearest(xScale, yScale, groupWidth, gapRatio);
    const getDataItemPosition = getDataItemPos(xScale, yScale, groupWidth, gapRatio);
    const [datatipDisabled, setDatatipDisabled] = hooks.useState(false);
    const { datatipContent, dataCursorContent, datatipProps: { 'aria-describedby': datatipAriaDescribedby, ...datatipProps } } = useSelectDrill.useChartDatatipAndCursor({
        series,
        groups,
        width,
        height,
        findNearest: findNearestData,
        plotAreaSpace,
        onDataCursorPositionChange,
        isDataCursorEnabled,
        dataCursorPosition,
        dataCursorStyle,
        hoveredItemInfo,
        focusedItemInfo,
        getDataItem,
        getMarkerInfo,
        getDataItemPos: getDataItemPosition,
        datatip,
        valueFormats,
        isHoriz,
        touchResponse,
        isDisabled: datatipDisabled,
        xScale: xScale,
        yScale,
        timeAxisType: xAxis?.timeAxisType,
        formatAxisLabel,
        formatYValue,
        hasXYValues: isDataXAxis
    });
    const isGroupInteractive = (index) => {
        if (xAxis?.timeAxisType != null) {
            return false;
        }
        const groupDrill = groups[index]?.drilling;
        if (groupDrill === 'on') {
            return true;
        }
        if (groupDrill != 'off' && (drilling === 'on' || drilling === 'groupsOnly')) {
            return true;
        }
        return false;
    };
    const plotAreaClipPathId = useId.useId();
    const { startIndex: xStartIndex, endIndex: xEndIndex } = xIndexExtent;
    const gridLines = (jsxRuntime.jsx(Gridlines.Gridlines, { plotArea: plotArea, yMinorTicks: yMinorTicks, xMinorTicks: xMinorTicks, xScale: xScale, yScale: yScale, isLog: yAxis?.scale === 'log', yTicks: yMajorTicks, xTicks: xMajorTicks, yAxisPosition: yAxisPosition, isDataXAxis: isDataXAxis }));
    const hasData = series.length > 0 && groups.length > 0;
    const { contextMenuContent, contextMenuProps } = useChartContextMenu.useChartContextMenu({
        isRtl,
        width,
        height,
        getDataItemPosition,
        series,
        groups,
        getDataItem,
        focusedItemInfo,
        rootRef,
        xAxisTitle: xAxis?.title,
        yAxisTitle: yAxis?.title,
        contextMenuConfig: hasData ? contextMenuConfig : undefined,
        onContextMenuDismissed
    });
    const [dragOver, setDragOver] = hooks.useState({
        accepted: undefined,
        type: ''
    });
    const { draggable, dndProps, dndContent } = useChartDnd.useChartDnd({
        onDrag: props.onDrag,
        onDragStart: props.onDragStart,
        onDragEnd: props.onDragEnd,
        onDragEnter: props.onDragEnter,
        onDragLeave: props.onDragLeave,
        onDragOver: props.onDragOver,
        onDrop: props.onDrop,
        itemsDraggable: props.itemsDraggable,
        groupDraggable: props.groupDraggable,
        rootRef,
        groups,
        series,
        selectedIds,
        getDataItem,
        xSpace,
        ySpace,
        plotAreaSpace,
        setDragOver,
        setDatatipDisabled,
        onSelectionChange
    });
    const eventsProps = mergeProps.mergeProps(navProps, selectDrillProps, viewportProps, datatipProps, marqueeProps, tooltipProps, contextMenuProps, dndProps);
    const overviewContentRenderer = overview != 'off' && (overview === 'on' || !overview.renderer)
        ? defaultOverviewContentRenderer
        : undefined;
    const { background, slidingWindow } = overviewRenderer(plotAreaSpace);
    return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [getTextDimensions && resolvedVars['labelFontSize'] != undefined && (jsxRuntime.jsxs("div", { tabIndex: isOverview ? undefined : 0, draggable: draggable, ref: rootRef, "aria-activedescendant": activeId, "aria-label": props['aria-label'], "aria-labelledby": props['aria-labelledby'], "aria-describedby": stringUtils.merge([props['aria-describedby'], datatipAriaDescribedby]), style: { ...touchResponseStyle }, role: isOverview ? undefined : 'application', className: PRIVATE_Chart_themes_ChartStyles_css.styles.baseChartStyle, "data-oj-private-selection-mode": isTestEnv ? selectionMode : undefined, ...testIdProps, ...(isOverview ? {} : eventsProps), children: [jsxRuntime.jsxs("svg", { width: "100%", height: scrollDims.height != 0 && overview != 'off'
                            ? `${Math.ceil((updatedSpace.availSpace.height + OVERVIEW_GAP) * 100) / height}%`
                            : '100%', children: [jsxRuntime.jsx("clipPath", { id: `${plotAreaClipPathId}`, children: jsxRuntime.jsx("rect", { ...plotAreaSpace }) }), background, jsxRuntime.jsx(Gridlines.PlotArea, { color: plotArea?.color, dragOverStyle: dragOver.type !== 'plotArea' ? 'none' : dragOver.accepted ? 'accept' : 'reject', yScale: yScale, hasAxisLine: !isOverview, cursor: cursor, isLog: yAxis?.scale === 'log', availSpace: plotAreaSpace, xAxisPosition: xAxisPosition, isDataXAxis: isDataXAxis, isRtl: isRtl }), !renderGridLinesInFront && gridLines, jsxRuntime.jsx(Axis.Axis, { ...yProps, axisPosition: yAxisPosition, isRtl: isRtl, cursor: yAxisCursor, availSpace: ySpace, dragOverStyle: dragOver.type !== 'yAxis' ? 'none' : dragOver.accepted ? 'accept' : 'reject' }), jsxRuntime.jsx(Axis.Axis, { ...xProps, isRtl: isRtl, axisPosition: xAxisPosition, isTextInteractive: isGroupInteractive, activeId: activeId, cursor: cursor, focusedGroupIndex: focusedGroupInfo.isFocusVisible ? focusedGroupInfo.groupIndex : undefined, availSpace: xSpace, dragOverStyle: dragOver.type !== 'xAxis' ? 'none' : dragOver.accepted ? 'accept' : 'reject' }), jsxRuntime.jsxs("g", { "clip-path": `url(#${plotAreaClipPathId})`, children: [children({
                                        xStartIndex,
                                        xEndIndex,
                                        colors,
                                        xScale: xScale,
                                        yScale,
                                        isPointInsideMarquee,
                                        defaultFontSize: resolvedVars['labelFontSize'],
                                        gapRatio,
                                        activeId,
                                        focusedItemInfo,
                                        hoveredItemInfo,
                                        getTextDimensions,
                                        groupWidth
                                    }), renderGridLinesInFront && gridLines, dataCursorContent] }), slidingWindow, zoomAndScroll === 'live' && !isOverview && (jsxRuntime.jsx(ScrollBar.ScrollBar, { availSpace: scrollDims, isRtl: isRtl, viewport: xViewportExtent, axisExtent: xAxisExtent, isHoriz: xAxisPosition === 'bottom' })), marqueeContent] }), jsxRuntime.jsx(useOverviewContext.OverviewContext.Provider, { value: {
                            yAxisSize: ySpace.width,
                            isOverview: true,
                            width,
                            height: scrollDims.height,
                            overviewRenderer: (overviewChartPlotArea) => {
                                const { xScale: overviewXScale, ...windowCoords } = getWindowCoords(isRtl, xViewportExtent, xAxisExtent, yViewportExtent, yAxisExtent, overviewChartPlotArea);
                                return getRenderer(xAxisExtent, isRtl, overviewXScale, overviewChartPlotArea, windowCoords, true, onViewportChange);
                            }
                        }, children: !isOverview && overview !== 'off' && overviewContentRenderer && (jsxRuntime.jsx("div", { style: { width, height: scrollDims.height }, children: overviewContentRenderer() })) }), toggleButtonContent, datatipContent, tooltipContent, contextMenuContent, selectionContent, dndContent] })), textMeasureContent, cssContent] }));
}

function Chart({ width, height, ...props }) {
    // TODO: reevaluate how we handle empty data
    const { isOverview, overviewRenderer, yAxisSize, width: overviewWidth, height: overviewHeight } = useOverviewContext.useOverviewContext();
    let chartWidth = width;
    let chartHeight = height;
    if (chartWidth === undefined && isOverview && overviewWidth !== undefined) {
        chartWidth = `${overviewWidth}px`;
    }
    if (chartHeight === undefined && isOverview && overviewHeight !== undefined) {
        chartHeight = `${overviewHeight}px`;
    }
    return (jsxRuntime.jsx(TrackResizeContainer.TrackResizeContainer, { width: chartWidth, height: chartHeight, class: PRIVATE_Chart_themes_ChartStyles_css.dimensionStyle, children: (width, height) => width || height ? (jsxRuntime.jsx(ChartWithDimensions, { width: width, height: height, ...props, yAxisSize: yAxisSize, isOverview: isOverview, overviewRenderer: overviewRenderer })) : undefined }));
}

exports.Chart = Chart;
//# sourceMappingURL=Chart-13ccd345.js.map
