const e=require("../_util/type.js"),t=require("../_util/warning.js"),n=require("../_util/omit.js"),r=require("../config-provider/DisabledContext.js"),i=require("../_util/props-util/index.js"),a=require("../config-provider/hooks/useConfigInject.js"),o=require("../_util/vue-types/index.js"),s=require("../form/FormItemContext.js"),c=require("../_util/KeyCode.js"),l=require("../_util/wave/index.js"),u=require("./style/index.js");let d=require("vue"),f=require("@antsoo-lib/icons");var p=e.tuple(`small`,`default`),m=()=>({id:String,prefixCls:String,size:o.default.oneOf(p),disabled:{type:Boolean,default:void 0},checkedChildren:o.default.any,unCheckedChildren:o.default.any,tabindex:o.default.oneOfType([o.default.string,o.default.number]),autofocus:{type:Boolean,default:void 0},loading:{type:Boolean,default:void 0},checked:o.default.oneOfType([o.default.string,o.default.number,o.default.looseBool]),checkedValue:o.default.oneOfType([o.default.string,o.default.number,o.default.looseBool]).def(!0),unCheckedValue:o.default.oneOfType([o.default.string,o.default.number,o.default.looseBool]).def(!1),onChange:{type:Function},onClick:{type:Function},onKeydown:{type:Function},onMouseup:{type:Function},"onUpdate:checked":{type:Function},onBlur:Function,onFocus:Function}),h=(0,d.defineComponent)({compatConfig:{MODE:3},name:`ASwitch`,__ANT_SWITCH:!0,inheritAttrs:!1,props:m(),slots:Object,setup(e,{attrs:o,slots:p,expose:m,emit:h}){let g=s.useInjectFormItemContext(),_=r.useInjectDisabled(),v=(0,d.computed)(()=>e.disabled??_.value);(0,d.onBeforeMount)(()=>{t.default(!(`defaultChecked`in o),`Switch`,`'defaultChecked' is deprecated, please use 'v-model:checked'`),t.default(!(`value`in o),`Switch`,"`value` is not validate prop, do you mean `checked`?")});let y=(0,d.ref)(e.checked===void 0?o.defaultChecked:e.checked),b=(0,d.computed)(()=>y.value===e.checkedValue);(0,d.watch)(()=>e.checked,()=>{y.value=e.checked});let{prefixCls:x,direction:S,size:C}=a.default(`switch`,e),[w,T]=u.default(x),E=(0,d.ref)(),D=()=>{E.value?.focus()};m({focus:D,blur:()=>{E.value?.blur()}}),(0,d.onMounted)(()=>{(0,d.nextTick)(()=>{e.autofocus&&!v.value&&E.value.focus()})});let O=(e,t)=>{v.value||(h(`update:checked`,e),h(`change`,e,t),g.onFieldChange())},k=e=>{h(`blur`,e)},A=t=>{D();let n=b.value?e.unCheckedValue:e.checkedValue;O(n,t),h(`click`,n,t)},j=t=>{t.keyCode===c.default.LEFT?O(e.unCheckedValue,t):t.keyCode===c.default.RIGHT&&O(e.checkedValue,t),h(`keydown`,t)},M=e=>{E.value?.blur(),h(`mouseup`,e)},N=(0,d.computed)(()=>({[`${x.value}-small`]:C.value===`small`,[`${x.value}-loading`]:e.loading,[`${x.value}-checked`]:b.value,[`${x.value}-disabled`]:v.value,[x.value]:!0,[`${x.value}-rtl`]:S.value===`rtl`,[T.value]:!0}));return()=>w((0,d.createVNode)(l.default,null,{default:()=>[(0,d.createVNode)(`button`,{...n.default(e,[`prefixCls`,`checkedChildren`,`unCheckedChildren`,`checked`,`autofocus`,`checkedValue`,`unCheckedValue`,`id`,`onChange`,`onUpdate:checked`]),...o,id:e.id??g.id.value,onKeydown:j,onClick:A,onBlur:k,onMouseup:M,type:`button`,role:`switch`,"aria-checked":y.value,disabled:v.value||e.loading,class:[o.class,N.value],ref:E},[(0,d.createVNode)(`div`,{class:`${x.value}-handle`},[e.loading?(0,d.createVNode)(f.LoadingOutlined,{class:`${x.value}-loading-icon`},null):null]),(0,d.createVNode)(`span`,{class:`${x.value}-inner`},[(0,d.createVNode)(`span`,{class:`${x.value}-inner-checked`},[i.getPropsSlot(p,e,`checkedChildren`)]),(0,d.createVNode)(`span`,{class:`${x.value}-inner-unchecked`},[i.getPropsSlot(p,e,`unCheckedChildren`)])])])]}))}}),g=e.withInstall(h);exports.SwitchSizes=p,exports.default=g,exports.switchProps=m;