@mx-cartographer/experiences 9.0.2 → 9.1.0-alpha.bb1

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 (120) hide show
  1. package/dist/Analytics-BKzTPees.mjs +61 -0
  2. package/dist/GlobalCopyApi-BeXzaDH9.mjs +487 -0
  3. package/dist/HeaderCell-EhCUSjvj.mjs +10 -0
  4. package/dist/Loader-BlVzRtUd.mjs +73 -0
  5. package/dist/MiniWidgetContainer-COwnjfy7.mjs +110 -0
  6. package/dist/OriginalBalanceAction-sbiqaxok.mjs +110 -0
  7. package/dist/SpendingLegend-D15ixlQ1.mjs +222 -0
  8. package/dist/accounts/index.es.js +12 -1598
  9. package/dist/accounts-DkyAiLpg.mjs +15632 -0
  10. package/dist/analytics/index.es.js +155 -139
  11. package/dist/budgets/index.es.js +1317 -1266
  12. package/dist/cashflow/index.es.js +1047 -942
  13. package/dist/categories/index.es.js +4 -4
  14. package/dist/common/index.es.js +101 -310
  15. package/dist/core/index.es.js +80 -104
  16. package/dist/core-BexP5oiV.mjs +4047 -0
  17. package/dist/dashboard/index.es.js +185 -141
  18. package/dist/debts/index.es.js +1384 -1272
  19. package/dist/finstrong/index.es.js +3366 -3471
  20. package/dist/goals/index.es.js +1103 -984
  21. package/dist/help/index.es.js +3 -25
  22. package/dist/help-CctDYrAH.mjs +2308 -0
  23. package/dist/insights/index.es.js +93 -4843
  24. package/dist/investments/index.es.js +1533 -1522
  25. package/dist/merchants/index.es.js +75 -64
  26. package/dist/microinsights/index.es.js +15 -824
  27. package/dist/microinsights-CRf3ChsJ.mjs +1814 -0
  28. package/dist/networth/index.es.js +550 -503
  29. package/dist/notifications/index.es.js +169 -161
  30. package/dist/recurringtransactions/index.es.js +10 -962
  31. package/dist/recurringtransactions-gbJ_NA8u.mjs +1564 -0
  32. package/dist/settings/index.es.js +13 -880
  33. package/dist/settings-ZMHe439l.mjs +1526 -0
  34. package/dist/spending/index.es.js +400 -456
  35. package/dist/transactions/index.es.js +10 -603
  36. package/dist/trends/index.es.js +1268 -1407
  37. package/package.json +28 -28
  38. package/dist/Account-BaJmiJAG.mjs +0 -118
  39. package/dist/Account-BxHMlV9R.mjs +0 -30
  40. package/dist/AccountDetailsHeader-DIysk_4w.mjs +0 -95
  41. package/dist/AccountDisplayName-CO7z3v99.mjs +0 -11
  42. package/dist/AccountFields-mwJ8NXsX.mjs +0 -141
  43. package/dist/AccountListItem-BDXHs4tV.mjs +0 -94
  44. package/dist/AccountUtils-T5_Odvos.mjs +0 -27
  45. package/dist/Accounts-CseLC3lL.mjs +0 -5
  46. package/dist/Analytics-CkYXKvco.mjs +0 -53
  47. package/dist/Analytics-CzGzz_sE.mjs +0 -136
  48. package/dist/ApiEndpoints-DXwIYNUV.mjs +0 -49
  49. package/dist/BudgetUtil-Bg2AQJpQ.mjs +0 -74
  50. package/dist/Category-DEKZGLYe.mjs +0 -301
  51. package/dist/CategorySelectorDrawer-8soGrhB8.mjs +0 -430
  52. package/dist/Connect-Dk6GZEsA.mjs +0 -39
  53. package/dist/ConnectCard-CCep7Zqe.mjs +0 -54
  54. package/dist/ConnectDrawer-Cnjr3Ddg.mjs +0 -58
  55. package/dist/ConnectionsDrawer-CtfPXk0M.mjs +0 -54
  56. package/dist/CurrencyDialog-DumQCTPO.mjs +0 -373
  57. package/dist/CurrencyInput-adTIRtL3.mjs +0 -87
  58. package/dist/CurrencyText-CCbE6MmF.mjs +0 -20
  59. package/dist/DateFormats-HudZ3Bjs.mjs +0 -64
  60. package/dist/DateUtil-Bhq59ZVg.mjs +0 -58
  61. package/dist/DebtUtils-DD3186U-.mjs +0 -153
  62. package/dist/Dialog-Bvd2n8hz.mjs +0 -66
  63. package/dist/Donut-SzzfZDHF.mjs +0 -88
  64. package/dist/Drawer-BXqqBMxg.mjs +0 -174
  65. package/dist/EmbeddedCard-DPwJjqMH.mjs +0 -856
  66. package/dist/EmptyState-CJUDc3kD.mjs +0 -84
  67. package/dist/Error-Dogaw2jO.mjs +0 -84
  68. package/dist/ErrorBoundary-CsdOcnJ9.mjs +0 -23
  69. package/dist/ExportCsvAction-Bw02ZJEj.mjs +0 -24
  70. package/dist/GlobalAccountFilter-7Cg2-9A5.mjs +0 -237
  71. package/dist/GlobalCopyApi-wcnDUzMV.mjs +0 -128
  72. package/dist/GoalsUtil-C9EnLWvC.mjs +0 -107
  73. package/dist/HeaderCell-P8w6CmfO.mjs +0 -6
  74. package/dist/Help-CkQTjORd.mjs +0 -299
  75. package/dist/Help-DJ8PrVHX.mjs +0 -3209
  76. package/dist/IconBacking-DgT8DCeh.mjs +0 -39
  77. package/dist/InformationTooltip-4su8bn1e.mjs +0 -41
  78. package/dist/InvestmentUtil-BItV7uEs.mjs +0 -134
  79. package/dist/LineChart-CejWS_rh.mjs +0 -612
  80. package/dist/ListItemAction-CzZ8s39Z.mjs +0 -69
  81. package/dist/ListItemRow-kH1rn8Xu.mjs +0 -67
  82. package/dist/ListItemWrapper-B5r-YQQ_.mjs +0 -42
  83. package/dist/Loader-CxeBwuPG.mjs +0 -21
  84. package/dist/Localization-DnoVyBNK.mjs +0 -38
  85. package/dist/ManageIncome-D1yBODQi.mjs +0 -595
  86. package/dist/MicroWidgetContainer-CfKdQfhi.mjs +0 -45
  87. package/dist/MiniWidgetContainer-BdPiUU-u.mjs +0 -66
  88. package/dist/NetWorthUtils-DilGN1nW.mjs +0 -95
  89. package/dist/Notification-DTNYSd8P.mjs +0 -7
  90. package/dist/NotificationSettings-B4JA5IKE.mjs +0 -677
  91. package/dist/NotificationUtils-BRGFTePr.mjs +0 -23
  92. package/dist/NumberFormatting--XMeeBfr.mjs +0 -49
  93. package/dist/OriginalBalanceAction-BybTXDtO.mjs +0 -114
  94. package/dist/RecurringSettings-D2xbNb67.mjs +0 -88
  95. package/dist/RecurringTransactionsUtil-B3rLEx_g.mjs +0 -253
  96. package/dist/ResponsiveButton-CC9F_Ezk.mjs +0 -45
  97. package/dist/SearchBox-Cpgu_gdO.mjs +0 -50
  98. package/dist/Select-BFt-HD-L.mjs +0 -55
  99. package/dist/SelectionBox-B4xELRgp.mjs +0 -48
  100. package/dist/SingleSegmentDonut-7Uy6VEld.mjs +0 -69
  101. package/dist/Sizes-DISGrlUg.mjs +0 -6
  102. package/dist/SkeletonLoader-BaNboJjD.mjs +0 -38
  103. package/dist/SpendingData-PKlh8caU.mjs +0 -53
  104. package/dist/SpendingLegend-5Ct_FZ8o.mjs +0 -193
  105. package/dist/StatusBar-CPfSXe80.mjs +0 -30
  106. package/dist/TabContentContainer-CnMXkVqr.mjs +0 -21
  107. package/dist/ToggleListItem-Dl1lXNwj.mjs +0 -91
  108. package/dist/TransactionDetails-DctXr07p.mjs +0 -1714
  109. package/dist/TransactionUtils-BphBJBbU.mjs +0 -234
  110. package/dist/TrendsUtil-D9z3kIj_.mjs +0 -69
  111. package/dist/UserStore-CRpKQjpP.mjs +0 -3002
  112. package/dist/ViewMoreMicroCard-BD_MNc2z.mjs +0 -1295
  113. package/dist/WidgetContainer-CmbU4CBH.mjs +0 -482
  114. package/dist/hooks-BaO_gOI6.mjs +0 -77
  115. package/dist/useAccountDisplayName-CFa_MrS6.mjs +0 -15
  116. package/dist/useAriaLive-MkYebyUR.mjs +0 -35
  117. package/dist/useDimensions-CeDR9V8N.mjs +0 -36
  118. package/dist/useInsightsEnabled-DaNLPmUU.mjs +0 -11
  119. package/dist/useScreenSize-mWpmnh5w.mjs +0 -36
  120. package/dist/useWidgetLoadTimer-CJb-RELP.mjs +0 -19
@@ -1,311 +1,300 @@
1
- import { jsxs as C, jsx as e, Fragment as vt } from "react/jsx-runtime";
2
- import g, { useRef as wt, useState as Dt, useEffect as It } from "react";
3
- import { observer as A } from "mobx-react-lite";
4
- import { CategoryIcon as ve, Text as F, Icon as He, H3 as Ge, P as pe } from "@mxenabled/mxui";
5
- import H from "@mui/material/Box";
6
- import S from "@mui/material/Stack";
7
- import Te from "@mui/material/Button";
8
- import { addSeconds as et } from "date-fns/addSeconds";
9
- import { differenceInCalendarMonths as Se } from "date-fns/differenceInCalendarMonths";
10
- import Lt from "numeral";
11
- import { useTheme as Z, styled as Et, alpha as Mt } from "@mui/material/styles";
12
- import { useItemTooltip as At, ChartsTooltipContainer as Rt } from "@mui/x-charts/ChartsTooltip";
13
- import { LineChart as kt } from "@mui/x-charts/LineChart";
14
- import { u as Q } from "../useScreenSize-mWpmnh5w.mjs";
15
- import { u as Ht } from "../useDimensions-CeDR9V8N.mjs";
16
- import tt from "@mui/material/Card";
17
- import ot from "@mui/material/CardContent";
18
- import Ne from "@mui/material/Divider";
19
- import Fe from "@mui/material/Grid";
20
- import { b as nt } from "../Localization-DnoVyBNK.mjs";
21
- import { u as R, l as q, g as $, b as fe, h as we, d as De, B as ye, D as st, f as Be, a as rt } from "../hooks-BaO_gOI6.mjs";
22
- import { C as xe } from "../CurrencyText-CCbE6MmF.mjs";
23
- import { a as Re, C as $e, b as Nt } from "../Category-DEKZGLYe.mjs";
24
- import { f as X, D as G } from "../DateFormats-HudZ3Bjs.mjs";
25
- import { f as re, a as Wt } from "../NumberFormatting--XMeeBfr.mjs";
26
- import { a as Ke, c as Ot, g as Gt } from "../TrendsUtil-D9z3kIj_.mjs";
27
- import { c as Bt, i as Pt, d as Vt, e as zt, g as at, b as it, f as Ye } from "../SpendingData-PKlh8caU.mjs";
28
- import Ft from "@mui/material/ToggleButton";
29
- import $t from "@mui/material/ToggleButtonGroup";
30
- import { parseISO as lt } from "date-fns/parseISO";
31
- import { H as ke } from "../HeaderCell-P8w6CmfO.mjs";
32
- import { T as W, a as Kt } from "../ViewMoreMicroCard-BD_MNc2z.mjs";
33
- import { useGridApiContext as Yt, useGridRootProps as jt, DataGridPro as Ut } from "@mui/x-data-grid-pro";
34
- import Xt from "@mui/material/Badge";
35
- import Zt from "@mui/material/IconButton";
36
- import { A as w } from "../Analytics-CzGzz_sE.mjs";
37
- import { T as ct } from "../EmbeddedCard-DPwJjqMH.mjs";
38
- import { T as dt } from "../TransactionDetails-DctXr07p.mjs";
39
- import { D as Pe } from "../Drawer-BXqqBMxg.mjs";
40
- import { u as Ie } from "../useWidgetLoadTimer-CJb-RELP.mjs";
41
- import { L as Le } from "../Loader-CxeBwuPG.mjs";
42
- import { W as ut } from "../WidgetContainer-CmbU4CBH.mjs";
43
- import { L as Ve } from "../LineChart-CejWS_rh.mjs";
44
- import { M as Qt } from "../MiniWidgetContainer-BdPiUU-u.mjs";
45
- import { subMonths as qt } from "date-fns";
46
- import { TrendingUp as Jt, TrendingDown as eo, MultilineChart as to, ExpandLess as oo, ExpandMore as no, ChevronRight as so, ArrowBack as ro } from "@mxenabled/mx-icons";
47
- import { M as ao } from "../MicroWidgetContainer-CfKdQfhi.mjs";
48
- import io from "@mui/material/Collapse";
49
- import We from "@mui/material/List";
50
- import mt from "@mui/material/ListItem";
51
- import lo from "@mui/material/ListItemButton";
52
- import co from "@mui/material/ListItemIcon";
1
+ import { d as St, f as ze, s as Qe, u as Me } from "../GlobalCopyApi-BeXzaDH9.mjs";
2
+ import { J as ie, X as xt, a as wt, i as It, ln as B, r as Fe, rt as Re, un as X } from "../core-BexP5oiV.mjs";
3
+ import { $t as et, An as Dt, Gn as tt, Hn as Lt, On as Et, _n as Mt, c as ot, fn as nt, gn as At, hn as $e, hr as Rt, in as Nt, jn as be, lr as We, mn as rt, mr as Z, pn as kt, qn as Ht, sr as w, vn as Wt, yn as Oe } from "../accounts-DkyAiLpg.mjs";
4
+ import { n as Se } from "../Analytics-BKzTPees.mjs";
5
+ import { D as ye, E as xe, d as F, h as fe, i as at, k as st, m as Ge, n as we, p as A, s as q, t as Ie } from "../Loader-BlVzRtUd.mjs";
6
+ import { n as Ot, t as Gt } from "../MiniWidgetContainer-COwnjfy7.mjs";
7
+ import { t as Ae } from "../HeaderCell-EhCUSjvj.mjs";
8
+ import { n as Bt, r as W } from "../microinsights-CRf3ChsJ.mjs";
9
+ import m, { useEffect as Pt, useRef as Vt, useState as zt } from "react";
10
+ import { observer as R } from "mobx-react-lite";
11
+ import v from "@mui/material/Stack";
12
+ import { CategoryIcon as De, H3 as Be, Icon as Ne, P as pe, Text as z } from "@mxenabled/mxui";
13
+ import ve from "@mui/material/Button";
14
+ import { ArrowBack as Ft, ChevronRight as $t, ExpandLess as Kt, ExpandMore as jt, MultilineChart as Yt, TrendingDown as Ut, TrendingUp as Xt } from "@mxenabled/mx-icons";
15
+ import { Fragment as Zt, jsx as e, jsxs as f } from "react/jsx-runtime";
16
+ import { alpha as qt, styled as Jt, useTheme as J } from "@mui/material/styles";
17
+ import k from "@mui/material/Box";
18
+ import Qt from "@mui/material/ToggleButton";
19
+ import eo from "@mui/material/ToggleButtonGroup";
20
+ import to from "@mui/material/IconButton";
21
+ import oo from "numeral";
22
+ import { subMonths as no } from "date-fns";
23
+ import { parseISO as it } from "date-fns/parseISO";
24
+ import { addSeconds as lt } from "date-fns/addSeconds";
25
+ import { differenceInCalendarMonths as Te } from "date-fns/differenceInCalendarMonths";
26
+ import { Stack as ro } from "@mui/material";
27
+ import ct from "@mui/material/Card";
28
+ import dt from "@mui/material/CardContent";
29
+ import ke from "@mui/material/Divider";
30
+ import He from "@mui/material/List";
31
+ import ut from "@mui/material/ListItem";
32
+ import ao from "@mui/material/ListItemButton";
33
+ import so from "@mui/material/ListItemIcon";
53
34
  import ht from "@mui/material/ListItemText";
