import { _ as _extends } from '../extends-C4cduGrv.js';
import { _ as _objectWithoutProperties } from '../objectWithoutProperties-TXwlfNxG.js';
import { _ as _defineProperty } from '../defineProperty-CEd-kZQW.js';
import React__default from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';

var _excluded = ["checked", "onChange", "className"];

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) { _defineProperty(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 STYLES = {
  padding: 2,
  width: 44,
  height: 24
};

var DISABLED_STYLES = _objectSpread({
  filter: "grayscale(100%)",
  cursor: "not-allowed",
  opacity: 0.75
}, STYLES);

function ToggleInput(_ref) {
  var checked = _ref.checked,
      onChange = _ref.onChange,
      className = _ref.className,
      props = _objectWithoutProperties(_ref, _excluded);

  var backgroundColor = checked ? "bg-green-400" : "bg-gray-500";
  var thumbPosition = checked ? "translate-x-full" : "translate-x-0";
  var activeStyle = props.disabled ? DISABLED_STYLES : STYLES;
  return /*#__PURE__*/React__default.createElement("div", {
    className: cx("inline-flex rounded-full transition-colors duration-200 focus:outline-none focus:shadow-outline ".concat(backgroundColor, " relative"), className),
    style: activeStyle
  }, /*#__PURE__*/React__default.createElement("div", {
    className: "top-0 left-0 bg-white w-5 h-5 rounded-full transition-all duration-200 transform ".concat(thumbPosition)
  }), /*#__PURE__*/React__default.createElement("input", _extends({}, props, {
    onChange: onChange,
    checked: checked,
    type: "checkbox",
    className: "appearance-none absolute w-full h-full"
  })));
}

ToggleInput.propTypes = {
  checked: PropTypes.bool.isRequired,
  onChange: PropTypes.func.isRequired,
  disabled: PropTypes.bool,
  className: PropTypes.string
};

export { ToggleInput as default };
