"use client" import { useEffect, useLayoutEffect, useState } from "react" import { usePathname } from "next/navigation" import { UltiMailLogo } from "@/components/ultimail-logo" import { markSuiteSplashSeen, shouldShowSuiteSplash, suiteSplashAppFromPath, SUITE_SPLASH_CONFIG, type SuiteSplashApp, } from "@/lib/suite/suite-app-splash" import { suitePublicAsset } from "@/lib/suite/suite-public-asset" import { cn } from "@/lib/utils" const SPLASH_VISIBLE_MS = 1750 const SPLASH_EXIT_MS = 500 export function FirstLaunchSplash({ children, }: { children: React.ReactNode }) { const pathname = usePathname() const [activeApp, setActiveApp] = useState(() => typeof window === "undefined" ? null : shouldShowSuiteSplash(window.location.pathname) ) const [isHiding, setIsHiding] = useState(false) const [isComplete, setIsComplete] = useState(() => activeApp === null) useLayoutEffect(() => { const nextApp = shouldShowSuiteSplash(pathname) const root = document.documentElement root.dataset.splashApp = suiteSplashAppFromPath(pathname) ?? "" root.dataset.splashSeen = nextApp ? "0" : "1" setActiveApp(nextApp) setIsComplete(nextApp === null) setIsHiding(false) }, [pathname]) useEffect(() => { if (!activeApp) return const hideTimer = window.setTimeout(() => { setIsHiding(true) }, SPLASH_VISIBLE_MS) const completeTimer = window.setTimeout(() => { markSuiteSplashSeen(activeApp) document.documentElement.dataset.splashSeen = "1" setActiveApp(null) setIsComplete(true) }, SPLASH_VISIBLE_MS + SPLASH_EXIT_MS) return () => { window.clearTimeout(hideTimer) window.clearTimeout(completeTimer) } }, [activeApp]) const config = activeApp ? SUITE_SPLASH_CONFIG[activeApp] : null return ( <> {children} {!isComplete && config ? (
{config.pill}
{activeApp === "mail" ? ( ) : config.markDark ? ( <> ) : ( )}

{config.subtitle}

) : null} ) }