@nextblock-cms/ecom 0.20.3 → 0.21.1

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 (446) hide show
  1. package/README.md +43 -0
  2. package/_virtual/_rolldown/runtime.cjs +1 -0
  3. package/index.cjs +1 -0
  4. package/index.es.js +38 -146
  5. package/lib/CurrencyProvider.cjs +1 -0
  6. package/lib/CurrencyProvider.d.ts +1 -1
  7. package/lib/CurrencyProvider.es.js +85 -95
  8. package/lib/PaymentReadinessProvider.cjs +1 -0
  9. package/lib/PaymentReadinessProvider.d.ts +1 -1
  10. package/lib/PaymentReadinessProvider.es.js +24 -27
  11. package/lib/cart-store.cjs +1 -0
  12. package/lib/cart-store.es.js +109 -121
  13. package/lib/components/AccountNavigationMenu.cjs +1 -0
  14. package/lib/components/AccountNavigationMenu.d.ts +1 -1
  15. package/lib/components/AccountNavigationMenu.es.js +36 -50
  16. package/lib/components/AddToCartButton.cjs +1 -0
  17. package/lib/components/AddToCartButton.d.ts +1 -1
  18. package/lib/components/AddToCartButton.es.js +94 -89
  19. package/lib/components/Cart.cjs +1 -0
  20. package/lib/components/Cart.d.ts +1 -1
  21. package/lib/components/Cart.es.js +261 -180
  22. package/lib/components/CartDrawer.cjs +1 -0
  23. package/lib/components/CartDrawer.d.ts +1 -1
  24. package/lib/components/CartDrawer.es.js +218 -148
  25. package/lib/components/CartIcon.cjs +1 -0
  26. package/lib/components/CartIcon.d.ts +1 -1
  27. package/lib/components/CartIcon.es.js +33 -35
  28. package/lib/components/Checkout.cjs +1 -0
  29. package/lib/components/Checkout.d.ts +1 -1
  30. package/lib/components/Checkout.es.js +1092 -1108
  31. package/lib/components/CouponForm.cjs +1 -0
  32. package/lib/components/CouponForm.d.ts +1 -1
  33. package/lib/components/CouponForm.es.js +136 -148
  34. package/lib/components/CurrencySwitcher.cjs +1 -0
  35. package/lib/components/CurrencySwitcher.d.ts +1 -1
  36. package/lib/components/CurrencySwitcher.es.js +22 -18
  37. package/lib/components/CustomerProfileForm.cjs +1 -0
  38. package/lib/components/CustomerProfileForm.es.js +454 -313
  39. package/lib/components/FeaturedProduct.cjs +1 -0
  40. package/lib/components/FeaturedProduct.d.ts +1 -1
  41. package/lib/components/FeaturedProduct.es.js +98 -83
  42. package/lib/components/FreemiusLicensePanel.cjs +1 -0
  43. package/lib/components/FreemiusLicensePanel.d.ts +1 -1
  44. package/lib/components/FreemiusLicensePanel.es.js +70 -65
  45. package/lib/components/InvoiceDocument.cjs +1 -0
  46. package/lib/components/InvoiceDocument.es.js +256 -192
  47. package/lib/components/InvoiceViewerShell.cjs +29 -0
  48. package/lib/components/InvoiceViewerShell.d.ts +1 -1
  49. package/lib/components/InvoiceViewerShell.es.js +75 -106
  50. package/lib/components/ProductCard.cjs +1 -0
  51. package/lib/components/ProductCard.d.ts +1 -1
  52. package/lib/components/ProductCard.es.js +186 -171
  53. package/lib/components/ProductDetailsLayout.cjs +1 -0
  54. package/lib/components/ProductDetailsLayout.es.js +405 -404
  55. package/lib/components/ProductGallery.cjs +1 -0
  56. package/lib/components/ProductGallery.d.ts +1 -1
  57. package/lib/components/ProductGallery.es.js +51 -54
  58. package/lib/components/ProductGrid.cjs +1 -0
  59. package/lib/components/ProductGrid.d.ts +1 -1
  60. package/lib/components/ProductGrid.es.js +23 -25
  61. package/lib/components/ShippingEstimator.cjs +1 -0
  62. package/lib/components/ShippingEstimator.d.ts +1 -1
  63. package/lib/components/ShippingEstimator.es.js +158 -153
  64. package/lib/components/ShortDescription.cjs +1 -0
  65. package/lib/components/ShortDescription.es.js +17 -17
  66. package/lib/components/SimpleTiptapRenderer.cjs +1 -0
  67. package/lib/components/SimpleTiptapRenderer.es.js +238 -211
  68. package/lib/components/SubscriptionSelector.cjs +1 -0
  69. package/lib/components/SubscriptionSelector.es.js +159 -154
  70. package/lib/countries.cjs +1 -0
  71. package/lib/countries.es.js +232 -75
  72. package/lib/coupon-server.cjs +1 -0
  73. package/lib/coupon-server.es.js +180 -224
  74. package/lib/coupons.cjs +1 -0
  75. package/lib/coupons.es.js +12 -14
  76. package/lib/currency-constants.cjs +1 -0
  77. package/lib/currency-constants.es.js +4 -4
  78. package/lib/currency-rest-client.cjs +1 -0
  79. package/lib/currency-rest-client.es.js +15 -22
  80. package/lib/currency-store.cjs +1 -0
  81. package/lib/currency-store.es.js +20 -27
  82. package/lib/currency-sync.cjs +1 -0
  83. package/lib/currency-sync.es.js +124 -170
  84. package/lib/currency.cjs +1 -0
  85. package/lib/currency.es.js +242 -310
  86. package/lib/customer-addresses.cjs +1 -0
  87. package/lib/customer-addresses.es.js +80 -109
  88. package/lib/customer-orders.cjs +1 -0
  89. package/lib/customer-orders.es.js +31 -43
  90. package/lib/customer.cjs +1 -0
  91. package/lib/customer.es.js +43 -52
  92. package/lib/export-helpers.cjs +1 -0
  93. package/lib/export-helpers.es.js +53 -52
  94. package/lib/factory.cjs +1 -0
  95. package/lib/factory.es.js +10 -7
  96. package/lib/freemius-coupons.cjs +1 -0
  97. package/lib/freemius-coupons.es.js +245 -262
  98. package/lib/freemius-license-claim.cjs +1 -0
  99. package/lib/freemius-license-claim.es.js +87 -71
  100. package/lib/freemius-license.cjs +1 -0
  101. package/lib/freemius-license.es.js +32 -39
  102. package/lib/freemius-order-sync.cjs +1 -0
  103. package/lib/freemius-order-sync.es.js +226 -290
  104. package/lib/freemius-trial-provision.cjs +1 -0
  105. package/lib/freemius-trial-provision.es.js +136 -130
  106. package/lib/inventory-settings.cjs +1 -0
  107. package/lib/inventory-settings.es.js +69 -77
  108. package/lib/invoice-server.cjs +33 -0
  109. package/lib/invoice-server.es.js +94 -141
  110. package/lib/invoice-ui.cjs +1 -0
  111. package/lib/invoice-ui.es.js +50 -66
  112. package/lib/invoice.cjs +1 -0
  113. package/lib/invoice.es.js +85 -94
  114. package/lib/order-inventory.cjs +61 -0
  115. package/lib/order-inventory.es.js +67 -79
  116. package/lib/order-tax-details.cjs +1 -0
  117. package/lib/order-tax-details.es.js +142 -153
  118. package/lib/pages/cms/coupons/CouponEditorForm.cjs +1 -0
  119. package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
  120. package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
  121. package/lib/pages/cms/coupons/CouponsPage.cjs +5 -0
  122. package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
  123. package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
  124. package/lib/pages/cms/coupons/CreateCouponDialog.cjs +1 -0
  125. package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
  126. package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
  127. package/lib/pages/cms/coupons/EditCouponPage.cjs +1 -0
  128. package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
  129. package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
  130. package/lib/pages/cms/coupons/ProductScopePicker.cjs +1 -0
  131. package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
  132. package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
  133. package/lib/pages/cms/coupons/actions.cjs +1 -0
  134. package/lib/pages/cms/coupons/actions.es.js +112 -115
  135. package/lib/pages/cms/coupons/index.cjs +1 -0
  136. package/lib/pages/cms/coupons/index.es.js +3 -0
  137. package/lib/pages/cms/coupons/product-options.cjs +1 -0
  138. package/lib/pages/cms/coupons/product-options.es.js +21 -23
  139. package/lib/pages/cms/orders/ExportReportsDialog.cjs +1 -0
  140. package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
  141. package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
  142. package/lib/pages/cms/orders/OrderDetailPage.cjs +1 -0
  143. package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
  144. package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
  145. package/lib/pages/cms/orders/OrderPrintButton.cjs +1 -0
  146. package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
  147. package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
  148. package/lib/pages/cms/orders/OrderStatusForm.cjs +1 -0
  149. package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
  150. package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
  151. package/lib/pages/cms/orders/OrdersPage.cjs +1 -0
  152. package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
  153. package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
  154. package/lib/pages/cms/orders/actions.cjs +7 -0
  155. package/lib/pages/cms/orders/actions.es.js +53 -69
  156. package/lib/pages/cms/orders/export-actions.cjs +1 -0
  157. package/lib/pages/cms/orders/export-actions.es.js +23 -26
  158. package/lib/pages/cms/orders/index.cjs +1 -0
  159. package/lib/pages/cms/orders/index.es.js +6 -0
  160. package/lib/pages/cms/orders/server-actions.cjs +1 -0
  161. package/lib/pages/cms/orders/server-actions.es.js +60 -51
  162. package/lib/pages/cms/payments/PaymentsClient.cjs +1 -0
  163. package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
  164. package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
  165. package/lib/pages/cms/payments/PaymentsPage.cjs +1 -0
  166. package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
  167. package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
  168. package/lib/pages/cms/payments/actions.cjs +1 -0
  169. package/lib/pages/cms/payments/actions.es.js +38 -48
  170. package/lib/pages/cms/payments/index.cjs +1 -0
  171. package/lib/pages/cms/payments/index.es.js +3 -0
  172. package/lib/pages/cms/payments/queries.cjs +1 -0
  173. package/lib/pages/cms/payments/queries.es.js +38 -48
  174. package/lib/pages/cms/products/ProductsPage.cjs +1 -0
  175. package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
  176. package/lib/pages/cms/products/ProductsPage.es.js +63 -66
  177. package/lib/pages/cms/products/[id]/edit/EditProductPage.cjs +1 -0
  178. package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
  179. package/lib/pages/cms/products/[id]/edit/EditProductPage.es.js +139 -0
  180. package/lib/pages/cms/products/actions.cjs +44 -0
  181. package/lib/pages/cms/products/actions.es.js +121 -162
  182. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs +1 -0
  183. package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
  184. package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
  185. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs +1 -0
  186. package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
  187. package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
  188. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs +1 -0
  189. package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
  190. package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
  191. package/lib/pages/cms/products/categories/components/CategoryManager.cjs +1 -0
  192. package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
  193. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs +1 -0
  194. package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
  195. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs +1 -0
  196. package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
  197. package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
  198. package/lib/pages/cms/products/components/DeleteProductButton.cjs +1 -0
  199. package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
  200. package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
  201. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs +1 -0
  202. package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
  203. package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
  204. package/lib/pages/cms/products/components/ProductCategorySelector.cjs +1 -0
  205. package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
  206. package/lib/pages/cms/products/components/ProductForm.cjs +1 -0
  207. package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
  208. package/lib/pages/cms/products/components/ProductMediaManager.cjs +1 -0
  209. package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
  210. package/lib/pages/cms/products/components/ProductsBulkTable.cjs +1 -0
  211. package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
  212. package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
  213. package/lib/pages/cms/products/components/SaleScheduleFields.cjs +1 -0
  214. package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
  215. package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
  216. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs +1 -0
  217. package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
  218. package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
  219. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs +5 -0
  220. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
  221. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
  222. package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
  223. package/lib/pages/cms/products/components/VariationsEditor.cjs +1 -0
  224. package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
  225. package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
  226. package/lib/pages/cms/products/index.cjs +1 -0
  227. package/lib/pages/cms/products/index.es.js +8 -0
  228. package/lib/pages/cms/products/inventory/InventoryPage.cjs +1 -0
  229. package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
  230. package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
  231. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs +2 -0
  232. package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
  233. package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
  234. package/lib/pages/cms/products/inventory/actions.cjs +3 -0
  235. package/lib/pages/cms/products/inventory/actions.es.js +83 -91
  236. package/lib/pages/cms/products/new/NewProductPage.cjs +1 -0
  237. package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
  238. package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
  239. package/lib/pages/cms/products/product-price-sync.cjs +1 -0
  240. package/lib/pages/cms/products/product-price-sync.es.js +74 -89
  241. package/lib/pages/cms/products/server-actions.cjs +1 -0
  242. package/lib/pages/cms/products/server-actions.es.js +250 -233
  243. package/lib/pages/cms/shipping/ShippingPage.cjs +5 -0
  244. package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
  245. package/lib/pages/cms/shipping/components/RateForm.cjs +1 -0
  246. package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
  247. package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
  248. package/lib/pages/cms/shipping/components/ZoneForm.cjs +1 -0
  249. package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
  250. package/lib/pages/cms/shipping/index.cjs +1 -0
  251. package/lib/pages/cms/shipping/index.es.js +3 -0
  252. package/lib/pages/cms/shipping/server-actions.cjs +1 -0
  253. package/lib/pages/cms/shipping/server-actions.es.js +131 -149
  254. package/lib/pages/cms/taxes/TaxesPage.cjs +1 -0
  255. package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
  256. package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
  257. package/lib/pages/cms/taxes/actions.cjs +1 -0
  258. package/lib/pages/cms/taxes/actions.es.js +41 -53
  259. package/lib/pages/cms/taxes/components/TaxRateForm.cjs +1 -0
  260. package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
  261. package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
  262. package/lib/pages/cms/taxes/index.cjs +1 -0
  263. package/lib/pages/cms/taxes/index.es.js +3 -0
  264. package/lib/payment-config.cjs +1 -0
  265. package/lib/payment-config.es.js +110 -126
  266. package/lib/product-actions.cjs +238 -0
  267. package/lib/product-actions.es.js +289 -544
  268. package/lib/product-context.cjs +1 -0
  269. package/lib/product-context.es.js +13 -15
  270. package/lib/product-schema.cjs +1 -0
  271. package/lib/product-schema.es.js +99 -134
  272. package/lib/providers/freemius.cjs +1 -0
  273. package/lib/providers/freemius.es.js +446 -530
  274. package/lib/providers/stripe.cjs +1 -0
  275. package/lib/providers/stripe.es.js +417 -477
  276. package/lib/server-actions/coupon-actions.cjs +1 -0
  277. package/lib/server-actions/coupon-actions.es.js +22 -22
  278. package/lib/server-actions/customer-actions.cjs +1 -0
  279. package/lib/server-actions/customer-actions.es.js +26 -28
  280. package/lib/server-actions/product-actions.cjs +1 -0
  281. package/lib/server-actions/product-actions.es.js +9 -15
  282. package/lib/server-actions/shipping-actions.cjs +1 -0
  283. package/lib/server-actions/shipping-actions.es.js +27 -24
  284. package/lib/server-actions/tax-actions.cjs +1 -0
  285. package/lib/server-actions/tax-actions.es.js +33 -39
  286. package/lib/shared-inventory.cjs +15 -0
  287. package/lib/shared-inventory.es.js +111 -160
  288. package/lib/shipping/resolver.cjs +7 -0
  289. package/lib/shipping/resolver.es.js +44 -61
  290. package/lib/shipping-rate-currency.cjs +1 -0
  291. package/lib/shipping-rate-currency.es.js +52 -67
  292. package/lib/states.cjs +1 -0
  293. package/lib/states.es.js +333 -154
  294. package/lib/stripe/checkout.cjs +1 -0
  295. package/lib/stripe/checkout.es.js +125 -181
  296. package/lib/stripe/client.cjs +1 -0
  297. package/lib/stripe/client.es.js +14 -19
  298. package/lib/stripe/order-sync.cjs +1 -0
  299. package/lib/stripe/order-sync.es.js +106 -126
  300. package/lib/stripe/webhooks.cjs +1 -0
  301. package/lib/stripe/webhooks.es.js +37 -31
  302. package/lib/tax-calculation.cjs +1 -0
  303. package/lib/tax-calculation.es.js +84 -98
  304. package/lib/trials.cjs +1 -0
  305. package/lib/trials.es.js +24 -30
  306. package/lib/types.cjs +1 -0
  307. package/lib/types.es.js +21 -27
  308. package/lib/use-cart.cjs +1 -0
  309. package/lib/use-cart.es.js +38 -40
  310. package/lib/use-price-formatter.cjs +1 -0
  311. package/lib/use-price-formatter.es.js +10 -11
  312. package/lib/variation-utils.cjs +1 -0
  313. package/lib/variation-utils.es.js +199 -261
  314. package/lib/zod-config.cjs +1 -0
  315. package/lib/zod-config.es.js +5 -6
  316. package/package.json +22 -21
  317. package/server.cjs +1 -0
  318. package/server.es.js +56 -211
  319. package/index.cjs.js +0 -1
  320. package/lib/CurrencyProvider.cjs.js +0 -1
  321. package/lib/PaymentReadinessProvider.cjs.js +0 -1
  322. package/lib/cart-store.cjs.js +0 -1
  323. package/lib/components/AccountNavigationMenu.cjs.js +0 -1
  324. package/lib/components/AddToCartButton.cjs.js +0 -1
  325. package/lib/components/Cart.cjs.js +0 -1
  326. package/lib/components/CartDrawer.cjs.js +0 -1
  327. package/lib/components/CartIcon.cjs.js +0 -1
  328. package/lib/components/Checkout.cjs.js +0 -1
  329. package/lib/components/CouponForm.cjs.js +0 -1
  330. package/lib/components/CurrencySwitcher.cjs.js +0 -1
  331. package/lib/components/CustomerProfileForm.cjs.js +0 -1
  332. package/lib/components/FeaturedProduct.cjs.js +0 -1
  333. package/lib/components/FreemiusLicensePanel.cjs.js +0 -1
  334. package/lib/components/InvoiceDocument.cjs.js +0 -1
  335. package/lib/components/InvoiceViewerShell.cjs.js +0 -29
  336. package/lib/components/ProductCard.cjs.js +0 -1
  337. package/lib/components/ProductDetailsLayout.cjs.js +0 -1
  338. package/lib/components/ProductGallery.cjs.js +0 -1
  339. package/lib/components/ProductGrid.cjs.js +0 -1
  340. package/lib/components/ShippingEstimator.cjs.js +0 -1
  341. package/lib/components/ShortDescription.cjs.js +0 -1
  342. package/lib/components/SimpleTiptapRenderer.cjs.js +0 -1
  343. package/lib/components/SubscriptionSelector.cjs.js +0 -1
  344. package/lib/countries.cjs.js +0 -1
  345. package/lib/coupon-server.cjs.js +0 -1
  346. package/lib/coupons.cjs.js +0 -1
  347. package/lib/currency-constants.cjs.js +0 -1
  348. package/lib/currency-rest-client.cjs.js +0 -1
  349. package/lib/currency-store.cjs.js +0 -1
  350. package/lib/currency-sync.cjs.js +0 -1
  351. package/lib/currency.cjs.js +0 -1
  352. package/lib/customer-addresses.cjs.js +0 -1
  353. package/lib/customer-orders.cjs.js +0 -1
  354. package/lib/customer.cjs.js +0 -1
  355. package/lib/export-helpers.cjs.js +0 -1
  356. package/lib/factory.cjs.js +0 -1
  357. package/lib/freemius-coupons.cjs.js +0 -1
  358. package/lib/freemius-license-claim.cjs.js +0 -1
  359. package/lib/freemius-license.cjs.js +0 -1
  360. package/lib/freemius-order-sync.cjs.js +0 -1
  361. package/lib/freemius-trial-provision.cjs.js +0 -1
  362. package/lib/inventory-settings.cjs.js +0 -1
  363. package/lib/invoice-server.cjs.js +0 -33
  364. package/lib/invoice-ui.cjs.js +0 -1
  365. package/lib/invoice.cjs.js +0 -1
  366. package/lib/order-inventory.cjs.js +0 -61
  367. package/lib/order-tax-details.cjs.js +0 -1
  368. package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +0 -1
  369. package/lib/pages/cms/coupons/CouponsPage.cjs.js +0 -5
  370. package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +0 -1
  371. package/lib/pages/cms/coupons/EditCouponPage.cjs.js +0 -1
  372. package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +0 -1
  373. package/lib/pages/cms/coupons/actions.cjs.js +0 -1
  374. package/lib/pages/cms/coupons/product-options.cjs.js +0 -1
  375. package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +0 -1
  376. package/lib/pages/cms/orders/OrderDetailPage.cjs.js +0 -1
  377. package/lib/pages/cms/orders/OrderPrintButton.cjs.js +0 -1
  378. package/lib/pages/cms/orders/OrderStatusForm.cjs.js +0 -1
  379. package/lib/pages/cms/orders/OrdersPage.cjs.js +0 -1
  380. package/lib/pages/cms/orders/actions.cjs.js +0 -7
  381. package/lib/pages/cms/orders/export-actions.cjs.js +0 -1
  382. package/lib/pages/cms/orders/server-actions.cjs.js +0 -1
  383. package/lib/pages/cms/payments/PaymentsClient.cjs.js +0 -1
  384. package/lib/pages/cms/payments/PaymentsPage.cjs.js +0 -1
  385. package/lib/pages/cms/payments/actions.cjs.js +0 -1
  386. package/lib/pages/cms/payments/queries.cjs.js +0 -1
  387. package/lib/pages/cms/products/ProductsPage.cjs.js +0 -1
  388. package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +0 -1
  389. package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +0 -156
  390. package/lib/pages/cms/products/actions.cjs.js +0 -44
  391. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +0 -1
  392. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +0 -1
  393. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +0 -1
  394. package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +0 -1
  395. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +0 -1
  396. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +0 -1
  397. package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +0 -1
  398. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +0 -1
  399. package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +0 -1
  400. package/lib/pages/cms/products/components/ProductForm.cjs.js +0 -1
  401. package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +0 -1
  402. package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +0 -1
  403. package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +0 -1
  404. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +0 -1
  405. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +0 -5
  406. package/lib/pages/cms/products/components/VariationsEditor.cjs.js +0 -1
  407. package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +0 -1
  408. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +0 -2
  409. package/lib/pages/cms/products/inventory/actions.cjs.js +0 -3
  410. package/lib/pages/cms/products/new/NewProductPage.cjs.js +0 -1
  411. package/lib/pages/cms/products/product-price-sync.cjs.js +0 -1
  412. package/lib/pages/cms/products/server-actions.cjs.js +0 -1
  413. package/lib/pages/cms/shipping/ShippingPage.cjs.js +0 -5
  414. package/lib/pages/cms/shipping/components/RateForm.cjs.js +0 -1
  415. package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +0 -1
  416. package/lib/pages/cms/shipping/server-actions.cjs.js +0 -1
  417. package/lib/pages/cms/taxes/TaxesPage.cjs.js +0 -1
  418. package/lib/pages/cms/taxes/actions.cjs.js +0 -1
  419. package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +0 -1
  420. package/lib/payment-config.cjs.js +0 -1
  421. package/lib/product-actions.cjs.js +0 -238
  422. package/lib/product-context.cjs.js +0 -1
  423. package/lib/product-schema.cjs.js +0 -1
  424. package/lib/providers/freemius.cjs.js +0 -5
  425. package/lib/providers/stripe.cjs.js +0 -1
  426. package/lib/server-actions/coupon-actions.cjs.js +0 -1
  427. package/lib/server-actions/customer-actions.cjs.js +0 -1
  428. package/lib/server-actions/product-actions.cjs.js +0 -1
  429. package/lib/server-actions/shipping-actions.cjs.js +0 -1
  430. package/lib/server-actions/tax-actions.cjs.js +0 -1
  431. package/lib/shared-inventory.cjs.js +0 -15
  432. package/lib/shipping/resolver.cjs.js +0 -7
  433. package/lib/shipping-rate-currency.cjs.js +0 -1
  434. package/lib/states.cjs.js +0 -1
  435. package/lib/stripe/checkout.cjs.js +0 -1
  436. package/lib/stripe/client.cjs.js +0 -1
  437. package/lib/stripe/order-sync.cjs.js +0 -1
  438. package/lib/stripe/webhooks.cjs.js +0 -1
  439. package/lib/tax-calculation.cjs.js +0 -1
  440. package/lib/trials.cjs.js +0 -1
  441. package/lib/types.cjs.js +0 -1
  442. package/lib/use-cart.cjs.js +0 -1
  443. package/lib/use-price-formatter.cjs.js +0 -1
  444. package/lib/variation-utils.cjs.js +0 -1
  445. package/lib/zod-config.cjs.js +0 -1
  446. package/server.cjs.js +0 -1
