UNPKG

@sprig-technologies/sprig-browser

Version:

npm package for the sprig web sdk

773 lines 63.3 kB
var Ot = Object.defineProperty; var Ct = (r, e, i) => e in r ? Ot(r, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : r[e] = i; var z = (r, e, i) => Ct(r, typeof e != "symbol" ? e + "" : e, i); import { l as H, g as O, s as dt, e as g, S as u, v as ct, m as S, b as P, h as pt, E as ae, a as Q, D as C, c as Pt, r as G, i as Mt, j as jt, k as Ft, n as Ke, o as Je, d as qt, p as ut, q as gt } from "./metricsReporter-0HbKrvkx.js"; const gr = 360, hr = "ul-app", yr = "#e6e6e6", br = "#bd282a", mr = 1030, Qe = () => { try { return window.parent.Intercom; } catch { return null; } }, Ye = [Object.freeze(Object.defineProperty({ __proto__: null, disable: () => { const r = Qe(); r && (r.ul_wasVisible = !!document.querySelector("iframe.intercom-launcher-frame"), r.ul_wasVisible && r("update", { hide_default_launcher: !0 })); }, enable: () => { const r = Qe(); r && (r.ul_wasVisible && r("update", { hide_default_launcher: !1 }), delete r.ul_wasVisible); } }, Symbol.toStringTag, { value: "Module" }))]; class Ht { static disable() { Ye.forEach((e) => e.disable()); } static enable() { Ye.forEach((e) => e.enable()); } } const Xe = "ul-view-sdk-script", Vt = /* @__PURE__ */ new Set(["ios", "android"]), F = "visitors", q = "environments"; async function D(r, e) { var s, n, o; const { shouldDropOnRateLimit: i, ...a } = e; a.headers = Object.assign(O(window.UserLeap), a.headers); const t = await dt(r, { ...a, shouldDropOnRateLimit: i }); if (t.ok) { const l = (s = t.headers) == null ? void 0 : s.get("Authorization"), c = l ? l.split(" ") : void 0, d = c && c.length === 2 ? c[1] : void 0, p = (n = t.headers) == null ? void 0 : n.get("x-ul-visitor-id"); if (window.UserLeap.userId && p === window.UserLeap.visitorId) { const m = H.getItemObject("sprig.anon.env.vid.map"); m && m[window.UserLeap.envId] === p && (delete m[window.UserLeap.envId], H.setItemObject("sprig.anon.env.vid.map", m)); } d && p && (p !== window.UserLeap.visitorId || window.UserLeap.token !== d) && (_("token", d), _("vid", p), g.emit(u.VisitorIDUpdated, { visitorId: p }), window.UserLeap.token = d, window.UserLeap.visitorId = p); } return (o = t.json) != null && o.logMessage && console.warn(`[Sprig] ${t.json.logMessage}`), t; } function _(r, e) { const i = H.getItemObject("userleap.ids"); let a = i[window.UserLeap.envId]; a ? a[r] = e : a = { [r]: e }, i[window.UserLeap.envId] = a, H.setItemObject("userleap.ids", i); } function Ce() { return window.previewMode ? "0" : window.UserLeap.visitorId ?? ""; } function x(r, e, i) { const a = [window.UserLeap._API_URL, "sdk", r]; return e && e.forEach((t) => { a.push(t), t === q ? a.push(window.UserLeap.envId) : t === F && a.push(Ce()); }), i && a.push(i), a.join("/"); } const te = async (r, e, i) => { var Ne, ze, Be, $e; const { context: a, delay: t, avatars: s, experimentFlags: n, forceBrandedLogo: o, endCard: l, isFeedback: c = !1, heatmap: d, locale: p, layout: m, previewMode: f, productConfig: h, questions: b, responseGroupUid: v, surveyId: y, uuid: I, vid: L, sessionReplay: k, studyType: V, surveyVisitorAttributes: T } = r, E = O(window.UserLeap), M = oe(E), K = we(E); if (k) if (M) g.emit(u.ReplayCapture, { responseGroupUid: v, hasQuestions: !!(b != null && b.length), surveyId: y, uploadId: k.uploadId, replayType: k.replayDurationType ?? "before", seconds: k.replayDurationSeconds, generateVideoUploadUrlPayload: { mediaRecordingUid: ct(), mediaType: "screen", questionId: 1, responseGroupUid: v, surveyId: y, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), visitorId: window.UserLeap.visitorId, isReplay: !0 } }); else { if (!S.replay) return window.UserLeap.reportError("displayQuestions", new Error("Replay module not registered")), { success: !1, message: "Replay module not registered", surveyState: "no survey" }; S.replay.scheduleOrCaptureReplay({ responseGroupId: v, surveyId: y, visitorId: L, replayParams: k, completeUploadHeaders: E, apiUrl: window.UserLeap._API_URL, triggerTimestamp: Date.now(), isStandalone: b.length === 0 }); } if (d) { if (!S.replay) return window.UserLeap.reportError("displayQuestions", new Error("Replay module not registered")), { success: !1, message: "Replay module not registered", surveyState: "no survey" }; const { eventId: U, replayParams: N, responseGroupUid: Se, surveyId: Te } = d; await S.replay.initializeReplay({ maxReplayDurationSeconds: 300, maxInflightRequests: window.UserLeap.maxInflightReplayRequests, teardownAfter: !0, apiUrl: window.UserLeap._API_URL, replaySettings: i }), S.replay.tryReplayAction(() => { var Ge; return (Ge = S.replay) == null ? void 0 : Ge.scheduleCapture({ apiUrl: window.UserLeap._API_URL, completeUploadHeaders: E, eventId: U, isHeatmap: !0, replayParams: N, responseGroupId: Se, surveyId: Te, triggerTimestamp: Date.now(), visitorId: L }); }, "Error in scheduling/capturing replay"); } if (L == null || !(b != null && b.length)) return P.info("CannotDisplaySurvey", { vid: L }), { success: !1, message: "[Sprig] no survey found", surveyState: window.UserLeap.container ? "previous survey ready" : "no survey" }; if (window.UserLeap.container) { P.info("AlreadyDisplayingSurvey"); const U = "[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey"; return console.warn(U), { success: !1, message: U, surveyState: "previous survey ready" }; } if (L !== window.UserLeap.visitorId && I !== window.UserLeap.visitorId && !window.previewMode) { const U = "Attempted to display survey to a different visitor"; return window.UserLeap.reportError("DisplaySurvey", new Error(U)), { success: !1, message: U, surveyState: "no survey" }; } P.info("ShowingSurvey", { surveyId: y }), (Ne = S.replay) == null || Ne.RecordSurveyShown({ id: y, userAgent: window.navigator.userAgent }), Ht.disable(), g.emit(u.SurveyWillPresent, { name: u.SurveyWillPresent, "survey.id": y, layout: m }); let W, X, R, ne, le = document.createElement("div"); const qe = (U) => { const { "view.version": N } = U; N !== E["x-ul-sdk-version"] && yt(), g.removeListener("verify.view.version", qe); }; g.on("verify.view.version", qe), window.UserLeap.useMobileStyling = K, pt(E) ? (W = "ul-direct-embeded-frame", X = document.head, R = window, ne = !1, (() => { const U = O(window.UserLeap), N = oe(U), Se = window.UserLeap.forceDirectEmbed, Te = U["userleap-platform"] === "web"; return N || Se && Te; })() && (ht(y, c), le.id = W, window.UserLeap.container.appendChild(le), bt(), g.emit(u.SurveyLifeCycle, { state: "presented" }), g.emit(u.SurveyPresented, { name: u.SurveyPresented, "survey.id": y }))) : { frameId: W, contentWinDocHead: X, contentWindow: R, hasOverlay: ne, iframe: le } = zt({ productConfig: h, useMobileStyling: K, surveyId: y, isFeedback: c, enableCspTrustedTypes: (ze = window.UserLeap._config) == null ? void 0 : ze.enableCspTrustedTypes }), window.UserLeap.frameId = W; const J = { apiURL: window.UserLeap._API_URL, avatars: s, cards: b, configureExitOnOverlayClick: (U) => { g.once(u.CloseSurveyOnOverlayClick, U); }, context: a, endCard: l, envId: window.UserLeap.envId, eventEmitFn: g.emit.bind(g), experimentFlags: n, fontFamily: window.UserLeap.fontFamily, fontFamilyURL: window.UserLeap.fontFamilyURL, forceBrandedLogo: o, frame: le, headers: E, layout: m, locale: p, mobileSDKVersion: window.UserLeap.mobileSDKVersion, previewKey: Q.getItem("sprig.previewKey"), previewMode: f || !!window.previewMode, productConfig: { framePosition: h == null ? void 0 : h.framePosition, desktopDisplay: h == null ? void 0 : h.desktopDisplay, placement: h == null ? void 0 : h.placement }, responseGroupUid: v, startingQuestionIdx: (Be = window.UserLeap.config) == null ? void 0 : Be.startingQuestionIdx, studyType: V, styleNonce: window.UserLeap.styleNonce, surveyId: y, tabTitle: document.title, trackPageViewUrl: e, ulEvents: ae, upchunkLibraryURL: window.UserLeap.upchunkLibraryURL, useMobileStyling: K, userId: I, viewDocument: R == null ? void 0 : R.document, viewWindow: R, visitorAttributes: { externalUserId: window.UserLeap.userId, email: window.UserLeap.email }, surveyVisitorAttributes: T || {}, ...window.UserLeap._config }; ($e = window.UserLeap._config) != null && $e.startingQuestionIdx && (window.UserLeap._config = { ...window.UserLeap._config, startingQuestionIdx: null }); const At = (c ? window.UserLeap.feedbackCustomStyles : window.UserLeap.customStyles) ?? h.customStyles; J.customStyles = At, R && (R.__cfg = J); const Le = window.UserLeap.viewSDKURL ? window.UserLeap.viewSDKURL : J.path, He = document.getElementById(Xe); He && He.remove(); const Ue = function() { const U = document.createElement("script"); return window.UserLeap.isMobileSDK || U.setAttribute("type", "module"), window.UserLeap.nonce && U.setAttribute("nonce", window.UserLeap.nonce), U.id = Xe, U; }(), Ve = () => { window.UserLeap.container && Object.assign(window.UserLeap.container.style, { display: "flex" }); }; if (J.installationMethod === "web-npm" || J.installationMethod === "web-npm-bundled") { const { default: U } = await import("./view-CDrJuRMn.js").then((N) => N.C); U.configure(J), ne && window.UserLeap.container && Ve(); } else Le && (Ue.src = `${Le}${window.UserLeap.isMobileSDK ? "" : `?t=${Date.now()}`}`, ne && Ue.addEventListener("load", () => { window.UserLeap.container && Ve(); }), R == null || R.addEventListener("error", (U) => { U.target instanceof HTMLScriptElement && U.target.src === Le && window.UserLeap.reportError("loadFrameScript", new Error("Frame script failed to load")); }, { capture: !0, once: !0 })); X == null || X.appendChild(Ue); const We = { success: !0, surveyState: "ready", surveyId: y, responseGroupUid: v }; return window.UserLeap.isMobileSDK && t && (We.delay = t), We; }; function we(r) { var i; if (window.UserLeap.useMobileStyling !== void 0) return window.UserLeap.useMobileStyling; const e = ((i = window.UserLeap.windowDimensions) == null ? void 0 : i.width) ?? document.body.clientWidth; return oe(r) || e > 10 && e < 500; } function oe(r) { return Vt.has(r["userleap-platform"]); } const Ze = /* @__PURE__ */ new WeakMap(), Wt = (r, e) => { try { return ((a) => { var n, o; const t = Ze.get(a); if (t) return t; if (!((n = a.trustedTypes) != null && n.createPolicy)) throw new Error("Trusted types not supported"); const s = (o = a.trustedTypes) == null ? void 0 : o.createPolicy("sprig-sdk", { createHTML: (l) => l, createScript: (l) => l, createScriptURL: (l) => l }); return Ze.set(a, s), s; })(e).createHTML(r); } catch (i) { return console.warn("Could not create TrustedHTML object", i), r; } }, Pe = (r, e, i = window) => { var a; return e && ((a = i.trustedTypes) != null && a.createPolicy) ? Wt(r, i) : r; }, Me = "ul-frame"; globalThis.UserLeap && globalThis.Sprig && (globalThis.Sprig._gtm ? globalThis.Sprig = globalThis.UserLeap : globalThis.UserLeap = globalThis.Sprig), globalThis.UserLeap || (globalThis.UserLeap = globalThis.Sprig), globalThis.Sprig || (globalThis.Sprig = globalThis.UserLeap); const Ie = "0px", ht = (r, e, i) => { globalThis.UserLeap.container = document.createElement("div"), globalThis.UserLeap.container.className = "ul-container" + (e ? " ul-container-feedback" : ""), r && (globalThis.UserLeap.container.dataset.studyId = r.toString()); const a = ft(); i && a && !globalThis.UserLeap.useMobileStyling ? a.appendChild(globalThis.UserLeap.container) : document.body.appendChild(globalThis.UserLeap.container); }, yt = (r, e) => { var a; $t(); const i = globalThis.UserLeap.container; if (i) try { (a = i.parentNode) == null || a.removeChild(i), globalThis.UserLeap.container = null, _("trackStartUrl", null), g.emit(u.SurveyLifeCycle, { state: "dismissed" }), g.emit(u.SurveyClosed, { name: u.SurveyClosed, initiator: r, "survey.id": parseInt(i.dataset.studyId), ...e && { studyType: e } }); } catch (t) { console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${r} ` + i), t instanceof Error && globalThis.UserLeap.reportError("dismissActiveSurvey", t); } }, bt = () => { g.once(u.SurveyWillClose, ({ initiator: r, studyType: e }) => { g.removeAllListeners(u.CloseSurveyOnOverlayClick), yt(r, e); }); }, Nt = (r, e, i, a) => { var d, p; const t = { position: "fixed", bottom: "0px", right: Ie, 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%" }, s = Object.assign({}, e, globalThis.UserLeap), { desktopDisplay: n } = e || {}, o = n === "center-modal"; let l; o && (s.framePosition = "center"); let c = !1; if (i) (d = globalThis.UserLeap.windowDimensions) != null && d.width ? t.width = `${globalThis.UserLeap.windowDimensions.width}px` : t.width = "100%", (p = globalThis.UserLeap.windowDimensions) != null && p.height ? t.maxHeight = globalThis.UserLeap.windowDimensions.height - 20 + "px" : globalThis.UserLeap.maxHeight ? t.maxHeight = globalThis.UserLeap.maxHeight : t.maxHeight = document.body.clientHeight - 20 + "px", ["light", "dark"].includes(s.overlayStyleMobile) && (c = !0); else { t.width = "360px", t.maxHeight = globalThis.UserLeap.maxHeight || "66vh"; const m = () => { c = !0, l = { margin: "auto", position: "static" }; }; if (a) o ? m() : l = { position: "relative", height: "300px" }; else switch (s.framePosition) { case "bottomLeft": l = { left: Ie }; break; case "topLeft": l = { left: Ie, top: 0 }; break; case "topRight": l = { top: 0 }; break; case "center": m(); } } return c && ((m, f) => { const h = { position: "fixed", overflow: "auto", top: "0px", left: "0px", display: "none", height: "100%", width: "100%", transition: "background-color 0.3s ease-out", zIndex: 2147483646 }, b = f ? m.overlayStyleMobile : m.overlayStyle; h["background-color"] = b === "light" ? "rgba(255,255,255, 0.95)" : "rgba(0,0,0,0.9)", f || (h.margin = "auto"), globalThis.UserLeap.container && Object.assign(globalThis.UserLeap.container.style, h); })(s, i), Object.assign(r.style, t, l), c; }, zt = ({ productConfig: r, useMobileStyling: e, surveyId: i, isFeedback: a, enableCspTrustedTypes: t }) => { var f, h; const s = Me, n = a && r.desktopDisplay === "slider"; ht(i, a, n), Bt(); const o = document.createElement("iframe"); o.id = s, o.setAttribute("title", "Sprig User Feedback Dialog"); const l = Nt(o, r, e, a); bt(); let c = !1; o.setHeight = (b) => { parseInt(o.style.height) == b && c || (c = !0, o.style.height = `${b}px`, g.emit(u.SurveyHeight, { name: u.SurveyHeight, contentFrameHeight: b, "survey.id": i })); }; let d = !1; o.setWidth = (b) => { parseInt(o.style.width) == b && d || (d = !0, o.style.width = `${b}px`, g.emit(u.SurveyWidth, { name: u.SurveyWidth, contentFrameWidth: b, "survey.id": i })); }, (f = globalThis.UserLeap.container) == null || f.appendChild(o), r && (e ? r.exitOnOverlayClickMobile : r.exitOnOverlayClick) && globalThis.UserLeap.container && (globalThis.UserLeap.container.onclick = () => { g.emit(u.CloseSurveyOnOverlayClick); }), g.emit(u.SurveyLifeCycle, { state: "presented" }), g.emit(u.SurveyPresented, { name: u.SurveyPresented, "survey.id": i }); const p = (h = o.contentWindow) == null ? void 0 : h.document; if (p && (p.open("text/html", "replace"), p.write(Pe("<!doctype html><head></head><body></body></html>", t, o.contentWindow)), p.close(), !e)) { const b = p.body; b.style.display = "flex", b.style.alignItems = "center"; } const m = p == null ? void 0 : p.head; return { frameId: s, contentWinDocHead: m, contentWindow: o.contentWindow, hasOverlay: l, iframe: o }; }, mt = { [u.SurveyFadingOut]: () => { globalThis.UserLeap.container && Object.assign(globalThis.UserLeap.container.style, { "background-color": "rgba(0,0,0,0)" }); } }, Bt = () => { Object.entries(mt).forEach(([r, e]) => { g.on(r, e); }); }, $t = () => { Object.entries(mt).forEach(([r, e]) => { g.off(r, e); }); }, j = (r) => !!r && r.nodeType === Node.ELEMENT_NODE, et = (r) => r instanceof HTMLElement || r instanceof SVGElement, pe = ({ document: r, elementId: e, styleString: i, nonce: a }) => { const t = r.getElementById(e); if (t) return void (t.textContent = i); const s = r.createElement("style"); a && (s.nonce = a), s.textContent = i, s.id = e, r.head.appendChild(s); }, tt = (r, e) => { const i = e.querySelector(r); if (!j(i)) return 0; const a = getComputedStyle(i); return parseFloat(a.paddingLeft) + parseFloat(a.paddingRight) + (parseFloat(a.marginLeft) + parseFloat(a.marginRight)) + (parseFloat(a.borderLeftWidth) + parseFloat(a.borderRightWidth)); }, Gt = (r, e, i) => { const a = r.querySelector(".ul-card__container"), t = r.querySelector(".ul-app"); let s = 600, n = 360; if (j(a) && j(t)) { const o = a.querySelector(".ul-card--matrix_grid"), l = !o && e && i; try { l && (t.style.width = "360px"), s = a.scrollHeight, s += ((p) => { const m = p.querySelector(".sprig-question-body"), f = p.querySelector(".ul-card"), h = p.querySelector(".ul-card-main-content"), b = p.querySelector(".ul-footer"), v = p.querySelector(".sprig-container"); let y = 0; return j(f) && (y += f.scrollHeight - f.clientHeight), j(h) && (y += h.scrollHeight - h.clientHeight), j(m) && (y += m.scrollHeight - m.clientHeight), j(b) && j(v) && v.clientHeight === 0 && (y += b.clientHeight), y; })(r); const c = getComputedStyle(a), d = parseFloat(c.marginTop) + parseFloat(c.marginBottom); s += d + (parseFloat(c.borderTopWidth) + parseFloat(c.borderBottomWidth)), o && (n = o.scrollWidth, n += tt(".ul-card__container", r), n += tt(".sprig-question-body", r)); } finally { l && t.style.removeProperty("width"); } } return [s + 2, n]; }, fr = (r) => { const e = r.querySelector(".ul-card__container"); e && (e.scrollTop = 0); }, ft = () => w, Y = () => document.getElementById("sprig-feedback-container"), Re = () => document.getElementById("sprig-feedback-loading-animation"), vt = () => !!document.getElementById(Me); let rt = !1, w = null, A = null, je = !1, re = null, B = null; const Kt = ["bottom-left", "bottom-right", "center-left", "center-right"], ue = () => { var e; const r = window.UserLeap.container; return ((e = r == null ? void 0 : r.parentElement) == null ? void 0 : e.id) === "sprig-feedback-loading-container"; }, wt = () => document.getElementById("sprig-feedback-error-container"), Lt = () => { if (!w) return 0; const r = w == null ? void 0 : w.clientWidth, e = window.getComputedStyle(w); return r + parseInt(e.borderRightWidth || "0") + parseInt(e.borderLeftWidth || "0"); }, ge = (r) => { const e = Y(); e && (B != null && B.endsWith("right") ? e.style.right = `${r}px` : B != null && B.endsWith("left") && (e.style.left = `${r}px`)); }, ke = () => { if (w && (ue() || wt())) { g.off(u.SurveyAppeared, ee), xe(); const r = Lt(); return ge(-r), !0; } return !1; }, ee = () => { if (!w || !A) return; const r = Re(); r && r.remove(), w.style.height = "auto", w.style.width = "auto", A.disabled = !1, je = !1; }, xe = () => { if (w && !Re()) { const r = (() => { var i; if (Re()) return; const e = document.createElement("div"); return e.className = "ul-loading-spinner-container", e.id = "sprig-feedback-loading-animation", e.role = "progressbar", e.setAttribute("aria-live", "polite"), e.setAttribute("aria-busy", "true"), e.setAttribute("aria-label", "Processing..."), e.innerHTML = Pe(` <div class="ul-loading-spinner"> <div class="first"></div> <div class="second"></div> <div class="third"></div> <div class="fourth"></div> </div> `, (i = window.UserLeap._config) == null ? void 0 : i.enableCspTrustedTypes), e; })(); r && (w.style.height = "300px", w.style.width = "360px", w.appendChild(r)); } }, it = () => { w && A && (ge(0), A.disabled = !0, je = !0); }, Ut = async (r, e, i) => { const { buttonTheme: a, customStyles: t, eventId: s, placement: n, desktopDisplay: o, feedbackLabel: l, surveyUuid: c, surveyId: d } = r; window.UserLeap.feedbackCustomStyles = void 0; let p = Y(); if (p) { if (!e && s === re) return; p.remove(), g.off(ae.SURVEY_FADING_OUT, ke); } re = s, pe({ 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 }), pe({ document, elementId: "ul-custom-style", styleString: t ?? "", nonce: window.UserLeap.styleNonce }), rt = o === "center-modal", B = n; const [m, f] = n.split("-"); ((y) => { if (Y() || !Kt.includes(y)) return; const [I, L] = y.split("-"), k = document.createElement("div"); k.id = "sprig-feedback-container", k.classList.add(`sprig-feedback-container-${L}`, `sprig-feedback-container-${I}`), document.body.appendChild(k); })(n), p = Y(), A = document.createElement("button"); const h = document.createElement("div"); h.className = "sprig-feedback-button-label", h.innerText = l, A.appendChild(h), A.id = "sprig-feedback-button", A.classList.add(`sprig-feedback-button-${f}`, `sprig-feedback-button-${m}`, `sprig-feedback-button-${a}`, "fade-in-transition"), g.on(ae.SURVEY_FADING_OUT, ke), A.addEventListener("click", async () => { const y = document.getElementById("sprig-feedback-error-container"); if (vt() || wt()) { if (ke()) { g.emit(u.SurveyCloseRequested, { name: u.SurveyCloseRequested, initiator: C.FeedbackClosed, studyType: "feedbackButton", "survey.id": d }), g.emit(u.SurveyWillClose, { name: u.SurveyWillClose, initiator: C.FeedbackClosed, studyType: "feedbackButton", "survey.id": d }); const L = Y(); y && L && (L.remove(), re = null, w = null); } return; } if (we(O(window.UserLeap)) || je || it(), e) return w && w.classList.add("sprig-feedback-loading-container-previews"), await te(e), void ee(); const I = await (async (L) => { const k = await D(x("1", [F], "startFeedbackStudy"), { body: JSON.stringify({ surveyUuid: L }), method: "POST" }); return k.ok ? k.json : null; })(c); if (I) g.once(u.SurveyAppeared, ee), te({ ...I, studyType: "feedbackButton" }, i); else if (w) { const L = Jt(); w.appendChild(L), ee(), w.style.height = "300px", w.style.width = "360px"; } }), p == null || p.appendChild(A), g.emit(u.FeedbackButtonLoaded, { name: u.FeedbackButtonLoaded, "survey.id": d }); const { useMobileStyling: b, _config: { border: v } } = window.UserLeap; if (rt || b) ge(0); else { const y = document.createElement("div"); y.id = "sprig-feedback-loading-container", y.className = `sprig-feedback-loading-container sprig-feedback-loading-container-${f}`, y.style.setProperty("--feedback-border", v), w = y, xe(), p == null || p.appendChild(y); const I = Lt(); ge(-I); } window.UserLeap._config.isOnQuestionsTab && e && !ue() && w && (it(), xe(), w && w.classList.add("sprig-feedback-loading-container-previews"), te(e), ee()); }, Jt = () => { var i; const r = document.createElement("div"); r.id = "sprig-feedback-error-container", r.innerHTML = Pe(`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none"> <circle cx="20" cy="20" r="14.5" stroke="#B0B5B7" stroke-width="3"/> <path d="M20 12L20 21.6" stroke="#B0B5B7" stroke-width="3" stroke-linecap="round"/> <circle cx="19.9984" cy="27.6" r="1.6" fill="#B0B5B7"/> </svg>`, (i = window.UserLeap._config) == null ? void 0 : i.enableCspTrustedTypes); const e = document.createElement("h3"); return e.className = "sprig-feedback-error-text", e.innerText = "There was an error while loading the survey", r.appendChild(e), r; }, De = new class { constructor() { z(this, "_ldData", {}); } getAllLaunchDarklyVariations() { return this._ldData; } setLDFlagsVariations(r) { try { return !(!r || typeof r != "object" || Array.isArray(r)) && (Object.keys(this._ldData).forEach((e) => { delete this._ldData[e]; }), Object.keys(r).forEach((e) => this._ldData[`!launch_darkly_${e}`] = (r[e] ?? 0) + 1), !0); } catch (e) { return e instanceof Error && window.UserLeap.reportError("setAllLDFlagsVariations", e), console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."), !1; } } }(); Object.freeze(De); const ce = new class { constructor() { z(this, "_optimizelyData", {}); } setOptimizelyExperiment(r, e = !0) { if (!r || typeof r != "object") return !1; const { experiments: i } = r; try { return e && Object.keys(this._optimizelyData).map((a) => { delete this._optimizelyData[a]; }), i && i.map((a) => { const { id: t, variation: s } = a, n = this.transformExperimentId(t); s && typeof s == "string" && (this._optimizelyData[n] = s); }), !0; } catch (a) { return a instanceof Error && window.UserLeap.reportError("setOptimizelyExperiment", a), !1; } } getAllOptimizelyExperiments() { return this._optimizelyData; } getOptimizelyVariationName(r) { return this._optimizelyData[this.transformExperimentId(r)]; } transformExperimentId(r) { return "!optimizely_experiments_" + r; } getAndSetWebOptimizelyExperiments() { var r; try { if (window && window.optimizely && typeof window.optimizely.get == "function") { const e = (r = window.optimizely.get("state")) == null ? void 0 : r.getExperimentStates({ isActive: !0 }); if (e) { const i = Object.keys(e).map((a) => { var t, s; return (t = e[a].variation) != null && t.name ? { id: a, variation: (s = e[a].variation) == null ? void 0 : s.name } : { id: a, variation: "Original" }; }); return this.setOptimizelyExperiment({ experiments: i }, !1), !0; } return !1; } return !1; } catch (e) { return e instanceof Error && window.UserLeap.reportError("getAndSetWebOptimizely", e), !1; } } }(); Object.freeze(ce); class Qt { constructor(e, i) { z(this, "paused"); z(this, "queue"); z(this, "ul"); this.ul = e, this.paused = !1, this.queue = [], this.flush(i); } flush(e) { const i = e.length; if (i) for (let a = 0; a < i; a++) this.push(e[a]); } isPaused() { return this.paused; } pause() { this.paused = !0; } unpause() { this.paused = !1; const e = this.queue.slice(); this.empty(), this.flush(e); } push(e) { if (this.paused) this.queue.push(e); else if (e instanceof Function) e(); else { const i = Array.prototype.slice.call(e, 1), a = e[0], t = this.ul[a]; t instanceof Function ? t.apply(this.ul, i) : a && console.warn("[Sprig] (ERR-100) No valid UserLeap action called", a); } } perform(e) { if (this.paused) { let i = () => { }; const a = new Promise(function(t) { i = function() { t(e()); }; }); return this.queue.push(i), a; } return e(); } empty() { this.queue.length = 0; } } let St, Tt; const Ae = (r) => { let e = 0, i = r.firstElementChild; for (; i; ) e += Ae(i), i.shadowRoot && (e += Ae(i.shadowRoot)), i = i.nextElementSibling, e++; return e; }, st = () => { St.report(Ae(document.body)), Tt.report(document.documentElement.innerHTML.toString().length); }, Oe = (r, e) => { const i = performance.now(); document.hidden ? setTimeout(() => Oe(r, e), r) : setTimeout(() => { const a = performance.now() - i; e.report(a / 1e3), setTimeout(() => Oe(r, e), r); }, 0); }; let he, ye, be, me, at, $ = {}; const de = (r, e = 1) => { const { name: i } = r; $[i] = ($[i] || 0) + e; }, It = (r) => { let e = 1; return r.childNodes.forEach((i) => { e += It(i); }), e; }, ot = (r) => { let e = 0; return r.forEach((i) => { e += It(i); }), e; }, Yt = (r) => { switch (r.type) { case "childList": return de(he, ot(r.addedNodes)), void de(ye, ot(r.removedNodes)); case "attributes": return void de(be); case "characterData": return void de(me); } }, Xt = (r) => r.forEach(Yt), Zt = () => { he.report($[he.name] || 0), ye.report($[ye.name] || 0), be.report($[be.name] || 0), me.report($[me.name] || 0), $ = {}; }, er = (r = 1e3) => { he = G("sdk_mutations_nodes_added"), ye = G("sdk_mutations_nodes_removed"), be = G("sdk_mutations_attributes_changed"), me = G("sdk_mutations_character_data"), at = new MutationObserver(Xt), at.observe(document, { attributes: !0, attributeOldValue: !0, characterData: !0, characterDataOldValue: !0, childList: !0, subtree: !0 }), setInterval(Zt, r); }, tr = ({ isWeb: r, reportingIntervalSeconds: e, thresholds: i, postMetrics: a }) => { Mt(i, (t, s) => { var n, o; if ((n = S.replay) != null && n.isReplayRecording()) { const l = `Value: ${t} on ${s.metric} violated threshold of ${s.type} ${s.value}`; (o = S.replay) == null || o.disableRecording("Threshold violated", new Error(l), { reportError: !1 }), window.UserLeap.reportError("Sdk Performance Metric threshold violated", new Error("Sdk Performance Metric threshold violated"), { metricName: s.metric, type: s.type, value: s.value }, { metricName: s.metric }), Ft(); } }), jt({ reportingIntervalSeconds: e, postMetrics: a }), r && (((t = 1e3) => { const s = G("sdk_event_queue_latency_seconds"); Oe(t, s); })(), ((t = 1e4) => { St = G("sdk_dom_nodes_count"), Tt = G("sdk_page_html_characters"), st(), setInterval(st, t); })(), er()); }, rr = "test", ir = ["popState", "pushState", "replaceState"]; let Fe, ie; const fe = {}, Z = "!email", kt = "pageUrl"; var lt; let Ee = ((lt = globalThis.location) == null ? void 0 : lt.href) || ""; function se(r) { var o, l; const { pageUrlEvents: e, interactiveEvents: i, dismissOnPageChange: a, platform: t } = globalThis.UserLeap._config; if (t && t !== "web") return; Ee !== globalThis.location.href && P.navigation("LocationChange", { from: Ee, to: globalThis.location.href }), Ee = globalThis.location.href; const s = Rt().trackStartUrl, n = s ? String(s) : null; e && Dt(globalThis.location.href), i && (_t(), sr()), ft() && (() => { if (ue()) return; const c = Y(); c && (Pt(re) || (c.remove(), re = null, w = null)); })(), Q.getItem("sprig.isCapturingHeatmap") && ((l = (o = S.replay) == null ? void 0 : o.checkPendingHeatmapsUrl()) == null || l.then((c) => { var d; c && ((d = S.replay) == null || d.uploadReadyPendingCaptures(!0)); })), !ue() && a && n && n !== globalThis.location.href && r && ir.includes(r.type) && globalThis.UserLeap("dismissActiveSurvey", C.PageChange); } const Et = { capture: !0 }, sr = () => { const r = globalThis.UserLeap._config.interactiveEvents.filter((i) => ut(i, globalThis.location.href)).map((i) => { const { name: a, properties: t } = i, { selector: s, innerText: n } = t; return s ? (o) => { if (et(o.target)) try { o.target.closest(s) && globalThis.UserLeap("track", a); } catch { } return !1; } : (o) => (et(o.target) && o.target.innerText === n && globalThis.UserLeap("track", a), !1); }), e = (i) => r.forEach((a) => a(i)); globalThis.UserLeap._config.interactiveEventsHandler = e, globalThis.addEventListener("click", e, Et); }, _t = () => { globalThis.UserLeap._config.interactiveEventsHandler && globalThis.removeEventListener("click", globalThis.UserLeap._config.interactiveEventsHandler, Et), delete globalThis.UserLeap._config.interactiveEventsHandler; }; function Rt() { const r = H.getItemObject("userleap.ids"); return (r == null ? void 0 : r[globalThis.UserLeap.envId]) || {}; } function xt() { if (globalThis.previewMode) return; const r = H.getItemObject("sprig.anon.env.vid.map") || {}, e = r[globalThis.UserLeap.envId]; globalThis.UserLeap.visitorId = e || ct(), P.info("NewVid", { vid: globalThis.UserLeap.visitorId }), _("vid", globalThis.UserLeap.visitorId), e || (r[globalThis.UserLeap.envId] = globalThis.UserLeap.visitorId, H.setItemObject("sprig.anon.env.vid.map", r)), g.emit(u.VisitorIDUpdated, { visitorId: globalThis.UserLeap.visitorId }); } function Dt(r, e, i, a) { var t, s; try { if (r.endsWith("mock_snippet.html")) return; P.info("PageView", { url: r }); const n = (t = document == null ? void 0 : document.querySelector('meta[name="description"]')) == null ? void 0 : t.getAttribute("content"); (s = S.replay) == null || s.RecordPageView({ ...n && { description: n }, url: r, referrer: document.referrer, pageTitle: document.title }); const o = globalThis.UserLeap._config.pageUrlEvents; let l = !1; if (o && o.length) for (let d = 0; d < o.length && (l = ut(o[d], r), !l); d++) ; if (!l) return; globalThis.UserLeap.debugMode && console.info("[DEBUG] Sprig trackPageView", r); const c = { url: r }; a && (c.trackPageView = !0), globalThis.UserLeap._queue.push(["track", kt, e, c, i]); } catch (n) { n instanceof Error && (n.stack = r, globalThis.UserLeap.reportError("trackPageView", n)), console.warn("[Sprig] (ERR-428) Failed to track page view", n); } } function ar() { var e; const r = ((e = globalThis.Backbone) == null ? void 0 : e.history) || globalThis.history; "pushState" in r && (r.pushState = /* @__PURE__ */ ((i) => function(...a) { const t = i.apply(this, a), s = new Event("pushState"); return globalThis.dispatchEvent(s), se(s), t; })(r.pushState)), "replaceState" in r && (r.replaceState = /* @__PURE__ */ ((i) => function(...a) { const t = i.apply(this, a), s = new Event("replaceState"); return globalThis.dispatchEvent(s), se(s), t; })(r.replaceState)), ["hashchange", "popstate"].forEach((i) => globalThis.addEventListener(i, se, !0)); } async function _e(r, e) { const i = Ce(); r && !e && (globalThis.UserLeap._config.mode = rr); const a = we(O(globalThis.UserLeap)), t = await D(function(s) { const n = new URL(x("1", [q], "questions")); return Object.entries(s || {}).forEach(([o, l]) => { l && n.searchParams.append(o, String(l)); }), n.toString(); }({ desktopDisplay: globalThis.UserLeap._config.desktopDisplay, isMobile: a, previewLanguage: globalThis.UserLeap._config.previewLanguage, surveyid: r == null ? void 0 : r.surveyId, surveytemplateid: r == null ? void 0 : r.surveyTemplateId, vid: i }), { shouldDropOnRateLimit: !0 }); if (!t.ok) return t.reportError && t.error && (console.warn("[Sprig] (ERR-414) Failed to request questions from the server", t.error), globalThis.UserLeap.reportError("getQuestions", t.error)), { success: !1, surveyState: "no survey" }; if (t.json.delay && await gt(t.json.delay), !t.json.isFeedback) return te(t.json, ie, Fe); { const { feedbackLabel: s, productConfig: n, surveyUuid: o, feedbackCustomStyles: l } = t.json, { buttonTheme: c, placement: d, desktopDisplay: p } = n; Ut({ customStyles: l, buttonTheme: c, desktopDisplay: p, eventId: 0, feedbackLabel: s, placement: d, surveyUuid: o, surveyId: r == null ? void 0 : r.surveyId }, t.json); } } function or(r) { if (!r) return; globalThis.UserLeap._config = r, r.mute && globalThis.UserLeap._queue.pause(); const { interactiveEvents: e, pageUrlEvents: i, dismissOnPageChange: a } = r; e && function(t) { let s = t.length; for (; s; ) { const n = Math.floor(Math.random() * s); s -= 1; const o = t[s]; t[s] = t[n], t[n] = o; } }(e), (e || i || a) && (ar(), se()); } const nr = function(r) { if (!globalThis.UserLeap) return; const e = async (t = {}) => { var y, I, L, k, V; const { userId: s, anonymousId: n, metadata: o = {}, properties: l, showSurveyCallback: c } = t; let { eventName: d } = t; if (globalThis.UserLeap.debugMode && d !== kt && console.info("[DEBUG] Sprig track", t), r.mode === "test") return; const p = Q.getItem("sprig.previewKey") ?? void 0; if (r.requireUserIdForTracking && !globalThis.UserLeap.userId && !s) { const T = "[Sprig] - Skipping tracking without userId"; return console.warn(T), { success: !1, message: T, surveyState: "no survey" }; } if (!d || d.trim().length === 0) { d = d ? String(d) : ""; const T = "[Sprig] - Invalid event name " + d; return console.warn(T), { success: !1, message: T, surveyState: "no survey" }; } const m = ie ?? globalThis.location.href; o.url || (o.url = m), _("trackStartUrl", m), (I = (y = globalThis.UserLeap) == null ? void 0 : y._config) != null && I.optimizelyEnabled && (oe(O(globalThis.UserLeap)) || ce.getAndSetWebOptimizelyExperiments(), o.optimizelyExperiments = Object.assign({}, ce.getAllOptimizelyExperiments())), (k = (L = globalThis.UserLeap) == null ? void 0 : L._config) != null && k.launchDarklyEnabled && (o.launchDarklyFlags = De.getAllLaunchDarklyVariations()), s && (globalThis.UserLeap.userId = s), n && (globalThis.UserLeap.partnerAnonymousId = n), l && (o.eventProperties = l), (V = S.replay) == null || V.RecordEvent({ name: d, url: o.url }), P.info("TrackEvent", { eventName: d }); const f = globalThis.UserLeap.delayingSurvey || vt() ? await D(x("1", [F], "events/batch"), { body: JSON.stringify({ events: [{ event: d, metadata: o }], previewKey: p }), method: "POST", shouldDropOnRateLimit: !0 }) : await D(x("1", [F], "events"), { body: JSON.stringify({ event: d, metadata: o, previewKey: p }), method: "POST", shouldDropOnRateLimit: !0 }); if (!f.ok) { const T = "[Sprig] (ERR-421) Failed to track event"; return f.reportError && (console.warn(T, f.error), f.error && globalThis.UserLeap.reportError("track", f.error)), { success: !1, message: T, error: f.error, surveyState: "no survey" }; } s && _("uid", s), n && _("aid", n); const h = f.json; h.invalidPreviewKey && Q.removeItem("sprig.previewKey"); const b = o.trackPageView ? o.url : void 0; return h != null && h.feedbackButton && Ut(h.feedbackButton, void 0, b), await async function(T, E) { var K, W; let M = !0; return !(E && ((K = T == null ? void 0 : T.json) != null && K.surveyId) && (globalThis.UserLeap.delayingSurvey = !0, M = await E(T.json.surveyId), globalThis.UserLeap.delayingSurvey = !1, !M)) && ((W = T == null ? void 0 : T.json) != null && W.delay && !globalThis.UserLeap.isMobileSDK && (globalThis.UserLeap.delayingSurvey = !0, await gt(T.json.delay), globalThis.UserLeap.delayingSurvey = !1), M); }(f, c) ? function(T) { if (!globalThis.UserLeap._config.dismissOnPageChange) return !0; const E = new URL(T), M = new URL(ie ?? globalThis.location.href); return E.hostname === M.hostname && E.pathname === M.pathname; }(m) ? te(h, b, Fe) : { 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" }; }, i = (t, s) => { var o; const n = (o = t == null ? void 0 : t.querySelector(`[id="${Me}"]`)) == null ? void 0 : o.contentDocument; n && pe({ document: n, elementId: "ul-custom-style", styleString: s }); }, a = { displaySurvey: async (t) => (console.warn("[Sprig] displaySurvey should only be used to debug your studies; not intended for production usage."), globalThis.UserLeap("dismissActiveSurvey", C.Override), _e({ surveyId: t }, !0)), _previewSurvey(t) { globalThis.UserLeap("dismissActiveSurvey", C.Override), _e({ surveyTemplateId: t }, !1); }, _reviewSurvey(t) { globalThis.UserLeap("dismissActiveSurvey", C.Override), _e({ surveyId: t }, !1); }, previewSurvey(t) { a._previewSurvey(t); }, reviewSurvey(t) { a._reviewSurvey(t); }, mute() { globalThis.UserLeap._queue.pause(); }, unmute() { globalThis.UserLeap._queue.unpause(); }, setVisitorToken() { console.warn("[Sprig] setVisitorToken is deprecated."); }, dismissActiveSurvey(t = C.API) { globalThis.UserLeap.container && (t === C.Closed && globalThis.Sprig.trackHistory && globalThis.Sprig.trackHistory({ event: "closed" }), g.emit(u.SurveyCloseRequested, { name: u.SurveyCloseRequested, initiator: t, "survey.id": parseInt(globalThis.UserLeap.container.dataset.studyId) }), g.emit(u.SurveyWillClose, { name: u.SurveyWillClose, initiator: t, "survey.id": parseInt(globalThis.UserLeap.container.dataset.studyId) })); }, async setAttribute(t, s) { if (!t || !s && s !== 0 && s !== !1) { const n = "[Sprig] - Disregarding empty attribute / value provided"; return console.warn(n), { success: !1, message: n }; } return this.setAttributes({ [t]: s }); }, async setAttributes(t) { if (t == null || Object.keys(t).length === 0) { const s = "[Sprig] - Disregarding empty attributes provided"; return console.warn(s), { success: !1, message: s }; } return this.identifyAndSetAttributes({ attributes: t }); }, async identifyAndSetAttributes(t) { if (globalThis.UserLeap.debugMode && console.info("[DEBUG] Sprig identifyAndSetAttributes", t), r.mode === "test") return; if (t === null || typeof t != "object" || !(t.userId || t.anonymousId || t.attributes)) { const d = "[Sprig] - Disregarding empty payload provided"; return console.warn(d), { success: !1, message: d }; } const { userId: s, anonymousId: n, attributes: o } = t; if (r.requireUserIdForTracking && !globalThis.UserLeap.userId && !s) { const d = "[Sprig] - Skipping tracking without userId"; return console.warn(d), { success: !1, message: d }; } if (o) { o.email && !o[Z] && (o[Z] = o.email, delete o.email); const d = Object.keys(o); for (const p of d) o[p] === fe[p] && delete o[p]; } if (!(o && Object.keys(o).length !== 0 || s && globalThis.UserLeap.userId !== s || n && globalThis.UserLeap.partnerAnonymousId !== n)) return { success: !0 }; const l = {}; let c; return s && (l.userId = globalThis.UserLeap.userId = s), n && (l.partnerAnonymousId = globalThis.UserLeap.partnerAnonymousId = n), o && Object.keys(o).length > 0 ? (c = await D(x("1", [q, F], "attributes"), { body: JSON.stringify(o), method: "PUT" }), c.ok ? Object.assign(fe, o) : c.reportError && (console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed", c.error), c.error && globalThis.UserLeap.reportError("identifyAndSetAttributes", c.error))) : c = await D(x("1", [q, F]), { body: JSON.stringify(l), method: "PUT" }), o && o[Z] && (globalThis.UserLeap.email = o[Z]), c.ok && (s && _("uid", s), n && _("aid", n)), { success: !!c.ok }; }, async removeAttributes(t) { if (globalThis.UserLeap.debugMode && console.info("[DEBUG] Sprig removeAttributes", t), r.mode === "test") return; if (t == null || t.length === 0) { const n = "[Sprig] - Disregarding empty attributes provided"; return console.warn(n), { success: !1, message: n }; } if (r.requireUserIdForTracking && !globalThis.UserLeap.userId) { const n = "[Sprig] - Skipping tracking without userId"; return console.warn(n), { success: !1, message: n }; } const s = await D(x("1", [q, F], "attributes"), { body: JSON.stringify({ delete: t }), method: "DELETE" }); return !s.ok && s.reportError && (console.warn("[Sprig] (ERR-433) Remove attributes failed", s.error), s.error && globalThis.UserLeap.reportError("removeAttributes", s.error)), { success: !!s.ok }; }, async addSurveyListener(t) { g.on(u.SurveyLifeCycle, t); }, async removeSurveyListener(t) { g.removeListener(u.SurveyLifeCycle, t); }, async addListener(t, s) { g.on(t, s); }, async removeListener(t, s) { g.removeListener(t, s); }, async removeAllListeners() { g.removeAllListeners(); }, setPreviewKey(t) { t && typeof t == "string" && Q.isStorageAvailable && t && Q.setItem("sprig.previewKey", t); }, async setUserId(t) { var o; if (globalThis.UserLeap.debugMode && console.info("[DEBUG] Sprig setUserId", t), t == null) { const l = `[Sprig] - Invalid userId ${t}`; return console.warn(l), { success: !1, message: l }; } if (r.mode === "test" || t === globalThis.UserLeap.userId) return; globalThis.UserLeap.userId = t; const s = globalThis.UserLeap.visitorId, n = await D(x("1", [q, F]), { body: JSON.stringify({ userId: t }), method: "PUT" }); n.ok ? (s !== globalThis.UserLeap.visitorId && ((o = S.replay) == null || o.clearUserReplayData()), _("uid", t)) : n.reportError && (console.warn("[Sprig] (ERR-420) Failed to set user id", n.error), n.error && globalThis.UserLeap.reportError("setUserId", n.error)); }, async setPartnerAnonymousId(t) { if (globalThis.UserLeap.debugMode && console.info("[DEBUG] Sprig setPartnerAnonymousId", t), t == null) { const s = `[Sprig] - Invalid partnerAnonymousId ${t}`; return console.warn(s), { success: !1, message: s }; } return globalThis.UserLeap.partnerAnonymousId = t, _("aid", t), { success: !0 }; }, track: async (t, s, n = {}, o = void 0) => e({ eventName: t, properties: s, metadata: n, showSurveyCallback: o }), identifyAndTrack: async (t) => await e(t), trackPageView(t, s = void 0, n = void 0, o = !0) { ie = t, Dt(t, s, n, o); }, applyFeedbackStyles({ button: t = "", view: s = "" }) { globalThis.UserLeap.feedbackCustomStyles = s, document.getElementById("sprig-feedback-style") && pe({ document, elementId: "ul-custom-style", styleString: t, nonce: globalThis.UserLeap.styleNonce }), i(document.querySelector(".ul-container-feedback"), s); }, applyStyles(t) { globalThis.UserLeap.customStyles = t, i(globalThis.UserLeap.container, t); }, setWindowDimensions(t, s) { var m, f; const n = typeof t == "string" ? parseInt(t, 10) : t, o = typeof s == "string" ? parseInt(s, 10) : s; isNaN(n) || isNaN(o) || (globalThis.UserLeap.windowDimensions = { width: n, height: o }); const l = O(globalThis.UserLeap), c = we(l), d = l["userleap-platform"] === "web"; if (!globalThis.UserLeap.frameId) return; const p = document.getElementById(globalThis.UserLeap.frameId); p && (globalThis.UserLeap.useMobileStyling && ((m = globalThis.UserLeap.windowDimensions) != null && m.width && (p.style.width = `${globalThis.UserLeap.windowDimensions.width}px`), (f = globalThis.UserLeap.windowDimensions) != null && f.height && (p.style.maxHeight = globalThis.UserLeap.windowDimensions.height - 20 + "px"), p.contentDocument && (p.style.height = String(Gt(p.contentDocument, d && !c, pt(l))[0]) + "px")), g.emit(u.SurveyDimensions, { name: u.SurveyDimensions, contentFrameWidth: p.clientWidth, contentFrameHeight: p.clientHeight, "survey.id": parseInt(globalThis.UserLeap.container.dataset.studyId) })); }, logoutUser() { var t; globalThis.UserLeap.debugMode && console.info("[DEBUG] Sprig logout"), P.info("LogOut", { vid: globalThis.UserLeap.visitorId, userId: globalThis.UserLeap.userId }), globalThis.UserLeap.visitorId = null, globalThis.UserLeap.userId = null, globalThis.UserLeap.partnerAnonymousId = null, globalThis.UserLeap.token = null, globalThis.UserLeap.email = null, H.removeItem("userleap.ids"), gl