"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = TabularDataTooltip;
var _react = _interopRequireDefault(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _tabularDataTooltipRow = _interopRequireDefault(require("./tabular-data-tooltip-row"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/** Component providing easy to use structure for table in a chart tooltip */
function TabularDataTooltip({
  title,
  rows = [],
  extra = null,
  footer = null,
  testId = 'tabular-data-tooltip',
  className = ''
}) {
  const hasSymbol = rows.some(r => r.symbol);
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
    "test-id": testId,
    className: (0, _classnames.default)('tabular-data-tooltip', className),
    children: [title && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "tabular-data-tooltip-header",
      "test-id": "tabular-data-tooltip-header",
      children: title
    }), rows.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)("table", {
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)("tbody", {
        children: rows.map((row, idx) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_tabularDataTooltipRow.default, {
          row: row,
          hasSymbol: hasSymbol
        }, idx))
      })
    }), extra, footer]
  });
}