@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.
- package/README.md +43 -0
- package/_virtual/_rolldown/runtime.cjs +1 -0
- package/index.cjs +1 -0
- package/index.es.js +38 -146
- package/lib/CurrencyProvider.cjs +1 -0
- package/lib/CurrencyProvider.d.ts +1 -1
- package/lib/CurrencyProvider.es.js +85 -95
- package/lib/PaymentReadinessProvider.cjs +1 -0
- package/lib/PaymentReadinessProvider.d.ts +1 -1
- package/lib/PaymentReadinessProvider.es.js +24 -27
- package/lib/cart-store.cjs +1 -0
- package/lib/cart-store.es.js +109 -121
- package/lib/components/AccountNavigationMenu.cjs +1 -0
- package/lib/components/AccountNavigationMenu.d.ts +1 -1
- package/lib/components/AccountNavigationMenu.es.js +36 -50
- package/lib/components/AddToCartButton.cjs +1 -0
- package/lib/components/AddToCartButton.d.ts +1 -1
- package/lib/components/AddToCartButton.es.js +94 -89
- package/lib/components/Cart.cjs +1 -0
- package/lib/components/Cart.d.ts +1 -1
- package/lib/components/Cart.es.js +261 -180
- package/lib/components/CartDrawer.cjs +1 -0
- package/lib/components/CartDrawer.d.ts +1 -1
- package/lib/components/CartDrawer.es.js +218 -148
- package/lib/components/CartIcon.cjs +1 -0
- package/lib/components/CartIcon.d.ts +1 -1
- package/lib/components/CartIcon.es.js +33 -35
- package/lib/components/Checkout.cjs +1 -0
- package/lib/components/Checkout.d.ts +1 -1
- package/lib/components/Checkout.es.js +1092 -1108
- package/lib/components/CouponForm.cjs +1 -0
- package/lib/components/CouponForm.d.ts +1 -1
- package/lib/components/CouponForm.es.js +136 -148
- package/lib/components/CurrencySwitcher.cjs +1 -0
- package/lib/components/CurrencySwitcher.d.ts +1 -1
- package/lib/components/CurrencySwitcher.es.js +22 -18
- package/lib/components/CustomerProfileForm.cjs +1 -0
- package/lib/components/CustomerProfileForm.es.js +454 -313
- package/lib/components/FeaturedProduct.cjs +1 -0
- package/lib/components/FeaturedProduct.d.ts +1 -1
- package/lib/components/FeaturedProduct.es.js +98 -83
- package/lib/components/FreemiusLicensePanel.cjs +1 -0
- package/lib/components/FreemiusLicensePanel.d.ts +1 -1
- package/lib/components/FreemiusLicensePanel.es.js +70 -65
- package/lib/components/InvoiceDocument.cjs +1 -0
- package/lib/components/InvoiceDocument.es.js +256 -192
- package/lib/components/InvoiceViewerShell.cjs +29 -0
- package/lib/components/InvoiceViewerShell.d.ts +1 -1
- package/lib/components/InvoiceViewerShell.es.js +75 -106
- package/lib/components/ProductCard.cjs +1 -0
- package/lib/components/ProductCard.d.ts +1 -1
- package/lib/components/ProductCard.es.js +186 -171
- package/lib/components/ProductDetailsLayout.cjs +1 -0
- package/lib/components/ProductDetailsLayout.es.js +405 -404
- package/lib/components/ProductGallery.cjs +1 -0
- package/lib/components/ProductGallery.d.ts +1 -1
- package/lib/components/ProductGallery.es.js +51 -54
- package/lib/components/ProductGrid.cjs +1 -0
- package/lib/components/ProductGrid.d.ts +1 -1
- package/lib/components/ProductGrid.es.js +23 -25
- package/lib/components/ShippingEstimator.cjs +1 -0
- package/lib/components/ShippingEstimator.d.ts +1 -1
- package/lib/components/ShippingEstimator.es.js +158 -153
- package/lib/components/ShortDescription.cjs +1 -0
- package/lib/components/ShortDescription.es.js +17 -17
- package/lib/components/SimpleTiptapRenderer.cjs +1 -0
- package/lib/components/SimpleTiptapRenderer.es.js +238 -211
- package/lib/components/SubscriptionSelector.cjs +1 -0
- package/lib/components/SubscriptionSelector.es.js +159 -154
- package/lib/countries.cjs +1 -0
- package/lib/countries.es.js +232 -75
- package/lib/coupon-server.cjs +1 -0
- package/lib/coupon-server.es.js +180 -224
- package/lib/coupons.cjs +1 -0
- package/lib/coupons.es.js +12 -14
- package/lib/currency-constants.cjs +1 -0
- package/lib/currency-constants.es.js +4 -4
- package/lib/currency-rest-client.cjs +1 -0
- package/lib/currency-rest-client.es.js +15 -22
- package/lib/currency-store.cjs +1 -0
- package/lib/currency-store.es.js +20 -27
- package/lib/currency-sync.cjs +1 -0
- package/lib/currency-sync.es.js +124 -170
- package/lib/currency.cjs +1 -0
- package/lib/currency.es.js +242 -310
- package/lib/customer-addresses.cjs +1 -0
- package/lib/customer-addresses.es.js +80 -109
- package/lib/customer-orders.cjs +1 -0
- package/lib/customer-orders.es.js +31 -43
- package/lib/customer.cjs +1 -0
- package/lib/customer.es.js +43 -52
- package/lib/export-helpers.cjs +1 -0
- package/lib/export-helpers.es.js +53 -52
- package/lib/factory.cjs +1 -0
- package/lib/factory.es.js +10 -7
- package/lib/freemius-coupons.cjs +1 -0
- package/lib/freemius-coupons.es.js +245 -262
- package/lib/freemius-license-claim.cjs +1 -0
- package/lib/freemius-license-claim.es.js +87 -71
- package/lib/freemius-license.cjs +1 -0
- package/lib/freemius-license.es.js +32 -39
- package/lib/freemius-order-sync.cjs +1 -0
- package/lib/freemius-order-sync.es.js +226 -290
- package/lib/freemius-trial-provision.cjs +1 -0
- package/lib/freemius-trial-provision.es.js +136 -130
- package/lib/inventory-settings.cjs +1 -0
- package/lib/inventory-settings.es.js +69 -77
- package/lib/invoice-server.cjs +33 -0
- package/lib/invoice-server.es.js +94 -141
- package/lib/invoice-ui.cjs +1 -0
- package/lib/invoice-ui.es.js +50 -66
- package/lib/invoice.cjs +1 -0
- package/lib/invoice.es.js +85 -94
- package/lib/order-inventory.cjs +61 -0
- package/lib/order-inventory.es.js +67 -79
- package/lib/order-tax-details.cjs +1 -0
- package/lib/order-tax-details.es.js +142 -153
- package/lib/pages/cms/coupons/CouponEditorForm.cjs +1 -0
- package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
- package/lib/pages/cms/coupons/CouponsPage.cjs +5 -0
- package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs +1 -0
- package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
- package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
- package/lib/pages/cms/coupons/EditCouponPage.cjs +1 -0
- package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
- package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
- package/lib/pages/cms/coupons/ProductScopePicker.cjs +1 -0
- package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
- package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
- package/lib/pages/cms/coupons/actions.cjs +1 -0
- package/lib/pages/cms/coupons/actions.es.js +112 -115
- package/lib/pages/cms/coupons/index.cjs +1 -0
- package/lib/pages/cms/coupons/index.es.js +3 -0
- package/lib/pages/cms/coupons/product-options.cjs +1 -0
- package/lib/pages/cms/coupons/product-options.es.js +21 -23
- package/lib/pages/cms/orders/ExportReportsDialog.cjs +1 -0
- package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
- package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.cjs +1 -0
- package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
- package/lib/pages/cms/orders/OrderPrintButton.cjs +1 -0
- package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
- package/lib/pages/cms/orders/OrderStatusForm.cjs +1 -0
- package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
- package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
- package/lib/pages/cms/orders/OrdersPage.cjs +1 -0
- package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
- package/lib/pages/cms/orders/actions.cjs +7 -0
- package/lib/pages/cms/orders/actions.es.js +53 -69
- package/lib/pages/cms/orders/export-actions.cjs +1 -0
- package/lib/pages/cms/orders/export-actions.es.js +23 -26
- package/lib/pages/cms/orders/index.cjs +1 -0
- package/lib/pages/cms/orders/index.es.js +6 -0
- package/lib/pages/cms/orders/server-actions.cjs +1 -0
- package/lib/pages/cms/orders/server-actions.es.js +60 -51
- package/lib/pages/cms/payments/PaymentsClient.cjs +1 -0
- package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
- package/lib/pages/cms/payments/PaymentsPage.cjs +1 -0
- package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
- package/lib/pages/cms/payments/actions.cjs +1 -0
- package/lib/pages/cms/payments/actions.es.js +38 -48
- package/lib/pages/cms/payments/index.cjs +1 -0
- package/lib/pages/cms/payments/index.es.js +3 -0
- package/lib/pages/cms/payments/queries.cjs +1 -0
- package/lib/pages/cms/payments/queries.es.js +38 -48
- package/lib/pages/cms/products/ProductsPage.cjs +1 -0
- package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
- package/lib/pages/cms/products/ProductsPage.es.js +63 -66
- package/lib/pages/cms/products/[id]/edit/EditProductPage.cjs +1 -0
- package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
- package/lib/pages/cms/products/[id]/edit/EditProductPage.es.js +139 -0
- package/lib/pages/cms/products/actions.cjs +44 -0
- package/lib/pages/cms/products/actions.es.js +121 -162
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs +1 -0
- package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
- package/lib/pages/cms/products/attributes/components/AttributeManager.cjs +1 -0
- package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs +1 -0
- package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs +1 -0
- package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs +1 -0
- package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs +1 -0
- package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
- package/lib/pages/cms/products/components/DeleteProductButton.cjs +1 -0
- package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
- package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs +1 -0
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs +1 -0
- package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
- package/lib/pages/cms/products/components/ProductForm.cjs +1 -0
- package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
- package/lib/pages/cms/products/components/ProductMediaManager.cjs +1 -0
- package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs +1 -0
- package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs +1 -0
- package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs +1 -0
- package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs +5 -0
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
- package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.cjs +1 -0
- package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
- package/lib/pages/cms/products/index.cjs +1 -0
- package/lib/pages/cms/products/index.es.js +8 -0
- package/lib/pages/cms/products/inventory/InventoryPage.cjs +1 -0
- package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs +2 -0
- package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
- package/lib/pages/cms/products/inventory/actions.cjs +3 -0
- package/lib/pages/cms/products/inventory/actions.es.js +83 -91
- package/lib/pages/cms/products/new/NewProductPage.cjs +1 -0
- package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
- package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
- package/lib/pages/cms/products/product-price-sync.cjs +1 -0
- package/lib/pages/cms/products/product-price-sync.es.js +74 -89
- package/lib/pages/cms/products/server-actions.cjs +1 -0
- package/lib/pages/cms/products/server-actions.es.js +250 -233
- package/lib/pages/cms/shipping/ShippingPage.cjs +5 -0
- package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
- package/lib/pages/cms/shipping/components/RateForm.cjs +1 -0
- package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
- package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
- package/lib/pages/cms/shipping/components/ZoneForm.cjs +1 -0
- package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
- package/lib/pages/cms/shipping/index.cjs +1 -0
- package/lib/pages/cms/shipping/index.es.js +3 -0
- package/lib/pages/cms/shipping/server-actions.cjs +1 -0
- package/lib/pages/cms/shipping/server-actions.es.js +131 -149
- package/lib/pages/cms/taxes/TaxesPage.cjs +1 -0
- package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
- package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
- package/lib/pages/cms/taxes/actions.cjs +1 -0
- package/lib/pages/cms/taxes/actions.es.js +41 -53
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs +1 -0
- package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
- package/lib/pages/cms/taxes/index.cjs +1 -0
- package/lib/pages/cms/taxes/index.es.js +3 -0
- package/lib/payment-config.cjs +1 -0
- package/lib/payment-config.es.js +110 -126
- package/lib/product-actions.cjs +238 -0
- package/lib/product-actions.es.js +289 -544
- package/lib/product-context.cjs +1 -0
- package/lib/product-context.es.js +13 -15
- package/lib/product-schema.cjs +1 -0
- package/lib/product-schema.es.js +99 -134
- package/lib/providers/freemius.cjs +1 -0
- package/lib/providers/freemius.es.js +446 -530
- package/lib/providers/stripe.cjs +1 -0
- package/lib/providers/stripe.es.js +417 -477
- package/lib/server-actions/coupon-actions.cjs +1 -0
- package/lib/server-actions/coupon-actions.es.js +22 -22
- package/lib/server-actions/customer-actions.cjs +1 -0
- package/lib/server-actions/customer-actions.es.js +26 -28
- package/lib/server-actions/product-actions.cjs +1 -0
- package/lib/server-actions/product-actions.es.js +9 -15
- package/lib/server-actions/shipping-actions.cjs +1 -0
- package/lib/server-actions/shipping-actions.es.js +27 -24
- package/lib/server-actions/tax-actions.cjs +1 -0
- package/lib/server-actions/tax-actions.es.js +33 -39
- package/lib/shared-inventory.cjs +15 -0
- package/lib/shared-inventory.es.js +111 -160
- package/lib/shipping/resolver.cjs +7 -0
- package/lib/shipping/resolver.es.js +44 -61
- package/lib/shipping-rate-currency.cjs +1 -0
- package/lib/shipping-rate-currency.es.js +52 -67
- package/lib/states.cjs +1 -0
- package/lib/states.es.js +333 -154
- package/lib/stripe/checkout.cjs +1 -0
- package/lib/stripe/checkout.es.js +125 -181
- package/lib/stripe/client.cjs +1 -0
- package/lib/stripe/client.es.js +14 -19
- package/lib/stripe/order-sync.cjs +1 -0
- package/lib/stripe/order-sync.es.js +106 -126
- package/lib/stripe/webhooks.cjs +1 -0
- package/lib/stripe/webhooks.es.js +37 -31
- package/lib/tax-calculation.cjs +1 -0
- package/lib/tax-calculation.es.js +84 -98
- package/lib/trials.cjs +1 -0
- package/lib/trials.es.js +24 -30
- package/lib/types.cjs +1 -0
- package/lib/types.es.js +21 -27
- package/lib/use-cart.cjs +1 -0
- package/lib/use-cart.es.js +38 -40
- package/lib/use-price-formatter.cjs +1 -0
- package/lib/use-price-formatter.es.js +10 -11
- package/lib/variation-utils.cjs +1 -0
- package/lib/variation-utils.es.js +199 -261
- package/lib/zod-config.cjs +1 -0
- package/lib/zod-config.es.js +5 -6
- package/package.json +22 -21
- package/server.cjs +1 -0
- package/server.es.js +56 -211
- package/index.cjs.js +0 -1
- package/lib/CurrencyProvider.cjs.js +0 -1
- package/lib/PaymentReadinessProvider.cjs.js +0 -1
- package/lib/cart-store.cjs.js +0 -1
- package/lib/components/AccountNavigationMenu.cjs.js +0 -1
- package/lib/components/AddToCartButton.cjs.js +0 -1
- package/lib/components/Cart.cjs.js +0 -1
- package/lib/components/CartDrawer.cjs.js +0 -1
- package/lib/components/CartIcon.cjs.js +0 -1
- package/lib/components/Checkout.cjs.js +0 -1
- package/lib/components/CouponForm.cjs.js +0 -1
- package/lib/components/CurrencySwitcher.cjs.js +0 -1
- package/lib/components/CustomerProfileForm.cjs.js +0 -1
- package/lib/components/FeaturedProduct.cjs.js +0 -1
- package/lib/components/FreemiusLicensePanel.cjs.js +0 -1
- package/lib/components/InvoiceDocument.cjs.js +0 -1
- package/lib/components/InvoiceViewerShell.cjs.js +0 -29
- package/lib/components/ProductCard.cjs.js +0 -1
- package/lib/components/ProductDetailsLayout.cjs.js +0 -1
- package/lib/components/ProductGallery.cjs.js +0 -1
- package/lib/components/ProductGrid.cjs.js +0 -1
- package/lib/components/ShippingEstimator.cjs.js +0 -1
- package/lib/components/ShortDescription.cjs.js +0 -1
- package/lib/components/SimpleTiptapRenderer.cjs.js +0 -1
- package/lib/components/SubscriptionSelector.cjs.js +0 -1
- package/lib/countries.cjs.js +0 -1
- package/lib/coupon-server.cjs.js +0 -1
- package/lib/coupons.cjs.js +0 -1
- package/lib/currency-constants.cjs.js +0 -1
- package/lib/currency-rest-client.cjs.js +0 -1
- package/lib/currency-store.cjs.js +0 -1
- package/lib/currency-sync.cjs.js +0 -1
- package/lib/currency.cjs.js +0 -1
- package/lib/customer-addresses.cjs.js +0 -1
- package/lib/customer-orders.cjs.js +0 -1
- package/lib/customer.cjs.js +0 -1
- package/lib/export-helpers.cjs.js +0 -1
- package/lib/factory.cjs.js +0 -1
- package/lib/freemius-coupons.cjs.js +0 -1
- package/lib/freemius-license-claim.cjs.js +0 -1
- package/lib/freemius-license.cjs.js +0 -1
- package/lib/freemius-order-sync.cjs.js +0 -1
- package/lib/freemius-trial-provision.cjs.js +0 -1
- package/lib/inventory-settings.cjs.js +0 -1
- package/lib/invoice-server.cjs.js +0 -33
- package/lib/invoice-ui.cjs.js +0 -1
- package/lib/invoice.cjs.js +0 -1
- package/lib/order-inventory.cjs.js +0 -61
- package/lib/order-tax-details.cjs.js +0 -1
- package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +0 -1
- package/lib/pages/cms/coupons/CouponsPage.cjs.js +0 -5
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +0 -1
- package/lib/pages/cms/coupons/EditCouponPage.cjs.js +0 -1
- package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +0 -1
- package/lib/pages/cms/coupons/actions.cjs.js +0 -1
- package/lib/pages/cms/coupons/product-options.cjs.js +0 -1
- package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +0 -1
- package/lib/pages/cms/orders/OrderDetailPage.cjs.js +0 -1
- package/lib/pages/cms/orders/OrderPrintButton.cjs.js +0 -1
- package/lib/pages/cms/orders/OrderStatusForm.cjs.js +0 -1
- package/lib/pages/cms/orders/OrdersPage.cjs.js +0 -1
- package/lib/pages/cms/orders/actions.cjs.js +0 -7
- package/lib/pages/cms/orders/export-actions.cjs.js +0 -1
- package/lib/pages/cms/orders/server-actions.cjs.js +0 -1
- package/lib/pages/cms/payments/PaymentsClient.cjs.js +0 -1
- package/lib/pages/cms/payments/PaymentsPage.cjs.js +0 -1
- package/lib/pages/cms/payments/actions.cjs.js +0 -1
- package/lib/pages/cms/payments/queries.cjs.js +0 -1
- package/lib/pages/cms/products/ProductsPage.cjs.js +0 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +0 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +0 -156
- package/lib/pages/cms/products/actions.cjs.js +0 -44
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +0 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +0 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +0 -1
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +0 -1
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +0 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +0 -1
- package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +0 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +0 -1
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +0 -1
- package/lib/pages/cms/products/components/ProductForm.cjs.js +0 -1
- package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +0 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +0 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +0 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +0 -1
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +0 -5
- package/lib/pages/cms/products/components/VariationsEditor.cjs.js +0 -1
- package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +0 -1
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +0 -2
- package/lib/pages/cms/products/inventory/actions.cjs.js +0 -3
- package/lib/pages/cms/products/new/NewProductPage.cjs.js +0 -1
- package/lib/pages/cms/products/product-price-sync.cjs.js +0 -1
- package/lib/pages/cms/products/server-actions.cjs.js +0 -1
- package/lib/pages/cms/shipping/ShippingPage.cjs.js +0 -5
- package/lib/pages/cms/shipping/components/RateForm.cjs.js +0 -1
- package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +0 -1
- package/lib/pages/cms/shipping/server-actions.cjs.js +0 -1
- package/lib/pages/cms/taxes/TaxesPage.cjs.js +0 -1
- package/lib/pages/cms/taxes/actions.cjs.js +0 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +0 -1
- package/lib/payment-config.cjs.js +0 -1
- package/lib/product-actions.cjs.js +0 -238
- package/lib/product-context.cjs.js +0 -1
- package/lib/product-schema.cjs.js +0 -1
- package/lib/providers/freemius.cjs.js +0 -5
- package/lib/providers/stripe.cjs.js +0 -1
- package/lib/server-actions/coupon-actions.cjs.js +0 -1
- package/lib/server-actions/customer-actions.cjs.js +0 -1
- package/lib/server-actions/product-actions.cjs.js +0 -1
- package/lib/server-actions/shipping-actions.cjs.js +0 -1
- package/lib/server-actions/tax-actions.cjs.js +0 -1
- package/lib/shared-inventory.cjs.js +0 -15
- package/lib/shipping/resolver.cjs.js +0 -7
- package/lib/shipping-rate-currency.cjs.js +0 -1
- package/lib/states.cjs.js +0 -1
- package/lib/stripe/checkout.cjs.js +0 -1
- package/lib/stripe/client.cjs.js +0 -1
- package/lib/stripe/order-sync.cjs.js +0 -1
- package/lib/stripe/webhooks.cjs.js +0 -1
- package/lib/tax-calculation.cjs.js +0 -1
- package/lib/trials.cjs.js +0 -1
- package/lib/types.cjs.js +0 -1
- package/lib/use-cart.cjs.js +0 -1
- package/lib/use-price-formatter.cjs.js +0 -1
- package/lib/variation-utils.cjs.js +0 -1
- package/lib/zod-config.cjs.js +0 -1
- package/server.cjs.js +0 -1
package/lib/currency.es.js
CHANGED
|
@@ -1,312 +1,244 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
import { formatPrice as e, getCurrencyMinorUnitFactor as t, majorUnitAmountToMinor as n, minorUnitAmountToMajor as r, normalizeCurrencyCode as i } from "@nextblock-cms/utils";
|
|
2
|
+
//#region src/lib/currency.ts
|
|
3
|
+
var a = [
|
|
4
|
+
"none",
|
|
5
|
+
"nearest",
|
|
6
|
+
"up",
|
|
7
|
+
"down",
|
|
8
|
+
"charm"
|
|
9
|
+
], o = {
|
|
10
|
+
AU: "AUD",
|
|
11
|
+
CA: "CAD",
|
|
12
|
+
CH: "CHF",
|
|
13
|
+
CZ: "CZK",
|
|
14
|
+
DE: "EUR",
|
|
15
|
+
DK: "DKK",
|
|
16
|
+
ES: "EUR",
|
|
17
|
+
EU: "EUR",
|
|
18
|
+
FI: "EUR",
|
|
19
|
+
FR: "EUR",
|
|
20
|
+
GB: "GBP",
|
|
21
|
+
IE: "EUR",
|
|
22
|
+
IN: "INR",
|
|
23
|
+
IT: "EUR",
|
|
24
|
+
JP: "JPY",
|
|
25
|
+
MX: "MXN",
|
|
26
|
+
NL: "EUR",
|
|
27
|
+
NO: "NOK",
|
|
28
|
+
NZ: "NZD",
|
|
29
|
+
PL: "PLN",
|
|
30
|
+
PT: "EUR",
|
|
31
|
+
SE: "SEK",
|
|
32
|
+
SG: "SGD",
|
|
33
|
+
US: "USD"
|
|
33
34
|
};
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
function
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
function S(n) {
|
|
123
|
-
const e = Math.max(0, Math.round(n.amount)), r = u(n.currencyCode), c = h(n.currencies)[r] ?? l(f(n.currencies)), o = P(c.rounding_increment, 1);
|
|
124
|
-
if (c.rounding_mode === "nearest")
|
|
125
|
-
return Math.round(e / o) * o;
|
|
126
|
-
if (c.rounding_mode === "up")
|
|
127
|
-
return Math.ceil(e / o) * o;
|
|
128
|
-
if (c.rounding_mode === "down")
|
|
129
|
-
return Math.floor(e / o) * o;
|
|
130
|
-
if (c.rounding_mode === "charm") {
|
|
131
|
-
const i = g(c.code), a = Math.min(
|
|
132
|
-
Math.max(c.rounding_charm_amount ?? 0, 0),
|
|
133
|
-
Math.max(i - 1, 0)
|
|
134
|
-
);
|
|
135
|
-
let s = Math.floor(e / i) * i + a;
|
|
136
|
-
return s < e && (s += i), s;
|
|
137
|
-
}
|
|
138
|
-
return e;
|
|
35
|
+
function s(e) {
|
|
36
|
+
return typeof e == "number" && Number.isFinite(e);
|
|
37
|
+
}
|
|
38
|
+
function c(e, t = 1) {
|
|
39
|
+
let n = typeof e == "string" ? Number.parseInt(e, 10) : e;
|
|
40
|
+
return typeof n == "number" && Number.isFinite(n) && n > 0 ? Math.max(1, Math.round(n)) : t;
|
|
41
|
+
}
|
|
42
|
+
function l(e) {
|
|
43
|
+
let t = typeof e == "string" ? Number.parseInt(e, 10) : e;
|
|
44
|
+
return typeof t == "number" && Number.isFinite(t) && t >= 0 ? Math.round(t) : null;
|
|
45
|
+
}
|
|
46
|
+
function u(e) {
|
|
47
|
+
if (typeof e == "string") {
|
|
48
|
+
let t = e.trim().toLowerCase();
|
|
49
|
+
if (a.includes(t)) return t;
|
|
50
|
+
}
|
|
51
|
+
return "none";
|
|
52
|
+
}
|
|
53
|
+
function d(e) {
|
|
54
|
+
let t = e || {}, n = i(typeof t.code == "string" ? t.code : null), r = t.is_default === !0;
|
|
55
|
+
return {
|
|
56
|
+
code: n,
|
|
57
|
+
symbol: typeof t.symbol == "string" && t.symbol.trim() ? t.symbol.trim() : n,
|
|
58
|
+
exchange_rate: r ? 1 : s(t.exchange_rate) && t.exchange_rate > 0 ? t.exchange_rate : 1,
|
|
59
|
+
is_default: r,
|
|
60
|
+
is_active: t.is_active !== !1,
|
|
61
|
+
auto_sync_product_prices: !r && t.auto_sync_product_prices === !0,
|
|
62
|
+
rounding_mode: u(t.rounding_mode),
|
|
63
|
+
rounding_increment: c(t.rounding_increment, 1),
|
|
64
|
+
rounding_charm_amount: l(t.rounding_charm_amount),
|
|
65
|
+
auto_update_exchange_rate: !r && t.auto_update_exchange_rate !== !1,
|
|
66
|
+
exchange_rate_source: typeof t.exchange_rate_source == "string" && t.exchange_rate_source.trim() ? t.exchange_rate_source.trim() : null,
|
|
67
|
+
exchange_rate_updated_at: typeof t.exchange_rate_updated_at == "string" && t.exchange_rate_updated_at.trim() ? t.exchange_rate_updated_at : null
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function f(e) {
|
|
71
|
+
return !e || typeof e != "object" || Array.isArray(e) ? {} : Object.entries(e).reduce((e, [t, n]) => {
|
|
72
|
+
let r = i(t), a = typeof n == "string" ? Number.parseFloat(n) : n;
|
|
73
|
+
return s(a) && a >= 0 && (e[r] = Math.round(a)), e;
|
|
74
|
+
}, {});
|
|
75
|
+
}
|
|
76
|
+
function p(e) {
|
|
77
|
+
return !e || typeof e != "object" || Array.isArray(e) ? {} : Object.entries(e).reduce((e, [t, n]) => {
|
|
78
|
+
let r = i(t), a = typeof n == "string" ? Number.parseFloat(n) : n;
|
|
79
|
+
return a === null ? (e[r] = null, e) : (s(a) && a >= 0 && (e[r] = Math.round(a)), e);
|
|
80
|
+
}, {});
|
|
81
|
+
}
|
|
82
|
+
function m(e) {
|
|
83
|
+
return e.map(d).find((e) => e.is_default) ?? d(e[0]) ?? d({
|
|
84
|
+
code: "USD",
|
|
85
|
+
symbol: "$",
|
|
86
|
+
exchange_rate: 1,
|
|
87
|
+
is_default: !0,
|
|
88
|
+
is_active: !0
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function h(e) {
|
|
92
|
+
return e.reduce((e, t) => {
|
|
93
|
+
let n = d(t);
|
|
94
|
+
return e[n.code] = n, e;
|
|
95
|
+
}, {});
|
|
96
|
+
}
|
|
97
|
+
function g(e, t) {
|
|
98
|
+
let n = i(t), r = m(e);
|
|
99
|
+
return h(e)[n]?.exchange_rate ?? (r.code, 1);
|
|
100
|
+
}
|
|
101
|
+
function _(e) {
|
|
102
|
+
let { amount: r, currencies: a } = e, o = i(e.fromCurrencyCode), s = i(e.toCurrencyCode);
|
|
103
|
+
if (!Number.isFinite(r)) return 0;
|
|
104
|
+
if (o === s) return Math.round(r);
|
|
105
|
+
let c = h(a), l = m(a), u = c[o]?.exchange_rate ?? (o === l.code ? 1 : l.exchange_rate), d = c[s]?.exchange_rate ?? (s === l.code ? 1 : l.exchange_rate), f = r / t(o) / u * d, p = n(f, s);
|
|
106
|
+
return e.applyRounding ? v({
|
|
107
|
+
amount: p,
|
|
108
|
+
currencyCode: s,
|
|
109
|
+
currencies: a
|
|
110
|
+
}) : p;
|
|
111
|
+
}
|
|
112
|
+
function v(e) {
|
|
113
|
+
let n = Math.max(0, Math.round(e.amount)), r = i(e.currencyCode), a = h(e.currencies)[r] ?? d(m(e.currencies)), o = c(a.rounding_increment, 1);
|
|
114
|
+
if (a.rounding_mode === "nearest") return Math.round(n / o) * o;
|
|
115
|
+
if (a.rounding_mode === "up") return Math.ceil(n / o) * o;
|
|
116
|
+
if (a.rounding_mode === "down") return Math.floor(n / o) * o;
|
|
117
|
+
if (a.rounding_mode === "charm") {
|
|
118
|
+
let e = t(a.code), r = Math.min(Math.max(a.rounding_charm_amount ?? 0, 0), Math.max(e - 1, 0)), i = Math.floor(n / e) * e + r;
|
|
119
|
+
return i < n && (i += e), i;
|
|
120
|
+
}
|
|
121
|
+
return n;
|
|
139
122
|
}
|
|
140
|
-
function
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
salePrices: r.sale_prices,
|
|
263
|
-
fallbackPrice: r.price,
|
|
264
|
-
fallbackSalePrice: r.sale_price,
|
|
265
|
-
saleStartAt: r.sale_start_at,
|
|
266
|
-
saleEndAt: r.sale_end_at,
|
|
267
|
-
scheduledPrice: r.scheduled_price,
|
|
268
|
-
scheduledPrices: r.scheduled_prices,
|
|
269
|
-
scheduledPriceAt: r.scheduled_price_at,
|
|
270
|
-
currencyCode: n.currencyCode,
|
|
271
|
-
currencies: n.currencies,
|
|
272
|
-
now: n.now
|
|
273
|
-
})
|
|
274
|
-
).map((r) => r.sale_price ?? r.price).filter((r) => Number.isFinite(r));
|
|
275
|
-
return e.length ? {
|
|
276
|
-
min: Math.min(...e),
|
|
277
|
-
max: Math.max(...e)
|
|
278
|
-
} : null;
|
|
279
|
-
}
|
|
280
|
-
function K(n, e) {
|
|
281
|
-
const r = f(e), t = n?.trim();
|
|
282
|
-
if (!t)
|
|
283
|
-
return r.code;
|
|
284
|
-
const o = t.replace("_", "-").split("-").map((d) => d.toUpperCase())[1];
|
|
285
|
-
if (!o)
|
|
286
|
-
return r.code;
|
|
287
|
-
const i = E[o];
|
|
288
|
-
return i && new Set(e.map((d) => u(d.code))).has(i) ? i : r.code;
|
|
289
|
-
}
|
|
290
|
-
function $(n) {
|
|
291
|
-
return n.map(l).sort((e, r) => e.is_default !== r.is_default ? e.is_default ? -1 : 1 : u(e.code).localeCompare(u(r.code)));
|
|
292
|
-
}
|
|
293
|
-
export {
|
|
294
|
-
R as CURRENCY_ROUNDING_MODES,
|
|
295
|
-
S as applyCurrencyRounding,
|
|
296
|
-
A as convertMinorUnitAmount,
|
|
297
|
-
T as describeCurrencyRoundingRule,
|
|
298
|
-
h as getCurrencyLookup,
|
|
299
|
-
f as getDefaultCurrency,
|
|
300
|
-
O as getExchangeRateForCurrency,
|
|
301
|
-
K as inferCurrencyCodeFromLocale,
|
|
302
|
-
w as isSaleWindowActive,
|
|
303
|
-
j as isScheduledPriceDue,
|
|
304
|
-
l as normalizeCurrencyRecord,
|
|
305
|
-
z as normalizeCurrencyRoundingMode,
|
|
306
|
-
C as normalizePriceMap,
|
|
307
|
-
U as normalizeSalePriceMap,
|
|
308
|
-
v as resolveEffectivePriceForCurrency,
|
|
309
|
-
D as resolvePriceForCurrency,
|
|
310
|
-
L as resolvePriceRangeForCurrency,
|
|
311
|
-
$ as sortCurrencies
|
|
312
|
-
};
|
|
123
|
+
function y(n) {
|
|
124
|
+
let i = d(n);
|
|
125
|
+
if (i.rounding_mode === "nearest") return `Nearest ${e(i.rounding_increment ?? 1, i.code)}`;
|
|
126
|
+
if (i.rounding_mode === "up") return `Round up to ${e(i.rounding_increment ?? 1, i.code)}`;
|
|
127
|
+
if (i.rounding_mode === "down") return `Round down to ${e(i.rounding_increment ?? 1, i.code)}`;
|
|
128
|
+
if (i.rounding_mode === "charm") {
|
|
129
|
+
let t = i.rounding_charm_amount ?? 0;
|
|
130
|
+
return `Charm ending ${e(t, i.code)}`;
|
|
131
|
+
}
|
|
132
|
+
return `Exact conversion (${r(1, i.code).toFixed(t(i.code) === 1 ? 0 : 2)} step)`;
|
|
133
|
+
}
|
|
134
|
+
function b(e, t) {
|
|
135
|
+
let n = m(t);
|
|
136
|
+
return e[n.code] === void 0 ? Object.keys(e)[0] ?? n.code : n.code;
|
|
137
|
+
}
|
|
138
|
+
function x(e) {
|
|
139
|
+
let { amountMap: t, fallbackAmount: n, currencies: r } = e, a = i(e.currencyCode), o = f(t);
|
|
140
|
+
if (o[a] !== void 0) return o[a];
|
|
141
|
+
if (Object.keys(o).length > 0) {
|
|
142
|
+
let e = b(o, r), t = o[e];
|
|
143
|
+
if (t !== void 0) return _({
|
|
144
|
+
amount: t,
|
|
145
|
+
fromCurrencyCode: e,
|
|
146
|
+
toCurrencyCode: a,
|
|
147
|
+
currencies: r,
|
|
148
|
+
applyRounding: !0
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return typeof n == "number" && Number.isFinite(n) ? _({
|
|
152
|
+
amount: n,
|
|
153
|
+
fromCurrencyCode: m(r).code,
|
|
154
|
+
toCurrencyCode: a,
|
|
155
|
+
currencies: r,
|
|
156
|
+
applyRounding: !0
|
|
157
|
+
}) : 0;
|
|
158
|
+
}
|
|
159
|
+
function S(e) {
|
|
160
|
+
let { prices: t = {}, salePrices: n = {}, fallbackPrice: r, fallbackSalePrice: a, currencies: o } = e, s = i(e.currencyCode), c = f(t), l = p(n), u = x({
|
|
161
|
+
amountMap: c,
|
|
162
|
+
fallbackAmount: r,
|
|
163
|
+
currencyCode: s,
|
|
164
|
+
currencies: o
|
|
165
|
+
}), d = x({
|
|
166
|
+
amountMap: f(l),
|
|
167
|
+
fallbackAmount: a,
|
|
168
|
+
currencyCode: s,
|
|
169
|
+
currencies: o
|
|
170
|
+
});
|
|
171
|
+
return {
|
|
172
|
+
currencyCode: s,
|
|
173
|
+
price: u,
|
|
174
|
+
sale_price: d > 0 && d <= u ? d : null
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function C(e) {
|
|
178
|
+
let t = (e.now ?? /* @__PURE__ */ new Date()).getTime();
|
|
179
|
+
if (e.saleStartAt) {
|
|
180
|
+
let n = new Date(e.saleStartAt).getTime();
|
|
181
|
+
if (Number.isFinite(n) && t < n) return !1;
|
|
182
|
+
}
|
|
183
|
+
if (e.saleEndAt) {
|
|
184
|
+
let n = new Date(e.saleEndAt).getTime();
|
|
185
|
+
if (Number.isFinite(n) && t >= n) return !1;
|
|
186
|
+
}
|
|
187
|
+
return !0;
|
|
188
|
+
}
|
|
189
|
+
function w(e) {
|
|
190
|
+
if (!e.scheduledPriceAt) return !1;
|
|
191
|
+
let t = new Date(e.scheduledPriceAt).getTime();
|
|
192
|
+
return Number.isFinite(t) ? (e.now ?? /* @__PURE__ */ new Date()).getTime() >= t : !1;
|
|
193
|
+
}
|
|
194
|
+
function T(e) {
|
|
195
|
+
let t = e.now ?? /* @__PURE__ */ new Date(), n = w({
|
|
196
|
+
scheduledPriceAt: e.scheduledPriceAt,
|
|
197
|
+
now: t
|
|
198
|
+
}), r = n ? e.scheduledPrices : e.prices, i = n ? e.scheduledPrice : e.fallbackPrice, a = C({
|
|
199
|
+
saleStartAt: e.saleStartAt,
|
|
200
|
+
saleEndAt: e.saleEndAt,
|
|
201
|
+
now: t
|
|
202
|
+
});
|
|
203
|
+
return S({
|
|
204
|
+
prices: r,
|
|
205
|
+
salePrices: a ? e.salePrices : null,
|
|
206
|
+
fallbackPrice: i,
|
|
207
|
+
fallbackSalePrice: a ? e.fallbackSalePrice : null,
|
|
208
|
+
currencyCode: e.currencyCode,
|
|
209
|
+
currencies: e.currencies
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
function E(e) {
|
|
213
|
+
let t = e.entries.map((t) => T({
|
|
214
|
+
prices: t.prices,
|
|
215
|
+
salePrices: t.sale_prices,
|
|
216
|
+
fallbackPrice: t.price,
|
|
217
|
+
fallbackSalePrice: t.sale_price,
|
|
218
|
+
saleStartAt: t.sale_start_at,
|
|
219
|
+
saleEndAt: t.sale_end_at,
|
|
220
|
+
scheduledPrice: t.scheduled_price,
|
|
221
|
+
scheduledPrices: t.scheduled_prices,
|
|
222
|
+
scheduledPriceAt: t.scheduled_price_at,
|
|
223
|
+
currencyCode: e.currencyCode,
|
|
224
|
+
currencies: e.currencies,
|
|
225
|
+
now: e.now
|
|
226
|
+
})).map((e) => e.sale_price ?? e.price).filter((e) => Number.isFinite(e));
|
|
227
|
+
return t.length ? {
|
|
228
|
+
min: Math.min(...t),
|
|
229
|
+
max: Math.max(...t)
|
|
230
|
+
} : null;
|
|
231
|
+
}
|
|
232
|
+
function D(e, t) {
|
|
233
|
+
let n = m(t), r = e?.trim();
|
|
234
|
+
if (!r) return n.code;
|
|
235
|
+
let a = r.replace("_", "-").split("-").map((e) => e.toUpperCase())[1];
|
|
236
|
+
if (!a) return n.code;
|
|
237
|
+
let s = o[a];
|
|
238
|
+
return s && new Set(t.map((e) => i(e.code))).has(s) ? s : n.code;
|
|
239
|
+
}
|
|
240
|
+
function O(e) {
|
|
241
|
+
return e.map(d).sort((e, t) => e.is_default === t.is_default ? i(e.code).localeCompare(i(t.code)) : e.is_default ? -1 : 1);
|
|
242
|
+
}
|
|
243
|
+
//#endregion
|
|
244
|
+
export { a as CURRENCY_ROUNDING_MODES, v as applyCurrencyRounding, _ as convertMinorUnitAmount, y as describeCurrencyRoundingRule, h as getCurrencyLookup, m as getDefaultCurrency, g as getExchangeRateForCurrency, D as inferCurrencyCodeFromLocale, C as isSaleWindowActive, w as isScheduledPriceDue, d as normalizeCurrencyRecord, u as normalizeCurrencyRoundingMode, f as normalizePriceMap, p as normalizeSalePriceMap, T as resolveEffectivePriceForCurrency, S as resolvePriceForCurrency, E as resolvePriceRangeForCurrency, O as sortCurrencies };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./customer.cjs");let t=require("@nextblock-cms/db/server");function n(e){return e?.trim()||null}function r(t){return t?e.normalizeCustomerAddress({company_name:t.company_name,recipient_name:t.recipient_name,line1:t.line1,line2:t.line2,city:t.city,state:t.state,postal_code:t.postal_code,country_code:t.country_code}):null}function i(e,t){return e?.find(e=>e.address_type===t&&e.is_default)??e?.find(e=>e.address_type===t)??null}async function a(t,n,r,i){let a=e.normalizeCustomerAddress(i),{data:o,error:s}=await t.from(`user_addresses`).select(`*`).eq(`user_id`,n).eq(`address_type`,r).order(`is_default`,{ascending:!1}).order(`updated_at`,{ascending:!1});if(s)throw Error(s.message);let c=o?.[0]??null,l=(o??[]).slice(1).map(e=>e.id);if(!a){if(o?.length){let e=o.map(e=>e.id),{error:n}=await t.from(`user_addresses`).delete().in(`id`,e);if(n)throw Error(n.message)}return}let u={user_id:n,address_type:r,is_default:!0,company_name:a.company_name??null,recipient_name:a.recipient_name??null,line1:a.line1??null,line2:a.line2??null,city:a.city??null,state:a.state??null,postal_code:a.postal_code??null,country_code:a.country_code??null,updated_at:new Date().toISOString()};if(c){let{error:e}=await t.from(`user_addresses`).update(u).eq(`id`,c.id);if(e)throw Error(e.message)}else{let{error:e}=await t.from(`user_addresses`).insert(u);if(e)throw Error(e.message)}if(l.length){let{error:e}=await t.from(`user_addresses`).delete().in(`id`,l);if(e)throw Error(e.message)}}async function o(e,n){let{data:a,error:o}=await(n??(0,t.createClient)()).from(`user_addresses`).select(`*`).eq(`user_id`,e).in(`address_type`,[`billing`,`shipping`]).order(`is_default`,{ascending:!1}).order(`updated_at`,{ascending:!1});if(o)throw Error(o.message);return{billingAddress:r(i(a??[],`billing`)),shippingAddress:r(i(a??[],`shipping`))}}async function s(e){let n=e.client??(0,t.createClient)();await a(n,e.userId,`billing`,e.billingAddress??null),await a(n,e.userId,`shipping`,e.shippingAddress??null)}async function c(e){let r=e.client??(0,t.createClient)(),i=n(e.fullName),a=n(e.phone);if(!i&&!a)return;let{data:o,error:s}=await r.from(`profiles`).select(`full_name, phone`).eq(`id`,e.userId).maybeSingle();if(s)throw Error(s.message);if(!o)return;let c=n(o.full_name)||i,l=n(o.phone)||a;if(n(o.full_name)===c&&n(o.phone)===l)return;let{error:u}=await r.from(`profiles`).update({full_name:c,phone:l,updated_at:new Date().toISOString()}).eq(`id`,e.userId);if(u)throw Error(u.message)}exports.fillMissingUserProfileCheckoutDetails=c,exports.getDefaultUserAddresses=o,exports.upsertDefaultUserAddresses=s;
|