const { useState, useEffect } = React; /* New copy is written in English first and translated later, so a locale falls back to English for any key it doesn't have yet. Objects merge key by key; a translated string or array replaces the English one. */ const isPlainObject = v => v !== null && typeof v === 'object' && !Array.isArray(v); function withEnglishFallback(locale, en) { if (!isPlainObject(locale) || !isPlainObject(en)) return locale ?? en; const merged = { ...en }; for (const [k, v] of Object.entries(locale)) merged[k] = withEnglishFallback(v, en[k]); return merged; } /* Put the real last-hour count (window.LANDING_STATS, null = too small to show) into the hero's pulse line, or drop the line. */ const FIRST_NUMBER = /[0-9]+/; function withLiveStats(base) { const n = (window.LANDING_STATS || {}).hourCompletions; const pulse = n == null ? '' : base.hero.pulse.replace(FIRST_NUMBER, n.toLocaleString(base.loc)); return { ...base, hero: { ...base.hero, pulse } }; } const { Nav, Hero, Together, HappeningNow, DayStory, Buddy, Characters, ForCreators, OurPromise, MissADay, LanguageStrip, Pricing, FAQ, Download, Footer } = window; /* ── THEMES ─────────────────────────────────────────────────── */ const THEMES = { navy: { bg:'linear-gradient(148deg,#1B2D6E 0%,#0d1a42 100%)', text:'#fff', sub:'rgba(255,255,255,0.62)', navBg:'rgba(13,26,66,0.93)', cta:'#F47215', ctaT:'#fff', statsBg:'#1B2D6E', statsSub:'rgba(255,255,255,0.52)', accent:'#F47215', badge:'rgba(255,255,255,0.1)', badgeT:'rgba(255,255,255,0.85)' }, blue: { bg:'linear-gradient(148deg,#2563EB 0%,#1B2D6E 100%)', text:'#fff', sub:'rgba(255,255,255,0.66)', navBg:'rgba(37,99,235,0.93)', cta:'#F47215', ctaT:'#fff', statsBg:'#2563EB', statsSub:'rgba(255,255,255,0.55)', accent:'#F47215', badge:'rgba(255,255,255,0.13)', badgeT:'rgba(255,255,255,0.9)' }, orange: { bg:'linear-gradient(148deg,#F47215 0%,#c45a0a 100%)', text:'#fff', sub:'rgba(255,255,255,0.72)', navBg:'rgba(196,90,10,0.93)', cta:'#fff', ctaT:'#F47215', statsBg:'#F47215', statsSub:'rgba(255,255,255,0.62)', accent:'#2563EB', badge:'rgba(255,255,255,0.16)', badgeT:'rgba(255,255,255,0.92)' }, }; /* ── LANGUAGE ───────────────────────────────────────────────── */ /* The server picks the language from the address (/, /ar, /fr, ...). On the plain `/` a language the visitor chose earlier wins; choosing one moves the address to that language's URL without a reload. */ const LANG_KEY = 'upwedo.lang'; const SITE = window.LANDING_LOCALE || { lang:'en', urls:{ en:'/' } }; function rememberedLang() { try { return localStorage.getItem(LANG_KEY); } catch (e) { return null; } } function initialLang() { const saved = rememberedLang(); const onDefault = SITE.lang === 'en' && new URL(SITE.urls.en, location.href).pathname === location.pathname; return onDefault && saved && window.I18N[saved] && SITE.urls[saved] ? saved : SITE.lang; } function showLangInAddress(lang) { const url = SITE.urls[lang]; if (!url) return; const next = new URL(url, location.href); if (next.pathname !== location.pathname) history.replaceState(null, '', next.pathname + location.search + location.hash); } /* ── APP ────────────────────────────────────────────────────── */ function App() { const [lang, setLangState] = useState(initialLang); const setLang = c => { setLangState(c); try { localStorage.setItem(LANG_KEY, c); } catch (e) { /* private mode: the URL still carries it */ } }; useEffect(() => { showLangInAddress(lang); }, [lang]); const th = THEMES.navy; const pill = false; const L = withLiveStats(withEnglishFallback(window.I18N[lang], window.I18N.en)); useEffect(() => { const root = document.documentElement; root.lang = L.code; root.dir = L.dir; root.setAttribute('data-locale', L.code); document.title = L.title; }, [lang]); return (
); } ReactDOM.createRoot(document.getElementById('root')).render();