@sprig-technologies/sprig-bundled 2.39.3 → 2.39.4

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