@burdenoff/microfe-billing 2026.821.1 → 2026.825.2

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 (145) hide show
  1. package/dist/billing/BillingAdminRoutes.js.map +1 -1
  2. package/dist/billing/BillingRoot.js.map +1 -1
  3. package/dist/billing/BillingUserRoutes.js.map +1 -1
  4. package/dist/billing/hooks/useBillingAccountSelection.js.map +1 -1
  5. package/dist/billing/hooks/useBillingEventEmitter.js.map +1 -1
  6. package/dist/billing/hooks/useBillingNavigate.js.map +1 -1
  7. package/dist/billing/hooks/useBillingPermissions.js.map +1 -1
  8. package/dist/billing/hooks/useDefaultBillingCurrency.js.map +1 -1
  9. package/dist/billing/modules/addons/components/FloatingCartDrawer.js.map +1 -1
  10. package/dist/billing/modules/addons/hooks/useAddons.js.map +1 -1
  11. package/dist/billing/modules/addons/pages/AddonBrowseDetailPage.js.map +1 -1
  12. package/dist/billing/modules/addons/pages/AddonCreatePage.js.map +1 -1
  13. package/dist/billing/modules/addons/pages/AddonDetailPage.js.map +1 -1
  14. package/dist/billing/modules/addons/pages/AddonEditPage.js.map +1 -1
  15. package/dist/billing/modules/addons/pages/AddonsBrowsePage.js.map +1 -1
  16. package/dist/billing/modules/addons/pages/AddonsListPage.js.map +1 -1
  17. package/dist/billing/modules/addons/store/addonCartStore.js.map +1 -1
  18. package/dist/billing/modules/affiliate/api.js.map +1 -1
  19. package/dist/billing/modules/affiliate/pages/AffiliateDashboardPage.js +107 -107
  20. package/dist/billing/modules/affiliate/pages/AffiliateDashboardPage.js.map +1 -1
  21. package/dist/billing/modules/analytics/pages/AnalyticsPage.js +80 -81
  22. package/dist/billing/modules/analytics/pages/AnalyticsPage.js.map +1 -1
  23. package/dist/billing/modules/billing/hooks/useInvoices.js.map +1 -1
  24. package/dist/billing/modules/billing/hooks/useRefunds.js.map +1 -1
  25. package/dist/billing/modules/billing/hooks/useTransactions.js.map +1 -1
  26. package/dist/billing/modules/billing/pages/InvoiceDetailPage.js.map +1 -1
  27. package/dist/billing/modules/billing/pages/InvoicesListPage.js +1 -1
  28. package/dist/billing/modules/billing/pages/InvoicesListPage.js.map +1 -1
  29. package/dist/billing/modules/billing/pages/PaymentMethodsPage.js.map +1 -1
  30. package/dist/billing/modules/billing/pages/RefundsPage.js.map +1 -1
  31. package/dist/billing/modules/billing/pages/TransactionsPage.js.map +1 -1
  32. package/dist/billing/modules/billing/pages/UserRefundsPage.js +127 -127
  33. package/dist/billing/modules/billing/pages/UserRefundsPage.js.map +1 -1
  34. package/dist/billing/modules/checkout/components/BillingAccountSelector.js.map +1 -1
  35. package/dist/billing/modules/checkout/components/CompleteBillingAccountModal.js.map +1 -1
  36. package/dist/billing/modules/checkout/components/CreditsAmountInput.js.map +1 -1
  37. package/dist/billing/modules/checkout/components/NativeCheckoutView.js.map +1 -1
  38. package/dist/billing/modules/checkout/components/OrderSummary.js.map +1 -1
  39. package/dist/billing/modules/checkout/components/PromoCodeInput.js.map +1 -1
  40. package/dist/billing/modules/checkout/components/RazorpayPaymentButton.js.map +1 -1
  41. package/dist/billing/modules/checkout/components/SimpleAutoPayToggle.js.map +1 -1
  42. package/dist/billing/modules/checkout/components/StoreShippingSection.js.map +1 -1
  43. package/dist/billing/modules/checkout/components/StripePaymentForm.js.map +1 -1
  44. package/dist/billing/modules/checkout/components/SubscriptionSelector.js.map +1 -1
  45. package/dist/billing/modules/checkout/components/UnifiedPaymentMethodSelector.js.map +1 -1
  46. package/dist/billing/modules/checkout/components/WorkspaceQuotaAssignmentModal.js.map +1 -1
  47. package/dist/billing/modules/checkout/hooks/useCheckout.js +0 -1
  48. package/dist/billing/modules/checkout/hooks/useCheckout.js.map +1 -1
  49. package/dist/billing/modules/checkout/hooks/useNativeCheckout.js.map +1 -1
  50. package/dist/billing/modules/checkout/hooks/usePaymentProviders.js.map +1 -1
  51. package/dist/billing/modules/checkout/hooks/usePaymentStatusPolling.js.map +1 -1
  52. package/dist/billing/modules/checkout/hooks/useStoreShipping.js.map +1 -1
  53. package/dist/billing/modules/checkout/pages/CheckoutPage.js +412 -395
  54. package/dist/billing/modules/checkout/pages/CheckoutPage.js.map +1 -1
  55. package/dist/billing/modules/checkout/utils/storeOrder.js.map +1 -1
  56. package/dist/billing/modules/coupons/pages/CouponDetailPage.js.map +1 -1
  57. package/dist/billing/modules/coupons/pages/CouponsListPage.js.map +1 -1
  58. package/dist/billing/modules/coupons/pages/CreateCouponPage.js.map +1 -1
  59. package/dist/billing/modules/coupons/pages/EditCouponPage.js.map +1 -1
  60. package/dist/billing/modules/credits/hooks/useCredits.js.map +1 -1
  61. package/dist/billing/modules/credits/pages/AdminCreditsPage.js.map +1 -1
  62. package/dist/billing/modules/credits/pages/CreditTransactionsPage.js.map +1 -1
  63. package/dist/billing/modules/credits/pages/CreditWithdrawalPage.js.map +1 -1
  64. package/dist/billing/modules/credits/pages/CreditsPage.js.map +1 -1
  65. package/dist/billing/modules/dashboard/components/ActiveSubscriptionCard.js.map +1 -1
  66. package/dist/billing/modules/dashboard/components/AddPaymentMethodModal.js.map +1 -1
  67. package/dist/billing/modules/dashboard/components/BillingAccountCard.js.map +1 -1
  68. package/dist/billing/modules/dashboard/components/CreateBillingAccountModal.js.map +1 -1
  69. package/dist/billing/modules/dashboard/components/PaymentMethodsSection.js.map +1 -1
  70. package/dist/billing/modules/dashboard/components/RecommendedAddonsSection.js.map +1 -1
  71. package/dist/billing/modules/dashboard/hooks/useBillingOverviewData.js.map +1 -1
  72. package/dist/billing/modules/dashboard/hooks/useDashboard.js.map +1 -1
  73. package/dist/billing/modules/dashboard/pages/OverviewPage.js.map +1 -1
  74. package/dist/billing/modules/discounts/pages/DiscountsListPage.js.map +1 -1
  75. package/dist/billing/modules/earnings/api.js.map +1 -1
  76. package/dist/billing/modules/earnings/pages/DeveloperRevenueAdminPage.js +145 -145
  77. package/dist/billing/modules/earnings/pages/DeveloperRevenueAdminPage.js.map +1 -1
  78. package/dist/billing/modules/earnings/pages/EarningsPage.js +133 -133
  79. package/dist/billing/modules/earnings/pages/EarningsPage.js.map +1 -1
  80. package/dist/billing/modules/earnings/pages/PayoutAdminPage.js +7 -9
  81. package/dist/billing/modules/earnings/pages/PayoutAdminPage.js.map +1 -1
  82. package/dist/billing/modules/earnings/pages/PayoutsPage.js +95 -95
  83. package/dist/billing/modules/earnings/pages/PayoutsPage.js.map +1 -1
  84. package/dist/billing/modules/plans/constants/featuredQuotas.js.map +1 -1
  85. package/dist/billing/modules/plans/hooks/usePlans.js.map +1 -1
  86. package/dist/billing/modules/plans/hooks/useQuotas.js.map +1 -1
  87. package/dist/billing/modules/plans/pages/PlanAssignFreePage.js.map +1 -1
  88. package/dist/billing/modules/plans/pages/PlanBrowseDetailPage.js.map +1 -1
  89. package/dist/billing/modules/plans/pages/PlanCreatePage.js.map +1 -1
  90. package/dist/billing/modules/plans/pages/PlanDetailPage.js.map +1 -1
  91. package/dist/billing/modules/plans/pages/PlanEditPage.js.map +1 -1
  92. package/dist/billing/modules/plans/pages/PlansBrowsePage.js.map +1 -1
  93. package/dist/billing/modules/plans/pages/PlansListPage.js.map +1 -1
  94. package/dist/billing/modules/promotions/pages/CreatePromotionPage.js.map +1 -1
  95. package/dist/billing/modules/promotions/pages/PromotionsListPage.js.map +1 -1
  96. package/dist/billing/modules/quota/hooks/useQuotaTemplates.js.map +1 -1
  97. package/dist/billing/modules/quota/pages/QuotaAssignFreePage.js.map +1 -1
  98. package/dist/billing/modules/quota/pages/QuotaTemplateCreatePage.js.map +1 -1
  99. package/dist/billing/modules/quota/pages/QuotaTemplateDetailPage.js.map +1 -1
  100. package/dist/billing/modules/quota/pages/QuotaTemplateEditPage.js.map +1 -1
  101. package/dist/billing/modules/quota/pages/QuotaTemplatesListPage.js.map +1 -1
  102. package/dist/billing/modules/settings/pages/SettingsPage.js.map +1 -1
  103. package/dist/billing/modules/settings/pages/TeamPermissionsPage.js.map +1 -1
  104. package/dist/billing/modules/store/pages/StoreCheckoutPage.js +5 -6
  105. package/dist/billing/modules/store/pages/StoreCheckoutPage.js.map +1 -1
  106. package/dist/billing/modules/subscriptions/components/ManageSeatsModal.js.map +1 -1
  107. package/dist/billing/modules/subscriptions/hooks/useSubscriptions.js.map +1 -1
  108. package/dist/billing/modules/subscriptions/pages/SubscriptionDetailPage.js.map +1 -1
  109. package/dist/billing/modules/subscriptions/pages/SubscriptionsListPage.js.map +1 -1
  110. package/dist/billing/modules/subscriptions/pages/UpgradeSubscriptionPage.js.map +1 -1
  111. package/dist/billing/modules/usage/hooks/useUsage.js +14 -9
  112. package/dist/billing/modules/usage/hooks/useUsage.js.map +1 -1
  113. package/dist/billing/modules/usage/pages/UsagePage.js +481 -453
  114. package/dist/billing/modules/usage/pages/UsagePage.js.map +1 -1
  115. package/dist/billing/providers/BillingProvider.js.map +1 -1
  116. package/dist/billing/shared/components/AccessDenied.js.map +1 -1
  117. package/dist/billing/shared/components/ActorIdentity.js.map +1 -1
  118. package/dist/billing/shared/components/CurrencyPriceOverridesEditor.js.map +1 -1
  119. package/dist/billing/shared/components/EmptyState.js.map +1 -1
  120. package/dist/billing/shared/components/PageHeader.js.map +1 -1
  121. package/dist/billing/shared/components/ServerError.js.map +1 -1
  122. package/dist/billing/shared/components/StatCard.js.map +1 -1
  123. package/dist/billing/shared/hooks/useActorProfiles.js.map +1 -1
  124. package/dist/billing/shared/types/graphql.js.map +1 -1
  125. package/dist/billing/shared/ui/Card.js.map +1 -1
  126. package/dist/billing/shared/ui/MetricCard.js.map +1 -1
  127. package/dist/billing/shared/ui/ProgressBar.js.map +1 -1
  128. package/dist/billing/shared/ui/StatusPill.js.map +1 -1
  129. package/dist/billing/shared/utils/directBillingGraphql.js.map +1 -1
  130. package/dist/billing/shared/utils/error.js.map +1 -1
  131. package/dist/billing/shared/utils/format.js.map +1 -1
  132. package/dist/billing/shared/utils/gatewayGraphql.js.map +1 -1
  133. package/dist/billing/shared/utils/navigation.js.map +1 -1
  134. package/dist/billing/shared/utils/paymentTheme.js.map +1 -1
  135. package/dist/billing/shared/utils/planFeatureQuantity.js.map +1 -1
  136. package/dist/billing/shared/utils/status.js.map +1 -1
  137. package/dist/billing/shared/utils/tokens.js.map +1 -1
  138. package/dist/generated/global-operations.js +5 -1
  139. package/dist/generated/global-operations.js.map +1 -1
  140. package/dist/generated/global-types.js.map +1 -1
  141. package/dist/generated/wspace-operations.js +1 -1
  142. package/dist/generated/wspace-operations.js.map +1 -1
  143. package/dist/node_modules/@capacitor/core/dist/index.js +1 -1
  144. package/dist/node_modules/@capacitor/core/dist/index.js.map +1 -1
  145. package/package.json +13 -10
