@loczer/storefront-sdk 0.208.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 (88) hide show
  1. package/dist/StorefrontContext.d.ts +89 -0
  2. package/dist/StorefrontContext.d.ts.map +1 -1
  3. package/dist/StorefrontContext.js +8 -1
  4. package/dist/StorefrontProvider.d.ts +84 -0
  5. package/dist/StorefrontProvider.d.ts.map +1 -1
  6. package/dist/StorefrontProvider.js +55 -41
  7. package/dist/chunks/pkg/booking-engine/dist/node_modules/@date-fns/tz/date/index-DAbcklF5.js +1 -0
  8. package/dist/chunks/pkg/booking-engine/dist/node_modules/@date-fns/tz/date/mini-CSEBo1ZP.js +60 -0
  9. package/dist/chunks/pkg/booking-engine/dist/node_modules/@date-fns/tz/index--u3Qf-qy.js +4 -0
  10. package/dist/chunks/pkg/booking-engine/dist/node_modules/@date-fns/tz/tz/index-CEcibV-H.js +1 -0
  11. package/dist/chunks/pkg/booking-engine/dist/node_modules/@date-fns/tz/tzOffset/index-COlDDdap.js +22 -0
  12. package/dist/chunks/pkg/booking-engine/dist/pricing-BJaynUu_.js +3 -0
  13. package/dist/chunks/pkg/booking-engine/dist/utils/schedule-ssRov9xe.js +39 -0
  14. package/dist/chunks/pkg/booking-engine/dist/utils/timezone-B6XIbBPz.js +79 -0
  15. package/dist/chunks/pkg/ui/dist/Map/{MapContent-CDeWtwKa.js → MapContent-TzYCv8ji.js} +109 -108
  16. package/dist/chunks/pkg/ui/dist/Map/constants-dF2KdJZy.js +8 -0
  17. package/dist/chunks/pkg/ui/dist/{Map-Cs7wgtH9.js → Map-ZM-ZOU9P.js} +1 -1
  18. package/dist/components/BookingBikeVariantDialog/index.js +15 -15
  19. package/dist/components/ContactSection/index.js +9 -9
  20. package/dist/components/Header/index.d.ts.map +1 -1
  21. package/dist/components/Header/index.js +72 -66
  22. package/dist/components/Itineraries/ItinerariesSection.d.ts +2 -0
  23. package/dist/components/Itineraries/ItinerariesSection.d.ts.map +1 -0
  24. package/dist/components/Itineraries/ItinerariesSection.js +81 -0
  25. package/dist/components/Itineraries/ItineraryListItem.d.ts +9 -0
  26. package/dist/components/Itineraries/ItineraryListItem.d.ts.map +1 -0
  27. package/dist/components/Itineraries/ItineraryListItem.js +100 -0
  28. package/dist/components/Itineraries/ItineraryRouteMap.d.ts +10 -0
  29. package/dist/components/Itineraries/ItineraryRouteMap.d.ts.map +1 -0
  30. package/dist/components/Itineraries/ItineraryRouteMap.js +67 -0
  31. package/dist/components/Itineraries/index.d.ts +4 -0
  32. package/dist/components/Itineraries/index.d.ts.map +1 -0
  33. package/dist/components/Itineraries/index.js +4 -0
  34. package/dist/components/Map/index.d.ts +12 -0
  35. package/dist/components/Map/index.d.ts.map +1 -1
  36. package/dist/components/Map/index.js +1 -1
  37. package/dist/components/ProductPriceBadge/index.d.ts.map +1 -1
  38. package/dist/components/ProductPriceBadge/index.js +86 -80
  39. package/dist/components/StorefrontCartPanel/index.d.ts +4 -4
  40. package/dist/components/StorefrontCartPanel/index.d.ts.map +1 -1
  41. package/dist/components/StorefrontCartPanel/index.js +10 -9
  42. package/dist/i18n/en.d.ts +42 -6
  43. package/dist/i18n/en.d.ts.map +1 -1
  44. package/dist/i18n/en.js +44 -8
  45. package/dist/i18n/fr.d.ts +42 -6
  46. package/dist/i18n/fr.d.ts.map +1 -1
  47. package/dist/i18n/fr.js +44 -8
  48. package/dist/index.d.ts +817 -36
  49. package/dist/index.js +67 -60
  50. package/dist/lib/booking.d.ts +0 -6
  51. package/dist/lib/booking.d.ts.map +1 -1
  52. package/dist/lib/booking.js +51 -65
  53. package/dist/lib/cartSummary.d.ts +5 -3
  54. package/dist/lib/cartSummary.d.ts.map +1 -1
  55. package/dist/lib/cartSummary.js +7 -7
  56. package/dist/lib/itineraryPresentation.d.ts +14 -0
  57. package/dist/lib/itineraryPresentation.d.ts.map +1 -0
  58. package/dist/lib/itineraryPresentation.js +26 -0
  59. package/dist/lib/pricing.d.ts +18 -6
  60. package/dist/lib/pricing.d.ts.map +1 -1
  61. package/dist/lib/pricing.js +45 -29
  62. package/dist/lib/storefrontItineraries.d.ts +418 -0
  63. package/dist/lib/storefrontItineraries.d.ts.map +1 -0
  64. package/dist/lib/storefrontItineraries.js +81 -0
  65. package/dist/pages/BookingPage.d.ts.map +1 -1
  66. package/dist/pages/BookingPage.js +205 -201
  67. package/dist/pages/CheckoutPage.d.ts.map +1 -1
  68. package/dist/pages/CheckoutPage.js +276 -273
  69. package/dist/pages/HomePage.d.ts.map +1 -1
  70. package/dist/pages/HomePage.js +111 -108
  71. package/dist/pages/ItinerariesPage.d.ts +2 -0
  72. package/dist/pages/ItinerariesPage.d.ts.map +1 -0
  73. package/dist/pages/ItinerariesPage.js +76 -0
  74. package/dist/pages/ItineraryDetailsPage.d.ts +66 -0
  75. package/dist/pages/ItineraryDetailsPage.d.ts.map +1 -0
  76. package/dist/pages/ItineraryDetailsPage.js +223 -0
  77. package/dist/pages/ProductPage.js +6 -6
  78. package/dist/pages/checkout/components/CheckoutSummaryColumn.d.ts +2 -2
  79. package/dist/pages/checkout/components/CheckoutSummaryColumn.d.ts.map +1 -1
  80. package/dist/pages/checkout/components/CheckoutSummaryColumn.js +4 -4
  81. package/dist/pages/itineraries/ElevationProfile.d.ts +5 -0
  82. package/dist/pages/itineraries/ElevationProfile.d.ts.map +1 -0
  83. package/dist/pages/itineraries/ElevationProfile.js +59 -0
  84. package/dist/routes.d.ts.map +1 -1
  85. package/dist/routes.js +18 -10
  86. package/dist/storefront.css +1 -1
  87. package/package.json +1 -1
  88. package/dist/chunks/pkg/ui/dist/Map/constants-BNmiJXfg.js +0 -4
