@mx-cartographer/experiences 9.4.56 → 9.4.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.
@@ -1,22 +1,20 @@
1
- import { CategoryGuidToName as y, CategoryGuids as h } from "../constants/Category.es.js";
1
+ import { CategoryGuidToName as y, CategoryGuids as T } from "../constants/Category.es.js";
2
2
  import { DATE_FORMATS_INTL as m, formatDate as f } from "../constants/DateFormats.es.js";
3
3
  import { TransactionStatus as C, TransactionType as v } from "../types/Transaction.es.js";
4
4
  import { getLocalizedCategoryName as A } from "./CategoryUtil.es.js";
5
- import { formatCurrency as E } from "./NumberFormatting.es.js";
6
- import { fromUnixUTC as S } from "./DateUtil.es.js";
7
- import { TABLE_CONST as b } from "../constants/Table.es.js";
5
+ import { formatCurrency as O } from "./NumberFormatting.es.js";
6
+ import { endOfUtcDay as D, fromUnixUTC as h, startOfUtcDay as E } from "./DateUtil.es.js";
7
+ import { TABLE_CONST as S } from "../constants/Table.es.js";
8
8
  import { COLUMN_NAMES as _ } from "../constants/Transaction.es.js";
9
- import { format as O } from "date-fns/format";
10
- import { startOfMonth as D } from "date-fns/startOfMonth";
11
- import { startOfToday as N } from "date-fns/startOfToday";
12
- import { endOfToday as M } from "date-fns/endOfToday";
13
- import { fromUnixTime as U } from "date-fns/fromUnixTime";
14
- import { getUnixTime as T } from "date-fns/getUnixTime";
15
- var te = (t) => t.top_level_category_guid === h.TRANSFER, re = (t, r, o, d = [], i) => {
9
+ import { format as b } from "date-fns/format";
10
+ import { startOfMonth as N } from "date-fns/startOfMonth";
11
+ import { startOfToday as M } from "date-fns/startOfToday";
12
+ import { endOfToday as U } from "date-fns/endOfToday";
13
+ var X = (t) => t.top_level_category_guid === T.TRANSFER, ee = (t, r, n, d = [], i) => {
16
14
  const c = r.reduce((e, s) => ({
17
15
  ...e,
18
16
  [s.guid]: s
19
- }), {}), n = o.reduce((e, s) => ({
17
+ }), {}), o = n.reduce((e, s) => ({
20
18
  ...e,
21
19
  [s.guid]: s
22
20
  }), {}), a = d.reduce((e, s) => {
@@ -32,7 +30,7 @@ var te = (t) => t.top_level_category_guid === h.TRANSFER, re = (t, r, o, d = [],
32
30
  };
33
31
  }, {});
34
32
  return t.map((e) => {
35
- const s = c[e.account_guid], u = e.category_guid ? n[e.category_guid] : null, g = a[e.guid] ?? [];
33
+ const s = c[e.account_guid], u = e.category_guid ? o[e.category_guid] : null, g = a[e.guid] ?? [];
36
34
  return {
37
35
  ...e,
38
36
  account: s?.user_name || "Unknown",
@@ -40,78 +38,78 @@ var te = (t) => t.top_level_category_guid === h.TRANSFER, re = (t, r, o, d = [],
40
38
  accountIsHidden: s?.is_hidden,
41
39
  category: u ? A(u, i) : "Uncategorized",
42
40
  institutionName: s?.institution?.name || s?.institutionName || void 0,
43
- isIncome: e.top_level_category_guid === h.INCOME,
41
+ isIncome: e.top_level_category_guid === T.INCOME,
44
42
  isPending: e.feed_status === C.PENDING,
45
43
  number: s?.account_number || "",
46
44
  payee: e.description,
47
45
  tags: g
48
46
  };
49
47
  });
50
- }, L = "uncategorized", oe = (t, r, o, d, i, c) => {
51
- const n = R(t, i, c), a = I(n, o, d);
48
+ }, L = "uncategorized", te = (t, r, n, d, i, c) => {
49
+ const o = R(t, i, c), a = I(o, n, d);
52
50
  return r.forEach((e) => {
53
51
  const s = a.findIndex((g) => g.guid === e), u = c.filter((g) => g.parent_guid === e);
54
52
  a.splice(s + 1, 0, ...u);
55
53
  }), a;
56
- }, R = (t, r, o) => {
54
+ }, R = (t, r, n) => {
57
55
  const { accounts: d = [], dateRange: i = {
58
- start: D(N()),
59
- end: M()
60
- }, custom: c = () => !0, searchTerm: n = "", showSplits: a = !1 } = t;
61
- return o.filter((e) => a ? !e.has_been_split : !e.parent_guid).filter((e) => !!d.find((s) => s === e.account_guid)).filter((e) => e.date >= T(i.start) && e.date <= T(i.end)).filter(c).filter((e) => {
62
- if (n === L && e.has_been_split) return !1;
63
- if (/^spl/i.test(n) && (e.has_been_split || e.parent_guid)) return !0;
64
- const s = e.tags.some((g) => p(n, r.find((l) => l.guid === g)?.name)), u = U(e.date);
65
- return p(n, e.payee) || p(n, e.feed_description) || p(n, e.category) || p(n, f(u, m.MONTH)) || p(n, f(u, m.DAY)) || p(n, f(u, m.FULL_MONTH_DAY)) || p(n, f(u, m.MONTH_DAY_YEAR)) || p(n, O(u, "do")) || p(n, e.account) || p(n, E(e.amount, "0,0.00")) || p(n, e.memo) || s;
56
+ start: N(M()),
57
+ end: U()
58
+ }, custom: c = () => !0, searchTerm: o = "", showSplits: a = !1 } = t;
59
+ return n.filter((e) => a ? !e.has_been_split : !e.parent_guid).filter((e) => !!d.find((s) => s === e.account_guid)).filter((e) => e.date >= E(i.start) && e.date <= D(i.end)).filter(c).filter((e) => {
60
+ if (o === L && e.has_been_split) return !1;
61
+ if (/^spl/i.test(o) && (e.has_been_split || e.parent_guid)) return !0;
62
+ const s = e.tags.some((g) => p(o, r.find((l) => l.guid === g)?.name)), u = h(e.date);
63
+ return p(o, e.payee) || p(o, e.feed_description) || p(o, e.category) || p(o, f(u, m.MONTH)) || p(o, f(u, m.DAY)) || p(o, f(u, m.FULL_MONTH_DAY)) || p(o, f(u, m.MONTH_DAY_YEAR)) || p(o, b(u, "do")) || p(o, e.account) || p(o, O(e.amount, "0,0.00")) || p(o, e.memo) || s;
66
64
  });
67
- }, I = (t, r, o) => [...t].sort((d, i) => {
68
- const c = r, n = (d[c] || "") > (i[c] || "");
69
- let a = n ? -1 : 1, e = n ? 1 : -1;
70
- return (r === _.DATE || r === _.AMOUNT) && (a = n ? 1 : -1, e = n ? -1 : 1), o === b.ASC ? a : e;
65
+ }, I = (t, r, n) => [...t].sort((d, i) => {
66
+ const c = r, o = (d[c] || "") > (i[c] || "");
67
+ let a = o ? -1 : 1, e = o ? 1 : -1;
68
+ return (r === _.DATE || r === _.AMOUNT) && (a = o ? 1 : -1, e = o ? -1 : 1), n === S.ASC ? a : e;
71
69
  }), p = (t, r) => {
72
- const o = t.toLowerCase().split(" "), d = r?.toString().toLowerCase() ?? "";
73
- return o.every((i) => d.indexOf(i) > -1);
70
+ const n = t.toLowerCase().split(" "), d = r?.toString().toLowerCase() ?? "";
71
+ return n.every((i) => d.indexOf(i) > -1);
74
72
  };
75
73
  function w(t) {
76
74
  return new Set(t.filter((r) => r.parent_guid !== void 0).map((r) => r.parent_guid));
77
75
  }
78
76
  function j(t) {
79
- return t.reduce((r, o) => (o.parent_guid && (r[o.parent_guid] || (r[o.parent_guid] = []), r[o.parent_guid].push(o)), r), {});
77
+ return t.reduce((r, n) => (n.parent_guid && (r[n.parent_guid] || (r[n.parent_guid] = []), r[n.parent_guid].push(n)), r), {});
80
78
  }
81
- function ne(t, r) {
82
- const o = w(r), d = j(r), i = /* @__PURE__ */ new Set(), c = [];
83
- for (const n of t) o.has(n.guid) ? (d[n.guid] ?? []).slice().sort((a, e) => Math.abs(e.amount) - Math.abs(a.amount)).forEach((a) => {
79
+ function re(t, r) {
80
+ const n = w(r), d = j(r), i = /* @__PURE__ */ new Set(), c = [];
81
+ for (const o of t) n.has(o.guid) ? (d[o.guid] ?? []).slice().sort((a, e) => Math.abs(e.amount) - Math.abs(a.amount)).forEach((a) => {
84
82
  i.has(a.guid) || (c.push(a), i.add(a.guid));
85
- }) : i.has(n.guid) || (c.push(n), i.add(n.guid));
83
+ }) : i.has(o.guid) || (c.push(o), i.add(o.guid));
86
84
  return c;
87
85
  }
88
- var ie = (t, r) => {
89
- const o = x(G(t, r)), d = new Blob([o], { type: "text/csv;charset=utf-8;" }), i = document.createElement("a");
86
+ var ne = (t, r) => {
87
+ const n = F(G(t, r)), d = new Blob([n], { type: "text/csv;charset=utf-8;" }), i = document.createElement("a");
90
88
  i.href = URL.createObjectURL(d), i.setAttribute("download", "transactions.csv"), document.body.appendChild(i), i.click(), document.body.removeChild(i), URL.revokeObjectURL(i.href);
91
- }, G = (t, r) => t.map((o) => ({
92
- Date: f(S(o.date), m.YEAR_MONTH_DAY),
93
- Description: F(o),
94
- "Original Description": o.feed_description,
95
- Amount: `${o.amount}`,
96
- Type: o.transaction_type === v.CREDIT ? "Credit" : "Debit",
97
- "Parent Category": y[o.top_level_category_guid || ""],
98
- Category: o.category,
99
- Account: o.account,
100
- Tags: B(o, r),
101
- Memo: o.memo,
102
- Pending: o.isPending ? "TRUE" : "FALSE"
103
- })), P = (t) => t ? /[,"\n\r]/.test(t) ? `"${t.replace(/"/g, '""')}"` : t : "", x = (t) => t.length === 0 ? "" : Object.keys(t[0]).join(",").concat(`\r
89
+ }, G = (t, r) => t.map((n) => ({
90
+ Date: f(h(n.date), m.YEAR_MONTH_DAY),
91
+ Description: B(n),
92
+ "Original Description": n.feed_description,
93
+ Amount: `${n.amount}`,
94
+ Type: n.transaction_type === v.CREDIT ? "Credit" : "Debit",
95
+ "Parent Category": y[n.top_level_category_guid || ""],
96
+ Category: n.category,
97
+ Account: n.account,
98
+ Tags: Y(n, r),
99
+ Memo: n.memo,
100
+ Pending: n.isPending ? "TRUE" : "FALSE"
101
+ })), P = (t) => t ? /[,"\n\r]/.test(t) ? `"${t.replace(/"/g, '""')}"` : t : "", F = (t) => t.length === 0 ? "" : Object.keys(t[0]).join(",").concat(`\r
104
102
  `) + t.map((r) => Object.values(r).map(P).join(",")).join(`\r
105
- `), F = (t) => {
103
+ `), B = (t) => {
106
104
  let r = t.parent_guid ? "Split: " : "";
107
105
  return r += t.is_hidden ? "(Excluded) " : "", r += t.description, r;
108
- }, B = (t, r) => t.tags.map((o) => r.filter((d) => d.guid === o)[0]?.name ?? "").join(" ");
106
+ }, Y = (t, r) => t.tags.map((n) => r.filter((d) => d.guid === n)[0]?.name ?? "").join(" ");
109
107
  export {
110
- re as buildDetailedTransactions,
111
- ie as exportTransactionsToCSV,
112
- ne as flattenTransactionsWithSplits,
113
- te as isTransferTransaction,
114
- oe as sortAndFilterTransactions
108
+ ee as buildDetailedTransactions,
109
+ ne as exportTransactionsToCSV,
110
+ re as flattenTransactionsWithSplits,
111
+ X as isTransferTransaction,
112
+ te as sortAndFilterTransactions
115
113
  };
116
114
 
117
115
  //# sourceMappingURL=TransactionUtils.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TransactionUtils.es.js","names":[],"sources":["../../../src/core/utils/TransactionUtils.ts"],"sourcesContent":["import { endOfToday } from 'date-fns/endOfToday'\nimport { format } from 'date-fns/format'\nimport { fromUnixTime } from 'date-fns/fromUnixTime'\nimport { getUnixTime } from 'date-fns/getUnixTime'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { startOfToday } from 'date-fns/startOfToday'\n\nimport { TABLE_CONST } from '../constants/Table'\nimport {\n CategoryGuids,\n CategoryGuidToName,\n DATE_FORMATS_INTL,\n formatDate,\n ORDINAL_DATE_FORMAT,\n} from '../constants'\nimport { COLUMN_NAMES } from '../constants/Transaction'\nimport { TransactionStatus, TransactionType } from '../types'\nimport type { Category, CategoryCopy, DetailedAccount, Tag, Tagging, Transaction } from '../types'\n\nimport { type TransactionFilter } from '../stores/TransactionStore'\n\nimport { getLocalizedCategoryName } from './CategoryUtil'\nimport { fromUnixUTC } from './DateUtil'\nimport { formatCurrency } from './NumberFormatting'\n\ninterface AccountsMap {\n [key: string]: DetailedAccount\n}\n\n// True for account-to-account transfers (top-level Transfer category). Used to\n// swap the payee/description for the institution name in the transaction detail\n// header, the table Payee column, and the mobile list.\nexport const isTransferTransaction = (\n transaction: Pick<Transaction, 'top_level_category_guid'>,\n): boolean => transaction.top_level_category_guid === CategoryGuids.TRANSFER\n\ninterface CategoriesMap {\n [key: string]: Category\n}\n\ninterface TaggingsMap {\n [key: string]: string[]\n}\n\nexport const buildDetailedTransactions = (\n transactions: Transaction[],\n accounts: DetailedAccount[],\n categories: Category[],\n taggings: Tagging[] = [],\n categoryCopy: CategoryCopy,\n) => {\n const accountsMap = accounts.reduce((acc: AccountsMap, account: DetailedAccount) => {\n return { ...acc, [account.guid]: account }\n }, {})\n\n const categoriesMap = categories.reduce((acc: CategoriesMap, category: Category) => {\n return { ...acc, [category.guid]: category }\n }, {})\n\n const taggingsMap = taggings.reduce((acc: TaggingsMap, tagging: Tagging) => {\n const { transaction_guid, tag_guid } = tagging\n\n if (!acc[transaction_guid]) {\n return {\n ...acc,\n [transaction_guid]: [tag_guid],\n }\n }\n const tags = [...acc[transaction_guid], tag_guid] as string[]\n\n return {\n ...acc,\n [transaction_guid]: tags,\n }\n }, {})\n\n return transactions.map((transaction: Transaction) => {\n const account = accountsMap[transaction.account_guid]\n const category = transaction.category_guid ? categoriesMap[transaction.category_guid] : null\n const tags = taggingsMap[transaction.guid] ?? []\n\n return {\n ...transaction,\n account: account?.user_name || 'Unknown',\n accountIsClosed: account?.is_closed,\n accountIsHidden: account?.is_hidden,\n category: category ? getLocalizedCategoryName(category, categoryCopy) : 'Uncategorized',\n institutionName: account?.institution?.name || account?.institutionName || undefined,\n isIncome: transaction.top_level_category_guid === CategoryGuids.INCOME,\n isPending: transaction.feed_status === TransactionStatus.PENDING,\n number: account?.account_number || '',\n payee: transaction.description,\n tags,\n }\n })\n}\n\nconst UNCATEGORIZED_TERM = 'uncategorized'\n\nexport const sortAndFilterTransactions = (\n filter: TransactionFilter,\n expandedSplits: string[],\n sortColumn: string,\n sortDirection: string,\n tags: Tag[],\n transactions: Transaction[],\n) => {\n const filteredTransactions = filterTransactions(filter, tags, transactions)\n\n const sortedTransactions = sortTransactions(filteredTransactions, sortColumn, sortDirection)\n\n expandedSplits.forEach((guid) => {\n const index = sortedTransactions.findIndex((t) => t.guid === guid)\n const children = transactions.filter((t) => t.parent_guid === guid)\n sortedTransactions.splice(index + 1, 0, ...children)\n })\n return sortedTransactions\n}\n\nconst filterTransactions = (\n filter: TransactionFilter,\n tags: Tag[],\n transactions: Transaction[],\n) => {\n const {\n accounts = [],\n dateRange = { start: startOfMonth(startOfToday()), end: endOfToday() },\n custom = () => true,\n searchTerm: searchFilter = '',\n showSplits = false,\n } = filter\n\n return (\n transactions\n // Filters out parent of split transactions when showSplits is true and filters out split\n // transaction children when showSplits is false\n .filter((t) => (showSplits ? !t.has_been_split : !t.parent_guid))\n // Filter for selected accounts\n .filter((t) => Boolean(accounts.find((guid) => guid === t.account_guid)))\n // Filter for Date Range.\n // NOTE: bounds are local-midnight (getUnixTime of a local Date) while dates\n // are rendered/exported on the UTC calendar day (fromUnixUTC). For a\n // midnight-UTC row near a month boundary in a negative-offset browser the\n // two can disagree by a day. Left as-is here to keep this fix low-risk;\n // unifying range + search on UTC is tracked with the core-data ISO\n // migration (MEW-3961 follow-up).\n .filter((t) => t.date >= getUnixTime(dateRange.start) && t.date <= getUnixTime(dateRange.end))\n // Custom filter\n .filter(custom)\n // Search filter\n .filter((transaction) => {\n // Don't return uncategorized split transactions\n if (searchFilter === UNCATEGORIZED_TERM && transaction.has_been_split) {\n return false\n }\n\n // Split check - When searching for \"Splits\" and transaction is a split or is a parent of a split(s)\n const splitPattern = /^spl/i\n if (\n splitPattern.test(searchFilter) &&\n (transaction.has_been_split || Boolean(transaction.parent_guid))\n ) {\n return true\n }\n\n // Check transactions tags\n const isTagIncludedInSearch = transaction.tags.some((guid) =>\n isIncludedInSearch(searchFilter, tags.find((tag) => tag.guid === guid)?.name),\n )\n const date = fromUnixTime(transaction.date)\n return (\n isIncludedInSearch(searchFilter, transaction.payee) ||\n isIncludedInSearch(searchFilter, transaction.feed_description) ||\n isIncludedInSearch(searchFilter, transaction.category) ||\n isIncludedInSearch(searchFilter, formatDate(date, DATE_FORMATS_INTL.MONTH)) ||\n isIncludedInSearch(searchFilter, formatDate(date, DATE_FORMATS_INTL.DAY)) ||\n isIncludedInSearch(searchFilter, formatDate(date, DATE_FORMATS_INTL.FULL_MONTH_DAY)) ||\n isIncludedInSearch(searchFilter, formatDate(date, DATE_FORMATS_INTL.MONTH_DAY_YEAR)) ||\n isIncludedInSearch(searchFilter, format(date, ORDINAL_DATE_FORMAT)) ||\n isIncludedInSearch(searchFilter, transaction.account) ||\n isIncludedInSearch(searchFilter, formatCurrency(transaction.amount, '0,0.00')) ||\n isIncludedInSearch(searchFilter, transaction.memo) ||\n isTagIncludedInSearch\n )\n })\n )\n}\n\nconst sortTransactions = (\n transactions: Transaction[],\n sortColumn: string,\n sortDirection: string,\n) => {\n return [...transactions].sort((a: Transaction, b: Transaction) => {\n const column = sortColumn as keyof Transaction\n const sortCompare = (a[column] || '') > (b[column] || '')\n\n let sortASC = sortCompare ? -1 : 1\n let sortDESC = sortCompare ? 1 : -1\n\n if (sortColumn === COLUMN_NAMES.DATE || sortColumn === COLUMN_NAMES.AMOUNT) {\n sortASC = sortCompare ? 1 : -1\n sortDESC = sortCompare ? -1 : 1\n }\n\n return sortDirection === TABLE_CONST.ASC ? sortASC : sortDESC\n })\n}\n\n/**\n * Determines if a value is included within the terms set in the search bar\n */\nconst isIncludedInSearch = (searchFilter: string, value: string | null | undefined) => {\n const lowerCasedTerms = searchFilter.toLowerCase().split(' ')\n const lowerCasedValue = value?.toString().toLowerCase() ?? ''\n\n return lowerCasedTerms.every((filter) => lowerCasedValue.indexOf(filter) > -1)\n}\n\n// TODO: Change the way formatting data is exported in order to handle localization\ntype FormattedTransaction = {\n Date: string\n Description: string\n 'Original Description': string\n Amount: string\n Type: string\n 'Parent Category': string\n Category: string\n Account: string\n Tags: string\n Memo: string\n Pending: string\n}\n\n/**\n * Collects the GUIDs of all transactions that act as parents\n * to one or more split (child) transactions.\n */\nfunction extractParentTransactionGuids(transactions: Transaction[]): Set<string> {\n return new Set(\n transactions.filter((tx) => tx.parent_guid !== undefined).map((tx) => tx.parent_guid!),\n )\n}\n\n/**\n * Organizes child transactions by their parent transaction GUID.\n * Returns a map from parent GUID to an array of its child transactions.\n */\nfunction mapChildTransactionsByParent(transactions: Transaction[]): Record<string, Transaction[]> {\n return transactions.reduce<Record<string, Transaction[]>>((accumulator, tx) => {\n if (tx.parent_guid) {\n if (!accumulator[tx.parent_guid]) accumulator[tx.parent_guid] = []\n accumulator[tx.parent_guid].push(tx)\n }\n return accumulator\n }, {})\n}\n\n/**\n * Produces a list of transactions based on the given sorted transactions,\n * where parent transactions that have split children are replaced by those\n * children sorted by descending absolute amount. All other transactions\n * are included as-is, with duplicates removed.\n */\nexport function flattenTransactionsWithSplits(\n sortedTransactions: Transaction[],\n allTransactions: Transaction[],\n): Transaction[] {\n // Set of parent transaction GUIDs that have split child transactions\n const parentTransactionGuidsWithSplits = extractParentTransactionGuids(allTransactions)\n\n // Map from parent GUID to array of its child split transactions\n const childTransactionsGroupedByParent = mapChildTransactionsByParent(allTransactions)\n\n // Track GUIDs of transactions already included in the result to avoid duplicates\n const processedTransactionGuids = new Set<string>()\n\n // Resulting list of transactions with parents replaced by their split children\n const flattenedTransactionList: Transaction[] = []\n\n for (const transaction of sortedTransactions) {\n if (parentTransactionGuidsWithSplits.has(transaction.guid)) {\n // This transaction is a parent with splits, so replace it with its children\n const splitChildTransactions = childTransactionsGroupedByParent[transaction.guid] ?? []\n\n splitChildTransactions\n .slice()\n .sort((a, b) => Math.abs(b.amount) - Math.abs(a.amount))\n .forEach((childTransaction) => {\n if (!processedTransactionGuids.has(childTransaction.guid)) {\n flattenedTransactionList.push(childTransaction)\n processedTransactionGuids.add(childTransaction.guid)\n }\n })\n } else if (!processedTransactionGuids.has(transaction.guid)) {\n // Normal transaction (no splits), add as-is if not already added\n flattenedTransactionList.push(transaction)\n processedTransactionGuids.add(transaction.guid)\n }\n }\n\n return flattenedTransactionList\n}\n\nexport const exportTransactionsToCSV = (transactions: Transaction[], tags: Tag[]) => {\n const csvContent = structureCSVData(formatTransactions(transactions, tags))\n\n const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' })\n const link = document.createElement('a')\n link.href = URL.createObjectURL(blob)\n link.setAttribute('download', 'transactions.csv')\n\n document.body.appendChild(link)\n link.click()\n document.body.removeChild(link)\n\n URL.revokeObjectURL(link.href)\n}\n\n/**\n * Formats a list of transactions into a list that will be used when\n * downloaded to a CSV file.\n */\nconst formatTransactions = (transactions: Transaction[], tags: Tag[]) => {\n return transactions.map((transaction) => ({\n // Post dates are calendar days; format on the UTC day so the export can't\n // shift to the prior day in a Western-offset browser.\n Date: formatDate(fromUnixUTC(transaction.date), DATE_FORMATS_INTL.YEAR_MONTH_DAY),\n Description: getDescription(transaction),\n 'Original Description': transaction.feed_description,\n Amount: `${transaction.amount}`,\n Type: transaction.transaction_type === TransactionType.CREDIT ? 'Credit' : 'Debit',\n 'Parent Category': CategoryGuidToName[transaction.top_level_category_guid || ''],\n Category: transaction.category,\n Account: transaction.account,\n Tags: getTags(transaction, tags),\n Memo: transaction.memo,\n Pending: transaction.isPending ? 'TRUE' : 'FALSE',\n })) as FormattedTransaction[]\n}\n\n/**\n * Escapes a value for safe CSV output\n */\nconst escapeCsvField = (field?: string | null): string => {\n if (!field) return ''\n return /[,\"\\n\\r]/.test(field) ? `\"${field.replace(/\"/g, '\"\"')}\"` : field\n}\n\n/**\n * Structures the CSV file data using the formatted transactions\n */\nconst structureCSVData = (formattedTransactions: FormattedTransaction[]) => {\n // Guard the empty export: Object.keys(undefined) would throw for a zero-row\n // list (e.g. an over-filtered range), so emit an empty file instead.\n if (formattedTransactions.length === 0) return ''\n\n const csvHeader = Object.keys(formattedTransactions[0]).join(',').concat('\\r\\n')\n const csvRows = formattedTransactions\n .map((transaction) => Object.values(transaction).map(escapeCsvField).join(','))\n .join('\\r\\n')\n\n return csvHeader + csvRows\n}\n\n/**\n * Get the description for a transaction that will be used within the CSV copy.\n * We want to highlight that split transactions are a split as well as\n * hidden transactions are hidden.\n */\nconst getDescription = (transaction: Transaction) => {\n let description = transaction.parent_guid ? 'Split: ' : ''\n description += transaction.is_hidden ? '(Excluded) ' : ''\n description += transaction.description\n\n return description\n}\n\nconst getTags = (transaction: Transaction, tags: Tag[]) => {\n return transaction.tags\n .map((tagGuid) => {\n const tag = tags.filter((t) => t.guid === tagGuid)[0]\n\n return tag?.name ?? ''\n })\n .join(' ')\n}\n"],"mappings":";;;;;;;;;;;;;;AAgCA,IAAa,KAAA,CACX,MACY,EAAY,4BAA4B,EA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,EAAY,EAAY,IAAI,GAAG,EAAkB,cAAc;AAAA,EAChF,aAAa,EAAe,CAAW;AAAA,EACvC,wBAAwB,EAAY;AAAA,EACpC,QAAQ,GAAG,EAAY,MAAA;AAAA,EACvB,MAAM,EAAY,qBAAqB,EAAgB,SAAS,WAAW;AAAA,EAC3E,mBAAmB,EAAmB,EAAY,2BAA2B,EAAA;AAAA,EAC7E,UAAU,EAAY;AAAA,EACtB,SAAS,EAAY;AAAA,EACrB,MAAM,EAAQ,GAAa,CAAI;AAAA,EAC/B,MAAM,EAAY;AAAA,EAClB,SAAS,EAAY,YAAY,SAAS;AAC5C,EAAE,GAME,IAAA,CAAkB,MACjB,IACE,WAAW,KAAK,CAAK,IAAI,IAAI,EAAM,QAAQ,MAAM,IAAI,CAAA,MAAO,IADhD,IAOf,IAAA,CAAoB,MAGpB,EAAsB,WAAW,IAAU,KAE7B,OAAO,KAAK,EAAsB,CAAA,CAAE,EAAE,KAAK,GAAG,EAAE,OAAO;AAAA,CAKlE,IAJS,EACb,IAAA,CAAK,MAAgB,OAAO,OAAO,CAAW,EAAE,IAAI,CAAc,EAAE,KAAK,GAAG,CAAC,EAC7E,KAAK;AAAA,CAEW,GAQf,IAAA,CAAkB,MAA6B;AACnD,MAAI,IAAc,EAAY,cAAc,YAAY;AACxD,SAAA,KAAe,EAAY,YAAY,gBAAgB,IACvD,KAAe,EAAY,aAEpB;AACT,GAEM,IAAA,CAAW,GAA0B,MAClC,EAAY,KAChB,IAAA,CAAK,MACQ,EAAK,OAAA,CAAQ,MAAM,EAAE,SAAS,CAAO,EAAE,CAAA,GAEvC,QAAQ,EACrB,EACA,KAAK,GAAG"}
1
+ {"version":3,"file":"TransactionUtils.es.js","names":[],"sources":["../../../src/core/utils/TransactionUtils.ts"],"sourcesContent":["import { endOfToday } from 'date-fns/endOfToday'\nimport { format } from 'date-fns/format'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { startOfToday } from 'date-fns/startOfToday'\n\nimport { TABLE_CONST } from '../constants/Table'\nimport {\n CategoryGuids,\n CategoryGuidToName,\n DATE_FORMATS_INTL,\n formatDate,\n ORDINAL_DATE_FORMAT,\n} from '../constants'\nimport { COLUMN_NAMES } from '../constants/Transaction'\nimport { TransactionStatus, TransactionType } from '../types'\nimport type { Category, CategoryCopy, DetailedAccount, Tag, Tagging, Transaction } from '../types'\n\nimport { type TransactionFilter } from '../stores/TransactionStore'\n\nimport { getLocalizedCategoryName } from './CategoryUtil'\nimport { endOfUtcDay, fromUnixUTC, startOfUtcDay } from './DateUtil'\nimport { formatCurrency } from './NumberFormatting'\n\ninterface AccountsMap {\n [key: string]: DetailedAccount\n}\n\n// True for account-to-account transfers (top-level Transfer category). Used to\n// swap the payee/description for the institution name in the transaction detail\n// header, the table Payee column, and the mobile list.\nexport const isTransferTransaction = (\n transaction: Pick<Transaction, 'top_level_category_guid'>,\n): boolean => transaction.top_level_category_guid === CategoryGuids.TRANSFER\n\ninterface CategoriesMap {\n [key: string]: Category\n}\n\ninterface TaggingsMap {\n [key: string]: string[]\n}\n\nexport const buildDetailedTransactions = (\n transactions: Transaction[],\n accounts: DetailedAccount[],\n categories: Category[],\n taggings: Tagging[] = [],\n categoryCopy: CategoryCopy,\n) => {\n const accountsMap = accounts.reduce((acc: AccountsMap, account: DetailedAccount) => {\n return { ...acc, [account.guid]: account }\n }, {})\n\n const categoriesMap = categories.reduce((acc: CategoriesMap, category: Category) => {\n return { ...acc, [category.guid]: category }\n }, {})\n\n const taggingsMap = taggings.reduce((acc: TaggingsMap, tagging: Tagging) => {\n const { transaction_guid, tag_guid } = tagging\n\n if (!acc[transaction_guid]) {\n return {\n ...acc,\n [transaction_guid]: [tag_guid],\n }\n }\n const tags = [...acc[transaction_guid], tag_guid] as string[]\n\n return {\n ...acc,\n [transaction_guid]: tags,\n }\n }, {})\n\n return transactions.map((transaction: Transaction) => {\n const account = accountsMap[transaction.account_guid]\n const category = transaction.category_guid ? categoriesMap[transaction.category_guid] : null\n const tags = taggingsMap[transaction.guid] ?? []\n\n return {\n ...transaction,\n account: account?.user_name || 'Unknown',\n accountIsClosed: account?.is_closed,\n accountIsHidden: account?.is_hidden,\n category: category ? getLocalizedCategoryName(category, categoryCopy) : 'Uncategorized',\n institutionName: account?.institution?.name || account?.institutionName || undefined,\n isIncome: transaction.top_level_category_guid === CategoryGuids.INCOME,\n isPending: transaction.feed_status === TransactionStatus.PENDING,\n number: account?.account_number || '',\n payee: transaction.description,\n tags,\n }\n })\n}\n\nconst UNCATEGORIZED_TERM = 'uncategorized'\n\nexport const sortAndFilterTransactions = (\n filter: TransactionFilter,\n expandedSplits: string[],\n sortColumn: string,\n sortDirection: string,\n tags: Tag[],\n transactions: Transaction[],\n) => {\n const filteredTransactions = filterTransactions(filter, tags, transactions)\n\n const sortedTransactions = sortTransactions(filteredTransactions, sortColumn, sortDirection)\n\n expandedSplits.forEach((guid) => {\n const index = sortedTransactions.findIndex((t) => t.guid === guid)\n const children = transactions.filter((t) => t.parent_guid === guid)\n sortedTransactions.splice(index + 1, 0, ...children)\n })\n return sortedTransactions\n}\n\nconst filterTransactions = (\n filter: TransactionFilter,\n tags: Tag[],\n transactions: Transaction[],\n) => {\n const {\n accounts = [],\n dateRange = { start: startOfMonth(startOfToday()), end: endOfToday() },\n custom = () => true,\n searchTerm: searchFilter = '',\n showSplits = false,\n } = filter\n\n return (\n transactions\n // Filters out parent of split transactions when showSplits is true and filters out split\n // transaction children when showSplits is false\n .filter((t) => (showSplits ? !t.has_been_split : !t.parent_guid))\n // Filter for selected accounts\n .filter((t) => Boolean(accounts.find((guid) => guid === t.account_guid)))\n // Date range on the UTC calendar day, the same day the Date cell, CSV export\n // and category totals use. Local-midnight bounds put a midnight-UTC row near\n // a month boundary in a different month than the chart. (MEW-4191)\n .filter(\n (t) => t.date >= startOfUtcDay(dateRange.start) && t.date <= endOfUtcDay(dateRange.end),\n )\n // Custom filter\n .filter(custom)\n // Search filter\n .filter((transaction) => {\n // Don't return uncategorized split transactions\n if (searchFilter === UNCATEGORIZED_TERM && transaction.has_been_split) {\n return false\n }\n\n // Split check - When searching for \"Splits\" and transaction is a split or is a parent of a split(s)\n const splitPattern = /^spl/i\n if (\n splitPattern.test(searchFilter) &&\n (transaction.has_been_split || Boolean(transaction.parent_guid))\n ) {\n return true\n }\n\n // Check transactions tags\n const isTagIncludedInSearch = transaction.tags.some((guid) =>\n isIncludedInSearch(searchFilter, tags.find((tag) => tag.guid === guid)?.name),\n )\n const date = fromUnixUTC(transaction.date)\n return (\n isIncludedInSearch(searchFilter, transaction.payee) ||\n isIncludedInSearch(searchFilter, transaction.feed_description) ||\n isIncludedInSearch(searchFilter, transaction.category) ||\n isIncludedInSearch(searchFilter, formatDate(date, DATE_FORMATS_INTL.MONTH)) ||\n isIncludedInSearch(searchFilter, formatDate(date, DATE_FORMATS_INTL.DAY)) ||\n isIncludedInSearch(searchFilter, formatDate(date, DATE_FORMATS_INTL.FULL_MONTH_DAY)) ||\n isIncludedInSearch(searchFilter, formatDate(date, DATE_FORMATS_INTL.MONTH_DAY_YEAR)) ||\n isIncludedInSearch(searchFilter, format(date, ORDINAL_DATE_FORMAT)) ||\n isIncludedInSearch(searchFilter, transaction.account) ||\n isIncludedInSearch(searchFilter, formatCurrency(transaction.amount, '0,0.00')) ||\n isIncludedInSearch(searchFilter, transaction.memo) ||\n isTagIncludedInSearch\n )\n })\n )\n}\n\nconst sortTransactions = (\n transactions: Transaction[],\n sortColumn: string,\n sortDirection: string,\n) => {\n return [...transactions].sort((a: Transaction, b: Transaction) => {\n const column = sortColumn as keyof Transaction\n const sortCompare = (a[column] || '') > (b[column] || '')\n\n let sortASC = sortCompare ? -1 : 1\n let sortDESC = sortCompare ? 1 : -1\n\n if (sortColumn === COLUMN_NAMES.DATE || sortColumn === COLUMN_NAMES.AMOUNT) {\n sortASC = sortCompare ? 1 : -1\n sortDESC = sortCompare ? -1 : 1\n }\n\n return sortDirection === TABLE_CONST.ASC ? sortASC : sortDESC\n })\n}\n\n/**\n * Determines if a value is included within the terms set in the search bar\n */\nconst isIncludedInSearch = (searchFilter: string, value: string | null | undefined) => {\n const lowerCasedTerms = searchFilter.toLowerCase().split(' ')\n const lowerCasedValue = value?.toString().toLowerCase() ?? ''\n\n return lowerCasedTerms.every((filter) => lowerCasedValue.indexOf(filter) > -1)\n}\n\n// TODO: Change the way formatting data is exported in order to handle localization\ntype FormattedTransaction = {\n Date: string\n Description: string\n 'Original Description': string\n Amount: string\n Type: string\n 'Parent Category': string\n Category: string\n Account: string\n Tags: string\n Memo: string\n Pending: string\n}\n\n/**\n * Collects the GUIDs of all transactions that act as parents\n * to one or more split (child) transactions.\n */\nfunction extractParentTransactionGuids(transactions: Transaction[]): Set<string> {\n return new Set(\n transactions.filter((tx) => tx.parent_guid !== undefined).map((tx) => tx.parent_guid!),\n )\n}\n\n/**\n * Organizes child transactions by their parent transaction GUID.\n * Returns a map from parent GUID to an array of its child transactions.\n */\nfunction mapChildTransactionsByParent(transactions: Transaction[]): Record<string, Transaction[]> {\n return transactions.reduce<Record<string, Transaction[]>>((accumulator, tx) => {\n if (tx.parent_guid) {\n if (!accumulator[tx.parent_guid]) accumulator[tx.parent_guid] = []\n accumulator[tx.parent_guid].push(tx)\n }\n return accumulator\n }, {})\n}\n\n/**\n * Produces a list of transactions based on the given sorted transactions,\n * where parent transactions that have split children are replaced by those\n * children sorted by descending absolute amount. All other transactions\n * are included as-is, with duplicates removed.\n */\nexport function flattenTransactionsWithSplits(\n sortedTransactions: Transaction[],\n allTransactions: Transaction[],\n): Transaction[] {\n // Set of parent transaction GUIDs that have split child transactions\n const parentTransactionGuidsWithSplits = extractParentTransactionGuids(allTransactions)\n\n // Map from parent GUID to array of its child split transactions\n const childTransactionsGroupedByParent = mapChildTransactionsByParent(allTransactions)\n\n // Track GUIDs of transactions already included in the result to avoid duplicates\n const processedTransactionGuids = new Set<string>()\n\n // Resulting list of transactions with parents replaced by their split children\n const flattenedTransactionList: Transaction[] = []\n\n for (const transaction of sortedTransactions) {\n if (parentTransactionGuidsWithSplits.has(transaction.guid)) {\n // This transaction is a parent with splits, so replace it with its children\n const splitChildTransactions = childTransactionsGroupedByParent[transaction.guid] ?? []\n\n splitChildTransactions\n .slice()\n .sort((a, b) => Math.abs(b.amount) - Math.abs(a.amount))\n .forEach((childTransaction) => {\n if (!processedTransactionGuids.has(childTransaction.guid)) {\n flattenedTransactionList.push(childTransaction)\n processedTransactionGuids.add(childTransaction.guid)\n }\n })\n } else if (!processedTransactionGuids.has(transaction.guid)) {\n // Normal transaction (no splits), add as-is if not already added\n flattenedTransactionList.push(transaction)\n processedTransactionGuids.add(transaction.guid)\n }\n }\n\n return flattenedTransactionList\n}\n\nexport const exportTransactionsToCSV = (transactions: Transaction[], tags: Tag[]) => {\n const csvContent = structureCSVData(formatTransactions(transactions, tags))\n\n const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' })\n const link = document.createElement('a')\n link.href = URL.createObjectURL(blob)\n link.setAttribute('download', 'transactions.csv')\n\n document.body.appendChild(link)\n link.click()\n document.body.removeChild(link)\n\n URL.revokeObjectURL(link.href)\n}\n\n/**\n * Formats a list of transactions into a list that will be used when\n * downloaded to a CSV file.\n */\nconst formatTransactions = (transactions: Transaction[], tags: Tag[]) => {\n return transactions.map((transaction) => ({\n // Post dates are calendar days; format on the UTC day so the export can't\n // shift to the prior day in a Western-offset browser.\n Date: formatDate(fromUnixUTC(transaction.date), DATE_FORMATS_INTL.YEAR_MONTH_DAY),\n Description: getDescription(transaction),\n 'Original Description': transaction.feed_description,\n Amount: `${transaction.amount}`,\n Type: transaction.transaction_type === TransactionType.CREDIT ? 'Credit' : 'Debit',\n 'Parent Category': CategoryGuidToName[transaction.top_level_category_guid || ''],\n Category: transaction.category,\n Account: transaction.account,\n Tags: getTags(transaction, tags),\n Memo: transaction.memo,\n Pending: transaction.isPending ? 'TRUE' : 'FALSE',\n })) as FormattedTransaction[]\n}\n\n/**\n * Escapes a value for safe CSV output\n */\nconst escapeCsvField = (field?: string | null): string => {\n if (!field) return ''\n return /[,\"\\n\\r]/.test(field) ? `\"${field.replace(/\"/g, '\"\"')}\"` : field\n}\n\n/**\n * Structures the CSV file data using the formatted transactions\n */\nconst structureCSVData = (formattedTransactions: FormattedTransaction[]) => {\n // Guard the empty export: Object.keys(undefined) would throw for a zero-row\n // list (e.g. an over-filtered range), so emit an empty file instead.\n if (formattedTransactions.length === 0) return ''\n\n const csvHeader = Object.keys(formattedTransactions[0]).join(',').concat('\\r\\n')\n const csvRows = formattedTransactions\n .map((transaction) => Object.values(transaction).map(escapeCsvField).join(','))\n .join('\\r\\n')\n\n return csvHeader + csvRows\n}\n\n/**\n * Get the description for a transaction that will be used within the CSV copy.\n * We want to highlight that split transactions are a split as well as\n * hidden transactions are hidden.\n */\nconst getDescription = (transaction: Transaction) => {\n let description = transaction.parent_guid ? 'Split: ' : ''\n description += transaction.is_hidden ? '(Excluded) ' : ''\n description += transaction.description\n\n return description\n}\n\nconst getTags = (transaction: Transaction, tags: Tag[]) => {\n return transaction.tags\n .map((tagGuid) => {\n const tag = tags.filter((t) => t.guid === tagGuid)[0]\n\n return tag?.name ?? ''\n })\n .join(' ')\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,IAAa,IAAA,CACX,MACY,EAAY,4BAA4B,EAAc,UAUvD,KAAA,CACX,GACA,GACA,GACA,IAAsB,CAAC,GACvB,MACG;AACH,QAAM,IAAc,EAAS,OAAA,CAAQ,GAAkB,OAC9C;AAAA,IAAE,GAAG;AAAA,IAAM,CAAA,EAAQ,IAAA,GAAO;AAAA,EAAQ,IACxC,CAAC,CAAC,GAEC,IAAgB,EAAW,OAAA,CAAQ,GAAoB,OACpD;AAAA,IAAE,GAAG;AAAA,IAAM,CAAA,EAAS,IAAA,GAAO;AAAA,EAAS,IAC1C,CAAC,CAAC,GAEC,IAAc,EAAS,OAAA,CAAQ,GAAkB,MAAqB;AAC1E,UAAM,EAAE,kBAAA,GAAkB,UAAA,EAAA,IAAa;AAEvC,QAAI,CAAC,EAAI,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AM,QAAQ,MAAM,IAAI,CAAA,MAAO,IADhD,IAOf,IAAA,CAAoB,MAGpB,EAAsB,WAAW,IAAU,KAE7B,OAAO,KAAK,EAAsB,CAAA,CAAE,EAAE,KAAK,GAAG,EAAE,OAAO;AAAA,CAKlE,IAJS,EACb,IAAA,CAAK,MAAgB,OAAO,OAAO,CAAW,EAAE,IAAI,CAAc,EAAE,KAAK,GAAG,CAAC,EAC7E,KAAK;AAAA,CAEW,GAQf,IAAA,CAAkB,MAA6B;AACnD,MAAI,IAAc,EAAY,cAAc,YAAY;AACxD,SAAA,KAAe,EAAY,YAAY,gBAAgB,IACvD,KAAe,EAAY,aAEpB;AACT,GAEM,IAAA,CAAW,GAA0B,MAClC,EAAY,KAChB,IAAA,CAAK,MACQ,EAAK,OAAA,CAAQ,MAAM,EAAE,SAAS,CAAO,EAAE,CAAA,GAEvC,QAAQ,EACrB,EACA,KAAK,GAAG"}
@@ -10,8 +10,12 @@ interface BaseLayoutProps {
10
10
  beat: Beat;
11
11
  beatActions?: BeatActions;
12
12
  obsolete?: ObsoleteState;
13
+ /** Swap only the block slot for a LoadingCard (e.g. while a sampled beat loads). */
14
+ isLoading?: boolean;
15
+ /** Replace the entire card with an ErrorCard (e.g. when the sample fails to load). */
16
+ isError?: boolean;
13
17
  }
14
- declare const BaseLayout: (({ beat, beatActions, obsolete }: BaseLayoutProps) => import("react/jsx-runtime").JSX.Element | null) & {
18
+ declare const BaseLayout: (({ beat, beatActions, obsolete, isLoading, isError, }: BaseLayoutProps) => import("react/jsx-runtime").JSX.Element | null) & {
15
19
  displayName: string;
16
20
  };
17
21
  export default BaseLayout;
@@ -1,25 +1,27 @@
1
- import { useAppConfig as T, useGlobalCopyStore as F, useInsightsV2Store as A } from "../../common/context/hooks.es.js";
2
- import { sendBeatCta as I } from "../../common/utils/PostMessage.es.js";
3
- import { blocks as E, hasDrawerBlock as H } from "../mappings/blocks.es.js";
4
- import M from "./Footer.es.js";
5
- import { BeatActionsProvider as G } from "../beatActions.es.js";
6
- import R from "./Header.es.js";
7
- import { FeedbackBar as j } from "./FeedbackBar.es.js";
8
- import z from "./FeedbackDialog.es.js";
9
- import { DismissInsightDialog as N } from "./DismissInsightDialog.es.js";
10
- import { HiddenConfirmationCard as P } from "./HiddenConfirmationCard.es.js";
11
- import { ObsolesceBanner as U } from "./ObsolesceBanner.es.js";
12
- import { ActionBlockLayer as V } from "../actionBlocks/ActionBlockLayer.es.js";
13
- import { useBeatFeedbackFlow as W } from "../hooks/useBeatFeedbackFlow.es.js";
14
- import { observer as X } from "mobx-react-lite";
1
+ import { useAppConfig as A, useGlobalCopyStore as I, useInsightsV2Store as E } from "../../common/context/hooks.es.js";
2
+ import { sendBeatCta as H } from "../../common/utils/PostMessage.es.js";
3
+ import { blocks as M, hasDrawerBlock as G } from "../mappings/blocks.es.js";
4
+ import R from "./Footer.es.js";
5
+ import { BeatActionsProvider as j } from "../beatActions.es.js";
6
+ import z from "./Header.es.js";
7
+ import { FeedbackBar as N } from "./FeedbackBar.es.js";
8
+ import P from "./FeedbackDialog.es.js";
9
+ import { DismissInsightDialog as U } from "./DismissInsightDialog.es.js";
10
+ import { HiddenConfirmationCard as V } from "./HiddenConfirmationCard.es.js";
11
+ import { ErrorCard as W } from "./ErrorCard.es.js";
12
+ import { LoadingCard as X } from "./LoadingCard.es.js";
13
+ import { ObsolesceBanner as Y } from "./ObsolesceBanner.es.js";
14
+ import { ActionBlockLayer as q } from "../actionBlocks/ActionBlockLayer.es.js";
15
+ import { useBeatFeedbackFlow as J } from "../hooks/useBeatFeedbackFlow.es.js";
16
+ import { observer as K } from "mobx-react-lite";
15
17
  import m from "@mui/material/Stack";
16
- import { P as Y } from "@mxenabled/mxui";
18
+ import { P as Q } from "@mxenabled/mxui";
17
19
  import p from "@mui/material/Button";
18
- import { ChevronRight as q } from "@mxenabled/mx-icons";
19
- import { Fragment as J, jsx as o, jsxs as r } from "react/jsx-runtime";
20
- import K from "@mui/material/Box";
21
- import Q from "@mui/material/Card";
22
- var Z = {}, $ = {
20
+ import { ChevronRight as Z } from "@mxenabled/mx-icons";
21
+ import { Fragment as $, jsx as o, jsxs as t } from "react/jsx-runtime";
22
+ import ee from "@mui/material/Box";
23
+ import oe from "@mui/material/Card";
24
+ var ie = {}, re = {
23
25
  position: "absolute",
24
26
  top: 0,
25
27
  left: 0,
@@ -28,29 +30,31 @@ var Z = {}, $ = {
28
30
  backgroundColor: "background.default",
29
31
  opacity: 0.7,
30
32
  zIndex: 1
31
- }, _e = X(({ beat: i, beatActions: h = Z, obsolete: s }) => {
32
- const { openCtaDrawer: y } = A(), g = F(), { is_mobile_webview: k, clientConfig: v } = T(), e = W(i, h), t = i.insights_payload;
33
- if (!t || e.cardState === "dismissed") return null;
34
- const { instance_slot: _, primary_cta: n, secondary_cta: a, sub_title: C, title: x, widget_type: S, guid: d, user_guid: w, dismissed_at: B } = t, { block: D } = _, u = (L, O) => {
35
- H(L) ? y(d, O) : I(i, {
36
- isMobileWebview: k,
37
- webviewScheme: v?.master?.ui_message_webview_url_scheme,
38
- userGuid: w
33
+ }, De = K(({ beat: i, beatActions: h = ie, obsolete: s, isLoading: y = !1, isError: g = !1 }) => {
34
+ const { openCtaDrawer: C } = E(), k = I(), { is_mobile_webview: v, clientConfig: _ } = A(), e = J(i, h);
35
+ if (g) return /* @__PURE__ */ o(W, {});
36
+ const r = i.insights_payload;
37
+ if (!r || e.cardState === "dismissed") return null;
38
+ const { instance_slot: x, primary_cta: n, secondary_cta: a, sub_title: S, title: w, widget_type: B, guid: d, user_guid: D, dismissed_at: L } = r, { block: O } = x, u = (T, F) => {
39
+ G(T) ? C(d, F) : H(i, {
40
+ isMobileWebview: v,
41
+ webviewScheme: _?.master?.ui_message_webview_url_scheme,
42
+ userGuid: D
39
43
  });
40
- }, b = E[D], f = S === "mini", l = g.insights_feed?.general, c = s?.state === "not_refreshable" && !B && !!l;
41
- return /* @__PURE__ */ o(G, {
44
+ }, f = M[O], b = B === "mini", l = k.insights_feed?.general, c = s?.state === "not_refreshable" && !L && !!l;
45
+ return /* @__PURE__ */ o(j, {
42
46
  value: e.wrappedActions,
43
- children: /* @__PURE__ */ r(m, {
47
+ children: /* @__PURE__ */ t(m, {
44
48
  sx: { mb: 16 },
45
49
  children: [
46
- e.cardState === "confirming" ? /* @__PURE__ */ o(P, {
50
+ e.cardState === "confirming" ? /* @__PURE__ */ o(V, {
47
51
  onClose: e.collapseConfirmation,
48
52
  onLeaveFeedback: e.openHideSurvey,
49
53
  onUndo: e.undoDismiss
50
- }) : /* @__PURE__ */ r(J, { children: [s && l && /* @__PURE__ */ o(U, {
54
+ }) : /* @__PURE__ */ t($, { children: [s && l && /* @__PURE__ */ o(Y, {
51
55
  ...s,
52
56
  copy: l
53
- }), /* @__PURE__ */ r(Q, {
57
+ }), /* @__PURE__ */ t(oe, {
54
58
  inert: c,
55
59
  sx: { ...c && {
56
60
  position: "relative",
@@ -58,17 +62,17 @@ var Z = {}, $ = {
58
62
  pointerEvents: "none"
59
63
  } },
60
64
  children: [
61
- c && /* @__PURE__ */ o(K, { sx: $ }),
62
- /* @__PURE__ */ o(R, {
63
- isMini: f,
64
- subtitle: C,
65
- title: x ?? ""
65
+ c && /* @__PURE__ */ o(ee, { sx: re }),
66
+ /* @__PURE__ */ o(z, {
67
+ isMini: b,
68
+ subtitle: S,
69
+ title: w ?? ""
66
70
  }),
67
- b && /* @__PURE__ */ o(b, {
71
+ y ? /* @__PURE__ */ o(X, {}) : f && /* @__PURE__ */ o(f, {
68
72
  beatGuid: d,
69
- payload: t
73
+ payload: r
70
74
  }),
71
- /* @__PURE__ */ r(m, {
75
+ /* @__PURE__ */ t(m, {
72
76
  sx: {
73
77
  gap: 6,
74
78
  pb: 16,
@@ -76,11 +80,11 @@ var Z = {}, $ = {
76
80
  pr: 16,
77
81
  pt: 12
78
82
  },
79
- children: [/* @__PURE__ */ o(Y, {
80
- dangerouslySetInnerHTML: { __html: t.description.html_text },
83
+ children: [/* @__PURE__ */ o(Q, {
84
+ dangerouslySetInnerHTML: { __html: r.description.html_text },
81
85
  variant: "subtitle2"
82
86
  }), i?.in_description_cta && /* @__PURE__ */ o(p, {
83
- endIcon: /* @__PURE__ */ o(q, {}),
87
+ endIcon: /* @__PURE__ */ o(Z, {}),
84
88
  onClick: () => {
85
89
  },
86
90
  sx: {
@@ -91,7 +95,7 @@ var Z = {}, $ = {
91
95
  children: i.in_description_cta
92
96
  })]
93
97
  }),
94
- !f && n?.label && /* @__PURE__ */ r(m, {
98
+ !b && n?.label && /* @__PURE__ */ t(m, {
95
99
  sx: {
96
100
  gap: 8,
97
101
  pb: 16,
@@ -107,19 +111,19 @@ var Z = {}, $ = {
107
111
  children: a.label
108
112
  })]
109
113
  }),
110
- /* @__PURE__ */ o(j, {
114
+ /* @__PURE__ */ o(N, {
111
115
  onTellUsMore: e.openRatingSurvey,
112
116
  show: e.isFeedbackBarShown
113
117
  })
114
118
  ]
115
119
  })] }),
116
- /* @__PURE__ */ o(V, { beat: i }),
117
- /* @__PURE__ */ o(N, {
120
+ /* @__PURE__ */ o(q, { beat: i }),
121
+ /* @__PURE__ */ o(U, {
118
122
  isOpen: e.isDismissOpen,
119
123
  onClose: e.closeDismissDialog,
120
124
  onDismiss: e.confirmDismiss
121
125
  }),
122
- e.isSurveyOpen && /* @__PURE__ */ o(z, {
126
+ e.isSurveyOpen && /* @__PURE__ */ o(P, {
123
127
  characterLimitLabel: e.survey.characterLimitLabel,
124
128
  closeAriaLabel: e.survey.closeAriaLabel,
125
129
  isOpen: !0,
@@ -132,13 +136,13 @@ var Z = {}, $ = {
132
136
  secondaryText: e.survey.backText,
133
137
  title: e.survey.title
134
138
  }),
135
- e.cardState === "visible" && t.footer && /* @__PURE__ */ o(M, { footer: t.footer })
139
+ e.cardState === "visible" && r.footer && /* @__PURE__ */ o(R, { footer: r.footer })
136
140
  ]
137
141
  })
138
142
  });
139
143
  });
140
144
  export {
141
- _e as default
145
+ De as default
142
146
  };
143
147
 
144
148
  //# sourceMappingURL=BaseLayout.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseLayout.es.js","names":[],"sources":["../../../src/insights-v2/components/BaseLayout.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Card from '@mui/material/Card'\nimport Stack from '@mui/material/Stack'\n\nimport { ChevronRight } from '@mxenabled/mx-icons'\nimport { P } from '@mxenabled/mxui'\n\nimport { blocks, hasDrawerBlock } from '../mappings/blocks'\n\nimport Footer from './Footer'\nimport Header from './Header'\nimport FeedbackBar from './FeedbackBar'\nimport FeedbackDialog from './FeedbackDialog'\nimport DismissInsightDialog from './DismissInsightDialog'\nimport HiddenConfirmationCard from './HiddenConfirmationCard'\nimport { ObsolesceBanner, type ObsolesceBannerState } from './ObsolesceBanner'\nimport { useAppConfig, useGlobalCopyStore, useInsightsV2Store } from '../../common'\nimport { sendBeatCta } from '../../common/utils/PostMessage'\nimport type { Beat } from '../../core'\nimport { BeatActionsProvider, type BeatActions } from '../beatActions'\nimport { ActionBlockLayer } from '../actionBlocks/ActionBlockLayer'\nimport { useBeatFeedbackFlow } from '../hooks/useBeatFeedbackFlow'\n\nexport interface ObsoleteState {\n state: ObsolesceBannerState\n onRefresh: () => void\n onDismiss: () => void\n}\n\ninterface BaseLayoutProps {\n beat: Beat\n beatActions?: BeatActions\n obsolete?: ObsoleteState\n}\n\nconst NO_BEAT_ACTIONS: BeatActions = {}\n\nconst OBSOLETE_OVERLAY_SX = {\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n height: '100%',\n backgroundColor: 'background.default',\n opacity: 0.7,\n zIndex: 1,\n} as const\n\nconst BaseLayout = observer(\n ({ beat, beatActions = NO_BEAT_ACTIONS, obsolete }: BaseLayoutProps) => {\n const { openCtaDrawer } = useInsightsV2Store()\n const copy = useGlobalCopyStore()\n const { is_mobile_webview, clientConfig } = useAppConfig()\n const flow = useBeatFeedbackFlow(beat, beatActions)\n\n const insights_payload = beat.insights_payload\n\n if (!insights_payload) return null\n if (flow.cardState === 'dismissed') return null\n\n const {\n instance_slot,\n primary_cta,\n secondary_cta,\n sub_title,\n title,\n widget_type,\n guid,\n user_guid,\n dismissed_at,\n } = insights_payload\n const { block } = instance_slot\n\n // A CTA with a real drilldown `block` opens a drawer; otherwise it notifies\n // the host app via a beat/cta post message (the \"Make a Transfer\" CTA on the\n // Save an extra $100 beat). Mirrors Pulse's SaveAnExtra100Dollars beat.\n const handleCtaClick = (\n ctaBlock: string | null | undefined,\n source: 'primaryCta' | 'secondaryCta',\n ) => {\n if (hasDrawerBlock(ctaBlock)) {\n openCtaDrawer(guid, source)\n } else {\n sendBeatCta(beat, {\n isMobileWebview: is_mobile_webview,\n webviewScheme: clientConfig?.master?.ui_message_webview_url_scheme,\n userGuid: user_guid,\n })\n }\n }\n\n const Block = blocks[block as keyof typeof blocks]\n\n const isMini = widget_type === 'mini'\n const obsoleteCopy = copy.insights_feed?.general\n const isObsoleteDimmed =\n obsolete?.state === 'not_refreshable' && !dismissed_at && !!obsoleteCopy\n\n return (\n <BeatActionsProvider value={flow.wrappedActions}>\n <Stack sx={{ mb: 16 }}>\n {flow.cardState === 'confirming' ? (\n <HiddenConfirmationCard\n onClose={flow.collapseConfirmation}\n onLeaveFeedback={flow.openHideSurvey}\n onUndo={flow.undoDismiss}\n />\n ) : (\n <>\n {obsolete && obsoleteCopy && <ObsolesceBanner {...obsolete} copy={obsoleteCopy} />}\n <Card\n inert={isObsoleteDimmed}\n sx={{\n ...(isObsoleteDimmed && {\n position: 'relative',\n zIndex: 2,\n pointerEvents: 'none',\n }),\n }}\n >\n {isObsoleteDimmed && <Box sx={OBSOLETE_OVERLAY_SX} />}\n <Header isMini={isMini} subtitle={sub_title} title={title ?? ''} />\n {Block && <Block beatGuid={guid} payload={insights_payload} />}\n\n <Stack sx={{ gap: 6, pb: 16, pl: 12, pr: 16, pt: 12 }}>\n <P\n dangerouslySetInnerHTML={{\n __html: insights_payload.description.html_text,\n }}\n variant=\"subtitle2\"\n />\n {/* TODO: Migrate to insights_payload.in_description_cta once backend provides it */}\n {beat?.in_description_cta && (\n <Button\n endIcon={<ChevronRight />}\n onClick={() => {}}\n sx={{ height: 24, p: 4, width: 'max-content' }}\n >\n {beat.in_description_cta}\n </Button>\n )}\n </Stack>\n\n {!isMini && primary_cta?.label && (\n <Stack sx={{ gap: 8, pb: 16, px: 16 }}>\n <Button\n onClick={() => handleCtaClick(primary_cta.block, 'primaryCta')}\n variant=\"outlined\"\n >\n {primary_cta.label}\n </Button>\n {secondary_cta?.label && (\n <Button\n color=\"secondary\"\n onClick={() => handleCtaClick(secondary_cta.block, 'secondaryCta')}\n >\n {secondary_cta.label}\n </Button>\n )}\n </Stack>\n )}\n\n <FeedbackBar onTellUsMore={flow.openRatingSurvey} show={flow.isFeedbackBarShown} />\n </Card>\n </>\n )}\n\n <ActionBlockLayer beat={beat} />\n\n <DismissInsightDialog\n isOpen={flow.isDismissOpen}\n onClose={flow.closeDismissDialog}\n onDismiss={flow.confirmDismiss}\n />\n\n {flow.isSurveyOpen && (\n <FeedbackDialog\n characterLimitLabel={flow.survey.characterLimitLabel}\n closeAriaLabel={flow.survey.closeAriaLabel}\n isOpen={true}\n onBackClick={flow.feedbackDialogCallbacks.onBackClick}\n onClose={flow.closeSurvey}\n onSubmit={flow.submitSurvey}\n onTextInputFocus={flow.feedbackDialogCallbacks.onTextInputFocus}\n options={flow.survey.options}\n primaryText={flow.survey.submitText}\n secondaryText={flow.survey.backText}\n title={flow.survey.title}\n />\n )}\n\n {flow.cardState === 'visible' && insights_payload.footer && (\n <Footer footer={insights_payload.footer} />\n )}\n </Stack>\n </BeatActionsProvider>\n )\n },\n)\n\nexport default BaseLayout\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsCA,IAAM,IAA+B,CAAC,GAEhC,IAAsB;AAAA,EAC1B,UAAU;AAAA,EACV,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA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AAA,gBAC7D,SAAQ;AAAA,gBAEP,UAAA,EAAY;AAAA,cACP,CAAA,GACP,GAAe,SACd,gBAAA,EAAC,GAAD;AAAA,gBACE,OAAM;AAAA,gBACN,SAAA,MAAe,EAAe,EAAc,OAAO,cAAc;AAAA,gBAEhE,UAAA,EAAc;AAAA,cACT,CAAA,CAEL;AAAA;YAGT,gBAAA,EAAC,GAAD;AAAA,cAAa,cAAc,EAAK;AAAA,cAAkB,MAAM,EAAK;AAAA,YAAqB,CAAA;AAAA,UAC9E;AAAA,QACN,CAAA,CAAA,EAAA,CAAA;AAAA,QAGJ,gBAAA,EAAC,GAAD,EAAwB,MAAA,EAAO,CAAA;AAAA,QAE/B,gBAAA,EAAC,GAAD;AAAA,UACE,QAAQ,EAAK;AAAA,UACb,SAAS,EAAK;AAAA,UACd,WAAW,EAAK;AAAA,QACjB,CAAA;AAAA,QAEA,EAAK,gBACJ,gBAAA,EAAC,GAAD;AAAA,UACE,qBAAqB,EAAK,OAAO;AAAA,UACjC,gBAAgB,EAAK,OAAO;AAAA,UAC5B,QAAQ;AAAA,UACR,aAAa,EAAK,wBAAwB;AAAA,UAC1C,SAAS,EAAK;AAAA,UACd,UAAU,EAAK;AAAA,UACf,kBAAkB,EAAK,wBAAwB;AAAA,UAC/C,SAAS,EAAK,OAAO;AAAA,UACrB,aAAa,EAAK,OAAO;AAAA,UACzB,eAAe,EAAK,OAAO;AAAA,UAC3B,OAAO,EAAK,OAAO;AAAA,QACpB,CAAA;AAAA,QAGF,EAAK,cAAc,aAAa,EAAiB,UAChD,gBAAA,EAAC,GAAD,EAAQ,QAAQ,EAAiB,OAAS,CAAA;AAAA,MAEvC;AAAA;EACY,CAAA;AAEzB,CACF"}
1
+ {"version":3,"file":"BaseLayout.es.js","names":[],"sources":["../../../src/insights-v2/components/BaseLayout.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Card from '@mui/material/Card'\nimport Stack from '@mui/material/Stack'\n\nimport { ChevronRight } from '@mxenabled/mx-icons'\nimport { P } from '@mxenabled/mxui'\n\nimport { blocks, hasDrawerBlock } from '../mappings/blocks'\n\nimport Footer from './Footer'\nimport Header from './Header'\nimport FeedbackBar from './FeedbackBar'\nimport FeedbackDialog from './FeedbackDialog'\nimport DismissInsightDialog from './DismissInsightDialog'\nimport HiddenConfirmationCard from './HiddenConfirmationCard'\nimport ErrorCard from './ErrorCard'\nimport LoadingCard from './LoadingCard'\nimport { ObsolesceBanner, type ObsolesceBannerState } from './ObsolesceBanner'\nimport { useAppConfig, useGlobalCopyStore, useInsightsV2Store } from '../../common'\nimport { sendBeatCta } from '../../common/utils/PostMessage'\nimport type { Beat } from '../../core'\nimport { BeatActionsProvider, type BeatActions } from '../beatActions'\nimport { ActionBlockLayer } from '../actionBlocks/ActionBlockLayer'\nimport { useBeatFeedbackFlow } from '../hooks/useBeatFeedbackFlow'\n\nexport interface ObsoleteState {\n state: ObsolesceBannerState\n onRefresh: () => void\n onDismiss: () => void\n}\n\ninterface BaseLayoutProps {\n beat: Beat\n beatActions?: BeatActions\n obsolete?: ObsoleteState\n /** Swap only the block slot for a LoadingCard (e.g. while a sampled beat loads). */\n isLoading?: boolean\n /** Replace the entire card with an ErrorCard (e.g. when the sample fails to load). */\n isError?: boolean\n}\n\nconst NO_BEAT_ACTIONS: BeatActions = {}\n\nconst OBSOLETE_OVERLAY_SX = {\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n height: '100%',\n backgroundColor: 'background.default',\n opacity: 0.7,\n zIndex: 1,\n} as const\n\nconst BaseLayout = observer(\n ({\n beat,\n beatActions = NO_BEAT_ACTIONS,\n obsolete,\n isLoading = false,\n isError = false,\n }: BaseLayoutProps) => {\n const { openCtaDrawer } = useInsightsV2Store()\n const copy = useGlobalCopyStore()\n const { is_mobile_webview, clientConfig } = useAppConfig()\n const flow = useBeatFeedbackFlow(beat, beatActions)\n\n // Error replaces the entire card; loading only swaps the block slot (below).\n if (isError) return <ErrorCard />\n\n const insights_payload = beat.insights_payload\n\n if (!insights_payload) return null\n if (flow.cardState === 'dismissed') return null\n\n const {\n instance_slot,\n primary_cta,\n secondary_cta,\n sub_title,\n title,\n widget_type,\n guid,\n user_guid,\n dismissed_at,\n } = insights_payload\n const { block } = instance_slot\n\n // A CTA with a real drilldown `block` opens a drawer; otherwise it notifies\n // the host app via a beat/cta post message (the \"Make a Transfer\" CTA on the\n // Save an extra $100 beat). Mirrors Pulse's SaveAnExtra100Dollars beat.\n const handleCtaClick = (\n ctaBlock: string | null | undefined,\n source: 'primaryCta' | 'secondaryCta',\n ) => {\n if (hasDrawerBlock(ctaBlock)) {\n openCtaDrawer(guid, source)\n } else {\n sendBeatCta(beat, {\n isMobileWebview: is_mobile_webview,\n webviewScheme: clientConfig?.master?.ui_message_webview_url_scheme,\n userGuid: user_guid,\n })\n }\n }\n\n const Block = blocks[block as keyof typeof blocks]\n\n const isMini = widget_type === 'mini'\n const obsoleteCopy = copy.insights_feed?.general\n const isObsoleteDimmed =\n obsolete?.state === 'not_refreshable' && !dismissed_at && !!obsoleteCopy\n\n return (\n <BeatActionsProvider value={flow.wrappedActions}>\n <Stack sx={{ mb: 16 }}>\n {flow.cardState === 'confirming' ? (\n <HiddenConfirmationCard\n onClose={flow.collapseConfirmation}\n onLeaveFeedback={flow.openHideSurvey}\n onUndo={flow.undoDismiss}\n />\n ) : (\n <>\n {obsolete && obsoleteCopy && <ObsolesceBanner {...obsolete} copy={obsoleteCopy} />}\n <Card\n inert={isObsoleteDimmed}\n sx={{\n ...(isObsoleteDimmed && {\n position: 'relative',\n zIndex: 2,\n pointerEvents: 'none',\n }),\n }}\n >\n {isObsoleteDimmed && <Box sx={OBSOLETE_OVERLAY_SX} />}\n <Header isMini={isMini} subtitle={sub_title} title={title ?? ''} />\n {isLoading ? (\n <LoadingCard />\n ) : (\n Block && <Block beatGuid={guid} payload={insights_payload} />\n )}\n\n <Stack sx={{ gap: 6, pb: 16, pl: 12, pr: 16, pt: 12 }}>\n <P\n dangerouslySetInnerHTML={{\n __html: insights_payload.description.html_text,\n }}\n variant=\"subtitle2\"\n />\n {/* TODO: Migrate to insights_payload.in_description_cta once backend provides it */}\n {beat?.in_description_cta && (\n <Button\n endIcon={<ChevronRight />}\n onClick={() => {}}\n sx={{ height: 24, p: 4, width: 'max-content' }}\n >\n {beat.in_description_cta}\n </Button>\n )}\n </Stack>\n\n {!isMini && primary_cta?.label && (\n <Stack sx={{ gap: 8, pb: 16, px: 16 }}>\n <Button\n onClick={() => handleCtaClick(primary_cta.block, 'primaryCta')}\n variant=\"outlined\"\n >\n {primary_cta.label}\n </Button>\n {secondary_cta?.label && (\n <Button\n color=\"secondary\"\n onClick={() => handleCtaClick(secondary_cta.block, 'secondaryCta')}\n >\n {secondary_cta.label}\n </Button>\n )}\n </Stack>\n )}\n\n <FeedbackBar onTellUsMore={flow.openRatingSurvey} show={flow.isFeedbackBarShown} />\n </Card>\n </>\n )}\n\n <ActionBlockLayer beat={beat} />\n\n <DismissInsightDialog\n isOpen={flow.isDismissOpen}\n onClose={flow.closeDismissDialog}\n onDismiss={flow.confirmDismiss}\n />\n\n {flow.isSurveyOpen && (\n <FeedbackDialog\n characterLimitLabel={flow.survey.characterLimitLabel}\n closeAriaLabel={flow.survey.closeAriaLabel}\n isOpen={true}\n onBackClick={flow.feedbackDialogCallbacks.onBackClick}\n onClose={flow.closeSurvey}\n onSubmit={flow.submitSurvey}\n onTextInputFocus={flow.feedbackDialogCallbacks.onTextInputFocus}\n options={flow.survey.options}\n primaryText={flow.survey.submitText}\n secondaryText={flow.survey.backText}\n title={flow.survey.title}\n />\n )}\n\n {flow.cardState === 'visible' && insights_payload.footer && (\n <Footer footer={insights_payload.footer} />\n )}\n </Stack>\n </BeatActionsProvider>\n )\n },\n)\n\nexport default BaseLayout\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA4CA,IAAM,KAA+B,CAAC,GAEhC,KAAsB;AAAA,EAC1B,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AA,MAEvC;AAAA;EACY,CAAA;AAEzB,CACF"}
@@ -0,0 +1,15 @@
1
+ export interface ErrorCardProps {
2
+ /** Force the CIBC illustration. When omitted, derived from the app's copy namespace. */
3
+ isCibc?: boolean;
4
+ onRetry?: () => void;
5
+ }
6
+ /**
7
+ * Card-framed error state for the InsightsV2 feed.
8
+ *
9
+ * Reads its copy from the experiences copy store and derives the CIBC variant from
10
+ * the app config, so the host only has to signal that an error occurred.
11
+ */
12
+ export declare const ErrorCard: (({ isCibc, onRetry }: ErrorCardProps) => import("react/jsx-runtime").JSX.Element) & {
13
+ displayName: string;
14
+ };
15
+ export default ErrorCard;
@@ -0,0 +1,85 @@
1
+ import { useAppConfig as m, useGlobalCopyStore as p } from "../../common/context/hooks.es.js";
2
+ import { BlobSVG as d } from "../../common/components/Error.es.js";
3
+ import { ThemedSVGImage as i } from "./chartblocks/ThemedSVGImage.es.js";
4
+ import { ReactComponent as x } from "./shared/images/ErrorViewCibc.es.js";
5
+ import { observer as g } from "mobx-react-lite";
6
+ import { Icon as h, P as f, Text as y } from "@mxenabled/mxui";
7
+ import { jsx as e, jsxs as o } from "react/jsx-runtime";
8
+ import { Button as u, Card as C, Stack as r } from "@mui/material";
9
+ var b = "cibc_custom_copy", v = () => window.location.reload(), B = g(({ isCibc: n, onRetry: a = v }) => {
10
+ const s = p(), { options: c } = m(), t = s.insights_feed?.general, l = n ?? c?.custom_copy_namespace === b;
11
+ return /* @__PURE__ */ e(C, {
12
+ sx: { pt: 32 },
13
+ children: /* @__PURE__ */ o(r, {
14
+ sx: { gap: 32 },
15
+ children: [/* @__PURE__ */ o(r, {
16
+ sx: {
17
+ alignItems: "center",
18
+ gap: 16,
19
+ px: 16
20
+ },
21
+ children: [l ? /* @__PURE__ */ e(i, {
22
+ divProps: { style: {
23
+ maxWidth: 150,
24
+ width: "100%"
25
+ } },
26
+ image: x
27
+ }) : /* @__PURE__ */ o(r, {
28
+ sx: {
29
+ position: "relative",
30
+ display: "inline-flex",
31
+ alignItems: "center",
32
+ justifyContent: "center"
33
+ },
34
+ children: [/* @__PURE__ */ e(i, {
35
+ divProps: { style: {
36
+ position: "absolute",
37
+ zIndex: 0
38
+ } },
39
+ image: d
40
+ }), /* @__PURE__ */ e(h, {
41
+ color: "primary",
42
+ name: "error",
43
+ size: 48,
44
+ sx: { zIndex: 1 }
45
+ })]
46
+ }), /* @__PURE__ */ o(r, {
47
+ sx: {
48
+ alignItems: "center",
49
+ gap: 2
50
+ },
51
+ children: [/* @__PURE__ */ e(y, {
52
+ bold: !0,
53
+ variant: "body1",
54
+ children: t?.error_heading
55
+ }), /* @__PURE__ */ e(f, {
56
+ color: "text.secondary",
57
+ sx: {
58
+ fontWeight: 400,
59
+ textAlign: "center"
60
+ },
61
+ variant: "subtitle2",
62
+ children: t?.error_message
63
+ })]
64
+ })]
65
+ }), /* @__PURE__ */ e(r, {
66
+ sx: {
67
+ pb: 16,
68
+ px: 16
69
+ },
70
+ children: /* @__PURE__ */ e(u, {
71
+ color: "primary",
72
+ onClick: a,
73
+ variant: "outlined",
74
+ children: t?.try_again
75
+ })
76
+ })]
77
+ })
78
+ });
79
+ });
80
+ export {
81
+ B as ErrorCard,
82
+ B as default
83
+ };
84
+
85
+ //# sourceMappingURL=ErrorCard.es.js.map