"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _styledComponents = _interopRequireDefault(require("styled-components"));
var _utils = require("../../../common/utils");
var _ = require("../../..");
var _ColumnProvider = require("../shared/ColumnProvider");
var _TextWrapper = require("./TextWrapper");
var _textUtils = require("../shared/textUtils");
var _getStylesForSizes = _interopRequireDefault(require("../shared/getStylesForSizes"));
var _FlexTableProvider = require("../shared/FlexTableProvider");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var getDensityStyles = function getDensityStyles(_ref) {
  var density = _ref.density;
  return "\n  padding-top: ".concat((0, _textUtils.getDensityPaddings)(density), "px !important;\n  padding-bottom: ").concat((0, _textUtils.getDensityPaddings)(density), "px;\n");
};
var StyledFlexbox = (0, _styledComponents.default)(_.Flexbox).withConfig({
  displayName: "Cell__StyledFlexbox",
  componentId: "sc-icfddc-0"
})(["overflow:hidden;", ""], (0, _getStylesForSizes.default)(function (p) {
  return {
    xs: p.$xs,
    sm: p.$sm,
    md: p.$md,
    lg: p.$lg,
    xl: p.$xl
  };
}, {
  density: getDensityStyles
}));
var Cell = function Cell(props) {
  var children = props.children,
    columnId = props.columnId,
    className = props.className;
  var flexProps = (0, _ColumnProvider.useFlexCellProps)(props);
  var _useFlexTable = (0, _FlexTableProvider.useFlexTable)('density'),
    xs = _useFlexTable.xs,
    sm = _useFlexTable.sm,
    md = _useFlexTable.md,
    lg = _useFlexTable.lg,
    xl = _useFlexTable.xl;
  return _react.default.createElement(StyledFlexbox, _extends({
    className: className,
    role: "cell",
    $xs: xs,
    $sm: sm,
    $md: md,
    $lg: lg,
    $xl: xl
  }, flexProps), (0, _utils.isElement)(children) && children, (0, _utils.isFunction)(children) ? children({
    columnId: columnId
  }) : !(0, _utils.isElement)(children) && _react.default.createElement(_TextWrapper.TextWrapper, null, children));
};
Cell.TextWrapper = _react.default.memo(_TextWrapper.TextWrapper);
var _default = exports.default = Cell;