@kiva/kv-components 3.106.0 → 3.107.1

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 (179) hide show
  1. package/.eslintrc.cjs +1 -0
  2. package/CHANGELOG.md +22 -0
  3. package/dist/components/.storybook/main.js +85 -0
  4. package/dist/components/.storybook/package.json +3 -0
  5. package/dist/components/.storybook/preview.js +61 -0
  6. package/dist/components/.storybook/tailwind.css +5 -0
  7. package/dist/components/KvAccordionItem.vue +130 -0
  8. package/dist/components/KvActivityRow.vue +33 -0
  9. package/dist/components/KvBorrowerImage.vue +179 -0
  10. package/dist/components/KvButton.vue +287 -0
  11. package/dist/components/KvCarousel.vue +297 -0
  12. package/dist/components/KvCartModal.vue +365 -0
  13. package/dist/components/KvCheckbox.vue +203 -0
  14. package/dist/components/KvChip.vue +54 -0
  15. package/dist/components/KvClassicLoanCard.vue +527 -0
  16. package/dist/components/KvCommentsAdd.vue +135 -0
  17. package/dist/components/KvCommentsContainer.vue +84 -0
  18. package/dist/components/KvCommentsHeartButton.vue +70 -0
  19. package/dist/components/KvCommentsList.vue +68 -0
  20. package/dist/components/KvCommentsListItem.vue +241 -0
  21. package/dist/components/KvCommentsReplyButton.vue +52 -0
  22. package/dist/components/KvContentfulImg.vue +273 -0
  23. package/dist/components/KvCountdownTimer.vue +59 -0
  24. package/dist/components/KvExpandable.vue +84 -0
  25. package/dist/components/KvExpandableQuestion.vue +120 -0
  26. package/dist/components/KvFlag.vue +120 -0
  27. package/dist/components/KvGrid.vue +28 -0
  28. package/dist/components/KvImpactDashboardHeader.vue +40 -0
  29. package/dist/components/KvInlineActivityCard.vue +55 -0
  30. package/dist/components/KvInlineActivityFeed.vue +38 -0
  31. package/dist/components/KvIntroductionLoanCard.vue +446 -0
  32. package/dist/components/KvLendAmountButton.vue +65 -0
  33. package/dist/components/KvLendCta.vue +451 -0
  34. package/dist/components/KvLightbox.vue +334 -0
  35. package/dist/components/KvLineGraph.vue +128 -0
  36. package/dist/components/KvLoadingPlaceholder.vue +38 -0
  37. package/dist/components/KvLoadingSpinner.vue +81 -0
  38. package/dist/components/KvLoanActivities.vue +268 -0
  39. package/dist/components/KvLoanBookmark.vue +39 -0
  40. package/dist/components/KvLoanCallouts.vue +53 -0
  41. package/dist/components/KvLoanProgressGroup.vue +76 -0
  42. package/dist/components/KvLoanTag.vue +88 -0
  43. package/dist/components/KvLoanTeamPick.vue +44 -0
  44. package/dist/components/KvLoanUse.vue +92 -0
  45. package/dist/components/KvMap.vue +599 -0
  46. package/dist/components/KvMaterialIcon.vue +47 -0
  47. package/dist/components/KvPageContainer.vue +15 -0
  48. package/dist/components/KvPagination.vue +198 -0
  49. package/dist/components/KvPieChart.vue +257 -0
  50. package/dist/components/KvPopper.vue +178 -0
  51. package/dist/components/KvProgressBar.vue +149 -0
  52. package/dist/components/KvRadio.vue +198 -0
  53. package/dist/components/KvSelect.vue +114 -0
  54. package/dist/components/KvSideSheet.vue +134 -0
  55. package/dist/components/KvSwitch.vue +143 -0
  56. package/dist/components/KvTab.vue +90 -0
  57. package/dist/components/KvTabPanel.vue +64 -0
  58. package/dist/components/KvTabs.vue +182 -0
  59. package/dist/components/KvTextInput.vue +247 -0
  60. package/dist/components/KvTextLink.vue +138 -0
  61. package/dist/components/KvThemeProvider.vue +122 -0
  62. package/dist/components/KvToast.vue +221 -0
  63. package/dist/components/KvTooltip.vue +168 -0
  64. package/dist/components/KvTreeMapChart.vue +229 -0
  65. package/dist/components/KvUserAvatar.vue +132 -0
  66. package/dist/components/KvVerticalCarousel.vue +156 -0
  67. package/dist/components/KvVotingCard.vue +160 -0
  68. package/dist/components/KvVotingCardV2.vue +154 -0
  69. package/dist/components/KvWideLoanCard.vue +432 -0
  70. package/dist/components/stories/Forms.stories.js +62 -0
  71. package/dist/components/stories/KvAccordionItem.stories.js +24 -0
  72. package/dist/components/stories/KvActivityRow.stories.js +25 -0
  73. package/dist/components/stories/KvBorrowerImage.stories.js +68 -0
  74. package/dist/components/stories/KvButton.stories.js +144 -0
  75. package/dist/components/stories/KvCarousel.stories.js +426 -0
  76. package/dist/components/stories/KvCartModal.stories.js +54 -0
  77. package/dist/components/stories/KvCheckbox.stories.js +163 -0
  78. package/dist/components/stories/KvChip.stories.js +43 -0
  79. package/dist/components/stories/KvClassicLoanCard.stories.js +480 -0
  80. package/dist/components/stories/KvCommentsAdd.stories.js +32 -0
  81. package/dist/components/stories/KvCommentsContainer.stories.js +42 -0
  82. package/dist/components/stories/KvCommentsHeartButton.stories.js +25 -0
  83. package/dist/components/stories/KvCommentsList.stories.js +39 -0
  84. package/dist/components/stories/KvCommentsListItem.stories.js +45 -0
  85. package/dist/components/stories/KvCommentsReplyButton.stories.js +21 -0
  86. package/dist/components/stories/KvContentfulImg.stories.js +196 -0
  87. package/dist/components/stories/KvCountdownTimer.stories.js +30 -0
  88. package/dist/components/stories/KvExpandableQuestion.stories.js +129 -0
  89. package/dist/components/stories/KvFlag.stories.js +36 -0
  90. package/dist/components/stories/KvGrid.stories.js +97 -0
  91. package/dist/components/stories/KvImpactDashboardHeader.stories.js +22 -0
  92. package/dist/components/stories/KvInlineActivityCard.stories.js +69 -0
  93. package/dist/components/stories/KvInlineActivityFeed.stories.js +76 -0
  94. package/dist/components/stories/KvIntroductionLoanCard.stories.js +208 -0
  95. package/dist/components/stories/KvLendAmountButton.stories.js +31 -0
  96. package/dist/components/stories/KvLendCta.stories.js +177 -0
  97. package/dist/components/stories/KvLightbox.stories.js +304 -0
  98. package/dist/components/stories/KvLineGraph.stories.js +52 -0
  99. package/dist/components/stories/KvLoadingPlaceholder.stories.js +17 -0
  100. package/dist/components/stories/KvLoadingSpinner.stories.js +52 -0
  101. package/dist/components/stories/KvLoanActivities.stories.js +104 -0
  102. package/dist/components/stories/KvLoanBookmark.stories.js +22 -0
  103. package/dist/components/stories/KvLoanCallouts.stories.js +22 -0
  104. package/dist/components/stories/KvLoanProgressGroup.stories.js +29 -0
  105. package/dist/components/stories/KvLoanTag.stories.js +61 -0
  106. package/dist/components/stories/KvLoanTeamPick.stories.js +20 -0
  107. package/dist/components/stories/KvLoanUse.stories.js +60 -0
  108. package/dist/components/stories/KvMap.stories.js +121 -0
  109. package/dist/components/stories/KvMaterialIcon.stories.js +201 -0
  110. package/dist/components/stories/KvPageContainer.stories.js +50 -0
  111. package/dist/components/stories/KvPagination.stories.js +70 -0
  112. package/dist/components/stories/KvPieChart.stories.js +47 -0
  113. package/dist/components/stories/KvProgressBar.stories.js +53 -0
  114. package/dist/components/stories/KvRadio.stories.js +140 -0
  115. package/dist/components/stories/KvSelect.stories.js +125 -0
  116. package/dist/components/stories/KvSideSheet.stories.js +50 -0
  117. package/dist/components/stories/KvSwitch.stories.js +66 -0
  118. package/dist/components/stories/KvTabs.stories.js +106 -0
  119. package/dist/components/stories/KvTextInput.stories.js +194 -0
  120. package/dist/components/stories/KvTextLink.stories.js +55 -0
  121. package/dist/components/stories/KvThemeProvider.stories.js +178 -0
  122. package/dist/components/stories/KvToast.stories.js +117 -0
  123. package/dist/components/stories/KvTooltip.stories.js +26 -0
  124. package/dist/components/stories/KvTreeMapChart.stories.js +42 -0
  125. package/dist/components/stories/KvUserAvatar.stories.js +47 -0
  126. package/dist/components/stories/KvVerticalCarousel.stories.js +168 -0
  127. package/dist/components/stories/KvVotingCard.stories.js +33 -0
  128. package/dist/components/stories/KvVotingCardV2.stories.js +89 -0
  129. package/dist/components/stories/KvWideLoanCard.stories.js +292 -0
  130. package/dist/components/stories/StyleguidePrimitives.stories.js +499 -0
  131. package/dist/components/stories/StyleguideProse.stories.js +215 -0
  132. package/dist/data/countries-borders.json +1 -0
  133. package/dist/data/ne_110m_admin_0_countries.json +1 -0
  134. package/dist/utils/Alea.cjs +87 -0
  135. package/dist/utils/Alea.js +9 -0
  136. package/dist/utils/attrs.cjs +50 -0
  137. package/dist/utils/attrs.js +7 -0
  138. package/dist/utils/carousels.cjs +184 -0
  139. package/dist/utils/carousels.js +8 -0
  140. package/dist/utils/chunk-3HK4G4NT.js +27 -0
  141. package/dist/utils/chunk-55HF2ORX.js +201 -0
  142. package/dist/utils/chunk-AY3PR5S4.js +54 -0
  143. package/dist/utils/chunk-AZPWOFD5.js +148 -0
  144. package/dist/utils/chunk-B5J5WLAH.js +18 -0
  145. package/dist/utils/chunk-GPSH6OPA.js +64 -0
  146. package/dist/utils/chunk-HIY5IW65.js +28 -0
  147. package/dist/utils/chunk-HV3AUBFT.js +15 -0
  148. package/dist/utils/chunk-MSMZIN54.js +110 -0
  149. package/dist/utils/chunk-OXJCCNNW.js +30 -0
  150. package/dist/utils/chunk-S3MABILA.js +22 -0
  151. package/dist/utils/chunk-VIGEMAKO.js +249 -0
  152. package/dist/utils/chunk-YCNMJ4YV.js +37 -0
  153. package/dist/utils/chunk-YFEC5ODJ.js +129 -0
  154. package/dist/utils/expander.cjs +78 -0
  155. package/dist/utils/expander.js +9 -0
  156. package/dist/utils/imageUtils.cjs +54 -0
  157. package/dist/utils/imageUtils.js +9 -0
  158. package/dist/utils/index.cjs +1118 -0
  159. package/dist/utils/index.js +166 -0
  160. package/dist/utils/loanCard.cjs +222 -0
  161. package/dist/utils/loanCard.js +9 -0
  162. package/dist/utils/loanUtils.cjs +170 -0
  163. package/dist/utils/loanUtils.js +23 -0
  164. package/dist/utils/mapUtils.cjs +276 -0
  165. package/dist/utils/mapUtils.js +15 -0
  166. package/dist/utils/printing.cjs +42 -0
  167. package/dist/utils/printing.js +9 -0
  168. package/dist/utils/scrollLock.cjs +54 -0
  169. package/dist/utils/scrollLock.js +13 -0
  170. package/dist/utils/throttle.cjs +38 -0
  171. package/dist/utils/throttle.js +7 -0
  172. package/dist/utils/touchEvents.cjs +47 -0
  173. package/dist/utils/touchEvents.js +11 -0
  174. package/dist/utils/treemap.cjs +133 -0
  175. package/dist/utils/treemap.js +7 -0
  176. package/package.json +12 -4
  177. package/utils/index.js +14 -0
  178. package/vue/KvVerticalCarousel.vue +1 -1
  179. package/index.js +0 -3
