export const supportedPlatforms = [
  "official_site",
  "media_article",
  "comparison_review",
  "recommendation_list",
] as const;

export type SamplePlatform = (typeof supportedPlatforms)[number];

export interface ArticleSampleInput {
  title: string;
  body: string;
  image_lines: string;
  platform: SamplePlatform;
  user_instructions: string;
}

export interface ArticleSample {
  filePath: string;
  fileName: string;
  slug: string;
  name: string;
  input: ArticleSampleInput;
  expectedHardFailures: string[];
  expectedWarnings: string[];
}

export interface InvalidArticleSample {
  filePath: string;
  fileName: string;
  reason: string;
}

export interface LoadedArticleSamples {
  valid: ArticleSample[];
  invalid: InvalidArticleSample[];
}

export type SampleStatus = "passed" | "failed" | "skipped";

export type FailureCategory =
  | "preflight_failed"
  | "sample_invalid"
  | "page_flow_failed"
  | "stream_timeout"
  | "stream_failed"
  | "llm_failed"
  | "export_failed"
  | "console_error"
  | "unknown_failed";

export interface ExportValidationResult {
  fileName: "optimized.md" | "optimized.docx" | "qa_report.json";
  status: "passed" | "failed";
  statusCode?: number;
  error?: string;
}

export interface SampleResult {
  file: string;
  name: string;
  slug: string;
  status: SampleStatus;
  duration_ms: number;
  job_id?: string;
  qa_status?: "pass" | "warn" | "fail";
  qa_fail_rules: string[];
  qa_warn_rules: string[];
  expected_hard_failures: string[];
  expected_warnings: string[];
  exports: Record<string, "passed" | "failed">;
  llm_tasks: string[];
  failure_category?: FailureCategory;
  failure_message?: string;
  artifacts: {
    final_screenshot?: string;
    failure_screenshot?: string;
    trace?: string;
  };
}

export interface RunSummary {
  started_at: string;
  finished_at: string;
  mode: "live";
  provider: string;
  model: string;
  base_url: string;
  report_dir: string;
  totals: {
    passed: number;
    failed: number;
    skipped: number;
  };
  samples: SampleResult[];
  invalid_samples: InvalidArticleSample[];
}
