/**
 * Estimates reading time for a given text
 * @param text The text to calculate reading time for
 * @returns Estimated reading time in minutes
 */
export function estimateReadingTime(text: string): number {
  // Average reading speed: 200 words per minute
  const wordsPerMinute = 200;
  
  // Remove extra whitespace and split into words
  const words = text.trim().split(/\s+/).length;
  
  // Calculate reading time and round up
  const readingTime = Math.ceil(words / wordsPerMinute);
  
  // Minimum 1 minute
  return Math.max(1, readingTime);
}

/**
 * Formats reading time with tilde prefix
 * @param minutes Reading time in minutes
 * @returns Formatted string (e.g., "~3 min")
 */
export function formatReadingTime(minutes: number): string {
  return `~${minutes} min`;
}