@sprig-technologies/sprig-bundled 2.40.3 → 2.41.0

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