import{ap as P,a9 as K,a as N,aa as a,aq as U,cE as A,aj as g,r as m,f as C,V as E,U as D,al as G,ac as H,J as o,j as h,T as k,aG as L,a1 as W,b9 as y,cP as q,bm as S}from"./index.bde7963b.js";var J=K("small","default"),R=function(){return{id:String,prefixCls:String,size:a.oneOf(J),disabled:{type:Boolean,default:void 0},checkedChildren:a.any,unCheckedChildren:a.any,tabindex:a.oneOfType([a.string,a.number]),autofocus:{type:Boolean,default:void 0},loading:{type:Boolean,default:void 0},checked:a.oneOfType([a.string,a.number,a.looseBool]),checkedValue:a.oneOfType([a.string,a.number,a.looseBool]).def(!0),unCheckedValue:a.oneOfType([a.string,a.number,a.looseBool]).def(!1),onChange:{type:Function},onClick:{type:Function},onKeydown:{type:Function},onMouseup:{type:Function},"onUpdate:checked":{type:Function},onBlur:Function,onFocus:Function}},$=N({name:"ASwitch",__ANT_SWITCH:!0,inheritAttrs:!1,props:R(),slots:["checkedChildren","unCheckedChildren"],setup:function(t,u){var s=u.attrs,p=u.slots,F=u.expose,l=u.emit,x=U();A(function(){g(!("defaultChecked"in s),"Switch","'defaultChecked' is deprecated, please use 'v-model:checked'"),g(!("value"in s),"Switch","`value` is not validate prop, do you mean `checked`?")});var r=m(t.checked!==void 0?t.checked:s.defaultChecked),f=C(function(){return r.value===t.checkedValue});E(function(){return t.checked},function(){r.value=t.checked});var w=D("switch",t),i=w.prefixCls,T=w.direction,V=w.size,d=m(),b=function(){var e;(e=d.value)===null||e===void 0||e.focus()},z=function(){var e;(e=d.value)===null||e===void 0||e.blur()};F({focus:b,blur:z}),G(function(){H(function(){t.autofocus&&!t.disabled&&d.value.focus()})});var v=function(e,c){t.disabled||(l("update:checked",e),l("change",e,c),x.onFieldChange())},_=function(e){l("blur",e)},I=function(e){b();var c=f.value?t.unCheckedValue:t.checkedValue;v(c,e),l("click",c,e)},j=function(e){e.keyCode===S.LEFT?v(t.unCheckedValue,e):e.keyCode===S.RIGHT&&v(t.checkedValue,e),l("keydown",e)},M=function(e){var c;(c=d.value)===null||c===void 0||c.blur(),l("mouseup",e)},O=C(function(){var n;return n={},o(n,"".concat(i.value,"-small"),V.value==="small"),o(n,"".concat(i.value,"-loading"),t.loading),o(n,"".concat(i.value,"-checked"),f.value),o(n,"".concat(i.value,"-disabled"),t.disabled),o(n,i.value,!0),o(n,"".concat(i.value,"-rtl"),T.value==="rtl"),n});return function(){var n;return h(q,{insertExtraNode:!0},{default:function(){return[h("button",k(k(k({},L(t,["prefixCls","checkedChildren","unCheckedChildren","checked","autofocus","checkedValue","unCheckedValue","id","onChange","onUpdate:checked"])),s),{},{id:(n=t.id)!==null&&n!==void 0?n:x.id.value,onKeydown:j,onClick:I,onBlur:_,onMouseup:M,type:"button",role:"switch","aria-checked":r.value,disabled:t.disabled||t.loading,class:[s.class,O.value],ref:d}),[h("div",{class:"".concat(i.value,"-handle")},[t.loading?h(W,{class:"".concat(i.value,"-loading-icon")},null):null]),h("span",{class:"".concat(i.value,"-inner")},[f.value?y(p,t,"checkedChildren"):y(p,t,"unCheckedChildren")])])]}})}}}),X=P($);export{X as S};
