import{r as t,aW as I,bv as j,aS as L,ao as M,bc as v,aX as N,aV as y,am as T,bM as x,ar as H,aq as O,at as u,as as S,e0 as W}from"./index-D2cxrzyv.js";var q=["prefixCls","className","style","checked","disabled","defaultChecked","type","title","onChange"],G=t.forwardRef(function(e,r){var a=e.prefixCls,i=a===void 0?"rc-checkbox":a,b=e.className,l=e.style,w=e.checked,s=e.disabled,p=e.defaultChecked,R=p===void 0?!1:p,h=e.type,f=h===void 0?"checkbox":h,P=e.title,d=e.onChange,_=I(e,q),c=t.useRef(null),g=t.useRef(null),D=j(R,{value:w}),$=L(D,2),C=$[0],z=$[1];t.useImperativeHandle(r,function(){return{focus:function(o){var n;(n=c.current)===null||n===void 0||n.focus(o)},blur:function(){var o;(o=c.current)===null||o===void 0||o.blur()},input:c.current,nativeElement:g.current}});var B=M(i,b,v(v({},"".concat(i,"-checked"),C),"".concat(i,"-disabled"),s)),E=function(o){s||("checked"in e||z(o.target.checked),d==null||d({target:y(y({},e),{},{type:f,checked:o.target.checked}),stopPropagation:function(){o.stopPropagation()},preventDefault:function(){o.preventDefault()},nativeEvent:o.nativeEvent}))};return t.createElement("span",{className:B,title:P,style:l,ref:g},t.createElement("input",N({},_,{className:"".concat(i,"-input"),ref:c,onChange:E,disabled:s,checked:!!C,type:f})),t.createElement("span",{className:"".concat(i,"-inner")}))});function V(e){const r=T.useRef(null),a=()=>{x.cancel(r.current),r.current=null};return[()=>{a(),r.current=x(()=>{r.current=null})},l=>{r.current&&(l.stopPropagation(),a()),e==null||e(l)}]}const F=e=>{const{checkboxCls:r}=e,a=`${r}-wrapper`;return[{[`${r}-group`]:Object.assign(Object.assign({},u(e)),{display:"inline-flex",flexWrap:"wrap",columnGap:e.marginXS,[`> ${e.antCls}-row`]:{flex:1}}),[a]:Object.assign(Object.assign({},u(e)),{display:"inline-flex",alignItems:"baseline",cursor:"pointer","&:after":{display:"inline-block",width:0,overflow:"hidden",content:"'\\a0'"},[`& + ${a}`]:{marginInlineStart:0},[`&${a}-in-form-item`]:{'input[type="checkbox"]':{width:14,height:14}}}),[r]:Object.assign(Object.assign({},u(e)),{position:"relative",whiteSpace:"nowrap",lineHeight:1,cursor:"pointer",borderRadius:e.borderRadiusSM,alignSelf:"center",[`${r}-input`]:{position:"absolute",inset:0,zIndex:1,cursor:"pointer",opacity:0,margin:0,[`&:focus-visible + ${r}-inner`]:W(e)},[`${r}-inner`]:{boxSizing:"border-box",display:"block",width:e.checkboxSize,height:e.checkboxSize,direction:"ltr",backgroundColor:e.colorBgContainer,border:`${S(e.lineWidth)} ${e.lineType} ${e.colorBorder}`,borderRadius:e.borderRadiusSM,borderCollapse:"separate",transition:`all ${e.motionDurationSlow}`,"&:after":{boxSizing:"border-box",position:"absolute",top:"50%",insetInlineStart:"25%",display:"table",width:e.calc(e.checkboxSize).div(14).mul(5).equal(),height:e.calc(e.checkboxSize).div(14).mul(8).equal(),border:`${S(e.lineWidthBold)} solid ${e.colorWhite}`,borderTop:0,borderInlineStart:0,transform:"rotate(45deg) scale(0) translate(-50%,-50%)",opacity:0,content:'""',transition:`all ${e.motionDurationFast} ${e.motionEaseInBack}, opacity ${e.motionDurationFast}`}},"& + span":{paddingInlineStart:e.paddingXS,paddingInlineEnd:e.paddingXS}})},{[` ${a}:not(${a}-disabled), ${r}:not(${r}-disabled) `]:{[`&:hover ${r}-inner`]:{borderColor:e.colorPrimary}},[`${a}:not(${a}-disabled)`]:{[`&:hover ${r}-checked:not(${r}-disabled) ${r}-inner`]:{backgroundColor:e.colorPrimaryHover,borderColor:"transparent"},[`&:hover ${r}-checked:not(${r}-disabled):after`]:{borderColor:e.colorPrimaryHover}}},{[`${r}-checked`]:{[`${r}-inner`]:{backgroundColor:e.colorPrimary,borderColor:e.colorPrimary,"&:after":{opacity:1,transform:"rotate(45deg) scale(1) translate(-50%,-50%)",transition:`all ${e.motionDurationMid} ${e.motionEaseOutBack} ${e.motionDurationFast}`}}},[` ${a}-checked:not(${a}-disabled), ${r}-checked:not(${r}-disabled) `]:{[`&:hover ${r}-inner`]:{backgroundColor:e.colorPrimaryHover,borderColor:"transparent"}}},{[r]:{"&-indeterminate":{"&":{[`${r}-inner`]:{backgroundColor:`${e.colorBgContainer}`,borderColor:`${e.colorBorder}`,"&:after":{top:"50%",insetInlineStart:"50%",width:e.calc(e.fontSizeLG).div(2).equal(),height:e.calc(e.fontSizeLG).div(2).equal(),backgroundColor:e.colorPrimary,border:0,transform:"translate(-50%, -50%) scale(1)",opacity:1,content:'""'}},[`&:hover ${r}-inner`]:{backgroundColor:`${e.colorBgContainer}`,borderColor:`${e.colorPrimary}`}}}}},{[`${a}-disabled`]:{cursor:"not-allowed"},[`${r}-disabled`]:{[`&, ${r}-input`]:{cursor:"not-allowed",pointerEvents:"none"},[`${r}-inner`]:{background:e.colorBgContainerDisabled,borderColor:e.colorBorder,"&:after":{borderColor:e.colorTextDisabled}},"&:after":{display:"none"},"& + span":{color:e.colorTextDisabled},[`&${r}-indeterminate ${r}-inner::after`]:{background:e.colorTextDisabled}}}]};function X(e,r){const a=H(r,{checkboxCls:`.${e}`,checkboxSize:r.controlInteractiveSize});return F(a)}const A=O("Checkbox",(e,{prefixCls:r})=>[X(r,e)]);export{G as C,V as a,X as g,A as u};