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