'use client';
"use strict";var e=require("react");exports.useInView=function({triggerOnce:r,skip:n,addRootMargin:t=0,initialInView:i,onChange:o}={}){let c=e.useRef(),[u,s]=e.useState({inView:!!i}),w=e.useRef(),d=e.useCallback(e=>{if(void 0!==c.current&&(c.current(),c.current=void 0,w.current=void 0),n||!e)return;let i=()=>{w.current||(w.current=requestAnimationFrame(()=>{let n=e.getBoundingClientRect(),d=-t,v=(window.innerHeight||document.documentElement.clientHeight)+t,l=n.top<=d&&n.bottom>=d||n.top>=d&&n.bottom<=v||n.top<=v&&n.bottom>=v;l!==u.inView&&(s({inView:l}),o&&o(l,e),l&&r&&c.current&&(window.removeEventListener("scroll",i),window.removeEventListener("resize",i),w.current&&cancelAnimationFrame(w.current),c.current=void 0,w.current=void 0)),w.current=void 0}))};window.addEventListener("scroll",i),window.addEventListener("resize",i),i(),c.current=()=>{window.removeEventListener("scroll",i),window.removeEventListener("resize",i),w.current&&cancelAnimationFrame(w.current),w.current=void 0}},[n,t,u.inView,o,r]);e.useEffect(()=>{c.current||!u.entry||r||n||s({inView:!!i})},[u.entry,r,n,i]);let v=[d,u.inView,u.entry];return v.ref=v[0],v.inView=v[1],v.entry=v[2],v};
