;
! function() {
    try {
        var e = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof global ? global : "undefined" != typeof window ? window : "undefined" != typeof self ? self : {},
            n = (new e.Error).stack;
        n && ((e._debugIds || (e._debugIds = {}))[n] = "96b64554-2322-daa7-77d3-dc5b04cfa6f9")
    } catch (e) {}
}();
(globalThis.TURBOPACK || (globalThis.TURBOPACK = [])).push(["object" == typeof document ? document.currentScript : void 0, 451637, (e, t, i) => {
    e.e, t.exports = (() => {
        "use strict";
        var e = {
                d: (t, i) => {
                    for (var n in i) e.o(i, n) && !e.o(t, n) && Object.defineProperty(t, n, {
                        enumerable: !0,
                        get: i[n]
                    })
                },
                o: (e, t) => Object.prototype.hasOwnProperty.call(e, t)
            },
            t = {};
        e.d(t, {
            default: () => tj
        });
        class i {
            constructor() {
                this.callbacks = {}
            }
            on(e, t) {
                let i = this.callbacks[e];
                i ? i.push(t) : this.callbacks[e] = [t]
            }
            off(e, t) {
                let i = this.callbacks[e];
                if (!i) return;
                if (!t) return void delete this.callbacks[e];
                let n = i.indexOf(t); - 1 !== n && i.splice(n, 1), 0 === i.length && delete this.callbacks[e]
            }
            dispatch(e, t) {
                let i = this.callbacks[e];
                i && i.forEach(e => e(t))
            }
        }

        function n(e) {
            tj.config && tj.config.logging && console.log(`Gist: ${e}`)
        }
        let s = "gist.web.isPersistingSession";

        function o(e, t, i = null) {
            let n = i;
            n || (n = new Date).setDate(n.getDate() + 365);
            let s = {
                value: t,
                expiry: n
            };
            l().setItem(e, JSON.stringify(s))
        }

        function r(e) {
            l().removeItem(e)
        }

        function a() {
            let e = sessionStorage.getItem(s);
            return null === e ? (sessionStorage.setItem(s, "true"), !0) : "true" === e
        }

        function l() {
            return a() ? localStorage : sessionStorage
        }

        function d(e) {
            if (!e) return null;
            try {
                let t = l().getItem(e);
                if (!t) return null;
                let i = JSON.parse(t);
                if (!i.expiry) return i.value;
                if (e.startsWith("gist.")) {
                    let t = new Date,
                        n = new Date(i.expiry),
                        s = e.startsWith("gist.web.message.broadcasts") && !e.endsWith("shouldShow") && !e.endsWith("numberOfTimesShown") || e.startsWith("gist.web.message.user") && !e.endsWith("seen") && !e.endsWith("state"),
                        o = new Date(t.getTime() + 366e4);
                    if (s && n.getTime() > o.getTime() || t.getTime() > n.getTime()) return r(e), null
                }
                return i.value
            } catch (t) {
                n(`Error checking key ${e} for expiry: ${t}`)
            }
            return null
        }
        var c, u = new Uint8Array(16);
        let p = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
        for (var g = [], m = 0; m < 256; ++m) g.push((m + 256).toString(16).substr(1));
        let f = function(e) {
                var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0,
                    i = (g[e[t + 0]] + g[e[t + 1]] + g[e[t + 2]] + g[e[t + 3]] + "-" + g[e[t + 4]] + g[e[t + 5]] + "-" + g[e[t + 6]] + g[e[t + 7]] + "-" + g[e[t + 8]] + g[e[t + 9]] + "-" + g[e[t + 10]] + g[e[t + 11]] + g[e[t + 12]] + g[e[t + 13]] + g[e[t + 14]] + g[e[t + 15]]).toLowerCase();
                if (!("string" == typeof i && p.test(i))) throw TypeError("Stringified UUID is invalid");
                return i
            },
            h = function(e, t, i) {
                var n = (e = e || {}).random || (e.rng || function() {
                    if (!c && !(c = "u" > typeof crypto && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || "u" > typeof msCrypto && "function" == typeof msCrypto.getRandomValues && msCrypto.getRandomValues.bind(msCrypto))) throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
                    return c(u)
                })();
                if (n[6] = 15 & n[6] | 64, n[8] = 63 & n[8] | 128, t) {
                    i = i || 0;
                    for (var s = 0; s < 16; ++s) t[i + s] = n[s];
                    return t
                }
                return f(n)
            },
            v = "gist.web.userQueueUseSSE",
            w = "gist.web.activeSSEConnection",
            y, b = 30,
            x = {
                RENDERER_HOST: {
                    prod: "https://code.gist.build",
                    dev: "https://code.gist.build",
                    local: "http://localhost:9998"
                },
                ENGINE_API_ENDPOINT: {
                    prod: "https://engine.api.gist.build",
                    dev: "https://engine.api.dev.gist.build",
                    local: "http://engine.api.local.gist.build:82"
                },
                GIST_QUEUE_API_ENDPOINT: {
                    prod: "https://consumer.cloud.gist.build",
                    dev: "https://consumer.cloud.dev.gist.build",
                    local: "http://localhost:3010"
                },
                GIST_QUEUE_REALTIME_API_ENDPOINT: {
                    prod: "https://realtime.cloud.gist.build",
                    dev: "https://realtime.cloud.dev.gist.build",
                    local: "http://localhost:3009"
                },
                GIST_VIEW_ENDPOINT: {
                    prod: "https://renderer.gist.build/3.0",
                    dev: "https://renderer.gist.build/3.0",
                    local: "http://localhost:9998"
                },
                getSdkId: () => (y || (y = h()), y),
                useSSE: () => d(v) ? ? !1,
                setUseSSEFlag(e) {
                    o(v, e, new Date((new Date).getTime() + 6e4)), n(`Set user uses SSE to "${e}"`)
                },
                removeActiveSSEConnection() {
                    r(w)
                },
                setActiveSSEConnection() {
                    o(w, x.getSdkId(), new Date((new Date).getTime() + x.getSSEHeartbeat()))
                },
                hasActiveSSEConnection: () => d(w) ? ? !1,
                isSSEConnectionManagedBySDK: () => d(w) === x.getSdkId(),
                getSSEHeartbeat: () => 1e3 * (b + 5),
                setSSEHeartbeat(e) {
                    e && e > 0 && (b = e)
                }
            };

        function I(e) {
            return null !== e && "object" == typeof e && "response" in e
        }

        function S(e) {
            return I(e) ? e.response : void 0
        }

        function C() {
            let e = x.GIST_QUEUE_API_ENDPOINT[tj.config.env ? ? "prod"],
                t = {
                    "X-CIO-Site-Id": tj.config.siteId,
                    "X-CIO-Client-Platform": "web"
                },
                i = R();
            async function n(i, s = {}) {
                let o = new AbortController,
                    r = setTimeout(() => o.abort(), 5e3);
                try {
                    let n = await fetch(e + i, {
                        method: s.method || "GET",
                        headers: { ...t,
                            ...s.headers || {}
                        },
                        body: s.method && "GET" !== s.method.toUpperCase() ? s.body : void 0,
                        signal: o.signal
                    });
                    clearTimeout(r);
                    let l = n.headers.get("content-type") ? .includes("application/json") ? await n.json() : await n.text(),
                        d = Object.fromEntries(n.headers.entries());
                    if (n.status < 200 || n.status >= 400) {
                        var a;
                        throw a = {
                            status: n.status,
                            data: l,
                            headers: d
                        }, Object.assign(Error(), {
                            response: a
                        })
                    }
                    return {
                        status: n.status,
                        headers: d,
                        data: l
                    }
                } catch (e) {
                    if (clearTimeout(r), I(e)) throw e;
                    if (e instanceof Error) throw Object.assign(e, {
                        response: {
                            status: 0,
                            data: e.message || "Unknown error",
                            headers: {}
                        }
                    });
                    throw e
                }
            }
            return null != i && (t["X-Gist-Encoded-User-Token"] = i), n.post = (e, t = {}, i = {}) => n(e, {
                method: "POST",
                body: JSON.stringify(t),
                headers: {
                    "Content-Type": "application/json",
                    ...i.headers || {}
                }
            }), n
        }
        let E = "gist.web.userLocale",
            $ = 600,
            k = !1,
            P = "gist.web.userQueueNextPullCheck",
            T = "gist.web.sessionId";

        function L() {
            let e = d(T);
            return e || (e = h()), o(T, e, new Date((new Date).getTime() + 18e5)), String(e)
        }
        let M = "gist.web.userToken",
            D = "gist.web.usingGuestUserToken",
            N = "gist.web.guestUserToken";

        function A() {
            return null !== d(D)
        }

        function _() {
            if (null === d(M)) {
                let e = d(N);
                null == e && (o(N, e = h()), n(`Set guest user token "${e}" with expiry date set to 1 year from today`)), o(M, e), o(D, !0), n(`Using anonymous session with token: "${e}"`)
            }
        }
        async function q() {
            let e = d(M);
            return null === e ? null : await async function(e) {
                let t = (new TextEncoder).encode(e);
                return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256", t))).map(e => e.toString(16).padStart(2, "0")).join("")
            }(e)
        }

        function R() {
            let e = d(M);
            return null === e ? null : btoa(e)
        }

        function O() {
            r(M), n("Cleared user token")
        }
        async function W(e) {
            try {
                return await C().post(`/api/v1/logs/queue/${e}`)
            } catch (e) {
                return S(e)
            }
        }

        function U(e) {
            try {
                return (document.getElementById(e) ? ? document.querySelector(e)) || null
            } catch {
                return null
            }
        }
        let z = {
            isEmbedded: !1,
            elementId: "",
            hasRouteRule: !1,
            routeRule: "",
            position: "",
            hasPosition: !1,
            tooltipPosition: "",
            hasTooltipPosition: !1,
            tooltipArrowColor: "#fff",
            shouldScale: !1,
            campaignId: null,
            messageWidth: 414,
            overlayColor: "#00000033",
            persistent: !1,
            exitClick: !1,
            hasCustomWidth: !1
        };

        function B(e) {
            let t = e ? .properties ? .gist;
            return t ? {
                isEmbedded: !!t.elementId && !t.tooltipPosition,
                elementId: t.elementId || "",
                hasRouteRule: !!t.routeRuleWeb,
                routeRule: t.routeRuleWeb || "",
                position: t.position || "",
                hasPosition: !!t.position,
                tooltipPosition: t.tooltipPosition || "",
                hasTooltipPosition: !!t.tooltipPosition,
                tooltipArrowColor: function(e) {
                    let t = z.tooltipArrowColor;
                    if ((e ? .properties ? .gist ? .tooltipArrowColor ? .length ? ? 0) > 0) t = e.properties.gist.tooltipArrowColor;
                    else {
                        if (!Array.isArray(e ? .displaySettings) || 0 === e.displaySettings.length) return t;
                        let i = e.displaySettings[0];
                        if (e.savedStepName) {
                            let t = e.displaySettings.find(t => t ? .stepName === e.savedStepName && t.displaySettings);
                            t && (i = t)
                        }
                        i ? .displaySettings ? .tooltipArrowColor && (t = i.displaySettings.tooltipArrowColor)
                    }
                    return t
                }(e),
                shouldScale: !!t.scale,
                campaignId: t.campaignId ? ? null,
                messageWidth: null != t.messageWidth && t.messageWidth > 0 ? t.messageWidth : z.messageWidth,
                hasCustomWidth: (t.messageWidth ? ? 0) > 0,
                overlayColor: t.overlayColor || z.overlayColor,
                persistent: !!t.persistent,
                exitClick: !!t.exitClick
            } : z
        }
        let F = ["x-gist-top", "x-gist-floating-top", "x-gist-bottom", "x-gist-floating-bottom", "x-gist-floating-bottom-left", "x-gist-floating-bottom-right", "x-gist-floating-top-left", "x-gist-floating-top-right"];

        function H(e) {
            if (document.getElementById(e)) return;
            let t = document.createElement("div");
            t.id = e, "x-gist-top" === e ? document.body.insertBefore(t, document.body.firstChild) : document.body.insertAdjacentElement("beforeend", t), n("Top & bottom elements injected into page")
        }
        let j = ["x-gist-top", "x-gist-bottom", "x-gist-floating-top", "x-gist-floating-bottom"];

        function V(e) {
            return tj.currentMessages.find(t => t.instanceId === e)
        }

        function G(e) {
            return !!e && tj.currentMessages.some(t => t.queueId === e)
        }

        function X(e) {
            return e ? tj.currentMessages.find(t => t.elementId === e) ? ? null : null
        }

        function J(e) {
            tj.currentMessages = tj.currentMessages.filter(t => t.instanceId !== e)
        }

        function Y(e, t) {
            J(e), tj.currentMessages.push(t)
        }

        function K(e) {
            let t = {
                topLeft: "x-gist-floating-top-left",
                topCenter: "x-gist-floating-top",
                topRight: "x-gist-floating-top-right",
                bottomLeft: "x-gist-floating-bottom-left",
                bottomCenter: "x-gist-floating-bottom",
                bottomRight: "x-gist-floating-bottom-right"
            };
            return e && t[e] ? t[e] : (n(`Invalid overlay position "${e}", defaulting to "topCenter"`), t.topCenter)
        }

        function Q(e) {
            return e.tooltipPosition ? "tooltip" : e.overlay ? "modal" : e.elementId && F.includes(e.elementId) ? "overlay" : e.elementId ? "inline" : "modal"
        }

        function Z(e, t) {
            let i = Q(e),
                n = t.displayType;
            if (void 0 === n) return !1;
            if (i !== n) return !0;
            let s = B(e);
            switch (n) {
                case "modal":
                    {
                        if ((e.position || "center") !== (t.modalPosition || "center")) return !0;
                        let i = t.dismissOutsideClick ? ? z.exitClick;
                        if (s.exitClick !== i) return !0;
                        let n = t.overlayColor ? ? z.overlayColor;
                        if (s.overlayColor !== n) return !0;
                        break
                    }
                case "overlay":
                    {
                        let i = K(t.overlayPosition);
                        if (e.elementId !== i) return !0;
                        break
                    }
                case "inline":
                    if (e.elementId !== t.elementSelector) return !0;
                    break;
                case "tooltip":
                    if (e.tooltipPosition !== t.tooltipPosition || e.elementId !== t.elementSelector || void 0 !== t.tooltipArrowColor && s.tooltipArrowColor !== t.tooltipArrowColor) return !0
            }
            if ("overlay" !== n || !j.includes(K(t.overlayPosition))) {
                let e = t.maxWidth ? ? z.messageWidth;
                if (s.messageWidth !== e) return !0
            }
            return !1
        }

        function ee(e, t) {
            if (e.properties || (e.properties = {}), e.properties.gist || (e.properties.gist = {}), "modal" === t.displayType) e.overlay = !0, e.elementId = null, e.properties.gist.elementId = null, e.position = t.modalPosition || "center", e.properties.gist.position = t.modalPosition || "center", e.tooltipPosition = void 0, e.properties.gist.tooltipPosition = void 0, e.properties.gist.tooltipArrowColor = void 0;
            else if ("overlay" === t.displayType) {
                e.overlay = !1;
                let i = K(t.overlayPosition);
                e.elementId = i, e.properties.gist.elementId = i, e.position = null, e.properties.gist.position = null, e.tooltipPosition = void 0, e.properties.gist.tooltipPosition = void 0, e.properties.gist.tooltipArrowColor = void 0
            } else "inline" === t.displayType ? (e.overlay = !1, e.elementId = t.elementSelector, e.properties.gist.elementId = t.elementSelector, e.position = null, e.properties.gist.position = null, e.tooltipPosition = void 0, e.properties.gist.tooltipPosition = void 0, e.properties.gist.tooltipArrowColor = void 0) : "tooltip" === t.displayType && (e.overlay = !1, e.elementId = t.elementSelector, e.properties.gist.elementId = t.elementSelector, e.tooltipPosition = t.tooltipPosition, e.properties.gist.tooltipPosition = t.tooltipPosition, e.position = null, e.properties.gist.position = null, void 0 !== t.tooltipArrowColor && (e.properties.gist.tooltipArrowColor = t.tooltipArrowColor));
            e.elementId && j.includes(e.elementId) ? delete e.properties.gist.messageWidth : void 0 !== t.maxWidth && t.maxWidth > 0 ? e.properties.gist.messageWidth = t.maxWidth : delete e.properties.gist.messageWidth, void 0 !== t.overlayColor ? e.properties.gist.overlayColor = t.overlayColor : delete e.properties.gist.overlayColor, void 0 !== t.dismissOutsideClick ? e.properties.gist.exitClick = t.dismissOutsideClick : delete e.properties.gist.exitClick
        }
        let et = {
                top: ["bottom", "left", "right"],
                bottom: ["top", "left", "right"],
                left: ["right", "top", "bottom"],
                right: ["left", "top", "bottom"]
            },
            ei = /auto|scroll/,
            en = {
                top: "gist-arrow-bottom",
                bottom: "gist-arrow-top",
                left: "gist-arrow-right",
                right: "gist-arrow-left"
            };

        function es(e) {
            let t = U(e);
            return t || n(`Tooltip target element not found for selector: ${e}`), t
        }

        function eo(e, t) {
            if (e.bottom <= 0 || e.top >= window.innerHeight || e.right <= 0 || e.left >= window.innerWidth) return !1;
            for (let i of t) {
                let t = i.getBoundingClientRect();
                if (e.bottom <= t.top || e.top >= t.bottom || e.right <= t.left || e.left >= t.right) return !1
            }
            return !0
        }

        function er(e, t, i) {
            let n = function(e, t, i) {
                switch (i) {
                    case "top":
                        return {
                            top: t.top - e.height - 16,
                            left: t.left + (t.width - e.width) / 2
                        };
                    case "bottom":
                        return {
                            top: t.bottom + 16,
                            left: t.left + (t.width - e.width) / 2
                        };
                    case "left":
                        return {
                            top: t.top + (t.height - e.height) / 2,
                            left: t.left - e.width - 16
                        };
                    case "right":
                        return {
                            top: t.top + (t.height - e.height) / 2,
                            left: t.right + 16
                        }
                }
            }(e, t, i);
            return ("top" === i || "bottom" === i ? n.top >= 0 && n.top + e.height <= window.innerHeight : n.left >= 0 && n.left + e.width <= window.innerWidth) && ("top" === i || "bottom" === i ? e.width + 8 <= window.innerWidth : e.height + 8 <= window.innerHeight) ? function(e, t, i) {
                let {
                    top: n,
                    left: s
                } = e, o = null;
                if ("top" === i || "bottom" === i) {
                    let e = window.innerWidth - t.width - 4;
                    e >= 4 && (s < 4 ? (o = s - 4, s = 4) : s > e && (o = s - e, s = e))
                } else {
                    let e = window.innerHeight - t.height - 4;
                    e >= 4 && (n < 4 ? (o = n - 4, n = 4) : n > e && (o = n - e, n = e))
                }
                if (null !== o) {
                    let e = ("top" === i || "bottom" === i ? t.width / 2 : t.height / 2) - 16 - 4;
                    Math.abs(o) > e && (o = o > 0 ? e : -e)
                }
                return {
                    top: n,
                    left: s,
                    position: i,
                    arrowOffset: o
                }
            }(n, e, i) : null
        }

        function ea(e, t, i) {
            let n = er(e, t, i);
            if (n) return n;
            for (let n of et[i]) {
                let i = er(e, t, n);
                if (i) return i
            }
            return null
        }

        function el(e) {
            let t = [],
                i = e.parentElement;
            for (; i;) {
                let e = getComputedStyle(i),
                    n = e.overflow + e.overflowX + e.overflowY;
                ei.test(n) && t.push(i), i = i.parentElement
            }
            return t
        }

        function ed(e) {
            let t = U(e);
            t && (t.classList.remove("gist-visible"), Array.from(t.classList).filter(e => e.startsWith("gist-")).forEach(e => t.classList.remove(e)), t.style.removeProperty("height"), t.style.removeProperty("width"), t.innerHTML = "")
        }

        function ec(e) {
            let t = U(e);
            if (t) return !(!t.style || !t.style.height || "0px" === t.style.height)
        }

        function eu(e, t, i = null) {
            let n = document.getElementById(e);
            n && (n.onload = () => {
                ! function(e, t, i = null) {
                    let n = document.getElementById(e);
                    n ? .contentWindow && (i && (t.stepId = i), n.contentWindow.postMessage({
                        options: t,
                        capabilities: ep
                    }, "*"))
                }(e, t, i)
            })
        }
        let ep = ["MultiStepDisplayTypes"];

        function eg(e) {
            if (!e.displaySettings) return;
            let t = ew(e.instanceId ? ? ""),
                i = document.getElementById(t);
            i ? .contentWindow && i.contentWindow.postMessage({
                action: "updateDisplaySettings",
                displaySettings: e.displaySettings
            }, "*")
        }
        async function em() {
            let e = document.querySelector(".gist-message");
            e && (e.classList.remove("gist-visible"), await new Promise(e => setTimeout(e, 300))), ef()
        }

        function ef() {
            let e = document.querySelector("#gist-embed-message");
            e && e.parentNode ? .removeChild(e)
        }
        let eh = new Map;

        function ev(e) {
            let t = e.instanceId ? ? "",
                i = eh.get(t);
            i && (i.cleanup(), eh.delete(t));
            let n = U(`gist-tooltip-${t}`);
            n && n.parentNode ? .removeChild(n)
        }

        function ew(e) {
            return `gist-${e}`
        }

        function ey() {
            let e = document.querySelector(".gist-message");
            e && e.classList.add("gist-visible")
        }
        let eb = "gist.web.customAttributes",
            ex = new Map;

        function eI() {
            let e = Array.from(ex.entries()),
                t = new Date;
            t.setDate(t.getDate() + 30), o(eb, e, t), n(`Saved ${ex.size} custom attributes to storage with TTL of 30 days`)
        }
        async function eS(e) {
            let t = await ek();
            if (!t) return;
            let i = new Date;
            i.setMinutes(i.getMinutes() + 60), o(t, e.filter(eE), i)
        }
        async function eC(e, t) {
            let i = d(e);
            return i ? .find(e => e.queueId === t)
        }

        function eE(e) {
            return !(!e.properties ? .gist || !e.properties.gist.broadcast)
        }

        function e$(e) {
            if (!eE(e)) return !1;
            let t = e.properties.gist.broadcast;
            return 0 === t.frequency.delay && 0 === t.frequency.count
        }
        async function ek() {
            let e = await q();
            return e ? `gist.web.message.broadcasts.${e}` : null
        }

        function eP(e, t) {
            return `${e}.${t}.numberOfTimesShown`
        }

        function eT(e, t) {
            return `${e}.${t}.shouldShow`
        }
        let eL = d(eb);
        if (eL) try {
            ex = new Map(eL)
        } catch {
            ex = new Map
        } else ex = new Map;
        let eM = "gist.web.message.user";
        async function eD(e) {
            let t = await eN();
            if (!t) return;
            let i = e.filter(e => !(e.properties && e.properties.gist && e.properties.gist.broadcast)),
                n = new Date;
            n.setMinutes(n.getMinutes() + 60), o(t, i, n)
        }
        async function eN() {
            let e = await q();
            return e ? `${eM}.${e}` : null
        }
        async function eA() {
            let e = await q();
            return e ? `${eM}.${e}.seen` : null
        }
        async function e_(e) {
            let t = await q();
            return t ? `${eM}.${t}.message.${e}.loading` : null
        }
        async function eq(e) {
            let t = await q();
            return t ? `${eM}.${t}.message.${e}.state` : null
        }
        async function eR(e) {
            let t = await eq(e);
            t && (r(t), n(`Cleared message state for queueId: ${e}`))
        }

        function eO(e) {
            return `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.54223 5.33301L7.7089 9.33301L11.8756 5.33301L12.6121 6.04011L7.7089 10.7472L2.80566 6.04011L3.54223 5.33301Z" fill="${e}"/></svg>`
        }
        let eW = `
  #gist-preview-bar {
    position: fixed; bottom: 0; left: 0; right: 0;
    z-index: 99999999999;
    font-family: system-ui, -apple-system, sans-serif;
    pointer-events: none;
  }
  .gist-pb-toggle-row {
    display: flex; justify-content: center;
    padding: 6px 16px;
    border-bottom: 1px solid #e5e7eb;
  }
  .gist-pb-toggle-row--collapsed { border-bottom: none; }
  .gist-pb-toggle-btn {
    background: #08272B; border: none;
    padding: 4px 14px;
    border-radius: 100px;
    font-size: 12px; font-weight: 500;
    font-family: system-ui, -apple-system, sans-serif;
    color: white; cursor: pointer;
    display: flex; align-items: center; gap: 6px;
    pointer-events: auto;
    height: auto; min-width: auto;
    box-sizing: border-box;
    line-height: normal;
    -webkit-appearance: none;
    appearance: none;
  }
  .gist-pb-controls-row {
    background: #F8F9F9;
    box-shadow: 1px 2px 2px #34344605, 3px 3px 8px #34344614;
    display: flex; flex-wrap: wrap; align-items: center;
    gap: 12px; padding: 10px 16px 12px;
    pointer-events: auto;
  }
  .gist-pb-label-group { display: flex; flex-direction: column; gap: 4px; }
  .gist-pb-label-group--grow { flex: 1; }
  .gist-pb-label {
    font-size: 10px; font-weight: 600; color: #3F4E50;
    letter-spacing: 0.05em; text-transform: uppercase;
    font-family: system-ui, -apple-system, sans-serif;
  }
  .gist-pb-select {
    height: 32px; padding: 0 32px 0 8px;
    border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 13px; font-family: system-ui, -apple-system, sans-serif;
    background: white url("data:image/svg+xml,${encodeURIComponent(eO("#3F4E50"))}") no-repeat right 2px center;
    color: #3F4E50; cursor: pointer; outline: none;
    appearance: none; min-width: 120px;
  }
  .gist-pb-input {
    height: 32px; padding: 0 8px;
    border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 13px; font-family: system-ui, -apple-system, sans-serif;
    color: #3F4E50; outline: none; box-sizing: border-box;
  }
  .gist-pb-checkbox-row { display: flex; align-items: center; gap: 6px; height: 32px; }
  .gist-pb-checkbox-label {
    font-size: 12px; font-family: system-ui, -apple-system, sans-serif;
    color: #3F4E50; cursor: pointer; user-select: none;
  }
  .gist-pb-color-control {
    display: flex; align-items: center;
    border: 1px solid #d1d5db; border-radius: 6px;
    overflow: hidden; height: 32px; background: white;
  }
  .gist-pb-color-swatch {
    width: 28px; height: 100%;
    cursor: pointer; flex-shrink: 0;
    border-right: 1px solid #d1d5db; position: relative;
  }
  .gist-pb-color-input {
    position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;
  }
  .gist-pb-color-hex {
    flex: 1; border: none; outline: none; padding: 0 6px;
    font-size: 13px; font-family: monospace; color: #3F4E50;
    min-width: 0; background: transparent;
  }
  .gist-pb-color-opacity {
    width: 36px; border: none; border-left: 1px solid #d1d5db;
    outline: none; padding: 0 4px;
    font-size: 13px; font-family: system-ui, -apple-system, sans-serif;
    color: #3F4E50; background: transparent; text-align: right;
  }
  .gist-pb-color-pct {
    font-size: 12px; color: #3F4E50; padding: 0 6px 0 2px;
    font-family: system-ui, -apple-system, sans-serif; flex-shrink: 0;
  }
  .gist-pb-input--invalid { border-color: #941616; outline: 1px solid #941616; }
  .gist-pb-inline-row { display: flex; align-items: center; gap: 6px; }
  .gist-pb-select-elem-btn, .gist-pb-cancel-btn {
    height: 32px; padding: 0 12px;
    border: none; border-radius: 6px;
    font-size: 12px; font-weight: 500; font-family: system-ui, -apple-system, sans-serif;
    background: #08272B; color: white; cursor: pointer; white-space: nowrap; flex-shrink: 0;
    min-width: auto; box-sizing: border-box;
    -webkit-appearance: none; appearance: none;
  }
  .gist-pb-select-elem-btn:disabled {
    opacity: 0.4; cursor: not-allowed;
  }
  .gist-pb-spacer { flex: 1; min-width: 0; }
  .gist-pb-save-btn {
    height: 36px; padding: 0 18px;
    background: #08272B; color: white;
    border: none; border-radius: 6px;
    font-size: 13px; font-weight: 600;
    font-family: system-ui, -apple-system, sans-serif;
    cursor: pointer; white-space: nowrap; align-self: center;
    min-width: auto; box-sizing: border-box;
    -webkit-appearance: none; appearance: none;
  }
  .gist-pb-save-btn:disabled {
    background: #CAD6D8; cursor: not-allowed;
  }
  .gist-pb-picker-overlay {
    position: fixed; inset: 0; z-index: 999999999998; cursor: crosshair;
  }
  .gist-pb-checkbox { cursor: pointer; width: 14px; height: 14px; }
  .gist-pb-pick-highlight { outline: 2px solid #006FF5 !important; }
  .gist-pb-pick-error { outline: 2px solid #941616 !important; }
  #gist-preview-bar.gist-pb-hidden { display: none; }
  .gist-pb-ended-row {
    justify-content: center; align-items: center; gap: 10px; padding: 12px 16px;
    flex-wrap: nowrap;
  }
  .gist-pb-ended-icon {
    display: flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 50%;
    background: #08272B; color: white;
    font-size: 13px; font-weight: 700; flex-shrink: 0;
  }
  .gist-pb-ended-text {
    margin: 0; font-size: 13px; color: #3F4E50;
    font-family: system-ui, -apple-system, sans-serif;
    min-width: 0;
  }
  .gist-pb-ended-text strong { color: #08272B; }
  @media (max-width: 1024px) {
    .gist-pb-controls-row { gap: 8px; }
    .gist-pb-label-group { flex: 1 1 100%; }
    .gist-pb-label-group--grow { flex: 1 1 100%; }
    .gist-pb-select { width: 100%; min-width: unset; box-sizing: border-box; }
    .gist-pb-input { width: 100% !important; box-sizing: border-box; }
    .gist-pb-color-control { width: 100%; }
    .gist-pb-checkbox-row { width: 100%; }
    .gist-pb-inline-row { flex-direction: row; align-items: center; }
    .gist-pb-inline-row .gist-pb-input { flex: 1; min-width: 0; }
    .gist-pb-save-btn { width: 100%; box-sizing: border-box; }
    .gist-pb-label--spacer { display: none; }
  }
`,
            eU = "cioPreviewId",
            ez = "cioPreviewSettings",
            eB = "gist.previewBar.collapsed",
            eF = "gist-pb-styles",
            eH = "gist-preview-bar",
            ej = {
                topLeft: "Top Left",
                topCenter: "Top Center",
                topRight: "Top Right",
                bottomLeft: "Bottom Left",
                bottomCenter: "Bottom Center",
                bottomRight: "Bottom Right"
            },
            eV = null,
            eG = [],
            eX = {},
            eJ = null,
            eY = !1,
            eK = !1,
            eQ = 5,
            eZ = null,
            e0 = !0,
            e1 = !1,
            e2 = !1,
            e3 = null,
            e4 = null,
            e6 = null,
            e5 = new Map;

        function e9(e, t = {}) {
            let i = document.createElement(e);
            for (let [e, n] of Object.entries(t)) i[e] = n;
            return i
        }

        function e8(e, t) {
            let i = e9("div", {
                className: "gist-pb-label-group"
            });
            return i.appendChild(e9("span", {
                className: "gist-pb-label",
                textContent: e
            })), i.appendChild(t), i
        }

        function e7(e, t) {
            let i = e9("select", {
                className: "gist-pb-select"
            });
            for (let n of e) {
                let e = e9("option", {
                    value: n.value,
                    textContent: n.label
                });
                n.value === t && (e.selected = !0), i.appendChild(e)
            }
            return i
        }

        function te(e, t, i) {
            let n = e9("input", {
                className: "gist-pb-input",
                type: e,
                value: String(t)
            });
            return i && (n.style.width = i), n
        }

        function tt(e) {
            return !!("inline" !== e.displayType && "tooltip" !== e.displayType || e.elementSelector ? .trim())
        }

        function ti(e) {
            let t;
            if ("overlay" === e.displayType && j.includes(K(e.overlayPosition))) {
                let {
                    maxWidth: t,
                    ...i
                } = e;
                e = i
            }
            if (eX = e, eJ) {
                let t = eG.findIndex(e => e.stepName === eJ); - 1 !== t && (eG[t] = { ...eG[t],
                    displaySettings: { ...e
                    }
                })
            }
            if (!eV) return;
            let i = tj.currentMessages.find(e => e.instanceId === eV);
            i && tt(e) && (eg(i), Z(i, e) && tL(i, eJ, e)), (t = new URLSearchParams(window.location.search).get(eU)) && (async function(e, t) {
                try {
                    return await C()(`/api/v1/preview/${e}`, {
                        method: "POST",
                        body: JSON.stringify(t),
                        headers: {
                            "Content-Type": "application/json"
                        }
                    })
                } catch (e) {
                    return S(e)
                }
            })(t, eG).then(e => {
                e && 404 === e.status && eV && tj.dismissMessage(eV)
            }).catch(() => n("Failed to persist preview display settings"))
        }

        function tn(e) {
            let t = e.value.trim();
            t && !U(t) ? e.classList.add("gist-pb-input--invalid") : e.classList.remove("gist-pb-input--invalid")
        }

        function ts(e, t) {
            let i = te("text", e.elementSelector || "", "260px");
            i.placeholder = "Element ID or selector", tn(i), i.addEventListener("change", () => {
                let e = i.value.trim(),
                    t = eX.elementSelector;
                e && to(e), ti({ ...eX,
                    elementSelector: e
                }), t && t !== e && tr(t), tn(i)
            });
            let n = e9("button", {
                type: "button",
                className: "gist-pb-select-elem-btn",
                textContent: "Select Element"
            });
            e2 && (n.disabled = !0), n.addEventListener("click", () => tl(i));
            let s = e9("div", {
                className: "gist-pb-inline-row"
            });
            s.appendChild(i), s.appendChild(n), t.appendChild(e8("Element Selector", s))
        }

        function to(e) {
            if (!e || e5.has(e)) return;
            let t = U(e);
            t && e5.set(e, t.innerHTML)
        }

        function tr(e) {
            let t = e5.get(e);
            if (void 0 === t) return;
            let i = U(e);
            i && (i.innerHTML = t)
        }

        function ta() {
            for (let e of e5.keys()) tr(e);
            e5.clear()
        }

        function tl(e) {
            if (e2) return;
            e2 = !0;
            let t = document.querySelector(`#${eH} .gist-pb-select-elem-btn`);
            t && (t.disabled = !0);
            let i = { ...eX
                },
                s = tj.currentMessages.find(e => e.instanceId === eV) ? ? null;
            s && tT(s), eX.elementSelector && tr(eX.elementSelector);
            let o = e9("div", {
                    className: "gist-pb-picker-overlay"
                }),
                r = null,
                a = e => {
                    o.style.pointerEvents = "none";
                    let t = document.elementFromPoint(e.clientX, e.clientY);
                    o.style.pointerEvents = "all", t && t !== r && t !== o && (r ? .classList.remove("gist-pb-pick-highlight"), (r = t).classList.add("gist-pb-pick-highlight"))
                },
                l = e => {
                    if ("Escape" === e.key) {
                        if (c(), eX = i, eJ) {
                            let e = eG.findIndex(e => e.stepName === eJ); - 1 !== e && (eG[e] = { ...eG[e],
                                displaySettings: { ...i
                                }
                            })
                        }
                        s && tt(i) && tL(s, eJ, i), td()
                    }
                },
                d = t => {
                    t.preventDefault(), t.stopPropagation(), o.style.pointerEvents = "none";
                    let i = document.elementFromPoint(t.clientX, t.clientY);
                    if (o.style.pointerEvents = "all", i && i !== o) {
                        i.classList.remove("gist-pb-pick-highlight");
                        let t = document.getElementById(eH),
                            o = t ? .contains(i) ? null : function(e) {
                                if (e.id) {
                                    let t = CSS.escape(e.id);
                                    if (1 === document.querySelectorAll(`#${t}`).length) return e.id
                                }
                                let t = [],
                                    i = e;
                                for (; i && "BODY" !== i.tagName && "HTML" !== i.tagName;) {
                                    if (i.id) {
                                        let e = CSS.escape(i.id);
                                        if (1 === document.querySelectorAll(`#${e}`).length) {
                                            t.unshift(`#${e}`);
                                            break
                                        }
                                    }
                                    let e = i.tagName.toLowerCase();
                                    i.className && "string" == typeof i.className && (e += i.className.trim().split(/\s+/).filter(Boolean).map(e => `.${CSS.escape(e)}`).join(""));
                                    let n = i.parentElement;
                                    n && (e += `:nth-of-type(${Array.from(n.children).filter(e=>e.tagName===i.tagName).indexOf(i)+1})`), t.unshift(e);
                                    try {
                                        if (1 === document.querySelectorAll(t.join(" > ")).length) break
                                    } catch {}
                                    i = i.parentElement
                                }
                                let s = t.join(" > ");
                                try {
                                    if (1 !== document.querySelectorAll(s).length) return n("buildUniqueSelector: could not produce a unique selector for element"), null
                                } catch {
                                    return null
                                }
                                return s
                            }(i);
                        if (null === o) return i.classList.add("gist-pb-pick-error"), void setTimeout(() => {
                            i.classList.remove("gist-pb-pick-error"), i.classList.add("gist-pb-pick-highlight")
                        }, 800);
                        e.value = o, to(o);
                        let r = eX.elementSelector,
                            a = { ...eX,
                                elementSelector: o
                            },
                            l = null != s && tt(a) && Z(s, a);
                        ti(a), r && r !== o && tr(r), s && !l && tL(s, eJ, a)
                    }
                    c(), td()
                },
                c = () => {
                    r ? .classList.remove("gist-pb-pick-highlight"), o.removeEventListener("mousemove", a), o.removeEventListener("click", d), document.removeEventListener("keydown", l), document.body.removeChild(o), e2 = !1, e3 = null
                };
            e3 = c, o.addEventListener("mousemove", a), o.addEventListener("click", d), document.addEventListener("keydown", l), document.body.appendChild(o)
        }

        function td() {
            var e, t;
            let i, n, s, o, r, a, l, d = document.getElementById(eH);
            if (!d) return;
            if (d.classList.toggle("gist-pb-hidden", !eV && !eK), d.innerHTML = "", !eV) {
                if (eK) {
                    let e = e9("div", {
                            className: "gist-pb-controls-row gist-pb-ended-row"
                        }),
                        t = e9("span", {
                            className: "gist-pb-ended-icon",
                            textContent: "✓"
                        }),
                        i = e9("p", {
                            className: "gist-pb-ended-text"
                        });
                    if (i.innerHTML = tu(eQ), e.appendChild(t), e.appendChild(i), e0) {
                        let t = e9("button", {
                            type: "button",
                            className: "gist-pb-cancel-btn",
                            textContent: "Cancel"
                        });
                        t.addEventListener("click", tp), e.appendChild(t)
                    }
                    d.appendChild(e)
                }
                return
            }
            let c = e9("div", {
                    className: "gist-pb-toggle-row" + (eY ? " gist-pb-toggle-row--collapsed" : "")
                }),
                u = e9("button", {
                    type: "button",
                    className: "gist-pb-toggle-btn"
                }),
                p = eY ? "transform:rotate(180deg);display:inline-flex;" : "display:inline-flex;";
            if (u.innerHTML = `${eY?"Expand":"Collapse"}<span style="${p}">${eO("white")}</span>`, u.addEventListener("click", tg), c.appendChild(u), d.appendChild(c), eY) return;
            let g = e9("div", {
                className: "gist-pb-controls-row"
            });
            if (eG.length > 0) {
                let e = eJ ? ? eG[0].stepName,
                    t = e7(eG.map(e => ({
                        value: e.stepName,
                        label: e.stepName
                    })), e);
                t.addEventListener("change", () => {
                    let e = eG.find(e => e.stepName === t.value);
                    if (e) {
                        eJ = e.stepName, eX = { ...e.displaySettings
                        };
                        let t = tj.currentMessages.find(e => e.instanceId === eV);
                        t && tt(e.displaySettings) && tL(t, e.stepName, e.displaySettings), td()
                    }
                }), g.appendChild(e8("Step", t))
            }
            let m = e7([{
                value: "modal",
                label: "Modal"
            }, {
                value: "overlay",
                label: "Overlay"
            }, {
                value: "inline",
                label: "Inline"
            }, {
                value: "tooltip",
                label: "Tooltip"
            }], eX.displayType || "modal");
            m.addEventListener("change", () => {
                let e = m.value,
                    t = eX.displayType,
                    i = eX.elementSelector,
                    n = { ...eX,
                        displayType: e
                    };
                "modal" === e ? (n.modalPosition = n.modalPosition || "center", n.maxWidth = n.maxWidth ? ? 414, delete n.overlayPosition, delete n.elementSelector, delete n.tooltipPosition) : "overlay" === e ? (n.overlayPosition = n.overlayPosition || "topCenter", n.maxWidth = n.maxWidth ? ? 414, delete n.modalPosition, delete n.elementSelector, delete n.tooltipPosition) : "inline" === e ? (delete n.modalPosition, delete n.overlayPosition, delete n.tooltipPosition) : "tooltip" === e && (n.tooltipPosition = n.tooltipPosition || "top", delete n.modalPosition, delete n.overlayPosition, delete n.overlayColor, delete n.dismissOutsideClick), ti(eX = n), ("inline" === t || "tooltip" === t) && i && "inline" !== e && "tooltip" !== e && tr(i), td()
            }), g.appendChild(e8("Display Type", m));
            let f = eX.displayType || "modal";
            "modal" === f ? ((i = e7([{
                value: "top",
                label: "Top"
            }, {
                value: "center",
                label: "Center"
            }, {
                value: "bottom",
                label: "Bottom"
            }], (e = eX).modalPosition || "center")).addEventListener("change", () => ti({ ...eX,
                modalPosition: i.value
            })), g.appendChild(e8("Position", i)), (n = te("number", e.maxWidth ? ? 414, "80px")).addEventListener("change", () => ti({ ...eX,
                maxWidth: parseInt(n.value) || 414
            })), g.appendChild(e8("Max Width", n)), g.appendChild(function(e) {
                let t, {
                        color: i,
                        opacity: n
                    } = 8 === (t = (e.overlayColor || "#00000033").replace("#", "")).length ? {
                        color: "#" + t.slice(0, 6).toUpperCase(),
                        opacity: Math.round(parseInt(t.slice(6), 16) / 255 * 100)
                    } : 6 === t.length ? {
                        color: "#" + t.toUpperCase(),
                        opacity: 100
                    } : {
                        color: "#000000",
                        opacity: 20
                    },
                    s = e9("div", {
                        className: "gist-pb-color-control"
                    }),
                    o = e9("input", {
                        className: "gist-pb-color-input",
                        type: "color",
                        value: i
                    }),
                    r = e9("div", {
                        className: "gist-pb-color-swatch"
                    });
                r.style.background = i, r.appendChild(o), r.addEventListener("click", () => o.click());
                let a = e9("input", {
                        className: "gist-pb-color-hex",
                        type: "text",
                        maxLength: 6,
                        value: i.replace("#", "")
                    }),
                    l = e9("input", {
                        className: "gist-pb-color-opacity",
                        type: "number",
                        min: "0",
                        max: "100",
                        value: String(n)
                    }),
                    d = e9("span", {
                        className: "gist-pb-color-pct",
                        textContent: "%"
                    }),
                    c = () => {
                        let e, t = "#" + a.value.replace("#", ""),
                            i = parseInt(l.value) || 0;
                        r.style.background = t, o.value = t, ti({ ...eX,
                            overlayColor: (e = Math.round(Math.min(100, Math.max(0, i)) / 100 * 255), "#" + t.replace("#", "").toUpperCase() + e.toString(16).padStart(2, "0").toUpperCase())
                        })
                    };
                return o.addEventListener("input", () => {
                    a.value = o.value.replace("#", "").toUpperCase(), r.style.background = o.value
                }), o.addEventListener("change", c), a.addEventListener("change", c), l.addEventListener("change", c), s.appendChild(r), s.appendChild(a), s.appendChild(l), s.appendChild(d), e8("Overlay Color", s)
            }(e)), s = e9("div", {
                className: "gist-pb-checkbox-row"
            }), (o = e9("input", {
                className: "gist-pb-checkbox",
                type: "checkbox"
            })).checked = e.dismissOutsideClick ? ? !1, r = e9("label", {
                className: "gist-pb-checkbox-label",
                textContent: "Dismiss on click outside"
            }), o.addEventListener("change", () => ti({ ...eX,
                dismissOutsideClick: o.checked
            })), r.addEventListener("click", () => {
                o.checked = !o.checked, ti({ ...eX,
                    dismissOutsideClick: o.checked
                })
            }), s.appendChild(o), s.appendChild(r), (a = e8(" ", s)).classList.add("gist-pb-label-group--grow"), a.firstChild.classList.add("gist-pb-label--spacer"), g.appendChild(a)) : "overlay" === f ? function(e, t) {
                let i = e7(Object.entries(ej).map(([e, t]) => ({
                    value: e,
                    label: t
                })), e.overlayPosition || "topCenter");
                if (i.addEventListener("change", () => ti({ ...eX,
                        overlayPosition: i.value
                    })), t.appendChild(e8("Position", i)), !j.includes(K(e.overlayPosition))) {
                    let i = te("number", e.maxWidth ? ? 414, "80px");
                    i.addEventListener("change", () => ti({ ...eX,
                        maxWidth: parseInt(i.value) || 414
                    })), t.appendChild(e8("Max Width", i))
                }
            }(eX, g) : "inline" === f ? ts(eX, g) : "tooltip" === f && ((l = e7([{
                value: "top",
                label: "Top"
            }, {
                value: "bottom",
                label: "Bottom"
            }, {
                value: "left",
                label: "Left"
            }, {
                value: "right",
                label: "Right"
            }], (t = eX).tooltipPosition || "top")).addEventListener("change", () => ti({ ...eX,
                tooltipPosition: l.value
            })), g.appendChild(e8("Position", l)), ts(t, g)), g.appendChild(e9("div", {
                className: "gist-pb-spacer"
            }));
            let h = e9("button", {
                type: "button",
                className: "gist-pb-save-btn",
                textContent: "End session"
            });
            h.addEventListener("click", async () => {
                eV && await tj.dismissMessage(eV)
            }), g.appendChild(h), d.appendChild(g)
        }
        async function tc() {
            if (!e1)
                if (e1 = !0, O(), function() {
                        try {
                            sessionStorage.removeItem(s)
                        } catch {}
                    }(), e0) {
                    try {
                        window.close()
                    } catch {}
                    try {
                        window.location.reload()
                    } catch {}
                    e3 && e3(), eZ && (clearInterval(eZ), eZ = null), ta(), document.getElementById(eH) ? .remove(), document.getElementById(eF) ? .remove(), eV = null, eG = [], eX = {}, eJ = null, eK = !1, eQ = 5, e0 = !0, e1 = !1
                } else eK = !1, e1 = !1, td()
        }

        function tu(e) {
            return e0 ? `<strong>Preview session ended.</strong> This tab will close in ${e}s…` : `<strong>Preview session ended.</strong> Finishing session in ${e}s… This tab will stay open.`
        }

        function tp() {
            eK && eZ && (e0 = !1, td())
        }

        function tg() {
            eY = !eY;
            try {
                sessionStorage.setItem(eB, String(eY))
            } catch {}
            td()
        }

        function tm() {
            ta(), eV = null, eG = [], eX = {}, eJ = null, eK = !0, eQ = 5, e0 = !0, e1 = !1;
            let e = new URLSearchParams(window.location.search).get(eU);
            e && (async function(e) {
                try {
                    return await C()(`/api/v1/preview/${e}`, {
                        method: "DELETE"
                    })
                } catch (e) {
                    return S(e)
                }
            })(e).catch(() => n("Failed to delete preview session")), td(), eZ && clearInterval(eZ), eZ = setInterval(async () => {
                if ((eQ -= 1) <= 0) clearInterval(eZ), eZ = null, await tc();
                else {
                    let e = document.querySelector(`#${eH} .gist-pb-ended-text`);
                    e ? e.innerHTML = tu(eQ) : td()
                }
            }, 1e3)
        }
        async function tf(e) {
            if (!tj.isDocumentVisible) return n("Document hidden, not showing message now."), null;
            if (G(e.queueId)) return n(`Message with queueId ${e.queueId} is already showing.`), null;
            let t = B(e);
            return !e.tooltipPosition && t.hasTooltipPosition && (e.tooltipPosition = t.tooltipPosition), e.tooltipPosition ? function(e, t) {
                let i = t.elementId || e.elementId;
                if (!i) return n(`No target selector specified for tooltip message ${e.messageId}`), tj.messageError(e), null;
                if (!U(i)) {
                    if (!tj.config.isPreviewSession || !e.properties ? .gist ? .livePreview) return n(`Tooltip target element "${i}" not found for message ${e.messageId}, skipping display`), tj.messageError(e), null;
                    n(`Preview: tooltip target "${i}" not found, loading message for preview bar`)
                }
                let s = tj.currentMessages.find(e => e.tooltipPosition && e.elementId === i);
                return s && (n(`Tooltip already showing on target "${i}" (instance ${s.instanceId}), dismissing it first`), tj.messageDismissed(s), ev(s), s.instanceId && J(s.instanceId)), e.instanceId = h(), e.overlay = !1, e.firstLoad = !0, e.shouldResizeHeight = !1, e.shouldScale = !1, e.renderStartTime = (new Date).getTime(), e.elementId = i, tj.currentMessages.push(e), tC(e, null, e.savedStepName || null)
            }(e, t) : tj.overlayInstanceId ? (n(`Message ${tj.overlayInstanceId} already showing.`), null) : (e.instanceId = h(), e.overlay = !0, e.firstLoad = !0, e.shouldResizeHeight = !0, e.shouldScale = t.shouldScale, e.renderStartTime = (new Date).getTime(), tj.overlayInstanceId = e.instanceId, tj.currentMessages.push(e), tC(e, null, e.savedStepName || null))
        }

        function th(e, t) {
            return tj.isDocumentVisible ? G(e.queueId) ? (n(`Message with queueId ${e.queueId} is already showing.`), null) : X(t) ? (n(`Message with elementId ${t} already has a message.`), null) : (e.instanceId = h(), e.overlay = !1, e.firstLoad = !0, e.shouldScale = !1, e.elementId = t, e.shouldResizeHeight = !ec(t), e.renderStartTime = (new Date).getTime(), tj.currentMessages.push(e), tC(e, t, e.savedStepName || null)) : (n("Document hidden, not showing message now."), null)
        }
        async function tv(e) {
            e ? (tj.messageDismissed(e), await tw(e)) : n("Message not found")
        }
        async function tw(e) {
            "tooltip" === Q(e) ? tx(e) : e.overlay ? await tI(!0, e) : tb(e)
        }
        async function ty(e) {
            e ? B(e).persistent && (n("Persistent message dismissed, logging view"), await tM(e), await tE(e), await eR(e.queueId ? ? "")) : n("Message not found")
        }

        function tb(e) {
            e.instanceId && J(e.instanceId), e.elementId && ed(e.elementId), tj.config.isPreviewSession && (tm(), tS())
        }

        function tx(e) {
            ev(e), e.instanceId && J(e.instanceId), 0 === tj.currentMessages.length && (window.removeEventListener("message", tk), window.removeEventListener("touchstart", t$)), tj.config.isPreviewSession && (tm(), tS())
        }
        async function tI(e, t) {
            e ? await em() : ef(), 0 === tj.currentMessages.length && (window.removeEventListener("message", tk), window.removeEventListener("touchstart", t$)), t.instanceId && J(t.instanceId), tj.overlayInstanceId = null, tj.config.isPreviewSession && (tm(), tS())
        }

        function tS() {
            let e = new URL(window.location.href);
            e.searchParams.delete(eU), e.searchParams.delete(ez), history.replaceState(null, "", e.toString())
        }

        function tC(e, t = null, i = null) {
            let s = tj.config.env,
                o = {
                    endpoint: x.ENGINE_API_ENDPOINT[s],
                    siteId: tj.config.siteId,
                    dataCenter: tj.config.dataCenter,
                    messageId: e.messageId,
                    instanceId: e.instanceId ? ? "",
                    livePreview: !1,
                    properties: e.properties,
                    customAttributes: Object.fromEntries(new Map(ex))
                },
                r = `${x.GIST_VIEW_ENDPOINT[s]}/index.html`;
            return window.addEventListener("message", tk), window.addEventListener("touchstart", t$), "tooltip" === Q(e) ? function(e, t, i, n = null) {
                let s = t.instanceId ? ? "",
                    o = ew(s),
                    r = B(t),
                    a = eh.get(s);
                a && (a.cleanup(), eh.delete(s)), document.querySelectorAll(`#gist-tooltip-${s}`).forEach(e => {
                    e.parentNode ? .removeChild(e)
                });
                let l = `gist-tooltip-${s}`,
                    d = document.createElement("div");
                d.id = l, d.innerHTML = function(e, t, i, n = "") {
                    let s = 600;
                    t.messageWidth > s && (s = t.messageWidth);
                    let o = t.tooltipArrowColor,
                        r = function(e) {
                            switch (e) {
                                case "top":
                                default:
                                    return "gist-arrow-bottom";
                                case "bottom":
                                    return "gist-arrow-top";
                                case "left":
                                    return "gist-arrow-right";
                                case "right":
                                    return "gist-arrow-left"
                            }
                        }(t.tooltipPosition),
                        a = n ? `#${n} ` : "";
                    return `
    <div class="gist-tooltip-outer">
        <style>
            ${a}.gist-tooltip-outer {
                position: absolute;
            }
            ${a}.gist-tooltip-container {
                position: relative;
                z-index: 9999999;
                opacity: 0;
                transition: opacity 0.3s ease-in-out;
            }
            ${a}.gist-tooltip-container.gist-visible {
                opacity: 1;
            }
            ${a}.gist-tooltip-frame-clip {
                overflow: hidden;
            }
            ${a}.gist-tooltip-frame {
                display: block;
                width: ${t.messageWidth}px;
                border: none;
                transition: height 0.1s ease-in-out;
            }
            ${a}.gist-tooltip-arrow {
                width: 0;
                height: 0;
                position: absolute;
                z-index: 1;
            }
            ${a}.gist-tooltip-arrow.gist-arrow-bottom {
                bottom: 0;
                left: 50%;
                transform: translateX(-50%) translateY(100%);
                border-left: 10px solid transparent;
                border-right: 10px solid transparent;
                border-top: 10px solid ${o};
            }
            ${a}.gist-tooltip-arrow.gist-arrow-top {
                top: 0;
                left: 50%;
                transform: translateX(-50%) translateY(-100%);
                border-left: 10px solid transparent;
                border-right: 10px solid transparent;
                border-bottom: 10px solid ${o};
            }
            ${a}.gist-tooltip-arrow.gist-arrow-right {
                right: 0;
                top: 50%;
                transform: translateY(-50%) translateX(100%);
                border-top: 10px solid transparent;
                border-bottom: 10px solid transparent;
                border-left: 10px solid ${o};
            }
            ${a}.gist-tooltip-arrow.gist-arrow-left {
                left: 0;
                top: 50%;
                transform: translateY(-50%) translateX(-100%);
                border-top: 10px solid transparent;
                border-bottom: 10px solid transparent;
                border-right: 10px solid ${o};
            }
            @media (max-width: ${s}px) {
                ${a}.gist-tooltip-frame {
                    max-width: 100%;
                }
            }
        </style>
        <div class="gist-tooltip-container">
            <div class="gist-tooltip-arrow ${r}"></div>
            <div class="gist-tooltip-frame-clip">
                <iframe id="${e}" class="gist-tooltip-frame" src="${i}"></iframe>
            </div>
        </div>
    </div>`
                }(o, r, e, l), document.body.appendChild(d), eu(o, i, n)
            }(r, e, o, i) : t ? (F.includes(t) && H(t), function(e, t, i, s, o = null) {
                let r = U(e);
                if (r) {
                    var a;
                    let n, l = ew(i.instanceId ? ? "");
                    r.classList.add(l);
                    let d = B(i),
                        c = d.messageWidth + "px";
                    j.includes(e) && !d.hasCustomWidth && (c = "100%"), F.includes(e) && (r.style.width = c), ec(e) || (r.style.height = "0px"), a = ew(i.instanceId ? ? ""), n = 800, d.messageWidth > n && (n = d.messageWidth), r.innerHTML = `
    <div id="gist-embed">
        <style>
            #x-gist-floating-top, #x-gist-floating-top-left, #x-gist-floating-top-right {
                position: fixed;
                top: 0px;
                z-index: 1000000;
            }
            #x-gist-floating-bottom, #x-gist-floating-bottom-left, #x-gist-floating-bottom-right {
                position: fixed;
                bottom: 0px;
                z-index: 1000000;
            }
            #x-gist-bottom, #x-gist-top, #x-gist-floating-top, #x-gist-floating-bottom {
                left: 50%;
                transform: translate(-50%, 0%);
            }
            #x-gist-floating-top-right, #x-gist-floating-bottom-right {
                right: 0px;
            }
            #gist-embed {
                position: relative;
                height: 100%;
                width: 100%;
            }
            #gist-embed-container {
                position: relative;
                height: 100%;
                width: 100%;
            }
            #gist-embed-container .gist-frame {
                height: 100%;
                width: 100%;
                border: none;
            }
            #x-gist-top.${a},
            #x-gist-bottom.${a},
            #x-gist-floating-top.${a},
            #x-gist-floating-bottom.${a},
            #x-gist-floating-top-left.${a},
            #x-gist-floating-top-right.${a},
            #x-gist-floating-bottom-left.${a},
            #x-gist-floating-bottom-right.${a} {
                transition: height 0.1s ease-in-out;
            }
            @media (max-width: ${n}px) {
                #x-gist-top.${a},
                #x-gist-bottom.${a},
                #x-gist-floating-top.${a},
                #x-gist-floating-bottom.${a},
                #x-gist-floating-top-left.${a},
                #x-gist-floating-top-right.${a},
                #x-gist-floating-bottom-left.${a},
                #x-gist-floating-bottom-right.${a} {
                    width: 100% !important;
                }
            }
        </style>
        <div id="gist-embed-container">
            <iframe id="${a}" class="gist-frame" src="${t}"></iframe>
        </div>
    </div>`, eu(l, s, o)
                } else n(`Message could not be embedded, elementId ${e} not found.`)
            }(t, r, e, o, i)) : function(e, t, i, n = null) {
                var s;
                let o, r;
                document.querySelectorAll("#gist-embed-message").forEach(e => {
                    e.parentNode ? .removeChild(e)
                }), document.body.insertAdjacentHTML("afterbegin", (o = B(t), s = ew(t.instanceId ? ? ""), r = 600, o.messageWidth > r && (r = o.messageWidth), `
    <div id="gist-embed-message">
        <style>
            #gist-overlay.gist-background {
                position: fixed;
                z-index: 9999999998;
                left: 0;
                top: 0;
                width: 100%;
                height: 100%;
                background-color: ${o.overlayColor};
                visibility: hidden;
            }
            #gist-overlay.gist-background.gist-visible {
                visibility: visible;
            }
            .gist-message {
                width: ${o.messageWidth}px;
                position: absolute;
                border: none;
                opacity: 0;
                transition: opacity 0.3s ease-in-out, height 0.1s ease-in-out;
                z-index: 9999999999;
                left: 50%;
                transform: translateX(-50%);
            }
            .gist-message.gist-visible {
                opacity: 1;
                pointer-events: auto;
            }
            .gist-message.gist-center {
                transform: translate(-50%, -50%);
                top: 50%;
            }
            .gist-message.gist-bottom {
                bottom: 0;
            }
            .gist-message.gist-top {
                top: 0;
            }
            @media (max-width: ${r}px) {
                .gist-message {
                    width: 100%;
                }
            }
        </style>
        <div id="gist-overlay" class="gist-background">
            <iframe id="${s}" class="gist-message" src="${e}"></iframe>
        </div>
    </div>`)), eu(ew(t.instanceId ? ? ""), i, n)
            }(r, e, o, i), e
        }
        async function tE(e) {
            let t;
            n(`Message shown, logging view for: ${e.messageId}`), null != e.queueId ? (await tM(e), t = await W(e.queueId)) : t = await async function(e) {
                try {
                    return await C().post(`/api/v1/logs/message/${e}`)
                } catch (e) {
                    return S(e)
                }
            }(e.messageId), n(200 === t ? .status ? "Message view logged" : `Problem logging message: ${t?.status}`)
        }

        function t$() {}
        async function tk(e) {
            let t = tj.config.env,
                i = e.data;
            if (i.gist && e.origin === x.RENDERER_HOST[t]) {
                let e = i.gist.instanceId,
                    t = V(e);
                if (!t) return;
                let a = B(t);
                switch (i.gist.method) {
                    case "routeLoaded":
                        {
                            let s = .001 * ((new Date).getTime() - (t.renderStartTime ? ? 0));
                            if (n(`Engine render for message: ${t.messageId} timer elapsed in ${s.toFixed(3)} seconds`), async function(e) {
                                    let t = await e_(e);
                                    t && r(t)
                                }(t.queueId ? ? ""), t.currentRoute = i.gist.parameters.route, i.gist.parameters.fullDisplaySettings && !t.displaySettings ? t.displaySettings = i.gist.parameters.fullDisplaySettings : t.displaySettings && (n("SDK already has display settings state, sending it to iframe"), eg(t)), tj.config.isPreviewSession && t.properties ? .gist ? .livePreview && function(e) {
                                    if (eK) return;
                                    eV = e.instanceId ? ? null;
                                    let t = e.displaySettings;
                                    if (Array.isArray(t) && t.length > 0 ? (eG = t, eJ || (eJ = eG[0].stepName, eX = { ...eG[0].displaySettings
                                        })) : t && "object" == typeof t && !Array.isArray(t) && (eX = { ...t
                                        }), e4 || e6) {
                                        let e = !!e4,
                                            t = !!e6,
                                            i = e4,
                                            s = e6;
                                        if (e4 = null, e6 = null, e) {
                                            let e = eG.find(e => e.stepName === i);
                                            if (!e) return n(`Preview bar: step "${i}" not found, ignoring initial step/display override`), td();
                                            eJ = e.stepName, eX = { ...e.displaySettings
                                            }
                                        }
                                        if (t) {
                                            if (!e) return n(`Preview bar: display type "${s}" provided without a step, ignoring`), td();
                                            eX = { ...eX,
                                                displayType: s
                                            }
                                        }
                                        td();
                                        let o = tj.currentMessages.find(e => e.instanceId === eV);
                                        return o && tt(eX) ? tL(o, eJ, eX) : function() {
                                            let e = eX.displayType;
                                            if ("inline" !== e && "tooltip" !== e) return;
                                            let t = document.querySelector("#gist-preview-bar .gist-pb-input[type='text']");
                                            t && tl(t)
                                        }()
                                    }
                                    td()
                                }(t), t.firstLoad || t.isDisplayChange) {
                                if ("tooltip" === Q(t)) {
                                    let e = t.properties ? .gist ? .elementId || t.elementId || void 0;
                                    if (!e || !U(e)) {
                                        if (tj.config.isPreviewSession && t.properties ? .gist ? .livePreview) {
                                            n(`Preview: tooltip target "${e}" not found, preview bar will show element picker`), t.firstLoad = !1, t.isDisplayChange = !1;
                                            break
                                        }
                                        n(`Tooltip target not found for "${e}", emitting error and skipping display`), tj.messageError(t), t.firstLoad = !1, t.isDisplayChange = !1, tx(t);
                                        break
                                    }
                                    if (!await async function(e) {
                                            let t = e.instanceId ? ? "",
                                                i = B(e),
                                                s = `gist-tooltip-${t}`,
                                                o = U(s);
                                            if (!o) return n(`Tooltip wrapper not found for instance ${t}`), !1;
                                            let r = e.properties ? .gist ? .elementId || e.elementId || void 0;
                                            if (!r) return n(`No target selector for tooltip ${t}`), !1;
                                            let a = eh.get(t);
                                            a && (a.cleanup(), eh.delete(t));
                                            let l = o.querySelector(".gist-tooltip-outer");
                                            if (!l) return n(`Tooltip inner element not found for instance ${t}`), !1;
                                            let d = i.tooltipPosition || "bottom";
                                            if (!await async function(e, t, i) {
                                                    let s = es(t);
                                                    if (!s) return !1;
                                                    let o = [];
                                                    try {
                                                        o = el(s)
                                                    } catch {}
                                                    if (eo(s.getBoundingClientRect(), o)) return !0;
                                                    if (! function(e, t, i) {
                                                            let n = es(t);
                                                            if (!n) return !1;
                                                            let s = n.getBoundingClientRect(),
                                                                o = window.innerWidth,
                                                                r = window.innerHeight,
                                                                a = new DOMRect(Math.max(0, (o - s.width) / 2), Math.max(0, (r - s.height) / 2), s.width, s.height);
                                                            return e.style.display = "", null !== ea(e.getBoundingClientRect(), a, i)
                                                        }(e, t, i)) return n(`Preflight failed: tooltip would not fit after scrolling target "${t}" into view`), !1;
                                                    s.scrollIntoView({
                                                        behavior: "smooth",
                                                        block: "center",
                                                        inline: "center"
                                                    }), await new Promise(e => {
                                                        let t = s.getBoundingClientRect(),
                                                            i = 0,
                                                            n = Date.now();
                                                        setTimeout(function o() {
                                                            let r = s.getBoundingClientRect();
                                                            1 > Math.abs(r.top - t.top) && 1 > Math.abs(r.left - t.left) ? i++ : i = 0, t = r, i >= 2 || Date.now() - n > 1e3 ? e() : setTimeout(o, 50)
                                                        }, 50)
                                                    });
                                                    let r = s.getBoundingClientRect(),
                                                        a = [];
                                                    try {
                                                        a = el(s)
                                                    } catch {}
                                                    return eo(r, a)
                                                }(l, r, d)) return n(`Tooltip for instance ${t} skipped: target "${r}" is off-screen and cannot be scrolled into a valid position`), !1;
                                            let c = function(e, t, i, s) {
                                                let o = es(t);
                                                if (!o) return null;
                                                let r = null,
                                                    a = null,
                                                    l = !1,
                                                    d = [],
                                                    c = null;
                                                try {
                                                    d = el(o)
                                                } catch {}

                                                function u() {
                                                    let t;
                                                    if (l) return;
                                                    if (!o || !document.contains(o) || !document.contains(e)) return n("Tooltip or target element removed from DOM, cleaning up listeners"), g(), void s ? .onDetach ? .();
                                                    let r = o.getBoundingClientRect();
                                                    if (!eo(r, d)) return void(e.style.display = "none");
                                                    e.style.display = "";
                                                    let a = ea(e.getBoundingClientRect(), r, i);
                                                    a ? (e.style.position = "absolute", e.style.top = `${a.top+window.scrollY}px`, e.style.left = `${a.left+window.scrollX}px`, (t = e.querySelector(".gist-tooltip-arrow")) && (t.classList.remove("gist-arrow-top", "gist-arrow-bottom", "gist-arrow-left", "gist-arrow-right"), t.classList.add(en[a.position]), null !== a.arrowOffset ? "top" === a.position || "bottom" === a.position ? (t.style.left = `calc(50% + ${a.arrowOffset}px)`, t.style.removeProperty("top")) : (t.style.top = `calc(50% + ${a.arrowOffset}px)`, t.style.removeProperty("left")) : "top" === a.position || "bottom" === a.position ? (t.style.left = "50%", t.style.removeProperty("top")) : (t.style.top = "50%", t.style.removeProperty("left")))) : e.style.display = "none"
                                                }

                                                function p() {
                                                    null === r && (r = requestAnimationFrame(() => {
                                                        r = null, u()
                                                    }))
                                                }

                                                function g() {
                                                    if (!l) {
                                                        for (let e of (l = !0, c && (c.disconnect(), c = null), window.removeEventListener("scroll", p), window.removeEventListener("resize", p), d)) e.removeEventListener("scroll", p);
                                                        null !== r && (cancelAnimationFrame(r), r = null), null !== a && (cancelAnimationFrame(a), a = null)
                                                    }
                                                }
                                                if (u(), l) return null;
                                                for (let e of (window.addEventListener("scroll", p, {
                                                        passive: !0
                                                    }), window.addEventListener("resize", p, {
                                                        passive: !0
                                                    }), d)) e.addEventListener("scroll", p, {
                                                    passive: !0
                                                });
                                                try {
                                                    (c = new MutationObserver(() => {
                                                        null === a && (a = requestAnimationFrame(() => {
                                                            a = null, document.contains(o) || u()
                                                        }))
                                                    })).observe(document.body, {
                                                        childList: !0,
                                                        subtree: !0
                                                    })
                                                } catch {}
                                                return {
                                                    cleanup: g,
                                                    reposition: u
                                                }
                                            }(l, r, d, {
                                                onDetach: () => {
                                                    eh.delete(t);
                                                    let e = U(s);
                                                    e && e.parentNode ? .removeChild(e)
                                                }
                                            });
                                            if (c) {
                                                if ("none" !== l.style.display) {
                                                    let e = o.querySelector(".gist-tooltip-container");
                                                    return e ? (eh.set(t, c), e.classList.add("gist-visible"), !0) : (c.cleanup(), n(`Tooltip container not found for instance ${t}`), !1)
                                                }
                                                return c.cleanup(), n(`Tooltip for instance ${t} could not be positioned within the viewport, target "${r}" may be off-screen`), !1
                                            }
                                            return n(`Failed to position tooltip for instance ${t}, target "${r}" may not exist or no position fits the viewport`), !1
                                        }(t)) {
                                        if (tj.config.isPreviewSession && t.properties ? .gist ? .livePreview) {
                                            n(`Preview: tooltip positioning failed for "${e}", preview bar will remain active`), t.firstLoad = !1, t.isDisplayChange = !1;
                                            break
                                        }
                                        n(`Tooltip positioning failed for "${e}", emitting error and cleaning up`), tj.messageError(t), t.firstLoad = !1, t.isDisplayChange = !1, tx(t);
                                        break
                                    }
                                } else {
                                    let e;
                                    t.overlay ? function(e) {
                                        let t = B(e),
                                            i = document.querySelector("#gist-overlay");
                                        if (i) {
                                            i.classList.add("gist-visible");
                                            let n = document.querySelector(".gist-message");
                                            n && (e.position ? n.classList.add("gist-" + e.position) : n.classList.add("gist-center")), setTimeout(ey, 100), t.exitClick && setTimeout(() => {
                                                var t;
                                                let i;
                                                return t = e.instanceId ? ? "", void((i = document.querySelector("#gist-overlay")) && i.addEventListener("click", () => {
                                                    tj.dismissMessage(t)
                                                }))
                                            }, 1e3)
                                        } else ef()
                                    }(t) : (e = U(t.elementId)) && e.classList.add("gist-visible")
                                }
                                t.firstLoad && !t.isDisplayChange && (tj.messageShown(t), a.persistent ? n("Persistent message shown, skipping logging view") : await tE(t)), t.firstLoad = !1, t.isDisplayChange = !1
                            }
                            Y(e, t);
                            break
                        }
                    case "tap":
                        {
                            let e = i.gist.parameters.action,
                                n = i.gist.parameters.name;
                            if (tj.messageAction(t, e, n), i.gist.parameters.system && !a.persistent) {
                                await tv(t);
                                break
                            }
                            try {
                                let i = new URL(e);
                                if (i && "gist:" === i.protocol) switch (i.href.replace("gist://", "").split("?")[0]) {
                                    case "close":
                                        await ty(t), await tD(t), await tv(t), await tz();
                                        break;
                                    case "showMessage":
                                        {
                                            let e = i.searchParams.get("messageId"),
                                                t = i.searchParams.get("properties");
                                            if (e) {
                                                let i = t ? JSON.parse(atob(t)) : void 0;
                                                await tj.showMessage({
                                                    messageId: e,
                                                    properties: i
                                                })
                                            }
                                            break
                                        }
                                    case "loadPage":
                                        {
                                            let e = i.href.substring(i.href.indexOf("?url=") + 5);e && (e.startsWith("mailto:") || e.startsWith("https://") || e.startsWith("http://") || e.startsWith("/") ? window.location.href = e : window.location.href = window.location + e)
                                        }
                                }
                            } catch {}
                            break
                        }
                    case "changeMessageStep":
                        {
                            let e = i.gist.parameters.displaySettings,
                                s = i.gist.parameters.messageStepName;tj.config.isPreviewSession && s && t.properties ? .gist ? .livePreview && function(e, t) {
                                if (eK) return;
                                eJ = e;
                                let i = eG.find(t => t.stepName === e);
                                i ? eX = { ...i.displaySettings
                                } : t && (eX = { ...t
                                }), td()
                            }(s, e),
                            (a.persistent || e$(t)) && await async function(e, t, i) {
                                let s = await eq(e);
                                if (!s) return;
                                let r = d(s) || {},
                                    a = {
                                        stepName: void 0 !== t ? t : r.stepName,
                                        displaySettings: void 0 !== i ? i : r.displaySettings
                                    },
                                    l = new Date;
                                l.setDate(l.getDate() + 30), o(s, a, l), n(`Saved message state for queueId: ${e}`)
                            }(t.queueId ? ? "", s, e),
                            e && Z(t, e) && (n("Display settings changed, reloading message"), await tT(t), ee(t, e), await tP(t, s ? ? null));
                            break
                        }
                    case "routeChanged":
                        t.currentRoute = i.gist.parameters.route, t.renderStartTime = (new Date).getTime(), Y(e, t), n(`Route changed to: ${t.currentRoute}`);
                        break;
                    case "sizeChanged":
                        n(`Size Changed Width: ${i.gist.parameters.width} - Height: ${i.gist.parameters.height}`), "tooltip" === Q(t) ? function(e, t) {
                            let i = e.instanceId ? ? "",
                                n = ew(i),
                                s = document.getElementById(n);
                            if (s && t.height > 0) {
                                s.style.height = `${t.height}px`;
                                let e = eh.get(i);
                                e && e.reposition()
                            }
                        }(t, i.gist.parameters) : t.elementId && !t.shouldResizeHeight || function(e, t) {
                            let i = U(e.elementId ? e.elementId : ew(e.instanceId ? ? ""));
                            if (i) {
                                let n = i.style;
                                if (t.height > 0)
                                    if (t.height > window.innerHeight) {
                                        let i = 1 - (t.height / window.innerHeight - 1);
                                        e.shouldScale && i >= .4 ? (n.height = `${t.height}px`, n.transform = `translateX(-50%) translateY(-50%) scale(${i})`) : n.height = `${window.innerHeight}px`
                                    } else n.height = `${t.height}px`
                            }
                        }(t, i.gist.parameters);
                        break;
                    case "titleChanged":
                        var s;
                        let l;
                        n(`Overlay title changed to: ${i.gist.parameters.title}`), s = i.gist.parameters.title, (l = U(ew(e))) && (l.title = s);
                        break;
                    case "eventDispatched":
                        tj.events.dispatch("eventDispatched", {
                            name: i.gist.parameters.name,
                            payload: i.gist.parameters.payload
                        });
                        break;
                    case "error":
                    case "routeError":
                        tj.messageError(t), "tooltip" === Q(t) ? tx(t) : tj.overlayInstanceId ? await tI(!1, t) : tb(t)
                }
            }
        }
        async function tP(e, t) {
            e.isDisplayChange = !0, e.renderStartTime = (new Date).getTime();
            let i = Q(e),
                s = e.elementId || null;
            if ("tooltip" === i) return tj.overlayInstanceId === e.instanceId && (tj.overlayInstanceId = null), e.shouldScale = !1, e.shouldResizeHeight = !1, void tC(e, null, t);
            if (s) {
                let t = X(s);
                t && t.instanceId !== e.instanceId && (n(`Dismissing existing message at ${s} to make room for multi-step message`), await tv(t))
            }
            if (e.overlay) {
                tj.overlayInstanceId = e.instanceId ? ? null;
                let t = B(e);
                e.shouldScale = t.shouldScale, e.shouldResizeHeight = !0
            } else tj.overlayInstanceId = null, e.shouldScale = !1, e.shouldResizeHeight = !ec(s ? ? "");
            s && F.includes(s) && H(s), tC(e, s, t)
        }
        async function tT(e) {
            "tooltip" === Q(e) ? ev(e) : e.overlay ? await em() : e.elementId && ed(e.elementId)
        }
        async function tL(e, t, i) {
            i && Z(e, i) && (await tT(e), ee(e, i)), await tP(e, t ? ? null)
        }
        async function tM(e) {
            n(`Logging user message view locally for: ${e.queueId}`), eE(e) ? await async function(e) {
                n(`Marking broadcast ${e} as seen.`);
                let t = await ek();
                if (!t) return;
                let i = await eC(t, e);
                if (!i) return;
                let {
                    frequency: s
                } = i.properties.gist.broadcast, r = eP(t, e), a = eT(t, e), l = d(r) || 0;
                if (o(r, l + 1), 1 === s.count) o(a, !1), n(`Marked broadcast ${e} as seen.`);
                else {
                    let t = new Date;
                    t.setSeconds(t.getSeconds() + s.delay), o(a, !1, t), n(`Marked broadcast ${e} as seen, broadcast was seen ${l+1} times, next show date is ${t}.`)
                }
            }(e.queueId ? ? "") : await async function(e) {
                let t = await eA();
                if (!t) return;
                let i = d(t) ? ? [];
                i.push(e), o(t, i)
            }(e.queueId ? ? "")
        }
        async function tD(e) {
            eE(e) && (n(`Logging broadcast dismissed locally for: ${e.queueId}`), await async function(e) {
                n(`Marking broadcast ${e} as dismissed.`);
                let t = await ek();
                if (!t) return;
                let i = await eC(t, e);
                i && (!0 !== i.properties.gist.broadcast.frequency.ignoreDismiss ? (o(eT(t, e), !1), n(`Marked broadcast ${e} as dismissed and will not show again.`)) : n(`Broadcast ${e} is set to ignore dismiss.`))
            }(e.queueId ? ? ""), await eR(e.queueId ? ? ""))
        }
        let tN = "messageInboxUpdated";
        async function tA(e) {
            let t = await tq();
            if (!t) return;
            let i = new Date;
            i.setMinutes(i.getMinutes() + 60), o(t, e, i), tj.events.dispatch(tN, e)
        }
        async function t_() {
            let e = await tq();
            if (!e) return [];
            let t = d(e) ? ? [],
                i = new Date;
            return t.filter(e => !e.expiry || new Date(e.expiry) > i)
        }
        async function tq() {
            let e = await q();
            return e ? `gist.web.inbox.messages.${e}` : null
        }
        let tR = (e, t) => e().then(new Promise(e => setTimeout(e, t)).then(() => tR(e, t))),
            tO = !1,
            tW = null;
        async function tU() {
            tO ? await tz() : d(M) ? (n("Queue watcher started"), tO = !0, tR(() => new Promise(() => {
                !async function() {
                    if (x.hasActiveSSEConnection()) return !x.isSSEConnectionManagedBySDK() && tW && (n("Not the main instance, closing our SSE connection."), tH()), await tz();
                    tW && (n("SSE connection not active, closing it."), tH()), !x.useSSE() || A() ? await tF() : await async function() {
                        let e;
                        tH();
                        let t = null === (e = R()) ? (n("No user token available for SSE endpoint."), null) : x.GIST_QUEUE_REALTIME_API_ENDPOINT[tj.config.env ? ? "prod"] + `/api/v3/sse?userToken=${e}&siteId=${tj.config.siteId}&sessionId=${L()}`;
                        null === t ? (n("SSE endpoint not available, falling back to polling."), await tF()) : (n(`Starting SSE queue listener on ${t}`), tW = new EventSource(t), x.setActiveSSEConnection(), tW.addEventListener("connected", async e => {
                            try {
                                n("SSE connection received"), x.setUseSSEFlag(!0);
                                let t = JSON.parse(e.data);
                                t.heartbeat && (x.setSSEHeartbeat(t.heartbeat), n(`SSE heartbeat set to ${t.heartbeat} seconds`)), x.setActiveSSEConnection()
                            } catch (e) {
                                n(`Failed to parse SSE settings: ${e}`)
                            }
                            r(P), await tF()
                        }), tW.addEventListener("messages", async e => {
                            try {
                                let t = JSON.parse(e.data);
                                n("SSE message received"), await eD(t), await eS(t), await tz()
                            } catch (e) {
                                n(`Failed to parse SSE message: ${e}`), tH()
                            }
                        }), tW.addEventListener("inbox_messages", async e => {
                            try {
                                let t = JSON.parse(e.data);
                                n("SSE inbox messages received"), await tA(t)
                            } catch (e) {
                                n(`Failed to parse SSE inbox messages: ${e}`)
                            }
                        }), tW.addEventListener("error", async () => {
                            n("SSE error received"), tH()
                        }), tW.addEventListener("heartbeat", async () => {
                            n("SSE heartbeat received"), x.setActiveSSEConnection(), x.setUseSSEFlag(!0)
                        }))
                    }()
                }()
            }), 1e3)) : n("User token not setup, queue not started.")
        }
        async function tz() {
            let e = await async function() {
                    let e = await ek();
                    return e ? (d(e) ? ? []).filter(t => {
                        let {
                            frequency: i
                        } = t.properties.gist.broadcast, n = d(eT(e, t.queueId)) ? ? !0, s = d(eP(e, t.queueId)) || 0, o = 0 === i.count;
                        return n && (o || s < i.count)
                    }) : []
                }(),
                t = await async function() {
                    let e = await eN();
                    if (!e) return [];
                    let t = d(e) ? ? [],
                        i = await async function() {
                            let e = await eA();
                            return e ? d(e) ? ? [] : []
                        }();
                    return t.filter(e => !i.includes(e.queueId ? ? ""))
                }(),
                i = e.concat(t);
            for (let e of (n(`Messages in local queue: ${i.length}`), i.sort((e, t) => e.priority - t.priority))) await tB(e)
        }
        async function tB(e) {
            let t = B(e);
            if (t.hasRouteRule) {
                if (null == tj.currentRoute && "loading" === document.readyState) return n(`Deferring message ${e.queueId}, page not fully loaded`), !1;
                let i = new RegExp(t.routeRule),
                    s = new URL(window.location.href).pathname,
                    o = null != tj.currentRoute && i.test(tj.currentRoute),
                    r = tj.currentRoute !== s && i.test(s);
                if (!o && !r) return n(`Route ${s} (currentRoute: ${tj.currentRoute}) does not match rule: ${t.routeRule}`), !1
            }
            if (t.hasPosition && (e.position = t.position), t.hasTooltipPosition && (e.tooltipPosition = t.tooltipPosition), t.persistent || e$(e)) {
                let i = await async function(e) {
                    let t = await eq(e);
                    return t ? d(t) : null
                }(e.queueId ? ? "");
                i && (n(`Restoring saved state for queueId ${e.queueId}`), i.displaySettings && (ee(e, i.displaySettings), t = B(e)), e.savedStepName = i.stepName ? ? null)
            }
            if (t.persistent || e$(e) || !await async function(e) {
                    let t = await e_(e);
                    return !!t && null !== d(t)
                }(e.queueId ? ? "")) {
                let i = null;
                return t.isEmbedded ? !tj.config.isPreviewSession || !e.properties ? .gist ? .livePreview || U(t.elementId) || F.includes(t.elementId) ? i = th(e, t.elementId) : (n(`Preview: element "${t.elementId}" not found, showing as overlay so placement can be changed`), i = await tf(e)) : i = await tf(e), i && async function(e) {
                    let t = await e_(e);
                    t && o(t, !0, new Date(Date.now() + 5e3))
                }(e.queueId ? ? ""), null !== i
            }
            return n(`Not showing message with queueId ${e.queueId} because its already loading.`), !1
        }
        async function tF() {
            if (d(M))
                if (tj.isDocumentVisible)
                    if (null === d(P)) {
                        let e = await async function() {
                            var e, t;
                            let i, s, a, l;
                            if (k) return;
                            k = !0;
                            let c = d(M);
                            try {
                                let e, t = {
                                    "X-Gist-User-Anonymous": String(A()),
                                    "Content-Language": String((e = d(E), null !== e ? e : navigator.language))
                                };
                                i = await C().post(`/api/v4/users?sessionId=${L()}`, {}, {
                                    headers: t
                                })
                            } catch (t) {
                                let e = S(t);
                                e ? i = e : n(`Error getting user queue: ${t}`)
                            } finally {
                                k = !1
                            }
                            return c !== d(M) ? (n("User token changed, clearing queue next pull check."), void r(P)) : (e = i, $ = (s = e ? .headers ? .["x-gist-queue-polling-interval"]) && Number(s) > 0 ? Number(s) : Math.min(2 * $, 600), a = new Date((new Date).getTime() + 1e3 * $), o(P, $, a), t = i, l = "true" === t ? .headers ? .["x-cio-use-sse"] ? .toLowerCase(), x.setUseSSEFlag(l), i)
                        }();
                        if (e) {
                            if (200 === e.status || 204 === e.status) {
                                n("200 response, updating local store.");
                                let t = e.data,
                                    i = t ? .inAppMessages ? ? [],
                                    s = t ? .inboxMessages ? ? [];
                                eD(i), eS(i), tA(s)
                            } else 304 === e.status && n("304 response, using local store.");
                            await tz()
                        } else n("No response object returned while checking message queue.")
                    } else n("Next queue pull scheduled for later.");
            else n("Document not visible, skipping queue check.");
            else n("User token reset, skipping queue check.")
        }

        function tH(e = !1) {
            e && x.removeActiveSSEConnection(), (e || x.isSSEConnectionManagedBySDK()) && x.setUseSSEFlag(!1), tW && (n("Stopping SSE queue listener..."), tW.close(), tW = null)
        }
        class tj {
            static async setup(e) {
                this.initialized ? n("Gist SDK already initialized, skipping setup.") : (this.initialized = !0, this.events = new i, this.config = {
                    useAnonymousSession: e.useAnonymousSession ? ? !1,
                    siteId: e.siteId,
                    dataCenter: e.dataCenter,
                    env: e.env ? ? "prod",
                    logging: e.logging ? ? !1,
                    experiments: e.experiments ? ? !1
                }, this.currentMessages = [], eh.forEach(e => e.cleanup()), eh.clear(), document.querySelectorAll('[id^="gist-tooltip-"]').forEach(e => {
                    e.parentNode ? .removeChild(e)
                }), this.overlayInstanceId = null, this.currentRoute = null, this.isDocumentVisible = !0, this.config.isPreviewSession = function() {
                    let e = new URLSearchParams(window.location.search),
                        t = e.get(eU);
                    if (t) {
                        sessionStorage.setItem(s, String(!1)), tj.setUserToken(t), n(`Preview mode enabled with user token: ${t}`),
                            function() {
                                if (document.getElementById(eH)) return;
                                ! function() {
                                    if (document.getElementById(eF)) return;
                                    let e = document.createElement("style");
                                    e.id = eF, e.textContent = eW, document.head.appendChild(e)
                                }();
                                try {
                                    eY = "true" === sessionStorage.getItem(eB)
                                } catch {
                                    eY = !1
                                }
                                let e = e9("div", {
                                    id: eH
                                });
                                document.body.appendChild(e), td()
                            }();
                        let i = e.get(ez);
                        if (i) try {
                            let e = JSON.parse(atob(i)),
                                t = e.stepName || null,
                                n = e.displayType || null;
                            (t || n) && (e4 = t, e6 = n)
                        } catch {
                            n("Preview bar: failed to parse cioPreviewSettings")
                        }
                    }
                    return !a()
                }(), function() {
                    let e = l();
                    for (let t = e.length - 1; t >= 0; t--) {
                        let i = e.key(t);
                        i ? .startsWith("gist.") && d(i)
                    }
                }(), n(`Setup complete on ${this.config.env} environment.`), this.config.isPreviewSession || !this.config.useAnonymousSession || new URLSearchParams(location.search).has("ajs_uid") || _(), await tU(), "loading" === document.readyState && document.addEventListener("DOMContentLoaded", () => {
                    tz()
                }, {
                    once: !0
                }), document.addEventListener("visibilitychange", async () => {
                    "hidden" === document.visibilityState ? this.isDocumentVisible = !1 : (this.isDocumentVisible = !0, await tz())
                }, !1))
            }
            static async setCurrentRoute(e) {
                this.currentRoute = e, n(`Current route set to: ${e}`), await async function() {
                    if (0 !== tj.currentMessages.length)
                        for (let e of [...tj.currentMessages]) null == document.querySelector(`#gist-${e.instanceId}`) && (n(`Removing active message ${e.instanceId} that no longer exists after route change`), await tw(e))
                }(), await tz()
            }
            static async setUserToken(e, t) {
                var i;
                this.config.isPreviewSession || (void 0 === (i = t) && (i = new Date).setDate(i.getDate() + 30), o(M, e, i), A() && (r(P), r(D)), n(`Set user token "${e}" with expiry date set to ${i}`), tH(!0), await tU())
            }
            static setUserLocale(e) {
                o(E, e), n(`Set user locate to "${e}"`)
            }
            static setCustomAttribute(e, t) {
                return e && "string" == typeof e ? (ex.set(e, t), eI(), n(`Set custom attribute "${e}" to "${t}"`), !0) : (n(`Invalid key for custom attribute: ${e}`), !1)
            }
            static clearCustomAttributes() {
                ex.clear(), r(eb), n("Cleared all custom attributes")
            }
            static removeCustomAttribute(e) {
                if (!e || "string" != typeof e) return n(`Invalid key for custom attribute: ${e}`), !1;
                let t = ex.has(e);
                return ex.delete(e), ex.size > 0 ? eI() : r(eb), n(`Removed custom attribute "${e}"`), t
            }
            static async clearUserToken() {
                this.config.isPreviewSession || (O(), this.config.useAnonymousSession && _(), tH(!0), await tU())
            }
            static async dismissMessage(e) {
                let t = V(e);
                t && (await ty(t), await tD(t), await tv(t), await tz())
            }
            static async embedMessage(e, t) {
                let i = th(e, t);
                return i ? .instanceId ? ? null
            }
            static async showMessage(e) {
                let t = await tf(e);
                return t ? .instanceId ? ? null
            }
            static updateMessageDisplaySettings(e, t) {
                let i = V(e);
                return !!i && (i.displaySettings = t, eg(i), !0)
            }
            static messageShown(e) {
                n(`Message shown: ${e.messageId}`), this.events.dispatch("messageShown", e)
            }
            static messageDismissed(e) {
                null !== e && (n(`Message dismissed: ${e.messageId}`), this.events.dispatch("messageDismissed", e))
            }
            static messageError(e) {
                n(`Message error: ${e.messageId}`), this.events.dispatch("messageError", e)
            }
            static messageAction(e, t, i) {
                n(`Message action: ${e.currentRoute}, ${t} with name ${i} on ${e.instanceId}`), this.events.dispatch("messageAction", {
                    message: e,
                    action: t,
                    name: i
                })
            }
            static async getInboxUnopenedCount() {
                return (await t_()).filter(e => !e.opened).length
            }
            static async getInboxMessages() {
                return await t_()
            }
            static async updateInboxMessageOpenState(e, t) {
                return await async function(e, t) {
                    let i = await tq();
                    if (!i) return;
                    let s = await async function(e, t) {
                        try {
                            return await C()(`/api/v1/messages/${e}`, {
                                method: "PATCH",
                                body: JSON.stringify(t),
                                headers: {
                                    "Content-Type": "application/json"
                                }
                            })
                        } catch (e) {
                            return S(e)
                        }
                    }(e, {
                        opened: t
                    });
                    if (!s || s.status < 200 || s.status >= 300) {
                        let e = `Failed to mark inbox message opened: ${s?.status??"unknown error"}`;
                        throw n(e), Error(e)
                    }
                    let r = await t_(),
                        a = null,
                        l = r.map(i => {
                            if (i.queueId === e) {
                                let e = { ...i,
                                    opened: t
                                };
                                return a = e, e
                            }
                            return i
                        }),
                        d = new Date;
                    d.setMinutes(d.getMinutes() + 60), o(i, l, d), a && tj.events.dispatch("inboxMessageAction", {
                        message: a,
                        action: t ? "opened" : "unopened"
                    }), tj.events.dispatch(tN, await t_())
                }(e, t)
            }
            static async removeInboxMessage(e) {
                return await async function(e) {
                    let t = await tq();
                    if (!t) return;
                    let i = await W(e);
                    if (!i || i.status < 200 || i.status >= 300) {
                        let e = `Failed to remove inbox message: ${i?.status??"unknown error"}`;
                        throw n(e), Error(e)
                    }
                    let s = (await t_()).filter(t => t.queueId !== e),
                        r = new Date;
                    r.setMinutes(r.getMinutes() + 60), o(t, s, r), tj.events.dispatch(tN, await t_())
                }(e)
            }
        }
        return t.default
    })()
}, 877486, e => {
    "use strict";
    var t, i, n, s, o = e.i(274466);
    (t = n || (n = {})).MessageOpened = "in-app:message-opened", t.MessageDismissed = "in-app:message-dismissed", t.MessageError = "in-app:message-error", t.MessageAction = "in-app:message-action";
    var r = Object.values(n);
    (i = s || (s = {})).Metric = "Report Delivery Event", i.Content = "Report Content Event", i.Opened = "opened", i.Clicked = "clicked", i.ViewedContent = "viewed_content", i.ClickedContent = "clicked_content";
    var a = "in_app_content";

    function l(e, t) {
        return new CustomEvent(e, {
            detail: t
        })
    }
    var d = e.i(451637),
        c = "_cio";

    function u(e, t, i) {
        var n = this;
        return {
            sentAt: new Date(i.sentAt),
            expiresAt: i.expiry ? new Date(i.expiry) : void 0,
            messageId: i.queueId,
            opened: (null == i ? void 0 : i.opened) === !0,
            properties: i.properties,
            type: i.type || "",
            topics: i.topics || [],
            trackClick: function(t) {
                void 0 !== i.deliveryId && "" !== i.deliveryId && e.track(s.Metric, {
                    deliveryId: i.deliveryId,
                    metric: s.Clicked,
                    actionName: t
                })
            },
            markOpened: function() {
                return (0, o.__awaiter)(n, void 0, void 0, function() {
                    return (0, o.__generator)(this, function(e) {
                        switch (e.label) {
                            case 0:
                                return [4, t.updateInboxMessageOpenState(i.queueId, !0)];
                            case 1:
                                return e.sent(), [2]
                        }
                    })
                })
            },
            markUnopened: function() {
                return (0, o.__awaiter)(n, void 0, void 0, function() {
                    return (0, o.__generator)(this, function(e) {
                        switch (e.label) {
                            case 0:
                                return [4, t.updateInboxMessageOpenState(i.queueId, !1)];
                            case 1:
                                return e.sent(), [2]
                        }
                    })
                })
            },
            markDeleted: function() {
                return (0, o.__awaiter)(n, void 0, void 0, function() {
                    return (0, o.__generator)(this, function(e) {
                        switch (e.label) {
                            case 0:
                                return [4, t.removeInboxMessage(i.queueId)];
                            case 1:
                                return e.sent(), [2]
                        }
                    })
                })
            }
        }
    }

    function p(e, t, i) {
        return (0, o.__awaiter)(this, void 0, void 0, function() {
            var n, s;
            return (0, o.__generator)(this, function(o) {
                switch (o.label) {
                    case 0:
                        if (!(!(n = i) || !Array.isArray(n))) return [3, 2];
                        return [4, e.getInboxMessages()];
                    case 1:
                        n = o.sent(), o.label = 2;
                    case 2:
                        if (!n || !Array.isArray(n)) return [2, []];
                        if (n = n.slice().sort(function(e, t) {
                                return new Date(t.sentAt).getTime() - new Date(e.sentAt).getTime()
                            }), 0 === t.length) return [2, n.filter(function(e) {
                            var t = e.topics;
                            return !t || 0 === t.length || !t.some(function(e) {
                                return e.startsWith(c)
                            })
                        })];
                        return s = t.some(function(e) {
                            return e.startsWith(c)
                        }), [2, n.filter(function(e) {
                            var i = e.topics;
                            return !(!i || 0 === i.length || !s && i.some(function(e) {
                                return e.startsWith(c)
                            })) && i.some(function(e) {
                                return t.includes(e)
                            })
                        })]
                }
            })
        })
    }

    function g(e) {
        var t, i = this,
            c = !1,
            g = !1,
            m = new EventTarget;

        function f() {
            return (0, o.__awaiter)(this, void 0, void 0, function() {
                var e;
                return (0, o.__generator)(this, function(i) {
                    switch (i.label) {
                        case 0:
                            if (!(e = t.user().anonymousId())) return [3, 2];
                            return [4, d.default.setCustomAttribute("cio_anonymous_id", e)];
                        case 1:
                            i.sent(), i.label = 2;
                        case 2:
                            return [2]
                    }
                })
            })
        }

        function h(e) {
            return (0, o.__awaiter)(this, void 0, void 0, function() {
                return (0, o.__generator)(this, function(t) {
                    switch (t.label) {
                        case 0:
                            return [4, d.default.clearUserToken()];
                        case 1:
                            return t.sent(), [4, d.default.clearCustomAttributes()];
                        case 2:
                            return t.sent(), [4, f()];
                        case 3:
                            return t.sent(), [2, e]
                    }
                })
            })
        }

        function v(e) {
            return (0, o.__awaiter)(this, void 0, void 0, function() {
                var i;
                return (0, o.__generator)(this, function(n) {
                    switch (n.label) {
                        case 0:
                            if (!c) return [2, e];
                            if (!("string" == typeof(i = t.user().id()) && i.length > 0)) return [3, 2];
                            return [4, d.default.setUserToken(i)];
                        case 1:
                            return n.sent(), [3, 4];
                        case 2:
                            return [4, d.default.clearUserToken()];
                        case 3:
                            n.sent(), n.label = 4;
                        case 4:
                            return [2, e]
                    }
                })
            })
        }
        return {
            name: "Customer.io In-App Plugin",
            type: "before",
            version: "0.0.1",
            isLoaded: function() {
                return g
            },
            load: function(w, y) {
                return (0, o.__awaiter)(i, void 0, void 0, function() {
                    return (0, o.__generator)(this, function(i) {
                        switch (i.label) {
                            case 0:
                                if (t = y, null == e.siteId || "" === e.siteId) return console.error("[Customer.io In-App Plugin] ".concat("siteId is required. Can't initialize.")), [2, w];
                                return [4, f()];
                            case 1:
                                return i.sent(), [4, d.default.setup({
                                    siteId: e.siteId,
                                    env: e._env ? e._env : "prod",
                                    logging: e._logging,
                                    useAnonymousSession: e.anonymousInApp
                                })];
                            case 2:
                                return i.sent(), c = !0, [4, v(w)];
                            case 3:
                                return i.sent(), c && !g && (t.on("reset", h), e.events && (r.forEach(function(t) {
                                    m.addEventListener(t, null == e ? void 0 : e.events)
                                }), ["messageDismissed", "messageError"].forEach(function(e) {
                                    d.default.events.on(e, function(t) {
                                        var i, s;
                                        m.dispatchEvent(l(function(e) {
                                            switch (e) {
                                                case "messageShown":
                                                    return n.MessageOpened;
                                                case "messageDismissed":
                                                    return n.MessageDismissed;
                                                case "messageError":
                                                    return n.MessageError;
                                                case "messageAction":
                                                    return n.MessageAction;
                                                default:
                                                    return ""
                                            }
                                        }(e), {
                                            messageId: t.messageId,
                                            deliveryId: null == (s = null == (i = t.properties) ? void 0 : i.gist) ? void 0 : s.campaignId
                                        }))
                                    })
                                })), d.default.events.on("messageShown", function(i) {
                                    var o, r, c, u, p, g, f, h, v, w, y, b = null == (r = null == (o = null == i ? void 0 : i.properties) ? void 0 : o.gist) ? void 0 : r.campaignId;
                                    if (e.events && m.dispatchEvent(l(n.MessageOpened, {
                                            messageId: null == i ? void 0 : i.messageId,
                                            deliveryId: b,
                                            message: {
                                                dismiss: function() {
                                                    d.default.dismissMessage(null == i ? void 0 : i.instanceId)
                                                }
                                            }
                                        })), void 0 !== b && "" !== b) return void t.track(s.Metric, {
                                        deliveryId: b,
                                        metric: s.Opened
                                    });
                                    var x = null == (p = null == (u = null == (c = null == i ? void 0 : i.properties) ? void 0 : c.gist) ? void 0 : u.broadcast) ? void 0 : p.broadcastIdInt;
                                    if (x || (x = null == (h = null == (f = null == (g = null == i ? void 0 : i.properties) ? void 0 : g.gist) ? void 0 : f.broadcast) ? void 0 : h.broadcastId), x) {
                                        var I = null == (y = null == (w = null == (v = null == i ? void 0 : i.properties) ? void 0 : v.gist) ? void 0 : w.broadcast) ? void 0 : y.templateId;
                                        t.track(s.Content, {
                                            actionType: s.ViewedContent,
                                            contentId: x,
                                            templateId: I,
                                            contentType: a
                                        })
                                    }
                                }), d.default.events.on("inboxMessageAction", function(e) {
                                    var i, n, o, r;
                                    (null == e ? void 0 : e.message) && (null == e ? void 0 : e.action) !== "" && (i = t, n = e.message, o = e.action, r = null == n ? void 0 : n.deliveryId, "opened" === o && void 0 !== r && "" !== r && i.track(s.Metric, {
                                        deliveryId: n.deliveryId,
                                        metric: s.Opened
                                    }))
                                }), d.default.events.on("messageAction", function(i) {
                                    var o, r, c, u, p, g, f, h, v, w, y, b, x, I, S, C = null == (c = null == (r = null == (o = null == i ? void 0 : i.message) ? void 0 : o.properties) ? void 0 : r.gist) ? void 0 : c.campaignId;
                                    if (e.events && m.dispatchEvent(l(n.MessageAction, {
                                            messageId: i.message.messageId,
                                            deliveryId: C,
                                            action: i.action,
                                            name: i.name,
                                            actionName: i.name,
                                            actionValue: i.action,
                                            message: {
                                                dismiss: function() {
                                                    d.default.dismissMessage(i.message.instanceId)
                                                }
                                            }
                                        })), "gist://close" !== i.action) {
                                        if (void 0 !== C && "" !== C) return void t.track(s.Metric, {
                                            deliveryId: C,
                                            metric: s.Clicked,
                                            actionName: i.name,
                                            actionValue: i.action
                                        });
                                        var E = null == (f = null == (g = null == (p = null == (u = null == i ? void 0 : i.message) ? void 0 : u.properties) ? void 0 : p.gist) ? void 0 : g.broadcast) ? void 0 : f.broadcastIdInt;
                                        if (E || (E = null == (y = null == (w = null == (v = null == (h = null == i ? void 0 : i.message) ? void 0 : h.properties) ? void 0 : v.gist) ? void 0 : w.broadcast) ? void 0 : y.broadcastId), E) {
                                            var $ = null == (S = null == (I = null == (x = null == (b = null == i ? void 0 : i.message) ? void 0 : b.properties) ? void 0 : x.gist) ? void 0 : I.broadcast) ? void 0 : S.templateId;
                                            t.track(s.Content, {
                                                actionType: s.ClickedContent,
                                                contentId: E,
                                                templateId: $,
                                                contentType: a,
                                                actionName: i.name,
                                                actionValue: i.action
                                            })
                                        }
                                    }
                                }), d.default.events.on("eventDispatched", function(e) {
                                    var i, n, s;
                                    if ("analytics:track" === e.name) {
                                        var o = null == (i = e.payload) ? void 0 : i.event;
                                        if (void 0 === o || "" === o) return;
                                        t.track(o, null == (n = e.payload) ? void 0 : n.properties, null == (s = e.payload) ? void 0 : s.options)
                                    }
                                })), y.inbox = function() {
                                    for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
                                    if (!g) throw Error("Customer.io In-App Plugin is not loaded yet. Ensure the plugin is initialized before calling inbox().");
                                    return function(e, t, i) {
                                        var n = this;
                                        return {
                                            total: function() {
                                                return (0, o.__awaiter)(n, void 0, void 0, function() {
                                                    return (0, o.__generator)(this, function(e) {
                                                        switch (e.label) {
                                                            case 0:
                                                                return [4, p(t, i, null)];
                                                            case 1:
                                                                return [2, e.sent().length]
                                                        }
                                                    })
                                                })
                                            },
                                            totalUnopened: function() {
                                                return (0, o.__awaiter)(n, void 0, void 0, function() {
                                                    return (0, o.__generator)(this, function(e) {
                                                        switch (e.label) {
                                                            case 0:
                                                                return [4, p(t, i, null)];
                                                            case 1:
                                                                return [2, e.sent().filter(function(e) {
                                                                    return (null == e ? void 0 : e.opened) !== !0
                                                                }).length]
                                                        }
                                                    })
                                                })
                                            },
                                            messages: function() {
                                                return (0, o.__awaiter)(n, void 0, void 0, function() {
                                                    return (0, o.__generator)(this, function(n) {
                                                        switch (n.label) {
                                                            case 0:
                                                                return [4, p(t, i, null)];
                                                            case 1:
                                                                return [2, n.sent().map(function(i) {
                                                                    return u(e, t, i)
                                                                })]
                                                        }
                                                    })
                                                })
                                            },
                                            onUpdates: function(s) {
                                                var r = function(r) {
                                                    return (0, o.__awaiter)(n, void 0, void 0, function() {
                                                        return (0, o.__generator)(this, function(n) {
                                                            switch (n.label) {
                                                                case 0:
                                                                    return n.trys.push([0, 2, , 3]), [4, p(t, i, r)];
                                                                case 1:
                                                                    return s(n.sent().map(function(i) {
                                                                        return u(e, t, i)
                                                                    })), [3, 3];
                                                                case 2:
                                                                    return console.error("Error processing inbox updates:", n.sent()), [3, 3];
                                                                case 3:
                                                                    return [2]
                                                            }
                                                        })
                                                    })
                                                };
                                                return t.events.on("messageInboxUpdated", r),
                                                    function() {
                                                        t.events.off("messageInboxUpdated", r)
                                                    }
                                            }
                                        }
                                    }(y, d.default, e)
                                }, g = !0, [2, Promise.resolve()]
                        }
                    })
                })
            },
            identify: v,
            page: function(e) {
                if (!g) return e;
                var t, i, n, s, o, r = null != (n = null == (i = null == (t = e.event) ? void 0 : t.properties) ? void 0 : i.name) ? n : null == (o = null == (s = e.event) ? void 0 : s.properties) ? void 0 : o.url;
                return "string" == typeof r && r.length > 0 && d.default.setCurrentRoute(r), e
            },
            unload: function() {
                e.events && r.forEach(function(t) {
                    m.removeEventListener(t, null == e ? void 0 : e.events)
                })
            }
        }
    }
    e.s(["InAppPlugin", 0, g], 137185), e.i(137185), e.s(["InAppEvents", 0, n, "InAppPlugin", 0, g], 877486)
}]);

//# debugId=96b64554-2322-daa7-77d3-dc5b04cfa6f9