// Deterministic option-name -> color, shared by every select/multi-select field
// (D-07: no stored color column — colour is derived from the value's hash).
// 7-color pastel palette, bg-*-100/text-*-900 pairs for AA contrast on white.
export const OPTION_COLORS = [
  "bg-blue-100 text-blue-900",
  "bg-green-100 text-green-900",
  "bg-purple-100 text-purple-900",
  "bg-pink-100 text-pink-900",
  "bg-amber-100 text-amber-900",
  "bg-teal-100 text-teal-900",
  "bg-orange-100 text-orange-900",
];

export function getOptionColor(value: string): string {
  let hash = 0;
  for (let i = 0; i < value.length; i++) {
    hash = (hash << 5) - hash + value.charCodeAt(i);
    hash |= 0; // 32-bit int
  }
  return OPTION_COLORS[Math.abs(hash) % OPTION_COLORS.length];
}
