@customerio/cdp-analytics-browser 0.4.10 → 0.4.11
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/cjs/generated/version.js +1 -1
- package/dist/pkg/generated/version.js +1 -1
- package/dist/types/core/buffer/index.d.ts +1 -1
- package/dist/types/generated/version.d.ts +1 -1
- package/dist/umd/573.js +1 -1
- package/dist/umd/573.js.gz +0 -0
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.gz +0 -0
- package/dist/umd/standalone.js +1 -1
- package/dist/umd/standalone.js.gz +0 -0
- package/package.json +3 -3
- package/src/generated/version.ts +1 -1
|
@@ -76,7 +76,7 @@ export declare class AnalyticsBuffered implements PromiseLike<[Analytics, Contex
|
|
|
76
76
|
deregister: (...args: string[]) => Promise<Context>;
|
|
77
77
|
user: () => Promise<import("../user").User>;
|
|
78
78
|
inbox(...topics: string[]): import('../../plugins/in-app-plugin').InboxAPI;
|
|
79
|
-
readonly VERSION = "0.4.
|
|
79
|
+
readonly VERSION = "0.4.11";
|
|
80
80
|
private _createMethod;
|
|
81
81
|
/**
|
|
82
82
|
* These are for methods that where determining when the method gets "flushed" is not important.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "0.4.
|
|
1
|
+
export declare const version = "0.4.11";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/umd/573.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_customerio_cdp_analytics_browser=self.webpackChunk_customerio_cdp_analytics_browser||[]).push([[573],{7573:function(e){var t;t=()=>(()=>{"use strict";var e={d:(t,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{default:()=>sn});class n{constructor(){this.callbacks={}}on(e,t){const n=this.callbacks[e];n?n.push(t):this.callbacks[e]=[t]}off(e,t){const n=this.callbacks[e];if(!n)return;if(!t)return void delete this.callbacks[e];const i=n.indexOf(t);-1!==i&&n.splice(i,1),0===n.length&&delete this.callbacks[e]}dispatch(e,t){const n=this.callbacks[e];n&&n.forEach((e=>e(t)))}}function i(e){sn.config&&sn.config.logging&&console.log(`Gist: ${e}`)}const o="gist.web.isPersistingSession";function s(e,t,n=null){let i=n;i||(i=new Date,i.setDate(i.getDate()+365));const o={value:t,expiry:i};c().setItem(e,JSON.stringify(o))}function a(e){return d(e)}function r(e){c().removeItem(e)}function l(){const e=sessionStorage.getItem(o);return null===e?(sessionStorage.setItem(o,"true"),!0):"true"===e}function c(){return l()?localStorage:sessionStorage}function d(e){if(!e)return null;try{const t=c().getItem(e);if(!t)return null;const n=JSON.parse(t);if(!n.expiry)return n.value;const i=new Date,o=new Date(n.expiry),s=e.startsWith("gist.web.message.broadcasts")&&!e.endsWith("shouldShow")&&!e.endsWith("numberOfTimesShown")||e.startsWith("gist.web.message.user")&&!e.endsWith("seen")&&!e.endsWith("state"),a=new Date(i.getTime()+366e4);return s&&o.getTime()>a.getTime()||i.getTime()>o.getTime()?(r(e),null):n.value}catch(t){i(`Error checking key ${e} for expiry: ${t}`)}return null}var p,u=new Uint8Array(16);function g(){if(!p&&!(p="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return p(u)}const m=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var f=[],h=0;h<256;++h)f.push((h+256).toString(16).substr(1));const w=function(e,t,n){var i=(e=e||{}).random||(e.rng||g)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(var o=0;o<16;++o)t[n+o]=i[o];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(f[e[t+0]]+f[e[t+1]]+f[e[t+2]]+f[e[t+3]]+"-"+f[e[t+4]]+f[e[t+5]]+"-"+f[e[t+6]]+f[e[t+7]]+"-"+f[e[t+8]]+f[e[t+9]]+"-"+f[e[t+10]]+f[e[t+11]]+f[e[t+12]]+f[e[t+13]]+f[e[t+14]]+f[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&m.test(e)}(n))throw TypeError("Stringified UUID is invalid");return n}(i)},y="gist.web.userQueueUseSSE",b="gist.web.activeSSEConnection";let v,x=30;const S={RENDERER_HOST:"https://code.gist.build",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://api.local.gist.build:86"},GIST_QUEUE_REALTIME_API_ENDPOINT:{prod:"https://realtime.cloud.gist.build",dev:"https://realtime.cloud.dev.gist.build",local:"http://api.local.gist.build:3000"},GIST_VIEW_ENDPOINT:{prod:"https://renderer.gist.build/3.0",dev:"https://renderer.gist.build/3.0",local:"http://app.local.gist.build:8080/web"},getSdkId:()=>(v||(v=w()),v),useSSE:()=>a(y)??!1,setUseSSEFlag(e){s(y,e,new Date((new Date).getTime()+6e4)),i(`Set user uses SSE to "${e}"`)},removeActiveSSEConnection(){r(b)},setActiveSSEConnection(){s(b,S.getSdkId(),new Date((new Date).getTime()+S.getSSEHeartbeat()))},hasActiveSSEConnection:()=>a(b)??!1,isSSEConnectionManagedBySDK:()=>a(b)===S.getSdkId(),getSSEHeartbeat:()=>1e3*(x+5),setSSEHeartbeat(e){e&&e>0&&(x=e)}};function I(e){return null!==e&&"object"==typeof e&&"response"in e}function C(e){return I(e)?e.response:void 0}function E(){const e=S.GIST_QUEUE_API_ENDPOINT[sn.config.env??"prod"],t={"X-CIO-Site-Id":sn.config.siteId,"X-CIO-Client-Platform":"web"},n=z();async function i(n,i={}){const o=e+n,s=new AbortController,a=setTimeout((()=>s.abort()),5e3);try{const e=await fetch(o,{method:i.method||"GET",headers:{...t,...i.headers||{}},body:i.method&&"GET"!==i.method.toUpperCase()?i.body:void 0,signal:s.signal});clearTimeout(a);const n=e.headers.get("content-type")?.includes("application/json"),r=n?await e.json():await e.text(),l=Object.fromEntries(e.headers.entries());if(e.status<200||e.status>=400)throw function(e){return Object.assign(new Error,{response:e})}({status:e.status,data:r,headers:l});return{status:e.status,headers:l,data:r}}catch(e){if(clearTimeout(a),I(e))throw e;if(e instanceof Error)throw Object.assign(e,{response:{status:0,data:e.message||"Unknown error",headers:{}}});throw e}}return null!=n&&(t["X-Gist-Encoded-User-Token"]=n),i.post=(e,t={},n={})=>i(e,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",...n.headers||{}}}),i}const $="gist.web.userLocale";function k(){const e=a($);return null!==e?e:navigator.language}let P=600,L=!1;const T="gist.web.userQueueNextPullCheck",M="gist.web.sessionId";function N(){let e=a(M);return e||(e=w()),s(M,e,new Date((new Date).getTime()+18e5)),String(e)}const D="gist.web.userToken",A="gist.web.usingGuestUserToken",q="gist.web.guestUserToken";function R(){return null!==a(A)}function W(){return a(D)}function O(){if(null===W()){let e=a(q);null==e&&(e=w(),s(q,e),i(`Set guest user token "${e}" with expiry date set to 1 year from today`)),s(D,e),s(A,!0),i(`Using anonymous session with token: "${e}"`)}}async function U(){const e=W();return null===e?null:await async function(e){const t=(new TextEncoder).encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map((e=>e.toString(16).padStart(2,"0"))).join("")}(e)}function z(){const e=W();return null===e?null:btoa(e)}function B(){r(D),i("Cleared user token")}async function F(e){try{return await E().post(`/api/v1/logs/queue/${e}`)}catch(e){return C(e)}}function H(e){try{return(document.getElementById(e)??document.querySelector(e))||null}catch{return null}}const _={isEmbedded:!1,elementId:"",hasRouteRule:!1,routeRule:"",position:"",hasPosition:!1,tooltipPosition:"",hasTooltipPosition:!1,tooltipArrowColor:"#fff",shouldScale:!1,campaignId:null,messageWidth:414,overlayColor:"#00000033",persistent:!1,exitClick:!1,hasCustomWidth:!1};function j(e){let t=_.tooltipArrowColor;if((e?.properties?.gist?.tooltipArrowColor?.length??0)>0)t=e.properties.gist.tooltipArrowColor;else{if(!Array.isArray(e?.displaySettings)||0===e.displaySettings.length)return t;let n=e.displaySettings[0];if(e.savedStepName){const t=e.displaySettings.find((t=>t?.stepName===e.savedStepName&&t.displaySettings));t&&(n=t)}n?.displaySettings?.tooltipArrowColor&&(t=n.displaySettings.tooltipArrowColor)}return t}function G(e){const t=_,n=e?.properties?.gist;return n?{isEmbedded:!!n.elementId&&!n.tooltipPosition,elementId:n.elementId||"",hasRouteRule:!!n.routeRuleWeb,routeRule:n.routeRuleWeb||"",position:n.position||"",hasPosition:!!n.position,tooltipPosition:n.tooltipPosition||"",hasTooltipPosition:!!n.tooltipPosition,tooltipArrowColor:j(e),shouldScale:!!n.scale,campaignId:n.campaignId??null,messageWidth:null!=n.messageWidth&&n.messageWidth>0?n.messageWidth:t.messageWidth,hasCustomWidth:(n.messageWidth??0)>0,overlayColor:n.overlayColor||t.overlayColor,persistent:!!n.persistent,exitClick:!!n.exitClick}:t}const V=["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(e){if(document.getElementById(e))return;const t=document.createElement("div");t.id=e,"x-gist-top"===e?document.body.insertBefore(t,document.body.firstChild):document.body.insertAdjacentElement("beforeend",t),i("Top & bottom elements injected into page")}const J=["x-gist-top","x-gist-bottom","x-gist-floating-top","x-gist-floating-bottom"];function Y(e){return sn.currentMessages.find((t=>t.instanceId===e))}function Q(e){return!!e&&sn.currentMessages.some((t=>t.queueId===e))}function K(e){return e?sn.currentMessages.find((t=>t.elementId===e))??null:null}function Z(e){sn.currentMessages=sn.currentMessages.filter((t=>t.instanceId!==e))}function ee(e,t){Z(e),sn.currentMessages.push(t)}function te(e){const t={topLeft:"x-gist-floating-top-left",topCenter:"x-gist-floating-top",topRight:"x-gist-floating-top-right",bottomLeft:"x-gist-floating-bottom-left",bottomCenter:"x-gist-floating-bottom",bottomRight:"x-gist-floating-bottom-right"};return e&&t[e]?t[e]:(i(`Invalid overlay position "${e}", defaulting to "topCenter"`),t.topCenter)}function ne(e){return e.tooltipPosition?"tooltip":e.overlay?"modal":e.elementId&&V.includes(e.elementId)?"overlay":e.elementId?"inline":"modal"}function ie(e,t){const n=ne(e),i=t.displayType;if(void 0===i)return!1;if(n!==i)return!0;const o=G(e);switch(i){case"modal":{if((e.position||"center")!==(t.modalPosition||"center"))return!0;const n=t.dismissOutsideClick??_.exitClick;if(o.exitClick!==n)return!0;const i=t.overlayColor??_.overlayColor;if(o.overlayColor!==i)return!0;break}case"overlay":{const n=te(t.overlayPosition);if(e.elementId!==n)return!0;break}case"inline":if(e.elementId!==t.elementSelector)return!0;break;case"tooltip":if(e.tooltipPosition!==t.tooltipPosition)return!0;if(e.elementId!==t.elementSelector)return!0;if(void 0!==t.tooltipArrowColor&&o.tooltipArrowColor!==t.tooltipArrowColor)return!0}if("overlay"!==i||!J.includes(te(t.overlayPosition))){const e=t.maxWidth??_.messageWidth;if(o.messageWidth!==e)return!0}return!1}function oe(e,t){if(e.properties||(e.properties={}),e.properties.gist||(e.properties.gist={}),"modal"===t.displayType)e.overlay=!0,e.elementId=null,e.properties.gist.elementId=null,e.position=t.modalPosition||"center",e.properties.gist.position=t.modalPosition||"center",e.tooltipPosition=void 0,e.properties.gist.tooltipPosition=void 0,e.properties.gist.tooltipArrowColor=void 0;else if("overlay"===t.displayType){e.overlay=!1;const n=te(t.overlayPosition);e.elementId=n,e.properties.gist.elementId=n,e.position=null,e.properties.gist.position=null,e.tooltipPosition=void 0,e.properties.gist.tooltipPosition=void 0,e.properties.gist.tooltipArrowColor=void 0}else"inline"===t.displayType?(e.overlay=!1,e.elementId=t.elementSelector,e.properties.gist.elementId=t.elementSelector,e.position=null,e.properties.gist.position=null,e.tooltipPosition=void 0,e.properties.gist.tooltipPosition=void 0,e.properties.gist.tooltipArrowColor=void 0):"tooltip"===t.displayType&&(e.overlay=!1,e.elementId=t.elementSelector,e.properties.gist.elementId=t.elementSelector,e.tooltipPosition=t.tooltipPosition,e.properties.gist.tooltipPosition=t.tooltipPosition,e.position=null,e.properties.gist.position=null,void 0!==t.tooltipArrowColor&&(e.properties.gist.tooltipArrowColor=t.tooltipArrowColor));e.elementId&&J.includes(e.elementId)?delete e.properties.gist.messageWidth:void 0!==t.maxWidth&&t.maxWidth>0?e.properties.gist.messageWidth=t.maxWidth:delete e.properties.gist.messageWidth,void 0!==t.overlayColor?e.properties.gist.overlayColor=t.overlayColor:delete e.properties.gist.overlayColor,void 0!==t.dismissOutsideClick?e.properties.gist.exitClick=t.dismissOutsideClick:delete e.properties.gist.exitClick}const se={top:["bottom","left","right"],bottom:["top","left","right"],left:["right","top","bottom"],right:["left","top","bottom"]},ae=/auto|scroll/,re={top:"gist-arrow-bottom",bottom:"gist-arrow-top",left:"gist-arrow-right",right:"gist-arrow-left"};function le(e){const t=H(e);return t||i(`Tooltip target element not found for selector: ${e}`),t}function ce(e,t){if(e.bottom<=0||e.top>=window.innerHeight||e.right<=0||e.left>=window.innerWidth)return!1;for(const n of t){const t=n.getBoundingClientRect();if(e.bottom<=t.top||e.top>=t.bottom||e.right<=t.left||e.left>=t.right)return!1}return!0}function de(e,t,n){const i=function(e,t,n){switch(n){case"top":return{top:t.top-e.height-16,left:t.left+(t.width-e.width)/2};case"bottom":return{top:t.bottom+16,left:t.left+(t.width-e.width)/2};case"left":return{top:t.top+(t.height-e.height)/2,left:t.left-e.width-16};case"right":return{top:t.top+(t.height-e.height)/2,left:t.right+16}}}(e,t,n);return function(e,t,n){return"top"===n||"bottom"===n?e.top>=0&&e.top+t.height<=window.innerHeight:e.left>=0&&e.left+t.width<=window.innerWidth}(i,e,n)&&function(e,t){return"top"===t||"bottom"===t?e.width+8<=window.innerWidth:e.height+8<=window.innerHeight}(e,n)?function(e,t,n){let{top:i,left:o}=e,s=null;if("top"===n||"bottom"===n){const e=4,n=window.innerWidth-t.width-4;n>=e&&(o<e?(s=o-e,o=e):o>n&&(s=o-n,o=n))}else{const e=4,n=window.innerHeight-t.height-4;n>=e&&(i<e?(s=i-e,i=e):i>n&&(s=i-n,i=n))}if(null!==s){const e=("top"===n||"bottom"===n?t.width/2:t.height/2)-16-4;Math.abs(s)>e&&(s=s>0?e:-e)}return{top:i,left:o,position:n,arrowOffset:s}}(i,e,n):null}function pe(e,t,n){const i=de(e,t,n);if(i)return i;for(const i of se[n]){const n=de(e,t,i);if(n)return n}return null}function ue(e){const t=[];let n=e.parentElement;for(;n;){const e=getComputedStyle(n),i=e.overflow+e.overflowX+e.overflowY;ae.test(i)&&t.push(n),n=n.parentElement}return t}function ge(e){const t=H(e);t&&(t.classList.remove("gist-visible"),Array.from(t.classList).filter((e=>e.startsWith("gist-"))).forEach((e=>t.classList.remove(e))),t.style.removeProperty("height"),t.style.removeProperty("width"),t.innerHTML="")}function me(e){const t=H(e);if(t)return!(!t.style||!t.style.height||"0px"===t.style.height)}function fe(e,t,n=null){const i=document.getElementById(e);i&&(i.onload=()=>{!function(e,t,n=null){const i=document.getElementById(e);if(i?.contentWindow){const e={options:t,capabilities:he};n&&(t.stepId=n),i.contentWindow.postMessage(e,"*")}}(e,t,n)})}const he=["MultiStepDisplayTypes"];function we(e){if(!e.displaySettings)return;const t=Se(e.instanceId??""),n=document.getElementById(t);n?.contentWindow&&n.contentWindow.postMessage({action:"updateDisplaySettings",displaySettings:e.displaySettings},"*")}async function ye(){const e=document.querySelector(".gist-message");e&&(e.classList.remove("gist-visible"),await new Promise((e=>setTimeout(e,300)))),be()}function be(){const e=document.querySelector("#gist-embed-message");e&&e.parentNode?.removeChild(e)}const ve=new Map;function xe(e){const t=e.instanceId??"",n=ve.get(t);n&&(n.cleanup(),ve.delete(t));const i=H(`gist-tooltip-${t}`);i&&i.parentNode?.removeChild(i)}function Se(e){return`gist-${e}`}function Ie(){const e=document.querySelector(".gist-message");e&&e.classList.add("gist-visible")}const Ce="gist.web.customAttributes";let Ee=new Map;function $e(){const e=Array.from(Ee.entries()),t=new Date;t.setDate(t.getDate()+30),s(Ce,e,t),i(`Saved ${Ee.size} custom attributes to storage with TTL of 30 days`)}async function ke(e){const t=await Me();if(!t)return;const n=new Date;n.setMinutes(n.getMinutes()+60),s(t,e.filter(Le),n)}async function Pe(e,t){return a(e)?.find((e=>e.queueId===t))}function Le(e){return!(!e.properties?.gist||!e.properties.gist.broadcast)}function Te(e){if(!Le(e))return!1;const t=e.properties.gist.broadcast;return 0===t.frequency.delay&&0===t.frequency.count}async function Me(){const e=await U();return e?`gist.web.message.broadcasts.${e}`:null}function Ne(e,t){return`${e}.${t}.numberOfTimesShown`}function De(e,t){return`${e}.${t}.shouldShow`}!function(){const e=a(Ce);if(e)try{Ee=new Map(e)}catch{Ee=new Map}else Ee=new Map}();const Ae="gist.web.message.user";async function qe(e){const t=await Re();if(!t)return;const n=e.filter((e=>!(e.properties&&e.properties.gist&&e.properties.gist.broadcast))),i=new Date;i.setMinutes(i.getMinutes()+60),s(t,n,i)}async function Re(){const e=await U();return e?`${Ae}.${e}`:null}async function We(){const e=await U();return e?`${Ae}.${e}.seen`:null}async function Oe(e){const t=await U();return t?`${Ae}.${t}.message.${e}.loading`:null}async function Ue(e){const t=await U();return t?`${Ae}.${t}.message.${e}.state`:null}async function ze(e){const t=await Ue(e);t&&(r(t),i(`Cleared message state for queueId: ${e}`))}function Be(e){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.54223 5.33301L7.7089 9.33301L11.8756 5.33301L12.6121 6.04011L7.7089 10.7472L2.80566 6.04011L3.54223 5.33301Z" fill="${e}"/></svg>`}const Fe=`\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(Be("#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`,He="cioPreviewId",_e="cioPreviewSettings",je="gist.previewBar.collapsed",Ge="gist-pb-styles",Ve="gist-preview-bar",Xe={topLeft:"Top Left",topCenter:"Top Center",topRight:"Top Right",bottomLeft:"Bottom Left",bottomCenter:"Bottom Center",bottomRight:"Bottom Right"};let Je=null,Ye=[],Qe={},Ke=null,Ze=!1,et=!1,tt=5,nt=null,it=!0,ot=!1,st=!1,at=null,rt=null,lt=null;const ct=new Map;function dt(e,t={}){const n=document.createElement(e);for(const[e,i]of Object.entries(t))n[e]=i;return n}function pt(e,t){const n=dt("div",{className:"gist-pb-label-group"});return n.appendChild(dt("span",{className:"gist-pb-label",textContent:e})),n.appendChild(t),n}function ut(e,t){const n=dt("select",{className:"gist-pb-select"});for(const i of e){const e=dt("option",{value:i.value,textContent:i.label});i.value===t&&(e.selected=!0),n.appendChild(e)}return n}function gt(e,t,n){const i=dt("input",{className:"gist-pb-input",type:e,value:String(t)});return n&&(i.style.width=n),i}function mt(e,t){const n=Math.round(Math.min(100,Math.max(0,t))/100*255);return"#"+e.replace("#","").toUpperCase()+n.toString(16).padStart(2,"0").toUpperCase()}function ft(e){return!!("inline"!==e.displayType&&"tooltip"!==e.displayType||e.elementSelector?.trim())}function ht(e){if("overlay"===e.displayType&&J.includes(te(e.overlayPosition))){const{maxWidth:t,...n}=e;e=n}if(Qe=e,Ke){const t=Ye.findIndex((e=>e.stepName===Ke));-1!==t&&(Ye[t]={...Ye[t],displaySettings:{...e}})}if(!Je)return;const t=sn.currentMessages.find((e=>e.instanceId===Je));t&&ft(e)&&(we(t),ie(t,e)&&Ht(t,Ke,e)),function(){const e=new URLSearchParams(window.location.search).get(He);e&&async function(e,t){try{return await E()(`/api/v1/preview/${e}`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})}catch(e){return C(e)}}(e,Ye).then((e=>{e&&404===e.status&&Je&&sn.dismissMessage(Je)})).catch((()=>i("Failed to persist preview display settings")))}()}function wt(e){const t=e.value.trim();t&&!H(t)?e.classList.add("gist-pb-input--invalid"):e.classList.remove("gist-pb-input--invalid")}function yt(e,t){const n=gt("text",e.elementSelector||"","260px");n.placeholder="Element ID or selector",wt(n),n.addEventListener("change",(()=>{const e=n.value.trim(),t=Qe.elementSelector;e&&bt(e),ht({...Qe,elementSelector:e}),t&&t!==e&&vt(t),wt(n)}));const i=dt("button",{type:"button",className:"gist-pb-select-elem-btn",textContent:"Select Element"});st&&(i.disabled=!0),i.addEventListener("click",(()=>St(n)));const o=dt("div",{className:"gist-pb-inline-row"});o.appendChild(n),o.appendChild(i),t.appendChild(pt("Element Selector",o))}function bt(e){if(!e||ct.has(e))return;const t=H(e);t&&ct.set(e,t.innerHTML)}function vt(e){const t=ct.get(e);if(void 0===t)return;const n=H(e);n&&(n.innerHTML=t)}function xt(){for(const e of ct.keys())vt(e);ct.clear()}function St(e){if(st)return;st=!0;const t=document.querySelector(`#${Ve} .gist-pb-select-elem-btn`);t&&(t.disabled=!0);const n={...Qe},o=sn.currentMessages.find((e=>e.instanceId===Je))??null;o&&Ft(o),Qe.elementSelector&&vt(Qe.elementSelector);const s=dt("div",{className:"gist-pb-picker-overlay"});let a=null;const r=e=>{s.style.pointerEvents="none";const t=document.elementFromPoint(e.clientX,e.clientY);s.style.pointerEvents="all",t&&t!==a&&t!==s&&(a?.classList.remove("gist-pb-pick-highlight"),a=t,a.classList.add("gist-pb-pick-highlight"))},l=e=>{if("Escape"===e.key){if(d(),Qe=n,Ke){const e=Ye.findIndex((e=>e.stepName===Ke));-1!==e&&(Ye[e]={...Ye[e],displaySettings:{...n}})}o&&ft(n)&&Ht(o,Ke,n),It()}},c=t=>{t.preventDefault(),t.stopPropagation(),s.style.pointerEvents="none";const n=document.elementFromPoint(t.clientX,t.clientY);if(s.style.pointerEvents="all",n&&n!==s){n.classList.remove("gist-pb-pick-highlight");const t=document.getElementById(Ve)?.contains(n)?null:function(e){if(e.id){const t=CSS.escape(e.id);if(1===document.querySelectorAll(`#${t}`).length)return e.id}const t=[];let n=e;for(;n&&"BODY"!==n.tagName&&"HTML"!==n.tagName;){if(n.id){const e=CSS.escape(n.id);if(1===document.querySelectorAll(`#${e}`).length){t.unshift(`#${e}`);break}}let e=n.tagName.toLowerCase();n.className&&"string"==typeof n.className&&(e+=n.className.trim().split(/\s+/).filter(Boolean).map((e=>`.${CSS.escape(e)}`)).join(""));const i=n.parentElement;i&&(e+=`:nth-of-type(${Array.from(i.children).filter((e=>e.tagName===n.tagName)).indexOf(n)+1})`),t.unshift(e);try{if(1===document.querySelectorAll(t.join(" > ")).length)break}catch{}n=n.parentElement}const o=t.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===t)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);e.value=t,bt(t);const s=Qe.elementSelector,a={...Qe,elementSelector:t},r=null!=o&&ft(a)&&ie(o,a);ht(a),s&&s!==t&&vt(s),o&&!r&&Ht(o,Ke,a)}d(),It()},d=()=>{a?.classList.remove("gist-pb-pick-highlight"),s.removeEventListener("mousemove",r),s.removeEventListener("click",c),document.removeEventListener("keydown",l),document.body.removeChild(s),st=!1,at=null};at=d,s.addEventListener("mousemove",r),s.addEventListener("click",c),document.addEventListener("keydown",l),document.body.appendChild(s)}function It(){const e=document.getElementById(Ve);if(!e)return;if(e.classList.toggle("gist-pb-hidden",!Je&&!et),e.innerHTML="",!Je){if(et){const t=dt("div",{className:"gist-pb-controls-row gist-pb-ended-row"}),n=dt("span",{className:"gist-pb-ended-icon",textContent:"✓"}),i=dt("p",{className:"gist-pb-ended-text"});if(i.innerHTML=Ct(tt),t.appendChild(n),t.appendChild(i),it){const e=dt("button",{type:"button",className:"gist-pb-cancel-btn",textContent:"Cancel"});e.addEventListener("click",Et),t.appendChild(e)}e.appendChild(t)}return}const t=dt("div",{className:"gist-pb-toggle-row"+(Ze?" gist-pb-toggle-row--collapsed":"")}),n=dt("button",{type:"button",className:"gist-pb-toggle-btn"}),i=Ze?"transform:rotate(180deg);display:inline-flex;":"display:inline-flex;";if(n.innerHTML=`${Ze?"Expand":"Collapse"}<span style="${i}">${Be("white")}</span>`,n.addEventListener("click",$t),t.appendChild(n),e.appendChild(t),Ze)return;const o=dt("div",{className:"gist-pb-controls-row"});if(Ye.length>0){const e=Ke??Ye[0].stepName,t=ut(Ye.map((e=>({value:e.stepName,label:e.stepName}))),e);t.addEventListener("change",(()=>{const e=Ye.find((e=>e.stepName===t.value));if(e){Ke=e.stepName,Qe={...e.displaySettings};const t=sn.currentMessages.find((e=>e.instanceId===Je));t&&ft(e.displaySettings)&&Ht(t,e.stepName,e.displaySettings),It()}})),o.appendChild(pt("Step",t))}const s=ut([{value:"modal",label:"Modal"},{value:"overlay",label:"Overlay"},{value:"inline",label:"Inline"},{value:"tooltip",label:"Tooltip"}],Qe.displayType||"modal");s.addEventListener("change",(()=>{const e=s.value,t=Qe.displayType,n=Qe.elementSelector,i={...Qe,displayType:e};"modal"===e?(i.modalPosition=i.modalPosition||"center",i.maxWidth=i.maxWidth??414,delete i.overlayPosition,delete i.elementSelector,delete i.tooltipPosition):"overlay"===e?(i.overlayPosition=i.overlayPosition||"topCenter",i.maxWidth=i.maxWidth??414,delete i.modalPosition,delete i.elementSelector,delete i.tooltipPosition):"inline"===e?(delete i.modalPosition,delete i.overlayPosition,delete i.tooltipPosition):"tooltip"===e&&(i.tooltipPosition=i.tooltipPosition||"top",delete i.modalPosition,delete i.overlayPosition,delete i.overlayColor,delete i.dismissOutsideClick),Qe=i,ht(Qe),"inline"!==t&&"tooltip"!==t||!n||"inline"===e||"tooltip"===e||vt(n),It()})),o.appendChild(pt("Display Type",s));const a=Qe.displayType||"modal";"modal"===a?function(e,t){const n=ut([{value:"top",label:"Top"},{value:"center",label:"Center"},{value:"bottom",label:"Bottom"}],e.modalPosition||"center");n.addEventListener("change",(()=>ht({...Qe,modalPosition:n.value}))),t.appendChild(pt("Position",n));const i=gt("number",e.maxWidth??414,"80px");i.addEventListener("change",(()=>ht({...Qe,maxWidth:parseInt(i.value)||414}))),t.appendChild(pt("Max Width",i)),t.appendChild(function(e){const{color:t,opacity:n}=function(e){const t=e.replace("#","");return 8===t.length?{color:"#"+t.slice(0,6).toUpperCase(),opacity:Math.round(parseInt(t.slice(6),16)/255*100)}:6===t.length?{color:"#"+t.toUpperCase(),opacity:100}:{color:"#000000",opacity:20}}(e.overlayColor||"#00000033"),i=dt("div",{className:"gist-pb-color-control"}),o=dt("input",{className:"gist-pb-color-input",type:"color",value:t}),s=dt("div",{className:"gist-pb-color-swatch"});s.style.background=t,s.appendChild(o),s.addEventListener("click",(()=>o.click()));const a=dt("input",{className:"gist-pb-color-hex",type:"text",maxLength:6,value:t.replace("#","")}),r=dt("input",{className:"gist-pb-color-opacity",type:"number",min:"0",max:"100",value:String(n)}),l=dt("span",{className:"gist-pb-color-pct",textContent:"%"}),c=()=>{const e="#"+a.value.replace("#",""),t=parseInt(r.value)||0;s.style.background=e,o.value=e,ht({...Qe,overlayColor:mt(e,t)})};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),pt("Overlay Color",i)}(e));const o=dt("div",{className:"gist-pb-checkbox-row"}),s=dt("input",{className:"gist-pb-checkbox",type:"checkbox"});s.checked=e.dismissOutsideClick??!1;const a=dt("label",{className:"gist-pb-checkbox-label",textContent:"Dismiss on click outside"});s.addEventListener("change",(()=>ht({...Qe,dismissOutsideClick:s.checked}))),a.addEventListener("click",(()=>{s.checked=!s.checked,ht({...Qe,dismissOutsideClick:s.checked})})),o.appendChild(s),o.appendChild(a);const r=pt(" ",o);r.classList.add("gist-pb-label-group--grow"),r.firstChild.classList.add("gist-pb-label--spacer"),t.appendChild(r)}(Qe,o):"overlay"===a?function(e,t){const n=ut(Object.entries(Xe).map((([e,t])=>({value:e,label:t}))),e.overlayPosition||"topCenter");if(n.addEventListener("change",(()=>ht({...Qe,overlayPosition:n.value}))),t.appendChild(pt("Position",n)),!J.includes(te(e.overlayPosition))){const n=gt("number",e.maxWidth??414,"80px");n.addEventListener("change",(()=>ht({...Qe,maxWidth:parseInt(n.value)||414}))),t.appendChild(pt("Max Width",n))}}(Qe,o):"inline"===a?function(e,t){yt(e,t)}(Qe,o):"tooltip"===a&&function(e,t){const n=ut([{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],e.tooltipPosition||"top");n.addEventListener("change",(()=>ht({...Qe,tooltipPosition:n.value}))),t.appendChild(pt("Position",n)),yt(e,t)}(Qe,o),o.appendChild(dt("div",{className:"gist-pb-spacer"}));const r=dt("button",{type:"button",className:"gist-pb-save-btn",textContent:"End session"});r.addEventListener("click",(async()=>{Je&&await sn.dismissMessage(Je)})),o.appendChild(r),e.appendChild(o)}function Ct(e){return it?`<strong>Preview session ended.</strong> This tab will close in ${e}s…`:`<strong>Preview session ended.</strong> Finishing session in ${e}s… This tab will stay open.`}function Et(){et&&nt&&(it=!1,It())}function $t(){Ze=!Ze;try{sessionStorage.setItem(je,String(Ze))}catch{}It()}function kt(){xt(),Je=null,Ye=[],Qe={},Ke=null,et=!0,tt=5,it=!0,ot=!1;const e=new URLSearchParams(window.location.search).get(He);e&&async function(e){try{return await E()(`/api/v1/preview/${e}`,{method:"DELETE"})}catch(e){return C(e)}}(e).catch((()=>i("Failed to delete preview session"))),It(),nt&&clearInterval(nt),nt=setInterval((async()=>{if(tt-=1,tt<=0)clearInterval(nt),nt=null,await async function(){if(!ot)if(ot=!0,B(),function(){try{sessionStorage.removeItem(o)}catch{}}(),it){try{window.close()}catch{}try{window.location.reload()}catch{}at&&at(),nt&&(clearInterval(nt),nt=null),xt(),document.getElementById(Ve)?.remove(),document.getElementById(Ge)?.remove(),Je=null,Ye=[],Qe={},Ke=null,et=!1,tt=5,it=!0,ot=!1}else et=!1,ot=!1,It()}();else{const e=document.querySelector(`#${Ve} .gist-pb-ended-text`);e?e.innerHTML=Ct(tt):It()}}),1e3)}async function Pt(e){if(!sn.isDocumentVisible)return i("Document hidden, not showing message now."),null;if(Q(e.queueId))return i(`Message with queueId ${e.queueId} is already showing.`),null;const t=G(e);return!e.tooltipPosition&&t.hasTooltipPosition&&(e.tooltipPosition=t.tooltipPosition),e.tooltipPosition?function(e,t){const n=t.elementId||e.elementId;if(!n)return i(`No target selector specified for tooltip message ${e.messageId}`),sn.messageError(e),null;if(!H(n)){if(!sn.config.isPreviewSession||!e.properties?.gist?.livePreview)return i(`Tooltip target element "${n}" not found for message ${e.messageId}, skipping display`),sn.messageError(e),null;i(`Preview: tooltip target "${n}" not found, loading message for preview bar`)}const o=sn.currentMessages.find((e=>e.tooltipPosition&&e.elementId===n));return o&&(i(`Tooltip already showing on target "${n}" (instance ${o.instanceId}), dismissing it first`),sn.messageDismissed(o),xe(o),o.instanceId&&Z(o.instanceId)),e.instanceId=w(),e.overlay=!1,e.firstLoad=!0,e.shouldResizeHeight=!1,e.shouldScale=!1,e.renderStartTime=(new Date).getTime(),e.elementId=n,sn.currentMessages.push(e),Wt(e,null,e.savedStepName||null)}(e,t):sn.overlayInstanceId?(i(`Message ${sn.overlayInstanceId} already showing.`),null):(e.instanceId=w(),e.overlay=!0,e.firstLoad=!0,e.shouldResizeHeight=!0,e.shouldScale=t.shouldScale,e.renderStartTime=(new Date).getTime(),sn.overlayInstanceId=e.instanceId,sn.currentMessages.push(e),Wt(e,null,e.savedStepName||null))}function Lt(e,t){return sn.isDocumentVisible?Q(e.queueId)?(i(`Message with queueId ${e.queueId} is already showing.`),null):K(t)?(i(`Message with elementId ${t} already has a message.`),null):(e.instanceId=w(),e.overlay=!1,e.firstLoad=!0,e.shouldScale=!1,e.elementId=t,e.shouldResizeHeight=!me(t),e.renderStartTime=(new Date).getTime(),sn.currentMessages.push(e),Wt(e,t,e.savedStepName||null)):(i("Document hidden, not showing message now."),null)}async function Tt(e){e?(sn.messageDismissed(e),await Mt(e)):i("Message not found")}async function Mt(e){"tooltip"===ne(e)?At(e):e.overlay?await qt(!0,e):Dt(e)}async function Nt(e){e?G(e).persistent&&(i("Persistent message dismissed, logging view"),await _t(e),await Ot(e),await ze(e.queueId??"")):i("Message not found")}function Dt(e){e.instanceId&&Z(e.instanceId),e.elementId&&ge(e.elementId),sn.config.isPreviewSession&&(kt(),Rt())}function At(e){xe(e),e.instanceId&&Z(e.instanceId),0===sn.currentMessages.length&&(window.removeEventListener("message",zt),window.removeEventListener("touchstart",Ut)),sn.config.isPreviewSession&&(kt(),Rt())}async function qt(e,t){e?await ye():be(),0===sn.currentMessages.length&&(window.removeEventListener("message",zt),window.removeEventListener("touchstart",Ut)),t.instanceId&&Z(t.instanceId),sn.overlayInstanceId=null,sn.config.isPreviewSession&&(kt(),Rt())}function Rt(){const e=new URL(window.location.href);e.searchParams.delete(He),e.searchParams.delete(_e),history.replaceState(null,"",e.toString())}function Wt(e,t=null,n=null){const o=sn.config.env,s={endpoint:S.ENGINE_API_ENDPOINT[o],siteId:sn.config.siteId,dataCenter:sn.config.dataCenter,messageId:e.messageId,instanceId:e.instanceId??"",livePreview:!1,properties:e.properties,customAttributes:Object.fromEntries(new Map(Ee))},a=`${S.GIST_VIEW_ENDPOINT[o]}/index.html`;return window.addEventListener("message",zt),window.addEventListener("touchstart",Ut),"tooltip"===ne(e)?function(e,t,n,i=null){const o=t.instanceId??"",s=Se(o),a=G(t),r=ve.get(o);r&&(r.cleanup(),ve.delete(o)),document.querySelectorAll(`#gist-tooltip-${o}`).forEach((e=>{e.parentNode?.removeChild(e)}));const l=`gist-tooltip-${o}`,c=document.createElement("div");c.id=l,c.innerHTML=function(e,t,n,i=""){let o=600;t.messageWidth>o&&(o=t.messageWidth);const s=t.tooltipArrowColor,a=function(e){switch(e){case"top":default:return"gist-arrow-bottom";case"bottom":return"gist-arrow-top";case"left":return"gist-arrow-right";case"right":return"gist-arrow-left"}}(t.tooltipPosition),r=i?`#${i} `:"";return`\n <div class="gist-tooltip-outer">\n <style>\n ${r}.gist-tooltip-outer {\n position: absolute;\n }\n ${r}.gist-tooltip-container {\n position: relative;\n z-index: 9999999;\n opacity: 0;\n transition: opacity 0.3s ease-in-out;\n }\n ${r}.gist-tooltip-container.gist-visible {\n opacity: 1;\n }\n ${r}.gist-tooltip-frame-clip {\n overflow: hidden;\n }\n ${r}.gist-tooltip-frame {\n display: block;\n width: ${t.messageWidth}px;\n border: none;\n transition: height 0.1s ease-in-out;\n }\n ${r}.gist-tooltip-arrow {\n width: 0;\n height: 0;\n position: absolute;\n z-index: 1;\n }\n ${r}.gist-tooltip-arrow.gist-arrow-bottom {\n bottom: 0;\n left: 50%;\n transform: translateX(-50%) translateY(100%);\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n border-top: 10px solid ${s};\n }\n ${r}.gist-tooltip-arrow.gist-arrow-top {\n top: 0;\n left: 50%;\n transform: translateX(-50%) translateY(-100%);\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n border-bottom: 10px solid ${s};\n }\n ${r}.gist-tooltip-arrow.gist-arrow-right {\n right: 0;\n top: 50%;\n transform: translateY(-50%) translateX(100%);\n border-top: 10px solid transparent;\n border-bottom: 10px solid transparent;\n border-left: 10px solid ${s};\n }\n ${r}.gist-tooltip-arrow.gist-arrow-left {\n left: 0;\n top: 50%;\n transform: translateY(-50%) translateX(-100%);\n border-top: 10px solid transparent;\n border-bottom: 10px solid transparent;\n border-right: 10px solid ${s};\n }\n @media (max-width: ${o}px) {\n ${r}.gist-tooltip-frame {\n max-width: 100%;\n }\n }\n </style>\n <div class="gist-tooltip-container">\n <div class="gist-tooltip-arrow ${a}"></div>\n <div class="gist-tooltip-frame-clip">\n <iframe id="${e}" class="gist-tooltip-frame" src="${n}"></iframe>\n </div>\n </div>\n </div>`}(s,a,e,l),document.body.appendChild(c),fe(s,n,i)}(a,e,s,n):t?(V.includes(t)&&X(t),function(e,t,n,o,s=null){const a=H(e);if(a){const i=Se(n.instanceId??"");a.classList.add(i);const r=G(n);let l=r.messageWidth+"px";J.includes(e)&&!r.hasCustomWidth&&(l="100%"),V.includes(e)&&(a.style.width=l),me(e)||(a.style.height="0px"),a.innerHTML=function(e,t,n){return function(e,t,n){let i=800;return t.messageWidth>i&&(i=t.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 }\n #x-gist-top.${e},\n #x-gist-bottom.${e},\n #x-gist-floating-top.${e},\n #x-gist-floating-bottom.${e},\n #x-gist-floating-top-left.${e},\n #x-gist-floating-top-right.${e},\n #x-gist-floating-bottom-left.${e},\n #x-gist-floating-bottom-right.${e} {\n transition: height 0.1s ease-in-out;\n }\n @media (max-width: ${i}px) {\n #x-gist-top.${e},\n #x-gist-bottom.${e},\n #x-gist-floating-top.${e},\n #x-gist-floating-bottom.${e},\n #x-gist-floating-top-left.${e},\n #x-gist-floating-top-right.${e},\n #x-gist-floating-bottom-left.${e},\n #x-gist-floating-bottom-right.${e} {\n width: 100% !important;\n }\n }\n </style>\n <div id="gist-embed-container">\n <iframe id="${e}" class="gist-frame" src="${n}"></iframe>\n </div>\n </div>`}(Se(t.instanceId??""),n,e)}(t,n,r),fe(i,o,s)}else i(`Message could not be embedded, elementId ${e} not found.`)}(t,a,e,s,n)):function(e,t,n,i=null){document.querySelectorAll("#gist-embed-message").forEach((e=>{e.parentNode?.removeChild(e)})),document.body.insertAdjacentHTML("afterbegin",function(e,t){const n=G(t);return function(e,t,n){let i=600;return t.messageWidth>i&&(i=t.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: ${t.overlayColor};\n visibility: hidden;\n }\n #gist-overlay.gist-background.gist-visible {\n visibility: visible;\n }\n .gist-message {\n width: ${t.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 }\n .gist-message.gist-visible {\n opacity: 1;\n pointer-events: auto;\n }\n .gist-message.gist-center {\n transform: translate(-50%, -50%);\n top: 50%;\n }\n .gist-message.gist-bottom {\n bottom: 0;\n }\n .gist-message.gist-top {\n top: 0;\n }\n @media (max-width: ${i}px) {\n .gist-message {\n width: 100%;\n }\n }\n </style>\n <div id="gist-overlay" class="gist-background">\n <iframe id="${e}" class="gist-message" src="${n}"></iframe>\n </div>\n </div>`}(Se(t.instanceId??""),n,e)}(e,t)),fe(Se(t.instanceId??""),n,i)}(a,e,s,n),e}async function Ot(e){let t;i(`Message shown, logging view for: ${e.messageId}`),null!=e.queueId?(await _t(e),t=await F(e.queueId)):t=await async function(e){try{return await E().post(`/api/v1/logs/message/${e}`)}catch(e){return C(e)}}(e.messageId),i(200===t?.status?"Message view logged":`Problem logging message: ${t?.status}`)}function Ut(){}async function zt(e){const t=e.data;if(t.gist&&e.origin===S.RENDERER_HOST){const e=t.gist.instanceId,n=Y(e);if(!n)return;const o=G(n);switch(t.gist.method){case"routeLoaded":{const s=.001*((new Date).getTime()-(n.renderStartTime??0));if(i(`Engine render for message: ${n.messageId} timer elapsed in ${s.toFixed(3)} seconds`),async function(e){const t=await Oe(e);t&&r(t)}(n.queueId??""),n.currentRoute=t.gist.parameters.route,t.gist.parameters.fullDisplaySettings&&!n.displaySettings?n.displaySettings=t.gist.parameters.fullDisplaySettings:n.displaySettings&&(i("SDK already has display settings state, sending it to iframe"),we(n)),sn.config.isPreviewSession&&n.properties?.gist?.livePreview&&function(e){if(et)return;Je=e.instanceId??null;const t=e.displaySettings;if(Array.isArray(t)&&t.length>0?(Ye=t,Ke||(Ke=Ye[0].stepName,Qe={...Ye[0].displaySettings})):t&&"object"==typeof t&&!Array.isArray(t)&&(Qe={...t}),rt||lt){const e=!!rt,t=!!lt,n=rt,o=lt;if(rt=null,lt=null,e){const e=Ye.find((e=>e.stepName===n));if(!e)return i(`Preview bar: step "${n}" not found, ignoring initial step/display override`),void It();Ke=e.stepName,Qe={...e.displaySettings}}if(t){if(!e)return i(`Preview bar: display type "${o}" provided without a step, ignoring`),void It();Qe={...Qe,displayType:o}}It();const s=sn.currentMessages.find((e=>e.instanceId===Je));s&&ft(Qe)?Ht(s,Ke,Qe):function(){const e=Qe.displayType;if("inline"!==e&&"tooltip"!==e)return;const t=document.querySelector("#gist-preview-bar .gist-pb-input[type='text']");t&&St(t)}()}else It()}(n),n.firstLoad||n.isDisplayChange){if("tooltip"===ne(n)){const e=n.properties?.gist?.elementId||n.elementId||void 0;if(!e||!H(e)){if(sn.config.isPreviewSession&&n.properties?.gist?.livePreview){i(`Preview: tooltip target "${e}" not found, preview bar will show element picker`),n.firstLoad=!1,n.isDisplayChange=!1;break}i(`Tooltip target not found for "${e}", emitting error and skipping display`),sn.messageError(n),n.firstLoad=!1,n.isDisplayChange=!1,At(n);break}const t=await async function(e){const t=e.instanceId??"",n=G(e),o=`gist-tooltip-${t}`,s=H(o);if(!s)return i(`Tooltip wrapper not found for instance ${t}`),!1;const a=e.properties?.gist?.elementId||e.elementId||void 0;if(!a)return i(`No target selector for tooltip ${t}`),!1;const r=ve.get(t);r&&(r.cleanup(),ve.delete(t));const l=s.querySelector(".gist-tooltip-outer");if(!l)return i(`Tooltip inner element not found for instance ${t}`),!1;const c=n.tooltipPosition||"bottom";if(!await async function(e,t,n){const o=le(t);if(!o)return!1;let s=[];try{s=ue(o)}catch{}if(ce(o.getBoundingClientRect(),s))return!0;if(!function(e,t,n){const i=le(t);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 e.style.display="",null!==pe(e.getBoundingClientRect(),r,n)}(e,t,n))return i(`Preflight failed: tooltip would not fit after scrolling target "${t}" into view`),!1;o.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),await function(e){return new Promise((t=>{let n=e.getBoundingClientRect(),i=0;const o=Date.now();setTimeout((function s(){const a=e.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?t():setTimeout(s,50)}),50)}))}(o);const a=o.getBoundingClientRect();let r=[];try{r=ue(o)}catch{}return ce(a,r)}(l,a,c))return i(`Tooltip for instance ${t} skipped: target "${a}" is off-screen and cannot be scrolled into a valid position`),!1;const d=function(e,t,n,o){const s=le(t);if(!s)return null;let a=null,r=null,l=!1,c=[],d=null;try{c=ue(s)}catch{}function p(){if(l)return;if(!s||!document.contains(s)||!document.contains(e))return i("Tooltip or target element removed from DOM, cleaning up listeners"),g(),void o?.onDetach?.();const t=s.getBoundingClientRect();if(!ce(t,c))return void(e.style.display="none");e.style.display="";const a=pe(e.getBoundingClientRect(),t,n);a?(function(e,t){e.style.position="absolute",e.style.top=`${t.top+window.scrollY}px`,e.style.left=`${t.left+window.scrollX}px`}(e,a),function(e,t){const n=e.querySelector(".gist-tooltip-arrow");n&&(n.classList.remove("gist-arrow-top","gist-arrow-bottom","gist-arrow-left","gist-arrow-right"),n.classList.add(re[t.position]),null!==t.arrowOffset?"top"===t.position||"bottom"===t.position?(n.style.left=`calc(50% + ${t.arrowOffset}px)`,n.style.removeProperty("top")):(n.style.top=`calc(50% + ${t.arrowOffset}px)`,n.style.removeProperty("left")):"top"===t.position||"bottom"===t.position?(n.style.left="50%",n.style.removeProperty("top")):(n.style.top="50%",n.style.removeProperty("left")))}(e,a)):e.style.display="none"}function u(){null===a&&(a=requestAnimationFrame((()=>{a=null,p()})))}function g(){if(!l){l=!0,d&&(d.disconnect(),d=null),window.removeEventListener("scroll",u),window.removeEventListener("resize",u);for(const e of c)e.removeEventListener("scroll",u);null!==a&&(cancelAnimationFrame(a),a=null),null!==r&&(cancelAnimationFrame(r),r=null)}}if(p(),l)return null;window.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",u,{passive:!0});for(const e of c)e.addEventListener("scroll",u,{passive:!0});try{d=new MutationObserver((()=>{null===r&&(r=requestAnimationFrame((()=>{r=null,document.contains(s)||p()})))})),d.observe(document.body,{childList:!0,subtree:!0})}catch{}return{cleanup:g,reposition:p}}(l,a,c,{onDetach:()=>{ve.delete(t);const e=H(o);e&&e.parentNode?.removeChild(e)}});if(d){if("none"!==l.style.display){const e=s.querySelector(".gist-tooltip-container");return e?(ve.set(t,d),e.classList.add("gist-visible"),!0):(d.cleanup(),i(`Tooltip container not found for instance ${t}`),!1)}return d.cleanup(),i(`Tooltip for instance ${t} could not be positioned within the viewport, target "${a}" may be off-screen`),!1}return i(`Failed to position tooltip for instance ${t}, target "${a}" may not exist or no position fits the viewport`),!1}(n);if(!t){if(sn.config.isPreviewSession&&n.properties?.gist?.livePreview){i(`Preview: tooltip positioning failed for "${e}", preview bar will remain active`),n.firstLoad=!1,n.isDisplayChange=!1;break}i(`Tooltip positioning failed for "${e}", emitting error and cleaning up`),sn.messageError(n),n.firstLoad=!1,n.isDisplayChange=!1,At(n);break}}else n.overlay?function(e){const t=G(e),n=document.querySelector("#gist-overlay");if(n){n.classList.add("gist-visible");const i=document.querySelector(".gist-message");i&&(e.position?i.classList.add("gist-"+e.position):i.classList.add("gist-center")),setTimeout(Ie,100),t.exitClick&&setTimeout((()=>function(e){const t=document.querySelector("#gist-overlay");t&&t.addEventListener("click",(()=>{sn.dismissMessage(e)}))}(e.instanceId??"")),1e3)}else be()}(n):function(e){const t=H(e);t&&t.classList.add("gist-visible")}(n.elementId);n.firstLoad&&!n.isDisplayChange&&(sn.messageShown(n),o.persistent?i("Persistent message shown, skipping logging view"):await Ot(n)),n.firstLoad=!1,n.isDisplayChange=!1}ee(e,n);break}case"tap":{const e=t.gist.parameters.action,i=t.gist.parameters.name;if(sn.messageAction(n,e,i),t.gist.parameters.system&&!o.persistent){await Tt(n);break}try{const t=new URL(e);if(t&&"gist:"===t.protocol)switch(t.href.replace("gist://","").split("?")[0]){case"close":await Nt(n),await jt(n),await Tt(n),await en();break;case"showMessage":{const e=t.searchParams.get("messageId"),n=t.searchParams.get("properties");if(e){const t=n?JSON.parse(atob(n)):void 0;await sn.showMessage({messageId:e,properties:t})}break}case"loadPage":{const e=t.href.substring(t.href.indexOf("?url=")+5);e&&(e.startsWith("mailto:")||e.startsWith("https://")||e.startsWith("http://")||e.startsWith("/")?window.location.href=e:window.location.href=window.location+e);break}}}catch{}break}case"changeMessageStep":{const e=t.gist.parameters.displaySettings,r=t.gist.parameters.messageStepName;sn.config.isPreviewSession&&r&&n.properties?.gist?.livePreview&&function(e,t){if(et)return;Ke=e;const n=Ye.find((t=>t.stepName===e));n?Qe={...n.displaySettings}:t&&(Qe={...t}),It()}(r,e),(o.persistent||Te(n))&&await async function(e,t,n){const o=await Ue(e);if(!o)return;const r=a(o)||{},l={stepName:void 0!==t?t: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: ${e}`)}(n.queueId??"",r,e),e&&ie(n,e)&&(i("Display settings changed, reloading message"),await Ft(n),oe(n,e),await Bt(n,r??null));break}case"routeChanged":n.currentRoute=t.gist.parameters.route,n.renderStartTime=(new Date).getTime(),ee(e,n),i(`Route changed to: ${n.currentRoute}`);break;case"sizeChanged":i(`Size Changed Width: ${t.gist.parameters.width} - Height: ${t.gist.parameters.height}`),"tooltip"===ne(n)?function(e,t){const n=e.instanceId??"",i=Se(n),o=document.getElementById(i);if(o&&t.height>0){o.style.height=`${t.height}px`;const e=ve.get(n);e&&e.reposition()}}(n,t.gist.parameters):n.elementId&&!n.shouldResizeHeight||function(e,t){const n=H(e.elementId?e.elementId:Se(e.instanceId??""));if(n){const i=n.style;if(t.height>0)if(t.height>window.innerHeight){const n=1-(t.height/window.innerHeight-1);e.shouldScale&&n>=.4?(i.height=`${t.height}px`,i.transform=`translateX(-50%) translateY(-50%) scale(${n})`):i.height=`${window.innerHeight}px`}else i.height=`${t.height}px`}}(n,t.gist.parameters);break;case"titleChanged":i(`Overlay title changed to: ${t.gist.parameters.title}`),function(e,t){const n=H(Se(e));n&&(n.title=t)}(e,t.gist.parameters.title);break;case"eventDispatched":sn.events.dispatch("eventDispatched",{name:t.gist.parameters.name,payload:t.gist.parameters.payload});break;case"error":case"routeError":sn.messageError(n),"tooltip"===ne(n)?At(n):sn.overlayInstanceId?await qt(!1,n):Dt(n)}}}async function Bt(e,t){e.isDisplayChange=!0,e.renderStartTime=(new Date).getTime();const n=ne(e),o=e.elementId||null;if("tooltip"===n)return sn.overlayInstanceId===e.instanceId&&(sn.overlayInstanceId=null),e.shouldScale=!1,e.shouldResizeHeight=!1,void Wt(e,null,t);if(o){const t=K(o);t&&t.instanceId!==e.instanceId&&(i(`Dismissing existing message at ${o} to make room for multi-step message`),await Tt(t))}if(e.overlay){sn.overlayInstanceId=e.instanceId??null;const t=G(e);e.shouldScale=t.shouldScale,e.shouldResizeHeight=!0}else sn.overlayInstanceId=null,e.shouldScale=!1,e.shouldResizeHeight=!me(o??"");o&&V.includes(o)&&X(o),Wt(e,o,t)}async function Ft(e){"tooltip"===ne(e)?xe(e):e.overlay?await ye():e.elementId&&ge(e.elementId)}async function Ht(e,t,n){n&&ie(e,n)&&(await Ft(e),oe(e,n)),await Bt(e,t??null)}async function _t(e){i(`Logging user message view locally for: ${e.queueId}`),Le(e)?await async function(e){i(`Marking broadcast ${e} as seen.`);const t=await Me();if(!t)return;const n=await Pe(t,e);if(!n)return;const o=n.properties.gist.broadcast,{frequency:r}=o,l=Ne(t,e),c=De(t,e),d=a(l)||0;if(s(l,d+1),1===r.count)s(c,!1),i(`Marked broadcast ${e} as seen.`);else{const t=new Date;t.setSeconds(t.getSeconds()+r.delay),s(c,!1,t),i(`Marked broadcast ${e} as seen, broadcast was seen ${d+1} times, next show date is ${t}.`)}}(e.queueId??""):await async function(e){const t=await We();if(!t)return;const n=a(t)??[];n.push(e),s(t,n)}(e.queueId??"")}async function jt(e){Le(e)&&(i(`Logging broadcast dismissed locally for: ${e.queueId}`),await async function(e){i(`Marking broadcast ${e} as dismissed.`);const t=await Me();if(!t)return;const n=await Pe(t,e);n&&(!0!==n.properties.gist.broadcast.frequency.ignoreDismiss?(s(De(t,e),!1),i(`Marked broadcast ${e} as dismissed and will not show again.`)):i(`Broadcast ${e} is set to ignore dismiss.`))}(e.queueId??""),await ze(e.queueId??""))}const Gt="messageInboxUpdated";async function Vt(e){const t=await Jt();if(!t)return;const n=new Date;n.setMinutes(n.getMinutes()+60),s(t,e,n),sn.events.dispatch(Gt,e)}async function Xt(){const e=await Jt();if(!e)return[];const t=a(e)??[],n=new Date;return t.filter((e=>!e.expiry||new Date(e.expiry)>n))}async function Jt(){const e=await U();return e?`gist.web.inbox.messages.${e}`:null}const Yt=(e,t)=>e().then((e=>new Promise((t=>setTimeout(t,e))))(t).then((()=>Yt(e,t))));let Qt=!1,Kt=null;async function Zt(){Qt?await en():W()?(i("Queue watcher started"),Qt=!0,Yt((()=>new Promise((()=>{!async function(){if(S.hasActiveSSEConnection())return!S.isSSEConnectionManagedBySDK()&&Kt&&(i("Not the main instance, closing our SSE connection."),on()),void await en();Kt&&(i("SSE connection not active, closing it."),on()),!S.useSSE()||R()?await nn():await async function(){on();const e=function(){const e=z();return null===e?(i("No user token available for SSE endpoint."),null):S.GIST_QUEUE_REALTIME_API_ENDPOINT[sn.config.env??"prod"]+`/api/v3/sse?userToken=${e}&siteId=${sn.config.siteId}&sessionId=${N()}`}();if(null===e)return i("SSE endpoint not available, falling back to polling."),void await nn();i(`Starting SSE queue listener on ${e}`),Kt=new EventSource(e),S.setActiveSSEConnection(),Kt.addEventListener("connected",(async e=>{try{i("SSE connection received"),S.setUseSSEFlag(!0);const t=JSON.parse(e.data);t.heartbeat&&(S.setSSEHeartbeat(t.heartbeat),i(`SSE heartbeat set to ${t.heartbeat} seconds`)),S.setActiveSSEConnection()}catch(e){i(`Failed to parse SSE settings: ${e}`)}r(T),await nn()})),Kt.addEventListener("messages",(async e=>{try{const t=JSON.parse(e.data);i("SSE message received"),await qe(t),await ke(t),await en()}catch(e){i(`Failed to parse SSE message: ${e}`),on()}})),Kt.addEventListener("inbox_messages",(async e=>{try{const t=JSON.parse(e.data);i("SSE inbox messages received"),await Vt(t)}catch(e){i(`Failed to parse SSE inbox messages: ${e}`)}})),Kt.addEventListener("error",(async()=>{i("SSE error received"),on()})),Kt.addEventListener("heartbeat",(async()=>{i("SSE heartbeat received"),S.setActiveSSEConnection(),S.setUseSSEFlag(!0)}))}()}()}))),1e3)):i("User token not setup, queue not started.")}async function en(){const e=await async function(){const e=await Me();return e?(a(e)??[]).filter((t=>{const n=t.properties.gist.broadcast,{frequency:i}=n,o=a(De(e,t.queueId))??!0,s=a(Ne(e,t.queueId))||0,r=0===i.count;return o&&(r||s<i.count)})):[]}(),t=await async function(){const e=await Re();if(!e)return[];const t=a(e)??[],n=await async function(){const e=await We();return e?a(e)??[]:[]}();return t.filter((e=>!n.includes(e.queueId??"")))}(),n=e.concat(t);i(`Messages in local queue: ${n.length}`);const o=n.sort(((e,t)=>e.priority-t.priority));for(const e of o)await tn(e)}async function tn(e){let t=G(e);if(t.hasRouteRule){let e=sn.currentRoute;null==e&&(e=new URL(window.location.href).pathname);const n=t.routeRule;if(i(`Verifying route ${e} against rule: ${n}`),!new RegExp(n).test(e))return i(`Route ${e} does not match rule.`),!1}if(t.hasPosition&&(e.position=t.position),t.hasTooltipPosition&&(e.tooltipPosition=t.tooltipPosition),t.persistent||Te(e)){const n=await async function(e){const t=await Ue(e);return t?a(t):null}(e.queueId??"");n&&(i(`Restoring saved state for queueId ${e.queueId}`),n.displaySettings&&(oe(e,n.displaySettings),t=G(e)),e.savedStepName=n.stepName??null)}if(t.persistent||Te(e)||!await async function(e){const t=await Oe(e);return!!t&&null!==a(t)}(e.queueId??"")){let n=null;return t.isEmbedded?!sn.config.isPreviewSession||!e.properties?.gist?.livePreview||H(t.elementId)||V.includes(t.elementId)?n=Lt(e,t.elementId):(i(`Preview: element "${t.elementId}" not found, showing as overlay so placement can be changed`),n=await Pt(e)):n=await Pt(e),n&&async function(e){const t=await Oe(e);t&&s(t,!0,new Date(Date.now()+5e3))}(e.queueId??""),null!==n}return i(`Not showing message with queueId ${e.queueId} because its already loading.`),!1}async function nn(){if(W())if(sn.isDocumentVisible)if(null===a(T)){const e=await async function(){const e=W();let t;try{if(!L){L=!0;const e={"X-Gist-User-Anonymous":String(R()),"Content-Language":String(k())};t=await E().post(`/api/v4/users?sessionId=${N()}`,{},{headers:e})}}catch(e){const n=C(e);n?t=n:i(`Error getting user queue: ${e}`)}finally{L=!1}return e!==W()?(i("User token changed, clearing queue next pull check."),void r(T)):(function(e){if(e?.headers){const t=e.headers["x-gist-queue-polling-interval"];t&&Number(t)>0&&(P=Number(t))}const t=new Date((new Date).getTime()+1e3*P);s(T,P,t)}(t),function(e){const t="true"===e?.headers?.["x-cio-use-sse"]?.toLowerCase();S.setUseSSEFlag(t)}(t),t)}();if(e){if(200===e.status||204===e.status){i("200 response, updating local store.");const t=e.data,n=t?.inAppMessages??[],o=t?.inboxMessages??[];qe(n),ke(n),Vt(o)}else 304===e.status&&i("304 response, using local store.");await en()}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 on(e=!1){e&&S.removeActiveSSEConnection(),(e||S.isSSEConnectionManagedBySDK())&&S.setUseSSEFlag(!1),Kt&&(i("Stopping SSE queue listener..."),Kt.close(),Kt=null)}class sn{static async setup(e){this.initialized?i("Gist SDK already initialized, skipping setup."):(this.initialized=!0,this.events=new n,this.config={useAnonymousSession:e.useAnonymousSession??!1,siteId:e.siteId,dataCenter:e.dataCenter,env:e.env??"prod",logging:e.logging??!1,experiments:e.experiments??!1},this.currentMessages=[],ve.forEach((e=>e.cleanup())),ve.clear(),document.querySelectorAll('[id^="gist-tooltip-"]').forEach((e=>{e.parentNode?.removeChild(e)})),this.overlayInstanceId=null,this.currentRoute=null,this.isDocumentVisible=!0,this.config.isPreviewSession=function(){const e=new URLSearchParams(window.location.search),t=e.get(He);if(t){sessionStorage.setItem(o,String(!1)),sn.setUserToken(t),i(`Preview mode enabled with user token: ${t}`),function(){if(document.getElementById(Ve))return;!function(){if(document.getElementById(Ge))return;const e=document.createElement("style");e.id=Ge,e.textContent=Fe,document.head.appendChild(e)}();try{Ze="true"===sessionStorage.getItem(je)}catch{Ze=!1}const e=dt("div",{id:Ve});document.body.appendChild(e),It()}();const n=e.get(_e);if(n)try{const e=JSON.parse(atob(n)),t=e.stepName||null,i=e.displayType||null;(t||i)&&function(e,t){rt=e,lt=t}(t,i)}catch{i("Preview bar: failed to parse cioPreviewSettings")}}return!l()}(),function(){const e=c();for(let t=e.length-1;t>=0;t--)d(e.key(t))}(),i(`Setup complete on ${this.config.env} environment.`),this.config.isPreviewSession||!this.config.useAnonymousSession||new URLSearchParams(location.search).has("ajs_uid")||O(),await Zt(),document.addEventListener("visibilitychange",(async()=>{"hidden"===document.visibilityState?this.isDocumentVisible=!1:(this.isDocumentVisible=!0,await en())}),!1))}static async setCurrentRoute(e){this.currentRoute=e,i(`Current route set to: ${e}`),await async function(){if(0!==sn.currentMessages.length)for(const e of[...sn.currentMessages])null==document.querySelector(`#gist-${e.instanceId}`)&&(i(`Removing active message ${e.instanceId} that no longer exists after route change`),await Mt(e))}(),await en()}static async setUserToken(e,t){this.config.isPreviewSession||(function(e,t){void 0===t&&(t=new Date).setDate(t.getDate()+30),s(D,e,t),R()&&(r(T),r(A)),i(`Set user token "${e}" with expiry date set to ${t}`)}(e,t),on(!0),await Zt())}static setUserLocale(e){var t;s($,t=e),i(`Set user locate to "${t}"`)}static setCustomAttribute(e,t){return function(e,t){return e&&"string"==typeof e?(Ee.set(e,t),$e(),i(`Set custom attribute "${e}" to "${t}"`),!0):(i(`Invalid key for custom attribute: ${e}`),!1)}(e,t)}static clearCustomAttributes(){Ee.clear(),r(Ce),i("Cleared all custom attributes")}static removeCustomAttribute(e){return function(e){if(!e||"string"!=typeof e)return i(`Invalid key for custom attribute: ${e}`),!1;const t=Ee.has(e);return Ee.delete(e),Ee.size>0?$e():r(Ce),i(`Removed custom attribute "${e}"`),t}(e)}static async clearUserToken(){this.config.isPreviewSession||(B(),this.config.useAnonymousSession&&O(),on(!0),await Zt())}static async dismissMessage(e){const t=Y(e);t&&(await Nt(t),await jt(t),await Tt(t),await en())}static async embedMessage(e,t){return Lt(e,t)?.instanceId??null}static async showMessage(e){return(await Pt(e))?.instanceId??null}static updateMessageDisplaySettings(e,t){const n=Y(e);return!!n&&(n.displaySettings=t,we(n),!0)}static messageShown(e){i(`Message shown: ${e.messageId}`),this.events.dispatch("messageShown",e)}static messageDismissed(e){null!==e&&(i(`Message dismissed: ${e.messageId}`),this.events.dispatch("messageDismissed",e))}static messageError(e){i(`Message error: ${e.messageId}`),this.events.dispatch("messageError",e)}static messageAction(e,t,n){i(`Message action: ${e.currentRoute}, ${t} with name ${n} on ${e.instanceId}`),this.events.dispatch("messageAction",{message:e,action:t,name:n})}static async getInboxUnopenedCount(){return(await Xt()).filter((e=>!e.opened)).length}static async getInboxMessages(){return await Xt()}static async updateInboxMessageOpenState(e,t){return await async function(e,t){const n=await Jt();if(!n)return;const o=await async function(e,t){try{return await E()(`/api/v1/messages/${e}`,{method:"PATCH",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})}catch(e){return C(e)}}(e,{opened:t});if(!o||o.status<200||o.status>=300){const e=`Failed to mark inbox message opened: ${o?.status??"unknown error"}`;throw i(e),new Error(e)}const a=await Xt();let r=null;const l=a.map((n=>{if(n.queueId===e){const e={...n,opened:t};return r=e,e}return n})),c=new Date;if(c.setMinutes(c.getMinutes()+60),s(n,l,c),r){const e=t?"opened":"unopened";sn.events.dispatch("inboxMessageAction",{message:r,action:e})}sn.events.dispatch(Gt,await Xt())}(e,t)}static async removeInboxMessage(e){return await async function(e){const t=await Jt();if(!t)return;const n=await F(e);if(!n||n.status<200||n.status>=300){const e=`Failed to remove inbox message: ${n?.status??"unknown error"}`;throw i(e),new Error(e)}const o=(await Xt()).filter((t=>t.queueId!==e)),a=new Date;a.setMinutes(a.getMinutes()+60),s(t,o,a),sn.events.dispatch(Gt,await Xt())}(e)}}return t.default})(),e.exports=t()}}]);
|
|
1
|
+
(self.webpackChunk_customerio_cdp_analytics_browser=self.webpackChunk_customerio_cdp_analytics_browser||[]).push([[573],{7573:function(e){var t;t=()=>(()=>{"use strict";var e={d:(t,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{default:()=>on});class n{constructor(){this.callbacks={}}on(e,t){const n=this.callbacks[e];n?n.push(t):this.callbacks[e]=[t]}off(e,t){const n=this.callbacks[e];if(!n)return;if(!t)return void delete this.callbacks[e];const i=n.indexOf(t);-1!==i&&n.splice(i,1),0===n.length&&delete this.callbacks[e]}dispatch(e,t){const n=this.callbacks[e];n&&n.forEach((e=>e(t)))}}function i(e){on.config&&on.config.logging&&console.log(`Gist: ${e}`)}const s="gist.web.isPersistingSession";function o(e,t,n=null){let i=n;i||(i=new Date,i.setDate(i.getDate()+365));const s={value:t,expiry:i};c().setItem(e,JSON.stringify(s))}function a(e){return d(e)}function r(e){c().removeItem(e)}function l(){const e=sessionStorage.getItem(s);return null===e?(sessionStorage.setItem(s,"true"),!0):"true"===e}function c(){return l()?localStorage:sessionStorage}function d(e){if(!e)return null;try{const t=c().getItem(e);if(!t)return null;const n=JSON.parse(t);if(!n.expiry)return n.value;if(e.startsWith("gist.")){const t=new Date,i=new Date(n.expiry),s=e.startsWith("gist.web.message.broadcasts")&&!e.endsWith("shouldShow")&&!e.endsWith("numberOfTimesShown")||e.startsWith("gist.web.message.user")&&!e.endsWith("seen")&&!e.endsWith("state"),o=new Date(t.getTime()+366e4);if(s&&i.getTime()>o.getTime())return r(e),null;if(t.getTime()>i.getTime())return r(e),null}return n.value}catch(t){i(`Error checking key ${e} for expiry: ${t}`)}return null}var p,u=new Uint8Array(16);function g(){if(!p&&!(p="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return p(u)}const m=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var f=[],h=0;h<256;++h)f.push((h+256).toString(16).substr(1));const w=function(e,t,n){var i=(e=e||{}).random||(e.rng||g)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(var s=0;s<16;++s)t[n+s]=i[s];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(f[e[t+0]]+f[e[t+1]]+f[e[t+2]]+f[e[t+3]]+"-"+f[e[t+4]]+f[e[t+5]]+"-"+f[e[t+6]]+f[e[t+7]]+"-"+f[e[t+8]]+f[e[t+9]]+"-"+f[e[t+10]]+f[e[t+11]]+f[e[t+12]]+f[e[t+13]]+f[e[t+14]]+f[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&m.test(e)}(n))throw TypeError("Stringified UUID is invalid");return n}(i)},y="gist.web.userQueueUseSSE",b="gist.web.activeSSEConnection";let v,x=30;const S={RENDERER_HOST:"https://code.gist.build",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://api.local.gist.build:86"},GIST_QUEUE_REALTIME_API_ENDPOINT:{prod:"https://realtime.cloud.gist.build",dev:"https://realtime.cloud.dev.gist.build",local:"http://api.local.gist.build:3000"},GIST_VIEW_ENDPOINT:{prod:"https://renderer.gist.build/3.0",dev:"https://renderer.gist.build/3.0",local:"http://app.local.gist.build:8080/web"},getSdkId:()=>(v||(v=w()),v),useSSE:()=>a(y)??!1,setUseSSEFlag(e){o(y,e,new Date((new Date).getTime()+6e4)),i(`Set user uses SSE to "${e}"`)},removeActiveSSEConnection(){r(b)},setActiveSSEConnection(){o(b,S.getSdkId(),new Date((new Date).getTime()+S.getSSEHeartbeat()))},hasActiveSSEConnection:()=>a(b)??!1,isSSEConnectionManagedBySDK:()=>a(b)===S.getSdkId(),getSSEHeartbeat:()=>1e3*(x+5),setSSEHeartbeat(e){e&&e>0&&(x=e)}};function I(e){return null!==e&&"object"==typeof e&&"response"in e}function C(e){return I(e)?e.response:void 0}function E(){const e=S.GIST_QUEUE_API_ENDPOINT[on.config.env??"prod"],t={"X-CIO-Site-Id":on.config.siteId,"X-CIO-Client-Platform":"web"},n=z();async function i(n,i={}){const s=e+n,o=new AbortController,a=setTimeout((()=>o.abort()),5e3);try{const e=await fetch(s,{method:i.method||"GET",headers:{...t,...i.headers||{}},body:i.method&&"GET"!==i.method.toUpperCase()?i.body:void 0,signal:o.signal});clearTimeout(a);const n=e.headers.get("content-type")?.includes("application/json"),r=n?await e.json():await e.text(),l=Object.fromEntries(e.headers.entries());if(e.status<200||e.status>=400)throw function(e){return Object.assign(new Error,{response:e})}({status:e.status,data:r,headers:l});return{status:e.status,headers:l,data:r}}catch(e){if(clearTimeout(a),I(e))throw e;if(e instanceof Error)throw Object.assign(e,{response:{status:0,data:e.message||"Unknown error",headers:{}}});throw e}}return null!=n&&(t["X-Gist-Encoded-User-Token"]=n),i.post=(e,t={},n={})=>i(e,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",...n.headers||{}}}),i}const $="gist.web.userLocale";function k(){const e=a($);return null!==e?e:navigator.language}let P=600,L=!1;const T="gist.web.userQueueNextPullCheck",M="gist.web.sessionId";function N(){let e=a(M);return e||(e=w()),o(M,e,new Date((new Date).getTime()+18e5)),String(e)}const D="gist.web.userToken",A="gist.web.usingGuestUserToken",q="gist.web.guestUserToken";function R(){return null!==a(A)}function W(){return a(D)}function O(){if(null===W()){let e=a(q);null==e&&(e=w(),o(q,e),i(`Set guest user token "${e}" with expiry date set to 1 year from today`)),o(D,e),o(A,!0),i(`Using anonymous session with token: "${e}"`)}}async function U(){const e=W();return null===e?null:await async function(e){const t=(new TextEncoder).encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map((e=>e.toString(16).padStart(2,"0"))).join("")}(e)}function z(){const e=W();return null===e?null:btoa(e)}function B(){r(D),i("Cleared user token")}async function F(e){try{return await E().post(`/api/v1/logs/queue/${e}`)}catch(e){return C(e)}}function H(e){try{return(document.getElementById(e)??document.querySelector(e))||null}catch{return null}}const _={isEmbedded:!1,elementId:"",hasRouteRule:!1,routeRule:"",position:"",hasPosition:!1,tooltipPosition:"",hasTooltipPosition:!1,tooltipArrowColor:"#fff",shouldScale:!1,campaignId:null,messageWidth:414,overlayColor:"#00000033",persistent:!1,exitClick:!1,hasCustomWidth:!1};function j(e){let t=_.tooltipArrowColor;if((e?.properties?.gist?.tooltipArrowColor?.length??0)>0)t=e.properties.gist.tooltipArrowColor;else{if(!Array.isArray(e?.displaySettings)||0===e.displaySettings.length)return t;let n=e.displaySettings[0];if(e.savedStepName){const t=e.displaySettings.find((t=>t?.stepName===e.savedStepName&&t.displaySettings));t&&(n=t)}n?.displaySettings?.tooltipArrowColor&&(t=n.displaySettings.tooltipArrowColor)}return t}function G(e){const t=_,n=e?.properties?.gist;return n?{isEmbedded:!!n.elementId&&!n.tooltipPosition,elementId:n.elementId||"",hasRouteRule:!!n.routeRuleWeb,routeRule:n.routeRuleWeb||"",position:n.position||"",hasPosition:!!n.position,tooltipPosition:n.tooltipPosition||"",hasTooltipPosition:!!n.tooltipPosition,tooltipArrowColor:j(e),shouldScale:!!n.scale,campaignId:n.campaignId??null,messageWidth:null!=n.messageWidth&&n.messageWidth>0?n.messageWidth:t.messageWidth,hasCustomWidth:(n.messageWidth??0)>0,overlayColor:n.overlayColor||t.overlayColor,persistent:!!n.persistent,exitClick:!!n.exitClick}:t}const V=["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(e){if(document.getElementById(e))return;const t=document.createElement("div");t.id=e,"x-gist-top"===e?document.body.insertBefore(t,document.body.firstChild):document.body.insertAdjacentElement("beforeend",t),i("Top & bottom elements injected into page")}const J=["x-gist-top","x-gist-bottom","x-gist-floating-top","x-gist-floating-bottom"];function Y(e){return on.currentMessages.find((t=>t.instanceId===e))}function Q(e){return!!e&&on.currentMessages.some((t=>t.queueId===e))}function K(e){return e?on.currentMessages.find((t=>t.elementId===e))??null:null}function Z(e){on.currentMessages=on.currentMessages.filter((t=>t.instanceId!==e))}function ee(e,t){Z(e),on.currentMessages.push(t)}function te(e){const t={topLeft:"x-gist-floating-top-left",topCenter:"x-gist-floating-top",topRight:"x-gist-floating-top-right",bottomLeft:"x-gist-floating-bottom-left",bottomCenter:"x-gist-floating-bottom",bottomRight:"x-gist-floating-bottom-right"};return e&&t[e]?t[e]:(i(`Invalid overlay position "${e}", defaulting to "topCenter"`),t.topCenter)}function ne(e){return e.tooltipPosition?"tooltip":e.overlay?"modal":e.elementId&&V.includes(e.elementId)?"overlay":e.elementId?"inline":"modal"}function ie(e,t){const n=ne(e),i=t.displayType;if(void 0===i)return!1;if(n!==i)return!0;const s=G(e);switch(i){case"modal":{if((e.position||"center")!==(t.modalPosition||"center"))return!0;const n=t.dismissOutsideClick??_.exitClick;if(s.exitClick!==n)return!0;const i=t.overlayColor??_.overlayColor;if(s.overlayColor!==i)return!0;break}case"overlay":{const n=te(t.overlayPosition);if(e.elementId!==n)return!0;break}case"inline":if(e.elementId!==t.elementSelector)return!0;break;case"tooltip":if(e.tooltipPosition!==t.tooltipPosition)return!0;if(e.elementId!==t.elementSelector)return!0;if(void 0!==t.tooltipArrowColor&&s.tooltipArrowColor!==t.tooltipArrowColor)return!0}if("overlay"!==i||!J.includes(te(t.overlayPosition))){const e=t.maxWidth??_.messageWidth;if(s.messageWidth!==e)return!0}return!1}function se(e,t){if(e.properties||(e.properties={}),e.properties.gist||(e.properties.gist={}),"modal"===t.displayType)e.overlay=!0,e.elementId=null,e.properties.gist.elementId=null,e.position=t.modalPosition||"center",e.properties.gist.position=t.modalPosition||"center",e.tooltipPosition=void 0,e.properties.gist.tooltipPosition=void 0,e.properties.gist.tooltipArrowColor=void 0;else if("overlay"===t.displayType){e.overlay=!1;const n=te(t.overlayPosition);e.elementId=n,e.properties.gist.elementId=n,e.position=null,e.properties.gist.position=null,e.tooltipPosition=void 0,e.properties.gist.tooltipPosition=void 0,e.properties.gist.tooltipArrowColor=void 0}else"inline"===t.displayType?(e.overlay=!1,e.elementId=t.elementSelector,e.properties.gist.elementId=t.elementSelector,e.position=null,e.properties.gist.position=null,e.tooltipPosition=void 0,e.properties.gist.tooltipPosition=void 0,e.properties.gist.tooltipArrowColor=void 0):"tooltip"===t.displayType&&(e.overlay=!1,e.elementId=t.elementSelector,e.properties.gist.elementId=t.elementSelector,e.tooltipPosition=t.tooltipPosition,e.properties.gist.tooltipPosition=t.tooltipPosition,e.position=null,e.properties.gist.position=null,void 0!==t.tooltipArrowColor&&(e.properties.gist.tooltipArrowColor=t.tooltipArrowColor));e.elementId&&J.includes(e.elementId)?delete e.properties.gist.messageWidth:void 0!==t.maxWidth&&t.maxWidth>0?e.properties.gist.messageWidth=t.maxWidth:delete e.properties.gist.messageWidth,void 0!==t.overlayColor?e.properties.gist.overlayColor=t.overlayColor:delete e.properties.gist.overlayColor,void 0!==t.dismissOutsideClick?e.properties.gist.exitClick=t.dismissOutsideClick:delete e.properties.gist.exitClick}const oe={top:["bottom","left","right"],bottom:["top","left","right"],left:["right","top","bottom"],right:["left","top","bottom"]},ae=/auto|scroll/,re={top:"gist-arrow-bottom",bottom:"gist-arrow-top",left:"gist-arrow-right",right:"gist-arrow-left"};function le(e){const t=H(e);return t||i(`Tooltip target element not found for selector: ${e}`),t}function ce(e,t){if(e.bottom<=0||e.top>=window.innerHeight||e.right<=0||e.left>=window.innerWidth)return!1;for(const n of t){const t=n.getBoundingClientRect();if(e.bottom<=t.top||e.top>=t.bottom||e.right<=t.left||e.left>=t.right)return!1}return!0}function de(e,t,n){const i=function(e,t,n){switch(n){case"top":return{top:t.top-e.height-16,left:t.left+(t.width-e.width)/2};case"bottom":return{top:t.bottom+16,left:t.left+(t.width-e.width)/2};case"left":return{top:t.top+(t.height-e.height)/2,left:t.left-e.width-16};case"right":return{top:t.top+(t.height-e.height)/2,left:t.right+16}}}(e,t,n);return function(e,t,n){return"top"===n||"bottom"===n?e.top>=0&&e.top+t.height<=window.innerHeight:e.left>=0&&e.left+t.width<=window.innerWidth}(i,e,n)&&function(e,t){return"top"===t||"bottom"===t?e.width+8<=window.innerWidth:e.height+8<=window.innerHeight}(e,n)?function(e,t,n){let{top:i,left:s}=e,o=null;if("top"===n||"bottom"===n){const e=4,n=window.innerWidth-t.width-4;n>=e&&(s<e?(o=s-e,s=e):s>n&&(o=s-n,s=n))}else{const e=4,n=window.innerHeight-t.height-4;n>=e&&(i<e?(o=i-e,i=e):i>n&&(o=i-n,i=n))}if(null!==o){const e=("top"===n||"bottom"===n?t.width/2:t.height/2)-16-4;Math.abs(o)>e&&(o=o>0?e:-e)}return{top:i,left:s,position:n,arrowOffset:o}}(i,e,n):null}function pe(e,t,n){const i=de(e,t,n);if(i)return i;for(const i of oe[n]){const n=de(e,t,i);if(n)return n}return null}function ue(e){const t=[];let n=e.parentElement;for(;n;){const e=getComputedStyle(n),i=e.overflow+e.overflowX+e.overflowY;ae.test(i)&&t.push(n),n=n.parentElement}return t}function ge(e){const t=H(e);t&&(t.classList.remove("gist-visible"),Array.from(t.classList).filter((e=>e.startsWith("gist-"))).forEach((e=>t.classList.remove(e))),t.style.removeProperty("height"),t.style.removeProperty("width"),t.innerHTML="")}function me(e){const t=H(e);if(t)return!(!t.style||!t.style.height||"0px"===t.style.height)}function fe(e,t,n=null){const i=document.getElementById(e);i&&(i.onload=()=>{!function(e,t,n=null){const i=document.getElementById(e);if(i?.contentWindow){const e={options:t,capabilities:he};n&&(t.stepId=n),i.contentWindow.postMessage(e,"*")}}(e,t,n)})}const he=["MultiStepDisplayTypes"];function we(e){if(!e.displaySettings)return;const t=Se(e.instanceId??""),n=document.getElementById(t);n?.contentWindow&&n.contentWindow.postMessage({action:"updateDisplaySettings",displaySettings:e.displaySettings},"*")}async function ye(){const e=document.querySelector(".gist-message");e&&(e.classList.remove("gist-visible"),await new Promise((e=>setTimeout(e,300)))),be()}function be(){const e=document.querySelector("#gist-embed-message");e&&e.parentNode?.removeChild(e)}const ve=new Map;function xe(e){const t=e.instanceId??"",n=ve.get(t);n&&(n.cleanup(),ve.delete(t));const i=H(`gist-tooltip-${t}`);i&&i.parentNode?.removeChild(i)}function Se(e){return`gist-${e}`}function Ie(){const e=document.querySelector(".gist-message");e&&e.classList.add("gist-visible")}const Ce="gist.web.customAttributes";let Ee=new Map;function $e(){const e=Array.from(Ee.entries()),t=new Date;t.setDate(t.getDate()+30),o(Ce,e,t),i(`Saved ${Ee.size} custom attributes to storage with TTL of 30 days`)}async function ke(e){const t=await Me();if(!t)return;const n=new Date;n.setMinutes(n.getMinutes()+60),o(t,e.filter(Le),n)}async function Pe(e,t){return a(e)?.find((e=>e.queueId===t))}function Le(e){return!(!e.properties?.gist||!e.properties.gist.broadcast)}function Te(e){if(!Le(e))return!1;const t=e.properties.gist.broadcast;return 0===t.frequency.delay&&0===t.frequency.count}async function Me(){const e=await U();return e?`gist.web.message.broadcasts.${e}`:null}function Ne(e,t){return`${e}.${t}.numberOfTimesShown`}function De(e,t){return`${e}.${t}.shouldShow`}!function(){const e=a(Ce);if(e)try{Ee=new Map(e)}catch{Ee=new Map}else Ee=new Map}();const Ae="gist.web.message.user";async function qe(e){const t=await Re();if(!t)return;const n=e.filter((e=>!(e.properties&&e.properties.gist&&e.properties.gist.broadcast))),i=new Date;i.setMinutes(i.getMinutes()+60),o(t,n,i)}async function Re(){const e=await U();return e?`${Ae}.${e}`:null}async function We(){const e=await U();return e?`${Ae}.${e}.seen`:null}async function Oe(e){const t=await U();return t?`${Ae}.${t}.message.${e}.loading`:null}async function Ue(e){const t=await U();return t?`${Ae}.${t}.message.${e}.state`:null}async function ze(e){const t=await Ue(e);t&&(r(t),i(`Cleared message state for queueId: ${e}`))}function Be(e){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.54223 5.33301L7.7089 9.33301L11.8756 5.33301L12.6121 6.04011L7.7089 10.7472L2.80566 6.04011L3.54223 5.33301Z" fill="${e}"/></svg>`}const Fe=`\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(Be("#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`,He="cioPreviewId",_e="cioPreviewSettings",je="gist.previewBar.collapsed",Ge="gist-pb-styles",Ve="gist-preview-bar",Xe={topLeft:"Top Left",topCenter:"Top Center",topRight:"Top Right",bottomLeft:"Bottom Left",bottomCenter:"Bottom Center",bottomRight:"Bottom Right"};let Je=null,Ye=[],Qe={},Ke=null,Ze=!1,et=!1,tt=5,nt=null,it=!0,st=!1,ot=!1,at=null,rt=null,lt=null;const ct=new Map;function dt(e,t={}){const n=document.createElement(e);for(const[e,i]of Object.entries(t))n[e]=i;return n}function pt(e,t){const n=dt("div",{className:"gist-pb-label-group"});return n.appendChild(dt("span",{className:"gist-pb-label",textContent:e})),n.appendChild(t),n}function ut(e,t){const n=dt("select",{className:"gist-pb-select"});for(const i of e){const e=dt("option",{value:i.value,textContent:i.label});i.value===t&&(e.selected=!0),n.appendChild(e)}return n}function gt(e,t,n){const i=dt("input",{className:"gist-pb-input",type:e,value:String(t)});return n&&(i.style.width=n),i}function mt(e,t){const n=Math.round(Math.min(100,Math.max(0,t))/100*255);return"#"+e.replace("#","").toUpperCase()+n.toString(16).padStart(2,"0").toUpperCase()}function ft(e){return!!("inline"!==e.displayType&&"tooltip"!==e.displayType||e.elementSelector?.trim())}function ht(e){if("overlay"===e.displayType&&J.includes(te(e.overlayPosition))){const{maxWidth:t,...n}=e;e=n}if(Qe=e,Ke){const t=Ye.findIndex((e=>e.stepName===Ke));-1!==t&&(Ye[t]={...Ye[t],displaySettings:{...e}})}if(!Je)return;const t=on.currentMessages.find((e=>e.instanceId===Je));t&&ft(e)&&(we(t),ie(t,e)&&Ht(t,Ke,e)),function(){const e=new URLSearchParams(window.location.search).get(He);e&&async function(e,t){try{return await E()(`/api/v1/preview/${e}`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})}catch(e){return C(e)}}(e,Ye).then((e=>{e&&404===e.status&&Je&&on.dismissMessage(Je)})).catch((()=>i("Failed to persist preview display settings")))}()}function wt(e){const t=e.value.trim();t&&!H(t)?e.classList.add("gist-pb-input--invalid"):e.classList.remove("gist-pb-input--invalid")}function yt(e,t){const n=gt("text",e.elementSelector||"","260px");n.placeholder="Element ID or selector",wt(n),n.addEventListener("change",(()=>{const e=n.value.trim(),t=Qe.elementSelector;e&&bt(e),ht({...Qe,elementSelector:e}),t&&t!==e&&vt(t),wt(n)}));const i=dt("button",{type:"button",className:"gist-pb-select-elem-btn",textContent:"Select Element"});ot&&(i.disabled=!0),i.addEventListener("click",(()=>St(n)));const s=dt("div",{className:"gist-pb-inline-row"});s.appendChild(n),s.appendChild(i),t.appendChild(pt("Element Selector",s))}function bt(e){if(!e||ct.has(e))return;const t=H(e);t&&ct.set(e,t.innerHTML)}function vt(e){const t=ct.get(e);if(void 0===t)return;const n=H(e);n&&(n.innerHTML=t)}function xt(){for(const e of ct.keys())vt(e);ct.clear()}function St(e){if(ot)return;ot=!0;const t=document.querySelector(`#${Ve} .gist-pb-select-elem-btn`);t&&(t.disabled=!0);const n={...Qe},s=on.currentMessages.find((e=>e.instanceId===Je))??null;s&&Ft(s),Qe.elementSelector&&vt(Qe.elementSelector);const o=dt("div",{className:"gist-pb-picker-overlay"});let a=null;const r=e=>{o.style.pointerEvents="none";const t=document.elementFromPoint(e.clientX,e.clientY);o.style.pointerEvents="all",t&&t!==a&&t!==o&&(a?.classList.remove("gist-pb-pick-highlight"),a=t,a.classList.add("gist-pb-pick-highlight"))},l=e=>{if("Escape"===e.key){if(d(),Qe=n,Ke){const e=Ye.findIndex((e=>e.stepName===Ke));-1!==e&&(Ye[e]={...Ye[e],displaySettings:{...n}})}s&&ft(n)&&Ht(s,Ke,n),It()}},c=t=>{t.preventDefault(),t.stopPropagation(),o.style.pointerEvents="none";const n=document.elementFromPoint(t.clientX,t.clientY);if(o.style.pointerEvents="all",n&&n!==o){n.classList.remove("gist-pb-pick-highlight");const t=document.getElementById(Ve)?.contains(n)?null:function(e){if(e.id){const t=CSS.escape(e.id);if(1===document.querySelectorAll(`#${t}`).length)return e.id}const t=[];let n=e;for(;n&&"BODY"!==n.tagName&&"HTML"!==n.tagName;){if(n.id){const e=CSS.escape(n.id);if(1===document.querySelectorAll(`#${e}`).length){t.unshift(`#${e}`);break}}let e=n.tagName.toLowerCase();n.className&&"string"==typeof n.className&&(e+=n.className.trim().split(/\s+/).filter(Boolean).map((e=>`.${CSS.escape(e)}`)).join(""));const i=n.parentElement;i&&(e+=`:nth-of-type(${Array.from(i.children).filter((e=>e.tagName===n.tagName)).indexOf(n)+1})`),t.unshift(e);try{if(1===document.querySelectorAll(t.join(" > ")).length)break}catch{}n=n.parentElement}const s=t.join(" > ");try{if(1!==document.querySelectorAll(s).length)return i("buildUniqueSelector: could not produce a unique selector for element"),null}catch{return null}return s}(n);if(null===t)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);e.value=t,bt(t);const o=Qe.elementSelector,a={...Qe,elementSelector:t},r=null!=s&&ft(a)&&ie(s,a);ht(a),o&&o!==t&&vt(o),s&&!r&&Ht(s,Ke,a)}d(),It()},d=()=>{a?.classList.remove("gist-pb-pick-highlight"),o.removeEventListener("mousemove",r),o.removeEventListener("click",c),document.removeEventListener("keydown",l),document.body.removeChild(o),ot=!1,at=null};at=d,o.addEventListener("mousemove",r),o.addEventListener("click",c),document.addEventListener("keydown",l),document.body.appendChild(o)}function It(){const e=document.getElementById(Ve);if(!e)return;if(e.classList.toggle("gist-pb-hidden",!Je&&!et),e.innerHTML="",!Je){if(et){const t=dt("div",{className:"gist-pb-controls-row gist-pb-ended-row"}),n=dt("span",{className:"gist-pb-ended-icon",textContent:"✓"}),i=dt("p",{className:"gist-pb-ended-text"});if(i.innerHTML=Ct(tt),t.appendChild(n),t.appendChild(i),it){const e=dt("button",{type:"button",className:"gist-pb-cancel-btn",textContent:"Cancel"});e.addEventListener("click",Et),t.appendChild(e)}e.appendChild(t)}return}const t=dt("div",{className:"gist-pb-toggle-row"+(Ze?" gist-pb-toggle-row--collapsed":"")}),n=dt("button",{type:"button",className:"gist-pb-toggle-btn"}),i=Ze?"transform:rotate(180deg);display:inline-flex;":"display:inline-flex;";if(n.innerHTML=`${Ze?"Expand":"Collapse"}<span style="${i}">${Be("white")}</span>`,n.addEventListener("click",$t),t.appendChild(n),e.appendChild(t),Ze)return;const s=dt("div",{className:"gist-pb-controls-row"});if(Ye.length>0){const e=Ke??Ye[0].stepName,t=ut(Ye.map((e=>({value:e.stepName,label:e.stepName}))),e);t.addEventListener("change",(()=>{const e=Ye.find((e=>e.stepName===t.value));if(e){Ke=e.stepName,Qe={...e.displaySettings};const t=on.currentMessages.find((e=>e.instanceId===Je));t&&ft(e.displaySettings)&&Ht(t,e.stepName,e.displaySettings),It()}})),s.appendChild(pt("Step",t))}const o=ut([{value:"modal",label:"Modal"},{value:"overlay",label:"Overlay"},{value:"inline",label:"Inline"},{value:"tooltip",label:"Tooltip"}],Qe.displayType||"modal");o.addEventListener("change",(()=>{const e=o.value,t=Qe.displayType,n=Qe.elementSelector,i={...Qe,displayType:e};"modal"===e?(i.modalPosition=i.modalPosition||"center",i.maxWidth=i.maxWidth??414,delete i.overlayPosition,delete i.elementSelector,delete i.tooltipPosition):"overlay"===e?(i.overlayPosition=i.overlayPosition||"topCenter",i.maxWidth=i.maxWidth??414,delete i.modalPosition,delete i.elementSelector,delete i.tooltipPosition):"inline"===e?(delete i.modalPosition,delete i.overlayPosition,delete i.tooltipPosition):"tooltip"===e&&(i.tooltipPosition=i.tooltipPosition||"top",delete i.modalPosition,delete i.overlayPosition,delete i.overlayColor,delete i.dismissOutsideClick),Qe=i,ht(Qe),"inline"!==t&&"tooltip"!==t||!n||"inline"===e||"tooltip"===e||vt(n),It()})),s.appendChild(pt("Display Type",o));const a=Qe.displayType||"modal";"modal"===a?function(e,t){const n=ut([{value:"top",label:"Top"},{value:"center",label:"Center"},{value:"bottom",label:"Bottom"}],e.modalPosition||"center");n.addEventListener("change",(()=>ht({...Qe,modalPosition:n.value}))),t.appendChild(pt("Position",n));const i=gt("number",e.maxWidth??414,"80px");i.addEventListener("change",(()=>ht({...Qe,maxWidth:parseInt(i.value)||414}))),t.appendChild(pt("Max Width",i)),t.appendChild(function(e){const{color:t,opacity:n}=function(e){const t=e.replace("#","");return 8===t.length?{color:"#"+t.slice(0,6).toUpperCase(),opacity:Math.round(parseInt(t.slice(6),16)/255*100)}:6===t.length?{color:"#"+t.toUpperCase(),opacity:100}:{color:"#000000",opacity:20}}(e.overlayColor||"#00000033"),i=dt("div",{className:"gist-pb-color-control"}),s=dt("input",{className:"gist-pb-color-input",type:"color",value:t}),o=dt("div",{className:"gist-pb-color-swatch"});o.style.background=t,o.appendChild(s),o.addEventListener("click",(()=>s.click()));const a=dt("input",{className:"gist-pb-color-hex",type:"text",maxLength:6,value:t.replace("#","")}),r=dt("input",{className:"gist-pb-color-opacity",type:"number",min:"0",max:"100",value:String(n)}),l=dt("span",{className:"gist-pb-color-pct",textContent:"%"}),c=()=>{const e="#"+a.value.replace("#",""),t=parseInt(r.value)||0;o.style.background=e,s.value=e,ht({...Qe,overlayColor:mt(e,t)})};return s.addEventListener("input",(()=>{a.value=s.value.replace("#","").toUpperCase(),o.style.background=s.value})),s.addEventListener("change",c),a.addEventListener("change",c),r.addEventListener("change",c),i.appendChild(o),i.appendChild(a),i.appendChild(r),i.appendChild(l),pt("Overlay Color",i)}(e));const s=dt("div",{className:"gist-pb-checkbox-row"}),o=dt("input",{className:"gist-pb-checkbox",type:"checkbox"});o.checked=e.dismissOutsideClick??!1;const a=dt("label",{className:"gist-pb-checkbox-label",textContent:"Dismiss on click outside"});o.addEventListener("change",(()=>ht({...Qe,dismissOutsideClick:o.checked}))),a.addEventListener("click",(()=>{o.checked=!o.checked,ht({...Qe,dismissOutsideClick:o.checked})})),s.appendChild(o),s.appendChild(a);const r=pt(" ",s);r.classList.add("gist-pb-label-group--grow"),r.firstChild.classList.add("gist-pb-label--spacer"),t.appendChild(r)}(Qe,s):"overlay"===a?function(e,t){const n=ut(Object.entries(Xe).map((([e,t])=>({value:e,label:t}))),e.overlayPosition||"topCenter");if(n.addEventListener("change",(()=>ht({...Qe,overlayPosition:n.value}))),t.appendChild(pt("Position",n)),!J.includes(te(e.overlayPosition))){const n=gt("number",e.maxWidth??414,"80px");n.addEventListener("change",(()=>ht({...Qe,maxWidth:parseInt(n.value)||414}))),t.appendChild(pt("Max Width",n))}}(Qe,s):"inline"===a?function(e,t){yt(e,t)}(Qe,s):"tooltip"===a&&function(e,t){const n=ut([{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],e.tooltipPosition||"top");n.addEventListener("change",(()=>ht({...Qe,tooltipPosition:n.value}))),t.appendChild(pt("Position",n)),yt(e,t)}(Qe,s),s.appendChild(dt("div",{className:"gist-pb-spacer"}));const r=dt("button",{type:"button",className:"gist-pb-save-btn",textContent:"End session"});r.addEventListener("click",(async()=>{Je&&await on.dismissMessage(Je)})),s.appendChild(r),e.appendChild(s)}function Ct(e){return it?`<strong>Preview session ended.</strong> This tab will close in ${e}s…`:`<strong>Preview session ended.</strong> Finishing session in ${e}s… This tab will stay open.`}function Et(){et&&nt&&(it=!1,It())}function $t(){Ze=!Ze;try{sessionStorage.setItem(je,String(Ze))}catch{}It()}function kt(){xt(),Je=null,Ye=[],Qe={},Ke=null,et=!0,tt=5,it=!0,st=!1;const e=new URLSearchParams(window.location.search).get(He);e&&async function(e){try{return await E()(`/api/v1/preview/${e}`,{method:"DELETE"})}catch(e){return C(e)}}(e).catch((()=>i("Failed to delete preview session"))),It(),nt&&clearInterval(nt),nt=setInterval((async()=>{if(tt-=1,tt<=0)clearInterval(nt),nt=null,await async function(){if(!st)if(st=!0,B(),function(){try{sessionStorage.removeItem(s)}catch{}}(),it){try{window.close()}catch{}try{window.location.reload()}catch{}at&&at(),nt&&(clearInterval(nt),nt=null),xt(),document.getElementById(Ve)?.remove(),document.getElementById(Ge)?.remove(),Je=null,Ye=[],Qe={},Ke=null,et=!1,tt=5,it=!0,st=!1}else et=!1,st=!1,It()}();else{const e=document.querySelector(`#${Ve} .gist-pb-ended-text`);e?e.innerHTML=Ct(tt):It()}}),1e3)}async function Pt(e){if(!on.isDocumentVisible)return i("Document hidden, not showing message now."),null;if(Q(e.queueId))return i(`Message with queueId ${e.queueId} is already showing.`),null;const t=G(e);return!e.tooltipPosition&&t.hasTooltipPosition&&(e.tooltipPosition=t.tooltipPosition),e.tooltipPosition?function(e,t){const n=t.elementId||e.elementId;if(!n)return i(`No target selector specified for tooltip message ${e.messageId}`),on.messageError(e),null;if(!H(n)){if(!on.config.isPreviewSession||!e.properties?.gist?.livePreview)return i(`Tooltip target element "${n}" not found for message ${e.messageId}, skipping display`),on.messageError(e),null;i(`Preview: tooltip target "${n}" not found, loading message for preview bar`)}const s=on.currentMessages.find((e=>e.tooltipPosition&&e.elementId===n));return s&&(i(`Tooltip already showing on target "${n}" (instance ${s.instanceId}), dismissing it first`),on.messageDismissed(s),xe(s),s.instanceId&&Z(s.instanceId)),e.instanceId=w(),e.overlay=!1,e.firstLoad=!0,e.shouldResizeHeight=!1,e.shouldScale=!1,e.renderStartTime=(new Date).getTime(),e.elementId=n,on.currentMessages.push(e),Wt(e,null,e.savedStepName||null)}(e,t):on.overlayInstanceId?(i(`Message ${on.overlayInstanceId} already showing.`),null):(e.instanceId=w(),e.overlay=!0,e.firstLoad=!0,e.shouldResizeHeight=!0,e.shouldScale=t.shouldScale,e.renderStartTime=(new Date).getTime(),on.overlayInstanceId=e.instanceId,on.currentMessages.push(e),Wt(e,null,e.savedStepName||null))}function Lt(e,t){return on.isDocumentVisible?Q(e.queueId)?(i(`Message with queueId ${e.queueId} is already showing.`),null):K(t)?(i(`Message with elementId ${t} already has a message.`),null):(e.instanceId=w(),e.overlay=!1,e.firstLoad=!0,e.shouldScale=!1,e.elementId=t,e.shouldResizeHeight=!me(t),e.renderStartTime=(new Date).getTime(),on.currentMessages.push(e),Wt(e,t,e.savedStepName||null)):(i("Document hidden, not showing message now."),null)}async function Tt(e){e?(on.messageDismissed(e),await Mt(e)):i("Message not found")}async function Mt(e){"tooltip"===ne(e)?At(e):e.overlay?await qt(!0,e):Dt(e)}async function Nt(e){e?G(e).persistent&&(i("Persistent message dismissed, logging view"),await _t(e),await Ot(e),await ze(e.queueId??"")):i("Message not found")}function Dt(e){e.instanceId&&Z(e.instanceId),e.elementId&&ge(e.elementId),on.config.isPreviewSession&&(kt(),Rt())}function At(e){xe(e),e.instanceId&&Z(e.instanceId),0===on.currentMessages.length&&(window.removeEventListener("message",zt),window.removeEventListener("touchstart",Ut)),on.config.isPreviewSession&&(kt(),Rt())}async function qt(e,t){e?await ye():be(),0===on.currentMessages.length&&(window.removeEventListener("message",zt),window.removeEventListener("touchstart",Ut)),t.instanceId&&Z(t.instanceId),on.overlayInstanceId=null,on.config.isPreviewSession&&(kt(),Rt())}function Rt(){const e=new URL(window.location.href);e.searchParams.delete(He),e.searchParams.delete(_e),history.replaceState(null,"",e.toString())}function Wt(e,t=null,n=null){const s=on.config.env,o={endpoint:S.ENGINE_API_ENDPOINT[s],siteId:on.config.siteId,dataCenter:on.config.dataCenter,messageId:e.messageId,instanceId:e.instanceId??"",livePreview:!1,properties:e.properties,customAttributes:Object.fromEntries(new Map(Ee))},a=`${S.GIST_VIEW_ENDPOINT[s]}/index.html`;return window.addEventListener("message",zt),window.addEventListener("touchstart",Ut),"tooltip"===ne(e)?function(e,t,n,i=null){const s=t.instanceId??"",o=Se(s),a=G(t),r=ve.get(s);r&&(r.cleanup(),ve.delete(s)),document.querySelectorAll(`#gist-tooltip-${s}`).forEach((e=>{e.parentNode?.removeChild(e)}));const l=`gist-tooltip-${s}`,c=document.createElement("div");c.id=l,c.innerHTML=function(e,t,n,i=""){let s=600;t.messageWidth>s&&(s=t.messageWidth);const o=t.tooltipArrowColor,a=function(e){switch(e){case"top":default:return"gist-arrow-bottom";case"bottom":return"gist-arrow-top";case"left":return"gist-arrow-right";case"right":return"gist-arrow-left"}}(t.tooltipPosition),r=i?`#${i} `:"";return`\n <div class="gist-tooltip-outer">\n <style>\n ${r}.gist-tooltip-outer {\n position: absolute;\n }\n ${r}.gist-tooltip-container {\n position: relative;\n z-index: 9999999;\n opacity: 0;\n transition: opacity 0.3s ease-in-out;\n }\n ${r}.gist-tooltip-container.gist-visible {\n opacity: 1;\n }\n ${r}.gist-tooltip-frame-clip {\n overflow: hidden;\n }\n ${r}.gist-tooltip-frame {\n display: block;\n width: ${t.messageWidth}px;\n border: none;\n transition: height 0.1s ease-in-out;\n }\n ${r}.gist-tooltip-arrow {\n width: 0;\n height: 0;\n position: absolute;\n z-index: 1;\n }\n ${r}.gist-tooltip-arrow.gist-arrow-bottom {\n bottom: 0;\n left: 50%;\n transform: translateX(-50%) translateY(100%);\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n border-top: 10px solid ${o};\n }\n ${r}.gist-tooltip-arrow.gist-arrow-top {\n top: 0;\n left: 50%;\n transform: translateX(-50%) translateY(-100%);\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n border-bottom: 10px solid ${o};\n }\n ${r}.gist-tooltip-arrow.gist-arrow-right {\n right: 0;\n top: 50%;\n transform: translateY(-50%) translateX(100%);\n border-top: 10px solid transparent;\n border-bottom: 10px solid transparent;\n border-left: 10px solid ${o};\n }\n ${r}.gist-tooltip-arrow.gist-arrow-left {\n left: 0;\n top: 50%;\n transform: translateY(-50%) translateX(-100%);\n border-top: 10px solid transparent;\n border-bottom: 10px solid transparent;\n border-right: 10px solid ${o};\n }\n @media (max-width: ${s}px) {\n ${r}.gist-tooltip-frame {\n max-width: 100%;\n }\n }\n </style>\n <div class="gist-tooltip-container">\n <div class="gist-tooltip-arrow ${a}"></div>\n <div class="gist-tooltip-frame-clip">\n <iframe id="${e}" class="gist-tooltip-frame" src="${n}"></iframe>\n </div>\n </div>\n </div>`}(o,a,e,l),document.body.appendChild(c),fe(o,n,i)}(a,e,o,n):t?(V.includes(t)&&X(t),function(e,t,n,s,o=null){const a=H(e);if(a){const i=Se(n.instanceId??"");a.classList.add(i);const r=G(n);let l=r.messageWidth+"px";J.includes(e)&&!r.hasCustomWidth&&(l="100%"),V.includes(e)&&(a.style.width=l),me(e)||(a.style.height="0px"),a.innerHTML=function(e,t,n){return function(e,t,n){let i=800;return t.messageWidth>i&&(i=t.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 }\n #x-gist-top.${e},\n #x-gist-bottom.${e},\n #x-gist-floating-top.${e},\n #x-gist-floating-bottom.${e},\n #x-gist-floating-top-left.${e},\n #x-gist-floating-top-right.${e},\n #x-gist-floating-bottom-left.${e},\n #x-gist-floating-bottom-right.${e} {\n transition: height 0.1s ease-in-out;\n }\n @media (max-width: ${i}px) {\n #x-gist-top.${e},\n #x-gist-bottom.${e},\n #x-gist-floating-top.${e},\n #x-gist-floating-bottom.${e},\n #x-gist-floating-top-left.${e},\n #x-gist-floating-top-right.${e},\n #x-gist-floating-bottom-left.${e},\n #x-gist-floating-bottom-right.${e} {\n width: 100% !important;\n }\n }\n </style>\n <div id="gist-embed-container">\n <iframe id="${e}" class="gist-frame" src="${n}"></iframe>\n </div>\n </div>`}(Se(t.instanceId??""),n,e)}(t,n,r),fe(i,s,o)}else i(`Message could not be embedded, elementId ${e} not found.`)}(t,a,e,o,n)):function(e,t,n,i=null){document.querySelectorAll("#gist-embed-message").forEach((e=>{e.parentNode?.removeChild(e)})),document.body.insertAdjacentHTML("afterbegin",function(e,t){const n=G(t);return function(e,t,n){let i=600;return t.messageWidth>i&&(i=t.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: ${t.overlayColor};\n visibility: hidden;\n }\n #gist-overlay.gist-background.gist-visible {\n visibility: visible;\n }\n .gist-message {\n width: ${t.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 }\n .gist-message.gist-visible {\n opacity: 1;\n pointer-events: auto;\n }\n .gist-message.gist-center {\n transform: translate(-50%, -50%);\n top: 50%;\n }\n .gist-message.gist-bottom {\n bottom: 0;\n }\n .gist-message.gist-top {\n top: 0;\n }\n @media (max-width: ${i}px) {\n .gist-message {\n width: 100%;\n }\n }\n </style>\n <div id="gist-overlay" class="gist-background">\n <iframe id="${e}" class="gist-message" src="${n}"></iframe>\n </div>\n </div>`}(Se(t.instanceId??""),n,e)}(e,t)),fe(Se(t.instanceId??""),n,i)}(a,e,o,n),e}async function Ot(e){let t;i(`Message shown, logging view for: ${e.messageId}`),null!=e.queueId?(await _t(e),t=await F(e.queueId)):t=await async function(e){try{return await E().post(`/api/v1/logs/message/${e}`)}catch(e){return C(e)}}(e.messageId),i(200===t?.status?"Message view logged":`Problem logging message: ${t?.status}`)}function Ut(){}async function zt(e){const t=e.data;if(t.gist&&e.origin===S.RENDERER_HOST){const e=t.gist.instanceId,n=Y(e);if(!n)return;const s=G(n);switch(t.gist.method){case"routeLoaded":{const o=.001*((new Date).getTime()-(n.renderStartTime??0));if(i(`Engine render for message: ${n.messageId} timer elapsed in ${o.toFixed(3)} seconds`),async function(e){const t=await Oe(e);t&&r(t)}(n.queueId??""),n.currentRoute=t.gist.parameters.route,t.gist.parameters.fullDisplaySettings&&!n.displaySettings?n.displaySettings=t.gist.parameters.fullDisplaySettings:n.displaySettings&&(i("SDK already has display settings state, sending it to iframe"),we(n)),on.config.isPreviewSession&&n.properties?.gist?.livePreview&&function(e){if(et)return;Je=e.instanceId??null;const t=e.displaySettings;if(Array.isArray(t)&&t.length>0?(Ye=t,Ke||(Ke=Ye[0].stepName,Qe={...Ye[0].displaySettings})):t&&"object"==typeof t&&!Array.isArray(t)&&(Qe={...t}),rt||lt){const e=!!rt,t=!!lt,n=rt,s=lt;if(rt=null,lt=null,e){const e=Ye.find((e=>e.stepName===n));if(!e)return i(`Preview bar: step "${n}" not found, ignoring initial step/display override`),void It();Ke=e.stepName,Qe={...e.displaySettings}}if(t){if(!e)return i(`Preview bar: display type "${s}" provided without a step, ignoring`),void It();Qe={...Qe,displayType:s}}It();const o=on.currentMessages.find((e=>e.instanceId===Je));o&&ft(Qe)?Ht(o,Ke,Qe):function(){const e=Qe.displayType;if("inline"!==e&&"tooltip"!==e)return;const t=document.querySelector("#gist-preview-bar .gist-pb-input[type='text']");t&&St(t)}()}else It()}(n),n.firstLoad||n.isDisplayChange){if("tooltip"===ne(n)){const e=n.properties?.gist?.elementId||n.elementId||void 0;if(!e||!H(e)){if(on.config.isPreviewSession&&n.properties?.gist?.livePreview){i(`Preview: tooltip target "${e}" not found, preview bar will show element picker`),n.firstLoad=!1,n.isDisplayChange=!1;break}i(`Tooltip target not found for "${e}", emitting error and skipping display`),on.messageError(n),n.firstLoad=!1,n.isDisplayChange=!1,At(n);break}const t=await async function(e){const t=e.instanceId??"",n=G(e),s=`gist-tooltip-${t}`,o=H(s);if(!o)return i(`Tooltip wrapper not found for instance ${t}`),!1;const a=e.properties?.gist?.elementId||e.elementId||void 0;if(!a)return i(`No target selector for tooltip ${t}`),!1;const r=ve.get(t);r&&(r.cleanup(),ve.delete(t));const l=o.querySelector(".gist-tooltip-outer");if(!l)return i(`Tooltip inner element not found for instance ${t}`),!1;const c=n.tooltipPosition||"bottom";if(!await async function(e,t,n){const s=le(t);if(!s)return!1;let o=[];try{o=ue(s)}catch{}if(ce(s.getBoundingClientRect(),o))return!0;if(!function(e,t,n){const i=le(t);if(!i)return!1;const s=i.getBoundingClientRect(),o=window.innerWidth,a=window.innerHeight,r=new DOMRect(Math.max(0,(o-s.width)/2),Math.max(0,(a-s.height)/2),s.width,s.height);return e.style.display="",null!==pe(e.getBoundingClientRect(),r,n)}(e,t,n))return i(`Preflight failed: tooltip would not fit after scrolling target "${t}" into view`),!1;s.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),await function(e){return new Promise((t=>{let n=e.getBoundingClientRect(),i=0;const s=Date.now();setTimeout((function o(){const a=e.getBoundingClientRect();Math.abs(a.top-n.top)<1&&Math.abs(a.left-n.left)<1?i++:i=0,n=a,i>=2||Date.now()-s>1e3?t():setTimeout(o,50)}),50)}))}(s);const a=s.getBoundingClientRect();let r=[];try{r=ue(s)}catch{}return ce(a,r)}(l,a,c))return i(`Tooltip for instance ${t} skipped: target "${a}" is off-screen and cannot be scrolled into a valid position`),!1;const d=function(e,t,n,s){const o=le(t);if(!o)return null;let a=null,r=null,l=!1,c=[],d=null;try{c=ue(o)}catch{}function p(){if(l)return;if(!o||!document.contains(o)||!document.contains(e))return i("Tooltip or target element removed from DOM, cleaning up listeners"),g(),void s?.onDetach?.();const t=o.getBoundingClientRect();if(!ce(t,c))return void(e.style.display="none");e.style.display="";const a=pe(e.getBoundingClientRect(),t,n);a?(function(e,t){e.style.position="absolute",e.style.top=`${t.top+window.scrollY}px`,e.style.left=`${t.left+window.scrollX}px`}(e,a),function(e,t){const n=e.querySelector(".gist-tooltip-arrow");n&&(n.classList.remove("gist-arrow-top","gist-arrow-bottom","gist-arrow-left","gist-arrow-right"),n.classList.add(re[t.position]),null!==t.arrowOffset?"top"===t.position||"bottom"===t.position?(n.style.left=`calc(50% + ${t.arrowOffset}px)`,n.style.removeProperty("top")):(n.style.top=`calc(50% + ${t.arrowOffset}px)`,n.style.removeProperty("left")):"top"===t.position||"bottom"===t.position?(n.style.left="50%",n.style.removeProperty("top")):(n.style.top="50%",n.style.removeProperty("left")))}(e,a)):e.style.display="none"}function u(){null===a&&(a=requestAnimationFrame((()=>{a=null,p()})))}function g(){if(!l){l=!0,d&&(d.disconnect(),d=null),window.removeEventListener("scroll",u),window.removeEventListener("resize",u);for(const e of c)e.removeEventListener("scroll",u);null!==a&&(cancelAnimationFrame(a),a=null),null!==r&&(cancelAnimationFrame(r),r=null)}}if(p(),l)return null;window.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",u,{passive:!0});for(const e of c)e.addEventListener("scroll",u,{passive:!0});try{d=new MutationObserver((()=>{null===r&&(r=requestAnimationFrame((()=>{r=null,document.contains(o)||p()})))})),d.observe(document.body,{childList:!0,subtree:!0})}catch{}return{cleanup:g,reposition:p}}(l,a,c,{onDetach:()=>{ve.delete(t);const e=H(s);e&&e.parentNode?.removeChild(e)}});if(d){if("none"!==l.style.display){const e=o.querySelector(".gist-tooltip-container");return e?(ve.set(t,d),e.classList.add("gist-visible"),!0):(d.cleanup(),i(`Tooltip container not found for instance ${t}`),!1)}return d.cleanup(),i(`Tooltip for instance ${t} could not be positioned within the viewport, target "${a}" may be off-screen`),!1}return i(`Failed to position tooltip for instance ${t}, target "${a}" may not exist or no position fits the viewport`),!1}(n);if(!t){if(on.config.isPreviewSession&&n.properties?.gist?.livePreview){i(`Preview: tooltip positioning failed for "${e}", preview bar will remain active`),n.firstLoad=!1,n.isDisplayChange=!1;break}i(`Tooltip positioning failed for "${e}", emitting error and cleaning up`),on.messageError(n),n.firstLoad=!1,n.isDisplayChange=!1,At(n);break}}else n.overlay?function(e){const t=G(e),n=document.querySelector("#gist-overlay");if(n){n.classList.add("gist-visible");const i=document.querySelector(".gist-message");i&&(e.position?i.classList.add("gist-"+e.position):i.classList.add("gist-center")),setTimeout(Ie,100),t.exitClick&&setTimeout((()=>function(e){const t=document.querySelector("#gist-overlay");t&&t.addEventListener("click",(()=>{on.dismissMessage(e)}))}(e.instanceId??"")),1e3)}else be()}(n):function(e){const t=H(e);t&&t.classList.add("gist-visible")}(n.elementId);n.firstLoad&&!n.isDisplayChange&&(on.messageShown(n),s.persistent?i("Persistent message shown, skipping logging view"):await Ot(n)),n.firstLoad=!1,n.isDisplayChange=!1}ee(e,n);break}case"tap":{const e=t.gist.parameters.action,i=t.gist.parameters.name;if(on.messageAction(n,e,i),t.gist.parameters.system&&!s.persistent){await Tt(n);break}try{const t=new URL(e);if(t&&"gist:"===t.protocol)switch(t.href.replace("gist://","").split("?")[0]){case"close":await Nt(n),await jt(n),await Tt(n),await en();break;case"showMessage":{const e=t.searchParams.get("messageId"),n=t.searchParams.get("properties");if(e){const t=n?JSON.parse(atob(n)):void 0;await on.showMessage({messageId:e,properties:t})}break}case"loadPage":{const e=t.href.substring(t.href.indexOf("?url=")+5);e&&(e.startsWith("mailto:")||e.startsWith("https://")||e.startsWith("http://")||e.startsWith("/")?window.location.href=e:window.location.href=window.location+e);break}}}catch{}break}case"changeMessageStep":{const e=t.gist.parameters.displaySettings,r=t.gist.parameters.messageStepName;on.config.isPreviewSession&&r&&n.properties?.gist?.livePreview&&function(e,t){if(et)return;Ke=e;const n=Ye.find((t=>t.stepName===e));n?Qe={...n.displaySettings}:t&&(Qe={...t}),It()}(r,e),(s.persistent||Te(n))&&await async function(e,t,n){const s=await Ue(e);if(!s)return;const r=a(s)||{},l={stepName:void 0!==t?t:r.stepName,displaySettings:void 0!==n?n:r.displaySettings},c=new Date;c.setDate(c.getDate()+30),o(s,l,c),i(`Saved message state for queueId: ${e}`)}(n.queueId??"",r,e),e&&ie(n,e)&&(i("Display settings changed, reloading message"),await Ft(n),se(n,e),await Bt(n,r??null));break}case"routeChanged":n.currentRoute=t.gist.parameters.route,n.renderStartTime=(new Date).getTime(),ee(e,n),i(`Route changed to: ${n.currentRoute}`);break;case"sizeChanged":i(`Size Changed Width: ${t.gist.parameters.width} - Height: ${t.gist.parameters.height}`),"tooltip"===ne(n)?function(e,t){const n=e.instanceId??"",i=Se(n),s=document.getElementById(i);if(s&&t.height>0){s.style.height=`${t.height}px`;const e=ve.get(n);e&&e.reposition()}}(n,t.gist.parameters):n.elementId&&!n.shouldResizeHeight||function(e,t){const n=H(e.elementId?e.elementId:Se(e.instanceId??""));if(n){const i=n.style;if(t.height>0)if(t.height>window.innerHeight){const n=1-(t.height/window.innerHeight-1);e.shouldScale&&n>=.4?(i.height=`${t.height}px`,i.transform=`translateX(-50%) translateY(-50%) scale(${n})`):i.height=`${window.innerHeight}px`}else i.height=`${t.height}px`}}(n,t.gist.parameters);break;case"titleChanged":i(`Overlay title changed to: ${t.gist.parameters.title}`),function(e,t){const n=H(Se(e));n&&(n.title=t)}(e,t.gist.parameters.title);break;case"eventDispatched":on.events.dispatch("eventDispatched",{name:t.gist.parameters.name,payload:t.gist.parameters.payload});break;case"error":case"routeError":on.messageError(n),"tooltip"===ne(n)?At(n):on.overlayInstanceId?await qt(!1,n):Dt(n)}}}async function Bt(e,t){e.isDisplayChange=!0,e.renderStartTime=(new Date).getTime();const n=ne(e),s=e.elementId||null;if("tooltip"===n)return on.overlayInstanceId===e.instanceId&&(on.overlayInstanceId=null),e.shouldScale=!1,e.shouldResizeHeight=!1,void Wt(e,null,t);if(s){const t=K(s);t&&t.instanceId!==e.instanceId&&(i(`Dismissing existing message at ${s} to make room for multi-step message`),await Tt(t))}if(e.overlay){on.overlayInstanceId=e.instanceId??null;const t=G(e);e.shouldScale=t.shouldScale,e.shouldResizeHeight=!0}else on.overlayInstanceId=null,e.shouldScale=!1,e.shouldResizeHeight=!me(s??"");s&&V.includes(s)&&X(s),Wt(e,s,t)}async function Ft(e){"tooltip"===ne(e)?xe(e):e.overlay?await ye():e.elementId&&ge(e.elementId)}async function Ht(e,t,n){n&&ie(e,n)&&(await Ft(e),se(e,n)),await Bt(e,t??null)}async function _t(e){i(`Logging user message view locally for: ${e.queueId}`),Le(e)?await async function(e){i(`Marking broadcast ${e} as seen.`);const t=await Me();if(!t)return;const n=await Pe(t,e);if(!n)return;const s=n.properties.gist.broadcast,{frequency:r}=s,l=Ne(t,e),c=De(t,e),d=a(l)||0;if(o(l,d+1),1===r.count)o(c,!1),i(`Marked broadcast ${e} as seen.`);else{const t=new Date;t.setSeconds(t.getSeconds()+r.delay),o(c,!1,t),i(`Marked broadcast ${e} as seen, broadcast was seen ${d+1} times, next show date is ${t}.`)}}(e.queueId??""):await async function(e){const t=await We();if(!t)return;const n=a(t)??[];n.push(e),o(t,n)}(e.queueId??"")}async function jt(e){Le(e)&&(i(`Logging broadcast dismissed locally for: ${e.queueId}`),await async function(e){i(`Marking broadcast ${e} as dismissed.`);const t=await Me();if(!t)return;const n=await Pe(t,e);n&&(!0!==n.properties.gist.broadcast.frequency.ignoreDismiss?(o(De(t,e),!1),i(`Marked broadcast ${e} as dismissed and will not show again.`)):i(`Broadcast ${e} is set to ignore dismiss.`))}(e.queueId??""),await ze(e.queueId??""))}const Gt="messageInboxUpdated";async function Vt(e){const t=await Jt();if(!t)return;const n=new Date;n.setMinutes(n.getMinutes()+60),o(t,e,n),on.events.dispatch(Gt,e)}async function Xt(){const e=await Jt();if(!e)return[];const t=a(e)??[],n=new Date;return t.filter((e=>!e.expiry||new Date(e.expiry)>n))}async function Jt(){const e=await U();return e?`gist.web.inbox.messages.${e}`:null}const Yt=(e,t)=>e().then((e=>new Promise((t=>setTimeout(t,e))))(t).then((()=>Yt(e,t))));let Qt=!1,Kt=null;async function Zt(){Qt?await en():W()?(i("Queue watcher started"),Qt=!0,Yt((()=>new Promise((()=>{!async function(){if(S.hasActiveSSEConnection())return!S.isSSEConnectionManagedBySDK()&&Kt&&(i("Not the main instance, closing our SSE connection."),sn()),void await en();Kt&&(i("SSE connection not active, closing it."),sn()),!S.useSSE()||R()?await nn():await async function(){sn();const e=function(){const e=z();return null===e?(i("No user token available for SSE endpoint."),null):S.GIST_QUEUE_REALTIME_API_ENDPOINT[on.config.env??"prod"]+`/api/v3/sse?userToken=${e}&siteId=${on.config.siteId}&sessionId=${N()}`}();if(null===e)return i("SSE endpoint not available, falling back to polling."),void await nn();i(`Starting SSE queue listener on ${e}`),Kt=new EventSource(e),S.setActiveSSEConnection(),Kt.addEventListener("connected",(async e=>{try{i("SSE connection received"),S.setUseSSEFlag(!0);const t=JSON.parse(e.data);t.heartbeat&&(S.setSSEHeartbeat(t.heartbeat),i(`SSE heartbeat set to ${t.heartbeat} seconds`)),S.setActiveSSEConnection()}catch(e){i(`Failed to parse SSE settings: ${e}`)}r(T),await nn()})),Kt.addEventListener("messages",(async e=>{try{const t=JSON.parse(e.data);i("SSE message received"),await qe(t),await ke(t),await en()}catch(e){i(`Failed to parse SSE message: ${e}`),sn()}})),Kt.addEventListener("inbox_messages",(async e=>{try{const t=JSON.parse(e.data);i("SSE inbox messages received"),await Vt(t)}catch(e){i(`Failed to parse SSE inbox messages: ${e}`)}})),Kt.addEventListener("error",(async()=>{i("SSE error received"),sn()})),Kt.addEventListener("heartbeat",(async()=>{i("SSE heartbeat received"),S.setActiveSSEConnection(),S.setUseSSEFlag(!0)}))}()}()}))),1e3)):i("User token not setup, queue not started.")}async function en(){const e=await async function(){const e=await Me();return e?(a(e)??[]).filter((t=>{const n=t.properties.gist.broadcast,{frequency:i}=n,s=a(De(e,t.queueId))??!0,o=a(Ne(e,t.queueId))||0,r=0===i.count;return s&&(r||o<i.count)})):[]}(),t=await async function(){const e=await Re();if(!e)return[];const t=a(e)??[],n=await async function(){const e=await We();return e?a(e)??[]:[]}();return t.filter((e=>!n.includes(e.queueId??"")))}(),n=e.concat(t);i(`Messages in local queue: ${n.length}`);const s=n.sort(((e,t)=>e.priority-t.priority));for(const e of s)await tn(e)}async function tn(e){let t=G(e);if(t.hasRouteRule){let e=on.currentRoute;null==e&&(e=new URL(window.location.href).pathname);const n=t.routeRule;if(i(`Verifying route ${e} against rule: ${n}`),!new RegExp(n).test(e))return i(`Route ${e} does not match rule.`),!1}if(t.hasPosition&&(e.position=t.position),t.hasTooltipPosition&&(e.tooltipPosition=t.tooltipPosition),t.persistent||Te(e)){const n=await async function(e){const t=await Ue(e);return t?a(t):null}(e.queueId??"");n&&(i(`Restoring saved state for queueId ${e.queueId}`),n.displaySettings&&(se(e,n.displaySettings),t=G(e)),e.savedStepName=n.stepName??null)}if(t.persistent||Te(e)||!await async function(e){const t=await Oe(e);return!!t&&null!==a(t)}(e.queueId??"")){let n=null;return t.isEmbedded?!on.config.isPreviewSession||!e.properties?.gist?.livePreview||H(t.elementId)||V.includes(t.elementId)?n=Lt(e,t.elementId):(i(`Preview: element "${t.elementId}" not found, showing as overlay so placement can be changed`),n=await Pt(e)):n=await Pt(e),n&&async function(e){const t=await Oe(e);t&&o(t,!0,new Date(Date.now()+5e3))}(e.queueId??""),null!==n}return i(`Not showing message with queueId ${e.queueId} because its already loading.`),!1}async function nn(){if(W())if(on.isDocumentVisible)if(null===a(T)){const e=await async function(){const e=W();let t;try{if(!L){L=!0;const e={"X-Gist-User-Anonymous":String(R()),"Content-Language":String(k())};t=await E().post(`/api/v4/users?sessionId=${N()}`,{},{headers:e})}}catch(e){const n=C(e);n?t=n:i(`Error getting user queue: ${e}`)}finally{L=!1}return e!==W()?(i("User token changed, clearing queue next pull check."),void r(T)):(function(e){if(e?.headers){const t=e.headers["x-gist-queue-polling-interval"];t&&Number(t)>0&&(P=Number(t))}const t=new Date((new Date).getTime()+1e3*P);o(T,P,t)}(t),function(e){const t="true"===e?.headers?.["x-cio-use-sse"]?.toLowerCase();S.setUseSSEFlag(t)}(t),t)}();if(e){if(200===e.status||204===e.status){i("200 response, updating local store.");const t=e.data,n=t?.inAppMessages??[],s=t?.inboxMessages??[];qe(n),ke(n),Vt(s)}else 304===e.status&&i("304 response, using local store.");await en()}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 sn(e=!1){e&&S.removeActiveSSEConnection(),(e||S.isSSEConnectionManagedBySDK())&&S.setUseSSEFlag(!1),Kt&&(i("Stopping SSE queue listener..."),Kt.close(),Kt=null)}class on{static async setup(e){this.initialized?i("Gist SDK already initialized, skipping setup."):(this.initialized=!0,this.events=new n,this.config={useAnonymousSession:e.useAnonymousSession??!1,siteId:e.siteId,dataCenter:e.dataCenter,env:e.env??"prod",logging:e.logging??!1,experiments:e.experiments??!1},this.currentMessages=[],ve.forEach((e=>e.cleanup())),ve.clear(),document.querySelectorAll('[id^="gist-tooltip-"]').forEach((e=>{e.parentNode?.removeChild(e)})),this.overlayInstanceId=null,this.currentRoute=null,this.isDocumentVisible=!0,this.config.isPreviewSession=function(){const e=new URLSearchParams(window.location.search),t=e.get(He);if(t){sessionStorage.setItem(s,String(!1)),on.setUserToken(t),i(`Preview mode enabled with user token: ${t}`),function(){if(document.getElementById(Ve))return;!function(){if(document.getElementById(Ge))return;const e=document.createElement("style");e.id=Ge,e.textContent=Fe,document.head.appendChild(e)}();try{Ze="true"===sessionStorage.getItem(je)}catch{Ze=!1}const e=dt("div",{id:Ve});document.body.appendChild(e),It()}();const n=e.get(_e);if(n)try{const e=JSON.parse(atob(n)),t=e.stepName||null,i=e.displayType||null;(t||i)&&function(e,t){rt=e,lt=t}(t,i)}catch{i("Preview bar: failed to parse cioPreviewSettings")}}return!l()}(),function(){const e=c();for(let t=e.length-1;t>=0;t--){const n=e.key(t);n?.startsWith("gist.")&&d(n)}}(),i(`Setup complete on ${this.config.env} environment.`),this.config.isPreviewSession||!this.config.useAnonymousSession||new URLSearchParams(location.search).has("ajs_uid")||O(),await Zt(),document.addEventListener("visibilitychange",(async()=>{"hidden"===document.visibilityState?this.isDocumentVisible=!1:(this.isDocumentVisible=!0,await en())}),!1))}static async setCurrentRoute(e){this.currentRoute=e,i(`Current route set to: ${e}`),await async function(){if(0!==on.currentMessages.length)for(const e of[...on.currentMessages])null==document.querySelector(`#gist-${e.instanceId}`)&&(i(`Removing active message ${e.instanceId} that no longer exists after route change`),await Mt(e))}(),await en()}static async setUserToken(e,t){this.config.isPreviewSession||(function(e,t){void 0===t&&(t=new Date).setDate(t.getDate()+30),o(D,e,t),R()&&(r(T),r(A)),i(`Set user token "${e}" with expiry date set to ${t}`)}(e,t),sn(!0),await Zt())}static setUserLocale(e){var t;o($,t=e),i(`Set user locate to "${t}"`)}static setCustomAttribute(e,t){return function(e,t){return e&&"string"==typeof e?(Ee.set(e,t),$e(),i(`Set custom attribute "${e}" to "${t}"`),!0):(i(`Invalid key for custom attribute: ${e}`),!1)}(e,t)}static clearCustomAttributes(){Ee.clear(),r(Ce),i("Cleared all custom attributes")}static removeCustomAttribute(e){return function(e){if(!e||"string"!=typeof e)return i(`Invalid key for custom attribute: ${e}`),!1;const t=Ee.has(e);return Ee.delete(e),Ee.size>0?$e():r(Ce),i(`Removed custom attribute "${e}"`),t}(e)}static async clearUserToken(){this.config.isPreviewSession||(B(),this.config.useAnonymousSession&&O(),sn(!0),await Zt())}static async dismissMessage(e){const t=Y(e);t&&(await Nt(t),await jt(t),await Tt(t),await en())}static async embedMessage(e,t){return Lt(e,t)?.instanceId??null}static async showMessage(e){return(await Pt(e))?.instanceId??null}static updateMessageDisplaySettings(e,t){const n=Y(e);return!!n&&(n.displaySettings=t,we(n),!0)}static messageShown(e){i(`Message shown: ${e.messageId}`),this.events.dispatch("messageShown",e)}static messageDismissed(e){null!==e&&(i(`Message dismissed: ${e.messageId}`),this.events.dispatch("messageDismissed",e))}static messageError(e){i(`Message error: ${e.messageId}`),this.events.dispatch("messageError",e)}static messageAction(e,t,n){i(`Message action: ${e.currentRoute}, ${t} with name ${n} on ${e.instanceId}`),this.events.dispatch("messageAction",{message:e,action:t,name:n})}static async getInboxUnopenedCount(){return(await Xt()).filter((e=>!e.opened)).length}static async getInboxMessages(){return await Xt()}static async updateInboxMessageOpenState(e,t){return await async function(e,t){const n=await Jt();if(!n)return;const s=await async function(e,t){try{return await E()(`/api/v1/messages/${e}`,{method:"PATCH",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})}catch(e){return C(e)}}(e,{opened:t});if(!s||s.status<200||s.status>=300){const e=`Failed to mark inbox message opened: ${s?.status??"unknown error"}`;throw i(e),new Error(e)}const a=await Xt();let r=null;const l=a.map((n=>{if(n.queueId===e){const e={...n,opened:t};return r=e,e}return n})),c=new Date;if(c.setMinutes(c.getMinutes()+60),o(n,l,c),r){const e=t?"opened":"unopened";on.events.dispatch("inboxMessageAction",{message:r,action:e})}on.events.dispatch(Gt,await Xt())}(e,t)}static async removeInboxMessage(e){return await async function(e){const t=await Jt();if(!t)return;const n=await F(e);if(!n||n.status<200||n.status>=300){const e=`Failed to remove inbox message: ${n?.status??"unknown error"}`;throw i(e),new Error(e)}const s=(await Xt()).filter((t=>t.queueId!==e)),a=new Date;a.setMinutes(a.getMinutes()+60),o(t,s,a),on.events.dispatch(Gt,await Xt())}(e)}}return t.default})(),e.exports=t()}}]);
|
package/dist/umd/573.js.gz
CHANGED
|
Binary file
|