export const STUDY_TYPE_MAP: Record<string, { label: string; type: 'success' | 'info' | 'warning' | 'default' }> = {
  'Randomized Controlled Trial': { label: 'RCT', type: 'success' },
  'Clinical Trial, Phase III': { label: '3期RCT', type: 'success' },
  'Clinical Trial, Phase II': { label: '2期研究', type: 'info' },
  'Clinical Trial, Phase I': { label: '1期研究', type: 'default' },
  'Meta-Analysis': { label: 'Meta分析', type: 'info' },
  'Systematic Review': { label: '系统评价', type: 'info' },
  'Review': { label: '综述', type: 'default' },
  'Practice Guideline': { label: '指南', type: 'warning' },
  'Guideline': { label: '指南', type: 'warning' },
  'Observational Study': { label: '观察性研究', type: 'info' },
  'Multicenter Study': { label: '多中心', type: 'info' },
  'Comparative Study': { label: '对比研究', type: 'default' },
  'Editorial': { label: '社论', type: 'warning' },
  'Case Reports': { label: '病例报告', type: 'default' },
  'Consensus Development Conference': { label: '共识', type: 'warning' },
}

export function computeStudyTypes(pubTypes: string[]): { label: string; type: 'success' | 'info' | 'warning' | 'default' }[] {
  if (!pubTypes?.length) return []
  return pubTypes
    .filter((t: string) => t !== 'Journal Article')
    .map((t: string) => STUDY_TYPE_MAP[t])
    .filter(Boolean) as { label: string; type: 'success' | 'info' | 'warning' | 'default' }[]
}
