"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const ooo = require("./ooo-peCOvX-J.cjs");
const schedule = require("./schedule-QRkIR3Fc.cjs");
const booking = require("./booking-1p4PTxwz.cjs");
const eventTypeRepository = require("./eventTypeRepository-SolNAp1J.cjs");
const formResponse = require("./formResponse-1uX8yEhp.cjs");
const team = require("./team-K4b1jbEE.cjs");
const user = require("./user-7XDeDEMd.cjs");
const features_repository = require("./features.repository-UzW6TkXH.cjs");
const membership = require("./membership-tqAzHYj6.cjs");
class PrismaSelectedSlotRepository {
  constructor(prismaClient) {
    this.prismaClient = prismaClient;
  }
  async findFirst({ where }) {
    return await this.prismaClient.selectedSlots.findFirst({
      where
    });
  }
  async findReservedByOthers({
    slot,
    eventTypeId,
    uid
  }) {
    return await this.findFirst({
      where: {
        slotUtcStartDate: slot.utcStartIso,
        slotUtcEndDate: slot.utcEndIso,
        eventTypeId,
        uid: { not: uid },
        releaseAt: { gt: /* @__PURE__ */ new Date() }
      }
    });
  }
  async findManyReservedByOthers(slots, eventTypeId, uid) {
    return await this.prismaClient.selectedSlots.findMany({
      where: {
        OR: slots.map((slot) => ({
          slotUtcStartDate: slot.utcStartIso,
          slotUtcEndDate: slot.utcEndIso,
          eventTypeId,
          uid: { not: uid },
          releaseAt: { gt: /* @__PURE__ */ new Date() }
        }))
      },
      select: {
        slotUtcStartDate: true,
        slotUtcEndDate: true
      }
    });
  }
  async findManyUnexpiredSlots({
    userIds,
    currentTimeInUtc
  }) {
    return this.prismaClient.selectedSlots.findMany({
      where: {
        userId: { in: userIds },
        releaseAt: { gt: currentTimeInUtc }
      },
      select: {
        id: true,
        slotUtcStartDate: true,
        slotUtcEndDate: true,
        userId: true,
        isSeat: true,
        eventTypeId: true,
        uid: true
      }
    });
  }
  async deleteManyExpiredSlots({
    eventTypeId,
    currentTimeInUtc
  }) {
    return this.prismaClient.selectedSlots.deleteMany({
      where: {
        eventTypeId: { equals: eventTypeId },
        releaseAt: { lt: currentTimeInUtc }
      }
    });
  }
}
exports.PrismaAttributeRepository = ooo.PrismaAttributeRepository;
exports.PrismaHostRepository = ooo.HostRepository;
exports.PrismaOOORepository = ooo.PrismaOOORepository;
exports.PrismaScheduleRepository = schedule.ScheduleRepository;
exports.PrismaBookingRepository = booking.BookingRepository;
exports.PrismaEventTypeRepository = eventTypeRepository.EventTypeRepository;
exports.PrismaRoutingFormResponseRepository = formResponse.RoutingFormResponseRepository;
exports.PrismaTeamRepository = team.TeamRepository;
exports.PrismaUserRepository = user.UserRepository;
exports.PrismaFeaturesRepository = features_repository.FeaturesRepository;
exports.PrismaMembershipRepository = membership.MembershipRepository;
exports.PrismaSelectedSlotRepository = PrismaSelectedSlotRepository;
