@mx-cartographer/experiences 8.1.5 → 8.1.6

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.
@@ -0,0 +1,1721 @@
1
+ import { jsx as e, jsxs as m } from "react/jsx-runtime";
2
+ import l, { useMemo as ke } from "react";
3
+ import { observer as w } from "mobx-react-lite";
4
+ import ze from "@mui/material/Alert";
5
+ import W from "@mui/material/Box";
6
+ import Te from "@mui/material/Divider";
7
+ import be from "@mui/material/List";
8
+ import he from "@mui/material/Paper";
9
+ import Ve from "@mui/material/Snackbar";
10
+ import L from "@mui/material/Stack";
11
+ import { useTheme as H, alpha as Ae } from "@mui/material/styles";
12
+ import { P as ee, Text as A, H2 as We, MerchantLogo as Ce, Toast as Ye, CategoryIcon as Oe, CategoryIconVariants as Ge, TextField as Le, Icon as ye } from "@mxenabled/mxui";
13
+ import { endOfMonth as Be } from "date-fns/endOfMonth";
14
+ import { getUnixTime as Ie } from "date-fns/getUnixTime";
15
+ import { isBefore as je } from "date-fns/isBefore";
16
+ import { startOfMonth as De } from "date-fns/startOfMonth";
17
+ import { l as qe, d as Qe, C as Xe, c as Ze, i as Je } from "./BudgetUtil-DalEN9--.mjs";
18
+ import me from "@mui/material/Button";
19
+ import et from "@mui/material/FormGroup";
20
+ import ue from "@mui/material/IconButton";
21
+ import $e from "@mui/material/TextField";
22
+ import { u as xe } from "./useAriaLive-MkYebyUR.mjs";
23
+ import { O as C } from "./exportTransactionsToCSV-B2Lp7AMl.mjs";
24
+ import { u as O, h as R, m as tt, d as at, l as we, g as G, b as rt, o as nt } from "./hooks-HwStH7q_.mjs";
25
+ import { A as Y } from "./Analytics-CzGzz_sE.mjs";
26
+ import ot from "@mui/material/ToggleButton";
27
+ import { ChevronRight as Ke, Icon as P, Delete as fe, Cancel as Se, Search as it, Edit as st, Flag as lt } from "@mxenabled/mx-icons";
28
+ import { fromUnixTime as ve } from "date-fns/fromUnixTime";
29
+ import j from "@mui/material/Avatar";
30
+ import U from "@mui/material/ListItem";
31
+ import q from "@mui/material/ListItemAvatar";
32
+ import z from "@mui/material/ListItemText";
33
+ import { f as Me, D as Re } from "./DateFormats-CaOj_4eI.mjs";
34
+ import { BarChart as ct } from "@mui/x-charts";
35
+ import { b as dt, T as ut, u as re, c as mt, d as _t, E as pt, C as gt } from "./EmbeddedCard-BqVpA1Jn.mjs";
36
+ import { L as ht } from "./Loader-CxeBwuPG.mjs";
37
+ import { f as V } from "./NumberFormatting-CyrvFgfd.mjs";
38
+ import { b as E } from "./Localization-CkQ49EKr.mjs";
39
+ import Q from "@mui/material/ListItemButton";
40
+ import X from "@mui/material/ListItemIcon";
41
+ import { b as Fe } from "./CategorySelectorDrawer-DjeHNx71.mjs";
42
+ import { D as ae } from "./Dialog-iLlBR8TG.mjs";
43
+ import { D as _e } from "./Drawer-XPaLYjiO.mjs";
44
+ import yt from "@mui/material/styles/useTheme";
45
+ import Pe from "@mui/material/InputAdornment";
46
+ import Tt from "@mui/material/Checkbox";
47
+ import { j as bt } from "./DateUtil-D0TO0DaZ.mjs";
48
+ import Ne from "@mui/material/Grid";
49
+ import { C as Ct } from "./CurrencyInput-CSJ3zMgE.mjs";
50
+ import ft from "@mui/material/Switch";
51
+ var de = /* @__PURE__ */ ((t) => (t[t.Category = 0] = "Category", t[t.Date = 1] = "Date", t[t.Memo = 2] = "Memo", t[t.Tags = 3] = "Tags", t))(de || {}), ie = /* @__PURE__ */ ((t) => (t[t.MerchantBudget = 0] = "MerchantBudget", t[t.SplitTransaction = 1] = "SplitTransaction", t[t.HideTransaction = 2] = "HideTransaction", t[t.MerchantLogo = 3] = "MerchantLogo", t))(ie || {});
52
+ const St = [
53
+ 0,
54
+ 1,
55
+ 2,
56
+ 3
57
+ /* Tags */
58
+ ], xt = [
59
+ 1,
60
+ 2,
61
+ 3
62
+ /* MerchantLogo */
63
+ ], At = ({
64
+ startDate: t,
65
+ onViewHistory: r,
66
+ totalTransaction: s,
67
+ amount: a,
68
+ spentPercentage: n,
69
+ remainingAmount: o,
70
+ iconColor: i,
71
+ icon: _
72
+ }) => {
73
+ const { budgets: c } = O();
74
+ return /* @__PURE__ */ e(l.Fragment, { children: /* @__PURE__ */ m(
75
+ W,
76
+ {
77
+ sx: {
78
+ bgcolor: "background.paper",
79
+ borderBottomColor: "divider",
80
+ borderBottomStyle: "solid",
81
+ borderBottomWidth: 1
82
+ },
83
+ children: [
84
+ /* @__PURE__ */ m(
85
+ L,
86
+ {
87
+ sx: {
88
+ alignItems: "center",
89
+ flexDirection: "row",
90
+ gap: 12,
91
+ justifyContent: "space-between",
92
+ pt: 16,
93
+ px: 24
94
+ },
95
+ children: [
96
+ /* @__PURE__ */ e(ee, { bold: !0, variant: "subtitle1", children: bt(t) }),
97
+ r && /* @__PURE__ */ e(me, { endIcon: /* @__PURE__ */ e(Ke, {}), onClick: r, sx: { height: 28 }, children: /* @__PURE__ */ e(A, { bold: !0, variant: "body2", children: c.spending_history }) })
98
+ ]
99
+ }
100
+ ),
101
+ /* @__PURE__ */ e(
102
+ dt,
103
+ {
104
+ amount: /* @__PURE__ */ m(L, { sx: { alignItems: "baseline", flexDirection: "row", gap: 4 }, children: [
105
+ /* @__PURE__ */ e(We, { children: V(s, "0,0.00") }),
106
+ /* @__PURE__ */ e(ee, { color: "text.secondary", variant: "body2", children: "/" }),
107
+ /* @__PURE__ */ e(ee, { color: "text.secondary", variant: "body2", children: V(a, "0,0.00") })
108
+ ] }),
109
+ completeColor: `${i}.main`,
110
+ icon: _,
111
+ label: c.spent_label,
112
+ leftLabel: E(c.percent_spent, n.toFixed()),
113
+ percentComplete: n,
114
+ rightLabel: E(
115
+ c.balance_left,
116
+ V(o, "0,0.00")
117
+ ),
118
+ sx: {
119
+ pb: 24,
120
+ pt: 16,
121
+ px: 24
122
+ }
123
+ }
124
+ )
125
+ ]
126
+ }
127
+ ) });
128
+ }, Nt = ({
129
+ merchantBudget: t,
130
+ transaction: r,
131
+ onClose: s,
132
+ isOpen: a,
133
+ setCurrencyDialogAction: n,
134
+ renderingToast: o
135
+ }) => {
136
+ const { budgets: i, common: _ } = O(), { sortedTransactions: c } = R(), d = l.useMemo(() => c.reduce((h, I) => I.parent_guid ? h : h + I.amount, 0), [c]), { remainingAmount: u, spentPercentage: p, iconColor: g } = qe(
137
+ d,
138
+ t.amount ?? 0
139
+ );
140
+ return /* @__PURE__ */ m(
141
+ _e,
142
+ {
143
+ ariaLabelClose: _.close_aria,
144
+ footerStyles: {
145
+ px: 24,
146
+ py: 16
147
+ },
148
+ isOpen: a,
149
+ onClose: s,
150
+ onPrimaryAction: () => n(Ee.EDIT),
151
+ onSecondaryAction: () => {
152
+ n(Ee.DELETE);
153
+ },
154
+ primaryText: i.details_edit_button,
155
+ secondaryColor: "error",
156
+ secondaryText: i.details_delete_button,
157
+ sx: {
158
+ "& .list-wrapper": {
159
+ pr: 24
160
+ }
161
+ },
162
+ title: E(i.details_type_title, t.merchant_name),
163
+ children: [
164
+ /* @__PURE__ */ e(
165
+ At,
166
+ {
167
+ amount: t.amount,
168
+ icon: /* @__PURE__ */ e(
169
+ Ce,
170
+ {
171
+ categoryGuid: r.top_level_category_guid || "",
172
+ merchantGuid: r.merchant_guid || ""
173
+ }
174
+ ),
175
+ iconColor: g,
176
+ remainingAmount: u,
177
+ spentPercentage: p,
178
+ startDate: r.date,
179
+ totalTransaction: d
180
+ }
181
+ ),
182
+ /* @__PURE__ */ e(ut, {}),
183
+ o?.()
184
+ ]
185
+ }
186
+ );
187
+ }, It = w(Nt);
188
+ var Ee = /* @__PURE__ */ ((t) => (t.CREATE = "create", t.EDIT = "edit", t.DELETE = "delete", t))(Ee || {});
189
+ const Dt = w(({ transaction: t }) => {
190
+ const [r, s] = l.useState(null), [a, n] = l.useState(""), [o, i] = l.useState(!1), _ = l.useRef(!1), [c, d] = l.useState(null), u = H(), {
191
+ addMerchantBudget: p,
192
+ updateMerchantBudget: g,
193
+ deleteMerchantBudget: h,
194
+ getMerchantBudgetByMerchantGuid: I,
195
+ alert: M,
196
+ setAlert: B
197
+ } = tt(), { setFilter: k } = R(), { accounts: f } = at(), x = u.palette.mode === "dark" ? "grey.800" : "grey.100", { budgets: y, common: Z } = O(), { announce: se, ariaLive: le } = xe(), [te, $] = l.useState(!1), b = t?.merchant_guid ? I(t.merchant_guid) : void 0, K = () => {
198
+ d(r), s(null), n("");
199
+ }, ne = () => {
200
+ b ? $(!0) : s(
201
+ "create"
202
+ /* CREATE */
203
+ );
204
+ }, F = {
205
+ create: {
206
+ content: E(
207
+ y.create_budget_content,
208
+ /* @__PURE__ */ e("strong", { children: t.description }),
209
+ `${V(t.amount, "0,0.00")}`
210
+ ),
211
+ title: y.dialog_create_budget_title,
212
+ primaryButtonText: y.dialog_primary_button_text,
213
+ errorAlertMessage: E(
214
+ y.alert_merchant_budget_not_created,
215
+ t.description
216
+ ),
217
+ errorRetryAction: () => s(
218
+ "create"
219
+ /* CREATE */
220
+ ),
221
+ successAlertMessage: E(
222
+ y.alert_budget_created,
223
+ t.description
224
+ ),
225
+ apiTrigger: async () => await p(t.merchant_guid, Number(a))
226
+ },
227
+ edit: {
228
+ content: E(
229
+ y.edit_budget_content,
230
+ /* @__PURE__ */ e("strong", { children: t.description })
231
+ ),
232
+ title: y.details_edit_title,
233
+ primaryButtonText: y.add_save_button,
234
+ errorAlertMessage: E(
235
+ y.error_alert_edit_merchant_budget,
236
+ t.description
237
+ ),
238
+ errorRetryAction: () => s(
239
+ "edit"
240
+ /* EDIT */
241
+ ),
242
+ successAlertMessage: E(
243
+ y.success_alert_edit_merchant_budget,
244
+ t.description
245
+ ),
246
+ apiTrigger: async () => await g({
247
+ ...b,
248
+ amount: Number(a)
249
+ })
250
+ },
251
+ delete: {
252
+ content: E(
253
+ y.delete_description,
254
+ /* @__PURE__ */ e("strong", { children: t.description })
255
+ ),
256
+ title: y.delete_title,
257
+ primaryButtonText: y.details_delete_button,
258
+ errorAlertMessage: E(
259
+ y.error_alert_delete_merchant_budget,
260
+ t.description
261
+ ),
262
+ errorRetryAction: () => s(
263
+ "delete"
264
+ /* DELETE */
265
+ ),
266
+ successAlertMessage: E(
267
+ y.success_alert_delete_merchant_budget,
268
+ t.description
269
+ ),
270
+ apiTrigger: async () => await h(b.guid)
271
+ }
272
+ }, oe = async () => {
273
+ if (_.current) return;
274
+ _.current = !0;
275
+ const { apiTrigger: v, successAlertMessage: S, errorAlertMessage: T } = F[r], { isSuccess: D } = await v(), J = D ? S : T;
276
+ K(), i(!D), B(J), se(J), D && r === "delete" && $(!1), _.current = !1;
277
+ };
278
+ l.useEffect(() => {
279
+ const v = {
280
+ start: De(new Date(t.date * 1e3)),
281
+ end: Be(new Date(t.date * 1e3))
282
+ };
283
+ te && k({
284
+ accounts: f.map((S) => S.guid),
285
+ custom: te ? (S) => S.merchant_guid === t.merchant_guid : (S) => S.guid === t.guid,
286
+ dateRange: v
287
+ });
288
+ }, [te, t, f]);
289
+ const N = () => /* @__PURE__ */ e(
290
+ Ye,
291
+ {
292
+ actionText: y.autogenerate_budgets_error_primary_button,
293
+ autoHideDuration: 3500,
294
+ closeAriaLabel: Z.close_aria,
295
+ handleClose: () => B(""),
296
+ message: M,
297
+ onActionClick: F[c]?.errorRetryAction,
298
+ open: !!M,
299
+ severity: o ? "error" : "success",
300
+ showAction: o,
301
+ showClose: !0
302
+ }
303
+ );
304
+ return /* @__PURE__ */ m(l.Fragment, { children: [
305
+ le,
306
+ /* @__PURE__ */ e(U, { disableGutters: !0, disablePadding: !0, children: /* @__PURE__ */ m(Q, { onClick: ne, children: [
307
+ /* @__PURE__ */ e(q, { children: /* @__PURE__ */ e(j, { sx: { bgcolor: x }, variant: "rounded", children: /* @__PURE__ */ e(P, { name: "bubble_chart", sx: { color: "text.primary" } }) }) }),
308
+ /* @__PURE__ */ e(
309
+ z,
310
+ {
311
+ primary: y.add_merchant_budget_primary_text,
312
+ primaryTypographyProps: { variant: "caption" },
313
+ secondary: /* @__PURE__ */ e(A, { bold: !0, sx: { color: "text.primary" }, variant: "body1", children: b ? `${V(b.amount, "0,0.00")} / ${Z.month_text}` : y.add_merchant_budget_secondary_text })
314
+ }
315
+ ),
316
+ /* @__PURE__ */ e(X, { children: /* @__PURE__ */ e(P, { name: "chevron_right", sx: { color: "text.primary" } }) })
317
+ ] }) }),
318
+ !!b && /* @__PURE__ */ e(
319
+ It,
320
+ {
321
+ isOpen: te,
322
+ merchantBudget: b,
323
+ onClose: () => $(!1),
324
+ renderingToast: () => M && N(),
325
+ setCurrencyDialogAction: (v) => {
326
+ v === "edit" && n(b?.amount.toString() || ""), s(v);
327
+ },
328
+ transaction: t
329
+ }
330
+ ),
331
+ r && /* @__PURE__ */ e(
332
+ Qe,
333
+ {
334
+ closeAriaLabel: Z.close_aria,
335
+ content: F[r].content,
336
+ handleInputChange: n,
337
+ handleModalClose: K,
338
+ handlePrimaryAction: oe,
339
+ handleSecondaryAction: K,
340
+ inputLabel: r !== "delete" ? Z.amount_text : "",
341
+ inputValue: a,
342
+ isOpen: !!r,
343
+ primaryText: F[r].primaryButtonText,
344
+ secondaryText: Z.cancel_button,
345
+ title: F[r].title
346
+ }
347
+ ),
348
+ !!M && N()
349
+ ] });
350
+ }), vt = ({ transaction: t }) => {
351
+ const { addOrUpdateTransactionRule: r, updateTransaction: s } = R(), { categories: a } = we(), { onEvent: n } = G(), { setShouldDisableDrawerScroll: o, updateManualTransaction: i } = re(), { transactions: _ } = O(), c = H(), [d, u] = l.useState(!1), [p, g] = l.useState(""), h = async (f) => {
352
+ await s({ ...t, category_guid: p }), f && await r(p, t), g(""), n(Y.TRANSACTION_DETAILS_CLICK_CATEGORY, {
353
+ transaction_guid: t.guid
354
+ });
355
+ }, I = (f) => {
356
+ if (t.is_manual && !t.guid) {
357
+ const x = a.find((y) => y.guid === f);
358
+ i({
359
+ ...t,
360
+ category: x?.name,
361
+ category_guid: f,
362
+ top_level_category_guid: x?.parent_guid || f
363
+ });
364
+ } else
365
+ g(f);
366
+ M();
367
+ }, M = () => {
368
+ u(!1), o(!1);
369
+ }, B = l.useMemo(
370
+ () => a.find((f) => f.guid === p),
371
+ [p]
372
+ ), k = c.palette.mode === "dark" ? "grey.800" : "grey.100";
373
+ return /* @__PURE__ */ m(U, { disableGutters: !0, disablePadding: !0, children: [
374
+ /* @__PURE__ */ m(
375
+ Q,
376
+ {
377
+ onClick: () => {
378
+ n(C.ON_TRANSACTION_CATEGORY_CLICK), u(!0);
379
+ },
380
+ children: [
381
+ /* @__PURE__ */ e(q, { children: /* @__PURE__ */ e(j, { sx: { bgcolor: k }, variant: "rounded", children: /* @__PURE__ */ e(
382
+ Oe,
383
+ {
384
+ categoryGuid: t.top_level_category_guid,
385
+ size: 24,
386
+ sx: { color: "text.primary" },
387
+ variant: Ge.Transparent
388
+ }
389
+ ) }) }),
390
+ /* @__PURE__ */ e(
391
+ z,
392
+ {
393
+ primary: _.category_title,
394
+ primaryTypographyProps: { variant: "caption" },
395
+ secondary: /* @__PURE__ */ e(A, { bold: !0, sx: { color: "text.primary" }, variant: "body1", children: t.category ?? _.actions_select_a_category })
396
+ }
397
+ ),
398
+ /* @__PURE__ */ e(X, { children: /* @__PURE__ */ e(P, { name: "chevron_right", sx: { color: "text.primary" } }) })
399
+ ]
400
+ }
401
+ ),
402
+ /* @__PURE__ */ e(
403
+ Fe,
404
+ {
405
+ initialSelected: t.category_guid,
406
+ onClose: M,
407
+ onSelect: I,
408
+ showDrawer: d,
409
+ title: _.actions_select_a_category
410
+ }
411
+ ),
412
+ /* @__PURE__ */ e(
413
+ ae,
414
+ {
415
+ copy: {
416
+ title: E(
417
+ _.actions_apply_to_all_transaction_types,
418
+ t.description
419
+ )
420
+ },
421
+ isOpen: !!p,
422
+ onClose: () => g(""),
423
+ onPrimaryAction: () => h(!0),
424
+ onSecondaryAction: () => h(!1),
425
+ primaryText: _.actions_apply_to_all,
426
+ secondaryText: _.actions_this_time_only,
427
+ children: /* @__PURE__ */ e(ee, { variant: "subtitle1", children: E(
428
+ _.actions_all_past_and_future,
429
+ t.description,
430
+ B?.name
431
+ ) })
432
+ }
433
+ )
434
+ ] });
435
+ }, Et = ({ transaction: t }) => {
436
+ const { onEvent: r } = G(), { updateTransaction: s } = R(), { updateManualTransaction: a } = re(), { common: n, transactions: o } = O(), i = H(), [_, c] = l.useState(!1), [d, u] = l.useState(t.date), p = (I) => {
437
+ u(Ie(I));
438
+ }, g = async () => {
439
+ if (t.is_manual && !t.guid) {
440
+ a({ ...t, date: d }), c(!1);
441
+ return;
442
+ }
443
+ await s({ ...t, date: d }), r(Y.TRANSACTION_DETAILS_CLICK_DATE, { transaction_guid: t.guid }), c(!1);
444
+ }, h = i.palette.mode === "dark" ? "grey.800" : "grey.100";
445
+ return /* @__PURE__ */ m(U, { className: "mx-txn-date-action", disableGutters: !0, disablePadding: !0, children: [
446
+ /* @__PURE__ */ m(
447
+ Q,
448
+ {
449
+ onClick: () => {
450
+ r(C.ON_TRANSACTION_DATE_CLICK), c(!0);
451
+ },
452
+ children: [
453
+ /* @__PURE__ */ e(q, { children: /* @__PURE__ */ e(j, { sx: { bgcolor: h }, variant: "rounded", children: /* @__PURE__ */ e(P, { name: "calendar_month", sx: { color: "text.primary" } }) }) }),
454
+ /* @__PURE__ */ e(
455
+ z,
456
+ {
457
+ primary: o.date_title,
458
+ primaryTypographyProps: { variant: "caption" },
459
+ secondary: /* @__PURE__ */ e(A, { bold: !0, sx: { color: "text.primary" }, variant: "body1", children: Me(ve(t.date), Re.YEAR_MONTH_DAY) })
460
+ }
461
+ ),
462
+ /* @__PURE__ */ e(X, { children: /* @__PURE__ */ e(P, { name: "chevron_right", sx: { color: "text.primary" } }) })
463
+ ]
464
+ }
465
+ ),
466
+ /* @__PURE__ */ e(
467
+ _e,
468
+ {
469
+ ariaLabelClose: n.close_aria,
470
+ isOpen: _,
471
+ onClose: () => c(!1),
472
+ onPrimaryAction: g,
473
+ primaryText: n.save_button,
474
+ secondaryText: n.cancel_button,
475
+ title: o.date_edit_title,
476
+ children: /* @__PURE__ */ e(L, { alignItems: "center", mt: 40, children: /* @__PURE__ */ e(
477
+ Xe,
478
+ {
479
+ beginDate: ve(d),
480
+ copy: {
481
+ nextAria: o.date_next_aria,
482
+ prevAria: o.date_prev_aria,
483
+ today: n.date_range_picker.today
484
+ },
485
+ onDateSelected: p,
486
+ selectionType: Ze.Single
487
+ }
488
+ ) })
489
+ }
490
+ )
491
+ ] });
492
+ }, Ot = ({ transaction: t }) => {
493
+ const { onEvent: r } = G(), { removeTransaction: s } = R(), { setShouldDisableDrawerScroll: a } = re(), { common: n, transactions: o } = O(), [i, _] = l.useState(!1), c = async () => {
494
+ await s(t.guid), r(C.ON_TRANSACTION_DELETE_DELETED);
495
+ };
496
+ return /* @__PURE__ */ m(W, { className: "mx-txn-delete", children: [
497
+ t && /* @__PURE__ */ e(U, { disableGutters: !0, disablePadding: !0, children: /* @__PURE__ */ m(
498
+ Q,
499
+ {
500
+ onClick: () => {
501
+ r(C.ON_TRANSACTION_DELETE_CLICK), a(!0), _(!0);
502
+ },
503
+ children: [
504
+ /* @__PURE__ */ e(q, { children: /* @__PURE__ */ e(j, { variant: "rounded", children: /* @__PURE__ */ e(fe, { color: "secondary", fontSize: "small" }) }) }),
505
+ /* @__PURE__ */ e(
506
+ z,
507
+ {
508
+ primary: o.manual_transaction_delete_title,
509
+ secondary: o.manual_transaction_delete_subtitle
510
+ }
511
+ ),
512
+ /* @__PURE__ */ e(X, { children: /* @__PURE__ */ e(fe, {}) })
513
+ ]
514
+ }
515
+ ) }),
516
+ /* @__PURE__ */ e(
517
+ ae,
518
+ {
519
+ copy: { title: o.manual_transaction_delete_title },
520
+ isOpen: i,
521
+ onClose: () => {
522
+ a(!1), _(!1);
523
+ },
524
+ onPrimaryAction: c,
525
+ onSecondaryAction: () => r(C.ON_TRANSACTION_DELETE_CANCEL),
526
+ primaryText: n.delete_button,
527
+ secondaryText: n.cancel_button,
528
+ children: /* @__PURE__ */ e(A, { sx: { whiteSpace: "normal" }, variant: "subtitle1", children: o.manual_transaction_delete_description })
529
+ }
530
+ )
531
+ ] });
532
+ }, Lt = w(Ot), wt = ({ transaction: t }) => {
533
+ const { onEvent: r } = G(), { updateTransaction: s } = R(), { setShouldDisableDrawerScroll: a } = re(), { common: n, transactions: o } = O(), i = H(), [_, c] = l.useState(!1), d = async () => {
534
+ await s({ ...t, merchant_guid: "" }), r(Y.TRANSACTION_DETAILS_CLICK_DELETE_LOGO, {
535
+ transaction_guid: t.guid
536
+ });
537
+ }, u = i.palette.mode === "dark" ? "grey.800" : "grey.100";
538
+ return /* @__PURE__ */ e(l.Fragment, { children: t && /* @__PURE__ */ m(U, { className: "mx-txn-delete-logo", disableGutters: !0, disablePadding: !0, children: [
539
+ /* @__PURE__ */ m(
540
+ Q,
541
+ {
542
+ onClick: () => {
543
+ r(C.ON_TRANSACTION_DELETE_LOGO_CLICK), c(!0);
544
+ },
545
+ children: [
546
+ /* @__PURE__ */ e(q, { children: /* @__PURE__ */ e(j, { sx: { bgcolor: u }, variant: "rounded", children: /* @__PURE__ */ e(P, { name: "delete", sx: { color: "text.primary" } }) }) }),
547
+ /* @__PURE__ */ e(z, { primary: o.merchant_logo_title, secondary: o.merchant_logo_desc }),
548
+ /* @__PURE__ */ e(X, { children: /* @__PURE__ */ e(P, { name: "chevron_right", sx: { color: "text.primary" } }) })
549
+ ]
550
+ }
551
+ ),
552
+ /* @__PURE__ */ m(
553
+ ae,
554
+ {
555
+ copy: { title: o.merchant_logo_modal_title },
556
+ isOpen: _,
557
+ onClose: () => {
558
+ a(!1), c(!1);
559
+ },
560
+ onPrimaryAction: d,
561
+ onSecondaryAction: () => r(C.ON_TRANSACTION_DELETE_LOGO_CANCEL),
562
+ primaryText: n.delete_button,
563
+ secondaryText: n.cancel_button,
564
+ title: o.merchant_logo_modal_title,
565
+ children: [
566
+ /* @__PURE__ */ e(A, { sx: { whiteSpace: "normal" }, variant: "subtitle1", children: o.merchant_logo_modal_desc }),
567
+ /* @__PURE__ */ e(A, { bold: !0, sx: { whiteSpace: "normal" }, variant: "subtitle1", children: ` ${o.merchant_logo_modal_desc_bold}` })
568
+ ]
569
+ }
570
+ )
571
+ ] }) });
572
+ }, Mt = w(wt), Rt = ({ transaction: t }) => {
573
+ const { onEvent: r } = G(), { setAlert: s, updateTransaction: a } = R(), { setShouldDisableDrawerScroll: n } = re(), { common: o, transactions: i } = O(), _ = H(), [c, d] = l.useState(!1), u = t.is_hidden, p = async () => {
574
+ try {
575
+ await a({ ...t, is_hidden: !t.is_hidden }), r(
576
+ u ? C.ON_TRANSACTION_UNHIDDEN : C.ON_TRANSACTION_HIDDEN
577
+ ), s(u ? i.transaction_included : i.transaction_excluded);
578
+ } catch {
579
+ s(u ? i.transaction_not_included : i.transaction_not_excluded);
580
+ }
581
+ }, g = _.palette.mode === "dark" ? "grey.800" : "grey.100";
582
+ return /* @__PURE__ */ e(l.Fragment, { children: t && /* @__PURE__ */ m(U, { className: "mx-txn-hide-transaction", disableGutters: !0, disablePadding: !0, children: [
583
+ /* @__PURE__ */ m(
584
+ Q,
585
+ {
586
+ "aria-checked": u,
587
+ "aria-labelledby": "hide-transaction-text",
588
+ onClick: () => {
589
+ r(
590
+ u ? C.ON_TRANSACTION_UNHIDE_CLICK : C.ON_TRANSACTION_HIDE_CLICK
591
+ ), r(
592
+ u ? "transaction_details_click_unhide_transaction" : "transaction_details_click_hide_transaction",
593
+ {
594
+ transaction_guid: t.guid
595
+ }
596
+ ), d(!0);
597
+ },
598
+ role: "switch",
599
+ children: [
600
+ /* @__PURE__ */ e(q, { children: /* @__PURE__ */ e(j, { sx: { bgcolor: g }, variant: "rounded", children: u ? /* @__PURE__ */ e(P, { name: "visibility_off", sx: { color: "text.primary" } }) : /* @__PURE__ */ e(P, { name: "visibility", sx: { color: "text.primary" } }) }) }),
601
+ /* @__PURE__ */ e(
602
+ z,
603
+ {
604
+ id: "hide-transaction-text",
605
+ primary: i.exclude_transaction,
606
+ secondary: i.excluding_transaction
607
+ }
608
+ ),
609
+ /* @__PURE__ */ e(X, { "aria-hidden": "true", children: /* @__PURE__ */ e(
610
+ ft,
611
+ {
612
+ checked: u,
613
+ inputProps: { tabIndex: -1 },
614
+ sx: { pointerEvents: "none" },
615
+ tabIndex: -1
616
+ }
617
+ ) })
618
+ ]
619
+ }
620
+ ),
621
+ /* @__PURE__ */ e(
622
+ ae,
623
+ {
624
+ copy: {
625
+ title: u ? i.include_transaction : i.exclude_transaction
626
+ },
627
+ isOpen: c,
628
+ onClose: () => {
629
+ n(!1), d(!1);
630
+ },
631
+ onPrimaryAction: p,
632
+ onSecondaryAction: () => r(
633
+ u ? C.ON_TRANSACTION_UNHIDE_CANCEL_CLICK : C.ON_TRANSACTION_HIDE_CANCEL_CLICK
634
+ ),
635
+ primaryText: u ? i.include : i.exclude,
636
+ secondaryText: o.cancel_button,
637
+ children: /* @__PURE__ */ e(A, { truncate: !1, variant: "subtitle1", children: u ? i.including_transaction : i.excluding_transaction })
638
+ }
639
+ )
640
+ ] }) });
641
+ }, kt = w(Rt), He = ({ transaction: t }) => {
642
+ const { amount: r, description: s, isIncome: a, merchant_guid: n, payee: o, top_level_category_guid: i } = t;
643
+ return /* @__PURE__ */ m(L, { className: "mx-txn-amount-header", direction: "row", gap: 12, px: 16, py: 24, children: [
644
+ /* @__PURE__ */ e(
645
+ Ce,
646
+ {
647
+ categoryGuid: i || "",
648
+ merchantGuid: n || "",
649
+ size: 64
650
+ }
651
+ ),
652
+ /* @__PURE__ */ m(L, { overflow: "hidden'", children: [
653
+ /* @__PURE__ */ e(A, { bold: !0, mb: 4, truncate: !0, variant: "body1", children: s || o }),
654
+ /* @__PURE__ */ m(ee, { color: a ? "success.main" : "text.primary", truncate: !0, variant: "h1", children: [
655
+ a ? "+" : "",
656
+ V(r, "0,0.00")
657
+ ] })
658
+ ] })
659
+ ] });
660
+ }, Pt = ({ transaction: t }) => {
661
+ const { onEvent: r } = G(), { updateTransaction: s } = R(), { updateManualTransaction: a } = re(), { common: n, transactions: o } = O(), i = H(), [_, c] = l.useState(!1), [d, u] = l.useState("");
662
+ l.useEffect(() => {
663
+ _ && u(t.memo ? t.memo : "");
664
+ }, [_]);
665
+ const p = async () => {
666
+ if (t.is_manual && !t.guid) {
667
+ a({ ...t, memo: d }), c(!1);
668
+ return;
669
+ }
670
+ await s({ ...t, memo: d }), r(Y.TRANSACTION_DETAILS_CLICK_MEMO, { transaction_guid: t.guid }), c(!1);
671
+ }, g = i.palette.mode === "dark" ? "grey.800" : "grey.100";
672
+ return /* @__PURE__ */ m(U, { className: "mx-txn-memo-action", disableGutters: !0, disablePadding: !0, children: [
673
+ /* @__PURE__ */ m(
674
+ Q,
675
+ {
676
+ onClick: () => {
677
+ r(C.ON_TRANSACTION_MEMO_CLICK), c(!0);
678
+ },
679
+ children: [
680
+ /* @__PURE__ */ e(q, { children: /* @__PURE__ */ e(j, { sx: { bgcolor: g }, variant: "rounded", children: /* @__PURE__ */ e(P, { name: "article", sx: { color: "text.primary" } }) }) }),
681
+ /* @__PURE__ */ e(
682
+ z,
683
+ {
684
+ primary: o.memo_title,
685
+ primaryTypographyProps: { variant: "caption" },
686
+ secondary: /* @__PURE__ */ e(
687
+ A,
688
+ {
689
+ bold: !0,
690
+ sx: { overflowWrap: "break-word", whiteSpace: "wrap", color: "text.primary" },
691
+ variant: "body1",
692
+ children: t.memo ? t.memo : o.memo_desc
693
+ }
694
+ )
695
+ }
696
+ ),
697
+ /* @__PURE__ */ e(X, { children: /* @__PURE__ */ e(P, { name: "chevron_right", sx: { color: "text.primary" } }) })
698
+ ]
699
+ }
700
+ ),
701
+ /* @__PURE__ */ m(
702
+ _e,
703
+ {
704
+ ariaLabelClose: n.close_aria,
705
+ isOpen: _,
706
+ onClose: () => c(!1),
707
+ onPrimaryAction: p,
708
+ title: o.memo_title,
709
+ children: [
710
+ /* @__PURE__ */ e(He, { transaction: t }),
711
+ /* @__PURE__ */ e(
712
+ $e,
713
+ {
714
+ "aria-label": o.memo_desc_aria,
715
+ focused: !0,
716
+ multiline: !0,
717
+ name: "memo",
718
+ onChange: (h) => u(h.target.value),
719
+ placeholder: o.memo_desc,
720
+ rows: 4,
721
+ sx: { mx: 16, width: "calc(100% - 32px)" },
722
+ value: d
723
+ }
724
+ )
725
+ ]
726
+ }
727
+ )
728
+ ] });
729
+ }, Gt = w(Pt), Bt = ({
730
+ index: t,
731
+ onDeleteRow: r,
732
+ onCategoryChanged: s,
733
+ onUpdateAmount: a,
734
+ split: n
735
+ }) => {
736
+ const { onEvent: o } = G(), { transactions: i } = O(), [_, c] = l.useState(`${n.amount}`), [d, u] = l.useState(!1), p = t === 0, g = (h) => {
737
+ isNaN(Number(h)) || (c(h), a(t, Number(h)));
738
+ };
739
+ return /* @__PURE__ */ m(W, { bgcolor: "background.paper", className: "mx-txn-split-manager-row", pb: 4, px: 8, children: [
740
+ /* @__PURE__ */ m(Ne, { alignItems: p ? "center" : "start", container: !0, children: [
741
+ /* @__PURE__ */ e(Ne, { item: !0, xs: 7, children: /* @__PURE__ */ m(L, { alignItems: "start", children: [
742
+ /* @__PURE__ */ e(
743
+ me,
744
+ {
745
+ endIcon: /* @__PURE__ */ e(Ke, {}),
746
+ onClick: () => u(!0),
747
+ startIcon: /* @__PURE__ */ e(Oe, { categoryGuid: n.top_level_category_guid }),
748
+ sx: { px: 12, py: 8 },
749
+ children: n.category
750
+ }
751
+ ),
752
+ /* @__PURE__ */ e(W, { children: !n.category_guid && /* @__PURE__ */ m(L, { color: "error.main", direction: "row", gap: 8, p: 12, children: [
753
+ /* @__PURE__ */ e("span", { "aria-label": "error", role: "img", children: /* @__PURE__ */ e(Se, { sx: { fontSize: 15 } }) }),
754
+ /* @__PURE__ */ e(A, { variant: "body2", children: i.split_transaction_errors_select_category })
755
+ ] }) })
756
+ ] }) }),
757
+ /* @__PURE__ */ e(Ne, { item: !0, xs: 5, children: p ? /* @__PURE__ */ e("div", { className: "mx-txn-split-manager-row-top-container", children: /* @__PURE__ */ e(A, { children: V(n.amount, "0,0.00") }) }) : /* @__PURE__ */ m(L, { alignItems: "start", children: [
758
+ /* @__PURE__ */ m(L, { alignItems: "start", direction: "row", gap: 8, children: [
759
+ /* @__PURE__ */ e(
760
+ Ct,
761
+ {
762
+ amount: _,
763
+ ariaLabel: i.split_transaction_edit_split_amount,
764
+ label: i.split_transaction_edit_split_amount,
765
+ minAmount: 0.01,
766
+ name: "split-amount-input",
767
+ setAmount: g,
768
+ sx: {
769
+ ".MuiOutlinedInput-input": { p: 12 }
770
+ },
771
+ type: "number"
772
+ }
773
+ ),
774
+ /* @__PURE__ */ e(
775
+ ue,
776
+ {
777
+ "aria-label": i.split_transaction_delete_split_btn,
778
+ color: "secondary",
779
+ onClick: () => {
780
+ o(C.ON_TRANSACTION_SPLIT_DELETE_CLICK), r(t);
781
+ },
782
+ sx: { w: 44, h: 44 },
783
+ children: /* @__PURE__ */ e(fe, {})
784
+ }
785
+ )
786
+ ] }),
787
+ !_ && /* @__PURE__ */ m(L, { color: "error.main", direction: "row", gap: 8, py: 12, children: [
788
+ /* @__PURE__ */ e("span", { "aria-label": "error", role: "img", children: /* @__PURE__ */ e(Se, { sx: { fontSize: 15 } }) }),
789
+ /* @__PURE__ */ e(A, { variant: "body2", children: i.split_transaction_errors_enter_an_amount })
790
+ ] })
791
+ ] }) })
792
+ ] }),
793
+ /* @__PURE__ */ e(
794
+ Fe,
795
+ {
796
+ initialSelected: n.category_guid,
797
+ onClose: () => u(!1),
798
+ onSelect: (h) => {
799
+ s(t, h), u(!1);
800
+ },
801
+ showDrawer: d,
802
+ title: i.actions_select_a_category
803
+ }
804
+ )
805
+ ] });
806
+ }, $t = w(Bt), Kt = ({
807
+ onAddSplit: t,
808
+ onCategoryChanged: r,
809
+ onDeleteSplit: s,
810
+ onUpdateAmount: a,
811
+ splits: n,
812
+ transaction: o
813
+ }) => {
814
+ const { transactions: i } = O(), { onEvent: _ } = G(), [c, d] = l.useState(""), { announce: u, ariaLive: p } = xe();
815
+ return l.useEffect(() => {
816
+ if (n.length <= 1)
817
+ d(i.split_transaction_errors_min_splits), u(i.split_transaction_errors_min_splits);
818
+ else if (n[0].amount < 0) {
819
+ const g = E(
820
+ i.split_transaction_errors_totals_must_equal_amount,
821
+ V(o.amount, "0,0.00")
822
+ );
823
+ d(g), u(g);
824
+ } else
825
+ d(""), u("");
826
+ }, [n]), /* @__PURE__ */ m(W, { className: "mx-txn-split-manager", children: [
827
+ p,
828
+ n.map((g, h) => /* @__PURE__ */ e(
829
+ $t,
830
+ {
831
+ index: h,
832
+ onCategoryChanged: r,
833
+ onDeleteRow: s,
834
+ onUpdateAmount: a,
835
+ split: g
836
+ },
837
+ h
838
+ )),
839
+ c && /* @__PURE__ */ m(L, { bgcolor: "background.paper", color: "error.main", direction: "row", gap: 8, p: 16, children: [
840
+ /* @__PURE__ */ e("span", { "aria-label": "error", role: "img", children: /* @__PURE__ */ e(Se, { sx: { fontSize: 15 } }) }),
841
+ /* @__PURE__ */ e(A, { variant: "body2", children: c })
842
+ ] }),
843
+ /* @__PURE__ */ e(W, { p: 16, children: /* @__PURE__ */ e(
844
+ me,
845
+ {
846
+ "aria-label": i.split_transaction_add_split_btn,
847
+ onClick: () => {
848
+ _(C.ON_TRANSACTION_SPLIT_ADD_CLICK), t();
849
+ },
850
+ children: i.split_transaction_add_split_btn
851
+ }
852
+ ) })
853
+ ] });
854
+ }, Ft = w(Kt), Ht = ({ transaction: t }) => {
855
+ const { onEvent: r } = G(), { announce: s, ariaLive: a } = xe(), { splitTransaction: n, unSplitTransaction: o } = R(), { common: i, transactions: _ } = O(), { setShouldDisableDrawerScroll: c } = re(), { categories: d } = we(), u = H(), p = {
856
+ ...t,
857
+ amount: t.amount - 1,
858
+ guid: "",
859
+ has_been_split: !1,
860
+ parent_guid: t.guid
861
+ }, g = {
862
+ ...t,
863
+ amount: 1,
864
+ category_guid: void 0,
865
+ category: _.split_transaction_select_category_btn,
866
+ guid: "",
867
+ has_been_split: !1,
868
+ parent_guid: t.guid,
869
+ top_level_category_guid: void 0
870
+ }, [h, I] = l.useState(!1), [M, B] = l.useState(!1), [k, f] = l.useState(!1), [x, y] = l.useState([]), Z = () => {
871
+ const N = [...x];
872
+ N.push({ ...g }), N[0].amount -= 1, y(N), s(
873
+ E(
874
+ _.split_transaction_add_split_announcement,
875
+ N.length
876
+ )
877
+ );
878
+ }, se = (N) => {
879
+ if (N > 0) {
880
+ const v = x[N], S = [...x];
881
+ S.splice(N, 1), S[0].amount += v.amount, y(S), s(
882
+ E(_.split_transaction_delete_split_announcement, N + 1)
883
+ );
884
+ }
885
+ }, le = (N, v) => {
886
+ const S = [...x];
887
+ S[N].amount = v, S[0].amount = t.amount - S.reduce(
888
+ (T, D, J) => T + (J !== 0 ? D.amount : 0),
889
+ 0
890
+ ), y(S);
891
+ }, te = (N, v) => {
892
+ const S = [...x], T = d.find((D) => D.guid === v);
893
+ T && (S[N] = {
894
+ ...S[N],
895
+ category_guid: v,
896
+ category: T.name,
897
+ top_level_category_guid: T.parent_guid || v
898
+ }, y(S), s(
899
+ E(
900
+ _.split_transaction_select_category_announcement,
901
+ T.name,
902
+ N + 1
903
+ )
904
+ ));
905
+ }, $ = () => {
906
+ if (t.parent_guid || t.has_been_split) {
907
+ B(!0);
908
+ return;
909
+ }
910
+ y([{ ...p }, { ...g }]), r(Y.TRANSACTION_DETAILS_CLICK_SPLIT, {
911
+ transaction_guid: t.guid
912
+ }), I(!0);
913
+ }, b = async () => {
914
+ if (!k) {
915
+ f(!0);
916
+ try {
917
+ r(C.ON_TRANSACTION_SPLIT_SAVE_CLICK), await n({ ...t, has_been_split: !0 }, x), I(!1);
918
+ } finally {
919
+ f(!1);
920
+ }
921
+ }
922
+ }, K = async () => {
923
+ k || (r(C.ON_TRANSACTION_SPLIT_CANCEL_CLICK), y([{ ...p }, { ...g }]), f(!1), I(!1));
924
+ }, ne = async () => {
925
+ r(Y.TRANSACTION_DETAILS_CLICK_UNSPLIT, {
926
+ transaction_guid: t.guid
927
+ });
928
+ const N = t.parent_guid ?? t.guid;
929
+ await o(N);
930
+ }, F = l.useMemo(() => {
931
+ const N = x.some((S) => !S.category_guid), v = x.some((S) => S.amount <= 0);
932
+ return N || v;
933
+ }, [x]), oe = u.palette.mode === "dark" ? "grey.800" : "grey.100";
934
+ return /* @__PURE__ */ e(l.Fragment, { children: t && /* @__PURE__ */ m(U, { disableGutters: !0, disablePadding: !0, children: [
935
+ /* @__PURE__ */ m(Q, { onClick: $, children: [
936
+ /* @__PURE__ */ e(q, { children: /* @__PURE__ */ e(j, { sx: { bgcolor: oe }, variant: "rounded", children: /* @__PURE__ */ e(P, { name: "call_split", sx: { color: "text.primary" } }) }) }),
937
+ /* @__PURE__ */ e(
938
+ z,
939
+ {
940
+ primary: t.has_been_split || t.parent_guid ? _.split_transaction_unsplit_title : _.split_transaction_title,
941
+ secondary: t.has_been_split || t.parent_guid ? _.split_transaction_unsplit_subtitle : _.split_transaction_desc
942
+ }
943
+ ),
944
+ /* @__PURE__ */ e(X, { children: t.has_been_split || t.parent_guid ? /* @__PURE__ */ e(P, { name: "delete" }) : /* @__PURE__ */ e(P, { name: "chevron_right", sx: { color: "text.primary" } }) })
945
+ ] }),
946
+ /* @__PURE__ */ m(
947
+ _e,
948
+ {
949
+ ariaLabelClose: i.close_aria,
950
+ isOpen: h,
951
+ isPrimaryDisabled: F || k,
952
+ onClose: K,
953
+ onPrimaryAction: b,
954
+ primaryText: i.save_button,
955
+ secondaryText: i.cancel_button,
956
+ title: _.split_transaction_title,
957
+ children: [
958
+ a,
959
+ /* @__PURE__ */ e(He, { transaction: t }),
960
+ /* @__PURE__ */ e(
961
+ Ft,
962
+ {
963
+ onAddSplit: Z,
964
+ onCategoryChanged: te,
965
+ onDeleteSplit: se,
966
+ onUpdateAmount: le,
967
+ splits: x,
968
+ transaction: t
969
+ }
970
+ )
971
+ ]
972
+ }
973
+ ),
974
+ /* @__PURE__ */ e(
975
+ ae,
976
+ {
977
+ copy: { title: _.split_transaction_unsplit_title },
978
+ isOpen: M,
979
+ onClose: () => {
980
+ c(!1), B(!1);
981
+ },
982
+ onPrimaryAction: ne,
983
+ onSecondaryAction: () => {
984
+ r(C.ON_TRANSACTION_UNSPLIT_CANCEL);
985
+ },
986
+ primaryText: i.delete_button,
987
+ secondaryText: i.cancel_button,
988
+ children: /* @__PURE__ */ e(ee, { variant: "subtitle1", children: E(
989
+ _.split_transaction_unsplit_description,
990
+ t.description
991
+ ) })
992
+ }
993
+ )
994
+ ] }) });
995
+ }, Ut = w(Ht), zt = () => {
996
+ const t = yt(), { onEvent: r } = G(), { addTag: s } = R(), { transactions: a } = O(), [n, o] = l.useState(!1), [i, _] = l.useState(""), [c, d] = l.useState(""), u = l.useRef(null);
997
+ l.useEffect(() => {
998
+ n && u?.current?.focus();
999
+ }, [n]);
1000
+ const p = () => {
1001
+ r(
1002
+ n ? C.ON_TRANSACTION_TAGS_TAG_ADD_CANCEL_CLICK : C.ON_TRANSACTION_TAGS_TAG_ADD_CLICK
1003
+ ), n || _(""), o(!n);
1004
+ }, g = async () => {
1005
+ r(C.ON_TRANSACTION_TAGS_TAG_ADDED), await s(i), o(!1);
1006
+ };
1007
+ return l.useEffect(() => {
1008
+ d(i.length > 40 ? a.tags_error_name_must_be_40_chars : "");
1009
+ }, [i]), /* @__PURE__ */ m(W, { className: "mx-txn-tag-manager-header", children: [
1010
+ /* @__PURE__ */ m(
1011
+ L,
1012
+ {
1013
+ alignItems: "center",
1014
+ bgcolor: t.palette.background.default,
1015
+ direction: "row",
1016
+ justifyContent: "space-between",
1017
+ px: 24,
1018
+ py: 16,
1019
+ children: [
1020
+ /* @__PURE__ */ e(A, { bold: !0, children: a.tags_your_tags }),
1021
+ /* @__PURE__ */ e(
1022
+ me,
1023
+ {
1024
+ "aria-expanded": n,
1025
+ "aria-label": a.tags_add_tag_btn_aria,
1026
+ onClick: p,
1027
+ children: a.tags_add_tag_btn
1028
+ }
1029
+ )
1030
+ ]
1031
+ }
1032
+ ),
1033
+ /* @__PURE__ */ m(
1034
+ ae,
1035
+ {
1036
+ copy: { title: a.tags_add_tag_btn },
1037
+ isOpen: n,
1038
+ onClose: () => o(!1),
1039
+ onPrimaryAction: g,
1040
+ onSecondaryAction: () => o(!1),
1041
+ children: [
1042
+ /* @__PURE__ */ e(
1043
+ Le,
1044
+ {
1045
+ "aria-label": a.tags_placeholder,
1046
+ name: "add-tag",
1047
+ onChange: (h) => _(h.target.value),
1048
+ placeholder: a.tags_placeholder,
1049
+ sx: { width: "100%" },
1050
+ value: i
1051
+ }
1052
+ ),
1053
+ /* @__PURE__ */ e(ee, { id: "add-tag-error", sx: { color: "error.main" }, variant: "subtitle2", children: c })
1054
+ ]
1055
+ }
1056
+ )
1057
+ ] });
1058
+ }, Vt = w(zt), Wt = ({ onSearchValueChanged: t, searchValue: r }) => {
1059
+ const { common: s, transactions: a } = O(), n = /* @__PURE__ */ e(
1060
+ ue,
1061
+ {
1062
+ "aria-label": a.tags_cancel_search || "Search",
1063
+ onClick: () => t(""),
1064
+ children: /* @__PURE__ */ e(Se, {})
1065
+ }
1066
+ );
1067
+ return /* @__PURE__ */ e(W, { className: "mx-txn-tag-manager-search", px: 24, py: 16, children: /* @__PURE__ */ e(
1068
+ Le,
1069
+ {
1070
+ InputProps: {
1071
+ startAdornment: /* @__PURE__ */ e(Pe, { position: "start", children: /* @__PURE__ */ e(it, { color: "disabled" }) }),
1072
+ endAdornment: /* @__PURE__ */ e(Pe, { position: "end", sx: { padding: 0 }, children: r ? n : null })
1073
+ },
1074
+ "aria-label": s.search_aria,
1075
+ name: "search",
1076
+ onChange: (o) => t(o.target.value),
1077
+ placeholder: s.search_placeholder,
1078
+ sx: { bgcolor: "background.paper", width: "100%" },
1079
+ value: r
1080
+ }
1081
+ ) });
1082
+ }, Yt = w(Wt), jt = ({ onTagChecked: t, selectedTags: r, tag: s }) => {
1083
+ const { onEvent: a } = G(), { removeTag: n, updateTag: o } = R(), { common: i, transactions: _ } = O(), [c, d] = l.useState(!1), [u, p] = l.useState(!1), [g, h] = l.useState(""), [I, M] = l.useState(""), B = async () => {
1084
+ a(C.ON_TRANSACTION_TAGS_TAG_EDIT_SAVED), s && await o({ ...s, name: g }), d(!1);
1085
+ }, k = async () => {
1086
+ a(C.ON_TRANSACTION_TAGS_TAG_DELETED), await n(s.guid), p(!1);
1087
+ };
1088
+ l.useEffect(() => {
1089
+ M(g.length > 40 ? _.tags_error_name_must_be_40_chars : "");
1090
+ }, [g]);
1091
+ const f = () => {
1092
+ a(C.ON_TRANSACTION_TAGS_TAG_EDIT_CLICK), h(s.name), d(!0);
1093
+ }, x = () => {
1094
+ a(C.ON_TRANSACTION_TAGS_TAG_DELETE_CLICK), p(!0);
1095
+ };
1096
+ return /* @__PURE__ */ m(
1097
+ U,
1098
+ {
1099
+ className: "mx-txn-transaction-manager-row",
1100
+ disableGutters: !0,
1101
+ disablePadding: !0,
1102
+ secondaryAction: !s.is_default_tag && /* @__PURE__ */ m(L, { direction: "row", children: [
1103
+ /* @__PURE__ */ e(
1104
+ ue,
1105
+ {
1106
+ "aria-label": `Edit ${s.name} tag`,
1107
+ color: "secondary",
1108
+ onClick: f,
1109
+ children: /* @__PURE__ */ e(st, { color: "secondary" })
1110
+ }
1111
+ ),
1112
+ /* @__PURE__ */ e(
1113
+ ue,
1114
+ {
1115
+ "aria-label": `Delete ${s.name} tag`,
1116
+ color: "secondary",
1117
+ onClick: x,
1118
+ children: /* @__PURE__ */ e(fe, { color: "secondary" })
1119
+ }
1120
+ )
1121
+ ] }),
1122
+ children: [
1123
+ /* @__PURE__ */ m(
1124
+ Q,
1125
+ {
1126
+ "aria-checked": r.includes(s.guid),
1127
+ onClick: () => t(s.guid),
1128
+ role: "checkbox",
1129
+ children: [
1130
+ /* @__PURE__ */ e(X, { sx: { ml: 0 }, children: /* @__PURE__ */ e(
1131
+ Tt,
1132
+ {
1133
+ "aria-hidden": !0,
1134
+ checked: r.includes(s.guid),
1135
+ edge: "start",
1136
+ tabIndex: -1
1137
+ }
1138
+ ) }),
1139
+ /* @__PURE__ */ e(z, { children: s.name })
1140
+ ]
1141
+ }
1142
+ ),
1143
+ /* @__PURE__ */ m(
1144
+ ae,
1145
+ {
1146
+ copy: { title: "Update tag name" },
1147
+ isOpen: c,
1148
+ onClose: () => d(!1),
1149
+ onPrimaryAction: B,
1150
+ onSecondaryAction: () => d(!1),
1151
+ children: [
1152
+ /* @__PURE__ */ e(
1153
+ Le,
1154
+ {
1155
+ "aria-describedby": I ? "update-tag-error" : void 0,
1156
+ "aria-label": _.tags_update_the_tag_name,
1157
+ name: "update-tag",
1158
+ onChange: (y) => h(y.target.value),
1159
+ placeholder: "Tag name",
1160
+ sx: { width: "100%" },
1161
+ value: g
1162
+ }
1163
+ ),
1164
+ /* @__PURE__ */ e(ee, { id: "update-tag-error", sx: { color: "error.main" }, variant: "subtitle2", children: I })
1165
+ ]
1166
+ }
1167
+ ),
1168
+ /* @__PURE__ */ e(
1169
+ ae,
1170
+ {
1171
+ copy: { title: _.tags_delete_title },
1172
+ isOpen: u,
1173
+ onClose: () => p(!1),
1174
+ onPrimaryAction: k,
1175
+ onSecondaryAction: () => a(C.ON_TRANSACTION_TAGS_TAG_DELETE_CANCEL_CLICK),
1176
+ primaryText: i.delete_button,
1177
+ secondaryText: i.cancel_button,
1178
+ children: /* @__PURE__ */ e(A, { truncate: !1, children: _.tags_deleting_this_tag_will_remove_it })
1179
+ }
1180
+ )
1181
+ ]
1182
+ }
1183
+ );
1184
+ }, qt = w(jt), Qt = ({ selectedTags: t, onTagChecked: r }) => {
1185
+ const { tags: s } = R(), [a, n] = l.useState(""), o = s.filter(
1186
+ (i) => i.name.toLowerCase().includes(a.toLowerCase())
1187
+ );
1188
+ return /* @__PURE__ */ m("div", { className: "mx-txn-tag-manager", children: [
1189
+ /* @__PURE__ */ e(
1190
+ Yt,
1191
+ {
1192
+ onSearchValueChanged: (i) => n(i),
1193
+ searchValue: a
1194
+ }
1195
+ ),
1196
+ /* @__PURE__ */ e(Vt, {}),
1197
+ /* @__PURE__ */ e(he, { sx: { boxShadow: "none" }, children: /* @__PURE__ */ e(be, { children: o.map((i) => /* @__PURE__ */ m(l.Fragment, { children: [
1198
+ /* @__PURE__ */ e(qt, { onTagChecked: r, selectedTags: t, tag: i }),
1199
+ /* @__PURE__ */ e(Te, { sx: { ml: 24 } })
1200
+ ] }, i.guid)) }) })
1201
+ ] });
1202
+ }, Xt = w(Qt), Zt = ({ transaction: t }) => {
1203
+ const { onEvent: r } = G(), { tags: s, updateTaggings: a, updateTransaction: n } = R(), { common: o, transactions: i } = O(), { updateManualTransaction: _ } = re(), c = H(), [d, u] = l.useState(!1), [p, g] = l.useState(t.tags);
1204
+ l.useEffect(() => {
1205
+ g(t.tags);
1206
+ }, [d, t]);
1207
+ const h = (k) => {
1208
+ const f = [...p], x = p.indexOf(k);
1209
+ x >= 0 ? f.splice(x, 1) : f.push(k), g(f);
1210
+ }, I = async () => {
1211
+ if (t.is_manual && !t.guid) {
1212
+ _({ ...t, tags: p }), u(!1);
1213
+ return;
1214
+ }
1215
+ await a(p, t.guid), await n({ ...t, tags: p }), r(Y.TRANSACTION_DETAILS_CLICK_TAGS, { transaction_guid: t.guid }), u(!1);
1216
+ }, M = l.useMemo(
1217
+ () => t.tags.map(
1218
+ (k, f, x) => `${s.find((y) => y.guid === k)?.name}${f < x.length - 1 ? " / " : ""}`
1219
+ ),
1220
+ [s, t]
1221
+ ), B = c.palette.mode === "dark" ? "grey.800" : "grey.100";
1222
+ return /* @__PURE__ */ m(U, { disableGutters: !0, disablePadding: !0, children: [
1223
+ /* @__PURE__ */ m(
1224
+ Q,
1225
+ {
1226
+ onClick: () => {
1227
+ r(C.ON_TRANSACTION_TAGS_CLICK), u(!0);
1228
+ },
1229
+ children: [
1230
+ /* @__PURE__ */ e(q, { children: /* @__PURE__ */ e(j, { sx: { bgcolor: B }, variant: "rounded", children: /* @__PURE__ */ e(P, { name: "local_offer", sx: { color: "text.primary" } }) }) }),
1231
+ /* @__PURE__ */ e(
1232
+ z,
1233
+ {
1234
+ primary: i.tags_title,
1235
+ primaryTypographyProps: { variant: "caption" },
1236
+ secondary: /* @__PURE__ */ e(A, { bold: !0, sx: { color: "text.primary" }, variant: "body1", children: t.tags?.length > 0 ? M : i.tags_desc })
1237
+ }
1238
+ ),
1239
+ /* @__PURE__ */ e(X, { children: /* @__PURE__ */ e(P, { name: "chevron_right", sx: { color: "text.primary" } }) })
1240
+ ]
1241
+ }
1242
+ ),
1243
+ /* @__PURE__ */ e(
1244
+ _e,
1245
+ {
1246
+ ariaLabelClose: o.close_aria,
1247
+ isOpen: d,
1248
+ onClose: () => u(!1),
1249
+ onPrimaryAction: I,
1250
+ primaryText: o.save_button,
1251
+ secondaryText: o.cancel_button,
1252
+ title: i.tags_title,
1253
+ children: /* @__PURE__ */ e(Xt, { onTagChecked: h, selectedTags: p })
1254
+ }
1255
+ )
1256
+ ] });
1257
+ }, Jt = w(Zt), ea = ({ transaction: t, viewOnly: r = !1 }) => {
1258
+ const { updateTransaction: s } = R(), { common: a, transactions: n } = O(), { onEvent: o } = G(), { announce: i, ariaLive: _ } = xe(), [c, d] = l.useState(!1), [u, p] = l.useState(""), g = l.useRef(null);
1259
+ l.useEffect(() => {
1260
+ c && (p(t.description), g?.current?.focus());
1261
+ }, [c]);
1262
+ const h = () => {
1263
+ d(!0), o(C.ON_TRANSACTION_DESCRIPTION_EDIT_CLICK), setTimeout(() => document.getElementById("transaction-description-input")?.focus(), 0);
1264
+ }, I = async () => {
1265
+ o(Y.TRANSACTION_DETAILS_CLICK_DESCRIPTION, {
1266
+ transaction_guid: t.guid
1267
+ }), await s({ ...t, description: u }), d(!1), i(`${n.payee_title}: ${u}`), setTimeout(() => document.getElementById("transaction-description-edit-button")?.focus(), 0);
1268
+ };
1269
+ return /* @__PURE__ */ m(W, { className: "mx-txn-transaction-description", children: [
1270
+ _,
1271
+ c ? /* @__PURE__ */ m(et, { row: !0, children: [
1272
+ /* @__PURE__ */ e(
1273
+ $e,
1274
+ {
1275
+ "aria-label": n.payee_title,
1276
+ id: "transaction-description-input",
1277
+ inputProps: { maxLength: 140 },
1278
+ label: n.payee_title,
1279
+ name: n.payee_title,
1280
+ onChange: (M) => p(M.target.value),
1281
+ ref: g,
1282
+ sx: {
1283
+ backgroundColor: "background.paper",
1284
+ ".MuiOutlinedInput-root": { borderTopRightRadius: 0, borderBottomRightRadius: 0 },
1285
+ ".MuiOutlinedInput-input": { p: 11 },
1286
+ width: 250
1287
+ },
1288
+ value: u
1289
+ }
1290
+ ),
1291
+ /* @__PURE__ */ e(
1292
+ me,
1293
+ {
1294
+ disabled: !u,
1295
+ onClick: I,
1296
+ sx: {
1297
+ borderTopLeftRadius: 0,
1298
+ borderBottomLeftRadius: 0
1299
+ },
1300
+ variant: "outlined",
1301
+ children: a.save_button
1302
+ }
1303
+ )
1304
+ ] }) : /* @__PURE__ */ m(L, { alignItems: "center", direction: "row", gap: 4, sx: { minHeight: 44 }, children: [
1305
+ /* @__PURE__ */ e(A, { bold: !0, children: t.description }),
1306
+ !r && /* @__PURE__ */ e(
1307
+ ue,
1308
+ {
1309
+ "aria-label": n.payee_edit,
1310
+ id: "transaction-description-edit-button",
1311
+ onClick: h,
1312
+ sx: { color: "action.active" },
1313
+ children: /* @__PURE__ */ e(ye, { name: "create", size: 22 })
1314
+ }
1315
+ )
1316
+ ] })
1317
+ ] });
1318
+ }, ta = w(ea), aa = ({ transaction: t }) => {
1319
+ const { updateTransaction: r } = R(), { transactions: s } = O(), { onEvent: a } = G(), n = H(), o = n.palette.mode === "dark", i = async () => {
1320
+ a(Y.TRANSACTION_DETAILS_CLICK_FLAG, { transaction_guid: t.guid }), await r({ ...t, is_flagged: !t.is_flagged });
1321
+ };
1322
+ return /* @__PURE__ */ e("div", { className: "mx-txn-transaction-flag", children: /* @__PURE__ */ e(
1323
+ ot,
1324
+ {
1325
+ "aria-label": s.flag_btn_aria,
1326
+ "aria-pressed": t.is_flagged,
1327
+ color: o ? "primary" : "warning",
1328
+ onClick: i,
1329
+ selected: t.is_flagged,
1330
+ sx: {
1331
+ borderRadius: 6,
1332
+ color: o ? "common.white" : "secondary.main",
1333
+ "&.Mui-selected": {
1334
+ color: o ? "primary.main" : "common.white",
1335
+ backgroundColor: o ? Ae(n.palette.primary.main, 0.25) : "warning.dark",
1336
+ ":hover": {
1337
+ color: o ? "primary.main" : "common.white",
1338
+ backgroundColor: o ? Ae(n.palette.primary.main, 0.2) : "warning.main"
1339
+ }
1340
+ },
1341
+ ":hover": {
1342
+ color: o ? "common.white" : "warning.contrastText",
1343
+ backgroundColor: o ? Ae(n.palette.primary.main, 0.2) : "warning.light"
1344
+ }
1345
+ },
1346
+ value: "flagged",
1347
+ children: /* @__PURE__ */ e(lt, { color: "inherit" })
1348
+ }
1349
+ ) });
1350
+ }, ra = w(aa), ge = (t, r, s, a = !0, n = "inset") => a ? /* @__PURE__ */ m(l.Fragment, { children: [
1351
+ /* @__PURE__ */ m(U, { disableGutters: !0, disablePadding: !0, children: [
1352
+ /* @__PURE__ */ e(q, { children: /* @__PURE__ */ e(j, { sx: { bgcolor: "neutral.light" }, variant: "rounded", children: t }) }),
1353
+ /* @__PURE__ */ e(
1354
+ z,
1355
+ {
1356
+ primary: r,
1357
+ primaryTypographyProps: { variant: "caption" },
1358
+ secondary: s
1359
+ }
1360
+ )
1361
+ ] }),
1362
+ /* @__PURE__ */ e(Te, { variant: n })
1363
+ ] }) : null, na = ({ transaction: t }) => {
1364
+ const { transactions: r } = O(), { tags: s } = R(), a = l.useMemo(() => {
1365
+ const n = new Map(s.map((o) => [o.guid, o.name]));
1366
+ return t.tags.map((o) => n.get(o)).filter(Boolean).join(" / ");
1367
+ }, [s, t.tags]);
1368
+ return /* @__PURE__ */ m(be, { sx: { "& .MuiListItem-root": { px: 24, py: 12 } }, children: [
1369
+ ge(
1370
+ /* @__PURE__ */ e(
1371
+ Oe,
1372
+ {
1373
+ categoryGuid: t.top_level_category_guid,
1374
+ size: 24,
1375
+ sx: { color: "text.primary" },
1376
+ variant: Ge.Transparent
1377
+ }
1378
+ ),
1379
+ r.category_title,
1380
+ /* @__PURE__ */ e(A, { bold: !0, variant: "body1", children: t.category ?? r.actions_select_a_category })
1381
+ ),
1382
+ ge(
1383
+ /* @__PURE__ */ e(ye, { name: "calendar_month", sx: { color: "text.primary" } }),
1384
+ r.date_title,
1385
+ /* @__PURE__ */ e(A, { bold: !0, variant: "body1", children: Me(ve(t.date), Re.YEAR_MONTH_DAY) })
1386
+ ),
1387
+ ge(
1388
+ /* @__PURE__ */ e(ye, { name: "article", sx: { color: "text.primary" } }),
1389
+ r.memo_title,
1390
+ /* @__PURE__ */ e(A, { bold: !0, sx: { overflowWrap: "break-word", whiteSpace: "wrap" }, variant: "body1", children: t.memo ?? r.memo_desc }),
1391
+ !!t.memo,
1392
+ t.tags?.length > 0 ? "inset" : "fullWidth"
1393
+ ),
1394
+ ge(
1395
+ /* @__PURE__ */ e(ye, { name: "local_offer", sx: { color: "text.primary" } }),
1396
+ r.tags_title,
1397
+ /* @__PURE__ */ e(A, { bold: !0, variant: "body1", children: t.tags?.length ? a : r.tags_desc }),
1398
+ !!t.tags?.length,
1399
+ "fullWidth"
1400
+ )
1401
+ ] });
1402
+ }, oa = w(na), ia = ({
1403
+ data: t,
1404
+ color: r,
1405
+ width: s = 85,
1406
+ height: a = 65
1407
+ }) => {
1408
+ const n = H(), o = {
1409
+ series: [
1410
+ {
1411
+ data: t.map(({ value: c }) => c),
1412
+ type: "bar"
1413
+ }
1414
+ ],
1415
+ xAxis: [
1416
+ {
1417
+ data: t.map(({ label: c }) => c),
1418
+ scaleType: "band",
1419
+ categoryGapRatio: 0.3
1420
+ }
1421
+ ]
1422
+ }, i = t.map(
1423
+ (c, d) => d === t.length - 1 ? r(n) : `${r(n)}80`
1424
+ ), _ = (c, d) => {
1425
+ if (c <= 0 || d <= 0) return "";
1426
+ const u = Math.min(6, c / 2, d / 2);
1427
+ return `M${u},0 L${c - u},0 Q${c},0 ${c},${u} L${c},${d} L0,${d} L0,${u} Q0,0 ${u},0 Z`;
1428
+ };
1429
+ return /* @__PURE__ */ e(
1430
+ L,
1431
+ {
1432
+ sx: {
1433
+ width: s,
1434
+ height: a
1435
+ },
1436
+ children: /* @__PURE__ */ e(
1437
+ ct,
1438
+ {
1439
+ axisHighlight: {
1440
+ x: "none",
1441
+ y: "none"
1442
+ },
1443
+ height: a,
1444
+ margin: {
1445
+ bottom: -10,
1446
+ left: 0,
1447
+ right: 0,
1448
+ top: 10
1449
+ },
1450
+ series: o.series,
1451
+ slots: {
1452
+ bar: ({ ownerState: c, ...d }) => {
1453
+ const { ariaLabel: u } = t[c.dataIndex];
1454
+ return /* @__PURE__ */ e("g", { "aria-label": u, children: /* @__PURE__ */ e(
1455
+ "path",
1456
+ {
1457
+ d: _(d.width, d.height),
1458
+ fill: i[c.dataIndex],
1459
+ transform: `translate(${d.x}, ${d.y})`
1460
+ }
1461
+ ) });
1462
+ },
1463
+ axisTickLabel: ({ text: c, ...d }) => {
1464
+ const u = t[t.length - 1]?.label;
1465
+ return /* @__PURE__ */ e(
1466
+ "text",
1467
+ {
1468
+ ...d,
1469
+ style: {
1470
+ ...d.style,
1471
+ fontSize: 6.75,
1472
+ lineHeight: "9px",
1473
+ fontWeight: u === c ? "bold" : 400
1474
+ },
1475
+ children: c
1476
+ }
1477
+ );
1478
+ }
1479
+ },
1480
+ sx: {
1481
+ "& .MuiChartsAxis-bottom .MuiChartsAxis-tickContainer:first-of-type .MuiChartsAxis-tick": {
1482
+ display: "none"
1483
+ }
1484
+ },
1485
+ width: s,
1486
+ xAxis: o.xAxis,
1487
+ yAxis: [{ width: 0, position: "none" }]
1488
+ }
1489
+ )
1490
+ }
1491
+ );
1492
+ }, sa = {
1493
+ BILL_AMOUNT_NOT_STANDARD: "BillAmountNotStandard"
1494
+ }, la = (t, r) => {
1495
+ if (r)
1496
+ switch (r.template) {
1497
+ case sa.BILL_AMOUNT_NOT_STANDARD: {
1498
+ const s = r.data_series ? mt(r.data_series) : [], a = _t(s, r.payload?.merchant_name);
1499
+ return {
1500
+ instanceSlot: /* @__PURE__ */ e(
1501
+ ia,
1502
+ {
1503
+ color: (n) => n.palette.categories.billsUtilities,
1504
+ data: a.slice(-3)
1505
+ }
1506
+ ),
1507
+ dataSeries: s,
1508
+ chartData: a,
1509
+ callToAction: t.view_history
1510
+ };
1511
+ }
1512
+ default:
1513
+ return null;
1514
+ }
1515
+ return null;
1516
+ }, ca = ({
1517
+ bottomActions: t = xt,
1518
+ canFlagTransaction: r = !0,
1519
+ topActions: s = St,
1520
+ transaction: a
1521
+ }) => {
1522
+ const { onEvent: n } = G(), { isCopyLoaded: o } = rt(), { userFeatures: i } = nt(), { accounts: _, common: c, insights_feed: d } = O(), { detailedCategories: u } = we(), {
1523
+ alert: p,
1524
+ associatedBeats: g,
1525
+ detailedTransactions: h,
1526
+ cachedStartDate: I,
1527
+ loadEmbeddedInstanceTransactions: M,
1528
+ setAlert: B
1529
+ } = R(), [k, f] = l.useState(!1), [x, y] = l.useState(!1), [Z, se] = l.useState(!1), le = H(), te = a?.number && a.number.length > 4, $ = l.useMemo(() => g.find((T) => T.associated_transaction_guid === a.guid), [g, a]), b = la(c, $), [K, ne] = l.useState(
1530
+ b ? b.dataSeries.length - 1 : 0
1531
+ );
1532
+ l.useEffect(
1533
+ () => n(Y.TRANSACTION_DETAILS_VIEW, { transaction_guid: a.guid }),
1534
+ []
1535
+ ), l.useEffect(() => {
1536
+ if (!b || b.dataSeries.length === 0) return;
1537
+ const { date: T } = b.dataSeries[K], D = De(T);
1538
+ je(D, I) && (y(!0), M(D).finally(() => {
1539
+ y(!1);
1540
+ }));
1541
+ }, [K, b, I]);
1542
+ const F = t.includes(ie.MerchantBudget) && !a?.merchant_guid ? t.filter((T) => T !== ie.MerchantBudget) : t, oe = ke(() => {
1543
+ if (b) {
1544
+ const T = u.find(
1545
+ (Ue) => Ue.guid === a.top_level_category_guid
1546
+ ), D = $?.payload?.average_amount ?? 0, J = a.amount;
1547
+ let pe = d.general.increased_text;
1548
+ J - D < 0 && (pe = d.general.decreased_text);
1549
+ const ce = D === 0 ? 0 : Math.round(Math.abs(J - D) / D * 100);
1550
+ return { category: T, percentageAmount: ce, changetype: pe };
1551
+ }
1552
+ return null;
1553
+ }, [b, u]), N = ke(() => {
1554
+ if (!b?.dataSeries?.length)
1555
+ return [];
1556
+ const { guid: T, date: D } = b.dataSeries[K], J = De(D), pe = Be(D);
1557
+ return h.filter((ce) => ce.date >= Ie(J) && ce.date <= Ie(pe) && ce.guid === T);
1558
+ }, [K, b, h, x]);
1559
+ if (!o)
1560
+ return /* @__PURE__ */ e(ht, {});
1561
+ const v = Je(i, "MX_TXN_DETAILS_VIEW_ONLY"), S = le.palette.mode === "dark" ? "grey.800" : "grey.100";
1562
+ return /* @__PURE__ */ m(W, { className: "mx-txn-transaction-details", width: "100%", children: [
1563
+ a && /* @__PURE__ */ m(L, { children: [
1564
+ /* @__PURE__ */ m(L, { gap: 12, p: 24, children: [
1565
+ /* @__PURE__ */ e(he, { elevation: 2, sx: { width: 64 }, children: /* @__PURE__ */ e(
1566
+ Ce,
1567
+ {
1568
+ categoryGuid: a.top_level_category_guid || "",
1569
+ merchantGuid: a.merchant_guid || "",
1570
+ size: 64
1571
+ }
1572
+ ) }),
1573
+ /* @__PURE__ */ e(ta, { transaction: a, viewOnly: v }),
1574
+ /* @__PURE__ */ m(L, { direction: "row", justifyContent: "space-between", sx: { minHeight: 44 }, children: [
1575
+ /* @__PURE__ */ m(ee, { color: a.isIncome ? "success.main" : "text.primary", variant: "h1", children: [
1576
+ a.isIncome ? "+" : "",
1577
+ V(a.amount, "0,0.00")
1578
+ ] }),
1579
+ !v && r && /* @__PURE__ */ e(ra, { transaction: a })
1580
+ ] }),
1581
+ b?.instanceSlot && /* @__PURE__ */ e(
1582
+ pt,
1583
+ {
1584
+ callToAction: b.callToAction,
1585
+ description: E(
1586
+ d.general.embedded_description,
1587
+ oe.changetype,
1588
+ /* @__PURE__ */ e("strong", { children: oe.percentageAmount })
1589
+ ),
1590
+ instanceSlot: b.instanceSlot,
1591
+ onCtaClick: () => {
1592
+ f(!0);
1593
+ },
1594
+ title: $.html_micro_title
1595
+ }
1596
+ ),
1597
+ /* @__PURE__ */ m(L, { sx: { bgcolor: S, borderRadius: "4px", gap: 4, p: 8 }, children: [
1598
+ /* @__PURE__ */ e(A, { bold: !0, children: `${a.account}
1599
+ ${te ? a.number : "•".repeat(4).concat(a.number ?? "")}` }),
1600
+ /* @__PURE__ */ e(A, { bold: !0, variant: "tiny", children: a.feed_description })
1601
+ ] })
1602
+ ] }),
1603
+ /* @__PURE__ */ e(he, { square: !0, sx: { boxShadow: "none" }, children: v ? /* @__PURE__ */ e(oa, { transaction: a }) : /* @__PURE__ */ e(be, { children: s.map((T, D) => /* @__PURE__ */ m(l.Fragment, { children: [
1604
+ T === de.Category && /* @__PURE__ */ e(vt, { transaction: a }),
1605
+ T === de.Date && /* @__PURE__ */ e(Et, { transaction: a }),
1606
+ T === de.Memo && /* @__PURE__ */ e(Gt, { transaction: a }),
1607
+ T === de.Tags && /* @__PURE__ */ e(Jt, { transaction: a }),
1608
+ /* @__PURE__ */ e(
1609
+ Te,
1610
+ {
1611
+ component: "li",
1612
+ variant: D < s.length - 1 ? "inset" : "fullWidth"
1613
+ }
1614
+ )
1615
+ ] }, T)) }) }),
1616
+ !v && F.length > 0 && /* @__PURE__ */ m(l.Fragment, { children: [
1617
+ /* @__PURE__ */ e(A, { bold: !0, mb: 8, ml: 26, mt: 16, variant: "body1", children: _.actions }),
1618
+ /* @__PURE__ */ e(he, { square: !0, sx: { boxShadow: "none" }, children: /* @__PURE__ */ m(be, { children: [
1619
+ F.map((T, D) => /* @__PURE__ */ m(l.Fragment, { children: [
1620
+ T === ie.MerchantBudget && /* @__PURE__ */ e(Dt, { transaction: a }),
1621
+ T === ie.SplitTransaction && /* @__PURE__ */ e(Ut, { transaction: a }),
1622
+ T === ie.HideTransaction && /* @__PURE__ */ e(kt, { transaction: a }),
1623
+ T === ie.MerchantLogo && /* @__PURE__ */ e(Mt, { transaction: a }),
1624
+ /* @__PURE__ */ e(
1625
+ Te,
1626
+ {
1627
+ component: "li",
1628
+ variant: D < F.length - 1 ? "inset" : "fullWidth"
1629
+ }
1630
+ )
1631
+ ] }, T)),
1632
+ a.is_manual && !a.parent_guid && !a.has_been_split && /* @__PURE__ */ e(Lt, { transaction: a })
1633
+ ] }) })
1634
+ ] })
1635
+ ] }),
1636
+ $ && b && /* @__PURE__ */ e(
1637
+ gt,
1638
+ {
1639
+ ariaLabel: Me(
1640
+ b?.dataSeries[K]?.date,
1641
+ Re.MONTH
1642
+ ),
1643
+ barChartProps: {
1644
+ amounts: {
1645
+ average: $.payload.average_amount,
1646
+ formattedAverage: V($.payload.average_amount, "0,0")
1647
+ },
1648
+ color: oe.category?.color || "",
1649
+ data: b.chartData,
1650
+ margin: { bottom: 10, left: 24, right: 24, top: 20 },
1651
+ monthlyAmountLabel: d.general.monthly_amount,
1652
+ onBarClick: (T) => {
1653
+ ne(T);
1654
+ },
1655
+ trendAmountLabel: d.general.trend,
1656
+ legendPosition: "top"
1657
+ },
1658
+ beat: {
1659
+ heading: $.html_title,
1660
+ subHeading: {
1661
+ category_guid: a.category_guid ?? "",
1662
+ merchant_guid: a.merchant_guid ?? "",
1663
+ description: a.description ?? ""
1664
+ }
1665
+ },
1666
+ data: b.chartData,
1667
+ defaultSelectedIndex: K,
1668
+ icon: /* @__PURE__ */ e(
1669
+ Ce,
1670
+ {
1671
+ alt: a.description ?? "",
1672
+ categoryGuid: a.category_guid ?? "",
1673
+ merchantGuid: a.merchant_guid ?? "",
1674
+ size: 16
1675
+ }
1676
+ ),
1677
+ isOpen: k,
1678
+ onClose: () => {
1679
+ f(!1), ne(b.dataSeries.length - 1);
1680
+ },
1681
+ onTabChange: (T) => {
1682
+ ne(T);
1683
+ },
1684
+ tipSection: Z ? void 0 : {
1685
+ message: E(
1686
+ d.general.tip_section_message,
1687
+ /* @__PURE__ */ e("strong", { children: d.general.tip_section_title }),
1688
+ /* @__PURE__ */ e("strong", { children: $.primary_transaction?.description })
1689
+ ),
1690
+ onDismiss: () => se(!0)
1691
+ },
1692
+ title: d.general.transaction_history_title,
1693
+ transactionListProps: {
1694
+ showLoader: x,
1695
+ showInsights: !0,
1696
+ transaction: N
1697
+ }
1698
+ }
1699
+ ),
1700
+ /* @__PURE__ */ e(
1701
+ Ve,
1702
+ {
1703
+ anchorOrigin: { vertical: "bottom", horizontal: "right" },
1704
+ autoHideDuration: 3500,
1705
+ onClose: () => B(""),
1706
+ open: !!p,
1707
+ children: /* @__PURE__ */ e(ze, { closeText: "", onClose: () => B(""), severity: "success", variant: "filled", children: p })
1708
+ }
1709
+ )
1710
+ ] });
1711
+ }, ir = w(ca);
1712
+ export {
1713
+ ie as B,
1714
+ vt as C,
1715
+ Et as D,
1716
+ Gt as M,
1717
+ ir as T,
1718
+ Jt as a,
1719
+ de as b,
1720
+ At as c
1721
+ };