import{a as s,j as K,t as T,u as I,h as f,C as $,S as R,D as W,k as L,L as M}from"./index-a6248777.js";import{u as A}from"./index-d52e4464.js";import{K as S,W as H}from"./index-3bb9c29d.js";var O=s.forwardRef(function(e,i){var n,a=e.prefixCls,t=a===void 0?"rc-switch":a,r=e.className,d=e.checked,v=e.defaultChecked,C=e.disabled,x=e.loadingIcon,g=e.checkedChildren,k=e.unCheckedChildren,h=e.onClick,u=e.onChange,m=e.onKeyDown,w=K(e,["prefixCls","className","checked","defaultChecked","disabled","loadingIcon","checkedChildren","unCheckedChildren","onClick","onChange","onKeyDown"]),o=A(!1,{value:d,defaultValue:v}),p=T(o,2),c=p[0],D=p[1];function y(l,N){var b=c;return C||(b=l,D(b),u==null||u(b,N)),b}function P(l){l.which===S.LEFT?y(!1,l):l.which===S.RIGHT&&y(!0,l),m==null||m(l)}function j(l){var N=y(!c,l);h==null||h(N,l)}var z=I(t,r,(n={},f(n,"".concat(t,"-checked"),c),f(n,"".concat(t,"-disabled"),C),n));return s.createElement("button",Object.assign({},w,{type:"button",role:"switch","aria-checked":c,disabled:C,className:z,ref:i,onKeyDown:P,onClick:j}),x,s.createElement("span",{className:"".concat(t,"-inner")},c?g:k))});O.displayName="Switch";var _=globalThis&&globalThis.__rest||function(e,i){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&i.indexOf(a)<0&&(n[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,a=Object.getOwnPropertySymbols(e);t<a.length;t++)i.indexOf(a[t])<0&&Object.prototype.propertyIsEnumerable.call(e,a[t])&&(n[a[t]]=e[a[t]]);return n},E=s.forwardRef(function(e,i){var n,a=e.prefixCls,t=e.size,r=e.disabled,d=e.loading,v=e.className,C=v===void 0?"":v,x=_(e,["prefixCls","size","disabled","loading","className"]),g=s.useContext($),k=g.getPrefixCls,h=g.direction,u=s.useContext(R),m=s.useContext(W),w=(r??m)||d,o=k("switch",a),p=s.createElement("div",{className:"".concat(o,"-handle")},d&&s.createElement(M,{className:"".concat(o,"-loading-icon")})),c=I((n={},f(n,"".concat(o,"-small"),(t||u)==="small"),f(n,"".concat(o,"-loading"),d),f(n,"".concat(o,"-rtl"),h==="rtl"),n),C);return s.createElement(H,{insertExtraNode:!0},s.createElement(O,L({},x,{prefixCls:o,className:c,disabled:w,ref:i,loadingIcon:p})))});E.__ANT_SWITCH=!0;const q=E;export{q as S};
