import * as s from "react";
import I from "../../../@ant-design/icons/es/icons/LoadingOutlined.mjs";
import V from "../../../classnames/index.mjs";
import T from "../../../rc-switch/es/index.mjs";
import D from "../_util/wave/index.mjs";
import "../config-provider/index.mjs";
import H from "../config-provider/DisabledContext.mjs";
import W from "../config-provider/hooks/useSize.mjs";
import R from "./style/index.mjs";
import A from "../../../rc-util/es/hooks/useMergedState.mjs";
import { ConfigContext as L } from "../config-provider/context.mjs";
var M = globalThis && globalThis.__rest || function(t, r) {
  var n = {};
  for (var e in t)
    Object.prototype.hasOwnProperty.call(t, e) && r.indexOf(e) < 0 && (n[e] = t[e]);
  if (t != null && typeof Object.getOwnPropertySymbols == "function")
    for (var o = 0, e = Object.getOwnPropertySymbols(t); o < e.length; o++)
      r.indexOf(e[o]) < 0 && Object.prototype.propertyIsEnumerable.call(t, e[o]) && (n[e[o]] = t[e[o]]);
  return n;
};
const f = /* @__PURE__ */ s.forwardRef((t, r) => {
  const {
    prefixCls: n,
    size: e,
    disabled: o,
    loading: i,
    className: u,
    rootClassName: p,
    style: g,
    checked: c,
    value: h,
    defaultChecked: d,
    defaultValue: C,
    onChange: m
  } = t, v = M(t, ["prefixCls", "size", "disabled", "loading", "className", "rootClassName", "style", "checked", "value", "defaultChecked", "defaultValue", "onChange"]), [b, y] = A(!1, {
    value: c ?? h,
    defaultValue: d ?? C
  }), {
    getPrefixCls: S,
    direction: O,
    switch: a
  } = s.useContext(L), x = s.useContext(H), N = (o ?? x) || i, l = S("switch", n), w = /* @__PURE__ */ s.createElement("div", {
    className: `${l}-handle`
  }, i && /* @__PURE__ */ s.createElement(I, {
    className: `${l}-loading-icon`
  })), [k, P, _] = R(l), j = W(e), z = V(a == null ? void 0 : a.className, {
    [`${l}-small`]: j === "small",
    [`${l}-loading`]: i,
    [`${l}-rtl`]: O === "rtl"
  }, u, p, P, _), E = Object.assign(Object.assign({}, a == null ? void 0 : a.style), g), $ = function() {
    y(arguments.length <= 0 ? void 0 : arguments[0]), m == null || m.apply(void 0, arguments);
  };
  return k(/* @__PURE__ */ s.createElement(D, {
    component: "Switch"
  }, /* @__PURE__ */ s.createElement(T, Object.assign({}, v, {
    checked: b,
    onChange: $,
    prefixCls: l,
    className: z,
    style: E,
    disabled: N,
    ref: r,
    loadingIcon: w
  }))));
});
f.__ANT_SWITCH = !0;
process.env.NODE_ENV !== "production" && (f.displayName = "Switch");
const Z = f;
export {
  Z as default
};
