import{d as r,x as h,r as n,y as v,w as c,a as o}from"./index-f1aa8576.js";import{c as u}from"./index-b94ac003.js";const S="_sticky_4d2w6_1",g="_white_4d2w6_6",x={sticky:S,white:g},w=r({name:"m-sticky",props:{position:{type:String,default:"top"},mode:{type:String,default:"fixed"},offsetTop:{type:String,default:"0px"},offsetBottom:{default:"0px"},varName:{type:String,default:"--header-height"}},emits:["barHeight"],setup(t,{slots:s,emit:d}){const e=h({divStyle:{},heightV:0,sectionStyle:{width:"100%",height:"auto",left:"0"}}),y=i=>{e.sectionStyle.height=`${i}px`,e.heightV=i,document.documentElement.style.setProperty(t.varName,`${i}px`),d("barHeight",i)},f=n(),l=n();return v(()=>{t.position==="top"?e.divStyle.top=t.offsetTop||"0px":e.divStyle.bottom=t.offsetBottom||"0px";try{u(f.value,i=>{const m=i[0],{height:a}=m.contentRect;Math.abs(a-e.heightV)>1&&setTimeout(()=>{y(a)},10)})}catch(i){}}),c(()=>t.offsetTop,()=>{e.divStyle.top=t.offsetTop}),c(()=>t.offsetBottom,()=>{e.divStyle.bottom=t.offsetBottom}),()=>o("div",{style:[e.sectionStyle],class:t.mode==="sticky"&&x.sticky},[o("div",{ref:f,class:["van-sticky",t.mode==="fixed"?"van-sticky--fixed":""],style:[e.divStyle,e.sectionStyle]},[o("div",{ref:l},[s.default&&s.default()])])])}});export{w as M};
