/**
 * User agent randomization for anti-bot measures
 */

const DESKTOP_USER_AGENTS = [
  'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
  'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
  'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
  'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0',
  'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15',
];

const MOBILE_USER_AGENTS = [
  'Mozilla/5.0 (iPhone; CPU iPhone OS 17_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Mobile/15E148 Safari/604.1',
  'Mozilla/5.0 (Linux; Android 13; SM-S911B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36',
  'Mozilla/5.0 (iPad; CPU OS 17_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Mobile/15E148 Safari/604.1',
  'Mozilla/5.0 (Linux; Android 13; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36',
];

const TIMEZONES = [
  'America/New_York',
  'America/Chicago',
  'America/Los_Angeles',
  'Europe/London',
  'Europe/Paris',
  'Asia/Tokyo',
  'Australia/Sydney',
];

const LOCALES = [
  'en-US',
  'en-GB',
  'fr-FR',
  'de-DE',
  'ja-JP',
  'es-ES',
];

/**
 * Get a random user agent for the specified device mode
 */
export function getRandomUserAgent(deviceMode: 'desktop' | 'mobile'): string {
  const agents = deviceMode === 'desktop' ? DESKTOP_USER_AGENTS : MOBILE_USER_AGENTS;
  return agents[Math.floor(Math.random() * agents.length)];
}

/**
 * Get a random timezone
 */
export function getRandomTimezone(): string {
  return TIMEZONES[Math.floor(Math.random() * TIMEZONES.length)];
}

/**
 * Get a random locale
 */
export function getRandomLocale(): string {
  return LOCALES[Math.floor(Math.random() * LOCALES.length)];
}

/**
 * Get viewport size for device mode
 */
export function getViewport(deviceMode: 'desktop' | 'mobile'): { width: number; height: number } {
  if (deviceMode === 'mobile') {
    return { width: 375, height: 812 }; // iPhone X size
  }
  return { width: 1920, height: 1080 }; // Full HD
}
