@wix/bookings 1.0.1782 → 1.0.1784

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/build/cjs/context-booking-checkout.d.ts +32 -0
  2. package/build/cjs/context-booking-checkout.js +2002 -1762
  3. package/build/cjs/context-booking-checkout.js.map +1 -1
  4. package/build/cjs/context-my-booking.d.ts +2832 -0
  5. package/build/cjs/context-my-booking.js +592 -0
  6. package/build/cjs/context-my-booking.js.map +1 -0
  7. package/build/cjs/context-my-bookings.d.ts +2862 -0
  8. package/build/cjs/context-my-bookings.js +12885 -0
  9. package/build/cjs/context-my-bookings.js.map +1 -0
  10. package/build/cjs/context-service.d.ts +18 -24
  11. package/build/cjs/context-service.js +403 -396
  12. package/build/cjs/context-service.js.map +1 -1
  13. package/build/cjs/context-time-slots.d.ts +24 -7
  14. package/build/cjs/context-time-slots.js +82 -81
  15. package/build/cjs/context-time-slots.js.map +1 -1
  16. package/build/es/context-booking-checkout.d.mts +32 -0
  17. package/build/es/context-booking-checkout.mjs +2002 -1762
  18. package/build/es/context-booking-checkout.mjs.map +1 -1
  19. package/build/es/context-my-booking.d.mts +2832 -0
  20. package/build/es/context-my-booking.mjs +562 -0
  21. package/build/es/context-my-booking.mjs.map +1 -0
  22. package/build/es/context-my-bookings.d.mts +2862 -0
  23. package/build/es/context-my-bookings.mjs +12844 -0
  24. package/build/es/context-my-bookings.mjs.map +1 -0
  25. package/build/es/context-service.d.mts +18 -24
  26. package/build/es/context-service.mjs +403 -396
  27. package/build/es/context-service.mjs.map +1 -1
  28. package/build/es/context-time-slots.d.mts +24 -7
  29. package/build/es/context-time-slots.mjs +82 -81
  30. package/build/es/context-time-slots.mjs.map +1 -1
  31. package/build/internal/cjs/context-booking-checkout.d.ts +32 -0
  32. package/build/internal/cjs/context-my-booking.d.ts +2832 -0
  33. package/build/internal/cjs/context-my-bookings.d.ts +2862 -0
  34. package/build/internal/cjs/context-service.d.ts +18 -24
  35. package/build/internal/cjs/context-time-slots.d.ts +24 -7
  36. package/build/internal/es/context-booking-checkout.d.mts +32 -0
  37. package/build/internal/es/context-my-booking.d.mts +2832 -0
  38. package/build/internal/es/context-my-bookings.d.mts +2862 -0
  39. package/build/internal/es/context-service.d.mts +18 -24
  40. package/build/internal/es/context-time-slots.d.mts +24 -7
  41. package/context/my-booking/package.json +3 -0
  42. package/context/my-bookings/package.json +3 -0
  43. package/context-runtime/context-booking-checkout/runtime.d.ts +32 -0
  44. package/context-runtime/context-booking-checkout/runtime.js +3 -3
  45. package/context-runtime/context-my-booking/runtime.d.ts +2832 -0
  46. package/context-runtime/context-my-booking/runtime.js +2 -0
  47. package/context-runtime/context-my-bookings/runtime.d.ts +2862 -0
  48. package/context-runtime/context-my-bookings/runtime.js +11 -0
  49. package/context-runtime/context-service/runtime.d.ts +18 -24
  50. package/context-runtime/context-service/runtime.js +3 -3
  51. package/context-runtime/context-time-slots/runtime.d.ts +24 -7
  52. package/context-runtime/context-time-slots/runtime.js +2 -2
  53. package/package.json +22 -6
