// @bun
var{defineProperty:U,getOwnPropertyNames:_,getOwnPropertyDescriptor:$}=Object,S=Object.prototype.hasOwnProperty;function E(j){return this[j]}var L=(j)=>{var q=(X??=new WeakMap).get(j),w;if(q)return q;if(q=U({},"__esModule",{value:!0}),j&&typeof j==="object"||typeof j==="function"){for(var z of _(j))if(!S.call(q,z))U(q,z,{get:E.bind(j,z),enumerable:!(w=$(j,z))||w.enumerable})}return X.set(j,q),q},X;var A=(j)=>j;function I(j,q){this[j]=A.bind(null,q)}var M=(j,q)=>{for(var w in q)U(j,w,{get:q[w],enumerable:!0,configurable:!0,set:I.bind(q,w)})};var O=(j,q)=>()=>(j&&(q=j(j=0)),q);var V=import.meta.require;function W(j,q,w={}){let{root:z=null,rootMargin:F="0px",threshold:B=0,once:x=!1,immediate:C=!0}=w,G={isIntersecting:!1,intersectionRatio:0,boundingClientRect:null,intersectionRect:null,isVisible:!1,entry:null},K=[],J=null,P=!1,N=()=>{if(typeof j==="function")return j();return j},Y=()=>{K.forEach((H)=>H(G))},Z=(H)=>{let D=H[0];if(!D)return;if(G={isIntersecting:D.isIntersecting,intersectionRatio:D.intersectionRatio,boundingClientRect:D.boundingClientRect,intersectionRect:D.intersectionRect,isVisible:D.isIntersecting,entry:D},Y(),q)q(D,J);if(x&&D.isIntersecting)R()},Q=()=>{if(typeof IntersectionObserver>"u")return;if(J)return;let H=N();if(!H)return;J=new IntersectionObserver(Z,{root:z,rootMargin:F,threshold:B}),J.observe(H),P=!0},R=()=>{if(J)J.disconnect(),J=null;P=!1};if(C)Q();return{get:()=>G,subscribe:(H)=>{if(K.push(H),H(G),K.length===1&&!C&&!P)Q();return()=>{if(K=K.filter((D)=>D!==H),K.length===0&&!q)R()}},isVisible:()=>G.isVisible,stop:R,start:Q}}function T(j,q){let w=W(j,void 0,q),z=[],F=!1;return{get:()=>w.isVisible(),subscribe:(B)=>{let x=w.subscribe((C)=>{if(C.isVisible!==F)F=C.isVisible,B(C.isVisible)});return z.push(B),B(w.isVisible()),()=>{if(z=z.filter((C)=>C!==B),z.length===0)x()}}}}function k(j,q,w){return{stop:W(j,(F)=>{if(F.isIntersecting)q()},{...w,once:!0}).stop}}function p(j,q,w={}){let{debounce:z=100,...F}=w,B=!1,x=null,C=W(j,async(G)=>{if(!G.isIntersecting||B)return;if(x)clearTimeout(x);x=setTimeout(async()=>{B=!0;try{await q()}finally{B=!1}},z)},{rootMargin:"100px",...F});return{stop:()=>{if(x)clearTimeout(x);C.stop()},start:C.start,isLoading:()=>B}}function y(j,q,w={}){let{root:z=null,rootMargin:F="0px",threshold:B=0}=w,x=null,C=()=>{if(typeof j==="function")return j();return j},G=()=>{if(typeof IntersectionObserver>"u")return;if(x)return;x=new IntersectionObserver(q,{root:z,rootMargin:F,threshold:B});for(let N of C())x.observe(N)},K=()=>{if(x)x.disconnect(),x=null},J=(N)=>{x?.observe(N)},P=(N)=>{x?.unobserve(N)};return G(),{stop:K,start:G,observe:J,unobserve:P}}export{k as useLazyLoad,y as useIntersectionObserverMultiple,W as useIntersectionObserver,p as useInfiniteScroll,T as useElementVisibility};
