/* UpWeDo landing page sections — all copy comes from `L` (I18N[lang]) */ const { useState, useEffect, useRef } = React; /* ── VIEWPORT ───────────────────────────────────────────────── */ const MOBILE_MAX = 720; function useViewportWidth() { const [w,setW] = useState(window.innerWidth); useEffect(()=>{ const fn=()=>setW(window.innerWidth); window.addEventListener('resize',fn); return ()=>window.removeEventListener('resize',fn); },[]); return w; } const useIsMobile = () => useViewportWidth() <= MOBILE_MAX; const sectionPad = m => m ? '72px 20px' : '128px 7vw'; const h2Size = (m, desktop) => m ? 'clamp(28px,8.2vw,38px)' : desktop; /* "{n} members" + { n:12 } → "12 members" */ const fill = (text, vars) => Object.entries(vars).reduce((t,[k,v])=>t.split(`{${k}}`).join(v), text); /* ── AUTO-CYCLE (switchers that advance on their own) ───────── */ /* Steps through `count` items every `ms` while the section is on screen. Picking an item stops it for good; reduced motion never starts it. */ function useAutoCycle(count, ms) { const ref = useRef(null); const [index,setIndex] = useState(0); const [auto,setAuto] = useState(()=>!window.matchMedia('(prefers-reduced-motion: reduce)').matches); const [visible,setVisible] = useState(false); useEffect(()=>{ const obs = new IntersectionObserver(([e])=>setVisible(e.isIntersecting), { threshold:.35 }); if (ref.current) obs.observe(ref.current); return ()=>obs.disconnect(); },[]); useEffect(()=>{ if (!auto || !visible) return; const id = setTimeout(()=>setIndex(i=>(i+1)%count), ms); return ()=>clearTimeout(id); },[index, auto, visible, count, ms]); const select = i => { setAuto(false); setIndex(i); }; return { ref, index, select, cycling: auto && visible }; } /* ── SECTION HEADING (kicker · h2 · optional lead) ──────────── */ function SectionHead({ kicker, h2, p, accent, dark=false, m, mb, align='center' }) { const lines = Array.isArray(h2) ? h2 : [h2]; const centered = align==='center'; return (
{kicker}

{lines.map((l,i)=>{i>0&&
}{l}
)}

{p &&

{p}

}
); } /* ── ANIMATED COUNTER (locale-aware) ────────────────────────── */ function Counter({ to, sfx='', loc='en-US' }) { const [n, setN] = useState(0); const ref = useRef(null); const done = useRef(false); useEffect(()=>{ const obs = new IntersectionObserver(([e])=>{ if(e.isIntersecting && !done.current){ done.current = true; const t0 = performance.now(), dur = 1900; const tick = now => { const p = Math.min((now-t0)/dur,1); const e2 = p<.5?2*p*p:-1+(4-2*p)*p; setN(Math.floor(e2*to)); if(p<1) requestAnimationFrame(tick); }; requestAnimationFrame(tick); } },{threshold:.4}); if(ref.current) obs.observe(ref.current); return ()=>obs.disconnect(); },[to]); // 12,400 reads fine in full; from 100k up, "123K" is easier to take in at 72px. const shown = to >= 100000 ? n.toLocaleString(loc, { notation:'compact', maximumFractionDigits:1 }) : n.toLocaleString(loc); return {shown}{sfx}; } /* ── LOGO ───────────────────────────────────────────────────── */ /* The compact lockup (mark + wordmark); both uses sit on dark backgrounds, so it is the reversed one. */ function Logo({ sz=30 }) { const src = (window.BRAND||{}).logoReversed || 'assets/brand/upwedo-logo-compact-reversed.svg'; return UpWeDo; } /* ── STORE BADGE ────────────────────────────────────────────── */ function StoreBadge({ store, L }) { const [h, setH] = useState(false); const txt = store==='apple' ? L.badge.apple : L.badge.google; return (
setH(true)} onMouseLeave={()=>setH(false)} style={{ display:'inline-flex', alignItems:'center', gap:10, background:'rgba(0,0,0,0.55)', borderRadius:10, padding:'8px 18px', cursor:'pointer', border:'1.5px solid rgba(255,255,255,0.12)', userSelect:'none', transition:'transform .15s, box-shadow .15s', transform:h?'translateY(-2px)':'none', boxShadow:h?'0 8px 24px rgba(0,0,0,0.25)':'none' }}> {store==='apple' ? : }
{txt[0]}
{txt[1]}
); } /* ── CTA BUTTON ─────────────────────────────────────────────── */ function Btn({ label, bg, col, pill, outline }) { const [h,setH]=useState(false); return ( ); } /* ── LANGUAGE SWITCHER ──────────────────────────────────────── */ const LANG_OPTIONS = [ ['en','English'], ['ar','العربية'], ['fr','Français'], ['es','Español'], ['pt','Português'], ['de','Deutsch'], ['tr','Türkçe'] ]; function LangSwitcher({ th, lang, setLang }) { const [open,setOpen]=useState(false); const ref=useRef(null); useEffect(()=>{ const fn=e=>{ if(ref.current && !ref.current.contains(e.target)) setOpen(false); }; document.addEventListener('click',fn); return ()=>document.removeEventListener('click',fn); },[]); const current = LANG_OPTIONS.find(o=>o[0]===lang) || LANG_OPTIONS[0]; return (
{open && (
{LANG_OPTIONS.map(([c,name])=>( ))}
)}
); } /* ── NAV ────────────────────────────────────────────────────── */ /* The inline links need ~1000px (more in some languages); below that the menu button takes over, while spacing stays desktop above MOBILE_MAX. */ const NAV_LINKS_MIN = 1000; function Nav({ th, pill, L, lang, setLang }) { const phone = useIsMobile(); const m = useViewportWidth() < NAV_LINKS_MIN; const [sc,setSc]=useState(false); const [menu,setMenu]=useState(false); useEffect(()=>{ const fn=()=>setSc(window.scrollY>50); window.addEventListener('scroll',fn,{passive:true}); return ()=>window.removeEventListener('scroll',fn); },[]); useEffect(()=>{ if(!m) setMenu(false); },[m]); const solid = sc || menu; return ( ); } /* ── HERO ───────────────────────────────────────────────────── */ /* The app's Home and a habit's community count, with a challenge and the buddy floating around them. */ const HERO_CHIPS = [ { key:'challenge', icon:'⏳', color:'#F47215', pos:{ top:400, insetInlineStart:0 } }, { key:'buddy', img:'boy', color:'#2563EB', pos:{ bottom:20, insetInlineEnd:0 } }, ]; /* Two phones: today's Home in front (Done or Not today), the crowd behind it. */ const HERO_BACK_SCALE = 0.86; /* Floats beside the phone on wide screens; on a phone the chips sit in a row under it. */ function FloatChip({ icon, img, color, title, sub, style }) { return (
{img ? : icon}
{title}
{sub}
); } /* Live numbers under the store badges: today, this week and the people active, with the last 14 days as a small column trend (today in the accent). Anything the server held back as too small is left out. */ const HERO_LIVE_KEYS = [['todayCompletions','today'], ['weekCompletions','week'], ['activeMembers','people']]; function HeroLive({ th, L, m, centered }) { const S = window.LANDING_STATS || {}; const daily = (window.LANDING_TRENDS || {}).daily || []; const figures = HERO_LIVE_KEYS.filter(([k]) => S[k] != null); if (!figures.length) return null; const max = Math.max(1, ...daily.map(d=>d.completions)); return (
{figures.map(([k,label],i)=>(
{i===0 && }
{L.hero.live[label]}
))} {daily.length > 0 && ( ); } function Hero({ th, layout, L, dir }) { const m = useIsMobile(); const vw = useViewportWidth(); const split = layout==='split' && vw >= 1000; const textBlock = (
{L.hero.pulse &&
{L.hero.pulse}
}

{L.hero.h1[0]}
{L.hero.h1[1]}

{L.hero.p}

{L.hero.foot}

{L.hero.creators}
); const chips = HERO_CHIPS.map(c=>( )); const stageW = m ? Math.min(vw-40, 340) : 580, stageH = m ? 520 : 560; const backScale = m ? 0.8 : HERO_BACK_SCALE; const phoneBlock = (
{!m && chips}
{m &&
{chips}
}
); return (
{textBlock}{phoneBlock}
); } /* ── CHARACTERS (Sound familiar?) ───────────────────────────── */ /* Six people who tried and stopped. A card flips to what they need and how UpWeDo helps; both faces share one grid cell, so flipping never changes the card's height. Nothing flips on its own: the visitor picks. */ const CHARACTER_META = [ { e:'🔁', color:'#F47215' }, { e:'🤫', color:'#8B5CF6' }, { e:'🧠', color:'#2563EB' }, { e:'👻', color:'#0891B2' }, { e:'🌱', color:'#16A34A' }, { e:'🧍', color:'#DB2777' }, ]; function CharacterCard({ c, meta, open, onToggle, hint, t, rtl, m }) { const face = visible => ({ gridArea:'1 / 1', display:'flex', flexDirection:'column', gap:14, visibility:visible?'visible':'hidden', opacity:visible?1:0, transition:'opacity .25s' }); const pill = (label, solid) => ( {label} {solid && } ); return ( ); } function Characters({ accent, L, dir }) { const m = useIsMobile(); const vw = useViewportWidth(); const t = L.characters; const [open,setOpen] = useState(null); const [touched,setTouched] = useState(false); const toggle = i => { setTouched(true); setOpen(o=>o===i?null:i); }; const cols = vw < 1000 ? 2 : 3; return (
👆 {t.hint}
{/* On a phone the cards are a swipe row, the next one peeking in. */}
{t.items.map((c,i)=>( toggle(i)} hint={!touched && open===null && i===0} t={t} rtl={dir==='rtl'} m={m} /> ))}
); } /* ── PROMISE (no streaks, anonymous, consent, every language) ─── */ /* Lucide flame-off (no streaks), eye-off (anonymous), shield-check (analytics only with consent), languages. */ const PROMISE_ICONS = [ 'M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 3zM2 2l20 20', 'M9.88 9.88a3 3 0 1 0 4.24 4.24M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61M2 2l20 20', 'M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10zM9 12l2 2 4-4', 'M5 8l6 6M4 14l6-6 2-3M2 5h12M7 2h1M22 22l-5-10-5 10M14 18h6', ]; function OurPromise({ accent, L }) { const m = useIsMobile(); return (
{L.pulse.values.map((v,i)=>(
{v.label}

{v.body}

))}
); } /* ── MISS A DAY (streak apps vs. UpWeDo) ───────────────────── */ /* A two-way switch flips between a normal day and a missed one: the streak app falls to zero; UpWeDo has no streak, so the week's active days just count one fewer and nothing resets. The result panels flip it too. */ function MissADay({ L }) { const m = useIsMobile(); const c = L.missDay; const [missed,setMissed] = useState(false); const [tried,setTried] = useState(false); const choose = v => { setTried(true); setMissed(v); }; const option = (value, label, emoji) => { const on = missed===value; return ( ); }; const panel = (side, good) => { const d = c[side]; const tone = !missed ? '#111827' : good ? '#16A34A' : '#DC2626'; return ( ); }; return (
{option(false, c.normal, '😌')}{option(true, c.missed, '😬')}
👆 {c.hint}
{panel('streak', false)}{panel('upwedo', true)}
); } /* ── LANGUAGE STRIP ─────────────────────────────────────────── */ function LanguageStrip({ L }) { const m = useIsMobile(); return (
🌍 {L.local.h2[1]} {L.local.langs.map(l=>( {l.flag}{l.name} ))}
); } /* ── PLAN LIMITS (live from window.PLAN_LIMITS; null = unlimited) ── */ /* Groups are hidden in the app for now, so their limits are not shown. */ const HIDDEN_LIMITS = new Set(['groups','groupMembers','orgGroups']); function PlanLimitRows({ limits, t, loc, featured }) { return (
{t.title}
{limits.filter(l=>t[l.key] && !HIDDEN_LIMITS.has(l.key)).map(l=>(
{t[l.key]} {l.n==null ? t.unlimited : l.n.toLocaleString(loc)}
))}
); } /* ── PRICING ────────────────────────────────────────────────── */ function Pricing({ accent, L }) { const m = useIsMobile(); /* Three plans side by side need ~1000px; narrower, one centred column (no 2 + 1 split). */ const single = useViewportWidth() < 1000; return (
{L.pricing.kicker}

{L.pricing.h2}

{L.pricing.plans.map((p,i)=>{ const featured = i===1; const live = (window.PLAN_PRICES||{})[p.key]; const price = live ? live.monthly : p.price; const sub = live ? `${p.sub} · ${L.pricing.annual.replace('{price}', live.annual)}` : p.sub; /* Paid plans can't be bought yet: their button says so instead of starting a trial. */ const paid = p.key!=='free'; const limits = (window.PLAN_LIMITS||{})[p.key] || []; return (
{featured&&
{L.pricing.popular}
} {/* Paid plans show no price until they can be bought: the plan name takes the price's place. */} {paid ?
{p.name}
: <>
{p.name}
{price} {sub}
}

{p.desc}

{paid ?
{L.pricing.soon}
: e.currentTarget.style.opacity='.82'} onMouseLeave={e=>e.currentTarget.style.opacity='1'}>{p.cta}}
{p.perks.map((pk,j)=>(
{pk}
))}
{limits.length > 0 && }
); })}
); } /* ── FAQ ────────────────────────────────────────────────────── */ function FAQ({ accent, L }) { const m = useIsMobile(); const [open,setOpen]=useState(null); return (
{L.faq.kicker}

{L.faq.h2}

{L.faq.items.map((f,i)=>(
{open===i&&

{f.a}

}
))}
); } /* ── DOWNLOAD CTA ───────────────────────────────────────────── */ function Download({ th, L }) { const m = useIsMobile(); return (

{L.download.h2[0]}
{L.download.h2[1]}

{L.download.p}

); } /* ── FOOTER ─────────────────────────────────────────────────── */ const FOOTER_LINKS = (u) => [ ['#features', u.pricing || '#pricing', '#download', '#'], ['#together', '#creators', u.pricing || '#pricing', '#'], ['#', u.privacy || '#', u.terms || '#', u.contact || '#'], ]; function Footer({ th, L }) { const m = useIsMobile(); const links = FOOTER_LINKS(window.PLAN_URLS || {}); return ( ); } Object.assign(window, { useViewportWidth, useIsMobile, sectionPad, fill, useAutoCycle, SectionHead, Counter, Logo, StoreBadge, Btn, LangSwitcher, Nav, Hero, Characters, OurPromise, MissADay, LanguageStrip, Pricing, FAQ, Download, Footer });