@sprig-technologies/sprig-bundled
Version:
npm package for the sprig web sdk with bundled dependencies
510 lines • 64.4 kB
JavaScript
import { u as Y, h as J, a as e, c as O, g as je, b as te, F as he, p as re, d as ve, e as be, _ as ne, T as Ce, A as nr, M as _e, D as Me, f as sr, P as ir, i as ar, q as or, j as de, s as Ze, k as lr, S as cr, l as dr, m as ur, n as pr, o as mr, r as gr, t as hr, v as Le, w as $e } from "./view-Cu4weTLz.js";
import { i as ie, E as Pe, h as Qe, j as We, A as br } from "./index-Czvv7meW.js";
import { H as ae, Q as le, a as Ie, M as me, b as pe, O as fe, B as ee, L as Te, S as vr, u as yr, g as fr, c as xr } from "./getAttributedUrl-Dq1b-gQL.js";
const Sr = ({ className: n, message: s, next: d, properties: t, questionId: r, type: a }) => {
const { useMobileStyling: g, border: v, isLongFormSurvey: u, focusedQuestionId: h } = Y((m) => ({ useMobileStyling: m.useMobileStyling, border: m.border, isLongFormSurvey: ie(m.studyType), focusedQuestionId: m.focusedQuestionId })), [l, b] = J(!1), [c, N] = J(""), [o, f] = J(!1), p = u && h === r, k = t == null ? void 0 : t.collectName, x = (t == null ? void 0 : t.nameLabelText) || "Full Name", _ = (t == null ? void 0 : t.consentText) || "I agree to the stated conditions", w = (t == null ? void 0 : t.submitButtonText) || "Submit", E = !!c.trim(), M = l && (!k || E), U = (m, S = !1) => {
m.preventDefault(), m.stopPropagation();
let P = null;
if (!S) {
if (!M) return void f(!0);
P = { submitted: !0 }, k && (P.name = c);
}
d({ value: P, questionId: r, type: a }, M);
};
return e("div", { className: O(n, u && !p && "ul-card--unfocused", "ul-card__consent-legal", "fade-in-transition"), children: [e(ae, { isRequired: u && (t == null ? void 0 : t.required), message: s, properties: { questionHtml: t.questionHtml } }), t != null && t.richTextBody ? e(le, { children: e(Ie, { className: "ul-rich-text-body", html: t.richTextBody, id: "ul-card__consent-legal-body-container" }) }) : null, e(me, { embeddedType: "pdf", properties: t, children: e(pe, { children: [e("div", { className: "sprig-stretch", children: [e(fe, { allowTextEntry: !1, border: v, error: o && !l, id: "consent", isRadio: !1, isSelected: l, label: _, onUserInputChanged: ({ selected: m }) => {
m !== l && b(!l);
}, useMobileStyling: g }), k && e("input", { "aria-label": x, "aria-placeholder": x, className: O(te("ul-consent-legal__name-input", g)), "data-gramm": "false", maxLength: 250, name: "name", onBlur: (m) => {
m.currentTarget.style.borderColor = o && !E ? Pe : Qe;
}, onFocus: (m) => {
m.currentTarget.style.borderColor = o && !E ? Pe : v;
}, onInput: (m) => {
m.preventDefault(), m.stopPropagation(), N(m.currentTarget.value);
}, placeholder: x, style: o && !E ? { borderColor: Pe } : {}, tabIndex: 0, value: c })] }), e("div", { className: "ul-card__button-wrapper ul-card-vertical__button-wrapper", children: [e(ee, { className: M ? "" : "sprig-button-disabled", onClick: U, children: w }), t.required === !1 && !u && e("button", { className: "ul-card-skip__button", onClick: (m) => U(m, !0), children: je(t) })] })] }) })] }, r);
}, ke = (n) => (s) => {
s.pointerType !== "touch" && n();
}, kr = ({ activeValue: n, border: s, icon: d, isPressed: t, onSubmit: r, range: a, scaleLabelType: g, selectedValue: v, setSelectedValue: u, setActiveValue: h, setIsPressed: l, useMobileStyling: b, value: c, viewDocument: N }) => {
const { isLongFormSurvey: o, enableCspTrustedTypes: f } = Y((S) => ({ isLongFormSurvey: ie(S.studyType), enableCspTrustedTypes: S.enableCspTrustedTypes })), p = `option-${c}`, k = g === "number", x = g === "star", _ = g === "smiley", w = k && c === n || c === v, [E, M] = (() => {
const S = x && v !== null && c <= v;
return x && c <= n || _ && c === n || S || c === n || c === v ? [s, t || S || c === v ? 1 : 0.3] : ["", 1];
})(), U = he(() => {
const S = v === c, P = { borderColor: w && !b || S ? E : "", fillOpacity: w ? "" : M, zIndex: w ? 3 : "auto", color: S ? "#fff" : "" };
return k ? { ...P, backgroundColor: S ? E : "" } : { ...P, color: x || _ || S ? E : "" };
}, [w, E, M, v, c, k, x, _, b]), m = he(() => We((({ icon: S, scaleLabelType: P, value: D, selectedValue: A }) => {
if (P === "smiley" && D === A) {
let C = 0;
return S.replace(/black/g, () => ++C == 1 ? "black" : "white");
}
return S;
})({ icon: d, scaleLabelType: g, value: c, selectedValue: v }), f), [f, d, g, v, c]);
return e("button", { "aria-label": k ? void 0 : String(c), className: (() => {
switch (g) {
case "star":
return O(te("likert-star", b), te(`likert-star-${c}`, b));
case "smiley":
return O(te("likert-smiley", b), te(`likert-smiley-${c}`, b));
default:
return c === a ? O(te("likert-number", b), te(`likert-number-${c}`, b), te("likert-last-option", b)) : O(te("likert-number", b), te(`likert-number-${c}`, b));
}
})(), dangerouslySetInnerHTML: { __html: m }, id: p, onClick: (S) => {
o && (S.preventDefault(), S.stopPropagation(), u(c)), r();
}, onKeyDown: (S) => {
var A, C;
const P = N.querySelectorAll(`.likert-${g ?? "number"}`), D = c - 1;
S.key === "ArrowRight" ? (A = P[D + 1]) == null || A.focus() : S.key === "ArrowLeft" ? (C = P[D - 1]) == null || C.focus() : S.key !== "Enter" && S.key !== " " || (o && (S.preventDefault(), S.stopPropagation(), u(c)), r());
}, onPointerCancel: ke(() => l(!1)), onPointerDown: ke(() => {
l(!0), h(c);
}), onPointerEnter: ke(() => h(c)), onPointerLeave: ke(() => {
h(-1), l(!1);
}), onPointerUp: ke(() => l(!1)), style: U, tabIndex: 0 });
}, Tr = ({ className: n, labels: s, message: d, next: t, properties: r, questionId: a, type: g }) => {
const { border: v, useMobileStyling: u, viewDocument: h, isLongFormSurvey: l, focusedQuestionId: b } = Y((D) => ({ border: D.border, useMobileStyling: D.useMobileStyling, viewDocument: D.viewDocument, isLongFormSurvey: ie(D.studyType), focusedQuestionId: D.focusedQuestionId })), [c, N] = J(-1), [o, f] = J(!1), [p, k] = J(null);
re(() => {
N(-1), f(!1), k(null);
}, [a]);
const x = l && b === a, _ = s && s.left, w = s && s.right;
let E;
const { range: M, scaleLabelType: U, ratingIcons: m } = r;
M && (E = Number(M));
const S = E || 5, P = (D) => {
var A, C;
switch (U) {
case "star":
return (A = m[0]) == null ? void 0 : A.svg;
case "smiley":
return (C = m[D]) == null ? void 0 : C.svg;
default:
return String(D + 1);
}
};
return e("form", { className: O(n, "ul-card--likert", "fade-in-transition", l && !x && "ul-card--unfocused"), children: [e(ae, { isRequired: l && (r == null ? void 0 : r.required), message: d, properties: r }), e(me, { properties: r, children: e(ve, { children: [e(le, { children: [e("div", { "aria-label": `Rating (1 - ${S})`, className: "ul-card--likert__numbers", role: "radiogroup", children: [...Array(S)].map((D, A) => {
const C = A + 1;
return e(kr, { activeValue: c, border: v, icon: P(A), isPressed: o, onSubmit: () => t({ value: C, questionId: a, type: g }, !0), range: S, scaleLabelType: U, selectedValue: p, setActiveValue: N, setIsPressed: f, setSelectedValue: k, useMobileStyling: u, value: C, viewDocument: h }, A);
}) }), e("div", { className: "ul-card--likert__labels", children: [e("span", { children: _ }), e("span", { children: w })] })] }), !r.required && !l && e(pe, { children: e("div", { className: "ul-vertical-centered-container", children: e(ee, { onClick: (D) => {
D.preventDefault(), D.stopPropagation(), t({ value: null, questionId: a, type: g }, !0);
}, children: be(r) }) }) })] }) })] }, a);
}, Ir = ({ columns: n, onSelect: s, options: d, selectedOptions: t }) => {
const r = ne([]), { border: a, useMobileStyling: g, cards: v, index: u } = Y((o) => ({ border: o.border, useMobileStyling: o.useMobileStyling, cards: o.cards, index: o.index })), h = d.findIndex((o) => t[o.id] === null), [l, b] = J(h), c = Ce((o, f) => {
var x;
s(o, f);
const p = l + 1, k = d[p];
if (k && t[k.id] === null) {
b(p);
const _ = v[u];
(_ == null ? void 0 : _.groupId) != null || ((x = r.current[p]) == null || x.scrollIntoView({ block: "nearest", behavior: "smooth" }));
}
}, [s, d, t, l, v, u]), N = Ce((o, f) => {
const p = l === o;
return e(nr, { animate: !0, header: f.label, isOpen: p, onClick: () => {
var k;
return b(p && !((k = window.UserLeap) != null && k.isMobileSDK) ? -1 : o);
}, ref: (k) => {
k && (r.current[o] = k);
}, showHeaderCheck: t[f.id] !== null, children: e("div", { style: { paddingTop: "12px" }, children: n.map((k) => e(fe, { allowTextEntry: !1, ariaLabel: `${f.label}-${k.label}`, border: a, error: !1, id: `${f.id}-${k.value}`, isRadio: !0, isSelected: t[f.id] === k.value, label: k.label, onUserInputChanged: () => c(f.id, k.value), useMobileStyling: g }, k.label)) }) }, f.id);
}, [a, n, l, c, t, g]);
return e("div", { children: d.map((o, f) => N(f, o)) });
}, _r = ({ columns: n, onSelect: s, options: d, selectedOptions: t }) => {
const { border: r, useMobileStyling: a, isLongFormSurvey: g } = Y((o) => ({ border: o.border, useMobileStyling: o.useMobileStyling, isLongFormSurvey: ie(o.studyType) })), v = d.length, u = n.length, h = ne(null), [l, b] = J(!1), [c, N] = J(!1);
return re(() => {
const o = h.current, f = new ResizeObserver((p) => {
window.requestAnimationFrame(() => {
o && (b(Math.round(p[0].contentRect.width) < o.scrollWidth), N(Math.round(p[0].contentRect.width) < o.scrollWidth));
});
});
return o && f.observe(o), () => {
o && f.unobserve(o);
};
}, []), e("div", { className: "ul-card--matrix_question_container", children: [e("div", { className: O("ul-card--matrix_container", l && "ul-matrix-scroll-gradient"), onScroll: () => {
(() => {
const o = h.current;
o && b(o.clientWidth + Math.abs(o.scrollLeft) < o.scrollWidth);
})();
}, ref: h, children: e("div", { className: O(g && "ul-card--matrix_grid_longform", "ul-card--matrix_grid"), style: `--numColumns: ${u}; --numRows: ${v + 1};`, children: [e("div", {}), " ", n.map((o) => e("div", { className: "ul-matrix-column-label", children: o.label }, o.label)), d.map((o) => e(ve, { children: [e("div", { "aria-label": o.label, className: "ul-matrix-row-label", children: o.label }, o.label), e("div", { className: "ul-matrix-row-options", role: "radiogroup", children: n.map((f, p) => e("div", { className: O("ul-matrix-option-wrapper", p === u - 1 && "ul-matrix-last-option"), children: e(fe, { allowTextEntry: !1, ariaLabel: `${o.label}-${f.label}`, border: r, choiceStyle: { background: "transparent", border: "none", marginBottom: "0", padding: "0" }, error: !1, id: `${o.id}-${f.value}`, isRadio: !0, isSelected: t[o.id] === f.value, onUserInputChanged: () => s(o.id, f.value), useMobileStyling: a }) }, f.value)) })] }))] }) }), (l || c) && e("button", { className: c && !l ? "ul-matrix-scroll-arrow left" : "ul-matrix-scroll-arrow", onClick: c && !l ? (o) => {
o.preventDefault();
const f = h.current;
if (f) {
const p = getComputedStyle(f).direction === "rtl";
f.scrollTo({ left: p ? f.scrollWidth - f.clientWidth : 0, behavior: "smooth" });
}
} : (o) => {
o.preventDefault();
const f = h.current;
if (f) {
const p = getComputedStyle(f).direction === "rtl";
f.scrollTo({ left: p ? f.clientWidth - f.scrollWidth : f.scrollWidth, behavior: "smooth" });
}
}, children: e(c && !l ? Cr : Nr, {}) })] });
}, Cr = () => e("svg", { fill: "currentColor", height: "32", transform: "matrix(-1,0,0,1,0,0)", version: "1.1", viewBox: "0 0 256 256", width: "32", xmlns: "http://www.w3.org/2000/svg", children: e("path", { d: "M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z" }) }), Nr = () => e("svg", { fill: "currentColor", height: "32", viewBox: "0 0 256 256", width: "32", xmlns: "http://www.w3.org/2000/svg", children: e("path", { d: "M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z" }) }), wr = ({ className: n, message: s, next: d, options: t, properties: r, questionId: a, type: g, showIndividualSubmit: v = !1, onSubmitButtonClick: u }) => {
const { useMobileStyling: h, isLongFormSurvey: l, focusedQuestionId: b, setFocusedQuestionId: c } = Y((m) => ({ useMobileStyling: m.useMobileStyling, isLongFormSurvey: ie(m.studyType), focusedQuestionId: m.focusedQuestionId, setFocusedQuestionId: m.setFocusedQuestionId })), N = r.matrixColumn, o = r.required, f = l && b === a, p = (m) => Object.values(m).every((S) => S == null), k = (m) => o && p(m), x = (m) => {
if (m.preventDefault(), m.stopPropagation(), d({ value: w, questionId: a, type: g }, !0), u) {
const S = !p(w);
u(S);
}
}, _ = t.reduce((m, S) => (m[S.id] = null, m), {}), [w, E] = J(_), M = (m, S) => {
l && d({ value: { ...w, [m]: S }, questionId: a, type: g }, !k({ ...w, [m]: S })), E((P) => ({ ...P, [m]: S }));
}, U = r.displayMatrixAsAccordion || h;
return e("form", { className: O(n, !l && "ul-card__matrix", "fade-in-transition", l && !f && "ul-card--unfocused"), id: "text-form", onClick: () => {
f && c(a);
}, onSubmit: x, children: [e(ae, { isRequired: l && (r == null ? void 0 : r.required), message: s, properties: r }), e(me, { properties: r, children: [e(le, { children: [e(U ? Ir : _r, { columns: N, onSelect: M, options: t, selectedOptions: w }), v && e(Te, { handleSubmit: x, isSubmitDisabled: k(w) })] }), !l && e(pe, { children: e("div", { className: "ul-card__button-wrapper", children: e(ee, { disabled: k(w), children: be(r) }) }) })] })] }, a);
}, Ge = ({ className: n, message: s, onSubmit: d, options: t = [], properties: r, questionId: a, type: g, showIndividualSubmit: v = !1, onSubmitButtonClick: u }) => {
const { border: h, useMobileStyling: l, isLongFormSurvey: b, focusedQuestionId: c, setFocusedQuestionId: N } = Y((T) => ({ border: T.border, useMobileStyling: T.useMobileStyling, isLongFormSurvey: ie(T.studyType), focusedQuestionId: T.focusedQuestionId, setFocusedQuestionId: T.setFocusedQuestionId })), o = b && c === a, f = t.reduce((T, Q) => (T[Q.id] = { isSelected: !1 }, T), {}), [p, k] = J(f), x = g === "multiplechoice", _ = r.required, w = t.find((T) => {
var Q;
return (Q = T.optionProperties) == null ? void 0 : Q.noneOfTheAbove;
}), E = (T) => Object.entries(T).some(([Q, V]) => {
var q;
const i = t.find((R) => `${R.id}` === Q), y = V.userText === void 0 || V.userText.trim() === "";
return ((q = i == null ? void 0 : i.optionProperties) == null ? void 0 : q.allowsTextEntry) && y && V.isSelected;
}), M = (T) => Object.values(T).filter((Q) => Q.isSelected).length, U = (T) => {
const { minSelect: Q = 0, maxSelect: V = 1 / 0, maxSelectMode: i } = r, y = M(T);
switch (i) {
case _e.Maximum:
return y <= V;
case _e.Range:
return y === 0 || y >= Q;
default:
return !0;
}
}, m = r.minSelect && r.minSelect > 0 && r.maxSelectMode === _e.Range && M(p) < r.minSelect && (_ || M(p) > 0), S = (T) => E(T) || _ && !M(T) || !U(T), P = (T) => U(T) && !E(T) && M(T) > 0, D = Object.entries(p).some(([T, Q]) => {
var V, i;
return Q.isSelected && ((i = (V = t.find((y) => `${y.id}` === T)) == null ? void 0 : V.optionProperties) == null ? void 0 : i.allowsTextEntry);
}), A = v && (!x || D), C = (T) => {
z(T.id, T.selected, T.userText, T.noneOfTheAbove), T.selected && b && !x && !o && N(a);
}, B = (T) => {
var Q;
return (r == null ? void 0 : r.maxSelectMode) !== _e.Unlimited && M(p) === (r == null ? void 0 : r.maxSelect) && !((Q = p[T]) != null && Q.isSelected);
}, K = (T) => {
if (T.preventDefault(), T.stopPropagation(), d(p, !0), u) {
const Q = P(p);
u(Q);
}
}, z = (T, Q, V, i) => {
const y = Object.assign({}, p);
if ((x || i) && Q) for (const L of Object.values(y)) L.isSelected = !1, delete L.userText;
else w && !i && p[w.id].isSelected && (y[w.id].isSelected = !1);
y[T] = { isSelected: Q, userText: V };
const q = x && Object.entries(y).some(([L, j]) => {
var Z, se;
return j.isSelected && ((se = (Z = t.find((ce) => `${ce.id}` === L)) == null ? void 0 : Z.optionProperties) == null ? void 0 : se.allowsTextEntry);
}), R = !S(y);
if (b && (d(y, R), x && !q && R && u)) {
const L = P(y);
u(L);
}
k(y);
};
return e("form", { className: O(n, "ul-card--multiple", "fade-in-transition", b && !o && "ul-card--unfocused"), id: "text-form", onClick: g === "multipleselect" ? () => {
b && c !== a && g === "multipleselect" && N(a);
} : void 0, onSubmit: K, children: [e(ae, { isRequired: b && (r == null ? void 0 : r.required), message: s, properties: r }), e(me, { properties: r, children: e(ve, { children: [e(le, { children: [r.isDropdown ? e(vr, { disabledOptions: t.filter((T) => B(T.id)), dropdownFooter: m ? e("div", { className: "ul-card__min-select-counter", style: { marginLeft: "16px" }, children: [M(p), "/", r.minSelect] }) : void 0, isMultiSelect: !x, multiselectText: r.dropdownMultiselectedText ?? "choices selected", onChange: (T) => {
const Q = { ...p };
for (const V of t) T.includes(V) ? Q[V.id].isSelected = !0 : Q[V.id].isSelected = !1;
b && d(Q, !S(Q)), k(Q);
}, options: t, placeholderText: r.dropdownPlaceholderText ?? (x ? "Select choice" : "Select choice(s)"), value: t.filter((T) => p[T.id].isSelected) }) : e("div", { className: O(te("ul-card__choices", l)), role: x ? "radiogroup" : "group", children: [t.map(({ id: T, label: Q, value: V, optionProperties: i }) => {
var L, j;
const y = `${T}`, { allowsTextEntry: q, noneOfTheAbove: R } = { allowsTextEntry: !1, noneOfTheAbove: !1, ...i };
return e(fe, { allowTextEntry: q, border: h, disabled: B(y), error: E(p), id: y, isRadio: x, isSelected: !!((L = p[y]) != null && L.isSelected), label: Q, noneOfTheAbove: R, onUserInputChanged: C, promptText: (i == null ? void 0 : i.otherOptionPlaceholder) || "Please specify", text: (j = p[T]) == null ? void 0 : j.userText, useMobileStyling: l, value: V }, y);
}), !!m && e("div", { className: "ul-card__min-select-counter", children: [M(p), "/", r.minSelect] })] }), A && e(Te, { handleSubmit: K, isSubmitDisabled: S(p) })] }), !b && e(pe, { children: e("div", { className: "ul-card__button-wrapper", children: e(ee, { disabled: S(p), onClick: K, children: be(r) }) }) })] }) })] }, a);
}, qr = (n) => {
const { questionId: s, type: d, next: t, options: r } = n, { setFocusedQuestionId: a } = Y((g) => ({ setFocusedQuestionId: g.setFocusedQuestionId }));
return e(Ge, { ...n, onSubmit: (g, v) => {
var N;
const u = Object.entries(g).find(([, o]) => o.isSelected) || [void 0, void 0], [h, l] = u, b = r.find((o) => `${o.id}` === h);
!((N = b == null ? void 0 : b.optionProperties) != null && N.allowsTextEntry) || l != null && l.userText && l.userText.trim() !== "" || a(s);
const c = l != null && l.userText ? { [h]: { userText: l.userText } } : null;
t({ value: b && h ? { [h]: b.value } : {}, secondaryValue: c, questionId: s, type: d }, v);
} });
}, Lr = (n) => {
const { questionId: s, type: d, next: t } = n;
return e(Ge, { ...n, onSubmit: (r, a) => {
const g = Object.entries(r).reduce((u, [h, l]) => (u[h] = l.isSelected, u), {}), v = Object.entries(r).reduce((u, [h, l]) => {
if (!l.userText) return u;
const b = u || {};
return b[h] = { userText: l.userText }, b;
}, null);
t({ value: g, secondaryValue: v, questionId: s, type: d }, a);
} });
}, Pr = ({ className: n, labels: s, message: d, properties: t, next: r, questionId: a, type: g }) => {
const [v, u] = J(null), { border: h, useMobileStyling: l, viewDocument: b, isLongFormSurvey: c, focusedQuestionId: N } = Y((k) => ({ border: k.border, useMobileStyling: k.useMobileStyling, viewDocument: k.viewDocument, isLongFormSurvey: ie(k.studyType), focusedQuestionId: k.focusedQuestionId })), o = c && N === a, f = s && s.left, p = s && s.right;
return e("form", { className: O(n, "ul-card--nps", "fade-in-transition", c && !o && "ul-card--unfocused"), children: [e(ae, { isRequired: c && (t == null ? void 0 : t.required), message: d, properties: t }), e(me, { properties: t, children: [e(le, { children: [e("div", { className: "ul-card--nps__numbers", children: [...Array(11)].map((k, x) => e("button", { className: O(te("nps-number", l), te(`nps-number-${x}`, l)), id: `option-${x}`, onClick: (_) => {
c && (_.preventDefault(), _.stopPropagation(), u(x)), r({ value: x, questionId: a, type: g }, !0);
}, onKeyDown: (_) => {
var E, M;
const w = b.querySelectorAll("button.nps-number");
_.key === "ArrowRight" ? (E = w[x + 1]) == null || E.focus() : _.key === "ArrowLeft" ? (M = w[x - 1]) == null || M.focus() : _.key !== "Enter" && _.key !== " " || (c && (_.preventDefault(), _.stopPropagation(), u(x)), r({ value: x, questionId: a, type: g }, !0));
}, onPointerDown: (_) => {
_.currentTarget.style.zIndex = "2", _.currentTarget.style.borderColor = h;
}, onPointerLeave: (_) => {
_.currentTarget.style.zIndex = "auto", _.currentTarget.style.borderColor = Qe;
}, style: v === x ? { backgroundColor: h, color: "#fff" } : void 0, tabIndex: 0, children: x }, x)) }), e("div", { className: "ul-card--nps__labels", children: [e("span", { children: f }), e("span", { children: p })] })] }), !t.required && !c && e(pe, { children: e("div", { className: "ul-vertical-centered-container", children: e(ee, { onClick: (k) => {
k.preventDefault(), k.stopPropagation(), r({ value: null, questionId: a, type: g }, !0);
}, children: be(t) }) }) })] })] }, a);
}, Mr = (n) => {
const { className: s, message: d, next: t, properties: r, questionId: a, type: g, showIndividualSubmit: v = !1, onSubmitButtonClick: u } = n, h = g === "aidynamicfollowup" || g === "aidynamicstandalone", l = h ? n.loading : void 0, { border: b, useMobileStyling: c, update: N, isLongFormSurvey: o, focusedQuestionId: f, setFocusedQuestionId: p, isPreview: k } = Y((C) => ({ border: C.border, useMobileStyling: C.useMobileStyling, update: C.update, isLongFormSurvey: ie(C.studyType), focusedQuestionId: C.focusedQuestionId, setFocusedQuestionId: C.setFocusedQuestionId, isPreview: C.isPreview })), [x, _] = J(""), w = ne(null), E = o && f === a;
re(() => {
var C, B;
o && !k && (E ? (C = w.current) == null || C.focus() : (B = w.current) == null || B.blur());
}, [o, E, k]);
const M = x.trim(), U = r.required === !0 && !M, m = yr(w, () => N()), S = (C) => {
C.preventDefault(), C.stopPropagation();
const B = M.length > 0, K = !r.required || B;
t({ value: x, questionId: a, type: g }, K), u && u(B);
}, P = r && r.openTextPlaceholder ? r.openTextPlaceholder : "";
if ((l === Me.failure || l === void 0) && h) return e(ve, {});
const D = l === Me.inFlight, A = D ? "Preparing your next question" : d;
return e("form", { className: O(s, "ul-card-text", "fade-in-transition", o && !E && "ul-card--unfocused"), id: "text-form", onClick: () => {
o && f !== a && p(a);
}, children: [e(ae, { isRequired: o && (r == null ? void 0 : r.required), message: A, properties: r }), e(me, { properties: r, children: e("div", { className: "ul-card-text", children: e(le, { children: [e("div", { className: "ul-card-text__container", children: e("textarea", { "aria-describedby": "ul-caption", "aria-labelledby": "ul-question", "aria-multiline": "true", "aria-placeholder": P, className: O(D && "ul-card-text__input__loading", te("ul-card-text__input", c)), "data-gramm": "false", disabled: D, maxLength: 5e3, name: "text", onBlur: (C) => {
C.currentTarget.style.borderColor = Qe;
}, onChange: (C) => {
const { value: B } = C.currentTarget;
if (m(), C.preventDefault(), C.stopPropagation(), _(B), o) {
const K = B.trim().length > 0;
t({ value: B, questionId: a, type: g }, K);
}
}, onFocus: (C) => {
C.currentTarget.style.borderColor = b, p(a);
}, placeholder: P, ref: w, role: "textbox", tabIndex: 0 }) }), r.footerHtml && e(Ie, { className: "footer", html: r.footerHtml }), v && e(Te, { handleSubmit: S, isSubmitDisabled: U }), e(pe, { children: !o && e(ee, { disabled: U || D, onClick: S, children: be(r) }) })] }) }) })] }, a);
}, De = 1, ze = 2, Ye = 3, Ne = (n) => n.type === "av_permission", Oe = (n) => n.type === "screen_permission", Ke = (n, s) => n === void 0 ? De : n ? ((d, t) => !(Ne(t) ? t.permissionDescriptors : []).includes("camera") || d.getVideoTracks().length > 0)(n, s) ? Ye : De : ze, Ue = { avStream: null, currentPage: null, mediaRecordingUids: null, nextQuestion: () => {
}, passthroughData: void 0, recordingMediaTypes: void 0, screenPermissionRequested: !1, type: void 0 }, ue = sr((n) => ({ ...Ue, reset: () => {
n(Ue);
}, updatePage: (s) => {
n(s);
} }));
function Re({ currentPage: n, pages: s }) {
const { avStream: d, recordingMediaTypes: t, updatePage: r } = ue.getState(), { recorderEventEmitter: a } = Y.getState();
a.emit("av.permission", { "permission.descriptors": n.permissionDescriptors, "stream.ready": (g, v) => {
if (d === g) return;
let u = n;
if (g && !n.permissionDescriptors.includes("camera")) {
const h = s.indexOf(n), l = v != null && v.active ? h + 2 : h + 1;
v != null && v.active && t && a.emit("begin.recording", { "recording.media.types": t, "start.recording.callback": (b) => r({ mediaRecordingUids: b }) }), u = s[l];
}
r({ currentPage: u, avStream: g });
} });
}
function Fe({ status: n }) {
const { nextQuestion: s, passthroughData: d, mediaRecordingUids: t, reset: r } = ue.getState(), { recorderEventEmitter: a, handleUploadUpdate: g, index: v } = Y.getState(), u = { value: { taskStatus: n }, type: "recordedtask", questionId: (d == null ? void 0 : d.questionId) || 1 };
d && a.emit("finish.task", { "begin.callback": (h) => {
g({ mediaRecordingUid: h, isSubmitted: !0, progressPct: 0, isComplete: !1 });
}, "progress.callback": (h, l) => {
g({ mediaRecordingUid: h, progressPct: l.detail, isSubmitted: !1, isComplete: !1 });
}, "upload.callback": (h) => {
h && g({ mediaRecordingUid: h, isComplete: !0, isSubmitted: !0, progressPct: 100 });
}, "passthrough.data": d, "current.index": v, "task.response": u, "task.complete.callback": (h) => {
u.value.taskDurationMillisecond = h, t && (u.value.mediaRecordingUids = t), r(), s(u);
} });
}
function Be({ pages: n, setIsRequestingPermission: s }) {
const { recorderEventEmitter: d, eventEmitFn: t } = Y.getState(), { updatePage: r, currentPage: a, recordingMediaTypes: g, screenPermissionRequested: v } = ue.getState();
if (!a) return;
const u = n.indexOf(a);
switch (a.type) {
case "av_permission": {
const h = v ? u + 2 : u + 1;
return v && g && d.emit("begin.recording", { "recording.media.types": g, "start.recording.callback": (l) => {
r({ mediaRecordingUids: l });
} }), void r({ currentPage: n[h] });
}
case "screen_permission":
return void d.emit("screen.permission", { "screen.permission.requested": s, "stream.ready.callback": (h, l) => {
const b = l ? n[u + 1] : a;
l && g && d.emit("begin.recording", { "recording.media.types": g, "start.recording.callback": (c) => {
r({ captureStream: l, mediaRecordingUids: c });
} }), r({ currentPage: b, screenPermissionRequested: !0, captureStream: l });
} });
case "start_task":
return t("recorded.task.start"), d.emit("recorded.task.start"), d.emit("start.task"), void r({ currentPage: n[u + 1], screenPermissionRequested: !0 });
case "complete_task":
return;
}
}
const Xe = "ul-permission-graphics-container", Je = "ul-permission-body", er = O(Xe, "ul_recorded-task-inset-spacing"), we = O("ul-horizontal-button-container", "ul-horizontal-button-container-left"), rr = ({ richTextBody: n }) => e(Ie, { className: "ul-rich-text-body", html: n, id: "ul-task-detail-container" }), qe = ({ required: n, skipButtonText: s, bottom: d = !1 }) => n ? null : e(ee, { className: O(d && "ul-skip-button-below", "ul-button-inactive"), onClick: Fe.bind(null, { status: "abandoned" }), children: s || "Skip" }), Ee = (n) => {
const { avStream: s, captureStream: d, recordingMediaTypes: t, updatePage: r } = ue.getState(), a = (t == null ? void 0 : t.includes("audio")) || (t == null ? void 0 : t.includes("video"));
re(() => {
const g = setInterval(() => {
a && s && !s.active ? r({ avStream: null, currentPage: n[0] }) : d && d.active || r({ captureStream: void 0, currentPage: n[a ? 1 : 0] });
}, 1e3);
return () => clearInterval(g);
}, [s, d, a, n, t, r]);
}, Dr = ({ content: n, pages: s, required: d }) => {
const { buttonText: t, skipButtonText: r, taskDetail: a } = n;
return Ee(s), e("div", { className: "ul-task-page", children: [a && e(rr, { richTextBody: a }), e("div", { className: we, children: [e(ee, { onClick: Be.bind(null, { pages: s }), children: t }), e(qe, { required: d, skipButtonText: r })] })] }, "start-task");
}, Rr = ({ content: n, pages: s, properties: d }) => {
const { buttonText: t, skipButtonText: r } = n;
return Ee(s), e("div", { className: "ul-task-page", children: [n.taskDetail && e(rr, { richTextBody: n.taskDetail }), e(me, { properties: d, children: e("div", { className: we, children: [e(ee, { className: "ul-complete-task-button", onClick: Fe.bind(null, { status: "completed" }), children: t }), e(ee, { className: O("ul-button-inactive"), onClick: Fe.bind(null, { status: "given.up" }), children: r })] }) })] }, "complete-task");
}, Fr = ({ content: n, pages: s, required: d }) => {
const { buttonText: t, skipButtonText: r } = n, [a] = Y((u) => [u.tabTitle]), [g, v] = J(!1);
return e("div", { children: [e("div", { className: er, children: [e("p", { style: { marginTop: "auto" }, children: n.selectTabText }), e("div", { className: "ul-select-tab-container", children: e("p", { className: Je, children: a }) })] }), e("div", { className: d ? "" : we, children: [e(ee, { disabled: g, onClick: Be.bind(null, { pages: s, setIsRequestingPermission: v }), children: t }), e(qe, { required: d, skipButtonText: r })] })] });
}, Qr = ({ content: n }) => e(Ie, { className: O(Xe, "ul_permission_svg_container", "ul_recorded-task-inset-spacing", "ul-center-horizontally"), html: n.svg }, "ul-permission-request-graphic"), Br = ({ content: n, pages: s, required: d }) => {
const { permissionDeniedHeadline: t, permissionDeniedBody: r, skipButtonText: a, tryAgainButtonText: g } = n, v = Ne(s[0]) ? s[0] : null;
return re(() => {
const u = setInterval(() => {
v !== null && Re({ currentPage: v, pages: s });
}, 1e3);
return () => clearInterval(u);
}, [v, s]), v ? e("div", { children: [e("div", { className: er, children: e("p", { className: "ul-av-permission-denied-paragraph", children: [e("span", { className: "ul-av-permission-denied-headline", children: t }), e("span", { className: Je, children: r })] }) }), e("div", { className: we, children: [e(ee, { onClick: Re.bind(null, { currentPage: v, pages: s }), children: g }), e(qe, { required: d, skipButtonText: a })] })] }) : null;
}, Er = ({ stream: n }) => e("video", { autoPlay: !0, className: O("ul_recorded-task-inset-spacing"), id: "ul-record-task-video-preview", muted: !0, ref: (s) => {
s && (s.srcObject = n || null);
} }), Ar = ({ content: n, pages: s, required: d }) => {
const { skipButtonText: t } = n, { avStream: r } = ue.getState();
return Ee(s), e("div", { children: [e(Er, { stream: r }), e("div", { className: "ul-vertical-button-container-center", children: [e(ee, { onClick: Be.bind(null, { pages: s }), children: n.buttonText }), e(qe, { bottom: !0, required: d, skipButtonText: t })] })] });
}, $r = ({ properties: n }) => {
const { pages: s, required: d } = n, { avStream: t, currentPage: r } = ue.getState();
if (r === void 0) return null;
switch (r == null ? void 0 : r.type) {
case "av_permission": {
const a = Ke(t, r);
return a === De ? e(Qr, { content: r }) : e(a === ze ? Br : Ar, { content: r, pages: s, required: d });
}
case "screen_permission":
return e(Fr, { content: r, pages: s, required: d });
case "start_task":
return e(Dr, { content: r, pages: s, required: d });
case "complete_task":
return e(Rr, { content: r, pages: s, properties: n });
default:
return null;
}
}, Or = ({ className: n, properties: s, next: d, questionId: t }) => {
const r = Y(), { surveyId: a, responseGroupUid: g, userId: v, update: u } = r, h = ue(), { screenPermissionRequested: l } = h, b = ue((p) => p.avStream);
let c = ue((p) => p.currentPage);
c || (c = function({ pages: p, userId: k, responseGroupUid: x, surveyId: _, questionId: w, next: E }) {
const { updatePage: M } = ue.getState(), { eventEmitFn: U, recorderEventEmitter: m } = Y.getState(), S = { questionId: w, surveyId: _, visitorId: k, responseGroupUid: x };
let P = 0;
m.emit("recorded.task.permission.screen"), U("recorded.task.permission.screen"), m.emit("permission.status", { "permission.status.callback": (A, C, B, K) => {
const z = p[P], { type: T } = z, Q = ["screen"];
if (Ne(z)) {
const { permissionDescriptors: V } = z, i = V == null ? void 0 : V.includes("microphone"), y = V == null ? void 0 : V.includes("camera");
i && Q.push("audio"), y && Q.push("video"), (A != null && A.active && !y || A != null && A.active && C) && P++;
}
Oe(p[P]) && B && (P++, m.emit("begin.recording", { "recording.media.types": Q, "start.recording.callback": (V) => M({ mediaRecordingUids: V }) })), M({ currentPage: p[P], avStream: A, screenPermissionRequested: B, nextQuestion: E, type: T, passthroughData: S, recordingMediaTypes: Q, captureStream: K });
} });
const D = p[P];
return D.type === "av_permission" && Re({ currentPage: D, pages: p }), D;
}({ questionId: t, surveyId: a, next: (p) => {
d(p, !0);
}, pages: s.pages, responseGroupUid: g, userId: v }));
let N = c.headline, o = c.captionText;
const f = Ke(b, c);
return Oe(c) && l && (N = c.permissionDeniedHeadline, o = c.permissionDeniedCaptionText), Ne(c) && f === Ye && (N = c.permissionGrantedHeadline, o = c.permissionGrantedCaptionText), re(() => {
u();
}, [u]), e("div", { className: O(n, "ul-center-horizontally", "fade-in-transition"), children: [e(ae, { isRequired: s == null ? void 0 : s.required, message: N, properties: { captionText: o } }), e(le, { children: e($r, { properties: s }) })] });
}, Ur = ({ richTextBody: n, plaintextBody: s }) => n ? e(Ie, { className: "ul-rich-text-body", html: n, id: "ul-card__text-url-body-container" }) : s ? e("div", { className: "ul-rich-text-body", id: "ul-card__text-url-body-container", children: (s ? s.split(/\n\s*\n/g) : []).map((d, t) => e("p", { children: d }, t)) }) : null, Vr = ({ className: n, message: s, next: d, properties: t, questionId: r, type: a }) => {
const { visitorAttributes: g, isLongFormSurvey: v } = Y((b) => ({ visitorAttributes: b.visitorAttributes, isLongFormSurvey: ie(b.studyType) })), u = (b, c = !1) => {
d({ value: c ? { skipped: !0 } : void 0, questionId: r, type: a }, !0);
}, h = fr(t && t.buttonUrl, g), l = v && t.promptActionType === ir.NO_BUTTON;
return e("div", { className: O(n, "ul-card__text-url-prompt", "fade-in-transition"), children: [e(ae, { isRequired: v && (t == null ? void 0 : t.required), message: s, properties: { questionHtml: t.questionHtml } }), e(le, { children: e(Ur, { plaintextBody: t == null ? void 0 : t.body, richTextBody: t == null ? void 0 : t.richTextBody }) }), e(me, { properties: t, children: !l && e(pe, { children: e("div", { className: "ul-card-button-group", children: [e("a", { className: "ul-card-text__button ul-card__text-url-prompt-button", href: h, id: "ul-card-text__button", onClick: u, onKeyPress: (b) => {
b.key !== "Enter" && b.key !== " " || d({ value: void 0, questionId: r, type: a }, !0);
}, rel: "noreferrer", role: h ? "link" : "button", tabIndex: 0, target: "_blank", children: be(t) }), t.required === !1 && e("button", { className: "ul-card-skip__button", onClick: (b) => u(0, !0), children: je(t) })] }) }) })] }, r);
}, Hr = ({ className: n, questionId: s }) => {
const { border: d, destroy: t, endCard: r, forceBrandedLogo: a, update: g } = Y((h) => ({ border: h.border, destroy: h.destroy, endCard: h.endCard, forceBrandedLogo: h.forceBrandedLogo, update: h.update }));
re(() => {
setTimeout(() => {
t(br);
}, a ? 4e3 : 2e3);
}, [t, a]);
const v = r && r.subheader ? e("p", { className: "ul-caption", children: r.subheader }) : null, u = r && r.headline ? r.headline : "";
return re(() => {
g();
}, [g]), e("div", { className: O(n, "ul-card--thanks", "fade-in-transition"), children: e("div", { children: e("div", { className: "ul-card--thanks-content", children: [e("div", { className: "ul-thanks-check", children: e("svg", { "aria-labelledby": "title", fill: "none", height: "99", viewBox: "0 0 81 99", width: "81", xmlns: "http://www.w3.org/2000/svg", children: [e("path", { clipRule: "evenodd", d: "M40.5 77C60.9345 77 77.5 60.4345 77.5 40C77.5 19.5655 60.9345 3 40.5 3C20.0655 3 3.5 19.5655 3.5 40C3.5 60.4345 20.0655 77 40.5 77ZM80.5 40C80.5 62.0914 62.5914 80 40.5 80C18.4086 80 0.5 62.0914 0.5 40C0.5 17.9086 18.4086 0 40.5 0C62.5914 0 80.5 17.9086 80.5 40Z", fill: d, fillRule: "evenodd" }), e("path", { clipRule: "evenodd", d: "M55.025 22.9046C55.6299 23.4705 55.6616 24.4198 55.0956 25.0247C54.8724 25.2634 54.6109 25.5285 54.3157 25.8277C52.2547 27.9168 48.5549 31.667 44.8135 39.6658C43.2818 42.9406 42.0864 45.8386 41.0823 48.2729C40.6539 49.3116 40.2603 50.2659 39.8902 51.129C39.287 52.5359 38.7248 53.7508 38.1744 54.625C37.8997 55.0613 37.5806 55.4905 37.2017 55.8245C36.8201 56.1607 36.2613 56.5 35.5457 56.5C34.6742 56.5 34.0892 55.9692 33.7774 55.6083C33.4502 55.2296 33.1752 54.7511 32.9396 54.301C32.7305 53.9013 32.5088 53.4367 32.2797 52.9565C32.2429 52.8794 32.2059 52.8019 32.1688 52.7243C31.8942 52.1499 31.5959 51.534 31.2537 50.8868C29.8886 48.305 27.8539 45.2878 24.2343 43.1382C23.522 42.7152 23.2875 41.7949 23.7105 41.0826C24.1335 40.3703 25.0539 40.1358 25.7662 40.5588C30.0556 43.1062 32.4149 46.6647 33.9058 49.4845C34.2776 50.1876 34.5973 50.8487 34.8753 51.4302C34.9147 51.5124 34.9529 51.5926 34.9902 51.6707C35.2222 52.1567 35.4164 52.5637 35.5978 52.9102C35.6151 52.9434 35.6321 52.9754 35.6485 53.0061C36.0565 52.3531 36.5341 51.3434 37.133 49.9468C37.4781 49.1418 37.8572 48.2229 38.2761 47.2074C39.2886 44.7532 40.5339 41.7347 42.0961 38.3948C46.0591 29.9221 50.0641 25.8648 52.1535 23.7482C52.4423 23.4556 52.6944 23.2002 52.9048 22.9753C53.4708 22.3703 54.42 22.3387 55.025 22.9046ZM35.1994 53.5892C35.1994 53.5892 35.2 53.5888 35.2012 53.5879C35.2 53.5889 35.1994 53.5893 35.1994 53.5892ZM36.0666 53.6682C36.0732 53.674 36.0765 53.6775 36.0765 53.6777C36.0765 53.678 36.0732 53.6751 36.0666 53.6682Z", fill: d, fillRule: "evenodd" }), e("path", { d: "M69.5 97C69.5 98.1046 56.2924 99 40 99C23.7076 99 10.5 98.1046 10.5 97C10.5 95.8954 23.7076 95 40 95C56.2924 95 69.5 95.8954 69.5 97Z", fill: "black", fillOpacity: "0.2" })] }) }), e(ae, { message: u }), v] }) }) }, s);
}, jr = ({ className: n }) => {
const { uploadProgress: s } = Y((a) => ({ uploadProgress: a.uploadProgress }));
let d, t;
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.");
const r = Math.round(Math.min(99, ...Object.values(s).filter((a) => a.isSubmitted).map((a) => a.progressPct || 0)));
return e("div", { className: O(n, "ul-card--uploading", "fade-in-transition"), children: [e("div", { "aria-busy": "true", "aria-label": "Processing...", "aria-live": "polite", className: "ul-loading-spinner-container", role: "progressbar", children: e("div", { className: "ul-loading-spinner", children: [e("div", { className: "first" }), e("div", { className: "second" }), e("div", { className: "third" }), e("div", { className: "fourth" })] }) }), e(ae, { message: `${d} (${r}% complete)` }), e("p", { className: "ul-caption", children: t })] });
}, tr = ar(void 0), Zr = ({ value: n, children: s }) => e(tr.Provider, { value: n, children: s }), Wr = ({ isRightLabel: n, isLeftLabel: s }) => n ? de.RIGHT : s ? de.LEFT : null, Gr = "Best", zr = "Worst", Yr = ({ className: n, labels: s, message: d, properties: t, options: r, questionId: a, type: g, next: v }) => {
var w, E, M, U;
const [u, h] = J(r.map((m, S) => ({ ...m, label: m.label === "" ? `Item ${S + 1}` : m.label, isRightLabel: !1, isLeftLabel: !1 }))), l = (() => {
const m = or(tr);
if (m === void 0) throw new Error("usePreviousResponses must be used within a PreviousResponsesProvider");
return m;
})(), b = { padding: "24px", display: "flex", cursor: "pointer", width: "auto" }, [c, N] = J(!1);
re(() => {
const m = u.findIndex((z) => z.isRightLabel), S = u.findIndex((z) => z.isLeftLabel), P = m !== -1 && S !== -1;
N(P);
const D = !t.required || t.required && P, A = u.map((z) => ({ id: z.id, option: z.label, selected: Wr(z) })), C = Math.floor(a), B = Object.keys(l).filter((z) => z.startsWith(C.toString())).map(Number).sort((z, T) => z - T).at(-1), K = [];
if (typeof B == "number") {
const z = l[B], T = JSON.parse(z);
K.push(...T);
}
K.push(A), setTimeout(() => {
v({ value: K, questionId: a, type: g }, D, P), N(!1);
}, P ? 500 : 0);
}, [u]);
const { border: o, useMobileStyling: f, enableCspTrustedTypes: p } = Y((m) => ({ border: m.border, useMobileStyling: m.useMobileStyling, enableCspTrustedTypes: m.enableCspTrustedTypes })), k = (m, S) => () => {
c || h((P) => ((D, A, C) => D.map((B) => B.id === A ? { ...B, isRightLabel: C === de.RIGHT, isLeftLabel: C === de.LEFT } : C === de.RIGHT && B.isRightLabel || C === de.LEFT && B.isLeftLabel ? { ...B, isRightLabel: !1, isLeftLabel: !1 } : B))(P, m, S));
}, x = (w = t.ratingIcons) == null ? void 0 : w[0].svg, _ = (E = t.ratingIcons) == null ? void 0 : E[1].svg;
return e("form", { className: O(n, "ul-card-maxdiff", "fade-in-transition"), children: [e(ae, { isRequired: t == null ? void 0 : t.required, message: d, properties: t }), e(le, { children: e("div", { className: "ul-card--maxdiff__question-inner-container", children: [e("div", { className: "ul-card-maxdiff__label", children: (s == null ? void 0 : s.left) || ((M = t == null ? void 0 : t.labels) == null ? void 0 : M.left) || Gr }), e("div", { children: " " }), e("div", { className: "ul-card-maxdiff__label", children: (s == null ? void 0 : s.right) || ((U = t == null ? void 0 : t.labels) == null ? void 0 : U.right) || zr }), u.map(({ id: m, label: S, isLeftLabel: P, isRightLabel: D }) => e(ve, { children: [e("div", { className: "ul-card-maxdiff__option-control " + (_ ? "smiley" : ""), children: _ ? e(Ve, { ariaPressed: P, className: P ? "ul-card-maxdiff__option-btn ul-card-maxdiff__option-selected good" : "ul-card-maxdiff__option-btn", enableCspTrustedTypes: p, html: _, id: `smiley-good-${m}`, onClick: k(m, de.LEFT) }) : e(fe, { allowTextEntry: !1, ariaLabel: `bestLabel-${S}`, border: o, choiceStyle: b, error: !1, id: `${m}`, isRadio: !0, isSelected: P, onUserInputChanged: k(m, de.LEFT), useMobileStyling: f }) }), e("div", { className: "ul-card-maxdiff__option-label", children: S }), e("div", { className: "ul-card-maxdiff__option-control " + (x ? "smiley" : ""), children: x ? e(Ve, { ariaPressed: D, className: D ? "ul-card-maxdiff__option-btn ul-card-maxdiff__option-selected bad" : "ul-card-maxdiff__option-btn", enableCspTrustedTypes: p, html: x, id: `smiley-bad-${m}`, onClick: k(m, de.RIGHT) }) : e(fe, { allowTextEntry: !1, ariaLabel: `worstLabel-${S}`, border: o, choiceStyle: b, error: !1, id: `${m}`, isRadio: !0, isSelected: D, onUserInputChanged: k(m, de.RIGHT), useMobileStyling: f }) })] }))] }) })] }, a);
}, Ve = ({ enableCspTrustedTypes: n, ariaPressed: s, className: d, html: t, id: r, onClick: a }) => {
const g = he(() => We(t, n), [n, t]);
return e("span", { "aria-pressed": s, className: d, dangerouslySetInnerHTML: { __html: g }, id: r, onClick: a, tabIndex: 0, type: "button" });
}, Kr = ({ className: n, labels: s, message: d, next: t, properties: r, questionId: a, type: g, onSubmitButtonClick: v, options: u, showIndividualSubmit: h = !1 }) => {
const l = ne(null), b = ne(0), c = ne(0), N = ne(null), o = ne(!1), f = ne([]), [p, k] = J(() => (r == null ? void 0 : r.required) === !0), [x, _] = J(!1), [w, E] = J(() => u.map((I) => ({ ...I, rank: null }))), M = he(() => Array.from({ length: u.length }, (I, $) => $ + 1), [u.length]), { isLongFormSurvey: U, focusedQuestionId: m, setFocusedQuestionId: S, useMobileStyling: P, isPreview: D, headers: A } = Y((I) => ({ useMobileStyling: I.useMobileStyling, isLongFormSurvey: ie(I.studyType), focusedQuestionId: I.focusedQuestionId, setFocusedQuestionId: I.setFocusedQuestionId, isPreview: I.isPreview, headers: I.headers })), C = (A == null ? void 0 : A["userleap-platform"]) === "android", B = P && !D && !C, K = !B && !C, z = U && m === a, T = (I) => {
I.preventDefault(), L(w), v && v(x);
}, Q = (I, $) => {
E((H) => {
const F = parseInt($), W = H.map((G) => ({ ...G }));
W.some((G) => G.rank == null) && W.forEach((G, ye) => G.rank = ye + 1);
const oe = W.findIndex((G) => G.id === I);
if (oe === -1) return H;
const X = W[oe].rank;
return F < X ? W.forEach((G) => {
G.id !== I && G.rank >= F && G.rank < X && (G.rank = G.rank + 1);
}) : F > X && W.forEach((G) => {
G.id !== I && G.rank > X && G.rank <= F && (G.rank = G.rank - 1);
}), W[oe].rank = F, W.sort((G, ye) => G.rank - ye.rank), j(W), W;
});
}, V = (I, $) => {
for (let H = 0; H < f.current.length; H++) {
const F = f.current[H];
if (!F || F === N.current) continue;
const W = F.getBoundingClientRect();
if (I >= W.left && I <= W.right && $ >= W.top && $ <= W.bottom) return { element: F, index: H };
}
return null;
}, i = (I) => ($) => {
if (!B) return;
$.preventDefault(), $.stopPropagation(), o.current = !0, l.current = I;
const H = $.touches[0];
b.current = H.clientY, c.current = H.clientY;
const F = $.currentTarget.closest(".ul-card-rank__option");
F && (N.current = F, F.classList.add("is-dragging"));
}, y = (I) => {
if (!B || !o.current || l.current === null) return;
I.preventDefault(), I.stopPropagation();
const $ = I.touches[0];
c.current = $.clientY;
const H = c.current - b.current;
N.current && (N.current.style.transform = `translateY(${H}px)`, N.current.style.zIndex = "1000"), f.current.forEach((W) => {
W && W !== N.current && W.classList.remove("is-drop-target");
});
const F = V($.clientX, $.clientY);
F && F.element.classList.add("is-drop-target");
}, q = (I) => {
if (!B || !o.current || l.current === null) return;
I.preventDefault(), I.stopPropagation();
const $ = I.changedTouches[0], H = V($.clientX, $.clientY);
N.current && (N.current.style.transform = "", N.current.style.zIndex = "", N.current.classList.remove("is-dragging")), f.current.forEach((F) => {
F && F.classList.remove("is-drop-target");
}), H && H.index !== l.current && R(l.current, H.index), l.current = null, N.current = null, o.current = !1;
}, R = (I, $) => {
E((H) => {
const F = H.map((oe) => ({ ...oe })), [W] = F.splice(I, 1);
return F.splice($, 0, W), F.forEach((oe, X) => {
oe.rank = X + 1;
}), j(F), F;
});
}, L = (I) => {
const $ = {};
I.reduce((H, F) => (H[F.id] = F.rank, H), $), t({ value: $, questionId: a, type: g }, !0);
}, j = (I) => {
k(!1), _(!0), U && L(I);
}, { left: Z, right: se } = s, ce = u.length, xe = (I) => {
I.preventDefault(), I.currentTarget.classList.add("is-drop-target");
}, Se = (I) => {
I.currentTarget.classList.remove("is-drop-target");
}, ge = (I) => {
l.current = null, I.currentTarget.classList.remove("is-dragging");
};
return e("form", { className: O(n, "ul-card-rank", "fade-in-transition", U && !z && "ul-card--unfocused"), onClick: U && !z ? () => {
S(a);
} : void 0, onSubmit: T, children: [e(ae, { isRequired: r == null ? void 0 : r.required, message: d, properties: r }), e(me, { properties: r, children: e(ve, C ? { children: [e(le, { children: [e("div", { className: "ul-card--rank__question-inner-container", children: [e("div", { className: "ul-card-rank__labels", children: e("span", { children: ["1 - ", Z] }) }), e("ol", { className: "ul-card-rank__list", children: w.map(({ id: I, label: $, rank: H }) => e("li", { className: "ul-card-rank__option", children: [e("select", { "aria-label": `Rank for ${$}`, className: O("ul-card-rank__select", H == null && "ul-card-rank__select--placeholder"), name: `rank[${I}]`, onChange: (F) => Q(I, F.currentTarget.value), value: H ?? "", children: [H == null && e("option", { className: "ul-card-rank__select-option", disabled: !0, value: "", children: "-" }), M.map((F) => e("option", { className: "ul-card-rank__select-option", value: F, children: F }, `${F}-${a}`))] }), e("span", { children: $ })] }, I)) }), e("div", { className: "ul-card-rank__labels", children: e("span", { children: [ce, " - ", se] }) })] }), h && e(Te, { handleSubmit: T, isSubmitDisabled: p })] }), !U && e(pe, { children: e("div", { className: "ul-card__button-wrapper", children: e(ee, { disabled: p, children: be(r) }) }) })] } : { children: [e(le, { children: [e("div", { className: "ul-card--rank__question-inner-container", children: [e("div", { className: "ul-card-rank__labels", children: e("span", {