import { useState } from "react"; import { Link, useLocation, useParams } from "react-router"; import { Area, AreaChart, CartesianGrid, Line, ReferenceLine, ResponsiveContainer, Tooltip, XAxis, YAxis, } from "recharts"; import { useDdragonManifest, useInternalMatchDetail } from "../api/hooks"; import type { ApiInternalMatchDetailResponse, TeamSide } from "../api/types"; import { DEFAULT_COMMUNITY_ID } from "../config"; import { championDisplayName, championIconUrl, itemIconUrl, runeIconUrl, runeKeystoneIconUrl, runeStyleIconUrl, summonerSpellIconUrl, } from "../lib/ddragon"; import { sideShortLabel, teamIndexColorClasses, teamIndexLabel, } from "../lib/league"; import { internalMatchDetailPath, internalMatchGamePath, } from "../lib/internal-match-routes"; import { LANE_LABELS } from "../lib/riot-history"; type MatchGameDetail = ApiInternalMatchDetailResponse["games"][number]; type MatchGameTeam = MatchGameDetail["teams"][number]; type MatchGameParticipant = MatchGameTeam["participants"][number]; type DdragonManifestData = ReturnType["data"]; type RuneStyleEntry = NonNullable["runesReforged"][number]; type DetailTab = "scoreboard" | "matchup" | "build"; type TimelineMetric = "gold" | "xp"; type MatchGameBackTarget = { to: string; label: string; }; type MatchGameNavigationState = { backTo: string; backLabel: string; }; const DETAIL_TABS: Array<{ id: DetailTab; label: string }> = [ { id: "scoreboard", label: "스코어보드" }, { id: "matchup", label: "라인전" }, { id: "build", label: "룬 / 빌드" }, ]; const TIMELINE_METRICS: Array<{ id: TimelineMetric; label: string }> = [ { id: "gold", label: "골드" }, { id: "xp", label: "경험치" }, ]; function isRecord(value: unknown): value is Record { return typeof value === "object" && value !== null; } function resolveBackTarget( state: unknown, fallbackTo: string, ): MatchGameBackTarget { if ( isRecord(state) && typeof state.backTo === "string" && state.backTo.startsWith("/") && !state.backTo.startsWith("//") ) { return { to: state.backTo, label: typeof state.backLabel === "string" ? state.backLabel : "돌아가기", }; } return { to: fallbackTo, label: "경기 결과로 돌아가기", }; } function createNavigationState( backTarget: MatchGameBackTarget, fallbackTo: string, ): MatchGameNavigationState | undefined { if (backTarget.to === fallbackTo) return undefined; return { backTo: backTarget.to, backLabel: backTarget.label, }; } const SKILL_ROWS: Array<{ slot: 1 | 2 | 3 | 4; label: string; className: string; }> = [ { slot: 1, label: "Q", className: "bg-blue-500 text-white" }, { slot: 2, label: "W", className: "bg-cyan-500 text-white" }, { slot: 3, label: "E", className: "bg-amber-500 text-black" }, { slot: 4, label: "R", className: "bg-red-500 text-white" }, ]; const STAT_PERK_LABELS: Record = { 5001: "체력", 5002: "방어", 5003: "마저", 5005: "공속", 5007: "가속", 5008: "적응", 5010: "이속", 5011: "체력", }; function formatDateTime(value: string | number) { return new Intl.DateTimeFormat("ko-KR", { month: "long", day: "numeric", hour: "2-digit", minute: "2-digit", }).format(new Date(value)); } function formatDuration(seconds: number) { const minutes = Math.floor(seconds / 60); const rest = seconds % 60; return `${minutes}:${String(rest).padStart(2, "0")}`; } function formatNumber(value: number) { return new Intl.NumberFormat("ko-KR").format(value); } function formatCompactNumber(value: number) { if (value >= 1000) return `${(value / 1000).toFixed(1)}K`; return String(value); } function formatSignedCompactNumber(value: number) { if (value === 0) return "0"; return `${value > 0 ? "+" : "-"}${formatCompactNumber(Math.abs(value))}`; } function formatGameVersion(value: string | undefined) { if (!value) return null; const [major, minor] = value.split("."); return major && minor ? `${major}.${minor}` : value; } function formatKda(kills: number, deaths: number, assists: number) { if (deaths === 0) return kills + assists > 0 ? "Perfect" : "-"; return ((kills + assists) / deaths).toFixed(2); } function formatPercent(value: number) { return `${value}%`; } function barWidth(value: number, max: number) { return `${Math.max(0, Math.min(100, max > 0 ? (value / max) * 100 : 0))}%`; } function sideLabel(side: TeamSide) { return sideShortLabel(side); } function sideTone(side: TeamSide) { return side === "blue" ? { border: "border-blue-500/20", bg: "bg-blue-500/5", text: "text-blue-400", bar: "bg-blue-500", } : { border: "border-red-500/20", bg: "bg-red-500/5", text: "text-red-400", bar: "bg-red-500", }; } function teamTotals(team: MatchGameTeam) { return team.participants.reduce( (totals, participant) => ({ kills: totals.kills + participant.kills, deaths: totals.deaths + participant.deaths, assists: totals.assists + participant.assists, gold: totals.gold + participant.gold, damage: totals.damage + participant.damageDealtToChampions, damageTaken: totals.damageTaken + (participant.damageTaken ?? 0), vision: totals.vision + participant.visionScore, }), { kills: 0, deaths: 0, assists: 0, gold: 0, damage: 0, damageTaken: 0, vision: 0, }, ); } function getTeamName( detail: ApiInternalMatchDetailResponse, teamIndex: number, ) { return teamIndexLabel( teamIndex, detail.match.teams.find((team) => team.teamIndex === teamIndex)?.name, ); } function resolveSelectedSeries( detail: ApiInternalMatchDetailResponse, selectedGame: MatchGameDetail, ) { const teamIndexes = selectedGame.teams.map((team) => team.teamIndex); return detail.match.seriesResults.find( (series) => teamIndexes.includes(series.teamAIndex) && teamIndexes.includes(series.teamBIndex), ); } function participantBuildKey(participant: MatchGameParticipant) { return `${participant.side}-${participant.userId ?? participant.summonerName}-${participant.championId}`; } function findRuneStyle( manifest: DdragonManifestData, styleId: number | undefined, ) { return manifest?.runesReforged.find((style) => style.id === styleId) ?? null; } function selectedRuneIds(participant: MatchGameParticipant) { const explicit = participant.perks.selectedPerkIds ?? []; const fromStyles = participant.perks.styles?.flatMap((style) => style.perkIds) ?? []; return new Set([ ...explicit, ...fromStyles, ...(participant.perks.keystone ? [participant.perks.keystone] : []), ]); } function runeStyleSelection( participant: MatchGameParticipant, styleId: number | undefined, ) { return participant.perks.styles?.find((style) => style.styleId === styleId); } function WinBadge({ win }: { win: boolean }) { return win ? ( 승리 ) : ( 패배 ); } function ChampionCell({ participant, manifest, }: { participant: MatchGameParticipant; manifest: ReturnType["data"]; }) { const icon = championIconUrl(manifest, participant.championId); const name = championDisplayName(manifest, participant.championId) ?? String(participant.championId); return (
{icon ? ( {name} ) : null} {participant.championLevel > 0 && ( {participant.championLevel} )}
{name} {LANE_LABELS[participant.teamPosition] ?? participant.teamPosition ?? "-"}
); } function SpellRuneStrip({ participant, manifest, }: { participant: MatchGameParticipant; manifest: ReturnType["data"]; }) { const spellIcons = participant.summonerSpells .map((spellId) => summonerSpellIconUrl(manifest, spellId)) .filter((icon): icon is string => Boolean(icon)); const runeIcons = [ runeKeystoneIconUrl(manifest, participant.perks.keystone), runeStyleIconUrl(manifest, participant.perks.subStyle), ].filter((icon): icon is string => Boolean(icon)); return (
{[0, 1].map((index) => ( {spellIcons[index] ? ( ) : null} ))}
{[0, 1].map((index) => ( {runeIcons[index] ? ( ) : null} ))}
); } function ItemStrip({ participant, manifest, }: { participant: MatchGameParticipant; manifest: ReturnType["data"]; }) { const itemIds = [ ...Array.from({ length: 6 }, (_, index) => participant.items[index] ?? 0), participant.trinket, ]; return (
{itemIds.map((itemId, index) => { const icon = itemIconUrl(manifest, itemId); return ( {icon ? ( ) : null} ); })}
); } function PercentBar({ value, side }: { value: number; side: TeamSide }) { const width = `${Math.max(0, Math.min(100, value))}%`; return (
); } function PlayerIdentityCell({ participant, manifest, avatarSize = "h-12 w-12", nameMaxWidth = "max-w-[150px]", }: { participant: MatchGameParticipant; manifest: ReturnType["data"]; avatarSize?: string; nameMaxWidth?: string; }) { const location = useLocation(); const historyBackTo = `${location.pathname}${location.search}${location.hash}`; const lane = LANE_LABELS[participant.teamPosition] ?? participant.teamPosition ?? "-"; const nameNode = ( <> {participant.summonerName} {participant.tagLine ? ( {" "} #{participant.tagLine} ) : null} ); return (
{participant.userId ? ( {nameNode} ) : ( {nameNode} )}
{lane} {(participant.firstBloodKill || participant.firstBloodAssist) && ( {participant.firstBloodKill ? "FB" : "FBA"} )}
); } function PlayerRow({ participant, manifest, teamDamageTaken, }: { participant: MatchGameParticipant; manifest: ReturnType["data"]; teamDamageTaken: number; }) { const takenShare = teamDamageTaken > 0 ? ((participant.damageTaken ?? 0) / teamDamageTaken) * 100 : 0; return (
{participant.kills} / {participant.deaths} / {participant.assists}
{formatKda( participant.kills, participant.deaths, participant.assists, )} ({participant.killParticipation}%)
{formatNumber(participant.damageDealtToChampions)}
{formatPercent(participant.damageShare)} {formatNumber(participant.damageTaken ?? 0)}
{Math.round(takenShare)}% {participant.visionScore} 와드 {participant.wardsPlaced ?? 0}/{participant.wardsKilled ?? 0} 제어 {participant.controlWardsBought ?? 0} {participant.cs} {participant.csPerMin}/m ); } function PlayerCard({ participant, manifest, teamDamageTaken, }: { participant: MatchGameParticipant; manifest: ReturnType["data"]; teamDamageTaken: number; }) { const takenShare = teamDamageTaken > 0 ? ((participant.damageTaken ?? 0) / teamDamageTaken) * 100 : 0; return (
{participant.kills} / {participant.deaths} / {participant.assists}
{formatKda( participant.kills, participant.deaths, participant.assists, )} ({participant.killParticipation}%)
가한 피해량
{formatNumber(participant.damageDealtToChampions)} {formatPercent(participant.damageShare)}
받은 피해량
{formatNumber(participant.damageTaken ?? 0)} {Math.round(takenShare)}%
CS
{participant.cs} {participant.csPerMin}/m
시야
{participant.visionScore} {participant.wardsPlaced ?? 0}/{participant.wardsKilled ?? 0}
); } function TeamScoreHeader({ team, detail, }: { team: MatchGameTeam; detail: ApiInternalMatchDetailResponse; }) { const tone = sideTone(team.side); const teamTone = teamIndexColorClasses(team.teamIndex); const totals = teamTotals(team); return (
KDA {totals.kills} / {totals.deaths} / {totals.assists}
Gold {formatCompactNumber(totals.gold)}
); } function BanStrip({ bans, manifest, }: { bans: MatchGameTeam["bans"] | undefined; manifest: ReturnType["data"]; }) { const sortedBans = [...(bans ?? [])].sort( (left, right) => left.pickTurn - right.pickTurn, ); return (
{sortedBans.length > 0 ? ( sortedBans.map((ban) => { const icon = championIconUrl(manifest, ban.championId); const name = championDisplayName(manifest, ban.championId) ?? String(ban.championId); return ( {icon ? ( {name} ) : null} ); }) ) : ( 밴 없음 )}
); } function PostgameBreakdown({ selectedGame, detail, manifest, }: { selectedGame: MatchGameDetail; detail: ApiInternalMatchDetailResponse; manifest: ReturnType["data"]; }) { const orderedTeams = [...selectedGame.teams].sort((left, right) => left.side === right.side ? 0 : left.side === "blue" ? -1 : 1, ); const version = formatGameVersion(selectedGame.gameVersion); return (

경기 요약

{version ? Ver. {version} : null} {formatDuration(selectedGame.gameDuration)} {selectedGame.riotMatchId}
{orderedTeams.map((team) => { const tone = sideTone(team.side); const teamTone = teamIndexColorClasses(team.teamIndex); return (
{getTeamName(detail, team.teamIndex)} 밴
); })}
); } function GoldComparisonStrip({ selectedGame, detail, }: { selectedGame: MatchGameDetail; detail: ApiInternalMatchDetailResponse; }) { const blueTeam = selectedGame.teams.find((team) => team.side === "blue"); const redTeam = selectedGame.teams.find((team) => team.side === "red"); if (!blueTeam || !redTeam) return null; const blueTotals = teamTotals(blueTeam); const redTotals = teamTotals(redTeam); const goldDiff = blueTotals.gold - redTotals.gold; const maxGold = Math.max(1, blueTotals.gold, redTotals.gold); const leaderSide = goldDiff > 0 ? "blue" : goldDiff < 0 ? "red" : ("blue" as TeamSide); const leaderName = goldDiff === 0 ? "동률" : getTeamName( detail, leaderSide === "blue" ? blueTeam.teamIndex : redTeam.teamIndex, ); return (
{getTeamName(detail, blueTeam.teamIndex)} {formatNumber(blueTotals.gold)}
골드 차이
0 ? "text-blue-400" : goldDiff < 0 ? "text-red-400" : "text-base-content/55" }`} > {formatSignedCompactNumber(goldDiff)}
{leaderName}
{formatNumber(redTotals.gold)} {getTeamName(detail, redTeam.teamIndex)}
); } interface TimelineChartPoint { timestamp: number; timeLabel: string; value: number; positive: number; negative: number; blueTotal: number; redTotal: number; leaderSide: TeamSide | null; } function TimelineTooltip({ active, payload, blueTeamName, redTeamName, metricLabel, }: { active?: boolean; payload?: Array<{ payload: TimelineChartPoint }>; blueTeamName: string; redTeamName: string; metricLabel: string; }) { const point = payload?.[0]?.payload; if (!active || !point) return null; const leaderName = point.leaderSide === "blue" ? blueTeamName : point.leaderSide === "red" ? redTeamName : "동률"; return (
{point.timeLabel}
{leaderName} {formatSignedCompactNumber(point.value)}
{blueTeamName} {formatNumber(point.blueTotal)}
{redTeamName} {formatNumber(point.redTotal)}
{metricLabel}
); } function TimelineGraph({ selectedGame, detail, }: { selectedGame: MatchGameDetail; detail: ApiInternalMatchDetailResponse; }) { const [metric, setMetric] = useState("gold"); const blueTeam = selectedGame.teams.find((team) => team.side === "blue"); const redTeam = selectedGame.teams.find((team) => team.side === "red"); const blueTeamName = blueTeam ? getTeamName(detail, blueTeam.teamIndex) : "BLUE"; const redTeamName = redTeam ? getTeamName(detail, redTeam.teamIndex) : "RED"; const metricLabel = metric === "gold" ? "골드" : "경험치"; const chartData: TimelineChartPoint[] = (selectedGame.timeline ?? []).map( (point) => { const value = metric === "gold" ? point.goldDiff : point.xpDiff; return { timestamp: point.timestamp, timeLabel: formatDuration(point.timestamp), value, positive: Math.max(value, 0), negative: Math.min(value, 0), blueTotal: metric === "gold" ? point.blue.gold : point.blue.xp, redTotal: metric === "gold" ? point.red.gold : point.red.xp, leaderSide: value > 0 ? "blue" : value < 0 ? "red" : null, }; }, ); const maxAbs = Math.max( 1, ...chartData.map((point) => Math.abs(point.value)), ); const finalPoint = chartData[chartData.length - 1]; const finalLeader = finalPoint?.leaderSide === "blue" ? blueTeamName : finalPoint?.leaderSide === "red" ? redTeamName : "동률"; return (

경기 흐름

{finalPoint ? `${finalLeader} ${formatSignedCompactNumber(finalPoint.value)}` : "타임라인 대기"}
{TIMELINE_METRICS.map((item) => ( ))}
{chartData.length > 0 ? (
`${Math.round(Number(value) / 60)}분` } tick={{ fill: "currentColor", fontSize: 11 }} tickLine={false} axisLine={false} /> formatSignedCompactNumber(Number(value)) } tick={{ fill: "currentColor", fontSize: 11 }} tickLine={false} axisLine={false} width={58} /> } />
{blueTeamName} 0 {redTeamName}
) : (
타임라인 데이터가 아직 없습니다
)}
); } function TeamTable({ team, detail, manifest, }: { team: MatchGameTeam; detail: ApiInternalMatchDetailResponse; manifest: ReturnType["data"]; }) { const teamDamageTaken = teamTotals(team).damageTaken; return (
{team.participants.map((participant) => ( ))}
{team.participants.map((participant) => ( ))}
선수 KDA 가한 피해량 받은 피해량 시야 CS 아이템
); } function DetailTabBar({ activeTab, onChange, }: { activeTab: DetailTab; onChange: (tab: DetailTab) => void; }) { return (
{DETAIL_TABS.map((tab) => ( ))}
); } function RuneBuildPanel({ selectedGame, detail, manifest, }: { selectedGame: MatchGameDetail; detail: ApiInternalMatchDetailResponse; manifest: DdragonManifestData; }) { const orderedTeams = [...selectedGame.teams].sort((left, right) => left.side === right.side ? 0 : left.side === "blue" ? -1 : 1, ); const participants = orderedTeams.flatMap((team) => team.participants); const defaultKey = participants[0] ? participantBuildKey(participants[0]) : ""; const [selectedKey, setSelectedKey] = useState(defaultKey); const effectiveSelectedKey = participants.some( (participant) => participantBuildKey(participant) === selectedKey, ) ? selectedKey : defaultKey; const selectedParticipant = participants.find( (participant) => participantBuildKey(participant) === effectiveSelectedKey, ) ?? participants[0]; if (!selectedParticipant) { return (
빌드 데이터가 없습니다
); } return (
); } function BuildChampionSelector({ selectedGame, detail, manifest, selectedKey, onSelect, }: { selectedGame: MatchGameDetail; detail: ApiInternalMatchDetailResponse; manifest: DdragonManifestData; selectedKey: string; onSelect: (key: string) => void; }) { const orderedTeams = [...selectedGame.teams].sort((left, right) => left.side === right.side ? 0 : left.side === "blue" ? -1 : 1, ); return (
{orderedTeams.map((team) => { const tone = sideTone(team.side); return (
{sideLabel(team.side)} Side
{getTeamName(detail, team.teamIndex)}
{team.participants.map((participant) => ( onSelect(participantBuildKey(participant))} /> ))}
); })}
); } function BuildChampionButton({ participant, manifest, selected, onClick, }: { participant: MatchGameParticipant; manifest: DdragonManifestData; selected: boolean; onClick: () => void; }) { const icon = championIconUrl(manifest, participant.championId); const championName = championDisplayName(manifest, participant.championId) ?? String(participant.championId); const tone = sideTone(participant.side); return ( ); } function RunesPanel({ participant, manifest, }: { participant: MatchGameParticipant; manifest: DdragonManifestData; }) { const selectedIds = selectedRuneIds(participant); const primaryStyleId = participant.perks.primaryStyle ?? participant.perks.styles?.[0]?.styleId; const subStyleId = participant.perks.subStyle ?? participant.perks.styles?.[1]?.styleId; const primaryStyle = findRuneStyle(manifest, primaryStyleId); const subStyle = findRuneStyle(manifest, subStyleId); return (
Runes
{participant.summonerName}
); } function RuneTreeColumn({ label, runeStyle, selection, selectedIds, manifest, }: { label: string; runeStyle: RuneStyleEntry | null; selection: ReturnType; selectedIds: Set; manifest: DdragonManifestData; }) { if (!runeStyle) { return (
{label}
룬 데이터 없음
); } const styleIcon = runeStyleIconUrl(manifest, runeStyle.id); const selectionIds = new Set(selection?.perkIds ?? []); return (
{styleIcon ? ( ) : null}
{label}
{runeStyle.name}
{runeStyle.slots.map((slot, slotIndex) => (
{slot.runes.map((rune) => { const selected = selectedIds.has(rune.id) || selectionIds.has(rune.id); const icon = runeIconUrl(manifest, rune.id); return ( {icon ? ( ) : null} ); })}
))}
); } function RuneShardRows({ participant }: { participant: MatchGameParticipant }) { const statPerks = participant.perks.statPerks; const shards = [ { label: "공격", value: statPerks?.offense }, { label: "보조", value: statPerks?.flex }, { label: "방어", value: statPerks?.defense }, ].filter((shard) => typeof shard.value === "number" && shard.value > 0); if (shards.length === 0) return null; return (
스탯 파편
{shards.map((shard) => ( {shard.label} {STAT_PERK_LABELS[shard.value ?? 0] ?? shard.value} ))}
); } function ItemBuildPanel({ participant, manifest, }: { participant: MatchGameParticipant; manifest: DdragonManifestData; }) { const buildEvents = (participant.itemBuild ?? []).filter( (event) => event.itemId > 0 && event.type === "purchased", ); const fallbackItems = [ ...participant.items.filter((itemId) => itemId > 0), participant.trinket, ].filter((itemId) => itemId > 0); return (
Item Build
{buildEvents.length > 0 ? (
{buildEvents.map((event, index) => (
{index < buildEvents.length - 1 ? ( > ) : null}
))}
) : fallbackItems.length > 0 ? (
{fallbackItems.map((itemId, index) => { const icon = itemIconUrl(manifest, itemId); return ( {icon ? ( ) : null} ); })}
) : (
아이템 빌드 데이터 없음
)}
); } function ItemBuildNode({ itemId, timestamp, manifest, }: { itemId: number; timestamp: number; manifest: DdragonManifestData; }) { const icon = itemIconUrl(manifest, itemId); return (
{icon ? ( ) : null} {formatDuration(timestamp)}
); } function SkillBuildPanel({ participant, }: { participant: MatchGameParticipant; }) { const skillEvents = participant.skillBuild ?? []; const skillByLevel = new Map( skillEvents.map((event) => [event.level, event]), ); return (
Skill Build
Lv. {skillEvents.length || participant.championLevel || "-"}
{skillEvents.length > 0 ? (
{SKILL_ROWS.map((row) => (
{row.label}
{Array.from({ length: 18 }, (_, index) => index + 1).map( (level) => { const event = skillByLevel.get(level); const active = event?.skillSlot === row.slot; return (
{active ? level : ""}
); }, )}
))}
) : (
스킬 빌드 데이터 없음
)}
); } const LANE_SORT_ORDER = ["TOP", "JUNGLE", "MIDDLE", "BOTTOM", "UTILITY"]; function laneSortValue(position: string) { const index = LANE_SORT_ORDER.indexOf(position); return index === -1 ? 99 : index; } function ChampionAvatar({ participant, manifest, size = "h-9 w-9", }: { participant: MatchGameParticipant; manifest: ReturnType["data"]; size?: string; }) { const icon = championIconUrl(manifest, participant.championId); const name = championDisplayName(manifest, participant.championId) ?? String(participant.championId); return ( {icon ? ( {name} ) : null} {participant.championLevel > 0 ? ( {participant.championLevel} ) : null} ); } function MatchupMetricRow({ label, blueLead, redLead, blueText, redText, bluePct, }: { label: string; blueLead: boolean; redLead: boolean; blueText: string; redText: string; bluePct: number; }) { return (
{blueText} {label} {redText}
); } function LaneMatchupCard({ blue, red, detail, manifest, }: { blue: MatchGameParticipant; red: MatchGameParticipant; detail: ApiInternalMatchDetailResponse; manifest: ReturnType["data"]; }) { const laneLabel = LANE_LABELS[blue.teamPosition] ?? LANE_LABELS[red.teamPosition] ?? blue.teamPosition ?? "-"; const metrics = [ { key: "kda", label: "KDA", blueValue: blue.deaths === 0 ? blue.kills + blue.assists : (blue.kills + blue.assists) / blue.deaths, redValue: red.deaths === 0 ? red.kills + red.assists : (red.kills + red.assists) / red.deaths, blueText: `${blue.kills}/${blue.deaths}/${blue.assists}`, redText: `${red.kills}/${red.deaths}/${red.assists}`, }, { key: "gold", label: "골드", blueValue: blue.gold, redValue: red.gold, blueText: formatNumber(blue.gold), redText: formatNumber(red.gold), }, { key: "damage", label: "딜량", blueValue: blue.damageDealtToChampions, redValue: red.damageDealtToChampions, blueText: formatNumber(blue.damageDealtToChampions), redText: formatNumber(red.damageDealtToChampions), }, { key: "cs", label: "CS", blueValue: blue.cs, redValue: red.cs, blueText: `${blue.cs} (${blue.csPerMin}/m)`, redText: `${red.cs} (${red.csPerMin}/m)`, }, ]; const championName = (participant: MatchGameParticipant) => championDisplayName(manifest, participant.championId) ?? String(participant.championId); return (
{blue.summonerName}
{championName(blue)}
{laneLabel}
{red.summonerName}
{championName(red)}
{metrics.map((metric) => { const total = metric.blueValue + metric.redValue; const bluePct = total > 0 ? (metric.blueValue / total) * 100 : 50; return ( metric.redValue} redLead={metric.redValue > metric.blueValue} blueText={metric.blueText} redText={metric.redText} bluePct={bluePct} /> ); })}
); } function LaneMatchupPanel({ selectedGame, detail, manifest, }: { selectedGame: MatchGameDetail; detail: ApiInternalMatchDetailResponse; manifest: ReturnType["data"]; }) { const blueTeam = selectedGame.teams.find((team) => team.side === "blue"); const redTeam = selectedGame.teams.find((team) => team.side === "red"); if (!blueTeam || !redTeam) { return (
라인전 비교 데이터가 없습니다
); } const blueSorted = [...blueTeam.participants].sort( (left, right) => laneSortValue(left.teamPosition) - laneSortValue(right.teamPosition), ); const redSorted = [...redTeam.participants].sort( (left, right) => laneSortValue(left.teamPosition) - laneSortValue(right.teamPosition), ); const blueTeamName = getTeamName(detail, blueTeam.teamIndex); const redTeamName = getTeamName(detail, redTeam.teamIndex); return (
{blueTeamName} VS {redTeamName}
{blueSorted.map((blue, index) => { const red = redSorted[index]; if (!red) return null; return ( ); })}
); } function ScoreboardTables({ selectedGame, detail, manifest, }: { selectedGame: MatchGameDetail; detail: ApiInternalMatchDetailResponse; manifest: ReturnType["data"]; }) { const orderedTeams = [...selectedGame.teams].sort((left, right) => left.side === right.side ? 0 : left.side === "blue" ? -1 : 1, ); return (
{orderedTeams.map((team) => ( ))}
); } function GameAnalysisPanel({ activeTab, selectedGame, detail, manifest, }: { activeTab: DetailTab; selectedGame: MatchGameDetail; detail: ApiInternalMatchDetailResponse; manifest: ReturnType["data"]; }) { if (activeTab === "scoreboard") { return ( ); } if (activeTab === "build") { return ( ); } return ( ); } function GameTabs({ detail, communityId, currentGameNumber, navigationState, }: { detail: ApiInternalMatchDetailResponse; communityId: string; currentGameNumber: number; navigationState: MatchGameNavigationState | undefined; }) { return ( ); } function MatchScoreHero({ detail, communityId, selectedGame, backTarget, navigationState, }: { detail: ApiInternalMatchDetailResponse; communityId: string; selectedGame: MatchGameDetail; backTarget: MatchGameBackTarget; navigationState: MatchGameNavigationState | undefined; }) { const selectedSeries = resolveSelectedSeries(detail, selectedGame); const [leftTeam, rightTeam] = selectedGame.teams; const leftScore = selectedSeries?.teamAIndex === leftTeam?.teamIndex ? selectedSeries?.teamAWins : selectedSeries?.teamBWins; const rightScore = selectedSeries?.teamBIndex === rightTeam?.teamIndex ? selectedSeries?.teamBWins : selectedSeries?.teamAWins; return (
← {backTarget.label}

{detail.match.title} · {selectedGame.gameNumber}세트

{formatDateTime(selectedGame.gameCreation)} ·{" "} {formatDuration(selectedGame.gameDuration)} ·{" "} {selectedGame.riotMatchId}

{leftTeam && rightTeam && (
{getTeamName(detail, leftTeam.teamIndex)}
{sideLabel(leftTeam.side)}
{leftScore ?? (leftTeam.win ? 1 : 0)} VS {rightScore ?? (rightTeam.win ? 1 : 0)}
{getTeamName(detail, rightTeam.teamIndex)}
{sideLabel(rightTeam.side)}
)}
); } export default function MatchGameDetailPage() { const { cid, matchId, id, gameNumber } = useParams(); const location = useLocation(); const [activeTab, setActiveTab] = useState("scoreboard"); const communityId = cid ?? DEFAULT_COMMUNITY_ID; const resolvedMatchId = matchId ?? id; const requestedGameNumber = Number(gameNumber); const detailQuery = useInternalMatchDetail(resolvedMatchId, communityId); const { data: ddragon } = useDdragonManifest(); const detail = detailQuery.data; const fallbackBackTo = resolvedMatchId ? internalMatchDetailPath(communityId, resolvedMatchId) : `/communities/${communityId}/internal-stats`; const backTarget = resolveBackTarget(location.state, fallbackBackTo); const navigationState = createNavigationState(backTarget, fallbackBackTo); if (detailQuery.isLoading) { return (
세트 상세 기록을 불러오는 중...
); } if (detailQuery.error || !detail) { return (

세트 기록을 찾을 수 없습니다

{backTarget.label}
); } const selectedGame = detail.games.find((game) => game.gameNumber === requestedGameNumber) ?? detail.games[0]; if (!selectedGame) { return (

수집된 세트 기록이 없습니다

{backTarget.label}
); } return (
); }