"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const index = require("./email-manager-W3dV0VZ2.cjs");
const verifyEmail = require("./verifyEmail-jal2sPg5.cjs");
const crypto = require("crypto");
const index$1 = require("./i18n-HHdcQbuJ.cjs");
const server = require("@trpc/server");
const verifyEmailCodeHandler = async ({ ctx, input }) => {
  const { code, email, teamId } = input;
  const { id } = ctx.user;
  if (!code || !email)
    throw new server.TRPCError({ code: "BAD_REQUEST" });
  const secret = crypto.createHash("md5").update(email + process.env.CALENDSO_ENCRYPTION_KEY).digest("hex");
  const isValidToken = verifyEmail.totpRawCheck(code, secret, { step: 900 });
  if (!isValidToken)
    throw new server.TRPCError({ code: "BAD_REQUEST", message: "invalid_code" });
  await index$1.prisma.verifiedEmail.create({
    data: {
      email,
      userId: id,
      teamId
    }
  });
  return isValidToken;
};
exports.AttendeeCancelledEmail = index.AttendeeCancelledEmail;
exports.AttendeeDeclinedEmail = index.AttendeeDeclinedEmail;
exports.AttendeeRequestEmail = index.AttendeeRequestEmail;
exports.AttendeeRescheduledEmail = index.AttendeeRescheduledEmail;
exports.AttendeeScheduledEmail = index.AttendeeScheduledEmail;
exports.AttendeeUpdatedEmail = index.AttendeeUpdatedEmail;
exports.AttendeeVerifyEmail = index.AttendeeVerifyEmail;
exports.OrganizerCancelledEmail = index.OrganizerCancelledEmail;
exports.OrganizerReassignedEmail = index.OrganizerReassignedEmail;
exports.OrganizerRequestEmail = index.OrganizerRequestEmail;
exports.OrganizerRescheduledEmail = index.OrganizerRescheduledEmail;
exports.OrganizerScheduledEmail = index.OrganizerScheduledEmail;
exports.sendEmailVerificationByCode = verifyEmail.sendEmailVerificationByCode;
exports.sendSignupToOrganizationEmail = verifyEmail.sendSignupToOrganizationEmail;
exports.verifyEmailCodeHandler = verifyEmailCodeHandler;
