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