@sprig-technologies/sprig-browser
Version:
npm package for the sprig web sdk
1,142 lines • 188 kB
JavaScript
import { C as Ht, A as Se, D as Gr, a as Kr, i as Yr, E as Qr, b as De, d as Ct, r as Jr, e as At } from "./core-BPGg40bv.js";
import { b as Xr, D as Bt, e as Be, h as We, S as ne, s as ht, v as mt } from "./metricsReporter-Dsn4xUH7.js";
var Me, P, Rn, xe, qt, Nn, gt, Ln, Le = {}, Mn = [], eo = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, Ze = Array.isArray;
function pe(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 F(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 ? Me.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 Re(e, s, r, o, null);
}
function Re(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 Y(e) {
return e.children;
}
function se(e, t) {
this.props = e, this.context = t;
}
function je(e, t) {
if (t == null)
return e.__ ? je(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" ? je(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 vt(e) {
(!e.__d && (e.__d = !0) && xe.push(e) && !Ge.__r++ || qt !== P.debounceRendering) && ((qt = P.debounceRendering) || Nn)(Ge);
}
function Ge() {
var e, t, n, r, o, i, s, d, l;
for (xe.sort(gt); e = xe.shift(); )
e.__d && (t = xe.length, r = void 0, i = (o = (n = e).__v).__e, d = [], l = [], (s = n.__P) && ((r = pe({}, o)).__v = o.__v + 1, P.vnode && P.vnode(r), Et(s, r, o, n.__n, s.ownerSVGElement !== void 0, 32 & o.__u ? [i] : null, d, i ?? je(o), !!(32 & o.__u), l), r.__.__k[r.__i] = r, Bn(d, r, l), r.__e != i && Hn(r)), xe.length > t && xe.sort(gt));
Ge.__r = 0;
}
function Vt(e, t, n, r, o, i, s, d, l, p, h) {
var c, u, m, g, f, v = r && r.__k || Mn, k = t.length;
for (n.__d = l, function(_, T, j) {
var E, w, I, D, x, b = T.length, y = j.length, S = y, L = 0;
for (_.__k = [], E = 0; E < b; E++)
(w = _.__k[E] = (w = T[E]) == null || typeof w == "boolean" || typeof w == "function" ? null : typeof w == "string" || typeof w == "number" || typeof w == "bigint" || w.constructor == String ? Re(null, w, null, null, w) : Ze(w) ? Re(Y, { children: w }, null, null, null) : w.constructor === void 0 && w.__b > 0 ? Re(w.type, w.props, w.key, w.ref ? w.ref : null, w.__v) : w) != null ? (w.__ = _, w.__b = _.__b + 1, x = to(w, j, D = E + L, S), w.__i = x, I = null, x !== -1 && (S--, (I = j[x]) && (I.__u |= 131072)), I == null || I.__v === null ? (x == -1 && L--, typeof w.type != "function" && (w.__u |= 65536)) : x !== D && (x === D + 1 ? L++ : x > D ? S > b - D ? L += x - D : L-- : L = x < D && x == D - 1 ? x - D : 0, x !== E + L && (w.__u |= 65536))) : (I = j[E]) && I.key == null && I.__e && (I.__e == _.__d && (_.__d = je(I)), ft(I, I, !1), j[E] = null, S--);
if (S)
for (E = 0; E < y; E++)
(I = j[E]) != null && !(131072 & I.__u) && (I.__e == _.__d && (_.__d = je(I)), ft(I, I));
}(n, t, v), l = n.__d, c = 0; c < k; c++)
(m = n.__k[c]) != null && typeof m != "boolean" && typeof m != "function" && (u = m.__i === -1 ? Le : v[m.__i] || Le, m.__i = c, Et(e, m, u, o, i, s, d, l, p, h), g = m.__e, m.ref && u.ref != m.ref && (u.ref && St(u.ref, null, m), h.push(m.ref, m.__c || g, m)), f == null && g != null && (f = g), 65536 & m.__u || u.__k === m.__k ? l = An(m, l, e) : typeof m.type == "function" && m.__d !== void 0 ? l = m.__d : g && (l = g.nextSibling), m.__d = void 0, m.__u &= -196609);
n.__d = l, n.__e = f;
}
function An(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 = An(r[o], t, n));
return t;
}
return e.__e != t && (n.insertBefore(e.__e, t || null), t = e.__e), t && t.nextSibling;
}
function he(e, t) {
return t = t || [], e == null || typeof e == "boolean" || (Ze(e) ? e.some(function(n) {
he(n, t);
}) : t.push(e)), t;
}
function to(e, t, n, r) {
var o = e.key, i = e.type, s = n - 1, d = n + 1, l = t[n];
if (l === null || l && o == l.key && i === l.type)
return n;
if (r > (l == null || 131072 & l.__u ? 0 : 1))
for (; s >= 0 || d < t.length; ) {
if (s >= 0) {
if ((l = t[s]) && !(131072 & l.__u) && o == l.key && i === l.type)
return s;
s--;
}
if (d < t.length) {
if ((l = t[d]) && !(131072 & l.__u) && o == l.key && i === l.type)
return d;
d++;
}
}
return -1;
}
function zt(e, t, n) {
t[0] === "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || eo.test(t) ? n : n + "px";
}
function Ae(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 || zt(e.style, t, "");
if (n)
for (t in n)
r && n[t] === r[t] || zt(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 ? Ft : $t, i)) : e.removeEventListener(t, i ? Ft : $t, 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 $t(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 Ft(e) {
return this.l[e.type + !0](P.event ? P.event(e) : e);
}
function Et(e, t, n, r, o, i, s, d, l, p) {
var h, c, u, m, g, f, v, k, _, T, j, E, w, I, D, x = t.type;
if (t.constructor !== void 0)
return null;
128 & n.__u && (l = !!(32 & n.__u), i = [d = t.__e = n.__e]), (h = P.__b) && h(t);
e:
if (typeof x == "function")
try {
if (k = t.props, _ = (h = x.contextType) && r[h.__c], T = h ? _ ? _.props.value : h.__ : r, n.__c ? v = (c = t.__c = n.__c).__ = c.__E : ("prototype" in x && x.prototype.render ? t.__c = c = new x(k, T) : (t.__c = c = new se(k, T), c.constructor = x, c.render = no), _ && _.sub(c), c.props = k, c.state || (c.state = {}), c.context = T, c.__n = r, u = c.__d = !0, c.__h = [], c._sb = []), c.__s == null && (c.__s = c.state), x.getDerivedStateFromProps != null && (c.__s == c.state && (c.__s = pe({}, c.__s)), pe(c.__s, x.getDerivedStateFromProps(k, c.__s))), m = c.props, g = c.state, c.__v = t, u)
x.getDerivedStateFromProps == null && c.componentWillMount != null && c.componentWillMount(), c.componentDidMount != null && c.__h.push(c.componentDidMount);
else {
if (x.getDerivedStateFromProps == null && k !== m && c.componentWillReceiveProps != null && c.componentWillReceiveProps(k, T), !c.__e && (c.shouldComponentUpdate != null && c.shouldComponentUpdate(k, c.__s, T) === !1 || t.__v === n.__v)) {
for (t.__v !== n.__v && (c.props = k, c.state = c.__s, c.__d = !1), t.__e = n.__e, t.__k = n.__k, t.__k.forEach(function(b) {
b && (b.__ = t);
}), j = 0; j < c._sb.length; j++)
c.__h.push(c._sb[j]);
c._sb = [], c.__h.length && s.push(c);
break e;
}
c.componentWillUpdate != null && c.componentWillUpdate(k, c.__s, T), c.componentDidUpdate != null && c.__h.push(function() {
c.componentDidUpdate(m, g, f);
});
}
if (c.context = T, c.props = k, c.__P = e, c.__e = !1, E = P.__r, w = 0, "prototype" in x && x.prototype.render) {
for (c.state = c.__s, c.__d = !1, E && E(t), h = c.render(c.props, c.state, c.context), I = 0; I < c._sb.length; I++)
c.__h.push(c._sb[I]);
c._sb = [];
} else
do
c.__d = !1, E && E(t), h = c.render(c.props, c.state, c.context), c.state = c.__s;
while (c.__d && ++w < 25);
c.state = c.__s, c.getChildContext != null && (r = pe(pe({}, r), c.getChildContext())), u || c.getSnapshotBeforeUpdate == null || (f = c.getSnapshotBeforeUpdate(m, g)), Vt(e, Ze(D = h != null && h.type === Y && h.key == null ? h.props.children : h) ? D : [D], t, n, r, o, i, s, d, l, p), c.base = t.__e, t.__u &= -161, c.__h.length && s.push(c), v && (c.__E = c.__ = null);
} catch (b) {
t.__v = null, l || i != null ? (t.__e = d, t.__u |= l ? 160 : 32, i[i.indexOf(d)] = null) : (t.__e = n.__e, t.__k = n.__k), P.__e(b, t, n);
}
else
i == null && t.__v === n.__v ? (t.__k = n.__k, t.__e = n.__e) : t.__e = function(b, y, S, L, C, M, A, H, B) {
var R, $, Z, ee, V, Q, be, re = S.props, ce = y.props, oe = y.type;
if (oe === "svg" && (C = !0), M != null) {
for (R = 0; R < M.length; R++)
if ((V = M[R]) && "setAttribute" in V == !!oe && (oe ? V.localName === oe : V.nodeType === 3)) {
b = V, M[R] = null;
break;
}
}
if (b == null) {
if (oe === null)
return document.createTextNode(ce);
b = C ? document.createElementNS("http://www.w3.org/2000/svg", oe) : document.createElement(oe, ce.is && ce), M = null, H = !1;
}
if (oe === null)
re === ce || H && b.data === ce || (b.data = ce);
else {
if (M = M && Me.call(b.childNodes), re = S.props || Le, !H && M != null)
for (re = {}, R = 0; R < b.attributes.length; R++)
re[(V = b.attributes[R]).name] = V.value;
for (R in re)
V = re[R], R == "children" || (R == "dangerouslySetInnerHTML" ? Z = V : R === "key" || R in ce || Ae(b, R, null, V, C));
for (R in ce)
V = ce[R], R == "children" ? ee = V : R == "dangerouslySetInnerHTML" ? $ = V : R == "value" ? Q = V : R == "checked" ? be = V : R === "key" || H && typeof V != "function" || re[R] === V || Ae(b, R, V, re[R], C);
if ($)
H || Z && ($.__html === Z.__html || $.__html === b.innerHTML) || (b.innerHTML = $.__html), y.__k = [];
else if (Z && (b.innerHTML = ""), Vt(b, Ze(ee) ? ee : [ee], y, S, L, C && oe !== "foreignObject", M, A, M ? M[0] : S.__k && je(S, 0), H, B), M != null)
for (R = M.length; R--; )
M[R] != null && On(M[R]);
H || (R = "value", Q !== void 0 && (Q !== b[R] || oe === "progress" && !Q || oe === "option" && Q !== re[R]) && Ae(b, R, Q, re[R], !1), R = "checked", be !== void 0 && be !== b[R] && Ae(b, R, be, re[R], !1));
}
return b;
}(n.__e, t, n, r, o, i, s, l, p);
(h = P.diffed) && h(t);
}
function Bn(e, t, n) {
t.__d = void 0;
for (var r = 0; r < n.length; r++)
St(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 St(e, t, n) {
try {
typeof e == "function" ? e(t) : e.current = t;
} catch (r) {
P.__e(r, n);
}
}
function ft(e, t, n) {
var r, o;
if (P.unmount && P.unmount(e), (r = e.ref) && (r.current && r.current !== e.__e || St(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] && ft(r[o], t, n || typeof e.type != "function");
n || e.__e == null || On(e.__e), e.__ = e.__e = e.__d = void 0;
}
function no(e, t, n) {
return this.constructor(e, n);
}
function Ie(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 = [], Et(t, e = (!r && n || t).__k = F(Y, null, [e]), o || Le, Le, t.ownerSVGElement !== void 0, !r && n ? [n] : o ? null : t.firstChild ? Me.call(t.childNodes) : null, i, !r && n ? n : o ? o.__e : t.firstChild, r, s), Bn(i, e, s);
}
function qn(e, t) {
Ie(e, t, qn);
}
function ro(e, t, n) {
var r, o, i, s, d = pe({}, 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 ? Me.call(arguments, 2) : n), Re(e.type, d, r || e.key, o || e.ref, null);
}
function Vn(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, vt(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;
}
Me = 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, se.prototype.setState = function(e, t) {
var n;
n = this.__s != null && this.__s !== this.state ? this.__s : this.__s = pe({}, this.state), typeof e == "function" && (e = e(pe({}, n), this.props)), e && pe(n, e), e != null && this.__v && (t && this._sb.push(t), vt(this));
}, se.prototype.forceUpdate = function(e) {
this.__v && (this.__e = !0, e && this.__h.push(e), vt(this));
}, se.prototype.render = Y, xe = [], Nn = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, gt = function(e, t) {
return e.__v.__b - t.__v.__b;
}, Ge.__r = 0, Ln = 0;
var me, z, rt, Wt, Te = 0, zn = [], qe = [], Zt = P.__b, Gt = P.__r, Kt = P.diffed, Yt = P.__c, Qt = P.unmount;
function we(e, t) {
P.__h && P.__h(z, e, Te || t), Te = 0;
var n = z.__H || (z.__H = { __: [], __h: [] });
return e >= n.__.length && n.__.push({ __V: qe }), n.__[e];
}
function W(e) {
return Te = 1, jt(Zn, e);
}
function jt(e, t, n) {
var r = we(me++, 2);
if (r.t = e, !r.__c && (r.__ = [n ? n(t) : Zn(void 0, t), function(d) {
var l = r.__N ? r.__N[0] : r.__[0], p = r.t(l, d);
l !== p && (r.__N = [p, r.__[1]], r.__c.setState({}));
}], r.__c = z, !z.u)) {
var o = function(d, l, p) {
if (!r.__c.__H)
return !0;
var h = r.__c.__H.__.filter(function(u) {
return u.__c;
});
if (h.every(function(u) {
return !u.__N;
}))
return !i || i.call(this, d, l, p);
var c = !1;
return h.forEach(function(u) {
if (u.__N) {
var m = u.__[0];
u.__ = u.__N, u.__N = void 0, m !== u.__[0] && (c = !0);
}
}), !(!c && r.__c.props === d) && (!i || i.call(this, d, l, p));
};
z.u = !0;
var i = z.shouldComponentUpdate, s = z.componentWillUpdate;
z.componentWillUpdate = function(d, l, p) {
if (this.__e) {
var h = i;
i = void 0, o(d, l, p), i = h;
}
s && s.call(this, d, l, p);
}, z.shouldComponentUpdate = o;
}
return r.__N || r.__;
}
function K(e, t) {
var n = we(me++, 3);
!P.__s && Tt(n.__H, t) && (n.__ = e, n.i = t, z.__H.__h.push(n));
}
function Oe(e, t) {
var n = we(me++, 4);
!P.__s && Tt(n.__H, t) && (n.__ = e, n.i = t, z.__h.push(n));
}
function te(e) {
return Te = 5, Ue(function() {
return { current: e };
}, []);
}
function $n(e, t, n) {
Te = 6, Oe(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 Ue(e, t) {
var n = we(me++, 7);
return Tt(n.__H, t) ? (n.__V = e(), n.i = t, n.__h = e, n.__V) : n.__;
}
function Ke(e, t) {
return Te = 8, Ue(function() {
return e;
}, t);
}
function Fn(e) {
var t = z.context[e.__c], n = we(me++, 9);
return n.c = e, t ? (n.__ == null && (n.__ = !0, t.sub(z)), t.props.value) : e.__;
}
function It(e, t) {
P.useDebugValue && P.useDebugValue(t ? t(e) : e);
}
function Wn() {
var e = we(me++, 11);
if (!e.__) {
for (var t = z.__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 = zn.shift(); )
if (e.__P && e.__H)
try {
e.__H.__h.forEach(Ve), e.__H.__h.forEach(_t), e.__H.__h = [];
} catch (t) {
e.__H.__h = [], P.__e(t, e.__v);
}
}
P.__b = function(e) {
z = null, Zt && Zt(e);
}, P.__r = function(e) {
Gt && Gt(e), me = 0;
var t = (z = e.__c).__H;
t && (rt === z ? (t.__h = [], z.__h = [], t.__.forEach(function(n) {
n.__N && (n.__ = n.__N), n.__V = qe, n.__N = n.i = void 0;
})) : (t.__h.forEach(Ve), t.__h.forEach(_t), t.__h = [], me = 0)), rt = z;
}, P.diffed = function(e) {
Kt && Kt(e);
var t = e.__c;
t && t.__H && (t.__H.__h.length && (zn.push(t) !== 1 && Wt === P.requestAnimationFrame || ((Wt = P.requestAnimationFrame) || io)(oo)), t.__H.__.forEach(function(n) {
n.i && (n.__H = n.i), n.__V !== qe && (n.__ = n.__V), n.i = void 0, n.__V = qe;
})), rt = z = null;
}, P.__c = function(e, t) {
t.some(function(n) {
try {
n.__h.forEach(Ve), n.__h = n.__h.filter(function(r) {
return !r.__ || _t(r);
});
} catch (r) {
t.some(function(o) {
o.__h && (o.__h = []);
}), t = [], P.__e(r, n.__v);
}
}), Yt && Yt(e, t);
}, P.unmount = function(e) {
Qt && Qt(e);
var t, n = e.__c;
n && n.__H && (n.__H.__.forEach(function(r) {
try {
Ve(r);
} catch (o) {
t = o;
}
}), n.__H = void 0, t && P.__e(t, n.__v));
};
var Jt = typeof requestAnimationFrame == "function";
function io(e) {
var t, n = function() {
clearTimeout(r), Jt && cancelAnimationFrame(t), setTimeout(e);
}, r = setTimeout(n, 100);
Jt && (t = requestAnimationFrame(n));
}
function Ve(e) {
var t = z, n = e.__c;
typeof n == "function" && (e.__c = void 0, n()), z = t;
}
function _t(e) {
var t = z;
e.__c = e.__(), z = t;
}
function Tt(e, t) {
return !e || e.length !== t.length || t.some(function(n, r) {
return n !== e[r];
});
}
function Zn(e, t) {
return typeof t == "function" ? t(e) : t;
}
function Gn(e, t) {
for (var n in t)
e[n] = t[n];
return e;
}
function bt(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 Ye(e) {
this.props = e;
}
function Kn(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 : bt(this.props, o);
}
function r(o) {
return this.shouldComponentUpdate = n, F(e, o);
}
return r.displayName = "Memo(" + (e.displayName || e.name) + ")", r.prototype.isReactComponent = !0, r.__f = !0, r;
}
(Ye.prototype = new se()).isPureReactComponent = !0, Ye.prototype.shouldComponentUpdate = function(e, t) {
return bt(this.props, e) || bt(this.state, t);
};
var Xt = P.__b;
P.__b = function(e) {
e.type && e.type.__f && e.ref && (e.props.ref = e.ref, e.ref = null), Xt && Xt(e);
};
var so = typeof Symbol < "u" && Symbol.for && Symbol.for("react.forward_ref") || 3911;
function Pt(e) {
function t(n) {
var r = Gn({}, 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 en = function(e, t) {
return e == null ? null : he(he(e).map(t));
}, Yn = { map: en, forEach: en, count: function(e) {
return e ? he(e).length : 0;
}, only: function(e) {
var t = he(e);
if (t.length !== 1)
throw "Children.only";
return t[0];
}, toArray: he }, 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 tn = P.unmount;
function Qn(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 = Gn({}, e)).__c != null && (e.__c.__P === n && (e.__c.__P = t), e.__c = null), e.__k = e.__k && e.__k.map(function(r) {
return Qn(r, t, n);
})), e;
}
function Jn(e, t, n) {
return e && n && (e.__v = null, e.__k = e.__k && e.__k.map(function(r) {
return Jn(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 Ne() {
this.__u = 0, this.t = null, this.__b = null;
}
function Xn(e) {
var t = e.__.__c;
return t && t.__a && t.__a(e);
}
function er(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 F(n, i);
}
return o.displayName = "Lazy", o.__f = !0, o;
}
function Ee() {
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), tn && tn(e);
}, (Ne.prototype = new se()).__c = function(e, t) {
var n = t.__c, r = this;
r.t == null && (r.t = []), r.t.push(n);
var o = Xn(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 l = r.state.__a;
r.__v.__k[0] = Jn(l, l.__c.__P, l.__c.__O);
}
var p;
for (r.setState({ __a: r.__b = null }); p = r.t.pop(); )
p.forceUpdate();
}
};
r.__u++ || 32 & t.__u || r.setState({ __a: r.__b = r.__v.__k[0] }), e.then(s, s);
}, Ne.prototype.componentWillUnmount = function() {
this.t = [];
}, Ne.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] = Qn(this.__b, n, r.__O = r.__P);
}
this.__b = null;
}
var o = t.__a && F(Y, null, e.fallback);
return o && (o.__u &= -33), [F(Y, null, t.__a ? null : e.children), o];
};
var nn = 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() {
Ie(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);
} }), Ie(F(lo, { context: t.context }, e.__v), t.l);
}
function tr(e, t) {
var n = F(co, { __v: e, i: t });
return n.containerInfo = t, n;
}
(Ee.prototype = new se()).__a = function(e) {
var t = this, n = Xn(t.__v), r = t.o.get(e);
return r[0]++, function(o) {
var i = function() {
t.props.revealOrder ? (r.push(o), nn(t, e, r)) : o();
};
n ? n(i) : i();
};
}, Ee.prototype.render = function(e) {
this.u = null, this.o = /* @__PURE__ */ new Map();
var t = he(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;
}, Ee.prototype.componentDidUpdate = Ee.prototype.componentDidMount = function() {
var e = this;
this.o.forEach(function(t, n) {
nn(e, n, t);
});
};
var nr = 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 rr(e, t, n) {
return t.__k == null && (t.textContent = ""), Ie(e, t), typeof n == "function" && n(), e ? e.__c : null;
}
function or(e, t, n) {
return qn(e, t), typeof n == "function" && n(), e ? e.__c : null;
}
se.prototype.isReactComponent = {}, ["componentWillMount", "componentWillReceiveProps", "componentWillUpdate"].forEach(function(e) {
Object.defineProperty(se.prototype, e, { configurable: !0, get: function() {
return this["UNSAFE_" + e];
}, set: function(t) {
Object.defineProperty(this, e, { configurable: !0, writable: !0, value: t });
} });
});
var rn = P.event;
function vo() {
}
function fo() {
return this.cancelBubble;
}
function _o() {
return this.defaultPrevented;
}
P.event = function(e) {
return rn && (e = rn(e)), e.persist = vo, e.isPropagationStopped = fo, e.isDefaultPrevented = _o, e.nativeEvent = e;
};
var Dt, bo = { enumerable: !1, configurable: !0, get: function() {
return this.class;
} }, on = 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 = he(n.children).forEach(function(l) {
l.props.selected = o.value.indexOf(l.props.value) != -1;
})), r == "select" && o.defaultValue != null && (o.value = he(n.children).forEach(function(l) {
l.props.selected = o.multiple ? o.defaultValue.indexOf(l.props.value) != -1 : o.defaultValue == l.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 = nr, on && on(e);
};
var sn = P.__r;
P.__r = function(e) {
sn && sn(e), Dt = e.__c;
};
var an = P.diffed;
P.diffed = function(e) {
an && an(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), Dt = null;
};
var ir = { ReactCurrentDispatcher: { current: { readContext: function(e) {
return Dt.__n[e.__c].props.value;
} } } };
function sr(e) {
return F.bind(null, e);
}
function He(e) {
return !!e && e.$$typeof === nr;
}
function ar(e) {
return He(e) && e.type === Y;
}
function lr(e) {
return He(e) ? ro.apply(null, arguments) : e;
}
function dr(e) {
return !!e.__k && (Ie(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 = Y;
function Rt(e) {
e();
}
function mr(e) {
return e;
}
function gr() {
return [!1, Rt];
}
var vr = Oe, fr = He;
function _r(e, t) {
var n = t(), r = W({ h: { __: n, v: t } }), o = r[0].h, i = r[1];
return Oe(function() {
o.__ = n, o.v = t, ot(o) && i({ h: o });
}, [e, n, t]), K(function() {
return ot(o) && i({ h: o }), e(function() {
ot(o) && i({ h: o });
});
}, [e]), n;
}
function ot(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: W, useId: Wn, useReducer: jt, useEffect: K, useLayoutEffect: Oe, useInsertionEffect: vr, useTransition: gr, useDeferredValue: mr, useSyncExternalStore: _r, startTransition: Rt, useRef: te, useImperativeHandle: $n, useMemo: Ue, useCallback: Ke, useContext: Fn, useDebugValue: It, version: "17.0.2", Children: Yn, render: rr, hydrate: or, unmountComponentAtNode: dr, createPortal: tr, createElement: F, createContext: Vn, createFactory: sr, cloneElement: lr, createRef: Un, Fragment: Y, isValidElement: He, isElement: fr, isFragment: ar, findDOMNode: cr, Component: se, PureComponent: Ye, memo: Kn, forwardRef: Pt, flushSync: pr, unstable_batchedUpdates: ur, StrictMode: hr, Suspense: Ne, SuspenseList: Ee, lazy: er, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ir };
const xo = Object.freeze(Object.defineProperty({ __proto__: null, Children: Yn, Component: se, Fragment: Y, PureComponent: Ye, StrictMode: hr, Suspense: Ne, SuspenseList: Ee, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ir, cloneElement: lr, createContext: Vn, createElement: F, createFactory: sr, createPortal: tr, createRef: Un, default: yo, findDOMNode: cr, flushSync: pr, forwardRef: Pt, hydrate: or, isElement: fr, isFragment: ar, isValidElement: He, lazy: er, memo: Kn, render: rr, startTransition: Rt, unmountComponentAtNode: dr, unstable_batchedUpdates: ur, useCallback: Ke, useContext: Fn, useDebugValue: It, useDeferredValue: mr, useEffect: K, useErrorBoundary: function(e) {
var t = we(me++, 10), n = W();
return t.__ = e, z.componentDidCatch || (z.componentDidCatch = function(r, o) {
t.__ && t.__(r, o), n[1](r);
}), [n[0], function() {
n[1](void 0);
}];
}, useId: Wn, useImperativeHandle: $n, useInsertionEffect: vr, useLayoutEffect: Oe, useMemo: Ue, useReducer: jt, useRef: te, useState: W, useSyncExternalStore: _r, useTransition: gr, version: "17.0.2" }, Symbol.toStringTag, { value: "Module" })), ln = (e) => {
let t;
const n = /* @__PURE__ */ new Set(), r = (s, d) => {
const l = typeof s == "function" ? s(t) : s;
if (!Object.is(l, t)) {
const p = t;
t = d ?? typeof l != "object" ? l : Object.assign({}, t, l), n.forEach((h) => h(t, p));
}
}, 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 (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 br = { exports: {} }, dn = {};
const yr = wo(xo);
var xr = { exports: {} }, cn = {}, Pe = yr, Co = typeof Object.is == "function" ? Object.is : function(e, t) {
return e === t && (e !== 0 || 1 / e == 1 / t) || e != e && t != t;
}, Eo = Pe.useState, So = Pe.useEffect, jo = Pe.useLayoutEffect, Io = Pe.useDebugValue;
function it(e) {
var t = e.getSnapshot;
e = e.value;
try {
var n = t();
return !Co(e, n);
} catch {
return !0;
}
}
var To = typeof window > "u" || window.document === void 0 || window.document.createElement === void 0 ? function(e, t) {
return t();
} : function(e, t) {
var n = t(), r = Eo({ inst: { value: n, getSnapshot: t } }), o = r[0].inst, i = r[1];
return jo(function() {
o.value = n, o.getSnapshot = t, it(o) && i({ inst: o });
}, [e, n, t]), So(function() {
return it(o) && i({ inst: o }), e(function() {
it(o) && i({ inst: o });
});
}, [e]), Io(n), n;
};
cn.useSyncExternalStore = Pe.useSyncExternalStore !== void 0 ? Pe.useSyncExternalStore : To, xr.exports = cn;
var Xe = yr, Po = xr.exports, Do = typeof Object.is == "function" ? Object.is : function(e, t) {
return e === t && (e !== 0 || 1 / e == 1 / t) || e != e && t != t;
}, Ro = Po.useSyncExternalStore, No = Xe.useRef, Lo = Xe.useEffect, Mo = Xe.useMemo, Oo = Xe.useDebugValue;
dn.useSyncExternalStoreWithSelector = function(e, t, n, r, o) {
var i = No(null);
if (i.current === null) {
var s = { hasValue: !1, value: null };
i.current = s;
} else
s = i.current;
i = Mo(function() {
function l(m) {
if (!c) {
if (c = !0, p = m, m = r(m), o !== void 0 && s.hasValue) {
var g = s.value;
if (o(g, m))
return h = g;
}
return h = m;
}
if (g = h, Do(p, m))
return g;
var f = r(m);
return o !== void 0 && o(g, f) ? g : (p = m, h = f);
}
var p, h, c = !1, u = n === void 0 ? null : n;
return [function() {
return l(t());
}, u === null ? void 0 : function() {
return l(u());
}];
}, [t, n, r, o]);
var d = Ro(e, i[0], i[1]);
return Lo(function() {
s.hasValue = !0, s.value = d;
}, [d]), Oo(d), d;
}, br.exports = dn;
const Uo = ko(br.exports), { useSyncExternalStoreWithSelector: Ho } = Uo, un = (e) => {
const t = typeof e == "function" ? ((r) => r ? ln(r) : ln)(e) : e, n = (r, o) => function(i, s = i.getState, d) {
const l = Ho(i.subscribe, i.getState, i.getServerState || i.getState, s, d);
return It(l), l;
}(t, r, o);
return Object.assign(n, t), n;
}, kr = (e) => e ? un(e) : un, Ao = 1, Bo = 2, Nt = { 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);
} }, qo = (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;
}
}, wr = (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;
}, Cr = ({ 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: u } = 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 f = 1; f < c.length; f += 2) {
const v = c[f], k = c[f + 1], _ = pn({ comparator: k.comparator, response: r[k.questionIndex], type: e[k.questionIndex].type, value: k.value });
v === Ao ? g && (g = _) : v === Bo && (g || (g = _));
}
if (g) {
s = u === -1 && n ? e.length - 1 : u;
break;
}
}
const l = e.findIndex((h) => h.type === "uploading");
let p;
return p = l > 0 ? n ? e.length - 3 : e.length - 2 : e.length - 1, t >= p || s === -1 || s !== null && s > p ? l > 0 && Object.values(o).some((c) => c.isSubmitted && !c.isComplete) ? l : 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" && wr(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 Nt[e](t, r);
}, Vo = (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((l) => [...l, 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, l = d.reduce((h, c) => (h[c.id] = null, h), {}), p = [{ ...l, [d[0].id]: s[0].value }, d.reduce((h, c) => (h[c.id] = s[0].value, h), {})];
return e.props.properties.required || p.push(l), p;
}
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((l) => l + 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;
}, zo = (e) => e in Nt, $o = (e) => typeof e == "object" && e !== null && "taskStatus" in e, Fo = (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: l, value: p } = d;
return { comparator: l, target: i, value: p };
});
return [...n, ...s];
}, []), st = /* @__PURE__ */ new Set(["thanks", "uploading"]), q = kr()((e, t) => ({ allResponses: [], answers: void 0, apiURL: "", border: "#000000", cards: [], close: async (n = Se) => {
const r = t(), { fadeout: o, remove: i, trackHistory: s, studyType: d } = r;
await o(n), at(r) || s({ event: "closed" }), Xr.info("SurveyClosing", { surveyId: r.surveyId }), Ht.enable(), i({ initiator: Bt.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), Ht.enable(), i({ initiator: Bt.Complete, studyType: s });
}, endCard: { headline: "" }, envId: "", eventEmitFn: Be.emit.bind(Be), fadeout: async (n) => {
const { eventEmitFn: r, headers: o, viewDocument: i } = t();
return We(o) ? Promise.resolve() : (r(ne.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, f;
const { cards: s, destroy: d, index: l, uploadProgress: p } = t(), h = r || ((m = p[n]) == null ? void 0 : m.isComplete), c = { ...p, [n]: { progressPct: h ? 100 : o || ((g = p[n]) == null ? void 0 : g.progressPct), isComplete: h, isSubmitted: i || ((f = p[n]) == null ? void 0 : f.isSubmitted) } };
if (e({ uploadProgress: c }), s[l].type !== "uploading")
return;
const u = Object.entries(p).every(([v, k]) => !k.isSubmitted || k.isComplete || n == v && r);
if (u && l >= s.length - 1)
return d(Se);
e({ index: u ? l + 1 : l, 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: l, trackHistory: p, uploadProgress: h, viewedCardCount: c } = t();
e({ minScrollableHeight: void 0 });
const u = Date.now(), m = [...o], g = m[s], { type: f } = n.data, v = { ...n.data }, k = v.value;
((D) => !st.has(D.type))(g) && (g.value = k), v.answeredAt = u, delete v.type;
const _ = { response: v, responseGroupUid: d, questionIndex: s };
let T = f === "multiplechoice" ? Object.values(k).find((D) => D !== !1) : k;
f === "multipleselect" && (T = m[s].props.options.reduce((D, x) => (k[x.id] && D.push(x.value), D), []));
const j = r.slice(0);
j[s] = T, e({ allResponses: j });
const E = Cr({ cards: m, index: s, hasEndCard: !!n.endCard, uploadProgress: h, allResponses: j });
if (E === null)
return _.completedAt = u, l(_), void n.completeSurvey();
st.has(m[E].type) && (_.completedAt = u);
const w = l(_);
st.has(m[E].type) || w.finally(() => {
p({ event: "seen", index: E });
});
const I = m[E];
m[E] && i && i("survey.question", { qid: I.name, props: I.props }), e({ cards: m, hasViewedEmbed: !1, index: E, viewedCardCount: c + 1 });
}, pendingRemoveIframeReason: null, previewKey: null, previewMode: void 0, recorder: () => {
}, recorderEventEmitter: Be, 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(ne.SurveyCloseRequested, { name: ne.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(ne.SurveyWillClose, { name: ne.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 || at(s))
return;
const d = { responseGroupUid: i, meta: s.meta, customMetadata: s.customMetadata, responses: [o], completedAt: n, previewKey: s.previewKey }, l = await s.trackPromise(ht(`${s.apiURL}/sdk/1/environments/${s.envId}/visitors/${s.userId}/responses/submit`, { body: JSON.stringify(d), headers: s.headers, method: "POST" }));
l.ok ? s.eventEmitFn(ne.QuestionAnswered, { ...o, questionIndex: r, "survey.id": s.surveyId }) : l.reportError && (console.warn("[Sprig] (ERR-427) Failed to submit response", l.error), await s.trackPromise(hn(s, "submitResponse", l.error)));
}, surveyId: 0, tabTitle: "", trackHistory: async ({ event: n, index: r, isNew: o = !1 }) => {
const i = t();
if (at(i))
return;
const { cards: s, index: d } = i, l = r !== void 0 ? s[r] : s[d], p = { sid: i.surveyId, qid: l.name, action: n, vid: i.userId, eid: i.envId, isNew: o, responseGroupUid: i.responseGroupUid, previewKey: i.previewKey }, h = await i.trackPromise(ht(`${i.apiURL}/sdk/1/visitors/${i.userId}/surveys/${i.surveyId}/history`, { body: JSON.stringify(p), 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: l, viewDocument: p } = t(), h = o["userleap-platform"] === "web", c = We(o), u = n[r], m = u.type === "matrix" && !(u.props.properties.displayMatrixAsAccordion || d);
e({ minScrollableHeight: void 0 }), setTimeout(() => {
var k, _, T;
!c && !d && ((k = s == null ? void 0 : s.setWidth) == null || k.call(s, Gr));
const [g, f, v] = Kr(p, h && !d, c);
c ? (i(ne.SurveyHeight, { name: ne.SurveyHeight, contentFrameHeight: g, "survey.id": l }), i(ne.SurveyWidth, { name: ne.SurveyWidth, contentFrameWidth: f, "survey.id": l })) : ((_ = s.setHeight) == null || _.call(s, g), e({ minScrollableHeight: v }), !d && m && ((T = s.setWidth) == null || T.call(s, f)));
}, 100);
}, uploadingCardViewed: !1, uploadProgress: {}, useDesktopPrototype: void 0, useMobileStyling: !1, userId: "", viewDocument: window.document, viewedCardCount: 0 })), at = (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, header