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