import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import { s as styleInject, u as useViewHandler, S as SettingsHeader } from './index-bbdfb97a.js';
import { useState, useEffect } from 'react';
import { observer } from 'mobx-react-lite';
import Slider$1 from 'rc-slider';
import classnames from 'classnames';
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
import '@babel/runtime/helpers/defineProperty';
import 'react-dynamic-multi-render';
import '@crystaldesign/diva-core';
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 wrapper = "wrapper-JzMTM";
var slideWrapper = "slide-wrapper-arLxY";
var css_248z = ".wrapper-JzMTM {\n  display: flex;\n  justify-content: center;\n  flex-direction: column;\n  margin-bottom: 24px;\n}\n\n.slide-wrapper-arLxY {\n  width: calc(100% - 64px);\n  padding: 0px 32px;\n}\n\n.slide-wrapper-arLxY .rc-slider {\n  position: relative;\n  width: 100%;\n  height: 14px;\n  padding: 5px 0;\n  border-radius: 6px;\n  touch-action: none;\n  box-sizing: border-box;\n  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n}\n.slide-wrapper-arLxY .rc-slider * {\n  box-sizing: border-box;\n  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n}\n.slide-wrapper-arLxY .rc-slider-rail {\n  position: absolute;\n  width: 100%;\n  height: 4px;\n  background-color: #e9e9e9;\n  border-radius: 6px;\n}\n.slide-wrapper-arLxY .rc-slider-track,\n.slide-wrapper-arLxY .rc-slider-tracks {\n  position: absolute;\n  height: 4px;\n  background-color: #abe2fb;\n  border-radius: 6px;\n}\n.slide-wrapper-arLxY .rc-slider-track-draggable {\n  z-index: 1;\n  box-sizing: content-box;\n  background-clip: content-box;\n  border-top: 5px solid rgba(0, 0, 0, 0);\n  border-bottom: 5px solid rgba(0, 0, 0, 0);\n  transform: translateY(-5px);\n}\n.slide-wrapper-arLxY .rc-slider-handle {\n  position: absolute;\n  z-index: 1;\n  width: 14px;\n  height: 14px;\n  margin-top: -5px;\n  background-color: #fff;\n  border: solid 2px #96dbfa;\n  border-radius: 50%;\n  cursor: pointer;\n  cursor: grab;\n  opacity: 0.8;\n  -webkit-user-select: none;\n     -moz-user-select: none;\n          user-select: none;\n  touch-action: pan-x;\n}\n.slide-wrapper-arLxY .rc-slider-handle-dragging.rc-slider-handle-dragging.rc-slider-handle-dragging {\n  border-color: #57c5f7;\n  box-shadow: 0 0 0 5px #96dbfa;\n}\n.slide-wrapper-arLxY .rc-slider-handle-dragging.rc-slider-handle-dragging.rc-slider-handle-dragging-delete {\n  opacity: 0;\n}\n.slide-wrapper-arLxY .rc-slider-handle:focus {\n  outline: none;\n  box-shadow: none;\n}\n.slide-wrapper-arLxY .rc-slider-handle.focus-visible {\n  border-color: #2db7f5;\n  box-shadow: 0 0 0 3px #96dbfa;\n}\n.slide-wrapper-arLxY .rc-slider-handle:focus-visible {\n  border-color: #2db7f5;\n  box-shadow: 0 0 0 3px #96dbfa;\n}\n.slide-wrapper-arLxY .rc-slider-handle-click-focused:focus {\n  border-color: #96dbfa;\n  box-shadow: none;\n  box-shadow: initial;\n}\n.slide-wrapper-arLxY .rc-slider-handle:hover {\n  border-color: #57c5f7;\n}\n.slide-wrapper-arLxY .rc-slider-handle:active {\n  border-color: #57c5f7;\n  box-shadow: 0 0 5px #57c5f7;\n  cursor: grabbing;\n}\n.slide-wrapper-arLxY .rc-slider-mark {\n  position: absolute;\n  top: 18px;\n  left: 0;\n  width: 100%;\n  font-size: 12px;\n}\n.slide-wrapper-arLxY .rc-slider-mark-text {\n  position: absolute;\n  display: inline-block;\n  color: #999;\n  text-align: center;\n  vertical-align: middle;\n  cursor: pointer;\n}\n.slide-wrapper-arLxY .rc-slider-mark-text-active {\n  color: #666;\n}\n.slide-wrapper-arLxY .rc-slider-step {\n  position: absolute;\n  width: 100%;\n  height: 4px;\n  background: transparent;\n}\n.slide-wrapper-arLxY .rc-slider-dot {\n  position: absolute;\n  bottom: -2px;\n  width: 8px;\n  height: 8px;\n  vertical-align: middle;\n  background-color: #fff;\n  border: 2px solid #e9e9e9;\n  border-radius: 50%;\n  cursor: pointer;\n}\n.slide-wrapper-arLxY .rc-slider-dot-active {\n  border-color: #96dbfa;\n}\n.slide-wrapper-arLxY .rc-slider-dot-reverse {\n  margin-right: -4px;\n}\n.slide-wrapper-arLxY .rc-slider-disabled {\n  background-color: #e9e9e9;\n}\n.slide-wrapper-arLxY .rc-slider-disabled .rc-slider-track {\n  background-color: #ccc;\n}\n.slide-wrapper-arLxY .rc-slider-disabled .rc-slider-handle,\n.slide-wrapper-arLxY .rc-slider-disabled .rc-slider-dot {\n  background-color: #fff;\n  border-color: #ccc;\n  box-shadow: none;\n  cursor: not-allowed;\n}\n.slide-wrapper-arLxY .rc-slider-disabled .rc-slider-mark-text,\n.slide-wrapper-arLxY .rc-slider-disabled .rc-slider-dot {\n  cursor: not-allowed !important;\n}\n.slide-wrapper-arLxY .rc-slider-vertical {\n  width: 14px;\n  height: 100%;\n  padding: 0 5px;\n}\n.slide-wrapper-arLxY .rc-slider-vertical .rc-slider-rail {\n  width: 4px;\n  height: 100%;\n}\n.slide-wrapper-arLxY .rc-slider-vertical .rc-slider-track {\n  bottom: 0;\n  left: 5px;\n  width: 4px;\n}\n.slide-wrapper-arLxY .rc-slider-vertical .rc-slider-track-draggable {\n  border-top: 0;\n  border-right: 5px solid rgba(0, 0, 0, 0);\n  border-bottom: 0;\n  border-left: 5px solid rgba(0, 0, 0, 0);\n  transform: translateX(-5px);\n}\n.slide-wrapper-arLxY .rc-slider-vertical .rc-slider-handle {\n  position: absolute;\n  z-index: 1;\n  margin-top: 0;\n  margin-left: -5px;\n  touch-action: pan-y;\n}\n.slide-wrapper-arLxY .rc-slider-vertical .rc-slider-mark {\n  top: 0;\n  left: 18px;\n  height: 100%;\n}\n.slide-wrapper-arLxY .rc-slider-vertical .rc-slider-step {\n  width: 4px;\n  height: 100%;\n}\n.slide-wrapper-arLxY .rc-slider-vertical .rc-slider-dot {\n  margin-left: -2px;\n}\n.slide-wrapper-arLxY .rc-slider-tooltip-zoom-down-enter,\n.slide-wrapper-arLxY .rc-slider-tooltip-zoom-down-appear {\n  display: block !important;\n}\n.slide-wrapper-arLxY .rc-slider-tooltip-zoom-down-enter,\n.slide-wrapper-arLxY .rc-slider-tooltip-zoom-down-appear {\n  animation-duration: 0.3s;\n  animation-fill-mode: both;\n  animation-play-state: paused;\n}\n.slide-wrapper-arLxY .rc-slider-tooltip-zoom-down-leave {\n  display: block !important;\n}\n.slide-wrapper-arLxY .rc-slider-tooltip-zoom-down-leave {\n  animation-duration: 0.3s;\n  animation-fill-mode: both;\n  animation-play-state: paused;\n}\n.slide-wrapper-arLxY .rc-slider-tooltip-zoom-down-enter.rc-slider-tooltip-zoom-down-enter-active,\n.slide-wrapper-arLxY .rc-slider-tooltip-zoom-down-appear.rc-slider-tooltip-zoom-down-appear-active {\n  animation-name: rcSliderTooltipZoomDownIn;\n  animation-play-state: running;\n}\n.slide-wrapper-arLxY .rc-slider-tooltip-zoom-down-leave.rc-slider-tooltip-zoom-down-leave-active {\n  animation-name: rcSliderTooltipZoomDownOut;\n  animation-play-state: running;\n}\n.slide-wrapper-arLxY .rc-slider-tooltip-zoom-down-enter,\n.slide-wrapper-arLxY .rc-slider-tooltip-zoom-down-appear {\n  transform: scale(0, 0);\n  animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1);\n}\n.slide-wrapper-arLxY .rc-slider-tooltip-zoom-down-leave {\n  animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);\n}\n@keyframes rcSliderTooltipZoomDownIn-940eH {\n  0% {\n    transform: scale(0, 0);\n    transform-origin: 50% 100%;\n    opacity: 0;\n  }\n  100% {\n    transform: scale(1, 1);\n    transform-origin: 50% 100%;\n  }\n}\n@keyframes rcSliderTooltipZoomDownOut-4UkXB {\n  0% {\n    transform: scale(1, 1);\n    transform-origin: 50% 100%;\n  }\n  100% {\n    transform: scale(0, 0);\n    transform-origin: 50% 100%;\n    opacity: 0;\n  }\n}\n.slide-wrapper-arLxY .rc-slider-tooltip {\n  position: absolute;\n  top: -9999px;\n  left: -9999px;\n  visibility: visible;\n  box-sizing: border-box;\n  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n}\n.slide-wrapper-arLxY .rc-slider-tooltip * {\n  box-sizing: border-box;\n  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n}\n.slide-wrapper-arLxY .rc-slider-tooltip-hidden {\n  display: none;\n}\n.slide-wrapper-arLxY .rc-slider-tooltip-placement-top {\n  padding: 4px 0 8px 0;\n}\n.slide-wrapper-arLxY .rc-slider-tooltip-inner {\n  min-width: 24px;\n  height: 24px;\n  padding: 6px 2px;\n  color: #fff;\n  font-size: 12px;\n  line-height: 1;\n  text-align: center;\n  text-decoration: none;\n  background-color: #6c6c6c;\n  border-radius: 6px;\n  box-shadow: 0 0 4px #d9d9d9;\n}\n.slide-wrapper-arLxY .rc-slider-tooltip-arrow {\n  position: absolute;\n  width: 0;\n  height: 0;\n  border-color: transparent;\n  border-style: solid;\n}\n.slide-wrapper-arLxY .rc-slider-tooltip-placement-top .rc-slider-tooltip-arrow {\n  bottom: 4px;\n  left: 50%;\n  margin-left: -4px;\n  border-width: 4px 4px 0;\n  border-top-color: #6c6c6c;\n}\n";
styleInject(css_248z);