@@ -1,1114 +1,1098 @@
1
- 'use client';
2
- import { jsxs as r, jsx as e, Fragment as ht } from "react/jsx-runtime";
3
- import { Badge as Xe } from "@nextblock-cms/ui/badge";
4
- import { Button as ke } from "@nextblock-cms/ui/button";
5
- import { Card as X, CardHeader as Y, CardTitle as W, CardContent as Z } from "@nextblock-cms/ui/card";
6
- import { Checkbox as gt } from "@nextblock-cms/ui/checkbox";
7
- import { Input as j } from "@nextblock-cms/ui/input";
8
- import { Label as b } from "@nextblock-cms/ui/label";
9
- import { Separator as ft } from "@nextblock-cms/ui/separator";
10
- import { RadioGroup as Ue, RadioGroupItem as Ce } from "@nextblock-cms/ui/radio-group";
11
- import { Checkout as _t } from "@freemius/checkout";
12
- import { getCartItemActivePrice as Ae } from "../cart-store.es.js";
13
- import { useCart as yt } from "../use-cart.es.js";
14
- import { useState as y, useMemo as F, useEffect as V } from "react";
15
- import { X as bt, FlaskConical as xt, CreditCard as vt, ChevronRight as Nt, Loader2 as Se, Package as wt, Download as kt, MapPin as Ct } from "lucide-react";
16
- import { useTranslations as Ye } from "@nextblock-cms/utils";
17
- import { usePriceFormatter as St } from "../use-price-formatter.es.js";
18
- import { normalizeCountryCode as $t, countries as Ft } from "../countries.es.js";
19
- import { usePaymentReadiness as At } from "../PaymentReadinessProvider.es.js";
20
- import { getShippingEstimates as Tt } from "../server-actions/shipping-actions.es.js";
21
- import { getTaxEstimate as jt } from "../server-actions/tax-actions.es.js";
22
- import { isDigitalItem as $e } from "../types.es.js";
23
- import { countryUsesStructuredStates as pe, getStatesForCountry as Je, getSubdivisionLabel as Et } from "../states.es.js";
24
- import { addressesMatch as It, emptyCustomerAddress as Mt, normalizeCustomerAddress as Te, isCustomerAddressComplete as Ge } from "../customer.es.js";
25
- import { useCurrency as Dt } from "../CurrencyProvider.es.js";
26
- import { getTrialSummary as He } from "../trials.es.js";
27
- import { CouponForm as Lt } from "./CouponForm.es.js";
28
- const Rt = process.env.NEXT_PUBLIC_IS_SANDBOX === "true", me = "nextblock-checkout-draft-v1";
29
- function ue(n, o) {
30
- return {
31
- ...Mt(),
32
- company_name: n?.company_name || "",
33
- recipient_name: n?.recipient_name || o || "",
34
- line1: n?.line1 || "",
35
- line2: n?.line2 || "",
36
- city: n?.city || "",
37
- state: n?.state || "",
38
- postal_code: n?.postal_code || "",
39
- country_code: $t(n?.country_code) || "CA"
40
- };
1
+ "use client";
2
+ import { isDigitalItem as e } from "../types.es.js";
3
+ import { useCurrency as t } from "../CurrencyProvider.es.js";
4
+ import { getCartItemActivePrice as n } from "../cart-store.es.js";
5
+ import { useCart as r } from "../use-cart.es.js";
6
+ import { usePriceFormatter as i } from "../use-price-formatter.es.js";
7
+ import { getTrialSummary as a } from "../trials.es.js";
8
+ import { CouponForm as o } from "./CouponForm.es.js";
9
+ import { countries as s, normalizeCountryCode as c } from "../countries.es.js";
10
+ import { countryUsesStructuredStates as l, getStatesForCountry as ee, getSubdivisionLabel as te } from "../states.es.js";
11
+ import { getShippingEstimates as ne } from "../server-actions/shipping-actions.es.js";
12
+ import { usePaymentReadiness as re } from "../PaymentReadinessProvider.es.js";
13
+ import { getTaxEstimate as ie } from "../server-actions/tax-actions.es.js";
14
+ import { addressesMatch as ae, emptyCustomerAddress as u, isCustomerAddressComplete as oe, normalizeCustomerAddress as se } from "../customer.es.js";
15
+ import { Badge as ce } from "@nextblock-cms/ui/badge";
16
+ import { Button as le } from "@nextblock-cms/ui/button";
17
+ import { useEffect as d, useMemo as f, useState as p } from "react";
18
+ import { ChevronRight as ue, CreditCard as de, Download as fe, FlaskConical as pe, Loader2 as me, MapPin as m, Package as he, X as ge } from "lucide-react";
19
+ import { useTranslations as _e } from "@nextblock-cms/utils";
20
+ import { Fragment as ve, jsx as h, jsxs as g } from "react/jsx-runtime";
21
+ import { Input as _ } from "@nextblock-cms/ui/input";
22
+ import { Label as v } from "@nextblock-cms/ui/label";
23
+ import { Card as y, CardContent as b, CardHeader as x, CardTitle as S } from "@nextblock-cms/ui/card";
24
+ import { Checkbox as ye } from "@nextblock-cms/ui/checkbox";
25
+ import { Separator as be } from "@nextblock-cms/ui/separator";
26
+ import { RadioGroup as xe, RadioGroupItem as Se } from "@nextblock-cms/ui/radio-group";
27
+ import { Checkout as Ce } from "@freemius/checkout";
28
+ //#region src/lib/components/Checkout.tsx
29
+ var we = process.env.NEXT_PUBLIC_IS_SANDBOX === "true", C = "nextblock-checkout-draft-v1";
30
+ function w(e, t) {
31
+ return {
32
+ ...u(),
33
+ company_name: e?.company_name || "",
34
+ recipient_name: e?.recipient_name || t || "",
35
+ line1: e?.line1 || "",
36
+ line2: e?.line2 || "",
37
+ city: e?.city || "",
38
+ state: e?.state || "",
39
+ postal_code: e?.postal_code || "",
40
+ country_code: c(e?.country_code) || "CA"
41
+ };
41
42
  }
42
- function qt(n) {
43
- const o = Te(n);
44
- return !(!o?.country_code || !o.postal_code || pe(o.country_code) && !o.state);
43
+ function Te(e) {
44
+ let t = se(e);
45
+ return !(!t?.country_code || !t.postal_code || l(t.country_code) && !t.state);
45
46
  }
46
- function Fe(n, o, A) {
47
- return n.reduce((m, f) => {
48
- const { price: g, sale_price: S } = Ae(f, {
49
- currencyCode: o,
50
- currencies: A
51
- });
52
- return m + (S ?? g) * f.quantity;
53
- }, 0);
47
+ function Ee(e, t, r) {
48
+ return e.reduce((e, i) => {
49
+ let { price: a, sale_price: o } = n(i, {
50
+ currencyCode: t,
51
+ currencies: r
52
+ });
53
+ return e + (o ?? a) * i.quantity;
54
+ }, 0);
54
55
  }
55
- function Qe({
56
- idPrefix: n,
57
- title: o,
58
- description: A,
59
- value: m,
60
- onChange: f
61
- }) {
62
- const { t: g, lang: S } = Ye(), E = F(() => {
63
- try {
64
- return new Intl.DisplayNames([S], { type: "region" });
65
- } catch {
66
- return null;
67
- }
68
- }, [S]), I = g("company_name") === "company_name" ? "Company name" : g("company_name"), ee = g("select_an_option") === "select_an_option" ? "Select an option" : g("select_an_option"), q = g("state_province") === "state_province" ? "State / Province" : g("state_province"), U = Je(m.country_code), K = pe(m.country_code);
69
- return /* @__PURE__ */ r(X, { children: [
70
- /* @__PURE__ */ r(Y, { children: [
71
- /* @__PURE__ */ r(W, { role: "heading", "aria-level": 2, className: "flex items-center gap-2", children: [
72
- /* @__PURE__ */ e(Ct, { className: "w-5 h-5" }),
73
- o
74
- ] }),
75
- /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: A })
76
- ] }),
77
- /* @__PURE__ */ r(Z, { className: "space-y-4", children: [
78
- /* @__PURE__ */ r("div", { className: "grid gap-4 sm:grid-cols-3", children: [
79
- /* @__PURE__ */ r("div", { className: "space-y-2", children: [
80
- /* @__PURE__ */ e(b, { htmlFor: `${n}-company`, children: I }),
81
- /* @__PURE__ */ e(
82
- j,
83
- {
84
- id: `${n}-company`,
85
- name: `${n}-company`,
86
- autoComplete: `${n} organization`,
87
- value: m.company_name,
88
- onChange: (u) => f({ ...m, company_name: u.target.value })
89
- }
90
- )
91
- ] }),
92
- /* @__PURE__ */ r("div", { className: "space-y-2", children: [
93
- /* @__PURE__ */ e(b, { htmlFor: `${n}-name`, children: g("full_name") }),
94
- /* @__PURE__ */ e(
95
- j,
96
- {
97
- id: `${n}-name`,
98
- name: `${n}-name`,
99
- autoComplete: `${n} name`,
100
- required: !0,
101
- value: m.recipient_name,
102
- onChange: (u) => f({ ...m, recipient_name: u.target.value })
103
- }
104
- )
105
- ] }),
106
- /* @__PURE__ */ r("div", { className: "space-y-2", children: [
107
- /* @__PURE__ */ e(b, { htmlFor: `${n}-country`, children: g("country") }),
108
- /* @__PURE__ */ e(
109
- "select",
110
- {
111
- id: `${n}-country`,
112
- name: `${n}-country`,
113
- autoComplete: `${n} country`,
114
- required: !0,
115
- className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
116
- value: m.country_code,
117
- onChange: (u) => {
118
- const te = u.target.value, re = Je(te);
119
- f({
120
- ...m,
121
- country_code: te,
122
- state: re.some((he) => he.code === m.state) ? m.state : ""
123
- });
124
- },
125
- children: Ft.map((u) => /* @__PURE__ */ e("option", { value: u.code, children: E?.of(u.code) ?? u.name }, u.code))
126
- }
127
- )
128
- ] })
129
- ] }),
130
- /* @__PURE__ */ r("div", { className: "space-y-2", children: [
131
- /* @__PURE__ */ e(b, { htmlFor: `${n}-line1`, children: g("address_line_1") }),
132
- /* @__PURE__ */ e(
133
- j,
134
- {
135
- id: `${n}-line1`,
136
- name: `${n}-line1`,
137
- autoComplete: `${n} address-line1`,
138
- required: !0,
139
- value: m.line1,
140
- onChange: (u) => f({ ...m, line1: u.target.value })
141
- }
142
- )
143
- ] }),
144
- /* @__PURE__ */ r("div", { className: "space-y-2", children: [
145
- /* @__PURE__ */ e(b, { htmlFor: `${n}-line2`, children: g("address_line_2") }),
146
- /* @__PURE__ */ e(
147
- j,
148
- {
149
- id: `${n}-line2`,
150
- name: `${n}-line2`,
151
- autoComplete: `${n} address-line2`,
152
- value: m.line2,
153
- onChange: (u) => f({ ...m, line2: u.target.value })
154
- }
155
- )
156
- ] }),
157
- /* @__PURE__ */ r("div", { className: "grid gap-4 sm:grid-cols-3", children: [
158
- /* @__PURE__ */ r("div", { className: "space-y-2", children: [
159
- /* @__PURE__ */ e(b, { htmlFor: `${n}-city`, children: g("city") }),
160
- /* @__PURE__ */ e(
161
- j,
162
- {
163
- id: `${n}-city`,
164
- name: `${n}-city`,
165
- autoComplete: `${n} address-level2`,
166
- required: !0,
167
- value: m.city,
168
- onChange: (u) => f({ ...m, city: u.target.value })
169
- }
170
- )
171
- ] }),
172
- /* @__PURE__ */ r("div", { className: "space-y-2", children: [
173
- /* @__PURE__ */ e(b, { htmlFor: `${n}-state`, children: g("state_province") }),
174
- K ? /* @__PURE__ */ r(
175
- "select",
176
- {
177
- id: `${n}-state`,
178
- name: `${n}-state`,
179
- autoComplete: `${n} address-level1`,
180
- required: !0,
181
- className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
182
- value: m.state,
183
- onChange: (u) => f({ ...m, state: u.target.value }),
184
- children: [
185
- /* @__PURE__ */ e("option", { value: "", children: `${ee}: ${q}` }),
186
- U.map((u) => /* @__PURE__ */ e("option", { value: u.code, children: Et(m.country_code, u, S) }, u.code))
187
- ]
188
- }
189
- ) : /* @__PURE__ */ e(
190
- j,
191
- {
192
- id: `${n}-state`,
193
- name: `${n}-state`,
194
- autoComplete: `${n} address-level1`,
195
- value: m.state,
196
- onChange: (u) => f({ ...m, state: u.target.value })
197
- }
198
- )
199
- ] }),
200
- /* @__PURE__ */ r("div", { className: "space-y-2", children: [
201
- /* @__PURE__ */ e(b, { htmlFor: `${n}-postal`, children: g("postal_zip_code") }),
202
- /* @__PURE__ */ e(
203
- j,
204
- {
205
- id: `${n}-postal`,
206
- name: `${n}-postal`,
207
- autoComplete: `${n} postal-code`,
208
- required: !0,
209
- value: m.postal_code,
210
- onChange: (u) => f({ ...m, postal_code: u.target.value })
211
- }
212
- )
213
- ] })
214
- ] })
215
- ] })
216
- ] });
56
+ function De({ idPrefix: e, title: t, description: n, value: r, onChange: i }) {
57
+ let { t: a, lang: o } = _e(), c = f(() => {
58
+ try {
59
+ return new Intl.DisplayNames([o], { type: "region" });
60
+ } catch {
61
+ return null;
62
+ }
63
+ }, [o]), ne = a("company_name") === "company_name" ? "Company name" : a("company_name"), re = a("select_an_option") === "select_an_option" ? "Select an option" : a("select_an_option"), ie = a("state_province") === "state_province" ? "State / Province" : a("state_province"), ae = ee(r.country_code), u = l(r.country_code);
64
+ return /* @__PURE__ */ g(y, { children: [/* @__PURE__ */ g(x, { children: [/* @__PURE__ */ g(S, {
65
+ role: "heading",
66
+ "aria-level": 2,
67
+ className: "flex items-center gap-2",
68
+ children: [/* @__PURE__ */ h(m, { className: "w-5 h-5" }), t]
69
+ }), /* @__PURE__ */ h("p", {
70
+ className: "text-sm text-muted-foreground",
71
+ children: n
72
+ })] }), /* @__PURE__ */ g(b, {
73
+ className: "space-y-4",
74
+ children: [
75
+ /* @__PURE__ */ g("div", {
76
+ className: "grid gap-4 sm:grid-cols-3",
77
+ children: [
78
+ /* @__PURE__ */ g("div", {
79
+ className: "space-y-2",
80
+ children: [/* @__PURE__ */ h(v, {
81
+ htmlFor: `${e}-company`,
82
+ children: ne
83
+ }), /* @__PURE__ */ h(_, {
84
+ id: `${e}-company`,
85
+ name: `${e}-company`,
86
+ autoComplete: `${e} organization`,
87
+ value: r.company_name,
88
+ onChange: (e) => i({
89
+ ...r,
90
+ company_name: e.target.value
91
+ })
92
+ })]
93
+ }),
94
+ /* @__PURE__ */ g("div", {
95
+ className: "space-y-2",
96
+ children: [/* @__PURE__ */ h(v, {
97
+ htmlFor: `${e}-name`,
98
+ children: a("full_name")
99
+ }), /* @__PURE__ */ h(_, {
100
+ id: `${e}-name`,
101
+ name: `${e}-name`,
102
+ autoComplete: `${e} name`,
103
+ required: !0,
104
+ value: r.recipient_name,
105
+ onChange: (e) => i({
106
+ ...r,
107
+ recipient_name: e.target.value
108
+ })
109
+ })]
110
+ }),
111
+ /* @__PURE__ */ g("div", {
112
+ className: "space-y-2",
113
+ children: [/* @__PURE__ */ h(v, {
114
+ htmlFor: `${e}-country`,
115
+ children: a("country")
116
+ }), /* @__PURE__ */ h("select", {
117
+ id: `${e}-country`,
118
+ name: `${e}-country`,
119
+ autoComplete: `${e} country`,
120
+ required: !0,
121
+ className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
122
+ value: r.country_code,
123
+ onChange: (e) => {
124
+ let t = e.target.value, n = ee(t);
125
+ i({
126
+ ...r,
127
+ country_code: t,
128
+ state: n.some((e) => e.code === r.state) ? r.state : ""
129
+ });
130
+ },
131
+ children: s.map((e) => /* @__PURE__ */ h("option", {
132
+ value: e.code,
133
+ children: c?.of(e.code) ?? e.name
134
+ }, e.code))
135
+ })]
136
+ })
137
+ ]
138
+ }),
139
+ /* @__PURE__ */ g("div", {
140
+ className: "space-y-2",
141
+ children: [/* @__PURE__ */ h(v, {
142
+ htmlFor: `${e}-line1`,
143
+ children: a("address_line_1")
144
+ }), /* @__PURE__ */ h(_, {
145
+ id: `${e}-line1`,
146
+ name: `${e}-line1`,
147
+ autoComplete: `${e} address-line1`,
148
+ required: !0,
149
+ value: r.line1,
150
+ onChange: (e) => i({
151
+ ...r,
152
+ line1: e.target.value
153
+ })
154
+ })]
155
+ }),
156
+ /* @__PURE__ */ g("div", {
157
+ className: "space-y-2",
158
+ children: [/* @__PURE__ */ h(v, {
159
+ htmlFor: `${e}-line2`,
160
+ children: a("address_line_2")
161
+ }), /* @__PURE__ */ h(_, {
162
+ id: `${e}-line2`,
163
+ name: `${e}-line2`,
164
+ autoComplete: `${e} address-line2`,
165
+ value: r.line2,
166
+ onChange: (e) => i({
167
+ ...r,
168
+ line2: e.target.value
169
+ })
170
+ })]
171
+ }),
172
+ /* @__PURE__ */ g("div", {
173
+ className: "grid gap-4 sm:grid-cols-3",
174
+ children: [
175
+ /* @__PURE__ */ g("div", {
176
+ className: "space-y-2",
177
+ children: [/* @__PURE__ */ h(v, {
178
+ htmlFor: `${e}-city`,
179
+ children: a("city")
180
+ }), /* @__PURE__ */ h(_, {
181
+ id: `${e}-city`,
182
+ name: `${e}-city`,
183
+ autoComplete: `${e} address-level2`,
184
+ required: !0,
185
+ value: r.city,
186
+ onChange: (e) => i({
187
+ ...r,
188
+ city: e.target.value
189
+ })
190
+ })]
191
+ }),
192
+ /* @__PURE__ */ g("div", {
193
+ className: "space-y-2",
194
+ children: [/* @__PURE__ */ h(v, {
195
+ htmlFor: `${e}-state`,
196
+ children: a("state_province")
197
+ }), u ? /* @__PURE__ */ g("select", {
198
+ id: `${e}-state`,
199
+ name: `${e}-state`,
200
+ autoComplete: `${e} address-level1`,
201
+ required: !0,
202
+ className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
203
+ value: r.state,
204
+ onChange: (e) => i({
205
+ ...r,
206
+ state: e.target.value
207
+ }),
208
+ children: [/* @__PURE__ */ h("option", {
209
+ value: "",
210
+ children: `${re}: ${ie}`
211
+ }), ae.map((e) => /* @__PURE__ */ h("option", {
212
+ value: e.code,
213
+ children: te(r.country_code, e, o)
214
+ }, e.code))]
215
+ }) : /* @__PURE__ */ h(_, {
216
+ id: `${e}-state`,
217
+ name: `${e}-state`,
218
+ autoComplete: `${e} address-level1`,
219
+ value: r.state,
220
+ onChange: (e) => i({
221
+ ...r,
222
+ state: e.target.value
223
+ })
224
+ })]
225
+ }),
226
+ /* @__PURE__ */ g("div", {
227
+ className: "space-y-2",
228
+ children: [/* @__PURE__ */ h(v, {
229
+ htmlFor: `${e}-postal`,
230
+ children: a("postal_zip_code")
231
+ }), /* @__PURE__ */ h(_, {
232
+ id: `${e}-postal`,
233
+ name: `${e}-postal`,
234
+ autoComplete: `${e} postal-code`,
235
+ required: !0,
236
+ value: r.postal_code,
237
+ onChange: (e) => i({
238
+ ...r,
239
+ postal_code: e.target.value
240
+ })
241
+ })]
242
+ })
243
+ ]
244
+ })
245
+ ]
246
+ })] });
217
247
  }
218
- function Ve({
219
- title: n,
220
- description: o,
221
- badgeLabel: A,
222
- children: m
223
- }) {
224
- return /* @__PURE__ */ r(X, { children: [
225
- /* @__PURE__ */ e(Y, { children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-3 flex-wrap", children: [
226
- /* @__PURE__ */ r("div", { children: [
227
- /* @__PURE__ */ e(W, { role: "heading", "aria-level": 2, children: n }),
228
- /* @__PURE__ */ e("p", { className: "mt-1 text-sm text-muted-foreground", children: o })
229
- ] }),
230
- A ? /* @__PURE__ */ e(Xe, { variant: "secondary", children: A }) : null
231
- ] }) }),
232
- /* @__PURE__ */ e(Z, { className: "space-y-4", children: m })
233
- ] });
248
+ function Oe({ title: e, description: t, badgeLabel: n, children: r }) {
249
+ return /* @__PURE__ */ g(y, { children: [/* @__PURE__ */ h(x, { children: /* @__PURE__ */ g("div", {
250
+ className: "flex items-center justify-between gap-3 flex-wrap",
251
+ children: [/* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h(S, {
252
+ role: "heading",
253
+ "aria-level": 2,
254
+ children: e
255
+ }), /* @__PURE__ */ h("p", {
256
+ className: "mt-1 text-sm text-muted-foreground",
257
+ children: t
258
+ })] }), n ? /* @__PURE__ */ h(ce, {
259
+ variant: "secondary",
260
+ children: n
261
+ }) : null]
262
+ }) }), /* @__PURE__ */ h(b, {
263
+ className: "space-y-4",
264
+ children: r
265
+ })] });
234
266
  }
