import { isColorLight } from "../../_utilities/utilities";

export const filterBgColors = (colors, postType) => {
	if (!postType) return colors || [];

	if (postType === "articles") {
		return (
			colors?.filter((color) => {
				// Garder seulement certaines couleurs pour les articles
				const allowedColors = [
					"carhop-green-light",
					"carhop-blue-light",
					"carhop-orange-light",
					"carhop-red-light",
					"carhop-purple-light",
				];
				return allowedColors.includes(color.slug);
			}) || []
		);
	}

	return colors || [];
};

export const filterTextColors = (colors, postType, backgroundColor) => {
	if (!postType) return colors || [];
	if (postType === "page" && !isColorLight(backgroundColor)) {
		// Retourner seulement du blanc pour les pages avec arrière-plan sombre
		return [
			{
				name: "White",
				slug: "white",
				color: "#ffffff",
			},
		];
	}

	return colors || [];
};
