@mx-cartographer/experiences 9.7.122 → 9.7.124

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 (31) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/common/components/WidgetContainer.es.js +29 -29
  3. package/dist/common/components/WidgetContainer.es.js.map +1 -1
  4. package/dist/common/components/drawer/Header.es.js +1 -1
  5. package/dist/common/components/drawer/Header.es.js.map +1 -1
  6. package/dist/core/types/localization/InsightsFeedCopy.d.ts +7 -0
  7. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.d.ts +2 -1
  8. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js +66 -62
  9. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js.map +1 -1
  10. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +86 -85
  11. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
  12. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +5 -3
  13. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +137 -107
  14. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
  15. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.d.ts +4 -2
  16. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.es.js +17 -13
  17. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.es.js.map +1 -1
  18. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js +7 -7
  19. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js.map +1 -1
  20. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.d.ts +6 -3
  21. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js +31 -31
  22. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js.map +1 -1
  23. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.es.js +1 -1
  24. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.es.js.map +1 -1
  25. package/dist/settings/NotificationSettingsWidget.es.js +1 -1
  26. package/dist/settings/NotificationSettingsWidget.es.js.map +1 -1
  27. package/dist/trends/TrendsFullWidget.es.js +18 -18
  28. package/dist/trends/TrendsFullWidget.es.js.map +1 -1
  29. package/dist/trends/TrendsWidget.es.js +1 -1
  30. package/dist/trends/TrendsWidget.es.js.map +1 -1
  31. package/package.json +1 -1
@@ -1,21 +1,25 @@
1
- import { useAccountStore as g, useCategoryStore as m, useGlobalUiStore as l, useTransactionStore as p } from "../../../common/context/hooks.es.js";
2
- import { selectTransactionsByGuids as y } from "../../CommonUtils.es.js";
3
- import { toDrillDownSlotData as S } from "./utils.es.js";
4
- import { useMemo as T } from "react";
5
- var f = (o) => S(o?.instance_slot?.data ?? {}), b = (o, { slotData: s = f, beatTransactions: n } = {}) => {
6
- const e = o.insights_payload, t = T(() => s(e), [e, s]), r = p(), u = g(), i = m(), { displayedDateRange: d } = l(), c = y(r.detailedTransactions, t?.transaction_guids);
1
+ import { useAccountStore as m, useCategoryStore as l, useGlobalUiStore as p, useTransactionStore as y } from "../../../common/context/hooks.es.js";
2
+ import { selectTransactionsByGuids as S } from "../../CommonUtils.es.js";
3
+ import { toDrillDownSlotData as T } from "./utils.es.js";
4
+ import { useMemo as f } from "react";
5
+ var C = (o) => T(o?.instance_slot?.data ?? {}), h = (o, { slotData: s = C, beatTransactions: n } = {}, e) => {
6
+ const r = o.insights_payload, t = f(() => s(r, e), [
7
+ r,
8
+ s,
9
+ e
10
+ ]), i = y(), d = m(), c = l(), { displayedDateRange: g } = p(), u = S(i.detailedTransactions, t?.transaction_guids);
7
11
  return {
8
12
  instanceSlotData: t,
9
- beatTransactions: n ? n(c, t) : c,
10
- spendCategoryGuids: i.spendCategories.map((a) => a.guid),
11
- allAccountGuids: u.accounts.map((a) => a.guid),
12
- categoryName: i.getCategoryName(t?.category_guid ?? "") || "",
13
- displayedDateRange: d,
14
- transactionStore: r
13
+ beatTransactions: n ? n(u, t) : u,
14
+ spendCategoryGuids: c.spendCategories.map((a) => a.guid),
15
+ allAccountGuids: d.accounts.map((a) => a.guid),
16
+ categoryName: c.getCategoryName(t?.category_guid ?? "") || "",
17
+ displayedDateRange: g,
18
+ transactionStore: i
15
19
  };
16
20
  };
17
21
  export {
18
- b as useTransactionHistory
22
+ h as useTransactionHistory
19
23
  };
20
24
 
21
25
  //# sourceMappingURL=useTransactionHistory.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTransactionHistory.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nimport {\n useAccountStore,\n useCategoryStore,\n useGlobalUiStore,\n useTransactionStore,\n} from '../../../common'\nimport type { Beat } from '../../../core'\nimport type { BarChartBlockData } from '../../../core/types/InsightsInstanceSlotData'\nimport { selectTransactionsByGuids } from '../../CommonUtils'\nimport type { DrillDownVariantConfig } from './layout'\nimport { type SlotDataResolver, toDrillDownSlotData } from './utils'\n\n// The default source of the drawer's facts: the bar chart's `instance_slot.data`.\nconst fromInstanceSlot: SlotDataResolver = (payload) =>\n toDrillDownSlotData((payload?.instance_slot?.data ?? {}) as BarChartBlockData)\n\n/**\n * The drawer's facts and store reads. `slotData` and `beatTransactions` are the variant's resolvers\n * from the drilldown registry (layout.tsx): a variant that names no `slotData` reads\n * `instance_slot.data`, and one that names no `beatTransactions` gets the beat's own transactions.\n */\nexport const useTransactionHistory = (\n beat: Beat,\n {\n slotData: resolveSlotData = fromInstanceSlot,\n beatTransactions: resolveBeatTransactions,\n }: Pick<DrillDownVariantConfig, 'slotData' | 'beatTransactions'> = {},\n) => {\n // Memoised: the drawer's filter effect depends on this object's identity.\n const insightsPayload = beat.insights_payload\n const instanceSlotData = useMemo(\n () => resolveSlotData(insightsPayload),\n [insightsPayload, resolveSlotData],\n )\n\n const transactionStore = useTransactionStore()\n const accountStore = useAccountStore()\n const categoryStore = useCategoryStore()\n const { displayedDateRange } = useGlobalUiStore()\n\n const ownTransactions = selectTransactionsByGuids(\n transactionStore.detailedTransactions,\n instanceSlotData?.transaction_guids,\n )\n const beatTransactions = resolveBeatTransactions\n ? resolveBeatTransactions(ownTransactions, instanceSlotData)\n : ownTransactions\n\n const spendCategoryGuids = categoryStore.spendCategories.map((category) => category.guid)\n const allAccountGuids = accountStore.accounts.map((account) => account.guid)\n const categoryName = categoryStore.getCategoryName(instanceSlotData?.category_guid ?? '') || ''\n\n return {\n instanceSlotData,\n beatTransactions,\n spendCategoryGuids,\n allAccountGuids,\n categoryName,\n displayedDateRange,\n transactionStore,\n }\n}\n"],"mappings":";;;;AAeA,IAAM,IAAA,CAAsC,MAC1C,EAAqB,GAAS,eAAe,QAAQ,CAAC,CAAuB,GAOlE,IAAA,CACX,GACA,EACE,UAAU,IAAkB,GAC5B,kBAAkB,EAAA,IAC+C,CAAC,MACjE;AAEH,QAAM,IAAkB,EAAK,kBACvB,IAAmB,EAAA,MACjB,EAAgB,CAAe,GACrC,CAAC,GAAiB,CAAe,CACnC,GAEM,IAAmB,EAAoB,GACvC,IAAe,EAAgB,GAC/B,IAAgB,EAAiB,GACjC,EAAE,oBAAA,EAAA,IAAuB,EAAiB,GAE1C,IAAkB,EACtB,EAAiB,sBACjB,GAAkB,iBACpB;AASA,SAAO;AAAA,IACL,kBAAA;AAAA,IACA,kBAVuB,IACrB,EAAwB,GAAiB,CAAgB,IACzD;AAAA,IASF,oBAPyB,EAAc,gBAAgB,IAAA,CAAK,MAAa,EAAS,IAOlF;AAAA,IACA,iBAPsB,EAAa,SAAS,IAAA,CAAK,MAAY,EAAQ,IAOrE;AAAA,IACA,cAPmB,EAAc,gBAAgB,GAAkB,iBAAiB,EAAE,KAAK;AAAA,IAQ3F,oBAAA;AAAA,IACA,kBAAA;AAAA,EACF;AACF"}
1
+ {"version":3,"file":"useTransactionHistory.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nimport {\n useAccountStore,\n useCategoryStore,\n useGlobalUiStore,\n useTransactionStore,\n} from '../../../common'\nimport type { Beat } from '../../../core'\nimport type { BarChartBlockData } from '../../../core/types/InsightsInstanceSlotData'\nimport { selectTransactionsByGuids } from '../../CommonUtils'\nimport type { DrillDownVariantConfig } from './layout'\nimport type { DrilldownData } from '../../../core'\nimport { type SlotDataResolver, toDrillDownSlotData } from './utils'\n\n// The default source of the drawer's facts: the bar chart's `instance_slot.data`.\nconst fromInstanceSlot: SlotDataResolver = (payload) =>\n toDrillDownSlotData((payload?.instance_slot?.data ?? {}) as BarChartBlockData)\n\n/**\n * The drawer's facts and store reads. `slotData` and `beatTransactions` are the variant's resolvers\n * from the drilldown registry (layout.tsx): a variant that names no `slotData` reads\n * `instance_slot.data`, and one that names no `beatTransactions` gets the beat's own transactions.\n * `ctaDrilldownData` is the drilldown_data of the CTA that opened the drawer, for a resolver that\n * reads its facts from the opener.\n */\nexport const useTransactionHistory = (\n beat: Beat,\n {\n slotData: resolveSlotData = fromInstanceSlot,\n beatTransactions: resolveBeatTransactions,\n }: Pick<DrillDownVariantConfig, 'slotData' | 'beatTransactions'> = {},\n ctaDrilldownData?: DrilldownData,\n) => {\n // Memoised: the drawer's filter effect depends on this object's identity.\n const insightsPayload = beat.insights_payload\n const instanceSlotData = useMemo(\n () => resolveSlotData(insightsPayload, ctaDrilldownData),\n [insightsPayload, resolveSlotData, ctaDrilldownData],\n )\n\n const transactionStore = useTransactionStore()\n const accountStore = useAccountStore()\n const categoryStore = useCategoryStore()\n const { displayedDateRange } = useGlobalUiStore()\n\n const ownTransactions = selectTransactionsByGuids(\n transactionStore.detailedTransactions,\n instanceSlotData?.transaction_guids,\n )\n const beatTransactions = resolveBeatTransactions\n ? resolveBeatTransactions(ownTransactions, instanceSlotData)\n : ownTransactions\n\n const spendCategoryGuids = categoryStore.spendCategories.map((category) => category.guid)\n const allAccountGuids = accountStore.accounts.map((account) => account.guid)\n const categoryName = categoryStore.getCategoryName(instanceSlotData?.category_guid ?? '') || ''\n\n return {\n instanceSlotData,\n beatTransactions,\n spendCategoryGuids,\n allAccountGuids,\n categoryName,\n displayedDateRange,\n transactionStore,\n }\n}\n"],"mappings":";;;;AAgBA,IAAM,IAAA,CAAsC,MAC1C,EAAqB,GAAS,eAAe,QAAQ,CAAC,CAAuB,GASlE,IAAA,CACX,GACA,EACE,UAAU,IAAkB,GAC5B,kBAAkB,EAAA,IAC+C,CAAC,GACpE,MACG;AAEH,QAAM,IAAkB,EAAK,kBACvB,IAAmB,EAAA,MACjB,EAAgB,GAAiB,CAAgB,GACvD;AAAA,IAAC;AAAA,IAAiB;AAAA,IAAiB;AAAA,EAAgB,CACrD,GAEM,IAAmB,EAAoB,GACvC,IAAe,EAAgB,GAC/B,IAAgB,EAAiB,GACjC,EAAE,oBAAA,EAAA,IAAuB,EAAiB,GAE1C,IAAkB,EACtB,EAAiB,sBACjB,GAAkB,iBACpB;AASA,SAAO;AAAA,IACL,kBAAA;AAAA,IACA,kBAVuB,IACrB,EAAwB,GAAiB,CAAgB,IACzD;AAAA,IASF,oBAPyB,EAAc,gBAAgB,IAAA,CAAK,MAAa,EAAS,IAOlF;AAAA,IACA,iBAPsB,EAAa,SAAS,IAAA,CAAK,MAAY,EAAQ,IAOrE;AAAA,IACA,cAPmB,EAAc,gBAAgB,GAAkB,iBAAiB,EAAE,KAAK;AAAA,IAQ3F,oBAAA;AAAA,IACA,kBAAA;AAAA,EACF;AACF"}
@@ -1,12 +1,12 @@
1
1
  import { useInsightsV2Store as d, useTransactionStore as f } from "../../../common/context/hooks.es.js";