235
- const mr = ({ initialCustomer: n }) => {
236
- const o = St(), [A, m] = y({}), [f, g] = y(null), [S, E] = y({}), [I, ee] = y(n?.email || ""), [q, U] = y(""), [K, u] = y(n?.phone || ""), [te, re] = y(!1), [he, je] = y(null), [Ee, ne] = y(!1), [We, Ie] = y(!1), [Ze, le] = y(!1), [J, G] = y([]), [T, z] = y(null), [w, se] = y(null), [M, et] = y(null), [k, Me] = y(
237
- () => ue(n?.billingAddress, n?.fullName)
238
- ), [B, De] = y(
239
- () => ue(
240
- n?.shippingAddress ?? n?.billingAddress,
241
- n?.fullName
242
- )
243
- ), [D, Le] = y(
244
- !n?.shippingAddress || It(n?.billingAddress, n?.shippingAddress)
245
- ), H = yt((t) => t), { t: s, lang: ge } = Ye(), { activeCurrencyCode: a, currencies: L } = Dt(), Re = At(), x = H?.items ?? [], v = F(
246
- () => x.filter((t) => !$e(t)),
247
- [x]
248
- ), C = F(
249
- () => x.filter((t) => $e(t)),
250
- [x]
251
- ), P = n?.isAuthenticated ?? !1, l = (t, c, h) => {
252
- const i = s(t, h);
253
- if (i !== t)
254
- return i;
255
- if (!h)
256
- return c;
257
- let _ = c;
258
- return Object.entries(h).forEach(([p, d]) => {
259
- _ = _.replace(
260
- new RegExp(`\\{${p}\\}`, "g"),
261
- String(d)
262
- );
263
- }), _;
264
- }, N = v.length > 0, tt = F(
265
- () => Fe(x, a, L),
266
- [a, L, x]
267
- ), fe = F(
268
- () => Fe(v, a, L),
269
- [a, L, v]
270
- ), _e = F(
271
- () => Fe(C, a, L),
272
- [a, L, C]
273
- ), ye = M?.providerDiscounts.stripe ?? 0, be = M?.providerDiscounts.freemius ?? 0, ce = Math.max(0, fe - ye), rt = Math.max(0, _e - be), $ = F(
274
- () => D ? k : B,
275
- [k, B, D]
276
- ), O = F(
277
- () => N ? $ : k,
278
- [k, N, $]
279
- ), ie = !N || qt($), ae = F(
280
- () => J.find((t) => t.id === T),
281
- [J, T]
282
- ), qe = F(
283
- () => ce + (ae?.amount ?? 0) + (w && !w.isPendingExternalCalculation ? w.amount : 0),
284
- [ce, ae, w]
285
- ), nt = qe + rt;
286
- if (V(() => {
287
- if (!(P || typeof window > "u"))
288
- try {
289
- const t = window.localStorage.getItem(me);
290
- if (!t)
291
- return;
292
- const c = JSON.parse(t);
293
- c.email && ee(c.email), c.phone && u(c.phone), c.billingAddress && Me(ue(c.billingAddress)), c.shippingAddress && De(ue(c.shippingAddress)), typeof c.useBillingForShipping == "boolean" && Le(c.useBillingForShipping), (typeof c.selectedMethodId == "string" || c.selectedMethodId === null) && z(c.selectedMethodId);
294
- } catch (t) {
295
- console.error("[Checkout] Failed to restore checkout draft:", t);
296
- }
297
- }, [P]), V(() => {
298
- if (!(typeof window > "u"))
299
- try {
300
- if (P) {
301
- window.localStorage.removeItem(me);
302
- return;
303
- }
304
- window.localStorage.setItem(
305
- me,
306
- JSON.stringify({
307
- email: I,
308
- phone: K,
309
- billingAddress: k,
310
- shippingAddress: B,
311
- useBillingForShipping: D,
312
- selectedMethodId: T
313
- })
314
- );
315
- } catch {
316
- }
317
- }, [
318
- k,
319
- I,
320
- P,
321
- K,
322
- T,
323
- B,
324
- D
325
- ]), V(() => {
326
- if (!N) {
327
- G([]), z(null), ne(!1);
328
- return;
329
- }
330
- if (!ie) {
331
- G([]), z(null), ne(!1);
332
- return;
333
- }
334
- let t = !1;
335
- const h = setTimeout(async () => {
336
- if ($.country_code) {
337
- ne(!0), Ie(!1);
338
- try {
339
- const i = await Tt(
340
- ce,
341
- {
342
- country: $.country_code,
343
- state: $.state,
344
- postal_code: $.postal_code
345
- },
346
- ge,
347
- a
348
- );
349
- if (t)
350
- return;
351
- if (i.success && i.methods) {
352
- const _ = i.methods;
353
- G(_), z(
354
- (p) => p && _.some((d) => d.id === p) ? p : _[0]?.id ?? null
355
- );
356
- } else
357
- G([]), z(null);
358
- } catch (i) {
359
- if (t)
360
- return;
361
- console.error("[Checkout] Failed to load shipping rates:", i), G([]), z(null), Ie(!0);
362
- } finally {
363
- t || ne(!1);
364
- }
365
- }
366
- }, 400);
367
- return () => {
368
- t = !0, clearTimeout(h);
369
- };
370
- }, [
371
- a,
372
- N,
373
- ie,
374
- ge,
375
- $.country_code,
376
- $.postal_code,
377
- $.state,
378
- ce
379
- ]), V(() => {
380
- let t = !1;
381
- const h = setTimeout(async () => {
382
- if (!N || !O.country_code) {
383
- le(!1), se(null);
384
- return;
385
- }
386
- if (pe(O.country_code) && !O.state) {
387
- le(!1), se(null);
388
- return;
389
- }
390
- le(!0);
391
- try {
392
- const i = await jt(
393
- v,
394
- {
395
- country_code: O.country_code,
396
- state: O.state
397
- },
398
- a,
399
- M?.code ?? null,
400
- x
401
- );
402
- if (t)
403
- return;
404
- se(i.success && i.tax ? i.tax : null);
405
- } catch (i) {
406
- if (t)
407
- return;
408
- console.error("[Checkout] Failed to load the tax estimate:", i), se(null);
409
- } finally {
410
- t || le(!1);
411
- }
412
- }, 300);
413
- return () => {
414
- t = !0, clearTimeout(h);
415
- };
416
- }, [
417
- a,
418
- N,
419
- v,
420
- O.country_code,
421
- O.state,
422
- M?.code,
423
- x
424
- ]), V(() => {
425
- const t = (c) => {
426
- c.persisted && g(null);
427
- };
428
- return window.addEventListener("pageshow", t), () => window.removeEventListener("pageshow", t);
429
- }, []), !H)
430
- return /* @__PURE__ */ r("div", { role: "status", "aria-busy": "true", className: "container mx-auto px-4 py-12 md:px-6", children: [
431
- /* @__PURE__ */ e("span", { className: "sr-only", children: s("loading") === "loading" ? "Loading…" : s("loading") }),
432
- /* @__PURE__ */ r("div", { className: "mx-auto max-w-6xl", children: [
433
- /* @__PURE__ */ e("div", { className: "mb-8 h-9 w-48 rounded-md bg-muted" }),
434
- /* @__PURE__ */ r("div", { className: "grid gap-8 lg:grid-cols-12 lg:items-start", children: [
435
- /* @__PURE__ */ r("div", { className: "space-y-6 lg:col-span-8", children: [
436
- /* @__PURE__ */ e("div", { className: "h-56 rounded-xl border bg-muted/40" }),
437
- /* @__PURE__ */ e("div", { className: "h-96 rounded-xl border bg-muted/40" })
438
- ] }),
439
- /* @__PURE__ */ e("div", { className: "lg:col-span-4", children: /* @__PURE__ */ e("div", { className: "h-72 rounded-xl border bg-muted/40" }) })
440
- ] })
441
- ] })
442
- ] });
443
- const xe = () => {
444
- re(!1), je(null);
445
- }, ze = te ? /* @__PURE__ */ e(
446
- "div",
447
- {
448
- className: "fixed inset-0 z-50 flex items-center justify-center overscroll-contain bg-black/60 backdrop-blur-sm",
449
- onClick: xe,
450
- onKeyDown: (t) => {
451
- t.key === "Escape" && xe();
452
- },
453
- children: /* @__PURE__ */ r(
454
- "div",
455
- {
456
- role: "dialog",
457
- "aria-modal": "true",
458
- "aria-labelledby": "sandbox-checkout-title",
459
- className: "relative bg-background border rounded-xl shadow-2xl p-8 max-w-md mx-4",
460
- onClick: (t) => t.stopPropagation(),
461
- children: [
462
- /* @__PURE__ */ e(
463
- "button",
464
- {
465
- type: "button",
466
- autoFocus: !0,
467
- onClick: xe,
468
- "aria-label": l("close", "Close"),
469
- className: "absolute top-4 right-4 inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-foreground transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",
470
- children: /* @__PURE__ */ e(bt, { className: "w-5 h-5" })
471
- }
472
- ),
473
- /* @__PURE__ */ r("div", { className: "flex items-center gap-3 mb-4", children: [
474
- /* @__PURE__ */ e("div", { className: "p-2 rounded-full bg-amber-100 dark:bg-amber-900/20", children: /* @__PURE__ */ e(xt, { className: "h-6 w-6 text-amber-600 dark:text-amber-400" }) }),
475
- /* @__PURE__ */ e("h2", { id: "sandbox-checkout-title", className: "text-xl font-semibold", children: s("ecommerce.checkout_successful") })
476
- ] }),
477
- /* @__PURE__ */ e("p", { className: "text-muted-foreground mb-2", children: s("ecommerce.sandbox_notice") }),
478
- /* @__PURE__ */ e("p", { className: "text-muted-foreground mb-2", children: he === "stripe" ? l(
479
- "ecommerce.sandbox_checkout_stripe_description",
480
- "This simulated step represents the Stripe checkout for physical products."
481
- ) : l(
482
- "ecommerce.sandbox_checkout_freemius_description",
483
- "This simulated step represents the Freemius checkout for digital products."
484
- ) }),
485
- /* @__PURE__ */ e("p", { className: "text-muted-foreground mb-6", children: s("ecommerce.license_notice") }),
486
- /* @__PURE__ */ e(
487
- "a",
488
- {
489
- href: "https://nextblock.dev",
490
- target: "_blank",
491
- rel: "noopener noreferrer",
492
- className: "block w-full text-center py-3 px-4 rounded-lg bg-primary text-primary-foreground font-semibold hover:opacity-90 transition-opacity",
493
- children: s("ecommerce.purchase_at")
494
- }
495
- )
496
- ]
497
- }
498
- )
499
- }
500
- ) : null, oe = (t, c, h) => (E((i) => ({ ...i, [t]: c })), h && document.getElementById(h)?.focus(), null), ve = (t, c) => c.recipient_name.trim() ? c.line1.trim() ? c.city.trim() ? pe(c.country_code) && !c.state ? `${t}-state` : c.postal_code.trim() ? `${t}-line1` : `${t}-postal` : `${t}-city` : `${t}-line1` : `${t}-name`, lt = (t) => {
501
- if (!P && (!I || !/^\S+@\S+\.\S+$/.test(I)))
502
- return U(s("ecommerce.invalid_email")), oe(t, s("ecommerce.invalid_email"), "checkout-email");
503
- const c = Te(k);
504
- if (!Ge(c))
505
- return oe(
506
- t,
507
- s("checkout_complete_billing_address"),
508
- ve("billing", k)
509
- );
510
- const h = N ? Te(D ? k : B) : null;
511
- if (t === "stripe") {
512
- if (!Ge(h))
513
- return oe(
514
- t,
515
- s("checkout_complete_shipping_address"),
516
- D ? ve("billing", k) : ve("shipping", B)
517
- );
518
- if (!T)
519
- return oe(
520
- t,
521
- l(
522
- "ecommerce.shipping_method_required",
523
- "Please select a shipping method before continuing."
524
- )
525
- );
526
- }
527
- return U(""), {
528
- normalizedBillingAddress: c,
529
- normalizedShippingAddress: h
530
- };
531
- }, Be = async (t, c, h) => {
532
- E((_) => ({
533
- ..._,
534
- [t]: ""
535
- }));
536
- const i = lt(t);
537
- if (i) {
538
- if (Rt) {
539
- const _ = new Set(c.map((d) => d.id)), p = x.filter((d) => !_.has(d.id));
540
- if (H.setItems(p), p.length === 0 && H.removeCoupon(), je(t), re(!0), typeof window < "u" && p.length === 0)
541
- try {
542
- window.localStorage.removeItem(me);
543
- } catch {
544
- }
545
- return;
546
- }
547
- g(h);
548
- try {
549
- const _ = await fetch("/api/checkout", {
550
- method: "POST",
551
- headers: { "Content-Type": "application/json" },
552
- body: JSON.stringify({
553
- items: c,
554
- customerEmail: P ? void 0 : I,
555
- customerPhone: K || null,
556
- billingAddress: i.normalizedBillingAddress,
557
- shippingAddress: t === "stripe" ? i.normalizedShippingAddress : null,
558
- shippingMethodId: t === "stripe" ? T : null,
559
- locale: ge,
560
- currencyCode: a,
561
- couponCode: M?.code ?? H.appliedCoupon?.code ?? null,
562
- couponContextItems: x
563
- })
564
- }), p = await _.json();
565
- if (!_.ok) {
566
- const d = p?.errorKey && typeof p.errorKey == "string" ? l(
567
- p.errorKey,
568
- p?.error || l("ecommerce.generic_error", "Something went wrong."),
569
- p.errorParams
570
- ) : p?.error || s("ecommerce.generic_error");
571
- E((Q) => ({
572
- ...Q,
573
- [t]: d
574
- })), g(null);
575
- return;
576
- }
577
- if (p.customProps && p.customProps.provider === "freemius") {
578
- const d = p.customProps;
579
- let Q = null;
580
- const dt = () => {
581
- window.location.href = `/checkout/success?session_id=${d.order_id}`;
582
- }, Ke = (R) => (Q || (Q = fetch("/api/checkout/freemius/sync", {
583
- method: "POST",
584
- headers: { "Content-Type": "application/json" },
585
- body: JSON.stringify({
586
- orderId: d.order_id,
587
- checkoutResponse: R
588
- })
589
- }).then(async (de) => {
590
- if (!de.ok) {
591
- const pt = await de.json().catch(() => null);
592
- console.error("Freemius checkout sync failed:", pt);
593
- }
594
- })), Q), mt = {
595
- product_id: d.plugin_id,
596
- public_key: d.public_key,
597
- sandbox: d.sandbox
598
- }, ut = {
599
- name: s("ecommerce.checkout_overlay_title"),
600
- plan_id: d.plan_id,
601
- ...d.billing_cycle ? { billing_cycle: d.billing_cycle } : {},
602
- ...d.trial ? { trial: d.trial } : {},
603
- ...d.coupon ? { coupon: d.coupon } : {},
604
- user_email: d.user_email,
605
- user_firstname: d.user_firstname,
606
- user_lastname: d.user_lastname,
607
- sandbox: d.sandbox,
608
- purchaseCompleted: function(R) {
609
- Ke(R);
610
- },
611
- success: function(R) {
612
- (async () => {
613
- try {
614
- await Ke(R);
615
- } finally {
616
- dt();
617
- }
618
- })();
619
- }
620
- };
621
- try {
622
- new _t(mt).open(ut), g(null);
623
- } catch (R) {
624
- console.error("[Checkout] Freemius overlay failed to open:", R), E((de) => ({
625
- ...de,
626
- [t]: s("ecommerce.checkout_popup_blocked")
627
- })), p.url && (window.location.href = p.url), g(null);
628
- }
629
- } else p.url ? window.location.href = p.url : (E((d) => ({
630
- ...d,
631
- [t]: s("ecommerce.checkout_failed") + (p.error || l("ecommerce.unknown_error", "Unknown error"))
632
- })), g(null));
633
- } catch (_) {
634
- console.error(_), E((p) => ({
635
- ...p,
636
- [t]: s("ecommerce.generic_error")
637
- })), g(null);
638
- }
639
- }
640
- };
641
- if (x.length === 0)
642
- return /* @__PURE__ */ r(ht, { children: [
643
- ze,
644
- /* @__PURE__ */ r("div", { className: "container mx-auto flex min-h-[50vh] flex-col items-center justify-center p-8 text-center", children: [
645
- /* @__PURE__ */ e("h1", { className: "mb-4 text-2xl font-bold", children: s("ecommerce.cart_empty") }),
646
- /* @__PURE__ */ e("p", { className: "mb-8 text-muted-foreground", children: s("ecommerce.cart_empty_description") }),
647
- /* @__PURE__ */ e(ke, { asChild: !0, children: /* @__PURE__ */ e("a", { href: "/shop", children: s("ecommerce.go_to_shop") }) })
648
- ] })
649
- ] });
650
- const Pe = l(
651
- "ecommerce.checkout_payments_unavailable",
652
- "This store is not able to take payments right now. Please contact the seller to complete your purchase."
653
- ), Oe = Re.stripe ? null : Pe, Ne = Re.freemius ? null : Pe, we = Oe || (N ? ie ? Ee ? l(
654
- "ecommerce.calculating_shipping",
655
- "Calculating shipping..."
656
- ) : T ? null : J.length > 0 ? s("ecommerce.select_rate") : s("ecommerce.no_rates_for_region") : l(
657
- "ecommerce.waiting_on_address_info",
658
- "Complete your shipping address to view available shipping options."
659
- ) : null), st = f !== null || we !== null, ct = v.length === 1 ? l("ecommerce.item_count_one", "{count} item", {
660
- count: v.length
661
- }) : l("ecommerce.item_count_other", "{count} items", {
662
- count: v.length
663
- }), it = C.length === 1 ? l("ecommerce.license_count_one", "{count} license", {
664
- count: C.length
665
- }) : l("ecommerce.license_count_other", "{count} licenses", {
666
- count: C.length
667
- }), at = (t) => $e(t) ? l("ecommerce.digital_label", "Digital") : l("ecommerce.physical_label", "Physical"), ot = (t) => t === "monthly" ? l(
668
- "ecommerce.checkout_billing_cycle_monthly",
669
- "Monthly subscription"
670
- ) : t === "annual" ? l(
671
- "ecommerce.checkout_billing_cycle_annual",
672
- "Annual subscription"
673
- ) : t === "lifetime" ? l(
674
- "ecommerce.checkout_billing_cycle_lifetime",
675
- "Lifetime subscription"
676
- ) : null;
677
- return /* @__PURE__ */ r("div", { className: "container mx-auto px-4 py-12 md:px-6", children: [
678
- ze,
679
- /* @__PURE__ */ r("div", { className: "mx-auto max-w-6xl", children: [
680
- /* @__PURE__ */ e("h1", { className: "mb-8 text-3xl font-bold", children: s("ecommerce.checkout") }),
681
- /* @__PURE__ */ r("div", { className: "grid gap-8 lg:grid-cols-12 lg:items-start", children: [
682
- /* @__PURE__ */ r("div", { className: "lg:col-span-8 space-y-6", children: [
683
- /* @__PURE__ */ r(X, { children: [
684
- /* @__PURE__ */ e(Y, { children: /* @__PURE__ */ r(W, { role: "heading", "aria-level": 2, className: "flex items-center gap-2", children: [
685
- /* @__PURE__ */ e(vt, { className: "w-5 h-5" }),
686
- s("ecommerce.contact_information")
687
- ] }) }),
688
- /* @__PURE__ */ r(Z, { className: "space-y-4", children: [
689
- P ? /* @__PURE__ */ e("div", { className: "rounded-xl border bg-muted/20 p-4 text-sm text-muted-foreground", children: s("checkout_prefill_notice", { email: n?.email || "" }) }) : /* @__PURE__ */ r("div", { className: "space-y-2", children: [
690
- /* @__PURE__ */ r(b, { htmlFor: "checkout-email", children: [
691
- s("ecommerce.email_address"),
692
- " ",
693
- /* @__PURE__ */ e("span", { className: "text-destructive", children: "*" })
694
- ] }),
695
- /* @__PURE__ */ e(
696
- j,
697
- {
698
- id: "checkout-email",
699
- name: "email",
700
- type: "email",
701
- autoComplete: "email",
702
- spellCheck: !1,
703
- "aria-invalid": q ? !0 : void 0,
704
- "aria-describedby": q ? "checkout-email-error" : void 0,
705
- placeholder: s("ecommerce.email_placeholder"),
706
- value: I,
707
- onChange: (t) => {
708
- ee(t.target.value), q && U("");
709
- },
710
- required: !0
711
- }
712
- ),
713
- q ? /* @__PURE__ */ e("p", { id: "checkout-email-error", role: "alert", className: "text-xs text-destructive mt-1", children: q }) : null
714
- ] }),
715
- /* @__PURE__ */ r("div", { className: "space-y-2", children: [
716
- /* @__PURE__ */ e(b, { htmlFor: "checkout-phone", children: s("phone_number") }),
717
- /* @__PURE__ */ e(
718
- j,
719
- {
720
- id: "checkout-phone",
721
- name: "phone",
722
- type: "tel",
723
- inputMode: "tel",
724
- autoComplete: "tel",
725
- placeholder: s("optional"),
726
- value: K,
727
- onChange: (t) => u(t.target.value)
728
- }
729
- )
730
- ] })
731
- ] })
732
- ] }),
733
- /* @__PURE__ */ e(
734
- Qe,
735
- {
736
- idPrefix: "billing",
737
- title: s("billing_address"),
738
- description: s("checkout_billing_address_help"),
739
- value: k,
740
- onChange: Me
741
- }
742
- ),
743
- N ? /* @__PURE__ */ r("div", { className: "flex items-center space-x-3 rounded-xl border bg-muted/20 p-4", children: [
744
- /* @__PURE__ */ e(
745
- gt,
746
- {
747
- id: "use-billing-for-shipping",
748
- checked: D,
749
- onCheckedChange: (t) => Le(!!t)
750
- }
751
- ),
752
- /* @__PURE__ */ r("div", { className: "space-y-1", children: [
753
- /* @__PURE__ */ e(b, { htmlFor: "use-billing-for-shipping", className: "cursor-pointer", children: s("use_billing_for_shipping") }),
754
- /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: s("checkout_use_billing_for_shipping_help") })
755
- ] })
756
- ] }) : null,
757
- N && !D ? /* @__PURE__ */ e(
758
- Qe,
759
- {
760
- idPrefix: "shipping",
761
- title: s("shipping_address"),
762
- description: s("checkout_shipping_address_help"),
763
- value: B,
764
- onChange: De
765
- }
766
- ) : null,
767
- N ? /* @__PURE__ */ r(X, { children: [
768
- /* @__PURE__ */ e(Y, { children: /* @__PURE__ */ r(W, { role: "heading", "aria-level": 2, className: "flex items-center gap-2", children: [
769
- /* @__PURE__ */ e(Nt, { className: "w-5 h-5 text-primary" }),
770
- s("ecommerce.shipping_method")
771
- ] }) }),
772
- /* @__PURE__ */ e(Z, { children: Ee ? /* @__PURE__ */ r("div", { role: "status", className: "flex items-center justify-center py-6", children: [
773
- /* @__PURE__ */ e(Se, { className: "w-6 h-6 animate-spin text-muted-foreground" }),
774
- /* @__PURE__ */ e("span", { className: "sr-only", children: l("ecommerce.calculating_shipping", "Calculating shipping…") })
775
- ] }) : We ? /* @__PURE__ */ e("div", { role: "alert", className: "rounded-lg bg-destructive/10 px-4 py-3 text-center text-sm text-destructive", children: l(
776
- "ecommerce.shipping_calculation_failed",
777
- "We couldn't calculate shipping right now. Please try again."
778
- ) }) : J.length > 0 ? (
779
- // A real radio group. These rows used to be <div onClick>: no role, no
780
- // tab stop, no keys, so a keyboard user could not change the shipping method.
781
- /* @__PURE__ */ e(
782
- Ue,
783
- {
784
- value: T ?? "",
785
- onValueChange: z,
786
- "aria-label": s("ecommerce.shipping_method"),
787
- className: "space-y-3",
788
- children: J.map((t) => /* @__PURE__ */ r(
789
- b,
790
- {
791
- htmlFor: `shipping-method-${t.id}`,
792
- className: `flex items-center justify-between gap-3 p-4 rounded-lg border-2 cursor-pointer transition-colors ${T === t.id ? "border-primary bg-primary/5" : "border-border hover:border-muted-foreground/40"}`,
793
- children: [
794
- /* @__PURE__ */ r("span", { className: "flex min-w-0 items-center gap-3", children: [
795
- /* @__PURE__ */ e(Ce, { id: `shipping-method-${t.id}`, value: t.id }),
796
- /* @__PURE__ */ e("span", { className: "font-medium break-words", children: t.name })
797
- ] }),
798
- /* @__PURE__ */ e("span", { className: "font-bold tabular-nums", children: o(t.amount, a) })
799
- ]
800
- },
801
- t.id
802
- ))
803
- }
804
- )
805
- ) : /* @__PURE__ */ e("div", { className: "py-4 text-center text-muted-foreground bg-muted/30 rounded-lg italic", children: ie ? s("ecommerce.no_rates_for_region") : l(
806
- "ecommerce.waiting_on_address_info",
807
- "Complete your shipping address to view available shipping options."
808
- ) }) })
809
- ] }) : null
810
- ] }),
811
- /* @__PURE__ */ r("div", { className: "lg:col-span-4 space-y-6", children: [
812
- /* @__PURE__ */ r(X, { className: "top-6", children: [
813
- /* @__PURE__ */ e(Y, { children: /* @__PURE__ */ e(W, { role: "heading", "aria-level": 2, children: s("ecommerce.order_summary") }) }),
814
- /* @__PURE__ */ r(Z, { className: "space-y-4", children: [
815
- /* @__PURE__ */ e("div", { className: "space-y-3 max-h-[260px] overflow-y-auto pr-2", children: x.map((t) => {
816
- const c = Ae(t, {
817
- currencyCode: a,
818
- currencies: L
819
- }), h = He(t, s);
820
- return /* @__PURE__ */ r("div", { className: "flex items-start justify-between gap-4", children: [
821
- /* @__PURE__ */ r("div", { className: "flex gap-3", children: [
822
- t.image_url ? /* @__PURE__ */ e("div", { className: "h-10 w-10 shrink-0 overflow-hidden rounded border bg-neutral-100", children: /* @__PURE__ */ e("img", { src: t.image_url, alt: t.title, className: "h-full w-full object-cover" }) }) : null,
823
- /* @__PURE__ */ r("div", { className: "grid gap-0.5", children: [
824
- /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
825
- /* @__PURE__ */ e("span", { className: "font-medium text-xs line-clamp-1", children: t.title }),
826
- /* @__PURE__ */ e(Xe, { variant: "outline", className: "text-[9px] uppercase", children: at(t) })
827
- ] }),
828
- t.variant_label ? /* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground line-clamp-1", children: t.variant_label }) : null,
829
- /* @__PURE__ */ r("span", { className: "text-[10px] text-muted-foreground", children: [
830
- s("ecommerce.qty"),
831
- ": ",
832
- t.quantity
833
- ] }),
834
- h ? /* @__PURE__ */ r("span", { className: "text-[10px] font-medium text-emerald-700", children: [
835
- h.label,
836
- " - ",
837
- h.paymentRequirementLabel
838
- ] }) : null
839
- ] })
840
- ] }),
841
- /* @__PURE__ */ r("div", { className: "flex flex-col items-end gap-0.5 shrink-0", children: [
842
- /* @__PURE__ */ e("span", { className: "font-medium text-xs", children: o(
843
- (c.sale_price ?? c.price) * t.quantity,
844
- a
845
- ) }),
846
- c.sale_price ? /* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground line-through", children: o(c.price * t.quantity, a) }) : null
847
- ] })
848
- ] }, `${t.id}-${t.variant_id || "base"}`);
849
- }) }),
850
- /* @__PURE__ */ e(ft, {}),
851
- /* @__PURE__ */ e(
852
- Lt,
853
- {
854
- items: x,
855
- currencyCode: a,
856
- onQuoteChange: et
857
- }
858
- ),
859
- /* @__PURE__ */ r("div", { className: "space-y-2 text-sm", children: [
860
- /* @__PURE__ */ r("div", { className: "flex justify-between", children: [
861
- /* @__PURE__ */ e("span", { children: s("ecommerce.subtotal") }),
862
- /* @__PURE__ */ e("span", { children: o(tt, a) })
863
- ] }),
864
- v.length > 0 ? /* @__PURE__ */ r("div", { className: "flex justify-between text-muted-foreground", children: [
865
- /* @__PURE__ */ e("span", { children: l(
866
- "ecommerce.physical_products",
867
- "Physical products"
868
- ) }),
869
- /* @__PURE__ */ e("span", { children: o(fe, a) })
870
- ] }) : null,
871
- C.length > 0 ? /* @__PURE__ */ r("div", { className: "flex justify-between text-muted-foreground", children: [
872
- /* @__PURE__ */ e("span", { children: l(
873
- "ecommerce.digital_products",
874
- "Digital products"
875
- ) }),
876
- /* @__PURE__ */ e("span", { children: o(_e, a) })
877
- ] }) : null,
878
- M ? /* @__PURE__ */ r("div", { className: "flex justify-between text-emerald-600", children: [
879
- /* @__PURE__ */ r("span", { children: [
880
- l("ecommerce.discount", "Discount"),
881
- " (",
882
- M.code,
883
- ")"
884
- ] }),
885
- /* @__PURE__ */ r("span", { children: [
886
- "-",
887
- o(M.discountTotal, a)
888
- ] })
889
- ] }) : null,
890
- (v.length > 0 || C.length > 0) && /* @__PURE__ */ r("div", { className: "flex justify-between font-bold text-lg pt-2 border-t mt-2", children: [
891
- /* @__PURE__ */ e("span", { children: l(
892
- "ecommerce.estimated_total",
893
- "Estimated total"
894
- ) }),
895
- /* @__PURE__ */ e("span", { className: "text-primary", children: o(nt, a) })
896
- ] })
897
- ] })
898
- ] })
899
- ] }),
900
- v.length > 0 ? /* @__PURE__ */ r(
901
- Ve,
902
- {
903
- title: l(
904
- "ecommerce.stripe_checkout_title",
905
- "Stripe Checkout"
906
- ),
907
- description: l(
908
- "ecommerce.stripe_checkout_description",
909
- "Pay for physical products in one Stripe checkout session."
910
- ),
911
- badgeLabel: ct,
912
- children: [
913
- /* @__PURE__ */ r("div", { className: "space-y-2 text-sm", children: [
914
- /* @__PURE__ */ r("div", { className: "flex justify-between", children: [
915
- /* @__PURE__ */ e("span", { children: l(
916
- "ecommerce.physical_subtotal",
917
- "Physical subtotal"
918
- ) }),
919
- /* @__PURE__ */ e("span", { children: o(fe, a) })
920
- ] }),
921
- ye > 0 ? /* @__PURE__ */ r("div", { className: "flex justify-between text-emerald-600", children: [
922
- /* @__PURE__ */ e("span", { children: l("ecommerce.discount", "Discount") }),
923
- /* @__PURE__ */ r("span", { children: [
924
- "-",
925
- o(ye, a)
926
- ] })
927
- ] }) : null,
928
- /* @__PURE__ */ r("div", { className: "flex justify-between", children: [
929
- /* @__PURE__ */ e("span", { children: s("ecommerce.shipping") }),
930
- /* @__PURE__ */ e("span", { children: ae ? o(ae.amount, a) : "-" })
931
- ] }),
932
- /* @__PURE__ */ r("div", { className: "flex justify-between", children: [
933
- /* @__PURE__ */ e("span", { children: l("ecommerce.tax", "Tax") }),
934
- /* @__PURE__ */ e("span", { children: Ze ? "..." : w?.isPendingExternalCalculation ? l(
935
- "ecommerce.tax_calculated_on_stripe",
936
- "Calculated on Stripe"
937
- ) : w ? o(w.amount, a) : "-" })
938
- ] }),
939
- w && w.lines.length > 0 ? /* @__PURE__ */ e("div", { className: "rounded-lg bg-muted/20 px-3 py-2 text-xs text-muted-foreground", children: w.lines.map((t) => /* @__PURE__ */ r("div", { className: "flex justify-between gap-3", children: [
940
- /* @__PURE__ */ r("span", { children: [
941
- t.name,
942
- " (",
943
- t.rate.toFixed(4),
944
- "%)"
945
- ] }),
946
- /* @__PURE__ */ e("span", { children: o(t.amount, a) })
947
- ] }, t.id || `${t.name}-${t.rate}`)) }) : null,
948
- /* @__PURE__ */ r("div", { className: "flex justify-between font-semibold pt-2 border-t", children: [
949
- /* @__PURE__ */ e("span", { children: l(
950
- "ecommerce.total_on_stripe",
951
- "Total on Stripe"
952
- ) }),
953
- /* @__PURE__ */ e("span", { children: o(qe, a) })
954
- ] })
955
- ] }),
956
- /* @__PURE__ */ r(
957
- ke,
958
- {
959
- className: "w-full",
960
- size: "lg",
961
- onClick: () => Be("stripe", v, "stripe"),
962
- disabled: st,
963
- children: [
964
- f === "stripe" ? /* @__PURE__ */ e(Se, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ e(wt, { className: "mr-2 h-4 w-4" }),
965
- f === "stripe" ? s("ecommerce.processing") : l(
966
- "ecommerce.checkout_physical_products",
967
- "Checkout Physical Products"
968
- )
969
- ]
970
- }
971
- ),
972
- we && f === null ? /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground", children: we }) : null,
973
- S.stripe ? /* @__PURE__ */ e("div", { role: "alert", className: "rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive", children: S.stripe }) : null,
974
- /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground", children: w?.isPendingExternalCalculation ? l(
975
- "checkout_stripe_tax_finalized_notice",
976
- "Tax will be finalized by Stripe Tax on the payment step."
977
- ) : l(
978
- "ecommerce.shipping_taxes_collected_on_stripe",
979
- "Shipping and taxes are only collected during the Stripe step for physical products."
980
- ) })
981
- ]
982
- }
983
- ) : null,
984
- C.length > 0 ? /* @__PURE__ */ r(
985
- Ve,
986
- {
987
- title: l(
988
- "ecommerce.freemius_checkout_title",
989
- "Freemius Checkout"
990
- ),
991
- description: l(
992
- "ecommerce.freemius_checkout_description",
993
- "Digital products use the Freemius checkout flow."
994
- ),
995
- badgeLabel: it,
996
- children: [
997
- /* @__PURE__ */ e("div", { className: "space-y-3", children: C.map((t) => {
998
- const c = Ae(t, {
999
- currencyCode: a,
1000
- currencies: L
1001
- }), h = He(t, s), i = `freemius:${t.id}`, _ = h ? A[i] || "paid" : void 0;
1002
- return /* @__PURE__ */ r("div", { className: "rounded-lg border p-3 space-y-3", children: [
1003
- /* @__PURE__ */ r("div", { className: "flex items-start justify-between gap-3", children: [
1004
- /* @__PURE__ */ r("div", { children: [
1005
- /* @__PURE__ */ e("p", { className: "font-medium", children: t.title }),
1006
- t.billing_cycle ? /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground capitalize", children: ot(t.billing_cycle) }) : null,
1007
- h ? /* @__PURE__ */ r("p", { className: "text-xs font-medium text-emerald-700", children: [
1008
- h.label,
1009
- " - ",
1010
- h.paymentRequirementLabel
1011
- ] }) : null
1012
- ] }),
1013
- /* @__PURE__ */ e("span", { className: "font-medium", children: o(c.sale_price ?? c.price, a) })
1014
- ] }),
1015
- h && !t.trial_requires_payment_method && /* @__PURE__ */ r("div", { className: "bg-muted/30 p-3 rounded-md border text-sm mt-2 mb-3", children: [
1016
- /* @__PURE__ */ e("p", { className: "font-medium mb-3", children: l(
1017
- "ecommerce.freemius_trial_preference_title",
1018
- "How would you like to start your trial?"
1019
- ) }),
1020
- /* @__PURE__ */ r(
1021
- Ue,
1022
- {
1023
- value: A[i] || "paid",
1024
- onValueChange: (p) => m((d) => ({ ...d, [i]: p })),
1025
- className: "gap-3",
1026
- children: [
1027
- /* @__PURE__ */ r("div", { className: "flex items-start space-x-3", children: [
1028
- /* @__PURE__ */ e(Ce, { value: "paid", id: `${i}-paid`, className: "mt-1" }),
1029
- /* @__PURE__ */ r("div", { className: "grid gap-1.5", children: [
1030
- /* @__PURE__ */ e(b, { htmlFor: `${i}-paid`, className: "font-medium leading-none cursor-pointer", children: l(
1031
- "ecommerce.freemius_trial_with_card",
1032
- "Enter Payment Details Now (Still get full trial length free)"
1033
- ) }),
1034
- /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: l(
1035
- "ecommerce.freemius_trial_with_card_help",
1036
- "You will not be billed until the trial ends. Cancel anytime."
1037
- ) })
1038
- ] })
1039
- ] }),
1040
- /* @__PURE__ */ r("div", { className: "flex items-start space-x-3", children: [
1041
- /* @__PURE__ */ e(Ce, { value: "free", id: `${i}-free`, className: "mt-1" }),
1042
- /* @__PURE__ */ e("div", { className: "grid gap-1.5", children: /* @__PURE__ */ e(b, { htmlFor: `${i}-free`, className: "font-medium leading-none cursor-pointer", children: l(
1043
- "ecommerce.freemius_trial_no_card",
1044
- "Start Free Trial (No card required)"
1045
- ) }) })
1046
- ] })
1047
- ]
1048
- }
1049
- )
1050
- ] }),
1051
- /* @__PURE__ */ r(
1052
- ke,
1053
- {
1054
- className: "w-full h-auto min-h-[2.75rem] py-2",
1055
- onClick: () => Be(
1056
- "freemius",
1057
- [
1058
- {
1059
- ...t,
1060
- ..._ ? { trial_preference: _ } : {}
1061
- }
1062
- ],
1063
- i
1064
- ),
1065
- disabled: f !== null || Ne !== null,
1066
- children: [
1067
- f === i ? /* @__PURE__ */ e(Se, { className: "mr-2 h-4 w-4 shrink-0 animate-spin" }) : /* @__PURE__ */ e(kt, { className: "mr-2 h-4 w-4 shrink-0" }),
1068
- /* @__PURE__ */ e("span", { className: "whitespace-normal text-left", children: f === i ? s("ecommerce.processing") : C.length > 1 ? l(
1069
- "ecommerce.checkout_product",
1070
- "Checkout {title}",
1071
- { title: t.title }
1072
- ) : l(
1073
- "ecommerce.checkout_digital_product",
1074
- "Checkout Digital Product"
1075
- ) })
1076
- ]
1077
- }
1078
- )
1079
- ] }, i);
1080
- }) }),
1081
- /* @__PURE__ */ r("div", { className: "flex justify-between text-sm font-semibold border-t pt-3", children: [
1082
- /* @__PURE__ */ e("span", { children: l(
1083
- "ecommerce.digital_subtotal",
1084
- "Digital subtotal"
1085
- ) }),
1086
- /* @__PURE__ */ e("span", { children: o(_e, a) })
1087
- ] }),
1088
- be > 0 ? /* @__PURE__ */ r("div", { className: "flex justify-between text-sm font-semibold text-emerald-600", children: [
1089
- /* @__PURE__ */ e("span", { children: l("ecommerce.discount", "Discount") }),
1090
- /* @__PURE__ */ r("span", { children: [
1091
- "-",
1092
- o(be, a)
1093
- ] })
1094
- ] }) : null,
1095
- Ne ? /* @__PURE__ */ e("div", { className: "rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs", children: Ne }) : null,
1096
- S.freemius ? /* @__PURE__ */ e("div", { role: "alert", className: "rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive", children: S.freemius }) : null,
1097
- /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground", children: C.length > 1 ? l(
1098
- "ecommerce.freemius_multi_checkout_notice",
1099
- "Freemius licenses are completed one at a time, so each digital product gets its own checkout action."
1100
- ) : l(
1101
- "ecommerce.freemius_tax_notice",
1102
- "Taxes and compliance for digital products are handled inside the Freemius checkout."
1103
- ) })
1104
- ]
1105
- }
1106
- ) : null
1107
- ] })
1108
- ] })
1109
- ] })
1110
- ] });
1111
- };
1112
- export {
1113
- mr as Checkout
267
+ var T = ({ initialCustomer: s }) => {
268
+ let c = i(), [ee, te] = p({}), [u, m] = p(null), [T, E] = p({}), [D, ke] = p(s?.email || ""), [O, Ae] = p(""), [k, je] = p(s?.phone || ""), [Me, Ne] = p(!1), [Pe, Fe] = p(null), [Ie, A] = p(!1), [Le, Re] = p(!1), [ze, j] = p(!1), [M, N] = p([]), [P, F] = p(null), [I, L] = p(null), [R, Be] = p(null), [z, Ve] = p(() => w(s?.billingAddress, s?.fullName)), [B, He] = p(() => w(s?.shippingAddress ?? s?.billingAddress, s?.fullName)), [V, Ue] = p(!s?.shippingAddress || ae(s?.billingAddress, s?.shippingAddress)), H = r((e) => e), { t: U, lang: We } = _e(), { activeCurrencyCode: W, currencies: G } = t(), Ge = re(), K = H?.items ?? [], q = f(() => K.filter((t) => !e(t)), [K]), J = f(() => K.filter((t) => e(t)), [K]), Y = s?.isAuthenticated ?? !1, X = (e, t, n) => {
269
+ let r = U(e, n);
270
+ if (r !== e) return r;
271
+ if (!n) return t;
272
+ let i = t;
273
+ return Object.entries(n).forEach(([e, t]) => {
274
+ i = i.replace(RegExp(`\\{${e}\\}`, "g"), String(t));
275
+ }), i;
276
+ }, Z = q.length > 0, Ke = f(() => Ee(K, W, G), [
277
+ W,
278
+ G,
279
+ K
280
+ ]), qe = f(() => Ee(q, W, G), [
281
+ W,
282
+ G,
283
+ q
284
+ ]), Je = f(() => Ee(J, W, G), [
285
+ W,
286
+ G,
287
+ J
288
+ ]), Ye = R?.providerDiscounts.stripe ?? 0, Xe = R?.providerDiscounts.freemius ?? 0, Ze = Math.max(0, qe - Ye), Qe = Math.max(0, Je - Xe), Q = f(() => V ? z : B, [
289
+ z,
290
+ B,
291
+ V
292
+ ]), $ = f(() => Z ? Q : z, [
293
+ z,
294
+ Z,
295
+ Q
296
+ ]), $e = !Z || Te(Q), et = f(() => M.find((e) => e.id === P), [M, P]), tt = f(() => Ze + (et?.amount ?? 0) + (I && !I.isPendingExternalCalculation ? I.amount : 0), [
297
+ Ze,
298
+ et,
299
+ I
300
+ ]), nt = tt + Qe;
301
+ if (d(() => {
302
+ if (!(Y || typeof window > "u")) try {
303
+ let e = window.localStorage.getItem(C);
304
+ if (!e) return;
305
+ let t = JSON.parse(e);
306
+ t.email && ke(t.email), t.phone && je(t.phone), t.billingAddress && Ve(w(t.billingAddress)), t.shippingAddress && He(w(t.shippingAddress)), typeof t.useBillingForShipping == "boolean" && Ue(t.useBillingForShipping), (typeof t.selectedMethodId == "string" || t.selectedMethodId === null) && F(t.selectedMethodId);
307
+ } catch (e) {
308
+ console.error("[Checkout] Failed to restore checkout draft:", e);
309
+ }
310
+ }, [Y]), d(() => {
311
+ if (typeof window < "u") try {
312
+ if (Y) {
313
+ window.localStorage.removeItem(C);
314
+ return;
315
+ }
316
+ window.localStorage.setItem(C, JSON.stringify({
317
+ email: D,
318
+ phone: k,
319
+ billingAddress: z,
320
+ shippingAddress: B,
321
+ useBillingForShipping: V,
322
+ selectedMethodId: P
323
+ }));
324
+ } catch {}
325
+ }, [
326
+ z,
327
+ D,
328
+ Y,
329
+ k,
330
+ P,
331
+ B,
332
+ V
333
+ ]), d(() => {
334
+ if (!Z) {
335
+ N([]), F(null), A(!1);
336
+ return;
337
+ }
338
+ if (!$e) {
339
+ N([]), F(null), A(!1);
340
+ return;
341
+ }
342
+ let e = !1, t = setTimeout(async () => {
343
+ if (Q.country_code) {
344
+ A(!0), Re(!1);
345
+ try {
346
+ let t = await ne(Ze, {
347
+ country: Q.country_code,
348
+ state: Q.state,
349
+ postal_code: Q.postal_code
350
+ }, We, W);
351
+ if (e) return;
352
+ if (t.success && t.methods) {
353
+ let e = t.methods;
354
+ N(e), F((t) => t && e.some((e) => e.id === t) ? t : e[0]?.id ?? null);
355
+ } else N([]), F(null);
356
+ } catch (t) {
357
+ if (e) return;
358
+ console.error("[Checkout] Failed to load shipping rates:", t), N([]), F(null), Re(!0);
359
+ } finally {
360
+ e || A(!1);
361
+ }
362
+ }
363
+ }, 400);
364
+ return () => {
365
+ e = !0, clearTimeout(t);
366
+ };
367
+ }, [
368
+ W,
369
+ Z,
370
+ $e,
371
+ We,
372
+ Q.country_code,
373
+ Q.postal_code,
374
+ Q.state,
375
+ Ze
376
+ ]), d(() => {
377
+ let e = !1, t = setTimeout(async () => {
378
+ if (!Z || !$.country_code) {
379
+ j(!1), L(null);
380
+ return;
381
+ }
382
+ if (l($.country_code) && !$.state) {
383
+ j(!1), L(null);
384
+ return;
385
+ }
386
+ j(!0);
387
+ try {
388
+ let t = await ie(q, {
389
+ country_code: $.country_code,
390
+ state: $.state
391
+ }, W, R?.code ?? null, K);
392
+ if (e) return;
393
+ L(t.success && t.tax ? t.tax : null);
394
+ } catch (t) {
395
+ if (e) return;
396
+ console.error("[Checkout] Failed to load the tax estimate:", t), L(null);
397
+ } finally {
398
+ e || j(!1);
399
+ }
400
+ }, 300);
401
+ return () => {
402
+ e = !0, clearTimeout(t);
403
+ };
404
+ }, [
405
+ W,
406
+ Z,
407
+ q,
408
+ $.country_code,
409
+ $.state,
410
+ R?.code,
411
+ K
412
+ ]), d(() => {
413
+ let e = (e) => {
414
+ e.persisted && m(null);
415
+ };
416
+ return window.addEventListener("pageshow", e), () => window.removeEventListener("pageshow", e);
417
+ }, []), !H) return /* @__PURE__ */ g("div", {
418
+ role: "status",
419
+ "aria-busy": "true",
420
+ className: "container mx-auto px-4 py-12 md:px-6",
421
+ children: [/* @__PURE__ */ h("span", {
422
+ className: "sr-only",
423
+ children: U("loading") === "loading" ? "Loading…" : U("loading")
424
+ }), /* @__PURE__ */ g("div", {
425
+ className: "mx-auto max-w-6xl",
426
+ children: [/* @__PURE__ */ h("div", { className: "mb-8 h-9 w-48 rounded-md bg-muted" }), /* @__PURE__ */ g("div", {
427
+ className: "grid gap-8 lg:grid-cols-12 lg:items-start",
428
+ children: [/* @__PURE__ */ g("div", {
429
+ className: "space-y-6 lg:col-span-8",
430
+ children: [/* @__PURE__ */ h("div", { className: "h-56 rounded-xl border bg-muted/40" }), /* @__PURE__ */ h("div", { className: "h-96 rounded-xl border bg-muted/40" })]
431
+ }), /* @__PURE__ */ h("div", {
432
+ className: "lg:col-span-4",
433
+ children: /* @__PURE__ */ h("div", { className: "h-72 rounded-xl border bg-muted/40" })
434
+ })]
435
+ })]
436
+ })]
437
+ });
438
+ let rt = () => {
439
+ Ne(!1), Fe(null);
440
+ }, it = Me ? /* @__PURE__ */ h("div", {
441
+ className: "fixed inset-0 z-50 flex items-center justify-center overscroll-contain bg-black/60 backdrop-blur-sm",
442
+ onClick: rt,
443
+ onKeyDown: (e) => {
444
+ e.key === "Escape" && rt();
445
+ },
446
+ children: /* @__PURE__ */ g("div", {
447
+ role: "dialog",
448
+ "aria-modal": "true",
449
+ "aria-labelledby": "sandbox-checkout-title",
450
+ className: "relative bg-background border rounded-xl shadow-2xl p-8 max-w-md mx-4",
451
+ onClick: (e) => e.stopPropagation(),
452
+ children: [
453
+ /* @__PURE__ */ h("button", {
454
+ type: "button",
455
+ autoFocus: !0,
456
+ onClick: rt,
457
+ "aria-label": X("close", "Close"),
458
+ className: "absolute top-4 right-4 inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-foreground transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring",
459
+ children: /* @__PURE__ */ h(ge, { className: "w-5 h-5" })
460
+ }),
461
+ /* @__PURE__ */ g("div", {
462
+ className: "flex items-center gap-3 mb-4",
463
+ children: [/* @__PURE__ */ h("div", {
464
+ className: "p-2 rounded-full bg-amber-100 dark:bg-amber-900/20",
465
+ children: /* @__PURE__ */ h(pe, { className: "h-6 w-6 text-amber-600 dark:text-amber-400" })
466
+ }), /* @__PURE__ */ h("h2", {
467
+ id: "sandbox-checkout-title",
468
+ className: "text-xl font-semibold",
469
+ children: U("ecommerce.checkout_successful")
470
+ })]
471
+ }),
472
+ /* @__PURE__ */ h("p", {
473
+ className: "text-muted-foreground mb-2",
474
+ children: U("ecommerce.sandbox_notice")
475
+ }),
476
+ /* @__PURE__ */ h("p", {
477
+ className: "text-muted-foreground mb-2",
478
+ children: Pe === "stripe" ? X("ecommerce.sandbox_checkout_stripe_description", "This simulated step represents the Stripe checkout for physical products.") : X("ecommerce.sandbox_checkout_freemius_description", "This simulated step represents the Freemius checkout for digital products.")
479
+ }),
480
+ /* @__PURE__ */ h("p", {
481
+ className: "text-muted-foreground mb-6",
482
+ children: U("ecommerce.license_notice")
483
+ }),
484
+ /* @__PURE__ */ h("a", {
485
+ href: "https://nextblock.dev",
486
+ target: "_blank",
487
+ rel: "noopener noreferrer",
488
+ className: "block w-full text-center py-3 px-4 rounded-lg bg-primary text-primary-foreground font-semibold hover:opacity-90 transition-opacity",
489
+ children: U("ecommerce.purchase_at")
490
+ })
491
+ ]
492
+ })
493
+ }) : null, at = (e, t, n) => (E((n) => ({
494
+ ...n,
495
+ [e]: t
496
+ })), n && document.getElementById(n)?.focus(), null), ot = (e, t) => t.recipient_name.trim() ? t.line1.trim() ? t.city.trim() ? l(t.country_code) && !t.state ? `${e}-state` : t.postal_code.trim() ? `${e}-line1` : `${e}-postal` : `${e}-city` : `${e}-line1` : `${e}-name`, st = (e) => {
497
+ if (!Y && (!D || !/^\S+@\S+\.\S+$/.test(D))) return Ae(U("ecommerce.invalid_email")), at(e, U("ecommerce.invalid_email"), "checkout-email");
498
+ let t = se(z);
499
+ if (!oe(t)) return at(e, U("checkout_complete_billing_address"), ot("billing", z));
500
+ let n = Z ? se(V ? z : B) : null;
501
+ if (e === "stripe") {
502
+ if (!oe(n)) return at(e, U("checkout_complete_shipping_address"), V ? ot("billing", z) : ot("shipping", B));
503
+ if (!P) return at(e, X("ecommerce.shipping_method_required", "Please select a shipping method before continuing."));
504
+ }
505
+ return Ae(""), {
506
+ normalizedBillingAddress: t,
507
+ normalizedShippingAddress: n
508
+ };
509
+ }, ct = async (e, t, n) => {
510
+ E((t) => ({
511
+ ...t,
512
+ [e]: ""
513
+ }));
514
+ let r = st(e);
515
+ if (r) {
516
+ if (we) {
517
+ let n = new Set(t.map((e) => e.id)), r = K.filter((e) => !n.has(e.id));
518
+ if (H.setItems(r), r.length === 0 && H.removeCoupon(), Fe(e), Ne(!0), typeof window < "u" && r.length === 0) try {
519
+ window.localStorage.removeItem(C);
520
+ } catch {}
521
+ return;
522
+ }
523
+ m(n);
524
+ try {
525
+ let n = await fetch("/api/checkout", {
526
+ method: "POST",
527
+ headers: { "Content-Type": "application/json" },
528
+ body: JSON.stringify({
529
+ items: t,
530
+ customerEmail: Y ? void 0 : D,
531
+ customerPhone: k || null,
532
+ billingAddress: r.normalizedBillingAddress,
533
+ shippingAddress: e === "stripe" ? r.normalizedShippingAddress : null,
534
+ shippingMethodId: e === "stripe" ? P : null,
535
+ locale: We,
536
+ currencyCode: W,
537
+ couponCode: R?.code ?? H.appliedCoupon?.code ?? null,
538
+ couponContextItems: K
539
+ })
540
+ }), i = await n.json();
541
+ if (!n.ok) {
542
+ let t = i?.errorKey && typeof i.errorKey == "string" ? X(i.errorKey, i?.error || X("ecommerce.generic_error", "Something went wrong."), i.errorParams) : i?.error || U("ecommerce.generic_error");
543
+ E((n) => ({
544
+ ...n,
545
+ [e]: t
546
+ })), m(null);
547
+ return;
548
+ }
549
+ if (i.customProps && i.customProps.provider === "freemius") {
550
+ let t = i.customProps, n = null, r = () => {
551
+ window.location.href = `/checkout/success?session_id=${t.order_id}`;
552
+ }, a = (e) => (n ||= fetch("/api/checkout/freemius/sync", {
553
+ method: "POST",
554
+ headers: { "Content-Type": "application/json" },
555
+ body: JSON.stringify({
556
+ orderId: t.order_id,
557
+ checkoutResponse: e
558
+ })
559
+ }).then(async (e) => {
560
+ if (!e.ok) {
561
+ let t = await e.json().catch(() => null);
562
+ console.error("Freemius checkout sync failed:", t);
563
+ }
564
+ }), n), o = {
565
+ product_id: t.plugin_id,
566
+ public_key: t.public_key,
567
+ sandbox: t.sandbox
568
+ }, s = {
569
+ name: U("ecommerce.checkout_overlay_title"),
570
+ plan_id: t.plan_id,
571
+ ...t.billing_cycle ? { billing_cycle: t.billing_cycle } : {},
572
+ ...t.trial ? { trial: t.trial } : {},
573
+ ...t.coupon ? { coupon: t.coupon } : {},
574
+ user_email: t.user_email,
575
+ user_firstname: t.user_firstname,
576
+ user_lastname: t.user_lastname,
577
+ sandbox: t.sandbox,
578
+ purchaseCompleted: function(e) {
579
+ a(e);
580
+ },
581
+ success: function(e) {
582
+ (async () => {
583
+ try {
584
+ await a(e);
585
+ } finally {
586
+ r();
587
+ }
588
+ })();
589
+ }
590
+ };
591
+ try {
592
+ new Ce(o).open(s), m(null);
593
+ } catch (t) {
594
+ console.error("[Checkout] Freemius overlay failed to open:", t), E((t) => ({
595
+ ...t,
596
+ [e]: U("ecommerce.checkout_popup_blocked")
597
+ })), i.url && (window.location.href = i.url), m(null);
598
+ }
599
+ } else i.url ? window.location.href = i.url : (E((t) => ({
600
+ ...t,
601
+ [e]: U("ecommerce.checkout_failed") + (i.error || X("ecommerce.unknown_error", "Unknown error"))
602
+ })), m(null));
603
+ } catch (t) {
604
+ console.error(t), E((t) => ({
605
+ ...t,
606
+ [e]: U("ecommerce.generic_error")
607
+ })), m(null);
608
+ }
609
+ }
610
+ };
611
+ if (K.length === 0) return /* @__PURE__ */ g(ve, { children: [it, /* @__PURE__ */ g("div", {
612
+ className: "container mx-auto flex min-h-[50vh] flex-col items-center justify-center p-8 text-center",
613
+ children: [
614
+ /* @__PURE__ */ h("h1", {
615
+ className: "mb-4 text-2xl font-bold",
616
+ children: U("ecommerce.cart_empty")
617
+ }),
618
+ /* @__PURE__ */ h("p", {
619
+ className: "mb-8 text-muted-foreground",
620
+ children: U("ecommerce.cart_empty_description")
621
+ }),
622
+ /* @__PURE__ */ h(le, {
623
+ asChild: !0,
624
+ children: /* @__PURE__ */ h("a", {
625
+ href: "/shop",
626
+ children: U("ecommerce.go_to_shop")
627
+ })
628
+ })
629
+ ]
630
+ })] });
631
+ let lt = X("ecommerce.checkout_payments_unavailable", "This store is not able to take payments right now. Please contact the seller to complete your purchase."), ut = Ge.stripe ? null : lt, dt = Ge.freemius ? null : lt, ft = ut || (Z ? $e ? Ie ? X("ecommerce.calculating_shipping", "Calculating shipping...") : P ? null : M.length > 0 ? U("ecommerce.select_rate") : U("ecommerce.no_rates_for_region") : X("ecommerce.waiting_on_address_info", "Complete your shipping address to view available shipping options.") : null), pt = u !== null || ft !== null, mt = q.length === 1 ? X("ecommerce.item_count_one", "{count} item", { count: q.length }) : X("ecommerce.item_count_other", "{count} items", { count: q.length }), ht = J.length === 1 ? X("ecommerce.license_count_one", "{count} license", { count: J.length }) : X("ecommerce.license_count_other", "{count} licenses", { count: J.length }), gt = (t) => e(t) ? X("ecommerce.digital_label", "Digital") : X("ecommerce.physical_label", "Physical"), _t = (e) => e === "monthly" ? X("ecommerce.checkout_billing_cycle_monthly", "Monthly subscription") : e === "annual" ? X("ecommerce.checkout_billing_cycle_annual", "Annual subscription") : e === "lifetime" ? X("ecommerce.checkout_billing_cycle_lifetime", "Lifetime subscription") : null;
632
+ return /* @__PURE__ */ g("div", {
633
+ className: "container mx-auto px-4 py-12 md:px-6",
634
+ children: [it, /* @__PURE__ */ g("div", {
635
+ className: "mx-auto max-w-6xl",
636
+ children: [/* @__PURE__ */ h("h1", {
637
+ className: "mb-8 text-3xl font-bold",
638
+ children: U("ecommerce.checkout")
639
+ }), /* @__PURE__ */ g("div", {
640
+ className: "grid gap-8 lg:grid-cols-12 lg:items-start",
641
+ children: [/* @__PURE__ */ g("div", {
642
+ className: "lg:col-span-8 space-y-6",
643
+ children: [
644
+ /* @__PURE__ */ g(y, { children: [/* @__PURE__ */ h(x, { children: /* @__PURE__ */ g(S, {
645
+ role: "heading",
646
+ "aria-level": 2,
647
+ className: "flex items-center gap-2",
648
+ children: [/* @__PURE__ */ h(de, { className: "w-5 h-5" }), U("ecommerce.contact_information")]
649
+ }) }), /* @__PURE__ */ g(b, {
650
+ className: "space-y-4",
651
+ children: [Y ? /* @__PURE__ */ h("div", {
652
+ className: "rounded-xl border bg-muted/20 p-4 text-sm text-muted-foreground",
653
+ children: U("checkout_prefill_notice", { email: s?.email || "" })
654
+ }) : /* @__PURE__ */ g("div", {
655
+ className: "space-y-2",
656
+ children: [
657
+ /* @__PURE__ */ g(v, {
658
+ htmlFor: "checkout-email",
659
+ children: [
660
+ U("ecommerce.email_address"),
661
+ " ",
662
+ /* @__PURE__ */ h("span", {
663
+ className: "text-destructive",
664
+ children: "*"
665
+ })
666
+ ]
667
+ }),
668
+ /* @__PURE__ */ h(_, {
669
+ id: "checkout-email",
670
+ name: "email",
671
+ type: "email",
672
+ autoComplete: "email",
673
+ spellCheck: !1,
674
+ "aria-invalid": O ? !0 : void 0,
675
+ "aria-describedby": O ? "checkout-email-error" : void 0,
676
+ placeholder: U("ecommerce.email_placeholder"),
677
+ value: D,
678
+ onChange: (e) => {
679
+ ke(e.target.value), O && Ae("");
680
+ },
681
+ required: !0
682
+ }),
683
+ O ? /* @__PURE__ */ h("p", {
684
+ id: "checkout-email-error",
685
+ role: "alert",
686
+ className: "text-xs text-destructive mt-1",
687
+ children: O
688
+ }) : null
689
+ ]
690
+ }), /* @__PURE__ */ g("div", {
691
+ className: "space-y-2",
692
+ children: [/* @__PURE__ */ h(v, {
693
+ htmlFor: "checkout-phone",
694
+ children: U("phone_number")
695
+ }), /* @__PURE__ */ h(_, {
696
+ id: "checkout-phone",
697
+ name: "phone",
698
+ type: "tel",
699
+ inputMode: "tel",
700
+ autoComplete: "tel",
701
+ placeholder: U("optional"),
702
+ value: k,
703
+ onChange: (e) => je(e.target.value)
704
+ })]
705
+ })]
706
+ })] }),
707
+ /* @__PURE__ */ h(De, {
708
+ idPrefix: "billing",
709
+ title: U("billing_address"),
710
+ description: U("checkout_billing_address_help"),
711
+ value: z,
712
+ onChange: Ve
713
+ }),
714
+ Z ? /* @__PURE__ */ g("div", {
715
+ className: "flex items-center space-x-3 rounded-xl border bg-muted/20 p-4",
716
+ children: [/* @__PURE__ */ h(ye, {
717
+ id: "use-billing-for-shipping",
718
+ checked: V,
719
+ onCheckedChange: (e) => Ue(!!e)
720
+ }), /* @__PURE__ */ g("div", {
721
+ className: "space-y-1",
722
+ children: [/* @__PURE__ */ h(v, {
723
+ htmlFor: "use-billing-for-shipping",
724
+ className: "cursor-pointer",
725
+ children: U("use_billing_for_shipping")
726
+ }), /* @__PURE__ */ h("p", {
727
+ className: "text-sm text-muted-foreground",
728
+ children: U("checkout_use_billing_for_shipping_help")
729
+ })]
730
+ })]
731
+ }) : null,
732
+ Z && !V ? /* @__PURE__ */ h(De, {
733
+ idPrefix: "shipping",
734
+ title: U("shipping_address"),
735
+ description: U("checkout_shipping_address_help"),
736
+ value: B,
737
+ onChange: He
738
+ }) : null,
739
+ Z ? /* @__PURE__ */ g(y, { children: [/* @__PURE__ */ h(x, { children: /* @__PURE__ */ g(S, {
740
+ role: "heading",
741
+ "aria-level": 2,
742
+ className: "flex items-center gap-2",
743
+ children: [/* @__PURE__ */ h(ue, { className: "w-5 h-5 text-primary" }), U("ecommerce.shipping_method")]
744
+ }) }), /* @__PURE__ */ h(b, { children: Ie ? /* @__PURE__ */ g("div", {
745
+ role: "status",
746
+ className: "flex items-center justify-center py-6",
747
+ children: [/* @__PURE__ */ h(me, { className: "w-6 h-6 animate-spin text-muted-foreground" }), /* @__PURE__ */ h("span", {
748
+ className: "sr-only",
749
+ children: X("ecommerce.calculating_shipping", "Calculating shipping…")
750
+ })]
751
+ }) : Le ? /* @__PURE__ */ h("div", {
752
+ role: "alert",
753
+ className: "rounded-lg bg-destructive/10 px-4 py-3 text-center text-sm text-destructive",
754
+ children: X("ecommerce.shipping_calculation_failed", "We couldn't calculate shipping right now. Please try again.")
755
+ }) : M.length > 0 ? /* @__PURE__ */ h(xe, {
756
+ value: P ?? "",
757
+ onValueChange: F,
758
+ "aria-label": U("ecommerce.shipping_method"),
759
+ className: "space-y-3",
760
+ children: M.map((e) => /* @__PURE__ */ g(v, {
761
+ htmlFor: `shipping-method-${e.id}`,
762
+ className: `flex items-center justify-between gap-3 p-4 rounded-lg border-2 cursor-pointer transition-colors ${P === e.id ? "border-primary bg-primary/5" : "border-border hover:border-muted-foreground/40"}`,
763
+ children: [/* @__PURE__ */ g("span", {
764
+ className: "flex min-w-0 items-center gap-3",
765
+ children: [/* @__PURE__ */ h(Se, {
766
+ id: `shipping-method-${e.id}`,
767
+ value: e.id
768
+ }), /* @__PURE__ */ h("span", {
769
+ className: "font-medium break-words",
770
+ children: e.name
771
+ })]
772
+ }), /* @__PURE__ */ h("span", {
773
+ className: "font-bold tabular-nums",
774
+ children: c(e.amount, W)
775
+ })]
776
+ }, e.id))
777
+ }) : /* @__PURE__ */ h("div", {
778
+ className: "py-4 text-center text-muted-foreground bg-muted/30 rounded-lg italic",
779
+ children: $e ? U("ecommerce.no_rates_for_region") : X("ecommerce.waiting_on_address_info", "Complete your shipping address to view available shipping options.")
780
+ }) })] }) : null
781
+ ]
782
+ }), /* @__PURE__ */ g("div", {
783
+ className: "lg:col-span-4 space-y-6",
784
+ children: [
785
+ /* @__PURE__ */ g(y, {
786
+ className: "top-6",
787
+ children: [/* @__PURE__ */ h(x, { children: /* @__PURE__ */ h(S, {
788
+ role: "heading",
789
+ "aria-level": 2,
790
+ children: U("ecommerce.order_summary")
791
+ }) }), /* @__PURE__ */ g(b, {
792
+ className: "space-y-4",
793
+ children: [
794
+ /* @__PURE__ */ h("div", {
795
+ className: "space-y-3 max-h-[260px] overflow-y-auto pr-2",
796
+ children: K.map((e) => {
797
+ let t = n(e, {
798
+ currencyCode: W,
799
+ currencies: G
800
+ }), r = a(e, U);
801
+ return /* @__PURE__ */ g("div", {
802
+ className: "flex items-start justify-between gap-4",
803
+ children: [/* @__PURE__ */ g("div", {
804
+ className: "flex gap-3",
805
+ children: [e.image_url ? /* @__PURE__ */ h("div", {
806
+ className: "h-10 w-10 shrink-0 overflow-hidden rounded border bg-neutral-100",
807
+ children: /* @__PURE__ */ h("img", {
808
+ src: e.image_url,
809
+ alt: e.title,
810
+ className: "h-full w-full object-cover"
811
+ })
812
+ }) : null, /* @__PURE__ */ g("div", {
813
+ className: "grid gap-0.5",
814
+ children: [
815
+ /* @__PURE__ */ g("div", {
816
+ className: "flex items-center gap-2",
817
+ children: [/* @__PURE__ */ h("span", {
818
+ className: "font-medium text-xs line-clamp-1",
819
+ children: e.title
820
+ }), /* @__PURE__ */ h(ce, {
821
+ variant: "outline",
822
+ className: "text-[9px] uppercase",
823
+ children: gt(e)
824
+ })]
825
+ }),
826
+ e.variant_label ? /* @__PURE__ */ h("span", {
827
+ className: "text-[10px] text-muted-foreground line-clamp-1",
828
+ children: e.variant_label
829
+ }) : null,
830
+ /* @__PURE__ */ g("span", {
831
+ className: "text-[10px] text-muted-foreground",
832
+ children: [
833
+ U("ecommerce.qty"),
834
+ ": ",
835
+ e.quantity
836
+ ]
837
+ }),
838
+ r ? /* @__PURE__ */ g("span", {
839
+ className: "text-[10px] font-medium text-emerald-700",
840
+ children: [
841
+ r.label,
842
+ " - ",
843
+ r.paymentRequirementLabel
844
+ ]
845
+ }) : null
846
+ ]
847
+ })]
848
+ }), /* @__PURE__ */ g("div", {
849
+ className: "flex flex-col items-end gap-0.5 shrink-0",
850
+ children: [/* @__PURE__ */ h("span", {
851
+ className: "font-medium text-xs",
852
+ children: c((t.sale_price ?? t.price) * e.quantity, W)
853
+ }), t.sale_price ? /* @__PURE__ */ h("span", {
854
+ className: "text-[9px] text-muted-foreground line-through",
855
+ children: c(t.price * e.quantity, W)
856
+ }) : null]
857
+ })]
858
+ }, `${e.id}-${e.variant_id || "base"}`);
859
+ })
860
+ }),
861
+ /* @__PURE__ */ h(be, {}),
862
+ /* @__PURE__ */ h(o, {
863
+ items: K,
864
+ currencyCode: W,
865
+ onQuoteChange: Be
866
+ }),
867
+ /* @__PURE__ */ g("div", {
868
+ className: "space-y-2 text-sm",
869
+ children: [
870
+ /* @__PURE__ */ g("div", {
871
+ className: "flex justify-between",
872
+ children: [/* @__PURE__ */ h("span", { children: U("ecommerce.subtotal") }), /* @__PURE__ */ h("span", { children: c(Ke, W) })]
873
+ }),
874
+ q.length > 0 ? /* @__PURE__ */ g("div", {
875
+ className: "flex justify-between text-muted-foreground",
876
+ children: [/* @__PURE__ */ h("span", { children: X("ecommerce.physical_products", "Physical products") }), /* @__PURE__ */ h("span", { children: c(qe, W) })]
877
+ }) : null,
878
+ J.length > 0 ? /* @__PURE__ */ g("div", {
879
+ className: "flex justify-between text-muted-foreground",
880
+ children: [/* @__PURE__ */ h("span", { children: X("ecommerce.digital_products", "Digital products") }), /* @__PURE__ */ h("span", { children: c(Je, W) })]
881
+ }) : null,
882
+ R ? /* @__PURE__ */ g("div", {
883
+ className: "flex justify-between text-emerald-600",
884
+ children: [/* @__PURE__ */ g("span", { children: [
885
+ X("ecommerce.discount", "Discount"),
886
+ " (",
887
+ R.code,
888
+ ")"
889
+ ] }), /* @__PURE__ */ g("span", { children: ["-", c(R.discountTotal, W)] })]
890
+ }) : null,
891
+ (q.length > 0 || J.length > 0) && /* @__PURE__ */ g("div", {
892
+ className: "flex justify-between font-bold text-lg pt-2 border-t mt-2",
893
+ children: [/* @__PURE__ */ h("span", { children: X("ecommerce.estimated_total", "Estimated total") }), /* @__PURE__ */ h("span", {
894
+ className: "text-primary",
895
+ children: c(nt, W)
896
+ })]
897
+ })
898
+ ]
899
+ })
900
+ ]
901
+ })]
902
+ }),
903
+ q.length > 0 ? /* @__PURE__ */ g(Oe, {
904
+ title: X("ecommerce.stripe_checkout_title", "Stripe Checkout"),
905
+ description: X("ecommerce.stripe_checkout_description", "Pay for physical products in one Stripe checkout session."),
906
+ badgeLabel: mt,
907
+ children: [
908
+ /* @__PURE__ */ g("div", {
909
+ className: "space-y-2 text-sm",
910
+ children: [
911
+ /* @__PURE__ */ g("div", {
912
+ className: "flex justify-between",
913
+ children: [/* @__PURE__ */ h("span", { children: X("ecommerce.physical_subtotal", "Physical subtotal") }), /* @__PURE__ */ h("span", { children: c(qe, W) })]
914
+ }),
915
+ Ye > 0 ? /* @__PURE__ */ g("div", {
916
+ className: "flex justify-between text-emerald-600",
917
+ children: [/* @__PURE__ */ h("span", { children: X("ecommerce.discount", "Discount") }), /* @__PURE__ */ g("span", { children: ["-", c(Ye, W)] })]
918
+ }) : null,
919
+ /* @__PURE__ */ g("div", {
920
+ className: "flex justify-between",
921
+ children: [/* @__PURE__ */ h("span", { children: U("ecommerce.shipping") }), /* @__PURE__ */ h("span", { children: et ? c(et.amount, W) : "-" })]
922
+ }),
923
+ /* @__PURE__ */ g("div", {
924
+ className: "flex justify-between",
925
+ children: [/* @__PURE__ */ h("span", { children: X("ecommerce.tax", "Tax") }), /* @__PURE__ */ h("span", { children: ze ? "..." : I?.isPendingExternalCalculation ? X("ecommerce.tax_calculated_on_stripe", "Calculated on Stripe") : I ? c(I.amount, W) : "-" })]
926
+ }),
927
+ I && I.lines.length > 0 ? /* @__PURE__ */ h("div", {
928
+ className: "rounded-lg bg-muted/20 px-3 py-2 text-xs text-muted-foreground",
929
+ children: I.lines.map((e) => /* @__PURE__ */ g("div", {
930
+ className: "flex justify-between gap-3",
931
+ children: [/* @__PURE__ */ g("span", { children: [
932
+ e.name,
933
+ " (",
934
+ e.rate.toFixed(4),
935
+ "%)"
936
+ ] }), /* @__PURE__ */ h("span", { children: c(e.amount, W) })]
937
+ }, e.id || `${e.name}-${e.rate}`))
938
+ }) : null,
939
+ /* @__PURE__ */ g("div", {
940
+ className: "flex justify-between font-semibold pt-2 border-t",
941
+ children: [/* @__PURE__ */ h("span", { children: X("ecommerce.total_on_stripe", "Total on Stripe") }), /* @__PURE__ */ h("span", { children: c(tt, W) })]
942
+ })
943
+ ]
944
+ }),
945
+ /* @__PURE__ */ g(le, {
946
+ className: "w-full",
947
+ size: "lg",
948
+ onClick: () => ct("stripe", q, "stripe"),
949
+ disabled: pt,
950
+ children: [u === "stripe" ? /* @__PURE__ */ h(me, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ h(he, { className: "mr-2 h-4 w-4" }), u === "stripe" ? U("ecommerce.processing") : X("ecommerce.checkout_physical_products", "Checkout Physical Products")]
951
+ }),
952
+ ft && u === null ? /* @__PURE__ */ h("p", {
953
+ className: "text-[11px] text-muted-foreground",
954
+ children: ft
955
+ }) : null,
956
+ T.stripe ? /* @__PURE__ */ h("div", {
957
+ role: "alert",
958
+ className: "rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive",
959
+ children: T.stripe
960
+ }) : null,
961
+ /* @__PURE__ */ h("p", {
962
+ className: "text-[11px] text-muted-foreground",
963
+ children: I?.isPendingExternalCalculation ? X("checkout_stripe_tax_finalized_notice", "Tax will be finalized by Stripe Tax on the payment step.") : X("ecommerce.shipping_taxes_collected_on_stripe", "Shipping and taxes are only collected during the Stripe step for physical products.")
964
+ })
965
+ ]
966
+ }) : null,
967
+ J.length > 0 ? /* @__PURE__ */ g(Oe, {
968
+ title: X("ecommerce.freemius_checkout_title", "Freemius Checkout"),
969
+ description: X("ecommerce.freemius_checkout_description", "Digital products use the Freemius checkout flow."),
970
+ badgeLabel: ht,
971
+ children: [
972
+ /* @__PURE__ */ h("div", {
973
+ className: "space-y-3",
974
+ children: J.map((e) => {
975
+ let t = n(e, {
976
+ currencyCode: W,
977
+ currencies: G
978
+ }), r = a(e, U), i = `freemius:${e.id}`, o = r ? ee[i] || "paid" : void 0;
979
+ return /* @__PURE__ */ g("div", {
980
+ className: "rounded-lg border p-3 space-y-3",
981
+ children: [
982
+ /* @__PURE__ */ g("div", {
983
+ className: "flex items-start justify-between gap-3",
984
+ children: [/* @__PURE__ */ g("div", { children: [
985
+ /* @__PURE__ */ h("p", {
986
+ className: "font-medium",
987
+ children: e.title
988
+ }),
989
+ e.billing_cycle ? /* @__PURE__ */ h("p", {
990
+ className: "text-xs text-muted-foreground capitalize",
991
+ children: _t(e.billing_cycle)
992
+ }) : null,
993
+ r ? /* @__PURE__ */ g("p", {
994
+ className: "text-xs font-medium text-emerald-700",
995
+ children: [
996
+ r.label,
997
+ " - ",
998
+ r.paymentRequirementLabel
999
+ ]
1000
+ }) : null
1001
+ ] }), /* @__PURE__ */ h("span", {
1002
+ className: "font-medium",
1003
+ children: c(t.sale_price ?? t.price, W)
1004
+ })]
1005
+ }),
1006
+ r && !e.trial_requires_payment_method && /* @__PURE__ */ g("div", {
1007
+ className: "bg-muted/30 p-3 rounded-md border text-sm mt-2 mb-3",
1008
+ children: [/* @__PURE__ */ h("p", {
1009
+ className: "font-medium mb-3",
1010
+ children: X("ecommerce.freemius_trial_preference_title", "How would you like to start your trial?")
1011
+ }), /* @__PURE__ */ g(xe, {
1012
+ value: ee[i] || "paid",
1013
+ onValueChange: (e) => te((t) => ({
1014
+ ...t,
1015
+ [i]: e
1016
+ })),
1017
+ className: "gap-3",
1018
+ children: [/* @__PURE__ */ g("div", {
1019
+ className: "flex items-start space-x-3",
1020
+ children: [/* @__PURE__ */ h(Se, {
1021
+ value: "paid",
1022
+ id: `${i}-paid`,
1023
+ className: "mt-1"
1024
+ }), /* @__PURE__ */ g("div", {
1025
+ className: "grid gap-1.5",
1026
+ children: [/* @__PURE__ */ h(v, {
1027
+ htmlFor: `${i}-paid`,
1028
+ className: "font-medium leading-none cursor-pointer",
1029
+ children: X("ecommerce.freemius_trial_with_card", "Enter Payment Details Now (Still get full trial length free)")
1030
+ }), /* @__PURE__ */ h("p", {
1031
+ className: "text-xs text-muted-foreground",
1032
+ children: X("ecommerce.freemius_trial_with_card_help", "You will not be billed until the trial ends. Cancel anytime.")
1033
+ })]
1034
+ })]
1035
+ }), /* @__PURE__ */ g("div", {
1036
+ className: "flex items-start space-x-3",
1037
+ children: [/* @__PURE__ */ h(Se, {
1038
+ value: "free",
1039
+ id: `${i}-free`,
1040
+ className: "mt-1"
1041
+ }), /* @__PURE__ */ h("div", {
1042
+ className: "grid gap-1.5",
1043
+ children: /* @__PURE__ */ h(v, {
1044
+ htmlFor: `${i}-free`,
1045
+ className: "font-medium leading-none cursor-pointer",
1046
+ children: X("ecommerce.freemius_trial_no_card", "Start Free Trial (No card required)")
1047
+ })
1048
+ })]
1049
+ })]
1050
+ })]
1051
+ }),
1052
+ /* @__PURE__ */ g(le, {
1053
+ className: "w-full h-auto min-h-[2.75rem] py-2",
1054
+ onClick: () => ct("freemius", [{
1055
+ ...e,
1056
+ ...o ? { trial_preference: o } : {}
1057
+ }], i),
1058
+ disabled: u !== null || dt !== null,
1059
+ children: [u === i ? /* @__PURE__ */ h(me, { className: "mr-2 h-4 w-4 shrink-0 animate-spin" }) : /* @__PURE__ */ h(fe, { className: "mr-2 h-4 w-4 shrink-0" }), /* @__PURE__ */ h("span", {
1060
+ className: "whitespace-normal text-left",
1061
+ children: u === i ? U("ecommerce.processing") : J.length > 1 ? X("ecommerce.checkout_product", "Checkout {title}", { title: e.title }) : X("ecommerce.checkout_digital_product", "Checkout Digital Product")
1062
+ })]
1063
+ })
1064
+ ]
1065
+ }, i);
1066
+ })
1067
+ }),
1068
+ /* @__PURE__ */ g("div", {
1069
+ className: "flex justify-between text-sm font-semibold border-t pt-3",
1070
+ children: [/* @__PURE__ */ h("span", { children: X("ecommerce.digital_subtotal", "Digital subtotal") }), /* @__PURE__ */ h("span", { children: c(Je, W) })]
1071
+ }),
1072
+ Xe > 0 ? /* @__PURE__ */ g("div", {
1073
+ className: "flex justify-between text-sm font-semibold text-emerald-600",
1074
+ children: [/* @__PURE__ */ h("span", { children: X("ecommerce.discount", "Discount") }), /* @__PURE__ */ g("span", { children: ["-", c(Xe, W)] })]
1075
+ }) : null,
1076
+ dt ? /* @__PURE__ */ h("div", {
1077
+ className: "rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs",
1078
+ children: dt
1079
+ }) : null,
1080
+ T.freemius ? /* @__PURE__ */ h("div", {
1081
+ role: "alert",
1082
+ className: "rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive",
1083
+ children: T.freemius
1084
+ }) : null,
1085
+ /* @__PURE__ */ h("p", {
1086
+ className: "text-[11px] text-muted-foreground",
1087
+ children: J.length > 1 ? X("ecommerce.freemius_multi_checkout_notice", "Freemius licenses are completed one at a time, so each digital product gets its own checkout action.") : X("ecommerce.freemius_tax_notice", "Taxes and compliance for digital products are handled inside the Freemius checkout.")
1088
+ })
1089
+ ]
1090
+ }) : null
1091
+ ]
1092
+ })]
1093
+ })]
1094
+ })]
1095
+ });
1114
1096
  };
1097
+ //#endregion
1098
+ export { T as Checkout };