import React, { lazy, Suspense, useEffect, useRef, useState } from 'react' import { createRoot } from 'react-dom/client' import HomepageAnnouncement from '../../components/homepage/HomepageAnnouncement' // Below-fold — lazy-loaded to keep initial bundle small const HomeWelcomeRow = lazy(() => import('./HomeWelcomeRow')) const HomeFromFollowing = lazy(() => import('./HomeFromFollowing')) const HomeTrendingForYou = lazy(() => import('./HomeTrendingForYou')) const HomeBecauseYouLike = lazy(() => import('./HomeBecauseYouLike')) const HomeSuggestedCreators = lazy(() => import('./HomeSuggestedCreators')) const HomeTrending = lazy(() => import('./HomeTrending')) const HomeMedalHighlights = lazy(() => import('./HomeMedalHighlights')) const HomeRising = lazy(() => import('./HomeRising')) const HomeFresh = lazy(() => import('./HomeFresh')) const HomeCollections = lazy(() => import('./HomeCollections')) const HomeWorldSpotlight = lazy(() => import('./HomeWorldSpotlight')) const HomeGroups = lazy(() => import('./HomeGroups')) const HomeCategories = lazy(() => import('./HomeCategories')) const HomeTags = lazy(() => import('./HomeTags')) const HomeCreators = lazy(() => import('./HomeCreators')) const HomeNews = lazy(() => import('./HomeNews')) const HomeCTA = lazy(() => import('./HomeCTA')) function cx(...parts) { return parts.filter(Boolean).join(' ') } function SectionFallback({ variant = 'gallery' }) { if (variant === 'welcome') { return (
) } if (variant === 'tags') { return ( ) } if (variant === 'cta') { return ( ) } const cardClassName = variant === 'categories' ? 'h-28 rounded-2xl' : variant === 'news' ? 'h-24 rounded-2xl' : variant === 'creators' ? 'h-64 rounded-2xl' : variant === 'collections' ? 'h-80 rounded-[28px]' : variant === 'groups' ? 'h-80 rounded-[28px]' : 'aspect-[4/3] rounded-2xl' const gridClassName = variant === 'creators' ? 'grid-cols-2 sm:grid-cols-3 lg:grid-cols-6' : variant === 'news' ? 'grid-cols-1' : variant === 'categories' ? 'grid-cols-2 lg:grid-cols-4' : variant === 'collections' ? 'grid-cols-1 lg:grid-cols-2 xl:grid-cols-3' : variant === 'groups' ? 'grid-cols-1 sm:grid-cols-2 xl:grid-cols-4' : 'grid-cols-2 xl:grid-cols-4' const cardCount = variant === 'creators' ? 6 : variant === 'news' ? 4 : 4 return ( ) } function SectionPlaceholder({ variant = 'gallery' }) { const heightClassName = variant === 'welcome' ? 'h-20' : variant === 'tags' ? 'h-28' : variant === 'cta' ? 'h-40' : variant === 'news' ? 'h-48' : variant === 'categories' ? 'h-44' : variant === 'creators' ? 'h-72' : variant === 'collections' ? 'h-80' : variant === 'groups' ? 'h-80' : 'h-[28rem]' return ( ) } function DeferredSection({ children, fallback, variant = 'gallery', eager = false, rootMargin = '1200px 0px' }) { const anchorRef = useRef(null) const [isVisible, setIsVisible] = useState(eager) useEffect(() => { if (eager || isVisible) { return undefined } const node = anchorRef.current if (!node) { return undefined } if (typeof window === 'undefined' || typeof window.IntersectionObserver !== 'function') { setIsVisible(true) return undefined } const observer = new window.IntersectionObserver((entries) => { entries.forEach((entry) => { if (!entry.isIntersecting) { return } setIsVisible(true) observer.disconnect() }) }, { rootMargin, threshold: 0.01 }) observer.observe(node) return () => observer.disconnect() }, [eager, isVisible, rootMargin]) return (