import { translateFailureReason } from '@/lib/failureReasonMessages';

export function getPlaceholderMessage(reason: string | undefined) {
  if (reason === 'brand_zero_hit_stop') {
    return '品牌命中率为 0%，已停止后续搜索';
  }

  if (reason === 'captcha_intercept') {
    return '历史记录：1688 滑块验证未通过，当时已跳过当前阶段';
  }

  if (reason === 'round_failed') {
    return '当前阶段执行失败，已跳过';
  }

  if (reason === 'browser_target_crashed') {
    return '搜索浏览器崩溃，未进入结果页';
  }

  if (reason) {
    return translateFailureReason(reason);
  }

  return '该阶段没有可展示的商家结果';
}

export function getShortageMessage(reason: string | undefined) {
  if (reason === 'captcha_intercept') {
    return '1688 验证码未解除';
  }

  return translateFailureReason(reason);
}

export function formatStageSkipReason(reason: string | undefined) {
  if (!reason) {
    return '';
  }

  if (reason === 'brand_zero_hit_stop') {
    return '品牌命中率为 0%，已停止后续搜索';
  }

  if (reason === 'captcha_intercept') {
    return '历史记录：1688 滑块验证未通过，当时已跳过当前阶段';
  }

  if (reason === 'round_failed') {
    return '当前阶段执行失败，已跳过';
  }

  if (reason === 'browser_target_crashed') {
    return '搜索浏览器崩溃，未进入结果页';
  }

  return translateFailureReason(reason);
}
