import{defineComponent as E,shallowRef as b,onMounted as P,onBeforeUnmount as U,computed as H,createVNode as K}from"vue";import O from"../../_util/classNames.mjs";import u from"../../_util/vue-types/index.mjs";import A from"../../vc-util/Dom/addEventListener.mjs";const Y=E({compatConfig:{MODE:3},name:"Handle",inheritAttrs:!1,props:{prefixCls:String,vertical:{type:Boolean,default:void 0},offset:Number,disabled:{type:Boolean,default:void 0},min:Number,max:Number,value:Number,tabindex:u.oneOfType([u.number,u.string]),reverse:{type:Boolean,default:void 0},ariaLabel:String,ariaLabelledBy:String,ariaValueTextFormatter:Function,onMouseenter:{type:Function},onMouseleave:{type:Function},onMousedown:{type:Function}},setup(s,{attrs:l,emit:i,expose:y}){const n=b(!1),o=b(),x=()=>{document.activeElement===o.value&&(n.value=!0)},h=e=>{n.value=!1,i("blur",e)},M=()=>{n.value=!1},r=()=>{o.value?.focus()},g=()=>{o.value?.blur()},w=()=>{n.value=!0,r()},B=e=>{e.preventDefault(),r(),i("mousedown",e)};y({focus:r,blur:g,clickFocus:w,ref:o});let d=null;P(()=>{d=A(document,"mouseup",x)}),U(()=>{d?.remove()});const F=H(()=>{const{vertical:e,offset:t,reverse:a}=s;return e?{[a?"top":"bottom"]:`${t}%`,[a?"bottom":"top"]:"auto",transform:a?null:"translateY(+50%)"}:{[a?"right":"left"]:`${t}%`,[a?"left":"right"]:"auto",transform:`translateX(${a?"+":"-"}50%)`}});return()=>{const{prefixCls:e,disabled:t,min:a,max:N,value:c,tabindex:f,ariaLabel:L,ariaLabelledBy:T,ariaValueTextFormatter:m,onMouseenter:S,onMouseleave:V}=s,C=O(l.class,{[`${e}-handle-click-focused`]:n.value}),$={"aria-valuemin":a,"aria-valuemax":N,"aria-valuenow":c,"aria-disabled":!!t},k=[l.style,F.value];let p=f||0;(t||f===null)&&(p=null);let v;m&&(v=m(c));const D={...l,role:"slider",tabindex:p,...$,class:C,onBlur:h,onKeydown:M,onMousedown:B,onMouseenter:S,onMouseleave:V,ref:o,style:k};return K("div",{...D,"aria-label":L,"aria-labelledby":T,"aria-valuetext":v},null)}}});export{Y as default};