2
- import { getDrillDownConfig as g, guidListOf as m } from "./utils.es.js";
3
- import { getDynamicCtaBasedOnTriggers as p } from "../util.es.js";
4
- import l from "react";
2
+ import { getDrillDownConfig as g, guidListOf as p } from "./utils.es.js";
3
+ import { getDynamicCtaBasedOnTriggers as l } from "../util.es.js";
4
+ import m from "react";
5
5
  var w = ({ beat: t }) => {
6
- const { isTransactionDataLoaded: o, loadMissingTransactionData: s, loadTransactionsByGuids: n } = f(), { actionDrawer: r } = d();
7
- l.useEffect(() => {
8
- const a = t?.insights_payload, c = p(r, a?.primary_cta, a?.secondary_cta, a?.in_description_cta)?.variant, { fetchMissingTransactions: e } = g(c ?? ""), i = m(e?.(t));
9
- (async () => (o || await s(), i && await n(i)))();
6
+ const { isTransactionDataLoaded: s, loadMissingTransactionData: n, loadTransactionsByGuids: r } = f(), { actionDrawer: c } = d();
7
+ m.useEffect(() => {
8
+ const a = t?.insights_payload, o = l(c, a?.primary_cta, a?.secondary_cta, a?.in_description_cta), { fetchMissingTransactions: e } = g(o?.variant ?? ""), i = p(e?.(t, o?.drilldown_data));
9
+ (async () => (s || await n(), i && await r(i)))();
10
10
  }, []);
11
11
  };
12
12
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"useTransactionHistoryPrepare.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.ts"],"sourcesContent":["import React from 'react'\n\nimport { useInsightsV2Store, useTransactionStore } from '../../../common'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\nimport { getDrillDownConfig, guidListOf } from './utils'\n\n/**\n * Open-time load for the Transaction History drawer. The list reads `detailedTransactions`, which\n * stays empty until beats, tags, taggings, rules and transactions are all loaded; a feed that never\n * mounted the transactions module has none of them. Loads only the missing pieces, so a host that\n * seeded any of them through `GlobalStore.loadData` keeps what it seeded.\n */\nexport const useTransactionHistoryPrepare = ({ beat }: ActionBlockProps) => {\n const { isTransactionDataLoaded, loadMissingTransactionData, loadTransactionsByGuids } =\n useTransactionStore()\n const { actionDrawer } = useInsightsV2Store()\n\n React.useEffect(() => {\n // A drawer whose registry entry names `fetchMissingTransactions` (Upcoming Bill) also fetches by\n // guid the transactions it returns that the store lacks, so each older paid bill gets its bar.\n const payload = beat?.insights_payload\n const variant = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n payload?.primary_cta,\n payload?.secondary_cta,\n payload?.in_description_cta,\n )?.variant\n const { fetchMissingTransactions } = getDrillDownConfig(variant ?? '')\n // The same narrowing the drawer applies, so the fetch and the chart agree on a valid guid list.\n const guids = guidListOf(fetchMissingTransactions?.(beat))\n\n // The window load replaces the store's transactions, so it finishes before the by-guid fetch\n // adds the older ones; run together, it could wipe them out.\n const load = async () => {\n if (!isTransactionDataLoaded) await loadMissingTransactionData()\n if (guids) await loadTransactionsByGuids(guids)\n }\n void load()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n}\n"],"mappings":";;;;AAaA,IAAa,IAAA,CAAgC,EAAE,MAAA,EAAA,MAA6B;AAC1E,QAAM,EAAE,yBAAA,GAAyB,4BAAA,GAA4B,yBAAA,EAAA,IAC3D,EAAoB,GAChB,EAAE,cAAA,EAAA,IAAiB,EAAmB;AAE5C,EAAA,EAAM,UAAA,MAAgB;AAGpB,UAAM,IAAU,GAAM,kBAChB,IAAU,EACd,GACA,GAAS,aACT,GAAS,eACT,GAAS,kBACX,GAAG,SACG,EAAE,0BAAA,EAAA,IAA6B,EAAmB,KAAW,EAAE,GAE/D,IAAQ,EAAW,IAA2B,CAAI,CAAC;AAQzD,KAJa,aACN,KAAyB,MAAM,EAA2B,GAC3D,KAAO,MAAM,EAAwB,CAAK;AAAA,EAIlD,GAAG,CAAC,CAAC;AACP"}
1
+ {"version":3,"file":"useTransactionHistoryPrepare.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.ts"],"sourcesContent":["import React from 'react'\n\nimport { useInsightsV2Store, useTransactionStore } from '../../../common'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\nimport { getDrillDownConfig, guidListOf } from './utils'\n\n/**\n * Open-time load for the Transaction History drawer. The list reads `detailedTransactions`, which\n * stays empty until beats, tags, taggings, rules and transactions are all loaded; a feed that never\n * mounted the transactions module has none of them. Loads only the missing pieces, so a host that\n * seeded any of them through `GlobalStore.loadData` keeps what it seeded.\n */\nexport const useTransactionHistoryPrepare = ({ beat }: ActionBlockProps) => {\n const { isTransactionDataLoaded, loadMissingTransactionData, loadTransactionsByGuids } =\n useTransactionStore()\n const { actionDrawer } = useInsightsV2Store()\n\n React.useEffect(() => {\n // A drawer whose registry entry names `fetchMissingTransactions` (Upcoming Bill) also fetches by\n // guid the transactions it returns that the store lacks, so each older paid bill gets its bar.\n const payload = beat?.insights_payload\n const openedCta = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n payload?.primary_cta,\n payload?.secondary_cta,\n payload?.in_description_cta,\n )\n const { fetchMissingTransactions } = getDrillDownConfig(openedCta?.variant ?? '')\n // The same narrowing the drawer applies, so the fetch and the chart agree on a valid guid list.\n const guids = guidListOf(fetchMissingTransactions?.(beat, openedCta?.drilldown_data))\n\n // The window load replaces the store's transactions, so it finishes before the by-guid fetch\n // adds the older ones; run together, it could wipe them out.\n const load = async () => {\n if (!isTransactionDataLoaded) await loadMissingTransactionData()\n if (guids) await loadTransactionsByGuids(guids)\n }\n void load()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n}\n"],"mappings":";;;;AAaA,IAAa,IAAA,CAAgC,EAAE,MAAA,EAAA,MAA6B;AAC1E,QAAM,EAAE,yBAAA,GAAyB,4BAAA,GAA4B,yBAAA,EAAA,IAC3D,EAAoB,GAChB,EAAE,cAAA,EAAA,IAAiB,EAAmB;AAE5C,EAAA,EAAM,UAAA,MAAgB;AAGpB,UAAM,IAAU,GAAM,kBAChB,IAAY,EAChB,GACA,GAAS,aACT,GAAS,eACT,GAAS,kBACX,GACM,EAAE,0BAAA,EAAA,IAA6B,EAAmB,GAAW,WAAW,EAAE,GAE1E,IAAQ,EAAW,IAA2B,GAAM,GAAW,cAAc,CAAC;AAQpF,KAJa,aACN,KAAyB,MAAM,EAA2B,GAC3D,KAAO,MAAM,EAAwB,CAAK;AAAA,EAIlD,GAAG,CAAC,CAAC;AACP"}
@@ -1,4 +1,4 @@
1
- import { ActionDrawerState, Beat, DataSeries, GlobalCopy, InsightsPayload, Subtitle, Transaction } from '../../../core';
1
+ import { ActionDrawerState, Beat, DataSeries, DrilldownData, GlobalCopy, InsightsPayload, Subtitle, Transaction } from '../../../core';
2
2
  import { BarChartBlockData, DataSet, InsightsInstanceSlotData } from '../../../core/types/InsightsInstanceSlotData';
3
3
  import { TransactionFilter } from '../../../core/stores/TransactionStore';
4
4
  import { buildChartData, ChartDataSeriesItem } from '../../blocks/ChartBlocks/BarchartBlock/utils';
@@ -88,8 +88,11 @@ export declare const finiteNumberOf: (value: unknown) => number | undefined;
88
88
  export declare const nonEmptyStringOf: (value: unknown) => string | undefined;
89
89
  export declare const guidListOf: (value: unknown) => string[] | undefined;
90
90
  export declare const calendarDateOf: (value: unknown) => string | undefined;
91
- /** Resolves the drawer's facts (bars, guids, colour, average, tip values) from the beat's payload. */
92
- export type SlotDataResolver = (payload: Partial<InsightsPayload> | undefined) => DrillDownSlotData;
91
+ /**
92
+ * Resolves the drawer's facts (bars, guids, colour, average, tip values) from the beat's payload, or
93
+ * from the drilldown_data of the CTA that opened the drawer (`ctaDrilldownData`).
94
+ */
95
+ export type SlotDataResolver = (payload: Partial<InsightsPayload> | undefined, ctaDrilldownData?: DrilldownData) => DrillDownSlotData;
93
96
  /**
94
97
  * Builds the drawer's transactions from the beat's own (its `transaction_guids` in the store) and
95
98
  * its facts, e.g. Upcoming Bill appends its projected bill. Absent: the beat's own, as they are.
@@ -1,15 +1,15 @@
1
- import { DATE_FORMATS_INTL as h, formatDate as p } from "../../../core/constants/DateFormats.es.js";
2
- import { fromUnixUTC as _ } from "../../../core/utils/DateUtil.es.js";
3
- import { buildChartData as c, buildDataSeries as l } from "../../blocks/ChartBlocks/BarchartBlock/utils.es.js";
1
+ import { DATE_FORMATS_INTL as h, formatDate as _ } from "../../../core/constants/DateFormats.es.js";
2
+ import { fromUnixUTC as p } from "../../../core/utils/DateUtil.es.js";
3
+ import { buildChartData as u, buildDataSeries as c } from "../../blocks/ChartBlocks/BarchartBlock/utils.es.js";
4
4
  import { buildComparisonSeries as D } from "../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js";
5
- import { DRILLDOWN_VARIANTS as u, FALLBACK as T, layout as b } from "./layout.es.js";
5
+ import { DRILLDOWN_VARIANTS as l, FALLBACK as T, layout as b } from "./layout.es.js";
6
6
  import { format as y, isValid as B, parseISO as m } from "date-fns";
7
- var M = (t) => b[t] ?? T, L = ({ data: t, ariaLabel: e, top: a, beatTransactions: o }) => {
7
+ var M = (t) => b[t] ?? T, E = ({ data: t, ariaLabel: e, top: a, beatTransactions: o }) => {
8
8
  if (a === "upcomingBill") {
9
- const r = A(o);
9
+ const r = v(o);
10
10
  return {
11
11
  dataSeries: r,
12
- chartData: c(r, e).map((n, d) => r[d].label ? {
12
+ chartData: u(r, e).map((n, d) => r[d].label ? {
13
13
  ...n,
14
14
  label: r[d].label
15
15
  } : n),
@@ -17,7 +17,7 @@ var M = (t) => b[t] ?? T, L = ({ data: t, ariaLabel: e, top: a, beatTransactions
17
17
  };
18
18
  }
19
19
  if (a === "tabsOnly") return {
20
- dataSeries: l(t).filter((r) => r.localized_label),
20
+ dataSeries: c(t).filter((r) => r.localized_label),
21
21
  chartData: [],
22
22
  comparisonBars: []
23
23
  };
@@ -26,7 +26,7 @@ var M = (t) => b[t] ?? T, L = ({ data: t, ariaLabel: e, top: a, beatTransactions
26
26
  chartData: [],
27
27
  comparisonBars: []
28
28
  };
29
- const i = [...l(t)].sort((r, n) => !r.date || !n.date ? 0 : new Date(r.date).getTime() - new Date(n.date).getTime());
29
+ const i = [...c(t)].sort((r, n) => !r.date || !n.date ? 0 : new Date(r.date).getTime() - new Date(n.date).getTime());
30
30
  switch (a) {
31
31
  case "doubleBar":
32
32
  return {
@@ -38,23 +38,23 @@ var M = (t) => b[t] ?? T, L = ({ data: t, ariaLabel: e, top: a, beatTransactions
38
38
  case "monthTabs":
39
39
  return {
40
40
  dataSeries: i,
41
- chartData: c(i, e),
41
+ chartData: u(i, e),
42
42
  comparisonBars: []
43
43
  };
44
44
  }
45
45
  }, S = "TRN-projected-bill", g = (t) => ({
46
- date: y(_(t.date), "yyyy-MM-dd"),
46
+ date: y(p(t.date), "yyyy-MM-dd"),
47
47
  amount: t.amount,
48
48
  guid: t.guid,
49
49
  category_guid: t.top_level_category_guid ?? t.category_guid
50
- }), v = (t) => {
50
+ }), A = (t) => {
51
51
  const e = t[t.length - 1];
52
52
  return e?.guid !== "TRN-projected-bill" ? { transactions: t } : {
53
53
  transactions: t.slice(0, -1),
54
54
  projectedTransaction: e
55
55
  };
56
- }, A = (t = []) => {
57
- const { transactions: e, projectedTransaction: a } = v(t);
56
+ }, v = (t = []) => {
57
+ const { transactions: e, projectedTransaction: a } = A(t);
58
58
  if (!a || !e.length) return [];
59
59
  const o = [...e].sort((s, f) => s.date - f.date), i = /* @__PURE__ */ new Set(), r = [];
60
60
  for (const s of o)
