"use strict";

exports.__esModule = true;
exports.MultiLevelSortingList = void 0;
exports._MultiLevelSortingList = _MultiLevelSortingList;
var _react = _interopRequireWildcard(require("react"));
var _mobxReactLite = require("mobx-react-lite");
var _designSystem = require("@wix/design-system");
var _ListDragAndDropContext = require("../ListDragAndDrop/ListDragAndDropContext");
var _DraggableListItem = require("../ListDragAndDrop/DraggableListItem");
var _MultiLevelSortingTableListItem = require("./MultiLevelSortingTableListItem");
var _DraggableCardOverlay = require("../GridDragAndDropDndKit/DraggableCardOverlay");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/MultiLevelSortingPanel/MultiLevelSortingList.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 _MultiLevelSortingList(props) {
  const {
    state
  } = props;
  const {
    dragAndDrop
  } = state;
  const renderItem = (0, _react.useCallback)((sortableColumn, index, {
    length
  }) => {
    return /*#__PURE__*/_react.default.createElement(_DraggableListItem.DraggableListItem, {
      key: sortableColumn.key,
      id: sortableColumn.key,
      index: index,
      state: dragAndDrop,
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 28,
        columnNumber: 9
      }
    }, /*#__PURE__*/_react.default.createElement(_MultiLevelSortingTableListItem.MultiLevelSortingTableListItem, {
      key: sortableColumn.key,
      sortableColumn: sortableColumn,
      index: index,
      state: state,
      showDivider: index < length - 1,
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 34,
        columnNumber: 11
      }
    }));
  }, []);
  return /*#__PURE__*/_react.default.createElement(_ListDragAndDropContext.ListDragAndDropContext, {
    state: dragAndDrop,
    onSubmit: async ({
      from,
      over
    }) => {
      dragAndDrop._onSortReorder(from.item.columnId, over.item.columnId);
    },
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 48,
      columnNumber: 5
    }
  }, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    direction: "vertical",
    dataHook: "multi-level-sorting-list",
    backgroundColor: "D60",
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 55,
      columnNumber: 9
    }
  }, state.sortingCollection.result.items.map(renderItem)), /*#__PURE__*/_react.default.createElement(_DraggableCardOverlay.DraggableCardOverlay, {
    state: dragAndDrop,
    renderItem: index => {
      const item = state.sortingCollection.result.items[index];
      return item ? renderItem(item, index, {
        length: 0
      }) : null;
    },
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 62,
      columnNumber: 9
    }
  })));
}
const MultiLevelSortingList = exports.MultiLevelSortingList = (0, _mobxReactLite.observer)(_MultiLevelSortingList);
//# sourceMappingURL=MultiLevelSortingList.js.map