@nextblock-cms/ecom 0.20.1 → 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 (317) hide show
  1. package/_virtual/_rolldown/runtime.cjs.js +1 -0
  2. package/index.cjs.js +1 -1
  3. package/index.es.js +38 -146
  4. package/lib/CurrencyProvider.cjs.js +1 -1
  5. package/lib/CurrencyProvider.d.ts +1 -1
  6. package/lib/CurrencyProvider.es.js +85 -95
  7. package/lib/PaymentReadinessProvider.cjs.js +1 -1
  8. package/lib/PaymentReadinessProvider.d.ts +1 -1
  9. package/lib/PaymentReadinessProvider.es.js +24 -27
  10. package/lib/cart-store.cjs.js +1 -1
  11. package/lib/cart-store.es.js +109 -121
  12. package/lib/components/AccountNavigationMenu.cjs.js +1 -1
  13. package/lib/components/AccountNavigationMenu.d.ts +1 -1
  14. package/lib/components/AccountNavigationMenu.es.js +36 -50
  15. package/lib/components/AddToCartButton.cjs.js +1 -1
  16. package/lib/components/AddToCartButton.d.ts +1 -1
  17. package/lib/components/AddToCartButton.es.js +94 -89
  18. package/lib/components/Cart.cjs.js +1 -1
  19. package/lib/components/Cart.d.ts +1 -1
  20. package/lib/components/Cart.es.js +261 -180
  21. package/lib/components/CartDrawer.cjs.js +1 -1
  22. package/lib/components/CartDrawer.d.ts +1 -1
  23. package/lib/components/CartDrawer.es.js +218 -148
  24. package/lib/components/CartIcon.cjs.js +1 -1
  25. package/lib/components/CartIcon.d.ts +1 -1
  26. package/lib/components/CartIcon.es.js +33 -35
  27. package/lib/components/Checkout.cjs.js +1 -1
  28. package/lib/components/Checkout.d.ts +1 -1
  29. package/lib/components/Checkout.es.js +1092 -1108
  30. package/lib/components/CouponForm.cjs.js +1 -1
  31. package/lib/components/CouponForm.d.ts +1 -1
  32. package/lib/components/CouponForm.es.js +136 -148
  33. package/lib/components/CurrencySwitcher.cjs.js +1 -1
  34. package/lib/components/CurrencySwitcher.d.ts +1 -1
  35. package/lib/components/CurrencySwitcher.es.js +22 -18
  36. package/lib/components/CustomerProfileForm.cjs.js +1 -1
  37. package/lib/components/CustomerProfileForm.es.js +454 -313
  38. package/lib/components/FeaturedProduct.cjs.js +1 -1
  39. package/lib/components/FeaturedProduct.d.ts +1 -1
  40. package/lib/components/FeaturedProduct.es.js +98 -83
  41. package/lib/components/FreemiusLicensePanel.cjs.js +1 -1
  42. package/lib/components/FreemiusLicensePanel.d.ts +1 -1
  43. package/lib/components/FreemiusLicensePanel.es.js +70 -65
  44. package/lib/components/InvoiceDocument.cjs.js +1 -1
  45. package/lib/components/InvoiceDocument.es.js +256 -192
  46. package/lib/components/InvoiceViewerShell.cjs.js +2 -2
  47. package/lib/components/InvoiceViewerShell.d.ts +1 -1
  48. package/lib/components/InvoiceViewerShell.es.js +75 -106
  49. package/lib/components/ProductCard.cjs.js +1 -1
  50. package/lib/components/ProductCard.d.ts +1 -1
  51. package/lib/components/ProductCard.es.js +186 -171
  52. package/lib/components/ProductDetailsLayout.cjs.js +1 -1
  53. package/lib/components/ProductDetailsLayout.es.js +405 -404
  54. package/lib/components/ProductGallery.cjs.js +1 -1
  55. package/lib/components/ProductGallery.d.ts +1 -1
  56. package/lib/components/ProductGallery.es.js +51 -54
  57. package/lib/components/ProductGrid.cjs.js +1 -1
  58. package/lib/components/ProductGrid.d.ts +1 -1
  59. package/lib/components/ProductGrid.es.js +23 -25
  60. package/lib/components/ShippingEstimator.cjs.js +1 -1
  61. package/lib/components/ShippingEstimator.d.ts +1 -1
  62. package/lib/components/ShippingEstimator.es.js +158 -153
  63. package/lib/components/ShortDescription.cjs.js +1 -1
  64. package/lib/components/ShortDescription.es.js +17 -17
  65. package/lib/components/SimpleTiptapRenderer.cjs.js +1 -1
  66. package/lib/components/SimpleTiptapRenderer.es.js +238 -211
  67. package/lib/components/SubscriptionSelector.cjs.js +1 -1
  68. package/lib/components/SubscriptionSelector.es.js +159 -154
  69. package/lib/countries.cjs.js +1 -1
  70. package/lib/countries.es.js +232 -75
  71. package/lib/coupon-server.cjs.js +1 -1
  72. package/lib/coupon-server.es.js +180 -224
  73. package/lib/coupons.cjs.js +1 -1
  74. package/lib/coupons.es.js +12 -14
  75. package/lib/currency-constants.cjs.js +1 -1
  76. package/lib/currency-constants.es.js +4 -4
  77. package/lib/currency-rest-client.cjs.js +1 -1
  78. package/lib/currency-rest-client.es.js +15 -22
  79. package/lib/currency-store.cjs.js +1 -1
  80. package/lib/currency-store.es.js +20 -27
  81. package/lib/currency-sync.cjs.js +1 -1
  82. package/lib/currency-sync.es.js +124 -170
  83. package/lib/currency.cjs.js +1 -1
  84. package/lib/currency.es.js +242 -310
  85. package/lib/customer-addresses.cjs.js +1 -1
  86. package/lib/customer-addresses.es.js +80 -109
  87. package/lib/customer-orders.cjs.js +1 -1
  88. package/lib/customer-orders.es.js +31 -43
  89. package/lib/customer.cjs.js +1 -1
  90. package/lib/customer.es.js +43 -52
  91. package/lib/export-helpers.cjs.js +1 -1
  92. package/lib/export-helpers.es.js +53 -52
  93. package/lib/factory.cjs.js +1 -1
  94. package/lib/factory.es.js +10 -7
  95. package/lib/freemius-coupons.cjs.js +1 -1
  96. package/lib/freemius-coupons.es.js +245 -262
  97. package/lib/freemius-license-claim.cjs.js +1 -1
  98. package/lib/freemius-license-claim.es.js +87 -71
  99. package/lib/freemius-license.cjs.js +1 -1
  100. package/lib/freemius-license.es.js +32 -39
  101. package/lib/freemius-order-sync.cjs.js +1 -1
  102. package/lib/freemius-order-sync.es.js +226 -290
  103. package/lib/freemius-trial-provision.cjs.js +1 -1
  104. package/lib/freemius-trial-provision.es.js +136 -130
  105. package/lib/inventory-settings.cjs.js +1 -1
  106. package/lib/inventory-settings.es.js +69 -77
  107. package/lib/invoice-server.cjs.js +3 -3
  108. package/lib/invoice-server.es.js +94 -141
  109. package/lib/invoice-ui.cjs.js +1 -1
  110. package/lib/invoice-ui.es.js +50 -66
  111. package/lib/invoice.cjs.js +1 -1
  112. package/lib/invoice.es.js +85 -94
  113. package/lib/order-inventory.cjs.js +25 -25
  114. package/lib/order-inventory.es.js +67 -79
  115. package/lib/order-tax-details.cjs.js +1 -1
  116. package/lib/order-tax-details.es.js +142 -153
  117. package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -1
  118. package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
  119. package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
  120. package/lib/pages/cms/coupons/CouponsPage.cjs.js +2 -2
  121. package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
  122. package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
  123. package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -1
  124. package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
  125. package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
  126. package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -1
  127. package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
  128. package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
  129. package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -1
  130. package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
  131. package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
  132. package/lib/pages/cms/coupons/actions.cjs.js +1 -1
  133. package/lib/pages/cms/coupons/actions.es.js +112 -115
  134. package/lib/pages/cms/coupons/index.cjs.js +1 -0
  135. package/lib/pages/cms/coupons/index.es.js +3 -0
  136. package/lib/pages/cms/coupons/product-options.cjs.js +1 -1
  137. package/lib/pages/cms/coupons/product-options.es.js +21 -23
  138. package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -1
  139. package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
  140. package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
  141. package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -1
  142. package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
  143. package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
  144. package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -1
  145. package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
  146. package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
  147. package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -1
  148. package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
  149. package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
  150. package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -1
  151. package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
  152. package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
  153. package/lib/pages/cms/orders/actions.cjs.js +3 -3
  154. package/lib/pages/cms/orders/actions.es.js +53 -69
  155. package/lib/pages/cms/orders/export-actions.cjs.js +1 -1
  156. package/lib/pages/cms/orders/export-actions.es.js +23 -26
  157. package/lib/pages/cms/orders/index.cjs.js +1 -0
  158. package/lib/pages/cms/orders/index.es.js +6 -0
  159. package/lib/pages/cms/orders/server-actions.cjs.js +1 -1
  160. package/lib/pages/cms/orders/server-actions.es.js +60 -51
  161. package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -1
  162. package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
  163. package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
  164. package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -1
  165. package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
  166. package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
  167. package/lib/pages/cms/payments/actions.cjs.js +1 -1
  168. package/lib/pages/cms/payments/actions.es.js +38 -48
  169. package/lib/pages/cms/payments/index.cjs.js +1 -0
  170. package/lib/pages/cms/payments/index.es.js +3 -0
  171. package/lib/pages/cms/payments/queries.cjs.js +1 -1
  172. package/lib/pages/cms/payments/queries.es.js +38 -48
  173. package/lib/pages/cms/products/ProductsPage.cjs.js +1 -1
  174. package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
  175. package/lib/pages/cms/products/ProductsPage.es.js +63 -66
  176. package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
  177. package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -1
  178. package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +138 -155
  179. package/lib/pages/cms/products/actions.cjs.js +4 -4
  180. package/lib/pages/cms/products/actions.es.js +121 -162
  181. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -1
  182. package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
  183. package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
  184. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -1
  185. package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
  186. package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
  187. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -1
  188. package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
  189. package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
  190. package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -1
  191. package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
  192. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -1
  193. package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
  194. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -1
  195. package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
  196. package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
  197. package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -1
  198. package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
  199. package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
  200. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -1
  201. package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
  202. package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
  203. package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -1
  204. package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
  205. package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
  206. package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
  207. package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -1
  208. package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
  209. package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -1
  210. package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
  211. package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
  212. package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -1
  213. package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
  214. package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
  215. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -1
  216. package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
  217. package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
  218. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +2 -2
  219. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
  220. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
  221. package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
  222. package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -1
  223. package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
  224. package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
  225. package/lib/pages/cms/products/index.cjs.js +1 -0
  226. package/lib/pages/cms/products/index.es.js +8 -0
  227. package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -1
  228. package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
  229. package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
  230. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -2
  231. package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
  232. package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
  233. package/lib/pages/cms/products/inventory/actions.cjs.js +3 -3
  234. package/lib/pages/cms/products/inventory/actions.es.js +83 -91
  235. package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -1
  236. package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
  237. package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
  238. package/lib/pages/cms/products/product-price-sync.cjs.js +1 -1
  239. package/lib/pages/cms/products/product-price-sync.es.js +74 -89
  240. package/lib/pages/cms/products/server-actions.cjs.js +1 -1
  241. package/lib/pages/cms/products/server-actions.es.js +250 -233
  242. package/lib/pages/cms/shipping/ShippingPage.cjs.js +2 -2
  243. package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
  244. package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -1
  245. package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
  246. package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
  247. package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -1
  248. package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
  249. package/lib/pages/cms/shipping/index.cjs.js +1 -0
  250. package/lib/pages/cms/shipping/index.es.js +3 -0
  251. package/lib/pages/cms/shipping/server-actions.cjs.js +1 -1
  252. package/lib/pages/cms/shipping/server-actions.es.js +131 -149
  253. package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -1
  254. package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
  255. package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
  256. package/lib/pages/cms/taxes/actions.cjs.js +1 -1
  257. package/lib/pages/cms/taxes/actions.es.js +41 -53
  258. package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -1
  259. package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
  260. package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
  261. package/lib/pages/cms/taxes/index.cjs.js +1 -0
  262. package/lib/pages/cms/taxes/index.es.js +3 -0
  263. package/lib/payment-config.cjs.js +1 -1
  264. package/lib/payment-config.es.js +110 -126
  265. package/lib/product-actions.cjs.js +4 -4
  266. package/lib/product-actions.es.js +289 -544
  267. package/lib/product-context.cjs.js +1 -1
  268. package/lib/product-context.es.js +13 -15
  269. package/lib/product-schema.cjs.js +1 -1
  270. package/lib/product-schema.es.js +99 -134
  271. package/lib/providers/freemius.cjs.js +1 -5
  272. package/lib/providers/freemius.es.js +446 -530
  273. package/lib/providers/stripe.cjs.js +1 -1
  274. package/lib/providers/stripe.es.js +417 -477
  275. package/lib/server-actions/coupon-actions.cjs.js +1 -1
  276. package/lib/server-actions/coupon-actions.es.js +22 -22
  277. package/lib/server-actions/customer-actions.cjs.js +1 -1
  278. package/lib/server-actions/customer-actions.es.js +26 -28
  279. package/lib/server-actions/product-actions.cjs.js +1 -1
  280. package/lib/server-actions/product-actions.es.js +9 -15
  281. package/lib/server-actions/shipping-actions.cjs.js +1 -1
  282. package/lib/server-actions/shipping-actions.es.js +27 -24
  283. package/lib/server-actions/tax-actions.cjs.js +1 -1
  284. package/lib/server-actions/tax-actions.es.js +33 -39
  285. package/lib/shared-inventory.cjs.js +2 -2
  286. package/lib/shared-inventory.es.js +111 -160
  287. package/lib/shipping/resolver.cjs.js +2 -2
  288. package/lib/shipping/resolver.es.js +44 -61
  289. package/lib/shipping-rate-currency.cjs.js +1 -1
  290. package/lib/shipping-rate-currency.es.js +52 -67
  291. package/lib/states.cjs.js +1 -1
  292. package/lib/states.es.js +333 -154
  293. package/lib/stripe/checkout.cjs.js +1 -1
  294. package/lib/stripe/checkout.es.js +125 -181
  295. package/lib/stripe/client.cjs.js +1 -1
  296. package/lib/stripe/client.es.js +14 -19
  297. package/lib/stripe/order-sync.cjs.js +1 -1
  298. package/lib/stripe/order-sync.es.js +106 -126
  299. package/lib/stripe/webhooks.cjs.js +1 -1
  300. package/lib/stripe/webhooks.es.js +37 -31
  301. package/lib/tax-calculation.cjs.js +1 -1
  302. package/lib/tax-calculation.es.js +84 -98
  303. package/lib/trials.cjs.js +1 -1
  304. package/lib/trials.es.js +24 -30
  305. package/lib/types.cjs.js +1 -1
  306. package/lib/types.es.js +21 -27
  307. package/lib/use-cart.cjs.js +1 -1
  308. package/lib/use-cart.es.js +38 -40
  309. package/lib/use-price-formatter.cjs.js +1 -1
  310. package/lib/use-price-formatter.es.js +10 -11
  311. package/lib/variation-utils.cjs.js +1 -1
  312. package/lib/variation-utils.es.js +199 -261
  313. package/lib/zod-config.cjs.js +1 -1
  314. package/lib/zod-config.es.js +5 -6
  315. package/package.json +16 -16
  316. package/server.cjs.js +1 -1
  317. package/server.es.js +56 -211
