@mx-cartographer/experiences 9.6.14 → 9.7.0
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.
- package/CHANGELOG.md +14 -0
- package/dist/core/types/Insights.d.ts +3 -2
- package/dist/core/types/Insights.es.js.map +1 -1
- package/dist/core/types/localization/InsightsFeedCopy.d.ts +2 -0
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js +67 -67
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.d.ts +16 -12
- package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.es.js +67 -46
- package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/layout.d.ts +17 -0
- package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/layout.es.js +24 -0
- package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/layout.es.js.map +1 -0
- package/dist/insights-v2/components/BaseLayout.es.js +1 -1
- package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
- package/dist/insights-v2/components/TransactionListCard.es.js +15 -14
- package/dist/insights-v2/components/TransactionListCard.es.js.map +1 -1
- package/dist/insights-v2/components/statusIcon.d.ts +8 -0
- package/dist/insights-v2/components/statusIcon.es.js +11 -6
- package/dist/insights-v2/components/statusIcon.es.js.map +1 -1
- package/dist/insights-v2/ctaActions/ctaPostMessages.es.js +15 -14
- package/dist/insights-v2/ctaActions/ctaPostMessages.es.js.map +1 -1
- package/dist/insights-v2/index.es.js +18 -18
- package/dist/microinsights/cards/InsightCard.es.js +38 -38
- package/dist/microinsights/cards/InsightCard.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { slot as
|
|
1
|
+
import { slot as T } from "../../core/types/Insights.es.js";
|
|
2
2
|
import { resolveInsightRender as S } from "../../insights-v2/resolveInsightRender.es.js";
|
|
3
3
|
import F from "../../insights-v2/components/LogoFromGuid.es.js";
|
|
4
4
|
import O from "../../insights-v2/components/InsightErrorCard.es.js";
|
|
5
|
-
import { ON_CLICK_EVENT as
|
|
6
|
-
import
|
|
5
|
+
import { ON_CLICK_EVENT as v, ON_VIEW_EVENT as A, ON_VIEW_FIRST_TIME_EVENT as L } from "../constants/Analytics.es.js";
|
|
6
|
+
import V from "../beaticons/BeatMaterialIcon.es.js";
|
|
7
7
|
import { BeatIcon as j } from "../beaticons/BeatIcon.es.js";
|
|
8
|
-
import { useCopyStore as
|
|
9
|
-
import
|
|
10
|
-
import { statusIconName as
|
|
11
|
-
import { useEffect as
|
|
8
|
+
import { useCopyStore as w, useEvent as z, useInsightsMicroWidgetStore as G } from "../context/hooks.es.js";
|
|
9
|
+
import k from "../MicroCardTemplate.es.js";
|
|
10
|
+
import { statusIconName as K, statusIconPalette as Z } from "../../insights-v2/components/statusIcon.es.js";
|
|
11
|
+
import { useEffect as x } from "react";
|
|
12
12
|
import { jsx as o } from "react/jsx-runtime";
|
|
13
|
-
import { alpha as
|
|
14
|
-
import
|
|
15
|
-
import { useInView as
|
|
16
|
-
var
|
|
17
|
-
const { ref: _, inView: m } =
|
|
18
|
-
|
|
19
|
-
m && (i.has_been_displayed ? d(A(i.template)) : (i.guid.startsWith("OFR") ?
|
|
13
|
+
import { alpha as B, useTheme as $ } from "@mui/material/styles";
|
|
14
|
+
import q from "@mui/material/Box";
|
|
15
|
+
import { useInView as D } from "react-intersection-observer";
|
|
16
|
+
var H = 32, li = ({ ariaLabel: a, beat: i, elevation: g, index: c, isActiveCard: l, onCardClick: u, posthog: r, widthOverrides: n, variant: f, showIcon: h, heightOverrides: p }) => {
|
|
17
|
+
const { ref: _, inView: m } = D({ threshold: 1 }), I = $(), { cardsCopy: M } = w(), { onEvent: d } = z(), { updateBeat: P, updateOffer: R } = G();
|
|
18
|
+
x(() => {
|
|
19
|
+
m && (i.has_been_displayed ? d(A(i.template)) : (i.guid.startsWith("OFR") ? R({
|
|
20
20
|
...i,
|
|
21
21
|
has_been_displayed: !0
|
|
22
|
-
}) :
|
|
22
|
+
}) : P({
|
|
23
23
|
...i,
|
|
24
24
|
has_been_displayed: !0
|
|
25
25
|
}), d(L(i.template))));
|
|
26
|
-
}, [m]),
|
|
26
|
+
}, [m]), x(() => {
|
|
27
27
|
if (m && i) if (i.template === "MarketingOffer") {
|
|
28
28
|
const t = i;
|
|
29
29
|
r?.capture("viewed_messaging_insight", {
|
|
@@ -43,8 +43,8 @@ var q = 32, si = ({ ariaLabel: s, beat: i, elevation: g, index: c, isActiveCard:
|
|
|
43
43
|
c,
|
|
44
44
|
m
|
|
45
45
|
]);
|
|
46
|
-
const
|
|
47
|
-
if (u && u(i), d(
|
|
46
|
+
const s = () => {
|
|
47
|
+
if (u && u(i), d(v(i.template)), i.template === "MarketingOffer") {
|
|
48
48
|
const t = i;
|
|
49
49
|
r?.capture("clicked_messaging_insight", {
|
|
50
50
|
template: i.template,
|
|
@@ -59,9 +59,9 @@ var q = 32, si = ({ ariaLabel: s, beat: i, elevation: g, index: c, isActiveCard:
|
|
|
59
59
|
position: c
|
|
60
60
|
});
|
|
61
61
|
}, y = S(i), e = y === "v2" ? i.insights_payload : void 0;
|
|
62
|
-
if (y === "error") return /* @__PURE__ */ o(
|
|
62
|
+
if (y === "error") return /* @__PURE__ */ o(q, {
|
|
63
63
|
"aria-hidden": !l,
|
|
64
|
-
"aria-label":
|
|
64
|
+
"aria-label": a,
|
|
65
65
|
"aria-roledescription": "slide",
|
|
66
66
|
ref: _,
|
|
67
67
|
role: "group",
|
|
@@ -73,27 +73,27 @@ var q = 32, si = ({ ariaLabel: s, beat: i, elevation: g, index: c, isActiveCard:
|
|
|
73
73
|
children: /* @__PURE__ */ o(O, { beat: i })
|
|
74
74
|
});
|
|
75
75
|
if (e) {
|
|
76
|
-
const t =
|
|
77
|
-
return /* @__PURE__ */ o(
|
|
76
|
+
const t = T(e.instance_slot.data, "logo"), E = T(e.instance_slot.data, "icon"), C = K(E?.guid), N = Z(E?.color), W = e.primary_cta?.label || e.in_description_cta?.label || void 0;
|
|
77
|
+
return /* @__PURE__ */ o(k, {
|
|
78
78
|
"aria-roledescription": "slide",
|
|
79
|
-
ariaLabel:
|
|
79
|
+
ariaLabel: a,
|
|
80
80
|
description: e.description.html_text,
|
|
81
81
|
elevation: g,
|
|
82
82
|
heightOverrides: p,
|
|
83
83
|
icon: h && (t ? /* @__PURE__ */ o(F, {
|
|
84
84
|
logo: t,
|
|
85
|
-
size:
|
|
86
|
-
}) :
|
|
87
|
-
bgColor:
|
|
88
|
-
iconColor:
|
|
89
|
-
name:
|
|
90
|
-
}) : /* @__PURE__ */ o(
|
|
91
|
-
bgColor:
|
|
85
|
+
size: H
|
|
86
|
+
}) : C ? /* @__PURE__ */ o(V, {
|
|
87
|
+
bgColor: B(I.palette[N].main, 0.15),
|
|
88
|
+
iconColor: N,
|
|
89
|
+
name: C
|
|
90
|
+
}) : /* @__PURE__ */ o(V, {
|
|
91
|
+
bgColor: B(I.palette.primary.main, 0.15),
|
|
92
92
|
name: "lightbulb"
|
|
93
93
|
})),
|
|
94
94
|
isActiveCard: l,
|
|
95
|
-
onCardClick:
|
|
96
|
-
onPrimaryAction:
|
|
95
|
+
onCardClick: s,
|
|
96
|
+
onPrimaryAction: s,
|
|
97
97
|
primaryActionText: W,
|
|
98
98
|
ref: _,
|
|
99
99
|
title: e.title ?? "",
|
|
@@ -101,17 +101,17 @@ var q = 32, si = ({ ariaLabel: s, beat: i, elevation: g, index: c, isActiveCard:
|
|
|
101
101
|
widthOverrides: n
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
|
-
return /* @__PURE__ */ o(
|
|
104
|
+
return /* @__PURE__ */ o(k, {
|
|
105
105
|
"aria-roledescription": "slide",
|
|
106
|
-
ariaLabel:
|
|
106
|
+
ariaLabel: a,
|
|
107
107
|
description: i?.html_micro_description && i?.html_micro_description.length > 0 ? i.html_micro_description : i.html_description || "",
|
|
108
108
|
elevation: g,
|
|
109
109
|
heightOverrides: p,
|
|
110
110
|
icon: h && /* @__PURE__ */ o(j, { beat: i }),
|
|
111
111
|
isActiveCard: l,
|
|
112
|
-
onCardClick:
|
|
113
|
-
onPrimaryAction:
|
|
114
|
-
primaryActionText: i.micro_call_to_action ||
|
|
112
|
+
onCardClick: s,
|
|
113
|
+
onPrimaryAction: s,
|
|
114
|
+
primaryActionText: i.micro_call_to_action || M?.micro_card_cta,
|
|
115
115
|
ref: _,
|
|
116
116
|
title: i.micro_title && i.micro_title.length > 0 ? i.micro_title : i.title,
|
|
117
117
|
variant: f,
|
|
@@ -119,7 +119,7 @@ var q = 32, si = ({ ariaLabel: s, beat: i, elevation: g, index: c, isActiveCard:
|
|
|
119
119
|
});
|
|
120
120
|
};
|
|
121
121
|
export {
|
|
122
|
-
|
|
122
|
+
li as InsightCard
|
|
123
123
|
};
|
|
124
124
|
|
|
125
125
|
//# sourceMappingURL=InsightCard.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InsightCard.es.js","names":[],"sources":["../../../src/microinsights/cards/InsightCard.tsx"],"sourcesContent":["import React, { useEffect } from 'react'\nimport { useInView } from 'react-intersection-observer'\n\nimport Box from '@mui/material/Box'\nimport { alpha, useTheme } from '@mui/material/styles'\n\nimport { BeatIcon } from '../beaticons'\nimport BeatMaterialIcon from '../beaticons/BeatMaterialIcon'\n\nimport { useCopyStore, useEvent, useInsightsMicroWidgetStore } from '../context/hooks'\n\nimport { ON_CLICK_EVENT, ON_VIEW_EVENT, ON_VIEW_FIRST_TIME_EVENT } from '../constants/Analytics'\nimport { VIEW_THRESHOLD } from '../constants/App'\n\nimport type { BeatLikeOffer, MicroInsightCardProps } from '../interfaces'\nimport type { Beat } from '../../core/types/Beat'\n// Leaf imports, not the `core` barrel: that pulls GlobalStore and every feature store into the\n// micro bundle, and through `core/stores` it reintroduces a circular path this module avoids.\nimport { slot } from '../../core/types/Insights'\nimport type { LogoRef } from '../../core/types/Insights'\nimport MicroCardTemplate from '../MicroCardTemplate'\n// Leaf imports on purpose: the `insights-v2` barrel pulls in `mappings/blocks` and its charts.\nimport InsightErrorCard from '../../insights-v2/components/InsightErrorCard'\nimport LogoFromGuid from '../../insights-v2/components/LogoFromGuid'\nimport { statusIconName } from '../../insights-v2/components/statusIcon'\nimport { resolveInsightRender } from '../../insights-v2/resolveInsightRender'\n\n/** The legacy micro card's icon tile size (BeatMaterialIcon). */\nconst ICON_SIZE = 32\n\nexport interface InsightCardProps extends MicroInsightCardProps {\n beat: Beat | BeatLikeOffer\n index?: number\n}\n\nexport const InsightCard: React.FC<InsightCardProps> = ({\n ariaLabel,\n beat,\n elevation,\n index,\n isActiveCard,\n onCardClick,\n posthog,\n widthOverrides,\n variant,\n showIcon,\n heightOverrides,\n}) => {\n const { ref, inView } = useInView({\n threshold: VIEW_THRESHOLD,\n })\n\n const theme = useTheme()\n\n // *************** Context functions *********************\n const { cardsCopy } = useCopyStore()\n const { onEvent } = useEvent()\n const { updateBeat, updateOffer } = useInsightsMicroWidgetStore()\n\n // ************** Use Effects Hooks **********************\n useEffect(() => {\n if (inView) {\n if (!beat.has_been_displayed) {\n if (beat.guid.startsWith('OFR')) {\n updateOffer({\n ...beat,\n has_been_displayed: true,\n })\n } else {\n updateBeat({\n ...beat,\n has_been_displayed: true,\n })\n }\n onEvent(ON_VIEW_FIRST_TIME_EVENT(beat.template))\n } else {\n onEvent(ON_VIEW_EVENT(beat.template))\n }\n }\n }, [inView])\n\n useEffect(() => {\n if (inView && beat) {\n if (beat.template === 'MarketingOffer') {\n const offerBeat = beat as BeatLikeOffer\n posthog?.capture('viewed_messaging_insight', {\n template: beat.template,\n campaign_guid: offerBeat.campaign_guid,\n campaign_name: offerBeat.pulse_campaign_name,\n offer_guid: offerBeat.guid,\n user_guid: offerBeat.user_guid,\n })\n } else {\n posthog?.capture('viewed_insight', {\n beat_guid: beat.guid,\n template: beat.template,\n position: index,\n })\n }\n }\n }, [beat, index, inView])\n\n // *************** Click handlers ************************\n const handleClick = () => {\n /* eslint-disable no-unused-expressions */\n onCardClick && onCardClick(beat)\n onEvent(ON_CLICK_EVENT(beat.template))\n\n if (beat.template === 'MarketingOffer') {\n const offerBeat = beat as BeatLikeOffer\n posthog?.capture('clicked_messaging_insight', {\n template: beat.template,\n campaign_guid: offerBeat.campaign_guid,\n campaign_name: offerBeat.pulse_campaign_name,\n offer_guid: offerBeat.guid,\n user_guid: offerBeat.user_guid,\n })\n } else {\n posthog?.capture('clicked_insight', {\n beat_guid: beat.guid,\n template: beat.template,\n position: index,\n })\n }\n }\n\n const insightRender = resolveInsightRender(beat as Beat)\n const v2Payload = insightRender === 'v2' ? beat.insights_payload : undefined\n\n if (insightRender === 'error') {\n // Keeps the carousel's slot sizing; the error card does not know about it.\n return (\n <Box\n aria-hidden={!isActiveCard}\n aria-label={ariaLabel}\n aria-roledescription=\"slide\"\n ref={ref}\n role=\"group\"\n sx={{\n height: heightOverrides ? '100%' : 120,\n minWidth: widthOverrides ? `${widthOverrides}px` : '100%',\n my: 1,\n }}\n >\n <InsightErrorCard beat={beat} />\n </Box>\n )\n }\n\n if (v2Payload) {\n // Figma (Micro Widget | Large Transaction) is the legacy micro card's layout fed from the envelope:\n // the slot's logo on the left (merchant, or the category without one), title, description, and the\n // primary CTA as a link. The logo falls back to the insight glyph when the slot carries none.\n // ditto ≥ 1.4.3 words micro's action as in_description_cta instead of primary_cta; either way\n // the label stays the card's tap (`micro-carousel/cta`), never a drawer.\n // A block with no row logo may name a status icon instead (account_block `minimal`: `ICO-error`),\n // drawn in the legacy card's tinted tile (Figma Micro | Low Account Balance).\n const rowLogo = slot<LogoRef>(v2Payload.instance_slot.data, 'logo')\n const statusIcon = slot<LogoRef>(v2Payload.instance_slot.data, 'icon')\n const statusName = statusIconName(statusIcon?.guid)\n const actionLabel = v2Payload.primary_cta?.label ?? v2Payload.in_description_cta?.label\n\n return (\n <MicroCardTemplate\n aria-roledescription=\"slide\"\n ariaLabel={ariaLabel}\n description={v2Payload.description.html_text}\n elevation={elevation}\n heightOverrides={heightOverrides}\n icon={\n showIcon &&\n (rowLogo ? (\n <LogoFromGuid logo={rowLogo} size={ICON_SIZE} />\n ) : statusName ? (\n <BeatMaterialIcon\n bgColor={alpha(theme.palette.error.main, 0.15)}\n iconColor=\"error\"\n name={statusName}\n />\n ) : (\n <BeatMaterialIcon bgColor={alpha(theme.palette.primary.main, 0.15)} name=\"lightbulb\" />\n ))\n }\n isActiveCard={isActiveCard}\n onCardClick={handleClick}\n onPrimaryAction={handleClick}\n primaryActionText={actionLabel}\n ref={ref}\n title={v2Payload.title ?? ''}\n variant={variant}\n widthOverrides={widthOverrides}\n />\n )\n }\n\n return (\n <MicroCardTemplate\n aria-roledescription=\"slide\"\n ariaLabel={ariaLabel}\n description={\n beat?.html_micro_description && beat?.html_micro_description.length > 0\n ? beat.html_micro_description\n : beat.html_description || ''\n }\n elevation={elevation}\n heightOverrides={heightOverrides}\n icon={showIcon && <BeatIcon beat={beat} />}\n isActiveCard={isActiveCard}\n onCardClick={handleClick}\n onPrimaryAction={handleClick}\n primaryActionText={beat.micro_call_to_action || cardsCopy?.micro_card_cta}\n ref={ref}\n title={beat.micro_title && beat.micro_title.length > 0 ? beat.micro_title : beat.title}\n variant={variant}\n widthOverrides={widthOverrides}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4BA,IAAM,IAAY,IAOL,KAAA,CAA2C,EACtD,WAAA,GACA,MAAA,GACA,WAAA,GACA,OAAA,GACA,cAAA,GACA,aAAA,GACA,SAAA,GACA,gBAAA,GACA,SAAA,GACA,UAAA,GACA,iBAAA,EAAA,MACI;AACJ,QAAM,EAAE,KAAA,GAAK,QAAA,EAAA,IAAW,EAAU,EAChC,WAAA,EACF,CAAC,GAEK,IAAQ,EAAS,GAGjB,EAAE,WAAA,EAAA,IAAc,EAAa,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iBAAiB;AAAA,MACjB,mBAAmB;AAAA,MACd,KAAA;AAAA,MACL,OAAO,EAAU,SAAS;AAAA,MACjB,SAAA;AAAA,MACO,gBAAA;AAAA,IACjB,CAAA;AAAA,EAEL;AAEA,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,wBAAqB;AAAA,IACV,WAAA;AAAA,IACX,aACE,GAAM,0BAA0B,GAAM,uBAAuB,SAAS,IAClE,EAAK,yBACL,EAAK,oBAAoB;AAAA,IAEpB,WAAA;AAAA,IACM,iBAAA;AAAA,IACjB,MAAM,KAAY,gBAAA,EAAC,GAAD,EAAgB,MAAA,EAAO,CAAA;AAAA,IAC3B,cAAA;AAAA,IACd,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,mBAAmB,EAAK,wBAAwB,GAAW;AAAA,IACtD,KAAA;AAAA,IACL,OAAO,EAAK,eAAe,EAAK,YAAY,SAAS,IAAI,EAAK,cAAc,EAAK;AAAA,IACxE,SAAA;AAAA,IACO,gBAAA;AAAA,EACjB,CAAA;AAEL"}
|
|
1
|
+
{"version":3,"file":"InsightCard.es.js","names":[],"sources":["../../../src/microinsights/cards/InsightCard.tsx"],"sourcesContent":["import React, { useEffect } from 'react'\nimport { useInView } from 'react-intersection-observer'\n\nimport Box from '@mui/material/Box'\nimport { alpha, useTheme } from '@mui/material/styles'\n\nimport { BeatIcon } from '../beaticons'\nimport BeatMaterialIcon from '../beaticons/BeatMaterialIcon'\n\nimport { useCopyStore, useEvent, useInsightsMicroWidgetStore } from '../context/hooks'\n\nimport { ON_CLICK_EVENT, ON_VIEW_EVENT, ON_VIEW_FIRST_TIME_EVENT } from '../constants/Analytics'\nimport { VIEW_THRESHOLD } from '../constants/App'\n\nimport type { BeatLikeOffer, MicroInsightCardProps } from '../interfaces'\nimport type { Beat } from '../../core/types/Beat'\n// Leaf imports, not the `core` barrel: that pulls GlobalStore and every feature store into the\n// micro bundle, and through `core/stores` it reintroduces a circular path this module avoids.\nimport { slot } from '../../core/types/Insights'\nimport type { LogoRef } from '../../core/types/Insights'\nimport MicroCardTemplate from '../MicroCardTemplate'\n// Leaf imports on purpose: the `insights-v2` barrel pulls in `mappings/blocks` and its charts.\nimport InsightErrorCard from '../../insights-v2/components/InsightErrorCard'\nimport LogoFromGuid from '../../insights-v2/components/LogoFromGuid'\nimport { statusIconName, statusIconPalette } from '../../insights-v2/components/statusIcon'\nimport { resolveInsightRender } from '../../insights-v2/resolveInsightRender'\n\n/** The legacy micro card's icon tile size (BeatMaterialIcon). */\nconst ICON_SIZE = 32\n\nexport interface InsightCardProps extends MicroInsightCardProps {\n beat: Beat | BeatLikeOffer\n index?: number\n}\n\nexport const InsightCard: React.FC<InsightCardProps> = ({\n ariaLabel,\n beat,\n elevation,\n index,\n isActiveCard,\n onCardClick,\n posthog,\n widthOverrides,\n variant,\n showIcon,\n heightOverrides,\n}) => {\n const { ref, inView } = useInView({\n threshold: VIEW_THRESHOLD,\n })\n\n const theme = useTheme()\n\n // *************** Context functions *********************\n const { cardsCopy } = useCopyStore()\n const { onEvent } = useEvent()\n const { updateBeat, updateOffer } = useInsightsMicroWidgetStore()\n\n // ************** Use Effects Hooks **********************\n useEffect(() => {\n if (inView) {\n if (!beat.has_been_displayed) {\n if (beat.guid.startsWith('OFR')) {\n updateOffer({\n ...beat,\n has_been_displayed: true,\n })\n } else {\n updateBeat({\n ...beat,\n has_been_displayed: true,\n })\n }\n onEvent(ON_VIEW_FIRST_TIME_EVENT(beat.template))\n } else {\n onEvent(ON_VIEW_EVENT(beat.template))\n }\n }\n }, [inView])\n\n useEffect(() => {\n if (inView && beat) {\n if (beat.template === 'MarketingOffer') {\n const offerBeat = beat as BeatLikeOffer\n posthog?.capture('viewed_messaging_insight', {\n template: beat.template,\n campaign_guid: offerBeat.campaign_guid,\n campaign_name: offerBeat.pulse_campaign_name,\n offer_guid: offerBeat.guid,\n user_guid: offerBeat.user_guid,\n })\n } else {\n posthog?.capture('viewed_insight', {\n beat_guid: beat.guid,\n template: beat.template,\n position: index,\n })\n }\n }\n }, [beat, index, inView])\n\n // *************** Click handlers ************************\n const handleClick = () => {\n /* eslint-disable no-unused-expressions */\n onCardClick && onCardClick(beat)\n onEvent(ON_CLICK_EVENT(beat.template))\n\n if (beat.template === 'MarketingOffer') {\n const offerBeat = beat as BeatLikeOffer\n posthog?.capture('clicked_messaging_insight', {\n template: beat.template,\n campaign_guid: offerBeat.campaign_guid,\n campaign_name: offerBeat.pulse_campaign_name,\n offer_guid: offerBeat.guid,\n user_guid: offerBeat.user_guid,\n })\n } else {\n posthog?.capture('clicked_insight', {\n beat_guid: beat.guid,\n template: beat.template,\n position: index,\n })\n }\n }\n\n const insightRender = resolveInsightRender(beat as Beat)\n const v2Payload = insightRender === 'v2' ? beat.insights_payload : undefined\n\n if (insightRender === 'error') {\n // Keeps the carousel's slot sizing; the error card does not know about it.\n return (\n <Box\n aria-hidden={!isActiveCard}\n aria-label={ariaLabel}\n aria-roledescription=\"slide\"\n ref={ref}\n role=\"group\"\n sx={{\n height: heightOverrides ? '100%' : 120,\n minWidth: widthOverrides ? `${widthOverrides}px` : '100%',\n my: 1,\n }}\n >\n <InsightErrorCard beat={beat} />\n </Box>\n )\n }\n\n if (v2Payload) {\n // Figma (Micro Widget | Large Transaction) is the legacy micro card's layout fed from the envelope:\n // the slot's logo on the left (merchant, or the category without one), title, description, and the\n // primary CTA as a link. The logo falls back to the insight glyph when the slot carries none.\n // ditto ≥ 1.4.3 words micro's action as in_description_cta instead of primary_cta; either way\n // the label stays the card's tap (`micro-carousel/cta`), never a drawer.\n // A block with no row logo may name a status icon instead (account_block `minimal`: `ICO-error`),\n // drawn in the legacy card's tinted tile (Figma Micro | Low Account Balance).\n // The status tile takes the palette the slot names (Payday's on-track check is `success.main`),\n // falling back to error. `||` on the label: the copy may send the primary label as \"\".\n const rowLogo = slot<LogoRef>(v2Payload.instance_slot.data, 'logo')\n const statusIcon = slot<LogoRef>(v2Payload.instance_slot.data, 'icon')\n const statusName = statusIconName(statusIcon?.guid)\n const statusPalette = statusIconPalette(statusIcon?.color)\n const actionLabel =\n v2Payload.primary_cta?.label || v2Payload.in_description_cta?.label || undefined\n\n return (\n <MicroCardTemplate\n aria-roledescription=\"slide\"\n ariaLabel={ariaLabel}\n description={v2Payload.description.html_text}\n elevation={elevation}\n heightOverrides={heightOverrides}\n icon={\n showIcon &&\n (rowLogo ? (\n <LogoFromGuid logo={rowLogo} size={ICON_SIZE} />\n ) : statusName ? (\n <BeatMaterialIcon\n bgColor={alpha(theme.palette[statusPalette].main, 0.15)}\n iconColor={statusPalette}\n name={statusName}\n />\n ) : (\n <BeatMaterialIcon bgColor={alpha(theme.palette.primary.main, 0.15)} name=\"lightbulb\" />\n ))\n }\n isActiveCard={isActiveCard}\n onCardClick={handleClick}\n onPrimaryAction={handleClick}\n primaryActionText={actionLabel}\n ref={ref}\n title={v2Payload.title ?? ''}\n variant={variant}\n widthOverrides={widthOverrides}\n />\n )\n }\n\n return (\n <MicroCardTemplate\n aria-roledescription=\"slide\"\n ariaLabel={ariaLabel}\n description={\n beat?.html_micro_description && beat?.html_micro_description.length > 0\n ? beat.html_micro_description\n : beat.html_description || ''\n }\n elevation={elevation}\n heightOverrides={heightOverrides}\n icon={showIcon && <BeatIcon beat={beat} />}\n isActiveCard={isActiveCard}\n onCardClick={handleClick}\n onPrimaryAction={handleClick}\n primaryActionText={beat.micro_call_to_action || cardsCopy?.micro_card_cta}\n ref={ref}\n title={beat.micro_title && beat.micro_title.length > 0 ? beat.micro_title : beat.title}\n variant={variant}\n widthOverrides={widthOverrides}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4BA,IAAM,IAAY,IAOL,KAAA,CAA2C,EACtD,WAAA,GACA,MAAA,GACA,WAAA,GACA,OAAA,GACA,cAAA,GACA,aAAA,GACA,SAAA,GACA,gBAAA,GACA,SAAA,GACA,UAAA,GACA,iBAAA,EAAA,MACI;AACJ,QAAM,EAAE,KAAA,GAAK,QAAA,EAAA,IAAW,EAAU,EAChC,WA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