@@ -738,10 +738,15 @@ interface TimeSlotsContextValue extends TimeSlotsContextFields {
738
738
  * Starts loading the upcoming time slots, which are the service's time slots from the current
739
739
  * time on, a page at a time. `timeSlots` holds them while no date is selected.
740
740
  *
741
- * Until it's called, `timeSlots` is empty while no date is selected. Calling it again has no
742
- * effect, so every component that shows the upcoming time slots can call it. After the first
743
- * call, the list reloads when the time zone or a filter changes. When the service changes, the
744
- * context starts over and the components inside it mount again, so they call it again.
741
+ * Until it's called, `timeSlots` is empty while no date is selected, and `isLoading` doesn't
742
+ * count the wait for the call. A component renders at least once before its call, so check
743
+ * `upcomingTimeSlotsRequested` too, as in the example, to show a loading state instead of an
744
+ * empty list.
745
+ *
746
+ * Calling it again has no effect, so every component that shows the upcoming time slots can call
747
+ * it. After the first call, the list reloads when the time zone or a filter changes. When the
748
+ * service changes, the context starts over and the components inside it mount again, so they
749
+ * call it again.
745
750
  *
746
751
  * A multi-service appointment, and a course whose last session has ended, have no upcoming
747
752
  * time slots. When the first page fails to load, `errorCode` is `'upcomingSlotsLoadFailed'`.
@@ -754,14 +759,15 @@ interface TimeSlotsContextValue extends TimeSlotsContextFields {
754
759
  * import { useTimeSlotsContext } from '@wix/bookings/context/time-slots';
755
760
  *
756
761
  * function UpcomingSlots() {
757
- * const { timeSlots, isLoading, hasError, loadUpcomingTimeSlots } = useTimeSlotsContext();
762
+ * const { timeSlots, isLoading, hasError, loadUpcomingTimeSlots, upcomingTimeSlotsRequested } =
763
+ * useTimeSlotsContext();
758
764
  *
759
765
  * useEffect(() => {
760
766
  * void loadUpcomingTimeSlots();
761
767
  * }, [loadUpcomingTimeSlots]);
762
768
  *
763
- * if (isLoading) return <p>Loading times...</p>;
764
769
  * if (hasError && !timeSlots.length) return <p>We couldn't load the times. Try again later.</p>;
770
+ * if (!upcomingTimeSlotsRequested || isLoading) return <p>Loading times...</p>;
765
771
  * if (!timeSlots.length) return <p>No upcoming times.</p>;
766
772
  *
767
773
  * return (
@@ -775,7 +781,18 @@ interface TimeSlotsContextValue extends TimeSlotsContextFields {
775
781
  * ```
776
782
  */
777
783
  readonly loadUpcomingTimeSlots: () => Promise<void>;
778
- /** Whether a component called `loadUpcomingTimeSlots()`. */
784
+ /**
785
+ * Whether a component called `loadUpcomingTimeSlots()`.
786
+ *
787
+ * Until a component calls it, `isLoading` is `false` and `timeSlots` is empty, though the list
788
+ * isn't loaded yet. A component that shows the upcoming time slots treats
789
+ * `!upcomingTimeSlotsRequested` as loading, so it doesn't show an empty list before its call.
790
+ * Once any component calls it, it's `true` for every component in the context, so one that
791
+ * mounts later shows the time slots that already loaded.
792
+ *
793
+ * When the context fails to load, it stays `false` and `hasError` is `true`, so check `hasError`
794
+ * first.
795
+ */
779
796
  readonly upcomingTimeSlotsRequested: boolean;
780
797
  /**
781
798
  * Shows the previous page of upcoming time slots in `timeSlots`, from the pages that already
@@ -20,11 +20,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // context-time-slots.ts
21
21
  var context_time_slots_exports = {};
22
22
  __export(context_time_slots_exports, {
23
- TimeSlotsContextProvider: () => ql,
24
- default: () => ql,
25
- injectAccessTokenGetter: () => Zl,
26
- timeSlotsContext: () => Hl,
27
- useTimeSlotsContext: () => Ul
23
+ TimeSlotsContextProvider: () => Jl,
24
+ default: () => Jl,
25
+ injectAccessTokenGetter: () => Ql,
26
+ timeSlotsContext: () => Ul,
27
+ useTimeSlotsContext: () => Wl
28
28
  });
29
29
  module.exports = __toCommonJS(context_time_slots_exports);
30
30
 
@@ -2371,7 +2371,7 @@ function Fc({ nextAvailableSlotsCount: e2, isLoading: t2, hasError: n2, children
2371
2371
  }, navigateToBookingForm: () => {
2372
2372
  }, timeSlotLimitPerDay: null, daysWithMore: /* @__PURE__ */ new Set(), loadingDate: null, loadAllTimeSlotsForDay: async () => {
2373
2373
  } };
2374
- return (0, import_jsx_runtime.jsx)(Hl.Provider, { value: a2, children: r2 });
2374
+ return (0, import_jsx_runtime.jsx)(Ul.Provider, { value: a2, children: r2 });
2375
2375
  }
2376
2376
  function Ic({ nextAvailableSlotsCount: e2, children: t2 }) {
2377
2377
  return (0, import_jsx_runtime.jsx)(Fc, { nextAvailableSlotsCount: e2, isLoading: true, hasError: false, children: t2 });
@@ -2574,61 +2574,62 @@ function ll(e2) {
2574
2574
  function ul(e2, t2) {
2575
2575
  return t2 === void 0 ? false : !e2 || new Date(e2).getTime() <= t2;
2576
2576
  }
2577
- function dl({ serviceId: e2, serviceType: t2, lastSessionEnd: n2, timeZone: r2, now: i2, onlyAvailableSlots: a2, locationId: o2, staffId: s2, timeSlotLimitPerDay: c2, customerChoices: l2, minRemainingCapacity: u2 }) {
2577
+ var dl = 864e5;
2578
+ function fl({ serviceId: e2, serviceType: t2, lastSessionEnd: n2, timeZone: r2, now: i2, onlyAvailableSlots: a2, locationId: o2, staffId: s2, timeSlotLimitPerDay: c2, customerChoices: l2, minRemainingCapacity: u2 }) {
2578
2579
  let d2 = { serviceId: e2, onlyAvailableSlots: a2, locationId: o2 ?? void 0, staffId: s2 ?? void 0, timeZone: r2, fromLocalDate: No(new Date(i2), r2) };
2579
- return Xa(t2) ? { ...d2, serviceType: `CLASS`, minRemainingCapacity: u2 } : Za(t2) ? !n2 || ul(n2, i2) ? void 0 : { ...d2, serviceType: `COURSE`, toLocalDate: No(new Date(n2), r2) } : { ...d2, serviceType: `APPOINTMENT`, toLocalDate: hs().toLocalDate, timeSlotsPerDay: c2 + 1, customerChoices: l2 };
2580
+ return Xa(t2) ? { ...d2, serviceType: `CLASS`, minRemainingCapacity: u2 } : Za(t2) ? !n2 || ul(n2, i2) ? void 0 : { ...d2, serviceType: `COURSE`, toLocalDate: No(new Date(new Date(n2).getTime() + dl), r2) } : { ...d2, serviceType: `APPOINTMENT`, toLocalDate: hs().toLocalDate, timeSlotsPerDay: c2 + 1, customerChoices: l2 };
2580
2581
  }
2581
- function fl({ isAppointment: e2, staffOnSlotCount: t2, hasStaffFilter: n2, hasRequestedGender: r2, hasStaffPricedVariants: i2, staffSelectionStrategy: a2 }) {
2582
+ function pl({ isAppointment: e2, staffOnSlotCount: t2, hasStaffFilter: n2, hasRequestedGender: r2, hasStaffPricedVariants: i2, staffSelectionStrategy: a2 }) {
2582
2583
  return e2 && t2 > 1 && !n2 && !i2 && (a2 !== `CUSTOMER_MUST_CHOOSE` || r2);
2583
2584
  }
2584
- function pl(e2, t2) {
2585
+ function ml(e2, t2) {
2585
2586
  return e2.length ? e2.length === 1 ? { anyResource: false, staffMemberId: e2[0] } : t2 ? { anyResource: true } : null : null;
2586
2587
  }
2587
- function ml(e2, t2, n2) {
2588
+ function hl(e2, t2, n2) {
2588
2589
  return t2 && !t2.anyResource && e2.includes(t2.staffMemberId) ? { isComplete: true, resourceId: t2.staffMemberId } : t2?.anyResource && n2 ? { isComplete: true, resourceId: void 0 } : e2.length <= 1 ? { isComplete: true, resourceId: e2[0] } : { isComplete: n2, resourceId: void 0 };
2589
2590
  }
2590
- var hl = { staff: null, requestedGender: null, locationId: null };
2591
- function gl({ entry: e2, appointmentLike: t2, staffChoiceHidden: n2, staffPriced: r2, staffSelectionStrategy: i2, genderAllowed: a2, staffMemberIds: o2, locationIds: s2 }) {
2592
- if (!e2) return hl;
2591
+ var gl = { staff: null, requestedGender: null, locationId: null };
2592
+ function _l({ entry: e2, appointmentLike: t2, staffChoiceHidden: n2, staffPriced: r2, staffSelectionStrategy: i2, genderAllowed: a2, staffMemberIds: o2, locationIds: s2 }) {
2593
+ if (!e2) return gl;
2593
2594
  let c2 = e2.locationId && s2.includes(e2.locationId) ? e2.locationId : null, l2 = t2 && !n2 ? oo(e2) : null;
2594
- if (!l2) return { ...hl, locationId: c2 };
2595
- if (!l2.anyResource) return o2.includes(l2.staffMemberId) ? { staff: l2, requestedGender: null, locationId: c2 } : { ...hl, locationId: c2 };
2595
+ if (!l2) return { ...gl, locationId: c2 };
2596
+ if (!l2.anyResource) return o2.includes(l2.staffMemberId) ? { staff: l2, requestedGender: null, locationId: c2 } : { ...gl, locationId: c2 };
2596
2597
  let u2 = a2 ? e2.requestedGender ?? null : null;
2597
- return o2.length > 1 && !r2 && (i2 !== `CUSTOMER_MUST_CHOOSE` || u2 !== null) ? { staff: l2, requestedGender: u2, locationId: c2 } : { ...hl, locationId: c2 };
2598
+ return o2.length > 1 && !r2 && (i2 !== `CUSTOMER_MUST_CHOOSE` || u2 !== null) ? { staff: l2, requestedGender: u2, locationId: c2 } : { ...gl, locationId: c2 };
2598
2599
  }
2599
- var _l = [];
2600
- function vl({ sessions: e2, dayQuery: t2, daySlots: n2, staffFilter: r2, appointmentLike: i2, limitPerDay: a2, expandedDates: o2 }) {
2601
- let s2 = Dl(Ol(e2, r2)), c2 = n2 ? Ol(i2 ? Xo(n2) : n2, r2) : _l;
2602
- return { rows: t2 ? c2 : kl(s2, a2, o2), slotIdOf: t2 ? qo : Yo, daysWithMore: El(s2, a2, o2) };
2600
+ var vl = [];
2601
+ function yl({ sessions: e2, dayQuery: t2, daySlots: n2, staffFilter: r2, appointmentLike: i2, limitPerDay: a2, expandedDates: o2 }) {
2602
+ let s2 = Ol(kl(e2, r2)), c2 = n2 ? kl(i2 ? Xo(n2) : n2, r2) : vl;
2603
+ return { rows: t2 ? c2 : Al(s2, a2, o2), slotIdOf: t2 ? qo : Yo, daysWithMore: Dl(s2, a2, o2) };
2603
2604
  }
2604
- function yl({ rows: e2, slotIdOf: t2 }, n2) {
2605
- return [...e2.filter((e3) => t2(e3) === n2)].sort((e3, t3) => Tl(t3) - Tl(e3))[0] ?? null;
2605
+ function bl({ rows: e2, slotIdOf: t2 }, n2) {
2606
+ return [...e2.filter((e3) => t2(e3) === n2)].sort((e3, t3) => El(t3) - El(e3))[0] ?? null;
2606
2607
  }
2607
- function bl(e2, t2, n2, r2) {
2608
- return { slotId: n2(e2), slotStartTime: e2.localStartDate ?? null, slotEndTime: e2.localEndDate ?? null, bookable: e2.bookable ?? false, tooEarlyToBook: e2.bookingPolicyViolations?.tooEarlyToBook ?? false, tooLateToBook: e2.bookingPolicyViolations?.tooLateToBook ?? false, totalCapacity: e2.totalCapacity ?? null, remainingCapacity: e2.remainingCapacity ?? null, bookableCapacity: e2.bookableCapacity ?? null, eventId: e2.eventInfo?.eventId ?? null, eventTitle: e2.eventInfo?.eventTitle ?? null, waitlistCapacity: e2.eventInfo?.waitingList?.remainingCapacity ?? null, locationId: e2.location?._id ?? null, locationName: e2.location?.name || e2.location?.formattedAddress || null, durationMinutes: wl(e2, t2), isAllDay: e2.allDay ?? false, staff: r2 ? [] : xl(e2) };
2608
+ function xl(e2, t2, n2, r2) {
2609
+ return { slotId: n2(e2), slotStartTime: e2.localStartDate ?? null, slotEndTime: e2.localEndDate ?? null, bookable: e2.bookable ?? false, tooEarlyToBook: e2.bookingPolicyViolations?.tooEarlyToBook ?? false, tooLateToBook: e2.bookingPolicyViolations?.tooLateToBook ?? false, totalCapacity: e2.totalCapacity ?? null, remainingCapacity: e2.remainingCapacity ?? null, bookableCapacity: e2.bookableCapacity ?? null, eventId: e2.eventInfo?.eventId ?? null, eventTitle: e2.eventInfo?.eventTitle ?? null, waitlistCapacity: e2.eventInfo?.waitingList?.remainingCapacity ?? null, locationId: e2.location?._id ?? null, locationName: e2.location?.name || e2.location?.formattedAddress || null, durationMinutes: Tl(e2, t2), isAllDay: e2.allDay ?? false, staff: r2 ? [] : Sl(e2) };
2609
2610
  }
2610
- function xl(e2) {
2611
+ function Sl(e2) {
2611
2612
  let t2 = /* @__PURE__ */ new Map();
2612
2613
  for (let n2 of e2.availableResources ?? []) if (n2.resourceTypeId === `1cd44cf8-756f-41c3-bd90-3e2ffcaf1155`) for (let e3 of n2.resources ?? []) e3._id && !t2.has(e3._id) && t2.set(e3._id, e3.name ?? ``);
2613
2614
  return [...t2].map(([e3, t3]) => ({ staffMemberId: e3, name: t3 }));
2614
2615
  }
2615
- function Sl(e2) {
2616
- let t2 = xl(e2);
2616
+ function Cl(e2) {
2617
+ let t2 = Sl(e2);
2617
2618
  if (t2.length) return t2.length === 1 ? t2[0].staffMemberId : null;
2618
2619
  }
2619
- function Cl(e2) {
2620
- return xl(e2).map((e3) => e3.staffMemberId);
2620
+ function wl(e2) {
2621
+ return Sl(e2).map((e3) => e3.staffMemberId);
2621
2622
  }
2622
- function wl(e2, t2) {
2623
+ function Tl(e2, t2) {
2623
2624
  if (!e2.localStartDate || !e2.localEndDate) return null;
2624
2625
  let n2 = e2.allDay ? `UTC` : t2 ?? `UTC`, r2 = Nc(e2.localStartDate, n2), i2 = Nc(e2.localEndDate, n2);
2625
2626
  return !r2 || !i2 || i2 < r2 ? null : Math.round((i2.getTime() - r2.getTime()) / 6e4);
2626
2627
  }
2627
- function Tl(e2) {
2628
+ function El(e2) {
2628
2629
  let t2 = e2.bookableCapacity ?? e2.remainingCapacity;
2629
2630
  return (e2.eventInfo?.waitingList?.remainingCapacity ?? 0) > 0 && (t2 ?? 0) <= 0 ? 1 : e2.bookable ? 2 : 0;
2630
2631
  }
2631
- function El(e2, t2, n2) {
2632
+ function Dl(e2, t2, n2) {
2632
2633
  let r2 = /* @__PURE__ */ new Map();
2633
2634
  for (let t3 of e2) {
2634
2635
  let e3 = (t3.localStartDate ?? ``).slice(0, 10);
@@ -2636,16 +2637,16 @@ function El(e2, t2, n2) {
2636
2637
  }
2637
2638
  return new Set([...r2].filter(([e3, r3]) => r3 > t2 && !n2.has(e3)).map(([e3]) => e3));
2638
2639
  }
2639
- function Dl(e2) {
2640
+ function Ol(e2) {
2640
2641
  return e2.flatMap((e3) => {
2641
2642
  let t2 = e3.availableResources?.find((e4) => e4.resourceTypeId === Wr), n2 = t2?.resources ?? [];
2642
2643
  return n2.length <= 1 ? [e3] : n2.map((n3) => ({ ...e3, availableResources: [{ ...t2, resources: [n3] }] }));
2643
2644
  });
2644
2645
  }
2645
- function Ol(e2, t2) {
2646
+ function kl(e2, t2) {
2646
2647
  return t2 ? e2.map((e3) => ({ ...e3, availableResources: e3.availableResources?.map((e4) => e4.resourceTypeId === `1cd44cf8-756f-41c3-bd90-3e2ffcaf1155` ? { ...e4, resources: e4.resources?.filter((e5) => e5._id === t2) } : e4) })) : e2;
2647
2648
  }
2648
- function kl(e2, t2, n2) {
2649
+ function Al(e2, t2, n2) {
2649
2650
  let r2 = /* @__PURE__ */ new Map();
2650
2651
  return e2.filter((e3) => {
2651
2652
  let i2 = (e3.localStartDate ?? ``).slice(0, 10);
@@ -2654,21 +2655,21 @@ function kl(e2, t2, n2) {
2654
2655
  return r2.set(i2, a2 + 1), a2 < t2;
2655
2656
  });
2656
2657
  }
2657
- async function Al() {
2658
+ async function jl() {
2658
2659
  try {
2659
2660
  return await Ko();
2660
2661
  } catch (e2) {
2661
2662
  return $(e2, { feature: Q.timeSlots, action: `fetch-business-time-zone`, level: `warning` }), { businessTimeZone: null, staffSelectionStrategy: void 0, allowGenderSelection: false };
2662
2663
  }
2663
2664
  }
2664
- function jl(e2) {
2665
- return Xs({ key: zs(), warmupData: e2, fetchData: Al });
2666
- }
2667
2665
  function Ml(e2) {
2666
+ return Xs({ key: zs(), warmupData: e2, fetchData: jl });
2667
+ }
2668
+ function Nl(e2) {
2668
2669
  return (e2.localStartDate ?? ``).slice(0, 10);
2669
2670
  }
2670
- var Nl = [];
2671
- function Pl(e2, t2) {
2671
+ var Pl = [];
2672
+ function Fl(e2, t2) {
2672
2673
  let { serviceId: n2 = ``, serviceType: r2 = `CLASS`, fromLocalDate: i2 = ``, toLocalDate: o2, timeZone: l2, locationId: u2, staffId: d2, onlyAvailableSlots: f2 = false, customerChoices: p2, minRemainingCapacity: m2, timeSlotsPerDay: h2 } = t2 ?? {}, [g2, _2] = (0, import_react.useState)([]), [v2, y2] = (0, import_react.useState)([]), [b2, x2] = (0, import_react.useState)(1), [S2, C2] = (0, import_react.useState)(!!n2), [w2, T2] = (0, import_react.useState)(null), [ee2, E2] = (0, import_react.useState)(null), [D2, te2] = (0, import_react.useState)(/* @__PURE__ */ new Set()), [ne2, O2] = (0, import_react.useState)(null), k2 = (0, import_react.useRef)(null), re2 = (0, import_react.useRef)(null);
2673
2674
  (0, import_react.useEffect)(() => {
2674
2675
  if (_2([]), y2([]), x2(1), E2(null), T2(null), te2(/* @__PURE__ */ new Set()), O2(null), C2(!!n2), !n2) return;
@@ -2710,9 +2711,9 @@ function Pl(e2, t2) {
2710
2711
  try {
2711
2712
  let a3 = await vs({ serviceId: n2, serviceType: r2, date: e3, timeZone: l2, onlyAvailableSlots: f2, locationId: u2, staffId: d2, customerChoices: p2, minRemainingCapacity: m2, fromLocalDate: i2, toLocalDate: o2 });
2712
2713
  if (t3) return;
2713
- let c3 = a3.timeSlots.filter((t4) => Ml(t4) === e3), h3 = Math.max(0, s2.findIndex((t4) => t4.some((t5) => Ml(t5) === e3)));
2714
+ let c3 = a3.timeSlots.filter((t4) => Nl(t4) === e3), h3 = Math.max(0, s2.findIndex((t4) => t4.some((t5) => Nl(t5) === e3)));
2714
2715
  s2 = s2.map((t4, n3) => {
2715
- let r3 = t4.filter((t5) => Ml(t5) !== e3);
2716
+ let r3 = t4.filter((t5) => Nl(t5) !== e3);
2716
2717
  return n3 === h3 ? [...r3, ...c3] : r3;
2717
2718
  }), _2(s2), te2((t4) => /* @__PURE__ */ new Set([...t4, e3]));
2718
2719
  } catch (e4) {
@@ -2727,7 +2728,7 @@ function Pl(e2, t2) {
2727
2728
  t3 = true, k2.current = null, re2.current = null;
2728
2729
  };
2729
2730
  }, [n2, r2, i2, o2, l2, u2, d2, f2, p2, m2, h2, e2]);
2730
- let ie2 = [...g2[b2 - 1] ?? Nl].sort((e3, t3) => (e3.localStartDate ?? ``).localeCompare(t3.localStartDate ?? ``)), A2 = g2[b2], ae2 = A2 ? A2.length > 0 : v2[b2 - 1] != null, j2 = b2 > 1;
2731
+ let ie2 = [...g2[b2 - 1] ?? Pl].sort((e3, t3) => (e3.localStartDate ?? ``).localeCompare(t3.localStartDate ?? ``)), A2 = g2[b2], ae2 = A2 ? A2.length > 0 : v2[b2 - 1] != null, j2 = b2 > 1;
2731
2732
  async function oe2() {
2732
2733
  ae2 && !S2 && await k2.current?.(b2 + 1);
2733
2734
  }
@@ -2739,67 +2740,67 @@ function Pl(e2, t2) {
2739
2740
  }
2740
2741
  return { isLoadingPage: S2, firstPageSettled: g2.length > 0 || w2 !== null, error: w2, timeZone: ee2, sessions: ie2, pageSize: e2, currentPage: b2, hasNextPage: ae2, hasPreviousPage: j2, nextPage: oe2, previousPage: M2, expandedDates: D2, loadingDate: ne2, loadAllSessionsForDay: se2 };
2741
2742
  }
2742
- var Fl = (e2) => e2?.onlineBooking?.enabled === true;
2743
- function Il(e2, t2) {
2743
+ var Il = (e2) => e2?.onlineBooking?.enabled === true;
2744
+ function Ll(e2, t2) {
2744
2745
  return e2 ? e2.anyResource ? t2 ?? `` : e2.staffMemberId : null;
2745
2746
  }
2746
- var Ll = [];
2747
2747
  var Rl = [];
2748
- var zl = cn.map((e2) => ({ id: e2, gender: e2 }));
2749
- var Bl = () => {
2748
+ var zl = [];
2749
+ var Bl = cn.map((e2) => ({ id: e2, gender: e2 }));
2750
+ var Vl = () => {
2750
2751
  };
2751
- var Vl = async () => {
2752
+ var Hl = async () => {
2752
2753
  };
2753
- var Hl = (0, import_react.createContext)(null);
2754
- function Ul() {
2755
- let e2 = (0, import_react.useContext)(Hl);
2754
+ var Ul = (0, import_react.createContext)(null);
2755
+ function Wl() {
2756
+ let e2 = (0, import_react.useContext)(Ul);
2756
2757
  if (!e2) throw Error(`useTimeSlotsContext must be used within TimeSlotsContextProvider`);
2757
2758
  return e2;
2758
2759
  }
2759
- function Wl(e2, t2, n2) {
2760
+ function Gl(e2, t2, n2) {
2760
2761
  e2 ? t2() : n2();
2761
2762
  }
2762
- var Gl = { loginRequired: `rescheduleLoginRequired`, notFound: `rescheduleNotFound`, accessDenied: `rescheduleAccessDenied`, failed: `rescheduleNotFound`, wrongService: `rescheduleNotFound`, notReschedulable: `rescheduleNotReschedulable` };
2763
- function Kl(e2 = 3) {
2763
+ var Kl = { loginRequired: `rescheduleLoginRequired`, notFound: `rescheduleNotFound`, accessDenied: `rescheduleAccessDenied`, failed: `rescheduleNotFound`, wrongService: `rescheduleNotFound`, notReschedulable: `rescheduleNotReschedulable` };
2764
+ function ql(e2 = 3) {
2764
2765
  return Math.min(Math.max(e2, 1), sc);
2765
2766
  }
2766
- function ql(e2) {
2767
+ function Jl(e2) {
2767
2768
  let { isLoading: n2, bookingsSettingsLoading: r2 } = (0, import_service.useServiceContext)();
2768
2769
  kc(Cc.TIME_SLOTS, !n2 && !r2);
2769
- let i2 = Is(), [a2] = (0, import_react.useState)(() => jl(i2));
2770
- return (0, import_jsx_runtime.jsx)(oc, { children: (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: (0, import_jsx_runtime.jsx)(Ic, { nextAvailableSlotsCount: Kl(e2.nextAvailableSlotsCount), children: e2.children }), children: (0, import_jsx_runtime.jsx)(Yl, { ...e2, configurationPromise: a2 }) }) });
2770
+ let i2 = Is(), [a2] = (0, import_react.useState)(() => Ml(i2));
2771
+ return (0, import_jsx_runtime.jsx)(oc, { children: (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: (0, import_jsx_runtime.jsx)(Ic, { nextAvailableSlotsCount: ql(e2.nextAvailableSlotsCount), children: e2.children }), children: (0, import_jsx_runtime.jsx)(Xl, { ...e2, configurationPromise: a2 }) }) });
2771
2772
  }
2772
- function Jl(e2) {
2773
+ function Yl(e2) {
2773
2774
  let [t2, n2] = (0, import_react.useState)({ serviceId: e2, key: 0 });
2774
2775
  return e2 !== t2.serviceId && n2({ serviceId: e2, key: t2.serviceId ? t2.key + 1 : t2.key }), t2.key;
2775
2776
  }
2776
- function Yl({ onlyAvailableSlots: e2 = true, nextAvailableSlotsCount: t2 = 3, loadDaysAvailabilityInitially: n2 = false, timeSlotLimitPerDay: r2 = 100, configurationPromise: i2, children: o2 }) {
2777
- let s2 = nc().isLoading, { searchParams: d2 } = vc(), { reschedule: f2 } = (0, import_service.useServiceContext)(), [m2] = (0, import_react.useState)(() => ({ locationId: d2.get(eo.location), staffId: d2.get(eo.resource), timeZone: (f2 ? void 0 : Pr(d2.get(eo.blob))?.timezone) ?? d2.get(eo.timezone) })), [h2, g2] = (0, import_react.useState)(m2.timeZone), _2 = Kl(t2), [v2, y2] = (0, import_react.useState)(false);
2777
+ function Xl({ onlyAvailableSlots: e2 = true, nextAvailableSlotsCount: t2 = 3, loadDaysAvailabilityInitially: n2 = false, timeSlotLimitPerDay: r2 = 100, configurationPromise: i2, children: o2 }) {
2778
+ let s2 = nc().isLoading, { searchParams: d2 } = vc(), { reschedule: f2 } = (0, import_service.useServiceContext)(), [m2] = (0, import_react.useState)(() => ({ locationId: d2.get(eo.location), staffId: d2.get(eo.resource), timeZone: (f2 ? void 0 : Pr(d2.get(eo.blob))?.timezone) ?? d2.get(eo.timezone) })), [h2, g2] = (0, import_react.useState)(m2.timeZone), _2 = ql(t2), [v2, y2] = (0, import_react.useState)(false);
2778
2779
  (0, import_react.useEffect)(() => y2(true), []);
2779
2780
  let b2 = v2 && !s2;
2780
2781
  ll(b2);
2781
- let x2 = js(i2), S2 = (0, import_react.useSyncExternalStore)(os, as, () => false), { serviceId: C2 } = (0, import_service.useServiceContext)(), w2 = Jl(C2), T2 = Number.isFinite(r2) ? Math.max(1, Math.floor(r2)) : 100;
2782
- return (0, import_jsx_runtime.jsx)(cc, { fallback: (0, import_jsx_runtime.jsx)(Lc, { nextAvailableSlotsCount: _2, children: o2 }), feature: Q.timeSlots, children: (0, import_jsx_runtime.jsx)(Xl, { onlyAvailableSlots: e2, selectedTimeZone: h2, setSelectedTimeZone: g2, enabled: b2, nextAvailableSlotsCount: _2, loadDaysAvailabilityInitially: n2, timeSlotLimitPerDay: T2, landingLocationId: m2.locationId, landingStaffId: m2.staffId, businessTimeZone: x2.businessTimeZone, staffSelectionStrategy: x2.staffSelectionStrategy, allowGenderSelection: x2.allowGenderSelection, requestedGenderRejected: S2, children: o2 }) }, w2);
2782
+ let x2 = js(i2), S2 = (0, import_react.useSyncExternalStore)(os, as, () => false), { serviceId: C2 } = (0, import_service.useServiceContext)(), w2 = Yl(C2), T2 = Number.isFinite(r2) ? Math.max(1, Math.floor(r2)) : 100;
2783
+ return (0, import_jsx_runtime.jsx)(cc, { fallback: (0, import_jsx_runtime.jsx)(Lc, { nextAvailableSlotsCount: _2, children: o2 }), feature: Q.timeSlots, children: (0, import_jsx_runtime.jsx)(Zl, { onlyAvailableSlots: e2, selectedTimeZone: h2, setSelectedTimeZone: g2, enabled: b2, nextAvailableSlotsCount: _2, loadDaysAvailabilityInitially: n2, timeSlotLimitPerDay: T2, landingLocationId: m2.locationId, landingStaffId: m2.staffId, businessTimeZone: x2.businessTimeZone, staffSelectionStrategy: x2.staffSelectionStrategy, allowGenderSelection: x2.allowGenderSelection, requestedGenderRejected: S2, children: o2 }) }, w2);
2783
2784
  }
2784
- function Xl({ onlyAvailableSlots: e2, selectedTimeZone: t2, setSelectedTimeZone: n2, enabled: i2, nextAvailableSlotsCount: l2, loadDaysAvailabilityInitially: d2, timeSlotLimitPerDay: f2, landingLocationId: m2, landingStaffId: h2, businessTimeZone: g2, staffSelectionStrategy: _2, allowGenderSelection: v2, requestedGenderRejected: y2, children: b2 }) {
2785
- let { service: x2, serviceId: S2, serviceType: C2, setSlot: w2, clearSlot: T2, setMultiServiceSlot: ee2, clearMultiServiceSlot: E2, draftRevision: D2, navigateToMultiServiceForm: te2, selection: ne2, selectStaffMember: O2, clearSelection: k2, clearStaffMember: re2, withSelectionParam: ie2, staffMembers: A2, serviceOptionsAndVariants: ae2, isLoading: j2, hasError: oe2, multiServiceAppointmentServices: M2 = Rl, reschedule: se2 } = (0, import_service.useServiceContext)(), N2 = se2 != null, ce2 = N2 && se2.status !== `ready`, le2 = N2 && se2.status === `loading`, ue2 = N2 ? Gl[se2.status] : void 0, de2 = ce2 ? null : se2?.booking ?? null, fe2 = de2 ? se2.validUntil : null, pe2 = ol(x2) && !Fl(x2), P2 = pe2 || ce2 ? null : S2, me2 = vc(), he2 = N2 ? null : me2.searchParams.get(eo.blob), ge2 = (0, import_react.useMemo)(() => io(Pr(he2)), [he2]), F2 = !S2 && !j2 && !oe2 && (ge2.valid || ge2.reason !== `too-few-services`), _e2 = F2 && ge2.valid && M2.some((e3) => !Fl(e3) && ge2.services.some((t3) => t3.serviceId === e3._id)), ve2 = pe2 || _e2, ye2 = F2 && ge2.valid && !_e2 ? ge2.requestKey : null, be2 = (0, import_react.useMemo)(() => ye2 && ge2.valid ? { services: ge2.services, locationId: ge2.locationId, locationType: ge2.locationType } : null, [ye2]), xe2 = !!P2 || be2 !== null, Se2 = P2 || ye2, Ce2 = i2 && !j2 && !oe2 && !xe2 && !le2, we2 = ic(), Te2 = nc(), { navigate: Ee2, resolvePath: De2 } = go(), [Oe2, ke2] = (0, import_react.useState)(null), [Ae2, je2] = (0, import_react.useState)(false), Me2 = (0, import_react.useRef)([]), Ne2 = (0, import_react.useRef)(false), Pe2 = (0, import_react.useCallback)(() => (je2(true), Ne2.current ? Promise.resolve() : new Promise((e3) => {
2785
+ function Zl({ onlyAvailableSlots: e2, selectedTimeZone: t2, setSelectedTimeZone: n2, enabled: i2, nextAvailableSlotsCount: l2, loadDaysAvailabilityInitially: d2, timeSlotLimitPerDay: f2, landingLocationId: m2, landingStaffId: h2, businessTimeZone: g2, staffSelectionStrategy: _2, allowGenderSelection: v2, requestedGenderRejected: y2, children: b2 }) {
2786
+ let { service: x2, serviceId: S2, serviceType: C2, setSlot: w2, clearSlot: T2, setMultiServiceSlot: ee2, clearMultiServiceSlot: E2, draftRevision: D2, navigateToMultiServiceForm: te2, selection: ne2, selectStaffMember: O2, clearSelection: k2, clearStaffMember: re2, withSelectionParam: ie2, staffMembers: A2, serviceOptionsAndVariants: ae2, isLoading: j2, hasError: oe2, multiServiceAppointmentServices: M2 = zl, reschedule: se2 } = (0, import_service.useServiceContext)(), N2 = se2 != null, ce2 = N2 && se2.status !== `ready`, le2 = N2 && se2.status === `loading`, ue2 = N2 ? Kl[se2.status] : void 0, de2 = ce2 ? null : se2?.booking ?? null, fe2 = de2 ? se2.validUntil : null, pe2 = ol(x2) && !Il(x2), P2 = pe2 || ce2 ? null : S2, me2 = vc(), he2 = N2 ? null : me2.searchParams.get(eo.blob), ge2 = (0, import_react.useMemo)(() => io(Pr(he2)), [he2]), F2 = !S2 && !j2 && !oe2 && (ge2.valid || ge2.reason !== `too-few-services`), _e2 = F2 && ge2.valid && M2.some((e3) => !Il(e3) && ge2.services.some((t3) => t3.serviceId === e3._id)), ve2 = pe2 || _e2, ye2 = F2 && ge2.valid && !_e2 ? ge2.requestKey : null, be2 = (0, import_react.useMemo)(() => ye2 && ge2.valid ? { services: ge2.services, locationId: ge2.locationId, locationType: ge2.locationType } : null, [ye2]), xe2 = !!P2 || be2 !== null, Se2 = P2 || ye2, Ce2 = i2 && !j2 && !oe2 && !xe2 && !le2, we2 = ic(), Te2 = nc(), { navigate: Ee2, resolvePath: De2 } = go(), [Oe2, ke2] = (0, import_react.useState)(null), [Ae2, je2] = (0, import_react.useState)(false), Me2 = (0, import_react.useRef)([]), Ne2 = (0, import_react.useRef)(false), Pe2 = (0, import_react.useCallback)(() => (je2(true), Ne2.current ? Promise.resolve() : new Promise((e3) => {
2786
2787
  Me2.current.push(e3);
2787
2788
  })), []), Fe2 = i2 ? Intl.DateTimeFormat().resolvedOptions().timeZone : null, Ie2 = Ja(x2), Le2 = (0, import_react.useRef)(null), Re2 = oo(ne2), ze2 = (0, import_react.useRef)(Re2);
2788
2789
  ze2.current = Re2;
2789
- let Be2 = Re2 && !Re2.anyResource ? Re2.staffMemberId : null, Ve2 = ne2.requestedGender ?? null, I2 = !Xa(C2) && !Za(C2), He2 = I2 && !F2 && bs(ae2), L2 = F2 || I2 && _2 === `CUSTOMER_CANNOT_CHOOSE`, Ue2 = _2 !== void 0, We2 = Go({ allowGenderSelection: v2, staffSelectionStrategy: _2 ?? null }) && I2 && !F2 && !He2, Ge2 = We2 && !y2, Ke2 = (0, import_react.useMemo)(() => P2 ? Pr(he2)?.services.find((e3) => e3.serviceId === P2) ?? null : null, [he2, P2]), qe2 = (A2 ?? []).map((e3) => e3.staffMemberId).join(`,`), Je2 = Ie2.map((e3) => e3.id).join(`,`), Ye2 = (0, import_react.useMemo)(() => gl({ entry: Ke2, appointmentLike: I2, staffChoiceHidden: L2, staffPriced: He2, staffSelectionStrategy: _2, genderAllowed: Ge2, staffMemberIds: qe2.split(`,`), locationIds: Je2.split(`,`) }), [Ke2, I2, L2, He2, _2, Ge2, qe2, Je2]), R2 = Ye2.staff, Xe2 = Ye2.locationId, Ze2 = L2 || R2 !== null, [Qe2, $e2] = (0, import_react.useState)(null), [et2, tt2] = (0, import_react.useState)(m2 !== null || N2), z2 = (0, import_react.useMemo)(() => x2 ? Os(x2) : [], [x2]), nt2 = R2 && !R2.anyResource ? R2.staffMemberId : null, rt2 = (0, import_react.useMemo)(() => {
2790
+ let Be2 = Re2 && !Re2.anyResource ? Re2.staffMemberId : null, Ve2 = ne2.requestedGender ?? null, I2 = !Xa(C2) && !Za(C2), He2 = I2 && !F2 && bs(ae2), L2 = F2 || I2 && _2 === `CUSTOMER_CANNOT_CHOOSE`, Ue2 = _2 !== void 0, We2 = Go({ allowGenderSelection: v2, staffSelectionStrategy: _2 ?? null }) && I2 && !F2 && !He2, Ge2 = We2 && !y2, Ke2 = (0, import_react.useMemo)(() => P2 ? Pr(he2)?.services.find((e3) => e3.serviceId === P2) ?? null : null, [he2, P2]), qe2 = (A2 ?? []).map((e3) => e3.staffMemberId).join(`,`), Je2 = Ie2.map((e3) => e3.id).join(`,`), Ye2 = (0, import_react.useMemo)(() => _l({ entry: Ke2, appointmentLike: I2, staffChoiceHidden: L2, staffPriced: He2, staffSelectionStrategy: _2, genderAllowed: Ge2, staffMemberIds: qe2.split(`,`), locationIds: Je2.split(`,`) }), [Ke2, I2, L2, He2, _2, Ge2, qe2, Je2]), R2 = Ye2.staff, Xe2 = Ye2.locationId, Ze2 = L2 || R2 !== null, [Qe2, $e2] = (0, import_react.useState)(null), [et2, tt2] = (0, import_react.useState)(m2 !== null || N2), z2 = (0, import_react.useMemo)(() => x2 ? Os(x2) : [], [x2]), nt2 = R2 && !R2.anyResource ? R2.staffMemberId : null, rt2 = (0, import_react.useMemo)(() => {
2790
2791
  if (!nt2) return z2;
2791
2792
  let e3 = z2.find((e4) => e4.staffMemberId === nt2);
2792
2793
  return e3 ? [e3] : z2;
2793
2794
  }, [z2, nt2]), it2 = de2?.locationId ?? null, at2 = (0, import_react.useMemo)(() => {
2794
2795
  let e3 = Ds(Ie2, rt2);
2795
2796
  return !it2 || e3.some((e4) => e4.id === it2) ? e3 : Ie2.filter((t3) => t3.id === it2 || e3.some((e4) => e4.id === t3.id));
2796
- }, [x2, rt2, it2]), ot2 = (e3) => !!e3 && at2.some((t3) => t3.id === e3), st2 = Qe2 ?? (et2 ? ot2(it2) ? it2 : m2 : null), ct2 = Ie2.length > 1 && at2.length === 1 ? at2[0].id : null, B2 = Xe2 ?? (ot2(st2) ? st2 : ct2), lt2 = (0, import_react.useMemo)(() => Xe2 ? [] : at2.map((e3) => ({ id: e3.id, name: e3.label })), [at2, Xe2]), ut2 = (0, import_react.useMemo)(() => new Map(z2.map((e3) => [e3.staffMemberId, e3.locationCoverage])), [z2]), dt2 = (0, import_react.useCallback)((e3, t3) => ws([{ staffMemberId: e3, locationCoverage: ut2.get(e3) }], t3).length === 1, [ut2]), ft2 = (0, import_react.useMemo)(() => Ze2 ? [] : (A2 ?? []).filter((e3) => e3.name).map((e3) => ({ id: e3.staffMemberId, name: e3.name ?? ``, gender: null })), [A2, Ze2]), pt2 = (0, import_react.useMemo)(() => B2 ? ft2.filter((e3) => dt2(e3.id, B2)) : ft2, [ft2, B2, dt2]), mt2 = I2 && !Ue2 ? Ll : pt2, ht2 = I2 && !Ue2 ? 0 : ft2.length, gt2 = Ge2 && ht2 > 1, _t2 = (0, import_react.useMemo)(() => gt2 ? [...zl, ...mt2] : mt2, [gt2, mt2]), [vt2, yt2] = (0, import_react.useState)(null), [bt2, xt2] = (0, import_react.useState)(h2 !== null);
2797
+ }, [x2, rt2, it2]), ot2 = (e3) => !!e3 && at2.some((t3) => t3.id === e3), st2 = Qe2 ?? (et2 ? ot2(it2) ? it2 : m2 : null), ct2 = Ie2.length > 1 && at2.length === 1 ? at2[0].id : null, B2 = Xe2 ?? (ot2(st2) ? st2 : ct2), lt2 = (0, import_react.useMemo)(() => Xe2 ? [] : at2.map((e3) => ({ id: e3.id, name: e3.label })), [at2, Xe2]), ut2 = (0, import_react.useMemo)(() => new Map(z2.map((e3) => [e3.staffMemberId, e3.locationCoverage])), [z2]), dt2 = (0, import_react.useCallback)((e3, t3) => ws([{ staffMemberId: e3, locationCoverage: ut2.get(e3) }], t3).length === 1, [ut2]), ft2 = (0, import_react.useMemo)(() => Ze2 ? [] : (A2 ?? []).filter((e3) => e3.name).map((e3) => ({ id: e3.staffMemberId, name: e3.name ?? ``, gender: null })), [A2, Ze2]), pt2 = (0, import_react.useMemo)(() => B2 ? ft2.filter((e3) => dt2(e3.id, B2)) : ft2, [ft2, B2, dt2]), mt2 = I2 && !Ue2 ? Rl : pt2, ht2 = I2 && !Ue2 ? 0 : ft2.length, gt2 = Ge2 && ht2 > 1, _t2 = (0, import_react.useMemo)(() => gt2 ? [...Bl, ...mt2] : mt2, [gt2, mt2]), [vt2, yt2] = (0, import_react.useState)(null), [bt2, xt2] = (0, import_react.useState)(h2 !== null);
2797
2798
  bt2 && h2 !== null && B2 !== null && !dt2(h2, B2) && xt2(false);
2798
2799
  let St2 = vt2 ?? (bt2 ? h2 : null), V2 = R2 ? R2.anyResource ? null : R2.staffMemberId : St2 !== null && pt2.some((e3) => e3.id === St2) ? St2 : null, Ct2 = Re2?.anyResource ? Ve2 : null, [wt2, Tt2] = (0, import_react.useState)(Ct2), [Et2, Dt2] = (0, import_react.useState)(Ct2);
2799
2800
  !y2 && Re2?.anyResource && Ve2 !== Et2 && (Dt2(Ve2), Tt2(Ve2));
2800
2801
  let Ot2 = R2 ? Ye2.requestedGender : We2 && ht2 > 1 && V2 === null ? wt2 : null, kt2 = y2 ? null : Ot2, At2 = (0, import_react.useCallback)((e3) => {
2801
2802
  ze2.current = e3, e3 ? e3.anyResource ? k2(kt2 ?? void 0) : O2(e3.staffMemberId) : re2();
2802
- }, [re2, k2, O2, kt2]), jt2 = (0, import_react.useCallback)((e3) => At2(e3 ? { anyResource: false, staffMemberId: e3 } : { anyResource: true }), [At2]), Mt2 = (de2?.addOnIds ?? []).filter((e3) => x2?.addOnGroups?.some((t3) => t3.addOnIds?.includes(e3))), Nt2 = de2 && Xa(C2) ? de2.participants : null, Pt2 = I2 ? to(ne2) : null, { addOnIds: Ft2, ...It2 } = Pt2 ?? {}, Lt2 = I2 && de2 ? Mt2.length ? { ...It2, addOnIds: Mt2 } : It2 : Pt2, Rt2 = Lt2 ? $o(Lt2) : void 0, zt2 = JSON.stringify(Ot2 ? { ...Rt2, requestedGender: { gender: Ot2 } } : Rt2 ?? null), Bt2 = (0, import_react.useMemo)(() => JSON.parse(zt2), [zt2]), Vt2 = R2?.anyResource === true, Ht2 = (0, import_react.useCallback)((e3) => Vt2 || _2 !== void 0 && fl({ isAppointment: I2, staffOnSlotCount: e3, hasStaffFilter: V2 !== null, hasRequestedGender: kt2 !== null, hasStaffPricedVariants: He2, staffSelectionStrategy: _2 }), [Vt2, I2, _2, V2, kt2, He2]), Ut2 = (0, import_react.useCallback)((e3) => R2 ?? (L2 ? null : e3), [R2, L2]), Wt2 = (0, import_react.useCallback)((e3) => {
2803
+ }, [re2, k2, O2, kt2]), jt2 = (0, import_react.useCallback)((e3) => At2(e3 ? { anyResource: false, staffMemberId: e3 } : { anyResource: true }), [At2]), Mt2 = (de2?.addOnIds ?? []).filter((e3) => x2?.addOnGroups?.some((t3) => t3.addOnIds?.includes(e3))), Nt2 = de2 && Xa(C2) ? de2.participants : null, Pt2 = I2 ? to(ne2) : null, { addOnIds: Ft2, ...It2 } = Pt2 ?? {}, Lt2 = I2 && de2 ? Mt2.length ? { ...It2, addOnIds: Mt2 } : It2 : Pt2, Rt2 = Lt2 ? $o(Lt2) : void 0, zt2 = JSON.stringify(Ot2 ? { ...Rt2, requestedGender: { gender: Ot2 } } : Rt2 ?? null), Bt2 = (0, import_react.useMemo)(() => JSON.parse(zt2), [zt2]), Vt2 = R2?.anyResource === true, Ht2 = (0, import_react.useCallback)((e3) => Vt2 || _2 !== void 0 && pl({ isAppointment: I2, staffOnSlotCount: e3, hasStaffFilter: V2 !== null, hasRequestedGender: kt2 !== null, hasStaffPricedVariants: He2, staffSelectionStrategy: _2 }), [Vt2, I2, _2, V2, kt2, He2]), Ut2 = (0, import_react.useCallback)((e3) => R2 ?? (L2 ? null : e3), [R2, L2]), Wt2 = (0, import_react.useCallback)((e3) => {
2803
2804
  let t3 = e3 === null ? null : _t2.find((t4) => t4.id === e3);
2804
2805
  t3 !== void 0 && (xt2(false), yt2(t3 && !t3.gender ? t3.id : null), Tt2(t3?.gender ?? null));
2805
2806
  }, [_t2]), Gt2 = (0, import_react.useCallback)((e3) => {
@@ -2812,7 +2813,7 @@ function Xl({ onlyAvailableSlots: e2, selectedTimeZone: t2, setSelectedTimeZone:
2812
2813
  dn2.current = false;
2813
2814
  return;
2814
2815
  }
2815
- ke2(null), Le2.current && Wl(P2, T2, E2), Le2.current = null, fn2.current = null;
2816
+ ke2(null), Le2.current && Gl(P2, T2, E2), Le2.current = null, fn2.current = null;
2816
2817
  }, [U2, be2, H2, B2, V2, Bt2, Nt2, e2, l2, f2, D2]);
2817
2818
  let pn2 = (0, import_react.useCallback)(async () => {
2818
2819
  let e3 = await un2();
@@ -2844,7 +2845,7 @@ function Xl({ onlyAvailableSlots: e2, selectedTimeZone: t2, setSelectedTimeZone:
2844
2845
  mn2 && Tn2(Sn2());
2845
2846
  }
2846
2847
  }, [gn2, _n2, mn2, hn2, Tn2, Sn2]);
2847
- let Dn2 = x2?.schedule?.lastSessionEnd, On2 = I2 || Xa(C2) || Za(C2) && !ul(Dn2, Jt2), kn2 = !!(Ae2 && i2 && !j2 && P2 && H2 && Jt2 !== void 0), An2 = kn2 && P2 && H2 && Jt2 !== void 0 ? dl({ serviceId: P2, serviceType: C2, lastSessionEnd: Dn2, timeZone: H2, now: Jt2, onlyAvailableSlots: e2, locationId: B2, staffId: V2, timeSlotLimitPerDay: f2, customerChoices: Bt2, minRemainingCapacity: Nt2 }) : void 0, G2 = Pl(l2, An2), jn2 = Ae2 && P2 && On2 && !(Ae2 && P2 && On2 && (!i2 || j2)) && !H2, Mn2 = ve2 ? `onlineBookingOff` : ue2 ?? (G2.error === null ? jn2 ? `timeZoneMissing` : null : `upcomingSlotsLoadFailed`), Nn2 = U2 !== null, Pn2 = (0, import_react.useMemo)(() => vl({ sessions: G2.sessions, dayQuery: Nn2, daySlots: on2, staffFilter: V2, appointmentLike: I2, limitPerDay: f2, expandedDates: G2.expandedDates }), [G2.sessions, Nn2, on2, V2, I2, f2, G2.expandedDates]), { slotIdOf: Fn2 } = Pn2, In2 = Ae2 && (An2 ? G2.firstPageSettled : kn2 || i2 && !j2 && !P2 || jn2);
2848
+ let Dn2 = x2?.schedule?.lastSessionEnd, On2 = I2 || Xa(C2) || Za(C2) && !ul(Dn2, Jt2), kn2 = !!(Ae2 && i2 && !j2 && P2 && H2 && Jt2 !== void 0), An2 = kn2 && P2 && H2 && Jt2 !== void 0 ? fl({ serviceId: P2, serviceType: C2, lastSessionEnd: Dn2, timeZone: H2, now: Jt2, onlyAvailableSlots: e2, locationId: B2, staffId: V2, timeSlotLimitPerDay: f2, customerChoices: Bt2, minRemainingCapacity: Nt2 }) : void 0, G2 = Fl(l2, An2), jn2 = Ae2 && P2 && On2 && !(Ae2 && P2 && On2 && (!i2 || j2)) && !H2, Mn2 = ve2 ? `onlineBookingOff` : ue2 ?? (G2.error === null ? jn2 ? `timeZoneMissing` : null : `upcomingSlotsLoadFailed`), Nn2 = U2 !== null, Pn2 = (0, import_react.useMemo)(() => yl({ sessions: G2.sessions, dayQuery: Nn2, daySlots: on2, staffFilter: V2, appointmentLike: I2, limitPerDay: f2, expandedDates: G2.expandedDates }), [G2.sessions, Nn2, on2, V2, I2, f2, G2.expandedDates]), { slotIdOf: Fn2 } = Pn2, In2 = Ae2 && (An2 ? G2.firstPageSettled : kn2 || i2 && !j2 && !P2 || jn2);
2848
2849
  Ne2.current = In2, (0, import_react.useEffect)(() => {
2849
2850
  if (!In2) return;
2850
2851
  let e3 = Me2.current;
@@ -2862,10 +2863,10 @@ function Xl({ onlyAvailableSlots: e2, selectedTimeZone: t2, setSelectedTimeZone:
2862
2863
  }, [Hn2, P2, C2, M2, N2]), Wn2 = (0, import_react.useCallback)((e3) => {
2863
2864
  if (e3 === null) {
2864
2865
  let e4 = Le2.current !== null;
2865
- Le2.current = null, fn2.current = null, ke2(null), e4 && Wl(P2, T2, E2);
2866
+ Le2.current = null, fn2.current = null, ke2(null), e4 && Gl(P2, T2, E2);
2866
2867
  return;
2867
2868
  }
2868
- let t3 = yl(Pn2, e3);
2869
+ let t3 = bl(Pn2, e3);
2869
2870
  if (!t3) return;
2870
2871
  if (F2) {
2871
2872
  if (!ee2(t3.nestedTimeSlots ?? [], H2 ?? void 0)) return;
@@ -2873,10 +2874,10 @@ function Xl({ onlyAvailableSlots: e2, selectedTimeZone: t2, setSelectedTimeZone:
2873
2874
  return;
2874
2875
  }
2875
2876
  Le2.current = t3, ke2(t3), K2(e3, t3);
2876
- let n3 = Cl(t3);
2877
- if (w2(ys(t3), { staffId: I2 ? void 0 : Sl(t3), timezone: H2 ?? void 0, bookable: t3.bookable, staffChoiceRequired: I2 && Ue2 && !L2 && n3.length > 1 && !Ht2(n3.length), rescheduleStaffId: I2 && (_2 !== `CUSTOMER_MAY_CHOOSE` || !Ht2(n3.length)) ? n3[0] : void 0 }), !I2) return;
2877
+ let n3 = wl(t3);
2878
+ if (w2(ys(t3), { staffId: I2 ? void 0 : Cl(t3), timezone: H2 ?? void 0, bookable: t3.bookable, staffChoiceRequired: I2 && Ue2 && !L2 && n3.length > 1 && !Ht2(n3.length), rescheduleStaffId: I2 && (_2 !== `CUSTOMER_MAY_CHOOSE` || !Ht2(n3.length)) ? n3[0] : void 0 }), !I2) return;
2878
2879
  let r2 = ze2.current, i3;
2879
- i3 = R2 || (V2 && n3.includes(V2) ? { anyResource: false, staffMemberId: V2 } : kt2 !== null && Ht2(n3.length) ? { anyResource: true } : pl(n3, Ue2 && Ht2(n3.length))), Il(i3, kt2) !== Il(r2, Ve2) && At2(i3);
2880
+ i3 = R2 || (V2 && n3.includes(V2) ? { anyResource: false, staffMemberId: V2 } : kt2 !== null && Ht2(n3.length) ? { anyResource: true } : ml(n3, Ue2 && Ht2(n3.length))), Ll(i3, kt2) !== Ll(r2, Ve2) && At2(i3);
2880
2881
  }, [F2, P2, T2, E2, ee2, w2, Pn2, K2, H2, I2, Ue2, _2, Ht2, R2, V2, kt2, Ve2, At2]), Gn2 = (0, import_react.useCallback)(() => {
2881
2882
  let e3 = Le2.current;
2882
2883
  if (!e3 || N2 || !e3.bookable) return;
@@ -2887,15 +2888,15 @@ function Xl({ onlyAvailableSlots: e2, selectedTimeZone: t2, setSelectedTimeZone:
2887
2888
  if (!P2) return;
2888
2889
  let t3;
2889
2890
  if (I2) {
2890
- let n4 = Cl(e3), r2 = ml(n4, Ut2(ze2.current), Ht2(n4.length));
2891
+ let n4 = wl(e3), r2 = hl(n4, Ut2(ze2.current), Ht2(n4.length));
2891
2892
  t3 = (r2.isComplete ? r2.resourceId : n4[0]) ?? (n4.length ? null : void 0);
2892
2893
  }
2893
2894
  let n3 = De2(`bookingForm`, { slug: x2?.mainSlug?.name ?? null, serviceId: P2 });
2894
2895
  Hn2(Pc({ serviceId: P2, serviceType: C2 ?? void 0, start: e3.localStartDate, end: e3.localEndDate, timeZone: H2 ?? void 0, isEligibleForFlowCompletion: !!n3 })), n3 && Ee2(ie2(n3, { handoff: true, staffId: t3 }));
2895
- }, [Hn2, F2, te2, H2, P2, C2, x2, I2, Ut2, Ht2, Ee2, De2, ie2, N2]), Kn2 = Oe2 ? Cl(Oe2) : null, qn2 = Kn2 ? F2 || !I2 || ml(Kn2, Ut2(Re2), Ht2(Kn2.length)).isComplete : false, Jn2 = Kn2 ? Ht2(Kn2.length) : false, Yn2 = (0, import_react.useMemo)(() => !Oe2 || Ze2 ? [] : xl(Oe2).map((e3) => ({ staffMemberId: e3.staffMemberId, name: e3.name || null, image: null, isSelected: e3.staffMemberId === Be2 })), [Oe2, Ze2, Be2]), Xn2 = (0, import_react.useMemo)(() => ({ isMultiService: F2, availabilityRequestKey: Se2, needsServiceChoice: Ce2, isRescheduling: N2, rescheduleValidUntil: rn2, businessTimeZone: g2, canChangeTimeZone: Kt2, setTimeZone: qt2, locationFilterOptions: lt2, selectedLocationFilter: B2, setLocationFilter: Gt2, staffFilterOptions: _t2, selectedStaffFilter: V2, setStaffFilter: Wt2, requestedGender: kt2, genderSelectionAllowed: Ge2, currentTimeSlotsPage: U2 ? 1 : G2.currentPage, hasNextTimeSlotsPage: !U2 && G2.hasNextPage, hasPreviousTimeSlotsPage: !U2 && G2.hasPreviousPage, nextTimeSlotsPage: U2 ? Vl : G2.nextPage, loadUpcomingTimeSlots: Pe2, upcomingTimeSlotsRequested: Ae2, previousTimeSlotsPage: U2 ? Bl : G2.previousPage, timeSlots: Pn2.rows.map((e3) => bl(e3, H2, Fn2, L2)), isLoading: zn2, hasError: Vn2, errorCode: Bn2, selectedDate: an2, daysAvailabilityRange: Xt2, daysAvailability: nn2, daysAvailabilityLoading: Qt2, daysAvailabilityHasError: $t2, selectDate: wn2, setDaysAvailabilityRange: en2, goToNextAvailableDate: En2, nextAvailableSlotsCount: l2, timeZone: H2, staffFromSlots: Yn2, selectedResourceId: Be2, setSelectedResource: jt2, canAutoAssignStaff: Jn2, isComplete: qn2, selectedTimeSlot: Oe2 ? bl(Oe2, H2, Fn2, L2) : null, selectTimeSlot: Wn2, navigateToBookingForm: Gn2, timeSlotLimitPerDay: f2, daysWithMore: Pn2.daysWithMore, loadingDate: G2.loadingDate, loadAllTimeSlotsForDay: G2.loadAllSessionsForDay }), [F2, Se2, Ce2, N2, rn2, g2, H2, Kt2, qt2, G2, Pe2, Ae2, lt2, B2, Gt2, _t2, V2, Wt2, kt2, Ge2, U2, zn2, Bn2, Vn2, Pn2, an2, Xt2, nn2, Qt2, $t2, wn2, en2, En2, l2, Yn2, Be2, jt2, Jn2, qn2, Oe2, Wn2, Gn2, f2, Fn2, L2]);
2896
- return (0, import_jsx_runtime.jsx)(Hl.Provider, { value: Xn2, children: b2 });
2896
+ }, [Hn2, F2, te2, H2, P2, C2, x2, I2, Ut2, Ht2, Ee2, De2, ie2, N2]), Kn2 = Oe2 ? wl(Oe2) : null, qn2 = Kn2 ? F2 || !I2 || hl(Kn2, Ut2(Re2), Ht2(Kn2.length)).isComplete : false, Jn2 = Kn2 ? Ht2(Kn2.length) : false, Yn2 = (0, import_react.useMemo)(() => !Oe2 || Ze2 ? [] : Sl(Oe2).map((e3) => ({ staffMemberId: e3.staffMemberId, name: e3.name || null, image: null, isSelected: e3.staffMemberId === Be2 })), [Oe2, Ze2, Be2]), Xn2 = (0, import_react.useMemo)(() => ({ isMultiService: F2, availabilityRequestKey: Se2, needsServiceChoice: Ce2, isRescheduling: N2, rescheduleValidUntil: rn2, businessTimeZone: g2, canChangeTimeZone: Kt2, setTimeZone: qt2, locationFilterOptions: lt2, selectedLocationFilter: B2, setLocationFilter: Gt2, staffFilterOptions: _t2, selectedStaffFilter: V2, setStaffFilter: Wt2, requestedGender: kt2, genderSelectionAllowed: Ge2, currentTimeSlotsPage: U2 ? 1 : G2.currentPage, hasNextTimeSlotsPage: !U2 && G2.hasNextPage, hasPreviousTimeSlotsPage: !U2 && G2.hasPreviousPage, nextTimeSlotsPage: U2 ? Hl : G2.nextPage, loadUpcomingTimeSlots: Pe2, upcomingTimeSlotsRequested: Ae2, previousTimeSlotsPage: U2 ? Vl : G2.previousPage, timeSlots: Pn2.rows.map((e3) => xl(e3, H2, Fn2, L2)), isLoading: zn2, hasError: Vn2, errorCode: Bn2, selectedDate: an2, daysAvailabilityRange: Xt2, daysAvailability: nn2, daysAvailabilityLoading: Qt2, daysAvailabilityHasError: $t2, selectDate: wn2, setDaysAvailabilityRange: en2, goToNextAvailableDate: En2, nextAvailableSlotsCount: l2, timeZone: H2, staffFromSlots: Yn2, selectedResourceId: Be2, setSelectedResource: jt2, canAutoAssignStaff: Jn2, isComplete: qn2, selectedTimeSlot: Oe2 ? xl(Oe2, H2, Fn2, L2) : null, selectTimeSlot: Wn2, navigateToBookingForm: Gn2, timeSlotLimitPerDay: f2, daysWithMore: Pn2.daysWithMore, loadingDate: G2.loadingDate, loadAllTimeSlotsForDay: G2.loadAllSessionsForDay }), [F2, Se2, Ce2, N2, rn2, g2, H2, Kt2, qt2, G2, Pe2, Ae2, lt2, B2, Gt2, _t2, V2, Wt2, kt2, Ge2, U2, zn2, Bn2, Vn2, Pn2, an2, Xt2, nn2, Qt2, $t2, wn2, en2, En2, l2, Yn2, Be2, jt2, Jn2, qn2, Oe2, Wn2, Gn2, f2, Fn2, L2]);
2897
+ return (0, import_jsx_runtime.jsx)(Ul.Provider, { value: Xn2, children: b2 });
2897
2898
  }
2898
- var Zl = sn(`4936242d-905c-48bf-80ce-5f56d075de4f`);
2899
+ var Ql = sn(`4936242d-905c-48bf-80ce-5f56d075de4f`);
2899
2900
  // Annotate the CommonJS export names for ESM import in node:
2900
2901
  0 && (module.exports = {
2901
2902
  TimeSlotsContextProvider,