@loczer/storefront-sdk 0.229.0 → 0.231.0

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/dist/StorefrontContext.d.ts +0 -2
  2. package/dist/StorefrontContext.d.ts.map +1 -1
  3. package/dist/StorefrontProvider.d.ts +0 -1
  4. package/dist/StorefrontProvider.d.ts.map +1 -1
  5. package/dist/chunks/pkg/booking-engine/dist/schemas/{base-booking-C9kJFMIu.js → base-booking-BJXFzDM5.js} +0 -2
  6. package/dist/chunks/pkg/booking-engine/dist/schemas/{cart-inputs-epi7FXIk.js → cart-inputs-3lBblkB0.js} +0 -10
  7. package/dist/chunks/pkg/booking-engine/dist/{schemas-DW5gdDYz.js → schemas-JjiUWFIv.js} +2 -2
  8. package/dist/components/BookingBikeQuickAddCard/index.d.ts +3 -1
  9. package/dist/components/BookingBikeQuickAddCard/index.d.ts.map +1 -1
  10. package/dist/components/BookingBikeQuickAddCard/index.js +97 -85
  11. package/dist/components/BookingBikeVariantDialog/index.d.ts.map +1 -1
  12. package/dist/components/BookingBikeVariantDialog/index.js +9 -7
  13. package/dist/components/ContractSaleDocument/InvoiceDetails.d.ts.map +1 -1
  14. package/dist/components/ContractSaleDocument/InvoiceDetails.js +126 -138
  15. package/dist/components/Footer/businessHoursStatus.js +1 -1
  16. package/dist/components/LanguageSelector/index.js +1 -1
  17. package/dist/components/StorefrontCartPanel/index.js +1 -1
  18. package/dist/i18n/en.d.ts +1 -4
  19. package/dist/i18n/en.d.ts.map +1 -1
  20. package/dist/i18n/en.js +2 -5
  21. package/dist/i18n/fr.d.ts +1 -4
  22. package/dist/i18n/fr.d.ts.map +1 -1
  23. package/dist/i18n/fr.js +3 -6
  24. package/dist/index.d.ts +14 -35
  25. package/dist/index.js +3 -3
  26. package/dist/lib/booking-period.js +1 -1
  27. package/dist/lib/booking.d.ts +6 -6
  28. package/dist/lib/booking.d.ts.map +1 -1
  29. package/dist/lib/booking.js +21 -21
  30. package/dist/lib/checkoutSubmit.d.ts +2 -6
  31. package/dist/lib/checkoutSubmit.d.ts.map +1 -1
  32. package/dist/lib/checkoutSubmit.js +3 -11
  33. package/dist/lib/pricing.js +1 -1
  34. package/dist/lib/storefrontAvailability.d.ts +12 -8
  35. package/dist/lib/storefrontAvailability.d.ts.map +1 -1
  36. package/dist/lib/storefrontAvailability.js +17 -7
  37. package/dist/pages/BookingPage.d.ts.map +1 -1
  38. package/dist/pages/BookingPage.js +202 -204
  39. package/dist/pages/CheckoutPage.d.ts.map +1 -1
  40. package/dist/pages/CheckoutPage.js +23 -25
  41. package/dist/pages/HomePage.js +8 -8
  42. package/dist/pages/ProductPage.d.ts.map +1 -1
  43. package/dist/pages/ProductPage.js +187 -181
  44. package/dist/pages/checkout/components/CheckoutDetailsCard.d.ts.map +1 -1
  45. package/dist/pages/checkout/components/CheckoutDetailsCard.js +4 -17
  46. package/dist/pages/checkout/types.d.ts +1 -2
  47. package/dist/pages/checkout/types.d.ts.map +1 -1
  48. package/dist/pages/checkout/types.js +1 -2
  49. package/dist/storefront.css +1 -1
  50. package/dist/storefrontSchemas.d.ts +0 -2
  51. package/dist/storefrontSchemas.d.ts.map +1 -1
  52. package/dist/storefrontSchemas.js +1 -2
  53. package/package.json +1 -1
@@ -1,16 +1,16 @@
1
1
  import { applyBookingParamsToSearch as e, createBookingPeriodConfigFromStorefrontConfiguration as t, getBookingParamsFromSearch as n, getDefaultBookingParamsForStorefrontConfiguration as r, pickBookingSearchParams as i, resolveBookingSearchParamsFromSessionStorage as a, writeBookingSearchParamsToSessionStorage as ee } from "../lib/booking.js";
2
2
  import { getLocalizedValue as o } from "../localization.js";
3
- import { getStorefrontCheckoutProductId as s, getStorefrontProductSelectionDisplayName as te } from "../lib/products.js";
4
- import { useStorefrontCart as ne } from "../lib/cart.js";
5
- import { calculateBookingRentalUnitSummary as re, getPricingUnitLabel as ie } from "../lib/pricing.js";
6
- import { buildStorefrontCartSummary as ae } from "../lib/cartSummary.js";
7
- import { ROUTE as oe, buildStorefrontAvailabilityKey as c, getStorefrontAvailabilityIssue as se, getStorefrontAvailabilityStatus as l, getValidStorefrontAvailabilitySchedule as u, isStorefrontAvailabilityInsufficient as ce, responseSchema as le } from "../lib/storefrontAvailability.js";
3
+ import { getStorefrontCheckoutProductId as s, getStorefrontProductSelectionDisplayName as c } from "../lib/products.js";
4
+ import { useStorefrontCart as te } from "../lib/cart.js";
5
+ import { calculateBookingRentalUnitSummary as ne, getPricingUnitLabel as re } from "../lib/pricing.js";
6
+ import { buildStorefrontCartSummary as ie } from "../lib/cartSummary.js";
7
+ import { ROUTE as ae, buildStorefrontAvailabilityKey as l, getStorefrontAvailabilityIssue as oe, getStorefrontAvailabilityStatus as se, getStorefrontProductAvailabilityStatus as u, getValidStorefrontAvailabilitySchedule as d, isStorefrontAvailabilityInsufficient as ce, responseSchema as le } from "../lib/storefrontAvailability.js";
8
8
  import { Badge as ue } from "../ui/badge.js";
