import{a6 as S,az as k,a7 as P,ap as I,m as R,w as $,n as T,q as p,d as B,S as N,ak as O,R as z,v as u,al as E,N as q,aA as A,E as C,Y as H,k as x,aq as V,at as v,af as _,y as j}from"./index.879f7421.js";function D(o,l){if(!S||!window.IntersectionObserver)return;const r=new IntersectionObserver(e=>{l(e[0].intersectionRatio>0)},{root:document.body}),s=()=>{o.value&&r.observe(o.value)},f=()=>{o.value&&r.unobserve(o.value)};k(f),P(f),I(s)}const[F,L]=R("sticky"),M={zIndex:$,position:T("top"),container:Object,offsetTop:p(0),offsetBottom:p(0)};var U=B({name:F,props:M,emits:["scroll","change"],setup(o,{emit:l,slots:r}){const s=N(),f=O(s),e=z({fixed:!1,width:0,height:0,transform:0}),i=u(()=>E(o.position==="top"?o.offsetTop:o.offsetBottom)),w=u(()=>{const{fixed:t,height:d,width:n}=e;if(t)return{width:`${n}px`,height:`${d}px`}}),b=u(()=>{if(!e.fixed)return;const t=q(A(o.zIndex),{width:`${e.width}px`,height:`${e.height}px`,[o.position]:`${i.value}px`});return e.transform&&(t.transform=`translate3d(0, ${e.transform}px, 0)`),t}),g=t=>l("scroll",{scrollTop:t,isFixed:e.fixed}),h=()=>{if(!s.value||V(s))return;const{container:t,position:d}=o,n=v(s),y=_(window);if(e.width=n.width,e.height=n.height,d==="top")if(t){const a=v(t),c=a.bottom-i.value-e.height;e.fixed=i.value>n.top&&a.bottom>0,e.transform=c<0?c:0}else e.fixed=i.value>n.top;else{const{clientHeight:a}=document.documentElement;if(t){const c=v(t),m=a-c.top-i.value-e.height;e.fixed=a-i.value<n.bottom&&a>c.top,e.transform=m<0?-m:0}else e.fixed=a-i.value<n.bottom}g(y)};return C(()=>e.fixed,t=>l("change",t)),H("scroll",h,{target:f,passive:!0}),D(s,h),()=>{var t;return x("div",{ref:s,style:w.value},[x("div",{class:L({fixed:e.fixed}),style:b.value},[(t=r.default)==null?void 0:t.call(r)])])}}});const Z=j(U);export{Z as S};
