@asteby/storefront-react 0.19.0 → 0.21.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 (51) hide show
  1. package/README.md +41 -0
  2. package/dist/account-server.cjs +405 -7
  3. package/dist/account-server.cjs.map +1 -1
  4. package/dist/account-server.d.cts +41 -1
  5. package/dist/account-server.d.ts +41 -1
  6. package/dist/account-server.js +73 -3
  7. package/dist/account-server.js.map +1 -1
  8. package/dist/account.cjs +1663 -4
  9. package/dist/account.cjs.map +1 -1
  10. package/dist/account.css +362 -0
  11. package/dist/account.d.cts +499 -3
  12. package/dist/account.d.ts +499 -3
  13. package/dist/account.js +1102 -2
  14. package/dist/account.js.map +1 -1
  15. package/dist/cart.cjs +125 -2
  16. package/dist/cart.cjs.map +1 -1
  17. package/dist/cart.css +145 -2
  18. package/dist/cart.js +4 -2
  19. package/dist/cart.js.map +1 -1
  20. package/dist/checkout.cjs +129 -1
  21. package/dist/checkout.cjs.map +1 -1
  22. package/dist/checkout.css +142 -0
  23. package/dist/checkout.d.cts +3 -1
  24. package/dist/checkout.d.ts +3 -1
  25. package/dist/checkout.js +10 -3
  26. package/dist/checkout.js.map +1 -1
  27. package/dist/chunk-PPQEUTXJ.js +260 -0
  28. package/dist/chunk-PPQEUTXJ.js.map +1 -0
  29. package/dist/chunk-TXEYBDFG.js +182 -0
  30. package/dist/chunk-TXEYBDFG.js.map +1 -0
  31. package/dist/chunk-VHEY5AU3.js +152 -0
  32. package/dist/chunk-VHEY5AU3.js.map +1 -0
  33. package/dist/fiscal.d.cts +34 -34
  34. package/dist/fiscal.d.ts +34 -34
  35. package/dist/fiscal.js +4 -258
  36. package/dist/fiscal.js.map +1 -1
  37. package/dist/index.js +1 -1
  38. package/dist/payments.css +15 -14
  39. package/dist/payments.js +2 -2
  40. package/dist/product-preview-DRtLWGLS.d.cts +85 -0
  41. package/dist/product-preview-DaICr4f2.d.ts +85 -0
  42. package/dist/ui.cjs +202 -0
  43. package/dist/ui.cjs.map +1 -1
  44. package/dist/ui.css +142 -0
  45. package/dist/ui.d.cts +3 -0
  46. package/dist/ui.d.ts +3 -0
  47. package/dist/ui.js +3 -1
  48. package/dist/ui.js.map +1 -1
  49. package/dist/voucher-document-SFWJCLTN.js +124 -0
  50. package/dist/voucher-document-SFWJCLTN.js.map +1 -0
  51. package/package.json +2 -2
package/dist/account.cjs CHANGED
@@ -2,8 +2,331 @@
2
2
 
3
3
  var react = require('react');
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
+ var storefront = require('@asteby/storefront');
5
6
 
6
- // src/account/account-auth.tsx
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropNames = Object.getOwnPropertyNames;
9
+ var __esm = (fn, res) => function __init() {
10
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
+ };
12
+ var __export = (target, all) => {
13
+ for (var name in all)
14
+ __defProp(target, name, { get: all[name], enumerable: true });
15
+ };
16
+
17
+ // src/account/voucher.ts
18
+ function text(v) {
19
+ if (typeof v === "number" && Number.isFinite(v)) return String(v);
20
+ if (typeof v !== "string") return null;
21
+ const s = v.trim().slice(0, MAX);
22
+ return s || null;
23
+ }
24
+ function moneyOf(v) {
25
+ if (!v || typeof v !== "object") return null;
26
+ const m = v;
27
+ const amount = text(m.amount);
28
+ const cur = text(m.currency_code);
29
+ return amount && cur && Number.isFinite(Number(amount)) ? { amount, currency_code: cur.toUpperCase() } : null;
30
+ }
31
+ function voucherOf(p) {
32
+ const pay = p?.payment;
33
+ if (!pay || typeof pay !== "object") return null;
34
+ const v = {
35
+ method: text(pay.method ?? pay.provider),
36
+ reference: text(pay.reference),
37
+ barcode: text(pay.barcode),
38
+ clabe: text(pay.clabe),
39
+ expires_at: text(pay.expires_at) ?? text(p?.expires_at),
40
+ amount: moneyOf(pay.amount) ?? moneyOf(p?.total),
41
+ instructions: text(pay.instructions)
42
+ };
43
+ return v.reference || v.barcode || v.clabe ? v : null;
44
+ }
45
+ function barcodeValue(v) {
46
+ return v.barcode ?? (v.method?.toLowerCase() === "oxxo" ? v.reference : null);
47
+ }
48
+ function code128Modules(value) {
49
+ if (!value || value.length > 80) return null;
50
+ let codes;
51
+ if (/^\d+$/.test(value) && value.length % 2 === 0) {
52
+ codes = [105];
53
+ for (let i = 0; i < value.length; i += 2) codes.push(Number(value.slice(i, i + 2)));
54
+ } else {
55
+ codes = [104];
56
+ for (const ch of value) {
57
+ const c = ch.charCodeAt(0);
58
+ if (c < 32 || c > 126) return null;
59
+ codes.push(c - 32);
60
+ }
61
+ }
62
+ let sum = codes[0];
63
+ for (let i = 1; i < codes.length; i++) sum += codes[i] * i;
64
+ codes.push(sum % 103);
65
+ return codes.map((c) => BARS[c]).join("") + STOP;
66
+ }
67
+ function barcodeGeometry(value, opts = {}) {
68
+ const bits = code128Modules(value);
69
+ if (!bits) return null;
70
+ const mod = opts.module ?? 2;
71
+ const quiet = 10;
72
+ const rects = [];
73
+ for (let i = 0; i < bits.length; ) {
74
+ if (bits[i] === "0") {
75
+ i++;
76
+ continue;
77
+ }
78
+ let j = i;
79
+ while (j < bits.length && bits[j] === "1") j++;
80
+ rects.push({ x: (quiet + i) * mod, w: (j - i) * mod });
81
+ i = j;
82
+ }
83
+ return { width: (bits.length + quiet * 2) * mod, height: opts.height ?? 70, rects };
84
+ }
85
+ var MAX, BARS, STOP;
86
+ var init_voucher = __esm({
87
+ "src/account/voucher.ts"() {
88
+ MAX = 256;
89
+ BARS = [
90
+ "11011001100",
91
+ "11001101100",
92
+ "11001100110",
93
+ "10010011000",
94
+ "10010001100",
95
+ "10001001100",
96
+ "10011001000",
97
+ "10011000100",
98
+ "10001100100",
99
+ "11001001000",
100
+ "11001000100",
101
+ "11000100100",
102
+ "10110011100",
103
+ "10011011100",
104
+ "10011001110",
105
+ "10111001100",
106
+ "10011101100",
107
+ "10011100110",
108
+ "11001110010",
109
+ "11001011100",
110
+ "11001001110",
111
+ "11011100100",
112
+ "11001110100",
113
+ "11101101110",
114
+ "11101001100",
115
+ "11100101100",
116
+ "11100100110",
117
+ "11101100100",
118
+ "11100110100",
119
+ "11100110010",
120
+ "11011011000",
121
+ "11011000110",
122
+ "11000110110",
123
+ "10100011000",
124
+ "10001011000",
125
+ "10001000110",
126
+ "10110001000",
127
+ "10001101000",
128
+ "10001100010",
129
+ "11010001000",
130
+ "11000101000",
131
+ "11000100010",
132
+ "10110111000",
133
+ "10110001110",
134
+ "10001101110",
135
+ "10111011000",
136
+ "10111000110",
137
+ "10001110110",
138
+ "11101110110",
139
+ "11010001110",
140
+ "11000101110",
141
+ "11011101000",
142
+ "11011100010",
143
+ "11011101110",
144
+ "11101011000",
145
+ "11101000110",
146
+ "11100010110",
147
+ "11101101000",
148
+ "11101100010",
149
+ "11100011010",
150
+ "11101111010",
151
+ "11001000010",
152
+ "11110001010",
153
+ "10100110000",
154
+ "10100001100",
155
+ "10010110000",
156
+ "10010000110",
157
+ "10000101100",
158
+ "10000100110",
159
+ "10110010000",
160
+ "10110000100",
161
+ "10011010000",
162
+ "10011000010",
163
+ "10000110100",
164
+ "10000110010",
165
+ "11000010010",
166
+ "11001010000",
167
+ "11110111010",
168
+ "11000010100",
169
+ "10001111010",
170
+ "10100111100",
171
+ "10010111100",
172
+ "10010011110",
173
+ "10111100100",
174
+ "10011110100",
175
+ "10011110010",
176
+ "11110100100",
177
+ "11110010100",
178
+ "11110010010",
179
+ "11011011110",
180
+ "11011110110",
181
+ "11110110110",
182
+ "10101111000",
183
+ "10100011110",
184
+ "10001011110",
185
+ "10111101000",
186
+ "10111100010",
187
+ "11110101000",
188
+ "11110100010",
189
+ "10111011110",
190
+ "10111101110",
191
+ "11101011110",
192
+ "11110101110",
193
+ "11010000100",
194
+ "11010010000",
195
+ "11010011100"
196
+ ];
197
+ STOP = "1100011101011";
198
+ }
199
+ });
200
+
201
+ // src/account/voucher-document.ts
202
+ var voucher_document_exports = {};
203
+ __export(voucher_document_exports, {
204
+ esc: () => esc,
205
+ renderVoucherDocument: () => renderVoucherDocument
206
+ });
207
+ function esc(s) {
208
+ return s.replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]);
209
+ }
210
+ function formatMoney3(m, locale) {
211
+ if (!m) return "";
212
+ try {
213
+ return new Intl.NumberFormat(locale, { style: "currency", currency: m.currency_code }).format(Number(m.amount));
214
+ } catch {
215
+ return `${m.amount} ${m.currency_code}`;
216
+ }
217
+ }
218
+ function formatDate2(iso, locale, timeZone) {
219
+ if (!iso) return "";
220
+ const d = new Date(iso);
221
+ if (Number.isNaN(d.getTime())) return "";
222
+ try {
223
+ return d.toLocaleString(locale, { dateStyle: "long", timeStyle: "short", ...timeZone ? { timeZone } : {} });
224
+ } catch {
225
+ return d.toISOString();
226
+ }
227
+ }
228
+ function barcodeSvg(value, label) {
229
+ const g = barcodeGeometry(value);
230
+ if (!g) return null;
231
+ const rects = g.rects.map((r) => `<rect x="${r.x}" y="0" width="${r.w}" height="${g.height}"/>`).join("");
232
+ return `<svg viewBox="0 0 ${g.width} ${g.height}" width="${g.width}" height="${g.height}" role="img" aria-label="${esc(label)} ${esc(value)}" shape-rendering="crispEdges" fill="#000">${rects}</svg>`;
233
+ }
234
+ function renderVoucherDocument(v, opts = {}) {
235
+ const locale = opts.locale ?? "es-MX";
236
+ const t = locale.toLowerCase().startsWith("en") ? EN5 : ES5;
237
+ const shop = opts.shopName || "";
238
+ const method = v.method ? Object.prototype.hasOwnProperty.call(t.methods, v.method.toLowerCase()) ? t.methods[v.method.toLowerCase()] : v.method : t.cash;
239
+ const isSpei = !!v.clabe && !v.reference;
240
+ const code = barcodeValue(v);
241
+ const svg = code ? barcodeSvg(code, t.barcode) : null;
242
+ const expires = formatDate2(v.expires_at, locale, opts.timeZone);
243
+ const field = (label, value) => value ? `<div class="box"><div class="label">${esc(label)}</div><div class="value">${esc(value)}</div></div>` : "";
244
+ const steps = isSpei ? t.stepsSpei : t.stepsCash;
245
+ const subtitle = [shop, method, opts.number ? `${t.order} ${opts.number}` : ""].filter(Boolean).map(esc).join(" \xB7 ");
246
+ return `<!doctype html>
247
+ <html lang="${esc(locale)}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
248
+ <meta name="robots" content="noindex"><title>${esc(t.title)}${shop ? ` - ${esc(shop)}` : ""}</title><style>${CSS}</style></head>
249
+ <body><main>
250
+ <div class="head"><div><h1>${esc(t.title)}</h1><div class="muted">${subtitle}</div></div>
251
+ ${v.amount ? `<div><div class="label" style="text-align:right">${esc(t.total)}</div><div class="amount">${esc(formatMoney3(v.amount, locale))}</div></div>` : ""}</div>
252
+ ${field(t.reference, v.reference)}${field(t.clabe, v.clabe)}
253
+ ${svg ? `<div class="bar">${svg}<div class="muted" style="font-family:ui-monospace,monospace">${esc(code)}</div></div>` : ""}
254
+ ${expires ? `<p><strong>${esc(t.expires)}:</strong> ${esc(expires)}. ${esc(t.expiresNote)}</p>` : ""}
255
+ <ol class="steps">${steps.map((s) => `<li>${esc(s)}</li>`).join("")}</ol>
256
+ ${v.instructions ? `<p class="note pre muted">${esc(v.instructions)}</p>` : ""}
257
+ <p class="note muted">${esc(t.footer)}</p>
258
+ ${opts.printButton ? `<div class="actions"><button type="button" id="print">${esc(t.print)}</button></div>` : ""}
259
+ </main>
260
+ ${opts.printButton || opts.autoPrint ? `<script${opts.nonce ? ` nonce="${esc(opts.nonce)}"` : ""}>(function(){var b=document.getElementById("print");if(b)b.addEventListener("click",function(){window.print()});${opts.autoPrint ? 'window.addEventListener("load",function(){setTimeout(function(){window.print()},300)});' : ""}})();</script>` : ""}
261
+ </body></html>`;
262
+ }
263
+ var ES5, EN5, CSS;
264
+ var init_voucher_document = __esm({
265
+ "src/account/voucher-document.ts"() {
266
+ init_voucher();
267
+ ES5 = {
268
+ title: "Ficha de pago",
269
+ total: "Total a pagar",
270
+ reference: "Referencia",
271
+ clabe: "CLABE",
272
+ expires: "Vence",
273
+ expiresNote: "Pasada esa fecha la ficha deja de ser v\xE1lida.",
274
+ order: "Pedido",
275
+ barcode: "C\xF3digo de barras",
276
+ print: "Imprimir ficha",
277
+ footer: "Tu pedido se genera cuando se confirma el pago. Esta ficha es de un solo uso; no la compartas.",
278
+ stepsCash: [
279
+ "Acude a la tienda OXXO (o el comercio indicado) y di que vas a hacer un pago de servicio en efectivo.",
280
+ "Muestra el c\xF3digo de barras o dicta la referencia y paga el monto exacto.",
281
+ "Conserva tu comprobante: confirmaremos tu pago autom\xE1ticamente."
282
+ ],
283
+ stepsSpei: ["Entra a la banca en l\xEDnea o app de tu banco.", "Haz una transferencia SPEI a la CLABE indicada por el monto exacto.", "Conserva tu comprobante: confirmaremos tu pago autom\xE1ticamente."],
284
+ methods: { oxxo: "OXXO", spei: "Transferencia SPEI", bank_transfer: "Transferencia bancaria", bank_deposit: "Dep\xF3sito bancario", cash: "Pago en efectivo" },
285
+ cash: "Pago en efectivo"
286
+ };
287
+ EN5 = {
288
+ title: "Payment voucher",
289
+ total: "Amount to pay",
290
+ reference: "Reference",
291
+ clabe: "CLABE",
292
+ expires: "Expires",
293
+ expiresNote: "After that date the voucher is no longer valid.",
294
+ order: "Order",
295
+ barcode: "Barcode",
296
+ print: "Print voucher",
297
+ footer: "Your order is created when the payment is confirmed. This voucher is single-use; do not share it.",
298
+ stepsCash: [
299
+ "Go to an OXXO store (or the store indicated) and say you want to make a cash service payment.",
300
+ "Show the barcode or read out the reference and pay the exact amount.",
301
+ "Keep your receipt: we will confirm your payment automatically."
302
+ ],
303
+ stepsSpei: ["Open your bank online or app.", "Make a SPEI transfer to the CLABE below for the exact amount.", "Keep your receipt: we will confirm your payment automatically."],
304
+ methods: { oxxo: "OXXO", spei: "SPEI transfer", bank_transfer: "Bank transfer", bank_deposit: "Bank deposit", cash: "Cash payment" },
305
+ cash: "Cash payment"
306
+ };
307
+ CSS = `
308
+ @page { size: A4; margin: 18mm; }
309
+ * { box-sizing: border-box; }
310
+ body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #111; background: #fff; }
311
+ main { max-width: 174mm; margin: 0 auto; padding: 24px 16px; }
312
+ h1 { font-size: 22px; margin: 0; }
313
+ .muted { color: #555; }
314
+ .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-bottom: 3px solid #111; padding-bottom: 12px; }
315
+ .amount { font-size: 28px; font-weight: 700; text-align: right; }
316
+ .box { border: 1px solid #111; padding: 14px 16px; margin-top: 18px; }
317
+ .label { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: #555; }
318
+ .value { font: 700 22px/1.3 ui-monospace, "SF Mono", Menlo, Consolas, monospace; word-break: break-all; letter-spacing: .04em; }
319
+ .bar { margin-top: 18px; text-align: center; }
320
+ .bar svg { max-width: 100%; height: auto; }
321
+ .steps { margin: 18px 0 0; padding-left: 20px; }
322
+ .note { margin-top: 18px; font-size: 12px; }
323
+ .pre { white-space: pre-line; }
324
+ .actions { margin-top: 24px; display: flex; gap: 12px; }
325
+ .actions button { font: inherit; padding: 10px 18px; border: 1px solid #111; background: #111; color: #fff; cursor: pointer; }
326
+ @media print { .actions { display: none; } main { padding: 0; } }
327
+ `;
328
+ }
329
+ });
7
330
  var ES = {
8
331
  valueMissing: "Completa este campo.",
9
332
  choiceMissing: "Elige una opci\xF3n.",
@@ -49,8 +372,8 @@ function labelOf(el) {
49
372
  const legend = el.closest("fieldset")?.querySelector("legend");
50
373
  if (legend?.textContent) return legend.textContent.trim();
51
374
  }
52
- const text = el.labels?.[0]?.getAttribute("data-sf-label") ?? el.labels?.[0]?.textContent ?? el.getAttribute("aria-label") ?? el.name;
53
- return text.trim();
375
+ const text2 = el.labels?.[0]?.getAttribute("data-sf-label") ?? el.labels?.[0]?.textContent ?? el.getAttribute("aria-label") ?? el.name;
376
+ return text2.trim();
54
377
  }