54
- import { g as Oe } from "../TransactionUtils-BphBJBbU.mjs";
55
- import { L as uo } from "../ListItemRow-kH1rn8Xu.mjs";
56
- import { Stack as mo } from "@mui/material";
57
- import ho from "@mui/material/ListItemAvatar";
58
- import { E as go } from "../ExportCsvAction-Bw02ZJEj.mjs";
59
- import { u as po } from "../useInsightsEnabled-DaNLPmUU.mjs";
60
- import { E as fo } from "../EmptyState-CJUDc3kD.mjs";
61
- import { C as yo } from "../ConnectDrawer-Cnjr3Ddg.mjs";
62
- const gt = ({ categoryGuid: t, topLevelCategoryGuid: n }) => {
63
- const { categories: s } = R(), { getCategoryName: o } = q(), r = o(t);
64
- return /* @__PURE__ */ C(S, { alignItems: "center", direction: "column", gap: "8", justifyContent: "center", mb: 4, children: [
65
- /* @__PURE__ */ e(
66
- H,
67
- {
68
- "aria-label": nt(s.category_icon_label_aria, r),
69
- mb: 4,
70
- role: "img",
71
- children: /* @__PURE__ */ e(ve, { categoryGuid: n })
72
- }
73
- ),
74
- /* @__PURE__ */ e(F, { variant: "body1", children: r })
75
- ] });
76
- }, Co = ({
77
- categoryGuids: { guid: t, topLevelGuid: n },
78
- hoveredAreaData: s,
79
- cursorPosition: o,
80
- chartContainerRef: r
81
- }) => {
82
- const c = Z(), a = wt(null), [d, u] = Dt({ x: o.x, y: o.y });
83
- if (It(() => {
35
+ import io from "@mui/material/ListItemAvatar";
36
+ import { ChartsTooltipContainer as lo, useItemTooltip as co } from "@mui/x-charts/ChartsTooltip";
37
+ import { LineChart as uo } from "@mui/x-charts/LineChart";
38
+ import ho from "@mui/material/Badge";
39
+ import { DataGridPro as go, useGridApiContext as mo, useGridRootProps as po } from "@mui/x-data-grid-pro";
40
+ import yo from "@mui/material/Collapse";
41
+ import Ke from "@mui/material/Grid";
42
+ var gt = ({ categoryGuid: t, topLevelCategoryGuid: n }) => {
43
+ const { categories: r } = A(), { getCategoryName: o } = q(), a = o(t);
44
+ return /* @__PURE__ */ f(v, {
45
+ alignItems: "center",
46
+ direction: "column",
47
+ gap: "8",
48
+ justifyContent: "center",
49
+ mb: 4,
50
+ children: [/* @__PURE__ */ e(k, {
51
+ "aria-label": Qe(r.category_icon_label_aria, a),
52
+ mb: 4,
53
+ role: "img",
54
+ children: /* @__PURE__ */ e(De, { categoryGuid: n })
55
+ }), /* @__PURE__ */ e(z, {
56
+ variant: "body1",
57
+ children: a
58
+ })]
59
+ });
60
+ }, fo = ({ categoryGuids: { guid: t, topLevelGuid: n }, hoveredAreaData: r, cursorPosition: o, chartContainerRef: a }) => {
61
+ const l = J(), s = Vt(null), [c, u] = zt({
62
+ x: o.x,
63
+ y: o.y
64
+ });
65
+ if (Pt(() => {
84
66
  (() => {
85
- const m = a.current, _ = r.current;
86
- if (!m || !_) return;
87
- const h = m.getBoundingClientRect(), p = _.getBoundingClientRect();
88
- let y = o.x, T = o.y;
89
- y + h.width * 2 > p.right ? y = o.x - h.width : y - h.width < p.left && (y = o.x), T + h.height * 2 > p.bottom && (T = o.y - h.height), u({ x: y, y: T });
67
+ const g = s.current, _ = a.current;
68
+ if (!g || !_) return;
69
+ const h = g.getBoundingClientRect(), p = _.getBoundingClientRect();
70
+ let C = o.x, x = o.y;
71
+ C + h.width * 2 > p.right ? C = o.x - h.width : C - h.width < p.left && (C = o.x), x + h.height * 2 > p.bottom && (x = o.y - h.height), u({
72
+ x: C,
73
+ y: x
74
+ });
90
75
  })();
91
- }, [o, r]), !s) return null;
92
- const i = s.reduce((f, m) => f + m.y, 0);
93
- return /* @__PURE__ */ e(
94
- tt,
95
- {
96
- ref: a,
97
- sx: {
98
- position: "absolute",
99
- top: d.y,
100
- left: d.x,
101
- width: 250,
102
- pointerEvents: "none"
103
- },
104
- children: /* @__PURE__ */ C(ot, { children: [
105
- /* @__PURE__ */ C(H, { alignItems: "center", display: "flex", flexDirection: "column", children: [
106
- /* @__PURE__ */ e(gt, { categoryGuid: t, topLevelCategoryGuid: n }),
107
- /* @__PURE__ */ e(F, { variant: "body2", children: `${s.length}-month total` }),
108
- /* @__PURE__ */ e(xe, { amount: i, bold: !0, formatString: "0,0", variant: "body2" })
109
- ] }),
110
- /* @__PURE__ */ e(Ne, { sx: { my: 16, width: "100%" } }),
111
- /* @__PURE__ */ e(Fe, { container: !0, children: s.map((f, m) => /* @__PURE__ */ C(g.Fragment, { children: [
112
- m > 0 && m % 3 === 0 && /* @__PURE__ */ e(Ne, { sx: { my: 16, width: "100%" } }),
113
- /* @__PURE__ */ e(Fe, { size: 4, children: /* @__PURE__ */ C(H, { alignItems: "center", display: "flex", flexDirection: "column", children: [
114
- /* @__PURE__ */ e(F, { color: c.palette.text.secondary, variant: "caption", children: f.x }),
115
- /* @__PURE__ */ e(
116
- xe,
117
- {
118
- amount: f.y,
119
- bold: !0,
120
- formatString: "0,0",
121
- variant: "body1"
122
- }
123
- )
124
- ] }) })
125
- ] }, m)) })
126
- ] })
127
- }
128
- );
129
- }, _o = A(Co), bo = ({
130
- sx: t,
131
- categoryGuids: n,
132
- hoveredLegend: s,
133
- legendRef: o,
134
- onHoverLegend: r,
135
- onClickLegend: c
136
- }) => {
137
- const { isMobile: a } = Q(), { getCategoryName: d } = q();
138
- return /* @__PURE__ */ e(
139
- S,
140
- {
141
- direction: "row",
142
- flexWrap: "wrap",
143
- gap: a ? 2 : 6,
144
- justifyContent: "start",
145
- ref: o,
146
- sx: t,
147
- children: n.map(({ guid: u, top_level_guid: i }) => {
148
- const f = s === u, m = Re[u], _ = Re[i], h = m ?? _ ?? Re.default, p = h + "33";
149
- return /* @__PURE__ */ C(
150
- Te,
151
- {
152
- onClick: () => c(u),
153
- onMouseEnter: () => r(u),
154
- onMouseLeave: () => r(null),
155
- sx: {
156
- color: "text.primary",
157
- fontWeight: "normal",
158
- display: "flex",
159
- justifyContent: "center",
160
- alignItems: "center",
161
- paddingX: 8,
162
- paddingY: 4,
163
- borderRadius: 1,
164
- opacity: f ? 1 : 0.7
165
- },
166
- children: [
167
- /* @__PURE__ */ e(
168
- H,
169
- {
170
- sx: {
171
- width: 16,
172
- height: 16,
173
- marginRight: a ? 5 : 10,
174
- borderRadius: "2px",
175
- backgroundColor: s ? f ? h : p : h
176
- }
177
- }
178
- ),
179
- /* @__PURE__ */ e(F, { variant: "body1", children: d(u) })
180
- ]
181
- },
182
- u
183
- );
76
+ }, [o, a]), !r) return null;
77
+ const i = r.reduce((y, g) => y + g.y, 0);
78
+ return /* @__PURE__ */ e(ct, {
79
+ ref: s,
80
+ sx: {
81
+ position: "absolute",
82
+ top: c.y,
83
+ left: c.x,
84
+ width: 250,
85
+ pointerEvents: "none"
86
+ },
87
+ children: /* @__PURE__ */ f(dt, { children: [
88
+ /* @__PURE__ */ f(k, {
89
+ alignItems: "center",
90
+ display: "flex",
91
+ flexDirection: "column",
92
+ children: [
93
+ /* @__PURE__ */ e(gt, {
94
+ categoryGuid: t,
95
+ topLevelCategoryGuid: n
96
+ }),
97
+ /* @__PURE__ */ e(z, {
98
+ variant: "body2",
99
+ children: `${r.length}-month total`
100
+ }),
101
+ /* @__PURE__ */ e(be, {
102
+ amount: i,
103
+ bold: !0,
104
+ formatString: "0,0",
105
+ variant: "body2"
106
+ })
107
+ ]
108
+ }),
109
+ /* @__PURE__ */ e(ke, { sx: {
110
+ my: 16,
111
+ width: "100%"
112
+ } }),
113
+ /* @__PURE__ */ e(Ke, {
114
+ container: !0,
115
+ children: r.map((y, g) => /* @__PURE__ */ f(m.Fragment, { children: [g > 0 && g % 3 === 0 && /* @__PURE__ */ e(ke, { sx: {
116
+ my: 16,
117
+ width: "100%"
118
+ } }), /* @__PURE__ */ e(Ke, {
119
+ size: 4,
120
+ children: /* @__PURE__ */ f(k, {
121
+ alignItems: "center",
122
+ display: "flex",
123
+ flexDirection: "column",
124
+ children: [/* @__PURE__ */ e(z, {
125
+ color: l.palette.text.secondary,
126
+ variant: "caption",
127
+ children: y.x
128
+ }), /* @__PURE__ */ e(be, {
129
+ amount: y.y,
130
+ bold: !0,
131
+ formatString: "0,0",
132
+ variant: "body1"
133
+ })]
134
+ })
135
+ })] }, g))
184
136
  })
185
- }
186
- );
187
- }, To = ({
188
- categoryGuids: { guid: t, topLevelGuid: n },
189
- series: s,
190
- xData: o
191
- }) => {
192
- const r = At(), c = Z();
193
- if (!r?.identifier) return null;
194
- const { dataIndex: a, seriesId: d } = r.identifier;
195
- if (a == null || !d) return null;
196
- const i = s.find((m) => m.id === d)?.data?.[a], f = o?.[a];
197
- return i === void 0 || !f ? null : /* @__PURE__ */ e(tt, { sx: { pt: 4, px: 8 }, children: /* @__PURE__ */ e(ot, { children: /* @__PURE__ */ C(H, { alignItems: "center", display: "flex", flexDirection: "column", children: [
198
- /* @__PURE__ */ e(gt, { categoryGuid: t, topLevelCategoryGuid: n }),
199
- /* @__PURE__ */ e(F, { color: c.palette.text.secondary, variant: "body2", children: X(f, G.MONTH_SHORT_YEAR) }),
200
- /* @__PURE__ */ e(xe, { amount: String(i), bold: !0, formatString: "0,0", variant: "body1" })
201
- ] }) }) });
202
- }, So = ({
203
- onHoverArea: t,
204
- onHoverPoint: n,
205
- onHoverLegend: s,
206
- onClickLegend: o,
207
- stackedDatasets: r,
208
- unstackedDatasets: c = [],
209
- availableHeight: a = 0,
210
- minimumHeight: d = 350
211
- }) => {
212
- const u = Z(), { isMobile: i } = Q(), [f, { height: m }] = Ht(), _ = g.useRef(null), [h, p] = g.useState(0);
213
- g.useEffect(() => {
214
- const l = Math.max(a - m, d);
215
- p(l);
216
- }, [a, m]);
217
- const [y, T] = g.useState(null), [N, x] = g.useState({
137
+ ] })
138
+ });
139
+ }, Co = R(fo), _o = ({ sx: t, categoryGuids: n, hoveredLegend: r, legendRef: o, onHoverLegend: a, onClickLegend: l }) => {
140
+ const { isMobile: s } = Z(), { getCategoryName: c } = q();
141
+ return /* @__PURE__ */ e(v, {
142
+ direction: "row",
143
+ flexWrap: "wrap",
144
+ gap: s ? 2 : 6,
145
+ justifyContent: "start",
146
+ ref: o,
147
+ sx: t,
148
+ children: n.map(({ guid: u, top_level_guid: i }) => {
149
+ const y = r === u, g = Me[u], _ = Me[i], h = g ?? _ ?? Me.default, p = h + "33";
150
+ return /* @__PURE__ */ f(ve, {
151
+ onClick: () => l(u),
152
+ onMouseEnter: () => a(u),
153
+ onMouseLeave: () => a(null),
154
+ sx: {
155
+ color: "text.primary",
156
+ fontWeight: "normal",
157
+ display: "flex",
158
+ justifyContent: "center",
159
+ alignItems: "center",
160
+ paddingX: 8,
161
+ paddingY: 4,
162
+ borderRadius: 1,
163
+ opacity: y ? 1 : 0.7
164
+ },
165
+ children: [/* @__PURE__ */ e(k, { sx: {
166
+ width: 16,
167
+ height: 16,
168
+ marginRight: s ? 5 : 10,
169
+ borderRadius: "2px",
170
+ backgroundColor: r ? y ? h : p : h
171
+ } }), /* @__PURE__ */ e(z, {
172
+ variant: "body1",
173
+ children: c(u)
174
+ })]
175
+ }, u);
176
+ })
177
+ });
178
+ }, bo = ({ categoryGuids: { guid: t, topLevelGuid: n }, series: r, xData: o }) => {
179
+ const a = co(), l = J();
180
+ if (!a?.identifier) return null;
181
+ const { dataIndex: s, seriesId: c } = a.identifier;
182
+ if (s == null || !c) return null;
183
+ const u = r.find((y) => y.id === c)?.data?.[s], i = o?.[s];
184
+ return u === void 0 || !i ? null : /* @__PURE__ */ e(ct, {
185
+ sx: {
186
+ pt: 4,
187
+ px: 8
188
+ },
189
+ children: /* @__PURE__ */ e(dt, { children: /* @__PURE__ */ f(k, {
190
+ alignItems: "center",
191
+ display: "flex",
192
+ flexDirection: "column",
193
+ children: [
194
+ /* @__PURE__ */ e(gt, {
195
+ categoryGuid: t,
196
+ topLevelCategoryGuid: n
197
+ }),
198
+ /* @__PURE__ */ e(z, {
199
+ color: l.palette.text.secondary,
200
+ variant: "body2",
201
+ children: X(i, B.MONTH_SHORT_YEAR)
202
+ }),
203
+ /* @__PURE__ */ e(be, {
204
+ amount: String(u),
205
+ bold: !0,
206
+ formatString: "0,0",
207
+ variant: "body1"
208
+ })
209
+ ]
210
+ }) })
211
+ });
212
+ }, vo = ({ onHoverArea: t, onHoverPoint: n, onHoverLegend: r, onClickLegend: o, stackedDatasets: a, unstackedDatasets: l = [], availableHeight: s = 0, minimumHeight: c = 350 }) => {
213
+ const u = J(), { isMobile: i } = Z(), [y, { height: g }] = Ot(), _ = m.useRef(null), [h, p] = m.useState(0);
214
+ m.useEffect(() => {
215
+ p(Math.max(s - g, c));
216
+ }, [s, g]);
217
+ const [C, x] = m.useState(null), [H, T] = m.useState({
218
218
  hoveredSeriesId: null,
219
219
  hoveredAreaData: null,
220
220
  isAreaHovered: !1,
221
- cursorPos: { x: 0, y: 0 }
222
- }), { hoveredSeriesId: L, hoveredAreaData: M, isAreaHovered: E, cursorPos: v } = N, K = E && L && M, ae = !K, Y = [...r, ...c], J = Y[0]?.dataset.length ?? 0, P = Y.flatMap((l) => l.dataset.map((b) => b.x)), V = Y.flatMap((l) => l.dataset.map((b) => b.y)), O = r[0]?.dataset?.map(
223
- (l, b) => r.reduce((I, z) => I + z.dataset[b]?.y || 0, 0)
224
- ) ?? [0], ee = Math.max(...O), Ce = Math.max(
225
- ...c.flatMap((l) => l.dataset.map((b) => b.y))
226
- ), ie = Math.floor(Math.min(...V) / 100) * 100, te = Math.ceil(Math.max(ee, Ce) / 100) * 100, j = r.map((l, b) => ({
221
+ cursorPos: {
222
+ x: 0,
223
+ y: 0
224
+ }
225
+ }), { hoveredSeriesId: L, hoveredAreaData: E, isAreaHovered: N, cursorPos: S } = H, $ = N && L && E, le = !$, K = [...a, ...l], Q = K[0]?.dataset.length ?? 0, P = K.flatMap((d) => d.dataset.map((b) => b.x)), V = K.flatMap((d) => d.dataset.map((b) => b.y)), O = a[0]?.dataset?.map((d, b) => a.reduce((D, U) => D + U.dataset[b]?.y || 0, 0)) ?? [0], ee = Math.max(...O), ce = Math.max(...l.flatMap((d) => d.dataset.map((b) => b.y))), j = Math.floor(Math.min(...V) / 100) * 100, de = Math.ceil(Math.max(ee, ce) / 100) * 100, Y = a.map((d, b) => ({
227
226
  id: `stacked-${b}`,
228
- guid: l.category_guid,
229
- top_level_guid: l.top_level_category_guid,
227
+ guid: d.category_guid,
228
+ top_level_guid: d.top_level_category_guid,
230
229
  area: !0,
231
- color: r[b].category_color ?? u.palette.primary.main,
232
- data: l.dataset.map((I) => I.y),
233
- label: r[b].category_name,
230
+ color: a[b].category_color ?? u.palette.primary.main,
231
+ data: d.dataset.map((D) => D.y),
232
+ label: a[b].category_name,
234
233
  stack: "total",
235
234
  type: "line",
236
235
  highlightScope: { highlight: "item" },
237
- valueFormatter: (I) => re(I, "0,0")
238
- })), ne = c.map((l, b) => ({
236
+ valueFormatter: (D) => ie(D, "0,0")
237
+ })), te = l.map((d, b) => ({
239
238
  id: `unstacked-${b}`,
240
- guid: l.category_guid,
241
- top_level_guid: l.top_level_category_guid,
239
+ guid: d.category_guid,
240
+ top_level_guid: d.top_level_category_guid,
242
241
  area: !1,
243
- color: l.category_color,
244
- data: l.dataset.map((I) => I.y),
245
- label: l.category_name,
242
+ color: d.category_color,
243
+ data: d.dataset.map((D) => D.y),
244
+ label: d.category_name,
246
245
  type: "line",
247
- valueFormatter: (I) => re(I, "0,0")
248
- })), U = [...j, ...ne], de = [
249
- ...j.map(({ guid: l, top_level_guid: b }) => ({
250
- guid: l,
251
- top_level_guid: b
252
- })),
253
- ...ne.map(({ guid: l, top_level_guid: b }) => ({
254
- guid: l,
255
- top_level_guid: b
256
- }))
257
- ], B = (l) => {
258
- const I = l.startsWith("stacked-") ? r[parseInt(l.split("-")[1])] : c[parseInt(l.split("-")[1])];
246
+ valueFormatter: (D) => ie(D, "0,0")
247
+ })), ae = [...Y, ...te], oe = [...Y.map(({ guid: d, top_level_guid: b }) => ({
248
+ guid: d,
249
+ top_level_guid: b
250
+ })), ...te.map(({ guid: d, top_level_guid: b }) => ({
251
+ guid: d,
252
+ top_level_guid: b
253
+ }))], ne = (d) => {
254
+ const b = d.startsWith("stacked-") ? a[parseInt(d.split("-")[1])] : l[parseInt(d.split("-")[1])];
259
255
  return {
260
- guid: I?.category_guid,
261
- topLevelGuid: I?.top_level_category_guid
256
+ guid: b?.category_guid,
257
+ topLevelGuid: b?.top_level_category_guid
262
258
  };
263
- }, ue = (l) => {
264
- T(l), s?.(l ?? "");
265
- }, se = (l) => {
266
- o?.(l ?? "");
267
- }, le = () => {
268
- const l = B(String(L)).guid;
269
- l && o?.(l);
270
- }, ce = (l) => {
271
- const b = String(l?.seriesId), I = B(b).guid, z = U.find((he) => he.id === b), Ee = z && l?.dataIndex !== void 0, _e = z && l?.dataIndex === void 0;
272
- if (Ee)
273
- x({
274
- hoveredSeriesId: b,
275
- hoveredAreaData: null,
276
- isAreaHovered: !1,
277
- cursorPos: v
278
- }), n?.(I);
279
- else if (_e) {
280
- const he = z?.data.map((Me, Ae) => ({
281
- x: P[Ae],
282
- y: Me
283
- })) ?? [];
284
- x({
285
- hoveredSeriesId: b,
286
- hoveredAreaData: he,
287
- isAreaHovered: !0,
288
- cursorPos: v
289
- }), t?.(I);
290
- } else
291
- x({
292
- hoveredSeriesId: null,
293
- hoveredAreaData: null,
294
- isAreaHovered: !1,
295
- cursorPos: v
296
- });
297
- }, me = (l) => {
298
- if (l.target instanceof Element && l.target.classList[0]?.includes("MuiMarkElement-root"))
299
- return;
300
- const b = l.currentTarget.getBoundingClientRect();
301
- x((I) => ({
302
- ...I,
259
+ }, se = (d) => {
260
+ x(d), r?.(d ?? "");
261
+ }, ue = (d) => {
262
+ o?.(d ?? "");
263
+ }, he = () => {
264
+ const d = ne(String(L)).guid;
265
+ d && o?.(d);
266
+ }, ge = (d) => {
267
+ const b = String(d?.seriesId), D = ne(b).guid, U = ae.find((me) => me.id === b), Ce = U && d?.dataIndex !== void 0, Le = U && d?.dataIndex === void 0;
268
+ Ce ? (T({
269
+ hoveredSeriesId: b,
270
+ hoveredAreaData: null,
271
+ isAreaHovered: !1,
272
+ cursorPos: S
273
+ }), n?.(D)) : Le ? (T({
274
+ hoveredSeriesId: b,
275
+ hoveredAreaData: U?.data.map((me, Ee) => ({
276
+ x: P[Ee],
277
+ y: me
278
+ })) ?? [],
279
+ isAreaHovered: !0,
280
+ cursorPos: S
281
+ }), t?.(D)) : T({
282
+ hoveredSeriesId: null,
283
+ hoveredAreaData: null,
284
+ isAreaHovered: !1,
285
+ cursorPos: S
286
+ });
287
+ }, I = (d) => {
288
+ if (d.target instanceof Element && d.target.classList[0]?.includes("MuiMarkElement-root")) return;
289
+ const b = d.currentTarget.getBoundingClientRect();
290
+ T((D) => ({
291
+ ...D,
303
292
  cursorPos: {
304
- x: l.clientX - b.left,
305
- y: l.clientY - b.top
293
+ x: d.clientX - b.left,
294
+ y: d.clientY - b.top
306
295
  }
307
296
  }));
308
- }, D = {
297
+ }, G = {
309
298
  p: 4,
310
299
  "& .MuiBarLabel-root": {
311
300
  fontSize: 10,
@@ -315,921 +304,799 @@ const gt = ({ categoryGuid: t, topLevelCategoryGuid: n }) => {
315
304
  opacity: 0.4,
316
305
  transition: "opacity 0.3s ease"
317
306
  },
318
- "& .MuiAreaElement-root:hover": {
319
- opacity: 1
320
- },
321
- '& [class*="MuiLineElement-series-unstacked-"]': {
322
- strokeWidth: 3
323
- },
324
- ...y && j.reduce((l, b, I) => {
325
- const z = `.MuiAreaElement-series-stacked-${I}`;
326
- return l[z] = {
327
- opacity: j[I].guid === y ? 0.9 : 0.2
328
- }, l;
307
+ "& .MuiAreaElement-root:hover": { opacity: 1 },
308
+ '& [class*="MuiLineElement-series-unstacked-"]': { strokeWidth: 3 },
309
+ ...C && Y.reduce((d, b, D) => {
310
+ const U = `.MuiAreaElement-series-stacked-${D}`;
311
+ return d[U] = { opacity: Y[D].guid === C ? 0.9 : 0.2 }, d;
329
312
  }, {})
330
313
  };
331
- return /* @__PURE__ */ e(
332
- H,
333
- {
334
- onMouseMove: me,
335
- ref: _,
336
- sx: {
337
- position: "relative",
314
+ return /* @__PURE__ */ e(k, {
315
+ onMouseMove: I,
316
+ ref: _,
317
+ sx: {
318
+ position: "relative",
319
+ touchAction: "pan-y",
320
+ "& svg": {
338
321
  touchAction: "pan-y",
339
- "& svg": {
340
- touchAction: "pan-y",
341
- userSelect: "none"
342
- },
343
- "& .recharts-wrapper": {
344
- touchAction: "pan-y"
345
- }
322
+ userSelect: "none"
346
323
  },
347
- children: /* @__PURE__ */ C(
348
- S,
349
- {
350
- direction: { xs: "column", md: "column" },
351
- spacing: { xs: 0, md: 4 },
352
- sx: { width: "100%", position: "relative" },
353
- children: [
354
- /* @__PURE__ */ e(
355
- kt,
356
- {
357
- height: h,
358
- hideLegend: !0,
359
- margin: { bottom: 24, left: 12, right: 54, top: 48 },
360
- onAreaClick: le,
361
- onHighlightChange: ce,
362
- series: U,
363
- skipAnimation: !0,
364
- slotProps: {
365
- tooltip: { trigger: ae ? "item" : "none" }
366
- },
367
- slots: {
368
- tooltip: ae && L ? (l) => /* @__PURE__ */ e(Rt, { children: /* @__PURE__ */ e(
369
- To,
370
- {
371
- ...l,
372
- categoryGuids: B(L),
373
- series: U,
374
- xData: P
375
- }
376
- ) }) : void 0
377
- },
378
- sx: D,
379
- xAxis: [
380
- {
381
- data: P,
382
- scaleType: "time",
383
- valueFormatter: (l) => X(l, G.MONTH_SHORT_YEAR),
384
- tickNumber: J
385
- // How many ticks to show on the x-axis
386
- }
387
- ],
388
- yAxis: [
389
- {
390
- min: ie,
391
- max: te || 100,
392
- valueFormatter: (l) => Lt(l).format("0a")
393
- }
394
- ]
395
- }
396
- ),
397
- /* @__PURE__ */ e(
398
- bo,
399
- {
400
- categoryGuids: de,
401
- hoveredLegend: y,
402
- legendRef: f,
403
- onClickLegend: se,
404
- onHoverLegend: ue,
405
- sx: { px: i ? 0 : 24 }
406
- }
407
- ),
408
- K && /* @__PURE__ */ e(
409
- _o,
410
- {
411
- categoryGuids: B(L),
412
- chartContainerRef: _,
413
- cursorPosition: v,
414
- hoveredAreaData: M.map((l) => ({
415
- ...l,
416
- x: X(l.x, G.MONTH_SHORT_YEAR)
417
- }))
418
- }
419
- )
420
- ]
421
- }
422
- )
423
- }
424
- );
425
- }, pt = ({ selectedTab: t, onTabChange: n }) => {
426
- const { common: s } = R();
427
- return /* @__PURE__ */ e(
428
- $t,
429
- {
430
- "aria-label": s.view_toggle,
431
- exclusive: !0,
432
- onChange: n,
433
- orientation: "horizontal",
434
- value: t,
435
- children: ["Chart", "Table"].map((o) => /* @__PURE__ */ e(
436
- Ft,
437
- {
438
- "aria-label": o === "Chart" ? s.view_chart : s.view_table,
439
- "aria-pressed": t === o,
440
- color: "primary",
441
- sx: { width: 56 },
442
- value: o,
443
- children: o === "Chart" ? /* @__PURE__ */ e(He, { name: "table_chart_view" }) : /* @__PURE__ */ e(He, { name: "format_list_bulleted" })
444
- },
445
- o
446
- ))
447
- }
448
- );
449
- }, ft = ({ selectedDateRange: t, selectedCategoryGuid: n }) => {
450
- const { trends: s } = R(), { isMobile: o, isDesktop: r } = Q(), { getCategoryName: c } = q(), a = g.useMemo(() => {
451
- const i = t.start.getFullYear() === t.end.getFullYear() ? X(
452
- t.start,
453
- o ? G.MONTH_SHORT : G.MONTH_LONG
454
- ) : X(
455
- t.start,
456
- o ? G.MONTH_SHORT_YEAR : G.MONTH_YEAR
457
- ), f = X(
458
- t.end,
459
- o ? G.MONTH_SHORT_YEAR : G.MONTH_YEAR
460
- );
461
- return `${i} - ${f}`;
462
- }, [t, o]), u = c(n) || (o ? s.sub_title : s.sub_title_by_category);
463
- return /* @__PURE__ */ C(H, { children: [
464
- /* @__PURE__ */ e(
465
- Ge,
466
- {
467
- sx: {
468
- fontSize: r ? null : 15,
469
- overflow: "visible",
470
- textOverflow: "unset"
471
- },
472
- children: u
473
- }
474
- ),
475
- /* @__PURE__ */ e(F, { variant: r ? "subtitle1" : "body2", children: a })
476
- ] });
477
- }, xo = (t) => {
324
+ "& .recharts-wrapper": { touchAction: "pan-y" }
325
+ },
326
+ children: /* @__PURE__ */ f(v, {
327
+ direction: {
328
+ xs: "column",
329
+ md: "column"
330
+ },
331
+ spacing: {
332
+ xs: 0,
333
+ md: 4
334
+ },
335
+ sx: {
336
+ width: "100%",
337
+ position: "relative"
338
+ },
339
+ children: [
340
+ /* @__PURE__ */ e(uo, {
341
+ height: h,
342
+ hideLegend: !0,
343
+ margin: {
344
+ bottom: 24,
345
+ left: 12,
346
+ right: 54,
347
+ top: 48
348
+ },
349
+ onAreaClick: he,
350
+ onHighlightChange: ge,
351
+ series: ae,
352
+ skipAnimation: !0,
353
+ slotProps: { tooltip: { trigger: le ? "item" : "none" } },
354
+ slots: { tooltip: le && L ? (d) => /* @__PURE__ */ e(lo, { children: /* @__PURE__ */ e(bo, {
355
+ ...d,
356
+ categoryGuids: ne(L),
357
+ series: ae,
358
+ xData: P
359
+ }) }) : void 0 },
360
+ sx: G,
361
+ xAxis: [{
362
+ data: P,
363
+ scaleType: "time",
364
+ valueFormatter: (d) => X(d, B.MONTH_SHORT_YEAR),
365
+ tickNumber: Q
366
+ }],
367
+ yAxis: [{
368
+ min: j,
369
+ max: de || 100,
370
+ valueFormatter: (d) => oo(d).format("0a")
371
+ }]
372
+ }),
373
+ /* @__PURE__ */ e(_o, {
374
+ categoryGuids: oe,
375
+ hoveredLegend: C,
376
+ legendRef: y,
377
+ onClickLegend: ue,
378
+ onHoverLegend: se,
379
+ sx: { px: i ? 0 : 24 }
380
+ }),
381
+ $ && /* @__PURE__ */ e(Co, {
382
+ categoryGuids: ne(L),
383
+ chartContainerRef: _,
384
+ cursorPosition: S,
385
+ hoveredAreaData: E.map((d) => ({
386
+ ...d,
387
+ x: X(d.x, B.MONTH_SHORT_YEAR)
388
+ }))
389
+ })
390
+ ]
391
+ })
392
+ });
393
+ }, mt = ({ selectedTab: t, onTabChange: n }) => {
394
+ const { common: r } = A();
395
+ return /* @__PURE__ */ e(eo, {
396
+ "aria-label": r.view_toggle,
397
+ exclusive: !0,
398
+ onChange: n,
399
+ orientation: "horizontal",
400
+ value: t,
401
+ children: ["Chart", "Table"].map((o) => /* @__PURE__ */ e(Qt, {
402
+ "aria-label": o === "Chart" ? r.view_chart : r.view_table,
403
+ "aria-pressed": t === o,
404
+ color: "primary",
405
+ sx: { width: 56 },
406
+ value: o,
407
+ children: o === "Chart" ? /* @__PURE__ */ e(Ne, { name: "table_chart_view" }) : /* @__PURE__ */ e(Ne, { name: "format_list_bulleted" })
408
+ }, o))
409
+ });
410
+ }, pt = ({ selectedDateRange: t, selectedCategoryGuid: n }) => {
411
+ const { trends: r } = A(), { isMobile: o, isDesktop: a } = Z(), { getCategoryName: l } = q(), s = m.useMemo(() => `${t.start.getFullYear() === t.end.getFullYear() ? X(t.start, o ? B.MONTH_SHORT : B.MONTH_LONG) : X(t.start, o ? B.MONTH_SHORT_YEAR : B.MONTH_YEAR)} - ${X(t.end, o ? B.MONTH_SHORT_YEAR : B.MONTH_YEAR)}`, [t, o]), c = l(n) || (o ? r.sub_title : r.sub_title_by_category);
412
+ return /* @__PURE__ */ f(k, { children: [/* @__PURE__ */ e(Be, {
413
+ sx: {
414
+ fontSize: a ? null : 15,
415
+ overflow: "visible",
416
+ textOverflow: "unset"
417
+ },
418
+ children: c
419
+ }), /* @__PURE__ */ e(z, {
420
+ variant: a ? "subtitle1" : "body2",
421
+ children: s
422
+ })] });
423
+ }, To = (t) => {
478
424
  const n = t.id === "total";
479
- return /* @__PURE__ */ C(S, { alignItems: "center", direction: "row", role: "rowheader", tabIndex: t.tabIndex, children: [
480
- !n && /* @__PURE__ */ e(H, { "aria-hidden": !0, children: /* @__PURE__ */ e(ve, { categoryGuid: t.row.top_level_category_guid, variant: "twotone" }) }),
481
- /* @__PURE__ */ e(F, { bold: n, sx: { ml: 12 }, variant: n ? "body1" : "body2", children: t.row.category })
482
- ] });
425
+ return /* @__PURE__ */ f(v, {
426
+ alignItems: "center",
427
+ direction: "row",
428
+ role: "rowheader",
429
+ tabIndex: t.tabIndex,
430
+ children: [!n && /* @__PURE__ */ e(k, {
431
+ "aria-hidden": !0,
432
+ children: /* @__PURE__ */ e(De, {
433
+ categoryGuid: t.row.top_level_category_guid,
434
+ variant: "twotone"
435
+ })
436
+ }), /* @__PURE__ */ e(z, {
437
+ bold: n,
438
+ sx: { ml: 12 },
439
+ variant: n ? "body1" : "body2",
440
+ children: t.row.category
441
+ })]
442
+ });
483
443
  }, je = (t) => {
484
- const n = t.row.category_guid, s = t.row.top_level_category_guid, o = n === $e.INCOME || s === $e.INCOME, r = t.id === "total", c = t.field === "total", a = c ? t.row[t.field] : t.row.monthlyAmounts[t.field];
485
- return /* @__PURE__ */ e(S, { alignItems: "flex-end", direction: "row", tabIndex: t.tabIndex, children: /* @__PURE__ */ e(
486
- xe,
487
- {
488
- amount: o ? Math.abs(a) : a,
444
+ const n = t.row.category_guid, r = t.row.top_level_category_guid, o = n === ze.INCOME || r === ze.INCOME, a = t.id === "total", l = t.field === "total", s = l ? t.row[t.field] : t.row.monthlyAmounts[t.field];
445
+ return /* @__PURE__ */ e(v, {
446
+ alignItems: "flex-end",
447
+ direction: "row",
448
+ tabIndex: t.tabIndex,
449
+ children: /* @__PURE__ */ e(be, {
450
+ amount: o ? Math.abs(s) : s,
489
451
  isIncome: o,
490
- sx: { fontWeight: o || c || r ? 600 : 500 },
452
+ sx: { fontWeight: o || l || a ? 600 : 500 },
491
453
  symbol: o ? "+" : void 0,
492
- variant: r ? "body1" : "body2"
493
- }
494
- ) });
495
- }, Ue = (t, n) => {
496
- const s = X(lt(n.isoDate), G.MONTH_LONG);
497
- return t[s] = n.amount, t;
498
- }, Xe = (t) => (n, s) => {
499
- const o = X(lt(s.isoDate), G.MONTH_LONG);
500
- return n + (t.includes(o) ? s.amount : 0);
501
- }, vo = (t, n) => {
502
- const s = [], o = new Date(t);
454
+ variant: a ? "body1" : "body2"
455
+ })
456
+ });
457
+ }, Ye = (t, n) => {
458
+ const r = X(it(n.isoDate), B.MONTH_LONG);
459
+ return t[r] = n.amount, t;
460
+ }, Ue = (t) => (n, r) => {
461
+ const o = X(it(r.isoDate), B.MONTH_LONG);
462
+ return n + (t.includes(o) ? r.amount : 0);
463
+ }, So = (t, n) => {
464
+ const r = [], o = new Date(t);
503
465
  for (; o <= n; ) {
504
- const r = X(o, G.MONTH_LONG);
505
- s.push(r), o.setMonth(o.getMonth() + 1);
466
+ const a = X(o, B.MONTH_LONG);
467
+ r.push(a), o.setMonth(o.getMonth() + 1);
506
468
  }
507
- return s;
508
- }, wo = (t, n) => {
509
- const s = {
469
+ return r;
470
+ }, xo = (t, n) => {
471
+ const r = {
510
472
  field: "category",
511
473
  flex: 1,
512
474
  headerClassName: "trends-table-header",
513
475
  headerName: n.category_title,
514
476
  minWidth: 210,
515
- renderHeader: ke,
516
- renderCell: xo,
477
+ renderHeader: Ae,
478
+ renderCell: To,
517
479
  sortable: !0,
518
- sortComparator: Ot,
480
+ sortComparator: It,
519
481
  type: "string"
520
- }, o = t.map((c) => ({
521
- field: c,
482
+ }, o = t.map((l) => ({
483
+ field: l,
522
484
  flex: 1,
523
485
  headerClassName: "trends-table-header",
524
- headerName: c,
486
+ headerName: l,
525
487
  minWidth: 100,
526
- renderHeader: ke,
488
+ renderHeader: Ae,
527
489
  renderCell: je,
528
490
  align: "center",
529
491
  headerAlign: "center",
530
492
  sortable: !0,
531
493
  hideSortIcons: !1,
532
494
  type: "number",
533
- sortComparator: Ke,
534
- valueGetter: (a, d) => d.monthlyAmounts?.[c] ?? 0
535
- })), r = {
495
+ sortComparator: Fe,
496
+ valueGetter: (s, c) => c.monthlyAmounts?.[l] ?? 0
497
+ })), a = {
536
498
  field: "total",
537
499
  flex: 1,
538
500
  headerClassName: "trends-table-header",
539
501
  headerName: n.table_column_total,
540
502
  minWidth: 100,
541
- renderHeader: ke,
503
+ renderHeader: Ae,
542
504
  renderCell: je,
543
505
  align: "center",
544
506
  headerAlign: "center",
545
507
  sortable: !0,
546
508
  hideSortIcons: !1,
547
509
  type: "number",
548
- sortComparator: Ke
510
+ sortComparator: Fe
549
511
  };
550
- return [s, ...o, r];
551
- }, Ze = (t, n, s, o, r) => {
552
- const c = t.filter((a) => a.is_income === s).map((a) => {
553
- let d = a.totalMonthlyAmounts;
554
- return r && (d = a.monthlyAmounts), {
555
- id: a.guid,
556
- category: a.name,
557
- category_guid: a.guid,
512
+ return [
513
+ r,
514
+ ...o,
515
+ a
516
+ ];
517
+ }, Xe = (t, n, r, o, a) => {
518
+ const l = t.filter((s) => s.is_income === r).map((s) => {
519
+ let c = s.totalMonthlyAmounts;
520
+ return a && (c = s.monthlyAmounts), {
521
+ id: s.guid,
522
+ category: s.name,
523
+ category_guid: s.guid,
558
524
  isParent: !1,
559
- top_level_category_guid: a.parent_guid || a.guid,
560
- total: d.reduce(Xe(o), 0),
561
- monthlyAmounts: d.reduce(Ue, {})
525
+ top_level_category_guid: s.parent_guid || s.guid,
526
+ total: c.reduce(Ue(o), 0),
527
+ monthlyAmounts: c.reduce(Ye, {})
562
528
  };
563
529
  });
564
- if (r && r.is_income === s) {
565
- const a = r.monthlyAmounts.reduce(Xe(o), 0);
566
- a !== 0 && c.push({
567
- id: `sub-${r.guid}`,
568
- category: nt(n.category_general, r.name),
569
- category_guid: r.guid,
530
+ if (a && a.is_income === r) {
531
+ const s = a.monthlyAmounts.reduce(Ue(o), 0);
532
+ s !== 0 && l.push({
533
+ id: `sub-${a.guid}`,
534
+ category: Qe(n.category_general, a.name),
535
+ category_guid: a.guid,
570
536
  isParent: !0,
571
- top_level_category_guid: r.guid,
572
- total: a,
573
- monthlyAmounts: r.monthlyAmounts.reduce(Ue, {})
537
+ top_level_category_guid: a.guid,
538
+ total: s,
539
+ monthlyAmounts: a.monthlyAmounts.reduce(Ye, {})
574
540
  });
575
541
  }
576
- return c;
577
- }, Do = Et("div")({
542
+ return l;
543
+ }, wo = Jt("div")({
578
544
  display: "flex",
579
545
  visibility: "hidden",
580
546
  width: 0
581
547
  });
582
- function Io({
583
- direction: t,
584
- index: n,
585
- sortingOrder: s,
586
- disabled: o,
587
- className: r,
588
- field: c
589
- }) {
590
- const a = Yt(), d = jt();
548
+ function Io({ direction: t, index: n, sortingOrder: r, disabled: o, className: a, field: l }) {
549
+ const s = mo(), c = po();
591
550
  let u = null;
592
551
  const i = {};
593
- if (t === "asc" ? u = d.slots.columnSortedAscendingIcon : t === "desc" ? u = d.slots.columnSortedDescendingIcon : (u = d.slots.columnUnsortedIcon ?? null, i.sortingOrder = s), !u) return null;
594
- const m = a.current.getColumn(c)?.headerName ?? c;
595
- let _ = "";
596
- t === "asc" ? _ = ", sorted ascending" : t === "desc" && (_ = ", sorted descending");
597
- const h = ["Total", "Category"].includes(m) ? "" : " category totals", p = `Sort by ${m}${h}${_}`, y = /* @__PURE__ */ e(u, { className: "MuiDataGrid-sortIcon", fontSize: "small", ...i }), T = /* @__PURE__ */ e(
598
- Zt,
599
- {
600
- disabled: o,
601
- size: "small",
602
- tabIndex: -1,
603
- ...d.slotProps?.baseIconButton,
604
- "aria-label": p,
605
- className: `MuiDataGrid-sortButton${r ? ` ${r}` : ""}`,
606
- title: p,
607
- children: y
608
- }
609
- );
610
- return /* @__PURE__ */ e(Do, { className: "MuiDataGrid-iconButtonContainer", children: n != null ? /* @__PURE__ */ e(Xt, { badgeContent: n, color: "default", overlap: "circular", children: T }) : T });
552
+ if (t === "asc" ? u = c.slots.columnSortedAscendingIcon : t === "desc" ? u = c.slots.columnSortedDescendingIcon : (u = c.slots.columnUnsortedIcon ?? null, i.sortingOrder = r), !u) return null;
553
+ const y = s.current.getColumn(l)?.headerName ?? l;
554
+ let g = "";
555
+ t === "asc" ? g = ", sorted ascending" : t === "desc" && (g = ", sorted descending");
556
+ const _ = `Sort by ${y}${["Total", "Category"].includes(y) ? "" : " category totals"}${g}`, h = /* @__PURE__ */ e(u, {
557
+ className: "MuiDataGrid-sortIcon",
558
+ fontSize: "small",
559
+ ...i
560
+ }), p = /* @__PURE__ */ e(to, {
561
+ disabled: o,
562
+ size: "small",
563
+ tabIndex: -1,
564
+ ...c.slotProps?.baseIconButton,
565
+ "aria-label": _,
566
+ className: `MuiDataGrid-sortButton${a ? ` ${a}` : ""}`,
567
+ title: _,
568
+ children: h
569
+ });
570
+ return /* @__PURE__ */ e(wo, {
571
+ className: "MuiDataGrid-iconButtonContainer",
572
+ children: n != null ? /* @__PURE__ */ e(ho, {
573
+ badgeContent: n,
574
+ color: "default",
575
+ overlap: "circular",
576
+ children: p
577
+ }) : p
578
+ });
611
579
  }
612
- const Lo = g.memo(Io), Qe = ({
613
- columns: t,
614
- onRowClick: n,
615
- parentCategory: s,
616
- rows: o,
617
- totalRow: r
618
- }) => {
619
- const c = Z(), { onEvent: a } = $(), d = c.palette.mode === "light";
620
- return /* @__PURE__ */ e(
621
- Ut,
622
- {
623
- columns: t,
624
- disableColumnFilter: !0,
625
- disableColumnMenu: !0,
626
- hideFooter: !0,
627
- initialState: { sorting: { sortModel: [{ field: "category", sort: "asc" }] } },
628
- onRowClick: (u) => {
629
- s || n?.(u.row.category_guid), a(w.TRENDS_CLICK_LIST_ITEM, {
630
- ...W,
631
- listItem: Nt[u.row.category_guid]
632
- });
633
- },
634
- pinnedRows: {
635
- bottom: r ? [r] : []
580
+ var Do = m.memo(Io), Ze = ({ columns: t, onRowClick: n, parentCategory: r, rows: o, totalRow: a }) => {
581
+ const l = J(), { onEvent: s } = F(), c = l.palette.mode === "light";
582
+ return /* @__PURE__ */ e(go, {
583
+ columns: t,
584
+ disableColumnFilter: !0,
585
+ disableColumnMenu: !0,
586
+ hideFooter: !0,
587
+ initialState: { sorting: { sortModel: [{
588
+ field: "category",
589
+ sort: "asc"
590
+ }] } },
591
+ onRowClick: (u) => {
592
+ r || n?.(u.row.category_guid), s(w.TRENDS_CLICK_LIST_ITEM, {
593
+ ...W,
594
+ listItem: St[u.row.category_guid]
595
+ });
596
+ },
597
+ pinnedRows: { bottom: a ? [a] : [] },
598
+ rowHeight: 64,
599
+ rows: o,
600
+ slotProps: { baseIconButton: {
601
+ color: "secondary",
602
+ sx: { ml: 8 }
603
+ } },
604
+ slots: { columnHeaderSortIcon: Do },
605
+ sortingOrder: ["asc", "desc"],
606
+ sx: {
607
+ borderColor: "divider",
608
+ borderWidth: 1,
609
+ borderStyle: "solid",
610
+ borderRadius: 2,
611
+ "& .MuiDataGrid-columnHeaders": {
612
+ bgcolor: c ? "neutral.50" : "neutral.800",
613
+ borderBottom: "none"
636
614
  },
637
- rowHeight: 64,
638
- rows: o,
639
- slotProps: { baseIconButton: { color: "secondary", sx: { ml: 8 } } },
640
- slots: { columnHeaderSortIcon: Lo },
641
- sortingOrder: ["asc", "desc"],
642
- sx: {
643
- borderColor: "divider",
644
- borderWidth: 1,
645
- borderStyle: "solid",
646
- borderRadius: 2,
647
- "& .MuiDataGrid-columnHeaders": {
648
- bgcolor: d ? "neutral.50" : "neutral.800",
649
- borderBottom: "none"
650
- },
651
- "& .trends-table-header": {
652
- bgcolor: d ? "neutral.50" : "neutral.800"
653
- }
654
- }
615
+ "& .trends-table-header": { bgcolor: c ? "neutral.50" : "neutral.800" }
655
616
  }
656
- );
657
- }, yt = ({
658
- selectedDateRange: t,
659
- selectedCategory: n,
660
- onClickRow: s,
661
- height: o = "100%",
662
- sx: r = {}
663
- }) => {
664
- const { trends: c } = R(), { trendsCategories: a } = q(), d = g.useMemo(() => vo(t.start, t.end), [t]), u = g.useMemo(() => wo(d, c), [d, c]), i = g.useMemo(() => {
665
- if (n)
666
- return a.find((h) => h.guid === n);
667
- }, [n, a]), [f, m] = g.useMemo(() => {
668
- let h = a;
669
- return i && (h = i.subCategories.filter(
670
- (p) => p.monthlyAmounts.some((y) => y.amount !== 0)
671
- )), [
672
- Ze(h, c, !0, d, i),
673
- Ze(h, c, !1, d, i)
674
- ];
675
- }, [a, d, i, c]), _ = {
617
+ });
618
+ }, yt = ({ selectedDateRange: t, selectedCategory: n, onClickRow: r, height: o = "100%", sx: a = {} }) => {
619
+ const { trends: l } = A(), { trendsCategories: s } = q(), c = m.useMemo(() => So(t.start, t.end), [t]), u = m.useMemo(() => xo(c, l), [c, l]), i = m.useMemo(() => {
620
+ if (n) return s.find((h) => h.guid === n);
621
+ }, [n, s]), [y, g] = m.useMemo(() => {
622
+ let h = s;
623
+ return i && (h = i.subCategories.filter((p) => p.monthlyAmounts.some((C) => C.amount !== 0))), [Xe(h, l, !0, c, i), Xe(h, l, !1, c, i)];
624
+ }, [
625
+ s,
626
+ c,
627
+ i,
628
+ l
629
+ ]), _ = {
676
630
  id: "total",
677
- category: c.table_column_total,
631
+ category: l.table_column_total,
678
632
  category_guid: "total",
679
633
  isParent: !1,
680
634
  top_level_category_guid: "total",
681
- total: m.reduce((h, p) => h + p.total, 0),
682
- monthlyAmounts: m.reduce(
683
- (h, p) => (Object.entries(p.monthlyAmounts).forEach(([y, T]) => {
684
- h[y] = (h[y] || 0) + T;
685
- }), h),
686
- {}
687
- )
635
+ total: g.reduce((h, p) => h + p.total, 0),
636
+ monthlyAmounts: g.reduce((h, p) => (Object.entries(p.monthlyAmounts).forEach(([C, x]) => {
637
+ h[C] = (h[C] || 0) + x;
638
+ }), h), {})
688
639
  };
689
- return /* @__PURE__ */ C(
690
- S,
691
- {
692
- gap: 24,
693
- sx: { height: o, width: "100%", overflowX: "auto", boxShadow: "none", ...r },
694
- children: [
695
- (!i || i && i.is_income) && /* @__PURE__ */ e(
696
- Qe,
697
- {
698
- columns: u,
699
- onRowClick: s,
700
- parentCategory: i,
701
- rows: f
702
- }
703
- ),
704
- (!i || i && !i.is_income) && /* @__PURE__ */ e(
705
- Qe,
706
- {
707
- columns: u,
708
- onRowClick: s,
709
- parentCategory: i,
710
- rows: m,
711
- totalRow: _
712
- }
713
- )
714
- ]
715
- }
716
- );
717
- }, Eo = {
718
- title: "Transaction List"
719
- }, Mo = ({
720
- categoryGuid: t,
721
- dateRange: n,
722
- isOpen: s,
723
- onClose: o
724
- }) => {
725
- const { onEvent: r } = $(), { selectedAccountGuids: c } = fe(), { common: a } = R(), { setFilter: d, sortedTransactions: u } = we(), [i, f] = g.useState(""), m = g.useMemo(
726
- () => u.find((h) => h.guid === i),
727
- [i, u]
728
- );
729
- g.useEffect(() => {
730
- d({
731
- accounts: c,
640
+ return /* @__PURE__ */ f(v, {
641
+ gap: 24,
642
+ sx: {
643
+ height: o,
644
+ width: "100%",
645
+ overflowX: "auto",
646
+ boxShadow: "none",
647
+ ...a
648
+ },
649
+ children: [(!i || i && i.is_income) && /* @__PURE__ */ e(Ze, {
650
+ columns: u,
651
+ onRowClick: r,
652
+ parentCategory: i,
653
+ rows: y
654
+ }), (!i || i && !i.is_income) && /* @__PURE__ */ e(Ze, {
655
+ columns: u,
656
+ onRowClick: r,
657
+ parentCategory: i,
658
+ rows: g,
659
+ totalRow: _
660
+ })]
661
+ });
662
+ }, Lo = { title: "Transaction List" }, Eo = ({ categoryGuid: t, dateRange: n, isOpen: r, onClose: o }) => {
663
+ const { onEvent: a } = F(), { selectedAccountGuids: l } = fe(), { common: s } = A(), { setFilter: c, sortedTransactions: u } = xe(), [i, y] = m.useState(""), g = m.useMemo(() => u.find((h) => h.guid === i), [i, u]);
664
+ m.useEffect(() => {
665
+ c({
666
+ accounts: l,
732
667
  dateRange: n,
733
668
  custom: (h) => t === "" || t === h.category_guid || t === h.top_level_category_guid,
734
669
  showSplits: !!t
735
670
  });
736
- }, [c, t, n]), g.useEffect(() => r(w.TRENDS_VIEW_TRANSACTIONS), []);
671
+ }, [
672
+ l,
673
+ t,
674
+ n
675
+ ]), m.useEffect(() => a(w.TRENDS_VIEW_TRANSACTIONS), []);
737
676
  const _ = () => {
738
- f(""), o();
677
+ y(""), o();
739
678
  };
740
- return /* @__PURE__ */ C(
741
- Pe,
742
- {
743
- ariaLabelClose: a.close_aria,
744
- isOpen: s,
745
- onClose: _,
746
- title: Eo.title,
747
- children: [
748
- m && /* @__PURE__ */ e(dt, { transaction: m }),
749
- !m && /* @__PURE__ */ e(ct, { onClick: f })
750
- ]
751
- }
752
- );
753
- }, Ao = A(Mo), Ro = ({ onBackClick: t, onMenuClick: n, sx: s }) => {
754
- const { onEvent: o } = $(), { isDesktop: r, isTablet: c, isMobile: a } = Q(), { isAccountDataLoaded: d, loadAccountData: u } = De(), {
755
- categoriesLoaded: i,
756
- loadCategories: f,
757
- loadDateRangeCategoryTotals: m,
758
- loadMonthlyCategoryTotals: _,
759
- monthlyCategoryTotals: h,
760
- getCategoryName: p
761
- } = q(), {
762
- isTransactionDataLoaded: y,
763
- loadTransactionData: T,
764
- sortedTransactions: N
765
- } = we(), { selectedDateRange: x, setSelectedDateRange: L } = ye(), { isInitialized: M, selectedAccounts: E } = fe(), { trends: v } = R(), [K, ae] = g.useState(!1), [Y, J] = g.useState(!1), [P, V] = g.useState("Chart"), [O, ee] = g.useState(""), [Ce, ie] = g.useState(window.innerHeight), j = Ce - (a ? 315 : 345);
766
- Ie({
679
+ return /* @__PURE__ */ f(We, {
680
+ ariaLabelClose: s.close_aria,
681
+ isOpen: r,
682
+ onClose: _,
683
+ title: Lo.title,
684
+ children: [g && /* @__PURE__ */ e(ot, { transaction: g }), !g && /* @__PURE__ */ e(et, { onClick: y })]
685
+ });
686
+ }, Mo = R(Eo), Ao = ({ onBackClick: t, onMenuClick: n, sx: r }) => {
687
+ const { onEvent: o } = F(), { isDesktop: a, isTablet: l, isMobile: s } = Z(), { isAccountDataLoaded: c, loadAccountData: u } = we(), { categoriesLoaded: i, loadCategories: y, loadDateRangeCategoryTotals: g, loadMonthlyCategoryTotals: _, monthlyCategoryTotals: h, getCategoryName: p } = q(), { isTransactionDataLoaded: C, loadTransactionData: x, sortedTransactions: H } = xe(), { selectedDateRange: T, setSelectedDateRange: L } = ye(), { isInitialized: E, selectedAccounts: N } = fe(), { trends: S } = A(), [$, le] = m.useState(!1), [K, Q] = m.useState(!1), [P, V] = m.useState("Chart"), [O, ee] = m.useState(""), [ce, j] = m.useState(window.innerHeight), de = ce - (s ? 315 : 345);
688
+ Se({
767
689
  widgetName: "TrendsFullWidget",
768
- isLoaded: K
769
- }), g.useEffect(() => {
770
- const D = () => ie(window.innerHeight);
771
- return window.addEventListener("resize", D), d || u().finally(), i || f().finally(), y || T().finally(), () => window.removeEventListener("resize", D);
772
- }, []), g.useEffect(() => {
773
- M && m(E, x.start, x.end).then(() => {
774
- _(
775
- E,
776
- x.start,
777
- x.end
778
- );
690
+ isLoaded: $
691
+ }), m.useEffect(() => {
692
+ const I = () => j(window.innerHeight);
693
+ return window.addEventListener("resize", I), c || u().finally(), i || y().finally(), C || x().finally(), () => window.removeEventListener("resize", I);
694
+ }, []), m.useEffect(() => {
695
+ E && g(N, T.start, T.end).then(() => {
696
+ _(N, T.start, T.end);
779
697
  }).finally(() => {
780
- ae(!0), o(w.TRENDS_LOAD_WIDGET, {
698
+ le(!0), o(w.TRENDS_LOAD_WIDGET, {
781
699
  ...W,
782
- time_period: `${Se(x.end, x.start)}M`
700
+ time_period: `${Te(T.end, T.start)}M`
783
701
  });
784
702
  });
785
- }, [M, E, x]);
786
- const ne = g.useMemo(() => {
787
- if (!K) return { stackedDatasets: [], unstackedDatasets: [] };
788
- const D = Gt(
789
- h,
790
- x.start,
791
- x.end
792
- ), l = O.length ? D.filter(
793
- (b) => b.top_level_category_guid === O || b.category_guid === O
794
- ) : Bt(D);
703
+ }, [
704
+ E,
705
+ N,
706
+ T
707
+ ]);
708
+ const Y = m.useMemo(() => {
709
+ if (!$) return {
710
+ stackedDatasets: [],
711
+ unstackedDatasets: []
712
+ };
713
+ const I = wt(h, T.start, T.end), G = O.length ? I.filter((d) => d.top_level_category_guid === O || d.category_guid === O) : At(I);
795
714
  return {
796
- stackedDatasets: l.filter(Vt),
797
- unstackedDatasets: l.filter(Pt)
715
+ stackedDatasets: G.filter(Mt),
716
+ unstackedDatasets: G.filter(Wt)
798
717
  };
799
- }, [h, O, x]), U = (D, l) => {
800
- V(l ?? P), o(w.TRENDS_CLICK_TOGGLE_VIEW);
801
- }, de = (D) => {
802
- const l = et(D?.[0], 1), b = D?.[1], I = Se(b, l);
803
- L({ start: l, end: b }), o(w.TRENDS_CLICK_TIME_WINDOW, {
804
- time_period: I + "M"
805
- });
806
- }, B = () => {
718
+ }, [
719
+ h,
720
+ O,
721
+ T
722
+ ]), te = (I, G) => {
723
+ V(G ?? P), o(w.TRENDS_CLICK_TOGGLE_VIEW);
724
+ }, ae = (I) => {
725
+ const G = lt(I?.[0], 1), d = I?.[1], b = Te(d, G);
726
+ L({
727
+ start: G,
728
+ end: d
729
+ }), o(w.TRENDS_CLICK_TIME_WINDOW, { time_period: b + "M" });
730
+ }, oe = () => {
807
731
  o(w.TRENDS_CLICK_FILTER);
808
- }, ue = (D) => {
809
- ee(D);
810
- }, se = (D) => {
811
- ee(D), o(w.TRENDS_CLICK_LEGEND, { category: p(D) });
812
- }, le = (D) => {
813
- o(w.TRENDS_HOVER_LEGEND, { category: p(D) });
814
- }, ce = (D) => {
815
- o(w.TRENDS_HOVER_AREA, { category: D });
816
- }, me = (D) => {
817
- o(w.TRENDS_HOVER_POINT, { category: D });
732
+ }, ne = (I) => {
733
+ ee(I);
734
+ }, se = (I) => {
735
+ ee(I), o(w.TRENDS_CLICK_LEGEND, { category: p(I) });
736
+ }, ue = (I) => {
737
+ o(w.TRENDS_HOVER_LEGEND, { category: p(I) });
738
+ }, he = (I) => {
739
+ o(w.TRENDS_HOVER_AREA, { category: I });
740
+ }, ge = (I) => {
741
+ o(w.TRENDS_HOVER_POINT, { category: I });
818
742
  };
819
- return !M || !K ? /* @__PURE__ */ e(Le, {}) : /* @__PURE__ */ C(
820
- ut,
821
- {
822
- calendarActions: { onRangeChanged: de },
823
- dateRange: x,
824
- dateRangeVariant: "timeframebuttons",
825
- onAccountsFilterClick: B,
826
- onBackClick: t,
827
- onMenuClick: n,
828
- sx: s,
829
- title: v.title,
743
+ return !E || !$ ? /* @__PURE__ */ e(Ie, {}) : /* @__PURE__ */ f(tt, {
744
+ calendarActions: { onRangeChanged: ae },
745
+ dateRange: T,
746
+ dateRangeVariant: "timeframebuttons",
747
+ onAccountsFilterClick: oe,
748
+ onBackClick: t,
749
+ onMenuClick: n,
750
+ sx: r,
751
+ title: S.title,
752
+ children: [/* @__PURE__ */ f(v, {
753
+ sx: { px: a ? 48 : l ? 24 : 12 },
830
754
  children: [
831
- /* @__PURE__ */ C(
832
- S,
833
- {
834
- sx: {
835
- // eslint-disable-next-line no-nested-ternary
836
- px: r ? 48 : c ? 24 : 12
837
- },
838
- children: [
839
- /* @__PURE__ */ C(
840
- S,
841
- {
842
- flexDirection: "row",
843
- justifyContent: "space-between",
844
- sx: { pb: a ? 12 : 24, pt: a ? 24 : 48 },
845
- children: [
846
- /* @__PURE__ */ e(
847
- ft,
848
- {
849
- selectedCategoryGuid: O,
850
- selectedDateRange: x
851
- }
852
- ),
853
- /* @__PURE__ */ e(pt, { onTabChange: U, selectedTab: P })
854
- ]
855
- }
856
- ),
857
- /* @__PURE__ */ C(S, { alignItems: "center", flexDirection: "row", width: "100%", children: [
858
- /* @__PURE__ */ e(H, { flexGrow: 1, children: O && /* @__PURE__ */ C(Te, { onClick: () => ee(""), sx: { p: 0, pr: 5 }, children: [
859
- /* @__PURE__ */ e(He, { name: "arrow_back" }),
860
- v.all_categories
861
- ] }) }),
862
- /* @__PURE__ */ e(Te, { onClick: () => J(!0), sx: { px: 5 }, children: `${v.view_transactions} (${N.length})` })
863
- ] }),
864
- /* @__PURE__ */ C(H, { children: [
865
- P === "Chart" && /* @__PURE__ */ e(
866
- So,
867
- {
868
- availableHeight: j,
869
- onClickLegend: se,
870
- onHoverArea: ce,
871
- onHoverLegend: le,
872
- onHoverPoint: me,
873
- stackedDatasets: ne.stackedDatasets,
874
- unstackedDatasets: ne.unstackedDatasets
875
- }
876
- ),
877
- P === "Table" && /* @__PURE__ */ e(
878
- yt,
879
- {
880
- onClickRow: ue,
881
- selectedCategory: O,
882
- selectedDateRange: x
883
- }
884
- )
885
- ] })
886
- ]
887
- }
888
- ),
889
- /* @__PURE__ */ e(
890
- Ao,
891
- {
892
- categoryGuid: O,
893
- dateRange: x,
894
- isOpen: Y,
895
- onClose: () => J(!1)
896
- }
897
- )
755
+ /* @__PURE__ */ f(v, {
756
+ flexDirection: "row",
757
+ justifyContent: "space-between",
758
+ sx: {
759
+ pb: s ? 12 : 24,
760
+ pt: s ? 24 : 48
761
+ },
762
+ children: [/* @__PURE__ */ e(pt, {
763
+ selectedCategoryGuid: O,
764
+ selectedDateRange: T
765
+ }), /* @__PURE__ */ e(mt, {
766
+ onTabChange: te,
767
+ selectedTab: P
768
+ })]
769
+ }),
770
+ /* @__PURE__ */ f(v, {
771
+ alignItems: "center",
772
+ flexDirection: "row",
773
+ width: "100%",
774
+ children: [/* @__PURE__ */ e(k, {
775
+ flexGrow: 1,
776
+ children: O && /* @__PURE__ */ f(ve, {
777
+ onClick: () => ee(""),
778
+ sx: {
779
+ p: 0,
780
+ pr: 5
781
+ },
782
+ children: [/* @__PURE__ */ e(Ne, { name: "arrow_back" }), S.all_categories]
783
+ })
784
+ }), /* @__PURE__ */ e(ve, {
785
+ onClick: () => Q(!0),
786
+ sx: { px: 5 },
787
+ children: `${S.view_transactions} (${H.length})`
788
+ })]
789
+ }),
790
+ /* @__PURE__ */ f(k, { children: [P === "Chart" && /* @__PURE__ */ e(vo, {
791
+ availableHeight: de,
792
+ onClickLegend: se,
793
+ onHoverArea: he,
794
+ onHoverLegend: ue,
795
+ onHoverPoint: ge,
796
+ stackedDatasets: Y.stackedDatasets,
797
+ unstackedDatasets: Y.unstackedDatasets
798
+ }), P === "Table" && /* @__PURE__ */ e(yt, {
799
+ onClickRow: ne,
800
+ selectedCategory: O,
801
+ selectedDateRange: T
802
+ })] })
898
803
  ]
899
- }
900
- );
901
- }, rs = A(Ro), ko = () => {
902
- const { monthlyCategoryTotals: t } = q(), { trends: n } = R(), s = Z(), { availableHeight: o = 300 } = st(), r = g.useMemo(() => zt(t), [t]);
903
- return /* @__PURE__ */ e(
904
- Ve,
905
- {
906
- baseline: "min",
907
- colors: [s.palette.primary.main],
908
- datasets: [r],
909
- height: o,
910
- labels: [n.spending_label],
911
- showArea: !0,
912
- showAverage: !0,
913
- showLegend: !0,
914
- showMarkLabel: !0,
915
- useCustomMark: !0,
916
- valueFormatterString: "0,0"
917
- }
918
- );
919
- }, Ho = A(ko), No = ({ onPrimaryCtaClick: t, sx: n }) => {
920
- const { isAccountDataLoaded: s, loadAccountData: o } = De(), { loadMonthlyCategoryTotals: r, monthlyTotalsLoaded: c } = q(), { isInitialized: a } = Be(), { trends: d } = R(), { selectedAccounts: u } = fe();
921
- return g.useEffect(() => {
922
- s || o().finally();
923
- }, []), Ie({
804
+ }), /* @__PURE__ */ e(Mo, {
805
+ categoryGuid: O,
806
+ dateRange: T,
807
+ isOpen: K,
808
+ onClose: () => Q(!1)
809
+ })]
810
+ });
811
+ }, Gn = R(Ao), Ro = () => {
812
+ const { monthlyCategoryTotals: t } = q(), { trends: n } = A(), r = J(), { availableHeight: o = 300 } = st(), a = m.useMemo(() => kt(t), [t]);
813
+ return /* @__PURE__ */ e(Oe, {
814
+ baseline: "min",
815
+ colors: [r.palette.primary.main],
816
+ datasets: [a],
817
+ height: o,
818
+ labels: [n.spending_label],
819
+ showArea: !0,
820
+ showAverage: !0,
821
+ showLegend: !0,
822
+ showMarkLabel: !0,
823
+ useCustomMark: !0,
824
+ valueFormatterString: "0,0"
825
+ });
826
+ }, No = R(Ro), ko = ({ onPrimaryCtaClick: t, sx: n }) => {
827
+ const { isAccountDataLoaded: r, loadAccountData: o } = we(), { loadMonthlyCategoryTotals: a, monthlyTotalsLoaded: l } = q(), { isInitialized: s } = Ge(), { trends: c } = A(), { selectedAccounts: u } = fe();
828
+ return m.useEffect(() => {
829
+ r || o().finally();
830
+ }, []), Se({
924
831
  widgetName: "TrendsMiniWidget",
925
- isLoaded: c
926
- }), g.useEffect(() => {
927
- a && s && r(u).finally();
928
- }, [s, a, u]), !s || !a || !c ? /* @__PURE__ */ e(Le, {}) : /* @__PURE__ */ e(
929
- Qt,
930
- {
931
- contentStyles: { height: "calc(100% - 72px)", minHeight: 300, ":last-child": { pb: 0 } },
932
- onPrimaryCtaClick: t,
933
- primaryCtaLabel: d.primary_cta,
934
- subTitle: d.sub_title,
935
- sx: { height: "100%", ...n },
936
- title: d.mini_title,
937
- children: /* @__PURE__ */ e(Ho, {})
938
- }
939
- );
940
- }, as = A(No), Wo = 70, qe = ({
941
- title: t,
942
- totalAmount: n,
943
- transactionType: s,
944
- percentage: o,
945
- secondaryLabel: r,
946
- shouldDisplayPercentage: c
947
- }) => {
948
- const { availableWidth: a } = st(), d = g.useRef(null), u = g.useRef(null), i = Wt(Number(Math.abs(o)), {
832
+ isLoaded: l
833
+ }), m.useEffect(() => {
834
+ s && r && a(u).finally();
835
+ }, [
836
+ r,
837
+ s,
838
+ u
839
+ ]), !r || !s || !l ? /* @__PURE__ */ e(Ie, {}) : /* @__PURE__ */ e(Gt, {
840
+ contentStyles: {
841
+ height: "calc(100% - 72px)",
842
+ minHeight: 300,
843
+ ":last-child": { pb: 0 }
844
+ },
845
+ onPrimaryCtaClick: t,
846
+ primaryCtaLabel: c.primary_cta,
847
+ subTitle: c.sub_title,
848
+ sx: {
849
+ height: "100%",
850
+ ...n
851
+ },
852
+ title: c.mini_title,
853
+ children: /* @__PURE__ */ e(No, {})
854
+ });
855
+ }, Bn = R(ko), Ho = 70, qe = ({ title: t, totalAmount: n, transactionType: r, percentage: o, secondaryLabel: a, shouldDisplayPercentage: l }) => {
856
+ const { availableWidth: s } = st(), c = m.useRef(null), u = m.useRef(null), i = xt(Number(Math.abs(o)), {
949
857
  style: "percent",
950
858
  minimumIntegerDigits: 1
951
- }), f = a === 288 && re(n, "0,0.00").length > 10 ? re(n, "0,0") : re(n, "0,0.00"), m = s === "spending" ? o > 0 : o >= 0, _ = s === "spending" ? "error.main" : "success.main", h = s === "spending" ? "success.main" : "text.secondary", p = d?.current, y = u?.current, T = p && y ? p.scrollWidth > y.clientWidth - Wo : !1;
952
- return /* @__PURE__ */ C(
953
- S,
954
- {
859
+ }), y = s === 288 && ie(n, "0,0.00").length > 10 ? ie(n, "0,0") : ie(n, "0,0.00"), g = r === "spending" ? o > 0 : o >= 0, _ = r === "spending" ? "error.main" : "success.main", h = r === "spending" ? "success.main" : "text.secondary", p = c?.current, C = u?.current, x = p && C ? p.scrollWidth > C.clientWidth - Ho : !1;
860
+ return /* @__PURE__ */ f(v, {
861
+ sx: {
862
+ border: 1,
863
+ borderColor: "divider",
864
+ borderRadius: "4px",
865
+ flex: 1,
866
+ minWidth: 0,
867
+ px: 12,
868
+ py: 8
869
+ },
870
+ children: [/* @__PURE__ */ f(v, {
955
871
  sx: {
956
- border: 1,
957
- borderColor: "divider",
958
- borderRadius: "4px",
959
- flex: 1,
960
- minWidth: 0,
961
- px: 12,
962
- py: 8
872
+ alignItems: "center",
873
+ flexDirection: "row",
874
+ justifyContent: "space-between"
963
875
  },
964
- children: [
965
- /* @__PURE__ */ C(
966
- S,
967
- {
968
- sx: {
969
- alignItems: "center",
970
- flexDirection: "row",
971
- justifyContent: "space-between"
972
- },
973
- children: [
974
- /* @__PURE__ */ e(pe, { color: "text.secondary", variant: "caption", children: t }),
975
- c && /* @__PURE__ */ C(S, { sx: { alignItems: "center", flexDirection: "row", gap: 4 }, children: [
976
- m ? /* @__PURE__ */ e(Jt, { size: 20, sx: { color: _ } }) : /* @__PURE__ */ e(eo, { size: 20, sx: { color: h } }),
977
- /* @__PURE__ */ e(
978
- pe,
979
- {
980
- sx: {
981
- color: m ? _ : h,
982
- fontWeight: 600
983
- },
984
- variant: "body2",
985
- children: i
986
- }
987
- )
988
- ] })
989
- ]
990
- }
991
- ),
992
- /* @__PURE__ */ C(
993
- S,
994
- {
995
- ref: u,
996
- sx: {
997
- alignItems: "center",
998
- flexDirection: "row",
999
- justifyContent: "space-between"
1000
- },
1001
- children: [
1002
- /* @__PURE__ */ e(
1003
- H,
1004
- {
1005
- ref: d,
1006
- sx: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
1007
- children: /* @__PURE__ */ e(Ge, { children: f })
1008
- }
1009
- ),
1010
- c && a >= 450 && !T && /* @__PURE__ */ e(
1011
- pe,
1012
- {
1013
- color: m ? _ : h,
1014
- variant: "caption",
1015
- children: r
1016
- }
1017
- )
1018
- ]
1019
- }
1020
- )
1021
- ]
1022
- }
1023
- );
1024
- }, Oo = A(() => {
1025
- const { trends: t } = R();
1026
- return /* @__PURE__ */ C(S, { sx: { alignItems: "start", flexDirection: "row", gap: 12 }, children: [
1027
- /* @__PURE__ */ e(to, { size: 32 }),
1028
- /* @__PURE__ */ C(S, { children: [
1029
- /* @__PURE__ */ e(pe, { fontWeight: 600, variant: "body1", children: t.zero_state_content_header }),
1030
- /* @__PURE__ */ e(pe, { color: "text.secondary", variant: "subtitle2", children: t.zero_state_content_description })
1031
- ] })
1032
- ] });
1033
- }), is = A(({ onCtaClick: t }) => {
1034
- const { isAccountDataLoaded: n, loadAccountData: s, visibleAccounts: o } = De();
1035
- g.useEffect(() => {
1036
- n || s().finally();
876
+ children: [/* @__PURE__ */ e(pe, {
877
+ color: "text.secondary",
878
+ variant: "caption",
879
+ children: t
880
+ }), l && /* @__PURE__ */ f(v, {
881
+ sx: {
882
+ alignItems: "center",
883
+ flexDirection: "row",
884
+ gap: 4
885
+ },
886
+ children: [g ? /* @__PURE__ */ e(Xt, {
887
+ size: 20,
888
+ sx: { color: _ }
889
+ }) : /* @__PURE__ */ e(Ut, {
890
+ size: 20,
891
+ sx: { color: h }
892
+ }), /* @__PURE__ */ e(pe, {
893
+ sx: {
894
+ color: g ? _ : h,
895
+ fontWeight: 600
896
+ },
897
+ variant: "body2",
898
+ children: i
899
+ })]
900
+ })]
901
+ }), /* @__PURE__ */ f(v, {
902
+ ref: u,
903
+ sx: {
904
+ alignItems: "center",
905
+ flexDirection: "row",
906
+ justifyContent: "space-between"
907
+ },
908
+ children: [/* @__PURE__ */ e(k, {
909
+ ref: c,
910
+ sx: {
911
+ overflow: "hidden",
912
+ textOverflow: "ellipsis",
913
+ whiteSpace: "nowrap"
914
+ },
915
+ children: /* @__PURE__ */ e(Be, { children: y })
916
+ }), l && s >= 450 && !x && /* @__PURE__ */ e(pe, {
917
+ color: g ? _ : h,
918
+ variant: "caption",
919
+ children: a
920
+ })]
921
+ })]
922
+ });
923
+ }, Wo = R(() => {
924
+ const { trends: t } = A();
925
+ return /* @__PURE__ */ f(v, {
926
+ sx: {
927
+ alignItems: "start",
928
+ flexDirection: "row",
929
+ gap: 12
930
+ },
931
+ children: [/* @__PURE__ */ e(Yt, { size: 32 }), /* @__PURE__ */ f(v, { children: [/* @__PURE__ */ e(pe, {
932
+ fontWeight: 600,
933
+ variant: "body1",
934
+ children: t.zero_state_content_header
935
+ }), /* @__PURE__ */ e(pe, {
936
+ color: "text.secondary",
937
+ variant: "subtitle2",
938
+ children: t.zero_state_content_description
939
+ })] })]
940
+ });
941
+ }), Pn = R(({ onCtaClick: t }) => {
942
+ const { isAccountDataLoaded: n, loadAccountData: r, visibleAccounts: o } = we();
943
+ m.useEffect(() => {
944
+ n || r().finally();
1037
945
  }, []);
1038
- const { onEvent: r } = $(), { monthlyCategoryTotals: c, loadMonthlyCategoryTotals: a, monthlyTotalsLoaded: d } = q(), u = {
1039
- start: qt(/* @__PURE__ */ new Date(), 1),
946
+ const { onEvent: a } = F(), { monthlyCategoryTotals: l, loadMonthlyCategoryTotals: s, monthlyTotalsLoaded: c } = q(), u = {
947
+ start: no(/* @__PURE__ */ new Date(), 1),
1040
948
  end: /* @__PURE__ */ new Date()
1041
- }, { trends: i } = R(), { selectedAccounts: f, isInitialized: m } = fe();
1042
- Ie({
949
+ }, { trends: i } = A(), { selectedAccounts: y, isInitialized: g } = fe();
950
+ Se({
1043
951
  widgetName: "TrendsMicroWidget",
1044
- isLoaded: d
1045
- }), g.useEffect(() => {
1046
- m && a(f, u.start).then(() => {
1047
- r(w.TRENDS_LOAD_WIDGET, {
1048
- state: o?.length ? "default" : "zeroState"
1049
- });
952
+ isLoaded: c
953
+ }), m.useEffect(() => {
954
+ g && s(y, u.start).then(() => {
955
+ a(w.TRENDS_LOAD_WIDGET, { state: o?.length ? "default" : "zeroState" });
1050
956
  });
1051
- }, [m, f]);
1052
- const { spendingData: _, incomeData: h } = g.useMemo(
1053
- () => ({
1054
- spendingData: it(c, u),
1055
- incomeData: at(c, u)
1056
- }),
1057
- [c, u]
1058
- ), [p, y] = _, [T, N] = h, x = Ye(y.y, p.y), L = Ye(N.y, T.y), M = m && !o?.length, E = () => {
1059
- r(
1060
- M ? w.TRENDS_CLICK_GET_STARTED : w.TRENDS_CLICK_VIEW_MORE
1061
- ), t();
957
+ }, [g, y]);
958
+ const { spendingData: _, incomeData: h } = m.useMemo(() => ({
959
+ spendingData: rt(l, u),
960
+ incomeData: nt(l, u)
961
+ }), [l, u]), [p, C] = _, [x, H] = h, T = $e(C.y, p.y), L = $e(H.y, x.y), E = g && !o?.length, N = () => {
962
+ a(E ? w.TRENDS_CLICK_GET_STARTED : w.TRENDS_CLICK_VIEW_MORE), t();
1062
963
  };
1063
- return !d || !m ? /* @__PURE__ */ e(Le, {}) : /* @__PURE__ */ e(
1064
- ao,
1065
- {
1066
- className: "mx-trends-microwidget",
1067
- ctaLabel: i.micro_primary_cta_label,
1068
- onCTAClick: E,
1069
- subHeader: M ? void 0 : i.micro_subheader,
1070
- title: i.title,
1071
- children: M ? /* @__PURE__ */ e(Oo, {}) : /* @__PURE__ */ C(
1072
- S,
1073
- {
1074
- sx: {
1075
- alignItems: "stretch",
1076
- flexDirection: "row",
1077
- gap: 12
1078
- },
1079
- children: [
1080
- /* @__PURE__ */ e(
1081
- qe,
1082
- {
1083
- percentage: x,
1084
- secondaryLabel: i.micro_secondary_label,
1085
- shouldDisplayPercentage: y.y !== 0 && p.y !== 0,
1086
- title: i.spending_label,
1087
- totalAmount: y.y,
1088
- transactionType: "spending"
1089
- }
1090
- ),
1091
- /* @__PURE__ */ e(
1092
- qe,
1093
- {
1094
- percentage: L,
1095
- secondaryLabel: i.micro_secondary_label,
1096
- shouldDisplayPercentage: N.y !== 0 && T.y !== 0,
1097
- title: i.income_label,
1098
- totalAmount: N.y,
1099
- transactionType: "income"
1100
- }
1101
- )
1102
- ]
1103
- }
1104
- )
1105
- }
1106
- );
1107
- }), Go = A(
1108
- ({ isExpanded: t, onClick: n }) => {
1109
- const s = Z();
1110
- return /* @__PURE__ */ e(mt, { children: /* @__PURE__ */ e(lo, { onClick: n, sx: { justifyContent: "center" }, children: /* @__PURE__ */ C(
1111
- S,
1112
- {
1113
- sx: { color: s.palette.primary.main, flexDirection: "row", alignItems: "center" },
1114
- children: [
1115
- /* @__PURE__ */ e(ht, { children: /* @__PURE__ */ e(F, { bold: !0, variant: "body2", children: t ? "View less" : "View more" }) }),
1116
- /* @__PURE__ */ e(co, { sx: { color: s.palette.primary.main }, children: t ? /* @__PURE__ */ e(oo, {}) : /* @__PURE__ */ e(
1117
- no,
1118
- {
1119
- sx: {
1120
- transition: "transform 0.3s ease-in-out",
1121
- transform: t ? "rotate(180deg)" : "rotate(0deg)"
1122
- }
1123
- }
1124
- ) })
1125
- ]
964
+ return !c || !g ? /* @__PURE__ */ e(Ie, {}) : /* @__PURE__ */ e(Ht, {
965
+ className: "mx-trends-microwidget",
966
+ ctaLabel: i.micro_primary_cta_label,
967
+ onCTAClick: N,
968
+ subHeader: E ? void 0 : i.micro_subheader,
969
+ title: i.title,
970
+ children: E ? /* @__PURE__ */ e(Wo, {}) : /* @__PURE__ */ f(v, {
971
+ sx: {
972
+ alignItems: "stretch",
973
+ flexDirection: "row",
974
+ gap: 12
975
+ },
976
+ children: [/* @__PURE__ */ e(qe, {
977
+ percentage: T,
978
+ secondaryLabel: i.micro_secondary_label,
979
+ shouldDisplayPercentage: C.y !== 0 && p.y !== 0,
980
+ title: i.spending_label,
981
+ totalAmount: C.y,
982
+ transactionType: "spending"
983
+ }), /* @__PURE__ */ e(qe, {
984
+ percentage: L,
985
+ secondaryLabel: i.micro_secondary_label,
986
+ shouldDisplayPercentage: H.y !== 0 && x.y !== 0,
987
+ title: i.income_label,
988
+ totalAmount: H.y,
989
+ transactionType: "income"
990
+ })]
991
+ })
992
+ });
993
+ }), Oo = R(({ isExpanded: t, onClick: n }) => {
994
+ const r = J();
995
+ return /* @__PURE__ */ e(ut, { children: /* @__PURE__ */ e(ao, {
996
+ onClick: n,
997
+ sx: { justifyContent: "center" },
998
+ children: /* @__PURE__ */ f(v, {
999
+ sx: {
1000
+ color: r.palette.primary.main,
1001
+ flexDirection: "row",
1002
+ alignItems: "center"
1003
+ },
1004
+ children: [/* @__PURE__ */ e(ht, { children: /* @__PURE__ */ e(z, {
1005
+ bold: !0,
1006
+ variant: "body2",
1007
+ children: t ? "View less" : "View more"
1008
+ }) }), /* @__PURE__ */ e(so, {
1009
+ sx: { color: r.palette.primary.main },
1010
+ children: t ? /* @__PURE__ */ e(Kt, {}) : /* @__PURE__ */ e(jt, { sx: {
1011
+ transition: "transform 0.3s ease-in-out",
1012
+ transform: t ? "rotate(180deg)" : "rotate(0deg)"
1013
+ } })
1014
+ })]
1015
+ })
1016
+ }) });
1017
+ }), Je = R(({ totalAmount: t, guid: n, name: r, transactions: o, onClick: a, isLastItem: l = !1, showDivider: s = !0 }) => {
1018
+ const { trends: c } = A(), { onEvent: u } = F(), i = J(), y = `${o.length} ${o.length === 1 ? c.transaction : c.transactions}`, g = () => {
1019
+ a?.(), u(w.TRENDS_CLICK_LIST_ITEM, {
1020
+ ...W,
1021
+ listItem: r
1022
+ });
1023
+ };
1024
+ return /* @__PURE__ */ f(m.Fragment, { children: [/* @__PURE__ */ e(Et, {
1025
+ leftIcon: n ? /* @__PURE__ */ e(De, {
1026
+ categoryGuid: n,
1027
+ sx: {
1028
+ bgcolor: qt(Re(n, i), 0.15),
1029
+ border: `1px solid ${Re(n, i)}`,
1030
+ color: "text.primary"
1126
1031
  }
1127
- ) }) });
1128
- }
1129
- ), Je = A(
1130
- ({
1131
- totalAmount: t,
1132
- guid: n,
1133
- name: s,
1134
- transactions: o,
1135
- onClick: r,
1136
- isLastItem: c = !1,
1137
- showDivider: a = !0
1138
- }) => {
1139
- const { trends: d } = R(), { onEvent: u } = $(), i = Z(), f = `${o.length} ${o.length === 1 ? d.transaction : d.transactions}`, m = () => {
1140
- r?.(), u(w.TRENDS_CLICK_LIST_ITEM, {
1141
- ...W,
1142
- listItem: s
1143
- });
1144
- };
1145
- return /* @__PURE__ */ C(g.Fragment, { children: [
1146
- /* @__PURE__ */ e(
1147
- uo,
1148
- {
1149
- leftIcon: n ? /* @__PURE__ */ e(
1150
- ve,
1151
- {
1152
- categoryGuid: n,
1153
- sx: {
1154
- bgcolor: Mt(Oe(n, i), 0.15),
1155
- border: `1px solid ${Oe(n, i)}`,
1156
- color: "text.primary"
1157
- }
1158
- }
1159
- ) : void 0,
1160
- onClick: m,
1161
- rightContent: re(Math.abs(t), "0,0.00"),
1162
- rightIcon: r ? /* @__PURE__ */ e(so, {}) : void 0,
1163
- subtitle: f,
1164
- title: s
1165
- }
1166
- ),
1167
- a && /* @__PURE__ */ e(Ne, { component: "li", sx: { ml: c ? 24 : 68 } })
1168
- ] }, n);
1169
- }
1170
- ), Bo = A(
1171
- ({ availableHeight: t = 0, onCategoryClick: n }) => {
1172
- const { collapsedCategories: s, visibleCategories: o, setVisibleListLength: r } = ye(), { isLargeDesktop: c, isDesktop: a } = Q(), { trends: d } = R(), { onEvent: u } = $(), [i, f] = g.useState(!1), m = a || c;
1173
- g.useEffect(() => {
1174
- const p = Math.floor(t / 64) - 1, y = o.length + s.length;
1175
- p !== o.length && (r(m ? Math.max(p, 5) : 5), f(p >= y));
1176
- }, [t]);
1177
- const _ = () => {
1178
- f(!i), u(w.TRENDS_CLICK_VIEW_MORE, {
1179
- ...W
1180
- });
1181
- }, h = o.length + (i ? s.length : 0);
1182
- return /* @__PURE__ */ C(S, { sx: { width: "100%" }, children: [
1183
- /* @__PURE__ */ e(S, { sx: { pb: 4, pt: 16, px: 16 }, children: /* @__PURE__ */ e(Ge, { children: d.categories }) }),
1184
- /* @__PURE__ */ C(We, { children: [
1185
- o.map((p, y) => /* @__PURE__ */ e(
1186
- Je,
1187
- {
1032
+ }) : void 0,
1033
+ onClick: g,
1034
+ rightContent: ie(Math.abs(t), "0,0.00"),
1035
+ rightIcon: a ? /* @__PURE__ */ e($t, {}) : void 0,
1036
+ subtitle: y,
1037
+ title: r
1038
+ }), s && /* @__PURE__ */ e(ke, {
1039
+ component: "li",
1040
+ sx: { ml: l ? 24 : 68 }
1041
+ })] }, n);
1042
+ }), Go = R(({ availableHeight: t = 0, onCategoryClick: n }) => {
1043
+ const { collapsedCategories: r, visibleCategories: o, setVisibleListLength: a } = ye(), { isLargeDesktop: l, isDesktop: s } = Z(), { trends: c } = A(), { onEvent: u } = F(), [i, y] = m.useState(!1), g = s || l;
1044
+ m.useEffect(() => {
1045
+ const p = Math.floor(t / 64) - 1, C = o.length + r.length;
1046
+ p !== o.length && (a(g ? Math.max(p, 5) : 5), y(p >= C));
1047
+ }, [t]);
1048
+ const _ = () => {
1049
+ y(!i), u(w.TRENDS_CLICK_VIEW_MORE, { ...W });
1050
+ }, h = o.length + (i ? r.length : 0);
1051
+ return /* @__PURE__ */ f(v, {
1052
+ sx: { width: "100%" },
1053
+ children: [/* @__PURE__ */ e(v, {
1054
+ sx: {
1055
+ pb: 4,
1056
+ pt: 16,
1057
+ px: 16
1058
+ },
1059
+ children: /* @__PURE__ */ e(Be, { children: c.categories })
1060
+ }), /* @__PURE__ */ f(He, { children: [
1061
+ o.map((p, C) => /* @__PURE__ */ e(Je, {
1062
+ ...p,
1063
+ isLastItem: C === h - 1,
1064
+ onClick: p.transactions.length > 0 ? () => n(p) : void 0,
1065
+ showDivider: !0
1066
+ }, p.guid)),
1067
+ /* @__PURE__ */ e(yo, {
1068
+ component: "li",
1069
+ in: i,
1070
+ sx: { "&.MuiCollapse-root .MuiListItemButton-root": { paddingLeft: 24 } },
1071
+ children: /* @__PURE__ */ e(He, { children: r.map((p, C) => {
1072
+ const x = o.length + C;
1073
+ return /* @__PURE__ */ e(Je, {
1188
1074
  ...p,
1189
- isLastItem: y === h - 1,
1075
+ isLastItem: x === h - 1,
1190
1076
  onClick: p.transactions.length > 0 ? () => n(p) : void 0,
1191
1077
  showDivider: !0
1192
- },
1193
- p.guid
1194
- )),
1195
- /* @__PURE__ */ e(
1196
- io,
1197
- {
1198
- component: "li",
1199
- in: i,
1200
- sx: { "&.MuiCollapse-root .MuiListItemButton-root": { paddingLeft: 24 } },
1201
- children: /* @__PURE__ */ e(We, { children: s.map((p, y) => {
1202
- const T = o.length + y;
1203
- return /* @__PURE__ */ e(
1204
- Je,
1205
- {
1206
- ...p,
1207
- isLastItem: T === h - 1,
1208
- onClick: p.transactions.length > 0 ? () => n(p) : void 0,
1209
- showDivider: !0
1210
- },
1211
- p.guid
1212
- );
1213
- }) })
1214
- }
1215
- ),
1216
- s.length > 0 && /* @__PURE__ */ e(Go, { isExpanded: i, onClick: _ })
1217
- ] })
1218
- ] });
1219
- }
1220
- ), Po = ({ beats: t, onInsightCardClick: n }) => {
1221
- const { onEvent: s } = $(), { isMobile: o, isDesktop: r, isLargeDesktop: c } = Q(), { beatStore: a, endpoint: d, sessionToken: u } = Be(), i = r || c, f = i || o ? 1 : 2, m = () => null, _ = (T) => {
1222
- n?.(T), s(w.TRENDS_CLICK_INSIGHT, W);
1223
- }, h = i ? 200 : 170, p = i ? 170 : 124, y = t.length > 0 ? h : p;
1224
- return /* @__PURE__ */ e(mo, { sx: { height: y }, children: /* @__PURE__ */ e(
1225
- Kt,
1226
- {
1227
- areBeatsLoading: a.isLoading,
1078
+ }, p.guid);
1079
+ }) })
1080
+ }),
1081
+ r.length > 0 && /* @__PURE__ */ e(Oo, {
1082
+ isExpanded: i,
1083
+ onClick: _
1084
+ })
1085
+ ] })]
1086
+ });
1087
+ }), Bo = ({ beats: t, onInsightCardClick: n }) => {
1088
+ const { onEvent: r } = F(), { isMobile: o, isDesktop: a, isLargeDesktop: l } = Z(), { beatStore: s, endpoint: c, sessionToken: u } = Ge(), i = a || l, y = i || o ? 1 : 2, g = () => null, _ = (C) => {
1089
+ n?.(C), r(w.TRENDS_CLICK_INSIGHT, W);
1090
+ }, h = i ? 200 : 170, p = i ? 170 : 124;
1091
+ return /* @__PURE__ */ e(ro, {
1092
+ sx: { height: t.length > 0 ? h : p },
1093
+ children: /* @__PURE__ */ e(Bt, {
1094
+ areBeatsLoading: s.isLoading,
1228
1095
  beats: t,
1229
1096
  cardStyle: "border",
1230
- endpoint: d,
1097
+ endpoint: c,
1231
1098
  headerSx: { p: 0 },
1232
- logOutUser: m,
1099
+ logOutUser: g,
1233
1100
  onCardClick: _,
1234
1101
  showCarouselControls: !0,
1235
1102
  showHeader: i,
@@ -1237,28 +1104,27 @@ const Lo = g.memo(Io), Qe = ({
1237
1104
  showWithMargin: !1,
1238
1105
  token: u,
1239
1106
  userHasFullInsightFeedBeats: !1,
1240
- visibleCardsCount: f
1241
- }
1242
- ) });
1243
- }, Vo = A(Po), zo = A(({ chartLabel: t, chartColor: n }) => {
1244
- const { onEvent: s } = $(), {
1245
- categoryDetailsChartData: { monthlyAmounts: o, tooltipLabels: r }
1246
- } = ye();
1247
- return /* @__PURE__ */ e(S, { sx: { pt: 12, width: "100%" }, children: /* @__PURE__ */ e(
1248
- Ve,
1249
- {
1107
+ visibleCardsCount: y
1108
+ })
1109
+ });
1110
+ }, Po = R(Bo), Vo = R(({ chartLabel: t, chartColor: n }) => {
1111
+ const { onEvent: r } = F(), { categoryDetailsChartData: { monthlyAmounts: o, tooltipLabels: a } } = ye();
1112
+ return /* @__PURE__ */ e(v, {
1113
+ sx: {
1114
+ pt: 12,
1115
+ width: "100%"
1116
+ },
1117
+ children: /* @__PURE__ */ e(Oe, {
1250
1118
  baseline: "min",
1251
1119
  colors: [n],
1252
1120
  curveType: "bump",
1253
- customTooltipLabels: r,
1121
+ customTooltipLabels: a,
1254
1122
  datasets: [o],
1255
1123
  height: 265,
1256
1124
  labels: [t],
1257
- markStyles: () => ({
1258
- stroke: n
1259
- }),
1125
+ markStyles: () => ({ stroke: n }),
1260
1126
  onItemClick: () => {
1261
- s(w.TRENDS_CLICK_CHART, W);
1127
+ r(w.TRENDS_CLICK_CHART, W);
1262
1128
  },
1263
1129
  showArea: !0,
1264
1130
  showAverage: !0,
@@ -1271,107 +1137,129 @@ const Lo = g.memo(Io), Qe = ({
1271
1137
  showYAxisTicks: !0,
1272
1138
  useCustomMark: !0,
1273
1139
  valueFormatterString: "0,0"
1274
- }
1275
- ) });
1276
- }), Fo = A(() => {
1277
- const t = Z(), { is_mobile_webview: n } = rt(), { isDesktop: s, isSmallTablet: o, isTablet: r } = Q(), { common: c, trends: a } = R(), { selectedCategoryData: d, selectedDateRangeMonthRange: u } = ye(), { sortedTransactions: i } = we(), [f, m] = g.useState(null);
1278
- if (!d)
1279
- return null;
1280
- const { guid: _, name: h, is_income: p, totalAmount: y } = d, T = Oe(_, t), N = p ? a.income_label : a.spending_label, x = ` ${d.transactions.length === 1 ? a.transaction : a.transactions} (${d.transactions.length})`, L = g.useMemo(
1281
- () => i.find((v) => v.guid === f),
1282
- [f, i]
1283
- ), M = i.length > 0 && !n && (s || r && !o), E = (v) => v.category_guid === _ || v.top_level_category_guid === _;
1284
- return /* @__PURE__ */ C(S, { sx: { alignItems: "center", height: "100%" }, children: [
1285
- /* @__PURE__ */ C(S, { sx: { borderRadius: 0, pb: 4, pt: 16, px: 12, width: "100%" }, children: [
1286
- /* @__PURE__ */ e(We, { sx: { px: 12 }, children: /* @__PURE__ */ C(mt, { children: [
1287
- /* @__PURE__ */ e(ho, { children: /* @__PURE__ */ e(ve, { categoryGuid: _ }) }),
1288
- /* @__PURE__ */ e(
1289
- ht,
1290
- {
1291
- primary: h,
1292
- secondary: u,
1293
- slotProps: {
1294
- primary: { component: "div", variant: "h3", fontSize: 18, fontWeight: 700 },
1295
- secondary: { component: "div", variant: "body2", fontSize: 13 }
1296
- }
1297
- }
1298
- ),
1299
- /* @__PURE__ */ e(F, { component: "div", variant: "h3", children: re(Math.abs(y), "0,0.00") })
1300
- ] }) }),
1301
- /* @__PURE__ */ e(zo, { chartColor: T, chartLabel: N }),
1302
- /* @__PURE__ */ C(S, { alignItems: "center", direction: "row", justifyContent: "space-between", sx: { mx: 12 }, children: [
1303
- /* @__PURE__ */ e(F, { bold: !0, variant: "body1", children: x }),
1304
- M && /* @__PURE__ */ e(go, { filter: E })
1305
- ] })
1306
- ] }),
1307
- /* @__PURE__ */ e(
1308
- ct,
1309
- {
1140
+ })
1141
+ });
1142
+ }), zo = R(() => {
1143
+ const t = J(), { is_mobile_webview: n } = at(), { isDesktop: r, isSmallTablet: o, isTablet: a } = Z(), { common: l, trends: s } = A(), { selectedCategoryData: c, selectedDateRangeMonthRange: u } = ye(), { sortedTransactions: i } = xe(), [y, g] = m.useState(null);
1144
+ if (!c) return null;
1145
+ const { guid: _, name: h, is_income: p, totalAmount: C } = c, x = Re(_, t), H = p ? s.income_label : s.spending_label, T = ` ${c.transactions.length === 1 ? s.transaction : s.transactions} (${c.transactions.length})`, L = m.useMemo(() => i.find((S) => S.guid === y), [y, i]), E = i.length > 0 && !n && (r || a && !o), N = (S) => S.category_guid === _ || S.top_level_category_guid === _;
1146
+ return /* @__PURE__ */ f(v, {
1147
+ sx: {
1148
+ alignItems: "center",
1149
+ height: "100%"
1150
+ },
1151
+ children: [
1152
+ /* @__PURE__ */ f(v, {
1153
+ sx: {
1154
+ borderRadius: 0,
1155
+ pb: 4,
1156
+ pt: 16,
1157
+ px: 12,
1158
+ width: "100%"
1159
+ },
1160
+ children: [
1161
+ /* @__PURE__ */ e(He, {
1162
+ sx: { px: 12 },
1163
+ children: /* @__PURE__ */ f(ut, { children: [
1164
+ /* @__PURE__ */ e(io, { children: /* @__PURE__ */ e(De, { categoryGuid: _ }) }),
1165
+ /* @__PURE__ */ e(ht, {
1166
+ primary: h,
1167
+ secondary: u,
1168
+ slotProps: {
1169
+ primary: {
1170
+ component: "div",
1171
+ variant: "h3",
1172
+ fontSize: 18,
1173
+ fontWeight: 700
1174
+ },
1175
+ secondary: {
1176
+ component: "div",
1177
+ variant: "body2",
1178
+ fontSize: 13
1179
+ }
1180
+ }
1181
+ }),
1182
+ /* @__PURE__ */ e(z, {
1183
+ component: "div",
1184
+ variant: "h3",
1185
+ children: ie(Math.abs(C), "0,0.00")
1186
+ })
1187
+ ] })
1188
+ }),
1189
+ /* @__PURE__ */ e(Vo, {
1190
+ chartColor: x,
1191
+ chartLabel: H
1192
+ }),
1193
+ /* @__PURE__ */ f(v, {
1194
+ alignItems: "center",
1195
+ direction: "row",
1196
+ justifyContent: "space-between",
1197
+ sx: { mx: 12 },
1198
+ children: [/* @__PURE__ */ e(z, {
1199
+ bold: !0,
1200
+ variant: "body1",
1201
+ children: T
1202
+ }), E && /* @__PURE__ */ e(Nt, { filter: N })]
1203
+ })
1204
+ ]
1205
+ }),
1206
+ /* @__PURE__ */ e(et, {
1310
1207
  bgcolor: "transparent",
1311
- filter: E,
1208
+ filter: N,
1312
1209
  height: "calc(100vh - 475px)",
1313
- onClick: m
1314
- }
1315
- ),
1316
- /* @__PURE__ */ e(
1317
- Pe,
1318
- {
1319
- ariaLabelClose: c.close_aria,
1210
+ onClick: g
1211
+ }),
1212
+ /* @__PURE__ */ e(We, {
1213
+ ariaLabelClose: l.close_aria,
1320
1214
  isOpen: !!L,
1321
- onClose: () => m(""),
1322
- title: a.transaction,
1323
- children: L && /* @__PURE__ */ e(dt, { transaction: L })
1324
- }
1325
- )
1326
- ] });
1327
- }), $o = (t, n) => {
1328
- const s = at(t, n), o = it(t, n);
1329
- return [s, o].filter((r) => r.length > 0);
1330
- }, Ko = (t, n) => {
1331
- const [s, o] = t, r = s, c = o ?? s, a = [];
1332
- if (r) {
1333
- const d = r.reduce((u, i) => u + i.y, 0);
1334
- a.push({ label: n.income_label, amount: d });
1215
+ onClose: () => g(""),
1216
+ title: s.transaction,
1217
+ children: L && /* @__PURE__ */ e(ot, { transaction: L })
1218
+ })
1219
+ ]
1220
+ });
1221
+ }), Fo = (t, n) => [nt(t, n), rt(t, n)].filter((r) => r.length > 0), $o = (t, n) => {
1222
+ const [r, o] = t, a = r, l = o ?? r, s = [];
1223
+ if (a) {
1224
+ const c = a.reduce((u, i) => u + i.y, 0);
1225
+ s.push({
1226
+ label: n.income_label,
1227
+ amount: c
1228
+ });
1335
1229
  }
1336
- if (c) {
1337
- const d = c.reduce((u, i) => u + i.y, 0);
1338
- a.push({ label: n.spending_label, amount: d });
1230
+ if (l) {
1231
+ const c = l.reduce((u, i) => u + i.y, 0);
1232
+ s.push({
1233
+ label: n.spending_label,
1234
+ amount: c
1235
+ });
1339
1236
  }
1340
- return a;
1341
- }, Yo = ({
1342
- availableHeight: t = 0,
1343
- minHeight: n = 500,
1344
- selectedDateRange: s,
1345
- totals: o
1346
- }) => {
1347
- const r = Z(), { onEvent: c } = $(), { trends: a } = R(), { isSmallMobile: d, isMobile: u, isSmallTablet: i, isTablet: f } = Q(), m = [r.palette.chart?.chart1, r.palette.chart?.chart2], _ = $o(o, s), h = Ko(_, a), [p, y] = g.useState(0), T = 458, N = 195, x = 56, L = u || d ? N : i || f ? T : p;
1348
- return g.useEffect(() => {
1349
- const E = Math.max(t - x, n);
1350
- y(E);
1351
- }, [t]), /* @__PURE__ */ e(
1352
- Ve,
1353
- {
1354
- baseline: "min",
1355
- colors: m,
1356
- curveType: "bump",
1357
- datasets: _,
1358
- height: L,
1359
- labels: h,
1360
- onItemClick: () => {
1361
- c(w.TRENDS_CLICK_CHART, W);
1362
- },
1363
- showArea: !0,
1364
- showAxisHighlight: !0,
1365
- showLegend: !0,
1366
- showTooltip: !0,
1367
- showXAxis: !0,
1368
- showXAxisTicks: !0,
1369
- showYAxis: !0,
1370
- showYAxisTicks: !0,
1371
- valueFormatterString: "0.0a"
1372
- }
1373
- );
1374
- }, jo = A(Yo), Uo = [
1237
+ return s;
1238
+ }, Ko = ({ availableHeight: t = 0, minHeight: n = 500, selectedDateRange: r, totals: o }) => {
1239
+ const a = J(), { onEvent: l } = F(), { trends: s } = A(), { isSmallMobile: c, isMobile: u, isSmallTablet: i, isTablet: y } = Z(), g = [a.palette.chart?.chart1, a.palette.chart?.chart2], _ = Fo(o, r), h = $o(_, s), [p, C] = m.useState(0), x = 458, H = 195, T = 56, L = u || c ? H : i || y ? x : p;
1240
+ return m.useEffect(() => {
1241
+ C(Math.max(t - T, n));
1242
+ }, [t]), /* @__PURE__ */ e(Oe, {
1243
+ baseline: "min",
1244
+ colors: g,
1245
+ curveType: "bump",
1246
+ datasets: _,
1247
+ height: L,
1248
+ labels: h,
1249
+ onItemClick: () => {
1250
+ l(w.TRENDS_CLICK_CHART, W);
1251
+ },
1252
+ showArea: !0,
1253
+ showAxisHighlight: !0,
1254
+ showLegend: !0,
1255
+ showTooltip: !0,
1256
+ showXAxis: !0,
1257
+ showXAxisTicks: !0,
1258
+ showYAxis: !0,
1259
+ showYAxisTicks: !0,
1260
+ valueFormatterString: "0.0a"
1261
+ });
1262
+ }, jo = R(Ko), Yo = [
1375
1263
  "BillAmountNotStandard",
1376
1264
  "CategorySpendingV2",
1377
1265
  "CostOfLivingToIncome",
@@ -1405,209 +1293,182 @@ const Lo = g.memo(Io), Qe = ({
1405
1293
  "WeeklyNewMerchantsV2",
1406
1294
  "WeeklyNoSpendDays",
1407
1295
  "WeeklySmallPurchasesSummary"
1408
- ], Xo = (t, n, s) => ({
1296
+ ], Uo = (t, n, r) => ({
1409
1297
  description: n ? t.empty_state_sub_text : t.empty_state_sub_text_no_aggregation,
1410
1298
  header: n ? t.zero_state_content_header : t.zero_state_content_header_no_aggregation,
1411
- onClickHandler: n ? s : void 0,
1299
+ onClickHandler: n ? r : void 0,
1412
1300
  primaryButton: n ? t.empty_state_primary : void 0
1413
- }), Zo = ({
1414
- onBackClick: t,
1415
- onMenuClick: n,
1416
- onInsightCardClick: s,
1417
- sx: o
1418
- }) => {
1419
- const { onEvent: r } = $(), { config: c } = rt(), { isDesktop: a, isLargeDesktop: d, isMobile: u } = Q(), { isAccountDataLoaded: i, loadAccountData: f, visibleAccounts: m } = De(), {
1420
- categoriesLoaded: _,
1421
- loadCategories: h,
1422
- loadDateRangeCategoryTotals: p,
1423
- loadMonthlyCategoryTotals: y,
1424
- monthlyCategoryTotals: T,
1425
- monthlyTotalsLoaded: N
1426
- } = q(), { isTransactionDataLoaded: x, loadTransactionData: L, setFilter: M } = we(), { selectedCategoryData: E, selectedDateRange: v, setSelectedCategoryData: K, setSelectedDateRange: ae } = ye(), { isInitialized: Y, selectedAccounts: J, selectedAccountGuids: P } = fe(), { trends: V, connect: O } = R(), { beatStore: ee } = Be(), ie = po() && c.show_insights_widget_in_master, te = a || d, [j, ne] = g.useState(!1), [U, de] = g.useState(!1), [B, ue] = g.useState("Chart"), [se, le] = g.useState(""), [ce, me] = g.useState(window.innerHeight), D = te ? 56 : 0, l = ce - 208, b = ce - (ie ? 550 + D : 266), [I, z] = g.useState(!1), Ee = c.show_connections_widget_in_master;
1427
- Ie({
1301
+ }), Xo = ({ onBackClick: t, onMenuClick: n, onInsightCardClick: r, sx: o }) => {
1302
+ const { onEvent: a } = F(), { config: l } = at(), { isDesktop: s, isLargeDesktop: c, isMobile: u } = Z(), { isAccountDataLoaded: i, loadAccountData: y, visibleAccounts: g } = we(), { categoriesLoaded: _, loadCategories: h, loadDateRangeCategoryTotals: p, loadMonthlyCategoryTotals: C, monthlyCategoryTotals: x, monthlyTotalsLoaded: H } = q(), { isTransactionDataLoaded: T, loadTransactionData: L, setFilter: E } = xe(), { selectedCategoryData: N, selectedDateRange: S, setSelectedCategoryData: $, setSelectedDateRange: le } = ye(), { isInitialized: K, selectedAccounts: Q, selectedAccountGuids: P } = fe(), { trends: V, connect: O } = A(), { beatStore: ee } = Ge(), ce = Rt() && l.show_insights_widget_in_master, j = s || c, [de, Y] = m.useState(!1), [te, ae] = m.useState(!1), [oe, ne] = m.useState("Chart"), [se, ue] = m.useState(""), [he, ge] = m.useState(window.innerHeight), I = j ? 56 : 0, G = he - 208, d = he - (ce ? 550 + I : 266), [b, D] = m.useState(!1), U = l.show_connections_widget_in_master;
1303
+ Se({
1428
1304
  widgetName: "TrendsWidget",
1429
- isLoaded: j
1305
+ isLoaded: de
1430
1306
  });
1431
- const _e = g.useMemo(() => U ? ee.getFilteredBeats({ templates: Uo }) : [], [U]);
1432
- g.useEffect(() => {
1433
- const k = () => me(window.innerHeight);
1434
- return window.addEventListener("resize", k), i || f().finally(), _ || h().finally(), x || L().finally(), () => window.removeEventListener("resize", k);
1435
- }, []), g.useEffect(() => {
1436
- Y && i && (ee.loadBeats().finally(() => de(!0)), p(J, v.start, v.end).then(() => {
1437
- y(
1438
- J,
1439
- v.start,
1440
- v.end
1441
- ).finally();
1307
+ const Ce = m.useMemo(() => te ? ee.getFilteredBeats({ templates: Yo }) : [], [te]);
1308
+ m.useEffect(() => {
1309
+ const M = () => ge(window.innerHeight);
1310
+ return window.addEventListener("resize", M), i || y().finally(), _ || h().finally(), T || L().finally(), () => window.removeEventListener("resize", M);
1311
+ }, []), m.useEffect(() => {
1312
+ K && i && (ee.loadBeats().finally(() => ae(!0)), p(Q, S.start, S.end).then(() => {
1313
+ C(Q, S.start, S.end).finally();
1442
1314
  }).finally(() => {
1443
- ne(!0), r(w.TRENDS_LOAD_WIDGET, {
1315
+ Y(!0), a(w.TRENDS_LOAD_WIDGET, {
1444
1316
  ...W,
1445
- time_period: `${Se(v.end, v.start)}M`
1317
+ time_period: `${Te(S.end, S.start)}M`
1446
1318
  });
1447
1319
  }));
1448
- }, [Y, i, J, v]), g.useEffect(() => {
1449
- if (T.length !== 0) {
1450
- const k = {
1451
- accounts: P,
1452
- dateRange: { start: v.start, end: v.end }
1453
- };
1454
- M({
1455
- ...k,
1456
- custom: (oe) => !!T.find(
1457
- (ge) => ge.top_level_category_guid === oe.top_level_category_guid || ge.category_guid === oe.category_guid
1458
- )
1459
- });
1460
- }
1461
- }, [T]);
1462
- const he = (k) => {
1463
- K(k);
1464
- }, Me = () => {
1465
- K(null), r(w.TRENDS_CLICK_BACK, W);
1466
- }, Ae = () => {
1467
- z(!0), r(w.TRENDS_CLICK_CONNECT_ACCOUNTS);
1468
- }, Ct = (k, oe) => {
1469
- ue(oe ?? B), r(w.TRENDS_CLICK_TOGGLE_VIEW, {
1320
+ }, [
1321
+ K,
1322
+ i,
1323
+ Q,
1324
+ S
1325
+ ]), m.useEffect(() => {
1326
+ x.length !== 0 && E({
1327
+ accounts: P,
1328
+ dateRange: {
1329
+ start: S.start,
1330
+ end: S.end
1331
+ },
1332
+ custom: (M) => !!x.find((re) => re.top_level_category_guid === M.top_level_category_guid || re.category_guid === M.category_guid)
1333
+ });
1334
+ }, [x]);
1335
+ const Le = (M) => {
1336
+ $(M);
1337
+ }, me = () => {
1338
+ $(null), a(w.TRENDS_CLICK_BACK, W);
1339
+ }, Ee = () => {
1340
+ D(!0), a(w.TRENDS_CLICK_CONNECT_ACCOUNTS);
1341
+ }, ft = (M, re) => {
1342
+ ne(re ?? oe), a(w.TRENDS_CLICK_TOGGLE_VIEW, {
1470
1343
  ...W,
1471
- toggleView: oe
1344
+ toggleView: re
1472
1345
  });
1473
- }, _t = (k) => {
1474
- const oe = et(k?.[0], 1), ge = k?.[1], xt = Se(ge, oe);
1475
- ae({ start: oe, end: ge }), r(w.TRENDS_CLICK_TIME_WINDOW, {
1346
+ }, Ct = (M) => {
1347
+ const re = lt(M?.[0], 1), Ve = M?.[1], Tt = Te(Ve, re);
1348
+ le({
1349
+ start: re,
1350
+ end: Ve
1351
+ }), a(w.TRENDS_CLICK_TIME_WINDOW, {
1476
1352
  ...W,
1477
- time_period: xt + "M"
1353
+ time_period: Tt + "M"
1478
1354
  });
1479
- }, bt = (k) => {
1480
- r(w.TRENDS_CLICK_FILTER, {
1355
+ }, _t = (M) => {
1356
+ a(w.TRENDS_CLICK_FILTER, {
1481
1357
  ...W,
1482
- filterValue: k
1358
+ filterValue: M
1483
1359
  });
1484
- }, Tt = (k) => {
1485
- le(k);
1486
- }, St = () => {
1487
- le(""), r(w.TRENDS_CLICK_ALL_CATEGORIES, W);
1360
+ }, bt = (M) => {
1361
+ ue(M);
1362
+ }, vt = () => {
1363
+ ue(""), a(w.TRENDS_CLICK_ALL_CATEGORIES, W);
1488
1364
  };
1489
- if (!Y || !i || !j || !N)
1490
- return /* @__PURE__ */ e(Le, {});
1491
- const ze = m.length === 0 || T.length === 0, be = Xo(V, Ee, Ae);
1492
- return /* @__PURE__ */ C(
1493
- ut,
1494
- {
1495
- calendarActions: { onRangeChanged: _t },
1496
- dateRange: v,
1497
- dateRangeVariant: u ? "timeframetabs" : "timeframebuttons",
1498
- onAccountsFilterClick: bt,
1499
- onBackClick: t,
1500
- onMenuClick: n,
1501
- sx: o,
1502
- title: V.title,
1365
+ if (!K || !i || !de || !H) return /* @__PURE__ */ e(Ie, {});
1366
+ const Pe = g.length === 0 || x.length === 0, _e = Uo(V, U, Ee);
1367
+ return /* @__PURE__ */ f(tt, {
1368
+ calendarActions: { onRangeChanged: Ct },
1369
+ dateRange: S,
1370
+ dateRangeVariant: u ? "timeframetabs" : "timeframebuttons",
1371
+ onAccountsFilterClick: _t,
1372
+ onBackClick: t,
1373
+ onMenuClick: n,
1374
+ sx: o,
1375
+ title: V.title,
1376
+ children: [/* @__PURE__ */ f(v, {
1377
+ sx: { px: u ? 0 : 48 },
1503
1378
  children: [
1504
- /* @__PURE__ */ C(
1505
- S,
1506
- {
1507
- sx: {
1508
- px: u ? 0 : 48
1509
- },
1510
- children: [
1511
- /* @__PURE__ */ C(
1512
- S,
1513
- {
1514
- flexDirection: "row",
1515
- justifyContent: "space-between",
1516
- sx: { px: u ? 16 : 0, py: 16 },
1517
- children: [
1518
- /* @__PURE__ */ e(
1519
- ft,
1520
- {
1521
- selectedCategoryGuid: se,
1522
- selectedDateRange: v
1523
- }
1524
- ),
1525
- /* @__PURE__ */ e(pt, { onTabChange: Ct, selectedTab: B })
1526
- ]
1527
- }
1528
- ),
1529
- /* @__PURE__ */ e(S, { alignItems: "center", flexDirection: "row", sx: { pb: 8 }, width: "100%", children: /* @__PURE__ */ e(H, { flexGrow: 1, children: se && /* @__PURE__ */ C(Te, { onClick: St, sx: { p: 0, pr: 5 }, children: [
1530
- /* @__PURE__ */ e(ro, {}),
1531
- V.all_categories
1532
- ] }) }) }),
1533
- ze && /* @__PURE__ */ e(
1534
- fo,
1535
- {
1536
- header: be.header,
1537
- icon: "multiline_chart",
1538
- onClick: be.onClickHandler,
1539
- primaryButton: be.primaryButton,
1540
- subText: be.description,
1541
- sx: { height: l, maxWidth: 432 }
1542
- }
1543
- ),
1544
- !ze && /* @__PURE__ */ C(S, { flexDirection: te ? "row" : "column", gap: te ? 48 : 16, children: [
1545
- B === "Chart" && /* @__PURE__ */ C(vt, { children: [
1546
- /* @__PURE__ */ e(H, { sx: { width: te ? "68%" : "100%" }, children: /* @__PURE__ */ e(
1547
- jo,
1548
- {
1549
- availableHeight: l,
1550
- minHeight: 450,
1551
- selectedDateRange: v,
1552
- totals: T
1553
- }
1554
- ) }),
1555
- /* @__PURE__ */ C(S, { gap: 16, sx: { width: te ? "32%" : "100%" }, children: [
1556
- ie && U && _e.length > 0 && /* @__PURE__ */ e(
1557
- Vo,
1558
- {
1559
- beats: _e,
1560
- onInsightCardClick: s
1561
- }
1562
- ),
1563
- /* @__PURE__ */ e(
1564
- Bo,
1565
- {
1566
- availableHeight: b,
1567
- onCategoryClick: he
1568
- }
1569
- )
1570
- ] })
1571
- ] }),
1572
- B === "Table" && /* @__PURE__ */ e(H, { sx: { width: "100%" }, children: /* @__PURE__ */ e(
1573
- yt,
1574
- {
1575
- height: "unset",
1576
- onClickRow: Tt,
1577
- selectedCategory: se,
1578
- selectedDateRange: v
1579
- }
1580
- ) })
1581
- ] }),
1582
- /* @__PURE__ */ e(
1583
- Pe,
1584
- {
1585
- ariaLabelClose: V.close_category_details,
1586
- isOpen: !!E,
1587
- onClose: Me,
1588
- shouldShowHeaderShadow: !0,
1589
- title: E?.is_income ? V.category_income : V.category_spending,
1590
- children: E && /* @__PURE__ */ e(Fo, {})
1591
- }
1592
- )
1593
- ]
1594
- }
1595
- ),
1596
- /* @__PURE__ */ e(
1597
- yo,
1598
- {
1599
- onClose: () => z(!1),
1600
- showConnectWidget: I,
1601
- title: O.mini_title
1379
+ /* @__PURE__ */ f(v, {
1380
+ flexDirection: "row",
1381
+ justifyContent: "space-between",
1382
+ sx: {
1383
+ px: u ? 16 : 0,
1384
+ py: 16
1385
+ },
1386
+ children: [/* @__PURE__ */ e(pt, {
1387
+ selectedCategoryGuid: se,
1388
+ selectedDateRange: S
1389
+ }), /* @__PURE__ */ e(mt, {
1390
+ onTabChange: ft,
1391
+ selectedTab: oe
1392
+ })]
1393
+ }),
1394
+ /* @__PURE__ */ e(v, {
1395
+ alignItems: "center",
1396
+ flexDirection: "row",
1397
+ sx: { pb: 8 },
1398
+ width: "100%",
1399
+ children: /* @__PURE__ */ e(k, {
1400
+ flexGrow: 1,
1401
+ children: se && /* @__PURE__ */ f(ve, {
1402
+ onClick: vt,
1403
+ sx: {
1404
+ p: 0,
1405
+ pr: 5
1406
+ },
1407
+ children: [/* @__PURE__ */ e(Ft, {}), V.all_categories]
1408
+ })
1409
+ })
1410
+ }),
1411
+ Pe && /* @__PURE__ */ e(Dt, {
1412
+ header: _e.header,
1413
+ icon: "multiline_chart",
1414
+ onClick: _e.onClickHandler,
1415
+ primaryButton: _e.primaryButton,
1416
+ subText: _e.description,
1417
+ sx: {
1418
+ height: G,
1419
+ maxWidth: 432
1602
1420
  }
1603
- )
1421
+ }),
1422
+ !Pe && /* @__PURE__ */ f(v, {
1423
+ flexDirection: j ? "row" : "column",
1424
+ gap: j ? 48 : 16,
1425
+ children: [oe === "Chart" && /* @__PURE__ */ f(Zt, { children: [/* @__PURE__ */ e(k, {
1426
+ sx: { width: j ? "68%" : "100%" },
1427
+ children: /* @__PURE__ */ e(jo, {
1428
+ availableHeight: G,
1429
+ minHeight: 450,
1430
+ selectedDateRange: S,
1431
+ totals: x
1432
+ })
1433
+ }), /* @__PURE__ */ f(v, {
1434
+ gap: 16,
1435
+ sx: { width: j ? "32%" : "100%" },
1436
+ children: [ce && te && Ce.length > 0 && /* @__PURE__ */ e(Po, {
1437
+ beats: Ce,
1438
+ onInsightCardClick: r
1439
+ }), /* @__PURE__ */ e(Go, {
1440
+ availableHeight: d,
1441
+ onCategoryClick: Le
1442
+ })]
1443
+ })] }), oe === "Table" && /* @__PURE__ */ e(k, {
1444
+ sx: { width: "100%" },
1445
+ children: /* @__PURE__ */ e(yt, {
1446
+ height: "unset",
1447
+ onClickRow: bt,
1448
+ selectedCategory: se,
1449
+ selectedDateRange: S
1450
+ })
1451
+ })]
1452
+ }),
1453
+ /* @__PURE__ */ e(We, {
1454
+ ariaLabelClose: V.close_category_details,
1455
+ isOpen: !!N,
1456
+ onClose: me,
1457
+ shouldShowHeaderShadow: !0,
1458
+ title: N?.is_income ? V.category_income : V.category_spending,
1459
+ children: N && /* @__PURE__ */ e(zo, {})
1460
+ })
1604
1461
  ]
1605
- }
1606
- );
1607
- }, ls = A(Zo);
1462
+ }), /* @__PURE__ */ e(Lt, {
1463
+ onClose: () => D(!1),
1464
+ showConnectWidget: b,
1465
+ title: O.mini_title
1466
+ })]
1467
+ });
1468
+ }, Vn = R(Xo);
1608
1469
  export {
1609
- rs as TrendsFullWidget,
1610
- is as TrendsMicroWidget,
1611
- as as TrendsMiniWidget,
1612
- ls as TrendsWidget
1470
+ Gn as TrendsFullWidget,
1471
+ Pn as TrendsMicroWidget,
1472
+ Bn as TrendsMiniWidget,
1473
+ Vn as TrendsWidget
1613
1474
  };