import type { QuestionType } from "@/types";
import type { LucideIcon } from "lucide-react";
import {
  List,
  CheckSquare,
  Star,
  LineChart,
  Pencil,
  Grid3x3,
  FileUp,
  ChevronDown,
  Calendar,
} from "lucide-react";

export interface QuestionTypeConfig {
  type: QuestionType;
  label: string;
  icon: LucideIcon;
  defaultTitle: string;
  defaultOptions: Record<string, unknown>;
}

export const QUESTION_TYPES: QuestionTypeConfig[] = [
  {
    type: "multiple_choice",
    label: "Multiple Choice",
    icon: List,
    defaultTitle: "Which of these best describes you?",
    defaultOptions: { choices: ["Option A", "Option B", "Option C"] },
  },
  {
    type: "checkbox",
    label: "Checkboxes",
    icon: CheckSquare,
    defaultTitle: "Which of these apply to you? (Select all that apply)",
    defaultOptions: { choices: ["Option A", "Option B", "Option C"] },
  },
  {
    type: "rating",
    label: "Rating Scale",
    icon: Star,
    defaultTitle: "How would you rate our service?",
    defaultOptions: { minRating: 1, maxRating: 5 },
  },
  {
    type: "nps",
    label: "NPS Score",
    icon: LineChart,
    defaultTitle: "How likely are you to recommend us?",
    defaultOptions: { minRating: 0, maxRating: 10 },
  },
  {
    type: "open_text",
    label: "Open Text",
    icon: Pencil,
    defaultTitle: "What could we do better?",
    defaultOptions: { placeholder: "Type your answer here…" },
  },
  {
    type: "matrix",
    label: "Matrix / Likert",
    icon: Grid3x3,
    defaultTitle: "Rate the following statements",
    defaultOptions: {
      rows: ["Statement 1", "Statement 2"],
      columns: ["Strongly disagree", "Neutral", "Strongly agree"],
    },
  },
  {
    type: "file_upload",
    label: "File Upload",
    icon: FileUp,
    defaultTitle: "Upload a supporting file",
    defaultOptions: {},
  },
  {
    type: "dropdown",
    label: "Dropdown",
    icon: ChevronDown,
    defaultTitle: "Select your country",
    defaultOptions: {
      choices: ["Option A", "Option B", "Option C"],
      allowMultiple: false,
    },
  },
  {
    type: "date_time",
    label: "Date / Time",
    icon: Calendar,
    defaultTitle: "When did this happen?",
    defaultOptions: {},
  },
];

export function getQuestionTypeConfig(type: QuestionType) {
  return QUESTION_TYPES.find((q) => q.type === type);
}

export function getQuestionTypeLabel(type: QuestionType): string {
  return getQuestionTypeConfig(type)?.label ?? type;
}
