@sprig-technologies/sprig-bundled 2.39.0 → 2.39.2

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