export const calendarCategories = [
  {
    name: 'Koncert',
    labelKey: 'concert',
    aliases: ['concert'],
    color: '#DA6C6C',
    textColor: 'text-[#DA6C6C]',
    bgColor: 'bg-[#DA6C6C]',
  },
  {
    name: 'Kiállítás',
    labelKey: 'exhibition',
    aliases: ['exhibition', 'kiallitas'],
    color: '#819A91',
    textColor: 'text-[#819A91]',
    bgColor: 'bg-[#819A91]',
  },
  {
    name: 'Előadás',
    labelKey: 'performance',
    aliases: ['performance', 'eloadas'],
    color: '#748DAE',
    textColor: 'text-[#748DAE]',
    bgColor: 'bg-[#748DAE]',
  },
  {
    name: 'Egyéb',
    labelKey: 'other',
    aliases: ['other', 'egyeb', 'egyéb'],
    color: '#7e7e7e',
    textColor: 'text-[#7e7e7e]',
    bgColor: 'bg-[#7e7e7e]',
  },
];

const normalizeCategory = (value: string) =>
  value
    .normalize('NFD')
    .replace(/[\u0300-\u036f]/g, '')
    .toLowerCase()
    .trim();

export const getCategoryColors = (categoryName: string) => {
  const normalized = categoryName ? normalizeCategory(categoryName) : '';
  const category = calendarCategories.find((cat) => {
    const aliases = [cat.name, cat.labelKey, ...(cat.aliases || [])].map((value) =>
      normalizeCategory(value)
    );
    return aliases.includes(normalized);
  });

  return category
    ? {
        color: category.color,
        textColor: category.textColor,
        bgColor: category.bgColor,
      }
    : {
        color: '#7e7e7e',
        textColor: 'text-[#7e7e7e]',
        bgColor: 'bg-[#7e7e7e]',
      };
};
