"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.TableSectionRow = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireWildcard(require("react"));
var _CollectionSectionHeader = require("../CollectionSectionHeader");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/TableSections/TableSectionRow.tsx";
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const TableSectionRow = exports.TableSectionRow = /*#__PURE__*/(0, _react.forwardRef)(({
  state,
  RegularTrElement,
  rowData,
  ...props
}, ref) => {
  const {
    children,
    className,
    style
  } = props;
  const isSectionRow = state.isSectionRow(rowData);
  const regularTrElementProps = {
    ...props,
    rowData,
    className: className || '',
    children: children || []
  };
  if (state.isInvisibleRow(rowData)) {
    return /*#__PURE__*/_react.default.createElement("tr", (0, _extends2.default)({}, props, {
      ref: ref,
      className: className,
      style: {
        ...style,
        visibility: 'collapse'
      },
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 37,
        columnNumber: 7
      }
    }));
  }
  if (isSectionRow && Array.isArray(children) && children.length > 0) {
    const sectionWithCount = state.getSectionWithCount(rowData);
    if (!sectionWithCount) {
      return /*#__PURE__*/_react.default.createElement(RegularTrElement, (0, _extends2.default)({}, regularTrElementProps, {
        __self: void 0,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 53,
          columnNumber: 14
        }
      }));
    }
    return /*#__PURE__*/_react.default.createElement("tr", (0, _extends2.default)({}, props, {
      ref: ref,
      className: className,
      style: {
        ...style,
        position: 'relative',
        cursor: 'default'
      },
      "data-hook": "table-section-header-row",
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 57,
        columnNumber: 7
      }
    }), /*#__PURE__*/_react.default.createElement("th", {
      colSpan: children.length,
      scope: "rowgroup",
      style: {
        padding: '0px'
      },
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 68,
        columnNumber: 9
      }
    }, /*#__PURE__*/_react.default.createElement(_CollectionSectionHeader.CollectionSectionHeader, {
      section: sectionWithCount,
      biComponentType: "TableSections",
      skin: "neutral",
      dataHook: "table-section-header",
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 73,
        columnNumber: 11
      }
    })));
  }
  return /*#__PURE__*/_react.default.createElement(RegularTrElement, (0, _extends2.default)({}, regularTrElementProps, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 84,
      columnNumber: 10
    }
  }));
});
//# sourceMappingURL=TableSectionRow.js.map