export const VALID_EVENT_TYPES = [
  'meeting',
  'blocked',
  'appointment',
  'public',
  'personal',
  'closed'
];

export const VALID_VISIBILITY_TYPES = [
  'public',
  'private',
  'shared',
  'blocked'
];

export const VALID_EVENT_STATUSES = [
  'pending',
  'confirmed',
  'cancelled',
  'blocked',
  'completed'
];

export const EVENT_TYPE_LABELS = {
  meeting: 'Meeting',
  blocked: 'Blocked',
  appointment: 'Appointment',
  public: 'Public Event',
  personal: 'Personal Event',
  closed: 'Closed'
};

/**
 * Validates and normalizes event types.
 * Falls back to 'meeting' if the type is invalid.
 */
export const validateEventType = (type) => {
  if (!type) return 'meeting';
  
  const normalized = type.toLowerCase();
  
  if (VALID_EVENT_TYPES.includes(normalized)) {
    return normalized;
  }
  
  // Fallback logic for legacy types mapping to new types if needed, 
  // otherwise default to 'meeting'
  if (normalized === 'maintenance' || normalized === 'inspection') return 'meeting';
  if (normalized === 'meeting_request') return 'appointment';
  
  return 'meeting';
};

/**
 * Validates visibility types.
 * Falls back to 'private' if invalid.
 */
export const validateVisibilityType = (type) => {
  if (!type) return 'private';
  
  const normalized = type.toLowerCase();
  
  if (VALID_VISIBILITY_TYPES.includes(normalized)) {
    return normalized;
  }
  
  return 'private';
};

/**
 * Validates event status.
 * Falls back to 'pending' if invalid.
 */
export const validateEventStatus = (status) => {
  if (!status) return 'pending';
  
  const normalized = status.toLowerCase();
  
  if (VALID_EVENT_STATUSES.includes(normalized)) {
    return normalized;
  }
  
  return 'pending';
};