@sprig-technologies/sprig-browser 2.39.2 → 2.39.3

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.
@@ -0,0 +1,586 @@
1
+ import { a as A, u as e, h as H, c as M, g as j, e as X, f as fe, p as ee, F as pe, d as ae, _ as Y, T as ce, A as je, i as Fe, j as Ze, k as ze, w as Pe } from "./view-BTPuuKmm.js";
2
+ import { v as Ye, R as F, B as W, M as J, O as ke, Q as te, a as re, b as de, S as Ke, L as Xe, u as We, H as xe, g as Je, P as et, p as tt, c as rt, s as nt } from "./getAttributedUrl-CKXj5eVU.js";
3
+ import { a as he, D as _e, A as Se } from "./core-fXpU4mUJ.js";
4
+ import { t as Re } from "./metricsReporter-1Oozsgva.js";
5
+ const at = ({ properties: t, surveyVideoUrl: s, questionId: r }) => {
6
+ const n = `ul-card-video__question_player-q${r}`, { apiURL: a, viewDocument: l } = A((o) => ({ apiURL: o.apiURL, viewDocument: o.viewDocument }));
7
+ return e("div", { id: n, ref: (o) => {
8
+ if (o && o.children.length === 0 && !t.properties.hideRecordedPrompt) {
9
+ const d = Ye(n, { src: s, type: "application/x-mpegURL" }, void 0, t.properties.mediaType === F.MEDIA_TYPE_AUDIO, a, l);
10
+ o.appendChild(d);
11
+ }
12
+ } });
13
+ }, ie = ({ isDisabled: t, onClick: s, children: r }) => e(W, { className: "ul-card__button-checkmark", disabled: t, onClick: s, type: "button", children: [e("svg", { fill: "none", height: "10", viewBox: "0 0 13 10", width: "13", xmlns: "http://www.w3.org/2000/svg", children: e("path", { d: "M11.5 1.5L4.5 8.5L1 5", stroke: "#ffffff", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "1.5" }) }), r || "Ok"] }), st = ({ className: t, next: s, properties: r, questionId: n, type: a }) => {
14
+ const { useMobileStyling: l, border: o } = A((k) => ({ useMobileStyling: k.useMobileStyling, border: k.border })), [d, c] = H(!1), [u, g] = H(""), [i, v] = H(!1), f = r == null ? void 0 : r.collectName, x = (r == null ? void 0 : r.nameLabelText) || "Full Name", p = (r == null ? void 0 : r.consentText) || "I agree to the stated conditions", C = (r == null ? void 0 : r.submitButtonText) || "Submit", I = !!u.trim(), m = d && (!f || I), S = (k, w = !1) => {
15
+ k.preventDefault(), k.stopPropagation();
16
+ let b = null;
17
+ if (!w) {
18
+ if (!m) return void v(!0);
19
+ b = { submitted: !0 }, f && (b.name = u);
20
+ }
21
+ s({ value: b, questionId: n, type: a }, !!w || m);
22
+ }, T = (k) => {
23
+ k.preventDefault(), k.stopPropagation(), g(k.currentTarget.value);
24
+ }, y = (k) => {
25
+ k.currentTarget.style.borderColor = i && !I ? he : o;
26
+ }, D = (k) => {
27
+ k.currentTarget.style.borderColor = i && !I ? he : _e;
28
+ }, P = () => e(te, { children: [e("div", { className: "sprig-stretch", children: [e(ke, { allowTextEntry: !1, border: o, error: i && !d, id: "consent", isRadio: !1, isSelected: d, label: p, onUserInputChanged: ({ selected: k }) => {
29
+ k !== d && c(!d);
30
+ }, useMobileStyling: l }), f && e("input", { "aria-label": x, "aria-placeholder": x, className: M(j("ul-consent-legal__name-input", l)), "data-gramm": "false", maxLength: 250, name: "name", onBlur: D, onFocus: y, onInput: T, placeholder: x, style: i && !I ? { borderColor: he } : {}, tabIndex: 0, value: u })] }), e("div", { className: "ul-card__button-wrapper ul-card-vertical__button-wrapper", children: [e(ie, { isDisabled: !m, onClick: (k) => S(new SubmitEvent(k.type)), children: X({ buttonText: C }) }), r.required === !1 && e("button", { className: "ul-card-skip__button", onClick: (k) => S(new SubmitEvent(k.type), !0), children: fe(r) })] })] });
31
+ return e("div", { className: M(t, "ul-card__consent-legal", "fade-in-transition"), children: e(J, { properties: r, defaultBody: P, embeddedType: "pdf" }) }, n);
32
+ }, it = () => {
33
+ const { destroy: t, forceBrandedLogo: s } = A((r) => ({ destroy: r.destroy, forceBrandedLogo: r.forceBrandedLogo }));
34
+ return ee(() => {
35
+ setTimeout(() => {
36
+ t(Se);
37
+ }, s ? 4e3 : 2e3);
38
+ }, [t, s]), e("div", { className: "end-of-survey-text", children: "End of survey" });
39
+ }, lt = ({ icon: t, scaleLabelType: s, value: r, selectedValue: n }) => {
40
+ if (s === "smiley" && r === n) {
41
+ let a = 0;
42
+ return t.replace(/black/g, () => ++a == 1 ? "black" : "white");
43
+ }
44
+ return t;
45
+ }, ot = ({ activeValue: t, border: s, icon: r, isPressed: n, range: a, scaleLabelType: l, selectedValue: o, setSelectedValue: d, setActiveValue: c, setIsPressed: u, useMobileStyling: g, value: i, viewDocument: v }) => {
46
+ const f = `option-${i}`, x = l === "number", p = l === "star", C = l === "smiley", I = x && i === t || i === o, [m, S] = (() => {
47
+ const y = p && o !== null && i <= o;
48
+ return p && i <= t || C && i === t || y || i === t || i === o ? [s, n || y || i === o ? 1 : 0.3] : ["", 1];
49
+ })(), T = pe(() => {
50
+ const y = { borderColor: I ? m : "", fillOpacity: I ? "" : S, zIndex: I ? 3 : "auto", color: o === i ? "#fff" : "" };
51
+ return x ? { ...y, backgroundColor: o === i ? m : "" } : { ...y, color: p || C || o === i ? m : "" };
52
+ }, [I, m, S, o, i, x, p, C]);
53
+ return e("button", { "aria-label": x ? void 0 : String(i), className: (() => {
54
+ switch (l) {
55
+ case "star":
56
+ return M(j("likert-star", g), j(`likert-star-${i}`, g));
57
+ case "smiley":
58
+ return M(j("likert-smiley", g), j(`likert-smiley-${i}`, g));
59
+ default:
60
+ return i === a ? M(j("likert-number", g), j(`likert-number-${i}`, g), j("likert-last-option", g)) : M(j("likert-number", g), j(`likert-number-${i}`, g));
61
+ }
62
+ })(), dangerouslySetInnerHTML: { __html: lt({ icon: r, scaleLabelType: l, value: i, selectedValue: o }) }, id: f, onClick: (y) => {
63
+ y.preventDefault(), y.stopPropagation(), d(i);
64
+ }, onKeyDown: (y) => {
65
+ var k, w;
66
+ const D = v.querySelectorAll(`.likert-${l ?? "number"}`), P = i - 1;
67
+ y.key === "ArrowRight" ? (k = D[P + 1]) == null || k.focus() : y.key === "ArrowLeft" ? (w = D[P - 1]) == null || w.focus() : y.key !== "Enter" && y.key !== " " || (y.preventDefault(), y.stopPropagation(), d(i));
68
+ }, onPointerDown: () => u(!0), onPointerEnter: () => c(i), onPointerLeave: () => {
69
+ c(-1), u(!1);
70
+ }, style: T, tabIndex: 0 });
71
+ }, ct = ({ className: t, labels: s, next: r, properties: n, questionId: a, type: l }) => {
72
+ const { border: o, useMobileStyling: d, viewDocument: c } = A((k) => ({ border: k.border, useMobileStyling: k.useMobileStyling, viewDocument: k.viewDocument })), [u, g] = H(-1), [i, v] = H(!1), [f, x] = H(null), p = s && s.left, C = s && s.right;
73
+ let I;
74
+ const { range: m, scaleLabelType: S, ratingIcons: T } = n;
75
+ m && (I = Number(m));
76
+ const y = I || 5, D = (k) => {
77
+ var w, b;
78
+ switch (S) {
79
+ case "star":
80
+ return (w = T[0]) == null ? void 0 : w.svg;
81
+ case "smiley":
82
+ return (b = T[k]) == null ? void 0 : b.svg;
83
+ default:
84
+ return String(k + 1);
85
+ }
86
+ }, P = [...Array(y)].map((k, w) => {
87
+ const b = w + 1;
88
+ return e(ot, { activeValue: u, border: o, icon: D(w), isPressed: i, range: y, scaleLabelType: S, selectedValue: f, setActiveValue: g, setIsPressed: v, setSelectedValue: x, useMobileStyling: d, value: b, viewDocument: c }, w);
89
+ });
90
+ return e("form", { className: M(t, "ul-card--likert", "fade-in-transition"), children: e(J, { properties: n, defaultBody: () => e(ae, { children: [e(re, { children: [e("div", { "aria-label": `Rating (1 - ${y})`, className: "ul-card--likert__numbers", role: "radiogroup", children: P }), e("div", { className: "ul-card--likert__labels", children: [e("span", { children: p }), e("span", { children: C })] })] }), e(te, { children: e(ie, { isDisabled: f === null && n.required, onClick: () => r({ value: f, questionId: a, type: l }, !0), children: X(n) }) })] }) }) }, a);
91
+ }, dt = ({ columns: t, onSelect: s, options: r, selectedOptions: n }) => {
92
+ const a = Y([]), { border: l, useMobileStyling: o } = A((v) => ({ border: v.border, useMobileStyling: v.useMobileStyling })), d = r.findIndex((v) => n[v.id] === null), [c, u] = H(d), g = ce((v, f) => {
93
+ s(v, f);
94
+ const x = c + 1, p = r[x];
95
+ p && n[p.id] === null && u(x);
96
+ }, [s, r, n, c]), i = ce((v, f) => {
97
+ const x = c === v;
98
+ return e(je, { animate: !0, header: f.label, isOpen: x, onClick: () => u(x && !window.UserLeap.isMobileSDK ? -1 : v), ref: (p) => {
99
+ p && (a.current[v] = p);
100
+ }, showHeaderCheck: n[f.id] !== null, children: e("div", { style: { paddingTop: "12px" }, children: t.map((p) => e(ke, { allowTextEntry: !1, ariaLabel: `${f.label}-${p.label}`, border: l, error: !1, id: `${f.id}-${p.value}`, isRadio: !0, isSelected: n[f.id] === p.value, label: p.label, onUserInputChanged: () => g(f.id, p.value), useMobileStyling: o }, p.label)) }) }, f.id);
101
+ }, [l, t, c, g, n, o]);
102
+ return e("div", { children: r.map((v, f) => i(f, v)) });
103
+ }, ut = ({ className: t, next: s, options: r, properties: n, questionId: a, type: l, onSubmitButtonClick: o }) => {
104
+ const d = n.matrixColumn, c = n.required, u = (x) => {
105
+ x.preventDefault(), x.stopPropagation(), s({ value: i, questionId: a, type: l }, !0), o && o();
106
+ }, g = r.reduce((x, p) => (x[p.id] = null, x), {}), [i, v] = H(g), f = (x, p) => {
107
+ v((C) => ({ ...C, [x]: p }));
108
+ };
109
+ return e("form", { className: M(t, "ul-card__matrix", "fade-in-transition"), id: "text-form", onSubmit: u, children: e(J, { properties: n, defaultBody: () => {
110
+ return e(ae, { children: [e(re, { children: e(dt, { columns: d, onSelect: f, options: r, selectedOptions: i }) }), e(te, { children: e(ie, { isDisabled: (x = i, c && Object.values(x).every((p) => p == null)), onClick: () => u(new SubmitEvent("submit")), children: X(n) }) })] });
111
+ var x;
112
+ } }) }, a);
113
+ }, Le = ({ className: t, onSubmit: s, options: r = [], properties: n, questionId: a, type: l, showIndividualSubmit: o = !1, onSubmitButtonClick: d }) => {
114
+ const { border: c, useMobileStyling: u } = A((h) => ({ border: h.border, useMobileStyling: h.useMobileStyling })), g = r.reduce((h, L) => (h[L.id] = { isSelected: !1 }, h), {}), [i, v] = H(g), f = l === "multiplechoice", x = n.required, p = r.find((h) => {
115
+ var L;
116
+ return (L = h.optionProperties) == null ? void 0 : L.noneOfTheAbove;
117
+ }), C = (h) => Object.entries(h).some(([L, $]) => {
118
+ var G;
119
+ const Q = r.find((Z) => `${Z.id}` === L), O = $.userText === void 0 || $.userText.trim() === "";
120
+ return ((G = Q == null ? void 0 : Q.optionProperties) == null ? void 0 : G.allowsTextEntry) && O && $.isSelected;
121
+ }), I = (h) => Object.values(h).filter((L) => L.isSelected).length, m = n.minSelect && n.minSelect > 0 && n.maxSelectMode === de.Range && I(i) < n.minSelect && (x || I(i) > 0), S = (h) => C(h) || x && !I(h) || !((L) => {
122
+ const { minSelect: $ = 0, maxSelect: Q = 1 / 0, maxSelectMode: O } = n, G = I(L);
123
+ switch (O) {
124
+ case de.Maximum:
125
+ return G <= Q;
126
+ case de.Range:
127
+ return G === 0 || G >= $;
128
+ default:
129
+ return !0;
130
+ }
131
+ })(h), T = Object.entries(i).some(([h, L]) => {
132
+ var $, Q;
133
+ return L.isSelected && ((Q = ($ = r.find((O) => `${O.id}` === h)) == null ? void 0 : $.optionProperties) == null ? void 0 : Q.allowsTextEntry);
134
+ }), y = o && (!f || T), D = (h) => {
135
+ b(h.id, h.selected, h.userText, h.noneOfTheAbove);
136
+ }, P = (h) => {
137
+ var L;
138
+ return (n == null ? void 0 : n.maxSelectMode) !== de.Unlimited && I(i) === (n == null ? void 0 : n.maxSelect) && !((L = i[h]) != null && L.isSelected);
139
+ }, k = r.map(({ id: h, label: L, value: $, optionProperties: Q }) => {
140
+ var se, ne;
141
+ const O = `${h}`, { allowsTextEntry: G, noneOfTheAbove: Z } = { allowsTextEntry: !1, noneOfTheAbove: !1, ...Q };
142
+ return e(ke, { allowTextEntry: G, border: c, disabled: P(O), error: (V = i, C(V)), id: O, isRadio: f, isSelected: !!((se = i[O]) != null && se.isSelected), label: L, noneOfTheAbove: Z, onUserInputChanged: D, promptText: "Please specify", text: (ne = i[h]) == null ? void 0 : ne.userText, useMobileStyling: u, value: $ }, O);
143
+ var V;
144
+ }), w = () => {
145
+ s(i, !0), d && d();
146
+ }, b = (h, L, $, Q) => {
147
+ const O = Object.assign({}, i);
148
+ if ((f || Q) && L) for (const G of Object.values(O)) G.isSelected = !1, delete G.userText;
149
+ else p && !Q && i[p.id].isSelected && (O[p.id].isSelected = !1);
150
+ O[h] = { isSelected: L, userText: $ }, v(O);
151
+ };
152
+ return e("form", { className: M(t, "ul-card--multiple", "fade-in-transition"), id: "text-form", onSubmit: w, children: e(J, { properties: n, defaultBody: () => e(ae, { children: [e(re, { children: [n.isDropdown ? e(Ke, { disabledOptions: r.filter((h) => P(h.id)), dropdownFooter: m ? e("div", { className: "ul-card__min-select-counter", style: { marginLeft: "16px" }, children: [I(i), "/", n.minSelect] }) : void 0, isMultiSelect: !f, multiselectText: n.dropdownMultiselectedText ?? "choices selected", onChange: (h) => {
153
+ const L = { ...i };
154
+ for (const $ of r) h.includes($) ? L[$.id].isSelected = !0 : L[$.id].isSelected = !1;
155
+ v(L);
156
+ }, options: r, placeholderText: n.dropdownPlaceholderText ?? (f ? "Select choice" : "Select choice(s)"), value: r.filter((h) => i[h.id].isSelected) }) : e("div", { className: M(j("ul-card__choices", u)), role: f ? "radiogroup" : "group", children: [k, !!m && e("div", { className: "ul-card__min-select-counter", children: [I(i), "/", n.minSelect] })] }), y && e(Xe, { handleSubmit: w, isSubmitDisabled: S(i) })] }), e(te, { children: e(ie, { isDisabled: S(i), onClick: w, children: X(n) }) })] }) }) }, a);
157
+ }, pt = (t) => {
158
+ const { questionId: s, type: r, next: n, options: a } = t;
159
+ return e(Le, { ...t, onSubmit: (l, o) => {
160
+ const d = Object.entries(l).find(([, v]) => v.isSelected) || [void 0, void 0], [c, u] = d, g = a.find((v) => `${v.id}` === c), i = u != null && u.userText ? { [c]: { userText: u.userText } } : null;
161
+ n({ value: g && c ? { [c]: g.value } : {}, secondaryValue: i, questionId: s, type: r }, o);
162
+ } });
163
+ }, mt = (t) => {
164
+ const { questionId: s, type: r, next: n } = t;
165
+ return e(Le, { ...t, onSubmit: (a, l) => {
166
+ const o = Object.entries(a).reduce((c, [u, g]) => (c[u] = g.isSelected, c), {}), d = Object.entries(a).reduce((c, [u, g]) => {
167
+ if (!g.userText) return c;
168
+ const i = c || {};
169
+ return i[u] = { userText: g.userText }, i;
170
+ }, null);
171
+ n({ value: o, secondaryValue: d, questionId: s, type: r }, l);
172
+ } });
173
+ }, gt = ({ className: t, labels: s, properties: r, next: n, questionId: a, type: l }) => {
174
+ const [o, d] = H(null), { border: c, useMobileStyling: u, viewDocument: g } = A((x) => ({ border: x.border, useMobileStyling: x.useMobileStyling, viewDocument: x.viewDocument })), i = s && s.left, v = s && s.right, f = [...Array(11)].map((x, p) => e("button", { className: M(j("nps-number", u), j(`nps-number-${p}`, u)), id: `option-${p}`, onClick: (C) => {
175
+ C.preventDefault(), C.stopPropagation(), d(p);
176
+ }, onKeyDown: (C) => {
177
+ var m, S;
178
+ const I = g.querySelectorAll("button.nps-number");
179
+ C.key === "ArrowRight" ? (m = I[p + 1]) == null || m.focus() : C.key === "ArrowLeft" ? (S = I[p - 1]) == null || S.focus() : C.key !== "Enter" && C.key !== " " || (C.preventDefault(), C.stopPropagation(), d(p));
180
+ }, onPointerDown: (C) => {
181
+ C.currentTarget.style.zIndex = "2", C.currentTarget.style.borderColor = c;
182
+ }, onPointerLeave: (C) => {
183
+ C.currentTarget.style.zIndex = "auto", C.currentTarget.style.borderColor = _e;
184
+ }, style: o === p ? { backgroundColor: c, color: "#fff" } : void 0, tabIndex: 0, children: p }, p));
185
+ return e("form", { className: M(t, "ul-card--nps", "fade-in-transition"), children: e(J, { properties: r, defaultBody: () => e(ae, { children: [e(re, { children: [e("div", { className: "ul-card--nps__numbers", children: f }), e("div", { className: "ul-card--nps__labels", children: [e("span", { children: i }), e("span", { children: v })] })] }), e(te, { children: e(ie, { isDisabled: o === null && r.required, onClick: () => n({ value: o, questionId: a, type: l }, !0), children: X(r) }) })] }) }) }, a);
186
+ }, ht = ({ className: t, next: s, properties: r, questionId: n, type: a, onSubmitButtonClick: l }) => {
187
+ const { border: o, useMobileStyling: d, update: c } = A((T) => ({ border: T.border, useMobileStyling: T.useMobileStyling, update: T.update })), [u, g] = H(""), i = Y(null), v = u.trim(), f = r.required === !0 && !v, x = We(i, () => c()), p = (T) => {
188
+ const { value: y } = T.currentTarget;
189
+ x(), T.preventDefault(), T.stopPropagation(), g(y);
190
+ }, C = (T) => {
191
+ T.preventDefault(), T.stopPropagation();
192
+ const y = r.required !== !0 || v.length > 0;
193
+ s({ value: u, questionId: n, type: a }, y), l && l();
194
+ }, I = r && r.openTextPlaceholder ? r.openTextPlaceholder : "", m = (T) => {
195
+ T.currentTarget.style.borderColor = o;
196
+ }, S = (T) => {
197
+ T.currentTarget.style.borderColor = _e;
198
+ };
199
+ return e("form", { className: M(t, "ul-card-text", "fade-in-transition"), id: "text-form", children: e(J, { defaultBody: () => e("div", { className: "ul-card-text", children: [e(re, { children: [e("div", { className: "ul-card-text__container", children: e("textarea", { "aria-describedby": "ul-caption", "aria-labelledby": "ul-question", "aria-multiline": "true", "aria-placeholder": I, className: M(j("ul-card-text__input", d)), "data-gramm": "false", maxLength: 5e3, name: "text", onBlur: S, onChange: p, onFocus: m, placeholder: I, ref: i, role: "textbox", tabIndex: 0 }) }), r.footerHtml && e("div", { className: "footer", dangerouslySetInnerHTML: { __html: r.footerHtml } })] }), e(te, { children: e(ie, { isDisabled: f, onClick: C, children: X(r) }) })] }), properties: r }) }, n);
200
+ }, vt = ({ className: t, labels: s, next: r, properties: n, questionId: a, type: l, onSubmitButtonClick: o, options: d }) => {
201
+ const c = Y(null), u = Y(0), g = Y(0), i = Y(null), v = Y(!1), f = Y([]), [x, p] = H(() => (n == null ? void 0 : n.required) === !0), [C, I] = H(() => d.map((_) => ({ ..._, rank: null }))), m = pe(() => Array.from({ length: d.length }, (_, q) => q + 1), [d.length]), { useMobileStyling: S, isPreview: T, headers: y } = A((_) => ({ useMobileStyling: _.useMobileStyling, isPreview: _.isPreview, headers: _.headers })), D = (y == null ? void 0 : y["userleap-platform"]) === "android", P = S && !T && !D, k = !P && !D, w = (_, q) => {
202
+ I((R) => {
203
+ const N = parseInt(q), E = R.map((U) => ({ ...U }));
204
+ E.some((U) => U.rank == null) && E.forEach((U, le) => U.rank = le + 1);
205
+ const z = E.findIndex((U) => U.id === _);
206
+ if (z === -1) return R;
207
+ const B = E[z].rank;
208
+ return N < B ? E.forEach((U) => {
209
+ U.id !== _ && U.rank >= N && U.rank < B && (U.rank = U.rank + 1);
210
+ }) : N > B && E.forEach((U) => {
211
+ U.id !== _ && U.rank > B && U.rank <= N && (U.rank = U.rank - 1);
212
+ }), E[z].rank = N, E.sort((U, le) => U.rank - le.rank), Z(), E;
213
+ });
214
+ }, b = (_, q) => {
215
+ for (let R = 0; R < f.current.length; R++) {
216
+ const N = f.current[R];
217
+ if (!N || N === i.current) continue;
218
+ const E = N.getBoundingClientRect();
219
+ if (_ >= E.left && _ <= E.right && q >= E.top && q <= E.bottom) return { element: N, index: R };
220
+ }
221
+ return null;
222
+ }, h = (_) => (q) => {
223
+ if (!P) return;
224
+ q.preventDefault(), q.stopPropagation(), v.current = !0, c.current = _;
225
+ const R = q.touches[0];
226
+ u.current = R.clientY, g.current = R.clientY;
227
+ const N = q.currentTarget.closest(".ul-card-rank__option");
228
+ N && (i.current = N, N.classList.add("is-dragging"));
229
+ }, L = (_) => {
230
+ if (!P || !v.current || c.current === null) return;
231
+ _.preventDefault(), _.stopPropagation();
232
+ const q = _.touches[0];
233
+ g.current = q.clientY;
234
+ const R = g.current - u.current;
235
+ i.current && (i.current.style.transform = `translateY(${R}px)`, i.current.style.zIndex = "1000"), f.current.forEach((E) => {
236
+ E && E !== i.current && E.classList.remove("is-drop-target");
237
+ });
238
+ const N = b(q.clientX, q.clientY);
239
+ N && N.element.classList.add("is-drop-target");
240
+ }, $ = (_) => {
241
+ if (!P || !v.current || c.current === null) return;
242
+ _.preventDefault(), _.stopPropagation();
243
+ const q = _.changedTouches[0], R = b(q.clientX, q.clientY);
244
+ i.current && (i.current.style.transform = "", i.current.style.zIndex = "", i.current.classList.remove("is-dragging")), f.current.forEach((N) => {
245
+ N && N.classList.remove("is-drop-target");
246
+ }), R && R.index !== c.current && Q(c.current, R.index), c.current = null, i.current = null, v.current = !1;
247
+ }, Q = (_, q) => {
248
+ I((R) => {
249
+ const N = R.map((z) => ({ ...z })), [E] = N.splice(_, 1);
250
+ return N.splice(q, 0, E), N.forEach((z, B) => {
251
+ z.rank = B + 1;
252
+ }), Z(), N;
253
+ });
254
+ }, O = (_) => {
255
+ _.preventDefault(), _.dataTransfer && (_.dataTransfer.dropEffect = "move");
256
+ }, G = (_) => {
257
+ const q = {};
258
+ _.reduce((R, N) => (R[N.id] = N.rank, R), q), r({ value: q, questionId: a, type: l }, !0);
259
+ }, Z = () => {
260
+ p(!1);
261
+ }, { left: V, right: se } = s, ne = d.length, Qe = (_) => {
262
+ _.preventDefault(), _.currentTarget.classList.add("is-drop-target");
263
+ }, Ge = (_) => {
264
+ _.currentTarget.classList.remove("is-drop-target");
265
+ }, Ve = (_) => {
266
+ c.current = null, _.currentTarget.classList.remove("is-dragging");
267
+ };
268
+ return e("form", { className: M(t, "ul-card-rank", "fade-in-transition"), onSubmit: (_) => {
269
+ _.preventDefault(), G(C), o && o();
270
+ }, children: e(J, { properties: n, defaultBody: () => e(ae, D ? { children: [e(re, { children: e("div", { className: "ul-card--rank__question-inner-container", children: [e("div", { className: "ul-card-rank__labels", children: e("span", { children: ["1 - ", V] }) }), e("ol", { className: "ul-card-rank__list", children: C.map(({ id: _, label: q, rank: R }) => e("li", { className: "ul-card-rank__option", children: [e("select", { "aria-label": `Rank for ${q}`, className: M("ul-card-rank__select", R == null && "ul-card-rank__select--placeholder"), name: `rank[${_}]`, onChange: (N) => w(_, N.currentTarget.value), value: R ?? "", children: [R == null && e("option", { className: "ul-card-rank__select-option", disabled: !0, value: "", children: "-" }), m.map((N) => e("option", { className: "ul-card-rank__select-option", value: N, children: N }, `${N}-${a}`))] }), e("span", { children: q })] }, _)) }), e("div", { className: "ul-card-rank__labels", children: e("span", { children: [ne, " - ", se] }) })] }) }), e(te, { children: e("div", { className: "ul-card__button-wrapper", children: e(W, { disabled: x, children: X(n) }) }) })] } : { children: [e(re, { children: e("div", { className: "ul-card--rank__question-inner-container", children: [e("div", { className: "ul-card-rank__labels", children: e("span", { children: ["1 - ", V] }) }), e("ol", { className: "ul-card-rank__list", onDragOver: D ? void 0 : O, children: C.map(({ id: _, label: q, rank: R }, N) => {
271
+ return e("li", { className: "ul-card-rank__option", draggable: !!k || void 0, onDragEnd: k ? Ve : void 0, onDragEnter: k ? Qe : void 0, onDragLeave: k ? Ge : void 0, onDragStart: k ? (z = N, (B) => {
272
+ c.current = z, B.dataTransfer && (B.dataTransfer.effectAllowed = "move", B.dataTransfer.setData("text/plain", String(z)), B.currentTarget.classList.add("is-dragging"));
273
+ }) : void 0, onDrop: k ? (E = N, (B) => {
274
+ var le, Ne;
275
+ B.preventDefault(), B.currentTarget.classList.remove("is-drop-target");
276
+ const U = c.current;
277
+ c.current = null, (Ne = (le = B.currentTarget.closest(".ul-card-rank__list")) == null ? void 0 : le.querySelector(".is-dragging")) == null || Ne.classList.remove("is-dragging"), U != null && U !== E && Q(U, E);
278
+ }) : void 0, ref: (B) => f.current[N] = B, children: [e("select", { "aria-label": `Rank for ${q}`, className: M("ul-card-rank__select", R == null && "ul-card-rank__select--placeholder"), name: `rank[${_}]`, onChange: (B) => w(_, B.currentTarget.value), value: R ?? "", children: [R == null && e("option", { className: "ul-card-rank__select-option", disabled: !0, value: "", children: "-" }), m.map((B) => e("option", { className: "ul-card-rank__select-option", value: B, children: B }, B))] }), e("span", { children: q }), !D && e("button", { "aria-label": `Drag ${q} to reorder`, className: "ul-card-rank__drag-btn", onTouchEnd: P ? $ : void 0, onTouchMove: P ? L : void 0, onTouchStart: P ? h(N) : 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" }) }) })] }, _);
279
+ var E, z;
280
+ }) }), e("div", { className: "ul-card-rank__labels", children: e("span", { children: [ne, " - ", se] }) })] }) }), e(te, { children: e("div", { className: "ul-card__button-wrapper", children: e(W, { disabled: x, children: X(n) }) }) })] }) }) }, a);
281
+ }, ve = 1, Me = 2, Ue = 3, ue = (t) => t.type === "av_permission", Ie = (t) => t.type === "screen_permission", Ee = (t, s) => t === void 0 ? ve : t ? ((r, n) => !(ue(n) ? n.permissionDescriptors : []).includes("camera") || r.getVideoTracks().length > 0)(t, s) ? Ue : ve : Me, we = { avStream: null, currentPage: null, mediaRecordingUids: null, nextQuestion: () => {
282
+ }, passthroughData: void 0, recordingMediaTypes: void 0, screenPermissionRequested: !1, type: void 0 }, K = Fe((t) => ({ ...we, reset: () => {
283
+ t(we);
284
+ }, updatePage: (s) => {
285
+ t(s);
286
+ } }));
287
+ function be({ currentPage: t, pages: s }) {
288
+ const { avStream: r, recordingMediaTypes: n, updatePage: a } = K.getState(), { recorderEventEmitter: l } = A.getState();
289
+ l.emit("av.permission", { "permission.descriptors": t.permissionDescriptors, "stream.ready": (o, d) => {
290
+ if (r === o) return;
291
+ let c = t;
292
+ if (o && !t.permissionDescriptors.includes("camera")) {
293
+ const u = s.indexOf(t), g = d != null && d.active ? u + 2 : u + 1;
294
+ d != null && d.active && n && l.emit("begin.recording", { "recording.media.types": n, "start.recording.callback": (i) => a({ mediaRecordingUids: i }) }), c = s[g];
295
+ }
296
+ a({ currentPage: c, avStream: o });
297
+ } });
298
+ }
299
+ function ye({ status: t }) {
300
+ const { nextQuestion: s, passthroughData: r, mediaRecordingUids: n, reset: a } = K.getState(), { recorderEventEmitter: l, handleUploadUpdate: o, index: d } = A.getState(), c = { value: { taskStatus: t }, type: "recordedtask", questionId: (r == null ? void 0 : r.questionId) || 1 };
301
+ r && l.emit("finish.task", { "begin.callback": (u) => {
302
+ o({ mediaRecordingUid: u, isSubmitted: !0, progressPct: 0, isComplete: !1 });
303
+ }, "progress.callback": (u, g) => {
304
+ o({ mediaRecordingUid: u, progressPct: g.detail, isSubmitted: !1, isComplete: !1 });
305
+ }, "upload.callback": (u) => {
306
+ u && o({ mediaRecordingUid: u, isComplete: !0, isSubmitted: !0, progressPct: 100 });
307
+ }, "passthrough.data": r, "current.index": d, "task.response": c, "task.complete.callback": (u) => {
308
+ c.value.taskDurationMillisecond = u, n && (c.value.mediaRecordingUids = n), a(), s(c);
309
+ } });
310
+ }
311
+ function Ce({ pages: t, setIsRequestingPermission: s }) {
312
+ const { recorderEventEmitter: r, eventEmitFn: n } = A.getState(), { updatePage: a, currentPage: l, recordingMediaTypes: o, screenPermissionRequested: d } = K.getState();
313
+ if (!l) return;
314
+ const c = t.indexOf(l);
315
+ switch (l.type) {
316
+ case "av_permission": {
317
+ const u = d ? c + 2 : c + 1;
318
+ return d && o && r.emit("begin.recording", { "recording.media.types": o, "start.recording.callback": (g) => {
319
+ a({ mediaRecordingUids: g });
320
+ } }), void a({ currentPage: t[u] });
321
+ }
322
+ case "screen_permission":
323
+ return void r.emit("screen.permission", { "screen.permission.requested": s, "stream.ready.callback": (u, g) => {
324
+ const i = g ? t[c + 1] : l;
325
+ g && o && r.emit("begin.recording", { "recording.media.types": o, "start.recording.callback": (v) => {
326
+ a({ captureStream: g, mediaRecordingUids: v });
327
+ } }), a({ currentPage: i, screenPermissionRequested: !0, captureStream: g });
328
+ } });
329
+ case "start_task":
330
+ return n("recorded.task.start"), r.emit("recorded.task.start"), r.emit("start.task"), void a({ currentPage: t[c + 1], screenPermissionRequested: !0 });
331
+ case "complete_task":
332
+ return;
333
+ }
334
+ }
335
+ const Be = "ul-permission-graphics-container", Ae = "ul-permission-body", $e = M(Be, "ul_recorded-task-inset-spacing"), me = M("ul-horizontal-button-container", "ul-horizontal-button-container-left"), Oe = ({ richTextBody: t }) => e("div", { className: "ul-rich-text-body", dangerouslySetInnerHTML: { __html: t }, id: "ul-task-detail-container" }), ge = ({ required: t, skipButtonText: s, bottom: r = !1 }) => t ? null : e(W, { className: M(r && "ul-skip-button-below", "ul-button-inactive"), onClick: ye.bind(null, { status: "abandoned" }), children: s || "Skip" }), Te = (t) => {
336
+ const { avStream: s, captureStream: r, recordingMediaTypes: n, updatePage: a } = K.getState(), l = (n == null ? void 0 : n.includes("audio")) || (n == null ? void 0 : n.includes("video"));
337
+ ee(() => {
338
+ const o = setInterval(() => {
339
+ l && s && !s.active ? a({ avStream: null, currentPage: t[0] }) : r && r.active || a({ captureStream: void 0, currentPage: t[l ? 1 : 0] });
340
+ }, 1e3);
341
+ return () => clearInterval(o);
342
+ }, [s, r, l, t, n, a]);
343
+ }, bt = ({ content: t, pages: s, required: r }) => {
344
+ const { buttonText: n, skipButtonText: a, taskDetail: l } = t;
345
+ return Te(s), e("div", { className: "ul-task-page", children: [l && e(Oe, { richTextBody: l }), e("div", { className: me, children: [e(W, { onClick: Ce.bind(null, { pages: s }), children: n }), e(ge, { required: r, skipButtonText: a })] })] }, "start-task");
346
+ }, yt = ({ content: t, pages: s, properties: r }) => {
347
+ const { buttonText: n, skipButtonText: a } = t;
348
+ Te(s);
349
+ const l = e(J, { properties: r, defaultBody: () => e("div", { className: me, children: [e(W, { className: "ul-complete-task-button", onClick: ye.bind(null, { status: "completed" }), children: n }), e(W, { className: M("ul-button-inactive"), onClick: ye.bind(null, { status: "given.up" }), children: a })] }) });
350
+ return e("div", { className: "ul-task-page", children: [t.taskDetail && e(Oe, { richTextBody: t.taskDetail }), l] }, "complete-task");
351
+ }, ft = ({ content: t, pages: s, required: r }) => {
352
+ const { buttonText: n, skipButtonText: a } = t, [l] = A((c) => [c.tabTitle]), [o, d] = H(!1);
353
+ return e("div", { children: [e("div", { className: $e, children: [e("p", { style: { marginTop: "auto" }, children: t.selectTabText }), e("div", { className: "ul-select-tab-container", children: e("p", { className: Ae, children: l }) })] }), e("div", { className: r ? "" : me, children: [e(W, { disabled: o, onClick: Ce.bind(null, { pages: s, setIsRequestingPermission: d }), children: n }), e(ge, { required: r, skipButtonText: a })] })] });
354
+ }, kt = ({ content: t }) => e("div", { className: M(Be, "ul_permission_svg_container", "ul_recorded-task-inset-spacing", "ul-center-horizontally"), dangerouslySetInnerHTML: { __html: t.svg } }, "ul-permission-request-graphic"), xt = ({ content: t, pages: s, required: r }) => {
355
+ const { permissionDeniedHeadline: n, permissionDeniedBody: a, skipButtonText: l, tryAgainButtonText: o } = t, d = ue(s[0]) ? s[0] : null;
356
+ return ee(() => {
357
+ const c = setInterval(() => {
358
+ d !== null && be({ currentPage: d, pages: s });
359
+ }, 1e3);
360
+ return () => clearInterval(c);
361
+ }, [d, s]), d ? e("div", { children: [e("div", { className: $e, children: e("p", { className: "ul-av-permission-denied-paragraph", children: [e("span", { className: "ul-av-permission-denied-headline", children: n }), e("span", { className: Ae, children: a })] }) }), e("div", { className: me, children: [e(W, { onClick: be.bind(null, { currentPage: d, pages: s }), children: o }), e(ge, { required: r, skipButtonText: l })] })] }) : null;
362
+ }, _t = ({ stream: t }) => e("video", { autoPlay: !0, className: M("ul_recorded-task-inset-spacing"), id: "ul-record-task-video-preview", muted: !0, ref: (s) => {
363
+ s && (s.srcObject = t || null);
364
+ } }), St = ({ content: t, pages: s, required: r }) => {
365
+ const { skipButtonText: n } = t, { avStream: a } = K.getState();
366
+ return Te(s), e("div", { children: [e(_t, { stream: a }), e("div", { className: "ul-vertical-button-container-center", children: [e(W, { onClick: Ce.bind(null, { pages: s }), children: t.buttonText }), e(ge, { bottom: !0, required: r, skipButtonText: n })] })] });
367
+ }, Ct = ({ properties: t }) => {
368
+ const { pages: s, required: r } = t, { avStream: n, currentPage: a } = K.getState();
369
+ if (a === void 0) return null;
370
+ switch (a == null ? void 0 : a.type) {
371
+ case "av_permission": {
372
+ const l = Ee(n, a);
373
+ return l === ve ? e(kt, { content: a }) : e(l === Me ? xt : St, { content: a, pages: s, required: r });
374
+ }
375
+ case "screen_permission":
376
+ return e(ft, { content: a, pages: s, required: r });
377
+ case "start_task":
378
+ return e(bt, { content: a, pages: s, required: r });
379
+ case "complete_task":
380
+ return e(yt, { content: a, pages: s, properties: t });
381
+ default:
382
+ return null;
383
+ }
384
+ }, Tt = ({ className: t, properties: s, next: r, questionId: n }) => {
385
+ const a = A(), { surveyId: l, responseGroupUid: o, userId: d } = a, c = K(), { screenPermissionRequested: u } = c, g = K((p) => p.avStream);
386
+ let i = K((p) => p.currentPage);
387
+ i || (i = function({ pages: p, userId: C, responseGroupUid: I, surveyId: m, questionId: S, next: T }) {
388
+ const { updatePage: y } = K.getState(), { eventEmitFn: D, recorderEventEmitter: P } = A.getState(), k = { questionId: S, surveyId: m, visitorId: C, responseGroupUid: I };
389
+ let w = 0;
390
+ P.emit("recorded.task.permission.screen"), D("recorded.task.permission.screen"), P.emit("permission.status", { "permission.status.callback": (h, L, $, Q) => {
391
+ const O = p[w], { type: G } = O, Z = ["screen"];
392
+ if (ue(O)) {
393
+ const { permissionDescriptors: V } = O, se = V == null ? void 0 : V.includes("microphone"), ne = V == null ? void 0 : V.includes("camera");
394
+ se && Z.push("audio"), ne && Z.push("video"), (h != null && h.active && !ne || h != null && h.active && L) && w++;
395
+ }
396
+ Ie(p[w]) && $ && (w++, P.emit("begin.recording", { "recording.media.types": Z, "start.recording.callback": (V) => y({ mediaRecordingUids: V }) })), y({ currentPage: p[w], avStream: h, screenPermissionRequested: $, nextQuestion: T, type: G, passthroughData: k, recordingMediaTypes: Z, captureStream: Q });
397
+ } });
398
+ const b = p[w];
399
+ return b.type === "av_permission" && be({ currentPage: b, pages: p }), b;
400
+ }({ questionId: n, surveyId: l, next: (p) => {
401
+ r(p, !0);
402
+ }, pages: s.pages, responseGroupUid: o, userId: d }));
403
+ let v = i.headline, f = i.captionText;
404
+ const x = Ee(g, i);
405
+ return Ie(i) && u && (v = i.permissionDeniedHeadline, f = i.permissionDeniedCaptionText), ue(i) && x === Ue && (v = i.permissionGrantedHeadline, f = i.permissionGrantedCaptionText), e("div", { className: M(t, "ul-center-horizontally", "fade-in-transition"), children: [e(xe, { message: v, properties: { captionText: f } }), e(re, { children: e(Ct, { properties: s }) })] });
406
+ }, Nt = ({ className: t, next: s, properties: r, questionId: n, type: a }) => {
407
+ const { visitorAttributes: l, isLongFormSurvey: o } = A((i) => ({ visitorAttributes: i.visitorAttributes, isLongFormSurvey: Re(i.studyType) })), d = (i, v = !1) => {
408
+ s({ value: v ? { skipped: !0 } : void 0, questionId: n, type: a }, !0);
409
+ }, c = (i) => {
410
+ i.key !== "Enter" && i.key !== " " || s({ value: void 0, questionId: n, type: a }, !0);
411
+ }, u = Je(r && r.buttonUrl, l), g = o && r.promptActionType === et.NO_BUTTON ? () => e(ae, {}) : () => e("div", { children: e("div", { className: "ul-card-button-group", children: [e("a", { className: "ul-card-text__button ul-card__text-url-prompt-button", href: u, id: "ul-card-text__button", onClick: d, onKeyPress: c, rel: "noreferrer", role: u ? "link" : "button", tabIndex: 0, target: "_blank", children: X(r) }), r.required === !1 && e("button", { className: "ul-card-skip__button", onClick: (i) => d(0, !0), children: fe(r) })] }) });
412
+ return e("div", { className: M(t, "ul-card__text-url-prompt", "fade-in-transition"), children: e(J, { defaultBody: g, properties: r }) }, n);
413
+ }, It = ({ className: t, questionId: s }) => {
414
+ const { border: r, destroy: n, endCard: a, forceBrandedLogo: l } = A((c) => ({ border: c.border, destroy: c.destroy, endCard: c.endCard, forceBrandedLogo: c.forceBrandedLogo }));
415
+ ee(() => {
416
+ setTimeout(() => {
417
+ n(Se);
418
+ }, l ? 4e3 : 2e3);
419
+ }, [n, l]);
420
+ const o = a && a.subheader ? e("p", { className: "ul-caption", children: a.subheader }) : null, d = a && a.headline ? a.headline : "";
421
+ return e("div", { className: M(t, "ul-card--thanks", "fade-in-transition"), children: e("div", { children: e("div", { className: "ul-card--thanks-content", children: [e("div", { className: "ul-thanks-check", children: e("svg", { "aria-labelledby": "title", fill: "none", height: "99", viewBox: "0 0 81 99", width: "81", xmlns: "http://www.w3.org/2000/svg", children: [e("path", { clipRule: "evenodd", d: "M40.5 77C60.9345 77 77.5 60.4345 77.5 40C77.5 19.5655 60.9345 3 40.5 3C20.0655 3 3.5 19.5655 3.5 40C3.5 60.4345 20.0655 77 40.5 77ZM80.5 40C80.5 62.0914 62.5914 80 40.5 80C18.4086 80 0.5 62.0914 0.5 40C0.5 17.9086 18.4086 0 40.5 0C62.5914 0 80.5 17.9086 80.5 40Z", fill: r, 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: r, 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(xe, { message: d }), o] }) }) }, s);
422
+ }, wt = () => e("div", { className: "thinking-dots-container", children: e("div", { className: "thinking-dot" }) }), Dt = ({ className: t }) => {
423
+ const { uploadProgress: s } = A((l) => ({ uploadProgress: l.uploadProgress }));
424
+ let r, n;
425
+ Object.values(s).filter((l) => l.isSubmitted).length > 1 ? (r = "Your responses are processing", n = "Please keep this tab open until your responses are fully processed.") : (r = "Your response is processing", n = "Please keep this tab open until your response is fully processed.");
426
+ const a = Math.round(Math.min(99, ...Object.values(s).filter((l) => l.isSubmitted).map((l) => l.progressPct || 0)));
427
+ return e("div", { className: M(t, "ul-card--uploading", "fade-in-transition"), children: [e("div", { "aria-busy": "true", "aria-label": "Processing...", "aria-live": "polite", className: "ul-loading-spinner-container", role: "progressbar", children: e("div", { className: "ul-loading-spinner", children: [e("div", { className: "first" }), e("div", { className: "second" }), e("div", { className: "third" }), e("div", { className: "fourth" })] }) }), e(xe, { message: `${r} (${a}% complete)` }), e("p", { className: "ul-caption", children: n })] });
428
+ }, De = 0, qe = 1, qt = ({ className: t, next: s, properties: r, questionId: n, type: a }) => {
429
+ const l = `ul-card-video__player_recorder-q${n}`, { apiURL: o, envId: d, handleUploadUpdate: c, headers: u, responseGroupUid: g, surveyId: i, update: v, viewDocument: f, visitorId: x } = A((b) => ({ apiURL: b.apiURL, envId: b.envId, handleUploadUpdate: b.handleUploadUpdate, headers: b.headers, responseGroupUid: b.responseGroupUid, surveyId: b.surveyId, update: b.update, viewDocument: b.viewDocument, visitorId: b.userId })), [p, C] = H(!1), [I, m] = H(null), [S, T] = H(null), [y, D] = H(De), P = Y(null);
430
+ ee(() => {
431
+ const b = P.current, h = new ResizeObserver(() => {
432
+ v();
433
+ });
434
+ return b && h.observe(b), () => {
435
+ b && h.unobserve(b);
436
+ };
437
+ }, [v]);
438
+ const k = (b, h) => {
439
+ b === F.UPLOAD_STARTED ? (m(h[F.UPLOAD_ID]), T(h[F.MEDIA_RECORDING_UID]), C(!0)) : b === F.DELETE ? (m(null), T(null), C(!1)) : b === F.UPLOAD_PROGRESS ? isNaN(h[F.UPLOAD_PROGRESS_PCT]) ? c({ mediaRecordingUid: h[F.MEDIA_RECORDING_UID], isComplete: !0 }) : c({ mediaRecordingUid: h[F.MEDIA_RECORDING_UID], progressPct: h[F.UPLOAD_PROGRESS_PCT] }) : b === F.UPLOAD_FINISHED && c({ mediaRecordingUid: h[F.MEDIA_RECORDING_UID], isComplete: !0 });
440
+ }, w = (b) => {
441
+ b.preventDefault(), b.stopPropagation(), document.getElementById(l) && nt(l), I && S ? (c({ mediaRecordingUid: S, isSubmitted: !0 }), s({ value: { mediaRecordingUid: S }, questionId: n, type: a }, !0)) : s({ value: null, questionId: n, type: a }, !0);
442
+ };
443
+ return e("form", { className: M(t, "ul-card--video", "fade-in-transition"), id: "ul-video-interview-form", children: [e(re, { children: [e("div", { id: "ul-question-player-container", ref: P, style: { display: y === De ? "" : "none" }, children: e(J, { defaultBody: () => e("button", { className: "ul-video-btn ul-record-response-btn", onClick: (b) => {
444
+ b.preventDefault(), b.stopPropagation(), document.getElementById(l) && tt(l), D(qe);
445
+ } }), properties: r }) }), e("div", { style: { display: y === qe ? "block" : "none" }, children: e("div", { id: "ul-recorder-player-container", ref: (b) => {
446
+ if (b && b.children.length === 0) {
447
+ const h = rt(l, { surveyId: i, responseGroupUid: g, questionId: n, visitorId: x, envId: d }, o, k, void 0, { ...u, "x-ul-video-recorder-origin": "sdk" }, r.mediaType === F.MEDIA_TYPE_AUDIO, f);
448
+ b.appendChild(h);
449
+ }
450
+ } }) })] }), e(te, { children: [e(ie, { isDisabled: !!r.required && !p, onClick: w, children: X(r) }), e("button", { className: "ul-card-text__button ul-button-inactive ul-card-skip__button", id: "ul-card-video__skip_button", onClick: w, style: { ...r.required ? { display: "none" } : {}, ...p ? { display: "none" } : {} }, children: fe(r) })] })] });
451
+ }, He = (t) => t.type === "thanks" || t.type === "uploading", Pt = ({ card: t, avatars: s, isThinking: r, isCurrentQuestion: n, currentQuestionBubbleRef: a }) => {
452
+ const l = ((o) => "properties" in o.props && o.props.properties && "questionHtml" in o.props.properties && o.props.properties.questionHtml ? { content: o.props.properties.questionHtml, isHtml: !0 } : "message" in o.props ? { content: o.props.message, isHtml: !1 } : { content: "Question", isHtml: !1 })(t);
453
+ return e(oe, { avatars: s, isLeft: !0, message: { id: `question-${t.name}`, type: "question", content: l.content }, ref: n ? a : null, children: r ? e(wt, {}) : e(ae, { children: [l.isHtml ? e("div", { className: "chat-message-text", dangerouslySetInnerHTML: { __html: l.content } }) : e("div", { className: "chat-message-text", children: l.content }), t.type === "videovoice" && e(at, { properties: t.props, questionId: t.name, surveyVideoUrl: t.props.properties.videoUrl })] }) });
454
+ }, Rt = ({ card: t, avatars: s }) => {
455
+ const r = ((n) => {
456
+ if (!("properties" in n.props) || !n.props.properties || typeof n.props.properties != "object") return null;
457
+ const a = n.props.properties, l = [{ key: "captionHtml", isHtml: !0 }, { key: "captionText", isHtml: !1 }, { key: "richTextBody", isHtml: !0 }, { key: "body", isHtml: !1 }];
458
+ for (const { key: o, isHtml: d } of l) {
459
+ const c = a[o];
460
+ if (typeof c != "string") continue;
461
+ const u = c.trim();
462
+ if (u) {
463
+ if (d && !u.replaceAll(/<[^>]*>/g, "").trim()) continue;
464
+ return { content: u, isHtml: d };
465
+ }
466
+ }
467
+ return null;
468
+ })(t);
469
+ return r ? e(oe, { avatars: s, hideAvatar: !0, isLeft: !0, message: { id: `caption-${t.name}`, type: "question", content: r.content }, children: r.isHtml ? e("div", { className: "chat-message-text", dangerouslySetInnerHTML: { __html: r.content } }) : e("div", { className: "chat-message-text", children: r.content }) }) : null;
470
+ }, Lt = ({ card: t, userResponse: s, avatars: r }) => {
471
+ const n = ((a, l) => {
472
+ if (a.type === "open" && l && typeof l == "object" && "value" in l) return l.value;
473
+ })(t, s);
474
+ return e("div", { className: "chat-bubble-container chat-right", children: [e("div", { className: "chat-bubble chat-bubble-right chat-bubble-text-only", children: e("div", { className: "chat-message-text", children: n || e("div", { className: "chat-message-no-response", children: "No response" }) }) }), e("img", { alt: "User Avatar", className: "chat-avatar chat-avatar-right", srcSet: `${r.respondentAvatar["1x"]} 1x, ${r.respondentAvatar["2x"]} 2x` })] });
475
+ }, Mt = ({ card: t, avatars: s, isCurrentQuestion: r, currentQuestionBubbleRef: n }) => {
476
+ const { endCard: a } = A((l) => ({ endCard: l.endCard }));
477
+ return e(ae, { children: [e(oe, { avatars: s, isLeft: !0, message: { id: `thanks-${t.name}`, type: "question", content: (a == null ? void 0 : a.headline) ?? "Great! Thank you for your participation." }, ref: r ? n : null }), (a == null ? void 0 : a.subheader) && e(oe, { avatars: s, hideAvatar: !0, isLeft: !0, message: { id: `caption-${t.name}`, type: "question", content: a.subheader } }), e(it, {})] });
478
+ }, Ut = ({ card: t, cardIndex: s, index: r, avatars: n, cardResponses: a, questionThinkingStates: l, startingQuestionIdx: o, currentQuestionBubbleRef: d, handleCardResponse: c }) => {
479
+ const u = s === r, g = s < r, i = He(t);
480
+ if (i) return e(Mt, { avatars: n, card: t, currentQuestionBubbleRef: d, isCurrentQuestion: u });
481
+ const v = `${t.name}`, f = a.get(v), x = t.type === "open", p = l.get(v), C = s > (o ?? 0) && t.type !== "thanks" && t.type !== "uploading" && (p === !0 || p === void 0);
482
+ return e(Pe.Fragment, { children: [e(Pt, { avatars: n, card: t, currentQuestionBubbleRef: d, isCurrentQuestion: u, isThinking: C }), !C && e(Rt, { avatars: n, card: t }), g && x ? e(Lt, { avatars: n, card: t, userResponse: f }) : (!g || !x) && !C && e(oe, { avatars: n, isLeft: !1, message: { id: `card-${t.name}`, type: "card", content: "" }, children: e("div", { className: "chat-card-container", children: e(Bt, { card: t, className: i ? "chat-thanks-card" : "chat-card", isAnswered: g, next: u ? c : () => {
483
+ } }) }) })] }, `question-card-${t.name}`);
484
+ }, oe = Pe.forwardRef(({ message: t, isLeft: s = !1, children: r, avatars: n, hideAvatar: a = !1 }, l) => {
485
+ const o = s ? "chat-bubble-left" : "chat-bubble-right";
486
+ return e("div", { className: `chat-bubble-container ${s ? "chat-left" : "chat-right"}${s && a ? " chat-no-avatar" : ""}`, ref: l, children: [s && !a && e("img", { alt: "AI Avatar", className: "chat-avatar chat-avatar-left", srcSet: `${n.agentAvatar["1x"]} 1x, ${n.agentAvatar["2x"]} 2x` }), e("div", { className: `chat-bubble ${o}`, children: r || e("div", { className: "chat-message-text", children: t.content }) }), !s && !a && e("img", { alt: "User Avatar", className: "chat-avatar chat-avatar-right", srcSet: `${n.respondentAvatar["1x"]} 1x, ${n.respondentAvatar["2x"]} 2x` })] });
487
+ });
488
+ oe.displayName = "ChatBubble";
489
+ const Et = () => {
490
+ const t = A((r) => r.close), s = pe(() => () => t(Se), [t]);
491
+ return e("div", { "aria-label": "Close button", className: "conversational-close-btn", onClick: s, onKeyPress: (r) => {
492
+ r.key === "Enter" && s();
493
+ }, role: "button", tabIndex: 0, children: e("svg", { fill: "none", height: "16px", viewBox: "0 0 13 13", width: "16px", xmlns: "http://www.w3.org/2000/svg", children: e("path", { d: "M2.54964 1.78369L1.78369 2.54964L5.73405 6.5L1.78369 10.4504L2.54964 11.2163L6.5 7.26595L10.4504 11.2163L11.2163 10.4504L7.26595 6.5L11.2163 2.54964L10.4504 1.78369L6.5 5.73405L2.54964 1.78369Z", fill: "#262136" }) }) });
494
+ }, Bt = ({ card: t, next: s, className: r = "", isAnswered: n = !1 }) => {
495
+ const a = { className: n ? `${r} answered-card` : r, next: n ? () => {
496
+ } : s, questionId: t.name, type: t.type, isAnswered: n };
497
+ switch (t.type) {
498
+ case "consentlegal":
499
+ return e(st, { ...a, ...t.props });
500
+ case "likert":
501
+ return e(ct, { ...a, ...t.props });
502
+ case "matrix":
503
+ return e(ut, { ...a, ...t.props });
504
+ case "multiplechoice":
505
+ return e(pt, { ...a, ...t.props });
506
+ case "multipleselect":
507
+ return e(mt, { ...a, ...t.props });
508
+ case "nps":
509
+ return e(gt, { ...a, ...t.props });
510
+ case "open":
511
+ return e(ht, { ...a, ...t.props });
512
+ case "rankorder":
513
+ return e(vt, { ...a, ...t.props });
514
+ case "recordedtask":
515
+ return e(Tt, { ...a, ...t.props });
516
+ case "texturlprompt":
517
+ return e(Nt, { ...a, ...t.props });
518
+ case "thanks":
519
+ return e(It, { ...a, ...t.props });
520
+ case "uploading":
521
+ return e(Dt, { ...a, ...t.props });
522
+ case "videovoice":
523
+ return e(qt, { ...a, ...t.props });
524
+ default:
525
+ return null;
526
+ }
527
+ }, Qt = ({ cards: t, next: s, previousResponses: r }) => {
528
+ const { messagesContainerRef: n, currentQuestionBubbleRef: a, scrollToCurrentQuestion: l } = (() => {
529
+ const m = Y(null), S = Y(null), T = ce(() => {
530
+ if (S.current && m.current) {
531
+ const y = m.current, D = S.current.offsetTop - y.offsetTop - 16;
532
+ y.scrollTo({ top: Math.max(0, D), behavior: "smooth" });
533
+ }
534
+ }, []);
535
+ return { messagesContainerRef: m, currentQuestionBubbleRef: S, scrollToCurrentQuestion: T };
536
+ })(), { cardResponses: o, setCardResponse: d } = (() => {
537
+ const [m, S] = H(/* @__PURE__ */ new Map());
538
+ return { cardResponses: m, setCardResponse: ce((T, y) => {
539
+ S((D) => new Map(D).set(T, y));
540
+ }, []) };
541
+ })(), { index: c, isLongFormSurvey: u, avatars: g, startingQuestionIdx: i } = A((m) => ({ index: m.index, isLongFormSurvey: Re(m.studyType), avatars: m.avatars, startingQuestionIdx: m.startingQuestionIdx })), v = ((m, S, T) => {
542
+ const [y, D] = H(/* @__PURE__ */ new Map());
543
+ return ee(() => {
544
+ if (m.length > 0 && S < m.length) {
545
+ const P = m[S], k = `${P.name}`;
546
+ if (S <= (T ?? 0) || He(P)) return void D((b) => new Map(b).set(k, !1));
547
+ D((b) => new Map(b).set(k, !0));
548
+ const w = setTimeout(() => {
549
+ D((b) => new Map(b).set(k, !1));
550
+ }, 1e3);
551
+ return () => clearTimeout(w);
552
+ }
553
+ }, [S, m, T]), y;
554
+ })(t, c, i), f = ((m, S) => {
555
+ const [T, y] = H(/* @__PURE__ */ new Set([0]));
556
+ return ee(() => {
557
+ y((D) => new Set(D).add(m));
558
+ }, [m]), ee(() => {
559
+ const D = S ?? 0;
560
+ D > 0 && y((P) => {
561
+ const k = new Set(P);
562
+ for (let w = 0; w <= D; w++) k.add(w);
563
+ return k;
564
+ });
565
+ }, [S]), T;
566
+ })(c, i), x = pe(() => ({ ...r, ...Ze(t.map((m, S) => {
567
+ var T, y;
568
+ return { ...m, value: S < c ? ((T = o.get(`${m.name}`)) == null ? void 0 : T.value) ?? null : null, secondaryValue: S < c ? ((y = o.get(`${m.name}`)) == null ? void 0 : y.secondaryValue) ?? null : null };
569
+ })) }), [r, o, t, c]), p = ze(t, x);
570
+ ee(() => {
571
+ requestAnimationFrame(() => {
572
+ l();
573
+ });
574
+ }, [c, l, v]);
575
+ const C = ce((m, S) => {
576
+ if (!S) return;
577
+ const T = p[c];
578
+ if (!T) return;
579
+ const y = `${T.name}`;
580
+ d(y, m), s([m]);
581
+ }, [p, c, s, d]), I = p.map((m, S) => ({ card: m, cardIndex: S })).filter(({ cardIndex: m }) => f.has(m));
582
+ return e("div", { className: "conversational-ui ul-conversational-ui", children: [!u && e(Et, {}), e("div", { className: "chat-container", ref: n, children: e("div", { className: "chat-messages", children: I.map(({ card: m, cardIndex: S }) => e(Ut, { avatars: g, card: m, cardIndex: S, cardResponses: o, currentQuestionBubbleRef: a, handleCardResponse: C, index: c, questionThinkingStates: v, startingQuestionIdx: i }, `question-card-${m.name}`)) }) })] });
583
+ };
584
+ export {
585
+ Qt as default
586
+ };