@mx-cartographer/experiences 9.7.159 → 9.7.161

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 (81) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/common/components/CurrencyDialog.d.ts +11 -1
  3. package/dist/common/components/CurrencyDialog.es.js +50 -44
  4. package/dist/common/components/CurrencyDialog.es.js.map +1 -1
  5. package/dist/common/components/ErrorBoundary.d.ts +1 -0
  6. package/dist/common/components/ErrorBoundary.es.js +1 -1
  7. package/dist/common/components/ErrorBoundary.es.js.map +1 -1
  8. package/dist/common/components/index.d.ts +1 -1
  9. package/dist/core/types/localization/InsightsFeedCopy.d.ts +8 -0
  10. package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.d.ts +2 -0
  11. package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.es.js +39 -39
  12. package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.es.js.map +1 -1
  13. package/dist/insights-v2/actionBlocks/AccountListBlock/index.d.ts +1 -1
  14. package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js +40 -35
  15. package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js.map +1 -1
  16. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.d.ts +1 -1
  17. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js +91 -91
  18. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js.map +1 -1
  19. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.d.ts +42 -2
  20. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.es.js +75 -15
  21. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.es.js.map +1 -1
  22. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.d.ts +2 -0
  23. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js +73 -74
  24. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js.map +1 -1
  25. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/index.d.ts +1 -1
  26. package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationBlock.d.ts +2 -0
  27. package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationBlock.es.js +20 -21
  28. package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationBlock.es.js.map +1 -1
  29. package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/index.d.ts +1 -1
  30. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.d.ts +2 -0
  31. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js +36 -38
  32. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js.map +1 -1
  33. package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/index.d.ts +1 -1
  34. package/dist/insights-v2/actionBlocks/OverdraftBlock/OverdraftBlock.d.ts +2 -0
  35. package/dist/insights-v2/actionBlocks/OverdraftBlock/OverdraftBlock.es.js +29 -30
  36. package/dist/insights-v2/actionBlocks/OverdraftBlock/OverdraftBlock.es.js.map +1 -1
  37. package/dist/insights-v2/actionBlocks/OverdraftBlock/index.d.ts +1 -1
  38. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.d.ts +2 -0
  39. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.es.js +60 -59
  40. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.es.js.map +1 -1
  41. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/index.d.ts +1 -1
  42. package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/PayoffStrategiesBlock.d.ts +2 -0
  43. package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/PayoffStrategiesBlock.es.js +20 -20
  44. package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/PayoffStrategiesBlock.es.js.map +1 -1
  45. package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/index.d.ts +1 -1
  46. package/dist/insights-v2/actionBlocks/PlaceholderActionBlock.es.js.map +1 -1
  47. package/dist/insights-v2/actionBlocks/QuizMerchantBlock/QuizMerchantBlock.es.js +3 -3
  48. package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.d.ts +2 -0
  49. package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.es.js +36 -36
  50. package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.es.js.map +1 -1
  51. package/dist/insights-v2/actionBlocks/RemainingCashBlock/index.d.ts +1 -1
  52. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.d.ts +2 -1
  53. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +77 -76
  54. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
  55. package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListBlock.es.js +64 -59
  56. package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListBlock.es.js.map +1 -1
  57. package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListCreditLimitHeader.d.ts +11 -0
  58. package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListCreditLimitHeader.es.js +138 -0
  59. package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListCreditLimitHeader.es.js.map +1 -0
  60. package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.d.ts +13 -0
  61. package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js +80 -63
  62. package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js.map +1 -1
  63. package/dist/insights-v2/actionBlocks/useRequiredCopy.d.ts +3 -0
  64. package/dist/insights-v2/actionBlocks/useRequiredCopy.es.js +11 -0
  65. package/dist/insights-v2/actionBlocks/useRequiredCopy.es.js.map +1 -0
  66. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.es.js +14 -14
  67. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.es.js.map +1 -1
  68. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.d.ts +9 -2
  69. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.es.js +14 -7
  70. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.es.js.map +1 -1
  71. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/utils.d.ts +7 -1
  72. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/utils.es.js +14 -7
  73. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/utils.es.js.map +1 -1
  74. package/dist/insights-v2/blocks/ComponentBlocks/SavingsSummaryBlock/SavingsSummaryBlock.es.js +1 -1
  75. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/SVGImageBlock.es.js +4 -4
  76. package/dist/insights-v2/components/CompactInsightCard.es.js +164 -138
  77. package/dist/insights-v2/components/CompactInsightCard.es.js.map +1 -1
  78. package/dist/insights-v2/mappings/blocks.d.ts +1 -0
  79. package/dist/insights-v2/mappings/blocks.es.js +190 -178
  80. package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
  81. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ActionBlockLayer.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/ActionBlockLayer.tsx"],"sourcesContent":["import { useRef } from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport {\n Drawer,\n Loader,\n useGlobalCopyStore,\n useGlobalUiStore,\n useInsightsV2Store,\n} from '../../common'\nimport type { Beat } from '../../core'\nimport {\n actionBlocks,\n hasDrawerBlock,\n type ActionBlockEntry,\n type ActionBlockProps,\n} from '../mappings/blocks'\nimport StatusSnackbar from '../components/shared/StatusSnackbar'\nimport { BlockErrorMessage } from './BlockErrorMessage'\nimport { useOpenedCta } from './useOpenedCta'\nimport type { OpenedCta } from './util'\n\ninterface ActionBlockLayerProps {\n beat: Beat\n}\n\n/** Keeps the CTA the user pressed for the open session: a refreshed beat may name another CTA there. */\nconst useSessionCta = (isOpen: boolean, resolved: OpenedCta): OpenedCta => {\n const pinned = useRef<OpenedCta>(undefined)\n\n if (!isOpen) {\n pinned.current = undefined\n return resolved\n }\n pinned.current ??= resolved\n\n return pinned.current\n}\n\n/**\n * Renders a registered action block. Callers MUST key this per block name — a\n * block with `usePrepare` and one without run a different number of hooks, so\n * reusing the same fiber across a block switch violates the rules of hooks.\n */\nconst ActionBlockRunner = ({\n actionBlock,\n ...blockProps\n}: ActionBlockProps & { actionBlock: ActionBlockEntry }) => {\n const { Component, usePrepare } = actionBlock\n\n usePrepare(blockProps)\n\n return <Component {...blockProps} />\n}\n\n// `observer` is required: this reads `isCopyLoaded` off GlobalUiStore and the\n// action drawer off InsightsV2Store. Without it the component never re-renders\n// and stays stuck on <Loader /> forever.\nexport const ActionBlockLayer = observer(function ActionBlockLayer({\n beat,\n}: ActionBlockLayerProps) {\n const copy = useGlobalCopyStore()\n const commonCopy = copy.common\n const closeAria = commonCopy?.close_aria ?? 'Close'\n const { isCopyLoaded } = useGlobalUiStore()\n const { actionDrawer, actionNotice, closeActionDrawer, setActionNotice } = useInsightsV2Store()\n\n // Every card in the feed renders its own layer against the shared store, so\n // this card's drawer only opens when its beat is the one that triggered it.\n const isCurrentBeatOpen = actionDrawer.isDrawerOpen && actionDrawer.guid === beat.guid\n\n const currentCta = useSessionCta(isCurrentBeatOpen, useOpenedCta(beat))\n\n // Mirrors BaseLayout's guard — the layer is exported, so callers are not\n // guaranteed to have narrowed this already.\n if (!beat.insights_payload) return null\n\n if (!isCopyLoaded) return isCurrentBeatOpen ? <Loader /> : null\n\n // A block that closes its own drawer hands its message here, so it shows after the unmount.\n const notice = actionNotice[beat.guid]\n const noticeSnackbar = (\n <StatusSnackbar\n closeAriaLabel={closeAria}\n message={notice?.message ?? ''}\n onClose={() => setActionNotice(beat.guid, undefined)}\n open={Boolean(notice)}\n severity={notice?.severity}\n />\n )\n\n // A CTA without a real block never opens a drawer (BaseLayout won't trigger it);\n // a real-but-unknown block shows the error (\"oops\") content.\n const blockValid = hasDrawerBlock(currentCta?.block)\n const actionBlock = blockValid\n ? actionBlocks[currentCta?.block as keyof typeof actionBlocks]\n : undefined\n\n // A modal block owns its dialog: no drawer behind it, and nothing mounted until it is opened.\n if (actionBlock?.presentation === 'modal') {\n return (\n <>\n {isCurrentBeatOpen && (\n <ActionBlockRunner actionBlock={actionBlock} beat={beat} key={currentCta?.block} />\n )}\n {noticeSnackbar}\n </>\n )\n }\n\n const resolvedTitle = actionBlock?.title?.(currentCta?.variant, copy, beat)\n const drawerTitle = actionBlock\n ? resolvedTitle || currentCta?.label || ''\n : blockValid\n ? (commonCopy?.error_heading ?? 'Oops')\n : (currentCta?.label ?? '')\n\n return (\n <>\n <Drawer\n ariaLabelClose={closeAria}\n headerAction={actionBlock?.headerAction}\n isOpen={isCurrentBeatOpen}\n onClose={closeActionDrawer}\n title={drawerTitle}\n >\n {actionBlock ? (\n <ActionBlockRunner actionBlock={actionBlock} beat={beat} key={currentCta?.block} />\n ) : blockValid ? (\n <BlockErrorMessage />\n ) : null}\n </Drawer>\n {noticeSnackbar}\n </>\n )\n})\n"],"mappings":";;;;;;;;;;;AA4BA,IAAM,IAAA,CAAiB,GAAiB,MAAmC;AACzE,QAAM,IAAS,EAAkB,MAAS;AAE1C,SAAK,KAIL,EAAO,YAAY,GAEZ,EAAO,YALZ,EAAO,UAAU,QACV;AAKX,GAOM,IAAA,CAAqB,EACzB,aAAA,GACA,GAAG,EAAA,MACuD;AAC1D,QAAM,EAAE,WAAA,GAAW,YAAA,EAAA,IAAe;AAElC,SAAA,EAAW,CAAU,GAEd,gBAAA,EA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Aa;AAAA,IAC3B,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,OAAO;AAAA,IAEN,UAAA,IACC,gBAAA,EAAC,GAAD;AAAA,MAAgC,aAAA;AAAA,MAAmB,MAAA;AAAA,IAA+B,GAApB,GAAY,KAAQ,IAChF,IACF,gBAAA,EAAC,GAAD,CAAoB,CAAA,IAClB;AAAA,EACE,CAAA,GACP,CACD,EAAA,CAAA;AAEN,CAAC"}
