@burdenoff/microfe-billing 2026.1113.2 → 2026.1113.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.
Files changed (105) hide show
  1. package/dist/billing/BillingRoot.js +83 -77
  2. package/dist/billing/BillingRoot.js.map +1 -1
  3. package/dist/billing/modules/addons/pages/AddonBrowseDetailPage.js +78 -78
  4. package/dist/billing/modules/addons/pages/AddonCreatePage.js +70 -70
  5. package/dist/billing/modules/addons/pages/AddonDetailPage.js +72 -72
  6. package/dist/billing/modules/addons/pages/AddonEditPage.js +79 -79
  7. package/dist/billing/modules/addons/pages/AddonsBrowsePage.js +224 -224
  8. package/dist/billing/modules/addons/pages/AddonsListPage.js +186 -186
  9. package/dist/billing/modules/affiliate/pages/AffiliateDashboardPage.js +168 -168
  10. package/dist/billing/modules/affiliate/pages/AffiliateDashboardPage.js.map +1 -1
  11. package/dist/billing/modules/analytics/pages/AnalyticsPage.js +88 -88
  12. package/dist/billing/modules/billing/hooks/index.js +5 -5
  13. package/dist/billing/modules/billing/hooks/useInvoices.js +39 -20
  14. package/dist/billing/modules/billing/hooks/useInvoices.js.map +1 -1
  15. package/dist/billing/modules/billing/index.js +14 -14
  16. package/dist/billing/modules/billing/pages/BillingWebhookLogsPage.js +92 -92
  17. package/dist/billing/modules/billing/pages/InvoiceDetailPage.js +160 -160
  18. package/dist/billing/modules/billing/pages/InvoiceDetailPage.js.map +1 -1
  19. package/dist/billing/modules/billing/pages/InvoicesListPage.js +100 -100
  20. package/dist/billing/modules/billing/pages/OrderCallbackLogsPage.js +105 -105
  21. package/dist/billing/modules/billing/pages/PaymentMethodsPage.js +37 -37
  22. package/dist/billing/modules/billing/pages/RefundIssueLogsPage.js +41 -41
  23. package/dist/billing/modules/billing/pages/RefundsPage.js +334 -334
  24. package/dist/billing/modules/billing/pages/RefundsPage.js.map +1 -1
  25. package/dist/billing/modules/billing/pages/TransactionsPage.js +174 -174
  26. package/dist/billing/modules/billing/pages/TransactionsPage.js.map +1 -1
  27. package/dist/billing/modules/billing/pages/UserRefundsPage.js +24 -24
  28. package/dist/billing/modules/billing/pages/UserRefundsPage.js.map +1 -1
  29. package/dist/billing/modules/checkout/components/OrderSummary.js +71 -71
  30. package/dist/billing/modules/checkout/pages/CheckoutPage.js +646 -625
  31. package/dist/billing/modules/checkout/pages/CheckoutPage.js.map +1 -1
  32. package/dist/billing/modules/checkout/utils/checkoutOptions.d.ts +23 -0
  33. package/dist/billing/modules/checkout/utils/checkoutOptions.js +8 -0
  34. package/dist/billing/modules/checkout/utils/checkoutOptions.js.map +1 -0
  35. package/dist/billing/modules/coupons/pages/CouponDetailPage.js +112 -112
  36. package/dist/billing/modules/coupons/pages/CouponsListPage.js +118 -118
  37. package/dist/billing/modules/coupons/pages/CouponsListPage.js.map +1 -1
  38. package/dist/billing/modules/coupons/pages/CreateCouponPage.js +119 -119
  39. package/dist/billing/modules/coupons/pages/EditCouponPage.js +82 -82
  40. package/dist/billing/modules/credits/pages/AdminCreditsPage.js +30 -30
  41. package/dist/billing/modules/credits/pages/CreditTransactionsPage.js +77 -77
  42. package/dist/billing/modules/credits/pages/CreditWithdrawalPage.js +144 -144
  43. package/dist/billing/modules/credits/pages/CreditsPage.js +67 -67
  44. package/dist/billing/modules/dashboard/pages/OverviewPage.js +594 -442
  45. package/dist/billing/modules/dashboard/pages/OverviewPage.js.map +1 -1
  46. package/dist/billing/modules/dashboard/utils/overviewSummary.d.ts +46 -0
  47. package/dist/billing/modules/dashboard/utils/overviewSummary.js +37 -0
  48. package/dist/billing/modules/dashboard/utils/overviewSummary.js.map +1 -0
  49. package/dist/billing/modules/discounts/pages/DiscountsListPage.js +199 -199
  50. package/dist/billing/modules/discounts/pages/DiscountsListPage.js.map +1 -1
  51. package/dist/billing/modules/earnings/pages/DeveloperRevenueAdminPage.js +64 -64
  52. package/dist/billing/modules/earnings/pages/DeveloperRevenueOrgDetailPage.js +122 -122
  53. package/dist/billing/modules/earnings/pages/DeveloperRevenueOrgDetailPage.js.map +1 -1
  54. package/dist/billing/modules/earnings/pages/EarningsPage.js +102 -102
  55. package/dist/billing/modules/earnings/pages/EarningsPage.js.map +1 -1
  56. package/dist/billing/modules/earnings/pages/PayoutAdminPage.js +178 -178
  57. package/dist/billing/modules/earnings/pages/PayoutAdminPage.js.map +1 -1
  58. package/dist/billing/modules/earnings/pages/PayoutsPage.js +107 -107
  59. package/dist/billing/modules/earnings/pages/PayoutsPage.js.map +1 -1
  60. package/dist/billing/modules/plans/pages/PlanAssignFreePage.js +54 -54
  61. package/dist/billing/modules/plans/pages/PlanBrowseDetailPage.js +94 -94
  62. package/dist/billing/modules/plans/pages/PlanCreatePage.js +73 -73
  63. package/dist/billing/modules/plans/pages/PlanDetailPage.js +96 -96
  64. package/dist/billing/modules/plans/pages/PlanEditPage.js +16 -16
  65. package/dist/billing/modules/plans/pages/PlanEditPage.js.map +1 -1
  66. package/dist/billing/modules/plans/pages/PlansBrowsePage.js +100 -100
  67. package/dist/billing/modules/plans/pages/PlansListPage.js +88 -88
  68. package/dist/billing/modules/promotions/pages/CreatePromotionPage.js +60 -60
  69. package/dist/billing/modules/promotions/pages/PromotionsListPage.js +37 -37
  70. package/dist/billing/modules/quota/pages/QuotaAssignFreePage.js +62 -62
  71. package/dist/billing/modules/quota/pages/QuotaPage.js +1 -1
  72. package/dist/billing/modules/quota/pages/QuotaTemplateCreatePage.js +69 -69
  73. package/dist/billing/modules/quota/pages/QuotaTemplateDetailPage.js +76 -76
  74. package/dist/billing/modules/quota/pages/QuotaTemplateEditPage.js +80 -80
  75. package/dist/billing/modules/quota/pages/QuotaTemplatesListPage.js +95 -95
  76. package/dist/billing/modules/settings/pages/SettingsPage.js +134 -134
  77. package/dist/billing/modules/settings/pages/SettingsPage.js.map +1 -1
  78. package/dist/billing/modules/settings/pages/TeamPermissionsPage.js +62 -62
  79. package/dist/billing/modules/settings/pages/TeamPermissionsPage.js.map +1 -1
  80. package/dist/billing/modules/subscriptions/components/ManageSeatsModal.js +36 -36
  81. package/dist/billing/modules/subscriptions/pages/SubscriptionDetailPage.js +534 -410
  82. package/dist/billing/modules/subscriptions/pages/SubscriptionDetailPage.js.map +1 -1
  83. package/dist/billing/modules/subscriptions/pages/SubscriptionsListPage.js +111 -111
  84. package/dist/billing/modules/subscriptions/pages/UpgradeSubscriptionPage.js +166 -160
  85. package/dist/billing/modules/subscriptions/pages/UpgradeSubscriptionPage.js.map +1 -1
  86. package/dist/billing/modules/subscriptions/utils/subscriptionDetailView.d.ts +30 -0
  87. package/dist/billing/modules/subscriptions/utils/subscriptionDetailView.js +20 -0
  88. package/dist/billing/modules/subscriptions/utils/subscriptionDetailView.js.map +1 -0
  89. package/dist/billing/modules/subscriptions/utils/upgradeAccess.d.ts +10 -0
  90. package/dist/billing/modules/subscriptions/utils/upgradeAccess.js +7 -0
  91. package/dist/billing/modules/subscriptions/utils/upgradeAccess.js.map +1 -0
  92. package/dist/billing/modules/usage/pages/UsagePage.js +722 -591
  93. package/dist/billing/modules/usage/pages/UsagePage.js.map +1 -1
  94. package/dist/billing/modules/usage/utils/usageHealth.d.ts +63 -0
  95. package/dist/billing/modules/usage/utils/usageHealth.js +43 -0
  96. package/dist/billing/modules/usage/utils/usageHealth.js.map +1 -0
  97. package/dist/billing/shared/components/EmptyState.js +3 -3
  98. package/dist/billing/shared/components/MoneyActionDialog.js +12 -12
  99. package/dist/billing/shared/ui/MetricCard.js +13 -13
  100. package/dist/billing/shared/utils/format.js +16 -4
  101. package/dist/billing/shared/utils/format.js.map +1 -1
  102. package/dist/billing/shared/utils/index.js +8 -8
  103. package/dist/generated/global-operations.js +294 -286
  104. package/dist/generated/global-operations.js.map +1 -1
  105. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"AffiliateDashboardPage.js","names":["journeyColumns","journey","formatDateTime","AffiliateDashboardPage","permissions","useBillingPermissions","isFluidgrids","useIsFluidgridsVariant","codeToDeactivate","setCodeToDeactivate","useState","isDeactivating","setIsDeactivating","deactivateError","setDeactivateError","useBillingEventEmitter","useBilling","codes","setCodes","journeys","setJourneys","analytics","setAnalytics","loading","setLoading","error","setError","selectedCodeId","setSelectedCodeId","form","setForm","requestContext","useMemo","apiGatewayUrl","authToken","orgId","loadData","useCallback","loadedCodes","loadedAnalytics","loadedJourneys","fetchMyAffiliateCodes","fetchMyAffiliateAnalytics","fetchMyAffiliateJourneys","loadError","useEffect","AccessDenied","isServerError","ServerError","selectedCode","item","handleSubmit","updateAffiliateCode","emit","createdCode","createAffiliateCode","submitError","handleEdit","code","confirmDeactivate","handleDeactivate","err","deactivateAffiliateCode","codeId","handleQuickNote","note","addAffiliateCodeNote","metricCards","Ticket","Users","Link2","formatCurrency","TrendingUp","MoneyActionDialog","PageHeader","CTAOverflowMenu","RefreshCw","PagePurpose","EmphasisPanel","StatCard","card","Plus","current","event","IllustratedEmptyState","shareUrl","StickyNote","ResponsiveTable"],"sources":["../../../../../src/billing/modules/affiliate/pages/AffiliateDashboardPage.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState, type FC } from 'react';\nimport { Link2, Plus, RefreshCw, StickyNote, Ticket, TrendingUp, Users } from 'lucide-react';\nimport { ResponsiveTable, type ResponsiveTableColumn } from '@burdenoff/fe-libs/ui';\n\nimport { useBilling } from '../../../providers/BillingProvider';\nimport { useBillingEventEmitter } from '../../../hooks/useBillingEventEmitter';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useIsFluidgridsVariant } from '../../../hooks/useBillingVariant';\nimport { MoneyActionDialog } from '../../../shared/components';\nimport { AccessDenied, PageHeader, ServerError, StatCard } from '../../../shared/components';\nimport {\n CTAOverflowMenu,\n PagePurpose,\n EmphasisPanel,\n IllustratedEmptyState,\n} from '@burdenoff/fe-libs/ui';\nimport { formatCurrency, formatDateTime, isServerError } from '../../../shared/utils';\n\nconst journeyColumns: ResponsiveTableColumn<AffiliateJourney>[] = [\n { key: 'code', header: 'Code', priority: 'primary', cell: (journey) => journey.codeValue },\n { key: 'product', header: 'Product', cell: (journey) => journey.productSlug },\n {\n key: 'path',\n header: 'Path',\n cell: (journey) => journey.currentPath || journey.landingPath || '-',\n },\n { key: 'country', header: 'Country', cell: (journey) => journey.geographyCountry || '-' },\n { key: 'status', header: 'Status', cell: (journey) => journey.status },\n {\n key: 'visited',\n header: 'Visited',\n cell: (journey) => formatDateTime(journey.lastVisitedAt),\n },\n];\nimport {\n addAffiliateCodeNote,\n createAffiliateCode,\n deactivateAffiliateCode,\n fetchMyAffiliateAnalytics,\n fetchMyAffiliateCodes,\n fetchMyAffiliateJourneys,\n updateAffiliateCode,\n type AffiliateCode,\n type AffiliateJourney,\n type AffiliateAnalyticsSummary,\n} from '../api';\n\nexport const AffiliateDashboardPage: FC = () => {\n const permissions = useBillingPermissions();\n const isFluidgrids = useIsFluidgridsVariant();\n const [codeToDeactivate, setCodeToDeactivate] = useState<{ id: string; label: string } | null>(\n null\n );\n const [isDeactivating, setIsDeactivating] = useState(false);\n const [deactivateError, setDeactivateError] = useState<string | null>(null);\n const { emit } = useBillingEventEmitter();\n const { apiGatewayUrl, authToken, orgId } = useBilling();\n\n const [codes, setCodes] = useState<AffiliateCode[]>([]);\n const [journeys, setJourneys] = useState<AffiliateJourney[]>([]);\n const [analytics, setAnalytics] = useState<AffiliateAnalyticsSummary | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const [selectedCodeId, setSelectedCodeId] = useState<string | null>(null);\n const [form, setForm] = useState({\n label: '',\n description: '',\n notes: '',\n productSlug: '',\n destinationPath: '',\n destinationUrl: '',\n });\n\n const requestContext = useMemo(\n () => ({\n apiGatewayUrl,\n authToken,\n orgId,\n }),\n [apiGatewayUrl, authToken, orgId]\n );\n\n const loadData = useCallback(async () => {\n setLoading(true);\n setError(null);\n try {\n const [loadedCodes, loadedAnalytics, loadedJourneys] = await Promise.all([\n fetchMyAffiliateCodes(requestContext),\n fetchMyAffiliateAnalytics(requestContext),\n fetchMyAffiliateJourneys(requestContext),\n ]);\n setCodes(loadedCodes);\n setAnalytics(loadedAnalytics);\n setJourneys(loadedJourneys);\n } catch (loadError) {\n setError(\n loadError instanceof Error ? loadError : new Error('Failed to load affiliate dashboard')\n );\n } finally {\n setLoading(false);\n }\n }, [requestContext]);\n\n useEffect(() => {\n void loadData();\n }, [loadData]);\n\n if (!permissions.canViewBillingAccount) {\n return <AccessDenied message=\"You don't have permission to view affiliate analytics.\" />;\n }\n\n if (error && isServerError(error)) {\n return (\n <ServerError\n title=\"Affiliate service unavailable\"\n message={error.message}\n onRetry={() => void loadData()}\n showRetry\n />\n );\n }\n\n const selectedCode = codes.find((item) => item.id === selectedCodeId) ?? null;\n\n const handleSubmit = async () => {\n if (!form.productSlug.trim()) {\n setError(new Error('Product slug is required'));\n return;\n }\n\n try {\n if (selectedCode) {\n await updateAffiliateCode(\n selectedCode.id,\n {\n label: form.label,\n description: form.description,\n notes: form.notes,\n destinationPath: form.destinationPath,\n destinationUrl: form.destinationUrl,\n },\n requestContext\n );\n emit('billing.affiliate_code.updated', {\n route: '/billing/affiliate',\n entityId: selectedCode.id,\n source: 'affiliate-dashboard',\n });\n } else {\n const createdCode = await createAffiliateCode(\n {\n label: form.label,\n description: form.description,\n notes: form.notes,\n productSlug: form.productSlug,\n destinationPath: form.destinationPath,\n destinationUrl: form.destinationUrl,\n },\n requestContext\n );\n emit('billing.affiliate_code.created', {\n route: '/billing/affiliate',\n entityId: createdCode.id,\n source: 'affiliate-dashboard',\n });\n }\n\n setSelectedCodeId(null);\n setForm({\n label: '',\n description: '',\n notes: '',\n productSlug: '',\n destinationPath: '',\n destinationUrl: '',\n });\n await loadData();\n } catch (submitError) {\n setError(\n submitError instanceof Error ? submitError : new Error('Failed to save affiliate code')\n );\n }\n };\n\n const handleEdit = (code: AffiliateCode) => {\n setSelectedCodeId(code.id);\n setForm({\n label: code.label ?? '',\n description: code.description ?? '',\n notes: code.notes ?? '',\n productSlug: code.productSlug,\n destinationPath: code.destinationPath ?? '',\n destinationUrl: code.destinationUrl ?? '',\n });\n };\n\n const confirmDeactivate = async () => {\n if (!codeToDeactivate) return;\n setIsDeactivating(true);\n setDeactivateError(null);\n try {\n await handleDeactivate(codeToDeactivate.id);\n setCodeToDeactivate(null);\n } catch (err) {\n setDeactivateError(err instanceof Error ? err.message : 'Could not deactivate this code.');\n } finally {\n setIsDeactivating(false);\n }\n };\n\n const handleDeactivate = async (codeId: string) => {\n await deactivateAffiliateCode(codeId, requestContext);\n emit('billing.affiliate_code.deactivated', {\n route: '/billing/affiliate',\n entityId: codeId,\n source: 'affiliate-dashboard',\n });\n await loadData();\n };\n\n const handleQuickNote = async (codeId: string) => {\n const note = window.prompt('Add an internal note for this affiliate code');\n if (!note) return;\n await addAffiliateCodeNote(codeId, note, requestContext);\n emit('billing.affiliate_code.note_added', {\n route: '/billing/affiliate',\n entityId: codeId,\n source: 'affiliate-dashboard',\n });\n await loadData();\n };\n\n const metricCards = analytics\n ? [\n { title: 'Codes', value: analytics.totalCodes, icon: <Ticket className=\"size-5\" /> },\n { title: 'Visits', value: analytics.totalVisits, icon: <Users className=\"size-5\" /> },\n { title: 'Journeys', value: analytics.totalJourneys, icon: <Link2 className=\"size-5\" /> },\n {\n title: 'Revenue influenced',\n value: formatCurrency(analytics.totalRevenueAmount, 'USD'),\n icon: <TrendingUp className=\"size-5\" />,\n },\n ]\n : [];\n\n return (\n <div className=\"space-y-6 p-6\">\n {isFluidgrids && (\n <MoneyActionDialog\n open={codeToDeactivate !== null}\n tone=\"danger\"\n title=\"Deactivate this affiliate code?\"\n description=\"The code stops tracking new visits straight away. Visits and journeys already recorded are kept.\"\n details={[{ label: 'Code', value: codeToDeactivate?.label ?? '' }]}\n confirmLabel=\"Deactivate code\"\n busyLabel=\"Deactivating…\"\n isBusy={isDeactivating}\n error={deactivateError}\n onConfirm={() => void confirmDeactivate()}\n onCancel={() => setCodeToDeactivate(null)}\n />\n )}\n <PageHeader\n title=\"Affiliate codes\"\n description=\"Create referral codes, add internal notes, and monitor attributed journeys.\"\n actions={\n <CTAOverflowMenu\n actions={[\n {\n label: 'Refresh',\n onSelect: () => void loadData(),\n icon: <RefreshCw className=\"size-4\" />,\n },\n ]}\n />\n }\n />\n\n <PagePurpose>\n Generate referral links for any product, share them, and see exactly what they drive —\n visits, signups, paid conversions and the rewards you have earned. Create and manage your\n codes on the left and watch attributed visitor journeys on the right.\n </PagePurpose>\n\n {loading ? (\n <div className=\"grid gap-4 md:grid-cols-2 xl:grid-cols-4\">\n {[1, 2, 3, 4].map((item) => (\n <div\n key={item}\n className=\"h-28 animate-pulse rounded-lg border border-border-subtle bg-bg-surface\"\n />\n ))}\n </div>\n ) : analytics ? (\n <EmphasisPanel className=\"p-4 sm:p-5\">\n <div className=\"grid gap-4 md:grid-cols-2 xl:grid-cols-4\">\n {metricCards.map((card) => (\n <StatCard key={card.title} label={card.title} value={card.value} icon={card.icon} />\n ))}\n </div>\n </EmphasisPanel>\n ) : null}\n\n {error && !isServerError(error) ? (\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4 text-sm text-status-error-text\">\n {error.message}\n </div>\n ) : null}\n\n <div className=\"grid gap-6 xl:grid-cols-[1.1fr,1.9fr]\">\n <section className=\"rounded-lg border border-border-seam bg-bg-surface p-4 xl:sticky xl:top-6 xl:self-start\">\n <div className=\"mb-4 flex items-center justify-between\">\n <h2 className=\"text-lg font-semibold text-text-primary\">\n {selectedCode ? 'Update affiliate code' : 'Create affiliate code'}\n </h2>\n {!selectedCode ? <Plus className=\"size-4 text-text-secondary\" /> : null}\n </div>\n\n <div className=\"space-y-3\">\n <input\n value={form.label}\n onChange={(event) =>\n setForm((current) => ({ ...current, label: event.target.value }))\n }\n placeholder=\"Label\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <input\n value={form.productSlug}\n onChange={(event) =>\n setForm((current) => ({ ...current, productSlug: event.target.value }))\n }\n placeholder=\"Product slug (eg. bigconsole)\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n disabled={Boolean(selectedCode)}\n />\n <input\n value={form.destinationPath}\n onChange={(event) =>\n setForm((current) => ({ ...current, destinationPath: event.target.value }))\n }\n placeholder=\"Destination path (eg. /pricing)\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <input\n value={form.destinationUrl}\n onChange={(event) =>\n setForm((current) => ({ ...current, destinationUrl: event.target.value }))\n }\n placeholder=\"Absolute destination URL (optional)\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <textarea\n value={form.description}\n onChange={(event) =>\n setForm((current) => ({ ...current, description: event.target.value }))\n }\n placeholder=\"Description\"\n className=\"min-h-24 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <textarea\n value={form.notes}\n onChange={(event) =>\n setForm((current) => ({ ...current, notes: event.target.value }))\n }\n placeholder=\"Internal notes\"\n className=\"min-h-24 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n </div>\n\n <div className=\"mt-4 flex flex-wrap gap-3\">\n <button\n type=\"button\"\n onClick={() => void handleSubmit()}\n className=\"rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text\"\n >\n {selectedCode ? 'Save changes' : 'Create code'}\n </button>\n {selectedCode ? (\n <button\n type=\"button\"\n onClick={() => {\n setSelectedCodeId(null);\n setForm({\n label: '',\n description: '',\n notes: '',\n productSlug: '',\n destinationPath: '',\n destinationUrl: '',\n });\n }}\n className=\"rounded-md border border-border-subtle bg-bg-surface px-4 py-2 text-sm font-medium text-text-primary\"\n >\n Cancel\n </button>\n ) : null}\n </div>\n </section>\n\n <section className=\"space-y-4\">\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\">\n <h2 className=\"mb-4 text-lg font-semibold text-text-primary\">My codes</h2>\n {codes.length === 0 && !loading ? (\n <IllustratedEmptyState\n illustration=\"empty-data\"\n title=\"No affiliate codes yet\"\n description=\"Create your first code to start tracking attributable journeys.\"\n />\n ) : (\n <div className=\"space-y-4\">\n {codes.map((code) => {\n const shareUrl =\n code.destinationUrl ||\n `https://${code.productSlug}.com${code.destinationPath || ''}?ref=${code.code}`;\n return (\n <div\n key={code.id}\n className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\"\n >\n <div className=\"flex flex-wrap items-start justify-between gap-4\">\n <div>\n <p className=\"text-sm font-semibold text-text-primary\">\n {code.label || code.code}\n </p>\n <p className=\"text-xs text-text-secondary\">\n {code.code} · {code.productSlug}\n </p>\n <p className=\"mt-1 break-all text-xs text-text-secondary\">{shareUrl}</p>\n </div>\n <div className=\"flex flex-wrap gap-2\">\n <button\n type=\"button\"\n onClick={() => handleEdit(code)}\n className=\"rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary\"\n >\n Edit\n </button>\n <button\n type=\"button\"\n onClick={() => void handleQuickNote(code.id)}\n className=\"inline-flex items-center gap-1 rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary\"\n >\n <StickyNote className=\"size-3.5\" />\n Note\n </button>\n {code.status === 'ACTIVE' ? (\n <button\n type=\"button\"\n onClick={() =>\n isFluidgrids\n ? (setDeactivateError(null),\n setCodeToDeactivate({\n id: code.id,\n label: code.label || code.code,\n }))\n : void handleDeactivate(code.id)\n }\n className=\"rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-status-error-text\"\n >\n Deactivate\n </button>\n ) : null}\n </div>\n </div>\n <div className=\"mt-4 grid gap-3 sm:grid-cols-2 xl:grid-cols-4\">\n <div className=\"rounded-md border border-border-subtle bg-bg-surface p-3\">\n <p className=\"text-xs text-text-secondary\">Visits</p>\n <p className=\"text-lg font-semibold text-text-primary\">\n {code.totalVisits}\n </p>\n </div>\n <div className=\"rounded-md border border-border-subtle bg-bg-surface p-3\">\n <p className=\"text-xs text-text-secondary\">Signups</p>\n <p className=\"text-lg font-semibold text-text-primary\">\n {code.totalSignups}\n </p>\n </div>\n <div className=\"rounded-md border border-border-subtle bg-bg-surface p-3\">\n <p className=\"text-xs text-text-secondary\">Paid conversions</p>\n <p className=\"text-lg font-semibold text-text-primary\">\n {code.totalPaidConversions + code.totalStorePurchases}\n </p>\n </div>\n <div className=\"rounded-md border border-border-subtle bg-bg-surface p-3\">\n <p className=\"text-xs text-text-secondary\">Rewards earned</p>\n <p className=\"text-lg font-semibold text-text-primary\">\n {formatCurrency(code.totalRewardAmount, 'USD')}\n </p>\n </div>\n </div>\n {code.notes ? (\n <p className=\"mt-3 text-sm text-text-secondary\">{code.notes}</p>\n ) : null}\n </div>\n );\n })}\n </div>\n )}\n </div>\n\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\">\n <h2 className=\"mb-4 text-lg font-semibold text-text-primary\">\n Recent attributed journeys\n </h2>\n {journeys.length === 0 ? (\n <IllustratedEmptyState\n illustration=\"empty-people\"\n title=\"No journeys yet\"\n description=\"Journeys will appear as visitors land on your affiliate links.\"\n />\n ) : (\n <ResponsiveTable\n data={journeys}\n rowKey={(journey) => journey.id}\n columns={journeyColumns}\n />\n )}\n </div>\n </section>\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,IAAMA,IAA4D;CAChE;EAAE,KAAK;EAAQ,QAAQ;EAAQ,UAAU;EAAW,OAAO,MAAYC,EAAQ;CAAU;CACzF;EAAE,KAAK;EAAW,QAAQ;EAAW,OAAO,MAAYA,EAAQ;CAAY;CAC5E;EACE,KAAK;EACL,QAAQ;EACR,OAAO,MAAYA,EAAQ,eAAeA,EAAQ,eAAe;CACnE;CACA;EAAE,KAAK;EAAW,QAAQ;EAAW,OAAO,MAAYA,EAAQ,oBAAoB;CAAI;CACxF;EAAE,KAAK;EAAU,QAAQ;EAAU,OAAO,MAAYA,EAAQ;CAAO;CACrE;EACE,KAAK;EACL,QAAQ;EACR,OAAO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EL,CAAA,GAAA,kBAAC,OAAD;MAAK,WAAU;MAAf,UAAA,CACE,kBAAC,MAAD;OAAI,WAAU;OAA+C,UAAA;MAEzD,CAAA,GACHvC,EAAS,WAAW,IACnB,kBAACiE,GAAD;OACE,cAAa;OACb,OAAM;OACN,aAAY;MACb,CAAA,IAED,kBAACG,GAAD;OACE,MAAMpE;OACN,SAAS,MAAYlB,EAAQ;OAC7B,SAASD;MACV,CAAA,CAEA;KACE,CAAA,CAAA;IACN,CAAA,CAAA;;EACF;;AAET"}