@@ -62,28 +62,28 @@ var M = (t) => b[t] ?? T, L = ({ data: t, ariaLabel: e, top: a, beatTransactions
62
62
  const n = [...r, g(a)], d = n.map((s) => s.date.slice(0, 7));
63
63
  return new Set(d).size === d.length ? n : n.map((s) => ({
64
64
  ...s,
65
- label: p(m(s.date), h.MONTH_DAY)
65
+ label: _(m(s.date), h.MONTH_DAY)
66
66
  }));
67
- }, U = (t = [], e) => {
67
+ }, L = (t = [], e) => {
68
68
  if (!(!t.length || e?.date == null || e?.amount == null))
69
69
  return {
70
70
  ...t.reduce((a, o) => o.date > a.date ? o : a),
71
71
  guid: S,
72
72
  amount: e.amount,
73
- date: x(e.date),
73
+ date: C(e.date),
74
74
  has_been_split: !1,
75
75
  is_hidden: !1,
76
76
  is_flagged: !1,
77
77
  parent_guid: null
78
78
  };
79
- }, j = (t, e, a) => {
79
+ }, U = (t, e, a) => {
80
80
  const o = e.insights_feed?.general?.transaction_history_title ?? "", i = e.insights_feed?.transaction_history_block;
81
- if (t === u.TRANSACTION) return o;
81
+ if (t === l.TRANSACTION) return o;
82
82
  const r = a?.insights_payload?.title;
83
- if (t === u.ACCOUNT_BALANCE && r) return r;
84
- const n = `${t}_drawer_title`;
83
+ if (t === l.ACCOUNT_BALANCE && r) return r;
84
+ const n = t === l.DEBT_TO_INCOME ? "monthly_debt_to_income_drawer_title" : `${t}_drawer_title`;
85
85
  return i?.[n] ?? o;
86
- }, E = (t, e) => ({
86
+ }, j = (t, e) => ({
87
87
  accounts: t.accounts ?? e.allAccountGuids,
88
88
  dateRange: t.dateRange ?? e.displayedDateRange,
89
89
  custom: t.custom ?? (() => !0),
@@ -97,8 +97,8 @@ var M = (t) => b[t] ?? T, L = ({ data: t, ariaLabel: e, top: a, beatTransactions
97
97
  chartBarIndex: Math.max(0, i - 1),
98
98
  subTabIndex: d
99
99
  };
100
- }, x = (t) => Date.parse(`${t}T00:00:00Z`) / 1e3, H = (t) => typeof t == "number" && Number.isFinite(t) ? t : void 0, G = (t) => typeof t == "string" && t.trim() !== "" ? t : void 0, P = (t) => Array.isArray(t) && t.length > 0 && t.every((e) => typeof e == "string" && e !== "") ? t : void 0, V = (t) => typeof t == "string" && /^\d{4}-\d{2}-\d{2}$/.test(t) && B(m(t)) ? t : void 0, $ = ({ series: t, category_guid: e, average_amount: a, additional_data: o }) => {
101
- const i = l(t).map(({ guid: r }) => r).filter((r) => !!r);
100
+ }, C = (t) => Date.parse(`${t}T00:00:00Z`) / 1e3, H = (t) => typeof t == "number" && Number.isFinite(t) ? t : void 0, G = (t) => typeof t == "string" && t.trim() !== "" ? t : void 0, P = (t) => Array.isArray(t) && t.length > 0 && t.every((e) => typeof e == "string" && e !== "") ? t : void 0, V = (t) => typeof t == "string" && /^\d{4}-\d{2}-\d{2}$/.test(t) && B(m(t)) ? t : void 0, $ = ({ series: t, category_guid: e, average_amount: a, additional_data: o }) => {
101
+ const i = c(t).map(({ guid: r }) => r).filter((r) => !!r);
102
102
  return {
103
103
  data_series: t,
104
104
  category_guid: e,
@@ -118,21 +118,21 @@ var M = (t) => b[t] ?? T, L = ({ data: t, ariaLabel: e, top: a, beatTransactions
118
118
  };
119
119
  export {
120
120
  S as PROJECTED_BILL_GUID,
121
- U as buildProjectedBillTransaction,
122
- A as buildUpcomingBillSeries,
121
+ L as buildProjectedBillTransaction,
122
+ v as buildUpcomingBillSeries,
123
123
  V as calendarDateOf,
124
124
  H as finiteNumberOf,
125
125
  F as getDefaultSelection,
126
- j as getDrawerHeaderTitle,
126
+ U as getDrawerHeaderTitle,
127
127
  M as getDrillDownConfig,
128
- L as getFlattenedDataSeries,
128
+ E as getFlattenedDataSeries,
129
129
  P as guidListOf,
130
130
  G as nonEmptyStringOf,
131
131
  k as resolveDrillDownSubHeader,
132
- v as splitProjectedTransaction,
132
+ A as splitProjectedTransaction,
133
133
  $ as toDrillDownSlotData,
134
- E as toStoreFilter,
135
- x as utcDayToUnix
134
+ j as toStoreFilter,
135
+ C as utcDayToUnix
136
136
  };
137
137
 
138
138
  //# sourceMappingURL=utils.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/utils.ts"],"sourcesContent":["import { format, isValid, parseISO } from 'date-fns'\n\nimport type {\n ActionDrawerState,\n Beat,\n DataSeries,\n DrilldownPayload,\n GlobalCopy,\n InsightsPayload,\n Subtitle,\n Transaction,\n} from '../../../core'\nimport type {\n BarChartBlockData,\n DataSet,\n InsightsInstanceSlotData,\n} from '../../../core/types/InsightsInstanceSlotData'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../core/constants'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport { fromUnixUTC } from '../../../core/utils/DateUtil'\nimport {\n buildChartData,\n buildDataSeries,\n type ChartDataSeriesItem,\n} from '../../blocks/ChartBlocks/BarchartBlock/utils'\nimport { buildComparisonSeries } from '../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils'\nimport {\n layout,\n FALLBACK,\n DRILLDOWN_VARIANTS,\n DrillDownVariant,\n DrillDownVariantConfig,\n} from './layout'\nimport { TransactionHistoryBlock } from '../../../core/types/localization/InsightsFeedCopy'\n\ninterface DefaultSelectionProp {\n chartTabCount: number\n comparisonTabCount: number\n actionDrawer: ActionDrawerState\n beatGuid: string\n}\nexport const getDrillDownConfig = (variant?: string): DrillDownVariantConfig =>\n layout[variant as DrillDownVariant] ?? FALLBACK\n\n// The shaped chart inputs a drill-down needs, derived once from the beat's data_series. `dataSeries`\n// is the flat per-bar source (indexes the filterStrategy); `chartData` feeds the single-bar chart;\n// `comparisonBars` feeds the double-bar chart and its month tabs (empty for every other top kind).\nexport interface FlattenedDataSeries {\n dataSeries: ChartDataSeriesItem[]\n chartData: ReturnType<typeof buildChartData>\n comparisonBars: DataSet[]\n}\n\n/**\n * Shapes the beat's raw data_series into the chart inputs for the variant's top kind: the single-bar\n * family (singleBar / upcomingBill), the double bar's month columns, or a tabs-only drawer's sides.\n */\ninterface FlattenedDataSeriesInput {\n data: DataSeries | undefined\n ariaLabel: string\n top: DrillDownVariantConfig['top']\n // UpcomingBill has no data_series; it builds its bars from these instead (its paid bills plus the\n // projected bill its `beatTransactions` resolver appends).\n beatTransactions: Transaction[]\n}\n\nexport const getFlattenedDataSeries = ({\n data,\n ariaLabel,\n top,\n beatTransactions,\n}: FlattenedDataSeriesInput): FlattenedDataSeries => {\n // UpcomingBill has no backend data_series: a bar per month of paid bills plus the projected bill,\n // each named by its month (buildChartData's default MONTH_SHORT) as the design labels it. A\n // projected bill sharing the latest paid month keeps its own day label.\n if (top === 'upcomingBill') {\n const dataSeries = buildUpcomingBillSeries(beatTransactions)\n const chartData = buildChartData(dataSeries, ariaLabel).map((bar, index) =>\n dataSeries[index].label ? { ...bar, label: dataSeries[index].label } : bar,\n )\n return { dataSeries, chartData, comparisonBars: [] }\n }\n\n // Tabs only: the rows are the sides of one month, not bars. They keep their wire order, which the\n // side tabs and the filter's dataSeries[subIndex] both index; there is no chart and no month tab.\n if (top === 'tabsOnly') {\n return {\n dataSeries: buildDataSeries(data).filter((row) => row.localized_label),\n chartData: [],\n comparisonBars: [],\n }\n }\n\n // List: one account over a window the strategy reads from the beat; no series, chart or tabs.\n if (top === 'list') {\n return { dataSeries: [], chartData: [], comparisonBars: [] }\n }\n\n // The month families: the backend sends data_series newest-first, so normalize it date-ascending\n // here. chartData/tabs and the filter's dataSeries[selectedIndex] indexing both read this one\n // array, so they stay aligned and the last tab is the most recent month.\n const dataSeries = [...buildDataSeries(data)].sort((a, b) => {\n if (!a.date || !b.date) return 0\n\n return new Date(a.date).getTime() - new Date(b.date).getTime()\n })\n\n switch (top) {\n // Double bar: comparison beats build paired month columns (with their guids) instead of chartData.\n case 'doubleBar':\n return { dataSeries, chartData: [], comparisonBars: buildComparisonSeries(data, ariaLabel) }\n // Single bar draws chartData as bars; month tabs reads the same chartData for its tabs only.\n case 'singleBar':\n case 'monthTabs':\n return { dataSeries, chartData: buildChartData(dataSeries, ariaLabel), comparisonBars: [] }\n }\n}\n\n// Sentinel guid for the synthesized projected bill. It intentionally matches no real store\n// transaction, so the projected tab lists only its Projected amount row.\nexport const PROJECTED_BILL_GUID = 'TRN-projected-bill'\n\n// One bar in the UpcomingBill chart. `date` is 'yyyy-MM-dd' so buildChartData/parseISO can read it.\n// `label` is set only when two bars share a month, so they are named by their day.\nexport interface UpcomingBillBar {\n date: string\n amount: number\n guid: string\n category_guid?: string\n label?: string\n}\n\n// The bill's UTC calendar day, the day the transaction list heads its row with\n// (fromUnixUTCToDayOfWeekAndDate); a local-time date put a UTC-midnight bill on the day before.\nconst toUpcomingBillBar = (transaction: Transaction): UpcomingBillBar => ({\n date: format(fromUnixUTC(transaction.date), 'yyyy-MM-dd'),\n amount: transaction.amount,\n guid: transaction.guid,\n category_guid: transaction.top_level_category_guid ?? transaction.category_guid,\n})\n\n/**\n * Splits a drawer's transactions into the real ones and the synthesized projected bill, which a\n * `beatTransactions` resolver (Upcoming Bill's) appends last under PROJECTED_BILL_GUID. Every other\n * variant has no projected bill, so its transactions pass through untouched.\n */\nexport const splitProjectedTransaction = (\n transactions: Transaction[],\n): { transactions: Transaction[]; projectedTransaction?: Transaction } => {\n const last = transactions[transactions.length - 1]\n if (last?.guid !== PROJECTED_BILL_GUID) return { transactions }\n\n return { transactions: transactions.slice(0, -1), projectedTransaction: last }\n}\n\n/**\n * UpcomingBill has no data_series: build the bar series from the drawer's transactions, its paid\n * bills plus the projected bill last (mirrors pulse's magicTransactions). Paid bills are sorted and\n * de-duped by date, each keeping its real guid so the guid filter finds it; the projected bar keeps\n * the PROJECTED_BILL_GUID sentinel and lands last. No projected bill (a missing due date or amount),\n * no bars. Bars are named by month; when two share a month, every bar is named by its day so no two\n * tabs read the same.\n */\nexport const buildUpcomingBillSeries = (transactions: Transaction[] = []): UpcomingBillBar[] => {\n const { transactions: paidBills, projectedTransaction } = splitProjectedTransaction(transactions)\n if (!projectedTransaction || !paidBills.length) return []\n\n const sorted = [...paidBills].sort((a, b) => a.date - b.date)\n\n const seenDates = new Set<number>()\n const history: UpcomingBillBar[] = []\n for (const transaction of sorted) {\n if (seenDates.has(transaction.date)) continue\n seenDates.add(transaction.date)\n history.push(toUpcomingBillBar(transaction))\n }\n\n const bars = [...history, toUpcomingBillBar(projectedTransaction)]\n\n const months = bars.map((bar) => bar.date.slice(0, 7))\n if (new Set(months).size === months.length) return bars\n\n return bars.map((bar) => ({\n ...bar,\n label: formatDate(parseISO(bar.date), DATE_FORMATS_INTL.MONTH_DAY),\n }))\n}\n\n/**\n * The transaction behind UpcomingBill's projected bar, as legacy pulse's drawer lists it under\n * \"Projected amount\": the latest paid bill's merchant and category with the due date and projected\n * amount, on the PROJECTED_BILL_GUID sentinel. Its split / hidden / flagged state is cleared so the\n * inert row never shows the paid bill's badges. Undefined without paid bills, a due date or amount.\n */\nexport const buildProjectedBillTransaction = (\n transactions: Transaction[] = [],\n payload: { date?: string; amount?: number } | undefined,\n): Transaction | undefined => {\n if (!transactions.length || payload?.date == null || payload?.amount == null) return undefined\n\n const latestBill = transactions.reduce((latest, t) => (t.date > latest.date ? t : latest))\n\n return {\n ...latestBill,\n guid: PROJECTED_BILL_GUID,\n amount: payload.amount,\n date: utcDayToUnix(payload.date),\n has_been_split: false,\n is_hidden: false,\n is_flagged: false,\n parent_guid: null,\n }\n}\n\nexport const getDrawerHeaderTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\n beat?: Beat,\n): string => {\n const transactionHistoryTitle = copy.insights_feed?.general?.transaction_history_title ?? ''\n const drawerTitleCopy = copy.insights_feed?.transaction_history_block as TransactionHistoryBlock\n\n if (variant === DRILLDOWN_VARIANTS.TRANSACTION) return transactionHistoryTitle\n\n // Savings Account Balances Summary: the drawer reads as the card it opens from (\"Savings\n // Contributions\", Figma 1135:50175), whatever the host's drawer copy says.\n const beatTitle = beat?.insights_payload?.title\n if (variant === DRILLDOWN_VARIANTS.ACCOUNT_BALANCE && beatTitle) return beatTitle\n\n // Safely access the drawer title from transaction_history_block\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'> & {\n merchant_name?: string\n // Monthly Deposit Summary: the deposits on the Income sub-tab, across every month.\n income_transaction_guids?: string[]\n // A drawer's own sub-tab names when the card's legend rows aren't the chart's (Income / Other Deposits).\n sub_tab_labels?: string[]\n }\n\n// A YYYY-MM-DD day as the epoch seconds of its UTC midnight: the day a transaction row is dated on\n// (fromUnixUTCToDayOfWeekAndDate), so a synthesized row agrees with the bars in every zone.\nexport const utcDayToUnix = (day: string): number => Date.parse(`${day}T00:00:00Z`) / 1000\n\n// Narrowing for drilldown_data's untyped values: each returns the value when it has the right shape,\n// else undefined, so a reader drops a missing or mistyped fact.\nexport const finiteNumberOf = (value: unknown): number | undefined =>\n typeof value === 'number' && Number.isFinite(value) ? value : undefined\n\nexport const nonEmptyStringOf = (value: unknown): string | undefined =>\n typeof value === 'string' && value.trim() !== '' ? value : undefined\n\nexport const guidListOf = (value: unknown): string[] | undefined =>\n Array.isArray(value) &&\n value.length > 0 &&\n value.every((item) => typeof item === 'string' && item !== '')\n ? (value as string[])\n : undefined\n\n// parseISO rejects impossible days such as 2026-02-30.\nexport const calendarDateOf = (value: unknown): string | undefined =>\n typeof value === 'string' && /^\\d{4}-\\d{2}-\\d{2}$/.test(value) && isValid(parseISO(value))\n ? value\n : undefined\n\n/** 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":";;;;;;AAyCA,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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K,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
+ {"version":3,"file":"utils.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/utils.ts"],"sourcesContent":["import { format, isValid, parseISO } from 'date-fns'\n\nimport type {\n ActionDrawerState,\n Beat,\n DataSeries,\n DrilldownPayload,\n DrilldownData,\n GlobalCopy,\n InsightsPayload,\n Subtitle,\n Transaction,\n} from '../../../core'\nimport type {\n BarChartBlockData,\n DataSet,\n InsightsInstanceSlotData,\n} from '../../../core/types/InsightsInstanceSlotData'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../core/constants'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport { fromUnixUTC } from '../../../core/utils/DateUtil'\nimport {\n buildChartData,\n buildDataSeries,\n type ChartDataSeriesItem,\n} from '../../blocks/ChartBlocks/BarchartBlock/utils'\nimport { buildComparisonSeries } from '../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils'\nimport {\n layout,\n FALLBACK,\n DRILLDOWN_VARIANTS,\n DrillDownVariant,\n DrillDownVariantConfig,\n} from './layout'\nimport { TransactionHistoryBlock } from '../../../core/types/localization/InsightsFeedCopy'\n\ninterface DefaultSelectionProp {\n chartTabCount: number\n comparisonTabCount: number\n actionDrawer: ActionDrawerState\n beatGuid: string\n}\nexport const getDrillDownConfig = (variant?: string): DrillDownVariantConfig =>\n layout[variant as DrillDownVariant] ?? FALLBACK\n\n// The shaped chart inputs a drill-down needs, derived once from the beat's data_series. `dataSeries`\n// is the flat per-bar source (indexes the filterStrategy); `chartData` feeds the single-bar chart;\n// `comparisonBars` feeds the double-bar chart and its month tabs (empty for every other top kind).\nexport interface FlattenedDataSeries {\n dataSeries: ChartDataSeriesItem[]\n chartData: ReturnType<typeof buildChartData>\n comparisonBars: DataSet[]\n}\n\n/**\n * Shapes the beat's raw data_series into the chart inputs for the variant's top kind: the single-bar\n * family (singleBar / upcomingBill), the double bar's month columns, or a tabs-only drawer's sides.\n */\ninterface FlattenedDataSeriesInput {\n data: DataSeries | undefined\n ariaLabel: string\n top: DrillDownVariantConfig['top']\n // UpcomingBill has no data_series; it builds its bars from these instead (its paid bills plus the\n // projected bill its `beatTransactions` resolver appends).\n beatTransactions: Transaction[]\n}\n\nexport const getFlattenedDataSeries = ({\n data,\n ariaLabel,\n top,\n beatTransactions,\n}: FlattenedDataSeriesInput): FlattenedDataSeries => {\n // UpcomingBill has no backend data_series: a bar per month of paid bills plus the projected bill,\n // each named by its month (buildChartData's default MONTH_SHORT) as the design labels it. A\n // projected bill sharing the latest paid month keeps its own day label.\n if (top === 'upcomingBill') {\n const dataSeries = buildUpcomingBillSeries(beatTransactions)\n const chartData = buildChartData(dataSeries, ariaLabel).map((bar, index) =>\n dataSeries[index].label ? { ...bar, label: dataSeries[index].label } : bar,\n )\n return { dataSeries, chartData, comparisonBars: [] }\n }\n\n // Tabs only: the rows are the sides of one month, not bars. They keep their wire order, which the\n // side tabs and the filter's dataSeries[subIndex] both index; there is no chart and no month tab.\n if (top === 'tabsOnly') {\n return {\n dataSeries: buildDataSeries(data).filter((row) => row.localized_label),\n chartData: [],\n comparisonBars: [],\n }\n }\n\n // List: one account over a window the strategy reads from the beat; no series, chart or tabs.\n if (top === 'list') {\n return { dataSeries: [], chartData: [], comparisonBars: [] }\n }\n\n // The month families: the backend sends data_series newest-first, so normalize it date-ascending\n // here. chartData/tabs and the filter's dataSeries[selectedIndex] indexing both read this one\n // array, so they stay aligned and the last tab is the most recent month.\n const dataSeries = [...buildDataSeries(data)].sort((a, b) => {\n if (!a.date || !b.date) return 0\n\n return new Date(a.date).getTime() - new Date(b.date).getTime()\n })\n\n switch (top) {\n // Double bar: comparison beats build paired month columns (with their guids) instead of chartData.\n case 'doubleBar':\n return { dataSeries, chartData: [], comparisonBars: buildComparisonSeries(data, ariaLabel) }\n // Single bar draws chartData as bars; month tabs reads the same chartData for its tabs only.\n case 'singleBar':\n case 'monthTabs':\n return { dataSeries, chartData: buildChartData(dataSeries, ariaLabel), comparisonBars: [] }\n }\n}\n\n// Sentinel guid for the synthesized projected bill. It intentionally matches no real store\n// transaction, so the projected tab lists only its Projected amount row.\nexport const PROJECTED_BILL_GUID = 'TRN-projected-bill'\n\n// One bar in the UpcomingBill chart. `date` is 'yyyy-MM-dd' so buildChartData/parseISO can read it.\n// `label` is set only when two bars share a month, so they are named by their day.\nexport interface UpcomingBillBar {\n date: string\n amount: number\n guid: string\n category_guid?: string\n label?: string\n}\n\n// The bill's UTC calendar day, the day the transaction list heads its row with\n// (fromUnixUTCToDayOfWeekAndDate); a local-time date put a UTC-midnight bill on the day before.\nconst toUpcomingBillBar = (transaction: Transaction): UpcomingBillBar => ({\n date: format(fromUnixUTC(transaction.date), 'yyyy-MM-dd'),\n amount: transaction.amount,\n guid: transaction.guid,\n category_guid: transaction.top_level_category_guid ?? transaction.category_guid,\n})\n\n/**\n * Splits a drawer's transactions into the real ones and the synthesized projected bill, which a\n * `beatTransactions` resolver (Upcoming Bill's) appends last under PROJECTED_BILL_GUID. Every other\n * variant has no projected bill, so its transactions pass through untouched.\n */\nexport const splitProjectedTransaction = (\n transactions: Transaction[],\n): { transactions: Transaction[]; projectedTransaction?: Transaction } => {\n const last = transactions[transactions.length - 1]\n if (last?.guid !== PROJECTED_BILL_GUID) return { transactions }\n\n return { transactions: transactions.slice(0, -1), projectedTransaction: last }\n}\n\n/**\n * UpcomingBill has no data_series: build the bar series from the drawer's transactions, its paid\n * bills plus the projected bill last (mirrors pulse's magicTransactions). Paid bills are sorted and\n * de-duped by date, each keeping its real guid so the guid filter finds it; the projected bar keeps\n * the PROJECTED_BILL_GUID sentinel and lands last. No projected bill (a missing due date or amount),\n * no bars. Bars are named by month; when two share a month, every bar is named by its day so no two\n * tabs read the same.\n */\nexport const buildUpcomingBillSeries = (transactions: Transaction[] = []): UpcomingBillBar[] => {\n const { transactions: paidBills, projectedTransaction } = splitProjectedTransaction(transactions)\n if (!projectedTransaction || !paidBills.length) return []\n\n const sorted = [...paidBills].sort((a, b) => a.date - b.date)\n\n const seenDates = new Set<number>()\n const history: UpcomingBillBar[] = []\n for (const transaction of sorted) {\n if (seenDates.has(transaction.date)) continue\n seenDates.add(transaction.date)\n history.push(toUpcomingBillBar(transaction))\n }\n\n const bars = [...history, toUpcomingBillBar(projectedTransaction)]\n\n const months = bars.map((bar) => bar.date.slice(0, 7))\n if (new Set(months).size === months.length) return bars\n\n return bars.map((bar) => ({\n ...bar,\n label: formatDate(parseISO(bar.date), DATE_FORMATS_INTL.MONTH_DAY),\n }))\n}\n\n/**\n * The transaction behind UpcomingBill's projected bar, as legacy pulse's drawer lists it under\n * \"Projected amount\": the latest paid bill's merchant and category with the due date and projected\n * amount, on the PROJECTED_BILL_GUID sentinel. Its split / hidden / flagged state is cleared so the\n * inert row never shows the paid bill's badges. Undefined without paid bills, a due date or amount.\n */\nexport const buildProjectedBillTransaction = (\n transactions: Transaction[] = [],\n payload: { date?: string; amount?: number } | undefined,\n): Transaction | undefined => {\n if (!transactions.length || payload?.date == null || payload?.amount == null) return undefined\n\n const latestBill = transactions.reduce((latest, t) => (t.date > latest.date ? t : latest))\n\n return {\n ...latestBill,\n guid: PROJECTED_BILL_GUID,\n amount: payload.amount,\n date: utcDayToUnix(payload.date),\n has_been_split: false,\n is_hidden: false,\n is_flagged: false,\n parent_guid: null,\n }\n}\n\nexport const getDrawerHeaderTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\n beat?: Beat,\n): string => {\n const transactionHistoryTitle = copy.insights_feed?.general?.transaction_history_title ?? ''\n const drawerTitleCopy = copy.insights_feed?.transaction_history_block as TransactionHistoryBlock\n\n if (variant === DRILLDOWN_VARIANTS.TRANSACTION) return transactionHistoryTitle\n\n // Savings Account Balances Summary: the drawer reads as the card it opens from (\"Savings\n // Contributions\", Figma 1135:50175), whatever the host's drawer copy says.\n const beatTitle = beat?.insights_payload?.title\n if (variant === DRILLDOWN_VARIANTS.ACCOUNT_BALANCE && beatTitle) return beatTitle\n\n // Safely access the drawer title from transaction_history_block. Debt to Income's ditto variant\n // (debt_to_income) keeps the host copy's existing monthly_debt_to_income_drawer_title.\n const key = (\n variant === DRILLDOWN_VARIANTS.DEBT_TO_INCOME\n ? 'monthly_debt_to_income_drawer_title'\n : `${variant}_drawer_title`\n ) as keyof TransactionHistoryBlock\n return (drawerTitleCopy?.[key] as string) ?? transactionHistoryTitle\n}\n\nexport const toStoreFilter = (\n filter: TransactionFilter,\n defaults: { allAccountGuids: string[]; displayedDateRange: { start: Date; end: Date } },\n): TransactionFilter => ({\n accounts: filter.accounts ?? defaults.allAccountGuids,\n dateRange: filter.dateRange ?? defaults.displayedDateRange,\n custom: filter.custom ?? (() => true),\n showSplits: filter.showSplits ?? false,\n})\n\nexport const getDefaultSelection = ({\n chartTabCount,\n comparisonTabCount,\n actionDrawer,\n beatGuid,\n}: DefaultSelectionProp): { chartBarIndex: number; subTabIndex: number } => {\n // A double-bar drawer's tabs are its comparison columns; every other drawer's are its chart bars.\n const tabCount = comparisonTabCount || chartTabCount\n const openedViaChartBar = actionDrawer.guid === beatGuid && actionDrawer.trigger === 'chartBar'\n\n // actionDrawer.context is an opaque `unknown` bag; narrow it to the shape the chart blocks write.\n const context = actionDrawer.context as DrilldownPayload | undefined\n const subTabIndex = openedViaChartBar ? (context?.tabIndex ?? 0) : 0\n\n if (openedViaChartBar) {\n const clamped = Math.min(Math.max(context?.chartBarIndex ?? 0, 0), Math.max(0, tabCount - 1))\n return { chartBarIndex: clamped, subTabIndex }\n }\n\n return { chartBarIndex: Math.max(0, tabCount - 1), subTabIndex }\n}\n\n/**\n * The drawer's facts: the generic slot facts plus the bar chart's average, and the merchant a\n * variant's tip names.\n */\nexport type DrillDownSlotData = InsightsInstanceSlotData &\n Pick<BarChartBlockData, 'average_amount'> & {\n merchant_name?: string\n // Monthly Deposit Summary: the deposits on the Income sub-tab, across every month.\n income_transaction_guids?: string[]\n // A drawer's own sub-tab names when the card's legend rows aren't the chart's (Income / Other Deposits).\n sub_tab_labels?: string[]\n }\n\n// A YYYY-MM-DD day as the epoch seconds of its UTC midnight: the day a transaction row is dated on\n// (fromUnixUTCToDayOfWeekAndDate), so a synthesized row agrees with the bars in every zone.\nexport const utcDayToUnix = (day: string): number => Date.parse(`${day}T00:00:00Z`) / 1000\n\n// Narrowing for drilldown_data's untyped values: each returns the value when it has the right shape,\n// else undefined, so a reader drops a missing or mistyped fact.\nexport const finiteNumberOf = (value: unknown): number | undefined =>\n typeof value === 'number' && Number.isFinite(value) ? value : undefined\n\nexport const nonEmptyStringOf = (value: unknown): string | undefined =>\n typeof value === 'string' && value.trim() !== '' ? value : undefined\n\nexport const guidListOf = (value: unknown): string[] | undefined =>\n Array.isArray(value) &&\n value.length > 0 &&\n value.every((item) => typeof item === 'string' && item !== '')\n ? (value as string[])\n : undefined\n\n// parseISO rejects impossible days such as 2026-02-30.\nexport const calendarDateOf = (value: unknown): string | undefined =>\n typeof value === 'string' && /^\\d{4}-\\d{2}-\\d{2}$/.test(value) && isValid(parseISO(value))\n ? value\n : undefined\n\n/**\n * Resolves the drawer's facts (bars, guids, colour, average, tip values) from the beat's payload, or\n * from the drilldown_data of the CTA that opened the drawer (`ctaDrilldownData`).\n */\nexport type SlotDataResolver = (\n payload: Partial<InsightsPayload> | undefined,\n ctaDrilldownData?: DrilldownData,\n) => DrillDownSlotData\n\n/**\n * Builds the drawer's transactions from the beat's own (its `transaction_guids` in the store) and\n * its facts, e.g. Upcoming Bill appends its projected bill. Absent: the beat's own, as they are.\n */\nexport type BeatTransactionsResolver = (\n transactions: Transaction[],\n slotData: DrillDownSlotData,\n) => Transaction[]\n\n/** The drawer's facts from a bar chart's `instance_slot.data` (variants with no `slotData`). */\nexport const toDrillDownSlotData = ({\n series,\n category_guid,\n average_amount,\n additional_data,\n}: BarChartBlockData): DrillDownSlotData => {\n const transactionGuids = buildDataSeries(series)\n .map(({ guid }) => guid)\n .filter((guid): guid is string => !!guid)\n\n return {\n data_series: series,\n category_guid,\n average_amount,\n legends: additional_data,\n transaction_guids: transactionGuids.length ? transactionGuids : undefined,\n }\n}\n\n/** The drawer's sub-heading: the merchant name and logo. */\nexport const resolveDrillDownSubHeader = (\n payload: Partial<InsightsPayload> | undefined,\n): Subtitle | undefined => {\n if (!payload) return undefined\n\n return {\n text: payload.subtitle ?? '',\n logo: { merchant_guid: payload.logo?.guid, category_guid: '' },\n }\n}\n"],"mappings":";;;;;;AA0CA,IAAa,IAAA,CAAsB,MACjC,EAAO,CAAA,KAAgC,GAwB5B,IAAA,CAA0B,EACrC,MAAA,GACA,WAAA,GACA,KAAA,GACA,kBAAA,EAAA,MACmD;AAInD,MAAI,MAAQ,gBAAgB;AAC1B,UAAM,IAAa,EAAwB,CAAgB;AAI3D,WAAO;AAAA,MAAE,YAAA;AAAA,MAAY,WAHH,EAAe,GAAY,CAAS,EAAE,IAAA,CAAK,GAAK,MAChE,EAAW,CAAA,EAAO,QAAQ;AAAA,QAAE,GAAG;AAAA,QAAK,OAAO,EAAW,CAAA,EAAO;AAAA,MAAM,IAAI,CAEpD;AAAA,MAAW,gBAAgB,CAAC;AAAA,IAAE;AAAA,EACrD;AAIA,M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,IACA,QAqBO,IAAA,CAAuB,EAClC,QAAA,GACA,eAAA,GACA,gBAAA,GACA,iBAAA,EAAA,MAC0C;AAC1C,QAAM,IAAmB,EAAgB,CAAM,EAC5C,IAAA,CAAK,EAAE,MAAA,EAAA,MAAW,CAAI,EACtB,OAAA,CAAQ,MAAyB,CAAC,CAAC,CAAI;AAE1C,SAAO;AAAA,IACL,aAAa;AAAA,IACb,eAAA;AAAA,IACA,gBAAA;AAAA,IACA,SAAS;AAAA,IACT,mBAAmB,EAAiB,SAAS,IAAmB;AAAA,EAClE;AACF,GAGa,IAAA,CACX,MACyB;AACzB,MAAK;AAEL,WAAO;AAAA,MACL,MAAM,EAAQ,YAAY;AAAA,MAC1B,MAAM;AAAA,QAAE,eAAe,EAAQ,MAAM;AAAA,QAAM,eAAe;AAAA,MAAG;AAAA,IAC/D;AACF"}
@@ -2,7 +2,7 @@ var a = (o) => ({ color: [o.palette.categories.billsUtilities, o.palette.chart.c
2
2
  const c = {
3
3
  SpendToIncome: a(o),
4
4
  spend_to_income: a(o),
5
- DebtToIncome: { color: [o.palette.chart.chart5, o.palette.chart.chart1] },
5
+ debt_to_income: { color: [o.palette.chart.chart5, o.palette.chart.chart1] },
6
6
  SavingsToIncome: { color: [o.palette.chartMono.chartMono5, o.palette.chartMono.chartMono3] }
7
7
  };
8
8
  return t && Object.hasOwn(c, t) ? c[t] : void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.ts"],"sourcesContent":["import type { Theme } from '@mui/material/styles'\n\n// One palette per comparison; ditto's snake_case variant shares the legacy PascalCase entry's palette.\nconst spendToIncome = (theme: Theme) => ({\n color: [theme.palette.categories.billsUtilities, theme.palette.chart.chart1] as string[],\n})\n\nexport const getLayoutConfig = (theme: Theme, variant?: string | null) => {\n const config = {\n SpendToIncome: spendToIncome(theme),\n // Insights 2.0: ditto's layout variant for Monthly Spend to Income Comparison.\n spend_to_income: spendToIncome(theme),\n DebtToIncome: {\n color: [theme.palette.chart.chart5, theme.palette.chart.chart1] as string[],\n },\n SavingsToIncome: {\n color: [theme.palette.chartMono.chartMono5, theme.palette.chartMono.chartMono3] as string[],\n },\n }\n // Object.hasOwn: the variant is backend-controlled, and an inherited name like `constructor`\n // would otherwise return a truthy non-config.\n return variant && Object.hasOwn(config, variant)\n ? config[variant as keyof typeof config]\n : undefined\n}\n"],"mappings":"AAGA,IAAM,IAAA,CAAiB,OAAkB,EACvC,OAAO,CAAC,EAAM,QAAQ,WAAW,gBAAgB,EAAM,QAAQ,MAAM,MAAM,EAC7E,IAEa,IAAA,CAAmB,GAAc,MAA4B;AACxE,QAAM,IAAS;AAAA,IACb,eAAe,EAAc,CAAK;AAAA,IAElC,iBAAiB,EAAc,CAAK;AAAA,IACpC,cAAc,EACZ,OAAO,CAAC,EAAM,QAAQ,MAAM,QAAQ,EAAM,QAAQ,MAAM,MAAM,EAChE;AAAA,IACA,iBAAiB,EACf,OAAO,CAAC,EAAM,QAAQ,UAAU,YAAY,EAAM,QAAQ,UAAU,UAAU,EAChF;AAAA,EACF;AAGA,SAAO,KAAW,OAAO,OAAO,GAAQ,CAAO,IAC3C,EAAO,CAAA,IACP;AACN"}
1
+ {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.ts"],"sourcesContent":["import type { Theme } from '@mui/material/styles'\n\n// One palette per comparison; ditto's snake_case variant shares the legacy PascalCase entry's palette.\nconst spendToIncome = (theme: Theme) => ({\n color: [theme.palette.categories.billsUtilities, theme.palette.chart.chart1] as string[],\n})\n\nexport const getLayoutConfig = (theme: Theme, variant?: string | null) => {\n const config = {\n SpendToIncome: spendToIncome(theme),\n // Insights 2.0: ditto's layout variant for Monthly Spend to Income Comparison.\n spend_to_income: spendToIncome(theme),\n // Insights 2.0: ditto's layout variant for Monthly Debt to Income Comparison. Debt (main) chart5,\n // Income chart1 (Figma 1117:8564); the card and its drawer both read it.\n debt_to_income: {\n color: [theme.palette.chart.chart5, theme.palette.chart.chart1] as string[],\n },\n SavingsToIncome: {\n color: [theme.palette.chartMono.chartMono5, theme.palette.chartMono.chartMono3] as string[],\n },\n }\n // Object.hasOwn: the variant is backend-controlled, and an inherited name like `constructor`\n // would otherwise return a truthy non-config.\n return variant && Object.hasOwn(config, variant)\n ? config[variant as keyof typeof config]\n : undefined\n}\n"],"mappings":"AAGA,IAAM,IAAA,CAAiB,OAAkB,EACvC,OAAO,CAAC,EAAM,QAAQ,WAAW,gBAAgB,EAAM,QAAQ,MAAM,MAAM,EAC7E,IAEa,IAAA,CAAmB,GAAc,MAA4B;AACxE,QAAM,IAAS;AAAA,IACb,eAAe,EAAc,CAAK;AAAA,IAElC,iBAAiB,EAAc,CAAK;AAAA,IAGpC,gBAAgB,EACd,OAAO,CAAC,EAAM,QAAQ,MAAM,QAAQ,EAAM,QAAQ,MAAM,MAAM,EAChE;AAAA,IACA,iBAAiB,EACf,OAAO,CAAC,EAAM,QAAQ,UAAU,YAAY,EAAM,QAAQ,UAAU,UAAU,EAChF;AAAA,EACF;AAGA,SAAO,KAAW,OAAO,OAAO,GAAQ,CAAO,IAC3C,EAAO,CAAA,IACP;AACN"}
@@ -3,7 +3,7 @@ import { WidgetContainer as s } from "../common/components/WidgetContainer.es.js
3
3
  import { NotificationSettings as e } from "./components/notifications/NotificationSettings.es.js";
4
4
  import { observer as a } from "mobx-react-lite";
5
5
  import n from "@mui/material/Stack";
6
- import { ChevronLeft as f } from "@mxenabled/mx-icons";
6
+ import { ArrowBackIosNew as f } from "@mxenabled/mx-icons";
7
7
  import { jsx as o, jsxs as l } from "react/jsx-runtime";
8
8
  import p from "@mui/material/IconButton";
9
9
  var x = a((t) => {
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationSettingsWidget.es.js","names":[],"sources":["../../src/settings/NotificationSettingsWidget.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport IconButton from '@mui/material/IconButton'\nimport Stack from '@mui/material/Stack'\n\nimport { ChevronLeft } from '@mxenabled/mx-icons'\n\nimport { useAppConfig, WidgetContainer } from '../common'\nimport { WidgetProps } from '../core'\n\nimport { NotificationSettings } from './components/notifications/NotificationSettings'\n\nexport const NotificationSettingsWidget = observer((props: WidgetProps) => {\n const { clientConfig } = useAppConfig()\n\n const view = clientConfig?.master?.deep_link_params?.view\n const showBackButton = clientConfig?.master?.show_back_button\n\n if (view) {\n return (\n <Stack>\n {showBackButton && props.onBackClick && (\n <IconButton\n color=\"primary\"\n onClick={props.onBackClick}\n sx={{ p: 10, alignSelf: 'flex-start' }}\n >\n <ChevronLeft size={24} />\n </IconButton>\n )}\n <NotificationSettings view={view} />\n </Stack>\n )\n }\n\n return (\n <WidgetContainer {...props} showAccountFilter={false}>\n <Stack my={24}>\n <NotificationSettings />\n </Stack>\n </WidgetContainer>\n )\n})\n"],"mappings":";;;;;;;;AAYA,IAAa,IAA6B,EAAA,CAAU,MAAuB;AACzE,QAAM,EAAE,cAAA,EAAA,IAAiB,EAAa,GAEhC,IAAO,GAAc,QAAQ,kBAAkB,MAC/C,IAAiB,GAAc,QAAQ;AAE7C,SAAI,IAEA,gBAAA,EAAC,GAAD,EAAA,UAAA,CACG,KAAkB,EAAM,eACvB,gBAAA,EAAC,GAAD;AAAA,IACE,OAAM;AAAA,IACN,SAAS,EAAM;AAAA,IACf,IAAI;AAAA,MAAE,GAAG;AAAA,MAAI,WAAW;AAAA,IAAa;AAAA,IAErC,UAAA,gBAAA,EAAC,GAAD,EAAa,MAAM,GAAK,CAAA;AAAA,EACd,CAAA,GAEd,gBAAA,EAAC,GAAD,EAA4B,MAAA,EAAO,CAAA,CAC9B,EAAA,CAAA,IAKT,gBAAA,EAAC,GAAD;AAAA,IAAiB,GAAI;AAAA,IAAO,mBAAmB;AAAA,IAC7C,UAAA,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,MACT,UAAA,gBAAA,EAAC,GAAD,CAAuB,CAAA;AAAA,IAClB,CAAA;AAAA,EACQ,CAAA;AAErB,CAAC"}
1
+ {"version":3,"file":"NotificationSettingsWidget.es.js","names":[],"sources":["../../src/settings/NotificationSettingsWidget.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport IconButton from '@mui/material/IconButton'\nimport Stack from '@mui/material/Stack'\n\nimport { ArrowBackIosNew } from '@mxenabled/mx-icons'\n\nimport { useAppConfig, WidgetContainer } from '../common'\nimport { WidgetProps } from '../core'\n\nimport { NotificationSettings } from './components/notifications/NotificationSettings'\n\nexport const NotificationSettingsWidget = observer((props: WidgetProps) => {\n const { clientConfig } = useAppConfig()\n\n const view = clientConfig?.master?.deep_link_params?.view\n const showBackButton = clientConfig?.master?.show_back_button\n\n if (view) {\n return (\n <Stack>\n {showBackButton && props.onBackClick && (\n <IconButton\n color=\"primary\"\n onClick={props.onBackClick}\n sx={{ p: 10, alignSelf: 'flex-start' }}\n >\n <ArrowBackIosNew size={24} />\n </IconButton>\n )}\n <NotificationSettings view={view} />\n </Stack>\n )\n }\n\n return (\n <WidgetContainer {...props} showAccountFilter={false}>\n <Stack my={24}>\n <NotificationSettings />\n </Stack>\n </WidgetContainer>\n )\n})\n"],"mappings":";;;;;;;;AAYA,IAAa,IAA6B,EAAA,CAAU,MAAuB;AACzE,QAAM,EAAE,cAAA,EAAA,IAAiB,EAAa,GAEhC,IAAO,GAAc,QAAQ,kBAAkB,MAC/C,IAAiB,GAAc,QAAQ;AAE7C,SAAI,IAEA,gBAAA,EAAC,GAAD,EAAA,UAAA,CACG,KAAkB,EAAM,eACvB,gBAAA,EAAC,GAAD;AAAA,IACE,OAAM;AAAA,IACN,SAAS,EAAM;AAAA,IACf,IAAI;AAAA,MAAE,GAAG;AAAA,MAAI,WAAW;AAAA,IAAa;AAAA,IAErC,UAAA,gBAAA,EAAC,GAAD,EAAiB,MAAM,GAAK,CAAA;AAAA,EAClB,CAAA,GAEd,gBAAA,EAAC,GAAD,EAA4B,MAAA,EAAO,CAAA,CAC9B,EAAA,CAAA,IAKT,gBAAA,EAAC,GAAD;AAAA,IAAiB,GAAI;AAAA,IAAO,mBAAmB;AAAA,IAC7C,UAAA,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,MACT,UAAA,gBAAA,EAAC,GAAD,CAAuB,CAAA;AAAA,IAClB,CAAA;AAAA,EACQ,CAAA;AAErB,CAAC"}
@@ -9,20 +9,20 @@ import { getTopLevelCategoryTotals as ge, isExpense as ue, isIncome as Te } from
9
9
  import { TRENDS_ANALYTICS_METADATA as pe } from "./constants/TrendsWidget.es.js";
10
10
  import { StackedLineChart as De } from "../common/components/charts/StackedLineChart.es.js";
11
11
  import Ce from "./components/TrendsViewToggle.es.js";
12
- import Se from "./components/DateRangeText.es.js";
13
- import _e from "./components/TrendsTableContainer.es.js";
12
+ import _e from "./components/DateRangeText.es.js";
13
+ import Se from "./components/TrendsTableContainer.es.js";
14
14
  import Ee from "./components/TrendsDrawer.es.js";
15
15
  import s from "react";
16
16
  import { observer as he } from "mobx-react-lite";
17
17
  import D from "@mui/material/Stack";
18
- import { Icon as Le } from "@mxenabled/mxui";
18
+ import { Icon as we } from "@mxenabled/mxui";
19
19
  import h from "@mui/material/Button";
20
20
  import { jsx as o, jsxs as c } from "react/jsx-runtime";
21
- import L from "@mui/material/Box";
22
- import { differenceInCalendarMonths as w } from "date-fns/differenceInCalendarMonths";
23
- import { addSeconds as we } from "date-fns/addSeconds";
21
+ import w from "@mui/material/Box";
22
+ import { differenceInCalendarMonths as L } from "date-fns/differenceInCalendarMonths";
23
+ import { addSeconds as Le } from "date-fns/addSeconds";
24
24
  var Re = ({ onBackClick: R, onMenuClick: y, sx: I }) => {
25
- const { onEvent: a } = ae(), { isDesktop: k, isTablet: v, isMobile: f } = ce(), { isAccountDataLoaded: l, loadAccountData: A } = te(), { categoriesLoaded: N, loadCategories: b, monthlyCategoryTotals: C, getCategoryName: S, reloadCategoryTotals: x } = oe(), { isTransactionDataLoaded: H, loadTransactionData: G, sortedTransactions: W } = se(), { selectedDateRange: t, setSelectedDateRange: O } = ie(), { isInitialized: g, selectedAccounts: V, selectedAccountGuids: z } = ne(), { trends: u } = re(), [T, M] = s.useState(!1), [F, _] = s.useState(!1), [m, j] = s.useState("Chart"), [r, p] = s.useState(""), [K, $] = s.useState(window.innerHeight), B = K - (f ? 315 : 345);
25
+ const { onEvent: a } = ae(), { isDesktop: k, isTablet: v, isMobile: f } = ce(), { isAccountDataLoaded: l, loadAccountData: A } = te(), { categoriesLoaded: N, loadCategories: b, monthlyCategoryTotals: C, getCategoryName: _, reloadCategoryTotals: x } = oe(), { isTransactionDataLoaded: H, loadTransactionData: G, sortedTransactions: W } = se(), { selectedDateRange: t, setSelectedDateRange: O } = ie(), { isInitialized: g, selectedAccounts: V, selectedAccountGuids: z } = ne(), { trends: u } = re(), [T, M] = s.useState(!1), [F, S] = s.useState(!1), [m, j] = s.useState("Chart"), [r, p] = s.useState(""), [K, $] = s.useState(window.innerHeight), B = K - (f ? 315 : 345);
26
26
  de({
27
27
  widgetName: "TrendsFullWidget",
28
28
  isLoaded: T
@@ -33,7 +33,7 @@ var Re = ({ onBackClick: R, onMenuClick: y, sx: I }) => {
33
33
  g && l && x(V, t.start, t.end).finally(() => {
34
34
  M(!0), a(n.TRENDS_LOAD_WIDGET, {
35
35
  ...pe,
36
- time_period: `${w(t.end, t.start)}M`
36
+ time_period: `${L(t.end, t.start)}M`
37
37
  });
38
38
  });
39
39
  }, [
@@ -60,7 +60,7 @@ var Re = ({ onBackClick: R, onMenuClick: y, sx: I }) => {
60
60
  ]), P = (e, i) => {
61
61
  j(i ?? m), a(n.TRENDS_CLICK_TOGGLE_VIEW);
62
62
  }, Y = (e) => {
63
- const i = we(e?.[0], 1), d = e?.[1], ee = w(d, i);
63
+ const i = Le(e?.[0], 1), d = e?.[1], ee = L(d, i);
64
64
  O({
65
65
  start: i,
66
66
  end: d
@@ -70,9 +70,9 @@ var Re = ({ onBackClick: R, onMenuClick: y, sx: I }) => {
70
70
  }, q = (e) => {
71
71
  p(e);
72
72
  }, J = (e) => {
73
- p(e), a(n.TRENDS_CLICK_LEGEND, { category: S(e) });
73
+ p(e), a(n.TRENDS_CLICK_LEGEND, { category: _(e) });
74
74
  }, Q = (e) => {
75
- a(n.TRENDS_HOVER_LEGEND, { category: S(e) });
75
+ a(n.TRENDS_HOVER_LEGEND, { category: _(e) });
76
76
  }, X = (e) => {
77
77
  a(n.TRENDS_HOVER_AREA, { category: e });
78
78
  }, Z = (e) => {
@@ -97,7 +97,7 @@ var Re = ({ onBackClick: R, onMenuClick: y, sx: I }) => {
97
97
  pb: f ? 12 : 24,
98
98
  pt: f ? 24 : 48
99
99
  },
100
- children: [/* @__PURE__ */ o(Se, {
100
+ children: [/* @__PURE__ */ o(_e, {
101
101
  selectedCategoryGuid: r,
102
102
  selectedDateRange: t
103
103
  }), /* @__PURE__ */ o(Ce, {
@@ -109,7 +109,7 @@ var Re = ({ onBackClick: R, onMenuClick: y, sx: I }) => {
109
109
  alignItems: "center",
110
110
  flexDirection: "row",
111
111
  width: "100%",
112
- children: [/* @__PURE__ */ o(L, {
112
+ children: [/* @__PURE__ */ o(w, {
113
113
  flexGrow: 1,
114
114
  children: r && /* @__PURE__ */ c(h, {
115
115
  onClick: () => p(""),
@@ -117,15 +117,15 @@ var Re = ({ onBackClick: R, onMenuClick: y, sx: I }) => {
117
117
  p: 0,
118
118
  pr: 5
119
119
  },
120
- children: [/* @__PURE__ */ o(Le, { name: "arrow_back" }), u.all_categories]
120
+ children: [/* @__PURE__ */ o(we, { name: "arrow_back_ios_new" }), u.all_categories]
121
121
  })
122
122
  }), /* @__PURE__ */ o(h, {
123
- onClick: () => _(!0),
123
+ onClick: () => S(!0),
124
124
  sx: { px: 5 },
125
125
  children: `${u.view_transactions} (${W.length})`
126
126
  })]
127
127
  }),
128
- /* @__PURE__ */ c(L, { children: [m === "Chart" && /* @__PURE__ */ o(De, {
128
+ /* @__PURE__ */ c(w, { children: [m === "Chart" && /* @__PURE__ */ o(De, {
129
129
  availableHeight: B,
130
130
  onClickLegend: J,
131
131
  onHoverArea: X,
@@ -133,7 +133,7 @@ var Re = ({ onBackClick: R, onMenuClick: y, sx: I }) => {
133
133
  onHoverPoint: Z,
134
134
  stackedDatasets: E.stackedDatasets,
135
135
  unstackedDatasets: E.unstackedDatasets
136
- }), m === "Table" && /* @__PURE__ */ o(_e, {
136
+ }), m === "Table" && /* @__PURE__ */ o(Se, {
137
137
  onClickRow: q,
138
138
  selectedCategory: r,
139
139
  selectedDateRange: t
@@ -143,7 +143,7 @@ var Re = ({ onBackClick: R, onMenuClick: y, sx: I }) => {
143
143
  categoryGuid: r,
144
144
  dateRange: t,
145
145
  isOpen: F,
146
- onClose: () => _(!1)
146
+ onClose: () => S(!1)
147
147
  })]
148
148
  });
149
149
  }, qe = he(Re);
@@ -1 +1 @@
1
- {"version":3,"file":"TrendsFullWidget.es.js","names":[],"sources":["../../src/trends/TrendsFullWidget.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport { DateRange } from '@mui/x-date-pickers-pro'\nimport { Icon } from '@mxenabled/mxui'\nimport Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\nimport Button from '@mui/material/Button'\n\nimport { addSeconds } from 'date-fns/addSeconds'\nimport { differenceInCalendarMonths } from 'date-fns/differenceInCalendarMonths'\n\nimport {\n ANALYTICS_EVENTS,\n Loader,\n WidgetContainer,\n useAccountStore,\n useEvent,\n useCategoryStore,\n useGlobalCopyStore,\n useGlobalUiStore,\n useScreenSize,\n useTransactionStore,\n useTrendsStore,\n useWidgetLoadTimer,\n} from '../common'\nimport { WidgetProps } from '../core'\nimport { StackedLineChart } from '../common/components/charts/StackedLineChart'\n\nimport { getStackedLineChartData, StackedLineChartData } from '../core/utils/TrendsUtil'\nimport { getTopLevelCategoryTotals, isExpense, isIncome } from './utils/shared'\n\nimport TrendsViewToggle, { type TrendsTabValue } from './components/TrendsViewToggle'\nimport DateRangeText from './components/DateRangeText'\nimport TrendsTableContainer from './components/TrendsTableContainer'\nimport TrendsDrawer from './components/TrendsDrawer'\nimport { TRENDS_ANALYTICS_METADATA } from './constants/TrendsWidget'\n\nconst TrendsFullWidget: React.FC<WidgetProps> = ({ onBackClick, onMenuClick, sx }) => {\n const { onEvent } = useEvent()\n const { isDesktop, isTablet, isMobile } = useScreenSize()\n const { isAccountDataLoaded, loadAccountData } = useAccountStore()\n const {\n categoriesLoaded,\n loadCategories,\n monthlyCategoryTotals,\n getCategoryName,\n reloadCategoryTotals,\n } = useCategoryStore()\n const {\n isTransactionDataLoaded,\n loadTransactionData,\n sortedTransactions: transactions,\n } = useTransactionStore()\n const { selectedDateRange, setSelectedDateRange } = useTrendsStore()\n const { isInitialized, selectedAccounts, selectedAccountGuids } = useGlobalUiStore()\n const { trends: copy } = useGlobalCopyStore()\n\n const [isWidgetInitialized, setIsWidgetInitialized] = React.useState(false)\n const [showTransactions, setShowTransactions] = React.useState(false)\n const [selectedTab, setSelectedTab] = React.useState<TrendsTabValue>('Chart')\n const [selectedCategory, setSelectedCategory] = React.useState('')\n\n // Control responsive chart height based on available widget iframe viewport height\n const [viewportHeight, setViewportHeight] = React.useState(window.innerHeight)\n const unavailableChartHeight = isMobile ? 315 : 345\n const availableChartHeight = viewportHeight - unavailableChartHeight\n\n useWidgetLoadTimer({\n widgetName: 'TrendsFullWidget',\n isLoaded: isWidgetInitialized,\n })\n\n React.useEffect(() => {\n const handleResize = () => setViewportHeight(window.innerHeight)\n window.addEventListener('resize', handleResize)\n\n if (!isAccountDataLoaded) {\n loadAccountData().finally()\n }\n if (!categoriesLoaded) {\n loadCategories().finally()\n }\n if (!isTransactionDataLoaded) {\n loadTransactionData().finally()\n }\n\n return () => window.removeEventListener('resize', handleResize)\n }, [])\n\n // Initialize monthlyCategoryTotals, and reload on account or date range change.\n // Depends on primitives rather than `selectedAccounts` / `selectedDateRange`,\n // whose object identities change even when the values do not. (MEW-3910)\n //\n // Loads both totals in parallel; see TrendsWidget for why chaining the monthly\n // request behind the date-range one reintroduces the stale-write race.\n // Also waits for account data so the first request isn't fired with an empty\n // account list and immediately superseded. (MEW-3910)\n React.useEffect(() => {\n if (isInitialized && isAccountDataLoaded) {\n reloadCategoryTotals(\n selectedAccounts,\n selectedDateRange.start,\n selectedDateRange.end,\n ).finally(() => {\n setIsWidgetInitialized(true)\n onEvent(ANALYTICS_EVENTS.TRENDS_LOAD_WIDGET, {\n ...TRENDS_ANALYTICS_METADATA,\n time_period: `${differenceInCalendarMonths(selectedDateRange.end, selectedDateRange.start)}M`,\n })\n })\n }\n }, [\n isInitialized,\n isAccountDataLoaded,\n selectedAccountGuids.join(','),\n selectedDateRange.start.getTime(),\n selectedDateRange.end.getTime(),\n ])\n\n // Cache a full year of StackedLineChart data\n const chartData = React.useMemo(() => {\n if (!isWidgetInitialized) return { stackedDatasets: [], unstackedDatasets: [] }\n\n const data = getStackedLineChartData(\n monthlyCategoryTotals,\n selectedDateRange.start,\n selectedDateRange.end,\n )\n\n const filteredData = selectedCategory.length\n ? data.filter(\n (d) =>\n d.top_level_category_guid === selectedCategory || d.category_guid === selectedCategory,\n )\n : getTopLevelCategoryTotals(data)\n\n return {\n stackedDatasets: filteredData.filter(isExpense) as StackedLineChartData[],\n unstackedDatasets: filteredData.filter(isIncome) as StackedLineChartData[],\n }\n }, [monthlyCategoryTotals, selectedCategory, selectedDateRange])\n\n const onTabChange = (_event: React.SyntheticEvent, newValue: TrendsTabValue) => {\n setSelectedTab(newValue ?? selectedTab)\n onEvent(ANALYTICS_EVENTS.TRENDS_CLICK_TOGGLE_VIEW)\n }\n\n const onRangeChanged = (dateRange: DateRange<Date>) => {\n const startDate = addSeconds(dateRange?.[0] as Date, 1)\n const endDate = dateRange?.[1] as Date\n const months = differenceInCalendarMonths(endDate, startDate)\n\n setSelectedDateRange({ start: startDate, end: endDate })\n onEvent(ANALYTICS_EVENTS.TRENDS_CLICK_TIME_WINDOW, {\n time_period: months + 'M',\n })\n }\n\n const onAccountsFilterClick = () => {\n onEvent(ANALYTICS_EVENTS.TRENDS_CLICK_FILTER)\n }\n const onClickRow = (guid: string) => {\n setSelectedCategory(guid)\n }\n const onClickLegend = (guid: string) => {\n setSelectedCategory(guid)\n onEvent(ANALYTICS_EVENTS.TRENDS_CLICK_LEGEND, { category: getCategoryName(guid) })\n }\n const onHoverLegend = (guid: string) => {\n onEvent(ANALYTICS_EVENTS.TRENDS_HOVER_LEGEND, { category: getCategoryName(guid) })\n }\n const onHoverArea = (category: string) => {\n onEvent(ANALYTICS_EVENTS.TRENDS_HOVER_AREA, { category })\n }\n const onHoverPoint = (category: string) => {\n onEvent(ANALYTICS_EVENTS.TRENDS_HOVER_POINT, { category })\n }\n\n // Mirrors the effect's readiness condition. The effect now also waits for\n // account data, so the render gate must too — otherwise a state where the\n // effect never runs would leave a spinner with nothing to clear it. Matches\n // TrendsWidget's gate. (MEW-3910)\n if (!isInitialized || !isAccountDataLoaded || !isWidgetInitialized) return <Loader />\n\n return (\n <WidgetContainer\n calendarActions={{ onRangeChanged }}\n dateRange={selectedDateRange}\n dateRangeVariant=\"timeframebuttons\"\n onAccountsFilterClick={onAccountsFilterClick}\n onBackClick={onBackClick}\n onMenuClick={onMenuClick}\n sx={sx}\n title={copy.title}\n >\n <Stack\n sx={{\n // eslint-disable-next-line no-nested-ternary\n px: isDesktop ? 48 : isTablet ? 24 : 12,\n }}\n >\n <Stack\n flexDirection=\"row\"\n justifyContent=\"space-between\"\n sx={{ pb: isMobile ? 12 : 24, pt: isMobile ? 24 : 48 }}\n >\n <DateRangeText\n selectedCategoryGuid={selectedCategory}\n selectedDateRange={selectedDateRange}\n />\n <TrendsViewToggle onTabChange={onTabChange} selectedTab={selectedTab} />\n </Stack>\n <Stack alignItems=\"center\" flexDirection=\"row\" width=\"100%\">\n <Box flexGrow={1}>\n {selectedCategory && (\n <Button onClick={() => setSelectedCategory('')} sx={{ p: 0, pr: 5 }}>\n <Icon name=\"arrow_back\" />\n {copy.all_categories}\n </Button>\n )}\n </Box>\n <Button onClick={() => setShowTransactions(true)} sx={{ px: 5 }}>\n {`${copy.view_transactions} (${transactions.length})`}\n </Button>\n </Stack>\n <Box>\n {selectedTab === 'Chart' && (\n <StackedLineChart\n availableHeight={availableChartHeight}\n onClickLegend={onClickLegend}\n onHoverArea={onHoverArea}\n onHoverLegend={onHoverLegend}\n onHoverPoint={onHoverPoint}\n stackedDatasets={chartData.stackedDatasets}\n unstackedDatasets={chartData.unstackedDatasets}\n />\n )}\n {selectedTab === 'Table' && (\n <TrendsTableContainer\n onClickRow={onClickRow}\n selectedCategory={selectedCategory}\n selectedDateRange={selectedDateRange}\n />\n )}\n </Box>\n </Stack>\n <TrendsDrawer\n categoryGuid={selectedCategory}\n dateRange={selectedDateRange}\n isOpen={showTransactions}\n onClose={() => setShowTransactions(false)}\n />\n </WidgetContainer>\n )\n}\n\nexport default observer(TrendsFullWidget)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsCA,IAAM,KAAA,CAA2C,EAAE,aAAA,GAAa,aAAA,GAAa,IAAA,EAAA,MAAS;AACpF,QAAM,EAAE,SAAA,EAAA,IAAY,GAAS,GACvB,EAAE,WAAA,GAAW,UAAA,GAAU,UAAA,EAAA,IAAa,GAAc,GAClD,EAAE,qBAAA,GAAqB,iBAAA,EAAA,IAAoB,GAAgB,GAC3D,EACJ,kBAAA,GACA,gBAAA,GACA,uBAAA,GACA,iBAAA,GACA,sBAAA,EAAA,IACE,GAAiB,GACf,EACJ,yBAAA,GACA,qBAAA,GACA,oBAAoB,EAAA,IAClB,GAAoB,GAClB,EAAE,mBAAA,GAAmB,sBAAA,EAAA,IAAyB,GAAe,GAC7D,EAAE,eAAA,GAAe,kBAAA,GAAkB,sBAAA,EAAA,IAAyB,GAAiB,GAC7E,EAAE,QAAQ,EAAA,IAAS,GAAmB,GAEtC,CAAC,GAAqB,CAAA,IAA0B,EAAM,SAAS,EAAK,GACpE,CAAC,GAAkB,CAA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AA;AAAA,UACtC,CAAA,CACH;AAAA;QACP,gBAAA,EAAC,GAAD,EAAA,UAAA,CACG,MAAgB,WACf,gBAAA,EAAC,IAAD;AAAA,UACE,iBAAiB;AAAA,UACF,eAAA;AAAA,UACF,aAAA;AAAA,UACE,eAAA;AAAA,UACD,cAAA;AAAA,UACd,iBAAiB,EAAU;AAAA,UAC3B,mBAAmB,EAAU;AAAA,QAC9B,CAAA,GAEF,MAAgB,WACf,gBAAA,EAAC,IAAD;AAAA,UACc,YAAA;AAAA,UACM,kBAAA;AAAA,UACC,mBAAA;AAAA,QACpB,CAAA,CAEA,EAAA,CAAA;AAAA,MACA;AAAA,IACP,CAAA,GAAA,gBAAA,EAAC,IAAD;AAAA,MACE,cAAc;AAAA,MACd,WAAW;AAAA,MACX,QAAQ;AAAA,MACR,SAAA,MAAe,EAAoB,EAAK;AAAA,IACzC,CAAA,CACc;AAAA;AAErB,GAEA,KAAe,GAAS,EAAgB"}
1
+ {"version":3,"file":"TrendsFullWidget.es.js","names":[],"sources":["../../src/trends/TrendsFullWidget.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport { DateRange } from '@mui/x-date-pickers-pro'\nimport { Icon } from '@mxenabled/mxui'\nimport Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\nimport Button from '@mui/material/Button'\n\nimport { addSeconds } from 'date-fns/addSeconds'\nimport { differenceInCalendarMonths } from 'date-fns/differenceInCalendarMonths'\n\nimport {\n ANALYTICS_EVENTS,\n Loader,\n WidgetContainer,\n useAccountStore,\n useEvent,\n useCategoryStore,\n useGlobalCopyStore,\n useGlobalUiStore,\n useScreenSize,\n useTransactionStore,\n useTrendsStore,\n useWidgetLoadTimer,\n} from '../common'\nimport { WidgetProps } from '../core'\nimport { StackedLineChart } from '../common/components/charts/StackedLineChart'\n\nimport { getStackedLineChartData, StackedLineChartData } from '../core/utils/TrendsUtil'\nimport { getTopLevelCategoryTotals, isExpense, isIncome } from './utils/shared'\n\nimport TrendsViewToggle, { type TrendsTabValue } from './components/TrendsViewToggle'\nimport DateRangeText from './components/DateRangeText'\nimport TrendsTableContainer from './components/TrendsTableContainer'\nimport TrendsDrawer from './components/TrendsDrawer'\nimport { TRENDS_ANALYTICS_METADATA } from './constants/TrendsWidget'\n\nconst TrendsFullWidget: React.FC<WidgetProps> = ({ onBackClick, onMenuClick, sx }) => {\n const { onEvent } = useEvent()\n const { isDesktop, isTablet, isMobile } = useScreenSize()\n const { isAccountDataLoaded, loadAccountData } = useAccountStore()\n const {\n categoriesLoaded,\n loadCategories,\n monthlyCategoryTotals,\n getCategoryName,\n reloadCategoryTotals,\n } = useCategoryStore()\n const {\n isTransactionDataLoaded,\n loadTransactionData,\n sortedTransactions: transactions,\n } = useTransactionStore()\n const { selectedDateRange, setSelectedDateRange } = useTrendsStore()\n const { isInitialized, selectedAccounts, selectedAccountGuids } = useGlobalUiStore()\n const { trends: copy } = useGlobalCopyStore()\n\n const [isWidgetInitialized, setIsWidgetInitialized] = React.useState(false)\n const [showTransactions, setShowTransactions] = React.useState(false)\n const [selectedTab, setSelectedTab] = React.useState<TrendsTabValue>('Chart')\n const [selectedCategory, setSelectedCategory] = React.useState('')\n\n // Control responsive chart height based on available widget iframe viewport height\n const [viewportHeight, setViewportHeight] = React.useState(window.innerHeight)\n const unavailableChartHeight = isMobile ? 315 : 345\n const availableChartHeight = viewportHeight - unavailableChartHeight\n\n useWidgetLoadTimer({\n widgetName: 'TrendsFullWidget',\n isLoaded: isWidgetInitialized,\n })\n\n React.useEffect(() => {\n const handleResize = () => setViewportHeight(window.innerHeight)\n window.addEventListener('resize', handleResize)\n\n if (!isAccountDataLoaded) {\n loadAccountData().finally()\n }\n if (!categoriesLoaded) {\n loadCategories().finally()\n }\n if (!isTransactionDataLoaded) {\n loadTransactionData().finally()\n }\n\n return () => window.removeEventListener('resize', handleResize)\n }, [])\n\n // Initialize monthlyCategoryTotals, and reload on account or date range change.\n // Depends on primitives rather than `selectedAccounts` / `selectedDateRange`,\n // whose object identities change even when the values do not. (MEW-3910)\n //\n // Loads both totals in parallel; see TrendsWidget for why chaining the monthly\n // request behind the date-range one reintroduces the stale-write race.\n // Also waits for account data so the first request isn't fired with an empty\n // account list and immediately superseded. (MEW-3910)\n React.useEffect(() => {\n if (isInitialized && isAccountDataLoaded) {\n reloadCategoryTotals(\n selectedAccounts,\n selectedDateRange.start,\n selectedDateRange.end,\n ).finally(() => {\n setIsWidgetInitialized(true)\n onEvent(ANALYTICS_EVENTS.TRENDS_LOAD_WIDGET, {\n ...TRENDS_ANALYTICS_METADATA,\n time_period: `${differenceInCalendarMonths(selectedDateRange.end, selectedDateRange.start)}M`,\n })\n })\n }\n }, [\n isInitialized,\n isAccountDataLoaded,\n selectedAccountGuids.join(','),\n selectedDateRange.start.getTime(),\n selectedDateRange.end.getTime(),\n ])\n\n // Cache a full year of StackedLineChart data\n const chartData = React.useMemo(() => {\n if (!isWidgetInitialized) return { stackedDatasets: [], unstackedDatasets: [] }\n\n const data = getStackedLineChartData(\n monthlyCategoryTotals,\n selectedDateRange.start,\n selectedDateRange.end,\n )\n\n const filteredData = selectedCategory.length\n ? data.filter(\n (d) =>\n d.top_level_category_guid === selectedCategory || d.category_guid === selectedCategory,\n )\n : getTopLevelCategoryTotals(data)\n\n return {\n stackedDatasets: filteredData.filter(isExpense) as StackedLineChartData[],\n unstackedDatasets: filteredData.filter(isIncome) as StackedLineChartData[],\n }\n }, [monthlyCategoryTotals, selectedCategory, selectedDateRange])\n\n const onTabChange = (_event: React.SyntheticEvent, newValue: TrendsTabValue) => {\n setSelectedTab(newValue ?? selectedTab)\n onEvent(ANALYTICS_EVENTS.TRENDS_CLICK_TOGGLE_VIEW)\n }\n\n const onRangeChanged = (dateRange: DateRange<Date>) => {\n const startDate = addSeconds(dateRange?.[0] as Date, 1)\n const endDate = dateRange?.[1] as Date\n const months = differenceInCalendarMonths(endDate, startDate)\n\n setSelectedDateRange({ start: startDate, end: endDate })\n onEvent(ANALYTICS_EVENTS.TRENDS_CLICK_TIME_WINDOW, {\n time_period: months + 'M',\n })\n }\n\n const onAccountsFilterClick = () => {\n onEvent(ANALYTICS_EVENTS.TRENDS_CLICK_FILTER)\n }\n const onClickRow = (guid: string) => {\n setSelectedCategory(guid)\n }\n const onClickLegend = (guid: string) => {\n setSelectedCategory(guid)\n onEvent(ANALYTICS_EVENTS.TRENDS_CLICK_LEGEND, { category: getCategoryName(guid) })\n }\n const onHoverLegend = (guid: string) => {\n onEvent(ANALYTICS_EVENTS.TRENDS_HOVER_LEGEND, { category: getCategoryName(guid) })\n }\n const onHoverArea = (category: string) => {\n onEvent(ANALYTICS_EVENTS.TRENDS_HOVER_AREA, { category })\n }\n const onHoverPoint = (category: string) => {\n onEvent(ANALYTICS_EVENTS.TRENDS_HOVER_POINT, { category })\n }\n\n // Mirrors the effect's readiness condition. The effect now also waits for\n // account data, so the render gate must too — otherwise a state where the\n // effect never runs would leave a spinner with nothing to clear it. Matches\n // TrendsWidget's gate. (MEW-3910)\n if (!isInitialized || !isAccountDataLoaded || !isWidgetInitialized) return <Loader />\n\n return (\n <WidgetContainer\n calendarActions={{ onRangeChanged }}\n dateRange={selectedDateRange}\n dateRangeVariant=\"timeframebuttons\"\n onAccountsFilterClick={onAccountsFilterClick}\n onBackClick={onBackClick}\n onMenuClick={onMenuClick}\n sx={sx}\n title={copy.title}\n >\n <Stack\n sx={{\n // eslint-disable-next-line no-nested-ternary\n px: isDesktop ? 48 : isTablet ? 24 : 12,\n }}\n >\n <Stack\n flexDirection=\"row\"\n justifyContent=\"space-between\"\n sx={{ pb: isMobile ? 12 : 24, pt: isMobile ? 24 : 48 }}\n >\n <DateRangeText\n selectedCategoryGuid={selectedCategory}\n selectedDateRange={selectedDateRange}\n />\n <TrendsViewToggle onTabChange={onTabChange} selectedTab={selectedTab} />\n </Stack>\n <Stack alignItems=\"center\" flexDirection=\"row\" width=\"100%\">\n <Box flexGrow={1}>\n {selectedCategory && (\n <Button onClick={() => setSelectedCategory('')} sx={{ p: 0, pr: 5 }}>\n <Icon name=\"arrow_back_ios_new\" />\n {copy.all_categories}\n </Button>\n )}\n </Box>\n <Button onClick={() => setShowTransactions(true)} sx={{ px: 5 }}>\n {`${copy.view_transactions} (${transactions.length})`}\n </Button>\n </Stack>\n <Box>\n {selectedTab === 'Chart' && (\n <StackedLineChart\n availableHeight={availableChartHeight}\n onClickLegend={onClickLegend}\n onHoverArea={onHoverArea}\n onHoverLegend={onHoverLegend}\n onHoverPoint={onHoverPoint}\n stackedDatasets={chartData.stackedDatasets}\n unstackedDatasets={chartData.unstackedDatasets}\n />\n )}\n {selectedTab === 'Table' && (\n <TrendsTableContainer\n onClickRow={onClickRow}\n selectedCategory={selectedCategory}\n selectedDateRange={selectedDateRange}\n />\n )}\n </Box>\n </Stack>\n <TrendsDrawer\n categoryGuid={selectedCategory}\n dateRange={selectedDateRange}\n isOpen={showTransactions}\n onClose={() => setShowTransactions(false)}\n />\n </WidgetContainer>\n )\n}\n\nexport default observer(TrendsFullWidget)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsCA,IAAM,KAAA,CAA2C,EAAE,aAAA,GAAa,aAAA,GAAa,IAAA,EAAA,MAAS;AACpF,QAAM,EAAE,SAAA,EAAA,IAAY,GAAS,GACvB,EAAE,WAAA,GAAW,UAAA,GAAU,UAAA,EAAA,IAAa,GAAc,GAClD,EAAE,qBAAA,GAAqB,iBAAA,EAAA,IAAoB,GAAgB,GAC3D,EACJ,kBAAA,GACA,gBAAA,GACA,uBAAA,GACA,iBAAA,GACA,sBAAA,EAAA,IACE,GAAiB,GACf,EACJ,yBAAA,GACA,qBAAA,GACA,oBAAoB,EAAA,IAClB,GAAoB,GAClB,EAAE,mBAAA,GAAmB,sBAAA,EAAA,IAAyB,GAAe,GAC7D,EAAE,eAAA,GAAe,kBAAA,GAAkB,sBAAA,EAAA,IAAyB,GAAiB,GAC7E,EAAE,QAAQ,EAAA,IAAS,GAAmB,GAEtC,CAAC,GAAqB,C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;AAAA,YAC3D,UAAA,GAAG,EAAK,iBAAA,KAAsB,EAAa,MAAA;AAAA,UACtC,CAAA,CACH;AAAA;QACP,gBAAA,EAAC,GAAD,EAAA,UAAA,CACG,MAAgB,WACf,gBAAA,EAAC,IAAD;AAAA,UACE,iBAAiB;AAAA,UACF,eAAA;AAAA,UACF,aAAA;AAAA,UACE,eAAA;AAAA,UACD,cAAA;AAAA,UACd,iBAAiB,EAAU;AAAA,UAC3B,mBAAmB,EAAU;AAAA,QAC9B,CAAA,GAEF,MAAgB,WACf,gBAAA,EAAC,IAAD;AAAA,UACc,YAAA;AAAA,UACM,kBAAA;AAAA,UACC,mBAAA;AAAA,QACpB,CAAA,CAEA,EAAA,CAAA;AAAA,MACA;AAAA,IACP,CAAA,GAAA,gBAAA,EAAC,IAAD;AAAA,MACE,cAAc;AAAA,MACd,WAAW;AAAA,MACX,QAAQ;AAAA,MACR,SAAA,MAAe,EAAoB,EAAK;AAAA,IACzC,CAAA,CACc;AAAA;AAErB,GAEA,KAAe,GAAS,EAAgB"}
@@ -22,7 +22,7 @@ import n from "react";
22
22
  import { observer as qe } from "mobx-react-lite";
23
23
  import f from "@mui/material/Stack";
24
24
  import Je from "@mui/material/Button";
25
- import { ArrowBack as Qe } from "@mxenabled/mx-icons";
25
+ import { ArrowBackIosNew as Qe } from "@mxenabled/mx-icons";
26
26
  import { Fragment as Xe, jsx as t, jsxs as l } from "react/jsx-runtime";
27
27
  import w from "@mui/material/Box";
28
28
  import { differenceInCalendarMonths as M } from "date-fns/differenceInCalendarMonths";