@nextblock-cms/ecom 0.8.6 → 0.8.7

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 (277) hide show
  1. package/index.cjs.js +1 -1
  2. package/index.es.js +136 -533
  3. package/lib/CurrencyProvider.cjs.js +1 -0
  4. package/lib/CurrencyProvider.es.js +99 -0
  5. package/lib/cart-store.cjs.js +1 -0
  6. package/{cart-store.es.js → lib/cart-store.es.js} +13 -13
  7. package/lib/components/AccountNavigationMenu.cjs.js +1 -0
  8. package/lib/components/AccountNavigationMenu.es.js +44 -0
  9. package/lib/components/AddToCartButton.cjs.js +1 -0
  10. package/{AddToCartButton-ffE0DhHu.js → lib/components/AddToCartButton.es.js} +14 -13
  11. package/lib/components/Cart.cjs.js +1 -0
  12. package/lib/components/Cart.es.js +148 -0
  13. package/lib/components/CartDrawer.cjs.js +1 -0
  14. package/{components → lib/components}/CartDrawer.es.js +15 -14
  15. package/{components → lib/components}/CartIcon.cjs.js +1 -1
  16. package/{components → lib/components}/CartIcon.es.js +1 -0
  17. package/lib/components/Checkout.cjs.js +1 -0
  18. package/{components → lib/components}/Checkout.es.js +330 -363
  19. package/lib/components/CouponForm.cjs.js +1 -0
  20. package/lib/components/CouponForm.es.js +136 -0
  21. package/lib/components/CurrencySwitcher.cjs.js +1 -0
  22. package/{components → lib/components}/CurrencySwitcher.es.js +5 -4
  23. package/lib/components/CustomerProfileForm.cjs.js +1 -0
  24. package/lib/components/CustomerProfileForm.es.js +355 -0
  25. package/lib/components/FeaturedProduct.cjs.js +1 -0
  26. package/{components → lib/components}/FeaturedProduct.es.js +9 -8
  27. package/lib/components/InvoiceDocument.cjs.js +1 -0
  28. package/lib/components/InvoiceDocument.es.js +196 -0
  29. package/lib/components/InvoiceViewerShell.cjs.js +29 -0
  30. package/lib/components/InvoiceViewerShell.es.js +100 -0
  31. package/lib/components/ProductCard.cjs.js +1 -0
  32. package/lib/components/ProductCard.es.js +119 -0
  33. package/lib/components/ProductDetailsLayout.cjs.js +1 -0
  34. package/lib/components/ProductDetailsLayout.es.js +361 -0
  35. package/lib/components/ProductGallery.cjs.js +1 -0
  36. package/lib/components/ProductGallery.es.js +41 -0
  37. package/lib/components/ProductGrid.cjs.js +1 -0
  38. package/lib/components/ProductGrid.es.js +19 -0
  39. package/lib/components/ShippingEstimator.cjs.js +1 -0
  40. package/lib/components/ShippingEstimator.es.js +125 -0
  41. package/lib/components/SubscriptionSelector.cjs.js +1 -0
  42. package/lib/components/SubscriptionSelector.es.js +140 -0
  43. package/lib/countries.cjs.js +1 -0
  44. package/lib/countries.es.js +77 -0
  45. package/lib/coupon-server.cjs.js +1 -0
  46. package/{coupon-server-DUKVtyYs.js → lib/coupon-server.es.js} +68 -82
  47. package/lib/coupons.cjs.js +1 -0
  48. package/lib/coupons.es.js +17 -0
  49. package/lib/currency-store.cjs.js +1 -0
  50. package/lib/currency-store.es.js +27 -0
  51. package/lib/currency-sync.cjs.js +1 -0
  52. package/lib/currency-sync.es.js +180 -0
  53. package/lib/customer-addresses.cjs.js +1 -0
  54. package/lib/customer-addresses.es.js +116 -0
  55. package/lib/customer-orders.cjs.js +1 -0
  56. package/lib/customer-orders.es.js +45 -0
  57. package/lib/customer.cjs.js +1 -0
  58. package/{customer-C3xccjUg.js → lib/customer.es.js} +15 -14
  59. package/lib/export-helpers.cjs.js +1 -0
  60. package/lib/export-helpers.es.js +56 -0
  61. package/lib/factory.cjs.js +1 -0
  62. package/lib/factory.es.js +8 -0
  63. package/lib/freemius-coupons.cjs.js +1 -0
  64. package/lib/freemius-coupons.es.js +272 -0
  65. package/lib/freemius-order-sync.cjs.js +1 -0
  66. package/lib/freemius-order-sync.es.js +284 -0
  67. package/lib/inventory-settings.cjs.js +1 -0
  68. package/lib/inventory-settings.es.js +86 -0
  69. package/lib/invoice-server.cjs.js +33 -0
  70. package/lib/invoice-server.es.js +141 -0
  71. package/lib/invoice-ui.cjs.js +1 -0
  72. package/lib/invoice-ui.es.js +71 -0
  73. package/lib/invoice.cjs.js +1 -0
  74. package/lib/invoice.es.js +102 -0
  75. package/lib/order-inventory.cjs.js +61 -0
  76. package/lib/order-inventory.es.js +128 -0
  77. package/lib/order-tax-details.cjs.js +1 -0
  78. package/lib/order-tax-details.es.js +164 -0
  79. package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -0
  80. package/lib/pages/cms/coupons/CouponEditorForm.es.js +189 -0
  81. package/lib/pages/cms/coupons/CouponsPage.cjs.js +5 -0
  82. package/lib/pages/cms/coupons/CouponsPage.es.js +171 -0
  83. package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -0
  84. package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -0
  85. package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -0
  86. package/lib/pages/cms/coupons/EditCouponPage.es.js +48 -0
  87. package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -0
  88. package/lib/pages/cms/coupons/ProductScopePicker.es.js +120 -0
  89. package/lib/pages/cms/coupons/actions.cjs.js +1 -0
  90. package/lib/pages/cms/coupons/actions.es.js +128 -0
  91. package/lib/pages/cms/coupons/product-options.cjs.js +1 -0
  92. package/lib/pages/cms/coupons/product-options.es.js +27 -0
  93. package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -0
  94. package/lib/pages/cms/orders/ExportReportsDialog.es.js +130 -0
  95. package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -0
  96. package/lib/pages/cms/orders/OrderDetailPage.es.js +137 -0
  97. package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -0
  98. package/lib/pages/cms/orders/OrderPrintButton.es.js +22 -0
  99. package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -0
  100. package/lib/pages/cms/orders/OrderStatusForm.es.js +71 -0
  101. package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -0
  102. package/lib/pages/cms/orders/OrdersPage.es.js +104 -0
  103. package/lib/pages/cms/orders/actions.cjs.js +7 -0
  104. package/lib/pages/cms/orders/actions.es.js +71 -0
  105. package/lib/pages/cms/orders/export-actions.cjs.js +1 -0
  106. package/lib/pages/cms/orders/export-actions.es.js +27 -0
  107. package/lib/pages/cms/orders/server-actions.cjs.js +1 -0
  108. package/lib/pages/cms/orders/server-actions.es.js +55 -0
  109. package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -0
  110. package/lib/pages/cms/payments/PaymentsClient.es.js +188 -0
  111. package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -0
  112. package/lib/pages/cms/payments/PaymentsPage.es.js +29 -0
  113. package/lib/pages/cms/payments/actions.cjs.js +1 -0
  114. package/lib/pages/cms/payments/actions.es.js +23 -0
  115. package/lib/pages/cms/payments/queries.cjs.js +1 -0
  116. package/lib/pages/cms/payments/queries.es.js +30 -0
  117. package/lib/pages/cms/products/ProductsPage.cjs.js +1 -0
  118. package/lib/pages/cms/products/ProductsPage.es.js +46 -0
  119. package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -0
  120. package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +156 -0
  121. package/lib/pages/cms/products/actions.cjs.js +44 -0
  122. package/lib/pages/cms/products/actions.es.js +175 -0
  123. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -0
  124. package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +48 -0
  125. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -0
  126. package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +291 -0
  127. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -0
  128. package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +36 -0
  129. package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -0
  130. package/lib/pages/cms/products/categories/components/CategoryManager.es.js +263 -0
  131. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -0
  132. package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +114 -0
  133. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -0
  134. package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +107 -0
  135. package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -0
  136. package/lib/pages/cms/products/components/DeleteProductButton.es.js +48 -0
  137. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -0
  138. package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +86 -0
  139. package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -0
  140. package/lib/pages/cms/products/components/ProductCategorySelector.es.js +160 -0
  141. package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -0
  142. package/lib/pages/cms/products/components/ProductForm.es.js +702 -0
  143. package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -0
  144. package/lib/pages/cms/products/components/ProductMediaManager.es.js +104 -0
  145. package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -0
  146. package/lib/pages/cms/products/components/ProductsBulkTable.es.js +228 -0
  147. package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -0
  148. package/lib/pages/cms/products/components/SaleScheduleFields.es.js +137 -0
  149. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -0
  150. package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +36 -0
  151. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +1 -0
  152. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +40 -0
  153. package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -0
  154. package/lib/pages/cms/products/components/VariationsEditor.es.js +408 -0
  155. package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -0
  156. package/lib/pages/cms/products/inventory/InventoryPage.es.js +16 -0
  157. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -0
  158. package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +214 -0
  159. package/lib/pages/cms/products/inventory/actions.cjs.js +3 -0
  160. package/lib/pages/cms/products/inventory/actions.es.js +95 -0
  161. package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -0
  162. package/lib/pages/cms/products/new/NewProductPage.es.js +76 -0
  163. package/lib/pages/cms/products/product-price-sync.cjs.js +1 -0
  164. package/lib/pages/cms/products/product-price-sync.es.js +98 -0
  165. package/lib/pages/cms/products/server-actions.cjs.js +1 -0
  166. package/lib/pages/cms/products/server-actions.es.js +193 -0
  167. package/lib/pages/cms/shipping/ShippingPage.cjs.js +5 -0
  168. package/lib/pages/cms/shipping/ShippingPage.es.js +211 -0
  169. package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -0
  170. package/lib/pages/cms/shipping/components/RateForm.es.js +441 -0
  171. package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -0
  172. package/lib/pages/cms/shipping/components/ZoneForm.es.js +228 -0
  173. package/lib/pages/cms/shipping/server-actions.cjs.js +1 -0
  174. package/lib/pages/cms/shipping/server-actions.es.js +159 -0
  175. package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -0
  176. package/lib/pages/cms/taxes/TaxesPage.es.js +172 -0
  177. package/lib/pages/cms/taxes/actions.cjs.js +1 -0
  178. package/lib/pages/cms/taxes/actions.es.js +57 -0
  179. package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -0
  180. package/lib/pages/cms/taxes/components/TaxRateForm.es.js +100 -0
  181. package/lib/product-actions.cjs.js +237 -0
  182. package/lib/product-actions.es.js +524 -0
  183. package/lib/product-context.cjs.js +1 -0
  184. package/lib/product-context.es.js +16 -0
  185. package/lib/product-schema.cjs.js +1 -0
  186. package/lib/product-schema.es.js +134 -0
  187. package/lib/providers/freemius.cjs.js +5 -0
  188. package/lib/providers/freemius.es.js +538 -0
  189. package/lib/providers/stripe.cjs.js +1 -0
  190. package/lib/providers/stripe.es.js +473 -0
  191. package/lib/server-actions/coupon-actions.cjs.js +1 -0
  192. package/lib/server-actions/coupon-actions.es.js +23 -0
  193. package/lib/server-actions/customer-actions.cjs.js +1 -0
  194. package/lib/server-actions/customer-actions.es.js +30 -0
  195. package/lib/server-actions/product-actions.cjs.js +1 -0
  196. package/{server-actions → lib/server-actions}/product-actions.es.js +5 -4
  197. package/lib/server-actions/shipping-actions.cjs.js +1 -0
  198. package/{shipping-actions-BnHjlo2q.js → lib/server-actions/shipping-actions.es.js} +9 -7
  199. package/lib/server-actions/tax-actions.cjs.js +1 -0
  200. package/lib/server-actions/tax-actions.es.js +40 -0
  201. package/lib/shared-inventory.cjs.js +15 -0
  202. package/lib/shared-inventory.es.js +171 -0
  203. package/lib/shipping/resolver.cjs.js +7 -0
  204. package/lib/shipping/resolver.es.js +62 -0
  205. package/lib/shipping-rate-currency.cjs.js +1 -0
  206. package/lib/shipping-rate-currency.es.js +72 -0
  207. package/lib/states.cjs.js +1 -0
  208. package/{states-DlHJezQ1.js → lib/states.es.js} +27 -100
  209. package/lib/stripe/checkout.cjs.js +1 -0
  210. package/lib/stripe/checkout.es.js +182 -0
  211. package/lib/stripe/client.cjs.js +1 -0
  212. package/lib/stripe/client.es.js +7 -0
  213. package/lib/stripe/order-sync.cjs.js +1 -0
  214. package/lib/stripe/order-sync.es.js +130 -0
  215. package/lib/stripe/webhooks.cjs.js +1 -0
  216. package/lib/stripe/webhooks.es.js +30 -0
  217. package/lib/tax-calculation.cjs.js +1 -0
  218. package/lib/tax-calculation.es.js +101 -0
  219. package/lib/trials.cjs.js +1 -0
  220. package/{trials-RDcRAZKx.js → lib/trials.es.js} +9 -9
  221. package/{use-cart.es.js → lib/use-cart.es.js} +1 -0
  222. package/lib/zod-config.cjs.js +1 -0
  223. package/lib/zod-config.es.js +6 -0
  224. package/package.json +4 -4
  225. package/server.cjs.js +1 -110
  226. package/server.es.js +178 -6052
  227. package/AddToCartButton-DsSEH9yp.cjs +0 -1
  228. package/CouponForm-BI_5SBHQ.js +0 -152
  229. package/CouponForm-D_uu2bLP.cjs +0 -1
  230. package/CurrencyProvider-Cg-Q6ucj.cjs +0 -1
  231. package/CurrencyProvider-OzlRN96V.js +0 -120
  232. package/CurrencyProvider.cjs.js +0 -1
  233. package/CurrencyProvider.es.js +0 -10
  234. package/ProductDetailsLayout-BxJH_BxR.cjs +0 -1
  235. package/ProductDetailsLayout-Dg8dRTYp.js +0 -530
  236. package/ProductGrid-BdL7iglO.cjs +0 -1
  237. package/ProductGrid-D3AWM8sr.js +0 -130
  238. package/actions-AHmBrS5e.cjs +0 -48
  239. package/actions-j5fuSZX-.js +0 -820
  240. package/cart-store.cjs.js +0 -1
  241. package/components/Cart.cjs.js +0 -1
  242. package/components/Cart.es.js +0 -259
  243. package/components/CartDrawer.cjs.js +0 -1
  244. package/components/Checkout.cjs.js +0 -1
  245. package/components/CurrencySwitcher.cjs.js +0 -1
  246. package/components/FeaturedProduct.cjs.js +0 -1
  247. package/components/ProductDetailsLayout.cjs.js +0 -1
  248. package/components/ProductDetailsLayout.es.js +0 -19
  249. package/components/ProductGrid.cjs.js +0 -1
  250. package/components/ProductGrid.es.js +0 -6
  251. package/coupon-server-C9ySm3I5.cjs +0 -1
  252. package/customer-C-UPvrYN.cjs +0 -1
  253. package/invoice-ui-CAnJPu6n.cjs +0 -29
  254. package/invoice-ui-DtpbTJE1.js +0 -2886
  255. package/product-actions-CONBF8i6.cjs +0 -251
  256. package/product-actions-DjlIWCMH.js +0 -691
  257. package/resolver-Fz_FKsfX.cjs +0 -7
  258. package/resolver-cfrCaHpE.js +0 -128
  259. package/server-actions/product-actions.cjs.js +0 -1
  260. package/shipping-actions-D6zt20gg.cjs +0 -1
  261. package/states-CWYRxV4B.cjs +0 -1
  262. package/tax-calculation-Dab89aHd.js +0 -181
  263. package/tax-calculation-MkDKOEkL.cjs +0 -1
  264. package/trials-DvZaOtNy.cjs +0 -1
  265. /package/{components → lib/components}/SimpleTiptapRenderer.cjs.js +0 -0
  266. /package/{components → lib/components}/SimpleTiptapRenderer.es.js +0 -0
  267. /package/{currency-constants.cjs.js → lib/currency-constants.cjs.js} +0 -0
  268. /package/{currency-constants.es.js → lib/currency-constants.es.js} +0 -0
  269. /package/{currency-rest-client-uolJxUkL.cjs → lib/currency-rest-client.cjs.js} +0 -0
  270. /package/{currency-rest-client-CwoqdgAP.js → lib/currency-rest-client.es.js} +0 -0
  271. /package/{currency.cjs.js → lib/currency.cjs.js} +0 -0
  272. /package/{currency.es.js → lib/currency.es.js} +0 -0
  273. /package/{types.cjs.js → lib/types.cjs.js} +0 -0
  274. /package/{types.es.js → lib/types.es.js} +0 -0
  275. /package/{use-cart.cjs.js → lib/use-cart.cjs.js} +0 -0
  276. /package/{variation-utils.cjs.js → lib/variation-utils.cjs.js} +0 -0
  277. /package/{variation-utils.es.js → lib/variation-utils.es.js} +0 -0
