@burdenoff/microfe-billing 2026.1113.4 → 2026.1114.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/billing/modules/addons/pages/AddonsBrowsePage.js +293 -291
  2. package/dist/billing/modules/addons/pages/AddonsBrowsePage.js.map +1 -1
  3. package/dist/billing/modules/affiliate/pages/AffiliateDashboardPage.js +25 -24
  4. package/dist/billing/modules/affiliate/pages/AffiliateDashboardPage.js.map +1 -1
  5. package/dist/billing/modules/analytics/pages/AnalyticsPage.js +25 -24
  6. package/dist/billing/modules/analytics/pages/AnalyticsPage.js.map +1 -1
  7. package/dist/billing/modules/billing/hooks/index.js +5 -5
  8. package/dist/billing/modules/billing/hooks/useInvoices.js +20 -39
  9. package/dist/billing/modules/billing/hooks/useInvoices.js.map +1 -1
  10. package/dist/billing/modules/billing/index.js +14 -14
  11. package/dist/billing/modules/billing/pages/InvoicesListPage.js +92 -89
  12. package/dist/billing/modules/billing/pages/InvoicesListPage.js.map +1 -1
  13. package/dist/billing/modules/billing/pages/TransactionsPage.js +2 -2
  14. package/dist/billing/modules/billing/pages/UserRefundsPage.js +140 -140
  15. package/dist/billing/modules/billing/pages/UserRefundsPage.js.map +1 -1
  16. package/dist/billing/modules/coupons/pages/CouponDetailPage.js +16 -15
  17. package/dist/billing/modules/coupons/pages/CouponDetailPage.js.map +1 -1
  18. package/dist/billing/modules/credits/pages/CreditWithdrawalPage.js +1 -1
  19. package/dist/billing/modules/credits/pages/CreditsPage.js +164 -137
  20. package/dist/billing/modules/credits/pages/CreditsPage.js.map +1 -1
  21. package/dist/billing/modules/dashboard/pages/OverviewPage.js +444 -594
  22. package/dist/billing/modules/dashboard/pages/OverviewPage.js.map +1 -1
  23. package/dist/billing/modules/earnings/pages/EarningsPage.js +20 -20
  24. package/dist/billing/modules/earnings/pages/EarningsPage.js.map +1 -1
  25. package/dist/billing/modules/earnings/pages/PayoutsPage.js +1 -1
  26. package/dist/billing/modules/plans/pages/PlansBrowsePage.js +32 -32
  27. package/dist/billing/modules/settings/pages/SettingsPage.js +4 -4
  28. package/dist/billing/modules/subscriptions/pages/SubscriptionDetailPage.js +577 -640
  29. package/dist/billing/modules/subscriptions/pages/SubscriptionDetailPage.js.map +1 -1
  30. package/dist/billing/shared/components/HeaderActions.d.ts +10 -0
  31. package/dist/billing/shared/components/HeaderActions.js +33 -0
  32. package/dist/billing/shared/components/HeaderActions.js.map +1 -0
  33. package/dist/billing/shared/components/index.d.ts +1 -0
  34. package/dist/billing/shared/components/index.js +2 -1
  35. package/dist/billing/shared/utils/format.js +4 -16
  36. package/dist/billing/shared/utils/format.js.map +1 -1
  37. package/dist/billing/shared/utils/index.js +8 -8
  38. package/dist/generated/global-operations.js +286 -294
  39. package/dist/generated/global-operations.js.map +1 -1
  40. package/package.json +1 -1
  41. package/dist/billing/modules/dashboard/utils/overviewSummary.d.ts +0 -46
  42. package/dist/billing/modules/dashboard/utils/overviewSummary.js +0 -37
  43. package/dist/billing/modules/dashboard/utils/overviewSummary.js.map +0 -1
  44. package/dist/billing/modules/subscriptions/utils/subscriptionDetailView.d.ts +0 -30
  45. package/dist/billing/modules/subscriptions/utils/subscriptionDetailView.js +0 -20
  46. package/dist/billing/modules/subscriptions/utils/subscriptionDetailView.js.map +0 -1
@@ -1,668 +1,518 @@
1
1
  import { useBilling as e } from "../../../providers/BillingProvider.js";
2
2
  import { useBillingEventEmitter as t } from "../../../hooks/useBillingEventEmitter.js";
3
3
  import { useBillingPermissions as n } from "../../../hooks/useBillingPermissions.js";
4
- import { useIsFluidgridsVariant as ee } from "../../../hooks/useBillingVariant.js";
5
- import "../../billing/hooks/index.js";
6
- import { formatCardBrand as r, formatCardExpiry as i, formatCardNumber as te, formatCurrency as a, formatDate as o, formatInvoiceStatus as s, formatPlanPrice as ne } from "../../../shared/utils/format.js";
7
- import { pickLatestInvoice as c, pickSavedCard as re, resolveChangePlanPath as ie, resolveNoAccountMode as ae, shouldShowNewAccountButton as oe, summarizePlan as se } from "../utils/overviewSummary.js";
8
- import { StatCard as l } from "../../../shared/components/StatCard.js";
9
- import { ServerError as ce } from "../../../shared/components/ServerError.js";
10
- import { isServerError as le } from "../../../shared/utils/error.js";
11
- import { AccessDenied as ue } from "../../../shared/components/AccessDenied.js";
12
- import { PushPermissionNudge as de } from "../../../shared/components/PushPermissionNudge.js";
4
+ import { StatCard as r } from "../../../shared/components/StatCard.js";
5
+ import { ServerError as ee } from "../../../shared/components/ServerError.js";
6
+ import { AccessDenied as te } from "../../../shared/components/AccessDenied.js";
7
+ import { HeaderActions as ne } from "../../../shared/components/HeaderActions.js";
8
+ import { PushPermissionNudge as re } from "../../../shared/components/PushPermissionNudge.js";
13
9
  import "../../../shared/utils/index.js";
14
- import { useInvoices as u } from "../../billing/hooks/useInvoices.js";
15
10
  import "../hooks/index.js";
11
+ import { isServerError as ie } from "../../../shared/utils/error.js";
16
12
  import "../components/index.js";
17
- import { useDashboardMutations as fe } from "../hooks/useDashboard.js";
18
- import { useBillingOverviewData as pe } from "../hooks/useBillingOverviewData.js";
19
- import { useAddonCartStore as me } from "../../addons/store/addonCartStore.js";
20
- import { BillingAccountCard as he } from "../components/BillingAccountCard.js";
21
- import { PaymentMethodsSection as ge } from "../components/PaymentMethodsSection.js";
22
- import { ActiveSubscriptionCard as _e } from "../components/ActiveSubscriptionCard.js";
23
- import { RecommendedAddonsSection as ve } from "../components/RecommendedAddonsSection.js";
24
- import { CreateBillingAccountModal as ye } from "../components/CreateBillingAccountModal.js";
25
- import { AddPaymentMethodModal as be } from "../components/AddPaymentMethodModal.js";
26
- import { FloatingCartDrawer as xe } from "../../addons/components/FloatingCartDrawer.js";
27
- import { getStoredBillingAccountId as Se, setStoredBillingAccountId as Ce } from "../../../hooks/useBillingAccountSelection.js";
28
- import { withBillingAccountId as we } from "../../../shared/utils/navigation.js";
29
- import { useTr as Te } from "../../../shared/hooks/useTr.js";
30
- import { useCallback as d, useEffect as f, useState as p } from "react";
31
- import { AccessGate as Ee, AuroraBackground as De, Button as Oe, CTAOverflowMenu as ke, GlassCard as Ae, GradientText as m, IllustratedEmptyState as je, OptionalFields as Me, PagePurpose as Ne } from "@burdenoff/fe-libs/ui";
32
- import { Activity as Pe, ArrowRight as h, Building2 as g, CalendarClock as Fe, Check as _, ChevronDown as v, Coins as Ie, CreditCard as Le, Crown as y, FileText as b, Loader2 as Re, Plus as x, Receipt as ze, RefreshCw as S, Sparkles as Be, Wallet as C } from "lucide-react";
33
- import { Fragment as w, jsx as T, jsxs as E } from "react/jsx-runtime";
34
- import { shouldPromptForPushPermission as Ve } from "@burdenoff/fe-libs/shared/native";
13
+ import { useAddonCartStore as ae } from "../../addons/store/addonCartStore.js";
14
+ import { useDashboardMutations as oe } from "../hooks/useDashboard.js";
15
+ import { useBillingOverviewData as se } from "../hooks/useBillingOverviewData.js";
16
+ import { FloatingCartDrawer as ce } from "../../addons/components/FloatingCartDrawer.js";
17
+ import { BillingAccountCard as le } from "../components/BillingAccountCard.js";
18
+ import { PaymentMethodsSection as ue } from "../components/PaymentMethodsSection.js";
19
+ import { ActiveSubscriptionCard as de } from "../components/ActiveSubscriptionCard.js";
20
+ import { RecommendedAddonsSection as fe } from "../components/RecommendedAddonsSection.js";
21
+ import { CreateBillingAccountModal as i } from "../components/CreateBillingAccountModal.js";
22
+ import { AddPaymentMethodModal as pe } from "../components/AddPaymentMethodModal.js";
23
+ import { getStoredBillingAccountId as me, setStoredBillingAccountId as he } from "../../../hooks/useBillingAccountSelection.js";
24
+ import { withBillingAccountId as a } from "../../../shared/utils/navigation.js";
25
+ import { useTr as ge } from "../../../shared/hooks/useTr.js";
26
+ import "../../../shared/components/index.js";
27
+ import { useCallback as o, useEffect as s, useState as c } from "react";
28
+ import { AuroraBackground as _e, Button as ve, GlassCard as ye, GradientText as l, IllustratedEmptyState as be, PagePurpose as xe } from "@burdenoff/fe-libs/ui";
29
+ import { Activity as Se, ArrowRight as Ce, Building2 as u, Check as d, ChevronDown as f, Coins as we, Crown as p, Loader2 as Te, Plus as m, Receipt as Ee, RefreshCw as h, Sparkles as De, Wallet as g } from "lucide-react";
30
+ import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
31
+ import { shouldPromptForPushPermission as Oe } from "@burdenoff/fe-libs/shared/native";
35
32
  // src/billing/modules/dashboard/pages/OverviewPage.tsx
