@reblu/site-blocks 0.5.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -21,8 +21,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
23
  ALLOWED_YOUTUBE_HOSTS: () => ALLOWED_YOUTUBE_HOSTS,
24
+ AddedToCartToast: () => AddedToCartToast,
25
+ CartLineList: () => CartLineList,
26
+ CartSummary: () => CartSummary,
27
+ CheckoutForm: () => CheckoutForm,
28
+ CheckoutLoginPrompt: () => CheckoutLoginPrompt,
29
+ DEFAULT_SHOP_ERROR_FALLBACK_MESSAGE: () => DEFAULT_SHOP_ERROR_FALLBACK_MESSAGE,
30
+ DEFAULT_SHOP_ERROR_MESSAGES: () => DEFAULT_SHOP_ERROR_MESSAGES,
24
31
  DEFAULT_SHOP_PRICE_BANDS: () => DEFAULT_SHOP_PRICE_BANDS,
25
32
  MarkdownRenderer: () => MarkdownRenderer,
33
+ OrderConfirmation: () => OrderConfirmation,
26
34
  ProductCard: () => ProductCard,
27
35
  ProfileCard: () => ProfileCard,
28
36
  SafeHtml: () => SafeHtml,
@@ -31,6 +39,7 @@ __export(src_exports, {
31
39
  Treatment: () => Treatment,
32
40
  buildShareUrls: () => buildShareUrls,
33
41
  formatPrice: () => formatPrice,
42
+ getShopErrorMessage: () => getShopErrorMessage,
34
43
  isAllowedYouTubeHost: () => isAllowedYouTubeHost,
35
44
  markdownToSafeHtml: () => markdownToSafeHtml,
36
45
  readingTime: () => readingTime,
@@ -71,6 +80,25 @@ function buildShareUrls(url, title) {
71
80
  };
72
81
  }
73
82
 
83
+ // src/lib/shop-error-messages.ts
84
+ var DEFAULT_SHOP_ERROR_MESSAGES = {
85
+ STOCK_CHANGED: "Alguno de los productos de tu carrito ya no tiene stock suficiente.",
86
+ PRICE_CHANGED: "El precio de alguno de los productos de tu carrito ha cambiado. Rev\xEDsalo antes de continuar.",
87
+ PRODUCT_UNAVAILABLE: "Alguno de los productos de tu carrito ya no est\xE1 disponible.",
88
+ DISCOUNT_INVALID: "El c\xF3digo de descuento no es v\xE1lido.",
89
+ SHIPPING_UNAVAILABLE: "El env\xEDo no est\xE1 disponible para la direcci\xF3n indicada.",
90
+ INVALID_INPUT: "Revisa los datos introducidos.",
91
+ STORE_DISABLED: "La tienda no est\xE1 disponible en este momento.",
92
+ PAYMENT_PROVIDER_ERROR: "No hemos podido conectar con la pasarela de pago. Int\xE9ntalo de nuevo.",
93
+ INTERNAL_ERROR: "Ha ocurrido un error inesperado. Int\xE9ntalo de nuevo en unos minutos."
94
+ };
95
+ var DEFAULT_SHOP_ERROR_FALLBACK_MESSAGE = "No se ha podido completar la operaci\xF3n. Int\xE9ntalo de nuevo.";
96
+ function getShopErrorMessage(code, overrides, fallback = DEFAULT_SHOP_ERROR_FALLBACK_MESSAGE) {
97
+ if (!code) return fallback;
98
+ const messages = { ...DEFAULT_SHOP_ERROR_MESSAGES, ...overrides };
99
+ return messages[code] ?? fallback;
100
+ }
101
+
74
102
  // ../../node_modules/.pnpm/devlop@1.1.0/node_modules/devlop/lib/default.js
75
103
  function ok() {
76
104
  }
@@ -13619,11 +13647,672 @@ function ShopFilters({
13619
13647
  )
13620
13648
  ] });
13621
13649
  }
