"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.NestedTableParentCell = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireWildcard(require("react"));
var _mobxReactLite = require("mobx-react-lite");
var _designSystem = require("@wix/design-system");
var _wixUiIconsCommon = require("@wix/wix-ui-icons-common");
var _Rotate = require("../Rotate");
var _MainCellLayout = require("./MainCellLayout");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/NestedTable/NestedTableParentCell.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); }
function _NestedTableParentCell(props) {
  const {
    state: parentState,
    item,
    rowNum,
    dragAndDrop
  } = props;
  const {
    node: {
      collection
    }
  } = parentState;
  const {
    originalKeyedItem,
    state: {
      nestedTable
    }
  } = item;
  const renderProps = parentState.renderMainColumn == null ? void 0 : parentState.renderMainColumn(originalKeyedItem.item);
  const [state] = (0, _react.useState)(() => item.state.createNode({
    parent: originalKeyedItem
  }));
  (0, _react.useEffect)(() => {
    if (!state) {
      return;
    }
    state._rowNum = rowNum;
  }, [rowNum]);
  const _expanded = state == null ? void 0 : state._expanded;
  return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
    "data-hook": "indentation-wrapper"
  }, process.env.NODE_ENV === 'test' && {
    'data-indentation-width': nestedTable._indentationWidth
  }, {
    style: {
      display: 'flex',
      minWidth: 0,
      paddingInlineStart: parentState.childrenDepth * nestedTable._indentationWidth
    },
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 57,
      columnNumber: 5
    }
  }), /*#__PURE__*/_react.default.createElement(_MainCellLayout.MainCellLayout, {
    dragHandle: (dragAndDrop == null ? void 0 : dragAndDrop.NestedTableDragHandle) && /*#__PURE__*/_react.default.createElement(dragAndDrop.NestedTableDragHandle, {
      item: item,
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 72,
        columnNumber: 13
      }
    }),
    expandCollapseButton: /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
      paddingInlineEnd: "12px",
      visibility: state == null || state._isNotExpandableWhenEmpty || parentState._isExpandableActionDisabled(originalKeyedItem.item) ? 'hidden' : undefined,
      dataHook: "expand-collapse-wrapper",
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 76,
        columnNumber: 11
      }
    }, /*#__PURE__*/_react.default.createElement(_designSystem.TextButton, {
      size: "small",
      dataHook: "expand-collapse",
      prefixIcon: /*#__PURE__*/_react.default.createElement(_Rotate.Rotate, {
        timeout: 200,
        deg: _expanded ? 90 : 0,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 91,
          columnNumber: 17
        }
      }, /*#__PURE__*/_react.default.createElement(_wixUiIconsCommon.ChevronRightSmall, {
        "data-hook": "chevron-icon",
        style: {
          paddingRight: 0,
          paddingInlineEnd: 0
        },
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 92,
          columnNumber: 19
        }
      })),
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 87,
        columnNumber: 13
      }
    })),
    image: renderProps == null ? void 0 : renderProps.image,
    title: (renderProps == null ? void 0 : renderProps.title) ?? collection.itemName(originalKeyedItem.item),
    subtitle: renderProps == null ? void 0 : renderProps.subtitle,
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 69,
      columnNumber: 7
    }
  }));
}
const NestedTableParentCell = exports.NestedTableParentCell = (0, _mobxReactLite.observer)(_NestedTableParentCell);
//# sourceMappingURL=NestedTableParentCell.js.map