import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectDestructuringEmpty from '@babel/runtime/helpers/objectDestructuringEmpty';
import { u as useViewHandler } from './index-bbdfb97a.js';
import { observer } from 'mobx-react-lite';
import { useEffect } from 'react';
import RalDropdownFilter from './index-4b3e6bbf.js';
import SlideFilter from './index-9a965a68.js';
import { jsx } from 'react/jsx-runtime';
import 'react-dynamic-multi-render';
import '@crystaldesign/diva-core';
import '@babel/runtime/helpers/asyncToGenerator';
import '@babel/runtime/helpers/slicedToArray';
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 'classnames';
import 'qrcode.react';
import '@babel/runtime/helpers/typeof';
import 'flat';
import 'react-switch';
import 'react-countup';
import 'react-dropdown';
import './index-69271b96.js';
import '@crystaldesign/content-box';
import './index-e9a81262.js';

var defaultColorFilters = [{
  rgb: '#CC3300',
  text: 'red'
}, {
  rgb: '#FF8C00',
  text: 'orange'
}, {
  rgb: '#E1C699',
  text: 'beige'
}, {
  rgb: '#330000',
  text: 'brown'
}, {
  rgb: '#F0E68C',
  text: 'yellow'
}, {
  rgb: '#006633',
  text: 'green'
}, {
  rgb: '#3333FF',
  text: 'blue'
}, {
  rgb: '#6633FF',
  text: 'violet'
}, {
  rgb: '#CCCCCC',
  text: 'grey'
}, {
  rgb: '#000000',
  text: 'black'
}, {
  rgb: '#eeeeee',
  text: 'white'
}, {
  rgb: '#eeeeee',
  text: 'else'
}];

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 RalFilter = function RalFilter(_ref) {
  var props = Object.assign({}, (_objectDestructuringEmpty(_ref), _ref));
  var viewHandler = useViewHandler();
  var palette = viewHandler.settingsState.itemPalettes.get(props.id);
  var visibleColorItems = [];
  var deleteCurValue = function deleteCurValue() {
    viewHandler.paletteViewHandler.onSelectFilter(props.id, '', 'RAL');
  };
  useEffect(function () {
    if (palette && !(palette !== null && palette !== void 0 && palette.deleteCurFilter)) palette.deleteCurFilter = deleteCurValue;
  }, [palette]);
  palette === null || palette === void 0 || palette.groups.map(function (group) {
    return group.items.map(function (itemP) {
      var _item$colorGroups;
      var item = itemP;
      if (!((_item$colorGroups = item.colorGroups1) !== null && _item$colorGroups !== void 0 && _item$colorGroups.length)) return;
      var colorGroups = [item.colorGroups1, item.colorGroups2, item.colorGroups3];
      var _loop = function _loop() {
        var groups = colorGroups[i];
        var group = defaultColorFilters.find(function (group) {
          return group.text === groups;
        });
        if (group && !visibleColorItems.find(function (i) {
          return i.text === groups;
        })) {
          visibleColorItems.push(group);
        }
      };
      for (var i = 0; i < colorGroups.length; i++) {
        _loop();
      }
    });
  });
  if (viewHandler.uiState.isInMobileView && viewHandler.getViewConfig().ralFilter) return /*#__PURE__*/jsx(SlideFilter, _objectSpread({
    deleteCurValue: deleteCurValue,
    visibleColorItems: visibleColorItems
  }, props));else return /*#__PURE__*/jsx(RalDropdownFilter, _objectSpread({
    deleteCurValue: deleteCurValue,
    visibleColorItems: visibleColorItems
  }, props));
};
var RALFilter = observer(RalFilter);

export { RALFilter as default };
