function hexToRgb(hex: string): { r: number; g: number; b: number } {
	const bigint = parseInt(hex.slice(1), 16);
	return {
		b: bigint & 255,
		g: (bigint >> 8) & 255,
		r: (bigint >> 16) & 255,
	};
}

export function colorIsDarkSimple(color: string) {
	if (color === "#FFFFFF") return false;
	const { r, g, b } = hexToRgb(color);
	return r * 0.299 + g * 0.587 + b * 0.114 <= 186;
}

export function isColorDark(hex: string, cutoff = 186) {
	if (hex === "#FFFFFF") return false;
	const { r, g, b } = hexToRgb(hex);
	return r * 0.299 + g * 0.587 + b * 0.114 <= cutoff;
}
