@sprig-technologies/sprig-bundled 2.43.0 → 2.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,717 @@
1
+ import { u as Y, h as J, a as e, c as V, g as Ve, b as te, F as ge, d as ve, e as he, _ as ne, T as Te, A as rr, p as se, M as ke, D as we, f as tr, P as nr, i as sr, q as ir, j as de, s as He, k as ar, S as lr, l as or, m as dr, n as Qe, o as cr, r as ur, t as pr, v as Be } from "./view-DcerBHpf.js";
2
+ import { i as ae, E as Ne, h as Me, j as Ue, A as mr } from "./index-BUTuSSuP.js";
3
+ import { H as le, Q as oe, a as xe, M as me, b as pe, O as fe, B as re, L as Se, S as gr, u as hr, g as br, c as vr } from "./getAttributedUrl-8t2IIhOk.js";
4
+ const yr = ({ className: t, message: s, next: o, properties: n, questionId: r, type: l }) => {
5
+ const { useMobileStyling: m, border: b, isLongFormSurvey: u, focusedQuestionId: g } = Y((y) => ({ useMobileStyling: y.useMobileStyling, border: y.border, isLongFormSurvey: ae(y.studyType), focusedQuestionId: y.focusedQuestionId })), [d, f] = J(!1), [i, k] = J(""), [c, v] = J(!1), p = u && g === r, w = n == null ? void 0 : n.collectName, h = (n == null ? void 0 : n.nameLabelText) || "Full Name", _ = (n == null ? void 0 : n.consentText) || "I agree to the stated conditions", M = (n == null ? void 0 : n.submitButtonText) || "Submit", $ = !!i.trim(), D = d && (!w || $), R = (y, C = !1) => {
6
+ y.preventDefault(), y.stopPropagation();
7
+ let F = null;
8
+ if (!C) {
9
+ if (!D) return void v(!0);
10
+ F = { submitted: !0 }, w && (F.name = i);
11
+ }
12
+ o({ value: F, questionId: r, type: l }, D);
13
+ };
14
+ return e("div", { className: V(t, u && !p && "ul-card--unfocused", "ul-card__consent-legal", "fade-in-transition"), children: [e(le, { isRequired: u && (n == null ? void 0 : n.required), message: s, properties: { questionHtml: n.questionHtml } }), n != null && n.richTextBody ? e(oe, { children: e(xe, { className: "ul-rich-text-body", html: n.richTextBody, id: "ul-card__consent-legal-body-container" }) }) : null, e(me, { embeddedType: "pdf", properties: n, children: e(pe, { children: [e("div", { className: "sprig-stretch", children: [e(fe, { allowTextEntry: !1, border: b, error: c && !d, id: "consent", isRadio: !1, isSelected: d, label: _, onUserInputChanged: ({ selected: y }) => {
15
+ y !== d && f(!d);
16
+ }, useMobileStyling: m }), w && e("input", { "aria-label": h, "aria-placeholder": h, className: V(te("ul-consent-legal__name-input", m)), "data-gramm": "false", maxLength: 250, name: "name", onBlur: (y) => {
17
+ y.currentTarget.style.borderColor = c && !$ ? Ne : Me;
18
+ }, onFocus: (y) => {
19
+ y.currentTarget.style.borderColor = c && !$ ? Ne : b;
20
+ }, onInput: (y) => {
21
+ y.preventDefault(), y.stopPropagation(), k(y.currentTarget.value);
22
+ }, placeholder: h, style: c && !$ ? { borderColor: Ne } : {}, tabIndex: 0, value: i })] }), e("div", { className: "ul-card__button-wrapper ul-card-vertical__button-wrapper", children: [e(re, { className: D ? "" : "sprig-button-disabled", onClick: R, children: M }), n.required === !1 && !u && e("button", { className: "ul-card-skip__button", onClick: (y) => R(y, !0), children: Ve(n) })] })] }) })] }, r);
23
+ }, fr = ({ activeValue: t, border: s, icon: o, isPressed: n, onSubmit: r, range: l, scaleLabelType: m, selectedValue: b, setSelectedValue: u, setActiveValue: g, setIsPressed: d, useMobileStyling: f, value: i, viewDocument: k }) => {
24
+ const { isLongFormSurvey: c, enableCspTrustedTypes: v } = Y((C) => ({ isLongFormSurvey: ae(C.studyType), enableCspTrustedTypes: C.enableCspTrustedTypes })), p = `option-${i}`, w = m === "number", h = m === "star", _ = m === "smiley", M = w && i === t || i === b, [$, D] = (() => {
25
+ const C = h && b !== null && i <= b;
26
+ return h && i <= t || _ && i === t || C || i === t || i === b ? [s, n || C || i === b ? 1 : 0.3] : ["", 1];
27
+ })(), R = ge(() => {
28
+ const C = { borderColor: M ? $ : "", fillOpacity: M ? "" : D, zIndex: M ? 3 : "auto", color: b === i ? "#fff" : "" };
29
+ return w ? { ...C, backgroundColor: b === i ? $ : "" } : { ...C, color: h || _ || b === i ? $ : "" };
30
+ }, [M, $, D, b, i, w, h, _]), y = ge(() => Ue((({ icon: C, scaleLabelType: F, value: L, selectedValue: Q }) => {
31
+ if (F === "smiley" && L === Q) {
32
+ let I = 0;
33
+ return C.replace(/black/g, () => ++I == 1 ? "black" : "white");
34
+ }
35
+ return C;
36
+ })({ icon: o, scaleLabelType: m, value: i, selectedValue: b }), v), [v, o, m, b, i]);
37
+ return e("button", { "aria-label": w ? void 0 : String(i), className: (() => {
38
+ switch (m) {
39
+ case "star":
40
+ return V(te("likert-star", f), te(`likert-star-${i}`, f));
41
+ case "smiley":
42
+ return V(te("likert-smiley", f), te(`likert-smiley-${i}`, f));
43
+ default:
44
+ return i === l ? V(te("likert-number", f), te(`likert-number-${i}`, f), te("likert-last-option", f)) : V(te("likert-number", f), te(`likert-number-${i}`, f));
45
+ }
46
+ })(), dangerouslySetInnerHTML: { __html: y }, id: p, onClick: (C) => {
47
+ c && (C.preventDefault(), C.stopPropagation(), u(i)), r();
48
+ }, onKeyDown: (C) => {
49
+ var Q, I;
50
+ const F = k.querySelectorAll(`.likert-${m ?? "number"}`), L = i - 1;
51
+ C.key === "ArrowRight" ? (Q = F[L + 1]) == null || Q.focus() : C.key === "ArrowLeft" ? (I = F[L - 1]) == null || I.focus() : C.key !== "Enter" && C.key !== " " || (c && (C.preventDefault(), C.stopPropagation(), u(i)), r());
52
+ }, onPointerDown: () => d(!0), onPointerEnter: () => g(i), onPointerLeave: () => {
53
+ g(-1), d(!1);
54
+ }, style: R, tabIndex: 0 });
55
+ }, Sr = ({ className: t, labels: s, message: o, next: n, properties: r, questionId: l, type: m }) => {
56
+ const { border: b, useMobileStyling: u, viewDocument: g, isLongFormSurvey: d, focusedQuestionId: f } = Y((L) => ({ border: L.border, useMobileStyling: L.useMobileStyling, viewDocument: L.viewDocument, isLongFormSurvey: ae(L.studyType), focusedQuestionId: L.focusedQuestionId })), [i, k] = J(-1), [c, v] = J(!1), [p, w] = J(null), h = d && f === l, _ = s && s.left, M = s && s.right;
57
+ let $;
58
+ const { range: D, scaleLabelType: R, ratingIcons: y } = r;
59
+ D && ($ = Number(D));
60
+ const C = $ || 5, F = (L) => {
61
+ var Q, I;
62
+ switch (R) {
63
+ case "star":
64
+ return (Q = y[0]) == null ? void 0 : Q.svg;
65
+ case "smiley":
66
+ return (I = y[L]) == null ? void 0 : I.svg;
67
+ default:
68
+ return String(L + 1);
69
+ }
70
+ };
71
+ return e("form", { className: V(t, "ul-card--likert", "fade-in-transition", d && !h && "ul-card--unfocused"), children: [e(le, { isRequired: d && (r == null ? void 0 : r.required), message: o, properties: r }), e(me, { properties: r, children: e(ve, { children: [e(oe, { children: [e("div", { "aria-label": `Rating (1 - ${C})`, className: "ul-card--likert__numbers", role: "radiogroup", children: [...Array(C)].map((L, Q) => {
72
+ const I = Q + 1;
73
+ return e(fr, { activeValue: i, border: b, icon: F(Q), isPressed: c, onSubmit: () => n({ value: I, questionId: l, type: m }, !0), range: C, scaleLabelType: R, selectedValue: p, setActiveValue: k, setIsPressed: v, setSelectedValue: w, useMobileStyling: u, value: I, viewDocument: g }, Q);
74
+ }) }), e("div", { className: "ul-card--likert__labels", children: [e("span", { children: _ }), e("span", { children: M })] })] }), !r.required && !d && e(pe, { children: e("div", { className: "ul-vertical-centered-container", children: e(re, { onClick: (L) => {
75
+ L.preventDefault(), L.stopPropagation(), n({ value: null, questionId: l, type: m }, !0);
76
+ }, children: he(r) }) }) })] }) })] }, l);
77
+ }, je = (t) => t && (t.scrollHeight > t.offsetHeight ? t : je(t.parentElement)), xr = (t) => {
78
+ if (!t || !((o) => o instanceof HTMLElement)(t)) return 0;
79
+ const s = getComputedStyle(t);
80
+ return parseFloat(s.marginTop) + parseFloat(s.marginBottom) + (parseFloat(s.borderTopWidth) + parseFloat(s.borderBottomWidth));
81
+ }, kr = ({ columns: t, onSelect: s, options: o, selectedOptions: n }) => {
82
+ const r = ne([]), { border: l, useMobileStyling: m } = Y((i) => ({ border: i.border, useMobileStyling: i.useMobileStyling })), b = o.findIndex((i) => n[i.id] === null), [u, g] = J(b), d = Te((i, k) => {
83
+ s(i, k);
84
+ const c = u + 1, v = o[c];
85
+ if (v && n[v.id] === null) {
86
+ g(c);
87
+ const p = r.current[u];
88
+ if (p != null && p.firstElementChild) {
89
+ const w = je(p), h = p.firstElementChild, _ = xr(p) + h.clientHeight;
90
+ w == null || w.scrollTo(0, p.offsetTop + _);
91
+ }
92
+ }
93
+ }, [s, o, n, u]), f = Te((i, k) => {
94
+ const c = u === i;
95
+ return e(rr, { animate: !0, header: k.label, isOpen: c, onClick: () => {
96
+ var v;
97
+ return g(c && !((v = window.UserLeap) != null && v.isMobileSDK) ? -1 : i);
98
+ }, ref: (v) => {
99
+ v && (r.current[i] = v);
100
+ }, showHeaderCheck: n[k.id] !== null, children: e("div", { style: { paddingTop: "12px" }, children: t.map((v) => e(fe, { allowTextEntry: !1, ariaLabel: `${k.label}-${v.label}`, border: l, error: !1, id: `${k.id}-${v.value}`, isRadio: !0, isSelected: n[k.id] === v.value, label: v.label, onUserInputChanged: () => d(k.id, v.value), useMobileStyling: m }, v.label)) }) }, k.id);
101
+ }, [l, t, u, d, n, m]);
102
+ return e("div", { children: o.map((i, k) => f(k, i)) });
103
+ }, Tr = ({ columns: t, onSelect: s, options: o, selectedOptions: n }) => {
104
+ const { border: r, useMobileStyling: l, isLongFormSurvey: m } = Y((c) => ({ border: c.border, useMobileStyling: c.useMobileStyling, isLongFormSurvey: ae(c.studyType) })), b = o.length, u = t.length, g = ne(null), [d, f] = J(!1), [i, k] = J(!1);
105
+ return se(() => {
106
+ const c = g.current, v = new ResizeObserver((p) => {
107
+ window.requestAnimationFrame(() => {
108
+ c && (f(Math.round(p[0].contentRect.width) < c.scrollWidth), k(Math.round(p[0].contentRect.width) < c.scrollWidth));
109
+ });
110
+ });
111
+ return c && v.observe(c), () => {
112
+ c && v.unobserve(c);
113
+ };
114
+ }, []), e("div", { className: "ul-card--matrix_question_container", children: [e("div", { className: V("ul-card--matrix_container", d && "ul-matrix-scroll-gradient"), onScroll: () => {
115
+ (() => {
116
+ const c = g.current;
117
+ c && f(c.clientWidth + Math.abs(c.scrollLeft) < c.scrollWidth);
118
+ })();
119
+ }, ref: g, children: e("div", { className: V(m && "ul-card--matrix_grid_longform", "ul-card--matrix_grid"), style: `--numColumns: ${u}; --numRows: ${b + 1};`, children: [e("div", {}), " ", t.map((c) => e("div", { className: "ul-matrix-column-label", children: c.label }, c.label)), o.map((c) => e(ve, { children: [e("div", { "aria-label": c.label, className: "ul-matrix-row-label", children: c.label }, c.label), e("div", { className: "ul-matrix-row-options", role: "radiogroup", children: t.map((v, p) => e("div", { className: V("ul-matrix-option-wrapper", p === u - 1 && "ul-matrix-last-option"), children: e(fe, { allowTextEntry: !1, ariaLabel: `${c.label}-${v.label}`, border: r, choiceStyle: { background: "transparent", border: "none", marginBottom: "0", padding: "0" }, error: !1, id: `${c.id}-${v.value}`, isRadio: !0, isSelected: n[c.id] === v.value, onUserInputChanged: () => s(c.id, v.value), useMobileStyling: l }) }, v.value)) })] }))] }) }), (d || i) && e("button", { className: i && !d ? "ul-matrix-scroll-arrow left" : "ul-matrix-scroll-arrow", onClick: i && !d ? (c) => {
120
+ c.preventDefault();
121
+ const v = g.current;
122
+ if (v) {
123
+ const p = getComputedStyle(v).direction === "rtl";
124
+ v.scrollTo({ left: p ? v.scrollWidth - v.clientWidth : 0, behavior: "smooth" });
125
+ }
126
+ } : (c) => {
127
+ c.preventDefault();
128
+ const v = g.current;
129
+ if (v) {
130
+ const p = getComputedStyle(v).direction === "rtl";
131
+ v.scrollTo({ left: p ? v.clientWidth - v.scrollWidth : v.scrollWidth, behavior: "smooth" });
132
+ }
133
+ }, children: e(i && !d ? Ir : Cr, {}) })] });
134
+ }, Ir = () => 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" }) }), Cr = () => 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" }) }), _r = ({ className: t, message: s, next: o, options: n, properties: r, questionId: l, type: m, showIndividualSubmit: b = !1, onSubmitButtonClick: u }) => {
135
+ const { useMobileStyling: g, isLongFormSurvey: d, focusedQuestionId: f, setFocusedQuestionId: i } = Y((R) => ({ useMobileStyling: R.useMobileStyling, isLongFormSurvey: ae(R.studyType), focusedQuestionId: R.focusedQuestionId, setFocusedQuestionId: R.setFocusedQuestionId })), k = r.matrixColumn, c = r.required, v = d && f === l, p = (R) => {
136
+ R.preventDefault(), R.stopPropagation(), o({ value: h, questionId: l, type: m }, !0), u && u();
137
+ }, w = n.reduce((R, y) => (R[y.id] = null, R), {}), [h, _] = J(w), M = (R) => c && Object.values(R).every((y) => y == null), $ = (R, y) => {
138
+ d && o({ value: { ...h, [R]: y }, questionId: l, type: m }, !M({ ...h, [R]: y })), _((C) => ({ ...C, [R]: y }));
139
+ }, D = r.displayMatrixAsAccordion || g;
140
+ return e("form", { className: V(t, !d && "ul-card__matrix", "fade-in-transition", d && !v && "ul-card--unfocused"), id: "text-form", onClick: () => {
141
+ v && i(l);
142
+ }, onSubmit: p, children: [e(le, { isRequired: d && (r == null ? void 0 : r.required), message: s, properties: r }), e(me, { properties: r, children: [e(oe, { children: [e(D ? kr : Tr, { columns: k, onSelect: $, options: n, selectedOptions: h }), b && e(Se, { handleSubmit: p, isSubmitDisabled: M(h) })] }), !d && e(pe, { children: e("div", { className: "ul-card__button-wrapper", children: e(re, { disabled: M(h), children: he(r) }) }) })] })] }, l);
143
+ }, We = ({ className: t, message: s, onSubmit: o, options: n = [], properties: r, questionId: l, type: m, showIndividualSubmit: b = !1, onSubmitButtonClick: u }) => {
144
+ const { border: g, useMobileStyling: d, isLongFormSurvey: f, focusedQuestionId: i, setFocusedQuestionId: k } = Y((x) => ({ border: x.border, useMobileStyling: x.useMobileStyling, isLongFormSurvey: ae(x.studyType), focusedQuestionId: x.focusedQuestionId, setFocusedQuestionId: x.setFocusedQuestionId })), c = f && i === l, v = n.reduce((x, N) => (x[N.id] = { isSelected: !1 }, x), {}), [p, w] = J(v), h = m === "multiplechoice", _ = r.required, M = n.find((x) => {
145
+ var N;
146
+ return (N = x.optionProperties) == null ? void 0 : N.noneOfTheAbove;
147
+ }), $ = (x) => Object.entries(x).some(([N, W]) => {
148
+ var ee;
149
+ const G = n.find((a) => `${a.id}` === N), H = W.userText === void 0 || W.userText.trim() === "";
150
+ return ((ee = G == null ? void 0 : G.optionProperties) == null ? void 0 : ee.allowsTextEntry) && H && W.isSelected;
151
+ }), D = (x) => Object.values(x).filter((N) => N.isSelected).length, R = r.minSelect && r.minSelect > 0 && r.maxSelectMode === ke.Range && D(p) < r.minSelect && (_ || D(p) > 0), y = (x) => $(x) || _ && !D(x) || !((N) => {
152
+ const { minSelect: W = 0, maxSelect: G = 1 / 0, maxSelectMode: H } = r, ee = D(N);
153
+ switch (H) {
154
+ case ke.Maximum:
155
+ return ee <= G;
156
+ case ke.Range:
157
+ return ee === 0 || ee >= W;
158
+ default:
159
+ return !0;
160
+ }
161
+ })(x), C = Object.entries(p).some(([x, N]) => {
162
+ var W, G;
163
+ return N.isSelected && ((G = (W = n.find((H) => `${H.id}` === x)) == null ? void 0 : W.optionProperties) == null ? void 0 : G.allowsTextEntry);
164
+ }), F = b && (!h || C), L = (x) => {
165
+ j(x.id, x.selected, x.userText, x.noneOfTheAbove), x.selected && f && !h && !c && k(l);
166
+ }, Q = (x) => {
167
+ var N;
168
+ return (r == null ? void 0 : r.maxSelectMode) !== ke.Unlimited && D(p) === (r == null ? void 0 : r.maxSelect) && !((N = p[x]) != null && N.isSelected);
169
+ }, I = (x) => {
170
+ x.preventDefault(), x.stopPropagation(), o(p, !0), u && u();
171
+ }, j = (x, N, W, G) => {
172
+ const H = Object.assign({}, p);
173
+ if ((h || G) && N) for (const S of Object.values(H)) S.isSelected = !1, delete S.userText;
174
+ else M && !G && p[M.id].isSelected && (H[M.id].isSelected = !1);
175
+ H[x] = { isSelected: N, userText: W };
176
+ const ee = h && Object.entries(H).some(([S, q]) => {
177
+ var B, E;
178
+ return q.isSelected && ((E = (B = n.find((Z) => `${Z.id}` === S)) == null ? void 0 : B.optionProperties) == null ? void 0 : E.allowsTextEntry);
179
+ }), a = !y(H);
180
+ f && (o(H, a), h && !ee && a && u && u()), w(H);
181
+ };
182
+ return e("form", { className: V(t, "ul-card--multiple", "fade-in-transition", f && !c && "ul-card--unfocused"), id: "text-form", onClick: m === "multipleselect" ? () => {
183
+ f && i !== l && m === "multipleselect" && k(l);
184
+ } : void 0, onSubmit: I, children: [e(le, { isRequired: f && (r == null ? void 0 : r.required), message: s, properties: r }), e(me, { properties: r, children: e(ve, { children: [e(oe, { children: [r.isDropdown ? e(gr, { disabledOptions: n.filter((x) => Q(x.id)), dropdownFooter: R ? e("div", { className: "ul-card__min-select-counter", style: { marginLeft: "16px" }, children: [D(p), "/", r.minSelect] }) : void 0, isMultiSelect: !h, multiselectText: r.dropdownMultiselectedText ?? "choices selected", onChange: (x) => {
185
+ const N = { ...p };
186
+ for (const W of n) x.includes(W) ? N[W.id].isSelected = !0 : N[W.id].isSelected = !1;
187
+ f && o(N, !y(N)), w(N);
188
+ }, options: n, placeholderText: r.dropdownPlaceholderText ?? (h ? "Select choice" : "Select choice(s)"), value: n.filter((x) => p[x.id].isSelected) }) : e("div", { className: V(te("ul-card__choices", d)), role: h ? "radiogroup" : "group", children: [n.map(({ id: x, label: N, value: W, optionProperties: G }) => {
189
+ var q, B;
190
+ const H = `${x}`, { allowsTextEntry: ee, noneOfTheAbove: a } = { allowsTextEntry: !1, noneOfTheAbove: !1, ...G };
191
+ return e(fe, { allowTextEntry: ee, border: g, disabled: Q(H), error: (S = p, $(S)), id: H, isRadio: h, isSelected: !!((q = p[H]) != null && q.isSelected), label: N, noneOfTheAbove: a, onUserInputChanged: L, promptText: (G == null ? void 0 : G.otherOptionPlaceholder) || "Please specify", text: (B = p[x]) == null ? void 0 : B.userText, useMobileStyling: d, value: W }, H);
192
+ var S;
193
+ }), !!R && e("div", { className: "ul-card__min-select-counter", children: [D(p), "/", r.minSelect] })] }), F && e(Se, { handleSubmit: I, isSubmitDisabled: y(p) })] }), !f && e(pe, { children: e("div", { className: "ul-card__button-wrapper", children: e(re, { disabled: y(p), onClick: I, children: he(r) }) }) })] }) })] }, l);
194
+ }, Nr = (t) => {
195
+ const { questionId: s, type: o, next: n, options: r } = t, { setFocusedQuestionId: l } = Y((m) => ({ setFocusedQuestionId: m.setFocusedQuestionId }));
196
+ return e(We, { ...t, onSubmit: (m, b) => {
197
+ var k;
198
+ const u = Object.entries(m).find(([, c]) => c.isSelected) || [void 0, void 0], [g, d] = u, f = r.find((c) => `${c.id}` === g);
199
+ !((k = f == null ? void 0 : f.optionProperties) != null && k.allowsTextEntry) || d != null && d.userText && d.userText.trim() !== "" || l(s);
200
+ const i = d != null && d.userText ? { [g]: { userText: d.userText } } : null;
201
+ n({ value: f && g ? { [g]: f.value } : {}, secondaryValue: i, questionId: s, type: o }, b);
202
+ } });
203
+ }, wr = (t) => {
204
+ const { questionId: s, type: o, next: n } = t;
205
+ return e(We, { ...t, onSubmit: (r, l) => {
206
+ const m = Object.entries(r).reduce((u, [g, d]) => (u[g] = d.isSelected, u), {}), b = Object.entries(r).reduce((u, [g, d]) => {
207
+ if (!d.userText) return u;
208
+ const f = u || {};
209
+ return f[g] = { userText: d.userText }, f;
210
+ }, null);
211
+ n({ value: m, secondaryValue: b, questionId: s, type: o }, l);
212
+ } });
213
+ }, qr = ({ className: t, labels: s, message: o, properties: n, next: r, questionId: l, type: m }) => {
214
+ const [b, u] = J(null), { border: g, useMobileStyling: d, viewDocument: f, isLongFormSurvey: i, focusedQuestionId: k } = Y((w) => ({ border: w.border, useMobileStyling: w.useMobileStyling, viewDocument: w.viewDocument, isLongFormSurvey: ae(w.studyType), focusedQuestionId: w.focusedQuestionId })), c = i && k === l, v = s && s.left, p = s && s.right;
215
+ return e("form", { className: V(t, "ul-card--nps", "fade-in-transition", i && !c && "ul-card--unfocused"), children: [e(le, { isRequired: i && (n == null ? void 0 : n.required), message: o, properties: n }), e(me, { properties: n, children: [e(oe, { children: [e("div", { className: "ul-card--nps__numbers", children: [...Array(11)].map((w, h) => e("button", { className: V(te("nps-number", d), te(`nps-number-${h}`, d)), id: `option-${h}`, onClick: (_) => {
216
+ i && (_.preventDefault(), _.stopPropagation(), u(h)), r({ value: h, questionId: l, type: m }, !0);
217
+ }, onKeyDown: (_) => {
218
+ var $, D;
219
+ const M = f.querySelectorAll("button.nps-number");
220
+ _.key === "ArrowRight" ? ($ = M[h + 1]) == null || $.focus() : _.key === "ArrowLeft" ? (D = M[h - 1]) == null || D.focus() : _.key !== "Enter" && _.key !== " " || (i && (_.preventDefault(), _.stopPropagation(), u(h)), r({ value: h, questionId: l, type: m }, !0));
221
+ }, onPointerDown: (_) => {
222
+ _.currentTarget.style.zIndex = "2", _.currentTarget.style.borderColor = g;
223
+ }, onPointerLeave: (_) => {
224
+ _.currentTarget.style.zIndex = "auto", _.currentTarget.style.borderColor = Me;
225
+ }, style: b === h ? { backgroundColor: g, color: "#fff" } : void 0, tabIndex: 0, children: h }, h)) }), e("div", { className: "ul-card--nps__labels", children: [e("span", { children: v }), e("span", { children: p })] })] }), !n.required && !i && e(pe, { children: e("div", { className: "ul-vertical-centered-container", children: e(re, { onClick: (w) => {
226
+ w.preventDefault(), w.stopPropagation(), r({ value: null, questionId: l, type: m }, !0);
227
+ }, children: he(n) }) }) })] })] }, l);
228
+ }, Lr = (t) => {
229
+ const { className: s, message: o, next: n, properties: r, questionId: l, type: m, showIndividualSubmit: b = !1, onSubmitButtonClick: u } = t, g = m === "aidynamicfollowup" || m === "aidynamicstandalone", d = g ? t.loading : void 0, { border: f, useMobileStyling: i, update: k, isLongFormSurvey: c, focusedQuestionId: v, setFocusedQuestionId: p, isPreview: w } = Y((I) => ({ border: I.border, useMobileStyling: I.useMobileStyling, update: I.update, isLongFormSurvey: ae(I.studyType), focusedQuestionId: I.focusedQuestionId, setFocusedQuestionId: I.setFocusedQuestionId, isPreview: I.isPreview })), [h, _] = J(""), M = ne(null), $ = c && v === l;
230
+ se(() => {
231
+ var I, j;
232
+ c && !w && ($ ? (I = M.current) == null || I.focus() : (j = M.current) == null || j.blur());
233
+ }, [c, $, w]);
234
+ const D = h.trim(), R = r.required === !0 && !D, y = hr(M, () => k()), C = (I) => {
235
+ I.preventDefault(), I.stopPropagation();
236
+ const j = D.length > 0, x = !r.required || j;
237
+ n({ value: h, questionId: l, type: m }, x), u && u(j);
238
+ }, F = r && r.openTextPlaceholder ? r.openTextPlaceholder : "";
239
+ if ((d === we.failure || d === void 0) && g) return e(ve, {});
240
+ const L = d === we.inFlight, Q = L ? "Preparing your next question" : o;
241
+ return e("form", { className: V(s, "ul-card-text", "fade-in-transition", c && !$ && "ul-card--unfocused"), id: "text-form", onClick: () => {
242
+ c && v !== l && p(l);
243
+ }, children: [e(le, { isRequired: c && (r == null ? void 0 : r.required), message: Q, properties: r }), e(me, { properties: r, children: e("div", { className: "ul-card-text", children: e(oe, { children: [e("div", { className: "ul-card-text__container", children: e("textarea", { "aria-describedby": "ul-caption", "aria-labelledby": "ul-question", "aria-multiline": "true", "aria-placeholder": F, className: V(L && "ul-card-text__input__loading", te("ul-card-text__input", i)), "data-gramm": "false", disabled: L, maxLength: 5e3, name: "text", onBlur: (I) => {
244
+ I.currentTarget.style.borderColor = Me;
245
+ }, onChange: (I) => {
246
+ const { value: j } = I.currentTarget;
247
+ if (y(), I.preventDefault(), I.stopPropagation(), _(j), c) {
248
+ const x = j.trim().length > 0;
249
+ n({ value: j, questionId: l, type: m }, x);
250
+ }
251
+ }, onFocus: (I) => {
252
+ I.currentTarget.style.borderColor = f, p(l);
253
+ }, placeholder: F, ref: M, role: "textbox", tabIndex: 0 }) }), r.footerHtml && e(xe, { className: "footer", html: r.footerHtml }), b && e(Se, { handleSubmit: C, isSubmitDisabled: R }), e(pe, { children: !c && e(re, { disabled: R || L, onClick: C, children: he(r) }) })] }) }) })] }, l);
254
+ }, qe = 1, Ze = 2, Ge = 3, Ie = (t) => t.type === "av_permission", Ee = (t) => t.type === "screen_permission", ze = (t, s) => t === void 0 ? qe : t ? ((o, n) => !(Ie(n) ? n.permissionDescriptors : []).includes("camera") || o.getVideoTracks().length > 0)(t, s) ? Ge : qe : Ze, $e = { avStream: null, currentPage: null, mediaRecordingUids: null, nextQuestion: () => {
255
+ }, passthroughData: void 0, recordingMediaTypes: void 0, screenPermissionRequested: !1, type: void 0 }, ce = tr((t) => ({ ...$e, reset: () => {
256
+ t($e);
257
+ }, updatePage: (s) => {
258
+ t(s);
259
+ } }));
260
+ function Le({ currentPage: t, pages: s }) {
261
+ const { avStream: o, recordingMediaTypes: n, updatePage: r } = ce.getState(), { recorderEventEmitter: l } = Y.getState();
262
+ l.emit("av.permission", { "permission.descriptors": t.permissionDescriptors, "stream.ready": (m, b) => {
263
+ if (o === m) return;
264
+ let u = t;
265
+ if (m && !t.permissionDescriptors.includes("camera")) {
266
+ const g = s.indexOf(t), d = b != null && b.active ? g + 2 : g + 1;
267
+ b != null && b.active && n && l.emit("begin.recording", { "recording.media.types": n, "start.recording.callback": (f) => r({ mediaRecordingUids: f }) }), u = s[d];
268
+ }
269
+ r({ currentPage: u, avStream: m });
270
+ } });
271
+ }
272
+ function Pe({ status: t }) {
273
+ const { nextQuestion: s, passthroughData: o, mediaRecordingUids: n, reset: r } = ce.getState(), { recorderEventEmitter: l, handleUploadUpdate: m, index: b } = Y.getState(), u = { value: { taskStatus: t }, type: "recordedtask", questionId: (o == null ? void 0 : o.questionId) || 1 };
274
+ o && l.emit("finish.task", { "begin.callback": (g) => {
275
+ m({ mediaRecordingUid: g, isSubmitted: !0, progressPct: 0, isComplete: !1 });
276
+ }, "progress.callback": (g, d) => {
277
+ m({ mediaRecordingUid: g, progressPct: d.detail, isSubmitted: !1, isComplete: !1 });
278
+ }, "upload.callback": (g) => {
279
+ g && m({ mediaRecordingUid: g, isComplete: !0, isSubmitted: !0, progressPct: 100 });
280
+ }, "passthrough.data": o, "current.index": b, "task.response": u, "task.complete.callback": (g) => {
281
+ u.value.taskDurationMillisecond = g, n && (u.value.mediaRecordingUids = n), r(), s(u);
282
+ } });
283
+ }
284
+ function Re({ pages: t, setIsRequestingPermission: s }) {
285
+ const { recorderEventEmitter: o, eventEmitFn: n } = Y.getState(), { updatePage: r, currentPage: l, recordingMediaTypes: m, screenPermissionRequested: b } = ce.getState();
286
+ if (!l) return;
287
+ const u = t.indexOf(l);
288
+ switch (l.type) {
289
+ case "av_permission": {
290
+ const g = b ? u + 2 : u + 1;
291
+ return b && m && o.emit("begin.recording", { "recording.media.types": m, "start.recording.callback": (d) => {
292
+ r({ mediaRecordingUids: d });
293
+ } }), void r({ currentPage: t[g] });
294
+ }
295
+ case "screen_permission":
296
+ return void o.emit("screen.permission", { "screen.permission.requested": s, "stream.ready.callback": (g, d) => {
297
+ const f = d ? t[u + 1] : l;
298
+ d && m && o.emit("begin.recording", { "recording.media.types": m, "start.recording.callback": (i) => {
299
+ r({ captureStream: d, mediaRecordingUids: i });
300
+ } }), r({ currentPage: f, screenPermissionRequested: !0, captureStream: d });
301
+ } });
302
+ case "start_task":
303
+ return n("recorded.task.start"), o.emit("recorded.task.start"), o.emit("start.task"), void r({ currentPage: t[u + 1], screenPermissionRequested: !0 });
304
+ case "complete_task":
305
+ return;
306
+ }
307
+ }
308
+ const Ye = "ul-permission-graphics-container", Ke = "ul-permission-body", Xe = V(Ye, "ul_recorded-task-inset-spacing"), Ce = V("ul-horizontal-button-container", "ul-horizontal-button-container-left"), Je = ({ richTextBody: t }) => e(xe, { className: "ul-rich-text-body", html: t, id: "ul-task-detail-container" }), _e = ({ required: t, skipButtonText: s, bottom: o = !1 }) => t ? null : e(re, { className: V(o && "ul-skip-button-below", "ul-button-inactive"), onClick: Pe.bind(null, { status: "abandoned" }), children: s || "Skip" }), De = (t) => {
309
+ const { avStream: s, captureStream: o, recordingMediaTypes: n, updatePage: r } = ce.getState(), l = (n == null ? void 0 : n.includes("audio")) || (n == null ? void 0 : n.includes("video"));
310
+ se(() => {
311
+ const m = setInterval(() => {
312
+ l && s && !s.active ? r({ avStream: null, currentPage: t[0] }) : o && o.active || r({ captureStream: void 0, currentPage: t[l ? 1 : 0] });
313
+ }, 1e3);
314
+ return () => clearInterval(m);
315
+ }, [s, o, l, t, n, r]);
316
+ }, Pr = ({ content: t, pages: s, required: o }) => {
317
+ const { buttonText: n, skipButtonText: r, taskDetail: l } = t;
318
+ return De(s), e("div", { className: "ul-task-page", children: [l && e(Je, { richTextBody: l }), e("div", { className: Ce, children: [e(re, { onClick: Re.bind(null, { pages: s }), children: n }), e(_e, { required: o, skipButtonText: r })] })] }, "start-task");
319
+ }, Mr = ({ content: t, pages: s, properties: o }) => {
320
+ const { buttonText: n, skipButtonText: r } = t;
321
+ return De(s), e("div", { className: "ul-task-page", children: [t.taskDetail && e(Je, { richTextBody: t.taskDetail }), e(me, { properties: o, children: e("div", { className: Ce, children: [e(re, { className: "ul-complete-task-button", onClick: Pe.bind(null, { status: "completed" }), children: n }), e(re, { className: V("ul-button-inactive"), onClick: Pe.bind(null, { status: "given.up" }), children: r })] }) })] }, "complete-task");
322
+ }, Rr = ({ content: t, pages: s, required: o }) => {
323
+ const { buttonText: n, skipButtonText: r } = t, [l] = Y((u) => [u.tabTitle]), [m, b] = J(!1);
324
+ return e("div", { children: [e("div", { className: Xe, children: [e("p", { style: { marginTop: "auto" }, children: t.selectTabText }), e("div", { className: "ul-select-tab-container", children: e("p", { className: Ke, children: l }) })] }), e("div", { className: o ? "" : Ce, children: [e(re, { disabled: m, onClick: Re.bind(null, { pages: s, setIsRequestingPermission: b }), children: n }), e(_e, { required: o, skipButtonText: r })] })] });
325
+ }, Dr = ({ content: t }) => e(xe, { className: V(Ye, "ul_permission_svg_container", "ul_recorded-task-inset-spacing", "ul-center-horizontally"), html: t.svg }, "ul-permission-request-graphic"), Fr = ({ content: t, pages: s, required: o }) => {
326
+ const { permissionDeniedHeadline: n, permissionDeniedBody: r, skipButtonText: l, tryAgainButtonText: m } = t, b = Ie(s[0]) ? s[0] : null;
327
+ return se(() => {
328
+ const u = setInterval(() => {
329
+ b !== null && Le({ currentPage: b, pages: s });
330
+ }, 1e3);
331
+ return () => clearInterval(u);
332
+ }, [b, s]), b ? e("div", { children: [e("div", { className: Xe, children: e("p", { className: "ul-av-permission-denied-paragraph", children: [e("span", { className: "ul-av-permission-denied-headline", children: n }), e("span", { className: Ke, children: r })] }) }), e("div", { className: Ce, children: [e(re, { onClick: Le.bind(null, { currentPage: b, pages: s }), children: m }), e(_e, { required: o, skipButtonText: l })] })] }) : null;
333
+ }, Qr = ({ stream: t }) => e("video", { autoPlay: !0, className: V("ul_recorded-task-inset-spacing"), id: "ul-record-task-video-preview", muted: !0, ref: (s) => {
334
+ s && (s.srcObject = t || null);
335
+ } }), Br = ({ content: t, pages: s, required: o }) => {
336
+ const { skipButtonText: n } = t, { avStream: r } = ce.getState();
337
+ return De(s), e("div", { children: [e(Qr, { stream: r }), e("div", { className: "ul-vertical-button-container-center", children: [e(re, { onClick: Re.bind(null, { pages: s }), children: t.buttonText }), e(_e, { bottom: !0, required: o, skipButtonText: n })] })] });
338
+ }, Er = ({ properties: t }) => {
339
+ const { pages: s, required: o } = t, { avStream: n, currentPage: r } = ce.getState();
340
+ if (r === void 0) return null;
341
+ switch (r == null ? void 0 : r.type) {
342
+ case "av_permission": {
343
+ const l = ze(n, r);
344
+ return l === qe ? e(Dr, { content: r }) : e(l === Ze ? Fr : Br, { content: r, pages: s, required: o });
345
+ }
346
+ case "screen_permission":
347
+ return e(Rr, { content: r, pages: s, required: o });
348
+ case "start_task":
349
+ return e(Pr, { content: r, pages: s, required: o });
350
+ case "complete_task":
351
+ return e(Mr, { content: r, pages: s, properties: t });
352
+ default:
353
+ return null;
354
+ }
355
+ }, $r = ({ className: t, properties: s, next: o, questionId: n }) => {
356
+ const r = Y(), { surveyId: l, responseGroupUid: m, userId: b, update: u } = r, g = ce(), { screenPermissionRequested: d } = g, f = ce((p) => p.avStream);
357
+ let i = ce((p) => p.currentPage);
358
+ i || (i = function({ pages: p, userId: w, responseGroupUid: h, surveyId: _, questionId: M, next: $ }) {
359
+ const { updatePage: D } = ce.getState(), { eventEmitFn: R, recorderEventEmitter: y } = Y.getState(), C = { questionId: M, surveyId: _, visitorId: w, responseGroupUid: h };
360
+ let F = 0;
361
+ y.emit("recorded.task.permission.screen"), R("recorded.task.permission.screen"), y.emit("permission.status", { "permission.status.callback": (Q, I, j, x) => {
362
+ const N = p[F], { type: W } = N, G = ["screen"];
363
+ if (Ie(N)) {
364
+ const { permissionDescriptors: H } = N, ee = H == null ? void 0 : H.includes("microphone"), a = H == null ? void 0 : H.includes("camera");
365
+ ee && G.push("audio"), a && G.push("video"), (Q != null && Q.active && !a || Q != null && Q.active && I) && F++;
366
+ }
367
+ Ee(p[F]) && j && (F++, y.emit("begin.recording", { "recording.media.types": G, "start.recording.callback": (H) => D({ mediaRecordingUids: H }) })), D({ currentPage: p[F], avStream: Q, screenPermissionRequested: j, nextQuestion: $, type: W, passthroughData: C, recordingMediaTypes: G, captureStream: x });
368
+ } });
369
+ const L = p[F];
370
+ return L.type === "av_permission" && Le({ currentPage: L, pages: p }), L;
371
+ }({ questionId: n, surveyId: l, next: (p) => {
372
+ o(p, !0);
373
+ }, pages: s.pages, responseGroupUid: m, userId: b }));
374
+ let k = i.headline, c = i.captionText;
375
+ const v = ze(f, i);
376
+ return Ee(i) && d && (k = i.permissionDeniedHeadline, c = i.permissionDeniedCaptionText), Ie(i) && v === Ge && (k = i.permissionGrantedHeadline, c = i.permissionGrantedCaptionText), se(() => {
377
+ u();
378
+ }, [u]), e("div", { className: V(t, "ul-center-horizontally", "fade-in-transition"), children: [e(le, { isRequired: s == null ? void 0 : s.required, message: k, properties: { captionText: c } }), e(oe, { children: e(Er, { properties: s }) })] });
379
+ }, Ar = ({ richTextBody: t, plaintextBody: s }) => t ? e(xe, { className: "ul-rich-text-body", html: t, 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((o, n) => e("p", { children: o }, n)) }) : null, Or = ({ className: t, message: s, next: o, properties: n, questionId: r, type: l }) => {
380
+ const { visitorAttributes: m, isLongFormSurvey: b } = Y((f) => ({ visitorAttributes: f.visitorAttributes, isLongFormSurvey: ae(f.studyType) })), u = (f, i = !1) => {
381
+ o({ value: i ? { skipped: !0 } : void 0, questionId: r, type: l }, !0);
382
+ }, g = br(n && n.buttonUrl, m), d = b && n.promptActionType === nr.NO_BUTTON;
383
+ return e("div", { className: V(t, "ul-card__text-url-prompt", "fade-in-transition"), children: [e(le, { isRequired: b && (n == null ? void 0 : n.required), message: s, properties: { questionHtml: n.questionHtml } }), e(oe, { children: e(Ar, { plaintextBody: n == null ? void 0 : n.body, richTextBody: n == null ? void 0 : n.richTextBody }) }), e(me, { properties: n, children: !d && 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: g, id: "ul-card-text__button", onClick: u, onKeyPress: (f) => {
384
+ f.key !== "Enter" && f.key !== " " || o({ value: void 0, questionId: r, type: l }, !0);
385
+ }, rel: "noreferrer", role: g ? "link" : "button", tabIndex: 0, target: "_blank", children: he(n) }), n.required === !1 && e("button", { className: "ul-card-skip__button", onClick: (f) => u(0, !0), children: Ve(n) })] }) }) })] }, r);
386
+ }, Vr = ({ className: t, questionId: s }) => {
387
+ const { border: o, destroy: n, endCard: r, forceBrandedLogo: l, update: m } = Y((g) => ({ border: g.border, destroy: g.destroy, endCard: g.endCard, forceBrandedLogo: g.forceBrandedLogo, update: g.update }));
388
+ se(() => {
389
+ setTimeout(() => {
390
+ n(mr);
391
+ }, l ? 4e3 : 2e3);
392
+ }, [n, l]);
393
+ const b = r && r.subheader ? e("p", { className: "ul-caption", children: r.subheader }) : null, u = r && r.headline ? r.headline : "";
394
+ return se(() => {
395
+ m();
396
+ }, [m]), e("div", { className: V(t, "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: o, 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: o, 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(le, { message: u }), b] }) }) }, s);
397
+ }, Hr = ({ className: t }) => {
398
+ const { uploadProgress: s } = Y((l) => ({ uploadProgress: l.uploadProgress }));
399
+ let o, n;
400
+ Object.values(s).filter((l) => l.isSubmitted).length > 1 ? (o = "Your responses are processing", n = "Please keep this tab open until your responses are fully processed.") : (o = "Your response is processing", n = "Please keep this tab open until your response is fully processed.");
401
+ const r = Math.round(Math.min(99, ...Object.values(s).filter((l) => l.isSubmitted).map((l) => l.progressPct || 0)));
402
+ return e("div", { className: V(t, "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(le, { message: `${o} (${r}% complete)` }), e("p", { className: "ul-caption", children: n })] });
403
+ }, er = sr(void 0), Ur = ({ value: t, children: s }) => e(er.Provider, { value: t, children: s }), jr = ({ isRightLabel: t, isLeftLabel: s }) => t ? de.RIGHT : s ? de.LEFT : null, Wr = "Best", Zr = "Worst", Gr = ({ className: t, labels: s, message: o, properties: n, options: r, questionId: l, type: m, next: b }) => {
404
+ var M, $, D, R;
405
+ const [u, g] = J(r.map((y, C) => ({ ...y, label: y.label === "" ? `Item ${C + 1}` : y.label, isRightLabel: !1, isLeftLabel: !1 }))), d = (() => {
406
+ const y = ir(er);
407
+ if (y === void 0) throw new Error("usePreviousResponses must be used within a PreviousResponsesProvider");
408
+ return y;
409
+ })(), f = { padding: "24px", display: "flex", cursor: "pointer", width: "auto" }, [i, k] = J(!1);
410
+ se(() => {
411
+ const y = u.findIndex((N) => N.isRightLabel), C = u.findIndex((N) => N.isLeftLabel), F = y !== -1 && C !== -1;
412
+ k(F);
413
+ const L = !n.required || n.required && F, Q = u.map((N) => ({ id: N.id, option: N.label, selected: jr(N) })), I = Math.floor(l), j = Object.keys(d).filter((N) => N.startsWith(I.toString())).map(Number).sort((N, W) => N - W).at(-1), x = [];
414
+ if (typeof j == "number") {
415
+ const N = d[j], W = JSON.parse(N);
416
+ x.push(...W);
417
+ }
418
+ x.push(Q), setTimeout(() => {
419
+ b({ value: x, questionId: l, type: m }, L, F), k(!1);
420
+ }, F ? 500 : 0);
421
+ }, [u]);
422
+ const { border: c, useMobileStyling: v, enableCspTrustedTypes: p } = Y((y) => ({ border: y.border, useMobileStyling: y.useMobileStyling, enableCspTrustedTypes: y.enableCspTrustedTypes })), w = (y, C) => () => {
423
+ i || g((F) => ((L, Q, I) => L.map((j) => j.id === Q ? { ...j, isRightLabel: I === de.RIGHT, isLeftLabel: I === de.LEFT } : I === de.RIGHT && j.isRightLabel || I === de.LEFT && j.isLeftLabel ? { ...j, isRightLabel: !1, isLeftLabel: !1 } : j))(F, y, C));
424
+ }, h = (M = n.ratingIcons) == null ? void 0 : M[0].svg, _ = ($ = n.ratingIcons) == null ? void 0 : $[1].svg;
425
+ return e("form", { className: V(t, "ul-card-maxdiff", "fade-in-transition"), children: [e(le, { isRequired: n == null ? void 0 : n.required, message: o, properties: n }), e(oe, { 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) || ((D = n == null ? void 0 : n.labels) == null ? void 0 : D.left) || Wr }), e("div", { children: " " }), e("div", { className: "ul-card-maxdiff__label", children: (s == null ? void 0 : s.right) || ((R = n == null ? void 0 : n.labels) == null ? void 0 : R.right) || Zr }), u.map(({ id: y, label: C, isLeftLabel: F, isRightLabel: L }) => e(ve, { children: [e("div", { className: "ul-card-maxdiff__option-control " + (_ ? "smiley" : ""), children: _ ? e(Ae, { ariaPressed: F, className: F ? "ul-card-maxdiff__option-btn ul-card-maxdiff__option-selected good" : "ul-card-maxdiff__option-btn", enableCspTrustedTypes: p, html: _, id: `smiley-good-${y}`, onClick: w(y, de.LEFT) }) : e(fe, { allowTextEntry: !1, ariaLabel: `bestLabel-${C}`, border: c, choiceStyle: f, error: !1, id: `${y}`, isRadio: !0, isSelected: F, onUserInputChanged: w(y, de.LEFT), useMobileStyling: v }) }), e("div", { className: "ul-card-maxdiff__option-label", children: C }), e("div", { className: "ul-card-maxdiff__option-control " + (h ? "smiley" : ""), children: h ? e(Ae, { ariaPressed: L, className: L ? "ul-card-maxdiff__option-btn ul-card-maxdiff__option-selected bad" : "ul-card-maxdiff__option-btn", enableCspTrustedTypes: p, html: h, id: `smiley-bad-${y}`, onClick: w(y, de.RIGHT) }) : e(fe, { allowTextEntry: !1, ariaLabel: `worstLabel-${C}`, border: c, choiceStyle: f, error: !1, id: `${y}`, isRadio: !0, isSelected: L, onUserInputChanged: w(y, de.RIGHT), useMobileStyling: v }) })] }))] }) })] }, l);
426
+ }, Ae = ({ enableCspTrustedTypes: t, ariaPressed: s, className: o, html: n, id: r, onClick: l }) => {
427
+ const m = ge(() => Ue(n, t), [t, n]);
428
+ return e("span", { "aria-pressed": s, className: o, dangerouslySetInnerHTML: { __html: m }, id: r, onClick: l, tabIndex: 0, type: "button" });
429
+ }, zr = ({ className: t, labels: s, message: o, next: n, properties: r, questionId: l, type: m, onSubmitButtonClick: b, options: u, showIndividualSubmit: g = !1 }) => {
430
+ const d = ne(null), f = ne(0), i = ne(0), k = ne(null), c = ne(!1), v = ne([]), [p, w] = J(() => (r == null ? void 0 : r.required) === !0), [h, _] = J(() => u.map((T) => ({ ...T, rank: null }))), M = ge(() => Array.from({ length: u.length }, (T, O) => O + 1), [u.length]), { isLongFormSurvey: $, focusedQuestionId: D, setFocusedQuestionId: R, useMobileStyling: y, isPreview: C, headers: F } = Y((T) => ({ useMobileStyling: T.useMobileStyling, isLongFormSurvey: ae(T.studyType), focusedQuestionId: T.focusedQuestionId, setFocusedQuestionId: T.setFocusedQuestionId, isPreview: T.isPreview, headers: T.headers })), L = (F == null ? void 0 : F["userleap-platform"]) === "android", Q = y && !C && !L, I = !Q && !L, j = $ && D === l, x = (T) => {
431
+ T.preventDefault(), S(h), b && b();
432
+ }, N = (T, O) => {
433
+ _((A) => {
434
+ const P = parseInt(O), U = A.map((z) => ({ ...z }));
435
+ U.some((z) => z.rank == null) && U.forEach((z, ye) => z.rank = ye + 1);
436
+ const ie = U.findIndex((z) => z.id === T);
437
+ if (ie === -1) return A;
438
+ const K = U[ie].rank;
439
+ return P < K ? U.forEach((z) => {
440
+ z.id !== T && z.rank >= P && z.rank < K && (z.rank = z.rank + 1);
441
+ }) : P > K && U.forEach((z) => {
442
+ z.id !== T && z.rank > K && z.rank <= P && (z.rank = z.rank - 1);
443
+ }), U[ie].rank = P, U.sort((z, ye) => z.rank - ye.rank), q(U), U;
444
+ });
445
+ }, W = (T, O) => {
446
+ for (let A = 0; A < v.current.length; A++) {
447
+ const P = v.current[A];
448
+ if (!P || P === k.current) continue;
449
+ const U = P.getBoundingClientRect();
450
+ if (T >= U.left && T <= U.right && O >= U.top && O <= U.bottom) return { element: P, index: A };
451
+ }
452
+ return null;
453
+ }, G = (T) => (O) => {
454
+ if (!Q) return;
455
+ O.preventDefault(), O.stopPropagation(), c.current = !0, d.current = T;
456
+ const A = O.touches[0];
457
+ f.current = A.clientY, i.current = A.clientY;
458
+ const P = O.currentTarget.closest(".ul-card-rank__option");
459
+ P && (k.current = P, P.classList.add("is-dragging"));
460
+ }, H = (T) => {
461
+ if (!Q || !c.current || d.current === null) return;
462
+ T.preventDefault(), T.stopPropagation();
463
+ const O = T.touches[0];
464
+ i.current = O.clientY;
465
+ const A = i.current - f.current;
466
+ k.current && (k.current.style.transform = `translateY(${A}px)`, k.current.style.zIndex = "1000"), v.current.forEach((U) => {
467
+ U && U !== k.current && U.classList.remove("is-drop-target");
468
+ });
469
+ const P = W(O.clientX, O.clientY);
470
+ P && P.element.classList.add("is-drop-target");
471
+ }, ee = (T) => {
472
+ if (!Q || !c.current || d.current === null) return;
473
+ T.preventDefault(), T.stopPropagation();
474
+ const O = T.changedTouches[0], A = W(O.clientX, O.clientY);
475
+ k.current && (k.current.style.transform = "", k.current.style.zIndex = "", k.current.classList.remove("is-dragging")), v.current.forEach((P) => {
476
+ P && P.classList.remove("is-drop-target");
477
+ }), A && A.index !== d.current && a(d.current, A.index), d.current = null, k.current = null, c.current = !1;
478
+ }, a = (T, O) => {
479
+ _((A) => {
480
+ const P = A.map((ie) => ({ ...ie })), [U] = P.splice(T, 1);
481
+ return P.splice(O, 0, U), P.forEach((ie, K) => {
482
+ ie.rank = K + 1;
483
+ }), q(P), P;
484
+ });
485
+ }, S = (T) => {
486
+ const O = {};
487
+ T.reduce((A, P) => (A[P.id] = P.rank, A), O), n({ value: O, questionId: l, type: m }, !0);
488
+ }, q = (T) => {
489
+ w(!1), $ && S(T);
490
+ }, { left: B, right: E } = s, Z = u.length, X = (T) => {
491
+ T.preventDefault(), T.currentTarget.classList.add("is-drop-target");
492
+ }, ue = (T) => {
493
+ T.currentTarget.classList.remove("is-drop-target");
494
+ }, be = (T) => {
495
+ d.current = null, T.currentTarget.classList.remove("is-dragging");
496
+ };
497
+ return e("form", { className: V(t, "ul-card-rank", "fade-in-transition", $ && !j && "ul-card--unfocused"), onClick: $ && !j ? () => {
498
+ R(l);
499
+ } : void 0, onSubmit: x, children: [e(le, { isRequired: r == null ? void 0 : r.required, message: o, properties: r }), e(me, { properties: r, children: e(ve, L ? { children: [e(oe, { children: [e("div", { className: "ul-card--rank__question-inner-container", children: [e("div", { className: "ul-card-rank__labels", children: e("span", { children: ["1 - ", B] }) }), e("ol", { className: "ul-card-rank__list", children: h.map(({ id: T, label: O, rank: A }) => e("li", { className: "ul-card-rank__option", children: [e("select", { "aria-label": `Rank for ${O}`, className: V("ul-card-rank__select", A == null && "ul-card-rank__select--placeholder"), name: `rank[${T}]`, onChange: (P) => N(T, P.currentTarget.value), value: A ?? "", children: [A == null && e("option", { className: "ul-card-rank__select-option", disabled: !0, value: "", children: "-" }), M.map((P) => e("option", { className: "ul-card-rank__select-option", value: P, children: P }, `${P}-${l}`))] }), e("span", { children: O })] }, T)) }), e("div", { className: "ul-card-rank__labels", children: e("span", { children: [Z, " - ", E] }) })] }), g && e(Se, { handleSubmit: x, isSubmitDisabled: p })] }), !$ && e(pe, { children: e("div", { className: "ul-card__button-wrapper", children: e(re, { disabled: p, children: he(r) }) }) })] } : { children: [e(oe, { children: [e("div", { className: "ul-card--rank__question-inner-container", children: [e("div", { className: "ul-card-rank__labels", children: e("span", { children: ["1 - ", B] }) }), e("ol", { className: "ul-card-rank__list", onDragOver: L ? void 0 : (T) => {
500
+ T.preventDefault(), T.dataTransfer && (T.dataTransfer.dropEffect = "move");
501
+ }, children: h.map(({ id: T, label: O, rank: A }, P) => {
502
+ return e("li", { className: "ul-card-rank__option", draggable: !!I || void 0, onDragEnd: I ? be : void 0, onDragEnter: I ? X : void 0, onDragLeave: I ? ue : void 0, onDragStart: I ? (ie = P, (K) => {
503
+ d.current = ie, K.dataTransfer && (K.dataTransfer.effectAllowed = "move", K.dataTransfer.setData("text/plain", String(ie)), K.currentTarget.classList.add("is-dragging"));
504
+ }) : void 0, onDrop: I ? (U = P, (K) => {
505
+ var ye, Fe;
506
+ K.preventDefault(), K.currentTarget.classList.remove("is-drop-target");
507
+ const z = d.current;
508
+ d.current = null, (Fe = (ye = K.currentTarget.closest(".ul-card-rank__list")) == null ? void 0 : ye.querySelector(".is-dragging")) == null || Fe.classList.remove("is-dragging"), z != null && z !== U && a(z, U);
509
+ }) : void 0, ref: (K) => v.current[P] = K, children: [e("select", { "aria-label": `Rank for ${O}`, className: V("ul-card-rank__select", A == null && "ul-card-rank__select--placeholder"), name: `rank[${T}]`, onChange: (K) => N(T, K.currentTarget.value), value: A ?? "", children: [A == null && e("option", { className: "ul-card-rank__select-option", disabled: !0, value: "", children: "-" }), M.map((K) => e("option", { className: "ul-card-rank__select-option", value: K, children: K }, `${K}-${l}`))] }), e("span", { children: O }), !L && e("button", { "aria-label": `Drag ${O} to reorder`, className: "ul-card-rank__drag-btn", onTouchEnd: Q ? ee : void 0, onTouchMove: Q ? H : void 0, onTouchStart: Q ? G(P) : 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" }) }) })] }, T);
510
+ var U, ie;
511
+ }) }), e("div", { className: "ul-card-rank__labels", children: e("span", { children: [Z, " - ", E] }) })] }), g && e(Se, { handleSubmit: x, isSubmitDisabled: p })] }), !$ && e(pe, { children: e("div", { className: "ul-card__button-wrapper", children: e(re, { disabled: p, children: he(r) }) }) })] }) })] }, l);
512
+ }, Yr = /* @__PURE__ */ new Set(["aidynamicfollowup", "aidynamicstandalone", "open", "matrix", "multipleselect", "multiplechoice", "rankorder"]), Oe = ({ cardInstance: t, moveToNextQuestion: s, showIndividualSubmit: o, submitQuestion: n, updateCardValues: r, allResponsesArray: l }) => {
513
+ const { isLongFormSurvey: m, createDynamicFollowupQuestion: b, cards: u, surveyVisitorAttributes: g } = Y((h) => ({ isLongFormSurvey: ae(h.studyType), createDynamicFollowupQuestion: h.createDynamicFollowupQuestion, cards: h.cards, surveyVisitorAttributes: h.surveyVisitorAttributes }));
514
+ if (!t) return null;
515
+ const { name: d, type: f, props: i, childId: k } = t, c = o && Yr.has(f), v = i == null ? void 0 : i.displayLogic;
516
+ if (v != null && v.length && !He({ displayLogic: v, allResponses: l, cards: u, surveyVisitorAttributes: g ?? {} })) return null;
517
+ const p = { className: "ul-card", next: (h, _, M = !0) => n(h, _ && M), questionId: d, type: f, showIndividualSubmit: o, ...c ? { next: (h, _) => {
518
+ r(h.questionId, h, _ ?? !0);
519
+ }, onSubmitButtonClick: (h = !1) => {
520
+ k ? h ? (s(d), b({ parentQuestionId: d })) : s(k) : s(d);
521
+ } } : {} }, w = (() => {
522
+ switch (f) {
523
+ case "consentlegal":
524
+ return e(yr, { ...p, ...i });
525
+ case "likert":
526
+ return e(Sr, { ...p, ...i });
527
+ case "matrix":
528
+ return e(_r, { ...p, ...i });
529
+ case "maxdiff":
530
+ return e(Gr, { ...p, ...i });
531
+ case "multiplechoice":
532
+ return e(Nr, { ...p, ...i });
533
+ case "multipleselect":
534
+ return e(wr, { ...p, ...i });
535
+ case "nps":
536
+ return e(qr, { ...p, ...i });
537
+ case "open":
538
+ case "aidynamicfollowup":
539
+ case "aidynamicstandalone":
540
+ return e(Lr, { ...p, type: t.type, ...i });
541
+ case "rankorder":
542
+ return e(zr, { ...p, ...i });
543
+ case "recordedtask":
544
+ return e($r, { ...p, ...i });
545
+ case "texturlprompt":
546
+ return e(Or, { ...p, ...i });
547
+ case "thanks":
548
+ return e(Vr, { ...p, ...i });
549
+ case "uploading":
550
+ return e(Hr, { ...p, ...i });
551
+ default:
552
+ return null;
553
+ }
554
+ })();
555
+ return w ? m ? e("div", { className: "ul-card-scroll-wrapper", children: w }, d) : w : null;
556
+ }, Kr = ({ isSubmitDisabled: t = !1, onSubmit: s, buttonText: o }) => {
557
+ var k;
558
+ const { cards: n, forceBrandedLogo: r, index: l, marketingUrl: m, showSurveyBrand: b, slugName: u, surveyId: g, useMobileStyling: d } = Y((c) => ({ cards: c.cards, forceBrandedLogo: c.forceBrandedLogo, index: c.index, marketingUrl: c.marketingUrl, showSurveyBrand: c.showSurveyBrand, slugName: c.slugName, surveyId: c.surveyId, useMobileStyling: c.useMobileStyling })), f = ((k = n[l]) == null ? void 0 : k.type) === "thanks", i = dr({ marketingUrl: m, slugName: u, surveyId: g, forceBrandedLogo: r });
559
+ return e("footer", { className: V("long-form-question-footer-container", d && "long-form-question-footer-container--mobile", f && "long-form-question-footer-container-center"), children: [f && r ? e(ar, { marketingUrlLink: i }) : e("div", { className: "long-form-question-footer-container-logo", children: b ? e(lr, { forceBrandedLogo: r, marketingUrlLink: i }) : null }), !f && e("div", { className: V("ul-card__button-wrapper", "ul-card-vertical__button-wrapper", "long-form-question-footer-container-actions"), children: e(re, { className: V("long-form-button", t && "sprig-button-disabled"), disabled: t, onClick: s, children: e("span", { className: "long-form-button-text-container", children: o ?? e(or, { stroke: "white" }) }) }) })] });
560
+ }, rt = ({ cards: t, next: s, previousResponses: o }) => {
561
+ var ee;
562
+ const n = ne(null), [r, l] = J({}), [m, b] = J({}), { isLongFormSurvey: u, focusedQuestionId: g, setFocusedQuestionId: d, createDynamicFollowupQuestion: f, allResponses: i, cardIndexByName: k, surveyVisitorAttributes: c, cards: v, createDynamicStandaloneQuestion: p } = Y((a) => ({ isLongFormSurvey: ae(a.studyType), focusedQuestionId: a.focusedQuestionId, setFocusedQuestionId: a.setFocusedQuestionId, createDynamicFollowupQuestion: a.createDynamicFollowupQuestion, allResponses: a.allResponses, cardIndexByName: a.cardIndexByName, surveyVisitorAttributes: a.surveyVisitorAttributes, cards: a.cards, createDynamicStandaloneQuestion: a.createDynamicStandaloneQuestion })), w = ge(() => ({ ...o, ...Qe(t.map((a) => {
563
+ var S, q;
564
+ return { ...a, value: ((S = r[a.name]) == null ? void 0 : S.value) ?? null, secondaryValue: ((q = r[a.name]) == null ? void 0 : q.secondaryValue) ?? null };
565
+ })) }), [o, r, t]);
566
+ vr(w);
567
+ const h = cr(t, w), _ = ge(() => ur({ storeAllResponses: i, cards: t, cardValues: r, cardIndexByName: k }), [i, t, r, k]), M = ge(() => {
568
+ const a = /* @__PURE__ */ new Set();
569
+ return t.forEach((S) => {
570
+ var B;
571
+ const q = (B = S.props) == null ? void 0 : B.displayLogic;
572
+ if (!q || q.length === 0) return void a.add(S.name);
573
+ He({ displayLogic: q, allResponses: _, cards: v, surveyVisitorAttributes: c ?? {} }) && a.add(S.name);
574
+ }), a;
575
+ }, [t, _, c, v]);
576
+ se(() => {
577
+ t.some((a) => {
578
+ if (a.type === "aidynamicstandalone" && a.props && M.has(a.name)) {
579
+ if (a.props.loading === we.inFlight) return !0;
580
+ if (a.props.loading === void 0) return p({ questionId: a.name }), !0;
581
+ }
582
+ return !1;
583
+ });
584
+ }, [t, p, M]);
585
+ const $ = ne(null);
586
+ se(() => {
587
+ const a = M, S = $.current;
588
+ if (S !== null) for (const q of S) a.has(q) || (l((B) => {
589
+ const E = { ...B };
590
+ return delete E[q], E;
591
+ }), b((B) => {
592
+ const E = { ...B };
593
+ return delete E[q], E;
594
+ }));
595
+ $.current = new Set(a);
596
+ }, [M]);
597
+ const D = ne(null), R = ne(!1), y = ne(null), C = Te((a) => {
598
+ var E, Z;
599
+ R.current = !0;
600
+ const S = t.findIndex((X) => X.name === a);
601
+ if (!u || a === null || S === -1) return void (R.current = !1);
602
+ const q = (E = D.current) == null ? void 0 : E.querySelectorAll(".ul-card-scroll-wrapper")[S], B = (Z = D.current) == null ? void 0 : Z.closest(".ul-card-main-content");
603
+ if (q && B) {
604
+ if (q && B) {
605
+ const X = q.getBoundingClientRect(), ue = B.getBoundingClientRect(), be = X.top - ue.top + B.scrollTop, T = be + X.height / 2, O = window.innerHeight - 157;
606
+ let A;
607
+ X.height >= O ? A = be : A = T - B.clientHeight / 2;
608
+ const P = B.clientHeight, U = B.scrollHeight - P, ie = Math.max(0, Math.min(A, U));
609
+ B.scrollTo({ top: ie, behavior: "smooth" }), setTimeout(() => {
610
+ R.current = !1;
611
+ }, 500);
612
+ }
613
+ } else R.current = !1;
614
+ }, [u, t]);
615
+ se(() => {
616
+ g !== null && t.findIndex((a) => a.name === g) !== -1 || d(t[0].name);
617
+ }, [t, g, d]);
618
+ const F = ({ displayCard: a, response: S }) => {
619
+ if (a && ((a == null ? void 0 : a.childId) ?? 0) > 0) {
620
+ const q = Qe([a].map((B) => ({ ...B, value: (S == null ? void 0 : S.value) ?? null, secondaryValue: (S == null ? void 0 : S.secondaryValue) ?? null })));
621
+ f({ parentQuestionId: a == null ? void 0 : a.name, parentResponseConfig: q });
622
+ }
623
+ };
624
+ function L(a, S) {
625
+ return a.filter((q) => M.has(q.name)).map((q) => {
626
+ const B = S[q.name], E = h.find((Z) => Z.name === q.name);
627
+ return { ...B, questionText: E ? Be(E) : void 0 };
628
+ });
629
+ }
630
+ const Q = (a) => {
631
+ if (!u) return;
632
+ let S = t.findIndex((q) => q.name === a) + 1;
633
+ for (; S < t.length && !M.has(t[S].name); ) S++;
634
+ S < t.length ? d(t[S].name) : d(a);
635
+ };
636
+ se(() => {
637
+ u && g !== null && (y.current !== g ? C(g) : y.current = null);
638
+ }, [g, u, C]);
639
+ const I = Te(() => {
640
+ var ue, be;
641
+ if (R.current) return;
642
+ const a = (ue = D.current) == null ? void 0 : ue.closest(".ul-card-main-content");
643
+ if (!a) return;
644
+ const S = (be = D.current) == null ? void 0 : be.querySelectorAll(".ul-card-scroll-wrapper");
645
+ if (!S || S.length === 0) return;
646
+ const q = a.getBoundingClientRect(), B = q.top + q.height / 2;
647
+ let E = 0, Z = 1 / 0;
648
+ S.forEach((T, O) => {
649
+ const A = T.getBoundingClientRect(), P = A.top + A.height / 2, U = Math.abs(B - P);
650
+ U < Z && (Z = U, E = O);
651
+ });
652
+ const X = t[E];
653
+ y.current = X.name, d(X.name);
654
+ }, [t, d]);
655
+ se(() => {
656
+ var S;
657
+ if (!u) return;
658
+ const a = ((S = D.current) == null ? void 0 : S.closest(".ul-card__container")) || null;
659
+ return a && a.addEventListener("scroll", I, { passive: !0 }), () => {
660
+ a && a.removeEventListener("scroll", I);
661
+ };
662
+ }, [I, u]);
663
+ const j = ge(() => t.every((a) => {
664
+ var S;
665
+ return !M.has(a.name) || !(!(a != null && a.props) || !("properties" in a.props) || ((S = a.props.properties) == null ? void 0 : S.required) !== !1) || m[a.name];
666
+ }), [m, t, M]), x = async (a, S, q) => {
667
+ return b((E) => ({ ...E, [a]: q })), await (B = (E) => ({ ...E, [a]: S }), new Promise((E) => {
668
+ l((Z) => {
669
+ const X = B(Z);
670
+ return E(X), X;
671
+ });
672
+ }));
673
+ var B;
674
+ };
675
+ se(() => {
676
+ var B;
677
+ if (!u) return;
678
+ const a = n.current, S = (B = t == null ? void 0 : t[0]) == null ? void 0 : B.groupId;
679
+ n.current = S;
680
+ const q = {};
681
+ if (t.forEach((E) => {
682
+ var Z, X;
683
+ pr(E) && (E.props.properties.required || (q[E.name] = { value: ((Z = r[E.name]) == null ? void 0 : Z.value) ?? null, secondaryValue: ((X = r[E.name]) == null ? void 0 : X.secondaryValue) ?? null, questionId: E.name, type: E.type }));
684
+ }), a == null || a !== S) l(q), b({});
685
+ else {
686
+ l((Z) => ({ ...Z, ...q }));
687
+ const E = t.reduce((Z, X) => {
688
+ var ue;
689
+ return X.type === "aidynamicfollowup" && ((ue = X.props) == null ? void 0 : ue.loading) === null && (Z[X.name] = !0), Z;
690
+ }, {});
691
+ b((Z) => ({ ...Z, ...E }));
692
+ }
693
+ }, [t, u]);
694
+ const N = async (a, S) => {
695
+ if (u) {
696
+ const q = await x(a.questionId, a, S), B = W(a.type), E = G(a.type);
697
+ if (B && Q(a.questionId), E && S) {
698
+ const Z = L(t, q);
699
+ s(Z);
700
+ }
701
+ } else {
702
+ const q = h.find((E) => E.name === a.questionId), B = { ...a, questionText: q ? Be(q) : void 0 };
703
+ F({ displayCard: q, response: a }), s([B]);
704
+ }
705
+ }, W = (a) => (/* @__PURE__ */ new Set(["nps", "likert", "multiplechoice"])).has(a), G = (a) => (/* @__PURE__ */ new Set(["videovoice", "consentlegal", "texturlprompt", "maxdiff"])).has(a), H = ((ee = t[0]) == null ? void 0 : ee.type) === "thanks";
706
+ return u ? e("div", { className: "ul-card-list-container--longform", "data-testid": "ui-container", ref: D, children: [e(Ur, { value: o, children: h.map((a, S) => e(Oe, { allResponsesArray: _, cardInstance: a, moveToNextQuestion: Q, showIndividualSubmit: t.length > 1 && S < t.length - 1, submitQuestion: N, updateCardValues: x }, (a == null ? void 0 : a.name) || S)) }), !H && e(Kr, { isSubmitDisabled: !j, onSubmit: function() {
707
+ const a = L(t, r);
708
+ if ((h == null ? void 0 : h.length) === 1 && (a == null ? void 0 : a.length) === 1) {
709
+ const S = h[0], q = a[0];
710
+ F({ displayCard: S, response: q });
711
+ }
712
+ s(a);
713
+ } })] }) : e(ve, { children: [e("div", { "data-testid": "ui-container", style: { display: "none" } }), h.map((a, S) => e(Oe, { allResponsesArray: _, cardInstance: a, moveToNextQuestion: Q, showIndividualSubmit: !1, submitQuestion: N, updateCardValues: x }, (a == null ? void 0 : a.name) || S))] });
714
+ };
715
+ export {
716
+ rt as PageCard
717
+ };