function evaluateKillConditions(context) {
  const {
    seasonStats,
    recentStats,
    homeAwaySplit,
    restSplit,
    vsOpponentSplit,
    spread,
  } = context;

  const conditions = [];

  // 1. low_minutes: season avg minutes < 24
  if (seasonStats && seasonStats.minutes != null && seasonStats.minutes < 24) {
    conditions.push({
      code: 'low_minutes',
      reason: `Player averages only ${seasonStats.minutes} minutes per game`,
    });
  }

  // 2. small_sample: games played < 15
  if (seasonStats && seasonStats.games_played != null && seasonStats.games_played < 15) {
    conditions.push({
      code: 'small_sample',
      reason: `Only ${seasonStats.games_played} games played this season`,
    });
  }

  // 3. b2b_high_usage: back-to-back game + minutes > 32
  if (restSplit && restSplit.isB2B && seasonStats && seasonStats.minutes > 32) {
    conditions.push({
      code: 'b2b_high_usage',
      reason: `Back-to-back game with ${seasonStats.minutes} avg minutes`,
    });
  }

  // 4. blowout_risk: spread > 10 points
  if (spread != null && Math.abs(spread) > 10) {
    conditions.push({
      code: 'blowout_risk',
      reason: `Game spread is ${spread > 0 ? '+' : ''}${spread} — blowout risk`,
    });
  }

  // 5. split_conflict: home/away split differs > 5 from recent form
  if (homeAwaySplit && recentStats) {
    const splitAvg = homeAwaySplit.avg;
    const recentAvg = recentStats.value;
    if (splitAvg != null && recentAvg != null && Math.abs(splitAvg - recentAvg) > 5) {
      conditions.push({
        code: 'split_conflict',
        reason: `Situational avg (${splitAvg}) differs from recent form (${recentAvg}) by ${Math.abs(splitAvg - recentAvg).toFixed(1)}`,
      });
    }
  }

  // 6. no_opponent_data: vs_team games < 2
  if (vsOpponentSplit && vsOpponentSplit.games != null && vsOpponentSplit.games < 2) {
    conditions.push({
      code: 'no_opponent_data',
      reason: `Only ${vsOpponentSplit.games} game(s) against this opponent`,
    });
  }

  return conditions;
}

module.exports = { evaluateKillConditions };
