@mx-cartographer/experiences 8.0.0-alpha.sms2 → 9.0.0-alpha.mega1

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 (139) hide show
  1. package/CHANGELOG.md +217 -0
  2. package/dist/{Account-Cp30A3ad.mjs → Account-BIKn4XEZ.mjs} +1 -1
  3. package/dist/Account-CMjOp7S2.mjs +118 -0
  4. package/dist/AccountApi-DgZ8ILj1.mjs +19 -0
  5. package/dist/AccountDetailsHeader-BOV91g1o.mjs +95 -0
  6. package/dist/AccountDisplayName-CO7z3v99.mjs +11 -0
  7. package/dist/{AccountFields-CW6cIthP.mjs → AccountFields-BRRH37K1.mjs} +10 -11
  8. package/dist/{AccountListItem-DxmAs98Z.mjs → AccountListItem-Ds5C0mOT.mjs} +4 -4
  9. package/dist/{AccountStore-hIs-yA6W.mjs → AccountStore-BFKvXJSD.mjs} +79 -69
  10. package/dist/{Accounts-DUHkUyK4.mjs → Accounts-CuE8aSZN.mjs} +1 -1
  11. package/dist/{BudgetUtil-CIDAPPPT.mjs → BudgetUtil-CDSOZXem.mjs} +4 -4
  12. package/dist/CategorySelectorDrawer-C4aZYP4N.mjs +418 -0
  13. package/dist/CategoryStore-DEqAnHbi.mjs +186 -0
  14. package/dist/{CategoryUtil-DfVKKkRf.mjs → CategoryUtil-CFHBvaV4.mjs} +1 -1
  15. package/dist/{ConnectionsDrawer-CSo6AFkG.mjs → ConnectionsDrawer-BExzgE16.mjs} +5 -5
  16. package/dist/{CurrencyInput-BrGvhgVK.mjs → CurrencyInput-DDQ4DBrE.mjs} +1 -1
  17. package/dist/{CurrencyText-Dr0EZ7bp.mjs → CurrencyText-C-85TnUF.mjs} +3 -3
  18. package/dist/{DateUtil-CDPZw_-m.mjs → DateUtil-CVsMhbZU.mjs} +3 -3
  19. package/dist/{DebtsStore-hi1cqrRk.mjs → DebtsStore-Dv_T7Dts.mjs} +12 -12
  20. package/dist/{Dialog-CDV0kKxj.mjs → Dialog-CWymUiuO.mjs} +32 -35
  21. package/dist/Drawer-Bet2ZPJo.mjs +176 -0
  22. package/dist/{ExportCsvAction-CQ1grpwo.mjs → ExportCsvAction-oG_Mn66T.mjs} +3 -3
  23. package/dist/{FinstrongStore-dKZOZ2hM.mjs → FinstrongStore-BjFkMTIL.mjs} +6 -6
  24. package/dist/GlobalAccountFilter-BpWlPAl5.mjs +316 -0
  25. package/dist/{GoalStore-CFeAJloA.mjs → GoalStore-Dbjgft2i.mjs} +155 -137
  26. package/dist/{Help-i4OasOO-.mjs → Help-BW_ar-4B.mjs} +2 -2
  27. package/dist/LineChart-DHj-Bufi.mjs +580 -0
  28. package/dist/{ListItemAction-BNCWQAN_.mjs → ListItemAction-Cbr3417C.mjs} +10 -10
  29. package/dist/{ManageIncome-D_qVX5dN.mjs → ManageIncome-DIIyqDTp.mjs} +85 -85
  30. package/dist/{MicroWidgetContainer-BGpNl5ZS.mjs → MicroWidgetContainer-DSyYwRCU.mjs} +2 -2
  31. package/dist/{MiniWidgetContainer-D7MkHG15.mjs → MiniWidgetContainer-DKn7ndO6.mjs} +1 -1
  32. package/dist/NetWorthStore-B6ziBtaH.mjs +168 -0
  33. package/dist/NotificationSettings-e789PcRb.mjs +676 -0
  34. package/dist/{OriginalBalanceAction-62e0mU_3.mjs → OriginalBalanceAction-DFoG79Ba.mjs} +3 -3
  35. package/dist/{RecurringSettings-RfZ8Wuhh.mjs → RecurringSettings-BpCUcE8w.mjs} +4 -4
  36. package/dist/{RecurringTransactionsStore-D3EOKZ2B.mjs → RecurringTransactionsStore-D_--5PWH.mjs} +1 -1
  37. package/dist/{RecurringTransactions-Bhx56aA3.mjs → RepeatingTransaction-C2txVA9O.mjs} +3 -3
  38. package/dist/{SettingsStore-BASMQSIp.mjs → SettingsStore-CInvh-rQ.mjs} +1 -1
  39. package/dist/SpendingData-B7NuTQ9s.mjs +53 -0
  40. package/dist/SpendingLegend-BxefXiQd.mjs +193 -0
  41. package/dist/TransactionDetails-CPwv9xtZ.mjs +1374 -0
  42. package/dist/{TransactionStore-DgLrYW4C.mjs → TransactionStore-D2aMUClq.mjs} +128 -111
  43. package/dist/TrendsStore-BdsYfCc7.mjs +183 -0
  44. package/dist/{User-DqNX2GAK.mjs → User-CulNdZUr.mjs} +21 -20
  45. package/dist/ViewMoreMicroCard-CDWR16_h.mjs +1147 -0
  46. package/dist/WidgetContainer-mzejMmz2.mjs +555 -0
  47. package/dist/accounts/components/detailsdrawer/Accounts/AccountDetailsChart.d.ts +1 -0
  48. package/dist/accounts/index.es.js +933 -232
  49. package/dist/accounts/stores/AccountStore.d.ts +6 -2
  50. package/dist/accounts/utils/AccountDetails.d.ts +5 -0
  51. package/dist/analytics/index.es.js +2 -2
  52. package/dist/budgets/components/AddBudgets.d.ts +2 -1
  53. package/dist/budgets/index.es.js +561 -522
  54. package/dist/cashflow/index.es.js +397 -396
  55. package/dist/categories/components/CustomCategories/AddSubcategory.d.ts +1 -0
  56. package/dist/categories/components/CustomCategories/DeleteSubcategory.d.ts +1 -0
  57. package/dist/categories/components/CustomCategories/RenameSubcategory.d.ts +1 -0
  58. package/dist/categories/components/SubcategoryRow.d.ts +1 -0
  59. package/dist/categories/index.es.js +2 -2
  60. package/dist/categories/stores/CategoryStore.d.ts +5 -3
  61. package/dist/common/components/GlobalAccountFilter.d.ts +11 -0
  62. package/dist/common/components/WidgetContainer.d.ts +7 -6
  63. package/dist/common/components/charts/linechart/CustomTooltip.d.ts +6 -1
  64. package/dist/common/components/charts/stackedlinechart/CustomPointTooltip.d.ts +5 -2
  65. package/dist/common/components/globalaccountfilter/GlobalAccountFilterList.d.ts +7 -0
  66. package/dist/common/components/index.d.ts +2 -2
  67. package/dist/common/hooks/index.d.ts +1 -0
  68. package/dist/common/hooks/useWidgetLoadTimer.d.ts +6 -0
  69. package/dist/common/index.es.js +325 -306
  70. package/dist/common/stores/GlobalUiStore.d.ts +7 -4
  71. package/dist/common/types/localization/AccountsCopy.d.ts +6 -0
  72. package/dist/common/types/localization/CategoryCopy.d.ts +3 -0
  73. package/dist/common/types/localization/CommonCopy.d.ts +3 -0
  74. package/dist/common/types/localization/GoalsCopy.d.ts +3 -1
  75. package/dist/common/types/localization/MicroInsightsCopy.d.ts +1 -0
  76. package/dist/common/types/localization/TransactionsCopy.d.ts +4 -0
  77. package/dist/common/types/localization/TrendsCopy.d.ts +4 -0
  78. package/dist/dashboard/index.es.js +95 -125
  79. package/dist/debts/index.es.js +466 -460
  80. package/dist/{exportTransactionsToCSV-BFpuIAXW.mjs → exportTransactionsToCSV-BU1jTY0Q.mjs} +4 -4
  81. package/dist/finstrong/components/shared/CustomDoubleBarPlot.d.ts +4 -5
  82. package/dist/finstrong/index.es.js +1660 -1553
  83. package/dist/goals/index.es.js +716 -677
  84. package/dist/goals/stores/GoalStore.d.ts +2 -0
  85. package/dist/help/index.es.js +14 -10
  86. package/dist/{hooks-C41HAxM5.mjs → hooks-fY_n74f7.mjs} +16 -16
  87. package/dist/investments/index.es.js +464 -457
  88. package/dist/merchants/index.es.js +1 -1
  89. package/dist/microinsights/MicroCardTemplate.d.ts +23 -0
  90. package/dist/microinsights/beaticons/BeatMaterialIcon.d.ts +8 -0
  91. package/dist/microinsights/beaticons/MonthlySpendComparisonIcon.d.ts +1 -2
  92. package/dist/microinsights/beaticons/index.d.ts +1 -0
  93. package/dist/microinsights/cards/InsightCard.d.ts +0 -2
  94. package/dist/microinsights/cards/ViewMoreMicroCard.d.ts +2 -5
  95. package/dist/microinsights/index.d.ts +2 -2
  96. package/dist/microinsights/index.es.js +824 -14
  97. package/dist/networth/components/NetWorthChart.d.ts +3 -2
  98. package/dist/networth/components/NetWorthList.d.ts +3 -3
  99. package/dist/networth/index.es.js +433 -438
  100. package/dist/networth/stores/NetWorthStore.d.ts +20 -9
  101. package/dist/networth/utils/NetWorthUtils.d.ts +2 -2
  102. package/dist/notifications/index.es.js +5 -5
  103. package/dist/recurringtransactions/index.es.js +331 -325
  104. package/dist/settings/index.es.js +293 -285
  105. package/dist/spending/components/SpendingChart.d.ts +1 -1
  106. package/dist/spending/components/SpendingList.d.ts +1 -1
  107. package/dist/spending/components/SpendingTabLabel.d.ts +1 -0
  108. package/dist/spending/index.es.js +250 -235
  109. package/dist/transactions/index.es.js +288 -281
  110. package/dist/transactions/stores/TransactionStore.d.ts +5 -0
  111. package/dist/trends/components/TrendsTable.d.ts +0 -2
  112. package/dist/trends/index.es.js +876 -802
  113. package/dist/trends/utils/TrendsData.d.ts +1 -0
  114. package/dist/trends/utils/TrendsTable.d.ts +12 -0
  115. package/dist/{useAccountDisplayName-usSZCQ7I.mjs → useAccountDisplayName-DbkgGLdg.mjs} +2 -2
  116. package/dist/useAriaLive-B3_pRUio.mjs +35 -0
  117. package/dist/{useInsightsEnabled-CNjP5cfR.mjs → useInsightsEnabled-dhmXeSyF.mjs} +1 -1
  118. package/dist/useWidgetLoadTimer-CrUzxN-P.mjs +19 -0
  119. package/package.json +26 -21
  120. package/dist/AccountDetailsContent-C1HumFnW.mjs +0 -683
  121. package/dist/AccountDetailsHeader-NMx79DGs.mjs +0 -87
  122. package/dist/CategorySelectorDrawer-DqDAA_5I.mjs +0 -399
  123. package/dist/CategoryStore-MUwRWH9e.mjs +0 -176
  124. package/dist/ConnectDrawer-Dn1MlqLz.mjs +0 -545
  125. package/dist/Drawer-Dqe5EqvA.mjs +0 -163
  126. package/dist/LineChart-bc1D9xBE.mjs +0 -581
  127. package/dist/NetWorthStore-8FFC1Bs0.mjs +0 -150
  128. package/dist/NotificationSettings-BsWiYD94.mjs +0 -672
  129. package/dist/SpendingData-DPQ96k3x.mjs +0 -55
  130. package/dist/SpendingLegend-CZzDb-7d.mjs +0 -193
  131. package/dist/TransactionDetails-Duv1X9ec.mjs +0 -1379
  132. package/dist/TrendsStore-_mRaFUdf.mjs +0 -182
  133. package/dist/ViewMoreMicroCard-CH9E-jOx.mjs +0 -1930
  134. package/dist/WidgetContainer-B1Jzb4XA.mjs +0 -565
  135. package/dist/common/components/accountfilter/AccountFilter.d.ts +0 -20
  136. package/dist/common/components/accountfilter/AccountFilterOptions.d.ts +0 -31
  137. package/dist/common/components/accountfilter/index.d.ts +0 -1
  138. package/dist/microinsights/cards/BaseCard.d.ts +0 -13
  139. package/dist/{ToggleListItem-ciFTiqRS.mjs → Notification-Bs1fdbzI.mjs} +1 -1
