@mx-cartographer/experiences 9.7.56 → 9.7.58

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 (49) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/core/stores/TransactionStore.d.ts +6 -0
  3. package/dist/core/stores/TransactionStore.es.js +45 -33
  4. package/dist/core/stores/TransactionStore.es.js.map +1 -1
  5. package/dist/core/types/InsightsInstanceSlotData.d.ts +2 -1
  6. package/dist/core/types/InsightsInstanceSlotData.es.js.map +1 -1
  7. package/dist/core/types/localization/InsightsFeedCopy.d.ts +8 -0
  8. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.d.ts +5 -1
  9. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js +63 -58
  10. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js.map +1 -1
  11. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +115 -107
  12. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
  13. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +7 -1
  14. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +88 -59
  15. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
  16. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.d.ts +7 -1
  17. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.es.js +13 -13
  18. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.es.js.map +1 -1
  19. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.d.ts +1 -1
  20. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js +10 -7
  21. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js.map +1 -1
  22. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.d.ts +46 -15
  23. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js +87 -59
  24. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js.map +1 -1
  25. package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js +93 -53
  26. package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js.map +1 -1
  27. package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/layout.d.ts +20 -20
  28. package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/layout.es.js +48 -39
  29. package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/layout.es.js.map +1 -1
  30. package/dist/insights-v2/components/LogoClusterCard.d.ts +7 -1
  31. package/dist/insights-v2/components/LogoClusterCard.es.js +54 -48
  32. package/dist/insights-v2/components/LogoClusterCard.es.js.map +1 -1
  33. package/dist/insights-v2/components/LogoTile.d.ts +6 -4
  34. package/dist/insights-v2/components/LogoTile.es.js +21 -19
  35. package/dist/insights-v2/components/LogoTile.es.js.map +1 -1
  36. package/dist/insights-v2/components/MerchantHighlightCard.d.ts +8 -3
  37. package/dist/insights-v2/components/MerchantHighlightCard.es.js +24 -21
  38. package/dist/insights-v2/components/MerchantHighlightCard.es.js.map +1 -1
  39. package/dist/insights-v2/components/P2PLogoStack.d.ts +7 -1
  40. package/dist/insights-v2/components/P2PLogoStack.es.js +34 -26
  41. package/dist/insights-v2/components/P2PLogoStack.es.js.map +1 -1
  42. package/dist/insights-v2/components/celebrationGradients.d.ts +6 -3
  43. package/dist/insights-v2/components/celebrationGradients.es.js +8 -7
  44. package/dist/insights-v2/components/celebrationGradients.es.js.map +1 -1
  45. package/dist/insights-v2/components/statusTokens.d.ts +0 -5
  46. package/dist/insights-v2/components/statusTokens.es.js +0 -5
  47. package/dist/insights-v2/components/statusTokens.es.js.map +1 -1
  48. package/dist/insights-v2/index.es.js +75 -75
  49. package/package.json +1 -1
