import { formatCompositeStat, TankClass, TankDefinition, TankType, type CompositeStats, type CompositeStatsKey, } from '@blitzkit/core'; import strings from '@blitzkit/i18n/strings/en.json'; import { amberDark, blueDark } from '@radix-ui/colors'; import { Flex, Text, type FlexProps } from '@radix-ui/themes'; import { times } from 'lodash-es'; import type { ReactNode } from 'react'; import { breakdownConfig } from '../constants/embeds'; import { toRadiusVar } from '../core/radix/utils'; import { useLocale } from '../hooks/useLocale'; import { useEmbedStateCurry } from '../stores/embedState/utilities'; import { ClassHeavy } from './ClassIcon/components/ClassHeavy'; import { ClassLight } from './ClassIcon/components/ClassLight'; import { ClassMedium } from './ClassIcon/components/ClassMedium'; import { ClassTankDestroyer } from './ClassIcon/components/ClassTankDestroyer'; type BreakdownEmbedWrapperProps = FlexProps & { children: ReactNode; }; export function BreakdownEmbedWrapper({ children, ...props }: BreakdownEmbedWrapperProps) { const { useEmbedState } = useEmbedStateCurry(); return ( {children} ); } interface BreakdownEmbedCardProps { tank: TankDefinition | null | undefined; composite: CompositeStats; } export function BreakdownEmbedCard({ tank, composite, }: BreakdownEmbedCardProps) { const { useEmbedState, useRichText } = useEmbedStateCurry(); const { unwrap } = useLocale(); return ( {useEmbedState('cardTitleClassIcon') && tank !== null && tank !== undefined && ( <> {tank.class === TankClass.LIGHT && ( )} {tank.class === TankClass.MEDIUM && ( )} {tank.class === TankClass.HEAVY && ( )} {tank.class === TankClass.TANK_DESTROYER && ( )} )}{' '} {tank === null ? 'Total' : tank === undefined ? `Unknown tank` : unwrap(tank.name)} {times(4, (index) => { const column = (index + 1) as 1 | 2 | 3 | 4; const statKey = useEmbedState(`column${column}`) as CompositeStatsKey; const customLabel = useEmbedState(`column${column}CustomLabel`); return ( {formatCompositeStat(composite[statKey], statKey, composite)} {customLabel.length === 0 ? strings.common.composite_stats[statKey] : customLabel} ); })} ); }