"use strict";
const index = require("./i18n-Bs8xJzoY.cjs");
const getOrgMemberOrTeamWhere = (memberId, teamId) => {
  const conditions = [];
  if (memberId) {
    conditions.push({
      AND: [
        {
          members: {
            some: {
              userId: memberId,
              accepted: true
            }
          }
        },
        {
          isOrganization: true
        }
      ]
    });
  }
  if (teamId) {
    conditions.push({
      AND: [
        {
          children: {
            some: {
              id: teamId
            }
          }
        },
        {
          isOrganization: true
        }
      ]
    });
  }
  return {
    OR: conditions
  };
};
async function getOrgIdFromMemberOrTeamId(args) {
  const orgId = await index.prisma.team.findFirst({
    where: getOrgMemberOrTeamWhere(args.memberId, args.teamId),
    select: {
      id: true
    }
  });
  return orgId?.id;
}
exports.getOrgIdFromMemberOrTeamId = getOrgIdFromMemberOrTeamId;
