import { a6 as escape_html, a8 as ensure_array_like, a9 as attr, ab as stringify, aa as attr_class, a1 as derived } from './index3-C4geC3K_.js'; import './root-D12ma0No.js'; import './utils-D_bK1W85.js'; import './exports-B5ORJhfK.js'; import './state.svelte-DvHRBIfo.js'; function _page($$renderer, $$props) { $$renderer.component(($$renderer2) => { let { data } = $$props; const stateConfig = { CREATED: { label: "Created", color: "text-text-secondary border-border" }, LOBBY: { label: "In Lobby", color: "text-yellow-400 border-yellow-500/30" }, ROLLING: { label: "Rolling", color: "text-yellow-400 border-yellow-500/30", dot: "bg-yellow-400" }, PICKING: { label: "Picking", color: "text-blue-400 border-blue-500/30", dot: "bg-blue-400" }, PLAYING: { label: "Live", color: "text-green-400 border-green-500/30", dot: "bg-green-400" }, FINISHED: { label: "Finished", color: "text-text-secondary border-border" }, CANCELLED: { label: "Cancelled", color: "text-red-400 border-red-500/30" } }; const liveStates = ["LOBBY", "ROLLING", "PICKING", "PLAYING"]; const liveMatches = derived(() => data.matches.filter((m) => liveStates.includes(m.state))); const recentMatches = derived(() => data.matches.filter((m) => !liveStates.includes(m.state))); function teamDisplay(m) { const p1 = m.participants[0]; const p2 = m.participants[1]; return { p1, p2 }; } function timeAgo(date) { const d = new Date(date); const diff = Date.now() - d.getTime(); const mins = Math.floor(diff / 6e4); if (mins < 1) return "just now"; if (mins < 60) return `${mins}m ago`; const hours = Math.floor(mins / 60); if (hours < 24) return `${hours}h ago`; const days = Math.floor(hours / 24); return `${days}d ago`; } $$renderer2.push(`

Matches

${escape_html(data.matches.length)} match${escape_html(data.matches.length !== 1 ? "es" : "")} `); if (liveMatches().length > 0) { $$renderer2.push(""); $$renderer2.push(`· ${escape_html(liveMatches().length)} live`); } else { $$renderer2.push(""); } $$renderer2.push(`

`); { $$renderer2.push(""); } $$renderer2.push(` `); if (liveMatches().length > 0) { $$renderer2.push(""); $$renderer2.push(`

Live Now

`); const each_array_4 = ensure_array_like(liveMatches()); for (let $$index_4 = 0, $$length = each_array_4.length; $$index_4 < $$length; $$index_4++) { let m = each_array_4[$$index_4]; const { p1, p2 } = teamDisplay(m); const sc = stateConfig[m.state]; $$renderer2.push(`
`); if (p1?.team.avatarUrl) { $$renderer2.push(""); $$renderer2.push(``); } else { $$renderer2.push(""); } $$renderer2.push(` ${escape_html(p1?.team.name ?? "?")}
${escape_html(p1?.score ?? 0)} vs ${escape_html(p2?.score ?? 0)}
${escape_html(p2?.team.name ?? "?")} `); if (p2?.team.avatarUrl) { $$renderer2.push(""); $$renderer2.push(``); } else { $$renderer2.push(""); } $$renderer2.push(`
`); if (sc?.dot) { $$renderer2.push(""); $$renderer2.push(``); } else { $$renderer2.push(""); } $$renderer2.push(` ${escape_html(sc?.label ?? m.state)}`); } $$renderer2.push(`
`); } else { $$renderer2.push(""); } $$renderer2.push(`
`); if (liveMatches().length > 0) { $$renderer2.push(""); $$renderer2.push(`

Past Matches

`); } else { $$renderer2.push(""); } $$renderer2.push(`
`); const each_array_5 = ensure_array_like(recentMatches()); if (each_array_5.length !== 0) { $$renderer2.push(""); for (let $$index_5 = 0, $$length = each_array_5.length; $$index_5 < $$length; $$index_5++) { let m = each_array_5[$$index_5]; const { p1, p2 } = teamDisplay(m); const config = m.config; const sc = stateConfig[m.state]; $$renderer2.push(`
${escape_html(p1?.team.name ?? "?")} `); if (m.state === "FINISHED") { $$renderer2.push(""); $$renderer2.push(` (p2?.score ?? 0) ? "text-green-400" : "text-text-secondary")}`)}>${escape_html(p1?.score ?? 0)} - (p1?.score ?? 0) ? "text-green-400" : "text-text-secondary")}`)}>${escape_html(p2?.score ?? 0)}`); } else { $$renderer2.push(""); $$renderer2.push(`vs`); } $$renderer2.push(` ${escape_html(p2?.team.name ?? "?")}

${escape_html(m.name ? `${m.name} · ` : "")}BO${escape_html(config.bestOf)} `); if (m.finishedAt) { $$renderer2.push(""); $$renderer2.push(`· ${escape_html(timeAgo(m.finishedAt))}`); } else if (m.createdAt) { $$renderer2.push(""); $$renderer2.push(`· ${escape_html(timeAgo(m.createdAt))}`); } else { $$renderer2.push(""); } $$renderer2.push(`

`); if (m.state === "FINISHED" && m.winnerId) { $$renderer2.push(""); const winner = m.participants.find((p) => p.teamId === m.winnerId); $$renderer2.push(`🏆 ${escape_html(winner?.team.name)}`); } else { $$renderer2.push(""); } $$renderer2.push(` ${escape_html(sc?.label ?? m.state)}`); } } else { $$renderer2.push(""); if (liveMatches().length === 0) { $$renderer2.push(""); $$renderer2.push(`

No matches yet. Create one to get started.

`); } else { $$renderer2.push(""); } $$renderer2.push(``); } $$renderer2.push(`
`); }); } export { _page as default }; //# sourceMappingURL=_page.svelte-Bj4oURhW.js.map