"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
require("@emotion/react");
const React = require("react");
const jsxRuntime = require("@emotion/react/jsx-runtime");
const styled = require("./styled.js");
const checkLeftSize = {
  default: "calc(100% - 20px);",
  small: "calc(100% - 14px);"
};
const Switch = function({
  defaultChecked,
  controlChecked,
  onChange,
  size = "default",
  cssStyle,
  className,
  style
}) {
  const [checked, setChecked] = React.useState(defaultChecked);
  React.useEffect(() => {
    if (controlChecked !== void 0) {
      setChecked(controlChecked);
    }
  }, [controlChecked]);
  return /* @__PURE__ */ jsxRuntime.jsx(
    styled.SwitchButton,
    {
      size,
      checked,
      type: "button",
      role: "switch",
      "aria-checked": "true",
      "ant-click-animating": "false",
      onClick: () => {
        setChecked(!checked);
        onChange == null ? void 0 : onChange(!checked);
      },
      css: cssStyle,
      className,
      style,
      children: /* @__PURE__ */ jsxRuntime.jsx(
        styled.SwitchDot,
        {
          size,
          checked,
          checkedLeft: checkLeftSize[size]
        }
      )
    }
  );
};
exports.Switch = Switch;
//# sourceMappingURL=index.js.map
