import { H as HttpError } from "./http-error-RJXCPZV2.js";
import { U as UserRepository, p as prisma } from "./user--mpkKOwW.js";
const throwIfNotHaveAdminAccessToTeam = async ({
  teamId,
  userId
}) => {
  if (!teamId) {
    return;
  }
  const userRepo = new UserRepository(prisma);
  const userAdminTeams = await userRepo.getUserAdminTeams({ userId });
  const teamsUserHasAdminAccessFor = userAdminTeams?.teams?.map(({ team }) => team.id) ?? [];
  const hasAdminAccessToTeam = teamsUserHasAdminAccessFor.some((id) => id === teamId);
  if (!hasAdminAccessToTeam) {
    throw new HttpError({ statusCode: 401, message: "You must be an admin of the team to do this" });
  }
};
export {
  throwIfNotHaveAdminAccessToTeam as t
};
