function getAuditActorFromContext(context) {
  const apiToken = context.apiToken;
  if (apiToken) {
    return {
      type: "api_token",
      id: apiToken.tokenId,
      displayName: apiToken.serviceAccountName || apiToken.tokenName,
      email: null,
      role: apiToken.serviceAccountName ? "service-account" : "api-token"
    };
  }
  const adminUser = context.adminUser;
  if (adminUser) {
    return {
      type: "admin",
      id: adminUser.id,
      displayName: adminUser.username,
      email: adminUser.email,
      role: adminUser.role
    };
  }
  const user = context.user;
  if (user) {
    return {
      type: "user",
      id: user.id,
      displayName: user.username,
      email: user.email,
      role: user.role
    };
  }
  return {
    type: "system",
    id: null,
    displayName: "anonymous",
    email: null,
    role: null
  };
}
function getAuditActorFromEvent(event) {
  return getAuditActorFromContext(event.context);
}

export { getAuditActorFromContext as a, getAuditActorFromEvent as g };
//# sourceMappingURL=audit-log-actor.mjs.map
