const LANGUAGE_ALIASES: Record<string, string> = {
  js: 'javascript',
  ts: 'typescript',
  py: 'python',
  rb: 'ruby',
  sh: 'bash',
  yml: 'yaml',
  md: 'markdown',
  xml: 'xml',
  svg: 'xml',
  noise: 'xml'
}

export function resolveHighlightLanguage(typeName?: string): string {
  if (!typeName) return 'plaintext'
  const key = typeName.trim().toLowerCase()
  if (!key) return 'plaintext'
  return LANGUAGE_ALIASES[key] || key
}

export function isHtmlFrontendType(codeType?: { name?: string; category?: number } | null): boolean {
  if (!codeType) return false
  return codeType.category === 0 && (codeType.name || '').toLowerCase() === 'html'
}
