import{aa as S,a_ as P,ab as k,aG as I,t as R,z as $,u as N,w as p,d as T,R as z,ao as B,r as O,y as u,aN as _,N as C,aw as D,Z as E,a0 as H,c as x,az as V,am as h,aq as Z,D as j}from"./index.b4473196.js";function q(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)};P(f),k(f),I(s)}const[A,F]=R("sticky"),G={zIndex:$,position:N("top"),container:Object,offsetTop:p(0),offsetBottom:p(0)};var L=T({name:A,props:G,emits:["scroll","change"],setup(o,{emit:l,slots:r}){const s=z(),f=B(s),e=O({fixed:!1,width:0,height:0,transform:0}),i=u(()=>_(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=C(D(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}),v=()=>{if(!s.value||V(s))return;const{container:t,position:d}=o,n=h(s),y=Z(window);if(e.width=n.width,e.height=n.height,d==="top")if(t){const a=h(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=h(t),m=a-c.top-i.value-e.height;e.fixed=a-i.valuec.top,e.transform=m<0?-m:0}else e.fixed=a-i.valuee.fixed,t=>l("change",t)),H("scroll",v,{target:f,passive:!0}),q(s,v),()=>{var t;return x("div",{ref:s,style:w.value},[x("div",{class:F({fixed:e.fixed}),style:b.value},[(t=r.default)==null?void 0:t.call(r)])])}}});const U=j(L);export{U as S};