"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

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

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

var _propTypes = _interopRequireDefault(require("prop-types"));

var _utils = require("../utils");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _getProps(min, max, value, rtl) {
  return {
    style: {
      left: rtl ? "".concat(100 - (0, _utils.getPercent)(min, max, value), "%") : "".concat((0, _utils.getPercent)(min, max, value), "%"),
      zIndex: 100
    },
    'aria-valuenow': value,
    'aria-valuetext': value,
    'aria-valuemin': min,
    'aria-valuemax': max
  };
}

function Slider(_ref) {
  var _classNames;

  var prefix = _ref.prefix,
      hasMovingClass = _ref.hasMovingClass,
      min = _ref.min,
      max = _ref.max,
      value = _ref.value,
      onKeyDown = _ref.onKeyDown,
      rtl = _ref.rtl;
  var classes = (0, _classnames["default"])((_classNames = {}, _defineProperty(_classNames, "".concat(prefix, "range-slider"), true), _defineProperty(_classNames, "".concat(prefix, "range-slider-moving"), hasMovingClass), _classNames));
  return _react["default"].createElement("div", _extends({
    className: classes,
    onKeyDown: onKeyDown,
    role: "slider",
    tabIndex: 0
  }, _getProps(min, max, value, rtl)), _react["default"].createElement("div", {
    className: "".concat(prefix, "range-slider-inner")
  }));
}

Slider.propTypes = {
  min: _propTypes["default"].number,
  max: _propTypes["default"].number,
  value: _propTypes["default"].number,
  prefix: _propTypes["default"].string,
  hasMovingClass: _propTypes["default"].bool,
  rtl: _propTypes["default"].bool
};
Slider.defaultProps = {
  prefix: 'next-',
  min: 0,
  max: 100,
  value: 0,
  hasMovingClass: false,
  rtl: false
};
var _default = Slider;
exports["default"] = _default;