@@ -40,16 +40,28 @@ import { useI18n as Ye } from "@burdenoff/fe-libs/shared/providers/shell/I18nPro
40
40
  import { getProfileScopedKey as Xe } from "@burdenoff/fe-libs/shared/utils";
41
41
  import { PagePurpose as Ze } from "@burdenoff/fe-libs/ui";
42
42
  //#region src/billing/modules/checkout/pages/CheckoutPage.tsx
43
- var Qe = () => {
44
- let { t: Qe } = Ye(), h = (e, t) => {
45
- let n = Qe(e);
43
+ function Qe(e) {
44
+ return typeof e.id != "string" || typeof e.name != "string" || typeof e.email != "string" || typeof e.currency != "string" || typeof e.creditAmount != "number" || typeof e.isActive != "boolean" ? null : {
45
+ ...e,
46
+ id: e.id,
47
+ name: e.name,
48
+ email: e.email,
49
+ currency: e.currency,
50
+ creditAmount: e.creditAmount,
51
+ isActive: e.isActive,
52
+ billingAddresses: e.billingAddresses === null ? null : e.billingAddresses?.flatMap((e) => e ? [{ ...e }] : [])
53
+ };
54
+ }
55
+ var $e = () => {
56
+ let { t: $e } = Ye(), h = (e, t) => {
57
+ let n = $e(e);
46
58
  return n === e ? t : n;
47
- }, { planId: $e, addonId: et, storeOrderId: g } = qe(), _ = se(), tt = Ke(), v = tt.state, nt = a(), { emit: y } = r(), { orgId: b, stripePublishableKey: rt, razorpayKey: it, apiGatewayUrl: at, authToken: ot, currentUser: st, workspaceId: x } = e(), { productSlug: ct } = Je(), lt = Ne(null), ut = x ? [{
59
+ }, { planId: et, addonId: tt, storeOrderId: g } = qe(), _ = se(), nt = Ke(), v = nt.state, rt = a(), { emit: y } = r(), { orgId: b, stripePublishableKey: it, razorpayKey: at, apiGatewayUrl: ot, authToken: st, currentUser: ct, workspaceId: x } = e(), { productSlug: lt } = Je(), ut = Ne(null), dt = x ? [{
48
60
  id: x,
49
61
  name: "Current workspace"
50
- }] : [], { items: S, clearCart: dt, _hasHydrated: C } = oe(), w = tt.pathname.includes("/checkout/addons") && !et, T = tt.pathname.includes("/checkout/store") && !!g, E = w ? "ADDON" : T ? "ORDER" : v?.purchaseType ?? ($e ? "PLAN" : et ? "ADDON" : "CREDITS"), D = v?.itemId ?? $e ?? et ?? g, [ft, O] = u(!1), k = Ne(!1), [pt, A] = u(!1), [mt, ht] = u([]), [gt, _t] = u(null), [j, M] = u("select"), [N, vt] = u(null), [yt, P] = u(null), [F, bt] = u(null), [xt, St] = u("card");
62
+ }] : [], { items: S, clearCart: ft, _hasHydrated: C } = oe(), w = nt.pathname.includes("/checkout/addons") && !tt, T = nt.pathname.includes("/checkout/store") && !!g, E = w ? "ADDON" : T ? "ORDER" : v?.purchaseType ?? (et ? "PLAN" : tt ? "ADDON" : "CREDITS"), D = v?.itemId ?? et ?? tt ?? g, [pt, mt] = u(!1), ht = Ne(!1), [gt, _t] = u(!1), [vt, yt] = u([]), [bt, xt] = u(null), [O, k] = u("select"), [A, St] = u(null), [Ct, j] = u(null), [M, wt] = u(null), [Tt, Et] = u("card");
51
63
  c(() => {
52
- if (j !== "success" || !F) return;
64
+ if (O !== "success" || !M) return;
53
65
  let e = typeof window < "u" ? window.localStorage.getItem(Xe("boff-referral-attribution")) : null;
54
66
  if (!e) return;
55
67
  let t;
@@ -59,192 +71,197 @@ var Qe = () => {
59
71
  return;
60
72
  }
61
73
  if (!t.journeyId && !t.codeId) return;
62
- let n = F.transactionId || N?.paymentId || N?.orderId || g || D || E, r = `${t.journeyId ?? "journey"}:${n}`;
63
- lt.current !== r && (lt.current = r, ce({
74
+ let n = M.transactionId || A?.paymentId || A?.orderId || g || D || E, r = `${t.journeyId ?? "journey"}:${n}`;
75
+ ut.current !== r && (ut.current = r, ce({
64
76
  journeyId: t.journeyId,
65
77
  codeId: t.codeId,
66
78
  eventType: E === "ORDER" ? "STORE_PURCHASE" : "PAID_CONVERSION",
67
- productSlug: ct,
68
- actorUserId: st?.id,
69
- orderId: F.transactionId || N?.paymentId || N?.orderId,
70
- billingAccountId: F.billingAccountId,
79
+ productSlug: lt,
80
+ actorUserId: ct?.id,
81
+ orderId: M.transactionId || A?.paymentId || A?.orderId,
82
+ billingAccountId: M.billingAccountId,
71
83
  storeOrderId: E === "ORDER" ? g : void 0,
72
- valueAmount: F.total,
73
- currency: F.currency,
84
+ valueAmount: M.total,
85
+ currency: M.currency,
74
86
  mode: "billing-checkout",
75
87
  metadata: {
76
88
  purchaseType: E,
77
- billingAccountName: F.billingAccountName
89
+ billingAccountName: M.billingAccountName
78
90
  }
79
91
  }, {
80
- apiGatewayUrl: at,
81
- authToken: ot,
92
+ apiGatewayUrl: ot,
93
+ authToken: st,
82
94
  orgId: b
83
95
  }).catch(() => {
84
- lt.current = null;
96
+ ut.current = null;
85
97
  }));
86
98
  }, [
87
- at,
88
99
  ot,
89
- st?.id,
100
+ st,
101
+ ct?.id,
90
102
  D,
91
- j,
103
+ O,
92
104
  b,
93
- N?.orderId,
94
- N?.paymentId,
95
- ct,
96
- F,
105
+ A?.orderId,
106
+ A?.paymentId,
107
+ lt,
108
+ M,
97
109
  E,
98
110
  g
99
111
  ]);
100
- let [I, L] = u(1), R = le({
112
+ let [N, P] = u(1), F = le({
101
113
  defaultCurrency: "USD",
102
114
  upgradeFromSubscriptionId: v?.upgradeFromSubscriptionId,
103
115
  downgradeFromSubscriptionId: v?.downgradeFromSubscriptionId
104
- }), { config: Ct, stripeEnabled: wt, razorpayEnabled: Tt } = fe(), { elapsedTime: Et, error: Dt } = pe({
105
- paymentId: j === "processing" ? N?.paymentId ?? null : null,
106
- billingAccountId: R.billingAccount?.id ?? F?.billingAccountId ?? null,
107
- paymentType: xt,
116
+ }), { config: Dt, stripeEnabled: Ot, razorpayEnabled: kt } = fe(), { elapsedTime: At, error: jt } = pe({
117
+ paymentId: O === "processing" ? A?.paymentId ?? null : null,
118
+ billingAccountId: F.billingAccount?.id ?? M?.billingAccountId ?? null,
119
+ paymentType: Tt,
108
120
  pollingInterval: 5e3,
109
121
  maxPollingTime: 3e5,
110
122
  onSuccess: (e) => {
111
- if (e.transactionId && bt((t) => t && {
123
+ if (e.transactionId && wt((t) => t && {
112
124
  ...t,
113
125
  transactionId: e.transactionId
114
- }), M("success"), w && dt(), (E === "PLAN" || E === "ADDON") && x) {
115
- let e = (z?.getPlan?.features ?? []).filter((e) => e != null).filter((e) => e.quota?.name && Ae(e.quota.name)).map((e) => {
126
+ }), k("success"), w && ft(), (E === "PLAN" || E === "ADDON") && x) {
127
+ let e = (I?.getPlan?.features ?? []).filter((e) => e != null).filter((e) => e.quota?.name && Ae(e.quota.name)).map((e) => {
116
128
  let t = e.quota?.limits, n = t && "value" in t ? Number(t.value) : null, r = t && "type" in t ? String(t.type) : "number";
117
129
  return {
118
130
  quotaName: e.quota.name,
119
- productId: z?.getPlan?.context?.productId ?? "platform",
131
+ productId: I?.getPlan?.context?.productId ?? "platform",
120
132
  limit: r === "number" ? n : null,
121
133
  noLimit: r !== "number",
122
134
  resetPeriod: "NEVER",
123
135
  quotaMode: "dedicated"
124
136
  };
125
137
  });
126
- e.length > 0 && (ht(e), Vt().then((e) => {
138
+ e.length > 0 && (yt(e), Gt().then((e) => {
127
139
  let t = e.data?.getActiveSubscriptions?.find((e) => e.planId === D);
128
- t && _t(t.id);
129
- }), (ut.length === 1 || ut.length > 1) && A(!0));
140
+ t && xt(t.id);
141
+ }), (dt.length === 1 || dt.length > 1) && _t(!0));
130
142
  }
131
143
  },
132
144
  onFailure: (e) => {
133
- P(e.failureReason || "Payment failed"), M("error");
145
+ j(e.failureReason || "Payment failed"), k("error");
134
146
  },
135
147
  onTimeout: () => {
136
- P("Payment verification timed out. Please check your billing history for the payment status."), M("error");
148
+ j("Payment verification timed out. Please check your billing history for the payment status."), k("error");
137
149
  }
138
- }), { data: Ot, loading: kt, refetch: At } = ee({}), { data: z, loading: jt } = re({
150
+ }), { data: Mt, loading: Nt, refetch: Pt } = ee({}), { data: I, loading: Ft } = re({
139
151
  variables: { id: D },
140
152
  skip: E !== "PLAN" || !D
141
- }), { data: B, loading: Mt } = ie({
153
+ }), { data: L, loading: It } = ie({
142
154
  variables: { addonIDs: D ? [D] : [] },
143
155
  skip: E !== "ADDON" || !D || T
144
- }), { data: V } = ae({
156
+ }), { data: R } = ae({
145
157
  variables: { id: g },
146
158
  skip: !T || !g
147
- }), Nt = l(() => {
148
- let e = V?.getStoreOrder?.lineItems;
159
+ }), Lt = l(() => {
160
+ let e = R?.getStoreOrder?.lineItems;
149
161
  return Array.isArray(e) ? e : [];
150
- }, [V]), H = T && Nt.some((e) => String(e.itemType).toUpperCase() === "PHYSICAL"), Pt = Me(V?.getStoreOrder?.currency), [U, Ft] = u({
162
+ }, [R]), z = T && Lt.some((e) => String(e.itemType).toUpperCase() === "PHYSICAL"), Rt = Me(R?.getStoreOrder?.currency), [B, zt] = u({
151
163
  shippingAddressId: null,
152
164
  shippingMethodId: null,
153
165
  shippingCost: 0,
154
166
  destinationCountry: null
155
- }), [It] = De(), { data: Lt, loading: Rt } = ne({
156
- variables: { billingAccountId: R.billingAccount?.id },
157
- skip: !R.billingAccount?.id
158
- }), { data: zt, loading: Bt, refetch: Vt } = o({
159
- variables: { billingAccountId: R.billingAccount?.id },
160
- skip: !R.billingAccount?.id || E !== "ADDON" && E !== "PLAN" || T
161
- }), W = l(() => zt?.getActiveSubscriptions ?? [], [zt]), G = l(() => !R.selectedSubscriptionId || W.length === 0 ? null : W.find((e) => e.id === R.selectedSubscriptionId) ?? null, [R.selectedSubscriptionId, W]), K = R.items[0]?.type === "CREDITS" ? R.items[0].quantity : 100, { data: Ht, loading: Ut } = te({
167
+ }), [Bt] = De(), { data: Vt, loading: Ht } = ne({
168
+ variables: { billingAccountId: F.billingAccount?.id },
169
+ skip: !F.billingAccount?.id
170
+ }), { data: Ut, loading: Wt, refetch: Gt } = o({
171
+ variables: { billingAccountId: F.billingAccount?.id },
172
+ skip: !F.billingAccount?.id || E !== "ADDON" && E !== "PLAN" || T
173
+ }), V = l(() => Ut?.getActiveSubscriptions ?? [], [Ut]), H = l(() => !F.selectedSubscriptionId || V.length === 0 ? null : V.find((e) => e.id === F.selectedSubscriptionId) ?? null, [F.selectedSubscriptionId, V]), U = F.items[0]?.type === "CREDITS" ? F.items[0].quantity : 100, { data: Kt, loading: qt } = te({
162
174
  variables: {
163
- creditAmount: K,
164
- currency: R.selectedCurrency || "USD"
175
+ creditAmount: U,
176
+ currency: F.selectedCurrency || "USD"
165
177
  },
166
178
  skip: E !== "CREDITS"
167
- }), q = l(() => Ht?.getCostOfCredits?.amount && K > 0 ? Ht.getCostOfCredits.amount / K : .01, [Ht, K]), J = l(() => Lt?.getPaymentMethods ?? [], [Lt]), Y = l(() => Ot?.myBillingAccounts ?? [], [Ot]), X = l(() => {
168
- if (!R.billingAccount) return;
169
- let e = Y.find((e) => e.id === R.billingAccount?.id)?.billingAddresses;
179
+ }), W = l(() => Kt?.getCostOfCredits?.amount && U > 0 ? Kt.getCostOfCredits.amount / U : .01, [Kt, U]), G = l(() => Vt?.getPaymentMethods ?? [], [Vt]), K = l(() => Mt?.myBillingAccounts ?? [], [Mt]), q = l(() => {
180
+ if (!F.billingAccount) return;
181
+ let e = K.find((e) => e.id === F.billingAccount?.id)?.billingAddresses;
170
182
  if (e && e.length > 0) return e[0]?.country || void 0;
171
- }, [R.billingAccount, Y]), [Wt, Gt] = u(null);
183
+ }, [F.billingAccount, K]), [Jt, Yt] = u(null);
172
184
  c(() => {
173
- if (X) if (X === "IN") R.selectedCurrency !== "INR" && R.setCurrency("INR"), Tt && Wt !== X && R.selectedProvider !== "CREDITS" && (R.setPaymentProvider("RAZORPAY"), Gt(X));
185
+ if (q) if (q === "IN") F.selectedCurrency !== "INR" && F.setCurrency("INR"), kt && Jt !== q && F.selectedProvider !== "CREDITS" && (F.setPaymentProvider("RAZORPAY"), Yt(q));
174
186
  else {
175
- if (R.selectedCurrency === "INR") {
176
- let e = R.billingAccount?.currency, t = e && e !== "INR" ? e : "USD";
177
- R.setCurrency(t);
187
+ if (F.selectedCurrency === "INR") {
188
+ let e = F.billingAccount?.currency, t = e && e !== "INR" ? e : "USD";
189
+ F.setCurrency(t);
178
190
  }
179
- R.selectedProvider === "RAZORPAY" && (R.setPaymentProvider("STRIPE"), Gt(X));
191
+ F.selectedProvider === "RAZORPAY" && (F.setPaymentProvider("STRIPE"), Yt(q));
180
192
  }
181
193
  }, [
182
- X,
183
- R.selectedCurrency,
184
- R.selectedProvider,
185
- R.setCurrency,
186
- R.setPaymentProvider,
187
- R.billingAccount?.currency,
188
- Tt,
189
- Wt
190
- ]), c(() => {
191
- if (!R.billingAccount?.currency || X === "IN") return;
192
- let e = R.billingAccount.currency;
193
- e !== "INR" && R.selectedCurrency !== e && R.setCurrency(e);
194
+ q,
195
+ F.selectedCurrency,
196
+ F.selectedProvider,
197
+ F.setCurrency,
198
+ F.setPaymentProvider,
199
+ F.billingAccount?.currency,
200
+ kt,
201
+ Jt
202
+ ]);
203
+ let { availableCredits: Xt, billingAccount: Zt, canPayWithCredits: Qt, selectedCurrency: J, selectedPaymentMethodId: $t, selectedProvider: en, setCurrency: Y, setPaymentProvider: X, setSelectedPaymentMethodId: tn, total: nn } = F;
204
+ c(() => {
205
+ if (!Zt?.currency || q === "IN") return;
206
+ let e = Zt.currency;
207
+ e !== "INR" && J !== e && Y(e);
194
208
  }, [
195
- R.billingAccount?.id,
196
- R.billingAccount?.currency,
197
- X,
198
- R.selectedCurrency,
199
- R.setCurrency
209
+ q,
210
+ Zt,
211
+ J,
212
+ Y
200
213
  ]), c(() => {
201
- if (R.selectedProvider !== "AUTO" && R.selectedProvider !== null) return;
202
- let e = R.availableCredits >= R.total;
203
- if (R.canPayWithCredits && e) {
204
- R.setPaymentProvider("CREDITS"), R.setSelectedPaymentMethodId(null);
205
- return;
206
- }
207
- if (J.length > 0 && !R.selectedPaymentMethodId) {
208
- let e = J.find((e) => e.isDefault && e.isVerified), t = J.find((e) => e.isVerified), n = e || t;
209
- if (n) {
210
- R.setSelectedPaymentMethodId(n.id), n.razorpayPaymentMethodId ? R.setPaymentProvider("RAZORPAY") : n.stripePaymentMethodId && R.setPaymentProvider("STRIPE");
214
+ if (!(en !== "AUTO" && en !== null)) {
215
+ if (Qt && Xt >= nn) {
216
+ X("CREDITS"), tn(null);
211
217
  return;
212
218
  }
219
+ if (G.length > 0 && !$t) {
220
+ let e = G.find((e) => e.isDefault && e.isVerified), t = G.find((e) => e.isVerified), n = e || t;
221
+ if (n) {
222
+ tn(n.id), n.razorpayPaymentMethodId ? X("RAZORPAY") : n.stripePaymentMethodId && X("STRIPE");
223
+ return;
224
+ }
225
+ }
213
226
  }
214
227
  }, [
215
- J.length,
216
- R.canPayWithCredits,
217
- R.availableCredits,
218
- R.total
228
+ Xt,
229
+ Qt,
230
+ nn,
231
+ G,
232
+ $t,
233
+ en,
234
+ X,
235
+ tn
219
236
  ]);
220
237
  let [Z, Q] = u(!1);
221
238
  c(() => {
222
- if (!T || Z || !V?.getStoreOrder) return;
223
- let e = Me(V.getStoreOrder.currency);
224
- R.selectedCurrency !== e && R.setCurrency(e);
239
+ if (!T || Z || !R?.getStoreOrder) return;
240
+ let e = Me(R.getStoreOrder.currency);
241
+ J !== e && Y(e);
225
242
  }, [
226
243
  T,
227
244
  Z,
228
- V,
229
- R.selectedCurrency,
230
- R.setCurrency
245
+ J,
246
+ Y,
247
+ R
231
248
  ]), c(() => {
232
- if (E === "PLAN" && z?.getPlan?.pricingModel === "PER_SEAT") {
233
- let e = z.getPlan.minSeats ?? 1;
234
- L((t) => t < e ? e : t);
249
+ if (E === "PLAN" && I?.getPlan?.pricingModel === "PER_SEAT") {
250
+ let e = I.getPlan.minSeats ?? 1;
251
+ P((t) => t < e ? e : t);
235
252
  }
236
- }, [z, E]), c(() => {
237
- E === "PLAN" && z?.getPlan?.pricingModel === "PER_SEAT" && Z && Q(!1);
238
- }, [I]), c(() => {
253
+ }, [I, E]), c(() => {
254
+ E === "PLAN" && I?.getPlan?.pricingModel === "PER_SEAT" && Z && Q(!1);
255
+ }, [N]), c(() => {
239
256
  if (!Z) {
240
257
  if (w && C && S.length > 0) {
241
- R.clearItems();
258
+ F.clearItems();
242
259
  for (let e of S) {
243
260
  let t = e.addon, n = t.features?.map((e) => ({
244
261
  id: e.quota?.id || e.id,
245
262
  name: e.quota?.name || "Feature",
246
263
  limits: e.quota?.limits
247
- })) || [], r = R.selectedCurrency || "USD", i = t.currencyPrices?.[r] ?? t.price, a = {
264
+ })) || [], r = F.selectedCurrency || "USD", i = t.currencyPrices?.[r] ?? t.price, a = {
248
265
  id: t.id,
249
266
  type: "ADDON",
250
267
  name: t.name,
@@ -256,25 +273,25 @@ var Qe = () => {
256
273
  features: n,
257
274
  metadata: { addonId: t.id }
258
275
  };
259
- R.addItem(a);
276
+ F.addItem(a);
260
277
  }
261
278
  Q(!0);
262
279
  return;
263
280
  }
264
- if (E === "PLAN" && z?.getPlan) {
265
- let e = z.getPlan, t = e.features?.map((e) => ({
281
+ if (E === "PLAN" && I?.getPlan) {
282
+ let e = I.getPlan, t = e.features?.map((e) => ({
266
283
  id: e.quota?.id || e.id,
267
284
  name: e.quota?.name || "Feature",
268
285
  limits: e.quota?.limits
269
- })) || [], n = R.selectedCurrency || "USD", r = e.currencyPrices, i = e.pricingModel === "PER_SEAT", a;
286
+ })) || [], n = F.selectedCurrency || "USD", r = e.currencyPrices, i = e.pricingModel === "PER_SEAT", a;
270
287
  if (i && e.pricePerSeat) {
271
288
  let t = r?.[n];
272
- a = (typeof t == "object" && t?.perSeat ? t.perSeat : e.pricePerSeat) * I;
289
+ a = (typeof t == "object" && t?.perSeat ? t.perSeat : e.pricePerSeat) * N;
273
290
  } else {
274
291
  let t = r?.[n];
275
292
  a = typeof t == "number" ? t : e.price;
276
293
  }
277
- let o = i ? I : 1, ee = {
294
+ let o = i ? N : 1, ee = {
278
295
  id: e.id,
279
296
  type: "PLAN",
280
297
  name: e.name,
@@ -290,13 +307,13 @@ var Qe = () => {
290
307
  seatCount: i ? o : void 0
291
308
  }
292
309
  };
293
- R.addItem(ee), Q(!0);
294
- } else if (E === "ADDON" && !w && B?.getSelectedAddons?.[0]) {
295
- let e = B.getSelectedAddons[0], t = e.features?.map((e) => ({
310
+ F.addItem(ee), Q(!0);
311
+ } else if (E === "ADDON" && !w && L?.getSelectedAddons?.[0]) {
312
+ let e = L.getSelectedAddons[0], t = e.features?.map((e) => ({
296
313
  id: e.quota?.id || e.id,
297
314
  name: e.quota?.name || "Feature",
298
315
  limits: e.quota?.limits
299
- })) || [], n = R.selectedCurrency || "USD", r = e.currencyPrices?.[n] ?? e.price, i = {
316
+ })) || [], n = F.selectedCurrency || "USD", r = e.currencyPrices?.[n] ?? e.price, i = {
300
317
  id: e.id,
301
318
  type: "ADDON",
302
319
  name: e.name,
@@ -308,10 +325,10 @@ var Qe = () => {
308
325
  features: t,
309
326
  metadata: { addonId: e.id }
310
327
  };
311
- R.addItem(i), Q(!0);
312
- } else if (T && V?.getStoreOrder) {
313
- let e = V.getStoreOrder, t = je(e);
314
- for (let e of t) R.addItem(e);
328
+ F.addItem(i), Q(!0);
329
+ } else if (T && R?.getStoreOrder) {
330
+ let e = R.getStoreOrder, t = je(e);
331
+ for (let e of t) F.addItem(e);
315
332
  Q(!0);
316
333
  } else if (E === "CREDITS") {
317
334
  let e = {
@@ -319,48 +336,48 @@ var Qe = () => {
319
336
  type: "CREDITS",
320
337
  name: "Credits",
321
338
  description: "Purchase credits for your account",
322
- price: q,
323
- currency: R.selectedCurrency || "USD",
339
+ price: W,
340
+ currency: F.selectedCurrency || "USD",
324
341
  quantity: 100
325
342
  };
326
- R.addItem(e), Q(!0);
343
+ F.addItem(e), Q(!0);
327
344
  }
328
345
  }
329
346
  }, [
330
347
  E,
331
- z,
332
- B,
333
- V,
334
- R.addItem,
335
- R.clearItems,
348
+ I,
349
+ L,
350
+ R,
351
+ F.addItem,
352
+ F.clearItems,
336
353
  v?.quantity,
337
354
  Z,
338
355
  w,
339
356
  T,
340
357
  S,
341
358
  C,
342
- q,
343
- R.selectedCurrency
359
+ W,
360
+ F.selectedCurrency
344
361
  ]), c(() => {
345
- if (!(!T || !Z || R.conversionRate <= 1)) {
346
- for (let e of R.items) if (e.type === "ORDER" && e.currency !== R.selectedCurrency) {
347
- let t = e.price * R.conversionRate;
348
- R.updateItemPrice(e.id, t, R.selectedCurrency);
362
+ if (!(!T || !Z || F.conversionRate <= 1)) {
363
+ for (let e of F.items) if (e.type === "ORDER" && e.currency !== F.selectedCurrency) {
364
+ let t = e.price * F.conversionRate;
365
+ F.updateItemPrice(e.id, t, F.selectedCurrency);
349
366
  }
350
367
  }
351
368
  }, [
352
369
  T,
353
370
  Z,
354
- R.conversionRate,
355
- R.selectedCurrency,
356
- R.updateItemPrice
371
+ F.conversionRate,
372
+ F.selectedCurrency,
373
+ F.updateItemPrice
357
374
  ]);
358
375
  let $ = Ne(null);
359
376
  c(() => {
360
- if (H) if (U.shippingCost > 0) {
361
- let e = R.selectedCurrency, t = Pt !== e && R.conversionRate > 1 ? U.shippingCost * R.conversionRate : U.shippingCost, n = $.current;
377
+ if (z) if (B.shippingCost > 0) {
378
+ let e = F.selectedCurrency, t = Rt !== e && F.conversionRate > 1 ? B.shippingCost * F.conversionRate : B.shippingCost, n = $.current;
362
379
  if (n && n.price === t && n.currency === e) return;
363
- n === null ? R.addItem({
380
+ n === null ? F.addItem({
364
381
  id: Ee,
365
382
  type: "ORDER",
366
383
  name: "Shipping",
@@ -371,89 +388,89 @@ var Qe = () => {
371
388
  storeOrderId: g,
372
389
  isShipping: !0
373
390
  }
374
- }) : R.updateItemPrice(Ee, t, e), $.current = {
391
+ }) : F.updateItemPrice(Ee, t, e), $.current = {
375
392
  price: t,
376
393
  currency: e
377
394
  };
378
- } else $.current !== null && ($.current = null, R.removeItem(Ee));
395
+ } else $.current !== null && ($.current = null, F.removeItem(Ee));
379
396
  }, [
380
- H,
381
- U.shippingCost,
382
- Pt,
383
- R.selectedCurrency,
384
- R.conversionRate,
397
+ z,
398
+ B.shippingCost,
399
+ Rt,
400
+ F.selectedCurrency,
401
+ F.conversionRate,
385
402
  g,
386
- R.addItem,
387
- R.updateItemPrice,
388
- R.removeItem
403
+ F.addItem,
404
+ F.updateItemPrice,
405
+ F.removeItem
389
406
  ]), c(() => {
390
- if (E === "CREDITS" && Z && q > 0) {
391
- let e = R.items.find((e) => e.id === "credits-purchase");
392
- e && e.price !== q && R.updateItemPrice("credits-purchase", q);
407
+ if (E === "CREDITS" && Z && W > 0) {
408
+ let e = F.items.find((e) => e.id === "credits-purchase");
409
+ e && e.price !== W && F.updateItemPrice("credits-purchase", W);
393
410
  }
394
411
  }, [
395
412
  E,
396
413
  Z,
397
- q,
398
- R.items,
399
- R.updateItemPrice
414
+ W,
415
+ F.items,
416
+ F.updateItemPrice
400
417
  ]), c(() => {
401
- if (!Z || R.items.length === 0) return;
402
- let e = R.selectedCurrency || "USD";
403
- for (let t of R.items) if (t.type === "PLAN" && z?.getPlan) {
404
- let n = z.getPlan.currencyPrices?.[e] ?? z.getPlan.price;
405
- (t.price !== n || t.currency !== e) && R.updateItemPrice(t.id, n, e);
418
+ if (!Z || F.items.length === 0) return;
419
+ let e = F.selectedCurrency || "USD";
420
+ for (let t of F.items) if (t.type === "PLAN" && I?.getPlan) {
421
+ let n = I.getPlan.currencyPrices?.[e] ?? I.getPlan.price;
422
+ (t.price !== n || t.currency !== e) && F.updateItemPrice(t.id, n, e);
406
423
  } else if (t.type === "ADDON") {
407
- if (!w && B?.getSelectedAddons?.[0]) {
408
- let n = B.getSelectedAddons[0], r = n.currencyPrices?.[e] ?? n.price;
409
- (t.price !== r || t.currency !== e) && R.updateItemPrice(t.id, r, e);
424
+ if (!w && L?.getSelectedAddons?.[0]) {
425
+ let n = L.getSelectedAddons[0], r = n.currencyPrices?.[e] ?? n.price;
426
+ (t.price !== r || t.currency !== e) && F.updateItemPrice(t.id, r, e);
410
427
  }
411
428
  if (w) {
412
429
  let n = S.find((e) => e.addon.id === t.id);
413
430
  if (n) {
414
431
  let r = n.addon.currencyPrices?.[e] ?? n.addon.price;
415
- (t.price !== r || t.currency !== e) && R.updateItemPrice(t.id, r, e);
432
+ (t.price !== r || t.currency !== e) && F.updateItemPrice(t.id, r, e);
416
433
  }
417
434
  }
418
435
  }
419
436
  }, [
420
- R.selectedCurrency,
437
+ F.selectedCurrency,
421
438
  Z,
422
- R.items,
423
- R.updateItemPrice,
424
- z,
425
- B,
439
+ F.items,
440
+ F.updateItemPrice,
441
+ I,
442
+ L,
426
443
  S,
427
444
  w
428
445
  ]), c(() => {
429
- if (Y.length > 0 && !R.billingAccount) {
446
+ if (K.length > 0 && !F.billingAccount) {
430
447
  if (v?.billingAccountId) {
431
- let e = Y.find((e) => e.id === v.billingAccountId);
448
+ let e = K.find((e) => e.id === v.billingAccountId);
432
449
  if (e) {
433
- R.setBillingAccount(e);
450
+ F.setBillingAccount(e);
434
451
  return;
435
452
  }
436
453
  }
437
454
  if (b) {
438
455
  let e = i(b);
439
456
  if (e) {
440
- let t = Y.find((t) => t.id === e);
457
+ let t = K.find((t) => t.id === e);
441
458
  if (t) {
442
- R.setBillingAccount(t);
459
+ F.setBillingAccount(t);
443
460
  return;
444
461
  }
445
462
  }
446
463
  }
447
- R.setBillingAccount(Y[0]);
464
+ F.setBillingAccount(K[0]);
448
465
  }
449
466
  }, [
450
- Y,
451
- R.billingAccount,
452
- R.setBillingAccount,
467
+ K,
468
+ F.billingAccount,
469
+ F.setBillingAccount,
453
470
  v?.billingAccountId,
454
471
  b
455
472
  ]);
456
- let Kt = !!(v?.upgradeFromSubscriptionId || v?.downgradeFromSubscriptionId);
473
+ let rn = !!(v?.upgradeFromSubscriptionId || v?.downgradeFromSubscriptionId);
457
474
  c(() => {
458
475
  w && C && S.length === 0 && !Z && _("/addons", { replace: !0 });
459
476
  }, [
@@ -463,70 +480,70 @@ var Qe = () => {
463
480
  Z,
464
481
  _
465
482
  ]);
466
- let qt = de({
467
- billingAccountId: R.billingAccount?.id,
483
+ let an = de({
484
+ billingAccountId: F.billingAccount?.id,
468
485
  purchaseType: E,
469
486
  productId: D
470
- }), Jt = s(async () => {
471
- if (!R.billingAccount) return;
472
- let e = k.current;
473
- if (k.current = !1, !e && !Te(R.billingAccount)) {
474
- O(!0);
487
+ }), on = s(async () => {
488
+ if (!F.billingAccount) return;
489
+ let e = ht.current;
490
+ if (ht.current = !1, !e && !Te(F.billingAccount)) {
491
+ mt(!0);
475
492
  return;
476
493
  }
477
- if (P(null), H) try {
478
- let e = (await It({ variables: { input: {
494
+ if (j(null), z) try {
495
+ let e = (await Bt({ variables: { input: {
479
496
  orderId: g,
480
- shippingMethodId: U.shippingMethodId,
481
- ...U.shippingAddressId ? { shippingAddressId: U.shippingAddressId } : {}
497
+ shippingMethodId: B.shippingMethodId,
498
+ ...B.shippingAddressId ? { shippingAddressId: B.shippingAddressId } : {}
482
499
  } } })).data?.setStoreOrderShipping?.shippingCost;
483
- typeof e == "number" && e !== U.shippingCost && Ft((t) => ({
500
+ typeof e == "number" && e !== B.shippingCost && zt((t) => ({
484
501
  ...t,
485
502
  shippingCost: e
486
503
  }));
487
504
  } catch {
488
- P("Could not save your shipping details. Please review your delivery address and try again."), M("error");
505
+ j("Could not save your shipping details. Please review your delivery address and try again."), k("error");
489
506
  return;
490
507
  }
491
- let t = R.billingAccount.creditAmount ?? 0, n = [...R.items], r = R.total, i = await R.initiatePayment();
508
+ let t = F.billingAccount.creditAmount ?? 0, n = [...F.items], r = F.total, i = await F.initiatePayment();
492
509
  if (i.success) {
493
510
  if (y("billing.checkout.initiated", {
494
511
  route: "/billing/checkout",
495
512
  entityId: i.paymentId ?? i.orderId,
496
513
  source: "checkout",
497
514
  amount: i.total || r,
498
- currency: i.currency || R.selectedCurrency
499
- }), R.selectedProvider === "CREDITS") {
515
+ currency: i.currency || F.selectedCurrency
516
+ }), F.selectedProvider === "CREDITS") {
500
517
  y("billing.credits.spent", {
501
518
  route: "/billing/checkout",
502
519
  entityId: i.orderId,
503
520
  source: "checkout",
504
521
  amount: r,
505
522
  currency: "CREDITS"
506
- }), bt({
523
+ }), wt({
507
524
  items: n,
508
525
  total: r,
509
- billingAccountName: R.billingAccount.name,
510
- billingAccountId: R.billingAccount.id,
526
+ billingAccountName: F.billingAccount.name,
527
+ billingAccountId: F.billingAccount.id,
511
528
  previousBalance: t,
512
529
  newBalance: t - r,
513
530
  paymentMethod: "credits",
514
531
  currency: "Credits",
515
532
  transactionId: i.orderId
516
- }), St("credits"), vt({ paymentId: i.orderId }), M("processing");
533
+ }), Et("credits"), St({ paymentId: i.orderId }), k("processing");
517
534
  return;
518
535
  }
519
- bt({
536
+ wt({
520
537
  items: n,
521
538
  total: i.total || r,
522
- billingAccountName: R.billingAccount.name,
523
- billingAccountId: R.billingAccount.id,
539
+ billingAccountName: F.billingAccount.name,
540
+ billingAccountId: F.billingAccount.id,
524
541
  previousBalance: t,
525
542
  newBalance: t,
526
543
  paymentMethod: "card",
527
- currency: i.currency || R.selectedCurrency,
544
+ currency: i.currency || F.selectedCurrency,
528
545
  transactionId: i.paymentId
529
- }), St("card"), vt({
546
+ }), Et("card"), St({
530
547
  clientSecret: i.clientSecret,
531
548
  orderId: i.orderId,
532
549
  razorpayKeyId: i.razorpayKeyId,
@@ -538,56 +555,56 @@ var Qe = () => {
538
555
  prefillContact: i.prefillContact,
539
556
  total: i.total,
540
557
  currency: i.currency
541
- }), i.paymentComplete ? M("processing") : M("payment");
558
+ }), i.paymentComplete ? k("processing") : k("payment");
542
559
  } else y("billing.checkout.failed", {
543
560
  route: "/billing/checkout",
544
561
  source: "checkout",
545
562
  reason: i.error || "Payment initiation failed"
546
- }), P(i.error || "Payment initiation failed"), M("error");
563
+ }), j(i.error || "Payment initiation failed"), k("error");
547
564
  }, [
548
- R,
565
+ F,
549
566
  y,
550
- H,
551
- U,
567
+ z,
568
+ B,
552
569
  g,
553
- It
554
- ]), Yt = s((e) => {
570
+ Bt
571
+ ]), sn = s((e) => {
555
572
  y("billing.payment.succeeded", {
556
573
  route: "/billing/checkout",
557
- entityId: N?.paymentId ?? N?.orderId,
574
+ entityId: A?.paymentId ?? A?.orderId,
558
575
  source: "checkout"
559
- }), vt((e) => e), M("processing");
576
+ }), St((e) => e), k("processing");
560
577
  }, [
561
578
  y,
562
- N?.orderId,
563
- N?.paymentId
564
- ]), Xt = s((e) => {
579
+ A?.orderId,
580
+ A?.paymentId
581
+ ]), cn = s((e) => {
565
582
  y("billing.payment.failed", {
566
583
  route: "/billing/checkout",
567
- entityId: N?.paymentId ?? N?.orderId,
584
+ entityId: A?.paymentId ?? A?.orderId,
568
585
  source: "checkout",
569
586
  reason: e
570
- }), P(e), M("error");
587
+ }), j(e), k("error");
571
588
  }, [
572
589
  y,
573
- N?.orderId,
574
- N?.paymentId
575
- ]), Zt = s((e) => {
576
- R.updateItemQuantity("credits-purchase", e);
577
- }, [R]);
578
- if (!nt.canProcessPayment) return /* @__PURE__ */ p(t, { message: "You don't have permission to make purchases." });
590
+ A?.orderId,
591
+ A?.paymentId
592
+ ]), ln = s((e) => {
593
+ F.updateItemQuantity("credits-purchase", e);
594
+ }, [F]);
595
+ if (!rt.canProcessPayment) return /* @__PURE__ */ p(t, { message: "You don't have permission to make purchases." });
579
596
  if (ue()) return /* @__PURE__ */ p(me, {
580
597
  purchaseType: E,
581
598
  productId: D,
582
- billingAccountId: R.billingAccount?.id,
583
- nativeCheckout: qt,
599
+ billingAccountId: F.billingAccount?.id,
600
+ nativeCheckout: an,
584
601
  onBack: () => _("dashboard")
585
602
  });
586
- let Qt = kt || jt && E === "PLAN" || Mt && E === "ADDON" && !w || w && !C;
603
+ let un = Nt || Ft && E === "PLAN" || It && E === "ADDON" && !w || w && !C;
587
604
  if (w && C && S.length === 0 && !Z) return null;
588
- let $t = () => {
605
+ let dn = () => {
589
606
  if (w) {
590
- let e = R.items.length;
607
+ let e = F.items.length;
591
608
  return `Purchase ${e} Add-on${e === 1 ? "" : "s"}`;
592
609
  }
593
610
  switch (E) {
@@ -596,7 +613,7 @@ var Qe = () => {
596
613
  case "ADDON": return "Purchase Add-on";
597
614
  default: return "Checkout";
598
615
  }
599
- }, en = () => {
616
+ }, fn = () => {
600
617
  switch (E) {
601
618
  case "CREDITS": return /* @__PURE__ */ p(Re, { className: "size-6" });
602
619
  case "PLAN": return /* @__PURE__ */ p(Be, { className: "size-6" });
@@ -604,7 +621,7 @@ var Qe = () => {
604
621
  default: return /* @__PURE__ */ p(Ue, { className: "size-6" });
605
622
  }
606
623
  };
607
- if (Qt) return /* @__PURE__ */ p("div", {
624
+ if (un) return /* @__PURE__ */ p("div", {
608
625
  className: "flex items-center justify-center min-h-[400px]",
609
626
  children: /* @__PURE__ */ m("div", {
610
627
  className: "text-center space-y-4",
@@ -614,10 +631,10 @@ var Qe = () => {
614
631
  })]
615
632
  })
616
633
  });
617
- if (j === "success") {
634
+ if (O === "success") {
618
635
  let e = (e) => {
619
- if (!F) return `${e.toFixed(2)}`;
620
- let t = F.currency;
636
+ if (!M) return `${e.toFixed(2)}`;
637
+ let t = M.currency;
621
638
  return t === "Credits" ? `${e.toFixed(2)} Credits` : `${{
622
639
  INR: "₹",
623
640
  USD: "$",
@@ -641,7 +658,7 @@ var Qe = () => {
641
658
  children: h("billing.checkout.purchaseCompleted", "Your purchase has been completed successfully.")
642
659
  })] })]
643
660
  }),
644
- F && /* @__PURE__ */ m("div", {
661
+ M && /* @__PURE__ */ m("div", {
645
662
  className: "bg-bg-surface border border-border-subtle rounded-lg overflow-hidden",
646
663
  children: [
647
664
  /* @__PURE__ */ m("div", {
@@ -651,7 +668,7 @@ var Qe = () => {
651
668
  children: [/* @__PURE__ */ p(Ve, { className: "size-4" }), h("billing.checkout.itemsPurchased", "Items Purchased")]
652
669
  }), /* @__PURE__ */ p("div", {
653
670
  className: "space-y-2",
654
- children: F.items.map((t) => /* @__PURE__ */ m("div", {
671
+ children: M.items.map((t) => /* @__PURE__ */ m("div", {
655
672
  className: "flex items-center justify-between",
656
673
  children: [/* @__PURE__ */ m("div", {
657
674
  className: "flex items-center gap-2",
@@ -685,7 +702,7 @@ var Qe = () => {
685
702
  children: h("billing.checkout.paymentMethod", "Payment Method")
686
703
  }), /* @__PURE__ */ p("div", {
687
704
  className: "flex items-center gap-2",
688
- children: F.paymentMethod === "credits" ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(We, { className: "size-4 text-status-warning-text" }), /* @__PURE__ */ p("span", {
705
+ children: M.paymentMethod === "credits" ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(We, { className: "size-4 text-status-warning-text" }), /* @__PURE__ */ p("span", {
689
706
  className: "font-medium text-text-primary",
690
707
  children: h("billing.checkout.credits", "Credits")
691
708
  })] }) : /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(ze, { className: "size-4 text-accent-blue" }), /* @__PURE__ */ p("span", {
@@ -699,12 +716,12 @@ var Qe = () => {
699
716
  children: h("billing.checkout.totalPaid", "Total Paid")
700
717
  }), /* @__PURE__ */ p("p", {
701
718
  className: "font-bold text-lg text-text-primary",
702
- children: e(F.total)
719
+ children: e(M.total)
703
720
  })]
704
721
  })]
705
722
  })
706
723
  }),
707
- F.paymentMethod === "credits" && /* @__PURE__ */ m("div", {
724
+ M.paymentMethod === "credits" && /* @__PURE__ */ m("div", {
708
725
  className: "p-4 border-b border-border-subtle",
709
726
  children: [/* @__PURE__ */ m("h3", {
710
727
  className: "font-semibold text-text-primary mb-3 flex items-center gap-2",
@@ -719,7 +736,7 @@ var Qe = () => {
719
736
  children: h("billing.checkout.previousBalance", "Previous Balance")
720
737
  }), /* @__PURE__ */ p("p", {
721
738
  className: "font-semibold text-text-primary",
722
- children: t(F.previousBalance)
739
+ children: t(M.previousBalance)
723
740
  })]
724
741
  }),
725
742
  /* @__PURE__ */ p(Fe, { className: "size-5 text-text-secondary shrink-0" }),
@@ -730,7 +747,7 @@ var Qe = () => {
730
747
  children: h("billing.checkout.newBalance", "New Balance")
731
748
  }), /* @__PURE__ */ p("p", {
732
749
  className: "font-semibold text-status-success-text",
733
- children: t(F.newBalance)
750
+ children: t(M.newBalance)
734
751
  })]
735
752
  })
736
753
  ]
@@ -745,15 +762,15 @@ var Qe = () => {
745
762
  children: h("billing.checkout.billingAccount", "Billing Account")
746
763
  }), /* @__PURE__ */ p("p", {
747
764
  className: "font-medium text-text-primary",
748
- children: F.billingAccountName
749
- })] }), F.transactionId && /* @__PURE__ */ m("div", {
765
+ children: M.billingAccountName
766
+ })] }), M.transactionId && /* @__PURE__ */ m("div", {
750
767
  className: "text-right",
751
768
  children: [/* @__PURE__ */ p("p", {
752
769
  className: "text-xs text-text-secondary mb-1",
753
770
  children: h("billing.checkout.transactionId", "Transaction ID")
754
771
  }), /* @__PURE__ */ m("p", {
755
772
  className: "font-mono text-xs text-text-secondary",
756
- children: [F.transactionId.slice(0, 8), "..."]
773
+ children: [M.transactionId.slice(0, 8), "..."]
757
774
  })]
758
775
  })]
759
776
  })
@@ -775,17 +792,17 @@ var Qe = () => {
775
792
  })]
776
793
  })
777
794
  ]
778
- }), pt && mt.length > 0 && x && gt && /* @__PURE__ */ p(ke, {
779
- billingAccountId: F?.billingAccountId ?? "",
780
- subscriptionId: gt,
781
- quotas: mt,
782
- workspaces: ut,
795
+ }), gt && vt.length > 0 && x && bt && /* @__PURE__ */ p(ke, {
796
+ billingAccountId: M?.billingAccountId ?? "",
797
+ subscriptionId: bt,
798
+ quotas: vt,
799
+ workspaces: dt,
783
800
  currentWorkspaceId: x,
784
- onAssigned: () => A(!1),
785
- onSkip: () => A(!1)
801
+ onAssigned: () => _t(!1),
802
+ onSkip: () => _t(!1)
786
803
  })] });
787
804
  }
788
- if (j === "error") return /* @__PURE__ */ p("div", {
805
+ if (O === "error") return /* @__PURE__ */ p("div", {
789
806
  className: "max-w-lg mx-auto p-6",
790
807
  children: /* @__PURE__ */ m("div", {
791
808
  className: "text-center space-y-6",
@@ -799,7 +816,7 @@ var Qe = () => {
799
816
  children: h("billing.checkout.paymentFailed", "Payment Failed")
800
817
  }), /* @__PURE__ */ p("p", {
801
818
  className: "text-text-secondary mt-2",
802
- children: yt || Dt || R.error || h("billing.checkout.genericError", "Something went wrong. Please try again.")
819
+ children: Ct || jt || F.error || h("billing.checkout.genericError", "Something went wrong. Please try again.")
803
820
  })] }),
804
821
  /* @__PURE__ */ m("div", {
805
822
  className: "flex gap-3 justify-center",
@@ -811,7 +828,7 @@ var Qe = () => {
811
828
  }), /* @__PURE__ */ p("button", {
812
829
  type: "button",
813
830
  onClick: () => {
814
- M("select"), P(null), R.reset();
831
+ k("select"), j(null), F.reset();
815
832
  },
816
833
  className: "px-4 py-2 rounded-lg bg-action-primary-bg text-action-primary-text hover:bg-action-primary-bgHover",
817
834
  children: h("billing.checkout.tryAgain", "Try Again")
@@ -820,7 +837,7 @@ var Qe = () => {
820
837
  ]
821
838
  })
822
839
  });
823
- if (j === "processing") return /* @__PURE__ */ p("div", {
840
+ if (O === "processing") return /* @__PURE__ */ p("div", {
824
841
  className: "max-w-lg mx-auto p-6",
825
842
  children: /* @__PURE__ */ m("div", {
826
843
  className: "text-center space-y-6",
@@ -848,7 +865,7 @@ var Qe = () => {
848
865
  children: ((e) => {
849
866
  let t = Math.floor(e / 1e3);
850
867
  return `${Math.floor(t / 60)}:${(t % 60).toString().padStart(2, "0")}`;
851
- })(Et)
868
+ })(At)
852
869
  })
853
870
  ]
854
871
  }), /* @__PURE__ */ p("p", {
@@ -860,13 +877,13 @@ var Qe = () => {
860
877
  className: "w-full bg-bg-sunken rounded-full h-2 overflow-hidden",
861
878
  children: /* @__PURE__ */ p("div", {
862
879
  className: "bg-action-primary-bg h-2 rounded-full transition-all duration-1000",
863
- style: { width: `${Math.min(Et / 3e5 * 100, 100)}%` }
880
+ style: { width: `${Math.min(At / 3e5 * 100, 100)}%` }
864
881
  })
865
882
  }),
866
- Et > 3e4 && /* @__PURE__ */ p("button", {
883
+ At > 3e4 && /* @__PURE__ */ p("button", {
867
884
  type: "button",
868
885
  onClick: () => {
869
- M("error"), P("Payment verification was cancelled. Please check your billing history.");
886
+ k("error"), j("Payment verification was cancelled. Please check your billing history.");
870
887
  },
871
888
  className: "text-sm text-text-secondary hover:text-text-primary underline",
872
889
  children: h("billing.checkout.cancelAndCheckHistory", "Cancel and check billing history")
@@ -874,19 +891,19 @@ var Qe = () => {
874
891
  ]
875
892
  })
876
893
  });
877
- if (j === "payment" && N) {
894
+ if (O === "payment" && A) {
878
895
  let e = (e, t) => `${{
879
896
  INR: "₹",
880
897
  USD: "$",
881
898
  EUR: "€",
882
899
  GBP: "£"
883
- }[t] || t + " "}${e.toFixed(2)}`, t = N.currency || R.selectedCurrency, r = N.total ?? R.total;
900
+ }[t] || t + " "}${e.toFixed(2)}`, t = A.currency || F.selectedCurrency, r = A.total ?? F.total;
884
901
  return /* @__PURE__ */ m("div", {
885
902
  className: "max-w-2xl mx-auto p-4 sm:p-6 space-y-6",
886
903
  children: [
887
904
  /* @__PURE__ */ m("button", {
888
905
  type: "button",
889
- onClick: () => M("select"),
906
+ onClick: () => k("select"),
890
907
  className: "flex items-center gap-2 text-sm text-text-secondary hover:text-text-primary",
891
908
  children: [/* @__PURE__ */ p(Pe, { className: "size-4" }), h("billing.checkout.backToCheckout", "Back to checkout")]
892
909
  }),
@@ -901,7 +918,7 @@ var Qe = () => {
901
918
  className: "font-semibold text-text-primary flex items-center gap-2",
902
919
  children: [/* @__PURE__ */ p(Ve, { className: "size-4" }), h("billing.checkout.paymentSummary", "Payment Summary")]
903
920
  }),
904
- R.billingAccount && /* @__PURE__ */ m("div", {
921
+ F.billingAccount && /* @__PURE__ */ m("div", {
905
922
  className: "p-3 bg-bg-sunken rounded-lg space-y-1",
906
923
  children: [
907
924
  /* @__PURE__ */ p("div", {
@@ -910,15 +927,15 @@ var Qe = () => {
910
927
  }),
911
928
  /* @__PURE__ */ p("div", {
912
929
  className: "font-medium text-text-primary",
913
- children: R.billingAccount.name
930
+ children: F.billingAccount.name
914
931
  }),
915
932
  /* @__PURE__ */ p("div", {
916
933
  className: "text-sm text-text-secondary",
917
- children: R.billingAccount.email
934
+ children: F.billingAccount.email
918
935
  })
919
936
  ]
920
937
  }),
921
- E === "ADDON" && R.selectedSubscriptionId && G && /* @__PURE__ */ m("div", {
938
+ E === "ADDON" && F.selectedSubscriptionId && H && /* @__PURE__ */ m("div", {
922
939
  className: "p-3 bg-bg-sunken rounded-lg space-y-1",
923
940
  children: [
924
941
  /* @__PURE__ */ p("div", {
@@ -927,11 +944,11 @@ var Qe = () => {
927
944
  }),
928
945
  /* @__PURE__ */ p("div", {
929
946
  className: "font-medium text-text-primary",
930
- children: G.plan?.name || h("billing.checkout.subscription", "Subscription")
947
+ children: H.plan?.name || h("billing.checkout.subscription", "Subscription")
931
948
  }),
932
- G.plan?.product?.name && /* @__PURE__ */ p("div", {
949
+ H.plan?.product?.name && /* @__PURE__ */ p("div", {
933
950
  className: "text-sm text-text-secondary",
934
- children: G.plan.product.name
951
+ children: H.plan.product.name
935
952
  })
936
953
  ]
937
954
  }),
@@ -939,7 +956,7 @@ var Qe = () => {
939
956
  className: "space-y-2 text-sm",
940
957
  children: [
941
958
  (() => {
942
- let n = R.taxRate, i = n > 0 ? r / (1 + n) : r, a = n > 0 ? r - i : 0;
959
+ let n = F.taxRate, i = n > 0 ? r / (1 + n) : r, a = n > 0 ? r - i : 0;
943
960
  return /* @__PURE__ */ m(f, { children: [
944
961
  /* @__PURE__ */ m("div", {
945
962
  className: "flex justify-between",
@@ -951,16 +968,16 @@ var Qe = () => {
951
968
  children: e(i, t)
952
969
  })]
953
970
  }),
954
- R.discountAmount > 0 && /* @__PURE__ */ m("div", {
971
+ F.discountAmount > 0 && /* @__PURE__ */ m("div", {
955
972
  className: "flex justify-between text-status-success-text",
956
- children: [/* @__PURE__ */ p("span", { children: h("billing.checkout.discount", "Discount") }), /* @__PURE__ */ m("span", { children: ["-", e(R.discountAmount, t)] })]
973
+ children: [/* @__PURE__ */ p("span", { children: h("billing.checkout.discount", "Discount") }), /* @__PURE__ */ m("span", { children: ["-", e(F.discountAmount, t)] })]
957
974
  }),
958
975
  a > 0 && /* @__PURE__ */ m("div", {
959
976
  className: "flex justify-between",
960
977
  children: [/* @__PURE__ */ m("span", {
961
978
  className: "text-text-secondary",
962
979
  children: [
963
- R.taxType || h("billing.checkout.tax", "Tax"),
980
+ F.taxType || h("billing.checkout.tax", "Tax"),
964
981
  " (",
965
982
  (n * 100).toFixed(0),
966
983
  "%)"
@@ -987,23 +1004,23 @@ var Qe = () => {
987
1004
  })
988
1005
  ]
989
1006
  }),
990
- R.selectedProvider === "STRIPE" && N.clientSecret && /* @__PURE__ */ p("div", {
1007
+ F.selectedProvider === "STRIPE" && A.clientSecret && /* @__PURE__ */ p("div", {
991
1008
  className: "rounded-lg border border-border-subtle bg-bg-surface overflow-hidden",
992
1009
  children: /* @__PURE__ */ p("div", {
993
1010
  className: "p-4 space-y-4",
994
1011
  children: /* @__PURE__ */ p(ye, {
995
- clientSecret: N.clientSecret,
996
- publishableKey: rt || Ct?.stripePublishableKey || "",
997
- amount: Math.round((N.total ?? R.total) * 100),
998
- currency: N.currency || R.selectedCurrency,
999
- onSuccess: Yt,
1000
- onError: Xt,
1001
- onCancel: () => M("select"),
1002
- isCompletingExistingPayment: !!R.selectedPaymentMethodId
1012
+ clientSecret: A.clientSecret,
1013
+ publishableKey: it || Dt?.stripePublishableKey || "",
1014
+ amount: Math.round((A.total ?? F.total) * 100),
1015
+ currency: A.currency || F.selectedCurrency,
1016
+ onSuccess: sn,
1017
+ onError: cn,
1018
+ onCancel: () => k("select"),
1019
+ isCompletingExistingPayment: !!F.selectedPaymentMethodId
1003
1020
  })
1004
1021
  })
1005
1022
  }),
1006
- R.selectedProvider === "RAZORPAY" && N.orderId && /* @__PURE__ */ p("div", {
1023
+ F.selectedProvider === "RAZORPAY" && A.orderId && /* @__PURE__ */ p("div", {
1007
1024
  className: "rounded-lg border border-border-subtle bg-bg-surface overflow-hidden",
1008
1025
  children: /* @__PURE__ */ m("div", {
1009
1026
  className: "p-4 space-y-4",
@@ -1011,27 +1028,27 @@ var Qe = () => {
1011
1028
  className: "flex items-center gap-2 cursor-pointer",
1012
1029
  children: [/* @__PURE__ */ p("input", {
1013
1030
  type: "checkbox",
1014
- checked: R.saveCard,
1015
- onChange: (e) => R.setSaveCard(e.target.checked),
1031
+ checked: F.saveCard,
1032
+ onChange: (e) => F.setSaveCard(e.target.checked),
1016
1033
  className: "size-4 rounded border-border-subtle text-text-link focus:ring-[var(--color-focus-ring)]"
1017
1034
  }), /* @__PURE__ */ p("span", {
1018
1035
  className: "text-sm text-text-secondary",
1019
1036
  children: "Save card for future purchases"
1020
1037
  })]
1021
1038
  }), /* @__PURE__ */ p(be, {
1022
- orderId: N.orderId,
1023
- keyId: N.razorpayKeyId || it || "",
1024
- amount: Math.round((N.total ?? R.total) * 100),
1025
- currency: N.currency || "INR",
1026
- customerId: N.razorpayCustomerId,
1039
+ orderId: A.orderId,
1040
+ keyId: A.razorpayKeyId || at || "",
1041
+ amount: Math.round((A.total ?? F.total) * 100),
1042
+ currency: A.currency || "INR",
1043
+ customerId: A.razorpayCustomerId,
1027
1044
  prefill: {
1028
- name: N.prefillName,
1029
- email: N.prefillEmail,
1030
- contact: N.prefillContact
1045
+ name: A.prefillName,
1046
+ email: A.prefillEmail,
1047
+ contact: A.prefillContact
1031
1048
  },
1032
- onSuccess: (e) => Yt(e.razorpay_payment_id),
1033
- onError: Xt,
1034
- onCancel: () => M("select")
1049
+ onSuccess: (e) => sn(e.razorpay_payment_id),
1050
+ onError: cn,
1051
+ onCancel: () => k("select")
1035
1052
  })]
1036
1053
  })
1037
1054
  })
@@ -1051,10 +1068,10 @@ var Qe = () => {
1051
1068
  className: "flex items-center gap-3 mb-6",
1052
1069
  children: [/* @__PURE__ */ p("div", {
1053
1070
  className: "p-2 rounded-lg bg-[var(--color-accent-soft)] text-text-link",
1054
- children: en()
1071
+ children: fn()
1055
1072
  }), /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("h1", {
1056
1073
  className: "text-2xl font-bold text-text-primary",
1057
- children: $t()
1074
+ children: dn()
1058
1075
  }), /* @__PURE__ */ p("p", {
1059
1076
  className: "text-sm text-text-secondary",
1060
1077
  children: "Complete your purchase securely"
@@ -1121,58 +1138,58 @@ var Qe = () => {
1121
1138
  children: [/* @__PURE__ */ m("div", {
1122
1139
  className: "lg:col-span-3 space-y-6 order-2 lg:order-1",
1123
1140
  children: [
1124
- E === "CREDITS" && R.items[0] && /* @__PURE__ */ p("div", {
1141
+ E === "CREDITS" && F.items[0] && /* @__PURE__ */ p("div", {
1125
1142
  className: "rounded-lg border border-border-subtle bg-bg-surface p-4 sm:p-6",
1126
1143
  children: /* @__PURE__ */ p(ve, {
1127
- value: R.items[0].quantity,
1128
- onChange: Zt,
1129
- costPerCredit: q,
1130
- currency: R.selectedCurrency,
1131
- disabled: Ut
1144
+ value: F.items[0].quantity,
1145
+ onChange: ln,
1146
+ costPerCredit: W,
1147
+ currency: F.selectedCurrency,
1148
+ disabled: qt
1132
1149
  })
1133
1150
  }),
1134
1151
  /* @__PURE__ */ m("div", {
1135
1152
  className: "rounded-lg border border-border-subtle bg-bg-surface p-4 sm:p-6 space-y-4",
1136
1153
  children: [/* @__PURE__ */ p(he, {
1137
- accounts: Y,
1138
- selectedAccountId: R.billingAccount?.id ?? null,
1139
- onSelect: R.setBillingAccount,
1140
- isLoading: kt,
1141
- disabled: Kt,
1142
- disabledMessage: Kt ? "Billing account is locked for plan changes" : void 0
1143
- }), E === "ADDON" && !T && R.billingAccount && /* @__PURE__ */ p(xe, {
1144
- subscriptions: W,
1145
- selectedSubscriptionId: R.selectedSubscriptionId,
1146
- onSelect: R.setSelectedSubscriptionId,
1147
- isLoading: Bt
1154
+ accounts: K,
1155
+ selectedAccountId: F.billingAccount?.id ?? null,
1156
+ onSelect: F.setBillingAccount,
1157
+ isLoading: Nt,
1158
+ disabled: rn,
1159
+ disabledMessage: rn ? "Billing account is locked for plan changes" : void 0
1160
+ }), E === "ADDON" && !T && F.billingAccount && /* @__PURE__ */ p(xe, {
1161
+ subscriptions: V,
1162
+ selectedSubscriptionId: F.selectedSubscriptionId,
1163
+ onSelect: F.setSelectedSubscriptionId,
1164
+ isLoading: Wt
1148
1165
  })]
1149
1166
  }),
1150
- H && /* @__PURE__ */ p(Oe, {
1167
+ z && /* @__PURE__ */ p(Oe, {
1151
1168
  storeOrderId: g,
1152
- currency: R.selectedCurrency,
1153
- onChange: Ft
1169
+ currency: F.selectedCurrency,
1170
+ onChange: zt
1154
1171
  }),
1155
1172
  /* @__PURE__ */ m("div", {
1156
1173
  className: "rounded-lg border border-border-subtle bg-bg-surface p-4 sm:p-6 space-y-4",
1157
1174
  children: [
1158
1175
  /* @__PURE__ */ p(Ce, {
1159
- savedPaymentMethods: J,
1160
- selectedPaymentMethodId: R.selectedPaymentMethodId,
1161
- onSelectSavedCard: R.setSelectedPaymentMethodId,
1162
- selectedProvider: R.selectedProvider,
1163
- onSelectProvider: R.setPaymentProvider,
1164
- stripeEnabled: wt,
1165
- razorpayEnabled: Tt,
1166
- canPayWithCredits: R.canPayWithCredits && R.hasEnoughCredits,
1167
- availableCredits: R.availableCredits,
1168
- totalAmount: R.subtotalUSD,
1169
- billingCountry: X,
1170
- saveCard: R.saveCard,
1171
- onSaveCardChange: R.setSaveCard,
1172
- autoRenewEnabled: E === "PLAN" && R.autoRenew,
1173
- isLoading: Rt
1176
+ savedPaymentMethods: G,
1177
+ selectedPaymentMethodId: F.selectedPaymentMethodId,
1178
+ onSelectSavedCard: F.setSelectedPaymentMethodId,
1179
+ selectedProvider: F.selectedProvider,
1180
+ onSelectProvider: F.setPaymentProvider,
1181
+ stripeEnabled: Ot,
1182
+ razorpayEnabled: kt,
1183
+ canPayWithCredits: F.canPayWithCredits && F.hasEnoughCredits,
1184
+ availableCredits: F.availableCredits,
1185
+ totalAmount: F.subtotalUSD,
1186
+ billingCountry: q,
1187
+ saveCard: F.saveCard,
1188
+ onSaveCardChange: F.setSaveCard,
1189
+ autoRenewEnabled: E === "PLAN" && F.autoRenew,
1190
+ isLoading: Ht
1174
1191
  }),
1175
- R.selectedProvider !== "CREDITS" && R.selectedProvider !== "AUTO" && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("div", { className: "border-t border-border-subtle" }), /* @__PURE__ */ p("div", {
1192
+ F.selectedProvider !== "CREDITS" && F.selectedProvider !== "AUTO" && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("div", { className: "border-t border-border-subtle" }), /* @__PURE__ */ p("div", {
1176
1193
  className: "bg-bg-sunken p-4 rounded-button",
1177
1194
  children: /* @__PURE__ */ m("div", {
1178
1195
  className: "flex items-start gap-3",
@@ -1191,7 +1208,7 @@ var Qe = () => {
1191
1208
  className: "flex-1 text-sm",
1192
1209
  children: [/* @__PURE__ */ m("p", {
1193
1210
  className: "font-medium text-text-primary mb-1",
1194
- children: ["Currency: ", R.selectedCurrency]
1211
+ children: ["Currency: ", F.selectedCurrency]
1195
1212
  }), /* @__PURE__ */ m("p", {
1196
1213
  className: "text-text-secondary text-xs",
1197
1214
  children: [
@@ -1199,30 +1216,30 @@ var Qe = () => {
1199
1216
  " ",
1200
1217
  /* @__PURE__ */ p("strong", {
1201
1218
  className: "text-text-primary",
1202
- children: R.selectedCurrency
1219
+ children: F.selectedCurrency
1203
1220
  }),
1204
1221
  " ",
1205
1222
  "based on your billing account settings.",
1206
- R.selectedCurrency === "INR" && " GST will be applied at checkout."
1223
+ F.selectedCurrency === "INR" && " GST will be applied at checkout."
1207
1224
  ]
1208
1225
  })]
1209
1226
  })]
1210
1227
  })
1211
1228
  })] }),
1212
- E === "PLAN" && z?.getPlan?.pricingModel === "PER_SEAT" && /* @__PURE__ */ p("div", {
1229
+ E === "PLAN" && I?.getPlan?.pricingModel === "PER_SEAT" && /* @__PURE__ */ p("div", {
1213
1230
  className: "border-t border-border-subtle pt-4",
1214
1231
  children: /* @__PURE__ */ m("div", {
1215
1232
  className: "space-y-3",
1216
1233
  children: [/* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("label", {
1217
1234
  className: "text-sm font-medium text-text-primary",
1218
1235
  children: "Number of seats"
1219
- }), z.getPlan.minSeats && /* @__PURE__ */ m("p", {
1236
+ }), I.getPlan.minSeats && /* @__PURE__ */ m("p", {
1220
1237
  className: "text-xs text-text-secondary mt-0.5",
1221
1238
  children: [
1222
1239
  "Minimum ",
1223
- z.getPlan.minSeats,
1240
+ I.getPlan.minSeats,
1224
1241
  " seat",
1225
- z.getPlan.minSeats === 1 ? "" : "s",
1242
+ I.getPlan.minSeats === 1 ? "" : "s",
1226
1243
  " required"
1227
1244
  ]
1228
1245
  })] }), /* @__PURE__ */ m("div", {
@@ -1230,44 +1247,44 @@ var Qe = () => {
1230
1247
  children: [
1231
1248
  /* @__PURE__ */ p("button", {
1232
1249
  type: "button",
1233
- onClick: () => L((e) => Math.max(z.getPlan?.minSeats ?? 1, e - 1)),
1234
- disabled: I <= (z.getPlan.minSeats ?? 1),
1250
+ onClick: () => P((e) => Math.max(I.getPlan?.minSeats ?? 1, e - 1)),
1251
+ disabled: N <= (I.getPlan.minSeats ?? 1),
1235
1252
  className: "size-9 rounded-button border border-border-subtle flex items-center justify-center hover:bg-action-ghost-bgHover disabled:opacity-40 disabled:cursor-not-allowed transition-colors text-text-primary",
1236
1253
  children: "−"
1237
1254
  }),
1238
1255
  /* @__PURE__ */ p("input", {
1239
1256
  type: "number",
1240
- value: I,
1241
- min: z.getPlan.minSeats ?? 1,
1242
- max: z.getPlan.maxSeats ?? 999,
1257
+ value: N,
1258
+ min: I.getPlan.minSeats ?? 1,
1259
+ max: I.getPlan.maxSeats ?? 999,
1243
1260
  onChange: (e) => {
1244
1261
  let t = parseInt(e.target.value, 10);
1245
- isNaN(t) || L(Math.max(z.getPlan?.minSeats ?? 1, t));
1262
+ isNaN(t) || P(Math.max(I.getPlan?.minSeats ?? 1, t));
1246
1263
  },
1247
1264
  className: "w-20 h-9 text-center border border-border-subtle rounded-button bg-bg-surface text-text-primary text-sm focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]"
1248
1265
  }),
1249
1266
  /* @__PURE__ */ p("button", {
1250
1267
  type: "button",
1251
- onClick: () => L((e) => Math.min(z.getPlan?.maxSeats ?? 999, e + 1)),
1252
- disabled: I >= (z.getPlan.maxSeats ?? 999),
1268
+ onClick: () => P((e) => Math.min(I.getPlan?.maxSeats ?? 999, e + 1)),
1269
+ disabled: N >= (I.getPlan.maxSeats ?? 999),
1253
1270
  className: "size-9 rounded-button border border-border-subtle flex items-center justify-center hover:bg-action-ghost-bgHover disabled:opacity-40 disabled:cursor-not-allowed transition-colors text-text-primary",
1254
1271
  children: "+"
1255
1272
  }),
1256
- z.getPlan.pricePerSeat && /* @__PURE__ */ m("span", {
1273
+ I.getPlan.pricePerSeat && /* @__PURE__ */ m("span", {
1257
1274
  className: "text-sm text-text-secondary",
1258
1275
  children: [
1259
1276
  "×",
1260
1277
  " ",
1261
- z.getPlan.pricePerSeat.toLocaleString("en", {
1278
+ I.getPlan.pricePerSeat.toLocaleString("en", {
1262
1279
  style: "currency",
1263
- currency: z.getPlan.currency ?? "USD"
1280
+ currency: I.getPlan.currency ?? "USD"
1264
1281
  }),
1265
1282
  " ",
1266
1283
  "=",
1267
1284
  " ",
1268
- (z.getPlan.pricePerSeat * I).toLocaleString("en", {
1285
+ (I.getPlan.pricePerSeat * N).toLocaleString("en", {
1269
1286
  style: "currency",
1270
- currency: z.getPlan.currency ?? "USD"
1287
+ currency: I.getPlan.currency ?? "USD"
1271
1288
  }),
1272
1289
  "/mo"
1273
1290
  ]
@@ -1290,46 +1307,46 @@ var Qe = () => {
1290
1307
  /* @__PURE__ */ p("div", {
1291
1308
  className: "p-4",
1292
1309
  children: /* @__PURE__ */ p(ge, {
1293
- items: R.items,
1294
- subtotal: R.subtotal,
1295
- discountAmount: R.discountAmount,
1296
- taxAmount: R.taxAmount,
1297
- taxRate: R.taxRate,
1298
- taxType: R.taxType,
1299
- total: R.total,
1300
- currency: R.selectedCurrency,
1301
- isCalculatingTax: R.isCalculatingTax,
1302
- showInCredits: R.selectedProvider === "CREDITS",
1303
- onUpdateQuantity: E !== "PLAN" && E !== "ORDER" ? R.updateItemQuantity : void 0,
1304
- onRemoveItem: R.removeItem,
1310
+ items: F.items,
1311
+ subtotal: F.subtotal,
1312
+ discountAmount: F.discountAmount,
1313
+ taxAmount: F.taxAmount,
1314
+ taxRate: F.taxRate,
1315
+ taxType: F.taxType,
1316
+ total: F.total,
1317
+ currency: F.selectedCurrency,
1318
+ isCalculatingTax: F.isCalculatingTax,
1319
+ showInCredits: F.selectedProvider === "CREDITS",
1320
+ onUpdateQuantity: E !== "PLAN" && E !== "ORDER" ? F.updateItemQuantity : void 0,
1321
+ onRemoveItem: F.removeItem,
1305
1322
  isEditable: E !== "PLAN" && E !== "ORDER"
1306
1323
  })
1307
1324
  }),
1308
1325
  /* @__PURE__ */ p("div", {
1309
1326
  className: "px-4 pb-4 border-t border-border-subtle pt-4",
1310
1327
  children: /* @__PURE__ */ p(_e, {
1311
- value: R.promoCode,
1312
- onChange: R.setPromoCode,
1313
- onValidate: async () => await R.validatePromoCode(),
1314
- onClear: R.clearPromoCode,
1315
- isApplied: R.promoDiscount > 0,
1316
- discountValue: R.promoDiscount,
1317
- discountType: R.promoDiscountType,
1318
- isValidating: R.isProcessing
1328
+ value: F.promoCode,
1329
+ onChange: F.setPromoCode,
1330
+ onValidate: async () => await F.validatePromoCode(),
1331
+ onClear: F.clearPromoCode,
1332
+ isApplied: F.promoDiscount > 0,
1333
+ discountValue: F.promoDiscount,
1334
+ discountType: F.promoDiscountType,
1335
+ isValidating: F.isProcessing
1319
1336
  })
1320
1337
  }),
1321
- E === "PLAN" && R.selectedProvider !== "CREDITS" && R.selectedProvider !== "AUTO" && (() => {
1338
+ E === "PLAN" && F.selectedProvider !== "CREDITS" && F.selectedProvider !== "AUTO" && (() => {
1322
1339
  let e = "", t = !1, n = !1;
1323
- if (R.selectedPaymentMethodId) {
1324
- let r = J.find((e) => e.id === R.selectedPaymentMethodId);
1340
+ if (F.selectedPaymentMethodId) {
1341
+ let r = G.find((e) => e.id === F.selectedPaymentMethodId);
1325
1342
  r && (e = `${r.type === "CREDIT_CARD" || r.type === "DEBIT_CARD" ? "Card" : r.type}${r.last4 ? ` •••• ${r.last4}` : ""}`, t = !0, n = !1);
1326
- } else (R.selectedProvider === "RAZORPAY" || R.selectedProvider === "STRIPE") && (e = R.selectedProvider === "RAZORPAY" ? "new card (Razorpay)" : "new card (Stripe)", t = !0, n = !0);
1343
+ } else (F.selectedProvider === "RAZORPAY" || F.selectedProvider === "STRIPE") && (e = F.selectedProvider === "RAZORPAY" ? "new card (Razorpay)" : "new card (Stripe)", t = !0, n = !0);
1327
1344
  return /* @__PURE__ */ p("div", {
1328
1345
  className: "px-4 pb-4",
1329
1346
  children: /* @__PURE__ */ p(Se, {
1330
- enabled: R.autoRenew,
1347
+ enabled: F.autoRenew,
1331
1348
  onToggle: (e) => {
1332
- R.setAutoRenew(e), e && R.selectedPaymentMethodId && R.setAutoRenewPaymentMethodId(R.selectedPaymentMethodId);
1349
+ F.setAutoRenew(e), e && F.selectedPaymentMethodId && F.setAutoRenewPaymentMethodId(F.selectedPaymentMethodId);
1333
1350
  },
1334
1351
  hasPaymentMethodSelected: t,
1335
1352
  selectedPaymentMethodDisplay: e,
@@ -1341,10 +1358,10 @@ var Qe = () => {
1341
1358
  }),
1342
1359
  /* @__PURE__ */ p("button", {
1343
1360
  type: "button",
1344
- onClick: Jt,
1345
- disabled: R.isProcessing || !R.billingAccount || R.items.length === 0 || E === "ADDON" && !T && Bt || E === "ADDON" && !T && W.length === 0 || E === "ADDON" && !T && !R.selectedSubscriptionId || H && (!U.shippingAddressId || !U.shippingMethodId),
1361
+ onClick: on,
1362
+ disabled: F.isProcessing || !F.billingAccount || F.items.length === 0 || E === "ADDON" && !T && Wt || E === "ADDON" && !T && V.length === 0 || E === "ADDON" && !T && !F.selectedSubscriptionId || z && (!B.shippingAddressId || !B.shippingMethodId),
1346
1363
  className: "w-full px-6 py-4 rounded-lg bg-action-primary-bg text-action-primary-text font-semibold\n hover:bg-action-primary-bgHover disabled:opacity-50 disabled:cursor-not-allowed\n transition-colors flex items-center justify-center gap-2",
1347
- children: R.isProcessing ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(d, { className: "size-5 animate-spin" }), "Processing…"] }) : R.selectedProvider === "CREDITS" ? "Pay with Credits" : "Proceed to Payment"
1364
+ children: F.isProcessing ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(d, { className: "size-5 animate-spin" }), "Processing…"] }) : F.selectedProvider === "CREDITS" ? "Pay with Credits" : "Proceed to Payment"
1348
1365
  }),
1349
1366
  /* @__PURE__ */ p("p", {
1350
1367
  className: "text-center text-xs text-text-secondary",
@@ -1354,22 +1371,22 @@ var Qe = () => {
1354
1371
  })
1355
1372
  })]
1356
1373
  }),
1357
- ft && R.billingAccount && /* @__PURE__ */ p(we, {
1358
- billingAccountId: R.billingAccount.id,
1359
- hasPhone: !!R.billingAccount.contactNumber?.trim(),
1360
- hasAddress: !!(R.billingAccount.billingAddresses?.[0]?.line1?.trim() && R.billingAccount.billingAddresses?.[0]?.postalCode?.trim()),
1374
+ pt && F.billingAccount && /* @__PURE__ */ p(we, {
1375
+ billingAccountId: F.billingAccount.id,
1376
+ hasPhone: !!F.billingAccount.contactNumber?.trim(),
1377
+ hasAddress: !!(F.billingAccount.billingAddresses?.[0]?.line1?.trim() && F.billingAccount.billingAddresses?.[0]?.postalCode?.trim()),
1361
1378
  onCompleted: () => {
1362
- k.current = !0, O(!1), Jt(), At().then((e) => {
1363
- let t = (e.data?.myBillingAccounts ?? []).find((e) => e.id === R.billingAccount?.id);
1364
- t && R.setBillingAccount(t);
1379
+ ht.current = !0, mt(!1), on(), Pt().then((e) => {
1380
+ let t = (e.data?.myBillingAccounts ?? []).map(Qe).find((e) => e?.id === F.billingAccount?.id);
1381
+ t && F.setBillingAccount(t);
1365
1382
  });
1366
1383
  },
1367
- onCancel: () => O(!1)
1384
+ onCancel: () => mt(!1)
1368
1385
  })
1369
1386
  ]
1370
1387
  });
1371
1388
  };
1372
1389
  //#endregion
1373
- export { Qe as CheckoutPage };
1390
+ export { $e as CheckoutPage };
1374
1391
 
1375
1392
  //# sourceMappingURL=CheckoutPage.js.map