import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import { u as useViewHandler } from './index-bbdfb97a.js';
import 'react';
import { s as shelfPlannerContainerRtv, a as shelfPlannerContainerHorizontal, b as shelfPlannerContainerVertical, e as expanded, c as shelfGrid, d as shelfGridBorder, w as warning, f as accessoires, g as configHeaderWrapper, h as closeButton, n as name, S as SelectedAcc, i as accessoireContainer } from './index-e64c557b.js';
import { c as collapsableInner } from './index-105eab2c.js';
import ShelfAccessoires from './index-ffce7d1a.js';
import ShelfAccessoiresOld from './index-a56e35c3.js';
import GridList from './index-3177dc24.js';
import classnames from 'classnames';
import { observer } from 'mobx-react-lite';
import SettingsItemsWrapper from './index-e8768440.js';
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
import 'react-dynamic-multi-render';
import '@crystaldesign/diva-core';
import '@babel/runtime/helpers/asyncToGenerator';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/regenerator';
import '@babel/runtime/helpers/classCallCheck';
import '@babel/runtime/helpers/createClass';
import '@babel/runtime/helpers/toConsumableArray';
import '@crystaldesign/diva-utils';
import 'mobx';
import '@crystaldesign/web-planner-logic';
import 'qrcode.react';
import '@babel/runtime/helpers/typeof';
import 'flat';
import 'react-switch';
import 'react-countup';
import 'sift';
import './index-0d3bfd91.js';
import './index-2b5bdfe1.js';
import './index-caff71dc.js';
import './index-5cb692e9.js';
import './index.module-d6f043d2.js';
import './index-04a7a9b4.js';
import './index-755074ae.js';
import '@mui/icons-material/Block';
import '@mui/icons-material/Warning';
import './index-db439036.js';
import 'react-dropdown';
import './index-7f2e9c31.js';
import '@babel/runtime/helpers/objectDestructuringEmpty';
import './index-4b3e6bbf.js';
import './index-69271b96.js';
import './index-9a965a68.js';
import '@crystaldesign/content-box';
import './index-e9a81262.js';
import './index-2f37b9f2.js';
import './index-bea5c228.js';
import './index-014a5003.js';
import 'swiper/react';
import 'swiper/modules';
import './UnlockCard-575022e0.js';
import './index-ce21cd4d.js';
import './index-6a697eea.js';
import './index-ea5e3e90.js';
import './index-69fd5e9e.js';
import './index-079ef135.js';
import './index-4b48794b.js';
import 'react-laag';
import './index.module-25687dd9.js';
import './index-3f40a92d.js';
import './index-66fd1759.js';
import './index-8a330776.js';
import './index-4fda4c71.js';
import './index-d896efe9.js';
import './index.module-fe49e10f.js';
import './index-6051ac01.js';
import './index-ec31a7cb.js';
import './index-79fbb400.js';
import './index-2e39dac3.js';
import './index-1641324b.js';
import './index-7635bafb.js';
import './index-0e0e6ac6.js';
import './index-a1cef81d.js';
import './index-4c03ac5c.js';
import './index-10d8be2f.js';
import './index-b7364bb1.js';
import './index-a253bbbf.js';
import './index-4ca1affe.js';
import 'rc-slider';
import './index-c44088dc.js';
import './index-e4d1ba18.js';
import './index-d5bb9bda.js';
import './index-dd2aabd2.js';
import './index-eb98a8c6.js';
import 'react-confetti-explosion';
import './index-d0331808.js';
import './index-7167c5bc.js';
import './index-5a146745.js';
import 'react-qr-code';
import './index-c648d661.js';
import './useCustomDimensions-8be02680.js';
import './index-c0a41b5b.js';
import './ussIsSticky-2f6bc37b.js';
import './index-290c519e.js';
import './index-be7a52a8.js';
import './index-9c4f9dc2.js';
import './index.module-613d19d3.js';
import './index-23081351.js';
import './index-b14a4a7c.js';
import './index-fdf81349.js';
import './index-688fe1aa.js';
import 'react-beautiful-dnd';
import './index-78fc8323.js';
import './index-49b01da7.js';
import './index-f4a37353.js';

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var ShelfPlanner = function ShelfPlanner(_ref) {
  var _viewHandler$settings, _viewHandler$settings2, _viewHandler$settings3, _viewHandler$settings4, _item$shelfPlannerGri, _item$shelfPlannerGri2, _item$shelfPlannerGri3, _filteredGroups$0$ite, _filteredGroups$, _selAccItem, _selAccItem2;
  var item = _ref.item,
    style = _ref.style,
    filteredGroups = _ref.filteredGroups;
  var viewHandler = useViewHandler();
  var height = ((_viewHandler$settings = (_viewHandler$settings2 = viewHandler.settingsState.settingsScrollerElement) === null || _viewHandler$settings2 === void 0 ? void 0 : _viewHandler$settings2.getBoundingClientRect().height) !== null && _viewHandler$settings !== void 0 ? _viewHandler$settings : 0) - 10;
  var width = ((_viewHandler$settings3 = (_viewHandler$settings4 = viewHandler.settingsState.settingsScrollerElement) === null || _viewHandler$settings4 === void 0 ? void 0 : _viewHandler$settings4.getBoundingClientRect().width) !== null && _viewHandler$settings3 !== void 0 ? _viewHandler$settings3 : 0) - 16;
  var grid = (_item$shelfPlannerGri = item === null || item === void 0 || (_item$shelfPlannerGri2 = item.shelfPlannerGrids) === null || _item$shelfPlannerGri2 === void 0 ? void 0 : _item$shelfPlannerGri2.find(function (g) {
    return g.ActAccessoire;
  })) !== null && _item$shelfPlannerGri !== void 0 ? _item$shelfPlannerGri : item === null || item === void 0 || (_item$shelfPlannerGri3 = item.shelfPlannerGrids) === null || _item$shelfPlannerGri3 === void 0 ? void 0 : _item$shelfPlannerGri3[0];
  if (!grid) return /*#__PURE__*/jsx(Fragment, {});
  var items = (_filteredGroups$0$ite = (_filteredGroups$ = filteredGroups[0]) === null || _filteredGroups$ === void 0 ? void 0 : _filteredGroups$.items) !== null && _filteredGroups$0$ite !== void 0 ? _filteredGroups$0$ite : [];
  var selAcc = grid.ActAccessoire;
  var selAccItem = undefined;
  if (selAcc) {
    selAccItem = items.find(function (item) {
      return item.articleCodex == selAcc;
    });
  }
  var requiredWarning = grid.getRequiredWarning(viewHandler.configState.lang);
  var palettesOfSelectedAcc = [];
  if ((_selAccItem = selAccItem) !== null && _selAccItem !== void 0 && (_selAccItem = _selAccItem.configStepKeys) !== null && _selAccItem !== void 0 && _selAccItem.length) {
    var _loop = function _loop() {
      var stepKey = selAccItem.configStepKeys[i];
      var itemPalette = viewHandler.settingsState.itemPaletteArr.find(function (_ref2) {
        var _ref3 = _slicedToArray(_ref2, 2);
          _ref3[0];
          var itemPalette = _ref3[1];
        return itemPalette.configStepKey == stepKey.key;
      });
      if (!itemPalette) return 1; // continue
      if (viewHandler.settingsState.selectedShelfAccessoire == stepKey.basketId) palettesOfSelectedAcc.push(itemPalette[1]);
    };
    for (var i = 0; i < selAccItem.configStepKeys.length; i++) {
      if (_loop()) continue;
    }
  }
  var mobileRTV = viewHandler.getIsInMobileView() && viewHandler.productState.shelfPlannerRTV;
  return /*#__PURE__*/jsxs("div", {
    ref: function ref(_ref4) {
      return item.htmlRef = _ref4;
    },
    className: classnames(viewHandler.productState.shelfPlannerRTV ? shelfPlannerContainerRtv : undefined, grid.Direction == 'horizontal' ? shelfPlannerContainerHorizontal : shelfPlannerContainerVertical, viewHandler.uiState.configSettingsIsExpanded ? expanded : undefined),
    style: _objectSpread({
      height: height
    }, style),
    children: [!viewHandler.productState.shelfPlannerRTV && /*#__PURE__*/jsx("div", {
      className: shelfGrid,
      children: /*#__PURE__*/jsx("div", {
        className: shelfGridBorder,
        children: /*#__PURE__*/jsx(GridList, {
          item: item,
          direction: grid.Direction,
          width: width,
          height: height - 16 - 16
        })
      })
    }), requiredWarning && /*#__PURE__*/jsx("div", {
      className: warning,
      dangerouslySetInnerHTML: {
        __html: requiredWarning
      }
    }), /*#__PURE__*/jsxs("div", {
      className: accessoires,
      children: [!!palettesOfSelectedAcc.length && /*#__PURE__*/jsxs(Fragment, {
        children: [/*#__PURE__*/jsxs("div", {
          className: configHeaderWrapper,
          onClick: function onClick() {
            return viewHandler.paletteViewHandler.setSelectedShelfAccessoire();
          },
          children: [/*#__PURE__*/jsx("div", {
            className: closeButton
          }), /*#__PURE__*/jsx("div", {
            className: name,
            children: (_selAccItem2 = selAccItem) === null || _selAccItem2 === void 0 ? void 0 : _selAccItem2.name
          })]
        }), /*#__PURE__*/jsx(SettingsItemsWrapper, {
          itemPalettesArr: palettesOfSelectedAcc
        })]
      }), !palettesOfSelectedAcc.length && /*#__PURE__*/jsxs(Fragment, {
        children: [!mobileRTV && /*#__PURE__*/jsx(SelectedAcc, {
          selAccItem: selAccItem
        }), /*#__PURE__*/jsx("div", {
          className: classnames(accessoireContainer, collapsableInner),
          style: {
            height: grid.Direction == 'horizontal' ? height - 80 : '',
            overflow: mobileRTV ? 'visible' : undefined
          },
          children: items.map(function (acc, key) {
            return /*#__PURE__*/jsxs(Fragment, {
              children: [viewHandler.productState.shelfPlannerRTV && /*#__PURE__*/jsx(ShelfAccessoires, {
                grids: item.shelfPlannerGrids,
                item: acc,
                sel: acc.articleCodex == selAcc
              }, key), !viewHandler.productState.shelfPlannerRTV && /*#__PURE__*/jsx(ShelfAccessoiresOld, {
                grids: item.shelfPlannerGrids,
                item: acc
              }, key)]
            });
          })
        })]
      })]
    })]
  });
};
var index = observer(ShelfPlanner);

export { index as default };
