"""Construit l'agrégat set × couleur prêt pour les visualisations."""

from pathlib import Path

from lib.rebrickable.colors_by_set import (
    aggregate_colors_by_set,
    build_colors_lookup,
    load_parts,
    write_colors_by_set,
)
from lib.rebrickable.color_ignores import load_ignored_part_numbers


PARTS_PATH = Path("data/intermediate/parts_filtered.csv")
COLORS_PATH = Path("data/raw/colors.csv")
PARTS_CATALOG_PATH = Path("data/raw/parts.csv")
DESTINATION_PATH = Path("data/intermediate/colors_by_set.csv")


def main() -> None:
    """Génère colors_by_set.csv depuis parts_filtered.csv."""
    parts = load_parts(PARTS_PATH)
    colors_lookup = build_colors_lookup(COLORS_PATH)
    ignored_parts = load_ignored_part_numbers(PARTS_CATALOG_PATH)
    aggregated = aggregate_colors_by_set(parts, colors_lookup, ignored_parts=ignored_parts)
    write_colors_by_set(DESTINATION_PATH, aggregated)


if __name__ == "__main__":
    main()