@@ -1,29 +1,30 @@
1
- import { applyBookingParamsToSearch as e, getBookingDurationLabel as t, getBookingDurationMinutes as n, getBookingParamsFromSearch as r, resolveBookingSearchParamsFromSessionStorage as i, writeBookingSearchParamsToSessionStorage as ee } from "../lib/booking.js";
2
- import { useStorefrontCart as te } from "../lib/cart.js";
3
- import { buildStorefrontCartSummary as ne } from "../lib/cartSummary.js";
4
- import { ROUTE as re, responseSchema as ie } from "../lib/checkoutPaymentDecision.js";
5
- import { ROUTE as ae, responseSchema as oe } from "../lib/checkoutSubmit.js";
6
- import { ROUTE as se, buildStorefrontAvailabilityKey as ce, getStorefrontAvailabilityIssue as le, getValidStorefrontAvailabilitySchedule as ue, responseSchema as de } from "../lib/storefrontAvailability.js";
7
- import { Button as fe } from "../ui/button.js";
8
- import { toast as a } from "../lib/toast.js";
9
- import { BookingFlowSteps as pe } from "../components/BookingFlowSteps/index.js";
1
+ import { applyBookingParamsToSearch as e, getBookingParamsFromSearch as t, resolveBookingSearchParamsFromSessionStorage as n, writeBookingSearchParamsToSessionStorage as r } from "../lib/booking.js";
2
+ import { useStorefrontCart as i } from "../lib/cart.js";
3
+ import { calculateBookingRentalUnitSummary as ee, formatRentalUnitQuantity as te, getPricingUnitLabel as ne } from "../lib/pricing.js";
4
+ import { buildStorefrontCartSummary as re } from "../lib/cartSummary.js";
5
+ import { ROUTE as ie, responseSchema as ae } from "../lib/checkoutPaymentDecision.js";
6
+ import { ROUTE as oe, responseSchema as se } from "../lib/checkoutSubmit.js";
7
+ import { ROUTE as ce, buildStorefrontAvailabilityKey as le, getStorefrontAvailabilityIssue as ue, getValidStorefrontAvailabilitySchedule as de, responseSchema as fe } from "../lib/storefrontAvailability.js";
8
+ import { Button as pe } from "../ui/button.js";
10
9
  import { useStorefront as me, useStorefrontProducts as he } from "../StorefrontContext.js";
11
- import { apiPost as o } from "../lib/apiCall.js";
12
- import { FulfillmentSection as ge } from "../components/FulfillmentSection/index.js";
13
- import { ROUTE as _e, responseSchema as ve } from "../lib/checkoutVerifyCoupon.js";
14
- import { CheckoutDetailsCard as ye } from "./checkout/components/CheckoutDetailsCard.js";
15
- import { CheckoutPaymentSummaryCard as be } from "./checkout/components/CheckoutPaymentSummaryCard.js";
16
- import { CheckoutInsuranceCard as xe } from "./checkout/components/CheckoutInsuranceCard.js";
17
- import { CheckoutSummaryColumn as Se } from "./checkout/components/CheckoutSummaryColumn.js";
18
- import { checkoutFormSchema as Ce } from "./checkout/types.js";
19
- import { useEffect as s, useMemo as c, useRef as we, useState as l } from "react";
20
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
21
- import { Link as Te, useNavigate as Ee, useParams as De, useSearchParams as Oe } from "@rpcbase/router";
22
- import { useTranslation as ke } from "react-i18next";
23
- import { ArrowLeft as Ae } from "lucide-react";
24
- import { useForm as je, zodResolver as Me } from "@rpcbase/form";
10
+ import { toast as ge } from "../lib/toast.js";
11
+ import { BookingFlowSteps as _e } from "../components/BookingFlowSteps/index.js";
12
+ import { apiPost as a } from "../lib/apiCall.js";
13
+ import { FulfillmentSection as ve } from "../components/FulfillmentSection/index.js";
14
+ import { ROUTE as ye, responseSchema as be } from "../lib/checkoutVerifyCoupon.js";
15
+ import { CheckoutDetailsCard as xe } from "./checkout/components/CheckoutDetailsCard.js";
16
+ import { CheckoutPaymentSummaryCard as Se } from "./checkout/components/CheckoutPaymentSummaryCard.js";
17
+ import { CheckoutInsuranceCard as Ce } from "./checkout/components/CheckoutInsuranceCard.js";
18
+ import { CheckoutSummaryColumn as we } from "./checkout/components/CheckoutSummaryColumn.js";
19
+ import { checkoutFormSchema as Te } from "./checkout/types.js";
20
+ import { useEffect as o, useMemo as s, useRef as Ee, useState as c } from "react";
21
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
22
+ import { Link as De, useNavigate as Oe, useParams as ke, useSearchParams as Ae } from "@rpcbase/router";
23
+ import { useTranslation as je } from "react-i18next";
24
+ import { ArrowLeft as Me } from "lucide-react";
25
+ import { useForm as Ne, zodResolver as Pe } from "@rpcbase/form";
25
26
  //#region src/pages/CheckoutPage.tsx
