export interface SelfPresenceIdentityInput {
  homeUserId?: string;
  homeOderId?: string;
  actorUserId?: string;
}

/** Collect every user id that represents the local user on a room's signal server. */
export function resolveSelfPresenceUserIds(input: SelfPresenceIdentityInput): ReadonlySet<string> {
  const ids = new Set<string>();

  if (input.homeUserId?.trim()) {
    ids.add(input.homeUserId.trim());
  }

  if (input.homeOderId?.trim()) {
    ids.add(input.homeOderId.trim());
  }

  if (input.actorUserId?.trim()) {
    ids.add(input.actorUserId.trim());
  }

  return ids;
}

export function isSelfPresenceUserId(
  userId: string | undefined,
  selfIds: ReadonlySet<string>
): boolean {
  return !!userId?.trim() && selfIds.has(userId.trim());
}
