import M from "../../@babel/runtime/helpers/esm/extends.mjs";
import k from "../../@babel/runtime/helpers/esm/defineProperty.mjs";
import P from "../../@babel/runtime/helpers/esm/slicedToArray.mjs";
import R from "../../@babel/runtime/helpers/esm/objectWithoutProperties.mjs";
import * as a from "react";
import T from "../../classnames/index.mjs";
import j from "../../rc-util/es/hooks/useMergedState.mjs";
import p from "../../rc-util/es/KeyCode.mjs";
var A = ["prefixCls", "className", "checked", "defaultChecked", "disabled", "loadingIcon", "checkedChildren", "unCheckedChildren", "onClick", "onChange", "onKeyDown"], F = /* @__PURE__ */ a.forwardRef(function(e, f) {
  var o, C = e.prefixCls, c = C === void 0 ? "rc-switch" : C, v = e.className, g = e.checked, w = e.defaultChecked, d = e.disabled, N = e.loadingIcon, y = e.checkedChildren, b = e.unCheckedChildren, r = e.onClick, l = e.onChange, s = e.onKeyDown, x = R(e, A), I = j(!1, {
    value: g,
    defaultValue: w
  }), u = P(I, 2), i = u[0], K = u[1];
  function h(n, m) {
    var t = i;
    return d || (t = n, K(t), l == null || l(t, m)), t;
  }
  function D(n) {
    n.which === p.LEFT ? h(!1, n) : n.which === p.RIGHT && h(!0, n), s == null || s(n);
  }
  function E(n) {
    var m = h(!i, n);
    r == null || r(m, n);
  }
  var S = T(c, v, (o = {}, k(o, "".concat(c, "-checked"), i), k(o, "".concat(c, "-disabled"), d), o));
  return /* @__PURE__ */ a.createElement("button", M({}, x, {
    type: "button",
    role: "switch",
    "aria-checked": i,
    disabled: d,
    className: S,
    ref: f,
    onKeyDown: D,
    onClick: E
  }), N, /* @__PURE__ */ a.createElement("span", {
    className: "".concat(c, "-inner")
  }, /* @__PURE__ */ a.createElement("span", {
    className: "".concat(c, "-inner-checked")
  }, y), /* @__PURE__ */ a.createElement("span", {
    className: "".concat(c, "-inner-unchecked")
  }, b)));
});
F.displayName = "Switch";
export {
  F as default
};