26
- var Ne = .2, Pe = (e) => e <= 0 ? 1 : Math.max(1, Math.ceil(e / 1440)), f = (e, t, n) => {
27
+ var Fe = .2, d = (e, t, n) => {
27
28
  try {
28
29
  return new Intl.NumberFormat(n, {
29
30
  style: "currency",
@@ -32,7 +33,7 @@ var Ne = .2, Pe = (e) => e <= 0 ? 1 : Math.max(1, Math.ceil(e / 1440)), f = (e,
32
33
  } catch {
33
34
  return `${(e / 100).toFixed(2)} ${t.toUpperCase()}`;
34
35
  }
35
- }, Fe = (e, t) => {
36
+ }, Ie = (e, t) => {
36
37
  try {
37
38
  return new Intl.NumberFormat(t, {
38
39
  style: "percent",
@@ -42,7 +43,7 @@ var Ne = .2, Pe = (e) => e <= 0 ? 1 : Math.max(1, Math.ceil(e / 1440)), f = (e,
42
43
  } catch {
43
44
  return `${Number.parseFloat((e * 100).toFixed(2))}%`;
44
45
  }
45
- }, Ie = (e, t, n) => {
46
+ }, Le = (e, t, n) => {
46
47
  let r = {
47
48
  dateStyle: "medium",
48
49
  timeStyle: "short"
@@ -55,112 +56,114 @@ var Ne = .2, Pe = (e) => e <= 0 ? 1 : Math.max(1, Math.ceil(e / 1440)), f = (e,
55
56
  } catch {}
56
57
  return new Intl.DateTimeFormat(t, r).format(e);
57
58
  };
58
- function p() {
59
- let { t: p, i18n: m } = ke(), { storefrontConfiguration: h } = me(), Le = h.workspace?.workspaceLanguage, { bikes: g, accessories: Re } = he(), { storeSlug: _ } = De(), [v, ze] = Oe(), Be = Ee(), { items: Ve, itemCount: He, checkoutSessionId: y, setQuantity: Ue, removeItem: We, ensureCheckoutSessionId: Ge, clearCheckoutSession: Ke, clear: qe } = te(), [b, Je] = l(!1), Ye = we(!1), [x, S] = l(null), [Xe, Ze] = l(!1), [Qe, C] = l(null), $e = v.get("coupon") ?? v.get("code") ?? "", [et, w] = l($e), [tt, nt] = l($e.trim()), [T, E] = l(null), [D, O] = l(null), [k, A] = l(!1), [rt, j] = l(null), [it, M] = l(null), [N, at] = l(!1), [P, ot] = l(!1), st = c(() => i(v, _), [v, _]), F = h.settings.fulfillmentModes.includes("delivery"), ct = h.settings.deliveryDisabledReason.trim(), lt = F || ct.length > 0, ut = h.shop.address?.trim() ?? "", I = c(() => {
60
- let e = r(st, {
59
+ function f() {
60
+ let { t: f, i18n: p } = je(), { storefrontConfiguration: m } = me(), Re = m.workspace?.workspaceLanguage, { bikes: ze, accessories: Be } = he(), { storeSlug: h } = ke(), [g, Ve] = Ae(), He = Oe(), { items: Ue, itemCount: We, checkoutSessionId: _, setQuantity: Ge, removeItem: Ke, ensureCheckoutSessionId: qe, clearCheckoutSession: Je, clear: Ye } = i(), [v, Xe] = c(!1), Ze = Ee(!1), [y, b] = c(null), [Qe, x] = c(!1), [$e, S] = c(null), et = g.get("coupon") ?? g.get("code") ?? "", [tt, C] = c(et), [nt, rt] = c(et.trim()), [w, T] = c(null), [E, D] = c(null), [it, at] = c(!1), [ot, O] = c(null), [st, k] = c(null), [A, ct] = c(!1), [j, lt] = c(!1), ut = s(() => n(g, h), [g, h]), M = m.settings.fulfillmentModes.includes("delivery"), dt = m.settings.deliveryDisabledReason.trim(), ft = M || dt.length > 0, pt = m.shop.address?.trim() ?? "", N = s(() => {
61
+ let e = t(ut, {
61
62
  start_time: "",
62
63
  end_time: ""
63
64
  });
64
- return e.fulfillment === "delivery" && !F ? {
65
+ return e.fulfillment === "delivery" && !M ? {
65
66
  ...e,
66
67
  fulfillment: "pickup"
67
68
  } : e;
68
- }, [st, F]), L = c(() => ue(I), [I]), dt = c(() => t(I), [I]), ft = c(() => n(I), [I]), pt = c(() => Pe(ft), [ft]), R = c(() => ne({
69
- items: Ve,
70
- language: m.language,
71
- fallbackLanguage: Le,
69
+ }, [ut, M]), P = s(() => de(N), [N]), F = m.bookingEngine.pricing, I = ee(N, F, m.bookingEngine.shop.timeZone), mt = ne(F.baseUnit, f), ht = I ? te(I.billableUnitCount, I.priceUnit, p.language, f) : void 0, gt = I?.billableUnitCount, L = s(() => re({
70
+ items: Ue,
71
+ language: p.language,
72
+ fallbackLanguage: Re,
72
73
  products: {
73
- bikes: g,
74
- accessories: Re
74
+ bikes: ze,
75
+ accessories: Be
75
76
  },
76
- estimatedDays: pt
77
+ priceUnit: F.baseUnit,
78
+ billableUnitCount: gt
77
79
  }), [
78
- Re,
79
- g,
80
- pt,
81
- m.language,
82
- Ve,
83
- Le
84
- ]), z = c(() => R.lines.map((e) => ({
80
+ Be,
81
+ ze,
82
+ gt,
83
+ p.language,
84
+ Ue,
85
+ F.baseUnit,
86
+ Re
87
+ ]), _t = s(() => L.lines.map((e) => ({
85
88
  productId: e.checkoutProductId,
86
89
  productVariantId: e.productVariantId,
87
90
  quantity: e.quantity
88
- })), [R.lines]), [mt, B] = l([]), [ht, V] = l(!1);
89
- s(() => {
90
- if (!_ || z.length === 0) {
91
- B([]), V(!1);
91
+ })), [L.lines]), [vt, R] = c([]), [z, B] = c(!1);
92
+ o(() => {
93
+ if (!h || _t.length === 0) {
94
+ R([]), B(!1);
92
95
  return;
93
96
  }
94
- if (!L) {
95
- B([]), V(!1);
97
+ if (!P) {
98
+ R([]), B(!1);
96
99
  return;
97
100
  }
98
101
  let e = !1;
99
- return V(!0), B([]), (async () => {
102
+ return B(!0), R([]), (async () => {
100
103
  try {
101
- let t = await o(se, {
102
- storeSlug: _,
103
- schedule: L,
104
- products: z
105
- }), n = de.parse(t);
104
+ let t = await a(ce, {
105
+ storeSlug: h,
106
+ schedule: P,
107
+ products: _t
108
+ }), n = fe.parse(t);
106
109
  if (e) return;
107
- B(n.success ? n.availability ?? [] : []);
110
+ R(n.success ? n.availability ?? [] : []);
108
111
  } catch (t) {
109
112
  if (e) return;
110
- console.error("Failed to load checkout cart availability", t), B([]);
113
+ console.error("Failed to load checkout cart availability", t), R([]);
111
114
  } finally {
112
- e || V(!1);
115
+ e || B(!1);
113
116
  }
114
117
  })(), () => {
115
118
  e = !0;
116
119
  };
117
120
  }, [
118
- I.end_date,
119
- I.end_time,
120
- I.start_date,
121
- I.start_time,
122
- L,
123
- z,
124
- _
121
+ N.end_date,
122
+ N.end_time,
123
+ N.start_date,
124
+ N.start_time,
125
+ P,
126
+ _t,
127
+ h
125
128
  ]);
126
- let gt = c(() => new Map(mt.map((e) => [ce(e.productId, e.productVariantId), e])), [mt]), H = c(() => ({
127
- ...R,
128
- lines: R.lines.map((e) => {
129
- let t = gt.get(ce(e.checkoutProductId, e.productVariantId)), n = t ? le(t) : e.availabilityStatus === "OUT_OF_STOCK" ? "unavailable" : void 0;
129
+ let yt = s(() => new Map(vt.map((e) => [le(e.productId, e.productVariantId), e])), [vt]), V = s(() => ({
130
+ ...L,
131
+ lines: L.lines.map((e) => {
132
+ let t = yt.get(le(e.checkoutProductId, e.productVariantId)), n = t ? ue(t) : e.availabilityStatus === "OUT_OF_STOCK" ? "unavailable" : void 0;
130
133
  return {
131
134
  ...e,
132
- insufficientCapacity: !ht && n !== void 0,
133
- availabilityIssue: ht ? void 0 : n
135
+ insufficientCapacity: !z && n !== void 0,
136
+ availabilityIssue: z ? void 0 : n
134
137
  };
135
138
  })
136
139
  }), [
137
- gt,
138
- ht,
139
- R
140
- ]), U = c(() => R.lines.map((e) => ({
140
+ yt,
141
+ z,
142
+ L
143
+ ]), H = s(() => L.lines.map((e) => ({
141
144
  kind: e.kind,
142
145
  productId: e.checkoutProductId,
143
146
  productVariantId: e.productVariantId,
144
147
  quantity: e.quantity
145
- })), [R.lines]), _t = new Map(g.map((e) => [e.checkoutProductId?.trim() || e.id, e])), W = R.lines.flatMap((e) => {
146
- let t = _t.get(e.checkoutProductId);
148
+ })), [L.lines]), bt = new Map(ze.map((e) => [e.checkoutProductId?.trim() || e.id, e])), U = L.lines.flatMap((e) => {
149
+ let t = bt.get(e.checkoutProductId);
147
150
  return t?.insurance?.enabled ? [{
148
151
  quantity: e.quantity,
149
152
  pricePerDayMinor: t.insurance.pricePerDayMinor,
150
153
  deductibleAmountMinor: t.insurance.deductibleAmountMinor
151
154
  }] : [];
152
- }), G = h.modules?.insurance?.enabled === !0 && W.length > 0, K = G && P, vt = W.reduce((e, t) => e + t.pricePerDayMinor * t.quantity, 0), yt = W.reduce((e, t) => Math.max(e, t.deductibleAmountMinor), 0), bt = R.estimatedTotalMinor ?? R.totalPerDayMinor, q = D?.totalMinor ?? bt, J = T?.discountAmountMinor ?? 0, Y = e(new URLSearchParams(), I).toString(), xt = `/${_ ?? ""}/booking${Y ? `?${Y}` : ""}`, St = `/${_ ?? ""}/checkout${Y ? `?${Y}` : ""}`, Ct = new URLSearchParams(Y);
153
- y && Ct.set("checkout_session_id", y);
154
- let wt = y ? `/${_ ?? ""}/checkout/payment?${Ct.toString()}` : null;
155
- s(() => {
156
- !_ || !wt || Ye.current || Be(wt, { replace: !0 });
155
+ }), W = m.modules?.insurance?.enabled === !0 && U.length > 0, G = W && j, xt = U.reduce((e, t) => e + t.pricePerDayMinor * t.quantity, 0), St = U.reduce((e, t) => Math.max(e, t.deductibleAmountMinor), 0), Ct = L.estimatedTotalMinor ?? L.totalPerBaseUnitMinor, K = E?.totalMinor ?? Ct, q = w?.discountAmountMinor ?? 0, J = e(new URLSearchParams(), N).toString(), wt = `/${h ?? ""}/booking${J ? `?${J}` : ""}`, Tt = `/${h ?? ""}/checkout${J ? `?${J}` : ""}`, Et = new URLSearchParams(J);
156
+ _ && Et.set("checkout_session_id", _);
157
+ let Dt = _ ? `/${h ?? ""}/checkout/payment?${Et.toString()}` : null;
158
+ o(() => {
159
+ !h || !Dt || Ze.current || He(Dt, { replace: !0 });
157
160
  }, [
158
- wt,
159
- Be,
160
- _
161
+ Dt,
162
+ He,
163
+ h
161
164
  ]);
162
- let Tt = je({
163
- resolver: Me(Ce),
165
+ let Ot = Ne({
166
+ resolver: Pe(Te),
164
167
  defaultValues: {
165
168
  first_name: "",
166
169
  last_name: "",
@@ -169,138 +172,138 @@ function p() {
169
172
  notes: ""
170
173
  }
171
174
  });
172
- s(() => {
173
- ee(_, I);
174
- }, [I, _]), s(() => {
175
- !G && P && ot(!1);
176
- }, [P, G]);
177
- let Et = (t) => {
175
+ o(() => {
176
+ r(h, N);
177
+ }, [N, h]), o(() => {
178
+ !W && j && lt(!1);
179
+ }, [j, W]);
180
+ let kt = (t) => {
178
181
  let n = {
179
- ...I,
182
+ ...N,
180
183
  ...t
181
- }, r = e(v, n);
182
- ze(r, { replace: !0 }), ee(_, r);
184
+ }, i = e(g, n);
185
+ Ve(i, { replace: !0 }), r(h, i);
183
186
  };
184
- s(() => {
185
- if (!_ || U.length === 0 || !L) {
186
- E(null), O(null), A(!1), j(null), M(null);
187
+ o(() => {
188
+ if (!h || H.length === 0 || !P) {
189
+ T(null), D(null), at(!1), O(null), k(null);
187
190
  return;
188
191
  }
189
- let e = tt.trim(), t = e.length === 0 && !N, n = !1;
190
- return A(!0), M(null), j(null), (async () => {
192
+ let e = nt.trim(), t = e.length === 0 && !A, n = !1;
193
+ return at(!0), k(null), O(null), (async () => {
191
194
  try {
192
- let r = await o(_e, {
193
- storeSlug: _,
194
- schedule: L,
195
- items: U,
195
+ let r = await a(ye, {
196
+ storeSlug: h,
197
+ schedule: P,
198
+ items: H,
196
199
  couponCode: e || void 0,
197
200
  includeAutoApply: t,
198
- insuranceAccepted: K
199
- }), i = ve.parse(r);
201
+ insuranceAccepted: G
202
+ }), i = be.parse(r);
200
203
  if (n) return;
201
- if (O(typeof i.subtotalMinor == "number" && typeof i.totalMinor == "number" ? {
204
+ if (D(typeof i.subtotalMinor == "number" && typeof i.totalMinor == "number" ? {
202
205
  subtotalMinor: i.subtotalMinor,
203
206
  totalMinor: i.totalMinor,
204
207
  lateReturnSurchargeMinor: i.lateReturnSurchargeMinor,
205
208
  insuranceSubtotalMinor: i.insuranceSubtotalMinor,
206
209
  insuranceBillableDays: i.insuranceBillableDays
207
210
  } : null), !i.success) {
208
- E(null), M(i.message || p("checkout_coupon_invalid"));
211
+ T(null), k(i.message || f("checkout_coupon_invalid"));
209
212
  return;
210
213
  }
211
- E(i.coupon ?? null), i.coupon && (i.coupon.autoApplied && e.length === 0 ? (w(i.coupon.code), j(p("checkout_coupon_auto_applied", { code: i.coupon.code }))) : j(p("checkout_coupon_manual_applied")));
214
+ T(i.coupon ?? null), i.coupon && (i.coupon.autoApplied && e.length === 0 ? (C(i.coupon.code), O(f("checkout_coupon_auto_applied", { code: i.coupon.code }))) : O(f("checkout_coupon_manual_applied")));
212
215
  } catch (e) {
213
216
  if (n) return;
214
- console.error("Failed to verify checkout coupon", e), E(null), O(null), M(p("checkout_coupon_error"));
217
+ console.error("Failed to verify checkout coupon", e), T(null), D(null), k(f("checkout_coupon_error"));
215
218
  } finally {
216
- n || A(!1);
219
+ n || at(!1);
217
220
  }
218
221
  })(), () => {
219
222
  n = !0;
220
223
  };
221
224
  }, [
222
- N,
223
- I.end_date,
224
- I.end_time,
225
- I.start_date,
226
- I.start_time,
227
- L,
228
- U,
229
- K,
230
- _,
231
- tt,
232
- p
233
- ]), s(() => {
234
- if (!_ || R.lines.length === 0 || !L) {
235
- S(null), C(null), Ze(!1);
225
+ A,
226
+ N.end_date,
227
+ N.end_time,
228
+ N.start_date,
229
+ N.start_time,
230
+ P,
231
+ H,
232
+ G,
233
+ h,
234
+ nt,
235
+ f
236
+ ]), o(() => {
237
+ if (!h || L.lines.length === 0 || !P) {
238
+ b(null), S(null), x(!1);
236
239
  return;
237
240
  }
238
241
  let e = !1;
239
- return Ze(!0), C(null), (async () => {
242
+ return x(!0), S(null), (async () => {
240
243
  try {
241
- let t = await o(re, {
242
- storeSlug: _,
243
- schedule: L,
244
- estimatedTotalMinor: q
245
- }), n = ie.parse(t);
244
+ let t = await a(ie, {
245
+ storeSlug: h,
246
+ schedule: P,
247
+ estimatedTotalMinor: K
248
+ }), n = ae.parse(t);
246
249
  if (e) return;
247
250
  if (!n.success || !n.decision) {
248
- S(null), C(n.errorCode === "online_payment_provider_missing" ? p("checkout_payment_error") : n.message || p("checkout_payment_error"));
251
+ b(null), S(n.errorCode === "online_payment_provider_missing" ? f("checkout_payment_error") : n.message || f("checkout_payment_error"));
249
252
  return;
250
253
  }
251
- S(n.decision);
254
+ b(n.decision);
252
255
  } catch (t) {
253
256
  if (e) return;
254
- console.error("Failed to load checkout payment decision", t), S(null), C(p("checkout_payment_error"));
257
+ console.error("Failed to load checkout payment decision", t), b(null), S(f("checkout_payment_error"));
255
258
  } finally {
256
- e || Ze(!1);
259
+ e || x(!1);
257
260
  }
258
261
  })(), () => {
259
262
  e = !0;
260
263
  };
261
264
  }, [
262
- I.end_date,
263
- I.end_time,
264
- I.start_date,
265
- I.start_time,
266
- L,
267
- q,
268
- R.lines.length,
269
- _,
270
- p
265
+ N.end_date,
266
+ N.end_time,
267
+ N.start_date,
268
+ N.start_time,
269
+ P,
270
+ K,
271
+ L.lines.length,
272
+ h,
273
+ f
271
274
  ]);
272
- let X = x?.currency ?? "EUR", Dt = f(q, X, m.language), Ot = J > 0 ? `-${f(J, X, m.language)}` : null, Z = D?.insuranceSubtotalMinor ?? 0, kt = Math.max(0, q - Z), At = Math.round(kt / 1.2), jt = At + Z, Mt = Math.max(0, kt - At), Nt = f(jt, X, m.language), Pt = f(Mt, X, m.language), Ft = Fe(Ne, m.language), It = Z > 0 ? f(Z, X, m.language) : void 0, Q = x?.amountToCollectMinor ?? 0, Lt = f(Q, X, m.language), Rt = x?.paymentMode === "deposit" && Q > 0 ? f(Q, X, m.language) : null, zt = x?.shouldCollectOnlinePayment === !0 && Q > 0, Bt = h.shop.timeZone?.trim() || void 0, $ = c(() => x ? Fe(Math.max(0, Math.min(1, x.bookingDepositPercentage)), m.language) : null, [m.language, x]), Vt = c(() => {
273
- if (!x?.depositRefundableUntilIso) return null;
274
- let e = new Date(x.depositRefundableUntilIso);
275
- return Number.isNaN(e.getTime()) ? null : Ie(e, m.language, Bt);
275
+ let Y = y?.currency ?? "EUR", At = d(K, Y, p.language), jt = q > 0 ? `-${d(q, Y, p.language)}` : null, X = E?.insuranceSubtotalMinor ?? 0, Mt = Math.max(0, K - X), Nt = Math.round(Mt / 1.2), Pt = Nt + X, Ft = Math.max(0, Mt - Nt), It = d(Pt, Y, p.language), Lt = d(Ft, Y, p.language), Rt = Ie(Fe, p.language), zt = X > 0 ? d(X, Y, p.language) : void 0, Z = y?.amountToCollectMinor ?? 0, Bt = d(Z, Y, p.language), Vt = y?.paymentMode === "deposit" && Z > 0 ? d(Z, Y, p.language) : null, Ht = y?.shouldCollectOnlinePayment === !0 && Z > 0, Ut = m.shop.timeZone?.trim() || void 0, Q = s(() => y ? Ie(Math.max(0, Math.min(1, y.bookingDepositPercentage)), p.language) : null, [p.language, y]), $ = s(() => {
276
+ if (!y?.depositRefundableUntilIso) return null;
277
+ let e = new Date(y.depositRefundableUntilIso);
278
+ return Number.isNaN(e.getTime()) ? null : Le(e, p.language, Ut);
276
279
  }, [
277
- m.language,
278
- x?.depositRefundableUntilIso,
279
- Bt
280
- ]), Ht = c(() => x ? x.paymentMode === "deposit" && Q > 0 && $ ? Vt ? p("checkout_payment_due_now_helper_deposit_refundable_until", {
281
- percent: $,
282
- date: Vt
283
- }) : p("checkout_payment_due_now_helper_deposit", { percent: $ }) : x.paymentMode === "none" || Q <= 0 ? p("checkout_payment_due_now_helper_none") : null : null, [
280
+ p.language,
281
+ y?.depositRefundableUntilIso,
282
+ Ut
283
+ ]), Wt = s(() => y ? y.paymentMode === "deposit" && Z > 0 && Q ? $ ? f("checkout_payment_due_now_helper_deposit_refundable_until", {
284
+ percent: Q,
285
+ date: $
286
+ }) : f("checkout_payment_due_now_helper_deposit", { percent: Q }) : y.paymentMode === "none" || Z <= 0 ? f("checkout_payment_due_now_helper_none") : null : null, [
287
+ Z,
284
288
  Q,
285
289
  $,
286
- Vt,
287
- x,
288
- p
289
- ]), Ut = Tt.handleSubmit(async (e) => {
290
- if (!_ || U.length === 0 || !L) return;
291
- Je(!0), Ye.current = !0;
292
- let t = Ge();
290
+ y,
291
+ f
292
+ ]), Gt = Ot.handleSubmit(async (e) => {
293
+ if (!h || H.length === 0 || !P) return;
294
+ Xe(!0), Ze.current = !0;
295
+ let t = qe();
293
296
  try {
294
- let n = await o(ae, {
295
- storeSlug: _,
297
+ let n = await a(oe, {
298
+ storeSlug: h,
296
299
  checkoutSessionId: t,
297
- schedule: L,
298
- fulfillment: I.fulfillment,
299
- startAddress: I.fulfillment === "delivery" ? I.start_address : void 0,
300
- endAddress: I.fulfillment === "delivery" ? I.end_address : void 0,
301
- couponCode: T?.code,
302
- couponAutoApplied: !N && T?.autoApplied,
303
- insuranceAccepted: K,
300
+ schedule: P,
301
+ fulfillment: N.fulfillment,
302
+ startAddress: N.fulfillment === "delivery" ? N.start_address : void 0,
303
+ endAddress: N.fulfillment === "delivery" ? N.end_address : void 0,
304
+ couponCode: w?.code,
305
+ couponAutoApplied: !A && w?.autoApplied,
306
+ insuranceAccepted: G,
304
307
  customer: {
305
308
  firstName: e.first_name,
306
309
  lastName: e.last_name,
@@ -308,174 +311,174 @@ function p() {
308
311
  phone: e.phone,
309
312
  notes: e.notes
310
313
  },
311
- items: U
312
- }), r = oe.parse(n);
314
+ items: H
315
+ }), r = se.parse(n);
313
316
  if (!r.success || !r.checkout) {
314
- Ke(), a.error(r.errorCode === "online_payment_provider_missing" ? p("checkout_payment_error") : r.message || p("checkout_payment_error"));
317
+ Je(), ge.error(r.errorCode === "online_payment_provider_missing" ? f("checkout_payment_error") : r.message || f("checkout_payment_error"));
315
318
  return;
316
319
  }
317
- r.checkout.requiresPayment || a.success(p("checkout_success_toast")), await Be(r.checkout.nextPath), r.checkout.requiresPayment || qe();
320
+ r.checkout.requiresPayment || ge.success(f("checkout_success_toast")), await He(r.checkout.nextPath), r.checkout.requiresPayment || Ye();
318
321
  } catch (e) {
319
- console.error("Failed to submit storefront checkout", e), a.error(p("checkout_payment_error"));
322
+ console.error("Failed to submit storefront checkout", e), ge.error(f("checkout_payment_error"));
320
323
  } finally {
321
- Ye.current = !1, Je(!1);
324
+ Ze.current = !1, Xe(!1);
322
325
  }
323
- }), Wt = p(zt ? "checkout_continue_to_payment" : "checkout_submit"), Gt = I.fulfillment === "delivery" && I.start_address.trim().length === 0, Kt = !b && !Xe && !Qe && !k && !it && !!x && !!L && !Gt && U.length > 0;
324
- return R.lines.length === 0 ? /* @__PURE__ */ u("div", {
326
+ }), Kt = f(Ht ? "checkout_continue_to_payment" : "checkout_submit"), qt = N.fulfillment === "delivery" && N.start_address.trim().length === 0, Jt = !v && !Qe && !$e && !it && !st && !!y && !!P && !qt && H.length > 0;
327
+ return L.lines.length === 0 ? /* @__PURE__ */ l("div", {
325
328
  className: "mx-auto max-w-3xl px-4 py-10 sm:px-6",
326
- children: /* @__PURE__ */ d("div", {
329
+ children: /* @__PURE__ */ u("div", {
327
330
  className: "rounded-xl border border-slate-200 bg-white p-4 shadow-sm",
328
331
  children: [
329
- /* @__PURE__ */ u("h1", {
332
+ /* @__PURE__ */ l("h1", {
330
333
  className: "text-xl font-semibold tracking-tight text-slate-950",
331
- children: /* @__PURE__ */ u("span", { children: p("cart_empty_title") })
334
+ children: /* @__PURE__ */ l("span", { children: f("cart_empty_title") })
332
335
  }),
333
- /* @__PURE__ */ u("p", {
336
+ /* @__PURE__ */ l("p", {
334
337
  className: "mt-2 text-sm text-slate-600",
335
- children: /* @__PURE__ */ u("span", { children: p("cart_empty_description") })
338
+ children: /* @__PURE__ */ l("span", { children: f("cart_empty_description") })
336
339
  }),
337
- /* @__PURE__ */ u("div", {
340
+ /* @__PURE__ */ l("div", {
338
341
  className: "mt-6",
339
- children: /* @__PURE__ */ u(Te, {
340
- to: xt,
341
- children: /* @__PURE__ */ d(fe, {
342
+ children: /* @__PURE__ */ l(De, {
343
+ to: wt,
344
+ children: /* @__PURE__ */ u(pe, {
342
345
  className: "gap-2",
343
- children: [/* @__PURE__ */ u(Ae, {
346
+ children: [/* @__PURE__ */ l(Me, {
344
347
  className: "h-4 w-4",
345
348
  "aria-hidden": "true"
346
- }), /* @__PURE__ */ u("span", { children: p("back_to_booking") })]
349
+ }), /* @__PURE__ */ l("span", { children: f("back_to_booking") })]
347
350
  })
348
351
  })
349
352
  })
350
353
  ]
351
354
  })
352
- }) : /* @__PURE__ */ u("div", {
355
+ }) : /* @__PURE__ */ l("div", {
353
356
  className: "mx-auto max-w-7xl px-4 py-8 sm:px-6",
354
- children: /* @__PURE__ */ d("div", {
357
+ children: /* @__PURE__ */ u("div", {
355
358
  className: "flex flex-col gap-6",
356
359
  children: [
357
- /* @__PURE__ */ u(pe, {
360
+ /* @__PURE__ */ l(_e, {
358
361
  currentStep: "checkout",
359
- bookingPath: xt,
360
- checkoutPath: St
362
+ bookingPath: wt,
363
+ checkoutPath: Tt
361
364
  }),
362
- /* @__PURE__ */ d(Te, {
363
- to: xt,
365
+ /* @__PURE__ */ u(De, {
366
+ to: wt,
364
367
  className: "inline-flex items-center gap-2 text-sm font-medium text-slate-700 hover:text-slate-950",
365
- children: [/* @__PURE__ */ u(Ae, {
368
+ children: [/* @__PURE__ */ l(Me, {
366
369
  className: "h-4 w-4",
367
370
  "aria-hidden": "true"
368
- }), /* @__PURE__ */ u("span", { children: p("back_to_booking") })]
371
+ }), /* @__PURE__ */ l("span", { children: f("back_to_booking") })]
369
372
  }),
370
- /* @__PURE__ */ d("div", {
373
+ /* @__PURE__ */ u("div", {
371
374
  className: "grid gap-6 lg:grid-cols-12",
372
- children: [/* @__PURE__ */ d("div", {
375
+ children: [/* @__PURE__ */ u("div", {
373
376
  className: "lg:col-span-7",
374
377
  children: [
375
- /* @__PURE__ */ u("h1", {
378
+ /* @__PURE__ */ l("h1", {
376
379
  className: "text-xl font-semibold tracking-tight text-slate-950",
377
- children: /* @__PURE__ */ u("span", { children: p("checkout_title") })
380
+ children: /* @__PURE__ */ l("span", { children: f("checkout_title") })
378
381
  }),
379
- L ? null : /* @__PURE__ */ u("p", {
382
+ P ? null : /* @__PURE__ */ l("p", {
380
383
  role: "alert",
381
384
  className: "mt-3 text-sm text-destructive",
382
- children: /* @__PURE__ */ u("span", { children: p("booking_time_slots_required") })
385
+ children: /* @__PURE__ */ l("span", { children: f("booking_time_slots_required") })
383
386
  }),
384
- /* @__PURE__ */ d("div", {
387
+ /* @__PURE__ */ u("div", {
385
388
  className: "mt-5 grid gap-4",
386
389
  children: [
387
- lt ? /* @__PURE__ */ u("div", {
390
+ ft ? /* @__PURE__ */ l("div", {
388
391
  className: "rounded-xl border border-slate-200 bg-white p-3 shadow-sm",
389
- children: /* @__PURE__ */ u(ge, {
390
- value: I.fulfillment,
391
- onValueChange: (e) => Et({ fulfillment: e }),
392
- pickupAddress: ut,
393
- deliveryEnabled: F,
394
- deliveryDisabledReason: ct,
395
- startAddress: I.start_address,
396
- onStartAddressChange: (e) => Et({ start_address: e }),
397
- endAddress: I.end_address,
398
- onEndAddressChange: (e) => Et({ end_address: e }),
392
+ children: /* @__PURE__ */ l(ve, {
393
+ value: N.fulfillment,
394
+ onValueChange: (e) => kt({ fulfillment: e }),
395
+ pickupAddress: pt,
396
+ deliveryEnabled: M,
397
+ deliveryDisabledReason: dt,
398
+ startAddress: N.start_address,
399
+ onStartAddressChange: (e) => kt({ start_address: e }),
400
+ endAddress: N.end_address,
401
+ onEndAddressChange: (e) => kt({ end_address: e }),
399
402
  showPickupAddressWhenPickupOnly: !1,
400
403
  testIdPrefix: "storefront-checkout-fulfillment"
401
404
  })
402
405
  }) : null,
403
- /* @__PURE__ */ u(ye, { form: Tt }),
404
- G ? /* @__PURE__ */ u(xe, {
405
- accepted: K,
406
- disabled: b || k,
407
- dailyAmountLabel: f(vt, X, m.language),
408
- totalAmountLabel: It,
409
- billableDays: D?.insuranceBillableDays,
410
- deductibleLabel: yt > 0 ? f(yt, X, m.language) : void 0,
411
- onAcceptedChange: ot
406
+ /* @__PURE__ */ l(xe, { form: Ot }),
407
+ W ? /* @__PURE__ */ l(Ce, {
408
+ accepted: G,
409
+ disabled: v || it,
410
+ dailyAmountLabel: d(xt, Y, p.language),
411
+ totalAmountLabel: zt,
412
+ billableDays: E?.insuranceBillableDays,
413
+ deductibleLabel: St > 0 ? d(St, Y, p.language) : void 0,
414
+ onAcceptedChange: lt
412
415
  }) : null,
413
- /* @__PURE__ */ u(be, {
414
- estimatedTotalLabel: Dt,
415
- couponCode: T?.code,
416
- discountAmountLabel: Ot,
417
- totalExcludingTaxLabel: Nt,
418
- vatAmountLabel: Pt,
419
- vatRateLabel: Ft,
420
- insuranceAmountLabel: It,
421
- depositAmountLabel: Rt,
422
- amountToCollectMinor: Q,
423
- amountToCollectLabel: Lt,
424
- paymentSummaryHelper: Ht,
425
- paymentDecisionLoading: Xe,
426
- paymentDecisionError: Qe,
416
+ /* @__PURE__ */ l(Se, {
417
+ estimatedTotalLabel: At,
418
+ couponCode: w?.code,
419
+ discountAmountLabel: jt,
420
+ totalExcludingTaxLabel: It,
421
+ vatAmountLabel: Lt,
422
+ vatRateLabel: Rt,
423
+ insuranceAmountLabel: zt,
424
+ depositAmountLabel: Vt,
425
+ amountToCollectMinor: Z,
426
+ amountToCollectLabel: Bt,
427
+ paymentSummaryHelper: Wt,
428
+ paymentDecisionLoading: Qe,
429
+ paymentDecisionError: $e,
427
430
  canChoosePaymentMethod: !1,
428
431
  showAmountDueNowRow: !0,
429
432
  selectedPaymentMethod: "card",
430
- submitting: b,
433
+ submitting: v,
431
434
  onSelectPaymentMethod: () => {}
432
435
  }),
433
- /* @__PURE__ */ u(fe, {
436
+ /* @__PURE__ */ l(pe, {
434
437
  type: "button",
435
438
  size: "lg",
436
439
  onClick: () => {
437
- Ut();
440
+ Gt();
438
441
  },
439
- disabled: !Kt,
442
+ disabled: !Jt,
440
443
  className: "mt-4 w-fit",
441
- children: /* @__PURE__ */ u("span", { children: Wt })
444
+ children: /* @__PURE__ */ l("span", { children: Kt })
442
445
  }),
443
- Gt ? /* @__PURE__ */ u("p", {
446
+ qt ? /* @__PURE__ */ l("p", {
444
447
  className: "text-sm text-slate-600",
445
- children: /* @__PURE__ */ u("span", { children: p("checkout_delivery_address_required") })
448
+ children: /* @__PURE__ */ l("span", { children: f("checkout_delivery_address_required") })
446
449
  }) : null
447
450
  ]
448
451
  })
449
452
  ]
450
- }), /* @__PURE__ */ u(Se, {
451
- lines: H.lines,
452
- itemCount: He,
453
- totalPerDayMinor: H.totalPerDayMinor,
454
- estimatedDays: H.estimatedDays,
455
- estimatedTotalMinor: H.estimatedTotalMinor,
456
- discountedEstimatedTotalMinor: q,
457
- discountAmountMinor: J,
458
- lateReturnSurchargeMinor: D?.lateReturnSurchargeMinor,
459
- couponCode: T?.code,
460
- durationLabel: dt.label,
461
- onQuantityChange: Ue,
462
- onRemove: We,
453
+ }), /* @__PURE__ */ l(we, {
454
+ lines: V.lines,
455
+ itemCount: We,
456
+ totalPerBaseUnitMinor: V.totalPerBaseUnitMinor,
457
+ baseUnitLabel: mt,
458
+ estimatedTotalMinor: V.estimatedTotalMinor,
459
+ discountedEstimatedTotalMinor: K,
460
+ discountAmountMinor: q,
461
+ lateReturnSurchargeMinor: E?.lateReturnSurchargeMinor,
462
+ couponCode: w?.code,
463
+ durationInBaseUnitLabel: ht,
464
+ onQuantityChange: Ge,
465
+ onRemove: Ke,
463
466
  coupon: {
464
- code: et,
465
- appliedCode: T?.code,
466
- discountLabel: T && J > 0 ? f(J, X, m.language) : null,
467
- message: rt,
468
- error: it,
469
- loading: k,
470
- disabled: b,
467
+ code: tt,
468
+ appliedCode: w?.code,
469
+ discountLabel: w && q > 0 ? d(q, Y, p.language) : null,
470
+ message: ot,
471
+ error: st,
472
+ loading: it,
473
+ disabled: v,
471
474
  onCodeChange: (e) => {
472
- w(e), M(null), j(null);
475
+ C(e), k(null), O(null);
473
476
  },
474
477
  onApply: () => {
475
- at(!1), nt(et.trim());
478
+ ct(!1), rt(tt.trim());
476
479
  },
477
480
  onRemove: () => {
478
- w(""), nt(""), E(null), O(null), M(null), j(null), at(!0);
481
+ C(""), rt(""), T(null), D(null), k(null), O(null), ct(!0);
479
482
  }
480
483
  }
481
484
  })]
@@ -485,4 +488,4 @@ function p() {
485
488
  });
486
489
  }
487
490
  //#endregion
488
- export { p as default };
491
+ export { f as default };