"""Calcule l'évolution annuelle des palettes de couleurs."""

from pathlib import Path

from lib.rebrickable.colors_timeline import (
    build_year_color_matrix,
    compute_yearly_stats,
    load_colors_by_set,
    write_year_color_matrix,
    write_yearly_stats,
)


COLORS_BY_SET_PATH = Path("data/intermediate/colors_by_set.csv")
TIMELINE_PATH = Path("data/intermediate/colors_timeline.csv")
MATRIX_PATH = Path("data/intermediate/colors_year_color_matrix.csv")


def main() -> None:
    """Construit les agrégats annuels et la matrice année × couleur."""
    colors_by_set = load_colors_by_set(COLORS_BY_SET_PATH)
    timeline = compute_yearly_stats(colors_by_set)
    matrix = build_year_color_matrix(colors_by_set)
    write_yearly_stats(TIMELINE_PATH, timeline)
    write_year_color_matrix(MATRIX_PATH, matrix)


if __name__ == "__main__":
    main()
