// lib/comparateur/types.ts

export type Profil = "C5" | "C4" | "C3" | "unknown";

export type TypeEntreprise =
  | "tpe-artisan"
  | "pme"
  | "eti-grand-compte"
  | "copropriete-syndic";

export type FournisseurId =
  | "edf"
  | "engie"
  | "totalenergies"
  | "alpiq"
  | "plum"
  | "ekwateur"
  | "mint"
  | "eni";

export type TypeContrat = "fixe" | "indexe" | "trv" | "inconnu";

export type ContratActuel = {
  fournisseurId: FournisseurId;
  prixKwhHtva: number;
  typeContrat: TypeContrat;
};

export type CalculatorInput = {
  profil: Profil;
  typeEntreprise: TypeEntreprise;
  consommationMwh: number;
  codePostal?: string;
  contratActuel?: ContratActuel;
};

export type ResolvedProfil = "C5" | "C4" | "C3";

export type FournisseurRanked = {
  id: FournisseurId;
  score: number;
  pros: string[];
  cons: string[];
  estimatedAnnualPrice: number;
};

export type RecommendedContractType = "fixe" | "indexe" | "hybride" | "sur-mesure";

export type ComparisonResult = {
  inferredProfil: ResolvedProfil;
  budgetEstimate: { min: number; max: number };
  savingsRange: { min: number; max: number };
  rankedFournisseurs: FournisseurRanked[];
  recommendation: {
    typeContrat: RecommendedContractType;
    rationale: string;
  };
  marketContext: {
    spotEpexAvg: number;
    turpeApprox: number;
    taxesApprox: number;
  };
};

export type MarketTariff = {
  min: number;
  max: number;
  avg: number;
};

// Wizard state
export type WizardStep = 1 | 2 | 3 | 4;

export type WizardState = {
  step: WizardStep;
  input: Partial<CalculatorInput>;
  result?: ComparisonResult;
};

export type WizardAction =
  | { type: "SET_PROFIL"; profil: Profil }
  | { type: "SET_TYPE_ENTREPRISE"; typeEntreprise: TypeEntreprise }
  | { type: "SET_CONSOMMATION"; mwh: number }
  | { type: "SET_CODE_POSTAL"; codePostal: string }
  | { type: "SET_CONTRAT_ACTUEL"; contrat: ContratActuel | undefined }
  | { type: "GO_TO_STEP"; step: WizardStep }
  | { type: "SET_RESULT"; result: ComparisonResult }
  | { type: "RESET" };
