import e from"../_util/warning.mjs";import t from"../_util/classNames.mjs";import{useInjectDisabled as n}from"../config-provider/DisabledContext.mjs";import{flattenChildren as r}from"../_util/props-util/index.mjs";import i from"../config-provider/hooks/useConfigInject.mjs";import{FormItemInputContext as a,useInjectFormItemContext as o}from"../form/FormItemContext.mjs";import s from"../vc-checkbox/Checkbox.mjs";import c from"./style/index.mjs";import{CheckboxGroupContextKey as l,checkboxProps as u}from"./interface.mjs";import{computed as d,createVNode as f,defineComponent as p,inject as m,onBeforeUnmount as h,onMounted as g,ref as _,watchEffect as v}from"vue";var y=p({compatConfig:{MODE:3},name:`ACheckbox`,inheritAttrs:!1,__ANT_CHECKBOX:!0,props:u(),setup(u,{emit:p,attrs:y,slots:b,expose:x}){let S=o(),C=a.useInject(),{prefixCls:w,direction:T,disabled:E}=i(`checkbox`,u),D=n(),[O,k]=c(w),A=m(l,void 0),j=Symbol(`checkboxUniId`),M=d(()=>A?.disabled.value||E.value);v(()=>{!u.skipGroup&&A&&A.registerValue(j,u.value)}),h(()=>{A&&A.cancelValue(j)}),g(()=>{e(!!(u.checked!==void 0||A||u.value===void 0),`Checkbox`,"`value` is not validate prop, do you mean `checked`?")});let N=e=>{let t=e.target.checked;p(`update:checked`,t),p(`change`,e),S.onFieldChange()},P=_();return x({focus:()=>{P.value?.focus()},blur:()=>{P.value?.blur()}}),()=>{let e=r(b.default?.()),{indeterminate:n,skipGroup:i,id:a=S.id.value,...o}=u,{onMouseenter:c,onMouseleave:l,onInput:d,class:m,style:h,...g}=y,_={...o,id:a,prefixCls:w.value,...g,disabled:M.value};A&&!i?(_.onChange=(...t)=>{p(`change`,...t),A.toggleOption({label:e,value:u.value})},_.name=A.name.value,_.checked=A.mergedValue.value.includes(u.value),_.disabled=M.value||D.value,_.indeterminate=n):_.onChange=N;let v=t({[`${w.value}-wrapper`]:!0,[`${w.value}-rtl`]:T.value===`rtl`,[`${w.value}-wrapper-checked`]:_.checked,[`${w.value}-wrapper-disabled`]:_.disabled,[`${w.value}-wrapper-in-form-item`]:C.isFormItemInput},m,k.value),x=t({[`${w.value}-indeterminate`]:n},k.value);return O(f(`label`,{class:v,style:h,onMouseenter:c,onMouseleave:l},[f(s,{"aria-checked":n?`mixed`:void 0,..._,class:x,ref:P},null),e.length?f(`span`,null,[e]):null]))}}});export{y as default};