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