@burdenoff/microfe-billing 2026.601.2 → 2026.601.3

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.
@@ -40,9 +40,9 @@ var Ke = () => {
40
40
  let { t: Ke } = We(), h = (e, t) => {
41
41
  let n = Ke(e);
42
42
  return n === e ? t : n;
43
- }, { planId: qe, addonId: g, storeOrderId: _ } = He(), v = se(), Je = Ve(), y = Je.state, Ye = a(), { emit: b } = r(), { orgId: x, stripePublishableKey: Xe, razorpayKey: Ze, apiGatewayUrl: Qe, authToken: $e, currentUser: et } = e(), { productSlug: tt } = Ue(), S = Oe(null), { items: C, clearCart: nt, _hasHydrated: w } = oe(), T = Je.pathname.includes("/checkout/addons") && !g, E = Je.pathname.includes("/checkout/store") && !!_, D = T ? "ADDON" : E ? "ORDER" : y?.purchaseType ?? (qe ? "PLAN" : g ? "ADDON" : "CREDITS"), O = y?.itemId ?? qe ?? g ?? _, [rt, k] = u(!1), [A, j] = u("select"), [M, N] = u(null), [it, P] = u(null), [F, I] = u(null), [at, ot] = u("card");
43
+ }, { planId: qe, addonId: g, storeOrderId: _ } = He(), v = se(), y = Ve(), b = y.state, Je = a(), { emit: x } = r(), { orgId: S, stripePublishableKey: Ye, razorpayKey: Xe, apiGatewayUrl: Ze, authToken: Qe, currentUser: $e } = e(), { productSlug: et } = Ue(), C = Oe(null), { items: w, clearCart: tt, _hasHydrated: T } = oe(), E = y.pathname.includes("/checkout/addons") && !g, D = y.pathname.includes("/checkout/store") && !!_, O = E ? "ADDON" : D ? "ORDER" : b?.purchaseType ?? (qe ? "PLAN" : g ? "ADDON" : "CREDITS"), k = b?.itemId ?? qe ?? g ?? _, [nt, A] = u(!1), j = Oe(!1), [M, N] = u("select"), [P, F] = u(null), [rt, I] = u(null), [L, it] = u(null), [at, ot] = u("card");
44
44
  c(() => {
45
- if (A !== "success" || !F) return;
45
+ if (M !== "success" || !L) return;
46
46
  let e = typeof window < "u" ? window.localStorage.getItem(Ge("boff-referral-attribution")) : null;
47
47
  if (!e) return;
48
48
  let t;
@@ -52,168 +52,168 @@ var Ke = () => {
52
52
  return;
53
53
  }
54
54
  if (!t.journeyId && !t.codeId) return;
55
- let n = F.transactionId || M?.paymentId || M?.orderId || _ || O || D, r = `${t.journeyId ?? "journey"}:${n}`;
56
- S.current !== r && (S.current = r, ce({
55
+ let n = L.transactionId || P?.paymentId || P?.orderId || _ || k || O, r = `${t.journeyId ?? "journey"}:${n}`;
56
+ C.current !== r && (C.current = r, ce({
57
57
  journeyId: t.journeyId,
58
58
  codeId: t.codeId,
59
- eventType: D === "ORDER" ? "STORE_PURCHASE" : "PAID_CONVERSION",
60
- productSlug: tt,
61
- actorUserId: et?.id,
62
- orderId: F.transactionId || M?.paymentId || M?.orderId,
63
- billingAccountId: F.billingAccountId,
64
- storeOrderId: D === "ORDER" ? _ : void 0,
65
- valueAmount: F.total,
66
- currency: F.currency,
59
+ eventType: O === "ORDER" ? "STORE_PURCHASE" : "PAID_CONVERSION",
60
+ productSlug: et,
61
+ actorUserId: $e?.id,
62
+ orderId: L.transactionId || P?.paymentId || P?.orderId,
63
+ billingAccountId: L.billingAccountId,
64
+ storeOrderId: O === "ORDER" ? _ : void 0,
65
+ valueAmount: L.total,
66
+ currency: L.currency,
67
67
  mode: "billing-checkout",
68
68
  metadata: {
69
- purchaseType: D,
70
- billingAccountName: F.billingAccountName
69
+ purchaseType: O,
70
+ billingAccountName: L.billingAccountName
71
71
  }
72
72
  }, {
73
- apiGatewayUrl: Qe,
74
- authToken: $e,
75
- orgId: x
73
+ apiGatewayUrl: Ze,
74
+ authToken: Qe,
75
+ orgId: S
76
76
  }).catch(() => {
77
- S.current = null;
77
+ C.current = null;
78
78
  }));
79
79
  }, [
80
+ Ze,
80
81
  Qe,
81
- $e,
82
- et?.id,
82
+ $e?.id,
83
+ k,
84
+ M,
85
+ S,
86
+ P?.orderId,
87
+ P?.paymentId,
88
+ et,
89
+ L,
83
90
  O,
84
- A,
85
- x,
86
- M?.orderId,
87
- M?.paymentId,
88
- tt,
89
- F,
90
- D,
91
91
  _
92
92
  ]);
93
- let [L, R] = u(1), z = le({
93
+ let [R, z] = u(1), B = le({
94
94
  defaultCurrency: "USD",
95
- upgradeFromSubscriptionId: y?.upgradeFromSubscriptionId,
96
- downgradeFromSubscriptionId: y?.downgradeFromSubscriptionId
97
- }), { config: st, stripeEnabled: ct, razorpayEnabled: B } = fe(), { elapsedTime: lt, error: ut } = pe({
98
- paymentId: A === "processing" ? M?.paymentId ?? null : null,
99
- billingAccountId: z.billingAccount?.id ?? F?.billingAccountId ?? null,
95
+ upgradeFromSubscriptionId: b?.upgradeFromSubscriptionId,
96
+ downgradeFromSubscriptionId: b?.downgradeFromSubscriptionId
97
+ }), { config: st, stripeEnabled: ct, razorpayEnabled: lt } = fe(), { elapsedTime: ut, error: dt } = pe({
98
+ paymentId: M === "processing" ? P?.paymentId ?? null : null,
99
+ billingAccountId: B.billingAccount?.id ?? L?.billingAccountId ?? null,
100
100
  paymentType: at,
101
101
  pollingInterval: 5e3,
102
102
  maxPollingTime: 3e5,
103
103
  onSuccess: (e) => {
104
- e.transactionId && I((t) => t && {
104
+ e.transactionId && it((t) => t && {
105
105
  ...t,
106
106
  transactionId: e.transactionId
107
- }), j("success"), T && nt();
107
+ }), N("success"), E && tt();
108
108
  },
109
109
  onFailure: (e) => {
110
- P(e.failureReason || "Payment failed"), j("error");
110
+ I(e.failureReason || "Payment failed"), N("error");
111
111
  },
112
112
  onTimeout: () => {
113
- P("Payment verification timed out. Please check your billing history for the payment status."), j("error");
113
+ I("Payment verification timed out. Please check your billing history for the payment status."), N("error");
114
114
  }
115
- }), { data: dt, loading: ft } = ee({}), { data: V, loading: pt } = re({
116
- variables: { id: O },
117
- skip: D !== "PLAN" || !O
118
- }), { data: H, loading: mt } = ie({
119
- variables: { addonIDs: O ? [O] : [] },
120
- skip: D !== "ADDON" || !O || E
115
+ }), { data: ft, loading: pt, refetch: mt } = ee({}), { data: V, loading: ht } = re({
116
+ variables: { id: k },
117
+ skip: O !== "PLAN" || !k
118
+ }), { data: H, loading: gt } = ie({
119
+ variables: { addonIDs: k ? [k] : [] },
120
+ skip: O !== "ADDON" || !k || D
121
121
  }), { data: U } = ae({
122
122
  variables: { id: _ },
123
- skip: !E || !_
124
- }), { data: ht, loading: gt } = ne({
125
- variables: { billingAccountId: z.billingAccount?.id },
126
- skip: !z.billingAccount?.id
127
- }), { data: _t, loading: vt } = o({
128
- variables: { billingAccountId: z.billingAccount?.id },
129
- skip: !z.billingAccount?.id || D !== "ADDON" || E
130
- }), W = l(() => _t?.getActiveSubscriptions ?? [], [_t]), G = l(() => !z.selectedSubscriptionId || W.length === 0 ? null : W.find((e) => e.id === z.selectedSubscriptionId) ?? null, [z.selectedSubscriptionId, W]), K = z.items[0]?.type === "CREDITS" ? z.items[0].quantity : 100, { data: q, loading: yt } = te({
123
+ skip: !D || !_
124
+ }), { data: _t, loading: vt } = ne({
125
+ variables: { billingAccountId: B.billingAccount?.id },
126
+ skip: !B.billingAccount?.id
127
+ }), { data: yt, loading: bt } = o({
128
+ variables: { billingAccountId: B.billingAccount?.id },
129
+ skip: !B.billingAccount?.id || O !== "ADDON" || D
130
+ }), W = l(() => yt?.getActiveSubscriptions ?? [], [yt]), G = l(() => !B.selectedSubscriptionId || W.length === 0 ? null : W.find((e) => e.id === B.selectedSubscriptionId) ?? null, [B.selectedSubscriptionId, W]), K = B.items[0]?.type === "CREDITS" ? B.items[0].quantity : 100, { data: q, loading: xt } = te({
131
131
  variables: {
132
132
  creditAmount: K,
133
- currency: z.selectedCurrency || "USD"
133
+ currency: B.selectedCurrency || "USD"
134
134
  },
135
- skip: D !== "CREDITS"
136
- }), J = l(() => q?.getCostOfCredits?.amount && K > 0 ? q.getCostOfCredits.amount / K : .01, [q, K]), Y = l(() => ht?.getPaymentMethods ?? [], [ht]), X = l(() => dt?.getBillingAccountsByOrg ?? [], [dt]), Z = l(() => {
137
- if (!z.billingAccount) return;
138
- let e = X.find((e) => e.id === z.billingAccount?.id)?.billingAddresses;
135
+ skip: O !== "CREDITS"
136
+ }), J = l(() => q?.getCostOfCredits?.amount && K > 0 ? q.getCostOfCredits.amount / K : .01, [q, K]), Y = l(() => _t?.getPaymentMethods ?? [], [_t]), X = l(() => ft?.getBillingAccountsByOrg ?? [], [ft]), Z = l(() => {
137
+ if (!B.billingAccount) return;
138
+ let e = X.find((e) => e.id === B.billingAccount?.id)?.billingAddresses;
139
139
  if (e && e.length > 0) return e[0]?.country || void 0;
140
- }, [z.billingAccount, X]), [bt, xt] = u(null);
140
+ }, [B.billingAccount, X]), [St, Ct] = u(null);
141
141
  c(() => {
142
- if (Z) if (Z === "IN") z.selectedCurrency !== "INR" && z.setCurrency("INR"), B && bt !== Z && z.selectedProvider !== "CREDITS" && (z.setPaymentProvider("RAZORPAY"), xt(Z));
142
+ if (Z) if (Z === "IN") B.selectedCurrency !== "INR" && B.setCurrency("INR"), lt && St !== Z && B.selectedProvider !== "CREDITS" && (B.setPaymentProvider("RAZORPAY"), Ct(Z));
143
143
  else {
144
- if (z.selectedCurrency === "INR") {
145
- let e = z.billingAccount?.currency, t = e && e !== "INR" ? e : "USD";
146
- z.setCurrency(t);
144
+ if (B.selectedCurrency === "INR") {
145
+ let e = B.billingAccount?.currency, t = e && e !== "INR" ? e : "USD";
146
+ B.setCurrency(t);
147
147
  }
148
- z.selectedProvider === "RAZORPAY" && (z.setPaymentProvider("STRIPE"), xt(Z));
148
+ B.selectedProvider === "RAZORPAY" && (B.setPaymentProvider("STRIPE"), Ct(Z));
149
149
  }
150
150
  }, [
151
151
  Z,
152
- z.selectedCurrency,
153
- z.selectedProvider,
154
- z.setCurrency,
155
- z.setPaymentProvider,
156
- z.billingAccount?.currency,
157
- B,
158
- bt
152
+ B.selectedCurrency,
153
+ B.selectedProvider,
154
+ B.setCurrency,
155
+ B.setPaymentProvider,
156
+ B.billingAccount?.currency,
157
+ lt,
158
+ St
159
159
  ]), c(() => {
160
- if (!z.billingAccount?.currency || Z === "IN") return;
161
- let e = z.billingAccount.currency;
162
- e !== "INR" && z.selectedCurrency !== e && z.setCurrency(e);
160
+ if (!B.billingAccount?.currency || Z === "IN") return;
161
+ let e = B.billingAccount.currency;
162
+ e !== "INR" && B.selectedCurrency !== e && B.setCurrency(e);
163
163
  }, [
164
- z.billingAccount?.id,
165
- z.billingAccount?.currency,
164
+ B.billingAccount?.id,
165
+ B.billingAccount?.currency,
166
166
  Z,
167
- z.selectedCurrency,
168
- z.setCurrency
167
+ B.selectedCurrency,
168
+ B.setCurrency
169
169
  ]), c(() => {
170
- if (z.selectedProvider !== "AUTO" && z.selectedProvider !== null) return;
171
- let e = z.availableCredits >= z.total;
172
- if (z.canPayWithCredits && e) {
173
- z.setPaymentProvider("CREDITS"), z.setSelectedPaymentMethodId(null);
170
+ if (B.selectedProvider !== "AUTO" && B.selectedProvider !== null) return;
171
+ let e = B.availableCredits >= B.total;
172
+ if (B.canPayWithCredits && e) {
173
+ B.setPaymentProvider("CREDITS"), B.setSelectedPaymentMethodId(null);
174
174
  return;
175
175
  }
176
- if (Y.length > 0 && !z.selectedPaymentMethodId) {
176
+ if (Y.length > 0 && !B.selectedPaymentMethodId) {
177
177
  let e = Y.find((e) => e.isDefault && e.isVerified), t = Y.find((e) => e.isVerified), n = e || t;
178
178
  if (n) {
179
- z.setSelectedPaymentMethodId(n.id), n.razorpayPaymentMethodId ? z.setPaymentProvider("RAZORPAY") : n.stripePaymentMethodId && z.setPaymentProvider("STRIPE");
179
+ B.setSelectedPaymentMethodId(n.id), n.razorpayPaymentMethodId ? B.setPaymentProvider("RAZORPAY") : n.stripePaymentMethodId && B.setPaymentProvider("STRIPE");
180
180
  return;
181
181
  }
182
182
  }
183
183
  }, [
184
184
  Y.length,
185
- z.canPayWithCredits,
186
- z.availableCredits,
187
- z.total
185
+ B.canPayWithCredits,
186
+ B.availableCredits,
187
+ B.total
188
188
  ]);
189
189
  let [Q, $] = u(!1);
190
190
  c(() => {
191
- if (!E || Q || !U?.getStoreOrder) return;
191
+ if (!D || Q || !U?.getStoreOrder) return;
192
192
  let e = De(U.getStoreOrder.currency);
193
- z.selectedCurrency !== e && z.setCurrency(e);
193
+ B.selectedCurrency !== e && B.setCurrency(e);
194
194
  }, [
195
- E,
195
+ D,
196
196
  Q,
197
197
  U,
198
- z.selectedCurrency,
199
- z.setCurrency
198
+ B.selectedCurrency,
199
+ B.setCurrency
200
200
  ]), c(() => {
201
- if (D === "PLAN" && V?.getPlan?.pricingModel === "PER_SEAT") {
201
+ if (O === "PLAN" && V?.getPlan?.pricingModel === "PER_SEAT") {
202
202
  let e = V.getPlan.minSeats ?? 1;
203
- R((t) => t < e ? e : t);
203
+ z((t) => t < e ? e : t);
204
204
  }
205
- }, [V, D]), c(() => {
206
- D === "PLAN" && V?.getPlan?.pricingModel === "PER_SEAT" && Q && $(!1);
207
- }, [L]), c(() => {
205
+ }, [V, O]), c(() => {
206
+ O === "PLAN" && V?.getPlan?.pricingModel === "PER_SEAT" && Q && $(!1);
207
+ }, [R]), c(() => {
208
208
  if (!Q) {
209
- if (T && w && C.length > 0) {
210
- z.clearItems();
211
- for (let e of C) {
209
+ if (E && T && w.length > 0) {
210
+ B.clearItems();
211
+ for (let e of w) {
212
212
  let t = e.addon, n = t.features?.map((e) => ({
213
213
  id: e.quota?.id || e.id,
214
214
  name: e.quota?.name || "Feature",
215
215
  limits: e.quota?.limits
216
- })) || [], r = z.selectedCurrency || "USD", i = t.currencyPrices?.[r] ?? t.price, a = {
216
+ })) || [], r = B.selectedCurrency || "USD", i = t.currencyPrices?.[r] ?? t.price, a = {
217
217
  id: t.id,
218
218
  type: "ADDON",
219
219
  name: t.name,
@@ -225,25 +225,25 @@ var Ke = () => {
225
225
  features: n,
226
226
  metadata: { addonId: t.id }
227
227
  };
228
- z.addItem(a);
228
+ B.addItem(a);
229
229
  }
230
230
  $(!0);
231
231
  return;
232
232
  }
233
- if (D === "PLAN" && V?.getPlan) {
233
+ if (O === "PLAN" && V?.getPlan) {
234
234
  let e = V.getPlan, t = e.features?.map((e) => ({
235
235
  id: e.quota?.id || e.id,
236
236
  name: e.quota?.name || "Feature",
237
237
  limits: e.quota?.limits
238
- })) || [], n = z.selectedCurrency || "USD", r = e.currencyPrices, i = e.pricingModel === "PER_SEAT", a;
238
+ })) || [], n = B.selectedCurrency || "USD", r = e.currencyPrices, i = e.pricingModel === "PER_SEAT", a;
239
239
  if (i && e.pricePerSeat) {
240
240
  let t = r?.[n];
241
- a = (typeof t == "object" && t?.perSeat ? t.perSeat : e.pricePerSeat) * L;
241
+ a = (typeof t == "object" && t?.perSeat ? t.perSeat : e.pricePerSeat) * R;
242
242
  } else {
243
243
  let t = r?.[n];
244
244
  a = typeof t == "number" ? t : e.price;
245
245
  }
246
- let o = i ? L : 1, ee = {
246
+ let o = i ? R : 1, ee = {
247
247
  id: e.id,
248
248
  type: "PLAN",
249
249
  name: e.name,
@@ -259,13 +259,13 @@ var Ke = () => {
259
259
  seatCount: i ? o : void 0
260
260
  }
261
261
  };
262
- z.addItem(ee), $(!0);
263
- } else if (D === "ADDON" && !T && H?.getSelectedAddons?.[0]) {
262
+ B.addItem(ee), $(!0);
263
+ } else if (O === "ADDON" && !E && H?.getSelectedAddons?.[0]) {
264
264
  let e = H.getSelectedAddons[0], t = e.features?.map((e) => ({
265
265
  id: e.quota?.id || e.id,
266
266
  name: e.quota?.name || "Feature",
267
267
  limits: e.quota?.limits
268
- })) || [], n = z.selectedCurrency || "USD", r = e.currencyPrices?.[n] ?? e.price, i = {
268
+ })) || [], n = B.selectedCurrency || "USD", r = e.currencyPrices?.[n] ?? e.price, i = {
269
269
  id: e.id,
270
270
  type: "ADDON",
271
271
  name: e.name,
@@ -273,254 +273,255 @@ var Ke = () => {
273
273
  price: r,
274
274
  priceUSD: e.price,
275
275
  currency: n,
276
- quantity: y?.quantity ?? 1,
276
+ quantity: b?.quantity ?? 1,
277
277
  features: t,
278
278
  metadata: { addonId: e.id }
279
279
  };
280
- z.addItem(i), $(!0);
281
- } else if (E && U?.getStoreOrder) {
280
+ B.addItem(i), $(!0);
281
+ } else if (D && U?.getStoreOrder) {
282
282
  let e = U.getStoreOrder, t = Ee(e);
283
- for (let e of t) z.addItem(e);
283
+ for (let e of t) B.addItem(e);
284
284
  $(!0);
285
- } else if (D === "CREDITS") {
285
+ } else if (O === "CREDITS") {
286
286
  let e = {
287
287
  id: "credits-purchase",
288
288
  type: "CREDITS",
289
289
  name: "Credits",
290
290
  description: "Purchase credits for your account",
291
291
  price: J,
292
- currency: z.selectedCurrency || "USD",
292
+ currency: B.selectedCurrency || "USD",
293
293
  quantity: 100
294
294
  };
295
- z.addItem(e), $(!0);
295
+ B.addItem(e), $(!0);
296
296
  }
297
297
  }
298
298
  }, [
299
- D,
299
+ O,
300
300
  V,
301
301
  H,
302
302
  U,
303
- z.addItem,
304
- z.clearItems,
305
- y?.quantity,
303
+ B.addItem,
304
+ B.clearItems,
305
+ b?.quantity,
306
306
  Q,
307
- T,
308
307
  E,
309
- C,
308
+ D,
310
309
  w,
310
+ T,
311
311
  J,
312
- z.selectedCurrency
312
+ B.selectedCurrency
313
313
  ]), c(() => {
314
- if (!(!E || !Q || z.conversionRate <= 1)) {
315
- for (let e of z.items) if (e.type === "ORDER" && e.currency !== z.selectedCurrency) {
316
- let t = e.price * z.conversionRate;
317
- z.updateItemPrice(e.id, t, z.selectedCurrency);
314
+ if (!(!D || !Q || B.conversionRate <= 1)) {
315
+ for (let e of B.items) if (e.type === "ORDER" && e.currency !== B.selectedCurrency) {
316
+ let t = e.price * B.conversionRate;
317
+ B.updateItemPrice(e.id, t, B.selectedCurrency);
318
318
  }
319
319
  }
320
320
  }, [
321
- E,
321
+ D,
322
322
  Q,
323
- z.conversionRate,
324
- z.selectedCurrency,
325
- z.updateItemPrice
323
+ B.conversionRate,
324
+ B.selectedCurrency,
325
+ B.updateItemPrice
326
326
  ]), c(() => {
327
- if (D === "CREDITS" && Q && J > 0) {
328
- let e = z.items.find((e) => e.id === "credits-purchase");
329
- e && e.price !== J && z.updateItemPrice("credits-purchase", J);
327
+ if (O === "CREDITS" && Q && J > 0) {
328
+ let e = B.items.find((e) => e.id === "credits-purchase");
329
+ e && e.price !== J && B.updateItemPrice("credits-purchase", J);
330
330
  }
331
331
  }, [
332
- D,
332
+ O,
333
333
  Q,
334
334
  J,
335
- z.items,
336
- z.updateItemPrice
335
+ B.items,
336
+ B.updateItemPrice
337
337
  ]), c(() => {
338
- if (!Q || z.items.length === 0) return;
339
- let e = z.selectedCurrency || "USD";
340
- for (let t of z.items) if (t.type === "PLAN" && V?.getPlan) {
338
+ if (!Q || B.items.length === 0) return;
339
+ let e = B.selectedCurrency || "USD";
340
+ for (let t of B.items) if (t.type === "PLAN" && V?.getPlan) {
341
341
  let n = V.getPlan.currencyPrices?.[e] ?? V.getPlan.price;
342
- (t.price !== n || t.currency !== e) && z.updateItemPrice(t.id, n, e);
342
+ (t.price !== n || t.currency !== e) && B.updateItemPrice(t.id, n, e);
343
343
  } else if (t.type === "ADDON") {
344
- if (!T && H?.getSelectedAddons?.[0]) {
344
+ if (!E && H?.getSelectedAddons?.[0]) {
345
345
  let n = H.getSelectedAddons[0], r = n.currencyPrices?.[e] ?? n.price;
346
- (t.price !== r || t.currency !== e) && z.updateItemPrice(t.id, r, e);
346
+ (t.price !== r || t.currency !== e) && B.updateItemPrice(t.id, r, e);
347
347
  }
348
- if (T) {
349
- let n = C.find((e) => e.addon.id === t.id);
348
+ if (E) {
349
+ let n = w.find((e) => e.addon.id === t.id);
350
350
  if (n) {
351
351
  let r = n.addon.currencyPrices?.[e] ?? n.addon.price;
352
- (t.price !== r || t.currency !== e) && z.updateItemPrice(t.id, r, e);
352
+ (t.price !== r || t.currency !== e) && B.updateItemPrice(t.id, r, e);
353
353
  }
354
354
  }
355
355
  }
356
356
  }, [
357
- z.selectedCurrency,
357
+ B.selectedCurrency,
358
358
  Q,
359
- z.items,
360
- z.updateItemPrice,
359
+ B.items,
360
+ B.updateItemPrice,
361
361
  V,
362
362
  H,
363
- C,
364
- T
363
+ w,
364
+ E
365
365
  ]), c(() => {
366
- if (X.length > 0 && !z.billingAccount) {
367
- if (y?.billingAccountId) {
368
- let e = X.find((e) => e.id === y.billingAccountId);
366
+ if (X.length > 0 && !B.billingAccount) {
367
+ if (b?.billingAccountId) {
368
+ let e = X.find((e) => e.id === b.billingAccountId);
369
369
  if (e) {
370
- z.setBillingAccount(e);
370
+ B.setBillingAccount(e);
371
371
  return;
372
372
  }
373
373
  }
374
- if (x) {
375
- let e = i(x);
374
+ if (S) {
375
+ let e = i(S);
376
376
  if (e) {
377
377
  let t = X.find((t) => t.id === e);
378
378
  if (t) {
379
- z.setBillingAccount(t);
379
+ B.setBillingAccount(t);
380
380
  return;
381
381
  }
382
382
  }
383
383
  }
384
- z.setBillingAccount(X[0]);
384
+ B.setBillingAccount(X[0]);
385
385
  }
386
386
  }, [
387
387
  X,
388
- z.billingAccount,
389
- z.setBillingAccount,
390
- y?.billingAccountId,
391
- x
388
+ B.billingAccount,
389
+ B.setBillingAccount,
390
+ b?.billingAccountId,
391
+ S
392
392
  ]);
393
- let St = !!(y?.upgradeFromSubscriptionId || y?.downgradeFromSubscriptionId);
393
+ let wt = !!(b?.upgradeFromSubscriptionId || b?.downgradeFromSubscriptionId);
394
394
  c(() => {
395
- T && w && C.length === 0 && !Q && v("/addons", { replace: !0 });
395
+ E && T && w.length === 0 && !Q && v("/addons", { replace: !0 });
396
396
  }, [
397
- w,
398
- C.length,
399
397
  T,
398
+ w.length,
399
+ E,
400
400
  Q,
401
401
  v
402
402
  ]);
403
- let Ct = de({
404
- billingAccountId: z.billingAccount?.id,
405
- purchaseType: D,
406
- productId: O
407
- }), wt = s(async () => {
408
- if (!z.billingAccount) return;
409
- if (!Te(z.billingAccount)) {
410
- k(!0);
403
+ let Tt = de({
404
+ billingAccountId: B.billingAccount?.id,
405
+ purchaseType: O,
406
+ productId: k
407
+ }), Et = s(async () => {
408
+ if (!B.billingAccount) return;
409
+ let e = j.current;
410
+ if (j.current = !1, !e && !Te(B.billingAccount)) {
411
+ A(!0);
411
412
  return;
412
413
  }
413
- P(null);
414
- let e = z.billingAccount.creditAmount ?? 0, t = [...z.items], n = z.total, r = await z.initiatePayment();
415
- if (r.success) {
416
- if (b("billing.checkout.initiated", {
414
+ I(null);
415
+ let t = B.billingAccount.creditAmount ?? 0, n = [...B.items], r = B.total, i = await B.initiatePayment();
416
+ if (i.success) {
417
+ if (x("billing.checkout.initiated", {
417
418
  route: "/billing/checkout",
418
- entityId: r.paymentId ?? r.orderId,
419
+ entityId: i.paymentId ?? i.orderId,
419
420
  source: "checkout",
420
- amount: r.total || n,
421
- currency: r.currency || z.selectedCurrency
422
- }), z.selectedProvider === "CREDITS") {
423
- b("billing.credits.spent", {
421
+ amount: i.total || r,
422
+ currency: i.currency || B.selectedCurrency
423
+ }), B.selectedProvider === "CREDITS") {
424
+ x("billing.credits.spent", {
424
425
  route: "/billing/checkout",
425
- entityId: r.orderId,
426
+ entityId: i.orderId,
426
427
  source: "checkout",
427
- amount: n,
428
+ amount: r,
428
429
  currency: "CREDITS"
429
- }), I({
430
- items: t,
431
- total: n,
432
- billingAccountName: z.billingAccount.name,
433
- billingAccountId: z.billingAccount.id,
434
- previousBalance: e,
435
- newBalance: e - n,
430
+ }), it({
431
+ items: n,
432
+ total: r,
433
+ billingAccountName: B.billingAccount.name,
434
+ billingAccountId: B.billingAccount.id,
435
+ previousBalance: t,
436
+ newBalance: t - r,
436
437
  paymentMethod: "credits",
437
438
  currency: "Credits",
438
- transactionId: r.orderId
439
- }), ot("credits"), N({ paymentId: r.orderId }), j("processing");
439
+ transactionId: i.orderId
440
+ }), ot("credits"), F({ paymentId: i.orderId }), N("processing");
440
441
  return;
441
442
  }
442
- I({
443
- items: t,
444
- total: r.total || n,
445
- billingAccountName: z.billingAccount.name,
446
- billingAccountId: z.billingAccount.id,
447
- previousBalance: e,
448
- newBalance: e,
443
+ it({
444
+ items: n,
445
+ total: i.total || r,
446
+ billingAccountName: B.billingAccount.name,
447
+ billingAccountId: B.billingAccount.id,
448
+ previousBalance: t,
449
+ newBalance: t,
449
450
  paymentMethod: "card",
450
- currency: r.currency || z.selectedCurrency,
451
- transactionId: r.paymentId
452
- }), ot("card"), N({
453
- clientSecret: r.clientSecret,
454
- orderId: r.orderId,
455
- razorpayKeyId: r.razorpayKeyId,
456
- razorpayCustomerId: r.razorpayCustomerId,
457
- paymentId: r.paymentId,
458
- paymentComplete: r.paymentComplete,
459
- prefillName: r.prefillName,
460
- prefillEmail: r.prefillEmail,
461
- prefillContact: r.prefillContact,
462
- total: r.total,
463
- currency: r.currency
464
- }), r.paymentComplete ? j("processing") : j("payment");
465
- } else b("billing.checkout.failed", {
451
+ currency: i.currency || B.selectedCurrency,
452
+ transactionId: i.paymentId
453
+ }), ot("card"), F({
454
+ clientSecret: i.clientSecret,
455
+ orderId: i.orderId,
456
+ razorpayKeyId: i.razorpayKeyId,
457
+ razorpayCustomerId: i.razorpayCustomerId,
458
+ paymentId: i.paymentId,
459
+ paymentComplete: i.paymentComplete,
460
+ prefillName: i.prefillName,
461
+ prefillEmail: i.prefillEmail,
462
+ prefillContact: i.prefillContact,
463
+ total: i.total,
464
+ currency: i.currency
465
+ }), i.paymentComplete ? N("processing") : N("payment");
466
+ } else x("billing.checkout.failed", {
466
467
  route: "/billing/checkout",
467
468
  source: "checkout",
468
- reason: r.error || "Payment initiation failed"
469
- }), P(r.error || "Payment initiation failed"), j("error");
470
- }, [z, b]), Tt = s((e) => {
471
- b("billing.payment.succeeded", {
469
+ reason: i.error || "Payment initiation failed"
470
+ }), I(i.error || "Payment initiation failed"), N("error");
471
+ }, [B, x]), Dt = s((e) => {
472
+ x("billing.payment.succeeded", {
472
473
  route: "/billing/checkout",
473
- entityId: M?.paymentId ?? M?.orderId,
474
+ entityId: P?.paymentId ?? P?.orderId,
474
475
  source: "checkout"
475
- }), N((e) => e), j("processing");
476
+ }), F((e) => e), N("processing");
476
477
  }, [
477
- b,
478
- M?.orderId,
479
- M?.paymentId
480
- ]), Et = s((e) => {
481
- b("billing.payment.failed", {
478
+ x,
479
+ P?.orderId,
480
+ P?.paymentId
481
+ ]), Ot = s((e) => {
482
+ x("billing.payment.failed", {
482
483
  route: "/billing/checkout",
483
- entityId: M?.paymentId ?? M?.orderId,
484
+ entityId: P?.paymentId ?? P?.orderId,
484
485
  source: "checkout",
485
486
  reason: e
486
- }), P(e), j("error");
487
+ }), I(e), N("error");
487
488
  }, [
488
- b,
489
- M?.orderId,
490
- M?.paymentId
491
- ]), Dt = s((e) => {
492
- z.updateItemQuantity("credits-purchase", e);
493
- }, [z]);
494
- if (!Ye.canProcessPayment) return /* @__PURE__ */ p(t, { message: "You don't have permission to make purchases." });
489
+ x,
490
+ P?.orderId,
491
+ P?.paymentId
492
+ ]), kt = s((e) => {
493
+ B.updateItemQuantity("credits-purchase", e);
494
+ }, [B]);
495
+ if (!Je.canProcessPayment) return /* @__PURE__ */ p(t, { message: "You don't have permission to make purchases." });
495
496
  if (ue()) return /* @__PURE__ */ p(me, {
496
- purchaseType: D,
497
- productId: O,
498
- billingAccountId: z.billingAccount?.id,
499
- nativeCheckout: Ct,
497
+ purchaseType: O,
498
+ productId: k,
499
+ billingAccountId: B.billingAccount?.id,
500
+ nativeCheckout: Tt,
500
501
  onBack: () => v("dashboard")
501
502
  });
502
- let Ot = ft || pt && D === "PLAN" || mt && D === "ADDON" && !T || T && !w;
503
- if (T && w && C.length === 0 && !Q) return null;
504
- let kt = () => {
505
- if (T) {
506
- let e = z.items.length;
503
+ let At = pt || ht && O === "PLAN" || gt && O === "ADDON" && !E || E && !T;
504
+ if (E && T && w.length === 0 && !Q) return null;
505
+ let jt = () => {
506
+ if (E) {
507
+ let e = B.items.length;
507
508
  return `Purchase ${e} Add-on${e === 1 ? "" : "s"}`;
508
509
  }
509
- switch (D) {
510
+ switch (O) {
510
511
  case "CREDITS": return "Buy Credits";
511
512
  case "PLAN": return "Subscribe to Plan";
512
513
  case "ADDON": return "Purchase Add-on";
513
514
  default: return "Checkout";
514
515
  }
515
- }, At = () => {
516
- switch (D) {
516
+ }, Mt = () => {
517
+ switch (O) {
517
518
  case "CREDITS": return /* @__PURE__ */ p(Ne, { className: "size-6" });
518
519
  case "PLAN": return /* @__PURE__ */ p(Fe, { className: "size-6" });
519
520
  case "ADDON": return /* @__PURE__ */ p(je, { className: "size-6" });
520
521
  default: return /* @__PURE__ */ p(Re, { className: "size-6" });
521
522
  }
522
523
  };
523
- if (Ot) return /* @__PURE__ */ p("div", {
524
+ if (At) return /* @__PURE__ */ p("div", {
524
525
  className: "flex items-center justify-center min-h-[400px]",
525
526
  children: /* @__PURE__ */ m("div", {
526
527
  className: "text-center space-y-4",
@@ -530,10 +531,10 @@ var Ke = () => {
530
531
  })]
531
532
  })
532
533
  });
533
- if (A === "success") {
534
+ if (M === "success") {
534
535
  let e = (e) => {
535
- if (!F) return `${e.toFixed(2)}`;
536
- let t = F.currency;
536
+ if (!L) return `${e.toFixed(2)}`;
537
+ let t = L.currency;
537
538
  return t === "Credits" ? `${e.toFixed(2)} Credits` : `${{
538
539
  INR: "₹",
539
540
  USD: "$",
@@ -557,7 +558,7 @@ var Ke = () => {
557
558
  children: h("billing.checkout.purchaseCompleted", "Your purchase has been completed successfully.")
558
559
  })] })]
559
560
  }),
560
- F && /* @__PURE__ */ m("div", {
561
+ L && /* @__PURE__ */ m("div", {
561
562
  className: "bg-card border border-border rounded-lg overflow-hidden",
562
563
  children: [
563
564
  /* @__PURE__ */ m("div", {
@@ -567,7 +568,7 @@ var Ke = () => {
567
568
  children: [/* @__PURE__ */ p(Ie, { className: "size-4" }), h("billing.checkout.itemsPurchased", "Items Purchased")]
568
569
  }), /* @__PURE__ */ p("div", {
569
570
  className: "space-y-2",
570
- children: F.items.map((t) => /* @__PURE__ */ m("div", {
571
+ children: L.items.map((t) => /* @__PURE__ */ m("div", {
571
572
  className: "flex items-center justify-between",
572
573
  children: [/* @__PURE__ */ m("div", {
573
574
  className: "flex items-center gap-2",
@@ -601,7 +602,7 @@ var Ke = () => {
601
602
  children: h("billing.checkout.paymentMethod", "Payment Method")
602
603
  }), /* @__PURE__ */ p("div", {
603
604
  className: "flex items-center gap-2",
604
- children: F.paymentMethod === "credits" ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(ze, { className: "size-4 text-status-warning-text" }), /* @__PURE__ */ p("span", {
605
+ children: L.paymentMethod === "credits" ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(ze, { className: "size-4 text-status-warning-text" }), /* @__PURE__ */ p("span", {
605
606
  className: "font-medium text-foreground",
606
607
  children: h("billing.checkout.credits", "Credits")
607
608
  })] }) : /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(Pe, { className: "size-4 text-accent-blue" }), /* @__PURE__ */ p("span", {
@@ -615,12 +616,12 @@ var Ke = () => {
615
616
  children: h("billing.checkout.totalPaid", "Total Paid")
616
617
  }), /* @__PURE__ */ p("p", {
617
618
  className: "font-bold text-lg text-foreground",
618
- children: e(F.total)
619
+ children: e(L.total)
619
620
  })]
620
621
  })]
621
622
  })
622
623
  }),
623
- F.paymentMethod === "credits" && /* @__PURE__ */ m("div", {
624
+ L.paymentMethod === "credits" && /* @__PURE__ */ m("div", {
624
625
  className: "p-4 border-b border-border",
625
626
  children: [/* @__PURE__ */ m("h3", {
626
627
  className: "font-semibold text-foreground mb-3 flex items-center gap-2",
@@ -635,7 +636,7 @@ var Ke = () => {
635
636
  children: h("billing.checkout.previousBalance", "Previous Balance")
636
637
  }), /* @__PURE__ */ p("p", {
637
638
  className: "font-semibold text-foreground",
638
- children: t(F.previousBalance)
639
+ children: t(L.previousBalance)
639
640
  })]
640
641
  }),
641
642
  /* @__PURE__ */ p(Ae, { className: "size-5 text-muted-foreground shrink-0" }),
@@ -646,7 +647,7 @@ var Ke = () => {
646
647
  children: h("billing.checkout.newBalance", "New Balance")
647
648
  }), /* @__PURE__ */ p("p", {
648
649
  className: "font-semibold text-status-success-text",
649
- children: t(F.newBalance)
650
+ children: t(L.newBalance)
650
651
  })]
651
652
  })
652
653
  ]
@@ -661,15 +662,15 @@ var Ke = () => {
661
662
  children: h("billing.checkout.billingAccount", "Billing Account")
662
663
  }), /* @__PURE__ */ p("p", {
663
664
  className: "font-medium text-foreground",
664
- children: F.billingAccountName
665
- })] }), F.transactionId && /* @__PURE__ */ m("div", {
665
+ children: L.billingAccountName
666
+ })] }), L.transactionId && /* @__PURE__ */ m("div", {
666
667
  className: "text-right",
667
668
  children: [/* @__PURE__ */ p("p", {
668
669
  className: "text-xs text-muted-foreground mb-1",
669
670
  children: h("billing.checkout.transactionId", "Transaction ID")
670
671
  }), /* @__PURE__ */ m("p", {
671
672
  className: "font-mono text-xs text-muted-foreground",
672
- children: [F.transactionId.slice(0, 8), "..."]
673
+ children: [L.transactionId.slice(0, 8), "..."]
673
674
  })]
674
675
  })]
675
676
  })
@@ -693,7 +694,7 @@ var Ke = () => {
693
694
  ]
694
695
  });
695
696
  }
696
- if (A === "error") return /* @__PURE__ */ p("div", {
697
+ if (M === "error") return /* @__PURE__ */ p("div", {
697
698
  className: "max-w-lg mx-auto p-6",
698
699
  children: /* @__PURE__ */ m("div", {
699
700
  className: "text-center space-y-6",
@@ -707,7 +708,7 @@ var Ke = () => {
707
708
  children: h("billing.checkout.paymentFailed", "Payment Failed")
708
709
  }), /* @__PURE__ */ p("p", {
709
710
  className: "text-muted-foreground mt-2",
710
- children: it || ut || z.error || h("billing.checkout.genericError", "Something went wrong. Please try again.")
711
+ children: rt || dt || B.error || h("billing.checkout.genericError", "Something went wrong. Please try again.")
711
712
  })] }),
712
713
  /* @__PURE__ */ m("div", {
713
714
  className: "flex gap-3 justify-center",
@@ -719,7 +720,7 @@ var Ke = () => {
719
720
  }), /* @__PURE__ */ p("button", {
720
721
  type: "button",
721
722
  onClick: () => {
722
- j("select"), P(null), z.reset();
723
+ N("select"), I(null), B.reset();
723
724
  },
724
725
  className: "px-4 py-2 rounded-lg bg-primary text-primary-foreground hover:bg-primary/90",
725
726
  children: h("billing.checkout.tryAgain", "Try Again")
@@ -728,7 +729,7 @@ var Ke = () => {
728
729
  ]
729
730
  })
730
731
  });
731
- if (A === "processing") return /* @__PURE__ */ p("div", {
732
+ if (M === "processing") return /* @__PURE__ */ p("div", {
732
733
  className: "max-w-lg mx-auto p-6",
733
734
  children: /* @__PURE__ */ m("div", {
734
735
  className: "text-center space-y-6",
@@ -756,7 +757,7 @@ var Ke = () => {
756
757
  children: ((e) => {
757
758
  let t = Math.floor(e / 1e3);
758
759
  return `${Math.floor(t / 60)}:${(t % 60).toString().padStart(2, "0")}`;
759
- })(lt)
760
+ })(ut)
760
761
  })
761
762
  ]
762
763
  }), /* @__PURE__ */ p("p", {
@@ -768,13 +769,13 @@ var Ke = () => {
768
769
  className: "w-full bg-muted rounded-full h-2 overflow-hidden",
769
770
  children: /* @__PURE__ */ p("div", {
770
771
  className: "bg-primary h-2 rounded-full transition-all duration-1000",
771
- style: { width: `${Math.min(lt / 3e5 * 100, 100)}%` }
772
+ style: { width: `${Math.min(ut / 3e5 * 100, 100)}%` }
772
773
  })
773
774
  }),
774
- lt > 3e4 && /* @__PURE__ */ p("button", {
775
+ ut > 3e4 && /* @__PURE__ */ p("button", {
775
776
  type: "button",
776
777
  onClick: () => {
777
- j("error"), P("Payment verification was cancelled. Please check your billing history.");
778
+ N("error"), I("Payment verification was cancelled. Please check your billing history.");
778
779
  },
779
780
  className: "text-sm text-muted-foreground hover:text-foreground underline",
780
781
  children: h("billing.checkout.cancelAndCheckHistory", "Cancel and check billing history")
@@ -782,19 +783,19 @@ var Ke = () => {
782
783
  ]
783
784
  })
784
785
  });
785
- if (A === "payment" && M) {
786
+ if (M === "payment" && P) {
786
787
  let e = (e, t) => `${{
787
788
  INR: "₹",
788
789
  USD: "$",
789
790
  EUR: "€",
790
791
  GBP: "£"
791
- }[t] || t + " "}${e.toFixed(2)}`, t = M.currency || z.selectedCurrency, r = M.total ?? z.total;
792
+ }[t] || t + " "}${e.toFixed(2)}`, t = P.currency || B.selectedCurrency, r = P.total ?? B.total;
792
793
  return /* @__PURE__ */ m("div", {
793
794
  className: "max-w-2xl mx-auto p-4 sm:p-6 space-y-6",
794
795
  children: [
795
796
  /* @__PURE__ */ m("button", {
796
797
  type: "button",
797
- onClick: () => j("select"),
798
+ onClick: () => N("select"),
798
799
  className: "flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground",
799
800
  children: [/* @__PURE__ */ p(ke, { className: "size-4" }), h("billing.checkout.backToCheckout", "Back to checkout")]
800
801
  }),
@@ -809,7 +810,7 @@ var Ke = () => {
809
810
  className: "font-semibold text-foreground flex items-center gap-2",
810
811
  children: [/* @__PURE__ */ p(Ie, { className: "size-4" }), h("billing.checkout.paymentSummary", "Payment Summary")]
811
812
  }),
812
- z.billingAccount && /* @__PURE__ */ m("div", {
813
+ B.billingAccount && /* @__PURE__ */ m("div", {
813
814
  className: "p-3 bg-muted/30 rounded-lg space-y-1",
814
815
  children: [
815
816
  /* @__PURE__ */ p("div", {
@@ -818,15 +819,15 @@ var Ke = () => {
818
819
  }),
819
820
  /* @__PURE__ */ p("div", {
820
821
  className: "font-medium text-foreground",
821
- children: z.billingAccount.name
822
+ children: B.billingAccount.name
822
823
  }),
823
824
  /* @__PURE__ */ p("div", {
824
825
  className: "text-sm text-muted-foreground",
825
- children: z.billingAccount.email
826
+ children: B.billingAccount.email
826
827
  })
827
828
  ]
828
829
  }),
829
- D === "ADDON" && z.selectedSubscriptionId && G && /* @__PURE__ */ m("div", {
830
+ O === "ADDON" && B.selectedSubscriptionId && G && /* @__PURE__ */ m("div", {
830
831
  className: "p-3 bg-muted/30 rounded-lg space-y-1",
831
832
  children: [
832
833
  /* @__PURE__ */ p("div", {
@@ -847,7 +848,7 @@ var Ke = () => {
847
848
  className: "space-y-2 text-sm",
848
849
  children: [
849
850
  (() => {
850
- let n = z.taxRate, i = n > 0 ? r / (1 + n) : r, a = n > 0 ? r - i : 0;
851
+ let n = B.taxRate, i = n > 0 ? r / (1 + n) : r, a = n > 0 ? r - i : 0;
851
852
  return /* @__PURE__ */ m(f, { children: [
852
853
  /* @__PURE__ */ m("div", {
853
854
  className: "flex justify-between",
@@ -859,16 +860,16 @@ var Ke = () => {
859
860
  children: e(i, t)
860
861
  })]
861
862
  }),
862
- z.discountAmount > 0 && /* @__PURE__ */ m("div", {
863
+ B.discountAmount > 0 && /* @__PURE__ */ m("div", {
863
864
  className: "flex justify-between text-status-success-text",
864
- children: [/* @__PURE__ */ p("span", { children: h("billing.checkout.discount", "Discount") }), /* @__PURE__ */ m("span", { children: ["-", e(z.discountAmount, t)] })]
865
+ children: [/* @__PURE__ */ p("span", { children: h("billing.checkout.discount", "Discount") }), /* @__PURE__ */ m("span", { children: ["-", e(B.discountAmount, t)] })]
865
866
  }),
866
867
  a > 0 && /* @__PURE__ */ m("div", {
867
868
  className: "flex justify-between",
868
869
  children: [/* @__PURE__ */ m("span", {
869
870
  className: "text-muted-foreground",
870
871
  children: [
871
- z.taxType || h("billing.checkout.tax", "Tax"),
872
+ B.taxType || h("billing.checkout.tax", "Tax"),
872
873
  " (",
873
874
  (n * 100).toFixed(0),
874
875
  "%)"
@@ -895,23 +896,23 @@ var Ke = () => {
895
896
  })
896
897
  ]
897
898
  }),
898
- z.selectedProvider === "STRIPE" && M.clientSecret && /* @__PURE__ */ p("div", {
899
+ B.selectedProvider === "STRIPE" && P.clientSecret && /* @__PURE__ */ p("div", {
899
900
  className: "rounded-lg border border-border bg-card overflow-hidden",
900
901
  children: /* @__PURE__ */ p("div", {
901
902
  className: "p-4 space-y-4",
902
903
  children: /* @__PURE__ */ p(ye, {
903
- clientSecret: M.clientSecret,
904
- publishableKey: Xe || st?.stripePublishableKey || "",
905
- amount: Math.round((M.total ?? z.total) * 100),
906
- currency: M.currency || z.selectedCurrency,
907
- onSuccess: Tt,
908
- onError: Et,
909
- onCancel: () => j("select"),
910
- isCompletingExistingPayment: !!z.selectedPaymentMethodId
904
+ clientSecret: P.clientSecret,
905
+ publishableKey: Ye || st?.stripePublishableKey || "",
906
+ amount: Math.round((P.total ?? B.total) * 100),
907
+ currency: P.currency || B.selectedCurrency,
908
+ onSuccess: Dt,
909
+ onError: Ot,
910
+ onCancel: () => N("select"),
911
+ isCompletingExistingPayment: !!B.selectedPaymentMethodId
911
912
  })
912
913
  })
913
914
  }),
914
- z.selectedProvider === "RAZORPAY" && M.orderId && /* @__PURE__ */ p("div", {
915
+ B.selectedProvider === "RAZORPAY" && P.orderId && /* @__PURE__ */ p("div", {
915
916
  className: "rounded-lg border border-border bg-card overflow-hidden",
916
917
  children: /* @__PURE__ */ m("div", {
917
918
  className: "p-4 space-y-4",
@@ -919,27 +920,27 @@ var Ke = () => {
919
920
  className: "flex items-center gap-2 cursor-pointer",
920
921
  children: [/* @__PURE__ */ p("input", {
921
922
  type: "checkbox",
922
- checked: z.saveCard,
923
- onChange: (e) => z.setSaveCard(e.target.checked),
923
+ checked: B.saveCard,
924
+ onChange: (e) => B.setSaveCard(e.target.checked),
924
925
  className: "size-4 rounded border-border text-primary focus:ring-primary"
925
926
  }), /* @__PURE__ */ p("span", {
926
927
  className: "text-sm text-muted-foreground",
927
928
  children: "Save card for future purchases"
928
929
  })]
929
930
  }), /* @__PURE__ */ p(be, {
930
- orderId: M.orderId,
931
- keyId: M.razorpayKeyId || Ze || "",
932
- amount: Math.round((M.total ?? z.total) * 100),
933
- currency: M.currency || "INR",
934
- customerId: M.razorpayCustomerId,
931
+ orderId: P.orderId,
932
+ keyId: P.razorpayKeyId || Xe || "",
933
+ amount: Math.round((P.total ?? B.total) * 100),
934
+ currency: P.currency || "INR",
935
+ customerId: P.razorpayCustomerId,
935
936
  prefill: {
936
- name: M.prefillName,
937
- email: M.prefillEmail,
938
- contact: M.prefillContact
937
+ name: P.prefillName,
938
+ email: P.prefillEmail,
939
+ contact: P.prefillContact
939
940
  },
940
- onSuccess: (e) => Tt(e.razorpay_payment_id),
941
- onError: Et,
942
- onCancel: () => j("select")
941
+ onSuccess: (e) => Dt(e.razorpay_payment_id),
942
+ onError: Ot,
943
+ onCancel: () => N("select")
943
944
  })]
944
945
  })
945
946
  })
@@ -959,16 +960,16 @@ var Ke = () => {
959
960
  className: "flex items-center gap-3 mb-6",
960
961
  children: [/* @__PURE__ */ p("div", {
961
962
  className: "p-2 rounded-lg bg-primary/10 text-primary",
962
- children: At()
963
+ children: Mt()
963
964
  }), /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("h1", {
964
965
  className: "text-2xl font-bold text-foreground",
965
- children: kt()
966
+ children: jt()
966
967
  }), /* @__PURE__ */ p("p", {
967
968
  className: "text-sm text-muted-foreground",
968
969
  children: "Complete your purchase securely"
969
970
  })] })]
970
971
  }),
971
- y?.upgradeFromSubscriptionId && y?.currentPlanName && /* @__PURE__ */ p("div", {
972
+ b?.upgradeFromSubscriptionId && b?.currentPlanName && /* @__PURE__ */ p("div", {
972
973
  className: "mb-6 p-4 rounded-lg border border-border-subtle bg-status-info-bg-subtle",
973
974
  children: /* @__PURE__ */ m("div", {
974
975
  className: "flex items-center gap-3",
@@ -984,7 +985,7 @@ var Ke = () => {
984
985
  " ",
985
986
  /* @__PURE__ */ p("span", {
986
987
  className: "font-semibold",
987
- children: y.currentPlanName
988
+ children: b.currentPlanName
988
989
  })
989
990
  ]
990
991
  }), /* @__PURE__ */ p("p", {
@@ -994,7 +995,7 @@ var Ke = () => {
994
995
  })]
995
996
  })
996
997
  }),
997
- y?.downgradeFromSubscriptionId && y?.currentPlanName && /* @__PURE__ */ p("div", {
998
+ b?.downgradeFromSubscriptionId && b?.currentPlanName && /* @__PURE__ */ p("div", {
998
999
  className: "mb-6 p-4 rounded-lg border border-status-warning-border bg-status-warning-bg-subtle",
999
1000
  children: /* @__PURE__ */ m("div", {
1000
1001
  className: "flex items-center gap-3",
@@ -1010,7 +1011,7 @@ var Ke = () => {
1010
1011
  " ",
1011
1012
  /* @__PURE__ */ p("span", {
1012
1013
  className: "font-semibold",
1013
- children: y.currentPlanName
1014
+ children: b.currentPlanName
1014
1015
  })
1015
1016
  ]
1016
1017
  }), /* @__PURE__ */ p("p", {
@@ -1025,30 +1026,30 @@ var Ke = () => {
1025
1026
  children: [/* @__PURE__ */ m("div", {
1026
1027
  className: "lg:col-span-3 space-y-6 order-2 lg:order-1",
1027
1028
  children: [
1028
- D === "CREDITS" && z.items[0] && /* @__PURE__ */ p("div", {
1029
+ O === "CREDITS" && B.items[0] && /* @__PURE__ */ p("div", {
1029
1030
  className: "rounded-lg border border-border bg-card p-4 sm:p-6",
1030
1031
  children: /* @__PURE__ */ p(ve, {
1031
- value: z.items[0].quantity,
1032
- onChange: Dt,
1032
+ value: B.items[0].quantity,
1033
+ onChange: kt,
1033
1034
  costPerCredit: J,
1034
- currency: z.selectedCurrency,
1035
- disabled: yt
1035
+ currency: B.selectedCurrency,
1036
+ disabled: xt
1036
1037
  })
1037
1038
  }),
1038
1039
  /* @__PURE__ */ m("div", {
1039
1040
  className: "rounded-lg border border-border bg-card p-4 sm:p-6 space-y-4",
1040
1041
  children: [/* @__PURE__ */ p(he, {
1041
1042
  accounts: X,
1042
- selectedAccountId: z.billingAccount?.id ?? null,
1043
- onSelect: z.setBillingAccount,
1044
- isLoading: ft,
1045
- disabled: St,
1046
- disabledMessage: St ? "Billing account is locked for plan changes" : void 0
1047
- }), D === "ADDON" && !E && z.billingAccount && /* @__PURE__ */ p(xe, {
1043
+ selectedAccountId: B.billingAccount?.id ?? null,
1044
+ onSelect: B.setBillingAccount,
1045
+ isLoading: pt,
1046
+ disabled: wt,
1047
+ disabledMessage: wt ? "Billing account is locked for plan changes" : void 0
1048
+ }), O === "ADDON" && !D && B.billingAccount && /* @__PURE__ */ p(xe, {
1048
1049
  subscriptions: W,
1049
- selectedSubscriptionId: z.selectedSubscriptionId,
1050
- onSelect: z.setSelectedSubscriptionId,
1051
- isLoading: vt
1050
+ selectedSubscriptionId: B.selectedSubscriptionId,
1051
+ onSelect: B.setSelectedSubscriptionId,
1052
+ isLoading: bt
1052
1053
  })]
1053
1054
  }),
1054
1055
  /* @__PURE__ */ m("div", {
@@ -1056,22 +1057,22 @@ var Ke = () => {
1056
1057
  children: [
1057
1058
  /* @__PURE__ */ p(Ce, {
1058
1059
  savedPaymentMethods: Y,
1059
- selectedPaymentMethodId: z.selectedPaymentMethodId,
1060
- onSelectSavedCard: z.setSelectedPaymentMethodId,
1061
- selectedProvider: z.selectedProvider,
1062
- onSelectProvider: z.setPaymentProvider,
1060
+ selectedPaymentMethodId: B.selectedPaymentMethodId,
1061
+ onSelectSavedCard: B.setSelectedPaymentMethodId,
1062
+ selectedProvider: B.selectedProvider,
1063
+ onSelectProvider: B.setPaymentProvider,
1063
1064
  stripeEnabled: ct,
1064
- razorpayEnabled: B,
1065
- canPayWithCredits: z.canPayWithCredits && z.hasEnoughCredits,
1066
- availableCredits: z.availableCredits,
1067
- totalAmount: z.subtotalUSD,
1065
+ razorpayEnabled: lt,
1066
+ canPayWithCredits: B.canPayWithCredits && B.hasEnoughCredits,
1067
+ availableCredits: B.availableCredits,
1068
+ totalAmount: B.subtotalUSD,
1068
1069
  billingCountry: Z,
1069
- saveCard: z.saveCard,
1070
- onSaveCardChange: z.setSaveCard,
1071
- autoRenewEnabled: D === "PLAN" && z.autoRenew,
1072
- isLoading: gt
1070
+ saveCard: B.saveCard,
1071
+ onSaveCardChange: B.setSaveCard,
1072
+ autoRenewEnabled: O === "PLAN" && B.autoRenew,
1073
+ isLoading: vt
1073
1074
  }),
1074
- z.selectedProvider !== "CREDITS" && z.selectedProvider !== "AUTO" && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("div", { className: "border-t border-border" }), /* @__PURE__ */ p("div", {
1075
+ B.selectedProvider !== "CREDITS" && B.selectedProvider !== "AUTO" && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("div", { className: "border-t border-border" }), /* @__PURE__ */ p("div", {
1075
1076
  className: "bg-muted/50 p-4 rounded-md",
1076
1077
  children: /* @__PURE__ */ m("div", {
1077
1078
  className: "flex items-start gap-3",
@@ -1090,7 +1091,7 @@ var Ke = () => {
1090
1091
  className: "flex-1 text-sm",
1091
1092
  children: [/* @__PURE__ */ m("p", {
1092
1093
  className: "font-medium text-foreground mb-1",
1093
- children: ["Currency: ", z.selectedCurrency]
1094
+ children: ["Currency: ", B.selectedCurrency]
1094
1095
  }), /* @__PURE__ */ m("p", {
1095
1096
  className: "text-muted-foreground text-xs",
1096
1097
  children: [
@@ -1098,17 +1099,17 @@ var Ke = () => {
1098
1099
  " ",
1099
1100
  /* @__PURE__ */ p("strong", {
1100
1101
  className: "text-foreground",
1101
- children: z.selectedCurrency
1102
+ children: B.selectedCurrency
1102
1103
  }),
1103
1104
  " ",
1104
1105
  "based on your billing account settings.",
1105
- z.selectedCurrency === "INR" && " GST will be applied at checkout."
1106
+ B.selectedCurrency === "INR" && " GST will be applied at checkout."
1106
1107
  ]
1107
1108
  })]
1108
1109
  })]
1109
1110
  })
1110
1111
  })] }),
1111
- D === "PLAN" && V?.getPlan?.pricingModel === "PER_SEAT" && /* @__PURE__ */ p("div", {
1112
+ O === "PLAN" && V?.getPlan?.pricingModel === "PER_SEAT" && /* @__PURE__ */ p("div", {
1112
1113
  className: "border-t border-border pt-4",
1113
1114
  children: /* @__PURE__ */ m("div", {
1114
1115
  className: "space-y-3",
@@ -1129,26 +1130,26 @@ var Ke = () => {
1129
1130
  children: [
1130
1131
  /* @__PURE__ */ p("button", {
1131
1132
  type: "button",
1132
- onClick: () => R((e) => Math.max(V.getPlan?.minSeats ?? 1, e - 1)),
1133
- disabled: L <= (V.getPlan.minSeats ?? 1),
1133
+ onClick: () => z((e) => Math.max(V.getPlan?.minSeats ?? 1, e - 1)),
1134
+ disabled: R <= (V.getPlan.minSeats ?? 1),
1134
1135
  className: "size-9 rounded-md border border-border flex items-center justify-center hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed transition-colors text-foreground",
1135
1136
  children: "−"
1136
1137
  }),
1137
1138
  /* @__PURE__ */ p("input", {
1138
1139
  type: "number",
1139
- value: L,
1140
+ value: R,
1140
1141
  min: V.getPlan.minSeats ?? 1,
1141
1142
  max: V.getPlan.maxSeats ?? 999,
1142
1143
  onChange: (e) => {
1143
1144
  let t = parseInt(e.target.value, 10);
1144
- isNaN(t) || R(Math.max(V.getPlan?.minSeats ?? 1, t));
1145
+ isNaN(t) || z(Math.max(V.getPlan?.minSeats ?? 1, t));
1145
1146
  },
1146
1147
  className: "w-20 h-9 text-center border border-border rounded-md bg-background text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-primary"
1147
1148
  }),
1148
1149
  /* @__PURE__ */ p("button", {
1149
1150
  type: "button",
1150
- onClick: () => R((e) => Math.min(V.getPlan?.maxSeats ?? 999, e + 1)),
1151
- disabled: L >= (V.getPlan.maxSeats ?? 999),
1151
+ onClick: () => z((e) => Math.min(V.getPlan?.maxSeats ?? 999, e + 1)),
1152
+ disabled: R >= (V.getPlan.maxSeats ?? 999),
1152
1153
  className: "size-9 rounded-md border border-border flex items-center justify-center hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed transition-colors text-foreground",
1153
1154
  children: "+"
1154
1155
  }),
@@ -1164,7 +1165,7 @@ var Ke = () => {
1164
1165
  " ",
1165
1166
  "=",
1166
1167
  " ",
1167
- (V.getPlan.pricePerSeat * L).toLocaleString("en", {
1168
+ (V.getPlan.pricePerSeat * R).toLocaleString("en", {
1168
1169
  style: "currency",
1169
1170
  currency: V.getPlan.currency ?? "USD"
1170
1171
  }),
@@ -1189,46 +1190,46 @@ var Ke = () => {
1189
1190
  /* @__PURE__ */ p("div", {
1190
1191
  className: "p-4",
1191
1192
  children: /* @__PURE__ */ p(ge, {
1192
- items: z.items,
1193
- subtotal: z.subtotal,
1194
- discountAmount: z.discountAmount,
1195
- taxAmount: z.taxAmount,
1196
- taxRate: z.taxRate,
1197
- taxType: z.taxType,
1198
- total: z.total,
1199
- currency: z.selectedCurrency,
1200
- isCalculatingTax: z.isCalculatingTax,
1201
- showInCredits: z.selectedProvider === "CREDITS",
1202
- onUpdateQuantity: D === "PLAN" ? void 0 : z.updateItemQuantity,
1203
- onRemoveItem: z.removeItem,
1204
- isEditable: D !== "PLAN"
1193
+ items: B.items,
1194
+ subtotal: B.subtotal,
1195
+ discountAmount: B.discountAmount,
1196
+ taxAmount: B.taxAmount,
1197
+ taxRate: B.taxRate,
1198
+ taxType: B.taxType,
1199
+ total: B.total,
1200
+ currency: B.selectedCurrency,
1201
+ isCalculatingTax: B.isCalculatingTax,
1202
+ showInCredits: B.selectedProvider === "CREDITS",
1203
+ onUpdateQuantity: O === "PLAN" ? void 0 : B.updateItemQuantity,
1204
+ onRemoveItem: B.removeItem,
1205
+ isEditable: O !== "PLAN"
1205
1206
  })
1206
1207
  }),
1207
1208
  /* @__PURE__ */ p("div", {
1208
1209
  className: "px-4 pb-4 border-t border-border pt-4",
1209
1210
  children: /* @__PURE__ */ p(_e, {
1210
- value: z.promoCode,
1211
- onChange: z.setPromoCode,
1212
- onValidate: async () => await z.validatePromoCode(),
1213
- onClear: z.clearPromoCode,
1214
- isApplied: z.promoDiscount > 0,
1215
- discountValue: z.promoDiscount,
1216
- discountType: z.promoDiscountType,
1217
- isValidating: z.isProcessing
1211
+ value: B.promoCode,
1212
+ onChange: B.setPromoCode,
1213
+ onValidate: async () => await B.validatePromoCode(),
1214
+ onClear: B.clearPromoCode,
1215
+ isApplied: B.promoDiscount > 0,
1216
+ discountValue: B.promoDiscount,
1217
+ discountType: B.promoDiscountType,
1218
+ isValidating: B.isProcessing
1218
1219
  })
1219
1220
  }),
1220
- D === "PLAN" && z.selectedProvider !== "CREDITS" && z.selectedProvider !== "AUTO" && (() => {
1221
+ O === "PLAN" && B.selectedProvider !== "CREDITS" && B.selectedProvider !== "AUTO" && (() => {
1221
1222
  let e = "", t = !1, n = !1;
1222
- if (z.selectedPaymentMethodId) {
1223
- let r = Y.find((e) => e.id === z.selectedPaymentMethodId);
1223
+ if (B.selectedPaymentMethodId) {
1224
+ let r = Y.find((e) => e.id === B.selectedPaymentMethodId);
1224
1225
  r && (e = `${r.type === "CREDIT_CARD" || r.type === "DEBIT_CARD" ? "Card" : r.type}${r.last4 ? ` •••• ${r.last4}` : ""}`, t = !0, n = !1);
1225
- } else (z.selectedProvider === "RAZORPAY" || z.selectedProvider === "STRIPE") && (e = z.selectedProvider === "RAZORPAY" ? "new card (Razorpay)" : "new card (Stripe)", t = !0, n = !0);
1226
+ } else (B.selectedProvider === "RAZORPAY" || B.selectedProvider === "STRIPE") && (e = B.selectedProvider === "RAZORPAY" ? "new card (Razorpay)" : "new card (Stripe)", t = !0, n = !0);
1226
1227
  return /* @__PURE__ */ p("div", {
1227
1228
  className: "px-4 pb-4",
1228
1229
  children: /* @__PURE__ */ p(Se, {
1229
- enabled: z.autoRenew,
1230
+ enabled: B.autoRenew,
1230
1231
  onToggle: (e) => {
1231
- z.setAutoRenew(e), e && z.selectedPaymentMethodId && z.setAutoRenewPaymentMethodId(z.selectedPaymentMethodId);
1232
+ B.setAutoRenew(e), e && B.selectedPaymentMethodId && B.setAutoRenewPaymentMethodId(B.selectedPaymentMethodId);
1232
1233
  },
1233
1234
  hasPaymentMethodSelected: t,
1234
1235
  selectedPaymentMethodDisplay: e,
@@ -1240,10 +1241,10 @@ var Ke = () => {
1240
1241
  }),
1241
1242
  /* @__PURE__ */ p("button", {
1242
1243
  type: "button",
1243
- onClick: wt,
1244
- disabled: z.isProcessing || !z.billingAccount || z.items.length === 0 || D === "ADDON" && !E && vt || D === "ADDON" && !E && W.length === 0 || D === "ADDON" && !E && !z.selectedSubscriptionId,
1244
+ onClick: Et,
1245
+ disabled: B.isProcessing || !B.billingAccount || B.items.length === 0 || O === "ADDON" && !D && bt || O === "ADDON" && !D && W.length === 0 || O === "ADDON" && !D && !B.selectedSubscriptionId,
1245
1246
  className: "w-full px-6 py-4 rounded-lg bg-primary text-primary-foreground font-semibold\n hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed\n transition-colors flex items-center justify-center gap-2",
1246
- children: z.isProcessing ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(d, { className: "size-5 animate-spin" }), "Processing…"] }) : z.selectedProvider === "CREDITS" ? "Pay with Credits" : "Proceed to Payment"
1247
+ children: B.isProcessing ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(d, { className: "size-5 animate-spin" }), "Processing…"] }) : B.selectedProvider === "CREDITS" ? "Pay with Credits" : "Proceed to Payment"
1247
1248
  }),
1248
1249
  /* @__PURE__ */ p("p", {
1249
1250
  className: "text-center text-xs text-muted-foreground",
@@ -1253,14 +1254,17 @@ var Ke = () => {
1253
1254
  })
1254
1255
  })]
1255
1256
  }),
1256
- rt && z.billingAccount && /* @__PURE__ */ p(we, {
1257
- billingAccountId: z.billingAccount.id,
1258
- hasPhone: !!z.billingAccount.contactNumber?.trim(),
1259
- hasAddress: !!(z.billingAccount.billingAddresses?.[0]?.line1?.trim() && z.billingAccount.billingAddresses?.[0]?.postalCode?.trim()),
1257
+ nt && B.billingAccount && /* @__PURE__ */ p(we, {
1258
+ billingAccountId: B.billingAccount.id,
1259
+ hasPhone: !!B.billingAccount.contactNumber?.trim(),
1260
+ hasAddress: !!(B.billingAccount.billingAddresses?.[0]?.line1?.trim() && B.billingAccount.billingAddresses?.[0]?.postalCode?.trim()),
1260
1261
  onCompleted: () => {
1261
- k(!1), wt();
1262
+ j.current = !0, A(!1), Et(), mt().then((e) => {
1263
+ let t = (e.data?.getBillingAccountsByOrg ?? []).find((e) => e.id === B.billingAccount?.id);
1264
+ t && B.setBillingAccount(t);
1265
+ });
1262
1266
  },
1263
- onCancel: () => k(!1)
1267
+ onCancel: () => A(!1)
1264
1268
  })
1265
1269
  ]
1266
1270
  });