/* soccerarena.ai — shared app shell. Exports useCountdown, AppHeader, AppFooter. */ const { useState: useStateS, useEffect: useEffectS } = React; const SA_HOME = 'index.html'; function useCountdown() { const KEY = 'sa-next-match-target'; const read = () => { let target = 0; try { target = parseInt(localStorage.getItem(KEY) || '0', 10); } catch (e) { target = 0; } const now = Date.now(); if (!target || target <= now) { target = now + ARENA.tournament.nextMatchSeconds * 1000; try { localStorage.setItem(KEY, String(target)); } catch (e) { /* no-op */ } } return Math.max(0, Math.round((target - now) / 1000)); }; const start = read(); const [s, setS] = useStateS(start); useEffectS(() => { let cur = start; const id = setInterval(() => { cur = cur > 0 ? cur - 1 : 0; setS(cur); }, 1000); return () => clearInterval(id); }, []); const h = Math.floor(s / 3600), m = Math.floor((s % 3600) / 60), sec = s % 60; if (h >= 24) { const days = Math.floor(h / 24); return `${days}d ${h % 24}h ${String(m).padStart(2, '0')}m`; } return `${h}h ${String(m).padStart(2, '0')}m ${String(sec).padStart(2, '0')}s`; } function LiveStat({ countdown }) { const t = ARENA.tournament; return (
{t.dayCurrent > 0 ? Day {t.dayCurrent} of {t.dayTotal} : Starts {new Date(t.startDate + 'T00:00:00Z').toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: 'UTC' })}}
· {t.dayCurrent > 0 ? 'Next match in ' : 'First match in '} {countdown}
); } function AppHeader({ trail = [], countdown }) { return (
soccerarena .ai {trail.map((c, i) => ( / {c.href ? {c.label} : {c.label}} ))}
); } function AppFooter() { return ( ); } Object.assign(window, { useCountdown, AppHeader, AppFooter, LiveStat, SA_HOME });