@mx-cartographer/experiences 9.7.134 → 9.7.135

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.
@@ -1 +1 @@
1
- {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/layout.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { Theme } from '@mui/material/styles'\nimport { endOfMonth, fromUnixTime, isValid, parseISO, startOfMonth } from 'date-fns'\nimport { getCategoryColor } from '../../../core/utils/CategoryUtil'\nimport {\n type Beat,\n type DataSeries,\n type DrilldownData,\n type InsightsFeedCopy,\n type Subtitle,\n type Transaction,\n TransactionStatus,\n buildDynamicCopy,\n} from '../../../core'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport type {\n DataSet,\n InsightsInstanceSlotData,\n} from '../../../core/types/InsightsInstanceSlotData'\nimport LogoMark from '../../components/LogoMark'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../core/constants'\nimport { fromUnixUTC } from '../../../core/utils/DateUtil'\nimport { CURRENCY_FORMAT, type CurrencyFormat } from '../../../core/utils/NumberFormatting'\nimport { Icon } from '@mxenabled/mx-icons'\nimport {\n buildDataSeries,\n type ChartDataSeriesItem,\n} from '../../blocks/ChartBlocks/BarchartBlock/utils'\nimport { getLayoutConfig as getDoubleBarLayoutConfig } from '../../blocks/ChartBlocks/DoubleBarChartBlock/layout'\nimport { asGuidList, asNonEmptyText, asNumber } from '../../blocks/slotReaders'\nimport type { TipSectionProps } from '../../../insights/components/shared/ChartDrawerTemplate/TipSection'\nimport {\n type BeatTransactionsResolver,\n buildProjectedBillTransaction,\n calendarDateOf,\n type DrillDownSlotData,\n type SlotDataResolver,\n} from './utils'\n\nexport interface DrillDownHeader {\n heading?: string\n subHeadingText?: string\n icon?: ReactNode\n}\n\nexport interface DrillDownHeaderContext {\n title?: string\n subHeader?: Subtitle\n categoryName: string\n selectedDate?: string | Date\n}\n\nexport const DRILLDOWN_VARIANTS = {\n TRANSACTION: 'not_standard_amount',\n CATEGORY_SPEND: 'category_spend',\n MONTHLY_SPEND: 'monthly_spend_comparison',\n ACCOUNT_BALANCE: 'account_balance',\n UPCOMING_BILL: 'upcoming_bill',\n SPEND_TO_INCOME: 'monthly_spend_to_income',\n SAVINGS_TO_INCOME: 'monthly_savings_to_income',\n DEBT_TO_INCOME: 'debt_to_income',\n COST_OF_LIVING: 'cost_living_to_income',\n NON_ESSENTIAL_CATEGORY: 'non_essential_category_summary',\n DEPOSIT_SUMMARY: 'monthly_deposit_summary',\n LOW_BALANCE: 'low_balance',\n SUBSCRIPTION_AGGREGATE: 'monthly_subscription_aggregate',\n} as const\n\nexport type DrillDownVariant = (typeof DRILLDOWN_VARIANTS)[keyof typeof DRILLDOWN_VARIANTS]\n\n/** One flattened data_series row a filterStrategy indexes; fields are optional because the backend keys rows dynamically. */\n\n// Resolves the top-chart palette from the theme (and the beat's category, when relevant).\nexport type ColorKind = (theme: Theme, categoryGuid?: string) => string[]\n\n// Resolves the dynamic drawer header (heading/sub-heading/icon JSX) from the selection context.\nexport type HeaderKind = (ctx: DrillDownHeaderContext) => DrillDownHeader\n\n/**\n * Everything a filterStrategy needs to turn the currently-selected bar/sub-tab into a\n * TransactionFilter. Data-only so strategies stay pure and testable.\n */\nexport interface FilterContext {\n beat: Beat\n beatTransactions: Transaction[]\n dataSeries: ChartDataSeriesItem[]\n // The double-bar drawer's month columns (main / comparison per month, with their guids); empty\n // for every other top kind.\n comparisonBars: DataSet[]\n selectedIndex: number\n subIndex: number\n isLastTab: boolean\n instanceSlotData: DrillDownSlotData\n spendCategoryGuids: string[]\n displayedDateRange: { start: Date; end: Date }\n}\n\n// Resolves the current selection into a TransactionFilter. Carried on each config row so behavior\n// lives next to the variant it belongs to (no separate strategy registry to chase).\nexport type FilterStrategy = (ctx: FilterContext) => TransactionFilter\n\n/** Sub-tabs under the chart (Income / Other Deposits); `subIndex` in `FilterContext` picks one. */\nexport type SubTabsKind = (ctx: {\n instanceSlotData: DrillDownSlotData\n copy: InsightsFeedCopy\n}) => string[]\n\nexport interface DrillDownVariantConfig {\n // `list`: no chart or tabs above the transaction list (an account's transactions for a window).\n // `monthTabs`: one tab per data_series month and no chart (a month's aggregated transactions).\n top: 'singleBar' | 'upcomingBill' | 'doubleBar' | 'tabsOnly' | 'monthTabs' | 'list'\n filterStrategy: FilterStrategy\n colors: ColorKind\n header?: HeaderKind\n // A second tab row under the chart that `subIndex` picks from (Income / Other Deposits).\n subTabs?: SubTabsKind\n // Where the drawer reads its facts. Absent: the bar chart's `instance_slot.data`.\n slotData?: SlotDataResolver\n // Builds the drawer's transactions from the beat's own. Absent: the beat's own, as they are.\n beatTransactions?: BeatTransactionsResolver\n // On open, returns the guids of the drawer's transactions to fetch by guid when the store lacks\n // them (older than its 90-day window), as pulse's BeatShell loads a legacy beat's: each drawer\n // reads them from wherever its beat keeps them (the beat, or the CTA that opened the drawer).\n // Absent: nothing is fetched.\n fetchMissingTransactions?: (beat: Beat, ctaDrilldownData?: DrilldownData) => unknown\n // undefined when the facts the tip needs are missing: the drawer shows no tip.\n tipSection?: (\n setCloseTipSection: (flag: boolean) => void,\n copy: InsightsFeedCopy,\n merchantName?: string,\n slotData?: DrillDownSlotData,\n ) => TipSectionProps | undefined\n scope: 'store' | 'beat'\n filterMode: 'store' | 'local'\n // Double bar: accessible names for the series tabs ([0] main, [1] comparison), as legacy pulse.\n subTabAriaLabels?: (copy: InsightsFeedCopy) => (string | undefined)[]\n // The list has no Transactions heading above it; the CSV export stays.\n hideListHeader?: boolean\n // The tip sits between the chart and the sub-tabs rather than under them.\n tipAboveSubTabs?: boolean\n // The average (Trend) legend's number format. Absent: `CURRENCY_FORMAT.cents`.\n averageFormat?: CurrencyFormat\n}\nconst categoryColor = (theme: Theme, categoryGuid?: string): string =>\n (categoryGuid && getCategoryColor(categoryGuid, theme)) || theme.palette.primary.main\n\nconst toLocalDate = (date: string | number | Date | undefined) =>\n typeof date === 'string' ? parseISO(date) : new Date(date ?? NaN)\n\nconst monthRange = (date: string | number | Date | undefined) => ({\n start: startOfMonth(toLocalDate(date)),\n end: endOfMonth(toLocalDate(date)),\n})\n\n// Scopes a filter to the beat's accounts when the beat carries account_guids; otherwise leaves\n// accounts unset so the store default (all accounts) applies.\nconst accountScope = (accountGuids?: string[]): Pick<TransactionFilter, 'accounts'> =>\n accountGuids?.length ? { accounts: accountGuids } : {}\n\n// Low Account Balance — `drilldown_data` names one account and a window (epoch seconds at UTC\n// midnight, to_date exclusive); only settled, visible rows, a split purchase as its parts, as the\n// pulse drawer listed them. Fails closed: a drawer that cannot name its rows shows none.\nconst accountWindowStrategy: FilterStrategy = ({ beat }) => {\n const { account_guid, from_date, to_date } = beat.insights_payload?.drilldown_data ?? {}\n if (\n typeof account_guid !== 'string' ||\n typeof from_date !== 'number' ||\n typeof to_date !== 'number' ||\n !Number.isFinite(from_date) ||\n !Number.isFinite(to_date) ||\n to_date <= from_date\n ) {\n return { accounts: [], custom: () => false }\n }\n\n return {\n accounts: [account_guid],\n custom: (trn) => !trn.is_hidden && trn.feed_status !== TransactionStatus.PENDING,\n showSplits: true,\n dateRange: { start: fromUnixUTC(from_date), end: fromUnixUTC(to_date - 1) },\n }\n}\n\n// Upcoming Bill: a missing or mistyped `drilldown_data` fact is dropped, so a bad due date, amount or\n// guid list draws no chart and lists no rows.\n\nexport const resolveUpcomingBillSlotData: SlotDataResolver = (payload) => {\n const data = payload?.drilldown_data ?? {}\n\n return {\n transaction_guids: asGuidList(data.transaction_guids),\n date: calendarDateOf(data.due_date),\n amount: asNumber(data.amount),\n category_guid: asNonEmptyText(data.category_guid),\n average_amount: asNumber(data.average_amount),\n merchant_name: asNonEmptyText(data.merchant_name),\n }\n}\n\n// Savings Account Balances Summary: the drawer's bars, trend and accounts come from the beat's\n// drilldown_data alone (tupac SavingsAccountBalancesSummary::Factory.drilldown_data), each narrowed:\n// a missing or malformed fact is dropped, so the drawer draws no bars and lists no rows.\nconst dataSeriesOf = (value: unknown): DataSeries | undefined => {\n const series = value as DataSeries | undefined\n return Array.isArray(series?.names) && Array.isArray(series?.data) ? series : undefined\n}\n\nexport const resolveSavingsContributionsSlotData: SlotDataResolver = (payload) => {\n const data = payload?.drilldown_data ?? {}\n\n return {\n account_guids: asGuidList(data.account_guids),\n data_series: dataSeriesOf(data.data_series),\n average_amount: asNumber(data.average_amount),\n }\n}\n\n// Monthly Deposit Summary's sub-tabs, in the donut legend's order.\nconst DEPOSIT_SUB_TABS = ['income', 'other'] as const\n\n// Monthly Deposit Summary: tupac's drilldown_data carries the six months (data_series rows with\n// aggregated_guids), the income guids and the trend. The donut's legend rows are the card's, so they\n// only name the sub-tabs; with no `legends`, the chart legend falls back to Monthly Amount / Trend.\nexport const resolveDepositSummarySlotData: SlotDataResolver = (payload) => {\n const data = payload?.drilldown_data ?? {}\n const donutLegends = (payload?.instance_slot?.data as InsightsInstanceSlotData | undefined)\n ?.legends\n const subTabLabels = donutLegends?.map(({ label }) => label)\n\n return {\n data_series: dataSeriesOf(data.data_series),\n average_amount: asNumber(data.average_amount),\n income_transaction_guids: asGuidList(data.income_transaction_guids),\n sub_tab_labels: subTabLabels?.length === DEPOSIT_SUB_TABS.length ? subTabLabels : undefined,\n }\n}\n\n// Monthly Debt to Income Comparison: the 6 months and the Debt / Income legend labels come from the\n// drilldown_data of the CTA that opened the drawer (ditto primary_cta_drilldown_data), never the card's\n// slot or the beat. A malformed series, or labels that are not two non-blank strings, yield nothing,\n// so the drawer draws no bars and lists no rows.\nconst DEBT_TO_INCOME_SERIES_COUNT = 2\n\nexport const resolveDebtToIncomeSlotData: SlotDataResolver = (_payload, ctaDrilldownData) => {\n const data = ctaDrilldownData ?? {}\n const dataSeries = dataSeriesOf(data.series)\n const labels = Array.isArray(data.labels) ? data.labels.map(asNonEmptyText) : []\n if (\n !dataSeries ||\n labels.length !== DEBT_TO_INCOME_SERIES_COUNT ||\n !labels.every((label): label is string => !!label)\n ) {\n return {}\n }\n\n // The legend's amounts are the selected month's, which the drawer fills from the bars.\n return { data_series: dataSeries, legends: labels.map((label) => ({ label, value: 0 })) }\n}\n\n// Every month's debt and income guids from the opening CTA, so the drawer fetches the ones older\n// than the store's window.\nconst debtToIncomeGuidsOf = (_beat: Beat, ctaDrilldownData?: DrilldownData): string[] =>\n buildDataSeries(dataSeriesOf(ctaDrilldownData?.series)).flatMap(\n (row) => row.aggregated_guids ?? [],\n )\n\n// The drawer's tip, as Figma words it: the bold tip title and the bold limit (\"less than 30%\") from\n// the copy service. No hard-coded English: no tip until the copy service carries both strings.\nconst debtToIncomeTipSection: DrillDownVariantConfig['tipSection'] = (setCloseTipSection, copy) => {\n const message = copy.transaction_history_block?.monthly_debt_to_income_tip_message\n const limit = copy.transaction_history_block?.monthly_debt_to_income_tip_limit\n if (!message || !limit) return undefined\n\n return {\n message: buildDynamicCopy(\n message,\n <strong>{copy.general.tip_section_title}</strong>,\n <strong>{limit}</strong>,\n ) as ReactNode,\n onDismiss: () => setCloseTipSection(true),\n }\n}\n\n// Every month's deposit guids, so the drawer fetches the ones older than the store's window.\nconst depositGuidsOf = (beat: Beat): string[] =>\n buildDataSeries(dataSeriesOf(beat.insights_payload?.drilldown_data?.data_series)).flatMap(\n (row) => row.aggregated_guids ?? [],\n )\n\n// Upcoming Bill: the paid bills plus the projected bill (due date, amount) appended last, so the\n// bars and the projected tab's \"Projected amount\" row read the one list.\nexport const resolveUpcomingBillTransactions: BeatTransactionsResolver = (\n transactions,\n slotData,\n) => {\n const projected = buildProjectedBillTransaction(transactions, slotData)\n\n return projected ? [...transactions, projected] : transactions\n}\n\nconst upcomingBillTipSection: DrillDownVariantConfig['tipSection'] = (\n setCloseTipSection,\n copy,\n _merchantName,\n slotData,\n) => {\n const merchantName = slotData?.merchant_name\n const dueDate = slotData?.date\n if (!merchantName || !dueDate) return undefined\n\n // No hard-coded English: no tip until the copy service carries the message.\n const message = copy.transaction_history_block?.upcoming_bill_tip_message\n if (!message) return undefined\n\n return {\n message: buildDynamicCopy(\n message,\n <strong>{copy.general.tip_section_title}</strong>,\n merchantName,\n formatDate(parseISO(dueDate), DATE_FORMATS_INTL.FULL_MONTH_DAY),\n ) as ReactNode,\n onDismiss: () => setCloseTipSection(true),\n }\n}\n\n// ── Single-bar filter strategies (this MR) ────────────────────────────────────────────────────\n\n// BillAmountNotStandard / UpcomingBill — the series carries a transaction (TRN) guid; match a single\n// transaction by guid within its month.\nconst transactionGuidStrategy: FilterStrategy = ({\n beatTransactions,\n dataSeries,\n selectedIndex,\n}) => {\n const seriesItem = dataSeries[selectedIndex]\n const seriesGuid = seriesItem?.guid\n const hasBeenSplit = beatTransactions.find((trn) => trn.guid === seriesGuid)?.has_been_split\n\n return {\n custom: (trn) => trn.guid === seriesGuid,\n dateRange: monthRange(seriesItem?.date),\n showSplits: !hasBeenSplit,\n }\n}\n\n// CategorySpendingV2 — match transactions in the beat's category (or whose top-level category is that\n// guid) within the month.\nconst categoryStrategy: FilterStrategy = ({ dataSeries, selectedIndex, instanceSlotData }) => {\n const seriesItem = dataSeries[selectedIndex]\n const categoryGuid = instanceSlotData.category_guid ?? seriesItem?.guid\n\n return {\n custom: (trn) =>\n trn.category_guid === categoryGuid || trn.top_level_category_guid === categoryGuid,\n dateRange: monthRange(seriesItem?.date),\n }\n}\n\n// MonthlySpendComparisonV2 — no per-bar guid; show all spending-category transactions\n// (income/transfers/investments excluded via spendCategoryGuids) within the month.\nconst spendCategoriesStrategy: FilterStrategy = ({\n dataSeries,\n selectedIndex,\n spendCategoryGuids,\n instanceSlotData,\n}) => {\n const seriesItem = dataSeries[selectedIndex]\n\n return {\n custom: (trn) =>\n !!trn.top_level_category_guid && spendCategoryGuids.includes(trn.top_level_category_guid),\n dateRange: monthRange(seriesItem?.date),\n ...accountScope(instanceSlotData.account_guids),\n }\n}\n\n// The beat's creation: tupac sends epoch seconds on the envelope and an ISO string on the wrapper.\nconst toCreatedAt = (createdAt: Beat['created_at']) =>\n typeof createdAt === 'number' ? fromUnixTime(createdAt) : parseISO(createdAt ?? '')\n\n// Savings Account Balances Summary: the beat's savings accounts within the month (the latest month\n// ends at the beat's creation). Fails closed: no drilldown_data accounts, no rows.\nconst accountDateStrategy: FilterStrategy = ({\n beat,\n dataSeries,\n selectedIndex,\n isLastTab,\n instanceSlotData,\n}) => {\n const seriesItem = dataSeries[selectedIndex]\n const { start, end } = monthRange(seriesItem?.date)\n const createdAt = toCreatedAt(beat.created_at)\n const accountGuids = instanceSlotData.account_guids\n const dateRange = {\n start,\n end: isLastTab && isValid(createdAt) && createdAt < end ? createdAt : end,\n }\n\n if (!accountGuids?.length) return { dateRange, accounts: [], custom: () => false }\n\n return { dateRange, accounts: accountGuids }\n}\n\n// A row's stored guids within the row's month, scoped to the beat's accounts. parseISO reads the\n// 'yyyy-MM-dd' date as a local calendar day, so the month never shifts with the viewer's time zone.\n// Fails closed: a missing row, guid list or date matches nothing, never the store's displayed range.\nconst guidsWithinMonth = (\n guids: string[] | undefined,\n date: string | undefined,\n accountGuids?: string[],\n): TransactionFilter => {\n const guidSet = new Set(guids)\n const month = parseISO(date ?? '')\n if (!guidSet.size || !isValid(month)) return { accounts: [], custom: () => false }\n\n return {\n custom: (trn) => guidSet.has(trn.guid),\n dateRange: { start: startOfMonth(month), end: endOfMonth(month) },\n ...accountScope(accountGuids),\n }\n}\n\n// Monthly Subscription Aggregate — one data_series row per month, each naming its own\n// aggregated_guids; the selected month tab lists exactly those.\nconst monthlyAggregatedGuidsStrategy: FilterStrategy = ({ beat, dataSeries, selectedIndex }) =>\n guidsWithinMonth(\n dataSeries[selectedIndex]?.aggregated_guids,\n dataSeries[selectedIndex]?.date,\n beat.account_guids,\n )\n\n// ── Double-bar strategies ──────────────────────────────────────────────────────────────────────\n\n// Monthly Spend to Income Comparison — the selected month's main (Spend, sub-tab 0) or comparison\n// (Income, sub-tab 1) bar guids. The V2 payload carries no account_guids on instance_slot.data.\nconst comparisonGuidsStrategy: FilterStrategy = ({\n beat,\n comparisonBars,\n selectedIndex,\n subIndex,\n}) => {\n const bar = comparisonBars[selectedIndex]\n\n return guidsWithinMonth(\n subIndex === 1 ? bar?.comparisonGuids : bar?.mainGuids,\n bar?.date,\n beat.account_guids,\n )\n}\n\n// ── Tabs-only strategies ───────────────────────────────────────────────────────────────────────\n\n// Monthly Non-Essential Category Summary — the series is the two sides of one month (non-essential /\n// essential), not a time series; the selected sub-tab picks the row.\nconst aggregatedGuidsStrategy: FilterStrategy = ({ beat, dataSeries, subIndex }) =>\n guidsWithinMonth(\n dataSeries[subIndex]?.aggregated_guids,\n dataSeries[subIndex]?.date,\n beat.account_guids,\n )\n\n// Monthly Deposit Summary: the selected month's guids, split into the Income / Other Deposits sub-tab.\n// Not scoped to beat.account_guids: those are the beat month's accounts only, and an older month's\n// deposits can sit in other accounts; the row's aggregated_guids are already exact.\nconst depositSummaryStrategy: FilterStrategy = (ctx) => {\n const { dataSeries, selectedIndex, subIndex, instanceSlotData } = ctx\n const month = dataSeries[selectedIndex]\n const income = new Set(instanceSlotData.income_transaction_guids)\n const isIncome = DEPOSIT_SUB_TABS[subIndex] === 'income'\n const guids = instanceSlotData.sub_tab_labels\n ? month?.aggregated_guids?.filter((guid) => income.has(guid) === isIncome)\n : month?.aggregated_guids\n\n return guidsWithinMonth(guids, month?.date)\n}\n\nexport const layout: Partial<Record<DrillDownVariant, DrillDownVariantConfig>> = {\n [DRILLDOWN_VARIANTS.TRANSACTION]: {\n top: 'singleBar',\n scope: 'store',\n filterMode: 'store',\n filterStrategy: transactionGuidStrategy,\n colors: (theme: Theme, categoryGuid?: string) => [categoryColor(theme, categoryGuid)],\n header: (ctx: DrillDownHeaderContext) => {\n const { title, subHeader } = ctx\n return {\n heading: title,\n subHeadingText: subHeader?.text || undefined,\n icon: (\n <LogoMark\n logo={{\n ...subHeader?.logo,\n merchant_name: subHeader?.text ?? subHeader?.logo?.merchant_name,\n }}\n size={16}\n />\n ),\n }\n },\n tipSection: (setCloseTipSection, copy, merchantName = '') => {\n return {\n message: buildDynamicCopy(\n copy.general.tip_section_message,\n <strong>{copy.general.tip_section_title}</strong>,\n <strong>{merchantName}</strong>,\n ),\n onDismiss: () => setCloseTipSection(true),\n } as TipSectionProps\n },\n },\n [DRILLDOWN_VARIANTS.CATEGORY_SPEND]: {\n top: 'singleBar',\n // As the card's Trend (Figma \"$x\"): whole dollars.\n averageFormat: CURRENCY_FORMAT.whole,\n filterStrategy: categoryStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme, categoryGuid?: string) => [categoryColor(theme, categoryGuid)],\n header: (ctx: DrillDownHeaderContext) => {\n return {\n heading: ctx.categoryName,\n subHeadingText: ctx.selectedDate\n ? formatDate(toLocalDate(ctx.selectedDate), DATE_FORMATS_INTL.MONTH_LONG) || ''\n : '',\n // Figma: the month's calendar icon in primary.main.\n icon: <Icon color=\"primary\" name=\"calendar_month\" size={16} />,\n }\n },\n },\n [DRILLDOWN_VARIANTS.MONTHLY_SPEND]: {\n top: 'singleBar',\n filterStrategy: spendCategoriesStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => [theme.palette.chart.chart2 ?? theme.palette.primary.main],\n },\n [DRILLDOWN_VARIANTS.ACCOUNT_BALANCE]: {\n top: 'singleBar',\n filterStrategy: accountDateStrategy,\n slotData: resolveSavingsContributionsSlotData,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => [theme.palette.success.main],\n },\n // Upcoming Bill: one bar per paid bill plus the projected bill, all from `drilldown_data`; a bar's\n // tab lists that bill alone (filtered locally, as legacy pulse does).\n [DRILLDOWN_VARIANTS.UPCOMING_BILL]: {\n top: 'upcomingBill',\n filterStrategy: transactionGuidStrategy,\n scope: 'beat',\n filterMode: 'local',\n colors: (theme: Theme, categoryGuid?: string) => [categoryColor(theme, categoryGuid)],\n slotData: resolveUpcomingBillSlotData,\n beatTransactions: resolveUpcomingBillTransactions,\n fetchMissingTransactions: (beat) => beat.insights_payload?.drilldown_data?.transaction_guids,\n tipSection: upcomingBillTipSection,\n },\n\n // Monthly Deposit Summary: six months of deposits from drilldown_data, then Income / Other Deposits\n // tabs named by the donut's legend rows; without both rows, no sub-tabs.\n [DRILLDOWN_VARIANTS.DEPOSIT_SUMMARY]: {\n top: 'singleBar',\n filterStrategy: depositSummaryStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => [theme.palette.success.main],\n slotData: resolveDepositSummarySlotData,\n fetchMissingTransactions: depositGuidsOf,\n subTabs: ({ instanceSlotData }) => instanceSlotData.sub_tab_labels ?? [],\n },\n\n // Low Account Balance's \"Transactions\" link: the account's transactions for the alert's window.\n [DRILLDOWN_VARIANTS.LOW_BALANCE]: {\n top: 'list',\n filterStrategy: accountWindowStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => [theme.palette.primary.main],\n // Figma 438:27640 lists the rows straight under the drawer header.\n hideListHeader: true,\n },\n\n // Monthly Subscription Aggregate's \"View Transactions\": one tab per month, no chart, each month\n // listing its own aggregated_guids.\n [DRILLDOWN_VARIANTS.SUBSCRIPTION_AGGREGATE]: {\n top: 'monthTabs',\n filterStrategy: monthlyAggregatedGuidsStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => [theme.palette.primary.main],\n },\n\n // ── Double-bar comparison beats (month tabs + main / comparison sub-tabs) ────────────────────\n // Monthly Spend to Income Comparison: Spend vs Income per month, in the card block's palette.\n [DRILLDOWN_VARIANTS.SPEND_TO_INCOME]: {\n top: 'doubleBar',\n filterStrategy: comparisonGuidsStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => getDoubleBarLayoutConfig(theme, 'spend_to_income')?.color ?? [],\n subTabAriaLabels: (copy) => [copy.general.spend_transactions, copy.general.income_transactions],\n },\n // Cost of Living to Income: one living-cost category (Housing, Groceries, ...) vs Income per month.\n // The cost bar takes the beat category's colour and Income the legacy chart4, as the pulse drawer.\n [DRILLDOWN_VARIANTS.COST_OF_LIVING]: {\n top: 'doubleBar',\n filterStrategy: comparisonGuidsStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme, categoryGuid?: string) => [\n categoryColor(theme, categoryGuid),\n theme.palette.chart.chart4 ?? theme.palette.primary.main,\n ],\n subTabAriaLabels: (copy) => [undefined, copy.general.income_transactions],\n },\n // Monthly Debt to Income Comparison: 6 months of Debt vs Income from the opening CTA's\n // drilldown_data, in the card block's palette so both series keep their card colours, plus the tip.\n [DRILLDOWN_VARIANTS.DEBT_TO_INCOME]: {\n top: 'doubleBar',\n filterStrategy: comparisonGuidsStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => getDoubleBarLayoutConfig(theme, 'debt_to_income')?.color ?? [],\n subTabAriaLabels: (copy) => [undefined, copy.general.income_transactions],\n slotData: resolveDebtToIncomeSlotData,\n fetchMissingTransactions: debtToIncomeGuidsOf,\n tipSection: debtToIncomeTipSection,\n // Figma 1117:8599: the tip above the Debt / Income tabs, and no Transactions heading.\n tipAboveSubTabs: true,\n hideListHeader: true,\n },\n // NEXT MR — the other double-bar beats reuse comparisonGuidsStrategy with their own palettes:\n // [DRILLDOWN_VARIANTS.SAVINGS_TO_INCOME]: comparison('savingsVsIncome'),\n\n // Monthly Non-Essential Category Summary (tabs only): one side tab per series row, labelled by the\n // row's pre-localized label; a row without one gets no tab.\n [DRILLDOWN_VARIANTS.NON_ESSENTIAL_CATEGORY]: {\n top: 'tabsOnly',\n filterStrategy: aggregatedGuidsStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => [theme.palette.primary.main],\n },\n}\n\n// Fallback for a missing/typo'd backend variant: a single-bar, store-scoped drawer filtered by the\n// beat's transaction guid and colored by category, so the drawer still renders instead of crashing.\nexport const FALLBACK: DrillDownVariantConfig = {\n top: 'singleBar',\n filterStrategy: transactionGuidStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme, categoryGuid?: string) => [categoryColor(theme, categoryGuid)],\n}\n"],"mappings":";;;;;;;;;;;;;;AA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S,CAAC;AAAA,IACvF,kBAAA,CAAmB,MAAS,CAAC,QAAW,EAAK,QAAQ,mBAAmB;AAAA,IACxE,UAAU;AAAA,IACV,0BAA0B;AAAA,IAC1B,YAAY;AAAA,IAEZ,iBAAiB;AAAA,IACjB,gBAAgB;AAAA,EAClB;AAAA,EAMC,CAAA,EAAmB,sBAAA,GAAyB;AAAA,IAC3C,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,QAAA,CAAS,MAAiB,CAAC,EAAM,QAAQ,QAAQ,IAAI;AAAA,EACvD;AACF,GAIa,KAAmC;AAAA,EAC9C,KAAK;AAAA,EACL,gBAAgB;AAAA,EAChB,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,QAAA,CAAS,GAAc,MAA0B,CAAC,EAAc,GAAO,CAAY,CAAC;AACtF"}
1
+ {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/layout.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { Theme } from '@mui/material/styles'\nimport { endOfMonth, fromUnixTime, isValid, parseISO, startOfMonth } from 'date-fns'\nimport { getCategoryColor } from '../../../core/utils/CategoryUtil'\nimport {\n type Beat,\n type DataSeries,\n type DrilldownData,\n type InsightsFeedCopy,\n type Subtitle,\n type Transaction,\n TransactionStatus,\n buildDynamicCopy,\n} from '../../../core'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport type {\n BarChartBlockData,\n DataSet,\n InsightsInstanceSlotData,\n} from '../../../core/types/InsightsInstanceSlotData'\nimport LogoMark from '../../components/LogoMark'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../core/constants'\nimport { fromUnixUTC } from '../../../core/utils/DateUtil'\nimport { CURRENCY_FORMAT, type CurrencyFormat } from '../../../core/utils/NumberFormatting'\nimport { Icon } from '@mxenabled/mx-icons'\nimport {\n buildDataSeries,\n type ChartDataSeriesItem,\n} from '../../blocks/ChartBlocks/BarchartBlock/utils'\nimport { getLayoutConfig as getDoubleBarLayoutConfig } from '../../blocks/ChartBlocks/DoubleBarChartBlock/layout'\nimport { asGuidList, asNonEmptyText, asNumber } from '../../blocks/slotReaders'\nimport type { TipSectionProps } from '../../../insights/components/shared/ChartDrawerTemplate/TipSection'\nimport {\n type BeatTransactionsResolver,\n buildProjectedBillTransaction,\n calendarDateOf,\n type DrillDownSlotData,\n type SlotDataResolver,\n toDrillDownSlotData,\n} from './utils'\n\nexport interface DrillDownHeader {\n heading?: string\n subHeadingText?: string\n icon?: ReactNode\n}\n\nexport interface DrillDownHeaderContext {\n title?: string\n subHeader?: Subtitle\n categoryName: string\n selectedDate?: string | Date\n}\n\nexport const DRILLDOWN_VARIANTS = {\n TRANSACTION: 'not_standard_amount',\n CATEGORY_SPEND: 'category_spend',\n MONTHLY_SPEND: 'monthly_spend_comparison',\n ACCOUNT_BALANCE: 'account_balance',\n UPCOMING_BILL: 'upcoming_bill',\n SPEND_TO_INCOME: 'monthly_spend_to_income',\n SAVINGS_TO_INCOME: 'savings_to_income',\n DEBT_TO_INCOME: 'debt_to_income',\n COST_OF_LIVING: 'cost_living_to_income',\n NON_ESSENTIAL_CATEGORY: 'non_essential_category_summary',\n DEPOSIT_SUMMARY: 'monthly_deposit_summary',\n LOW_BALANCE: 'low_balance',\n SUBSCRIPTION_AGGREGATE: 'monthly_subscription_aggregate',\n} as const\n\nexport type DrillDownVariant = (typeof DRILLDOWN_VARIANTS)[keyof typeof DRILLDOWN_VARIANTS]\n\n/** One flattened data_series row a filterStrategy indexes; fields are optional because the backend keys rows dynamically. */\n\n// Resolves the top-chart palette from the theme (and the beat's category, when relevant).\nexport type ColorKind = (theme: Theme, categoryGuid?: string) => string[]\n\n// Resolves the dynamic drawer header (heading/sub-heading/icon JSX) from the selection context.\nexport type HeaderKind = (ctx: DrillDownHeaderContext) => DrillDownHeader\n\n/**\n * Everything a filterStrategy needs to turn the currently-selected bar/sub-tab into a\n * TransactionFilter. Data-only so strategies stay pure and testable.\n */\nexport interface FilterContext {\n beat: Beat\n beatTransactions: Transaction[]\n dataSeries: ChartDataSeriesItem[]\n // The double-bar drawer's month columns (main / comparison per month, with their guids); empty\n // for every other top kind.\n comparisonBars: DataSet[]\n selectedIndex: number\n subIndex: number\n isLastTab: boolean\n instanceSlotData: DrillDownSlotData\n spendCategoryGuids: string[]\n displayedDateRange: { start: Date; end: Date }\n}\n\n// Resolves the current selection into a TransactionFilter. Carried on each config row so behavior\n// lives next to the variant it belongs to (no separate strategy registry to chase).\nexport type FilterStrategy = (ctx: FilterContext) => TransactionFilter\n\n/** Sub-tabs under the chart (Income / Other Deposits); `subIndex` in `FilterContext` picks one. */\nexport type SubTabsKind = (ctx: {\n instanceSlotData: DrillDownSlotData\n copy: InsightsFeedCopy\n}) => string[]\n\nexport interface DrillDownVariantConfig {\n // `list`: no chart or tabs above the transaction list (an account's transactions for a window).\n // `monthTabs`: one tab per data_series month and no chart (a month's aggregated transactions).\n top: 'singleBar' | 'upcomingBill' | 'doubleBar' | 'tabsOnly' | 'monthTabs' | 'list'\n filterStrategy: FilterStrategy\n colors: ColorKind\n header?: HeaderKind\n // A second tab row under the chart that `subIndex` picks from (Income / Other Deposits).\n subTabs?: SubTabsKind\n // Where the drawer reads its facts. Absent: the bar chart's `instance_slot.data`.\n slotData?: SlotDataResolver\n // Builds the drawer's transactions from the beat's own. Absent: the beat's own, as they are.\n beatTransactions?: BeatTransactionsResolver\n // On open, returns the guids of the drawer's transactions to fetch by guid when the store lacks\n // them (older than its 90-day window), as pulse's BeatShell loads a legacy beat's: each drawer\n // reads them from wherever its beat keeps them (the beat, or the CTA that opened the drawer).\n // Absent: nothing is fetched.\n fetchMissingTransactions?: (beat: Beat, ctaDrilldownData?: DrilldownData) => unknown\n // undefined when the facts the tip needs are missing: the drawer shows no tip.\n tipSection?: (\n setCloseTipSection: (flag: boolean) => void,\n copy: InsightsFeedCopy,\n merchantName?: string,\n slotData?: DrillDownSlotData,\n ) => TipSectionProps | undefined\n scope: 'store' | 'beat'\n filterMode: 'store' | 'local'\n // Double bar: accessible names for the series tabs ([0] main, [1] comparison), as legacy pulse.\n subTabAriaLabels?: (copy: InsightsFeedCopy) => (string | undefined)[]\n // The list has no Transactions heading above it; the CSV export stays.\n hideListHeader?: boolean\n // The average (Trend) legend's number format. Absent: `CURRENCY_FORMAT.cents`.\n averageFormat?: CurrencyFormat\n}\nconst categoryColor = (theme: Theme, categoryGuid?: string): string =>\n (categoryGuid && getCategoryColor(categoryGuid, theme)) || theme.palette.primary.main\n\nconst toLocalDate = (date: string | number | Date | undefined) =>\n typeof date === 'string' ? parseISO(date) : new Date(date ?? NaN)\n\nconst monthRange = (date: string | number | Date | undefined) => ({\n start: startOfMonth(toLocalDate(date)),\n end: endOfMonth(toLocalDate(date)),\n})\n\n// Scopes a filter to the beat's accounts when the beat carries account_guids; otherwise leaves\n// accounts unset so the store default (all accounts) applies.\nconst accountScope = (accountGuids?: string[]): Pick<TransactionFilter, 'accounts'> =>\n accountGuids?.length ? { accounts: accountGuids } : {}\n\n// Low Account Balance — `drilldown_data` names one account and a window (epoch seconds at UTC\n// midnight, to_date exclusive); only settled, visible rows, a split purchase as its parts, as the\n// pulse drawer listed them. Fails closed: a drawer that cannot name its rows shows none.\nconst accountWindowStrategy: FilterStrategy = ({ beat }) => {\n const { account_guid, from_date, to_date } = beat.insights_payload?.drilldown_data ?? {}\n if (\n typeof account_guid !== 'string' ||\n typeof from_date !== 'number' ||\n typeof to_date !== 'number' ||\n !Number.isFinite(from_date) ||\n !Number.isFinite(to_date) ||\n to_date <= from_date\n ) {\n return { accounts: [], custom: () => false }\n }\n\n return {\n accounts: [account_guid],\n custom: (trn) => !trn.is_hidden && trn.feed_status !== TransactionStatus.PENDING,\n showSplits: true,\n dateRange: { start: fromUnixUTC(from_date), end: fromUnixUTC(to_date - 1) },\n }\n}\n\n// Upcoming Bill: a missing or mistyped `drilldown_data` fact is dropped, so a bad due date, amount or\n// guid list draws no chart and lists no rows.\n\nexport const resolveUpcomingBillSlotData: SlotDataResolver = (payload) => {\n const data = payload?.drilldown_data ?? {}\n\n return {\n transaction_guids: asGuidList(data.transaction_guids),\n date: calendarDateOf(data.due_date),\n amount: asNumber(data.amount),\n category_guid: asNonEmptyText(data.category_guid),\n average_amount: asNumber(data.average_amount),\n merchant_name: asNonEmptyText(data.merchant_name),\n }\n}\n\n// Savings Account Balances Summary: the drawer's bars, trend and accounts come from the beat's\n// drilldown_data alone (tupac SavingsAccountBalancesSummary::Factory.drilldown_data), each narrowed:\n// a missing or malformed fact is dropped, so the drawer draws no bars and lists no rows.\nconst dataSeriesOf = (value: unknown): DataSeries | undefined => {\n const series = value as DataSeries | undefined\n return Array.isArray(series?.names) && Array.isArray(series?.data) ? series : undefined\n}\n\nexport const resolveSavingsContributionsSlotData: SlotDataResolver = (payload) => {\n const data = payload?.drilldown_data ?? {}\n\n return {\n account_guids: asGuidList(data.account_guids),\n data_series: dataSeriesOf(data.data_series),\n average_amount: asNumber(data.average_amount),\n }\n}\n\n// Monthly Deposit Summary's sub-tabs, in the donut legend's order.\nconst DEPOSIT_SUB_TABS = ['income', 'other'] as const\n\n// Monthly Deposit Summary: tupac's drilldown_data carries the six months (data_series rows with\n// aggregated_guids), the income guids and the trend. The donut's legend rows are the card's, so they\n// only name the sub-tabs; with no `legends`, the chart legend falls back to Monthly Amount / Trend.\nexport const resolveDepositSummarySlotData: SlotDataResolver = (payload) => {\n const data = payload?.drilldown_data ?? {}\n const donutLegends = (payload?.instance_slot?.data as InsightsInstanceSlotData | undefined)\n ?.legends\n const subTabLabels = donutLegends?.map(({ label }) => label)\n\n return {\n data_series: dataSeriesOf(data.data_series),\n average_amount: asNumber(data.average_amount),\n income_transaction_guids: asGuidList(data.income_transaction_guids),\n sub_tab_labels: subTabLabels?.length === DEPOSIT_SUB_TABS.length ? subTabLabels : undefined,\n }\n}\n\n// Monthly Debt to Income Comparison: the 6 months and the Debt / Income legend labels come from the\n// drilldown_data of the CTA that opened the drawer (ditto primary_cta_drilldown_data), never the card's\n// slot or the beat. A malformed series, or labels that are not two non-blank strings, yield nothing,\n// so the drawer draws no bars and lists no rows.\nconst DEBT_TO_INCOME_SERIES_COUNT = 2\n\nexport const resolveDebtToIncomeSlotData: SlotDataResolver = (_payload, ctaDrilldownData) => {\n const data = ctaDrilldownData ?? {}\n const dataSeries = dataSeriesOf(data.series)\n const labels = Array.isArray(data.labels) ? data.labels.map(asNonEmptyText) : []\n if (\n !dataSeries ||\n labels.length !== DEBT_TO_INCOME_SERIES_COUNT ||\n !labels.every((label): label is string => !!label)\n ) {\n return {}\n }\n\n // The legend's amounts are the selected month's, which the drawer fills from the bars.\n return { data_series: dataSeries, legends: labels.map((label) => ({ label, value: 0 })) }\n}\n\n// Every month's debt and income guids from the opening CTA, so the drawer fetches the ones older\n// than the store's window.\nconst debtToIncomeGuidsOf = (_beat: Beat, ctaDrilldownData?: DrilldownData): string[] =>\n buildDataSeries(dataSeriesOf(ctaDrilldownData?.series)).flatMap(\n (row) => row.aggregated_guids ?? [],\n )\n\n// The drawer's tip, as Figma words it: the bold tip title and the bold limit (\"less than 30%\") from\n// the copy service. No hard-coded English: no tip until the copy service carries both strings.\nconst debtToIncomeTipSection: DrillDownVariantConfig['tipSection'] = (setCloseTipSection, copy) => {\n const message = copy.transaction_history_block?.monthly_debt_to_income_tip_message\n const limit = copy.transaction_history_block?.monthly_debt_to_income_tip_limit\n if (!message || !limit) return undefined\n\n return {\n message: buildDynamicCopy(\n message,\n <strong>{copy.general.tip_section_title}</strong>,\n <strong>{limit}</strong>,\n ) as ReactNode,\n onDismiss: () => setCloseTipSection(true),\n }\n}\n\n// Monthly Savings to Income: the 6 months from the opening CTA's drilldown_data (tupac\n// payload.drilldown_series, as Debt to Income's); until a beat carries them, the card's own 4 months.\nconst resolveSavingsToIncomeSlotData: SlotDataResolver = (payload, ctaDrilldownData) => {\n const fromCta = resolveDebtToIncomeSlotData(payload, ctaDrilldownData)\n if (fromCta.data_series) return fromCta\n\n return toDrillDownSlotData((payload?.instance_slot?.data ?? {}) as BarChartBlockData)\n}\n\n// The Savings vs. Income tip, as Figma 1243:73833 words it: the bold tip title and the bold\n// percentage (\"20%\") from the copy service; no tip until the copy service carries both strings.\nconst savingsToIncomeTipSection: DrillDownVariantConfig['tipSection'] = (\n setCloseTipSection,\n copy,\n) => {\n const message = copy.transaction_history_block?.savings_to_income_tip_message\n const percentage = copy.transaction_history_block?.savings_to_income_tip_percentage\n if (!message || !percentage) return undefined\n\n return {\n message: buildDynamicCopy(\n message,\n <strong>{copy.general.tip_section_title}</strong>,\n <strong>{percentage}</strong>,\n ) as ReactNode,\n onDismiss: () => setCloseTipSection(true),\n }\n}\n\n// Every month's deposit guids, so the drawer fetches the ones older than the store's window.\nconst depositGuidsOf = (beat: Beat): string[] =>\n buildDataSeries(dataSeriesOf(beat.insights_payload?.drilldown_data?.data_series)).flatMap(\n (row) => row.aggregated_guids ?? [],\n )\n\n// Upcoming Bill: the paid bills plus the projected bill (due date, amount) appended last, so the\n// bars and the projected tab's \"Projected amount\" row read the one list.\nexport const resolveUpcomingBillTransactions: BeatTransactionsResolver = (\n transactions,\n slotData,\n) => {\n const projected = buildProjectedBillTransaction(transactions, slotData)\n\n return projected ? [...transactions, projected] : transactions\n}\n\nconst upcomingBillTipSection: DrillDownVariantConfig['tipSection'] = (\n setCloseTipSection,\n copy,\n _merchantName,\n slotData,\n) => {\n const merchantName = slotData?.merchant_name\n const dueDate = slotData?.date\n if (!merchantName || !dueDate) return undefined\n\n // No hard-coded English: no tip until the copy service carries the message.\n const message = copy.transaction_history_block?.upcoming_bill_tip_message\n if (!message) return undefined\n\n return {\n message: buildDynamicCopy(\n message,\n <strong>{copy.general.tip_section_title}</strong>,\n merchantName,\n formatDate(parseISO(dueDate), DATE_FORMATS_INTL.FULL_MONTH_DAY),\n ) as ReactNode,\n onDismiss: () => setCloseTipSection(true),\n }\n}\n\n// ── Single-bar filter strategies (this MR) ────────────────────────────────────────────────────\n\n// BillAmountNotStandard / UpcomingBill — the series carries a transaction (TRN) guid; match a single\n// transaction by guid within its month.\nconst transactionGuidStrategy: FilterStrategy = ({\n beatTransactions,\n dataSeries,\n selectedIndex,\n}) => {\n const seriesItem = dataSeries[selectedIndex]\n const seriesGuid = seriesItem?.guid\n const hasBeenSplit = beatTransactions.find((trn) => trn.guid === seriesGuid)?.has_been_split\n\n return {\n custom: (trn) => trn.guid === seriesGuid,\n dateRange: monthRange(seriesItem?.date),\n showSplits: !hasBeenSplit,\n }\n}\n\n// CategorySpendingV2 — match transactions in the beat's category (or whose top-level category is that\n// guid) within the month.\nconst categoryStrategy: FilterStrategy = ({ dataSeries, selectedIndex, instanceSlotData }) => {\n const seriesItem = dataSeries[selectedIndex]\n const categoryGuid = instanceSlotData.category_guid ?? seriesItem?.guid\n\n return {\n custom: (trn) =>\n trn.category_guid === categoryGuid || trn.top_level_category_guid === categoryGuid,\n dateRange: monthRange(seriesItem?.date),\n }\n}\n\n// MonthlySpendComparisonV2 — no per-bar guid; show all spending-category transactions\n// (income/transfers/investments excluded via spendCategoryGuids) within the month.\nconst spendCategoriesStrategy: FilterStrategy = ({\n dataSeries,\n selectedIndex,\n spendCategoryGuids,\n instanceSlotData,\n}) => {\n const seriesItem = dataSeries[selectedIndex]\n\n return {\n custom: (trn) =>\n !!trn.top_level_category_guid && spendCategoryGuids.includes(trn.top_level_category_guid),\n dateRange: monthRange(seriesItem?.date),\n ...accountScope(instanceSlotData.account_guids),\n }\n}\n\n// The beat's creation: tupac sends epoch seconds on the envelope and an ISO string on the wrapper.\nconst toCreatedAt = (createdAt: Beat['created_at']) =>\n typeof createdAt === 'number' ? fromUnixTime(createdAt) : parseISO(createdAt ?? '')\n\n// Savings Account Balances Summary: the beat's savings accounts within the month (the latest month\n// ends at the beat's creation). Fails closed: no drilldown_data accounts, no rows.\nconst accountDateStrategy: FilterStrategy = ({\n beat,\n dataSeries,\n selectedIndex,\n isLastTab,\n instanceSlotData,\n}) => {\n const seriesItem = dataSeries[selectedIndex]\n const { start, end } = monthRange(seriesItem?.date)\n const createdAt = toCreatedAt(beat.created_at)\n const accountGuids = instanceSlotData.account_guids\n const dateRange = {\n start,\n end: isLastTab && isValid(createdAt) && createdAt < end ? createdAt : end,\n }\n\n if (!accountGuids?.length) return { dateRange, accounts: [], custom: () => false }\n\n return { dateRange, accounts: accountGuids }\n}\n\n// A row's stored guids within the row's month, scoped to the beat's accounts. parseISO reads the\n// 'yyyy-MM-dd' date as a local calendar day, so the month never shifts with the viewer's time zone.\n// Fails closed: a missing row, guid list or date matches nothing, never the store's displayed range.\nconst guidsWithinMonth = (\n guids: string[] | undefined,\n date: string | undefined,\n accountGuids?: string[],\n): TransactionFilter => {\n const guidSet = new Set(guids)\n const month = parseISO(date ?? '')\n if (!guidSet.size || !isValid(month)) return { accounts: [], custom: () => false }\n\n return {\n custom: (trn) => guidSet.has(trn.guid),\n dateRange: { start: startOfMonth(month), end: endOfMonth(month) },\n ...accountScope(accountGuids),\n }\n}\n\n// Monthly Subscription Aggregate — one data_series row per month, each naming its own\n// aggregated_guids; the selected month tab lists exactly those.\nconst monthlyAggregatedGuidsStrategy: FilterStrategy = ({ beat, dataSeries, selectedIndex }) =>\n guidsWithinMonth(\n dataSeries[selectedIndex]?.aggregated_guids,\n dataSeries[selectedIndex]?.date,\n beat.account_guids,\n )\n\n// ── Double-bar strategies ──────────────────────────────────────────────────────────────────────\n\n// Every double-bar comparison (Spend, Savings, Debt or Cost of Living vs Income) — the selected month's\n// main (series 0) or comparison (Income, series 1) bar guids, whatever order the tabs show them in.\n// The V2 payload carries no account_guids on instance_slot.data.\nconst comparisonGuidsStrategy: FilterStrategy = ({\n beat,\n comparisonBars,\n selectedIndex,\n subIndex,\n}) => {\n const bar = comparisonBars[selectedIndex]\n\n return guidsWithinMonth(\n subIndex === 1 ? bar?.comparisonGuids : bar?.mainGuids,\n bar?.date,\n beat.account_guids,\n )\n}\n\n// ── Tabs-only strategies ───────────────────────────────────────────────────────────────────────\n\n// Monthly Non-Essential Category Summary — the series is the two sides of one month (non-essential /\n// essential), not a time series; the selected sub-tab picks the row.\nconst aggregatedGuidsStrategy: FilterStrategy = ({ beat, dataSeries, subIndex }) =>\n guidsWithinMonth(\n dataSeries[subIndex]?.aggregated_guids,\n dataSeries[subIndex]?.date,\n beat.account_guids,\n )\n\n// Monthly Deposit Summary: the selected month's guids, split into the Income / Other Deposits sub-tab.\n// Not scoped to beat.account_guids: those are the beat month's accounts only, and an older month's\n// deposits can sit in other accounts; the row's aggregated_guids are already exact.\nconst depositSummaryStrategy: FilterStrategy = (ctx) => {\n const { dataSeries, selectedIndex, subIndex, instanceSlotData } = ctx\n const month = dataSeries[selectedIndex]\n const income = new Set(instanceSlotData.income_transaction_guids)\n const isIncome = DEPOSIT_SUB_TABS[subIndex] === 'income'\n const guids = instanceSlotData.sub_tab_labels\n ? month?.aggregated_guids?.filter((guid) => income.has(guid) === isIncome)\n : month?.aggregated_guids\n\n return guidsWithinMonth(guids, month?.date)\n}\n\nexport const layout: Partial<Record<DrillDownVariant, DrillDownVariantConfig>> = {\n [DRILLDOWN_VARIANTS.TRANSACTION]: {\n top: 'singleBar',\n scope: 'store',\n filterMode: 'store',\n filterStrategy: transactionGuidStrategy,\n colors: (theme: Theme, categoryGuid?: string) => [categoryColor(theme, categoryGuid)],\n header: (ctx: DrillDownHeaderContext) => {\n const { title, subHeader } = ctx\n return {\n heading: title,\n subHeadingText: subHeader?.text || undefined,\n icon: (\n <LogoMark\n logo={{\n ...subHeader?.logo,\n merchant_name: subHeader?.text ?? subHeader?.logo?.merchant_name,\n }}\n size={16}\n />\n ),\n }\n },\n tipSection: (setCloseTipSection, copy, merchantName = '') => {\n return {\n message: buildDynamicCopy(\n copy.general.tip_section_message,\n <strong>{copy.general.tip_section_title}</strong>,\n <strong>{merchantName}</strong>,\n ),\n onDismiss: () => setCloseTipSection(true),\n } as TipSectionProps\n },\n },\n [DRILLDOWN_VARIANTS.CATEGORY_SPEND]: {\n top: 'singleBar',\n // As the card's Trend (Figma \"$x\"): whole dollars.\n averageFormat: CURRENCY_FORMAT.whole,\n filterStrategy: categoryStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme, categoryGuid?: string) => [categoryColor(theme, categoryGuid)],\n header: (ctx: DrillDownHeaderContext) => {\n return {\n heading: ctx.categoryName,\n subHeadingText: ctx.selectedDate\n ? formatDate(toLocalDate(ctx.selectedDate), DATE_FORMATS_INTL.MONTH_LONG) || ''\n : '',\n // Figma: the month's calendar icon in primary.main.\n icon: <Icon color=\"primary\" name=\"calendar_month\" size={16} />,\n }\n },\n },\n [DRILLDOWN_VARIANTS.MONTHLY_SPEND]: {\n top: 'singleBar',\n filterStrategy: spendCategoriesStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => [theme.palette.chart.chart2 ?? theme.palette.primary.main],\n },\n [DRILLDOWN_VARIANTS.ACCOUNT_BALANCE]: {\n top: 'singleBar',\n filterStrategy: accountDateStrategy,\n slotData: resolveSavingsContributionsSlotData,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => [theme.palette.success.main],\n },\n // Upcoming Bill: one bar per paid bill plus the projected bill, all from `drilldown_data`; a bar's\n // tab lists that bill alone (filtered locally, as legacy pulse does).\n [DRILLDOWN_VARIANTS.UPCOMING_BILL]: {\n top: 'upcomingBill',\n filterStrategy: transactionGuidStrategy,\n scope: 'beat',\n filterMode: 'local',\n colors: (theme: Theme, categoryGuid?: string) => [categoryColor(theme, categoryGuid)],\n slotData: resolveUpcomingBillSlotData,\n beatTransactions: resolveUpcomingBillTransactions,\n fetchMissingTransactions: (beat) => beat.insights_payload?.drilldown_data?.transaction_guids,\n tipSection: upcomingBillTipSection,\n },\n\n // Monthly Deposit Summary: six months of deposits from drilldown_data, then Income / Other Deposits\n // tabs named by the donut's legend rows; without both rows, no sub-tabs.\n [DRILLDOWN_VARIANTS.DEPOSIT_SUMMARY]: {\n top: 'singleBar',\n filterStrategy: depositSummaryStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => [theme.palette.success.main],\n slotData: resolveDepositSummarySlotData,\n fetchMissingTransactions: depositGuidsOf,\n subTabs: ({ instanceSlotData }) => instanceSlotData.sub_tab_labels ?? [],\n },\n\n // Low Account Balance's \"Transactions\" link: the account's transactions for the alert's window.\n [DRILLDOWN_VARIANTS.LOW_BALANCE]: {\n top: 'list',\n filterStrategy: accountWindowStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => [theme.palette.primary.main],\n // Figma 438:27640 lists the rows straight under the drawer header.\n hideListHeader: true,\n },\n\n // Monthly Subscription Aggregate's \"View Transactions\": one tab per month, no chart, each month\n // listing its own aggregated_guids.\n [DRILLDOWN_VARIANTS.SUBSCRIPTION_AGGREGATE]: {\n top: 'monthTabs',\n filterStrategy: monthlyAggregatedGuidsStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => [theme.palette.primary.main],\n },\n\n // ── Double-bar comparison beats (month tabs + main / comparison sub-tabs) ────────────────────\n // Monthly Spend to Income Comparison: Spend vs Income per month, in the card block's palette.\n [DRILLDOWN_VARIANTS.SPEND_TO_INCOME]: {\n top: 'doubleBar',\n filterStrategy: comparisonGuidsStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => getDoubleBarLayoutConfig(theme, 'spend_to_income')?.color ?? [],\n subTabAriaLabels: (copy) => [copy.general.spend_transactions, copy.general.income_transactions],\n },\n // Cost of Living to Income: one living-cost category (Housing, Groceries, ...) vs Income per month.\n // The cost bar takes the beat category's colour and Income the legacy chart4, as the pulse drawer.\n [DRILLDOWN_VARIANTS.COST_OF_LIVING]: {\n top: 'doubleBar',\n filterStrategy: comparisonGuidsStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme, categoryGuid?: string) => [\n categoryColor(theme, categoryGuid),\n theme.palette.chart.chart4 ?? theme.palette.primary.main,\n ],\n subTabAriaLabels: (copy) => [undefined, copy.general.income_transactions],\n },\n // Monthly Debt to Income Comparison: 6 months of Debt vs Income from the opening CTA's\n // drilldown_data, in the card block's palette so both series keep their card colours, plus the tip.\n [DRILLDOWN_VARIANTS.DEBT_TO_INCOME]: {\n top: 'doubleBar',\n filterStrategy: comparisonGuidsStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => getDoubleBarLayoutConfig(theme, 'debt_to_income')?.color ?? [],\n subTabAriaLabels: (copy) => [undefined, copy.general.income_transactions],\n slotData: resolveDebtToIncomeSlotData,\n fetchMissingTransactions: debtToIncomeGuidsOf,\n tipSection: debtToIncomeTipSection,\n },\n // Monthly Savings to Income Comparison: 6 months of Savings vs Income from the opening CTA's\n // drilldown_data (the card's 4 until a beat carries them), in the card block's palette.\n [DRILLDOWN_VARIANTS.SAVINGS_TO_INCOME]: {\n top: 'doubleBar',\n filterStrategy: comparisonGuidsStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => getDoubleBarLayoutConfig(theme, 'savings_to_income')?.color ?? [],\n subTabAriaLabels: (copy) => [\n copy.general.savings_transactions,\n copy.general.income_transactions,\n ],\n slotData: resolveSavingsToIncomeSlotData,\n fetchMissingTransactions: debtToIncomeGuidsOf,\n tipSection: savingsToIncomeTipSection,\n },\n\n // Monthly Non-Essential Category Summary (tabs only): one side tab per series row, labelled by the\n // row's pre-localized label; a row without one gets no tab.\n [DRILLDOWN_VARIANTS.NON_ESSENTIAL_CATEGORY]: {\n top: 'tabsOnly',\n filterStrategy: aggregatedGuidsStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => [theme.palette.primary.main],\n },\n}\n\n// Fallback for a missing/typo'd backend variant: a single-bar, store-scoped drawer filtered by the\n// beat's transaction guid and colored by category, so the drawer still renders instead of crashing.\nexport const FALLBACK: DrillDownVariantConfig = {\n top: 'singleBar',\n filterStrategy: transactionGuidStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme, categoryGuid?: string) => [categoryColor(theme, categoryG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B;AAAA,EAChB,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,QAAA,CAAS,GAAc,MAA0B,CAAC,EAAc,GAAO,CAAY,CAAC;AACtF"}
@@ -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// 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"],"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,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
+ {"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. Savings to\n // Income's variant is savings_to_income, so it resolves savings_to_income_drawer_title through the\n // generic path below (it deliberately drops the monthly_ prefix; do not re-add it).\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,I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AK;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,9 +1,10 @@
1
- var a = (o) => ({ color: [o.palette.categories.billsUtilities, o.palette.chart.chart1] }), r = (o, t) => {
1
+ var a = (o) => ({ color: [o.palette.categories.billsUtilities, o.palette.chart.chart1] }), n = (o) => ({ color: [o.palette.chartMono.chartMono5, o.palette.chartMono.chartMono3] }), r = (o, t) => {
2
2
  const c = {
3
3
  SpendToIncome: a(o),
4
4
  spend_to_income: a(o),
5
5
  debt_to_income: { color: [o.palette.chart.chart5, o.palette.chart.chart1] },
6
- SavingsToIncome: { color: [o.palette.chartMono.chartMono5, o.palette.chartMono.chartMono3] }
6
+ SavingsToIncome: n(o),
7
+ savings_to_income: n(o)
7
8
  };
8
9
  return t && Object.hasOwn(c, t) ? c[t] : void 0;
9
10
  };
@@ -1 +1 @@
1
- {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.ts"],"sourcesContent":["import type { Theme } from '@mui/material/styles'\n\n// One palette per comparison; ditto's snake_case variant shares the legacy PascalCase entry's palette.\nconst spendToIncome = (theme: Theme) => ({\n color: [theme.palette.categories.billsUtilities, theme.palette.chart.chart1] as string[],\n})\n\nexport const getLayoutConfig = (theme: Theme, variant?: string | null) => {\n const config = {\n SpendToIncome: spendToIncome(theme),\n // Insights 2.0: ditto's layout variant for Monthly Spend to Income Comparison.\n spend_to_income: spendToIncome(theme),\n // Insights 2.0: ditto's layout variant for Monthly Debt to Income Comparison. Debt (main) chart5,\n // Income chart1 (Figma 1117:8564); the card and its drawer both read it.\n debt_to_income: {\n color: [theme.palette.chart.chart5, theme.palette.chart.chart1] as string[],\n },\n SavingsToIncome: {\n color: [theme.palette.chartMono.chartMono5, theme.palette.chartMono.chartMono3] as string[],\n },\n }\n // Object.hasOwn: the variant is backend-controlled, and an inherited name like `constructor`\n // would otherwise return a truthy non-config.\n return variant && Object.hasOwn(config, variant)\n ? config[variant as keyof typeof config]\n : undefined\n}\n"],"mappings":"AAGA,IAAM,IAAA,CAAiB,OAAkB,EACvC,OAAO,CAAC,EAAM,QAAQ,WAAW,gBAAgB,EAAM,QAAQ,MAAM,MAAM,EAC7E,IAEa,IAAA,CAAmB,GAAc,MAA4B;AACxE,QAAM,IAAS;AAAA,IACb,eAAe,EAAc,CAAK;AAAA,IAElC,iBAAiB,EAAc,CAAK;AAAA,IAGpC,gBAAgB,EACd,OAAO,CAAC,EAAM,QAAQ,MAAM,QAAQ,EAAM,QAAQ,MAAM,MAAM,EAChE;AAAA,IACA,iBAAiB,EACf,OAAO,CAAC,EAAM,QAAQ,UAAU,YAAY,EAAM,QAAQ,UAAU,UAAU,EAChF;AAAA,EACF;AAGA,SAAO,KAAW,OAAO,OAAO,GAAQ,CAAO,IAC3C,EAAO,CAAA,IACP;AACN"}
1
+ {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.ts"],"sourcesContent":["import type { Theme } from '@mui/material/styles'\n\n// One palette per comparison; ditto's snake_case variant shares the legacy PascalCase entry's palette.\nconst spendToIncome = (theme: Theme) => ({\n color: [theme.palette.categories.billsUtilities, theme.palette.chart.chart1] as string[],\n})\n\nconst savingsToIncome = (theme: Theme) => ({\n color: [theme.palette.chartMono.chartMono5, theme.palette.chartMono.chartMono3] as string[],\n})\n\nexport const getLayoutConfig = (theme: Theme, variant?: string | null) => {\n const config = {\n SpendToIncome: spendToIncome(theme),\n // Insights 2.0: ditto's layout variant for Monthly Spend to Income Comparison.\n spend_to_income: spendToIncome(theme),\n // Insights 2.0: ditto's layout variant for Monthly Debt to Income Comparison. Debt (main) chart5,\n // Income chart1 (Figma 1117:8564); the card and its drawer both read it.\n debt_to_income: {\n color: [theme.palette.chart.chart5, theme.palette.chart.chart1] as string[],\n },\n SavingsToIncome: savingsToIncome(theme),\n // Insights 2.0: ditto's layout variant for Monthly Savings to Income Comparison.\n savings_to_income: savingsToIncome(theme),\n }\n // Object.hasOwn: the variant is backend-controlled, and an inherited name like `constructor`\n // would otherwise return a truthy non-config.\n return variant && Object.hasOwn(config, variant)\n ? config[variant as keyof typeof config]\n : undefined\n}\n"],"mappings":"AAGA,IAAM,IAAA,CAAiB,OAAkB,EACvC,OAAO,CAAC,EAAM,QAAQ,WAAW,gBAAgB,EAAM,QAAQ,MAAM,MAAM,EAC7E,IAEM,IAAA,CAAmB,OAAkB,EACzC,OAAO,CAAC,EAAM,QAAQ,UAAU,YAAY,EAAM,QAAQ,UAAU,UAAU,EAChF,IAEa,IAAA,CAAmB,GAAc,MAA4B;AACxE,QAAM,IAAS;AAAA,IACb,eAAe,EAAc,CAAK;AAAA,IAElC,iBAAiB,EAAc,CAAK;AAAA,IAGpC,gBAAgB,EACd,OAAO,CAAC,EAAM,QAAQ,MAAM,QAAQ,EAAM,QAAQ,MAAM,MAAM,EAChE;AAAA,IACA,iBAAiB,EAAgB,CAAK;AAAA,IAEtC,mBAAmB,EAAgB,CAAK;AAAA,EAC1C;AAGA,SAAO,KAAW,OAAO,OAAO,GAAQ,CAAO,IAC3C,EAAO,CAAA,IACP;AACN"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mx-cartographer/experiences",
3
- "version": "9.7.134",
3
+ "version": "9.7.135",
4
4
  "description": "Library containing experience widgets",
5
5
  "author": "MX",
6
6
  "license": "MIT",