@mx-cartographer/experiences 9.7.128 → 9.7.130

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 (92) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/core/types/localization/InsightsFeedCopy.d.ts +11 -15
  3. package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.d.ts +5 -1
  4. package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.es.js +78 -30
  5. package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.es.js.map +1 -1
  6. package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListContent.d.ts +26 -13
  7. package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListContent.es.js +107 -136
  8. package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListContent.es.js.map +1 -1
  9. package/dist/insights-v2/actionBlocks/AccountListBlock/layout.d.ts +21 -7
  10. package/dist/insights-v2/actionBlocks/AccountListBlock/layout.es.js +34 -17
  11. package/dist/insights-v2/actionBlocks/AccountListBlock/layout.es.js.map +1 -1
  12. package/dist/insights-v2/actionBlocks/AccountListBlock/useAccountListPrepare.d.ts +3 -1
  13. package/dist/insights-v2/actionBlocks/AccountListBlock/useAccountListPrepare.es.js +10 -8
  14. package/dist/insights-v2/actionBlocks/AccountListBlock/useAccountListPrepare.es.js.map +1 -1
  15. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js +46 -45
  16. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js.map +1 -1
  17. package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/layout.es.js +23 -22
  18. package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/layout.es.js.map +1 -1
  19. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js +26 -25
  20. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js.map +1 -1
  21. package/dist/insights-v2/actionBlocks/HelpBlock/layout.d.ts +0 -1
  22. package/dist/insights-v2/actionBlocks/HelpBlock/layout.es.js +6 -6
  23. package/dist/insights-v2/actionBlocks/HelpBlock/layout.es.js.map +1 -1
  24. package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/layout.es.js +8 -7
  25. package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/layout.es.js.map +1 -1
  26. package/dist/insights-v2/actionBlocks/OverdraftBlock/layout.es.js +11 -13
  27. package/dist/insights-v2/actionBlocks/OverdraftBlock/layout.es.js.map +1 -1
  28. package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/RecurringTransactionBlock.d.ts +10 -12
  29. package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/RecurringTransactionBlock.es.js +20 -19
  30. package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/RecurringTransactionBlock.es.js.map +1 -1
  31. package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/index.d.ts +1 -1
  32. package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/useRecurringTransactionBlock.d.ts +3 -12
  33. package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/useRecurringTransactionBlock.es.js +8 -8
  34. package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/useRecurringTransactionBlock.es.js.map +1 -1
  35. package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/useRecurringTransactionPrepare.d.ts +9 -0
  36. package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/useRecurringTransactionPrepare.es.js +27 -10
  37. package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/useRecurringTransactionPrepare.es.js.map +1 -1
  38. package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.d.ts +1 -7
  39. package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.es.js +49 -59
  40. package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.es.js.map +1 -1
  41. package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashContent.es.js +29 -75
  42. package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashContent.es.js.map +1 -1
  43. package/dist/insights-v2/actionBlocks/RemainingCashBlock/layout.d.ts +12 -0
  44. package/dist/insights-v2/actionBlocks/RemainingCashBlock/layout.es.js +18 -9
  45. package/dist/insights-v2/actionBlocks/RemainingCashBlock/layout.es.js.map +1 -1
  46. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +14 -13
  47. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
  48. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js +10 -9
  49. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js.map +1 -1
  50. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.d.ts +0 -3
  51. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js +30 -33
  52. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js.map +1 -1
  53. package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js +31 -30
  54. package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js.map +1 -1
  55. package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js +14 -14
  56. package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js +4 -4
  57. package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js +4 -4
  58. package/dist/insights-v2/blocks/ComponentBlocks/RepeatingTransactionBlock/RepeatingTransactionBlock.es.js +4 -4
  59. package/dist/insights-v2/blocks/ComponentBlocks/SavingsOpportunityBlock/SavingsOpportunityBlock.es.js +11 -10
  60. package/dist/insights-v2/blocks/ComponentBlocks/SavingsOpportunityBlock/SavingsOpportunityBlock.es.js.map +1 -1
  61. package/dist/insights-v2/blocks/ComponentBlocks/UpcomingSubscriptionBlock/UpcomingSubscriptionBlock.es.js +5 -5
  62. package/dist/insights-v2/blocks/ComponentBlocks/WeeklySmallPurchasesBlock/WeeklySmallPurchasesBlock.es.js +4 -4
  63. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/EmergencySavingsAccountPicker.es.js +1 -1
  64. package/dist/insights-v2/blocks/slotReaders.d.ts +5 -0
  65. package/dist/insights-v2/blocks/slotReaders.es.js +7 -5
  66. package/dist/insights-v2/blocks/slotReaders.es.js.map +1 -1
  67. package/dist/insights-v2/components/AmountBreakdownCard.es.js +9 -8
  68. package/dist/insights-v2/components/AmountBreakdownCard.es.js.map +1 -1
  69. package/dist/insights-v2/components/InsightListRow.d.ts +31 -0
  70. package/dist/insights-v2/components/InsightListRow.es.js +111 -0
  71. package/dist/insights-v2/components/InsightListRow.es.js.map +1 -0
  72. package/dist/insights-v2/components/SubTabs.d.ts +2 -1
  73. package/dist/insights-v2/components/SubTabs.es.js +10 -10
  74. package/dist/insights-v2/components/SubTabs.es.js.map +1 -1
  75. package/dist/insights-v2/index.es.js +12 -12
  76. package/dist/insights-v2/mappings/blocks.es.js +21 -21
  77. package/dist/recurringtransactions/components/RecurringTransactionDetails.d.ts +3 -1
  78. package/dist/recurringtransactions/components/RecurringTransactionDetails.es.js +169 -120
  79. package/dist/recurringtransactions/components/RecurringTransactionDetails.es.js.map +1 -1
  80. package/dist/recurringtransactions/components/RecurringTransactionList.d.ts +3 -1
  81. package/dist/recurringtransactions/components/RecurringTransactionList.es.js +151 -118
  82. package/dist/recurringtransactions/components/RecurringTransactionList.es.js.map +1 -1
  83. package/dist/transactions/components/shared/TransactionDetails.d.ts +1 -6
  84. package/dist/transactions/components/shared/TransactionDetails.es.js +149 -199
  85. package/dist/transactions/components/shared/TransactionDetails.es.js.map +1 -1
  86. package/dist/transactions/components/shared/transactiondetails/Description.d.ts +2 -0
  87. package/dist/transactions/components/shared/transactiondetails/Description.es.js +59 -50
  88. package/dist/transactions/components/shared/transactiondetails/Description.es.js.map +1 -1
  89. package/dist/transactions/components/shared/transactiondetails/TransactionHeaderParts.d.ts +10 -0
  90. package/dist/transactions/components/shared/transactiondetails/TransactionHeaderParts.es.js +68 -0
  91. package/dist/transactions/components/shared/transactiondetails/TransactionHeaderParts.es.js.map +1 -0
  92. package/package.json +1 -1
@@ -1,12 +1,12 @@
1
- import { DATE_FORMATS_INTL as h, formatDate as _ } from "../../../core/constants/DateFormats.es.js";
1
+ import { DATE_FORMATS_INTL as h, formatDate as f } from "../../../core/constants/DateFormats.es.js";
2
2
  import { fromUnixUTC as p } from "../../../core/utils/DateUtil.es.js";
3
3
  import { buildChartData as u, buildDataSeries as c } from "../../blocks/ChartBlocks/BarchartBlock/utils.es.js";
4
4
  import { buildComparisonSeries as D } from "../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js";
