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 { w as wcFavoriteSel, a as wcFavorite } from './index.module-25687dd9.js';
import { useHover, useLayer } from 'react-laag';
import MetaData from './index-7635bafb.js';
import { useDivaCore } from '@crystaldesign/diva-core';
import InfoIcon from './index-04a7a9b4.js';
import ReverseCheck from './index-755074ae.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';
import '@mui/icons-material/Block';
import '@mui/icons-material/Warning';

var paletteItem = "palette-item-0YKyA";
var wcVCodexText = "wcVCodexText-oxSnB";
var sel = "sel-Mp0M2";
var imageWrapper = "imageWrapper-wAIJh";
var small = "small-NQCY6";
var wcImage = "wcImage--G64h";
var titleWrapper = "titleWrapper-kC1Fd";
var title = "title-gcSeP";
var mobile = "mobile--MrOW";
var tablet = "tablet-R7-Yj";
var big = "big-Rc8hW";
var css_248z = "/*Size Normal */\n\n.palette-item-0YKyA {\n  border-radius: 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.palette-item-0YKyA:active,\n.palette-item-0YKyA:hover {\n  z-index: 200;\n  transition: 0.15s ease;\n}\n\n.wcVCodexText-oxSnB {\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.palette-item-0YKyA:hover .wcVCodexText-oxSnB,\n.sel-Mp0M2 .wcVCodexText-oxSnB {\n  display: block;\n}\n\n.imageWrapper-wAIJh {\n  border-radius: calc(var(--globalBorderRadius) * 2 + 2px);\n  border: 1px rgb(230, 230, 230) solid;\n  display: flex;\n  transition: 0.15s ease;\n  position: relative;\n}\n.palette-item-0YKyA:hover .imageWrapper-wAIJh {\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-Mp0M2.palette-item-0YKyA:hover .imageWrapper-wAIJh,\n.small-NQCY6.sel-Mp0M2.palette-item-0YKyA:hover .imageWrapper-wAIJh {\n  box-shadow: 0px 1px 4px rgba(68, 49, 49, 0.15);\n  border: 1px rgb(230, 230, 230) solid;\n}\n.sel-Mp0M2 .imageWrapper-wAIJh,\n.small-NQCY6.sel-Mp0M2 .imageWrapper-wAIJh {\n  box-shadow: 0px 1px 4px rgba(68, 49, 49, 0.15);\n}\n\n.wcImage--G64h {\n  width: calc(100% - 8px);\n  border: 4px white solid;\n  border-radius: calc(var(--globalBorderRadius) * 2 + 2px);\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-Mp0M2 .wcImage--G64h,\n.small-NQCY6.sel-Mp0M2 .wcImage--G64h {\n  border: 4px var(--primaryColor) solid;\n  border: 4px var(--optionItemBorderSelColor, var(--primaryColor)) solid;\n}\n\n.hexColor-47l-a {\n  width: 80px;\n  height: 80px;\n}\n\n.titleWrapper-kC1Fd {\n  display: flex;\n  justify-content: center;\n  overflow: visible;\n  max-height: 32px;\n}\n\n.title-gcSeP {\n  text-align: center;\n  width: 100%;\n  height: 32px;\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: 2;\n  transition: height 0.3s ease-out;\n}\n\n.mobile--MrOW:not(.tablet-R7-Yj) .title-gcSeP {\n  font-size: 12px;\n  line-height: 14px;\n}\n\n.palette-item-0YKyA:hover .title-gcSeP,\n.palette-item-0YKyA:focus .title-gcSeP {\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: 50px;\n  z-index: 200;\n  background-color: var(--settingsBackgroundColor);\n  border-bottom-left-radius: 6px;\n  border-bottom-right-radius: 6px;\n  transition: height 0.3s ease-in;\n}\n\n@supports (-moz-appearance: none) {\n  .palette-item-0YKyA:hover .title-gcSeP,\n  .palette-item-0YKyA:focus .title-gcSeP {\n    height: -moz-fit-content;\n    height: fit-content;\n  }\n}\n\n/* Size Small */\n\n.small-NQCY6 .wcVCodexText-oxSnB {\n  font-size: 12px;\n}\n\n.small-NQCY6 .title-gcSeP {\n  font-size: 12px;\n  height: 15px;\n  -webkit-line-clamp: 1;\n}\n\n.small-NQCY6 .titleWrapper-kC1Fd {\n  max-height: 14px;\n}\n\n.mobile--MrOW:not(.tablet-R7-Yj).small-NQCY6 .title-gcSeP {\n  font-size: 11px;\n  height: 14px;\n}\n\n.mobile--MrOW:not(.tablet-R7-Yj).small-NQCY6 .titleWrapper-kC1Fd {\n  max-height: 14px;\n}\n\n/* Size big */\n\n.big-Rc8hW .wcVCodexText-oxSnB {\n  font-size: 15px;\n}\n\n.big-Rc8hW .title-gcSeP {\n  font-size: 15px;\n  -webkit-line-clamp: 2;\n}\n\n.mobile--MrOW:not(.tablet-R7-Yj).big-Rc8hW .title-gcSeP {\n  font-size: 13px;\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 Option = function Option(_ref) {
  var _item$hexColor, _renderLayer;
  var itemP = _ref.item,
    type = _ref.type,
    paletteId = _ref.paletteId,
    hidePricePreview = _ref.hidePricePreview,
    namePostFix = _ref.namePostFix;
  var item = itemP;
  var viewHandler = useViewHandler();
  var _useState = useState(''),
    _useState2 = _slicedToArray(_useState, 2),
    metaDataVisible = _useState2[0],
    setMetaDataVisible = _useState2[1];
  var onClick = function onClick() {
    viewHandler.paletteViewHandler.clickedOnConfigPalette(item, undefined, paletteId);
  };
  var _useDivaCore = useDivaCore(),
    _useDivaCore$state$di = _useDivaCore.state.dimensions,
    isMobile = _useDivaCore$state$di.isMobile,
    isTablet = _useDivaCore$state$di.isTablet;

  /* 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.image || item.hexColor) && !item.contentItemId) {
    isOver = hover[0];
    hoverProps = hover[1];
    triggerProps = tooltip.triggerProps;
    layerProps = tooltip.layerProps;
    renderLayer = tooltip.renderLayer;
  }
  return /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread(_objectSpread({
    id: item.codex,
    className: classnames(paletteItem, item.sel ? sel : undefined, type == 'big' ? big : undefined, type == 'small' ? small : undefined, viewHandler.getIsInMobileView() ? mobile : undefined, viewHandler.uiState.isTablet ? tablet : undefined),
    onClick: onClick
  }, triggerProps), hoverProps), {}, {
    children: [/*#__PURE__*/jsxs("div", {
      className: classnames(imageWrapper),
      children: [viewHandler.getViewConfig().showVCodexInGallery && item.vCodex && /*#__PURE__*/jsx("div", {
        className: classnames(wcVCodexText),
        children: item.vCodex
      }), item.image ? /*#__PURE__*/jsx("img", {
        className: classnames(wcImage),
        src: type != 'small' ? item.image.replace('_gal', '') : item.image
      }) : /*#__PURE__*/jsx("div", {
        className: classnames(wcImage),
        style: {
          backgroundColor: '#' + ((_item$hexColor = item.hexColor) !== null && _item$hexColor !== void 0 ? _item$hexColor : 'fff')
        }
      }), item.contentItemId && /*#__PURE__*/jsx(InfoIcon, {
        item: item
      }, item.codex)]
    }), /*#__PURE__*/jsx("div", {
      className: titleWrapper,
      children: /*#__PURE__*/jsx("div", {
        className: title,
        dangerouslySetInnerHTML: {
          __html: item.text + (namePostFix ? namePostFix : '')
        }
      })
    }), item.doShowFav && /*#__PURE__*/jsx("div", {
      className: item.isFav ? wcFavoriteSel : wcFavorite,
      onClick: function onClick() {
        return viewHandler.paletteViewHandler.clickedOnFavIcon(item);
      }
    }), /*#__PURE__*/jsx(MetaData, {
      style: {
        position: 'relative',
        "float": 'left',
        display: 'none'
      },
      metaData: item.metaData,
      visible: [metaDataVisible, setMetaDataVisible]
    }, item.codex), !hidePricePreview && item.pricePreviewPromise !== undefined && /*#__PURE__*/jsx(PricePreview, {
      asyncPricePreview: item.pricePreviewPromise,
      sel: item.sel,
      style: type == 'small' ? {
        fontSize: 9
      } : undefined
    }), item.checkForReversingChanges !== undefined && /*#__PURE__*/jsx(ReverseCheck, {
      item: item,
      paletteId: paletteId
    }), isOver && ((_renderLayer = renderLayer) === null || _renderLayer === void 0 ? void 0 : _renderLayer(/*#__PURE__*/jsx(GenericToolTip, {
      text: item.text + (item.freeText ? item.freeText : '') + (namePostFix ? namePostFix : ''),
      hexColor: item.hexColor,
      desciption: metaDataVisible,
      pricePreviewPromise: item.pricePreviewPromise,
      image: item.image,
      layerProps: layerProps
    }, item.codex)))]
  }));
};
var GalleryText2 = observer(Option);

export { GalleryText2 as default };
