import React from 'react';
import classnames from 'classnames';
import TabularDataTooltipRow from './tabular-data-tooltip-row';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/** Component providing easy to use structure for table in a chart tooltip */
export default function TabularDataTooltip({
  title,
  rows = [],
  extra = null,
  footer = null,
  testId = 'tabular-data-tooltip',
  className = ''
}) {
  const hasSymbol = rows.some(r => r.symbol);
  return /*#__PURE__*/_jsxs("div", {
    "test-id": testId,
    className: classnames('tabular-data-tooltip', className),
    children: [title && /*#__PURE__*/_jsx("div", {
      className: "tabular-data-tooltip-header",
      "test-id": "tabular-data-tooltip-header",
      children: title
    }), rows.length > 0 && /*#__PURE__*/_jsx("table", {
      children: /*#__PURE__*/_jsx("tbody", {
        children: rows.map((row, idx) => /*#__PURE__*/_jsx(TabularDataTooltipRow, {
          row: row,
          hasSymbol: hasSymbol
        }, idx))
      })
    }), extra, footer]
  });
}