5
- import { DRILLDOWN_VARIANTS as l, FALLBACK as T, layout as b } from "./layout.es.js";
6
- import { format as y, isValid as B, parseISO as m } from "date-fns";
7
- var M = (t) => b[t] ?? T, E = ({ data: t, ariaLabel: e, top: a, beatTransactions: o }) => {
5
+ import { DRILLDOWN_VARIANTS as l, FALLBACK as T, layout as B } from "./layout.es.js";
6
+ import { format as b, isValid as S, parseISO as m } from "date-fns";
7
+ var M = (t) => B[t] ?? T, U = ({ data: t, ariaLabel: e, top: a, beatTransactions: o }) => {
8
8
  if (a === "upcomingBill") {
9
- const r = v(o);
9
+ const r = C(o);
10
10
  return {
11
11
  dataSeries: r,
12
12
  chartData: u(r, e).map((n, d) => r[d].label ? {
@@ -42,48 +42,48 @@ var M = (t) => b[t] ?? T, E = ({ data: t, ariaLabel: e, top: a, beatTransactions
42
42
  comparisonBars: []
43
43
  };
44
44
  }
45
- }, S = "TRN-projected-bill", g = (t) => ({
46
- date: y(p(t.date), "yyyy-MM-dd"),
45
+ }, y = "TRN-projected-bill", g = (t) => ({
46
+ date: b(p(t.date), "yyyy-MM-dd"),
47
47
  amount: t.amount,
48
48
  guid: t.guid,
49
49
  category_guid: t.top_level_category_guid ?? t.category_guid
50
- }), A = (t) => {
50
+ }), v = (t) => {
51
51
  const e = t[t.length - 1];
52
52
  return e?.guid !== "TRN-projected-bill" ? { transactions: t } : {
53
53
  transactions: t.slice(0, -1),
54
54
  projectedTransaction: e
55
55
  };
56
- }, v = (t = []) => {
57
- const { transactions: e, projectedTransaction: a } = A(t);
56
+ }, C = (t = []) => {
57
+ const { transactions: e, projectedTransaction: a } = v(t);
58
58
  if (!a || !e.length) return [];
59
- const o = [...e].sort((s, f) => s.date - f.date), i = /* @__PURE__ */ new Set(), r = [];
59
+ const o = [...e].sort((s, _) => s.date - _.date), i = /* @__PURE__ */ new Set(), r = [];
60
60
  for (const s of o)
61
61
  i.has(s.date) || (i.add(s.date), r.push(g(s)));
62
62
  const n = [...r, g(a)], d = n.map((s) => s.date.slice(0, 7));
63
63
  return new Set(d).size === d.length ? n : n.map((s) => ({
64
64
  ...s,
65
- label: _(m(s.date), h.MONTH_DAY)
65
+ label: f(m(s.date), h.MONTH_DAY)
66
66
  }));
67
- }, L = (t = [], e) => {
67
+ }, j = (t = [], e) => {
68
68
  if (!(!t.length || e?.date == null || e?.amount == null))
69
69
  return {
70
70
  ...t.reduce((a, o) => o.date > a.date ? o : a),
71
- guid: S,
71
+ guid: y,
72
72
  amount: e.amount,
73
- date: C(e.date),
73
+ date: x(e.date),
74
74
  has_been_split: !1,
75
75
  is_hidden: !1,
76
76
  is_flagged: !1,
77
77
  parent_guid: null
78
78
  };
79
- }, U = (t, e, a) => {
79
+ }, E = (t, e, a) => {
80
80
  const o = e.insights_feed?.general?.transaction_history_title ?? "", i = e.insights_feed?.transaction_history_block;
81
81
  if (t === l.TRANSACTION) return o;
82
82
  const r = a?.insights_payload?.title;
83
83
  if (t === l.ACCOUNT_BALANCE && r) return r;
84
84
  const n = t === l.DEBT_TO_INCOME ? "monthly_debt_to_income_drawer_title" : `${t}_drawer_title`;
85
85
  return i?.[n] ?? o;
86
- }, j = (t, e) => ({
86
+ }, L = (t, e) => ({
87
87
  accounts: t.accounts ?? e.allAccountGuids,
88
88
  dateRange: t.dateRange ?? e.displayedDateRange,
89
89
  custom: t.custom ?? (() => !0),
@@ -97,7 +97,7 @@ var M = (t) => b[t] ?? T, E = ({ data: t, ariaLabel: e, top: a, beatTransactions
97
97
  chartBarIndex: Math.max(0, i - 1),
98
98
  subTabIndex: d
99
99
  };
100
- }, C = (t) => Date.parse(`${t}T00:00:00Z`) / 1e3, H = (t) => typeof t == "number" && Number.isFinite(t) ? t : void 0, G = (t) => typeof t == "string" && t.trim() !== "" ? t : void 0, P = (t) => Array.isArray(t) && t.length > 0 && t.every((e) => typeof e == "string" && e !== "") ? t : void 0, V = (t) => typeof t == "string" && /^\d{4}-\d{2}-\d{2}$/.test(t) && B(m(t)) ? t : void 0, $ = ({ series: t, category_guid: e, average_amount: a, additional_data: o }) => {
100
+ }, x = (t) => Date.parse(`${t}T00:00:00Z`) / 1e3, H = (t) => typeof t == "string" && /^\d{4}-\d{2}-\d{2}$/.test(t) && S(m(t)) ? t : void 0, G = ({ series: t, category_guid: e, average_amount: a, additional_data: o }) => {
101
101
  const i = c(t).map(({ guid: r }) => r).filter((r) => !!r);
102
102
  return {
103
103
  data_series: t,
@@ -106,7 +106,7 @@ var M = (t) => b[t] ?? T, E = ({ data: t, ariaLabel: e, top: a, beatTransactions
106
106
  legends: o,
107
107
  transaction_guids: i.length ? i : void 0
108
108
  };
109
- }, k = (t) => {
109
+ }, P = (t) => {
110
110
  if (t)
111
111
  return {
112
112
  text: t.subtitle ?? "",
@@ -117,22 +117,19 @@ var M = (t) => b[t] ?? T, E = ({ data: t, ariaLabel: e, top: a, beatTransactions
117
117
  };
118
118
  };
119
119
  export {
120
- S as PROJECTED_BILL_GUID,
121
- L as buildProjectedBillTransaction,
122
- v as buildUpcomingBillSeries,
123
- V as calendarDateOf,
124
- H as finiteNumberOf,
120
+ y as PROJECTED_BILL_GUID,
121
+ j as buildProjectedBillTransaction,
122
+ C as buildUpcomingBillSeries,
123
+ H as calendarDateOf,
125
124
  F as getDefaultSelection,
126
- U as getDrawerHeaderTitle,
125
+ E as getDrawerHeaderTitle,
127
126
  M as getDrillDownConfig,
128
- E as getFlattenedDataSeries,
129
- P as guidListOf,
130
- G as nonEmptyStringOf,
131
- k as resolveDrillDownSubHeader,
132
- A as splitProjectedTransaction,
133
- $ as toDrillDownSlotData,
134
- j as toStoreFilter,
135
- C as utcDayToUnix
127
+ U as getFlattenedDataSeries,
128
+ P as resolveDrillDownSubHeader,
129
+ v as splitProjectedTransaction,
130
+ G as toDrillDownSlotData,
131
+ L as toStoreFilter,
132
+ x as utcDayToUnix
136
133
  };
137
134
 
138
135
  //# sourceMappingURL=utils.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/utils.ts"],"sourcesContent":["import { format, isValid, parseISO } from 'date-fns'\n\nimport type {\n ActionDrawerState,\n Beat,\n DataSeries,\n DrilldownPayload,\n DrilldownData,\n GlobalCopy,\n InsightsPayload,\n Subtitle,\n Transaction,\n} from '../../../core'\nimport type {\n BarChartBlockData,\n DataSet,\n InsightsInstanceSlotData,\n} from '../../../core/types/InsightsInstanceSlotData'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../core/constants'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport { fromUnixUTC } from '../../../core/utils/DateUtil'\nimport {\n buildChartData,\n buildDataSeries,\n type ChartDataSeriesItem,\n} from '../../blocks/ChartBlocks/BarchartBlock/utils'\nimport { buildComparisonSeries } from '../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils'\nimport {\n layout,\n FALLBACK,\n DRILLDOWN_VARIANTS,\n DrillDownVariant,\n DrillDownVariantConfig,\n} from './layout'\nimport { TransactionHistoryBlock } from '../../../core/types/localization/InsightsFeedCopy'\n\ninterface DefaultSelectionProp {\n chartTabCount: number\n comparisonTabCount: number\n actionDrawer: ActionDrawerState\n beatGuid: string\n}\nexport const getDrillDownConfig = (variant?: string): DrillDownVariantConfig =>\n layout[variant as DrillDownVariant] ?? FALLBACK\n\n// The shaped chart inputs a drill-down needs, derived once from the beat's data_series. `dataSeries`\n// is the flat per-bar source (indexes the filterStrategy); `chartData` feeds the single-bar chart;\n// `comparisonBars` feeds the double-bar chart and its month tabs (empty for every other top kind).\nexport interface FlattenedDataSeries {\n dataSeries: ChartDataSeriesItem[]\n chartData: ReturnType<typeof buildChartData>\n comparisonBars: DataSet[]\n}\n\n/**\n * Shapes the beat's raw data_series into the chart inputs for the variant's top kind: the single-bar\n * family (singleBar / upcomingBill), the double bar's month columns, or a tabs-only drawer's sides.\n */\ninterface FlattenedDataSeriesInput {\n data: DataSeries | undefined\n ariaLabel: string\n top: DrillDownVariantConfig['top']\n // UpcomingBill has no data_series; it builds its bars from these instead (its paid bills plus the\n // projected bill its `beatTransactions` resolver appends).\n beatTransactions: Transaction[]\n}\n\nexport const getFlattenedDataSeries = ({\n data,\n ariaLabel,\n top,\n beatTransactions,\n}: FlattenedDataSeriesInput): FlattenedDataSeries => {\n // UpcomingBill has no backend data_series: a bar per month of paid bills plus the projected bill,\n // each named by its month (buildChartData's default MONTH_SHORT) as the design labels it. A\n // projected bill sharing the latest paid month keeps its own day label.\n if (top === 'upcomingBill') {\n const dataSeries = buildUpcomingBillSeries(beatTransactions)\n const chartData = buildChartData(dataSeries, ariaLabel).map((bar, index) =>\n dataSeries[index].label ? { ...bar, label: dataSeries[index].label } : bar,\n )\n return { dataSeries, chartData, comparisonBars: [] }\n }\n\n // Tabs only: the rows are the sides of one month, not bars. They keep their wire order, which the\n // side tabs and the filter's dataSeries[subIndex] both index; there is no chart and no month tab.\n if (top === 'tabsOnly') {\n return {\n dataSeries: buildDataSeries(data).filter((row) => row.localized_label),\n chartData: [],\n comparisonBars: [],\n }\n }\n\n // List: one account over a window the strategy reads from the beat; no series, chart or tabs.\n if (top === 'list') {\n return { dataSeries: [], chartData: [], comparisonBars: [] }\n }\n\n // The month families: the backend sends data_series newest-first, so normalize it date-ascending\n // here. chartData/tabs and the filter's dataSeries[selectedIndex] indexing both read this one\n // array, so they stay aligned and the last tab is the most recent month.\n const dataSeries = [...buildDataSeries(data)].sort((a, b) => {\n if (!a.date || !b.date) return 0\n\n return new Date(a.date).getTime() - new Date(b.date).getTime()\n })\n\n switch (top) {\n // Double bar: comparison beats build paired month columns (with their guids) instead of chartData.\n case 'doubleBar':\n return { dataSeries, chartData: [], comparisonBars: buildComparisonSeries(data, ariaLabel) }\n // Single bar draws chartData as bars; month tabs reads the same chartData for its tabs only.\n case 'singleBar':\n case 'monthTabs':\n return { dataSeries, chartData: buildChartData(dataSeries, ariaLabel), comparisonBars: [] }\n }\n}\n\n// Sentinel guid for the synthesized projected bill. It intentionally matches no real store\n// transaction, so the projected tab lists only its Projected amount row.\nexport const PROJECTED_BILL_GUID = 'TRN-projected-bill'\n\n// One bar in the UpcomingBill chart. `date` is 'yyyy-MM-dd' so buildChartData/parseISO can read it.\n// `label` is set only when two bars share a month, so they are named by their day.\nexport interface UpcomingBillBar {\n date: string\n amount: number\n guid: string\n category_guid?: string\n label?: string\n}\n\n// The bill's UTC calendar day, the day the transaction list heads its row with\n// (fromUnixUTCToDayOfWeekAndDate); a local-time date put a UTC-midnight bill on the day before.\nconst toUpcomingBillBar = (transaction: Transaction): UpcomingBillBar => ({\n date: format(fromUnixUTC(transaction.date), 'yyyy-MM-dd'),\n amount: transaction.amount,\n guid: transaction.guid,\n category_guid: transaction.top_level_category_guid ?? transaction.category_guid,\n})\n\n/**\n * Splits a drawer's transactions into the real ones and the synthesized projected bill, which a\n * `beatTransactions` resolver (Upcoming Bill's) appends last under PROJECTED_BILL_GUID. Every other\n * variant has no projected bill, so its transactions pass through untouched.\n */\nexport const splitProjectedTransaction = (\n transactions: Transaction[],\n): { transactions: Transaction[]; projectedTransaction?: Transaction } => {\n const last = transactions[transactions.length - 1]\n if (last?.guid !== PROJECTED_BILL_GUID) return { transactions }\n\n return { transactions: transactions.slice(0, -1), projectedTransaction: last }\n}\n\n/**\n * UpcomingBill has no data_series: build the bar series from the drawer's transactions, its paid\n * bills plus the projected bill last (mirrors pulse's magicTransactions). Paid bills are sorted and\n * de-duped by date, each keeping its real guid so the guid filter finds it; the projected bar keeps\n * the PROJECTED_BILL_GUID sentinel and lands last. No projected bill (a missing due date or amount),\n * no bars. Bars are named by month; when two share a month, every bar is named by its day so no two\n * tabs read the same.\n */\nexport const buildUpcomingBillSeries = (transactions: Transaction[] = []): UpcomingBillBar[] => {\n const { transactions: paidBills, projectedTransaction } = splitProjectedTransaction(transactions)\n if (!projectedTransaction || !paidBills.length) return []\n\n const sorted = [...paidBills].sort((a, b) => a.date - b.date)\n\n const seenDates = new Set<number>()\n const history: UpcomingBillBar[] = []\n for (const transaction of sorted) {\n if (seenDates.has(transaction.date)) continue\n seenDates.add(transaction.date)\n history.push(toUpcomingBillBar(transaction))\n }\n\n const bars = [...history, toUpcomingBillBar(projectedTransaction)]\n\n const months = bars.map((bar) => bar.date.slice(0, 7))\n if (new Set(months).size === months.length) return bars\n\n return bars.map((bar) => ({\n ...bar,\n label: formatDate(parseISO(bar.date), DATE_FORMATS_INTL.MONTH_DAY),\n }))\n}\n\n/**\n * The transaction behind UpcomingBill's projected bar, as legacy pulse's drawer lists it under\n * \"Projected amount\": the latest paid bill's merchant and category with the due date and projected\n * amount, on the PROJECTED_BILL_GUID sentinel. Its split / hidden / flagged state is cleared so the\n * inert row never shows the paid bill's badges. Undefined without paid bills, a due date or amount.\n */\nexport const buildProjectedBillTransaction = (\n transactions: Transaction[] = [],\n payload: { date?: string; amount?: number } | undefined,\n): Transaction | undefined => {\n if (!transactions.length || payload?.date == null || payload?.amount == null) return undefined\n\n const latestBill = transactions.reduce((latest, t) => (t.date > latest.date ? t : latest))\n\n return {\n ...latestBill,\n guid: PROJECTED_BILL_GUID,\n amount: payload.amount,\n date: utcDayToUnix(payload.date),\n has_been_split: false,\n is_hidden: false,\n is_flagged: false,\n parent_guid: null,\n }\n}\n\nexport const getDrawerHeaderTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\n beat?: Beat,\n): string => {\n const transactionHistoryTitle = copy.insights_feed?.general?.transaction_history_title ?? ''\n const drawerTitleCopy = copy.insights_feed?.transaction_history_block as TransactionHistoryBlock\n\n if (variant === DRILLDOWN_VARIANTS.TRANSACTION) return transactionHistoryTitle\n\n // Savings Account Balances Summary: the drawer reads as the card it opens from (\"Savings\n // Contributions\", Figma 1135:50175), whatever the host's drawer copy says.\n const beatTitle = beat?.insights_payload?.title\n if (variant === DRILLDOWN_VARIANTS.ACCOUNT_BALANCE && beatTitle) return beatTitle\n\n // Safely access the drawer title from transaction_history_block. Debt to Income's ditto variant\n // (debt_to_income) keeps the host copy's existing monthly_debt_to_income_drawer_title.\n const key = (\n variant === DRILLDOWN_VARIANTS.DEBT_TO_INCOME\n ? 'monthly_debt_to_income_drawer_title'\n : `${variant}_drawer_title`\n ) as keyof TransactionHistoryBlock\n return (drawerTitleCopy?.[key] as string) ?? transactionHistoryTitle\n}\n\nexport const toStoreFilter = (\n filter: TransactionFilter,\n defaults: { allAccountGuids: string[]; displayedDateRange: { start: Date; end: Date } },\n): TransactionFilter => ({\n accounts: filter.accounts ?? defaults.allAccountGuids,\n dateRange: filter.dateRange ?? defaults.displayedDateRange,\n custom: filter.custom ?? (() => true),\n showSplits: filter.showSplits ?? false,\n})\n\nexport const getDefaultSelection = ({\n chartTabCount,\n comparisonTabCount,\n actionDrawer,\n beatGuid,\n}: DefaultSelectionProp): { chartBarIndex: number; subTabIndex: number } => {\n // A double-bar drawer's tabs are its comparison columns; every other drawer's are its chart bars.\n const tabCount = comparisonTabCount || chartTabCount\n const openedViaChartBar = actionDrawer.guid === beatGuid && actionDrawer.trigger === 'chartBar'\n\n // actionDrawer.context is an opaque `unknown` bag; narrow it to the shape the chart blocks write.\n const context = actionDrawer.context as DrilldownPayload | undefined\n const subTabIndex = openedViaChartBar ? (context?.tabIndex ?? 0) : 0\n\n if (openedViaChartBar) {\n const clamped = Math.min(Math.max(context?.chartBarIndex ?? 0, 0), Math.max(0, tabCount - 1))\n return { chartBarIndex: clamped, subTabIndex }\n }\n\n return { chartBarIndex: Math.max(0, tabCount - 1), subTabIndex }\n}\n\n/**\n * The drawer's facts: the generic slot facts plus the bar chart's average, and the merchant a\n * variant's tip names.\n */\nexport type DrillDownSlotData = InsightsInstanceSlotData &\n Pick<BarChartBlockData, 'average_amount'> & {\n merchant_name?: string\n // Monthly Deposit Summary: the deposits on the Income sub-tab, across every month.\n income_transaction_guids?: string[]\n // A drawer's own sub-tab names when the card's legend rows aren't the chart's (Income / Other Deposits).\n sub_tab_labels?: string[]\n }\n\n// A YYYY-MM-DD day as the epoch seconds of its UTC midnight: the day a transaction row is dated on\n// (fromUnixUTCToDayOfWeekAndDate), so a synthesized row agrees with the bars in every zone.\nexport const utcDayToUnix = (day: string): number => Date.parse(`${day}T00:00:00Z`) / 1000\n\n// Narrowing for drilldown_data's untyped values: each returns the value when it has the right shape,\n// else undefined, so a reader drops a missing or mistyped fact.\nexport const finiteNumberOf = (value: unknown): number | undefined =>\n typeof value === 'number' && Number.isFinite(value) ? value : undefined\n\nexport const nonEmptyStringOf = (value: unknown): string | undefined =>\n typeof value === 'string' && value.trim() !== '' ? value : undefined\n\nexport const guidListOf = (value: unknown): string[] | undefined =>\n Array.isArray(value) &&\n value.length > 0 &&\n value.every((item) => typeof item === 'string' && item !== '')\n ? (value as string[])\n : undefined\n\n// parseISO rejects impossible days such as 2026-02-30.\nexport const calendarDateOf = (value: unknown): string | undefined =>\n typeof value === 'string' && /^\\d{4}-\\d{2}-\\d{2}$/.test(value) && isValid(parseISO(value))\n ? value\n : undefined\n\n/**\n * Resolves the drawer's facts (bars, guids, colour, average, tip values) from the beat's payload, or\n * from the drilldown_data of the CTA that opened the drawer (`ctaDrilldownData`).\n */\nexport type SlotDataResolver = (\n payload: Partial<InsightsPayload> | undefined,\n ctaDrilldownData?: DrilldownData,\n) => DrillDownSlotData\n\n/**\n * Builds the drawer's transactions from the beat's own (its `transaction_guids` in the store) and\n * its facts, e.g. Upcoming Bill appends its projected bill. Absent: the beat's own, as they are.\n */\nexport type BeatTransactionsResolver = (\n transactions: Transaction[],\n slotData: DrillDownSlotData,\n) => Transaction[]\n\n/** The drawer's facts from a bar chart's `instance_slot.data` (variants with no `slotData`). */\nexport const toDrillDownSlotData = ({\n series,\n category_guid,\n average_amount,\n additional_data,\n}: BarChartBlockData): DrillDownSlotData => {\n const transactionGuids = buildDataSeries(series)\n .map(({ guid }) => guid)\n .filter((guid): guid is string => !!guid)\n\n return {\n data_series: series,\n category_guid,\n average_amount,\n legends: additional_data,\n transaction_guids: transactionGuids.length ? transactionGuids : undefined,\n }\n}\n\n/** The drawer's sub-heading: the merchant name and logo. */\nexport const resolveDrillDownSubHeader = (\n payload: Partial<InsightsPayload> | undefined,\n): Subtitle | undefined => {\n if (!payload) return undefined\n\n return {\n text: payload.subtitle ?? '',\n logo: { merchant_guid: payload.logo?.guid, category_guid: '' },\n }\n}\n"],"mappings":";;;;;;AA0CA,IAAa,IAAA,CAAsB,MACjC,EAAO,CAAA,KAAgC,GAwB5B,IAAA,CAA0B,EACrC,MAAA,GACA,WAAA,GACA,KAAA,GACA,kBAAA,EAAA,MACmD;AAInD,MAAI,MAAQ,gBAAgB;AAC1B,UAAM,IAAa,EAAwB,CAAgB;AAI3D,WAAO;AAAA,MAAE,YAAA;AAAA,MAAY,WAHH,EAAe,GAAY,CAAS,EAAE,IAAA,CAAK,GAAK,MAChE,EAAW,CAAA,EAAO,QAAQ;AAAA,QAAE,GAAG;AAAA,QAAK,OAAO,EAAW,CAAA,EAAO;AAAA,MAAM,IAAI,CAEpD;AAAA,MAAW,gBAAgB,CAAC;AAAA,IAAE;AAAA,EACrD;AAIA,MAAI,MAAQ,WACV,QAAO;AAAA,IACL,YAAY,EAAgB,CAAI,EAAE,OAAA,CAAQ,MAAQ,EAAI,eAAe;AAAA,IACrE,WAAW,CAAC;AAAA,IACZ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C,IAAA,CAAK,EAAE,MAAA,EAAA,MAAW,CAAI,EACtB,OAAA,CAAQ,MAAyB,CAAC,CAAC,CAAI;AAE1C,SAAO;AAAA,IACL,aAAa;AAAA,IACb,eAAA;AAAA,IACA,gBAAA;AAAA,IACA,SAAS;AAAA,IACT,mBAAmB,EAAiB,SAAS,IAAmB;AAAA,EAClE;AACF,GAGa,IAAA,CACX,MACyB;AACzB,MAAK;AAEL,WAAO;AAAA,MACL,MAAM,EAAQ,YAAY;AAAA,MAC1B,MAAM;AAAA,QAAE,eAAe,EAAQ,MAAM;AAAA,QAAM,eAAe;AAAA,MAAG;AAAA,IAC/D;AACF"}
1
+ {"version":3,"file":"utils.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/utils.ts"],"sourcesContent":["import { format, isValid, parseISO } from 'date-fns'\n\nimport type {\n ActionDrawerState,\n Beat,\n DataSeries,\n DrilldownPayload,\n DrilldownData,\n GlobalCopy,\n InsightsPayload,\n Subtitle,\n Transaction,\n} from '../../../core'\nimport type {\n BarChartBlockData,\n DataSet,\n InsightsInstanceSlotData,\n} from '../../../core/types/InsightsInstanceSlotData'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../core/constants'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport { fromUnixUTC } from '../../../core/utils/DateUtil'\nimport {\n buildChartData,\n buildDataSeries,\n type ChartDataSeriesItem,\n} from '../../blocks/ChartBlocks/BarchartBlock/utils'\nimport { buildComparisonSeries } from '../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils'\nimport {\n layout,\n FALLBACK,\n DRILLDOWN_VARIANTS,\n DrillDownVariant,\n DrillDownVariantConfig,\n} from './layout'\nimport { TransactionHistoryBlock } from '../../../core/types/localization/InsightsFeedCopy'\n\ninterface DefaultSelectionProp {\n chartTabCount: number\n comparisonTabCount: number\n actionDrawer: ActionDrawerState\n beatGuid: string\n}\nexport const getDrillDownConfig = (variant?: string): DrillDownVariantConfig =>\n layout[variant as DrillDownVariant] ?? FALLBACK\n\n// The shaped chart inputs a drill-down needs, derived once from the beat's data_series. `dataSeries`\n// is the flat per-bar source (indexes the filterStrategy); `chartData` feeds the single-bar chart;\n// `comparisonBars` feeds the double-bar chart and its month tabs (empty for every other top kind).\nexport interface FlattenedDataSeries {\n dataSeries: ChartDataSeriesItem[]\n chartData: ReturnType<typeof buildChartData>\n comparisonBars: DataSet[]\n}\n\n/**\n * Shapes the beat's raw data_series into the chart inputs for the variant's top kind: the single-bar\n * family (singleBar / upcomingBill), the double bar's month columns, or a tabs-only drawer's sides.\n */\ninterface FlattenedDataSeriesInput {\n data: DataSeries | undefined\n ariaLabel: string\n top: DrillDownVariantConfig['top']\n // UpcomingBill has no data_series; it builds its bars from these instead (its paid bills plus the\n // projected bill its `beatTransactions` resolver appends).\n beatTransactions: Transaction[]\n}\n\nexport const getFlattenedDataSeries = ({\n data,\n ariaLabel,\n top,\n beatTransactions,\n}: FlattenedDataSeriesInput): FlattenedDataSeries => {\n // UpcomingBill has no backend data_series: a bar per month of paid bills plus the projected bill,\n // each named by its month (buildChartData's default MONTH_SHORT) as the design labels it. A\n // projected bill sharing the latest paid month keeps its own day label.\n if (top === 'upcomingBill') {\n const dataSeries = buildUpcomingBillSeries(beatTransactions)\n const chartData = buildChartData(dataSeries, ariaLabel).map((bar, index) =>\n dataSeries[index].label ? { ...bar, label: dataSeries[index].label } : bar,\n )\n return { dataSeries, chartData, comparisonBars: [] }\n }\n\n // Tabs only: the rows are the sides of one month, not bars. They keep their wire order, which the\n // side tabs and the filter's dataSeries[subIndex] both index; there is no chart and no month tab.\n if (top === 'tabsOnly') {\n return {\n dataSeries: buildDataSeries(data).filter((row) => row.localized_label),\n chartData: [],\n comparisonBars: [],\n }\n }\n\n // List: one account over a window the strategy reads from the beat; no series, chart or tabs.\n if (top === 'list') {\n return { dataSeries: [], chartData: [], comparisonBars: [] }\n }\n\n // The month families: the backend sends data_series newest-first, so normalize it date-ascending\n // here. chartData/tabs and the filter's dataSeries[selectedIndex] indexing both read this one\n // array, so they stay aligned and the last tab is the most recent month.\n const dataSeries = [...buildDataSeries(data)].sort((a, b) => {\n if (!a.date || !b.date) return 0\n\n return new Date(a.date).getTime() - new Date(b.date).getTime()\n })\n\n switch (top) {\n // Double bar: comparison beats build paired month columns (with their guids) instead of chartData.\n case 'doubleBar':\n return { dataSeries, chartData: [], comparisonBars: buildComparisonSeries(data, ariaLabel) }\n // Single bar draws chartData as bars; month tabs reads the same chartData for its tabs only.\n case 'singleBar':\n case 'monthTabs':\n return { dataSeries, chartData: buildChartData(dataSeries, ariaLabel), comparisonBars: [] }\n }\n}\n\n// Sentinel guid for the synthesized projected bill. It intentionally matches no real store\n// transaction, so the projected tab lists only its Projected amount row.\nexport const PROJECTED_BILL_GUID = 'TRN-projected-bill'\n\n// One bar in the UpcomingBill chart. `date` is 'yyyy-MM-dd' so buildChartData/parseISO can read it.\n// `label` is set only when two bars share a month, so they are named by their day.\nexport interface UpcomingBillBar {\n date: string\n amount: number\n guid: string\n category_guid?: string\n label?: string\n}\n\n// The bill's UTC calendar day, the day the transaction list heads its row with\n// (fromUnixUTCToDayOfWeekAndDate); a local-time date put a UTC-midnight bill on the day before.\nconst toUpcomingBillBar = (transaction: Transaction): UpcomingBillBar => ({\n date: format(fromUnixUTC(transaction.date), 'yyyy-MM-dd'),\n amount: transaction.amount,\n guid: transaction.guid,\n category_guid: transaction.top_level_category_guid ?? transaction.category_guid,\n})\n\n/**\n * Splits a drawer's transactions into the real ones and the synthesized projected bill, which a\n * `beatTransactions` resolver (Upcoming Bill's) appends last under PROJECTED_BILL_GUID. Every other\n * variant has no projected bill, so its transactions pass through untouched.\n */\nexport const splitProjectedTransaction = (\n transactions: Transaction[],\n): { transactions: Transaction[]; projectedTransaction?: Transaction } => {\n const last = transactions[transactions.length - 1]\n if (last?.guid !== PROJECTED_BILL_GUID) return { transactions }\n\n return { transactions: transactions.slice(0, -1), projectedTransaction: last }\n}\n\n/**\n * UpcomingBill has no data_series: build the bar series from the drawer's transactions, its paid\n * bills plus the projected bill last (mirrors pulse's magicTransactions). Paid bills are sorted and\n * de-duped by date, each keeping its real guid so the guid filter finds it; the projected bar keeps\n * the PROJECTED_BILL_GUID sentinel and lands last. No projected bill (a missing due date or amount),\n * no bars. Bars are named by month; when two share a month, every bar is named by its day so no two\n * tabs read the same.\n */\nexport const buildUpcomingBillSeries = (transactions: Transaction[] = []): UpcomingBillBar[] => {\n const { transactions: paidBills, projectedTransaction } = splitProjectedTransaction(transactions)\n if (!projectedTransaction || !paidBills.length) return []\n\n const sorted = [...paidBills].sort((a, b) => a.date - b.date)\n\n const seenDates = new Set<number>()\n const history: UpcomingBillBar[] = []\n for (const transaction of sorted) {\n if (seenDates.has(transaction.date)) continue\n seenDates.add(transaction.date)\n history.push(toUpcomingBillBar(transaction))\n }\n\n const bars = [...history, toUpcomingBillBar(projectedTransaction)]\n\n const months = bars.map((bar) => bar.date.slice(0, 7))\n if (new Set(months).size === months.length) return bars\n\n return bars.map((bar) => ({\n ...bar,\n label: formatDate(parseISO(bar.date), DATE_FORMATS_INTL.MONTH_DAY),\n }))\n}\n\n/**\n * The transaction behind UpcomingBill's projected bar, as legacy pulse's drawer lists it under\n * \"Projected amount\": the latest paid bill's merchant and category with the due date and projected\n * amount, on the PROJECTED_BILL_GUID sentinel. Its split / hidden / flagged state is cleared so the\n * inert row never shows the paid bill's badges. Undefined without paid bills, a due date or amount.\n */\nexport const buildProjectedBillTransaction = (\n transactions: Transaction[] = [],\n payload: { date?: string; amount?: number } | undefined,\n): Transaction | undefined => {\n if (!transactions.length || payload?.date == null || payload?.amount == null) return undefined\n\n const latestBill = transactions.reduce((latest, t) => (t.date > latest.date ? t : latest))\n\n return {\n ...latestBill,\n guid: PROJECTED_BILL_GUID,\n amount: payload.amount,\n date: utcDayToUnix(payload.date),\n has_been_split: false,\n is_hidden: false,\n is_flagged: false,\n parent_guid: null,\n }\n}\n\nexport const getDrawerHeaderTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\n beat?: Beat,\n): string => {\n const transactionHistoryTitle = copy.insights_feed?.general?.transaction_history_title ?? ''\n const drawerTitleCopy = copy.insights_feed?.transaction_history_block as TransactionHistoryBlock\n\n if (variant === DRILLDOWN_VARIANTS.TRANSACTION) return transactionHistoryTitle\n\n // Savings Account Balances Summary: the drawer reads as the card it opens from (\"Savings\n // Contributions\", Figma 1135:50175), whatever the host's drawer copy says.\n const beatTitle = beat?.insights_payload?.title\n if (variant === DRILLDOWN_VARIANTS.ACCOUNT_BALANCE && beatTitle) return beatTitle\n\n // Safely access the drawer title from transaction_history_block. Debt to Income's ditto variant\n // (debt_to_income) keeps the host copy's existing monthly_debt_to_income_drawer_title.\n const key = (\n variant === DRILLDOWN_VARIANTS.DEBT_TO_INCOME\n ? 'monthly_debt_to_income_drawer_title'\n : `${variant}_drawer_title`\n ) as keyof TransactionHistoryBlock\n return (drawerTitleCopy?.[key] as string) ?? transactionHistoryTitle\n}\n\nexport const toStoreFilter = (\n filter: TransactionFilter,\n defaults: { allAccountGuids: string[]; displayedDateRange: { start: Date; end: Date } },\n): TransactionFilter => ({\n accounts: filter.accounts ?? defaults.allAccountGuids,\n dateRange: filter.dateRange ?? defaults.displayedDateRange,\n custom: filter.custom ?? (() => true),\n showSplits: filter.showSplits ?? false,\n})\n\nexport const getDefaultSelection = ({\n chartTabCount,\n comparisonTabCount,\n actionDrawer,\n beatGuid,\n}: DefaultSelectionProp): { chartBarIndex: number; subTabIndex: number } => {\n // A double-bar drawer's tabs are its comparison columns; every other drawer's are its chart bars.\n const tabCount = comparisonTabCount || chartTabCount\n const openedViaChartBar = actionDrawer.guid === beatGuid && actionDrawer.trigger === 'chartBar'\n\n // actionDrawer.context is an opaque `unknown` bag; narrow it to the shape the chart blocks write.\n const context = actionDrawer.context as DrilldownPayload | undefined\n const subTabIndex = openedViaChartBar ? (context?.tabIndex ?? 0) : 0\n\n if (openedViaChartBar) {\n const clamped = Math.min(Math.max(context?.chartBarIndex ?? 0, 0), Math.max(0, tabCount - 1))\n return { chartBarIndex: clamped, subTabIndex }\n }\n\n return { chartBarIndex: Math.max(0, tabCount - 1), subTabIndex }\n}\n\n/**\n * The drawer's facts: the generic slot facts plus the bar chart's average, and the merchant a\n * variant's tip names.\n */\nexport type DrillDownSlotData = InsightsInstanceSlotData &\n Pick<BarChartBlockData, 'average_amount'> & {\n merchant_name?: string\n // Monthly Deposit Summary: the deposits on the Income sub-tab, across every month.\n income_transaction_guids?: string[]\n // A drawer's own sub-tab names when the card's legend rows aren't the chart's (Income / Other Deposits).\n sub_tab_labels?: string[]\n }\n\n// A YYYY-MM-DD day as the epoch seconds of its UTC midnight: the day a transaction row is dated on\n// (fromUnixUTCToDayOfWeekAndDate), so a synthesized row agrees with the bars in every zone.\nexport const utcDayToUnix = (day: string): number => Date.parse(`${day}T00:00:00Z`) / 1000\n\n// parseISO rejects impossible days such as 2026-02-30.\nexport const calendarDateOf = (value: unknown): string | undefined =>\n typeof value === 'string' && /^\\d{4}-\\d{2}-\\d{2}$/.test(value) && isValid(parseISO(value))\n ? value\n : undefined\n\n/**\n * Resolves the drawer's facts (bars, guids, colour, average, tip values) from the beat's payload, or\n * from the drilldown_data of the CTA that opened the drawer (`ctaDrilldownData`).\n */\nexport type SlotDataResolver = (\n payload: Partial<InsightsPayload> | undefined,\n ctaDrilldownData?: DrilldownData,\n) => DrillDownSlotData\n\n/**\n * Builds the drawer's transactions from the beat's own (its `transaction_guids` in the store) and\n * its facts, e.g. Upcoming Bill appends its projected bill. Absent: the beat's own, as they are.\n */\nexport type BeatTransactionsResolver = (\n transactions: Transaction[],\n slotData: DrillDownSlotData,\n) => Transaction[]\n\n/** The drawer's facts from a bar chart's `instance_slot.data` (variants with no `slotData`). */\nexport const toDrillDownSlotData = ({\n series,\n category_guid,\n average_amount,\n additional_data,\n}: BarChartBlockData): DrillDownSlotData => {\n const transactionGuids = buildDataSeries(series)\n .map(({ guid }) => guid)\n .filter((guid): guid is string => !!guid)\n\n return {\n data_series: series,\n category_guid,\n average_amount,\n legends: additional_data,\n transaction_guids: transactionGuids.length ? transactionGuids : undefined,\n }\n}\n\n/** The drawer's sub-heading: the merchant name and logo. */\nexport const resolveDrillDownSubHeader = (\n payload: Partial<InsightsPayload> | undefined,\n): Subtitle | undefined => {\n if (!payload) return undefined\n\n return {\n text: payload.subtitle ?? '',\n logo: { merchant_guid: payload.logo?.guid, category_guid: '' },\n }\n}\n"],"mappings":";;;;;;AA0CA,IAAa,IAAA,CAAsB,MACjC,EAAO,CAAA,KAAgC,GAwB5B,IAAA,CAA0B,EACrC,MAAA,GACA,WAAA,GACA,KAAA,GACA,kBAAA,EAAA,MACmD;AAInD,MAAI,MAAQ,gBAAgB;AAC1B,UAAM,IAAa,EAAwB,CAAgB;AAI3D,WAAO;AAAA,MAAE,YAAA;AAAA,MAAY,WAHH,EAAe,GAAY,CAAS,EAAE,IAAA,CAAK,GAAK,MAChE,EAAW,CAAA,EAAO,QAAQ;AAAA,QAAE,GAAG;AAAA,QAAK,OAAO,EAAW,CAAA,EAAO;AAAA,MAAM,IAAI,CAEpD;AAAA,MAAW,gBAAgB,CAAC;AAAA,IAAE;AAAA,EACrD;AAIA,MAAI,MAAQ,WACV,QAAO;AAAA,IACL,YAAY,EAAgB,CAAI,EAAE,OAAA,CAAQ,MAAQ,EAAI,eAAe;AAAA,IACrE,WAAW,CAAC;AAAA,IACZ,gBAAgB,CAAC;AAAA,EACnB;AAIF,MAAI,MAAQ,OACV,QAAO;AAAA,IAAE,YAAY,CAAC;AAAA,IAAG,WAAW,CAAC;AAAA,IAAG,gBAAgB,CAAC;AAAA,EAAE;AAM7D,QAAM,IAAa,CAAC,GAAG,EAAgB,CAAI,CAAC,EAAE,KAAA,CAAM,GAAG,MACjD,CAAC,EAAE,QAAQ,CAAC,EAAE,OAAa,IAExB,IAAI,KAAK,EAAE,IAAI,EAAE,QAAQ,IAAI,IAAI,KAAK,EAAE,IAAI,EAAE,QAAQ,CAC9D;AAED,U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AAa,SACvB,IAAc,IAAqB,GAAS,YAAY,IAAK;AAEnE,SAAI,IAEK;AAAA,IAAE,eADO,KAAK,IAAI,KAAK,IAAI,GAAS,iBAAiB,GAAG,CAAC,GAAG,KAAK,IAAI,GAAG,IAAW,CAAC,CACnE;AAAA,IAAS,aAAA;AAAA,EAAY,IAGxC;AAAA,IAAE,eAAe,KAAK,IAAI,GAAG,IAAW,CAAC;AAAA,IAAG,aAAA;AAAA,EAAY;AACjE,GAiBa,IAAA,CAAgB,MAAwB,KAAK,MAAM,GAAG,CAAA,YAAe,IAAI,KAGzE,IAAA,CAAkB,MAC7B,OAAO,KAAU,YAAY,sBAAsB,KAAK,CAAK,KAAK,EAAQ,EAAS,CAAK,CAAC,IACrF,IACA,QAqBO,IAAA,CAAuB,EAClC,QAAA,GACA,eAAA,GACA,gBAAA,GACA,iBAAA,EAAA,MAC0C;AAC1C,QAAM,IAAmB,EAAgB,CAAM,EAC5C,IAAA,CAAK,EAAE,MAAA,EAAA,MAAW,CAAI,EACtB,OAAA,CAAQ,MAAyB,CAAC,CAAC,CAAI;AAE1C,SAAO;AAAA,IACL,aAAa;AAAA,IACb,eAAA;AAAA,IACA,gBAAA;AAAA,IACA,SAAS;AAAA,IACT,mBAAmB,EAAiB,SAAS,IAAmB;AAAA,EAClE;AACF,GAGa,IAAA,CACX,MACyB;AACzB,MAAK;AAEL,WAAO;AAAA,MACL,MAAM,EAAQ,YAAY;AAAA,MAC1B,MAAM;AAAA,QAAE,eAAe,EAAQ,MAAM;AAAA,QAAM,eAAe;AAAA,MAAG;AAAA,IAC/D;AACF"}
@@ -1,33 +1,34 @@
1
- import { readHelp as m, toText as o } from "../HelpBlock/layout.es.js";
1
+ import { asNonEmptyText as o, asNumber as m } from "../../blocks/slotReaders.es.js";
2
+ import { readHelp as E } from "../HelpBlock/layout.es.js";
2
3
  import { parseISO as c } from "date-fns/parseISO";
3
4
  var n = {
4
5
  SUMMARY_HEADER: "summary_header",
5
6
  GENERIC_LIST: "generic_list",
6
7
  HELP_HEADER: "help_header",
7
8
  DEPOSIT_HISTORY: "deposit_history"
8
- }, E = n.HELP_HEADER, h = (t, e, r) => {
9
+ }, f = n.HELP_HEADER, A = (t, r, e) => {
9
10
  switch (t) {
10
11
  case n.GENERIC_LIST:
11
12
  case n.HELP_HEADER:
12
- return e.transactions?.transactions_title ?? "";
13
+ return r.transactions?.transactions_title ?? "";
13
14
  case n.DEPOSIT_HISTORY:
14
- return e.insights_feed?.transaction_list_block?.deposit_history_drawer_title ?? "";
15
+ return r.insights_feed?.transaction_list_block?.deposit_history_drawer_title ?? "";
15
16
  default:
16
- return r?.insights_payload?.title ?? "";
17
+ return e?.insights_payload?.title ?? "";
17
18
  }
18
- }, A = (t, e) => {
19
- if (t?.variant !== E) return;
20
- const r = o(e?.help_label), a = m(e);
19
+ }, D = (t, r) => {
20
+ if (t?.variant !== f) return;
21
+ const e = o(r?.help_label), a = E(r);
21
22
  return {
22
- descriptionHtml: o(e?.description_html),
23
- ...r && a && { learnMore: {
23
+ descriptionHtml: o(r?.description_html),
24
+ ...e && a && { learnMore: {
24
25
  ...a,
25
- label: r
26
+ label: e
26
27
  } }
27
28
  };
28
- }, f = (t) => typeof t == "number" && Number.isFinite(t) ? t : void 0, p = (t) => typeof t == "number" && Number.isInteger(t) && t > 0 ? t : void 0, l = Date.UTC(2e3, 0, 1), u = Date.UTC(2100, 0, 1), s = /* @__PURE__ */ new WeakSet(), _ = (t, e) => {
29
- s.has(t) || (s.add(t), console.warn(e));
30
- }, d = (t, e, r) => {
29
+ }, l = (t) => typeof t == "number" && Number.isInteger(t) && t > 0 ? t : void 0, p = Date.UTC(2e3, 0, 1), u = Date.UTC(2100, 0, 1), s = /* @__PURE__ */ new WeakSet(), _ = (t, r) => {
30
+ s.has(t) || (s.add(t), console.warn(r));
31
+ }, d = (t, r, e) => {
31
32
  if (t == null || t === "") return;
32
33
  let a;
33
34
  if (typeof t == "number" && Number.isFinite(t)) a = t < 1e12 ? t * 1e3 : t;
@@ -35,33 +36,33 @@ var n = {
35
36
  const i = c(t).getTime();
36
37
  a = Number.isNaN(i) ? void 0 : i;
37
38
  }
38
- if (a === void 0 || a < l || a > u) {
39
- _(r, `[TransactionListBlock] drilldown_data.${e} is unparseable or out of range (${typeof t})`);
39
+ if (a === void 0 || a < p || a > u) {
40
+ _(e, `[TransactionListBlock] drilldown_data.${r} is unparseable or out of range (${typeof t})`);
40
41
  return;
41
42
  }
42
43
  return new Date(a);
43
- }, D = (t) => {
44
+ }, I = (t) => {
44
45
  if (t?.variant !== n.SUMMARY_HEADER) return;
45
- const e = t?.drilldown_data;
46
- if (!e) return;
47
- const r = f(e.amount);
48
- if (r === void 0) {
49
- Object.keys(e).length > 0 && _(e, "[TransactionListBlock] drilldown_data has no finite `amount` — no summary header.");
46
+ const r = t?.drilldown_data;
47
+ if (!r) return;
48
+ const e = m(r.amount);
49
+ if (e === void 0) {
50
+ Object.keys(r).length > 0 && _(r, "[TransactionListBlock] drilldown_data has no finite `amount` — no summary header.");
50
51
  return;
51
52
  }
52
53
  return {
53
- amount: r,
54
- startDate: d(e.start_date, "start_date", e),
55
- endDate: d(e.end_date, "end_date", e),
56
- count: p(e.count)
54
+ amount: e,
55
+ startDate: d(r.start_date, "start_date", r),
56
+ endDate: d(r.end_date, "end_date", r),
57
+ count: l(r.count)
57
58
  };
58
59
  };
59
60
  export {
60
- E as HELP_HEADER_VARIANT,
61
+ f as HELP_HEADER_VARIANT,
61
62
  n as TRANSACTION_LIST_VARIANTS,
62
- h as getTransactionListDrawerTitle,
63
- A as readHelpHeader,
64
- D as readSummary
63
+ A as getTransactionListDrawerTitle,
64
+ D as readHelpHeader,
65
+ I as readSummary
65
66
  };
66
67
 
67
68
  //# sourceMappingURL=layout.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionListBlock/layout.ts"],"sourcesContent":["import { parseISO } from 'date-fns/parseISO'\n\nimport type {\n Beat,\n DrilldownData,\n GlobalCopy,\n InDescriptionCTA,\n PrimaryCTA,\n SecondaryCTA,\n} from '../../../core'\nimport { readHelp, toText, type HelpContent } from '../HelpBlock/layout'\n\ntype DrilldownCta = PrimaryCTA | SecondaryCTA | InDescriptionCTA\n\n/** The transaction_list_block CTA variants. */\nexport const TRANSACTION_LIST_VARIANTS = {\n SUMMARY_HEADER: 'summary_header',\n GENERIC_LIST: 'generic_list',\n /** Opens the list under the beat's title, description and \"Learn More\". */\n HELP_HEADER: 'help_header',\n /** Opens Micro Deposits' Deposit History list. */\n DEPOSIT_HISTORY: 'deposit_history',\n} as const\n\nexport const HELP_HEADER_VARIANT = TRANSACTION_LIST_VARIANTS.HELP_HEADER\n\n/** Drawer title: the variant's title when it has one, otherwise the beat's own title. Add new variants here. */\nexport const getTransactionListDrawerTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\n beat?: Beat,\n): string => {\n switch (variant) {\n case TRANSACTION_LIST_VARIANTS.GENERIC_LIST:\n case TRANSACTION_LIST_VARIANTS.HELP_HEADER:\n return copy.transactions?.transactions_title ?? ''\n case TRANSACTION_LIST_VARIANTS.DEPOSIT_HISTORY:\n return copy.insights_feed?.transaction_list_block?.deposit_history_drawer_title ?? ''\n default:\n return beat?.insights_payload?.title ?? ''\n }\n}\n\nexport interface HelpHeaderContent {\n /** Pre-localized HTML under the title, from the payload's `drilldown_data.description_html`. */\n descriptionHtml?: string\n /** The \"Learn More\" link and the help drawer it opens; absent when the beat carries no help. */\n learnMore?: HelpContent & { label: string }\n}\n\n/**\n * The help-header variant's text, read from the payload's `drilldown_data` (shared by every CTA\n * of the card): `description_html`, and `help_label` with the `help_title` / `help_html` that\n * `readHelp` reads. Only the `help_header` variant renders the block.\n */\nexport const readHelpHeader = (\n cta: DrilldownCta | undefined,\n drilldown: DrilldownData | undefined,\n): HelpHeaderContent | undefined => {\n if (cta?.variant !== HELP_HEADER_VARIANT) return undefined\n\n const label = toText(drilldown?.help_label)\n const help = readHelp(drilldown)\n\n return {\n descriptionHtml: toText(drilldown?.description_html),\n ...(label && help && { learnMore: { ...help, label } }),\n }\n}\n\nexport interface TransactionListSummary {\n /** Headline figure (e.g. total withdrawn). */\n amount: number\n /** Validated range endpoints; rendered as `{start} – {end}`. Omitted when the payload value is\n * missing or unparseable (so the drawer never crashes on an Invalid Date). */\n startDate?: Date\n endDate?: Date\n /** Number of transactions for the pill, from the CTA's `drilldown_data.count`. */\n count?: number\n}\n\nconst toFiniteNumber = (value: unknown): number | undefined =>\n typeof value === 'number' && Number.isFinite(value) ? value : undefined\n\n// `> 0`: the card only shows with >= 1 guid, so a `count` of 0 is dropped and falls back to the\n// guid count rather than rendering \"0 transactions\".\nconst toCount = (value: unknown): number | undefined =>\n typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : undefined\n\n// Sane epoch window so a bad/typo payload can't render a far-past/future date.\nconst EPOCH_MIN = Date.UTC(2000, 0, 1)\nconst EPOCH_MAX = Date.UTC(2100, 0, 1)\n\n// `readSummary` runs on every observer re-render (no `useMemo` by design), so warn at most once per\n// distinct payload object instead of on every render. Keyed on the `drilldown_data` object, which is\n// a stable reference across re-renders of the same beat.\nconst warnedPayloads = new WeakSet<object>()\nconst warnOncePerPayload = (source: object, message: string): void => {\n if (warnedPayloads.has(source)) return\n warnedPayloads.add(source)\n console.warn(message)\n}\n\n/**\n * Parse a payload date value to a validated `Date`, or `undefined`. Accepts unix seconds or\n * milliseconds (auto-detected) and ISO strings. Fails closed (no throw): an unparseable or\n * out-of-range value returns undefined and warns, so `formatDate`/`intlFormat` never sees an Invalid\n * Date (which throws `RangeError` and takes down the whole drawer render).\n */\nconst toDate = (value: unknown, field: string, source: object): Date | undefined => {\n // Missing/empty is a normal \"no range\" case — return quietly, don't warn.\n if (value === undefined || value === null || value === '') return undefined\n\n let ms: number | undefined\n if (typeof value === 'number' && Number.isFinite(value)) {\n // < 1e12 is treated as seconds (1e12 ms is year 33658). Trade-off: genuine ms timestamps from\n // ~2000-2001 would be misread as seconds and fall outside the window below (dropped, not shown).\n ms = value < 1e12 ? value * 1000 : value\n } else if (typeof value === 'string') {\n const parsed = parseISO(value).getTime()\n ms = Number.isNaN(parsed) ? undefined : parsed\n }\n\n if (ms === undefined || ms < EPOCH_MIN || ms > EPOCH_MAX) {\n warnOncePerPayload(\n source,\n `[TransactionListBlock] drilldown_data.${field} is unparseable or out of range (${typeof value})`,\n )\n return undefined\n }\n return new Date(ms)\n}\n\n/**\n * Summary-header figures for the drawer, read from the clicked CTA's `drilldown_data` (the backend\n * hangs a drilldown's own data off the CTA that opens it). Fails closed throughout: only the\n * `summary_header` variant renders a header (so figures from a different CTA that `getDynamicCta…`\n * fell back to can't be misattributed), then without a finite `amount` there is still no header, and\n * each date is validated to a real `Date` or dropped — an unparseable value never reaches\n * `formatDate` (which throws on an Invalid Date).\n *\n * `drilldown_data` fields: `amount` (number), `start_date`/`end_date` (unix seconds|ms or ISO),\n * `count` (number of transactions).\n */\nexport const readSummary = (cta: DrilldownCta | undefined): TransactionListSummary | undefined => {\n // Defense-in-depth on financial figures: only the summary-header variant shows the card.\n if (cta?.variant !== TRANSACTION_LIST_VARIANTS.SUMMARY_HEADER) return undefined\n\n const source = cta?.drilldown_data\n if (!source) return undefined\n\n const amount = toFiniteNumber(source.amount)\n if (amount === undefined) {\n // `drilldown_data` present but no usable amount -> surface the likely contract drift (field\n // rename) instead of a silently missing header.\n if (Object.keys(source).length > 0) {\n warnOncePerPayload(\n source,\n '[TransactionListBlock] drilldown_data has no finite `amount` — no summary header.',\n )\n }\n return undefined\n }\n\n return {\n amount,\n startDate: toDate(source.start_date, 'start_date', source),\n endDate: toDate(source.end_date, 'end_date', source),\n count: toCount(source.count),\n }\n}\n"],"mappings":";;AAeA,IAAa,IAA4B;AAAA,EACvC,gBAAgB;AAAA,EAChB,cAAc;AAAA,EAEd,aAAa;AAAA,EAEb,iBAAiB;AACnB,GAEa,IAAsB,EAA0B,aAGhD,IAAA,CACX,GACA,GACA,MACW;AACX,U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EA,MAAI,MAAO,UAAa,IAAK,KAAa,IAAK,GAAW;AACxD,IAAA,EACE,GACA,yCAAyC,CAAA,oCAAyC,OAAO,CAAA,GAC3F;AACA;AAAA,EACF;AACA,SAAO,IAAI,KAAK,CAAE;AACpB,GAaa,IAAA,CAAe,MAAsE;AAEhG,MAAI,GAAK,YAAY,EAA0B,eAAgB;AAE/D,QAAM,IAAS,GAAK;AACpB,MAAI,CAAC,EAAQ;AAEb,QAAM,IAAS,EAAe,EAAO,MAAM;AAC3C,MAAI,MAAW,QAAW;AAGxB,IAAI,OAAO,KAAK,CAAM,EAAE,SAAS,KAC/B,EACE,GACA,mFACF;AAEF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,QAAA;AAAA,IACA,WAAW,EAAO,EAAO,YAAY,cAAc,CAAM;AAAA,IACzD,SAAS,EAAO,EAAO,UAAU,YAAY,CAAM;AAAA,IACnD,OAAO,EAAQ,EAAO,KAAK;AAAA,EAC7B;AACF"}
1
+ {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionListBlock/layout.ts"],"sourcesContent":["import { parseISO } from 'date-fns/parseISO'\n\nimport type {\n Beat,\n DrilldownData,\n GlobalCopy,\n InDescriptionCTA,\n PrimaryCTA,\n SecondaryCTA,\n} from '../../../core'\nimport { asNonEmptyText, asNumber } from '../../blocks/slotReaders'\nimport { readHelp, type HelpContent } from '../HelpBlock/layout'\n\ntype DrilldownCta = PrimaryCTA | SecondaryCTA | InDescriptionCTA\n\n/** The transaction_list_block CTA variants. */\nexport const TRANSACTION_LIST_VARIANTS = {\n SUMMARY_HEADER: 'summary_header',\n GENERIC_LIST: 'generic_list',\n /** Opens the list under the beat's title, description and \"Learn More\". */\n HELP_HEADER: 'help_header',\n /** Opens Micro Deposits' Deposit History list. */\n DEPOSIT_HISTORY: 'deposit_history',\n} as const\n\nexport const HELP_HEADER_VARIANT = TRANSACTION_LIST_VARIANTS.HELP_HEADER\n\n/** Drawer title: the variant's title when it has one, otherwise the beat's own title. Add new variants here. */\nexport const getTransactionListDrawerTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\n beat?: Beat,\n): string => {\n switch (variant) {\n case TRANSACTION_LIST_VARIANTS.GENERIC_LIST:\n case TRANSACTION_LIST_VARIANTS.HELP_HEADER:\n return copy.transactions?.transactions_title ?? ''\n case TRANSACTION_LIST_VARIANTS.DEPOSIT_HISTORY:\n return copy.insights_feed?.transaction_list_block?.deposit_history_drawer_title ?? ''\n default:\n return beat?.insights_payload?.title ?? ''\n }\n}\n\nexport interface HelpHeaderContent {\n /** Pre-localized HTML under the title, from the payload's `drilldown_data.description_html`. */\n descriptionHtml?: string\n /** The \"Learn More\" link and the help drawer it opens; absent when the beat carries no help. */\n learnMore?: HelpContent & { label: string }\n}\n\n/**\n * The help-header variant's text, read from the payload's `drilldown_data` (shared by every CTA\n * of the card): `description_html`, and `help_label` with the `help_title` / `help_html` that\n * `readHelp` reads. Only the `help_header` variant renders the block.\n */\nexport const readHelpHeader = (\n cta: DrilldownCta | undefined,\n drilldown: DrilldownData | undefined,\n): HelpHeaderContent | undefined => {\n if (cta?.variant !== HELP_HEADER_VARIANT) return undefined\n\n const label = asNonEmptyText(drilldown?.help_label)\n const help = readHelp(drilldown)\n\n return {\n descriptionHtml: asNonEmptyText(drilldown?.description_html),\n ...(label && help && { learnMore: { ...help, label } }),\n }\n}\n\nexport interface TransactionListSummary {\n /** Headline figure (e.g. total withdrawn). */\n amount: number\n /** Validated range endpoints; rendered as `{start} – {end}`. Omitted when the payload value is\n * missing or unparseable (so the drawer never crashes on an Invalid Date). */\n startDate?: Date\n endDate?: Date\n /** Number of transactions for the pill, from the CTA's `drilldown_data.count`. */\n count?: number\n}\n\n// `> 0`: the card only shows with >= 1 guid, so a `count` of 0 is dropped and falls back to the\n// guid count rather than rendering \"0 transactions\".\nconst toCount = (value: unknown): number | undefined =>\n typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : undefined\n\n// Sane epoch window so a bad/typo payload can't render a far-past/future date.\nconst EPOCH_MIN = Date.UTC(2000, 0, 1)\nconst EPOCH_MAX = Date.UTC(2100, 0, 1)\n\n// `readSummary` runs on every observer re-render (no `useMemo` by design), so warn at most once per\n// distinct payload object instead of on every render. Keyed on the `drilldown_data` object, which is\n// a stable reference across re-renders of the same beat.\nconst warnedPayloads = new WeakSet<object>()\nconst warnOncePerPayload = (source: object, message: string): void => {\n if (warnedPayloads.has(source)) return\n warnedPayloads.add(source)\n console.warn(message)\n}\n\n/**\n * Parse a payload date value to a validated `Date`, or `undefined`. Accepts unix seconds or\n * milliseconds (auto-detected) and ISO strings. Fails closed (no throw): an unparseable or\n * out-of-range value returns undefined and warns, so `formatDate`/`intlFormat` never sees an Invalid\n * Date (which throws `RangeError` and takes down the whole drawer render).\n */\nconst toDate = (value: unknown, field: string, source: object): Date | undefined => {\n // Missing/empty is a normal \"no range\" case — return quietly, don't warn.\n if (value === undefined || value === null || value === '') return undefined\n\n let ms: number | undefined\n if (typeof value === 'number' && Number.isFinite(value)) {\n // < 1e12 is treated as seconds (1e12 ms is year 33658). Trade-off: genuine ms timestamps from\n // ~2000-2001 would be misread as seconds and fall outside the window below (dropped, not shown).\n ms = value < 1e12 ? value * 1000 : value\n } else if (typeof value === 'string') {\n const parsed = parseISO(value).getTime()\n ms = Number.isNaN(parsed) ? undefined : parsed\n }\n\n if (ms === undefined || ms < EPOCH_MIN || ms > EPOCH_MAX) {\n warnOncePerPayload(\n source,\n `[TransactionListBlock] drilldown_data.${field} is unparseable or out of range (${typeof value})`,\n )\n return undefined\n }\n return new Date(ms)\n}\n\n/**\n * Summary-header figures for the drawer, read from the clicked CTA's `drilldown_data` (the backend\n * hangs a drilldown's own data off the CTA that opens it). Fails closed throughout: only the\n * `summary_header` variant renders a header (so figures from a different CTA that `getDynamicCta…`\n * fell back to can't be misattributed), then without a finite `amount` there is still no header, and\n * each date is validated to a real `Date` or dropped — an unparseable value never reaches\n * `formatDate` (which throws on an Invalid Date).\n *\n * `drilldown_data` fields: `amount` (number), `start_date`/`end_date` (unix seconds|ms or ISO),\n * `count` (number of transactions).\n */\nexport const readSummary = (cta: DrilldownCta | undefined): TransactionListSummary | undefined => {\n // Defense-in-depth on financial figures: only the summary-header variant shows the card.\n if (cta?.variant !== TRANSACTION_LIST_VARIANTS.SUMMARY_HEADER) return undefined\n\n const source = cta?.drilldown_data\n if (!source) return undefined\n\n const amount = asNumber(source.amount)\n if (amount === undefined) {\n // `drilldown_data` present but no usable amount -> surface the likely contract drift (field\n // rename) instead of a silently missing header.\n if (Object.keys(source).length > 0) {\n warnOncePerPayload(\n source,\n '[TransactionListBlock] drilldown_data has no finite `amount` — no summary header.',\n )\n }\n return undefined\n }\n\n return {\n amount,\n startDate: toDate(source.start_date, 'start_date', source),\n endDate: toDate(source.end_date, 'end_date', source),\n count: toCount(source.count),\n }\n}\n"],"mappings":";;;AAgBA,IAAa,IAA4B;AAAA,EACvC,gBAAgB;AAAA,EAChB,cAAc;AAAA,EAEd,aAAa;AAAA,EAEb,iBAAiB;AACnB,GAEa,IAAsB,EAA0B,aAGhD,IAAA,CACX,GACA,GACA,MACW;AACX,UAAQ,GAAR;AAAA,IACE,KAAK,EAA0B;AAAA,IAC/B,KAAK,EAA0B;AAC7B,aAAO,EAAK,cAAc,sBAAsB;AAAA,IAClD,KAAK,EAA0B;AAC7B,aAAO,EAAK,eAAe,wBAAwB,gCAAgC;AAAA,IACrF;AACE,aAAO,GAAM,kBAAkB,SAAS;AAAA,EAC5C;AACF,GAca,IAAA,CACX,GACA,MACkC;AAClC,MAAI,GAAK,YAAY,EAAqB;AAE1C,QAAM,IAAQ,EAAe,GAAW,UAAU,GAC5C,IAAO,EAAS,CAAS;AAE/B,SAAO;AAAA,IACL,iBAAiB,EAAe,GAAW,gBAAgB;AAAA,IAC3D,GAAI,KAAS,KAAQ,EAAE,WAAW;AAAA,MAAE,GAAG;AAAA,MAAM,OAAA;AAAA,IAAM,EAAE;AAAA,EACvD;AACF,GAeM,IA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"}
@@ -1,13 +1,13 @@
1
1
  import { slot as d } from "../../../../core/types/Insights.es.js";
2
2
  import { formatCurrency as T } from "../../../../core/utils/NumberFormatting.es.js";
3
3
  import { resolveVariantConfig as $ } from "../../resolveVariantConfig.es.js";
4
- import { useContainerDimensions as j } from "../../../hooks/useContainerDimensions.es.js";
5
- import F from "../../../components/LogoFromGuid.es.js";
6
- import { Confetti as P } from "../../../components/shared/Confetti.es.js";
7
- import { ReactComponent as N } from "../../../components/shared/images/PaidOffCard.es.js";
8
- import { ReactComponent as E } from "../../../components/shared/images/SavingsAccountDeposit.es.js";
9
- import { statusIconName as G } from "../../../components/statusIcon.es.js";
10
- import { asNumber as H, asText as x } from "../../slotReaders.es.js";
4
+ import { asNumber as j, asText as x } from "../../slotReaders.es.js";
5
+ import { useContainerDimensions as F } from "../../../hooks/useContainerDimensions.es.js";
6
+ import P from "../../../components/LogoFromGuid.es.js";
7
+ import { Confetti as N } from "../../../components/shared/Confetti.es.js";
8
+ import { ReactComponent as E } from "../../../components/shared/images/PaidOffCard.es.js";
9
+ import { ReactComponent as G } from "../../../components/shared/images/SavingsAccountDeposit.es.js";
10
+ import { statusIconName as H } from "../../../components/statusIcon.es.js";
11
11
  import { isDetailedAccountVariant as O } from "../DetailedAccountBlock/layout.es.js";
12
12
  import W from "../DetailedAccountBlock/DetailedAccountBlock.es.js";
13
13
  import { HeaderComponent as q } from "./HeaderComponent.es.js";
@@ -21,11 +21,11 @@ import { jsx as o, jsxs as t } from "react/jsx-runtime";
21
21
  import { useTheme as Q } from "@mui/material/styles";
22
22
  import s from "@mui/material/Box";
23
23
  var wo = ({ payload: g }) => {
24
- const h = Q(), b = M(null), { height: w, width: v } = j(b), { instance_slot: n } = g, { variant: p, institution_guid: I, institution_name: S, icon_name: z, merchant_name: D } = n;
24
+ const h = Q(), b = M(null), { height: w, width: v } = F(b), { instance_slot: n } = g, { variant: p, institution_guid: I, institution_name: S, icon_name: z, merchant_name: D } = n;
25
25
  if (O(p)) return /* @__PURE__ */ o(W, { payload: g });
26
- const { data: i } = n, m = i !== void 0, u = m ? H(d(i, "amount")) : n.amount, y = x(d(i, "sub_text")), R = m ? y : n.sub_text, A = m ? y : n.label, a = m ? x(d(i, "header_text")) : n.header_text, c = d(i, "logo"), e = $(J(h), p, "default", "AccountBlock");
26
+ const { data: i } = n, m = i !== void 0, u = m ? j(d(i, "amount")) : n.amount, y = x(d(i, "sub_text")), R = m ? y : n.sub_text, A = m ? y : n.label, a = m ? x(d(i, "header_text")) : n.header_text, c = d(i, "logo"), e = $(J(h), p, "default", "AccountBlock");
27
27
  if (e?.isConfetti) {
28
- const f = G(c?.guid), B = {
28
+ const f = H(c?.guid), B = {
29
29
  paidOffCard: /* @__PURE__ */ o(s, {
30
30
  sx: {
31
31
  flexShrink: 0,
@@ -33,7 +33,7 @@ var wo = ({ payload: g }) => {
33
33
  position: "relative",
34
34
  width: 48
35
35
  },
36
- children: /* @__PURE__ */ o(N, {
36
+ children: /* @__PURE__ */ o(E, {
37
37
  "aria-hidden": !0,
38
38
  role: "presentation",
39
39
  style: {
@@ -43,7 +43,7 @@ var wo = ({ payload: g }) => {
43
43
  }
44
44
  })
45
45
  }),
46
- savings: /* @__PURE__ */ o(E, {
46
+ savings: /* @__PURE__ */ o(G, {
47
47
  "aria-hidden": !0,
48
48
  height: 55,
49
49
  role: "presentation",
@@ -72,7 +72,7 @@ var wo = ({ payload: g }) => {
72
72
  size: e.logo_icon_size ?? 24,
73
73
  sx: { color: "success.contrastText" }
74
74
  })
75
- }) : c?.guid ? /* @__PURE__ */ o(F, {
75
+ }) : c?.guid ? /* @__PURE__ */ o(P, {
76
76
  logo: c,
77
77
  size: 48
78
78
  }) : null
@@ -104,7 +104,7 @@ var wo = ({ payload: g }) => {
104
104
  position: "absolute",
105
105
  zIndex: 1
106
106
  },
107
- children: /* @__PURE__ */ o(P, {
107
+ children: /* @__PURE__ */ o(N, {
108
108
  height: w,
109
109
  shouldRun: w > 0 && v > 0,
110
110
  width: v
@@ -2,14 +2,14 @@ import { buildDynamicCopy as s } from "../../../../core/utils/Localization.es.js
2
2
  import { GlobalDataContext as l } from "../../../../common/context/GlobalDataProvider.es.js";
3
3
  import { slot as u } from "../../../../core/types/Insights.es.js";
4
4
  import { resolveVariantConfig as c } from "../../resolveVariantConfig.es.js";
5
- import g from "../../../components/LogoFromGuid.es.js";
6
- import { asText as p, slotOrFlat as d } from "../../slotReaders.es.js";
5
+ import { asText as g, slotOrFlat as p } from "../../slotReaders.es.js";
6
+ import d from "../../../components/LogoFromGuid.es.js";
7
7
  import f from "../../../components/DirectDepositCard.es.js";
8
8
  import { detailedAccountVariant as _, getLayoutConfig as v } from "./layout.es.js";
9
9
  import { useContext as y } from "react";
10
10
  import { jsx as m } from "react/jsx-runtime";
11
11
  import { useTheme as x } from "@mui/material/styles";
12
- var n = (t, a) => p(d(t, a)), C = (t, a) => {
12
+ var n = (t, a) => g(p(t, a)), C = (t, a) => {
13
13
  const o = u(t.data, "logo"), e = n(t, "institution_guid"), r = o?.alt ?? n(t, "institution_name"), i = o ?? (e ? {
14
14
  guid: e,
15
15
  alt: r ?? e
@@ -22,7 +22,7 @@ var n = (t, a) => p(d(t, a)), C = (t, a) => {
22
22
  const a = x(), { instance_slot: o } = t, e = y(l)?.globalStore.copyStore.copy.insights_feed?.general?.institution_Logo, r = C(o, e), i = c(v(a), o.variant, _.Neutral, "DetailedAccountBlock");
23
23
  return /* @__PURE__ */ m(f, {
24
24
  ...i,
25
- logo: r?.guid ? /* @__PURE__ */ m(g, {
25
+ logo: r?.guid ? /* @__PURE__ */ m(d, {
26
26
  logo: r,
27
27
  size: 48
28
28
  }) : null,
@@ -2,8 +2,8 @@ import { slot as l } from "../../../../core/types/Insights.es.js";
2
2
  import { formatCurrency as A } from "../../../../core/utils/NumberFormatting.es.js";
3
3
  import L from "../../../components/StatusPill.es.js";
4
4
  import { resolveVariantConfig as S } from "../../resolveVariantConfig.es.js";
5
- import v, { isLogoGuid as x } from "../../../components/LogoFromGuid.es.js";
6
- import { asNumber as O, asText as i, slotOrFlat as u } from "../../slotReaders.es.js";
5
+ import { asNumber as x, asText as i, slotOrFlat as u } from "../../slotReaders.es.js";
6
+ import v, { isLogoGuid as O } from "../../../components/LogoFromGuid.es.js";
7
7
  import E from "../../../components/LogoClusterCard.es.js";
8
8
  import B from "../../../components/MerchantHighlightCard.es.js";
9
9
  import N from "../../../components/P2PLogoStack.es.js";
@@ -18,7 +18,7 @@ var g = 64, k = 6, G = 72, M = 3, T = [
18
18
  ], F = 32, m = (a) => {
19
19
  if (!a || typeof a != "object" || Array.isArray(a)) return;
20
20
  const { alt: r, color: t, fallback_guid: o, guid: n } = a;
21
- if (!(typeof n != "string" || !x(n)))
21
+ if (!(typeof n != "string" || !O(n)))
22
22
  return {
23
23
  alt: i(r),
24
24
  color: i(t),
@@ -83,7 +83,7 @@ var g = 64, k = 6, G = 72, M = 3, T = [
83
83
  }
84
84
  const s = i(l(t, "primary_text")) || i(u(r, "merchant_name"));
85
85
  if (!s) return null;
86
- const c = O(u(r, "amount")), y = i(l(t, "header_text")) || i(l(t, "date")), h = m(l(t, "logo")) ?? m({
86
+ const c = x(u(r, "amount")), y = i(l(t, "header_text")) || i(l(t, "date")), h = m(l(t, "logo")) ?? m({
87
87
  alt: s,
88
88
  fallback_guid: r.category_guid,
89
89
  guid: r.merchant_guid
@@ -1,14 +1,14 @@
1
1
  import { slot as l } from "../../../../core/types/Insights.es.js";
2
2
  import { formatCurrency as g } from "../../../../core/utils/NumberFormatting.es.js";
3
- import p, { isLogoGuid as f } from "../../../components/LogoFromGuid.es.js";
4
- import { asNumber as h, asText as s, slotOrFlat as r } from "../../slotReaders.es.js";
3
+ import { asNumber as p, asText as s, slotOrFlat as r } from "../../slotReaders.es.js";
4
+ import f, { isLogoGuid as h } from "../../../components/LogoFromGuid.es.js";
5
5
  import { buildUnhighlightedCurrentWeek as _, buildWeekStrip as x, parseDueDate as k } from "./weekStrip.es.js";
6
6
  import b from "../../../components/UpcomingBillCard.es.js";
7
7
  import y from "@mui/material/Stack";
8
8
  import { Icon as v } from "@mxenabled/mx-icons";
9
9
  import { jsx as t } from "react/jsx-runtime";
10
10
  var T = ({ payload: c }) => {
11
- const { instance_slot: o } = c, { data: d } = o, e = s(r(o, "merchant_name")) ?? "", a = h(r(o, "amount")), i = s(r(o, "due_date")), n = l(d, "logo") ?? (o.merchant_guid ? {
11
+ const { instance_slot: o } = c, { data: d } = o, e = s(r(o, "merchant_name")) ?? "", a = p(r(o, "amount")), i = s(r(o, "due_date")), n = l(d, "logo") ?? (o.merchant_guid ? {
12
12
  alt: e,
13
13
  fallback_guid: o.category_guid,
14
14
  guid: o.merchant_guid
@@ -18,7 +18,7 @@ var T = ({ payload: c }) => {
18
18
  children: /* @__PURE__ */ t(b, {
19
19
  amount: a !== void 0 ? g(a, "0,0.00") : "",
20
20
  days: u,
21
- logo: f(n?.guid) ? /* @__PURE__ */ t(p, {
21
+ logo: h(n?.guid) ? /* @__PURE__ */ t(f, {
22
22
  logo: n,
23
23
  size: 24
24
24
  }) : /* @__PURE__ */ t(v, {
@@ -1,17 +1,18 @@
1
- import { slot as i } from "../../../../core/types/Insights.es.js";
2
- import { formatCurrency as a } from "../../../../core/utils/NumberFormatting.es.js";
3
- import m from "../../../components/SavingsOpportunityCard.es.js";
4
- import { jsx as e } from "react/jsx-runtime";
5
- var s = (t) => typeof t == "number" && Number.isFinite(t), y = ({ payload: t }) => {
6
- const r = t.instance_slot?.data, o = i(r, "amount"), n = i(r, "primary_text");
7
- return !s(o) || typeof n != "string" ? null : /* @__PURE__ */ e(m, {
8
- amount: a(o, "0,0.00"),
9
- label: n,
1
+ import { slot as a } from "../../../../core/types/Insights.es.js";
2
+ import { formatCurrency as n } from "../../../../core/utils/NumberFormatting.es.js";
3
+ import { asNumber as i, asText as s } from "../../slotReaders.es.js";
4
+ import e from "../../../components/SavingsOpportunityCard.es.js";
5
+ import { jsx as p } from "react/jsx-runtime";
6
+ var v = ({ payload: m }) => {
7
+ const t = m.instance_slot?.data, r = i(a(t, "amount")), o = s(a(t, "primary_text"));
8
+ return r === void 0 || o === void 0 ? null : /* @__PURE__ */ p(e, {
9
+ amount: n(r, "0,0.00"),
10
+ label: o,
10
11
  slot: !0
11
12
  });
12
13
  };
13
14
  export {
14
- y as default
15
+ v as default
15
16
  };
16
17
 
17
18
  //# sourceMappingURL=SavingsOpportunityBlock.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SavingsOpportunityBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/SavingsOpportunityBlock/SavingsOpportunityBlock.tsx"],"sourcesContent":["import { slot as readSlot, type InsightsPayload } from '../../../../core'\nimport { formatCurrency } from '../../../../core/utils/NumberFormatting'\n\nimport SavingsOpportunityCard from '../../../components/SavingsOpportunityCard'\n\nconst isFiniteNumber = (value: unknown): value is number =>\n typeof value === 'number' && Number.isFinite(value)\n\n/**\n * Savings Opportunity V2 coupon (ditto `savings_amount_block`, single `save_amount` variant): reads\n * `primary_text` and `amount` off `instance_slot.data`. `slot()` is an unchecked cast, so a payload\n * that omits the amount or sends a non-number / non-string renders nothing rather than a fabricated\n * `$0.00` card (same guard as `SaveExtraBlock`).\n */\nconst SavingsOpportunityBlock = ({ payload }: { payload: InsightsPayload }) => {\n const data = payload.instance_slot?.data\n const amount = readSlot<unknown>(data, 'amount')\n const primaryText = readSlot<unknown>(data, 'primary_text')\n\n if (!isFiniteNumber(amount) || typeof primaryText !== 'string') return null\n\n return <SavingsOpportunityCard amount={formatCurrency(amount, '0,0.00')} label={primaryText} slot />\n}\n\nexport default SavingsOpportunityBlock\n"],"mappings":";;;;AAKA,IAAM,IAAA,CAAkB,MACtB,OAAO,KAAU,YAAY,OAAO,SAAS,CAAK,GAQ9C,IAAA,CAA2B,EAAE,SAAA,EAAA,MAA4C;AAC7E,QAAM,IAAO,EAAQ,eAAe,MAC9B,IAAS,EAAkB,GAAM,QAAQ,GACzC,IAAc,EAAkB,GAAM,cAAc;AAE1D,SAAI,CAAC,EAAe,CAAM,KAAK,OAAO,KAAgB,WAAiB,OAEhE,gBAAA,EAAC,GAAD;AAAA,IAAwB,QAAQ,EAAe,GAAQ,QAAQ;AAAA,IAAG,OAAO;AAAA,IAAa,MAAA;AAAA,EAAM,CAAA;AACrG"}
1
+ {"version":3,"file":"SavingsOpportunityBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/SavingsOpportunityBlock/SavingsOpportunityBlock.tsx"],"sourcesContent":["import { slot as readSlot, type InsightsPayload } from '../../../../core'\nimport { formatCurrency } from '../../../../core/utils/NumberFormatting'\n\nimport SavingsOpportunityCard from '../../../components/SavingsOpportunityCard'\nimport { asNumber, asText } from '../../slotReaders'\n\n/**\n * Savings Opportunity V2 coupon (ditto `savings_amount_block`, single `save_amount` variant): reads\n * `primary_text` and `amount` off `instance_slot.data`. `slot()` is an unchecked cast, so a payload\n * that omits the amount or sends a non-number / non-string renders nothing rather than a fabricated\n * `$0.00` card (same guard as `SaveExtraBlock`).\n */\nconst SavingsOpportunityBlock = ({ payload }: { payload: InsightsPayload }) => {\n const data = payload.instance_slot?.data\n const amount = asNumber(readSlot<unknown>(data, 'amount'))\n const primaryText = asText(readSlot<unknown>(data, 'primary_text'))\n\n if (amount === undefined || primaryText === undefined) return null\n\n return (\n <SavingsOpportunityCard amount={formatCurrency(amount, '0,0.00')} label={primaryText} slot />\n )\n}\n\nexport default SavingsOpportunityBlock\n"],"mappings":";;;;;AAYA,IAAM,IAAA,CAA2B,EAAE,SAAA,EAAA,MAA4C;AAC7E,QAAM,IAAO,EAAQ,eAAe,MAC9B,IAAS,EAAS,EAAkB,GAAM,QAAQ,CAAC,GACnD,IAAc,EAAO,EAAkB,GAAM,cAAc,CAAC;AAElE,SAAI,MAAW,UAAa,MAAgB,SAAkB,OAG5D,gBAAA,EAAC,GAAD;AAAA,IAAwB,QAAQ,EAAe,GAAQ,QAAQ;AAAA,IAAG,OAAO;AAAA,IAAa,MAAA;AAAA,EAAM,CAAA;AAEhG"}
@@ -1,8 +1,8 @@
1
1
  import { useGlobalCopyStore as k } from "../../../../common/context/hooks.es.js";
2
2
  import { slot as c } from "../../../../core/types/Insights.es.js";
3
3
  import { formatCurrency as S } from "../../../../core/utils/NumberFormatting.es.js";
4
- import z from "../../../components/LogoFromGuid.es.js";
5
- import { asNumber as h, asText as b } from "../../slotReaders.es.js";
4
+ import { asNumber as z, asText as h } from "../../slotReaders.es.js";
5
+ import b from "../../../components/LogoFromGuid.es.js";
6
6
  import C from "../../../components/SubscriptionHeroCard.es.js";
7
7
  import { createVariantBlock as $ } from "../../createVariantBlock.es.js";
8
8
  import { CADENCE as B, upcomingSubscriptionVariant as T } from "./layout.es.js";
@@ -89,7 +89,7 @@ var w = [
89
89
  top: 57.9
90
90
  }
91
91
  ], x = ({ payload: i }) => {
92
- const s = k().insights_feed?.upcoming_subscription_block, { instance_slot: p } = i, { data: e } = p, a = i.widget_type === "mini", l = h(c(e, "recurrence_type")), m = h(c(e, "amount")), f = b(c(e, "merchant_name")), u = b(c(e, "merchant_guid")), d = l !== void 0 ? B[l] : void 0, y = s?.[d?.copyKey] ?? d?.word, n = u ? {
92
+ const s = k().insights_feed?.upcoming_subscription_block, { instance_slot: p } = i, { data: e } = p, a = i.widget_type === "mini", l = z(c(e, "recurrence_type")), m = z(c(e, "amount")), f = h(c(e, "merchant_name")), u = h(c(e, "merchant_guid")), d = l !== void 0 ? B[l] : void 0, y = s?.[d?.copyKey] ?? d?.word, n = u ? {
93
93
  alt: f ?? "",
94
94
  guid: u
95
95
  } : null, g = m === void 0 ? "" : S(m, "0,0.00"), _ = g ? /* @__PURE__ */ j("span", {
@@ -118,7 +118,7 @@ var w = [
118
118
  top: `${t.top}%`,
119
119
  width: t.size
120
120
  },
121
- children: /* @__PURE__ */ o(z, {
121
+ children: /* @__PURE__ */ o(b, {
122
122
  logo: n,
123
123
  size: t.size
124
124
  })
@@ -129,7 +129,7 @@ var w = [
129
129
  children: /* @__PURE__ */ o(C, {
130
130
  backdrop: v,
131
131
  compact: a,
132
- logo: n ? /* @__PURE__ */ o(z, {
132
+ logo: n ? /* @__PURE__ */ o(b, {
133
133
  logo: n,
134
134
  size: a ? 40 : 64
135
135
  }) : null,