export type RoleKey =
  | 'COMPANY'
  | 'CUSTOMER'
  | 'JOB_SEEKER'
  | 'PHOTOGRAPHER'
  | 'MAKEUP_ARTIST'
  | 'TUTOR'
  | 'DEVELOPER'
  | 'VIDEO_EDITOR'
  | 'UGC_CONTENT_CREATOR'
  | 'GRAPHIC_DESIGNER'
  | 'SOCIAL_MEDIA_MANAGER'
  | 'FITNESS_TRAINER'
  | 'CATERING_SERVICES';

export const ROLE_PREFIXES: Record<RoleKey, string> = {
  PHOTOGRAPHER: 'photographers',
  MAKEUP_ARTIST: 'makeup-artists',
  TUTOR: 'tutors',
  DEVELOPER: 'developers',
  VIDEO_EDITOR: 'video-editors',
  GRAPHIC_DESIGNER: 'graphic-designers',
  SOCIAL_MEDIA_MANAGER: 'social-media-managers',
  FITNESS_TRAINER: 'fitness-trainers',
  CATERING_SERVICES: 'catering-services',
  UGC_CONTENT_CREATOR: 'ugc-content-creators',
  CUSTOMER: 'customers',
  COMPANY: 'companies',
  JOB_SEEKER: 'jobseeker',
};

export const PROFESSIONAL_ROLE_SET = new Set<RoleKey>([
  'PHOTOGRAPHER',
  'MAKEUP_ARTIST',
  'TUTOR',
  'DEVELOPER',
  'VIDEO_EDITOR',
  'UGC_CONTENT_CREATOR',
  'GRAPHIC_DESIGNER',
  'SOCIAL_MEDIA_MANAGER',
  'FITNESS_TRAINER',
  'CATERING_SERVICES',
]);

const ALL_ROLE_KEYS: RoleKey[] = [
  'COMPANY',
  'CUSTOMER',
  'JOB_SEEKER',
  'PHOTOGRAPHER',
  'MAKEUP_ARTIST',
  'TUTOR',
  'DEVELOPER',
  'VIDEO_EDITOR',
  'UGC_CONTENT_CREATOR',
  'GRAPHIC_DESIGNER',
  'SOCIAL_MEDIA_MANAGER',
  'FITNESS_TRAINER',
  'CATERING_SERVICES',
];

export function normalizeRole(value: string): RoleKey {
  const up = String(value || '')
    .trim()
    .toUpperCase()
    .replace(/\s+/g, '_');
  return (ALL_ROLE_KEYS.find((r) => r === up) || 'JOB_SEEKER') as RoleKey;
}

