@develemit/storefront 0.7.0 → 0.9.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.
package/dist/index.js CHANGED
@@ -2,9 +2,9 @@
2
2
  import { n as e, t } from "./sort-for-display-Cj6GMeCY.js";
3
3
  import { createContext as n, useCallback as r, useContext as i, useEffect as a, useMemo as o, useReducer as s, useRef as c, useState as l } from "react";
4
4
  import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
5
- import { cartLineSchema as p } from "@develemit/commerce-contracts";
5
+ import { cartLineSchema as p, formatOrderRef as m } from "@develemit/commerce-contracts";
6
6
  // src/lib/theme.ts
7
- var m = {
7
+ var h = {
8
8
  colorBg: "--sf-color-bg",
9
9
  colorSurface: "--sf-color-surface",
10
10
  colorFg: "--sf-color-fg",
@@ -18,16 +18,16 @@ var m = {
18
18
  fontBody: "--sf-font-body",
19
19
  spaceUnit: "--sf-space-unit"
20
20
  };
21
- function h(e) {
21
+ function g(e) {
22
22
  let t = {};
23
- for (let n of Object.keys(m)) {
23
+ for (let n of Object.keys(h)) {
24
24
  let r = e[n];
25
- r !== void 0 && (t[m[n]] = r);
25
+ r !== void 0 && (t[h[n]] = r);
26
26
  }
27
27
  return t;
28
28
  }
29
29
  // src/lib/provider.tsx
30
- var g = {
30
+ var _ = {
31
31
  renderLink: ({ href: e, children: t, className: n }) => /* @__PURE__ */ d("a", {
32
32
  href: e,
33
33
  className: n,
@@ -47,27 +47,27 @@ var g = {
47
47
  product: (e) => `/shop/${e}`,
48
48
  category: (e) => `/shop?category=${e}`
49
49
  }
50
- }, _ = n(g);
51
- function v({ children: e, hrefs: t, ...n }) {
50
+ }, v = n(_);
51
+ function y({ children: e, hrefs: t, ...n }) {
52
52
  let r = {
53
- ...g,
53
+ ..._,
54
54
  ...n,
55
55
  hrefs: {
56
- ...g.hrefs,
56
+ ..._.hrefs,
57
57
  ...t
58
58
  }
59
59
  };
60
- return /* @__PURE__ */ d(_.Provider, {
60
+ return /* @__PURE__ */ d(v.Provider, {
61
61
  value: r,
62
62
  children: e
63
63
  });
64
64
  }
65
- function y() {
66
- return i(_);
65
+ function b() {
66
+ return i(v);
67
67
  }
68
68
  // src/components/price-tag/price-tag.tsx
69
- function b({ priceCents: t, currency: n, sold: r = !1, className: i }) {
70
- let { locale: a } = y(), o = [
69
+ function x({ priceCents: t, currency: n, sold: r = !1, className: i }) {
70
+ let { locale: a } = b(), o = [
71
71
  "sf-price",
72
72
  r && "sf-price--sold",
73
73
  i
@@ -78,15 +78,15 @@ function b({ priceCents: t, currency: n, sold: r = !1, className: i }) {
78
78
  });
79
79
  }
80
80
  // src/components/availability-badge/availability-badge.tsx
81
- var x = {
81
+ var S = {
82
82
  oneOfAKind: "One of a kind",
83
83
  sold: "Sold",
84
84
  reserved: "On hold",
85
85
  available: "Available"
86
86
  };
87
- function S({ availability: e, quantity: t, labels: n, className: r }) {
87
+ function C({ availability: e, quantity: t, labels: n, className: r }) {
88
88
  let i = {
89
- ...x,
89
+ ...S,
90
90
  ...n
91
91
  }, a, o;
92
92
  e === "sold" ? (a = "sold", o = i.sold) : e === "reserved" ? (a = "reserved", o = i.reserved) : t === 1 ? (a = "unique", o = i.oneOfAKind) : (a = "available", o = i.available);
@@ -102,8 +102,8 @@ function S({ availability: e, quantity: t, labels: n, className: r }) {
102
102
  });
103
103
  }
104
104
  // src/components/product-card/product-card.tsx
105
- function C({ product: e, labels: t, sizes: n, priority: r }) {
106
- let { renderLink: i, renderImage: a, hrefs: o } = y(), s = e.availability === "sold", c = e.images[0], l = ["sf-card", s && "sf-card--sold"].filter(Boolean).join(" ");
105
+ function w({ product: e, labels: t, sizes: n, priority: r }) {
106
+ let { renderLink: i, renderImage: a, hrefs: o } = b(), s = e.availability === "sold", c = e.images[0], l = ["sf-card", s && "sf-card--sold"].filter(Boolean).join(" ");
107
107
  return /* @__PURE__ */ d("article", {
108
108
  className: l,
109
109
  children: i({
@@ -128,12 +128,12 @@ function C({ product: e, labels: t, sizes: n, priority: r }) {
128
128
  className: "sf-card__title",
129
129
  children: e.name
130
130
  }),
131
- /* @__PURE__ */ d(b, {
131
+ /* @__PURE__ */ d(x, {
132
132
  priceCents: e.priceCents,
133
133
  currency: e.currency,
134
134
  sold: s
135
135
  }),
136
- /* @__PURE__ */ d(S, {
136
+ /* @__PURE__ */ d(C, {
137
137
  availability: e.availability,
138
138
  quantity: e.quantity,
139
139
  labels: t
@@ -144,7 +144,7 @@ function C({ product: e, labels: t, sizes: n, priority: r }) {
144
144
  });
145
145
  }
146
146
  // src/components/product-grid/product-grid.tsx
147
- function w({ products: e, emptyState: t, labels: n, priorityCount: r = 0 }) {
147
+ function T({ products: e, emptyState: t, labels: n, priorityCount: r = 0 }) {
148
148
  return e.length === 0 ? /* @__PURE__ */ d("div", {
149
149
  className: "sf-grid-empty",
150
150
  children: t ?? "No products found."
@@ -152,7 +152,7 @@ function w({ products: e, emptyState: t, labels: n, priorityCount: r = 0 }) {
152
152
  className: "sf-grid",
153
153
  children: e.map((e, t) => /* @__PURE__ */ d("li", {
154
154
  className: "sf-grid__item",
155
- children: /* @__PURE__ */ d(C, {
155
+ children: /* @__PURE__ */ d(w, {
156
156
  product: e,
157
157
  labels: n,
158
158
  priority: t < r
@@ -161,8 +161,8 @@ function w({ products: e, emptyState: t, labels: n, priorityCount: r = 0 }) {
161
161
  });
162
162
  }
163
163
  // src/components/category-filter/category-filter.tsx
164
- function T({ categories: e, selected: t, onSelect: n, allLabel: r = "All", label: i = "Categories", formatLabel: a, sortCategories: o }) {
165
- let { renderLink: s, hrefs: c } = y(), l = o ? [...e].sort(o) : e, u = n !== void 0, p = (e, r, i) => {
164
+ function E({ categories: e, selected: t, onSelect: n, allLabel: r = "All", label: i = "Categories", formatLabel: a, sortCategories: o }) {
165
+ let { renderLink: s, hrefs: c } = b(), l = o ? [...e].sort(o) : e, u = n !== void 0, p = (e, r, i) => {
166
166
  let a = t === e, o = `sf-filter__item${a ? " sf-filter__item--active" : ""}`;
167
167
  return /* @__PURE__ */ d("li", { children: u ? /* @__PURE__ */ d("button", {
168
168
  type: "button",
@@ -186,8 +186,8 @@ function T({ categories: e, selected: t, onSelect: n, allLabel: r = "All", label
186
186
  });
187
187
  }
188
188
  // src/components/product-gallery/product-gallery.tsx
189
- function E({ images: e, sizes: t }) {
190
- let { renderImage: n } = y(), [r, i] = l(0);
189
+ function D({ images: e, sizes: t }) {
190
+ let { renderImage: n } = b(), [r, i] = l(0);
191
191
  return e.length === 0 ? null : /* @__PURE__ */ f("div", {
192
192
  className: "sf-gallery",
193
193
  role: "group",
@@ -233,21 +233,21 @@ function E({ images: e, sizes: t }) {
233
233
  });
234
234
  }
235
235
  // src/views/shop-view.tsx
236
- function D({ products: e, categories: n, activeCategory: r, slots: i = {}, labels: a, allLabel: o, formatCategoryLabel: s, sortCategories: c, nextHref: l, loadMoreLabel: u = "Load more" }) {
237
- let { renderLink: p } = y();
236
+ function O({ products: e, categories: n, activeCategory: r, slots: i = {}, labels: a, allLabel: o, formatCategoryLabel: s, sortCategories: c, nextHref: l, loadMoreLabel: u = "Load more" }) {
237
+ let { renderLink: p } = b();
238
238
  return /* @__PURE__ */ f("div", {
239
239
  className: "sf-shop",
240
240
  children: [
241
241
  i.header,
242
242
  i.intro,
243
- /* @__PURE__ */ d(T, {
243
+ /* @__PURE__ */ d(E, {
244
244
  categories: n,
245
245
  selected: r,
246
246
  allLabel: o,
247
247
  formatLabel: s,
248
248
  sortCategories: c
249
249
  }),
250
- /* @__PURE__ */ d(w, {
250
+ /* @__PURE__ */ d(T, {
251
251
  products: t(e),
252
252
  emptyState: i.emptyState,
253
253
  labels: a,
@@ -265,50 +265,59 @@ function D({ products: e, categories: n, activeCategory: r, slots: i = {}, label
265
265
  });
266
266
  }
267
267
  // src/views/product-detail-view.tsx
268
- function O({ product: e, slots: t = {}, labels: n }) {
268
+ function k({ product: e, slots: t = {}, labels: n, backHref: r, backLabel: i = "Back to the shop" }) {
269
+ let { renderLink: a } = b(), o = e.availability === "sold";
269
270
  return /* @__PURE__ */ f("article", {
270
- className: "sf-detail",
271
- children: [/* @__PURE__ */ d(E, { images: e.images }), /* @__PURE__ */ f("div", {
272
- className: "sf-detail__body",
273
- children: [
274
- /* @__PURE__ */ d("h1", {
275
- className: "sf-detail__title",
276
- children: e.name
277
- }),
278
- /* @__PURE__ */ d(b, {
279
- priceCents: e.priceCents,
280
- currency: e.currency
281
- }),
282
- /* @__PURE__ */ d(S, {
283
- availability: e.availability,
284
- quantity: e.quantity,
285
- labels: n
286
- }),
287
- /* @__PURE__ */ d("p", {
288
- className: "sf-detail__description",
289
- children: e.description
290
- }),
291
- (e.materials || e.dimensions) && /* @__PURE__ */ f("dl", {
292
- className: "sf-detail__specs",
293
- children: [e.materials && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("dt", { children: "Materials" }), /* @__PURE__ */ d("dd", { children: e.materials })] }), e.dimensions && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("dt", { children: "Dimensions" }), /* @__PURE__ */ d("dd", { children: e.dimensions })] })]
294
- }),
295
- t.actions && /* @__PURE__ */ d("div", {
296
- className: "sf-detail__actions",
297
- children: t.actions
298
- }),
299
- t.afterDetails
300
- ]
301
- })]
271
+ className: o ? "sf-detail sf-detail--sold" : "sf-detail",
272
+ children: [
273
+ r && a({
274
+ href: r,
275
+ className: "sf-detail__back",
276
+ children: i
277
+ }),
278
+ /* @__PURE__ */ d(D, { images: e.images }),
279
+ /* @__PURE__ */ f("div", {
280
+ className: "sf-detail__body",
281
+ children: [
282
+ /* @__PURE__ */ d("h1", {
283
+ className: "sf-detail__title",
284
+ children: e.name
285
+ }),
286
+ /* @__PURE__ */ d(x, {
287
+ priceCents: e.priceCents,
288
+ currency: e.currency
289
+ }),
290
+ /* @__PURE__ */ d(C, {
291
+ availability: e.availability,
292
+ quantity: e.quantity,
293
+ labels: n
294
+ }),
295
+ /* @__PURE__ */ d("p", {
296
+ className: "sf-detail__description",
297
+ children: e.description
298
+ }),
299
+ (e.materials || e.dimensions) && /* @__PURE__ */ f("dl", {
300
+ className: "sf-detail__specs",
301
+ children: [e.materials && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("dt", { children: "Materials" }), /* @__PURE__ */ d("dd", { children: e.materials })] }), e.dimensions && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("dt", { children: "Dimensions" }), /* @__PURE__ */ d("dd", { children: e.dimensions })] })]
302
+ }),
303
+ t.actions && /* @__PURE__ */ d("div", {
304
+ className: "sf-detail__actions",
305
+ children: t.actions
306
+ }),
307
+ t.afterDetails
308
+ ]
309
+ })
310
+ ]
302
311
  });
303
312
  }
304
313
  // src/views/featured-products.tsx
305
- function k({ products: e, heading: t = "Featured", labels: n }) {
314
+ function A({ products: e, heading: t = "Featured", labels: n }) {
306
315
  return e.length === 0 ? null : /* @__PURE__ */ f("section", {
307
316
  className: "sf-featured",
308
317
  children: [/* @__PURE__ */ d("h2", {
309
318
  className: "sf-featured__heading",
310
319
  children: t
311
- }), /* @__PURE__ */ d(w, {
320
+ }), /* @__PURE__ */ d(T, {
312
321
  products: e,
313
322
  labels: n,
314
323
  priorityCount: 6
@@ -316,8 +325,8 @@ function k({ products: e, heading: t = "Featured", labels: n }) {
316
325
  });
317
326
  }
318
327
  // src/cart/cart-reducer.ts
319
- var A = { lines: [] };
320
- function j(e, t) {
328
+ var j = { lines: [] };
329
+ function M(e, t) {
321
330
  let n = e.lines[0];
322
331
  if (n && n.currency !== t.currency) return {
323
332
  state: e,
@@ -352,42 +361,42 @@ function j(e, t) {
352
361
  capped: r.quantity + t.quantity > r.maxQuantity
353
362
  };
354
363
  }
355
- function M(e, t) {
364
+ function N(e, t) {
356
365
  switch (t.type) {
357
- case "add": return j(e, t.line).state;
366
+ case "add": return M(e, t.line).state;
358
367
  case "remove": return { lines: e.lines.filter((e) => e.productId !== t.productId) };
359
- case "setQuantity": return t.quantity <= 0 ? M(e, {
368
+ case "setQuantity": return t.quantity <= 0 ? N(e, {
360
369
  type: "remove",
361
370
  productId: t.productId
362
371
  }) : { lines: e.lines.map((e) => e.productId === t.productId ? {
363
372
  ...e,
364
373
  quantity: Math.min(t.quantity, e.maxQuantity)
365
374
  } : e) };
366
- case "clear": return A;
375
+ case "clear": return j;
367
376
  case "hydrate": return t.state;
368
377
  }
369
378
  }
370
- function N(e) {
379
+ function P(e) {
371
380
  return e.lines.reduce((e, t) => e + t.priceCents * t.quantity, 0);
372
381
  }
373
- function P(e) {
382
+ function F(e) {
374
383
  return e.lines.reduce((e, t) => e + t.quantity, 0);
375
384
  }
376
385
  // src/cart/cart-storage.ts
377
- function F(e = "sf-cart") {
386
+ function I(e = "sf-cart") {
378
387
  return {
379
388
  load() {
380
- if (typeof window > "u") return A;
389
+ if (typeof window > "u") return j;
381
390
  try {
382
391
  let t = window.localStorage.getItem(e);
383
- if (!t) return A;
392
+ if (!t) return j;
384
393
  let n = JSON.parse(t);
385
394
  return { lines: (Array.isArray(n?.lines) ? n.lines : []).flatMap((e) => {
386
395
  let t = p.safeParse(e);
387
396
  return t.success ? [t.data] : [];
388
397
  }) };
389
398
  } catch {
390
- return A;
399
+ return j;
391
400
  }
392
401
  },
393
402
  save(t) {
@@ -398,9 +407,9 @@ function F(e = "sf-cart") {
398
407
  };
399
408
  }
400
409
  // src/cart/cart-provider.tsx
401
- var I = n(null), L = F();
402
- function ee({ storage: e = L, children: t }) {
403
- let [n, i] = s(M, A), [u, f] = l(!1), [p, m] = l(!1), h = c(n);
410
+ var L = n(null), R = I();
411
+ function z({ storage: e = R, children: t }) {
412
+ let [n, i] = s(N, j), [u, f] = l(!1), [p, m] = l(!1), h = c(n);
404
413
  a(() => {
405
414
  h.current = n;
406
415
  }, [n]), a(() => {
@@ -421,15 +430,15 @@ function ee({ storage: e = L, children: t }) {
421
430
  e
422
431
  ]);
423
432
  let g = r((e) => {
424
- let t = j(h.current, e);
433
+ let t = M(h.current, e);
425
434
  return t.added && (h.current = t.state, i({
426
435
  type: "add",
427
436
  line: e
428
437
  })), t;
429
438
  }, []), _ = o(() => ({
430
439
  lines: n.lines,
431
- itemCount: P(n),
432
- subtotalCents: N(n),
440
+ itemCount: F(n),
441
+ subtotalCents: P(n),
433
442
  currency: n.lines[0]?.currency ?? null,
434
443
  hydrated: u,
435
444
  isOpen: p,
@@ -452,18 +461,18 @@ function ee({ storage: e = L, children: t }) {
452
461
  p,
453
462
  g
454
463
  ]);
455
- return /* @__PURE__ */ d(I.Provider, {
464
+ return /* @__PURE__ */ d(L.Provider, {
456
465
  value: _,
457
466
  children: t
458
467
  });
459
468
  }
460
- function R() {
461
- let e = i(I);
469
+ function B() {
470
+ let e = i(L);
462
471
  if (!e) throw Error("useCart must be used inside <CartProvider>");
463
472
  return e;
464
473
  }
465
474
  // src/components/cart-summary/discount-types.ts
466
- var z = {
475
+ var V = {
467
476
  toggle: "Have a code?",
468
477
  field: "Discount code",
469
478
  apply: "Apply",
@@ -480,17 +489,17 @@ var z = {
480
489
  currency: "That code does not apply to this cart."
481
490
  }
482
491
  };
483
- function B(e, t) {
484
- return t?.[e] ?? z.reasons[e];
492
+ function H(e, t) {
493
+ return t?.[e] ?? V.reasons[e];
485
494
  }
486
495
  // src/cart/use-checkout.ts
487
- var V = {
496
+ var U = {
488
497
  outOfStock: "Some items just sold or are on hold, so we removed them from your cart.",
489
498
  unavailable: "Checkout is unavailable right now. Please try again."
490
- }, te = (e) => window.location.assign(e);
491
- function ne({ startCheckout: e, onRedirect: t = te, onDiscountInvalid: n, labels: i }) {
492
- let a = R(), [o, s] = l(!1), [c, u] = l(null), { lines: d, remove: f } = a, p = {
493
- ...V,
499
+ }, W = (e) => window.location.assign(e);
500
+ function G({ startCheckout: e, onRedirect: t = W, onDiscountInvalid: n, labels: i }) {
501
+ let a = B(), [o, s] = l(!1), [c, u] = l(null), { lines: d, remove: f } = a, p = {
502
+ ...U,
494
503
  ...i
495
504
  };
496
505
  return {
@@ -505,7 +514,7 @@ function ne({ startCheckout: e, onRedirect: t = te, onDiscountInvalid: n, labels
505
514
  t(i.url);
506
515
  return;
507
516
  }
508
- i.error === "discount_invalid" ? (u(B(i.reason, p.discountReasons)), n?.(i.reason)) : (i.productIds.forEach(f), u(p.outOfStock));
517
+ i.error === "discount_invalid" ? (u(H(i.reason, p.discountReasons)), n?.(i.reason)) : (i.productIds.forEach(f), u(p.outOfStock));
509
518
  } catch {
510
519
  u(p.unavailable);
511
520
  }
@@ -524,17 +533,18 @@ function ne({ startCheckout: e, onRedirect: t = te, onDiscountInvalid: n, labels
524
533
  };
525
534
  }
526
535
  // src/components/add-to-cart-button/add-to-cart-button.tsx
527
- var H = {
536
+ var K = {
528
537
  add: "Add to cart",
529
538
  inCart: "In your cart",
530
- unavailable: "Unavailable"
539
+ unavailable: "Unavailable",
540
+ sold: "Sold"
531
541
  };
532
- function U({ product: e, labels: t, openOnAdd: n = !0, className: r }) {
533
- let i = R(), a = {
534
- ...H,
542
+ function q({ product: e, labels: t, openOnAdd: n = !0, className: r }) {
543
+ let i = B(), a = {
544
+ ...K,
535
545
  ...t
536
- }, o = i.lines.find((t) => t.productId === e.id)?.quantity ?? 0, s = e.availability !== "available", c = o >= e.quantity, l = !i.hydrated || s || c, u = s ? a.unavailable : c ? a.inCart : a.add;
537
- function f() {
546
+ }, o = i.lines.find((t) => t.productId === e.id)?.quantity ?? 0, s = e.availability === "sold", c = e.availability !== "available", l = o >= e.quantity, u = !i.hydrated || c || l, f = c ? a.unavailable : l ? a.inCart : a.add;
547
+ function p() {
538
548
  i.add({
539
549
  productId: e.id,
540
550
  slug: e.slug,
@@ -546,22 +556,25 @@ function U({ product: e, labels: t, openOnAdd: n = !0, className: r }) {
546
556
  maxQuantity: e.quantity
547
557
  }).added && n && i.open();
548
558
  }
549
- return /* @__PURE__ */ d("button", {
559
+ return s ? /* @__PURE__ */ d("span", {
560
+ className: ["sf-sold-note", r].filter(Boolean).join(" "),
561
+ children: a.sold
562
+ }) : /* @__PURE__ */ d("button", {
550
563
  type: "button",
551
564
  className: ["sf-button", r].filter(Boolean).join(" "),
552
- disabled: l,
553
- onClick: f,
554
- children: u
565
+ disabled: u,
566
+ onClick: p,
567
+ children: f
555
568
  });
556
569
  }
557
570
  // src/components/cart-line-item/cart-line-item.tsx
558
- var W = {
571
+ var J = {
559
572
  remove: "Remove",
560
573
  quantity: "Quantity"
561
574
  };
562
- function G({ line: t, labels: n }) {
563
- let { remove: r, setQuantity: i } = R(), { locale: a, renderLink: o, renderImage: s, hrefs: c } = y(), l = {
564
- ...W,
575
+ function Y({ line: t, labels: n }) {
576
+ let { remove: r, setQuantity: i } = B(), { locale: a, renderLink: o, renderImage: s, hrefs: c } = b(), l = {
577
+ ...J,
565
578
  ...n
566
579
  }, u = t.maxQuantity > 1;
567
580
  return /* @__PURE__ */ f("li", {
@@ -605,17 +618,17 @@ function G({ line: t, labels: n }) {
605
618
  });
606
619
  }
607
620
  // src/lib/parse-duration.ts
608
- function K(e) {
621
+ function ee(e) {
609
622
  let t = /^\s*(-?\d*\.?\d+)\s*(ms|s)\s*$/.exec(e);
610
623
  if (!t) return 0;
611
624
  let n = Number(t[1]);
612
625
  return Math.max(0, t[2] === "s" ? n * 1e3 : n);
613
626
  }
614
627
  // src/components/cart-drawer/use-drawer-presence.ts
615
- function q(e, t) {
628
+ function te(e, t) {
616
629
  let [n, r] = l(0), [i, o] = l(e), [s, c] = l(!1);
617
630
  return i !== e && (o(e), c(!e && n > 0)), a(() => {
618
- e && t.current && r(K(getComputedStyle(t.current).getPropertyValue("--sf-motion-duration")));
631
+ e && t.current && r(ee(getComputedStyle(t.current).getPropertyValue("--sf-motion-duration")));
619
632
  }, [e, t]), a(() => {
620
633
  if (!s) return;
621
634
  let e = setTimeout(() => c(!1), n);
@@ -626,7 +639,7 @@ function q(e, t) {
626
639
  };
627
640
  }
628
641
  // src/components/cart-summary/discount-field.tsx
629
- function J({ labels: t, applied: n, error: r, pending: i, currency: a, locale: o, onApply: s, onRemove: c }) {
642
+ function ne({ labels: t, applied: n, error: r, pending: i, currency: a, locale: o, onApply: s, onRemove: c }) {
630
643
  let [u, p] = l(!1), [m, h] = l("");
631
644
  function g(e) {
632
645
  e.preventDefault();
@@ -684,8 +697,8 @@ function J({ labels: t, applied: n, error: r, pending: i, currency: a, locale: o
684
697
  });
685
698
  }
686
699
  // src/components/cart-summary/use-discount.ts
687
- function Y(e) {
688
- let { lines: t } = R(), n = t.map((e) => ({
700
+ function re(e) {
701
+ let { lines: t } = B(), n = t.map((e) => ({
689
702
  productId: e.productId,
690
703
  quantity: e.quantity
691
704
  })), i = n.map((e) => `${e.productId}:${e.quantity}`).join(","), [o, s] = l(null), [u, d] = l(null), [f, p] = l(!1), m = c({
@@ -744,12 +757,12 @@ function Y(e) {
744
757
  };
745
758
  }
746
759
  // src/components/cart-summary/cart-summary.tsx
747
- function X({ onCheckout: t, checkoutLabel: n = "Checkout", checkoutDisabled: r = !1, labels: i, discount: a }) {
748
- let o = R(), { locale: s } = y(), c = i?.subtotal ?? "Subtotal", l = Y(a), u = {
749
- ...z,
760
+ function X({ onCheckout: t, checkoutLabel: n = "Checkout", checkoutDisabled: r = !1, labels: i, discount: a, showTaxNote: o = !1 }) {
761
+ let s = B(), { locale: c } = b(), l = i?.subtotal ?? "Subtotal", u = i?.taxNote ?? "Tax calculated at checkout", p = re(a), m = {
762
+ ...V,
750
763
  ...i?.discount,
751
764
  reasons: {
752
- ...z.reasons,
765
+ ...V.reasons,
753
766
  ...i?.discount?.reasons
754
767
  }
755
768
  };
@@ -758,25 +771,29 @@ function X({ onCheckout: t, checkoutLabel: n = "Checkout", checkoutDisabled: r =
758
771
  children: [
759
772
  /* @__PURE__ */ f("p", {
760
773
  className: "sf-cart-summary__row",
761
- children: [/* @__PURE__ */ d("span", { children: c }), /* @__PURE__ */ d("span", {
774
+ children: [/* @__PURE__ */ d("span", { children: l }), /* @__PURE__ */ d("span", {
762
775
  className: "sf-price",
763
- children: e(o.subtotalCents, o.currency ?? "USD", s)
776
+ children: e(s.subtotalCents, s.currency ?? "USD", c)
764
777
  })]
765
778
  }),
766
- a && o.lines.length > 0 && /* @__PURE__ */ d(J, {
767
- labels: u,
768
- currency: o.currency ?? "USD",
769
- locale: s,
770
- onApply: (e) => void l.apply(e),
771
- onRemove: l.remove,
772
- applied: l.applied,
773
- error: l.error,
774
- pending: l.pending
779
+ o && s.lines.length > 0 && /* @__PURE__ */ d("p", {
780
+ className: "sf-cart-summary__tax-note",
781
+ children: u
782
+ }),
783
+ a && s.lines.length > 0 && /* @__PURE__ */ d(ne, {
784
+ labels: m,
785
+ currency: s.currency ?? "USD",
786
+ locale: c,
787
+ onApply: (e) => void p.apply(e),
788
+ onRemove: p.remove,
789
+ applied: p.applied,
790
+ error: p.error,
791
+ pending: p.pending
775
792
  }),
776
793
  /* @__PURE__ */ d("button", {
777
794
  type: "button",
778
795
  className: "sf-button",
779
- disabled: r || !t || o.lines.length === 0,
796
+ disabled: r || !t || s.lines.length === 0,
780
797
  onClick: t,
781
798
  children: n
782
799
  })
@@ -789,11 +806,11 @@ var Z = {
789
806
  close: "Close",
790
807
  empty: "Your cart is empty."
791
808
  }, Q = "a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
792
- function re({ labels: e, summary: t, slots: n }) {
793
- let r = R(), i = {
809
+ function ie({ labels: e, summary: t, slots: n }) {
810
+ let r = B(), i = {
794
811
  ...Z,
795
812
  ...e
796
- }, o = c(null), s = c(null), { isOpen: l } = r, p = q(l, s);
813
+ }, o = c(null), s = c(null), { isOpen: l } = r, p = te(l, s);
797
814
  if (a(() => {
798
815
  if (!l) return;
799
816
  let e = document.activeElement;
@@ -846,7 +863,7 @@ function re({ labels: e, summary: t, slots: n }) {
846
863
  }) : /* @__PURE__ */ f(u, { children: [
847
864
  /* @__PURE__ */ d("ul", {
848
865
  className: "sf-drawer__lines",
849
- children: r.lines.map((e) => /* @__PURE__ */ d(G, { line: e }, e.productId))
866
+ children: r.lines.map((e) => /* @__PURE__ */ d(Y, { line: e }, e.productId))
850
867
  }),
851
868
  /* @__PURE__ */ d(X, { ...t }),
852
869
  n?.summaryNote && /* @__PURE__ */ d("div", {
@@ -858,8 +875,8 @@ function re({ labels: e, summary: t, slots: n }) {
858
875
  });
859
876
  }
860
877
  // src/components/cart-button/cart-button.tsx
861
- function ie({ label: e = "Cart", className: t, icon: n, labelHidden: r = !1, hideZeroCount: i = !1 }) {
862
- let a = R(), o = a.hydrated ? a.itemCount : 0, s = !(i && o === 0), c = s ? r ? `${e}, ${a.itemCount} items` : void 0 : `${e}, empty`;
878
+ function ae({ label: e = "Cart", className: t, icon: n, labelHidden: r = !1, hideZeroCount: i = !1 }) {
879
+ let a = B(), o = a.hydrated ? a.itemCount : 0, s = !(i && o === 0), c = s ? r ? `${e}, ${a.itemCount} items` : void 0 : `${e}, empty`;
863
880
  return /* @__PURE__ */ f("button", {
864
881
  type: "button",
865
882
  className: ["sf-cart-button", t].filter(Boolean).join(" "),
@@ -889,6 +906,7 @@ var $ = {
889
906
  subtotal: "Subtotal",
890
907
  discount: "Discount",
891
908
  shipping: "Shipping",
909
+ tax: "Tax",
892
910
  total: "Total",
893
911
  shipTo: "Ship to",
894
912
  tracking: "Track",
@@ -903,7 +921,7 @@ var $ = {
903
921
  }
904
922
  };
905
923
  // src/components/checkout-success/checkout-success-view.tsx
906
- function ae(e) {
924
+ function oe(e) {
907
925
  let t = [
908
926
  e.city,
909
927
  e.state,
@@ -917,7 +935,7 @@ function ae(e) {
917
935
  e.country
918
936
  ].filter((e) => !!e);
919
937
  }
920
- function oe({ order: t, locale: n, labels: r, className: i, slots: a, showReference: o, showSummaryHeading: s, continueHref: c, renderLink: l }) {
938
+ function se({ order: t, locale: n, labels: r, className: i, slots: a, showReference: o, showSummaryHeading: s, continueHref: c, renderLink: l }) {
921
939
  let u = {
922
940
  ...$,
923
941
  ...r,
@@ -925,11 +943,11 @@ function oe({ order: t, locale: n, labels: r, className: i, slots: a, showRefere
925
943
  ...$.status,
926
944
  ...r?.status
927
945
  }
928
- }, p = (r) => e(r, t.currency, n), m = t.shippingAddress ? ae(t.shippingAddress) : [], { fulfillment: h } = t, g = {
946
+ }, p = (r) => e(r, t.currency, n), h = t.shippingAddress ? oe(t.shippingAddress) : [], { fulfillment: g } = t, _ = {
929
947
  href: c ?? "",
930
948
  className: "sf-checkout-success__continue",
931
949
  children: u.continue
932
- }, _ = c ? l ? l(g) : /* @__PURE__ */ d("a", { ...g }) : null, v = a?.actions ?? _;
950
+ }, v = c ? l ? l(_) : /* @__PURE__ */ d("a", { ..._ }) : null, y = a?.actions ?? v;
933
951
  return /* @__PURE__ */ f("section", {
934
952
  className: ["sf-checkout-success", i].filter(Boolean).join(" "),
935
953
  "data-status": t.status,
@@ -940,7 +958,7 @@ function oe({ order: t, locale: n, labels: r, className: i, slots: a, showRefere
940
958
  }),
941
959
  o && /* @__PURE__ */ d("p", {
942
960
  className: "sf-checkout-success__reference",
943
- children: u.reference.replace("{id}", t.id)
961
+ children: u.reference.replace("{id}", m(t.id))
944
962
  }),
945
963
  a?.header,
946
964
  /* @__PURE__ */ d("p", {
@@ -984,6 +1002,11 @@ function oe({ order: t, locale: n, labels: r, className: i, slots: a, showRefere
984
1002
  ")"
985
1003
  ] }), /* @__PURE__ */ d("dd", { children: p(t.shippingCents) })]
986
1004
  }),
1005
+ t.taxCents > 0 && /* @__PURE__ */ f("div", {
1006
+ className: "sf-checkout-success__row",
1007
+ "data-tax": !0,
1008
+ children: [/* @__PURE__ */ d("dt", { children: u.tax }), /* @__PURE__ */ d("dd", { children: p(t.taxCents) })]
1009
+ }),
987
1010
  /* @__PURE__ */ f("div", {
988
1011
  className: "sf-checkout-success__row sf-checkout-success__row--total",
989
1012
  children: [/* @__PURE__ */ d("dt", { children: u.total }), /* @__PURE__ */ d("dd", { children: p(t.totalCents) })]
@@ -991,35 +1014,35 @@ function oe({ order: t, locale: n, labels: r, className: i, slots: a, showRefere
991
1014
  ]
992
1015
  }),
993
1016
  a?.afterTotals,
994
- m.length > 0 && /* @__PURE__ */ f("address", {
1017
+ h.length > 0 && /* @__PURE__ */ f("address", {
995
1018
  className: "sf-checkout-success__address",
996
- children: [/* @__PURE__ */ d("strong", { children: u.shipTo }), m.map((e) => /* @__PURE__ */ d("span", { children: e }, e))]
1019
+ children: [/* @__PURE__ */ d("strong", { children: u.shipTo }), h.map((e) => /* @__PURE__ */ d("span", { children: e }, e))]
997
1020
  }),
998
- h?.trackingNumber && /* @__PURE__ */ f("p", {
1021
+ g?.trackingNumber && /* @__PURE__ */ f("p", {
999
1022
  className: "sf-checkout-success__tracking",
1000
- children: [h.carrier && `${h.carrier} · `, h.trackingUrl ? /* @__PURE__ */ f("a", {
1001
- href: h.trackingUrl,
1023
+ children: [g.carrier && `${g.carrier} · `, g.trackingUrl ? /* @__PURE__ */ f("a", {
1024
+ href: g.trackingUrl,
1002
1025
  children: [
1003
1026
  u.tracking,
1004
1027
  " ",
1005
- h.trackingNumber
1028
+ g.trackingNumber
1006
1029
  ]
1007
- }) : h.trackingNumber]
1030
+ }) : g.trackingNumber]
1008
1031
  }),
1009
- v && /* @__PURE__ */ d("div", {
1032
+ y && /* @__PURE__ */ d("div", {
1010
1033
  className: "sf-checkout-success__actions",
1011
- children: v
1034
+ children: y
1012
1035
  })
1013
1036
  ]
1014
1037
  });
1015
1038
  }
1016
1039
  // src/cart/clear-cart-on-mount.tsx
1017
- function se() {
1018
- let { hydrated: e, clear: t } = R(), n = c(!1);
1040
+ function ce() {
1041
+ let { hydrated: e, clear: t } = B(), n = c(!1);
1019
1042
  return a(() => {
1020
1043
  e && !n.current && (n.current = !0, t());
1021
1044
  }, [e, t]), null;
1022
1045
  }
1023
- export { U as AddToCartButton, S as AvailabilityBadge, ie as CartButton, re as CartDrawer, G as CartLineItem, ee as CartProvider, X as CartSummary, T as CategoryFilter, oe as CheckoutSuccessView, se as ClearCartOnMount, k as FeaturedProducts, b as PriceTag, C as ProductCard, O as ProductDetailView, E as ProductGallery, w as ProductGrid, D as ShopView, v as StorefrontProvider, j as addLine, M as cartReducer, H as defaultAddToCartLabels, x as defaultAvailabilityLabels, Z as defaultCartDrawerLabels, W as defaultCartLineItemLabels, V as defaultCheckoutLabels, $ as defaultCheckoutSuccessLabels, B as discountReasonMessage, A as emptyCart, e as formatPrice, P as itemCount, F as localStorageCartStorage, t as sortForDisplay, N as subtotalCents, h as themeToCssVars, R as useCart, ne as useCheckout, y as useStorefront };
1046
+ export { q as AddToCartButton, C as AvailabilityBadge, ae as CartButton, ie as CartDrawer, Y as CartLineItem, z as CartProvider, X as CartSummary, E as CategoryFilter, se as CheckoutSuccessView, ce as ClearCartOnMount, A as FeaturedProducts, x as PriceTag, w as ProductCard, k as ProductDetailView, D as ProductGallery, T as ProductGrid, O as ShopView, y as StorefrontProvider, M as addLine, N as cartReducer, K as defaultAddToCartLabels, S as defaultAvailabilityLabels, Z as defaultCartDrawerLabels, J as defaultCartLineItemLabels, U as defaultCheckoutLabels, $ as defaultCheckoutSuccessLabels, H as discountReasonMessage, j as emptyCart, e as formatPrice, F as itemCount, I as localStorageCartStorage, t as sortForDisplay, P as subtotalCents, g as themeToCssVars, B as useCart, G as useCheckout, b as useStorefront };
1024
1047
 
1025
1048
  //# sourceMappingURL=index.js.map