@sprig-technologies/sprig-browser 2.32.0 → 2.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,981 @@
1
+ var ft = Object.defineProperty;
2
+ var vt = (r, t, n) => t in r ? ft(r, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[t] = n;
3
+ var G = (r, t, n) => (vt(r, typeof t != "symbol" ? t + "" : t, n), n);
4
+ import { g as z, s as Je, e as u, S as w, l as C, v as Qe, m as b, b as T, h as ht, E as te, D as V, c as bt, r as $, i as Lt, j as Ut, k as St, n as Fe, o as je, a as It, p as ke, d as kt, q as Ye } from "./metricsReporter-D9j5QNEB.js";
5
+ const Et = "360px", Xt = "ul-app", Zt = "#e6e6e6", er = "#bd282a", tr = 1030, ze = () => {
6
+ try {
7
+ return window.parent.Intercom;
8
+ } catch {
9
+ return null;
10
+ }
11
+ }, We = [Object.freeze(Object.defineProperty({ __proto__: null, disable: () => {
12
+ const r = ze();
13
+ r && (r.ul_wasVisible = !!document.querySelector("iframe.intercom-launcher-frame"), r.ul_wasVisible && r("update", { hide_default_launcher: !0 }));
14
+ }, enable: () => {
15
+ const r = ze();
16
+ r && (r.ul_wasVisible && r("update", { hide_default_launcher: !1 }), delete r.ul_wasVisible);
17
+ } }, Symbol.toStringTag, { value: "Module" }))];
18
+ class _t {
19
+ static disable() {
20
+ We.forEach((t) => t.disable());
21
+ }
22
+ static enable() {
23
+ We.forEach((t) => t.enable());
24
+ }
25
+ }
26
+ const Be = "ul-view-sdk-script", xt = ["ios", "android"], F = "visitors", j = "environments";
27
+ async function O(r, t) {
28
+ var i, o, s;
29
+ const { shouldDropOnRateLimit: n, ...a } = t;
30
+ a.headers = Object.assign(z(window.UserLeap), a.headers);
31
+ const e = await Je(r, { ...a, shouldDropOnRateLimit: n });
32
+ if (e.ok) {
33
+ const d = (i = e.headers) == null ? void 0 : i.get("Authorization"), c = d ? d.split(" ") : void 0, l = c && c.length === 2 ? c[1] : void 0, p = (o = e.headers) == null ? void 0 : o.get("x-ul-visitor-id");
34
+ l && p && (p !== window.UserLeap.visitorId || window.UserLeap.token !== l) && (E("token", l), E("vid", p), u.emit(w.VisitorIDUpdated, { visitorId: p }), window.UserLeap.token = l, window.UserLeap.visitorId = p);
35
+ }
36
+ return (s = e.json) != null && s.logMessage && console.warn(`[Sprig] ${e.json.logMessage}`), e;
37
+ }
38
+ function E(r, t) {
39
+ const n = C.getItem("userleap.ids");
40
+ let a = {};
41
+ if (n)
42
+ try {
43
+ a = JSON.parse(n);
44
+ } catch (i) {
45
+ i instanceof Error && (i.stack = n, window.UserLeap.reportError("Failed to parse local storage credentials", i)), console.warn("[Sprig] (ERR-427) Failed to lookup saved ids", i);
46
+ }
47
+ let e = a[window.UserLeap.envId];
48
+ e ? e[r] = t : e = { [r]: t }, a[window.UserLeap.envId] = e;
49
+ try {
50
+ C.setItem("userleap.ids", JSON.stringify(a));
51
+ } catch (i) {
52
+ i instanceof Error && console.warn(`[Sprig] (ERR-426) Unable to write to Local Storage:: ${i.message}`);
53
+ }
54
+ }
55
+ function Ee() {
56
+ return window.previewMode ? "0" : window.UserLeap.visitorId ?? "";
57
+ }
58
+ function D(r, t, n) {
59
+ const a = [window.UserLeap._API_URL, "sdk", r];
60
+ return t && t.forEach((e) => {
61
+ a.push(e), e === j ? a.push(window.UserLeap.envId) : e === F && a.push(Ee());
62
+ }), n && a.push(n), a.join("/");
63
+ }
64
+ const X = async (r, t) => {
65
+ var Pe, Ce, Te;
66
+ const { context: n, delay: a, forceBrandedLogo: e, endCard: i, isFeedback: o = !1, heatmap: s, locale: d, previewMode: c, productConfig: l, questions: p, responseGroupUid: y, surveyId: g, uuid: m, vid: _, sessionReplay: M, studyType: S } = r, L = z(window.UserLeap), I = ue(L), k = _e(L);
67
+ if (M)
68
+ if (I)
69
+ u.emit(w.ReplayCapture, { responseGroupUid: y, hasQuestions: !!(p != null && p.length), surveyId: g, uploadId: M.uploadId, replayType: M.replayDurationType ?? "before", seconds: M.replayDurationSeconds, generateVideoUploadUrlPayload: { mediaRecordingUid: Qe(), mediaType: "screen", questionId: 1, responseGroupUid: y, surveyId: g, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), visitorId: window.UserLeap.visitorId, isReplay: !0 } });
70
+ else {
71
+ if (!b.replay)
72
+ return window.UserLeap.reportError("displayQuestions", new Error("Replay module not registered")), { success: !1, message: "Replay module not registered", surveyState: "no survey" };
73
+ b.replay.scheduleOrCaptureReplay({ responseGroupId: y, surveyId: g, visitorId: _, replayParams: M, completeUploadHeaders: L, apiUrl: window.UserLeap._API_URL, triggerTimestamp: Date.now(), isStandalone: p.length === 0 });
74
+ }
75
+ if (s) {
76
+ if (!b.replay)
77
+ return window.UserLeap.reportError("displayQuestions", new Error("Replay module not registered")), { success: !1, message: "Replay module not registered", surveyState: "no survey" };
78
+ const { eventId: h, replayParams: ge, responseGroupUid: mt, surveyId: yt } = s;
79
+ await b.replay.initializeReplay({ maxReplayDurationSeconds: 300, maxInflightRequests: window.UserLeap.maxInflightReplayRequests, teardownAfter: !0 }), b.replay.tryReplayAction(() => {
80
+ var Me;
81
+ return (Me = b.replay) == null ? void 0 : Me.scheduleCapture({ apiUrl: window.UserLeap._API_URL, completeUploadHeaders: L, eventId: h, isHeatmap: !0, replayParams: ge, responseGroupId: mt, surveyId: yt, triggerTimestamp: Date.now(), visitorId: _ });
82
+ }, "Error in scheduling/capturing replay");
83
+ }
84
+ if (_ == null || !(p != null && p.length))
85
+ return T.info("CannotDisplaySurvey", { vid: _ }), { success: !1, message: "[Sprig] no survey found", surveyState: "no survey" };
86
+ if (window.UserLeap.container) {
87
+ T.info("AlreadyDisplayingSurvey");
88
+ const h = "[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";
89
+ return console.warn(h), { success: !1, message: h, surveyState: "no survey" };
90
+ }
91
+ if (_ !== window.UserLeap.visitorId && m !== window.UserLeap.visitorId && !window.previewMode) {
92
+ const h = "Attempted to display survey to a different visitor";
93
+ return window.UserLeap.reportError("DisplaySurvey", new Error(h)), { success: !1, message: h, surveyState: "no survey" };
94
+ }
95
+ T.info("ShowingSurvey", { surveyId: g }), (Pe = b.replay) == null || Pe.RecordSurveyShown({ id: g, userAgent: window.navigator.userAgent }), _t.disable(), u.emit(w.SurveyWillPresent, { name: w.SurveyWillPresent, "survey.id": g });
96
+ let W, v, U, x, A = document.createElement("div");
97
+ const B = (h) => {
98
+ const { "view.version": ge } = h;
99
+ ge !== L["x-ul-sdk-version"] && Ze(), u.removeListener("verify.view.version", B);
100
+ };
101
+ u.on("verify.view.version", B), window.UserLeap.useMobileStyling = k, ht(L) ? (W = "ul-direct-embeded-frame", v = document.head, U = window, x = !1, I && (Xe(g, o), A.id = W, window.UserLeap.container.appendChild(A), et(), u.emit(w.SurveyLifeCycle, { state: "presented" }), u.emit(w.SurveyPresented, { name: w.SurveyPresented, "survey.id": g }))) : { frameId: W, contentWinDocHead: v, contentWindow: U, hasOverlay: x, iframe: A } = Dt({ productConfig: l, useMobileStyling: k, surveyId: g, isFeedback: o }), window.UserLeap.frameId = W;
102
+ const R = { apiURL: window.UserLeap._API_URL, cards: p, configureExitOnOverlayClick: (h) => {
103
+ u.once(w.CloseSurveyOnOverlayClick, h);
104
+ }, context: n, endCard: i, envId: window.UserLeap.envId, eventEmitFn: u.emit.bind(u), fontFamily: window.UserLeap.fontFamily, fontFamilyURL: window.UserLeap.fontFamilyURL, forceBrandedLogo: e, frame: A, headers: L, locale: d, mobileSDKVersion: window.UserLeap.mobileSDKVersion, previewKey: C.getItem("sprig.previewKey"), previewMode: c, productConfig: { framePosition: l == null ? void 0 : l.framePosition, desktopDisplay: l == null ? void 0 : l.desktopDisplay, placement: l == null ? void 0 : l.placement }, responseGroupUid: y, startingQuestionIdx: (Ce = window.UserLeap.config) == null ? void 0 : Ce.startingQuestionIdx, studyType: S, styleNonce: window.UserLeap.styleNonce, surveyId: g, tabTitle: document.title, trackPageViewUrl: t, ulEvents: te, upchunkLibraryURL: window.UserLeap.upchunkLibraryURL, useMobileStyling: k, userId: m, viewDocument: U == null ? void 0 : U.document, viewWindow: U, visitorAttributes: { externalUserId: window.UserLeap.userId, email: window.UserLeap.email }, ...window.UserLeap._config };
105
+ (Te = window.UserLeap._config) != null && Te.startingQuestionIdx && (window.UserLeap._config = { ...window.UserLeap._config, startingQuestionIdx: null });
106
+ const re = (o ? window.UserLeap.feedbackCustomStyles : window.UserLeap.customStyles) ?? l.customStyles;
107
+ R.customStyles = re, U && (U.__cfg = R);
108
+ const J = window.UserLeap.viewSDKURL ? window.UserLeap.viewSDKURL : R.path, De = document.getElementById(Be);
109
+ De && De.remove();
110
+ const we = function() {
111
+ const h = document.createElement("script");
112
+ return window.UserLeap.nonce && h.setAttribute("nonce", window.UserLeap.nonce), h.id = Be, h;
113
+ }(), Re = () => {
114
+ window.UserLeap.container && Object.assign(window.UserLeap.container.style, { display: "flex" });
115
+ };
116
+ if (R.installationMethod === "web-npm" || R.installationMethod === "web-npm-bundled") {
117
+ const { default: h } = await import("./view-DU1bRQNQ.js");
118
+ h.configure(R), x && window.UserLeap.container && Re();
119
+ } else
120
+ J && (we.src = J, x && we.addEventListener("load", () => {
121
+ window.UserLeap.container && Re();
122
+ }), U == null || U.addEventListener("error", (h) => {
123
+ h.target instanceof HTMLScriptElement && h.target.src === J && window.UserLeap.reportError("loadFrameScript", new Error("Frame script failed to load"));
124
+ }, { capture: !0, once: !0 }));
125
+ v == null || v.appendChild(we);
126
+ const Oe = { success: !0, surveyState: "ready", surveyId: g, responseGroupUid: y };
127
+ return window.UserLeap.isMobileSDK && a && (Oe.delay = a), Oe;
128
+ };
129
+ function _e(r) {
130
+ var n;
131
+ if (window.UserLeap.useMobileStyling !== void 0)
132
+ return window.UserLeap.useMobileStyling;
133
+ const t = ((n = window.UserLeap.windowDimensions) == null ? void 0 : n.width) ?? document.body.clientWidth;
134
+ return ue(r) || t > 10 && t < 500;
135
+ }
136
+ function ue(r) {
137
+ return xt.includes(r["userleap-platform"]);
138
+ }
139
+ const xe = "ul-frame";
140
+ window.UserLeap && window.Sprig && (window.Sprig._gtm ? window.Sprig = window.UserLeap : window.UserLeap = window.Sprig), window.UserLeap || (window.UserLeap = window.Sprig), window.Sprig || (window.Sprig = window.UserLeap);
141
+ const me = "0px", Xe = (r, t, n) => {
142
+ window.UserLeap.container = document.createElement("div"), window.UserLeap.container.className = "ul-container" + (t ? " ul-container-feedback" : ""), r && (window.UserLeap.container.dataset.studyId = r.toString());
143
+ const a = rt();
144
+ n && a && !window.UserLeap.useMobileStyling ? a.appendChild(window.UserLeap.container) : document.body.appendChild(window.UserLeap.container);
145
+ }, Ze = (r, t) => {
146
+ var a;
147
+ Ot();
148
+ const n = window.UserLeap.container;
149
+ if (n)
150
+ try {
151
+ (a = n.parentNode) == null || a.removeChild(n), window.UserLeap.container = null, E("trackStartUrl", null), u.emit(w.SurveyLifeCycle, { state: "dismissed" }), u.emit(w.SurveyClosed, { name: w.SurveyClosed, initiator: r, "survey.id": parseInt(n.dataset.studyId), ...t && { studyType: t } });
152
+ } catch (e) {
153
+ console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${r} ` + n), e instanceof Error && window.UserLeap.reportError("dismissActiveSurvey", e);
154
+ }
155
+ }, et = () => {
156
+ u.once(w.SurveyWillClose, ({ initiator: r, studyType: t }) => {
157
+ u.removeAllListeners(w.CloseSurveyOnOverlayClick), Ze(r, t);
158
+ });
159
+ }, At = (r, t, n, a) => {
160
+ var l, p;
161
+ const e = { position: "fixed", bottom: "0px", right: me, border: 0, backgroundColor: "rgba(0,0,0,0)", zIndex: 2147483646, transition: "width 0.2s ease-in-out, height 0.2s ease-in-out", maxWidth: "100%" }, i = Object.assign({}, t, window.UserLeap), { desktopDisplay: o } = t || {}, s = o === "center-modal";
162
+ let d;
163
+ s && (i.framePosition = "center");
164
+ let c = !1;
165
+ if (n)
166
+ (l = window.UserLeap.windowDimensions) != null && l.width ? e.width = `${window.UserLeap.windowDimensions.width}px` : e.width = "100%", (p = window.UserLeap.windowDimensions) != null && p.height ? e.maxHeight = window.UserLeap.windowDimensions.height - 20 + "px" : window.UserLeap.maxHeight ? e.maxHeight = window.UserLeap.maxHeight : e.maxHeight = document.body.clientHeight - 20 + "px", ["light", "dark"].includes(i.overlayStyleMobile) && (c = !0);
167
+ else {
168
+ e.width = Et, e.maxHeight = window.UserLeap.maxHeight || "66vh";
169
+ const y = () => {
170
+ c = !0, d = { margin: "auto", position: "static" };
171
+ };
172
+ if (a)
173
+ s ? y() : d = { position: "relative", height: "300px" };
174
+ else
175
+ switch (i.framePosition) {
176
+ case "bottomLeft":
177
+ d = { left: me };
178
+ break;
179
+ case "topLeft":
180
+ d = { left: me, top: 0 };
181
+ break;
182
+ case "topRight":
183
+ d = { top: 0 };
184
+ break;
185
+ case "center":
186
+ y();
187
+ }
188
+ }
189
+ return c && ((y, g) => {
190
+ const m = { position: "fixed", overflow: "auto", top: "0px", left: "0px", display: "none", height: "100%", width: "100%", transition: "background-color 0.3s ease-out", zIndex: 2147483646 }, _ = g ? y.overlayStyleMobile : y.overlayStyle;
191
+ m["background-color"] = _ === "light" ? "rgba(255,255,255, 0.95)" : "rgba(0,0,0,0.9)", g || (m.margin = "auto"), window.UserLeap.container && Object.assign(window.UserLeap.container.style, m);
192
+ })(i, n), Object.assign(r.style, e, d), c;
193
+ }, Dt = ({ productConfig: r, useMobileStyling: t, surveyId: n, isFeedback: a }) => {
194
+ var y, g;
195
+ const e = xe, i = a && r.desktopDisplay === "slider";
196
+ Xe(n, a, i), Rt();
197
+ const o = document.createElement("iframe");
198
+ o.id = e, o.setAttribute("title", "Sprig User Feedback Dialog");
199
+ const s = At(o, r, t, a);
200
+ et();
201
+ let d = !1;
202
+ o.setHeight = (m) => {
203
+ parseInt(o.style.height) == m && d || (d = !0, o.style.height = `${m}px`, u.emit(w.SurveyHeight, { name: w.SurveyHeight, contentFrameHeight: m, "survey.id": n }));
204
+ };
205
+ let c = !1;
206
+ o.setWidth = (m) => {
207
+ parseInt(o.style.width) == m && c || (c = !0, o.style.width = `${m}px`, u.emit(w.SurveyWidth, { name: w.SurveyWidth, contentFrameWidth: m, "survey.id": n }));
208
+ }, (y = window.UserLeap.container) == null || y.appendChild(o), r && (t ? r.exitOnOverlayClickMobile : r.exitOnOverlayClick) && window.UserLeap.container && (window.UserLeap.container.onclick = () => {
209
+ u.emit(w.CloseSurveyOnOverlayClick);
210
+ }), u.emit(w.SurveyLifeCycle, { state: "presented" }), u.emit(w.SurveyPresented, { name: w.SurveyPresented, "survey.id": n });
211
+ const l = (g = o.contentWindow) == null ? void 0 : g.document;
212
+ if (l && (l.open("text/html", "replace"), l.write("<!doctype html><head></head><body></body></html>"), l.close(), !t)) {
213
+ const m = l.body;
214
+ m.style.display = "flex", m.style.alignItems = "center";
215
+ }
216
+ const p = l == null ? void 0 : l.head;
217
+ return { frameId: e, contentWinDocHead: p, contentWindow: o.contentWindow, hasOverlay: s, iframe: o };
218
+ }, tt = { [w.SurveyFadingOut]: () => {
219
+ window.UserLeap.container && Object.assign(window.UserLeap.container.style, { "background-color": "rgba(0,0,0,0)" });
220
+ } }, Rt = () => {
221
+ Object.entries(tt).forEach(([r, t]) => {
222
+ u.on(r, t);
223
+ });
224
+ }, Ot = () => {
225
+ Object.entries(tt).forEach(([r, t]) => {
226
+ u.off(r, t);
227
+ });
228
+ }, Ne = (r) => r instanceof HTMLElement || r instanceof SVGElement, oe = ({ document: r, elementId: t, styleString: n, nonce: a }) => {
229
+ const e = r.getElementById(t);
230
+ if (e)
231
+ return void (e.textContent = n);
232
+ const i = r.createElement("style");
233
+ a && (i.nonce = a), i.textContent = n, i.id = t, r.head.appendChild(i);
234
+ }, Pt = (r) => {
235
+ const t = r.querySelector(".ul-card__container");
236
+ let n = 600, a = 360;
237
+ if (t) {
238
+ n = t.scrollHeight;
239
+ const e = getComputedStyle(t);
240
+ n += parseFloat(e.marginTop) + parseFloat(e.marginBottom) + (parseFloat(e.borderTopWidth) + parseFloat(e.borderBottomWidth)) + (parseFloat(e.paddingTop) + parseFloat(e.paddingBottom));
241
+ const i = t.querySelector(".ul-card--matrix_grid");
242
+ a = i ? i.scrollWidth : t.scrollWidth;
243
+ const o = parseFloat(e.paddingLeft) + parseFloat(e.paddingRight);
244
+ a += parseFloat(e.marginLeft) + parseFloat(e.marginRight) + (parseFloat(e.borderLeftWidth) + parseFloat(e.borderRightWidth)) + o;
245
+ }
246
+ return [n + 1, a];
247
+ }, rr = (r) => {
248
+ const t = r.querySelector(".ul-card__container");
249
+ t && (t.scrollTop = 0);
250
+ }, rt = () => f, K = () => document.getElementById("sprig-feedback-container"), he = () => document.getElementById("sprig-feedback-loading-animation"), it = () => !!document.getElementById(xe);
251
+ let qe = !1, f = null, P = null, Ae = !1, Z = null, N = null;
252
+ const Ct = ["bottom-left", "bottom-right", "center-left", "center-right"], se = () => {
253
+ var t;
254
+ const r = window.UserLeap.container;
255
+ return ((t = r == null ? void 0 : r.parentElement) == null ? void 0 : t.id) === "sprig-feedback-loading-container";
256
+ }, nt = () => document.getElementById("sprig-feedback-error-container"), ot = () => {
257
+ if (!f)
258
+ return 0;
259
+ const r = f == null ? void 0 : f.clientWidth, t = window.getComputedStyle(f);
260
+ return r + parseInt(t.borderRightWidth || "0") + parseInt(t.borderLeftWidth || "0");
261
+ }, ae = (r) => {
262
+ const t = K();
263
+ t && (N != null && N.endsWith("right") ? t.style.right = `${r}px` : N != null && N.endsWith("left") && (t.style.left = `${r}px`));
264
+ }, ye = () => {
265
+ if (f && (se() || nt())) {
266
+ u.off(w.SurveyAppeared, Y), be();
267
+ const r = ot();
268
+ return ae(-r), !0;
269
+ }
270
+ return !1;
271
+ }, Y = () => {
272
+ if (!f || !P)
273
+ return;
274
+ const r = he();
275
+ r && r.remove(), f.style.height = "auto", f.style.width = "auto", P.disabled = !1, Ae = !1;
276
+ }, be = () => {
277
+ if (f && !he()) {
278
+ const r = (() => {
279
+ if (he())
280
+ return;
281
+ const t = document.createElement("div");
282
+ return t.className = "ul-loading-spinner-container", t.id = "sprig-feedback-loading-animation", t.role = "progressbar", t.setAttribute("aria-live", "polite"), t.setAttribute("aria-busy", "true"), t.setAttribute("aria-label", "Processing..."), t.innerHTML = `
283
+ <div class="ul-loading-spinner">
284
+ <div class="first"></div>
285
+ <div class="second"></div>
286
+ <div class="third"></div>
287
+ <div class="fourth"></div>
288
+ </div>
289
+ `, t;
290
+ })();
291
+ r && (f.style.height = "300px", f.style.width = "360px", f.appendChild(r));
292
+ }
293
+ }, Ve = () => {
294
+ f && P && (ae(0), P.disabled = !0, Ae = !0);
295
+ }, st = async (r, t, n) => {
296
+ const { buttonTheme: a, customStyles: e, eventId: i, placement: o, desktopDisplay: s, feedbackLabel: d, surveyUuid: c, surveyId: l } = r;
297
+ window.UserLeap.feedbackCustomStyles = void 0;
298
+ let p = K();
299
+ if (p) {
300
+ if (!t && i === Z)
301
+ return;
302
+ p.remove(), u.off(te.SURVEY_FADING_OUT, ye);
303
+ }
304
+ Z = i, oe({ document, elementId: "sprig-feedback-style", styleString: '.ul-loading-spinner-container{font-size:1.8rem;flex-grow:1;width:100%;height:100%;display:flex;align-items:center;justify-content:center}.ul-loading-spinner{display:inline-block;position:relative;width:6rem;height:6rem}.ul-loading-spinner div{box-sizing:border-box;display:block;position:absolute;width:80%;height:80%;margin:5px;border:5px solid #152e3e;border-radius:50%;animation:lds-ring 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:#152e3e transparent transparent transparent}.ul-loading-spinner .first{animation-delay:-.45s}.ul-loading-spinner .second{animation-delay:-.3s}.ul-loading-spinner .third{animation-delay:-.15s}@keyframes lds-ring{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.fade-in-transition{animation:fadeIn .4s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}#sprig-feedback-button{border-left:0;border-radius:0 8px 8px 0;display:grid;padding:8px;text-align:center;transition:all ease-in-out 1s;z-index:inherit}#sprig-feedback-button:hover{cursor:pointer}.sprig-feedback-button-label{writing-mode:vertical-lr;text-orientation:sideways}.sprig-feedback-button-right{transform:rotate(180deg)}.sprig-feedback-button-bottom{align-self:flex-end;margin-bottom:20px}.sprig-feedback-button-light{background:#efefee;color:#000;border:1px solid #e2e3e1}.sprig-feedback-button-dark{background:#000;color:#fff;border:1px solid #000000}#sprig-feedback-container{display:flex;align-items:center;position:fixed;transition:right .2s linear,left .2s linear;z-index:2147483646}.sprig-feedback-container-left{flex-flow:row-reverse}.sprig-feedback-container-center{top:50%;transform:translateY(-50%)}.sprig-feedback-container-bottom{bottom:0%;margin-bottom:15px}.sprig-feedback-loading-container{align-items:center;background-color:#fff;border:2px solid var(--feedback-border);display:flex;max-height:90vh;max-width:90vw;min-width:0px}.sprig-feedback-loading-container-left{border-left:none;border-radius:0 8px 8px 0}.sprig-feedback-loading-container-right{border-right:none;border-radius:8px 0 0 8px}#sprig-feedback-error-container{margin:auto;text-align:center;width:360px}.sprig-feedback-error-text{font-weight:400;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol}#sprig-feedback-loading-container .ul-container{position:relative;max-height:inherit}#sprig-feedback-loading-animation{position:absolute}.sprig-feedback-loading-container-previews iframe{max-height:inherit!important}', nonce: window.UserLeap.styleNonce }), oe({ document, elementId: "ul-custom-style", styleString: e ?? "", nonce: window.UserLeap.styleNonce }), qe = s === "center-modal", N = o;
305
+ const [y, g] = o.split("-");
306
+ ((S) => {
307
+ if (K() || !Ct.includes(S))
308
+ return;
309
+ const [L, I] = S.split("-"), k = document.createElement("div");
310
+ k.id = "sprig-feedback-container", k.classList.add(`sprig-feedback-container-${I}`, `sprig-feedback-container-${L}`), document.body.appendChild(k);
311
+ })(o), p = K(), P = document.createElement("button");
312
+ const m = document.createElement("div");
313
+ m.className = "sprig-feedback-button-label", m.innerText = d, P.appendChild(m), P.id = "sprig-feedback-button", P.classList.add(`sprig-feedback-button-${g}`, `sprig-feedback-button-${y}`, `sprig-feedback-button-${a}`, "fade-in-transition"), u.on(te.SURVEY_FADING_OUT, ye), P.addEventListener("click", async () => {
314
+ const S = document.getElementById("sprig-feedback-error-container");
315
+ if (it() || nt()) {
316
+ if (ye()) {
317
+ u.emit(w.SurveyWillClose, { name: w.SurveyWillClose, initiator: V.FeedbackClosed, studyType: "feedbackButton", "survey.id": l });
318
+ const I = K();
319
+ S && I && (I.remove(), Z = null, f = null);
320
+ }
321
+ return;
322
+ }
323
+ if (_e(z(window.UserLeap)) || Ae || Ve(), t)
324
+ return f && f.classList.add("sprig-feedback-loading-container-previews"), await X(t), void Y();
325
+ const L = await (async (I) => {
326
+ const k = await O(D("1", [F], "startFeedbackStudy"), { body: JSON.stringify({ surveyUuid: I }), method: "POST" });
327
+ return k.ok ? k.json : null;
328
+ })(c);
329
+ if (L)
330
+ u.once(w.SurveyAppeared, Y), X({ ...L, studyType: "feedbackButton" }, n);
331
+ else if (f) {
332
+ const I = Tt();
333
+ f.appendChild(I), Y(), f.style.height = "300px", f.style.width = "360px";
334
+ }
335
+ }), p == null || p.appendChild(P), u.emit(w.FeedbackButtonLoaded, { name: w.FeedbackButtonLoaded, "survey.id": l });
336
+ const { useMobileStyling: _, _config: { border: M } } = window.UserLeap;
337
+ if (qe || _)
338
+ ae(0);
339
+ else {
340
+ const S = document.createElement("div");
341
+ S.id = "sprig-feedback-loading-container", S.className = `sprig-feedback-loading-container sprig-feedback-loading-container-${g}`, S.style.setProperty("--feedback-border", M), f = S, be(), p == null || p.appendChild(S);
342
+ const L = ot();
343
+ ae(-L);
344
+ }
345
+ window.UserLeap._config.isOnQuestionsTab && t && !se() && f && (Ve(), be(), f && f.classList.add("sprig-feedback-loading-container-previews"), X(t), Y());
346
+ }, Tt = () => {
347
+ const r = document.createElement("div");
348
+ r.id = "sprig-feedback-error-container", r.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none">
349
+ <circle cx="20" cy="20" r="14.5" stroke="#B0B5B7" stroke-width="3"/>
350
+ <path d="M20 12L20 21.6" stroke="#B0B5B7" stroke-width="3" stroke-linecap="round"/>
351
+ <circle cx="19.9984" cy="27.6" r="1.6" fill="#B0B5B7"/>
352
+ </svg>`;
353
+ const t = document.createElement("h3");
354
+ return t.className = "sprig-feedback-error-text", t.innerText = "There was an error while loading the survey", r.appendChild(t), r;
355
+ }, Le = new class {
356
+ constructor() {
357
+ G(this, "_ldData", {});
358
+ }
359
+ getAllLaunchDarklyVariations() {
360
+ return this._ldData;
361
+ }
362
+ setLDFlagsVariations(r) {
363
+ try {
364
+ return !(!r || typeof r != "object" || Array.isArray(r)) && (Object.keys(this._ldData).forEach((t) => {
365
+ delete this._ldData[t];
366
+ }), Object.keys(r).forEach((t) => this._ldData[`!launch_darkly_${t}`] = (r[t] ?? 0) + 1), !0);
367
+ } catch (t) {
368
+ return t instanceof Error && window.UserLeap.reportError("setAllLDFlagsVariations", t), console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."), !1;
369
+ }
370
+ }
371
+ }();
372
+ Object.freeze(Le);
373
+ const ne = new class {
374
+ constructor() {
375
+ G(this, "_optimizelyData", {});
376
+ }
377
+ setOptimizelyExperiment(r, t = !0) {
378
+ if (!r || typeof r != "object")
379
+ return !1;
380
+ const { experiments: n } = r;
381
+ try {
382
+ return t && Object.keys(this._optimizelyData).map((a) => {
383
+ delete this._optimizelyData[a];
384
+ }), n && n.map((a) => {
385
+ const { id: e, variation: i } = a, o = this.transformExperimentId(e);
386
+ i && typeof i == "string" && (this._optimizelyData[o] = i);
387
+ }), !0;
388
+ } catch (a) {
389
+ return a instanceof Error && window.UserLeap.reportError("setOptimizelyExperiment", a), !1;
390
+ }
391
+ }
392
+ getAllOptimizelyExperiments() {
393
+ return this._optimizelyData;
394
+ }
395
+ getOptimizelyVariationName(r) {
396
+ return this._optimizelyData[this.transformExperimentId(r)];
397
+ }
398
+ transformExperimentId(r) {
399
+ return "!optimizely_experiments_" + r;
400
+ }
401
+ getAndSetWebOptimizelyExperiments() {
402
+ var r;
403
+ try {
404
+ if (window && window.optimizely && typeof window.optimizely.get == "function") {
405
+ const t = (r = window.optimizely.get("state")) == null ? void 0 : r.getExperimentStates({ isActive: !0 });
406
+ if (t) {
407
+ const n = Object.keys(t).map((a) => {
408
+ var e, i;
409
+ return (e = t[a].variation) != null && e.name ? { id: a, variation: (i = t[a].variation) == null ? void 0 : i.name } : { id: a, variation: "Original" };
410
+ });
411
+ return this.setOptimizelyExperiment({ experiments: n }, !1), !0;
412
+ }
413
+ return !1;
414
+ }
415
+ return !1;
416
+ } catch (t) {
417
+ return t instanceof Error && window.UserLeap.reportError("getAndSetWebOptimizely", t), !1;
418
+ }
419
+ }
420
+ }();
421
+ Object.freeze(ne);
422
+ class Mt {
423
+ constructor(t, n) {
424
+ G(this, "paused");
425
+ G(this, "queue");
426
+ G(this, "ul");
427
+ this.ul = t, this.paused = !1, this.queue = [], this.flush(n);
428
+ }
429
+ flush(t) {
430
+ const n = t.length;
431
+ if (n)
432
+ for (let a = 0; a < n; a++)
433
+ this.push(t[a]);
434
+ }
435
+ isPaused() {
436
+ return this.paused;
437
+ }
438
+ pause() {
439
+ this.paused = !0;
440
+ }
441
+ unpause() {
442
+ this.paused = !1;
443
+ const t = this.queue.slice();
444
+ this.empty(), this.flush(t);
445
+ }
446
+ push(t) {
447
+ if (this.paused)
448
+ this.queue.push(t);
449
+ else if (t instanceof Function)
450
+ t();
451
+ else {
452
+ const n = Array.prototype.slice.call(t, 1), a = t[0], e = this.ul[a];
453
+ e instanceof Function ? e.apply(this.ul, n) : a && console.warn("[Sprig] (ERR-100) No valid UserLeap action called", a);
454
+ }
455
+ }
456
+ perform(t) {
457
+ if (this.paused) {
458
+ let n = () => {
459
+ };
460
+ const a = new Promise(function(e) {
461
+ n = function() {
462
+ e(t());
463
+ };
464
+ });
465
+ return this.queue.push(n), a;
466
+ }
467
+ return t();
468
+ }
469
+ empty() {
470
+ this.queue.length = 0;
471
+ }
472
+ }
473
+ let at, dt;
474
+ const Ue = (r) => {
475
+ let t = 0, n = r.firstElementChild;
476
+ for (; n; )
477
+ t += Ue(n), n.shadowRoot && (t += Ue(n.shadowRoot)), n = n.nextElementSibling, t++;
478
+ return t;
479
+ }, He = () => {
480
+ at.report(Ue(document.body)), dt.report(document.documentElement.innerHTML.length);
481
+ }, Se = (r, t) => {
482
+ const n = performance.now();
483
+ document.hidden ? setTimeout(() => Se(r, t), r) : setTimeout(() => {
484
+ const a = performance.now() - n;
485
+ t.report(a / 1e3), setTimeout(() => Se(r, t), r);
486
+ }, 0);
487
+ };
488
+ let de, le, ce, pe, $e, H = {};
489
+ const ie = (r, t = 1) => {
490
+ const { name: n } = r;
491
+ H[n] = (H[n] || 0) + t;
492
+ }, lt = (r) => {
493
+ let t = 1;
494
+ return r.childNodes.forEach((n) => {
495
+ t += lt(n);
496
+ }), t;
497
+ }, Ge = (r) => {
498
+ let t = 0;
499
+ return r.forEach((n) => {
500
+ t += lt(n);
501
+ }), t;
502
+ }, Ft = (r) => {
503
+ switch (r.type) {
504
+ case "childList":
505
+ return ie(de, Ge(r.addedNodes)), void ie(le, Ge(r.removedNodes));
506
+ case "attributes":
507
+ return void ie(ce);
508
+ case "characterData":
509
+ return void ie(pe);
510
+ }
511
+ }, jt = (r) => r.forEach(Ft), zt = () => {
512
+ de.report(H[de.name] || 0), le.report(H[le.name] || 0), ce.report(H[ce.name] || 0), pe.report(H[pe.name] || 0), H = {};
513
+ }, Wt = (r = 1e3) => {
514
+ de = $("sdk_mutations_nodes_added"), le = $("sdk_mutations_nodes_removed"), ce = $("sdk_mutations_attributes_changed"), pe = $("sdk_mutations_character_data"), $e = new MutationObserver(jt), $e.observe(document, { attributes: !0, attributeOldValue: !0, characterData: !0, characterDataOldValue: !0, childList: !0, subtree: !0 }), setInterval(zt, r);
515
+ }, Bt = ({ isWeb: r, reportingIntervalSeconds: t, thresholds: n, postMetrics: a }) => {
516
+ Lt(n, (e, i) => {
517
+ var o, s;
518
+ if ((o = b.replay) != null && o.isReplayRecording()) {
519
+ const d = `Value: ${e} on ${i.metric} violated threshold of ${i.type} ${i.value}`;
520
+ (s = b.replay) == null || s.disableRecording("Threshold violated", new Error(d), { reportError: !1 }), window.UserLeap.reportError("Sdk Performance Metric threshold violated", new Error("Sdk Performance Metric threshold violated"), { metricName: i.metric, type: i.type, value: i.value }, { metricName: i.metric }), St();
521
+ }
522
+ }), Ut({ reportingIntervalSeconds: t, postMetrics: a }), r && (((e = 1e3) => {
523
+ const i = $("sdk_event_queue_latency_seconds");
524
+ Se(e, i);
525
+ })(), ((e = 1e4) => {
526
+ at = $("sdk_dom_nodes_count"), dt = $("sdk_page_html_characters"), He(), setInterval(He, e);
527
+ })(), Wt());
528
+ }, Nt = "test", qt = ["popState", "pushState", "replaceState"], Q = "!email", ct = "pageUrl";
529
+ let fe = window.location.href;
530
+ function ee(r) {
531
+ var s;
532
+ const { pageUrlEvents: t, interactiveEvents: n, dismissOnPageChange: a, platform: e } = window.UserLeap._config;
533
+ if (e && e !== "web")
534
+ return;
535
+ fe !== window.location.href && T.navigation("LocationChange", { from: fe, to: window.location.href }), fe = window.location.href;
536
+ const i = q("trackStartUrl"), o = i ? String(i) : null;
537
+ t && gt(window.location.href), n && (ut(), Vt()), rt() && (() => {
538
+ if (se())
539
+ return;
540
+ const d = K();
541
+ d && (bt(Z) || (d.remove(), Z = null, f = null));
542
+ })(), It.getItem("sprig.isCapturingHeatmap") && ((s = b.replay) == null || s.checkPendingHeatmapsUrl()), !se() && a && o && o !== window.location.href && r && qt.includes(r.type) && window.UserLeap("dismissActiveSurvey", V.PageChange);
543
+ }
544
+ const pt = { capture: !0 }, Vt = () => {
545
+ const r = window.UserLeap._config.interactiveEvents.filter((n) => ke(n, window.location.href)).map((n) => {
546
+ const { name: a, properties: e } = n, { selector: i, innerText: o } = e;
547
+ return i ? (s) => {
548
+ if (Ne(s.target))
549
+ try {
550
+ s.target.closest(i) && window.UserLeap("track", a);
551
+ } catch {
552
+ }
553
+ return !1;
554
+ } : (s) => (Ne(s.target) && s.target.innerText === o && window.UserLeap("track", a), !1);
555
+ }), t = (n) => r.forEach((a) => a(n));
556
+ window.UserLeap._config.interactiveEventsHandler = t, window.addEventListener("click", t, pt);
557
+ }, ut = () => {
558
+ window.UserLeap._config.interactiveEventsHandler && window.removeEventListener("click", window.UserLeap._config.interactiveEventsHandler, pt), delete window.UserLeap._config.interactiveEventsHandler;
559
+ };
560
+ function q(r) {
561
+ const t = C.getItem("userleap.ids");
562
+ if (t)
563
+ try {
564
+ const n = JSON.parse(t)[window.UserLeap.envId];
565
+ return n && n[r] || null;
566
+ } catch (n) {
567
+ n instanceof Error && (n.stack = t, window.UserLeap.reportError("Failed to parse local storage credentials", n));
568
+ }
569
+ return null;
570
+ }
571
+ function wt() {
572
+ window.previewMode || (window.UserLeap.visitorId = Qe(), T.info("NewVid", { vid: window.UserLeap.visitorId }), E("vid", window.UserLeap.visitorId), u.emit(w.VisitorIDUpdated, { visitorId: window.UserLeap.visitorId }));
573
+ }
574
+ function gt(r, t, n, a) {
575
+ var e, i;
576
+ try {
577
+ if (r.endsWith("mock_snippet.html"))
578
+ return;
579
+ T.info("PageView", { url: r });
580
+ const o = window.UserLeap._config.pageUrlEvents;
581
+ let s = !1;
582
+ if (o && o.length)
583
+ for (let l = 0; l < o.length && (s = ke(o[l], r), !s); l++)
584
+ ;
585
+ if (!s)
586
+ return;
587
+ window.UserLeap.debugMode && console.info("[DEBUG] Sprig trackPageView", r);
588
+ const d = { url: r };
589
+ a && (d.trackPageView = !0), window.UserLeap._queue.push(["track", ct, t, d, n]);
590
+ const c = (e = document == null ? void 0 : document.querySelector('meta[name="description"]')) == null ? void 0 : e.getAttribute("content");
591
+ (i = b.replay) == null || i.RecordPageView({ ...c && { description: c }, url: r, referrer: document.referrer, pageTitle: document.title });
592
+ } catch (o) {
593
+ o instanceof Error && (o.stack = r, window.UserLeap.reportError("trackPageView", o)), console.warn("[Sprig] (ERR-428) Failed to track page view", o);
594
+ }
595
+ }
596
+ function Ht() {
597
+ const r = "Backbone" in window && window.Backbone && window.Backbone.history ? window.Backbone.history : window.history;
598
+ "pushState" in r && (r.pushState = /* @__PURE__ */ ((t) => function(...n) {
599
+ const a = t.apply(this, n), e = new Event("pushState");
600
+ return window.dispatchEvent(e), ee(e), a;
601
+ })(r.pushState)), "replaceState" in r && (r.replaceState = /* @__PURE__ */ ((t) => function(...n) {
602
+ const a = t.apply(this, n), e = new Event("replaceState");
603
+ return window.dispatchEvent(e), ee(e), a;
604
+ })(r.replaceState)), ["hashchange", "popstate"].forEach((t) => window.addEventListener(t, ee, !0));
605
+ }
606
+ async function ve(r, t) {
607
+ const n = Ee();
608
+ r && !t && (window.UserLeap._config.mode = Nt);
609
+ const a = _e(z(window.UserLeap)), e = await O(function(i) {
610
+ const o = new URL(D("1", [j], "questions"));
611
+ return Object.entries(i || {}).forEach(([s, d]) => {
612
+ d && o.searchParams.append(s, String(d));
613
+ }), o.toString();
614
+ }({ desktopDisplay: window.UserLeap._config.desktopDisplay, isMobile: a, previewLanguage: window.UserLeap._config.previewLanguage, surveyid: r == null ? void 0 : r.surveyId, surveytemplateid: r == null ? void 0 : r.surveyTemplateId, vid: n }), { shouldDropOnRateLimit: !0 });
615
+ if (!e.ok)
616
+ return e.reportError && e.error && (console.warn("[Sprig] (ERR-414) Failed to request questions from the server", e.error), window.UserLeap.reportError("getQuestions", e.error)), { success: !1, surveyState: "no survey" };
617
+ if (e.json.delay && await Ye(e.json.delay), !e.json.isFeedback)
618
+ return X(e.json);
619
+ {
620
+ const { feedbackLabel: i, productConfig: o, surveyUuid: s, feedbackCustomStyles: d } = e.json, { buttonTheme: c, placement: l, desktopDisplay: p } = o;
621
+ st({ customStyles: d, buttonTheme: c, desktopDisplay: p, eventId: 0, feedbackLabel: i, placement: l, surveyUuid: s, surveyId: r == null ? void 0 : r.surveyId }, e.json);
622
+ }
623
+ }
624
+ function $t(r) {
625
+ if (!r)
626
+ return;
627
+ window.UserLeap._config = r, r.mute && window.UserLeap._queue.pause();
628
+ const { interactiveEvents: t, pageUrlEvents: n, dismissOnPageChange: a } = r;
629
+ t && function(e) {
630
+ let i = e.length;
631
+ for (; i; ) {
632
+ const o = Math.floor(Math.random() * i);
633
+ i -= 1;
634
+ const s = e[i];
635
+ e[i] = e[o], e[o] = s;
636
+ }
637
+ }(t), (t || n || a) && (Ht(), ee());
638
+ }
639
+ const Gt = function(r) {
640
+ if (!window.UserLeap)
641
+ return;
642
+ const t = async (e = {}) => {
643
+ var S, L, I, k, W;
644
+ const { userId: i, anonymousId: o, metadata: s = {}, properties: d, showSurveyCallback: c } = e;
645
+ let { eventName: l } = e;
646
+ if (window.UserLeap.debugMode && l !== ct && console.info("[DEBUG] Sprig track", e), r.mode === "test")
647
+ return;
648
+ const p = C.getItem("sprig.previewKey") ?? void 0;
649
+ if (r.requireUserIdForTracking && !window.UserLeap.userId && !i) {
650
+ const v = "[Sprig] - Skipping tracking without userId";
651
+ return console.warn(v), { success: !1, message: v, surveyState: "no survey" };
652
+ }
653
+ if (!l || l.trim().length === 0) {
654
+ l = l ? String(l) : "";
655
+ const v = "[Sprig] - Invalid event name " + l;
656
+ return console.warn(v), { success: !1, message: v, surveyState: "no survey" };
657
+ }
658
+ const y = window.location.href;
659
+ s.url || (s.url = y), E("trackStartUrl", y), (L = (S = window.UserLeap) == null ? void 0 : S._config) != null && L.optimizelyEnabled && (ue(z(window.UserLeap)) || ne.getAndSetWebOptimizelyExperiments(), s.optimizelyExperiments = Object.assign({}, ne.getAllOptimizelyExperiments())), (k = (I = window.UserLeap) == null ? void 0 : I._config) != null && k.launchDarklyEnabled && (s.launchDarklyFlags = Le.getAllLaunchDarklyVariations()), i && (window.UserLeap.userId = i), o && (window.UserLeap.partnerAnonymousId = o), d && (s.eventProperties = d), (W = b.replay) == null || W.RecordEvent({ name: l, url: s.url }), T.info("TrackEvent", { eventName: l });
660
+ const g = window.UserLeap.delayingSurvey || it() ? await O(D("1", [F], "events/batch"), { body: JSON.stringify({ events: [{ event: l, metadata: s }], previewKey: p }), method: "POST", shouldDropOnRateLimit: !0 }) : await O(D("1", [F], "events"), { body: JSON.stringify({ event: l, metadata: s, previewKey: p }), method: "POST", shouldDropOnRateLimit: !0 });
661
+ if (!g.ok) {
662
+ const v = "[Sprig] (ERR-421) Failed to track event";
663
+ return g.reportError && (console.warn(v, g.error), g.error && window.UserLeap.reportError("track", g.error)), { success: !1, message: v, error: g.error, surveyState: "no survey" };
664
+ }
665
+ i && E("uid", i), o && E("aid", o);
666
+ const m = g.json;
667
+ m.invalidPreviewKey && C.removeItem("sprig.previewKey");
668
+ const _ = s.trackPageView ? s.url : void 0;
669
+ return m != null && m.feedbackButton && st(m.feedbackButton, void 0, _), await async function(v, U) {
670
+ var A, B;
671
+ let x = !0;
672
+ return !(U && ((A = v == null ? void 0 : v.json) != null && A.surveyId) && (window.UserLeap.delayingSurvey = !0, x = await U(v.json.surveyId), window.UserLeap.delayingSurvey = !1, !x)) && ((B = v == null ? void 0 : v.json) != null && B.delay && !window.UserLeap.isMobileSDK && (window.UserLeap.delayingSurvey = !0, await Ye(v.json.delay), window.UserLeap.delayingSurvey = !1), x);
673
+ }(g, c) ? function(v, U) {
674
+ const { pageUrlEvents: x, interactiveEvents: A, dismissOnPageChange: B } = window.UserLeap._config;
675
+ if (!B)
676
+ return !0;
677
+ const R = [];
678
+ x && x.length && R.push(...x), A && A.length && R.push(...A);
679
+ const re = v && R.find((J) => J.id === v);
680
+ return re ? ke(re, window.location.href) : U === window.location.href;
681
+ }(m.eventId, y) ? X(m, _) : { success: !1, message: "Study should not be displayed after page navigation", surveyState: "no survey" } : { success: !1, message: "[Sprig] Callback returned false, aborting rendering of survey", surveyState: "no survey" };
682
+ }, n = (e, i) => {
683
+ var s;
684
+ const o = (s = e == null ? void 0 : e.querySelector(`[id="${xe}"]`)) == null ? void 0 : s.contentDocument;
685
+ o && oe({ document: o, elementId: "ul-custom-style", styleString: i });
686
+ }, a = { displaySurvey: async (e) => (console.warn("[Sprig] displaySurvey should only be used to debug your studies; not intended for production usage."), window.UserLeap("dismissActiveSurvey", V.Override), ve({ surveyId: e }, !0)), _previewSurvey(e) {
687
+ window.UserLeap("dismissActiveSurvey", V.Override), ve({ surveyTemplateId: e }, !1);
688
+ }, _reviewSurvey(e) {
689
+ window.UserLeap("dismissActiveSurvey", V.Override), ve({ surveyId: e }, !1);
690
+ }, previewSurvey(e) {
691
+ a._previewSurvey(e);
692
+ }, reviewSurvey(e) {
693
+ a._reviewSurvey(e);
694
+ }, mute() {
695
+ window.UserLeap._queue.pause();
696
+ }, unmute() {
697
+ window.UserLeap._queue.unpause();
698
+ }, setVisitorToken() {
699
+ console.warn("[Sprig] setVisitorToken is deprecated.");
700
+ }, dismissActiveSurvey(e = V.API) {
701
+ window.UserLeap.container && u.emit(w.SurveyWillClose, { name: w.SurveyWillClose, initiator: e, "survey.id": parseInt(window.UserLeap.container.dataset.studyId) });
702
+ }, async setAttribute(e, i) {
703
+ if (!e || !i && i !== 0 && i !== !1) {
704
+ const o = "[Sprig] - Disregarding empty attribute / value provided";
705
+ return console.warn(o), { success: !1, message: o };
706
+ }
707
+ return this.setAttributes({ [e]: i });
708
+ }, async setAttributes(e) {
709
+ if (e == null || Object.keys(e).length === 0) {
710
+ const i = "[Sprig] - Disregarding empty attributes provided";
711
+ return console.warn(i), { success: !1, message: i };
712
+ }
713
+ return this.identifyAndSetAttributes({ attributes: e });
714
+ }, async identifyAndSetAttributes(e) {
715
+ if (window.UserLeap.debugMode && console.info("[DEBUG] Sprig identifyAndSetAttributes", e), r.mode === "test")
716
+ return;
717
+ if (e === null || typeof e != "object" || !(e.userId || e.anonymousId || e.attributes)) {
718
+ const l = "[Sprig] - Disregarding empty payload provided";
719
+ return console.warn(l), { success: !1, message: l };
720
+ }
721
+ const { userId: i, anonymousId: o, attributes: s } = e;
722
+ if (r.requireUserIdForTracking && !window.UserLeap.userId && !i) {
723
+ const l = "[Sprig] - Skipping tracking without userId";
724
+ return console.warn(l), { success: !1, message: l };
725
+ }
726
+ if (!(s || i && window.UserLeap.userId !== i || o && window.UserLeap.partnerAnonymousId !== o))
727
+ return { success: !0 };
728
+ const d = {};
729
+ let c;
730
+ return i && (d.userId = window.UserLeap.userId = i), o && (d.partnerAnonymousId = window.UserLeap.partnerAnonymousId = o), s ? (s.email && !Object.prototype.hasOwnProperty.call(s, Q) && (s[Q] = s.email, delete s.email), c = await O(D("1", [j, F], "attributes"), { body: JSON.stringify(s), method: "PUT" }), !c.ok && c.reportError && (console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed", c.error), c.error && window.UserLeap.reportError("identifyAndSetAttributes", c.error))) : c = await O(D("1", [j, F]), { body: JSON.stringify(d), method: "PUT" }), s && s[Q] && (window.UserLeap.email = s[Q]), c.ok && (i && E("uid", i), o && E("aid", o)), { success: !!c.ok };
731
+ }, async removeAttributes(e) {
732
+ if (window.UserLeap.debugMode && console.info("[DEBUG] Sprig removeAttributes", e), r.mode === "test")
733
+ return;
734
+ if (e == null || e.length === 0) {
735
+ const o = "[Sprig] - Disregarding empty attributes provided";
736
+ return console.warn(o), { success: !1, message: o };
737
+ }
738
+ if (r.requireUserIdForTracking && !window.UserLeap.userId) {
739
+ const o = "[Sprig] - Skipping tracking without userId";
740
+ return console.warn(o), { success: !1, message: o };
741
+ }
742
+ const i = await O(D("1", [j, F], "attributes"), { body: JSON.stringify({ delete: e }), method: "DELETE" });
743
+ return !i.ok && i.reportError && (console.warn("[Sprig] (ERR-433) Remove attributes failed", i.error), i.error && window.UserLeap.reportError("removeAttributes", i.error)), { success: !!i.ok };
744
+ }, async addSurveyListener(e) {
745
+ u.on(w.SurveyLifeCycle, e);
746
+ }, async removeSurveyListener(e) {
747
+ u.removeListener(w.SurveyLifeCycle, e);
748
+ }, async addListener(e, i) {
749
+ u.on(e, i);
750
+ }, async removeListener(e, i) {
751
+ u.removeListener(e, i);
752
+ }, async removeAllListeners() {
753
+ u.removeAllListeners();
754
+ }, setPreviewKey(e) {
755
+ e && typeof e == "string" && C.isStorageAvailable && e && C.setItem("sprig.previewKey", e);
756
+ }, async setUserId(e) {
757
+ var s;
758
+ if (window.UserLeap.debugMode && console.info("[DEBUG] Sprig setUserId", e), e == null) {
759
+ const d = `[Sprig] - Invalid userId ${e}`;
760
+ return console.warn(d), { success: !1, message: d };
761
+ }
762
+ if (r.mode === "test" || e === window.UserLeap.userId)
763
+ return;
764
+ window.UserLeap.userId = e;
765
+ const i = window.UserLeap.visitorId, o = await O(D("1", [j, F]), { body: JSON.stringify({ userId: e }), method: "PUT" });
766
+ o.ok ? (i !== window.UserLeap.visitorId && ((s = b.replay) == null || s.clearUserReplayData()), E("uid", e)) : o.reportError && (console.warn("[Sprig] (ERR-420) Failed to set user id", o.error), o.error && window.UserLeap.reportError("setUserId", o.error));
767
+ }, async setPartnerAnonymousId(e) {
768
+ if (window.UserLeap.debugMode && console.info("[DEBUG] Sprig setPartnerAnonymousId", e), e == null) {
769
+ const i = `[Sprig] - Invalid partnerAnonymousId ${e}`;
770
+ return console.warn(i), { success: !1, message: i };
771
+ }
772
+ return window.UserLeap.partnerAnonymousId = e, E("aid", e), { success: !0 };
773
+ }, track: async (e, i, o = {}, s = void 0) => t({ eventName: e, properties: i, metadata: o, showSurveyCallback: s }), identifyAndTrack: async (e) => await t(e), trackPageView(e, i = void 0, o = void 0, s = !0) {
774
+ gt(e, i, o, s);
775
+ }, applyFeedbackStyles({ button: e = "", view: i = "" }) {
776
+ window.UserLeap.feedbackCustomStyles = i, document.getElementById("sprig-feedback-style") && oe({ document, elementId: "ul-custom-style", styleString: e, nonce: window.UserLeap.styleNonce }), n(document.querySelector(".ul-container-feedback"), i);
777
+ }, applyStyles(e) {
778
+ window.UserLeap.customStyles = e, n(window.UserLeap.container, e);
779
+ }, setWindowDimensions(e, i) {
780
+ var c, l;
781
+ const o = typeof e == "string" ? parseInt(e, 10) : e, s = typeof i == "string" ? parseInt(i, 10) : i;
782
+ if (isNaN(o) || isNaN(s) || (window.UserLeap.windowDimensions = { width: o, height: s }), !window.UserLeap.frameId)
783
+ return;
784
+ const d = document.getElementById(window.UserLeap.frameId);
785
+ d && (window.UserLeap.useMobileStyling && ((c = window.UserLeap.windowDimensions) != null && c.width && (d.style.width = `${window.UserLeap.windowDimensions.width}px`), (l = window.UserLeap.windowDimensions) != null && l.height && (d.style.maxHeight = window.UserLeap.windowDimensions.height - 20 + "px"), d.contentDocument && (d.style.height = String(Pt(d.contentDocument)[0]) + "px")), u.emit(w.SurveyDimensions, { name: w.SurveyDimensions, contentFrameWidth: d.clientWidth, contentFrameHeight: d.clientHeight, "survey.id": parseInt(window.UserLeap.container.dataset.studyId) }));
786
+ }, logoutUser() {
787
+ var e;
788
+ window.UserLeap.debugMode && console.info("[DEBUG] Sprig logout"), T.info("LogOut", { vid: window.UserLeap.visitorId, userId: window.UserLeap.userId }), window.UserLeap.visitorId = null, window.UserLeap.userId = null, window.UserLeap.partnerAnonymousId = null, window.UserLeap.token = null, window.UserLeap.email = null, C.removeItem("userleap.ids"), window.UserLeap._queue.isPaused() && window.UserLeap._queue.empty(), wt(), (e = b.replay) == null || e.clearUserReplayData(), window.UserLeap._queue.unpause();
789
+ }, teardown() {
790
+ ["hashchange", "popstate"].forEach((e) => window.removeEventListener(e, ee, !0)), window.UserLeap._config.interactiveEvents && ut(), window.UserLeap("dismissActiveSurvey", V.API), delete window.UserLeap, delete window.Sprig, delete window._Sprig;
791
+ }, integrateOptimizely(e, i = !0) {
792
+ var o, s;
793
+ if ((s = (o = window.UserLeap) == null ? void 0 : o._config) != null && s.optimizelyEnabled)
794
+ try {
795
+ const d = typeof e == "string" ? JSON.parse(e) : e;
796
+ ne.setOptimizelyExperiment(d, i);
797
+ } catch (d) {
798
+ console.warn("[Sprig] Error with integrating Optimizely data"), d instanceof Error && window.UserLeap.reportError("integrateOptimizely", d);
799
+ }
800
+ else
801
+ console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");
802
+ }, integrateOptimizelyClient(e) {
803
+ var i, o;
804
+ if (!((o = (i = window.UserLeap) == null ? void 0 : i._config) != null && o.optimizelyEnabled))
805
+ return void console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");
806
+ e.notificationCenter.addNotificationListener("ACTIVATE:experiment, user_id,attributes, variation, event", ({ experiment: s, variation: d }) => {
807
+ const c = { experiments: [{ id: s.id, variation: d.key }] };
808
+ window.UserLeap("integrateOptimizely", c, !1);
809
+ });
810
+ }, importLaunchDarklyData(e) {
811
+ var i, o;
812
+ (o = (i = window.UserLeap) == null ? void 0 : i._config) != null && o.launchDarklyEnabled ? Le.setLDFlagsVariations(e) : console.warn("[SPRIG] LaunchDarkly integration is currently not enabled for your product.");
813
+ }, setVisitorAttribute: (e, i) => (console.warn("[Sprig] setVisitorAttribute is deprecated. Please use setAttribute"), a.setAttribute(e, i)), setEmail: async (e) => a.setAttribute(Q, e), setVisitorEmail: async (e) => (console.warn("[Sprig] setVisitorEmail is deprecated. Please use setEmail"), a.setEmail(e)), _generateVideoUploadUrl: async (e) => async function(i) {
814
+ var s;
815
+ if (!i)
816
+ return;
817
+ const o = `${window.UserLeap._API_URL}/2/environments/integrations/upload`;
818
+ try {
819
+ const d = await fetch(o, { method: "POST", cache: "no-cache", headers: { "Content-Type": "application/json" }, body: JSON.stringify(i) });
820
+ if (d.ok) {
821
+ const c = await d.json();
822
+ return (s = c == null ? void 0 : c.upload) == null ? void 0 : s.url;
823
+ }
824
+ return null;
825
+ } catch (d) {
826
+ console.warn("[Sprig] Error with generating video upload url"), d instanceof Error && window.UserLeap.reportError("generateVideoUploadUrl", d);
827
+ }
828
+ }(e), _reportMetric(e, i) {
829
+ kt(e, i);
830
+ }, _completeSessionReplay: async ({ surveyId: e, responseGroupUuid: i, eventDigest: o }) => {
831
+ var s;
832
+ return b.replay ? (s = b.replay) == null ? void 0 : s._completeSessionReplay({ surveyId: e, responseGroupUuid: i, eventDigest: o, headers: z(window.UserLeap) }) : (window.UserLeap.reportError("_completeSessionReplay", new Error("Replay module not registered")), !1);
833
+ } };
834
+ Object.assign(window.UserLeap, a);
835
+ };
836
+ async function Kt(r, t, n = {}, a = {}) {
837
+ const e = window.__cfg && window.__cfg.mode, i = Ee(), o = window.UserLeap.envId, s = window.document.documentElement, d = { mode: e, screenWidth: window.screen.width, screenHeight: window.screen.height, clientWidth: s.clientWidth, clientHeight: s.clientHeight, location: window.location.href, language: window.navigator.language, ...n }, c = { action: r, breadcrumbs: T.breadcrumbs, err: { message: `${t == null ? void 0 : t.name} - ${t == null ? void 0 : t.message}`, stack: t == null ? void 0 : t.stack }, meta: d, vid: i, envId: o, ...a };
838
+ (await O(D("1", null, "errors"), { method: "POST", headers: { "x-ul-error": window.btoa(`userleap-${Date.now()}-error`) }, body: JSON.stringify(c), shouldDropOnRateLimit: !0 })).ok || console.warn("[Sprig] (ERR-444) Failed to report error to API", t);
839
+ }
840
+ function Jt(r = {}) {
841
+ const t = new URLSearchParams(window.location.search).get("sprigPreviewKey") ?? "";
842
+ async function n() {
843
+ var d;
844
+ if (window.UserLeap.loaded)
845
+ return;
846
+ if (window.UserLeap.reportError = Kt, window.UserLeap.loaded = !0, window.UserLeap._config = Object.assign({}, r, window.UserLeap.config), window.UserLeap.delayingSurvey = !1, window.UserLeap._config && typeof window.UserLeap._config == "object")
847
+ for (const c in window.UserLeap._config)
848
+ window.UserLeap[c] = window.UserLeap._config[c];
849
+ if (!window.UserLeap.envId) {
850
+ if (!window.UserLeap.appId)
851
+ throw new Error("Missing Environment id");
852
+ window.UserLeap.envId = window.UserLeap.appId;
853
+ }
854
+ window.UserLeap.debugMode && console.info("[DEBUG] Sprig debug mode enabled");
855
+ const a = window.UserLeap.sampleRate;
856
+ if (a) {
857
+ let c = q("sampled");
858
+ if (c === null && (c = Math.random() < a, E("sampled", c)), !c)
859
+ return;
860
+ } else
861
+ q("sampled") !== null && E("sampled", null);
862
+ window.UserLeap._API_URL || (window.UserLeap._API_URL = "https://api.sprig.com");
863
+ const e = [...window.UserLeap._queue];
864
+ window.UserLeap._queue = new Mt(window.UserLeap, []), window.UserLeap._queue.pause();
865
+ for (let c = 0; c < e.length; c++)
866
+ window.UserLeap._queue.push(e[c]);
867
+ const i = q("token");
868
+ i ? (window.UserLeap.token = i, window.UserLeap.visitorId = q("vid"), window.UserLeap.userId = q("uid"), window.UserLeap.partnerAnonymousId = q("aid")) : (C.removeItem("userleap.ids"), wt());
869
+ const o = ue(z(window.UserLeap)), s = await async function(c) {
870
+ const l = z(window.UserLeap);
871
+ document.addEventListener("securitypolicyviolation", Fe);
872
+ const p = await Je(D("1", [j], "config"), { headers: l });
873
+ if (document.removeEventListener("securitypolicyviolation", Fe), !p.ok)
874
+ return p.reportError && (console.warn("[Sprig] (ERR-422) Failed to load configuration", p.error), p.error && window.UserLeap.reportError("applyRemoteConfig", p.error)), je("Disabled: failed to fetch configuration"), c;
875
+ const y = p.json;
876
+ return y != null && y.disabled ? (je(`Disabled: ${y.disabled}`), { disabled: y.disabled }) : Object.assign({}, y, c);
877
+ }(r);
878
+ Bt({ isWeb: !o, reportingIntervalSeconds: s.metricsReportingEnabled || s.mobileMetricsReportingEnabled ? s.metricsReportingIntervalSeconds : 0, thresholds: s.metricThresholds, postMetrics: async (c) => {
879
+ var l;
880
+ await O(D("1", [j], "metrics"), { body: c, method: "POST", headers: { "x-ul-replay-enabled": `${!!((l = b.replay) != null && l.isReplayRecording())}` }, shouldDropOnRateLimit: !0 });
881
+ } }), await ((d = b.replay) == null ? void 0 : d.initializeReplay({ maxReplayDurationSeconds: s.maxReplayDurationSeconds, maxInflightRequests: window.UserLeap.maxInflightReplayRequests ?? 2, replaySettings: s.replaySettings })), Gt(s), await $t(s), window.UserLeap._queue.unpause(), u.emit(w.SDKReady, { mobileMetricsReportingEnabled: !!s.mobileMetricsReportingEnabled, metricsReportingInterval: s.metricsReportingIntervalSeconds || 0, metricsThresholds: s.metricThresholds || [], maxMobileReplayDurationSeconds: s.maxMobileReplayDurationSeconds, mobileReplaySettings: s.mobileReplaySettings }), u.emit(w.VisitorIDUpdated, { visitorId: window.UserLeap.visitorId });
882
+ }
883
+ window.UserLeap.UPDATES = te, window.UserLeap("setPreviewKey", t), document.readyState === "complete" ? n() : window.attachEvent ? window.attachEvent("onload", n) : window.addEventListener("load", () => {
884
+ n();
885
+ }, !1);
886
+ }
887
+ class Ie {
888
+ constructor() {
889
+ this.UPDATES = te;
890
+ }
891
+ displaySurvey(t) {
892
+ window.Sprig("displaySurvey", t);
893
+ }
894
+ mute() {
895
+ window.Sprig("mute");
896
+ }
897
+ unmute() {
898
+ window.Sprig("unmute");
899
+ }
900
+ dismissActiveSurvey() {
901
+ window.Sprig("dismissActiveSurvey");
902
+ }
903
+ setAttribute(t, n) {
904
+ window.Sprig("setAttribute", t, n);
905
+ }
906
+ setAttributes(t) {
907
+ window.Sprig("setAttributes", t);
908
+ }
909
+ identifyAndSetAttributes(t) {
910
+ window.Sprig("identifyAndSetAttributes", t);
911
+ }
912
+ removeAttributes(t) {
913
+ window.Sprig("removeAttributes", t);
914
+ }
915
+ addListener(t, n) {
916
+ window.Sprig("addListener", t, n);
917
+ }
918
+ removeListener(t, n) {
919
+ window.Sprig("removeListener", t, n);
920
+ }
921
+ removeAllListeners() {
922
+ window.Sprig("removeAllListeners");
923
+ }
924
+ setEmail(t) {
925
+ window.Sprig("setAttribute", "!email", t);
926
+ }
927
+ setUserId(t) {
928
+ window.Sprig("setUserId", t);
929
+ }
930
+ setPartnerAnonymousId(t) {
931
+ window.Sprig("setPartnerAnonymousId", t);
932
+ }
933
+ track(t, n = {}, a = {}) {
934
+ window.Sprig("track", t, n, a);
935
+ }
936
+ identifyAndTrack(t) {
937
+ window.Sprig("identifyAndTrack", t);
938
+ }
939
+ trackPageView(t, n, a) {
940
+ window.Sprig("trackPageView", t, n, a);
941
+ }
942
+ applyStyles(t) {
943
+ window.Sprig("applyStyles", t);
944
+ }
945
+ setWindowDimensions(t, n) {
946
+ window.Sprig("setWindowDimensions", t, n);
947
+ }
948
+ logoutUser() {
949
+ window.Sprig("logoutUser");
950
+ }
951
+ teardown() {
952
+ window.Sprig("teardown");
953
+ }
954
+ }
955
+ const Ke = { configure: (r) => {
956
+ if (!r.envId && !r.environmentId)
957
+ throw new Error("Initialization Error: Sprig configure requires an environmentId");
958
+ if (r.envId || (r.envId = r.environmentId ?? ""), r.installationMethod = "web-npm", window.Sprig)
959
+ return window.Sprig;
960
+ window.Sprig = function() {
961
+ window.Sprig._queue.push(arguments);
962
+ }, Object.getOwnPropertyNames(Ie.prototype).map((n) => {
963
+ n !== "constructor" && (window.Sprig[n] = Ie.prototype[n]);
964
+ });
965
+ const t = window.Sprig;
966
+ return t.appId = r.envId, t._queue = [], window.UserLeap = t, Jt(r), window.Sprig;
967
+ } }, ir = { sprig: Ke, SprigAPI: Ie, configure: Ke.configure };
968
+ export {
969
+ Xt as A,
970
+ _t as C,
971
+ Et as D,
972
+ tr as E,
973
+ Ie as S,
974
+ Pt as a,
975
+ er as b,
976
+ ir as c,
977
+ Zt as d,
978
+ oe as e,
979
+ rr as r,
980
+ Ke as s
981
+ };