import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["className", "id", "checked", "onChange", "options", "color"];
import React from "react";
import PropTypes from "prop-types";
import cx from "classnames";
import Typography from "../Typography";
import { getColorsLabels } from "../styles/colors";
import { useId } from "../hooks";
import getClasses from "./styles";
var colorsList = getColorsLabels();

var RoundedSwitch = function RoundedSwitch(props) {
  var className = props.className,
      propId = props.id,
      checked = props.checked,
      onChange = props.onChange,
      options = props.options,
      color = props.color,
      restProps = _objectWithoutProperties(props, _excluded);

  var classes = getClasses({
    color: color
  });
  var id = useId(propId, "rounded-switch");
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("input", _extends({
    id: id,
    type: "checkbox",
    checked: checked,
    onChange: onChange,
    className: classes.input
  }, restProps)), /*#__PURE__*/React.createElement("label", {
    htmlFor: id,
    className: cx(classes.label, className)
  }, /*#__PURE__*/React.createElement("div", {
    className: classes.option,
    "data-side": "left",
    "aria-hidden": "true"
  }, options[0]), /*#__PURE__*/React.createElement("div", {
    "data-side": "selector",
    className: cx(classes.selectedOption, _defineProperty({}, classes.checked, checked))
  }, /*#__PURE__*/React.createElement(Typography, {
    component: "span",
    weight: "bold",
    align: "center",
    variant: "f1-16",
    color: "inherit"
  }, checked ? options[1] : options[0])), /*#__PURE__*/React.createElement("div", {
    className: classes.option,
    "data-side": "right",
    "aria-hidden": "true"
  }, options[1])));
};

RoundedSwitch.propTypes = {
  className: PropTypes.string,
  checked: PropTypes.bool.isRequired,
  onChange: PropTypes.func.isRequired,
  options: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.element])).isRequired,
  color: PropTypes.oneOf(colorsList)
};
RoundedSwitch.defaultProps = {
  className: "",
  color: "secondary"
};
export default RoundedSwitch;