/**
 * Time-based behavior modifiers for realistic conversation timing.
 * Adjusts response speed and greeting style based on hour of day.
 *
 * Validates: Requirement 5.3
 */

export type TimePeriod = 'morning' | 'afternoon' | 'evening' | 'night';

export interface TimeModifier {
  period: TimePeriod;
  speedMultiplier: number;
  greetingStyle?: string;
  sleepActive: boolean;
}

export const TIME_MODIFIERS: Record<TimePeriod, TimeModifier> = {
  morning: {
    period: 'morning',
    speedMultiplier: 1.0,
    greetingStyle: 'günaydın',
    sleepActive: false,
  },
  afternoon: {
    period: 'afternoon',
    speedMultiplier: 1.0,
    greetingStyle: undefined,
    sleepActive: false,
  },
  evening: {
    period: 'evening',
    speedMultiplier: 0.8,
    greetingStyle: undefined,
    sleepActive: false,
  },
  night: {
    period: 'night',
    speedMultiplier: 2.0,
    greetingStyle: undefined,
    sleepActive: true,
  },
};

/**
 * Determines the time period from an hour value (0-23).
 * - 07-11: morning
 * - 12-17: afternoon
 * - 18-22: evening
 * - 23-06: night
 */
export function getTimePeriod(hour: number): TimePeriod {
  const h = Math.floor(hour) % 24;
  if (h >= 7 && h < 12) return 'morning';
  if (h >= 12 && h < 18) return 'afternoon';
  if (h >= 18 && h < 23) return 'evening';
  return 'night';
}

/**
 * Returns the full TimeModifier for the given hour (0-23).
 */
export function getTimeModifier(hour: number): TimeModifier {
  const period = getTimePeriod(hour);
  return { ...TIME_MODIFIERS[period] };
}
