export const STAGES = ["new", "contacted", "product_selected", "checkout", "payment_info", "purchased", "lost"] as const;
export type Stage = (typeof STAGES)[number];

// Urutan funnel. "lost" di luar urutan.
export const RANK: Record<Stage, number> = {
  new: 0, contacted: 1, product_selected: 2, checkout: 3, payment_info: 4, purchased: 5, lost: -1,
};

// Pemetaan tahap chat -> event Meta (sudah disepakati final)
export const STAGE_EVENT: Partial<Record<Stage, string>> = {
  contacted: "Contact",
  product_selected: "AddToCart",
  checkout: "InitiateCheckout",
  payment_info: "AddPaymentInfo",
  purchased: "Purchase",
};

export const STAGE_LABEL: Record<Stage, string> = {
  new: "Baru",
  contacted: "Sudah chat",
  product_selected: "Pilih produk",
  checkout: "Kirim data order",
  payment_info: "Minta rekening / bayar",
  purchased: "Closing",
  lost: "Lost",
};

export const isStage = (v: unknown): v is Stage =>
  typeof v === "string" && (STAGES as readonly string[]).includes(v);
