@kiva/kv-components 10.4.1 → 10.5.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.
@@ -1,357 +1,391 @@
1
- import P from "./KvLendCta2.js";
2
- import { KV_LEND_CTA_FRAGMENT as oe, KV_LEND_CTA_USER_FRAGMENT as se } from "./KvLendCta2.js";
3
- import { resolveComponent as A, openBlock as l, createElementBlock as s, createBlock as r, withCtx as w, createTextVNode as f, toDisplayString as a, createElementVNode as c, createVNode as b, withModifiers as D, normalizeClass as u, Fragment as k, renderList as _, createCommentVNode as i } from "vue";
4
- import "./KvLendCta.css";
5
- import y from "../_virtual/_plugin-vue_export-helper.js";
6
- const N = {
7
- ref: "root",
8
- class: "tw-whitespace-nowrap"
9
- }, g = {
10
- key: 2,
11
- class: "tw-w-full tw-text-center tw-rounded tw-p-2",
12
- style: { background: "#f1f1f1" }
13
- }, T = { class: "tw-flex tw-items-center" }, V = ["disabled"], O = {
14
- key: 0,
15
- class: "md:tw-hidden tw-w-full"
16
- }, R = { class: "tw-flex tw-flex-col tw-gap-1 tw-w-full" }, C = { class: "tw-flex tw-gap-1 tw-w-full" }, I = ["value"], E = { class: "tw-flex tw-gap-1" }, p = ["value"], S = { class: "tw-flex tw-items-center tw-h-full tw-w-full" }, W = { class: "tw-min-w-0 tw-flex-1 tw-overflow-hidden tw-text-ellipsis tw-whitespace-nowrap" }, U = {
17
- key: 1,
18
- class: "tw-w-full"
19
- }, F = { class: "tw-flex tw-flex-col tw-gap-1 tw-w-full" }, M = { class: "tw-flex tw-gap-1 tw-w-full" }, K = ["value"], H = { class: "tw-flex tw-gap-1" }, j = ["value"], G = { class: "tw-flex tw-items-center tw-h-full tw-w-full" }, z = { class: "tw-min-w-0 tw-flex-1 tw-overflow-hidden tw-text-ellipsis tw-whitespace-nowrap" }, q = ["value"], J = {
20
- key: 3,
21
- class: "amountDropdownWrapper"
22
- }, Q = ["value"];
23
- function X(v, o, n, Y, d, e) {
24
- const m = A("kv-ui-button"), B = A("kv-material-icon"), h = A("kv-ui-select"), L = A("kv-lend-amount-button");
25
- return l(), s("div", N, [
26
- e.isInBasket ? (l(), r(m, {
27
- key: 0,
28
- variant: "secondary",
29
- class: "tw-inline-flex tw-flex-1 tw-w-full tw-cursor-pointer",
30
- "data-testid": "bp-lend-cta-checkout-button",
31
- to: n.externalLinks ? void 0 : "/basket",
32
- href: n.externalLinks ? "/basket" : void 0,
33
- onClick: o[0] || (o[0] = (t) => e.clickSecondaryButton(t))
34
- }, {
35
- default: w(() => [
36
- f(a(e.loanInBasketButtonText), 1)
37
- ]),
38
- _: 1
39
- }, 8, ["to", "href"])) : e.showNonActionableLoanButton ? (l(), r(m, {
40
- key: 1,
41
- class: "tw-inline-flex tw-flex-1"
42
- }, {
43
- default: w(() => [
44
- f(a(e.ctaButtonText), 1)
45
- ]),
46
- _: 1
47
- })) : e.isFunded ? (l(), s("div", g, " This loan was just funded! 🎉 ")) : n.showViewLoan ? (l(), r(m, {
48
- key: 3,
49
- state: `${e.allSharesReserved ? "disabled" : ""}`,
50
- to: n.externalLinks ? void 0 : e.readMorePath,
51
- href: n.externalLinks ? e.readMorePath : void 0,
52
- class: "tw-mb-0 tw-cursor-pointer",
53
- onClick: o[1] || (o[1] = (t) => v.$emit("show-loan-details", t))
54
- }, {
55
- default: w(() => [
56
- c("span", T, [
57
- o[9] || (o[9] = f(" View loan ")),
58
- b(B, {
59
- class: "tw-w-3 tw-h-3",
60
- icon: d.mdiChevronRight
61
- }, null, 8, ["icon"])
62
- ])
63
- ]),
64
- _: 1
65
- }, 8, ["state", "to", "href"])) : e.useFormSubmit ? (l(), s("form", {
66
- key: 4,
67
- class: "tw-w-full tw-flex",
68
- onSubmit: o[8] || (o[8] = D((...t) => e.addToBasket && e.addToBasket(...t), ["prevent"]))
69
- }, [
70
- c("fieldset", {
71
- class: u(["tw-w-full tw-flex", {
72
- "tw-flex-col md:tw-flex-row md:tw-justify-between tw-min-w-0": n.showPresetAmounts && !e.isNarrowDesktop,
73
- "tw-flex-col tw-min-w-0": n.showPresetAmounts && e.isNarrowDesktop,
74
- "tw-gap-1.5": n.showPresetAmounts && !e.isLendAmountButton && !n.isAdding && !e.isNarrowDesktop
75
- }]),
76
- disabled: n.isAdding,
77
- "data-testid": "bp-lend-cta-select-and-button"
78
- }, [
79
- n.showPresetAmounts && !n.isAdding && !e.isLendAmountButton && e.presetButtonsPrices.length > 1 && !e.isNarrowDesktop ? (l(), s("div", O, [
80
- c("div", R, [
81
- c("div", C, [
82
- (l(!0), s(k, null, _(e.presetButtonsPrices, (t) => (l(), r(m, {
83
- key: t,
84
- variant: "secondary",
85
- class: u(["preset-option tw-flex-1 tw-min-w-0 tw-whitespace-nowrap", { "selected-option": d.selectedOption == t }]),
86
- "data-testid": "bp-lend-cta-lend-button-mobile",
87
- onClick: (x) => e.clickPresetButton(t)
88
- }, {
89
- default: w(() => [
90
- f(" $ " + a(t), 1)
91
- ]),
92
- _: 2
93
- }, 1032, ["class", "onClick"]))), 128)),
94
- e.showFilteredDropdown && d.viewportWidth >= d.MOBILE_DROPDOWN_BREAKPOINT ? (l(), r(h, {
95
- key: 0,
96
- id: `LoanAmountDropdownMobile_${e.loanId}`,
97
- modelValue: d.selectedDropdownOption,
98
- "onUpdate:modelValue": [
99
- o[2] || (o[2] = (t) => d.selectedDropdownOption = t),
100
- e.trackLendAmountSelection
101
- ],
102
- class: u(["filtered-dropdown mobile-dropdown tw-rounded", {
103
- "unselected-dropdown": !e.selectedDropdown,
104
- "selected-dropdown": e.selectedDropdown
105
- }]),
106
- "aria-label": "Lend amount",
107
- onClick: D(e.clickDropdown, ["stop"])
108
- }, {
109
- default: w(() => [
110
- (l(!0), s(k, null, _(e.presetDropdownPrices, (t) => (l(), s("option", {
111
- key: t,
112
- value: t
113
- }, a(t !== d.OTHER_OPTION ? `$${t}` : t), 9, I))), 128))
114
- ]),
115
- _: 1
116
- }, 8, ["id", "modelValue", "class", "onUpdate:modelValue", "onClick"])) : i("", !0)
117
- ]),
118
- c("div", E, [
119
- e.showFilteredDropdown && d.viewportWidth < d.MOBILE_DROPDOWN_BREAKPOINT ? (l(), r(h, {
120
- key: 0,
121
- id: `LoanAmountDropdownMobile_Small_${e.loanId}`,
122
- modelValue: d.selectedDropdownOption,
123
- "onUpdate:modelValue": [
124
- o[3] || (o[3] = (t) => d.selectedDropdownOption = t),
125
- e.trackLendAmountSelection
126
- ],
127
- class: u(["filtered-dropdown mobile-dropdown-small tw-rounded tw-w-2/5", {
128
- "unselected-dropdown": !e.selectedDropdown,
129
- "selected-dropdown": e.selectedDropdown
130
- }]),
131
- "aria-label": "Lend amount",
132
- onClick: D(e.clickDropdown, ["stop"])
133
- }, {
134
- default: w(() => [
135
- (l(!0), s(k, null, _(e.presetDropdownPrices, (t) => (l(), s("option", {
136
- key: "small-" + t,
137
- value: t
138
- }, a(t !== d.OTHER_OPTION ? `$${t}` : t), 9, p))), 128))
139
- ]),
140
- _: 1
141
- }, 8, ["id", "modelValue", "class", "onUpdate:modelValue", "onClick"])) : i("", !0),
142
- b(m, {
143
- class: u(["tw-inline-flex tw-flex-1 button-ellipsis tw-min-w-0", d.viewportWidth < d.MOBILE_DROPDOWN_BREAKPOINT ? "tw-w-3/5" : "tw-w-full"]),
144
- "data-testid": "bp-lend-cta-mobile-lend-button",
145
- type: "submit"
146
- }, {
147
- default: w(() => [
148
- c("span", S, [
149
- c("span", W, a(e.ctaButtonText), 1)
150
- ])
151
- ]),
152
- _: 1
153
- }, 8, ["class"])
154
- ])
155
- ])
156
- ])) : i("", !0),
157
- n.showPresetAmounts && !n.isAdding && !e.isLendAmountButton && e.presetButtonsPrices.length > 1 && e.isNarrowDesktop ? (l(), s("div", U, [
158
- c("div", F, [
159
- c("div", M, [
160
- (l(!0), s(k, null, _(e.presetButtonsPrices, (t) => (l(), r(m, {
161
- key: t,
162
- variant: "secondary",
163
- class: u(["preset-option tw-flex-1 tw-min-w-0 tw-whitespace-nowrap", { "selected-option": d.selectedOption == t }]),
164
- "data-testid": "bp-lend-cta-lend-button-narrow-desktop",
165
- onClick: (x) => e.clickPresetButton(t)
166
- }, {
167
- default: w(() => [
168
- f(" $ " + a(t), 1)
169
- ]),
170
- _: 2
171
- }, 1032, ["class", "onClick"]))), 128)),
172
- e.showFilteredDropdown && d.componentWidth >= d.NARROW_SIDEBAR_DROPDOWN_BREAKPOINT ? (l(), r(h, {
173
- key: 0,
174
- id: `LoanAmountDropdownNarrowDesktop_${e.loanId}`,
175
- modelValue: d.selectedDropdownOption,
176
- "onUpdate:modelValue": [
177
- o[4] || (o[4] = (t) => d.selectedDropdownOption = t),
178
- e.trackLendAmountSelection
179
- ],
180
- class: u(["filtered-dropdown mobile-dropdown tw-flex-1 tw-rounded", {
181
- "unselected-dropdown": !e.selectedDropdown,
182
- "selected-dropdown": e.selectedDropdown
183
- }]),
184
- "aria-label": "Lend amount",
185
- onClick: D(e.clickDropdown, ["stop"])
186
- }, {
187
- default: w(() => [
188
- (l(!0), s(k, null, _(e.presetDropdownPrices, (t) => (l(), s("option", {
189
- key: t,
190
- value: t
191
- }, a(t !== d.OTHER_OPTION ? `${t}` : t), 9, K))), 128))
192
- ]),
193
- _: 1
194
- }, 8, ["id", "modelValue", "class", "onUpdate:modelValue", "onClick"])) : i("", !0)
195
- ]),
196
- c("div", H, [
197
- e.showFilteredDropdown && d.componentWidth < d.NARROW_SIDEBAR_DROPDOWN_BREAKPOINT ? (l(), r(h, {
198
- key: 0,
199
- id: `LoanAmountDropdownNarrowDesktop_Small_${e.loanId}`,
200
- modelValue: d.selectedDropdownOption,
201
- "onUpdate:modelValue": [
202
- o[5] || (o[5] = (t) => d.selectedDropdownOption = t),
203
- e.trackLendAmountSelection
204
- ],
205
- class: u(["filtered-dropdown mobile-dropdown-small tw-rounded tw-w-2/5", {
206
- "unselected-dropdown": !e.selectedDropdown,
207
- "selected-dropdown": e.selectedDropdown
208
- }]),
209
- "aria-label": "Lend amount",
210
- onClick: D(e.clickDropdown, ["stop"])
211
- }, {
212
- default: w(() => [
213
- (l(!0), s(k, null, _(e.presetDropdownPrices, (t) => (l(), s("option", {
214
- key: "narrow-small-" + t,
215
- value: t
216
- }, a(t !== d.OTHER_OPTION ? `${t}` : t), 9, j))), 128))
217
- ]),
218
- _: 1
219
- }, 8, ["id", "modelValue", "class", "onUpdate:modelValue", "onClick"])) : i("", !0),
220
- b(m, {
221
- class: u(["tw-inline-flex tw-flex-1 button-ellipsis tw-min-w-0", d.componentWidth < d.NARROW_SIDEBAR_DROPDOWN_BREAKPOINT ? "tw-w-3/5" : "tw-w-full"]),
222
- "data-testid": "bp-lend-cta-narrow-desktop-lend-button",
223
- type: "submit"
224
- }, {
225
- default: w(() => [
226
- c("span", G, [
227
- c("span", z, a(e.ctaButtonText), 1)
228
- ])
229
- ]),
230
- _: 1
231
- }, 8, ["class"])
232
- ])
233
- ])
234
- ])) : i("", !0),
235
- n.showPresetAmounts && !n.isAdding && !e.isNarrowDesktop ? (l(), s("div", {
236
- key: 2,
237
- class: u({
238
- "tw-flex tw-gap-0.5 md:tw-gap-1 lg:tw-gap-1 tw-flex-wrap md:tw-flex-nowrap": !0,
239
- "tw-hidden md:tw-flex": !e.isLendAmountButton && e.presetButtonsPrices.length > 1
240
- })
241
- }, [
242
- e.isLendAmountButton ? i("", !0) : (l(!0), s(k, { key: 0 }, _(e.presetButtonsPrices, (t) => (l(), r(m, {
243
- key: t,
244
- variant: "secondary",
245
- class: u(["tw-inline-flex tw-flex-1 preset-option tw-w-8 tw-whitespace-nowrap", { "selected-option": d.selectedOption == t }]),
246
- "data-testid": "bp-lend-cta-lend-button",
247
- onClick: (x) => e.clickPresetButton(t)
248
- }, {
249
- default: w(() => [
250
- f(" $" + a(t), 1)
251
- ]),
252
- _: 2
253
- }, 1032, ["class", "onClick"]))), 128)),
254
- e.showFilteredDropdown ? (l(), r(h, {
255
- key: 1,
256
- id: `LoanAmountDropdown_${e.loanId}`,
257
- modelValue: d.selectedDropdownOption,
258
- "onUpdate:modelValue": [
259
- o[6] || (o[6] = (t) => d.selectedDropdownOption = t),
260
- e.trackLendAmountSelection
261
- ],
262
- class: u(["tw-min-w-12 tw-rounded filtered-dropdown", {
263
- "unselected-dropdown": !e.selectedDropdown,
264
- "selected-dropdown": e.selectedDropdown
265
- }]),
266
- "aria-label": "Lend amount",
267
- onClick: D(e.clickDropdown, ["stop"])
268
- }, {
269
- default: w(() => [
270
- (l(!0), s(k, null, _(e.presetDropdownPrices, (t) => (l(), s("option", {
271
- key: t,
272
- value: t
273
- }, a(t !== d.OTHER_OPTION ? `$${t}` : t), 9, q))), 128))
274
- ]),
275
- _: 1
276
- }, 8, ["id", "modelValue", "class", "onUpdate:modelValue", "onClick"])) : i("", !0)
277
- ], 2)) : n.showPresetAmounts ? i("", !0) : (l(), s("div", J, [
278
- e.hideShowLendDropdown && !e.isLessThan25 ? (l(), r(h, {
279
- key: 0,
280
- id: `LoanAmountDropdown_${e.loanId}`,
281
- modelValue: d.selectedOption,
282
- "onUpdate:modelValue": [
283
- o[7] || (o[7] = (t) => d.selectedOption = t),
284
- e.trackLendAmountSelection
285
- ],
286
- class: "tw-min-w-12",
287
- style: { "border-radius": "14px 0 0 14px" },
288
- "aria-label": "Lend amount",
289
- onClick: D(e.clickDropdown, ["stop"])
290
- }, {
291
- default: w(() => [
292
- (l(!0), s(k, null, _(e.prices, (t) => (l(), s("option", {
293
- key: t,
294
- value: t
295
- }, " $" + a(t), 9, Q))), 128))
296
- ]),
297
- _: 1
298
- }, 8, ["id", "modelValue", "onUpdate:modelValue", "onClick"])) : i("", !0)
299
- ])),
300
- c("div", {
301
- class: u({
302
- "tw-min-w-0": n.showPresetAmounts && !e.isNarrowDesktop,
303
- lendButtonWrapper: e.hideShowLendDropdown && !n.showPresetAmounts,
304
- "tw-hidden": e.hideLendButton || n.showPresetAmounts && !n.isAdding && !e.isLendAmountButton && e.presetButtonsPrices.length > 1 && (e.isNarrowComponent() || e.isNarrowDesktop),
305
- "md:tw-block tw-hidden": !e.isLendAmountButton && e.presetButtonsPrices.length > 1 && n.showPresetAmounts && !e.isNarrowDesktop
306
- })
307
- }, [
308
- e.lendButtonVisibility && !e.isLessThan25 ? (l(), r(m, {
309
- key: "lendButton",
310
- class: u(["tw-inline-flex tw-flex-1", { "button-ellipsis tw-w-full": n.showPresetAmounts }]),
311
- "data-testid": "bp-lend-cta-lend-button",
312
- type: "submit"
313
- }, {
314
- default: w(() => [
315
- f(a(e.ctaButtonText), 1)
316
- ]),
317
- _: 1
318
- }, 8, ["class"])) : e.showLendAgain ? (l(), r(m, {
319
- key: "lendAgainButton",
320
- class: u(["lend-again", { "tw-w-full": n.showPresetAmounts }]),
321
- "data-testid": "bp-lend-cta-lend-again-button",
322
- type: "submit"
323
- }, {
324
- default: w(() => [
325
- f(a(n.primaryButtonText || "Lend") + " again ", 1)
326
- ]),
327
- _: 1
328
- }, 8, ["class"])) : i("", !0)
329
- ], 2),
330
- e.isLendAmountButton && !n.enableFiveDollarsNotes ? (l(), r(L, {
331
- key: 4,
332
- class: "tw-w-full",
333
- "loan-id": e.loanId,
334
- "show-now": !1,
335
- "amount-left": e.amountForLendAmountButton,
336
- "is-adding": n.isAdding,
337
- onAddToBasket: e.addToBasket
338
- }, null, 8, ["loan-id", "amount-left", "is-adding", "onAddToBasket"])) : i("", !0),
339
- !n.isLoading && n.isAdding ? (l(), r(m, {
340
- key: 5,
341
- class: "tw-inline-flex tw-flex-1"
342
- }, {
343
- default: w(() => o[10] || (o[10] = [
344
- f(" Adding to basket ")
345
- ])),
346
- _: 1
347
- })) : i("", !0)
348
- ], 10, V)
349
- ], 32)) : i("", !0)
350
- ], 512);
351
- }
352
- const le = /* @__PURE__ */ y(P, [["render", X], ["__scopeId", "data-v-da60f69c"]]);
1
+ import u from "graphql-tag";
2
+ import { mdiChevronRight as d } from "@mdi/js";
3
+ import { throttle as h } from "../utils/throttle.js";
4
+ import { getLendCtaSelectedOption as o, getDropdownPriceArray as l } from "../utils/loanUtils.js";
5
+ import c from "./KvLendAmountButton.js";
6
+ import p from "./KvSelect.js";
7
+ import m from "./KvButton.js";
8
+ import f from "./KvMaterialIcon.js";
9
+ const n = "Other", v = 360, r = 480, a = 380, O = u`
10
+ fragment KvLendCta on LoanBasic {
11
+ id
12
+ name
13
+ status
14
+ minNoteSize
15
+ }
16
+ `, b = u`
17
+ fragment KvLendCtaUser on LoanBasic {
18
+ id
19
+ userProperties {
20
+ lentTo
21
+ }
22
+ }
23
+ `, D = {
24
+ name: "KvLendCta",
25
+ components: {
26
+ KvLendAmountButton: c,
27
+ KvUiButton: m,
28
+ KvUiSelect: p,
29
+ KvMaterialIcon: f
30
+ },
31
+ props: {
32
+ loan: {
33
+ type: Object,
34
+ default: () => ({})
35
+ },
36
+ unreservedAmount: {
37
+ type: String,
38
+ default: ""
39
+ },
40
+ basketItems: {
41
+ type: Array,
42
+ default: () => []
43
+ },
44
+ isLoading: {
45
+ type: Boolean,
46
+ default: !0
47
+ },
48
+ isAdding: {
49
+ type: Boolean,
50
+ default: !1
51
+ },
52
+ enableFiveDollarsNotes: {
53
+ type: Boolean,
54
+ default: !1
55
+ },
56
+ kvTrackFunction: {
57
+ type: Function,
58
+ required: !0
59
+ },
60
+ showViewLoan: {
61
+ type: Boolean,
62
+ default: !1
63
+ },
64
+ customLoanDetails: {
65
+ type: Boolean,
66
+ default: !1
67
+ },
68
+ externalLinks: {
69
+ type: Boolean,
70
+ default: !1
71
+ },
72
+ route: {
73
+ type: Object,
74
+ default: void 0
75
+ },
76
+ userBalance: {
77
+ type: String,
78
+ default: void 0
79
+ },
80
+ getCookie: {
81
+ type: Function,
82
+ default: void 0
83
+ },
84
+ setCookie: {
85
+ type: Function,
86
+ default: void 0
87
+ },
88
+ fiveDollarsSelected: {
89
+ type: Boolean,
90
+ default: !1
91
+ },
92
+ isVisitor: {
93
+ type: Boolean,
94
+ default: !0
95
+ },
96
+ primaryButtonText: {
97
+ type: String,
98
+ default: "Lend"
99
+ },
100
+ secondaryButtonText: {
101
+ type: String,
102
+ default: void 0
103
+ },
104
+ secondaryButtonHandler: {
105
+ type: Function,
106
+ default: void 0
107
+ },
108
+ /**
109
+ * Hide preset buttons under this amount when
110
+ * showPresetAmounts is true
111
+ * */
112
+ maxAmount: {
113
+ type: String,
114
+ default: ""
115
+ },
116
+ showPresetAmounts: {
117
+ type: Boolean,
118
+ default: !1
119
+ },
120
+ kvTrackCategory: {
121
+ type: String,
122
+ default: "Lending"
123
+ },
124
+ /**
125
+ * Breakpoint for narrow desktop layout (default: 480px)
126
+ * When component width is below this, it will use stacked layout even on desktop
127
+ */
128
+ narrowSidebarBreakpoint: {
129
+ type: Number,
130
+ default: r
131
+ },
132
+ /**
133
+ * Breakpoint for narrow desktop dropdown layout (default: 380px)
134
+ * When component width is below this in narrow desktop mode, dropdown moves to second row
135
+ */
136
+ narrowSidebarDropdownBreakpoint: {
137
+ type: Number,
138
+ default: a
139
+ }
140
+ },
141
+ emits: [
142
+ "show-loan-details",
143
+ "add-to-basket"
144
+ ],
145
+ data() {
146
+ var t, e;
147
+ return {
148
+ mdiChevronRight: d,
149
+ defaultAmountOptions: [25, 50, 75],
150
+ selectedOption: o(
151
+ this.getCookie,
152
+ this.setCookie,
153
+ this.enableFiveDollarsNotes,
154
+ (e = (t = this.route) == null ? void 0 : t.query) == null ? void 0 : e.utm_campaign,
155
+ this.unreservedAmount,
156
+ this.userBalance ? parseFloat(this.userBalance) : void 0,
157
+ this.fiveDollarsSelected
158
+ ),
159
+ selectedDropdownOption: n,
160
+ OTHER_OPTION: n,
161
+ // SSR-safe viewport width initialization
162
+ viewportWidth: typeof window < "u" ? window.innerWidth : 1024,
163
+ componentWidth: 1024,
164
+ resizeObserver: null,
165
+ MOBILE_DROPDOWN_BREAKPOINT: v,
166
+ NARROW_SIDEBAR_BREAKPOINT: r,
167
+ NARROW_SIDEBAR_DROPDOWN_BREAKPOINT: a
168
+ };
169
+ },
170
+ computed: {
171
+ readMorePath() {
172
+ return this.customLoanDetails ? "" : `/lend/${this.loanId}`;
173
+ },
174
+ loanId() {
175
+ var t;
176
+ return (t = this.loan) == null ? void 0 : t.id;
177
+ },
178
+ status() {
179
+ var t;
180
+ return ((t = this.loan) == null ? void 0 : t.status) ?? "";
181
+ },
182
+ minNoteSize() {
183
+ var t;
184
+ return ((t = this.loan) == null ? void 0 : t.minNoteSize) ?? "";
185
+ },
186
+ lentPreviously() {
187
+ var t, e;
188
+ return ((e = (t = this.loan) == null ? void 0 : t.userProperties) == null ? void 0 : e.lentTo) ?? !1;
189
+ },
190
+ isInBasket() {
191
+ var t;
192
+ return ((t = this.basketItems) == null ? void 0 : t.some((e) => e.__typename === "LoanReservation" && e.id === this.loanId)) ?? !1;
193
+ },
194
+ prices() {
195
+ const t = parseFloat(this.unreservedAmount < 25 ? this.minNoteSize : 25), e = l(
196
+ this.unreservedAmount,
197
+ this.isCompleteLoanActive,
198
+ t,
199
+ this.enableFiveDollarsNotes,
200
+ this.isVisitor
201
+ );
202
+ return this.maxAmount ? e.filter((s) => parseFloat(s) <= parseFloat(this.maxAmount)) : e;
203
+ },
204
+ presetButtonsPrices() {
205
+ const t = this.prices.slice(0, 3);
206
+ return this.prices.length === 4 && t.push(this.prices[3]), t;
207
+ },
208
+ presetDropdownPrices() {
209
+ if (this.prices.length === 4)
210
+ return [];
211
+ const t = this.prices.slice(this.defaultAmountOptions.length);
212
+ return t.unshift(n), t;
213
+ },
214
+ loanName() {
215
+ var t;
216
+ return ((t = this.loan) == null ? void 0 : t.name) ?? "";
217
+ },
218
+ presetAmountCtaButtonText() {
219
+ var t;
220
+ return ((t = this.loan) == null ? void 0 : t.borrowerCount) > 1 ? "Support" : `Support ${this.loanName}`;
221
+ },
222
+ defaultCtaButtonText() {
223
+ return this.showPresetAmounts ? this.presetAmountCtaButtonText : this.primaryButtonText || "Lend";
224
+ },
225
+ ctaButtonText() {
226
+ switch (this.state) {
227
+ case "loading":
228
+ return "Loading...";
229
+ case "refunded":
230
+ case "expired":
231
+ default:
232
+ return this.defaultCtaButtonText;
233
+ }
234
+ },
235
+ loanInBasketButtonText() {
236
+ return this.secondaryButtonText ? this.secondaryButtonText : this.showPresetAmounts ? "Continue to basket" : "Checkout now";
237
+ },
238
+ useFormSubmit() {
239
+ return !!(this.hideShowLendDropdown || this.lendButtonVisibility || this.showLendAgain || this.state === "lent-to" || this.isAdding);
240
+ },
241
+ state() {
242
+ return this.isLoading ? "loading" : this.isAdding ? "adding" : this.isInBasket ? "basketed" : this.status === "funded" || this.status === "refunded" || this.status === "expired" ? this.status : this.allSharesReserved ? "fully-reserved" : this.lentPreviously ? "lent-to" : "lend";
243
+ },
244
+ lendButtonVisibility() {
245
+ return this.state === "lend" || this.state === "loading";
246
+ },
247
+ showNonActionableLoanButton() {
248
+ return this.state === "refunded" || this.state === "expired";
249
+ },
250
+ hideShowLendDropdown() {
251
+ return this.state === "lend" || this.state === "lent-to";
252
+ },
253
+ allSharesReserved() {
254
+ return parseFloat(this.unreservedAmount) === 0;
255
+ },
256
+ isLessThan25() {
257
+ return this.enableFiveDollarsNotes ? !1 : this.isAmountLessThan25(this.unreservedAmount);
258
+ },
259
+ isLentTo() {
260
+ return this.state === "lent-to";
261
+ },
262
+ isCompleteLoanActive() {
263
+ return this.isAmountLessThan25(this.unreservedAmount) || this.isAmountBetween25And500(this.unreservedAmount);
264
+ },
265
+ isLendAmountButton() {
266
+ const t = this.maxAmount ? this.maxAmount : this.unreservedAmount;
267
+ return (this.lendButtonVisibility || this.state === "lent-to") && this.isAmountLessThan25(t) || this.showPresetAmounts && this.presetButtonsPrices.length === 1 && !this.isAdding;
268
+ },
269
+ isFunded() {
270
+ return this.state === "funded" || this.state === "fully-reserved";
271
+ },
272
+ amountToLend() {
273
+ return this.selectedDropdown ? this.selectedDropdownOption : this.isLessThan25 ? this.unreservedAmount : this.selectedOption;
274
+ },
275
+ amountForLendAmountButton() {
276
+ return this.maxAmount && parseFloat(this.maxAmount) === 25 ? Math.min(parseFloat(this.maxAmount), parseFloat(this.unreservedAmount)) : this.unreservedAmount;
277
+ },
278
+ showLendAgain() {
279
+ return this.isLentTo && !this.isLessThan25;
280
+ },
281
+ selectedDropdown() {
282
+ return this.selectedDropdownOption !== n;
283
+ },
284
+ showFilteredDropdown() {
285
+ return this.presetDropdownPrices.length > 1;
286
+ },
287
+ hideLendButton() {
288
+ return this.showPresetAmounts && (this.isAdding || this.presetButtonsPrices.length === 1);
289
+ },
290
+ /**
291
+ * Determines if component should use narrow desktop layout
292
+ * This is true when we're in desktop viewport but component width is narrow
293
+ */
294
+ isNarrowDesktop() {
295
+ return this.viewportWidth >= 768 && this.componentWidth < this.narrowSidebarBreakpoint;
296
+ }
297
+ },
298
+ watch: {
299
+ unreservedAmount(t, e) {
300
+ var s, i;
301
+ t !== e && e === "" && (this.selectedOption = o(
302
+ this.getCookie,
303
+ this.setCookie,
304
+ this.enableFiveDollarsNotes,
305
+ (i = (s = this.route) == null ? void 0 : s.query) == null ? void 0 : i.utm_campaign,
306
+ t,
307
+ this.userBalance ? parseFloat(this.userBalance) : void 0,
308
+ this.fiveDollarsSelected
309
+ )), this.showPresetAmounts && (this.selectedOption = n);
310
+ }
311
+ },
312
+ mounted() {
313
+ const t = () => {
314
+ var e;
315
+ this.viewportWidth = window.innerWidth, this.componentWidth = ((e = this.$refs.root) == null ? void 0 : e.offsetWidth) || 1024;
316
+ };
317
+ typeof window < "u" && (this.viewportWidth = window.innerWidth, window.ResizeObserver && this.$nextTick(() => {
318
+ this.resizeObserver = new window.ResizeObserver(h(t, 50)), this.$refs.root && (this.resizeObserver.observe(this.$refs.root), t());
319
+ }));
320
+ },
321
+ beforeUnmount() {
322
+ this.resizeHandler && typeof window < "u" && window.removeEventListener("resize", this.resizeHandler), this.resizeObserver && this.$refs.root && this.resizeObserver.disconnect();
323
+ },
324
+ methods: {
325
+ async addToBasket() {
326
+ this.kvTrackFunction(
327
+ this.kvTrackCategory,
328
+ "Add to basket",
329
+ this.showLendAgain ? "Lend again" : "lend-button-click",
330
+ this.loanId,
331
+ this.amountToLend
332
+ ), this.$emit("add-to-basket", this.amountToLend);
333
+ },
334
+ isAmountLessThan25(t) {
335
+ return t < 25 && t > 0;
336
+ },
337
+ isAmountBetween25And50(t) {
338
+ return t <= 50 && t > 25;
339
+ },
340
+ isAmountBetween25And500(t) {
341
+ return t < 500 && t >= 25;
342
+ },
343
+ trackLendAmountSelection(t) {
344
+ this.showPresetAmounts && (this.selectedOption = null), this.kvTrackFunction(
345
+ this.kvTrackCategory,
346
+ "Modify lend amount",
347
+ t,
348
+ this.loanId,
349
+ this.loanId
350
+ );
351
+ },
352
+ clickDropdown() {
353
+ this.kvTrackFunction(
354
+ this.kvTrackCategory,
355
+ "click-Modify loan amount",
356
+ "open dialog",
357
+ this.loanId,
358
+ this.loanId
359
+ );
360
+ },
361
+ clickSecondaryButton(t) {
362
+ this.secondaryButtonHandler ? (t.preventDefault(), t.stopPropagation(), this.secondaryButtonHandler()) : this.handleCheckout();
363
+ },
364
+ clickPresetButton(t) {
365
+ this.kvTrackFunction(
366
+ this.kvTrackCategory,
367
+ "Modify lend amount",
368
+ t,
369
+ this.loanId,
370
+ this.loanId
371
+ ), this.selectedOption = t, this.selectedDropdownOption = n;
372
+ },
373
+ handleCheckout() {
374
+ this.kvTrackFunction(
375
+ this.kvTrackCategory,
376
+ "click-Continue-to-checkout",
377
+ "Continue to checkout",
378
+ this.loanId,
379
+ this.loanId
380
+ );
381
+ },
382
+ isNarrowComponent() {
383
+ return this.componentWidth < 430;
384
+ }
385
+ }
386
+ };
353
387
  export {
354
- oe as KV_LEND_CTA_FRAGMENT,
355
- se as KV_LEND_CTA_USER_FRAGMENT,
356
- le as default
388
+ O as KV_LEND_CTA_FRAGMENT,
389
+ b as KV_LEND_CTA_USER_FRAGMENT,
390
+ D as default
357
391
  };