1
+ {"version":3,"file":"AffiliateDashboardPage.js","names":["journeyColumns","journey","formatDateTime","AffiliateDashboardPage","permissions","useBillingPermissions","isFluidgrids","useIsFluidgridsVariant","codeToDeactivate","setCodeToDeactivate","useState","isDeactivating","setIsDeactivating","deactivateError","setDeactivateError","useBillingEventEmitter","useBilling","codes","setCodes","journeys","setJourneys","analytics","setAnalytics","loading","setLoading","error","setError","selectedCodeId","setSelectedCodeId","form","setForm","requestContext","useMemo","apiGatewayUrl","authToken","orgId","loadData","useCallback","loadedCodes","loadedAnalytics","loadedJourneys","fetchMyAffiliateCodes","fetchMyAffiliateAnalytics","fetchMyAffiliateJourneys","loadError","useEffect","AccessDenied","isServerError","ServerError","selectedCode","item","handleSubmit","updateAffiliateCode","emit","createdCode","createAffiliateCode","submitError","handleEdit","code","confirmDeactivate","handleDeactivate","err","deactivateAffiliateCode","codeId","handleQuickNote","note","addAffiliateCodeNote","metricCards","Ticket","Users","Link2","formatCurrency","TrendingUp","MoneyActionDialog","PageHeader","CTAOverflowMenu","RefreshCw","PagePurpose","EmphasisPanel","StatCard","card","Plus","current","event","IllustratedEmptyState","shareUrl","StickyNote","ResponsiveTable"],"sources":["../../../../../src/billing/modules/affiliate/pages/AffiliateDashboardPage.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState, type FC } from 'react';\nimport { Link2, Plus, RefreshCw, StickyNote, Ticket, TrendingUp, Users } from 'lucide-react';\nimport { ResponsiveTable, type ResponsiveTableColumn } from '@burdenoff/fe-libs/ui';\n\nimport { useBilling } from '../../../providers/BillingProvider';\nimport { useBillingEventEmitter } from '../../../hooks/useBillingEventEmitter';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useIsFluidgridsVariant } from '../../../hooks/useBillingVariant';\nimport { MoneyActionDialog } from '../../../shared/components';\nimport { AccessDenied, PageHeader, ServerError, StatCard } from '../../../shared/components';\nimport {\n CTAOverflowMenu,\n PagePurpose,\n EmphasisPanel,\n IllustratedEmptyState,\n} from '@burdenoff/fe-libs/ui';\nimport { formatCurrency, formatDateTime, isServerError } from '../../../shared/utils';\n\nconst journeyColumns: ResponsiveTableColumn<AffiliateJourney>[] = [\n { key: 'code', header: 'Code', priority: 'primary', cell: (journey) => journey.codeValue },\n { key: 'product', header: 'Product', cell: (journey) => journey.productSlug },\n {\n key: 'path',\n header: 'Path',\n cell: (journey) => journey.currentPath || journey.landingPath || '-',\n },\n { key: 'country', header: 'Country', cell: (journey) => journey.geographyCountry || '-' },\n { key: 'status', header: 'Status', cell: (journey) => journey.status },\n {\n key: 'visited',\n header: 'Visited',\n cell: (journey) => formatDateTime(journey.lastVisitedAt),\n },\n];\nimport {\n addAffiliateCodeNote,\n createAffiliateCode,\n deactivateAffiliateCode,\n fetchMyAffiliateAnalytics,\n fetchMyAffiliateCodes,\n fetchMyAffiliateJourneys,\n updateAffiliateCode,\n type AffiliateCode,\n type AffiliateJourney,\n type AffiliateAnalyticsSummary,\n} from '../api';\n\nexport const AffiliateDashboardPage: FC = () => {\n const permissions = useBillingPermissions();\n const isFluidgrids = useIsFluidgridsVariant();\n const [codeToDeactivate, setCodeToDeactivate] = useState<{ id: string; label: string } | null>(\n null\n );\n const [isDeactivating, setIsDeactivating] = useState(false);\n const [deactivateError, setDeactivateError] = useState<string | null>(null);\n const { emit } = useBillingEventEmitter();\n const { apiGatewayUrl, authToken, orgId } = useBilling();\n\n const [codes, setCodes] = useState<AffiliateCode[]>([]);\n const [journeys, setJourneys] = useState<AffiliateJourney[]>([]);\n const [analytics, setAnalytics] = useState<AffiliateAnalyticsSummary | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const [selectedCodeId, setSelectedCodeId] = useState<string | null>(null);\n const [form, setForm] = useState({\n label: '',\n description: '',\n notes: '',\n productSlug: '',\n destinationPath: '',\n destinationUrl: '',\n });\n\n const requestContext = useMemo(\n () => ({\n apiGatewayUrl,\n authToken,\n orgId,\n }),\n [apiGatewayUrl, authToken, orgId]\n );\n\n const loadData = useCallback(async () => {\n setLoading(true);\n setError(null);\n try {\n const [loadedCodes, loadedAnalytics, loadedJourneys] = await Promise.all([\n fetchMyAffiliateCodes(requestContext),\n fetchMyAffiliateAnalytics(requestContext),\n fetchMyAffiliateJourneys(requestContext),\n ]);\n setCodes(loadedCodes);\n setAnalytics(loadedAnalytics);\n setJourneys(loadedJourneys);\n } catch (loadError) {\n setError(\n loadError instanceof Error ? loadError : new Error('Failed to load affiliate dashboard')\n );\n } finally {\n setLoading(false);\n }\n }, [requestContext]);\n\n useEffect(() => {\n void loadData();\n }, [loadData]);\n\n if (!permissions.canViewBillingAccount) {\n return <AccessDenied message=\"You don't have permission to view affiliate analytics.\" />;\n }\n\n if (error && isServerError(error)) {\n return (\n <ServerError\n title=\"Affiliate service unavailable\"\n message={error.message}\n onRetry={() => void loadData()}\n showRetry\n />\n );\n }\n\n const selectedCode = codes.find((item) => item.id === selectedCodeId) ?? null;\n\n const handleSubmit = async () => {\n if (!form.productSlug.trim()) {\n setError(new Error('Product slug is required'));\n return;\n }\n\n try {\n if (selectedCode) {\n await updateAffiliateCode(\n selectedCode.id,\n {\n label: form.label,\n description: form.description,\n notes: form.notes,\n destinationPath: form.destinationPath,\n destinationUrl: form.destinationUrl,\n },\n requestContext\n );\n emit('billing.affiliate_code.updated', {\n route: '/billing/affiliate',\n entityId: selectedCode.id,\n source: 'affiliate-dashboard',\n });\n } else {\n const createdCode = await createAffiliateCode(\n {\n label: form.label,\n description: form.description,\n notes: form.notes,\n productSlug: form.productSlug,\n destinationPath: form.destinationPath,\n destinationUrl: form.destinationUrl,\n },\n requestContext\n );\n emit('billing.affiliate_code.created', {\n route: '/billing/affiliate',\n entityId: createdCode.id,\n source: 'affiliate-dashboard',\n });\n }\n\n setSelectedCodeId(null);\n setForm({\n label: '',\n description: '',\n notes: '',\n productSlug: '',\n destinationPath: '',\n destinationUrl: '',\n });\n await loadData();\n } catch (submitError) {\n setError(\n submitError instanceof Error ? submitError : new Error('Failed to save affiliate code')\n );\n }\n };\n\n const handleEdit = (code: AffiliateCode) => {\n setSelectedCodeId(code.id);\n setForm({\n label: code.label ?? '',\n description: code.description ?? '',\n notes: code.notes ?? '',\n productSlug: code.productSlug,\n destinationPath: code.destinationPath ?? '',\n destinationUrl: code.destinationUrl ?? '',\n });\n };\n\n const confirmDeactivate = async () => {\n if (!codeToDeactivate) return;\n setIsDeactivating(true);\n setDeactivateError(null);\n try {\n await handleDeactivate(codeToDeactivate.id);\n setCodeToDeactivate(null);\n } catch (err) {\n setDeactivateError(err instanceof Error ? err.message : 'Could not deactivate this code.');\n } finally {\n setIsDeactivating(false);\n }\n };\n\n const handleDeactivate = async (codeId: string) => {\n await deactivateAffiliateCode(codeId, requestContext);\n emit('billing.affiliate_code.deactivated', {\n route: '/billing/affiliate',\n entityId: codeId,\n source: 'affiliate-dashboard',\n });\n await loadData();\n };\n\n const handleQuickNote = async (codeId: string) => {\n const note = window.prompt('Add an internal note for this affiliate code');\n if (!note) return;\n await addAffiliateCodeNote(codeId, note, requestContext);\n emit('billing.affiliate_code.note_added', {\n route: '/billing/affiliate',\n entityId: codeId,\n source: 'affiliate-dashboard',\n });\n await loadData();\n };\n\n const metricCards = analytics\n ? [\n { title: 'Codes', value: analytics.totalCodes, icon: <Ticket className=\"size-5\" /> },\n { title: 'Visits', value: analytics.totalVisits, icon: <Users className=\"size-5\" /> },\n { title: 'Journeys', value: analytics.totalJourneys, icon: <Link2 className=\"size-5\" /> },\n {\n title: 'Revenue influenced',\n value: formatCurrency(analytics.totalRevenueAmount, 'USD'),\n icon: <TrendingUp className=\"size-5\" />,\n },\n ]\n : [];\n\n return (\n <div className=\"space-y-6 p-6\">\n {isFluidgrids && (\n <MoneyActionDialog\n open={codeToDeactivate !== null}\n tone=\"danger\"\n title=\"Deactivate this affiliate code?\"\n description=\"The code stops tracking new visits straight away. Visits and journeys already recorded are kept.\"\n details={[{ label: 'Code', value: codeToDeactivate?.label ?? '' }]}\n confirmLabel=\"Deactivate code\"\n busyLabel=\"Deactivating…\"\n isBusy={isDeactivating}\n error={deactivateError}\n onConfirm={() => void confirmDeactivate()}\n onCancel={() => setCodeToDeactivate(null)}\n />\n )}\n <PageHeader\n title=\"Affiliate codes\"\n description=\"Create referral codes, add internal notes, and monitor attributed journeys.\"\n actions={\n <CTAOverflowMenu\n actions={[\n {\n label: 'Refresh',\n onSelect: () => void loadData(),\n icon: <RefreshCw className=\"size-4\" />,\n },\n ]}\n />\n }\n />\n\n <PagePurpose>\n Generate referral links for any product, share them, and see exactly what they drive —\n visits, signups, paid conversions and the rewards you have earned. Create and manage your\n codes on the left and watch attributed visitor journeys on the right.\n </PagePurpose>\n\n {loading ? (\n <div className=\"grid gap-4 md:grid-cols-2 xl:grid-cols-4\">\n {[1, 2, 3, 4].map((item) => (\n <div\n key={item}\n className=\"h-28 animate-pulse rounded-lg border border-border-subtle bg-bg-surface\"\n />\n ))}\n </div>\n ) : analytics ? (\n <EmphasisPanel className=\"p-4 sm:p-5\">\n <div className=\"grid gap-4 md:grid-cols-2 xl:grid-cols-4\">\n {metricCards.map((card) => (\n <StatCard key={card.title} label={card.title} value={card.value} icon={card.icon} />\n ))}\n </div>\n </EmphasisPanel>\n ) : null}\n\n {error && !isServerError(error) ? (\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4 text-sm text-status-error-text\">\n {error.message}\n </div>\n ) : null}\n\n <div className=\"grid gap-6 xl:grid-cols-[1.1fr,1.9fr]\">\n <section className=\"rounded-lg border border-border-seam bg-bg-surface p-4 xl:sticky xl:top-6 xl:self-start\">\n <div className=\"mb-4 flex items-center justify-between\">\n <h2 className=\"text-lg font-semibold text-text-primary\">\n {selectedCode ? 'Update affiliate code' : 'Create affiliate code'}\n </h2>\n {!selectedCode ? <Plus className=\"size-4 text-text-secondary\" /> : null}\n </div>\n\n <div className=\"space-y-3\">\n <input\n value={form.label}\n onChange={(event) =>\n setForm((current) => ({ ...current, label: event.target.value }))\n }\n placeholder=\"Label\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <input\n value={form.productSlug}\n onChange={(event) =>\n setForm((current) => ({ ...current, productSlug: event.target.value }))\n }\n placeholder=\"Product slug (eg. bigconsole)\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n disabled={Boolean(selectedCode)}\n />\n <input\n value={form.destinationPath}\n onChange={(event) =>\n setForm((current) => ({ ...current, destinationPath: event.target.value }))\n }\n placeholder=\"Destination path (eg. /pricing)\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <input\n value={form.destinationUrl}\n onChange={(event) =>\n setForm((current) => ({ ...current, destinationUrl: event.target.value }))\n }\n placeholder=\"Absolute destination URL (optional)\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <textarea\n value={form.description}\n onChange={(event) =>\n setForm((current) => ({ ...current, description: event.target.value }))\n }\n placeholder=\"Description\"\n className=\"min-h-24 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <textarea\n value={form.notes}\n onChange={(event) =>\n setForm((current) => ({ ...current, notes: event.target.value }))\n }\n placeholder=\"Internal notes\"\n className=\"min-h-24 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n </div>\n\n <div className=\"mt-4 flex flex-wrap gap-3\">\n <button\n type=\"button\"\n onClick={() => void handleSubmit()}\n className=\"rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text\"\n >\n {selectedCode ? 'Save changes' : 'Create code'}\n </button>\n {selectedCode ? (\n <button\n type=\"button\"\n onClick={() => {\n setSelectedCodeId(null);\n setForm({\n label: '',\n description: '',\n notes: '',\n productSlug: '',\n destinationPath: '',\n destinationUrl: '',\n });\n }}\n className=\"rounded-md border border-border-subtle bg-bg-surface px-4 py-2 text-sm font-medium text-text-primary\"\n >\n Cancel\n </button>\n ) : null}\n </div>\n </section>\n\n <section className=\"space-y-4\">\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\">\n <h2 className=\"mb-4 text-lg font-semibold text-text-primary\">My codes</h2>\n {codes.length === 0 && !loading ? (\n <IllustratedEmptyState\n illustration=\"empty-data\"\n title=\"No affiliate codes yet\"\n description=\"Create your first code to start tracking attributable journeys.\"\n />\n ) : (\n <div className=\"space-y-4\">\n {codes.map((code) => {\n const shareUrl =\n code.destinationUrl ||\n `https://${code.productSlug}.com${code.destinationPath || ''}?ref=${code.code}`;\n return (\n <div\n key={code.id}\n className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\"\n >\n <div className=\"flex flex-wrap items-start justify-between gap-4\">\n <div>\n <p className=\"text-sm font-semibold text-text-primary\">\n {code.label || code.code}\n </p>\n <p className=\"text-xs text-text-secondary\">\n {code.code} · {code.productSlug}\n </p>\n <p className=\"mt-1 break-all text-xs text-text-secondary\">{shareUrl}</p>\n </div>\n <div className=\"flex flex-wrap gap-2\">\n <button\n type=\"button\"\n onClick={() => handleEdit(code)}\n className=\"rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary\"\n >\n Edit\n </button>\n <button\n type=\"button\"\n onClick={() => void handleQuickNote(code.id)}\n className=\"inline-flex items-center gap-1 rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary\"\n >\n <StickyNote className=\"size-3.5\" />\n Note\n </button>\n {code.status === 'ACTIVE' ? (\n <button\n type=\"button\"\n onClick={() =>\n isFluidgrids\n ? (setDeactivateError(null),\n setCodeToDeactivate({\n id: code.id,\n label: code.label || code.code,\n }))\n : void handleDeactivate(code.id)\n }\n className=\"rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-status-error-text\"\n >\n Deactivate\n </button>\n ) : null}\n </div>\n </div>\n <div className=\"mt-4 grid gap-3 sm:grid-cols-2 xl:grid-cols-4\">\n <div className=\"rounded-md border border-border-subtle bg-bg-surface p-3\">\n <p className=\"text-xs text-text-secondary\">Visits</p>\n <p className=\"text-lg font-semibold text-text-primary\">\n {code.totalVisits}\n </p>\n </div>\n <div className=\"rounded-md border border-border-subtle bg-bg-surface p-3\">\n <p className=\"text-xs text-text-secondary\">Signups</p>\n <p className=\"text-lg font-semibold text-text-primary\">\n {code.totalSignups}\n </p>\n </div>\n <div className=\"rounded-md border border-border-subtle bg-bg-surface p-3\">\n <p className=\"text-xs text-text-secondary\">Paid conversions</p>\n <p className=\"text-lg font-semibold text-text-primary\">\n {code.totalPaidConversions + code.totalStorePurchases}\n </p>\n </div>\n <div className=\"rounded-md border border-border-subtle bg-bg-surface p-3\">\n <p className=\"text-xs text-text-secondary\">Rewards earned</p>\n <p className=\"text-lg font-semibold text-text-primary\">\n {formatCurrency(code.totalRewardAmount, 'USD')}\n </p>\n </div>\n </div>\n {code.notes ? (\n <p className=\"mt-3 text-sm text-text-secondary\">{code.notes}</p>\n ) : null}\n </div>\n );\n })}\n </div>\n )}\n </div>\n\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\">\n <h2 className=\"mb-4 text-lg font-semibold text-text-primary\">\n Recent attributed journeys\n </h2>\n {journeys.length === 0 ? (\n <IllustratedEmptyState\n illustration=\"empty-people\"\n title=\"No journeys yet\"\n description=\"Journeys will appear as visitors land on your affiliate links.\"\n />\n ) : (\n <ResponsiveTable\n data={journeys}\n rowKey={(journey) => journey.id}\n columns={journeyColumns}\n />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AAA,CACE,kBAAC,KAAD;cAAG,WAAU;cAA8B,UAAA;aAAmB,CAAA,GAC9D,kBAAC,KAAD;cAAG,WAAU;cACV,UAAAA,EAAK,uBAAuBA,EAAK;aACjC,CAAA,CACA;;YACL,kBAAC,OAAD;aAAK,WAAU;aAAf,UAAA,CACE,kBAAC,KAAD;cAAG,WAAU;cAA8B,UAAA;aAAiB,CAAA,GAC5D,kBAAC,KAAD;cAAG,WAAU;cACV,UAAAa,EAAeb,EAAK,mBAAmB,KAAK;aAC5C,CAAA,CACA;;WACF;;UACJA,EAAK,QACJ,kBAAC,KAAD;WAAG,WAAU;WAAoC,UAAAA,EAAK;UAAS,CAAA,IAC7D;SACD;QA7EE,GAAAA,EAAK,EA6EP;OAET,CAAC;MACE,CAAA,CAEJ;KAEL,CAAA,GAAA,kBAAC,OAAD;MAAK,WAAU;MAAf,UAAA,CACE,kBAAC,MAAD;OAAI,WAAU;OAA+C,UAAA;MAEzD,CAAA,GACHvC,EAAS,WAAW,IACnB,kBAACiE,GAAD;OACE,cAAa;OACb,OAAM;OACN,aAAY;MACb,CAAA,IAED,kBAACG,IAAD;OACE,MAAMpE;OACN,SAAS,MAAYlB,EAAQ;OAC7B,SAASD;MACV,CAAA,CAEA;KACE,CAAA,CAAA;IACN,CAAA,CAAA;;EACF;;AAET"}
@@ -7,9 +7,9 @@ import { formatCurrency as i, formatPercentage as a } from "../../../shared/util
7
7
  import { useGetBillingAnalyticsPageDataQuery as o } from "../../../../generated/global-operations.js";
8
8
  import { PlanDuration as s, SubscriptionStatus as c } from "../../../../generated/global-types.js";
9
9
  import { useMemo as l, useState as u } from "react";
10
- import { AlertCircle as d, BarChart3 as f, RefreshCw as p, TrendingUp as m, Users as h, Wallet as g } from "lucide-react";
11
- import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
12
- import { CTAOverflowMenu as b, EmphasisPanel as x, IllustratedEmptyState as S, PagePurpose as C } from "@burdenoff/fe-libs/ui";
10
+ import { CTAOverflowMenu as d, EmphasisPanel as f, IllustratedEmptyState as p, PagePurpose as m } from "@burdenoff/fe-libs/ui";
11
+ import { AlertCircle as h, BarChart3 as g, RefreshCw as _, TrendingUp as v, Users as y, Wallet as b } from "lucide-react";
12
+ import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
13
13
  // src/billing/modules/analytics/pages/AnalyticsPage.tsx
14
14
  var w = [
15
15
  {
@@ -180,119 +180,119 @@ var P = () => {
180
180
  estimatedMrr: n
181
181
  };
182
182
  }).sort((e, t) => t.estimatedMrr - e.estimatedMrr).slice(0, 5), [z]), Y = Math.max(...G.map((e) => e.value), 0), X = Math.max(...K.map((e) => e.value), 0);
