import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import { s as styleInject, u as useViewHandler, G as GenericToolTip, P as PricePreview } from './index-bbdfb97a.js';
import classnames from 'classnames';
import { observer } from 'mobx-react-lite';
import { useState } from 'react';
import MetaData from './index-7635bafb.js';
import InfoIcon from './index-04a7a9b4.js';
import { useHover, useLayer } from 'react-laag';
import { useDivaCore } from '@crystaldesign/diva-core';
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 articleItem = "article-item-eh-j4";
var wcVCodexText = "wcVCodexText-MyIlQ";
var sel = "sel-84QKb";
var imageWrapper = "imageWrapper-gvsu5";
var wcImage = "wcImage-GYOFl";
var titleWrapper = "titleWrapper-noaB3";
var title = "title-79bZq";
var mobile = "mobile-V-kG0";
var tablet = "tablet-SBmhr";
var wcArticleSize = "wcArticleSize--au3o";
var css_248z = "/*Size Normal */\n\n.article-item-eh-j4 {\n  border-radius: calc(var(--globalBorderRadius));\n  position: relative;\n  z-index: 100;\n  transition: all 0.15s ease;\n  cursor: pointer;\n  display: flex;\n  flex-direction: column;\n  gap: 4px;\n}\n\n.article-item-eh-j4:active,\n.article-item-eh-j4:hover {\n  z-index: 200;\n  transition: 0.15s ease;\n}\n\n.wcVCodexText-MyIlQ {\n  position: absolute;\n  top: 50%;\n  transform: translateY(-50%);\n  width: 100%;\n  color: white;\n  display: none;\n  text-align: center;\n}\n\n.article-item-eh-j4:hover .wcVCodexText-MyIlQ,\n.sel-84QKb .wcVCodexText-MyIlQ {\n  display: block;\n}\n\n.imageWrapper-gvsu5 {\n  border-radius: calc(var(--globalBorderRadius));\n  border: 1px rgb(230, 230, 230) solid;\n  display: flex;\n  transition: 0.15s ease;\n  position: relative;\n}\n.article-item-eh-j4:hover .imageWrapper-gvsu5 {\n  box-shadow: 0px 1px 4px rgba(68, 49, 49, 0.15);\n  border: 1px var(--primaryColor) solid;\n  border: 1px var(--optionItemBorderSelColor, var(--primaryColor)) solid;\n}\n.sel-84QKb.article-item-eh-j4:hover .imageWrapper-gvsu5 {\n  box-shadow: 0px 1px 4px rgba(68, 49, 49, 0.15);\n  border: 1px rgb(230, 230, 230) solid;\n}\n.sel-84QKb .imageWrapper-gvsu5 {\n  box-shadow: 0px 1px 4px rgba(68, 49, 49, 0.15);\n}\n\n.wcImage-GYOFl {\n  width: calc(100% - 8px);\n  border: 4px white solid;\n  background-color: #fff;\n  border-radius: calc(var(--globalBorderRadius));\n  user-select: none;\n  -moz-user-select: none;\n  -webkit-user-drag: none;\n  -webkit-user-select: none;\n  -ms-user-select: none;\n  -o-object-fit: contain;\n     object-fit: contain;\n  background-color: #fff;\n  transition: border 0.3s ease;\n  aspect-ratio: 1/1;\n}\n.sel-84QKb .wcImage-GYOFl {\n  border: 4px var(--primaryColor) solid;\n  border: 4px var(--optionItemBorderSelColor, var(--primaryColor)) solid;\n}\n\n.hexColor-LvQOl {\n  width: 80px;\n  height: 80px;\n}\n\n.titleWrapper-noaB3 {\n  display: flex;\n  justify-content: center;\n  overflow: visible;\n  max-height: 42px;\n}\n\n.title-79bZq {\n  text-align: center;\n  width: 100%;\n  height: 48px;\n  min-height: -moz-fit-content;\n  min-height: fit-content;\n  max-height: -moz-fit-content;\n  max-height: fit-content;\n  font-size: 14px;\n  line-height: 16px;\n  overflow: hidden;\n  display: -webkit-box;\n  word-wrap: break-word;\n  -webkit-box-orient: vertical;\n  -webkit-hyphens: auto;\n  hyphens: auto;\n  -webkit-line-clamp: 3;\n  transition: height 0.3s ease-out;\n}\n\n.mobile-V-kG0:not(.tablet-SBmhr) .title-79bZq {\n  font-size: 12px;\n  line-height: 14px;\n}\n\n.article-item-eh-j4:hover .title-79bZq,\n.article-item-eh-j4:focus .title-79bZq {\n  max-height: -moz-fit-content;\n  max-height: fit-content;\n  min-height: -moz-fit-content;\n  min-height: fit-content;\n  -webkit-line-clamp: 30;\n  height: 72px;\n  z-index: 200;\n  background-color: var(--settingsBackgroundColor);\n  border-bottom-left-radius: var(--globalBorderRadius);\n  border-bottom-right-radius: var(--globalBorderRadius);\n  transition: height 0.3s ease-in;\n}\n\n.article-item-eh-j4 .wcArticleSize--au3o {\n  bottom: 0px;\n  padding-bottom: 3px;\n  left: 0px;\n  padding-left: 4px;\n  padding-right: 4px;\n  font-family: var(--diva-typography-font-family);\n  font-weight: 100;\n  font-size: 11px;\n  line-height: 17px;\n  color: #6f6f6f;\n  z-index: 50;\n  position: absolute;\n  overflow: hidden;\n  display: -webkit-box;\n  word-wrap: break-word;\n  -webkit-box-orient: vertical;\n  -webkit-hyphens: auto;\n  hyphens: auto;\n  -webkit-line-clamp: 1;\n  width: calc(100% - 8px);\n  transition: opacity 0.3s ease;\n  background-color: rgba(255, 255, 255, 0.85);\n  border-bottom-left-radius: var(--globalBorderRadius);\n  border-bottom-right-radius: var(--globalBorderRadius);\n}\n\n.mobile-V-kG0:not(.tablet-SBmhr).article-item-eh-j4 .wcArticleSize--au3o {\n  font-size: 10px;\n  line-height: 12px;\n}\n\n.sel-84QKb .wcArticleSize--au3o {\n  bottom: 4px;\n  padding-bottom: 0px;\n  left: 4px;\n  padding-left: 4px;\n  padding-right: 4px;\n  width: calc(100% - 16px);\n  border-bottom-left-radius: calc(var(--globalBorderRadius) - 2px);\n  border-bottom-right-radius: calc(var(--globalBorderRadius) - 2px);\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 Article = function Article(_ref) {
  var _viewHandler$settings, _renderLayer, _item$longDescription;
  var itemP = _ref.item,
    paletteId = _ref.paletteId;
  var item = itemP;
  var viewHandler = useViewHandler();
  var _useDivaCore = useDivaCore(),
    _useDivaCore$state = _useDivaCore.state,
    _useDivaCore$state$di = _useDivaCore$state.dimensions,
    isMobile = _useDivaCore$state$di.isMobile,
    isTablet = _useDivaCore$state$di.isTablet,
    hidePrices = _useDivaCore$state.hidePrices;
  var _useState = useState(''),
    _useState2 = _slicedToArray(_useState, 2),
    metaDataVisible = _useState2[0],
    setMetaDataVisible = _useState2[1];
  var onClick = function onClick() {
    viewHandler.paletteViewHandler.clickedOnPlannerPalette(item, paletteId);
  };

  /* 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 && !item.contentItemId) {
    isOver = hover[0];
    hoverProps = hover[1];
    triggerProps = tooltip.triggerProps;
    layerProps = tooltip.layerProps;
    renderLayer = tooltip.renderLayer;
  }
  var isSelected = item.sel && ((_viewHandler$settings = viewHandler.settingsState.addElementSelected) === null || _viewHandler$settings === void 0 ? void 0 : _viewHandler$settings.mode) != 'add';
  return /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread(_objectSpread({
    id: item.codex,
    className: classnames(articleItem, isSelected ? sel : undefined, viewHandler.getIsInMobileView() ? mobile : undefined, viewHandler.uiState.isTablet ? tablet : undefined),
    onClick: onClick
  }, triggerProps), hoverProps), {}, {
    children: [/*#__PURE__*/jsxs("div", {
      className: classnames(imageWrapper),
      children: [viewHandler.getViewConfig().showOptionCodexInOptionHeader && /*#__PURE__*/jsx("div", {
        className: classnames(wcVCodexText),
        children: item.articleCodex
      }), item.image && /*#__PURE__*/jsx("img", {
        className: classnames(wcImage),
        src: item.image.replace('_gal', '').replace('_low', '')
      }), item.contentItemId && /*#__PURE__*/jsx(InfoIcon, {
        item: item,
        style: {
          top: -6,
          bottom: 'unset',
          right: -7
        }
      }, item.codex), /*#__PURE__*/jsx("div", {
        className: classnames(wcArticleSize),
        children: item.sizeInfo
      })]
    }), /*#__PURE__*/jsx("div", {
      className: titleWrapper,
      children: /*#__PURE__*/jsx("div", {
        className: title,
        dangerouslySetInnerHTML: {
          __html: item.title
        }
      })
    }), 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.title,
      desciption: metaDataVisible,
      codex: item.articleCodex,
      image: item.image,
      layerProps: layerProps,
      price: item.price
    }, item.codex))), /*#__PURE__*/jsx(MetaData, {
      style: {
        position: 'relative',
        "float": 'left',
        display: 'none'
      },
      metaData: item.metaData,
      visible: [metaDataVisible, setMetaDataVisible]
    }, item.codex), item.priceInfo !== undefined && !hidePrices && /*#__PURE__*/jsx(PricePreview, {
      price: item.price
    })]
  }));
};
var FaceLift = observer(Article);

export { FaceLift as default };
