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