UNPKG

@sprig-technologies/sprig-browser

Version:

npm package for the sprig web sdk

1,064 lines 187 kB
import { A as ke, D as Wr, a as Zr, C as Mt, i as Gr, E as Kr, b as Se, d as bt, r as Yr, e as Ot } from "./core-DLrmR9wp.js"; import { e as je, h as qe, S as J, s as lt, D as Ut, b as Qr, v as dt } from "./metricsReporter-qetrFwEv.js"; var De, P, Rn, fe, Ht, Nn, ct, Ln, Pe = {}, Mn = [], Jr = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, Ze = Array.isArray; function ae(e, t) { for (var n in t) e[n] = t[n]; return e; } function On(e) { var t = e.parentNode; t && t.removeChild(e); } function V(e, t, n) { var r, o, i, s = {}; for (i in t) i == "key" ? r = t[i] : i == "ref" ? o = t[i] : s[i] = t[i]; if (arguments.length > 2 && (s.children = arguments.length > 3 ? De.call(arguments, 2) : n), typeof e == "function" && e.defaultProps != null) for (i in e.defaultProps) s[i] === void 0 && (s[i] = e.defaultProps[i]); return Ie(e, s, r, o, null); } function Ie(e, t, n, r, o) { var i = { type: e, props: t, key: n, ref: r, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: o ?? ++Rn, __i: -1, __u: 0 }; return o == null && P.vnode != null && P.vnode(i), i; } function Un() { return { current: null }; } function Z(e) { return e.children; } function te(e, t) { this.props = e, this.context = t; } function we(e, t) { if (t == null) return e.__ ? we(e.__, e.__i + 1) : null; for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) != null && n.__e != null) return n.__e; return typeof e.type == "function" ? we(e) : null; } function Hn(e) { var t, n; if ((e = e.__) != null && e.__c != null) { for (e.__e = e.__c.base = null, t = 0; t < e.__k.length; t++) if ((n = e.__k[t]) != null && n.__e != null) { e.__e = e.__c.base = n.__e; break; } return Hn(e); } } function ut(e) { (!e.__d && (e.__d = !0) && fe.push(e) && !Ve.__r++ || Ht !== P.debounceRendering) && ((Ht = P.debounceRendering) || Nn)(Ve); } function Ve() { var e, t, n, r, o, i, s, d, a; for (fe.sort(ct); e = fe.shift(); ) e.__d && (t = fe.length, r = void 0, i = (o = (n = e).__v).__e, d = [], a = [], (s = n.__P) && ((r = ae({}, o)).__v = o.__v + 1, P.vnode && P.vnode(r), yt(s, r, o, n.__n, s.ownerSVGElement !== void 0, 32 & o.__u ? [i] : null, d, i ?? we(o), !!(32 & o.__u), a), r.__.__k[r.__i] = r, qn(d, r, a), r.__e != i && Hn(r)), fe.length > t && fe.sort(ct)); Ve.__r = 0; } function An(e, t, n, r, o, i, s, d, a, u, h) { var c, p, m, g, b, v = r && r.__k || Mn, _ = t.length; for (n.__d = a, function(f, T, S) { var w, x, j, D, y, E = T.length, k = S.length, I = k, N = 0; for (f.__k = [], w = 0; w < E; w++) (x = f.__k[w] = (x = T[w]) == null || typeof x == "boolean" || typeof x == "function" ? null : typeof x == "string" || typeof x == "number" || typeof x == "bigint" || x.constructor == String ? Ie(null, x, null, null, x) : Ze(x) ? Ie(Z, { children: x }, null, null, null) : x.constructor === void 0 && x.__b > 0 ? Ie(x.type, x.props, x.key, x.ref ? x.ref : null, x.__v) : x) != null ? (x.__ = f, x.__b = f.__b + 1, y = Xr(x, S, D = w + N, I), x.__i = y, j = null, y !== -1 && (I--, (j = S[y]) && (j.__u |= 131072)), j == null || j.__v === null ? (y == -1 && N--, typeof x.type != "function" && (x.__u |= 65536)) : y !== D && (y === D + 1 ? N++ : y > D ? I > E - D ? N += y - D : N-- : N = y < D && y == D - 1 ? y - D : 0, y !== w + N && (x.__u |= 65536))) : (j = S[w]) && j.key == null && j.__e && (j.__e == f.__d && (f.__d = we(j)), pt(j, j, !1), S[w] = null, I--); if (I) for (w = 0; w < k; w++) (j = S[w]) != null && !(131072 & j.__u) && (j.__e == f.__d && (f.__d = we(j)), pt(j, j)); }(n, t, v), a = n.__d, c = 0; c < _; c++) (m = n.__k[c]) != null && typeof m != "boolean" && typeof m != "function" && (p = m.__i === -1 ? Pe : v[m.__i] || Pe, m.__i = c, yt(e, m, p, o, i, s, d, a, u, h), g = m.__e, m.ref && p.ref != m.ref && (p.ref && xt(p.ref, null, m), h.push(m.ref, m.__c || g, m)), b == null && g != null && (b = g), 65536 & m.__u || p.__k === m.__k ? a = Bn(m, a, e) : typeof m.type == "function" && m.__d !== void 0 ? a = m.__d : g && (a = g.nextSibling), m.__d = void 0, m.__u &= -196609); n.__d = a, n.__e = b; } function Bn(e, t, n) { var r, o; if (typeof e.type == "function") { for (r = e.__k, o = 0; r && o < r.length; o++) r[o] && (r[o].__ = e, t = Bn(r[o], t, n)); return t; } return e.__e != t && (n.insertBefore(e.__e, t || null), t = e.__e), t && t.nextSibling; } function le(e, t) { return t = t || [], e == null || typeof e == "boolean" || (Ze(e) ? e.some(function(n) { le(n, t); }) : t.push(e)), t; } function Xr(e, t, n, r) { var o = e.key, i = e.type, s = n - 1, d = n + 1, a = t[n]; if (a === null || a && o == a.key && i === a.type) return n; if (r > (a == null || 131072 & a.__u ? 0 : 1)) for (; s >= 0 || d < t.length; ) { if (s >= 0) { if ((a = t[s]) && !(131072 & a.__u) && o == a.key && i === a.type) return s; s--; } if (d < t.length) { if ((a = t[d]) && !(131072 & a.__u) && o == a.key && i === a.type) return d; d++; } } return -1; } function At(e, t, n) { t[0] === "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || Jr.test(t) ? n : n + "px"; } function Me(e, t, n, r, o) { var i; e: if (t === "style") if (typeof n == "string") e.style.cssText = n; else { if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || At(e.style, t, ""); if (n) for (t in n) r && n[t] === r[t] || At(e.style, t, n[t]); } else if (t[0] === "o" && t[1] === "n") i = t !== (t = t.replace(/(PointerCapture)$|Capture$/, "$1")), t = t.toLowerCase() in e ? t.toLowerCase().slice(2) : t.slice(2), e.l || (e.l = {}), e.l[t + i] = n, n ? r ? n.u = r.u : (n.u = Date.now(), e.addEventListener(t, i ? qt : Bt, i)) : e.removeEventListener(t, i ? qt : Bt, i); else { if (o) t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s"); else if (t !== "width" && t !== "height" && t !== "href" && t !== "list" && t !== "form" && t !== "tabIndex" && t !== "download" && t !== "rowSpan" && t !== "colSpan" && t !== "role" && t in e) try { e[t] = n ?? ""; break e; } catch { } typeof n == "function" || (n == null || n === !1 && t[4] !== "-" ? e.removeAttribute(t) : e.setAttribute(t, n)); } } function Bt(e) { var t = this.l[e.type + !1]; if (e.t) { if (e.t <= t.u) return; } else e.t = Date.now(); return t(P.event ? P.event(e) : e); } function qt(e) { return this.l[e.type + !0](P.event ? P.event(e) : e); } function yt(e, t, n, r, o, i, s, d, a, u) { var h, c, p, m, g, b, v, _, f, T, S, w, x, j, D, y = t.type; if (t.constructor !== void 0) return null; 128 & n.__u && (a = !!(32 & n.__u), i = [d = t.__e = n.__e]), (h = P.__b) && h(t); e: if (typeof y == "function") try { if (_ = t.props, f = (h = y.contextType) && r[h.__c], T = h ? f ? f.props.value : h.__ : r, n.__c ? v = (c = t.__c = n.__c).__ = c.__E : ("prototype" in y && y.prototype.render ? t.__c = c = new y(_, T) : (t.__c = c = new te(_, T), c.constructor = y, c.render = to), f && f.sub(c), c.props = _, c.state || (c.state = {}), c.context = T, c.__n = r, p = c.__d = !0, c.__h = [], c._sb = []), c.__s == null && (c.__s = c.state), y.getDerivedStateFromProps != null && (c.__s == c.state && (c.__s = ae({}, c.__s)), ae(c.__s, y.getDerivedStateFromProps(_, c.__s))), m = c.props, g = c.state, c.__v = t, p) y.getDerivedStateFromProps == null && c.componentWillMount != null && c.componentWillMount(), c.componentDidMount != null && c.__h.push(c.componentDidMount); else { if (y.getDerivedStateFromProps == null && _ !== m && c.componentWillReceiveProps != null && c.componentWillReceiveProps(_, T), !c.__e && (c.shouldComponentUpdate != null && c.shouldComponentUpdate(_, c.__s, T) === !1 || t.__v === n.__v)) { for (t.__v !== n.__v && (c.props = _, c.state = c.__s, c.__d = !1), t.__e = n.__e, t.__k = n.__k, t.__k.forEach(function(E) { E && (E.__ = t); }), S = 0; S < c._sb.length; S++) c.__h.push(c._sb[S]); c._sb = [], c.__h.length && s.push(c); break e; } c.componentWillUpdate != null && c.componentWillUpdate(_, c.__s, T), c.componentDidUpdate != null && c.__h.push(function() { c.componentDidUpdate(m, g, b); }); } if (c.context = T, c.props = _, c.__P = e, c.__e = !1, w = P.__r, x = 0, "prototype" in y && y.prototype.render) { for (c.state = c.__s, c.__d = !1, w && w(t), h = c.render(c.props, c.state, c.context), j = 0; j < c._sb.length; j++) c.__h.push(c._sb[j]); c._sb = []; } else do c.__d = !1, w && w(t), h = c.render(c.props, c.state, c.context), c.state = c.__s; while (c.__d && ++x < 25); c.state = c.__s, c.getChildContext != null && (r = ae(ae({}, r), c.getChildContext())), p || c.getSnapshotBeforeUpdate == null || (b = c.getSnapshotBeforeUpdate(m, g)), An(e, Ze(D = h != null && h.type === Z && h.key == null ? h.props.children : h) ? D : [D], t, n, r, o, i, s, d, a, u), c.base = t.__e, t.__u &= -161, c.__h.length && s.push(c), v && (c.__E = c.__ = null); } catch (E) { t.__v = null, a || i != null ? (t.__e = d, t.__u |= a ? 160 : 32, i[i.indexOf(d)] = null) : (t.__e = n.__e, t.__k = n.__k), P.__e(E, t, n); } else i == null && t.__v === n.__v ? (t.__k = n.__k, t.__e = n.__e) : t.__e = eo(n.__e, t, n, r, o, i, s, a, u); (h = P.diffed) && h(t); } function qn(e, t, n) { t.__d = void 0; for (var r = 0; r < n.length; r++) xt(n[r], n[++r], n[++r]); P.__c && P.__c(t, e), e.some(function(o) { try { e = o.__h, o.__h = [], e.some(function(i) { i.call(o); }); } catch (i) { P.__e(i, o.__v); } }); } function eo(e, t, n, r, o, i, s, d, a) { var u, h, c, p, m, g, b, v = n.props, _ = t.props, f = t.type; if (f === "svg" && (o = !0), i != null) { for (u = 0; u < i.length; u++) if ((m = i[u]) && "setAttribute" in m == !!f && (f ? m.localName === f : m.nodeType === 3)) { e = m, i[u] = null; break; } } if (e == null) { if (f === null) return document.createTextNode(_); e = o ? document.createElementNS("http://www.w3.org/2000/svg", f) : document.createElement(f, _.is && _), i = null, d = !1; } if (f === null) v === _ || d && e.data === _ || (e.data = _); else { if (i = i && De.call(e.childNodes), v = n.props || Pe, !d && i != null) for (v = {}, u = 0; u < e.attributes.length; u++) v[(m = e.attributes[u]).name] = m.value; for (u in v) m = v[u], u == "children" || (u == "dangerouslySetInnerHTML" ? c = m : u === "key" || u in _ || Me(e, u, null, m, o)); for (u in _) m = _[u], u == "children" ? p = m : u == "dangerouslySetInnerHTML" ? h = m : u == "value" ? g = m : u == "checked" ? b = m : u === "key" || d && typeof m != "function" || v[u] === m || Me(e, u, m, v[u], o); if (h) d || c && (h.__html === c.__html || h.__html === e.innerHTML) || (e.innerHTML = h.__html), t.__k = []; else if (c && (e.innerHTML = ""), An(e, Ze(p) ? p : [p], t, n, r, o && f !== "foreignObject", i, s, i ? i[0] : n.__k && we(n, 0), d, a), i != null) for (u = i.length; u--; ) i[u] != null && On(i[u]); d || (u = "value", g !== void 0 && (g !== e[u] || f === "progress" && !g || f === "option" && g !== v[u]) && Me(e, u, g, v[u], !1), u = "checked", b !== void 0 && b !== e[u] && Me(e, u, b, v[u], !1)); } return e; } function xt(e, t, n) { try { typeof e == "function" ? e(t) : e.current = t; } catch (r) { P.__e(r, n); } } function pt(e, t, n) { var r, o; if (P.unmount && P.unmount(e), (r = e.ref) && (r.current && r.current !== e.__e || xt(r, null, t)), (r = e.__c) != null) { if (r.componentWillUnmount) try { r.componentWillUnmount(); } catch (i) { P.__e(i, t); } r.base = r.__P = null, e.__c = void 0; } if (r = e.__k) for (o = 0; o < r.length; o++) r[o] && pt(r[o], t, n || typeof e.type != "function"); n || e.__e == null || On(e.__e), e.__ = e.__e = e.__d = void 0; } function to(e, t, n) { return this.constructor(e, n); } function Ce(e, t, n) { var r, o, i, s; P.__ && P.__(e, t), o = (r = typeof n == "function") ? null : n && n.__k || t.__k, i = [], s = [], yt(t, e = (!r && n || t).__k = V(Z, null, [e]), o || Pe, Pe, t.ownerSVGElement !== void 0, !r && n ? [n] : o ? null : t.firstChild ? De.call(t.childNodes) : null, i, !r && n ? n : o ? o.__e : t.firstChild, r, s), qn(i, e, s); } function Vn(e, t) { Ce(e, t, Vn); } function no(e, t, n) { var r, o, i, s, d = ae({}, e.props); for (i in e.type && e.type.defaultProps && (s = e.type.defaultProps), t) i == "key" ? r = t[i] : i == "ref" ? o = t[i] : d[i] = t[i] === void 0 && s !== void 0 ? s[i] : t[i]; return arguments.length > 2 && (d.children = arguments.length > 3 ? De.call(arguments, 2) : n), Ie(e.type, d, r || e.key, o || e.ref, null); } function zn(e, t) { var n = { __c: t = "__cC" + Ln++, __: e, Consumer: function(r, o) { return r.children(o); }, Provider: function(r) { var o, i; return this.getChildContext || (o = [], (i = {})[t] = this, this.getChildContext = function() { return i; }, this.shouldComponentUpdate = function(s) { this.props.value !== s.value && o.some(function(d) { d.__e = !0, ut(d); }); }, this.sub = function(s) { o.push(s); var d = s.componentWillUnmount; s.componentWillUnmount = function() { o.splice(o.indexOf(s), 1), d && d.call(s); }; }), r.children; } }; return n.Provider.__ = n.Consumer.contextType = n; } De = Mn.slice, P = { __e: function(e, t, n, r) { for (var o, i, s; t = t.__; ) if ((o = t.__c) && !o.__) try { if ((i = o.constructor) && i.getDerivedStateFromError != null && (o.setState(i.getDerivedStateFromError(e)), s = o.__d), o.componentDidCatch != null && (o.componentDidCatch(e, r || {}), s = o.__d), s) return o.__E = o; } catch (d) { e = d; } throw e; } }, Rn = 0, te.prototype.setState = function(e, t) { var n; n = this.__s != null && this.__s !== this.state ? this.__s : this.__s = ae({}, this.state), typeof e == "function" && (e = e(ae({}, n), this.props)), e && ae(n, e), e != null && this.__v && (t && this._sb.push(t), ut(this)); }, te.prototype.forceUpdate = function(e) { this.__v && (this.__e = !0, e && this.__h.push(e), ut(this)); }, te.prototype.render = Z, fe = [], Nn = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, ct = function(e, t) { return e.__v.__b - t.__v.__b; }, Ve.__r = 0, Ln = 0; var ro = 0; function l(e, t, n, r, o, i) { var s, d, a = {}; for (d in t) d == "ref" ? s = t[d] : a[d] = t[d]; var u = { type: e, props: a, key: n, ref: s, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: --ro, __i: -1, __u: 0, __source: o, __self: i }; if (typeof e == "function" && (s = e.defaultProps)) for (d in s) a[d] === void 0 && (a[d] = s[d]); return P.vnode && P.vnode(u), u; } var de, q, Qe, Vt, Ee = 0, $n = [], Oe = [], zt = P.__b, $t = P.__r, Ft = P.diffed, Wt = P.__c, Zt = P.unmount; function be(e, t) { P.__h && P.__h(q, e, Ee || t), Ee = 0; var n = q.__H || (q.__H = { __: [], __h: [] }); return e >= n.__.length && n.__.push({ __V: Oe }), n.__[e]; } function z(e) { return Ee = 1, kt(Gn, e); } function kt(e, t, n) { var r = be(de++, 2); if (r.t = e, !r.__c && (r.__ = [n ? n(t) : Gn(void 0, t), function(d) { var a = r.__N ? r.__N[0] : r.__[0], u = r.t(a, d); a !== u && (r.__N = [u, r.__[1]], r.__c.setState({})); }], r.__c = q, !q.u)) { var o = function(d, a, u) { if (!r.__c.__H) return !0; var h = r.__c.__H.__.filter(function(p) { return p.__c; }); if (h.every(function(p) { return !p.__N; })) return !i || i.call(this, d, a, u); var c = !1; return h.forEach(function(p) { if (p.__N) { var m = p.__[0]; p.__ = p.__N, p.__N = void 0, m !== p.__[0] && (c = !0); } }), !(!c && r.__c.props === d) && (!i || i.call(this, d, a, u)); }; q.u = !0; var i = q.shouldComponentUpdate, s = q.componentWillUpdate; q.componentWillUpdate = function(d, a, u) { if (this.__e) { var h = i; i = void 0, o(d, a, u), i = h; } s && s.call(this, d, a, u); }, q.shouldComponentUpdate = o; } return r.__N || r.__; } function F(e, t) { var n = be(de++, 3); !P.__s && Ct(n.__H, t) && (n.__ = e, n.i = t, q.__H.__h.push(n)); } function Re(e, t) { var n = be(de++, 4); !P.__s && Ct(n.__H, t) && (n.__ = e, n.i = t, q.__h.push(n)); } function X(e) { return Ee = 5, Ne(function() { return { current: e }; }, []); } function Fn(e, t, n) { Ee = 6, Re(function() { return typeof e == "function" ? (e(t()), function() { return e(null); }) : e ? (e.current = t(), function() { return e.current = null; }) : void 0; }, n == null ? n : n.concat(e)); } function Ne(e, t) { var n = be(de++, 7); return Ct(n.__H, t) ? (n.__V = e(), n.i = t, n.__h = e, n.__V) : n.__; } function ze(e, t) { return Ee = 8, Ne(function() { return e; }, t); } function Wn(e) { var t = q.context[e.__c], n = be(de++, 9); return n.c = e, t ? (n.__ == null && (n.__ = !0, t.sub(q)), t.props.value) : e.__; } function wt(e, t) { P.useDebugValue && P.useDebugValue(t ? t(e) : e); } function Zn() { var e = be(de++, 11); if (!e.__) { for (var t = q.__v; t !== null && !t.__m && t.__ !== null; ) t = t.__; var n = t.__m || (t.__m = [0, 0]); e.__ = "P" + n[0] + "-" + n[1]++; } return e.__; } function oo() { for (var e; e = $n.shift(); ) if (e.__P && e.__H) try { e.__H.__h.forEach(Ue), e.__H.__h.forEach(ht), e.__H.__h = []; } catch (t) { e.__H.__h = [], P.__e(t, e.__v); } } P.__b = function(e) { q = null, zt && zt(e); }, P.__r = function(e) { $t && $t(e), de = 0; var t = (q = e.__c).__H; t && (Qe === q ? (t.__h = [], q.__h = [], t.__.forEach(function(n) { n.__N && (n.__ = n.__N), n.__V = Oe, n.__N = n.i = void 0; })) : (t.__h.forEach(Ue), t.__h.forEach(ht), t.__h = [], de = 0)), Qe = q; }, P.diffed = function(e) { Ft && Ft(e); var t = e.__c; t && t.__H && (t.__H.__h.length && ($n.push(t) !== 1 && Vt === P.requestAnimationFrame || ((Vt = P.requestAnimationFrame) || io)(oo)), t.__H.__.forEach(function(n) { n.i && (n.__H = n.i), n.__V !== Oe && (n.__ = n.__V), n.i = void 0, n.__V = Oe; })), Qe = q = null; }, P.__c = function(e, t) { t.some(function(n) { try { n.__h.forEach(Ue), n.__h = n.__h.filter(function(r) { return !r.__ || ht(r); }); } catch (r) { t.some(function(o) { o.__h && (o.__h = []); }), t = [], P.__e(r, n.__v); } }), Wt && Wt(e, t); }, P.unmount = function(e) { Zt && Zt(e); var t, n = e.__c; n && n.__H && (n.__H.__.forEach(function(r) { try { Ue(r); } catch (o) { t = o; } }), n.__H = void 0, t && P.__e(t, n.__v)); }; var Gt = typeof requestAnimationFrame == "function"; function io(e) { var t, n = function() { clearTimeout(r), Gt && cancelAnimationFrame(t), setTimeout(e); }, r = setTimeout(n, 100); Gt && (t = requestAnimationFrame(n)); } function Ue(e) { var t = q, n = e.__c; typeof n == "function" && (e.__c = void 0, n()), q = t; } function ht(e) { var t = q; e.__c = e.__(), q = t; } function Ct(e, t) { return !e || e.length !== t.length || t.some(function(n, r) { return n !== e[r]; }); } function Gn(e, t) { return typeof t == "function" ? t(e) : t; } function Kn(e, t) { for (var n in t) e[n] = t[n]; return e; } function mt(e, t) { for (var n in e) if (n !== "__source" && !(n in t)) return !0; for (var r in t) if (r !== "__source" && e[r] !== t[r]) return !0; return !1; } function $e(e) { this.props = e; } function Yn(e, t) { function n(o) { var i = this.props.ref, s = i == o.ref; return !s && i && (i.call ? i(null) : i.current = null), t ? !t(this.props, o) || !s : mt(this.props, o); } function r(o) { return this.shouldComponentUpdate = n, V(e, o); } return r.displayName = "Memo(" + (e.displayName || e.name) + ")", r.prototype.isReactComponent = !0, r.__f = !0, r; } ($e.prototype = new te()).isPureReactComponent = !0, $e.prototype.shouldComponentUpdate = function(e, t) { return mt(this.props, e) || mt(this.state, t); }; var Kt = P.__b; P.__b = function(e) { e.type && e.type.__f && e.ref && (e.props.ref = e.ref, e.ref = null), Kt && Kt(e); }; var so = typeof Symbol < "u" && Symbol.for && Symbol.for("react.forward_ref") || 3911; function Et(e) { function t(n) { var r = Kn({}, n); return delete r.ref, e(r, n.ref || null); } return t.$$typeof = so, t.render = t, t.prototype.isReactComponent = t.__f = !0, t.displayName = "ForwardRef(" + (e.displayName || e.name) + ")", t; } var Yt = function(e, t) { return e == null ? null : le(le(e).map(t)); }, Qn = { map: Yt, forEach: Yt, count: function(e) { return e ? le(e).length : 0; }, only: function(e) { var t = le(e); if (t.length !== 1) throw "Children.only"; return t[0]; }, toArray: le }, ao = P.__e; P.__e = function(e, t, n, r) { if (e.then) { for (var o, i = t; i = i.__; ) if ((o = i.__c) && o.__c) return t.__e == null && (t.__e = n.__e, t.__k = n.__k), o.__c(e, t); } ao(e, t, n, r); }; var Qt = P.unmount; function Jn(e, t, n) { return e && (e.__c && e.__c.__H && (e.__c.__H.__.forEach(function(r) { typeof r.__c == "function" && r.__c(); }), e.__c.__H = null), (e = Kn({}, e)).__c != null && (e.__c.__P === n && (e.__c.__P = t), e.__c = null), e.__k = e.__k && e.__k.map(function(r) { return Jn(r, t, n); })), e; } function Xn(e, t, n) { return e && n && (e.__v = null, e.__k = e.__k && e.__k.map(function(r) { return Xn(r, t, n); }), e.__c && e.__c.__P === t && (e.__e && n.appendChild(e.__e), e.__c.__e = !0, e.__c.__P = n)), e; } function Te() { this.__u = 0, this.t = null, this.__b = null; } function er(e) { var t = e.__.__c; return t && t.__a && t.__a(e); } function tr(e) { var t, n, r; function o(i) { if (t || (t = e()).then(function(s) { n = s.default || s; }, function(s) { r = s; }), r) throw r; if (!n) throw t; return V(n, i); } return o.displayName = "Lazy", o.__f = !0, o; } function xe() { this.u = null, this.o = null; } P.unmount = function(e) { var t = e.__c; t && t.__R && t.__R(), t && 32 & e.__u && (e.type = null), Qt && Qt(e); }, (Te.prototype = new te()).__c = function(e, t) { var n = t.__c, r = this; r.t == null && (r.t = []), r.t.push(n); var o = er(r.__v), i = !1, s = function() { i || (i = !0, n.__R = null, o ? o(d) : d()); }; n.__R = s; var d = function() { if (!--r.__u) { if (r.state.__a) { var a = r.state.__a; r.__v.__k[0] = Xn(a, a.__c.__P, a.__c.__O); } var u; for (r.setState({ __a: r.__b = null }); u = r.t.pop(); ) u.forceUpdate(); } }; r.__u++ || 32 & t.__u || r.setState({ __a: r.__b = r.__v.__k[0] }), e.then(s, s); }, Te.prototype.componentWillUnmount = function() { this.t = []; }, Te.prototype.render = function(e, t) { if (this.__b) { if (this.__v.__k) { var n = document.createElement("div"), r = this.__v.__k[0].__c; this.__v.__k[0] = Jn(this.__b, n, r.__O = r.__P); } this.__b = null; } var o = t.__a && V(Z, null, e.fallback); return o && (o.__u &= -33), [V(Z, null, t.__a ? null : e.children), o]; }; var Jt = function(e, t, n) { if (++n[1] === n[0] && e.o.delete(t), e.props.revealOrder && (e.props.revealOrder[0] !== "t" || !e.o.size)) for (n = e.u; n; ) { for (; n.length > 3; ) n.pop()(); if (n[1] < n[0]) break; e.u = n = n[2]; } }; function lo(e) { return this.getChildContext = function() { return e.context; }, e.children; } function co(e) { var t = this, n = e.i; t.componentWillUnmount = function() { Ce(null, t.l), t.l = null, t.i = null; }, t.i && t.i !== n && t.componentWillUnmount(), t.l || (t.i = n, t.l = { nodeType: 1, parentNode: n, childNodes: [], appendChild: function(r) { this.childNodes.push(r), t.i.appendChild(r); }, insertBefore: function(r, o) { this.childNodes.push(r), t.i.appendChild(r); }, removeChild: function(r) { this.childNodes.splice(this.childNodes.indexOf(r) >>> 1, 1), t.i.removeChild(r); } }), Ce(V(lo, { context: t.context }, e.__v), t.l); } function nr(e, t) { var n = V(co, { __v: e, i: t }); return n.containerInfo = t, n; } (xe.prototype = new te()).__a = function(e) { var t = this, n = er(t.__v), r = t.o.get(e); return r[0]++, function(o) { var i = function() { t.props.revealOrder ? (r.push(o), Jt(t, e, r)) : o(); }; n ? n(i) : i(); }; }, xe.prototype.render = function(e) { this.u = null, this.o = /* @__PURE__ */ new Map(); var t = le(e.children); e.revealOrder && e.revealOrder[0] === "b" && t.reverse(); for (var n = t.length; n--; ) this.o.set(t[n], this.u = [1, 0, this.u]); return e.children; }, xe.prototype.componentDidUpdate = xe.prototype.componentDidMount = function() { var e = this; this.o.forEach(function(t, n) { Jt(e, n, t); }); }; var rr = typeof Symbol < "u" && Symbol.for && Symbol.for("react.element") || 60103, uo = /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/, po = /^on(Ani|Tra|Tou|BeforeInp|Compo)/, ho = /[A-Z0-9]/g, mo = typeof document < "u", go = function(e) { return (typeof Symbol < "u" && typeof Symbol() == "symbol" ? /fil|che|rad/ : /fil|che|ra/).test(e); }; function or(e, t, n) { return t.__k == null && (t.textContent = ""), Ce(e, t), typeof n == "function" && n(), e ? e.__c : null; } function ir(e, t, n) { return Vn(e, t), typeof n == "function" && n(), e ? e.__c : null; } te.prototype.isReactComponent = {}, ["componentWillMount", "componentWillReceiveProps", "componentWillUpdate"].forEach(function(e) { Object.defineProperty(te.prototype, e, { configurable: !0, get: function() { return this["UNSAFE_" + e]; }, set: function(t) { Object.defineProperty(this, e, { configurable: !0, writable: !0, value: t }); } }); }); var Xt = P.event; function vo() { } function fo() { return this.cancelBubble; } function _o() { return this.defaultPrevented; } P.event = function(e) { return Xt && (e = Xt(e)), e.persist = vo, e.isPropagationStopped = fo, e.isDefaultPrevented = _o, e.nativeEvent = e; }; var St, bo = { enumerable: !1, configurable: !0, get: function() { return this.class; } }, en = P.vnode; P.vnode = function(e) { typeof e.type == "string" && function(t) { var n = t.props, r = t.type, o = {}; for (var i in n) { var s = n[i]; if (!(i === "value" && "defaultValue" in n && s == null || mo && i === "children" && r === "noscript" || i === "class" || i === "className")) { var d = i.toLowerCase(); i === "defaultValue" && "value" in n && n.value == null ? i = "value" : i === "download" && s === !0 ? s = "" : d === "ondoubleclick" ? i = "ondblclick" : d !== "onchange" || r !== "input" && r !== "textarea" || go(n.type) ? d === "onfocus" ? i = "onfocusin" : d === "onblur" ? i = "onfocusout" : po.test(i) ? i = d : r.indexOf("-") === -1 && uo.test(i) ? i = i.replace(ho, "-$&").toLowerCase() : s === null && (s = void 0) : d = i = "oninput", d === "oninput" && o[i = d] && (i = "oninputCapture"), o[i] = s; } } r == "select" && o.multiple && Array.isArray(o.value) && (o.value = le(n.children).forEach(function(a) { a.props.selected = o.value.indexOf(a.props.value) != -1; })), r == "select" && o.defaultValue != null && (o.value = le(n.children).forEach(function(a) { a.props.selected = o.multiple ? o.defaultValue.indexOf(a.props.value) != -1 : o.defaultValue == a.props.value; })), n.class && !n.className ? (o.class = n.class, Object.defineProperty(o, "className", bo)) : (n.className && !n.class || n.class && n.className) && (o.class = o.className = n.className), t.props = o; }(e), e.$$typeof = rr, en && en(e); }; var tn = P.__r; P.__r = function(e) { tn && tn(e), St = e.__c; }; var nn = P.diffed; P.diffed = function(e) { nn && nn(e); var t = e.props, n = e.__e; n != null && e.type === "textarea" && "value" in t && t.value !== n.value && (n.value = t.value == null ? "" : t.value), St = null; }; var sr = { ReactCurrentDispatcher: { current: { readContext: function(e) { return St.__n[e.__c].props.value; } } } }; function ar(e) { return V.bind(null, e); } function Le(e) { return !!e && e.$$typeof === rr; } function lr(e) { return Le(e) && e.type === Z; } function dr(e) { return Le(e) ? no.apply(null, arguments) : e; } function jt(e) { return !!e.__k && (Ce(null, e), !0); } function cr(e) { return e && (e.base || e.nodeType === 1 && e) || null; } var ur = function(e, t) { return e(t); }, pr = function(e, t) { return e(t); }, hr = Z; function It(e) { e(); } function mr(e) { return e; } function gr() { return [!1, It]; } var vr = Re, fr = Le; function _r(e, t) { var n = t(), r = z({ h: { __: n, v: t } }), o = r[0].h, i = r[1]; return Re(function() { o.__ = n, o.v = t, Je(o) && i({ h: o }); }, [e, n, t]), F(function() { return Je(o) && i({ h: o }), e(function() { Je(o) && i({ h: o }); }); }, [e]), n; } function Je(e) { var t, n, r = e.v, o = e.__; try { var i = r(); return !((t = o) === (n = i) && (t !== 0 || 1 / t == 1 / n) || t != t && n != n); } catch { return !0; } } var yo = { useState: z, useId: Zn, useReducer: kt, useEffect: F, useLayoutEffect: Re, useInsertionEffect: vr, useTransition: gr, useDeferredValue: mr, useSyncExternalStore: _r, startTransition: It, useRef: X, useImperativeHandle: Fn, useMemo: Ne, useCallback: ze, useContext: Wn, useDebugValue: wt, version: "17.0.2", Children: Qn, render: or, hydrate: ir, unmountComponentAtNode: jt, createPortal: nr, createElement: V, createContext: zn, createFactory: ar, cloneElement: dr, createRef: Un, Fragment: Z, isValidElement: Le, isElement: fr, isFragment: lr, findDOMNode: cr, Component: te, PureComponent: $e, memo: Yn, forwardRef: Et, flushSync: pr, unstable_batchedUpdates: ur, StrictMode: hr, Suspense: Te, SuspenseList: xe, lazy: tr, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: sr }; const xo = Object.freeze(Object.defineProperty({ __proto__: null, Children: Qn, Component: te, Fragment: Z, PureComponent: $e, StrictMode: hr, Suspense: Te, SuspenseList: xe, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: sr, cloneElement: dr, createContext: zn, createElement: V, createFactory: ar, createPortal: nr, createRef: Un, default: yo, findDOMNode: cr, flushSync: pr, forwardRef: Et, hydrate: ir, isElement: fr, isFragment: lr, isValidElement: Le, lazy: tr, memo: Yn, render: or, startTransition: It, unmountComponentAtNode: jt, unstable_batchedUpdates: ur, useCallback: ze, useContext: Wn, useDebugValue: wt, useDeferredValue: mr, useEffect: F, useErrorBoundary: function(e) { var t = be(de++, 10), n = z(); return t.__ = e, q.componentDidCatch || (q.componentDidCatch = function(r, o) { t.__ && t.__(r, o), n[1](r); }), [n[0], function() { n[1](void 0); }]; }, useId: Zn, useImperativeHandle: Fn, useInsertionEffect: vr, useLayoutEffect: Re, useMemo: Ne, useReducer: kt, useRef: X, useState: z, useSyncExternalStore: _r, useTransition: gr, version: "17.0.2" }, Symbol.toStringTag, { value: "Module" })), rn = (e) => { let t; const n = /* @__PURE__ */ new Set(), r = (s, d) => { const a = typeof s == "function" ? s(t) : s; if (!Object.is(a, t)) { const u = t; t = d ?? typeof a != "object" ? a : Object.assign({}, t, a), n.forEach((h) => h(t, u)); } }, o = () => t, i = { setState: r, getState: o, subscribe: (s) => (n.add(s), () => n.delete(s)), destroy: () => n.clear() }; return t = e(r, o, i), i; }; function ko(e) { return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e; } function wo(e) { if (Object.prototype.hasOwnProperty.call(e, "__esModule")) return e; var t = e.default; if (typeof t == "function") { var n = function r() { return this instanceof r ? Reflect.construct(t, arguments, this.constructor) : t.apply(this, arguments); }; n.prototype = t.prototype; } else n = {}; return Object.defineProperty(n, "__esModule", { value: !0 }), Object.keys(e).forEach(function(r) { var o = Object.getOwnPropertyDescriptor(e, r); Object.defineProperty(n, r, o.get ? o : { enumerable: !0, get: function() { return e[r]; } }); }), n; } var on = { exports: {} }, Xe = {}; const br = wo(xo); var sn, an, ln, dn, cn = { exports: {} }, et = {}; function Co() { return an || (an = 1, cn.exports = function() { if (sn) return et; sn = 1; var e = br, t = typeof Object.is == "function" ? Object.is : function(a, u) { return a === u && (a !== 0 || 1 / a == 1 / u) || a != a && u != u; }, n = e.useState, r = e.useEffect, o = e.useLayoutEffect, i = e.useDebugValue; function s(a) { var u = a.getSnapshot; a = a.value; try { var h = u(); return !t(a, h); } catch { return !0; } } var d = typeof window > "u" || window.document === void 0 || window.document.createElement === void 0 ? function(a, u) { return u(); } : function(a, u) { var h = u(), c = n({ inst: { value: h, getSnapshot: u } }), p = c[0].inst, m = c[1]; return o(function() { p.value = h, p.getSnapshot = u, s(p) && m({ inst: p }); }, [a, h, u]), r(function() { return s(p) && m({ inst: p }), a(function() { s(p) && m({ inst: p }); }); }, [a]), i(h), h; }; return et.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : d, et; }()), cn.exports; } var Eo = (dn || (dn = 1, on.exports = function() { if (ln) return Xe; ln = 1; var e = br, t = Co(), n = typeof Object.is == "function" ? Object.is : function(a, u) { return a === u && (a !== 0 || 1 / a == 1 / u) || a != a && u != u; }, r = t.useSyncExternalStore, o = e.useRef, i = e.useEffect, s = e.useMemo, d = e.useDebugValue; return Xe.useSyncExternalStoreWithSelector = function(a, u, h, c, p) { var m = o(null); if (m.current === null) { var g = { hasValue: !1, value: null }; m.current = g; } else g = m.current; m = s(function() { function v(w) { if (!T) { if (T = !0, _ = w, w = c(w), p !== void 0 && g.hasValue) { var x = g.value; if (p(x, w)) return f = x; } return f = w; } if (x = f, n(_, w)) return x; var j = c(w); return p !== void 0 && p(x, j) ? x : (_ = w, f = j); } var _, f, T = !1, S = h === void 0 ? null : h; return [function() { return v(u()); }, S === null ? void 0 : function() { return v(S()); }]; }, [u, h, c, p]); var b = r(a, m[0], m[1]); return i(function() { g.hasValue = !0, g.value = b; }, [b]), d(b), b; }, Xe; }()), on.exports); const So = ko(Eo), { useSyncExternalStoreWithSelector: jo } = So, un = (e) => { const t = typeof e == "function" ? ((r) => r ? rn(r) : rn)(e) : e, n = (r, o) => function(i, s = i.getState, d) { const a = jo(i.subscribe, i.getState, i.getServerState || i.getState, s, d); return wt(a), a; }(t, r, o); return Object.assign(n, t), n; }, yr = (e) => e ? un(e) : un, Io = 1, To = 2, Tt = { eq: (e, t) => e == t, neq(e, t) { return !this.eq(e, t); }, gt: (e, t) => e > t, gte: (e, t) => e >= t, lt: (e, t) => e < t, lte: (e, t) => e <= t, list_exact: (e, t) => !(!Array.isArray(e) || !Array.isArray(t)) && e.slice().sort().join(",") === t.slice().sort().join(","), list_all: (e, t) => !(!Array.isArray(e) || !Array.isArray(t)) && !t.some((n) => e.indexOf(n) === -1), list_alo(e, t) { if (!Array.isArray(t)) return !1; const n = Array.isArray(e) ? e : [e], r = new Set(n); return t.some((o) => r.has(o)); }, list_dni(e, t) { if (!Array.isArray(t)) return !1; const n = Array.isArray(e) ? e : [e], r = new Set(n); return t.every((o) => !r.has(o)); }, contains(e, t) { const n = e.toLowerCase(), r = t.toLowerCase(); return n.includes(r); }, notcontains(e, t) { return !this.contains(e, t); } }, Po = (e, t, n) => { switch (t) { case "videovoice": return !!(e && e.value); case "open": return !!n; case "multipleselect": return !!(n && Object.keys(n).length); case "recordedtask": return (n == null ? void 0 : n.taskStatus) === "completed"; case "texturlprompt": return !e.value; case "consentlegal": case "nps": case "likert": return n !== null; case "multiplechoice": return n !== void 0; case "matrix": return !!(n && Object.values(n).every((r) => r !== null)); default: return !0; } }, xr = (e, t) => { if (t === "matrix") { const n = Object.keys(e).length, r = Object.values(e).filter((o) => o !== null).length; return r > 0 && r < n; } return !1; }, kr = ({ cards: e, index: t, hasEndCard: n, allResponses: r, uploadProgress: o = {} }) => { if (t >= e.length || t < 0) return null; const i = e[t]; let s = t + 1; const d = i.props.routingOptions || []; for (let h = 0; h < d.length; h++) { const { group: c, target: p } = d[h]; if (!(c != null && c.length)) continue; const m = c[0]; if (m.questionIndex === void 0 || m.questionIndex > r.length) continue; let g = pn({ comparator: m.comparator, response: r[m.questionIndex], type: i.type, value: m.value }); for (let b = 1; b < c.length; b += 2) { const v = c[b], _ = c[b + 1], f = pn({ comparator: _.comparator, response: r[_.questionIndex], type: e[_.questionIndex].type, value: _.value }); v === Io ? g && (g = f) : v === To && (g || (g = f)); } if (g) { s = p === -1 && n ? e.length - 1 : p; break; } } const a = e.findIndex((h) => h.type === "uploading"); let u; return u = a > 0 ? n ? e.length - 3 : e.length - 2 : e.length - 1, t >= u || s === -1 || s !== null && s > u ? a > 0 && Object.values(o).some((c) => c.isSubmitted && !c.isComplete) ? a : n ? e.length - 1 : null : s === -1 ? null : s; }, pn = ({ comparator: e, response: t, type: n, value: r }) => { if (e === "answered") switch (n) { case "texturlprompt": return t === void 0; case "consentlegal": return t && t.submitted === !0; case "recordedtask": return "taskStatus" in t && t.taskStatus === "completed"; case "likert": case "nps": return Number.isInteger(t); case "matrix": return Object.values(t).every((o) => o !== null); case "multiplechoice": return t !== void 0; case "multipleselect": return (t == null ? void 0 : t.length) > 0; case "open": return t && t.length > 0; case "videovoice": return !!(t != null && t.mediaRecordingUid); default: return !1; } if (e === "given_up") return n !== "recordedtask" || "taskStatus" in t && t.taskStatus === "given.up"; if (e === "partial") return n === "matrix" && xr(t, n); if (e === "skipped") switch (n) { case "texturlprompt": return t == null ? void 0 : t.skipped; case "consentlegal": case "likert": case "nps": case "videovoice": return t === null; case "recordedtask": return "taskStatus" in t && t.taskStatus === "abandoned"; case "open": case "multipleselect": return (t == null ? void 0 : t.length) === 0; case "multiplechoice": return t === void 0; case "matrix": return Object.values(t).every((o) => o === null); default: return !1; } return Tt[e](t, r); }, Do = (e) => { var r, o, i; switch (e.type) { case "multipleselect": return e && e.props && e.props.options ? e.props.options.length > 13 ? e.props.options.map((s) => [s.value]) : (t = e.props.options.map((s) => s.value), n = !e.props.properties.required, t.reduce((s, d) => s.concat(s.map((a) => [...a, d])), [[]]).filter((s) => n || s.length > 0)) : null; case "multiplechoice": { if (!e || !e.props || !e.props.options) return null; const s = e.props.options.map((d) => d.value); return e.props.properties.required || s.push(void 0), s; } case "matrix": { if (!((r = e == null ? void 0 : e.props) != null && r.options)) return null; const s = e.props.properties.matrixColumn, d = e.props.options, a = d.reduce((h, c) => (h[c.id] = null, h), {}), u = [{ ...a, [d[0].id]: s[0].value }, d.reduce((h, c) => (h[c.id] = s[0].value, h), {})]; return e.props.properties.required || u.push(a), u; } case "likert": { const s = Number((i = (o = e.props) == null ? void 0 : o.properties) == null ? void 0 : i.range) || 5; return [...Array.from(Array(s).keys()).map((a) => a + 1), ...e.props.properties.required ? [] : [null]]; } case "nps": return [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...e.props.properties.required ? [] : [null]]; case "videovoice": case "open": return ["1", ...e.props.properties.required ? [] : [""]]; case "recordedtask": { const s = [{ taskStatus: "completed" }, { taskStatus: "given.up" }]; return e.props.properties.required || s.push({ taskStatus: "abandoned" }), s; } case "texturlprompt": return [void 0, ...e.props.properties.required ? [] : [{ skipped: !0 }]]; case "consentlegal": return [1, ...e.props.properties.required ? [] : [null]]; default: return [1]; } var t, n; }, Ro = (e) => e in Tt, No = (e) => typeof e == "object" && e !== null && "taskStatus" in e, Lo = (e, t = []) => t.reduce((n, r) => { const { group: o, target: i } = r; if (!(o != null && o.length)) return [...n]; const s = o.filter((d) => !!Number(d) || typeof d == "object" && d.questionIndex === e).map((d) => { const { comparator: a, value: u } = d; return { comparator: a, target: i, value: u }; }); return [...n, ...s]; }, []), tt = /* @__PURE__ */ new Set(["thanks", "uploading"]), U = yr()((e, t) => ({ allResponses: [], answers: void 0, apiURL: "", border: "#000000", cards: [], close: async (n = ke) => { const r = t(), { fadeout: o, remove: i, trackHistory: s, studyType: d } = r; await o(n), nt(r) || s({ event: "closed" }), Qr.info("SurveyClosing", { surveyId: r.surveyId }), Mt.enable(), i({ initiator: Ut.Closed, studyType: d }); }, configureExitOnOverlayClick: () => { }, customMetadata: {}, destroy: async (n) => { const { eventEmitFn: r, fadeout: o, remove: i, studyType: s, surveyId: d } = t(); r("survey.complete", d), await o(n), Mt.enable(), i({ initiator: Ut.Complete, studyType: s }); }, endCard: { headline: "" }, envId: "", eventEmitFn: je.emit.bind(je), fadeout: async (n) => { const { eventEmitFn: r, headers: o, viewDocument: i } = t(); return qe(o) ? Promise.resolve() : (r(J.SurveyFadingOut), new Promise((s) => { const d = i.getElementById(n); d ? (d.addEventListener("transitionend", () => { s(); }), d.classList.remove("ul-app--visible")) : s(); })); }, forceBrandedLogo: !1, frame: document.createElement("iframe"), handleClickEmbedButton: (n) => { const { cards: r, eventEmitFn: o, index: i } = t(); o(n, { qid: r[i].name, props: r[i].props }), e(() => ({ hasViewedEmbed: !0 })); }, handleUploadUpdate: ({ mediaRecordingUid: n, isComplete: r, progressPct: o, isSubmitted: i }) => { var m, g, b; const { cards: s, destroy: d, index: a, uploadProgress: u } = t(), h = r || ((m = u[n]) == null ? void 0 : m.isComplete), c = { ...u, [n]: { progressPct: h ? 100 : o || ((g = u[n]) == null ? void 0 : g.progressPct), isComplete: h, isSubmitted: i || ((b = u[n]) == null ? void 0 : b.isSubmitted) } }; if (e({ uploadProgress: c }), s[a].type !== "uploading") return; const p = Object.entries(u).every(([v, _]) => !_.isSubmitted || _.isComplete || n == v && r); if (p && a >= s.length - 1) return d(ke); e({ index: p ? a + 1 : a, uploadingCardViewed: !0 }); }, hasViewedEmbed: !1, headers: { Authorization: "", "Content-Type": "", "userleap-platform": "web", "x-ul-environment-id": "", "x-ul-installation-method": "web-snippet", "x-ul-sdk-version": "", "x-ul-visitor-id": "" }, index: 0, isPreview: !1, marketingUrl: "https://sprig.com", meta: { ch: 0, cw: 0, l: "", mode: null, p: "", sh: 0, sw: 0 }, mode: void 0, next: (n) => { const { allResponses: r, cards: o, eventEmitFn: i, index: s, responseGroupUid: d, submit: a, trackHistory: u, uploadProgress: h, viewedCardCount: c } = t(); e({ minScrollableHeight: void 0 }); const p = Date.now(), m = [...o], g = m[s], { type: b } = n.data, v = { ...n.data }, _ = v.value; ((D) => !tt.has(D.type))(g) && (g.value = _), v.answeredAt = p, delete v.type; const f = { response: v, responseGroupUid: d, questionIndex: s }; let T = b === "multiplechoice" ? Object.values(_).find((D) => D !== !1) : _; b === "multipleselect" && (T = m[s].props.options.reduce((D, y) => (_[y.id] && D.push(y.value), D), [])); const S = r.slice(0); S[s] = T, e({ allResponses: S }); const w = kr({ cards: m, index: s, hasEndCard: !!n.endCard, uploadProgress: h, allResponses: S }); if (w === null) return f.completedAt = p, a(f), void n.completeSurvey(); tt.has(m[w].type) && (f.completedAt = p); const x = a(f); tt.has(m[w].type) || x.finally(() => { u({ event: "seen", index: w }); }); const j = m[w]; m[w] && i && i("survey.question", { qid: j.name, props: j.props }), e({ cards: m, hasViewedEmbed: !1, index: w, viewedCardCount: c + 1 }); }, pendingRemoveIframeReason: null, previewKey: null, previewMode: void 0, recorder: () => { }, recorderEventEmitter: je, resolveTrackedPromise: () => { const { removeIframeIfReady: n } = t(); e((r) => ({ unresolvedRequestCount: r.unresolvedRequestCount - 1 })), n(); }, responseGroupUid: "", remove: ({ initiator: n, studyType: r }) => { const { eventEmitFn: o, removeIframeIfReady: i, surveyId: s } = t(); e({ pendingRemoveIframeReason: n, studyType: r }), o(J.SurveyCloseRequested, { name: J.SurveyCloseRequested, initiator: n, studyType: r, "survey.id": s }), i(); }, removeIframeIfReady: () => { const { eventEmitFn: n, pendingRemoveIframeReason: r, unresolvedRequestCount: o, studyType: i, surveyId: s } = t(); r && o === 0 && (n(J.SurveyWillClose, { name: J.SurveyWillClose, initiator: r, studyType: i, "survey.id": s }), e({ pendingRemoveIframeReason: null, studyType: i })); }, seen: async () => { const { trackHistory: n } = t(); return n({ event: "seen", isNew: !0 }); }, slugName: null, showStripes: !1, showSurveyBrand: !1, styleNonce: "", submit: async ({ completedAt: n, questionIndex: r, response: o, responseGroupUid: i }) => { const s = t(); if (!i || nt(s)) return; const d = { responseGroupUid: i, meta: s.meta, customMetadata: s.customMetadata, responses: [o], completedAt: n, previewKey: s.previewKey }, a = await s.trackPromise(lt(`${s.apiURL}/sdk/1/environments/${s.envId}/visitors/${s.userId}/responses/submit`, { body: JSON.stringify(d), headers: s.headers, method: "POST" })); a.ok ? s.eventEmitFn(J.QuestionAnswered, { ...o, questionIndex: r, "survey.id": s.surveyId }) : a.reportError && (console.warn("[Sprig] (ERR-427) Failed to submit response", a.error), await s.trackPromise(hn(s, "submitResponse", a.error))); }, surveyId: 0, tabTitle: "", trackHistory: async ({ event: n, index: r, isNew: o = !1 }) => { const i = t(); if (nt(i)) return; const { cards: s, index: d } = i, a = r !== void 0 ? s[r] : s[d], u = { sid: i.surveyId, qid: a.name, action: n, vid: i.userId, eid: i.envId, isNew: o, responseGroupUid: i.responseGroupUid, previewKey: i.previewKey }, h = await i.trackPromise(lt(`${i.apiURL}/sdk/1/visitors/${i.userId}/surveys/${i.surveyId}/history`, { body: JSON.stringify(u), headers: i.headers, method: "POST" })); !h.ok && h.reportError && (console.warn("[Sprig] (ERR-428) Failed to track survey event", h.error), await i.trackPromise(hn(i, "trackHistory", h.error))); }, trackPromise: async (n) => { const { resolveTrackedPromise: r } = t(); return e((o) => ({ unresolvedRequestCount: o.unresolvedRequestCount + 1 })), n.then((o) => (r(), o)).catch((o) => { throw r(), o; }); }, unresolvedRequestCount: 0, update: () => { const { cards: n, index: r, headers: o, eventEmitFn: i, frame: s, useMobileStyling: d, surveyId: a, viewDocument: u } = t(), h = o["userleap-platform"] === "web", c = qe(o), p = n[r], m = p.type === "matrix" && !(p.props.properties.displayMatrixAsAccordion || d); e({ minScrollableHeight: void 0 }), setTimeout(() => { var _, f, T; !c && !d && ((_ = s == null ? void 0 : s.setWidth) == null || _.call(s, Wr)); const [g, b, v] = Zr(u, h && !d, c); c ? (i(J.SurveyHeight, { name: J.SurveyHeight, contentFrameHeight: g, "survey.id": a }), i(J.SurveyWidth, { name: J.SurveyWidth, contentFrameWidth: b, "survey.id": a })) : ((f = s.setHeight) == null || f.call(s, g), e({ minScrollableHeight: v }), !d && m && ((T = s.setWidth) == null || T.call(s, b))); }, 100); }, uploadingCardViewed: !1, uploadProgress: {}, useDesktopPrototype: void 0, useMobileStyling: !1, userId: "", viewDocument: window.document, viewedCardCount: 0 })), nt = (e) => !e.userId || e.meta && e.meta.mode === "test" || e.isPreview || e.previewMode, hn = async (e, t, n) => { const { mode: r, userId: o, envId: i, apiURL: s, headers: d, viewDocument: a } = e, u = a.documentElement, h = { mode: r, screenWidth: window.screen.width, screenHeight: window.screen.height, clientWidth: u.clientWidth, clientHeight: u.clientHeight, location: window.location.href, language: window.navigator.language }, c = { action: t, err: { message: `${n == null ?