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 { useState } from 'react';
import { useHover, useLayer } from 'react-laag';
import { observer } from 'mobx-react-lite';
import { w as wcFavoriteSel, a as wcFavorite } from './index.module-25687dd9.js';
import classnames from 'classnames';
import IsActive from './index-3f40a92d.js';
import { useDivaCore } from '@crystaldesign/diva-core';
import InfoIcon from './index-04a7a9b4.js';
import ReverseCheck from './index-755074ae.js';
import { jsxs, Fragment, 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-nvOSq";
var wcSize = "wcSize-MLnBm";
var wcSizeGallery = "wcSize-gallery-IzaJk";
var sel = "sel-8nnXG";
var wcVCodexTextWrapper = "wcVCodexTextWrapper-U7uto";
var wcVCodexText = "wcVCodexText-PAE-G";
var wcGallery = "wcGallery-VQGx-";
var hexColor = "hexColor-Geitq";
var css_248z = ".palette-item-nvOSq .wcSize-MLnBm.wcSize-gallery-IzaJk {\n  width: 100%;\n  background: transparent;\n  position: relative;\n  border-radius: var(--globalBorderRadius);\n  display: flex;\n}\n.palette-item-nvOSq {\n  --galleryItemSelBorder: var(--galleryItemBorder);\n  border: var(--galleryItemBorder) solid var(--galleryItemBorderColor);\n}\n.palette-item-nvOSq:hover {\n  --galleryItemSelBorder: var(--galleryItemBorder);\n  border: var(--galleryItemBorder) solid var(--galleryItemBorderHoverColor);\n  box-shadow: var(--gallerySelectedBoxShadow);\n}\n\n.palette-item-nvOSq.sel-8nnXG {\n  border: var(--galleryItemBorder) solid var(--galleryItemBorderSelColor);\n  box-shadow: var(--gallerySelectedBoxShadow);\n}\n\n.wcVCodexTextWrapper-U7uto {\n  width: 100%;\n  height: 100%;\n  position: absolute;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n}\n\n.wcVCodexText-PAE-G {\n  width: 100%;\n  font-size: 18px;\n  text-shadow: 3px 4px 15px rgba(0,0,0,0.6);\n  color: white;\n  display: none;\n  text-align: center;\n  word-break: break-all;\n}\n\n.palette-item-nvOSq:hover .wcVCodexText-PAE-G,\n.sel-8nnXG .wcVCodexText-PAE-G {\n  display: block;\n}\n\n.palette-item-nvOSq.wcGallery-VQGx- {\n  display: block;\n  background: transparent;\n  margin: 0;\n  margin: initial;\n  position: relative;\n  float: left;\n  border-radius: var(--galleryItemRadius);\n  z-index: 100;\n  cursor: pointer;\n  width: 100%;\n}\n\n.palette-item-nvOSq.wcGallery-VQGx- img {\n  width: 100%;\n  height: 100%;\n  border-radius: var(--galleryItemRadius);\n  aspect-ratio: 1 / 1;\n  -webkit-touch-callout: none;\n  -webkit-user-select: none;\n  -moz-user-select: none;\n  user-select: none;\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}\n.hexColor-Geitq {\n  width: 80px;\n  height: 80px;\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 Gallery = function Gallery(_ref) {
  var _item$freeText, _renderLayer;
  var itemP = _ref.item,
    hidePricePreview = _ref.hidePricePreview,
    paletteId = _ref.paletteId,
    style = _ref.style,
    _ref$isActive = _ref.isActive,
    isActive = _ref$isActive === void 0 ? /*#__PURE__*/jsx(IsActive, {
      listenToGalleryVariables: true
    }) : _ref$isActive,
    namePostFix = _ref.namePostFix;
  var item = itemP;
  var viewHandler = useViewHandler();
  var _useDivaCore = useDivaCore(),
    _useDivaCore$state$di = _useDivaCore.state.dimensions,
    isMobile = _useDivaCore$state$di.isMobile,
    isTablet = _useDivaCore$state$di.isTablet;
  var onClick = function onClick() {
    if (item.doShowFav) {
      viewHandler.paletteViewHandler.clickedOnFavIcon(item);
    }
    viewHandler.paletteViewHandler.clickedOnConfigPalette(item, undefined, paletteId);
  };
  var _useState = useState(''),
    _useState2 = _slicedToArray(_useState, 2),
    metaDataVisible = _useState2[0];
    _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 && (item.image || item.hexColor) && !item.contentItemId) {
    isOver = hover[0];
    hoverProps = hover[1];
    triggerProps = tooltip.triggerProps;
    layerProps = tooltip.layerProps;
    renderLayer = tooltip.renderLayer;
  }
  return /*#__PURE__*/jsxs(Fragment, {
    children: [/*#__PURE__*/jsxs("div", _objectSpread(_objectSpread(_objectSpread({
      style: style,
      id: item.codex,
      "data-test-id": "plannerPaletteItem",
      className: classnames(paletteItem, wcGallery, item.sel ? sel : undefined),
      onClick: onClick
    }, triggerProps), hoverProps), {}, {
      children: [/*#__PURE__*/jsxs("div", {
        className: classnames(wcSize, wcSizeGallery),
        children: [!item.doShowFav && item.sel && isActive !== undefined && isActive, item.contentItemId && /*#__PURE__*/jsx(InfoIcon, {
          item: item
        }, item.codex), (viewHandler.getViewConfig().showVCodexInGallery && item.vCodex || item.freeText) && /*#__PURE__*/jsx("div", {
          className: wcVCodexTextWrapper,
          children: /*#__PURE__*/jsx("div", {
            className: classnames(wcVCodexText),
            children: (_item$freeText = item.freeText) !== null && _item$freeText !== void 0 ? _item$freeText : item.vCodex + (namePostFix ? namePostFix : '')
          })
        }), item.image ? /*#__PURE__*/jsx("img", {
          src: item.image
        }) : item.hexColor ? /*#__PURE__*/jsx("div", {
          className: hexColor,
          style: {
            backgroundColor: '#' + item.hexColor
          }
        }) : /*#__PURE__*/jsx(Fragment, {}), item.doShowFav && /*#__PURE__*/jsx("div", {
          className: item.isFav ? wcFavoriteSel : wcFavorite
        })]
      }), !hidePricePreview && item.pricePreviewPromise !== undefined && /*#__PURE__*/jsx(PricePreview, {
        asyncPricePreview: item.pricePreviewPromise,
        sel: item.sel
      }), 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 + (namePostFix ? namePostFix : ''),
      desciption: metaDataVisible,
      image: item.image,
      layerProps: layerProps,
      pricePreviewPromise: item.pricePreviewPromise,
      hexColor: item.hexColor
    }, item.codex)))]
  });
};
var Gallery$1 = observer(Gallery);

export { Gallery$1 as default };
