@mx-cartographer/experiences 9.7.129 → 9.7.131

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 (60) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.es.js +44 -43
  3. package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.es.js.map +1 -1
  4. package/dist/insights-v2/actionBlocks/AccountListBlock/layout.es.js +1 -1
  5. package/dist/insights-v2/actionBlocks/AccountListBlock/layout.es.js.map +1 -1
  6. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js +38 -38
  7. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js.map +1 -1
  8. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.d.ts +2 -0
  9. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.es.js +13 -12
  10. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.es.js.map +1 -1
  11. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js +46 -45
  12. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js.map +1 -1
  13. package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/layout.es.js +23 -22
  14. package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/layout.es.js.map +1 -1
  15. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js +26 -25
  16. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js.map +1 -1
  17. package/dist/insights-v2/actionBlocks/HelpBlock/layout.d.ts +0 -1
  18. package/dist/insights-v2/actionBlocks/HelpBlock/layout.es.js +6 -6
  19. package/dist/insights-v2/actionBlocks/HelpBlock/layout.es.js.map +1 -1
  20. package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlock.es.js +74 -104
  21. package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlock.es.js.map +1 -1
  22. package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/layout.d.ts +14 -0
  23. package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/layout.es.js +58 -11
  24. package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/layout.es.js.map +1 -1
  25. package/dist/insights-v2/actionBlocks/OverdraftBlock/layout.es.js +11 -13
  26. package/dist/insights-v2/actionBlocks/OverdraftBlock/layout.es.js.map +1 -1
  27. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.es.js +19 -18
  28. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.es.js.map +1 -1
  29. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +14 -13
  30. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
  31. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js +10 -9
  32. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js.map +1 -1
  33. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.d.ts +0 -3
  34. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js +30 -33
  35. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js.map +1 -1
  36. package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js +31 -30
  37. package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js.map +1 -1
  38. package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js +14 -14
  39. package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/layout.es.js +6 -6
  40. package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/layout.es.js.map +1 -1
  41. package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js +4 -4
  42. package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/layout.es.js +22 -28
  43. package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/layout.es.js.map +1 -1
  44. package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js +4 -4
  45. package/dist/insights-v2/blocks/ComponentBlocks/RepeatingTransactionBlock/RepeatingTransactionBlock.es.js +4 -4
  46. package/dist/insights-v2/blocks/ComponentBlocks/SavingsOpportunityBlock/SavingsOpportunityBlock.es.js +11 -10
  47. package/dist/insights-v2/blocks/ComponentBlocks/SavingsOpportunityBlock/SavingsOpportunityBlock.es.js.map +1 -1
  48. package/dist/insights-v2/blocks/ComponentBlocks/UpcomingSubscriptionBlock/UpcomingSubscriptionBlock.es.js +5 -5
  49. package/dist/insights-v2/blocks/ComponentBlocks/WeeklySmallPurchasesBlock/WeeklySmallPurchasesBlock.es.js +4 -4
  50. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/EmergencySavingsAccountPicker.es.js +1 -1
  51. package/dist/insights-v2/blocks/slotReaders.d.ts +5 -0
  52. package/dist/insights-v2/blocks/slotReaders.es.js +7 -5
  53. package/dist/insights-v2/blocks/slotReaders.es.js.map +1 -1
  54. package/dist/insights-v2/components/celebrationGradients.d.ts +15 -1
  55. package/dist/insights-v2/components/celebrationGradients.es.js +16 -7
  56. package/dist/insights-v2/components/celebrationGradients.es.js.map +1 -1
  57. package/dist/insights-v2/components/shared/elevation.d.ts +2 -0
  58. package/dist/insights-v2/components/shared/elevation.es.js +3 -2
  59. package/dist/insights-v2/components/shared/elevation.es.js.map +1 -1
  60. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [9.7.131] - 11-11-2026
2
+
3
+ - **CHANGED** - Insights V2 code follows its own patterns: the Make Transfer drawer's per-variant settings live in its layout, and a stray shadow, a wash and two tile gradients move into the shared elevation and gradient files; no visual or behaviour change (WEC-2259)
4
+
5
+ ## [9.7.130] - 11-10-2026
6
+
7
+ - **CHANGED** - Insights V2 drops a blank (whitespace-only) payload text value or guid as it already drops an empty one, in the drawers, the Create Budget dialog and the budget analytics event; payload values are read through one shared set of readers (WEC-2259)
8
+
1
9
  ## [9.7.129] - 11-10-2026
2
10
 
3
11
  - **BREAKING** - Monthly Obligations Status drawer and the insights Expense Details match Figma: every recurring expense is its own row (no "Other" fold), a tapped account opens Account Details (the shared account details block) in a nested drawer, and list dividers start under the text; needs the new Account List copy first (publish mrs_content !500 and !505 (Accounts tab label), bump firefly, then release); the exported `AmountBreakdownCard` now has the grey `action.hover` total box and the soft logo elevation shadow (WEC-2115)
