// Color utilities for JavaScript performance indicators

export const getDurationClass = (durationMs: number): string => {
  if (durationMs > 50) {
    return 'danger' // Red for > 50ms
  } else if (durationMs >= 10) {
    return 'warning' // Orange for 10-50ms  
  } else {
    return 'success' // Green for < 10ms
  }
}

export const getEventTypeClass = (eventName: string): string => {
  switch (eventName) {
    case 'EvaluateScript':
      return 'primary'
    case 'v8.compile':
      return 'secondary'
    case 'v8.callFunction':
      return 'info'
    case 'v8.newInstance':
      return 'success'
    case 'V8.DeoptimizeAllOptimizedCodeWithFunction':
      return 'danger'
    case 'CpuProfiler::StartProfiling':
      return 'warning'
    default:
      return 'muted'
  }
}

export const getScriptTypeClass = (scriptType: string): string => {
  switch (scriptType) {
    case 'Inline':
      return 'warning'
    case 'External':
      return 'success'
    case 'Bundle':
      return 'primary'
    case 'Minified':
      return 'info'
    case 'Extension':
      return 'muted'
    default:
      return 'secondary'
  }
}

export const getThirdPartyIndicator = (isThirdParty: boolean): string => {
  return isThirdParty ? '🌐' : '🏠'
}

export const getStreamingIndicator = (streamed?: boolean, reason?: string): string => {
  if (streamed === true) return '🚀'
  if (streamed === false && reason) {
    switch (reason) {
      case 'inline script':
        return '📄'
      default:
        return '⏳'
    }
  }
  return ''
}