import { ROLE_NAMES } from './roles';

export const CAMPUS_ATTENDANCE_TENANT_WIDE_ROLE_NAMES = Object.freeze([
  ROLE_NAMES.SUPER_ADMIN,
  ROLE_NAMES.SYSTEM_ADMIN,
  ROLE_NAMES.OWNER,
]);

export const CAMPUS_ATTENDANCE_MANAGER_ROLE_NAMES = Object.freeze([
  ...CAMPUS_ATTENDANCE_TENANT_WIDE_ROLE_NAMES,
  ROLE_NAMES.SUPERINTENDENT,
  ROLE_NAMES.DIRECTOR,
  ROLE_NAMES.OFFICE_MANAGER,
]);

export const CAMPUS_ATTENDANCE_DEFAULT_LIMIT = 120;
export const CAMPUS_ATTENDANCE_MAX_LIMIT = 366;

export function normalizeCampusKey(value: unknown): string | null {
  if (typeof value !== 'string' || value.trim().length === 0) {
    return null;
  }

  const normalized = value.trim().toLowerCase().replace(/\s+campus$/u, '');

  return normalized || null;
}
