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