export const emptyUserIdentityFilter = Object.freeze({
  displayUserId: "",
  userId: "",
  username: ""
});

export function normalizeUserIdentityFilter(value = {}) {
  return {
    displayUserId: String(value.displayUserId ?? "").trim(),
    userId: String(value.userId ?? "").trim(),
    username: String(value.username ?? "").trim()
  };
}

export function isUserIdentityFilterEmpty(value = {}) {
  const normalized = normalizeUserIdentityFilter(value);
  return !normalized.displayUserId && !normalized.userId && !normalized.username;
}

export function userIdentityFilterParams(value = {}, names = {}) {
  const normalized = normalizeUserIdentityFilter(value);
  const displayUserIdKey = names.displayUserId || "display_user_id";
  const userIdKey = names.userId || "user_id";
  const usernameKey = names.username || "username";
  return {
    [displayUserIdKey]: normalized.displayUserId,
    [userIdKey]: normalized.userId,
    [usernameKey]: normalized.username
  };
}
