@nextblock-cms/ecom 0.18.7 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/lib/CurrencyProvider.cjs.js +1 -1
  2. package/lib/CurrencyProvider.d.ts +1 -1
  3. package/lib/CurrencyProvider.es.js +21 -21
  4. package/lib/PaymentReadinessProvider.cjs.js +1 -1
  5. package/lib/PaymentReadinessProvider.d.ts +1 -1
  6. package/lib/PaymentReadinessProvider.es.js +11 -11
  7. package/lib/components/AccountNavigationMenu.cjs.js +1 -1
  8. package/lib/components/AccountNavigationMenu.d.ts +1 -1
  9. package/lib/components/AccountNavigationMenu.es.js +28 -28
  10. package/lib/components/AddToCartButton.cjs.js +1 -1
  11. package/lib/components/AddToCartButton.d.ts +1 -1
  12. package/lib/components/AddToCartButton.es.js +48 -48
  13. package/lib/components/Cart.cjs.js +1 -1
  14. package/lib/components/Cart.d.ts +1 -1
  15. package/lib/components/Cart.es.js +144 -144
  16. package/lib/components/CartDrawer.cjs.js +1 -1
  17. package/lib/components/CartDrawer.d.ts +1 -1
  18. package/lib/components/CartDrawer.es.js +95 -95
  19. package/lib/components/CartIcon.cjs.js +1 -1
  20. package/lib/components/CartIcon.d.ts +1 -1
  21. package/lib/components/CartIcon.es.js +20 -20
  22. package/lib/components/Checkout.cjs.js +1 -1
  23. package/lib/components/Checkout.d.ts +1 -1
  24. package/lib/components/Checkout.es.js +712 -712
  25. package/lib/components/CouponForm.cjs.js +1 -1
  26. package/lib/components/CouponForm.d.ts +1 -1
  27. package/lib/components/CouponForm.es.js +89 -89
  28. package/lib/components/CurrencySwitcher.cjs.js +1 -1
  29. package/lib/components/CurrencySwitcher.d.ts +1 -1
  30. package/lib/components/CurrencySwitcher.es.js +14 -14
  31. package/lib/components/CustomerProfileForm.cjs.js +1 -1
  32. package/lib/components/CustomerProfileForm.d.ts +1 -1
  33. package/lib/components/CustomerProfileForm.es.js +263 -263
  34. package/lib/components/FeaturedProduct.cjs.js +1 -1
  35. package/lib/components/FeaturedProduct.d.ts +1 -1
  36. package/lib/components/FeaturedProduct.es.js +38 -38
  37. package/lib/components/FreemiusLicensePanel.cjs.js +1 -1
  38. package/lib/components/FreemiusLicensePanel.d.ts +1 -1
  39. package/lib/components/FreemiusLicensePanel.es.js +47 -47
  40. package/lib/components/InvoiceDocument.cjs.js +1 -1
  41. package/lib/components/InvoiceDocument.d.ts +2 -1
  42. package/lib/components/InvoiceDocument.es.js +164 -164
  43. package/lib/components/InvoiceViewerShell.cjs.js +2 -2
  44. package/lib/components/InvoiceViewerShell.d.ts +1 -1
  45. package/lib/components/InvoiceViewerShell.es.js +57 -57
  46. package/lib/components/ProductCard.cjs.js +1 -1
  47. package/lib/components/ProductCard.d.ts +1 -1
  48. package/lib/components/ProductCard.es.js +98 -98
  49. package/lib/components/ProductDetailsLayout.cjs.js +1 -1
  50. package/lib/components/ProductDetailsLayout.es.js +267 -267
  51. package/lib/components/ProductGallery.cjs.js +1 -1
  52. package/lib/components/ProductGallery.d.ts +1 -1
  53. package/lib/components/ProductGallery.es.js +26 -26
  54. package/lib/components/ProductGrid.cjs.js +1 -1
  55. package/lib/components/ProductGrid.d.ts +1 -1
  56. package/lib/components/ProductGrid.es.js +12 -12
  57. package/lib/components/ShippingEstimator.cjs.js +1 -1
  58. package/lib/components/ShippingEstimator.d.ts +1 -1
  59. package/lib/components/ShippingEstimator.es.js +90 -90
  60. package/lib/components/SimpleTiptapRenderer.cjs.js +1 -1
  61. package/lib/components/SimpleTiptapRenderer.es.js +135 -135
  62. package/lib/components/SubscriptionSelector.cjs.js +1 -1
  63. package/lib/components/SubscriptionSelector.d.ts +2 -1
  64. package/lib/components/SubscriptionSelector.es.js +97 -97
  65. package/lib/components/media/MediaPickerDialog.d.ts +2 -1
  66. package/lib/components/media/MediaUploadForm.d.ts +2 -1
  67. package/lib/components/media/UploadFolderContext.d.ts +1 -1
  68. package/lib/freemius-trial-provision.cjs.js +1 -0
  69. package/lib/freemius-trial-provision.d.ts +85 -0
  70. package/lib/freemius-trial-provision.es.js +136 -0
  71. package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -1
  72. package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
  73. package/lib/pages/cms/coupons/CouponEditorForm.es.js +107 -107
  74. package/lib/pages/cms/coupons/CouponsPage.cjs.js +2 -2
  75. package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
  76. package/lib/pages/cms/coupons/CouponsPage.es.js +90 -90
  77. package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -1
  78. package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
  79. package/lib/pages/cms/coupons/CreateCouponDialog.es.js +22 -22
  80. package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -1
  81. package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
  82. package/lib/pages/cms/coupons/EditCouponPage.es.js +31 -31
  83. package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -1
  84. package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
  85. package/lib/pages/cms/coupons/ProductScopePicker.es.js +65 -65
  86. package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -1
  87. package/lib/pages/cms/orders/ExportReportsDialog.d.ts +2 -1
  88. package/lib/pages/cms/orders/ExportReportsDialog.es.js +86 -86
  89. package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
  90. package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -1
  91. package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
  92. package/lib/pages/cms/orders/OrderDetailPage.es.js +96 -96
  93. package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -1
  94. package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
  95. package/lib/pages/cms/orders/OrderPrintButton.es.js +4 -4
  96. package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -1
  97. package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
  98. package/lib/pages/cms/orders/OrderStatusForm.es.js +41 -41
  99. package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -1
  100. package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
  101. package/lib/pages/cms/orders/OrdersPage.es.js +69 -69
  102. package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -1
  103. package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
  104. package/lib/pages/cms/payments/PaymentsClient.es.js +142 -142
  105. package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -1
  106. package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
  107. package/lib/pages/cms/payments/PaymentsPage.es.js +7 -7
  108. package/lib/pages/cms/products/ProductsPage.cjs.js +1 -1
  109. package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
  110. package/lib/pages/cms/products/ProductsPage.es.js +47 -47
  111. package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
  112. package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -1
  113. package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +65 -65
  114. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -1
  115. package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
  116. package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +35 -35
  117. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -1
  118. package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
  119. package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +199 -199
  120. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -1
  121. package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
  122. package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +17 -17
  123. package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -1
  124. package/lib/pages/cms/products/categories/components/CategoryManager.d.ts +2 -1
  125. package/lib/pages/cms/products/categories/components/CategoryManager.es.js +138 -138
  126. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -1
  127. package/lib/pages/cms/products/components/CopyProductFromLanguage.d.ts +2 -1
  128. package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +75 -75
  129. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -1
  130. package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
  131. package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +79 -79
  132. package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -1
  133. package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
  134. package/lib/pages/cms/products/components/DeleteProductButton.es.js +16 -16
  135. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -1
  136. package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
  137. package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +57 -57
  138. package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -1
  139. package/lib/pages/cms/products/components/ProductCategorySelector.d.ts +2 -1
  140. package/lib/pages/cms/products/components/ProductCategorySelector.es.js +103 -103
  141. package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
  142. package/lib/pages/cms/products/components/ProductForm.d.ts +1 -1
  143. package/lib/pages/cms/products/components/ProductForm.es.js +408 -408
  144. package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -1
  145. package/lib/pages/cms/products/components/ProductMediaManager.d.ts +1 -1
  146. package/lib/pages/cms/products/components/ProductMediaManager.es.js +58 -58
  147. package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -1
  148. package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
  149. package/lib/pages/cms/products/components/ProductsBulkTable.es.js +214 -214
  150. package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -1
  151. package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
  152. package/lib/pages/cms/products/components/SaleScheduleFields.es.js +57 -57
  153. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -1
  154. package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
  155. package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +9 -9
  156. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +2 -2
  157. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
  158. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +14 -14
  159. package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
  160. package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -1
  161. package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
  162. package/lib/pages/cms/products/components/VariationsEditor.es.js +236 -236
  163. package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -1
  164. package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
  165. package/lib/pages/cms/products/inventory/InventoryPage.es.js +11 -11
  166. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -2
  167. package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
  168. package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +156 -156
  169. package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -1
  170. package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
  171. package/lib/pages/cms/products/new/NewProductPage.es.js +36 -36
  172. package/lib/pages/cms/shipping/ShippingPage.cjs.js +2 -2
  173. package/lib/pages/cms/shipping/ShippingPage.d.ts +2 -1
  174. package/lib/pages/cms/shipping/ShippingPage.es.js +168 -168
  175. package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -1
  176. package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
  177. package/lib/pages/cms/shipping/components/RateForm.es.js +288 -288
  178. package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -1
  179. package/lib/pages/cms/shipping/components/ZoneForm.d.ts +2 -1
  180. package/lib/pages/cms/shipping/components/ZoneForm.es.js +141 -141
  181. package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -1
  182. package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
  183. package/lib/pages/cms/taxes/TaxesPage.es.js +129 -129
  184. package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -1
  185. package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
  186. package/lib/pages/cms/taxes/components/TaxRateForm.es.js +55 -55
  187. package/lib/product-context.cjs.js +1 -1
  188. package/lib/product-context.es.js +7 -7
  189. package/package.json +4 -4
  190. package/server.cjs.js +1 -1
  191. package/server.d.ts +1 -0
  192. package/server.es.js +180 -172