1
+ {"version":3,"file":"ActionBlockLayer.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/ActionBlockLayer.tsx"],"sourcesContent":["import { useRef } from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport {\n Drawer,\n ErrorBoundary,\n Loader,\n useGlobalCopyStore,\n useGlobalStore,\n useGlobalUiStore,\n useInsightsV2Store,\n} from '../../common'\nimport type { Beat } from '../../core'\nimport {\n actionBlocks,\n hasDrawerBlock,\n type ActionBlockEntry,\n type ActionBlockProps,\n} from '../mappings/blocks'\nimport StatusSnackbar from '../components/shared/StatusSnackbar'\nimport { BlockErrorMessage } from './BlockErrorMessage'\nimport { useOpenedCta } from './useOpenedCta'\nimport type { OpenedCta } from './util'\n\ninterface ActionBlockLayerProps {\n beat: Beat\n}\n\n/** Keeps the CTA the user pressed for the open session: a refreshed beat may name another CTA there. */\nconst useSessionCta = (isOpen: boolean, resolved: OpenedCta): OpenedCta => {\n const pinned = useRef<OpenedCta>(undefined)\n\n if (!isOpen) {\n pinned.current = undefined\n return resolved\n }\n pinned.current ??= resolved\n\n return pinned.current\n}\n\n/**\n * Renders a registered action block. Callers MUST key it (or its wrapper) per block name — a\n * block with `usePrepare` and one without run a different number of hooks, so\n * reusing the same fiber across a block switch violates the rules of hooks.\n */\nconst ActionBlockRunner = ({\n actionBlock,\n ...blockProps\n}: ActionBlockProps & { actionBlock: ActionBlockEntry }) => {\n const { Component, usePrepare } = actionBlock\n\n usePrepare(blockProps)\n\n return <Component {...blockProps} />\n}\n\n// `observer` is required: this reads `isCopyLoaded` off GlobalUiStore and the\n// action drawer off InsightsV2Store. Without it the component never re-renders\n// and stays stuck on <Loader /> forever.\nexport const ActionBlockLayer = observer(function ActionBlockLayer({\n beat,\n}: ActionBlockLayerProps) {\n const copy = useGlobalCopyStore()\n const { captureException } = useGlobalStore()\n const commonCopy = copy.common\n const closeAria = commonCopy?.close_aria ?? 'Close'\n const { isCopyLoaded } = useGlobalUiStore()\n const { actionDrawer, actionNotice, closeActionDrawer, setActionNotice } = useInsightsV2Store()\n\n // Every card in the feed renders its own layer against the shared store, so\n // this card's drawer only opens when its beat is the one that triggered it.\n const isCurrentBeatOpen = actionDrawer.isDrawerOpen && actionDrawer.guid === beat.guid\n\n const currentCta = useSessionCta(isCurrentBeatOpen, useOpenedCta(beat))\n\n // Mirrors BaseLayout's guard — the layer is exported, so callers are not\n // guaranteed to have narrowed this already.\n if (!beat.insights_payload) return null\n\n if (!isCopyLoaded) return isCurrentBeatOpen ? <Loader /> : null\n\n // A block that closes its own drawer hands its message here, so it shows after the unmount.\n const notice = actionNotice[beat.guid]\n const noticeSnackbar = (\n <StatusSnackbar\n closeAriaLabel={closeAria}\n message={notice?.message ?? ''}\n onClose={() => setActionNotice(beat.guid, undefined)}\n open={Boolean(notice)}\n severity={notice?.severity}\n />\n )\n\n // A CTA without a real block never opens a drawer (BaseLayout won't trigger it);\n // a real-but-unknown block shows the error (\"oops\") content.\n const blockValid = hasDrawerBlock(currentCta?.block)\n const actionBlock = blockValid\n ? actionBlocks[currentCta?.block as keyof typeof actionBlocks]\n : undefined\n\n // A modal block owns its dialog: no drawer behind it, and nothing mounted until it is opened.\n if (actionBlock?.presentation === 'modal') {\n return (\n <>\n {isCurrentBeatOpen && (\n <ActionBlockRunner actionBlock={actionBlock} beat={beat} key={currentCta?.block} />\n )}\n {noticeSnackbar}\n </>\n )\n }\n\n const canMount = actionBlock && (actionBlock.copy === undefined || actionBlock.copy(copy) != null)\n const resolvedTitle = actionBlock?.title?.(currentCta?.variant, copy, beat)\n const drawerTitle = canMount\n ? resolvedTitle || currentCta?.label || ''\n : blockValid\n ? (commonCopy?.error_heading ?? 'Oops')\n : (currentCta?.label ?? '')\n\n return (\n <>\n <Drawer\n ariaLabelClose={closeAria}\n headerAction={actionBlock?.headerAction}\n isOpen={isCurrentBeatOpen}\n onClose={closeActionDrawer}\n title={drawerTitle}\n >\n {canMount ? (\n // A block that throws (e.g. its entry declares no `copy`) fails inside the drawer.\n <ErrorBoundary\n fallback={<BlockErrorMessage />}\n key={currentCta?.block}\n onCaptureException={captureException}\n >\n <ActionBlockRunner actionBlock={actionBlock} beat={beat} />\n </ErrorBoundary>\n ) : blockValid ? (\n <BlockErrorMessage />\n ) : null}\n </Drawer>\n {noticeSnackbar}\n </>\n )\n})\n"],"mappings":";;;;;;;;;;;;AA8BA,IAAM,IAAA,CAAiB,GAAiB,MAAmC;AACzE,QAAM,IAAS,EAAkB,MAAS;AAE1C,SAAK,KAIL,EAAO,YAAY,GAEZ,EAAO,YALZ,EAAO,UAAU,QACV;AAKX,GAOM,IAAA,CAAqB,EACzB,aAAA,GACA,GAAG,EAAA,MACuD;AAC1D,QAAM,EAAE,WAAA,GAAW,YAAA,EAAA,IAAe;AAElC,SAAA,EAAW,CAAU,GAEd,gBAAA,EAAC,GAAD,EAAW,GAAI,EAAa,CAAA;AACrC,GAKa,IAAmB,EAAS,SAA0B,EACjE,MAAA,EAAA,GACwB;AACxB,QAAM,IAAO,EAAmB,GAC1B,EAAE,kBAAA,EAAA,IAAqB,EAAe,GACtC,IAAa,EAAK,QAClB,IAAY,GAAY,cAAc,SACtC,EAAE,cAAA,EAAA,IAAiB,EAAiB,GACpC,EAAE,cAAA,GAAc,cAAA,GAAc,mBAAA,GAAmB,iBAAA,EAAA,IAAoB,EAAmB,GAIxF,IAAoB,EAAa,gBAAgB,EAAa,SAAS,EAAK,MAE5E,IAAa,EAAc,GAAmB,EAAa,CAAI,CAAC;AAItE,MAAI,CAAC,EAAK,iBAAkB,QAAO;AAEnC,MA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EACE,CAAA,GACP,CACD,EAAA,CAAA;AAEN,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { ActionBlockProps } from '../../mappings/blocks';
2
- /** `amount_input_modal_block`: one whole-dollar amount in a modal, picked by the CTA variant. */
2
+ /** `amount_input_modal_block`: one amount or percentage setting in a modal, picked by the CTA variant. */
3
3
  export declare const AmountInputModalBlock: (({ beat, }: ActionBlockProps) => import("react/jsx-runtime").JSX.Element) & {
4
4
  displayName: string;
5
5
  };
@@ -1,146 +1,146 @@
1
- import { buildDynamicCopy as j } from "../../../core/utils/Localization.es.js";
2
- import z from "../../../common/utils/AccountDisplayName.es.js";
3
- import { useCategoryStore as q, useGlobalCopyStore as w, useInsightsV2Store as P, useSettingsStore as J, useUserStore as K } from "../../../common/context/hooks.es.js";
4
- import B from "../../../common/components/Loader.es.js";
5
- import Q from "../../../common/components/CurrencyDialog.es.js";
6
- import { useBeatActions as X } from "../../beatActions.es.js";
7
- import { ANALYTICS_EVENTS_CONFIG as d } from "../../analytics/analyticsEventsConfig.es.js";
8
- import { useCtaHandler as Z } from "../../ctaActions/useCtaAction.es.js";
9
- import { useAnalyticsEvent as oo } from "../../analytics/useAnalyticsEvent.es.js";
10
- import { useOpenedCta as eo } from "../useOpenedCta.es.js";
11
- import { CreateBudgetDialog as to } from "./CreateBudgetDialog.es.js";
12
- import { AMOUNT_INPUT_VARIANTS as io, CREATE_BUDGET_VARIANT as no, findLowBalanceProfile as ro, isAmountInputVariant as x, isWholeAmount as ao, resolveAmountInputVariant as so, toInputValue as co } from "./layout.es.js";
1
+ import { buildDynamicCopy as X } from "../../../core/utils/Localization.es.js";
2
+ import Y from "../../../common/utils/AccountDisplayName.es.js";
3
+ import { useCategoryStore as Z, useGlobalCopyStore as N, useInsightsV2Store as k, useSettingsStore as oo, useUserStore as eo } from "../../../common/context/hooks.es.js";
4
+ import V from "../../../common/components/Loader.es.js";
5
+ import to from "../../../common/components/CurrencyDialog.es.js";
6
+ import { useBeatActions as no } from "../../beatActions.es.js";
7
+ import { useCtaHandler as io } from "../../ctaActions/useCtaAction.es.js";
8
+ import { useAnalyticsEvent as ro } from "../../analytics/useAnalyticsEvent.es.js";
9
+ import { useOpenedCta as so } from "../useOpenedCta.es.js";
10
+ import { AMOUNT_SETTINGS as ao, CREATE_BUDGET_VARIANT as co, findLowBalanceProfile as lo, isAmountInputVariant as w, resolveAmountInputVariant as uo, toInputValue as mo } from "./layout.es.js";
11
+ import { CreateBudgetDialog as po } from "./CreateBudgetDialog.es.js";
13
12
  import r from "react";
