import { P, R } from "./formResponse-XdQ90rtR.js";
import { S } from "./schedule-Ncrh5bY6.js";
import { B } from "./booking-PYnOyDBA.js";
import { E } from "./eventTypeRepository-U3cW6vHN.js";
import { T } from "./team-cSXKHM6s.js";
import { U } from "./user-9vti0VBh.js";
import { F } from "./features.repository-X0S5Zedc.js";
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 }
      }
    });
  }
}
export {
  B as PrismaBookingRepository,
  E as PrismaEventTypeRepository,
  F as PrismaFeaturesRepository,
  P as PrismaOOORepository,
  R as PrismaRoutingFormResponseRepository,
  S as PrismaScheduleRepository,
  PrismaSelectedSlotRepository,
  T as PrismaTeamRepository,
  U as PrismaUserRepository
};