36
- var He = ({ billingAccountId: e, onViewAll: t }) => {
37
- let n = Te(), { invoices: ee, isLoading: r } = u({ billingAccountId: e }), i = c(ee);
38
- return /* @__PURE__ */ E("div", {
39
- className: "flex items-start gap-3",
40
- children: [/* @__PURE__ */ T("div", {
41
- className: "size-9 rounded-lg bg-bg-sunken flex items-center justify-center flex-shrink-0",
42
- children: /* @__PURE__ */ T(b, { className: "size-4 text-text-secondary" })
43
- }), /* @__PURE__ */ E("div", {
44
- className: "min-w-0",
45
- children: [
46
- /* @__PURE__ */ T("p", {
47
- className: "text-xs text-text-secondary",
48
- children: n("billing.overview.latestInvoice", "Latest invoice")
49
- }),
50
- i ? /* @__PURE__ */ E(w, { children: [/* @__PURE__ */ E("p", {
51
- className: "text-sm font-medium text-text-primary",
52
- children: [
53
- a(i.total, i.currency),
54
- " · ",
55
- s(i.status)
56
- ]
57
- }), /* @__PURE__ */ E("p", {
58
- className: "text-xs text-text-secondary",
59
- children: [
60
- i.invoiceNumber,
61
- " · ",
62
- o(i.createdAt)
63
- ]
64
- })] }) : /* @__PURE__ */ T("p", {
65
- className: "text-sm text-text-secondary",
66
- children: r ? n("billing.overview.loadingInvoice", "Loading...") : n("billing.overview.noInvoices", "No invoices yet")
67
- }),
68
- /* @__PURE__ */ T("button", {
69
- type: "button",
70
- onClick: t,
71
- className: "text-xs text-text-link hover:underline mt-1",
72
- children: n("billing.overview.viewInvoices", "View all invoices")
73
- })
74
- ]
75
- })]
76
- });
77
- }, D = () => {
78
- let s = Te(), { navigate: c, basePath: u, orgId: b, productId: D } = e(), O = n(), k = ee(), { emit: A } = t(), [j, Ue] = p(() => Se(b)), [M, N] = p(!1), [P, F] = p(null), [We, Ge] = p(!1), [I, L] = p(!1), [Ke, qe] = p(!1), [Je, Ye] = p(0), [R, z] = p(!1), { billingAccounts: B, currentAccount: V, paymentMethods: H, activeSubscriptions: U, hasActiveSubscription: Xe, recommendedAddons: Ze, isLoading: W, error: Qe, refetchAll: G } = pe(j, D), K = V?.id, $e = W, q = d((e) => {
79
- Ue(e), Ce(b, e);
80
- }, [b]), { addToCart: et, isInCart: tt, getCartItem: nt, updateQuantity: rt, removeFromCart: J } = me(), { createBillingAccount: it, setBillingAddress: at, setDefaultPaymentMethod: ot, deletePaymentMethod: st, isCreatingAccount: ct } = fe();
81
- f(() => {
82
- Ye(0), z(!1);
83
- }, [K, U.length]), f(() => {
84
- j && B.length > 0 && (B.some((e) => e.id === j) || q(null));
33
+ var b = () => {
34
+ let b = ge(), { navigate: x, basePath: S, orgId: C, productId: ke } = e(), w = n(), { emit: T } = t(), [E, Ae] = c(() => me(C)), [D, O] = c(!1), [k, A] = c(null), [je, j] = c(!1), [M, N] = c(!1), [Me, P] = c(!1), [F, I] = c(0), [L, R] = c(!1), { billingAccounts: z, currentAccount: B, paymentMethods: V, activeSubscriptions: H, hasActiveSubscription: U, recommendedAddons: Ne, isLoading: W, error: G, refetchAll: K } = se(E, ke), q = B?.id, Pe = W, J = o((e) => {
35
+ Ae(e), he(C, e);
36
+ }, [C]), { addToCart: Y, isInCart: Fe, getCartItem: Ie, updateQuantity: Le, removeFromCart: X } = ae(), { createBillingAccount: Re, setBillingAddress: ze, setDefaultPaymentMethod: Be, deletePaymentMethod: Ve, isCreatingAccount: He } = oe();
37
+ s(() => {
38
+ I(0), R(!1);
39
+ }, [q, H.length]), s(() => {
40
+ E && z.length > 0 && (z.some((e) => e.id === E) || J(null));
85
41
  }, [
86
- B,
87
- j,
88
- q
89
- ]), f(() => {
90
- if (!j && B.length > 0) {
91
- let e = B.find((e) => e.isDefault) ?? B[0];
92
- q(e.id);
42
+ z,
43
+ E,
44
+ J
45
+ ]), s(() => {
46
+ if (!E && z.length > 0) {
47
+ let e = z.find((e) => e.isDefault) ?? z[0];
48
+ J(e.id);
93
49
  }
94
50
  }, [
95
- B,
96
- j,
97
- q
51
+ z,
52
+ E,
53
+ J
98
54
  ]);
99
- let Y = U[Je] || U[0] || null, X = d((e) => {
55
+ let Z = H[F] || H[0] || null, Q = o((e) => {
100
56
  let t = e;
101
- u && u !== "/" && (t = `${u.endsWith("/") ? u.slice(0, -1) : u}${e.startsWith("/") ? e : `/${e}`}`), c(t);
102
- }, [c, u]), lt = d(async (e, t) => {
103
- F(null);
57
+ S && S !== "/" && (t = `${S.endsWith("/") ? S.slice(0, -1) : S}${e.startsWith("/") ? e : `/${e}`}`), x(t);
58
+ }, [x, S]), Ue = o(async (e, t) => {
59
+ A(null);
104
60
  try {
105
- let n = await it(e);
106
- t && n.id && await at({
61
+ let n = await Re(e);
62
+ t && n.id && await ze({
107
63
  billingAccountId: n.id,
108
64
  ...t
109
- }), N(!1), q(n.id), A("billing.billing_account.created", {
65
+ }), O(!1), J(n.id), T("billing.billing_account.created", {
110
66
  route: "/billing/overview",
111
67
  entityId: n.id,
112
68
  source: "overview"
113
- }), await G(), Ve() && Ge(!0);
69
+ }), await K(), Oe() && j(!0);
114
70
  } catch (e) {
115
- F(e instanceof Error ? e.message : "Failed to create billing account");
71
+ A(e instanceof Error ? e.message : "Failed to create billing account");
116
72
  }
117
73
  }, [
118
- it,
119
- A,
120
- G,
121
- at,
122
- q
123
- ]), ut = d(() => {
124
- qe(!0);
125
- }, []), Z = d(async () => {
126
- await G();
127
- }, [G]), dt = d(async () => {
128
- A("billing.payment_method.added", {
74
+ Re,
75
+ T,
76
+ K,
77
+ ze,
78
+ J
79
+ ]), We = o(() => {
80
+ P(!0);
81
+ }, []), $ = o(async () => {
82
+ await K();
83
+ }, [K]), Ge = o(async () => {
84
+ T("billing.payment_method.added", {
129
85
  route: "/billing/overview",
130
- entityId: K,
86
+ entityId: q,
131
87
  source: "overview"
132
- }), await Z();
88
+ }), await $();
133
89
  }, [
134
- K,
135
- A,
136
- Z
137
- ]), ft = d(async (e) => {
138
- K && (await ot(e, K), A("billing.payment_method.default_set", {
90
+ q,
91
+ T,
92
+ $
93
+ ]), Ke = o(async (e) => {
94
+ q && (await Be(e, q), T("billing.payment_method.default_set", {
139
95
  route: "/billing/overview",
140
96
  entityId: e,
141
97
  source: "overview"
142
- }), await Z());
98
+ }), await $());
143
99
  }, [
144
- K,
145
- A,
146
- ot,
147
- Z
148
- ]), pt = d(async (e) => {
149
- K && (await st(e, K), A("billing.payment_method.deleted", {
100
+ q,
101
+ T,
102
+ Be,
103
+ $
104
+ ]), qe = o(async (e) => {
105
+ q && (await Ve(e, q), T("billing.payment_method.deleted", {
150
106
  route: "/billing/overview",
151
107
  entityId: e,
152
108
  source: "overview"
153
- }), await Z());
109
+ }), await $());
154
110
  }, [
155
- K,
156
- st,
157
- A,
158
- Z
159
- ]), mt = d((e) => {
160
- q(e.id), L(!1);
161
- }, [q]), ht = d(async () => {
162
- await G();
163
- }, [G]), gt = d((e) => {
164
- et(e);
165
- }, [et]), _t = d((e) => tt(e), [tt]), vt = d((e) => nt(e)?.quantity || 0, [nt]), yt = d((e, t) => {
166
- t <= 0 ? J(e) : rt(e, t);
167
- }, [rt, J]), bt = d((e) => {
168
- J(e);
169
- }, [J]);
170
- if (!O.canViewBillingAccount) return /* @__PURE__ */ T(ue, { message: "You don't have permission to view billing information." });
171
- if (Qe && le(Qe) && !W) return /* @__PURE__ */ T("div", {
111
+ q,
112
+ Ve,
113
+ T,
114
+ $
115
+ ]), Je = o((e) => {
116
+ J(e.id), N(!1);
117
+ }, [J]), Ye = o(async () => {
118
+ await K();
119
+ }, [K]), Xe = o((e) => {
120
+ Y(e);
121
+ }, [Y]), Ze = o((e) => Fe(e), [Fe]), Qe = o((e) => Ie(e)?.quantity || 0, [Ie]), $e = o((e, t) => {
122
+ t <= 0 ? X(e) : Le(e, t);
123
+ }, [Le, X]), et = o((e) => {
124
+ X(e);
125
+ }, [X]);
126
+ return w.canViewBillingAccount ? G && ie(G) && !W ? /* @__PURE__ */ v("div", {
172
127
  className: "p-6",
173
- children: /* @__PURE__ */ T(ce, {
174
- title: s("billing.serverError.title", "Server Unavailable"),
175
- message: s("billing.overview.serverUnavailableMessage", "Unable to load billing overview. The server might be down or experiencing issues."),
176
- onRetry: ht,
128
+ children: /* @__PURE__ */ v(ee, {
129
+ title: b("billing.serverError.title", "Server Unavailable"),
130
+ message: b("billing.overview.serverUnavailableMessage", "Unable to load billing overview. The server might be down or experiencing issues."),
131
+ onRetry: Ye,
177
132
  showRetry: !0
178
133
  })
179
- });
180
- if (W && !V) return /* @__PURE__ */ T("div", {
134
+ }) : W && !B ? /* @__PURE__ */ v("div", {
181
135
  className: "flex items-center justify-center min-h-[400px]",
182
- children: /* @__PURE__ */ E("div", {
136
+ children: /* @__PURE__ */ y("div", {
183
137
  className: "flex flex-col items-center gap-3",
184
- children: [/* @__PURE__ */ T(Re, { className: "size-8 animate-spin text-text-link" }), /* @__PURE__ */ T("p", {
138
+ children: [/* @__PURE__ */ v(Te, { className: "size-8 animate-spin text-text-link" }), /* @__PURE__ */ v("p", {
185
139
  className: "text-sm text-text-secondary",
186
- children: s("billing.overview.loadingInfo", "Loading billing information...")
140
+ children: b("billing.overview.loadingInfo", "Loading billing information...")
187
141
  })]
188
142
  })
189
- });
190
- if (!W && B.length === 0 && !V) {
191
- let e = ae(k, O.canManageBillingAccount);
192
- return /* @__PURE__ */ E("div", {
193
- className: "px-4 sm:px-6 lg:px-8 py-4 sm:py-6",
194
- children: [
195
- /* @__PURE__ */ E("header", {
196
- className: "relative overflow-hidden mb-6 sm:mb-8 rounded-card",
197
- children: [
198
- /* @__PURE__ */ T(De, { intensity: "subtle" }),
199
- /* @__PURE__ */ T("h1", {
200
- className: "text-2xl md:text-3xl font-semibold tracking-tight text-text-primary",
201
- children: /* @__PURE__ */ T(m, { children: s("billing.overview.title", "Billing Overview") })
202
- }),
203
- /* @__PURE__ */ T("p", {
204
- className: "text-sm text-text-secondary mt-1",
205
- children: s("billing.overview.emptySetupDescription", "Set up billing to manage subscriptions, payments, and invoices")
206
- })
207
- ]
208
- }),
209
- e === "request-access" ? /* @__PURE__ */ T(Ee, {
210
- message: s("billing.overview.needAccountAccess", "You need access to create a billing account"),
211
- granterHint: s("billing.overview.needAccountAccessHint", "Ask a billing admin of this organization to create one or give you access.")
212
- }) : /* @__PURE__ */ T(je, {
213
- illustration: "onboarding",
214
- title: s("billing.overview.emptyTitle", "No billing account"),
215
- description: s("billing.overview.emptyDescription", "Create a billing account to start managing your subscriptions and payments"),
216
- action: O.canManageBillingAccount ? /* @__PURE__ */ E("button", {
217
- type: "button",
218
- onClick: () => N(!0),
219
- className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-action-primary-text bg-action-primary-bg rounded-button hover:bg-action-primary-bgHover transition-colors duration-200",
220
- children: [/* @__PURE__ */ T(x, { className: "size-4" }), s("billing.overview.createBillingAccount", "Create Billing Account")]
221
- }) : void 0
222
- }),
223
- /* @__PURE__ */ T(ye, {
224
- isOpen: M,
225
- onClose: () => {
226
- N(!1), F(null);
227
- },
228
- onSubmit: lt,
229
- isSubmitting: ct,
230
- error: P
231
- })
232
- ]
233
- });
234
- }
235
- let xt = B.length > 1 && /* @__PURE__ */ E("div", {
236
- className: "relative",
237
- "data-tour": "billing-overview-account-selector",
238
- children: [/* @__PURE__ */ E("button", {
239
- type: "button",
240
- onClick: () => L(!I),
241
- className: "w-full sm:w-auto flex items-center justify-between gap-3 px-4 py-3 border border-border-seam rounded-card bg-bg-surface hover:bg-bg-sunken hover:border-border-strong transition-all duration-200",
242
- children: [/* @__PURE__ */ E("div", {
243
- className: "flex items-center gap-3",
244
- children: [/* @__PURE__ */ T("div", {
245
- className: "size-9 rounded-lg bg-[var(--color-accent-soft)] flex items-center justify-center",
246
- children: /* @__PURE__ */ T(g, { className: "size-4 text-text-link" })
247
- }), /* @__PURE__ */ E("div", {
248
- className: "text-left",
249
- children: [/* @__PURE__ */ T("p", {
250
- className: "text-sm font-medium text-text-primary",
251
- children: V?.name || s("billing.overview.selectAccount", "Select Account")
252
- }), /* @__PURE__ */ T("p", {
253
- className: "text-xs text-text-secondary",
254
- children: V?.email
255
- })]
256
- })]
257
- }), /* @__PURE__ */ T(v, { className: `size-4 text-text-muted transition-transform ${I ? "rotate-180" : ""}` })]
258
- }), I && /* @__PURE__ */ E(w, { children: [/* @__PURE__ */ T("div", {
259
- className: "fixed inset-0 z-10",
260
- onClick: () => L(!1)
261
- }), /* @__PURE__ */ T("div", {
262
- className: "absolute top-full left-0 right-0 sm:right-auto mt-1 w-full sm:w-80 bg-bg-elevated border border-border-seam rounded-card shadow-elevation-3 z-20 py-1 max-h-60 overflow-y-auto",
263
- children: B.map((e) => /* @__PURE__ */ E("button", {
264
- type: "button",
265
- onClick: () => mt(e),
266
- className: "w-full flex items-center justify-between gap-3 px-4 py-3 hover:bg-bg-sunken transition-colors",
267
- children: [/* @__PURE__ */ E("div", {
268
- className: "flex items-center gap-3 min-w-0",
269
- children: [/* @__PURE__ */ T("div", {
270
- className: "size-9 rounded-lg bg-bg-sunken flex items-center justify-center flex-shrink-0",
271
- children: /* @__PURE__ */ T(g, { className: "size-4 text-text-secondary" })
272
- }), /* @__PURE__ */ E("div", {
273
- className: "text-left min-w-0",
274
- children: [/* @__PURE__ */ T("p", {
275
- className: "text-sm font-medium text-text-primary truncate",
276
- children: e.name
277
- }), /* @__PURE__ */ T("p", {
278
- className: "text-xs text-text-secondary truncate",
279
- children: e.email
280
- })]
281
- })]
282
- }), V?.id === e.id && /* @__PURE__ */ T(_, { className: "size-4 text-text-link flex-shrink-0" })]
283
- }, e.id))
284
- })] })]
285
- }), St = V && /* @__PURE__ */ E("div", {
286
- className: "grid grid-cols-2 sm:grid-cols-4 gap-3 sm:gap-4",
287
- "data-tour": "billing-overview-stats-row",
143
+ }) : !W && z.length === 0 && !B ? /* @__PURE__ */ y("div", {
144
+ className: "px-4 sm:px-6 lg:px-8 py-4 sm:py-6",
288
145
  children: [
289
- /* @__PURE__ */ T(l, {
290
- className: "p-3 sm:p-5",
291
- label: s("billing.overview.stats.creditBalance", "Credit Balance"),
292
- value: `${(V.creditAmount || 0).toLocaleString()} Credits`,
293
- icon: /* @__PURE__ */ T(C, { className: "size-5" })
294
- }),
295
- /* @__PURE__ */ T(l, {
296
- className: "p-3 sm:p-5",
297
- label: s("billing.overview.stats.activePlans", "Active Plans"),
298
- value: U.length > 0 ? U.length === 1 ? U[0]?.plan?.name || "1 Plan" : `${U.length} ${s("billing.overview.stats.plansSuffix", "Plans")}` : s("billing.overview.stats.none", "None"),
299
- icon: /* @__PURE__ */ T(S, { className: "size-5" })
146
+ /* @__PURE__ */ y("header", {
147
+ className: "relative overflow-hidden mb-6 sm:mb-8 rounded-card",
148
+ children: [
149
+ /* @__PURE__ */ v(_e, { intensity: "subtle" }),
150
+ /* @__PURE__ */ v("h1", {
151
+ className: "text-2xl md:text-3xl font-semibold tracking-tight text-text-primary",
152
+ children: /* @__PURE__ */ v(l, { children: b("billing.overview.title", "Billing Overview") })
153
+ }),
154
+ /* @__PURE__ */ v("p", {
155
+ className: "text-sm text-text-secondary mt-1",
156
+ children: b("billing.overview.emptySetupDescription", "Set up billing to manage subscriptions, payments, and invoices")
157
+ })
158
+ ]
300
159
  }),
301
- /* @__PURE__ */ T(l, {
302
- className: "p-3 sm:p-5",
303
- label: s("billing.overview.stats.paymentMethods", "Payment Methods"),
304
- value: H.length,
305
- icon: /* @__PURE__ */ T(g, { className: "size-5" })
160
+ /* @__PURE__ */ v(be, {
161
+ illustration: "onboarding",
162
+ title: b("billing.overview.emptyTitle", "No billing account"),
163
+ description: b("billing.overview.emptyDescription", "Create a billing account to start managing your subscriptions and payments"),
164
+ action: w.canManageBillingAccount ? /* @__PURE__ */ y("button", {
165
+ type: "button",
166
+ onClick: () => O(!0),
167
+ className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-action-primary-text bg-action-primary-bg rounded-button hover:bg-action-primary-bgHover transition-colors duration-200",
168
+ children: [/* @__PURE__ */ v(m, { className: "size-4" }), b("billing.overview.createBillingAccount", "Create Billing Account")]
169
+ }) : void 0
306
170
  }),
307
- /* @__PURE__ */ T(l, {
308
- className: "p-3 sm:p-5",
309
- label: s("billing.overview.stats.paymentCurrency", "Payment Currency"),
310
- value: V.currency || "USD",
311
- icon: /* @__PURE__ */ T(g, { className: "size-5" })
171
+ /* @__PURE__ */ v(i, {
172
+ isOpen: D,
173
+ onClose: () => {
174
+ O(!1), A(null);
175
+ },
176
+ onSubmit: Ue,
177
+ isSubmitting: He,
178
+ error: k
312
179
  })
313
180
  ]
314
- }), Ct = /* @__PURE__ */ E("div", {
315
- className: "grid grid-cols-1 lg:grid-cols-3 gap-4 sm:gap-6",
316
- children: [/* @__PURE__ */ E("div", {
317
- className: "lg:col-span-2 space-y-4 sm:space-y-6",
318
- children: [
319
- V && /* @__PURE__ */ T(he, {
320
- dataTour: "billing-overview-billing-account-card",
321
- account: V,
322
- isDefault: V.isDefault ?? !1,
323
- onEdit: () => V && X(`/settings?billingAccountId=${V.id}`),
324
- onViewTransactions: () => X(`/transactions/${V.id}`),
325
- onViewCreditTransactions: () => X(`/creditTransactions/${V.id}`)
326
- }),
327
- /* @__PURE__ */ E("div", {
328
- className: "space-y-3",
329
- children: [U.length > 1 && /* @__PURE__ */ E("div", {
330
- className: "relative",
331
- children: [/* @__PURE__ */ E("button", {
332
- type: "button",
333
- onClick: () => z(!R),
334
- className: "w-full sm:w-auto flex items-center justify-between gap-3 px-4 py-3 border border-border-seam rounded-card bg-bg-surface hover:bg-bg-sunken hover:border-border-strong transition-all duration-200",
335
- children: [/* @__PURE__ */ E("div", {
336
- className: "flex items-center gap-3",
337
- children: [/* @__PURE__ */ T("div", {
338
- className: "size-9 rounded-lg bg-[var(--color-accent-soft)] flex items-center justify-center",
339
- children: /* @__PURE__ */ T(y, { className: "size-4 text-text-link" })
340
- }), /* @__PURE__ */ E("div", {
341
- className: "text-left",
342
- children: [/* @__PURE__ */ E("p", {
343
- className: "text-sm font-medium text-text-primary",
344
- children: [Y?.plan?.name || s("billing.overview.selectSubscription", "Select Subscription"), Y?.plan?.product?.name && /* @__PURE__ */ E("span", {
345
- className: "text-text-secondary font-normal",
346
- children: [
347
- " ",
348
- "· ",
349
- Y.plan.product.name
350
- ]
351
- })]
352
- }), /* @__PURE__ */ E("p", {
353
- className: "text-xs text-text-secondary",
354
- children: [
355
- U.length,
356
- " ",
357
- s("billing.overview.activeSubscriptions", "active subscriptions")
358
- ]
359
- })]
360
- })]
361
- }), /* @__PURE__ */ T(v, { className: `size-4 text-text-muted transition-transform ${R ? "rotate-180" : ""}` })]
362
- }), R && /* @__PURE__ */ E(w, { children: [/* @__PURE__ */ T("div", {
363
- className: "fixed inset-0 z-10",
364
- onClick: () => z(!1)
365
- }), /* @__PURE__ */ T("div", {
366
- className: "absolute top-full left-0 right-0 sm:right-auto mt-1 w-full sm:w-80 bg-bg-elevated border border-border-seam rounded-card shadow-elevation-3 z-20 py-1 max-h-60 overflow-y-auto",
367
- children: U.map((e, t) => /* @__PURE__ */ E("button", {
368
- type: "button",
369
- onClick: () => {
370
- Ye(t), z(!1);
371
- },
372
- className: "w-full flex items-center justify-between gap-3 px-4 py-3 hover:bg-bg-sunken transition-colors",
373
- children: [/* @__PURE__ */ E("div", {
374
- className: "flex items-center gap-3 min-w-0",
375
- children: [/* @__PURE__ */ T("div", {
376
- className: "size-9 rounded-lg bg-bg-sunken flex items-center justify-center flex-shrink-0",
377
- children: /* @__PURE__ */ T(y, { className: "size-4 text-text-secondary" })
378
- }), /* @__PURE__ */ E("div", {
379
- className: "text-left min-w-0",
380
- children: [/* @__PURE__ */ T("p", {
381
- className: "text-sm font-medium text-text-primary truncate",
382
- children: e.plan?.name || s("billing.overview.subscription", "Subscription")
383
- }), /* @__PURE__ */ E("p", {
384
- className: "text-xs text-text-secondary truncate",
385
- children: [
386
- e.plan?.product?.name || s("billing.overview.unknownProduct", "Unknown Product"),
387
- " ",
388
- "· ",
389
- s("billing.overview.ends", "Ends"),
390
- " ",
391
- new Date(e.endDate).toLocaleDateString()
392
- ]
393
- })]
394
- })]
395
- }), Je === t && /* @__PURE__ */ T(_, { className: "size-4 text-text-link flex-shrink-0" })]
396
- }, e.id))
397
- })] })]
398
- }), /* @__PURE__ */ T(_e, {
399
- dataTour: "billing-overview-active-subscription-card",
400
- subscription: Y,
401
- onViewDetails: () => Y && X(we(`/subscriptions/${Y.id}`, Y.billingAccountId ?? V?.id)),
402
- onUpgrade: () => Y && X(we(`/subscriptions/${Y.id}/upgrade`, Y.billingAccountId ?? V?.id)),
403
- onManage: () => V && X(`/subscriptions?billingAccountId=${V.id}`),
404
- onPurchasePlan: () => X("/plans")
405
- })]
406
- }),
407
- V && /* @__PURE__ */ T(ge, {
408
- dataTour: "billing-overview-payment-methods-section",
409
- paymentMethods: H,
410
- billingAccountId: V.id,
411
- onAddPaymentMethod: ut,
412
- onSetDefault: ft,
413
- onDelete: pt,
414
- isLoading: W
415
- })
416
- ]
417
- }), /* @__PURE__ */ E("div", {
418
- className: "space-y-4 sm:space-y-6",
419
- children: [/* @__PURE__ */ E("section", {
420
- className: "border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 p-4 sm:p-5",
421
- "data-tour": "billing-overview-quick-actions",
422
- children: [/* @__PURE__ */ T("h3", {
423
- className: "font-semibold text-text-primary mb-4",
424
- children: s("billing.overview.quickActions", "Quick Actions")
425
- }), /* @__PURE__ */ E("div", {
426
- className: "space-y-1.5",
427
- children: [
428
- /* @__PURE__ */ E("button", {
429
- type: "button",
430
- onClick: () => V && X(`/transactions/${V.id}`),
431
- disabled: !V,
432
- className: "w-full flex items-center gap-3 px-3 py-2.5 text-sm text-left text-text-primary hover:bg-bg-sunken rounded-button transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
433
- children: [/* @__PURE__ */ T("div", {
434
- className: "size-9 rounded-lg bg-status-info-bg-subtle flex items-center justify-center",
435
- children: /* @__PURE__ */ T(ze, { className: "size-4 text-status-info-text" })
436
- }), s("billing.overview.viewTransactions", "View Transactions")]
437
- }),
438
- /* @__PURE__ */ E("button", {
439
- type: "button",
440
- onClick: () => V && X(`/creditTransactions/${V.id}`),
441
- disabled: !V,
442
- className: "w-full flex items-center gap-3 px-3 py-2.5 text-sm text-left text-text-primary hover:bg-bg-sunken rounded-button transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
443
- children: [/* @__PURE__ */ T("div", {
444
- className: "size-9 rounded-lg bg-status-warning-bg-subtle flex items-center justify-center",
445
- children: /* @__PURE__ */ T(C, { className: "size-4 text-status-warning-text" })
446
- }), s("billing.overview.creditHistory", "Credit History")]
447
- }),
448
- /* @__PURE__ */ E("button", {
449
- type: "button",
450
- onClick: () => X("/checkout/credits"),
451
- className: "w-full flex items-center gap-3 px-3 py-2.5 text-sm text-left text-text-primary hover:bg-bg-sunken rounded-button transition-colors",
452
- children: [/* @__PURE__ */ T("div", {
453
- className: "size-9 rounded-lg bg-status-success-bg-subtle flex items-center justify-center",
454
- children: /* @__PURE__ */ T(Ie, { className: "size-4 text-status-success-text" })
455
- }), s("billing.overview.purchaseCredits", "Purchase Credits")]
456
- }),
457
- /* @__PURE__ */ E("button", {
458
- type: "button",
459
- onClick: () => V && X(`/usage?billingAccountId=${V.id}`),
460
- disabled: !V,
461
- className: "w-full flex items-center gap-3 px-3 py-2.5 text-sm text-left text-text-primary hover:bg-bg-sunken rounded-button transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
462
- children: [/* @__PURE__ */ T("div", {
463
- className: "size-9 rounded-lg bg-[var(--color-accent-soft)] flex items-center justify-center",
464
- children: /* @__PURE__ */ T(Pe, { className: "size-4 text-text-link" })
465
- }), s("billing.overview.usageAnalytics", "Usage Analytics")]
466
- })
467
- ]
468
- })]
469
- }), !Xe && /* @__PURE__ */ E(Ae, {
470
- treatment: "glass",
471
- glow: !0,
472
- className: "p-4 sm:p-5",
473
- children: [/* @__PURE__ */ E("div", {
474
- className: "flex items-start gap-3 mb-4",
475
- children: [/* @__PURE__ */ T("div", {
476
- className: "size-10 rounded-lg bg-bg-surface flex items-center justify-center flex-shrink-0 shadow-elevation-1",
477
- children: /* @__PURE__ */ T(Be, { className: "size-5 text-text-link" })
478
- }), /* @__PURE__ */ E("div", { children: [/* @__PURE__ */ T("h3", {
479
- className: "font-semibold text-text-primary",
480
- children: s("billing.overview.getStarted", "Get Started")
481
- }), /* @__PURE__ */ T("p", {
482
- className: "text-sm text-text-secondary mt-1",
483
- children: s("billing.overview.getStartedDescription", "Choose a plan that fits your needs to unlock all features")
484
- })] })]
485
- }), /* @__PURE__ */ E(Oe, {
486
- type: "button",
487
- onClick: () => X("/plans"),
488
- className: "w-full",
489
- children: [s("billing.overview.browsePlans", "Browse Plans"), /* @__PURE__ */ T(h, { className: "size-4" })]
490
- })]
491
- })]
492
- })]
493
- }), wt = /* @__PURE__ */ T(ve, {
494
- dataTour: "billing-overview-recommended-addons",
495
- addons: Ze,
496
- hasSubscription: Xe,
497
- onViewAddon: (e) => X(`/addons/${e}`),
498
- onPurchaseAddon: (e) => X(`/addons/${e}?action=purchase`),
499
- onViewAllAddons: () => X("/addons"),
500
- onAddToCart: gt,
501
- isInCart: _t,
502
- getCartQuantity: vt,
503
- onUpdateQuantity: yt,
504
- onRemoveFromCart: bt,
505
- maxAddons: 3,
506
- isLoading: $e
507
- }), Q = se(Y), $ = re(H), Tt = ie(Y), Et = /* @__PURE__ */ E("section", {
508
- className: "border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 p-4 sm:p-6 space-y-5",
509
- "data-tour": "billing-overview-plan-summary",
510
- children: [/* @__PURE__ */ E("div", {
511
- className: "flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",
512
- children: [/* @__PURE__ */ E("div", {
513
- className: "flex items-start gap-3",
514
- children: [/* @__PURE__ */ T("div", {
515
- className: "size-10 rounded-lg bg-[var(--color-accent-soft)] flex items-center justify-center flex-shrink-0",
516
- children: /* @__PURE__ */ T(y, { className: "size-5 text-text-link" })
517
- }), /* @__PURE__ */ E("div", { children: [
518
- /* @__PURE__ */ T("p", {
519
- className: "text-xs text-text-secondary",
520
- children: s("billing.overview.currentPlan", "Current plan")
521
- }),
522
- /* @__PURE__ */ T("p", {
523
- className: "text-lg font-semibold text-text-primary",
524
- children: Q ? Q.planName ?? s("billing.overview.subscription", "Subscription") : s("billing.overview.noPlan", "No plan yet")
525
- }),
526
- Q && Q.price !== null && Q.currency && /* @__PURE__ */ T("p", {
527
- className: "text-sm text-text-secondary",
528
- children: Q.duration ? ne(Q.price, Q.currency, Q.duration) : a(Q.price, Q.currency)
529
- })
530
- ] })]
531
- }), /* @__PURE__ */ E(Oe, {
532
- type: "button",
533
- onClick: () => X(Tt),
534
- children: [Q ? s("billing.overview.changePlan", "Change plan") : s("billing.overview.browsePlans", "Browse Plans"), /* @__PURE__ */ T(h, { className: "size-4" })]
535
- })]
536
- }), /* @__PURE__ */ E("div", {
537
- className: "grid grid-cols-1 sm:grid-cols-3 gap-4 border-t border-border-seam pt-4",
538
- children: [
539
- /* @__PURE__ */ E("div", {
540
- className: "flex items-start gap-3",
541
- children: [/* @__PURE__ */ T("div", {
542
- className: "size-9 rounded-lg bg-bg-sunken flex items-center justify-center flex-shrink-0",
543
- children: /* @__PURE__ */ T(Fe, { className: "size-4 text-text-secondary" })
544
- }), /* @__PURE__ */ E("div", { children: [/* @__PURE__ */ T("p", {
545
- className: "text-xs text-text-secondary",
546
- children: s("billing.overview.nextBill", "Next bill")
547
- }), /* @__PURE__ */ T("p", {
548
- className: "text-sm font-medium text-text-primary",
549
- children: Q?.nextBillDate ? o(Q.nextBillDate) : s("billing.overview.noNextBill", "None scheduled")
550
- })] })]
551
- }),
552
- /* @__PURE__ */ E("div", {
553
- className: "flex items-start gap-3",
554
- children: [/* @__PURE__ */ T("div", {
555
- className: "size-9 rounded-lg bg-bg-sunken flex items-center justify-center flex-shrink-0",
556
- children: /* @__PURE__ */ T(Le, { className: "size-4 text-text-secondary" })
557
- }), /* @__PURE__ */ E("div", { children: [
558
- /* @__PURE__ */ T("p", {
559
- className: "text-xs text-text-secondary",
560
- children: s("billing.overview.savedCard", "Saved card")
561
- }),
562
- $ ? /* @__PURE__ */ E("p", {
563
- className: "text-sm font-medium text-text-primary",
564
- children: [
565
- r($.brand),
566
- " ",
567
- te($.last4),
568
- i($.expiryMonth, $.expiryYear) && ` · ${i($.expiryMonth, $.expiryYear)}`
569
- ]
570
- }) : /* @__PURE__ */ T("p", {
571
- className: "text-sm text-text-secondary",
572
- children: s("billing.overview.noCard", "No card saved")
573
- }),
574
- /* @__PURE__ */ T("button", {
575
- type: "button",
576
- onClick: () => X("/payment-methods"),
577
- className: "text-xs text-text-link hover:underline mt-1",
578
- children: s("billing.overview.managePaymentMethods", "Payment methods")
579
- })
580
- ] })]
581
- }),
582
- V && /* @__PURE__ */ T(He, {
583
- billingAccountId: V.id,
584
- onViewAll: () => X("/invoices")
585
- })
586
- ]
587
- })]
588
- });
589
- return /* @__PURE__ */ E("div", {
181
+ }) : /* @__PURE__ */ y("div", {
590
182
  className: "px-4 sm:px-6 lg:px-8 py-4 sm:py-6 space-y-4 sm:space-y-8",
591
183
  children: [
592
- /* @__PURE__ */ E("header", {
184
+ /* @__PURE__ */ y("header", {
593
185
  className: "relative overflow-hidden rounded-card flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",
594
186
  children: [
595
- /* @__PURE__ */ T(De, { intensity: "subtle" }),
596
- /* @__PURE__ */ E("div", { children: [
597
- /* @__PURE__ */ T("h1", {
187
+ /* @__PURE__ */ v(_e, { intensity: "subtle" }),
188
+ /* @__PURE__ */ y("div", { children: [
189
+ /* @__PURE__ */ v("h1", {
598
190
  className: "text-2xl md:text-3xl font-semibold tracking-tight text-text-primary",
599
- children: /* @__PURE__ */ T(m, { children: s("billing.overview.title", "Billing Overview") })
191
+ children: /* @__PURE__ */ v(l, { children: b("billing.overview.title", "Billing Overview") })
600
192
  }),
601
- /* @__PURE__ */ T("p", {
193
+ /* @__PURE__ */ v("p", {
602
194
  className: "text-sm text-text-secondary mt-1",
603
- children: s("billing.overview.description", "Manage your billing accounts, subscriptions, and payment methods")
195
+ children: b("billing.overview.description", "Manage your billing accounts, subscriptions, and payment methods")
604
196
  }),
605
- /* @__PURE__ */ T(Ne, {
197
+ /* @__PURE__ */ v(xe, {
606
198
  className: "mt-3",
607
- children: s("billing.overview.purpose", "Your billing home base — see your current plan, credit balance and payment methods at a glance, and jump to transactions, usage, credits or new plans. Start here to understand what you are paying for and manage it.")
199
+ children: b("billing.overview.purpose", "Your billing home base — see your current plan, credit balance and payment methods at a glance, and jump to transactions, usage, credits or new plans. Start here to understand what you are paying for and manage it.")
608
200
  })
609
201
  ] }),
610
- /* @__PURE__ */ T(ke, {
611
- primary: oe(k, O.canManageBillingAccount, B.length) ? {
612
- label: s("billing.overview.newAccount", "New Account"),
613
- onSelect: () => N(!0),
614
- icon: /* @__PURE__ */ T(x, { className: "size-4" })
202
+ /* @__PURE__ */ v(ne, {
203
+ primary: w.canManageBillingAccount && z.length > 0 ? {
204
+ label: b("billing.overview.newAccount", "New Account"),
205
+ onSelect: () => O(!0),
206
+ icon: /* @__PURE__ */ v(m, { className: "size-4" })
615
207
  } : void 0,
616
208
  actions: [{
617
- label: s("billing.overview.refresh", "Refresh"),
209
+ label: b("billing.overview.refresh", "Refresh"),
618
210
  onSelect: () => {
619
- ht();
211
+ Ye();
620
212
  },
621
- icon: /* @__PURE__ */ T(S, { className: `size-4 ${W ? "animate-spin" : ""}` })
213
+ icon: /* @__PURE__ */ v(h, { className: `size-4 ${W ? "animate-spin" : ""}` })
622
214
  }]
623
215
  })
624
216
  ]
625
217
  }),
626
- k ? /* @__PURE__ */ E(w, { children: [Et, /* @__PURE__ */ T(Me, {
627
- storageKey: "billing.overview.more",
628
- label: s("billing.overview.moreOptions", "More options"),
629
- children: /* @__PURE__ */ E("div", {
630
- className: "space-y-4 sm:space-y-8",
218
+ z.length > 1 && /* @__PURE__ */ y("div", {
219
+ className: "relative",
220
+ "data-tour": "billing-overview-account-selector",
221
+ children: [/* @__PURE__ */ y("button", {
222
+ type: "button",
223
+ onClick: () => N(!M),
224
+ className: "w-full sm:w-auto flex items-center justify-between gap-3 px-4 py-3 border border-border-seam rounded-card bg-bg-surface hover:bg-bg-sunken hover:border-border-strong transition-all duration-200",
225
+ children: [/* @__PURE__ */ y("div", {
226
+ className: "flex items-center gap-3",
227
+ children: [/* @__PURE__ */ v("div", {
228
+ className: "size-9 rounded-lg bg-[var(--color-accent-soft)] flex items-center justify-center",
229
+ children: /* @__PURE__ */ v(u, { className: "size-4 text-text-link" })
230
+ }), /* @__PURE__ */ y("div", {
231
+ className: "text-left",
232
+ children: [/* @__PURE__ */ v("p", {
233
+ className: "text-sm font-medium text-text-primary",
234
+ children: B?.name || b("billing.overview.selectAccount", "Select Account")
235
+ }), /* @__PURE__ */ v("p", {
236
+ className: "text-xs text-text-secondary",
237
+ children: B?.email
238
+ })]
239
+ })]
240
+ }), /* @__PURE__ */ v(f, { className: `size-4 text-text-muted transition-transform ${M ? "rotate-180" : ""}` })]
241
+ }), M && /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("div", {
242
+ className: "fixed inset-0 z-10",
243
+ onClick: () => N(!1)
244
+ }), /* @__PURE__ */ v("div", {
245
+ className: "absolute top-full left-0 right-0 sm:right-auto mt-1 w-full sm:w-80 bg-bg-elevated border border-border-seam rounded-card shadow-elevation-3 z-20 py-1 max-h-60 overflow-y-auto",
246
+ children: z.map((e) => /* @__PURE__ */ y("button", {
247
+ type: "button",
248
+ onClick: () => Je(e),
249
+ className: "w-full flex items-center justify-between gap-3 px-4 py-3 hover:bg-bg-sunken transition-colors",
250
+ children: [/* @__PURE__ */ y("div", {
251
+ className: "flex items-center gap-3 min-w-0",
252
+ children: [/* @__PURE__ */ v("div", {
253
+ className: "size-9 rounded-lg bg-bg-sunken flex items-center justify-center flex-shrink-0",
254
+ children: /* @__PURE__ */ v(u, { className: "size-4 text-text-secondary" })
255
+ }), /* @__PURE__ */ y("div", {
256
+ className: "text-left min-w-0",
257
+ children: [/* @__PURE__ */ v("p", {
258
+ className: "text-sm font-medium text-text-primary truncate",
259
+ children: e.name
260
+ }), /* @__PURE__ */ v("p", {
261
+ className: "text-xs text-text-secondary truncate",
262
+ children: e.email
263
+ })]
264
+ })]
265
+ }), B?.id === e.id && /* @__PURE__ */ v(d, { className: "size-4 text-text-link flex-shrink-0" })]
266
+ }, e.id))
267
+ })] })]
268
+ }),
269
+ B && /* @__PURE__ */ y("div", {
270
+ className: "grid grid-cols-2 sm:grid-cols-4 gap-3 sm:gap-4",
271
+ "data-tour": "billing-overview-stats-row",
272
+ children: [
273
+ /* @__PURE__ */ v(r, {
274
+ className: "p-3 sm:p-5",
275
+ label: b("billing.overview.stats.creditBalance", "Credit Balance"),
276
+ value: `${(B.creditAmount || 0).toLocaleString()} Credits`,
277
+ icon: /* @__PURE__ */ v(g, { className: "size-5" })
278
+ }),
279
+ /* @__PURE__ */ v(r, {
280
+ className: "p-3 sm:p-5",
281
+ label: b("billing.overview.stats.activePlans", "Active Plans"),
282
+ value: H.length > 0 ? H.length === 1 ? H[0]?.plan?.name || "1 Plan" : `${H.length} ${b("billing.overview.stats.plansSuffix", "Plans")}` : b("billing.overview.stats.none", "None"),
283
+ icon: /* @__PURE__ */ v(h, { className: "size-5" })
284
+ }),
285
+ /* @__PURE__ */ v(r, {
286
+ className: "p-3 sm:p-5",
287
+ label: b("billing.overview.stats.paymentMethods", "Payment Methods"),
288
+ value: V.length,
289
+ icon: /* @__PURE__ */ v(u, { className: "size-5" })
290
+ }),
291
+ /* @__PURE__ */ v(r, {
292
+ className: "p-3 sm:p-5",
293
+ label: b("billing.overview.stats.paymentCurrency", "Payment Currency"),
294
+ value: B.currency || "USD",
295
+ icon: /* @__PURE__ */ v(u, { className: "size-5" })
296
+ })
297
+ ]
298
+ }),
299
+ /* @__PURE__ */ y("div", {
300
+ className: "grid grid-cols-1 lg:grid-cols-3 gap-4 sm:gap-6",
301
+ children: [/* @__PURE__ */ y("div", {
302
+ className: "lg:col-span-2 space-y-4 sm:space-y-6",
631
303
  children: [
632
- xt,
633
- St,
634
- Ct,
635
- wt
304
+ B && /* @__PURE__ */ v(le, {
305
+ dataTour: "billing-overview-billing-account-card",
306
+ account: B,
307
+ isDefault: B.isDefault ?? !1,
308
+ onEdit: () => B && Q(`/settings?billingAccountId=${B.id}`),
309
+ onViewTransactions: () => Q(`/transactions/${B.id}`),
310
+ onViewCreditTransactions: () => Q(`/creditTransactions/${B.id}`)
311
+ }),
312
+ /* @__PURE__ */ y("div", {
313
+ className: "space-y-3",
314
+ children: [H.length > 1 && /* @__PURE__ */ y("div", {
315
+ className: "relative",
316
+ children: [/* @__PURE__ */ y("button", {
317
+ type: "button",
318
+ onClick: () => R(!L),
319
+ className: "w-full sm:w-auto flex items-center justify-between gap-3 px-4 py-3 border border-border-seam rounded-card bg-bg-surface hover:bg-bg-sunken hover:border-border-strong transition-all duration-200",
320
+ children: [/* @__PURE__ */ y("div", {
321
+ className: "flex items-center gap-3",
322
+ children: [/* @__PURE__ */ v("div", {
323
+ className: "size-9 rounded-lg bg-[var(--color-accent-soft)] flex items-center justify-center",
324
+ children: /* @__PURE__ */ v(p, { className: "size-4 text-text-link" })
325
+ }), /* @__PURE__ */ y("div", {
326
+ className: "text-left",
327
+ children: [/* @__PURE__ */ y("p", {
328
+ className: "text-sm font-medium text-text-primary",
329
+ children: [Z?.plan?.name || b("billing.overview.selectSubscription", "Select Subscription"), Z?.plan?.product?.name && /* @__PURE__ */ y("span", {
330
+ className: "text-text-secondary font-normal",
331
+ children: [
332
+ " ",
333
+ "· ",
334
+ Z.plan.product.name
335
+ ]
336
+ })]
337
+ }), /* @__PURE__ */ y("p", {
338
+ className: "text-xs text-text-secondary",
339
+ children: [
340
+ H.length,
341
+ " ",
342
+ b("billing.overview.activeSubscriptions", "active subscriptions")
343
+ ]
344
+ })]
345
+ })]
346
+ }), /* @__PURE__ */ v(f, { className: `size-4 text-text-muted transition-transform ${L ? "rotate-180" : ""}` })]
347
+ }), L && /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("div", {
348
+ className: "fixed inset-0 z-10",
349
+ onClick: () => R(!1)
350
+ }), /* @__PURE__ */ v("div", {
351
+ className: "absolute top-full left-0 right-0 sm:right-auto mt-1 w-full sm:w-80 bg-bg-elevated border border-border-seam rounded-card shadow-elevation-3 z-20 py-1 max-h-60 overflow-y-auto",
352
+ children: H.map((e, t) => /* @__PURE__ */ y("button", {
353
+ type: "button",
354
+ onClick: () => {
355
+ I(t), R(!1);
356
+ },
357
+ className: "w-full flex items-center justify-between gap-3 px-4 py-3 hover:bg-bg-sunken transition-colors",
358
+ children: [/* @__PURE__ */ y("div", {
359
+ className: "flex items-center gap-3 min-w-0",
360
+ children: [/* @__PURE__ */ v("div", {
361
+ className: "size-9 rounded-lg bg-bg-sunken flex items-center justify-center flex-shrink-0",
362
+ children: /* @__PURE__ */ v(p, { className: "size-4 text-text-secondary" })
363
+ }), /* @__PURE__ */ y("div", {
364
+ className: "text-left min-w-0",
365
+ children: [/* @__PURE__ */ v("p", {
366
+ className: "text-sm font-medium text-text-primary truncate",
367
+ children: e.plan?.name || b("billing.overview.subscription", "Subscription")
368
+ }), /* @__PURE__ */ y("p", {
369
+ className: "text-xs text-text-secondary truncate",
370
+ children: [
371
+ e.plan?.product?.name || b("billing.overview.unknownProduct", "Unknown Product"),
372
+ " ",
373
+ "· ",
374
+ b("billing.overview.ends", "Ends"),
375
+ " ",
376
+ new Date(e.endDate).toLocaleDateString()
377
+ ]
378
+ })]
379
+ })]
380
+ }), F === t && /* @__PURE__ */ v(d, { className: "size-4 text-text-link flex-shrink-0" })]
381
+ }, e.id))
382
+ })] })]
383
+ }), /* @__PURE__ */ v(de, {
384
+ dataTour: "billing-overview-active-subscription-card",
385
+ subscription: Z,
386
+ onViewDetails: () => Z && Q(a(`/subscriptions/${Z.id}`, Z.billingAccountId ?? B?.id)),
387
+ onUpgrade: () => Z && Q(a(`/subscriptions/${Z.id}/upgrade`, Z.billingAccountId ?? B?.id)),
388
+ onManage: () => B && Q(`/subscriptions?billingAccountId=${B.id}`),
389
+ onPurchasePlan: () => Q("/plans")
390
+ })]
391
+ }),
392
+ B && /* @__PURE__ */ v(ue, {
393
+ dataTour: "billing-overview-payment-methods-section",
394
+ paymentMethods: V,
395
+ billingAccountId: B.id,
396
+ onAddPaymentMethod: We,
397
+ onSetDefault: Ke,
398
+ onDelete: qe,
399
+ isLoading: W
400
+ })
636
401
  ]
637
- })
638
- })] }) : /* @__PURE__ */ E(w, { children: [
639
- xt,
640
- St,
641
- Ct,
642
- wt
643
- ] }),
644
- /* @__PURE__ */ T(xe, {}),
645
- We && /* @__PURE__ */ T(de, { onDismiss: () => Ge(!1) }),
646
- /* @__PURE__ */ T(ye, {
647
- isOpen: M,
402
+ }), /* @__PURE__ */ y("div", {
403
+ className: "space-y-4 sm:space-y-6",
404
+ children: [/* @__PURE__ */ y("section", {
405
+ className: "border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 p-4 sm:p-5",
406
+ "data-tour": "billing-overview-quick-actions",
407
+ children: [/* @__PURE__ */ v("h3", {
408
+ className: "font-semibold text-text-primary mb-4",
409
+ children: b("billing.overview.quickActions", "Quick Actions")
410
+ }), /* @__PURE__ */ y("div", {
411
+ className: "space-y-1.5",
412
+ children: [
413
+ /* @__PURE__ */ y("button", {
414
+ type: "button",
415
+ onClick: () => B && Q(`/transactions/${B.id}`),
416
+ disabled: !B,
417
+ className: "w-full flex items-center gap-3 px-3 py-2.5 text-sm text-left text-text-primary hover:bg-bg-sunken rounded-button transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
418
+ children: [/* @__PURE__ */ v("div", {
419
+ className: "size-9 rounded-lg bg-status-info-bg-subtle flex items-center justify-center",
420
+ children: /* @__PURE__ */ v(Ee, { className: "size-4 text-status-info-text" })
421
+ }), b("billing.overview.viewTransactions", "View Transactions")]
422
+ }),
423
+ /* @__PURE__ */ y("button", {
424
+ type: "button",
425
+ onClick: () => B && Q(`/creditTransactions/${B.id}`),
426
+ disabled: !B,
427
+ className: "w-full flex items-center gap-3 px-3 py-2.5 text-sm text-left text-text-primary hover:bg-bg-sunken rounded-button transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
428
+ children: [/* @__PURE__ */ v("div", {
429
+ className: "size-9 rounded-lg bg-status-warning-bg-subtle flex items-center justify-center",
430
+ children: /* @__PURE__ */ v(g, { className: "size-4 text-status-warning-text" })
431
+ }), b("billing.overview.creditHistory", "Credit History")]
432
+ }),
433
+ /* @__PURE__ */ y("button", {
434
+ type: "button",
435
+ onClick: () => Q("/checkout/credits"),
436
+ className: "w-full flex items-center gap-3 px-3 py-2.5 text-sm text-left text-text-primary hover:bg-bg-sunken rounded-button transition-colors",
437
+ children: [/* @__PURE__ */ v("div", {
438
+ className: "size-9 rounded-lg bg-status-success-bg-subtle flex items-center justify-center",
439
+ children: /* @__PURE__ */ v(we, { className: "size-4 text-status-success-text" })
440
+ }), b("billing.overview.purchaseCredits", "Purchase Credits")]
441
+ }),
442
+ /* @__PURE__ */ y("button", {
443
+ type: "button",
444
+ onClick: () => B && Q(`/usage?billingAccountId=${B.id}`),
445
+ disabled: !B,
446
+ className: "w-full flex items-center gap-3 px-3 py-2.5 text-sm text-left text-text-primary hover:bg-bg-sunken rounded-button transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
447
+ children: [/* @__PURE__ */ v("div", {
448
+ className: "size-9 rounded-lg bg-[var(--color-accent-soft)] flex items-center justify-center",
449
+ children: /* @__PURE__ */ v(Se, { className: "size-4 text-text-link" })
450
+ }), b("billing.overview.usageAnalytics", "Usage Analytics")]
451
+ })
452
+ ]
453
+ })]
454
+ }), !U && /* @__PURE__ */ y(ye, {
455
+ treatment: "glass",
456
+ glow: !0,
457
+ className: "p-4 sm:p-5",
458
+ children: [/* @__PURE__ */ y("div", {
459
+ className: "flex items-start gap-3 mb-4",
460
+ children: [/* @__PURE__ */ v("div", {
461
+ className: "size-10 rounded-lg bg-bg-surface flex items-center justify-center flex-shrink-0 shadow-elevation-1",
462
+ children: /* @__PURE__ */ v(De, { className: "size-5 text-text-link" })
463
+ }), /* @__PURE__ */ y("div", { children: [/* @__PURE__ */ v("h3", {
464
+ className: "font-semibold text-text-primary",
465
+ children: b("billing.overview.getStarted", "Get Started")
466
+ }), /* @__PURE__ */ v("p", {
467
+ className: "text-sm text-text-secondary mt-1",
468
+ children: b("billing.overview.getStartedDescription", "Choose a plan that fits your needs to unlock all features")
469
+ })] })]
470
+ }), /* @__PURE__ */ y(ve, {
471
+ type: "button",
472
+ onClick: () => Q("/plans"),
473
+ className: "w-full",
474
+ children: [b("billing.overview.browsePlans", "Browse Plans"), /* @__PURE__ */ v(Ce, { className: "size-4" })]
475
+ })]
476
+ })]
477
+ })]
478
+ }),
479
+ /* @__PURE__ */ v(fe, {
480
+ dataTour: "billing-overview-recommended-addons",
481
+ addons: Ne,
482
+ hasSubscription: U,
483
+ onViewAddon: (e) => Q(`/addons/${e}`),
484
+ onPurchaseAddon: (e) => Q(`/addons/${e}?action=purchase`),
485
+ onViewAllAddons: () => Q("/addons"),
486
+ onAddToCart: Xe,
487
+ isInCart: Ze,
488
+ getCartQuantity: Qe,
489
+ onUpdateQuantity: $e,
490
+ onRemoveFromCart: et,
491
+ maxAddons: 3,
492
+ isLoading: Pe
493
+ }),
494
+ /* @__PURE__ */ v(ce, {}),
495
+ je && /* @__PURE__ */ v(re, { onDismiss: () => j(!1) }),
496
+ /* @__PURE__ */ v(i, {
497
+ isOpen: D,
648
498
  onClose: () => {
649
- N(!1), F(null);
499
+ O(!1), A(null);
650
500
  },
651
- onSubmit: lt,
652
- isSubmitting: ct,
653
- error: P
501
+ onSubmit: Ue,
502
+ isSubmitting: He,
503
+ error: k
654
504
  }),
655
- V && /* @__PURE__ */ T(be, {
656
- isOpen: Ke,
657
- onClose: () => qe(!1),
658
- billingAccountId: V.id,
659
- currency: V.currency,
660
- country: V.billingAddresses?.[0]?.country,
661
- onSuccess: dt
505
+ B && /* @__PURE__ */ v(pe, {
506
+ isOpen: Me,
507
+ onClose: () => P(!1),
508
+ billingAccountId: B.id,
509
+ currency: B.currency,
510
+ country: B.billingAddresses?.[0]?.country,
511
+ onSuccess: Ge
662
512
  })
663
513
  ]
664
- });
514
+ }) : /* @__PURE__ */ v(te, { message: "You don't have permission to view billing information." });
665
515
  };
666
- export { D as OverviewPage };
516
+ export { b as OverviewPage };
667
517
 
668
518
  //# sourceMappingURL=OverviewPage.js.map