@@ -0,0 +1,1118 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+
33
+ // utils/themeUtils.cjs
34
+ var require_themeUtils = __commonJS({
35
+ "utils/themeUtils.cjs"(exports, module2) {
36
+ var headerNumberCase = (str) => str.replace("h-1", "h1").replace("h-2", "h2").replace("h-3", "h3").replace("h-4", "h4").replace("h-5", "h5");
37
+ var buildTailwindClassName = (prefix, value) => {
38
+ let name = `${prefix}-${value}`;
39
+ name = name.replace("-DEFAULT", "");
40
+ return name;
41
+ };
42
+ var kebabCase = (str) => str.split("").map((letter, idx) => letter.toUpperCase() === letter ? `${idx !== 0 ? "-" : ""}${letter.toLowerCase()}` : letter).join("");
43
+ var removeObjectProperty = (object, key) => {
44
+ const ret = { ...object };
45
+ delete ret[key];
46
+ return ret;
47
+ };
48
+ module2.exports = {
49
+ buildTailwindClassName,
50
+ headerNumberCase,
51
+ kebabCase,
52
+ removeObjectProperty
53
+ };
54
+ }
55
+ });
56
+
57
+ // utils/index.js
58
+ var utils_exports = {};
59
+ __export(utils_exports, {
60
+ BALANCE_CAMPAIGN: () => BALANCE_CAMPAIGN,
61
+ BASE_CAMPAIGN: () => BASE_CAMPAIGN,
62
+ ERL_COOKIE_NAME: () => ERL_COOKIE_NAME,
63
+ Mash: () => Mash,
64
+ NO_BALANCE_CAMPAIGN: () => NO_BALANCE_CAMPAIGN,
65
+ TOP_UP_CAMPAIGN: () => TOP_UP_CAMPAIGN,
66
+ animationCoordinator: () => animationCoordinator,
67
+ carouselUtil: () => carouselUtil,
68
+ collapse: () => collapse,
69
+ expand: () => expand,
70
+ generateMapMarkers: () => generateMapMarkers,
71
+ getCoordinatesBetween: () => getCoordinatesBetween,
72
+ getCountryColor: () => getCountryColor,
73
+ getDropdownPriceArray: () => getDropdownPriceArray,
74
+ getLendCtaSelectedOption: () => getLendCtaSelectedOption,
75
+ getLoansIntervals: () => getLoansIntervals,
76
+ getTreemap: () => getTreemap,
77
+ isBetween25And50: () => isBetween25And50,
78
+ isLegacyPlaceholderAvatar: () => isLegacyPlaceholderAvatar,
79
+ isLessThan25: () => isLessThan25,
80
+ isTargetElement: () => isTargetElement,
81
+ loanCardComputedProperties: () => loanCardComputedProperties,
82
+ loanCardMethods: () => loanCardMethods,
83
+ lockPrintSingleEl: () => lockPrintSingleEl,
84
+ lockScroll: () => lockScroll,
85
+ lockScrollSmallOnly: () => lockScrollSmallOnly,
86
+ offBodyTouchstart: () => offBodyTouchstart,
87
+ onBodyTouchstart: () => onBodyTouchstart,
88
+ randomizedUserAvatarClass: () => randomizedUserAvatarClass,
89
+ throttle: () => throttle,
90
+ unlockPrintSingleEl: () => unlockPrintSingleEl,
91
+ unlockScroll: () => unlockScroll,
92
+ unlockScrollSmallOnly: () => unlockScrollSmallOnly,
93
+ useAttrs: () => useAttrs
94
+ });
95
+ module.exports = __toCommonJS(utils_exports);
96
+
97
+ // utils/Alea.js
98
+ function Mash() {
99
+ let n = 4022871197;
100
+ const mash = function(data) {
101
+ data = data.toString();
102
+ for (let i = 0; i < data.length; i++) {
103
+ n += data.charCodeAt(i);
104
+ let h = 0.02519603282416938 * n;
105
+ n = h >>> 0;
106
+ h -= n;
107
+ h *= n;
108
+ n = h >>> 0;
109
+ h -= n;
110
+ n += h * 4294967296;
111
+ }
112
+ return (n >>> 0) * 23283064365386963e-26;
113
+ };
114
+ mash.version = "Mash 0.9";
115
+ return mash;
116
+ }
117
+
118
+ // utils/attrs.js
119
+ function asArray(input) {
120
+ if (!input)
121
+ return [];
122
+ return Array.isArray(input) ? input : [input];
123
+ }
124
+ function useAttrs({ attrs, listeners }, ownEvents = []) {
125
+ const classes = asArray(attrs == null ? void 0 : attrs.class);
126
+ const styles = asArray(attrs == null ? void 0 : attrs.style);
127
+ const inputListeners = listeners ? { ...listeners } : {};
128
+ ownEvents.forEach((event) => {
129
+ delete inputListeners[event];
130
+ });
131
+ const inputAttrs = { ...attrs };
132
+ delete inputAttrs.class;
133
+ delete inputAttrs.style;
134
+ return {
135
+ classes,
136
+ styles,
137
+ inputAttrs,
138
+ inputListeners
139
+ };
140
+ }
141
+
142
+ // utils/carousels.js
143
+ var import_vue_demi = require("vue-demi");
144
+ var import_embla_carousel = __toESM(require("embla-carousel"), 1);
145
+
146
+ // utils/throttle.js
147
+ function throttle(func, timeFrame) {
148
+ let lastTime = 0;
149
+ return function t(...args) {
150
+ const now = /* @__PURE__ */ new Date();
151
+ if (now - lastTime >= timeFrame) {
152
+ func(...args);
153
+ lastTime = now;
154
+ }
155
+ };
156
+ }
157
+
158
+ // utils/carousels.js
159
+ function carouselUtil(props, { emit, slots }, extraEmblaOptions) {
160
+ var _a;
161
+ const {
162
+ emblaOptions,
163
+ slidesToScroll
164
+ } = (0, import_vue_demi.toRefs)(props);
165
+ const rootEl = (0, import_vue_demi.ref)(null);
166
+ const embla = (0, import_vue_demi.ref)(null);
167
+ const slides = (0, import_vue_demi.ref)([]);
168
+ const startIndex = ((_a = emblaOptions.value) == null ? void 0 : _a.startIndex) ?? 0;
169
+ const currentIndex = (0, import_vue_demi.ref)(startIndex);
170
+ const slideIndicatorCount = (0, import_vue_demi.ref)(0);
171
+ const componentSlotKeys = (0, import_vue_demi.computed)(() => {
172
+ const keys = Object.keys(slots);
173
+ return keys;
174
+ });
175
+ const nextIndex = (0, import_vue_demi.computed)(() => {
176
+ const nextSlideIndex = currentIndex.value + 1;
177
+ if (nextSlideIndex < slides.value.length) {
178
+ return nextSlideIndex;
179
+ }
180
+ return 0;
181
+ });
182
+ const previousIndex = (0, import_vue_demi.computed)(() => {
183
+ const previousSlideIndex = currentIndex.value - 1;
184
+ if (previousSlideIndex >= 0) {
185
+ return previousSlideIndex;
186
+ }
187
+ return slides.value.length - 1;
188
+ });
189
+ const goToSlide = (index) => {
190
+ embla.value.scrollTo(index);
191
+ };
192
+ const handleUserInteraction = async (index, interactionType) => {
193
+ if (index !== null && typeof index !== "undefined") {
194
+ await (0, import_vue_demi.nextTick)();
195
+ goToSlide(index);
196
+ }
197
+ emit("interact-carousel", interactionType);
198
+ };
199
+ const slideIndicatorListLength = () => {
200
+ const indicator = embla.value ? embla.value.scrollSnapList().length : 0;
201
+ slideIndicatorCount.value = indicator;
202
+ return indicator;
203
+ };
204
+ const reInitVisible = () => {
205
+ const slidesInView = embla.value.slidesInView(true).length;
206
+ if (slidesInView) {
207
+ embla.value.reInit({
208
+ slidesToScroll: slidesInView,
209
+ inViewThreshold: 0.9
210
+ });
211
+ }
212
+ };
213
+ const reInit = () => {
214
+ embla.value.reInit();
215
+ if (slidesToScroll.value === "visible") {
216
+ reInitVisible();
217
+ }
218
+ slides.value = embla.value.slideNodes();
219
+ slideIndicatorListLength();
220
+ };
221
+ const onCarouselContainerClick = (e) => {
222
+ if (embla.value && !embla.value.clickAllowed()) {
223
+ e.preventDefault();
224
+ e.stopPropagation();
225
+ }
226
+ };
227
+ const isAriaHidden = (index) => {
228
+ if (embla.value) {
229
+ return !embla.value.slidesInView(true).includes(index);
230
+ }
231
+ return false;
232
+ };
233
+ (0, import_vue_demi.onMounted)(async () => {
234
+ var _a2;
235
+ embla.value = (0, import_embla_carousel.default)(rootEl.value, {
236
+ loop: true,
237
+ containScroll: "trimSnaps",
238
+ inViewThreshold: 0.9,
239
+ align: "start",
240
+ ...extraEmblaOptions,
241
+ ...emblaOptions.value
242
+ });
243
+ if (slidesToScroll.value === "visible") {
244
+ reInitVisible();
245
+ embla.value.on(
246
+ "resize",
247
+ throttle(() => {
248
+ embla.value.reInit({
249
+ slidesToScroll: embla.value.slidesInView(true).length || "auto",
250
+ inViewThreshold: 0.9
251
+ });
252
+ slides.value = embla.value.slideNodes();
253
+ slideIndicatorListLength();
254
+ }, 250)
255
+ );
256
+ }
257
+ slides.value = embla.value.slideNodes();
258
+ slideIndicatorListLength();
259
+ (_a2 = embla == null ? void 0 : embla.value) == null ? void 0 : _a2.on("select", () => {
260
+ currentIndex.value = embla.value.selectedScrollSnap();
261
+ (0, import_vue_demi.nextTick)(() => {
262
+ emit("change", currentIndex);
263
+ });
264
+ });
265
+ });
266
+ (0, import_vue_demi.onUnmounted)(async () => {
267
+ var _a2, _b;
268
+ (_a2 = embla == null ? void 0 : embla.value) == null ? void 0 : _a2.off("select");
269
+ (_b = embla == null ? void 0 : embla.value) == null ? void 0 : _b.destroy();
270
+ });
271
+ return {
272
+ rootEl,
273
+ embla,
274
+ slides,
275
+ currentIndex,
276
+ componentSlotKeys,
277
+ nextIndex,
278
+ previousIndex,
279
+ slideIndicatorCount,
280
+ handleUserInteraction,
281
+ goToSlide,
282
+ reInit,
283
+ reInitVisible,
284
+ onCarouselContainerClick,
285
+ isAriaHidden,
286
+ slideIndicatorListLength
287
+ };
288
+ }
289
+
290
+ // utils/expander.js
291
+ function setInitialStyle(el, { property, delay, easing }) {
292
+ el.style.overflow = "hidden";
293
+ el.style.transition = `${property} ${delay}ms ${easing}`;
294
+ }
295
+ function unsetStyles(el, { property }) {
296
+ el.style[property] = null;
297
+ el.style.overflow = null;
298
+ el.style.transition = null;
299
+ }
300
+ function expand(el, {
301
+ easing = "ease",
302
+ delay = 500,
303
+ done = () => {
304
+ },
305
+ from = 0,
306
+ property = "height"
307
+ }) {
308
+ setInitialStyle(el, { property, delay, easing });
309
+ el.style[property] = "auto";
310
+ el.style.display = null;
311
+ const propValue = window.getComputedStyle(el).getPropertyValue(property);
312
+ el.style[property] = from;
313
+ el.addEventListener("transitionend", function listener() {
314
+ unsetStyles(el, { property });
315
+ done();
316
+ el.removeEventListener("transitionend", listener, true);
317
+ }, true);
318
+ void el.offsetWidth;
319
+ el.style[property] = propValue;
320
+ }
321
+ function collapse(el, {
322
+ easing = "ease",
323
+ delay = 500,
324
+ done = () => {
325
+ },
326
+ to = 0,
327
+ property = "height"
328
+ }) {
329
+ setInitialStyle(el, { property, delay, easing });
330
+ el.style[property] = window.getComputedStyle(el).getPropertyValue(property);
331
+ el.addEventListener("transitionend", function listener() {
332
+ unsetStyles(el, { property });
333
+ done();
334
+ el.removeEventListener("transitionend", listener, true);
335
+ }, true);
336
+ void el.offsetWidth;
337
+ el.style[property] = to;
338
+ }
339
+
340
+ // utils/imageUtils.js
341
+ function isLegacyPlaceholderAvatar(filename) {
342
+ if (!filename) {
343
+ return false;
344
+ }
345
+ let filenameCleaned = filename.toString();
346
+ if (filenameCleaned.includes(".")) {
347
+ [filenameCleaned] = filenameCleaned.split(".");
348
+ }
349
+ const defaultProfileIds = ["726677", "315726", "4d844ac2c0b77a8a522741b908ea5c32"];
350
+ return defaultProfileIds.includes(filenameCleaned);
351
+ }
352
+ function randomizedUserAvatarClass() {
353
+ const userCardStyleOptions = [
354
+ { color: "tw-text-action", bg: "tw-bg-brand-100" },
355
+ { color: "tw-text-black", bg: "tw-bg-brand-100" },
356
+ { color: "tw-text-white", bg: "tw-bg-action" },
357
+ { color: "tw-text-brand-100", bg: "tw-bg-action" },
358
+ { color: "tw-text-primary-inverse", bg: "tw-bg-action" },
359
+ { color: "tw-text-white", bg: "tw-bg-black" },
360
+ { color: "tw-text-action", bg: "tw-bg-black" }
361
+ ];
362
+ const randomStyle = userCardStyleOptions[Math.floor(Math.random() * userCardStyleOptions.length)];
363
+ return `${randomStyle.color} ${randomStyle.bg}`;
364
+ }
365
+
366
+ // utils/loanCard.js
367
+ var import_vue_demi2 = require("vue-demi");
368
+ var import_js = require("@mdi/js");
369
+ var LSE_LOAN_KEY = "N/A";
370
+ var ECO_FRIENDLY_KEY = "ECO-FRIENDLY";
371
+ var SUSTAINABLE_AG_KEY = "SUSTAINABLE AG";
372
+ var SINGLE_PARENT_KEY = "SINGLE PARENT";
373
+ var REFUGEE_KEY = "REFUGEES/DISPLACED";
374
+ var findCalloutData = (tags, tagName) => (tags == null ? void 0 : tags.find((t) => t.name.replace("#", "").toUpperCase() === tagName.toUpperCase())) ?? {};
375
+ function loanCardComputedProperties(props, hideUnitedStatesText = false) {
376
+ const {
377
+ externalLinks,
378
+ customLoanDetails,
379
+ loanId,
380
+ loan,
381
+ categoryPageName,
382
+ customCallouts
383
+ } = (0, import_vue_demi2.toRefs)(props);
384
+ const tag = (0, import_vue_demi2.computed)(() => externalLinks.value ? "a" : "router-link");
385
+ const readMorePath = (0, import_vue_demi2.computed)(() => customLoanDetails.value ? "" : `/lend/${loanId.value}`);
386
+ const isLoading = (0, import_vue_demi2.computed)(() => !loanId.value || !loan.value);
387
+ const borrowerName = (0, import_vue_demi2.computed)(() => {
388
+ var _a;
389
+ return ((_a = loan.value) == null ? void 0 : _a.name) || "";
390
+ });
391
+ const countryName = (0, import_vue_demi2.computed)(() => {
392
+ var _a, _b, _c;
393
+ return ((_c = (_b = (_a = loan.value) == null ? void 0 : _a.geocode) == null ? void 0 : _b.country) == null ? void 0 : _c.name) || "";
394
+ });
395
+ const countryCode = (0, import_vue_demi2.computed)(() => {
396
+ var _a, _b, _c;
397
+ return ((_c = (_b = (_a = loan.value) == null ? void 0 : _a.geocode) == null ? void 0 : _b.country) == null ? void 0 : _c.isoCode) || "";
398
+ });
399
+ const city = (0, import_vue_demi2.computed)(() => {
400
+ var _a, _b;
401
+ return ((_b = (_a = loan.value) == null ? void 0 : _a.geocode) == null ? void 0 : _b.city) || "";
402
+ });
403
+ const state = (0, import_vue_demi2.computed)(() => {
404
+ var _a, _b;
405
+ return ((_b = (_a = loan.value) == null ? void 0 : _a.geocode) == null ? void 0 : _b.state) || "";
406
+ });
407
+ const distributionModel = (0, import_vue_demi2.computed)(() => {
408
+ var _a;
409
+ return ((_a = loan.value) == null ? void 0 : _a.distributionModel) || "";
410
+ });
411
+ const imageHash = (0, import_vue_demi2.computed)(() => {
412
+ var _a, _b;
413
+ return ((_b = (_a = loan.value) == null ? void 0 : _a.image) == null ? void 0 : _b.hash) ?? "";
414
+ });
415
+ const hasProgressData = (0, import_vue_demi2.computed)(() => {
416
+ var _a, _b;
417
+ return typeof ((_a = loan.value) == null ? void 0 : _a.unreservedAmount) !== "undefined" && typeof ((_b = loan.value) == null ? void 0 : _b.fundraisingPercent) !== "undefined";
418
+ });
419
+ const allDataLoaded = (0, import_vue_demi2.computed)(() => !isLoading.value && hasProgressData.value);
420
+ const fundraisingPercent = (0, import_vue_demi2.computed)(() => {
421
+ var _a;
422
+ return ((_a = loan.value) == null ? void 0 : _a.fundraisingPercent) ?? 0;
423
+ });
424
+ const unreservedAmount = (0, import_vue_demi2.computed)(() => {
425
+ var _a;
426
+ const stringAmount = ((_a = loan.value) == null ? void 0 : _a.unreservedAmount) ?? "0";
427
+ return Number(stringAmount);
428
+ });
429
+ const formattedLocation = (0, import_vue_demi2.computed)(() => {
430
+ if (distributionModel.value === "direct") {
431
+ const countryText = hideUnitedStatesText && countryName.value.toLowerCase() === "united states" ? "" : `, ${countryName.value}`;
432
+ return `${city.value}, ${state.value}${countryText}`;
433
+ }
434
+ if (countryName.value === "Puerto Rico") {
435
+ return `${city.value}, PR`;
436
+ }
437
+ return countryName.value;
438
+ });
439
+ const loanUse = (0, import_vue_demi2.computed)(() => {
440
+ var _a;
441
+ return ((_a = loan.value) == null ? void 0 : _a.use) ?? "";
442
+ });
443
+ const loanStatus = (0, import_vue_demi2.computed)(() => {
444
+ var _a;
445
+ return ((_a = loan.value) == null ? void 0 : _a.status) ?? "";
446
+ });
447
+ const loanAmount = (0, import_vue_demi2.computed)(() => {
448
+ var _a;
449
+ return ((_a = loan.value) == null ? void 0 : _a.loanAmount) ?? "0";
450
+ });
451
+ const loanBorrowerCount = (0, import_vue_demi2.computed)(() => {
452
+ var _a;
453
+ return ((_a = loan.value) == null ? void 0 : _a.borrowerCount) ?? 0;
454
+ });
455
+ const loanCallouts = (0, import_vue_demi2.computed)(() => {
456
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
457
+ const callouts = [];
458
+ const activityName = ((_b = (_a = loan.value) == null ? void 0 : _a.activity) == null ? void 0 : _b.name) ?? "";
459
+ const activityId = ((_d = (_c = loan.value) == null ? void 0 : _c.activity) == null ? void 0 : _d.id) ?? null;
460
+ const sectorName = ((_f = (_e = loan.value) == null ? void 0 : _e.sector) == null ? void 0 : _f.name) ?? "";
461
+ const sectorId = ((_h = (_g = loan.value) == null ? void 0 : _g.sector) == null ? void 0 : _h.id) ?? null;
462
+ const tags = ((_j = (_i = loan.value) == null ? void 0 : _i.tags) == null ? void 0 : _j.filter((loantag) => loantag.charAt(0) === "#").map((loantag) => loantag.substring(1))) ?? [];
463
+ const themes = ((_k = loan.value) == null ? void 0 : _k.themes) ?? [];
464
+ const categories = {
465
+ ecoFriendly: !!tags.filter((t) => t.toUpperCase() === ECO_FRIENDLY_KEY || t.toUpperCase() === SUSTAINABLE_AG_KEY).length,
466
+ refugeesIdps: !!themes.filter((t) => t.toUpperCase() === REFUGEE_KEY).length,
467
+ singleParents: !!tags.filter((t) => t.toUpperCase() === SINGLE_PARENT_KEY).length
468
+ };
469
+ const isLseLoan = (_m = (_l = loan.value) == null ? void 0 : _l.partnerName) == null ? void 0 : _m.toUpperCase().includes(LSE_LOAN_KEY);
470
+ const tagsData = ((_n = loan.value) == null ? void 0 : _n.tagsData) ?? [];
471
+ const themesData = ((_o = loan.value) == null ? void 0 : _o.themesData) ?? [];
472
+ if (isLseLoan && tags.length) {
473
+ const position = Math.floor(Math.random() * tags.length);
474
+ const p1Tag = tags[position];
475
+ const tagData = findCalloutData(tagsData, p1Tag);
476
+ const id = (tagData == null ? void 0 : tagData.id) ?? null;
477
+ callouts.push({ label: p1Tag, type: "tag", id });
478
+ }
479
+ if (!categoryPageName.value) {
480
+ if (categories.ecoFriendly && !callouts.find((c) => c.label.toUpperCase() === ECO_FRIENDLY_KEY || c.label.toUpperCase() === SUSTAINABLE_AG_KEY)) {
481
+ callouts.push({ label: "Eco-friendly", type: "tag", id: 9 });
482
+ } else if (categories.refugeesIdps) {
483
+ callouts.push({ label: "Refugees and IDPs", type: "attribute", id: 28 });
484
+ } else if (categories.singleParents && !callouts.find((c) => c.label.toUpperCase() === SINGLE_PARENT_KEY)) {
485
+ callouts.push({ label: "Single Parent", type: "tag", id: 17 });
486
+ }
487
+ }
488
+ if (activityName && activityId && ((_p = categoryPageName.value) == null ? void 0 : _p.toUpperCase()) !== activityName.toUpperCase()) {
489
+ callouts.push({ id: activityId, label: activityName, type: "activity" });
490
+ }
491
+ if (sectorName && sectorId && activityName.toUpperCase() !== sectorName.toUpperCase() && sectorName.toUpperCase() !== ((_q = categoryPageName.value) == null ? void 0 : _q.toUpperCase()) && callouts.length < 2) {
492
+ callouts.push({ id: sectorId, label: sectorName, type: "sector" });
493
+ }
494
+ if (!!tags.length && callouts.length < 2) {
495
+ const position = Math.floor(Math.random() * tags.length);
496
+ const p4Tag = tags[position];
497
+ const tagData = findCalloutData(tagsData, p4Tag);
498
+ const id = (tagData == null ? void 0 : tagData.id) ?? null;
499
+ if (!callouts.filter((c) => c.label.toUpperCase() === p4Tag.toUpperCase()).length) {
500
+ callouts.push({ label: p4Tag, type: "tag", id });
501
+ }
502
+ }
503
+ if (!!themes.length && callouts.length < 2) {
504
+ const position = Math.floor(Math.random() * themes.length);
505
+ const theme = themes[position];
506
+ const themeData = findCalloutData(themesData, theme);
507
+ const id = (themeData == null ? void 0 : themeData.id) ?? null;
508
+ if (!callouts.filter((c) => c.label.toUpperCase() === theme.toUpperCase()).length && theme.toUpperCase() !== ((_r = categoryPageName.value) == null ? void 0 : _r.toUpperCase())) {
509
+ callouts.push({ label: theme, type: "attribute", id });
510
+ }
511
+ }
512
+ if (isLseLoan && callouts.length > 1)
513
+ return [callouts.shift()];
514
+ const customTags = ((_s = customCallouts.value) == null ? void 0 : _s.map((c) => ({ label: c }))) ?? [];
515
+ callouts.push(...customTags);
516
+ return callouts;
517
+ });
518
+ return {
519
+ tag,
520
+ readMorePath,
521
+ isLoading,
522
+ borrowerName,
523
+ countryName,
524
+ countryCode,
525
+ city,
526
+ state,
527
+ distributionModel,
528
+ imageHash,
529
+ hasProgressData,
530
+ allDataLoaded,
531
+ fundraisingPercent,
532
+ unreservedAmount,
533
+ formattedLocation,
534
+ loanUse,
535
+ loanStatus,
536
+ loanAmount,
537
+ loanBorrowerCount,
538
+ mdiMapMarker: import_js.mdiMapMarker,
539
+ loanCallouts
540
+ };
541
+ }
542
+ function loanCardMethods(props, emit) {
543
+ const {
544
+ loanId,
545
+ customLoanDetails,
546
+ kvTrackFunction
547
+ } = (0, import_vue_demi2.toRefs)(props);
548
+ function clickReadMore(target, event) {
549
+ kvTrackFunction.value("Lending", "click-Read more", target, loanId.value);
550
+ if (customLoanDetails.value) {
551
+ event.preventDefault();
552
+ emit("show-loan-details");
553
+ }
554
+ }
555
+ return {
556
+ clickReadMore
557
+ };
558
+ }
559
+
560
+ // utils/loanUtils.js
561
+ var import_numeral = __toESM(require("numeral"), 1);
562
+ var ERL_COOKIE_NAME = "kverlfivedollarnotes";
563
+ var TOP_UP_CAMPAIGN = "TOPUP-VB-BALANCE-MPV1";
564
+ var BASE_CAMPAIGN = "BASE-VB_BALANCE_MPV1";
565
+ var BALANCE_CAMPAIGN = "REPAYMENT-NOTIFICATION_BALANCE_MPV1";
566
+ var NO_BALANCE_CAMPAIGN = "REPAYMENT-NOTIFICATION_NO-BALANCE_MPV1";
567
+ function balanceCampaignOptions(val) {
568
+ if (val > 20)
569
+ return 25;
570
+ if (val > 15)
571
+ return 20;
572
+ if (val > 10)
573
+ return 15;
574
+ if (val > 5)
575
+ return 10;
576
+ return 5;
577
+ }
578
+ function isBetween25And50(unreservedAmount) {
579
+ return unreservedAmount <= 50 && unreservedAmount > 25;
580
+ }
581
+ function isLessThan25(unreservedAmount) {
582
+ return unreservedAmount < 25 && unreservedAmount > 0;
583
+ }
584
+ function getLendCtaSelectedOption(getCookie, setCookie, enableFiveDollarsNotes, campaign, unreservedAmount, userBalance, fiveDollarsSelected) {
585
+ if (enableFiveDollarsNotes && fiveDollarsSelected) {
586
+ return "5";
587
+ }
588
+ if (enableFiveDollarsNotes && typeof userBalance !== "undefined") {
589
+ let currentCampaign = getCookie == null ? void 0 : getCookie(ERL_COOKIE_NAME);
590
+ if (campaign && typeof campaign === "string" && !currentCampaign) {
591
+ const expires = /* @__PURE__ */ new Date();
592
+ expires.setHours(expires.getHours() + 24);
593
+ const campaignToCheck = campaign.toUpperCase();
594
+ currentCampaign = campaignToCheck.includes(TOP_UP_CAMPAIGN) ? TOP_UP_CAMPAIGN : campaignToCheck.includes(BASE_CAMPAIGN) ? BASE_CAMPAIGN : campaignToCheck.includes(BALANCE_CAMPAIGN) ? BALANCE_CAMPAIGN : campaignToCheck.includes(NO_BALANCE_CAMPAIGN) ? NO_BALANCE_CAMPAIGN : "";
595
+ if (currentCampaign && setCookie) {
596
+ setCookie(ERL_COOKIE_NAME, currentCampaign, { expires });
597
+ }
598
+ }
599
+ if (currentCampaign) {
600
+ let val = Math.floor(userBalance / 5) * 5;
601
+ if (currentCampaign === BASE_CAMPAIGN) {
602
+ val = val === 0 ? 5 : val > 25 ? 25 : val;
603
+ return Number(val <= unreservedAmount ? val : unreservedAmount).toFixed();
604
+ }
605
+ if (currentCampaign === BALANCE_CAMPAIGN) {
606
+ val = balanceCampaignOptions(val);
607
+ return Number(val).toFixed();
608
+ }
609
+ return Number(unreservedAmount > 5 ? 5 : unreservedAmount).toFixed();
610
+ }
611
+ }
612
+ if (isBetween25And50(unreservedAmount) || isLessThan25(unreservedAmount)) {
613
+ return Number(unreservedAmount).toFixed();
614
+ }
615
+ return "25";
616
+ }
617
+ function buildHugePriceArray(amountLeft) {
618
+ const priceArray = [];
619
+ let minAmount = 100;
620
+ let limitAmount = amountLeft > 1e3 ? 1e3 : amountLeft;
621
+ let optionCount = limitAmount / minAmount;
622
+ for (let i = 1; i <= optionCount; i += 1) {
623
+ const price = minAmount * i + 500;
624
+ if (price > limitAmount)
625
+ break;
626
+ priceArray.push((0, import_numeral.default)(price).format("0,0"));
627
+ }
628
+ minAmount = 1e3;
629
+ limitAmount = amountLeft > 1e4 ? 1e4 : amountLeft;
630
+ optionCount = limitAmount / minAmount;
631
+ for (let i = 1; i <= optionCount; i += 1) {
632
+ const price = minAmount * i + 1e3;
633
+ if (price > limitAmount)
634
+ break;
635
+ priceArray.push((0, import_numeral.default)(price).format("0,0"));
636
+ }
637
+ if (!priceArray.includes((0, import_numeral.default)(limitAmount).format("0,0"))) {
638
+ priceArray.push((0, import_numeral.default)(limitAmount).format("0,0"));
639
+ }
640
+ return priceArray;
641
+ }
642
+ function build5DollarsPriceArray(amountLeft) {
643
+ const limit5Notes = amountLeft < 50 ? amountLeft : 50;
644
+ const numberOf5 = limit5Notes / 5;
645
+ const numberOf25 = Math.ceil((amountLeft - limit5Notes) / 25) + 1;
646
+ const priceArray = [];
647
+ for (let i = 1; i <= numberOf5; i += 1) {
648
+ priceArray.push((0, import_numeral.default)(5 * i).format("0,0"));
649
+ }
650
+ if (amountLeft > limit5Notes) {
651
+ for (let i = 3; i <= numberOf25; i += 1) {
652
+ priceArray.push((0, import_numeral.default)(25 * i).format("0,0"));
653
+ }
654
+ }
655
+ return priceArray;
656
+ }
657
+ function buildPriceArray(amountLeft, minAmount) {
658
+ const optionCount = amountLeft / minAmount;
659
+ const priceArray = [];
660
+ for (let i = 1; i <= optionCount; i += 1) {
661
+ priceArray.push((0, import_numeral.default)(minAmount * i).format("0,0"));
662
+ }
663
+ return priceArray;
664
+ }
665
+ function getDropdownPriceArray(unreservedAmount, isCompleteLoanActive = false, minAmount = 25, enableFiveDollarsNotes = false, enableHugeAmount = false, isVisitor = true, inPfp = false) {
666
+ const parsedAmountLeft = parseFloat(unreservedAmount);
667
+ let priceArray = enableFiveDollarsNotes && !inPfp ? build5DollarsPriceArray(parsedAmountLeft).slice(0, 28) : buildPriceArray(parsedAmountLeft, minAmount).slice(0, 20);
668
+ if (enableHugeAmount && parsedAmountLeft > 500 && !isVisitor) {
669
+ const hugePriceArray = buildHugePriceArray(parsedAmountLeft);
670
+ priceArray = priceArray.concat(hugePriceArray);
671
+ }
672
+ if (isCompleteLoanActive && !priceArray.includes(Number(unreservedAmount).toFixed())) {
673
+ priceArray.push(Number(unreservedAmount).toFixed());
674
+ }
675
+ return priceArray;
676
+ }
677
+
678
+ // utils/mapUtils.js
679
+ function getRandomInRange(from, to, fixed) {
680
+ return (Math.random() * (to - from) + from).toFixed(fixed) * 1;
681
+ }
682
+ var randomCoordinates = Array.from(
683
+ { length: 20 },
684
+ () => [getRandomInRange(-180, 180, 3), getRandomInRange(-90, 90, 3)]
685
+ );
686
+ var mapColors = [
687
+ 100,
688
+ 300,
689
+ 500,
690
+ 650,
691
+ 800,
692
+ 1e3
693
+ ];
694
+ function getCoordinatesBetween(startCoordinates, endCoordinates, numberOfSteps) {
695
+ if (!startCoordinates || !endCoordinates || !numberOfSteps || numberOfSteps < 1 || !Array.isArray(startCoordinates) || !Array.isArray(endCoordinates) || startCoordinates.length !== 2 || endCoordinates.length !== 2) {
696
+ return [];
697
+ }
698
+ const diffX = endCoordinates[0] - startCoordinates[0];
699
+ const diffY = endCoordinates[1] - startCoordinates[1];
700
+ const sfX = diffX / numberOfSteps;
701
+ const sfY = diffY / numberOfSteps;
702
+ let i = 0;
703
+ let j = 0;
704
+ const lineCoordinates = [];
705
+ while (Math.abs(i) < Math.abs(diffX) || Math.abs(j) < Math.abs(diffY)) {
706
+ lineCoordinates.push([startCoordinates[0] + i, startCoordinates[1] + j]);
707
+ if (Math.abs(i) < Math.abs(diffX)) {
708
+ i += sfX;
709
+ }
710
+ if (Math.abs(j) < Math.abs(diffY)) {
711
+ j += sfY;
712
+ }
713
+ }
714
+ lineCoordinates[lineCoordinates.length - 1] = [endCoordinates[0], endCoordinates[1]];
715
+ return lineCoordinates;
716
+ }
717
+ function animateLines(mapInstance, originPoints, endPoint) {
718
+ const speedFactor = 100;
719
+ return new Promise((resolve) => {
720
+ mapInstance.addSource("endpoint", {
721
+ type: "geojson",
722
+ data: {
723
+ type: "Point",
724
+ coordinates: [
725
+ endPoint[0],
726
+ endPoint[1]
727
+ ]
728
+ }
729
+ });
730
+ const lineFlight = (startCoordinates, endCoordinates, index, lastLine = false) => {
731
+ const lineCoordinates = getCoordinatesBetween(startCoordinates, endCoordinates, speedFactor);
732
+ let animationCounter = 0;
733
+ const geojson = {
734
+ type: "FeatureCollection",
735
+ features: [{
736
+ type: "Feature",
737
+ geometry: {
738
+ type: "LineString",
739
+ coordinates: []
740
+ }
741
+ }]
742
+ };
743
+ mapInstance.addSource(`startPoint${index}`, {
744
+ type: "geojson",
745
+ data: {
746
+ type: "Point",
747
+ coordinates: [
748
+ startCoordinates[0],
749
+ startCoordinates[1]
750
+ ]
751
+ }
752
+ });
753
+ mapInstance.addLayer({
754
+ id: `line-animation${index}`,
755
+ type: "line",
756
+ source: {
757
+ type: "geojson",
758
+ data: geojson
759
+ },
760
+ layout: {
761
+ "line-cap": "round",
762
+ "line-join": "round"
763
+ },
764
+ paint: {
765
+ "line-color": "#277056",
766
+ "line-width": 2
767
+ }
768
+ });
769
+ const animateLine = () => {
770
+ if (animationCounter < lineCoordinates.length) {
771
+ geojson.features[0].geometry.coordinates.push(lineCoordinates[animationCounter]);
772
+ mapInstance.getSource(`line-animation${index}`).setData(geojson);
773
+ requestAnimationFrame(animateLine);
774
+ animationCounter += 1;
775
+ } else {
776
+ const coord = geojson.features[0].geometry.coordinates;
777
+ coord.shift();
778
+ coord.shift();
779
+ if (coord.length > 0) {
780
+ geojson.features[0].geometry.coordinates = coord;
781
+ mapInstance.getSource(`line-animation${index}`).setData(geojson);
782
+ requestAnimationFrame(animateLine);
783
+ } else {
784
+ mapInstance.removeLayer(`line-animation${index}`);
785
+ mapInstance.removeSource(`line-animation${index}`);
786
+ mapInstance.removeSource(`startPoint${index}`);
787
+ if (lastLine) {
788
+ mapInstance.removeSource("endpoint");
789
+ resolve();
790
+ }
791
+ }
792
+ }
793
+ };
794
+ animateLine();
795
+ };
796
+ originPoints.forEach((coordinate, index) => {
797
+ lineFlight(coordinate, endPoint, index, index === originPoints.length - 1);
798
+ });
799
+ });
800
+ }
801
+ function generateMapMarkers(mapInstance, borrowerPoints) {
802
+ const geojson = {
803
+ type: "FeatureCollection"
804
+ };
805
+ geojson.features = borrowerPoints.map((borrower) => ({
806
+ type: "Feature",
807
+ properties: {
808
+ message: "test",
809
+ image: borrower.image,
810
+ iconSize: [80, 80]
811
+ },
812
+ geometry: {
813
+ type: "Point",
814
+ coordinates: borrower.location
815
+ }
816
+ }));
817
+ geojson.features.forEach((marker) => {
818
+ const el = document.createElement("div");
819
+ el.className = "map-marker";
820
+ el.style.backgroundImage = `url(${marker.properties.image})`;
821
+ el.style.width = `${marker.properties.iconSize[0]}px`;
822
+ el.style.height = `${marker.properties.iconSize[1]}px`;
823
+ new maplibregl.Marker({ element: el }).setLngLat(marker.geometry.coordinates).addTo(mapInstance);
824
+ });
825
+ }
826
+ function animationCoordinator(mapInstance, borrowerPoints) {
827
+ return new Promise((resolve) => {
828
+ const destinationPoints = borrowerPoints.map((borrower) => borrower.location);
829
+ const totalNumberOfPoints = destinationPoints.length;
830
+ let currentPointIndex = 0;
831
+ const flyToPoint = (index) => {
832
+ mapInstance.flyTo({
833
+ // These options control the ending camera position: centered at
834
+ // the target, at zoom level 9, and north up.
835
+ center: destinationPoints[index],
836
+ zoom: 4,
837
+ bearing: 0,
838
+ // These options control the flight curve, making it move
839
+ // slowly and zoom out almost completely before starting
840
+ // to pan.
841
+ speed: 0.9,
842
+ // make the flying slow
843
+ curve: 1,
844
+ // change the speed at which it zooms out
845
+ // This can be any easing function: it takes a number between
846
+ // 0 and 1 and returns another number between 0 and 1.
847
+ easing(t) {
848
+ return t;
849
+ },
850
+ // this animation is considered essential with respect to prefers-reduced-motion
851
+ essential: true
852
+ }, { flyEnd: true });
853
+ };
854
+ mapInstance.on("moveend", (event) => {
855
+ if (event.flyEnd === true) {
856
+ animateLines(mapInstance, randomCoordinates, destinationPoints[currentPointIndex]).then(() => {
857
+ if (currentPointIndex < totalNumberOfPoints - 1) {
858
+ currentPointIndex += 1;
859
+ flyToPoint(currentPointIndex);
860
+ } else {
861
+ resolve();
862
+ }
863
+ });
864
+ }
865
+ });
866
+ flyToPoint(currentPointIndex);
867
+ });
868
+ }
869
+ var getLoansIntervals = (min, max, nbIntervals) => {
870
+ const size = Math.floor((max - min) / nbIntervals);
871
+ const result = [];
872
+ if (size <= 0)
873
+ return [[min, max]];
874
+ for (let i = 0; i < nbIntervals; i += 1) {
875
+ let inf = min + i * size;
876
+ let sup = inf + size < max ? inf + size : max;
877
+ if (i > 0) {
878
+ inf += 1 * i;
879
+ sup += 1 * i;
880
+ }
881
+ if (i > 0 && sup > max) {
882
+ sup = max;
883
+ }
884
+ if (i === nbIntervals - 1) {
885
+ if (sup < max || sup > max)
886
+ sup = max;
887
+ }
888
+ result.push([inf, sup]);
889
+ if (sup >= max)
890
+ break;
891
+ }
892
+ return result;
893
+ };
894
+ var getCountryColor = (lenderLoans, countriesData, kvTokensPrimitives) => {
895
+ const loanCountsArray = [];
896
+ countriesData.forEach((country) => {
897
+ loanCountsArray.push(country.value);
898
+ });
899
+ const maxNumLoansToOneCountry = Math.max(...loanCountsArray);
900
+ const intervals = getLoansIntervals(1, maxNumLoansToOneCountry, 6);
901
+ if (intervals.length === 1) {
902
+ const [inf, sup] = intervals[0];
903
+ for (let i = 0; i < sup; i += 1) {
904
+ const loansNumber = i + 1;
905
+ if (lenderLoans && lenderLoans >= loansNumber && lenderLoans < loansNumber + 1) {
906
+ return kvTokensPrimitives.colors.brand[mapColors[i]];
907
+ }
908
+ }
909
+ } else {
910
+ for (let i = 0; i < intervals.length; i += 1) {
911
+ const [inf, sup] = intervals[i];
912
+ if (lenderLoans && lenderLoans >= inf && lenderLoans <= sup) {
913
+ return kvTokensPrimitives.colors.brand[mapColors[i]];
914
+ }
915
+ }
916
+ }
917
+ return kvTokensPrimitives.colors.gray[300];
918
+ };
919
+
920
+ // utils/printing.js
921
+ function lockPrintSingleEl(domNode) {
922
+ if (typeof window !== "undefined" && domNode) {
923
+ document.body.classList.add("print:tw-invisible", "print:tw-overflow-hidden");
924
+ domNode.classList.add("print:tw-visible", "print:tw-overflow-auto");
925
+ }
926
+ }
927
+ function unlockPrintSingleEl(domNode) {
928
+ if (typeof window !== "undefined" && domNode) {
929
+ document.body.classList.remove("print:tw-invisible", "print:tw-overflow-hidden");
930
+ domNode.classList.remove("print:tw-visible", "print:tw-overflow-auto");
931
+ }
932
+ }
933
+
934
+ // utils/scrollLock.js
935
+ function lockScroll() {
936
+ if (typeof window !== "undefined") {
937
+ document.body.style.overflow = "hidden";
938
+ }
939
+ }
940
+ function unlockScroll() {
941
+ if (typeof window !== "undefined") {
942
+ document.body.style.overflow = null;
943
+ }
944
+ }
945
+ function lockScrollSmallOnly() {
946
+ if (typeof window !== "undefined") {
947
+ document.body.classList.add("tw-overflow-hidden", "md:tw-overflow-auto");
948
+ }
949
+ }
950
+ function unlockScrollSmallOnly() {
951
+ if (typeof window !== "undefined") {
952
+ document.body.classList.remove("tw-overflow-hidden", "md:tw-overflow-auto");
953
+ }
954
+ }
955
+
956
+ // utils/index.js
957
+ __reExport(utils_exports, __toESM(require_themeUtils(), 1), module.exports);
958
+
959
+ // utils/touchEvents.js
960
+ function onBodyTouchstart(handler) {
961
+ [...document.body.children].forEach((child) => child.addEventListener("touchstart", handler));
962
+ }
963
+ function offBodyTouchstart(handler) {
964
+ [...document.body.children].forEach((child) => child.removeEventListener("touchstart", handler));
965
+ }
966
+ function isTargetElement(event, elements) {
967
+ const els = Array.isArray(elements) ? elements : [elements];
968
+ for (let i = 0; i < els.length; i += 1) {
969
+ if (els[i] === event.target || els[i].contains(event.target)) {
970
+ return true;
971
+ }
972
+ }
973
+ return false;
974
+ }
975
+
976
+ // utils/treemap.js
977
+ var getMaximum = (array) => Math.max(...array);
978
+ var getMinimum = (array) => Math.min(...array);
979
+ var sumReducer = (acc, cur) => acc + cur;
980
+ var roundValue = (number) => Math.max(Math.round(number * 100) / 100, 0);
981
+ var validateArguments = ({ data, width, height }) => {
982
+ if (!width || typeof width !== "number" || width < 0) {
983
+ throw new Error("You need to specify the width of your treemap");
984
+ }
985
+ if (!height || typeof height !== "number" || height < 0) {
986
+ throw new Error("You need to specify the height of your treemap");
987
+ }
988
+ if (!data || !Array.isArray(data) || data.length === 0 || !data.every((dataPoint) => Object.prototype.hasOwnProperty.call(dataPoint, "value") && typeof dataPoint.value === "number" && dataPoint.value >= 0 && !Number.isNaN(dataPoint.value))) {
989
+ throw new Error("You data must be in this format [{ value: 1 }, { value: 2 }], 'value' being a positive number");
990
+ }
991
+ };
992
+ function getTreemap({ data, width, height }) {
993
+ let Rectangle = {};
994
+ let initialData = [];
995
+ function worstRatio(row, width2) {
996
+ const sum = row.reduce(sumReducer, 0);
997
+ const rowMax = getMaximum(row);
998
+ const rowMin = getMinimum(row);
999
+ return Math.max(width2 ** 2 * rowMax / sum ** 2, sum ** 2 / (width2 ** 2 * rowMin));
1000
+ }
1001
+ const getMinWidth = () => {
1002
+ if (Rectangle.totalHeight ** 2 > Rectangle.totalWidth ** 2) {
1003
+ return { value: Rectangle.totalWidth, vertical: false };
1004
+ }
1005
+ return { value: Rectangle.totalHeight, vertical: true };
1006
+ };
1007
+ const layoutRow = (row, width2, vertical) => {
1008
+ const rowHeight = row.reduce(sumReducer, 0) / width2;
1009
+ row.forEach((rowItem) => {
1010
+ const rowWidth = rowItem / rowHeight;
1011
+ const { xBeginning } = Rectangle;
1012
+ const { yBeginning } = Rectangle;
1013
+ let data2;
1014
+ if (vertical) {
1015
+ data2 = {
1016
+ x: xBeginning,
1017
+ y: yBeginning,
1018
+ width: rowHeight,
1019
+ height: rowWidth,
1020
+ data: initialData[Rectangle.data.length]
1021
+ };
1022
+ Rectangle.yBeginning += rowWidth;
1023
+ } else {
1024
+ data2 = {
1025
+ x: xBeginning,
1026
+ y: yBeginning,
1027
+ width: rowWidth,
1028
+ height: rowHeight,
1029
+ data: initialData[Rectangle.data.length]
1030
+ };
1031
+ Rectangle.xBeginning += rowWidth;
1032
+ }
1033
+ Rectangle.data.push(data2);
1034
+ });
1035
+ if (vertical) {
1036
+ Rectangle.xBeginning += rowHeight;
1037
+ Rectangle.yBeginning -= width2;
1038
+ Rectangle.totalWidth -= rowHeight;
1039
+ } else {
1040
+ Rectangle.xBeginning -= width2;
1041
+ Rectangle.yBeginning += rowHeight;
1042
+ Rectangle.totalHeight -= rowHeight;
1043
+ }
1044
+ };
1045
+ const layoutLastRow = (rows, children, width2) => {
1046
+ const { vertical } = getMinWidth();
1047
+ layoutRow(rows, width2, vertical);
1048
+ layoutRow(children, width2, vertical);
1049
+ };
1050
+ const squarify = (children, row, width2) => {
1051
+ if (children.length === 1) {
1052
+ return layoutLastRow(row, children, width2);
1053
+ }
1054
+ const rowWithChild = [...row, children[0]];
1055
+ if (row.length === 0 || worstRatio(row, width2) >= worstRatio(rowWithChild, width2)) {
1056
+ children.shift();
1057
+ return squarify(children, rowWithChild, width2);
1058
+ }
1059
+ layoutRow(row, width2, getMinWidth().vertical);
1060
+ return squarify(children, [], getMinWidth().value);
1061
+ };
1062
+ validateArguments({ data, width, height });
1063
+ Rectangle = {
1064
+ data: [],
1065
+ xBeginning: 0,
1066
+ yBeginning: 0,
1067
+ totalWidth: width,
1068
+ totalHeight: height
1069
+ };
1070
+ initialData = data;
1071
+ const totalValue = data.map((dataPoint) => dataPoint.value).reduce(sumReducer, 0);
1072
+ const dataScaled = data.map((dataPoint) => dataPoint.value * height * width / totalValue);
1073
+ squarify(dataScaled, [], getMinWidth().value);
1074
+ return Rectangle.data.map((dataPoint) => ({
1075
+ ...dataPoint,
1076
+ x: roundValue(dataPoint.x),
1077
+ y: roundValue(dataPoint.y),
1078
+ width: roundValue(dataPoint.width),
1079
+ height: roundValue(dataPoint.height)
1080
+ }));
1081
+ }
1082
+ // Annotate the CommonJS export names for ESM import in node:
1083
+ 0 && (module.exports = {
1084
+ BALANCE_CAMPAIGN,
1085
+ BASE_CAMPAIGN,
1086
+ ERL_COOKIE_NAME,
1087
+ Mash,
1088
+ NO_BALANCE_CAMPAIGN,
1089
+ TOP_UP_CAMPAIGN,
1090
+ animationCoordinator,
1091
+ carouselUtil,
1092
+ collapse,
1093
+ expand,
1094
+ generateMapMarkers,
1095
+ getCoordinatesBetween,
1096
+ getCountryColor,
1097
+ getDropdownPriceArray,
1098
+ getLendCtaSelectedOption,
1099
+ getLoansIntervals,
1100
+ getTreemap,
1101
+ isBetween25And50,
1102
+ isLegacyPlaceholderAvatar,
1103
+ isLessThan25,
1104
+ isTargetElement,
1105
+ loanCardComputedProperties,
1106
+ loanCardMethods,
1107
+ lockPrintSingleEl,
1108
+ lockScroll,
1109
+ lockScrollSmallOnly,
1110
+ offBodyTouchstart,
1111
+ onBodyTouchstart,
1112
+ randomizedUserAvatarClass,
1113
+ throttle,
1114
+ unlockPrintSingleEl,
1115
+ unlockScroll,
1116
+ unlockScrollSmallOnly,
1117
+ useAttrs
1118
+ });