183
- return i.canViewAnalytics ? /* @__PURE__ */ y("div", {
183
+ return i.canViewAnalytics ? /* @__PURE__ */ C("div", {
184
184
  className: "space-y-6 p-4 sm:p-6",
185
185
  children: [
186
- /* @__PURE__ */ v(t, {
186
+ /* @__PURE__ */ S(t, {
187
187
  title: "Revenue Analytics",
188
188
  description: "Track recurring revenue, customer growth, and billing performance using live billing data.",
189
- actions: /* @__PURE__ */ y("div", {
189
+ actions: /* @__PURE__ */ C("div", {
190
190
  className: "flex flex-col gap-2 sm:flex-row sm:items-center",
191
- children: [/* @__PURE__ */ v("select", {
191
+ children: [/* @__PURE__ */ S("select", {
192
192
  value: s,
193
193
  onChange: (e) => E(e.target.value),
194
194
  "aria-label": "Analytics period",
195
195
  className: "rounded-input border border-border-seam bg-bg-surface px-3 py-2 text-sm text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary",
196
- children: w.map((e) => /* @__PURE__ */ v("option", {
196
+ children: w.map((e) => /* @__PURE__ */ S("option", {
197
197
  value: e.value,
198
198
  children: e.label
199
199
  }, e.value))
200
- }), /* @__PURE__ */ v(b, { actions: [{
200
+ }), /* @__PURE__ */ S(d, { actions: [{
201
201
  label: "Refresh",
202
202
  onSelect: () => {
203
203
  R();
204
204
  },
205
- icon: /* @__PURE__ */ v(p, { className: "size-4" })
205
+ icon: /* @__PURE__ */ S(_, { className: "size-4" })
206
206
  }] })]
207
207
  })
208
208
  }),
209
- /* @__PURE__ */ v(C, { children: "Understand the financial health of your business at a glance — recurring revenue (MRR/ARR), customer growth, churn and your highest-value customers — all computed from live billing data. Use the period selector to compare timeframes and spot trends." }),
210
- L && /* @__PURE__ */ y("div", {
209
+ /* @__PURE__ */ S(m, { children: "Understand the financial health of your business at a glance — recurring revenue (MRR/ARR), customer growth, churn and your highest-value customers — all computed from live billing data. Use the period selector to compare timeframes and spot trends." }),
210
+ L && /* @__PURE__ */ C("div", {
211
211
  className: "flex items-start gap-3 rounded-lg border border-status-error-border bg-status-error-bg-subtle p-4 text-status-error-text",
212
- children: [/* @__PURE__ */ v(d, { className: "mt-0.5 size-4 shrink-0" }), /* @__PURE__ */ y("div", { children: [/* @__PURE__ */ v("p", {
212
+ children: [/* @__PURE__ */ S(h, { className: "mt-0.5 size-4 shrink-0" }), /* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("p", {
213
213
  className: "font-medium",
214
214
  children: "Unable to load billing analytics"
215
- }), /* @__PURE__ */ v("p", {
215
+ }), /* @__PURE__ */ S("p", {
216
216
  className: "mt-1 text-sm",
217
217
  children: L.message
218
218
  })] })]
219
219
  }),
220
- I && z.length === 0 ? /* @__PURE__ */ v("div", {
220
+ I && z.length === 0 ? /* @__PURE__ */ S("div", {
221
221
  className: "flex min-h-[320px] items-center justify-center rounded-lg border border-border-subtle bg-bg-surface",
222
- children: /* @__PURE__ */ y("div", {
222
+ children: /* @__PURE__ */ C("div", {
223
223
  className: "flex flex-col items-center gap-3 text-text-muted",
224
- children: [/* @__PURE__ */ v(p, { className: "size-6 animate-spin" }), /* @__PURE__ */ v("p", {
224
+ children: [/* @__PURE__ */ S(_, { className: "size-6 animate-spin" }), /* @__PURE__ */ S("p", {
225
225
  className: "text-sm",
226
226
  children: "Loading live billing analytics…"
227
227
  })]
228
228
  })
229
- }) : z.length === 0 ? /* @__PURE__ */ v(S, {
229
+ }) : z.length === 0 ? /* @__PURE__ */ S(p, {
230
230
  illustration: "empty-data",
231
231
  title: "No billing data available yet",
232
232
  description: "Create a billing account and complete a subscription or payment to unlock live analytics."
233
- }) : /* @__PURE__ */ y(_, { children: [
234
- /* @__PURE__ */ v(x, {
233
+ }) : /* @__PURE__ */ C(x, { children: [
234
+ /* @__PURE__ */ S(f, {
235
235
  className: "p-4 sm:p-5",
236
- children: /* @__PURE__ */ y("div", {
236
+ children: /* @__PURE__ */ C("div", {
237
237
  className: "grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4",
238
238
  children: [
239
- /* @__PURE__ */ v(n, {
239
+ /* @__PURE__ */ S(n, {
240
240
  label: "MRR",
241
241
  value: N(W.mrr, U),
242
- icon: /* @__PURE__ */ v(m, { className: "size-5" })
242
+ icon: /* @__PURE__ */ S(v, { className: "size-5" })
243
243
  }),
244
- /* @__PURE__ */ v(n, {
244
+ /* @__PURE__ */ S(n, {
245
245
  label: "ARR",
246
246
  value: N(W.arr, U),
247
- icon: /* @__PURE__ */ v(f, { className: "size-5" })
247
+ icon: /* @__PURE__ */ S(g, { className: "size-5" })
248
248
  }),
249
- /* @__PURE__ */ v(n, {
249
+ /* @__PURE__ */ S(n, {
250
250
  label: "ARPU",
251
251
  value: N(W.arpu, U),
252
- icon: /* @__PURE__ */ v(g, { className: "size-5" })
252
+ icon: /* @__PURE__ */ S(b, { className: "size-5" })
253
253
  }),
254
- /* @__PURE__ */ v(n, {
254
+ /* @__PURE__ */ S(n, {
255
255
  label: "Churn Rate",
256
256
  value: a(W.churnRate),
257
- icon: /* @__PURE__ */ v(h, { className: "size-5" })
257
+ icon: /* @__PURE__ */ S(y, { className: "size-5" })
258
258
  })
259
259
  ]
260
260
  })
261
261
  }),
262
- /* @__PURE__ */ y("div", {
262
+ /* @__PURE__ */ C("div", {
263
263
  className: "grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4",
264
264
  children: [
265
- /* @__PURE__ */ v(n, {
265
+ /* @__PURE__ */ S(n, {
266
266
  label: "Total Customers",
267
267
  value: W.totalCustomers
268
268
  }),
269
- /* @__PURE__ */ v(n, {
269
+ /* @__PURE__ */ S(n, {
270
270
  label: "New Customers",
271
271
  value: W.newCustomers
272
272
  }),
273
- /* @__PURE__ */ v(n, {
273
+ /* @__PURE__ */ S(n, {
274
274
  label: "Active Subscriptions",
275
275
  value: W.activeSubscriptions
276
276
  }),
277
- /* @__PURE__ */ v(n, {
277
+ /* @__PURE__ */ S(n, {
278
278
  label: "Estimated LTV",
279
279
  value: N(W.ltv, U)
280
280
  })
281
281
  ]
282
282
  }),
283
- /* @__PURE__ */ y("div", {
283
+ /* @__PURE__ */ C("div", {
284
284
  className: "grid grid-cols-1 gap-6 xl:grid-cols-2",
285
- children: [/* @__PURE__ */ y("section", {
285
+ children: [/* @__PURE__ */ C("section", {
286
286
  className: "rounded-card border border-border-seam bg-bg-surface p-4 sm:p-6 shadow-[var(--shadow-elevation-1)]",
287
- children: [/* @__PURE__ */ y("div", {
287
+ children: [/* @__PURE__ */ C("div", {
288
288
  className: "mb-4 flex items-center justify-between gap-3",
289
- children: [/* @__PURE__ */ y("div", { children: [/* @__PURE__ */ v("h3", {
289
+ children: [/* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("h3", {
290
290
  className: "font-semibold text-text-primary",
291
291
  children: "Revenue over time"
292
- }), /* @__PURE__ */ v("p", {
292
+ }), /* @__PURE__ */ S("p", {
293
293
  className: "text-sm text-text-muted",
294
294
  children: "Successful payments received during the selected period."
295
- })] }), /* @__PURE__ */ y("span", {
295
+ })] }), /* @__PURE__ */ C("span", {
296
296
  className: "rounded-full bg-status-info-bg-subtle px-2.5 py-1 text-xs font-medium text-status-info-text",
297
297
  children: [
298
298
  G.length,
@@ -300,64 +300,64 @@ var P = () => {
300
300
  G.length === 1 ? "" : "s"
301
301
  ]
302
302
  })]
303
- }), G.length === 0 ? /* @__PURE__ */ v("p", {
303
+ }), G.length === 0 ? /* @__PURE__ */ S("p", {
304
304
  className: "rounded-lg bg-bg-sunken/40 p-4 text-sm text-text-muted",
305
305
  children: "No successful payments were recorded during this period."
306
- }) : /* @__PURE__ */ v("div", {
306
+ }) : /* @__PURE__ */ S("div", {
307
307
  className: "space-y-3",
308
- children: G.map((e) => /* @__PURE__ */ y("div", {
308
+ children: G.map((e) => /* @__PURE__ */ C("div", {
309
309
  className: "space-y-1",
310
- children: [/* @__PURE__ */ y("div", {
310
+ children: [/* @__PURE__ */ C("div", {
311
311
  className: "flex items-center justify-between gap-3 text-sm",
312
- children: [/* @__PURE__ */ v("span", {
312
+ children: [/* @__PURE__ */ S("span", {
313
313
  className: "font-medium text-text-primary",
314
314
  children: e.label
315
- }), /* @__PURE__ */ v("span", {
315
+ }), /* @__PURE__ */ S("span", {
316
316
  className: "text-text-muted",
317
317
  children: N(e.value, U)
318
318
  })]
319
- }), /* @__PURE__ */ v("div", {
319
+ }), /* @__PURE__ */ S("div", {
320
320
  className: "h-2 rounded-full bg-bg-sunken",
321
- children: /* @__PURE__ */ v("div", {
321
+ children: /* @__PURE__ */ S("div", {
322
322
  className: "h-2 rounded-full bg-action-primary-bg transition-[width]",
323
323
  style: { width: `${Y > 0 ? e.value / Y * 100 : 0}%` }
324
324
  })
325
325
  })]
326
326
  }, e.label))
327
327
  })]
328
- }), /* @__PURE__ */ y("section", {
328
+ }), /* @__PURE__ */ C("section", {
329
329
  className: "rounded-card border border-border-seam bg-bg-surface p-4 sm:p-6 shadow-[var(--shadow-elevation-1)]",
330
- children: [/* @__PURE__ */ y("div", {
330
+ children: [/* @__PURE__ */ C("div", {
331
331
  className: "mb-4 flex items-center justify-between gap-3",
332
- children: [/* @__PURE__ */ y("div", { children: [/* @__PURE__ */ v("h3", {
332
+ children: [/* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("h3", {
333
333
  className: "font-semibold text-text-primary",
334
334
  children: "Subscription growth"
335
- }), /* @__PURE__ */ v("p", {
335
+ }), /* @__PURE__ */ S("p", {
336
336
  className: "text-sm text-text-muted",
337
337
  children: "New subscriptions created during the selected period."
338
- })] }), /* @__PURE__ */ y("span", {
338
+ })] }), /* @__PURE__ */ C("span", {
339
339
  className: "rounded-full bg-status-success-bg-subtle px-2.5 py-1 text-xs font-medium text-status-success-text",
340
340
  children: [K.reduce((e, t) => e + t.value, 0), " created"]
341
341
  })]
342
- }), K.length === 0 ? /* @__PURE__ */ v("p", {
342
+ }), K.length === 0 ? /* @__PURE__ */ S("p", {
343
343
  className: "rounded-lg bg-bg-sunken/40 p-4 text-sm text-text-muted",
344
344
  children: "No new subscriptions were created during this period."
345
- }) : /* @__PURE__ */ v("div", {
345
+ }) : /* @__PURE__ */ S("div", {
346
346
  className: "space-y-3",
347
- children: K.map((e) => /* @__PURE__ */ y("div", {
347
+ children: K.map((e) => /* @__PURE__ */ C("div", {
348
348
  className: "space-y-1",
349
- children: [/* @__PURE__ */ y("div", {
349
+ children: [/* @__PURE__ */ C("div", {
350
350
  className: "flex items-center justify-between gap-3 text-sm",
351
- children: [/* @__PURE__ */ v("span", {
351
+ children: [/* @__PURE__ */ S("span", {
352
352
  className: "font-medium text-text-primary",
353
353
  children: e.label
354
- }), /* @__PURE__ */ y("span", {
354
+ }), /* @__PURE__ */ C("span", {
355
355
  className: "text-text-muted",
356
356
  children: [e.value, " new"]
357
357
  })]
358
- }), /* @__PURE__ */ v("div", {
358
+ }), /* @__PURE__ */ S("div", {
359
359
  className: "h-2 rounded-full bg-bg-sunken",
360
- children: /* @__PURE__ */ v("div", {
360
+ children: /* @__PURE__ */ S("div", {
361
361
  className: "h-2 rounded-full bg-status-success-bg transition-[width]",
362
362
  style: { width: `${X > 0 ? e.value / X * 100 : 0}%` }
363
363
  })
@@ -366,80 +366,80 @@ var P = () => {
366
366
  })]
367
367
  })]
368
368
  }),
369
- /* @__PURE__ */ y("div", {
369
+ /* @__PURE__ */ C("div", {
370
370
  className: "grid grid-cols-1 gap-6 xl:grid-cols-2",
371
- children: [/* @__PURE__ */ y("section", {
371
+ children: [/* @__PURE__ */ C("section", {
372
372
  className: "rounded-card border border-border-seam bg-bg-surface shadow-[var(--shadow-elevation-1)]",
373
- children: [/* @__PURE__ */ y("div", {
373
+ children: [/* @__PURE__ */ C("div", {
374
374
  className: "border-b border-border-subtle p-4",
375
- children: [/* @__PURE__ */ v("h3", {
375
+ children: [/* @__PURE__ */ S("h3", {
376
376
  className: "font-semibold text-text-primary",
377
377
  children: "Revenue by plan"
378
- }), /* @__PURE__ */ v("p", {
378
+ }), /* @__PURE__ */ S("p", {
379
379
  className: "mt-1 text-sm text-text-muted",
380
380
  children: "Estimated monthly recurring revenue based on currently active subscriptions."
381
381
  })]
382
- }), /* @__PURE__ */ v("div", {
382
+ }), /* @__PURE__ */ S("div", {
383
383
  className: "p-4",
384
- children: q.length === 0 ? /* @__PURE__ */ v("p", {
384
+ children: q.length === 0 ? /* @__PURE__ */ S("p", {
385
385
  className: "text-sm text-text-muted",
386
386
  children: "No active plans to analyse yet."
387
- }) : /* @__PURE__ */ v("div", {
387
+ }) : /* @__PURE__ */ S("div", {
388
388
  className: "space-y-3",
389
- children: q.map((e) => /* @__PURE__ */ y("div", {
389
+ children: q.map((e) => /* @__PURE__ */ C("div", {
390
390
  className: "flex flex-col gap-2 rounded-lg border border-border-subtle p-3 sm:flex-row sm:items-center sm:justify-between",
391
- children: [/* @__PURE__ */ y("div", { children: [/* @__PURE__ */ v("p", {
391
+ children: [/* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("p", {
392
392
  className: "font-medium text-text-primary",
393
393
  children: e.name
394
- }), /* @__PURE__ */ y("p", {
394
+ }), /* @__PURE__ */ C("p", {
395
395
  className: "text-sm text-text-muted",
396
396
  children: [
397
397
  e.activeSubscriptions,
398
398
  " active subscription",
399
399
  e.activeSubscriptions === 1 ? "" : "s"
400
400
  ]
401
- })] }), /* @__PURE__ */ y("p", {
401
+ })] }), /* @__PURE__ */ C("p", {
402
402
  className: "text-sm font-semibold text-text-primary",
403
403
  children: [N(e.estimatedMrr, U), " / month"]
404
404
  })]
405
405
  }, e.name))
406
406
  })
407
407
  })]
408
- }), /* @__PURE__ */ y("section", {
408
+ }), /* @__PURE__ */ C("section", {
409
409
  className: "rounded-card border border-border-seam bg-bg-surface shadow-[var(--shadow-elevation-1)]",
410
- children: [/* @__PURE__ */ y("div", {
410
+ children: [/* @__PURE__ */ C("div", {
411
411
  className: "border-b border-border-subtle p-4",
412
- children: [/* @__PURE__ */ v("h3", {
412
+ children: [/* @__PURE__ */ S("h3", {
413
413
  className: "font-semibold text-text-primary",
414
414
  children: "Top customers"
415
- }), /* @__PURE__ */ v("p", {
415
+ }), /* @__PURE__ */ S("p", {
416
416
  className: "mt-1 text-sm text-text-muted",
417
417
  children: "Ranked by estimated monthly recurring revenue from active subscriptions."
418
418
  })]
419
- }), /* @__PURE__ */ v("div", {
419
+ }), /* @__PURE__ */ S("div", {
420
420
  className: "p-4",
421
- children: J.length === 0 ? /* @__PURE__ */ v("p", {
421
+ children: J.length === 0 ? /* @__PURE__ */ S("p", {
422
422
  className: "text-sm text-text-muted",
423
423
  children: "No customer revenue data available yet."
424
- }) : /* @__PURE__ */ v("div", {
424
+ }) : /* @__PURE__ */ S("div", {
425
425
  className: "space-y-3",
426
- children: J.map((e) => /* @__PURE__ */ y("div", {
426
+ children: J.map((e) => /* @__PURE__ */ C("div", {
427
427
  className: "flex flex-col gap-2 rounded-lg border border-border-subtle p-3 sm:flex-row sm:items-center sm:justify-between",
428
- children: [/* @__PURE__ */ y("div", {
428
+ children: [/* @__PURE__ */ C("div", {
429
429
  className: "min-w-0",
430
- children: [/* @__PURE__ */ v("p", {
430
+ children: [/* @__PURE__ */ S("p", {
431
431
  className: "truncate font-medium text-text-primary",
432
432
  children: e.name
433
- }), /* @__PURE__ */ v("p", {
433
+ }), /* @__PURE__ */ S("p", {
434
434
  className: "truncate text-sm text-text-muted",
435
435
  children: e.email
436
436
  })]
437
- }), /* @__PURE__ */ y("div", {
437
+ }), /* @__PURE__ */ C("div", {
438
438
  className: "text-left sm:text-right",
439
- children: [/* @__PURE__ */ y("p", {
439
+ children: [/* @__PURE__ */ C("p", {
440
440
  className: "text-sm font-semibold text-text-primary",
441
441
  children: [N(e.estimatedMrr, U), " / month"]
442
- }), /* @__PURE__ */ y("p", {
442
+ }), /* @__PURE__ */ C("p", {
443
443
  className: "text-xs text-text-muted",
444
444
  children: [
445
445
  e.activeSubscriptions,
@@ -455,7 +455,7 @@ var P = () => {
455
455
  })
456
456
  ] })
457
457
  ]
458
- }) : /* @__PURE__ */ v(e, { message: "You don't have permission to view analytics." });
458
+ }) : /* @__PURE__ */ S(e, { message: "You don't have permission to view analytics." });
459
459
  };
460
460
  export { P as AnalyticsPage };
461
461
 
@@ -1,6 +1,6 @@
1
- import { useInvoiceMutations as e } from "./useInvoices.js";
1
+ import { useInvoiceMutations as e, useInvoices as t } from "./useInvoices.js";
2
2
  import "./usePayments.js";
3
- import { useTransactions as t } from "./useTransactions.js";
4
- import { useBillingWebhookLogs as n, useRefundMutations as r, useRefundRecords as i, useRefunds as a } from "./useRefunds.js";
5
- import { useOrderCallbackMutations as o, useOrderCallbacks as s } from "./useOrderCallbacks.js";
6
- export { n as useBillingWebhookLogs, e as useInvoiceMutations, o as useOrderCallbackMutations, s as useOrderCallbacks, r as useRefundMutations, i as useRefundRecords, a as useRefunds, t as useTransactions };
3
+ import { useTransactions as n } from "./useTransactions.js";
4
+ import { useBillingWebhookLogs as r, useRefundMutations as i, useRefundRecords as a, useRefunds as o } from "./useRefunds.js";
5
+ import { useOrderCallbackMutations as s, useOrderCallbacks as c } from "./useOrderCallbacks.js";
6
+ export { r as useBillingWebhookLogs, e as useInvoiceMutations, t as useInvoices, s as useOrderCallbackMutations, c as useOrderCallbacks, i as useRefundMutations, a as useRefundRecords, o as useRefunds, n as useTransactions };