"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const index = require("./index-QSf6WJj0.cjs");
const common = require("./common-taGcBhj6.cjs");
const markAllGuestNoshowInBooking = async ({
  bookingId,
  hostsThatJoinedTheCall
}) => {
  try {
    const hostsThatJoinedTheCallEmails = hostsThatJoinedTheCall.map((h) => h.email);
    await index.prisma.attendee.updateMany({
      where: {
        bookingId,
        email: { notIn: hostsThatJoinedTheCallEmails }
      },
      data: { noShow: true }
    });
  } catch (err) {
    common.log.error("Error marking guests as no show in booking", err);
  }
};
async function triggerGuestNoShow(payload) {
  const result = await common.prepareNoShowTrigger(payload);
  if (!result)
    return;
  const {
    webhook,
    booking,
    hostsThatJoinedTheCall,
    didGuestJoinTheCall,
    originalRescheduledBooking,
    participants
  } = result;
  const maxStartTime = common.calculateMaxStartTime(booking.startTime, webhook.time, webhook.timeUnit);
  if (!didGuestJoinTheCall) {
    await common.sendWebhookPayload(
      webhook,
      index.WebhookTriggerEvents.AFTER_GUESTS_CAL_VIDEO_NO_SHOW,
      booking,
      maxStartTime,
      participants,
      originalRescheduledBooking
    );
    await markAllGuestNoshowInBooking({ bookingId: booking.id, hostsThatJoinedTheCall });
  }
}
exports.triggerGuestNoShow = triggerGuestNoShow;