@@ -0,0 +1,1147 @@
1
+ import { jsx as i, jsxs as L, Fragment as Se } from "react/jsx-runtime";
2
+ import h, { useEffect as ie, useState as oe } from "react";
3
+ import { observer as U } from "mobx-react-lite";
4
+ import N from "@mui/material/Stack";
5
+ import ne from "@mui/material/Button";
6
+ import { CategoryIcon as be, MerchantLogo as Pe, P as _e, Text as ue, H3 as Be } from "@mxenabled/mxui";
7
+ import { Icon as Ve, Close as Ge, ChevronLeft as ke, ChevronRight as fe } from "@mxenabled/mx-icons";
8
+ import { L as ze } from "./Loader-BSWSYqvn.mjs";
9
+ import Q from "@mui/material/Box";
10
+ import re from "@mui/material/IconButton";
11
+ import { alpha as T, useTheme as H } from "@mui/material/styles";
12
+ import { useInView as Te } from "react-intersection-observer";
13
+ import Ue from "@mui/material/styles/useTheme";
14
+ import { b as Ke } from "./Category-Ccoew_sA.mjs";
15
+ import { b as Fe } from "./Localization-2MODESHW.mjs";
16
+ import He from "@mui/material/CircularProgress";
17
+ import { makeAutoObservable as ae, runInAction as Re } from "mobx";
18
+ import { G as pe, a as $e, u as je, b as Ye } from "./useCombineEvents-CRwX-qWE.mjs";
19
+ import { B as he } from "./BeatApi-De2IaqH2.mjs";
20
+ import { u as Xe } from "./useWidgetLoadTimer-CrUzxN-P.mjs";
21
+ import Ze from "@mui/material/Card";
22
+ import Qe from "@mui/material/CardActionArea";
23
+ import qe from "@mui/material/Avatar";
24
+ const me = {
25
+ featureVersion: "spendVsIncomeTrends"
26
+ };
27
+ class Je {
28
+ copyApi = new pe("/", "");
29
+ copyObject = {};
30
+ namespace = "experiences";
31
+ translationKey = "micro_insights";
32
+ constructor() {
33
+ ae(this);
34
+ }
35
+ // NOTE: Not sure if this is special case, but other stores have this deprecation todo
36
+ // DEPRECATED: Initialize api in constructor and use loadCopy instead
37
+ // TODO: Remove this function
38
+ initialize = async (e, o) => {
39
+ this.copyApi = new pe(e, o), await this.loadCopy();
40
+ };
41
+ loadCopy = async () => {
42
+ const e = await this.copyApi.getGlobalCopy(this.namespace, this.translationKey);
43
+ Re(() => {
44
+ this.copyObject = e[this.translationKey];
45
+ });
46
+ };
47
+ get cardsCopy() {
48
+ return this.copyObject.cards;
49
+ }
50
+ get carouselCopy() {
51
+ return this.copyObject.carousel;
52
+ }
53
+ get zeroStateCopy() {
54
+ return this.copyObject.zero_state;
55
+ }
56
+ }
57
+ const se = {
58
+ BillAmountNotStandard: "BillAmountNotStandard",
59
+ CanadianUpcomingDeadlineAlert: "CanadianUpcomingDeadlineAlert",
60
+ DuplicatePaymentV2: "DuplicatePaymentV2",
61
+ IntroducePulse: "IntroducePulse",
62
+ LargeTransaction: "LargeTransaction",
63
+ MonthlySpendToIncomeComparisonV2: "MonthlySpendToIncomeComparisonV2",
64
+ QuarterlySummary: "QuarterlySummary",
65
+ SpendingPlanCategorySpending: "SpendingPlanCategorySpending",
66
+ SubscriptionPriceIncrease: "SubscriptionPriceIncrease",
67
+ UncategorizedTransactionsV2: "UncategorizedTransactionsV2",
68
+ UpcomingBill: "UpcomingBill",
69
+ UnifiedDeposit: "UnifiedDeposit",
70
+ WeeklySpendingPlanSummary: "WeeklySpendingPlanSummary",
71
+ WeeklyNewMerchantsV2: "WeeklyNewMerchantsV2",
72
+ MonthlySpendComparison: "MonthlySpendComparison",
73
+ MonthlySpendToIncomeComparison: "MonthlySpendToIncomeComparison"
74
+ }, O = window?.app?.clientConfig?.microwidget_instance_id || "", Ce = {
75
+ INSIGHTS_MICRO_WIDGET: "/micro-insights-carousel"
76
+ }, Oe = (t) => `on${t}Click`, ye = (t) => `on${t}View`, We = (t) => `on${t}ViewFirstTime`, ce = (t) => t.replace(/([a-z])([A-Z])/g, "$1 $2"), et = () => Object.values(se).reduce(
77
+ (t, e) => ({
78
+ ...t,
79
+ [Oe(e)]: {
80
+ action: P.MICRO_BEAT_CLICKED,
81
+ category: b.BEAT_INTERACTION,
82
+ label: ce(e),
83
+ value: O
84
+ }
85
+ }),
86
+ {}
87
+ ), tt = () => Object.values(se).reduce(
88
+ (t, e) => ({
89
+ ...t,
90
+ [ye(e)]: {
91
+ action: P.MICRO_BEAT_DISPLAYED,
92
+ category: b.BEAT_INTERACTION,
93
+ label: ce(e),
94
+ value: O
95
+ }
96
+ }),
97
+ {}
98
+ ), ot = () => Object.values(se).reduce(
99
+ (t, e) => ({
100
+ ...t,
101
+ [We(e)]: {
102
+ action: P.MICRO_BEAT_DISPLAYED_FIRST_TIME,
103
+ category: b.BEAT_INTERACTION,
104
+ label: ce(e),
105
+ value: O
106
+ }
107
+ }),
108
+ {}
109
+ ), x = {
110
+ CAROUSEL_CONTROL: "Carousel Control",
111
+ MICRO_WIDGET: "Micro Widget",
112
+ VIEW_MORE: "View More"
113
+ }, b = {
114
+ MICRO_WIDGET_INTERACTION: "Micro Widget Interaction",
115
+ BEAT_INTERACTION: "Beat Interaction"
116
+ }, y = {
117
+ ON_CAROUSEL_BACK_CLICK: "onCarouselBackClick",
118
+ ON_CAROUSEL_BACK_SWIPE: "onCarouselBackSwipe",
119
+ ON_CAROUSEL_FORWARD_CLICK: "onCarouselForwardClick",
120
+ ON_CAROUSEL_FORWARD_SWIPE: "onCarouselForwardSwipe",
121
+ ON_NO_RELEVANT_INSIGHTS_CLICKED: "onNoRelevantInsightsClicked",
122
+ ON_VIEW_MORE_CLICKED: "onViewMoreClicked"
123
+ }, Ne = {
124
+ ON_VIEW_MORE_VIEWED: "onViewMoreCardView"
125
+ }, P = {
126
+ CONTROL_BACKWARD: "Control Backward",
127
+ CONTROL_FORWARD: "Control Forward",
128
+ MICRO_BEAT_CLICKED: "Micro Beat Clicked",
129
+ MICRO_BEAT_DISPLAYED: "Micro Beat Displayed",
130
+ MICRO_BEAT_DISPLAYED_FIRST_TIME: "Micro Beat Displayed For First Time",
131
+ SWIPE_BACKWARD: "Swipe Backward",
132
+ SWIPE_FORWARD: "Swipe Forward"
133
+ }, k = {
134
+ MICRO_WIDGET_CAROUSEL: "Micro Widget Carousel",
135
+ MICRO_WIDGET_CAROUSEL_ZERO_STATE: "Micro Widget Carousel Zero State",
136
+ MICRO_WIDGET_CAROUSEL_NO_RELEVANT_INSIGHTS: "Micro Widget Carousel No Relevant Insights"
137
+ }, Ee = {
138
+ [k.MICRO_WIDGET_CAROUSEL]: {
139
+ label: x.MICRO_WIDGET,
140
+ name: k.MICRO_WIDGET_CAROUSEL,
141
+ path: Ce.INSIGHTS_MICRO_WIDGET,
142
+ value: O
143
+ },
144
+ // zero state
145
+ [k.MICRO_WIDGET_CAROUSEL_ZERO_STATE]: {
146
+ label: x.MICRO_WIDGET,
147
+ name: k.MICRO_WIDGET_CAROUSEL_ZERO_STATE,
148
+ path: Ce.INSIGHTS_MICRO_WIDGET,
149
+ value: O
150
+ },
151
+ // no relevant cards
152
+ [k.MICRO_WIDGET_CAROUSEL_NO_RELEVANT_INSIGHTS]: {
153
+ label: x.MICRO_WIDGET,
154
+ name: k.MICRO_WIDGET_CAROUSEL_NO_RELEVANT_INSIGHTS,
155
+ path: "/micro-widget",
156
+ value: O
157
+ }
158
+ }, ge = {
159
+ // carousel control interaction events - clicks and swipes
160
+ [y.ON_CAROUSEL_BACK_CLICK]: {
161
+ action: P.CONTROL_BACKWARD,
162
+ category: b.MICRO_WIDGET_INTERACTION,
163
+ label: x.CAROUSEL_CONTROL,
164
+ value: O
165
+ },
166
+ [y.ON_CAROUSEL_FORWARD_CLICK]: {
167
+ action: P.CONTROL_FORWARD,
168
+ category: b.MICRO_WIDGET_INTERACTION,
169
+ label: x.CAROUSEL_CONTROL,
170
+ value: O
171
+ },
172
+ [y.ON_CAROUSEL_BACK_SWIPE]: {
173
+ action: P.SWIPE_BACKWARD,
174
+ category: b.MICRO_WIDGET_INTERACTION,
175
+ label: x.CAROUSEL_CONTROL,
176
+ value: O
177
+ },
178
+ [y.ON_CAROUSEL_FORWARD_SWIPE]: {
179
+ action: P.SWIPE_FORWARD,
180
+ category: b.MICRO_WIDGET_INTERACTION,
181
+ label: x.CAROUSEL_CONTROL,
182
+ value: O
183
+ },
184
+ // read more card events
185
+ [y.ON_VIEW_MORE_CLICKED]: {
186
+ action: P.MICRO_BEAT_CLICKED,
187
+ category: b.BEAT_INTERACTION,
188
+ label: x.VIEW_MORE,
189
+ value: O
190
+ },
191
+ [Ne.ON_VIEW_MORE_VIEWED]: {
192
+ action: P.MICRO_BEAT_DISPLAYED,
193
+ category: b.BEAT_INTERACTION,
194
+ label: x.VIEW_MORE,
195
+ value: O
196
+ },
197
+ ...et(),
198
+ ...tt(),
199
+ ...ot()
200
+ }, Ie = async (t, e) => !e || !ge[t] ? null : e.sendAnalyticEvent(ge[t]).then((o) => o).catch((o) => {
201
+ throw o;
202
+ }), Ae = async (t, e) => !e || !Ee[t] ? null : e.sendAnalyticsPageview(Ee[t]).then((o) => o).catch((o) => {
203
+ throw o;
204
+ });
205
+ class it {
206
+ onAnalyticEvent = Ie;
207
+ onAnalyticPageView = Ae;
208
+ beatApi = new he("/", "");
209
+ constructor() {
210
+ ae(this);
211
+ }
212
+ initialize = async (e, o, n) => {
213
+ this.onAnalyticEvent = (r, a) => {
214
+ Ie(r, a).then((s) => s).catch((s) => {
215
+ throw s.status === 401 && n(), s;
216
+ });
217
+ }, this.onAnalyticPageView = (r, a) => {
218
+ Ae(r, a).then((s) => s).catch((s) => {
219
+ throw s.status === 401 && n(), s;
220
+ });
221
+ }, this.beatApi = new he(e, o);
222
+ };
223
+ updateBeat = async (e) => {
224
+ this.beatApi.updateBeat(e);
225
+ };
226
+ updateOffer = async (e) => {
227
+ this.beatApi.updateOffer(e);
228
+ };
229
+ }
230
+ class nt {
231
+ copyStore;
232
+ endpoint = "/";
233
+ insightsMicroWidgetStore;
234
+ session = null;
235
+ token = "";
236
+ isInitialized = !1;
237
+ constructor() {
238
+ this.copyStore = new Je(), this.insightsMicroWidgetStore = new it(), ae(this);
239
+ }
240
+ initialize = async (e, o, n) => {
241
+ await this.copyStore.initialize(e, o), await this.insightsMicroWidgetStore.initialize(e, o, n);
242
+ const r = await $e(e, o, "1.0.0", "Micro Insights Carousel");
243
+ Re(() => {
244
+ this.session = r, this.isInitialized = !0;
245
+ });
246
+ };
247
+ }
248
+ const $ = h.createContext(null), rt = ({
249
+ onEvent: t,
250
+ onPageview: e,
251
+ store: o,
252
+ children: n
253
+ }) => /* @__PURE__ */ i($.Provider, { value: { onEvent: t, onPageview: e, store: o, children: n }, children: n }), at = ({ beat: t }) => {
254
+ const { primary_category_guid: e, category_guids: o } = t, n = e || o?.[0] || Ke.UNCATEGORIZED;
255
+ return /* @__PURE__ */ i(be, { categoryGuid: n, size: 32, sx: { minWidth: 32 } });
256
+ }, R = ({
257
+ bgColor: t,
258
+ name: e,
259
+ iconColor: o = "primary"
260
+ }) => /* @__PURE__ */ i(
261
+ qe,
262
+ {
263
+ sx: {
264
+ bgcolor: t,
265
+ width: 32,
266
+ height: 32
267
+ },
268
+ variant: "rounded",
269
+ children: /* @__PURE__ */ i(Ve, { color: o, fill: !0, name: e, size: 20 })
270
+ }
271
+ ), st = ({ beat: t }) => {
272
+ const { category_guids: e, merchant_guids: o, primary_category_guid: n, primary_merchant_guid: r } = t;
273
+ return /* @__PURE__ */ i(
274
+ Pe,
275
+ {
276
+ categoryGuid: n || e && e[0] || "",
277
+ merchantGuid: r || o[0],
278
+ size: 32,
279
+ sx: {
280
+ display: "flex",
281
+ mt: 2,
282
+ minWidth: 32
283
+ }
284
+ }
285
+ );
286
+ }, ct = (t) => t ? t.data ? t.data.map((e) => {
287
+ const o = {};
288
+ return t.names?.map((n, r) => {
289
+ o[n] = e[r];
290
+ }), o;
291
+ }) : [] : [], lt = (t) => {
292
+ const e = ct(t), o = e.length / 2, n = e.slice(0, o), r = e.slice(o);
293
+ return !n.length || !r.length ? "primary" : n[0].amount > r[0].amount ? "error" : n[0].amount < r[0].amount ? "success" : "primary";
294
+ }, dt = ({ beat: t }) => {
295
+ const e = Ue(), o = lt(t.data_series), n = e.palette[o].main;
296
+ return /* @__PURE__ */ i(R, { bgColor: T(n, 0.15), iconColor: o, name: "bar_chart" });
297
+ }, _t = {
298
+ 0: (t, e) => /* @__PURE__ */ i(R, { bgColor: T(e.palette.primary.main, 0.15), name: "error" }),
299
+ 1: (t) => /* @__PURE__ */ i(at, { beat: t }),
300
+ 2: (t) => /* @__PURE__ */ i(st, { beat: t }),
301
+ 3: (t) => /* @__PURE__ */ i(dt, { beat: t }),
302
+ 4: (t, e) => /* @__PURE__ */ i(
303
+ R,
304
+ {
305
+ bgColor: T(e.palette.secondary.main, 0.15),
306
+ iconColor: "secondary",
307
+ name: "info"
308
+ }
309
+ ),
310
+ 5: (t, e) => /* @__PURE__ */ i(R, { bgColor: T(e.palette.primary.main, 0.15), name: "campaign" }),
311
+ // TODO: Waiting for the backend to accommodate icon types 6, 7, 8, and 9
312
+ 6: (t, e) => /* @__PURE__ */ i(
313
+ R,
314
+ {
315
+ bgColor: T(e.palette.success.main, 0.15),
316
+ iconColor: "success",
317
+ name: "check_circle"
318
+ }
319
+ ),
320
+ 7: (t, e) => /* @__PURE__ */ i(R, { bgColor: T(e.palette.primary.main, 0.15), name: "today" }),
321
+ 8: (t, e) => /* @__PURE__ */ i(R, { bgColor: T(e.palette.primary.main, 0.15), name: "calendar_clock" }),
322
+ 9: (t, e) => /* @__PURE__ */ i(R, { bgColor: T(e.palette.primary.main, 0.15), name: "celebration" })
323
+ }, ut = ({ beat: t }) => {
324
+ const e = H(), { icon_type: o } = t, n = o != null ? _t[o] : null;
325
+ return n ? n(t, e) : /* @__PURE__ */ i(R, { bgColor: T(e.palette.primary.main, 0.15), name: "error" });
326
+ }, B = () => {
327
+ const t = h.useContext($);
328
+ if (!t)
329
+ throw new Error("useCopyStore() must be used within the InsightsMicroWidgetDataProvider");
330
+ return t.store.copyStore;
331
+ }, pt = () => {
332
+ const t = h.useContext($);
333
+ if (!t?.store?.insightsMicroWidgetStore)
334
+ throw new Error(
335
+ "useInsightsMicroWidgetStore() must be used within the InsightsMicroWidgetDataProvider"
336
+ );
337
+ return t.store.insightsMicroWidgetStore;
338
+ }, j = () => {
339
+ const t = h.useContext($);
340
+ if (!t)
341
+ throw new Error("useEvent() must be used within the InsightsMicroWidgetDataProvider");
342
+ return { onEvent: t.onEvent };
343
+ }, Me = () => {
344
+ const t = h.useContext($);
345
+ if (!t)
346
+ throw new Error("usePageview() must be used within the InsightsMicroWidgetDataProvider");
347
+ return { onPageview: t.onPageview };
348
+ }, ht = {
349
+ LARGE: 180,
350
+ STANDARD: 154,
351
+ XLARGE: 200,
352
+ XXLARGE: 248
353
+ }, mt = 50, we = 1, q = h.forwardRef(
354
+ function({
355
+ ariaLabel: e,
356
+ cardSx: o,
357
+ closeAriaLabel: n,
358
+ description: r,
359
+ icon: a,
360
+ isActiveCard: s,
361
+ hasCardEffect: p = !1,
362
+ heightOverrides: m,
363
+ onClose: C,
364
+ onCardClick: _,
365
+ onPrimaryAction: c,
366
+ onSecondaryAction: d,
367
+ primaryActionText: l,
368
+ secondaryActionText: g,
369
+ title: E,
370
+ variant: A,
371
+ widthOverrides: I,
372
+ ...D
373
+ }, V) {
374
+ const S = !!(c && l), f = !!(d && g), M = p ? Ze : Q, w = /* @__PURE__ */ L(Se, { children: [
375
+ C && /* @__PURE__ */ i(
376
+ re,
377
+ {
378
+ "aria-label": n,
379
+ onClick: (u) => {
380
+ u.stopPropagation(), C?.();
381
+ },
382
+ onMouseDown: (u) => {
383
+ u.stopPropagation();
384
+ },
385
+ onTouchStart: (u) => {
386
+ u.stopPropagation();
387
+ },
388
+ sx: { minHeight: 40, minWidth: 40, position: "absolute", right: 4, top: 4 },
389
+ children: /* @__PURE__ */ i(Ge, {})
390
+ }
391
+ ),
392
+ /* @__PURE__ */ L(N, { sx: { gap: 6, height: "100%", justifyContent: "space-between" }, children: [
393
+ /* @__PURE__ */ L(N, { sx: { flexDirection: "row", gap: 12 }, children: [
394
+ a && a,
395
+ /* @__PURE__ */ L(N, { sx: { gap: 6 }, children: [
396
+ /* @__PURE__ */ i(N, { sx: { flexDirection: "row", justifyContent: "space-between" }, children: /* @__PURE__ */ i(_e, { bold: !0, sx: { lineHeight: "16px" }, variant: "body1", children: E }) }),
397
+ /* @__PURE__ */ i(
398
+ _e,
399
+ {
400
+ dangerouslySetInnerHTML: { __html: r },
401
+ sx: {
402
+ display: "-webkit-box",
403
+ overflow: "hidden",
404
+ textOverflow: "ellipsis",
405
+ WebkitBoxOrient: "vertical",
406
+ WebkitLineClamp: S ? 2 : 3
407
+ },
408
+ variant: "subtitle2"
409
+ }
410
+ )
411
+ ] })
412
+ ] }),
413
+ S && /* @__PURE__ */ L(
414
+ N,
415
+ {
416
+ sx: {
417
+ alignItems: "center",
418
+ flexDirection: "row",
419
+ height: 28,
420
+ pb: 4,
421
+ pl: a ? 36 : 0
422
+ },
423
+ children: [
424
+ S && /* @__PURE__ */ i(
425
+ ne,
426
+ {
427
+ onClick: (u) => {
428
+ u.stopPropagation(), c?.();
429
+ },
430
+ onMouseDown: (u) => {
431
+ u.stopPropagation();
432
+ },
433
+ onTouchStart: (u) => {
434
+ u.stopPropagation();
435
+ },
436
+ size: "small",
437
+ sx: { px: a ? 8 : 0 },
438
+ variant: "text",
439
+ children: /* @__PURE__ */ i(ue, { bold: !0, variant: "body2", children: l })
440
+ }
441
+ ),
442
+ f && /* @__PURE__ */ i(
443
+ ne,
444
+ {
445
+ onClick: (u) => {
446
+ u.stopPropagation(), d?.();
447
+ },
448
+ onMouseDown: (u) => {
449
+ u.stopPropagation();
450
+ },
451
+ onTouchStart: (u) => {
452
+ u.stopPropagation();
453
+ },
454
+ size: "small",
455
+ sx: { px: 8 },
456
+ variant: "text",
457
+ children: /* @__PURE__ */ i(ue, { bold: !0, sx: { color: "text.secondary" }, variant: "body2", children: g })
458
+ }
459
+ )
460
+ ]
461
+ }
462
+ )
463
+ ] })
464
+ ] });
465
+ return /* @__PURE__ */ i(
466
+ M,
467
+ {
468
+ "aria-hidden": !s,
469
+ "aria-label": e,
470
+ ref: V,
471
+ role: "group",
472
+ sx: {
473
+ backgroundColor: "background.paper",
474
+ height: m ? "100%" : 124,
475
+ minWidth: I ? `${I}px` : "100%",
476
+ position: "relative",
477
+ ...o
478
+ },
479
+ tabIndex: _ || !s ? -1 : 0,
480
+ variant: A,
481
+ ...D,
482
+ children: _ ? /* @__PURE__ */ i(
483
+ Qe,
484
+ {
485
+ onClick: _,
486
+ sx: {
487
+ pb: 8,
488
+ pt: 16,
489
+ px: 16,
490
+ height: m ? "100%" : 124
491
+ },
492
+ children: w
493
+ }
494
+ ) : w
495
+ }
496
+ );
497
+ }
498
+ ), Ct = ({
499
+ ariaLabel: t,
500
+ beat: e,
501
+ index: o,
502
+ isActiveCard: n,
503
+ onCardClick: r,
504
+ posthog: a,
505
+ widthOverrides: s,
506
+ variant: p,
507
+ showIcon: m,
508
+ heightOverrides: C
509
+ }) => {
510
+ const { ref: _, inView: c } = Te({
511
+ threshold: we
512
+ }), { cardsCopy: d } = B(), { onEvent: l } = j(), { updateBeat: g, updateOffer: E } = pt();
513
+ ie(() => {
514
+ c && (e.has_been_displayed ? l(ye(e.template)) : (e.guid.startsWith("OFR") ? E({
515
+ ...e,
516
+ has_been_displayed: !0
517
+ }) : g({
518
+ ...e,
519
+ has_been_displayed: !0
520
+ }), l(We(e.template))));
521
+ }, [c]), ie(() => {
522
+ if (c && e)
523
+ if (e.template === "MarketingOffer") {
524
+ const I = e;
525
+ a?.capture("viewed_messaging_insight", {
526
+ template: e.template,
527
+ campaign_guid: I.campaign_guid,
528
+ campaign_name: I.pulse_campaign_name
529
+ });
530
+ } else
531
+ a?.capture("viewed_insight", {
532
+ beat_guid: e.guid,
533
+ template: e.template,
534
+ position: o
535
+ });
536
+ }, [e, o, c]);
537
+ const A = () => {
538
+ if (r && r(e), l(Oe(e.template)), e.template === "MarketingOffer") {
539
+ const I = e;
540
+ a?.capture("clicked_messaging_insight", {
541
+ template: e.template,
542
+ campaign_guid: I.campaign_guid,
543
+ campaign_name: I.pulse_campaign_name
544
+ });
545
+ } else
546
+ a?.capture("clicked_insight", {
547
+ beat_guid: e.guid,
548
+ template: e.template,
549
+ position: o
550
+ });
551
+ };
552
+ return /* @__PURE__ */ i(
553
+ q,
554
+ {
555
+ "aria-roledescription": "slide",
556
+ ariaLabel: t,
557
+ cardSx: {
558
+ borderRadius: 2
559
+ },
560
+ description: e?.html_micro_description && e?.html_micro_description.length > 0 ? e.html_micro_description : e.html_description || "",
561
+ hasCardEffect: !0,
562
+ heightOverrides: C,
563
+ icon: m && /* @__PURE__ */ i(ut, { beat: e }),
564
+ isActiveCard: n,
565
+ onCardClick: A,
566
+ onPrimaryAction: A,
567
+ primaryActionText: e.micro_call_to_action || d.micro_card_cta,
568
+ ref: _,
569
+ title: e.micro_title && e.micro_title.length > 0 ? e.micro_title : e.title,
570
+ variant: p,
571
+ widthOverrides: s
572
+ }
573
+ );
574
+ }, Et = ({
575
+ currentBeatIndex: t,
576
+ numBeats: e,
577
+ onNextClick: o,
578
+ onPreviousClick: n,
579
+ scrollRightBoundary: r,
580
+ scrollX: a,
581
+ shouldApplyDotAnimation: s = !1,
582
+ visibleCardsCount: p = 1
583
+ }) => {
584
+ const m = H(), { carouselCopy: C } = B(), _ = Math.floor(a) > r || t - p + 1 === 0, c = a < 0 || e - 1 === t, d = m.palette.grey[500], l = m.palette.primary.main;
585
+ return /* @__PURE__ */ L(
586
+ N,
587
+ {
588
+ direction: "row",
589
+ sx: {
590
+ alignItems: "center",
591
+ justifyContent: "center",
592
+ pt: 4,
593
+ width: "100%",
594
+ // we were using `gap` instead of margin, but it doesn't work in safari browsers older than iOS 14.1
595
+ "& button:first-child": {
596
+ mr: 8
597
+ }
598
+ },
599
+ children: [
600
+ /* @__PURE__ */ i(
601
+ re,
602
+ {
603
+ "aria-disabled": _,
604
+ "aria-label": C.previous_insight_cta_aria,
605
+ disabled: _,
606
+ onClick: n,
607
+ children: /* @__PURE__ */ i(
608
+ ke,
609
+ {
610
+ style: {
611
+ color: _ ? d : l
612
+ }
613
+ }
614
+ )
615
+ }
616
+ ),
617
+ Array.from({ length: e }).map((g, E) => {
618
+ const A = E === t;
619
+ return /* @__PURE__ */ i(
620
+ Q,
621
+ {
622
+ className: "mx-insights-micro-carousel-dots",
623
+ sx: {
624
+ bgcolor: A ? l : d,
625
+ height: 8,
626
+ mr: 8,
627
+ // existing comment from meganthan "we were using `gap` instead of margin, but it doesn't work in safari browsers older than iOS 14.1"
628
+ ...s ? {
629
+ borderRadius: "4px",
630
+ transformOrigin: "center",
631
+ transition: "all 0.5s ease-out",
632
+ willChange: "width, background-color"
633
+ } : {
634
+ borderRadius: "50%",
635
+ p: 0
636
+ },
637
+ width: A && s ? 24 : 8
638
+ }
639
+ },
640
+ `carousel-button-${E}`
641
+ );
642
+ }),
643
+ /* @__PURE__ */ i(
644
+ re,
645
+ {
646
+ "aria-disabled": c,
647
+ "aria-label": C.next_insight_cta_aria,
648
+ disabled: c,
649
+ onClick: o,
650
+ children: /* @__PURE__ */ i(
651
+ fe,
652
+ {
653
+ style: {
654
+ color: c ? d : l
655
+ }
656
+ }
657
+ )
658
+ }
659
+ )
660
+ ]
661
+ }
662
+ );
663
+ }, gt = ({
664
+ activeCardIndex: t,
665
+ beats: e,
666
+ cardWidth: o,
667
+ showCTAColocatedWithText: n,
668
+ heightOverrides: r,
669
+ onCardClick: a,
670
+ posthog: s,
671
+ showIcon: p,
672
+ variant: m
673
+ }) => {
674
+ const { carouselCopy: C } = B(), _ = {
675
+ showCTAColocatedWithText: n,
676
+ heightOverrides: r,
677
+ posthog: s,
678
+ showIcon: p,
679
+ variant: m
680
+ };
681
+ return /* @__PURE__ */ L(Se, { children: [
682
+ e.map((c, d) => {
683
+ const l = d + 1, g = e.length + 1, E = Fe(
684
+ C.card_position_in_carousel_aria,
685
+ l.toString(),
686
+ g.toString()
687
+ ), A = c.micro_title && c.micro_title.length > 0, I = c.micro_description && c.micro_description.length > 0, D = A ? c.micro_title : c.title, V = I ? c.micro_description : c.description;
688
+ return /* @__PURE__ */ i(
689
+ Ct,
690
+ {
691
+ ariaLabel: `${E}: ${D}, ${V}`,
692
+ beat: c,
693
+ index: d,
694
+ isActiveCard: d === t,
695
+ onCardClick: a,
696
+ widthOverrides: o || void 0,
697
+ ..._
698
+ },
699
+ `${c.guid} ${d}`
700
+ );
701
+ }),
702
+ /* @__PURE__ */ i(
703
+ Wt,
704
+ {
705
+ isActiveCard: t === e.length,
706
+ onCardClick: a,
707
+ widthOverrides: o || void 0,
708
+ ..._
709
+ }
710
+ )
711
+ ] });
712
+ }, It = ({
713
+ analyticsMetadata: t,
714
+ allowSingleCardPeeking: e = !1,
715
+ beats: o = [],
716
+ showCTAColocatedWithText: n,
717
+ heightOverrides: r,
718
+ onCardClick: a,
719
+ posthog: s,
720
+ showCarouselControls: p,
721
+ showIcon: m,
722
+ showWithMargin: C = !0,
723
+ variant: _,
724
+ widthOverrides: c,
725
+ visibleCardsCount: d = 1
726
+ // Default to 1 card visible
727
+ }) => {
728
+ const l = h.useRef(null), g = h.useRef(null), [E, A] = h.useState(0), [I, D] = h.useState(null), [V, S] = h.useState(null), [f, M] = h.useState(null), { carouselCopy: w } = B(), { onEvent: u } = j();
729
+ h.useEffect(() => {
730
+ if (l.current && !e) {
731
+ const W = l.current.offsetWidth, K = 8;
732
+ let z;
733
+ if (d > 1) {
734
+ const le = (W - (d - 1) * K) / d / 3;
735
+ z = (W - le - (d - 1) * K) / d;
736
+ } else
737
+ z = W;
738
+ M(z);
739
+ }
740
+ }, [d, l.current?.offsetWidth]), h.useEffect(() => {
741
+ const W = g.current?.offsetWidth;
742
+ if (typeof W == "number" && e) {
743
+ const K = (F) => {
744
+ const de = [
745
+ { maxWidth: 375, cardWidth: 268 },
746
+ { maxWidth: 444, cardWidth: 300 },
747
+ { maxWidth: 599, cardWidth: 350 },
748
+ { maxWidth: 749, cardWidth: 450 },
749
+ { maxWidth: 900, cardWidth: 600 }
750
+ ].find((xe) => F <= xe.maxWidth);
751
+ return de ? de.cardWidth : 750;
752
+ };
753
+ M(K(W));
754
+ const z = () => {
755
+ const F = g.current?.offsetWidth;
756
+ typeof F == "number" && M(K(F));
757
+ };
758
+ return window.addEventListener("resize", z), () => {
759
+ window.removeEventListener("resize", z);
760
+ };
761
+ }
762
+ }, [e, g]);
763
+ const Y = () => {
764
+ u(y.ON_CAROUSEL_FORWARD_CLICK, t), l.current && f && l.current.scrollTo({
765
+ left: E + f + 8,
766
+ top: 0,
767
+ behavior: "smooth"
768
+ });
769
+ }, X = () => {
770
+ u(y.ON_CAROUSEL_BACK_CLICK, t), l.current && f && l.current.scrollTo({
771
+ left: Math.max(0, E - (f + 8)),
772
+ top: 0,
773
+ behavior: "smooth"
774
+ });
775
+ }, J = () => {
776
+ l.current && A(l.current.scrollLeft);
777
+ }, ee = () => {
778
+ if (!V || !I) return;
779
+ V - I > mt ? u(y.ON_CAROUSEL_FORWARD_SWIPE, t) : u(y.ON_CAROUSEL_BACK_SWIPE, t);
780
+ }, te = (W) => {
781
+ D(W.targetTouches[0].clientX);
782
+ }, Z = (W) => {
783
+ D(null), S(W.targetTouches[0].clientX);
784
+ }, v = f ? Math.round(E / (f + 8)) : 0, ve = l.current ? l.current.scrollWidth - l.current.offsetWidth : 0;
785
+ return /* @__PURE__ */ L(
786
+ N,
787
+ {
788
+ "aria-label": w.carousel_title,
789
+ "aria-roledescription": "carousel",
790
+ ref: g,
791
+ role: "group/region",
792
+ sx: {
793
+ alignItems: "center",
794
+ boxSizing: "border-box",
795
+ height: r,
796
+ width: c || "100%"
797
+ },
798
+ children: [
799
+ /* @__PURE__ */ i(
800
+ N,
801
+ {
802
+ direction: "row",
803
+ onScroll: J,
804
+ onTouchEnd: ee,
805
+ onTouchMove: te,
806
+ onTouchStart: Z,
807
+ ref: l,
808
+ sx: {
809
+ alignItems: "center",
810
+ height: r && "100%",
811
+ gap: 8,
812
+ listStyleType: "none",
813
+ m: 0,
814
+ maxWidth: C ? "calc(100% - 32px)" : "100%",
815
+ overflowX: "auto",
816
+ overflowY: "hidden",
817
+ p: 0,
818
+ scrollbarWidth: "none",
819
+ "-ms-overflow-style": "none",
820
+ "-webkit-overflow-scrolling": "touch",
821
+ "&::-webkit-scrollbar": {
822
+ display: "none"
823
+ }
824
+ },
825
+ children: /* @__PURE__ */ i(
826
+ gt,
827
+ {
828
+ activeCardIndex: v,
829
+ beats: o,
830
+ cardWidth: f,
831
+ heightOverrides: r,
832
+ onCardClick: a,
833
+ posthog: s,
834
+ showCTAColocatedWithText: n,
835
+ showIcon: m,
836
+ variant: _
837
+ }
838
+ )
839
+ }
840
+ ),
841
+ p && /* @__PURE__ */ i(
842
+ Et,
843
+ {
844
+ currentBeatIndex: v + d - 1,
845
+ numBeats: o.length + 1,
846
+ onNextClick: Y,
847
+ onPreviousClick: X,
848
+ scrollRightBoundary: ve,
849
+ scrollX: E,
850
+ shouldApplyDotAnimation: e,
851
+ visibleCardsCount: d
852
+ }
853
+ )
854
+ ]
855
+ }
856
+ );
857
+ }, At = U(It), St = ({
858
+ analyticsMetadata: t,
859
+ onCardClick: e,
860
+ posthog: o,
861
+ widthOverrides: n
862
+ }) => {
863
+ const { carouselCopy: r } = B(), { onEvent: a } = j(), s = () => {
864
+ a && (a(y.ON_VIEW_MORE_CLICKED, t), e(), o?.capture("clicked_view_more"));
865
+ };
866
+ return r ? /* @__PURE__ */ L(
867
+ N,
868
+ {
869
+ alignItems: "center",
870
+ direction: "row",
871
+ justifyContent: "space-between",
872
+ spacing: 2,
873
+ sx: {
874
+ p: 16,
875
+ pb: 8,
876
+ width: n || void 0
877
+ },
878
+ children: [
879
+ /* @__PURE__ */ i(Be, { children: r.carousel_title }),
880
+ /* @__PURE__ */ i(
881
+ ne,
882
+ {
883
+ endIcon: /* @__PURE__ */ i(fe, { size: 20 }),
884
+ onClick: s,
885
+ size: "small",
886
+ variant: "text",
887
+ children: r.view_all_insights_in_full_feed_cta_aria
888
+ }
889
+ )
890
+ ]
891
+ }
892
+ ) : /* @__PURE__ */ i(ze, {});
893
+ }, ft = U(St), Tt = ({
894
+ heightOverrides: t,
895
+ widthOverrides: e,
896
+ children: o
897
+ }) => {
898
+ const { carouselCopy: n } = B();
899
+ return /* @__PURE__ */ i(
900
+ Q,
901
+ {
902
+ "aria-label": n?.carousel_title,
903
+ "aria-roledescription": "carousel",
904
+ role: "group",
905
+ sx: {
906
+ boxSizing: "border-box",
907
+ height: t ? void 0 : "100%",
908
+ m: "0 auto",
909
+ width: e ? void 0 : "100%"
910
+ },
911
+ children: o
912
+ }
913
+ );
914
+ }, Le = ({
915
+ ariaLabel: t,
916
+ heightOverrides: e,
917
+ onCardClick: o,
918
+ posthog: n,
919
+ showIcon: r,
920
+ variant: a
921
+ }) => {
922
+ const { cardsCopy: s } = B(), p = H(), { onEvent: m } = j(), { onPageview: C } = Me();
923
+ h.useEffect(() => {
924
+ C(k.MICRO_WIDGET_CAROUSEL_NO_RELEVANT_INSIGHTS);
925
+ }, []);
926
+ const _ = () => {
927
+ o && o(), m(y.ON_NO_RELEVANT_INSIGHTS_CLICKED), n?.capture("clicked_insight", {
928
+ template: "no_relevant_insights"
929
+ });
930
+ };
931
+ return /* @__PURE__ */ i(
932
+ q,
933
+ {
934
+ ariaLabel: t,
935
+ cardSx: {
936
+ borderRadius: 2
937
+ },
938
+ description: s.no_relevant_insights_card_description,
939
+ hasCardEffect: !0,
940
+ heightOverrides: e,
941
+ icon: r && /* @__PURE__ */ i(R, { bgColor: T(p.palette.primary.main, 0.15), name: "lightbulb" }),
942
+ onCardClick: _,
943
+ onPrimaryAction: _,
944
+ primaryActionText: s.micro_card_cta,
945
+ title: s.no_relevant_insights_card_title,
946
+ variant: a
947
+ }
948
+ );
949
+ }, Qt = U(Le), De = ({
950
+ ariaLabel: t,
951
+ heightOverrides: e,
952
+ onCardClick: o,
953
+ showIcon: n,
954
+ variant: r
955
+ }) => {
956
+ const { onPageview: a } = Me(), { zeroStateCopy: s } = B(), p = H();
957
+ return h.useEffect(() => {
958
+ a(k.MICRO_WIDGET_CAROUSEL_ZERO_STATE);
959
+ }, []), /* @__PURE__ */ i(
960
+ q,
961
+ {
962
+ ariaLabel: t,
963
+ cardSx: {
964
+ borderRadius: 2
965
+ },
966
+ description: s.carousel_zero_state_description,
967
+ hasCardEffect: !0,
968
+ heightOverrides: e,
969
+ icon: n && /* @__PURE__ */ i(R, { bgColor: T(p.palette.primary.main, 0.15), name: "lightbulb" }),
970
+ onCardClick: o,
971
+ title: s.carousel_zero_state_title,
972
+ variant: r
973
+ }
974
+ );
975
+ }, qt = U(De), Rt = () => /* @__PURE__ */ i(
976
+ Q,
977
+ {
978
+ sx: {
979
+ alignItems: "center",
980
+ display: "flex",
981
+ height: "100%",
982
+ justifyContent: "center",
983
+ width: "100%"
984
+ },
985
+ children: /* @__PURE__ */ i(He, {})
986
+ }
987
+ ), G = new nt(), Ot = ({
988
+ allowSingleCardPeeking: t,
989
+ areBeatsLoading: e,
990
+ beats: o = [],
991
+ // This also determines the length of the carousel controls (beat.length + 1)
992
+ showCTAColocatedWithText: n = !0,
993
+ endpoint: r = "/",
994
+ heightOverrides: a,
995
+ logOutUser: s,
996
+ onCardClick: p = () => {
997
+ },
998
+ onEvent: m = () => {
999
+ },
1000
+ onPageview: C = () => {
1001
+ },
1002
+ posthog: _,
1003
+ showBorder: c = !0,
1004
+ showCarouselControls: d,
1005
+ showHeader: l,
1006
+ showIcon: g,
1007
+ showWithMargin: E = !0,
1008
+ token: A = "",
1009
+ userHasFullInsightFeedBeats: I,
1010
+ variant: D,
1011
+ visibleCardsCount: V = 1,
1012
+ widthOverrides: S
1013
+ }) => {
1014
+ const [f, M] = oe("STANDARD"), [w, u] = oe(!1), [Y, X] = oe(!1), J = je([m], G), ee = Ye([C], G);
1015
+ Xe({
1016
+ widgetName: "InsightsMicroWidget",
1017
+ isLoaded: w
1018
+ }), h.useEffect(() => {
1019
+ !G.isInitialized && !Y && (G.initialize(r, A, s).catch(() => X(!1)), X(!0));
1020
+ }, [r, A, s, G.isInitialized, Y]), h.useEffect(() => {
1021
+ const v = window.innerHeight;
1022
+ v < 180 ? M("STANDARD") : v >= 180 && v < 200 ? M("LARGE") : v >= 200 && v < 248 ? M("XLARGE") : v >= 248 && M("XXLARGE");
1023
+ }, [window.innerHeight]), h.useEffect(() => {
1024
+ u(!e && G.isInitialized);
1025
+ }, [e, G.isInitialized]);
1026
+ const te = {
1027
+ showCTAColocatedWithText: n,
1028
+ heightOverrides: a,
1029
+ onCardClick: p,
1030
+ posthog: _,
1031
+ showIcon: g,
1032
+ showWithMargin: E,
1033
+ widthOverrides: S
1034
+ }, Z = {
1035
+ carouselSize: f,
1036
+ variant: D,
1037
+ showCTAColocatedWithText: n,
1038
+ heightOverrides: a,
1039
+ onCardClick: p,
1040
+ posthog: _,
1041
+ showIcon: g
1042
+ };
1043
+ return /* @__PURE__ */ i(rt, { onEvent: J, onPageview: ee, store: G, children: /* @__PURE__ */ L(Tt, { heightOverrides: a, widthOverrides: S, children: [
1044
+ !w && /* @__PURE__ */ i(Rt, {}),
1045
+ w && l && /* @__PURE__ */ i(
1046
+ ft,
1047
+ {
1048
+ analyticsMetadata: me,
1049
+ onCardClick: p,
1050
+ posthog: _,
1051
+ widthOverrides: S
1052
+ }
1053
+ ),
1054
+ w && !!o.length && /* @__PURE__ */ i(
1055
+ At,
1056
+ {
1057
+ allowSingleCardPeeking: t,
1058
+ analyticsMetadata: me,
1059
+ beats: o,
1060
+ showCarouselControls: d,
1061
+ variant: c ? D : void 0,
1062
+ visibleCardsCount: V,
1063
+ ...te
1064
+ }
1065
+ ),
1066
+ w && !o.length && /* @__PURE__ */ i(
1067
+ N,
1068
+ {
1069
+ sx: {
1070
+ alignItems: "center",
1071
+ height: a,
1072
+ width: S || "100%"
1073
+ },
1074
+ children: /* @__PURE__ */ i(
1075
+ N,
1076
+ {
1077
+ sx: {
1078
+ height: `calc(${ht[f]}px - 44px)`,
1079
+ width: E ? `calc(${S}px - 32px)` : "100%"
1080
+ },
1081
+ children: I ? /* @__PURE__ */ i(Le, { ...Z }) : /* @__PURE__ */ i(De, { ...Z })
1082
+ }
1083
+ )
1084
+ }
1085
+ )
1086
+ ] }) });
1087
+ }, Jt = U(Ot), yt = ({
1088
+ ariaLabel: t,
1089
+ heightOverrides: e,
1090
+ isActiveCard: o,
1091
+ onCardClick: n,
1092
+ posthog: r,
1093
+ widthOverrides: a,
1094
+ showIcon: s,
1095
+ variant: p
1096
+ }) => {
1097
+ const m = H(), { ref: C, inView: _ } = Te({
1098
+ threshold: we
1099
+ }), { cardsCopy: c } = B(), { onEvent: d } = j();
1100
+ ie(() => {
1101
+ _ && (d(Ne.ON_VIEW_MORE_VIEWED), r?.capture("viewed_insight", {
1102
+ template: "view_more_card"
1103
+ }));
1104
+ }, [_]);
1105
+ const l = () => {
1106
+ n && n(), d(y.ON_VIEW_MORE_CLICKED), r?.capture("clicked_insight", {
1107
+ template: "view_more_card"
1108
+ });
1109
+ };
1110
+ return /* @__PURE__ */ i(
1111
+ q,
1112
+ {
1113
+ "aria-roledescription": "slide",
1114
+ ariaLabel: t,
1115
+ cardSx: {
1116
+ borderRadius: 2
1117
+ },
1118
+ description: c.view_more_card_description,
1119
+ hasCardEffect: !0,
1120
+ heightOverrides: e,
1121
+ icon: s && /* @__PURE__ */ i(R, { bgColor: T(m.palette.primary.main, 0.15), name: "show_chart" }),
1122
+ isActiveCard: o,
1123
+ onCardClick: l,
1124
+ onPrimaryAction: l,
1125
+ primaryActionText: c.micro_card_cta,
1126
+ ref: C,
1127
+ title: c.view_more_card_title,
1128
+ variant: p,
1129
+ widthOverrides: a
1130
+ }
1131
+ );
1132
+ }, Wt = U(yt);
1133
+ export {
1134
+ nt as A,
1135
+ R as B,
1136
+ ft as C,
1137
+ Ct as I,
1138
+ At as M,
1139
+ Qt as N,
1140
+ me as T,
1141
+ Wt as V,
1142
+ qt as Z,
1143
+ Jt as a,
1144
+ rt as b,
1145
+ q as c,
1146
+ dt as d
1147
+ };