55
378
  function useFieldErrors(formRef, options = {}) {
56
379
  const m = fieldMessages(options.locale, options.messages);
@@ -357,7 +680,7 @@ function AccountAuth({ capabilities, data, next, pending = false, initialView, f
357
680
  ...newPassword ? { minLength: 10, maxLength: 128, hint: m.passwordHint } : {}
358
681
  }
359
682
  );
360
- const link = (to, text) => /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: cx.link, "data-sf-account-link": to, onClick: () => go(to), children: text });
683
+ const link = (to, text2) => /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: cx.link, "data-sf-account-link": to, onClick: () => go(to), children: text2 });
361
684
  let body;
362
685
  let links = null;
363
686
  switch (view) {
@@ -540,9 +863,1345 @@ function PostPurchaseAccountPrompt({
540
863
  ] });
541
864
  }
542
865
 
866
+ // src/fiscal/messages.ts
867
+ function fill(template, vars) {
868
+ return template.replace(/\{(\w+)\}/g, (m, k) => k in vars ? String(vars[k]) : m);
869
+ }
870
+
871
+ // src/account/orders-messages.ts
872
+ var ES4 = {
873
+ // order list
874
+ "order.number": "Pedido {number}",
875
+ "order.placed": "Realizado el {date}",
876
+ "order.total": "Total",
877
+ "order.view": "Ver pedido",
878
+ "order.items.one": "{count} art\xEDculo",
879
+ "order.items.other": "{count} art\xEDculos",
880
+ "order.lines": "Art\xEDculos del pedido",
881
+ "order.line.quantity": "Cantidad {n}",
882
+ "order.line.each": "{price} c/u",
883
+ "order.line.unavailable": "Producto no disponible",
884
+ "order.productsMore": "y {n} m\xE1s",
885
+ "order.stepOf": "Paso {n} de {total}: {step}",
886
+ "order.listLabel": "Tus pedidos",
887
+ "order.loading": "Cargando tus pedidos",
888
+ "order.loadMore": "Ver m\xE1s pedidos",
889
+ "order.loadingMore": "Cargando\u2026",
890
+ "order.error": "No pudimos cargar tus pedidos. Tus compras est\xE1n a salvo.",
891
+ "order.retry": "Reintentar",
892
+ "order.emptyTitle": "A\xFAn no tienes pedidos",
893
+ "order.emptyBody": "Cuando compres, aqu\xED ver\xE1s el estado y el env\xEDo de cada pedido.",
894
+ "order.emptyGuest": "\xBFCompraste como invitado? Verifica tu correo para ver aqu\xED tus pedidos.",
895
+ // stage (order status)
896
+ "stage.pending_payment": "Esperando pago",
897
+ "stage.paid": "Pagado",
898
+ "stage.preparing": "En preparaci\xF3n",
899
+ "stage.ready_for_pickup": "Listo para recoger",
900
+ "stage.shipped": "Enviado",
901
+ "stage.in_transit": "En camino",
902
+ "stage.out_for_delivery": "En reparto",
903
+ "stage.delivered": "Entregado",
904
+ "stage.cancelled": "Cancelado",
905
+ "stage.refunded": "Reembolsado",
906
+ "stage.unknown": "En proceso",
907
+ // progress
908
+ "progress.label": "Progreso del pedido",
909
+ "step.paid": "Pagado",
910
+ "step.preparing": "En preparaci\xF3n",
911
+ "step.shipped": "Enviado",
912
+ "step.in_transit": "En camino",
913
+ "step.ready_for_pickup": "Listo para recoger",
914
+ "step.delivered": "Entregado",
915
+ "step.unknown": "Siguiente paso",
916
+ "stepState.done": "completado",
917
+ "stepState.current": "paso actual",
918
+ "stepState.pending": "pendiente",
919
+ "stepState.problem": "con incidencia",
920
+ "problem.delivery_exception": "Hubo un problema con la entrega. Contacta a la tienda si no se resuelve.",
921
+ "problem.returned": "El paquete regres\xF3 a la tienda. Cont\xE1ctanos para coordinar un nuevo env\xEDo.",
922
+ "problem.lost": "No encontramos tu paquete. Cont\xE1ctanos y lo resolvemos.",
923
+ "problem.payment_failed": "El pago no se complet\xF3. Puedes intentarlo de nuevo.",
924
+ "problem.unknown": "Tu pedido tiene una incidencia. Contacta a la tienda.",
925
+ "progress.cancelled": "Este pedido fue cancelado.",
926
+ "progress.refunded": "Este pedido fue reembolsado.",
927
+ // next action
928
+ "action.pay": "Pagar ahora",
929
+ "action.track": "Rastrear env\xEDo",
930
+ "action.pickup": "Recoger en sucursal",
931
+ "action.download_invoice": "Descargar factura",
932
+ "action.request_invoice": "Solicitar factura",
933
+ "action.correct_invoice_data": "Corregir datos de facturaci\xF3n",
934
+ "action.contact_store": "Contactar a la tienda",
935
+ "action.unknown": "Ver detalle",
936
+ "action.newTab": "(se abre en una pesta\xF1a nueva)",
937
+ "action.label": "Siguiente paso del pedido",
938
+ // shipment
939
+ "shipment.title": "Env\xEDo",
940
+ "shipment.return": "Devoluci\xF3n",
941
+ "shipment.carrier": "Paqueter\xEDa",
942
+ "shipment.service": "Servicio",
943
+ "shipment.number": "N\xFAmero de gu\xEDa",
944
+ "shipment.copy": "Copiar",
945
+ "shipment.copied": "Copiado",
946
+ "shipment.copyFailed": "No pudimos copiar; selecciona el texto.",
947
+ "shipment.track": "Rastrear con {carrier}",
948
+ "shipment.trackGeneric": "Rastrear env\xEDo",
949
+ "shipment.promised": "Llega a m\xE1s tardar el {date}",
950
+ "shipment.delivered": "Entregado el {date}",
951
+ "shipment.shipped": "Enviado el {date}",
952
+ "shipment.events": "Movimientos",
953
+ "shipment.noEvents": "La paqueter\xEDa a\xFAn no registra movimientos; suele tardar 24 horas.",
954
+ "shipment.showAll": "Ver todo ({count})",
955
+ "shipment.showLess": "Ver menos",
956
+ "shipment.returnLabel": "Gu\xEDa de devoluci\xF3n",
957
+ "shipment.test": "De prueba",
958
+ "shipment.testNote": "Env\xEDo de prueba: no es un env\xEDo real.",
959
+ "shipment.preparing": "Preparando tu env\xEDo",
960
+ "shipment.status.pending": "Preparando env\xEDo",
961
+ "shipment.status.label_created": "Gu\xEDa generada",
962
+ "shipment.status.in_transit": "En camino",
963
+ "shipment.status.out_for_delivery": "En reparto",
964
+ "shipment.status.delivered": "Entregado",
965
+ "shipment.status.exception": "Incidencia en la entrega",
966
+ "shipment.status.returned": "Devuelto a la tienda",
967
+ "shipment.status.lost": "Extraviado",
968
+ "shipment.status.cancelled": "Cancelado",
969
+ "shipment.status.unknown": "En proceso",
970
+ "shipment.eventFrom": "{location}",
971
+ // invoices
972
+ "invoice.title": "Facturas",
973
+ "invoice.invoice": "Factura",
974
+ "invoice.creditNote": "Nota de cr\xE9dito",
975
+ "invoice.creditNoteOf": "Corrige la factura {folio}",
976
+ "invoice.folio": "Folio fiscal",
977
+ "invoice.series": "Serie y folio",
978
+ "invoice.issued": "Emitida el {date}",
979
+ "invoice.total": "Total",
980
+ "invoice.pdf": "Descargar PDF",
981
+ "invoice.xml": "Descargar XML",
982
+ "invoice.downloadOf": "{action}, {kind} {name}",
983
+ "invoice.none": "A\xFAn no hay facturas de este pedido.",
984
+ "invoice.test": "Factura de prueba, sin validez",
985
+ "invoice.status.issued": "Emitida",
986
+ "invoice.status.pending": "En proceso",
987
+ "invoice.status.cancelled": "Cancelada",
988
+ "invoice.status.error": "No se pudo emitir",
989
+ "invoice.status.unknown": "En proceso",
990
+ "invoice.statusNote.pending": "La estamos generando; te avisaremos cuando est\xE9 lista.",
991
+ "invoice.statusNote.error": "Contacta a la tienda para resolverlo.",
992
+ "invoice.statusNote.cancelled": "Esta factura fue cancelada y ya no tiene validez.",
993
+ // pending payment
994
+ "pending.title": "Pendientes de pago",
995
+ "pending.intro": "Tu pedido se genera en cuanto confirmamos el pago. Paga con la ficha antes de que venza.",
996
+ "pending.waiting": "Esperando pago",
997
+ "pending.expired": "Vencida",
998
+ "pending.reference": "Referencia",
999
+ "pending.clabe": "CLABE",
1000
+ "pending.expires": "Vence el {date}",
1001
+ "pending.expiredOn": "Venci\xF3 el {date}",
1002
+ "pending.total": "Total",
1003
+ "pending.copyReference": "Copiar referencia",
1004
+ "pending.copyClabe": "Copiar CLABE",
1005
+ "pending.copied": "Copiada",
1006
+ "pending.copyFailed": "No pudimos copiar; selecciona el texto.",
1007
+ "pending.print": "Ver e imprimir ficha",
1008
+ "pending.download": "Descargar ficha",
1009
+ "pending.expiredNote": "Esta ficha ya no es v\xE1lida. Haz tu pedido de nuevo.",
1010
+ "pending.barcode": "C\xF3digo de barras {code}",
1011
+ "pending.method.oxxo": "OXXO",
1012
+ "pending.method.spei": "Transferencia SPEI",
1013
+ "pending.method.bank_transfer": "Transferencia bancaria",
1014
+ "pending.method.bank_deposit": "Dep\xF3sito bancario",
1015
+ "pending.method.cash": "Pago en efectivo",
1016
+ "pending.method.unknown": "Pago en efectivo",
1017
+ // refunds & payments
1018
+ "refund.title": "Reembolsos",
1019
+ "refund.status.requested": "Solicitado",
1020
+ "refund.status.processing": "En proceso",
1021
+ "refund.status.completed": "Completado",
1022
+ "refund.status.failed": "No se pudo completar",
1023
+ "refund.status.unknown": "En proceso",
1024
+ "refund.requested": "Solicitado el {date}",
1025
+ "refund.completed": "Completado el {date}",
1026
+ "refund.none": "Este pedido no tiene reembolsos.",
1027
+ "payment.title": "Pagos",
1028
+ "payment.status.paid": "Pagado",
1029
+ "payment.status.pending": "Pendiente",
1030
+ "payment.status.failed": "Fallido",
1031
+ "payment.status.refunded": "Reembolsado",
1032
+ "payment.status.partially_refunded": "Reembolsado parcialmente",
1033
+ "payment.status.unknown": "En proceso",
1034
+ "payment.paidOn": "Pagado el {date}",
1035
+ // sections
1036
+ "section.error": "No pudimos cargar esta secci\xF3n.",
1037
+ "section.retry": "Reintentar",
1038
+ "section.loading": "Cargando"
1039
+ };
1040
+ var EN4 = {
1041
+ "order.number": "Order {number}",
1042
+ "order.placed": "Placed on {date}",
1043
+ "order.total": "Total",
1044
+ "order.view": "View order",
1045
+ "order.items.one": "{count} item",
1046
+ "order.items.other": "{count} items",
1047
+ "order.lines": "Items in this order",
1048
+ "order.line.quantity": "Quantity {n}",
1049
+ "order.line.each": "{price} each",
1050
+ "order.line.unavailable": "Product unavailable",
1051
+ "order.productsMore": "and {n} more",
1052
+ "order.stepOf": "Step {n} of {total}: {step}",
1053
+ "order.listLabel": "Your orders",
1054
+ "order.loading": "Loading your orders",
1055
+ "order.loadMore": "Show more orders",
1056
+ "order.loadingMore": "Loading\u2026",
1057
+ "order.error": "We could not load your orders. Your purchases are safe.",
1058
+ "order.retry": "Try again",
1059
+ "order.emptyTitle": "You have no orders yet",
1060
+ "order.emptyBody": "When you buy, you will see the status and shipment of each order here.",
1061
+ "order.emptyGuest": "Did you buy as a guest? Verify your email to see your orders here.",
1062
+ "stage.pending_payment": "Waiting for payment",
1063
+ "stage.paid": "Paid",
1064
+ "stage.preparing": "Being prepared",
1065
+ "stage.ready_for_pickup": "Ready for pickup",
1066
+ "stage.shipped": "Shipped",
1067
+ "stage.in_transit": "On its way",
1068
+ "stage.out_for_delivery": "Out for delivery",
1069
+ "stage.delivered": "Delivered",
1070
+ "stage.cancelled": "Cancelled",
1071
+ "stage.refunded": "Refunded",
1072
+ "stage.unknown": "In progress",
1073
+ "progress.label": "Order progress",
1074
+ "step.paid": "Paid",
1075
+ "step.preparing": "Being prepared",
1076
+ "step.shipped": "Shipped",
1077
+ "step.in_transit": "On its way",
1078
+ "step.ready_for_pickup": "Ready for pickup",
1079
+ "step.delivered": "Delivered",
1080
+ "step.unknown": "Next step",
1081
+ "stepState.done": "completed",
1082
+ "stepState.current": "current step",
1083
+ "stepState.pending": "pending",
1084
+ "stepState.problem": "has a problem",
1085
+ "problem.delivery_exception": "There was a problem with the delivery. Contact the store if it is not resolved.",
1086
+ "problem.returned": "The package went back to the store. Contact us to arrange a new shipment.",
1087
+ "problem.lost": "We could not find your package. Contact us and we will sort it out.",
1088
+ "problem.payment_failed": "The payment did not go through. You can try again.",
1089
+ "problem.unknown": "Your order has a problem. Contact the store.",
1090
+ "progress.cancelled": "This order was cancelled.",
1091
+ "progress.refunded": "This order was refunded.",
1092
+ "action.pay": "Pay now",
1093
+ "action.track": "Track shipment",
1094
+ "action.pickup": "Pick up in store",
1095
+ "action.download_invoice": "Download invoice",
1096
+ "action.request_invoice": "Request invoice",
1097
+ "action.correct_invoice_data": "Fix billing details",
1098
+ "action.contact_store": "Contact the store",
1099
+ "action.unknown": "View details",
1100
+ "action.newTab": "(opens in a new tab)",
1101
+ "action.label": "Next step of the order",
1102
+ "shipment.title": "Shipment",
1103
+ "shipment.return": "Return",
1104
+ "shipment.carrier": "Carrier",
1105
+ "shipment.service": "Service",
1106
+ "shipment.number": "Tracking number",
1107
+ "shipment.copy": "Copy",
1108
+ "shipment.copied": "Copied",
1109
+ "shipment.copyFailed": "We could not copy; select the text.",
1110
+ "shipment.track": "Track with {carrier}",
1111
+ "shipment.trackGeneric": "Track shipment",
1112
+ "shipment.promised": "Arrives by {date}",
1113
+ "shipment.delivered": "Delivered on {date}",
1114
+ "shipment.shipped": "Shipped on {date}",
1115
+ "shipment.events": "Updates",
1116
+ "shipment.noEvents": "The carrier has not reported any movement yet; it usually takes 24 hours.",
1117
+ "shipment.showAll": "Show all ({count})",
1118
+ "shipment.showLess": "Show less",
1119
+ "shipment.returnLabel": "Return label",
1120
+ "shipment.test": "Test",
1121
+ "shipment.testNote": "Test shipment: it is not a real shipment.",
1122
+ "shipment.preparing": "Preparing your shipment",
1123
+ "shipment.status.pending": "Preparing shipment",
1124
+ "shipment.status.label_created": "Label created",
1125
+ "shipment.status.in_transit": "On its way",
1126
+ "shipment.status.out_for_delivery": "Out for delivery",
1127
+ "shipment.status.delivered": "Delivered",
1128
+ "shipment.status.exception": "Delivery problem",
1129
+ "shipment.status.returned": "Returned to the store",
1130
+ "shipment.status.lost": "Lost",
1131
+ "shipment.status.cancelled": "Cancelled",
1132
+ "shipment.status.unknown": "In progress",
1133
+ "shipment.eventFrom": "{location}",
1134
+ "invoice.title": "Invoices",
1135
+ "invoice.invoice": "Invoice",
1136
+ "invoice.creditNote": "Credit note",
1137
+ "invoice.creditNoteOf": "Corrects invoice {folio}",
1138
+ "invoice.folio": "Tax folio",
1139
+ "invoice.series": "Series and number",
1140
+ "invoice.issued": "Issued on {date}",
1141
+ "invoice.total": "Total",
1142
+ "invoice.pdf": "Download PDF",
1143
+ "invoice.xml": "Download XML",
1144
+ "invoice.downloadOf": "{action}, {kind} {name}",
1145
+ "invoice.none": "There are no invoices for this order yet.",
1146
+ "invoice.test": "Test invoice, not valid",
1147
+ "invoice.status.issued": "Issued",
1148
+ "invoice.status.pending": "In progress",
1149
+ "invoice.status.cancelled": "Cancelled",
1150
+ "invoice.status.error": "Could not be issued",
1151
+ "invoice.status.unknown": "In progress",
1152
+ "invoice.statusNote.pending": "We are generating it; we will let you know when it is ready.",
1153
+ "invoice.statusNote.error": "Contact the store to resolve it.",
1154
+ "invoice.statusNote.cancelled": "This invoice was cancelled and is no longer valid.",
1155
+ "pending.title": "Waiting for payment",
1156
+ "pending.intro": "Your order is created as soon as we confirm the payment. Pay with the voucher before it expires.",
1157
+ "pending.waiting": "Waiting for payment",
1158
+ "pending.expired": "Expired",
1159
+ "pending.reference": "Reference",
1160
+ "pending.clabe": "CLABE",
1161
+ "pending.expires": "Expires on {date}",
1162
+ "pending.expiredOn": "Expired on {date}",
1163
+ "pending.total": "Total",
1164
+ "pending.copyReference": "Copy reference",
1165
+ "pending.copyClabe": "Copy CLABE",
1166
+ "pending.copied": "Copied",
1167
+ "pending.copyFailed": "We could not copy; select the text.",
1168
+ "pending.print": "View and print voucher",
1169
+ "pending.download": "Download voucher",
1170
+ "pending.expiredNote": "This voucher is no longer valid. Place your order again.",
1171
+ "pending.barcode": "Barcode {code}",
1172
+ "pending.method.oxxo": "OXXO",
1173
+ "pending.method.spei": "SPEI transfer",
1174
+ "pending.method.bank_transfer": "Bank transfer",
1175
+ "pending.method.bank_deposit": "Bank deposit",
1176
+ "pending.method.cash": "Cash payment",
1177
+ "pending.method.unknown": "Cash payment",
1178
+ "refund.title": "Refunds",
1179
+ "refund.status.requested": "Requested",
1180
+ "refund.status.processing": "In progress",
1181
+ "refund.status.completed": "Completed",
1182
+ "refund.status.failed": "Could not be completed",
1183
+ "refund.status.unknown": "In progress",
1184
+ "refund.requested": "Requested on {date}",
1185
+ "refund.completed": "Completed on {date}",
1186
+ "refund.none": "This order has no refunds.",
1187
+ "payment.title": "Payments",
1188
+ "payment.status.paid": "Paid",
1189
+ "payment.status.pending": "Pending",
1190
+ "payment.status.failed": "Failed",
1191
+ "payment.status.refunded": "Refunded",
1192
+ "payment.status.partially_refunded": "Partially refunded",
1193
+ "payment.status.unknown": "In progress",
1194
+ "payment.paidOn": "Paid on {date}",
1195
+ "section.error": "We could not load this section.",
1196
+ "section.retry": "Try again",
1197
+ "section.loading": "Loading"
1198
+ };
1199
+ function accountMessages(locale, overrides) {
1200
+ const base = (locale ?? "es-MX").toLowerCase().startsWith("en") ? EN4 : ES4;
1201
+ return overrides ? { ...base, ...overrides } : base;
1202
+ }
1203
+ function enumText(m, group, value) {
1204
+ const key = `${group}.${typeof value === "string" ? value : ""}`;
1205
+ return Object.prototype.hasOwnProperty.call(m, key) ? m[key] : m[`${group}.unknown`];
1206
+ }
1207
+ var StorefrontContext = react.createContext(null);
1208
+ function useOptionalStorefront() {
1209
+ return react.useContext(StorefrontContext);
1210
+ }
1211
+ var DEFAULT_IMAGE_WIDTHS = [320, 480, 640, 768, 1024, 1280, 1600];
1212
+ var defaultImageLoader = (src, width, height) => {
1213
+ try {
1214
+ const isAbsolute = /^[a-z][a-z0-9+.-]*:/i.test(src);
1215
+ const url = new URL(src, "http://relative.invalid");
1216
+ url.searchParams.set("width", String(width));
1217
+ if (height) url.searchParams.set("height", String(height));
1218
+ return isAbsolute ? url.toString() : url.pathname + url.search + url.hash;
1219
+ } catch {
1220
+ return src;
1221
+ }
1222
+ };
1223
+ function parseRatio(ratio) {
1224
+ if (!ratio) return null;
1225
+ const [w, h] = ratio.split(/[/:]/).map((n) => Number.parseFloat(n));
1226
+ return w && h ? w / h : null;
1227
+ }
1228
+ function Image({
1229
+ data,
1230
+ sizes = "100vw",
1231
+ widths = DEFAULT_IMAGE_WIDTHS,
1232
+ loader = defaultImageLoader,
1233
+ priority = false,
1234
+ aspectRatio,
1235
+ alt,
1236
+ loading,
1237
+ decoding,
1238
+ ...rest
1239
+ }) {
1240
+ const ratio = parseRatio(aspectRatio) ?? (data.width && data.height ? data.width / data.height : null);
1241
+ let candidates = [...widths].sort((a, b) => a - b);
1242
+ if (data.width) {
1243
+ const capped = candidates.filter((w) => w <= data.width);
1244
+ candidates = capped.length ? capped : [data.width];
1245
+ }
1246
+ const srcSet = loader ? candidates.map((w) => `${loader(data.url, w, ratio ? Math.round(w / ratio) : void 0)} ${w}w`).join(", ") : void 0;
1247
+ const width = data.width ?? candidates[candidates.length - 1];
1248
+ const height = data.height ?? (ratio && width ? Math.round(width / ratio) : void 0);
1249
+ return /* @__PURE__ */ jsxRuntime.jsx(
1250
+ "img",
1251
+ {
1252
+ src: data.url,
1253
+ alt: alt ?? data.alt ?? "",
1254
+ ...srcSet ? { srcSet, sizes } : {},
1255
+ ...width ? { width } : {},
1256
+ ...height ? { height } : {},
1257
+ loading: loading ?? (priority ? "eager" : "lazy"),
1258
+ decoding: decoding ?? (priority ? "auto" : "async"),
1259
+ ...priority ? { fetchPriority: "high" } : {},
1260
+ ...rest
1261
+ }
1262
+ );
1263
+ }
1264
+ function productInitials(name) {
1265
+ const words = (name ?? "").normalize("NFKC").split(/[\s\-_/.,()]+/).map((w) => Array.from(w).find((c) => /\p{L}|\p{N}/u.test(c)) ?? "").filter(Boolean);
1266
+ if (words.length === 0) return "";
1267
+ return (words.length > 1 ? words[0] + words[1] : words[0]).toLocaleUpperCase();
1268
+ }
1269
+ function ProductThumb({
1270
+ image,
1271
+ name,
1272
+ size = 56,
1273
+ ratio = "1/1",
1274
+ fit = "contain",
1275
+ quantity,
1276
+ decorative = false,
1277
+ zoom = true,
1278
+ priority = false,
1279
+ sizes,
1280
+ loader,
1281
+ className,
1282
+ classNames: cx = {}
1283
+ }) {
1284
+ const url = image?.url || null;
1285
+ const [state, setState] = react.useState(url ? "loading" : "fallback");
1286
+ const box = react.useRef(null);
1287
+ react.useEffect(() => {
1288
+ const img = box.current?.querySelector("img");
1289
+ setState(!url ? "fallback" : img?.complete ? img.naturalWidth > 0 ? "loaded" : "fallback" : "loading");
1290
+ }, [url]);
1291
+ const label = name?.trim() || "";
1292
+ const initials = productInitials(label);
1293
+ const showBadge = typeof quantity === "number" && quantity > 1;
1294
+ const a11y = state === "fallback" && !decorative && label ? { role: "img", "aria-label": label } : { "aria-hidden": decorative || state === "fallback" ? true : void 0 };
1295
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1296
+ "span",
1297
+ {
1298
+ ref: box,
1299
+ className: [cx.root, className].filter(Boolean).join(" ") || void 0,
1300
+ style: { ["--sf-preview-size"]: `${size}px`, ["--sf-preview-ratio"]: ratio.replace(":", "/") },
1301
+ "data-sf-thumb": "",
1302
+ "data-state": state,
1303
+ "data-fit": fit,
1304
+ "data-zoom": zoom || void 0,
1305
+ ...a11y,
1306
+ children: [
1307
+ url && state !== "fallback" ? /* @__PURE__ */ jsxRuntime.jsx(
1308
+ Image,
1309
+ {
1310
+ data: { url, alt: image?.alt ?? null, ...image?.width ? { width: image.width } : {}, ...image?.height ? { height: image.height } : {} },
1311
+ alt: decorative ? "" : image?.alt ?? label,
1312
+ aspectRatio: ratio,
1313
+ sizes: sizes ?? `${size * 2}px`,
1314
+ widths: [Math.round(size), Math.round(size * 2), Math.round(size * 3)],
1315
+ ...loader !== void 0 ? { loader } : {},
1316
+ priority,
1317
+ className: cx.img,
1318
+ onLoad: () => setState("loaded"),
1319
+ onError: () => setState("fallback")
1320
+ }
1321
+ ) : null,
1322
+ state === "fallback" ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx.fallback, "data-sf-thumb-fallback": "", "aria-hidden": "true", children: initials ? /* @__PURE__ */ jsxRuntime.jsx("span", { "data-sf-thumb-initial": "", children: initials }) : /* @__PURE__ */ jsxRuntime.jsx(PackageGlyph, {}) }) : null,
1323
+ showBadge ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx.badge, "data-sf-thumb-qty": "", "aria-hidden": "true", children: quantity }) : null
1324
+ ]
1325
+ }
1326
+ );
1327
+ }
1328
+ function PackageGlyph() {
1329
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 24 24", width: "45%", height: "45%", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", focusable: "false", children: [
1330
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M21 8 12 3 3 8v8l9 5 9-5V8Z" }),
1331
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m3 8 9 5 9-5M12 13v8" })
1332
+ ] });
1333
+ }
1334
+ function ProductPreview({
1335
+ image,
1336
+ name,
1337
+ variant,
1338
+ sku,
1339
+ quantity,
1340
+ unitPrice,
1341
+ total,
1342
+ href,
1343
+ children,
1344
+ size = 64,
1345
+ ratio,
1346
+ fit,
1347
+ zoom,
1348
+ priority,
1349
+ sizes,
1350
+ loader,
1351
+ quantityLabel,
1352
+ unavailableLabel = "Producto no disponible",
1353
+ className,
1354
+ classNames: cx = {}
1355
+ }) {
1356
+ const missing = !name.trim();
1357
+ const title = missing ? unavailableLabel : name;
1358
+ const hasQty = typeof quantity === "number" && Number.isFinite(quantity);
1359
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: [cx.root, className].filter(Boolean).join(" ") || void 0, "data-sf-preview": "", "data-missing": missing || void 0, children: [
1360
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx.media, "data-sf-preview-media": "", children: /* @__PURE__ */ jsxRuntime.jsx(
1361
+ ProductThumb,
1362
+ {
1363
+ image,
1364
+ name: missing ? null : name,
1365
+ size,
1366
+ decorative: true,
1367
+ ...ratio ? { ratio } : {},
1368
+ ...fit ? { fit } : {},
1369
+ ...zoom !== void 0 ? { zoom } : {},
1370
+ ...priority ? { priority } : {},
1371
+ ...sizes ? { sizes } : {},
1372
+ ...loader !== void 0 ? { loader } : {},
1373
+ ...hasQty ? { quantity } : {},
1374
+ ...cx.thumb ? { classNames: cx.thumb } : {}
1375
+ }
1376
+ ) }),
1377
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cx.body, "data-sf-preview-body": "", children: [
1378
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx.name, "data-sf-preview-name": "", children: href && !missing ? /* @__PURE__ */ jsxRuntime.jsx("a", { href, children: title }) : title }),
1379
+ variant ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx.variant, "data-sf-preview-variant": "", children: variant }) : null,
1380
+ sku ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cx.sku, "data-sf-preview-sku": "", children: [
1381
+ "SKU ",
1382
+ sku
1383
+ ] }) : null,
1384
+ hasQty ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cx.meta, "data-sf-preview-meta": "", children: [
1385
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx.qty, "data-sf-preview-qty": "", children: (quantityLabel ?? "Cantidad {n}").replace("{n}", String(quantity)) }),
1386
+ unitPrice != null && quantity > 1 ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cx.unit, "data-sf-preview-unit": "", children: [
1387
+ " \xB7 ",
1388
+ unitPrice
1389
+ ] }) : null
1390
+ ] }) : null,
1391
+ children
1392
+ ] }),
1393
+ total != null ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx.total, "data-sf-preview-total": "", children: total }) : unitPrice != null && !(hasQty && quantity > 1) ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx.price, "data-sf-preview-total": "", children: unitPrice }) : null
1394
+ ] });
1395
+ }
1396
+ function ProductThumbStack({ items, max = 4, size = 44, moreLabel = "y {n} m\xE1s", className }) {
1397
+ if (items.length === 0) return null;
1398
+ const shown = items.length > max ? items.slice(0, max - 1) : items;
1399
+ const rest = items.length - shown.length;
1400
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className, "data-sf-thumb-stack": "", style: { ["--sf-preview-size"]: `${size}px` }, children: [
1401
+ shown.map((it, i) => /* @__PURE__ */ jsxRuntime.jsx(ProductThumb, { image: it.image ?? null, name: it.name ?? null, size, zoom: false }, i)),
1402
+ rest > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-sf-thumb-more": "", role: "img", "aria-label": moreLabel.replace("{n}", String(rest)), children: [
1403
+ "+",
1404
+ rest
1405
+ ] }) : null
1406
+ ] });
1407
+ }
1408
+
1409
+ // src/locale.ts
1410
+ function useResolvedLocale(locale) {
1411
+ const sf = useOptionalStorefront();
1412
+ return locale ?? sf?.locale ?? "es-MX";
1413
+ }
1414
+ var SR_ONLY = {
1415
+ position: "absolute",
1416
+ width: 1,
1417
+ height: 1,
1418
+ padding: 0,
1419
+ margin: -1,
1420
+ overflow: "hidden",
1421
+ clip: "rect(0 0 0 0)",
1422
+ whiteSpace: "nowrap",
1423
+ border: 0
1424
+ };
1425
+ function str(v) {
1426
+ if (typeof v === "number") return Number.isFinite(v) ? String(v) : null;
1427
+ if (typeof v !== "string") return null;
1428
+ const s = v.trim();
1429
+ return s ? s : null;
1430
+ }
1431
+ function moneyText(v, locale) {
1432
+ if (!v || typeof v !== "object") return null;
1433
+ const { amount, currency_code } = v;
1434
+ const a = typeof amount === "number" ? String(amount) : amount;
1435
+ if (typeof a !== "string" || !a.trim() || !Number.isFinite(Number(a)) || typeof currency_code !== "string" || !/^[A-Za-z]{3}$/.test(currency_code)) return null;
1436
+ return storefront.formatMoney({ amount: a.trim(), currency_code: currency_code.toUpperCase() }, locale);
1437
+ }
1438
+ function Hidden({ children }) {
1439
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { style: SR_ONLY, children });
1440
+ }
1441
+ function useAccountText({ locale, messages, timeZone }) {
1442
+ const resolved = useResolvedLocale(locale);
1443
+ const m = accountMessages(resolved, messages);
1444
+ const date = (iso, style = "date") => formatDate(iso, resolved, style, timeZone);
1445
+ const t = (key, vars) => vars ? fill(m[key], vars) : m[key];
1446
+ return { locale: resolved, m, t, date, timeZone };
1447
+ }
1448
+ function formatDate(iso, locale, style = "date", timeZone) {
1449
+ if (!iso || typeof iso !== "string") return null;
1450
+ const dayOnly = /^\d{4}-\d{2}-\d{2}$/.test(iso);
1451
+ const d = new Date(dayOnly ? `${iso}T12:00:00Z` : iso);
1452
+ if (Number.isNaN(d.getTime())) return null;
1453
+ const zone = dayOnly ? "UTC" : timeZone;
1454
+ try {
1455
+ return new Intl.DateTimeFormat(locale, { dateStyle: "long", ...style === "datetime" && !dayOnly ? { timeStyle: "short" } : {}, ...zone ? { timeZone: zone } : {} }).format(d);
1456
+ } catch {
1457
+ return d.toISOString().slice(0, 10);
1458
+ }
1459
+ }
1460
+ function Time({ value, text: text2, className }) {
1461
+ if (!value || !text2) return null;
1462
+ return /* @__PURE__ */ jsxRuntime.jsx("time", { dateTime: value, className, suppressHydrationWarning: true, children: text2 });
1463
+ }
1464
+ function plural(m, base, count) {
1465
+ return fill(count === 1 ? m["order.items.one"] : m["order.items.other"], { count });
1466
+ }
1467
+ function CopyButton({ value, label, copiedLabel, failedLabel, className, ariaLabel, ...rest }) {
1468
+ const [state, setState] = react.useState("idle");
1469
+ const timer = react.useRef(void 0);
1470
+ react.useEffect(() => () => clearTimeout(timer.current), []);
1471
+ const copy = react.useCallback(async () => {
1472
+ try {
1473
+ await navigator.clipboard.writeText(value);
1474
+ setState("copied");
1475
+ } catch {
1476
+ setState("failed");
1477
+ }
1478
+ clearTimeout(timer.current);
1479
+ timer.current = setTimeout(() => setState("idle"), 3e3);
1480
+ }, [value]);
1481
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1482
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: copy, className, "aria-label": ariaLabel, "data-sf-copy": rest["data-sf-copy"] ?? "", "data-state": state, children: state === "copied" ? copiedLabel : label }),
1483
+ /* @__PURE__ */ jsxRuntime.jsx("span", { role: "status", "aria-live": "polite", "data-sf-copy-status": true, style: state === "failed" ? void 0 : SR_ONLY, children: state === "copied" ? copiedLabel : state === "failed" ? failedLabel : "" })
1484
+ ] });
1485
+ }
1486
+ function lineImage(line) {
1487
+ const img = line?.image;
1488
+ if (!img || typeof img !== "object") return null;
1489
+ const url = str(img.url);
1490
+ if (!url) return null;
1491
+ const alt = str(img.alt);
1492
+ const w = Number(img.width);
1493
+ const h = Number(img.height);
1494
+ return { url, alt, ...Number.isFinite(w) && w > 0 ? { width: w } : {}, ...Number.isFinite(h) && h > 0 ? { height: h } : {} };
1495
+ }
1496
+ function validLines(order) {
1497
+ return (Array.isArray(order.lines) ? order.lines : []).filter((l) => !!l && typeof l === "object");
1498
+ }
1499
+ function OrderLines({ order, lineHref, size = 64, label, classNames: cx = {}, ...text2 }) {
1500
+ const { m, locale } = useAccountText(text2);
1501
+ const lines = validLines(order);
1502
+ if (lines.length === 0) return null;
1503
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx.root, "data-sf-order-lines": "", children: /* @__PURE__ */ jsxRuntime.jsx("ul", { className: cx.list, "aria-label": label ?? m["order.lines"], "data-sf-order-lines-list": "", children: lines.map((l, i) => {
1504
+ const qty = Number.isFinite(l.quantity) && l.quantity > 0 ? l.quantity : 1;
1505
+ const unit = moneyText(l.unit, locale);
1506
+ const variant = str(l.variant_title);
1507
+ return /* @__PURE__ */ jsxRuntime.jsx("li", { className: cx.item, "data-sf-order-line": "", children: /* @__PURE__ */ jsxRuntime.jsx(
1508
+ ProductPreview,
1509
+ {
1510
+ image: lineImage(l),
1511
+ name: str(l.title) ?? "",
1512
+ variant: variant && !/^default( title)?$/i.test(variant) ? variant : null,
1513
+ sku: str(l.sku),
1514
+ quantity: qty,
1515
+ quantityLabel: m["order.line.quantity"],
1516
+ unavailableLabel: m["order.line.unavailable"],
1517
+ unitPrice: unit ? fill(m["order.line.each"], { price: unit }) : null,
1518
+ total: moneyText(l.total, locale),
1519
+ href: lineHref?.(l) ?? null,
1520
+ size,
1521
+ ...cx.preview ? { classNames: cx.preview } : {}
1522
+ }
1523
+ ) }, `${str(l.sku) ?? ""}-${i}`);
1524
+ }) }) });
1525
+ }
1526
+ function OrderProductsStack({ order, size = 44, max = 4, className, ...text2 }) {
1527
+ const { m } = useAccountText(text2);
1528
+ const lines = validLines(order);
1529
+ if (lines.length === 0) return null;
1530
+ return /* @__PURE__ */ jsxRuntime.jsx(
1531
+ ProductThumbStack,
1532
+ {
1533
+ items: lines.map((l) => ({ image: lineImage(l), name: str(l.title) })),
1534
+ size,
1535
+ max,
1536
+ moreLabel: m["order.productsMore"],
1537
+ ...className ? { className } : {}
1538
+ }
1539
+ );
1540
+ }
1541
+ var STEP_STATES = /* @__PURE__ */ new Set(["done", "current", "pending", "problem"]);
1542
+ var stepState = (s) => typeof s === "string" && STEP_STATES.has(s) ? s : "pending";
1543
+ var GLYPH = { done: "\u2713", current: "\u25CF", pending: "\u25CB", problem: "!" };
1544
+ function stageTone(stage, problem) {
1545
+ if (problem) return "problem";
1546
+ if (stage === "delivered") return "done";
1547
+ if (stage === "cancelled" || stage === "refunded") return "muted";
1548
+ if (["pending_payment", "paid", "preparing", "ready_for_pickup", "shipped", "in_transit", "out_for_delivery"].includes(stage)) return "current";
1549
+ return "muted";
1550
+ }
1551
+ function OrderStatusBadge({ order, progress, className, ...text2 }) {
1552
+ const { m } = useAccountText(text2);
1553
+ const p = progress ?? (order ? storefront.orderProgress(order) : null);
1554
+ if (!p) return null;
1555
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className, "data-sf-order-badge": true, "data-sf-stage": p.stage, "data-sf-tone": stageTone(p.stage, p.problem), children: [
1556
+ enumText(m, "stage", p.stage),
1557
+ p.problem ? /* @__PURE__ */ jsxRuntime.jsx(Hidden, { children: `, ${m["stepState.problem"]}` }) : null
1558
+ ] });
1559
+ }
1560
+ function OrderProgress({ order, progress, variant = "full", classNames: cx = {}, ...text2 }) {
1561
+ const { m, t, date } = useAccountText(text2);
1562
+ const p = progress ?? (order ? storefront.orderProgress(order) : null);
1563
+ if (!p) return null;
1564
+ const steps = Array.isArray(p.steps) ? p.steps.filter((s) => s && typeof s === "object") : [];
1565
+ const stepLabel = (s) => enumText(m, "step", s.key);
1566
+ if (steps.length === 0 || p.stage === "cancelled" || p.stage === "refunded") {
1567
+ const note = p.stage === "cancelled" ? m["progress.cancelled"] : p.stage === "refunded" ? m["progress.refunded"] : enumText(m, "stage", p.stage);
1568
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx.root, "data-sf-progress": true, "data-sf-stage": p.stage, "data-sf-variant": variant, children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.terminal, "data-sf-progress-terminal": true, children: note }) });
1569
+ }
1570
+ if (variant === "compact") {
1571
+ const at = Math.max(0, steps.findIndex((s) => stepState(s.state) === "current" || stepState(s.state) === "problem"));
1572
+ const index = steps.some((s) => stepState(s.state) === "current" || stepState(s.state) === "problem") ? at : steps.every((s) => stepState(s.state) === "done") ? steps.length - 1 : 0;
1573
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx.root, "data-sf-progress": true, "data-sf-stage": p.stage, "data-sf-variant": "compact", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.label, "data-sf-progress-summary": true, children: t("order.stepOf", { n: index + 1, total: steps.length, step: stepLabel(steps[index]) }) }) });
1574
+ }
1575
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx.root, "data-sf-progress": true, "data-sf-stage": p.stage, "data-sf-variant": "full", children: [
1576
+ /* @__PURE__ */ jsxRuntime.jsx("ol", { className: cx.list, "aria-label": m["progress.label"], "data-sf-progress-list": true, children: steps.map((s, i) => {
1577
+ const state = stepState(s.state);
1578
+ return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: cx.step, "data-sf-step": typeof s.key === "string" ? s.key : "unknown", "data-sf-step-state": state, ...state === "current" || state === "problem" ? { "aria-current": "step" } : {}, children: [
1579
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx.marker, "aria-hidden": "true", "data-sf-step-marker": true, children: GLYPH[state] }),
1580
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cx.label, "data-sf-step-label": true, children: [
1581
+ stepLabel(s),
1582
+ /* @__PURE__ */ jsxRuntime.jsx(Hidden, { children: `, ${m[`stepState.${state}`]}` })
1583
+ ] }),
1584
+ /* @__PURE__ */ jsxRuntime.jsx(Time, { value: s.at, text: date(s.at), className: cx.time })
1585
+ ] }, `${s.key}-${i}`);
1586
+ }) }),
1587
+ p.problem ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.problem, "data-sf-progress-problem": typeof p.problem.code === "string" ? p.problem.code : "unknown", children: enumText(m, "problem", p.problem.code) }) : null
1588
+ ] });
1589
+ }
1590
+ function NextActionBar({ order, action, hrefFor, onAction, secondary, classNames: cx = {}, ...text2 }) {
1591
+ const { m } = useAccountText(text2);
1592
+ const a = action ?? (order ? storefront.nextAction(order) : null);
1593
+ if (!a || a.kind === "none") return secondary ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx.root, "data-sf-action-bar": true, children: secondary }) : null;
1594
+ const fromApi = a.kind === "track" || a.kind === "pickup" ? storefront.safeTrackingUrl(a.href) : null;
1595
+ const href = hrefFor?.(a) ?? fromApi;
1596
+ const external = !!href && /^https:\/\//i.test(href);
1597
+ const label = enumText(m, "action", a.kind);
1598
+ const common = { className: cx.primary, "data-sf-action": typeof a.kind === "string" ? a.kind : "unknown" };
1599
+ let primary = null;
1600
+ if (href) {
1601
+ primary = /* @__PURE__ */ jsxRuntime.jsxs("a", { href, ...common, ...external ? { target: "_blank", rel: "noopener noreferrer" } : {}, onClick: onAction ? (e) => onAction(a, e) : void 0, children: [
1602
+ label,
1603
+ external ? /* @__PURE__ */ jsxRuntime.jsxs(Hidden, { children: [
1604
+ " ",
1605
+ m["action.newTab"]
1606
+ ] }) : null
1607
+ ] });
1608
+ } else if (onAction) {
1609
+ primary = /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", ...common, onClick: (e) => onAction(a, e), children: label });
1610
+ }
1611
+ if (!primary && !secondary) return null;
1612
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx.root, role: "group", "aria-label": m["action.label"], "data-sf-action-bar": true, children: [
1613
+ primary,
1614
+ secondary
1615
+ ] });
1616
+ }
1617
+ function OrderCard({ order, orderHref, actionHref, onAction, headingLevel = 3, classNames: cx = {}, ...text2 }) {
1618
+ const { m, date, locale } = useAccountText(text2);
1619
+ const Heading = `h${headingLevel}`;
1620
+ const progress = storefront.orderProgress(order);
1621
+ const items = (Array.isArray(order.lines) ? order.lines : []).reduce((n, l) => n + (Number.isFinite(l?.quantity) ? l.quantity : 0), 0);
1622
+ const summary = order.shipments_summary && typeof order.shipments_summary === "object" ? order.shipments_summary : null;
1623
+ const shipments = Array.isArray(order.shipments) ? order.shipments : [];
1624
+ const showShipment = !!summary && typeof summary.count === "number" && summary.count > 0 && !(shipments.length > 0 && shipments.every(storefront.isTestShipment)) && !["pending_payment", "cancelled", "refunded"].includes(progress.stage);
1625
+ const action = storefront.nextAction(order);
1626
+ const total = moneyText(order.total, locale);
1627
+ const carrier = summary ? str(summary.carrier) : null;
1628
+ return /* @__PURE__ */ jsxRuntime.jsxs("article", { className: cx.root, "data-sf-order": true, "data-sf-order-status": progress.stage, "data-sf-order-id": order.id, children: [
1629
+ /* @__PURE__ */ jsxRuntime.jsxs("header", { className: cx.header, children: [
1630
+ /* @__PURE__ */ jsxRuntime.jsx(Heading, { className: cx.number, "data-sf-order-number": true, children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: orderHref(order), className: cx.link, "data-sf-order-link": true, children: fill(m["order.number"], { number: str(order.number) ?? (str(order.id) ?? "").slice(0, 8) }) }) }),
1631
+ /* @__PURE__ */ jsxRuntime.jsx(OrderStatusBadge, { progress, ...text2, ...cx.badge ? { className: cx.badge } : {} })
1632
+ ] }),
1633
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: cx.meta, "data-sf-order-meta": true, children: [
1634
+ /* @__PURE__ */ jsxRuntime.jsx(Time, { value: order.created_at, text: date(order.created_at) ? fill(m["order.placed"], { date: date(order.created_at) }) : null }),
1635
+ items > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1636
+ " \xB7 ",
1637
+ plural(m, "order.items", items)
1638
+ ] }) : null
1639
+ ] }),
1640
+ Array.isArray(order.lines) && order.lines.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx.products, "data-sf-order-products": true, children: /* @__PURE__ */ jsxRuntime.jsx(OrderProductsStack, { order, ...text2 }) }) : null,
1641
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx.summary, "data-sf-order-summary": true, children: [
1642
+ /* @__PURE__ */ jsxRuntime.jsx(OrderProgress, { progress, variant: "compact", ...text2, ...cx.progress ? { classNames: cx.progress } : {} }),
1643
+ showShipment ? /* @__PURE__ */ jsxRuntime.jsxs("p", { className: cx.shipment, "data-sf-order-shipment": true, children: [
1644
+ carrier ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1645
+ carrier,
1646
+ " \xB7 "
1647
+ ] }) : null,
1648
+ enumText(m, "shipment.status", summary.status)
1649
+ ] }) : null
1650
+ ] }),
1651
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx.footer, children: [
1652
+ total ? /* @__PURE__ */ jsxRuntime.jsxs("p", { className: cx.total, "data-sf-order-total": true, children: [
1653
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
1654
+ m["order.total"],
1655
+ ": "
1656
+ ] }),
1657
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: total })
1658
+ ] }) : null,
1659
+ /* @__PURE__ */ jsxRuntime.jsx(
1660
+ NextActionBar,
1661
+ {
1662
+ action,
1663
+ ...text2,
1664
+ hrefFor: (a) => actionHref?.(a, order) ?? void 0,
1665
+ ...onAction ? { onAction: (a) => onAction(a, order) } : {},
1666
+ classNames: { ...cx.actions ? { root: cx.actions } : {}, ...cx.action ?? {} }
1667
+ }
1668
+ )
1669
+ ] })
1670
+ ] });
1671
+ }
1672
+ function OrderList({ orders, status = "ready", skeletons = 3, onRetry, hasMore, loadingMore, onLoadMore, emptyAction, guestHint = true, orderHref, actionHref, onAction, headingLevel = 3, classNames: cx = {}, ...text2 }) {
1673
+ const { m } = useAccountText(text2);
1674
+ const list = (Array.isArray(orders) ? orders : []).filter((o) => !!o && typeof o === "object" && typeof o.id === "string");
1675
+ if (status === "loading" && list.length === 0) {
1676
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx.root, role: "status", "aria-busy": "true", "data-sf-orders": true, "data-sf-orders-state": "loading", children: [
1677
+ /* @__PURE__ */ jsxRuntime.jsx(Hidden, { children: m["order.loading"] }),
1678
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: cx.list, "aria-hidden": "true", children: Array.from({ length: Math.max(1, skeletons) }, (_, i) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: cx.skeleton, "data-sf-skeleton": true }, i)) })
1679
+ ] });
1680
+ }
1681
+ if (status === "error" && list.length === 0) {
1682
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx.root, "data-sf-orders": true, "data-sf-orders-state": "error", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx.error, role: "alert", "data-sf-orders-error": true, children: [
1683
+ /* @__PURE__ */ jsxRuntime.jsx("p", { children: m["order.error"] }),
1684
+ onRetry ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: cx.retry, onClick: onRetry, "data-sf-retry": true, children: m["order.retry"] }) : null
1685
+ ] }) });
1686
+ }
1687
+ if (list.length === 0) {
1688
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx.root, "data-sf-orders": true, "data-sf-orders-state": "empty", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx.empty, "data-sf-orders-empty": true, children: [
1689
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.emptyTitle, children: /* @__PURE__ */ jsxRuntime.jsx("strong", { children: m["order.emptyTitle"] }) }),
1690
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.emptyBody, children: m["order.emptyBody"] }),
1691
+ guestHint ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.emptyGuest, "data-sf-orders-guest-hint": true, children: m["order.emptyGuest"] }) : null,
1692
+ emptyAction
1693
+ ] }) });
1694
+ }
1695
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx.root, "data-sf-orders": true, "data-sf-orders-state": "ready", children: [
1696
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: cx.list, "aria-label": m["order.listLabel"], "data-sf-orders-list": true, children: list.map((o) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: cx.item, children: /* @__PURE__ */ jsxRuntime.jsx(OrderCard, { order: o, orderHref, ...actionHref ? { actionHref } : {}, ...onAction ? { onAction } : {}, headingLevel, ...text2, ...cx.card ? { classNames: cx.card } : {} }) }, o.id)) }),
1697
+ status === "error" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx.error, role: "alert", "data-sf-orders-error": true, children: [
1698
+ /* @__PURE__ */ jsxRuntime.jsx("p", { children: m["order.error"] }),
1699
+ onRetry ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: cx.retry, onClick: onRetry, "data-sf-retry": true, children: m["order.retry"] }) : null
1700
+ ] }) : null,
1701
+ hasMore && onLoadMore ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: cx.more, onClick: onLoadMore, disabled: loadingMore, "aria-disabled": loadingMore || void 0, "data-sf-orders-more": true, children: loadingMore ? m["order.loadingMore"] : m["order.loadMore"] }) : null
1702
+ ] });
1703
+ }
1704
+ function ShipmentCard({ shipment, testMode = "hide", eventsPreview = 3, renderCarrierMark, renderMap, headingLevel = 3, classNames: cx = {}, ...text2 }) {
1705
+ const { m, t, date } = useAccountText(text2);
1706
+ const [open, setOpen] = react.useState(false);
1707
+ const id = react.useId().replace(/:/g, "");
1708
+ if (!shipment || typeof shipment !== "object") return null;
1709
+ const test = storefront.isTestShipment(shipment);
1710
+ if (test && testMode === "hide") return null;
1711
+ const isReturn = shipment.kind === "return";
1712
+ const Heading = `h${headingLevel}`;
1713
+ const SubHeading = `h${headingLevel + 1}`;
1714
+ const carrier = str(shipment.carrier);
1715
+ const service = test ? null : str(shipment.service);
1716
+ const number = test ? null : str(shipment.tracking_number);
1717
+ const trackUrl = test ? null : storefront.safeTrackingUrl(shipment.tracking_url);
1718
+ const labelUrl = isReturn && !test ? storefront.safeTrackingUrl(shipment.label_url) : null;
1719
+ const events = test ? [] : storefront.sortTrackingEvents(shipment.events);
1720
+ const shown = open ? events : events.slice(0, Math.max(1, eventsPreview));
1721
+ const status = test ? m["shipment.preparing"] : enumText(m, "shipment.status", shipment.status);
1722
+ const promised = !test && shipment.status !== "delivered" ? date(shipment.promised_by) : null;
1723
+ const delivered = !test ? date(shipment.delivered_at) : null;
1724
+ const shipped = !test && !delivered ? date(shipment.shipped_at) : null;
1725
+ const titleId = `sf-shp-${id}`;
1726
+ const eventsId = `sf-shp-ev-${id}`;
1727
+ return /* @__PURE__ */ jsxRuntime.jsxs("article", { className: cx.root, "aria-labelledby": titleId, "data-sf-shipment": true, "data-sf-shipment-status": test ? "test" : typeof shipment.status === "string" ? shipment.status : "unknown", "data-sf-shipment-kind": isReturn ? "return" : "outbound", ...test ? { "data-sf-test": "" } : {}, children: [
1728
+ /* @__PURE__ */ jsxRuntime.jsxs("header", { className: cx.header, "data-sf-shipment-header": true, children: [
1729
+ renderCarrierMark && !test ? /* @__PURE__ */ jsxRuntime.jsx("span", { "data-sf-shipment-mark": true, children: renderCarrierMark(shipment) }) : null,
1730
+ /* @__PURE__ */ jsxRuntime.jsxs(Heading, { id: titleId, className: cx.carrier, "data-sf-shipment-title": true, children: [
1731
+ isReturn ? m["shipment.return"] : carrier ?? m["shipment.title"],
1732
+ isReturn && carrier ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1733
+ " \xB7 ",
1734
+ carrier
1735
+ ] }) : null
1736
+ ] }),
1737
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx.status, "data-sf-shipment-state": true, children: status }),
1738
+ test ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx.test, "data-sf-shipment-test": true, children: m["shipment.test"] }) : null
1739
+ ] }),
1740
+ test ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.meta, "data-sf-shipment-test-note": true, children: m["shipment.testNote"] }) : null,
1741
+ service ? /* @__PURE__ */ jsxRuntime.jsxs("p", { className: cx.meta, "data-sf-shipment-service": true, children: [
1742
+ m["shipment.service"],
1743
+ ": ",
1744
+ service
1745
+ ] }) : null,
1746
+ number ? /* @__PURE__ */ jsxRuntime.jsxs("p", { className: cx.number, "data-sf-shipment-number": true, children: [
1747
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
1748
+ m["shipment.number"],
1749
+ ": "
1750
+ ] }),
1751
+ /* @__PURE__ */ jsxRuntime.jsx("code", { children: number }),
1752
+ " ",
1753
+ /* @__PURE__ */ jsxRuntime.jsx(CopyButton, { value: number, label: m["shipment.copy"], copiedLabel: m["shipment.copied"], failedLabel: m["shipment.copyFailed"], ariaLabel: `${m["shipment.copy"]} ${m["shipment.number"]}`, className: cx.copy, "data-sf-copy": "tracking" })
1754
+ ] }) : null,
1755
+ promised || delivered || shipped ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.meta, "data-sf-shipment-dates": true, children: delivered ? /* @__PURE__ */ jsxRuntime.jsx(Time, { value: shipment.delivered_at, text: t("shipment.delivered", { date: delivered }) }) : promised ? /* @__PURE__ */ jsxRuntime.jsx(Time, { value: shipment.promised_by, text: t("shipment.promised", { date: promised }) }) : /* @__PURE__ */ jsxRuntime.jsx(Time, { value: shipment.shipped_at, text: t("shipment.shipped", { date: shipped ?? "" }) }) }) : null,
1756
+ trackUrl || labelUrl ? /* @__PURE__ */ jsxRuntime.jsxs("p", { className: cx.actions, "data-sf-shipment-actions": true, children: [
1757
+ trackUrl ? /* @__PURE__ */ jsxRuntime.jsxs("a", { href: trackUrl, target: "_blank", rel: "noopener noreferrer", className: cx.link, "data-sf-shipment-track": true, children: [
1758
+ carrier ? t("shipment.track", { carrier }) : m["shipment.trackGeneric"],
1759
+ /* @__PURE__ */ jsxRuntime.jsxs(Hidden, { children: [
1760
+ " ",
1761
+ m["action.newTab"]
1762
+ ] })
1763
+ ] }) : null,
1764
+ labelUrl ? /* @__PURE__ */ jsxRuntime.jsxs("a", { href: labelUrl, target: "_blank", rel: "noopener noreferrer", className: cx.link, "data-sf-shipment-label": true, children: [
1765
+ m["shipment.returnLabel"],
1766
+ /* @__PURE__ */ jsxRuntime.jsxs(Hidden, { children: [
1767
+ " ",
1768
+ m["action.newTab"]
1769
+ ] })
1770
+ ] }) : null
1771
+ ] }) : null,
1772
+ renderMap && !test && shipment.map ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx.map, "data-sf-shipment-map-slot": true, children: renderMap({ shipment, map: shipment.map }) }) : null,
1773
+ !test ? events.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.empty, "data-sf-shipment-empty": true, children: m["shipment.noEvents"] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-sf-shipment-events-wrap": true, children: [
1774
+ /* @__PURE__ */ jsxRuntime.jsx(SubHeading, { className: cx.meta, "data-sf-shipment-events-title": true, children: m["shipment.events"] }),
1775
+ /* @__PURE__ */ jsxRuntime.jsx("ol", { className: cx.events, id: eventsId, "data-sf-shipment-events": true, children: shown.map((e, i) => {
1776
+ const description = str(e.description);
1777
+ const location = str(e.location);
1778
+ return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: cx.event, "data-sf-event-status": typeof e.status === "string" ? e.status : "unknown", children: [
1779
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-sf-event-state": true, children: enumText(m, "shipment.status", e.status) }),
1780
+ description ? /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-sf-event-description": true, children: [
1781
+ " \xB7 ",
1782
+ description
1783
+ ] }) : null,
1784
+ location ? /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-sf-event-location": true, children: [
1785
+ " \xB7 ",
1786
+ location
1787
+ ] }) : null,
1788
+ " ",
1789
+ /* @__PURE__ */ jsxRuntime.jsx(Time, { value: e.occurred_at, text: date(e.occurred_at, "datetime") })
1790
+ ] }, `${str(e.id) ?? ""}-${i}`);
1791
+ }) }),
1792
+ events.length > Math.max(1, eventsPreview) ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: cx.toggle, "aria-expanded": open, "aria-controls": eventsId, onClick: () => setOpen((v) => !v), "data-sf-shipment-toggle": true, children: open ? m["shipment.showLess"] : t("shipment.showAll", { count: events.length }) }) : null
1793
+ ] }) : null
1794
+ ] });
1795
+ }
1796
+ var known = (s) => s === "issued" || s === "pending" || s === "cancelled" || s === "error";
1797
+ function InvoiceList({ invoices, summary, renderSummary, fileHref, onDownload, degraded, onRetry, testMode = "mark", headingLevel = 3, children, classNames: cx = {}, ...text2 }) {
1798
+ const { m, date, locale } = useAccountText(text2);
1799
+ const Heading = `h${headingLevel}`;
1800
+ const titleId = `sf-invoices-${react.useId().replace(/:/g, "")}`;
1801
+ const all = (Array.isArray(invoices) ? invoices : []).filter((d) => !!d && typeof d === "object" && typeof d.id === "string");
1802
+ const docs = testMode === "hide" ? all.filter((d) => !storefront.isTestInvoice(d)) : all;
1803
+ const { groups, orphans } = storefront.groupInvoiceDocs(docs);
1804
+ const renderDoc = (doc, parent) => {
1805
+ const test = storefront.isTestInvoice(doc);
1806
+ const status = known(doc.status) ? doc.status : "unknown";
1807
+ const kindLabel = doc.kind === "credit_note" ? m["invoice.creditNote"] : m["invoice.invoice"];
1808
+ const docName = (d) => [str(d.series), str(d.folio_number)].filter(Boolean).join("-");
1809
+ const name = docName(doc);
1810
+ const folio = str(doc.folio);
1811
+ const canDownload = status === "issued" && !test;
1812
+ const total = moneyText(doc.total, locale);
1813
+ const link = (kind) => {
1814
+ const label = kind === "pdf" ? m["invoice.pdf"] : m["invoice.xml"];
1815
+ const aria = fill(m["invoice.downloadOf"], { action: label, kind: kindLabel.toLowerCase(), name: name || folio || "" }).replace(/\s+,/g, ",").replace(/,\s*$/, "").trim();
1816
+ const href = fileHref?.(doc, kind);
1817
+ if (href) {
1818
+ return /* @__PURE__ */ jsxRuntime.jsx("a", { href, download: true, className: cx.download, "aria-label": aria, "data-sf-invoice-download": kind, children: label }, kind);
1819
+ }
1820
+ if (onDownload) {
1821
+ return /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: cx.download, "aria-label": aria, onClick: () => onDownload(doc, kind), "data-sf-invoice-download": kind, children: label }, kind);
1822
+ }
1823
+ return null;
1824
+ };
1825
+ return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: cx.doc, "data-sf-invoice-doc": true, "data-sf-invoice-kind": doc.kind === "credit_note" ? "credit_note" : "invoice", "data-sf-invoice-status": status, children: [
1826
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: cx.status, "data-sf-invoice-heading": true, children: [
1827
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: kindLabel }),
1828
+ name ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1829
+ " ",
1830
+ name
1831
+ ] }) : null,
1832
+ " \xB7 ",
1833
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-sf-invoice-state": true, children: enumText(m, "invoice.status", doc.status) }),
1834
+ test ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1835
+ " ",
1836
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx.test, "data-sf-invoice-test": true, children: m["invoice.test"] })
1837
+ ] }) : null
1838
+ ] }),
1839
+ parent ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.meta, "data-sf-invoice-parent": true, children: fill(m["invoice.creditNoteOf"], { folio: docName(parent) || str(parent.folio) || "" }).trim() }) : null,
1840
+ folio && !test ? /* @__PURE__ */ jsxRuntime.jsxs("p", { className: cx.meta, "data-sf-invoice-folio": true, children: [
1841
+ m["invoice.folio"],
1842
+ ": ",
1843
+ /* @__PURE__ */ jsxRuntime.jsx("code", { children: folio })
1844
+ ] }) : null,
1845
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: cx.meta, children: [
1846
+ doc.issued_at ? /* @__PURE__ */ jsxRuntime.jsx(Time, { value: doc.issued_at, text: fill(m["invoice.issued"], { date: date(doc.issued_at) ?? "" }) }) : null,
1847
+ total ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1848
+ " \xB7 ",
1849
+ m["invoice.total"],
1850
+ ": ",
1851
+ total
1852
+ ] }) : null
1853
+ ] }),
1854
+ status === "pending" || status === "error" || status === "cancelled" ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.note, "data-sf-invoice-note": true, children: m[`invoice.statusNote.${status}`] }) : null,
1855
+ canDownload && (fileHref || onDownload) ? /* @__PURE__ */ jsxRuntime.jsxs("p", { className: cx.actions, "data-sf-invoice-actions": true, children: [
1856
+ link("pdf"),
1857
+ link("xml")
1858
+ ] }) : null
1859
+ ] }, doc.id);
1860
+ };
1861
+ const hasDocs = groups.length + orphans.length > 0;
1862
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: cx.root, "aria-labelledby": titleId, "data-sf-invoices": true, children: [
1863
+ /* @__PURE__ */ jsxRuntime.jsx(Heading, { id: titleId, className: cx.title, children: m["invoice.title"] }),
1864
+ degraded ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx.error, role: "alert", "data-sf-section-error": "invoices", children: [
1865
+ /* @__PURE__ */ jsxRuntime.jsx("p", { children: m["section.error"] }),
1866
+ onRetry ? /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: cx.retry, onClick: onRetry, "data-sf-retry": true, children: [
1867
+ m["section.retry"],
1868
+ /* @__PURE__ */ jsxRuntime.jsxs(Hidden, { children: [
1869
+ " ",
1870
+ m["invoice.title"]
1871
+ ] })
1872
+ ] }) : null
1873
+ ] }) : hasDocs ? /* @__PURE__ */ jsxRuntime.jsxs("ul", { "data-sf-invoice-list": true, children: [
1874
+ groups.map(({ invoice, creditNotes }) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: cx.group, "data-sf-invoice-group": true, children: [
1875
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { children: renderDoc(invoice) }),
1876
+ creditNotes.length ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: cx.creditNotes, "data-sf-invoice-credit-notes": true, children: creditNotes.map((nc) => renderDoc(nc, invoice)) }) : null
1877
+ ] }, invoice.id)),
1878
+ orphans.map((nc) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: cx.group, "data-sf-invoice-group": true, children: /* @__PURE__ */ jsxRuntime.jsx("ul", { children: renderDoc(nc) }) }, nc.id))
1879
+ ] }) : summary && renderSummary ? /* @__PURE__ */ jsxRuntime.jsx("div", { "data-sf-invoice-summary": true, children: renderSummary(summary) }) : /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.empty, "data-sf-invoice-empty": true, children: m["invoice.none"] }),
1880
+ children
1881
+ ] });
1882
+ }
1883
+ init_voucher();
1884
+ function Barcode({ value, label, height = 56, className }) {
1885
+ const g = react.useMemo(() => barcodeGeometry(value, { height }), [value, height]);
1886
+ if (!g) return null;
1887
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", { className, viewBox: `0 0 ${g.width} ${g.height}`, width: g.width, height: g.height, role: "img", "aria-label": label, shapeRendering: "crispEdges", fill: "#000", "data-sf-voucher-barcode-svg": true, children: g.rects.map((r) => /* @__PURE__ */ jsxRuntime.jsx("rect", { x: r.x, y: 0, width: r.w, height: g.height }, r.x)) });
1888
+ }
1889
+ async function openDocument(payment, mode, opts) {
1890
+ const v = voucherOf(payment);
1891
+ if (!v) return;
1892
+ const { renderVoucherDocument: renderVoucherDocument2 } = await Promise.resolve().then(() => (init_voucher_document(), voucher_document_exports));
1893
+ const html = renderVoucherDocument2(v, { locale: opts.locale, ...opts.shopName ? { shopName: opts.shopName } : {}, ...opts.timeZone ? { timeZone: opts.timeZone } : {}, printButton: mode === "print", autoPrint: mode === "print" });
1894
+ const url = URL.createObjectURL(new Blob([html], { type: "text/html;charset=utf-8" }));
1895
+ const download = () => {
1896
+ const a = document.createElement("a");
1897
+ a.href = url;
1898
+ a.download = "ficha-de-pago.html";
1899
+ a.click();
1900
+ };
1901
+ if (mode === "print") {
1902
+ const w = window.open(url, "_blank");
1903
+ if (w) w.opener = null;
1904
+ else download();
1905
+ } else download();
1906
+ setTimeout(() => URL.revokeObjectURL(url), 6e4);
1907
+ }
1908
+ function PendingPaymentCard({ payment, voucherHref, shopName, headingLevel = 3, classNames: cx = {}, children, ...text2 }) {
1909
+ const { m, date, locale, timeZone } = useAccountText(text2);
1910
+ const titleId = `sf-voucher-${react.useId().replace(/:/g, "")}`;
1911
+ const v = voucherOf(payment);
1912
+ if (!v) return null;
1913
+ const expired = payment.status === "expired";
1914
+ const Heading = `h${headingLevel}`;
1915
+ const code = barcodeValue(v);
1916
+ const methodLabel = enumText(m, "pending.method", v.method?.toLowerCase());
1917
+ const total = moneyText(payment.total, locale) ?? moneyText(v.amount, locale);
1918
+ const copyValue = v.reference ?? v.clabe;
1919
+ const expires = date(v.expires_at ?? payment.expires_at, "datetime");
1920
+ return /* @__PURE__ */ jsxRuntime.jsxs("article", { className: cx.root, "aria-labelledby": titleId, "data-sf-voucher": true, "data-sf-voucher-status": expired ? "expired" : "pending_payment", children: [
1921
+ /* @__PURE__ */ jsxRuntime.jsxs("header", { className: cx.header, children: [
1922
+ /* @__PURE__ */ jsxRuntime.jsx(Heading, { id: titleId, className: cx.method, "data-sf-voucher-method": true, children: methodLabel }),
1923
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx.badge, "data-sf-voucher-badge": true, "data-sf-tone": expired ? "muted" : "current", children: expired ? m["pending.expired"] : m["pending.waiting"] })
1924
+ ] }),
1925
+ v.reference ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx.field, "data-sf-voucher-reference": true, children: [
1926
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.label, children: m["pending.reference"] }),
1927
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.value, "data-sf-voucher-value": true, children: v.reference })
1928
+ ] }) : null,
1929
+ v.clabe ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx.field, "data-sf-voucher-clabe": true, children: [
1930
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.label, children: m["pending.clabe"] }),
1931
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.value, "data-sf-voucher-value": true, children: v.clabe })
1932
+ ] }) : null,
1933
+ code && !expired ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx.barcode, "data-sf-voucher-barcode": true, children: /* @__PURE__ */ jsxRuntime.jsx(Barcode, { value: code, label: fill(m["pending.barcode"], { code }) }) }) : null,
1934
+ expires ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.expiry, "data-sf-voucher-expiry": true, children: /* @__PURE__ */ jsxRuntime.jsx(Time, { value: v.expires_at ?? payment.expires_at, text: fill(m[expired ? "pending.expiredOn" : "pending.expires"], { date: expires }) }) }) : null,
1935
+ total ? /* @__PURE__ */ jsxRuntime.jsxs("p", { className: cx.total, "data-sf-voucher-total": true, children: [
1936
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
1937
+ m["pending.total"],
1938
+ ": "
1939
+ ] }),
1940
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: total })
1941
+ ] }) : null,
1942
+ expired ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.note, "data-sf-voucher-expired-note": true, children: m["pending.expiredNote"] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx.actions, "data-sf-voucher-actions": true, children: [
1943
+ voucherHref ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1944
+ /* @__PURE__ */ jsxRuntime.jsxs("a", { href: voucherHref(payment, { download: false }), target: "_blank", rel: "noopener", className: cx.primary, "data-sf-voucher-print": true, children: [
1945
+ m["pending.print"],
1946
+ /* @__PURE__ */ jsxRuntime.jsxs(Hidden, { children: [
1947
+ " ",
1948
+ m["action.newTab"]
1949
+ ] })
1950
+ ] }),
1951
+ /* @__PURE__ */ jsxRuntime.jsx("a", { href: voucherHref(payment, { download: true }), download: true, className: cx.secondary, "data-sf-voucher-download": true, children: m["pending.download"] })
1952
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1953
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: cx.primary, onClick: () => void openDocument(payment, "print", { locale, shopName, timeZone }), "data-sf-voucher-print": true, children: m["pending.print"] }),
1954
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: cx.secondary, onClick: () => void openDocument(payment, "download", { locale, shopName, timeZone }), "data-sf-voucher-download": true, children: m["pending.download"] })
1955
+ ] }),
1956
+ copyValue ? /* @__PURE__ */ jsxRuntime.jsx(CopyButton, { value: copyValue, label: v.reference ? m["pending.copyReference"] : m["pending.copyClabe"], copiedLabel: m["pending.copied"], failedLabel: m["pending.copyFailed"], className: cx.secondary, "data-sf-copy": "voucher" }) : null
1957
+ ] }),
1958
+ children
1959
+ ] });
1960
+ }
1961
+ function PendingPaymentList({ payments, voucherHref, shopName, classNames, listClassNames: lc = {}, headingLevel = 2, ...text2 }) {
1962
+ const { m } = useAccountText(text2);
1963
+ const titleId = `sf-pending-${react.useId().replace(/:/g, "")}`;
1964
+ const items = (Array.isArray(payments) ? payments : []).filter((p) => !!voucherOf(p));
1965
+ if (items.length === 0) return null;
1966
+ const sorted = [...items.filter((p) => p.status !== "expired"), ...items.filter((p) => p.status === "expired")];
1967
+ const Heading = `h${headingLevel}`;
1968
+ const cardHeading = headingLevel + 1;
1969
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: lc.root, "aria-labelledby": titleId, "data-sf-pending": true, children: [
1970
+ /* @__PURE__ */ jsxRuntime.jsx(Heading, { id: titleId, className: lc.title, children: m["pending.title"] }),
1971
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: lc.intro, children: m["pending.intro"] }),
1972
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: lc.list, children: sorted.map((p) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: lc.item, children: /* @__PURE__ */ jsxRuntime.jsx(PendingPaymentCard, { payment: p, ...voucherHref ? { voucherHref } : {}, ...shopName ? { shopName } : {}, ...classNames ? { classNames } : {}, headingLevel: cardHeading, ...text2 }) }, p.id)) })
1973
+ ] });
1974
+ }
1975
+ var tone = (s) => s === "completed" ? "done" : s === "failed" ? "problem" : "current";
1976
+ function RefundList({ refunds, showEmpty = false, degraded, onRetry, headingLevel = 3, classNames: cx = {}, ...text2 }) {
1977
+ const { m, locale, date } = useAccountText(text2);
1978
+ const titleId = `sf-refunds-${react.useId().replace(/:/g, "")}`;
1979
+ const items = (Array.isArray(refunds) ? refunds : []).filter((r) => !!r && typeof r === "object" && typeof r.id === "string");
1980
+ if (!degraded && items.length === 0 && !showEmpty) return null;
1981
+ const Heading = `h${headingLevel}`;
1982
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: cx.root, "aria-labelledby": titleId, "data-sf-refunds": true, children: [
1983
+ /* @__PURE__ */ jsxRuntime.jsx(Heading, { id: titleId, className: cx.title, children: m["refund.title"] }),
1984
+ degraded ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx.error, role: "alert", "data-sf-section-error": "refunds", children: [
1985
+ /* @__PURE__ */ jsxRuntime.jsx("p", { children: m["section.error"] }),
1986
+ onRetry ? /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: cx.retry, onClick: onRetry, "data-sf-retry": true, children: [
1987
+ m["section.retry"],
1988
+ /* @__PURE__ */ jsxRuntime.jsxs(Hidden, { children: [
1989
+ " ",
1990
+ m["refund.title"]
1991
+ ] })
1992
+ ] }) : null
1993
+ ] }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: cx.empty, children: m["refund.none"] }) : /* @__PURE__ */ jsxRuntime.jsx("ul", { className: cx.list, children: items.map((r) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: cx.item, "data-sf-refund": true, "data-sf-refund-status": typeof r.status === "string" ? r.status : "unknown", children: [
1994
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx.amount, "data-sf-refund-amount": true, children: moneyText(r.amount, locale) ?? "" }),
1995
+ " ",
1996
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx.status, "data-sf-tone": tone(r.status), children: enumText(m, "refund.status", r.status) }),
1997
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cx.meta, children: [
1998
+ str(r.method_label) ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1999
+ " \xB7 ",
2000
+ str(r.method_label)
2001
+ ] }) : null,
2002
+ r.completed_at ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2003
+ " \xB7 ",
2004
+ /* @__PURE__ */ jsxRuntime.jsx(Time, { value: r.completed_at, text: fill(m["refund.completed"], { date: date(r.completed_at) ?? "" }) })
2005
+ ] }) : r.created_at ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2006
+ " \xB7 ",
2007
+ /* @__PURE__ */ jsxRuntime.jsx(Time, { value: r.created_at, text: fill(m["refund.requested"], { date: date(r.created_at) ?? "" }) })
2008
+ ] }) : null
2009
+ ] })
2010
+ ] }, r.id)) })
2011
+ ] });
2012
+ }
2013
+ function PaymentSummary({ payments, headingLevel = 3, classNames: cx = {}, ...text2 }) {
2014
+ const { m, locale, date } = useAccountText(text2);
2015
+ const titleId = `sf-payments-${react.useId().replace(/:/g, "")}`;
2016
+ const items = (Array.isArray(payments) ? payments : []).filter((p) => !!p && typeof p === "object" && typeof p.method_label === "string");
2017
+ if (items.length === 0) return null;
2018
+ const Heading = `h${headingLevel}`;
2019
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: cx.root, "aria-labelledby": titleId, "data-sf-payments": true, children: [
2020
+ /* @__PURE__ */ jsxRuntime.jsx(Heading, { id: titleId, className: cx.title, children: m["payment.title"] }),
2021
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: cx.list, children: items.map((p, i) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: cx.item, "data-sf-payment": true, "data-sf-payment-status": typeof p.status === "string" ? p.status : "unknown", children: [
2022
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: p.method_label }),
2023
+ moneyText(p.amount, locale) ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2024
+ " \xB7 ",
2025
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: moneyText(p.amount, locale) })
2026
+ ] }) : null,
2027
+ " \xB7",
2028
+ " ",
2029
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx.status, "data-sf-tone": p.status === "failed" ? "problem" : p.status === "paid" ? "done" : "current", children: enumText(m, "payment.status", p.status) }),
2030
+ p.paid_at ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cx.meta, children: [
2031
+ " \xB7 ",
2032
+ /* @__PURE__ */ jsxRuntime.jsx(Time, { value: p.paid_at, text: fill(m["payment.paidOn"], { date: date(p.paid_at) ?? "" }) })
2033
+ ] }) : null
2034
+ ] }, `${p.method_label}-${i}`)) })
2035
+ ] });
2036
+ }
2037
+ function useClient(client) {
2038
+ const ctx = useOptionalStorefront();
2039
+ return client ?? ctx?.client ?? null;
2040
+ }
2041
+ var asError = (e) => e instanceof Error ? e : new Error("Request failed");
2042
+ var ids = /* @__PURE__ */ new WeakMap();
2043
+ var seq = 0;
2044
+ function clientKey(c) {
2045
+ if (!c) return "none";
2046
+ let k = ids.get(c);
2047
+ if (!k) ids.set(c, k = `c${++seq}`);
2048
+ return k;
2049
+ }
2050
+ function useConnection(fetchPage, client, initial, key) {
2051
+ const owner = `${clientKey(client)}|${key}`;
2052
+ const empty = (status) => ({ status, nodes: [], error: null, cursor: null, hasMore: false, total: null, owner });
2053
+ const [state, setState] = react.useState(
2054
+ () => initial ? { status: "ready", nodes: initial.nodes ?? [], error: null, cursor: initial.page_info?.end_cursor ?? null, hasMore: !!initial.page_info?.has_next_page, total: initial.total_count ?? null, owner } : empty("loading")
2055
+ );
2056
+ const [loadingMore, setLoadingMore] = react.useState(false);
2057
+ const alive = react.useRef(null);
2058
+ const more = react.useRef(null);
2059
+ const fetchRef = react.useRef(fetchPage);
2060
+ fetchRef.current = fetchPage;
2061
+ const first = react.useCallback(() => {
2062
+ alive.current?.abort();
2063
+ more.current?.abort();
2064
+ setLoadingMore(false);
2065
+ if (!client) {
2066
+ setState(empty("loading"));
2067
+ return;
2068
+ }
2069
+ const ctl = new AbortController();
2070
+ alive.current = ctl;
2071
+ setState((s) => s.owner === owner && s.nodes.length ? { ...s, error: null } : empty("loading"));
2072
+ fetchRef.current(client, null, ctl.signal).then(
2073
+ (page) => !ctl.signal.aborted && setState({ status: "ready", nodes: page.nodes ?? [], error: null, cursor: page.page_info?.end_cursor ?? null, hasMore: !!page.page_info?.has_next_page, total: page.total_count ?? null, owner }),
2074
+ (e) => !ctl.signal.aborted && setState((s) => s.owner === owner ? { ...s, status: "error", error: asError(e) } : { ...empty("error"), error: asError(e) })
2075
+ );
2076
+ }, [client, owner]);
2077
+ react.useEffect(() => {
2078
+ if (!(initial && state.owner === owner)) first();
2079
+ return () => {
2080
+ alive.current?.abort();
2081
+ more.current?.abort();
2082
+ };
2083
+ }, [first, owner]);
2084
+ const loadMore = react.useCallback(() => {
2085
+ if (!client || state.owner !== owner || !state.hasMore || loadingMore) return;
2086
+ const ctl = new AbortController();
2087
+ more.current = ctl;
2088
+ setLoadingMore(true);
2089
+ fetchRef.current(client, state.cursor, ctl.signal).then(
2090
+ (page) => {
2091
+ if (ctl.signal.aborted) return;
2092
+ setLoadingMore(false);
2093
+ setState((s) => s.owner !== owner ? s : { ...s, nodes: [...s.nodes, ...page.nodes ?? []], cursor: page.page_info?.end_cursor ?? null, hasMore: !!page.page_info?.has_next_page, total: page.total_count ?? s.total, error: null });
2094
+ },
2095
+ (e) => {
2096
+ if (ctl.signal.aborted) return;
2097
+ setLoadingMore(false);
2098
+ setState((s) => s.owner !== owner ? s : { ...s, error: asError(e) });
2099
+ }
2100
+ );
2101
+ }, [client, owner, state.owner, state.hasMore, state.cursor, loadingMore]);
2102
+ const view = state.owner === owner ? state : empty("loading");
2103
+ return { status: view.status, nodes: view.nodes, error: view.error, hasMore: view.hasMore, loadingMore: state.owner === owner && loadingMore, totalCount: view.total, reload: first, loadMore };
2104
+ }
2105
+ function useCustomerOrders({ client, first = 20, initial } = {}) {
2106
+ return useConnection((c, after, signal) => c.customer.orders({ first, ...after ? { after } : {} }, { signal }), useClient(client), initial, `orders:${first}`);
2107
+ }
2108
+ function usePendingPayments({ client, first = 20, initial } = {}) {
2109
+ return useConnection((c, after, signal) => c.customer.pendingPayments({ first, ...after ? { after } : {} }, { signal }), useClient(client), initial, `pending:${first}`);
2110
+ }
2111
+ function useCustomerOrder(id, { client, initial, poll } = {}) {
2112
+ const c = useClient(client);
2113
+ const given = initial !== void 0;
2114
+ const owner = `${clientKey(c)}|${id ?? ""}`;
2115
+ const [state, setState] = react.useState(() => given ? { status: initial ? "ready" : "not_found", order: initial, error: null, owner } : { status: "loading", order: null, error: null, owner });
2116
+ const [refreshing, setRefreshing] = react.useState(false);
2117
+ const ctlRef = react.useRef(null);
2118
+ const initialOwner = react.useRef(given ? owner : null);
2119
+ const load = react.useCallback(
2120
+ (silent) => {
2121
+ ctlRef.current?.abort();
2122
+ setRefreshing(false);
2123
+ if (!c || !id) {
2124
+ setState({ status: "loading", order: null, error: null, owner });
2125
+ return;
2126
+ }
2127
+ const ctl = new AbortController();
2128
+ ctlRef.current = ctl;
2129
+ if (silent) setRefreshing(true);
2130
+ else setState((s) => s.owner === owner && s.order ? { ...s, error: null } : { status: "loading", order: null, error: null, owner });
2131
+ c.customer.order(id, { signal: ctl.signal }).then(
2132
+ (o) => {
2133
+ if (ctl.signal.aborted) return;
2134
+ setRefreshing(false);
2135
+ setState(o ? { status: "ready", order: o, error: null, owner } : { status: "not_found", order: null, error: null, owner });
2136
+ },
2137
+ (e) => {
2138
+ if (ctl.signal.aborted) return;
2139
+ setRefreshing(false);
2140
+ setState((s) => s.owner === owner && s.order ? { ...s, error: asError(e) } : { status: "error", order: null, error: asError(e), owner });
2141
+ }
2142
+ );
2143
+ },
2144
+ [c, id, owner]
2145
+ );
2146
+ react.useEffect(() => {
2147
+ if (initialOwner.current !== owner) load(false);
2148
+ initialOwner.current = null;
2149
+ return () => ctlRef.current?.abort();
2150
+ }, [load, owner]);
2151
+ const mine = state.owner === owner;
2152
+ const order = mine ? state.order : null;
2153
+ const keepPolling = !!poll && !!order && poll.while(order);
2154
+ const everyMs = poll?.everyMs ?? 1e4;
2155
+ const forMs = poll?.forMs ?? 6e4;
2156
+ react.useEffect(() => {
2157
+ if (!keepPolling) return;
2158
+ const t0 = Date.now();
2159
+ const timer = setInterval(() => {
2160
+ if (Date.now() - t0 >= forMs) clearInterval(timer);
2161
+ else load(true);
2162
+ }, everyMs);
2163
+ return () => clearInterval(timer);
2164
+ }, [keepPolling, everyMs, forMs, load]);
2165
+ const hasOrder = order !== null;
2166
+ const reload = react.useCallback(() => load(hasOrder), [load, hasOrder]);
2167
+ return { status: mine ? state.status : "loading", order, error: mine ? state.error : null, refreshing: mine && refreshing, reload };
2168
+ }
2169
+
2170
+ // src/account/index.ts
2171
+ init_voucher();
2172
+
543
2173
  exports.AccountAuth = AccountAuth;