var SliderComponent = function SliderComponent(_ref) {
  var item = _ref.item,
    style = _ref.style,
    paletteId = _ref.paletteId;
  var viewHandler = useViewHandler();
  var _useState = useState({}),
    _useState2 = _slicedToArray(_useState, 2),
    marks = _useState2[0],
    setMarks = _useState2[1];
  var _useState3 = useState([]),
    _useState4 = _slicedToArray(_useState3, 2),
    items = _useState4[0],
    setItems = _useState4[1];
  var _useState5 = useState(),
    _useState6 = _slicedToArray(_useState5, 2),
    curValue = _useState6[0],
    setCurValue = _useState6[1];
  var onChange = function onChange(index) {
    if (Array.isArray(index)) index = index[0];
    setCurValue(index);
    onChangeComplete(index);
  };
  var onChangeComplete = function onChangeComplete(index) {
    if ((index !== null && index !== void 0 ? index : curValue) !== undefined) viewHandler.paletteViewHandler.clickedOnConfigPalette(items[index !== null && index !== void 0 ? index : curValue], undefined, paletteId);
  };
  useEffect(function () {
    var itemList = item.groups.flatMap(function (group) {
      return group.items;
    });
    setItems(itemList);
    setCurValue(itemList.findIndex(function (i) {
      return i.sel;
    }));
    setMarks(itemList.reduce(function (acc, item, i) {
      acc[i] = item.text;
      return acc;
    }, {}));
  }, [item]);
  if (items.length === 0) return /*#__PURE__*/jsx(Fragment, {});
  return /*#__PURE__*/jsxs("div", {
    style: style,
    className: classnames(wrapper, 'no-swiping'),
    children: [/*#__PURE__*/jsx(SettingsHeader, {
      isInScroller: true,
      isSettingsHeader: false,
      item: item
    }), /*#__PURE__*/jsx("div", {
      className: slideWrapper,
      children: /*#__PURE__*/jsx(Slider$1, {
        marks: marks,
        trackStyle: {
          backgroundColor: '#e9e9e9'
        },
        value: curValue,
        onChange: onChange,
        onChangeComplete: onChangeComplete,
        min: Number(Object.keys(marks)[0]),
        max: Number(Object.keys(marks)[Object.keys(marks).length - 1])
      })
    })]
  });
};
var Slider = observer(SliderComponent);

export { Slider as default };