@@ -1,78 +1,99 @@
1
- import { DATE_FORMATS_INTL as l } from "../../../core/constants/DateFormats.es.js";
2
- import { buildChartData as u, buildDataSeries as d } from "../../blocks/ChartBlocks/BarchartBlock/utils.es.js";
3
- import { buildComparisonSeries as g } from "../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js";
4
- import { DRILLDOWN_VARIANTS as m, FALLBACK as _, layout as h } from "./layout.es.js";
5
- import { format as D, fromUnixTime as f } from "date-fns";
6
- var I = (t) => h[t] ?? _, A = ({ data: t, ariaLabel: e, top: r, beatTransactions: s, payload: o }) => {
7
- if (r === "upcomingBill") {
8
- const i = S(s, o);
1
+ import { DATE_FORMATS_INTL as f, formatDate as h } from "../../../core/constants/DateFormats.es.js";
2
+ import { fromUnixUTC as p } from "../../../core/utils/DateUtil.es.js";
3
+ import { buildChartData as c, buildDataSeries as l } from "../../blocks/ChartBlocks/BarchartBlock/utils.es.js";
4
+ import { buildComparisonSeries as _ } from "../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js";
5
+ import { DRILLDOWN_VARIANTS as D, FALLBACK as T, layout as b } from "./layout.es.js";
6
+ import { format as y, isValid as S, parseISO as g } from "date-fns";
7
+ var M = (t) => b[t] ?? T, j = ({ data: t, ariaLabel: e, top: a, beatTransactions: n }) => {
8
+ if (a === "upcomingBill") {
9
+ const r = x(n);
9
10
  return {
10
- dataSeries: i,
11
- chartData: u(i, e, l.MONTH_DAY),
11
+ dataSeries: r,
12
+ chartData: c(r, e).map((o, d) => r[d].label ? {
13
+ ...o,
14
+ label: r[d].label
15
+ } : o),
12
16
  comparisonBars: []
13
17
  };
14
18
  }
15
- if (r === "tabsOnly") return {
16
- dataSeries: d(t).filter((i) => i.localized_label),
19
+ if (a === "tabsOnly") return {
20
+ dataSeries: l(t).filter((r) => r.localized_label),
17
21
  chartData: [],
18
22
  comparisonBars: []
19
23
  };
20
- const a = [...d(t)].sort((i, n) => !i.date || !n.date ? 0 : new Date(i.date).getTime() - new Date(n.date).getTime());
21
- return r === "doubleBar" ? {
22
- dataSeries: a,
24
+ const i = [...l(t)].sort((r, o) => !r.date || !o.date ? 0 : new Date(r.date).getTime() - new Date(o.date).getTime());
25
+ return a === "doubleBar" ? {
26
+ dataSeries: i,
23
27
  chartData: [],
24
- comparisonBars: g(t, e)
28
+ comparisonBars: _(t, e)
25
29
  } : {
26
- dataSeries: a,
27
- chartData: u(a, e),
30
+ dataSeries: i,
31
+ chartData: c(i, e),
28
32
  comparisonBars: []
29
33
  };
30
- }, p = "TRN-projected-bill", B = (t) => ({
31
- date: D(f(t.date), "yyyy-MM-dd"),
34
+ }, B = "TRN-projected-bill", u = (t) => ({
35
+ date: y(p(t.date), "yyyy-MM-dd"),
32
36
  amount: t.amount,
33
37
  guid: t.guid,
34
38
  category_guid: t.top_level_category_guid ?? t.category_guid
35
- }), S = (t = [], e) => {
36
- if (!t.length || e?.date == null || e?.amount == null) return [];
37
- const r = [...t].sort((n, c) => n.date - c.date), s = /* @__PURE__ */ new Set(), o = [];
38
- for (const n of r)
39
- s.has(n.date) || (s.add(n.date), o.push(B(n)));
40
- const a = r[r.length - 1], i = {
41
- date: e.date,
42
- amount: e.amount,
43
- guid: p,
44
- category_guid: a.top_level_category_guid ?? a.category_guid
39
+ }), v = (t) => {
40
+ const e = t[t.length - 1];
41
+ return e?.guid !== "TRN-projected-bill" ? { transactions: t } : {
42
+ transactions: t.slice(0, -1),
43
+ projectedTransaction: e
45
44
  };
46
- return [...o, i];
47
- }, w = (t, e) => {
48
- const r = e.insights_feed?.general?.transaction_history_title ?? "", s = e.insights_feed?.transaction_history_block;
49
- if (t === m.TRANSACTION) return r;
50
- const o = `${t}_drawer_title`;
51
- return s?.[o] ?? r;
52
- }, C = (t, e) => ({
45
+ }, x = (t = []) => {
46
+ const { transactions: e, projectedTransaction: a } = v(t);
47
+ if (!a || !e.length) return [];
48
+ const n = [...e].sort((s, m) => s.date - m.date), i = /* @__PURE__ */ new Set(), r = [];
49
+ for (const s of n)
50
+ i.has(s.date) || (i.add(s.date), r.push(u(s)));
51
+ const o = [...r, u(a)], d = o.map((s) => s.date.slice(0, 7));
52
+ return new Set(d).size === d.length ? o : o.map((s) => ({
53
+ ...s,
54
+ label: h(g(s.date), f.MONTH_DAY)
55
+ }));
56
+ }, L = (t = [], e) => {
57
+ if (!(!t.length || e?.date == null || e?.amount == null))
58
+ return {
59
+ ...t.reduce((a, n) => n.date > a.date ? n : a),
60
+ guid: B,
61
+ amount: e.amount,
62
+ date: A(e.date),
63
+ has_been_split: !1,
64
+ is_hidden: !1,
65
+ is_flagged: !1,
66
+ parent_guid: null
67
+ };
68
+ }, U = (t, e) => {
69
+ const a = e.insights_feed?.general?.transaction_history_title ?? "", n = e.insights_feed?.transaction_history_block;
70
+ if (t === D.TRANSACTION) return a;
71
+ const i = `${t}_drawer_title`;
72
+ return n?.[i] ?? a;
73
+ }, F = (t, e) => ({
53
74
  accounts: t.accounts ?? e.allAccountGuids,
54
75
  dateRange: t.dateRange ?? e.displayedDateRange,
55
76
  custom: t.custom ?? (() => !0),
56
77
  showSplits: t.showSplits ?? !1
57
- }), R = ({ chartTabCount: t, comparisonTabCount: e, actionDrawer: r, beatGuid: s }) => {
58
- const o = e || t, a = r.guid === s && r.trigger === "chartBar", i = r.context, n = a ? i?.tabIndex ?? 0 : 0;
59
- return a ? {
60
- chartBarIndex: Math.min(Math.max(i?.chartBarIndex ?? 0, 0), Math.max(0, o - 1)),
61
- subTabIndex: n
78
+ }), E = ({ chartTabCount: t, comparisonTabCount: e, actionDrawer: a, beatGuid: n }) => {
79
+ const i = e || t, r = a.guid === n && a.trigger === "chartBar", o = a.context, d = r ? o?.tabIndex ?? 0 : 0;
80
+ return r ? {
81
+ chartBarIndex: Math.min(Math.max(o?.chartBarIndex ?? 0, 0), Math.max(0, i - 1)),
82
+ subTabIndex: d
62
83
  } : {
63
- chartBarIndex: Math.max(0, o - 1),
64
- subTabIndex: n
84
+ chartBarIndex: Math.max(0, i - 1),
85
+ subTabIndex: d
65
86
  };
66
- }, M = ({ series: t, category_guid: e, average_amount: r, additional_data: s }) => {
67
- const o = d(t).map(({ guid: a }) => a).filter((a) => !!a);
87
+ }, A = (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) && S(g(t)) ? t : void 0, $ = ({ series: t, category_guid: e, average_amount: a, additional_data: n }) => {
88
+ const i = l(t).map(({ guid: r }) => r).filter((r) => !!r);
68
89
  return {
69
90
  data_series: t,
70
91
  category_guid: e,
71
- average_amount: r,
72
- legends: s,
73
- transaction_guids: o.length ? o : void 0
92
+ average_amount: a,
93
+ legends: n,
94
+ transaction_guids: i.length ? i : void 0
74
95
  };
75
- }, N = (t) => {
96
+ }, k = (t) => {
76
97
  if (t)
77
98
  return {
78
99
  text: t.subtitle ?? "",
@@ -83,15 +104,22 @@ var I = (t) => h[t] ?? _, A = ({ data: t, ariaLabel: e, top: r, beatTransactions
83
104
  };
84
105
  };
85
106
  export {
86
- p as PROJECTED_BILL_GUID,
87
- S as buildUpcomingBillSeries,
88
- R as getDefaultSelection,
89
- w as getDrawerHeaderTitle,
90
- I as getDrillDownConfig,
91
- A as getFlattenedDataSeries,
92
- N as resolveDrillDownSubHeader,
93
- M as toDrillDownSlotData,
94
- C as toStoreFilter
107
+ B as PROJECTED_BILL_GUID,
108
+ L as buildProjectedBillTransaction,
109
+ x as buildUpcomingBillSeries,
110
+ V as calendarDateOf,
111
+ H as finiteNumberOf,
112
+ E as getDefaultSelection,
113
+ U as getDrawerHeaderTitle,
114
+ M as getDrillDownConfig,
115
+ j as getFlattenedDataSeries,
116
+ P as guidListOf,
117
+ G as nonEmptyStringOf,
118
+ k as resolveDrillDownSubHeader,
119
+ v as splitProjectedTransaction,
120
+ $ as toDrillDownSlotData,
121
+ F as toStoreFilter,
122
+ A as utcDayToUnix
95
123
  };
96
124
 
97
125
  //# 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, fromUnixTime } from 'date-fns'\n\nimport type {\n ActionDrawerState,\n DataSeries,\n DrilldownPayload,\n GlobalCopy,\n InsightsPayload,\n Subtitle,\n Transaction,\n} from '../../../core'\nimport { DATE_FORMATS_INTL } from '../../../core/constants'\nimport type {\n BarChartBlockData,\n DataSet,\n InsightsInstanceSlotData,\n} from '../../../core/types/InsightsInstanceSlotData'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\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.\n beatTransactions: Transaction[]\n payload: { date?: string; amount?: number } | undefined\n}\n\nexport const getFlattenedDataSeries = ({\n data,\n ariaLabel,\n top,\n beatTransactions,\n payload,\n}: FlattenedDataSeriesInput): FlattenedDataSeries => {\n // UpcomingBill has no backend data_series: synthesize the bars from the beat's recurring-bill\n // transactions + the projected bill, and label each bar by day (MONTH_DAY) since a bar is one bill.\n if (top === 'upcomingBill') {\n const dataSeries = buildUpcomingBillSeries(beatTransactions, payload)\n return {\n dataSeries,\n chartData: buildChartData(dataSeries, ariaLabel, DATE_FORMATS_INTL.MONTH_DAY),\n comparisonBars: [],\n }\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 // Single-bar family (THIS MR): the backend sends data_series newest-first, so normalize it\n // date-ascending here. chartData/tabs and the filter's dataSeries[selectedIndex] indexing both read\n // this one 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 // Double bar: comparison beats build paired month columns (with their guids) instead of chartData.\n if (top === 'doubleBar') {\n return { dataSeries, chartData: [], comparisonBars: buildComparisonSeries(data, ariaLabel) }\n }\n\n return { dataSeries, chartData: buildChartData(dataSeries, ariaLabel), comparisonBars: [] }\n}\n\n// Sentinel guid for the synthesized projected bill. It intentionally matches no real store\n// transaction, so the projected tab's guid filter yields an empty list (projected-bar-only scope).\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 both\n// historical unix timestamps and the ISO payload date after normalization here.\nexport interface UpcomingBillBar {\n date: string\n amount: number\n guid: string\n category_guid?: string\n}\n\nconst toUpcomingBillBar = (transaction: Transaction): UpcomingBillBar => ({\n date: format(fromUnixTime(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 * UpcomingBill has no data_series: build the bar series straight from the beat's recurring-bill\n * transactions plus the synthesized projected bill from payload (mirrors pulse's magicTransactions).\n * Historical bills are de-duped by date and each keeps its real transaction guid so the guid filter\n * finds it in the store; the projected bar (cloned category from the latest bill) carries the\n * PROJECTED_BILL_GUID sentinel. The result is sorted date-ascending so the projected bill lands last.\n */\nexport const buildUpcomingBillSeries = (\n transactions: Transaction[] = [],\n payload: { date?: string; amount?: number } | undefined,\n): UpcomingBillBar[] => {\n if (!transactions.length || payload?.date == null || payload?.amount == null) {\n return []\n }\n\n const sorted = [...transactions].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 latestBill = sorted[sorted.length - 1]\n const projected: UpcomingBillBar = {\n date: payload.date,\n amount: payload.amount,\n guid: PROJECTED_BILL_GUID,\n category_guid: latestBill.top_level_category_guid ?? latestBill.category_guid,\n }\n\n return [...history, projected]\n}\n\nexport const getDrawerHeaderTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\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 // Safely access the drawer title from transaction_history_block\n const key = `${variant}_drawer_title` 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/** The drawer's facts: the generic slot facts plus the bar chart's average. */\nexport type DrillDownSlotData = InsightsInstanceSlotData & Pick<BarChartBlockData, 'average_amount'>\n\n/** The drawer's facts from a bar chart's `instance_slot.data`. */\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":";;;;;AAuCA,IAAa,IAAA,CAAsB,MACjC,EAAO,CAAA,KAAgC,GAwB5B,IAAA,CAA0B,EACrC,MAAA,GACA,WAAA,GACA,KAAA,GACA,kBAAA,GACA,SAAA,EAAA,MACmD;AAGnD,MAAI,MAAQ,gBAAgB;AAC1B,UAAM,IAAa,EAAwB,GAAkB,CAAO;AACpE,WAAO;AAAA,MACL,YAAA;AAAA,MACA,WAAW,EAAe,GAAY,GAAW,EAAkB,SAAS;AAAA,MAC5E,gBAAgB,CAAC;AAAA,IACnB;AAAA,EACF;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;AAMF,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;AAGD,SAAI,MAAQ,cACH;AAAA,IAAE,YAAA;AAAA,IAAY,WAAW,CAAC;AAAA,IAAG,gBAAgB,EAAsB,GAAM,CAAS;AAAA,EAAE,IAGtF;AAAA,IAAE,YAAA;AAAA,IAAY,WAAW,EAAe,GAAY,CAAS;AAAA,IAAG,gBAAgB,CAAC;AAAA,EAAE;AAC5F,GAIa,IAAsB,sBAW7B,IAAA,CAAqB,OAA+C;AAAA,EACxE,MAAM,EAAO,EAAa,EAAY,IAAI,GAAG,YAAY;A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AU,EAAa,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,GAMa,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 DataSeries,\n DrilldownPayload,\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 // Single-bar family (THIS MR): the backend sends data_series newest-first, so normalize it\n // date-ascending here. chartData/tabs and the filter's dataSeries[selectedIndex] indexing both read\n // this one 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 // Double bar: comparison beats build paired month columns (with their guids) instead of chartData.\n if (top === 'doubleBar') {\n return { dataSeries, chartData: [], comparisonBars: buildComparisonSeries(data, ariaLabel) }\n }\n\n return { dataSeries, chartData: buildChartData(dataSeries, ariaLabel), comparisonBars: [] }\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): 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 // Safely access the drawer title from transaction_history_block\n const key = `${variant}_drawer_title` 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'> & { merchant_name?: string }\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/** Resolves the drawer's facts (bars, guids, colour, average, tip values) from the beat's payload. */\nexport type SlotDataResolver = (payload: Partial<InsightsPayload> | undefined) => 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":";;;;;;AAwCA,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;AAMF,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;AAGD,SAAI,MAAQ,cACH;AAAA,IAAE,YAAA;AAAA,IAAY,WAAW,CAAC;AAAA,IAA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AAAA,IAAG,aAAA;AAAA,EAAY;AACjE,GAWa,IAAA,CAAgB,MAAwB,KAAK,MAAM,GAAG,CAAA,YAAe,IAAI,KAIzE,IAAA,CAAkB,MAC7B,OAAO,KAAU,YAAY,OAAO,SAAS,CAAK,IAAI,IAAQ,QAEnD,IAAA,CAAoB,MAC/B,OAAO,KAAU,YAAY,EAAM,KAAK,MAAM,KAAK,IAAQ,QAEhD,IAAA,CAAc,MACzB,MAAM,QAAQ,CAAK,KACnB,EAAM,SAAS,KACf,EAAM,MAAA,CAAO,MAAS,OAAO,KAAS,YAAY,MAAS,EAAE,IACxD,IACD,QAGO,IAAA,CAAkB,MAC7B,OAAO,KAAU,YAAY,sBAAsB,KAAK,CAAK,KAAK,EAAQ,EAAS,CAAK,CAAC,IACrF,IACA,QAeO,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,74 +1,114 @@
1
1
  import { slot as s } from "../../../../core/types/Insights.es.js";
2
- import { formatCurrency as L } from "../../../../core/utils/NumberFormatting.es.js";
3
- import S from "../../../components/StatusPill.es.js";
4
- import _, { isLogoGuid as C } from "../../../components/LogoFromGuid.es.js";
5
- import { resolveVariantConfig as k } from "../../resolveVariantConfig.es.js";
6
- import x from "../../../components/LogoClusterCard.es.js";
7
- import y from "../../../components/MerchantHighlightCard.es.js";
8
- import { MERCHANT_LAYOUT as A, STATUS_PILL_TOKENS as E, merchantBlockVariant as I } from "./layout.es.js";
9
- import { Icon as b } from "@mxenabled/mx-icons";
2
+ import { formatCurrency as A } from "../../../../core/utils/NumberFormatting.es.js";
3
+ import L from "../../../components/StatusPill.es.js";
4
+ import v, { isLogoGuid as S } from "../../../components/LogoFromGuid.es.js";
5
+ import { resolveVariantConfig as x } from "../../resolveVariantConfig.es.js";
6
+ import O from "../../../components/LogoClusterCard.es.js";
7
+ import E from "../../../components/MerchantHighlightCard.es.js";
8
+ import B from "../../../components/P2PLogoStack.es.js";
9
+ import { MERCHANT_LAYOUT as N, merchantBlockVariant as R } from "./layout.es.js";
10
+ import w from "@mui/material/Stack";
11
+ import { Icon as _ } from "@mxenabled/mx-icons";
10
12
  import { jsx as e } from "react/jsx-runtime";
11
- var O = 64, T = 72, G = 32, d = (r) => typeof r == "string" ? r : void 0, h = /* @__PURE__ */ e(b, {
13
+ var u = 64, p = 6, z = 72, G = 3, M = [
14
+ 10,
15
+ 20,
16
+ 35
17
+ ], F = 32, i = (t) => typeof t == "string" ? t : void 0, g = (t) => {
18
+ if (!t || typeof t != "object" || Array.isArray(t)) return;
19
+ const { alt: a, color: r, fallback_guid: o, guid: n } = t;
20
+ if (!(typeof n != "string" || !S(n)))
21
+ return {
22
+ alt: i(a),
23
+ color: i(r),
24
+ fallback_guid: i(o),
25
+ guid: n
26
+ };
27
+ }, I = (t) => {
28
+ if (!Array.isArray(t)) return [];
29
+ const a = /* @__PURE__ */ new Map();
30
+ for (const r of t.map(g)) r?.guid && !a.has(r.guid) && a.set(r.guid, r);
31
+ return [...a.values()];
32
+ }, y = /* @__PURE__ */ e(_, {
12
33
  "aria-hidden": !0,
13
34
  "data-icon": "storefront",
14
35
  name: "storefront",
15
- size: G,
36
+ size: F,
16
37
  sx: { color: "text.secondary" }
17
- }), N = (r) => {
18
- if (!Array.isArray(r)) return [];
19
- const o = /* @__PURE__ */ new Set();
20
- return r.filter((t) => !C(t?.guid) || o.has(t.guid) ? !1 : (o.add(t.guid), !0));
21
- }, H = ({ payload: r }) => {
22
- const { instance_slot: o } = r, { data: t } = o, a = k(A, o.variant, I.SingleStandard, "MerchantBlock"), l = (i) => s(t, i) ?? o[i], m = d(l("status_text")), n = a.status ? E[a.status] : void 0, g = n && m ? /* @__PURE__ */ e(S, {
23
- bgcolor: n.bgcolor,
24
- borderColor: n.borderColor,
25
- icon: /* @__PURE__ */ e(b, {
38
+ }), k = (t, a) => t.length ? t.map((r) => /* @__PURE__ */ e(v, {
39
+ logo: r,
40
+ size: a
41
+ }, r.guid)) : [y], J = ({ payload: t }) => {
42
+ const { instance_slot: a } = t, { data: r } = a, o = x(N, a.variant, R.SingleStandard, "MerchantBlock"), n = (l) => s(r, l) ?? a[l], m = i(n("status_text")), f = o.status && m ? /* @__PURE__ */ e(L, {
43
+ icon: /* @__PURE__ */ e(_, {
26
44
  "aria-hidden": !0,
27
- "data-icon": n.icon,
28
- name: n.icon,
45
+ "data-icon": "check_circle",
46
+ fill: !0,
47
+ name: "check_circle",
29
48
  size: 16,
30
- sx: { color: n.borderColor }
49
+ sx: { color: "success.700" }
31
50
  }),
32
51
  label: m,
33
- labelColor: n.textColor,
34
- sx: a.kind === "multiple" ? {
52
+ sx: o.kind === "single" ? void 0 : {
35
53
  alignSelf: "stretch",
36
54
  justifyContent: "center"
37
- } : void 0
55
+ }
38
56
  }) : void 0;
39
- if (a.kind === "multiple") {
40
- const i = N(s(t, "logos"));
41
- return /* @__PURE__ */ e(x, {
42
- background: a.background,
43
- footer: g,
44
- logos: i.length ? i.map((p) => /* @__PURE__ */ e(_, {
45
- logo: p,
46
- size: T
47
- }, p.guid)) : [h]
57
+ if (o.kind !== "single") {
58
+ const l = I(s(r, "logos"));
59
+ return o.kind === "ranked" && l.length ? /* @__PURE__ */ e(O, {
60
+ background: o.background,
61
+ fullBleed: !0,
62
+ logos: k(l.slice(0, G), z),
63
+ overlap: p,
64
+ rankOffsets: M,
65
+ ranked: !0
66
+ }) : /* @__PURE__ */ e(w, {
67
+ sx: {
68
+ background: o.background,
69
+ bgcolor: o.background ? void 0 : o.bgcolor,
70
+ p: 16,
71
+ width: "100%"
72
+ },
73
+ children: /* @__PURE__ */ e(B, {
74
+ borderColor: null,
75
+ logos: k(l, u),
76
+ overlap: p,
77
+ shadow: "elevation",
78
+ size: u,
79
+ status: f
80
+ })
48
81
  });
49
82
  }
50
- const u = d(l("merchant_name"));
51
- if (!u) return null;
52
- const c = l("amount"), v = d(s(t, "date")), f = s(t, "logo") ?? (o.merchant_guid ? {
53
- alt: u,
54
- fallback_guid: o.category_guid,
55
- guid: o.merchant_guid
56
- } : void 0);
57
- return /* @__PURE__ */ e(y, {
58
- amount: typeof c == "number" && c !== 0 ? L(c, "0,0.00") : void 0,
59
- amountVariant: a.amountVariant,
60
- background: a.background,
61
- eyebrow: v,
62
- logo: C(f?.guid) ? /* @__PURE__ */ e(_, {
63
- logo: f,
64
- size: O
65
- }) : h,
66
- name: u,
67
- trailing: g
83
+ const d = i(s(r, "primary_text")) || i(n("merchant_name"));
84
+ if (!d) return null;
85
+ const c = n("amount"), C = i(s(r, "header_text")) || i(s(r, "date")), b = g(s(r, "logo")) ?? g({
86
+ alt: d,
87
+ fallback_guid: a.category_guid,
88
+ guid: a.merchant_guid
89
+ }), h = o.logo?.size ?? u;
90
+ return /* @__PURE__ */ e(E, {
91
+ amount: typeof c == "number" && Number.isFinite(c) && c !== 0 ? A(c, "0,0.00") : void 0,
92
+ amountVariant: o.amountVariant,
93
+ background: o.background,
94
+ bgcolor: o.bgcolor,
95
+ borderColor: o.borderColor,
96
+ eyebrow: o.hideDate ? void 0 : C,
97
+ fullBleed: o.fullBleed,
98
+ logo: b ? /* @__PURE__ */ e(v, {
99
+ logo: b,
100
+ size: h
101
+ }) : y,
102
+ logoBorderColor: o.logo?.borderColor,
103
+ logoRadius: o.logo?.radius,
104
+ logoShadow: o.logo?.shadow,
105
+ logoSize: h,
106
+ name: d,
107
+ trailing: f
68
108
  });
69
109
  };
70
110
  export {
71
- H as default
111
+ J as default
72
112
  };
73
113
 
74
114
  //# sourceMappingURL=MerchantBlock.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MerchantBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.tsx"],"sourcesContent":["import { Icon } from '@mxenabled/mx-icons'\n\nimport { slot, type InsightsPayload, type InstanceSlot, type LogoRef } from '../../../../core'\nimport type { MerchantBlockData } from '../../../../core/types/InsightsInstanceSlotData'\nimport { formatCurrency } from '../../../../core/utils/NumberFormatting'\n\nimport LogoClusterCard from '../../../components/LogoClusterCard'\nimport LogoFromGuid, { isLogoGuid } from '../../../components/LogoFromGuid'\nimport MerchantHighlightCard from '../../../components/MerchantHighlightCard'\nimport StatusPill from '../../../components/StatusPill'\nimport { resolveVariantConfig } from '../../resolveVariantConfig'\n\nimport { MERCHANT_LAYOUT, merchantBlockVariant, STATUS_PILL_TOKENS } from './layout'\n\ninterface MerchantBlockProps {\n payload: InsightsPayload\n}\n\nconst SINGLE_LOGO_SIZE = 64\nconst CLUSTER_LOGO_SIZE = 72\nconst FALLBACK_ICON_SIZE = 32\n\nconst text = (v: unknown) => (typeof v === 'string' ? v : undefined)\n\nconst storefront = (\n <Icon\n aria-hidden={true}\n data-icon=\"storefront\"\n name=\"storefront\"\n size={FALLBACK_ICON_SIZE}\n sx={{ color: 'text.secondary' }}\n />\n)\n\nconst uniqueLogos = (refs: unknown): LogoRef[] => {\n if (!Array.isArray(refs)) return []\n const seen = new Set<string>()\n return refs.filter((ref: LogoRef | null | undefined): ref is LogoRef => {\n if (!isLogoGuid(ref?.guid) || seen.has(ref.guid)) return false\n seen.add(ref.guid)\n return true\n })\n}\n\nconst MerchantBlock = ({ payload }: MerchantBlockProps) => {\n const { instance_slot } = payload\n const { data } = instance_slot\n const config = resolveVariantConfig(\n MERCHANT_LAYOUT,\n instance_slot.variant,\n merchantBlockVariant.SingleStandard,\n 'MerchantBlock',\n )\n const field = <K extends keyof InstanceSlot>(key: K) =>\n slot<InstanceSlot[K]>(data, key) ?? instance_slot[key]\n\n const statusText = text(field('status_text'))\n const tokens = config.status ? STATUS_PILL_TOKENS[config.status] : undefined\n const statusPill =\n tokens && statusText ? (\n <StatusPill\n bgcolor={tokens.bgcolor}\n borderColor={tokens.borderColor}\n icon={\n <Icon\n aria-hidden={true}\n data-icon={tokens.icon}\n name={tokens.icon}\n size={16}\n sx={{ color: tokens.borderColor }}\n />\n }\n label={statusText}\n labelColor={tokens.textColor}\n sx={\n config.kind === 'multiple'\n ? { alignSelf: 'stretch', justifyContent: 'center' }\n : undefined\n }\n />\n ) : undefined\n\n if (config.kind === 'multiple') {\n const logos = uniqueLogos(slot<MerchantBlockData['logos']>(data, 'logos'))\n\n return (\n <LogoClusterCard\n background={config.background}\n footer={statusPill}\n logos={\n logos.length\n ? logos.map((ref) => (\n <LogoFromGuid key={ref.guid} logo={ref} size={CLUSTER_LOGO_SIZE} />\n ))\n : [storefront]\n }\n />\n )\n }\n\n const merchantName = text(field('merchant_name'))\n if (!merchantName) return null\n\n const amount = field('amount')\n const date = text(slot<unknown>(data, 'date'))\n const logo =\n slot<LogoRef>(data, 'logo') ??\n (instance_slot.merchant_guid\n ? {\n alt: merchantName,\n fallback_guid: instance_slot.category_guid,\n guid: instance_slot.merchant_guid,\n }\n : undefined)\n\n return (\n <MerchantHighlightCard\n amount={\n typeof amount === 'number' && amount !== 0 ? formatCurrency(amount, '0,0.00') : undefined\n }\n amountVariant={config.amountVariant}\n background={config.background}\n eyebrow={date}\n logo={\n isLogoGuid(logo?.guid) ? <LogoFromGuid logo={logo} size={SINGLE_LOGO_SIZE} /> : storefront\n }\n name={merchantName}\n trailing={statusPill}\n />\n )\n}\n\nexport default MerchantBlock\n"],"mappings":";;;;;;;;;;AAkBA,IAAM,IAAmB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,SAAS,YAAY;AAC9B,UAAM,IAAQ,EAAY,EAAiC,GAAM,OAAO,CAAC;AAEzE,WACE,gBAAA,EAAC,GAAD;AAAA,MACE,YAAY,EAAO;AAAA,MACnB,QAAQ;AAAA,MACR,OACE,EAAM,SACF,EAAM,IAAA,CAAK,MACT,gBAAA,EAAC,GAAD;AAAA,QAA6B,MAAM;AAAA,QAAK,MAAM;AAAA,MAAoB,GAA/C,EAAI,IAA2C,CACnE,IACD,CAAC,CAAU;AAAA,IAElB,CAAA;AAAA,EAEL;AAEA,QAAM,IAAe,EAAK,EAAM,eAAe,CAAC;AAChD,MAAI,CAAC,EAAc,QAAO;AAE1B,QAAM,IAAS,EAAM,QAAQ,GACvB,IAAO,EAAK,EAAc,GAAM,MAAM,CAAC,GACvC,IACJ,EAAc,GAAM,MAAM,MACzB,EAAc,gBACX;AAAA,IACE,KAAK;AAAA,IACL,eAAe,EAAc;AAAA,IAC7B,MAAM,EAAc;AAAA,EACtB,IACA;AAEN,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,QACE,OAAO,KAAW,YAAY,MAAW,IAAI,EAAe,GAAQ,QAAQ,IAAI;AAAA,IAElF,eAAe,EAAO;AAAA,IACtB,YAAY,EAAO;AAAA,IACnB,SAAS;AAAA,IACT,MACE,EAAW,GAAM,IAAI,IAAI,gBAAA,EAAC,GAAD;AAAA,MAAoB,MAAA;AAAA,MAAM,MAAM;AAAA,IAAmB,CAAA,IAAI;AAAA,IAElF,MAAM;AAAA,IACN,UAAU;AAAA,EACX,CAAA;AAEL"}
1
+ {"version":3,"file":"MerchantBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\n\nimport { slot, type InsightsPayload, type InstanceSlot, type LogoRef } from '../../../../core'\nimport type { MerchantBlockData } from '../../../../core/types/InsightsInstanceSlotData'\nimport { formatCurrency } from '../../../../core/utils/NumberFormatting'\n\nimport LogoClusterCard from '../../../components/LogoClusterCard'\nimport LogoFromGuid, { isLogoGuid } from '../../../components/LogoFromGuid'\nimport MerchantHighlightCard from '../../../components/MerchantHighlightCard'\nimport P2PLogoStack from '../../../components/P2PLogoStack'\nimport StatusPill from '../../../components/StatusPill'\nimport { resolveVariantConfig } from '../../resolveVariantConfig'\n\nimport { MERCHANT_LAYOUT, merchantBlockVariant } from './layout'\n\ninterface MerchantBlockProps {\n payload: InsightsPayload\n}\n\nconst LOGO_SIZE = 64\nconst LOGO_OVERLAP = 6\nconst RANKED_LOGO_SIZE = 72\nconst RANKED_MAX = 3\nconst RANKED_OFFSETS = [10, 20, 35] as const\nconst FALLBACK_ICON_SIZE = 32\n\nconst text = (v: unknown) => (typeof v === 'string' ? v : undefined)\n\n/** A logo-guid object as a `LogoRef`, else undefined. */\nconst asLogoRef = (value: unknown): LogoRef | undefined => {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return undefined\n const { alt, color, fallback_guid, guid } = value as Record<string, unknown>\n if (typeof guid !== 'string' || !isLogoGuid(guid)) return undefined\n return { alt: text(alt), color: text(color), fallback_guid: text(fallback_guid), guid }\n}\n\nconst uniqueLogos = (refs: unknown): LogoRef[] => {\n if (!Array.isArray(refs)) return []\n const byGuid = new Map<string, LogoRef>()\n for (const ref of refs.map(asLogoRef)) {\n if (ref?.guid && !byGuid.has(ref.guid)) byGuid.set(ref.guid, ref)\n }\n return [...byGuid.values()]\n}\n\nconst storefront = (\n <Icon\n aria-hidden={true}\n data-icon=\"storefront\"\n name=\"storefront\"\n size={FALLBACK_ICON_SIZE}\n sx={{ color: 'text.secondary' }}\n />\n)\n\nconst logoTiles = (refs: LogoRef[], size: number) =>\n refs.length\n ? refs.map((ref) => <LogoFromGuid key={ref.guid} logo={ref} size={size} />)\n : [storefront]\n\nconst MerchantBlock = ({ payload }: MerchantBlockProps) => {\n const { instance_slot } = payload\n const { data } = instance_slot\n const config = resolveVariantConfig(\n MERCHANT_LAYOUT,\n instance_slot.variant,\n merchantBlockVariant.SingleStandard,\n 'MerchantBlock',\n )\n const field = <K extends keyof InstanceSlot>(key: K) =>\n slot<InstanceSlot[K]>(data, key) ?? instance_slot[key]\n\n const statusText = text(field('status_text'))\n const statusPill =\n config.status && statusText ? (\n <StatusPill\n icon={\n <Icon\n aria-hidden={true}\n data-icon=\"check_circle\"\n fill={true}\n name=\"check_circle\"\n size={16}\n sx={{ color: 'success.700' }}\n />\n }\n label={statusText}\n sx={\n config.kind === 'single' ? undefined : { alignSelf: 'stretch', justifyContent: 'center' }\n }\n />\n ) : undefined\n\n if (config.kind !== 'single') {\n const logos = uniqueLogos(slot<MerchantBlockData['logos']>(data, 'logos'))\n\n if (config.kind === 'ranked' && logos.length) {\n return (\n <LogoClusterCard\n background={config.background}\n fullBleed={true}\n logos={logoTiles(logos.slice(0, RANKED_MAX), RANKED_LOGO_SIZE)}\n overlap={LOGO_OVERLAP}\n rankOffsets={RANKED_OFFSETS}\n ranked={true}\n />\n )\n }\n\n return (\n <Stack\n sx={{\n background: config.background,\n bgcolor: config.background ? undefined : config.bgcolor,\n p: 16,\n width: '100%',\n }}\n >\n <P2PLogoStack\n borderColor={null}\n logos={logoTiles(logos, LOGO_SIZE)}\n overlap={LOGO_OVERLAP}\n shadow=\"elevation\"\n size={LOGO_SIZE}\n status={statusPill}\n />\n </Stack>\n )\n }\n\n // ditto's slot names first.\n const merchantName = text(slot<unknown>(data, 'primary_text')) || text(field('merchant_name'))\n if (!merchantName) return null\n\n const amount = field('amount')\n const date = text(slot<unknown>(data, 'header_text')) || text(slot<unknown>(data, 'date'))\n const logo =\n asLogoRef(slot<unknown>(data, 'logo')) ??\n asLogoRef({\n alt: merchantName,\n fallback_guid: instance_slot.category_guid,\n guid: instance_slot.merchant_guid,\n })\n const logoSize = config.logo?.size ?? LOGO_SIZE\n\n return (\n <MerchantHighlightCard\n amount={\n typeof amount === 'number' && Number.isFinite(amount) && amount !== 0\n ? formatCurrency(amount, '0,0.00')\n : undefined\n }\n amountVariant={config.amountVariant}\n background={config.background}\n bgcolor={config.bgcolor}\n borderColor={config.borderColor}\n eyebrow={config.hideDate ? undefined : date}\n fullBleed={config.fullBleed}\n logo={logo ? <LogoFromGuid logo={logo} size={logoSize} /> : storefront}\n logoBorderColor={config.logo?.borderColor}\n logoRadius={config.logo?.radius}\n logoShadow={config.logo?.shadow}\n logoSize={logoSize}\n name={merchantName}\n trailing={statusPill}\n />\n )\n}\n\nexport default MerchantBlock\n"],"mappings":";;;;;;;;;;;;AAqBA,IAAM,IAAY,IACZ,IAAe,GACf,IAAmB,IACnB,IAAa,GACb,IAAiB;AAAA,EAAC;AAAA,EAAI;AAAA,EAAI;AAAE,GAC5B,IAAqB,IAErB,IAAA,CAAQ,MAAgB,OAAO,KAAM,WAAW,IAAI,QAGpD,IAAA,CAAa,MAAwC;AACzD,MAAI,CAAC,KAAS,OAAO,KAAU,YAAY,MAAM,QAAQ,CAAK,EAAG;AACjE,QAAM,EAAE,KAAA,GAAK,OAAA,GAAO,eAAA,GAAe,MAAA,EAAA,IAAS;AAC5C,MAAI,SAAO,KAAS,YAAY,CAAC,EAAW,CAAI;AAChD,WAAO;AAAA,MAAE,KAAK,EAAK,CAAG;AAAA,MAAG,OAAO,EAAK,CAAK;AAAA,MAAG,eAAe,EAAK,CAAa;AAAA,MAAG,MAAA;AAAA,IAAK;AACxF,GAEM,IAAA,CAAe,MAA6B;AAChD,MAAI,CAAC,MAAM,QAAQ,CAAI,EAAG,QAAO,CAAC;AAClC,QAAM,IAAS,oBAAI,IAAqB;AACxC,aAAW,KAAO,EAAK,IAAI,CAAS,EAClC,CAAI,GAAK,QAAQ,CAAC,EAAO,IAAI,EAAI,IAAI,KAAG,EAAO,IAAI,EAAI,MAAM,CAAG;AAElE,SAAO,CAAC,GAAG,EAAO,OAAO,CAAC;AAC5B,GAEM,IACJ,gBAAA,EAAC,GAAD;AAAA,EACE,eAAa;AAAA,EACb,aAAU;AAAA,EACV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AA,EACX,CAAA;AAEL"}
@@ -1,32 +1,32 @@
1
- /**
2
- * Design branches of the Merchant component block (architecture doc, Merchant row): one
3
- * highlighted merchant (`single_*`, `MerchantHighlightCard`) or a row of merchant tiles
4
- * (`multiple_*`, `LogoClusterCard`), each plain, celebrated (`success`) or flagged (`error`).
5
- */
1
+ /** ditto declares only `highlight` today. */
6
2
  export declare const merchantBlockVariant: {
3
+ readonly Highlight: "highlight";
7
4
  readonly SingleStandard: "single_standard";
8
- readonly SingleLarge: "single_large";
9
5
  readonly SingleSuccess: "single_success";
10
- readonly SingleError: "single_error";
6
+ readonly SingleSubscription: "single_subscription";
11
7
  readonly MultipleStandard: "multiple_standard";
12
8
  readonly MultipleSuccess: "multiple_success";
13
- readonly MultipleError: "multiple_error";
9
+ readonly MultipleSubscription: "multiple_subscription";
10
+ readonly MultipleBadged: "multiple_badged";
14
11
  };
15
12
  export type MerchantBlockVariant = (typeof merchantBlockVariant)[keyof typeof merchantBlockVariant];
16
- export type MerchantStatus = 'success' | 'error';
17
13
  export interface MerchantBlockLayoutConfig {
18
- kind: 'single' | 'multiple';
19
- /** Single: the amount as a dark pill or plain text. */
14
+ /** Merchant card, logo cascade, or ranked logos. */
15
+ kind: 'single' | 'cascade' | 'ranked';
20
16
  amountVariant?: 'pill' | 'text';
21
- /** A wash layered over the card. */
17
+ /** A wash; replaces `bgcolor`. */
22
18
  background?: string;
23
- /** Draws `status_text` in a pill of this tone: beside the single name, under the multiple row. */
24
- status?: MerchantStatus;
19
+ bgcolor?: string;
20
+ borderColor?: string;
21
+ fullBleed?: boolean;
22
+ hideDate?: boolean;
23
+ logo?: {
24
+ size?: number;
25
+ shadow?: 'offset' | 'elevation';
26
+ borderColor?: string;
27
+ radius?: number;
28
+ };
29
+ /** Draw `status_text` in a success pill. */
30
+ status?: boolean;
25
31
  }
26
- export declare const STATUS_PILL_TOKENS: Record<MerchantStatus, {
27
- bgcolor: string;
28
- borderColor: string;
29
- textColor: string;
30
- icon: string;
31
- }>;
32
32
  export declare const MERCHANT_LAYOUT: Record<MerchantBlockVariant, MerchantBlockLayoutConfig>;
@@ -1,57 +1,66 @@
1
- import { STATUS_ERROR_TOKENS as l, STATUS_SUCCESS_TOKENS as i } from "../../../components/statusTokens.es.js";
2
- import { ERROR_WASH_GRADIENT as e, WARM_LIME_ACCENT_GRADIENT as s } from "../../../components/celebrationGradients.es.js";
3
- var a = {
1
+ import { WARM_LIME_ACCENT_GRADIENT as r, celebrateGradient as i } from "../../../components/celebrationGradients.es.js";
2
+ var n = {
3
+ Highlight: "highlight",
4
4
  SingleStandard: "single_standard",
5
- SingleLarge: "single_large",
6
5
  SingleSuccess: "single_success",
7
- SingleError: "single_error",
6
+ SingleSubscription: "single_subscription",
8
7
  MultipleStandard: "multiple_standard",
9
8
  MultipleSuccess: "multiple_success",
10
- MultipleError: "multiple_error"
11
- }, u = {
12
- success: {
13
- ...i,
14
- icon: "check_circle"
15
- },
16
- error: {
17
- ...l,
18
- icon: "error"
19
- }
20
- }, r = {
9
+ MultipleSubscription: "multiple_subscription",
10
+ MultipleBadged: "multiple_badged"
11
+ }, l = { bgcolor: "secondary.lighter" }, a = {
12
+ background: r,
13
+ status: !0
14
+ }, e = {
21
15
  kind: "single",
22
- amountVariant: "pill"
23
- }, c = {
24
- single_standard: {
16
+ amountVariant: "pill",
17
+ fullBleed: !0,
18
+ hideDate: !0,
19
+ logo: {
20
+ size: 72,
21
+ shadow: "elevation",
22
+ borderColor: "divider",
23
+ radius: 8
24
+ }
25
+ }, s = {
26
+ highlight: {
25
27
  kind: "single",
26
- amountVariant: "text"
28
+ amountVariant: "text",
29
+ bgcolor: "warning.lighter",
30
+ borderColor: "warning.light"
31
+ },
32
+ single_standard: {
33
+ ...e,
34
+ ...l
27
35
  },
28
- single_large: r,
29
36
  single_success: {
30
- ...r,
31
- background: s,
32
- status: "success"
37
+ ...e,
38
+ ...a
33
39
  },
34
- single_error: {
35
- ...r,
36
- background: e,
37
- status: "error"
40
+ single_subscription: {
41
+ ...e,
42
+ background: i(232.03)
43
+ },
44
+ multiple_standard: {
45
+ kind: "cascade",
46
+ ...l
38
47
  },
39
- multiple_standard: { kind: "multiple" },
40
48
  multiple_success: {
41
- kind: "multiple",
42
- background: s,
43
- status: "success"
49
+ kind: "cascade",
50
+ ...a
51
+ },
52
+ multiple_subscription: {
53
+ kind: "cascade",
54
+ background: i(200.73)
44
55
  },
45
- multiple_error: {
46
- kind: "multiple",
47
- background: e,
48
- status: "error"
56
+ multiple_badged: {
57
+ kind: "ranked",
58
+ background: i(242.46)
49
59
  }
50
60
  };
51
61
  export {
52
- c as MERCHANT_LAYOUT,
53
- u as STATUS_PILL_TOKENS,
54
- a as merchantBlockVariant
62
+ s as MERCHANT_LAYOUT,
63
+ n as merchantBlockVariant
55
64
  };
56
65
 
57
66
  //# sourceMappingURL=layout.es.js.map