export interface Topic {
  slug: string;
  title: string;
  shortTitle: string;
  description: string;
}

export interface Unit {
  number: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
  slug: string;
  title: string;
  description: string;
  color: "unit-1" | "unit-2" | "unit-3" | "unit-4" | "unit-5" | "unit-6" | "unit-7" | "unit-8";
  topics: Topic[];
}

export const curriculum: Unit[] = [
  {
    number: 1,
    slug: "unit-1-fractions",
    title: "Fractions",
    description: "Add, subtract, multiply, divide fractions and apply to quantities",
    color: "unit-1",
    topics: [
      {
        slug: "add-subtract",
        title: "Add and Subtract Fractions",
        shortTitle: "Add & Subtract",
        description: "Common and uncommon denominators, Butterfly Method",
      },
      {
        slug: "multiply",
        title: "Multiply Fractions",
        shortTitle: "Multiply",
        description: "Multiply numerators and denominators, simplify",
      },
      {
        slug: "divide",
        title: "Divide Fractions",
        shortTitle: "Divide",
        description: "Invert and multiply (reciprocal method)",
      },
      {
        slug: "mixed-operations",
        title: "Mixed Operations (BODMAS)",
        shortTitle: "BODMAS",
        description: "Order of operations with fractions",
      },
      {
        slug: "fraction-of-quantity",
        title: "Fraction of a Quantity",
        shortTitle: "Of a Quantity",
        description: "Calculate a fraction of a given amount",
      },
      {
        slug: "whole-from-fractions",
        title: "Calculate the Whole from Fractions",
        shortTitle: "Find the Whole",
        description: "Find the whole when given a part and its fraction",
      },
    ],
  },
  {
    number: 2,
    slug: "unit-2-decimals",
    title: "Decimals",
    description: "Compare, order, round decimals and express in standard form",
    color: "unit-2",
    topics: [
      {
        slug: "compare-order",
        title: "Compare and Order Decimals",
        shortTitle: "Compare & Order",
        description: "Place value, ascending, descending, greater/less than",
      },
      {
        slug: "approximate",
        title: "Approximate Decimals",
        shortTitle: "Approximation",
        description: "Round to whole numbers, decimal places, significant figures",
      },
      {
        slug: "standard-form",
        title: "Standard Form (Scientific Notation)",
        shortTitle: "Standard Form",
        description: "Express numbers as a × 10^n",
      },
    ],
  },
  {
    number: 3,
    slug: "unit-3-decimal-operations",
    title: "Decimal Operations",
    description: "Convert, add, subtract, multiply and divide decimals",
    color: "unit-3",
    topics: [
      {
        slug: "convert",
        title: "Convert Decimals and Fractions",
        shortTitle: "Convert",
        description: "Decimals to fractions and fractions to decimals",
      },
      {
        slug: "add-subtract",
        title: "Add and Subtract Decimals",
        shortTitle: "Add & Subtract",
        description: "Align decimal points, insert zeros as placeholders",
      },
      {
        slug: "multiply-divide",
        title: "Multiply and Divide Decimals",
        shortTitle: "Multiply & Divide",
        description: "By powers of 10, whole numbers, and decimals",
      },
    ],
  },
  {
    number: 4,
    slug: "unit-4-ratio-proportion",
    title: "Ratio & Proportion",
    description: "Define, simplify, and apply ratios to solve problems",
    color: "unit-4",
    topics: [
      {
        slug: "define-ratio",
        title: "Define a Ratio",
        shortTitle: "Define Ratio",
        description: "Relationship between two or more quantities",
      },
      {
        slug: "fractions-and-ratios",
        title: "Fractions and Ratios",
        shortTitle: "Fractions & Ratios",
        description: "Understand the relationship between fractions and ratios",
      },
      {
        slug: "simplify-ratios",
        title: "Simplify Ratios",
        shortTitle: "Simplify",
        description: "Write ratios in their simplest form",
      },
      {
        slug: "divide-in-ratio",
        title: "Divide a Quantity in a Given Ratio",
        shortTitle: "Divide in Ratio",
        description: "Share amounts using ratios",
      },
      {
        slug: "word-problems",
        title: "Proportional Parts Word Problems",
        shortTitle: "Word Problems",
        description: "Solve real-world problems with ratios",
      },
    ],
  },
  {
    number: 5,
    slug: "unit-5-integers",
    title: "Integers",
    description: "Add, subtract, multiply, divide integers and apply to real-world problems",
    color: "unit-5",
    topics: [
      {
        slug: "order-compare",
        title: "Order and Compare Integers",
        shortTitle: "Order & Compare",
        description: "Place integers on a number line, order them, and compare with < and >",
      },
      {
        slug: "add-subtract",
        title: "Add and Subtract Integers",
        shortTitle: "Add & Subtract",
        description: "Use number lines and sign rules to add and subtract positive and negative numbers",
      },
      {
        slug: "multiply-divide",
        title: "Multiply and Divide Integers",
        shortTitle: "Multiply & Divide",
        description: "Sign rules for multiplication and division with real-world thermometer problems",
      },
      {
        slug: "negative-fractions",
        title: "Negative Fractions",
        shortTitle: "Negative Fractions",
        description: "Apply the sign rules to add, subtract, multiply and divide fractions with negative signs",
      },
    ],
  },
  {
    number: 6,
    slug: "unit-6-number-system",
    title: "Number System",
    description: "Explore how numbers can be written in different bases, beyond the everyday denary system",
    color: "unit-6",
    topics: [
      {
        slug: "place-value",
        title: "Denary Place Value (Base 10)",
        shortTitle: "Place Value",
        description: "Powers of 10 and writing numbers in expanded form",
      },
      {
        slug: "binary",
        title: "Binary Numbers",
        shortTitle: "Binary",
        description: "Place value in base 2 and converting binary numbers to denary (decimal)",
      },
      {
        slug: "quaternary",
        title: "Quaternary Numbers",
        shortTitle: "Quaternary",
        description: "Place value in base 4 and converting between quaternary and denary (decimal)",
      },
    ],
  },
  {
    number: 7,
    slug: "unit-7-coordinates",
    title: "Coordinates",
    description: "Plot points and read coordinates on the Cartesian plane",
    color: "unit-7",
    topics: [
      {
        slug: "plot-points",
        title: "Plot Points on the Cartesian Plane",
        shortTitle: "Plot Points",
        description: "Use x and y coordinates to place points and reveal hidden shapes",
      },
      {
        slug: "read-coordinates",
        title: "State Coordinates of Points",
        shortTitle: "Read Coordinates",
        description: "Read off the (x, y) coordinates of points in all four quadrants",
      },
    ],
  },
  {
    number: 8,
    slug: "unit-8-number-properties",
    title: "Number Properties",
    description: "Identity and inverse, the laws of arithmetic, and powers of numbers",
    color: "unit-8",
    topics: [
      {
        slug: "identity-inverse",
        title: "Identity and Inverse",
        shortTitle: "Identity & Inverse",
        description: "Identity for addition and multiplication, inverses, and the zero facts",
      },
      {
        slug: "number-laws",
        title: "Commutative, Associative and Distributive Laws",
        shortTitle: "Number Laws",
        description: "Which operations can be swapped, regrouped, and expanded",
      },
      {
        slug: "exponents",
        title: "Powers and Exponents",
        shortTitle: "Exponents",
        description: "Base and power, expanding powers, and the index laws",
      },
    ],
  },
];

export function getUnit(slug: string): Unit | undefined {
  return curriculum.find((u) => u.slug === slug);
}

export function getTopic(unitSlug: string, topicSlug: string): Topic | undefined {
  const unit = getUnit(unitSlug);
  return unit?.topics.find((t) => t.slug === topicSlug);
}

export function getUnitColor(unitNumber: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8): string {
  const colors = {
    1: "unit-1",
    2: "unit-2",
    3: "unit-3",
    4: "unit-4",
    5: "unit-5",
    6: "unit-6",
    7: "unit-7",
    8: "unit-8",
  };
  return colors[unitNumber];
}
