import e from"../_util/throttleByAnimationFrame.mjs";import t from"../_util/props-util/initDefaultProps.mjs";import n from"../config-provider/hooks/useConfigInject.mjs";import r from"../_util/getScroll.mjs";import i from"../_util/scrollTo.mjs";import{getTransitionProps as a}from"../_util/transition.mjs";import{backTopProps as o}from"./interface.mjs";import{useInjectFloatButtonGroupContext as s}from"./context.mjs";import c from"./style/index.mjs";import l,{floatButtonPrefixCls as u}from"./FloatButton.mjs";import{Transition as d,createVNode as f,defineComponent as p,nextTick as m,onActivated as h,onBeforeUnmount as g,onDeactivated as _,onMounted as v,reactive as y,ref as b,vShow as x,watch as S,withDirectives as C}from"vue";import{VerticalAlignTopOutlined as w}from"@antsoo-lib/icons";var T=p({compatConfig:{MODE:3},name:`ABackTop`,inheritAttrs:!1,props:t(o(),{visibilityHeight:400,target:()=>window,duration:450,type:`default`,shape:`circle`}),setup(t,{slots:o,attrs:p,emit:T}){let{prefixCls:E,direction:D}=n(u,t),[O]=c(E),k=b(),A=y({visible:t.visibilityHeight===0,scrollEvent:null}),j=()=>k.value&&k.value.ownerDocument?k.value.ownerDocument:window,M=e=>{let{target:n=j,duration:r}=t;i(0,{getContainer:n,duration:r}),T(`click`,e)},N=e(e=>{let{visibilityHeight:n}=t,i=r(e.target,!0);A.visible=i>=n}),P=()=>{let{target:e}=t,n=(e||j)();N({target:n}),n?.addEventListener(`scroll`,N)},F=()=>{let{target:e}=t,n=(e||j)();N.cancel(),n?.removeEventListener(`scroll`,N)};S(()=>t.target,()=>{F(),m(()=>{P()})}),v(()=>{m(()=>{P()})}),h(()=>{m(()=>{P()})}),_(()=>{F()}),g(()=>{F()});let I=s();return()=>{let{description:e,type:n,shape:r,tooltip:i,badge:s}=t,c={...p,shape:I?.shape.value||r,onClick:M,class:{[`${E.value}`]:!0,[`${p.class}`]:p.class,[`${E.value}-rtl`]:D.value===`rtl`},description:e,type:n,tooltip:i,badge:s},u=a(`fade`);return O(f(d,u,{default:()=>[C(f(l,{...c,ref:k},{icon:()=>o.icon?.()||f(w,null,null)}),[[x,A.visible]])]}))}}});export{T as default};