import{t,b as e,i as o}from"./index-3194b0ff.js";import{c as s,S as i,Q as n,az as a,o as r,d as f,r as c,a as d}from"./index-fc0cdbb1.js";function l(t){var o;const s=e(t);return null!=(o=null==s?void 0:s.$el)?o:s}const p=o?window:void 0;const u=f({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(e,{slots:o,emit:f}){const u=c({divStyle:{},heightV:0,sectionStyle:{width:"100%",height:"auto",left:"0"}}),m=n(),y=n();return r((()=>{"top"===e.position?u.divStyle.top=e.offsetTop||"0px":u.divStyle.bottom=e.offsetBottom||"0px";try{!function(e,o,f={}){const{window:c=p,...d}=f;let u;const m=function(t){const e=function(){const t=n(!1);return a()&&r((()=>{t.value=!0})),t}();return s((()=>(e.value,Boolean(t()))))}((()=>c&&"ResizeObserver"in c)),y=()=>{u&&(u.disconnect(),u=void 0)},v=s((()=>Array.isArray(e)?e.map((t=>l(t))):[l(e)])),h=i(v,(t=>{if(y(),m.value&&c){u=new ResizeObserver(o);for(const e of t)e&&u.observe(e,d)}}),{immediate:!0,flush:"post",deep:!0});t((()=>{y(),h()}))}(y.value,(t=>{const o=t[0],{height:s}=o.contentRect;Math.abs(s-u.heightV)>1&&setTimeout((()=>{var t;t=s,u.sectionStyle.height="".concat(t,"px"),u.heightV=t,document.documentElement.style.setProperty(e.varName,"".concat(t,"px")),f("barHeight",t)}),10)}))}catch(o){}})),i((()=>e.offsetTop),(()=>{u.divStyle.top=e.offsetTop})),i((()=>e.offsetBottom),(()=>{u.divStyle.bottom=e.offsetBottom})),()=>d("div",{style:[u.sectionStyle],"class":"sticky"===e.mode&&"_sticky_4d2w6_1"},[d("div",{ref:m,"class":["van-sticky","fixed"===e.mode?"van-sticky--fixed":""],style:[u.divStyle,u.sectionStyle]},[d("div",{ref:y},[o["default"]&&o["default"]()])])])}});export{u as O};