2174
+ exports.Barcode = Barcode;
2175
+ exports.InvoiceList = InvoiceList;
2176
+ exports.NextActionBar = NextActionBar;
2177
+ exports.OrderCard = OrderCard;
2178
+ exports.OrderLines = OrderLines;
2179
+ exports.OrderList = OrderList;
2180
+ exports.OrderProductsStack = OrderProductsStack;
2181
+ exports.OrderProgress = OrderProgress;
2182
+ exports.OrderStatusBadge = OrderStatusBadge;
2183
+ exports.PaymentSummary = PaymentSummary;
2184
+ exports.PendingPaymentCard = PendingPaymentCard;
2185
+ exports.PendingPaymentList = PendingPaymentList;
544
2186
  exports.PostPurchaseAccountPrompt = PostPurchaseAccountPrompt;
2187
+ exports.ProductPreview = ProductPreview;
2188
+ exports.ProductThumb = ProductThumb;
2189
+ exports.ProductThumbStack = ProductThumbStack;
2190
+ exports.RefundList = RefundList;
2191
+ exports.ShipmentCard = ShipmentCard;
545
2192
  exports.accountAuthMessages = accountAuthMessages;
2193
+ exports.accountMessages = accountMessages;
2194
+ exports.barcodeGeometry = barcodeGeometry;
2195
+ exports.barcodeValue = barcodeValue;
2196
+ exports.code128Modules = code128Modules;
2197
+ exports.enumText = enumText;
2198
+ exports.lineImage = lineImage;
546
2199
  exports.postPurchaseAccountPromptMessages = postPurchaseAccountPromptMessages;
2200
+ exports.productInitials = productInitials;
2201
+ exports.stageTone = stageTone;
2202
+ exports.useCustomerOrder = useCustomerOrder;
2203
+ exports.useCustomerOrders = useCustomerOrders;
2204
+ exports.usePendingPayments = usePendingPayments;
2205
+ exports.voucherOf = voucherOf;
547
2206
  //# sourceMappingURL=account.cjs.map
548
2207
  //# sourceMappingURL=account.cjs.map