/**
 * Data Export Type Definitions
 * 
 * Types for user data export, statistics, and activity logs.
 */

/**
 * User statistics aggregated from various tables
 */
export interface UserStatistics {
  ride_count: number;
  coaster_count: number;
  park_count: number;
  review_count: number;
  reputation_score: number;
  photo_count: number;
  list_count: number;
  submission_count: number;
  account_created: string;
  last_updated: string;
}

/**
 * Individual activity log entry from profile_audit_log
 */
export interface ActivityLogEntry {
  id: string;
  action: string;
  changes: Record<string, any>;
  created_at: string;
  changed_by: string;
  ip_address_hash?: string;
  user_agent?: string;
}

/**
 * Profile data for export
 */
export interface ExportProfileData {
  username: string;
  display_name: string | null;
  bio: string | null;
  preferred_pronouns: string | null;
  personal_location: string | null;
  timezone: string;
  preferred_language: string;
  theme_preference: string;
  privacy_level: string;
  created_at: string;
  updated_at: string;
}

/**
 * Review data for export
 */
export interface ExportReviewData {
  id: string;
  rating: number;
  review_text: string | null;
  ride_name?: string;
  park_name?: string;
  created_at: string;
}

/**
 * User list data for export
 */
export interface ExportListData {
  id: string;
  name: string;
  description: string | null;
  is_public: boolean;
  item_count: number;
  created_at: string;
}

/**
 * Complete export data structure
 */
export interface ExportDataStructure {
  export_date: string;
  user_id: string;
  profile: ExportProfileData;
  statistics: UserStatistics;
  reviews: ExportReviewData[];
  lists: ExportListData[];
  activity_log: ActivityLogEntry[];
  preferences: {
    unit_preferences: any;
    accessibility_options: any;
    notification_preferences: any;
    privacy_settings: any;
  };
  metadata: {
    export_version: string;
    data_retention_info: string;
    instructions: string;
  };
}

/**
 * Export options
 */
export interface ExportOptions {
  include_reviews: boolean;
  include_lists: boolean;
  include_activity_log: boolean;
  include_preferences: boolean;
  format: 'json';
}

/**
 * Export progress tracking
 */
export interface ExportProgress {
  stage: 'starting' | 'fetching_profile' | 'fetching_reviews' | 'fetching_lists' | 'fetching_activity' | 'packaging' | 'complete';
  progress: number;
  message: string;
}

/**
 * Data categories available for export
 */
export type DataCategory = 'profile' | 'reviews' | 'lists' | 'activity_log' | 'preferences';

/**
 * Export request result
 */
export interface ExportRequestResult {
  success: boolean;
  data?: ExportDataStructure;
  error?: string;
  rate_limited?: boolean;
  next_available_at?: string;
}
