"use strict";

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

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

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

var _color = _interopRequireDefault(require("color"));

var _ThemeProvider = require("../ThemeProvider");

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

var sizes = {
  lg: {
    thumb: '24px',
    trackHeight: '4px',
    innerThumb: '6px'
  },
  md: {
    thumb: '18px',
    trackHeight: '4px',
    innerThumb: '4px'
  },
  sm: {
    thumb: '14px',
    trackHeight: '2px',
    innerThumb: '2px'
  }
};
exports.sizes = sizes;

var sliderStyle = function sliderStyle(_ref, theme) {
  var _ref$color = _ref.color,
      fillColor = _ref$color === void 0 ? 'primary' : _ref$color,
      _ref$size = _ref.size,
      size = _ref$size === void 0 ? 'md' : _ref$size,
      trackPercent = _ref.trackPercent;
  var centerProps = {
    position: 'absolute',
    top: '50%',
    transform: "translateY(-50%)"
  };
  var _sizes$size = sizes[size],
      trackHeight = _sizes$size.trackHeight,
      thumbSize = _sizes$size.thumb;
  var disabledTrackColor = (0, _color["default"])(theme.colors.track).darken(0.1).hex();
  return {
    style: {
      width: 'full',
      display: 'inline-block',
      position: 'relative',
      cursor: 'pointer',
      py: 3,
      _disabled: {
        opacity: 0.6,
        cursor: 'default',
        pointerEvents: 'none'
      }
    },
    track: _objectSpread(_objectSpread({}, centerProps), {}, {
      height: trackHeight,
      borderRadius: 'radius',
      width: '100%',
      bg: 'track',
      _disabled: {
        bg: disabledTrackColor
      }
    }),
    filledTrack: _objectSpread(_objectSpread({}, centerProps), {}, {
      height: trackHeight,
      bg: "".concat(fillColor, ".500"),
      width: "".concat(trackPercent, "%"),
      rounded: 'radius',
      zIndex: 1
    }),
    thumb: _objectSpread(_objectSpread({}, centerProps), {}, {
      size: thumbSize,
      rounded: 'full',
      bg: 'white',
      boxShadow: 'sm',
      left: "calc(".concat(trackPercent, "% - ").concat(thumbSize, " / 2)"),
      border: '1px',
      borderColor: 'border',
      transition: 'transform 0.2s',
      zIndex: 2,
      _focus: {
        boxShadow: 'outline'
      },
      _disabled: {
        bg: disabledTrackColor
      },
      _active: {
        transform: "translateY(-50%) scale(1.15)"
      }
    })
  };
};

exports.sliderStyle = sliderStyle;

var useSliderStyle = function useSliderStyle(props) {
  var theme = (0, _ThemeProvider.useTheme)();
  var styles = theme['styles'].slider ? theme['styles'].slider(props, theme) : sliderStyle(props, theme);
  return {
    root: styles.style,
    track: styles.track,
    filledTrack: styles.filledTrack,
    thumb: styles.thumb
  };
};

var _default = useSliderStyle;
exports["default"] = _default;
//# sourceMappingURL=styles.js.map