@sprig-technologies/sprig-browser 2.39.0 → 2.39.3

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