/**
 * Timeline Event Types
 * 
 * Type definitions for entity timeline/historical milestone system.
 * All timeline events flow through moderation queue before being stored.
 */

export type TimelineEventType =
  | 'name_change'
  | 'operator_change'
  | 'owner_change'
  | 'location_change'
  | 'status_change'
  | 'opening'
  | 'closure'
  | 'reopening'
  | 'renovation'
  | 'expansion'
  | 'acquisition'
  | 'milestone'
  | 'other';

export type EntityType = 'park' | 'ride' | 'company' | 'ride_model';

export type DatePrecision = 'day' | 'month' | 'year';

/**
 * Timeline event stored in database after approval
 */
export interface TimelineEvent {
  id: string;
  entity_id: string;
  entity_type: EntityType;
  event_type: TimelineEventType;
  event_date: string;
  event_date_precision: DatePrecision;
  title: string;
  description?: string;
  
  // Type-specific relational data
  from_value?: string;
  to_value?: string;
  from_entity_id?: string;
  to_entity_id?: string;
  from_location_id?: string;
  to_location_id?: string;
  
  // Metadata
  display_order: number;
  created_by?: string;
  approved_by?: string;
  submission_id?: string;
  
  created_at: string;
  updated_at: string;
}

/**
 * Form data for creating/editing timeline events
 */
export interface TimelineEventFormData {
  event_type: TimelineEventType;
  event_date: Date;
  event_date_precision: DatePrecision;
  title: string;
  description?: string;
  
  // Conditional fields based on event_type
  from_value?: string;
  to_value?: string;
  from_entity_id?: string;
  to_entity_id?: string;
  from_location_id?: string;
  to_location_id?: string;
}

/**
 * Complete submission data for timeline events
 * Includes entity reference and all form data
 */
export interface TimelineSubmissionData extends TimelineEventFormData {
  entity_id: string;
  entity_type: EntityType;
}