@@ -1,530 +0,0 @@
1
- import { jsx as t, jsxs as n } from "react/jsx-runtime";
2
- import le, { useState as T, useEffect as j, createContext as oe, useContext as ce, useMemo as $ } from "react";
3
- import { ShoppingCart as de, Download as me, Package as ue, ShieldCheck as pe } from "lucide-react";
4
- import { Badge as M } from "@nextblock-cms/ui/badge";
5
- import { Button as H } from "@nextblock-cms/ui/button";
6
- import { Label as fe } from "@nextblock-cms/ui/label";
7
- import { Separator as ge } from "@nextblock-cms/ui/separator";
8
- import { cn as q, useTranslations as Q, majorUnitAmountToMinor as E, formatPrice as D } from "@nextblock-cms/utils";
9
- import { A as he } from "./AddToCartButton-ffE0DhHu.js";
10
- import { Skeleton as G } from "@nextblock-cms/ui/Skeleton";
11
- import { useCart as xe } from "./use-cart.es.js";
12
- import { toast as K } from "sonner";
13
- import { g as _e } from "./actions-j5fuSZX-.js";
14
- import { u as Y } from "./CurrencyProvider-OzlRN96V.js";
15
- import { convertMinorUnitAmount as U, resolveEffectivePriceForCurrency as X } from "./currency.es.js";
16
- import { d as Z } from "./trials-RDcRAZKx.js";
17
- import { SimpleTiptapRenderer as ve } from "./components/SimpleTiptapRenderer.es.js";
18
- import { chooseInitialVariantSelections as W, normalizeSelectionsToAvailableVariants as z, findMatchingVariant as be, resolveTranslatedText as ye, getAvailableTermIdsForAttribute as Ne } from "./variation-utils.es.js";
19
- import { isDigitalProduct as we } from "./types.es.js";
20
- const Ce = ({ images: r = [], className: u }) => {
21
- const [e, c] = T(0);
22
- return j(() => {
23
- c(0);
24
- }, [r]), r.length ? /* @__PURE__ */ n("div", { className: q("flex flex-col gap-4", u), children: [
25
- /* @__PURE__ */ t("div", { className: "relative aspect-square w-full overflow-hidden rounded-lg border bg-white", children: /* @__PURE__ */ t(
26
- "img",
27
- {
28
- src: r[e].url,
29
- alt: r[e].alt,
30
- className: "h-full w-full object-cover object-center"
31
- }
32
- ) }),
33
- r.length > 1 && /* @__PURE__ */ t("div", { className: "flex gap-4 overflow-x-auto pb-2", children: r.map((f, o) => /* @__PURE__ */ t(
34
- "button",
35
- {
36
- onClick: () => c(o),
37
- className: q(
38
- "relative aspect-square w-20 flex-shrink-0 overflow-hidden rounded-md border",
39
- e === o ? "ring-2 ring-primary" : "ring-1 ring-transparent hover:ring-primary/50"
40
- ),
41
- children: /* @__PURE__ */ t(
42
- "img",
43
- {
44
- src: f.url,
45
- alt: f.alt,
46
- className: "h-full w-full object-cover object-center"
47
- }
48
- )
49
- },
50
- o
51
- )) })
52
- ] }) : /* @__PURE__ */ t("div", { className: q("relative aspect-square w-full overflow-hidden rounded-lg bg-secondary", u), children: /* @__PURE__ */ t("div", { className: "flex h-full items-center justify-center text-muted-foreground", children: "No Image" }) });
53
- }, ke = ({ product: r }) => {
54
- const u = xe((d) => d), { t: e } = Q(), { activeCurrencyCode: c, currencies: f, defaultCurrency: o } = Y(), [I, x] = T([]), [S, L] = T(!0), [l, _] = T("annual");
55
- if (j(() => {
56
- async function d() {
57
- try {
58
- if (!r.id) return;
59
- const a = await _e(r.id);
60
- x(a);
61
- } catch (a) {
62
- console.error("Failed to load pricing:", a);
63
- } finally {
64
- L(!1);
65
- }
66
- }
67
- d();
68
- }, [r.id]), !u)
69
- return /* @__PURE__ */ t(G, { className: "h-14 w-full" });
70
- const { addItem: y } = u, N = I[0], i = N?.pricing?.[0], v = () => {
71
- let d = r.price, a = r.freemius_plan_id;
72
- i && (l === "monthly" && i.monthly_price != null && (d = E(i.monthly_price, o.code)), l === "annual" && i.annual_price != null && (d = E(i.annual_price, o.code)), l === "lifetime" && i.lifetime_price != null && (d = E(i.lifetime_price, o.code)));
73
- const A = f.reduce((m, O) => (m[O.code] = U({
74
- amount: d,
75
- fromCurrencyCode: o.code,
76
- toCurrencyCode: O.code,
77
- currencies: f,
78
- applyRounding: !0
79
- }), m), {}), V = A[c] ?? d;
80
- N && N.id && (a = N.id);
81
- const { success: k, error: P } = y({
82
- id: r.id,
83
- product_id: r.id,
84
- title: r.title,
85
- price: V,
86
- prices: A,
87
- image_url: r.image_url,
88
- slug: r.slug,
89
- sku: r.sku,
90
- language_id: r.language_id,
91
- translation_group_id: r.translation_group_id,
92
- product_type: "digital",
93
- payment_provider: "freemius",
94
- provider: "freemius",
95
- billing_cycle: l,
96
- freemius_product_id: r.freemius_product_id,
97
- freemius_plan_id: a,
98
- // Overwrite if we got a real plan id
99
- trial_period_days: r.trial_period_days ?? 0,
100
- trial_requires_payment_method: r.trial_requires_payment_method ?? !1,
101
- is_taxable: r.is_taxable,
102
- currency_code: c
103
- });
104
- k ? K.success(e("ecommerce.added_to_cart_success", { item: r.title })) : K.error(P || e("ecommerce.added_to_cart_error"));
105
- };
106
- if (S)
107
- return /* @__PURE__ */ t(G, { className: "h-32 w-full" });
108
- if (!N || !i)
109
- return /* @__PURE__ */ t("div", { className: "p-4 border border-dashed rounded-lg text-center text-muted-foreground", children: e("ecommerce.pricing_unavailable") });
110
- const g = i.monthly_price != null, w = i.annual_price != null, R = i.lifetime_price != null;
111
- l === "annual" && !w && (g ? _("monthly") : R && _("lifetime"));
112
- const h = Z(r);
113
- let C = r.price;
114
- return l === "monthly" && i.monthly_price != null && (C = U({
115
- amount: E(i.monthly_price, o.code),
116
- fromCurrencyCode: o.code,
117
- toCurrencyCode: c,
118
- currencies: f,
119
- applyRounding: !0
120
- })), l === "annual" && i.annual_price != null && (C = U({
121
- amount: E(i.annual_price, o.code),
122
- fromCurrencyCode: o.code,
123
- toCurrencyCode: c,
124
- currencies: f,
125
- applyRounding: !0
126
- })), l === "lifetime" && i.lifetime_price != null && (C = U({
127
- amount: E(i.lifetime_price, o.code),
128
- fromCurrencyCode: o.code,
129
- toCurrencyCode: c,
130
- currencies: f,
131
- applyRounding: !0
132
- })), /* @__PURE__ */ n("div", { className: "flex flex-col gap-4", children: [
133
- /* @__PURE__ */ n("div", { className: "flex bg-secondary/35 p-1 rounded-lg w-full max-w-sm mx-auto shadow-inner", children: [
134
- g && /* @__PURE__ */ t(
135
- "button",
136
- {
137
- onClick: () => _("monthly"),
138
- className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-all ${l === "monthly" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
139
- children: e("ecommerce.monthly")
140
- }
141
- ),
142
- w && /* @__PURE__ */ t(
143
- "button",
144
- {
145
- onClick: () => _("annual"),
146
- className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-all ${l === "annual" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
147
- children: e("ecommerce.annual")
148
- }
149
- ),
150
- R && /* @__PURE__ */ t(
151
- "button",
152
- {
153
- onClick: () => _("lifetime"),
154
- className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-all ${l === "lifetime" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
155
- children: e("ecommerce.lifetime")
156
- }
157
- )
158
- ] }),
159
- /* @__PURE__ */ n("div", { className: "text-center", children: [
160
- /* @__PURE__ */ t("span", { className: "text-3xl font-extrabold text-foreground", children: D(C, c) }),
161
- l !== "lifetime" && /* @__PURE__ */ n("span", { className: "text-muted-foreground text-sm ml-1.5", children: [
162
- "/ ",
163
- e(l === "annual" ? "ecommerce.year" : "ecommerce.month")
164
- ] }),
165
- h && /* @__PURE__ */ n("div", { className: "mt-1 text-xs font-medium text-emerald-600 dark:text-emerald-400", children: [
166
- h.label,
167
- /* @__PURE__ */ t("span", { className: "mx-2 text-muted-foreground/50", children: "|" }),
168
- /* @__PURE__ */ t("span", { className: "text-muted-foreground", children: h.paymentRequirementLabel })
169
- ] })
170
- ] }),
171
- /* @__PURE__ */ n(H, { onClick: v, className: "w-full h-12 text-md font-bold shadow-md transition-all hover:shadow-lg active:scale-[0.98]", children: [
172
- /* @__PURE__ */ t(de, { className: "mr-2 h-4 w-4" }),
173
- h?.label ? `Start ${h.label}` : e("ecommerce.get_license")
174
- ] })
175
- ] });
176
- }, ee = oe(void 0), Ke = ({
177
- product: r,
178
- children: u
179
- }) => /* @__PURE__ */ t(ee.Provider, { value: { product: r }, children: u }), Pe = () => {
180
- const r = ce(ee);
181
- if (!r)
182
- throw new Error("useProduct must be used within a ProductProvider. Ensure the component is wrapped in a ProductProvider.");
183
- return r.product;
184
- };
185
- function B(r, u, e, c) {
186
- const f = {
187
- kind: "product-field",
188
- field: u,
189
- input: e,
190
- label: c
191
- }, 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";
192
- let x = (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(/\/+$/, "");
193
- try {
194
- (x.startsWith("http://") || x.startsWith("https://")) && (x = new URL(x).hostname);
195
- } catch {
196
- }
197
- const S = process.env.NEXTBLOCK_VERCEL_PROJECT_ID || process.env.VERCEL_PROJECT_ID, L = process.env.NEXTBLOCK_VERCEL_WORKSPACE_ID || process.env.VERCEL_ORG_ID, l = {
198
- origin: x,
199
- editUrl: `${o}/cms/products/${r.id}/edit`,
200
- data: {
201
- parentType: "product",
202
- parentId: r.id,
203
- slug: r.slug,
204
- languageId: r.language_id,
205
- draftId: null,
206
- target: f
207
- }
208
- };
209
- return S && (l.projectId = S), L && (l.workspaceId = L), {
210
- "data-vercel-edit-info": JSON.stringify(l),
211
- "data-vercel-edit-target": JSON.stringify(f),
212
- "data-nextblock-visual-edit": `product:${u}`
213
- };
214
- }
215
- const Xe = ({
216
- visualEditingEnabled: r = !1,
217
- descriptionNode: u
218
- }) => {
219
- const e = Pe(), { t: c, lang: f } = Q(), { activeCurrencyCode: o, currencies: I } = Y(), x = r ? B(
220
- e,
221
- "title",
222
- "plain-text",
223
- "Product title"
224
- ) : void 0, S = r ? B(
225
- e,
226
- "short_description",
227
- "plain-text",
228
- "Short description"
229
- ) : void 0, L = r ? B(
230
- e,
231
- "description_json",
232
- "tiptap",
233
- "Product description"
234
- ) : void 0, l = (s, b, p) => {
235
- const J = c(s, p);
236
- return J === s ? b : J;
237
- }, _ = e.images && e.images.length > 0 ? e.images : e.image_url ? [{ url: e.image_url, alt: e.title }] : [], y = e.custom_props?.provider === "freemius" || we(e), N = Z(e), i = !y && !!(e.has_variants && e.attributes?.length && e.variants?.length), v = e.attributes || [], g = e.variants || [], [w, R] = T(() => W(v, g)), [h, C] = T(1);
238
- j(() => {
239
- C(1);
240
- }, [e.id]), j(() => {
241
- i && R(W(v, g));
242
- }, [v, i, e.id, g]);
243
- const d = $(() => i ? z(
244
- v,
245
- g,
246
- w
247
- ) : w, [v, i, w, g]);
248
- j(() => {
249
- JSON.stringify(d) !== JSON.stringify(w) && R(d);
250
- }, [d, w]);
251
- const a = $(() => i ? be(g, d) : null, [i, d, g]), A = X({
252
- prices: e.prices,
253
- salePrices: e.sale_prices,
254
- fallbackPrice: e.price,
255
- fallbackSalePrice: e.sale_price,
256
- saleStartAt: e.sale_start_at,
257
- saleEndAt: e.sale_end_at,
258
- scheduledPrice: e.scheduled_price,
259
- scheduledPrices: e.scheduled_prices,
260
- scheduledPriceAt: e.scheduled_price_at,
261
- currencyCode: o,
262
- currencies: I
263
- }), V = i && a ? X({
264
- prices: a.prices,
265
- salePrices: a.sale_prices,
266
- fallbackPrice: a.price,
267
- fallbackSalePrice: a.sale_price,
268
- saleStartAt: a.sale_start_at,
269
- saleEndAt: a.sale_end_at,
270
- scheduledPrice: a.scheduled_price,
271
- scheduledPrices: a.scheduled_prices,
272
- scheduledPriceAt: a.scheduled_price_at,
273
- currencyCode: o,
274
- currencies: I
275
- }) : null, k = V?.price ?? A.price, P = V?.sale_price ?? A.sale_price, m = i ? a?.stock_quantity ?? 0 : e.stock ?? 0, O = $(() => {
276
- if (!a?.image_url)
277
- return _;
278
- const s = {
279
- url: a.image_url,
280
- alt: `${e.title} ${a.label}`
281
- }, b = _.filter(
282
- (p) => p.url !== a.image_url
283
- );
284
- return [s, ...b];
285
- }, [_, e.title, a]), te = typeof P == "number" && k > 0 ? Math.round(
286
- (k - P) / k * 100
287
- ) : 0, re = i && a ? {
288
- ...e,
289
- sku: a.sku,
290
- price: a.price,
291
- prices: a.prices,
292
- sale_price: typeof a.sale_price == "number" ? a.sale_price : null,
293
- sale_prices: a.sale_prices,
294
- image_url: a.image_url || e.image_url,
295
- stock: a.stock_quantity,
296
- variant_id: a.id,
297
- variant_label: a.label,
298
- selected_options: a.selected_options,
299
- currency_code: o
300
- } : {
301
- ...e,
302
- currency_code: o
303
- }, ae = (s, b) => {
304
- R(
305
- (p) => z(v, g, {
306
- ...p,
307
- [s]: b
308
- })
309
- );
310
- }, ie = l(
311
- "ecommerce.in_stock",
312
- `${m} in stock`,
313
- { count: String(m) }
314
- ), F = l(
315
- "ecommerce.out_of_stock",
316
- "Out of stock"
317
- ), ne = l(
318
- "ecommerce.select_options",
319
- "Select Options"
320
- ), se = l(
321
- "ecommerce.variant_selection_required",
322
- "Select one term from every dropdown to resolve a variation."
323
- );
324
- return /* @__PURE__ */ n("div", { className: "w-full animate-in fade-in slide-in-from-bottom-4 duration-700 ease-out", children: [
325
- /* @__PURE__ */ t("div", { className: "container mx-auto px-4 md:px-6 py-12", children: /* @__PURE__ */ n("div", { className: "grid gap-12 lg:grid-cols-[2fr_3fr] items-start", children: [
326
- /* @__PURE__ */ t("div", { className: "w-full max-w-2xl mx-auto lg:max-w-none", children: /* @__PURE__ */ t(Ce, { images: O, className: "w-full" }) }),
327
- /* @__PURE__ */ n("div", { className: "flex flex-col gap-4 pb-2 max-w-xl mx-auto lg:mx-0 lg:max-w-none", children: [
328
- /* @__PURE__ */ t("div", { className: "space-y-6", children: /* @__PURE__ */ n("div", { className: "space-y-4", children: [
329
- /* @__PURE__ */ t(
330
- "h1",
331
- {
332
- className: "text-3xl sm:text-4xl lg:text-5xl font-extrabold tracking-tight text-foreground leading-[1.1] lg:mt-0",
333
- ...x,
334
- children: e.title
335
- }
336
- ),
337
- 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, b) => {
338
- const p = ye(
339
- s.name,
340
- s.name_translations,
341
- f
342
- );
343
- return /* @__PURE__ */ n(le.Fragment, { children: [
344
- b > 0 && /* @__PURE__ */ t("span", { className: "text-muted-foreground/30", children: "•" }),
345
- /* @__PURE__ */ t("span", { children: p })
346
- ] }, s.id);
347
- }) }),
348
- /* @__PURE__ */ t(
349
- "div",
350
- {
351
- className: "prose prose-neutral dark:prose-invert max-w-none text-muted-foreground leading-relaxed text-left",
352
- ...S,
353
- children: e.short_description ? /* @__PURE__ */ t(
354
- "div",
355
- {
356
- className: "text-lg mb-4 leading-relaxed",
357
- dangerouslySetInnerHTML: {
358
- __html: e.short_description
359
- }
360
- }
361
- ) : r ? /* @__PURE__ */ t("p", { className: "text-lg mb-4 italic text-muted-foreground", children: "Add a short product description." }) : null
362
- }
363
- ),
364
- /* @__PURE__ */ n("div", { className: "flex items-center gap-3", children: [
365
- typeof P == "number" && /* @__PURE__ */ t(
366
- M,
367
- {
368
- variant: "destructive",
369
- className: "px-2.5 py-1 text-xs font-bold uppercase tracking-wide animate-pulse shadow-sm",
370
- children: c("ecommerce.sale_badge", {
371
- percent: String(te)
372
- })
373
- }
374
- ),
375
- !y && m > 0 && m < 10 && /* @__PURE__ */ t(
376
- M,
377
- {
378
- variant: "outline",
379
- className: "text-amber-600 border-amber-200 bg-amber-50",
380
- children: c("ecommerce.low_stock", {
381
- count: String(m)
382
- })
383
- }
384
- ),
385
- N && /* @__PURE__ */ t(
386
- M,
387
- {
388
- variant: "secondary",
389
- className: "border border-emerald-200 bg-emerald-50 text-emerald-800",
390
- children: N.label
391
- }
392
- )
393
- ] })
394
- ] }) }),
395
- /* @__PURE__ */ n("div", { className: "p-5 rounded-2xl bg-card/60 border border-border/80 shadow-md backdrop-blur-md space-y-4", children: [
396
- y ? /* @__PURE__ */ t(ke, { product: e }) : /* @__PURE__ */ n("div", { className: "space-y-3.5", children: [
397
- /* @__PURE__ */ n("div", { className: "flex items-center justify-between gap-4", children: [
398
- /* @__PURE__ */ n("div", { className: "space-y-1", children: [
399
- /* @__PURE__ */ t("span", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-widest", children: l("ecommerce.price", "Price") }),
400
- /* @__PURE__ */ n("div", { className: "flex items-baseline gap-2.5", children: [
401
- /* @__PURE__ */ t("span", { className: "text-3xl font-extrabold text-foreground", children: D(
402
- P ?? k,
403
- o
404
- ) }),
405
- typeof P == "number" && /* @__PURE__ */ t("span", { className: "text-lg text-muted-foreground line-through decoration-destructive/20 decoration-1", children: D(k, o) })
406
- ] })
407
- ] }),
408
- !y && (a || !i) && /* @__PURE__ */ n("div", { className: "text-right space-y-1", children: [
409
- /* @__PURE__ */ n("span", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-widest block", children: [
410
- !i && e.sku && /* @__PURE__ */ n("span", { className: "mr-2 font-normal lowercase normal-case text-muted-foreground/70", children: [
411
- "SKU: ",
412
- e.sku
413
- ] }),
414
- l("ecommerce.status", "Status")
415
- ] }),
416
- /* @__PURE__ */ t("div", { className: (m ?? 0) > 0 ? "text-emerald-600 dark:text-emerald-400 font-semibold text-sm" : "text-destructive font-semibold text-sm", children: (m ?? 0) > 0 ? ie : F })
417
- ] })
418
- ] }),
419
- i && /* @__PURE__ */ t("div", { className: "space-y-3", children: /* @__PURE__ */ t("div", { className: "grid gap-3 sm:grid-cols-2", children: v.map((s) => {
420
- const b = Ne(
421
- g,
422
- s.id,
423
- d
424
- );
425
- return /* @__PURE__ */ n("div", { className: "space-y-1", children: [
426
- /* @__PURE__ */ n("div", { className: "flex items-center justify-between", children: [
427
- /* @__PURE__ */ t(
428
- fe,
429
- {
430
- htmlFor: `attribute-${s.id}`,
431
- className: "text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",
432
- children: s.name
433
- }
434
- ),
435
- a?.sku && /* @__PURE__ */ t("span", { className: "text-[10px] text-muted-foreground font-mono", children: a.sku })
436
- ] }),
437
- /* @__PURE__ */ t(
438
- "select",
439
- {
440
- id: `attribute-${s.id}`,
441
- className: "flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
442
- value: d[s.id] || "",
443
- onChange: (p) => ae(
444
- s.id,
445
- p.target.value
446
- ),
447
- children: s.terms.map((p) => /* @__PURE__ */ t(
448
- "option",
449
- {
450
- value: p.id,
451
- disabled: !b.has(p.id),
452
- children: p.value
453
- },
454
- p.id
455
- ))
456
- }
457
- )
458
- ] }, s.id);
459
- }) }) }),
460
- i && !a && /* @__PURE__ */ t("p", { className: "text-xs text-muted-foreground italic pt-1", children: se }),
461
- /* @__PURE__ */ n("div", { className: "flex items-center gap-3 pt-1", children: [
462
- !y && (m ?? 0) > 0 && /* @__PURE__ */ n("div", { className: "flex items-center border rounded-lg h-12 bg-background border-input select-none", children: [
463
- /* @__PURE__ */ t(
464
- "button",
465
- {
466
- type: "button",
467
- onClick: () => C((s) => Math.max(1, s - 1)),
468
- className: "px-3 h-full flex items-center justify-center text-muted-foreground hover:text-foreground active:scale-95 transition-all text-lg font-medium",
469
- disabled: h <= 1,
470
- children: "-"
471
- }
472
- ),
473
- /* @__PURE__ */ t("span", { className: "w-8 text-center text-sm font-semibold", children: h }),
474
- /* @__PURE__ */ t(
475
- "button",
476
- {
477
- type: "button",
478
- onClick: () => C(
479
- (s) => m !== null && s >= m ? s : s + 1
480
- ),
481
- className: "px-3 h-full flex items-center justify-center text-muted-foreground hover:text-foreground active:scale-95 transition-all text-lg font-medium",
482
- disabled: m !== null && h >= m,
483
- children: "+"
484
- }
485
- )
486
- ] }),
487
- i && (!a || (m ?? 0) <= 0) ? /* @__PURE__ */ t(
488
- H,
489
- {
490
- disabled: !0,
491
- className: "flex-1 h-12 text-md font-bold shadow-md",
492
- children: a ? F : ne
493
- }
494
- ) : /* @__PURE__ */ t(
495
- he,
496
- {
497
- product: re,
498
- quantity: h,
499
- className: "flex-1 h-12 text-md font-bold shadow-md transition-all hover:shadow-lg active:scale-[0.98]"
500
- }
501
- )
502
- ] })
503
- ] }),
504
- /* @__PURE__ */ t(ge, { className: "opacity-60 my-0.5" }),
505
- /* @__PURE__ */ n("div", { className: "grid grid-cols-2 gap-4 text-center text-[11px] font-medium text-muted-foreground pt-1", children: [
506
- /* @__PURE__ */ t("div", { className: "flex items-center justify-center gap-2", children: y ? /* @__PURE__ */ n("span", { className: "inline-flex items-center gap-1.5", children: [
507
- /* @__PURE__ */ t(me, { className: "h-3.5 w-3.5" }),
508
- c("ecommerce.instant_digital_delivery")
509
- ] }) : /* @__PURE__ */ n("span", { className: "inline-flex items-center gap-1.5", children: [
510
- /* @__PURE__ */ t(ue, { className: "h-3.5 w-3.5" }),
511
- c("ecommerce.free_shipping")
512
- ] }) }),
513
- /* @__PURE__ */ t("div", { className: "flex items-center justify-center gap-2", children: /* @__PURE__ */ n("span", { className: "inline-flex items-center gap-1.5", children: [
514
- /* @__PURE__ */ t(pe, { className: "h-3.5 w-3.5" }),
515
- c("ecommerce.secure_checkout")
516
- ] }) })
517
- ] })
518
- ] })
519
- ] })
520
- ] }) }),
521
- /* @__PURE__ */ t("div", { className: "min-w-0 w-full", ...u ? void 0 : L, children: u || (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(ve, { 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: c("ecommerce.no_description") }) })) })
522
- ] });
523
- };
524
- export {
525
- Xe as P,
526
- ke as S,
527
- Ce as a,
528
- Ke as b,
529
- Pe as u
530
- };
@@ -1 +0,0 @@
1
- "use strict";const r=require("react/jsx-runtime"),S=require("./AddToCartButton-DsSEH9yp.cjs"),l=require("@nextblock-cms/utils"),P=require("next/link"),q=require("./CurrencyProvider-Cg-Q6ucj.cjs"),n=require("./currency.cjs.js"),A=require("./trials-DvZaOtNy.cjs"),k=require("./variation-utils.cjs.js"),b=({product:e,className:o})=>{const{activeCurrencyCode:s,currencies:i}=q.useCurrency(),c=n.resolvePriceRangeForCurrency({entries:e.variants?.length?e.variants:e.product_variants?.length?e.product_variants:[],currencyCode:s,currencies:i}),x=!!(e.has_variants&&c),t=n.resolveEffectivePriceForCurrency({prices:e.prices,salePrices:e.sale_prices,fallbackPrice:e.price,fallbackSalePrice:e.sale_price,saleStartAt:e.sale_start_at,saleEndAt:e.sale_end_at,scheduledPrice:e.scheduled_price,scheduledPrices:e.scheduled_prices,scheduledPriceAt:e.scheduled_price_at,currencyCode:s,currencies:i}),j=x&&c?c.min===c.max?l.formatPrice(c.min,s):`${l.formatPrice(c.min,s)} - ${l.formatPrice(c.max,s)}`:l.formatPrice(t.sale_price??t.price,s),y=e.variants?.length?e.variants:e.product_variants?.length?e.product_variants:[],N=x?y.some(a=>n.resolveEffectivePriceForCurrency({prices:a.prices,salePrices:a.sale_prices,fallbackPrice:a.price,fallbackSalePrice:a.sale_price,saleStartAt:a.sale_start_at,saleEndAt:a.sale_end_at,scheduledPrice:a.scheduled_price,scheduledPrices:a.scheduled_prices,scheduledPriceAt:a.scheduled_price_at,currencyCode:s,currencies:i}).sale_price!=null):t.sale_price!=null,{t:f,lang:C}=l.useTranslations(),g=f("ecommerce.on_sale"),w=g==="ecommerce.on_sale"?"On Sale":g,h=A.getTrialSummary(e),d=e.freemius_plans?.[0]?.freemius_pricing?.[0],m=i.find(a=>a.is_default)?.code||"USD",_=d?.override_monthly_price??d?.api_monthly_price,v=d?.override_annual_price??d?.api_annual_price,u=typeof _=="number"?n.resolvePriceForCurrency({prices:{[m]:l.majorUnitAmountToMinor(_,m)},currencyCode:s,currencies:i}):null,p=typeof v=="number"?n.resolvePriceForCurrency({prices:{[m]:l.majorUnitAmountToMinor(v,m)},currencyCode:s,currencies:i}):null;return r.jsxs("div",{className:l.cn("group relative flex flex-col overflow-hidden rounded-lg border bg-card text-card-foreground shadow-sm transition-all hover:shadow-md",o),children:[r.jsxs(P,{href:`/product/${e.slug}`,className:"relative aspect-square overflow-hidden bg-muted",children:[N&&r.jsx("span",{className:"absolute left-3 top-3 z-10 rounded-full bg-destructive px-2.5 py-1 text-[10px] font-bold uppercase tracking-wider text-destructive-foreground shadow-sm",children:w}),e.image_url?r.jsx("img",{src:e.image_url,alt:e.title,className:"h-full w-full object-cover object-center transition-transform duration-300 group-hover:scale-105"}):r.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"No Image"})]}),r.jsxs("div",{className:"flex flex-1 flex-col p-4",children:[e.categories&&e.categories.length>0&&r.jsx("div",{className:"text-[10px] font-bold uppercase tracking-widest text-amber-600 dark:text-amber-400 mb-1",children:e.categories.map(a=>k.resolveTranslatedText(a.name,a.name_translations,C)).join(" • ")}),r.jsx(P,{href:`/product/${e.slug}`,className:"mb-2",children:r.jsx("h3",{className:"line-clamp-1 text-lg font-medium text-foreground group-hover:underline",children:e.title})}),r.jsx("div",{className:"mb-4",children:e.product_type==="digital"&&(u||p)?r.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1",children:[u&&r.jsxs("div",{className:"flex items-baseline gap-0.5",children:[r.jsx("span",{className:"text-xl font-bold text-primary",children:l.formatPrice(u.price,s)}),r.jsxs("span",{className:"text-xs font-medium text-muted-foreground lowercase",children:["/ ",f("ecommerce.month")]})]}),p&&r.jsxs("div",{className:"flex items-baseline gap-0.5",children:[r.jsx("span",{className:l.cn("font-bold text-primary",u?"text-lg":"text-xl"),children:l.formatPrice(p.price,s)}),r.jsxs("span",{className:"text-xs font-medium text-muted-foreground lowercase",children:["/ ",f("ecommerce.year")]})]})]}):r.jsxs("div",{className:"flex items-baseline gap-2",children:[r.jsx("span",{className:"text-xl font-bold text-primary",children:j}),!x&&t.sale_price&&r.jsx("span",{className:"text-sm text-muted-foreground line-through",children:l.formatPrice(t.price,s)})]})}),h&&r.jsxs("div",{className:"mb-4 rounded-md border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs text-emerald-900",children:[r.jsx("div",{className:"font-semibold",children:h.label}),r.jsx("div",{className:"text-emerald-700",children:h.paymentRequirementLabel})]}),r.jsx("div",{className:"mt-auto",children:r.jsx(S.AddToCartButton,{product:{...e,price:e.price,prices:e.prices,sale_price:e.sale_price,sale_prices:e.sale_prices},className:"w-full"})})]})]})},R=({products:e,columns:o=3,className:s})=>e.length?r.jsx("div",{className:l.cn("grid gap-6 sm:grid-cols-2",o===3&&"lg:grid-cols-3",o===4&&"lg:grid-cols-4",s),children:e.map(i=>r.jsx(b,{product:i},i.id))}):r.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"No products found."});exports.ProductCard=b;exports.ProductGrid=R;
@@ -1,130 +0,0 @@
1
- import { jsxs as l, jsx as r } from "react/jsx-runtime";
2
- import { A as R } from "./AddToCartButton-ffE0DhHu.js";
3
- import { formatPrice as t, useTranslations as T, majorUnitAmountToMinor as y, cn as x } from "@nextblock-cms/utils";
4
- import N from "next/link";
5
- import { u as L } from "./CurrencyProvider-OzlRN96V.js";
6
- import { resolvePriceRangeForCurrency as E, resolveEffectivePriceForCurrency as P, resolvePriceForCurrency as C } from "./currency.es.js";
7
- import { d as $ } from "./trials-RDcRAZKx.js";
8
- import { resolveTranslatedText as F } from "./variation-utils.es.js";
9
- const M = ({ product: e, className: o }) => {
10
- const { activeCurrencyCode: a, currencies: i } = L(), c = E({
11
- entries: e.variants?.length ? e.variants : e.product_variants?.length ? e.product_variants : [],
12
- currencyCode: a,
13
- currencies: i
14
- }), u = !!(e.has_variants && c), n = P({
15
- prices: e.prices,
16
- salePrices: e.sale_prices,
17
- fallbackPrice: e.price,
18
- fallbackSalePrice: e.sale_price,
19
- saleStartAt: e.sale_start_at,
20
- saleEndAt: e.sale_end_at,
21
- scheduledPrice: e.scheduled_price,
22
- scheduledPrices: e.scheduled_prices,
23
- scheduledPriceAt: e.scheduled_price_at,
24
- currencyCode: a,
25
- currencies: i
26
- }), w = u && c ? c.min === c.max ? t(c.min, a) : `${t(c.min, a)} - ${t(
27
- c.max,
28
- a
29
- )}` : t(n.sale_price ?? n.price, a), S = e.variants?.length ? e.variants : e.product_variants?.length ? e.product_variants : [], j = u ? S.some(
30
- (s) => P({
31
- prices: s.prices,
32
- salePrices: s.sale_prices,
33
- fallbackPrice: s.price,
34
- fallbackSalePrice: s.sale_price,
35
- saleStartAt: s.sale_start_at,
36
- saleEndAt: s.sale_end_at,
37
- scheduledPrice: s.scheduled_price,
38
- scheduledPrices: s.scheduled_prices,
39
- scheduledPriceAt: s.scheduled_price_at,
40
- currencyCode: a,
41
- currencies: i
42
- }).sale_price != null
43
- ) : n.sale_price != null, { t: p, lang: A } = T(), _ = p("ecommerce.on_sale"), k = _ === "ecommerce.on_sale" ? "On Sale" : _, h = $(e), d = e.freemius_plans?.[0]?.freemius_pricing?.[0], m = i.find((s) => s.is_default)?.code || "USD", v = d?.override_monthly_price ?? d?.api_monthly_price, b = d?.override_annual_price ?? d?.api_annual_price, f = typeof v == "number" ? C({
44
- prices: {
45
- [m]: y(
46
- v,
47
- m
48
- )
49
- },
50
- currencyCode: a,
51
- currencies: i
52
- }) : null, g = typeof b == "number" ? C({
53
- prices: {
54
- [m]: y(
55
- b,
56
- m
57
- )
58
- },
59
- currencyCode: a,
60
- currencies: i
61
- }) : null;
62
- return /* @__PURE__ */ l("div", { className: x("group relative flex flex-col overflow-hidden rounded-lg border bg-card text-card-foreground shadow-sm transition-all hover:shadow-md", o), children: [
63
- /* @__PURE__ */ l(N, { href: `/product/${e.slug}`, className: "relative aspect-square overflow-hidden bg-muted", children: [
64
- j && /* @__PURE__ */ r("span", { className: "absolute left-3 top-3 z-10 rounded-full bg-destructive px-2.5 py-1 text-[10px] font-bold uppercase tracking-wider text-destructive-foreground shadow-sm", children: k }),
65
- e.image_url ? /* @__PURE__ */ r(
66
- "img",
67
- {
68
- src: e.image_url,
69
- alt: e.title,
70
- className: "h-full w-full object-cover object-center transition-transform duration-300 group-hover:scale-105"
71
- }
72
- ) : /* @__PURE__ */ r("div", { className: "flex h-full items-center justify-center text-muted-foreground", children: "No Image" })
73
- ] }),
74
- /* @__PURE__ */ l("div", { className: "flex flex-1 flex-col p-4", children: [
75
- e.categories && e.categories.length > 0 && /* @__PURE__ */ r("div", { className: "text-[10px] font-bold uppercase tracking-widest text-amber-600 dark:text-amber-400 mb-1", children: e.categories.map((s) => F(s.name, s.name_translations, A)).join(" • ") }),
76
- /* @__PURE__ */ r(N, { href: `/product/${e.slug}`, className: "mb-2", children: /* @__PURE__ */ r("h3", { className: "line-clamp-1 text-lg font-medium text-foreground group-hover:underline", children: e.title }) }),
77
- /* @__PURE__ */ r("div", { className: "mb-4", children: e.product_type === "digital" && (f || g) ? /* @__PURE__ */ l("div", { className: "flex flex-wrap items-baseline gap-x-3 gap-y-1", children: [
78
- f && /* @__PURE__ */ l("div", { className: "flex items-baseline gap-0.5", children: [
79
- /* @__PURE__ */ r("span", { className: "text-xl font-bold text-primary", children: t(f.price, a) }),
80
- /* @__PURE__ */ l("span", { className: "text-xs font-medium text-muted-foreground lowercase", children: [
81
- "/ ",
82
- p("ecommerce.month")
83
- ] })
84
- ] }),
85
- g && /* @__PURE__ */ l("div", { className: "flex items-baseline gap-0.5", children: [
86
- /* @__PURE__ */ r("span", { className: x("font-bold text-primary", f ? "text-lg" : "text-xl"), children: t(g.price, a) }),
87
- /* @__PURE__ */ l("span", { className: "text-xs font-medium text-muted-foreground lowercase", children: [
88
- "/ ",
89
- p("ecommerce.year")
90
- ] })
91
- ] })
92
- ] }) : /* @__PURE__ */ l("div", { className: "flex items-baseline gap-2", children: [
93
- /* @__PURE__ */ r("span", { className: "text-xl font-bold text-primary", children: w }),
94
- !u && n.sale_price && /* @__PURE__ */ r("span", { className: "text-sm text-muted-foreground line-through", children: t(n.price, a) })
95
- ] }) }),
96
- h && /* @__PURE__ */ l("div", { className: "mb-4 rounded-md border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs text-emerald-900", children: [
97
- /* @__PURE__ */ r("div", { className: "font-semibold", children: h.label }),
98
- /* @__PURE__ */ r("div", { className: "text-emerald-700", children: h.paymentRequirementLabel })
99
- ] }),
100
- /* @__PURE__ */ r("div", { className: "mt-auto", children: /* @__PURE__ */ r(
101
- R,
102
- {
103
- product: {
104
- ...e,
105
- price: e.price,
106
- prices: e.prices,
107
- sale_price: e.sale_price,
108
- sale_prices: e.sale_prices
109
- },
110
- className: "w-full"
111
- }
112
- ) })
113
- ] })
114
- ] });
115
- }, H = ({ products: e, columns: o = 3, className: a }) => e.length ? /* @__PURE__ */ r(
116
- "div",
117
- {
118
- className: x(
119
- "grid gap-6 sm:grid-cols-2",
120
- o === 3 && "lg:grid-cols-3",
121
- o === 4 && "lg:grid-cols-4",
122
- a
123
- ),
124
- children: e.map((i) => /* @__PURE__ */ r(M, { product: i }, i.id))
125
- }
126
- ) : /* @__PURE__ */ r("div", { className: "py-12 text-center text-muted-foreground", children: "No products found." });
127
- export {
128
- M as P,
129
- H as a
130
- };