@@ -1,407 +1,408 @@
1
- 'use client';
2
- import { jsxs as a, jsx as t, Fragment as te } from "react/jsx-runtime";
3
- import re, { useState as F, useEffect as A, useMemo as V } from "react";
4
- import { Download as ae, Package as se, ShieldCheck as ie } from "lucide-react";
5
- import { Badge as O } from "@nextblock-cms/ui/badge";
6
- import { Button as ce } from "@nextblock-cms/ui/button";
7
- import { Label as ne } from "@nextblock-cms/ui/label";
1
+ "use client";
2
+ import { isDigitalProduct as e } from "../types.es.js";
3
+ import { resolveEffectivePriceForCurrency as t } from "../currency.es.js";
4
+ import { useCurrency as n } from "../CurrencyProvider.es.js";
5
+ import { usePriceFormatter as r } from "../use-price-formatter.es.js";
6
+ import { getTrialSummary as i } from "../trials.es.js";
7
+ import { applyVariantSelection as a, chooseInitialVariantSelections as o, findMatchingVariant as s, getAvailableTermIdsForAttribute as c, normalizeSelectionsToAvailableVariants as l, resolveTranslatedText as u } from "../variation-utils.es.js";
8
+ import { AddToCartButton as d } from "./AddToCartButton.es.js";
9
+ import { ProductGallery as f } from "./ProductGallery.es.js";
10
+ import { SimpleTiptapRenderer as ee } from "./SimpleTiptapRenderer.es.js";
11
+ import { ShortDescription as te } from "./ShortDescription.es.js";
12
+ import { SubscriptionSelector as ne } from "./SubscriptionSelector.es.js";
13
+ import { useProduct as re } from "../product-context.es.js";
14
+ import { Badge as p } from "@nextblock-cms/ui/badge";
15
+ import { Button as ie } from "@nextblock-cms/ui/button";
16
+ import m, { useEffect as h, useMemo as g, useState as _ } from "react";
17
+ import { Download as ae, Package as oe, ShieldCheck as se } from "lucide-react";
18
+ import { cn as v, useTranslations as y } from "@nextblock-cms/utils";
19
+ import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
20
+ import { Label as ce } from "@nextblock-cms/ui/label";
8
21
  import { Separator as le } from "@nextblock-cms/ui/separator";
