(() => {
const { Toast } = window.AscendFaithDesignSystem_9749b4;
const { initSmoothScroll, scrollToY, ScrollProgress } = window.AF_MOTION;
const KEY = 'af-web-page-v2';
const store = { get: () => { try { return localStorage.getItem(KEY); } catch (e) { return null; } }, set: v => { try { localStorage.setItem(KEY, v); } catch (e) {} } };
function Site() {
  const [page, setPage] = React.useState(store.get() || 'home');
  const [product, setProduct] = React.useState(window.AF_DATA.products[1]);
  const [lines, setLines] = React.useState([]);
  const [bagOpen, setBagOpen] = React.useState(false);
  const [t, setT] = React.useState(null);
  const toast = (msg, variant = 'neutral') => { setT({ msg, variant, k: Date.now() }); clearTimeout(window._afWT); window._afWT = setTimeout(() => setT(null), 2600); };
  const nav = (pg, anchor) => { setPage(pg); store.set(pg); setTimeout(() => { const el = anchor && document.getElementById(anchor); scrollToY(el ? el.getBoundingClientRect().top + window.scrollY - 72 : 0, !anchor); }, 30); };
  const openProduct = p => { setProduct(p); nav('product'); };
  const addToBag = (p, s, q = 1) => { setLines(ls => [...ls, { p, s, q }]); setBagOpen(true); };
  const count = lines.reduce((s, l) => s + l.q, 0);
  React.useEffect(() => { initSmoothScroll(); }, []);
  React.useEffect(() => { const l = window.__afLenis; if (!l) return; bagOpen ? l.stop() : l.start(); }, [bagOpen]);
  React.useEffect(() => {
    const els = document.querySelectorAll('main section > .wrap > *, main > .wrap > *, main section > div:not(.wrap) > *, .af-product, .web-footer .wrap > *');
    els.forEach(el => { if (el.closest('.hero-words') || el.closest('[data-no-rv]') || el.classList.contains('rv')) return; el.classList.add('rv'); const i = Array.prototype.indexOf.call(el.parentNode.children, el); el.style.setProperty('--d', Math.min(i, 6) * 90 + 'ms'); });
    const io = new IntersectionObserver(es => es.forEach(e => { if (e.isIntersecting) { e.target.classList.add('in'); io.unobserve(e.target); } }), { threshold: 0.12, rootMargin: '0px 0px -40px 0px' });
    document.querySelectorAll('.rv:not(.in)').forEach(el => io.observe(el));
    const refresh = setTimeout(() => window.ScrollTrigger && window.ScrollTrigger.refresh(), 120);
    return () => { io.disconnect(); clearTimeout(refresh); };
  }, [page, product]);
  const [pop, setPop] = React.useState(0);
  React.useEffect(() => { if (count) { setPop(p => p + 1); } }, [count]);
  return (
    <>
      <ScrollProgress />
      <WebHeader key={'h' + pop} page={page} nav={nav} bagCount={count} openBag={() => setBagOpen(true)} />
      {page === 'home' && <HomePage nav={nav} openProduct={openProduct} />}
      {page === 'shop' && <ShopPage openProduct={openProduct} />}
      {page === 'product' && <ProductPage p={product} nav={nav} addToBag={addToBag} openProduct={openProduct} />}
      {page === 'about' && <AboutPage nav={nav} />}
      <WebFooter nav={nav} toast={toast} />
      <BagDrawer open={bagOpen} lines={lines} setLines={setLines} close={() => setBagOpen(false)} toast={toast} />
      {t && <div style={{ position: 'fixed', right: 24, bottom: 24, zIndex: 700 }}><Toast key={t.k} variant={t.variant}>{t.msg}</Toast></div>}
      <a className="v2-switch afm-glass" href="../website/index.html"><b>V2</b> · View original</a>
    </>
  );
}
window.Site = Site;
})();
