import { parseScoreCode } from './correctScoreLayout';

const CODE_I18N: Record<string, string> = {
  HOME: 'parlay_sel_home',
  AWAY: 'parlay_sel_away',
  DRAW: 'parlay_sel_draw',
  OVER: 'parlay_sel_over',
  UNDER: 'parlay_sel_under',
  ODD: 'parlay_sel_odd',
  EVEN: 'parlay_sel_even',
};

/** 标准选项按 code 显示固定文案，不依赖后台手填的 selectionName */
export function resolveSelectionLabel(
  t: (key: string) => string,
  code: string,
  fallback: string,
): string {
  const i18nKey = CODE_I18N[code];
  if (i18nKey) {
    const fullKey = `bet.${i18nKey}`;
    const v = t(fullKey);
    if (v !== fullKey) return v;
  }
  const parsed = parseScoreCode(code, t);
  if (parsed) return parsed.display;
  return fallback;
}
