import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import React from 'react';
import cx from 'classnames';
import Icons from '../icon';
import { RcSwitch } from '../components';
import { ConfigContext } from '../config-provider/context';
var LoadingLine = Icons.LoadingLine;
var Switch = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
  var disabled = _ref.disabled,
      loading = _ref.loading,
      size = _ref.size,
      className = _ref.className,
      otherProps = _objectWithoutProperties(_ref, ["disabled", "loading", "size", "className"]);

  var _React$useContext = React.useContext(ConfigContext),
      getPrefixClassName = _React$useContext.getPrefixClassName;

  var switchCls = getPrefixClassName('switch'); // render

  var loadingIcon = /*#__PURE__*/React.createElement("div", {
    className: "".concat(switchCls, "-handle")
  }, loading && /*#__PURE__*/React.createElement(LoadingLine, null));
  return /*#__PURE__*/React.createElement(RcSwitch, Object.assign({}, otherProps, {
    disabled: disabled || loading,
    prefixCls: switchCls,
    size: size,
    ref: ref,
    loadingIcon: loadingIcon,
    className: cx(size === 'large' && "".concat(switchCls, "-lg"), size === 'small' && "".concat(switchCls, "-sm"), loading && "".concat(switchCls, "-loading"), className)
  }));
});
Switch.displayName = 'Switch';
Switch.defaultProps = {
  size: 'medium',
  disabled: false,
  defaultChecked: false,
  loading: false
};
export default Switch;