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