@@ -1,62 +1,63 @@
1
- import J from "../../../common/utils/AccountDisplayName.es.js";
2
- import { useAccountStore as K, useAppConfig as M, useCashflowStore as P, useCategoryStore as Q, useGlobalCopyStore as U, useGlobalStore as W, useInsightsV2Store as X, useRecurringTransactionsStore as Y } from "../../../common/context/hooks.es.js";
3
- import { getFrequencyLabel as Z } from "../../../core/utils/RecurringTransactionsUtil.es.js";
4
- import C from "../../../common/components/drawer/Drawer.es.js";
5
- import A from "../../../common/components/Loader.es.js";
6
- import { getDynamicCtaBasedOnTriggers as tt } from "../util.es.js";
7
- import { useRecurringExpensesLoadState as ot } from "../RecurringTransactionBlock/useRecurringTransactionPrepare.es.js";
8
- import { RecurringTransactionBlock as et } from "../RecurringTransactionBlock/RecurringTransactionBlock.es.js";
9
- import { AccountDetailsBlock as nt } from "../AccountDetailsBlock/AccountDetailsBlock.es.js";
10
- import it from "./AccountListContent.es.js";
11
- import { buildSummary as ct, isCheckingAccount as S, resolveBeatAccounts as rt, toAccountSection as G } from "./layout.es.js";
12
- import { useState as T } from "react";
13
- import { observer as st } from "mobx-react-lite";
14
- import at from "@mui/material/Stack";
15
- import { CategoryIcon as ut, Text as lt } from "@mxenabled/mxui";
16
- import { Fragment as mt, jsx as o, jsxs as dt } from "react/jsx-runtime";
17
- var wt = st(function({ beat: n }) {
18
- const [i, l] = T(null), [r, m] = T(null), { copyStore: k } = W(), { accounts: d, common: v, insights_feed: L, recurring: s } = U(), { accountsLoaded: b, cashAccounts: x, visibleAccounts: p } = K(), { actionDrawer: D } = X(), { uiStore: w } = P(), { getTopLevelCategoryGuid: R } = Q(), { detailedRepeatingTransactions: B } = Y(), { config: E } = M(), { failed: g, ready: f, retry: F } = ot(), e = L?.account_list;
19
- if (!k.isInitialized) return /* @__PURE__ */ o(A, {});
20
- if (!e) return /* @__PURE__ */ o(at, {
1
+ import H from "../../../common/utils/AccountDisplayName.es.js";
2
+ import { useAccountStore as J, useAppConfig as K, useCashflowStore as M, useGlobalCopyStore as P, useGlobalStore as Q, useInsightsV2Store as U, useRecurringTransactionsStore as W } from "../../../common/context/hooks.es.js";
3
+ import { getFrequencyLabel as X } from "../../../core/utils/RecurringTransactionsUtil.es.js";
4
+ import A from "../../../common/components/drawer/Drawer.es.js";
5
+ import C from "../../../common/components/Loader.es.js";
6
+ import Y from "../../components/CategoryTile.es.js";
7
+ import { getDynamicCtaBasedOnTriggers as Z } from "../util.es.js";
8
+ import { useRecurringExpensesLoadState as tt } from "../RecurringTransactionBlock/useRecurringTransactionPrepare.es.js";
9
+ import { RecurringTransactionBlock as ot } from "../RecurringTransactionBlock/RecurringTransactionBlock.es.js";
10
+ import { AccountDetailsBlock as et } from "../AccountDetailsBlock/AccountDetailsBlock.es.js";
11
+ import nt from "./AccountListContent.es.js";
12
+ import { buildSummary as it, isCheckingAccount as S, resolveBeatAccounts as ct, toAccountSection as T } from "./layout.es.js";
13
+ import { useState as G } from "react";
14
+ import { observer as rt } from "mobx-react-lite";
15
+ import st from "@mui/material/Stack";
16
+ import { Text as at } from "@mxenabled/mxui";
17
+ import { Fragment as ut, jsx as o, jsxs as lt } from "react/jsx-runtime";
18
+ var Dt = rt(function({ beat: n }) {
19
+ const [i, l] = G(null), [r, m] = G(null), { copyStore: k } = Q(), { accounts: p, common: v, insights_feed: L, recurring: s } = P(), { accountsLoaded: b, cashAccounts: x, visibleAccounts: d } = J(), { actionDrawer: D } = U(), { uiStore: w } = M(), { detailedRepeatingTransactions: R } = W(), { config: B } = K(), { failed: g, ready: f, retry: E } = tt(), e = L?.account_list;
20
+ if (!k.isInitialized) return /* @__PURE__ */ o(C, {});
21
+ if (!e) return /* @__PURE__ */ o(st, {
21
22
  sx: { p: 24 },
22
- children: /* @__PURE__ */ o(lt, { children: v?.error_message ?? "Something went wrong." })
23
+ children: /* @__PURE__ */ o(at, { children: v?.error_message ?? "Something went wrong." })
23
24
  });
24
- if (!b) return /* @__PURE__ */ o(A, {});
25
- const { primary_cta: I, secondary_cta: $, in_description_cta: N } = n.insights_payload ?? {}, O = tt(D, I, $, N), y = rt(n, p, x), j = y.filter(S), q = y.filter((t) => !S(t)), a = E.display_available_balance_in_accounts, z = [G("checking", e.checking, j, a), G("savings", e.savings, q, a)].filter((t) => t.rows.length > 0), V = f ? [...w.expensesTilNextIncome].sort((t, c) => c.amount - t.amount).map((t) => {
26
- const c = p.find(({ guid: u }) => u === t.accountGuid), h = B.find(({ guid: u }) => u === t.repeatingTransactionGuid);
25
+ if (!b) return /* @__PURE__ */ o(C, {});
26
+ const { primary_cta: F, secondary_cta: $, in_description_cta: I } = n.insights_payload ?? {}, N = Z(D, F, $, I), y = ct(n, d, x), O = y.filter(S), j = y.filter((t) => !S(t)), a = B.display_available_balance_in_accounts, q = [T("checking", e.checking, O, a), T("savings", e.savings, j, a)].filter((t) => t.rows.length > 0), z = f ? [...w.expensesTilNextIncome].sort((t, c) => c.amount - t.amount).map((t) => {
27
+ const c = d.find(({ guid: u }) => u === t.accountGuid), h = R.find(({ guid: u }) => u === t.repeatingTransactionGuid);
27
28
  return {
28
29
  account: {
29
30
  institutionGuid: t.institutionGuid,
30
- name: c ? J(c) : t.institutionName
31
+ name: c ? H(c) : t.institutionName
31
32
  },
32
33
  amount: t.amount,
33
- frequency: h && Z(s, h, !1),
34
+ frequency: h && X(s, h, !1),
34
35
  key: `${t.repeatingTransactionGuid}-${t.expectedDate.getTime()}`,
35
- leading: /* @__PURE__ */ o(ut, {
36
- categoryGuid: R(t.categoryGuid),
36
+ leading: /* @__PURE__ */ o(Y, {
37
+ categoryGuid: t.categoryGuid,
37
38
  size: 32
38
39
  }),
39
40
  name: t.name,
40
41
  onClick: () => l(t)
41
42
  };
42
- }) : [], _ = () => l(null), H = () => m(null);
43
- return /* @__PURE__ */ dt(mt, { children: [
44
- /* @__PURE__ */ o(it, {
43
+ }) : [], _ = () => l(null), V = () => m(null);
44
+ return /* @__PURE__ */ lt(ut, { children: [
45
+ /* @__PURE__ */ o(nt, {
45
46
  copy: e,
46
- expenses: V,
47
+ expenses: z,
47
48
  expensesLoading: !f && !g,
48
49
  onAccountClick: m,
49
- onRetryExpenses: g ? F : void 0,
50
- sections: z,
50
+ onRetryExpenses: g ? E : void 0,
51
+ sections: q,
51
52
  showAvailable: a,
52
- summary: ct(O, e)
53
+ summary: it(N, e)
53
54
  }),
54
- /* @__PURE__ */ o(C, {
55
+ /* @__PURE__ */ o(A, {
55
56
  ariaLabelClose: s.close_drawer_aria,
56
57
  isOpen: i !== null,
57
58
  onClose: _,
58
59
  title: s.expense_details,
59
- children: i && /* @__PURE__ */ o(et, {
60
+ children: i && /* @__PURE__ */ o(ot, {
60
61
  beat: n,
61
62
  layout: "insights",
62
63
  onDeleted: _,
@@ -64,12 +65,12 @@ var wt = st(function({ beat: n }) {
64
65
  selectedRecurrence: i
65
66
  })
66
67
  }),
67
- /* @__PURE__ */ o(C, {
68
- ariaLabelClose: d?.close_account_details_aria,
68
+ /* @__PURE__ */ o(A, {
69
+ ariaLabelClose: p?.close_account_details_aria,
69
70
  isOpen: r !== null,
70
- onClose: H,
71
- title: d?.account_details,
72
- children: r && /* @__PURE__ */ o(nt, { beat: {
71
+ onClose: V,
72
+ title: p?.account_details,
73
+ children: r && /* @__PURE__ */ o(et, { beat: {
73
74
  ...n,
74
75
  primary_account: void 0,
75
76
  primary_account_guid: r
@@ -78,7 +79,7 @@ var wt = st(function({ beat: n }) {
78
79
  ] });
79
80
  });
80
81
  export {
81
- wt as AccountListBlock
82
+ Dt as AccountListBlock
82
83
  };
83
84
 
84
85
  //# sourceMappingURL=AccountListBlock.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AccountListBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.tsx"],"sourcesContent":["import { useState } from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport { CategoryIcon, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n Drawer,\n Loader,\n useAccountStore,\n useAppConfig,\n useCashflowStore,\n useCategoryStore,\n useGlobalCopyStore,\n useGlobalStore,\n useInsightsV2Store,\n useRecurringTransactionsStore,\n} from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport type { Recurrence } from '../../../core'\nimport { getFrequencyLabel } from '../../../core/utils/RecurringTransactionsUtil'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { AccountDetailsBlock } from '../AccountDetailsBlock'\nimport {\n RecurringTransactionBlock,\n useRecurringExpensesLoadState,\n} from '../RecurringTransactionBlock'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\n\nimport AccountListContent, { type ExpenseRow } from './AccountListContent'\nimport { buildSummary, isCheckingAccount, resolveBeatAccounts, toAccountSection } from './layout'\n\n/**\n * Account List drawer: the CTA's calculation, then Accounts and Recurring Expenses tabs.\n * A tapped expense opens its Expense Details, and a tapped account its Account Details (the shared\n * AccountDetailsBlock), each in a nested drawer.\n */\nexport const AccountListBlock = observer(function AccountListBlock({ beat }: ActionBlockProps) {\n const [tappedExpense, setTappedExpense] = useState<Recurrence | null>(null)\n const [tappedAccountGuid, setTappedAccountGuid] = useState<string | null>(null)\n const { copyStore } = useGlobalStore()\n const {\n accounts: accountsCopy,\n common: commonCopy,\n insights_feed: insightsFeedCopy,\n recurring: recurringCopy,\n } = useGlobalCopyStore()\n const { accountsLoaded, cashAccounts, visibleAccounts } = useAccountStore()\n const { actionDrawer } = useInsightsV2Store()\n const { uiStore } = useCashflowStore()\n const { getTopLevelCategoryGuid } = useCategoryStore()\n const { detailedRepeatingTransactions } = useRecurringTransactionsStore()\n const { config } = useAppConfig()\n const { failed: expensesFailed, ready: expensesReady, retry } = useRecurringExpensesLoadState()\n const copy = insightsFeedCopy?.account_list\n\n if (!copyStore.isInitialized) return <Loader />\n\n // Copy loads once at app start, so a retry cannot clear a missing namespace: a plain message.\n if (!copy) {\n return (\n <Stack sx={{ p: 24 }}>\n <Text>{commonCopy?.error_message ?? 'Something went wrong.'}</Text>\n </Stack>\n )\n }\n\n if (!accountsLoaded) return <Loader />\n\n const { primary_cta, secondary_cta, in_description_cta } = beat.insights_payload ?? {}\n const cta = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n primary_cta,\n secondary_cta,\n in_description_cta,\n )\n\n const listed = resolveBeatAccounts(beat, visibleAccounts, cashAccounts)\n const checking = listed.filter(isCheckingAccount)\n const savings = listed.filter((account) => !isCheckingAccount(account))\n const showAvailable = config.display_available_balance_in_accounts\n const sections = [\n toAccountSection('checking', copy.checking, checking, showAvailable),\n toAccountSection('savings', copy.savings, savings, showAvailable),\n ].filter((section) => section.rows.length > 0)\n\n // Every upcoming expense as its own row, largest first (Figma); no \"Other\" fold, so each opens its details.\n const expenses: ExpenseRow[] = expensesReady\n ? [...uiStore.expensesTilNextIncome]\n .sort((a, b) => b.amount - a.amount)\n .map((expense) => {\n const account = visibleAccounts.find(({ guid }) => guid === expense.accountGuid)\n const repeating = detailedRepeatingTransactions.find(\n ({ guid }) => guid === expense.repeatingTransactionGuid,\n )\n\n return {\n account: {\n institutionGuid: expense.institutionGuid,\n name: account ? getAccountDisplayName(account) : expense.institutionName,\n },\n amount: expense.amount,\n frequency: repeating && getFrequencyLabel(recurringCopy, repeating, false),\n key: `${expense.repeatingTransactionGuid}-${expense.expectedDate.getTime()}`,\n leading: (\n <CategoryIcon\n categoryGuid={getTopLevelCategoryGuid(expense.categoryGuid)}\n size={32}\n />\n ),\n name: expense.name,\n onClick: () => setTappedExpense(expense),\n }\n })\n : []\n\n const closeExpenseDetails = () => setTappedExpense(null)\n const closeAccountDetails = () => setTappedAccountGuid(null)\n\n return (\n <>\n <AccountListContent\n copy={copy}\n expenses={expenses}\n expensesLoading={!expensesReady && !expensesFailed}\n onAccountClick={setTappedAccountGuid}\n onRetryExpenses={expensesFailed ? retry : undefined}\n sections={sections}\n showAvailable={showAvailable}\n summary={buildSummary(cta, copy)}\n />\n <Drawer\n ariaLabelClose={recurringCopy.close_drawer_aria}\n isOpen={tappedExpense !== null}\n onClose={closeExpenseDetails}\n title={recurringCopy.expense_details}\n >\n {tappedExpense && (\n <RecurringTransactionBlock\n beat={beat}\n layout=\"insights\"\n onDeleted={closeExpenseDetails}\n repeatingTransactionGuid={tappedExpense.repeatingTransactionGuid}\n selectedRecurrence={tappedExpense}\n />\n )}\n </Drawer>\n <Drawer\n ariaLabelClose={accountsCopy?.close_account_details_aria}\n isOpen={tappedAccountGuid !== null}\n onClose={closeAccountDetails}\n title={accountsCopy?.account_details}\n >\n {tappedAccountGuid && (\n // The shared block shows the beat's account, so hand it the tapped one instead.\n <AccountDetailsBlock\n beat={{ ...beat, primary_account: undefined, primary_account_guid: tappedAccountGuid }}\n />\n )}\n </Drawer>\n </>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAsCA,IAAa,KAAmB,GAAS,SAA0B,EAAE,MAAA,EAAA,GAA0B;AAC7F,QAAM,CAAC,GAAe,CAAA,IAAoB,EAA4B,IAAI,GACpE,CAAC,GAAmB,CAAA,IAAwB,EAAwB,IAAI,GACxE,EAAE,WAAA,EAAA,IAAc,EAAe,GAC/B,EACJ,UAAU,GACV,QAAQ,GACR,eAAe,GACf,WAAW,EAAA,IACT,EAAmB,GACjB,EAAE,gBAAA,GAAgB,cAAA,GAAc,iBAAA,EAAA,IAAoB,EAAgB,GACpE,EAAE,cAAA,EAAA,IAAiB,EAAmB,GACtC,EAAE,SA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AsB;AAAA,MAC9B,SAAS;AAAA,MACT,OAAO,GAAc;AAAA,MAEpB,UAAA,KAEC,gBAAA,EAAC,IAAD,EACE,MAAM;AAAA,QAAE,GAAG;AAAA,QAAM,iBAAiB;AAAA,QAAW,sBAAsB;AAAA,MAAkB,EACtF,CAAA;AAAA,IAEG,CAAA;AAAA,EACR,EAAA,CAAA;AAEN,CAAC"}
1
+ {"version":3,"file":"AccountListBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.tsx"],"sourcesContent":["import { useState } from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n Drawer,\n Loader,\n useAccountStore,\n useAppConfig,\n useCashflowStore,\n useGlobalCopyStore,\n useGlobalStore,\n useInsightsV2Store,\n useRecurringTransactionsStore,\n} from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport type { Recurrence } from '../../../core'\nimport { getFrequencyLabel } from '../../../core/utils/RecurringTransactionsUtil'\nimport CategoryTile from '../../components/CategoryTile'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { AccountDetailsBlock } from '../AccountDetailsBlock'\nimport {\n RecurringTransactionBlock,\n useRecurringExpensesLoadState,\n} from '../RecurringTransactionBlock'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\n\nimport AccountListContent, { type ExpenseRow } from './AccountListContent'\nimport { buildSummary, isCheckingAccount, resolveBeatAccounts, toAccountSection } from './layout'\n\n/**\n * Account List drawer: the CTA's calculation, then Accounts and Recurring Expenses tabs.\n * A tapped expense opens its Expense Details, and a tapped account its Account Details (the shared\n * AccountDetailsBlock), each in a nested drawer.\n */\nexport const AccountListBlock = observer(function AccountListBlock({ beat }: ActionBlockProps) {\n const [tappedExpense, setTappedExpense] = useState<Recurrence | null>(null)\n const [tappedAccountGuid, setTappedAccountGuid] = useState<string | null>(null)\n const { copyStore } = useGlobalStore()\n const {\n accounts: accountsCopy,\n common: commonCopy,\n insights_feed: insightsFeedCopy,\n recurring: recurringCopy,\n } = useGlobalCopyStore()\n const { accountsLoaded, cashAccounts, visibleAccounts } = useAccountStore()\n const { actionDrawer } = useInsightsV2Store()\n const { uiStore } = useCashflowStore()\n const { detailedRepeatingTransactions } = useRecurringTransactionsStore()\n const { config } = useAppConfig()\n const { failed: expensesFailed, ready: expensesReady, retry } = useRecurringExpensesLoadState()\n const copy = insightsFeedCopy?.account_list\n\n if (!copyStore.isInitialized) return <Loader />\n\n // Copy loads once at app start, so a retry cannot clear a missing namespace: a plain message.\n if (!copy) {\n return (\n <Stack sx={{ p: 24 }}>\n <Text>{commonCopy?.error_message ?? 'Something went wrong.'}</Text>\n </Stack>\n )\n }\n\n if (!accountsLoaded) return <Loader />\n\n const { primary_cta, secondary_cta, in_description_cta } = beat.insights_payload ?? {}\n const cta = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n primary_cta,\n secondary_cta,\n in_description_cta,\n )\n\n const listed = resolveBeatAccounts(beat, visibleAccounts, cashAccounts)\n const checking = listed.filter(isCheckingAccount)\n const savings = listed.filter((account) => !isCheckingAccount(account))\n const showAvailable = config.display_available_balance_in_accounts\n const sections = [\n toAccountSection('checking', copy.checking, checking, showAvailable),\n toAccountSection('savings', copy.savings, savings, showAvailable),\n ].filter((section) => section.rows.length > 0)\n\n // Every upcoming expense as its own row, largest first (Figma); no \"Other\" fold, so each opens its details.\n const expenses: ExpenseRow[] = expensesReady\n ? [...uiStore.expensesTilNextIncome]\n .sort((a, b) => b.amount - a.amount)\n .map((expense) => {\n const account = visibleAccounts.find(({ guid }) => guid === expense.accountGuid)\n const repeating = detailedRepeatingTransactions.find(\n ({ guid }) => guid === expense.repeatingTransactionGuid,\n )\n\n return {\n account: {\n institutionGuid: expense.institutionGuid,\n name: account ? getAccountDisplayName(account) : expense.institutionName,\n },\n amount: expense.amount,\n frequency: repeating && getFrequencyLabel(recurringCopy, repeating, false),\n key: `${expense.repeatingTransactionGuid}-${expense.expectedDate.getTime()}`,\n leading: <CategoryTile categoryGuid={expense.categoryGuid} size={32} />,\n name: expense.name,\n onClick: () => setTappedExpense(expense),\n }\n })\n : []\n\n const closeExpenseDetails = () => setTappedExpense(null)\n const closeAccountDetails = () => setTappedAccountGuid(null)\n\n return (\n <>\n <AccountListContent\n copy={copy}\n expenses={expenses}\n expensesLoading={!expensesReady && !expensesFailed}\n onAccountClick={setTappedAccountGuid}\n onRetryExpenses={expensesFailed ? retry : undefined}\n sections={sections}\n showAvailable={showAvailable}\n summary={buildSummary(cta, copy)}\n />\n <Drawer\n ariaLabelClose={recurringCopy.close_drawer_aria}\n isOpen={tappedExpense !== null}\n onClose={closeExpenseDetails}\n title={recurringCopy.expense_details}\n >\n {tappedExpense && (\n <RecurringTransactionBlock\n beat={beat}\n layout=\"insights\"\n onDeleted={closeExpenseDetails}\n repeatingTransactionGuid={tappedExpense.repeatingTransactionGuid}\n selectedRecurrence={tappedExpense}\n />\n )}\n </Drawer>\n <Drawer\n ariaLabelClose={accountsCopy?.close_account_details_aria}\n isOpen={tappedAccountGuid !== null}\n onClose={closeAccountDetails}\n title={accountsCopy?.account_details}\n >\n {tappedAccountGuid && (\n // The shared block shows the beat's account, so hand it the tapped one instead.\n <AccountDetailsBlock\n beat={{ ...beat, primary_account: undefined, primary_account_guid: tappedAccountGuid }}\n />\n )}\n </Drawer>\n </>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;AAsCA,IAAa,KAAmB,GAAS,SAA0B,EAAE,MAAA,EAAA,GAA0B;AAC7F,QAAM,CAAC,GAAe,CAAA,IAAoB,EAA4B,IAAI,GACpE,CAAC,GAAmB,CAAA,IAAwB,EAAwB,IAAI,GACxE,EAAE,WAAA,EAAA,IAAc,EAAe,GAC/B,EACJ,UAAU,GACV,QAAQ,GACR,eAAe,GACf,WAAW,EAAA,IACT,EAAmB,GACjB,EAAE,gBAAA,GAAgB,cAAA,GAAc,iBAAA,EAAA,IAAoB,EA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Q,MAAsB;AAAA,MAC9B,SAAS;AAAA,MACT,OAAO,GAAc;AAAA,MAEpB,UAAA,KAEC,gBAAA,EAAC,IAAD,EACE,MAAM;AAAA,QAAE,GAAG;AAAA,QAAM,iBAAiB;AAAA,QAAW,sBAAsB;AAAA,MAAkB,EACtF,CAAA;AAAA,IAEG,CAAA;AAAA,EACR,EAAA,CAAA;AAEN,CAAC"}
@@ -3,7 +3,7 @@ import m from "../../../common/utils/AccountDisplayName.es.js";
3
3
  import { formatSignedCurrency as l } from "../../../core/utils/NumberFormatting.es.js";
4
4
  import { getAccountStartingBalance as d } from "../../../core/utils/AccountUtils.es.js";
5
5
  import { resolveVariantConfig as g } from "../../blocks/resolveVariantConfig.es.js";
6
- import { finiteNumberOf as s } from "../TransactionHistoryBlock/utils.es.js";
6
+ import { asNumber as s } from "../../blocks/slotReaders.es.js";
7
7
  var c = (a) => a.balance ?? 0, E = (a, e, i) => {
8
8
  const o = new Set(a.account_guids?.length ? a.account_guids : i.map(({ guid: n }) => n));
9
9
  return e.filter((n) => o.has(n.guid)).sort((n, t) => c(t) - c(n));
@@ -1 +1 @@
1
- {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AccountListBlock/layout.ts"],"sourcesContent":["import getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { AccountType, type Account, type Beat, type DrilldownData } from '../../../core'\nimport type { AccountListCopy } from '../../../core/types/localization/InsightsFeedCopy'\nimport { getAccountStartingBalance } from '../../../core/utils/AccountUtils'\nimport { formatSignedCurrency } from '../../../core/utils/NumberFormatting'\nimport { resolveVariantConfig } from '../../blocks/resolveVariantConfig'\nimport { finiteNumberOf } from '../TransactionHistoryBlock/utils'\n\nconst balanceOf = (account: Account) => account.balance ?? 0\n\n/** The beat's `account_guids` among visible accounts (or every cash account when it names none), largest first. */\nexport const resolveBeatAccounts = (\n beat: Beat,\n visibleAccounts: Account[],\n cashAccounts: Account[],\n): Account[] => {\n const guids = new Set<string>(\n beat.account_guids?.length ? beat.account_guids : cashAccounts.map(({ guid }) => guid),\n )\n\n return visibleAccounts\n .filter((account) => guids.has(account.guid))\n .sort((a, b) => balanceOf(b) - balanceOf(a))\n}\n\n/** Checking-family types; every other cash account goes under Savings (Figma has just the two). */\nconst CHECKING_TYPES: ReadonlySet<AccountType> = new Set([\n AccountType.CHECKING,\n AccountType.CHECKING_LINE_OF_CREDIT,\n])\n\nexport const isCheckingAccount = (account: Account): boolean =>\n CHECKING_TYPES.has(account.account_type)\n\nexport interface AccountListRow {\n guid: string\n name: string\n /** Empty when no institution is known: the default logo is shown. */\n institutionGuid: string\n balance: number\n}\n\n/** A group of accounts (Checking or Savings) with its own balance subtotal. */\nexport interface AccountSection {\n key: string\n header: string\n total: number\n /** Already ordered, largest balance first. */\n rows: AccountListRow[]\n}\n\n/** One account as a row, its balance by the host's available-vs-current rule (as RemainingCashBlock). */\nexport const toAccountRow = (account: Account, showAvailable: boolean): AccountListRow => ({\n balance: getAccountStartingBalance(account, showAvailable),\n guid: account.guid,\n institutionGuid: account.institution_guid ?? '',\n name: getAccountDisplayName(account),\n})\n\n/** Rows largest displayed balance first, with the section subtotal. */\nexport const toAccountSection = (\n key: string,\n header: string,\n accounts: Account[],\n showAvailable: boolean,\n): AccountSection => {\n const rows = accounts\n .map((account) => toAccountRow(account, showAvailable))\n .sort((a, b) => b.balance - a.balance)\n\n return { header, key, rows, total: rows.reduce((total, row) => total + row.balance, 0) }\n}\n\n/** A generic breakdown row: a label and its already-formatted display value. */\nexport interface SummaryRow {\n key: string\n label: string\n value: string\n /** The emphasised total row. */\n bold?: boolean\n}\n\n/** The \"How is this calculated?\" breakdown, built per insight so AccountListContent stays generic. */\nexport interface AccountListSummary {\n heading: string\n rows: SummaryRow[]\n}\n\ntype SummaryBuilder = (\n drilldown: DrilldownData | undefined,\n copy: AccountListCopy,\n) => AccountListSummary | undefined\n\n/** Monthly Obligations breakdown; undefined unless all three figures are finite, so the drawer falls back to the list. */\nconst buildMonthlyObligationsSummary: SummaryBuilder = (drilldown, copy) => {\n const availableFunds = finiteNumberOf(drilldown?.available_funds)\n const plannedExpenses = finiteNumberOf(drilldown?.planned_expenses)\n const totalRemaining = finiteNumberOf(drilldown?.total_remaining)\n\n if (\n availableFunds === undefined ||\n plannedExpenses === undefined ||\n totalRemaining === undefined\n ) {\n return undefined\n }\n\n return {\n heading: copy.how_is_this_calculated,\n rows: [\n {\n key: 'available_funds',\n label: copy.available_funds,\n value: formatSignedCurrency(availableFunds),\n },\n // Shown as a deduction (-$1,200.00), per Figma; the figure is stored positive.\n {\n key: 'planned_expenses',\n label: copy.planned_expenses,\n value: formatSignedCurrency(-plannedExpenses),\n },\n {\n bold: true,\n key: 'remaining',\n label: copy.remaining,\n value: formatSignedCurrency(totalRemaining),\n },\n ],\n }\n}\n\nconst SUMMARY_BUILDERS = {\n monthly_obligations: buildMonthlyObligationsSummary,\n} satisfies Record<string, SummaryBuilder>\n\n/** The drawer breakdown for the opening CTA's `variant`; unknown variants warn and fall back. */\nexport const buildSummary = (\n cta: { variant?: string | null; drilldown_data?: DrilldownData } | undefined,\n copy: AccountListCopy,\n): AccountListSummary | undefined =>\n resolveVariantConfig(\n SUMMARY_BUILDERS,\n cta?.variant,\n 'monthly_obligations',\n 'AccountListBlock',\n )(cta?.drilldown_data, copy)\n"],"mappings":";;;;;;AAQA,IAAM,IAAA,CAAa,MAAqB,EAAQ,WAAW,GAG9C,IAAA,CACX,GACA,GACA,MACc;AACd,QAAM,IAAQ,IAAI,IAChB,EAAK,eAAe,SAAS,EAAK,gBAAgB,EAAa,IAAA,CAAK,EAAE,MAAA,EAAA,MAAW,CAAI,CACvF;AAEA,SAAO,EACJ,OAAA,CAAQ,MAAY,EAAM,IAAI,EAAQ,IAAI,CAAC,EAC3C,KAAA,CAAM,GAAG,MAAM,EAAU,CAAC,IAAI,EAAU,CAAC,CAAC;AAC/C,GAGM,IAA2C,oBAAI,IAAI,CACvD,EAAY,UACZ,EAAY,uBACd,CAAC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AgB,CAAI"}
1
+ {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AccountListBlock/layout.ts"],"sourcesContent":["import getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { AccountType, type Account, type Beat, type DrilldownData } from '../../../core'\nimport type { AccountListCopy } from '../../../core/types/localization/InsightsFeedCopy'\nimport { getAccountStartingBalance } from '../../../core/utils/AccountUtils'\nimport { formatSignedCurrency } from '../../../core/utils/NumberFormatting'\nimport { resolveVariantConfig } from '../../blocks/resolveVariantConfig'\nimport { asNumber } from '../../blocks/slotReaders'\n\nconst balanceOf = (account: Account) => account.balance ?? 0\n\n/** The beat's `account_guids` among visible accounts (or every cash account when it names none), largest first. */\nexport const resolveBeatAccounts = (\n beat: Beat,\n visibleAccounts: Account[],\n cashAccounts: Account[],\n): Account[] => {\n const guids = new Set<string>(\n beat.account_guids?.length ? beat.account_guids : cashAccounts.map(({ guid }) => guid),\n )\n\n return visibleAccounts\n .filter((account) => guids.has(account.guid))\n .sort((a, b) => balanceOf(b) - balanceOf(a))\n}\n\n/** Checking-family types; every other cash account goes under Savings (Figma has just the two). */\nconst CHECKING_TYPES: ReadonlySet<AccountType> = new Set([\n AccountType.CHECKING,\n AccountType.CHECKING_LINE_OF_CREDIT,\n])\n\nexport const isCheckingAccount = (account: Account): boolean =>\n CHECKING_TYPES.has(account.account_type)\n\nexport interface AccountListRow {\n guid: string\n name: string\n /** Empty when no institution is known: the default logo is shown. */\n institutionGuid: string\n balance: number\n}\n\n/** A group of accounts (Checking or Savings) with its own balance subtotal. */\nexport interface AccountSection {\n key: string\n header: string\n total: number\n /** Already ordered, largest balance first. */\n rows: AccountListRow[]\n}\n\n/** One account as a row, its balance by the host's available-vs-current rule (as RemainingCashBlock). */\nexport const toAccountRow = (account: Account, showAvailable: boolean): AccountListRow => ({\n balance: getAccountStartingBalance(account, showAvailable),\n guid: account.guid,\n institutionGuid: account.institution_guid ?? '',\n name: getAccountDisplayName(account),\n})\n\n/** Rows largest displayed balance first, with the section subtotal. */\nexport const toAccountSection = (\n key: string,\n header: string,\n accounts: Account[],\n showAvailable: boolean,\n): AccountSection => {\n const rows = accounts\n .map((account) => toAccountRow(account, showAvailable))\n .sort((a, b) => b.balance - a.balance)\n\n return { header, key, rows, total: rows.reduce((total, row) => total + row.balance, 0) }\n}\n\n/** A generic breakdown row: a label and its already-formatted display value. */\nexport interface SummaryRow {\n key: string\n label: string\n value: string\n /** The emphasised total row. */\n bold?: boolean\n}\n\n/** The \"How is this calculated?\" breakdown, built per insight so AccountListContent stays generic. */\nexport interface AccountListSummary {\n heading: string\n rows: SummaryRow[]\n}\n\ntype SummaryBuilder = (\n drilldown: DrilldownData | undefined,\n copy: AccountListCopy,\n) => AccountListSummary | undefined\n\n/** Monthly Obligations breakdown; undefined unless all three figures are finite, so the drawer falls back to the list. */\nconst buildMonthlyObligationsSummary: SummaryBuilder = (drilldown, copy) => {\n const availableFunds = asNumber(drilldown?.available_funds)\n const plannedExpenses = asNumber(drilldown?.planned_expenses)\n const totalRemaining = asNumber(drilldown?.total_remaining)\n\n if (\n availableFunds === undefined ||\n plannedExpenses === undefined ||\n totalRemaining === undefined\n ) {\n return undefined\n }\n\n return {\n heading: copy.how_is_this_calculated,\n rows: [\n {\n key: 'available_funds',\n label: copy.available_funds,\n value: formatSignedCurrency(availableFunds),\n },\n // Shown as a deduction (-$1,200.00), per Figma; the figure is stored positive.\n {\n key: 'planned_expenses',\n label: copy.planned_expenses,\n value: formatSignedCurrency(-plannedExpenses),\n },\n {\n bold: true,\n key: 'remaining',\n label: copy.remaining,\n value: formatSignedCurrency(totalRemaining),\n },\n ],\n }\n}\n\nconst SUMMARY_BUILDERS = {\n monthly_obligations: buildMonthlyObligationsSummary,\n} satisfies Record<string, SummaryBuilder>\n\n/** The drawer breakdown for the opening CTA's `variant`; unknown variants warn and fall back. */\nexport const buildSummary = (\n cta: { variant?: string | null; drilldown_data?: DrilldownData } | undefined,\n copy: AccountListCopy,\n): AccountListSummary | undefined =>\n resolveVariantConfig(\n SUMMARY_BUILDERS,\n cta?.variant,\n 'monthly_obligations',\n 'AccountListBlock',\n )(cta?.drilldown_data, copy)\n"],"mappings":";;;;;;AAQA,IAAM,IAAA,CAAa,MAAqB,EAAQ,WAAW,GAG9C,IAAA,CACX,GACA,GACA,MACc;AACd,QAAM,IAAQ,IAAI,IAChB,EAAK,eAAe,SAAS,EAAK,gBAAgB,EAAa,IAAA,CAAK,EAAE,MAAA,EAAA,MAAW,CAAI,CACvF;AAEA,SAAO,EACJ,OAAA,CAAQ,MAAY,EAAM,IAAI,EAAQ,IAAI,CAAC,EAC3C,KAAA,CAAM,GAAG,MAAM,EAAU,CAAC,IAAI,EAAU,CAAC,CAAC;AAC/C,GAGM,IAA2C,oBAAI,IAAI,CACvD,EAAY,UACZ,EAAY,uBACd,CAAC,GAEY,IAAA,CAAqB,MAChC,EAAe,IAAI,EAAQ,YAAY,GAoB5B,IAAA,CAAgB,GAAkB,OAA4C;AAAA,EACzF,SAAS,EAA0B,GAAS,CAAa;AAAA,EACzD,MAAM,EAAQ;AAAA,EACd,iBAAiB,EAAQ,oBAAoB;AAAA,EAC7C,MAAM,EAAsB,CAAO;AACrC,IAGa,IAAA,CACX,GACA,GACA,GACA,MACmB;AACnB,QAAM,IAAO,EACV,IAAA,CAAK,MAAY,EAAa,GAAS,CAAa,CAAC,EACrD,KAAA,CAAM,GAAG,MAAM,EAAE,UAAU,EAAE,OAAO;AAEvC,SAAO;AAAA,IAAE,QAAA;AAAA,IAAQ,KAAA;AAAA,IAAK,MAAA;AAAA,IAAM,OAAO,EAAK,OAAA,CAAQ,GAAO,MAAQ,IAAQ,EAAI,SAAS,CAAC;AAAA,EAAE;AACzF,GAuBM,IAAA,CAAkD,GAAW,MAAS;AAC1E,QAAM,IAAiB,EAAS,GAAW,eAAe,GACpD,IAAkB,EAAS,GAAW,gBAAgB,GACtD,IAAiB,EAAS,GAAW,eAAe;AAE1D,MACE,EAAA,MAAmB,UACnB,MAAoB,UACpB,MAAmB;AAKrB,WAAO;AAAA,MACL,SAAS,EAAK;AAAA,MACd,MAAM;AAAA,QACJ;AAAA,UACE,KAAK;AAAA,UACL,OAAO,EAAK;AAAA,UACZ,OAAO,EAAqB,CAAc;AAAA,QAC5C;AAAA,QAEA;AAAA,UACE,KAAK;AAAA,UACL,OAAO,EAAK;AAAA,UACZ,OAAO,EAAqB,CAAC,CAAe;AAAA,QAC9C;AAAA,QACA;AAAA,UACE,MAAM;AAAA,UACN,KAAK;AAAA,UACL,OAAO,EAAK;AAAA,UACZ,OAAO,EAAqB,CAAc;AAAA,QAC5C;AAAA,MACF;AAAA,IACF;AACF,GAEM,IAAmB,EACvB,qBAAqB,EACvB,GAGa,IAAA,CACX,GACA,MAEA,EACE,GACA,GAAK,SACL,uBACA,kBACF,EAAE,GAAK,gBAAgB,CAAI"}
@@ -9,34 +9,34 @@ import { useCtaHandler as Z } from "../../ctaActions/useCtaAction.es.js";
9
9
  import { useAnalyticsEvent as oo } from "../../analytics/useAnalyticsEvent.es.js";
10
10
  import { getDynamicCtaBasedOnTriggers as eo } from "../util.es.js";
11
11
  import { CreateBudgetDialog as to } from "./CreateBudgetDialog.es.js";
12
- import { AMOUNT_INPUT_VARIANTS as io, findLowBalanceProfile as no, isAmountInputVariant as x, isWholeAmount as ro, resolveAmountInputVariant as ao, toInputValue as so } from "./layout.es.js";
12
+ import { AMOUNT_INPUT_VARIANTS as io, CREATE_BUDGET_VARIANT as no, findLowBalanceProfile as ro, isAmountInputVariant as x, isWholeAmount as ao, resolveAmountInputVariant as so, toInputValue as co } from "./layout.es.js";
13
13
  import a from "react";
14
- import { observer as k } from "mobx-react-lite";
15
- import V from "@mui/material/Stack";
16
- import { H3 as co, InstitutionLogo as lo, Text as w } from "@mxenabled/mxui";
17
- import { Icon as uo } from "@mxenabled/mx-icons";
14
+ import { observer as V } from "mobx-react-lite";
15
+ import k from "@mui/material/Stack";
16
+ import { H3 as lo, InstitutionLogo as uo, Text as w } from "@mxenabled/mxui";
17
+ import { Icon as mo } from "@mxenabled/mx-icons";
18
18
  import { jsx as o, jsxs as O } from "react/jsx-runtime";
19
- import mo from "@mui/material/Dialog";
20
- import po from "@mui/material/IconButton";
21
- var v = ({ children: y, closeAriaLabel: i, heading: n, onClose: e }) => {
19
+ import po from "@mui/material/Dialog";
20
+ import _o from "@mui/material/IconButton";
21
+ var E = ({ children: y, closeAriaLabel: i, heading: n, onClose: e }) => {
22
22
  const l = a.useId();
23
- return /* @__PURE__ */ o(mo, {
23
+ return /* @__PURE__ */ o(po, {
24
24
  "aria-labelledby": n ? l : void 0,
25
25
  maxWidth: "xs",
26
26
  onClose: e,
27
27
  open: !0,
28
- children: /* @__PURE__ */ O(V, {
28
+ children: /* @__PURE__ */ O(k, {
29
29
  sx: {
30
30
  gap: 12,
31
31
  p: 24,
32
32
  position: "relative"
33
33
  },
34
34
  children: [
35
- n && /* @__PURE__ */ o(co, {
35
+ n && /* @__PURE__ */ o(lo, {
36
36
  id: l,
37
37
  children: n
38
38
  }),
39
- /* @__PURE__ */ o(po, {
39
+ /* @__PURE__ */ o(_o, {
40
40
  "aria-label": i || "Close",
41
41
  onClick: e,
42
42
  sx: {
@@ -44,7 +44,7 @@ var v = ({ children: y, closeAriaLabel: i, heading: n, onClose: e }) => {
44
44
  right: 8,
45
45
  top: 18
46
46
  },
47
- children: /* @__PURE__ */ o(uo, {
47
+ children: /* @__PURE__ */ o(mo, {
48
48
  name: "close",
49
49
  sx: { color: "action.active" }
50
50
  })
@@ -53,79 +53,79 @@ var v = ({ children: y, closeAriaLabel: i, heading: n, onClose: e }) => {
53
53
  ]
54
54
  })
55
55
  });
56
- }, ko = k(function({ beat: i }) {
57
- const { common: n } = H(), { actionDrawer: e, closeActionDrawer: l } = P(), s = q(), { primary_cta: u, secondary_cta: p, in_description_cta: _ } = i.insights_payload ?? {}, [m] = a.useState(() => ao(eo(e, u, p, _))), r = m === "create_budget";
56
+ }, ko = V(function({ beat: i }) {
57
+ const { common: n } = H(), { actionDrawer: e, closeActionDrawer: l } = P(), s = q(), { primary_cta: u, secondary_cta: p, in_description_cta: _ } = i.insights_payload ?? {}, [m] = a.useState(() => so(eo(e, u, p, _))), r = m === no;
58
58
  return a.useEffect(() => {
59
59
  r && !s.categoriesLoaded && s.loadCategories();
60
- }, [s, r]), r ? s.categoriesLoaded ? /* @__PURE__ */ o(to, { beat: i }) : /* @__PURE__ */ o(v, {
60
+ }, [s, r]), r ? s.categoriesLoaded ? /* @__PURE__ */ o(to, { beat: i }) : /* @__PURE__ */ o(E, {
61
61
  closeAriaLabel: n?.close_aria,
62
62
  onClose: l,
63
63
  children: /* @__PURE__ */ o(B, {})
64
- }) : /* @__PURE__ */ o(_o, {
64
+ }) : /* @__PURE__ */ o(fo, {
65
65
  beat: i,
66
66
  variant: m
67
67
  });
68
- }), _o = k(function({ beat: i, variant: n }) {
69
- const { common: e, insights_feed: l } = H(), { closeActionDrawer: s } = P(), u = J(), { userInsightProfile: p } = K(), _ = Z(i, X()), m = oo(), r = l?.amount_input_modal, t = n === io.LOW_BALANCE_THRESHOLD, S = t ? no(u.notificationProfiles, i.primary_account_guid) : void 0, E = t ? S?.threshold : p?.savings_opportunity_minimum_checking_account_balance, [G, R] = a.useState(t), f = a.useRef(!0);
68
+ }), fo = V(function({ beat: i, variant: n }) {
69
+ const { common: e, insights_feed: l } = H(), { closeActionDrawer: s } = P(), u = J(), { userInsightProfile: p } = K(), _ = Z(i, X()), m = oo(), r = l?.amount_input_modal, t = n === io.LOW_BALANCE_THRESHOLD, I = t ? ro(u.notificationProfiles, i.primary_account_guid) : void 0, T = t ? I?.threshold : p?.savings_opportunity_minimum_checking_account_balance, [R, G] = a.useState(t), f = a.useRef(!0);
70
70
  a.useEffect(() => (f.current = !0, () => {
71
71
  f.current = !1;
72
72
  }), []), a.useEffect(() => {
73
73
  t && u.loadNotificationProfiles().finally(() => {
74
- f.current && R(!1);
74
+ f.current && G(!1);
75
75
  });
76
76
  }, [t, u]);
77
- const [F, M] = a.useState(null), [T, C] = a.useState(!1), [U, I] = a.useState(!1), g = F ?? so(E);
78
- if (G) return /* @__PURE__ */ o(v, {
77
+ const [F, M] = a.useState(null), [v, C] = a.useState(!1), [U, S] = a.useState(!1), g = F ?? co(T);
78
+ if (R) return /* @__PURE__ */ o(E, {
79
79
  closeAriaLabel: e?.close_aria,
80
80
  onClose: s,
81
81
  children: /* @__PURE__ */ o(B, {})
82
82
  });
83
83
  const c = x(n) ? r?.[n] : void 0, D = !!c?.title && !!c.description && !!c.input_label && !!r?.whole_number_error && !!r.save_error && !!e?.save_button && (!t || !!e.cancel_button) && !!e.close_aria;
84
- if (!r || !c || !D || !(t ? S : p))
85
- return console.warn(`amount_input_modal_block: ${r ? x(n) ? D ? t ? "no low-balance profile for the account" : "user insight profile not set by the host" : `copy incomplete for "${n}"` : `unknown variant "${n}"` : "copy namespace missing"}`), /* @__PURE__ */ o(v, {
84
+ if (!r || !c || !D || !(t ? I : p))
85
+ return console.warn(`amount_input_modal_block: ${r ? x(n) ? D ? t ? "no low-balance profile for the account" : "user insight profile not set by the host" : `copy incomplete for "${n}"` : `unknown variant "${n}"` : "copy namespace missing"}`), /* @__PURE__ */ o(E, {
86
86
  closeAriaLabel: e?.close_aria,
87
87
  heading: e?.error_heading,
88
88
  onClose: s,
89
89
  children: /* @__PURE__ */ o(w, { children: e?.error_message })
90
90
  });
91
- const b = () => {
91
+ const L = () => {
92
92
  m(t ? d.EDIT_INSIGHT_THRESHOLD_CANCELED : d.EDIT_SAFETY_NET_CANCEL), s();
93
- }, L = !t && !!E, N = i.primary_account ? z(i.primary_account) : "", A = ro(g), $ = g !== "" && !A, W = async () => {
94
- if (!A || T) return;
93
+ }, b = !t && !!T, N = i.primary_account ? z(i.primary_account) : "", A = ao(g), $ = g !== "" && !A, W = async () => {
94
+ if (!A || v) return;
95
95
  const h = Number(g);
96
- C(!0), I(!1);
96
+ C(!0), S(!1);
97
97
  const Y = t ? await _("updateNotificationProfileThreshold", {
98
- profileGuid: S?.guid,
98
+ profileGuid: I?.guid,
99
99
  threshold: h
100
100
  }, { analytics: d.EDIT_INSIGHT_THRESHOLD_SAVE }) : await _("updateUserInsightProfile", { fields: { savings_opportunity_minimum_checking_account_balance: h } }, { analytics: d.EDIT_SAFETY_NET_SAVE });
101
- f.current && (C(!1), Y ? s() : I(!0));
101
+ f.current && (C(!1), Y ? s() : S(!0));
102
102
  };
103
103
  return /* @__PURE__ */ o(Q, {
104
104
  closeAriaLabel: e.close_aria,
105
- content: j(L && c.description_edit || c.description, /* @__PURE__ */ o("strong", { children: N }, "account")),
105
+ content: j(b && c.description_edit || c.description, /* @__PURE__ */ o("strong", { children: N }, "account")),
106
106
  errorText: $ ? r.whole_number_error : U ? r.save_error : void 0,
107
107
  handleInputChange: (h) => {
108
- M(h), I(!1);
108
+ M(h), S(!1);
109
109
  },
110
110
  handleInputClick: t ? () => m(d.EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED) : void 0,
111
- handleModalClose: b,
111
+ handleModalClose: L,
112
112
  handlePrimaryAction: () => {
113
113
  W();
114
114
  },
115
- handleSecondaryAction: b,
115
+ handleSecondaryAction: L,
116
116
  inputLabel: c.input_label,
117
117
  inputValue: g,
118
118
  isOpen: !0,
119
- isPrimaryDisabled: T || !A,
119
+ isPrimaryDisabled: v || !A,
120
120
  primaryText: e.save_button,
121
121
  secondaryText: t ? e.cancel_button : void 0,
122
- subtitle: t && i.primary_account ? /* @__PURE__ */ O(V, {
122
+ subtitle: t && i.primary_account ? /* @__PURE__ */ O(k, {
123
123
  sx: {
124
124
  alignItems: "center",
125
125
  flexDirection: "row",
126
126
  gap: 8
127
127
  },
128
- children: [/* @__PURE__ */ o(lo, {
128
+ children: [/* @__PURE__ */ o(uo, {
129
129
  alt: "",
130
130
  institutionGuid: i.primary_account.institution_guid ?? "",
131
131
  size: 16
@@ -136,7 +136,7 @@ var v = ({ children: y, closeAriaLabel: i, heading: n, onClose: e }) => {
136
136
  children: N
137
137
  })]
138
138
  }) : void 0,
139
- title: L && c.title_edit || c.title
139
+ title: b && c.title_edit || c.title
140
140
  });
141
141
  });
142
142
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"AmountInputModalBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.tsx"],"sourcesContent":["import React from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport MuiDialog from '@mui/material/Dialog'\nimport IconButton from '@mui/material/IconButton'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { H3, InstitutionLogo, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n CurrencyDialog,\n Loader,\n buildDynamicCopy,\n useCategoryStore,\n useGlobalCopyStore,\n useInsightsV2Store,\n useSettingsStore,\n useUserStore,\n} from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../analytics'\nimport { useBeatActions } from '../../beatActions'\nimport { useCtaHandler } from '../../ctaActions'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\n\nimport { CreateBudgetDialog } from './CreateBudgetDialog'\nimport {\n AMOUNT_INPUT_VARIANTS,\n findLowBalanceProfile,\n isAmountInputVariant,\n isWholeAmount,\n resolveAmountInputVariant,\n toInputValue,\n} from './layout'\n\n/** Dialog frame for the formless states: loading and a non-retriable problem. */\nconst StatusDialog = ({\n children,\n closeAriaLabel,\n heading,\n onClose,\n}: React.PropsWithChildren<{ closeAriaLabel?: string; heading?: string; onClose: () => void }>) => {\n const headingId = React.useId()\n\n return (\n <MuiDialog\n aria-labelledby={heading ? headingId : undefined}\n maxWidth=\"xs\"\n onClose={onClose}\n open={true}\n >\n <Stack sx={{ gap: 12, p: 24, position: 'relative' }}>\n {heading && <H3 id={headingId}>{heading}</H3>}\n <IconButton\n aria-label={closeAriaLabel || 'Close'}\n onClick={onClose}\n sx={{ position: 'absolute', right: 8, top: 18 }}\n >\n <Icon name=\"close\" sx={{ color: 'action.active' }} />\n </IconButton>\n {children}\n </Stack>\n </MuiDialog>\n )\n}\n\n/** `amount_input_modal_block`: one whole-dollar amount in a modal, picked by the CTA variant. */\nexport const AmountInputModalBlock = observer(function AmountInputModalBlock({\n beat,\n}: ActionBlockProps) {\n const { common: commonCopy } = useGlobalCopyStore()\n const { actionDrawer, closeActionDrawer } = useInsightsV2Store()\n const categoryStore = useCategoryStore()\n const { primary_cta, secondary_cta, in_description_cta } = beat.insights_payload ?? {}\n // Read once on open: a refreshed beat must not swap the dialog under its snackbar.\n const [variant] = React.useState(() =>\n resolveAmountInputVariant(\n getDynamicCtaBasedOnTriggers(actionDrawer, primary_cta, secondary_cta, in_description_cta),\n ),\n )\n const isCreateBudget = variant === 'create_budget'\n\n // The create dialog names the category, so it waits for the category store.\n React.useEffect(() => {\n if (isCreateBudget && !categoryStore.categoriesLoaded) void categoryStore.loadCategories()\n }, [categoryStore, isCreateBudget])\n\n if (!isCreateBudget) return <AmountSettingDialog beat={beat} variant={variant} />\n\n return categoryStore.categoriesLoaded ? (\n <CreateBudgetDialog beat={beat} />\n ) : (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n})\n\n/** The low-balance threshold and safety-net settings (the two `AMOUNT_INPUT_VARIANTS`). */\nconst AmountSettingDialog = observer(function AmountSettingDialog({\n beat,\n variant,\n}: ActionBlockProps & { variant?: string }) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const settingsStore = useSettingsStore()\n const { userInsightProfile } = useUserStore()\n const runHandler = useCtaHandler(beat, useBeatActions())\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n const copy = insightsFeedCopy?.amount_input_modal\n const isLowBalance = variant === AMOUNT_INPUT_VARIANTS.LOW_BALANCE_THRESHOLD\n\n const lowBalanceProfile = isLowBalance\n ? findLowBalanceProfile(settingsStore.notificationProfiles, beat.primary_account_guid)\n : undefined\n const savedAmount = isLowBalance\n ? lowBalanceProfile?.threshold\n : userInsightProfile?.savings_opportunity_minimum_checking_account_balance\n\n // Mounting is the open, so profiles reload here and the threshold prefills as saved now.\n const [isLoadingProfiles, setIsLoadingProfiles] = React.useState(isLowBalance)\n // False once unmounted: a save that resolves after the user closed the dialog must not close\n // (or update) whatever action session is open by then.\n const isMounted = React.useRef(true)\n\n React.useEffect(() => {\n isMounted.current = true\n\n return () => {\n isMounted.current = false\n }\n }, [])\n\n React.useEffect(() => {\n if (!isLowBalance) return\n\n void settingsStore.loadNotificationProfiles().finally(() => {\n if (isMounted.current) setIsLoadingProfiles(false)\n })\n }, [isLowBalance, settingsStore])\n\n // `null` until the user types: the field shows the saved amount until then.\n const [typed, setTyped] = React.useState<string | null>(null)\n const [isSaving, setIsSaving] = React.useState(false)\n const [saveFailed, setSaveFailed] = React.useState(false)\n\n const value = typed ?? toInputValue(savedAmount)\n\n if (isLoadingProfiles) {\n return (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n }\n\n // Copy ships separately (see the doc's Rollout order), so check every string the form renders:\n // a partial ship falls to the error dialog instead of throwing mid-render.\n const variantCopy = isAmountInputVariant(variant) ? copy?.[variant] : undefined\n const hasCopy =\n !!variantCopy?.title &&\n !!variantCopy.description &&\n !!variantCopy.input_label &&\n !!copy?.whole_number_error &&\n !!copy.save_error &&\n !!commonCopy?.save_button &&\n // Cancel renders for the low-balance variant only.\n (!isLowBalance || !!commonCopy.cancel_button) &&\n !!commonCopy.close_aria\n const hasProfile = isLowBalance ? !!lowBalanceProfile : !!userInsightProfile\n\n if (!copy || !variantCopy || !hasCopy || !hasProfile) {\n // One message to the user; distinct warnings so a rollout problem can be traced to its cause.\n console.warn(\n `amount_input_modal_block: ${\n !copy\n ? 'copy namespace missing'\n : !isAmountInputVariant(variant)\n ? `unknown variant \"${variant}\"`\n : !hasCopy\n ? `copy incomplete for \"${variant}\"`\n : isLowBalance\n ? 'no low-balance profile for the account'\n : 'user insight profile not set by the host'\n }`,\n )\n\n return (\n <StatusDialog\n closeAriaLabel={commonCopy?.close_aria}\n heading={commonCopy?.error_heading}\n onClose={closeActionDrawer}\n >\n <Text>{commonCopy?.error_message}</Text>\n </StatusDialog>\n )\n }\n\n // Trigger 4 — user dismissed without saving (close icon, Cancel button, backdrop). Pulse\n // parity: EditThreshold.js close button / EditSafetyNet.js cancel button.\n const handleDismiss = () => {\n fireAnalyticsEvent(\n isLowBalance\n ? ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_CANCELED\n : ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_CANCEL,\n )\n closeActionDrawer()\n }\n\n const isEdit = !isLowBalance && !!savedAmount\n const accountName = beat.primary_account ? getAccountDisplayName(beat.primary_account) : ''\n const isValid = isWholeAmount(value)\n const isInvalid = value !== '' && !isValid\n\n const handleSave = async () => {\n // Guarded here too, not only by the disabled button: Enter submits the dialog's form directly.\n if (!isValid || isSaving) return\n\n const amount = Number(value)\n\n setIsSaving(true)\n setSaveFailed(false)\n\n // Trigger 2: save analytics ride the handler run, fired only on success.\n const ok = isLowBalance\n ? await runHandler(\n 'updateNotificationProfileThreshold',\n { profileGuid: lowBalanceProfile?.guid, threshold: amount },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_SAVE },\n )\n : await runHandler(\n 'updateUserInsightProfile',\n { fields: { savings_opportunity_minimum_checking_account_balance: amount } },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_SAVE },\n )\n\n if (!isMounted.current) return\n\n setIsSaving(false)\n\n if (ok) closeActionDrawer()\n else setSaveFailed(true)\n }\n\n return (\n <CurrencyDialog\n closeAriaLabel={commonCopy.close_aria}\n // Only strings and the <strong> go in, so the result is renderable (the helper's type also\n // admits raw DOM nodes).\n content={\n buildDynamicCopy(\n (isEdit && variantCopy.description_edit) || variantCopy.description,\n <strong key=\"account\">{accountName}</strong>,\n ) as React.ReactNode\n }\n errorText={isInvalid ? copy.whole_number_error : saveFailed ? copy.save_error : undefined}\n handleInputChange={(next) => {\n setTyped(next)\n setSaveFailed(false)\n }}\n handleInputClick={\n // Pulse fires input-selected for the threshold dialog only (EditThreshold.js); the\n // safety-net dialog has no input event.\n isLowBalance\n ? () => fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED)\n : undefined\n }\n handleModalClose={handleDismiss}\n handlePrimaryAction={() => void handleSave()}\n handleSecondaryAction={handleDismiss}\n inputLabel={variantCopy.input_label}\n inputValue={value}\n isOpen={true}\n isPrimaryDisabled={isSaving || !isValid}\n primaryText={commonCopy.save_button}\n secondaryText={isLowBalance ? commonCopy.cancel_button : undefined}\n subtitle={\n isLowBalance && beat.primary_account ? (\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n {/* Decorative: the account name is the visible text beside it. */}\n <InstitutionLogo\n alt=\"\"\n institutionGuid={beat.primary_account.institution_guid ?? ''}\n size={16}\n />\n <Text color=\"text.secondary\" uppercase={true} variant=\"body2\">\n {accountName}\n </Text>\n </Stack>\n ) : undefined\n }\n title={(isEdit && variantCopy.title_edit) || variantCopy.title}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuCA,IAAM,IAAA,CAAgB,EACpB,UAAA,GACA,gBAAA,GACA,SAAA,GACA,SAAA,EAAA,MACiG;AACjG,QAAM,IAAY,EAAM,MAAM;AAE9B,SACE,gBAAA,EAAC,IAAD;AAAA,IACE,mBAAiB,IAAU,IAAY;AAAA,IACvC,UAAS;AAAA,IACA,SAAA;AAAA,IACT,MAAM;AAAA,IAEN,UAAA,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,KAAK;AAAA,QAAI,GAAG;AAAA,Q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2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.tsx"],"sourcesContent":["import React from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport MuiDialog from '@mui/material/Dialog'\nimport IconButton from '@mui/material/IconButton'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { H3, InstitutionLogo, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n CurrencyDialog,\n Loader,\n buildDynamicCopy,\n useCategoryStore,\n useGlobalCopyStore,\n useInsightsV2Store,\n useSettingsStore,\n useUserStore,\n} from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../analytics'\nimport { useBeatActions } from '../../beatActions'\nimport { useCtaHandler } from '../../ctaActions'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\n\nimport { CreateBudgetDialog } from './CreateBudgetDialog'\nimport {\n AMOUNT_INPUT_VARIANTS,\n CREATE_BUDGET_VARIANT,\n findLowBalanceProfile,\n isAmountInputVariant,\n isWholeAmount,\n resolveAmountInputVariant,\n toInputValue,\n} from './layout'\n\n/** Dialog frame for the formless states: loading and a non-retriable problem. */\nconst StatusDialog = ({\n children,\n closeAriaLabel,\n heading,\n onClose,\n}: React.PropsWithChildren<{ closeAriaLabel?: string; heading?: string; onClose: () => void }>) => {\n const headingId = React.useId()\n\n return (\n <MuiDialog\n aria-labelledby={heading ? headingId : undefined}\n maxWidth=\"xs\"\n onClose={onClose}\n open={true}\n >\n <Stack sx={{ gap: 12, p: 24, position: 'relative' }}>\n {heading && <H3 id={headingId}>{heading}</H3>}\n <IconButton\n aria-label={closeAriaLabel || 'Close'}\n onClick={onClose}\n sx={{ position: 'absolute', right: 8, top: 18 }}\n >\n <Icon name=\"close\" sx={{ color: 'action.active' }} />\n </IconButton>\n {children}\n </Stack>\n </MuiDialog>\n )\n}\n\n/** `amount_input_modal_block`: one whole-dollar amount in a modal, picked by the CTA variant. */\nexport const AmountInputModalBlock = observer(function AmountInputModalBlock({\n beat,\n}: ActionBlockProps) {\n const { common: commonCopy } = useGlobalCopyStore()\n const { actionDrawer, closeActionDrawer } = useInsightsV2Store()\n const categoryStore = useCategoryStore()\n const { primary_cta, secondary_cta, in_description_cta } = beat.insights_payload ?? {}\n // Read once on open: a refreshed beat must not swap the dialog under its snackbar.\n const [variant] = React.useState(() =>\n resolveAmountInputVariant(\n getDynamicCtaBasedOnTriggers(actionDrawer, primary_cta, secondary_cta, in_description_cta),\n ),\n )\n const isCreateBudget = variant === CREATE_BUDGET_VARIANT\n\n // The create dialog names the category, so it waits for the category store.\n React.useEffect(() => {\n if (isCreateBudget && !categoryStore.categoriesLoaded) void categoryStore.loadCategories()\n }, [categoryStore, isCreateBudget])\n\n if (!isCreateBudget) return <AmountSettingDialog beat={beat} variant={variant} />\n\n return categoryStore.categoriesLoaded ? (\n <CreateBudgetDialog beat={beat} />\n ) : (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n})\n\n/** The low-balance threshold and safety-net settings (the two `AMOUNT_INPUT_VARIANTS`). */\nconst AmountSettingDialog = observer(function AmountSettingDialog({\n beat,\n variant,\n}: ActionBlockProps & { variant?: string }) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const settingsStore = useSettingsStore()\n const { userInsightProfile } = useUserStore()\n const runHandler = useCtaHandler(beat, useBeatActions())\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n const copy = insightsFeedCopy?.amount_input_modal\n const isLowBalance = variant === AMOUNT_INPUT_VARIANTS.LOW_BALANCE_THRESHOLD\n\n const lowBalanceProfile = isLowBalance\n ? findLowBalanceProfile(settingsStore.notificationProfiles, beat.primary_account_guid)\n : undefined\n const savedAmount = isLowBalance\n ? lowBalanceProfile?.threshold\n : userInsightProfile?.savings_opportunity_minimum_checking_account_balance\n\n // Mounting is the open, so profiles reload here and the threshold prefills as saved now.\n const [isLoadingProfiles, setIsLoadingProfiles] = React.useState(isLowBalance)\n // False once unmounted: a save that resolves after the user closed the dialog must not close\n // (or update) whatever action session is open by then.\n const isMounted = React.useRef(true)\n\n React.useEffect(() => {\n isMounted.current = true\n\n return () => {\n isMounted.current = false\n }\n }, [])\n\n React.useEffect(() => {\n if (!isLowBalance) return\n\n void settingsStore.loadNotificationProfiles().finally(() => {\n if (isMounted.current) setIsLoadingProfiles(false)\n })\n }, [isLowBalance, settingsStore])\n\n // `null` until the user types: the field shows the saved amount until then.\n const [typed, setTyped] = React.useState<string | null>(null)\n const [isSaving, setIsSaving] = React.useState(false)\n const [saveFailed, setSaveFailed] = React.useState(false)\n\n const value = typed ?? toInputValue(savedAmount)\n\n if (isLoadingProfiles) {\n return (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n }\n\n // Copy ships separately (see the doc's Rollout order), so check every string the form renders:\n // a partial ship falls to the error dialog instead of throwing mid-render.\n const variantCopy = isAmountInputVariant(variant) ? copy?.[variant] : undefined\n const hasCopy =\n !!variantCopy?.title &&\n !!variantCopy.description &&\n !!variantCopy.input_label &&\n !!copy?.whole_number_error &&\n !!copy.save_error &&\n !!commonCopy?.save_button &&\n // Cancel renders for the low-balance variant only.\n (!isLowBalance || !!commonCopy.cancel_button) &&\n !!commonCopy.close_aria\n const hasProfile = isLowBalance ? !!lowBalanceProfile : !!userInsightProfile\n\n if (!copy || !variantCopy || !hasCopy || !hasProfile) {\n // One message to the user; distinct warnings so a rollout problem can be traced to its cause.\n console.warn(\n `amount_input_modal_block: ${\n !copy\n ? 'copy namespace missing'\n : !isAmountInputVariant(variant)\n ? `unknown variant \"${variant}\"`\n : !hasCopy\n ? `copy incomplete for \"${variant}\"`\n : isLowBalance\n ? 'no low-balance profile for the account'\n : 'user insight profile not set by the host'\n }`,\n )\n\n return (\n <StatusDialog\n closeAriaLabel={commonCopy?.close_aria}\n heading={commonCopy?.error_heading}\n onClose={closeActionDrawer}\n >\n <Text>{commonCopy?.error_message}</Text>\n </StatusDialog>\n )\n }\n\n // Trigger 4 — user dismissed without saving (close icon, Cancel button, backdrop). Pulse\n // parity: EditThreshold.js close button / EditSafetyNet.js cancel button.\n const handleDismiss = () => {\n fireAnalyticsEvent(\n isLowBalance\n ? ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_CANCELED\n : ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_CANCEL,\n )\n closeActionDrawer()\n }\n\n const isEdit = !isLowBalance && !!savedAmount\n const accountName = beat.primary_account ? getAccountDisplayName(beat.primary_account) : ''\n const isValid = isWholeAmount(value)\n const isInvalid = value !== '' && !isValid\n\n const handleSave = async () => {\n // Guarded here too, not only by the disabled button: Enter submits the dialog's form directly.\n if (!isValid || isSaving) return\n\n const amount = Number(value)\n\n setIsSaving(true)\n setSaveFailed(false)\n\n // Trigger 2: save analytics ride the handler run, fired only on success.\n const ok = isLowBalance\n ? await runHandler(\n 'updateNotificationProfileThreshold',\n { profileGuid: lowBalanceProfile?.guid, threshold: amount },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_SAVE },\n )\n : await runHandler(\n 'updateUserInsightProfile',\n { fields: { savings_opportunity_minimum_checking_account_balance: amount } },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_SAVE },\n )\n\n if (!isMounted.current) return\n\n setIsSaving(false)\n\n if (ok) closeActionDrawer()\n else setSaveFailed(true)\n }\n\n return (\n <CurrencyDialog\n closeAriaLabel={commonCopy.close_aria}\n // Only strings and the <strong> go in, so the result is renderable (the helper's type also\n // admits raw DOM nodes).\n content={\n buildDynamicCopy(\n (isEdit && variantCopy.description_edit) || variantCopy.description,\n <strong key=\"account\">{accountName}</strong>,\n ) as React.ReactNode\n }\n errorText={isInvalid ? copy.whole_number_error : saveFailed ? copy.save_error : undefined}\n handleInputChange={(next) => {\n setTyped(next)\n setSaveFailed(false)\n }}\n handleInputClick={\n // Pulse fires input-selected for the threshold dialog only (EditThreshold.js); the\n // safety-net dialog has no input event.\n isLowBalance\n ? () => fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED)\n : undefined\n }\n handleModalClose={handleDismiss}\n handlePrimaryAction={() => void handleSave()}\n handleSecondaryAction={handleDismiss}\n inputLabel={variantCopy.input_label}\n inputValue={value}\n isOpen={true}\n isPrimaryDisabled={isSaving || !isValid}\n primaryText={commonCopy.save_button}\n secondaryText={isLowBalance ? commonCopy.cancel_button : undefined}\n subtitle={\n isLowBalance && beat.primary_account ? (\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n {/* Decorative: the account name is the visible text beside it. */}\n <InstitutionLogo\n alt=\"\"\n institutionGuid={beat.primary_account.institution_guid ?? ''}\n size={16}\n />\n <Text color=\"text.secondary\" uppercase={true} variant=\"body2\">\n {accountName}\n </Text>\n </Stack>\n ) : undefined\n }\n title={(isEdit && variantCopy.title_edit) || variantCopy.title}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwCA,IAAM,IAAA,CAAgB,EACpB,UAAA,GACA,gBAAA,GACA,SAAA,GACA,SAAA,EAAA,MACiG;AACjG,QAAM,IAAY,EAAM,MAAM;AAE9B,SACE,gBAAA,EAAC,IAAD;AAAA,IACE,mBAAiB,IAAU,IAAY;AAAA,IACvC,UAAS;AAAA,IACA,SAAA;AAAA,IACT,MAAM;AAAA,IAEN,UAAA,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,KAAK;AAAA,QAAI,GAAG;AAAA,QAAI,UAAU;AAAA,MAAW;AAAA,MAAlD,UAAA;AAAA,QACG,KAAW,gBAAA,EAAC,IAAD;AAAA,UAAI,IAAI;AAAA,UAAY,UAAA;AAAA,QAA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,EACG,KAAU,EAAY,oBAAqB,EAAY,aACxD,gBAAA,EAAC,UAAD,EAAA,UAAuB,EAAoB,GAA/B,SAA+B,CAC7C;AAAA,IAEF,WAAW,IAAY,EAAK,qBAAqB,IAAa,EAAK,aAAa;AAAA,IAChF,mBAAA,CAAoB,MAAS;AAC3B,MAAA,EAAS,CAAI,GACb,EAAc,EAAK;AAAA,IACrB;AAAA,IACA,kBAGE,IAAA,MACU,EAAmB,EAAwB,qCAAqC,IACtF;AAAA,IAEN,kBAAkB;AAAA,IAClB,qBAAA,MAAA;AAA2B,MAAK,EAAW;AAAA;AAAA,IAC3C,uBAAuB;AAAA,IACvB,YAAY,EAAY;AAAA,IACxB,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,mBAAmB,KAAY,CAAC;AAAA,IAChC,aAAa,EAAW;AAAA,IACxB,eAAe,IAAe,EAAW,gBAAgB;AAAA,IACzD,UACE,KAAgB,EAAK,kBACnB,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,YAAY;AAAA,QAAU,eAAe;AAAA,QAAO,KAAK;AAAA,MAAE;AAAA,MAAhE,UAAA,CAEE,gBAAA,EAAC,IAAD;AAAA,QACE,KAAI;AAAA,QACJ,iBAAiB,EAAK,gBAAgB,oBAAoB;AAAA,QAC1D,MAAM;AAAA,MACP,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,QAAM,OAAM;AAAA,QAAiB,WAAW;AAAA,QAAM,SAAQ;AAAA,QACnD,UAAA;AAAA,MACG,CAAA,CACD;AAAA,IACL,CAAA,IAAA;AAAA,IAEN,OAAQ,KAAU,EAAY,cAAe,EAAY;AAAA,EAC1D,CAAA;AAEL,CAAC"}
@@ -4,6 +4,8 @@ export declare const AMOUNT_INPUT_VARIANTS: {
4
4
  readonly LOW_BALANCE_THRESHOLD: "low_balance_threshold";
5
5
  readonly SAFETY_NET: "safety_net";
6
6
  };
7
+ /** Opens the Create Budget dialog instead of an amount setting (Category Spending). */
8
+ export declare const CREATE_BUDGET_VARIANT = "create_budget";
7
9
  export type AmountInputVariant = (typeof AMOUNT_INPUT_VARIANTS)[keyof typeof AMOUNT_INPUT_VARIANTS];
8
10
  export declare const isAmountInputVariant: (variant?: string | null) => variant is AmountInputVariant;
9
11
  /**
@@ -1,19 +1,20 @@
1
- import { AccountNotificationTypes as i } from "../../../core/types/Notification.es.js";
2
- import { actionBlocksKey as a } from "../../mappings/actionBlocksKey.es.js";
3
- var o = {
1
+ import { AccountNotificationTypes as a } from "../../../core/types/Notification.es.js";
2
+ import { actionBlocksKey as o } from "../../mappings/actionBlocksKey.es.js";
3
+ var e = {
4
4
  LOW_BALANCE_THRESHOLD: "low_balance_threshold",
5
5
  SAFETY_NET: "safety_net"
6
- }, T = (t) => Object.values(o).includes(t ?? ""), u = (t) => {
6
+ }, T = "create_budget", u = (t) => Object.values(e).includes(t ?? ""), N = (t) => {
7
7
  if (t?.variant) return t.variant;
8
- if (t?.block === a.SAFETY_NET_ACTION_BLOCK) return o.SAFETY_NET;
9
- }, e = 1e9, N = (t) => /^\d+$/.test(t) && Number(t) >= 1 && Number(t) <= e, c = (t) => t ? String(Math.round(t)) : "", l = (t, n) => n ? t.find((r) => r.entity_guid === n && r.notification_type === i.AccountBalanceLow) : void 0;
8
+ if (t?.block === o.SAFETY_NET_ACTION_BLOCK) return e.SAFETY_NET;
9
+ }, i = 1e9, c = (t) => /^\d+$/.test(t) && Number(t) >= 1 && Number(t) <= i, v = (t) => t ? String(Math.round(t)) : "", E = (t, r) => r ? t.find((n) => n.entity_guid === r && n.notification_type === a.AccountBalanceLow) : void 0;
10
10
  export {
11
- o as AMOUNT_INPUT_VARIANTS,
12
- l as findLowBalanceProfile,
13
- T as isAmountInputVariant,
14
- N as isWholeAmount,
15
- u as resolveAmountInputVariant,
16
- c as toInputValue
11
+ e as AMOUNT_INPUT_VARIANTS,
12
+ T as CREATE_BUDGET_VARIANT,
13
+ E as findLowBalanceProfile,
14
+ u as isAmountInputVariant,
15
+ c as isWholeAmount,
16
+ N as resolveAmountInputVariant,
17
+ v as toInputValue
17
18
  };
18
19
 
19
20
  //# sourceMappingURL=layout.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/layout.ts"],"sourcesContent":["import type { NotificationProfile } from '../../../core'\nimport { AccountNotificationTypes } from '../../../core/types/Notification'\nimport { actionBlocksKey } from '../../mappings/actionBlocksKey'\n\n/** CTA variants `amount_input_modal_block` serves (ditto sets one on the beat's CTA). */\nexport const AMOUNT_INPUT_VARIANTS = {\n LOW_BALANCE_THRESHOLD: 'low_balance_threshold',\n SAFETY_NET: 'safety_net',\n} as const\n\nexport type AmountInputVariant = (typeof AMOUNT_INPUT_VARIANTS)[keyof typeof AMOUNT_INPUT_VARIANTS]\n\nexport const isAmountInputVariant = (variant?: string | null): variant is AmountInputVariant =>\n Object.values<string>(AMOUNT_INPUT_VARIANTS).includes(variant ?? '')\n\n/**\n * The variant the modal edits, from the CTA that opened it. ditto drives the shared\n * `amount_input_modal_block` by an explicit CTA variant, but gives Savings Opportunity's safety-net\n * reminder a dedicated `safety_net_block` with no variant, so there the block name selects it. An\n * explicit variant always wins (so an unknown one still falls to the block's \"unknown variant\" path).\n */\nexport const resolveAmountInputVariant = (cta?: {\n block?: string | null\n variant?: string | null\n}): string | undefined => {\n if (cta?.variant) return cta.variant\n if (cta?.block === actionBlocksKey.SAFETY_NET_ACTION_BLOCK)\n return AMOUNT_INPUT_VARIANTS.SAFETY_NET\n return undefined\n}\n\n/** Pulse v1's upper bound for a safety net; applied to both variants. */\nconst MAX_AMOUNT = 1_000_000_000\n\n/** Whole dollars from 1 to `MAX_AMOUNT`, as pulse v1 accepted for both settings. */\nexport const isWholeAmount = (value: string): boolean =>\n /^\\d+$/.test(value) && Number(value) >= 1 && Number(value) <= MAX_AMOUNT\n\n/** A saved amount as the field's starting text; nothing saved (or zero) starts empty. */\nexport const toInputValue = (amount?: number | null): string =>\n amount ? String(Math.round(amount)) : ''\n\n/** The account's low-balance alert profile, which holds the threshold (as pulse v1 looked it up). */\nexport const findLowBalanceProfile = (\n profiles: NotificationProfile[],\n accountGuid?: string | null,\n): NotificationProfile | undefined =>\n accountGuid\n ? profiles.find(\n (profile) =>\n profile.entity_guid === accountGuid &&\n profile.notification_type === AccountNotificationTypes.AccountBalanceLow,\n )\n : undefined\n"],"mappings":";;AAKA,IAAa,IAAwB;AAAA,EACnC,uBAAuB;AAAA,EACvB,YAAY;AACd,GAIa,IAAA,CAAwB,MACnC,OAAO,OAAe,CAAqB,EAAE,SAAS,KAAW,EAAE,GAQxD,IAAA,CAA6B,MAGhB;AACxB,MAAI,GAAK,QAAS,QAAO,EAAI;AAC7B,MAAI,GAAK,UAAU,EAAgB,wBACjC,QAAO,EAAsB;AAEjC,GAGM,IAAa,KAGN,IAAA,CAAiB,MAC5B,QAAQ,KAAK,CAAK,KAAK,OAAO,CAAK,KAAK,KAAK,OAAO,CAAK,KAAK,GAGnD,IAAA,CAAgB,MAC3B,IAAS,OAAO,KAAK,MAAM,CAAM,CAAC,IAAI,IAG3B,IAAA,CACX,GACA,MAEA,IACI,EAAS,KAAA,CACN,MACC,EAAQ,gBAAgB,KACxB,EAAQ,sBAAsB,EAAyB,iBAC3D,IACA"}
1
+ {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/layout.ts"],"sourcesContent":["import type { NotificationProfile } from '../../../core'\nimport { AccountNotificationTypes } from '../../../core/types/Notification'\nimport { actionBlocksKey } from '../../mappings/actionBlocksKey'\n\n/** CTA variants `amount_input_modal_block` serves (ditto sets one on the beat's CTA). */\nexport const AMOUNT_INPUT_VARIANTS = {\n LOW_BALANCE_THRESHOLD: 'low_balance_threshold',\n SAFETY_NET: 'safety_net',\n} as const\n\n/** Opens the Create Budget dialog instead of an amount setting (Category Spending). */\nexport const CREATE_BUDGET_VARIANT = 'create_budget'\n\nexport type AmountInputVariant = (typeof AMOUNT_INPUT_VARIANTS)[keyof typeof AMOUNT_INPUT_VARIANTS]\n\nexport const isAmountInputVariant = (variant?: string | null): variant is AmountInputVariant =>\n Object.values<string>(AMOUNT_INPUT_VARIANTS).includes(variant ?? '')\n\n/**\n * The variant the modal edits, from the CTA that opened it. ditto drives the shared\n * `amount_input_modal_block` by an explicit CTA variant, but gives Savings Opportunity's safety-net\n * reminder a dedicated `safety_net_block` with no variant, so there the block name selects it. An\n * explicit variant always wins (so an unknown one still falls to the block's \"unknown variant\" path).\n */\nexport const resolveAmountInputVariant = (cta?: {\n block?: string | null\n variant?: string | null\n}): string | undefined => {\n if (cta?.variant) return cta.variant\n if (cta?.block === actionBlocksKey.SAFETY_NET_ACTION_BLOCK)\n return AMOUNT_INPUT_VARIANTS.SAFETY_NET\n return undefined\n}\n\n/** Pulse v1's upper bound for a safety net; applied to both variants. */\nconst MAX_AMOUNT = 1_000_000_000\n\n/** Whole dollars from 1 to `MAX_AMOUNT`, as pulse v1 accepted for both settings. */\nexport const isWholeAmount = (value: string): boolean =>\n /^\\d+$/.test(value) && Number(value) >= 1 && Number(value) <= MAX_AMOUNT\n\n/** A saved amount as the field's starting text; nothing saved (or zero) starts empty. */\nexport const toInputValue = (amount?: number | null): string =>\n amount ? String(Math.round(amount)) : ''\n\n/** The account's low-balance alert profile, which holds the threshold (as pulse v1 looked it up). */\nexport const findLowBalanceProfile = (\n profiles: NotificationProfile[],\n accountGuid?: string | null,\n): NotificationProfile | undefined =>\n accountGuid\n ? profiles.find(\n (profile) =>\n profile.entity_guid === accountGuid &&\n profile.notification_type === AccountNotificationTypes.AccountBalanceLow,\n )\n : undefined\n"],"mappings":";;AAKA,IAAa,IAAwB;AAAA,EACnC,uBAAuB;AAAA,EACvB,YAAY;AACd,GAGa,IAAwB,iBAIxB,IAAA,CAAwB,MACnC,OAAO,OAAe,CAAqB,EAAE,SAAS,KAAW,EAAE,GAQxD,IAAA,CAA6B,MAGhB;AACxB,MAAI,GAAK,QAAS,QAAO,EAAI;AAC7B,MAAI,GAAK,UAAU,EAAgB,wBACjC,QAAO,EAAsB;AAEjC,GAGM,IAAa,KAGN,IAAA,CAAiB,MAC5B,QAAQ,KAAK,CAAK,KAAK,OAAO,CAAK,KAAK,KAAK,OAAO,CAAK,KAAK,GAGnD,IAAA,CAAgB,MAC3B,IAAS,OAAO,KAAK,MAAM,CAAM,CAAC,IAAI,IAG3B,IAAA,CACX,GACA,MAEA,IACI,EAAS,KAAA,CACN,MACC,EAAQ,gBAAgB,KACxB,EAAQ,sBAAsB,EAAyB,iBAC3D,IACA"}