@@ -1,53 +1,53 @@
1
1
  'use client';
2
- import { jsxDEV as i } from "react/jsx-dev-runtime";
3
- import { useState as x, useEffect as q } from "react";
4
- import { Button as L } from "@nextblock-cms/ui/button";
5
- import { Skeleton as C } from "@nextblock-cms/ui/Skeleton";
6
- import { useCart as j } from "../use-cart.es.js";
7
- import { ShoppingCart as E } from "lucide-react";
8
- import { toast as k } from "sonner";
9
- import { getPublicFreemiusPricing as F } from "../pages/cms/products/actions.es.js";
10
- import { useTranslations as I, majorUnitAmountToMinor as m, formatPrice as U } from "@nextblock-cms/utils";
11
- import { useCurrency as B } from "../CurrencyProvider.es.js";
2
+ import { jsxDEV as n } from "react/jsx-dev-runtime";
3
+ import { useState as N, useEffect as A } from "react";
4
+ import { Button as T } from "@nextblock-cms/ui/button";
5
+ import { Skeleton as S } from "@nextblock-cms/ui/Skeleton";
6
+ import { useCart as $ } from "../use-cart.es.js";
7
+ import { ShoppingCart as q } from "lucide-react";
8
+ import { toast as v } from "sonner";
9
+ import { getPublicFreemiusPricing as L } from "../pages/cms/products/actions.es.js";
10
+ import { useTranslations as E, majorUnitAmountToMinor as m, formatPrice as F } from "@nextblock-cms/utils";
11
+ import { useCurrency as I } from "../CurrencyProvider.es.js";
12
12
  import { convertMinorUnitAmount as p } from "../currency.es.js";
