@wix/bookings 1.0.1744 → 1.0.1746

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.
@@ -3514,6 +3514,8 @@ interface RescheduledBooking {
3514
3514
  revision: string | null;
3515
3515
  serviceId: string | null;
3516
3516
  kind: 'appointment' | 'class' | 'other';
3517
+ /** When the booking starts now (before the move), as an ISO instant. */
3518
+ startDate: string | null;
3517
3519
  participants: number;
3518
3520
  addOnIds: string[];
3519
3521
  locationId: string | null;
@@ -4904,7 +4904,7 @@ function vy({ isLoading: e2, hasError: t2, bookingsSettingsLoading: n2, reschedu
4904
4904
  }, navigateToMultiServiceForm: () => {
4905
4905
  }, resolveNextPageHref: () => null, isNavigating: false, openPreferences: () => Promise.resolve(), multiServiceAppointmentsEnabled: false, isMultiServiceAppointment: false, multiServiceAppointmentServices: [], multiServiceAppointmentOptionsAndVariants: {}, multiServiceAppointmentVariantsStatus: `ready`, bookingsSettingsLoading: n2, reschedule: a2, rescheduleBooking: async () => ({ outcome: `failed` }), goHomeAfterReschedule: () => {
4906
4906
  }, canRescheduleToPick: false };
4907
- return p(Yy.Provider, { value: o2, children: i2 });
4907
+ return p(Xy.Provider, { value: o2, children: i2 });
4908
4908
  }
