"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.GridItem = void 0;
var _mobxReactLite = require("mobx-react-lite");
var _GridCardItem = require("./GridCardItem");
var _react = _interopRequireDefault(require("react"));
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/Grid/GridItem.tsx";
function _GridItem(props) {
  const {
    state,
    preset,
    index,
    rowIndex,
    columnIndex,
    renderItem,
    renderAddItem,
    actionCell,
    dragAndDrop,
    isOverlay
  } = props;
  const renderType = state.getItemRenderTypeAt(index);
  const {
    collection: {
      query: {
        hasNonPersistentActiveFilters
      }
    }
  } = state;
  if (renderType === null) {
    return null;
  }
  if (renderType === 'trailing') {
    if (hasNonPersistentActiveFilters) {
      return null;
    }
    return /*#__PURE__*/_react.default.createElement("div", {
      key: "add-item",
      "data-hook": "grid-add-item-container",
      style: {
        height: '100%'
      },
      onClick: () => state.onAddItemClick(),
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 62,
        columnNumber: 7
      }
    }, renderAddItem == null ? void 0 : renderAddItem());
  }
  let child = /*#__PURE__*/_react.default.createElement(_GridCardItem.GridCardItem, {
    state: state,
    index: index,
    rowIndex: rowIndex,
    columnIndex: columnIndex,
    keyedItem: renderType,
    renderItem: renderItem,
    actionCell: actionCell,
    preset: preset,
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 74,
      columnNumber: 5
    }
  });
  if (dragAndDrop) {
    const {
      DraggableCard
    } = dragAndDrop;
    child = /*#__PURE__*/_react.default.createElement(DraggableCard, {
      id: renderType.key,
      index: renderType.index,
      state: state,
      isOverlay: isOverlay,
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 89,
        columnNumber: 7
      }
    }, child);
  }
  return child;
}
const GridItem = exports.GridItem = (0, _mobxReactLite.observer)(_GridItem);
//# sourceMappingURL=GridItem.js.map