customerio-gist-web 3.22.2 → 3.22.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gist.min.js +1 -1
- package/package.json +1 -1
package/dist/gist.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Gist=e():t.Gist=e()}(this,()=>(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{default:()=>oi});class n{constructor(){this.callbacks={}}on(t,e){const n=this.callbacks[t];n?n.push(e):this.callbacks[t]=[e]}off(t,e){const n=this.callbacks[t];if(!n)return;if(!e)return void delete this.callbacks[t];const i=n.indexOf(e);-1!==i&&n.splice(i,1),0===n.length&&delete this.callbacks[t]}dispatch(t,e){const n=this.callbacks[t];n&&[...n].forEach(n=>{try{n(e)}catch(e){console.warn(`[Gist] Error in "${t}" event listener:`,e)}})}}function i(t){oi.config&&oi.config.logging&&console.log(`Gist: ${t}`)}const o="gist.web.isPersistingSession";function s(t,e,n=null){let i=n;i||(i=new Date,i.setDate(i.getDate()+365));const o={value:e,expiry:i};d().setItem(t,JSON.stringify(o))}function a(t){return c(t)}function r(t){d().removeItem(t)}function l(){const t=sessionStorage.getItem(o);return null===t?(sessionStorage.setItem(o,"true"),!0):"true"===t}function d(){return l()?localStorage:sessionStorage}function c(t){if(!t)return null;try{const e=d().getItem(t);if(!e)return null;const n=JSON.parse(e);if(!n.expiry)return n.value;if(t.startsWith("gist.")){const e=new Date,i=new Date(n.expiry),o=t.startsWith("gist.web.message.broadcasts")&&!t.endsWith("shouldShow")&&!t.endsWith("numberOfTimesShown")||t.startsWith("gist.web.message.user")&&!t.endsWith("seen")&&!t.endsWith("state"),s=new Date(e.getTime()+366e4);if(o&&i.getTime()>s.getTime())return r(t),null;if(e.getTime()>i.getTime())return r(t),null}return n.value}catch(e){i(`Error checking key ${t} for expiry: ${e}`)}return null}var p,u=new Uint8Array(16);function g(){if(!p&&!(p="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return p(u)}const m=/^(?:[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 f=[],h=0;h<256;++h)f.push((h+256).toString(16).substr(1));const b=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(f[t[e+0]]+f[t[e+1]]+f[t[e+2]]+f[t[e+3]]+"-"+f[t[e+4]]+f[t[e+5]]+"-"+f[t[e+6]]+f[t[e+7]]+"-"+f[t[e+8]]+f[t[e+9]]+"-"+f[t[e+10]]+f[t[e+11]]+f[t[e+12]]+f[t[e+13]]+f[t[e+14]]+f[t[e+15]]).toLowerCase();if(!function(t){return"string"==typeof t&&m.test(t)}(n))throw TypeError("Stringified UUID is invalid");return n},y=function(t,e,n){var i=(t=t||{}).random||(t.rng||g)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,e){n=n||0;for(var o=0;o<16;++o)e[n+o]=i[o];return e}return b(i)},v="gist.web.inbox.enabled",w="gist.web.userQueueUseSSE",x="gist.web.activeSSEConnection";let S,I=30;const C={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:()=>(S||(S=y()),S),useSSE:()=>a(w)??!1,setUseSSEFlag(t){s(w,t,new Date((new Date).getTime()+6e4)),i(`Set user uses SSE to "${t}"`)},removeActiveSSEConnection(){r(x)},setActiveSSEConnection(){s(x,C.getSdkId(),new Date((new Date).getTime()+C.getSSEHeartbeat()))},hasActiveSSEConnection:()=>a(x)??!1,isSSEConnectionManagedBySDK:()=>a(x)===C.getSdkId(),getSSEHeartbeat:()=>1e3*(I+5),setSSEHeartbeat(t){t&&t>0&&(I=t)},inboxEnabled:()=>a(v)??!1,setInboxEnabledFlag(t){s(v,t,new Date((new Date).getTime()+36e5)),i(`Set inbox enabled to "${t}"`)}};function $(t){return null!==t&&"object"==typeof t&&"response"in t}function k(t){return $(t)?t.response:void 0}function E(){const t=C.GIST_QUEUE_API_ENDPOINT[oi.config.env??"prod"],e={"X-CIO-Site-Id":oi.config.siteId,"X-CIO-Client-Platform":"web"},n=Wt();async function i(n,i={}){const o=t+n,s=new AbortController,a=setTimeout(()=>s.abort(),5e3);try{const t=await fetch(o,{method:i.method||"GET",headers:{...e,...i.headers||{}},body:i.method&&"GET"!==i.method.toUpperCase()?i.body:void 0,signal:s.signal});clearTimeout(a);const n=t.headers.get("content-type")?.includes("application/json"),r=n?await t.json():await t.text(),l=Object.fromEntries(t.headers.entries());if(t.status<200||t.status>=400)throw function(t){return Object.assign(new Error,{response:t})}({status:t.status,data:r,headers:l});return{status:t.status,headers:l,data:r}}catch(t){if(clearTimeout(a),$(t))throw t;if(t instanceof Error)throw Object.assign(t,{response:{status:0,data:t.message||"Unknown error",headers:{}}});throw t}}return null!=n&&(e["X-Gist-Encoded-User-Token"]=n),i.post=(t,e={},n={})=>i(t,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json",...n.headers||{}}}),i}const j="gist.web.userLocale";function L(){const t=a(j);return null!==t?t:navigator.language}const T="gist.web.branding";async function P(){if(null!==a(T))return void i("Branding already cached.");const t=await async function(){try{return await E()("/api/v1/branding")}catch(t){return k(t)}}();if(t&&t.status>=200&&t.status<300){const e=new Date;e.setMinutes(e.getMinutes()+10),s(T,t.data,e),i("Branding fetched and cached.")}}function D(){return a(T)}const N="gist.web.templates";async function M(){if(null!==a(N))return void i("Templates already cached.");const t=await async function(){try{return await E()("/api/v1/templates")}catch(t){return k(t)}}();if(t&&t.status>=200&&t.status<300){const e=new Date;e.setMinutes(e.getMinutes()+60),s(N,t.data,e),i("Templates fetched and cached.")}}function A(){return a(N)}function R(t){try{return(document.getElementById(t)??document.querySelector(t))||null}catch{return null}}function q(t,e={}){const n=document.createElement(t);for(const[t,i]of Object.entries(e))n[t]=i;return n}function z(t,e){if(document.getElementById(t))return;const n=document.createElement("style");n.id=t,n.textContent=e,document.head.appendChild(n)}function W(t){document.body?document.body.appendChild(t):document.addEventListener("DOMContentLoaded",()=>document.body.appendChild(t),{once:!0})}async function _(t){try{return await E().post(`/api/v1/logs/queue/${t}`)}catch(t){return k(t)}}const O="messageInboxUpdated",B="inboxMessageAction";async function U(t){const e=await G();if(!e)return;const n=new Date;n.setMinutes(n.getMinutes()+60),s(e,t,n),oi.events.dispatch(O,t)}async function H(){const t=await G();if(!t)return[];const e=a(t)??[],n=new Date;return e.filter(t=>!t.expiry||new Date(t.expiry)>n)}async function F(t,e){const n=await G();if(!n)return;const o=await async function(t,e){try{return await E()(`/api/v1/messages/${t}`,{method:"PATCH",body:JSON.stringify(e),headers:{"Content-Type":"application/json"}})}catch(t){return k(t)}}(t,{opened:e});if(!o||o.status<200||o.status>=300){const t=`Failed to mark inbox message opened: ${o?.status??"unknown error"}`;throw i(t),new Error(t)}const a=await H();let r=null;const l=a.map(n=>{if(n.queueId===t){const t={...n,opened:e};return r=t,t}return n}),d=new Date;if(d.setMinutes(d.getMinutes()+60),s(n,l,d),r){const t=e?"opened":"unopened";oi.events.dispatch(B,{message:r,action:t})}oi.events.dispatch(O,await H())}async function V(t){const e=await G();if(!e)return;const n=await H(),o=n.find(e=>e.queueId===t)??null,a=n.filter(e=>e.queueId!==t),r=new Date;r.setMinutes(r.getMinutes()+60),s(e,a,r),o&&oi.events.dispatch(B,{message:o,action:"dismissed"}),oi.events.dispatch(O,await H());const l=await _(t);(!l||l.status<200||l.status>=300)&&i(`Failed to log inbox message view: ${l?.status??"unknown error"}`)}async function G(){const t=await zt();return t?`gist.web.inbox.messages.${t}`:null}const X="jist",J={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},Q={start:"flex-start",end:"flex-end",center:"center","space-between":"space-between","space-around":"space-around","space-evenly":"space-evenly"};function Y(t){return"number"==typeof t?`${t}px`:"fill"===t?"100%":t}function K(t){try{return new Date(t).toLocaleDateString(navigator.language)}catch{return t}}class Z{#t;#e;#n;#i=0;constructor({formatDate:t,onAction:e,templates:n}={}){this.#t=t||K,this.#e=e||null,this.#n=n||{}}render(t,e){if(!t)return null;switch(t.type){case"layout":return this.#o(t,e);case"action":return this.#s(t,e);case"heading":return this.#a(t,e);case"text":return this.#r("p",t,e);case"date":return this.#l(t,e);case"button":return this.#d(t,e);case"image":return this.#c(t,e);case"dynamicLayout":return this.#p(t,e);case"template":return this.#u(t,e);default:return null}}#o(t,e){const n=document.createElement("div");n.style.display="flex",n.style.flexDirection="horizontal"===t.direction?"row":"column",t.gap&&(n.style.gap=Y(t.gap)),t.align&&(n.style.alignItems=J[t.align]||t.align),t.justify&&(n.style.justifyContent=Q[t.justify]||t.justify),t.margin&&(t.margin.top&&(n.style.marginTop=Y(t.margin.top)),t.margin.right&&(n.style.marginRight=Y(t.margin.right)),t.margin.bottom&&(n.style.marginBottom=Y(t.margin.bottom)),t.margin.left&&(n.style.marginLeft=Y(t.margin.left)));const i="horizontal"===t.direction,o=i&&(!t.justify||"start"===t.justify),s=i||"center"!==t.align?i||"end"!==t.align?"":"right":"center";for(const i of t.children||[]){const t=this.render(i,e);t&&(o&&"layout"===i.type&&(t.style.flex="1",t.style.minWidth="0"),s&&(t.style.textAlign=s),n.appendChild(t))}return n}#s(t,e){const n=t.name||"action",i=document.createElement("div");this.#g(i,"action",n),i.setAttribute("role","button"),i.setAttribute("tabindex","0");for(const n of t.children||[]){const t=this.render(n,e);t&&i.appendChild(t)}const o=e[n],s=t.meta||null;if(this.#e){const t=this.#e,e=e=>{e.stopPropagation(),t({component:"action",name:n,data:o,meta:s,event:e})};i.addEventListener("click",e),i.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),e(t))})}return i}#a(t,e){const n=t.variant||"h3";return this.#r(n,t,e,n)}#r(t,e,n,i){const o=e.name||e.type,s=document.createElement(t);return this.#g(s,e.type,o,i||e.variant),s.textContent=n[o]||"",s}#l(t,e){const n=t.name||"date",i=document.createElement("time");this.#g(i,"date",n,t.variant);const o=e[n];return i.textContent=o?this.#t(o,n):"",i}#d(t,e){const n=t.name||"button",i=e[n];if(!i)return null;const o=document.createElement("button");this.#g(o,"button",n,t.variant),o.textContent=i.label,i.disabled&&(o.disabled=!0);const s=t.meta||null;return o.addEventListener("click",t=>{t.stopPropagation(),this.#e&&this.#e({component:"button",name:n,data:i,meta:s,event:t})}),o}#c(t,e){const n=t.name||"image",i=e[n];if(!i)return null;const o=document.createElement("div");this.#g(o,"image",n,t.variant),o.style.overflow="hidden";const s=document.createElement("img");return s.src=i,s.alt=e.title||"",s.style.display="block",t.width&&(s.style.width=Y(t.width)),t.height&&(s.style.height=Y(t.height)),t.objectFit&&(s.style.objectFit=t.objectFit),t.borderRadius&&(s.style.borderRadius=Y(t.borderRadius)),o.appendChild(s),o}#p(t,e){const n=e[t.name];if(!Array.isArray(n))return null;const i=document.createElement("div"),o=t.direction||"vertical";i.style.display="flex",i.style.flexDirection="horizontal"===o?"row":"column",t.gap&&(i.style.gap=Y(t.gap)),t.align&&(i.style.alignItems=J[t.align]||t.align),t.justify&&(i.style.justifyContent=Q[t.justify]||t.justify),t.margin&&(t.margin.top&&(i.style.marginTop=Y(t.margin.top)),t.margin.right&&(i.style.marginRight=Y(t.margin.right)),t.margin.bottom&&(i.style.marginBottom=Y(t.margin.bottom)),t.margin.left&&(i.style.marginLeft=Y(t.margin.left)));for(const e of n){const n="object"==typeof e&&null!==e?e:{},o=this.render(t.template,n);o&&i.appendChild(o)}return i}#u(t,e){const n=this.#n[t.name];if(!n||this.#i>=10)return null;this.#i++;const i=this.render(n.root,e);return this.#i--,i}#g(t,e,n,i){t.classList.add(`${X}__${e}`),i&&t.classList.add(`${X}__${e}--${i}`),n!==e&&t.classList.add(`${X}__${n}`)}}var tt;const et=new Set(["fontWeight","maxLines","lineHeight","opacity"]),nt=new Set(["lineHeight","letterSpacing"]),it={"text-font-size":"font-size","text-font-weight":"font-weight","text-font-family":"font-family","text-color":"color","text-line-height":"line-height","text-letter-spacing":"letter-spacing","text-max-lines":"-webkit-line-clamp","background-color":"background-color","border-width":"border-width","border-color":"border-color","border-radius":"border-radius","padding-top":"padding-top","padding-right":"padding-right","padding-bottom":"padding-bottom","padding-left":"padding-left","margin-top":"margin-top","margin-right":"margin-right","margin-bottom":"margin-bottom","margin-left":"margin-left","min-width":"min-width","min-height":"min-height"},ot=["shadow-offset-x","shadow-offset-y","shadow-blur","shadow-color"],st={"shadow-offset-x":"0","shadow-offset-y":"0","shadow-blur":"0","shadow-color":"transparent"},at={heading:new Set(["text","padding","margin"]),text:new Set(["text","padding","margin"]),date:new Set(["text","padding","margin"]),button:new Set(["text","background","border","shadow","padding","margin","minWidth","minHeight","states"]),image:new Set(["border","padding","margin"])},rt=["hover","active","disabled"],lt=[["background-color","background-color"],["color","text-color"]];class dt extends HTMLElement{static observedAttributes=["template","data","theme","mode"];static#m=!1;static#f=null;static#h=0;static#b=new Map;static#y(){if(tt.#m)return;if(tt.#m=!0,document.querySelector("style[data-jist-base]"))return;const t=document.createElement("style");t.setAttribute("data-jist-base",""),t.textContent="/* ═══════════════════════════════════════════\n Jist Template Styles\n ═══════════════════════════════════════════ */\n\n/* ── Host Element ───────────────────────── */\n\njist-template {\n display: block;\n}\n\n/* ── Base Reset ─────────────────────────── */\n\n.jist__heading,\n.jist__text,\n.jist__date {\n margin: 0;\n padding: 0;\n}\n\n/* ── Heading ────────────────────────────── */\n\n.jist__heading {\n font-size: var(--jist-heading-text-font-size, 16px);\n font-weight: var(--jist-heading-text-font-weight, 600);\n color: var(--jist-heading-text-color, #000000);\n font-family: var(--jist-heading-text-font-family, inherit);\n line-height: var(--jist-heading-text-line-height, 1.3);\n letter-spacing: var(--jist-heading-text-letter-spacing, normal);\n padding-top: var(--jist-heading-padding-top, 0);\n padding-right: var(--jist-heading-padding-right, 0);\n padding-bottom: var(--jist-heading-padding-bottom, 0);\n padding-left: var(--jist-heading-padding-left, 0);\n margin-top: var(--jist-heading-margin-top, 0);\n margin-right: var(--jist-heading-margin-right, 0);\n margin-bottom: var(--jist-heading-margin-bottom, 0);\n margin-left: var(--jist-heading-margin-left, 0);\n /* Line clamping — active when --jist-heading-text-max-lines is set */\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: var(--jist-heading-text-max-lines, none);\n overflow: hidden;\n}\n\n/* ── Text ───────────────────────────────── */\n\n.jist__text {\n font-size: var(--jist-text-text-font-size, 14px);\n font-weight: var(--jist-text-text-font-weight, 400);\n color: var(--jist-text-text-color, #000000);\n font-family: var(--jist-text-text-font-family, inherit);\n line-height: var(--jist-text-text-line-height, 1.5);\n letter-spacing: var(--jist-text-text-letter-spacing, normal);\n padding-top: var(--jist-text-padding-top, 0);\n padding-right: var(--jist-text-padding-right, 0);\n padding-bottom: var(--jist-text-padding-bottom, 0);\n padding-left: var(--jist-text-padding-left, 0);\n margin-top: var(--jist-text-margin-top, 0);\n margin-right: var(--jist-text-margin-right, 0);\n margin-bottom: var(--jist-text-margin-bottom, 0);\n margin-left: var(--jist-text-margin-left, 0);\n /* Line clamping — active when --jist-text-text-max-lines is set */\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: var(--jist-text-text-max-lines, none);\n overflow: hidden;\n}\n\n/* ── Date ───────────────────────────────── */\n\n.jist__date {\n font-size: var(--jist-date-text-font-size, 12px);\n font-weight: var(--jist-date-text-font-weight, 400);\n color: var(--jist-date-text-color, #000000);\n font-family: var(--jist-date-text-font-family, inherit);\n line-height: var(--jist-date-text-line-height, 1.4);\n letter-spacing: var(--jist-date-text-letter-spacing, normal);\n padding-top: var(--jist-date-padding-top, 0);\n padding-right: var(--jist-date-padding-right, 0);\n padding-bottom: var(--jist-date-padding-bottom, 0);\n padding-left: var(--jist-date-padding-left, 0);\n margin-top: var(--jist-date-margin-top, 0);\n margin-right: var(--jist-date-margin-right, 0);\n margin-bottom: var(--jist-date-margin-bottom, 0);\n margin-left: var(--jist-date-margin-left, 0);\n}\n\n/* ── Button ─────────────────────────────── */\n\n.jist__button {\n appearance: none;\n -webkit-appearance: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n border: none;\n font-size: var(--jist-button-text-font-size, 14px);\n font-weight: var(--jist-button-text-font-weight, 500);\n color: var(--jist-button-text-color, #ffffff);\n font-family: var(--jist-button-text-font-family, inherit);\n line-height: var(--jist-button-text-line-height, 1);\n background-color: var(--jist-button-background-color, #4f46e5);\n border-width: var(--jist-button-border-width, 0);\n border-style: solid;\n border-color: var(--jist-button-border-color, transparent);\n border-radius: var(--jist-button-border-radius, 6px);\n box-shadow:\n var(--jist-button-shadow-offset-x, 0)\n var(--jist-button-shadow-offset-y, 0)\n var(--jist-button-shadow-blur, 0)\n var(--jist-button-shadow-color, transparent);\n padding-top: var(--jist-button-padding-top, 8px);\n padding-right: var(--jist-button-padding-right, 16px);\n padding-bottom: var(--jist-button-padding-bottom, 8px);\n padding-left: var(--jist-button-padding-left, 16px);\n margin-top: var(--jist-button-margin-top, 0);\n margin-right: var(--jist-button-margin-right, 0);\n margin-bottom: var(--jist-button-margin-bottom, 0);\n margin-left: var(--jist-button-margin-left, 0);\n min-width: var(--jist-button-min-width, 0);\n min-height: var(--jist-button-min-height, 0);\n transition: background-color 0.15s ease, color 0.15s ease,\n border-color 0.15s ease, box-shadow 0.15s ease;\n}\n\n.jist__button:hover {\n background-color: var(--jist-button-states-hover-background-color,\n var(--jist-button-background-color, #4338ca));\n color: var(--jist-button-states-hover-text-color,\n var(--jist-button-text-color, #ffffff));\n}\n\n.jist__button:active {\n background-color: var(--jist-button-states-active-background-color,\n var(--jist-button-background-color, #3730a3));\n color: var(--jist-button-states-active-text-color,\n var(--jist-button-text-color, #ffffff));\n}\n\n.jist__button:disabled {\n background-color: var(--jist-button-states-disabled-background-color,\n var(--jist-button-background-color, #c7d2fe));\n color: var(--jist-button-states-disabled-text-color,\n var(--jist-button-text-color, #a5b4fc));\n cursor: not-allowed;\n}\n\n/* ── Image ──────────────────────────────── */\n\n.jist__image {\n display: block;\n max-width: 100%;\n overflow: hidden;\n border-radius: var(--jist-image-border-radius, 0);\n padding-top: var(--jist-image-padding-top, 0);\n padding-right: var(--jist-image-padding-right, 0);\n padding-bottom: var(--jist-image-padding-bottom, 0);\n padding-left: var(--jist-image-padding-left, 0);\n margin-top: var(--jist-image-margin-top, 0);\n margin-right: var(--jist-image-margin-right, 0);\n margin-bottom: var(--jist-image-margin-bottom, 0);\n margin-left: var(--jist-image-margin-left, 0);\n}\n\n.jist__image img {\n border-radius: inherit;\n}\n\n/* ── Dark Mode Defaults ────────────────── */\n\n[data-jist-dark] .jist__heading { color: var(--jist-heading-text-color, #ffffff); }\n[data-jist-dark] .jist__text { color: var(--jist-text-text-color, #ffffff); }\n[data-jist-dark] .jist__date { color: var(--jist-date-text-color, #ffffff); }\n[data-jist-dark] .jist__button { color: var(--jist-button-text-color, #ffffff); }\n\n/* ── Action (clickable wrapper) ─────────── */\n\n.jist__action {\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n}\n\n.jist__action:focus-visible {\n outline: 2px solid var(--jist-button-background-color, #4f46e5);\n outline-offset: 2px;\n border-radius: 4px;\n}\n",document.head.appendChild(t)}#v=null;#w=null;#x=null;#S=null;#I="auto";#t=null;#e=null;#n={};#C=null;#$=null;get template(){return this.#w}set template(t){this.#w=t,this.#k()}get data(){return this.#x}set data(t){this.#x="string"==typeof t?JSON.parse(t):t,this.#k()}get theme(){return this.#S}set theme(t){this.#S="string"==typeof t?JSON.parse(t):t,this.#E(),this.#k()}get mode(){return this.#I}set mode(t){this.#I=t||"auto",this.#E()}get formatDate(){return this.#t}set formatDate(t){this.#t=t,this.#k()}get onAction(){return this.#e}set onAction(t){this.#e=t}get templates(){return this.#n}set templates(t){const e="string"==typeof t?JSON.parse(t):t||{},n={};for(const[t,i]of Object.entries(e)){if(t.startsWith("$"))continue;if(!Array.isArray(i))continue;const e=i.find(t=>"1"===t.version);e&&(n[t]=e)}this.#n=n,this.#k()}connectedCallback(){tt.#y(),this.#C=window.matchMedia("(prefers-color-scheme: dark)"),this.#$=()=>{"auto"===this.#I&&(this.#E(),this.#k())},this.#C.addEventListener("change",this.#$),this.#E(),this.#k()}disconnectedCallback(){this.#C&&this.#$&&this.#C.removeEventListener("change",this.#$),this.#j(),tt.#L()}attributeChangedCallback(t,e,n){if(e!==n)switch(t){case"template":this.#w=n||null,this.#k();break;case"data":this.#x=n?JSON.parse(n):null,this.#k();break;case"theme":this.#S=n?JSON.parse(n):null,this.#E(),this.#k();break;case"mode":this.#I=n||"auto",this.#E(),this.#k()}}#T(){return"dark"===this.#I||"light"!==this.#I&&(this.#C?.matches??!1)}#E(){if(!this.isConnected)return void(this.#S||(this.#j(),tt.#L()));if(this.#T()?this.setAttribute("data-jist-dark",""):this.removeAttribute("data-jist-dark"),!this.#S)return this.#j(),void tt.#L();const t=[];for(let e=0;e<this.style.length;e++)this.style[e].startsWith("--jist-")&&t.push(this.style[e]);if(t.forEach(t=>this.style.removeProperty(t)),this.#P(this.#S,"--jist"),this.#T()){const t=this.#S.modes?.dark;t&&this.#P(t,"--jist")}this.#D()}#P(t,e){for(const[n,i]of Object.entries(t)){if("modes"===n||n.startsWith("$"))continue;const t=`${e}-${n.replace(/([A-Z])/g,"-$1").toLowerCase()}`;if(null===i||"object"!=typeof i||Array.isArray(i)){if(null!=i&&""!==i){const e=0===i&&nt.has(n)?"normal":"number"!=typeof i||et.has(n)?String(i):`${i}px`;this.style.setProperty(t,e)}}else this.#P(i,t)}}#D(){const t=[],e=this.#S;if(!e)return;const n=e.modes?.dark;for(const i of Object.keys(at)){const o=e[i],s=n?.[i],a=at[i],r=new Set;for(const t of[o,s])if(t)for(const e of Object.keys(t))a.has(e)||e.startsWith("$")||r.add(e);for(const e of r){const n=o?.[e]??{},a=s?.[e]??{};t.push(this.#N(i,e,n,a))}}const i=t.join("\n");if(this.#j(),!i)return;let o=tt.#b.get(i);o||(o={id:tt.#h++,refs:0},tt.#b.set(i,o)),o.refs++,this.#v=i,this.setAttribute("data-jist-v",String(o.id)),tt.#L()}#j(){if(!this.#v)return;const t=tt.#b.get(this.#v);t&&(t.refs--,t.refs<=0&&tt.#b.delete(this.#v)),this.#v=null,this.removeAttribute("data-jist-v")}static#L(){if(0===tt.#b.size)return void(tt.#f&&(tt.#f.remove(),tt.#f=null));tt.#f||(tt.#f=document.createElement("style"),tt.#f.setAttribute("data-jist-variants",""),document.head.appendChild(tt.#f));const t=[];for(const[e,{id:n}]of tt.#b){const i=`[data-jist-v="${n}"]`;t.push(e.replace(/^(\.[a-z_-]+)/gm,`${i} $1`))}tt.#f.textContent=t.join("\n")}#N(t,e,n,i){const o=e.replace(/([A-Z])/g,"-$1").toLowerCase(),s=`.jist__${t}--${o}`,a=new Set,r=(t,e)=>{for(const[n,i]of Object.entries(t)){if("states"===n||n.startsWith("$"))continue;const t=n.replace(/([A-Z])/g,"-$1").toLowerCase(),o=e?`${e}-${t}`:t;null===i||"object"!=typeof i||Array.isArray(i)?a.add(o):r(i,o)}};r(n,""),r(i,"");const l=[];for(const e of a){const n=it[e];if(!n)continue;const i=`--jist-${t}-${o}-${e}`,s=`--jist-${t}-${e}`;l.push(` ${n}: var(${i}, var(${s}));`)}if("button"===t&&[...a].some(t=>t.startsWith("shadow-"))){const t=ot.map(t=>`var(--jist-button-${o}-${t}, var(--jist-button-${t}, ${st[t]}))`);l.push(` box-shadow: ${t.join(" ")};`)}let d=`${s} {\n${l.join("\n")}\n}`;if("button"===t&&(n.states||i.states))for(const t of rt){const e=n.states?.[t],a=i.states?.[t];if(!e&&!a)continue;const r=[];for(const[e,n]of lt){const i=`--jist-button-${o}-states-${t}-${n}`,s=`--jist-button-states-${t}-${n}`,a=`--jist-button-${o}-${n}`,l=`--jist-button-${n}`;r.push(` ${e}: var(${i}, var(${s}, var(${a}, var(${l}))));`)}d+=`\n${s}${"disabled"===t?":disabled":`:${t}`} {\n${r.join("\n")}\n}`}return d}#k(){if(!this.#w||!this.#x)return;if(!this.isConnected)return;const t=this.#n[this.#w];if(!t)return void(this.innerHTML="");const e=new Z({formatDate:this.#t||void 0,templates:this.#n,onAction:t=>{this.#e&&this.#e(t),this.dispatchEvent(new CustomEvent("jist-action",{bubbles:!0,detail:{component:t.component,name:t.name,data:t.data,meta:t.meta}}))}});this.innerHTML="";const n=e.render(t.root,this.#x);n&&this.appendChild(n)}}tt=dt,customElements.define("jist-template",dt);const ct=dt,pt="gist-inbox-button",ut="gist-inbox-badge",gt="gist-inbox-panel",mt="gist-inbox-messages";let ft=!1,ht=!1;const bt=new Set;function yt(){ft||(ft=!0,customElements.get("jist-template")||customElements.define("jist-template",ct),z("gist-inbox-styles","\n#gist-inbox-button {\n position: fixed;\n width: 56px;\n height: 56px;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n z-index: 9998;\n border: none;\n transition: background-color 0.2s ease,\n box-shadow 0.2s ease,\n transform 0.15s ease;\n}\n#gist-inbox-button:hover {\n transform: scale(1.05);\n}\n#gist-inbox-button:active {\n transform: scale(0.93);\n}\n#gist-inbox-button svg {\n width: 24px;\n height: 24px;\n}\n#gist-inbox-badge {\n position: absolute;\n top: -4px;\n right: -4px;\n min-width: 20px;\n height: 20px;\n border-radius: 10px;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0 6px;\n box-sizing: border-box;\n}\n#gist-inbox-panel {\n position: fixed;\n width: 400px;\n max-height: 600px;\n z-index: 9999;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n user-select: none;\n -webkit-user-select: none;\n transform: translateY(8px) scale(0.96);\n opacity: 0;\n pointer-events: none;\n transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),\n opacity 0.2s ease;\n}\n#gist-inbox-panel.gist-inbox-panel--open {\n transform: translateY(0) scale(1);\n opacity: 1;\n pointer-events: auto;\n}\n#gist-inbox-messages {\n overflow-y: auto;\n flex: 1;\n}\n.gist-inbox-message-row {\n transition: background-color 0.15s ease;\n}\n"),oi.events.on("messageInboxUpdated",t=>{vt(t)}),vt())}async function vt(t){t||(t=await H());const e=function(t){return t.filter(t=>t.topics?.some(t=>t.startsWith("cio_inbox"))).sort((t,e)=>{const n=(t.priority??Number.MAX_SAFE_INTEGER)-(e.priority??Number.MAX_SAFE_INTEGER);return 0!==n?n:new Date(e.sentAt??0).getTime()-new Date(t.sentAt??0).getTime()})}(t);if(0===e.length)return void wt();let n=D();n||(await kt(),n=D());const o=n?.patterns?.inbox;if(o){if(function(t,e){let n=document.getElementById(pt);n||(n=q("div",{id:pt}),n.addEventListener("click",()=>{ht?(ht=!1,document.getElementById(gt)?.classList.remove("gist-inbox-panel--open")):(ht=!0,vt())}),W(n));const i=$t(t.position);n.style.background=t.floatingIcon.background,n.style.color=t.floatingIcon.color,n.style.boxShadow="0 2px 8px rgba(0,0,0,0.15)",Object.assign(n.style,i),n.querySelector("svg")||n.insertAdjacentHTML("afterbegin",t.floatingIcon.svg);!function(t,e,n){let i=document.getElementById(ut);if(0===n||!e.unreadIndicator.showAlert)return void i?.remove();i||(i=q("span",{id:ut}),t.appendChild(i));const o=e.unreadIndicator;i.textContent=String(n),i.style.background=o.background,i.style.color=o.text.color,i.style.fontSize=`${o.text.fontSize}px`,i.style.fontWeight=String(o.text.fontWeight),i.style.fontFamily=o.text.fontFamily,i.style.lineHeight=String(o.text.lineHeight)}(n,t,e.filter(t=>!t.opened).length)}(o,e),ht){!function(t,e){let n=document.getElementById(gt);const o=!n;o&&(n=q("div",{id:gt}),W(n));const s=$t(t.position,!0);n.style.background=t.background,n.style.borderRadius=`${t.cornerRadius}px`,n.style.border=`1px solid ${t.borderColor}`,n.style.boxShadow=`${t.shadow.offsetX}px ${t.shadow.offsetY}px ${t.shadow.blur}px ${t.shadow.color}`,Object.assign(n.style,s);let a=document.getElementById(mt);a||(a=q("div",{id:mt}),n.appendChild(a)),a.innerHTML="";const r=D(),l=A();e.forEach((n,o)=>{const s=q("div",{className:"gist-inbox-message-row"});s.style.padding="12px 16px",s.style.cursor="pointer",s.addEventListener("mouseenter",()=>{s.style.background=t.hoverBackground}),s.addEventListener("mouseleave",()=>{s.style.background=""});const d=document.createElement("jist-template");s.appendChild(d),a.appendChild(s);const c=d;if(c.onAction=t=>{i(`Inbox action: ${t.name}`);const e=function(t){if(!t||"object"!=typeof t)return null;const e=t;return"string"==typeof e.behavior&&["openUrl","dismiss","openDeeplink","performAction"].includes(e.behavior)?{behavior:e.behavior,action:"string"==typeof e.action?e.action:void 0,name:"string"==typeof e.name?e.name:void 0,dismiss:"boolean"==typeof e.dismiss?e.dismiss:void 0,newTab:"boolean"==typeof e.newTab?e.newTab:void 0}:null}(t.data);e&&function(t,e){"openUrl"!==e.behavior&&"openDeeplink"!==e.behavior||!e.action||(function(t){try{return"javascript:"!==new URL(t,window.location.href).protocol}catch{return!1}}(e.action)?e.newTab?window.open(e.action,"_blank","noopener"):window.location.href=e.action:i(`Blocked unsafe URL: ${e.action}`)),("dismiss"===e.behavior||e.dismiss)&&t.queueId&&V(t.queueId),oi.events.dispatch("inboxMessageAction",{message:t,action:"clicked"})}(n,e)},l&&(c.templates=l),r?.theme&&(c.theme=r.theme),c.formatDate=Ct,c.data=n.properties??{},c.template=n.type??null,o<e.length-1){const e=q("div",{className:"gist-inbox-divider"});e.style.height="1px",e.style.background=t.dividerColor,e.style.margin="0",a.appendChild(e)}}),o?requestAnimationFrame(()=>{n.classList.add("gist-inbox-panel--open")}):n.classList.add("gist-inbox-panel--open")}(o,e);for(const t of e){const e=t.queueId;t.opened||!e||bt.has(e)||(bt.add(e),F(e,!0).finally(()=>{bt.delete(e)}))}}}else wt()}function wt(){document.getElementById(pt)?.remove(),document.getElementById(gt)?.remove(),ht=!1}const xt=[[60,"second",1],[3600,"minute",60],[86400,"hour",3600],[2592e3,"day",86400],[31536e3,"month",2592e3],[1/0,"year",31536e3]];let St=null,It=null;function Ct(t){const e=Math.round((Date.now()-new Date(t).getTime())/1e3);if(Number.isNaN(e))return t;const[,n,i]=xt.find(([t])=>Math.abs(e)<t);return function(){const t=L();return St&&It===t||(It=t,St=new Intl.RelativeTimeFormat(t,{numeric:"auto"})),St}().format(-Math.round(e/i),n)}function $t(t,e=!1){const n=e?"":"24px",i="96px";switch(t){case"bottom-left":return e?{bottom:i,left:"24px",right:"",top:""}:{bottom:n,left:n,right:"",top:""};case"top-right":return e?{top:i,right:"24px",bottom:"",left:""}:{top:n,right:n,bottom:"",left:""};case"top-left":return e?{top:i,left:"24px",bottom:"",right:""}:{top:n,left:n,bottom:"",right:""};default:return e?{bottom:i,right:"24px",left:"",top:""}:{bottom:n,right:n,left:"",top:""}}}async function kt(){await Promise.all([P(),M()])}let Et=600,jt=!1;const Lt="gist.web.userQueueNextPullCheck",Tt="gist.web.sessionId";function Pt(){let t=a(Tt);return t||(t=y()),s(Tt,t,new Date((new Date).getTime()+18e5)),String(t)}const Dt="gist.web.userToken",Nt="gist.web.usingGuestUserToken",Mt="gist.web.guestUserToken";function At(){return null!==a(Nt)}function Rt(){return a(Dt)}function qt(){if(null===Rt()){let t=a(Mt);null==t&&(t=y(),s(Mt,t),i(`Set guest user token "${t}" with expiry date set to 1 year from today`)),s(Dt,t),s(Nt,!0),i(`Using anonymous session with token: "${t}"`)}}async function zt(){const t=Rt();return null===t?null:await async function(t){const e=(new TextEncoder).encode(t),n=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(n)).map(t=>t.toString(16).padStart(2,"0")).join("")}(t)}function Wt(){const t=Rt();return null===t?null:btoa(t)}function _t(){r(Dt),i("Cleared user token")}const Ot={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 Bt(t){let e=Ot.tooltipArrowColor;if((t?.properties?.gist?.tooltipArrowColor?.length??0)>0)e=t.properties.gist.tooltipArrowColor;else{if(!Array.isArray(t?.displaySettings)||0===t.displaySettings.length)return e;let n=t.displaySettings[0];if(t.savedStepName){const e=t.displaySettings.find(e=>e?.stepName===t.savedStepName&&e.displaySettings);e&&(n=e)}n?.displaySettings?.tooltipArrowColor&&(e=n.displaySettings.tooltipArrowColor)}return e}function Ut(t){const e=Ot,n=t?.properties?.gist;return n?{isEmbedded:!!n.elementId&&!n.tooltipPosition,elementId:n.elementId||"",hasRouteRule:!!n.routeRuleWeb,routeRule:n.routeRuleWeb||"",position:n.position||"",hasPosition:!!n.position,tooltipPosition:n.tooltipPosition||"",hasTooltipPosition:!!n.tooltipPosition,tooltipArrowColor:Bt(t),shouldScale:!!n.scale,campaignId:n.campaignId??null,messageWidth:null!=n.messageWidth&&n.messageWidth>0?n.messageWidth:e.messageWidth,hasCustomWidth:(n.messageWidth??0)>0,overlayColor:n.overlayColor||e.overlayColor,persistent:!!n.persistent,exitClick:!!n.exitClick}:e}const Ht=["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 Ft(t){if(document.getElementById(t))return;const e=document.createElement("div");e.id=t,"x-gist-top"===t?document.body.insertBefore(e,document.body.firstChild):document.body.insertAdjacentElement("beforeend",e),i("Top & bottom elements injected into page")}const Vt=["x-gist-top","x-gist-bottom","x-gist-floating-top","x-gist-floating-bottom"];function Gt(t){return oi.currentMessages.find(e=>e.instanceId===t)}function Xt(t){return!!t&&oi.currentMessages.some(e=>e.queueId===t)}function Jt(t){return t?oi.currentMessages.find(e=>e.elementId===t)??null:null}function Qt(t){oi.currentMessages=oi.currentMessages.filter(e=>e.instanceId!==t)}function Yt(t,e){Qt(t),oi.currentMessages.push(e)}const Kt={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"},Zt=Object.fromEntries(Object.entries(Kt).map(([t,e])=>[e,t]));function te(t){return t&&Kt[t]?Kt[t]:(i(`Invalid overlay position "${t}", defaulting to "topCenter"`),Kt.topCenter)}function ee(t){try{const e=new RegExp(t),n=new URL(window.location.href).pathname,i=null!=oi.currentRoute&&e.test(oi.currentRoute),o=oi.currentRoute!==n&&e.test(n);return i||o}catch{return!1}}function ne(t){return t.tooltipPosition?"tooltip":t.overlay?"modal":t.elementId&&Ht.includes(t.elementId)?"overlay":t.elementId?"inline":"modal"}function ie(t,e){const n=ne(t),i=e.displayType;if(void 0===i)return!1;if(n!==i)return!0;const o=Ut(t);switch(i){case"modal":{if((t.position||"center")!==(e.modalPosition||"center"))return!0;const n=e.dismissOutsideClick??Ot.exitClick;if(o.exitClick!==n)return!0;const i=e.overlayColor??Ot.overlayColor;if(o.overlayColor!==i)return!0;break}case"overlay":{const n=te(e.overlayPosition);if(t.elementId!==n)return!0;break}case"inline":if(t.elementId!==e.elementSelector)return!0;break;case"tooltip":if(t.tooltipPosition!==e.tooltipPosition)return!0;if(t.elementId!==e.elementSelector)return!0;if(void 0!==e.tooltipArrowColor&&o.tooltipArrowColor!==e.tooltipArrowColor)return!0}if("overlay"!==i||!Vt.includes(te(e.overlayPosition))){const t=e.maxWidth??Ot.messageWidth;if(o.messageWidth!==t)return!0}return!1}function oe(t,e){if(t.properties||(t.properties={}),t.properties.gist||(t.properties.gist={}),"modal"===e.displayType)t.overlay=!0,t.elementId=null,t.properties.gist.elementId=null,t.position=e.modalPosition||"center",t.properties.gist.position=e.modalPosition||"center",t.tooltipPosition=void 0,t.properties.gist.tooltipPosition=void 0,t.properties.gist.tooltipArrowColor=void 0;else if("overlay"===e.displayType){t.overlay=!1;const n=te(e.overlayPosition);t.elementId=n,t.properties.gist.elementId=n,t.position=null,t.properties.gist.position=null,t.tooltipPosition=void 0,t.properties.gist.tooltipPosition=void 0,t.properties.gist.tooltipArrowColor=void 0}else"inline"===e.displayType?(t.overlay=!1,t.elementId=e.elementSelector,t.properties.gist.elementId=e.elementSelector,t.position=null,t.properties.gist.position=null,t.tooltipPosition=void 0,t.properties.gist.tooltipPosition=void 0,t.properties.gist.tooltipArrowColor=void 0):"tooltip"===e.displayType&&(t.overlay=!1,t.elementId=e.elementSelector,t.properties.gist.elementId=e.elementSelector,t.tooltipPosition=e.tooltipPosition,t.properties.gist.tooltipPosition=e.tooltipPosition,t.position=null,t.properties.gist.position=null,void 0!==e.tooltipArrowColor&&(t.properties.gist.tooltipArrowColor=e.tooltipArrowColor));t.elementId&&Vt.includes(t.elementId)?delete t.properties.gist.messageWidth:void 0!==e.maxWidth&&e.maxWidth>0?t.properties.gist.messageWidth=e.maxWidth:delete t.properties.gist.messageWidth,void 0!==e.overlayColor?t.properties.gist.overlayColor=e.overlayColor:delete t.properties.gist.overlayColor,void 0!==e.dismissOutsideClick?t.properties.gist.exitClick=e.dismissOutsideClick:delete t.properties.gist.exitClick}const se={top:["bottom","left","right"],bottom:["top","left","right"],left:["right","top","bottom"],right:["left","top","bottom"]},ae=/auto|scroll/,re={top:"gist-arrow-bottom",bottom:"gist-arrow-top",left:"gist-arrow-right",right:"gist-arrow-left"};function le(t){const e=R(t);return e||i(`Tooltip target element not found for selector: ${t}`),e}function de(t,e){if(t.bottom<=0||t.top>=window.innerHeight||t.right<=0||t.left>=window.innerWidth)return!1;for(const n of e){const e=n.getBoundingClientRect();if(t.bottom<=e.top||t.top>=e.bottom||t.right<=e.left||t.left>=e.right)return!1}return!0}function ce(t,e,n){const i=function(t,e,n){switch(n){case"top":return{top:e.top-t.height-16,left:e.left+(e.width-t.width)/2};case"bottom":return{top:e.bottom+16,left:e.left+(e.width-t.width)/2};case"left":return{top:e.top+(e.height-t.height)/2,left:e.left-t.width-16};case"right":return{top:e.top+(e.height-t.height)/2,left:e.right+16}}}(t,e,n);return function(t,e,n){return"top"===n||"bottom"===n?t.top>=0&&t.top+e.height<=window.innerHeight:t.left>=0&&t.left+e.width<=window.innerWidth}(i,t,n)&&function(t,e){return"top"===e||"bottom"===e?t.width+8<=window.innerWidth:t.height+8<=window.innerHeight}(t,n)?function(t,e,n){let{top:i,left:o}=t,s=null;if("top"===n||"bottom"===n){const t=4,n=window.innerWidth-e.width-4;n>=t&&(o<t?(s=o-t,o=t):o>n&&(s=o-n,o=n))}else{const t=4,n=window.innerHeight-e.height-4;n>=t&&(i<t?(s=i-t,i=t):i>n&&(s=i-n,i=n))}if(null!==s){const t=("top"===n||"bottom"===n?e.width/2:e.height/2)-16-4;Math.abs(s)>t&&(s=s>0?t:-t)}return{top:i,left:o,position:n,arrowOffset:s}}(i,t,n):null}function pe(t,e,n){const i=ce(t,e,n);if(i)return i;for(const i of se[n]){const n=ce(t,e,i);if(n)return n}return null}function ue(t){const e=[];let n=t.parentElement;for(;n;){const t=getComputedStyle(n),i=t.overflow+t.overflowX+t.overflowY;ae.test(i)&&e.push(n),n=n.parentElement}return e}function ge(t){const e=R(t);e&&(e.classList.remove("gist-visible"),Array.from(e.classList).filter(t=>t.startsWith("gist-")).forEach(t=>e.classList.remove(t)),e.style.removeProperty("height"),e.style.removeProperty("width"),e.innerHTML="")}function me(t){const e=R(t);if(e)return!(!e.style||!e.style.height||"0px"===e.style.height)}function fe(t,e,n=null){const i=document.getElementById(t);i&&(i.onload=()=>{!function(t,e,n=null){const i=document.getElementById(t);if(i?.contentWindow){const t={options:e,capabilities:he};n&&(e.stepId=n),i.contentWindow.postMessage(t,"*")}}(t,e,n)})}const he=["MultiStepDisplayTypes"];function be(t){if(!t.displaySettings)return;const e=Se(t.instanceId??""),n=document.getElementById(e);n?.contentWindow&&n.contentWindow.postMessage({action:"updateDisplaySettings",displaySettings:t.displaySettings},"*")}async function ye(){const t=document.querySelector(".gist-message");t&&(t.classList.remove("gist-visible"),await new Promise(t=>setTimeout(t,300))),ve()}function ve(){const t=document.querySelector("#gist-embed-message");t&&t.parentNode?.removeChild(t)}const we=new Map;function xe(t){const e=t.instanceId??"",n=we.get(e);n&&(n.cleanup(),we.delete(e));const i=R(`gist-tooltip-${e}`);i&&i.parentNode?.removeChild(i)}function Se(t){return`gist-${t}`}function Ie(){const t=document.querySelector(".gist-message");t&&t.classList.add("gist-visible")}const Ce="gist.web.customAttributes";let $e=new Map;function ke(){const t=Array.from($e.entries()),e=new Date;e.setDate(e.getDate()+30),s(Ce,t,e),i(`Saved ${$e.size} custom attributes to storage with TTL of 30 days`)}async function Ee(t){const e=await De();if(!e)return;const n=new Date;n.setMinutes(n.getMinutes()+60),s(e,t.filter(Te),n)}async function je(){const t=await De();return t?(a(t)??[]).filter(e=>{const n=e.properties.gist.broadcast,{frequency:i}=n,o=a(Me(t,e.queueId))??!0,s=a(Ne(t,e.queueId))||0,r=0===i.count;return o&&(r||s<i.count)}):[]}async function Le(t,e){const n=a(t);return n?.find(t=>t.queueId===e)}function Te(t){return!(!t.properties?.gist||!t.properties.gist.broadcast)}function Pe(t){if(!Te(t))return!1;const e=t.properties.gist.broadcast;return 0===e.frequency.delay&&0===e.frequency.count}async function De(){const t=await zt();return t?`gist.web.message.broadcasts.${t}`:null}function Ne(t,e){return`${t}.${e}.numberOfTimesShown`}function Me(t,e){return`${t}.${e}.shouldShow`}!function(){const t=a(Ce);if(t)try{$e=new Map(t)}catch{$e=new Map}else $e=new Map}();const Ae="gist.web.message.user";async function Re(t){const e=await ze();if(!e)return;const n=t.filter(t=>!(t.properties&&t.properties.gist&&t.properties.gist.broadcast)),i=new Date;i.setMinutes(i.getMinutes()+60),s(e,n,i)}async function qe(){const t=await ze();if(!t)return[];const e=a(t)??[],n=await async function(){const t=await We();return t?a(t)??[]:[]}();return e.filter(t=>!n.includes(t.queueId??""))}async function ze(){const t=await zt();return t?`${Ae}.${t}`:null}async function We(){const t=await zt();return t?`${Ae}.${t}.seen`:null}async function _e(t){const e=await zt();return e?`${Ae}.${e}.message.${t}.loading`:null}async function Oe(t){const e=await zt();return e?`${Ae}.${e}.message.${t}.state`:null}async function Be(t){const e=await Oe(t);e&&(r(e),i(`Cleared message state for queueId: ${t}`))}function Ue(t){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="${t}"/></svg>`}const He=`\n #gist-preview-bar {\n position: fixed; bottom: 0; left: 0; right: 0;\n z-index: 99999999999;\n font-family: system-ui, -apple-system, sans-serif;\n pointer-events: none;\n }\n .gist-pb-toggle-row {\n display: flex; justify-content: center;\n padding: 6px 16px;\n border-bottom: 1px solid #e5e7eb;\n }\n .gist-pb-toggle-row--collapsed { border-bottom: none; }\n .gist-pb-toggle-btn {\n background: #08272B; border: none;\n padding: 4px 14px;\n border-radius: 100px;\n font-size: 12px; font-weight: 500;\n font-family: system-ui, -apple-system, sans-serif;\n color: white; cursor: pointer;\n display: flex; align-items: center; gap: 6px;\n pointer-events: auto;\n height: auto; min-width: auto;\n box-sizing: border-box;\n line-height: normal;\n -webkit-appearance: none;\n appearance: none;\n }\n .gist-pb-controls-row {\n background: #F8F9F9;\n box-shadow: 1px 2px 2px #34344605, 3px 3px 8px #34344614;\n display: flex; flex-wrap: wrap; align-items: center;\n gap: 12px; padding: 10px 16px 12px;\n pointer-events: auto;\n }\n .gist-pb-label-group { display: flex; flex-direction: column; gap: 4px; }\n .gist-pb-label-group--grow { flex: 1; }\n .gist-pb-label {\n font-size: 10px; font-weight: 600; color: #3F4E50;\n letter-spacing: 0.05em; text-transform: uppercase;\n font-family: system-ui, -apple-system, sans-serif;\n }\n .gist-pb-select {\n height: 32px; padding: 0 32px 0 8px;\n border: 1px solid #d1d5db; border-radius: 6px;\n font-size: 13px; font-family: system-ui, -apple-system, sans-serif;\n background: white ${`url("data:image/svg+xml,${encodeURIComponent(Ue("#3F4E50"))}")`} no-repeat right 2px center;\n color: #3F4E50; cursor: pointer; outline: none;\n appearance: none; min-width: 120px;\n }\n .gist-pb-input {\n height: 32px; padding: 0 8px;\n border: 1px solid #d1d5db; border-radius: 6px;\n font-size: 13px; font-family: system-ui, -apple-system, sans-serif;\n color: #3F4E50; outline: none; box-sizing: border-box;\n }\n .gist-pb-checkbox-row { display: flex; align-items: center; gap: 6px; height: 32px; }\n .gist-pb-checkbox-label {\n font-size: 12px; font-family: system-ui, -apple-system, sans-serif;\n color: #3F4E50; cursor: pointer; user-select: none;\n }\n .gist-pb-color-control {\n display: flex; align-items: center;\n border: 1px solid #d1d5db; border-radius: 6px;\n overflow: hidden; height: 32px; background: white;\n }\n .gist-pb-color-swatch {\n width: 28px; height: 100%;\n cursor: pointer; flex-shrink: 0;\n border-right: 1px solid #d1d5db; position: relative;\n }\n .gist-pb-color-input {\n position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;\n }\n .gist-pb-color-hex {\n flex: 1; border: none; outline: none; padding: 0 6px;\n font-size: 13px; font-family: monospace; color: #3F4E50;\n min-width: 0; background: transparent;\n }\n .gist-pb-color-opacity {\n width: 36px; border: none; border-left: 1px solid #d1d5db;\n outline: none; padding: 0 4px;\n font-size: 13px; font-family: system-ui, -apple-system, sans-serif;\n color: #3F4E50; background: transparent; text-align: right;\n }\n .gist-pb-color-pct {\n font-size: 12px; color: #3F4E50; padding: 0 6px 0 2px;\n font-family: system-ui, -apple-system, sans-serif; flex-shrink: 0;\n }\n .gist-pb-input--invalid { border-color: #941616; outline: 1px solid #941616; }\n .gist-pb-inline-row { display: flex; align-items: center; gap: 6px; }\n .gist-pb-select-elem-btn, .gist-pb-cancel-btn {\n height: 32px; padding: 0 12px;\n border: none; border-radius: 6px;\n font-size: 12px; font-weight: 500; font-family: system-ui, -apple-system, sans-serif;\n background: #08272B; color: white; cursor: pointer; white-space: nowrap; flex-shrink: 0;\n min-width: auto; box-sizing: border-box;\n -webkit-appearance: none; appearance: none;\n }\n .gist-pb-select-elem-btn:disabled {\n opacity: 0.4; cursor: not-allowed;\n }\n .gist-pb-spacer { flex: 1; min-width: 0; }\n .gist-pb-save-btn {\n height: 36px; padding: 0 18px;\n background: #08272B; color: white;\n border: none; border-radius: 6px;\n font-size: 13px; font-weight: 600;\n font-family: system-ui, -apple-system, sans-serif;\n cursor: pointer; white-space: nowrap; align-self: center;\n min-width: auto; box-sizing: border-box;\n -webkit-appearance: none; appearance: none;\n }\n .gist-pb-save-btn:disabled {\n background: #CAD6D8; cursor: not-allowed;\n }\n .gist-pb-picker-overlay {\n position: fixed; inset: 0; z-index: 999999999998; cursor: crosshair;\n }\n .gist-pb-checkbox { cursor: pointer; width: 14px; height: 14px; }\n .gist-pb-pick-highlight { outline: 2px solid #006FF5 !important; }\n .gist-pb-pick-error { outline: 2px solid #941616 !important; }\n #gist-preview-bar.gist-pb-hidden { display: none; }\n .gist-pb-ended-row {\n justify-content: center; align-items: center; gap: 10px; padding: 12px 16px;\n flex-wrap: nowrap;\n }\n .gist-pb-ended-icon {\n display: flex; align-items: center; justify-content: center;\n width: 22px; height: 22px; border-radius: 50%;\n background: #08272B; color: white;\n font-size: 13px; font-weight: 700; flex-shrink: 0;\n }\n .gist-pb-ended-text {\n margin: 0; font-size: 13px; color: #3F4E50;\n font-family: system-ui, -apple-system, sans-serif;\n min-width: 0;\n }\n .gist-pb-ended-text strong { color: #08272B; }\n @media (max-width: 1024px) {\n .gist-pb-controls-row { gap: 8px; }\n .gist-pb-label-group { flex: 1 1 100%; }\n .gist-pb-label-group--grow { flex: 1 1 100%; }\n .gist-pb-select { width: 100%; min-width: unset; box-sizing: border-box; }\n .gist-pb-input { width: 100% !important; box-sizing: border-box; }\n .gist-pb-color-control { width: 100%; }\n .gist-pb-checkbox-row { width: 100%; }\n .gist-pb-inline-row { flex-direction: row; align-items: center; }\n .gist-pb-inline-row .gist-pb-input { flex: 1; min-width: 0; }\n .gist-pb-save-btn { width: 100%; box-sizing: border-box; }\n .gist-pb-label--spacer { display: none; }\n }\n`;const Fe="cioPreviewId",Ve="cioPreviewSettings";const Ge="gist.previewBar.collapsed",Xe="gist-pb-styles",Je="gist-preview-bar",Qe={topLeft:"Top Left",topCenter:"Top Center",topRight:"Top Right",bottomLeft:"Bottom Left",bottomCenter:"Bottom Center",bottomRight:"Bottom Right"};let Ye=null,Ke=[],Ze={},tn=null,en=!1,nn=!1,on=5,sn=null,an=!0,rn=!1,ln=!1,dn=null,cn=null,pn=null;const un=new Map;function gn(t,e){const n=q("div",{className:"gist-pb-label-group"});return n.appendChild(q("span",{className:"gist-pb-label",textContent:t})),n.appendChild(e),n}function mn(t,e){const n=q("select",{className:"gist-pb-select"});for(const i of t){const t=q("option",{value:i.value,textContent:i.label});i.value===e&&(t.selected=!0),n.appendChild(t)}return n}function fn(t,e,n){const i=q("input",{className:"gist-pb-input",type:t,value:String(e)});return n&&(i.style.width=n),i}function hn(t,e){const n=Math.round(Math.min(100,Math.max(0,e))/100*255);return"#"+t.replace("#","").toUpperCase()+n.toString(16).padStart(2,"0").toUpperCase()}function bn(t){return!!("inline"!==t.displayType&&"tooltip"!==t.displayType||t.elementSelector?.trim())}function yn(t){if("overlay"===t.displayType&&Vt.includes(te(t.overlayPosition))){const{maxWidth:e,...n}=t;t=n}if(Ze=t,tn){const e=Ke.findIndex(t=>t.stepName===tn);-1!==e&&(Ke[e]={...Ke[e],displaySettings:{...t}})}if(!Ye)return;const e=oi.currentMessages.find(t=>t.instanceId===Ye);e&&bn(t)&&(be(e),ie(e,t)&&Gn(e,tn,t)),function(){const t=new URLSearchParams(window.location.search).get(Fe);t&&async function(t,e){try{return await E()(`/api/v1/preview/${t}`,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json"}})}catch(t){return k(t)}}(t,Ke).then(t=>{t&&404===t.status&&Ye&&oi.dismissMessage(Ye)}).catch(()=>i("Failed to persist preview display settings"))}()}function vn(t){const e=t.value.trim();e&&!R(e)?t.classList.add("gist-pb-input--invalid"):t.classList.remove("gist-pb-input--invalid")}function wn(t,e){const n=fn("text",t.elementSelector||"","260px");n.placeholder="Element ID or selector",vn(n),n.addEventListener("change",()=>{const t=n.value.trim(),e=Ze.elementSelector;t&&xn(t),yn({...Ze,elementSelector:t}),e&&e!==t&&Sn(e),vn(n)});const i=q("button",{type:"button",className:"gist-pb-select-elem-btn",textContent:"Select Element"});ln&&(i.disabled=!0),i.addEventListener("click",()=>Cn(n));const o=q("div",{className:"gist-pb-inline-row"});o.appendChild(n),o.appendChild(i),e.appendChild(gn("Element Selector",o))}function xn(t){if(!t||un.has(t))return;const e=R(t);e&&un.set(t,e.innerHTML)}function Sn(t){const e=un.get(t);if(void 0===e)return;const n=R(t);n&&(n.innerHTML=e)}function In(){for(const t of un.keys())Sn(t);un.clear()}function Cn(t){if(ln)return;ln=!0;const e=document.querySelector(`#${Je} .gist-pb-select-elem-btn`);e&&(e.disabled=!0);const n={...Ze},o=oi.currentMessages.find(t=>t.instanceId===Ye)??null;o&&Vn(o),Ze.elementSelector&&Sn(Ze.elementSelector);const s=q("div",{className:"gist-pb-picker-overlay"});let a=null;const r=t=>{s.style.pointerEvents="none";const e=document.elementFromPoint(t.clientX,t.clientY);s.style.pointerEvents="all",e&&e!==a&&e!==s&&(a?.classList.remove("gist-pb-pick-highlight"),a=e,a.classList.add("gist-pb-pick-highlight"))},l=t=>{if("Escape"===t.key){if(c(),Ze=n,tn){const t=Ke.findIndex(t=>t.stepName===tn);-1!==t&&(Ke[t]={...Ke[t],displaySettings:{...n}})}o&&bn(n)&&Gn(o,tn,n),$n()}},d=e=>{e.preventDefault(),e.stopPropagation(),s.style.pointerEvents="none";const n=document.elementFromPoint(e.clientX,e.clientY);if(s.style.pointerEvents="all",n&&n!==s){n.classList.remove("gist-pb-pick-highlight");const e=document.getElementById(Je),s=e?.contains(n)?null:function(t){if(t.id){const e=CSS.escape(t.id);if(1===document.querySelectorAll(`#${e}`).length)return t.id}const e=[];let n=t;for(;n&&"BODY"!==n.tagName&&"HTML"!==n.tagName;){if(n.id){const t=CSS.escape(n.id);if(1===document.querySelectorAll(`#${t}`).length){e.unshift(`#${t}`);break}}let t=n.tagName.toLowerCase();n.className&&"string"==typeof n.className&&(t+=n.className.trim().split(/\s+/).filter(Boolean).map(t=>`.${CSS.escape(t)}`).join(""));const i=n.parentElement;i&&(t+=`:nth-of-type(${Array.from(i.children).filter(t=>t.tagName===n.tagName).indexOf(n)+1})`),e.unshift(t);try{if(1===document.querySelectorAll(e.join(" > ")).length)break}catch{}n=n.parentElement}const o=e.join(" > ");try{if(1!==document.querySelectorAll(o).length)return i("buildUniqueSelector: could not produce a unique selector for element"),null}catch{return null}return o}(n);if(null===s)return n.classList.add("gist-pb-pick-error"),void setTimeout(()=>{n.classList.remove("gist-pb-pick-error"),n.classList.add("gist-pb-pick-highlight")},800);t.value=s,xn(s);const a=Ze.elementSelector,r={...Ze,elementSelector:s},l=null!=o&&bn(r)&&ie(o,r);yn(r),a&&a!==s&&Sn(a),o&&!l&&Gn(o,tn,r)}c(),$n()},c=()=>{a?.classList.remove("gist-pb-pick-highlight"),s.removeEventListener("mousemove",r),s.removeEventListener("click",d),document.removeEventListener("keydown",l),document.body.removeChild(s),ln=!1,dn=null};dn=c,s.addEventListener("mousemove",r),s.addEventListener("click",d),document.addEventListener("keydown",l),document.body.appendChild(s)}function $n(){const t=document.getElementById(Je);if(!t)return;if(t.classList.toggle("gist-pb-hidden",!Ye&&!nn),t.innerHTML="",!Ye){if(nn){const e=q("div",{className:"gist-pb-controls-row gist-pb-ended-row"}),n=q("span",{className:"gist-pb-ended-icon",textContent:"✓"}),i=q("p",{className:"gist-pb-ended-text"});if(i.innerHTML=En(on),e.appendChild(n),e.appendChild(i),an){const t=q("button",{type:"button",className:"gist-pb-cancel-btn",textContent:"Cancel"});t.addEventListener("click",jn),e.appendChild(t)}t.appendChild(e)}return}const e=q("div",{className:"gist-pb-toggle-row"+(en?" gist-pb-toggle-row--collapsed":"")}),n=q("button",{type:"button",className:"gist-pb-toggle-btn"}),i=en?"transform:rotate(180deg);display:inline-flex;":"display:inline-flex;";if(n.innerHTML=`${en?"Expand":"Collapse"}<span style="${i}">${Ue("white")}</span>`,n.addEventListener("click",Ln),e.appendChild(n),t.appendChild(e),en)return;const o=q("div",{className:"gist-pb-controls-row"});if(Ke.length>0){const t=tn??Ke[0].stepName,e=mn(Ke.map(t=>({value:t.stepName,label:t.stepName})),t);e.addEventListener("change",()=>{const t=Ke.find(t=>t.stepName===e.value);if(t){tn=t.stepName,Ze={...t.displaySettings};const e=oi.currentMessages.find(t=>t.instanceId===Ye);e&&bn(t.displaySettings)&&Gn(e,t.stepName,t.displaySettings),$n()}}),o.appendChild(gn("Step",e))}const s=mn([{value:"modal",label:"Modal"},{value:"overlay",label:"Overlay"},{value:"inline",label:"Inline"},{value:"tooltip",label:"Tooltip"}],Ze.displayType||"modal");s.addEventListener("change",()=>{const t=s.value,e=Ze.displayType,n=Ze.elementSelector,i={...Ze,displayType:t};"modal"===t?(i.modalPosition=i.modalPosition||"center",i.maxWidth=i.maxWidth??414,delete i.overlayPosition,delete i.elementSelector,delete i.tooltipPosition):"overlay"===t?(i.overlayPosition=i.overlayPosition||"topCenter",i.maxWidth=i.maxWidth??414,delete i.modalPosition,delete i.elementSelector,delete i.tooltipPosition):"inline"===t?(delete i.modalPosition,delete i.overlayPosition,delete i.tooltipPosition):"tooltip"===t&&(i.tooltipPosition=i.tooltipPosition||"top",delete i.modalPosition,delete i.overlayPosition,delete i.overlayColor,delete i.dismissOutsideClick),Ze=i,yn(Ze),"inline"!==e&&"tooltip"!==e||!n||"inline"===t||"tooltip"===t||Sn(n),$n()}),o.appendChild(gn("Display Type",s));const a=Ze.displayType||"modal";"modal"===a?function(t,e){const n=mn([{value:"top",label:"Top"},{value:"center",label:"Center"},{value:"bottom",label:"Bottom"}],t.modalPosition||"center");n.addEventListener("change",()=>yn({...Ze,modalPosition:n.value})),e.appendChild(gn("Position",n));const i=fn("number",t.maxWidth??414,"80px");i.addEventListener("change",()=>yn({...Ze,maxWidth:parseInt(i.value)||414})),e.appendChild(gn("Max Width",i)),e.appendChild(function(t){const{color:e,opacity:n}=function(t){const e=t.replace("#","");return 8===e.length?{color:"#"+e.slice(0,6).toUpperCase(),opacity:Math.round(parseInt(e.slice(6),16)/255*100)}:6===e.length?{color:"#"+e.toUpperCase(),opacity:100}:{color:"#000000",opacity:20}}(t.overlayColor||"#00000033"),i=q("div",{className:"gist-pb-color-control"}),o=q("input",{className:"gist-pb-color-input",type:"color",value:e}),s=q("div",{className:"gist-pb-color-swatch"});s.style.background=e,s.appendChild(o),s.addEventListener("click",()=>o.click());const a=q("input",{className:"gist-pb-color-hex",type:"text",maxLength:6,value:e.replace("#","")}),r=q("input",{className:"gist-pb-color-opacity",type:"number",min:"0",max:"100",value:String(n)}),l=q("span",{className:"gist-pb-color-pct",textContent:"%"}),d=()=>{const t="#"+a.value.replace("#",""),e=parseInt(r.value)||0;s.style.background=t,o.value=t,yn({...Ze,overlayColor:hn(t,e)})};return o.addEventListener("input",()=>{a.value=o.value.replace("#","").toUpperCase(),s.style.background=o.value}),o.addEventListener("change",d),a.addEventListener("change",d),r.addEventListener("change",d),i.appendChild(s),i.appendChild(a),i.appendChild(r),i.appendChild(l),gn("Overlay Color",i)}(t));const o=q("div",{className:"gist-pb-checkbox-row"}),s=q("input",{className:"gist-pb-checkbox",type:"checkbox"});s.checked=t.dismissOutsideClick??!1;const a=q("label",{className:"gist-pb-checkbox-label",textContent:"Dismiss on click outside"});s.addEventListener("change",()=>yn({...Ze,dismissOutsideClick:s.checked})),a.addEventListener("click",()=>{s.checked=!s.checked,yn({...Ze,dismissOutsideClick:s.checked})}),o.appendChild(s),o.appendChild(a);const r=gn(" ",o);r.classList.add("gist-pb-label-group--grow"),r.firstChild.classList.add("gist-pb-label--spacer"),e.appendChild(r)}(Ze,o):"overlay"===a?function(t,e){const n=mn(Object.entries(Qe).map(([t,e])=>({value:t,label:e})),t.overlayPosition||"topCenter");if(n.addEventListener("change",()=>yn({...Ze,overlayPosition:n.value})),e.appendChild(gn("Position",n)),!Vt.includes(te(t.overlayPosition))){const n=fn("number",t.maxWidth??414,"80px");n.addEventListener("change",()=>yn({...Ze,maxWidth:parseInt(n.value)||414})),e.appendChild(gn("Max Width",n))}}(Ze,o):"inline"===a?function(t,e){wn(t,e)}(Ze,o):"tooltip"===a&&function(t,e){const n=mn([{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],t.tooltipPosition||"top");n.addEventListener("change",()=>yn({...Ze,tooltipPosition:n.value})),e.appendChild(gn("Position",n)),wn(t,e)}(Ze,o),o.appendChild(q("div",{className:"gist-pb-spacer"}));const r=q("button",{type:"button",className:"gist-pb-save-btn",textContent:"End session"});r.addEventListener("click",async()=>{Ye&&await oi.dismissMessage(Ye)}),o.appendChild(r),t.appendChild(o)}async function kn(){if(!rn)if(rn=!0,_t(),function(){try{sessionStorage.removeItem(o)}catch{}}(),an){try{window.close()}catch{}try{window.location.reload()}catch{}dn&&dn(),sn&&(clearInterval(sn),sn=null),In(),document.getElementById(Je)?.remove(),document.getElementById(Xe)?.remove(),Ye=null,Ke=[],Ze={},tn=null,nn=!1,on=5,an=!0,rn=!1}else nn=!1,rn=!1,$n()}function En(t){return an?`<strong>Preview session ended.</strong> This tab will close in ${t}s…`:`<strong>Preview session ended.</strong> Finishing session in ${t}s… This tab will stay open.`}function jn(){nn&&sn&&(an=!1,$n())}function Ln(){en=!en;try{sessionStorage.setItem(Ge,String(en))}catch{}$n()}function Tn(t){if(nn)return;Ye=t.instanceId??null;const e=t.displaySettings;if(Array.isArray(e)&&e.length>0?(Ke=e,tn||(tn=Ke[0].stepName,Ze={...Ke[0].displaySettings})):e&&"object"==typeof e&&!Array.isArray(e)&&(Ze={...e}),cn||pn){const t=!!cn,e=!!pn,n=cn,o=pn;if(cn=null,pn=null,t){const t=Ke.find(t=>t.stepName===n);if(!t)return i(`Preview bar: step "${n}" not found, ignoring initial step/display override`),void $n();tn=t.stepName,Ze={...t.displaySettings}}if(e){if(!t)return i(`Preview bar: display type "${o}" provided without a step, ignoring`),void $n();Ze={...Ze,displayType:o}}$n();const s=oi.currentMessages.find(t=>t.instanceId===Ye);return void(s&&bn(Ze)?Gn(s,tn,Ze):function(){const t=Ze.displayType;if("inline"!==t&&"tooltip"!==t)return;const e=document.querySelector("#gist-preview-bar .gist-pb-input[type='text']");e&&Cn(e)}())}$n()}function Pn(){In(),Ye=null,Ke=[],Ze={},tn=null,nn=!0,on=5,an=!0,rn=!1;const t=new URLSearchParams(window.location.search).get(Fe);t&&async function(t){try{return await E()(`/api/v1/preview/${t}`,{method:"DELETE"})}catch(t){return k(t)}}(t).catch(()=>i("Failed to delete preview session")),$n(),sn&&clearInterval(sn),sn=setInterval(async()=>{if(on-=1,on<=0)clearInterval(sn),sn=null,await kn();else{const t=document.querySelector(`#${Je} .gist-pb-ended-text`);t?t.innerHTML=En(on):$n()}},1e3)}async function Dn(t){if(!oi.isDocumentVisible)return i("Document hidden, not showing message now."),null;if(Xt(t.queueId))return i(`Message with queueId ${t.queueId} is already showing.`),null;const e=Ut(t);return!t.tooltipPosition&&e.hasTooltipPosition&&(t.tooltipPosition=e.tooltipPosition),t.tooltipPosition?function(t,e){const n=e.elementId||t.elementId;if(!n)return i(`No target selector specified for tooltip message ${t.messageId}`),oi.messageError(t),null;if(!R(n)){if(!oi.config.isPreviewSession||!t.properties?.gist?.livePreview)return i(`Tooltip target element "${n}" not found for message ${t.messageId}, skipping display`),oi.messageError(t),null;i(`Preview: tooltip target "${n}" not found, loading message for preview bar`)}const o=oi.currentMessages.find(t=>t.tooltipPosition&&t.elementId===n);o&&(i(`Tooltip already showing on target "${n}" (instance ${o.instanceId}), dismissing it first`),oi.messageDismissed(o),xe(o),o.instanceId&&Qt(o.instanceId)),t.instanceId=y(),t.overlay=!1,t.firstLoad=!0,t.shouldResizeHeight=!1,t.shouldScale=!1,t.renderStartTime=(new Date).getTime(),t.elementId=n,oi.currentMessages.push(t);return On(t,null,t.savedStepName||null)}(t,e):oi.overlayInstanceId?(i(`Message ${oi.overlayInstanceId} already showing.`),null):(t.instanceId=y(),t.overlay=!0,t.firstLoad=!0,t.shouldResizeHeight=!0,t.shouldScale=e.shouldScale,t.renderStartTime=(new Date).getTime(),oi.overlayInstanceId=t.instanceId,oi.currentMessages.push(t),On(t,null,t.savedStepName||null))}function Nn(t,e){return oi.isDocumentVisible?Xt(t.queueId)?(i(`Message with queueId ${t.queueId} is already showing.`),null):Jt(e)?(i(`Message with elementId ${e} already has a message.`),null):(t.instanceId=y(),t.overlay=!1,t.firstLoad=!0,t.shouldScale=!1,t.elementId=e,t.shouldResizeHeight=!me(e),t.renderStartTime=(new Date).getTime(),oi.currentMessages.push(t),On(t,e,t.savedStepName||null)):(i("Document hidden, not showing message now."),null)}async function Mn(t){t?(oi.messageDismissed(t),await An(t)):i("Message not found")}async function An(t){"tooltip"===ne(t)?zn(t):t.overlay?await Wn(!0,t):qn(t)}async function Rn(t){t?Ut(t).persistent&&(i("Persistent message dismissed, logging view"),await Xn(t),await Bn(t),await Be(t.queueId??"")):i("Message not found")}function qn(t){t.instanceId&&Qt(t.instanceId),t.elementId&&ge(t.elementId),oi.config.isPreviewSession&&(Pn(),_n())}function zn(t){xe(t),t.instanceId&&Qt(t.instanceId),0===oi.currentMessages.length&&(window.removeEventListener("message",Hn),window.removeEventListener("touchstart",Un)),oi.config.isPreviewSession&&(Pn(),_n())}async function Wn(t,e){t?await ye():ve(),0===oi.currentMessages.length&&(window.removeEventListener("message",Hn),window.removeEventListener("touchstart",Un)),e.instanceId&&Qt(e.instanceId),oi.overlayInstanceId=null,oi.config.isPreviewSession&&(Pn(),_n())}function _n(){const t=new URL(window.location.href);t.searchParams.delete(Fe),t.searchParams.delete(Ve),history.replaceState(null,"",t.toString())}function On(t,e=null,n=null){const o=oi.config.env,s={endpoint:C.ENGINE_API_ENDPOINT[o],siteId:oi.config.siteId,dataCenter:oi.config.dataCenter,messageId:t.messageId,instanceId:t.instanceId??"",livePreview:!1,properties:t.properties,customAttributes:Object.fromEntries(new Map($e))},a=`${C.GIST_VIEW_ENDPOINT[o]}/index.html`;return window.addEventListener("message",Hn),window.addEventListener("touchstart",Un),"tooltip"===ne(t)?function(t,e,n,i=null){const o=e.instanceId??"",s=Se(o),a=Ut(e),r=we.get(o);r&&(r.cleanup(),we.delete(o)),document.querySelectorAll(`#gist-tooltip-${o}`).forEach(t=>{t.parentNode?.removeChild(t)});const l=`gist-tooltip-${o}`,d=document.createElement("div");d.id=l,d.innerHTML=function(t,e,n,i=""){let o=600;e.messageWidth>o&&(o=e.messageWidth);const s=e.tooltipArrowColor,a=function(t){switch(t){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"}}(e.tooltipPosition),r=i?`#${i} `:"";return`\n <div class="gist-tooltip-outer">\n <style>\n ${r}.gist-tooltip-outer {\n position: absolute;\n }\n ${r}.gist-tooltip-container {\n position: relative;\n z-index: 9999999;\n opacity: 0;\n transition: opacity 0.3s ease-in-out;\n }\n ${r}.gist-tooltip-container.gist-visible {\n opacity: 1;\n }\n ${r}.gist-tooltip-frame-clip {\n overflow: hidden;\n }\n ${r}.gist-tooltip-frame {\n display: block;\n width: ${e.messageWidth}px;\n border: none;\n transition: height 0.1s ease-in-out;\n color-scheme: light only;\n }\n ${r}.gist-tooltip-arrow {\n width: 0;\n height: 0;\n position: absolute;\n z-index: 1;\n }\n ${r}.gist-tooltip-arrow.gist-arrow-bottom {\n bottom: 0;\n left: 50%;\n transform: translateX(-50%) translateY(100%);\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n border-top: 10px solid ${s};\n }\n ${r}.gist-tooltip-arrow.gist-arrow-top {\n top: 0;\n left: 50%;\n transform: translateX(-50%) translateY(-100%);\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n border-bottom: 10px solid ${s};\n }\n ${r}.gist-tooltip-arrow.gist-arrow-right {\n right: 0;\n top: 50%;\n transform: translateY(-50%) translateX(100%);\n border-top: 10px solid transparent;\n border-bottom: 10px solid transparent;\n border-left: 10px solid ${s};\n }\n ${r}.gist-tooltip-arrow.gist-arrow-left {\n left: 0;\n top: 50%;\n transform: translateY(-50%) translateX(-100%);\n border-top: 10px solid transparent;\n border-bottom: 10px solid transparent;\n border-right: 10px solid ${s};\n }\n @media (max-width: ${o}px) {\n ${r}.gist-tooltip-frame {\n max-width: 100%;\n }\n }\n </style>\n <div class="gist-tooltip-container">\n <div class="gist-tooltip-arrow ${a}"></div>\n <div class="gist-tooltip-frame-clip">\n <iframe id="${t}" class="gist-tooltip-frame" src="${n}"></iframe>\n </div>\n </div>\n </div>`}(s,a,t,l),document.body.appendChild(d),fe(s,n,i)}(a,t,s,n):e?(Ht.includes(e)&&Ft(e),function(t,e,n,o,s=null){const a=R(t);if(a){const i=Se(n.instanceId??"");a.classList.add(i);const r=Ut(n);let l=r.messageWidth+"px";Vt.includes(t)&&!r.hasCustomWidth&&(l="100%"),Ht.includes(t)&&(a.style.width=l),me(t)||(a.style.height="0px"),a.innerHTML=function(t,e,n){return function(t,e,n){let i=800;return e.messageWidth>i&&(i=e.messageWidth),`\n <div id="gist-embed">\n <style>\n #x-gist-floating-top, #x-gist-floating-top-left, #x-gist-floating-top-right {\n position: fixed;\n top: 0px;\n z-index: 1000000;\n }\n #x-gist-floating-bottom, #x-gist-floating-bottom-left, #x-gist-floating-bottom-right {\n position: fixed;\n bottom: 0px;\n z-index: 1000000;\n }\n #x-gist-bottom, #x-gist-top, #x-gist-floating-top, #x-gist-floating-bottom {\n left: 50%;\n transform: translate(-50%, 0%);\n }\n #x-gist-floating-top-right, #x-gist-floating-bottom-right {\n right: 0px;\n }\n #gist-embed {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container .gist-frame {\n height: 100%;\n width: 100%;\n border: none;\n color-scheme: light only;\n }\n #x-gist-top.${t},\n #x-gist-bottom.${t},\n #x-gist-floating-top.${t},\n #x-gist-floating-bottom.${t},\n #x-gist-floating-top-left.${t},\n #x-gist-floating-top-right.${t},\n #x-gist-floating-bottom-left.${t},\n #x-gist-floating-bottom-right.${t} {\n transition: height 0.1s ease-in-out;\n }\n @media (max-width: ${i}px) {\n #x-gist-top.${t},\n #x-gist-bottom.${t},\n #x-gist-floating-top.${t},\n #x-gist-floating-bottom.${t},\n #x-gist-floating-top-left.${t},\n #x-gist-floating-top-right.${t},\n #x-gist-floating-bottom-left.${t},\n #x-gist-floating-bottom-right.${t} {\n width: 100% !important;\n }\n }\n </style>\n <div id="gist-embed-container">\n <iframe id="${t}" class="gist-frame" src="${n}"></iframe>\n </div>\n </div>`}(Se(e.instanceId??""),n,t)}(e,n,r),fe(i,o,s)}else i(`Message could not be embedded, elementId ${t} not found.`)}(e,a,t,s,n)):function(t,e,n,i=null){document.querySelectorAll("#gist-embed-message").forEach(t=>{t.parentNode?.removeChild(t)}),document.body.insertAdjacentHTML("afterbegin",function(t,e){const n=Ut(e);return function(t,e,n){let i=600;return e.messageWidth>i&&(i=e.messageWidth),`\n <div id="gist-embed-message">\n <style>\n #gist-overlay.gist-background {\n position: fixed;\n z-index: 9999999998;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n background-color: ${e.overlayColor};\n visibility: hidden;\n }\n #gist-overlay.gist-background.gist-visible {\n visibility: visible;\n }\n .gist-message {\n width: ${e.messageWidth}px;\n position: absolute;\n border: none;\n opacity: 0;\n transition: opacity 0.3s ease-in-out, height 0.1s ease-in-out;\n z-index: 9999999999;\n left: 50%;\n transform: translateX(-50%);\n color-scheme: light only;\n }\n .gist-message.gist-visible {\n opacity: 1;\n pointer-events: auto;\n }\n .gist-message.gist-center {\n transform: translate(-50%, -50%);\n top: 50%;\n }\n .gist-message.gist-bottom {\n bottom: 0;\n }\n .gist-message.gist-top {\n top: 0;\n }\n @media (max-width: ${i}px) {\n .gist-message {\n width: 100%;\n }\n }\n </style>\n <div id="gist-overlay" class="gist-background">\n <iframe id="${t}" class="gist-message" src="${n}"></iframe>\n </div>\n </div>`}(Se(e.instanceId??""),n,t)}(t,e)),fe(Se(e.instanceId??""),n,i)}(a,t,s,n),t}async function Bn(t){let e;i(`Message shown, logging view for: ${t.messageId}`),null!=t.queueId?(await Xn(t),e=await _(t.queueId)):e=await async function(t){try{return await E().post(`/api/v1/logs/message/${t}`)}catch(t){return k(t)}}(t.messageId),i(200===e?.status?"Message view logged":`Problem logging message: ${e?.status}`)}function Un(){}async function Hn(t){const e=oi.config.env,n=t.data;if(n.gist&&t.origin===C.RENDERER_HOST[e]){const t=n.gist.instanceId,e=Gt(t);if(!e)return;const o=Ut(e);switch(n.gist.method){case"routeLoaded":{const s=.001*((new Date).getTime()-(e.renderStartTime??0));if(i(`Engine render for message: ${e.messageId} timer elapsed in ${s.toFixed(3)} seconds`),async function(t){const e=await _e(t);e&&r(e)}(e.queueId??""),e.currentRoute=n.gist.parameters.route,n.gist.parameters.fullDisplaySettings&&!e.displaySettings?e.displaySettings=n.gist.parameters.fullDisplaySettings:e.displaySettings&&(i("SDK already has display settings state, sending it to iframe"),be(e)),oi.config.isPreviewSession&&e.properties?.gist?.livePreview&&Tn(e),e.firstLoad||e.isDisplayChange){if("tooltip"===ne(e)){const t=e.properties?.gist?.elementId||e.elementId||void 0;if(!t||!R(t)){if(oi.config.isPreviewSession&&e.properties?.gist?.livePreview){i(`Preview: tooltip target "${t}" not found, preview bar will show element picker`),e.firstLoad=!1,e.isDisplayChange=!1;break}i(`Tooltip target not found for "${t}", emitting error and skipping display`),oi.messageError(e),e.firstLoad=!1,e.isDisplayChange=!1,zn(e);break}const n=await async function(t){const e=t.instanceId??"",n=Ut(t),o=`gist-tooltip-${e}`,s=R(o);if(!s)return i(`Tooltip wrapper not found for instance ${e}`),!1;const a=t.properties?.gist?.elementId||t.elementId||void 0;if(!a)return i(`No target selector for tooltip ${e}`),!1;const r=we.get(e);r&&(r.cleanup(),we.delete(e));const l=s.querySelector(".gist-tooltip-outer");if(!l)return i(`Tooltip inner element not found for instance ${e}`),!1;const d=n.tooltipPosition||"bottom";if(!await async function(t,e,n){const o=le(e);if(!o)return!1;let s=[];try{s=ue(o)}catch{}if(de(o.getBoundingClientRect(),s))return!0;if(!function(t,e,n){const i=le(e);if(!i)return!1;const o=i.getBoundingClientRect(),s=window.innerWidth,a=window.innerHeight,r=new DOMRect(Math.max(0,(s-o.width)/2),Math.max(0,(a-o.height)/2),o.width,o.height);return t.style.display="",null!==pe(t.getBoundingClientRect(),r,n)}(t,e,n))return i(`Preflight failed: tooltip would not fit after scrolling target "${e}" into view`),!1;o.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),await function(t){return new Promise(e=>{let n=t.getBoundingClientRect(),i=0;const o=Date.now();setTimeout(function s(){const a=t.getBoundingClientRect();Math.abs(a.top-n.top)<1&&Math.abs(a.left-n.left)<1?i++:i=0,n=a,i>=2||Date.now()-o>1e3?e():setTimeout(s,50)},50)})}(o);const a=o.getBoundingClientRect();let r=[];try{r=ue(o)}catch{}return de(a,r)}(l,a,d))return i(`Tooltip for instance ${e} skipped: target "${a}" is off-screen and cannot be scrolled into a valid position`),!1;const c=function(t,e,n,o){const s=le(e);if(!s)return null;let a=null,r=null,l=!1,d=[],c=null;try{d=ue(s)}catch{}function p(){if(l)return;if(!s||!document.contains(s)||!document.contains(t))return i("Tooltip or target element removed from DOM, cleaning up listeners"),g(),void o?.onDetach?.();const e=s.getBoundingClientRect();if(!de(e,d))return void(t.style.display="none");t.style.display="";const a=pe(t.getBoundingClientRect(),e,n);a?(function(t,e){t.style.position="absolute",t.style.top=`${e.top+window.scrollY}px`,t.style.left=`${e.left+window.scrollX}px`}(t,a),function(t,e){const n=t.querySelector(".gist-tooltip-arrow");n&&(n.classList.remove("gist-arrow-top","gist-arrow-bottom","gist-arrow-left","gist-arrow-right"),n.classList.add(re[e.position]),null!==e.arrowOffset?"top"===e.position||"bottom"===e.position?(n.style.left=`calc(50% + ${e.arrowOffset}px)`,n.style.removeProperty("top")):(n.style.top=`calc(50% + ${e.arrowOffset}px)`,n.style.removeProperty("left")):"top"===e.position||"bottom"===e.position?(n.style.left="50%",n.style.removeProperty("top")):(n.style.top="50%",n.style.removeProperty("left")))}(t,a)):t.style.display="none"}function u(){null===a&&(a=requestAnimationFrame(()=>{a=null,p()}))}function g(){if(!l){l=!0,c&&(c.disconnect(),c=null),window.removeEventListener("scroll",u),window.removeEventListener("resize",u);for(const t of d)t.removeEventListener("scroll",u);null!==a&&(cancelAnimationFrame(a),a=null),null!==r&&(cancelAnimationFrame(r),r=null)}}if(p(),l)return null;window.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",u,{passive:!0});for(const t of d)t.addEventListener("scroll",u,{passive:!0});try{c=new MutationObserver(()=>{null===r&&(r=requestAnimationFrame(()=>{r=null,document.contains(s)||p()}))}),c.observe(document.body,{childList:!0,subtree:!0})}catch{}return{cleanup:g,reposition:p}}(l,a,d,{onDetach:()=>{we.delete(e);const t=R(o);t&&t.parentNode?.removeChild(t)}});if(c){if("none"!==l.style.display){const t=s.querySelector(".gist-tooltip-container");return t?(we.set(e,c),t.classList.add("gist-visible"),!0):(c.cleanup(),i(`Tooltip container not found for instance ${e}`),!1)}return c.cleanup(),i(`Tooltip for instance ${e} could not be positioned within the viewport, target "${a}" may be off-screen`),!1}return i(`Failed to position tooltip for instance ${e}, target "${a}" may not exist or no position fits the viewport`),!1}(e);if(!n){if(oi.config.isPreviewSession&&e.properties?.gist?.livePreview){i(`Preview: tooltip positioning failed for "${t}", preview bar will remain active`),e.firstLoad=!1,e.isDisplayChange=!1;break}i(`Tooltip positioning failed for "${t}", emitting error and cleaning up`),oi.messageError(e),e.firstLoad=!1,e.isDisplayChange=!1,zn(e);break}}else e.overlay?function(t){const e=Ut(t),n=document.querySelector("#gist-overlay");if(n){n.classList.add("gist-visible");const i=document.querySelector(".gist-message");i&&(t.position?i.classList.add("gist-"+t.position):i.classList.add("gist-center")),setTimeout(Ie,100),e.exitClick&&setTimeout(()=>function(t){const e=document.querySelector("#gist-overlay");e&&e.addEventListener("click",()=>{oi.dismissMessage(t)})}(t.instanceId??""),1e3)}else ve()}(e):function(t){const e=R(t);e&&e.classList.add("gist-visible")}(e.elementId);e.firstLoad&&!e.isDisplayChange&&(oi.messageShown(e),o.persistent?i("Persistent message shown, skipping logging view"):await Bn(e)),e.firstLoad=!1,e.isDisplayChange=!1}Yt(t,e);break}case"tap":{const t=n.gist.parameters.action,i=n.gist.parameters.name;if(oi.messageAction(e,t,i),n.gist.parameters.system&&!o.persistent){await Mn(e);break}try{const n=new URL(t);if(n&&"gist:"===n.protocol)switch(n.href.replace("gist://","").split("?")[0]){case"close":await Rn(e),await Jn(e),await Mn(e),await ti();break;case"showMessage":{const t=n.searchParams.get("messageId"),e=n.searchParams.get("properties");if(t){const n=e?JSON.parse(atob(e)):void 0;await oi.showMessage({messageId:t,properties:n})}break}case"loadPage":{const t=n.href.substring(n.href.indexOf("?url=")+5);t&&(t.startsWith("mailto:")||t.startsWith("https://")||t.startsWith("http://")||t.startsWith("/")?window.location.href=t:window.location.href=window.location+t);break}}}catch{}break}case"changeMessageStep":{const t=n.gist.parameters.displaySettings,r=n.gist.parameters.messageStepName;oi.config.isPreviewSession&&r&&e.properties?.gist?.livePreview&&function(t,e){if(nn)return;tn=t;const n=Ke.find(e=>e.stepName===t);n?Ze={...n.displaySettings}:e&&(Ze={...e}),$n()}(r,t),(o.persistent||Pe(e))&&await async function(t,e,n){const o=await Oe(t);if(!o)return;const r=a(o)||{},l={stepName:void 0!==e?e:r.stepName,displaySettings:void 0!==n?n:r.displaySettings},d=new Date;d.setDate(d.getDate()+30),s(o,l,d),i(`Saved message state for queueId: ${t}`)}(e.queueId??"",r,t),t&&ie(e,t)&&(i("Display settings changed, reloading message"),await Vn(e),oe(e,t),await Fn(e,r??null));break}case"routeChanged":e.currentRoute=n.gist.parameters.route,e.renderStartTime=(new Date).getTime(),Yt(t,e),i(`Route changed to: ${e.currentRoute}`);break;case"sizeChanged":i(`Size Changed Width: ${n.gist.parameters.width} - Height: ${n.gist.parameters.height}`),"tooltip"===ne(e)?function(t,e){const n=t.instanceId??"",i=Se(n),o=document.getElementById(i);if(o&&e.height>0){o.style.height=`${e.height}px`;const t=we.get(n);t&&t.reposition()}}(e,n.gist.parameters):e.elementId&&!e.shouldResizeHeight||function(t,e){const n=R(t.elementId?t.elementId:Se(t.instanceId??""));if(n){const i=n.style;if(e.height>0)if(e.height>window.innerHeight){const n=1-(e.height/window.innerHeight-1);t.shouldScale&&n>=.4?(i.height=`${e.height}px`,i.transform=`translateX(-50%) translateY(-50%) scale(${n})`):i.height=`${window.innerHeight}px`}else i.height=`${e.height}px`}}(e,n.gist.parameters);break;case"titleChanged":i(`Overlay title changed to: ${n.gist.parameters.title}`),function(t,e){const n=R(Se(t));n&&(n.title=e)}(t,n.gist.parameters.title);break;case"eventDispatched":oi.events.dispatch("eventDispatched",{name:n.gist.parameters.name,payload:n.gist.parameters.payload});break;case"error":case"routeError":oi.messageError(e),"tooltip"===ne(e)?zn(e):oi.overlayInstanceId?await Wn(!1,e):qn(e)}}}async function Fn(t,e){t.isDisplayChange=!0,t.renderStartTime=(new Date).getTime();const n=ne(t),o=t.elementId||null;if("tooltip"===n)return oi.overlayInstanceId===t.instanceId&&(oi.overlayInstanceId=null),t.shouldScale=!1,t.shouldResizeHeight=!1,void On(t,null,e);if(o){const e=Jt(o);e&&e.instanceId!==t.instanceId&&(i(`Dismissing existing message at ${o} to make room for multi-step message`),await Mn(e))}if(t.overlay){oi.overlayInstanceId=t.instanceId??null;const e=Ut(t);t.shouldScale=e.shouldScale,t.shouldResizeHeight=!0}else oi.overlayInstanceId=null,t.shouldScale=!1,t.shouldResizeHeight=!me(o??"");o&&Ht.includes(o)&&Ft(o),On(t,o,e)}async function Vn(t){"tooltip"===ne(t)?xe(t):t.overlay?await ye():t.elementId&&ge(t.elementId)}async function Gn(t,e,n){n&&ie(t,n)&&(await Vn(t),oe(t,n)),await Fn(t,e??null)}async function Xn(t){i(`Logging user message view locally for: ${t.queueId}`),Te(t)?await async function(t){i(`Marking broadcast ${t} as seen.`);const e=await De();if(!e)return;const n=await Le(e,t);if(!n)return;const o=n.properties.gist.broadcast,{frequency:r}=o,l=Ne(e,t),d=Me(e,t),c=a(l)||0;if(s(l,c+1),1===r.count)s(d,!1),i(`Marked broadcast ${t} as seen.`);else{const e=new Date;e.setSeconds(e.getSeconds()+r.delay),s(d,!1,e),i(`Marked broadcast ${t} as seen, broadcast was seen ${c+1} times, next show date is ${e}.`)}}(t.queueId??""):await async function(t){const e=await We();if(!e)return;const n=a(e)??[];n.push(t),s(e,n)}(t.queueId??"")}async function Jn(t){Te(t)&&(i(`Logging broadcast dismissed locally for: ${t.queueId}`),await async function(t){i(`Marking broadcast ${t} as dismissed.`);const e=await De();if(!e)return;const n=await Le(e,t);n&&(!0!==n.properties.gist.broadcast.frequency.ignoreDismiss?(s(Me(e,t),!1),i(`Marked broadcast ${t} as dismissed and will not show again.`)):i(`Broadcast ${t} is set to ignore dismiss.`))}(t.queueId??""),await Be(t.queueId??""))}const Qn=(t,e)=>t().then((t=>new Promise(e=>setTimeout(e,t)))(e).then(()=>Qn(t,e)));let Yn=!1,Kn=null;async function Zn(){Yn?await ti():Rt()?(i("Queue watcher started"),Yn=!0,Qn(()=>new Promise(()=>{!async function(){if(C.hasActiveSSEConnection())return!C.isSSEConnectionManagedBySDK()&&Kn&&(i("Not the main instance, closing our SSE connection."),ii()),void await ti();Kn&&(i("SSE connection not active, closing it."),ii()),!C.useSSE()||At()?await ni():await async function(){ii();const t=function(){const t=Wt();return null===t?(i("No user token available for SSE endpoint."),null):C.GIST_QUEUE_REALTIME_API_ENDPOINT[oi.config.env??"prod"]+`/api/v3/sse?userToken=${t}&siteId=${oi.config.siteId}&sessionId=${Pt()}`}();if(null===t)return i("SSE endpoint not available, falling back to polling."),void await ni();i(`Starting SSE queue listener on ${t}`),Kn=new EventSource(t),C.setActiveSSEConnection(),Kn.addEventListener("connected",async t=>{try{i("SSE connection received"),C.setUseSSEFlag(!0);const e=JSON.parse(t.data);e.heartbeat&&(C.setSSEHeartbeat(e.heartbeat),i(`SSE heartbeat set to ${e.heartbeat} seconds`)),C.setActiveSSEConnection()}catch(t){i(`Failed to parse SSE settings: ${t}`)}r(Lt),await ni()}),Kn.addEventListener("messages",async t=>{try{const e=JSON.parse(t.data);i("SSE message received"),await Re(e),await Ee(e),await ti()}catch(t){i(`Failed to parse SSE message: ${t}`),ii()}}),Kn.addEventListener("inbox_messages",async t=>{try{const e=JSON.parse(t.data);i("SSE inbox messages received"),await U(e)}catch(t){i(`Failed to parse SSE inbox messages: ${t}`)}}),Kn.addEventListener("error",async()=>{i("SSE error received"),ii()}),Kn.addEventListener("heartbeat",async()=>{i("SSE heartbeat received"),C.setActiveSSEConnection(),C.setUseSSEFlag(!0)})}()}()}),1e3)):i("User token not setup, queue not started.")}async function ti(){const t=await je(),e=await qe(),n=t.concat(e);i(`Messages in local queue: ${n.length}`);const o=n.sort((t,e)=>t.priority-e.priority);for(const t of o)await ei(t)}async function ei(t){let e=Ut(t);if(e.hasRouteRule){if(null==oi.currentRoute&&"loading"===document.readyState)return i(`Deferring message ${t.queueId}, page not fully loaded`),!1;if(!ee(e.routeRule))return i(`Route ${new URL(window.location.href).pathname} (currentRoute: ${oi.currentRoute}) does not match rule: ${e.routeRule}`),!1}if(e.hasPosition&&(t.position=e.position),e.hasTooltipPosition&&(t.tooltipPosition=e.tooltipPosition),e.persistent||Pe(t)){const n=await async function(t){const e=await Oe(t);return e?a(e):null}(t.queueId??"");n&&(i(`Restoring saved state for queueId ${t.queueId}`),n.displaySettings&&(oe(t,n.displaySettings),e=Ut(t)),t.savedStepName=n.stepName??null)}if(e.persistent||Pe(t)||!await async function(t){const e=await _e(t);return!!e&&null!==a(e)}(t.queueId??"")){let n=null;return e.isEmbedded?!oi.config.isPreviewSession||!t.properties?.gist?.livePreview||R(e.elementId)||Ht.includes(e.elementId)?n=Nn(t,e.elementId):(i(`Preview: element "${e.elementId}" not found, showing as overlay so placement can be changed`),n=await Dn(t)):n=await Dn(t),n&&async function(t){const e=await _e(t);e&&s(e,!0,new Date(Date.now()+5e3))}(t.queueId??""),null!==n}return i(`Not showing message with queueId ${t.queueId} because its already loading.`),!1}async function ni(){if(Rt())if(oi.isDocumentVisible)if(null===a(Lt)){const t=await async function(){if(jt)return;jt=!0;const t=Rt();let e;try{const t={"X-Gist-User-Anonymous":String(At()),"Content-Language":String(L())};e=await E().post(`/api/v4/users?sessionId=${Pt()}`,{},{headers:t})}catch(t){const n=k(t);n?e=n:i(`Error getting user queue: ${t}`)}finally{jt=!1}return t!==Rt()?(i("User token changed, clearing queue next pull check."),void r(Lt)):(function(t){const e=t?.headers?.["x-gist-queue-polling-interval"];Et=e&&Number(e)>0?Number(e):Math.min(2*Et,600);const n=new Date((new Date).getTime()+1e3*Et);s(Lt,Et,n)}(e),function(t){const e="true"===t?.headers?.["x-cio-use-sse"]?.toLowerCase();C.setUseSSEFlag(e)}(e),await async function(t){const e=t?.headers?.["x-cio-inbox-enabled"]?.toLowerCase();if(void 0===e)return;const n="true"===e;C.setInboxEnabledFlag(n),n&&(i("Inbox enabled, ensuring branding and templates are cached."),await kt(),yt())}(e),e)}();if(t){if(200===t.status||204===t.status){i("200 response, updating local store.");const e=t.data,n=e?.inAppMessages??[],o=e?.inboxMessages??[];Re(n),Ee(n),U(o)}else 304===t.status&&i("304 response, using local store.");await ti()}else i("No response object returned while checking message queue.")}else i("Next queue pull scheduled for later.");else i("Document not visible, skipping queue check.");else i("User token reset, skipping queue check.")}function ii(t=!1){t&&C.removeActiveSSEConnection(),(t||C.isSSEConnectionManagedBySDK())&&C.setUseSSEFlag(!1),Kn&&(i("Stopping SSE queue listener..."),Kn.close(),Kn=null)}class oi{static async setup(t){this.initialized?i("Gist SDK already initialized, skipping setup."):(this.initialized=!0,this.events=new n,this.config={useAnonymousSession:t.useAnonymousSession??!1,siteId:t.siteId,dataCenter:t.dataCenter,env:t.env??"prod",logging:t.logging??!1,experiments:t.experiments??!1},this.currentMessages=[],we.forEach(t=>t.cleanup()),we.clear(),document.querySelectorAll('[id^="gist-tooltip-"]').forEach(t=>{t.parentNode?.removeChild(t)}),this.overlayInstanceId=null,this.currentRoute=null,this.isDocumentVisible=!0,this.config.isPreviewSession=function(){const t=new URLSearchParams(window.location.search),e=t.get(Fe);if(e){sessionStorage.setItem(o,String(!1)),oi.setUserToken(e),i(`Preview mode enabled with user token: ${e}`),function(){if(document.getElementById(Je))return;z(Xe,He);try{en="true"===sessionStorage.getItem(Ge)}catch{en=!1}const t=q("div",{id:Je});document.body.appendChild(t),$n()}();const n=t.get(Ve);if(n)try{const t=JSON.parse(atob(n)),e=t.stepName||null,i=t.displayType||null;(e||i)&&function(t,e){cn=t,pn=e}(e,i)}catch{i("Preview bar: failed to parse cioPreviewSettings")}}return!l()}(),ki(),function(){const t=d();for(let e=t.length-1;e>=0;e--){const n=t.key(e);n?.startsWith("gist.")&&c(n)}}(),async function(){C.inboxEnabled()&&(D()&&A()||(i("Inbox enabled but missing cached branding/templates, fetching."),await kt()),yt())}(),i(`Setup complete on ${this.config.env} environment.`),this.config.isPreviewSession||!this.config.useAnonymousSession||new URLSearchParams(location.search).has("ajs_uid")||qt(),await Zn(),"loading"===document.readyState&&document.addEventListener("DOMContentLoaded",()=>{ti()},{once:!0}),document.addEventListener("visibilitychange",async()=>{"hidden"===document.visibilityState?this.isDocumentVisible=!1:(this.isDocumentVisible=!0,await ti())},!1))}static setupDebugOverlay(){ki()}static async setCurrentRoute(t){this.currentRoute=t,i(`Current route set to: ${t}`),await async function(){if(0!==oi.currentMessages.length)for(const t of[...oi.currentMessages])null==document.querySelector(`#gist-${t.instanceId}`)&&(i(`Removing active message ${t.instanceId} that no longer exists after route change`),await An(t))}(),await ti(),this.events?.dispatch("routeChanged",t)}static async setUserToken(t,e){this.config.isPreviewSession||(function(t,e){void 0===e&&(e=new Date).setDate(e.getDate()+30),s(Dt,t,e),At()&&(r(Lt),r(Nt)),i(`Set user token "${t}" with expiry date set to ${e}`)}(t,e),ii(!0),await Zn())}static setUserLocale(t){var e;s(j,e=t),i(`Set user locate to "${e}"`)}static setCustomAttribute(t,e){return function(t,e){return t&&"string"==typeof t?($e.set(t,e),ke(),i(`Set custom attribute "${t}" to "${e}"`),!0):(i(`Invalid key for custom attribute: ${t}`),!1)}(t,e)}static clearCustomAttributes(){$e.clear(),r(Ce),i("Cleared all custom attributes")}static removeCustomAttribute(t){return function(t){if(!t||"string"!=typeof t)return i(`Invalid key for custom attribute: ${t}`),!1;const e=$e.has(t);return $e.delete(t),$e.size>0?ke():r(Ce),i(`Removed custom attribute "${t}"`),e}(t)}static async clearUserToken(){this.config.isPreviewSession||(_t(),this.config.useAnonymousSession&&qt(),ii(!0),await Zn())}static async dismissMessage(t){const e=Gt(t);e&&(await Rn(e),await Jn(e),await Mn(e),await ti())}static async embedMessage(t,e){const n=Nn(t,e);return n?.instanceId??null}static async showMessage(t){const e=await Dn(t);return e?.instanceId??null}static updateMessageDisplaySettings(t,e){const n=Gt(t);return!!n&&(n.displaySettings=e,be(n),!0)}static messageShown(t){i(`Message shown: ${t.messageId}`),this.events.dispatch("messageShown",t)}static messageDismissed(t){null!==t&&(i(`Message dismissed: ${t.messageId}`),this.events.dispatch("messageDismissed",t))}static messageError(t){i(`Message error: ${t.messageId}`),this.events.dispatch("messageError",t)}static messageAction(t,e,n){i(`Message action: ${t.currentRoute}, ${e} with name ${n} on ${t.instanceId}`),this.events.dispatch("messageAction",{message:t,action:e,name:n})}static async getInboxUnopenedCount(){return(await H()).filter(t=>!t.opened).length}static async getInboxMessages(){return await H()}static async updateInboxMessageOpenState(t,e){return await F(t,e)}static async removeInboxMessage(t){return await V(t)}static isInboxEnabled(){return C.inboxEnabled()}}const si="\n #gist-debug-overlay {\n position: fixed; bottom: 16px; right: 16px;\n z-index: 99999999999;\n background: #08272B; color: white;\n font-family: system-ui, -apple-system, sans-serif;\n font-size: 11px;\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0,0,0,0.3);\n width: 300px;\n max-height: min(700px, calc(100vh - 32px));\n display: flex;\n flex-direction: column;\n pointer-events: auto;\n overflow: hidden;\n }\n .gist-debug-header {\n display: flex; align-items: center;\n padding: 8px 12px;\n border-bottom: 1px solid rgba(255,255,255,0.1);\n flex-shrink: 0;\n }\n .gist-debug-title {\n flex: 1;\n font-weight: 700;\n font-size: 12px;\n letter-spacing: 0.02em;\n }\n #gist-debug-overlay-close {\n background: none; border: none;\n color: white; cursor: pointer;\n padding: 0; font-size: 18px; line-height: 1;\n opacity: 0.6; flex-shrink: 0;\n font-family: system-ui, -apple-system, sans-serif;\n -webkit-appearance: none; appearance: none;\n }\n #gist-debug-overlay-close:hover { opacity: 1; }\n .gist-debug-section {\n padding: 0 12px 8px;\n border-bottom: 1px solid rgba(255,255,255,0.07);\n overflow-y: auto;\n max-height: 180px;\n }\n .gist-debug-section:last-child { border-bottom: none; }\n .gist-debug-label {\n position: sticky;\n top: 0;\n z-index: 1;\n background: #08272B;\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.08em;\n color: rgba(255,255,255,0.45);\n padding: 8px 0 5px;\n font-weight: 600;\n }\n .gist-debug-value {\n font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;\n font-size: 11px;\n color: rgba(255,255,255,0.9);\n overflow-wrap: break-word;\n }\n .gist-debug-msg {\n background: rgba(255,255,255,0.06);\n border-radius: 4px;\n padding: 5px 7px;\n margin-bottom: 8px;\n }\n .gist-debug-msg:last-child { margin-bottom: 0; }\n .gist-debug-msg-row {\n display: flex;\n align-items: center;\n gap: 6px;\n margin-bottom: 2px;\n }\n .gist-debug-msg-row:last-child { margin-bottom: 0; }\n .gist-debug-msg-meta {\n display: flex;\n align-items: center;\n gap: 5px;\n margin-bottom: 4px;\n }\n .gist-debug-msg-state {\n font-size: 9px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n border-radius: 3px;\n padding: 1px 4px;\n flex-shrink: 0;\n }\n .gist-debug-msg-state--active {\n color: #4caf82;\n background: rgba(76,175,130,0.12);\n }\n .gist-debug-msg-state--queued {\n color: rgba(255,200,100,0.9);\n background: rgba(255,200,100,0.1);\n }\n .gist-debug-msg-dismiss {\n margin-left: auto;\n background: none;\n border: none;\n color: rgba(255,255,255,0.3);\n cursor: pointer;\n padding: 0;\n font-size: 13px;\n line-height: 1;\n font-family: system-ui, -apple-system, sans-serif;\n -webkit-appearance: none;\n appearance: none;\n }\n .gist-debug-msg-dismiss:hover { color: rgba(255,255,255,0.7); }\n .gist-debug-element-found {\n color: #4caf82;\n font-size: 9px;\n font-weight: 700;\n flex-shrink: 0;\n }\n .gist-debug-route-mismatch {\n color: #ff6b6b;\n font-size: 9px;\n font-weight: 700;\n flex-shrink: 0;\n }\n .gist-debug-msg-type {\n font-size: 9px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n color: rgba(255,255,255,0.45);\n background: rgba(255,255,255,0.08);\n border-radius: 3px;\n padding: 1px 4px;\n flex-shrink: 0;\n }\n .gist-debug-msg-key {\n color: rgba(255,255,255,0.45);\n font-size: 10px;\n line-height: 1.4;\n min-width: 64px;\n flex-shrink: 0;\n }\n .gist-debug-msg-val {\n font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;\n font-size: 10px;\n line-height: 1.4;\n color: rgba(255,255,255,0.9);\n overflow-wrap: break-word;\n }\n .gist-debug-val-error {\n color: #ff6b6b;\n font-weight: 600;\n }\n .gist-debug-expand-detail {\n background: rgba(255,107,107,0.08);\n border-left: 2px solid rgba(255,107,107,0.4);\n color: rgba(255,255,255,0.75);\n font-family: system-ui, -apple-system, sans-serif;\n font-size: 10px;\n padding: 4px 6px;\n margin-top: 4px;\n margin-bottom: 6px;\n border-radius: 0 3px 3px 0;\n }\n .gist-debug-expand-list {\n margin: 0;\n padding: 0 0 0 14px;\n list-style: disc;\n }\n .gist-debug-expand-list li {\n margin-bottom: 3px;\n line-height: 1.4;\n }\n .gist-debug-expand-list li:last-child { margin-bottom: 0; }\n .gist-debug-msg-details {\n margin: 5px 0 0;\n padding: 0 0 0 14px;\n list-style: disc;\n color: rgba(255,255,255,0.5);\n font-size: 10px;\n line-height: 1.4;\n font-family: system-ui, -apple-system, sans-serif;\n }\n .gist-debug-msg-details li { margin-bottom: 2px; }\n .gist-debug-msg-details li:last-child { margin-bottom: 0; }\n",ai="gist-debug-overlay-styles",ri=2e3,li=5e3;let di=null,ci=!1,pi=!1,ui=null;function gi(t){const e=t.properties?.gist;return ne(e?{...t,tooltipPosition:e.tooltipPosition??t.tooltipPosition,elementId:null!=e.elementId?String(e.elementId):t.elementId}:t)}function mi(t,e,n=!1){const i=q("div",{className:"gist-debug-msg-row"});return i.appendChild(q("span",{className:"gist-debug-msg-key",textContent:t})),i.appendChild(q("span",{className:n?"gist-debug-msg-val gist-debug-val-error":"gist-debug-msg-val",textContent:e})),i}function fi(t,e,n=!1){t.replaceChildren(...e.map(([t,e])=>mi(t,e,n)))}function hi(t,e){const n=q("div",{className:"gist-debug-msg"}),i=q("div",{className:"gist-debug-msg-meta"});if(i.appendChild(q("span",{className:"gist-debug-msg-type",textContent:gi(t)})),i.appendChild(q("span",{className:`gist-debug-msg-state gist-debug-msg-state--${e}`,textContent:e})),t.instanceId){const e=q("button",{className:"gist-debug-msg-dismiss",textContent:"×"});e.addEventListener("click",()=>{vi(),oi.dismissMessage(t.instanceId).then(()=>{vi(),wi()})}),i.appendChild(e)}n.appendChild(i);const o=[];for(const[e,i]of function(t){const e=t.properties?.gist,n=[];e?.routeRuleWeb&&n.push(["Route Rule",String(e.routeRuleWeb)]);const i=e?.elementId??t.elementId,o=gi(t);if(i&&"overlay"===o){const t=function(t){if(t)return Zt[t]}(String(i));t&&n.push(["Position",t.replace(/([A-Z])/g," $1").toLowerCase()])}else i&&"modal"!==o&&n.push(["Target",String(i)]);const s=e?.position??t.position;s&&"overlay"!==o&&n.push(["Position",String(s)]);const a=e?.tooltipPosition??t.tooltipPosition;return a&&n.push(["Tooltip",String(a)]),n}(t)){let t=null,s=null;if("Route Rule"===e){const e=!ee(i);t=e?"gist-debug-route-mismatch":"gist-debug-element-found",s=e?"✕":"✓",e&&o.push("Route rule does not match current route. If it should, verify the route is set correctly and that analytics.page() is called on route changes.")}else if("Target"===e){const e=!!R(i);t=e?"gist-debug-element-found":"gist-debug-route-mismatch",s=e?"✓":"✕",e||o.push("Target element not found on the page. If it should, verify the selector is correct.")}const a=mi(e,i);t&&s&&a.appendChild(q("span",{className:t,textContent:s})),n.appendChild(a)}if(o.length>0){const t=q("ul",{className:"gist-debug-msg-details"});for(const e of o)t.appendChild(q("li",{textContent:e}));n.appendChild(t)}return n}function bi(t){const e=q("div",{className:"gist-debug-expand-detail"}),n=q("ul",{className:"gist-debug-expand-list"});return n.appendChild(q("li",{textContent:t})),e.appendChild(n),e}function yi(){di&&(di.root.remove(),document.getElementById(ai)?.remove(),null!==ui&&(clearInterval(ui),ui=null),ci&&(oi.events&&(oi.events.off("messageShown",xi),oi.events.off("messageDismissed",xi),oi.events.off("messageInboxUpdated",Si),oi.events.off("routeChanged",xi)),ci=!1),di=null)}function vi(){if(!di)return;oi.config?fi(di.configRows,[["Site ID",oi.config.siteId],["Connection",C.useSSE()?"SSE":`Polling ${Et}s`]]):fi(di.configRows,[["Status","NOT INITIALIZED"]],!0),di.configDetail.style.display=oi.config?"none":"";const t=Rt();t?At()?di.userValue.textContent="(anonymous)":di.userValue.textContent=t.length>32?`${t.slice(0,32)}…`:t:di.userValue.textContent="(none)";const e=oi.currentRoute;di.routeValue.replaceChildren(q("span",{className:e?"gist-debug-msg-val":"gist-debug-msg-val gist-debug-val-error",textContent:e??"NONE"})),di.routeDetail.style.display=e?"none":""}async function wi(){if(!pi&&di){pi=!0;try{const t=oi.currentMessages??[],[e,n]=oi.config?await Promise.all([qe(),je()]):[[],[]],i=new Set(t.map(t=>t.queueId??t.messageId)),o=new Set,s=[...n,...e].filter(t=>{const e=t.queueId??t.messageId;return!i.has(e)&&!o.has(e)&&(o.add(e),!0)});if(!di)return;const a=t.length+s.length;di.messagesLabel.textContent=`Messages (${a})`,di.messagesList.replaceChildren(...t.map(t=>hi(t,"active")),...s.map(t=>hi(t,"queued")))}finally{pi=!1}}}function xi(){vi(),wi()}function Si(){wi()}async function Ii(){ci||(!ci&&oi.events&&(oi.events.on("messageShown",xi),oi.events.on("messageDismissed",xi),oi.events.on("messageInboxUpdated",Si),oi.events.on("routeChanged",xi),ci=!0),ci&&Ci(li)),vi(),await wi()}function Ci(t){null!==ui&&clearInterval(ui),ui=setInterval(()=>{Ii()},t)}const $i="cio_debug_session";function ki(){if("undefined"!=typeof window&&"true"===new URLSearchParams(window.location.search).get($i))try{di||null!==ui||(z(ai,si),di=function(){const t=q("div",{id:"gist-debug-overlay"}),e=q("div",{className:"gist-debug-header"});e.appendChild(q("span",{className:"gist-debug-title",textContent:"Customer.io In-App SDK Debugger"}));const n=q("button",{id:"gist-debug-overlay-close",ariaLabel:"Dismiss debug overlay",textContent:"×"});n.addEventListener("click",yi),e.appendChild(n),t.appendChild(e);const i=q("div",{className:"gist-debug-section"}),o=q("div",{className:"gist-debug-label"});o.appendChild(q("span",{textContent:"Config"})),i.appendChild(o);const s=q("div",{});i.appendChild(s);const a=bi("Verify your site ID and credentials are correct.");i.appendChild(a),t.appendChild(i);const r=q("div",{className:"gist-debug-section"}),l=q("div",{className:"gist-debug-label",textContent:"User"});r.appendChild(l);const d=q("div",{className:"gist-debug-value"});r.appendChild(d),t.appendChild(r);const c=q("div",{className:"gist-debug-section"}),p=q("div",{className:"gist-debug-label"});p.appendChild(q("span",{textContent:"Route"})),c.appendChild(p);const u=q("div",{className:"gist-debug-value"});c.appendChild(u);const g=bi("The current route is used to match against potential message page rules.");c.appendChild(g),t.appendChild(c);const m=q("div",{className:"gist-debug-section"}),f=q("div",{className:"gist-debug-label"});m.appendChild(f);const h=q("div",{});return m.appendChild(h),t.appendChild(m),{root:t,configRows:s,configDetail:a,userValue:d,routeValue:u,routeDetail:g,messagesLabel:f,messagesList:h}}(),W(di.root),Ci(ri),Ii())}catch(t){i(`Failed to initialize debug overlay: ${t}`)}}return"undefined"!=typeof window&&ki(),e.default})());
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Gist=e():t.Gist=e()}(this,()=>(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{default:()=>oi});class n{constructor(){this.callbacks={}}on(t,e){const n=this.callbacks[t];n?n.push(e):this.callbacks[t]=[e]}off(t,e){const n=this.callbacks[t];if(!n)return;if(!e)return void delete this.callbacks[t];const i=n.indexOf(e);-1!==i&&n.splice(i,1),0===n.length&&delete this.callbacks[t]}dispatch(t,e){const n=this.callbacks[t];n&&[...n].forEach(n=>{try{n(e)}catch(e){console.warn(`[Gist] Error in "${t}" event listener:`,e)}})}}function i(t){oi.config&&oi.config.logging&&console.log(`Gist: ${t}`)}const o="gist.web.isPersistingSession";function s(t,e,n=null){let i=n;i||(i=new Date,i.setDate(i.getDate()+365));const o={value:e,expiry:i};d().setItem(t,JSON.stringify(o))}function a(t){return c(t)}function r(t){d().removeItem(t)}function l(){const t=sessionStorage.getItem(o);return null===t?(sessionStorage.setItem(o,"true"),!0):"true"===t}function d(){return l()?localStorage:sessionStorage}function c(t){if(!t)return null;try{const e=d().getItem(t);if(!e)return null;const n=JSON.parse(e);if(!n.expiry)return n.value;if(t.startsWith("gist.")){const e=new Date,i=new Date(n.expiry),o=t.startsWith("gist.web.message.broadcasts")&&!t.endsWith("shouldShow")&&!t.endsWith("numberOfTimesShown")||t.startsWith("gist.web.message.user")&&!t.endsWith("seen")&&!t.endsWith("state"),s=new Date(e.getTime()+366e4);if(o&&i.getTime()>s.getTime())return r(t),null;if(e.getTime()>i.getTime())return r(t),null}return n.value}catch(e){i(`Error checking key ${t} for expiry: ${e}`)}return null}var p,u=new Uint8Array(16);function g(){if(!p&&!(p="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return p(u)}const m=/^(?:[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 f=[],h=0;h<256;++h)f.push((h+256).toString(16).substr(1));const b=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(f[t[e+0]]+f[t[e+1]]+f[t[e+2]]+f[t[e+3]]+"-"+f[t[e+4]]+f[t[e+5]]+"-"+f[t[e+6]]+f[t[e+7]]+"-"+f[t[e+8]]+f[t[e+9]]+"-"+f[t[e+10]]+f[t[e+11]]+f[t[e+12]]+f[t[e+13]]+f[t[e+14]]+f[t[e+15]]).toLowerCase();if(!function(t){return"string"==typeof t&&m.test(t)}(n))throw TypeError("Stringified UUID is invalid");return n},y=function(t,e,n){var i=(t=t||{}).random||(t.rng||g)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,e){n=n||0;for(var o=0;o<16;++o)e[n+o]=i[o];return e}return b(i)},v="gist.web.inbox.enabled",w="gist.web.userQueueUseSSE",x="gist.web.activeSSEConnection";let S,I=30;const C={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:()=>(S||(S=y()),S),useSSE:()=>a(w)??!1,setUseSSEFlag(t){s(w,t,new Date((new Date).getTime()+6e4)),i(`Set user uses SSE to "${t}"`)},removeActiveSSEConnection(){r(x)},setActiveSSEConnection(){s(x,C.getSdkId(),new Date((new Date).getTime()+C.getSSEHeartbeat()))},hasActiveSSEConnection:()=>a(x)??!1,isSSEConnectionManagedBySDK:()=>a(x)===C.getSdkId(),getSSEHeartbeat:()=>1e3*(I+5),setSSEHeartbeat(t){t&&t>0&&(I=t)},inboxEnabled:()=>a(v)??!1,setInboxEnabledFlag(t){s(v,t,new Date((new Date).getTime()+36e5)),i(`Set inbox enabled to "${t}"`)}};function $(t){return null!==t&&"object"==typeof t&&"response"in t}function k(t){return $(t)?t.response:void 0}function E(){const t=C.GIST_QUEUE_API_ENDPOINT[oi.config.env??"prod"],e={"X-CIO-Site-Id":oi.config.siteId,"X-CIO-Client-Platform":"web"},n=Wt();async function i(n,i={}){const o=t+n,s=new AbortController,a=setTimeout(()=>s.abort(),5e3);try{const t=await fetch(o,{method:i.method||"GET",headers:{...e,...i.headers||{}},body:i.method&&"GET"!==i.method.toUpperCase()?i.body:void 0,signal:s.signal});clearTimeout(a);const n=t.headers.get("content-type")?.includes("application/json"),r=n?await t.json():await t.text(),l=Object.fromEntries(t.headers.entries());if(t.status<200||t.status>=400)throw function(t){return Object.assign(new Error,{response:t})}({status:t.status,data:r,headers:l});return{status:t.status,headers:l,data:r}}catch(t){if(clearTimeout(a),$(t))throw t;if(t instanceof Error)throw Object.assign(t,{response:{status:0,data:t.message||"Unknown error",headers:{}}});throw t}}return null!=n&&(e["X-Gist-Encoded-User-Token"]=n),i.post=(t,e={},n={})=>i(t,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json",...n.headers||{}}}),i}const j="gist.web.userLocale";function L(){const t=a(j);return null!==t?t:navigator.language}const T="gist.web.branding";async function P(){if(null!==a(T))return void i("Branding already cached.");const t=await async function(){try{return await E()("/api/v1/branding")}catch(t){return k(t)}}();if(t&&t.status>=200&&t.status<300){const e=new Date;e.setMinutes(e.getMinutes()+10),s(T,t.data,e),i("Branding fetched and cached.")}}function D(){return a(T)}const N="gist.web.templates";async function M(){if(null!==a(N))return void i("Templates already cached.");const t=await async function(){try{return await E()("/api/v1/templates")}catch(t){return k(t)}}();if(t&&t.status>=200&&t.status<300){const e=new Date;e.setMinutes(e.getMinutes()+60),s(N,t.data,e),i("Templates fetched and cached.")}}function A(){return a(N)}function R(t){try{return(document.getElementById(t)??document.querySelector(t))||null}catch{return null}}function q(t,e={}){const n=document.createElement(t);for(const[t,i]of Object.entries(e))n[t]=i;return n}function z(t,e){if(document.getElementById(t))return;const n=document.createElement("style");n.id=t,n.textContent=e,document.head.appendChild(n)}function W(t){document.body?document.body.appendChild(t):document.addEventListener("DOMContentLoaded",()=>document.body.appendChild(t),{once:!0})}async function _(t){try{return await E().post(`/api/v1/logs/queue/${t}`)}catch(t){return k(t)}}const O="messageInboxUpdated",B="inboxMessageAction";async function U(t){const e=await G();if(!e)return;const n=new Date;n.setMinutes(n.getMinutes()+60),s(e,t,n),oi.events.dispatch(O,t)}async function H(){const t=await G();if(!t)return[];const e=a(t)??[],n=new Date;return e.filter(t=>!t.expiry||new Date(t.expiry)>n)}async function F(t,e){const n=await G();if(!n)return;const o=await async function(t,e){try{return await E()(`/api/v1/messages/${t}`,{method:"PATCH",body:JSON.stringify(e),headers:{"Content-Type":"application/json"}})}catch(t){return k(t)}}(t,{opened:e});if(!o||o.status<200||o.status>=300){const t=`Failed to mark inbox message opened: ${o?.status??"unknown error"}`;throw i(t),new Error(t)}const a=await H();let r=null;const l=a.map(n=>{if(n.queueId===t){const t={...n,opened:e};return r=t,t}return n}),d=new Date;if(d.setMinutes(d.getMinutes()+60),s(n,l,d),r){const t=e?"opened":"unopened";oi.events.dispatch(B,{message:r,action:t})}oi.events.dispatch(O,await H())}async function V(t){const e=await G();if(!e)return;const n=await H(),o=n.find(e=>e.queueId===t)??null,a=n.filter(e=>e.queueId!==t),r=new Date;r.setMinutes(r.getMinutes()+60),s(e,a,r),o&&oi.events.dispatch(B,{message:o,action:"dismissed"}),oi.events.dispatch(O,await H());const l=await _(t);(!l||l.status<200||l.status>=300)&&i(`Failed to log inbox message view: ${l?.status??"unknown error"}`)}async function G(){const t=await zt();return t?`gist.web.inbox.messages.${t}`:null}const X="jist",J={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},Q={start:"flex-start",end:"flex-end",center:"center","space-between":"space-between","space-around":"space-around","space-evenly":"space-evenly"};function Y(t){return"number"==typeof t?`${t}px`:"fill"===t?"100%":t}function K(t){try{return new Date(t).toLocaleDateString(navigator.language)}catch{return t}}class Z{#t;#e;#n;#i=0;constructor({formatDate:t,onAction:e,templates:n}={}){this.#t=t||K,this.#e=e||null,this.#n=n||{}}render(t,e){if(!t)return null;switch(t.type){case"layout":return this.#o(t,e);case"action":return this.#s(t,e);case"heading":return this.#a(t,e);case"text":return this.#r("p",t,e);case"date":return this.#l(t,e);case"button":return this.#d(t,e);case"image":return this.#c(t,e);case"dynamicLayout":return this.#p(t,e);case"template":return this.#u(t,e);default:return null}}#o(t,e){const n=document.createElement("div");n.style.display="flex",n.style.flexDirection="horizontal"===t.direction?"row":"column",t.gap&&(n.style.gap=Y(t.gap)),t.align&&(n.style.alignItems=J[t.align]||t.align),t.justify&&(n.style.justifyContent=Q[t.justify]||t.justify),t.margin&&(t.margin.top&&(n.style.marginTop=Y(t.margin.top)),t.margin.right&&(n.style.marginRight=Y(t.margin.right)),t.margin.bottom&&(n.style.marginBottom=Y(t.margin.bottom)),t.margin.left&&(n.style.marginLeft=Y(t.margin.left)));const i="horizontal"===t.direction,o=i&&(!t.justify||"start"===t.justify),s=i||"center"!==t.align?i||"end"!==t.align?"":"right":"center";for(const i of t.children||[]){const t=this.render(i,e);t&&(o&&"layout"===i.type&&(t.style.flex="1",t.style.minWidth="0"),s&&(t.style.textAlign=s),n.appendChild(t))}return n}#s(t,e){const n=t.name||"action",i=document.createElement("div");this.#g(i,"action",n),i.setAttribute("role","button"),i.setAttribute("tabindex","0");for(const n of t.children||[]){const t=this.render(n,e);t&&i.appendChild(t)}const o=e[n],s=t.meta||null;if(this.#e){const t=this.#e,e=e=>{e.stopPropagation(),t({component:"action",name:n,data:o,meta:s,event:e})};i.addEventListener("click",e),i.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),e(t))})}return i}#a(t,e){const n=t.variant||"h3";return this.#r(n,t,e,n)}#r(t,e,n,i){const o=e.name||e.type,s=document.createElement(t);return this.#g(s,e.type,o,i||e.variant),s.textContent=n[o]||"",s}#l(t,e){const n=t.name||"date",i=document.createElement("time");this.#g(i,"date",n,t.variant);const o=e[n];return i.textContent=o?this.#t(o,n):"",i}#d(t,e){const n=t.name||"button",i=e[n];if(!i)return null;const o=document.createElement("button");this.#g(o,"button",n,t.variant),o.textContent=i.label,i.disabled&&(o.disabled=!0);const s=t.meta||null;return o.addEventListener("click",t=>{t.stopPropagation(),this.#e&&this.#e({component:"button",name:n,data:i,meta:s,event:t})}),o}#c(t,e){const n=t.name||"image",i=e[n];if(!i)return null;const o=document.createElement("div");this.#g(o,"image",n,t.variant),o.style.overflow="hidden";const s=document.createElement("img");return s.src=i,s.alt=e.title||"",s.style.display="block",t.width&&(s.style.width=Y(t.width)),t.height&&(s.style.height=Y(t.height)),t.objectFit&&(s.style.objectFit=t.objectFit),t.borderRadius&&(s.style.borderRadius=Y(t.borderRadius)),o.appendChild(s),o}#p(t,e){const n=e[t.name];if(!Array.isArray(n))return null;const i=document.createElement("div"),o=t.direction||"vertical";i.style.display="flex",i.style.flexDirection="horizontal"===o?"row":"column",t.gap&&(i.style.gap=Y(t.gap)),t.align&&(i.style.alignItems=J[t.align]||t.align),t.justify&&(i.style.justifyContent=Q[t.justify]||t.justify),t.margin&&(t.margin.top&&(i.style.marginTop=Y(t.margin.top)),t.margin.right&&(i.style.marginRight=Y(t.margin.right)),t.margin.bottom&&(i.style.marginBottom=Y(t.margin.bottom)),t.margin.left&&(i.style.marginLeft=Y(t.margin.left)));for(const e of n){const n="object"==typeof e&&null!==e?e:{},o=this.render(t.template,n);o&&i.appendChild(o)}return i}#u(t,e){const n=this.#n[t.name];if(!n||this.#i>=10)return null;this.#i++;const i=this.render(n.root,e);return this.#i--,i}#g(t,e,n,i){t.classList.add(`${X}__${e}`),i&&t.classList.add(`${X}__${e}--${i}`),n!==e&&t.classList.add(`${X}__${n}`)}}var tt;const et=new Set(["fontWeight","maxLines","lineHeight","opacity"]),nt=new Set(["lineHeight","letterSpacing"]),it={"text-font-size":"font-size","text-font-weight":"font-weight","text-font-family":"font-family","text-color":"color","text-line-height":"line-height","text-letter-spacing":"letter-spacing","text-max-lines":"-webkit-line-clamp","background-color":"background-color","border-width":"border-width","border-color":"border-color","border-radius":"border-radius","padding-top":"padding-top","padding-right":"padding-right","padding-bottom":"padding-bottom","padding-left":"padding-left","margin-top":"margin-top","margin-right":"margin-right","margin-bottom":"margin-bottom","margin-left":"margin-left","min-width":"min-width","min-height":"min-height"},ot=["shadow-offset-x","shadow-offset-y","shadow-blur","shadow-color"],st={"shadow-offset-x":"0","shadow-offset-y":"0","shadow-blur":"0","shadow-color":"transparent"},at={heading:new Set(["text","padding","margin"]),text:new Set(["text","padding","margin"]),date:new Set(["text","padding","margin"]),button:new Set(["text","background","border","shadow","padding","margin","minWidth","minHeight","states"]),image:new Set(["border","padding","margin"])},rt=["hover","active","disabled"],lt=[["background-color","background-color"],["color","text-color"]];class dt extends HTMLElement{static observedAttributes=["template","data","theme","mode"];static#m=!1;static#f=null;static#h=0;static#b=new Map;static#y(){if(tt.#m)return;if(tt.#m=!0,document.querySelector("style[data-jist-base]"))return;const t=document.createElement("style");t.setAttribute("data-jist-base",""),t.textContent="/* ═══════════════════════════════════════════\n Jist Template Styles\n ═══════════════════════════════════════════ */\n\n/* ── Host Element ───────────────────────── */\n\njist-template {\n display: block;\n}\n\n/* ── Base Reset ─────────────────────────── */\n\n.jist__heading,\n.jist__text,\n.jist__date {\n margin: 0;\n padding: 0;\n}\n\n/* ── Heading ────────────────────────────── */\n\n.jist__heading {\n font-size: var(--jist-heading-text-font-size, 16px);\n font-weight: var(--jist-heading-text-font-weight, 600);\n color: var(--jist-heading-text-color, #000000);\n font-family: var(--jist-heading-text-font-family, inherit);\n line-height: var(--jist-heading-text-line-height, 1.3);\n letter-spacing: var(--jist-heading-text-letter-spacing, normal);\n padding-top: var(--jist-heading-padding-top, 0);\n padding-right: var(--jist-heading-padding-right, 0);\n padding-bottom: var(--jist-heading-padding-bottom, 0);\n padding-left: var(--jist-heading-padding-left, 0);\n margin-top: var(--jist-heading-margin-top, 0);\n margin-right: var(--jist-heading-margin-right, 0);\n margin-bottom: var(--jist-heading-margin-bottom, 0);\n margin-left: var(--jist-heading-margin-left, 0);\n /* Line clamping — active when --jist-heading-text-max-lines is set */\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: var(--jist-heading-text-max-lines, none);\n overflow: hidden;\n}\n\n/* ── Text ───────────────────────────────── */\n\n.jist__text {\n font-size: var(--jist-text-text-font-size, 14px);\n font-weight: var(--jist-text-text-font-weight, 400);\n color: var(--jist-text-text-color, #000000);\n font-family: var(--jist-text-text-font-family, inherit);\n line-height: var(--jist-text-text-line-height, 1.5);\n letter-spacing: var(--jist-text-text-letter-spacing, normal);\n padding-top: var(--jist-text-padding-top, 0);\n padding-right: var(--jist-text-padding-right, 0);\n padding-bottom: var(--jist-text-padding-bottom, 0);\n padding-left: var(--jist-text-padding-left, 0);\n margin-top: var(--jist-text-margin-top, 0);\n margin-right: var(--jist-text-margin-right, 0);\n margin-bottom: var(--jist-text-margin-bottom, 0);\n margin-left: var(--jist-text-margin-left, 0);\n /* Line clamping — active when --jist-text-text-max-lines is set */\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: var(--jist-text-text-max-lines, none);\n overflow: hidden;\n}\n\n/* ── Date ───────────────────────────────── */\n\n.jist__date {\n font-size: var(--jist-date-text-font-size, 12px);\n font-weight: var(--jist-date-text-font-weight, 400);\n color: var(--jist-date-text-color, #000000);\n font-family: var(--jist-date-text-font-family, inherit);\n line-height: var(--jist-date-text-line-height, 1.4);\n letter-spacing: var(--jist-date-text-letter-spacing, normal);\n padding-top: var(--jist-date-padding-top, 0);\n padding-right: var(--jist-date-padding-right, 0);\n padding-bottom: var(--jist-date-padding-bottom, 0);\n padding-left: var(--jist-date-padding-left, 0);\n margin-top: var(--jist-date-margin-top, 0);\n margin-right: var(--jist-date-margin-right, 0);\n margin-bottom: var(--jist-date-margin-bottom, 0);\n margin-left: var(--jist-date-margin-left, 0);\n}\n\n/* ── Button ─────────────────────────────── */\n\n.jist__button {\n appearance: none;\n -webkit-appearance: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n border: none;\n font-size: var(--jist-button-text-font-size, 14px);\n font-weight: var(--jist-button-text-font-weight, 500);\n color: var(--jist-button-text-color, #ffffff);\n font-family: var(--jist-button-text-font-family, inherit);\n line-height: var(--jist-button-text-line-height, 1);\n background-color: var(--jist-button-background-color, #4f46e5);\n border-width: var(--jist-button-border-width, 0);\n border-style: solid;\n border-color: var(--jist-button-border-color, transparent);\n border-radius: var(--jist-button-border-radius, 6px);\n box-shadow:\n var(--jist-button-shadow-offset-x, 0)\n var(--jist-button-shadow-offset-y, 0)\n var(--jist-button-shadow-blur, 0)\n var(--jist-button-shadow-color, transparent);\n padding-top: var(--jist-button-padding-top, 8px);\n padding-right: var(--jist-button-padding-right, 16px);\n padding-bottom: var(--jist-button-padding-bottom, 8px);\n padding-left: var(--jist-button-padding-left, 16px);\n margin-top: var(--jist-button-margin-top, 0);\n margin-right: var(--jist-button-margin-right, 0);\n margin-bottom: var(--jist-button-margin-bottom, 0);\n margin-left: var(--jist-button-margin-left, 0);\n min-width: var(--jist-button-min-width, 0);\n min-height: var(--jist-button-min-height, 0);\n transition: background-color 0.15s ease, color 0.15s ease,\n border-color 0.15s ease, box-shadow 0.15s ease;\n}\n\n.jist__button:hover {\n background-color: var(--jist-button-states-hover-background-color,\n var(--jist-button-background-color, #4338ca));\n color: var(--jist-button-states-hover-text-color,\n var(--jist-button-text-color, #ffffff));\n}\n\n.jist__button:active {\n background-color: var(--jist-button-states-active-background-color,\n var(--jist-button-background-color, #3730a3));\n color: var(--jist-button-states-active-text-color,\n var(--jist-button-text-color, #ffffff));\n}\n\n.jist__button:disabled {\n background-color: var(--jist-button-states-disabled-background-color,\n var(--jist-button-background-color, #c7d2fe));\n color: var(--jist-button-states-disabled-text-color,\n var(--jist-button-text-color, #a5b4fc));\n cursor: not-allowed;\n}\n\n/* ── Image ──────────────────────────────── */\n\n.jist__image {\n display: block;\n max-width: 100%;\n overflow: hidden;\n border-radius: var(--jist-image-border-radius, 0);\n padding-top: var(--jist-image-padding-top, 0);\n padding-right: var(--jist-image-padding-right, 0);\n padding-bottom: var(--jist-image-padding-bottom, 0);\n padding-left: var(--jist-image-padding-left, 0);\n margin-top: var(--jist-image-margin-top, 0);\n margin-right: var(--jist-image-margin-right, 0);\n margin-bottom: var(--jist-image-margin-bottom, 0);\n margin-left: var(--jist-image-margin-left, 0);\n}\n\n.jist__image img {\n border-radius: inherit;\n}\n\n/* ── Dark Mode Defaults ────────────────── */\n\n[data-jist-dark] .jist__heading { color: var(--jist-heading-text-color, #ffffff); }\n[data-jist-dark] .jist__text { color: var(--jist-text-text-color, #ffffff); }\n[data-jist-dark] .jist__date { color: var(--jist-date-text-color, #ffffff); }\n[data-jist-dark] .jist__button { color: var(--jist-button-text-color, #ffffff); }\n\n/* ── Action (clickable wrapper) ─────────── */\n\n.jist__action {\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n}\n\n.jist__action:focus-visible {\n outline: 2px solid var(--jist-button-background-color, #4f46e5);\n outline-offset: 2px;\n border-radius: 4px;\n}\n",document.head.appendChild(t)}#v=null;#w=null;#x=null;#S=null;#I="auto";#t=null;#e=null;#n={};#C=null;#$=null;get template(){return this.#w}set template(t){this.#w=t,this.#k()}get data(){return this.#x}set data(t){this.#x="string"==typeof t?JSON.parse(t):t,this.#k()}get theme(){return this.#S}set theme(t){this.#S="string"==typeof t?JSON.parse(t):t,this.#E(),this.#k()}get mode(){return this.#I}set mode(t){this.#I=t||"auto",this.#E()}get formatDate(){return this.#t}set formatDate(t){this.#t=t,this.#k()}get onAction(){return this.#e}set onAction(t){this.#e=t}get templates(){return this.#n}set templates(t){const e="string"==typeof t?JSON.parse(t):t||{},n={};for(const[t,i]of Object.entries(e)){if(t.startsWith("$"))continue;if(!Array.isArray(i))continue;const e=i.find(t=>"1"===t.version);e&&(n[t]=e)}this.#n=n,this.#k()}connectedCallback(){tt.#y(),this.#C=window.matchMedia("(prefers-color-scheme: dark)"),this.#$=()=>{"auto"===this.#I&&(this.#E(),this.#k())},this.#C.addEventListener("change",this.#$),this.#E(),this.#k()}disconnectedCallback(){this.#C&&this.#$&&this.#C.removeEventListener("change",this.#$),this.#j(),tt.#L()}attributeChangedCallback(t,e,n){if(e!==n)switch(t){case"template":this.#w=n||null,this.#k();break;case"data":this.#x=n?JSON.parse(n):null,this.#k();break;case"theme":this.#S=n?JSON.parse(n):null,this.#E(),this.#k();break;case"mode":this.#I=n||"auto",this.#E(),this.#k()}}#T(){return"dark"===this.#I||"light"!==this.#I&&(this.#C?.matches??!1)}#E(){if(!this.isConnected)return void(this.#S||(this.#j(),tt.#L()));if(this.#T()?this.setAttribute("data-jist-dark",""):this.removeAttribute("data-jist-dark"),!this.#S)return this.#j(),void tt.#L();const t=[];for(let e=0;e<this.style.length;e++)this.style[e].startsWith("--jist-")&&t.push(this.style[e]);if(t.forEach(t=>this.style.removeProperty(t)),this.#P(this.#S,"--jist"),this.#T()){const t=this.#S.modes?.dark;t&&this.#P(t,"--jist")}this.#D()}#P(t,e){for(const[n,i]of Object.entries(t)){if("modes"===n||n.startsWith("$"))continue;const t=`${e}-${n.replace(/([A-Z])/g,"-$1").toLowerCase()}`;if(null===i||"object"!=typeof i||Array.isArray(i)){if(null!=i&&""!==i){const e=0===i&&nt.has(n)?"normal":"number"!=typeof i||et.has(n)?String(i):`${i}px`;this.style.setProperty(t,e)}}else this.#P(i,t)}}#D(){const t=[],e=this.#S;if(!e)return;const n=e.modes?.dark;for(const i of Object.keys(at)){const o=e[i],s=n?.[i],a=at[i],r=new Set;for(const t of[o,s])if(t)for(const e of Object.keys(t))a.has(e)||e.startsWith("$")||r.add(e);for(const e of r){const n=o?.[e]??{},a=s?.[e]??{};t.push(this.#N(i,e,n,a))}}const i=t.join("\n");if(this.#j(),!i)return;let o=tt.#b.get(i);o||(o={id:tt.#h++,refs:0},tt.#b.set(i,o)),o.refs++,this.#v=i,this.setAttribute("data-jist-v",String(o.id)),tt.#L()}#j(){if(!this.#v)return;const t=tt.#b.get(this.#v);t&&(t.refs--,t.refs<=0&&tt.#b.delete(this.#v)),this.#v=null,this.removeAttribute("data-jist-v")}static#L(){if(0===tt.#b.size)return void(tt.#f&&(tt.#f.remove(),tt.#f=null));tt.#f||(tt.#f=document.createElement("style"),tt.#f.setAttribute("data-jist-variants",""),document.head.appendChild(tt.#f));const t=[];for(const[e,{id:n}]of tt.#b){const i=`[data-jist-v="${n}"]`;t.push(e.replace(/^(\.[a-z_-]+)/gm,`${i} $1`))}tt.#f.textContent=t.join("\n")}#N(t,e,n,i){const o=e.replace(/([A-Z])/g,"-$1").toLowerCase(),s=`.jist__${t}--${o}`,a=new Set,r=(t,e)=>{for(const[n,i]of Object.entries(t)){if("states"===n||n.startsWith("$"))continue;const t=n.replace(/([A-Z])/g,"-$1").toLowerCase(),o=e?`${e}-${t}`:t;null===i||"object"!=typeof i||Array.isArray(i)?a.add(o):r(i,o)}};r(n,""),r(i,"");const l=[];for(const e of a){const n=it[e];if(!n)continue;const i=`--jist-${t}-${o}-${e}`,s=`--jist-${t}-${e}`;l.push(` ${n}: var(${i}, var(${s}));`)}if("button"===t&&[...a].some(t=>t.startsWith("shadow-"))){const t=ot.map(t=>`var(--jist-button-${o}-${t}, var(--jist-button-${t}, ${st[t]}))`);l.push(` box-shadow: ${t.join(" ")};`)}let d=`${s} {\n${l.join("\n")}\n}`;if("button"===t&&(n.states||i.states))for(const t of rt){const e=n.states?.[t],a=i.states?.[t];if(!e&&!a)continue;const r=[];for(const[e,n]of lt){const i=`--jist-button-${o}-states-${t}-${n}`,s=`--jist-button-states-${t}-${n}`,a=`--jist-button-${o}-${n}`,l=`--jist-button-${n}`;r.push(` ${e}: var(${i}, var(${s}, var(${a}, var(${l}))));`)}d+=`\n${s}${"disabled"===t?":disabled":`:${t}`} {\n${r.join("\n")}\n}`}return d}#k(){if(!this.#w||!this.#x)return;if(!this.isConnected)return;const t=this.#n[this.#w];if(!t)return void(this.innerHTML="");const e=new Z({formatDate:this.#t||void 0,templates:this.#n,onAction:t=>{this.#e&&this.#e(t),this.dispatchEvent(new CustomEvent("jist-action",{bubbles:!0,detail:{component:t.component,name:t.name,data:t.data,meta:t.meta}}))}});this.innerHTML="";const n=e.render(t.root,this.#x);n&&this.appendChild(n)}}tt=dt,customElements.define("jist-template",dt);const ct=dt,pt="gist-inbox-button",ut="gist-inbox-badge",gt="gist-inbox-panel",mt="gist-inbox-messages";let ft=!1,ht=!1;const bt=new Set;function yt(){ft||(ft=!0,customElements.get("jist-template")||customElements.define("jist-template",ct),z("gist-inbox-styles","\n#gist-inbox-button {\n position: fixed;\n width: 56px;\n height: 56px;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n z-index: 9998;\n border: none;\n transition: background-color 0.2s ease,\n box-shadow 0.2s ease,\n transform 0.15s ease;\n}\n#gist-inbox-button:hover {\n transform: scale(1.05);\n}\n#gist-inbox-button:active {\n transform: scale(0.93);\n}\n#gist-inbox-button svg {\n width: 24px;\n height: 24px;\n}\n#gist-inbox-badge {\n position: absolute;\n top: -4px;\n right: -4px;\n min-width: 20px;\n height: 20px;\n border-radius: 10px;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0 6px;\n box-sizing: border-box;\n}\n#gist-inbox-panel {\n position: fixed;\n width: 400px;\n max-height: 600px;\n z-index: 9999;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n user-select: none;\n -webkit-user-select: none;\n transform: translateY(8px) scale(0.96);\n opacity: 0;\n pointer-events: none;\n transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),\n opacity 0.2s ease;\n}\n#gist-inbox-panel.gist-inbox-panel--open {\n transform: translateY(0) scale(1);\n opacity: 1;\n pointer-events: auto;\n}\n#gist-inbox-messages {\n overflow-y: auto;\n flex: 1;\n}\n.gist-inbox-message-row {\n transition: background-color 0.15s ease;\n}\n"),oi.events.on("messageInboxUpdated",t=>{vt(t)}),vt())}async function vt(t){t||(t=await H());const e=function(t){return t.filter(t=>t.topics?.some(t=>t.startsWith("cio_inbox"))).sort((t,e)=>{const n=(t.priority??Number.MAX_SAFE_INTEGER)-(e.priority??Number.MAX_SAFE_INTEGER);return 0!==n?n:new Date(e.sentAt??0).getTime()-new Date(t.sentAt??0).getTime()})}(t);if(0===e.length)return void wt();let n=D();n||(await kt(),n=D());const o=n?.patterns?.inbox;if(o){if(function(t,e){let n=document.getElementById(pt);n||(n=q("div",{id:pt}),n.addEventListener("click",()=>{ht?(ht=!1,document.getElementById(gt)?.classList.remove("gist-inbox-panel--open")):(ht=!0,vt())}),W(n));const i=$t(t.position);n.style.background=t.floatingIcon.background,n.style.color=t.floatingIcon.color,n.style.boxShadow="0 2px 8px rgba(0,0,0,0.15)",Object.assign(n.style,i),n.querySelector("svg")||n.insertAdjacentHTML("afterbegin",t.floatingIcon.svg);!function(t,e,n){let i=document.getElementById(ut);if(0===n||!e.unreadIndicator.showAlert)return void i?.remove();i||(i=q("span",{id:ut}),t.appendChild(i));const o=e.unreadIndicator;i.textContent=String(n),i.style.background=o.background,i.style.color=o.text.color,i.style.fontSize=`${o.text.fontSize}px`,i.style.fontWeight=String(o.text.fontWeight),i.style.fontFamily=o.text.fontFamily,i.style.lineHeight=String(o.text.lineHeight)}(n,t,e.filter(t=>!t.opened).length)}(o,e),ht){!function(t,e){let n=document.getElementById(gt);const o=!n;o&&(n=q("div",{id:gt}),W(n));const s=$t(t.position,!0);n.style.background=t.background,n.style.borderRadius=`${t.cornerRadius}px`,n.style.border=`1px solid ${t.borderColor}`,n.style.boxShadow=`${t.shadow.offsetX}px ${t.shadow.offsetY}px ${t.shadow.blur}px ${t.shadow.color}`,Object.assign(n.style,s);let a=document.getElementById(mt);a||(a=q("div",{id:mt}),n.appendChild(a)),a.innerHTML="";const r=D(),l=A();e.forEach((n,o)=>{const s=q("div",{className:"gist-inbox-message-row"});s.style.padding="12px 16px",s.style.cursor="pointer",s.addEventListener("mouseenter",()=>{s.style.background=t.hoverBackground}),s.addEventListener("mouseleave",()=>{s.style.background=""});const d=document.createElement("jist-template");s.appendChild(d),a.appendChild(s);const c=d;if(c.onAction=t=>{i(`Inbox action: ${t.name}`);const e=function(t){if(!t||"object"!=typeof t)return null;const e=t;return"string"==typeof e.behavior&&["openUrl","dismiss","openDeeplink","performAction"].includes(e.behavior)?{behavior:e.behavior,action:"string"==typeof e.action?e.action:void 0,name:"string"==typeof e.name?e.name:void 0,dismiss:"boolean"==typeof e.dismiss?e.dismiss:void 0,newTab:"boolean"==typeof e.newTab?e.newTab:void 0}:null}(t.data);e&&function(t,e){"openUrl"!==e.behavior&&"openDeeplink"!==e.behavior||!e.action||(function(t){try{return"javascript:"!==new URL(t,window.location.href).protocol}catch{return!1}}(e.action)?e.newTab?window.open(e.action,"_blank","noopener"):window.location.href=e.action:i(`Blocked unsafe URL: ${e.action}`)),("dismiss"===e.behavior||e.dismiss)&&t.queueId&&V(t.queueId),oi.events.dispatch("inboxMessageAction",{message:t,action:"clicked",actionConfig:e})}(n,e)},l&&(c.templates=l),r?.theme&&(c.theme=r.theme),c.formatDate=Ct,c.data=n.properties??{},c.template=n.type??null,o<e.length-1){const e=q("div",{className:"gist-inbox-divider"});e.style.height="1px",e.style.background=t.dividerColor,e.style.margin="0",a.appendChild(e)}}),o?requestAnimationFrame(()=>{n.classList.add("gist-inbox-panel--open")}):n.classList.add("gist-inbox-panel--open")}(o,e);for(const t of e){const e=t.queueId;t.opened||!e||bt.has(e)||(bt.add(e),F(e,!0).finally(()=>{bt.delete(e)}))}}}else wt()}function wt(){document.getElementById(pt)?.remove(),document.getElementById(gt)?.remove(),ht=!1}const xt=[[60,"second",1],[3600,"minute",60],[86400,"hour",3600],[2592e3,"day",86400],[31536e3,"month",2592e3],[1/0,"year",31536e3]];let St=null,It=null;function Ct(t){const e=Math.round((Date.now()-new Date(t).getTime())/1e3);if(Number.isNaN(e))return t;const[,n,i]=xt.find(([t])=>Math.abs(e)<t);return function(){const t=L();return St&&It===t||(It=t,St=new Intl.RelativeTimeFormat(t,{numeric:"auto"})),St}().format(-Math.round(e/i),n)}function $t(t,e=!1){const n=e?"":"24px",i="96px";switch(t){case"bottom-left":return e?{bottom:i,left:"24px",right:"",top:""}:{bottom:n,left:n,right:"",top:""};case"top-right":return e?{top:i,right:"24px",bottom:"",left:""}:{top:n,right:n,bottom:"",left:""};case"top-left":return e?{top:i,left:"24px",bottom:"",right:""}:{top:n,left:n,bottom:"",right:""};default:return e?{bottom:i,right:"24px",left:"",top:""}:{bottom:n,right:n,left:"",top:""}}}async function kt(){await Promise.all([P(),M()])}let Et=600,jt=!1;const Lt="gist.web.userQueueNextPullCheck",Tt="gist.web.sessionId";function Pt(){let t=a(Tt);return t||(t=y()),s(Tt,t,new Date((new Date).getTime()+18e5)),String(t)}const Dt="gist.web.userToken",Nt="gist.web.usingGuestUserToken",Mt="gist.web.guestUserToken";function At(){return null!==a(Nt)}function Rt(){return a(Dt)}function qt(){if(null===Rt()){let t=a(Mt);null==t&&(t=y(),s(Mt,t),i(`Set guest user token "${t}" with expiry date set to 1 year from today`)),s(Dt,t),s(Nt,!0),i(`Using anonymous session with token: "${t}"`)}}async function zt(){const t=Rt();return null===t?null:await async function(t){const e=(new TextEncoder).encode(t),n=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(n)).map(t=>t.toString(16).padStart(2,"0")).join("")}(t)}function Wt(){const t=Rt();return null===t?null:btoa(t)}function _t(){r(Dt),i("Cleared user token")}const Ot={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 Bt(t){let e=Ot.tooltipArrowColor;if((t?.properties?.gist?.tooltipArrowColor?.length??0)>0)e=t.properties.gist.tooltipArrowColor;else{if(!Array.isArray(t?.displaySettings)||0===t.displaySettings.length)return e;let n=t.displaySettings[0];if(t.savedStepName){const e=t.displaySettings.find(e=>e?.stepName===t.savedStepName&&e.displaySettings);e&&(n=e)}n?.displaySettings?.tooltipArrowColor&&(e=n.displaySettings.tooltipArrowColor)}return e}function Ut(t){const e=Ot,n=t?.properties?.gist;return n?{isEmbedded:!!n.elementId&&!n.tooltipPosition,elementId:n.elementId||"",hasRouteRule:!!n.routeRuleWeb,routeRule:n.routeRuleWeb||"",position:n.position||"",hasPosition:!!n.position,tooltipPosition:n.tooltipPosition||"",hasTooltipPosition:!!n.tooltipPosition,tooltipArrowColor:Bt(t),shouldScale:!!n.scale,campaignId:n.campaignId??null,messageWidth:null!=n.messageWidth&&n.messageWidth>0?n.messageWidth:e.messageWidth,hasCustomWidth:(n.messageWidth??0)>0,overlayColor:n.overlayColor||e.overlayColor,persistent:!!n.persistent,exitClick:!!n.exitClick}:e}const Ht=["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 Ft(t){if(document.getElementById(t))return;const e=document.createElement("div");e.id=t,"x-gist-top"===t?document.body.insertBefore(e,document.body.firstChild):document.body.insertAdjacentElement("beforeend",e),i("Top & bottom elements injected into page")}const Vt=["x-gist-top","x-gist-bottom","x-gist-floating-top","x-gist-floating-bottom"];function Gt(t){return oi.currentMessages.find(e=>e.instanceId===t)}function Xt(t){return!!t&&oi.currentMessages.some(e=>e.queueId===t)}function Jt(t){return t?oi.currentMessages.find(e=>e.elementId===t)??null:null}function Qt(t){oi.currentMessages=oi.currentMessages.filter(e=>e.instanceId!==t)}function Yt(t,e){Qt(t),oi.currentMessages.push(e)}const Kt={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"},Zt=Object.fromEntries(Object.entries(Kt).map(([t,e])=>[e,t]));function te(t){return t&&Kt[t]?Kt[t]:(i(`Invalid overlay position "${t}", defaulting to "topCenter"`),Kt.topCenter)}function ee(t){try{const e=new RegExp(t),n=new URL(window.location.href).pathname,i=null!=oi.currentRoute&&e.test(oi.currentRoute),o=oi.currentRoute!==n&&e.test(n);return i||o}catch{return!1}}function ne(t){return t.tooltipPosition?"tooltip":t.overlay?"modal":t.elementId&&Ht.includes(t.elementId)?"overlay":t.elementId?"inline":"modal"}function ie(t,e){const n=ne(t),i=e.displayType;if(void 0===i)return!1;if(n!==i)return!0;const o=Ut(t);switch(i){case"modal":{if((t.position||"center")!==(e.modalPosition||"center"))return!0;const n=e.dismissOutsideClick??Ot.exitClick;if(o.exitClick!==n)return!0;const i=e.overlayColor??Ot.overlayColor;if(o.overlayColor!==i)return!0;break}case"overlay":{const n=te(e.overlayPosition);if(t.elementId!==n)return!0;break}case"inline":if(t.elementId!==e.elementSelector)return!0;break;case"tooltip":if(t.tooltipPosition!==e.tooltipPosition)return!0;if(t.elementId!==e.elementSelector)return!0;if(void 0!==e.tooltipArrowColor&&o.tooltipArrowColor!==e.tooltipArrowColor)return!0}if("overlay"!==i||!Vt.includes(te(e.overlayPosition))){const t=e.maxWidth??Ot.messageWidth;if(o.messageWidth!==t)return!0}return!1}function oe(t,e){if(t.properties||(t.properties={}),t.properties.gist||(t.properties.gist={}),"modal"===e.displayType)t.overlay=!0,t.elementId=null,t.properties.gist.elementId=null,t.position=e.modalPosition||"center",t.properties.gist.position=e.modalPosition||"center",t.tooltipPosition=void 0,t.properties.gist.tooltipPosition=void 0,t.properties.gist.tooltipArrowColor=void 0;else if("overlay"===e.displayType){t.overlay=!1;const n=te(e.overlayPosition);t.elementId=n,t.properties.gist.elementId=n,t.position=null,t.properties.gist.position=null,t.tooltipPosition=void 0,t.properties.gist.tooltipPosition=void 0,t.properties.gist.tooltipArrowColor=void 0}else"inline"===e.displayType?(t.overlay=!1,t.elementId=e.elementSelector,t.properties.gist.elementId=e.elementSelector,t.position=null,t.properties.gist.position=null,t.tooltipPosition=void 0,t.properties.gist.tooltipPosition=void 0,t.properties.gist.tooltipArrowColor=void 0):"tooltip"===e.displayType&&(t.overlay=!1,t.elementId=e.elementSelector,t.properties.gist.elementId=e.elementSelector,t.tooltipPosition=e.tooltipPosition,t.properties.gist.tooltipPosition=e.tooltipPosition,t.position=null,t.properties.gist.position=null,void 0!==e.tooltipArrowColor&&(t.properties.gist.tooltipArrowColor=e.tooltipArrowColor));t.elementId&&Vt.includes(t.elementId)?delete t.properties.gist.messageWidth:void 0!==e.maxWidth&&e.maxWidth>0?t.properties.gist.messageWidth=e.maxWidth:delete t.properties.gist.messageWidth,void 0!==e.overlayColor?t.properties.gist.overlayColor=e.overlayColor:delete t.properties.gist.overlayColor,void 0!==e.dismissOutsideClick?t.properties.gist.exitClick=e.dismissOutsideClick:delete t.properties.gist.exitClick}const se={top:["bottom","left","right"],bottom:["top","left","right"],left:["right","top","bottom"],right:["left","top","bottom"]},ae=/auto|scroll/,re={top:"gist-arrow-bottom",bottom:"gist-arrow-top",left:"gist-arrow-right",right:"gist-arrow-left"};function le(t){const e=R(t);return e||i(`Tooltip target element not found for selector: ${t}`),e}function de(t,e){if(t.bottom<=0||t.top>=window.innerHeight||t.right<=0||t.left>=window.innerWidth)return!1;for(const n of e){const e=n.getBoundingClientRect();if(t.bottom<=e.top||t.top>=e.bottom||t.right<=e.left||t.left>=e.right)return!1}return!0}function ce(t,e,n){const i=function(t,e,n){switch(n){case"top":return{top:e.top-t.height-16,left:e.left+(e.width-t.width)/2};case"bottom":return{top:e.bottom+16,left:e.left+(e.width-t.width)/2};case"left":return{top:e.top+(e.height-t.height)/2,left:e.left-t.width-16};case"right":return{top:e.top+(e.height-t.height)/2,left:e.right+16}}}(t,e,n);return function(t,e,n){return"top"===n||"bottom"===n?t.top>=0&&t.top+e.height<=window.innerHeight:t.left>=0&&t.left+e.width<=window.innerWidth}(i,t,n)&&function(t,e){return"top"===e||"bottom"===e?t.width+8<=window.innerWidth:t.height+8<=window.innerHeight}(t,n)?function(t,e,n){let{top:i,left:o}=t,s=null;if("top"===n||"bottom"===n){const t=4,n=window.innerWidth-e.width-4;n>=t&&(o<t?(s=o-t,o=t):o>n&&(s=o-n,o=n))}else{const t=4,n=window.innerHeight-e.height-4;n>=t&&(i<t?(s=i-t,i=t):i>n&&(s=i-n,i=n))}if(null!==s){const t=("top"===n||"bottom"===n?e.width/2:e.height/2)-16-4;Math.abs(s)>t&&(s=s>0?t:-t)}return{top:i,left:o,position:n,arrowOffset:s}}(i,t,n):null}function pe(t,e,n){const i=ce(t,e,n);if(i)return i;for(const i of se[n]){const n=ce(t,e,i);if(n)return n}return null}function ue(t){const e=[];let n=t.parentElement;for(;n;){const t=getComputedStyle(n),i=t.overflow+t.overflowX+t.overflowY;ae.test(i)&&e.push(n),n=n.parentElement}return e}function ge(t){const e=R(t);e&&(e.classList.remove("gist-visible"),Array.from(e.classList).filter(t=>t.startsWith("gist-")).forEach(t=>e.classList.remove(t)),e.style.removeProperty("height"),e.style.removeProperty("width"),e.innerHTML="")}function me(t){const e=R(t);if(e)return!(!e.style||!e.style.height||"0px"===e.style.height)}function fe(t,e,n=null){const i=document.getElementById(t);i&&(i.onload=()=>{!function(t,e,n=null){const i=document.getElementById(t);if(i?.contentWindow){const t={options:e,capabilities:he};n&&(e.stepId=n),i.contentWindow.postMessage(t,"*")}}(t,e,n)})}const he=["MultiStepDisplayTypes"];function be(t){if(!t.displaySettings)return;const e=Se(t.instanceId??""),n=document.getElementById(e);n?.contentWindow&&n.contentWindow.postMessage({action:"updateDisplaySettings",displaySettings:t.displaySettings},"*")}async function ye(){const t=document.querySelector(".gist-message");t&&(t.classList.remove("gist-visible"),await new Promise(t=>setTimeout(t,300))),ve()}function ve(){const t=document.querySelector("#gist-embed-message");t&&t.parentNode?.removeChild(t)}const we=new Map;function xe(t){const e=t.instanceId??"",n=we.get(e);n&&(n.cleanup(),we.delete(e));const i=R(`gist-tooltip-${e}`);i&&i.parentNode?.removeChild(i)}function Se(t){return`gist-${t}`}function Ie(){const t=document.querySelector(".gist-message");t&&t.classList.add("gist-visible")}const Ce="gist.web.customAttributes";let $e=new Map;function ke(){const t=Array.from($e.entries()),e=new Date;e.setDate(e.getDate()+30),s(Ce,t,e),i(`Saved ${$e.size} custom attributes to storage with TTL of 30 days`)}async function Ee(t){const e=await De();if(!e)return;const n=new Date;n.setMinutes(n.getMinutes()+60),s(e,t.filter(Te),n)}async function je(){const t=await De();return t?(a(t)??[]).filter(e=>{const n=e.properties.gist.broadcast,{frequency:i}=n,o=a(Me(t,e.queueId))??!0,s=a(Ne(t,e.queueId))||0,r=0===i.count;return o&&(r||s<i.count)}):[]}async function Le(t,e){const n=a(t);return n?.find(t=>t.queueId===e)}function Te(t){return!(!t.properties?.gist||!t.properties.gist.broadcast)}function Pe(t){if(!Te(t))return!1;const e=t.properties.gist.broadcast;return 0===e.frequency.delay&&0===e.frequency.count}async function De(){const t=await zt();return t?`gist.web.message.broadcasts.${t}`:null}function Ne(t,e){return`${t}.${e}.numberOfTimesShown`}function Me(t,e){return`${t}.${e}.shouldShow`}!function(){const t=a(Ce);if(t)try{$e=new Map(t)}catch{$e=new Map}else $e=new Map}();const Ae="gist.web.message.user";async function Re(t){const e=await ze();if(!e)return;const n=t.filter(t=>!(t.properties&&t.properties.gist&&t.properties.gist.broadcast)),i=new Date;i.setMinutes(i.getMinutes()+60),s(e,n,i)}async function qe(){const t=await ze();if(!t)return[];const e=a(t)??[],n=await async function(){const t=await We();return t?a(t)??[]:[]}();return e.filter(t=>!n.includes(t.queueId??""))}async function ze(){const t=await zt();return t?`${Ae}.${t}`:null}async function We(){const t=await zt();return t?`${Ae}.${t}.seen`:null}async function _e(t){const e=await zt();return e?`${Ae}.${e}.message.${t}.loading`:null}async function Oe(t){const e=await zt();return e?`${Ae}.${e}.message.${t}.state`:null}async function Be(t){const e=await Oe(t);e&&(r(e),i(`Cleared message state for queueId: ${t}`))}function Ue(t){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="${t}"/></svg>`}const He=`\n #gist-preview-bar {\n position: fixed; bottom: 0; left: 0; right: 0;\n z-index: 99999999999;\n font-family: system-ui, -apple-system, sans-serif;\n pointer-events: none;\n }\n .gist-pb-toggle-row {\n display: flex; justify-content: center;\n padding: 6px 16px;\n border-bottom: 1px solid #e5e7eb;\n }\n .gist-pb-toggle-row--collapsed { border-bottom: none; }\n .gist-pb-toggle-btn {\n background: #08272B; border: none;\n padding: 4px 14px;\n border-radius: 100px;\n font-size: 12px; font-weight: 500;\n font-family: system-ui, -apple-system, sans-serif;\n color: white; cursor: pointer;\n display: flex; align-items: center; gap: 6px;\n pointer-events: auto;\n height: auto; min-width: auto;\n box-sizing: border-box;\n line-height: normal;\n -webkit-appearance: none;\n appearance: none;\n }\n .gist-pb-controls-row {\n background: #F8F9F9;\n box-shadow: 1px 2px 2px #34344605, 3px 3px 8px #34344614;\n display: flex; flex-wrap: wrap; align-items: center;\n gap: 12px; padding: 10px 16px 12px;\n pointer-events: auto;\n }\n .gist-pb-label-group { display: flex; flex-direction: column; gap: 4px; }\n .gist-pb-label-group--grow { flex: 1; }\n .gist-pb-label {\n font-size: 10px; font-weight: 600; color: #3F4E50;\n letter-spacing: 0.05em; text-transform: uppercase;\n font-family: system-ui, -apple-system, sans-serif;\n }\n .gist-pb-select {\n height: 32px; padding: 0 32px 0 8px;\n border: 1px solid #d1d5db; border-radius: 6px;\n font-size: 13px; font-family: system-ui, -apple-system, sans-serif;\n background: white ${`url("data:image/svg+xml,${encodeURIComponent(Ue("#3F4E50"))}")`} no-repeat right 2px center;\n color: #3F4E50; cursor: pointer; outline: none;\n appearance: none; min-width: 120px;\n }\n .gist-pb-input {\n height: 32px; padding: 0 8px;\n border: 1px solid #d1d5db; border-radius: 6px;\n font-size: 13px; font-family: system-ui, -apple-system, sans-serif;\n color: #3F4E50; outline: none; box-sizing: border-box;\n }\n .gist-pb-checkbox-row { display: flex; align-items: center; gap: 6px; height: 32px; }\n .gist-pb-checkbox-label {\n font-size: 12px; font-family: system-ui, -apple-system, sans-serif;\n color: #3F4E50; cursor: pointer; user-select: none;\n }\n .gist-pb-color-control {\n display: flex; align-items: center;\n border: 1px solid #d1d5db; border-radius: 6px;\n overflow: hidden; height: 32px; background: white;\n }\n .gist-pb-color-swatch {\n width: 28px; height: 100%;\n cursor: pointer; flex-shrink: 0;\n border-right: 1px solid #d1d5db; position: relative;\n }\n .gist-pb-color-input {\n position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;\n }\n .gist-pb-color-hex {\n flex: 1; border: none; outline: none; padding: 0 6px;\n font-size: 13px; font-family: monospace; color: #3F4E50;\n min-width: 0; background: transparent;\n }\n .gist-pb-color-opacity {\n width: 36px; border: none; border-left: 1px solid #d1d5db;\n outline: none; padding: 0 4px;\n font-size: 13px; font-family: system-ui, -apple-system, sans-serif;\n color: #3F4E50; background: transparent; text-align: right;\n }\n .gist-pb-color-pct {\n font-size: 12px; color: #3F4E50; padding: 0 6px 0 2px;\n font-family: system-ui, -apple-system, sans-serif; flex-shrink: 0;\n }\n .gist-pb-input--invalid { border-color: #941616; outline: 1px solid #941616; }\n .gist-pb-inline-row { display: flex; align-items: center; gap: 6px; }\n .gist-pb-select-elem-btn, .gist-pb-cancel-btn {\n height: 32px; padding: 0 12px;\n border: none; border-radius: 6px;\n font-size: 12px; font-weight: 500; font-family: system-ui, -apple-system, sans-serif;\n background: #08272B; color: white; cursor: pointer; white-space: nowrap; flex-shrink: 0;\n min-width: auto; box-sizing: border-box;\n -webkit-appearance: none; appearance: none;\n }\n .gist-pb-select-elem-btn:disabled {\n opacity: 0.4; cursor: not-allowed;\n }\n .gist-pb-spacer { flex: 1; min-width: 0; }\n .gist-pb-save-btn {\n height: 36px; padding: 0 18px;\n background: #08272B; color: white;\n border: none; border-radius: 6px;\n font-size: 13px; font-weight: 600;\n font-family: system-ui, -apple-system, sans-serif;\n cursor: pointer; white-space: nowrap; align-self: center;\n min-width: auto; box-sizing: border-box;\n -webkit-appearance: none; appearance: none;\n }\n .gist-pb-save-btn:disabled {\n background: #CAD6D8; cursor: not-allowed;\n }\n .gist-pb-picker-overlay {\n position: fixed; inset: 0; z-index: 999999999998; cursor: crosshair;\n }\n .gist-pb-checkbox { cursor: pointer; width: 14px; height: 14px; }\n .gist-pb-pick-highlight { outline: 2px solid #006FF5 !important; }\n .gist-pb-pick-error { outline: 2px solid #941616 !important; }\n #gist-preview-bar.gist-pb-hidden { display: none; }\n .gist-pb-ended-row {\n justify-content: center; align-items: center; gap: 10px; padding: 12px 16px;\n flex-wrap: nowrap;\n }\n .gist-pb-ended-icon {\n display: flex; align-items: center; justify-content: center;\n width: 22px; height: 22px; border-radius: 50%;\n background: #08272B; color: white;\n font-size: 13px; font-weight: 700; flex-shrink: 0;\n }\n .gist-pb-ended-text {\n margin: 0; font-size: 13px; color: #3F4E50;\n font-family: system-ui, -apple-system, sans-serif;\n min-width: 0;\n }\n .gist-pb-ended-text strong { color: #08272B; }\n @media (max-width: 1024px) {\n .gist-pb-controls-row { gap: 8px; }\n .gist-pb-label-group { flex: 1 1 100%; }\n .gist-pb-label-group--grow { flex: 1 1 100%; }\n .gist-pb-select { width: 100%; min-width: unset; box-sizing: border-box; }\n .gist-pb-input { width: 100% !important; box-sizing: border-box; }\n .gist-pb-color-control { width: 100%; }\n .gist-pb-checkbox-row { width: 100%; }\n .gist-pb-inline-row { flex-direction: row; align-items: center; }\n .gist-pb-inline-row .gist-pb-input { flex: 1; min-width: 0; }\n .gist-pb-save-btn { width: 100%; box-sizing: border-box; }\n .gist-pb-label--spacer { display: none; }\n }\n`;const Fe="cioPreviewId",Ve="cioPreviewSettings";const Ge="gist.previewBar.collapsed",Xe="gist-pb-styles",Je="gist-preview-bar",Qe={topLeft:"Top Left",topCenter:"Top Center",topRight:"Top Right",bottomLeft:"Bottom Left",bottomCenter:"Bottom Center",bottomRight:"Bottom Right"};let Ye=null,Ke=[],Ze={},tn=null,en=!1,nn=!1,on=5,sn=null,an=!0,rn=!1,ln=!1,dn=null,cn=null,pn=null;const un=new Map;function gn(t,e){const n=q("div",{className:"gist-pb-label-group"});return n.appendChild(q("span",{className:"gist-pb-label",textContent:t})),n.appendChild(e),n}function mn(t,e){const n=q("select",{className:"gist-pb-select"});for(const i of t){const t=q("option",{value:i.value,textContent:i.label});i.value===e&&(t.selected=!0),n.appendChild(t)}return n}function fn(t,e,n){const i=q("input",{className:"gist-pb-input",type:t,value:String(e)});return n&&(i.style.width=n),i}function hn(t,e){const n=Math.round(Math.min(100,Math.max(0,e))/100*255);return"#"+t.replace("#","").toUpperCase()+n.toString(16).padStart(2,"0").toUpperCase()}function bn(t){return!!("inline"!==t.displayType&&"tooltip"!==t.displayType||t.elementSelector?.trim())}function yn(t){if("overlay"===t.displayType&&Vt.includes(te(t.overlayPosition))){const{maxWidth:e,...n}=t;t=n}if(Ze=t,tn){const e=Ke.findIndex(t=>t.stepName===tn);-1!==e&&(Ke[e]={...Ke[e],displaySettings:{...t}})}if(!Ye)return;const e=oi.currentMessages.find(t=>t.instanceId===Ye);e&&bn(t)&&(be(e),ie(e,t)&&Gn(e,tn,t)),function(){const t=new URLSearchParams(window.location.search).get(Fe);t&&async function(t,e){try{return await E()(`/api/v1/preview/${t}`,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json"}})}catch(t){return k(t)}}(t,Ke).then(t=>{t&&404===t.status&&Ye&&oi.dismissMessage(Ye)}).catch(()=>i("Failed to persist preview display settings"))}()}function vn(t){const e=t.value.trim();e&&!R(e)?t.classList.add("gist-pb-input--invalid"):t.classList.remove("gist-pb-input--invalid")}function wn(t,e){const n=fn("text",t.elementSelector||"","260px");n.placeholder="Element ID or selector",vn(n),n.addEventListener("change",()=>{const t=n.value.trim(),e=Ze.elementSelector;t&&xn(t),yn({...Ze,elementSelector:t}),e&&e!==t&&Sn(e),vn(n)});const i=q("button",{type:"button",className:"gist-pb-select-elem-btn",textContent:"Select Element"});ln&&(i.disabled=!0),i.addEventListener("click",()=>Cn(n));const o=q("div",{className:"gist-pb-inline-row"});o.appendChild(n),o.appendChild(i),e.appendChild(gn("Element Selector",o))}function xn(t){if(!t||un.has(t))return;const e=R(t);e&&un.set(t,e.innerHTML)}function Sn(t){const e=un.get(t);if(void 0===e)return;const n=R(t);n&&(n.innerHTML=e)}function In(){for(const t of un.keys())Sn(t);un.clear()}function Cn(t){if(ln)return;ln=!0;const e=document.querySelector(`#${Je} .gist-pb-select-elem-btn`);e&&(e.disabled=!0);const n={...Ze},o=oi.currentMessages.find(t=>t.instanceId===Ye)??null;o&&Vn(o),Ze.elementSelector&&Sn(Ze.elementSelector);const s=q("div",{className:"gist-pb-picker-overlay"});let a=null;const r=t=>{s.style.pointerEvents="none";const e=document.elementFromPoint(t.clientX,t.clientY);s.style.pointerEvents="all",e&&e!==a&&e!==s&&(a?.classList.remove("gist-pb-pick-highlight"),a=e,a.classList.add("gist-pb-pick-highlight"))},l=t=>{if("Escape"===t.key){if(c(),Ze=n,tn){const t=Ke.findIndex(t=>t.stepName===tn);-1!==t&&(Ke[t]={...Ke[t],displaySettings:{...n}})}o&&bn(n)&&Gn(o,tn,n),$n()}},d=e=>{e.preventDefault(),e.stopPropagation(),s.style.pointerEvents="none";const n=document.elementFromPoint(e.clientX,e.clientY);if(s.style.pointerEvents="all",n&&n!==s){n.classList.remove("gist-pb-pick-highlight");const e=document.getElementById(Je),s=e?.contains(n)?null:function(t){if(t.id){const e=CSS.escape(t.id);if(1===document.querySelectorAll(`#${e}`).length)return t.id}const e=[];let n=t;for(;n&&"BODY"!==n.tagName&&"HTML"!==n.tagName;){if(n.id){const t=CSS.escape(n.id);if(1===document.querySelectorAll(`#${t}`).length){e.unshift(`#${t}`);break}}let t=n.tagName.toLowerCase();n.className&&"string"==typeof n.className&&(t+=n.className.trim().split(/\s+/).filter(Boolean).map(t=>`.${CSS.escape(t)}`).join(""));const i=n.parentElement;i&&(t+=`:nth-of-type(${Array.from(i.children).filter(t=>t.tagName===n.tagName).indexOf(n)+1})`),e.unshift(t);try{if(1===document.querySelectorAll(e.join(" > ")).length)break}catch{}n=n.parentElement}const o=e.join(" > ");try{if(1!==document.querySelectorAll(o).length)return i("buildUniqueSelector: could not produce a unique selector for element"),null}catch{return null}return o}(n);if(null===s)return n.classList.add("gist-pb-pick-error"),void setTimeout(()=>{n.classList.remove("gist-pb-pick-error"),n.classList.add("gist-pb-pick-highlight")},800);t.value=s,xn(s);const a=Ze.elementSelector,r={...Ze,elementSelector:s},l=null!=o&&bn(r)&&ie(o,r);yn(r),a&&a!==s&&Sn(a),o&&!l&&Gn(o,tn,r)}c(),$n()},c=()=>{a?.classList.remove("gist-pb-pick-highlight"),s.removeEventListener("mousemove",r),s.removeEventListener("click",d),document.removeEventListener("keydown",l),document.body.removeChild(s),ln=!1,dn=null};dn=c,s.addEventListener("mousemove",r),s.addEventListener("click",d),document.addEventListener("keydown",l),document.body.appendChild(s)}function $n(){const t=document.getElementById(Je);if(!t)return;if(t.classList.toggle("gist-pb-hidden",!Ye&&!nn),t.innerHTML="",!Ye){if(nn){const e=q("div",{className:"gist-pb-controls-row gist-pb-ended-row"}),n=q("span",{className:"gist-pb-ended-icon",textContent:"✓"}),i=q("p",{className:"gist-pb-ended-text"});if(i.innerHTML=En(on),e.appendChild(n),e.appendChild(i),an){const t=q("button",{type:"button",className:"gist-pb-cancel-btn",textContent:"Cancel"});t.addEventListener("click",jn),e.appendChild(t)}t.appendChild(e)}return}const e=q("div",{className:"gist-pb-toggle-row"+(en?" gist-pb-toggle-row--collapsed":"")}),n=q("button",{type:"button",className:"gist-pb-toggle-btn"}),i=en?"transform:rotate(180deg);display:inline-flex;":"display:inline-flex;";if(n.innerHTML=`${en?"Expand":"Collapse"}<span style="${i}">${Ue("white")}</span>`,n.addEventListener("click",Ln),e.appendChild(n),t.appendChild(e),en)return;const o=q("div",{className:"gist-pb-controls-row"});if(Ke.length>0){const t=tn??Ke[0].stepName,e=mn(Ke.map(t=>({value:t.stepName,label:t.stepName})),t);e.addEventListener("change",()=>{const t=Ke.find(t=>t.stepName===e.value);if(t){tn=t.stepName,Ze={...t.displaySettings};const e=oi.currentMessages.find(t=>t.instanceId===Ye);e&&bn(t.displaySettings)&&Gn(e,t.stepName,t.displaySettings),$n()}}),o.appendChild(gn("Step",e))}const s=mn([{value:"modal",label:"Modal"},{value:"overlay",label:"Overlay"},{value:"inline",label:"Inline"},{value:"tooltip",label:"Tooltip"}],Ze.displayType||"modal");s.addEventListener("change",()=>{const t=s.value,e=Ze.displayType,n=Ze.elementSelector,i={...Ze,displayType:t};"modal"===t?(i.modalPosition=i.modalPosition||"center",i.maxWidth=i.maxWidth??414,delete i.overlayPosition,delete i.elementSelector,delete i.tooltipPosition):"overlay"===t?(i.overlayPosition=i.overlayPosition||"topCenter",i.maxWidth=i.maxWidth??414,delete i.modalPosition,delete i.elementSelector,delete i.tooltipPosition):"inline"===t?(delete i.modalPosition,delete i.overlayPosition,delete i.tooltipPosition):"tooltip"===t&&(i.tooltipPosition=i.tooltipPosition||"top",delete i.modalPosition,delete i.overlayPosition,delete i.overlayColor,delete i.dismissOutsideClick),Ze=i,yn(Ze),"inline"!==e&&"tooltip"!==e||!n||"inline"===t||"tooltip"===t||Sn(n),$n()}),o.appendChild(gn("Display Type",s));const a=Ze.displayType||"modal";"modal"===a?function(t,e){const n=mn([{value:"top",label:"Top"},{value:"center",label:"Center"},{value:"bottom",label:"Bottom"}],t.modalPosition||"center");n.addEventListener("change",()=>yn({...Ze,modalPosition:n.value})),e.appendChild(gn("Position",n));const i=fn("number",t.maxWidth??414,"80px");i.addEventListener("change",()=>yn({...Ze,maxWidth:parseInt(i.value)||414})),e.appendChild(gn("Max Width",i)),e.appendChild(function(t){const{color:e,opacity:n}=function(t){const e=t.replace("#","");return 8===e.length?{color:"#"+e.slice(0,6).toUpperCase(),opacity:Math.round(parseInt(e.slice(6),16)/255*100)}:6===e.length?{color:"#"+e.toUpperCase(),opacity:100}:{color:"#000000",opacity:20}}(t.overlayColor||"#00000033"),i=q("div",{className:"gist-pb-color-control"}),o=q("input",{className:"gist-pb-color-input",type:"color",value:e}),s=q("div",{className:"gist-pb-color-swatch"});s.style.background=e,s.appendChild(o),s.addEventListener("click",()=>o.click());const a=q("input",{className:"gist-pb-color-hex",type:"text",maxLength:6,value:e.replace("#","")}),r=q("input",{className:"gist-pb-color-opacity",type:"number",min:"0",max:"100",value:String(n)}),l=q("span",{className:"gist-pb-color-pct",textContent:"%"}),d=()=>{const t="#"+a.value.replace("#",""),e=parseInt(r.value)||0;s.style.background=t,o.value=t,yn({...Ze,overlayColor:hn(t,e)})};return o.addEventListener("input",()=>{a.value=o.value.replace("#","").toUpperCase(),s.style.background=o.value}),o.addEventListener("change",d),a.addEventListener("change",d),r.addEventListener("change",d),i.appendChild(s),i.appendChild(a),i.appendChild(r),i.appendChild(l),gn("Overlay Color",i)}(t));const o=q("div",{className:"gist-pb-checkbox-row"}),s=q("input",{className:"gist-pb-checkbox",type:"checkbox"});s.checked=t.dismissOutsideClick??!1;const a=q("label",{className:"gist-pb-checkbox-label",textContent:"Dismiss on click outside"});s.addEventListener("change",()=>yn({...Ze,dismissOutsideClick:s.checked})),a.addEventListener("click",()=>{s.checked=!s.checked,yn({...Ze,dismissOutsideClick:s.checked})}),o.appendChild(s),o.appendChild(a);const r=gn(" ",o);r.classList.add("gist-pb-label-group--grow"),r.firstChild.classList.add("gist-pb-label--spacer"),e.appendChild(r)}(Ze,o):"overlay"===a?function(t,e){const n=mn(Object.entries(Qe).map(([t,e])=>({value:t,label:e})),t.overlayPosition||"topCenter");if(n.addEventListener("change",()=>yn({...Ze,overlayPosition:n.value})),e.appendChild(gn("Position",n)),!Vt.includes(te(t.overlayPosition))){const n=fn("number",t.maxWidth??414,"80px");n.addEventListener("change",()=>yn({...Ze,maxWidth:parseInt(n.value)||414})),e.appendChild(gn("Max Width",n))}}(Ze,o):"inline"===a?function(t,e){wn(t,e)}(Ze,o):"tooltip"===a&&function(t,e){const n=mn([{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],t.tooltipPosition||"top");n.addEventListener("change",()=>yn({...Ze,tooltipPosition:n.value})),e.appendChild(gn("Position",n)),wn(t,e)}(Ze,o),o.appendChild(q("div",{className:"gist-pb-spacer"}));const r=q("button",{type:"button",className:"gist-pb-save-btn",textContent:"End session"});r.addEventListener("click",async()=>{Ye&&await oi.dismissMessage(Ye)}),o.appendChild(r),t.appendChild(o)}async function kn(){if(!rn)if(rn=!0,_t(),function(){try{sessionStorage.removeItem(o)}catch{}}(),an){try{window.close()}catch{}try{window.location.reload()}catch{}dn&&dn(),sn&&(clearInterval(sn),sn=null),In(),document.getElementById(Je)?.remove(),document.getElementById(Xe)?.remove(),Ye=null,Ke=[],Ze={},tn=null,nn=!1,on=5,an=!0,rn=!1}else nn=!1,rn=!1,$n()}function En(t){return an?`<strong>Preview session ended.</strong> This tab will close in ${t}s…`:`<strong>Preview session ended.</strong> Finishing session in ${t}s… This tab will stay open.`}function jn(){nn&&sn&&(an=!1,$n())}function Ln(){en=!en;try{sessionStorage.setItem(Ge,String(en))}catch{}$n()}function Tn(t){if(nn)return;Ye=t.instanceId??null;const e=t.displaySettings;if(Array.isArray(e)&&e.length>0?(Ke=e,tn||(tn=Ke[0].stepName,Ze={...Ke[0].displaySettings})):e&&"object"==typeof e&&!Array.isArray(e)&&(Ze={...e}),cn||pn){const t=!!cn,e=!!pn,n=cn,o=pn;if(cn=null,pn=null,t){const t=Ke.find(t=>t.stepName===n);if(!t)return i(`Preview bar: step "${n}" not found, ignoring initial step/display override`),void $n();tn=t.stepName,Ze={...t.displaySettings}}if(e){if(!t)return i(`Preview bar: display type "${o}" provided without a step, ignoring`),void $n();Ze={...Ze,displayType:o}}$n();const s=oi.currentMessages.find(t=>t.instanceId===Ye);return void(s&&bn(Ze)?Gn(s,tn,Ze):function(){const t=Ze.displayType;if("inline"!==t&&"tooltip"!==t)return;const e=document.querySelector("#gist-preview-bar .gist-pb-input[type='text']");e&&Cn(e)}())}$n()}function Pn(){In(),Ye=null,Ke=[],Ze={},tn=null,nn=!0,on=5,an=!0,rn=!1;const t=new URLSearchParams(window.location.search).get(Fe);t&&async function(t){try{return await E()(`/api/v1/preview/${t}`,{method:"DELETE"})}catch(t){return k(t)}}(t).catch(()=>i("Failed to delete preview session")),$n(),sn&&clearInterval(sn),sn=setInterval(async()=>{if(on-=1,on<=0)clearInterval(sn),sn=null,await kn();else{const t=document.querySelector(`#${Je} .gist-pb-ended-text`);t?t.innerHTML=En(on):$n()}},1e3)}async function Dn(t){if(!oi.isDocumentVisible)return i("Document hidden, not showing message now."),null;if(Xt(t.queueId))return i(`Message with queueId ${t.queueId} is already showing.`),null;const e=Ut(t);return!t.tooltipPosition&&e.hasTooltipPosition&&(t.tooltipPosition=e.tooltipPosition),t.tooltipPosition?function(t,e){const n=e.elementId||t.elementId;if(!n)return i(`No target selector specified for tooltip message ${t.messageId}`),oi.messageError(t),null;if(!R(n)){if(!oi.config.isPreviewSession||!t.properties?.gist?.livePreview)return i(`Tooltip target element "${n}" not found for message ${t.messageId}, skipping display`),oi.messageError(t),null;i(`Preview: tooltip target "${n}" not found, loading message for preview bar`)}const o=oi.currentMessages.find(t=>t.tooltipPosition&&t.elementId===n);o&&(i(`Tooltip already showing on target "${n}" (instance ${o.instanceId}), dismissing it first`),oi.messageDismissed(o),xe(o),o.instanceId&&Qt(o.instanceId)),t.instanceId=y(),t.overlay=!1,t.firstLoad=!0,t.shouldResizeHeight=!1,t.shouldScale=!1,t.renderStartTime=(new Date).getTime(),t.elementId=n,oi.currentMessages.push(t);return On(t,null,t.savedStepName||null)}(t,e):oi.overlayInstanceId?(i(`Message ${oi.overlayInstanceId} already showing.`),null):(t.instanceId=y(),t.overlay=!0,t.firstLoad=!0,t.shouldResizeHeight=!0,t.shouldScale=e.shouldScale,t.renderStartTime=(new Date).getTime(),oi.overlayInstanceId=t.instanceId,oi.currentMessages.push(t),On(t,null,t.savedStepName||null))}function Nn(t,e){return oi.isDocumentVisible?Xt(t.queueId)?(i(`Message with queueId ${t.queueId} is already showing.`),null):Jt(e)?(i(`Message with elementId ${e} already has a message.`),null):(t.instanceId=y(),t.overlay=!1,t.firstLoad=!0,t.shouldScale=!1,t.elementId=e,t.shouldResizeHeight=!me(e),t.renderStartTime=(new Date).getTime(),oi.currentMessages.push(t),On(t,e,t.savedStepName||null)):(i("Document hidden, not showing message now."),null)}async function Mn(t){t?(oi.messageDismissed(t),await An(t)):i("Message not found")}async function An(t){"tooltip"===ne(t)?zn(t):t.overlay?await Wn(!0,t):qn(t)}async function Rn(t){t?Ut(t).persistent&&(i("Persistent message dismissed, logging view"),await Xn(t),await Bn(t),await Be(t.queueId??"")):i("Message not found")}function qn(t){t.instanceId&&Qt(t.instanceId),t.elementId&&ge(t.elementId),oi.config.isPreviewSession&&(Pn(),_n())}function zn(t){xe(t),t.instanceId&&Qt(t.instanceId),0===oi.currentMessages.length&&(window.removeEventListener("message",Hn),window.removeEventListener("touchstart",Un)),oi.config.isPreviewSession&&(Pn(),_n())}async function Wn(t,e){t?await ye():ve(),0===oi.currentMessages.length&&(window.removeEventListener("message",Hn),window.removeEventListener("touchstart",Un)),e.instanceId&&Qt(e.instanceId),oi.overlayInstanceId=null,oi.config.isPreviewSession&&(Pn(),_n())}function _n(){const t=new URL(window.location.href);t.searchParams.delete(Fe),t.searchParams.delete(Ve),history.replaceState(null,"",t.toString())}function On(t,e=null,n=null){const o=oi.config.env,s={endpoint:C.ENGINE_API_ENDPOINT[o],siteId:oi.config.siteId,dataCenter:oi.config.dataCenter,messageId:t.messageId,instanceId:t.instanceId??"",livePreview:!1,properties:t.properties,customAttributes:Object.fromEntries(new Map($e))},a=`${C.GIST_VIEW_ENDPOINT[o]}/index.html`;return window.addEventListener("message",Hn),window.addEventListener("touchstart",Un),"tooltip"===ne(t)?function(t,e,n,i=null){const o=e.instanceId??"",s=Se(o),a=Ut(e),r=we.get(o);r&&(r.cleanup(),we.delete(o)),document.querySelectorAll(`#gist-tooltip-${o}`).forEach(t=>{t.parentNode?.removeChild(t)});const l=`gist-tooltip-${o}`,d=document.createElement("div");d.id=l,d.innerHTML=function(t,e,n,i=""){let o=600;e.messageWidth>o&&(o=e.messageWidth);const s=e.tooltipArrowColor,a=function(t){switch(t){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"}}(e.tooltipPosition),r=i?`#${i} `:"";return`\n <div class="gist-tooltip-outer">\n <style>\n ${r}.gist-tooltip-outer {\n position: absolute;\n }\n ${r}.gist-tooltip-container {\n position: relative;\n z-index: 9999999;\n opacity: 0;\n transition: opacity 0.3s ease-in-out;\n }\n ${r}.gist-tooltip-container.gist-visible {\n opacity: 1;\n }\n ${r}.gist-tooltip-frame-clip {\n overflow: hidden;\n }\n ${r}.gist-tooltip-frame {\n display: block;\n width: ${e.messageWidth}px;\n border: none;\n transition: height 0.1s ease-in-out;\n color-scheme: light only;\n }\n ${r}.gist-tooltip-arrow {\n width: 0;\n height: 0;\n position: absolute;\n z-index: 1;\n }\n ${r}.gist-tooltip-arrow.gist-arrow-bottom {\n bottom: 0;\n left: 50%;\n transform: translateX(-50%) translateY(100%);\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n border-top: 10px solid ${s};\n }\n ${r}.gist-tooltip-arrow.gist-arrow-top {\n top: 0;\n left: 50%;\n transform: translateX(-50%) translateY(-100%);\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n border-bottom: 10px solid ${s};\n }\n ${r}.gist-tooltip-arrow.gist-arrow-right {\n right: 0;\n top: 50%;\n transform: translateY(-50%) translateX(100%);\n border-top: 10px solid transparent;\n border-bottom: 10px solid transparent;\n border-left: 10px solid ${s};\n }\n ${r}.gist-tooltip-arrow.gist-arrow-left {\n left: 0;\n top: 50%;\n transform: translateY(-50%) translateX(-100%);\n border-top: 10px solid transparent;\n border-bottom: 10px solid transparent;\n border-right: 10px solid ${s};\n }\n @media (max-width: ${o}px) {\n ${r}.gist-tooltip-frame {\n max-width: 100%;\n }\n }\n </style>\n <div class="gist-tooltip-container">\n <div class="gist-tooltip-arrow ${a}"></div>\n <div class="gist-tooltip-frame-clip">\n <iframe id="${t}" class="gist-tooltip-frame" src="${n}"></iframe>\n </div>\n </div>\n </div>`}(s,a,t,l),document.body.appendChild(d),fe(s,n,i)}(a,t,s,n):e?(Ht.includes(e)&&Ft(e),function(t,e,n,o,s=null){const a=R(t);if(a){const i=Se(n.instanceId??"");a.classList.add(i);const r=Ut(n);let l=r.messageWidth+"px";Vt.includes(t)&&!r.hasCustomWidth&&(l="100%"),Ht.includes(t)&&(a.style.width=l),me(t)||(a.style.height="0px"),a.innerHTML=function(t,e,n){return function(t,e,n){let i=800;return e.messageWidth>i&&(i=e.messageWidth),`\n <div id="gist-embed">\n <style>\n #x-gist-floating-top, #x-gist-floating-top-left, #x-gist-floating-top-right {\n position: fixed;\n top: 0px;\n z-index: 1000000;\n }\n #x-gist-floating-bottom, #x-gist-floating-bottom-left, #x-gist-floating-bottom-right {\n position: fixed;\n bottom: 0px;\n z-index: 1000000;\n }\n #x-gist-bottom, #x-gist-top, #x-gist-floating-top, #x-gist-floating-bottom {\n left: 50%;\n transform: translate(-50%, 0%);\n }\n #x-gist-floating-top-right, #x-gist-floating-bottom-right {\n right: 0px;\n }\n #gist-embed {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container .gist-frame {\n height: 100%;\n width: 100%;\n border: none;\n color-scheme: light only;\n }\n #x-gist-top.${t},\n #x-gist-bottom.${t},\n #x-gist-floating-top.${t},\n #x-gist-floating-bottom.${t},\n #x-gist-floating-top-left.${t},\n #x-gist-floating-top-right.${t},\n #x-gist-floating-bottom-left.${t},\n #x-gist-floating-bottom-right.${t} {\n transition: height 0.1s ease-in-out;\n }\n @media (max-width: ${i}px) {\n #x-gist-top.${t},\n #x-gist-bottom.${t},\n #x-gist-floating-top.${t},\n #x-gist-floating-bottom.${t},\n #x-gist-floating-top-left.${t},\n #x-gist-floating-top-right.${t},\n #x-gist-floating-bottom-left.${t},\n #x-gist-floating-bottom-right.${t} {\n width: 100% !important;\n }\n }\n </style>\n <div id="gist-embed-container">\n <iframe id="${t}" class="gist-frame" src="${n}"></iframe>\n </div>\n </div>`}(Se(e.instanceId??""),n,t)}(e,n,r),fe(i,o,s)}else i(`Message could not be embedded, elementId ${t} not found.`)}(e,a,t,s,n)):function(t,e,n,i=null){document.querySelectorAll("#gist-embed-message").forEach(t=>{t.parentNode?.removeChild(t)}),document.body.insertAdjacentHTML("afterbegin",function(t,e){const n=Ut(e);return function(t,e,n){let i=600;return e.messageWidth>i&&(i=e.messageWidth),`\n <div id="gist-embed-message">\n <style>\n #gist-overlay.gist-background {\n position: fixed;\n z-index: 9999999998;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n background-color: ${e.overlayColor};\n visibility: hidden;\n }\n #gist-overlay.gist-background.gist-visible {\n visibility: visible;\n }\n .gist-message {\n width: ${e.messageWidth}px;\n position: absolute;\n border: none;\n opacity: 0;\n transition: opacity 0.3s ease-in-out, height 0.1s ease-in-out;\n z-index: 9999999999;\n left: 50%;\n transform: translateX(-50%);\n color-scheme: light only;\n }\n .gist-message.gist-visible {\n opacity: 1;\n pointer-events: auto;\n }\n .gist-message.gist-center {\n transform: translate(-50%, -50%);\n top: 50%;\n }\n .gist-message.gist-bottom {\n bottom: 0;\n }\n .gist-message.gist-top {\n top: 0;\n }\n @media (max-width: ${i}px) {\n .gist-message {\n width: 100%;\n }\n }\n </style>\n <div id="gist-overlay" class="gist-background">\n <iframe id="${t}" class="gist-message" src="${n}"></iframe>\n </div>\n </div>`}(Se(e.instanceId??""),n,t)}(t,e)),fe(Se(e.instanceId??""),n,i)}(a,t,s,n),t}async function Bn(t){let e;i(`Message shown, logging view for: ${t.messageId}`),null!=t.queueId?(await Xn(t),e=await _(t.queueId)):e=await async function(t){try{return await E().post(`/api/v1/logs/message/${t}`)}catch(t){return k(t)}}(t.messageId),i(200===e?.status?"Message view logged":`Problem logging message: ${e?.status}`)}function Un(){}async function Hn(t){const e=oi.config.env,n=t.data;if(n.gist&&t.origin===C.RENDERER_HOST[e]){const t=n.gist.instanceId,e=Gt(t);if(!e)return;const o=Ut(e);switch(n.gist.method){case"routeLoaded":{const s=.001*((new Date).getTime()-(e.renderStartTime??0));if(i(`Engine render for message: ${e.messageId} timer elapsed in ${s.toFixed(3)} seconds`),async function(t){const e=await _e(t);e&&r(e)}(e.queueId??""),e.currentRoute=n.gist.parameters.route,n.gist.parameters.fullDisplaySettings&&!e.displaySettings?e.displaySettings=n.gist.parameters.fullDisplaySettings:e.displaySettings&&(i("SDK already has display settings state, sending it to iframe"),be(e)),oi.config.isPreviewSession&&e.properties?.gist?.livePreview&&Tn(e),e.firstLoad||e.isDisplayChange){if("tooltip"===ne(e)){const t=e.properties?.gist?.elementId||e.elementId||void 0;if(!t||!R(t)){if(oi.config.isPreviewSession&&e.properties?.gist?.livePreview){i(`Preview: tooltip target "${t}" not found, preview bar will show element picker`),e.firstLoad=!1,e.isDisplayChange=!1;break}i(`Tooltip target not found for "${t}", emitting error and skipping display`),oi.messageError(e),e.firstLoad=!1,e.isDisplayChange=!1,zn(e);break}const n=await async function(t){const e=t.instanceId??"",n=Ut(t),o=`gist-tooltip-${e}`,s=R(o);if(!s)return i(`Tooltip wrapper not found for instance ${e}`),!1;const a=t.properties?.gist?.elementId||t.elementId||void 0;if(!a)return i(`No target selector for tooltip ${e}`),!1;const r=we.get(e);r&&(r.cleanup(),we.delete(e));const l=s.querySelector(".gist-tooltip-outer");if(!l)return i(`Tooltip inner element not found for instance ${e}`),!1;const d=n.tooltipPosition||"bottom";if(!await async function(t,e,n){const o=le(e);if(!o)return!1;let s=[];try{s=ue(o)}catch{}if(de(o.getBoundingClientRect(),s))return!0;if(!function(t,e,n){const i=le(e);if(!i)return!1;const o=i.getBoundingClientRect(),s=window.innerWidth,a=window.innerHeight,r=new DOMRect(Math.max(0,(s-o.width)/2),Math.max(0,(a-o.height)/2),o.width,o.height);return t.style.display="",null!==pe(t.getBoundingClientRect(),r,n)}(t,e,n))return i(`Preflight failed: tooltip would not fit after scrolling target "${e}" into view`),!1;o.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),await function(t){return new Promise(e=>{let n=t.getBoundingClientRect(),i=0;const o=Date.now();setTimeout(function s(){const a=t.getBoundingClientRect();Math.abs(a.top-n.top)<1&&Math.abs(a.left-n.left)<1?i++:i=0,n=a,i>=2||Date.now()-o>1e3?e():setTimeout(s,50)},50)})}(o);const a=o.getBoundingClientRect();let r=[];try{r=ue(o)}catch{}return de(a,r)}(l,a,d))return i(`Tooltip for instance ${e} skipped: target "${a}" is off-screen and cannot be scrolled into a valid position`),!1;const c=function(t,e,n,o){const s=le(e);if(!s)return null;let a=null,r=null,l=!1,d=[],c=null;try{d=ue(s)}catch{}function p(){if(l)return;if(!s||!document.contains(s)||!document.contains(t))return i("Tooltip or target element removed from DOM, cleaning up listeners"),g(),void o?.onDetach?.();const e=s.getBoundingClientRect();if(!de(e,d))return void(t.style.display="none");t.style.display="";const a=pe(t.getBoundingClientRect(),e,n);a?(function(t,e){t.style.position="absolute",t.style.top=`${e.top+window.scrollY}px`,t.style.left=`${e.left+window.scrollX}px`}(t,a),function(t,e){const n=t.querySelector(".gist-tooltip-arrow");n&&(n.classList.remove("gist-arrow-top","gist-arrow-bottom","gist-arrow-left","gist-arrow-right"),n.classList.add(re[e.position]),null!==e.arrowOffset?"top"===e.position||"bottom"===e.position?(n.style.left=`calc(50% + ${e.arrowOffset}px)`,n.style.removeProperty("top")):(n.style.top=`calc(50% + ${e.arrowOffset}px)`,n.style.removeProperty("left")):"top"===e.position||"bottom"===e.position?(n.style.left="50%",n.style.removeProperty("top")):(n.style.top="50%",n.style.removeProperty("left")))}(t,a)):t.style.display="none"}function u(){null===a&&(a=requestAnimationFrame(()=>{a=null,p()}))}function g(){if(!l){l=!0,c&&(c.disconnect(),c=null),window.removeEventListener("scroll",u),window.removeEventListener("resize",u);for(const t of d)t.removeEventListener("scroll",u);null!==a&&(cancelAnimationFrame(a),a=null),null!==r&&(cancelAnimationFrame(r),r=null)}}if(p(),l)return null;window.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",u,{passive:!0});for(const t of d)t.addEventListener("scroll",u,{passive:!0});try{c=new MutationObserver(()=>{null===r&&(r=requestAnimationFrame(()=>{r=null,document.contains(s)||p()}))}),c.observe(document.body,{childList:!0,subtree:!0})}catch{}return{cleanup:g,reposition:p}}(l,a,d,{onDetach:()=>{we.delete(e);const t=R(o);t&&t.parentNode?.removeChild(t)}});if(c){if("none"!==l.style.display){const t=s.querySelector(".gist-tooltip-container");return t?(we.set(e,c),t.classList.add("gist-visible"),!0):(c.cleanup(),i(`Tooltip container not found for instance ${e}`),!1)}return c.cleanup(),i(`Tooltip for instance ${e} could not be positioned within the viewport, target "${a}" may be off-screen`),!1}return i(`Failed to position tooltip for instance ${e}, target "${a}" may not exist or no position fits the viewport`),!1}(e);if(!n){if(oi.config.isPreviewSession&&e.properties?.gist?.livePreview){i(`Preview: tooltip positioning failed for "${t}", preview bar will remain active`),e.firstLoad=!1,e.isDisplayChange=!1;break}i(`Tooltip positioning failed for "${t}", emitting error and cleaning up`),oi.messageError(e),e.firstLoad=!1,e.isDisplayChange=!1,zn(e);break}}else e.overlay?function(t){const e=Ut(t),n=document.querySelector("#gist-overlay");if(n){n.classList.add("gist-visible");const i=document.querySelector(".gist-message");i&&(t.position?i.classList.add("gist-"+t.position):i.classList.add("gist-center")),setTimeout(Ie,100),e.exitClick&&setTimeout(()=>function(t){const e=document.querySelector("#gist-overlay");e&&e.addEventListener("click",()=>{oi.dismissMessage(t)})}(t.instanceId??""),1e3)}else ve()}(e):function(t){const e=R(t);e&&e.classList.add("gist-visible")}(e.elementId);e.firstLoad&&!e.isDisplayChange&&(oi.messageShown(e),o.persistent?i("Persistent message shown, skipping logging view"):await Bn(e)),e.firstLoad=!1,e.isDisplayChange=!1}Yt(t,e);break}case"tap":{const t=n.gist.parameters.action,i=n.gist.parameters.name;if(oi.messageAction(e,t,i),n.gist.parameters.system&&!o.persistent){await Mn(e);break}try{const n=new URL(t);if(n&&"gist:"===n.protocol)switch(n.href.replace("gist://","").split("?")[0]){case"close":await Rn(e),await Jn(e),await Mn(e),await ti();break;case"showMessage":{const t=n.searchParams.get("messageId"),e=n.searchParams.get("properties");if(t){const n=e?JSON.parse(atob(e)):void 0;await oi.showMessage({messageId:t,properties:n})}break}case"loadPage":{const t=n.href.substring(n.href.indexOf("?url=")+5);t&&(t.startsWith("mailto:")||t.startsWith("https://")||t.startsWith("http://")||t.startsWith("/")?window.location.href=t:window.location.href=window.location+t);break}}}catch{}break}case"changeMessageStep":{const t=n.gist.parameters.displaySettings,r=n.gist.parameters.messageStepName;oi.config.isPreviewSession&&r&&e.properties?.gist?.livePreview&&function(t,e){if(nn)return;tn=t;const n=Ke.find(e=>e.stepName===t);n?Ze={...n.displaySettings}:e&&(Ze={...e}),$n()}(r,t),(o.persistent||Pe(e))&&await async function(t,e,n){const o=await Oe(t);if(!o)return;const r=a(o)||{},l={stepName:void 0!==e?e:r.stepName,displaySettings:void 0!==n?n:r.displaySettings},d=new Date;d.setDate(d.getDate()+30),s(o,l,d),i(`Saved message state for queueId: ${t}`)}(e.queueId??"",r,t),t&&ie(e,t)&&(i("Display settings changed, reloading message"),await Vn(e),oe(e,t),await Fn(e,r??null));break}case"routeChanged":e.currentRoute=n.gist.parameters.route,e.renderStartTime=(new Date).getTime(),Yt(t,e),i(`Route changed to: ${e.currentRoute}`);break;case"sizeChanged":i(`Size Changed Width: ${n.gist.parameters.width} - Height: ${n.gist.parameters.height}`),"tooltip"===ne(e)?function(t,e){const n=t.instanceId??"",i=Se(n),o=document.getElementById(i);if(o&&e.height>0){o.style.height=`${e.height}px`;const t=we.get(n);t&&t.reposition()}}(e,n.gist.parameters):e.elementId&&!e.shouldResizeHeight||function(t,e){const n=R(t.elementId?t.elementId:Se(t.instanceId??""));if(n){const i=n.style;if(e.height>0)if(e.height>window.innerHeight){const n=1-(e.height/window.innerHeight-1);t.shouldScale&&n>=.4?(i.height=`${e.height}px`,i.transform=`translateX(-50%) translateY(-50%) scale(${n})`):i.height=`${window.innerHeight}px`}else i.height=`${e.height}px`}}(e,n.gist.parameters);break;case"titleChanged":i(`Overlay title changed to: ${n.gist.parameters.title}`),function(t,e){const n=R(Se(t));n&&(n.title=e)}(t,n.gist.parameters.title);break;case"eventDispatched":oi.events.dispatch("eventDispatched",{name:n.gist.parameters.name,payload:n.gist.parameters.payload});break;case"error":case"routeError":oi.messageError(e),"tooltip"===ne(e)?zn(e):oi.overlayInstanceId?await Wn(!1,e):qn(e)}}}async function Fn(t,e){t.isDisplayChange=!0,t.renderStartTime=(new Date).getTime();const n=ne(t),o=t.elementId||null;if("tooltip"===n)return oi.overlayInstanceId===t.instanceId&&(oi.overlayInstanceId=null),t.shouldScale=!1,t.shouldResizeHeight=!1,void On(t,null,e);if(o){const e=Jt(o);e&&e.instanceId!==t.instanceId&&(i(`Dismissing existing message at ${o} to make room for multi-step message`),await Mn(e))}if(t.overlay){oi.overlayInstanceId=t.instanceId??null;const e=Ut(t);t.shouldScale=e.shouldScale,t.shouldResizeHeight=!0}else oi.overlayInstanceId=null,t.shouldScale=!1,t.shouldResizeHeight=!me(o??"");o&&Ht.includes(o)&&Ft(o),On(t,o,e)}async function Vn(t){"tooltip"===ne(t)?xe(t):t.overlay?await ye():t.elementId&&ge(t.elementId)}async function Gn(t,e,n){n&&ie(t,n)&&(await Vn(t),oe(t,n)),await Fn(t,e??null)}async function Xn(t){i(`Logging user message view locally for: ${t.queueId}`),Te(t)?await async function(t){i(`Marking broadcast ${t} as seen.`);const e=await De();if(!e)return;const n=await Le(e,t);if(!n)return;const o=n.properties.gist.broadcast,{frequency:r}=o,l=Ne(e,t),d=Me(e,t),c=a(l)||0;if(s(l,c+1),1===r.count)s(d,!1),i(`Marked broadcast ${t} as seen.`);else{const e=new Date;e.setSeconds(e.getSeconds()+r.delay),s(d,!1,e),i(`Marked broadcast ${t} as seen, broadcast was seen ${c+1} times, next show date is ${e}.`)}}(t.queueId??""):await async function(t){const e=await We();if(!e)return;const n=a(e)??[];n.push(t),s(e,n)}(t.queueId??"")}async function Jn(t){Te(t)&&(i(`Logging broadcast dismissed locally for: ${t.queueId}`),await async function(t){i(`Marking broadcast ${t} as dismissed.`);const e=await De();if(!e)return;const n=await Le(e,t);n&&(!0!==n.properties.gist.broadcast.frequency.ignoreDismiss?(s(Me(e,t),!1),i(`Marked broadcast ${t} as dismissed and will not show again.`)):i(`Broadcast ${t} is set to ignore dismiss.`))}(t.queueId??""),await Be(t.queueId??""))}const Qn=(t,e)=>t().then((t=>new Promise(e=>setTimeout(e,t)))(e).then(()=>Qn(t,e)));let Yn=!1,Kn=null;async function Zn(){Yn?await ti():Rt()?(i("Queue watcher started"),Yn=!0,Qn(()=>new Promise(()=>{!async function(){if(C.hasActiveSSEConnection())return!C.isSSEConnectionManagedBySDK()&&Kn&&(i("Not the main instance, closing our SSE connection."),ii()),void await ti();Kn&&(i("SSE connection not active, closing it."),ii()),!C.useSSE()||At()?await ni():await async function(){ii();const t=function(){const t=Wt();return null===t?(i("No user token available for SSE endpoint."),null):C.GIST_QUEUE_REALTIME_API_ENDPOINT[oi.config.env??"prod"]+`/api/v3/sse?userToken=${t}&siteId=${oi.config.siteId}&sessionId=${Pt()}`}();if(null===t)return i("SSE endpoint not available, falling back to polling."),void await ni();i(`Starting SSE queue listener on ${t}`),Kn=new EventSource(t),C.setActiveSSEConnection(),Kn.addEventListener("connected",async t=>{try{i("SSE connection received"),C.setUseSSEFlag(!0);const e=JSON.parse(t.data);e.heartbeat&&(C.setSSEHeartbeat(e.heartbeat),i(`SSE heartbeat set to ${e.heartbeat} seconds`)),C.setActiveSSEConnection()}catch(t){i(`Failed to parse SSE settings: ${t}`)}r(Lt),await ni()}),Kn.addEventListener("messages",async t=>{try{const e=JSON.parse(t.data);i("SSE message received"),await Re(e),await Ee(e),await ti()}catch(t){i(`Failed to parse SSE message: ${t}`),ii()}}),Kn.addEventListener("inbox_messages",async t=>{try{const e=JSON.parse(t.data);i("SSE inbox messages received"),await U(e)}catch(t){i(`Failed to parse SSE inbox messages: ${t}`)}}),Kn.addEventListener("error",async()=>{i("SSE error received"),ii()}),Kn.addEventListener("heartbeat",async()=>{i("SSE heartbeat received"),C.setActiveSSEConnection(),C.setUseSSEFlag(!0)})}()}()}),1e3)):i("User token not setup, queue not started.")}async function ti(){const t=await je(),e=await qe(),n=t.concat(e);i(`Messages in local queue: ${n.length}`);const o=n.sort((t,e)=>t.priority-e.priority);for(const t of o)await ei(t)}async function ei(t){let e=Ut(t);if(e.hasRouteRule){if(null==oi.currentRoute&&"loading"===document.readyState)return i(`Deferring message ${t.queueId}, page not fully loaded`),!1;if(!ee(e.routeRule))return i(`Route ${new URL(window.location.href).pathname} (currentRoute: ${oi.currentRoute}) does not match rule: ${e.routeRule}`),!1}if(e.hasPosition&&(t.position=e.position),e.hasTooltipPosition&&(t.tooltipPosition=e.tooltipPosition),e.persistent||Pe(t)){const n=await async function(t){const e=await Oe(t);return e?a(e):null}(t.queueId??"");n&&(i(`Restoring saved state for queueId ${t.queueId}`),n.displaySettings&&(oe(t,n.displaySettings),e=Ut(t)),t.savedStepName=n.stepName??null)}if(e.persistent||Pe(t)||!await async function(t){const e=await _e(t);return!!e&&null!==a(e)}(t.queueId??"")){let n=null;return e.isEmbedded?!oi.config.isPreviewSession||!t.properties?.gist?.livePreview||R(e.elementId)||Ht.includes(e.elementId)?n=Nn(t,e.elementId):(i(`Preview: element "${e.elementId}" not found, showing as overlay so placement can be changed`),n=await Dn(t)):n=await Dn(t),n&&async function(t){const e=await _e(t);e&&s(e,!0,new Date(Date.now()+5e3))}(t.queueId??""),null!==n}return i(`Not showing message with queueId ${t.queueId} because its already loading.`),!1}async function ni(){if(Rt())if(oi.isDocumentVisible)if(null===a(Lt)){const t=await async function(){if(jt)return;jt=!0;const t=Rt();let e;try{const t={"X-Gist-User-Anonymous":String(At()),"Content-Language":String(L())};e=await E().post(`/api/v4/users?sessionId=${Pt()}`,{},{headers:t})}catch(t){const n=k(t);n?e=n:i(`Error getting user queue: ${t}`)}finally{jt=!1}return t!==Rt()?(i("User token changed, clearing queue next pull check."),void r(Lt)):(function(t){const e=t?.headers?.["x-gist-queue-polling-interval"];Et=e&&Number(e)>0?Number(e):Math.min(2*Et,600);const n=new Date((new Date).getTime()+1e3*Et);s(Lt,Et,n)}(e),function(t){const e="true"===t?.headers?.["x-cio-use-sse"]?.toLowerCase();C.setUseSSEFlag(e)}(e),await async function(t){const e=t?.headers?.["x-cio-inbox-enabled"]?.toLowerCase();if(void 0===e)return;const n="true"===e;C.setInboxEnabledFlag(n),n&&(i("Inbox enabled, ensuring branding and templates are cached."),await kt(),yt())}(e),e)}();if(t){if(200===t.status||204===t.status){i("200 response, updating local store.");const e=t.data,n=e?.inAppMessages??[],o=e?.inboxMessages??[];Re(n),Ee(n),U(o)}else 304===t.status&&i("304 response, using local store.");await ti()}else i("No response object returned while checking message queue.")}else i("Next queue pull scheduled for later.");else i("Document not visible, skipping queue check.");else i("User token reset, skipping queue check.")}function ii(t=!1){t&&C.removeActiveSSEConnection(),(t||C.isSSEConnectionManagedBySDK())&&C.setUseSSEFlag(!1),Kn&&(i("Stopping SSE queue listener..."),Kn.close(),Kn=null)}class oi{static async setup(t){this.initialized?i("Gist SDK already initialized, skipping setup."):(this.initialized=!0,this.events=new n,this.config={useAnonymousSession:t.useAnonymousSession??!1,siteId:t.siteId,dataCenter:t.dataCenter,env:t.env??"prod",logging:t.logging??!1,experiments:t.experiments??!1},this.currentMessages=[],we.forEach(t=>t.cleanup()),we.clear(),document.querySelectorAll('[id^="gist-tooltip-"]').forEach(t=>{t.parentNode?.removeChild(t)}),this.overlayInstanceId=null,this.currentRoute=null,this.isDocumentVisible=!0,this.config.isPreviewSession=function(){const t=new URLSearchParams(window.location.search),e=t.get(Fe);if(e){sessionStorage.setItem(o,String(!1)),oi.setUserToken(e),i(`Preview mode enabled with user token: ${e}`),function(){if(document.getElementById(Je))return;z(Xe,He);try{en="true"===sessionStorage.getItem(Ge)}catch{en=!1}const t=q("div",{id:Je});document.body.appendChild(t),$n()}();const n=t.get(Ve);if(n)try{const t=JSON.parse(atob(n)),e=t.stepName||null,i=t.displayType||null;(e||i)&&function(t,e){cn=t,pn=e}(e,i)}catch{i("Preview bar: failed to parse cioPreviewSettings")}}return!l()}(),ki(),function(){const t=d();for(let e=t.length-1;e>=0;e--){const n=t.key(e);n?.startsWith("gist.")&&c(n)}}(),async function(){C.inboxEnabled()&&(D()&&A()||(i("Inbox enabled but missing cached branding/templates, fetching."),await kt()),yt())}(),i(`Setup complete on ${this.config.env} environment.`),this.config.isPreviewSession||!this.config.useAnonymousSession||new URLSearchParams(location.search).has("ajs_uid")||qt(),await Zn(),"loading"===document.readyState&&document.addEventListener("DOMContentLoaded",()=>{ti()},{once:!0}),document.addEventListener("visibilitychange",async()=>{"hidden"===document.visibilityState?this.isDocumentVisible=!1:(this.isDocumentVisible=!0,await ti())},!1))}static setupDebugOverlay(){ki()}static async setCurrentRoute(t){this.currentRoute=t,i(`Current route set to: ${t}`),await async function(){if(0!==oi.currentMessages.length)for(const t of[...oi.currentMessages])null==document.querySelector(`#gist-${t.instanceId}`)&&(i(`Removing active message ${t.instanceId} that no longer exists after route change`),await An(t))}(),await ti(),this.events?.dispatch("routeChanged",t)}static async setUserToken(t,e){this.config.isPreviewSession||(function(t,e){void 0===e&&(e=new Date).setDate(e.getDate()+30),s(Dt,t,e),At()&&(r(Lt),r(Nt)),i(`Set user token "${t}" with expiry date set to ${e}`)}(t,e),ii(!0),await Zn())}static setUserLocale(t){var e;s(j,e=t),i(`Set user locate to "${e}"`)}static setCustomAttribute(t,e){return function(t,e){return t&&"string"==typeof t?($e.set(t,e),ke(),i(`Set custom attribute "${t}" to "${e}"`),!0):(i(`Invalid key for custom attribute: ${t}`),!1)}(t,e)}static clearCustomAttributes(){$e.clear(),r(Ce),i("Cleared all custom attributes")}static removeCustomAttribute(t){return function(t){if(!t||"string"!=typeof t)return i(`Invalid key for custom attribute: ${t}`),!1;const e=$e.has(t);return $e.delete(t),$e.size>0?ke():r(Ce),i(`Removed custom attribute "${t}"`),e}(t)}static async clearUserToken(){this.config.isPreviewSession||(_t(),this.config.useAnonymousSession&&qt(),ii(!0),await Zn())}static async dismissMessage(t){const e=Gt(t);e&&(await Rn(e),await Jn(e),await Mn(e),await ti())}static async embedMessage(t,e){const n=Nn(t,e);return n?.instanceId??null}static async showMessage(t){const e=await Dn(t);return e?.instanceId??null}static updateMessageDisplaySettings(t,e){const n=Gt(t);return!!n&&(n.displaySettings=e,be(n),!0)}static messageShown(t){i(`Message shown: ${t.messageId}`),this.events.dispatch("messageShown",t)}static messageDismissed(t){null!==t&&(i(`Message dismissed: ${t.messageId}`),this.events.dispatch("messageDismissed",t))}static messageError(t){i(`Message error: ${t.messageId}`),this.events.dispatch("messageError",t)}static messageAction(t,e,n){i(`Message action: ${t.currentRoute}, ${e} with name ${n} on ${t.instanceId}`),this.events.dispatch("messageAction",{message:t,action:e,name:n})}static async getInboxUnopenedCount(){return(await H()).filter(t=>!t.opened).length}static async getInboxMessages(){return await H()}static async updateInboxMessageOpenState(t,e){return await F(t,e)}static async removeInboxMessage(t){return await V(t)}static isInboxEnabled(){return C.inboxEnabled()}}const si="\n #gist-debug-overlay {\n position: fixed; bottom: 16px; right: 16px;\n z-index: 99999999999;\n background: #08272B; color: white;\n font-family: system-ui, -apple-system, sans-serif;\n font-size: 11px;\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0,0,0,0.3);\n width: 300px;\n max-height: min(700px, calc(100vh - 32px));\n display: flex;\n flex-direction: column;\n pointer-events: auto;\n overflow: hidden;\n }\n .gist-debug-header {\n display: flex; align-items: center;\n padding: 8px 12px;\n border-bottom: 1px solid rgba(255,255,255,0.1);\n flex-shrink: 0;\n }\n .gist-debug-title {\n flex: 1;\n font-weight: 700;\n font-size: 12px;\n letter-spacing: 0.02em;\n }\n #gist-debug-overlay-close {\n background: none; border: none;\n color: white; cursor: pointer;\n padding: 0; font-size: 18px; line-height: 1;\n opacity: 0.6; flex-shrink: 0;\n font-family: system-ui, -apple-system, sans-serif;\n -webkit-appearance: none; appearance: none;\n }\n #gist-debug-overlay-close:hover { opacity: 1; }\n .gist-debug-section {\n padding: 0 12px 8px;\n border-bottom: 1px solid rgba(255,255,255,0.07);\n overflow-y: auto;\n max-height: 180px;\n }\n .gist-debug-section:last-child { border-bottom: none; }\n .gist-debug-label {\n position: sticky;\n top: 0;\n z-index: 1;\n background: #08272B;\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.08em;\n color: rgba(255,255,255,0.45);\n padding: 8px 0 5px;\n font-weight: 600;\n }\n .gist-debug-value {\n font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;\n font-size: 11px;\n color: rgba(255,255,255,0.9);\n overflow-wrap: break-word;\n }\n .gist-debug-msg {\n background: rgba(255,255,255,0.06);\n border-radius: 4px;\n padding: 5px 7px;\n margin-bottom: 8px;\n }\n .gist-debug-msg:last-child { margin-bottom: 0; }\n .gist-debug-msg-row {\n display: flex;\n align-items: center;\n gap: 6px;\n margin-bottom: 2px;\n }\n .gist-debug-msg-row:last-child { margin-bottom: 0; }\n .gist-debug-msg-meta {\n display: flex;\n align-items: center;\n gap: 5px;\n margin-bottom: 4px;\n }\n .gist-debug-msg-state {\n font-size: 9px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n border-radius: 3px;\n padding: 1px 4px;\n flex-shrink: 0;\n }\n .gist-debug-msg-state--active {\n color: #4caf82;\n background: rgba(76,175,130,0.12);\n }\n .gist-debug-msg-state--queued {\n color: rgba(255,200,100,0.9);\n background: rgba(255,200,100,0.1);\n }\n .gist-debug-msg-dismiss {\n margin-left: auto;\n background: none;\n border: none;\n color: rgba(255,255,255,0.3);\n cursor: pointer;\n padding: 0;\n font-size: 13px;\n line-height: 1;\n font-family: system-ui, -apple-system, sans-serif;\n -webkit-appearance: none;\n appearance: none;\n }\n .gist-debug-msg-dismiss:hover { color: rgba(255,255,255,0.7); }\n .gist-debug-element-found {\n color: #4caf82;\n font-size: 9px;\n font-weight: 700;\n flex-shrink: 0;\n }\n .gist-debug-route-mismatch {\n color: #ff6b6b;\n font-size: 9px;\n font-weight: 700;\n flex-shrink: 0;\n }\n .gist-debug-msg-type {\n font-size: 9px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n color: rgba(255,255,255,0.45);\n background: rgba(255,255,255,0.08);\n border-radius: 3px;\n padding: 1px 4px;\n flex-shrink: 0;\n }\n .gist-debug-msg-key {\n color: rgba(255,255,255,0.45);\n font-size: 10px;\n line-height: 1.4;\n min-width: 64px;\n flex-shrink: 0;\n }\n .gist-debug-msg-val {\n font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;\n font-size: 10px;\n line-height: 1.4;\n color: rgba(255,255,255,0.9);\n overflow-wrap: break-word;\n }\n .gist-debug-val-error {\n color: #ff6b6b;\n font-weight: 600;\n }\n .gist-debug-expand-detail {\n background: rgba(255,107,107,0.08);\n border-left: 2px solid rgba(255,107,107,0.4);\n color: rgba(255,255,255,0.75);\n font-family: system-ui, -apple-system, sans-serif;\n font-size: 10px;\n padding: 4px 6px;\n margin-top: 4px;\n margin-bottom: 6px;\n border-radius: 0 3px 3px 0;\n }\n .gist-debug-expand-list {\n margin: 0;\n padding: 0 0 0 14px;\n list-style: disc;\n }\n .gist-debug-expand-list li {\n margin-bottom: 3px;\n line-height: 1.4;\n }\n .gist-debug-expand-list li:last-child { margin-bottom: 0; }\n .gist-debug-msg-details {\n margin: 5px 0 0;\n padding: 0 0 0 14px;\n list-style: disc;\n color: rgba(255,255,255,0.5);\n font-size: 10px;\n line-height: 1.4;\n font-family: system-ui, -apple-system, sans-serif;\n }\n .gist-debug-msg-details li { margin-bottom: 2px; }\n .gist-debug-msg-details li:last-child { margin-bottom: 0; }\n",ai="gist-debug-overlay-styles",ri=2e3,li=5e3;let di=null,ci=!1,pi=!1,ui=null;function gi(t){const e=t.properties?.gist;return ne(e?{...t,tooltipPosition:e.tooltipPosition??t.tooltipPosition,elementId:null!=e.elementId?String(e.elementId):t.elementId}:t)}function mi(t,e,n=!1){const i=q("div",{className:"gist-debug-msg-row"});return i.appendChild(q("span",{className:"gist-debug-msg-key",textContent:t})),i.appendChild(q("span",{className:n?"gist-debug-msg-val gist-debug-val-error":"gist-debug-msg-val",textContent:e})),i}function fi(t,e,n=!1){t.replaceChildren(...e.map(([t,e])=>mi(t,e,n)))}function hi(t,e){const n=q("div",{className:"gist-debug-msg"}),i=q("div",{className:"gist-debug-msg-meta"});if(i.appendChild(q("span",{className:"gist-debug-msg-type",textContent:gi(t)})),i.appendChild(q("span",{className:`gist-debug-msg-state gist-debug-msg-state--${e}`,textContent:e})),t.instanceId){const e=q("button",{className:"gist-debug-msg-dismiss",textContent:"×"});e.addEventListener("click",()=>{vi(),oi.dismissMessage(t.instanceId).then(()=>{vi(),wi()})}),i.appendChild(e)}n.appendChild(i);const o=[];for(const[e,i]of function(t){const e=t.properties?.gist,n=[];e?.routeRuleWeb&&n.push(["Route Rule",String(e.routeRuleWeb)]);const i=e?.elementId??t.elementId,o=gi(t);if(i&&"overlay"===o){const t=function(t){if(t)return Zt[t]}(String(i));t&&n.push(["Position",t.replace(/([A-Z])/g," $1").toLowerCase()])}else i&&"modal"!==o&&n.push(["Target",String(i)]);const s=e?.position??t.position;s&&"overlay"!==o&&n.push(["Position",String(s)]);const a=e?.tooltipPosition??t.tooltipPosition;return a&&n.push(["Tooltip",String(a)]),n}(t)){let t=null,s=null;if("Route Rule"===e){const e=!ee(i);t=e?"gist-debug-route-mismatch":"gist-debug-element-found",s=e?"✕":"✓",e&&o.push("Route rule does not match current route. If it should, verify the route is set correctly and that analytics.page() is called on route changes.")}else if("Target"===e){const e=!!R(i);t=e?"gist-debug-element-found":"gist-debug-route-mismatch",s=e?"✓":"✕",e||o.push("Target element not found on the page. If it should, verify the selector is correct.")}const a=mi(e,i);t&&s&&a.appendChild(q("span",{className:t,textContent:s})),n.appendChild(a)}if(o.length>0){const t=q("ul",{className:"gist-debug-msg-details"});for(const e of o)t.appendChild(q("li",{textContent:e}));n.appendChild(t)}return n}function bi(t){const e=q("div",{className:"gist-debug-expand-detail"}),n=q("ul",{className:"gist-debug-expand-list"});return n.appendChild(q("li",{textContent:t})),e.appendChild(n),e}function yi(){di&&(di.root.remove(),document.getElementById(ai)?.remove(),null!==ui&&(clearInterval(ui),ui=null),ci&&(oi.events&&(oi.events.off("messageShown",xi),oi.events.off("messageDismissed",xi),oi.events.off("messageInboxUpdated",Si),oi.events.off("routeChanged",xi)),ci=!1),di=null)}function vi(){if(!di)return;oi.config?fi(di.configRows,[["Site ID",oi.config.siteId],["Connection",C.useSSE()?"SSE":`Polling ${Et}s`]]):fi(di.configRows,[["Status","NOT INITIALIZED"]],!0),di.configDetail.style.display=oi.config?"none":"";const t=Rt();t?At()?di.userValue.textContent="(anonymous)":di.userValue.textContent=t.length>32?`${t.slice(0,32)}…`:t:di.userValue.textContent="(none)";const e=oi.currentRoute;di.routeValue.replaceChildren(q("span",{className:e?"gist-debug-msg-val":"gist-debug-msg-val gist-debug-val-error",textContent:e??"NONE"})),di.routeDetail.style.display=e?"none":""}async function wi(){if(!pi&&di){pi=!0;try{const t=oi.currentMessages??[],[e,n]=oi.config?await Promise.all([qe(),je()]):[[],[]],i=new Set(t.map(t=>t.queueId??t.messageId)),o=new Set,s=[...n,...e].filter(t=>{const e=t.queueId??t.messageId;return!i.has(e)&&!o.has(e)&&(o.add(e),!0)});if(!di)return;const a=t.length+s.length;di.messagesLabel.textContent=`Messages (${a})`,di.messagesList.replaceChildren(...t.map(t=>hi(t,"active")),...s.map(t=>hi(t,"queued")))}finally{pi=!1}}}function xi(){vi(),wi()}function Si(){wi()}async function Ii(){ci||(!ci&&oi.events&&(oi.events.on("messageShown",xi),oi.events.on("messageDismissed",xi),oi.events.on("messageInboxUpdated",Si),oi.events.on("routeChanged",xi),ci=!0),ci&&Ci(li)),vi(),await wi()}function Ci(t){null!==ui&&clearInterval(ui),ui=setInterval(()=>{Ii()},t)}const $i="cio_debug_session";function ki(){if("undefined"!=typeof window&&"true"===new URLSearchParams(window.location.search).get($i))try{di||null!==ui||(z(ai,si),di=function(){const t=q("div",{id:"gist-debug-overlay"}),e=q("div",{className:"gist-debug-header"});e.appendChild(q("span",{className:"gist-debug-title",textContent:"Customer.io In-App SDK Debugger"}));const n=q("button",{id:"gist-debug-overlay-close",ariaLabel:"Dismiss debug overlay",textContent:"×"});n.addEventListener("click",yi),e.appendChild(n),t.appendChild(e);const i=q("div",{className:"gist-debug-section"}),o=q("div",{className:"gist-debug-label"});o.appendChild(q("span",{textContent:"Config"})),i.appendChild(o);const s=q("div",{});i.appendChild(s);const a=bi("Verify your site ID and credentials are correct.");i.appendChild(a),t.appendChild(i);const r=q("div",{className:"gist-debug-section"}),l=q("div",{className:"gist-debug-label",textContent:"User"});r.appendChild(l);const d=q("div",{className:"gist-debug-value"});r.appendChild(d),t.appendChild(r);const c=q("div",{className:"gist-debug-section"}),p=q("div",{className:"gist-debug-label"});p.appendChild(q("span",{textContent:"Route"})),c.appendChild(p);const u=q("div",{className:"gist-debug-value"});c.appendChild(u);const g=bi("The current route is used to match against potential message page rules.");c.appendChild(g),t.appendChild(c);const m=q("div",{className:"gist-debug-section"}),f=q("div",{className:"gist-debug-label"});m.appendChild(f);const h=q("div",{});return m.appendChild(h),t.appendChild(m),{root:t,configRows:s,configDetail:a,userValue:d,routeValue:u,routeDetail:g,messagesLabel:f,messagesList:h}}(),W(di.root),Ci(ri),Ii())}catch(t){i(`Failed to initialize debug overlay: ${t}`)}}return"undefined"!=typeof window&&ki(),e.default})());
|