import{a4 as S,a9 as P,a5 as k,aa as I,E as $,G as O,a0 as R,ab as x,d as T,U as B,ac as E,S as N,W as u,ad as j,J as z,ae as C,a3 as H,af as U,j as p,ag as V,Y as h,ah as _,O as A}from"./ResizeObserver.es.45df6c0f.js";function D(o,l){if(!S||!window.IntersectionObserver)return;const r=new IntersectionObserver(e=>{l(e[0].intersectionRatio>0)},{root:document.body}),n=()=>{o.value&&r.observe(o.value)},f=()=>{o.value&&r.unobserve(o.value)};P(f),k(f),I(n)}const[F,G]=$("sticky"),J={zIndex:O,position:R("top"),container:Object,offsetTop:x(0),offsetBottom:x(0)};var L=T({name:F,props:J,emits:["scroll","change"],setup(o,{emit:l,slots:r}){const n=B(),f=E(n),e=N({fixed:!1,width:0,height:0,transform:0}),a=u(()=>j(o.position==="top"?o.offsetTop:o.offsetBottom)),b=u(()=>{const{fixed:t,height:d,width:s}=e;if(t)return{width:`${s}px`,height:`${d}px`}}),g=u(()=>{if(!e.fixed)return;const t=z(C(o.zIndex),{width:`${e.width}px`,height:`${e.height}px`,[o.position]:`${a.value}px`});return e.transform&&(t.transform=`translate3d(0, ${e.transform}px, 0)`),t}),w=t=>l("scroll",{scrollTop:t,isFixed:e.fixed}),v=()=>{if(!n.value||V(n))return;const{container:t,position:d}=o,s=h(n),y=_(window);if(e.width=s.width,e.height=s.height,d==="top")if(t){const i=h(t),c=i.bottom-a.value-e.height;e.fixed=a.value>s.top&&i.bottom>0,e.transform=c<0?c:0}else e.fixed=a.value>s.top;else{const{clientHeight:i}=document.documentElement;if(t){const c=h(t),m=i-c.top-a.value-e.height;e.fixed=i-a.value<s.bottom&&i>c.top,e.transform=m<0?-m:0}else e.fixed=i-a.value<s.bottom}w(y)};return H(()=>e.fixed,t=>l("change",t)),U("scroll",v,{target:f}),D(n,v),()=>{var t;return p("div",{ref:n,style:b.value},[p("div",{class:G({fixed:e.fixed}),style:g.value},[(t=r.default)==null?void 0:t.call(r)])])}}});const W=A(L);export{W as S};