4909
4909
  function yy({ rescheduleRequest: e2, children: t2 }) {
4910
4910
  return p(py, { children: p(vy, { isLoading: true, hasError: false, bookingsSettingsLoading: true, rescheduleRequest: e2, children: t2 }) });
@@ -4948,11 +4948,16 @@ function Ay(e2) {
4948
4948
  function jy({ totalParticipants: e2, participantsChoices: t2 }) {
4949
4949
  return e2 || (t2?.serviceChoices ?? []).reduce((e3, t3) => e3 + (t3.numberOfParticipants ?? 1), 0) || 1;
4950
4950
  }
4951
- function My(e2, t2) {
4951
+ function My(e2) {
4952
+ if (!e2) return null;
4953
+ let t2 = new Date(e2);
4954
+ return Number.isNaN(t2.getTime()) ? null : t2.toISOString();
4955
+ }
4956
+ function Ny(e2, t2) {
4952
4957
  let { slot: n2, schedule: r2, tags: i2 } = e2.bookedEntity ?? {}, a2 = n2?.location;
4953
- return { bookingId: t2, revision: e2.revision ?? null, serviceId: n2?.serviceId ?? r2?.serviceId ?? null, kind: Ay(i2), participants: jy(e2), addOnIds: (e2.bookedAddOns ?? []).flatMap((e3) => e3._id ?? []), locationId: a2?._id ?? null, customAddress: a2?.locationType === `CUSTOM` ? a2.formattedAddress ?? `` : null };
4958
+ return { bookingId: t2, revision: e2.revision ?? null, serviceId: n2?.serviceId ?? r2?.serviceId ?? null, kind: Ay(i2), startDate: My(e2.startDate), participants: jy(e2), addOnIds: (e2.bookedAddOns ?? []).flatMap((e3) => e3._id ?? []), locationId: a2?._id ?? null, customAddress: a2?.locationType === `CUSTOM` ? a2.formattedAddress ?? `` : null };
4954
4959
  }
4955
- async function Ny({ bookingId: e2, token: t2 }) {
4960
+ async function Py({ bookingId: e2, token: t2 }) {
4956
4961
  let n2;
4957
4962
  try {
4958
4963
  t2 ? n2 = (await ad(t2)).booking : e2 && (n2 = (await Io({ filter: { _id: e2 }, cursorPaging: { limit: 1 } }, {})).extendedBookings?.[0]?.booking);
@@ -4962,17 +4967,17 @@ async function Ny({ bookingId: e2, token: t2 }) {
4962
4967
  }
4963
4968
  let r2 = n2?._id;
4964
4969
  if (!n2 || !r2) throw new Oy(`notFound`);
4965
- let i2 = My(n2, r2);
4970
+ let i2 = Ny(n2, r2);
4966
4971
  return t2 ? { ...i2, customAddress: null } : i2;
4967
4972
  }
4968
- function Py(e2) {
4973
+ function Fy(e2) {
4969
4974
  let t2 = e2?.bookedEntity?.slot;
4970
4975
  return { staffName: t2?.resource?.name || null, locationName: t2?.location?.name || t2?.location?.formattedAddress || null };
4971
4976
  }
4972
- async function Fy({ booking: e2, slot: t2, token: n2 }) {
4973
- return Py(n2 ? (await id(n2, t2, { revision: e2.revision || `1` })).booking : (await od(e2.bookingId, t2, { revision: e2.revision ?? `` })).booking);
4977
+ async function Iy({ booking: e2, slot: t2, token: n2 }) {
4978
+ return Fy(n2 ? (await id(n2, t2, { revision: e2.revision || `1` })).booking : (await od(e2.bookingId, t2, { revision: e2.revision ?? `` })).booking);
4974
4979
  }
4975
- async function Iy(e2) {
4980
+ async function Ly(e2) {
4976
4981
  try {
4977
4982
  let t2 = (await Io({ filter: { _id: e2 }, cursorPaging: { limit: 1 } }, { withEcomTransactions: true })).extendedBookings?.[0]?.transactions?.chargedMembershipPaymentDetails?.expirationDate;
4978
4983
  return t2 ? new Date(t2).toISOString() : null;
@@ -4980,7 +4985,7 @@ async function Iy(e2) {
4980
4985
  return ma(e3, { feature: fa.reschedule, action: `fetch-plan-valid-until`, level: `warning` }), null;
4981
4986
  }
4982
4987
  }
4983
- function Ly() {
4988
+ function Ry() {
4984
4989
  let e2 = pm();
4985
4990
  return i(() => {
4986
4991
  if (!e2) return null;
@@ -4991,25 +4996,25 @@ function Ly() {
4991
4996
  }
4992
4997
  }, [e2]);
4993
4998
  }
4994
- var Ry = Kd(`@wix/viewer-service-site-members`);
4995
- function zy() {
4999
+ var zy = Kd(`@wix/viewer-service-site-members`);
5000
+ function By() {
4996
5001
  try {
4997
5002
  return d();
4998
5003
  } catch {
4999
5004
  return null;
5000
5005
  }
5001
5006
  }
5002
- function By(e2) {
5007
+ function Vy(e2) {
5003
5008
  try {
5004
- return e2 ? e2(Ry) : null;
5009
+ return e2 ? e2(zy) : null;
5005
5010
  } catch {
5006
5011
  return null;
5007
5012
  }
5008
5013
  }
5009
- function Vy() {
5010
- return By(zy());
5014
+ function Hy() {
5015
+ return Vy(By());
5011
5016
  }
5012
- function Hy(e2) {
5017
+ function Uy(e2) {
5013
5018
  if (!e2) return null;
5014
5019
  try {
5015
5020
  let t2 = new URL(e2);
@@ -5018,93 +5023,93 @@ function Hy(e2) {
5018
5023
  return null;
5019
5024
  }
5020
5025
  }
5021
- function Uy(e2, { bookable: t2, staffChoiceRequired: n2, timezone: r2, validUntil: i2 }) {
5026
+ function Wy(e2, { bookable: t2, staffChoiceRequired: n2, timezone: r2, validUntil: i2 }) {
5022
5027
  if (!$g(e2) || !t2) return false;
5023
5028
  let a2 = Rg(e2);
5024
5029
  if (n2 && (!a2 || a2.anyResource)) return false;
5025
5030
  let o2 = e2.slotStart ? hf(e2.slotStart, r2) : null;
5026
5031
  return !i2 || !o2 || o2.getTime() <= Date.parse(i2);
5027
5032
  }
5028
- var Wy = { status: `loading`, booking: null, validUntil: null };
5029
- async function Gy(e2) {
5033
+ var Gy = { status: `loading`, booking: null, validUntil: null };
5034
+ async function Ky(e2) {
5030
5035
  return e2.getMemberDetails ? !!await e2.getMemberDetails().catch(() => null) : !!e2.isInitiallyLoggedIn;
5031
5036
  }
5032
- async function Ky(e2, t2) {
5037
+ async function qy(e2, t2) {
5033
5038
  let { bookingId: n2, token: r2 } = e2;
5034
- if (!r2 && !(t2 && await Gy(t2)) && !(t2 && await t2.promptLogin({ mode: `login` }).then(() => true, () => false))) return { status: `loginRequired`, booking: null, validUntil: null };
5039
+ if (!r2 && !(t2 && await Ky(t2)) && !(t2 && await t2.promptLogin({ mode: `login` }).then(() => true, () => false))) return { status: `loginRequired`, booking: null, validUntil: null };
5035
5040
  try {
5036
- let [t3, i2] = await Promise.all([Ny(e2), n2 && !r2 ? Iy(n2) : null]);
5041
+ let [t3, i2] = await Promise.all([Py(e2), n2 && !r2 ? Ly(n2) : null]);
5037
5042
  return { status: `ready`, booking: t3, validUntil: i2 };
5038
5043
  } catch (e3) {
5039
5044
  return ma(e3, { feature: fa.reschedule, action: `fetch-booking` }), { status: e3 instanceof Oy ? e3.reason : `failed`, booking: null, validUntil: null };
5040
5045
  }
5041
5046
  }
5042
- var qy = /* @__PURE__ */ new Map();
5043
- function Jy(e2, t2, n2) {
5044
- let r2 = `${e2.bookingId ?? ``}|${e2.token ?? ``}`, i2 = qy.get(r2) ?? { load: Ky(e2, t2), users: 0 };
5045
- return i2.users += 1, qy.set(r2, i2), i2.load.then(n2), () => {
5046
- --i2.users, i2.users === 0 && qy.get(r2) === i2 && qy.delete(r2);
5047
+ var Jy = /* @__PURE__ */ new Map();
5048
+ function Yy(e2, t2, n2) {
5049
+ let r2 = `${e2.bookingId ?? ``}|${e2.token ?? ``}`, i2 = Jy.get(r2) ?? { load: qy(e2, t2), users: 0 };
5050
+ return i2.users += 1, Jy.set(r2, i2), i2.load.then(n2), () => {
5051
+ --i2.users, i2.users === 0 && Jy.get(r2) === i2 && Jy.delete(r2);
5047
5052
  };
5048
5053
  }
5049
- var Yy = n(null);
5050
- var Xy = `useServiceContext must be used within ServiceContextProvider`;
5051
- function Zy(e2 = false) {
5052
- let t2 = a(Yy);
5053
- if (!t2 && !e2) throw Error(Xy);
5054
+ var Xy = n(null);
5055
+ var Zy = `useServiceContext must be used within ServiceContextProvider`;
5056
+ function Qy(e2 = false) {
5057
+ let t2 = a(Xy);
5058
+ if (!t2 && !e2) throw Error(Zy);
5054
5059
  return t2;
5055
5060
  }
5056
- function Qy(e2, t2, n2) {
5061
+ function $y(e2, t2, n2) {
5057
5062
  if (e2) return { by: `slug`, value: e2 };
5058
5063
  let r2 = t2?.services ?? [];
5059
5064
  return wg(t2) ? { by: `multi`, serviceIds: r2.map(({ serviceId: e3 }) => e3) } : r2.length === 1 ? { by: `id`, value: r2[0].serviceId } : n2 ? { by: `id`, value: n2 } : { by: `none` };
5060
5065
  }
5061
- var $y = (e2) => void 0;
5062
- var eb = (e2, t2) => Cg(t2.get(Y.blob))?.services.find((t3) => t3.serviceId === e2);
5063
- var tb = (e2, t2) => {
5064
- let n2 = eb(e2, t2) ?? Og(e2), r2 = $y(e2);
5066
+ var eb = (e2) => void 0;
5067
+ var tb = (e2, t2) => Cg(t2.get(Y.blob))?.services.find((t3) => t3.serviceId === e2);
5068
+ var nb = (e2, t2) => {
5069
+ let n2 = tb(e2, t2) ?? Og(e2), r2 = eb(e2);
5065
5070
  return r2 === void 0 ? n2 : zg(n2, r2);
5066
5071
  };
5067
- var nb = (e2, t2) => {
5068
- let n2 = tb(e2, t2), r2 = t2.get(Y.resource), i2 = $y(e2) !== void 0 || !!eb(e2, t2);
5072
+ var rb = (e2, t2) => {
5073
+ let n2 = nb(e2, t2), r2 = t2.get(Y.resource), i2 = eb(e2) !== void 0 || !!tb(e2, t2);
5069
5074
  return r2 && !i2 ? zg(n2, r2) : n2;
5070
5075
  };
5071
- function rb(e2, t2) {
5076
+ function ib(e2, t2) {
5072
5077
  return !e2 || !t2 || !e2.services.every($g) ? null : Mg(t2, e2);
5073
5078
  }
5074
- var ib = [];
5075
- function ab(e2) {
5079
+ var ab = [];
5080
+ function ob(e2) {
5076
5081
  return { min: 1, max: e2?.bookingPolicy?.participantsPolicy?.maxParticipantsPerBooking || 1 };
5077
5082
  }
5078
- function ob(e2, { previous: t2, others: n2 }, { min: r2, max: i2 }) {
5083
+ function sb(e2, { previous: t2, others: n2 }, { min: r2, max: i2 }) {
5079
5084
  let a2 = Math.max(0, Math.floor(e2)), o2 = Math.max(t2, i2 - n2), s2 = Math.min(a2, o2);
5080
5085
  return s2 > 0 && n2 + s2 < r2 ? Math.min(r2 - n2, o2) : s2;
5081
5086
  }
5082
- function sb({ serviceCtaState: e2, courseAvailability: t2, serviceBookability: n2 }) {
5087
+ function cb({ serviceCtaState: e2, courseAvailability: t2, serviceBookability: n2 }) {
5083
5088
  return `${e2}|${t2?.totalCapacity ?? `-`}|${t2?.remainingCapacity ?? `-`}|${t2 === null}|${n2.state}|${n2.isAvailableForBooking}`;
5084
5089
  }
5085
- var cb = (e2) => ({ service: e2, hasError: false });
5086
- var lb = () => ({ service: null, hasError: true });
5087
- var ub = { service: null, hasError: false };
5088
- var db = (e2) => ({ ...ub, isMultiServiceAppointment: true, multiServiceAppointmentServices: e2 });
5089
- var fb = () => ({ ...lb(), isMultiServiceAppointment: true });
5090
- var pb = [];
5091
- var mb = {};
5092
- function hb({ servicePromise: e2, refreshSignal: n2, injected: r2, rescheduleRequest: i2 = null, bookingsSettings: a2, children: o2 }) {
5093
- return p(t, { fallback: p(yy, { rescheduleRequest: i2, children: o2 }), children: p(_y, { bookingsSettings: a2, children: p(ga, { fallback: p(by, { rescheduleRequest: i2, children: o2 }), feature: fa.service, children: p(yb, { servicePromise: e2, refreshSignal: n2, injected: r2, rescheduleRequest: i2, children: o2 }) }) }) });
5094
- }
5095
- var gb = (e2) => e2 ?? void 0;
5096
- var _b = () => void 0;
5097
- function vb(e2, t2) {
5090
+ var lb = (e2) => ({ service: e2, hasError: false });
5091
+ var ub = () => ({ service: null, hasError: true });
5092
+ var db = { service: null, hasError: false };
5093
+ var fb = (e2) => ({ ...db, isMultiServiceAppointment: true, multiServiceAppointmentServices: e2 });
5094
+ var pb = () => ({ ...ub(), isMultiServiceAppointment: true });
5095
+ var mb = [];
5096
+ var hb = {};
5097
+ function gb({ servicePromise: e2, refreshSignal: n2, injected: r2, rescheduleRequest: i2 = null, bookingsSettings: a2, children: o2 }) {
5098
+ return p(t, { fallback: p(yy, { rescheduleRequest: i2, children: o2 }), children: p(_y, { bookingsSettings: a2, children: p(ga, { fallback: p(by, { rescheduleRequest: i2, children: o2 }), feature: fa.service, children: p(bb, { servicePromise: e2, refreshSignal: n2, injected: r2, rescheduleRequest: i2, children: o2 }) }) }) });
5099
+ }
5100
+ var _b = (e2) => e2 ?? void 0;
5101
+ var vb = () => void 0;
5102
+ function yb(e2, t2) {
5098
5103
  ma(e2, { feature: fa.service, action: `fetch-service-variants`, level: `warning`, contexts: { service: { serviceId: t2 } } });
5099
5104
  }
5100
- function yb({ servicePromise: e2, refreshSignal: t2 = 0, injected: n2, rescheduleRequest: a2 = null, children: u2 }) {
5101
- let d2 = n2 ? null : e2 ? ka(e2) : null, f2 = n2?.service ?? d2?.service ?? null, m2 = d2?.hasError ?? false, h2 = d2?.isMultiServiceAppointment ?? false, g2 = d2?.multiServiceAppointmentServices ?? pb, _2 = p_(), { navigate: v2, navigateToHref: ee2, resolvePath: y2, toHref: b2, getBookingFormPath: te2 } = ry(), ne2 = Ly(), x2 = lf($d.SERVICE), { getParsedUrl: S2, pushUrl: C2, searchParams: re2 } = Oa(), w2 = c(S2);
5105
+ function bb({ servicePromise: e2, refreshSignal: t2 = 0, injected: n2, rescheduleRequest: a2 = null, children: u2 }) {
5106
+ let d2 = n2 ? null : e2 ? ka(e2) : null, f2 = n2?.service ?? d2?.service ?? null, m2 = d2?.hasError ?? false, h2 = d2?.isMultiServiceAppointment ?? false, g2 = d2?.multiServiceAppointmentServices ?? mb, _2 = p_(), { navigate: v2, navigateToHref: ee2, resolvePath: y2, toHref: b2, getBookingFormPath: te2 } = ry(), ne2 = Ry(), x2 = lf($d.SERVICE), { getParsedUrl: S2, pushUrl: C2, searchParams: re2 } = Oa(), w2 = c(S2);
5102
5107
  w2.current = S2;
5103
5108
  let ie2 = c(C2);
5104
5109
  ie2.current = C2;
5105
5110
  let ae2 = v_(), oe2 = c(ae2);
5106
5111
  oe2.current = ae2;
5107
- let [T2, E2] = l(Wy), se2 = Vy(), D2 = (e3, t3) => a2 ? Og(e3) : tb(e3, t3), ce2 = c(D2);
5112
+ let [T2, E2] = l(Gy), se2 = Hy(), D2 = (e3, t3) => a2 ? Og(e3) : nb(e3, t3), ce2 = c(D2);
5108
5113
  ce2.current = D2;
5109
5114
  let [le2, ue2] = l(() => D2(f2?._id ?? ``, S2().searchParams)), O2 = c(le2), de2 = c(void 0), k2 = c(true), fe2 = c(false), pe2 = c(null), [me2, he2] = l(null), ge2 = c(me2), [_e2, ve2] = l(0), A2 = f2?._id ?? null, ye2 = s(() => {
5110
5115
  if (!a2) return null;
@@ -5116,25 +5121,25 @@ function yb({ servicePromise: e2, refreshSignal: t2 = 0, injected: n2, reschedul
5116
5121
  if (!f2) return null;
5117
5122
  let e3 = y2(`servicePage`, { slug: f2.mainSlug?.name ?? null, serviceId: f2._id ?? null });
5118
5123
  return e3 ? { href: b2(e3), target: `_self` } : null;
5119
- }, [f2, y2, b2]), [Ce2, we2] = l(ib), Te2 = n2 ? n2.masterEvents : Ce2, Ee2 = hy(), De2 = dy(), Oe2 = De2.isLoading, ke2 = !De2.isLoading && De2.multiServiceAppointmentsEnabled;
5124
+ }, [f2, y2, b2]), [Ce2, we2] = l(ab), Te2 = n2 ? n2.masterEvents : Ce2, Ee2 = hy(), De2 = dy(), Oe2 = De2.isLoading, ke2 = !De2.isLoading && De2.multiServiceAppointmentsEnabled;
5120
5125
  o(() => {
5121
5126
  if (!a2 || Oe2) return;
5122
- let e3 = false, t3 = Jy(a2, se2, (t4) => {
5127
+ let e3 = false, t3 = Yy(a2, se2, (t4) => {
5123
5128
  e3 || E2(t4);
5124
5129
  });
5125
5130
  return () => {
5126
5131
  e3 = true, t3();
5127
5132
  };
5128
5133
  }, [a2, Oe2, se2]);
5129
- let Ae2 = !n2 && !!f2 && Od(f2), je2 = Ae2 && A2 ? C_(A2, t2) : null, Me2 = (typeof window > `u` && je2 && A2 && ae2.scope && !Oe2 ? ka(Ma(I_({ key: je2, warmupData: ae2, fetchData: () => Pf(A2).catch((e3) => (vb(e3, A2), null)) }), gb, _b)) : void 0) ?? (je2 ? A_(je2) : void 0), [Ne2, Pe2] = l(() => Me2 ?? null), [Fe2, Ie2] = l(() => Me2 ? je2 : null), Le2 = je2 !== null && Fe2 !== je2, Re2 = n2 ? n2.serviceOptionsAndVariants : Ae2 ? Ne2 : null;
5134
+ let Ae2 = !n2 && !!f2 && Od(f2), je2 = Ae2 && A2 ? C_(A2, t2) : null, Me2 = (typeof window > `u` && je2 && A2 && ae2.scope && !Oe2 ? ka(Ma(I_({ key: je2, warmupData: ae2, fetchData: () => Pf(A2).catch((e3) => (yb(e3, A2), null)) }), _b, vb)) : void 0) ?? (je2 ? A_(je2) : void 0), [Ne2, Pe2] = l(() => Me2 ?? null), [Fe2, Ie2] = l(() => Me2 ? je2 : null), Le2 = je2 !== null && Fe2 !== je2, Re2 = n2 ? n2.serviceOptionsAndVariants : Ae2 ? Ne2 : null;
5130
5135
  o(() => {
5131
5136
  if (n2) return;
5132
5137
  let e3 = be2 && !Td(xe2) ? be2 : null;
5133
- if ((!e3 || Oe2) && we2((e4) => e4.length === 0 ? e4 : ib), Oe2) return;
5138
+ if ((!e3 || Oe2) && we2((e4) => e4.length === 0 ? e4 : ab), Oe2) return;
5134
5139
  let i2 = Ae2 ? A2 : null;
5135
5140
  if (!e3 && !i2) return;
5136
- let a3 = false, o2 = e3 ? Mf([e3], Ee2).catch(() => ib) : Promise.resolve(ib), s2 = i2 ? I_({ key: C_(i2, t2), warmupData: oe2.current, fetchData: () => Pf(i2) }).catch((e4) => {
5137
- vb(e4, i2);
5141
+ let a3 = false, o2 = e3 ? Mf([e3], Ee2).catch(() => ab) : Promise.resolve(ab), s2 = i2 ? I_({ key: C_(i2, t2), warmupData: oe2.current, fetchData: () => Pf(i2) }).catch((e4) => {
5142
+ yb(e4, i2);
5138
5143
  }) : Promise.resolve(void 0);
5139
5144
  return Promise.all([o2, s2]).then(([e4, t3]) => {
5140
5145
  a3 || r(() => {
@@ -5147,7 +5152,7 @@ function yb({ servicePromise: e2, refreshSignal: t2 = 0, injected: n2, reschedul
5147
5152
  let ze2 = a2 ? null : re2.get(Y.blob), Be2 = s(() => JSON.stringify([...new Set((Cg(ze2)?.services ?? []).filter((e3) => Hg(e3).length > 0).map(({ serviceId: e3 }) => e3))].sort()), [ze2]), Ve2 = s(() => {
5148
5153
  let e3 = new Set(JSON.parse(Be2));
5149
5154
  return [...new Set(g2.filter(Od).flatMap(({ _id: t3 }) => t3 && e3.has(t3) ? [t3] : []))];
5150
- }, [g2, Be2]), He2 = s(() => ({ serviceIds: Ve2, refreshSignal: t2 }), [Ve2, t2]), [Ue2, We2] = l(null), Ge2 = Ue2?.request === He2 ? Ue2 : null, Ke2 = Ge2?.data ?? mb, j2 = Ve2.length === 0 ? `ready` : Oe2 || !Ge2 ? `loading` : Ge2.data && Ve2.every((e3) => Ge2.data?.[e3]) ? `ready` : `error`;
5155
+ }, [g2, Be2]), He2 = s(() => ({ serviceIds: Ve2, refreshSignal: t2 }), [Ve2, t2]), [Ue2, We2] = l(null), Ge2 = Ue2?.request === He2 ? Ue2 : null, Ke2 = Ge2?.data ?? hb, j2 = Ve2.length === 0 ? `ready` : Oe2 || !Ge2 ? `loading` : Ge2.data && Ve2.every((e3) => Ge2.data?.[e3]) ? `ready` : `error`;
5151
5156
  o(() => {
5152
5157
  let { serviceIds: e3, refreshSignal: t3 } = He2;
5153
5158
  if (Oe2 || e3.length === 0) return;
@@ -5158,7 +5163,7 @@ function yb({ servicePromise: e2, refreshSignal: t2 = 0, injected: n2, reschedul
5158
5163
  n3 = true;
5159
5164
  };
5160
5165
  }, [Oe2, He2]);
5161
- let M2 = rm({ service: f2, masterEvents: Te2, locale: _2, timeZone: Ee2, now: y_() }), N2 = sb(M2), qe2 = s(() => M2, [f2, Te2, _2, Ee2, N2]), Je2 = c(null);
5166
+ let M2 = rm({ service: f2, masterEvents: Te2, locale: _2, timeZone: Ee2, now: y_() }), N2 = cb(M2), qe2 = s(() => M2, [f2, Te2, _2, Ee2, N2]), Je2 = c(null);
5162
5167
  o(() => {
5163
5168
  if (Je2.current !== null) {
5164
5169
  let e3 = ce2.current(f2?._id ?? ``, w2.current().searchParams);
@@ -5180,20 +5185,20 @@ function yb({ servicePromise: e2, refreshSignal: t2 = 0, injected: n2, reschedul
5180
5185
  O2.current = t3, ue2(t3);
5181
5186
  }, []), $e2 = i((e3) => {
5182
5187
  Qe2(e3);
5183
- let t3 = w2.current(), n3 = e3(tb(A2 ?? ``, t3.searchParams)), r2 = Eg(`${t3.pathname}${t3.search}${t3.hash}`, { currentUrl: t3, entries: [Lg(n3, Xe2.current)], policy: `inPlace` }), i2 = new URL(r2, t3);
5188
+ let t3 = w2.current(), n3 = e3(nb(A2 ?? ``, t3.searchParams)), r2 = Eg(`${t3.pathname}${t3.search}${t3.hash}`, { currentUrl: t3, entries: [Lg(n3, Xe2.current)], policy: `inPlace` }), i2 = new URL(r2, t3);
5184
5189
  Ye2.current = i2.searchParams.get(Y.blob), ie2.current(i2, { disableScrollToTop: true, skipHistory: true });
5185
5190
  }, [Qe2, A2]), et2 = Cg(ze2)?.wantsPromoCode === true, tt2 = i((e3) => {
5186
5191
  let t3 = w2.current(), n3 = Cg(t3.searchParams.get(Y.blob));
5187
5192
  if (!n3) return;
5188
5193
  let r2 = new URL(Mg(`${t3.pathname}${t3.search}${t3.hash}`, Fg(n3, e3)), t3);
5189
5194
  Ye2.current = r2.searchParams.get(Y.blob), ie2.current(r2, { disableScrollToTop: true, skipHistory: true });
5190
- }, []), nt2 = Uf(Re2), P2 = i((e3, t3) => nt2 ? Ug(e3, t3 ? [t3] : []) : e3, [nt2]), F2 = i((e3) => Qe2((t3) => P2(zg(t3, e3), e3)), [Qe2, P2]), rt2 = i(() => Qe2((e3) => P2(Vg(e3), null)), [Qe2, P2]), I2 = i((e3) => Qe2((t3) => P2(Bg(t3, e3), null)), [Qe2, P2]), it2 = i((e3) => $e2((t3) => Ug(t3, e3)), [$e2]), at2 = s(() => ab(f2), [f2]), ot2 = s(() => Wf(Re2, { locale: _2, staffMembers: f2 ? Gf(f2) : [], businessLocations: Cd(f2) }), [Re2, _2, f2]), st2 = s(() => new Set(Wf(Re2, { locale: _2 })?.choices.flatMap((e3) => e3.choiceId ? [e3.choiceId] : []) ?? []), [Re2, _2]), ct2 = i((e3) => {
5195
+ }, []), nt2 = Uf(Re2), P2 = i((e3, t3) => nt2 ? Ug(e3, t3 ? [t3] : []) : e3, [nt2]), F2 = i((e3) => Qe2((t3) => P2(zg(t3, e3), e3)), [Qe2, P2]), rt2 = i(() => Qe2((e3) => P2(Vg(e3), null)), [Qe2, P2]), I2 = i((e3) => Qe2((t3) => P2(Bg(t3, e3), null)), [Qe2, P2]), it2 = i((e3) => $e2((t3) => Ug(t3, e3)), [$e2]), at2 = s(() => ob(f2), [f2]), ot2 = s(() => Wf(Re2, { locale: _2, staffMembers: f2 ? Gf(f2) : [], businessLocations: Cd(f2) }), [Re2, _2, f2]), st2 = s(() => new Set(Wf(Re2, { locale: _2 })?.choices.flatMap((e3) => e3.choiceId ? [e3.choiceId] : []) ?? []), [Re2, _2]), ct2 = i((e3) => {
5191
5196
  let t3 = Object.entries(e3).filter(([e4, t4]) => st2.has(e4) && Number.isFinite(t4));
5192
5197
  if (!t3.length) return;
5193
5198
  let n3 = (e4) => {
5194
5199
  let n4 = qg(e4, st2), r2 = ([e5, t4]) => t4 <= Wg(n4, e5), i2 = [...t3.filter(r2), ...t3.filter((e5) => !r2(e5))];
5195
5200
  for (let [e5, t4] of i2) {
5196
- let r3 = Wg(n4, e5), i3 = ob(t4, { previous: r3, others: Gg(n4) - r3 }, at2);
5201
+ let r3 = Wg(n4, e5), i3 = sb(t4, { previous: r3, others: Gg(n4) - r3 }, at2);
5197
5202
  i3 !== r3 && (n4 = Kg(n4, e5, i3));
5198
5203
  }
5199
5204
  return n4;
@@ -5211,7 +5216,7 @@ function yb({ servicePromise: e2, refreshSignal: t2 = 0, injected: n2, reschedul
5211
5216
  return n3 ? (ge2.current = n3, he2(n3), true) : false;
5212
5217
  }, []), mt2 = i((e3, t3) => pt2((n3) => n_(n3, e3, t3, Wd())), [pt2]), ht2 = i(() => {
5213
5218
  pt2(i_);
5214
- }, [pt2]), gt2 = qe2.serviceCtaState, _t2 = s(() => h2 ? rb(me2 ?? Cg(ze2), te2()) : null, [h2, me2, ze2, te2]), vt2 = i((e3) => {
5219
+ }, [pt2]), gt2 = qe2.serviceCtaState, _t2 = s(() => h2 ? ib(me2 ?? Cg(ze2), te2()) : null, [h2, me2, ze2, te2]), vt2 = i((e3) => {
5215
5220
  if (h2) return _t2 ? b2(_t2) : null;
5216
5221
  let t3 = Yv({ actionState: gt2, serviceType: f2?.type ?? null, config: e3 ?? Jv });
5217
5222
  if (Xv(t3, f2?.type ?? null, le2)) return null;
@@ -5229,9 +5234,9 @@ function yb({ servicePromise: e2, refreshSignal: t2 = 0, injected: n2, reschedul
5229
5234
  }, (e4) => {
5230
5235
  ma(e4, { feature: fa.serviceCta, action: `navigateToNextPage` }), Ct2();
5231
5236
  });
5232
- }, [v2, Ct2, b2]), Tt2 = i(() => yt2.open(mm(s_({ service: f2, pricingOption: ot2 ?? void 0, selection: nb(A2 ?? ``, w2.current().searchParams), multiServiceAppointmentsEnabled: ke2 }))), [yt2, f2, ot2, A2, ke2]), Et2 = i((e3) => {
5237
+ }, [v2, Ct2, b2]), Tt2 = i(() => yt2.open(mm(s_({ service: f2, pricingOption: ot2 ?? void 0, selection: rb(A2 ?? ``, w2.current().searchParams), multiServiceAppointmentsEnabled: ke2 }))), [yt2, f2, ot2, A2, ke2]), Et2 = i((e3) => {
5233
5238
  if (St2.current) return;
5234
- let t3 = ge2.current ?? Cg(w2.current().searchParams.get(Y.blob)), n3 = rb(t3, te2());
5239
+ let t3 = ge2.current ?? Cg(w2.current().searchParams.get(Y.blob)), n3 = ib(t3, te2());
5235
5240
  if (n3) {
5236
5241
  for (let n4 of t3?.services ?? []) e3(gf({ serviceId: n4.serviceId, serviceType: n4.serviceType ?? g2.find(({ _id: e4 }) => e4 === n4.serviceId)?.type ?? void 0, start: n4.slotStart, end: n4.slotEnd, timeZone: t3?.timezone ?? void 0, isEligibleForFlowCompletion: true }));
5237
5242
  wt2(n3);
@@ -5257,49 +5262,49 @@ function yb({ servicePromise: e2, refreshSignal: t2 = 0, injected: n2, reschedul
5257
5262
  kt2.current = Ot2;
5258
5263
  let At2 = i(async () => {
5259
5264
  let e3 = ye2?.status === `ready` ? ye2.booking : null;
5260
- if (!ye2 || !a2 || !e3 || !Uy(O2.current, kt2.current())) return { outcome: `failed` };
5265
+ if (!ye2 || !a2 || !e3 || !Wy(O2.current, kt2.current())) return { outcome: `failed` };
5261
5266
  x2(pf({ component: of.RESCHEDULE_DIALOG, element: sf.CONFIRM_BUTTON })), x2(Qd({ action: af, pageName: sf.CONFIRM_BUTTON, referralInfo: w2.current().searchParams.get(Y.referral) ?? void 0 }));
5262
5267
  let t3 = Lg(O2.current, Xe2.current), n3;
5263
5268
  try {
5264
- n3 = await Fy({ booking: e3, slot: Dy(t3, de2.current ?? null, e3, pe2.current), token: a2.token });
5269
+ n3 = await Iy({ booking: e3, slot: Dy(t3, de2.current ?? null, e3, pe2.current), token: a2.token });
5265
5270
  } catch (e4) {
5266
5271
  return ma(e4, { feature: fa.reschedule, action: `reschedule-booking` }), { outcome: `failed` };
5267
5272
  }
5268
5273
  x2(ff({ bookingId: e3.bookingId }));
5269
5274
  let r2 = { outcome: `succeeded`, ...n3 };
5270
5275
  if (a2.fromManageBookingPage) return r2;
5271
- let i2 = Hy(a2.redirectUrl), o2 = i2 ? null : ne2();
5276
+ let i2 = Uy(a2.redirectUrl), o2 = i2 ? null : ne2();
5272
5277
  if (!i2 && !o2) return r2;
5273
5278
  try {
5274
5279
  return i2 ? await ee2({ href: i2 }) : o2 && await v2(o2), { outcome: `navigated` };
5275
5280
  } catch (e4) {
5276
5281
  return ma(e4, { feature: fa.reschedule, action: `return-after-reschedule` }), r2;
5277
5282
  }
5278
- }, [ye2, a2, ne2, v2, ee2, x2]), jt2 = Uy(le2, Ot2()), Mt2 = i(() => {
5283
+ }, [ye2, a2, ne2, v2, ee2, x2]), jt2 = Wy(le2, Ot2()), Mt2 = i(() => {
5279
5284
  x2(Qd({ component: sf.GO_TO_HOMEPAGE_BUTTON, action: af, pageName: cf })), v2(`/`).catch((e3) => ma(e3, { feature: fa.reschedule, action: `go-home` }));
5280
5285
  }, [v2, x2]), { serviceBookability: Nt2, policyDescription: Pt2, coverImage: Ft2 } = qe2, It2 = i(() => Nt2.isAvailableForBooking, [Nt2]), Lt2 = i(() => !!Pt2, [Pt2]), Rt2 = i(() => !!Ft2, [Ft2]), zt2 = i(() => Dp(f2), [f2]), Bt2 = i(() => !!f2 && om(f2), [f2]), Vt2 = s(() => ({ ...qe2, service: f2, servicePageLink: Se2, serviceOptionsAndVariants: Re2, pricingOption: ot2, isLoadingServiceOptionsAndVariants: Le2, isAvailableForBooking: It2, hasPolicyDescription: Lt2, hasCoverImage: Rt2, hasGalleryImages: zt2, isVariantDuration: Bt2, isLoading: false, hasError: m2, locale: _2, selectStaffMember: F2, clearSelection: I2, clearStaffMember: rt2, selection: le2, selectionTimezone: de2.current ?? Ee2, setVariant: it2, setVariantCounts: ct2, maxParticipantsPerBooking: at2.max, toggleAddOn: lt2, setAddOnQuantity: ut2, setSlot: dt2, clearSlot: ft2, setMultiServiceSlot: mt2, clearMultiServiceSlot: ht2, draftRevision: _e2, wantsPromoCode: et2, setWantsPromoCode: tt2, withSelectionParam: Ze2, navigateToNextPage: Dt2, navigateToMultiServiceForm: Et2, resolveNextPageHref: vt2, isNavigating: bt2, openPreferences: Tt2, multiServiceAppointmentsEnabled: ke2, isMultiServiceAppointment: h2, multiServiceAppointmentServices: g2, multiServiceAppointmentOptionsAndVariants: Ke2, multiServiceAppointmentVariantsStatus: j2, bookingsSettingsLoading: Oe2, reschedule: ye2, rescheduleBooking: At2, goHomeAfterReschedule: Mt2, canRescheduleToPick: jt2 }), [qe2, f2, Se2, Re2, ot2, Le2, It2, Lt2, Rt2, zt2, Bt2, m2, _2, F2, I2, rt2, le2, Ee2, it2, ct2, at2.max, lt2, ut2, dt2, ft2, mt2, ht2, _e2, et2, tt2, Ze2, Dt2, Et2, vt2, bt2, Tt2, ke2, h2, g2, Ke2, j2, Oe2, ye2, At2, Mt2, jt2]);
5281
- return p(Yy.Provider, { value: Vt2, children: u2 });
5286
+ return p(Xy.Provider, { value: Vt2, children: u2 });
5282
5287
  }
5283
- function bb({ pathname: e2, initialServiceId: t2, refreshSignal: n2, editingSurface: r2, children: i2 }) {
5288
+ function xb({ pathname: e2, initialServiceId: t2, refreshSignal: n2, editingSurface: r2, children: i2 }) {
5284
5289
  uf($d.SERVICE);
5285
5290
  let a2 = v_(), { getParsedUrl: o2 } = Oa(), [s2] = l(() => r2 ? null : Ey(o2().searchParams)), [c2] = l(() => {
5286
- let r3 = Qy(Md(e2), s2 ? null : ay(o2().searchParams), t2);
5287
- return r3.by === `none` ? Aa(ub) : r3.by === `multi` ? Ma(I_({ key: S_(r3.serviceIds), refresh: n2 !== 0, warmupData: a2, fetchData: () => ha(`service-context-load-multi-service`, { feature: fa.service }, Ld(r3.serviceIds)) }), db, fb) : Ma(I_({ key: x_(r3.by, r3.value), refresh: n2 !== 0, warmupData: a2, fetchData: () => ha(`service-context-load`, { feature: fa.service }, r3.by === `slug` ? Fd(r3.value) : Id(r3.value)) }), cb, lb);
5291
+ let r3 = $y(Md(e2), s2 ? null : ay(o2().searchParams), t2);
5292
+ return r3.by === `none` ? Aa(db) : r3.by === `multi` ? Ma(I_({ key: S_(r3.serviceIds), refresh: n2 !== 0, warmupData: a2, fetchData: () => ha(`service-context-load-multi-service`, { feature: fa.service }, Ld(r3.serviceIds)) }), fb, pb) : Ma(I_({ key: x_(r3.by, r3.value), refresh: n2 !== 0, warmupData: a2, fetchData: () => ha(`service-context-load`, { feature: fa.service }, r3.by === `slug` ? Fd(r3.value) : Id(r3.value)) }), lb, ub);
5288
5293
  });
5289
- return p(hb, { servicePromise: c2, refreshSignal: n2, rescheduleRequest: s2, children: i2 });
5294
+ return p(gb, { servicePromise: c2, refreshSignal: n2, rescheduleRequest: s2, children: i2 });
5290
5295
  }
5291
- function xb({ serviceData: e2, servicePicker: t2, refreshSignal: n2 = 0, editingSurface: r2 = false, children: i2 }) {
5292
- let { pathname: a2 } = Oa(), o2 = t2?.serviceId?.$eq, c2 = e2?.service ?? null, l2 = s(() => c2 ? { service: c2, masterEvents: e2?.masterEvents ?? ib, serviceOptionsAndVariants: e2?.serviceOptionsAndVariants ?? null, bookingsSettings: e2?.bookingsSettings } : null, [c2, e2?.masterEvents, e2?.serviceOptionsAndVariants, e2?.bookingsSettings]);
5293
- return l2 ? p(hb, { injected: l2, bookingsSettings: l2.bookingsSettings, children: i2 }, `injected:${n2}`) : e2 ? p(hb, { bookingsSettings: e2.bookingsSettings, children: i2 }) : p(bb, { pathname: a2, initialServiceId: o2, refreshSignal: n2, editingSurface: r2, children: i2 }, `fetch:${a2}:${o2 ?? ``}:${n2}:${r2}`);
5296
+ function Sb({ serviceData: e2, servicePicker: t2, refreshSignal: n2 = 0, editingSurface: r2 = false, children: i2 }) {
5297
+ let { pathname: a2 } = Oa(), o2 = t2?.serviceId?.$eq, c2 = e2?.service ?? null, l2 = s(() => c2 ? { service: c2, masterEvents: e2?.masterEvents ?? ab, serviceOptionsAndVariants: e2?.serviceOptionsAndVariants ?? null, bookingsSettings: e2?.bookingsSettings } : null, [c2, e2?.masterEvents, e2?.serviceOptionsAndVariants, e2?.bookingsSettings]);
5298
+ return l2 ? p(gb, { injected: l2, bookingsSettings: l2.bookingsSettings, children: i2 }, `injected:${n2}`) : e2 ? p(gb, { bookingsSettings: e2.bookingsSettings, children: i2 }) : p(xb, { pathname: a2, initialServiceId: o2, refreshSignal: n2, editingSurface: r2, children: i2 }, `fetch:${a2}:${o2 ?? ``}:${n2}:${r2}`);
5294
5299
  }
5295
- var Sb = ea;
5300
+ var Cb = ea;
5296
5301
  export {
5297
- Xy as SERVICE_CONTEXT_MISSING_PROVIDER_ERROR,
5298
- xb as ServiceContextProvider,
5299
- xb as default,
5300
- Sb as injectAccessTokenGetter,
5301
- Qy as resolveServiceTarget,
5302
- Yy as serviceContext,
5303
- Zy as useServiceContext
5302
+ Zy as SERVICE_CONTEXT_MISSING_PROVIDER_ERROR,
5303
+ Sb as ServiceContextProvider,
5304
+ Sb as default,
5305
+ Cb as injectAccessTokenGetter,
5306
+ $y as resolveServiceTarget,
5307
+ Xy as serviceContext,
5308
+ Qy as useServiceContext
5304
5309
  };
5305
5310
  //# sourceMappingURL=context-service-context.mjs.map