import{anyType as e,objectType as t}from"../_util/type.mjs";import n from"../_util/classNames.mjs";import r from"../_util/props-util/initDefaultProps.mjs";import i from"../config-provider/hooks/useConfigInject.mjs";import{useInjectAnchor as a}from"./context.mjs";import{createVNode as o,defineComponent as s,nextTick as c,onBeforeUnmount as l,onMounted as u,watch as d}from"vue";var f=()=>({prefixCls:String,href:String,title:e(),target:String,customTitleProps:t()}),p=s({compatConfig:{MODE:3},name:`AAnchorLink`,inheritAttrs:!1,props:r(f(),{href:`#`}),slots:Object,setup(e,{slots:t,attrs:r}){let s=null,{handleClick:f,scrollTo:p,unregisterLink:m,registerLink:h,activeLink:g}=a(),{prefixCls:_}=i(`anchor`,e),v=t=>{let{href:n}=e;f(t,{title:s,href:n}),p(n)};return d(()=>e.href,(e,t)=>{c(()=>{m(t),h(e)})}),u(()=>{h(e.href)}),l(()=>{m(e.href)}),()=>{let{href:i,target:a,title:c=t.title,customTitleProps:l={}}=e,u=_.value;s=typeof c==`function`?c(l):c;let d=g.value===i,f=n(`${u}-link`,{[`${u}-link-active`]:d},r.class),p=n(`${u}-link-title`,{[`${u}-link-title-active`]:d});return o(`div`,{...r,class:f},[o(`a`,{class:p,href:i,title:typeof s==`string`?s:``,target:a,onClick:v},[t.customTitle?t.customTitle(l):s]),t.default?.()])}}});export{f as anchorLinkProps,p as default};