import React from 'react';
import { flexRender } from '@tanstack/react-table';
// eslint-disable-next-line you-dont-need-lodash-underscore/is-nan
import isNaN from 'lodash-es/isNaN';
import { TruncateWithTooltip } from '../../truncate-with-tooltip';
import { useTranslation } from '../../hooks/use-translation';
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
const isValuePresent = value => {
  return typeof value === 'number' ? !isNaN(value) : !!value;
};
export function TableBodyCellContent({
  cell,
  getRowActions,
  getRowFooterAction,
  rowClickDisabled,
  rowSelectionDisabled,
  keyboardNavCellId,
  localizationProps
}) {
  const {
    t
  } = useTranslation();
  const shouldTruncate = !!cell.column.columnDef.meta?.truncateText;
  const value = cell.getValue();
  const cellProps = {
    ...cell.getContext(),
    getRowActions,
    getRowFooterAction,
    rowClickDisabled,
    rowSelectionDisabled,
    keyboardNavCellId
  };
  if (!shouldTruncate) {
    return /*#__PURE__*/_jsx(_Fragment, {
      children: flexRender(cell.column.columnDef.cell, cellProps)
    });
  }
  return /*#__PURE__*/_jsx(TruncateWithTooltip, {
    className: "react-table-cell-text",
    children: /*#__PURE__*/_jsx("span", {
      children: isValuePresent(value) ? flexRender(cell.column.columnDef.cell, cellProps) : localizationProps?.emptyCellLabel ?? t('N/A')
    })
  });
}