9
9
  import { Button as de } from "../ui/button.js";
10
10
  import { useStorefront as fe, useStorefrontBookingProducts as pe, useStorefrontProducts as me } from "../StorefrontContext.js";
11
11
  import { toast as he } from "../lib/toast.js";
12
12
  import { BookingPeriodSelector as ge } from "../components/BookingPeriodSelector/index.js";
13
- import { StepSectionTitle as d } from "../components/StepSectionTitle/index.js";
13
+ import { StepSectionTitle as f } from "../components/StepSectionTitle/index.js";
14
14
  import { Card as _e } from "../ui/card.js";
15
15
  import { ProductWarningNotice as ve } from "../components/ProductWarningNotice/index.js";
16
16
  import { StorefrontCartPanel as ye } from "../components/StorefrontCartPanel/index.js";
@@ -22,23 +22,23 @@ import { FulfillmentSection as we } from "../components/FulfillmentSection/index
22
22
  import { BookingFlowPageLayout as Te } from "../components/BookingFlowPageLayout/index.js";
23
23
  import { BookingBikeQuickAddCard as Ee } from "../components/BookingBikeQuickAddCard/index.js";
24
24
  import { BookingBikeVariantDialog as De } from "../components/BookingBikeVariantDialog/index.js";
25
- import { useEffect as f, useLayoutEffect as Oe, useMemo as p, useRef as m, useState as h } from "react";
26
- import { Fragment as ke, jsx as g, jsxs as _ } from "react/jsx-runtime";
25
+ import { useEffect as p, useLayoutEffect as Oe, useMemo as m, useRef as h, useState as g } from "react";
26
+ import { Fragment as ke, jsx as _, jsxs as v } from "react/jsx-runtime";
27
27
  import { Link as Ae, useLocation as je, useParams as Me, useSearchParams as Ne } from "@rpcbase/router";
28
28
  import { useTranslation as Pe } from "react-i18next";
29
29
  import { cn as Fe } from "@rpcbase/ui";
30
30
  import { Bike as Ie, Plus as Le } from "lucide-react";
31
31
  //#region src/pages/BookingPage.tsx