13650
+
13651
+ // src/components/cart-line-list.tsx
13652
+ var import_utils8 = require("@reblu/site-ui/utils");
13653
+ var import_jsx_runtime8 = require("react/jsx-runtime");
13654
+ var DEFAULT_LABELS2 = {
13655
+ quantityLabel: "Cantidad",
13656
+ decrease: "Reducir cantidad",
13657
+ increase: "Aumentar cantidad",
13658
+ remove: "Eliminar",
13659
+ unitPriceSuffix: "/ ud.",
13660
+ cancelledNotice: "Pago cancelado: tu carrito sigue aqu\xED"
13661
+ };
13662
+ function lineKey(productId, variantId) {
13663
+ return `${productId}-${variantId ?? "no-variant"}`;
13664
+ }
13665
+ function CartLineList({
13666
+ items,
13667
+ onQuantityChange,
13668
+ onRemove,
13669
+ liveMessage,
13670
+ notice,
13671
+ labels,
13672
+ currencyCode,
13673
+ locale,
13674
+ className
13675
+ }) {
13676
+ const t = { ...DEFAULT_LABELS2, ...labels };
13677
+ const noticeContent = notice === true ? t.cancelledNotice : notice;
13678
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: (0, import_utils8.cn)("space-y-4", className), "data-slot": "cart-line-list", children: [
13679
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { "aria-live": "polite", className: "sr-only", children: liveMessage }),
13680
+ noticeContent != null && noticeContent !== false && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
13681
+ "div",
13682
+ {
13683
+ role: "status",
13684
+ className: "rounded-lg bg-muted px-3 py-2 text-sm text-muted-foreground",
13685
+ "data-slot": "cart-line-list-notice",
13686
+ children: noticeContent
13687
+ }
13688
+ ),
13689
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { className: "space-y-4", children: items.map((item) => {
13690
+ const maxQty = item.maxStock ?? Infinity;
13691
+ const atMax = item.quantity >= maxQty;
13692
+ const atMin = item.quantity <= 1;
13693
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
13694
+ "li",
13695
+ {
13696
+ className: "flex gap-4 rounded-xl border border-border bg-card p-4",
13697
+ children: [
13698
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "h-20 w-20 flex-shrink-0 overflow-hidden rounded-lg bg-muted", children: item.imageUrl ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("img", { src: item.imageUrl, alt: item.name, className: "h-full w-full object-cover" }) : null }),
13699
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "min-w-0 flex-1", children: [
13700
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "truncate text-sm font-semibold leading-tight", children: item.name }),
13701
+ item.variantName && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "mt-0.5 text-xs text-muted-foreground", children: item.variantName }),
13702
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("p", { className: "mt-1 text-sm text-muted-foreground", children: [
13703
+ formatPrice(item.unitPrice, currencyCode, locale),
13704
+ " ",
13705
+ t.unitPriceSuffix
13706
+ ] }),
13707
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
13708
+ "div",
13709
+ {
13710
+ role: "group",
13711
+ "aria-label": t.quantityLabel,
13712
+ className: "mt-3 flex items-center gap-3",
13713
+ children: [
13714
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
13715
+ "button",
13716
+ {
13717
+ type: "button",
13718
+ "aria-label": t.decrease,
13719
+ disabled: !onQuantityChange || atMin,
13720
+ onClick: onQuantityChange ? () => onQuantityChange(item.productId, item.variantId, item.quantity - 1) : void 0,
13721
+ className: "flex h-7 w-7 items-center justify-center rounded border border-border transition hover:bg-muted disabled:cursor-not-allowed disabled:opacity-40",
13722
+ children: "\u2212"
13723
+ }
13724
+ ),
13725
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "w-8 text-center text-sm font-semibold tabular-nums", children: item.quantity }),
13726
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
13727
+ "button",
13728
+ {
13729
+ type: "button",
13730
+ "aria-label": t.increase,
13731
+ disabled: !onQuantityChange || atMax,
13732
+ onClick: onQuantityChange ? () => onQuantityChange(item.productId, item.variantId, item.quantity + 1) : void 0,
13733
+ className: "flex h-7 w-7 items-center justify-center rounded border border-border transition hover:bg-muted disabled:cursor-not-allowed disabled:opacity-40",
13734
+ children: "+"
13735
+ }
13736
+ ),
13737
+ onRemove && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
13738
+ "button",
13739
+ {
13740
+ type: "button",
13741
+ "aria-label": `${t.remove} ${item.name}`,
13742
+ onClick: () => onRemove(item.productId, item.variantId),
13743
+ className: "ml-2 text-muted-foreground transition-colors hover:text-destructive",
13744
+ children: t.remove
13745
+ }
13746
+ )
13747
+ ]
13748
+ }
13749
+ )
13750
+ ] }),
13751
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "flex-shrink-0 text-right", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-base font-bold", children: formatPrice(item.unitPrice * item.quantity, currencyCode, locale) }) })
13752
+ ]
13753
+ },
13754
+ lineKey(item.productId, item.variantId)
13755
+ );
13756
+ }) })
13757
+ ] });
13758
+ }
13759
+
13760
+ // src/components/cart-summary.tsx
13761
+ var import_utils9 = require("@reblu/site-ui/utils");
13762
+ var import_jsx_runtime9 = require("react/jsx-runtime");
13763
+ var DEFAULT_LABELS3 = {
13764
+ subtotal: "Subtotal",
13765
+ discountPrefix: "Descuento",
13766
+ shipping: "Env\xEDo",
13767
+ freeShipping: "Env\xEDo gratis",
13768
+ shippingCalculated: "Se calcula en el pago",
13769
+ total: "Total",
13770
+ cancelledNotice: "Pago cancelado: tu carrito sigue aqu\xED"
13771
+ };
13772
+ function CartSummary({
13773
+ subtotal,
13774
+ discount,
13775
+ discountCode,
13776
+ shipping,
13777
+ shippingEnabled,
13778
+ total,
13779
+ notice,
13780
+ labels,
13781
+ currencyCode,
13782
+ locale,
13783
+ className
13784
+ }) {
13785
+ const t = { ...DEFAULT_LABELS3, ...labels };
13786
+ const hasDiscount = Boolean(discount && discount > 0);
13787
+ const noticeContent = notice === true ? t.cancelledNotice : notice;
13788
+ const hasNotice = noticeContent != null && noticeContent !== false;
13789
+ const breakdown = /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
13790
+ "dl",
13791
+ {
13792
+ className: (0, import_utils9.cn)("space-y-2 text-sm", !hasNotice && className),
13793
+ "data-slot": "cart-summary",
13794
+ children: [
13795
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex justify-between text-muted-foreground", children: [
13796
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t.subtotal }),
13797
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: formatPrice(subtotal, currencyCode, locale) })
13798
+ ] }),
13799
+ hasDiscount && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex justify-between text-green-600 dark:text-green-400", children: [
13800
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("dt", { children: [
13801
+ t.discountPrefix,
13802
+ discountCode ? ` (${discountCode})` : ""
13803
+ ] }),
13804
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("dd", { children: [
13805
+ "-",
13806
+ formatPrice(discount, currencyCode, locale)
13807
+ ] })
13808
+ ] }),
13809
+ shippingEnabled && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex justify-between text-muted-foreground", children: [
13810
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t.shipping }),
13811
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: shipping == null || !Number.isFinite(shipping) ? t.shippingCalculated : shipping === 0 ? t.freeShipping : formatPrice(shipping, currencyCode, locale) })
13812
+ ] }),
13813
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex justify-between border-t border-border pt-2 text-base font-bold", children: [
13814
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t.total }),
13815
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: formatPrice(total, currencyCode, locale) })
13816
+ ] })
13817
+ ]
13818
+ }
13819
+ );
13820
+ if (!hasNotice) return breakdown;
13821
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: (0, import_utils9.cn)("space-y-3", className), "data-slot": "cart-summary-wrapper", children: [
13822
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
13823
+ "div",
13824
+ {
13825
+ role: "status",
13826
+ className: "rounded-lg bg-muted px-3 py-2 text-sm text-muted-foreground",
13827
+ "data-slot": "cart-summary-notice",
13828
+ children: noticeContent
13829
+ }
13830
+ ),
13831
+ breakdown
13832
+ ] });
13833
+ }
13834
+
13835
+ // src/components/added-to-cart-toast.tsx
13836
+ var import_utils10 = require("@reblu/site-ui/utils");
13837
+ var import_jsx_runtime10 = (
13838
+ // eslint-disable-next-line @next/next/no-img-element -- toast content, not a Next <Image> layout context
13839
+ require("react/jsx-runtime")
13840
+ );
13841
+ var DEFAULT_LABELS4 = {
13842
+ success: "A\xF1adido al carrito",
13843
+ error: "No se pudo a\xF1adir al carrito",
13844
+ outOfStock: "Producto agotado",
13845
+ viewCart: "Ver carrito"
13846
+ };
13847
+ function AddedToCartToast({
13848
+ status = "success",
13849
+ productName,
13850
+ quantity,
13851
+ imageUrl,
13852
+ cartHref,
13853
+ labels,
13854
+ className
13855
+ }) {
13856
+ const t = { ...DEFAULT_LABELS4, ...labels };
13857
+ const message = status === "error" ? t.error : status === "outOfStock" ? t.outOfStock : t.success;
13858
+ const hasThumbnail = Boolean(imageUrl && imageUrl.trim().length > 0);
13859
+ const variant = status === "success" ? "success" : "error";
13860
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
13861
+ "div",
13862
+ {
13863
+ "data-slot": "added-to-cart-toast",
13864
+ "data-variant": variant,
13865
+ className: (0, import_utils10.cn)(
13866
+ "flex items-center gap-3 rounded-xl border border-border bg-card p-3 text-sm shadow-lg",
13867
+ variant === "success" && "border-green-600/30 dark:border-green-400/30",
13868
+ variant === "error" && "border-destructive/30",
13869
+ className
13870
+ ),
13871
+ children: [
13872
+ hasThumbnail && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("img", { src: imageUrl, alt: productName, className: "h-10 w-10 flex-shrink-0 rounded-lg object-cover" }),
13873
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "min-w-0 flex-1", children: [
13874
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "truncate font-semibold text-foreground", children: productName }),
13875
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "truncate text-muted-foreground", children: quantity && quantity > 1 ? `${message} \xB7 x${quantity}` : message })
13876
+ ] }),
13877
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "flex-shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("a", { href: cartHref, className: "text-sm font-semibold text-primary underline-offset-2 hover:underline", children: t.viewCart }) })
13878
+ ]
13879
+ }
13880
+ );
13881
+ }
13882
+
13883
+ // src/components/checkout-login-prompt.tsx
13884
+ var import_utils11 = require("@reblu/site-ui/utils");
13885
+ var import_jsx_runtime11 = require("react/jsx-runtime");
13886
+ var DEFAULT_LABELS5 = {
13887
+ title: "Identificaci\xF3n",
13888
+ description: "Introduce tu email para agilizar el proceso o contin\xFAa como invitado.",
13889
+ emailLabel: "Email",
13890
+ emailPlaceholder: "tu@email.com",
13891
+ continueWithEmail: "Continuar con este email",
13892
+ checking: "Verificando\u2026",
13893
+ continueAsGuest: "Continuar como invitado",
13894
+ close: "Cerrar"
13895
+ };
13896
+ var EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
13897
+ function CheckoutLoginPrompt({
13898
+ open,
13899
+ email,
13900
+ onEmailChange,
13901
+ onClose,
13902
+ onSubmitEmail,
13903
+ onContinueAsGuest,
13904
+ checking,
13905
+ error,
13906
+ labels,
13907
+ className
13908
+ }) {
13909
+ if (!open) return null;
13910
+ const t = { ...DEFAULT_LABELS5, ...labels };
13911
+ const isValidEmail = EMAIL_PATTERN.test(email.trim());
13912
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
13913
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "fixed inset-0 z-50 bg-black/50", onClick: onClose, "aria-hidden": "true" }),
13914
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
13915
+ "div",
13916
+ {
13917
+ role: "dialog",
13918
+ "aria-modal": "true",
13919
+ "aria-labelledby": "checkout-login-prompt-title",
13920
+ "data-slot": "checkout-login-prompt",
13921
+ className: (0, import_utils11.cn)(
13922
+ "fixed left-1/2 top-1/2 z-50 w-full max-w-md -translate-x-1/2 -translate-y-1/2 space-y-5 rounded-2xl border border-border bg-background p-6 shadow-2xl",
13923
+ className
13924
+ ),
13925
+ children: [
13926
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-start justify-between gap-3", children: [
13927
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { children: [
13928
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h2", { id: "checkout-login-prompt-title", className: "text-xl font-bold", children: t.title }),
13929
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "mt-1 text-sm text-muted-foreground", children: t.description })
13930
+ ] }),
13931
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
13932
+ "button",
13933
+ {
13934
+ type: "button",
13935
+ onClick: onClose,
13936
+ "aria-label": t.close,
13937
+ className: "flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
13938
+ children: "\u2715"
13939
+ }
13940
+ )
13941
+ ] }),
13942
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "space-y-2", children: [
13943
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("label", { htmlFor: "checkout-login-prompt-email", className: "text-sm font-medium", children: t.emailLabel }),
13944
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
13945
+ "input",
13946
+ {
13947
+ id: "checkout-login-prompt-email",
13948
+ type: "email",
13949
+ autoComplete: "email",
13950
+ value: email,
13951
+ onChange: (e) => onEmailChange(e.target.value),
13952
+ placeholder: t.emailPlaceholder,
13953
+ className: (0, import_utils11.cn)(
13954
+ "w-full rounded-lg border bg-background px-3 py-2 text-sm transition focus:outline-none focus:ring-2 focus:ring-primary/20",
13955
+ error ? "border-destructive" : "border-border focus:border-primary"
13956
+ )
13957
+ }
13958
+ ),
13959
+ error && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "text-xs text-destructive", children: error })
13960
+ ] }),
13961
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "space-y-2", children: [
13962
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
13963
+ "button",
13964
+ {
13965
+ type: "button",
13966
+ onClick: onSubmitEmail,
13967
+ disabled: checking || !isValidEmail,
13968
+ className: (0, import_utils11.cn)(
13969
+ "flex w-full items-center justify-center gap-2 rounded-xl px-4 py-2.5 text-sm font-semibold transition-all",
13970
+ checking || !isValidEmail ? "cursor-not-allowed bg-muted text-muted-foreground" : "bg-primary text-primary-foreground hover:bg-primary/90"
13971
+ ),
13972
+ children: checking ? t.checking : t.continueWithEmail
13973
+ }
13974
+ ),
13975
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
13976
+ "button",
13977
+ {
13978
+ type: "button",
13979
+ onClick: onContinueAsGuest,
13980
+ className: "flex w-full items-center justify-center gap-2 rounded-xl bg-muted px-4 py-2.5 text-sm font-semibold text-muted-foreground transition-colors hover:bg-muted/70",
13981
+ children: t.continueAsGuest
13982
+ }
13983
+ )
13984
+ ] })
13985
+ ]
13986
+ }
13987
+ )
13988
+ ] });
13989
+ }
13990
+
13991
+ // src/components/checkout-form.tsx
13992
+ var import_utils12 = require("@reblu/site-ui/utils");
13993
+ var import_jsx_runtime12 = require("react/jsx-runtime");
13994
+ var DEFAULT_LABELS6 = {
13995
+ contactTitle: "Datos de contacto",
13996
+ nameLabel: "Nombre completo",
13997
+ namePlaceholder: "Tu nombre",
13998
+ emailLabel: "Email",
13999
+ emailPlaceholder: "tu@email.com",
14000
+ phoneLabel: "Tel\xE9fono",
14001
+ discountTitle: "C\xF3digo de descuento",
14002
+ discountPlaceholder: "C\xD3DIGO10",
14003
+ applyDiscount: "Aplicar",
14004
+ applyingDiscount: "Aplicando\u2026",
14005
+ removeDiscount: "Quitar",
14006
+ discountAppliedSuffix: (amount) => `\u2014 ${amount} de descuento`,
14007
+ submit: "Confirmar y pagar",
14008
+ submitting: "Procesando\u2026"
14009
+ };
14010
+ function CheckoutForm({
14011
+ contact,
14012
+ onContactChange,
14013
+ contactErrors,
14014
+ discountCode,
14015
+ onDiscountCodeChange,
14016
+ onApplyDiscount,
14017
+ onRemoveDiscount,
14018
+ appliedDiscount,
14019
+ discountApplying,
14020
+ discountError,
14021
+ loginPrompt,
14022
+ children: children2,
14023
+ submitting,
14024
+ submitDisabled,
14025
+ onSubmit,
14026
+ labels,
14027
+ currencyCode,
14028
+ locale,
14029
+ className
14030
+ }) {
14031
+ const t = { ...DEFAULT_LABELS6, ...labels };
14032
+ function patchContact(patch3) {
14033
+ onContactChange({ ...contact, ...patch3 });
14034
+ }
14035
+ function handleDiscountCodeKeyDown(event) {
14036
+ if (event.key !== "Enter") return;
14037
+ if (event.nativeEvent.isComposing) return;
14038
+ event.preventDefault();
14039
+ if (discountCode.trim() && !discountApplying) onApplyDiscount();
14040
+ }
14041
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
14042
+ loginPrompt,
14043
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
14044
+ "form",
14045
+ {
14046
+ "data-testid": "checkout-form",
14047
+ onSubmit,
14048
+ className: (0, import_utils12.cn)("space-y-8", className),
14049
+ "data-slot": "checkout-form",
14050
+ children: [
14051
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("section", { className: "space-y-4", children: [
14052
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h2", { className: "border-b border-border pb-2 text-lg font-semibold", children: t.contactTitle }),
14053
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children: [
14054
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "space-y-1", children: [
14055
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("label", { htmlFor: "checkout-form-name", className: "text-sm font-medium", children: t.nameLabel }),
14056
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
14057
+ "input",
14058
+ {
14059
+ id: "checkout-form-name",
14060
+ type: "text",
14061
+ autoComplete: "name",
14062
+ value: contact.name,
14063
+ onChange: (e) => patchContact({ name: e.target.value }),
14064
+ placeholder: t.namePlaceholder,
14065
+ className: (0, import_utils12.cn)(
14066
+ "w-full rounded-lg border bg-background px-3 py-2 text-sm transition focus:outline-none focus:ring-2 focus:ring-primary/20",
14067
+ contactErrors?.name ? "border-destructive" : "border-border focus:border-primary"
14068
+ )
14069
+ }
14070
+ ),
14071
+ contactErrors?.name && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "text-xs text-destructive", children: contactErrors.name })
14072
+ ] }),
14073
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "space-y-1", children: [
14074
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("label", { htmlFor: "checkout-form-email", className: "text-sm font-medium", children: t.emailLabel }),
14075
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
14076
+ "input",
14077
+ {
14078
+ id: "checkout-form-email",
14079
+ type: "email",
14080
+ autoComplete: "email",
14081
+ value: contact.email,
14082
+ onChange: (e) => patchContact({ email: e.target.value }),
14083
+ placeholder: t.emailPlaceholder,
14084
+ className: (0, import_utils12.cn)(
14085
+ "w-full rounded-lg border bg-background px-3 py-2 text-sm transition focus:outline-none focus:ring-2 focus:ring-primary/20",
14086
+ contactErrors?.email ? "border-destructive" : "border-border focus:border-primary"
14087
+ )
14088
+ }
14089
+ ),
14090
+ contactErrors?.email && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "text-xs text-destructive", children: contactErrors.email })
14091
+ ] }),
14092
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "space-y-1", children: [
14093
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("label", { htmlFor: "checkout-form-phone", className: "text-sm font-medium", children: t.phoneLabel }),
14094
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
14095
+ "input",
14096
+ {
14097
+ id: "checkout-form-phone",
14098
+ type: "tel",
14099
+ autoComplete: "tel",
14100
+ value: contact.phone ?? "",
14101
+ onChange: (e) => patchContact({ phone: e.target.value }),
14102
+ className: (0, import_utils12.cn)(
14103
+ "w-full rounded-lg border bg-background px-3 py-2 text-sm transition focus:outline-none focus:ring-2 focus:ring-primary/20",
14104
+ contactErrors?.phone ? "border-destructive" : "border-border focus:border-primary"
14105
+ )
14106
+ }
14107
+ ),
14108
+ contactErrors?.phone && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "text-xs text-destructive", children: contactErrors.phone })
14109
+ ] })
14110
+ ] })
14111
+ ] }),
14112
+ children2,
14113
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("section", { className: "space-y-3", children: [
14114
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h2", { className: "border-b border-border pb-2 text-lg font-semibold", children: t.discountTitle }),
14115
+ appliedDiscount ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center justify-between rounded-lg border border-green-200 bg-green-50 px-4 py-3 dark:border-green-800 dark:bg-green-900/20", children: [
14116
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-2 text-sm text-green-700 dark:text-green-400", children: [
14117
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "font-semibold", children: appliedDiscount.code }),
14118
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: t.discountAppliedSuffix(formatPrice(appliedDiscount.amount, currencyCode, locale)) })
14119
+ ] }),
14120
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
14121
+ "button",
14122
+ {
14123
+ type: "button",
14124
+ onClick: onRemoveDiscount,
14125
+ "aria-label": t.removeDiscount,
14126
+ className: "text-green-600 transition-colors hover:text-green-800 dark:text-green-400 dark:hover:text-green-200",
14127
+ children: t.removeDiscount
14128
+ }
14129
+ )
14130
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex gap-2", children: [
14131
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("label", { htmlFor: "checkout-form-discount-code", className: "sr-only", children: t.discountTitle }),
14132
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
14133
+ "input",
14134
+ {
14135
+ id: "checkout-form-discount-code",
14136
+ type: "text",
14137
+ value: discountCode,
14138
+ onChange: (e) => onDiscountCodeChange(e.target.value.toUpperCase()),
14139
+ onKeyDown: handleDiscountCodeKeyDown,
14140
+ placeholder: t.discountPlaceholder,
14141
+ className: "flex-1 rounded-lg border border-border bg-background px-3 py-2 text-sm uppercase transition focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20"
14142
+ }
14143
+ ),
14144
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
14145
+ "button",
14146
+ {
14147
+ type: "button",
14148
+ onClick: onApplyDiscount,
14149
+ disabled: !discountCode.trim() || discountApplying,
14150
+ className: "rounded-lg bg-muted px-4 py-2 text-sm font-medium text-foreground transition hover:bg-muted/70 disabled:cursor-not-allowed disabled:opacity-50",
14151
+ children: discountApplying ? t.applyingDiscount : t.applyDiscount
14152
+ }
14153
+ )
14154
+ ] }),
14155
+ discountError && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "text-xs text-destructive", children: discountError })
14156
+ ] }),
14157
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
14158
+ "button",
14159
+ {
14160
+ type: "submit",
14161
+ disabled: submitting || submitDisabled,
14162
+ className: (0, import_utils12.cn)(
14163
+ "flex w-full items-center justify-center gap-2 rounded-xl px-4 py-3 font-semibold transition-all",
14164
+ submitting || submitDisabled ? "cursor-not-allowed bg-muted text-muted-foreground" : "bg-primary text-primary-foreground hover:bg-primary/90"
14165
+ ),
14166
+ children: submitting ? t.submitting : t.submit
14167
+ }
14168
+ )
14169
+ ]
14170
+ }
14171
+ )
14172
+ ] });
14173
+ }
14174
+
14175
+ // src/components/order-confirmation.tsx
14176
+ var import_utils13 = require("@reblu/site-ui/utils");
14177
+ var import_jsx_runtime13 = require("react/jsx-runtime");
14178
+ var DEFAULT_LABELS7 = {
14179
+ pollingTitle: "Confirmando tu pedido\u2026",
14180
+ pollingDescription: "Estamos procesando el pago, un momento\u2026",
14181
+ foundTitle: "\xA1Pedido confirmado!",
14182
+ foundDescription: "Recibir\xE1s un email de confirmaci\xF3n con todos los detalles.",
14183
+ timeoutTitle: "Pago recibido",
14184
+ timeoutDescription: "Tu pago se ha procesado. Recibir\xE1s un email de confirmaci\xF3n en breve.",
14185
+ orderNumberLabel: "Pedido confirmado",
14186
+ totalLabel: "Total",
14187
+ confirmationEmailPrefix: "Te hemos enviado un email de confirmaci\xF3n a",
14188
+ sessionReferenceLabel: "Referencia de sesi\xF3n",
14189
+ // REB-837
14190
+ failedTitle: "El pago no se ha completado",
14191
+ failedDescription: "No se ha podido procesar el pago. Tu carrito sigue intacto.",
14192
+ backToCartLabel: "Volver al carrito",
14193
+ refundedTitle: "Este pedido ha sido reembolsado",
14194
+ refundedDescription: "El importe se ha devuelto a tu m\xE9todo de pago original.",
14195
+ partiallyRefundedTitle: "Este pedido ha sido reembolsado parcialmente",
14196
+ partiallyRefundedDescription: "Parte del importe se ha devuelto a tu m\xE9todo de pago original.",
14197
+ pendingTimeoutTitle: "Pedido recibido",
14198
+ pendingTimeoutDescription: "Estamos confirmando el pago; te enviaremos un email en cuanto se complete.",
14199
+ recheckLabel: "Volver a comprobar",
14200
+ notFoundTitle: "No encontramos ning\xFAn pedido",
14201
+ notFoundDescription: "Comprueba el enlace o contacta con nosotros si el problema persiste.",
14202
+ errorTitle: "Ha ocurrido un error",
14203
+ errorDescription: "No hemos podido comprobar el estado de tu pedido.",
14204
+ orderReferenceLabel: "Referencia del pedido"
14205
+ };
14206
+ function OrderConfirmation({
14207
+ status,
14208
+ order,
14209
+ sessionId,
14210
+ cartHref,
14211
+ onRecheck,
14212
+ labels,
14213
+ currencyCode,
14214
+ locale,
14215
+ className
14216
+ }) {
14217
+ const t = { ...DEFAULT_LABELS7, ...labels };
14218
+ const isPolling = status === "polling" || status === "loading";
14219
+ const isFound = status === "found" || status === "paid";
14220
+ const { title, description } = (() => {
14221
+ if (isPolling) return { title: t.pollingTitle, description: t.pollingDescription };
14222
+ if (status === "failed") return { title: t.failedTitle, description: t.failedDescription };
14223
+ if (status === "refunded") return { title: t.refundedTitle, description: t.refundedDescription };
14224
+ if (status === "partially_refunded") {
14225
+ return { title: t.partiallyRefundedTitle, description: t.partiallyRefundedDescription };
14226
+ }
14227
+ if (status === "pending_timeout") {
14228
+ return { title: t.pendingTimeoutTitle, description: t.pendingTimeoutDescription };
14229
+ }
14230
+ if (status === "not_found") return { title: t.notFoundTitle, description: t.notFoundDescription };
14231
+ if (status === "error") return { title: t.errorTitle, description: t.errorDescription };
14232
+ if (isFound || order) return { title: t.foundTitle, description: t.foundDescription };
14233
+ return { title: t.timeoutTitle, description: t.timeoutDescription };
14234
+ })();
14235
+ const showFullOrderSummary = Boolean(order) && (isFound || status === "timeout");
14236
+ const showOrderReference = Boolean(order) && !showFullOrderSummary && (status === "refunded" || status === "partially_refunded" || status === "pending_timeout");
14237
+ const showSessionReference = !order && sessionId && (status === "timeout" || status === "not_found" || status === "pending_timeout");
14238
+ const showRecheck = (status === "pending_timeout" || status === "error") && onRecheck;
14239
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: (0, import_utils13.cn)("space-y-6 text-center", className), "data-slot": "order-confirmation", children: [
14240
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h1", { className: "text-3xl font-bold", children: title }),
14241
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-lg text-muted-foreground", children: description }),
14242
+ showFullOrderSummary && order && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "space-y-6", children: [
14243
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "inline-block rounded-xl bg-muted px-6 py-4", children: [
14244
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "mb-1 text-xs uppercase tracking-widest text-muted-foreground", children: t.orderNumberLabel }),
14245
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "font-mono text-lg font-semibold", children: order.orderNumber })
14246
+ ] }),
14247
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "mx-auto max-w-sm space-y-3 rounded-xl border border-border bg-card p-5 text-left", children: [
14248
+ order.items.map((item, idx) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
14249
+ "div",
14250
+ {
14251
+ className: "flex justify-between gap-4 text-sm",
14252
+ children: [
14253
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "max-w-[60%] truncate text-muted-foreground", children: [
14254
+ item.product.name,
14255
+ item.variant ? ` (${item.variant.name})` : "",
14256
+ " x",
14257
+ item.quantity
14258
+ ] }),
14259
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: formatPrice(item.total, currencyCode, locale) })
14260
+ ]
14261
+ },
14262
+ idx
14263
+ )),
14264
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "space-y-1 border-t border-border pt-3 text-sm", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex justify-between pt-1 text-base font-bold", children: [
14265
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: t.totalLabel }),
14266
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: formatPrice(order.total, currencyCode, locale) })
14267
+ ] }) })
14268
+ ] }),
14269
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { className: "mx-auto max-w-sm text-sm text-muted-foreground", children: [
14270
+ t.confirmationEmailPrefix,
14271
+ " ",
14272
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "font-medium text-foreground", children: order.customerEmail }),
14273
+ "."
14274
+ ] })
14275
+ ] }),
14276
+ showOrderReference && order && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "inline-block rounded-xl bg-muted px-6 py-4", children: [
14277
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "mb-1 text-xs uppercase tracking-widest text-muted-foreground", children: t.orderReferenceLabel }),
14278
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "font-mono text-lg font-semibold", children: order.orderNumber })
14279
+ ] }),
14280
+ status === "failed" && cartHref && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
14281
+ "a",
14282
+ {
14283
+ href: cartHref,
14284
+ className: "inline-block text-sm font-semibold text-primary underline-offset-2 hover:underline",
14285
+ children: t.backToCartLabel
14286
+ }
14287
+ ),
14288
+ showRecheck && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
14289
+ "button",
14290
+ {
14291
+ type: "button",
14292
+ onClick: onRecheck,
14293
+ className: "inline-flex items-center justify-center rounded-xl bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground transition-colors hover:bg-primary/90",
14294
+ children: t.recheckLabel
14295
+ }
14296
+ ),
14297
+ showSessionReference && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "inline-block rounded-xl bg-muted px-6 py-4", children: [
14298
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "mb-1 text-xs uppercase tracking-widest text-muted-foreground", children: t.sessionReferenceLabel }),
14299
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "break-all font-mono text-sm font-semibold", children: sessionId })
14300
+ ] })
14301
+ ] });
14302
+ }
13622
14303
  // Annotate the CommonJS export names for ESM import in node:
13623
14304
  0 && (module.exports = {
13624
14305
  ALLOWED_YOUTUBE_HOSTS,
14306
+ AddedToCartToast,
14307
+ CartLineList,
14308
+ CartSummary,
14309
+ CheckoutForm,
14310
+ CheckoutLoginPrompt,
14311
+ DEFAULT_SHOP_ERROR_FALLBACK_MESSAGE,
14312
+ DEFAULT_SHOP_ERROR_MESSAGES,
13625
14313
  DEFAULT_SHOP_PRICE_BANDS,
13626
14314
  MarkdownRenderer,
14315
+ OrderConfirmation,
13627
14316
  ProductCard,
13628
14317
  ProfileCard,
13629
14318
  SafeHtml,
@@ -13632,6 +14321,7 @@ function ShopFilters({
13632
14321
  Treatment,
13633
14322
  buildShareUrls,
13634
14323
  formatPrice,
14324
+ getShopErrorMessage,
13635
14325
  isAllowedYouTubeHost,
13636
14326
  markdownToSafeHtml,
13637
14327
  readingTime,