export interface Issue {
  id: string;
  type: 'bug' | 'feature' | 'enhancement' | 'documentation' | 'question';
  title: string;
  description: string;
  status: 'open' | 'in-progress' | 'resolved' | 'closed' | 'wont-fix';
  priority: 'critical' | 'high' | 'medium' | 'low';
  createdAt: string;
  createdBy: string;
  updatedAt: string;
  assignedTo?: string;
  labels: string[];
  affectedModules: string[];
  relatedIssues: string[];
  resolution?: string;
  closedAt?: string;
  attachments: Attachment[];
  comments: Comment[];
  metadata?: Record<string, any>;
}

export interface Comment {
  id: string;
  issueId: string;
  author: string;
  content: string;
  createdAt: string;
  editedAt?: string;
  type: 'comment' | 'status-change' | 'assignment' | 'resolution';
}

export interface Attachment {
  id: string;
  filename: string;
  path: string;
  size: number;
  mimeType: string;
  uploadedAt: string;
  uploadedBy: string;
}

export interface IssueFilter {
  type?: Issue['type'][];
  status?: Issue['status'][];
  priority?: Issue['priority'][];
  assignedTo?: string;
  createdBy?: string;
  labels?: string[];
  affectedModules?: string[];
  dateRange?: {
    start: string;
    end: string;
  };
  searchQuery?: string;
}

export interface IssueStats {
  total: number;
  byType: Record<Issue['type'], number>;
  byStatus: Record<Issue['status'], number>;
  byPriority: Record<Issue['priority'], number>;
  averageResolutionTime: number;
  oldestOpenIssue?: Issue;
  mostActiveModule?: string;
  trends: {
    period: 'daily' | 'weekly' | 'monthly';
    opened: number[];
    closed: number[];
  };
}

export interface IssueTemplate {
  type: Issue['type'];
  name: string;
  description: string;
  sections: TemplateSection[];
  defaultLabels: string[];
  defaultPriority: Issue['priority'];
}

export interface TemplateSection {
  title: string;
  prompt: string;
  required: boolean;
  type: 'text' | 'multiline' | 'checklist' | 'selection';
  options?: string[];
}

export interface Milestone {
  id: string;
  title: string;
  description: string;
  dueDate: string;
  status: 'active' | 'completed' | 'overdue';
  issues: string[];
  progress: {
    total: number;
    completed: number;
    percentage: number;
  };
}

export interface IssueWorkflow {
  fromStatus: Issue['status'];
  toStatus: Issue['status'];
  requiresComment: boolean;
  requiresAssignee: boolean;
  autoActions: WorkflowAction[];
}

export interface WorkflowAction {
  type: 'notify' | 'label' | 'assign' | 'close-related';
  config: Record<string, any>;
}