@sprig-technologies/sprig-bundled 2.45.0 → 2.46.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,723 +0,0 @@
1
- import { u as Y, h as J, a as e, c as O, g as je, b as te, F as he, p as re, d as ve, e as be, _ as ne, T as Ce, A as nr, M as _e, D as Me, f as sr, P as ir, i as ar, q as or, j as de, s as Ze, k as lr, S as cr, l as dr, m as ur, n as pr, o as mr, r as gr, t as hr, v as Le, w as $e } from "./view-Cu4weTLz.js";
2
- import { i as ie, E as Pe, h as Qe, j as We, A as br } from "./index-Czvv7meW.js";
3
- import { H as ae, Q as le, a as Ie, M as me, b as pe, O as fe, B as ee, L as Te, S as vr, u as yr, g as fr, c as xr } from "./getAttributedUrl-Dq1b-gQL.js";
4
- const Sr = ({ className: n, message: s, next: d, properties: t, questionId: r, type: a }) => {
5
- const { useMobileStyling: g, border: v, isLongFormSurvey: u, focusedQuestionId: h } = Y((m) => ({ useMobileStyling: m.useMobileStyling, border: m.border, isLongFormSurvey: ie(m.studyType), focusedQuestionId: m.focusedQuestionId })), [l, b] = J(!1), [c, N] = J(""), [o, f] = J(!1), p = u && h === r, k = t == null ? void 0 : t.collectName, x = (t == null ? void 0 : t.nameLabelText) || "Full Name", _ = (t == null ? void 0 : t.consentText) || "I agree to the stated conditions", w = (t == null ? void 0 : t.submitButtonText) || "Submit", E = !!c.trim(), M = l && (!k || E), U = (m, S = !1) => {
6
- m.preventDefault(), m.stopPropagation();
7
- let P = null;
8
- if (!S) {
9
- if (!M) return void f(!0);
10
- P = { submitted: !0 }, k && (P.name = c);
11
- }
12
- d({ value: P, questionId: r, type: a }, M);
13
- };
14
- return e("div", { className: O(n, u && !p && "ul-card--unfocused", "ul-card__consent-legal", "fade-in-transition"), children: [e(ae, { isRequired: u && (t == null ? void 0 : t.required), message: s, properties: { questionHtml: t.questionHtml } }), t != null && t.richTextBody ? e(le, { children: e(Ie, { className: "ul-rich-text-body", html: t.richTextBody, id: "ul-card__consent-legal-body-container" }) }) : null, e(me, { embeddedType: "pdf", properties: t, children: e(pe, { children: [e("div", { className: "sprig-stretch", children: [e(fe, { allowTextEntry: !1, border: v, error: o && !l, id: "consent", isRadio: !1, isSelected: l, label: _, onUserInputChanged: ({ selected: m }) => {
15
- m !== l && b(!l);
16
- }, useMobileStyling: g }), k && e("input", { "aria-label": x, "aria-placeholder": x, className: O(te("ul-consent-legal__name-input", g)), "data-gramm": "false", maxLength: 250, name: "name", onBlur: (m) => {
17
- m.currentTarget.style.borderColor = o && !E ? Pe : Qe;
18
- }, onFocus: (m) => {
19
- m.currentTarget.style.borderColor = o && !E ? Pe : v;
20
- }, onInput: (m) => {
21
- m.preventDefault(), m.stopPropagation(), N(m.currentTarget.value);
22
- }, placeholder: x, style: o && !E ? { borderColor: Pe } : {}, tabIndex: 0, value: c })] }), e("div", { className: "ul-card__button-wrapper ul-card-vertical__button-wrapper", children: [e(ee, { className: M ? "" : "sprig-button-disabled", onClick: U, children: w }), t.required === !1 && !u && e("button", { className: "ul-card-skip__button", onClick: (m) => U(m, !0), children: je(t) })] })] }) })] }, r);
23
- }, ke = (n) => (s) => {
24
- s.pointerType !== "touch" && n();
25
- }, kr = ({ activeValue: n, border: s, icon: d, isPressed: t, onSubmit: r, range: a, scaleLabelType: g, selectedValue: v, setSelectedValue: u, setActiveValue: h, setIsPressed: l, useMobileStyling: b, value: c, viewDocument: N }) => {
26
- const { isLongFormSurvey: o, enableCspTrustedTypes: f } = Y((S) => ({ isLongFormSurvey: ie(S.studyType), enableCspTrustedTypes: S.enableCspTrustedTypes })), p = `option-${c}`, k = g === "number", x = g === "star", _ = g === "smiley", w = k && c === n || c === v, [E, M] = (() => {
27
- const S = x && v !== null && c <= v;
28
- return x && c <= n || _ && c === n || S || c === n || c === v ? [s, t || S || c === v ? 1 : 0.3] : ["", 1];
29
- })(), U = he(() => {
30
- const S = v === c, P = { borderColor: w && !b || S ? E : "", fillOpacity: w ? "" : M, zIndex: w ? 3 : "auto", color: S ? "#fff" : "" };
31
- return k ? { ...P, backgroundColor: S ? E : "" } : { ...P, color: x || _ || S ? E : "" };
32
- }, [w, E, M, v, c, k, x, _, b]), m = he(() => We((({ icon: S, scaleLabelType: P, value: D, selectedValue: A }) => {
33
- if (P === "smiley" && D === A) {
34
- let C = 0;
35
- return S.replace(/black/g, () => ++C == 1 ? "black" : "white");
36
- }
37
- return S;
38
- })({ icon: d, scaleLabelType: g, value: c, selectedValue: v }), f), [f, d, g, v, c]);
39
- return e("button", { "aria-label": k ? void 0 : String(c), className: (() => {
40
- switch (g) {
41
- case "star":
42
- return O(te("likert-star", b), te(`likert-star-${c}`, b));
43
- case "smiley":
44
- return O(te("likert-smiley", b), te(`likert-smiley-${c}`, b));
45
- default:
46
- return c === a ? O(te("likert-number", b), te(`likert-number-${c}`, b), te("likert-last-option", b)) : O(te("likert-number", b), te(`likert-number-${c}`, b));
47
- }
48
- })(), dangerouslySetInnerHTML: { __html: m }, id: p, onClick: (S) => {
49
- o && (S.preventDefault(), S.stopPropagation(), u(c)), r();
50
- }, onKeyDown: (S) => {
51
- var A, C;
52
- const P = N.querySelectorAll(`.likert-${g ?? "number"}`), D = c - 1;
53
- S.key === "ArrowRight" ? (A = P[D + 1]) == null || A.focus() : S.key === "ArrowLeft" ? (C = P[D - 1]) == null || C.focus() : S.key !== "Enter" && S.key !== " " || (o && (S.preventDefault(), S.stopPropagation(), u(c)), r());
54
- }, onPointerCancel: ke(() => l(!1)), onPointerDown: ke(() => {
55
- l(!0), h(c);
56
- }), onPointerEnter: ke(() => h(c)), onPointerLeave: ke(() => {
57
- h(-1), l(!1);
58
- }), onPointerUp: ke(() => l(!1)), style: U, tabIndex: 0 });
59
- }, Tr = ({ className: n, labels: s, message: d, next: t, properties: r, questionId: a, type: g }) => {
60
- const { border: v, useMobileStyling: u, viewDocument: h, isLongFormSurvey: l, focusedQuestionId: b } = Y((D) => ({ border: D.border, useMobileStyling: D.useMobileStyling, viewDocument: D.viewDocument, isLongFormSurvey: ie(D.studyType), focusedQuestionId: D.focusedQuestionId })), [c, N] = J(-1), [o, f] = J(!1), [p, k] = J(null);
61
- re(() => {
62
- N(-1), f(!1), k(null);
63
- }, [a]);
64
- const x = l && b === a, _ = s && s.left, w = s && s.right;
65
- let E;
66
- const { range: M, scaleLabelType: U, ratingIcons: m } = r;
67
- M && (E = Number(M));
68
- const S = E || 5, P = (D) => {
69
- var A, C;
70
- switch (U) {
71
- case "star":
72
- return (A = m[0]) == null ? void 0 : A.svg;
73
- case "smiley":
74
- return (C = m[D]) == null ? void 0 : C.svg;
75
- default:
76
- return String(D + 1);
77
- }
78
- };
79
- return e("form", { className: O(n, "ul-card--likert", "fade-in-transition", l && !x && "ul-card--unfocused"), children: [e(ae, { isRequired: l && (r == null ? void 0 : r.required), message: d, properties: r }), e(me, { properties: r, children: e(ve, { children: [e(le, { children: [e("div", { "aria-label": `Rating (1 - ${S})`, className: "ul-card--likert__numbers", role: "radiogroup", children: [...Array(S)].map((D, A) => {
80
- const C = A + 1;
81
- return e(kr, { activeValue: c, border: v, icon: P(A), isPressed: o, onSubmit: () => t({ value: C, questionId: a, type: g }, !0), range: S, scaleLabelType: U, selectedValue: p, setActiveValue: N, setIsPressed: f, setSelectedValue: k, useMobileStyling: u, value: C, viewDocument: h }, A);
82
- }) }), e("div", { className: "ul-card--likert__labels", children: [e("span", { children: _ }), e("span", { children: w })] })] }), !r.required && !l && e(pe, { children: e("div", { className: "ul-vertical-centered-container", children: e(ee, { onClick: (D) => {
83
- D.preventDefault(), D.stopPropagation(), t({ value: null, questionId: a, type: g }, !0);
84
- }, children: be(r) }) }) })] }) })] }, a);
85
- }, Ir = ({ columns: n, onSelect: s, options: d, selectedOptions: t }) => {
86
- const r = ne([]), { border: a, useMobileStyling: g, cards: v, index: u } = Y((o) => ({ border: o.border, useMobileStyling: o.useMobileStyling, cards: o.cards, index: o.index })), h = d.findIndex((o) => t[o.id] === null), [l, b] = J(h), c = Ce((o, f) => {
87
- var x;
88
- s(o, f);
89
- const p = l + 1, k = d[p];
90
- if (k && t[k.id] === null) {
91
- b(p);
92
- const _ = v[u];
93
- (_ == null ? void 0 : _.groupId) != null || ((x = r.current[p]) == null || x.scrollIntoView({ block: "nearest", behavior: "smooth" }));
94
- }
95
- }, [s, d, t, l, v, u]), N = Ce((o, f) => {
96
- const p = l === o;
97
- return e(nr, { animate: !0, header: f.label, isOpen: p, onClick: () => {
98
- var k;
99
- return b(p && !((k = window.UserLeap) != null && k.isMobileSDK) ? -1 : o);
100
- }, ref: (k) => {
101
- k && (r.current[o] = k);
102
- }, showHeaderCheck: t[f.id] !== null, children: e("div", { style: { paddingTop: "12px" }, children: n.map((k) => e(fe, { allowTextEntry: !1, ariaLabel: `${f.label}-${k.label}`, border: a, error: !1, id: `${f.id}-${k.value}`, isRadio: !0, isSelected: t[f.id] === k.value, label: k.label, onUserInputChanged: () => c(f.id, k.value), useMobileStyling: g }, k.label)) }) }, f.id);
103
- }, [a, n, l, c, t, g]);
104
- return e("div", { children: d.map((o, f) => N(f, o)) });
105
- }, _r = ({ columns: n, onSelect: s, options: d, selectedOptions: t }) => {
106
- const { border: r, useMobileStyling: a, isLongFormSurvey: g } = Y((o) => ({ border: o.border, useMobileStyling: o.useMobileStyling, isLongFormSurvey: ie(o.studyType) })), v = d.length, u = n.length, h = ne(null), [l, b] = J(!1), [c, N] = J(!1);
107
- return re(() => {
108
- const o = h.current, f = new ResizeObserver((p) => {
109
- window.requestAnimationFrame(() => {
110
- o && (b(Math.round(p[0].contentRect.width) < o.scrollWidth), N(Math.round(p[0].contentRect.width) < o.scrollWidth));
111
- });
112
- });
113
- return o && f.observe(o), () => {
114
- o && f.unobserve(o);
115
- };
116
- }, []), e("div", { className: "ul-card--matrix_question_container", children: [e("div", { className: O("ul-card--matrix_container", l && "ul-matrix-scroll-gradient"), onScroll: () => {
117
- (() => {
118
- const o = h.current;
119
- o && b(o.clientWidth + Math.abs(o.scrollLeft) < o.scrollWidth);
120
- })();
121
- }, ref: h, children: e("div", { className: O(g && "ul-card--matrix_grid_longform", "ul-card--matrix_grid"), style: `--numColumns: ${u}; --numRows: ${v + 1};`, children: [e("div", {}), " ", n.map((o) => e("div", { className: "ul-matrix-column-label", children: o.label }, o.label)), d.map((o) => e(ve, { children: [e("div", { "aria-label": o.label, className: "ul-matrix-row-label", children: o.label }, o.label), e("div", { className: "ul-matrix-row-options", role: "radiogroup", children: n.map((f, p) => e("div", { className: O("ul-matrix-option-wrapper", p === u - 1 && "ul-matrix-last-option"), children: e(fe, { allowTextEntry: !1, ariaLabel: `${o.label}-${f.label}`, border: r, choiceStyle: { background: "transparent", border: "none", marginBottom: "0", padding: "0" }, error: !1, id: `${o.id}-${f.value}`, isRadio: !0, isSelected: t[o.id] === f.value, onUserInputChanged: () => s(o.id, f.value), useMobileStyling: a }) }, f.value)) })] }))] }) }), (l || c) && e("button", { className: c && !l ? "ul-matrix-scroll-arrow left" : "ul-matrix-scroll-arrow", onClick: c && !l ? (o) => {
122
- o.preventDefault();
123
- const f = h.current;
124
- if (f) {
125
- const p = getComputedStyle(f).direction === "rtl";
126
- f.scrollTo({ left: p ? f.scrollWidth - f.clientWidth : 0, behavior: "smooth" });
127
- }
128
- } : (o) => {
129
- o.preventDefault();
130
- const f = h.current;
131
- if (f) {
132
- const p = getComputedStyle(f).direction === "rtl";
133
- f.scrollTo({ left: p ? f.clientWidth - f.scrollWidth : f.scrollWidth, behavior: "smooth" });
134
- }
135
- }, children: e(c && !l ? Cr : Nr, {}) })] });
136
- }, Cr = () => e("svg", { fill: "currentColor", height: "32", transform: "matrix(-1,0,0,1,0,0)", version: "1.1", viewBox: "0 0 256 256", width: "32", xmlns: "http://www.w3.org/2000/svg", children: e("path", { d: "M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z" }) }), Nr = () => e("svg", { fill: "currentColor", height: "32", viewBox: "0 0 256 256", width: "32", xmlns: "http://www.w3.org/2000/svg", children: e("path", { d: "M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z" }) }), wr = ({ className: n, message: s, next: d, options: t, properties: r, questionId: a, type: g, showIndividualSubmit: v = !1, onSubmitButtonClick: u }) => {
137
- const { useMobileStyling: h, isLongFormSurvey: l, focusedQuestionId: b, setFocusedQuestionId: c } = Y((m) => ({ useMobileStyling: m.useMobileStyling, isLongFormSurvey: ie(m.studyType), focusedQuestionId: m.focusedQuestionId, setFocusedQuestionId: m.setFocusedQuestionId })), N = r.matrixColumn, o = r.required, f = l && b === a, p = (m) => Object.values(m).every((S) => S == null), k = (m) => o && p(m), x = (m) => {
138
- if (m.preventDefault(), m.stopPropagation(), d({ value: w, questionId: a, type: g }, !0), u) {
139
- const S = !p(w);
140
- u(S);
141
- }
142
- }, _ = t.reduce((m, S) => (m[S.id] = null, m), {}), [w, E] = J(_), M = (m, S) => {
143
- l && d({ value: { ...w, [m]: S }, questionId: a, type: g }, !k({ ...w, [m]: S })), E((P) => ({ ...P, [m]: S }));
144
- }, U = r.displayMatrixAsAccordion || h;
145
- return e("form", { className: O(n, !l && "ul-card__matrix", "fade-in-transition", l && !f && "ul-card--unfocused"), id: "text-form", onClick: () => {
146
- f && c(a);
147
- }, onSubmit: x, children: [e(ae, { isRequired: l && (r == null ? void 0 : r.required), message: s, properties: r }), e(me, { properties: r, children: [e(le, { children: [e(U ? Ir : _r, { columns: N, onSelect: M, options: t, selectedOptions: w }), v && e(Te, { handleSubmit: x, isSubmitDisabled: k(w) })] }), !l && e(pe, { children: e("div", { className: "ul-card__button-wrapper", children: e(ee, { disabled: k(w), children: be(r) }) }) })] })] }, a);
148
- }, Ge = ({ className: n, message: s, onSubmit: d, options: t = [], properties: r, questionId: a, type: g, showIndividualSubmit: v = !1, onSubmitButtonClick: u }) => {
149
- const { border: h, useMobileStyling: l, isLongFormSurvey: b, focusedQuestionId: c, setFocusedQuestionId: N } = Y((T) => ({ border: T.border, useMobileStyling: T.useMobileStyling, isLongFormSurvey: ie(T.studyType), focusedQuestionId: T.focusedQuestionId, setFocusedQuestionId: T.setFocusedQuestionId })), o = b && c === a, f = t.reduce((T, Q) => (T[Q.id] = { isSelected: !1 }, T), {}), [p, k] = J(f), x = g === "multiplechoice", _ = r.required, w = t.find((T) => {
150
- var Q;
151
- return (Q = T.optionProperties) == null ? void 0 : Q.noneOfTheAbove;
152
- }), E = (T) => Object.entries(T).some(([Q, V]) => {
153
- var q;
154
- const i = t.find((R) => `${R.id}` === Q), y = V.userText === void 0 || V.userText.trim() === "";
155
- return ((q = i == null ? void 0 : i.optionProperties) == null ? void 0 : q.allowsTextEntry) && y && V.isSelected;
156
- }), M = (T) => Object.values(T).filter((Q) => Q.isSelected).length, U = (T) => {
157
- const { minSelect: Q = 0, maxSelect: V = 1 / 0, maxSelectMode: i } = r, y = M(T);
158
- switch (i) {
159
- case _e.Maximum:
160
- return y <= V;
161
- case _e.Range:
162
- return y === 0 || y >= Q;
163
- default:
164
- return !0;
165
- }
166
- }, m = r.minSelect && r.minSelect > 0 && r.maxSelectMode === _e.Range && M(p) < r.minSelect && (_ || M(p) > 0), S = (T) => E(T) || _ && !M(T) || !U(T), P = (T) => U(T) && !E(T) && M(T) > 0, D = Object.entries(p).some(([T, Q]) => {
167
- var V, i;
168
- return Q.isSelected && ((i = (V = t.find((y) => `${y.id}` === T)) == null ? void 0 : V.optionProperties) == null ? void 0 : i.allowsTextEntry);
169
- }), A = v && (!x || D), C = (T) => {
170
- z(T.id, T.selected, T.userText, T.noneOfTheAbove), T.selected && b && !x && !o && N(a);
171
- }, B = (T) => {
172
- var Q;
173
- return (r == null ? void 0 : r.maxSelectMode) !== _e.Unlimited && M(p) === (r == null ? void 0 : r.maxSelect) && !((Q = p[T]) != null && Q.isSelected);
174
- }, K = (T) => {
175
- if (T.preventDefault(), T.stopPropagation(), d(p, !0), u) {
176
- const Q = P(p);
177
- u(Q);
178
- }
179
- }, z = (T, Q, V, i) => {
180
- const y = Object.assign({}, p);
181
- if ((x || i) && Q) for (const L of Object.values(y)) L.isSelected = !1, delete L.userText;
182
- else w && !i && p[w.id].isSelected && (y[w.id].isSelected = !1);
183
- y[T] = { isSelected: Q, userText: V };
184
- const q = x && Object.entries(y).some(([L, j]) => {
185
- var Z, se;
186
- return j.isSelected && ((se = (Z = t.find((ce) => `${ce.id}` === L)) == null ? void 0 : Z.optionProperties) == null ? void 0 : se.allowsTextEntry);
187
- }), R = !S(y);
188
- if (b && (d(y, R), x && !q && R && u)) {
189
- const L = P(y);
190
- u(L);
191
- }
192
- k(y);
193
- };
194
- return e("form", { className: O(n, "ul-card--multiple", "fade-in-transition", b && !o && "ul-card--unfocused"), id: "text-form", onClick: g === "multipleselect" ? () => {
195
- b && c !== a && g === "multipleselect" && N(a);
196
- } : void 0, onSubmit: K, children: [e(ae, { isRequired: b && (r == null ? void 0 : r.required), message: s, properties: r }), e(me, { properties: r, children: e(ve, { children: [e(le, { children: [r.isDropdown ? e(vr, { disabledOptions: t.filter((T) => B(T.id)), dropdownFooter: m ? e("div", { className: "ul-card__min-select-counter", style: { marginLeft: "16px" }, children: [M(p), "/", r.minSelect] }) : void 0, isMultiSelect: !x, multiselectText: r.dropdownMultiselectedText ?? "choices selected", onChange: (T) => {
197
- const Q = { ...p };
198
- for (const V of t) T.includes(V) ? Q[V.id].isSelected = !0 : Q[V.id].isSelected = !1;
199
- b && d(Q, !S(Q)), k(Q);
200
- }, options: t, placeholderText: r.dropdownPlaceholderText ?? (x ? "Select choice" : "Select choice(s)"), value: t.filter((T) => p[T.id].isSelected) }) : e("div", { className: O(te("ul-card__choices", l)), role: x ? "radiogroup" : "group", children: [t.map(({ id: T, label: Q, value: V, optionProperties: i }) => {
201
- var L, j;
202
- const y = `${T}`, { allowsTextEntry: q, noneOfTheAbove: R } = { allowsTextEntry: !1, noneOfTheAbove: !1, ...i };
203
- return e(fe, { allowTextEntry: q, border: h, disabled: B(y), error: E(p), id: y, isRadio: x, isSelected: !!((L = p[y]) != null && L.isSelected), label: Q, noneOfTheAbove: R, onUserInputChanged: C, promptText: (i == null ? void 0 : i.otherOptionPlaceholder) || "Please specify", text: (j = p[T]) == null ? void 0 : j.userText, useMobileStyling: l, value: V }, y);
204
- }), !!m && e("div", { className: "ul-card__min-select-counter", children: [M(p), "/", r.minSelect] })] }), A && e(Te, { handleSubmit: K, isSubmitDisabled: S(p) })] }), !b && e(pe, { children: e("div", { className: "ul-card__button-wrapper", children: e(ee, { disabled: S(p), onClick: K, children: be(r) }) }) })] }) })] }, a);
205
- }, qr = (n) => {
206
- const { questionId: s, type: d, next: t, options: r } = n, { setFocusedQuestionId: a } = Y((g) => ({ setFocusedQuestionId: g.setFocusedQuestionId }));
207
- return e(Ge, { ...n, onSubmit: (g, v) => {
208
- var N;
209
- const u = Object.entries(g).find(([, o]) => o.isSelected) || [void 0, void 0], [h, l] = u, b = r.find((o) => `${o.id}` === h);
210
- !((N = b == null ? void 0 : b.optionProperties) != null && N.allowsTextEntry) || l != null && l.userText && l.userText.trim() !== "" || a(s);
211
- const c = l != null && l.userText ? { [h]: { userText: l.userText } } : null;
212
- t({ value: b && h ? { [h]: b.value } : {}, secondaryValue: c, questionId: s, type: d }, v);
213
- } });
214
- }, Lr = (n) => {
215
- const { questionId: s, type: d, next: t } = n;
216
- return e(Ge, { ...n, onSubmit: (r, a) => {
217
- const g = Object.entries(r).reduce((u, [h, l]) => (u[h] = l.isSelected, u), {}), v = Object.entries(r).reduce((u, [h, l]) => {
218
- if (!l.userText) return u;
219
- const b = u || {};
220
- return b[h] = { userText: l.userText }, b;
221
- }, null);
222
- t({ value: g, secondaryValue: v, questionId: s, type: d }, a);
223
- } });
224
- }, Pr = ({ className: n, labels: s, message: d, properties: t, next: r, questionId: a, type: g }) => {
225
- const [v, u] = J(null), { border: h, useMobileStyling: l, viewDocument: b, isLongFormSurvey: c, focusedQuestionId: N } = Y((k) => ({ border: k.border, useMobileStyling: k.useMobileStyling, viewDocument: k.viewDocument, isLongFormSurvey: ie(k.studyType), focusedQuestionId: k.focusedQuestionId })), o = c && N === a, f = s && s.left, p = s && s.right;
226
- return e("form", { className: O(n, "ul-card--nps", "fade-in-transition", c && !o && "ul-card--unfocused"), children: [e(ae, { isRequired: c && (t == null ? void 0 : t.required), message: d, properties: t }), e(me, { properties: t, children: [e(le, { children: [e("div", { className: "ul-card--nps__numbers", children: [...Array(11)].map((k, x) => e("button", { className: O(te("nps-number", l), te(`nps-number-${x}`, l)), id: `option-${x}`, onClick: (_) => {
227
- c && (_.preventDefault(), _.stopPropagation(), u(x)), r({ value: x, questionId: a, type: g }, !0);
228
- }, onKeyDown: (_) => {
229
- var E, M;
230
- const w = b.querySelectorAll("button.nps-number");
231
- _.key === "ArrowRight" ? (E = w[x + 1]) == null || E.focus() : _.key === "ArrowLeft" ? (M = w[x - 1]) == null || M.focus() : _.key !== "Enter" && _.key !== " " || (c && (_.preventDefault(), _.stopPropagation(), u(x)), r({ value: x, questionId: a, type: g }, !0));
232
- }, onPointerDown: (_) => {
233
- _.currentTarget.style.zIndex = "2", _.currentTarget.style.borderColor = h;
234
- }, onPointerLeave: (_) => {
235
- _.currentTarget.style.zIndex = "auto", _.currentTarget.style.borderColor = Qe;
236
- }, style: v === x ? { backgroundColor: h, color: "#fff" } : void 0, tabIndex: 0, children: x }, x)) }), e("div", { className: "ul-card--nps__labels", children: [e("span", { children: f }), e("span", { children: p })] })] }), !t.required && !c && e(pe, { children: e("div", { className: "ul-vertical-centered-container", children: e(ee, { onClick: (k) => {
237
- k.preventDefault(), k.stopPropagation(), r({ value: null, questionId: a, type: g }, !0);
238
- }, children: be(t) }) }) })] })] }, a);
239
- }, Mr = (n) => {
240
- const { className: s, message: d, next: t, properties: r, questionId: a, type: g, showIndividualSubmit: v = !1, onSubmitButtonClick: u } = n, h = g === "aidynamicfollowup" || g === "aidynamicstandalone", l = h ? n.loading : void 0, { border: b, useMobileStyling: c, update: N, isLongFormSurvey: o, focusedQuestionId: f, setFocusedQuestionId: p, isPreview: k } = Y((C) => ({ border: C.border, useMobileStyling: C.useMobileStyling, update: C.update, isLongFormSurvey: ie(C.studyType), focusedQuestionId: C.focusedQuestionId, setFocusedQuestionId: C.setFocusedQuestionId, isPreview: C.isPreview })), [x, _] = J(""), w = ne(null), E = o && f === a;
241
- re(() => {
242
- var C, B;
243
- o && !k && (E ? (C = w.current) == null || C.focus() : (B = w.current) == null || B.blur());
244
- }, [o, E, k]);
245
- const M = x.trim(), U = r.required === !0 && !M, m = yr(w, () => N()), S = (C) => {
246
- C.preventDefault(), C.stopPropagation();
247
- const B = M.length > 0, K = !r.required || B;
248
- t({ value: x, questionId: a, type: g }, K), u && u(B);
249
- }, P = r && r.openTextPlaceholder ? r.openTextPlaceholder : "";
250
- if ((l === Me.failure || l === void 0) && h) return e(ve, {});
251
- const D = l === Me.inFlight, A = D ? "Preparing your next question" : d;
252
- return e("form", { className: O(s, "ul-card-text", "fade-in-transition", o && !E && "ul-card--unfocused"), id: "text-form", onClick: () => {
253
- o && f !== a && p(a);
254
- }, children: [e(ae, { isRequired: o && (r == null ? void 0 : r.required), message: A, properties: r }), e(me, { properties: r, children: e("div", { className: "ul-card-text", children: e(le, { children: [e("div", { className: "ul-card-text__container", children: e("textarea", { "aria-describedby": "ul-caption", "aria-labelledby": "ul-question", "aria-multiline": "true", "aria-placeholder": P, className: O(D && "ul-card-text__input__loading", te("ul-card-text__input", c)), "data-gramm": "false", disabled: D, maxLength: 5e3, name: "text", onBlur: (C) => {
255
- C.currentTarget.style.borderColor = Qe;
256
- }, onChange: (C) => {
257
- const { value: B } = C.currentTarget;
258
- if (m(), C.preventDefault(), C.stopPropagation(), _(B), o) {
259
- const K = B.trim().length > 0;
260
- t({ value: B, questionId: a, type: g }, K);
261
- }
262
- }, onFocus: (C) => {
263
- C.currentTarget.style.borderColor = b, p(a);
264
- }, placeholder: P, ref: w, role: "textbox", tabIndex: 0 }) }), r.footerHtml && e(Ie, { className: "footer", html: r.footerHtml }), v && e(Te, { handleSubmit: S, isSubmitDisabled: U }), e(pe, { children: !o && e(ee, { disabled: U || D, onClick: S, children: be(r) }) })] }) }) })] }, a);
265
- }, De = 1, ze = 2, Ye = 3, Ne = (n) => n.type === "av_permission", Oe = (n) => n.type === "screen_permission", Ke = (n, s) => n === void 0 ? De : n ? ((d, t) => !(Ne(t) ? t.permissionDescriptors : []).includes("camera") || d.getVideoTracks().length > 0)(n, s) ? Ye : De : ze, Ue = { avStream: null, currentPage: null, mediaRecordingUids: null, nextQuestion: () => {
266
- }, passthroughData: void 0, recordingMediaTypes: void 0, screenPermissionRequested: !1, type: void 0 }, ue = sr((n) => ({ ...Ue, reset: () => {
267
- n(Ue);
268
- }, updatePage: (s) => {
269
- n(s);
270
- } }));
271
- function Re({ currentPage: n, pages: s }) {
272
- const { avStream: d, recordingMediaTypes: t, updatePage: r } = ue.getState(), { recorderEventEmitter: a } = Y.getState();
273
- a.emit("av.permission", { "permission.descriptors": n.permissionDescriptors, "stream.ready": (g, v) => {
274
- if (d === g) return;
275
- let u = n;
276
- if (g && !n.permissionDescriptors.includes("camera")) {
277
- const h = s.indexOf(n), l = v != null && v.active ? h + 2 : h + 1;
278
- v != null && v.active && t && a.emit("begin.recording", { "recording.media.types": t, "start.recording.callback": (b) => r({ mediaRecordingUids: b }) }), u = s[l];
279
- }
280
- r({ currentPage: u, avStream: g });
281
- } });
282
- }
283
- function Fe({ status: n }) {
284
- const { nextQuestion: s, passthroughData: d, mediaRecordingUids: t, reset: r } = ue.getState(), { recorderEventEmitter: a, handleUploadUpdate: g, index: v } = Y.getState(), u = { value: { taskStatus: n }, type: "recordedtask", questionId: (d == null ? void 0 : d.questionId) || 1 };
285
- d && a.emit("finish.task", { "begin.callback": (h) => {
286
- g({ mediaRecordingUid: h, isSubmitted: !0, progressPct: 0, isComplete: !1 });
287
- }, "progress.callback": (h, l) => {
288
- g({ mediaRecordingUid: h, progressPct: l.detail, isSubmitted: !1, isComplete: !1 });
289
- }, "upload.callback": (h) => {
290
- h && g({ mediaRecordingUid: h, isComplete: !0, isSubmitted: !0, progressPct: 100 });
291
- }, "passthrough.data": d, "current.index": v, "task.response": u, "task.complete.callback": (h) => {
292
- u.value.taskDurationMillisecond = h, t && (u.value.mediaRecordingUids = t), r(), s(u);
293
- } });
294
- }
295
- function Be({ pages: n, setIsRequestingPermission: s }) {
296
- const { recorderEventEmitter: d, eventEmitFn: t } = Y.getState(), { updatePage: r, currentPage: a, recordingMediaTypes: g, screenPermissionRequested: v } = ue.getState();
297
- if (!a) return;
298
- const u = n.indexOf(a);
299
- switch (a.type) {
300
- case "av_permission": {
301
- const h = v ? u + 2 : u + 1;
302
- return v && g && d.emit("begin.recording", { "recording.media.types": g, "start.recording.callback": (l) => {
303
- r({ mediaRecordingUids: l });
304
- } }), void r({ currentPage: n[h] });
305
- }
306
- case "screen_permission":
307
- return void d.emit("screen.permission", { "screen.permission.requested": s, "stream.ready.callback": (h, l) => {
308
- const b = l ? n[u + 1] : a;
309
- l && g && d.emit("begin.recording", { "recording.media.types": g, "start.recording.callback": (c) => {
310
- r({ captureStream: l, mediaRecordingUids: c });
311
- } }), r({ currentPage: b, screenPermissionRequested: !0, captureStream: l });
312
- } });
313
- case "start_task":
314
- return t("recorded.task.start"), d.emit("recorded.task.start"), d.emit("start.task"), void r({ currentPage: n[u + 1], screenPermissionRequested: !0 });
315
- case "complete_task":
316
- return;
317
- }
318
- }
319
- const Xe = "ul-permission-graphics-container", Je = "ul-permission-body", er = O(Xe, "ul_recorded-task-inset-spacing"), we = O("ul-horizontal-button-container", "ul-horizontal-button-container-left"), rr = ({ richTextBody: n }) => e(Ie, { className: "ul-rich-text-body", html: n, id: "ul-task-detail-container" }), qe = ({ required: n, skipButtonText: s, bottom: d = !1 }) => n ? null : e(ee, { className: O(d && "ul-skip-button-below", "ul-button-inactive"), onClick: Fe.bind(null, { status: "abandoned" }), children: s || "Skip" }), Ee = (n) => {
320
- const { avStream: s, captureStream: d, recordingMediaTypes: t, updatePage: r } = ue.getState(), a = (t == null ? void 0 : t.includes("audio")) || (t == null ? void 0 : t.includes("video"));
321
- re(() => {
322
- const g = setInterval(() => {
323
- a && s && !s.active ? r({ avStream: null, currentPage: n[0] }) : d && d.active || r({ captureStream: void 0, currentPage: n[a ? 1 : 0] });
324
- }, 1e3);
325
- return () => clearInterval(g);
326
- }, [s, d, a, n, t, r]);
327
- }, Dr = ({ content: n, pages: s, required: d }) => {
328
- const { buttonText: t, skipButtonText: r, taskDetail: a } = n;
329
- return Ee(s), e("div", { className: "ul-task-page", children: [a && e(rr, { richTextBody: a }), e("div", { className: we, children: [e(ee, { onClick: Be.bind(null, { pages: s }), children: t }), e(qe, { required: d, skipButtonText: r })] })] }, "start-task");
330
- }, Rr = ({ content: n, pages: s, properties: d }) => {
331
- const { buttonText: t, skipButtonText: r } = n;
332
- return Ee(s), e("div", { className: "ul-task-page", children: [n.taskDetail && e(rr, { richTextBody: n.taskDetail }), e(me, { properties: d, children: e("div", { className: we, children: [e(ee, { className: "ul-complete-task-button", onClick: Fe.bind(null, { status: "completed" }), children: t }), e(ee, { className: O("ul-button-inactive"), onClick: Fe.bind(null, { status: "given.up" }), children: r })] }) })] }, "complete-task");
333
- }, Fr = ({ content: n, pages: s, required: d }) => {
334
- const { buttonText: t, skipButtonText: r } = n, [a] = Y((u) => [u.tabTitle]), [g, v] = J(!1);
335
- return e("div", { children: [e("div", { className: er, children: [e("p", { style: { marginTop: "auto" }, children: n.selectTabText }), e("div", { className: "ul-select-tab-container", children: e("p", { className: Je, children: a }) })] }), e("div", { className: d ? "" : we, children: [e(ee, { disabled: g, onClick: Be.bind(null, { pages: s, setIsRequestingPermission: v }), children: t }), e(qe, { required: d, skipButtonText: r })] })] });
336
- }, Qr = ({ content: n }) => e(Ie, { className: O(Xe, "ul_permission_svg_container", "ul_recorded-task-inset-spacing", "ul-center-horizontally"), html: n.svg }, "ul-permission-request-graphic"), Br = ({ content: n, pages: s, required: d }) => {
337
- const { permissionDeniedHeadline: t, permissionDeniedBody: r, skipButtonText: a, tryAgainButtonText: g } = n, v = Ne(s[0]) ? s[0] : null;
338
- return re(() => {
339
- const u = setInterval(() => {
340
- v !== null && Re({ currentPage: v, pages: s });
341
- }, 1e3);
342
- return () => clearInterval(u);
343
- }, [v, s]), v ? e("div", { children: [e("div", { className: er, children: e("p", { className: "ul-av-permission-denied-paragraph", children: [e("span", { className: "ul-av-permission-denied-headline", children: t }), e("span", { className: Je, children: r })] }) }), e("div", { className: we, children: [e(ee, { onClick: Re.bind(null, { currentPage: v, pages: s }), children: g }), e(qe, { required: d, skipButtonText: a })] })] }) : null;
344
- }, Er = ({ stream: n }) => e("video", { autoPlay: !0, className: O("ul_recorded-task-inset-spacing"), id: "ul-record-task-video-preview", muted: !0, ref: (s) => {
345
- s && (s.srcObject = n || null);
346
- } }), Ar = ({ content: n, pages: s, required: d }) => {
347
- const { skipButtonText: t } = n, { avStream: r } = ue.getState();
348
- return Ee(s), e("div", { children: [e(Er, { stream: r }), e("div", { className: "ul-vertical-button-container-center", children: [e(ee, { onClick: Be.bind(null, { pages: s }), children: n.buttonText }), e(qe, { bottom: !0, required: d, skipButtonText: t })] })] });
349
- }, $r = ({ properties: n }) => {
350
- const { pages: s, required: d } = n, { avStream: t, currentPage: r } = ue.getState();
351
- if (r === void 0) return null;
352
- switch (r == null ? void 0 : r.type) {
353
- case "av_permission": {
354
- const a = Ke(t, r);
355
- return a === De ? e(Qr, { content: r }) : e(a === ze ? Br : Ar, { content: r, pages: s, required: d });
356
- }
357
- case "screen_permission":
358
- return e(Fr, { content: r, pages: s, required: d });
359
- case "start_task":
360
- return e(Dr, { content: r, pages: s, required: d });
361
- case "complete_task":
362
- return e(Rr, { content: r, pages: s, properties: n });
363
- default:
364
- return null;
365
- }
366
- }, Or = ({ className: n, properties: s, next: d, questionId: t }) => {
367
- const r = Y(), { surveyId: a, responseGroupUid: g, userId: v, update: u } = r, h = ue(), { screenPermissionRequested: l } = h, b = ue((p) => p.avStream);
368
- let c = ue((p) => p.currentPage);
369
- c || (c = function({ pages: p, userId: k, responseGroupUid: x, surveyId: _, questionId: w, next: E }) {
370
- const { updatePage: M } = ue.getState(), { eventEmitFn: U, recorderEventEmitter: m } = Y.getState(), S = { questionId: w, surveyId: _, visitorId: k, responseGroupUid: x };
371
- let P = 0;
372
- m.emit("recorded.task.permission.screen"), U("recorded.task.permission.screen"), m.emit("permission.status", { "permission.status.callback": (A, C, B, K) => {
373
- const z = p[P], { type: T } = z, Q = ["screen"];
374
- if (Ne(z)) {
375
- const { permissionDescriptors: V } = z, i = V == null ? void 0 : V.includes("microphone"), y = V == null ? void 0 : V.includes("camera");
376
- i && Q.push("audio"), y && Q.push("video"), (A != null && A.active && !y || A != null && A.active && C) && P++;
377
- }
378
- Oe(p[P]) && B && (P++, m.emit("begin.recording", { "recording.media.types": Q, "start.recording.callback": (V) => M({ mediaRecordingUids: V }) })), M({ currentPage: p[P], avStream: A, screenPermissionRequested: B, nextQuestion: E, type: T, passthroughData: S, recordingMediaTypes: Q, captureStream: K });
379
- } });
380
- const D = p[P];
381
- return D.type === "av_permission" && Re({ currentPage: D, pages: p }), D;
382
- }({ questionId: t, surveyId: a, next: (p) => {
383
- d(p, !0);
384
- }, pages: s.pages, responseGroupUid: g, userId: v }));
385
- let N = c.headline, o = c.captionText;
386
- const f = Ke(b, c);
387
- return Oe(c) && l && (N = c.permissionDeniedHeadline, o = c.permissionDeniedCaptionText), Ne(c) && f === Ye && (N = c.permissionGrantedHeadline, o = c.permissionGrantedCaptionText), re(() => {
388
- u();
389
- }, [u]), e("div", { className: O(n, "ul-center-horizontally", "fade-in-transition"), children: [e(ae, { isRequired: s == null ? void 0 : s.required, message: N, properties: { captionText: o } }), e(le, { children: e($r, { properties: s }) })] });
390
- }, Ur = ({ richTextBody: n, plaintextBody: s }) => n ? e(Ie, { className: "ul-rich-text-body", html: n, id: "ul-card__text-url-body-container" }) : s ? e("div", { className: "ul-rich-text-body", id: "ul-card__text-url-body-container", children: (s ? s.split(/\n\s*\n/g) : []).map((d, t) => e("p", { children: d }, t)) }) : null, Vr = ({ className: n, message: s, next: d, properties: t, questionId: r, type: a }) => {
391
- const { visitorAttributes: g, isLongFormSurvey: v } = Y((b) => ({ visitorAttributes: b.visitorAttributes, isLongFormSurvey: ie(b.studyType) })), u = (b, c = !1) => {
392
- d({ value: c ? { skipped: !0 } : void 0, questionId: r, type: a }, !0);
393
- }, h = fr(t && t.buttonUrl, g), l = v && t.promptActionType === ir.NO_BUTTON;
394
- return e("div", { className: O(n, "ul-card__text-url-prompt", "fade-in-transition"), children: [e(ae, { isRequired: v && (t == null ? void 0 : t.required), message: s, properties: { questionHtml: t.questionHtml } }), e(le, { children: e(Ur, { plaintextBody: t == null ? void 0 : t.body, richTextBody: t == null ? void 0 : t.richTextBody }) }), e(me, { properties: t, children: !l && e(pe, { children: e("div", { className: "ul-card-button-group", children: [e("a", { className: "ul-card-text__button ul-card__text-url-prompt-button", href: h, id: "ul-card-text__button", onClick: u, onKeyPress: (b) => {
395
- b.key !== "Enter" && b.key !== " " || d({ value: void 0, questionId: r, type: a }, !0);
396
- }, rel: "noreferrer", role: h ? "link" : "button", tabIndex: 0, target: "_blank", children: be(t) }), t.required === !1 && e("button", { className: "ul-card-skip__button", onClick: (b) => u(0, !0), children: je(t) })] }) }) })] }, r);
397
- }, Hr = ({ className: n, questionId: s }) => {
398
- const { border: d, destroy: t, endCard: r, forceBrandedLogo: a, update: g } = Y((h) => ({ border: h.border, destroy: h.destroy, endCard: h.endCard, forceBrandedLogo: h.forceBrandedLogo, update: h.update }));
399
- re(() => {
400
- setTimeout(() => {
401
- t(br);
402
- }, a ? 4e3 : 2e3);
403
- }, [t, a]);
404
- const v = r && r.subheader ? e("p", { className: "ul-caption", children: r.subheader }) : null, u = r && r.headline ? r.headline : "";
405
- return re(() => {
406
- g();
407
- }, [g]), e("div", { className: O(n, "ul-card--thanks", "fade-in-transition"), children: e("div", { children: e("div", { className: "ul-card--thanks-content", children: [e("div", { className: "ul-thanks-check", children: e("svg", { "aria-labelledby": "title", fill: "none", height: "99", viewBox: "0 0 81 99", width: "81", xmlns: "http://www.w3.org/2000/svg", children: [e("path", { clipRule: "evenodd", d: "M40.5 77C60.9345 77 77.5 60.4345 77.5 40C77.5 19.5655 60.9345 3 40.5 3C20.0655 3 3.5 19.5655 3.5 40C3.5 60.4345 20.0655 77 40.5 77ZM80.5 40C80.5 62.0914 62.5914 80 40.5 80C18.4086 80 0.5 62.0914 0.5 40C0.5 17.9086 18.4086 0 40.5 0C62.5914 0 80.5 17.9086 80.5 40Z", fill: d, fillRule: "evenodd" }), e("path", { clipRule: "evenodd", d: "M55.025 22.9046C55.6299 23.4705 55.6616 24.4198 55.0956 25.0247C54.8724 25.2634 54.6109 25.5285 54.3157 25.8277C52.2547 27.9168 48.5549 31.667 44.8135 39.6658C43.2818 42.9406 42.0864 45.8386 41.0823 48.2729C40.6539 49.3116 40.2603 50.2659 39.8902 51.129C39.287 52.5359 38.7248 53.7508 38.1744 54.625C37.8997 55.0613 37.5806 55.4905 37.2017 55.8245C36.8201 56.1607 36.2613 56.5 35.5457 56.5C34.6742 56.5 34.0892 55.9692 33.7774 55.6083C33.4502 55.2296 33.1752 54.7511 32.9396 54.301C32.7305 53.9013 32.5088 53.4367 32.2797 52.9565C32.2429 52.8794 32.2059 52.8019 32.1688 52.7243C31.8942 52.1499 31.5959 51.534 31.2537 50.8868C29.8886 48.305 27.8539 45.2878 24.2343 43.1382C23.522 42.7152 23.2875 41.7949 23.7105 41.0826C24.1335 40.3703 25.0539 40.1358 25.7662 40.5588C30.0556 43.1062 32.4149 46.6647 33.9058 49.4845C34.2776 50.1876 34.5973 50.8487 34.8753 51.4302C34.9147 51.5124 34.9529 51.5926 34.9902 51.6707C35.2222 52.1567 35.4164 52.5637 35.5978 52.9102C35.6151 52.9434 35.6321 52.9754 35.6485 53.0061C36.0565 52.3531 36.5341 51.3434 37.133 49.9468C37.4781 49.1418 37.8572 48.2229 38.2761 47.2074C39.2886 44.7532 40.5339 41.7347 42.0961 38.3948C46.0591 29.9221 50.0641 25.8648 52.1535 23.7482C52.4423 23.4556 52.6944 23.2002 52.9048 22.9753C53.4708 22.3703 54.42 22.3387 55.025 22.9046ZM35.1994 53.5892C35.1994 53.5892 35.2 53.5888 35.2012 53.5879C35.2 53.5889 35.1994 53.5893 35.1994 53.5892ZM36.0666 53.6682C36.0732 53.674 36.0765 53.6775 36.0765 53.6777C36.0765 53.678 36.0732 53.6751 36.0666 53.6682Z", fill: d, fillRule: "evenodd" }), e("path", { d: "M69.5 97C69.5 98.1046 56.2924 99 40 99C23.7076 99 10.5 98.1046 10.5 97C10.5 95.8954 23.7076 95 40 95C56.2924 95 69.5 95.8954 69.5 97Z", fill: "black", fillOpacity: "0.2" })] }) }), e(ae, { message: u }), v] }) }) }, s);
408
- }, jr = ({ className: n }) => {
409
- const { uploadProgress: s } = Y((a) => ({ uploadProgress: a.uploadProgress }));
410
- let d, t;
411
- Object.values(s).filter((a) => a.isSubmitted).length > 1 ? (d = "Your responses are processing", t = "Please keep this tab open until your responses are fully processed.") : (d = "Your response is processing", t = "Please keep this tab open until your response is fully processed.");
412
- const r = Math.round(Math.min(99, ...Object.values(s).filter((a) => a.isSubmitted).map((a) => a.progressPct || 0)));
413
- return e("div", { className: O(n, "ul-card--uploading", "fade-in-transition"), children: [e("div", { "aria-busy": "true", "aria-label": "Processing...", "aria-live": "polite", className: "ul-loading-spinner-container", role: "progressbar", children: e("div", { className: "ul-loading-spinner", children: [e("div", { className: "first" }), e("div", { className: "second" }), e("div", { className: "third" }), e("div", { className: "fourth" })] }) }), e(ae, { message: `${d} (${r}% complete)` }), e("p", { className: "ul-caption", children: t })] });
414
- }, tr = ar(void 0), Zr = ({ value: n, children: s }) => e(tr.Provider, { value: n, children: s }), Wr = ({ isRightLabel: n, isLeftLabel: s }) => n ? de.RIGHT : s ? de.LEFT : null, Gr = "Best", zr = "Worst", Yr = ({ className: n, labels: s, message: d, properties: t, options: r, questionId: a, type: g, next: v }) => {
415
- var w, E, M, U;
416
- const [u, h] = J(r.map((m, S) => ({ ...m, label: m.label === "" ? `Item ${S + 1}` : m.label, isRightLabel: !1, isLeftLabel: !1 }))), l = (() => {
417
- const m = or(tr);
418
- if (m === void 0) throw new Error("usePreviousResponses must be used within a PreviousResponsesProvider");
419
- return m;
420
- })(), b = { padding: "24px", display: "flex", cursor: "pointer", width: "auto" }, [c, N] = J(!1);
421
- re(() => {
422
- const m = u.findIndex((z) => z.isRightLabel), S = u.findIndex((z) => z.isLeftLabel), P = m !== -1 && S !== -1;
423
- N(P);
424
- const D = !t.required || t.required && P, A = u.map((z) => ({ id: z.id, option: z.label, selected: Wr(z) })), C = Math.floor(a), B = Object.keys(l).filter((z) => z.startsWith(C.toString())).map(Number).sort((z, T) => z - T).at(-1), K = [];
425
- if (typeof B == "number") {
426
- const z = l[B], T = JSON.parse(z);
427
- K.push(...T);
428
- }
429
- K.push(A), setTimeout(() => {
430
- v({ value: K, questionId: a, type: g }, D, P), N(!1);
431
- }, P ? 500 : 0);
432
- }, [u]);
433
- const { border: o, useMobileStyling: f, enableCspTrustedTypes: p } = Y((m) => ({ border: m.border, useMobileStyling: m.useMobileStyling, enableCspTrustedTypes: m.enableCspTrustedTypes })), k = (m, S) => () => {
434
- c || h((P) => ((D, A, C) => D.map((B) => B.id === A ? { ...B, isRightLabel: C === de.RIGHT, isLeftLabel: C === de.LEFT } : C === de.RIGHT && B.isRightLabel || C === de.LEFT && B.isLeftLabel ? { ...B, isRightLabel: !1, isLeftLabel: !1 } : B))(P, m, S));
435
- }, x = (w = t.ratingIcons) == null ? void 0 : w[0].svg, _ = (E = t.ratingIcons) == null ? void 0 : E[1].svg;
436
- return e("form", { className: O(n, "ul-card-maxdiff", "fade-in-transition"), children: [e(ae, { isRequired: t == null ? void 0 : t.required, message: d, properties: t }), e(le, { children: e("div", { className: "ul-card--maxdiff__question-inner-container", children: [e("div", { className: "ul-card-maxdiff__label", children: (s == null ? void 0 : s.left) || ((M = t == null ? void 0 : t.labels) == null ? void 0 : M.left) || Gr }), e("div", { children: " " }), e("div", { className: "ul-card-maxdiff__label", children: (s == null ? void 0 : s.right) || ((U = t == null ? void 0 : t.labels) == null ? void 0 : U.right) || zr }), u.map(({ id: m, label: S, isLeftLabel: P, isRightLabel: D }) => e(ve, { children: [e("div", { className: "ul-card-maxdiff__option-control " + (_ ? "smiley" : ""), children: _ ? e(Ve, { ariaPressed: P, className: P ? "ul-card-maxdiff__option-btn ul-card-maxdiff__option-selected good" : "ul-card-maxdiff__option-btn", enableCspTrustedTypes: p, html: _, id: `smiley-good-${m}`, onClick: k(m, de.LEFT) }) : e(fe, { allowTextEntry: !1, ariaLabel: `bestLabel-${S}`, border: o, choiceStyle: b, error: !1, id: `${m}`, isRadio: !0, isSelected: P, onUserInputChanged: k(m, de.LEFT), useMobileStyling: f }) }), e("div", { className: "ul-card-maxdiff__option-label", children: S }), e("div", { className: "ul-card-maxdiff__option-control " + (x ? "smiley" : ""), children: x ? e(Ve, { ariaPressed: D, className: D ? "ul-card-maxdiff__option-btn ul-card-maxdiff__option-selected bad" : "ul-card-maxdiff__option-btn", enableCspTrustedTypes: p, html: x, id: `smiley-bad-${m}`, onClick: k(m, de.RIGHT) }) : e(fe, { allowTextEntry: !1, ariaLabel: `worstLabel-${S}`, border: o, choiceStyle: b, error: !1, id: `${m}`, isRadio: !0, isSelected: D, onUserInputChanged: k(m, de.RIGHT), useMobileStyling: f }) })] }))] }) })] }, a);
437
- }, Ve = ({ enableCspTrustedTypes: n, ariaPressed: s, className: d, html: t, id: r, onClick: a }) => {
438
- const g = he(() => We(t, n), [n, t]);
439
- return e("span", { "aria-pressed": s, className: d, dangerouslySetInnerHTML: { __html: g }, id: r, onClick: a, tabIndex: 0, type: "button" });
440
- }, Kr = ({ className: n, labels: s, message: d, next: t, properties: r, questionId: a, type: g, onSubmitButtonClick: v, options: u, showIndividualSubmit: h = !1 }) => {
441
- const l = ne(null), b = ne(0), c = ne(0), N = ne(null), o = ne(!1), f = ne([]), [p, k] = J(() => (r == null ? void 0 : r.required) === !0), [x, _] = J(!1), [w, E] = J(() => u.map((I) => ({ ...I, rank: null }))), M = he(() => Array.from({ length: u.length }, (I, $) => $ + 1), [u.length]), { isLongFormSurvey: U, focusedQuestionId: m, setFocusedQuestionId: S, useMobileStyling: P, isPreview: D, headers: A } = Y((I) => ({ useMobileStyling: I.useMobileStyling, isLongFormSurvey: ie(I.studyType), focusedQuestionId: I.focusedQuestionId, setFocusedQuestionId: I.setFocusedQuestionId, isPreview: I.isPreview, headers: I.headers })), C = (A == null ? void 0 : A["userleap-platform"]) === "android", B = P && !D && !C, K = !B && !C, z = U && m === a, T = (I) => {
442
- I.preventDefault(), L(w), v && v(x);
443
- }, Q = (I, $) => {
444
- E((H) => {
445
- const F = parseInt($), W = H.map((G) => ({ ...G }));
446
- W.some((G) => G.rank == null) && W.forEach((G, ye) => G.rank = ye + 1);
447
- const oe = W.findIndex((G) => G.id === I);
448
- if (oe === -1) return H;
449
- const X = W[oe].rank;
450
- return F < X ? W.forEach((G) => {
451
- G.id !== I && G.rank >= F && G.rank < X && (G.rank = G.rank + 1);
452
- }) : F > X && W.forEach((G) => {
453
- G.id !== I && G.rank > X && G.rank <= F && (G.rank = G.rank - 1);
454
- }), W[oe].rank = F, W.sort((G, ye) => G.rank - ye.rank), j(W), W;
455
- });
456
- }, V = (I, $) => {
457
- for (let H = 0; H < f.current.length; H++) {
458
- const F = f.current[H];
459
- if (!F || F === N.current) continue;
460
- const W = F.getBoundingClientRect();
461
- if (I >= W.left && I <= W.right && $ >= W.top && $ <= W.bottom) return { element: F, index: H };
462
- }
463
- return null;
464
- }, i = (I) => ($) => {
465
- if (!B) return;
466
- $.preventDefault(), $.stopPropagation(), o.current = !0, l.current = I;
467
- const H = $.touches[0];
468
- b.current = H.clientY, c.current = H.clientY;
469
- const F = $.currentTarget.closest(".ul-card-rank__option");
470
- F && (N.current = F, F.classList.add("is-dragging"));
471
- }, y = (I) => {
472
- if (!B || !o.current || l.current === null) return;
473
- I.preventDefault(), I.stopPropagation();
474
- const $ = I.touches[0];
475
- c.current = $.clientY;
476
- const H = c.current - b.current;
477
- N.current && (N.current.style.transform = `translateY(${H}px)`, N.current.style.zIndex = "1000"), f.current.forEach((W) => {
478
- W && W !== N.current && W.classList.remove("is-drop-target");
479
- });
480
- const F = V($.clientX, $.clientY);
481
- F && F.element.classList.add("is-drop-target");
482
- }, q = (I) => {
483
- if (!B || !o.current || l.current === null) return;
484
- I.preventDefault(), I.stopPropagation();
485
- const $ = I.changedTouches[0], H = V($.clientX, $.clientY);
486
- N.current && (N.current.style.transform = "", N.current.style.zIndex = "", N.current.classList.remove("is-dragging")), f.current.forEach((F) => {
487
- F && F.classList.remove("is-drop-target");
488
- }), H && H.index !== l.current && R(l.current, H.index), l.current = null, N.current = null, o.current = !1;
489
- }, R = (I, $) => {
490
- E((H) => {
491
- const F = H.map((oe) => ({ ...oe })), [W] = F.splice(I, 1);
492
- return F.splice($, 0, W), F.forEach((oe, X) => {
493
- oe.rank = X + 1;
494
- }), j(F), F;
495
- });
496
- }, L = (I) => {
497
- const $ = {};
498
- I.reduce((H, F) => (H[F.id] = F.rank, H), $), t({ value: $, questionId: a, type: g }, !0);
499
- }, j = (I) => {
500
- k(!1), _(!0), U && L(I);
501
- }, { left: Z, right: se } = s, ce = u.length, xe = (I) => {
502
- I.preventDefault(), I.currentTarget.classList.add("is-drop-target");
503
- }, Se = (I) => {
504
- I.currentTarget.classList.remove("is-drop-target");
505
- }, ge = (I) => {
506
- l.current = null, I.currentTarget.classList.remove("is-dragging");
507
- };
508
- return e("form", { className: O(n, "ul-card-rank", "fade-in-transition", U && !z && "ul-card--unfocused"), onClick: U && !z ? () => {
509
- S(a);
510
- } : void 0, onSubmit: T, children: [e(ae, { isRequired: r == null ? void 0 : r.required, message: d, properties: r }), e(me, { properties: r, children: e(ve, C ? { children: [e(le, { children: [e("div", { className: "ul-card--rank__question-inner-container", children: [e("div", { className: "ul-card-rank__labels", children: e("span", { children: ["1 - ", Z] }) }), e("ol", { className: "ul-card-rank__list", children: w.map(({ id: I, label: $, rank: H }) => e("li", { className: "ul-card-rank__option", children: [e("select", { "aria-label": `Rank for ${$}`, className: O("ul-card-rank__select", H == null && "ul-card-rank__select--placeholder"), name: `rank[${I}]`, onChange: (F) => Q(I, F.currentTarget.value), value: H ?? "", children: [H == null && e("option", { className: "ul-card-rank__select-option", disabled: !0, value: "", children: "-" }), M.map((F) => e("option", { className: "ul-card-rank__select-option", value: F, children: F }, `${F}-${a}`))] }), e("span", { children: $ })] }, I)) }), e("div", { className: "ul-card-rank__labels", children: e("span", { children: [ce, " - ", se] }) })] }), h && e(Te, { handleSubmit: T, isSubmitDisabled: p })] }), !U && e(pe, { children: e("div", { className: "ul-card__button-wrapper", children: e(ee, { disabled: p, children: be(r) }) }) })] } : { children: [e(le, { children: [e("div", { className: "ul-card--rank__question-inner-container", children: [e("div", { className: "ul-card-rank__labels", children: e("span", { children: ["1 - ", Z] }) }), e("ol", { className: "ul-card-rank__list", onDragOver: C ? void 0 : (I) => {
511
- I.preventDefault(), I.dataTransfer && (I.dataTransfer.dropEffect = "move");
512
- }, children: w.map(({ id: I, label: $, rank: H }, F) => {
513
- return e("li", { className: "ul-card-rank__option", draggable: !!K || void 0, onDragEnd: K ? ge : void 0, onDragEnter: K ? xe : void 0, onDragLeave: K ? Se : void 0, onDragStart: K ? (oe = F, (X) => {
514
- l.current = oe, X.dataTransfer && (X.dataTransfer.effectAllowed = "move", X.dataTransfer.setData("text/plain", String(oe)), X.currentTarget.classList.add("is-dragging"));
515
- }) : void 0, onDrop: K ? (W = F, (X) => {
516
- var ye, Ae;
517
- X.preventDefault(), X.currentTarget.classList.remove("is-drop-target");
518
- const G = l.current;
519
- l.current = null, (Ae = (ye = X.currentTarget.closest(".ul-card-rank__list")) == null ? void 0 : ye.querySelector(".is-dragging")) == null || Ae.classList.remove("is-dragging"), G != null && G !== W && R(G, W);
520
- }) : void 0, ref: (X) => f.current[F] = X, children: [e("select", { "aria-label": `Rank for ${$}`, className: O("ul-card-rank__select", H == null && "ul-card-rank__select--placeholder"), name: `rank[${I}]`, onChange: (X) => Q(I, X.currentTarget.value), value: H ?? "", children: [H == null && e("option", { className: "ul-card-rank__select-option", disabled: !0, value: "", children: "-" }), M.map((X) => e("option", { className: "ul-card-rank__select-option", value: X, children: X }, `${X}-${a}`))] }), e("span", { children: $ }), !C && e("button", { "aria-label": `Drag ${$} to reorder`, className: "ul-card-rank__drag-btn", onTouchEnd: B ? q : void 0, onTouchMove: B ? y : void 0, onTouchStart: B ? i(F) : void 0, title: "Drag to reorder", type: "button", children: e("svg", { fill: "none", height: "17", viewBox: "0 0 16 17", width: "16", xmlns: "http://www.w3.org/2000/svg", children: e("path", { d: "M5.75 11.625C6.37132 11.625 6.875 12.1287 6.875 12.75C6.875 13.3713 6.37132 13.875 5.75 13.875C5.12868 13.875 4.625 13.3713 4.625 12.75C4.625 12.1287 5.12868 11.625 5.75 11.625ZM10.25 11.625C10.8713 11.625 11.375 12.1287 11.375 12.75C11.375 13.3713 10.8713 13.875 10.25 13.875C9.62868 13.875 9.125 13.3713 9.125 12.75C9.125 12.1287 9.62868 11.625 10.25 11.625ZM5.75 7.375C6.37132 7.375 6.875 7.87868 6.875 8.5C6.875 9.12132 6.37132 9.625 5.75 9.625C5.12868 9.625 4.625 9.12132 4.625 8.5C4.625 7.87868 5.12868 7.375 5.75 7.375ZM10.25 7.375C10.8713 7.375 11.375 7.87868 11.375 8.5C11.375 9.12132 10.8713 9.625 10.25 9.625C9.62868 9.625 9.125 9.12132 9.125 8.5C9.125 7.87868 9.62868 7.375 10.25 7.375ZM5.75 3.125C6.37132 3.125 6.875 3.62868 6.875 4.25C6.875 4.87132 6.37132 5.375 5.75 5.375C5.12868 5.375 4.625 4.87132 4.625 4.25C4.625 3.62868 5.12868 3.125 5.75 3.125ZM10.25 3.125C10.8713 3.125 11.375 3.62868 11.375 4.25C11.375 4.87132 10.8713 5.375 10.25 5.375C9.62868 5.375 9.125 4.87132 9.125 4.25C9.125 3.62868 9.62868 3.125 10.25 3.125Z", fill: "currentColor" }) }) })] }, I);
521
- var W, oe;
522
- }) }), e("div", { className: "ul-card-rank__labels", children: e("span", { children: [ce, " - ", se] }) })] }), h && e(Te, { handleSubmit: T, isSubmitDisabled: p })] }), !U && e(pe, { children: e("div", { className: "ul-card__button-wrapper", children: e(ee, { disabled: p, children: be(r) }) }) })] }) })] }, a);
523
- }, Xr = /* @__PURE__ */ new Set(["aidynamicfollowup", "aidynamicstandalone", "open", "matrix", "multipleselect", "multiplechoice", "rankorder"]), He = ({ cardInstance: n, moveToNextQuestion: s, showIndividualSubmit: d, submitQuestion: t, updateCardValues: r, allResponsesArray: a }) => {
524
- const { isLongFormSurvey: g, createDynamicFollowupQuestion: v, cards: u, surveyVisitorAttributes: h } = Y((x) => ({ isLongFormSurvey: ie(x.studyType), createDynamicFollowupQuestion: x.createDynamicFollowupQuestion, cards: x.cards, surveyVisitorAttributes: x.surveyVisitorAttributes }));
525
- if (!n) return null;
526
- const { name: l, type: b, props: c, childId: N } = n, o = d && Xr.has(b), f = c == null ? void 0 : c.displayLogic;
527
- if (f != null && f.length && !Ze({ displayLogic: f, allResponses: a, cards: u, surveyVisitorAttributes: h ?? {} })) return null;
528
- const p = { className: "ul-card", next: (x, _, w = !0) => t(x, _ && w), questionId: l, type: b, showIndividualSubmit: d, ...o ? { next: (x, _) => {
529
- r(x.questionId, x, _ ?? !0);
530
- }, onSubmitButtonClick: (x = !1) => {
531
- N ? x ? (s(l), v({ parentQuestionId: l })) : s(N) : s(l);
532
- } } : {} }, k = (() => {
533
- switch (b) {
534
- case "consentlegal":
535
- return e(Sr, { ...p, ...c });
536
- case "likert":
537
- return e(Tr, { ...p, ...c });
538
- case "matrix":
539
- return e(wr, { ...p, ...c });
540
- case "maxdiff":
541
- return e(Yr, { ...p, ...c });
542
- case "multiplechoice":
543
- return e(qr, { ...p, ...c });
544
- case "multipleselect":
545
- return e(Lr, { ...p, ...c });
546
- case "nps":
547
- return e(Pr, { ...p, ...c });
548
- case "open":
549
- case "aidynamicfollowup":
550
- case "aidynamicstandalone":
551
- return e(Mr, { ...p, type: n.type, ...c });
552
- case "rankorder":
553
- return e(Kr, { ...p, ...c });
554
- case "recordedtask":
555
- return e(Or, { ...p, ...c });
556
- case "texturlprompt":
557
- return e(Vr, { ...p, ...c });
558
- case "thanks":
559
- return e(Hr, { ...p, ...c });
560
- case "uploading":
561
- return e(jr, { ...p, ...c });
562
- default:
563
- return null;
564
- }
565
- })();
566
- return k ? g ? e("div", { className: "ul-card-scroll-wrapper", children: k }, l) : k : null;
567
- }, Jr = ({ isSubmitDisabled: n = !1, onSubmit: s, buttonText: d }) => {
568
- var N;
569
- const { cards: t, forceBrandedLogo: r, index: a, marketingUrl: g, showSurveyBrand: v, slugName: u, surveyId: h, useMobileStyling: l } = Y((o) => ({ cards: o.cards, forceBrandedLogo: o.forceBrandedLogo, index: o.index, marketingUrl: o.marketingUrl, showSurveyBrand: o.showSurveyBrand, slugName: o.slugName, surveyId: o.surveyId, useMobileStyling: o.useMobileStyling })), b = ((N = t[a]) == null ? void 0 : N.type) === "thanks", c = ur({ marketingUrl: g, slugName: u, surveyId: h, forceBrandedLogo: r });
570
- return e("footer", { className: O("long-form-question-footer-container", l && "long-form-question-footer-container--mobile", b && "long-form-question-footer-container-center"), children: [b && r ? e(lr, { marketingUrlLink: c }) : e("div", { className: "long-form-question-footer-container-logo", children: v ? e(cr, { forceBrandedLogo: r, marketingUrlLink: c }) : null }), !b && e("div", { className: O("ul-card__button-wrapper", "ul-card-vertical__button-wrapper", "long-form-question-footer-container-actions"), children: e(ee, { className: O("long-form-button", n && "sprig-button-disabled"), disabled: n, onClick: s, children: e("span", { className: "long-form-button-text-container", children: d ?? e(dr, { stroke: "white" }) }) }) })] });
571
- }, nt = ({ cards: n, next: s, previousResponses: d }) => {
572
- var V;
573
- const t = ne(null), [r, a] = J({}), [g, v] = J({}), { isLongFormSurvey: u, focusedQuestionId: h, setFocusedQuestionId: l, createDynamicFollowupQuestion: b, allResponses: c, cardIndexByName: N, surveyVisitorAttributes: o, cards: f, createDynamicStandaloneQuestion: p } = Y((i) => ({ isLongFormSurvey: ie(i.studyType), focusedQuestionId: i.focusedQuestionId, setFocusedQuestionId: i.setFocusedQuestionId, createDynamicFollowupQuestion: i.createDynamicFollowupQuestion, allResponses: i.allResponses, cardIndexByName: i.cardIndexByName, surveyVisitorAttributes: i.surveyVisitorAttributes, cards: i.cards, createDynamicStandaloneQuestion: i.createDynamicStandaloneQuestion })), k = he(() => ({ ...d, ...pr(n.map((i) => {
574
- var y, q;
575
- return { ...i, value: ((y = r[i.name]) == null ? void 0 : y.value) ?? null, secondaryValue: ((q = r[i.name]) == null ? void 0 : q.secondaryValue) ?? null };
576
- })) }), [d, r, n]);
577
- xr(k);
578
- const x = mr(n, k), _ = he(() => gr({ storeAllResponses: c, cards: n, cardValues: r, cardIndexByName: N }), [c, n, r, N]), w = he(() => {
579
- const i = /* @__PURE__ */ new Set();
580
- return n.forEach((y) => {
581
- var R;
582
- const q = (R = y.props) == null ? void 0 : R.displayLogic;
583
- if (!q || q.length === 0) return void i.add(y.name);
584
- Ze({ displayLogic: q, allResponses: _, cards: f, surveyVisitorAttributes: o ?? {} }) && i.add(y.name);
585
- }), i;
586
- }, [n, _, o, f]);
587
- re(() => {
588
- n.some((i) => {
589
- if (i.type === "aidynamicstandalone" && i.props && w.has(i.name)) {
590
- if (i.props.loading === Me.inFlight) return !0;
591
- if (i.props.loading === void 0) return p({ questionId: i.name }), !0;
592
- }
593
- return !1;
594
- });
595
- }, [n, p, w]);
596
- const E = ne(null);
597
- re(() => {
598
- const i = w, y = E.current;
599
- if (y !== null) for (const q of y) i.has(q) || (a((R) => {
600
- const L = { ...R };
601
- return delete L[q], L;
602
- }), v((R) => {
603
- const L = { ...R };
604
- return delete L[q], L;
605
- }));
606
- E.current = new Set(i);
607
- }, [w]);
608
- const M = ne(null), U = ne(!1), m = ne(null), S = Ce((i) => {
609
- var L, j;
610
- U.current = !0;
611
- const y = n.findIndex((Z) => Z.name === i);
612
- if (!u || i === null || y === -1) return void (U.current = !1);
613
- const q = (L = M.current) == null ? void 0 : L.querySelectorAll(".ul-card-scroll-wrapper")[y], R = (j = M.current) == null ? void 0 : j.closest(".ul-card-main-content");
614
- if (q && R) {
615
- if (q && R) {
616
- const Z = q.getBoundingClientRect(), se = R.getBoundingClientRect(), ce = Z.top - se.top + R.scrollTop, xe = ce + Z.height / 2, Se = window.innerHeight - 157;
617
- let ge;
618
- Z.height >= Se ? ge = ce : ge = xe - R.clientHeight / 2;
619
- const I = R.clientHeight, $ = R.scrollHeight - I, H = Math.max(0, Math.min(ge, $));
620
- R.scrollTo({ top: H, behavior: "smooth" }), setTimeout(() => {
621
- U.current = !1;
622
- }, 500);
623
- }
624
- } else U.current = !1;
625
- }, [u, n]);
626
- function P(i, y) {
627
- return i.filter((q) => w.has(q.name)).map((q) => {
628
- const R = y[q.name], L = x.find((j) => j.name === q.name);
629
- return { ...R, questionText: L ? $e(L) : void 0 };
630
- });
631
- }
632
- re(() => {
633
- h !== null && n.findIndex((i) => i.name === h) !== -1 || l(n[0].name);
634
- }, [n, h, l]);
635
- const D = (i) => {
636
- if (!u) return;
637
- let y = n.findIndex((q) => q.name === i) + 1;
638
- for (; y < n.length && !w.has(n[y].name); ) y++;
639
- y < n.length ? l(n[y].name) : l(i);
640
- };
641
- re(() => {
642
- u && h !== null && (m.current !== h ? S(h) : m.current = null);
643
- }, [h, u, S]);
644
- const A = Ce(() => {
645
- var se, ce;
646
- if (U.current) return;
647
- const i = (se = M.current) == null ? void 0 : se.closest(".ul-card-main-content");
648
- if (!i) return;
649
- const y = (ce = M.current) == null ? void 0 : ce.querySelectorAll(".ul-card-scroll-wrapper");
650
- if (!y || y.length === 0) return;
651
- const q = i.getBoundingClientRect(), R = q.top + q.height / 2;
652
- let L = 0, j = 1 / 0;
653
- y.forEach((xe, Se) => {
654
- const ge = xe.getBoundingClientRect(), I = ge.top + ge.height / 2, $ = Math.abs(R - I);
655
- $ < j && (j = $, L = Se);
656
- });
657
- const Z = n[L];
658
- m.current = Z.name, l(Z.name);
659
- }, [n, l]);
660
- re(() => {
661
- var y;
662
- if (!u) return;
663
- const i = ((y = M.current) == null ? void 0 : y.closest(".ul-card__container")) || null;
664
- return i && i.addEventListener("scroll", A, { passive: !0 }), () => {
665
- i && i.removeEventListener("scroll", A);
666
- };
667
- }, [A, u]);
668
- const C = he(() => n.every((i) => {
669
- var y;
670
- return !w.has(i.name) || !(!(i != null && i.props) || !("properties" in i.props) || ((y = i.props.properties) == null ? void 0 : y.required) !== !1) || g[i.name];
671
- }), [g, n, w]), B = async (i, y, q) => {
672
- return v((L) => ({ ...L, [i]: q })), await (R = (L) => ({ ...L, [i]: y }), new Promise((L) => {
673
- a((j) => {
674
- const Z = R(j);
675
- return L(Z), Z;
676
- });
677
- }));
678
- var R;
679
- };
680
- re(() => {
681
- var R;
682
- if (!u) return;
683
- const i = t.current, y = (R = n == null ? void 0 : n[0]) == null ? void 0 : R.groupId;
684
- t.current = y;
685
- const q = {};
686
- if (n.forEach((L) => {
687
- var j, Z;
688
- hr(L) && (L.props.properties.required || (q[L.name] = { value: ((j = r[L.name]) == null ? void 0 : j.value) ?? null, secondaryValue: ((Z = r[L.name]) == null ? void 0 : Z.secondaryValue) ?? null, questionId: L.name, type: L.type }));
689
- }), i == null || i !== y) a(q), v({});
690
- else {
691
- a((j) => ({ ...j, ...q }));
692
- const L = n.reduce((j, Z) => {
693
- var se;
694
- return Z.type === "aidynamicfollowup" && ((se = Z.props) == null ? void 0 : se.loading) === null && (j[Z.name] = !0), j;
695
- }, {});
696
- v((j) => ({ ...j, ...L }));
697
- }
698
- }, [n, u]);
699
- const K = async (i, y) => {
700
- const q = x.find((R) => R.name === i.questionId);
701
- if (u) {
702
- const R = await B(i.questionId, i, y), L = z(i.type), j = T(i.type);
703
- if (L && (Le({ displayCard: q, response: i, createDynamicFollowupQuestion: b }), D(i.questionId)), j && y) {
704
- const Z = P(n, R);
705
- s(Z);
706
- }
707
- } else {
708
- const R = { ...i, questionText: q ? $e(q) : void 0 };
709
- Le({ displayCard: q, response: i, createDynamicFollowupQuestion: b }), s([R]);
710
- }
711
- }, z = (i) => (/* @__PURE__ */ new Set(["nps", "likert", "multiplechoice"])).has(i), T = (i) => (/* @__PURE__ */ new Set(["videovoice", "consentlegal", "texturlprompt", "maxdiff"])).has(i), Q = ((V = n[0]) == null ? void 0 : V.type) === "thanks";
712
- return u ? e("div", { className: "ul-card-list-container--longform", "data-testid": "ui-container", ref: M, children: [e(Zr, { value: d, children: x.map((i, y) => e(He, { allResponsesArray: _, cardInstance: i, moveToNextQuestion: D, showIndividualSubmit: n.length > 1 && y < n.length - 1, submitQuestion: K, updateCardValues: B }, (i == null ? void 0 : i.name) || y)) }), !Q && e(Jr, { isSubmitDisabled: !C, onSubmit: function() {
713
- const i = P(n, r);
714
- if ((x == null ? void 0 : x.length) === 1 && (i == null ? void 0 : i.length) === 1) {
715
- const y = x[0], q = i[0];
716
- Le({ displayCard: y, response: q, createDynamicFollowupQuestion: b });
717
- }
718
- s(i);
719
- } })] }) : e(ve, { children: [e("div", { "data-testid": "ui-container", style: { display: "none" } }), x.map((i, y) => e(He, { allResponsesArray: _, cardInstance: i, moveToNextQuestion: D, showIndividualSubmit: !1, submitQuestion: K, updateCardValues: B }, (i == null ? void 0 : i.name) || y))] });
720
- };
721
- export {
722
- nt as PageCard
723
- };