9
- import { useTranslations as oe, cn as de } from "@nextblock-cms/utils";
10
- import { usePriceFormatter as me } from "../use-price-formatter.es.js";
11
- import { useProduct as ue } from "../product-context.es.js";
12
- import { ProductGallery as pe } from "./ProductGallery.es.js";
13
- import { AddToCartButton as he } from "./AddToCartButton.es.js";
14
- import { SubscriptionSelector as fe } from "./SubscriptionSelector.es.js";
15
- import { SimpleTiptapRenderer as ge } from "./SimpleTiptapRenderer.es.js";
16
- import { ShortDescription as xe } from "./ShortDescription.es.js";
17
- import { chooseInitialVariantSelections as M, normalizeSelectionsToAvailableVariants as ve, findMatchingVariant as _e, resolveTranslatedText as be, getAvailableTermIdsForAttribute as Ne, applyVariantSelection as ye } from "../variation-utils.es.js";
18
- import { useCurrency as we } from "../CurrencyProvider.es.js";
19
- import { resolveEffectivePriceForCurrency as J } from "../currency.es.js";
20
- import { isDigitalProduct as ke } from "../types.es.js";
21
- import { getTrialSummary as Se } from "../trials.es.js";
22
- function U(d, v, P, E) {
23
- const C = {
24
- kind: "product-field",
25
- field: v,
26
- input: P,
27
- label: E
28
- }, e = typeof window < "u" ? window.location.origin : process.env.NEXT_PUBLIC_URL || process.env.TARGET_URL || (process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : "") || "http://localhost:3000";
29
- let g = (typeof window < "u" ? window.location.origin : process.env.NEXT_PUBLIC_URL || process.env.TARGET_URL || (process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : "") || "http://localhost:3000").replace(/\/+$/, "");
30
- try {
31
- (g.startsWith("http://") || g.startsWith("https://")) && (g = new URL(g).hostname);
32
- } catch {
33
- }
34
- const y = process.env.NEXTBLOCK_VERCEL_PROJECT_ID || process.env.VERCEL_PROJECT_ID, m = process.env.NEXTBLOCK_VERCEL_WORKSPACE_ID || process.env.VERCEL_ORG_ID, _ = {
35
- origin: g,
36
- editUrl: `${e}/cms/products/${d.id}/edit`,
37
- data: {
38
- parentType: "product",
39
- parentId: d.id,
40
- slug: d.slug,
41
- languageId: d.language_id,
42
- draftId: null,
43
- target: C
44
- }
45
- };
46
- return y && (_.projectId = y), m && (_.workspaceId = m), {
47
- "data-vercel-edit-info": JSON.stringify(_),
48
- "data-vercel-edit-target": JSON.stringify(C),
49
- "data-nextblock-visual-edit": `product:${v}`
50
- };
22
+ //#region libs/ecommerce/src/lib/components/ProductDetailsLayout.tsx
23
+ function C(e, t, n, r) {
24
+ let i = {
25
+ kind: "product-field",
26
+ field: t,
27
+ input: n,
28
+ label: r
29
+ }, a = typeof window < "u" ? window.location.origin : process.env.NEXT_PUBLIC_URL || process.env.TARGET_URL || (process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : "") || "http://localhost:3000", o = (typeof window < "u" ? window.location.origin : process.env.NEXT_PUBLIC_URL || process.env.TARGET_URL || (process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : "") || "http://localhost:3000").replace(/\/+$/, "");
30
+ try {
31
+ (o.startsWith("http://") || o.startsWith("https://")) && (o = new URL(o).hostname);
32
+ } catch {}
33
+ let s = process.env.NEXTBLOCK_VERCEL_PROJECT_ID || process.env.VERCEL_PROJECT_ID, c = process.env.NEXTBLOCK_VERCEL_WORKSPACE_ID || process.env.VERCEL_ORG_ID, l = {
34
+ origin: o,
35
+ editUrl: `${a}/cms/products/${e.id}/edit`,
36
+ data: {
37
+ parentType: "product",
38
+ parentId: e.id,
39
+ slug: e.slug,
40
+ languageId: e.language_id,
41
+ draftId: null,
42
+ target: i
43
+ }
44
+ };
45
+ return s && (l.projectId = s), c && (l.workspaceId = c), {
46
+ "data-vercel-edit-info": JSON.stringify(l),
47
+ "data-vercel-edit-target": JSON.stringify(i),
48
+ "data-nextblock-visual-edit": `product:${t}`
49
+ };
51
50
  }
52
- const Ke = ({
53
- visualEditingEnabled: d = !1,
54
- descriptionNode: v,
55
- reviewsNode: P,
56
- canPurchase: E = !0,
57
- purchaseFallbackNode: C
58
- }) => {
59
- const e = ue(), { t: n, lang: g } = oe(), y = me(), { activeCurrencyCode: m, currencies: _ } = we(), G = d ? U(
60
- e,
61
- "title",
62
- "plain-text",
63
- "Product title"
64
- ) : void 0, K = d ? U(
65
- e,
66
- "short_description",
67
- "plain-text",
68
- "Short description"
69
- ) : void 0, X = d ? U(
70
- e,
71
- "description_json",
72
- "tiptap",
73
- "Product description"
74
- ) : void 0, o = (s, l, p) => {
75
- const h = n(s, p);
76
- return h === s ? l : h;
77
- }, R = e.images && e.images.length > 0 ? e.images : e.image_url ? [{ url: e.image_url, alt: e.title }] : [], b = e.custom_props?.provider === "freemius" || ke(e), j = Se(e, n), c = !b && !!(e.has_variants && e.attributes?.length && e.variants?.length), x = e.attributes || [], u = e.variants || [], [w, T] = F(() => M(x, u)), [q, I] = F(1);
78
- A(() => {
79
- I(1);
80
- }, [e.id]), A(() => {
81
- c && T(M(x, u));
82
- }, [x, c, e.id, u]);
83
- const N = V(() => c ? ve(
84
- x,
85
- u,
86
- w
87
- ) : w, [x, c, w, u]);
88
- A(() => {
89
- JSON.stringify(N) !== JSON.stringify(w) && T(N);
90
- }, [N, w]);
91
- const r = V(() => c ? _e(u, N) : null, [c, N, u]), $ = J({
92
- prices: e.prices,
93
- salePrices: e.sale_prices,
94
- fallbackPrice: e.price,
95
- fallbackSalePrice: e.sale_price,
96
- saleStartAt: e.sale_start_at,
97
- saleEndAt: e.sale_end_at,
98
- scheduledPrice: e.scheduled_price,
99
- scheduledPrices: e.scheduled_prices,
100
- scheduledPriceAt: e.scheduled_price_at,
101
- currencyCode: m,
102
- currencies: _
103
- }), B = c && r ? J({
104
- prices: r.prices,
105
- salePrices: r.sale_prices,
106
- fallbackPrice: r.price,
107
- fallbackSalePrice: r.sale_price,
108
- saleStartAt: r.sale_start_at,
109
- saleEndAt: r.sale_end_at,
110
- scheduledPrice: r.scheduled_price,
111
- scheduledPrices: r.scheduled_prices,
112
- scheduledPriceAt: r.scheduled_price_at,
113
- currencyCode: m,
114
- currencies: _
115
- }) : null, k = B?.price ?? $.price, S = B?.sale_price ?? $.sale_price, i = c ? r?.stock_quantity ?? 0 : e.stock ?? null, L = i === null || i > 0, f = i === null ? q : Math.max(1, Math.min(q, Math.max(i, 1))), z = V(() => {
116
- if (!r?.image_url)
117
- return R;
118
- const s = {
119
- url: r.image_url,
120
- alt: `${e.title} ${r.label}`
121
- }, l = R.filter(
122
- (p) => p.url !== r.image_url
123
- );
124
- return [s, ...l];
125
- }, [R, e.title, r]), Q = typeof S == "number" && k > 0 ? Math.round(
126
- (k - S) / k * 100
127
- ) : 0, W = c && r ? {
128
- ...e,
129
- sku: r.sku,
130
- price: r.price,
131
- prices: r.prices,
132
- sale_price: typeof r.sale_price == "number" ? r.sale_price : null,
133
- sale_prices: r.sale_prices,
134
- // The variant's own sale window and scheduled price, not the parent product's.
135
- sale_start_at: r.sale_start_at,
136
- sale_end_at: r.sale_end_at,
137
- scheduled_price: r.scheduled_price,
138
- scheduled_prices: r.scheduled_prices,
139
- scheduled_price_at: r.scheduled_price_at,
140
- image_url: r.image_url || e.image_url,
141
- stock: r.stock_quantity,
142
- variant_id: r.id,
143
- variant_label: r.label,
144
- selected_options: r.selected_options,
145
- currency_code: m
146
- } : {
147
- ...e,
148
- currency_code: m
149
- }, H = (s, l) => {
150
- T(
151
- (p) => ye(x, u, p, s, l)
152
- );
153
- }, Y = i === null ? o("ecommerce.in_stock_untracked", "In stock") : o("ecommerce.in_stock", `${i} in stock`, {
154
- count: String(i)
155
- }), D = o(
156
- "ecommerce.out_of_stock",
157
- "Out of stock"
158
- ), Z = o(
159
- "ecommerce.select_options",
160
- "Select Options"
161
- ), ee = o(
162
- "ecommerce.variant_selection_required",
163
- "Select one term from every dropdown to resolve a variation."
164
- );
165
- return /* @__PURE__ */ a("div", { className: "w-full animate-in fade-in slide-in-from-bottom-4 duration-700 ease-out", children: [
166
- /* @__PURE__ */ t("div", { className: "container mx-auto px-4 md:px-6 py-12", children: /* @__PURE__ */ a("div", { className: "grid gap-12 lg:grid-cols-[2fr_3fr] items-start", children: [
167
- /* @__PURE__ */ t("div", { className: "w-full max-w-2xl mx-auto lg:max-w-none", children: /* @__PURE__ */ t(pe, { images: z, className: "w-full" }) }),
168
- /* @__PURE__ */ a("div", { className: "flex flex-col gap-4 pb-2 max-w-xl mx-auto lg:mx-0 lg:max-w-none", children: [
169
- /* @__PURE__ */ t("div", { className: "space-y-6", children: /* @__PURE__ */ a("div", { className: "space-y-4", children: [
170
- /* @__PURE__ */ t(
171
- "h1",
172
- {
173
- className: "text-3xl sm:text-4xl lg:text-5xl font-extrabold tracking-tight text-foreground leading-[1.1] lg:mt-0",
174
- ...G,
175
- children: e.title
176
- }
177
- ),
178
- /* @__PURE__ */ t("div", { className: "flex items-center gap-2 mt-2", children: /* @__PURE__ */ a(
179
- "a",
180
- {
181
- href: "#reviews-section",
182
- className: "flex items-center gap-1.5 group hover:opacity-85 transition-opacity",
183
- children: [
184
- /* @__PURE__ */ t("div", { className: "flex items-center text-amber-500", children: Array.from({ length: 5 }).map((s, l) => /* @__PURE__ */ t(
185
- "svg",
186
- {
187
- className: de(
188
- "h-4 w-4 fill-current",
189
- l < Math.round(e.average_rating || 0) ? "text-amber-500" : "text-slate-300 dark:text-slate-700"
190
- ),
191
- viewBox: "0 0 20 20",
192
- fill: "currentColor",
193
- children: /* @__PURE__ */ t("path", { d: "M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" })
194
- },
195
- l
196
- )) }),
197
- e.total_reviews && e.total_reviews > 0 ? /* @__PURE__ */ a(te, { children: [
198
- /* @__PURE__ */ t("span", { className: "text-sm font-semibold text-slate-700 dark:text-slate-300", children: e.average_rating?.toFixed(1) }),
199
- /* @__PURE__ */ a("span", { className: "text-sm text-muted-foreground underline decoration-dotted group-hover:text-primary", children: [
200
- "(",
201
- e.total_reviews === 1 ? n("reviews.review_count_one", { count: e.total_reviews }) : n("reviews.review_count_other", { count: e.total_reviews }),
202
- ")"
203
- ] })
204
- ] }) : /* @__PURE__ */ t("span", { className: "text-xs text-muted-foreground group-hover:text-primary underline decoration-dotted", children: n("reviews.be_the_first") })
205
- ]
206
- }
207
- ) }),
208
- e.categories && e.categories.length > 0 && /* @__PURE__ */ t("div", { className: "flex flex-wrap items-center gap-1.5 text-xs font-bold uppercase tracking-widest text-amber-600 dark:text-amber-400", children: e.categories.map((s, l) => {
209
- const p = be(
210
- s.name,
211
- s.name_translations,
212
- g
213
- );
214
- return /* @__PURE__ */ a(re.Fragment, { children: [
215
- l > 0 && /* @__PURE__ */ t("span", { className: "text-muted-foreground/30", children: "•" }),
216
- /* @__PURE__ */ t("span", { children: p })
217
- ] }, s.id);
218
- }) }),
219
- /* @__PURE__ */ t(
220
- "div",
221
- {
222
- className: "prose prose-neutral dark:prose-invert max-w-none text-muted-foreground leading-relaxed text-left",
223
- ...K,
224
- children: e.short_description ? /* @__PURE__ */ t(
225
- xe,
226
- {
227
- value: e.short_description,
228
- className: "text-lg mb-4 leading-relaxed"
229
- }
230
- ) : d ? /* @__PURE__ */ t("p", { className: "text-lg mb-4 italic text-muted-foreground", children: "Add a short product description." }) : null
231
- }
232
- ),
233
- /* @__PURE__ */ a("div", { className: "flex items-center gap-3", children: [
234
- typeof S == "number" && /* @__PURE__ */ t(
235
- O,
236
- {
237
- variant: "destructive",
238
- className: "px-2.5 py-1 text-xs font-bold uppercase tracking-wide animate-pulse shadow-sm",
239
- children: n("ecommerce.sale_badge", {
240
- percent: String(Q)
241
- })
242
- }
243
- ),
244
- !b && i !== null && i > 0 && i < 10 && /* @__PURE__ */ t(
245
- O,
246
- {
247
- variant: "outline",
248
- className: "text-amber-600 border-amber-200 bg-amber-50",
249
- children: n("ecommerce.low_stock", {
250
- count: String(i)
251
- })
252
- }
253
- ),
254
- j && /* @__PURE__ */ t(
255
- O,
256
- {
257
- variant: "secondary",
258
- className: "border border-emerald-200 bg-emerald-50 text-emerald-800",
259
- children: j.label
260
- }
261
- )
262
- ] })
263
- ] }) }),
264
- /* @__PURE__ */ a("div", { className: "p-5 rounded-2xl bg-card border border-border/80 shadow-md space-y-4", children: [
265
- E ? b ? /* @__PURE__ */ t(fe, { product: e }) : /* @__PURE__ */ a("div", { className: "space-y-3.5", children: [
266
- /* @__PURE__ */ a("div", { className: "flex items-center justify-between gap-4", children: [
267
- /* @__PURE__ */ a("div", { className: "space-y-1", children: [
268
- /* @__PURE__ */ t("span", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-widest", children: o("ecommerce.price", "Price") }),
269
- /* @__PURE__ */ a("div", { className: "flex items-baseline gap-2.5", children: [
270
- /* @__PURE__ */ t("span", { className: "text-3xl font-extrabold text-foreground", children: y(
271
- S ?? k,
272
- m
273
- ) }),
274
- typeof S == "number" && /* @__PURE__ */ t("span", { className: "text-lg text-muted-foreground line-through decoration-destructive/20 decoration-1", children: y(k, m) })
275
- ] })
276
- ] }),
277
- !b && (r || !c) && /* @__PURE__ */ a("div", { className: "text-right space-y-1", children: [
278
- /* @__PURE__ */ a("span", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-widest block", children: [
279
- !c && e.sku && /* @__PURE__ */ a("span", { className: "mr-2 font-normal lowercase normal-case text-muted-foreground/70", children: [
280
- o("ecommerce.sku", "SKU"),
281
- ": ",
282
- e.sku
283
- ] }),
284
- o("ecommerce.status", "Status")
285
- ] }),
286
- /* @__PURE__ */ t("div", { className: L ? "text-emerald-600 dark:text-emerald-400 font-semibold text-sm" : "text-destructive font-semibold text-sm", children: L ? Y : D })
287
- ] })
288
- ] }),
289
- c && /* @__PURE__ */ t("div", { className: "space-y-3", children: /* @__PURE__ */ t("div", { className: "grid gap-3 sm:grid-cols-2", children: x.map((s, l) => {
290
- const p = Ne(
291
- u,
292
- s.id,
293
- {}
294
- );
295
- return /* @__PURE__ */ a("div", { className: "space-y-1", children: [
296
- /* @__PURE__ */ a("div", { className: "flex items-center justify-between", children: [
297
- /* @__PURE__ */ t(
298
- ne,
299
- {
300
- htmlFor: `attribute-${s.id}`,
301
- className: "text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",
302
- children: s.name
303
- }
304
- ),
305
- l === 0 && r?.sku && /* @__PURE__ */ t("span", { className: "text-[10px] text-muted-foreground font-mono", children: r.sku })
306
- ] }),
307
- /* @__PURE__ */ t(
308
- "select",
309
- {
310
- id: `attribute-${s.id}`,
311
- className: "flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring",
312
- value: N[s.id] || "",
313
- onChange: (h) => H(
314
- s.id,
315
- h.target.value
316
- ),
317
- children: s.terms.map((h) => /* @__PURE__ */ t(
318
- "option",
319
- {
320
- value: h.id,
321
- disabled: !p.has(h.id),
322
- children: h.value
323
- },
324
- h.id
325
- ))
326
- }
327
- )
328
- ] }, s.id);
329
- }) }) }),
330
- c && !r && /* @__PURE__ */ t("p", { className: "text-xs text-muted-foreground italic pt-1", children: ee }),
331
- /* @__PURE__ */ a("div", { className: "flex items-center gap-3 pt-1", children: [
332
- !b && L && /* @__PURE__ */ a(
333
- "div",
334
- {
335
- role: "group",
336
- "aria-label": o("ecommerce.quantity", "Quantity"),
337
- className: "flex items-center border rounded-lg h-12 bg-background border-input select-none",
338
- children: [
339
- /* @__PURE__ */ t(
340
- "button",
341
- {
342
- type: "button",
343
- onClick: () => I(Math.max(1, f - 1)),
344
- "aria-label": o("ecommerce.decrease_quantity", "Decrease quantity"),
345
- className: "px-3 h-full flex items-center justify-center rounded-l-lg text-muted-foreground hover:text-foreground active:scale-95 transition-colors text-lg font-medium focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",
346
- disabled: f <= 1,
347
- children: /* @__PURE__ */ t("span", { "aria-hidden": "true", children: "-" })
348
- }
349
- ),
350
- /* @__PURE__ */ t("span", { "aria-live": "polite", "aria-atomic": "true", className: "w-8 text-center text-sm font-semibold tabular-nums", children: f }),
351
- /* @__PURE__ */ t(
352
- "button",
353
- {
354
- type: "button",
355
- onClick: () => I(
356
- i !== null && f >= i ? f : f + 1
357
- ),
358
- "aria-label": o("ecommerce.increase_quantity", "Increase quantity"),
359
- className: "px-3 h-full flex items-center justify-center rounded-r-lg text-muted-foreground hover:text-foreground active:scale-95 transition-colors text-lg font-medium focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",
360
- disabled: i !== null && f >= i,
361
- children: /* @__PURE__ */ t("span", { "aria-hidden": "true", children: "+" })
362
- }
363
- )
364
- ]
365
- }
366
- ),
367
- c && (!r || !L) ? /* @__PURE__ */ t(
368
- ce,
369
- {
370
- disabled: !0,
371
- className: "flex-1 h-12 text-md font-bold shadow-md",
372
- children: r ? D : Z
373
- }
374
- ) : /* @__PURE__ */ t(
375
- he,
376
- {
377
- product: W,
378
- quantity: f,
379
- className: "flex-1 h-12 text-base font-bold shadow-md transition-shadow hover:shadow-lg active:scale-[0.98]"
380
- }
381
- )
382
- ] })
383
- ] }) : C,
384
- /* @__PURE__ */ t(le, { className: "opacity-60 my-0.5" }),
385
- /* @__PURE__ */ a("div", { className: "grid grid-cols-2 gap-4 text-center text-[11px] font-medium text-muted-foreground pt-1", children: [
386
- /* @__PURE__ */ t("div", { className: "flex items-center justify-center gap-2", children: b ? /* @__PURE__ */ a("span", { className: "inline-flex items-center gap-1.5", children: [
387
- /* @__PURE__ */ t(ae, { className: "h-3.5 w-3.5" }),
388
- n("ecommerce.instant_digital_delivery")
389
- ] }) : /* @__PURE__ */ a("span", { className: "inline-flex items-center gap-1.5", children: [
390
- /* @__PURE__ */ t(se, { className: "h-3.5 w-3.5" }),
391
- n("ecommerce.free_shipping")
392
- ] }) }),
393
- /* @__PURE__ */ t("div", { className: "flex items-center justify-center gap-2", children: /* @__PURE__ */ a("span", { className: "inline-flex items-center gap-1.5", children: [
394
- /* @__PURE__ */ t(ie, { className: "h-3.5 w-3.5" }),
395
- n("ecommerce.secure_checkout")
396
- ] }) })
397
- ] })
398
- ] })
399
- ] })
400
- ] }) }),
401
- /* @__PURE__ */ t("div", { className: "min-w-0 w-full", ...v ? void 0 : X, children: v || (e.description_json ? /* @__PURE__ */ t("div", { className: "container mx-auto px-4 md:px-6 pb-12 prose prose-neutral dark:prose-invert max-w-none leading-relaxed", children: /* @__PURE__ */ t(ge, { content: e.description_json }) }) : /* @__PURE__ */ t("div", { className: "container mx-auto px-4 md:px-6 pb-12", children: /* @__PURE__ */ t("p", { className: "italic text-sm text-muted-foreground", children: n("ecommerce.no_description") }) })) }),
402
- P && /* @__PURE__ */ t("div", { id: "reviews-section", className: "border-t border-border mt-12 pt-12", children: P })
403
- ] });
404
- };
405
- export {
406
- Ke as ProductDetailsLayout
51
+ var w = ({ visualEditingEnabled: w = !1, descriptionNode: T, reviewsNode: E, canPurchase: ue = !0, purchaseFallbackNode: de }) => {
52
+ let D = re(), { t: O, lang: fe } = y(), k = r(), { activeCurrencyCode: A, currencies: j } = n(), pe = w ? C(D, "title", "plain-text", "Product title") : void 0, me = w ? C(D, "short_description", "plain-text", "Short description") : void 0, M = w ? C(D, "description_json", "tiptap", "Product description") : void 0, N = (e, t, n) => {
53
+ let r = O(e, n);
54
+ return r === e ? t : r;
55
+ }, P = D.images && D.images.length > 0 ? D.images : D.image_url ? [{
56
+ url: D.image_url,
57
+ alt: D.title
58
+ }] : [], F = D.custom_props?.provider === "freemius" || e(D), I = i(D, O), L = !F && !!(D.has_variants && D.attributes?.length && D.variants?.length), R = D.attributes || [], z = D.variants || [], [B, V] = _(() => o(R, z)), [H, U] = _(1);
59
+ h(() => {
60
+ U(1);
61
+ }, [D.id]), h(() => {
62
+ L && V(o(R, z));
63
+ }, [
64
+ R,
65
+ L,
66
+ D.id,
67
+ z
68
+ ]);
69
+ let W = g(() => L ? l(R, z, B) : B, [
70
+ R,
71
+ L,
72
+ B,
73
+ z
74
+ ]);
75
+ h(() => {
76
+ JSON.stringify(W) !== JSON.stringify(B) && V(W);
77
+ }, [W, B]);
78
+ let G = g(() => L ? s(z, W) : null, [
79
+ L,
80
+ W,
81
+ z
82
+ ]), K = t({
83
+ prices: D.prices,
84
+ salePrices: D.sale_prices,
85
+ fallbackPrice: D.price,
86
+ fallbackSalePrice: D.sale_price,
87
+ saleStartAt: D.sale_start_at,
88
+ saleEndAt: D.sale_end_at,
89
+ scheduledPrice: D.scheduled_price,
90
+ scheduledPrices: D.scheduled_prices,
91
+ scheduledPriceAt: D.scheduled_price_at,
92
+ currencyCode: A,
93
+ currencies: j
94
+ }), q = L && G ? t({
95
+ prices: G.prices,
96
+ salePrices: G.sale_prices,
97
+ fallbackPrice: G.price,
98
+ fallbackSalePrice: G.sale_price,
99
+ saleStartAt: G.sale_start_at,
100
+ saleEndAt: G.sale_end_at,
101
+ scheduledPrice: G.scheduled_price,
102
+ scheduledPrices: G.scheduled_prices,
103
+ scheduledPriceAt: G.scheduled_price_at,
104
+ currencyCode: A,
105
+ currencies: j
106
+ }) : null, J = q?.price ?? K.price, Y = q?.sale_price ?? K.sale_price, X = L ? G?.stock_quantity ?? 0 : D.stock ?? null, Z = X === null || X > 0, Q = X === null ? H : Math.max(1, Math.min(H, Math.max(X, 1))), he = g(() => G?.image_url ? [{
107
+ url: G.image_url,
108
+ alt: `${D.title} ${G.label}`
109
+ }, ...P.filter((e) => e.url !== G.image_url)] : P, [
110
+ P,
111
+ D.title,
112
+ G
113
+ ]), ge = typeof Y == "number" && J > 0 ? Math.round((J - Y) / J * 100) : 0, _e = L && G ? {
114
+ ...D,
115
+ sku: G.sku,
116
+ price: G.price,
117
+ prices: G.prices,
118
+ sale_price: typeof G.sale_price == "number" ? G.sale_price : null,
119
+ sale_prices: G.sale_prices,
120
+ sale_start_at: G.sale_start_at,
121
+ sale_end_at: G.sale_end_at,
122
+ scheduled_price: G.scheduled_price,
123
+ scheduled_prices: G.scheduled_prices,
124
+ scheduled_price_at: G.scheduled_price_at,
125
+ image_url: G.image_url || D.image_url,
126
+ stock: G.stock_quantity,
127
+ variant_id: G.id,
128
+ variant_label: G.label,
129
+ selected_options: G.selected_options,
130
+ currency_code: A
131
+ } : {
132
+ ...D,
133
+ currency_code: A
134
+ }, ve = (e, t) => {
135
+ V((n) => a(R, z, n, e, t));
136
+ }, ye = X === null ? N("ecommerce.in_stock_untracked", "In stock") : N("ecommerce.in_stock", `${X} in stock`, { count: String(X) }), $ = N("ecommerce.out_of_stock", "Out of stock"), be = N("ecommerce.select_options", "Select Options"), xe = N("ecommerce.variant_selection_required", "Select one term from every dropdown to resolve a variation.");
137
+ return /* @__PURE__ */ S("div", {
138
+ className: "w-full animate-in fade-in slide-in-from-bottom-4 duration-700 ease-out",
139
+ children: [
140
+ /* @__PURE__ */ x("div", {
141
+ className: "container mx-auto px-4 md:px-6 py-12",
142
+ children: /* @__PURE__ */ S("div", {
143
+ className: "grid gap-12 lg:grid-cols-[2fr_3fr] items-start",
144
+ children: [/* @__PURE__ */ x("div", {
145
+ className: "w-full max-w-2xl mx-auto lg:max-w-none",
146
+ children: /* @__PURE__ */ x(f, {
147
+ images: he,
148
+ className: "w-full"
149
+ })
150
+ }), /* @__PURE__ */ S("div", {
151
+ className: "flex flex-col gap-4 pb-2 max-w-xl mx-auto lg:mx-0 lg:max-w-none",
152
+ children: [/* @__PURE__ */ x("div", {
153
+ className: "space-y-6",
154
+ children: /* @__PURE__ */ S("div", {
155
+ className: "space-y-4",
156
+ children: [
157
+ /* @__PURE__ */ x("h1", {
158
+ className: "text-3xl sm:text-4xl lg:text-5xl font-extrabold tracking-tight text-foreground leading-[1.1] lg:mt-0",
159
+ ...pe,
160
+ children: D.title
161
+ }),
162
+ /* @__PURE__ */ x("div", {
163
+ className: "flex items-center gap-2 mt-2",
164
+ children: /* @__PURE__ */ S("a", {
165
+ href: "#reviews-section",
166
+ className: "flex items-center gap-1.5 group hover:opacity-85 transition-opacity",
167
+ children: [/* @__PURE__ */ x("div", {
168
+ className: "flex items-center text-amber-500",
169
+ children: Array.from({ length: 5 }).map((e, t) => /* @__PURE__ */ x("svg", {
170
+ className: v("h-4 w-4 fill-current", t < Math.round(D.average_rating || 0) ? "text-amber-500" : "text-slate-300 dark:text-slate-700"),
171
+ viewBox: "0 0 20 20",
172
+ fill: "currentColor",
173
+ children: /* @__PURE__ */ x("path", { d: "M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" })
174
+ }, t))
175
+ }), D.total_reviews && D.total_reviews > 0 ? /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x("span", {
176
+ className: "text-sm font-semibold text-slate-700 dark:text-slate-300",
177
+ children: D.average_rating?.toFixed(1)
178
+ }), /* @__PURE__ */ S("span", {
179
+ className: "text-sm text-muted-foreground underline decoration-dotted group-hover:text-primary",
180
+ children: [
181
+ "(",
182
+ D.total_reviews === 1 ? O("reviews.review_count_one", { count: D.total_reviews }) : O("reviews.review_count_other", { count: D.total_reviews }),
183
+ ")"
184
+ ]
185
+ })] }) : /* @__PURE__ */ x("span", {
186
+ className: "text-xs text-muted-foreground group-hover:text-primary underline decoration-dotted",
187
+ children: O("reviews.be_the_first")
188
+ })]
189
+ })
190
+ }),
191
+ D.categories && D.categories.length > 0 && /* @__PURE__ */ x("div", {
192
+ className: "flex flex-wrap items-center gap-1.5 text-xs font-bold uppercase tracking-widest text-amber-600 dark:text-amber-400",
193
+ children: D.categories.map((e, t) => {
194
+ let n = u(e.name, e.name_translations, fe);
195
+ return /* @__PURE__ */ S(m.Fragment, { children: [t > 0 && /* @__PURE__ */ x("span", {
196
+ className: "text-muted-foreground/30",
197
+ children: "•"
198
+ }), /* @__PURE__ */ x("span", { children: n })] }, e.id);
199
+ })
200
+ }),
201
+ /* @__PURE__ */ x("div", {
202
+ className: "prose prose-neutral dark:prose-invert max-w-none text-muted-foreground leading-relaxed text-left",
203
+ ...me,
204
+ children: D.short_description ? /* @__PURE__ */ x(te, {
205
+ value: D.short_description,
206
+ className: "text-lg mb-4 leading-relaxed"
207
+ }) : w ? /* @__PURE__ */ x("p", {
208
+ className: "text-lg mb-4 italic text-muted-foreground",
209
+ children: "Add a short product description."
210
+ }) : null
211
+ }),
212
+ /* @__PURE__ */ S("div", {
213
+ className: "flex items-center gap-3",
214
+ children: [
215
+ typeof Y == "number" && /* @__PURE__ */ x(p, {
216
+ variant: "destructive",
217
+ className: "px-2.5 py-1 text-xs font-bold uppercase tracking-wide animate-pulse shadow-sm",
218
+ children: O("ecommerce.sale_badge", { percent: String(ge) })
219
+ }),
220
+ !F && X !== null && X > 0 && X < 10 && /* @__PURE__ */ x(p, {
221
+ variant: "outline",
222
+ className: "text-amber-600 border-amber-200 bg-amber-50",
223
+ children: O("ecommerce.low_stock", { count: String(X) })
224
+ }),
225
+ I && /* @__PURE__ */ x(p, {
226
+ variant: "secondary",
227
+ className: "border border-emerald-200 bg-emerald-50 text-emerald-800",
228
+ children: I.label
229
+ })
230
+ ]
231
+ })
232
+ ]
233
+ })
234
+ }), /* @__PURE__ */ S("div", {
235
+ className: "p-5 rounded-2xl bg-card border border-border/80 shadow-md space-y-4",
236
+ children: [
237
+ ue ? F ? /* @__PURE__ */ x(ne, { product: D }) : /* @__PURE__ */ S("div", {
238
+ className: "space-y-3.5",
239
+ children: [
240
+ /* @__PURE__ */ S("div", {
241
+ className: "flex items-center justify-between gap-4",
242
+ children: [/* @__PURE__ */ S("div", {
243
+ className: "space-y-1",
244
+ children: [/* @__PURE__ */ x("span", {
245
+ className: "text-[10px] font-bold text-muted-foreground uppercase tracking-widest",
246
+ children: N("ecommerce.price", "Price")
247
+ }), /* @__PURE__ */ S("div", {
248
+ className: "flex items-baseline gap-2.5",
249
+ children: [/* @__PURE__ */ x("span", {
250
+ className: "text-3xl font-extrabold text-foreground",
251
+ children: k(Y ?? J, A)
252
+ }), typeof Y == "number" && /* @__PURE__ */ x("span", {
253
+ className: "text-lg text-muted-foreground line-through decoration-destructive/20 decoration-1",
254
+ children: k(J, A)
255
+ })]
256
+ })]
257
+ }), !F && (G || !L) && /* @__PURE__ */ S("div", {
258
+ className: "text-right space-y-1",
259
+ children: [/* @__PURE__ */ S("span", {
260
+ className: "text-[10px] font-bold text-muted-foreground uppercase tracking-widest block",
261
+ children: [!L && D.sku && /* @__PURE__ */ S("span", {
262
+ className: "mr-2 font-normal lowercase normal-case text-muted-foreground/70",
263
+ children: [
264
+ N("ecommerce.sku", "SKU"),
265
+ ": ",
266
+ D.sku
267
+ ]
268
+ }), N("ecommerce.status", "Status")]
269
+ }), /* @__PURE__ */ x("div", {
270
+ className: Z ? "text-emerald-600 dark:text-emerald-400 font-semibold text-sm" : "text-destructive font-semibold text-sm",
271
+ children: Z ? ye : $
272
+ })]
273
+ })]
274
+ }),
275
+ L && /* @__PURE__ */ x("div", {
276
+ className: "space-y-3",
277
+ children: /* @__PURE__ */ x("div", {
278
+ className: "grid gap-3 sm:grid-cols-2",
279
+ children: R.map((e, t) => {
280
+ let n = c(z, e.id, {});
281
+ return /* @__PURE__ */ S("div", {
282
+ className: "space-y-1",
283
+ children: [/* @__PURE__ */ S("div", {
284
+ className: "flex items-center justify-between",
285
+ children: [/* @__PURE__ */ x(ce, {
286
+ htmlFor: `attribute-${e.id}`,
287
+ className: "text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",
288
+ children: e.name
289
+ }), t === 0 && G?.sku && /* @__PURE__ */ x("span", {
290
+ className: "text-[10px] text-muted-foreground font-mono",
291
+ children: G.sku
292
+ })]
293
+ }), /* @__PURE__ */ x("select", {
294
+ id: `attribute-${e.id}`,
295
+ className: "flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring",
296
+ value: W[e.id] || "",
297
+ onChange: (t) => ve(e.id, t.target.value),
298
+ children: e.terms.map((e) => /* @__PURE__ */ x("option", {
299
+ value: e.id,
300
+ disabled: !n.has(e.id),
301
+ children: e.value
302
+ }, e.id))
303
+ })]
304
+ }, e.id);
305
+ })
306
+ })
307
+ }),
308
+ L && !G && /* @__PURE__ */ x("p", {
309
+ className: "text-xs text-muted-foreground italic pt-1",
310
+ children: xe
311
+ }),
312
+ /* @__PURE__ */ S("div", {
313
+ className: "flex items-center gap-3 pt-1",
314
+ children: [!F && Z && /* @__PURE__ */ S("div", {
315
+ role: "group",
316
+ "aria-label": N("ecommerce.quantity", "Quantity"),
317
+ className: "flex items-center border rounded-lg h-12 bg-background border-input select-none",
318
+ children: [
319
+ /* @__PURE__ */ x("button", {
320
+ type: "button",
321
+ onClick: () => U(Math.max(1, Q - 1)),
322
+ "aria-label": N("ecommerce.decrease_quantity", "Decrease quantity"),
323
+ className: "px-3 h-full flex items-center justify-center rounded-l-lg text-muted-foreground hover:text-foreground active:scale-95 transition-colors text-lg font-medium focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",
324
+ disabled: Q <= 1,
325
+ children: /* @__PURE__ */ x("span", {
326
+ "aria-hidden": "true",
327
+ children: "-"
328
+ })
329
+ }),
330
+ /* @__PURE__ */ x("span", {
331
+ "aria-live": "polite",
332
+ "aria-atomic": "true",
333
+ className: "w-8 text-center text-sm font-semibold tabular-nums",
334
+ children: Q
335
+ }),
336
+ /* @__PURE__ */ x("button", {
337
+ type: "button",
338
+ onClick: () => U(X !== null && Q >= X ? Q : Q + 1),
339
+ "aria-label": N("ecommerce.increase_quantity", "Increase quantity"),
340
+ className: "px-3 h-full flex items-center justify-center rounded-r-lg text-muted-foreground hover:text-foreground active:scale-95 transition-colors text-lg font-medium focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",
341
+ disabled: X !== null && Q >= X,
342
+ children: /* @__PURE__ */ x("span", {
343
+ "aria-hidden": "true",
344
+ children: "+"
345
+ })
346
+ })
347
+ ]
348
+ }), L && (!G || !Z) ? /* @__PURE__ */ x(ie, {
349
+ disabled: !0,
350
+ className: "flex-1 h-12 text-md font-bold shadow-md",
351
+ children: G ? $ : be
352
+ }) : /* @__PURE__ */ x(d, {
353
+ product: _e,
354
+ quantity: Q,
355
+ className: "flex-1 h-12 text-base font-bold shadow-md transition-shadow hover:shadow-lg active:scale-[0.98]"
356
+ })]
357
+ })
358
+ ]
359
+ }) : de,
360
+ /* @__PURE__ */ x(le, { className: "opacity-60 my-0.5" }),
361
+ /* @__PURE__ */ S("div", {
362
+ className: "grid grid-cols-2 gap-4 text-center text-[11px] font-medium text-muted-foreground pt-1",
363
+ children: [/* @__PURE__ */ x("div", {
364
+ className: "flex items-center justify-center gap-2",
365
+ children: F ? /* @__PURE__ */ S("span", {
366
+ className: "inline-flex items-center gap-1.5",
367
+ children: [/* @__PURE__ */ x(ae, { className: "h-3.5 w-3.5" }), O("ecommerce.instant_digital_delivery")]
368
+ }) : /* @__PURE__ */ S("span", {
369
+ className: "inline-flex items-center gap-1.5",
370
+ children: [/* @__PURE__ */ x(oe, { className: "h-3.5 w-3.5" }), O("ecommerce.free_shipping")]
371
+ })
372
+ }), /* @__PURE__ */ x("div", {
373
+ className: "flex items-center justify-center gap-2",
374
+ children: /* @__PURE__ */ S("span", {
375
+ className: "inline-flex items-center gap-1.5",
376
+ children: [/* @__PURE__ */ x(se, { className: "h-3.5 w-3.5" }), O("ecommerce.secure_checkout")]
377
+ })
378
+ })]
379
+ })
380
+ ]
381
+ })]
382
+ })]
383
+ })
384
+ }),
385
+ /* @__PURE__ */ x("div", {
386
+ className: "min-w-0 w-full",
387
+ ...T ? void 0 : M,
388
+ children: T || (D.description_json ? /* @__PURE__ */ x("div", {
389
+ className: "container mx-auto px-4 md:px-6 pb-12 prose prose-neutral dark:prose-invert max-w-none leading-relaxed",
390
+ children: /* @__PURE__ */ x(ee, { content: D.description_json })
391
+ }) : /* @__PURE__ */ x("div", {
392
+ className: "container mx-auto px-4 md:px-6 pb-12",
393
+ children: /* @__PURE__ */ x("p", {
394
+ className: "italic text-sm text-muted-foreground",
395
+ children: O("ecommerce.no_description")
396
+ })
397
+ }))
398
+ }),
399
+ E && /* @__PURE__ */ x("div", {
400
+ id: "reviews-section",
401
+ className: "border-t border-border mt-12 pt-12",
402
+ children: E
403
+ })
404
+ ]
405
+ });
407
406
  };
407
+ //#endregion
408
+ export { w as ProductDetailsLayout };