"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.Slider = void 0;

var _style = _interopRequireDefault(require("styled-jsx/style"));

var _react = _interopRequireDefault(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _isThemePalette = _interopRequireDefault(require("../../utils/isThemePalette"));

var _useTheme = _interopRequireDefault(require("../../hooks/useTheme"));

var _jsxRuntime = require("react/jsx-runtime");

// Generated with util/create-component.js
const Slider = props => {
  const theme = (0, _useTheme.default)();
  const {
    children,
    className,
    value,
    max = 100,
    min = 1,
    wrapperProps = {},
    color = "primary",
    shape = "round",
    size = "medium",
    width = "100%",
    fullWidth = false,
    ...otherProps
  } = props;

  function handleBackgroundColor() {
    return theme.palette.shade; // return isThemePalette(color) ? theme.palette[color][500] : color;
  }

  function handleBackgroundColorActive() {
    return (0, _isThemePalette.default)(color) ? theme.palette[color][500] : color;
  }

  function handleWidth() {
    return fullWidth ? "100%" : width;
  }

  function handleShape() {
    switch (shape) {
      case "round":
        return "border-radius: 10em;";

      case "square":
        return "border-radius: 0em;";

      case "rounded":
      default:
        return "border-radius: 0.25em;";
    }
  }

  function handleSize() {
    switch (size) {
      case "xlarge":
        return "25px";

      case "large":
        return "18px";

      case "small":
        return "8px";

      case "mini":
        return "5px";

      case "medium":
      default:
        return "12px";
    }
  }

  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", { ...wrapperProps,
    className: _style.default.dynamic([["1793108931", [handleWidth(), handleWidth(), handleSize(), handleBackgroundColor(), handleShape(), handleSize(), handleSize(), handleBackgroundColorActive(), handleShape(), handleSize(), handleSize(), handleBackgroundColorActive(), handleShape()]]]) + " " + (wrapperProps && wrapperProps.className != null && wrapperProps.className || (0, _classnames.default)("Wps-Slider-Wrapper", (wrapperProps == null ? void 0 : wrapperProps.className) || "") || ""),
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
      type: "range",
      min: min,
      max: max,
      value: value,
      ...otherProps,
      className: _style.default.dynamic([["1793108931", [handleWidth(), handleWidth(), handleSize(), handleBackgroundColor(), handleShape(), handleSize(), handleSize(), handleBackgroundColorActive(), handleShape(), handleSize(), handleSize(), handleBackgroundColorActive(), handleShape()]]]) + " " + (otherProps && otherProps.className != null && otherProps.className || (0, _classnames.default)("Wps-Slider", className) || "")
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_style.default, {
      id: "1793108931",
      dynamic: [handleWidth(), handleWidth(), handleSize(), handleBackgroundColor(), handleShape(), handleSize(), handleSize(), handleBackgroundColorActive(), handleShape(), handleSize(), handleSize(), handleBackgroundColorActive(), handleShape()],
      children: `.Wps-Slider-Wrapper.__jsx-style-dynamic-selector{width:${handleWidth()};}.Wps-Slider.__jsx-style-dynamic-selector{-webkit-appearance:none;width:${handleWidth()};height:${handleSize()};background:${handleBackgroundColor()};outline:none;opacity:0.7;-webkit-transition:0.2s;-webkit-transition:opacity 0.2s;transition:opacity 0.2s;${handleShape()};}.Wps-Slider.__jsx-style-dynamic-selector:hover{opacity:1;}.Wps-Slider.__jsx-style-dynamic-selector::-webkit-slider-thumb{-webkit-appearance:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;width:${handleSize()};height:${handleSize()};background:${handleBackgroundColorActive()};${handleShape()};cursor:pointer;}.Wps-Slider.__jsx-style-dynamic-selector::-moz-range-thumb,.Wps-Slider.__jsx-style-dynamic-selector::-ms-thumb{width:${handleSize()};height:${handleSize()};background:${handleBackgroundColorActive()};${handleShape()};cursor:pointer;}`
    }), children]
  });
};

exports.Slider = Slider;