import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import { s as styleInject, u as useViewHandler, P as PricePreview, G as GenericToolTip } from './index-bbdfb97a.js';
import classnames from 'classnames';
import { observer } from 'mobx-react-lite';
import { useState } from 'react';
import { useDivaCore } from '@crystaldesign/diva-core';
import { useHover, useLayer } from 'react-laag';
import MetaData from './index-7635bafb.js';
import InfoIcon from './index-04a7a9b4.js';
import { jsxs, jsx } from 'react/jsx-runtime';
import 'react-dynamic-multi-render';
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';

var container = "container-08OcY";
var sel = "sel-hd522";
var titleContainer = "title-container-QzcUc";
var title = "title-WUWIa";
var css_248z = ".container-08OcY {\n  position: relative;\n  box-sizing: border-box;\n  border: 3px solid transparent;\n  border-radius: 6px;\n  overflow: hidden;\n  display: flex;\n  flex-direction: column;\n  transition:\n    box-shadow 0.2s ease-in-out,\n    border-color 0.2s ease-in-out;\n  background: #f2f2f2;\n  cursor: pointer;\n}\n\n.container-08OcY.sel-hd522 {\n  border-color: var(--primaryColor);\n}\n\n.container-08OcY:hover {\n  box-shadow: rgba(0, 0, 0,0.2) 0px 0px 16px 0px;\n}\n\n.container-08OcY img {\n  width: 100%;\n  -o-object-fit: contain;\n     object-fit: contain;\n}\n\n.title-container-QzcUc {\n  color: #4b4b4b;\n  display: flex;\n  justify-content: space-between;\n  flex-direction: column;\n  height: 100%;\n}\n.title-WUWIa {\n  height: auto;\n  margin: 0 3px;\n}\n\n.title-WUWIa {\n  font-weight: 600;\n  font-size: 13px;\n  line-height: 15px;\n}\n";
styleInject(css_248z);

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 ShelfAccessoires = function ShelfAccessoires(_ref) {
  var _renderLayer, _item$longDescription;
  var item = _ref.item;
    _ref.grids;
    var sel$1 = _ref.sel;
  var viewHandler = useViewHandler();
  var _useDivaCore = useDivaCore(),
    _useDivaCore$state = _useDivaCore.state,
    hidePrices = _useDivaCore$state.hidePrices,
    _useDivaCore$state$di = _useDivaCore$state.dimensions,
    isMobile = _useDivaCore$state$di.isMobile,
    isTablet = _useDivaCore$state$di.isTablet;
  var _useState = useState(''),
    _useState2 = _slicedToArray(_useState, 2),
    metaDataVisible = _useState2[0],
    setMetaDataVisible = _useState2[1];

  /* tool tip stuff*/
  var triggerProps = {};
  var layerProps = {};
  var renderLayer = undefined;
  var isOver = false;
  var hoverProps = {};
  var hover = useHover({
    delayEnter: 1500,
    hideOnScroll: true
  });
  var tooltip = useLayer({
    isOpen: hover[0],
    auto: true,
    placement: viewHandler.getViewConfig().tooltipPosition || 'left-center'
  });
  if (!isMobile && !isTablet && !viewHandler.getViewConfig().hideTooltip) {
    isOver = hover[0];
    hoverProps = hover[1];
    triggerProps = tooltip.triggerProps;
    layerProps = tooltip.layerProps;
    renderLayer = tooltip.renderLayer;
  }
  var header = item.name;
  return /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread(_objectSpread({
    id: item.articleCodex,
    className: classnames(container, sel$1 ? sel : undefined),
    onClick: function onClick() {
      return viewHandler.paletteViewHandler.selectShelfAccessorie(item.articleCodex);
    }
  }, triggerProps), hoverProps), {}, {
    children: [/*#__PURE__*/jsx("img", {
      style: {
        maxHeight: viewHandler.settingsState.settingsWidth / 3
      },
      src: item.image
    }), /*#__PURE__*/jsxs("div", {
      className: titleContainer,
      children: [/*#__PURE__*/jsx("div", {
        className: classnames(title),
        dangerouslySetInnerHTML: {
          __html: header
        }
      }), /*#__PURE__*/jsx(MetaData, {
        metaData: item.metaData,
        visible: [metaDataVisible, setMetaDataVisible]
      }, item.articleCodex), !hidePrices && !!item.price && /*#__PURE__*/jsx(PricePreview, {
        price: item.price,
        style: {
          paddingTop: 6
        }
      }), item.contentItemId && /*#__PURE__*/jsx(InfoIcon, {
        item: item,
        style: {
          top: 6,
          right: 6
        }
      }, item.articleCodex)]
    }), isOver && ((_renderLayer = renderLayer) === null || _renderLayer === void 0 ? void 0 : _renderLayer(/*#__PURE__*/jsx(GenericToolTip, {
      text: (_item$longDescription = item.longDescription) !== null && _item$longDescription !== void 0 ? _item$longDescription : item.name,
      desciption: metaDataVisible,
      image: item.image,
      codex: item.articleCodex,
      layerProps: layerProps
    }, item.articleCodex)))]
  }));
};
var ShelfAccessoires$1 = observer(ShelfAccessoires);

export { ShelfAccessoires$1 as default };