13
13
  import { getTrialSummary as V } from "../trials.es.js";
14
- const ie = ({ product: e }) => {
15
- const N = j((l) => l), { t } = I(), { activeCurrencyCode: c, currencies: u, defaultCurrency: r } = B(), [D, W] = x([]), [w, P] = x(!0), [n, a] = x("annual");
16
- if (q(() => {
14
+ const ne = ({ product: e }) => {
15
+ const x = $((l) => l), { t } = E(), { activeCurrencyCode: s, currencies: a, defaultCurrency: i } = I(), [R, j] = N([]), [U, B] = N(!0), [o, d] = N("annual");
16
+ if (A(() => {
17
17
  async function l() {
18
18
  try {
19
19
  if (!e.id) return;
20
- const s = await F(e.id);
21
- W(s);
22
- } catch (s) {
23
- console.error("Failed to load pricing:", s);
20
+ const c = await L(e.id);
21
+ j(c);
22
+ } catch (c) {
23
+ console.error("Failed to load pricing:", c);
24
24
  } finally {
25
- P(!1);
25
+ B(!1);
26
26
  }
27
27
  }
28
28
  l();
29
- }, [e.id]), !N)
30
- return /* @__PURE__ */ i(C, { className: "h-14 w-full" }, void 0, !1, {
31
- fileName: "D:/Websites/nextblock-production/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
29
+ }, [e.id]), !x)
30
+ return /* @__PURE__ */ n(S, { className: "h-14 w-full" }, void 0, !1, {
31
+ fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
32
32
  lineNumber: 50,
33
33
  columnNumber: 12
34
34
  }, void 0);
35
- const { addItem: M } = N, d = D[0], o = d?.pricing?.[0], R = () => {
36
- let l = e.price, s = e.freemius_plan_id;
37
- o && (n === "monthly" && o.monthly_price != null && (l = m(o.monthly_price, r.code)), n === "annual" && o.annual_price != null && (l = m(o.annual_price, r.code)), n === "lifetime" && o.lifetime_price != null && (l = m(o.lifetime_price, r.code)));
38
- const y = u.reduce((S, v) => (S[v.code] = p({
35
+ const { addItem: D } = x, u = R[0], r = u?.pricing?.[0], H = () => {
36
+ let l = e.price, c = e.freemius_plan_id;
37
+ r && (o === "monthly" && r.monthly_price != null && (l = m(r.monthly_price, i.code)), o === "annual" && r.annual_price != null && (l = m(r.annual_price, i.code)), o === "lifetime" && r.lifetime_price != null && (l = m(r.lifetime_price, i.code)));
38
+ const y = a.reduce((C, k) => (C[k.code] = p({
39
39
  amount: l,
40
- fromCurrencyCode: r.code,
41
- toCurrencyCode: v.code,
42
- currencies: u,
40
+ fromCurrencyCode: i.code,
41
+ toCurrencyCode: k.code,
42
+ currencies: a,
43
43
  applyRounding: !0
44
- }), S), {}), A = y[c] ?? l;
45
- d && d.id && (s = d.id);
46
- const { success: T, error: $ } = M({
44
+ }), C), {}), w = y[s] ?? l;
45
+ u && u.id && (c = u.id);
46
+ const { success: P, error: M } = D({
47
47
  id: e.id,
48
48
  product_id: e.id,
49
49
  title: e.title,
50
- price: A,
50
+ price: w,
51
51
  prices: y,
52
52
  image_url: e.image_url,
53
53
  slug: e.slug,
@@ -57,160 +57,160 @@ const ie = ({ product: e }) => {
57
57
  product_type: "digital",
58
58
  payment_provider: "freemius",
59
59
  provider: "freemius",
60
- billing_cycle: n,
60
+ billing_cycle: o,
61
61
  freemius_product_id: e.freemius_product_id,
62
- freemius_plan_id: s,
62
+ freemius_plan_id: c,
63
63
  // Overwrite if we got a real plan id
64
64
  trial_period_days: e.trial_period_days ?? 0,
65
65
  trial_requires_payment_method: e.trial_requires_payment_method ?? !1,
66
66
  is_taxable: e.is_taxable,
67
- currency_code: c
67
+ currency_code: s
68
68
  });
69
- T ? k.success(t("ecommerce.added_to_cart_success", { item: e.title })) : k.error($ || t("ecommerce.added_to_cart_error"));
69
+ P ? v.success(t("ecommerce.added_to_cart_success", { item: e.title })) : v.error(M || t("ecommerce.added_to_cart_error"));
70
70
  };
71
- if (w)
72
- return /* @__PURE__ */ i(C, { className: "h-32 w-full" }, void 0, !1, {
73
- fileName: "D:/Websites/nextblock-production/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
71
+ if (U)
72
+ return /* @__PURE__ */ n(S, { className: "h-32 w-full" }, void 0, !1, {
73
+ fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
74
74
  lineNumber: 123,
75
75
  columnNumber: 13
76
76
  }, void 0);
77
- if (!d || !o)
78
- return /* @__PURE__ */ i("div", { className: "p-4 border border-dashed rounded-lg text-center text-muted-foreground", children: t("ecommerce.pricing_unavailable") }, void 0, !1, {
79
- fileName: "D:/Websites/nextblock-production/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
77
+ if (!u || !r)
78
+ return /* @__PURE__ */ n("div", { className: "p-4 border border-dashed rounded-lg text-center text-muted-foreground", children: t("ecommerce.pricing_unavailable") }, void 0, !1, {
79
+ fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
80
80
  lineNumber: 128,
81
81
  columnNumber: 9
82
82
  }, void 0);
83
- const _ = o.monthly_price != null, g = o.annual_price != null, h = o.lifetime_price != null;
84
- n === "annual" && !g && (_ ? a("monthly") : h && a("lifetime"));
85
- const b = V(e);
86
- let f = e.price;
87
- return n === "monthly" && o.monthly_price != null && (f = p({
88
- amount: m(o.monthly_price, r.code),
89
- fromCurrencyCode: r.code,
90
- toCurrencyCode: c,
91
- currencies: u,
83
+ const _ = r.monthly_price != null, g = r.annual_price != null, h = r.lifetime_price != null;
84
+ o === "annual" && !g && (_ ? d("monthly") : h && d("lifetime"));
85
+ const f = V(e);
86
+ let b = e.price;
87
+ return o === "monthly" && r.monthly_price != null && (b = p({
88
+ amount: m(r.monthly_price, i.code),
89
+ fromCurrencyCode: i.code,
90
+ toCurrencyCode: s,
91
+ currencies: a,
92
92
  applyRounding: !0
93
- })), n === "annual" && o.annual_price != null && (f = p({
94
- amount: m(o.annual_price, r.code),
95
- fromCurrencyCode: r.code,
96
- toCurrencyCode: c,
97
- currencies: u,
93
+ })), o === "annual" && r.annual_price != null && (b = p({
94
+ amount: m(r.annual_price, i.code),
95
+ fromCurrencyCode: i.code,
96
+ toCurrencyCode: s,
97
+ currencies: a,
98
98
  applyRounding: !0
99
- })), n === "lifetime" && o.lifetime_price != null && (f = p({
100
- amount: m(o.lifetime_price, r.code),
101
- fromCurrencyCode: r.code,
102
- toCurrencyCode: c,
103
- currencies: u,
99
+ })), o === "lifetime" && r.lifetime_price != null && (b = p({
100
+ amount: m(r.lifetime_price, i.code),
101
+ fromCurrencyCode: i.code,
102
+ toCurrencyCode: s,
103
+ currencies: a,
104
104
  applyRounding: !0
105
- })), /* @__PURE__ */ i("div", { className: "flex flex-col gap-4", children: [
106
- /* @__PURE__ */ i("div", { className: "flex bg-secondary/35 p-1 rounded-lg w-full max-w-sm mx-auto shadow-inner", children: [
107
- _ && /* @__PURE__ */ i(
105
+ })), /* @__PURE__ */ n("div", { className: "flex flex-col gap-4", children: [
106
+ /* @__PURE__ */ n("div", { className: "flex bg-secondary/35 p-1 rounded-lg w-full max-w-sm mx-auto shadow-inner", children: [
107
+ _ && /* @__PURE__ */ n(
108
108
  "button",
109
109
  {
110
- onClick: () => a("monthly"),
111
- className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-all ${n === "monthly" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
110
+ onClick: () => d("monthly"),
111
+ className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-all ${o === "monthly" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
112
112
  children: t("ecommerce.monthly")
113
113
  },
114
114
  void 0,
115
115
  !1,
116
116
  {
117
- fileName: "D:/Websites/nextblock-production/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
117
+ fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
118
118
  lineNumber: 181,
119
119
  columnNumber: 13
120
120
  },
121
121
  void 0
122
122
  ),
123
- g && /* @__PURE__ */ i(
123
+ g && /* @__PURE__ */ n(
124
124
  "button",
125
125
  {
126
- onClick: () => a("annual"),
127
- className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-all ${n === "annual" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
126
+ onClick: () => d("annual"),
127
+ className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-all ${o === "annual" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
128
128
  children: t("ecommerce.annual")
129
129
  },
130
130
  void 0,
131
131
  !1,
132
132
  {
133
- fileName: "D:/Websites/nextblock-production/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
133
+ fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
134
134
  lineNumber: 193,
135
135
  columnNumber: 13
136
136
  },
137
137
  void 0
138
138
  ),
139
- h && /* @__PURE__ */ i(
139
+ h && /* @__PURE__ */ n(
140
140
  "button",
141
141
  {
142
- onClick: () => a("lifetime"),
143
- className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-all ${n === "lifetime" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
142
+ onClick: () => d("lifetime"),
143
+ className: `flex-1 py-1.5 text-xs font-semibold rounded-md transition-all ${o === "lifetime" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
144
144
  children: t("ecommerce.lifetime")
145
145
  },
146
146
  void 0,
147
147
  !1,
148
148
  {
149
- fileName: "D:/Websites/nextblock-production/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
149
+ fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
150
150
  lineNumber: 205,
151
151
  columnNumber: 13
152
152
  },
153
153
  void 0
154
154
  )
155
155
  ] }, void 0, !0, {
156
- fileName: "D:/Websites/nextblock-production/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
156
+ fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
157
157
  lineNumber: 179,
158
158
  columnNumber: 7
159
159
  }, void 0),
160
- /* @__PURE__ */ i("div", { className: "text-center", children: [
161
- /* @__PURE__ */ i("span", { className: "text-3xl font-extrabold text-foreground", children: U(f, c) }, void 0, !1, {
162
- fileName: "D:/Websites/nextblock-production/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
160
+ /* @__PURE__ */ n("div", { className: "text-center", children: [
161
+ /* @__PURE__ */ n("span", { className: "text-3xl font-extrabold text-foreground", children: F(b, s) }, void 0, !1, {
162
+ fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
163
163
  lineNumber: 219,
164
164
  columnNumber: 11
165
165
  }, void 0),
166
- n !== "lifetime" && /* @__PURE__ */ i("span", { className: "text-muted-foreground text-sm ml-1.5", children: [
166
+ o !== "lifetime" && /* @__PURE__ */ n("span", { className: "text-muted-foreground text-sm ml-1.5", children: [
167
167
  "/ ",
168
- t(n === "annual" ? "ecommerce.year" : "ecommerce.month")
168
+ t(o === "annual" ? "ecommerce.year" : "ecommerce.month")
169
169
  ] }, void 0, !0, {
170
- fileName: "D:/Websites/nextblock-production/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
170
+ fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
171
171
  lineNumber: 223,
172
172
  columnNumber: 15
173
173
  }, void 0),
174
- b && /* @__PURE__ */ i("div", { className: "mt-1 text-xs font-medium text-emerald-600 dark:text-emerald-400", children: [
175
- b.label,
176
- /* @__PURE__ */ i("span", { className: "mx-2 text-muted-foreground/50", children: "|" }, void 0, !1, {
177
- fileName: "D:/Websites/nextblock-production/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
174
+ f && /* @__PURE__ */ n("div", { className: "mt-1 text-xs font-medium text-emerald-600 dark:text-emerald-400", children: [
175
+ f.label,
176
+ /* @__PURE__ */ n("span", { className: "mx-2 text-muted-foreground/50", children: "|" }, void 0, !1, {
177
+ fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
178
178
  lineNumber: 228,
179
179
  columnNumber: 15
180
180
  }, void 0),
181
- /* @__PURE__ */ i("span", { className: "text-muted-foreground", children: b.paymentRequirementLabel }, void 0, !1, {
182
- fileName: "D:/Websites/nextblock-production/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
181
+ /* @__PURE__ */ n("span", { className: "text-muted-foreground", children: f.paymentRequirementLabel }, void 0, !1, {
182
+ fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
183
183
  lineNumber: 229,
184
184
  columnNumber: 15
185
185
  }, void 0)
186
186
  ] }, void 0, !0, {
187
- fileName: "D:/Websites/nextblock-production/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
187
+ fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
188
188
  lineNumber: 226,
189
189
  columnNumber: 13
190
190
  }, void 0)
191
191
  ] }, void 0, !0, {
192
- fileName: "D:/Websites/nextblock-production/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
192
+ fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
193
193
  lineNumber: 218,
194
194
  columnNumber: 7
195
195
  }, void 0),
196
- /* @__PURE__ */ i(L, { onClick: R, className: "w-full h-12 text-md font-bold shadow-md transition-all hover:shadow-lg active:scale-[0.98]", children: [
197
- /* @__PURE__ */ i(E, { className: "mr-2 h-4 w-4" }, void 0, !1, {
198
- fileName: "D:/Websites/nextblock-production/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
196
+ /* @__PURE__ */ n(T, { onClick: H, className: "w-full h-12 text-md font-bold shadow-md transition-all hover:shadow-lg active:scale-[0.98]", children: [
197
+ /* @__PURE__ */ n(q, { className: "mr-2 h-4 w-4" }, void 0, !1, {
198
+ fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
199
199
  lineNumber: 237,
200
200
  columnNumber: 9
201
201
  }, void 0),
202
- b?.label ? `Start ${b.label}` : t("ecommerce.get_license")
202
+ f?.label ? `Start ${f.label}` : t("ecommerce.get_license")
203
203
  ] }, void 0, !0, {
204
- fileName: "D:/Websites/nextblock-production/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
204
+ fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
205
205
  lineNumber: 236,
206
206
  columnNumber: 7
207
207
  }, void 0)
208
208
  ] }, void 0, !0, {
209
- fileName: "D:/Websites/nextblock-production/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
209
+ fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/components/SubscriptionSelector.tsx",
210
210
  lineNumber: 177,
211
211
  columnNumber: 5
212
212
  }, void 0);
213
213
  };
214
214
  export {
215
- ie as SubscriptionSelector
215
+ ne as SubscriptionSelector
216
216
  };
@@ -1,3 +1,4 @@
1
+ import { default as React } from 'react';
1
2
  import { Database } from '../../../../../db/src/index.ts';
2
3
  type Media = Database["public"]["Tables"]["media"]["Row"];
3
4
  interface MediaPickerDialogProps {
@@ -11,5 +12,5 @@ interface MediaPickerDialogProps {
11
12
  hideTrigger?: boolean;
12
13
  defaultFolder?: string;
13
14
  }
14
- export default function MediaPickerDialog({ triggerLabel, triggerVariant, onSelect, accept, title, open, onOpenChange, hideTrigger, defaultFolder, }: MediaPickerDialogProps): import("react/jsx-runtime").JSX.Element;
15
+ export default function MediaPickerDialog({ triggerLabel, triggerVariant, onSelect, accept, title, open, onOpenChange, hideTrigger, defaultFolder, }: MediaPickerDialogProps): React.JSX.Element;
15
16
  export {};
@@ -1,3 +1,4 @@
1
+ import { default as React } from 'react';
1
2
  import { Database } from '../../../../../db/src/index.ts';
2
3
  type Media = Database['public']['Tables']['media']['Row'];
3
4
  interface MediaUploadFormProps {
@@ -5,5 +6,5 @@ interface MediaUploadFormProps {
5
6
  returnJustData?: boolean;
6
7
  defaultFolder?: string;
7
8
  }
8
- export default function MediaUploadForm({ onUploadSuccess, returnJustData, defaultFolder }: MediaUploadFormProps): import("react/jsx-runtime").JSX.Element;
9
+ export default function MediaUploadForm({ onUploadSuccess, returnJustData, defaultFolder }: MediaUploadFormProps): React.JSX.Element;
9
10
  export {};
@@ -5,6 +5,6 @@ type UploadFolderContextValue = {
5
5
  export declare function UploadFolderProvider({ defaultFolder, children }: {
6
6
  defaultFolder?: string;
7
7
  children: React.ReactNode;
8
- }): import("react/jsx-runtime").JSX.Element;
8
+ }): React.JSX.Element;
9
9
  export declare function useUploadFolder(): UploadFolderContextValue;
10
10
  export {};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("@freemius/sdk"),F=require("./payment-config.cjs.js"),v=require("./providers/freemius.cjs.js"),y="A NextBlock license or trial already exists for this email. Activate that key from CMS Settings → Packages, or purchase a license at nextblock.dev.",m="The trial could not be provisioned automatically. Start it from CMS Settings → Packages instead.";function I(e){return e.toISOString().slice(0,19).replace("T"," ")}function S(e,n){const r=Number.isFinite(n)&&n>0?Math.floor(n):30;return new Date(e.getTime()+r*24*60*60*1e3)}function E(e){const n=e.filter(t=>t.id!==null&&t.id!==void 0);if(n.length===0)return null;const r=n.filter(t=>!t.is_hidden);return[...r.length>0?r:n].sort((t,s)=>{const a=t.licenses===null||t.licenses===void 0?Number.POSITIVE_INFINITY:t.licenses,u=s.licenses===null||s.licenses===void 0?Number.POSITIVE_INFINITY:s.licenses;return a-u})[0]}function k(e){return e.existingLicenses.some(r=>r.plugin_id===null||r.plugin_id===void 0||String(r.plugin_id).trim()===String(e.productId).trim())?{ok:!1,reason:"already_licensed"}:{ok:!0}}function b(e){return e.trim().toLowerCase()}async function w(e,n){await F.hydrateFreemiusEnvFromDb();const r=v.resolveFreemiusCheckoutCredentials(e.productId);if(!r.apiKey||!r.secretKey||!r.publicKey)return{error:"The license service is not configured for this product.",ok:!1,reason:"not_configured",status:503};const c=new T.Freemius({apiKey:r.apiKey,productId:Number(e.productId),publicKey:r.publicKey,secretKey:r.secretKey}),t=b(e.email),s=c.api.__unstable_ApiClient,a={product_id:e.productId};let u=[];try{const i=await c.api.user.retrieveByEmail(t);i?.id!==null&&i?.id!==void 0&&(u=await c.api.user.retrieveLicenses(i.id))}catch(i){return console.error("[Freemius trial] user lookup failed:",i),{error:"Freemius could not be reached to verify eligibility.",ok:!1,reason:"upstream_error",status:502}}if(!k({existingLicenses:u,productId:e.productId}).ok)return{error:y,ok:!1,reason:"already_licensed",status:409};let d=null;try{const{data:i,error:l}=await s.GET("/products/{product_id}/plans/{plan_id}/pricing.json",{params:{path:{...a,plan_id:e.planId}}});if(l)throw new Error(JSON.stringify(l));const o=E(i?.pricing??[]);d=o?.id!==null&&o?.id!==void 0?String(o.id):null}catch(i){return console.error("[Freemius trial] pricing lookup failed:",i),{error:"Freemius could not be reached to resolve the plan pricing.",ok:!1,reason:"upstream_error",status:502}}if(!d)return{error:m,ok:!1,reason:"no_pricing",status:502};const h=n?.now??new Date,f=I(S(h,e.trialDays));let p=null,_=null;try{const{data:i,error:l}=await s.POST("/products/{product_id}/plans/{plan_id}/pricing/{pricing_id}/licenses.json",{body:{expires_at:f,is_block_features:!0,send_email:!1},params:{path:{...a,plan_id:e.planId,pricing_id:d}}});if(l)throw new Error(JSON.stringify(l));const o=i?.license;p=o?.secret_key?.trim()||null,_=o?.id!==null&&o?.id!==void 0?String(o.id):null}catch(i){return console.error("[Freemius trial] license creation failed:",i),{error:"Freemius could not create the trial license.",ok:!1,reason:"upstream_error",status:502}}if(!p)return{error:m,ok:!1,reason:"no_key",status:502};let g=!1;try{const{error:i}=await s.PUT("/products/{product_id}/licenses.json",{body:{email:t,license_key:p,name:e.name.trim()},params:{path:a}});g=!i,i&&console.warn("[Freemius trial] license assignment refused:",JSON.stringify(i))}catch(i){console.warn("[Freemius trial] license assignment failed:",i)}return{assigned:g,expiresAt:f,licenseId:_,licenseKey:p,ok:!0,planId:e.planId,pricingId:d}}exports.FREEMIUS_TRIAL_ALREADY_USED_MESSAGE=y;exports.FREEMIUS_TRIAL_PROVISION_FAILED_MESSAGE=m;exports.computeTrialExpiry=S;exports.evaluateTrialEligibility=k;exports.formatFreemiusTimestamp=I;exports.pickTrialPricing=E;exports.provisionFreemiusTrialLicense=w;
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Vendor-side headless trial provisioning.
3
+ *
4
+ * The in-dashboard trial goes through the Freemius checkout overlay, which collects the
5
+ * buyer's name and email itself and creates a real Freemius *trial* (a subscription in a
6
+ * trialing state). Freemius exposes no API to start such a trial from a name and an
7
+ * email alone — the trial endpoint is install-scoped, and an install only exists once
8
+ * the buyer's site has activated something.
9
+ *
10
+ * What the API does allow the vendor to do is mint a time-boxed license on the plan
11
+ * (`POST .../plans/{plan}/pricing/{pricing}/licenses.json` with `expires_at`) and then
12
+ * assign it to an email (`PUT /products/{product}/licenses.json`), which creates the
13
+ * Freemius user if needed and sends the welcome email with the key. Functionally that is
14
+ * the same 30-day, no-card trial the overlay produces: the buyer's CMS activates the key
15
+ * normally, `package_activations.meta.nextblock.trial_ends_at` expires it locally, and
16
+ * the daily revalidation sees Freemius report it expired. What it is not is a Freemius
17
+ * subscription, so it never auto-converts — which a no-card trial cannot do anyway.
18
+ *
19
+ * Abuse controls: one trial per email per product (any existing license, even expired,
20
+ * refuses a new one), plus the route's per-address and per-email rate limits. The
21
+ * request is the buyer's own email, so the refusal names the reason.
22
+ */
23
+ export type FreemiusTrialProvisionRequest = {
24
+ email: string;
25
+ name: string;
26
+ /** Freemius plan the trial license is minted on (`fm_plan_id` in the package registry). */
27
+ planId: string;
28
+ /** Freemius product id (`fm_product_id` in the package registry). */
29
+ productId: string;
30
+ trialDays: number;
31
+ };
32
+ export type FreemiusTrialProvisionRejection = 'already_licensed' | 'no_key' | 'no_pricing';
33
+ export type FreemiusTrialProvisionResult = {
34
+ /** False when the license was minted but could not be tied to the email; the key still works. */
35
+ assigned: boolean;
36
+ expiresAt: string;
37
+ licenseId: string | null;
38
+ licenseKey: string;
39
+ ok: true;
40
+ planId: string;
41
+ pricingId: string;
42
+ } | {
43
+ error: string;
44
+ ok: false;
45
+ reason: FreemiusTrialProvisionRejection | 'not_configured' | 'upstream_error';
46
+ status: number;
47
+ };
48
+ export declare const FREEMIUS_TRIAL_ALREADY_USED_MESSAGE = "A NextBlock license or trial already exists for this email. Activate that key from CMS Settings \u2192 Packages, or purchase a license at nextblock.dev.";
49
+ export declare const FREEMIUS_TRIAL_PROVISION_FAILED_MESSAGE = "The trial could not be provisioned automatically. Start it from CMS Settings \u2192 Packages instead.";
50
+ export type FreemiusPricingLike = {
51
+ id?: string | number | null;
52
+ is_hidden?: boolean | null;
53
+ /** Site quota; null means unlimited. */
54
+ licenses?: number | null;
55
+ };
56
+ export type FreemiusOwnedLicenseLike = {
57
+ id?: string | number | null;
58
+ plugin_id?: string | number | null;
59
+ };
60
+ /** Freemius timestamps are "YYYY-MM-DD HH:mm:ss" in UTC, without a zone marker. */
61
+ export declare function formatFreemiusTimestamp(date: Date): string;
62
+ export declare function computeTrialExpiry(now: Date, trialDays: number): Date;
63
+ /**
64
+ * The plan's cheapest tier is the one to trial: a visible pricing with the smallest site
65
+ * quota (a single-site license), falling back to whatever is listed first.
66
+ */
67
+ export declare function pickTrialPricing(pricing: readonly FreemiusPricingLike[]): FreemiusPricingLike | null;
68
+ /** Pure decision: does this email already hold any license for the product? */
69
+ export declare function evaluateTrialEligibility(input: {
70
+ existingLicenses: readonly FreemiusOwnedLicenseLike[];
71
+ productId: string;
72
+ }): {
73
+ ok: true;
74
+ } | {
75
+ ok: false;
76
+ reason: 'already_licensed';
77
+ };
78
+ /**
79
+ * Mint and assign a trial license. The Freemius product-scope bearer credentials come
80
+ * from the same resolver as the license claim route, so a vendor that already answers
81
+ * claims needs no extra configuration.
82
+ */
83
+ export declare function provisionFreemiusTrialLicense(request: FreemiusTrialProvisionRequest, options?: {
84
+ now?: Date;
85
+ }): Promise<FreemiusTrialProvisionResult>;
@@ -0,0 +1,136 @@
1
+ import { Freemius as I } from "@freemius/sdk";
2
+ import { hydrateFreemiusEnvFromDb as h } from "./payment-config.es.js";
3
+ import { resolveFreemiusCheckoutCredentials as k } from "./providers/freemius.es.js";
4
+ const S = "A NextBlock license or trial already exists for this email. Activate that key from CMS Settings → Packages, or purchase a license at nextblock.dev.", g = "The trial could not be provisioned automatically. Start it from CMS Settings → Packages instead.";
5
+ function E(e) {
6
+ return e.toISOString().slice(0, 19).replace("T", " ");
7
+ }
8
+ function v(e, n) {
9
+ const i = Number.isFinite(n) && n > 0 ? Math.floor(n) : 30;
10
+ return new Date(e.getTime() + i * 24 * 60 * 60 * 1e3);
11
+ }
12
+ function w(e) {
13
+ const n = e.filter((t) => t.id !== null && t.id !== void 0);
14
+ if (n.length === 0)
15
+ return null;
16
+ const i = n.filter((t) => !t.is_hidden);
17
+ return [...i.length > 0 ? i : n].sort((t, s) => {
18
+ const l = t.licenses === null || t.licenses === void 0 ? Number.POSITIVE_INFINITY : t.licenses, u = s.licenses === null || s.licenses === void 0 ? Number.POSITIVE_INFINITY : s.licenses;
19
+ return l - u;
20
+ })[0];
21
+ }
22
+ function F(e) {
23
+ return e.existingLicenses.some(
24
+ (i) => i.plugin_id === null || i.plugin_id === void 0 || String(i.plugin_id).trim() === String(e.productId).trim()
25
+ ) ? { ok: !1, reason: "already_licensed" } : { ok: !0 };
26
+ }
27
+ function b(e) {
28
+ return e.trim().toLowerCase();
29
+ }
30
+ async function x(e, n) {
31
+ await h();
32
+ const i = k(e.productId);
33
+ if (!i.apiKey || !i.secretKey || !i.publicKey)
34
+ return {
35
+ error: "The license service is not configured for this product.",
36
+ ok: !1,
37
+ reason: "not_configured",
38
+ status: 503
39
+ };
40
+ const c = new I({
41
+ apiKey: i.apiKey,
42
+ productId: Number(e.productId),
43
+ publicKey: i.publicKey,
44
+ secretKey: i.secretKey
45
+ }), t = b(e.email), s = c.api.__unstable_ApiClient, l = { product_id: e.productId };
46
+ let u = [];
47
+ try {
48
+ const r = await c.api.user.retrieveByEmail(t);
49
+ r?.id !== null && r?.id !== void 0 && (u = await c.api.user.retrieveLicenses(r.id));
50
+ } catch (r) {
51
+ return console.error("[Freemius trial] user lookup failed:", r), {
52
+ error: "Freemius could not be reached to verify eligibility.",
53
+ ok: !1,
54
+ reason: "upstream_error",
55
+ status: 502
56
+ };
57
+ }
58
+ if (!F({ existingLicenses: u, productId: e.productId }).ok)
59
+ return { error: S, ok: !1, reason: "already_licensed", status: 409 };
60
+ let d = null;
61
+ try {
62
+ const { data: r, error: a } = await s.GET("/products/{product_id}/plans/{plan_id}/pricing.json", {
63
+ params: { path: { ...l, plan_id: e.planId } }
64
+ });
65
+ if (a)
66
+ throw new Error(JSON.stringify(a));
67
+ const o = w(r?.pricing ?? []);
68
+ d = o?.id !== null && o?.id !== void 0 ? String(o.id) : null;
69
+ } catch (r) {
70
+ return console.error("[Freemius trial] pricing lookup failed:", r), {
71
+ error: "Freemius could not be reached to resolve the plan pricing.",
72
+ ok: !1,
73
+ reason: "upstream_error",
74
+ status: 502
75
+ };
76
+ }
77
+ if (!d)
78
+ return {
79
+ error: g,
80
+ ok: !1,
81
+ reason: "no_pricing",
82
+ status: 502
83
+ };
84
+ const y = n?.now ?? /* @__PURE__ */ new Date(), m = E(v(y, e.trialDays));
85
+ let p = null, f = null;
86
+ try {
87
+ const { data: r, error: a } = await s.POST(
88
+ "/products/{product_id}/plans/{plan_id}/pricing/{pricing_id}/licenses.json",
89
+ {
90
+ body: { expires_at: m, is_block_features: !0, send_email: !1 },
91
+ params: { path: { ...l, plan_id: e.planId, pricing_id: d } }
92
+ }
93
+ );
94
+ if (a)
95
+ throw new Error(JSON.stringify(a));
96
+ const o = r?.license;
97
+ p = o?.secret_key?.trim() || null, f = o?.id !== null && o?.id !== void 0 ? String(o.id) : null;
98
+ } catch (r) {
99
+ return console.error("[Freemius trial] license creation failed:", r), {
100
+ error: "Freemius could not create the trial license.",
101
+ ok: !1,
102
+ reason: "upstream_error",
103
+ status: 502
104
+ };
105
+ }
106
+ if (!p)
107
+ return { error: g, ok: !1, reason: "no_key", status: 502 };
108
+ let _ = !1;
109
+ try {
110
+ const { error: r } = await s.PUT("/products/{product_id}/licenses.json", {
111
+ body: { email: t, license_key: p, name: e.name.trim() },
112
+ params: { path: l }
113
+ });
114
+ _ = !r, r && console.warn("[Freemius trial] license assignment refused:", JSON.stringify(r));
115
+ } catch (r) {
116
+ console.warn("[Freemius trial] license assignment failed:", r);
117
+ }
118
+ return {
119
+ assigned: _,
120
+ expiresAt: m,
121
+ licenseId: f,
122
+ licenseKey: p,
123
+ ok: !0,
124
+ planId: e.planId,
125
+ pricingId: d
126
+ };
127
+ }
128
+ export {
129
+ S as FREEMIUS_TRIAL_ALREADY_USED_MESSAGE,
130
+ g as FREEMIUS_TRIAL_PROVISION_FAILED_MESSAGE,
131
+ v as computeTrialExpiry,
132
+ F as evaluateTrialEligibility,
133
+ E as formatFreemiusTimestamp,
134
+ w as pickTrialPricing,
135
+ x as provisionFreemiusTrialLicense
136
+ };