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