// KAR-787 / R3: detect "orphan" users — app accounts with no linked consultant
// (Mitarbeiter) record. The 1:1 person↔login model (KAR-769) wants every login
// tied to an employee; an orphan signals a data-hygiene gap that an admin
// should resolve (link or remove).
//
// Linkage is via auth id: a consultant carries `auth_user_id`, a user_profile
// carries the same `auth_user_id`. A user is an orphan when no consultant
// carries their auth id (or they have none).

export function isOrphanUser(
  authUserId: string | null | undefined,
  linkedConsultantAuthIds: ReadonlySet<string>,
): boolean {
  if (!authUserId) return true
  return !linkedConsultantAuthIds.has(authUserId)
}
