customerio-gist-web 3.28.0 → 3.29.0
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/dist/types/gist.d.ts +16 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/managers/message-component-manager.d.ts +9 -1
- package/dist/types/managers/user-jwt-manager.d.ts +44 -0
- package/dist/types/managers/user-manager.d.ts +25 -1
- package/dist/types/types.d.ts +3 -0
- package/dist/types/version.d.ts +1 -0
- 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:()=>mo});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){po.config&&po.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")&&!t.endsWith("snoozed"),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}const u=new Uint8Array(16),p=[];for(let t=0;t<256;++t)p.push((t+256).toString(16).slice(1));const g=function(t,e,n){return e||t||!crypto.randomUUID?function(t,e,n){const i=(t=t||{}).random??t.rng?.()??crypto.getRandomValues(u);if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,e){if((n=n||0)<0||n+16>e.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let t=0;t<16;++t)e[n+t]=i[t];return e}return function(t,e=0){return(p[t[e+0]]+p[t[e+1]]+p[t[e+2]]+p[t[e+3]]+"-"+p[t[e+4]]+p[t[e+5]]+"-"+p[t[e+6]]+p[t[e+7]]+"-"+p[t[e+8]]+p[t[e+9]]+"-"+p[t[e+10]]+p[t[e+11]]+p[t[e+12]]+p[t[e+13]]+p[t[e+14]]+p[t[e+15]]).toLowerCase()}(i)}(t,e,n):crypto.randomUUID()},m="gist.web.inbox.enabled",f="gist.web.userQueueUseSSE",h="gist.web.activeSSEConnection";let b,y=30;const w={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:()=>(b||(b=g()),b),useSSE:()=>a(f)??!1,setUseSSEFlag(t){s(f,t,new Date((new Date).getTime()+6e4)),i(`Set user uses SSE to "${t}"`)},removeActiveSSEConnection(){r(h)},setActiveSSEConnection(){s(h,w.getSdkId(),new Date((new Date).getTime()+w.getSSEHeartbeat()))},hasActiveSSEConnection:()=>a(h)??!1,isSSEConnectionManagedBySDK:()=>a(h)===w.getSdkId(),getSSEHeartbeat:()=>1e3*(y+5),setSSEHeartbeat(t){t&&t>0&&(y=t)},inboxEnabled:()=>a(m)??!1,setInboxEnabledFlag(t){s(m,t,new Date((new Date).getTime()+36e5)),i(`Set inbox enabled to "${t}"`)}};function v(t){return null!==t&&"object"==typeof t&&"response"in t}function x(t){return v(t)?t.response:void 0}function S(){const t=w.GIST_QUEUE_API_ENDPOINT[po.config.env??"prod"],e={"X-CIO-Site-Id":po.config.siteId,"X-CIO-Client-Platform":"web"},n=Me();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),v(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 I="gist.web.userLocale";function $(){const t=a(I);return null!==t?t:navigator.language}const C="gist.web.branding";async function E(){if(null!==a(C))return void i("Branding already cached.");const t=await async function(){try{return await S()("/api/v1/branding")}catch(t){return x(t)}}();if(t&&t.status>=200&&t.status<300){const e=new Date;e.setMinutes(e.getMinutes()+10),s(C,t.data,e),i("Branding fetched and cached.")}}function k(){return a(C)}const j="gist.web.templates";async function L(){if(null!==a(j))return void i("Templates already cached.");const t=await async function(){try{return await S()("/api/v1/templates")}catch(t){return x(t)}}();if(t&&t.status>=200&&t.status<300){const e=new Date;e.setMinutes(e.getMinutes()+60),s(j,t.data,e),i("Templates fetched and cached.")}}function P(){return a(j)}function T(t){try{return(document.getElementById(t)??document.querySelector(t))||null}catch{return null}}function D(t,e){const n=T(t);return n?Promise.resolve(n):new Promise(n=>{const i=new MutationObserver(()=>{const e=T(t);e&&(clearTimeout(o),i.disconnect(),n(e))}),o=setTimeout(()=>{i.disconnect(),n(null)},e);i.observe(document.documentElement,{childList:!0,subtree:!0})})}function N(t,e={}){const n=document.createElement(t);for(const[t,i]of Object.entries(e))n[t]=i;return n}function A(t,e){if(document.getElementById(t))return;const n=document.createElement("style");n.id=t,n.textContent=e,document.head.appendChild(n)}function M(t){document.body?document.body.appendChild(t):document.addEventListener("DOMContentLoaded",()=>document.body.appendChild(t),{once:!0})}async function R(t){try{return await S().post(`/api/v1/logs/queue/${t}`)}catch(t){return x(t)}}const q="messageInboxUpdated",z="inboxMessageAction";async function O(t){const e=await B();if(!e)return;const n=new Date;n.setMinutes(n.getMinutes()+60),s(e,t,n),po.events.dispatch(q,t)}async function W(){const t=await B();if(!t)return[];const e=a(t)??[],n=new Date;return e.filter(t=>!t.expiry||new Date(t.expiry)>n)}async function _(t,e){const n=await B();if(!n)return;const o=await async function(t,e){try{return await S()(`/api/v1/messages/${t}`,{method:"PATCH",body:JSON.stringify(e),headers:{"Content-Type":"application/json"}})}catch(t){return x(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 W();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";po.events.dispatch(z,{message:r,action:t})}po.events.dispatch(q,await W())}async function U(t){const e=await B();if(!e)return;const n=await W(),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&&po.events.dispatch(z,{message:o,action:"dismissed"}),po.events.dispatch(q,await W());const l=await R(t);(!l||l.status<200||l.status>=300)&&i(`Failed to log inbox message view: ${l?.status??"unknown error"}`)}async function B(){const t=await Ae();return t?`gist.web.inbox.messages.${t}`:null}const F=["always","untilDismissed","onceEver"],H={isInlineElement:!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,isEmbed:!1,embedFrequency:"always",embedLogView:!1};function G(t){let e=H.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 V(t){const e=H,n=t?.properties?.gist,o=!!t?.embedId;if(!n)return{...e,isEmbed:o};const s=n.embed;return{isInlineElement:!!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:G(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,isEmbed:o,embedFrequency:(a=s?.frequency,r=e.embedFrequency,void 0===a?r:F.includes(a)?a:(i(`Unknown embed frequency "${String(a)}", falling back to "${r}".`),r)),embedLogView:!!s?.logView};var a,r}const J=["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 X(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 K=["x-gist-top","x-gist-bottom","x-gist-floating-top","x-gist-floating-bottom"];function Q(t){return po.currentMessages.find(e=>e.instanceId===t)}function Y(t){return!!t&&po.currentMessages.some(e=>e.queueId===t)}function Z(t){return t?po.currentMessages.find(e=>e.elementId===t)??null:null}function tt(t){po.currentMessages=po.currentMessages.filter(e=>e.instanceId!==t)}function et(t,e){tt(t),po.currentMessages.push(e)}const nt={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"},it=Object.fromEntries(Object.entries(nt).map(([t,e])=>[e,t]));function ot(t){return t&&nt[t]?nt[t]:(i(`Invalid overlay position "${t}", defaulting to "topCenter"`),nt.topCenter)}function st(t){try{const e=new RegExp(t),n=new URL(window.location.href).pathname,i=null!=po.currentRoute&&e.test(po.currentRoute),o=po.currentRoute!==n&&e.test(n);return i||o}catch{return!1}}function at(t){try{return(new URL(t,window.location.href).pathname.replace(/\/+$/,"")||"/")===(new URL(window.location.href).pathname.replace(/\/+$/,"")||"/")}catch{return!0}}function rt(t){return t.tooltipPosition?"tooltip":t.overlay?"modal":t.elementId&&J.includes(t.elementId)?"overlay":t.elementId?"inline":"modal"}function lt(t,e){const n=rt(t),i=e.displayType;if(void 0===i)return!1;if(n!==i)return!0;const o=V(t);switch(i){case"modal":{if((t.position||"center")!==(e.modalPosition||"center"))return!0;const n=e.dismissOutsideClick??H.exitClick;if(o.exitClick!==n)return!0;const i=e.overlayColor??H.overlayColor;if(o.overlayColor!==i)return!0;break}case"overlay":{const n=ot(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||!K.includes(ot(e.overlayPosition))){const t=e.maxWidth??H.messageWidth;if(o.messageWidth!==t)return!0}return!1}function dt(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=ot(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&&K.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 ct={top:["bottom","left","right"],bottom:["top","left","right"],left:["right","top","bottom"],right:["left","top","bottom"]},ut=/auto|scroll/,pt={top:"gist-arrow-bottom",bottom:"gist-arrow-top",left:"gist-arrow-right",right:"gist-arrow-left"};function gt(t){const e=T(t);return e||i(`Tooltip target element not found for selector: ${t}`),e}function mt(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 ft(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 ht(t,e,n){const i=ft(t,e,n);if(i)return i;for(const i of ct[n]){const n=ft(t,e,i);if(n)return n}return null}function bt(t){const e=[];let n=t.parentElement;for(;n;){const t=getComputedStyle(n),i=t.overflow+t.overflowX+t.overflowY;ut.test(i)&&e.push(n),n=n.parentElement}return e}function yt(t){return"system"===t||"auto"===t?"normal":"light only"}function wt(t){if(!t||"default"===t)return"light";if("system"===t)return;const e=function(){const t=getComputedStyle(document.documentElement).colorScheme;if(t&&"normal"!==t)return t;if(document.body){const t=getComputedStyle(document.body).colorScheme;if(t&&"normal"!==t)return t}}();return e?function(t){const e=t.includes("dark"),n=t.includes("light");if(!e||!n)return e?"dark":n?"light":void 0}(e):void 0}let vt,xt=null;function St(){xt||(vt=wt(po.config?.colorScheme),xt=new MutationObserver(()=>{const t=wt(po.config?.colorScheme);t!==vt&&(vt=t,It(t))}),xt.observe(document.documentElement,{attributes:!0,attributeFilter:["style","class"]}),document.body&&xt.observe(document.body,{attributes:!0,attributeFilter:["style","class"]}))}function It(t){const e=t??"normal",n=yt(po.config?.colorScheme);for(const t of po.currentMessages??[]){const i=qt(t.instanceId??""),o=document.getElementById(i);o&&(o.style.colorScheme=n,o.contentWindow&&o.contentWindow.postMessage({action:"updateColorScheme",colorScheme:e},"*"))}po.events?.dispatch("colorSchemeChanged",t)}function $t(t){const e=T(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 Ct(t){const e=T(t);if(e)return!(!e.style||!e.style.height||"0px"===e.style.height)}function Et(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){n&&(e.stepId=n);const t=wt(po.config?.colorScheme);t&&(e.colorScheme=t);const o={options:e,capabilities:Lt(e)};i.contentWindow.postMessage(o,"*")}}(t,e,n)})}const kt=["MultiStepDisplayTypes","CrossPageStepNavigation","Snooze"],jt=["Snooze"];function Lt(t){return t.isEmbed?jt:kt}function Pt(t){if(!t.displaySettings)return;const e=qt(t.instanceId??""),n=document.getElementById(e);n?.contentWindow&&n.contentWindow.postMessage({action:"updateDisplaySettings",displaySettings:t.displaySettings},"*")}let Tt=null;function Dt(){Tt&&(document.removeEventListener("keydown",Tt),Tt=null)}async function Nt(){const t=document.querySelector(".gist-message");t&&(t.classList.remove("gist-visible"),await new Promise(t=>setTimeout(t,300))),At()}function At(){Dt();const t=document.querySelector("#gist-embed-message");t&&t.parentNode?.removeChild(t)}const Mt=new Map;function Rt(t){const e=t.instanceId??"",n=Mt.get(e);n&&(n.cleanup(),Mt.delete(e));const i=T(`gist-tooltip-${e}`);i&&i.parentNode?.removeChild(i)}function qt(t){return`gist-${t}`}function zt(){const t=document.querySelector(".gist-message");t&&t.classList.add("gist-visible")}const Ot="jist",Wt={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},_t={start:"flex-start",end:"flex-end",center:"center","space-between":"space-between","space-around":"space-around","space-evenly":"space-evenly"};function Ut(t){return"number"==typeof t?`${t}px`:"fill"===t?"100%":t}function Bt(t){try{return new Date(t).toLocaleDateString(navigator.language)}catch{return t}}class Ft{#t;#e;#n;#i=0;constructor({formatDate:t,onAction:e,templates:n}={}){this.#t=t||Bt,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.#u(t,e);case"template":return this.#p(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=Ut(t.gap)),t.align&&(n.style.alignItems=Wt[t.align]||t.align),t.justify&&(n.style.justifyContent=_t[t.justify]||t.justify),t.margin&&(t.margin.top&&(n.style.marginTop=Ut(t.margin.top)),t.margin.right&&(n.style.marginRight=Ut(t.margin.right)),t.margin.bottom&&(n.style.marginBottom=Ut(t.margin.bottom)),t.margin.left&&(n.style.marginLeft=Ut(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=Ut(t.width)),t.height&&(s.style.height=Ut(t.height)),t.objectFit&&(s.style.objectFit=t.objectFit),t.borderRadius&&(s.style.borderRadius=Ut(t.borderRadius)),o.appendChild(s),o}#u(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=Ut(t.gap)),t.align&&(i.style.alignItems=Wt[t.align]||t.align),t.justify&&(i.style.justifyContent=_t[t.justify]||t.justify),t.margin&&(t.margin.top&&(i.style.marginTop=Ut(t.margin.top)),t.margin.right&&(i.style.marginRight=Ut(t.margin.right)),t.margin.bottom&&(i.style.marginBottom=Ut(t.margin.bottom)),t.margin.left&&(i.style.marginLeft=Ut(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}#p(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(`${Ot}__${e}`),i&&t.classList.add(`${Ot}__${e}--${i}`),n!==e&&t.classList.add(`${Ot}__${n}`)}}var Ht;const Gt="jist-template",Vt=["template","data","theme","mode","formatDate","onAction","templates"],Jt=new Set(["fontWeight","maxLines","lineHeight","opacity"]),Xt=new Set(["lineHeight","letterSpacing"]),Kt={"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"},Qt=["shadow-offset-x","shadow-offset-y","shadow-blur","shadow-color"],Yt={"shadow-offset-x":"0","shadow-offset-y":"0","shadow-blur":"0","shadow-color":"transparent"},Zt={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"])},te=["hover","active","disabled"],ee=[["background-color","background-color"],["color","text-color"]];class ne extends HTMLElement{static observedAttributes=["template","data","theme","mode"];static#m=!1;static#f=null;static#h=0;static#b=new Map;static#y(){if(Ht.#m)return;if(Ht.#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)}#w=null;#v=null;#x=null;#S=null;#I="auto";#t=null;#e=null;#n={};#$=null;#C=null;get template(){return this.#v}set template(t){this.#v=t,this.#E()}get data(){return this.#x}set data(t){this.#x="string"==typeof t?JSON.parse(t):t,this.#E()}get theme(){return this.#S}set theme(t){this.#S="string"==typeof t?JSON.parse(t):t,this.#k(),this.#E()}get mode(){return this.#I}set mode(t){this.#I=t||"auto",this.#k()}get formatDate(){return this.#t}set formatDate(t){this.#t=t,this.#E()}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.#E()}connectedCallback(){Ht.#y(),this.#$=window.matchMedia("(prefers-color-scheme: dark)"),this.#C=()=>{"auto"===this.#I&&(this.#k(),this.#E())},this.#$.addEventListener("change",this.#C);for(const t of Vt)this.#j(t);this.#k(),this.#E()}#j(t){if(!Object.prototype.hasOwnProperty.call(this,t))return;const e=this,n=e[t];delete e[t],e[t]=n}disconnectedCallback(){this.#$&&this.#C&&this.#$.removeEventListener("change",this.#C),this.#L(),Ht.#P()}attributeChangedCallback(t,e,n){if(e!==n)switch(t){case"template":this.#v=n||null,this.#E();break;case"data":this.#x=n?JSON.parse(n):null,this.#E();break;case"theme":this.#S=n?JSON.parse(n):null,this.#k(),this.#E();break;case"mode":this.#I=n||"auto",this.#k(),this.#E()}}#T(){return"dark"===this.#I||"light"!==this.#I&&(this.#$?.matches??!1)}#k(){if(!this.isConnected)return void(this.#S||(this.#L(),Ht.#P()));if(this.#T()?this.setAttribute("data-jist-dark",""):this.removeAttribute("data-jist-dark"),!this.#S)return this.#L(),void Ht.#P();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.#D(this.#S,"--jist"),this.#T()){const t=this.#S.modes?.dark;t&&this.#D(t,"--jist")}this.#N()}#D(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&&Xt.has(n)?"normal":"number"!=typeof i||Jt.has(n)?String(i):`${i}px`;this.style.setProperty(t,e)}}else this.#D(i,t)}}#N(){const t=[],e=this.#S;if(!e)return;const n=e.modes?.dark;for(const i of Object.keys(Zt)){const o=e[i],s=n?.[i],a=Zt[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.#A(i,e,n,a))}}const i=t.join("\n");if(this.#L(),!i)return;let o=Ht.#b.get(i);o||(o={id:Ht.#h++,refs:0},Ht.#b.set(i,o)),o.refs++,this.#w=i,this.setAttribute("data-jist-v",String(o.id)),Ht.#P()}#L(){if(!this.#w)return;const t=Ht.#b.get(this.#w);t&&(t.refs--,t.refs<=0&&Ht.#b.delete(this.#w)),this.#w=null,this.removeAttribute("data-jist-v")}static#P(){if(0===Ht.#b.size)return void(Ht.#f&&(Ht.#f.remove(),Ht.#f=null));Ht.#f||(Ht.#f=document.createElement("style"),Ht.#f.setAttribute("data-jist-variants",""),document.head.appendChild(Ht.#f));const t=[];for(const[e,{id:n}]of Ht.#b){const i=`[data-jist-v="${n}"]`;t.push(e.replace(/^(\.[a-z_-]+)/gm,`${i} $1`))}Ht.#f.textContent=t.join("\n")}#A(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=Kt[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=Qt.map(t=>`var(--jist-button-${o}-${t}, var(--jist-button-${t}, ${Yt[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 te){const e=n.states?.[t],a=i.states?.[t];if(!e&&!a)continue;const r=[];for(const[e,n]of ee){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}#E(){if(!this.#v||!this.#x)return;if(!this.isConnected)return;const t=this.#n[this.#v];if(!t)return void(this.innerHTML="");const e=new Ft({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)}}Ht=ne;const ie="gist-inbox-button",oe="gist-inbox-badge",se="gist-inbox-panel",ae="gist-inbox-messages";let re=!1,le=!1;const de=new Set;let ce=null,ue=null;function pe(t,e){const n={...t},i=e;for(const t of Object.keys(i)){const e=n[t],o=i[t];null==e||"object"!=typeof e||Array.isArray(e)||null==o||"object"!=typeof o||Array.isArray(o)?void 0!==o&&(n[t]=o):n[t]=pe(e,o)}return n}function ge(t,e){const n=t?.patterns?.inbox;if(!n)return null;const i=t?.patterns?.modes?.dark?.inbox;return("dark"===e||null==e&&ce?.matches)&&i?pe(n,i):n}function me(){re||(re=!0,function(){const t=customElements.get(Gt);t?t!==ne&&console.warn("[jist] <jist-template> is already registered by another copy or version of the library; keeping the first registration."):customElements.define(Gt,ne)}(),A("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-button svg [fill]:not([fill="none"]) {\n fill: currentColor;\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@media (max-width: 424px) {\n #gist-inbox-panel {\n width: auto !important;\n left: 12px !important;\n right: 12px !important;\n }\n}\n'),po.events.on("messageInboxUpdated",t=>{fe(t)}),po.events.on("colorSchemeChanged",()=>{fe()}),ce=window.matchMedia("(prefers-color-scheme: dark)"),ue=()=>{"system"===po.config?.colorScheme&&fe()},ce.addEventListener("change",ue),fe())}async function fe(t){t||(t=await W());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 he();let n=k();n||(await Se(),n=k());const o=wt(po.config?.colorScheme),s=ge(n,o);if(s){if(function(t,e){let n=document.getElementById(ie);n||(n=N("div",{id:ie}),n.addEventListener("click",()=>{le?(le=!1,document.getElementById(se)?.classList.remove("gist-inbox-panel--open")):(le=!0,fe())}),M(n));const i=xe(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(oe);if(0===n||!e.unreadIndicator.showAlert)return void i?.remove();i||(i=N("span",{id:oe}),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)}(s,e),le){!function(t,e,n,o){let s=document.getElementById(se);const a=!s;a&&(s=N("div",{id:se}),M(s));const r=xe(t.position,!0);s.style.background=t.background,s.style.borderRadius=`${t.cornerRadius}px`,s.style.border=`1px solid ${t.borderColor}`,s.style.boxShadow=`${t.shadow.offsetX}px ${t.shadow.offsetY}px ${t.shadow.blur}px ${t.shadow.color}`,Object.assign(s.style,r);let l=document.getElementById(ae);l||(l=N("div",{id:ae}),s.appendChild(l)),l.innerHTML="";const d=P();e.forEach((s,a)=>{const r=N("div",{className:"gist-inbox-message-row"});r.style.padding="12px 16px",r.style.cursor="pointer",r.addEventListener("mouseenter",()=>{r.style.background=t.hoverBackground}),r.addEventListener("mouseleave",()=>{r.style.background=""});const c=document.createElement("jist-template");r.appendChild(c),l.appendChild(r);const u=c;if(u.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&&U(t.queueId),po.events.dispatch("inboxMessageAction",{message:t,action:"clicked",actionConfig:e})}(s,e)},d&&(u.templates=d),n?.theme&&(u.theme=n.theme),u.mode=o,u.formatDate=ve,u.data=s.properties??{},u.template=s.type??null,a<e.length-1){const e=N("div",{className:"gist-inbox-divider"});e.style.height="1px",e.style.background=t.dividerColor,e.style.margin="0",l.appendChild(e)}}),a?requestAnimationFrame(()=>{s.classList.add("gist-inbox-panel--open")}):s.classList.add("gist-inbox-panel--open")}(s,e,n,o??"auto");for(const t of e){const e=t.queueId;t.opened||!e||de.has(e)||(de.add(e),_(e,!0).finally(()=>{de.delete(e)}))}}}else he()}function he(){document.getElementById(ie)?.remove(),document.getElementById(se)?.remove(),le=!1}const be=[[60,"second",1],[3600,"minute",60],[86400,"hour",3600],[2592e3,"day",86400],[31536e3,"month",2592e3],[1/0,"year",31536e3]];let ye=null,we=null;function ve(t){const e=Math.round((Date.now()-new Date(t).getTime())/1e3);if(Number.isNaN(e))return t;const[,n,i]=be.find(([t])=>Math.abs(e)<t);return function(){const t=$();return ye&&we===t||(we=t,ye=new Intl.RelativeTimeFormat(t,{numeric:"auto"})),ye}().format(-Math.round(e/i),n)}function xe(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 Se(){await Promise.all([E(),L()])}let Ie=600,$e=!1;const Ce="gist.web.userQueueNextPullCheck",Ee="gist.web.sessionId";function ke(){let t=a(Ee);return t||(t=g()),s(Ee,t,new Date((new Date).getTime()+18e5)),String(t)}const je="gist.web.userToken",Le="gist.web.usingGuestUserToken",Pe="gist.web.guestUserToken";function Te(){return null!==a(Le)}function De(){return a(je)}function Ne(){if(null===De()){let t=a(Pe);null==t&&(t=g(),s(Pe,t),i(`Set guest user token "${t}" with expiry date set to 1 year from today`)),s(je,t),s(Le,!0),i(`Using anonymous session with token: "${t}"`)}}async function Ae(){const t=De();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 Me(){const t=De();return null===t?null:btoa(t)}function Re(){r(je),i("Cleared user token")}const qe="gist.web.customAttributes";let ze=new Map;function Oe(){const t=Array.from(ze.entries()),e=new Date;e.setDate(e.getDate()+30),s(qe,t,e),i(`Saved ${ze.size} custom attributes to storage with TTL of 30 days`)}!function(){const t=a(qe);if(t)try{ze=new Map(t)}catch{ze=new Map}else ze=new Map}();const We="gist.web.embeds",_e="data-cio-embed-payload",Ue=`script[type="application/json"][${_e}]`,Be=new Set,Fe=new Set;let He=!1;function Ge(){const t=a(We);if(!t)return null;const e=Date.now(),n={};for(const[i,o]of Object.entries(t.hidden??{}))(!0===o||"number"==typeof o&&o>e)&&(n[i]=o);return{hidden:n}}function Ve(t){try{s(We,t)}catch(t){i(`Embed ${We} state could not be persisted: ${t}`)}He=!0}function Je(t){const e=Ge()??{hidden:{}};t(e),Ve(e)}function Xe(t){t.embedId&&Be.delete(t.embedId)}async function Ke(t){const e=t?.embedId,n=t?.message;if(!e||!n?.messageId)return i("Embed payload is missing an embedId or message, skipping."),null;if(!n.properties?.gist?.encodedMessageHtml)return i(`Embed ${e} payload has no message html, skipping.`),null;if(Be.has(e))return i(`Embed ${e} has already been rendered on this page.`),null;if(n.embedId=e,t.display&&(n.properties.gist.embed={...t.display,...n.properties.gist.embed}),n.overlay=!1,n.tooltipPosition=void 0,n.position=null,delete n.properties.gist.tooltipPosition,delete n.properties.gist.position,!function(t){return!Fe.has(t)&&void 0===function(){const t=Ge();return t?(He||Ve(t),t):{hidden:{}}}().hidden[t]}(e))return i(`Embed ${e} is suppressed by its stored state.`),null;const o=t.target||function(t){return`[data-cio-embed="${t}"]`}(e);Be.add(e);let s=!1;try{if(!await D(o,1e4))return i(`Embed ${e} target "${o}" never appeared, skipping.`),null;if(function(t){const e=T(t);return!!e?.querySelector(".gist-frame")}(o))return i(`Embed ${e} target "${o}" already holds a message, skipping.`),null;const t=hi(n,o);return t?(s=!0,t.instanceId??null):null}catch(t){return i(`Embed ${e} failed to render: ${t}`),null}finally{s||Be.delete(e)}}function Qe(t){const e=t.getAttribute(_e)??"";try{const n=JSON.parse(t.textContent??"");return e&&!n.embedId&&(n.embedId=e),n}catch(t){return i(`Embed payload ${e||"(unnamed)"} could not be parsed: ${t}`),null}}const Ye="gist.web.message.broadcasts";async function Ze(t){const e=await sn();if(!e)return;const n=new Date;n.setMinutes(n.getMinutes()+60),s(e,t.filter(nn),n)}async function tn(){const t=await sn();return t?(a(t)??[]).filter(e=>{const n=e.properties.gist.broadcast,{frequency:i}=n,o=a(rn(t,e.queueId))??!0,s=a(an(t,e.queueId))||0,r=0===i.count;return o&&(r||s<i.count)}):[]}async function en(t,e){const n=a(t);return n?.find(t=>t.queueId===e)}function nn(t){return!(!t.properties?.gist||!t.properties.gist.broadcast)}function on(t){if(!nn(t))return!1;const e=t.properties.gist.broadcast;return 0===e.frequency.delay&&0===e.frequency.count}async function sn(){const t=await Ae();return t?`${Ye}.${t}`:null}function an(t,e){return`${t}.${e}.numberOfTimesShown`}function rn(t,e){return`${t}.${e}.shouldShow`}const ln="gist.web.message.user",dn=43200;async function cn(t){const e=await pn();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 un(){const t=await pn();if(!t)return[];const e=a(t)??[],n=await async function(){const t=await gn();return t?a(t)??[]:[]}();return e.filter(t=>!n.includes(t.queueId??""))}async function pn(){const t=await Ae();return t?`${ln}.${t}`:null}async function gn(){const t=await Ae();return t?`${ln}.${t}.seen`:null}async function mn(t){const e=await Ae();return e?`${ln}.${e}.message.${t}.loading`:null}async function fn(t){const e=await Ae();return e?`${ln}.${e}.message.${t}.state`:null}async function hn(t){const e=await Ae();return e?`${ln}.${e}.message.${t}.snoozed`:null}async function bn(t,e,n){const o=await fn(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}`)}async function yn(t){const e=await fn(t);e&&(r(e),i(`Cleared message state for queueId: ${t}`))}const wn="M3.54223 5.33301L7.7089 9.33301L11.8756 5.33301L12.6121 6.04011L7.7089 10.7472L2.80566 6.04011L3.54223 5.33301Z";function vn(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="${wn}" fill="${t}"/></svg>`}const xn=`\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(vn("#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`;async function Sn(t,e){try{return await S()(`/api/v1/preview/${t}`,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json"}})}catch(t){return x(t)}}const In="cioPreviewId",$n="cioPreviewSettings";const Cn="gist.previewBar.collapsed",En="gist.previewBar.steps",kn="gist-pb-styles",jn="gist-preview-bar",Ln={topLeft:"Top Left",topCenter:"Top Center",topRight:"Top Right",bottomLeft:"Bottom Left",bottomCenter:"Bottom Center",bottomRight:"Bottom Right"};let Pn=null,Tn=[],Dn={},Nn=null,An=!1,Mn=!1,Rn=5,qn=null,zn=!0,On=!1,Wn=!1,_n=null,Un=null,Bn=null;const Fn=new Map;function Hn(t,e){const n=N("div",{className:"gist-pb-label-group"});return n.appendChild(N("span",{className:"gist-pb-label",textContent:t})),n.appendChild(e),n}function Gn(t,e){const n=N("select",{className:"gist-pb-select"});for(const i of t){const t=N("option",{value:i.value,textContent:i.label});i.value===e&&(t.selected=!0),n.appendChild(t)}return n}function Vn(t,e,n){const i=N("input",{className:"gist-pb-input",type:t,value:String(e)});return n&&(i.style.width=n),i}function Jn(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 Xn(t){return!!("inline"!==t.displayType&&"tooltip"!==t.displayType||t.elementSelector?.trim())}function Kn(t){if("overlay"===t.displayType&&K.includes(ot(t.overlayPosition))){const{maxWidth:e,...n}=t;t=n}if(Dn=t,Nn){const e=Tn.findIndex(t=>t.stepName===Nn);-1!==e&&(Tn[e]={...Tn[e],displaySettings:{...t}})}if(!Pn)return;const e=po.currentMessages.find(t=>t.instanceId===Pn);e&&Xn(t)&&(Pt(e),lt(e,t)&&Di(e,Nn,t)),function(){const t=new URLSearchParams(window.location.search).get(In);t&&(Qn(),Sn(t,Tn).then(t=>{t&&404===t.status&&Pn&&po.dismissMessage(Pn)}).catch(()=>i("Failed to persist preview display settings")))}()}function Qn(){try{sessionStorage.setItem(En,JSON.stringify(Tn))}catch{}}function Yn(t){const e=t.value.trim();e&&!T(e)?t.classList.add("gist-pb-input--invalid"):t.classList.remove("gist-pb-input--invalid")}function Zn(t,e){const n=Vn("text",t.elementSelector||"","260px");n.placeholder="Element ID or selector",Yn(n),n.addEventListener("change",()=>{const t=n.value.trim(),e=Dn.elementSelector;t&&ti(t),Kn({...Dn,elementSelector:t}),e&&e!==t&&ei(e),Yn(n)});const i=N("button",{type:"button",className:"gist-pb-select-elem-btn",textContent:"Select Element"});Wn&&(i.disabled=!0),i.addEventListener("click",()=>ii(n));const o=N("div",{className:"gist-pb-inline-row"});o.appendChild(n),o.appendChild(i),e.appendChild(Hn("Element Selector",o))}function ti(t){if(!t||Fn.has(t))return;const e=T(t);e&&Fn.set(t,e.innerHTML)}function ei(t){const e=Fn.get(t);if(void 0===e)return;const n=T(t);n&&(n.innerHTML=e)}function ni(){for(const t of Fn.keys())ei(t);Fn.clear()}function ii(t){if(Wn)return;Wn=!0;const e=document.querySelector(`#${jn} .gist-pb-select-elem-btn`);e&&(e.disabled=!0);const n={...Dn},o=po.currentMessages.find(t=>t.instanceId===Pn)??null;o&&Pi(o),Dn.elementSelector&&ei(Dn.elementSelector);const s=N("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(),Dn=n,Nn){const t=Tn.findIndex(t=>t.stepName===Nn);-1!==t&&(Tn[t]={...Tn[t],displaySettings:{...n}})}o&&Xn(n)&&Di(o,Nn,n),oi()}},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(jn),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,ti(s);const a=Dn.elementSelector,r={...Dn,elementSelector:s},l=null!=o&&Xn(r)&<(o,r);Kn(r),a&&a!==s&&ei(a),o&&!l&&Di(o,Nn,r)}c(),oi()},c=()=>{a?.classList.remove("gist-pb-pick-highlight"),s.removeEventListener("mousemove",r),s.removeEventListener("click",d),document.removeEventListener("keydown",l),document.body.removeChild(s),Wn=!1,_n=null};_n=c,s.addEventListener("mousemove",r),s.addEventListener("click",d),document.addEventListener("keydown",l),document.body.appendChild(s)}function oi(){const t=document.getElementById(jn);if(!t)return;if(t.classList.toggle("gist-pb-hidden",!Pn&&!Mn),t.innerHTML="",!Pn){if(Mn){const e=N("div",{className:"gist-pb-controls-row gist-pb-ended-row"}),n=N("span",{className:"gist-pb-ended-icon",textContent:"✓"}),i=N("p",{className:"gist-pb-ended-text"});if(i.innerHTML=ai(Rn),e.appendChild(n),e.appendChild(i),zn){const t=N("button",{type:"button",className:"gist-pb-cancel-btn",textContent:"Cancel"});t.addEventListener("click",ri),e.appendChild(t)}t.appendChild(e)}return}const e=N("div",{className:"gist-pb-toggle-row"+(An?" gist-pb-toggle-row--collapsed":"")}),n=N("button",{type:"button",className:"gist-pb-toggle-btn"}),i=An?"transform:rotate(180deg);display:inline-flex;":"display:inline-flex;";if(n.innerHTML=`${An?"Expand":"Collapse"}<span style="${i}">${vn("white")}</span>`,n.addEventListener("click",li),e.appendChild(n),t.appendChild(e),An)return;const o=N("div",{className:"gist-pb-controls-row"});if(Tn.length>0){const t=Nn??Tn[0].stepName,e=Gn(Tn.map(t=>({value:t.stepName,label:t.stepName})),t);e.addEventListener("change",()=>{const t=Tn.find(t=>t.stepName===e.value);if(t){Nn=t.stepName,Dn={...t.displaySettings};const e=po.currentMessages.find(t=>t.instanceId===Pn);e&&Ti(e,t.stepName,t.displaySettings).then(n=>{!n&&Xn(t.displaySettings)&&Di(e,t.stepName,t.displaySettings)}),oi()}}),o.appendChild(Hn("Step",e))}const s=Gn([{value:"modal",label:"Modal"},{value:"overlay",label:"Overlay"},{value:"inline",label:"Inline"},{value:"tooltip",label:"Tooltip"}],Dn.displayType||"modal");s.addEventListener("change",()=>{const t=s.value,e=Dn.displayType,n=Dn.elementSelector,i={...Dn,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),Dn=i,Kn(Dn),"inline"!==e&&"tooltip"!==e||!n||"inline"===t||"tooltip"===t||ei(n),oi()}),o.appendChild(Hn("Display Type",s));const a=Dn.displayType||"modal";"modal"===a?function(t,e){const n=Gn([{value:"top",label:"Top"},{value:"center",label:"Center"},{value:"bottom",label:"Bottom"}],t.modalPosition||"center");n.addEventListener("change",()=>Kn({...Dn,modalPosition:n.value})),e.appendChild(Hn("Position",n));const i=Vn("number",t.maxWidth??414,"80px");i.addEventListener("change",()=>Kn({...Dn,maxWidth:parseInt(i.value)||414})),e.appendChild(Hn("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=N("div",{className:"gist-pb-color-control"}),o=N("input",{className:"gist-pb-color-input",type:"color",value:e}),s=N("div",{className:"gist-pb-color-swatch"});s.style.background=e,s.appendChild(o),s.addEventListener("click",()=>o.click());const a=N("input",{className:"gist-pb-color-hex",type:"text",maxLength:6,value:e.replace("#","")}),r=N("input",{className:"gist-pb-color-opacity",type:"number",min:"0",max:"100",value:String(n)}),l=N("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,Kn({...Dn,overlayColor:Jn(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),Hn("Overlay Color",i)}(t));const o=N("div",{className:"gist-pb-checkbox-row"}),s=N("input",{className:"gist-pb-checkbox",type:"checkbox"});s.checked=t.dismissOutsideClick??!1;const a=N("label",{className:"gist-pb-checkbox-label",textContent:"Dismiss on click outside"});s.addEventListener("change",()=>Kn({...Dn,dismissOutsideClick:s.checked})),a.addEventListener("click",()=>{s.checked=!s.checked,Kn({...Dn,dismissOutsideClick:s.checked})}),o.appendChild(s),o.appendChild(a);const r=Hn(" ",o);r.classList.add("gist-pb-label-group--grow"),r.firstChild.classList.add("gist-pb-label--spacer"),e.appendChild(r)}(Dn,o):"overlay"===a?function(t,e){const n=Gn(Object.entries(Ln).map(([t,e])=>({value:t,label:e})),t.overlayPosition||"topCenter");if(n.addEventListener("change",()=>Kn({...Dn,overlayPosition:n.value})),e.appendChild(Hn("Position",n)),!K.includes(ot(t.overlayPosition))){const n=Vn("number",t.maxWidth??414,"80px");n.addEventListener("change",()=>Kn({...Dn,maxWidth:parseInt(n.value)||414})),e.appendChild(Hn("Max Width",n))}}(Dn,o):"inline"===a?function(t,e){Zn(t,e)}(Dn,o):"tooltip"===a&&function(t,e){const n=Gn([{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],t.tooltipPosition||"top");n.addEventListener("change",()=>Kn({...Dn,tooltipPosition:n.value})),e.appendChild(Hn("Position",n)),Zn(t,e)}(Dn,o),o.appendChild(N("div",{className:"gist-pb-spacer"}));const r=N("button",{type:"button",className:"gist-pb-save-btn",textContent:"End session"});r.addEventListener("click",async()=>{Pn&&await po.dismissMessage(Pn)}),o.appendChild(r),t.appendChild(o)}async function si(){if(!On)if(On=!0,function(){try{sessionStorage.removeItem(En)}catch{}}(),Re(),function(){try{sessionStorage.removeItem(o)}catch{}}(),zn){try{window.close()}catch{}try{window.location.reload()}catch{}_n&&_n(),qn&&(clearInterval(qn),qn=null),ni(),document.getElementById(jn)?.remove(),document.getElementById(kn)?.remove(),Pn=null,Tn=[],Dn={},Nn=null,Mn=!1,Rn=5,zn=!0,On=!1}else Mn=!1,On=!1,oi()}function ai(t){return zn?`<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 ri(){Mn&&qn&&(zn=!1,oi())}function li(){An=!An;try{sessionStorage.setItem(Cn,String(An))}catch{}oi()}function di(t){if(Mn)return;Pn=t.instanceId??null;const e=t.displaySettings;if(Array.isArray(e)&&e.length>0?(Tn=e,function(t){let e;try{const t=sessionStorage.getItem(En);if(!t)return;e=JSON.parse(t)}catch{return}if(Array.isArray(e))for(const n of e){const e=t.findIndex(t=>t.stepName===n.stepName);-1!==e&&n.displaySettings&&(t[e]={...t[e],displaySettings:{...t[e].displaySettings,...n.displaySettings}})}}(Tn),Nn||(Nn=Tn[0].stepName,Dn={...Tn[0].displaySettings})):e&&"object"==typeof e&&!Array.isArray(e)&&(Dn={...e}),Un||Bn){const t=!!Un,e=!!Bn,n=Un,o=Bn;if(Un=null,Bn=null,t){const t=Tn.find(t=>t.stepName===n);if(!t)return i(`Preview bar: step "${n}" not found, ignoring initial step/display override`),void oi();Nn=t.stepName,Dn={...t.displaySettings}}if(e){if(!t)return i(`Preview bar: display type "${o}" provided without a step, ignoring`),void oi();Dn={...Dn,displayType:o}}oi();const s=po.currentMessages.find(t=>t.instanceId===Pn);return void(s&&Xn(Dn)?Di(s,Nn,Dn):function(){const t=Dn.displayType;if("inline"!==t&&"tooltip"!==t)return;const e=document.querySelector("#gist-preview-bar .gist-pb-input[type='text']");e&&ii(e)}())}oi()}function ci(){ni(),Pn=null,Tn=[],Dn={},Nn=null,Mn=!0,Rn=5,zn=!0,On=!1;const t=new URLSearchParams(window.location.search).get(In);t&&async function(t){try{return await S()(`/api/v1/preview/${t}`,{method:"DELETE"})}catch(t){return x(t)}}(t).catch(()=>i("Failed to delete preview session")),oi(),qn&&clearInterval(qn),qn=setInterval(async()=>{if(Rn-=1,Rn<=0)clearInterval(qn),qn=null,await si();else{const t=document.querySelector(`#${jn} .gist-pb-ended-text`);t?t.innerHTML=ai(Rn):oi()}},1e3)}const ui=60,pi=new Set;function gi(t){return!(!t||pi.has(t)||(pi.add(t),0))}function mi(t){t&&pi.delete(t)}async function fi(t){if(!po.isDocumentVisible)return i("Document hidden, not showing message now."),null;if(Y(t.queueId))return i(`Message with queueId ${t.queueId} is already showing.`),null;const e=V(t);return!t.tooltipPosition&&e.hasTooltipPosition&&(t.tooltipPosition=e.tooltipPosition),t.tooltipPosition?function(t,e){const n=e.elementId||t.elementId,o=po.config.isPreviewSession&&t.properties?.gist?.livePreview;if(n){if(!T(n)){if(!o)return i(`Tooltip target element "${n}" not found for message ${t.messageId}, skipping display`),po.messageError(t),null;i(`Preview: tooltip target "${n}" not found, loading message for preview bar`)}}else{if(!o)return i(`No target selector specified for tooltip message ${t.messageId}`),po.messageError(t),null;i("Preview: no tooltip target yet, loading message for preview bar")}const s=po.currentMessages.find(t=>t.tooltipPosition&&t.elementId===n);s&&(i(`Tooltip already showing on target "${n}" (instance ${s.instanceId}), dismissing it first`),po.messageDismissed(s,"displaced"),Rt(s),s.instanceId&&tt(s.instanceId)),t.instanceId=g(),t.overlay=!1,t.firstLoad=!0,t.shouldResizeHeight=!1,t.shouldScale=!1,t.renderStartTime=(new Date).getTime(),t.elementId=n,po.currentMessages.push(t);return $i(t,null,t.savedStepName||null)}(t,e):po.overlayInstanceId?(i(`Message ${po.overlayInstanceId} already showing.`),null):(t.instanceId=g(),t.overlay=!0,t.firstLoad=!0,t.shouldResizeHeight=!0,t.shouldScale=e.shouldScale,t.renderStartTime=(new Date).getTime(),po.overlayInstanceId=t.instanceId,po.currentMessages.push(t),$i(t,null,t.savedStepName||null))}function hi(t,e){return po.isDocumentVisible||t.embedId?Y(t.queueId)?(i(`Message with queueId ${t.queueId} is already showing.`),null):Z(e)?(i(`Message with elementId ${e} already has a message.`),null):(t.instanceId=g(),t.overlay=!1,t.firstLoad=!0,t.shouldScale=!1,t.elementId=e,t.shouldResizeHeight=!Ct(e),t.renderStartTime=(new Date).getTime(),po.currentMessages.push(t),$i(t,e,t.savedStepName||null)):(i("Document hidden, not showing message now."),null)}async function bi(t,e="dismissed"){t?(po.messageDismissed(t,e),"dismissed"===e&&function(t){const e=t.embedId;e&&(Fe.add(e),"untilDismissed"===V(t).embedFrequency&&(Je(t=>{t.hidden[e]=!0}),i(`Embed ${e} dismissed and will not render again.`)))}(t),await yi(t)):i("Message not found")}async function yi(t){"tooltip"===rt(t)?xi(t):t.overlay?await Si(!0,t):vi(t)}async function wi(t){t?V(t).persistent&&(i("Persistent message dismissed, logging view"),await Ni(t),await Ci(t),await yn(t.queueId??"")):i("Message not found")}function vi(t){Xe(t),t.instanceId&&tt(t.instanceId),t.elementId&&$t(t.elementId),po.config.isPreviewSession&&(ci(),Ii())}function xi(t){Xe(t),Rt(t),t.instanceId&&tt(t.instanceId),0===po.currentMessages.length&&(window.removeEventListener("message",ji),window.removeEventListener("touchstart",Ei)),po.config.isPreviewSession&&(ci(),Ii())}async function Si(t,e){Xe(e),t?await Nt():At(),0===po.currentMessages.length&&(window.removeEventListener("message",ji),window.removeEventListener("touchstart",Ei)),e.instanceId&&tt(e.instanceId),po.overlayInstanceId=null,po.config.isPreviewSession&&(ci(),Ii())}function Ii(){const t=new URL(window.location.href);t.searchParams.delete(In),t.searchParams.delete($n),history.replaceState(null,"",t.toString())}function $i(t,e=null,n=null){const o=po.config.env,s={endpoint:w.ENGINE_API_ENDPOINT[o],siteId:po.config.siteId,dataCenter:po.config.dataCenter,messageId:t.messageId,instanceId:t.instanceId??"",livePreview:!1,isEmbed:!!t.embedId,properties:t.properties,customAttributes:Object.fromEntries(new Map(ze))};let a=`${w.GIST_VIEW_ENDPOINT[o]}/index.html`;return"undefined"!=typeof window&&window.crossOriginIsolated&&(a=`${a}?coi=1`,i("Cross-origin-isolated page detected, requesting renderer with COEP headers")),window.addEventListener("message",ji),window.addEventListener("touchstart",Ei),"tooltip"===rt(t)?function(t,e,n,i=null){const o=e.instanceId??"",s=qt(o),a=V(e),r=Mt.get(o);r&&(r.cleanup(),Mt.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;const c=yt(po.config?.colorScheme);d.innerHTML=function(t,e,n,i="",o="light only"){let s=600;e.messageWidth>s&&(s=e.messageWidth);const a=e.tooltipArrowColor,r=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),l=i?`#${i} `:"";return`\n <div class="gist-tooltip-outer">\n <style>\n ${l}.gist-tooltip-outer {\n position: absolute;\n }\n ${l}.gist-tooltip-container {\n position: relative;\n z-index: 9999999;\n opacity: 0;\n transition: opacity 0.3s ease-in-out;\n }\n ${l}.gist-tooltip-container.gist-visible {\n opacity: 1;\n }\n ${l}.gist-tooltip-frame-clip {\n overflow: hidden;\n }\n ${l}.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: ${o};\n }\n ${l}.gist-tooltip-arrow {\n width: 0;\n height: 0;\n position: absolute;\n z-index: 1;\n }\n ${l}.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 ${a};\n }\n ${l}.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 ${a};\n }\n ${l}.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 ${a};\n }\n ${l}.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 ${a};\n }\n @media (max-width: ${s}px) {\n ${l}.gist-tooltip-frame {\n max-width: 100%;\n }\n }\n </style>\n <div class="gist-tooltip-container">\n <div class="gist-tooltip-arrow ${r}"></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,c),document.body.appendChild(d),Et(s,n,i)}(a,t,s,n):e?(J.includes(e)&&X(e),function(t,e,n,o,s=null){const a=T(t);if(a){const i=qt(n.instanceId??"");a.classList.add(i);const r=V(n);let l=r.messageWidth+"px";K.includes(t)&&!r.hasCustomWidth&&(l="100%"),J.includes(t)&&(a.style.width=l),Ct(t)||(a.style.height="0px"),a.innerHTML=function(t,e,n){const i=yt(po.config?.colorScheme);return function(t,e,n,i="light only"){let o=800;return e.messageWidth>o&&(o=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: ${i};\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: ${o}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>`}(qt(e.instanceId??""),n,t,i)}(e,n,r),Et(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){Dt(),document.querySelectorAll("#gist-embed-message").forEach(t=>{t.parentNode?.removeChild(t)}),document.body.insertAdjacentHTML("afterbegin",function(t,e){const n=V(e),i=yt(po.config?.colorScheme);return function(t,e,n,i="light only"){let o=600;return e.messageWidth>o&&(o=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: ${i};\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: ${o}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>`}(qt(e.instanceId??""),n,t,i)}(t,e)),Et(qt(e.instanceId??""),n,i)}(a,t,s,n),t}async function Ci(t){let e;i(`Message shown, logging view for: ${t.messageId}`),null!=t.queueId?(await Ni(t),e=await R(t.queueId)):e=await async function(t){try{return await S().post(`/api/v1/logs/message/${t}`)}catch(t){return x(t)}}(t.messageId),i(200===e?.status?"Message view logged":`Problem logging message: ${e?.status}`)}function Ei(){}function ki(t){if(t.startsWith("mailto:")||t.startsWith("https://")||t.startsWith("http://")||t.startsWith("/"))window.location.href=t;else try{const e=new URL(t,window.location.href);"https:"===e.protocol||"http:"===e.protocol?window.location.href=e.href:i(`Refusing to navigate to non-http(s) target: ${t}`)}catch{i(`Refusing to navigate to unparseable target: ${t}`)}}async function ji(t){const e=po.config.env,n=t.data;if(n.gist&&t.origin===w.RENDERER_HOST[e]){const t=n.gist.instanceId,e=Q(t);if(!e)return;const o=V(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 mn(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"),Pt(e)),po.config.isPreviewSession&&e.properties?.gist?.livePreview&&di(e),e.firstLoad||e.isDisplayChange){if("tooltip"===rt(e)){const t=e.properties?.gist?.elementId||e.elementId||void 0;if(!t||!T(t)){if(po.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`),po.messageError(e),e.firstLoad=!1,e.isDisplayChange=!1,xi(e);break}const n=await async function(t){const e=t.instanceId??"",n=V(t),o=`gist-tooltip-${e}`,s=T(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=Mt.get(e);r&&(r.cleanup(),Mt.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=gt(e);if(!o)return!1;let s=[];try{s=bt(o)}catch{}if(mt(o.getBoundingClientRect(),s))return!0;if(!function(t,e,n){const i=gt(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!==ht(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=bt(o)}catch{}return mt(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=gt(e);if(!s)return null;let a=null,r=null,l=!1,d=[],c=null;try{d=bt(s)}catch{}function u(){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(!mt(e,d))return void(t.style.display="none");t.style.display="";const a=ht(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(pt[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 p(){null===a&&(a=requestAnimationFrame(()=>{a=null,u()}))}function g(){if(!l){l=!0,c&&(c.disconnect(),c=null),window.removeEventListener("scroll",p),window.removeEventListener("resize",p);for(const t of d)t.removeEventListener("scroll",p);null!==a&&(cancelAnimationFrame(a),a=null),null!==r&&(cancelAnimationFrame(r),r=null)}}if(u(),l)return null;window.addEventListener("scroll",p,{passive:!0}),window.addEventListener("resize",p,{passive:!0});for(const t of d)t.addEventListener("scroll",p,{passive:!0});try{c=new MutationObserver(()=>{null===r&&(r=requestAnimationFrame(()=>{r=null,document.contains(s)||u()}))}),c.observe(document.body,{childList:!0,subtree:!0})}catch{}return{cleanup:g,reposition:u}}(l,a,d,{onDetach:()=>{Mt.delete(e);const t=T(o);t&&t.parentNode?.removeChild(t)}});if(c){if("none"!==l.style.display){const t=s.querySelector(".gist-tooltip-container");return t?(Mt.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(po.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`),po.messageError(e),e.firstLoad=!1,e.isDisplayChange=!1,xi(e);break}}else e.overlay?function(t){const e=V(t),n=document.querySelector("#gist-overlay");if(n){n.classList.add("gist-visible");const o=document.querySelector(".gist-message");o&&(t.position?o.classList.add("gist-"+t.position):o.classList.add("gist-center")),setTimeout(zt,100),e.exitClick&&(i=t.instanceId??"",Dt(),Tt=t=>{"Escape"===t.key&&po.dismissMessage(i)},document.addEventListener("keydown",Tt),setTimeout(()=>function(t){const e=document.querySelector("#gist-overlay");e&&e.addEventListener("click",()=>{po.dismissMessage(t)})}(t.instanceId??""),1e3))}else At();var i}(e):function(t){const e=T(t);e&&e.classList.add("gist-visible")}(e.elementId);e.firstLoad&&!e.isDisplayChange&&(po.messageShown(e),o.isEmbed?(function(t){const e=t.embedId;e&&"onceEver"===V(t).embedFrequency&&(Je(t=>{t.hidden[e]=!0}),i(`Embed ${e} shown once and will not render again.`))}(e),o.embedLogView&&await Ci(e)):o.persistent?i("Persistent message shown, skipping logging view"):await Ci(e)),e.firstLoad=!1,e.isDisplayChange=!1}et(t,e);break}case"tap":{const t=n.gist.parameters.action,a=n.gist.parameters.name;if(po.messageAction(e,t,a),n.gist.parameters.system&&!o.persistent){await bi(e);break}try{const n=new URL(t);if(n&&"gist:"===n.protocol)switch(n.href.replace("gist://","").split("?")[0]){case"close":if(!gi(e.instanceId))break;try{await wi(e),await Ai(e),await bi(e),await Ui()}finally{mi(e.instanceId)}break;case"snooze":{const t=Number.parseInt(n.searchParams.get("showIn")??"",10),a=Number.isFinite(t)&&t>0?t:ui;o.isEmbed?function(t,e){const n=t.embedId;if(!(n&&e>0))return;const o=Date.now()+60*e*1e3;Je(t=>{t.hidden[n]=o}),i(`Embed ${n} snoozed for ${e} minute(s).`)}(e,a):o.persistent&&e.queueId?(await async function(t,e){const n=await hn(t);if(!n)return;const o=Math.min(Math.max(Math.floor(e),1),dn);s(n,!0,new Date(Date.now()+60*o*1e3)),i(`Snoozed message ${t} for ${o} minutes`)}(e.queueId,a),function(t){const e=60*t*1e3;e>2**31-1||setTimeout(()=>{Ui()},e)}(a)):(i("Snooze is only supported for persistent queue messages, closing instead"),await wi(e),await Ai(e)),await bi(e,"snoozed"),await Ui();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 po.showMessage({messageId:t,properties:n})}break}case"loadPage":{const t=n.href.substring(n.href.indexOf("?url=")+5);t&&ki(t);break}}}catch{}break}case"stepChangeRequested":{const t=n.gist.parameters.displaySettings,o=n.gist.parameters.messageStepName;if(!o){i(`stepChangeRequested for message ${e.messageId} arrived without a messageStepName; keeping the current step visible`);break}await Ti(e,o,t,n.gist.parameters.name??"")||(i(`Step "${o}" stays on this page, instructing renderer to show it`),function(t,e,n){const i=qt(t.instanceId??""),o=document.getElementById(i);o?.contentWindow?.postMessage({action:"showStep",stepId:e,requestId:n},"*")}(e,o,n.gist.parameters.requestId));break}case"changeMessageStep":{const t=n.gist.parameters.displaySettings,s=n.gist.parameters.messageStepName;po.config.isPreviewSession&&s&&e.properties?.gist?.livePreview&&function(t,e){if(Mn)return;Nn=t;const n=Tn.find(e=>e.stepName===t);n?Dn={...n.displaySettings}:e&&(Dn={...e}),oi()}(s,t),(o.persistent||on(e))&&await bn(e.queueId??"",s,t),t&&!o.isEmbed&<(e,t)&&(i("Display settings changed, reloading message"),await Pi(e),dt(e,t),await Li(e,s??null));break}case"routeChanged":e.currentRoute=n.gist.parameters.route,e.renderStartTime=(new Date).getTime(),et(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"===rt(e)?function(t,e){const n=t.instanceId??"",i=qt(n),o=document.getElementById(i);if(o&&e.height>0){o.style.height=`${e.height}px`;const t=Mt.get(n);t&&t.reposition()}}(e,n.gist.parameters):e.elementId&&!e.shouldResizeHeight||function(t,e){const n=T(t.elementId?t.elementId:qt(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=T(qt(t));n&&(n.title=e)}(t,n.gist.parameters.title);break;case"eventDispatched":po.events.dispatch("eventDispatched",{name:n.gist.parameters.name,payload:n.gist.parameters.payload});break;case"error":case"routeError":po.messageError(e),"tooltip"===rt(e)?xi(e):po.overlayInstanceId?await Si(!1,e):vi(e)}}}async function Li(t,e){t.isDisplayChange=!0,t.renderStartTime=(new Date).getTime();const n=rt(t),o=t.elementId||null;if("tooltip"===n)return po.overlayInstanceId===t.instanceId&&(po.overlayInstanceId=null),t.shouldScale=!1,t.shouldResizeHeight=!1,void $i(t,null,e);if(o){const e=Z(o);e&&e.instanceId!==t.instanceId&&(i(`Dismissing existing message at ${o} to make room for multi-step message`),await bi(e,"displaced"))}if(t.overlay){po.overlayInstanceId=t.instanceId??null;const e=V(t);t.shouldScale=e.shouldScale,t.shouldResizeHeight=!0}else po.overlayInstanceId=null,t.shouldScale=!1,t.shouldResizeHeight=!Ct(o??"");o&&J.includes(o)&&X(o),$i(t,o,e)}async function Pi(t){"tooltip"===rt(t)?Rt(t):t.overlay?await Nt():t.elementId&&$t(t.elementId)}async function Ti(t,e,n,o=""){const s=n?.pageUrl;if(!s||at(s))return!1;if(!function(t){try{const e=new URL(t,window.location.href).protocol;return"https:"===e||"http:"===e}catch{return!1}}(s))return i(`Step "${e}" page-url is not a navigable http(s) target (${s}); treating as a local step change`),!1;const a=V(t);if(po.messageAction(t,`gist://loadPage?url=${s}`,o),a.persistent||on(t)){i(`Saving step "${e}" before navigating to ${s}`);try{await bn(t.queueId??"",e,n)}catch(t){i(`Failed to save step state before navigating: ${t}`)}}return po.config.isPreviewSession?(await async function(){const t=new URLSearchParams(window.location.search).get(In);if(t){Qn();try{await Sn(t,Tn)}catch{i("Failed to flush preview display settings before navigation")}}}(),function(t){try{const e=new URL(window.location.href);return new URL(t,window.location.href).origin===e.origin}catch{return!1}}(s)?window.location.href=function(t,e,n){try{const i=new URL(t,window.location.href),o=De();if(!o)return t;i.searchParams.set(In,o);try{i.searchParams.set($n,btoa(JSON.stringify({stepName:e,displayType:n})))}catch{}return i.href}catch{return t}}(s,e,n?.displayType):(i(`Preview: step "${e}" targets a different origin (${s}); navigating without the preview session token`),ki(s))):ki(s),!0}async function Di(t,e,n){n&<(t,n)&&(await Pi(t),dt(t,n)),await Li(t,e??null)}async function Ni(t){i(`Logging user message view locally for: ${t.queueId}`),nn(t)?await async function(t){i(`Marking broadcast ${t} as seen.`);const e=await sn();if(!e)return;const n=await en(e,t);if(!n)return;const o=n.properties.gist.broadcast,{frequency:r}=o,l=an(e,t),d=rn(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 gn();if(!e)return;const n=a(e)??[];n.push(t),s(e,n)}(t.queueId??"")}async function Ai(t){nn(t)&&(i(`Logging broadcast dismissed locally for: ${t.queueId}`),await async function(t){i(`Marking broadcast ${t} as dismissed.`);const e=await sn();if(!e)return;const n=await en(e,t);n&&(!0!==n.properties.gist.broadcast.frequency.ignoreDismiss?(s(rn(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 yn(t.queueId??""))}const Mi=(t,e)=>t().then((t=>new Promise(e=>setTimeout(e,t)))(e).then(()=>Mi(t,e)));let Ri=!1,qi=null;const zi=1e4,Oi=new Set,Wi=new Map;async function _i(){Ri?await Ui():De()?(i("Queue watcher started"),Ri=!0,Mi(()=>new Promise(()=>{!async function(){if(w.hasActiveSSEConnection())return!w.isSSEConnectionManagedBySDK()&&qi&&(i("Not the main instance, closing our SSE connection."),Hi()),void await Ui();qi&&(i("SSE connection not active, closing it."),Hi()),!w.useSSE()||Te()?await Fi():await async function(){Hi();const t=function(){const t=Me();return null===t?(i("No user token available for SSE endpoint."),null):w.GIST_QUEUE_REALTIME_API_ENDPOINT[po.config.env??"prod"]+`/api/v3/sse?userToken=${t}&siteId=${po.config.siteId}&sessionId=${ke()}&platform=web`}();if(null===t)return i("SSE endpoint not available, falling back to polling."),void await Fi();i(`Starting SSE queue listener on ${t}`),qi=new EventSource(t),w.setActiveSSEConnection(),qi.addEventListener("connected",async t=>{try{i("SSE connection received"),w.setUseSSEFlag(!0);const e=JSON.parse(t.data);e.heartbeat&&(w.setSSEHeartbeat(e.heartbeat),i(`SSE heartbeat set to ${e.heartbeat} seconds`)),w.setActiveSSEConnection()}catch(t){i(`Failed to parse SSE settings: ${t}`)}r(Ce),await Fi()}),qi.addEventListener("messages",async t=>{try{const e=JSON.parse(t.data);i("SSE message received"),await cn(e),await Ze(e),await Ui()}catch(t){i(`Failed to parse SSE message: ${t}`),Hi()}}),qi.addEventListener("inbox_messages",async t=>{try{const e=JSON.parse(t.data);i("SSE inbox messages received"),await O(e)}catch(t){i(`Failed to parse SSE inbox messages: ${t}`)}}),qi.addEventListener("error",async()=>{i("SSE error received"),Hi()}),qi.addEventListener("heartbeat",async()=>{i("SSE heartbeat received"),w.setActiveSSEConnection(),w.setUseSSEFlag(!0)})}()}()}),1e3)):i("User token not setup, queue not started.")}async function Ui(){if(po.config?.embedOnly)return;const t=await tn(),e=await un(),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 Bi(t)}async function Bi(t){if(t.queueId&&await async function(t){const e=await hn(t);return!!e&&null!==a(e)}(t.queueId))return i(`Not showing message with queueId ${t.queueId} because it is snoozed.`),!1;let e=V(t);if(e.hasRouteRule){if(null==po.currentRoute&&!po.routeInitialized)return i(`Deferring message ${t.queueId}, route not yet initialized`),!1;if(!st(e.routeRule))return i(`Route ${new URL(window.location.href).pathname} (currentRoute: ${po.currentRoute}) does not match rule: ${e.routeRule}`),!1}if(e.hasPosition&&(t.position=e.position),e.hasTooltipPosition&&(t.tooltipPosition=e.tooltipPosition),e.persistent||on(t)){const n=await async function(t){const e=await fn(t);return e?a(e):null}(t.queueId??"");if(n){const o=n.displaySettings?.pageUrl;if(o&&!at(o))return i(`Saved step for queueId ${t.queueId} belongs to page ${o}, not showing on ${new URL(window.location.href).pathname}`),!1;i(`Restoring saved state for queueId ${t.queueId}`),n.displaySettings&&(dt(t,n.displaySettings),e=V(t)),t.savedStepName=n.stepName??null}}if(t.savedStepName){const n=function(t,e){let n=null;return e.hasTooltipPosition||t.tooltipPosition?n=e.elementId||t.elementId:e.isInlineElement&&(n=e.elementId),!n||J.includes(n)?null:n}(t,e);if(n&&!T(n)&&(!po.config.isPreviewSession||!t.properties?.gist?.livePreview))return function(t,e){const n=t.queueId??"",o=new URL(window.location.href).pathname;Oi.has(n)||Wi.get(n)!==o&&(Oi.add(n),i(`Anchor "${e}" not present for saved step "${t.savedStepName}" of queueId ${n}, waiting up to ${zi}ms`),D(e,zi).then(async s=>{if(Oi.delete(n),s)return Wi.delete(n),i(`Anchor "${e}" appeared, re-checking message queue`),void await Ui();const a=new URL(window.location.href).pathname;a===o?(Wi.set(n,o),i(`Anchor "${e}" did not appear within ${zi}ms, tour step for queueId ${n} cannot continue on ${o}`),po.messageError(t)):i(`Anchor wait for "${e}" outlived ${o} (now on ${a}), ignoring`)}).catch(t=>{Oi.delete(n),i(`Anchor wait for "${e}" failed: ${t}`)}))}(t,n),!1}if(e.persistent||on(t)||!await async function(t){const e=await mn(t);return!!e&&null!==a(e)}(t.queueId??"")){let n=null;return e.isInlineElement?!po.config.isPreviewSession||!t.properties?.gist?.livePreview||T(e.elementId)||J.includes(e.elementId)?n=hi(t,e.elementId):(i(`Preview: element "${e.elementId}" not found, showing as overlay so placement can be changed`),n=await fi(t)):n=await fi(t),n&&async function(t){const e=await mn(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 Fi(){if(De())if(po.isDocumentVisible)if(null===a(Ce)){const t=await async function(){if($e)return;$e=!0;const t=De();let e;try{const t={"X-Gist-User-Anonymous":String(Te()),"Content-Language":String($())};e=await S().post(`/api/v4/users?sessionId=${ke()}`,{},{headers:t})}catch(t){const n=x(t);n?e=n:i(`Error getting user queue: ${t}`)}finally{$e=!1}return t!==De()?(i("User token changed, clearing queue next pull check."),void r(Ce)):(function(t){const e=t?.headers?.["x-gist-queue-polling-interval"];Ie=e&&Number(e)>0?Number(e):Math.min(2*Ie,600);const n=new Date((new Date).getTime()+1e3*Ie);s(Ce,Ie,n)}(e),function(t){const e="true"===t?.headers?.["x-cio-use-sse"]?.toLowerCase();w.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;w.setInboxEnabledFlag(n),n&&(i("Inbox enabled, ensuring branding and templates are cached."),await Se(),me())}(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??[];cn(n),Ze(n),O(o)}else 304===t.status&&i("304 response, using local store.");await Ui()}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 Hi(t=!1){t&&w.removeActiveSSEConnection(),(t||w.isSSEConnectionManagedBySDK())&&w.setUseSSEFlag(!1),qi&&(i("Stopping SSE queue listener..."),qi.close(),qi=null)}const Gi="gist-debug-overlay-styles";let Vi=null,Ji=!1,Xi=!1,Ki=null;function Qi(t){const e=t.properties?.gist;return rt(e?{...t,tooltipPosition:e.tooltipPosition??t.tooltipPosition,elementId:null!=e.elementId?String(e.elementId):t.elementId}:t)}function Yi(t,e,n=!1){const i=N("div",{className:"gist-debug-msg-row"});return i.appendChild(N("span",{className:"gist-debug-msg-key",textContent:t})),i.appendChild(N("span",{className:n?"gist-debug-msg-val gist-debug-val-error":"gist-debug-msg-val",textContent:e})),i}function Zi(t,e,n=!1){t.replaceChildren(...e.map(([t,e])=>Yi(t,e,n)))}function to(t,e){const n=N("div",{className:"gist-debug-msg"}),i=N("div",{className:"gist-debug-msg-meta"});if(i.appendChild(N("span",{className:"gist-debug-msg-type",textContent:Qi(t)})),i.appendChild(N("span",{className:`gist-debug-msg-state gist-debug-msg-state--${e}`,textContent:e})),t.instanceId){const e=N("button",{className:"gist-debug-msg-dismiss",textContent:"×"});e.addEventListener("click",()=>{io(),po.dismissMessage(t.instanceId).then(()=>{io(),oo()})}),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=Qi(t);if(i&&"overlay"===o){const t=function(t){if(t)return it[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=!st(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=!!T(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=Yi(e,i);t&&s&&a.appendChild(N("span",{className:t,textContent:s})),n.appendChild(a)}if(o.length>0){const t=N("ul",{className:"gist-debug-msg-details"});for(const e of o)t.appendChild(N("li",{textContent:e}));n.appendChild(t)}return n}function eo(t){const e=N("div",{className:"gist-debug-expand-detail"}),n=N("ul",{className:"gist-debug-expand-list"});return n.appendChild(N("li",{textContent:t})),e.appendChild(n),e}function no(){Vi&&(Vi.root.remove(),document.getElementById(Gi)?.remove(),null!==Ki&&(clearInterval(Ki),Ki=null),Ji&&(po.events&&(po.events.off("messageShown",so),po.events.off("messageDismissed",so),po.events.off("messageInboxUpdated",ao),po.events.off("routeChanged",so)),Ji=!1),Vi=null)}function io(){if(!Vi)return;po.config?Zi(Vi.configRows,[["Site ID",po.config.siteId],["Connection",w.useSSE()?"SSE":`Polling ${Ie}s`]]):Zi(Vi.configRows,[["Status","NOT INITIALIZED"]],!0),Vi.configDetail.style.display=po.config?"none":"";const t=De();t?Te()?Vi.userValue.textContent="(anonymous)":Vi.userValue.textContent=t.length>32?`${t.slice(0,32)}…`:t:Vi.userValue.textContent="(none)";const e=po.currentRoute;Vi.routeValue.replaceChildren(N("span",{className:e?"gist-debug-msg-val":"gist-debug-msg-val gist-debug-val-error",textContent:e??"NONE"})),Vi.routeDetail.style.display=e?"none":""}async function oo(){if(!Xi&&Vi){Xi=!0;try{const t=po.currentMessages??[],[e,n]=po.config?await Promise.all([un(),tn()]):[[],[]],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(!Vi)return;const a=t.length+s.length;Vi.messagesLabel.textContent=`Messages (${a})`,Vi.messagesList.replaceChildren(...t.map(t=>to(t,"active")),...s.map(t=>to(t,"queued")))}finally{Xi=!1}}}function so(){io(),oo()}function ao(){oo()}async function ro(){Ji||(!Ji&&po.events&&(po.events.on("messageShown",so),po.events.on("messageDismissed",so),po.events.on("messageInboxUpdated",ao),po.events.on("routeChanged",so),Ji=!0),Ji&&lo(5e3)),io(),await oo()}function lo(t){null!==Ki&&clearInterval(Ki),Ki=setInterval(()=>{ro()},t)}function co(){if("undefined"!=typeof window&&"true"===new URLSearchParams(window.location.search).get("cio_debug_session"))try{Vi||null!==Ki||(A(Gi,"\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"),Vi=function(){const t=N("div",{id:"gist-debug-overlay"}),e=N("div",{className:"gist-debug-header"});e.appendChild(N("span",{className:"gist-debug-title",textContent:"Customer.io In-App SDK Debugger"}));const n=N("button",{id:"gist-debug-overlay-close",ariaLabel:"Dismiss debug overlay",textContent:"×"});n.addEventListener("click",no),e.appendChild(n),t.appendChild(e);const i=N("div",{className:"gist-debug-section"}),o=N("div",{className:"gist-debug-label"});o.appendChild(N("span",{textContent:"Config"})),i.appendChild(o);const s=N("div",{});i.appendChild(s);const a=eo("Verify your site ID and credentials are correct.");i.appendChild(a),t.appendChild(i);const r=N("div",{className:"gist-debug-section"}),l=N("div",{className:"gist-debug-label",textContent:"User"});r.appendChild(l);const d=N("div",{className:"gist-debug-value"});r.appendChild(d),t.appendChild(r);const c=N("div",{className:"gist-debug-section"}),u=N("div",{className:"gist-debug-label"});u.appendChild(N("span",{textContent:"Route"})),c.appendChild(u);const p=N("div",{className:"gist-debug-value"});c.appendChild(p);const g=eo("The current route is used to match against potential message page rules.");c.appendChild(g),t.appendChild(c);const m=N("div",{className:"gist-debug-section"}),f=N("div",{className:"gist-debug-label"});m.appendChild(f);const h=N("div",{});return m.appendChild(h),t.appendChild(m),{root:t,configRows:s,configDetail:a,userValue:d,routeValue:p,routeDetail:g,messagesLabel:f,messagesList:h}}(),M(Vi.root),lo(2e3),ro())}catch(t){i(`Failed to initialize debug overlay: ${t}`)}}function uo(t){const e=[...new Set(t.map(t=>t.siteId).filter(Boolean))];return e.length>1&&console.warn(`Gist: embed payloads on this page declare different site ids (${e.join(", ")}); using "${e[0]}".`),e[0]??""}class po{static async setup(t){if(this.initialized)return this.config?.embedOnly&&!t.embedOnly&&console.warn("Gist: setup() was called after the SDK had already initialized in embed-only mode, so in-app delivery will not start. Call setup() before mounting embeds."),void 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,colorScheme:t.colorScheme??"default",embedOnly:t.embedOnly??!1},this.currentMessages=[],Mt.forEach(t=>t.cleanup()),Mt.clear(),document.querySelectorAll('[id^="gist-tooltip-"]').forEach(t=>{t.parentNode?.removeChild(t)}),this.overlayInstanceId=null,this.currentRoute=null,this.routeInitialized=!1,this.isDocumentVisible=!0,this.config.isPreviewSession=!this.config.embedOnly&&function(){const t=new URLSearchParams(window.location.search),e=t.get(In);if(e){sessionStorage.setItem(o,String(!1)),po.setUserToken(e),i(`Preview mode enabled with user token: ${e}`),function(){if(document.getElementById(jn))return;A(kn,xn);try{An="true"===sessionStorage.getItem(Cn)}catch{An=!1}const t=N("div",{id:jn});document.body.appendChild(t),oi()}();const n=t.get($n);if(n)try{const t=JSON.parse(atob(n)),e=t.stepName||null,i=t.displayType||null;(e||i)&&function(t,e){Un=t,Bn=e}(e,i)}catch{i("Preview bar: failed to parse cioPreviewSettings")}}return!l()}(),co(),function(){const t=d();for(let e=t.length-1;e>=0;e--){const n=t.key(e);n?.startsWith("gist.")&&c(n)}}(),this.config.embedOnly||async function(){w.inboxEnabled()&&(k()&&P()||(i("Inbox enabled but missing cached branding/templates, fetching."),await Se()),me())}(),"auto"===this.config.colorScheme&&St(),i(`Setup complete on ${this.config.env} environment${this.config.embedOnly?" in embed-only mode":""}.`),this.config.embedOnly||(this.config.isPreviewSession||!this.config.useAnonymousSession||new URLSearchParams(location.search).has("ajs_uid")||Ne(),await _i(),setTimeout(()=>{this.routeInitialized||(this.routeInitialized=!0,Ui())},2e3),document.addEventListener("visibilitychange",async()=>{"hidden"===document.visibilityState?this.isDocumentVisible=!1:(this.isDocumentVisible=!0,await Ui())},!1))}static setupDebugOverlay(){co()}static async setCurrentRoute(t){this.routeInitialized=!0,this.currentRoute=t,i(`Current route set to: ${t}`),await async function(){if(function(){const t=new URL(window.location.href).pathname;for(const[e,n]of Wi)n!==t&&Wi.delete(e)}(),0!==po.currentMessages.length)for(const t of[...po.currentMessages])null==document.querySelector(`#gist-${t.instanceId}`)&&(i(`Removing active message ${t.instanceId} that no longer exists after route change`),await yi(t))}(),await Ui(),this.events?.dispatch("routeChanged",t)}static async setUserToken(t,e){this.config.isPreviewSession||(this.config.embedOnly?i("Embed-only mode, ignoring user token."):(function(t,e){void 0===e&&(e=new Date).setDate(e.getDate()+30),s(je,t,e),Te()&&(r(Ce),r(Le)),i(`Set user token "${t}" with expiry date set to ${e}`)}(t,e),Hi(!0),await _i()))}static setUserLocale(t){var e;s(I,e=t),i(`Set user locate to "${e}"`)}static setColorScheme(t){this.config.colorScheme=t,function(){const t=po.config?.colorScheme;"auto"===t?St():xt&&(xt.disconnect(),xt=null);const e=wt(t);vt=e,It(e)}(),i(`Color scheme set to: ${t}`)}static setCustomAttribute(t,e){return function(t,e){return t&&"string"==typeof t?(ze.set(t,e),Oe(),i(`Set custom attribute "${t}" to "${e}"`),!0):(i(`Invalid key for custom attribute: ${t}`),!1)}(t,e)}static clearCustomAttributes(){ze.clear(),r(qe),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=ze.has(t);return ze.delete(t),ze.size>0?Oe():r(qe),i(`Removed custom attribute "${t}"`),e}(t)}static async clearUserToken(){this.config.isPreviewSession||(this.config.embedOnly?i("Embed-only mode, ignoring user token reset."):(Re(),he(),this.config.useAnonymousSession&&Ne(),Hi(!0),await _i()))}static async dismissMessage(t){const e=Q(t);if(e&&gi(t))try{await wi(e),await Ai(e),await bi(e),await Ui()}finally{mi(t)}}static async embedMessage(t,e){const n=hi(t,e);return n?.instanceId??null}static async embed(t){return this.initialized||await this.setup({siteId:t.siteId??"",embedOnly:!0}),Ke(t)}static async mountEmbeds(){const t=[...document.querySelectorAll(Ue)].map(Qe).filter(t=>null!==t);return 0===t.length?[]:(this.initialized||await this.setup({siteId:uo(t),embedOnly:!0}),async function(t){return i(`Rendering ${t.length} embed(s).`),(await Promise.all(t.map(t=>Ke(t)))).filter(t=>null!==t)}(t))}static resetEmbed(t){!function(t){Je(e=>{delete e.hidden[t]}),Be.delete(t),Fe.delete(t),i(`Embed ${t} state cleared.`)}(t)}static async showMessage(t){const e=await fi(t);return e?.instanceId??null}static updateMessageDisplaySettings(t,e){const n=Q(t);return!!n&&(n.displaySettings=e,Pt(n),!0)}static messageShown(t){i(`Message shown: ${t.messageId}`),this.events.dispatch("messageShown",t)}static messageDismissed(t,e="dismissed"){null!==t&&(i(`Message dismissed: ${t.messageId} (${e})`),this.events.dispatch("messageDismissed",{...t,dismissReason:e}))}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 W()).filter(t=>!t.opened).length}static async getInboxMessages(){return await W()}static async updateInboxMessageOpenState(t,e){return await _(t,e)}static async removeInboxMessage(t){return await U(t)}static isInboxEnabled(){return w.inboxEnabled()}}let go=po;if("undefined"!=typeof window){const t=window;t.__gistWebLoaded?(console.warn("Gist: the SDK has been loaded more than once on this page; check for duplicate snippets or bundles."),t.Gist&&(go=t.Gist)):(t.__gistWebLoaded=!0,co())}const mo=go;return 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:()=>_o});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){Wo.config&&Wo.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};c().setItem(t,JSON.stringify(o))}function a(t){return d(t)}function r(t){c().removeItem(t)}function l(){const t=sessionStorage.getItem(o);return null===t?(sessionStorage.setItem(o,"true"),!0):"true"===t}function c(){return l()?localStorage:sessionStorage}function d(t){if(!t)return null;try{const e=c().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")&&!t.endsWith("snoozed"),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}const u=new Uint8Array(16),p=[];for(let t=0;t<256;++t)p.push((t+256).toString(16).slice(1));const g=function(t,e,n){return e||t||!crypto.randomUUID?function(t,e,n){const i=(t=t||{}).random??t.rng?.()??crypto.getRandomValues(u);if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,e){if((n=n||0)<0||n+16>e.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let t=0;t<16;++t)e[n+t]=i[t];return e}return function(t,e=0){return(p[t[e+0]]+p[t[e+1]]+p[t[e+2]]+p[t[e+3]]+"-"+p[t[e+4]]+p[t[e+5]]+"-"+p[t[e+6]]+p[t[e+7]]+"-"+p[t[e+8]]+p[t[e+9]]+"-"+p[t[e+10]]+p[t[e+11]]+p[t[e+12]]+p[t[e+13]]+p[t[e+14]]+p[t[e+15]]).toLowerCase()}(i)}(t,e,n):crypto.randomUUID()},m="gist.web.inbox.enabled",f="gist.web.userQueueUseSSE",h="gist.web.activeSSEConnection";let b,y=30;const w={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:()=>(b||(b=g()),b),useSSE:()=>a(f)??!1,setUseSSEFlag(t){s(f,t,new Date((new Date).getTime()+6e4)),i(`Set user uses SSE to "${t}"`)},removeActiveSSEConnection(){r(h)},setActiveSSEConnection(){s(h,w.getSdkId(),new Date((new Date).getTime()+w.getSSEHeartbeat()))},hasActiveSSEConnection:()=>a(h)??!1,isSSEConnectionManagedBySDK:()=>a(h)===w.getSdkId(),getSSEHeartbeat:()=>1e3*(y+5),setSSEHeartbeat(t){t&&t>0&&(y=t)},inboxEnabled:()=>a(m)??!1,setInboxEnabledFlag(t){s(m,t,new Date((new Date).getTime()+36e5)),i(`Set inbox enabled to "${t}"`)}};function v(t){return null!==t&&"object"==typeof t&&"response"in t}function x(t){return v(t)?t.response:void 0}function S(){const t=w.GIST_QUEUE_API_ENDPOINT[Wo.config.env??"prod"],e={"X-CIO-Site-Id":Wo.config.siteId,"X-CIO-Client-Platform":"web"},n=cn();null!=n&&(e["X-Gist-Encoded-User-Token"]=n);const i=Qe();async function o(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=Object.fromEntries(t.headers.entries()),r=t.status<200||t.status>=400,l=t.headers.get("content-type")?.includes("application/json");let c;try{c=l?await t.json():await t.text()}catch(t){if(!r)throw t}if(r)throw function(t){return Object.assign(new Error,{response:t})}({status:t.status,data:c,headers:n});return{status:t.status,headers:n,data:c}}catch(t){if(clearTimeout(a),v(t))throw t;if(t instanceof Error)throw Object.assign(t,{response:{status:0,data:t.message||"Unknown error",headers:{}}});throw t}}return null!==i&&(e["X-CIO-User-JWT"]=i),o.post=(t,e={},n={})=>o(t,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json",...n.headers||{}}}),o}const I=new Set;let $=null,C=!1,k=null,E=null,j=!1,L=!1,T=null;const P=new Set;function D(){C=!1,k=null,L=!1,T=null,P.clear()}function N(){null!==Qe()&&Ye(),$=null,D()}function A(){return{userToken:sn(),userJwt:Qe()}}function M(t,e){if(401!==t?.status)return!1;const n=A();if(e.userToken!==n.userToken||e.userJwt!==n.userJwt)return!1;if(L&&e.userToken!==E&&D(),C=!0,k=e.userJwt,E=e.userToken,L=!0,P.has(e.userJwt))return i("User JWT rejected again, queue fetches stay paused."),!0;P.add(e.userJwt);const o={},s=function(t){if(null===t||"object"!=typeof t)return;const e=t.reason;return"string"==typeof e?e:void 0}(t.data);return void 0!==s&&(o.reason=s),i(`User JWT rejected (${s??"no reason"}), queue fetches paused.`),Wo.events?.dispatch("userJwtRejected",o),!0}const q="gist.web.userLocale";function R(){const t=a(q);return null!==t?t:navigator.language}const O="gist.web.branding";async function z(){if(null!==a(O))return void i("Branding already cached.");const t=await async function(){try{return await S()("/api/v1/branding")}catch(t){return x(t)}}();if(t&&t.status>=200&&t.status<300){const e=new Date;e.setMinutes(e.getMinutes()+10),s(O,t.data,e),i("Branding fetched and cached.")}}function W(){return a(O)}const U="gist.web.templates";async function _(){if(null!==a(U))return void i("Templates already cached.");const t=await async function(){try{return await S()("/api/v1/templates")}catch(t){return x(t)}}();if(t&&t.status>=200&&t.status<300){const e=new Date;e.setMinutes(e.getMinutes()+60),s(U,t.data,e),i("Templates fetched and cached.")}}function B(){return a(U)}function F(t){try{return(document.getElementById(t)??document.querySelector(t))||null}catch{return null}}function H(t,e){const n=F(t);return n?Promise.resolve(n):new Promise(n=>{const i=new MutationObserver(()=>{const e=F(t);e&&(clearTimeout(o),i.disconnect(),n(e))}),o=setTimeout(()=>{i.disconnect(),n(null)},e);i.observe(document.documentElement,{childList:!0,subtree:!0})})}function J(t,e={}){const n=document.createElement(t);for(const[t,i]of Object.entries(e))n[t]=i;return n}function V(t,e){if(document.getElementById(t))return;const n=document.createElement("style");n.id=t,n.textContent=e,document.head.appendChild(n)}function G(t){document.body?document.body.appendChild(t):document.addEventListener("DOMContentLoaded",()=>document.body.appendChild(t),{once:!0})}async function X(t){const e=A();try{return await S().post(`/api/v1/logs/queue/${t}`)}catch(t){const n=x(t);return M(n,e),n}}const K="messageInboxUpdated",Q="inboxMessageAction";async function Y(t){const e=await nt();if(!e)return;const n=new Date;n.setMinutes(n.getMinutes()+60),s(e,t,n),Wo.events.dispatch(K,t)}async function Z(){const t=await nt();if(!t)return[];const e=a(t)??[],n=new Date;return e.filter(t=>!t.expiry||new Date(t.expiry)>n)}async function tt(t,e){const n=await nt();if(!n)return;const o=await async function(t,e){const n=A();try{return await S()(`/api/v1/messages/${t}`,{method:"PATCH",body:JSON.stringify(e),headers:{"Content-Type":"application/json"}})}catch(t){const e=x(t);return M(e,n),e}}(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 Z();let r=null;const l=a.map(n=>{if(n.queueId===t){const t={...n,opened:e};return r=t,t}return n}),c=new Date;if(c.setMinutes(c.getMinutes()+60),s(n,l,c),r){const t=e?"opened":"unopened";Wo.events.dispatch(Q,{message:r,action:t})}Wo.events.dispatch(K,await Z())}async function et(t){const e=await nt();if(!e)return;const n=await Z(),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&&Wo.events.dispatch(Q,{message:o,action:"dismissed"}),Wo.events.dispatch(K,await Z());const l=await X(t);(!l||l.status<200||l.status>=300)&&i(`Failed to log inbox message view: ${l?.status??"unknown error"}`)}async function nt(){const t=await ln();return t?`gist.web.inbox.messages.${t}`:null}const it=["always","untilDismissed","onceEver"],ot={isInlineElement:!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,isEmbed:!1,embedFrequency:"always",embedLogView:!1};function st(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 at(t){const e=ot,n=t?.properties?.gist,o=!!t?.embedId;if(!n)return{...e,isEmbed:o};const s=n.embed;return{isInlineElement:!!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:st(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,isEmbed:o,embedFrequency:(a=s?.frequency,r=e.embedFrequency,void 0===a?r:it.includes(a)?a:(i(`Unknown embed frequency "${String(a)}", falling back to "${r}".`),r)),embedLogView:!!s?.logView};var a,r}const rt=["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 lt(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 ct=["x-gist-top","x-gist-bottom","x-gist-floating-top","x-gist-floating-bottom"];function dt(t){return Wo.currentMessages.find(e=>e.instanceId===t)}function ut(t){return!!t&&Wo.currentMessages.some(e=>e.queueId===t)}function pt(t){return t?Wo.currentMessages.find(e=>e.elementId===t)??null:null}function gt(t){Wo.currentMessages=Wo.currentMessages.filter(e=>e.instanceId!==t)}function mt(t,e){gt(t),Wo.currentMessages.push(e)}const ft={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"},ht=Object.fromEntries(Object.entries(ft).map(([t,e])=>[e,t]));function bt(t){return t&&ft[t]?ft[t]:(i(`Invalid overlay position "${t}", defaulting to "topCenter"`),ft.topCenter)}function yt(t){try{const e=new RegExp(t),n=new URL(window.location.href).pathname,i=null!=Wo.currentRoute&&e.test(Wo.currentRoute),o=Wo.currentRoute!==n&&e.test(n);return i||o}catch{return!1}}function wt(t){try{return(new URL(t,window.location.href).pathname.replace(/\/+$/,"")||"/")===(new URL(window.location.href).pathname.replace(/\/+$/,"")||"/")}catch{return!0}}function vt(t){return t.tooltipPosition?"tooltip":t.overlay?"modal":t.elementId&&rt.includes(t.elementId)?"overlay":t.elementId?"inline":"modal"}function xt(t,e){const n=vt(t),i=e.displayType;if(void 0===i)return!1;if(n!==i)return!0;const o=at(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=bt(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||!ct.includes(bt(e.overlayPosition))){const t=e.maxWidth??ot.messageWidth;if(o.messageWidth!==t)return!0}return!1}function St(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=bt(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&&ct.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 It={top:["bottom","left","right"],bottom:["top","left","right"],left:["right","top","bottom"],right:["left","top","bottom"]},$t=/auto|scroll/,Ct={top:"gist-arrow-bottom",bottom:"gist-arrow-top",left:"gist-arrow-right",right:"gist-arrow-left"};function kt(t){const e=F(t);return e||i(`Tooltip target element not found for selector: ${t}`),e}function Et(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 jt(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 Lt(t,e,n){const i=jt(t,e,n);if(i)return i;for(const i of It[n]){const n=jt(t,e,i);if(n)return n}return null}function Tt(t){const e=[];let n=t.parentElement;for(;n;){const t=getComputedStyle(n),i=t.overflow+t.overflowX+t.overflowY;$t.test(i)&&e.push(n),n=n.parentElement}return e}function Pt(t){return"system"===t||"auto"===t?"normal":"light only"}function Dt(t){if(!t||"default"===t)return"light";if("system"===t)return;const e=function(){const t=getComputedStyle(document.documentElement).colorScheme;if(t&&"normal"!==t)return t;if(document.body){const t=getComputedStyle(document.body).colorScheme;if(t&&"normal"!==t)return t}}();return e?function(t){const e=t.includes("dark"),n=t.includes("light");if(!e||!n)return e?"dark":n?"light":void 0}(e):void 0}let Nt,At=null;function Mt(){At||(Nt=Dt(Wo.config?.colorScheme),At=new MutationObserver(()=>{const t=Dt(Wo.config?.colorScheme);t!==Nt&&(Nt=t,qt(t))}),At.observe(document.documentElement,{attributes:!0,attributeFilter:["style","class"]}),document.body&&At.observe(document.body,{attributes:!0,attributeFilter:["style","class"]}))}function qt(t){const e=t??"normal",n=Pt(Wo.config?.colorScheme);for(const i of Wo.currentMessages??[]){Kt(i.instanceId??"",t);const o=te(i.instanceId??""),s=document.getElementById(o);s&&(s.style.colorScheme=n,s.contentWindow&&s.contentWindow.postMessage({action:"updateColorScheme",colorScheme:e},"*"))}Wo.events?.dispatch("colorSchemeChanged",t)}function Rt(t){const e=F(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 Ot(t){const e=F(t);if(e)return!(!e.style||!e.style.height||"0px"===e.style.height)}function zt(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){n&&(e.stepId=n);const t=Dt(Wo.config?.colorScheme);t&&(e.colorScheme=t);const o={options:e,capabilities:_t(e)};i.contentWindow.postMessage(o,"*")}}(t,e,n)})}const Wt=["MultiStepDisplayTypes","CrossPageStepNavigation","Snooze","TooltipShadow"],Ut=["Snooze"];function _t(t){return t.isEmbed?Ut:Wt}function Bt(t){if(!t.displaySettings)return;const e=te(t.instanceId??""),n=document.getElementById(e);n?.contentWindow&&n.contentWindow.postMessage({action:"updateDisplaySettings",displaySettings:t.displaySettings},"*")}let Ft=null;function Ht(){Ft&&(document.removeEventListener("keydown",Ft),Ft=null)}async function Jt(){const t=document.querySelector(".gist-message");t&&(t.classList.remove("gist-visible"),await new Promise(t=>setTimeout(t,300))),Vt()}function Vt(){Ht();const t=document.querySelector("#gist-embed-message");t&&t.parentNode?.removeChild(t)}const Gt=new Map;function Xt(t){return document.querySelector(`#gist-tooltip-${t} .gist-tooltip-container`)}function Kt(t,e){Xt(t)?.style.setProperty("color-scheme",e??"light dark")}const Qt=[["tooltipArrowColor","--gist-tooltip-arrow-color"],["tooltipArrowColorDark","--gist-tooltip-arrow-color-dark"],["tooltipShadow","--gist-tooltip-shadow"]];function Yt(t,e){const n=t.instanceId??"",i=Xt(n);if(i){if(e)for(const[t,n]of Qt){const o=e[t];"string"==typeof o&&o?i.style.setProperty(n,o):i.style.removeProperty(n)}Kt(n,Dt(Wo.config?.colorScheme))}}function Zt(t){const e=t.instanceId??"",n=Gt.get(e);n&&(n.cleanup(),Gt.delete(e));const i=F(`gist-tooltip-${e}`);i&&i.parentNode?.removeChild(i)}function te(t){return`gist-${t}`}function ee(){const t=document.querySelector(".gist-message");t&&t.classList.add("gist-visible")}const ne="jist",ie={start:"flex-start",end:"flex-end",center:"center",stretch:"stretch",baseline:"baseline"},oe={start:"flex-start",end:"flex-end",center:"center","space-between":"space-between","space-around":"space-around","space-evenly":"space-evenly"};function se(t){return"number"==typeof t?`${t}px`:"fill"===t?"100%":t}function ae(t){try{return new Date(t).toLocaleDateString(navigator.language)}catch{return t}}class re{#t;#e;#n;#i=0;constructor({formatDate:t,onAction:e,templates:n}={}){this.#t=t||ae,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.#c(t,e);case"image":return this.#d(t,e);case"dynamicLayout":return this.#u(t,e);case"template":return this.#p(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=se(t.gap)),t.align&&(n.style.alignItems=ie[t.align]||t.align),t.justify&&(n.style.justifyContent=oe[t.justify]||t.justify),t.margin&&(t.margin.top&&(n.style.marginTop=se(t.margin.top)),t.margin.right&&(n.style.marginRight=se(t.margin.right)),t.margin.bottom&&(n.style.marginBottom=se(t.margin.bottom)),t.margin.left&&(n.style.marginLeft=se(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}#c(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}#d(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=se(t.width)),t.height&&(s.style.height=se(t.height)),t.objectFit&&(s.style.objectFit=t.objectFit),t.borderRadius&&(s.style.borderRadius=se(t.borderRadius)),o.appendChild(s),o}#u(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=se(t.gap)),t.align&&(i.style.alignItems=ie[t.align]||t.align),t.justify&&(i.style.justifyContent=oe[t.justify]||t.justify),t.margin&&(t.margin.top&&(i.style.marginTop=se(t.margin.top)),t.margin.right&&(i.style.marginRight=se(t.margin.right)),t.margin.bottom&&(i.style.marginBottom=se(t.margin.bottom)),t.margin.left&&(i.style.marginLeft=se(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}#p(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(`${ne}__${e}`),i&&t.classList.add(`${ne}__${e}--${i}`),n!==e&&t.classList.add(`${ne}__${n}`)}}var le;const ce="jist-template",de=["template","data","theme","mode","formatDate","onAction","templates"],ue=new Set(["fontWeight","maxLines","lineHeight","opacity"]),pe=new Set(["lineHeight","letterSpacing"]),ge={"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"},me=["shadow-offset-x","shadow-offset-y","shadow-blur","shadow-color"],fe={"shadow-offset-x":"0","shadow-offset-y":"0","shadow-blur":"0","shadow-color":"transparent"},he={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"])},be=["hover","active","disabled"],ye=[["background-color","background-color"],["color","text-color"]];class we extends HTMLElement{static observedAttributes=["template","data","theme","mode"];static#m=!1;static#f=null;static#h=0;static#b=new Map;static#y(){if(le.#m)return;if(le.#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)}#w=null;#v=null;#x=null;#S=null;#I="auto";#t=null;#e=null;#n={};#$=null;#C=null;get template(){return this.#v}set template(t){this.#v=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(){le.#y(),this.#$=window.matchMedia("(prefers-color-scheme: dark)"),this.#C=()=>{"auto"===this.#I&&(this.#E(),this.#k())},this.#$.addEventListener("change",this.#C);for(const t of de)this.#j(t);this.#E(),this.#k()}#j(t){if(!Object.prototype.hasOwnProperty.call(this,t))return;const e=this,n=e[t];delete e[t],e[t]=n}disconnectedCallback(){this.#$&&this.#C&&this.#$.removeEventListener("change",this.#C),this.#L(),le.#T()}attributeChangedCallback(t,e,n){if(e!==n)switch(t){case"template":this.#v=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()}}#P(){return"dark"===this.#I||"light"!==this.#I&&(this.#$?.matches??!1)}#E(){if(!this.isConnected)return void(this.#S||(this.#L(),le.#T()));if(this.#P()?this.setAttribute("data-jist-dark",""):this.removeAttribute("data-jist-dark"),!this.#S)return this.#L(),void le.#T();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.#D(this.#S,"--jist"),this.#P()){const t=this.#S.modes?.dark;t&&this.#D(t,"--jist")}this.#N()}#D(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&&pe.has(n)?"normal":"number"!=typeof i||ue.has(n)?String(i):`${i}px`;this.style.setProperty(t,e)}}else this.#D(i,t)}}#N(){const t=[],e=this.#S;if(!e)return;const n=e.modes?.dark;for(const i of Object.keys(he)){const o=e[i],s=n?.[i],a=he[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.#A(i,e,n,a))}}const i=t.join("\n");if(this.#L(),!i)return;let o=le.#b.get(i);o||(o={id:le.#h++,refs:0},le.#b.set(i,o)),o.refs++,this.#w=i,this.setAttribute("data-jist-v",String(o.id)),le.#T()}#L(){if(!this.#w)return;const t=le.#b.get(this.#w);t&&(t.refs--,t.refs<=0&&le.#b.delete(this.#w)),this.#w=null,this.removeAttribute("data-jist-v")}static#T(){if(0===le.#b.size)return void(le.#f&&(le.#f.remove(),le.#f=null));le.#f||(le.#f=document.createElement("style"),le.#f.setAttribute("data-jist-variants",""),document.head.appendChild(le.#f));const t=[];for(const[e,{id:n}]of le.#b){const i=`[data-jist-v="${n}"]`;t.push(e.replace(/^(\.[a-z_-]+)/gm,`${i} $1`))}le.#f.textContent=t.join("\n")}#A(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=ge[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=me.map(t=>`var(--jist-button-${o}-${t}, var(--jist-button-${t}, ${fe[t]}))`);l.push(` box-shadow: ${t.join(" ")};`)}let c=`${s} {\n${l.join("\n")}\n}`;if("button"===t&&(n.states||i.states))for(const t of be){const e=n.states?.[t],a=i.states?.[t];if(!e&&!a)continue;const r=[];for(const[e,n]of ye){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}))));`)}c+=`\n${s}${"disabled"===t?":disabled":`:${t}`} {\n${r.join("\n")}\n}`}return c}#k(){if(!this.#v||!this.#x)return;if(!this.isConnected)return;const t=this.#n[this.#v];if(!t)return void(this.innerHTML="");const e=new re({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)}}le=we;const ve="gist-inbox-button",xe="gist-inbox-badge",Se="gist-inbox-panel",Ie="gist-inbox-messages";let $e=!1,Ce=!1;const ke=new Set;let Ee=null,je=null;function Le(t,e){const n={...t},i=e;for(const t of Object.keys(i)){const e=n[t],o=i[t];null==e||"object"!=typeof e||Array.isArray(e)||null==o||"object"!=typeof o||Array.isArray(o)?void 0!==o&&(n[t]=o):n[t]=Le(e,o)}return n}function Te(t,e){const n=t?.patterns?.inbox;if(!n)return null;const i=t?.patterns?.modes?.dark?.inbox;return("dark"===e||null==e&&Ee?.matches)&&i?Le(n,i):n}function Pe(){$e||($e=!0,function(){const t=customElements.get(ce);t?t!==we&&console.warn("[jist] <jist-template> is already registered by another copy or version of the library; keeping the first registration."):customElements.define(ce,we)}(),V("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-button svg [fill]:not([fill="none"]) {\n fill: currentColor;\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@media (max-width: 424px) {\n #gist-inbox-panel {\n width: auto !important;\n left: 12px !important;\n right: 12px !important;\n }\n}\n'),Wo.events.on("messageInboxUpdated",t=>{De(t)}),Wo.events.on("colorSchemeChanged",()=>{De()}),Ee=window.matchMedia("(prefers-color-scheme: dark)"),je=()=>{"system"===Wo.config?.colorScheme&&De()},Ee.addEventListener("change",je),De())}async function De(t){t||(t=await Z());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 Ne();let n=W();n||(await ze(),n=W());const o=Dt(Wo.config?.colorScheme),s=Te(n,o);if(s){if(function(t,e){let n=document.getElementById(ve);n||(n=J("div",{id:ve}),n.addEventListener("click",()=>{Ce?(Ce=!1,document.getElementById(Se)?.classList.remove("gist-inbox-panel--open")):(Ce=!0,De())}),G(n));const i=Oe(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(xe);if(0===n||!e.unreadIndicator.showAlert)return void i?.remove();i||(i=J("span",{id:xe}),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)}(s,e),Ce){!function(t,e,n,o){let s=document.getElementById(Se);const a=!s;a&&(s=J("div",{id:Se}),G(s));const r=Oe(t.position,!0);s.style.background=t.background,s.style.borderRadius=`${t.cornerRadius}px`,s.style.border=`1px solid ${t.borderColor}`,s.style.boxShadow=`${t.shadow.offsetX}px ${t.shadow.offsetY}px ${t.shadow.blur}px ${t.shadow.color}`,Object.assign(s.style,r);let l=document.getElementById(Ie);l||(l=J("div",{id:Ie}),s.appendChild(l)),l.innerHTML="";const c=B();e.forEach((s,a)=>{const r=J("div",{className:"gist-inbox-message-row"});r.style.padding="12px 16px",r.style.cursor="pointer",r.addEventListener("mouseenter",()=>{r.style.background=t.hoverBackground}),r.addEventListener("mouseleave",()=>{r.style.background=""});const d=document.createElement("jist-template");r.appendChild(d),l.appendChild(r);const u=d;if(u.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&&et(t.queueId),Wo.events.dispatch("inboxMessageAction",{message:t,action:"clicked",actionConfig:e})}(s,e)},c&&(u.templates=c),n?.theme&&(u.theme=n.theme),u.mode=o,u.formatDate=Re,u.data=s.properties??{},u.template=s.type??null,a<e.length-1){const e=J("div",{className:"gist-inbox-divider"});e.style.height="1px",e.style.background=t.dividerColor,e.style.margin="0",l.appendChild(e)}}),a?requestAnimationFrame(()=>{s.classList.add("gist-inbox-panel--open")}):s.classList.add("gist-inbox-panel--open")}(s,e,n,o??"auto");for(const t of e){const e=t.queueId;t.opened||!e||ke.has(e)||(ke.add(e),tt(e,!0).finally(()=>{ke.delete(e)}))}}}else Ne()}function Ne(){document.getElementById(ve)?.remove(),document.getElementById(Se)?.remove(),Ce=!1}const Ae=[[60,"second",1],[3600,"minute",60],[86400,"hour",3600],[2592e3,"day",86400],[31536e3,"month",2592e3],[1/0,"year",31536e3]];let Me=null,qe=null;function Re(t){const e=Math.round((Date.now()-new Date(t).getTime())/1e3);if(Number.isNaN(e))return t;const[,n,i]=Ae.find(([t])=>Math.abs(e)<t);return function(){const t=R();return Me&&qe===t||(qe=t,Me=new Intl.RelativeTimeFormat(t,{numeric:"auto"})),Me}().format(-Math.round(e/i),n)}function Oe(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 ze(){await Promise.all([z(),_()])}let We=600,Ue=!1;const _e="gist.web.userQueueNextPullCheck",Be="gist.web.sessionId";function Fe(){let t=a(Be);return t||(t=g()),s(Be,t,new Date((new Date).getTime()+18e5)),String(t)}function He(){return We}const Je="gist.web.userToken",Ve="gist.web.usingGuestUserToken",Ge="gist.web.guestUserToken",Xe="gist.web.userJwt",Ke=30;function Qe(){const t=a(Xe);return"string"==typeof t&&""!==t?t:null}function Ye(){r(Xe)}function Ze(){const t=Qe();return null===t?null:function(t){const e=t.split(".");if(3!==e.length)return null;try{const t=atob(e[1].replace(/-/g,"+").replace(/_/g,"/")),n=(new TextDecoder).decode(Uint8Array.from(t,t=>t.charCodeAt(0))),i=JSON.parse(n)?.sub;return"string"==typeof i&&""!==i&&function(t){for(let e=0;e<t.length;e+=1)if(t.charCodeAt(e)>255)return!1;return!0}(i)?i:null}catch{return null}}(t)}function tn(){return null!==Ze()}function en(){return a(Je)}function nn(){return null!==a(Ve)}function on(){return!tn()&&nn()}function sn(){return Ze()??en()}function an(t,e){const n=en(),o=nn();return void 0===e&&(e=new Date).setDate(e.getDate()+Ke),s(Je,t,e),o&&(r(_e),r(Ve)),i(`Set user token "${t}" with expiry date set to ${e}`),o||n!==t}function rn(){if(null===en()){let t=a(Ge);null==t&&(t=g(),s(Ge,t),i(`Set guest user token "${t}" with expiry date set to 1 year from today`)),s(Je,t),s(Ve,!0),i(`Using anonymous session with token: "${t}"`)}}async function ln(){const t=sn();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 cn(){const t=sn();return null===t?null:btoa(t)}function dn(){r(Je),Ye(),i("Cleared user token")}const un="gist.web.customAttributes";let pn=new Map;function gn(){const t=Array.from(pn.entries()),e=new Date;e.setDate(e.getDate()+30),s(un,t,e),i(`Saved ${pn.size} custom attributes to storage with TTL of 30 days`)}!function(){const t=a(un);if(t)try{pn=new Map(t)}catch{pn=new Map}else pn=new Map}();const mn="gist.web.embeds",fn="data-cio-embed-payload",hn=`script[type="application/json"][${fn}]`,bn=new Set,yn=new Set;let wn=!1;function vn(){const t=a(mn);if(!t)return null;const e=Date.now(),n={};for(const[i,o]of Object.entries(t.hidden??{}))(!0===o||"number"==typeof o&&o>e)&&(n[i]=o);return{hidden:n}}function xn(t){try{s(mn,t)}catch(t){i(`Embed ${mn} state could not be persisted: ${t}`)}wn=!0}function Sn(t){const e=vn()??{hidden:{}};t(e),xn(e)}function In(t){t.embedId&&bn.delete(t.embedId)}async function $n(t){const e=t?.embedId,n=t?.message;if(!e||!n?.messageId)return i("Embed payload is missing an embedId or message, skipping."),null;if(!n.properties?.gist?.encodedMessageHtml)return i(`Embed ${e} payload has no message html, skipping.`),null;if(bn.has(e))return i(`Embed ${e} has already been rendered on this page.`),null;if(n.embedId=e,t.display&&(n.properties.gist.embed={...t.display,...n.properties.gist.embed}),n.overlay=!1,n.tooltipPosition=void 0,n.position=null,delete n.properties.gist.tooltipPosition,delete n.properties.gist.position,!function(t){return!yn.has(t)&&void 0===function(){const t=vn();return t?(wn||xn(t),t):{hidden:{}}}().hidden[t]}(e))return i(`Embed ${e} is suppressed by its stored state.`),null;const o=t.target||function(t){return`[data-cio-embed="${t}"]`}(e);bn.add(e);let s=!1;try{if(!await H(o,1e4))return i(`Embed ${e} target "${o}" never appeared, skipping.`),null;if(function(t){const e=F(t);return!!e?.querySelector(".gist-frame")}(o))return i(`Embed ${e} target "${o}" already holds a message, skipping.`),null;const t=Bi(n,o);return t?(s=!0,t.instanceId??null):null}catch(t){return i(`Embed ${e} failed to render: ${t}`),null}finally{s||bn.delete(e)}}function Cn(t){const e=t.getAttribute(fn)??"";try{const n=JSON.parse(t.textContent??"");return e&&!n.embedId&&(n.embedId=e),n}catch(t){return i(`Embed payload ${e||"(unnamed)"} could not be parsed: ${t}`),null}}const kn="gist.web.message.broadcasts";async function En(t){const e=await Dn();if(!e)return;const n=new Date;n.setMinutes(n.getMinutes()+60),s(e,t.filter(Tn),n)}async function jn(){const t=await Dn();return t?(a(t)??[]).filter(e=>{const n=e.properties.gist.broadcast,{frequency:i}=n,o=a(An(t,e.queueId))??!0,s=a(Nn(t,e.queueId))||0,r=0===i.count;return o&&(r||s<i.count)}):[]}async function Ln(t,e){const n=a(t);return n?.find(t=>t.queueId===e)}function Tn(t){return!(!t.properties?.gist||!t.properties.gist.broadcast)}function Pn(t){if(!Tn(t))return!1;const e=t.properties.gist.broadcast;return 0===e.frequency.delay&&0===e.frequency.count}async function Dn(){const t=await ln();return t?`${kn}.${t}`:null}function Nn(t,e){return`${t}.${e}.numberOfTimesShown`}function An(t,e){return`${t}.${e}.shouldShow`}const Mn="gist.web.message.user",qn=43200;async function Rn(t){const e=await zn();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 On(){const t=await zn();if(!t)return[];const e=a(t)??[],n=await async function(){const t=await Wn();return t?a(t)??[]:[]}();return e.filter(t=>!n.includes(t.queueId??""))}async function zn(){const t=await ln();return t?`${Mn}.${t}`:null}async function Wn(){const t=await ln();return t?`${Mn}.${t}.seen`:null}async function Un(t){const e=await ln();return e?`${Mn}.${e}.message.${t}.loading`:null}async function _n(t){const e=await ln();return e?`${Mn}.${e}.message.${t}.state`:null}async function Bn(t){const e=await ln();return e?`${Mn}.${e}.message.${t}.snoozed`:null}async function Fn(t,e,n){const o=await _n(t);if(!o)return;const r=a(o)||{},l={stepName:void 0!==e?e:r.stepName,displaySettings:void 0!==n?n:r.displaySettings},c=new Date;c.setDate(c.getDate()+30),s(o,l,c),i(`Saved message state for queueId: ${t}`)}async function Hn(t){const e=await _n(t);e&&(r(e),i(`Cleared message state for queueId: ${t}`))}const Jn="M3.54223 5.33301L7.7089 9.33301L11.8756 5.33301L12.6121 6.04011L7.7089 10.7472L2.80566 6.04011L3.54223 5.33301Z";function Vn(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="${Jn}" fill="${t}"/></svg>`}const Gn=`\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(Vn("#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`;async function Xn(t,e){try{return await S()(`/api/v1/preview/${t}`,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json"}})}catch(t){return x(t)}}const Kn="cioPreviewId",Qn="cioPreviewSettings";const Yn="gist.previewBar.collapsed",Zn="gist.previewBar.steps",ti="gist-pb-styles",ei="gist-preview-bar",ni={topLeft:"Top Left",topCenter:"Top Center",topRight:"Top Right",bottomLeft:"Bottom Left",bottomCenter:"Bottom Center",bottomRight:"Bottom Right"};let ii=null,oi=[],si={},ai=null,ri=!1,li=!1,ci=5,di=null,ui=!0,pi=!1,gi=!1,mi=null,fi=null,hi=null;const bi=new Map;function yi(t,e){const n=J("div",{className:"gist-pb-label-group"});return n.appendChild(J("span",{className:"gist-pb-label",textContent:t})),n.appendChild(e),n}function wi(t,e){const n=J("select",{className:"gist-pb-select"});for(const i of t){const t=J("option",{value:i.value,textContent:i.label});i.value===e&&(t.selected=!0),n.appendChild(t)}return n}function vi(t,e,n){const i=J("input",{className:"gist-pb-input",type:t,value:String(e)});return n&&(i.style.width=n),i}function xi(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 Si(t){return!!("inline"!==t.displayType&&"tooltip"!==t.displayType||t.elementSelector?.trim())}function Ii(t){if("overlay"===t.displayType&&ct.includes(bt(t.overlayPosition))){const{maxWidth:e,...n}=t;t=n}if(si=t,ai){const e=oi.findIndex(t=>t.stepName===ai);-1!==e&&(oi[e]={...oi[e],displaySettings:{...t}})}if(!ii)return;const e=Wo.currentMessages.find(t=>t.instanceId===ii);e&&Si(t)&&(Bt(e),xt(e,t)&&so(e,ai,t)),function(){const t=new URLSearchParams(window.location.search).get(Kn);t&&($i(),Xn(t,oi).then(t=>{t&&404===t.status&&ii&&Wo.dismissMessage(ii)}).catch(()=>i("Failed to persist preview display settings")))}()}function $i(){try{sessionStorage.setItem(Zn,JSON.stringify(oi))}catch{}}function Ci(t){const e=t.value.trim();e&&!F(e)?t.classList.add("gist-pb-input--invalid"):t.classList.remove("gist-pb-input--invalid")}function ki(t,e){const n=vi("text",t.elementSelector||"","260px");n.placeholder="Element ID or selector",Ci(n),n.addEventListener("change",()=>{const t=n.value.trim(),e=si.elementSelector;t&&Ei(t),Ii({...si,elementSelector:t}),e&&e!==t&&ji(e),Ci(n)});const i=J("button",{type:"button",className:"gist-pb-select-elem-btn",textContent:"Select Element"});gi&&(i.disabled=!0),i.addEventListener("click",()=>Ti(n));const o=J("div",{className:"gist-pb-inline-row"});o.appendChild(n),o.appendChild(i),e.appendChild(yi("Element Selector",o))}function Ei(t){if(!t||bi.has(t))return;const e=F(t);e&&bi.set(t,e.innerHTML)}function ji(t){const e=bi.get(t);if(void 0===e)return;const n=F(t);n&&(n.innerHTML=e)}function Li(){for(const t of bi.keys())ji(t);bi.clear()}function Ti(t){if(gi)return;gi=!0;const e=document.querySelector(`#${ei} .gist-pb-select-elem-btn`);e&&(e.disabled=!0);const n={...si},o=Wo.currentMessages.find(t=>t.instanceId===ii)??null;o&&io(o),si.elementSelector&&ji(si.elementSelector);const s=J("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(d(),si=n,ai){const t=oi.findIndex(t=>t.stepName===ai);-1!==t&&(oi[t]={...oi[t],displaySettings:{...n}})}o&&Si(n)&&so(o,ai,n),Pi()}},c=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(ei),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,Ei(s);const a=si.elementSelector,r={...si,elementSelector:s},l=null!=o&&Si(r)&&xt(o,r);Ii(r),a&&a!==s&&ji(a),o&&!l&&so(o,ai,r)}d(),Pi()},d=()=>{a?.classList.remove("gist-pb-pick-highlight"),s.removeEventListener("mousemove",r),s.removeEventListener("click",c),document.removeEventListener("keydown",l),document.body.removeChild(s),gi=!1,mi=null};mi=d,s.addEventListener("mousemove",r),s.addEventListener("click",c),document.addEventListener("keydown",l),document.body.appendChild(s)}function Pi(){const t=document.getElementById(ei);if(!t)return;if(t.classList.toggle("gist-pb-hidden",!ii&&!li),t.innerHTML="",!ii){if(li){const e=J("div",{className:"gist-pb-controls-row gist-pb-ended-row"}),n=J("span",{className:"gist-pb-ended-icon",textContent:"✓"}),i=J("p",{className:"gist-pb-ended-text"});if(i.innerHTML=Ni(ci),e.appendChild(n),e.appendChild(i),ui){const t=J("button",{type:"button",className:"gist-pb-cancel-btn",textContent:"Cancel"});t.addEventListener("click",Ai),e.appendChild(t)}t.appendChild(e)}return}const e=J("div",{className:"gist-pb-toggle-row"+(ri?" gist-pb-toggle-row--collapsed":"")}),n=J("button",{type:"button",className:"gist-pb-toggle-btn"}),i=ri?"transform:rotate(180deg);display:inline-flex;":"display:inline-flex;";if(n.innerHTML=`${ri?"Expand":"Collapse"}<span style="${i}">${Vn("white")}</span>`,n.addEventListener("click",Mi),e.appendChild(n),t.appendChild(e),ri)return;const o=J("div",{className:"gist-pb-controls-row"});if(oi.length>0){const t=ai??oi[0].stepName,e=wi(oi.map(t=>({value:t.stepName,label:t.stepName})),t);e.addEventListener("change",()=>{const t=oi.find(t=>t.stepName===e.value);if(t){ai=t.stepName,si={...t.displaySettings};const e=Wo.currentMessages.find(t=>t.instanceId===ii);e&&oo(e,t.stepName,t.displaySettings).then(n=>{!n&&Si(t.displaySettings)&&so(e,t.stepName,t.displaySettings)}),Pi()}}),o.appendChild(yi("Step",e))}const s=wi([{value:"modal",label:"Modal"},{value:"overlay",label:"Overlay"},{value:"inline",label:"Inline"},{value:"tooltip",label:"Tooltip"}],si.displayType||"modal");s.addEventListener("change",()=>{const t=s.value,e=si.displayType,n=si.elementSelector,i={...si,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),si=i,Ii(si),"inline"!==e&&"tooltip"!==e||!n||"inline"===t||"tooltip"===t||ji(n),Pi()}),o.appendChild(yi("Display Type",s));const a=si.displayType||"modal";"modal"===a?function(t,e){const n=wi([{value:"top",label:"Top"},{value:"center",label:"Center"},{value:"bottom",label:"Bottom"}],t.modalPosition||"center");n.addEventListener("change",()=>Ii({...si,modalPosition:n.value})),e.appendChild(yi("Position",n));const i=vi("number",t.maxWidth??414,"80px");i.addEventListener("change",()=>Ii({...si,maxWidth:parseInt(i.value)||414})),e.appendChild(yi("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=J("div",{className:"gist-pb-color-control"}),o=J("input",{className:"gist-pb-color-input",type:"color",value:e}),s=J("div",{className:"gist-pb-color-swatch"});s.style.background=e,s.appendChild(o),s.addEventListener("click",()=>o.click());const a=J("input",{className:"gist-pb-color-hex",type:"text",maxLength:6,value:e.replace("#","")}),r=J("input",{className:"gist-pb-color-opacity",type:"number",min:"0",max:"100",value:String(n)}),l=J("span",{className:"gist-pb-color-pct",textContent:"%"}),c=()=>{const t="#"+a.value.replace("#",""),e=parseInt(r.value)||0;s.style.background=t,o.value=t,Ii({...si,overlayColor:xi(t,e)})};return o.addEventListener("input",()=>{a.value=o.value.replace("#","").toUpperCase(),s.style.background=o.value}),o.addEventListener("change",c),a.addEventListener("change",c),r.addEventListener("change",c),i.appendChild(s),i.appendChild(a),i.appendChild(r),i.appendChild(l),yi("Overlay Color",i)}(t));const o=J("div",{className:"gist-pb-checkbox-row"}),s=J("input",{className:"gist-pb-checkbox",type:"checkbox"});s.checked=t.dismissOutsideClick??!1;const a=J("label",{className:"gist-pb-checkbox-label",textContent:"Dismiss on click outside"});s.addEventListener("change",()=>Ii({...si,dismissOutsideClick:s.checked})),a.addEventListener("click",()=>{s.checked=!s.checked,Ii({...si,dismissOutsideClick:s.checked})}),o.appendChild(s),o.appendChild(a);const r=yi(" ",o);r.classList.add("gist-pb-label-group--grow"),r.firstChild.classList.add("gist-pb-label--spacer"),e.appendChild(r)}(si,o):"overlay"===a?function(t,e){const n=wi(Object.entries(ni).map(([t,e])=>({value:t,label:e})),t.overlayPosition||"topCenter");if(n.addEventListener("change",()=>Ii({...si,overlayPosition:n.value})),e.appendChild(yi("Position",n)),!ct.includes(bt(t.overlayPosition))){const n=vi("number",t.maxWidth??414,"80px");n.addEventListener("change",()=>Ii({...si,maxWidth:parseInt(n.value)||414})),e.appendChild(yi("Max Width",n))}}(si,o):"inline"===a?function(t,e){ki(t,e)}(si,o):"tooltip"===a&&function(t,e){const n=wi([{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],t.tooltipPosition||"top");n.addEventListener("change",()=>Ii({...si,tooltipPosition:n.value})),e.appendChild(yi("Position",n)),ki(t,e)}(si,o),o.appendChild(J("div",{className:"gist-pb-spacer"}));const r=J("button",{type:"button",className:"gist-pb-save-btn",textContent:"End session"});r.addEventListener("click",async()=>{ii&&await Wo.dismissMessage(ii)}),o.appendChild(r),t.appendChild(o)}async function Di(){if(!pi)if(pi=!0,function(){try{sessionStorage.removeItem(Zn)}catch{}}(),dn(),function(){try{sessionStorage.removeItem(o)}catch{}}(),ui){try{window.close()}catch{}try{window.location.reload()}catch{}mi&&mi(),di&&(clearInterval(di),di=null),Li(),document.getElementById(ei)?.remove(),document.getElementById(ti)?.remove(),ii=null,oi=[],si={},ai=null,li=!1,ci=5,ui=!0,pi=!1}else li=!1,pi=!1,Pi()}function Ni(t){return ui?`<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 Ai(){li&&di&&(ui=!1,Pi())}function Mi(){ri=!ri;try{sessionStorage.setItem(Yn,String(ri))}catch{}Pi()}function qi(t){if(li)return;ii=t.instanceId??null;const e=t.displaySettings;if(Array.isArray(e)&&e.length>0?(oi=e,function(t){let e;try{const t=sessionStorage.getItem(Zn);if(!t)return;e=JSON.parse(t)}catch{return}if(Array.isArray(e))for(const n of e){const e=t.findIndex(t=>t.stepName===n.stepName);-1!==e&&n.displaySettings&&(t[e]={...t[e],displaySettings:{...t[e].displaySettings,...n.displaySettings}})}}(oi),ai||(ai=oi[0].stepName,si={...oi[0].displaySettings})):e&&"object"==typeof e&&!Array.isArray(e)&&(si={...e}),fi||hi){const t=!!fi,e=!!hi,n=fi,o=hi;if(fi=null,hi=null,t){const t=oi.find(t=>t.stepName===n);if(!t)return i(`Preview bar: step "${n}" not found, ignoring initial step/display override`),void Pi();ai=t.stepName,si={...t.displaySettings}}if(e){if(!t)return i(`Preview bar: display type "${o}" provided without a step, ignoring`),void Pi();si={...si,displayType:o}}Pi();const s=Wo.currentMessages.find(t=>t.instanceId===ii);return void(s&&Si(si)?so(s,ai,si):function(){const t=si.displayType;if("inline"!==t&&"tooltip"!==t)return;const e=document.querySelector("#gist-preview-bar .gist-pb-input[type='text']");e&&Ti(e)}())}Pi()}function Ri(){Li(),ii=null,oi=[],si={},ai=null,li=!0,ci=5,ui=!0,pi=!1;const t=new URLSearchParams(window.location.search).get(Kn);t&&async function(t){try{return await S()(`/api/v1/preview/${t}`,{method:"DELETE"})}catch(t){return x(t)}}(t).catch(()=>i("Failed to delete preview session")),Pi(),di&&clearInterval(di),di=setInterval(async()=>{if(ci-=1,ci<=0)clearInterval(di),di=null,await Di();else{const t=document.querySelector(`#${ei} .gist-pb-ended-text`);t?t.innerHTML=Ni(ci):Pi()}},1e3)}const Oi=60,zi=new Set;function Wi(t){return!(!t||zi.has(t)||(zi.add(t),0))}function Ui(t){t&&zi.delete(t)}async function _i(t){if(!Wo.isDocumentVisible)return i("Document hidden, not showing message now."),null;if(ut(t.queueId))return i(`Message with queueId ${t.queueId} is already showing.`),null;const e=at(t);return!t.tooltipPosition&&e.hasTooltipPosition&&(t.tooltipPosition=e.tooltipPosition),t.tooltipPosition?function(t,e){const n=e.elementId||t.elementId,o=Wo.config.isPreviewSession&&t.properties?.gist?.livePreview;if(n){if(!F(n)){if(!o)return i(`Tooltip target element "${n}" not found for message ${t.messageId}, skipping display`),Wo.messageError(t),null;i(`Preview: tooltip target "${n}" not found, loading message for preview bar`)}}else{if(!o)return i(`No target selector specified for tooltip message ${t.messageId}`),Wo.messageError(t),null;i("Preview: no tooltip target yet, loading message for preview bar")}const s=Wo.currentMessages.find(t=>t.tooltipPosition&&t.elementId===n);s&&(i(`Tooltip already showing on target "${n}" (instance ${s.instanceId}), dismissing it first`),Wo.messageDismissed(s,"displaced"),Zt(s),s.instanceId&>(s.instanceId)),t.instanceId=g(),t.overlay=!1,t.firstLoad=!0,t.shouldResizeHeight=!1,t.shouldScale=!1,t.renderStartTime=(new Date).getTime(),t.elementId=n,Wo.currentMessages.push(t);return Qi(t,null,t.savedStepName||null)}(t,e):Wo.overlayInstanceId?(i(`Message ${Wo.overlayInstanceId} already showing.`),null):(t.instanceId=g(),t.overlay=!0,t.firstLoad=!0,t.shouldResizeHeight=!0,t.shouldScale=e.shouldScale,t.renderStartTime=(new Date).getTime(),Wo.overlayInstanceId=t.instanceId,Wo.currentMessages.push(t),Qi(t,null,t.savedStepName||null))}function Bi(t,e){return Wo.isDocumentVisible||t.embedId?ut(t.queueId)?(i(`Message with queueId ${t.queueId} is already showing.`),null):pt(e)?(i(`Message with elementId ${e} already has a message.`),null):(t.instanceId=g(),t.overlay=!1,t.firstLoad=!0,t.shouldScale=!1,t.elementId=e,t.shouldResizeHeight=!Ot(e),t.renderStartTime=(new Date).getTime(),Wo.currentMessages.push(t),Qi(t,e,t.savedStepName||null)):(i("Document hidden, not showing message now."),null)}async function Fi(t,e="dismissed"){t?(Wo.messageDismissed(t,e),"dismissed"===e&&function(t){const e=t.embedId;e&&(yn.add(e),"untilDismissed"===at(t).embedFrequency&&(Sn(t=>{t.hidden[e]=!0}),i(`Embed ${e} dismissed and will not render again.`)))}(t),await Hi(t)):i("Message not found")}async function Hi(t){"tooltip"===vt(t)?Gi(t):t.overlay?await Xi(!0,t):Vi(t)}async function Ji(t){t?at(t).persistent&&(i("Persistent message dismissed, logging view"),await ao(t),await Yi(t),await Hn(t.queueId??"")):i("Message not found")}function Vi(t){In(t),t.instanceId&>(t.instanceId),t.elementId&&Rt(t.elementId),Wo.config.isPreviewSession&&(Ri(),Ki())}function Gi(t){In(t),Zt(t),t.instanceId&>(t.instanceId),0===Wo.currentMessages.length&&(window.removeEventListener("message",eo),window.removeEventListener("touchstart",Zi)),Wo.config.isPreviewSession&&(Ri(),Ki())}async function Xi(t,e){In(e),t?await Jt():Vt(),0===Wo.currentMessages.length&&(window.removeEventListener("message",eo),window.removeEventListener("touchstart",Zi)),e.instanceId&>(e.instanceId),Wo.overlayInstanceId=null,Wo.config.isPreviewSession&&(Ri(),Ki())}function Ki(){const t=new URL(window.location.href);t.searchParams.delete(Kn),t.searchParams.delete(Qn),history.replaceState(null,"",t.toString())}function Qi(t,e=null,n=null){const o=Wo.config.env,s={endpoint:w.ENGINE_API_ENDPOINT[o],siteId:Wo.config.siteId,dataCenter:Wo.config.dataCenter,messageId:t.messageId,instanceId:t.instanceId??"",livePreview:!1,isEmbed:!!t.embedId,properties:t.properties,customAttributes:Object.fromEntries(new Map(pn))};let a=`${w.GIST_VIEW_ENDPOINT[o]}/index.html`;return"undefined"!=typeof window&&window.crossOriginIsolated&&(a=`${a}?coi=1`,i("Cross-origin-isolated page detected, requesting renderer with COEP headers")),window.addEventListener("message",eo),window.addEventListener("touchstart",Zi),"tooltip"===vt(t)?function(t,e,n,i=null){const o=e.instanceId??"",s=te(o),a=at(e),r=Gt.get(o);r&&(r.cleanup(),Gt.delete(o)),document.querySelectorAll(`#gist-tooltip-${o}`).forEach(t=>{t.parentNode?.removeChild(t)});const l=`gist-tooltip-${o}`,c=document.createElement("div");c.id=l;const d=Pt(Wo.config?.colorScheme);c.innerHTML=function(t,e,n,i="",o="light only"){let s=600;e.messageWidth>s&&(s=e.messageWidth);const a=e.tooltipArrowColor,r=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),l=i?`#${i} `:"",c=`var(--gist-tooltip-arrow-color, ${a})`;return`\n <div class="gist-tooltip-outer">\n <style>\n ${l}.gist-tooltip-outer {\n position: absolute;\n }\n ${l}.gist-tooltip-container {\n position: relative;\n z-index: 9999999;\n opacity: 0;\n transition: opacity 0.3s ease-in-out;\n /* One shadow around the frame and arrow; none while unset. */\n filter: drop-shadow(var(--gist-tooltip-shadow));\n --gist-tooltip-arrow-fill: ${c};\n }\n /* Follows the container's color-scheme, the scheme the message renders in. */\n @supports (color: light-dark(#000, #fff)) {\n ${l}.gist-tooltip-container {\n --gist-tooltip-arrow-fill: light-dark(${c}, var(--gist-tooltip-arrow-color-dark, ${c}));\n }\n }\n ${l}.gist-tooltip-container.gist-visible {\n opacity: 1;\n }\n ${l}.gist-tooltip-frame-clip {\n overflow: hidden;\n }\n ${l}.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: ${o};\n }\n ${l}.gist-tooltip-arrow {\n width: 0;\n height: 0;\n position: absolute;\n z-index: 1;\n }\n ${l}.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 var(--gist-tooltip-arrow-fill);\n }\n ${l}.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 var(--gist-tooltip-arrow-fill);\n }\n ${l}.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 var(--gist-tooltip-arrow-fill);\n }\n ${l}.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 var(--gist-tooltip-arrow-fill);\n }\n @media (max-width: ${s}px) {\n ${l}.gist-tooltip-frame {\n max-width: 100%;\n }\n }\n </style>\n <div class="gist-tooltip-container">\n <div class="gist-tooltip-arrow ${r}"></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,d),document.body.appendChild(c),zt(s,n,i)}(a,t,s,n):e?(rt.includes(e)&<(e),function(t,e,n,o,s=null){const a=F(t);if(a){const i=te(n.instanceId??"");a.classList.add(i);const r=at(n);let l=r.messageWidth+"px";ct.includes(t)&&!r.hasCustomWidth&&(l="100%"),rt.includes(t)&&(a.style.width=l),Ot(t)||(a.style.height="0px"),a.innerHTML=function(t,e,n){const i=Pt(Wo.config?.colorScheme);return function(t,e,n,i="light only"){let o=800;return e.messageWidth>o&&(o=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: ${i};\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: ${o}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>`}(te(e.instanceId??""),n,t,i)}(e,n,r),zt(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){Ht(),document.querySelectorAll("#gist-embed-message").forEach(t=>{t.parentNode?.removeChild(t)}),document.body.insertAdjacentHTML("afterbegin",function(t,e){const n=at(e),i=Pt(Wo.config?.colorScheme);return function(t,e,n,i="light only"){let o=600;return e.messageWidth>o&&(o=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: ${i};\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: ${o}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>`}(te(e.instanceId??""),n,t,i)}(t,e)),zt(te(e.instanceId??""),n,i)}(a,t,s,n),t}async function Yi(t){let e;i(`Message shown, logging view for: ${t.messageId}`),null!=t.queueId?(await ao(t),e=await X(t.queueId)):e=await async function(t){try{return await S().post(`/api/v1/logs/message/${t}`)}catch(t){return x(t)}}(t.messageId),i(200===e?.status?"Message view logged":`Problem logging message: ${e?.status}`)}function Zi(){}function to(t){if(t.startsWith("mailto:")||t.startsWith("https://")||t.startsWith("http://")||t.startsWith("/"))window.location.href=t;else try{const e=new URL(t,window.location.href);"https:"===e.protocol||"http:"===e.protocol?window.location.href=e.href:i(`Refusing to navigate to non-http(s) target: ${t}`)}catch{i(`Refusing to navigate to unparseable target: ${t}`)}}async function eo(t){const e=Wo.config.env,n=t.data;if(n.gist&&t.origin===w.RENDERER_HOST[e]){const t=n.gist.instanceId,e=dt(t);if(!e)return;const o=at(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 Un(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"),Bt(e)),Wo.config.isPreviewSession&&e.properties?.gist?.livePreview&&qi(e),"tooltip"===vt(e)&&Yt(e,n.gist.parameters.displaySettings),e.firstLoad||e.isDisplayChange){if("tooltip"===vt(e)){const t=e.properties?.gist?.elementId||e.elementId||void 0;if(!t||!F(t)){if(Wo.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`),Wo.messageError(e),e.firstLoad=!1,e.isDisplayChange=!1,Gi(e);break}const n=await async function(t){const e=t.instanceId??"",n=at(t),o=`gist-tooltip-${e}`,s=F(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=Gt.get(e);r&&(r.cleanup(),Gt.delete(e));const l=s.querySelector(".gist-tooltip-outer");if(!l)return i(`Tooltip inner element not found for instance ${e}`),!1;const c=n.tooltipPosition||"bottom";if(!await async function(t,e,n){const o=kt(e);if(!o)return!1;let s=[];try{s=Tt(o)}catch{}if(Et(o.getBoundingClientRect(),s))return!0;if(!function(t,e,n){const i=kt(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!==Lt(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=Tt(o)}catch{}return Et(a,r)}(l,a,c))return i(`Tooltip for instance ${e} skipped: target "${a}" is off-screen and cannot be scrolled into a valid position`),!1;const d=function(t,e,n,o){const s=kt(e);if(!s)return null;let a=null,r=null,l=!1,c=[],d=null;try{c=Tt(s)}catch{}function u(){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(!Et(e,c))return void(t.style.display="none");t.style.display="";const a=Lt(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(Ct[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 p(){null===a&&(a=requestAnimationFrame(()=>{a=null,u()}))}function g(){if(!l){l=!0,d&&(d.disconnect(),d=null),window.removeEventListener("scroll",p),window.removeEventListener("resize",p);for(const t of c)t.removeEventListener("scroll",p);null!==a&&(cancelAnimationFrame(a),a=null),null!==r&&(cancelAnimationFrame(r),r=null)}}if(u(),l)return null;window.addEventListener("scroll",p,{passive:!0}),window.addEventListener("resize",p,{passive:!0});for(const t of c)t.addEventListener("scroll",p,{passive:!0});try{d=new MutationObserver(()=>{null===r&&(r=requestAnimationFrame(()=>{r=null,document.contains(s)||u()}))}),d.observe(document.body,{childList:!0,subtree:!0})}catch{}return{cleanup:g,reposition:u}}(l,a,c,{onDetach:()=>{Gt.delete(e);const t=F(o);t&&t.parentNode?.removeChild(t)}});if(d){if("none"!==l.style.display){const t=s.querySelector(".gist-tooltip-container");return t?(Gt.set(e,d),t.classList.add("gist-visible"),!0):(d.cleanup(),i(`Tooltip container not found for instance ${e}`),!1)}return d.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(Wo.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`),Wo.messageError(e),e.firstLoad=!1,e.isDisplayChange=!1,Gi(e);break}}else e.overlay?function(t){const e=at(t),n=document.querySelector("#gist-overlay");if(n){n.classList.add("gist-visible");const o=document.querySelector(".gist-message");o&&(t.position?o.classList.add("gist-"+t.position):o.classList.add("gist-center")),setTimeout(ee,100),e.exitClick&&(i=t.instanceId??"",Ht(),Ft=t=>{"Escape"===t.key&&Wo.dismissMessage(i)},document.addEventListener("keydown",Ft),setTimeout(()=>function(t){const e=document.querySelector("#gist-overlay");e&&e.addEventListener("click",()=>{Wo.dismissMessage(t)})}(t.instanceId??""),1e3))}else Vt();var i}(e):function(t){const e=F(t);e&&e.classList.add("gist-visible")}(e.elementId);e.firstLoad&&!e.isDisplayChange&&(Wo.messageShown(e),o.isEmbed?(function(t){const e=t.embedId;e&&"onceEver"===at(t).embedFrequency&&(Sn(t=>{t.hidden[e]=!0}),i(`Embed ${e} shown once and will not render again.`))}(e),o.embedLogView&&await Yi(e)):o.persistent?i("Persistent message shown, skipping logging view"):await Yi(e)),e.firstLoad=!1,e.isDisplayChange=!1}mt(t,e);break}case"tap":{const t=n.gist.parameters.action,a=n.gist.parameters.name;if(Wo.messageAction(e,t,a),n.gist.parameters.system&&!o.persistent){await Fi(e);break}try{const n=new URL(t);if(n&&"gist:"===n.protocol)switch(n.href.replace("gist://","").split("?")[0]){case"close":if(!Wi(e.instanceId))break;try{await Ji(e),await ro(e),await Fi(e),await ho()}finally{Ui(e.instanceId)}break;case"snooze":{const t=Number.parseInt(n.searchParams.get("showIn")??"",10),a=Number.isFinite(t)&&t>0?t:Oi;o.isEmbed?function(t,e){const n=t.embedId;if(!(n&&e>0))return;const o=Date.now()+60*e*1e3;Sn(t=>{t.hidden[n]=o}),i(`Embed ${n} snoozed for ${e} minute(s).`)}(e,a):o.persistent&&e.queueId?(await async function(t,e){const n=await Bn(t);if(!n)return;const o=Math.min(Math.max(Math.floor(e),1),qn);s(n,!0,new Date(Date.now()+60*o*1e3)),i(`Snoozed message ${t} for ${o} minutes`)}(e.queueId,a),function(t){const e=60*t*1e3;e>2**31-1||setTimeout(()=>{ho()},e)}(a)):(i("Snooze is only supported for persistent queue messages, closing instead"),await Ji(e),await ro(e)),await Fi(e,"snoozed"),await ho();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 Wo.showMessage({messageId:t,properties:n})}break}case"loadPage":{const t=n.href.substring(n.href.indexOf("?url=")+5);t&&to(t);break}}}catch{}break}case"stepChangeRequested":{const t=n.gist.parameters.displaySettings,o=n.gist.parameters.messageStepName;if(!o){i(`stepChangeRequested for message ${e.messageId} arrived without a messageStepName; keeping the current step visible`);break}await oo(e,o,t,n.gist.parameters.name??"")||(i(`Step "${o}" stays on this page, instructing renderer to show it`),function(t,e,n){const i=te(t.instanceId??""),o=document.getElementById(i);o?.contentWindow?.postMessage({action:"showStep",stepId:e,requestId:n},"*")}(e,o,n.gist.parameters.requestId));break}case"changeMessageStep":{const t=n.gist.parameters.displaySettings,s=n.gist.parameters.messageStepName;Wo.config.isPreviewSession&&s&&e.properties?.gist?.livePreview&&function(t,e){if(li)return;ai=t;const n=oi.find(e=>e.stepName===t);n?si={...n.displaySettings}:e&&(si={...e}),Pi()}(s,t),(o.persistent||Pn(e))&&await Fn(e.queueId??"",s,t),t&&!o.isEmbed&&xt(e,t)?(i("Display settings changed, reloading message"),await io(e),St(e,t),await no(e,s??null)):"tooltip"===vt(e)&&Yt(e,t);break}case"routeChanged":e.currentRoute=n.gist.parameters.route,e.renderStartTime=(new Date).getTime(),mt(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"===vt(e)?function(t,e){const n=t.instanceId??"",i=te(n),o=document.getElementById(i);if(o&&e.height>0){o.style.height=`${e.height}px`;const t=Gt.get(n);t&&t.reposition()}}(e,n.gist.parameters):e.elementId&&!e.shouldResizeHeight||function(t,e){const n=F(t.elementId?t.elementId:te(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=F(te(t));n&&(n.title=e)}(t,n.gist.parameters.title);break;case"eventDispatched":Wo.events.dispatch("eventDispatched",{name:n.gist.parameters.name,payload:n.gist.parameters.payload});break;case"error":case"routeError":Wo.messageError(e),"tooltip"===vt(e)?Gi(e):Wo.overlayInstanceId?await Xi(!1,e):Vi(e)}}}async function no(t,e){t.isDisplayChange=!0,t.renderStartTime=(new Date).getTime();const n=vt(t),o=t.elementId||null;if("tooltip"===n)return Wo.overlayInstanceId===t.instanceId&&(Wo.overlayInstanceId=null),t.shouldScale=!1,t.shouldResizeHeight=!1,void Qi(t,null,e);if(o){const e=pt(o);e&&e.instanceId!==t.instanceId&&(i(`Dismissing existing message at ${o} to make room for multi-step message`),await Fi(e,"displaced"))}if(t.overlay){Wo.overlayInstanceId=t.instanceId??null;const e=at(t);t.shouldScale=e.shouldScale,t.shouldResizeHeight=!0}else Wo.overlayInstanceId=null,t.shouldScale=!1,t.shouldResizeHeight=!Ot(o??"");o&&rt.includes(o)&<(o),Qi(t,o,e)}async function io(t){"tooltip"===vt(t)?Zt(t):t.overlay?await Jt():t.elementId&&Rt(t.elementId)}async function oo(t,e,n,o=""){const s=n?.pageUrl;if(!s||wt(s))return!1;if(!function(t){try{const e=new URL(t,window.location.href).protocol;return"https:"===e||"http:"===e}catch{return!1}}(s))return i(`Step "${e}" page-url is not a navigable http(s) target (${s}); treating as a local step change`),!1;const a=at(t);if(Wo.messageAction(t,`gist://loadPage?url=${s}`,o),a.persistent||Pn(t)){i(`Saving step "${e}" before navigating to ${s}`);try{await Fn(t.queueId??"",e,n)}catch(t){i(`Failed to save step state before navigating: ${t}`)}}return Wo.config.isPreviewSession?(await async function(){const t=new URLSearchParams(window.location.search).get(Kn);if(t){$i();try{await Xn(t,oi)}catch{i("Failed to flush preview display settings before navigation")}}}(),function(t){try{const e=new URL(window.location.href);return new URL(t,window.location.href).origin===e.origin}catch{return!1}}(s)?window.location.href=function(t,e,n){try{const i=new URL(t,window.location.href),o=sn();if(!o)return t;i.searchParams.set(Kn,o);try{i.searchParams.set(Qn,btoa(JSON.stringify({stepName:e,displayType:n})))}catch{}return i.href}catch{return t}}(s,e,n?.displayType):(i(`Preview: step "${e}" targets a different origin (${s}); navigating without the preview session token`),to(s))):to(s),!0}async function so(t,e,n){n&&xt(t,n)&&(await io(t),St(t,n)),await no(t,e??null)}async function ao(t){i(`Logging user message view locally for: ${t.queueId}`),Tn(t)?await async function(t){i(`Marking broadcast ${t} as seen.`);const e=await Dn();if(!e)return;const n=await Ln(e,t);if(!n)return;const o=n.properties.gist.broadcast,{frequency:r}=o,l=Nn(e,t),c=An(e,t),d=a(l)||0;if(s(l,d+1),1===r.count)s(c,!1),i(`Marked broadcast ${t} as seen.`);else{const e=new Date;e.setSeconds(e.getSeconds()+r.delay),s(c,!1,e),i(`Marked broadcast ${t} as seen, broadcast was seen ${d+1} times, next show date is ${e}.`)}}(t.queueId??""):await async function(t){const e=await Wn();if(!e)return;const n=a(e)??[];n.push(t),s(e,n)}(t.queueId??"")}async function ro(t){Tn(t)&&(i(`Logging broadcast dismissed locally for: ${t.queueId}`),await async function(t){i(`Marking broadcast ${t} as dismissed.`);const e=await Dn();if(!e)return;const n=await Ln(e,t);n&&(!0!==n.properties.gist.broadcast.frequency.ignoreDismiss?(s(An(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 Hn(t.queueId??""))}const lo=(t,e)=>t().then((t=>new Promise(e=>setTimeout(e,t)))(e).then(()=>lo(t,e)));let co=!1,uo=null;const po=1e4,go=new Set,mo=new Map;async function fo(){co?await ho():sn()?(i("Queue watcher started"),co=!0,lo(()=>new Promise(()=>{!async function(){if(w.hasActiveSSEConnection())return!w.isSSEConnectionManagedBySDK()&&uo&&(i("Not the main instance, closing our SSE connection."),wo()),void await ho();uo&&(i("SSE connection not active, closing it."),wo()),!w.useSSE()||on()?await yo():await async function(){wo();const t=function(){const t=cn();return null===t?(i("No user token available for SSE endpoint."),null):w.GIST_QUEUE_REALTIME_API_ENDPOINT[Wo.config.env??"prod"]+`/api/v3/sse?userToken=${t}&siteId=${Wo.config.siteId}&sessionId=${Fe()}&platform=web`}();if(null===t)return i("SSE endpoint not available, falling back to polling."),void await yo();i(`Starting SSE queue listener on ${t}`),uo=new EventSource(t),w.setActiveSSEConnection(),uo.addEventListener("connected",async t=>{try{i("SSE connection received"),w.setUseSSEFlag(!0);const e=JSON.parse(t.data);e.heartbeat&&(w.setSSEHeartbeat(e.heartbeat),i(`SSE heartbeat set to ${e.heartbeat} seconds`)),w.setActiveSSEConnection()}catch(t){i(`Failed to parse SSE settings: ${t}`)}r(_e),await yo()}),uo.addEventListener("messages",async t=>{try{const e=JSON.parse(t.data);i("SSE message received"),await Rn(e),await En(e),await ho()}catch(t){i(`Failed to parse SSE message: ${t}`),wo()}}),uo.addEventListener("inbox_messages",async t=>{try{const e=JSON.parse(t.data);i("SSE inbox messages received"),await Y(e)}catch(t){i(`Failed to parse SSE inbox messages: ${t}`)}}),uo.addEventListener("error",async()=>{i("SSE error received"),wo()}),uo.addEventListener("heartbeat",async()=>{i("SSE heartbeat received"),w.setActiveSSEConnection(),w.setUseSSEFlag(!0)})}()}()}),1e3)):i("User token not setup, queue not started.")}async function ho(){if(Wo.config?.embedOnly)return;const t=await jn(),e=await On(),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 bo(t)}async function bo(t){if(t.queueId&&await async function(t){const e=await Bn(t);return!!e&&null!==a(e)}(t.queueId))return i(`Not showing message with queueId ${t.queueId} because it is snoozed.`),!1;let e=at(t);if(e.hasRouteRule){if(null==Wo.currentRoute&&!Wo.routeInitialized)return i(`Deferring message ${t.queueId}, route not yet initialized`),!1;if(!yt(e.routeRule))return i(`Route ${new URL(window.location.href).pathname} (currentRoute: ${Wo.currentRoute}) does not match rule: ${e.routeRule}`),!1}if(e.hasPosition&&(t.position=e.position),e.hasTooltipPosition&&(t.tooltipPosition=e.tooltipPosition),e.persistent||Pn(t)){const n=await async function(t){const e=await _n(t);return e?a(e):null}(t.queueId??"");if(n){const o=n.displaySettings?.pageUrl;if(o&&!wt(o))return i(`Saved step for queueId ${t.queueId} belongs to page ${o}, not showing on ${new URL(window.location.href).pathname}`),!1;i(`Restoring saved state for queueId ${t.queueId}`),n.displaySettings&&(St(t,n.displaySettings),e=at(t)),t.savedStepName=n.stepName??null}}if(t.savedStepName){const n=function(t,e){let n=null;return e.hasTooltipPosition||t.tooltipPosition?n=e.elementId||t.elementId:e.isInlineElement&&(n=e.elementId),!n||rt.includes(n)?null:n}(t,e);if(n&&!F(n)&&(!Wo.config.isPreviewSession||!t.properties?.gist?.livePreview))return function(t,e){const n=t.queueId??"",o=new URL(window.location.href).pathname;go.has(n)||mo.get(n)!==o&&(go.add(n),i(`Anchor "${e}" not present for saved step "${t.savedStepName}" of queueId ${n}, waiting up to ${po}ms`),H(e,po).then(async s=>{if(go.delete(n),s)return mo.delete(n),i(`Anchor "${e}" appeared, re-checking message queue`),void await ho();const a=new URL(window.location.href).pathname;a===o?(mo.set(n,o),i(`Anchor "${e}" did not appear within ${po}ms, tour step for queueId ${n} cannot continue on ${o}`),Wo.messageError(t)):i(`Anchor wait for "${e}" outlived ${o} (now on ${a}), ignoring`)}).catch(t=>{go.delete(n),i(`Anchor wait for "${e}" failed: ${t}`)}))}(t,n),!1}if(e.persistent||Pn(t)||!await async function(t){const e=await Un(t);return!!e&&null!==a(e)}(t.queueId??"")){let n=null;return e.isInlineElement?!Wo.config.isPreviewSession||!t.properties?.gist?.livePreview||F(e.elementId)||rt.includes(e.elementId)?n=Bi(t,e.elementId):(i(`Preview: element "${e.elementId}" not found, showing as overlay so placement can be changed`),n=await _i(t)):n=await _i(t),n&&async function(t){const e=await Un(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 yo(){if(sn())if(Wo.isDocumentVisible){if(function(){const t=A();return L&&t.userToken!==E&&(i("User changed in another tab, queue fetches start over."),D()),C&&t.userJwt!==k&&(i("User JWT changed in another tab, queue fetches resume."),C=!1,k=null),C}()?(i("Queue fetches paused until a new user JWT or a change of user."),0):j?!function(t,e=Date.now()){return L&&null!==T&&e<T+1e3*t}(He())||(i("Queue fetch for the new user JWT held until a polling interval has passed."),0):null===a(_e)||(i("Next queue pull scheduled for later."),0)){const t=await async function(){if(Ue)return;Ue=!0;const t=A();let e;!function(t=Date.now()){j&&(j=!1,L&&(T=t))}();try{const t={"X-Gist-User-Anonymous":String(on()),"Content-Language":String(R())};e=await S().post(`/api/v4/users?sessionId=${Fe()}`,{},{headers:t})}catch(t){const n=x(t);n?e=n:i(`Error getting user queue: ${t}`)}finally{Ue=!1}return t.userToken!==sn()?(i("User token changed, clearing queue next pull check."),void r(_e)):t.userJwt===Qe()?(M(e,t)||function(t){const e=t?.headers?.["x-gist-queue-polling-interval"];We=e&&Number(e)>0?Number(e):Math.min(2*We,600);const n=new Date((new Date).getTime()+1e3*We);s(_e,We,n)}(e),e&&e.status>=200&&e.status<400&&(L=!1,T=null),function(t){const e="true"===t?.headers?.["x-cio-use-sse"]?.toLowerCase();w.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;w.setInboxEnabledFlag(n),n&&(i("Inbox enabled, ensuring branding and templates are cached."),await ze(),Pe())}(e),e):void i("User JWT changed during the queue fetch, discarding its response.")}();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??[];Rn(n),En(n),Y(o)}else 304===t.status&&i("304 response, using local store.");await ho()}else i("No response object returned while checking message queue.")}}else i("Document not visible, skipping queue check.");else i("User token reset, skipping queue check.")}function wo(t=!1){t&&w.removeActiveSSEConnection(),(t||w.isSSEConnectionManagedBySDK())&&w.setUseSSEFlag(!1),uo&&(i("Stopping SSE queue listener..."),uo.close(),uo=null)}const vo="3.29.0",xo="gist-debug-overlay-styles";let So=null,Io=!1,$o=!1,Co=null;function ko(t){const e=t.properties?.gist;return vt(e?{...t,tooltipPosition:e.tooltipPosition??t.tooltipPosition,elementId:null!=e.elementId?String(e.elementId):t.elementId}:t)}function Eo(t,e,n=!1){const i=J("div",{className:"gist-debug-msg-row"});return i.appendChild(J("span",{className:"gist-debug-msg-key",textContent:t})),i.appendChild(J("span",{className:n?"gist-debug-msg-val gist-debug-val-error":"gist-debug-msg-val",textContent:e})),i}function jo(t,e){const n=J("div",{className:"gist-debug-msg"}),i=J("div",{className:"gist-debug-msg-meta"});if(i.appendChild(J("span",{className:"gist-debug-msg-type",textContent:ko(t)})),i.appendChild(J("span",{className:`gist-debug-msg-state gist-debug-msg-state--${e}`,textContent:e})),t.instanceId){const e=J("button",{className:"gist-debug-msg-dismiss",textContent:"×"});e.addEventListener("click",()=>{Po(),Wo.dismissMessage(t.instanceId).then(()=>{Po(),Do()})}),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=ko(t);if(i&&"overlay"===o){const t=function(t){if(t)return ht[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=!yt(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=!!F(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=Eo(e,i);t&&s&&a.appendChild(J("span",{className:t,textContent:s})),n.appendChild(a)}if(o.length>0){const t=J("ul",{className:"gist-debug-msg-details"});for(const e of o)t.appendChild(J("li",{textContent:e}));n.appendChild(t)}return n}function Lo(t){const e=J("div",{className:"gist-debug-expand-detail"}),n=J("ul",{className:"gist-debug-expand-list"});return n.appendChild(J("li",{textContent:t})),e.appendChild(n),e}function To(){So&&(So.root.remove(),document.getElementById(xo)?.remove(),null!==Co&&(clearInterval(Co),Co=null),Io&&(Wo.events&&(Wo.events.off("messageShown",No),Wo.events.off("messageDismissed",No),Wo.events.off("messageInboxUpdated",Ao),Wo.events.off("routeChanged",No)),Io=!1),So=null)}function Po(){if(!So)return;Wo.config?function(t,e,n=!1){t.replaceChildren(...e.map(([t,e])=>Eo(t,e,n)))}(So.configRows,[["SDK Version",vo],["Site ID",Wo.config.siteId],["Connection",w.useSSE()?"SSE":`Polling ${He()}s`]]):So.configRows.replaceChildren(Eo("SDK Version",vo),Eo("Status","NOT INITIALIZED",!0)),So.configDetail.style.display=Wo.config?"none":"";const t=sn();t?on()?So.userValue.textContent="(anonymous)":So.userValue.textContent=t.length>32?`${t.slice(0,32)}…`:t:So.userValue.textContent="(none)";const e=Wo.currentRoute;So.routeValue.replaceChildren(J("span",{className:e?"gist-debug-msg-val":"gist-debug-msg-val gist-debug-val-error",textContent:e??"NONE"})),So.routeDetail.style.display=e?"none":""}async function Do(){if(!$o&&So){$o=!0;try{const t=Wo.currentMessages??[],[e,n]=Wo.config?await Promise.all([On(),jn()]):[[],[]],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(!So)return;const a=t.length+s.length;So.messagesLabel.textContent=`Messages (${a})`,So.messagesList.replaceChildren(...t.map(t=>jo(t,"active")),...s.map(t=>jo(t,"queued")))}finally{$o=!1}}}function No(){Po(),Do()}function Ao(){Do()}async function Mo(){Io||(!Io&&Wo.events&&(Wo.events.on("messageShown",No),Wo.events.on("messageDismissed",No),Wo.events.on("messageInboxUpdated",Ao),Wo.events.on("routeChanged",No),Io=!0),Io&&qo(5e3)),Po(),await Do()}function qo(t){null!==Co&&clearInterval(Co),Co=setInterval(()=>{Mo()},t)}function Ro(){if("undefined"!=typeof window&&"true"===new URLSearchParams(window.location.search).get("cio_debug_session"))try{So||null!==Co||(V(xo,"\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"),So=function(){const t=J("div",{id:"gist-debug-overlay"}),e=J("div",{className:"gist-debug-header"});e.appendChild(J("span",{className:"gist-debug-title",textContent:"Customer.io In-App SDK Debugger"}));const n=J("button",{id:"gist-debug-overlay-close",ariaLabel:"Dismiss debug overlay",textContent:"×"});n.addEventListener("click",To),e.appendChild(n),t.appendChild(e);const i=J("div",{className:"gist-debug-section"}),o=J("div",{className:"gist-debug-label"});o.appendChild(J("span",{textContent:"Config"})),i.appendChild(o);const s=J("div",{});i.appendChild(s);const a=Lo("Verify your site ID and credentials are correct.");i.appendChild(a),t.appendChild(i);const r=J("div",{className:"gist-debug-section"}),l=J("div",{className:"gist-debug-label",textContent:"User"});r.appendChild(l);const c=J("div",{className:"gist-debug-value"});r.appendChild(c),t.appendChild(r);const d=J("div",{className:"gist-debug-section"}),u=J("div",{className:"gist-debug-label"});u.appendChild(J("span",{textContent:"Route"})),d.appendChild(u);const p=J("div",{className:"gist-debug-value"});d.appendChild(p);const g=Lo("The current route is used to match against potential message page rules.");d.appendChild(g),t.appendChild(d);const m=J("div",{className:"gist-debug-section"}),f=J("div",{className:"gist-debug-label"});m.appendChild(f);const h=J("div",{});return m.appendChild(h),t.appendChild(m),{root:t,configRows:s,configDetail:a,userValue:c,routeValue:p,routeDetail:g,messagesLabel:f,messagesList:h}}(),G(So.root),qo(2e3),Mo())}catch(t){i(`Failed to initialize debug overlay: ${t}`)}}function Oo(t){const e=[...new Set(t.map(t=>t.siteId).filter(Boolean))];return e.length>1&&console.warn(`Gist: embed payloads on this page declare different site ids (${e.join(", ")}); using "${e[0]}".`),e[0]??""}class zo{static async setup(t){if(this.initialized)return this.config?.embedOnly&&!t.embedOnly&&console.warn("Gist: setup() was called after the SDK had already initialized in embed-only mode, so in-app delivery will not start. Call setup() before mounting embeds."),void 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,colorScheme:t.colorScheme??"default",embedOnly:t.embedOnly??!1},this.currentMessages=[],Gt.forEach(t=>t.cleanup()),Gt.clear(),document.querySelectorAll('[id^="gist-tooltip-"]').forEach(t=>{t.parentNode?.removeChild(t)}),this.overlayInstanceId=null,this.currentRoute=null,this.routeInitialized=!1,this.isDocumentVisible=!0,this.config.isPreviewSession=!this.config.embedOnly&&function(){const t=new URLSearchParams(window.location.search),e=t.get(Kn);if(e){sessionStorage.setItem(o,String(!1)),Ye(),Wo.setUserToken(e),i(`Preview mode enabled with user token: ${e}`),function(){if(document.getElementById(ei))return;V(ti,Gn);try{ri="true"===sessionStorage.getItem(Yn)}catch{ri=!1}const t=J("div",{id:ei});document.body.appendChild(t),Pi()}();const n=t.get(Qn);if(n)try{const t=JSON.parse(atob(n)),e=t.stepName||null,i=t.displayType||null;(e||i)&&function(t,e){fi=t,hi=e}(e,i)}catch{i("Preview bar: failed to parse cioPreviewSettings")}}return!l()}(),Ro(),function(){const t=c();for(let e=t.length-1;e>=0;e--){const n=t.key(e);n?.startsWith("gist.")&&d(n)}}(),this.config.embedOnly||async function(){w.inboxEnabled()&&(W()&&B()||(i("Inbox enabled but missing cached branding/templates, fetching."),await ze()),Pe())}(),"auto"===this.config.colorScheme&&Mt(),i(`Setup complete on ${this.config.env} environment${this.config.embedOnly?" in embed-only mode":""}.`),this.config.embedOnly||(this.config.isPreviewSession||!this.config.useAnonymousSession||new URLSearchParams(location.search).has("ajs_uid")||rn(),await fo(),setTimeout(()=>{this.routeInitialized||(this.routeInitialized=!0,ho())},2e3),document.addEventListener("visibilitychange",async()=>{"hidden"===document.visibilityState?this.isDocumentVisible=!1:(this.isDocumentVisible=!0,await ho())},!1))}static setupDebugOverlay(){Ro()}static async setCurrentRoute(t){this.routeInitialized=!0,this.currentRoute=t,i(`Current route set to: ${t}`),await async function(){if(function(){const t=new URL(window.location.href).pathname;for(const[e,n]of mo)n!==t&&mo.delete(e)}(),0!==Wo.currentMessages.length)for(const t of[...Wo.currentMessages])null==document.querySelector(`#gist-${t.instanceId}`)&&(i(`Removing active message ${t.instanceId} that no longer exists after route change`),await Hi(t))}(),await ho(),this.events?.dispatch("routeChanged",t)}static async setUserToken(t,e){if(!this.config.isPreviewSession)if(this.config.embedOnly)i("Embed-only mode, ignoring user token.");else{if(tn())return an(t,e),void i("User token kept for later: the user JWT names the user.");an(t,e)&&N(),wo(!0),await fo()}}static async setUserJwt(t){!this.config?.isPreviewSession&&l()&&(this.config?.embedOnly?i("Embed-only mode, ignoring user JWT."):function(t){const e="string"==typeof t?t.trim():"",n=""===e?null:e;if(null!==n&&!function(t){for(let e=0;e<t.length;e+=1){const n=t.charCodeAt(e);if(0===n||10===n||13===n||n>255)return!1}return!0}(n))return i("User JWT ignored: a request header can't carry it."),!1;if(!function(t){const e=Qe();return t===e||e===$||null!==t&&!I.has(t)}(n))return i(null===n?"User JWT left in place: another tab handed it over.":"User JWT ignored: another tab has replaced it since this page handed it over."),!1;if(null!==n&&(I.add(n),I.size>20&&I.delete(I.values().next().value)),$=n,n===Qe()&&!C)return i("User JWT unchanged."),!1;const o=sn();null===n?Ye():function(t){const e=new Date;e.setDate(e.getDate()+Ke),s(Xe,t,e)}(n);const a=sn()!==o;return a&&D(),C=!1,j=!0,i(null===n?"User JWT cleared.":"User JWT set."),a}(t)&&this.initialized&&(wo(!0),await fo()))}static setUserLocale(t){var e;s(q,e=t),i(`Set user locate to "${e}"`)}static setColorScheme(t){this.config.colorScheme=t,function(){const t=Wo.config?.colorScheme;"auto"===t?Mt():At&&(At.disconnect(),At=null);const e=Dt(t);Nt=e,qt(e)}(),i(`Color scheme set to: ${t}`)}static setCustomAttribute(t,e){return function(t,e){return t&&"string"==typeof t?(pn.set(t,e),gn(),i(`Set custom attribute "${t}" to "${e}"`),!0):(i(`Invalid key for custom attribute: ${t}`),!1)}(t,e)}static clearCustomAttributes(){pn.clear(),r(un),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=pn.has(t);return pn.delete(t),pn.size>0?gn():r(un),i(`Removed custom attribute "${t}"`),e}(t)}static async clearUserToken(){this.config.isPreviewSession||(this.config.embedOnly?i("Embed-only mode, ignoring user token reset."):(dn(),N(),Ne(),this.config.useAnonymousSession&&rn(),wo(!0),await fo()))}static async dismissMessage(t){const e=dt(t);if(e&&Wi(t))try{await Ji(e),await ro(e),await Fi(e),await ho()}finally{Ui(t)}}static async embedMessage(t,e){const n=Bi(t,e);return n?.instanceId??null}static async embed(t){return this.initialized||await this.setup({siteId:t.siteId??"",embedOnly:!0}),$n(t)}static async mountEmbeds(){const t=[...document.querySelectorAll(hn)].map(Cn).filter(t=>null!==t);return 0===t.length?[]:(this.initialized||await this.setup({siteId:Oo(t),embedOnly:!0}),async function(t){return i(`Rendering ${t.length} embed(s).`),(await Promise.all(t.map(t=>$n(t)))).filter(t=>null!==t)}(t))}static resetEmbed(t){!function(t){Sn(e=>{delete e.hidden[t]}),bn.delete(t),yn.delete(t),i(`Embed ${t} state cleared.`)}(t)}static async showMessage(t){const e=await _i(t);return e?.instanceId??null}static updateMessageDisplaySettings(t,e){const n=dt(t);return!!n&&(n.displaySettings=e,Bt(n),!0)}static messageShown(t){i(`Message shown: ${t.messageId}`),this.events.dispatch("messageShown",t)}static messageDismissed(t,e="dismissed"){null!==t&&(i(`Message dismissed: ${t.messageId} (${e})`),this.events.dispatch("messageDismissed",{...t,dismissReason:e}))}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 Z()).filter(t=>!t.opened).length}static async getInboxMessages(){return await Z()}static async updateInboxMessageOpenState(t,e){return await tt(t,e)}static async removeInboxMessage(t){return await et(t)}static isInboxEnabled(){return w.inboxEnabled()}}zo.version=vo;const Wo=zo;let Uo=Wo;if("undefined"!=typeof window){const t=window;t.__gistWebLoaded?(console.warn("Gist: the SDK has been loaded more than once on this page; check for duplicate snippets or bundles."),t.Gist&&(Uo=t.Gist)):(t.__gistWebLoaded=!0,Ro())}const _o=Uo;return e.default})());
|
package/dist/types/gist.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { type HideReason } from './managers/message-manager';
|
|
|
3
3
|
import type { GistConfig, GistMessage, DisplaySettings, ColorScheme, EmbedPayload } from './types';
|
|
4
4
|
import type { InboxMessage } from './managers/inbox-message-manager';
|
|
5
5
|
export default class Gist {
|
|
6
|
+
static readonly version: string;
|
|
6
7
|
static events: EventEmitter;
|
|
7
8
|
static config: GistConfig;
|
|
8
9
|
static initialized: boolean;
|
|
@@ -15,6 +16,21 @@ export default class Gist {
|
|
|
15
16
|
static setupDebugOverlay(): void;
|
|
16
17
|
static setCurrentRoute(route: string): Promise<void>;
|
|
17
18
|
static setUserToken(userToken: string, expiryDate?: Date): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Hands over the JWT the site's backend signed for the signed-in person. It's
|
|
21
|
+
* kept in gist-web's storage, so every tab and later page load sends it with
|
|
22
|
+
* their requests to Gist, until clearUserToken(), this page's null, a new JWT
|
|
23
|
+
* or 30 days end it. While its sub names a person, that person is the user:
|
|
24
|
+
* gist-web files what it caches under the sub and sends it as the user token,
|
|
25
|
+
* and setUserToken() only keeps its token for later. A JWT this page handed
|
|
26
|
+
* over before can't replace a newer one another tab stored, and null clears
|
|
27
|
+
* only the JWT this page left in storage. The queue is fetched straight away
|
|
28
|
+
* whenever the value changes, so a site can call this as often as it likes.
|
|
29
|
+
* Callable before setup(); ignored in a preview session and in embed-only mode.
|
|
30
|
+
* When Gist rejects the JWT, `userJwtRejected` fires once per JWT value in each
|
|
31
|
+
* tab, and that tab's queue fetches pause until a different JWT or user.
|
|
32
|
+
*/
|
|
33
|
+
static setUserJwt(jwt: string | null): Promise<void>;
|
|
18
34
|
static setUserLocale(userLocale: string): void;
|
|
19
35
|
static setColorScheme(colorScheme: ColorScheme): void;
|
|
20
36
|
static setCustomAttribute(key: string, value: unknown): boolean;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ import Gist from './gist';
|
|
|
2
2
|
declare let exported: typeof Gist;
|
|
3
3
|
export default exported;
|
|
4
4
|
export type { ColorScheme, GistConfig, GistEnv, GistMessage, DisplaySettings, MessageProperties, EmbedFrequency, EmbedDisplayConfig, EmbedPayload, } from './types';
|
|
5
|
+
export type { UserJwtRejectedEvent } from './managers/user-jwt-manager';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GistMessage, ColorScheme } from '../types';
|
|
1
|
+
import type { GistMessage, ColorScheme, DisplaySettings } from '../types';
|
|
2
2
|
export declare function resolveRendererColorScheme(colorScheme: ColorScheme | undefined): 'light' | 'dark' | undefined;
|
|
3
3
|
export declare function applyColorSchemeChange(): void;
|
|
4
4
|
export declare function startColorSchemeObserver(): void;
|
|
@@ -36,6 +36,14 @@ export declare function showOverlayComponent(message: GistMessage): void;
|
|
|
36
36
|
export declare function hideOverlayComponent(): Promise<void>;
|
|
37
37
|
export declare function removeOverlayComponent(): void;
|
|
38
38
|
export declare function loadTooltipComponent(url: string, message: GistMessage, options: MessageOptions, stepName?: string | null): void;
|
|
39
|
+
/**
|
|
40
|
+
* Applies the visible step's arrow colors and shadow, which the renderer
|
|
41
|
+
* reports from the message's own attributes, to the live tooltip. Unset values
|
|
42
|
+
* fall back to the template's arrow color and no shadow. A report without
|
|
43
|
+
* settings (no step visible yet) says nothing about the step, so the tooltip
|
|
44
|
+
* keeps what it has.
|
|
45
|
+
*/
|
|
46
|
+
export declare function applyTooltipAppearance(message: GistMessage, displaySettings: DisplaySettings | undefined): void;
|
|
39
47
|
export declare function showTooltipComponent(message: GistMessage): Promise<boolean>;
|
|
40
48
|
export declare function hideTooltipComponent(message: GistMessage): void;
|
|
41
49
|
export declare function clearAllTooltipHandles(): void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { NetworkResponse } from '../services/network';
|
|
2
|
+
/** What `userJwtRejected` carries. `reason` is absent when Gist's 401 has no body. */
|
|
3
|
+
export interface UserJwtRejectedEvent {
|
|
4
|
+
reason?: string;
|
|
5
|
+
}
|
|
6
|
+
/** The user token and JWT a request to Gist was sent with. */
|
|
7
|
+
interface RequestIdentity {
|
|
8
|
+
userToken: string | null;
|
|
9
|
+
userJwt: string | null;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Takes the JWT the site handed over, or null to clear it, and returns whether
|
|
13
|
+
* the user changed with it, so the caller can restart what belongs to the user.
|
|
14
|
+
*/
|
|
15
|
+
export declare function setUserJwt(jwt: string | null): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Applies a change of user made with setUserToken or clearUserToken in this tab.
|
|
18
|
+
* setUserToken changes the user only while no stored JWT names one (see gist.ts),
|
|
19
|
+
* so a JWT still stored then names nobody, and it goes. A change of user also
|
|
20
|
+
* lifts this tab's pause and starts the one-event-per-JWT count over.
|
|
21
|
+
*/
|
|
22
|
+
export declare function applyUserTokenChange(): void;
|
|
23
|
+
export declare function getRequestIdentity(): RequestIdentity;
|
|
24
|
+
export declare function isQueuePausedByUserJwtRejection(): boolean;
|
|
25
|
+
export declare function isQueueFetchRequested(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the fetch setUserJwt asked for has to wait. After a rejection the
|
|
28
|
+
* first one goes straight away, and each later one waits until a polling
|
|
29
|
+
* interval has passed since the one before.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isRequestedQueueFetchHeld(pollingIntervalSeconds: number, now?: number): boolean;
|
|
32
|
+
/** Called as a queue fetch is sent: it carries the fetch setUserJwt asked for. */
|
|
33
|
+
export declare function markQueueFetchSent(now?: number): void;
|
|
34
|
+
export declare function markQueueFetchSucceeded(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Reads Gist's answer to one of the calls it enforces: the queue fetch, an inbox
|
|
37
|
+
* open-state update or a view log. A 401 rejects the JWT the request carried,
|
|
38
|
+
* whatever its body. It counts only while the request's user token and JWT are
|
|
39
|
+
* still this tab's, since an answer to an earlier user or JWT says nothing about
|
|
40
|
+
* the current one. A counted rejection pauses this tab's queue fetches and
|
|
41
|
+
* dispatches `userJwtRejected` once per JWT value. Returns whether it counted.
|
|
42
|
+
*/
|
|
43
|
+
export declare function handleUserJwtRejection(response: NetworkResponse | undefined, sentWith: RequestIdentity): boolean;
|
|
44
|
+
export {};
|
|
@@ -1,6 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sub` of a JWT's payload, which names the person the JWT was signed for.
|
|
3
|
+
* Null when the payload can't be read, has no sub, or has one the user-token
|
|
4
|
+
* header can't carry; such a JWT names nobody, and Gist rejects it. Nothing is
|
|
5
|
+
* verified here: Gist does that.
|
|
6
|
+
*/
|
|
7
|
+
export declare function readUserJwtSubject(jwt: string): string | null;
|
|
8
|
+
/** The JWT the site handed over last, while it's stored. */
|
|
9
|
+
export declare function getUserJwt(): string | null;
|
|
10
|
+
export declare function storeUserJwt(jwt: string): void;
|
|
11
|
+
export declare function clearUserJwt(): void;
|
|
12
|
+
/** Whether the stored JWT names a person, who is then the user. */
|
|
13
|
+
export declare function isUserNamedByJwt(): boolean;
|
|
1
14
|
export declare function isUsingGuestUserToken(): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The user gist-web acts for, files what it caches under and sends as the user
|
|
17
|
+
* token: the person the stored JWT names, or else the token setUserToken stored.
|
|
18
|
+
* The JWT and the user token come from one stored value, so they name the same
|
|
19
|
+
* person in every tab.
|
|
20
|
+
*/
|
|
2
21
|
export declare function getUserToken(): string | null;
|
|
3
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Stores the token and returns whether that changed the stored user: a sign-in
|
|
24
|
+
* from no token or the guest token, or a switch from another token. While a JWT
|
|
25
|
+
* names the user, the stored token only waits for the JWT to go (see gist.ts).
|
|
26
|
+
*/
|
|
27
|
+
export declare function setUserToken(userToken: string, expiryDate?: Date): boolean;
|
|
4
28
|
export declare function useGuestSession(): void;
|
|
5
29
|
export declare function isAnonymousUser(): boolean;
|
|
6
30
|
export declare function getHashedUserToken(): Promise<string | null>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -49,6 +49,9 @@ export interface DisplaySettings {
|
|
|
49
49
|
elementSelector?: string;
|
|
50
50
|
tooltipPosition?: string;
|
|
51
51
|
tooltipArrowColor?: string;
|
|
52
|
+
tooltipArrowColorDark?: string;
|
|
53
|
+
/** A drop-shadow() argument (`x y blur [color]`) drawn around the frame and arrow. */
|
|
54
|
+
tooltipShadow?: string;
|
|
52
55
|
maxWidth?: number;
|
|
53
56
|
overlayColor?: string;
|
|
54
57
|
dismissOutsideClick?: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SDK_VERSION: string;
|