32
- var v = (e) => String(e).padStart(2, "0"), y = "product_modal", Re = (e, t) => {
32
+ var y = (e) => String(e).padStart(2, "0"), b = "product_modal", Re = (e, t) => {
33
33
  let n = t - e;
34
34
  return e >= 0 && (n === 1 || n === 2) ? n : null;
35
- }, ze = (e) => `${e.getFullYear()}-${v(e.getMonth() + 1)}-${v(e.getDate())}`, Be = (e) => {
35
+ }, ze = (e) => `${e.getFullYear()}-${y(e.getMonth() + 1)}-${y(e.getDate())}`, Be = (e) => {
36
36
  if (!e) return;
37
37
  let t = e.match(/^(\d{4})-(\d{2})-(\d{2})$/);
38
38
  if (!t) return;
39
39
  let n = Number(t[1]), r = Number(t[2]), i = Number(t[3]), a = new Date(n, r - 1, i);
40
40
  if (!(Number.isNaN(a.getTime()) || a.getFullYear() !== n || a.getMonth() !== r - 1 || a.getDate() !== i)) return a;
41
- }, b = (e, t) => e.fulfillment === t.fulfillment && e.start_date === t.start_date && e.start_time === t.start_time && e.end_date === t.end_date && e.end_time === t.end_time && e.start_address === t.start_address && e.end_address === t.end_address, x = (e, t = () => !0) => {
41
+ }, x = (e, t) => e.fulfillment === t.fulfillment && e.startDate === t.startDate && e.startTime === t.startTime && e.endDate === t.endDate && e.endTime === t.endTime && e.startAddress === t.startAddress && e.endAddress === t.endAddress, S = (e, t = () => !0) => {
42
42
  if (e.representedVariantId?.trim()) return e.representedVariantId.trim();
43
43
  let n = e.productVariants ?? [], r = n.find((e) => t(e.id))?.id ?? n[0]?.id;
44
44
  return typeof r == "string" && r.trim().length > 0 ? r : null;
@@ -46,49 +46,51 @@ var v = (e) => String(e).padStart(2, "0"), y = "product_modal", Re = (e, t) => {
46
46
  ...e,
47
47
  fulfillment: "pickup"
48
48
  } : e, He = (e, t) => {
49
- let n = s(e), r = e.representedVariantId?.trim();
50
- if (r) {
51
- let e = t.get(c(n, r));
52
- if (e) return e;
53
- }
54
- return t.get(c(n));
55
- }, Ue = (e, t, n) => n.get(c(s(e), t)), We = (e, t, n) => {
56
- let r = se(t);
57
- return r === "quantity_unavailable" ? e("availability_quantity_unavailable") : r === "unavailable" || n === "OUT_OF_STOCK" ? e("availability_out_of_stock") : t?.remaining === void 0 ? t?.fewRemaining || n === "LOW_STOCK" ? e("availability_low_stock") : e("availability_in_stock") : e("availability_remaining_count", { count: t.remaining });
49
+ let n = s(e);
50
+ return u({
51
+ availabilityByKey: t,
52
+ fallbackStatus: e.availabilityStatus ?? "AVAILABLE",
53
+ productId: n,
54
+ productVariantIds: (e.productVariants ?? []).map((e) => e.id),
55
+ representedVariantId: e.representedVariantId
56
+ });
57
+ }, Ue = (e, t, n) => n.get(l(s(e), t)), We = (e, t, n) => {
58
+ let r = oe(t);
59
+ return r === "quantityUnavailable" ? e("availability_quantity_unavailable") : r === "unavailable" || n === "OUT_OF_STOCK" ? e("availability_out_of_stock") : t?.remaining === void 0 ? t?.fewRemaining || n === "LOW_STOCK" ? e("availability_low_stock") : e("availability_in_stock") : e("availability_remaining_count", { count: t.remaining });
58
60
  }, Ge = (e) => {
59
61
  let t = /* @__PURE__ */ new Map();
60
62
  for (let n of e) {
61
63
  let e = s(n);
62
- t.set(c(e), { productId: e });
63
- for (let r of n.productVariants ?? []) t.set(c(e, r.id), {
64
+ t.set(l(e), { productId: e });
65
+ for (let r of n.productVariants ?? []) t.set(l(e, r.id), {
64
66
  productId: e,
65
67
  productVariantId: r.id
66
68
  });
67
69
  let r = n.representedVariantId?.trim();
68
- r && t.set(c(e, r), {
70
+ r && t.set(l(e, r), {
69
71
  productId: e,
70
72
  productVariantId: r
71
73
  });
72
74
  }
73
75
  return Array.from(t.values());
74
76
  };
75
- function S() {
76
- let { t: v, i18n: S } = Pe(), { storeSlug: C } = Me(), w = je(), Ke = m(null), { storefrontConfiguration: T } = fe(), E = T.workspace?.workspaceLanguage, { bikes: qe, accessories: Je } = me(), { bikes: D, accessories: O } = pe(), [k, A] = Ne(), { items: Ye, itemCount: Xe, addItem: Ze, removeItem: Qe, setQuantity: $e } = ne();
77
+ function C() {
78
+ let { t: u, i18n: y } = Pe(), { storeSlug: C } = Me(), w = je(), Ke = h(null), { storefrontConfiguration: T } = fe(), E = T.workspace?.workspaceLanguage, { bikes: qe, accessories: Je } = me(), { bikes: D, accessories: O } = pe(), [k, A] = Ne(), { items: Ye, itemCount: Xe, addItem: Ze, removeItem: Qe, setQuantity: $e } = te();
77
79
  Oe(() => {
78
80
  w.hash === "#booking-products" && Ke.current?.scrollIntoView({ block: "start" });
79
81
  }, [w.hash]);
80
- let et = p(() => t(T), [T]), j = p(() => r(T), [T]), M = T.settings.fulfillmentModes.includes("delivery"), tt = T.settings.deliveryDisabledReason.trim(), nt = T.shop.address?.trim() ?? "", N = T.bookingEngine.pricing.baseUnit, rt = ie(N, v), it = i(k).toString(), P = p(() => a(new URLSearchParams(it), C), [it, C]), [F, I] = h(() => ({
82
+ let et = m(() => t(T), [T]), j = m(() => r(T), [T]), M = T.settings.fulfillmentModes.includes("delivery"), tt = T.settings.deliveryDisabledReason.trim(), nt = T.shop.address?.trim() ?? "", N = T.bookingEngine.pricing.baseUnit, rt = re(N, u), it = i(k).toString(), P = m(() => a(new URLSearchParams(it), C), [it, C]), [F, I] = g(() => ({
81
83
  booking: Ve(n(P, j), M),
82
84
  shouldWriteToUrl: !0
83
- })), L = F.booking, R = p(() => Be(L.start_date), [L.start_date]), at = p(() => Be(L.end_date) ?? R, [L.end_date, R]), [ot, st] = h(void 0), ct = m(void 0), lt = m(""), ut = [
84
- L.start_date,
85
- L.start_time,
86
- L.end_date,
87
- L.end_time
85
+ })), L = F.booking, R = m(() => Be(L.startDate), [L.startDate]), at = m(() => Be(L.endDate) ?? R, [L.endDate, R]), [ot, st] = g(void 0), ct = h(void 0), lt = h(""), ut = [
86
+ L.startDate,
87
+ L.startTime,
88
+ L.endDate,
89
+ L.endTime
88
90
  ].join(":");
89
91
  lt.current = ut;
90
- let z = ot === ut, B = z ? L.start_time : "", V = z ? L.end_time : "", H = !z && k.get("start_date") === L.start_date && k.get("start_time") === L.start_time && k.get("end_date") === L.end_date && k.get("end_time") === L.end_time;
91
- f(() => {
92
+ let z = ot === ut, B = z ? L.startTime : "", V = z ? L.endTime : "", H = !z && k.get("start_date") === L.startDate && k.get("start_time") === L.startTime && k.get("end_date") === L.endDate && k.get("end_time") === L.endTime;
93
+ p(() => {
92
94
  I((e) => {
93
95
  if (e.shouldWriteToUrl) return e;
94
96
  let t = {
@@ -96,7 +98,7 @@ function S() {
96
98
  ...e.booking
97
99
  }, r = Ve(n(P, t), M);
98
100
  return {
99
- booking: b(e.booking, r) ? e.booking : r,
101
+ booking: x(e.booking, r) ? e.booking : r,
100
102
  shouldWriteToUrl: !0
101
103
  };
102
104
  });
@@ -104,12 +106,12 @@ function S() {
104
106
  P,
105
107
  j,
106
108
  M
107
- ]), f(() => {
109
+ ]), p(() => {
108
110
  if (!F.shouldWriteToUrl) return;
109
111
  let t = e(k, {
110
112
  ...L,
111
- start_time: H ? L.start_time : B,
112
- end_time: H ? L.end_time : V
113
+ startTime: H ? L.startTime : B,
114
+ endTime: H ? L.endTime : V
113
115
  });
114
116
  if (t.toString() === k.toString()) {
115
117
  I((e) => e.shouldWriteToUrl ? {
@@ -127,11 +129,11 @@ function S() {
127
129
  B,
128
130
  k,
129
131
  A
130
- ]), f(() => {
132
+ ]), p(() => {
131
133
  ee(C, {
132
134
  ...L,
133
- start_time: B,
134
- end_time: V
135
+ startTime: B,
136
+ endTime: V
135
137
  });
136
138
  }, [
137
139
  L,
@@ -139,13 +141,13 @@ function S() {
139
141
  B,
140
142
  C
141
143
  ]);
142
- let U = p(() => Ge([...D, ...O]), [O, D]), [dt, W] = h([]);
143
- f(() => {
144
+ let U = m(() => Ge([...D, ...O]), [O, D]), [dt, W] = g([]);
145
+ p(() => {
144
146
  if (!C || U.length === 0) {
145
147
  W([]);
146
148
  return;
147
149
  }
148
- let e = z ? u(L) : null;
150
+ let e = z ? d(L) : null;
149
151
  if (!e) {
150
152
  W([]);
151
153
  return;
@@ -153,7 +155,7 @@ function S() {
153
155
  let t = !1;
154
156
  return (async () => {
155
157
  try {
156
- let n = await Se(oe, {
158
+ let n = await Se(ae, {
157
159
  storeSlug: C,
158
160
  schedule: e,
159
161
  products: U
@@ -169,77 +171,71 @@ function S() {
169
171
  };
170
172
  }, [
171
173
  U,
172
- L.end_date,
173
- L.end_time,
174
- L.start_date,
175
- L.start_time,
174
+ L.endDate,
175
+ L.endTime,
176
+ L.startDate,
177
+ L.startTime,
176
178
  z,
177
179
  C
178
180
  ]);
179
- let G = p(() => new Map(dt.map((e) => [c(e.productId, e.productVariantId), e])), [dt]), K = p(() => D.map((e) => {
180
- let t = He(e, G);
181
- return {
182
- ...e,
183
- availabilityStatus: t ? l(t) : e.availabilityStatus ?? "AVAILABLE"
184
- };
185
- }), [G, D]), ft = p(() => O.map((e) => {
186
- let t = He(e, G);
187
- return {
188
- ...e,
189
- availabilityStatus: t ? l(t) : "AVAILABLE"
190
- };
191
- }), [O, G]), pt = (e, t) => {
181
+ let G = m(() => new Map(dt.map((e) => [l(e.productId, e.productVariantId), e])), [dt]), K = m(() => D.map((e) => ({
182
+ ...e,
183
+ availabilityStatus: He(e, G)
184
+ })), [G, D]), ft = m(() => O.map((e) => ({
185
+ ...e,
186
+ availabilityStatus: He(e, G)
187
+ })), [O, G]), q = (e, t) => {
192
188
  let n = Ue(e, t, G);
193
189
  return n ? ce(n) : e.availabilityStatus === "OUT_OF_STOCK";
194
- }, mt = (e) => (e.productVariants ?? []).length > 0, ht = (e, t) => {
190
+ }, pt = (e) => (e.productVariants ?? []).length > 0, mt = (e, t) => {
195
191
  let n = Ue(e, t, G);
196
- return n ? We(v, n, l(n)) : e.availabilityStatus === "OUT_OF_STOCK" ? v("availability_out_of_stock") : null;
197
- }, gt = Ce(C), _t = p(() => ({
198
- startDate: v("booking_start_date"),
199
- pickStartDate: v("booking_start_date"),
200
- startTime: v("booking_start_time"),
201
- endDate: v("booking_end_date"),
202
- pickEndDate: v("booking_end_date"),
203
- endTime: v("booking_end_time"),
204
- selectedDaysTooltip: ({ count: e }) => v("booking_selected_days_tooltip", { count: e }),
205
- rentalPeriod: v("booking_rental_period"),
206
- dateDrawerNext: v("booking_date_drawer_continue"),
207
- closeDrawer: v("booking_date_drawer_close"),
208
- timeSlotsLoading: v("booking_time_slots_loading"),
209
- timeSlotsUnavailable: v("booking_time_slots_unavailable"),
210
- timeSlotsLoadError: v("booking_time_slots_load_error"),
211
- retryTimeSlots: v("booking_time_slots_retry")
212
- }), [S.language, v]), q = (e) => {
192
+ return n ? We(u, n, se(n)) : e.availabilityStatus === "OUT_OF_STOCK" ? u("availability_out_of_stock") : null;
193
+ }, ht = Ce(C), gt = m(() => ({
194
+ startDate: u("booking_start_date"),
195
+ pickStartDate: u("booking_start_date"),
196
+ startTime: u("booking_start_time"),
197
+ endDate: u("booking_end_date"),
198
+ pickEndDate: u("booking_end_date"),
199
+ endTime: u("booking_end_time"),
200
+ selectedDaysTooltip: ({ count: e }) => u("booking_selected_days_tooltip", { count: e }),
201
+ rentalPeriod: u("booking_rental_period"),
202
+ dateDrawerNext: u("booking_date_drawer_continue"),
203
+ closeDrawer: u("booking_date_drawer_close"),
204
+ timeSlotsLoading: u("booking_time_slots_loading"),
205
+ timeSlotsUnavailable: u("booking_time_slots_unavailable"),
206
+ timeSlotsLoadError: u("booking_time_slots_load_error"),
207
+ retryTimeSlots: u("booking_time_slots_retry")
208
+ }), [y.language, u]), J = (e) => {
213
209
  let t = {
214
210
  ...L,
215
211
  ...e
216
212
  };
217
- b(L, t) || I((t) => {
213
+ x(L, t) || I((t) => {
218
214
  let n = {
219
215
  ...t.booking,
220
216
  ...e
221
217
  };
222
- return b(t.booking, n) ? t : {
218
+ return x(t.booking, n) ? t : {
223
219
  booking: n,
224
220
  shouldWriteToUrl: !0
225
221
  };
226
222
  });
227
- }, vt = {
223
+ }, _t = {
228
224
  startDate: R,
229
225
  onStartDateChange: (e) => {
230
- e && q({ start_date: ze(e) });
226
+ e && J({ startDate: ze(e) });
231
227
  },
232
- startTime: L.start_time,
233
- onStartTimeChange: (e) => q({ start_time: e }),
228
+ startTime: L.startTime,
229
+ onStartTimeChange: (e) => J({ startTime: e }),
234
230
  endDate: at,
235
231
  onEndDateChange: (e) => {
236
- e && q({ end_date: ze(e) });
232
+ e && J({ endDate: ze(e) });
237
233
  },
238
- endTime: L.end_time,
239
- onEndTimeChange: (e) => q({ end_time: e }),
234
+ endTime: L.endTime,
235
+ onEndTimeChange: (e) => J({ endTime: e }),
240
236
  bookingPeriodConfig: et,
241
237
  withMobileDateDrawer: !0,
242
- fetchTimeSlots: gt,
238
+ fetchTimeSlots: ht,
243
239
  onTimeSlotsConfirmationChange: (e) => {
244
240
  let t = e ? lt.current : void 0;
245
241
  ct.current !== t && (ct.current = t, I((e) => e.shouldWriteToUrl ? e : {
@@ -247,51 +243,51 @@ function S() {
247
243
  shouldWriteToUrl: !0
248
244
  }), st(t));
249
245
  },
250
- labels: _t,
251
- localeCode: S.language
252
- }, yt = re(L, T.bookingEngine.pricing, T.bookingEngine.shop.timeZone)?.billableUnitCount, J = p(() => ae({
246
+ labels: gt,
247
+ localeCode: y.language
248
+ }, vt = ne(L, T.bookingEngine.pricing, T.bookingEngine.shop.timeZone)?.billableUnitCount, Y = m(() => ie({
253
249
  items: Ye,
254
- language: S.language,
250
+ language: y.language,
255
251
  fallbackLanguage: E,
256
252
  products: {
257
253
  bikes: qe,
258
254
  accessories: Je
259
255
  },
260
256
  priceUnit: N,
261
- billableUnitCount: yt
257
+ billableUnitCount: vt
262
258
  }), [
263
- yt,
259
+ vt,
264
260
  Je,
265
261
  qe,
266
- S.language,
262
+ y.language,
267
263
  Ye,
268
264
  N,
269
265
  E
270
- ]), Y = p(() => J.lines.map((e) => ({
266
+ ]), X = m(() => Y.lines.map((e) => ({
271
267
  productId: e.checkoutProductId,
272
268
  productVariantId: e.productVariantId,
273
269
  quantity: e.quantity
274
- })), [J.lines]), [bt, xt] = h([]);
275
- f(() => {
276
- if (!C || Y.length === 0) {
277
- xt([]);
270
+ })), [Y.lines]), [yt, bt] = g([]);
271
+ p(() => {
272
+ if (!C || X.length === 0) {
273
+ bt([]);
278
274
  return;
279
275
  }
280
- let e = z ? u(L) : null;
276
+ let e = z ? d(L) : null;
281
277
  if (!e) {
282
- xt([]);
278
+ bt([]);
283
279
  return;
284
280
  }
285
281
  let t = !1;
286
282
  return (async () => {
287
283
  try {
288
- let n = await Se(oe, {
284
+ let n = await Se(ae, {
289
285
  storeSlug: C,
290
286
  schedule: e,
291
- products: Y
287
+ products: X
292
288
  }), r = le.parse(n);
293
289
  if (t) return;
294
- xt(r.success ? r.availability ?? [] : []);
290
+ bt(r.success ? r.availability ?? [] : []);
295
291
  } catch (e) {
296
292
  if (t) return;
297
293
  console.error("Failed to load storefront cart availability", e);
@@ -300,54 +296,54 @@ function S() {
300
296
  t = !0;
301
297
  };
302
298
  }, [
303
- L.end_date,
304
- L.end_time,
305
- L.start_date,
306
- L.start_time,
299
+ L.endDate,
300
+ L.endTime,
301
+ L.startDate,
302
+ L.startTime,
307
303
  z,
308
- Y,
304
+ X,
309
305
  C
310
306
  ]);
311
- let St = p(() => new Map(bt.map((e) => [c(e.productId, e.productVariantId), e])), [bt]), Ct = p(() => ({
312
- ...J,
313
- lines: J.lines.map((e) => {
314
- let t = St.get(c(e.checkoutProductId, e.productVariantId)), n = t ? se(t) : e.availabilityStatus === "OUT_OF_STOCK" ? "unavailable" : void 0;
307
+ let xt = m(() => new Map(yt.map((e) => [l(e.productId, e.productVariantId), e])), [yt]), St = m(() => ({
308
+ ...Y,
309
+ lines: Y.lines.map((e) => {
310
+ let t = xt.get(l(e.checkoutProductId, e.productVariantId)), n = t ? oe(t) : e.availabilityStatus === "OUT_OF_STOCK" ? "unavailable" : void 0;
315
311
  return {
316
312
  ...e,
317
313
  insufficientCapacity: n !== void 0,
318
314
  availabilityIssue: n
319
315
  };
320
316
  })
321
- }), [St, J]), X = e(new URLSearchParams(), {
317
+ }), [xt, Y]), Z = e(new URLSearchParams(), {
322
318
  ...L,
323
- start_time: B,
324
- end_time: V
325
- }).toString(), Z = z && u(L) !== null, wt = `/${C ?? ""}${X ? `?${X}` : ""}`, Tt = `/${C ?? ""}/booking${X ? `?${X}` : ""}`, Et = `/${C ?? ""}/checkout${X ? `?${X}` : ""}`, Dt = { backTo: `${w.pathname}${w.search}${w.hash}` }, [Ot, kt] = h(null), At = K.findIndex((e) => e.id === Ot), jt = k.get(y)?.trim() ?? "", Q = jt ? K.find((e) => e.id === jt) ?? ft.find((e) => e.id === jt) ?? null : null, $ = (e) => {
319
+ startTime: B,
320
+ endTime: V
321
+ }).toString(), Q = z && d(L) !== null, Ct = `/${C ?? ""}${Z ? `?${Z}` : ""}`, wt = `/${C ?? ""}/booking${Z ? `?${Z}` : ""}`, Tt = `/${C ?? ""}/checkout${Z ? `?${Z}` : ""}`, Et = { backTo: `${w.pathname}${w.search}${w.hash}` }, [Dt, Ot] = g(null), kt = K.findIndex((e) => e.id === Dt), At = k.get(b)?.trim() ?? "", $ = At ? K.find((e) => e.id === At) ?? ft.find((e) => e.id === At) ?? null : null, jt = (e) => {
326
322
  let t = new URLSearchParams(k);
327
- e?.trim() ? t.set(y, e) : t.delete(y), A(t, { replace: !0 });
323
+ e?.trim() ? t.set(b, e) : t.delete(b), A(t, { replace: !0 });
328
324
  }, Mt = (e) => {
329
- x(e) && $(e.id);
325
+ S(e) && jt(e.id);
330
326
  }, Nt = (e, t, n = 1) => {
331
- if (!Z) return;
327
+ if (!Q || t && q(e, t)) return;
332
328
  let r = Math.max(1, Math.floor(n));
333
329
  Ze({
334
330
  kind: e.kind,
335
331
  productId: s(e),
336
332
  ...t ? { productVariantId: t } : {},
337
333
  quantity: r
338
- }), he.success(v("product_added_to_cart_successfully", {
334
+ }), he.success(u("product_added_to_cart_successfully", {
339
335
  quantity: r,
340
- productName: te({
336
+ productName: c({
341
337
  product: e,
342
338
  productVariantId: t,
343
- language: S.language,
339
+ language: y.language,
344
340
  fallbackLanguage: E
345
341
  })
346
342
  }));
347
343
  }, Pt = (e) => {
348
344
  Mt(e);
349
345
  }, Ft = (e) => {
350
- let t = e.productVariants ?? [], n = x(e);
346
+ let t = e.productVariants ?? [], n = S(e);
351
347
  if (n) {
352
348
  if (t.length > 1) {
353
349
  Mt(e);
@@ -356,159 +352,161 @@ function S() {
356
352
  Nt(e, n);
357
353
  }
358
354
  };
359
- return /* @__PURE__ */ _(ke, { children: [/* @__PURE__ */ g(Te, {
355
+ return /* @__PURE__ */ v(ke, { children: [/* @__PURE__ */ _(Te, {
360
356
  currentStep: "booking",
361
- bookingPath: Tt,
362
- checkoutPath: Et,
363
- checkoutEnabled: Xe > 0 && Z,
364
- backPath: wt,
365
- backLabel: v("back_to_home"),
366
- children: /* @__PURE__ */ _("div", {
357
+ bookingPath: wt,
358
+ checkoutPath: Tt,
359
+ checkoutEnabled: Xe > 0 && Q,
360
+ backPath: Ct,
361
+ backLabel: u("back_to_home"),
362
+ children: /* @__PURE__ */ v("div", {
367
363
  className: "grid gap-6 lg:grid-cols-12",
368
- children: [/* @__PURE__ */ g("div", {
364
+ children: [/* @__PURE__ */ _("div", {
369
365
  className: "min-w-0 lg:col-span-8",
370
- children: /* @__PURE__ */ _("div", {
366
+ children: /* @__PURE__ */ v("div", {
371
367
  className: "space-y-6",
372
368
  children: [
373
- /* @__PURE__ */ _("div", {
369
+ /* @__PURE__ */ v("div", {
374
370
  className: "space-y-3",
375
371
  children: [
376
- /* @__PURE__ */ g(d, {
372
+ /* @__PURE__ */ _(f, {
377
373
  stepNumber: 1,
378
- title: v("booking_summary_title")
374
+ title: u("booking_summary_title")
379
375
  }),
380
- /* @__PURE__ */ g(ge, {
381
- ...vt,
376
+ /* @__PURE__ */ _(ge, {
377
+ ..._t,
382
378
  className: "gap-3",
383
379
  labelClassName: "text-xs font-medium text-slate-700",
384
380
  inputClassName: "h-10"
385
381
  }),
386
- /* @__PURE__ */ g(we, {
382
+ /* @__PURE__ */ _(we, {
387
383
  value: L.fulfillment,
388
- onValueChange: (e) => q({ fulfillment: e }),
384
+ onValueChange: (e) => J({ fulfillment: e }),
389
385
  pickupAddress: nt,
390
386
  deliveryEnabled: M,
391
387
  deliveryDisabledReason: tt,
392
- startAddress: L.start_address,
393
- onStartAddressChange: (e) => q({ start_address: e }),
394
- endAddress: L.end_address,
395
- onEndAddressChange: (e) => q({ end_address: e }),
388
+ startAddress: L.startAddress,
389
+ onStartAddressChange: (e) => J({ startAddress: e }),
390
+ endAddress: L.endAddress,
391
+ onEndAddressChange: (e) => J({ endAddress: e }),
396
392
  showPickupAddressWhenPickupOnly: !1,
397
393
  testIdPrefix: "storefront-booking-fulfillment"
398
394
  })
399
395
  ]
400
396
  }),
401
- /* @__PURE__ */ _("div", {
397
+ /* @__PURE__ */ v("div", {
402
398
  ref: Ke,
403
399
  id: "booking-products",
404
400
  className: "space-y-2 scroll-mt-32",
405
- children: [/* @__PURE__ */ g(d, {
401
+ children: [/* @__PURE__ */ _(f, {
406
402
  stepNumber: 2,
407
- title: v("products_title")
408
- }), /* @__PURE__ */ g("p", {
403
+ title: u("products_title")
404
+ }), /* @__PURE__ */ _("p", {
409
405
  className: "text-sm text-slate-600",
410
- children: /* @__PURE__ */ g("span", { children: v("products_description") })
406
+ children: /* @__PURE__ */ _("span", { children: u("products_description") })
411
407
  })]
412
408
  }),
413
- /* @__PURE__ */ g("div", {
409
+ /* @__PURE__ */ _("div", {
414
410
  className: "grid gap-4 md:grid-cols-2",
415
411
  children: K.map((e, t) => {
416
- let n = `/${C ?? ""}/products/${e.slug}`, r = !!x(e) || mt(e);
417
- return /* @__PURE__ */ g(Ee, {
412
+ let n = `/${C ?? ""}/products/${e.slug}`, r = !!S(e) || pt(e), i = e.availabilityStatus === "OUT_OF_STOCK";
413
+ return /* @__PURE__ */ _(Ee, {
418
414
  bike: e,
419
415
  detailsPath: n,
420
- productDetailsLinkState: Dt,
416
+ productDetailsLinkState: Et,
421
417
  onAction: () => Pt(e),
422
- actionDisabled: !r || !Z,
418
+ actionDisabled: !r || !Q || i,
423
419
  fallbackLanguage: E,
424
- dimOnColumnCount: Re(At, t),
420
+ getVariantAvailabilityLabel: (t) => mt(e, t),
421
+ isVariantOutOfCapacity: (t) => q(e, t),
422
+ dimOnColumnCount: Re(kt, t),
425
423
  onQuickAdd: (t, n) => Nt(e, t, n),
426
- onHoverStart: () => kt(e.id),
424
+ onHoverStart: () => Ot(e.id),
427
425
  onHoverEnd: () => {
428
- kt((t) => t === e.id ? null : t);
426
+ Ot((t) => t === e.id ? null : t);
429
427
  },
430
428
  testId: `storefront-booking-bike-card-${e.id}`.toLowerCase()
431
429
  }, e.id);
432
430
  })
433
431
  }),
434
- /* @__PURE__ */ _("div", {
432
+ /* @__PURE__ */ v("div", {
435
433
  className: "space-y-2 pt-4",
436
- children: [/* @__PURE__ */ g(d, {
434
+ children: [/* @__PURE__ */ _(f, {
437
435
  stepNumber: 3,
438
- title: v("accessories_title")
439
- }), /* @__PURE__ */ g("p", {
436
+ title: u("accessories_title")
437
+ }), /* @__PURE__ */ _("p", {
440
438
  className: "text-sm text-slate-600",
441
- children: /* @__PURE__ */ g("span", { children: v("accessories_description") })
439
+ children: /* @__PURE__ */ _("span", { children: u("accessories_description") })
442
440
  })]
443
441
  }),
444
- /* @__PURE__ */ g("div", {
442
+ /* @__PURE__ */ _("div", {
445
443
  className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3",
446
444
  children: ft.map((e) => {
447
- let t = o(e.name, S.language, E), n = o(e.description, S.language, E), r = o(e.warning, S.language, E), i = typeof e.images?.[0] == "string" ? e.images[0].trim() : "", a = xe(e.primaryImageStyle), ee = `/${C ?? ""}/products/${e.slug}`, s = x(e), te = e.availabilityStatus === "OUT_OF_STOCK", ne = !!s || mt(e);
448
- return /* @__PURE__ */ g(_e, {
445
+ let t = o(e.name, y.language, E), n = o(e.description, y.language, E), r = o(e.warning, y.language, E), i = typeof e.images?.[0] == "string" ? e.images[0].trim() : "", a = xe(e.primaryImageStyle), ee = `/${C ?? ""}/products/${e.slug}`, s = S(e), c = e.availabilityStatus === "OUT_OF_STOCK", te = !!s || pt(e);
446
+ return /* @__PURE__ */ _(_e, {
449
447
  "data-testid": `storefront-booking-accessory-card-${e.id}`.toLowerCase(),
450
448
  className: "h-full border-slate-200 bg-white shadow-sm transition-[border-color,box-shadow] duration-200 hover:border-primary/20 hover:shadow-md",
451
- children: /* @__PURE__ */ _("div", {
449
+ children: /* @__PURE__ */ v("div", {
452
450
  className: "flex h-full flex-col gap-2 p-3",
453
451
  children: [
454
- /* @__PURE__ */ _("div", {
452
+ /* @__PURE__ */ v("div", {
455
453
  className: Fe("relative aspect-[1618/1000] overflow-hidden rounded-xl", a.className),
456
454
  style: a.style,
457
- children: [i ? /* @__PURE__ */ g("img", {
455
+ children: [i ? /* @__PURE__ */ _("img", {
458
456
  src: i,
459
457
  alt: t,
460
458
  className: "absolute inset-0 h-full w-full object-contain p-1",
461
459
  loading: "lazy"
462
- }) : /* @__PURE__ */ g("div", {
460
+ }) : /* @__PURE__ */ _("div", {
463
461
  className: "absolute inset-0 flex items-center justify-center text-slate-400",
464
- children: /* @__PURE__ */ g(Ie, {
462
+ children: /* @__PURE__ */ _(Ie, {
465
463
  className: "h-8 w-8",
466
464
  "aria-hidden": "true"
467
465
  })
468
- }), te ? /* @__PURE__ */ g(ue, {
466
+ }), c ? /* @__PURE__ */ _(ue, {
469
467
  variant: "destructive",
470
468
  className: "pointer-events-none absolute right-2 top-2 shadow-sm",
471
- children: /* @__PURE__ */ g("span", { children: v("availability_out_of_stock") })
469
+ children: /* @__PURE__ */ _("span", { children: u("availability_out_of_stock") })
472
470
  }) : null]
473
471
  }),
474
- /* @__PURE__ */ _("div", {
472
+ /* @__PURE__ */ v("div", {
475
473
  className: "flex flex-1 flex-col gap-1",
476
474
  children: [
477
- /* @__PURE__ */ _("div", {
475
+ /* @__PURE__ */ v("div", {
478
476
  className: "flex items-start justify-between gap-2",
479
- children: [/* @__PURE__ */ g("p", {
477
+ children: [/* @__PURE__ */ _("p", {
480
478
  className: "min-w-0 text-sm font-semibold text-slate-950",
481
- children: /* @__PURE__ */ g("span", { children: t })
482
- }), /* @__PURE__ */ g(be, {
479
+ children: /* @__PURE__ */ _("span", { children: t })
480
+ }), /* @__PURE__ */ _(be, {
483
481
  prices: e.prices,
484
482
  className: "shrink-0",
485
483
  openOnHover: !1
486
484
  })]
487
485
  }),
488
- /* @__PURE__ */ g("p", {
486
+ /* @__PURE__ */ _("p", {
489
487
  className: "line-clamp-2 text-xs text-slate-600",
490
- children: /* @__PURE__ */ g("span", { children: n })
488
+ children: /* @__PURE__ */ _("span", { children: n })
491
489
  }),
492
- /* @__PURE__ */ g(ve, {
490
+ /* @__PURE__ */ _(ve, {
493
491
  warning: r,
494
492
  className: "mt-1"
495
493
  })
496
494
  ]
497
495
  }),
498
- /* @__PURE__ */ _("div", {
496
+ /* @__PURE__ */ v("div", {
499
497
  className: "mt-auto flex items-center gap-2",
500
- children: [/* @__PURE__ */ g(Ae, {
498
+ children: [/* @__PURE__ */ _(Ae, {
501
499
  to: ee,
502
- state: Dt,
500
+ state: Et,
503
501
  className: "text-xs font-medium text-slate-700 hover:text-slate-950",
504
- children: /* @__PURE__ */ g("span", { children: v("product_details_link") })
505
- }), /* @__PURE__ */ _(de, {
502
+ children: /* @__PURE__ */ _("span", { children: u("product_details_link") })
503
+ }), /* @__PURE__ */ v(de, {
506
504
  type: "button",
507
505
  size: "sm",
508
506
  className: "ml-auto gap-2",
509
507
  onClick: () => Ft(e),
510
- disabled: !ne || !Z,
511
- children: [/* @__PURE__ */ g("span", { children: v("add_to_cart") }), /* @__PURE__ */ g(Le, {
508
+ disabled: !te || !Q || c,
509
+ children: [/* @__PURE__ */ _("span", { children: u("add_to_cart") }), /* @__PURE__ */ _(Le, {
512
510
  className: "h-4 w-4",
513
511
  "aria-hidden": "true"
514
512
  })]
@@ -521,15 +519,15 @@ function S() {
521
519
  })
522
520
  ]
523
521
  })
524
- }), /* @__PURE__ */ g("div", {
522
+ }), /* @__PURE__ */ _("div", {
525
523
  className: "min-w-0 lg:col-span-4",
526
- children: /* @__PURE__ */ g(ye, {
527
- lines: Ct.lines,
524
+ children: /* @__PURE__ */ _(ye, {
525
+ lines: St.lines,
528
526
  itemCount: Xe,
529
527
  baseUnitLabel: rt,
530
- totalMinor: Ct.totalMinor,
531
- checkoutPath: Et,
532
- showCheckoutAction: Z,
528
+ totalMinor: St.totalMinor,
529
+ checkoutPath: Tt,
530
+ showCheckoutAction: Q,
533
531
  editable: !0,
534
532
  stickyTopClassName: "top-32",
535
533
  onQuantityChange: $e,
@@ -537,19 +535,19 @@ function S() {
537
535
  })
538
536
  })]
539
537
  })
540
- }), /* @__PURE__ */ g(De, {
541
- open: !!Q,
542
- product: Q,
538
+ }), /* @__PURE__ */ _(De, {
539
+ open: !!$,
540
+ product: $,
543
541
  onOpenChange: (e) => {
544
- e || $(null);
542
+ e || jt(null);
545
543
  },
546
- getVariantAvailabilityLabel: (e) => Q ? ht(Q, e) : null,
547
- isVariantOutOfCapacity: (e) => Q ? pt(Q, e) : !1,
548
- addDisabled: !Z,
544
+ getVariantAvailabilityLabel: (e) => $ ? mt($, e) : null,
545
+ isVariantOutOfCapacity: (e) => $ ? q($, e) : !1,
546
+ addDisabled: !Q,
549
547
  onAddVariant: (e, t) => {
550
- Q && (Nt(Q, e, t), $(null));
548
+ $ && (Nt($, e, t), jt(null));
551
549
  }
552
550
  })] });
553
551
  }
554
552
  //#endregion
555
- export { S as default };
553
+ export { C as default };