/* eslint-disable */
// Lightweight scroll-reveal wrapper using IntersectionObserver.

const Reveal = ({ children, stagger = false, as: As = 'div', style, ...rest }) => {
  const ref = React.useRef(null);
  React.useEffect(() => {
    const el = ref.current;
    if (!el) return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (e.isIntersecting) {
          e.target.classList.add('is-in');
          io.unobserve(e.target);
        }
      });
    }, { threshold: 0.12, rootMargin: '0px 0px -10% 0px' });
    io.observe(el);
    return () => io.disconnect();
  }, []);
  return (
    <As
      ref={ref}
      className={stagger ? 'uc-reveal-stagger' : 'uc-reveal'}
      style={style}
      {...rest}
    >{children}</As>
  );
};

Object.assign(window, { Reveal });
