"use strict";

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

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

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

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 switchStyle = function switchStyle(_ref, _ref2) {
  var _ref$color = _ref.color,
      color = _ref$color === void 0 ? 'primary' : _ref$color,
      _ref$size = _ref.size,
      size = _ref$size === void 0 ? 'md' : _ref$size;
  var colors = _ref2.colors;
  var sizes = {
    sm: {
      width: '1.5rem',
      height: '0.75rem'
    },
    md: {
      width: '2rem',
      height: '1rem'
    },
    lg: {
      width: '3rem',
      height: '1.5rem'
    }
  };
  var _sizes$size = sizes[size],
      width = _sizes$size.width,
      height = _sizes$size.height;
  return {
    style: {
      height: height,
      width: width,
      rounded: 'full',
      justifyContent: 'flex-start',
      bg: 'track',
      boxSizing: 'content-box',
      color: 'bodyText',
      p: '3px',
      _checked: {
        bg: "".concat(color, ".500")
      },
      _child: {
        transform: "translateX(0)"
      },
      _checkedAndChild: {
        transform: "translateX(calc(".concat(width, " - ").concat(height, "))")
      },
      _focus: {
        boxShadow: 'outline'
      },
      _hover: {
        cursor: 'pointer'
      },
      _checkedAndHover: {
        cursor: 'pointer'
      },
      _disabled: {
        opacity: 0.4,
        cursor: 'not-allowed'
      }
    }
  };
};

exports.switchStyle = switchStyle;

var useSwitchStyle = function useSwitchStyle(props) {
  var theme = (0, _ThemeProvider.useTheme)();
  var styles = theme['styles']["switch"] ? theme['styles']["switch"](props, theme) : switchStyle(props, theme);
  return _objectSpread({}, styles.style);
};

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