14
- import { observer as V } from "mobx-react-lite";
15
- import k from "@mui/material/Stack";
16
- import { H3 as lo, InstitutionLogo as uo, Text as H } from "@mxenabled/mxui";
17
- import { Icon as mo } from "@mxenabled/mx-icons";
18
- import { jsx as o, jsxs as O } from "react/jsx-runtime";
19
- import po from "@mui/material/Dialog";
20
- import fo from "@mui/material/IconButton";
21
- var S = ({ children: g, closeAriaLabel: i, heading: n, onClose: e }) => {
22
- const a = r.useId();
23
- return /* @__PURE__ */ o(po, {
24
- "aria-labelledby": n ? a : void 0,
13
+ import { observer as M } from "mobx-react-lite";
14
+ import G from "@mui/material/Stack";
15
+ import { H3 as fo, InstitutionLogo as yo, Text as B } from "@mxenabled/mxui";
16
+ import { Icon as go } from "@mxenabled/mx-icons";
17
+ import { jsx as e, jsxs as R } from "react/jsx-runtime";
18
+ import ho from "@mui/material/Dialog";
19
+ import _o from "@mui/material/IconButton";
20
+ var C = ({ children: y, closeAriaLabel: n, heading: i, onClose: t }) => {
21
+ const s = r.useId();
22
+ return /* @__PURE__ */ e(ho, {
23
+ "aria-labelledby": i ? s : void 0,
25
24
  maxWidth: "xs",
26
- onClose: e,
25
+ onClose: t,
27
26
  open: !0,
28
- children: /* @__PURE__ */ O(k, {
27
+ children: /* @__PURE__ */ R(G, {
29
28
  sx: {
30
29
  gap: 12,
31
30
  p: 24,
32
31
  position: "relative"
33
32
  },
34
33
  children: [
35
- n && /* @__PURE__ */ o(lo, {
36
- id: a,
37
- children: n
34
+ i && /* @__PURE__ */ e(fo, {
35
+ id: s,
36
+ children: i
38
37
  }),
39
- /* @__PURE__ */ o(fo, {
40
- "aria-label": i || "Close",
41
- onClick: e,
38
+ /* @__PURE__ */ e(_o, {
39
+ "aria-label": n || "Close",
40
+ onClick: t,
42
41
  sx: {
43
42
  position: "absolute",
44
43
  right: 8,
45
44
  top: 18
46
45
  },
47
- children: /* @__PURE__ */ o(mo, {
46
+ children: /* @__PURE__ */ e(go, {
48
47
  name: "close",
49
48
  sx: { color: "action.active" }
50
49
  })
51
50
  }),
52
- g
51
+ y
53
52
  ]
54
53
  })
55
54
  });
56
- }, ko = V(function({ beat: i }) {
57
- const { common: n } = w(), { closeActionDrawer: e } = P(), a = q(), l = eo(i), [u] = r.useState(() => so(l)), m = u === no;
55
+ }, $o = M(function({ beat: n }) {
56
+ const { common: i } = N(), { closeActionDrawer: t } = k(), s = Z(), c = so(n), [l] = r.useState(() => uo(c)), d = l === co;
58
57
  return r.useEffect(() => {
59
- m && !a.categoriesLoaded && a.loadCategories();
60
- }, [a, m]), m ? a.categoriesLoaded ? /* @__PURE__ */ o(to, { beat: i }) : /* @__PURE__ */ o(S, {
61
- closeAriaLabel: n?.close_aria,
62
- onClose: e,
63
- children: /* @__PURE__ */ o(B, {})
64
- }) : /* @__PURE__ */ o(_o, {
65
- beat: i,
66
- variant: u
58
+ d && !s.categoriesLoaded && s.loadCategories();
59
+ }, [s, d]), d ? s.categoriesLoaded ? /* @__PURE__ */ e(po, { beat: n }) : /* @__PURE__ */ e(C, {
60
+ closeAriaLabel: i?.close_aria,
61
+ onClose: t,
62
+ children: /* @__PURE__ */ e(V, {})
63
+ }) : /* @__PURE__ */ e(vo, {
64
+ beat: n,
65
+ variant: l
67
66
  });
68
- }), _o = V(function({ beat: i, variant: n }) {
69
- const { common: e, insights_feed: a } = w(), { closeActionDrawer: l } = P(), u = J(), { userInsightProfile: m } = K(), A = Z(i, X()), E = oo(), c = a?.amount_input_modal, t = n === io.LOW_BALANCE_THRESHOLD, h = t ? ro(u.notificationProfiles, i.primary_account_guid) : void 0, T = t ? h?.threshold : m?.savings_opportunity_minimum_checking_account_balance, [R, G] = r.useState(t), p = r.useRef(!0);
67
+ }), vo = M(function({ beat: n, variant: i }) {
68
+ const { common: t, insights_feed: s } = N(), { closeActionDrawer: c } = k(), l = oo(), { userInsightProfile: d } = eo(), $ = io(n, no()), S = ro(), u = s?.amount_input_modal, o = w(i) ? ao[i] : void 0, m = !!o?.needsNotificationProfiles, g = {
69
+ insightProfile: d,
70
+ lowBalanceProfile: m ? lo(l.notificationProfiles, n.primary_account_guid) : void 0
71
+ }, A = o?.read(g), [F, H] = r.useState(m), p = r.useRef(!0);
70
72
  r.useEffect(() => (p.current = !0, () => {
71
73
  p.current = !1;
72
74
  }), []), r.useEffect(() => {
73
- t && u.loadNotificationProfiles().finally(() => {
74
- p.current && G(!1);
75
+ m && l.loadNotificationProfiles().finally(() => {
76
+ p.current && H(!1);
75
77
  });
76
- }, [t, u]);
77
- const [F, M] = r.useState(null), [C, v] = r.useState(!1), [U, y] = r.useState(!1), f = F ?? co(T);
78
- if (R) return /* @__PURE__ */ o(S, {
79
- closeAriaLabel: e?.close_aria,
80
- onClose: l,
81
- children: /* @__PURE__ */ o(B, {})
78
+ }, [m, l]);
79
+ const [O, U] = r.useState(null), [I, b] = r.useState(!1), [j, h] = r.useState(!1), f = O ?? mo(A);
80
+ if (F) return /* @__PURE__ */ e(C, {
81
+ closeAriaLabel: t?.close_aria,
82
+ onClose: c,
83
+ children: /* @__PURE__ */ e(V, {})
82
84
  });
83
- const s = x(n) ? c?.[n] : void 0, D = !!s?.title && !!s.description && !!s.input_label && !!c?.whole_number_error && !!c.save_error && !!e?.save_button && (!t || !!e.cancel_button) && !!e.close_aria;
84
- if (!c || !s || !D || !(t ? h : m))
85
- return console.warn(`amount_input_modal_block: ${c ? x(n) ? D ? t ? "no low-balance profile for the account" : "user insight profile not set by the host" : `copy incomplete for "${n}"` : `unknown variant "${n}"` : "copy namespace missing"}`), /* @__PURE__ */ o(S, {
86
- closeAriaLabel: e?.close_aria,
87
- heading: e?.error_heading,
88
- onClose: l,
89
- children: /* @__PURE__ */ o(H, { children: e?.error_message })
85
+ const a = w(i) ? u?.[i] : void 0, x = o ? u?.[o.errorKey] : void 0, D = !!a?.title && !!a.description && !!a.input_label && !!x && !!u?.save_error && !!t?.save_button && (!o?.hasCancel || !!t.cancel_button) && !!t.close_aria, z = !!o?.hasSource(g);
86
+ if (!u || !o || !a || !D || !z)
87
+ return console.warn(`amount_input_modal_block: ${u ? o ? D ? m ? "no low-balance profile for the account" : "user insight profile not set by the host" : `copy incomplete for "${i}"` : `unknown variant "${i}"` : "copy namespace missing"}`), /* @__PURE__ */ e(C, {
88
+ closeAriaLabel: t?.close_aria,
89
+ heading: t?.error_heading,
90
+ onClose: c,
91
+ children: /* @__PURE__ */ e(B, { children: t?.error_message })
90
92
  });
91
- const L = () => {
92
- E(t ? d.EDIT_INSIGHT_THRESHOLD_CANCELED : d.EDIT_SAFETY_NET_CANCEL), l();
93
- }, b = !t && !!T, N = i.primary_account ? z(i.primary_account) : "", I = ao(f), $ = f !== "" && !I, W = async () => {
94
- if (!I || C) return;
95
- const _ = Number(f);
96
- v(!0), y(!1);
97
- const Y = t ? await A("updateNotificationProfileThreshold", {
98
- profileGuid: h?.guid,
99
- threshold: _
100
- }, { analytics: d.EDIT_INSIGHT_THRESHOLD_SAVE }) : await A("updateUserInsightProfile", { fields: { savings_opportunity_minimum_checking_account_balance: _ } }, { analytics: d.EDIT_SAFETY_NET_SAVE });
101
- p.current && (v(!1), Y ? l() : y(!0));
93
+ const P = () => {
94
+ S(o.analytics.cancel), c();
95
+ }, { inputSelected: L } = o.analytics, E = o.hasEditCopy && !!A, T = n.primary_account ? Y(n.primary_account) : "", _ = o.isValid(f), K = f !== "" && !_, W = async () => {
96
+ if (!_ || I) return;
97
+ const v = Number(f);
98
+ b(!0), h(!1);
99
+ const [q, J] = o.save(v, g), Q = await $(q, J, { analytics: o.analytics.save });
100
+ p.current && (b(!1), Q ? c() : h(!0));
102
101
  };
103
- return /* @__PURE__ */ o(Q, {
104
- closeAriaLabel: e.close_aria,
105
- content: j(b && s.description_edit || s.description, /* @__PURE__ */ o("strong", { children: N }, "account")),
106
- errorText: $ ? c.whole_number_error : U ? c.save_error : void 0,
107
- handleInputChange: (_) => {
108
- M(_), y(!1);
102
+ return /* @__PURE__ */ e(to, {
103
+ closeAriaLabel: t.close_aria,
104
+ content: X(E && a.description_edit || a.description, /* @__PURE__ */ e("strong", { children: T }, "account")),
105
+ errorText: K ? x : j ? u.save_error : void 0,
106
+ handleInputChange: (v) => {
107
+ U(v), h(!1);
109
108
  },
110
- handleInputClick: t ? () => E(d.EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED) : void 0,
111
- handleModalClose: L,
109
+ handleInputClick: L ? () => S(L) : void 0,
110
+ handleModalClose: P,
112
111
  handlePrimaryAction: () => {
113
112
  W();
114
113
  },
115
- handleSecondaryAction: L,
116
- inputLabel: s.input_label,
114
+ handleSecondaryAction: P,
115
+ inputLabel: a.input_label,
117
116
  inputValue: f,
118
117
  isOpen: !0,
119
- isPrimaryDisabled: C || !I,
120
- primaryText: e.save_button,
121
- secondaryText: t ? e.cancel_button : void 0,
122
- subtitle: t && i.primary_account ? /* @__PURE__ */ O(k, {
118
+ isPrimaryDisabled: I || !_,
119
+ primaryText: t.save_button,
120
+ secondaryText: o.hasCancel ? t.cancel_button : void 0,
121
+ subtitle: o.showsAccount && n.primary_account ? /* @__PURE__ */ R(G, {
123
122
  sx: {
124
123
  alignItems: "center",
125
124
  flexDirection: "row",
126
125
  gap: 8
127
126
  },
128
- children: [/* @__PURE__ */ o(uo, {
127
+ children: [/* @__PURE__ */ e(yo, {
129
128
  alt: "",
130
- institutionGuid: i.primary_account.institution_guid ?? "",
129
+ institutionGuid: n.primary_account.institution_guid ?? "",
131
130
  size: 16
132
- }), /* @__PURE__ */ o(H, {
131
+ }), /* @__PURE__ */ e(B, {
133
132
  color: "text.secondary",
134
133
  uppercase: !0,
135
134
  variant: "body2",
136
- children: N
135
+ children: T
137
136
  })]
138
137
  }) : void 0,
139
- title: b && s.title_edit || s.title
138
+ title: E && a.title_edit || a.title,
139
+ unit: o.unit
140
140
  });
141
141
  });
142
142
  export {
143
- ko as AmountInputModalBlock
143
+ $o as AmountInputModalBlock
144
144
  };
145
145
 
146
146
  //# sourceMappingURL=AmountInputModalBlock.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AmountInputModalBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.tsx"],"sourcesContent":["import React from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport MuiDialog from '@mui/material/Dialog'\nimport IconButton from '@mui/material/IconButton'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { H3, InstitutionLogo, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n CurrencyDialog,\n Loader,\n buildDynamicCopy,\n useCategoryStore,\n useGlobalCopyStore,\n useInsightsV2Store,\n useSettingsStore,\n useUserStore,\n} from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../analytics'\nimport { useBeatActions } from '../../beatActions'\nimport { useCtaHandler } from '../../ctaActions'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { useOpenedCta } from '../useOpenedCta'\n\nimport { CreateBudgetDialog } from './CreateBudgetDialog'\nimport {\n AMOUNT_INPUT_VARIANTS,\n CREATE_BUDGET_VARIANT,\n findLowBalanceProfile,\n isAmountInputVariant,\n isWholeAmount,\n resolveAmountInputVariant,\n toInputValue,\n} from './layout'\n\n/** Dialog frame for the formless states: loading and a non-retriable problem. */\nconst StatusDialog = ({\n children,\n closeAriaLabel,\n heading,\n onClose,\n}: React.PropsWithChildren<{ closeAriaLabel?: string; heading?: string; onClose: () => void }>) => {\n const headingId = React.useId()\n\n return (\n <MuiDialog\n aria-labelledby={heading ? headingId : undefined}\n maxWidth=\"xs\"\n onClose={onClose}\n open={true}\n >\n <Stack sx={{ gap: 12, p: 24, position: 'relative' }}>\n {heading && <H3 id={headingId}>{heading}</H3>}\n <IconButton\n aria-label={closeAriaLabel || 'Close'}\n onClick={onClose}\n sx={{ position: 'absolute', right: 8, top: 18 }}\n >\n <Icon name=\"close\" sx={{ color: 'action.active' }} />\n </IconButton>\n {children}\n </Stack>\n </MuiDialog>\n )\n}\n\n/** `amount_input_modal_block`: one whole-dollar amount in a modal, picked by the CTA variant. */\nexport const AmountInputModalBlock = observer(function AmountInputModalBlock({\n beat,\n}: ActionBlockProps) {\n const { common: commonCopy } = useGlobalCopyStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const categoryStore = useCategoryStore()\n const openedCta = useOpenedCta(beat)\n // Read once on open: a refreshed beat must not swap the dialog under its snackbar.\n const [variant] = React.useState(() => resolveAmountInputVariant(openedCta))\n const isCreateBudget = variant === CREATE_BUDGET_VARIANT\n\n // The create dialog names the category, so it waits for the category store.\n React.useEffect(() => {\n if (isCreateBudget && !categoryStore.categoriesLoaded) void categoryStore.loadCategories()\n }, [categoryStore, isCreateBudget])\n\n if (!isCreateBudget) return <AmountSettingDialog beat={beat} variant={variant} />\n\n return categoryStore.categoriesLoaded ? (\n <CreateBudgetDialog beat={beat} />\n ) : (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n})\n\n/** The low-balance threshold and safety-net settings (the two `AMOUNT_INPUT_VARIANTS`). */\nconst AmountSettingDialog = observer(function AmountSettingDialog({\n beat,\n variant,\n}: ActionBlockProps & { variant?: string }) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const settingsStore = useSettingsStore()\n const { userInsightProfile } = useUserStore()\n const runHandler = useCtaHandler(beat, useBeatActions())\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n const copy = insightsFeedCopy?.amount_input_modal\n const isLowBalance = variant === AMOUNT_INPUT_VARIANTS.LOW_BALANCE_THRESHOLD\n\n const lowBalanceProfile = isLowBalance\n ? findLowBalanceProfile(settingsStore.notificationProfiles, beat.primary_account_guid)\n : undefined\n const savedAmount = isLowBalance\n ? lowBalanceProfile?.threshold\n : userInsightProfile?.savings_opportunity_minimum_checking_account_balance\n\n // Mounting is the open, so profiles reload here and the threshold prefills as saved now.\n const [isLoadingProfiles, setIsLoadingProfiles] = React.useState(isLowBalance)\n // False once unmounted: a save that resolves after the user closed the dialog must not close\n // (or update) whatever action session is open by then.\n const isMounted = React.useRef(true)\n\n React.useEffect(() => {\n isMounted.current = true\n\n return () => {\n isMounted.current = false\n }\n }, [])\n\n React.useEffect(() => {\n if (!isLowBalance) return\n\n void settingsStore.loadNotificationProfiles().finally(() => {\n if (isMounted.current) setIsLoadingProfiles(false)\n })\n }, [isLowBalance, settingsStore])\n\n // `null` until the user types: the field shows the saved amount until then.\n const [typed, setTyped] = React.useState<string | null>(null)\n const [isSaving, setIsSaving] = React.useState(false)\n const [saveFailed, setSaveFailed] = React.useState(false)\n\n const value = typed ?? toInputValue(savedAmount)\n\n if (isLoadingProfiles) {\n return (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n }\n\n // Copy ships separately (see the doc's Rollout order), so check every string the form renders:\n // a partial ship falls to the error dialog instead of throwing mid-render.\n const variantCopy = isAmountInputVariant(variant) ? copy?.[variant] : undefined\n const hasCopy =\n !!variantCopy?.title &&\n !!variantCopy.description &&\n !!variantCopy.input_label &&\n !!copy?.whole_number_error &&\n !!copy.save_error &&\n !!commonCopy?.save_button &&\n // Cancel renders for the low-balance variant only.\n (!isLowBalance || !!commonCopy.cancel_button) &&\n !!commonCopy.close_aria\n const hasProfile = isLowBalance ? !!lowBalanceProfile : !!userInsightProfile\n\n if (!copy || !variantCopy || !hasCopy || !hasProfile) {\n // One message to the user; distinct warnings so a rollout problem can be traced to its cause.\n console.warn(\n `amount_input_modal_block: ${\n !copy\n ? 'copy namespace missing'\n : !isAmountInputVariant(variant)\n ? `unknown variant \"${variant}\"`\n : !hasCopy\n ? `copy incomplete for \"${variant}\"`\n : isLowBalance\n ? 'no low-balance profile for the account'\n : 'user insight profile not set by the host'\n }`,\n )\n\n return (\n <StatusDialog\n closeAriaLabel={commonCopy?.close_aria}\n heading={commonCopy?.error_heading}\n onClose={closeActionDrawer}\n >\n <Text>{commonCopy?.error_message}</Text>\n </StatusDialog>\n )\n }\n\n // Trigger 4 — user dismissed without saving (close icon, Cancel button, backdrop). Pulse\n // parity: EditThreshold.js close button / EditSafetyNet.js cancel button.\n const handleDismiss = () => {\n fireAnalyticsEvent(\n isLowBalance\n ? ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_CANCELED\n : ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_CANCEL,\n )\n closeActionDrawer()\n }\n\n const isEdit = !isLowBalance && !!savedAmount\n const accountName = beat.primary_account ? getAccountDisplayName(beat.primary_account) : ''\n const isValid = isWholeAmount(value)\n const isInvalid = value !== '' && !isValid\n\n const handleSave = async () => {\n // Guarded here too, not only by the disabled button: Enter submits the dialog's form directly.\n if (!isValid || isSaving) return\n\n const amount = Number(value)\n\n setIsSaving(true)\n setSaveFailed(false)\n\n // Trigger 2: save analytics ride the handler run, fired only on success.\n const ok = isLowBalance\n ? await runHandler(\n 'updateNotificationProfileThreshold',\n { profileGuid: lowBalanceProfile?.guid, threshold: amount },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_SAVE },\n )\n : await runHandler(\n 'updateUserInsightProfile',\n { fields: { savings_opportunity_minimum_checking_account_balance: amount } },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_SAVE },\n )\n\n if (!isMounted.current) return\n\n setIsSaving(false)\n\n if (ok) closeActionDrawer()\n else setSaveFailed(true)\n }\n\n return (\n <CurrencyDialog\n closeAriaLabel={commonCopy.close_aria}\n // Only strings and the <strong> go in, so the result is renderable (the helper's type also\n // admits raw DOM nodes).\n content={\n buildDynamicCopy(\n (isEdit && variantCopy.description_edit) || variantCopy.description,\n <strong key=\"account\">{accountName}</strong>,\n ) as React.ReactNode\n }\n errorText={isInvalid ? copy.whole_number_error : saveFailed ? copy.save_error : undefined}\n handleInputChange={(next) => {\n setTyped(next)\n setSaveFailed(false)\n }}\n handleInputClick={\n // Pulse fires input-selected for the threshold dialog only (EditThreshold.js); the\n // safety-net dialog has no input event.\n isLowBalance\n ? () => fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED)\n : undefined\n }\n handleModalClose={handleDismiss}\n handlePrimaryAction={() => void handleSave()}\n handleSecondaryAction={handleDismiss}\n inputLabel={variantCopy.input_label}\n inputValue={value}\n isOpen={true}\n isPrimaryDisabled={isSaving || !isValid}\n primaryText={commonCopy.save_button}\n secondaryText={isLowBalance ? commonCopy.cancel_button : undefined}\n subtitle={\n isLowBalance && beat.primary_account ? (\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n {/* Decorative: the account name is the visible text beside it. */}\n <InstitutionLogo\n alt=\"\"\n institutionGuid={beat.primary_account.institution_guid ?? ''}\n size={16}\n />\n <Text color=\"text.secondary\" uppercase={true} variant=\"body2\">\n {accountName}\n </Text>\n </Stack>\n ) : undefined\n }\n title={(isEdit && variantCopy.title_edit) || variantCopy.title}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwCA,IAAM,IAAA,CAAgB,EACpB,UAAA,GACA,gBAAA,GACA,SAAA,GACA,SAAA,EAAA,MACiG;AACjG,QAAM,IAAY,EAAM,MAAM;AAE9B,SACE,gBAAA,EAAC,IAAD;AAAA,IACE,mBAAiB,IAAU,IAAY;AAAA,IACvC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,"file":"AmountInputModalBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.tsx"],"sourcesContent":["import React from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport MuiDialog from '@mui/material/Dialog'\nimport IconButton from '@mui/material/IconButton'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { H3, InstitutionLogo, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n CurrencyDialog,\n Loader,\n buildDynamicCopy,\n useCategoryStore,\n useGlobalCopyStore,\n useInsightsV2Store,\n useSettingsStore,\n useUserStore,\n} from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { useAnalyticsEvent } from '../../analytics'\nimport { useBeatActions } from '../../beatActions'\nimport { useCtaHandler } from '../../ctaActions'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { useOpenedCta } from '../useOpenedCta'\n\nimport { CreateBudgetDialog } from './CreateBudgetDialog'\nimport {\n AMOUNT_SETTINGS,\n CREATE_BUDGET_VARIANT,\n findLowBalanceProfile,\n isAmountInputVariant,\n resolveAmountInputVariant,\n toInputValue,\n} from './layout'\n\n/** Dialog frame for the formless states: loading and a non-retriable problem. */\nconst StatusDialog = ({\n children,\n closeAriaLabel,\n heading,\n onClose,\n}: React.PropsWithChildren<{ closeAriaLabel?: string; heading?: string; onClose: () => void }>) => {\n const headingId = React.useId()\n\n return (\n <MuiDialog\n aria-labelledby={heading ? headingId : undefined}\n maxWidth=\"xs\"\n onClose={onClose}\n open={true}\n >\n <Stack sx={{ gap: 12, p: 24, position: 'relative' }}>\n {heading && <H3 id={headingId}>{heading}</H3>}\n <IconButton\n aria-label={closeAriaLabel || 'Close'}\n onClick={onClose}\n sx={{ position: 'absolute', right: 8, top: 18 }}\n >\n <Icon name=\"close\" sx={{ color: 'action.active' }} />\n </IconButton>\n {children}\n </Stack>\n </MuiDialog>\n )\n}\n\n/** `amount_input_modal_block`: one amount or percentage setting in a modal, picked by the CTA variant. */\nexport const AmountInputModalBlock = observer(function AmountInputModalBlock({\n beat,\n}: ActionBlockProps) {\n const { common: commonCopy } = useGlobalCopyStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const categoryStore = useCategoryStore()\n const openedCta = useOpenedCta(beat)\n // Read once on open: a refreshed beat must not swap the dialog under its snackbar.\n const [variant] = React.useState(() => resolveAmountInputVariant(openedCta))\n const isCreateBudget = variant === CREATE_BUDGET_VARIANT\n\n // The create dialog names the category, so it waits for the category store.\n React.useEffect(() => {\n if (isCreateBudget && !categoryStore.categoriesLoaded) void categoryStore.loadCategories()\n }, [categoryStore, isCreateBudget])\n\n if (!isCreateBudget) return <AmountSettingDialog beat={beat} variant={variant} />\n\n return categoryStore.categoriesLoaded ? (\n <CreateBudgetDialog beat={beat} />\n ) : (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n})\n\n/** One amount or percentage setting, per its `AMOUNT_SETTINGS` entry (`AMOUNT_INPUT_VARIANTS`). */\nconst AmountSettingDialog = observer(function AmountSettingDialog({\n beat,\n variant,\n}: ActionBlockProps & { variant?: string }) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const settingsStore = useSettingsStore()\n const { userInsightProfile } = useUserStore()\n const runHandler = useCtaHandler(beat, useBeatActions())\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n const copy = insightsFeedCopy?.amount_input_modal\n const setting = isAmountInputVariant(variant) ? AMOUNT_SETTINGS[variant] : undefined\n const needsNotificationProfiles = !!setting?.needsNotificationProfiles\n\n const sources = {\n insightProfile: userInsightProfile,\n lowBalanceProfile: needsNotificationProfiles\n ? findLowBalanceProfile(settingsStore.notificationProfiles, beat.primary_account_guid)\n : undefined,\n }\n const savedAmount = setting?.read(sources)\n\n // Mounting is the open, so profiles reload here and the threshold prefills as saved now.\n const [isLoadingProfiles, setIsLoadingProfiles] = React.useState(needsNotificationProfiles)\n // False once unmounted: a save that resolves after the user closed the dialog must not close\n // (or update) whatever action session is open by then.\n const isMounted = React.useRef(true)\n\n React.useEffect(() => {\n isMounted.current = true\n\n return () => {\n isMounted.current = false\n }\n }, [])\n\n React.useEffect(() => {\n if (!needsNotificationProfiles) return\n\n void settingsStore.loadNotificationProfiles().finally(() => {\n if (isMounted.current) setIsLoadingProfiles(false)\n })\n }, [needsNotificationProfiles, settingsStore])\n\n // `null` until the user types: the field shows the saved amount until then.\n const [typed, setTyped] = React.useState<string | null>(null)\n const [isSaving, setIsSaving] = React.useState(false)\n const [saveFailed, setSaveFailed] = React.useState(false)\n\n const value = typed ?? toInputValue(savedAmount)\n\n if (isLoadingProfiles) {\n return (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n }\n\n // Copy ships separately (see the doc's Rollout order), so check every string the form renders:\n // a partial ship falls to the error dialog instead of throwing mid-render.\n const variantCopy = isAmountInputVariant(variant) ? copy?.[variant] : undefined\n const errorCopy = setting ? copy?.[setting.errorKey] : undefined\n const hasCopy =\n !!variantCopy?.title &&\n !!variantCopy.description &&\n !!variantCopy.input_label &&\n !!errorCopy &&\n !!copy?.save_error &&\n !!commonCopy?.save_button &&\n (!setting?.hasCancel || !!commonCopy.cancel_button) &&\n !!commonCopy.close_aria\n const hasProfile = !!setting?.hasSource(sources)\n\n if (!copy || !setting || !variantCopy || !hasCopy || !hasProfile) {\n // One message to the user; distinct warnings so a rollout problem can be traced to its cause.\n console.warn(\n `amount_input_modal_block: ${\n !copy\n ? 'copy namespace missing'\n : !setting\n ? `unknown variant \"${variant}\"`\n : !hasCopy\n ? `copy incomplete for \"${variant}\"`\n : needsNotificationProfiles\n ? 'no low-balance profile for the account'\n : 'user insight profile not set by the host'\n }`,\n )\n\n return (\n <StatusDialog\n closeAriaLabel={commonCopy?.close_aria}\n heading={commonCopy?.error_heading}\n onClose={closeActionDrawer}\n >\n <Text>{commonCopy?.error_message}</Text>\n </StatusDialog>\n )\n }\n\n // Trigger 4 — user dismissed without saving (close icon, Cancel button, backdrop). Pulse\n // parity: EditThreshold.js close button / EditSafetyNet.js cancel button.\n const handleDismiss = () => {\n fireAnalyticsEvent(setting.analytics.cancel)\n closeActionDrawer()\n }\n\n const { inputSelected } = setting.analytics\n const isEdit = setting.hasEditCopy && !!savedAmount\n const accountName = beat.primary_account ? getAccountDisplayName(beat.primary_account) : ''\n const isValid = setting.isValid(value)\n const isInvalid = value !== '' && !isValid\n\n const handleSave = async () => {\n // Guarded here too, not only by the disabled button: Enter submits the dialog's form directly.\n if (!isValid || isSaving) return\n\n const amount = Number(value)\n\n setIsSaving(true)\n setSaveFailed(false)\n\n // Trigger 2: save analytics ride the handler run, fired only on success.\n const [handler, params] = setting.save(amount, sources)\n const ok = await runHandler(handler, params, { analytics: setting.analytics.save })\n\n if (!isMounted.current) return\n\n setIsSaving(false)\n\n if (ok) closeActionDrawer()\n else setSaveFailed(true)\n }\n\n return (\n <CurrencyDialog\n closeAriaLabel={commonCopy.close_aria}\n // Only strings and the <strong> go in, so the result is renderable (the helper's type also\n // admits raw DOM nodes).\n content={\n buildDynamicCopy(\n (isEdit && variantCopy.description_edit) || variantCopy.description,\n <strong key=\"account\">{accountName}</strong>,\n ) as React.ReactNode\n }\n errorText={isInvalid ? errorCopy : saveFailed ? copy.save_error : undefined}\n handleInputChange={(next) => {\n setTyped(next)\n setSaveFailed(false)\n }}\n handleInputClick={inputSelected ? () => fireAnalyticsEvent(inputSelected) : undefined}\n handleModalClose={handleDismiss}\n handlePrimaryAction={() => void handleSave()}\n handleSecondaryAction={handleDismiss}\n inputLabel={variantCopy.input_label}\n inputValue={value}\n isOpen={true}\n isPrimaryDisabled={isSaving || !isValid}\n primaryText={commonCopy.save_button}\n secondaryText={setting.hasCancel ? commonCopy.cancel_button : undefined}\n subtitle={\n setting.showsAccount && beat.primary_account ? (\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n {/* Decorative: the account name is the visible text beside it. */}\n <InstitutionLogo\n alt=\"\"\n institutionGuid={beat.primary_account.institution_guid ?? ''}\n size={16}\n />\n <Text color=\"text.secondary\" uppercase={true} variant=\"body2\">\n {accountName}\n </Text>\n </Stack>\n ) : undefined\n }\n title={(isEdit && variantCopy.title_edit) || variantCopy.title}\n unit={setting.unit}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuCA,IAAM,IAAA,CAAgB,EACpB,UAAA,GACA,gBAAA,GACA,SAAA,GACA,SAAA,EAAA,MACiG;AACjG,QAAM,IAAY,EAAM,MAAM;AAE9B,SACE,gBAAA,EAAC,IAAD;AAAA,IACE,mBAAiB,IAAU,IAAY;AAAA,IACvC,UAAS;AAAA,IACA,SAAA;AAAA,IACT,MAAM;AAAA,IAEN,UAAA,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,KAAK;AAAA,QAAI,GAAG;AAAA,QAAI,UAAU;AAAA,MAAW;AAAA,MAAlD,UAAA;AAAA,QACG,KAAW,gBAAA,EAAC,IAAD;AAAA,UAAI,IAAI;AAAA,UAAY,UAAA;AAAA,QAAY,CAAA;AAAA,QAC5C,gBAAA,EAAC,IAAD;AAAA,UACE,cAAY,KAAkB;AAAA,UAC9B,SAAS;AAAA,UACT,IAAI;AAAA,YAAE,UAAU;AAAA,YAAY,OAAO;AAAA,YAAG,KAAK;AAAA,UAAG;AAAA,UAE9C,UAAA,gBAAA,EAAC,IAAD;AAAA,YAAM,MAAK;AAAA,YAAQ,IAAI,EAAE,OAAO,gBAAgB;AAAA,UAAI,CAAA;AAAA,QAC1C,CAAA;AAAA,QACX;AAAA,MACI;AAAA;EACE,CAAA;AAEf,GAGa,KAAwB,EAAS,SAA+B,EAC3E,MAAA,EAAA,GACmB;AACnB,QAAM,EAAE,QAAQ,EAAA,IAAe,EAAmB,GAC5C,EAAE,mBAAA,EAAA,IAAsB,EA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AChC,aAAa,EAAW;AAAA,IACxB,eAAe,EAAQ,YAAY,EAAW,gBAAgB;AAAA,IAC9D,UACE,EAAQ,gBAAgB,EAAK,kBAC3B,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,YAAY;AAAA,QAAU,eAAe;AAAA,QAAO,KAAK;AAAA,MAAE;AAAA,MAAhE,UAAA,CAEE,gBAAA,EAAC,IAAD;AAAA,QACE,KAAI;AAAA,QACJ,iBAAiB,EAAK,gBAAgB,oBAAoB;AAAA,QAC1D,MAAM;AAAA,MACP,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,QAAM,OAAM;AAAA,QAAiB,WAAW;AAAA,QAAM,SAAQ;AAAA,QACnD,UAAA;AAAA,MACG,CAAA,CACD;AAAA,IACL,CAAA,IAAA;AAAA,IAEN,OAAQ,KAAU,EAAY,cAAe,EAAY;AAAA,IACzD,MAAM,EAAQ;AAAA,EACf,CAAA;AAEL,CAAC"}
@@ -1,8 +1,12 @@
1
- import { NotificationProfile } from '../../../core';
1
+ import { NotificationProfile, UserInsightProfile } from '../../../core';
2
+ import { AnalyticsEventConfigEntry } from '../../analytics/analyticsEventsConfig';
3
+ import { CtaHandlerName } from '../../ctaActions/ctaHandlers';
4
+ import { CurrencyDialogUnit } from '../../../common/components';
2
5
  /** CTA variants `amount_input_modal_block` serves (ditto sets one on the beat's CTA). */
3
6
  export declare const AMOUNT_INPUT_VARIANTS: {
4
7
  readonly LOW_BALANCE_THRESHOLD: "low_balance_threshold";
5
8
  readonly SAFETY_NET: "safety_net";
9
+ readonly CREDIT_LIMIT_PERCENTAGE: "credit_limit_percentage";
6
10
  };
7
11
  /** Opens the Create Budget dialog instead of an amount setting (Category Spending). */
8
12
  export declare const CREATE_BUDGET_VARIANT = "create_budget";
@@ -18,9 +22,45 @@ export declare const resolveAmountInputVariant: (cta?: {
18
22
  block?: string | null;
19
23
  variant?: string | null;
20
24
  }) => string | undefined;
21
- /** Whole dollars from 1 to `MAX_AMOUNT`, as pulse v1 accepted for both settings. */
25
+ /** Whole dollars from 1 to `MAX_AMOUNT`, as pulse v1 accepted for its dollar settings. */
22
26
  export declare const isWholeAmount: (value: string) => boolean;
27
+ /** The user's credit-limit alert as a whole 1-100 percent, else the default; the dialog and the Spending header both read it. */
28
+ export declare const resolveCreditLimitAlertPercent: (profile?: Pick<UserInsightProfile, "credit_card_close_to_limit_percentage"> | null) => number;
29
+ /** Where a setting's value can live; the dialog loads both and each variant reads its own. */
30
+ interface AmountSources {
31
+ insightProfile?: UserInsightProfile | null;
32
+ lowBalanceProfile?: NotificationProfile;
33
+ }
34
+ /** What one variant edits, how it validates and words its field, and the pulse analytics it fires. */
35
+ interface AmountSetting {
36
+ /** The saved value, from the setting's own source. */
37
+ read: (sources: AmountSources) => number | null | undefined;
38
+ /** The CTA handler and params that save `amount`. */
39
+ save: (amount: number, sources: AmountSources) => [CtaHandlerName, Record<string, unknown>];
40
+ /** Whether the source the setting edits is loaded; without it the dialog shows the plain error. */
41
+ hasSource: (sources: AmountSources) => boolean;
42
+ /** The source is the account's notification profile, which the dialog reloads on open. */
43
+ needsNotificationProfiles: boolean;
44
+ isValid: (value: string) => boolean;
45
+ /** The `insights_feed.amount_input_modal` key of the validation message. */
46
+ errorKey: 'whole_number_error' | 'percentage_error';
47
+ unit: CurrencyDialogUnit;
48
+ hasCancel: boolean;
49
+ /** Switches to `title_edit` / `description_edit` once a value is saved. */
50
+ hasEditCopy: boolean;
51
+ /** The account line under the title. */
52
+ showsAccount: boolean;
53
+ analytics: {
54
+ save: AnalyticsEventConfigEntry;
55
+ cancel: AnalyticsEventConfigEntry;
56
+ /** Pulse fires input-selected for the threshold dialogs only (EditThreshold.js). */
57
+ inputSelected?: AnalyticsEventConfigEntry;
58
+ };
59
+ }
60
+ /** Per-variant behaviour of the amount setting dialog; a new variant adds an entry here. */
61
+ export declare const AMOUNT_SETTINGS: Record<AmountInputVariant, AmountSetting>;
23
62
  /** A saved amount as the field's starting text; nothing saved (or zero) starts empty. */
24
63
  export declare const toInputValue: (amount?: number | null) => string;
25
64
  /** The account's low-balance alert profile, which holds the threshold (as pulse v1 looked it up). */
26
65
  export declare const findLowBalanceProfile: (profiles: NotificationProfile[], accountGuid?: string | null) => NotificationProfile | undefined;
66
+ export {};
@@ -1,20 +1,80 @@
1
- import { AccountNotificationTypes as a } from "../../../core/types/Notification.es.js";
2
- import { actionBlocksKey as o } from "../../mappings/actionBlocksKey.es.js";
3
- var e = {
1
+ import { AccountNotificationTypes as T } from "../../../core/types/Notification.es.js";
2
+ import { asNumber as E } from "../../blocks/slotReaders.es.js";
3
+ import { ANALYTICS_EVENTS_CONFIG as a } from "../../analytics/analyticsEventsConfig.es.js";
4
+ import { actionBlocksKey as l } from "../../mappings/actionBlocksKey.es.js";
5
+ var i = {
4
6
  LOW_BALANCE_THRESHOLD: "low_balance_threshold",
5
- SAFETY_NET: "safety_net"
6
- }, T = "create_budget", u = (t) => Object.values(e).includes(t ?? ""), N = (t) => {
7
- if (t?.variant) return t.variant;
8
- if (t?.block === o.SAFETY_NET_ACTION_BLOCK) return e.SAFETY_NET;
9
- }, i = 1e9, c = (t) => /^\d+$/.test(t) && Number(t) >= 1 && Number(t) <= i, v = (t) => t ? String(Math.round(t)) : "", E = (t, r) => r ? t.find((n) => n.entity_guid === r && n.notification_type === a.AccountBalanceLow) : void 0;
7
+ SAFETY_NET: "safety_net",
8
+ CREDIT_LIMIT_PERCENTAGE: "credit_limit_percentage"
9
+ }, C = "create_budget", f = (e) => Object.values(i).includes(e ?? ""), p = (e) => {
10
+ if (e?.variant) return e.variant;
11
+ if (e?.block === l.SAFETY_NET_ACTION_BLOCK) return i.SAFETY_NET;
12
+ }, A = 1e9, s = 100, c = (e) => (r) => /^\d+$/.test(r) && Number(r) >= 1 && Number(r) <= e, o = c(A), u = 75, d = (e) => {
13
+ const r = E(e?.credit_card_close_to_limit_percentage), t = r === void 0 ? void 0 : Math.round(r);
14
+ return t !== void 0 && t >= 1 && t <= s ? t : u;
15
+ }, _ = (e) => ({
16
+ read: ({ insightProfile: r }) => r?.[e],
17
+ save: (r) => ["updateUserInsightProfile", { fields: { [e]: r } }],
18
+ hasSource: ({ insightProfile: r }) => !!r,
19
+ needsNotificationProfiles: !1
20
+ }), N = {
21
+ read: ({ lowBalanceProfile: e }) => e?.threshold,
22
+ save: (e, { lowBalanceProfile: r }) => ["updateNotificationProfileThreshold", {
23
+ profileGuid: r?.guid,
24
+ threshold: e
25
+ }],
26
+ hasSource: ({ lowBalanceProfile: e }) => !!e,
27
+ needsNotificationProfiles: !0
28
+ }, n = {
29
+ save: a.EDIT_INSIGHT_THRESHOLD_SAVE,
30
+ cancel: a.EDIT_INSIGHT_THRESHOLD_CANCELED,
31
+ inputSelected: a.EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED
32
+ }, L = {
33
+ [i.LOW_BALANCE_THRESHOLD]: {
34
+ ...N,
35
+ isValid: o,
36
+ errorKey: "whole_number_error",
37
+ unit: "currency",
38
+ hasCancel: !0,
39
+ hasEditCopy: !1,
40
+ showsAccount: !0,
41
+ analytics: n
42
+ },
43
+ [i.SAFETY_NET]: {
44
+ ..._("savings_opportunity_minimum_checking_account_balance"),
45
+ isValid: o,
46
+ errorKey: "whole_number_error",
47
+ unit: "currency",
48
+ hasCancel: !1,
49
+ hasEditCopy: !0,
50
+ showsAccount: !1,
51
+ analytics: {
52
+ save: a.EDIT_SAFETY_NET_SAVE,
53
+ cancel: a.EDIT_SAFETY_NET_CANCEL
54
+ }
55
+ },
56
+ [i.CREDIT_LIMIT_PERCENTAGE]: {
57
+ ..._("credit_card_close_to_limit_percentage"),
58
+ read: ({ insightProfile: e }) => d(e),
59
+ isValid: c(s),
60
+ errorKey: "percentage_error",
61
+ unit: "percent",
62
+ hasCancel: !0,
63
+ hasEditCopy: !1,
64
+ showsAccount: !1,
65
+ analytics: n
66
+ }
67
+ }, m = (e) => e ? String(Math.round(e)) : "", D = (e, r) => r ? e.find((t) => t.entity_guid === r && t.notification_type === T.AccountBalanceLow) : void 0;
10
68
  export {
11
- e as AMOUNT_INPUT_VARIANTS,
12
- T as CREATE_BUDGET_VARIANT,
13
- E as findLowBalanceProfile,
14
- u as isAmountInputVariant,
15
- c as isWholeAmount,
16
- N as resolveAmountInputVariant,
17
- v as toInputValue
69
+ i as AMOUNT_INPUT_VARIANTS,
70
+ L as AMOUNT_SETTINGS,
71
+ C as CREATE_BUDGET_VARIANT,
72
+ D as findLowBalanceProfile,
73
+ f as isAmountInputVariant,
74
+ o as isWholeAmount,
75
+ p as resolveAmountInputVariant,
76
+ d as resolveCreditLimitAlertPercent,
77
+ m as toInputValue
18
78
  };
19
79
 
20
80
  //# sourceMappingURL=layout.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/layout.ts"],"sourcesContent":["import type { NotificationProfile } from '../../../core'\nimport { AccountNotificationTypes } from '../../../core/types/Notification'\nimport { actionBlocksKey } from '../../mappings/actionBlocksKey'\n\n/** CTA variants `amount_input_modal_block` serves (ditto sets one on the beat's CTA). */\nexport const AMOUNT_INPUT_VARIANTS = {\n LOW_BALANCE_THRESHOLD: 'low_balance_threshold',\n SAFETY_NET: 'safety_net',\n} as const\n\n/** Opens the Create Budget dialog instead of an amount setting (Category Spending). */\nexport const CREATE_BUDGET_VARIANT = 'create_budget'\n\nexport type AmountInputVariant = (typeof AMOUNT_INPUT_VARIANTS)[keyof typeof AMOUNT_INPUT_VARIANTS]\n\nexport const isAmountInputVariant = (variant?: string | null): variant is AmountInputVariant =>\n Object.values<string>(AMOUNT_INPUT_VARIANTS).includes(variant ?? '')\n\n/**\n * The variant the modal edits, from the CTA that opened it. ditto drives the shared\n * `amount_input_modal_block` by an explicit CTA variant, but gives Savings Opportunity's safety-net\n * reminder a dedicated `safety_net_block` with no variant, so there the block name selects it. An\n * explicit variant always wins (so an unknown one still falls to the block's \"unknown variant\" path).\n */\nexport const resolveAmountInputVariant = (cta?: {\n block?: string | null\n variant?: string | null\n}): string | undefined => {\n if (cta?.variant) return cta.variant\n if (cta?.block === actionBlocksKey.SAFETY_NET_ACTION_BLOCK)\n return AMOUNT_INPUT_VARIANTS.SAFETY_NET\n return undefined\n}\n\n/** Pulse v1's upper bound for a safety net; applied to both variants. */\nconst MAX_AMOUNT = 1_000_000_000\n\n/** Whole dollars from 1 to `MAX_AMOUNT`, as pulse v1 accepted for both settings. */\nexport const isWholeAmount = (value: string): boolean =>\n /^\\d+$/.test(value) && Number(value) >= 1 && Number(value) <= MAX_AMOUNT\n\n/** A saved amount as the field's starting text; nothing saved (or zero) starts empty. */\nexport const toInputValue = (amount?: number | null): string =>\n amount ? String(Math.round(amount)) : ''\n\n/** The account's low-balance alert profile, which holds the threshold (as pulse v1 looked it up). */\nexport const findLowBalanceProfile = (\n profiles: NotificationProfile[],\n accountGuid?: string | null,\n): NotificationProfile | undefined =>\n accountGuid\n ? profiles.find(\n (profile) =>\n profile.entity_guid === accountGuid &&\n profile.notification_type === AccountNotificationTypes.AccountBalanceLow,\n )\n : undefined\n"],"mappings":";;AAKA,IAAa,IAAwB;AAAA,EACnC,uBAAuB;AAAA,EACvB,YAAY;AACd,GAGa,IAAwB,iBAIxB,IAAA,CAAwB,MACnC,OAAO,OAAe,CAAqB,EAAE,SAAS,KAAW,EAAE,GAQxD,IAAA,CAA6B,MAGhB;AACxB,MAAI,GAAK,QAAS,QAAO,EAAI;AAC7B,MAAI,GAAK,UAAU,EAAgB,wBACjC,QAAO,EAAsB;AAEjC,GAGM,IAAa,KAGN,IAAA,CAAiB,MAC5B,QAAQ,KAAK,CAAK,KAAK,OAAO,CAAK,KAAK,KAAK,OAAO,CAAK,KAAK,GAGnD,IAAA,CAAgB,MAC3B,IAAS,OAAO,KAAK,MAAM,CAAM,CAAC,IAAI,IAG3B,IAAA,CACX,GACA,MAEA,IACI,EAAS,KAAA,CACN,MACC,EAAQ,gBAAgB,KACxB,EAAQ,sBAAsB,EAAyB,iBAC3D,IACA"}
1
+ {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/layout.ts"],"sourcesContent":["import type { NotificationProfile, UserInsightProfile } from '../../../core'\nimport { AccountNotificationTypes } from '../../../core/types/Notification'\nimport {\n ANALYTICS_EVENTS_CONFIG,\n type AnalyticsEventConfigEntry,\n} from '../../analytics/analyticsEventsConfig'\nimport type { CtaHandlerName } from '../../ctaActions/ctaHandlers'\nimport { actionBlocksKey } from '../../mappings/actionBlocksKey'\nimport { asNumber } from '../../blocks/slotReaders'\nimport type { CurrencyDialogUnit } from '../../../common/components'\n\n/** CTA variants `amount_input_modal_block` serves (ditto sets one on the beat's CTA). */\nexport const AMOUNT_INPUT_VARIANTS = {\n LOW_BALANCE_THRESHOLD: 'low_balance_threshold',\n SAFETY_NET: 'safety_net',\n CREDIT_LIMIT_PERCENTAGE: 'credit_limit_percentage',\n} as const\n\n/** Opens the Create Budget dialog instead of an amount setting (Category Spending). */\nexport const CREATE_BUDGET_VARIANT = 'create_budget'\n\nexport type AmountInputVariant = (typeof AMOUNT_INPUT_VARIANTS)[keyof typeof AMOUNT_INPUT_VARIANTS]\n\nexport const isAmountInputVariant = (variant?: string | null): variant is AmountInputVariant =>\n Object.values<string>(AMOUNT_INPUT_VARIANTS).includes(variant ?? '')\n\n/**\n * The variant the modal edits, from the CTA that opened it. ditto drives the shared\n * `amount_input_modal_block` by an explicit CTA variant, but gives Savings Opportunity's safety-net\n * reminder a dedicated `safety_net_block` with no variant, so there the block name selects it. An\n * explicit variant always wins (so an unknown one still falls to the block's \"unknown variant\" path).\n */\nexport const resolveAmountInputVariant = (cta?: {\n block?: string | null\n variant?: string | null\n}): string | undefined => {\n if (cta?.variant) return cta.variant\n if (cta?.block === actionBlocksKey.SAFETY_NET_ACTION_BLOCK)\n return AMOUNT_INPUT_VARIANTS.SAFETY_NET\n return undefined\n}\n\n/** Pulse v1's upper bound for a safety net; applied to both dollar settings. */\nconst MAX_AMOUNT = 1_000_000_000\n\nconst MAX_ALERT_PERCENT = 100\n\n/** A whole number from 1 to `max`, as pulse v1 validated its amount and threshold fields. */\nconst wholeNumberUpTo =\n (max: number) =>\n (value: string): boolean =>\n /^\\d+$/.test(value) && Number(value) >= 1 && Number(value) <= max\n\n/** Whole dollars from 1 to `MAX_AMOUNT`, as pulse v1 accepted for its dollar settings. */\nexport const isWholeAmount = wholeNumberUpTo(MAX_AMOUNT)\n\n/** tupac's default `credit_card_close_to_limit_percentage`, used when none (or an invalid one) is saved. */\nconst DEFAULT_CREDIT_LIMIT_ALERT_PERCENT = 75\n\n/** The user's credit-limit alert as a whole 1-100 percent, else the default; the dialog and the Spending header both read it. */\nexport const resolveCreditLimitAlertPercent = (\n profile?: Pick<UserInsightProfile, 'credit_card_close_to_limit_percentage'> | null,\n): number => {\n const saved = asNumber(profile?.credit_card_close_to_limit_percentage)\n // Rounded like the dialog's whole-number field, so a saved 60.6 shows 61 in both.\n const percent = saved === undefined ? undefined : Math.round(saved)\n return percent !== undefined && percent >= 1 && percent <= MAX_ALERT_PERCENT\n ? percent\n : DEFAULT_CREDIT_LIMIT_ALERT_PERCENT\n}\n\n/** A user insight profile field a variant prefills from and saves to. */\ntype InsightProfileField = keyof Pick<\n UserInsightProfile,\n 'savings_opportunity_minimum_checking_account_balance' | 'credit_card_close_to_limit_percentage'\n>\n\n/** Where a setting's value can live; the dialog loads both and each variant reads its own. */\ninterface AmountSources {\n insightProfile?: UserInsightProfile | null\n lowBalanceProfile?: NotificationProfile\n}\n\n/** A saved value read and written on a user insight profile field. */\nconst insightProfileField = (field: InsightProfileField) => ({\n read: ({ insightProfile }: AmountSources) => insightProfile?.[field],\n save: (amount: number): [CtaHandlerName, Record<string, unknown>] => [\n 'updateUserInsightProfile',\n { fields: { [field]: amount } },\n ],\n hasSource: ({ insightProfile }: AmountSources) => !!insightProfile,\n needsNotificationProfiles: false,\n})\n\n/** The account's low-balance alert threshold, on its notification profile. */\nconst lowBalanceThreshold = {\n read: ({ lowBalanceProfile }: AmountSources) => lowBalanceProfile?.threshold,\n save: (\n amount: number,\n { lowBalanceProfile }: AmountSources,\n ): [CtaHandlerName, Record<string, unknown>] => [\n 'updateNotificationProfileThreshold',\n { profileGuid: lowBalanceProfile?.guid, threshold: amount },\n ],\n hasSource: ({ lowBalanceProfile }: AmountSources) => !!lowBalanceProfile,\n needsNotificationProfiles: true,\n}\n\n/** What one variant edits, how it validates and words its field, and the pulse analytics it fires. */\ninterface AmountSetting {\n /** The saved value, from the setting's own source. */\n read: (sources: AmountSources) => number | null | undefined\n /** The CTA handler and params that save `amount`. */\n save: (amount: number, sources: AmountSources) => [CtaHandlerName, Record<string, unknown>]\n /** Whether the source the setting edits is loaded; without it the dialog shows the plain error. */\n hasSource: (sources: AmountSources) => boolean\n /** The source is the account's notification profile, which the dialog reloads on open. */\n needsNotificationProfiles: boolean\n isValid: (value: string) => boolean\n /** The `insights_feed.amount_input_modal` key of the validation message. */\n errorKey: 'whole_number_error' | 'percentage_error'\n unit: CurrencyDialogUnit\n hasCancel: boolean\n /** Switches to `title_edit` / `description_edit` once a value is saved. */\n hasEditCopy: boolean\n /** The account line under the title. */\n showsAccount: boolean\n analytics: {\n save: AnalyticsEventConfigEntry\n cancel: AnalyticsEventConfigEntry\n /** Pulse fires input-selected for the threshold dialogs only (EditThreshold.js). */\n inputSelected?: AnalyticsEventConfigEntry\n }\n}\n\nconst THRESHOLD_ANALYTICS = {\n save: ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_SAVE,\n cancel: ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_CANCELED,\n inputSelected: ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED,\n}\n\n/** Per-variant behaviour of the amount setting dialog; a new variant adds an entry here. */\nexport const AMOUNT_SETTINGS: Record<AmountInputVariant, AmountSetting> = {\n [AMOUNT_INPUT_VARIANTS.LOW_BALANCE_THRESHOLD]: {\n ...lowBalanceThreshold,\n isValid: isWholeAmount,\n errorKey: 'whole_number_error',\n unit: 'currency',\n hasCancel: true,\n hasEditCopy: false,\n showsAccount: true,\n analytics: THRESHOLD_ANALYTICS,\n },\n [AMOUNT_INPUT_VARIANTS.SAFETY_NET]: {\n ...insightProfileField('savings_opportunity_minimum_checking_account_balance'),\n isValid: isWholeAmount,\n errorKey: 'whole_number_error',\n unit: 'currency',\n hasCancel: false,\n hasEditCopy: true,\n showsAccount: false,\n analytics: {\n save: ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_SAVE,\n cancel: ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_CANCEL,\n },\n },\n [AMOUNT_INPUT_VARIANTS.CREDIT_LIMIT_PERCENTAGE]: {\n ...insightProfileField('credit_card_close_to_limit_percentage'),\n // Same rule as the Spending header's marker, so the field and the marker always agree.\n read: ({ insightProfile }) => resolveCreditLimitAlertPercent(insightProfile),\n isValid: wholeNumberUpTo(MAX_ALERT_PERCENT),\n errorKey: 'percentage_error',\n unit: 'percent',\n hasCancel: true,\n hasEditCopy: false,\n showsAccount: false,\n analytics: THRESHOLD_ANALYTICS,\n },\n}\n\n/** A saved amount as the field's starting text; nothing saved (or zero) starts empty. */\nexport const toInputValue = (amount?: number | null): string =>\n amount ? String(Math.round(amount)) : ''\n\n/** The account's low-balance alert profile, which holds the threshold (as pulse v1 looked it up). */\nexport const findLowBalanceProfile = (\n profiles: NotificationProfile[],\n accountGuid?: string | null,\n): NotificationProfile | undefined =>\n accountGuid\n ? profiles.find(\n (profile) =>\n profile.entity_guid === accountGuid &&\n profile.notification_type === AccountNotificationTypes.AccountBalanceLow,\n )\n : undefined\n"],"mappings":";;;;AAYA,IAAa,IAAwB;AAAA,EACnC,uBAAuB;AAAA,EACvB,YAAY;AAAA,EACZ,yBAAyB;AAC3B,GAGa,IAAwB,iBAIxB,IAAA,CAAwB,MACnC,OAAO,OAAe,CAAqB,EAAE,SAAS,KAAW,EAAE,GAQ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AU;AAAA,IACV,MAAM;AAAA,IACN,WAAW;AAAA,IACX,aAAa;AAAA,IACb,cAAc;AAAA,IACd,WAAW;AAAA,EACb;AAAA,EACC,CAAA,EAAsB,UAAA,GAAa;AAAA,IAClC,GAAG,EAAoB,sDAAsD;AAAA,IAC7E,SAAS;AAAA,IACT,UAAU;AAAA,IACV,MAAM;AAAA,IACN,WAAW;AAAA,IACX,aAAa;AAAA,IACb,cAAc;AAAA,IACd,WAAW;AAAA,MACT,MAAM,EAAwB;AAAA,MAC9B,QAAQ,EAAwB;AAAA,IAClC;AAAA,EACF;AAAA,EACC,CAAA,EAAsB,uBAAA,GAA0B;AAAA,IAC/C,GAAG,EAAoB,uCAAuC;AAAA,IAE9D,MAAA,CAAO,EAAE,gBAAA,EAAA,MAAqB,EAA+B,CAAc;AAAA,IAC3E,SAAS,EAAgB,CAAiB;AAAA,IAC1C,UAAU;AAAA,IACV,MAAM;AAAA,IACN,WAAW;AAAA,IACX,aAAa;AAAA,IACb,cAAc;AAAA,IACd,WAAW;AAAA,EACb;AACF,GAGa,IAAA,CAAgB,MAC3B,IAAS,OAAO,KAAK,MAAM,CAAM,CAAC,IAAI,IAG3B,IAAA,CACX,GACA,MAEA,IACI,EAAS,KAAA,CACN,MACC,EAAQ,gBAAgB,KACxB,EAAQ,sBAAsB,EAAyB,iBAC3D,IACA"}
@@ -1,4 +1,6 @@
1
+ import { GlobalCopy } from '../../../core';
1
2
  import { ActionBlockProps } from '../../mappings/blocks';
3
+ export declare const selectBudgetDetailsCopy: (copy: GlobalCopy) => import('../../../core/types/localization/InsightsFeedCopy').BudgetDetailsCopy | undefined;
2
4
  export declare const BudgetDetailsBlock: (({ beat }: ActionBlockProps) => import("react/jsx-runtime").JSX.Element) & {
3
5
  displayName: string;
4
6
  };