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 { useTranslation, useDivaCore, DivaUtils } from '@crystaldesign/diva-core';
import classnames from 'classnames';
import { observer } from 'mobx-react-lite';
import { useState } from 'react';
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 accItem = "AccItem-EuKUQ";
var wcSize = "wcSize-vX0Fm";
var wcSizeNormal = "wcSize-normal-bRIEC";
var wcImage = "wcImage-ScJeM";
var wcAccInfoContainer = "wcAccInfoContainer-eEHqy";
var wcConfiguratorSettingsTitle = "wcConfigurator-settings-title-Wlfnh";
var metaData = "meta-data-p5e7t";
var wcAccSize = "wcAccSize-LdKs3";
var css_248z = "/* Accessoires*/\n\n.AccItem-EuKUQ {\n  border-radius: var(--globalBorderRadius);\n  background: white;\n  position: relative;\n  display: flex;\n  z-index: 100;\n}\n\n.AccItem-EuKUQ:hover {\n  z-index: 200;\n}\n\n.AccItem-EuKUQ .wcSize-vX0Fm {\n  width: 98%;\n  background: white;\n  position: relative;\n  border-radius: var(--globalBorderRadius);\n}\n\n.AccItem-EuKUQ .wcSize-normal-bRIEC {\n  height: 80px;\n}\n\n.AccItem-EuKUQ .wcImagePlaceHolder-t26mm {\n  width: 48px;\n  float: left;\n  height: 48px;\n}\n\n.AccItem-EuKUQ .wcSize-normal-bRIEC .wcImage-ScJeM {\n  height: 80px;\n}\n\n.AccItem-EuKUQ .wcImage-ScJeM {\n  width: 80px;\n  float: left;\n  border-radius: var(--globalBorderRadius) 0px 0px var(--globalBorderRadius);\n  background-size: contain;\n  background-repeat: no-repeat;\n  background-position: 50% 50%;\n}\n\n.wcAccInfoContainer-eEHqy {\n  float: left;\n  width: calc(100% - 80px);\n  position: relative;\n  height: 100%;\n}\n.AccItem-EuKUQ .wcAccInfoContainer-eEHqy {\n  width: calc(100% - 150px);\n  display: flex;\n  flex-direction: column;\n  height: calc(100% - 12px);\n  justify-content: space-between;\n}\n\n.AccItem-EuKUQ .wcConfigurator-settings-title-Wlfnh {\n  display: -webkit-box;\n  float: left;\n  max-height: 64px;\n  min-height: 16px;\n  margin-top: 14px;\n  max-width: 100%;\n  color: var(--secondaryColor);\n  font-size: 16px;\n  line-height: 20.8px;\n  overflow: hidden;\n  word-wrap: break-word;\n  -webkit-box-orient: vertical;\n  -webkit-line-clamp: 2;\n  position: relative;\n  -webkit-hyphens: auto;\n  hyphens: auto;\n  z-index: 100;\n}\n\n.AccItem-EuKUQ .wcConfigurator-settings-title-Wlfnh.meta-data-p5e7t {\n  -webkit-line-clamp: 1;\n}\n\n.AccItem-EuKUQ .wcAccSize-LdKs3 {\n  display: -webkit-box;\n  font-family: var(--diva-typography-font-family);\n  font-weight: 100;\n  font-size: 13px;\n  line-height: 16px;\n  color: #6f6f6f;\n  width: 100%;\n  overflow: hidden;\n  word-wrap: break-word;\n  -webkit-box-orient: vertical;\n  -webkit-line-clamp: 1;\n  -webkit-hyphens: auto;\n  hyphens: auto;\n  z-index: 110;\n}\n@media all and (max-width: 1100px) {\n  .AccItem-EuKUQ .wcSize-normal-bRIEC {\n    height: 80px;\n  }\n\n  .AccItem-EuKUQ .wcSize-normal-bRIEC img {\n    height: 80px;\n  }\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,
    grids = _ref.grids;
  var viewHandler = useViewHandler();
  var i18n = useTranslation();
  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;
  }
  return /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread(_objectSpread({
    onClick: function onClick() {
      return viewHandler.paletteViewHandler.clickedOnShelfAccessorie(grids, item.articleCodex, undefined, true);
    },
    className: accItem
  }, triggerProps), hoverProps), {}, {
    children: [/*#__PURE__*/jsxs("div", {
      className: classnames(wcSize, wcSizeNormal),
      children: [/*#__PURE__*/jsx("div", {
        className: classnames(wcImage),
        style: {
          backgroundImage: "url(".concat(item.image, ")")
        }
      }), /*#__PURE__*/jsxs("div", {
        className: classnames(wcAccInfoContainer),
        children: [/*#__PURE__*/jsx("div", {
          className: classnames(wcConfiguratorSettingsTitle, metaDataVisible !== '' ? metaData : undefined),
          dangerouslySetInnerHTML: {
            __html: item.name
          }
        }), /*#__PURE__*/jsx(MetaData, {
          metaData: item.metaData,
          visible: [metaDataVisible, setMetaDataVisible]
        }, item.articleCodex), /*#__PURE__*/jsx("div", {
          className: classnames(wcAccSize),
          children: DivaUtils.sizeFormatter({
            width: item.width,
            height: item.height,
            depth: item.depth
          }, i18n)
        })]
      })]
    }), !hidePrices && !!item.price && /*#__PURE__*/jsx(PricePreview, {
      price: item.price,
      style: {
        paddingTop: 6
      }
    }), item.contentItemId && /*#__PURE__*/jsx(InfoIcon, {
      item: item,
      style: {
        bottom: 8,
        right: 8
      }
    }, 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 ShelfAccessoiresOld = observer(ShelfAccessoires);

export { ShelfAccessoiresOld as default };
