@customerio/cdp-analytics-browser 0.4.9 → 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.
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // This file is generated.
5
- exports.version = '0.4.9';
5
+ exports.version = '0.4.11';
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/generated/version.ts"],"names":[],"mappings":";;;AAAA,0BAA0B;AACb,QAAA,OAAO,GAAG,OAAO,CAAA"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/generated/version.ts"],"names":[],"mappings":";;;AAAA,0BAA0B;AACb,QAAA,OAAO,GAAG,QAAQ,CAAA"}
@@ -1,3 +1,3 @@
1
1
  // This file is generated.
2
- export var version = '0.4.9';
2
+ export var version = '0.4.11';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/generated/version.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,MAAM,CAAC,IAAM,OAAO,GAAG,OAAO,CAAA"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/generated/version.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAA"}
@@ -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.9";
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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/buffer/index.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/buffer/index.ts"],"names":[],"mappings":"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"}
@@ -1,2 +1,2 @@
1
- export declare const version = "0.4.9";
1
+ export declare const version = "0.4.11";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/generated/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,UAAU,CAAA"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/generated/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,WAAW,CAAA"}
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:()=>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 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)},b="gist.web.userQueueUseSSE",y="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(b)??!1,setUseSSEFlag(e){s(b,e,new Date((new Date).getTime()+6e4)),i(`Set user uses SSE to "${e}"`)},removeActiveSSEConnection(){r(y)},setActiveSSEConnection(){s(y,S.getSdkId(),new Date((new Date).getTime()+S.getSSEHeartbeat()))},hasActiveSSEConnection:()=>a(y)??!1,isSSEConnectionManagedBySDK:()=>a(y)===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 E(e){return I(e)?e.response:void 0}function $(){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 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 C="gist.web.userLocale";function k(){const e=a(C);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",q="gist.web.usingGuestUserToken",A="gist.web.guestUserToken";function R(){return null!==a(q)}function W(){return a(D)}function O(){if(null===W()){let e=a(A);null==e&&(e=w(),s(A,e),i(`Set guest user token "${e}" with expiry date set to 1 year from today`)),s(D,e),s(q,!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 $().post(`/api/v1/logs/queue/${e}`)}catch(e){return E(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){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:n.tooltipArrowColor||t.tooltipArrowColor,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 G=["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 V(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 X=["x-gist-top","x-gist-bottom","x-gist-floating-top","x-gist-floating-bottom"];function J(e){return on.currentMessages.find((t=>t.instanceId===e))}function Y(e){return!!e&&on.currentMessages.some((t=>t.queueId===e))}function Q(e){return e?on.currentMessages.find((t=>t.elementId===e))??null:null}function K(e){on.currentMessages=on.currentMessages.filter((t=>t.instanceId!==e))}function Z(e,t){K(e),on.currentMessages.push(t)}function ee(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 te(e){return e.tooltipPosition?"tooltip":e.overlay?"modal":e.elementId&&G.includes(e.elementId)?"overlay":e.elementId?"inline":"modal"}function ne(e,t){const n=te(e),i=t.displayType;if(void 0===i)return!1;if(n!==i)return!0;const o=j(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=ee(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||!X.includes(ee(t.overlayPosition))){const e=t.maxWidth??_.messageWidth;if(o.messageWidth!==e)return!0}return!1}function ie(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=ee(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&&X.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"]},se=/auto|scroll/,ae={top:"gist-arrow-bottom",bottom:"gist-arrow-top",left:"gist-arrow-right",right:"gist-arrow-left"};function re(e){const t=H(e);return t||i(`Tooltip target element not found for selector: ${e}`),t}function le(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 ce(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 de(e,t,n){const i=ce(e,t,n);if(i)return i;for(const i of oe[n]){const n=ce(e,t,i);if(n)return n}return null}function pe(e){const t=[];let n=e.parentElement;for(;n;){const e=getComputedStyle(n),i=e.overflow+e.overflowX+e.overflowY;se.test(i)&&t.push(n),n=n.parentElement}return t}function ue(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 ge(e){const t=H(e);if(t)return!(!t.style||!t.style.height||"0px"===t.style.height)}function me(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:fe};n&&(t.stepId=n),i.contentWindow.postMessage(e,"*")}}(e,t,n)})}const fe=["MultiStepDisplayTypes"];function he(e){if(!e.displaySettings)return;const t=xe(e.instanceId??""),n=document.getElementById(t);n?.contentWindow&&n.contentWindow.postMessage({action:"updateDisplaySettings",displaySettings:e.displaySettings},"*")}async function we(){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 ye=new Map;function ve(e){const t=e.instanceId??"",n=ye.get(t);n&&(n.cleanup(),ye.delete(t));const i=H(`gist-tooltip-${t}`);i&&i.parentNode?.removeChild(i)}function xe(e){return`gist-${e}`}function Se(){const e=document.querySelector(".gist-message");e&&e.classList.add("gist-visible")}const Ie="gist.web.customAttributes";let Ee=new Map;function $e(){const e=Array.from(Ee.entries()),t=new Date;t.setDate(t.getDate()+30),s(Ie,e,t),i(`Saved ${Ee.size} custom attributes to storage with TTL of 30 days`)}async function Ce(e){const t=await Te();if(!t)return;const n=new Date;n.setMinutes(n.getMinutes()+60),s(t,e.filter(Pe),n)}async function ke(e,t){return a(e)?.find((e=>e.queueId===t))}function Pe(e){return!(!e.properties?.gist||!e.properties.gist.broadcast)}function Le(e){if(!Pe(e))return!1;const t=e.properties.gist.broadcast;return 0===t.frequency.delay&&0===t.frequency.count}async function Te(){const e=await U();return e?`gist.web.message.broadcasts.${e}`:null}function Me(e,t){return`${e}.${t}.numberOfTimesShown`}function Ne(e,t){return`${e}.${t}.shouldShow`}!function(){const e=a(Ie);if(e)try{Ee=new Map(e)}catch{Ee=new Map}else Ee=new Map}();const De="gist.web.message.user";async function qe(e){const t=await Ae();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 Ae(){const e=await U();return e?`${De}.${e}`:null}async function Re(){const e=await U();return e?`${De}.${e}.seen`:null}async function We(e){const t=await U();return t?`${De}.${t}.message.${e}.loading`:null}async function Oe(e){const t=await U();return t?`${De}.${t}.message.${e}.state`:null}async function Ue(e){const t=await Oe(e);t&&(r(t),i(`Cleared message state for queueId: ${e}`))}function ze(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 Be=`\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(ze("#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`,Fe="cioPreviewId",He="cioPreviewSettings",_e="gist.previewBar.collapsed",je="gist-pb-styles",Ge="gist-preview-bar",Ve={topLeft:"Top Left",topCenter:"Top Center",topRight:"Top Right",bottomLeft:"Bottom Left",bottomCenter:"Bottom Center",bottomRight:"Bottom Right"};let Xe=null,Je=[],Ye={},Qe=null,Ke=!1,Ze=!1,et=5,tt=null,nt=!0,it=!1,ot=!1,st=null,at=null,rt=null;const lt=new Map;function ct(e,t={}){const n=document.createElement(e);for(const[e,i]of Object.entries(t))n[e]=i;return n}function dt(e,t){const n=ct("div",{className:"gist-pb-label-group"});return n.appendChild(ct("span",{className:"gist-pb-label",textContent:e})),n.appendChild(t),n}function pt(e,t){const n=ct("select",{className:"gist-pb-select"});for(const i of e){const e=ct("option",{value:i.value,textContent:i.label});i.value===t&&(e.selected=!0),n.appendChild(e)}return n}function ut(e,t,n){const i=ct("input",{className:"gist-pb-input",type:e,value:String(t)});return n&&(i.style.width=n),i}function gt(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 mt(e){return!!("inline"!==e.displayType&&"tooltip"!==e.displayType||e.elementSelector?.trim())}function ft(e){if("overlay"===e.displayType&&X.includes(ee(e.overlayPosition))){const{maxWidth:t,...n}=e;e=n}if(Ye=e,Qe){const t=Je.findIndex((e=>e.stepName===Qe));-1!==t&&(Je[t]={...Je[t],displaySettings:{...e}})}if(!Xe)return;const t=on.currentMessages.find((e=>e.instanceId===Xe));t&&mt(e)&&(he(t),ne(t,e)&&Ft(t,Qe,e)),function(){const e=new URLSearchParams(window.location.search).get(Fe);e&&async function(e,t){try{return await $()(`/api/v1/preview/${e}`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})}catch(e){return E(e)}}(e,Je).then((e=>{e&&404===e.status&&Xe&&on.dismissMessage(Xe)})).catch((()=>i("Failed to persist preview display settings")))}()}function ht(e){const t=e.value.trim();t&&!H(t)?e.classList.add("gist-pb-input--invalid"):e.classList.remove("gist-pb-input--invalid")}function wt(e,t){const n=ut("text",e.elementSelector||"","260px");n.placeholder="Element ID or selector",ht(n),n.addEventListener("change",(()=>{const e=n.value.trim(),t=Ye.elementSelector;e&&bt(e),ft({...Ye,elementSelector:e}),t&&t!==e&&yt(t),ht(n)}));const i=ct("button",{type:"button",className:"gist-pb-select-elem-btn",textContent:"Select Element"});ot&&(i.disabled=!0),i.addEventListener("click",(()=>xt(n)));const o=ct("div",{className:"gist-pb-inline-row"});o.appendChild(n),o.appendChild(i),t.appendChild(dt("Element Selector",o))}function bt(e){if(!e||lt.has(e))return;const t=H(e);t&&lt.set(e,t.innerHTML)}function yt(e){const t=lt.get(e);if(void 0===t)return;const n=H(e);n&&(n.innerHTML=t)}function vt(){for(const e of lt.keys())yt(e);lt.clear()}function xt(e){if(ot)return;ot=!0;const t=document.querySelector(`#${Ge} .gist-pb-select-elem-btn`);t&&(t.disabled=!0);const n={...Ye},o=on.currentMessages.find((e=>e.instanceId===Xe))??null;o&&Bt(o),Ye.elementSelector&&yt(Ye.elementSelector);const s=ct("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(),Ye=n,Qe){const e=Je.findIndex((e=>e.stepName===Qe));-1!==e&&(Je[e]={...Je[e],displaySettings:{...n}})}o&&mt(n)&&Ft(o,Qe,n),St()}},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(Ge)?.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=Ye.elementSelector,a={...Ye,elementSelector:t},r=null!=o&&mt(a)&&ne(o,a);ft(a),s&&s!==t&&yt(s),o&&!r&&Ft(o,Qe,a)}d(),St()},d=()=>{a?.classList.remove("gist-pb-pick-highlight"),s.removeEventListener("mousemove",r),s.removeEventListener("click",c),document.removeEventListener("keydown",l),document.body.removeChild(s),ot=!1,st=null};st=d,s.addEventListener("mousemove",r),s.addEventListener("click",c),document.addEventListener("keydown",l),document.body.appendChild(s)}function St(){const e=document.getElementById(Ge);if(!e)return;if(e.classList.toggle("gist-pb-hidden",!Xe&&!Ze),e.innerHTML="",!Xe){if(Ze){const t=ct("div",{className:"gist-pb-controls-row gist-pb-ended-row"}),n=ct("span",{className:"gist-pb-ended-icon",textContent:"✓"}),i=ct("p",{className:"gist-pb-ended-text"});if(i.innerHTML=It(et),t.appendChild(n),t.appendChild(i),nt){const e=ct("button",{type:"button",className:"gist-pb-cancel-btn",textContent:"Cancel"});e.addEventListener("click",Et),t.appendChild(e)}e.appendChild(t)}return}const t=ct("div",{className:"gist-pb-toggle-row"+(Ke?" gist-pb-toggle-row--collapsed":"")}),n=ct("button",{type:"button",className:"gist-pb-toggle-btn"}),i=Ke?"transform:rotate(180deg);display:inline-flex;":"display:inline-flex;";if(n.innerHTML=`${Ke?"Expand":"Collapse"}<span style="${i}">${ze("white")}</span>`,n.addEventListener("click",$t),t.appendChild(n),e.appendChild(t),Ke)return;const o=ct("div",{className:"gist-pb-controls-row"});if(Je.length>0){const e=Qe??Je[0].stepName,t=pt(Je.map((e=>({value:e.stepName,label:e.stepName}))),e);t.addEventListener("change",(()=>{const e=Je.find((e=>e.stepName===t.value));if(e){Qe=e.stepName,Ye={...e.displaySettings};const t=on.currentMessages.find((e=>e.instanceId===Xe));t&&mt(e.displaySettings)&&Ft(t,e.stepName,e.displaySettings),St()}})),o.appendChild(dt("Step",t))}const s=pt([{value:"modal",label:"Modal"},{value:"overlay",label:"Overlay"},{value:"inline",label:"Inline"},{value:"tooltip",label:"Tooltip"}],Ye.displayType||"modal");s.addEventListener("change",(()=>{const e=s.value,t=Ye.displayType,n=Ye.elementSelector,i={...Ye,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),Ye=i,ft(Ye),"inline"!==t&&"tooltip"!==t||!n||"inline"===e||"tooltip"===e||yt(n),St()})),o.appendChild(dt("Display Type",s));const a=Ye.displayType||"modal";"modal"===a?function(e,t){const n=pt([{value:"top",label:"Top"},{value:"center",label:"Center"},{value:"bottom",label:"Bottom"}],e.modalPosition||"center");n.addEventListener("change",(()=>ft({...Ye,modalPosition:n.value}))),t.appendChild(dt("Position",n));const i=ut("number",e.maxWidth??414,"80px");i.addEventListener("change",(()=>ft({...Ye,maxWidth:parseInt(i.value)||414}))),t.appendChild(dt("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=ct("div",{className:"gist-pb-color-control"}),o=ct("input",{className:"gist-pb-color-input",type:"color",value:t}),s=ct("div",{className:"gist-pb-color-swatch"});s.style.background=t,s.appendChild(o),s.addEventListener("click",(()=>o.click()));const a=ct("input",{className:"gist-pb-color-hex",type:"text",maxLength:6,value:t.replace("#","")}),r=ct("input",{className:"gist-pb-color-opacity",type:"number",min:"0",max:"100",value:String(n)}),l=ct("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,ft({...Ye,overlayColor:gt(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),dt("Overlay Color",i)}(e));const o=ct("div",{className:"gist-pb-checkbox-row"}),s=ct("input",{className:"gist-pb-checkbox",type:"checkbox"});s.checked=e.dismissOutsideClick??!1;const a=ct("label",{className:"gist-pb-checkbox-label",textContent:"Dismiss on click outside"});s.addEventListener("change",(()=>ft({...Ye,dismissOutsideClick:s.checked}))),a.addEventListener("click",(()=>{s.checked=!s.checked,ft({...Ye,dismissOutsideClick:s.checked})})),o.appendChild(s),o.appendChild(a);const r=dt(" ",o);r.classList.add("gist-pb-label-group--grow"),r.firstChild.classList.add("gist-pb-label--spacer"),t.appendChild(r)}(Ye,o):"overlay"===a?function(e,t){const n=pt(Object.entries(Ve).map((([e,t])=>({value:e,label:t}))),e.overlayPosition||"topCenter");if(n.addEventListener("change",(()=>ft({...Ye,overlayPosition:n.value}))),t.appendChild(dt("Position",n)),!X.includes(ee(e.overlayPosition))){const n=ut("number",e.maxWidth??414,"80px");n.addEventListener("change",(()=>ft({...Ye,maxWidth:parseInt(n.value)||414}))),t.appendChild(dt("Max Width",n))}}(Ye,o):"inline"===a?function(e,t){wt(e,t)}(Ye,o):"tooltip"===a&&function(e,t){const n=pt([{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],e.tooltipPosition||"top");n.addEventListener("change",(()=>ft({...Ye,tooltipPosition:n.value}))),t.appendChild(dt("Position",n)),wt(e,t)}(Ye,o),o.appendChild(ct("div",{className:"gist-pb-spacer"}));const r=ct("button",{type:"button",className:"gist-pb-save-btn",textContent:"End session"});r.addEventListener("click",(async()=>{Xe&&await on.dismissMessage(Xe)})),o.appendChild(r),e.appendChild(o)}function It(e){return nt?`<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(){Ze&&tt&&(nt=!1,St())}function $t(){Ke=!Ke;try{sessionStorage.setItem(_e,String(Ke))}catch{}St()}function Ct(){vt(),Xe=null,Je=[],Ye={},Qe=null,Ze=!0,et=5,nt=!0,it=!1;const e=new URLSearchParams(window.location.search).get(Fe);e&&async function(e){try{return await $()(`/api/v1/preview/${e}`,{method:"DELETE"})}catch(e){return E(e)}}(e).catch((()=>i("Failed to delete preview session"))),St(),tt&&clearInterval(tt),tt=setInterval((async()=>{if(et-=1,et<=0)clearInterval(tt),tt=null,await async function(){if(!it)if(it=!0,B(),function(){try{sessionStorage.removeItem(o)}catch{}}(),nt){try{window.close()}catch{}try{window.location.reload()}catch{}st&&st(),tt&&(clearInterval(tt),tt=null),vt(),document.getElementById(Ge)?.remove(),document.getElementById(je)?.remove(),Xe=null,Je=[],Ye={},Qe=null,Ze=!1,et=5,nt=!0,it=!1}else Ze=!1,it=!1,St()}();else{const e=document.querySelector(`#${Ge} .gist-pb-ended-text`);e?e.innerHTML=It(et):St()}}),1e3)}async function kt(e){if(!on.isDocumentVisible)return i("Document hidden, not showing message now."),null;if(Y(e.queueId))return i(`Message with queueId ${e.queueId} is already showing.`),null;const t=j(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 o=on.currentMessages.find((e=>e.tooltipPosition&&e.elementId===n));return o&&(i(`Tooltip already showing on target "${n}" (instance ${o.instanceId}), dismissing it first`),on.messageDismissed(o),ve(o),o.instanceId&&K(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,on.currentMessages.push(e),Rt(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),Rt(e,null,e.savedStepName||null))}function Pt(e,t){return on.isDocumentVisible?Y(e.queueId)?(i(`Message with queueId ${e.queueId} is already showing.`),null):Q(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=!ge(t),e.renderStartTime=(new Date).getTime(),on.currentMessages.push(e),Rt(e,t,e.savedStepName||null)):(i("Document hidden, not showing message now."),null)}async function Lt(e){e?(on.messageDismissed(e),await Tt(e)):i("Message not found")}async function Tt(e){"tooltip"===te(e)?Dt(e):e.overlay?await qt(!0,e):Nt(e)}async function Mt(e){e?j(e).persistent&&(i("Persistent message dismissed, logging view"),await Ht(e),await Wt(e),await Ue(e.queueId??"")):i("Message not found")}function Nt(e){e.instanceId&&K(e.instanceId),e.elementId&&ue(e.elementId),on.config.isPreviewSession&&(Ct(),At())}function Dt(e){ve(e),e.instanceId&&K(e.instanceId),0===on.currentMessages.length&&(window.removeEventListener("message",Ut),window.removeEventListener("touchstart",Ot)),on.config.isPreviewSession&&(Ct(),At())}async function qt(e,t){e?await we():be(),0===on.currentMessages.length&&(window.removeEventListener("message",Ut),window.removeEventListener("touchstart",Ot)),t.instanceId&&K(t.instanceId),on.overlayInstanceId=null,on.config.isPreviewSession&&(Ct(),At())}function At(){const e=new URL(window.location.href);e.searchParams.delete(Fe),e.searchParams.delete(He),history.replaceState(null,"",e.toString())}function Rt(e,t=null,n=null){const o=on.config.env,s={endpoint:S.ENGINE_API_ENDPOINT[o],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[o]}/index.html`;return window.addEventListener("message",Ut),window.addEventListener("touchstart",Ot),"tooltip"===te(e)?function(e,t,n,i=null){const o=t.instanceId??"",s=xe(o),a=j(t),r=ye.get(o);r&&(r.cleanup(),ye.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),me(s,n,i)}(a,e,s,n):t?(G.includes(t)&&V(t),function(e,t,n,o,s=null){const a=H(e);if(a){const i=xe(n.instanceId??"");a.classList.add(i);const r=j(n);let l=r.messageWidth+"px";X.includes(e)&&!r.hasCustomWidth&&(l="100%"),G.includes(e)&&(a.style.width=l),ge(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>`}(xe(t.instanceId??""),n,e)}(t,n,r),me(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=j(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>`}(xe(t.instanceId??""),n,e)}(e,t)),me(xe(t.instanceId??""),n,i)}(a,e,s,n),e}async function Wt(e){let t;i(`Message shown, logging view for: ${e.messageId}`),null!=e.queueId?(await Ht(e),t=await F(e.queueId)):t=await async function(e){try{return await $().post(`/api/v1/logs/message/${e}`)}catch(e){return E(e)}}(e.messageId),i(200===t?.status?"Message view logged":`Problem logging message: ${t?.status}`)}function Ot(){}async function Ut(e){const t=e.data;if(t.gist&&e.origin===S.RENDERER_HOST){const e=t.gist.instanceId,n=J(e);if(!n)return;const o=j(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 We(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"),he(n)),on.config.isPreviewSession&&n.properties?.gist?.livePreview&&function(e){if(Ze)return;Xe=e.instanceId??null;const t=e.displaySettings;if(Array.isArray(t)&&t.length>0?(Je=t,Qe||(Qe=Je[0].stepName,Ye={...Je[0].displaySettings})):t&&"object"==typeof t&&!Array.isArray(t)&&(Ye={...t}),at||rt){const e=!!at,t=!!rt,n=at,o=rt;if(at=null,rt=null,e){const e=Je.find((e=>e.stepName===n));if(!e)return i(`Preview bar: step "${n}" not found, ignoring initial step/display override`),void St();Qe=e.stepName,Ye={...e.displaySettings}}if(t){if(!e)return i(`Preview bar: display type "${o}" provided without a step, ignoring`),void St();Ye={...Ye,displayType:o}}St();const s=on.currentMessages.find((e=>e.instanceId===Xe));s&&mt(Ye)?Ft(s,Qe,Ye):function(){const e=Ye.displayType;if("inline"!==e&&"tooltip"!==e)return;const t=document.querySelector("#gist-preview-bar .gist-pb-input[type='text']");t&&xt(t)}()}else St()}(n),n.firstLoad||n.isDisplayChange){if("tooltip"===te(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,Dt(n);break}const t=await async function(e){const t=e.instanceId??"",n=j(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=ye.get(t);r&&(r.cleanup(),ye.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=re(t);if(!o)return!1;let s=[];try{s=pe(o)}catch{}if(le(o.getBoundingClientRect(),s))return!0;if(!function(e,t,n){const i=re(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!==de(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=pe(o)}catch{}return le(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=re(t);if(!s)return null;let a=null,r=null,l=!1,c=[],d=null;try{c=pe(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(!le(t,c))return void(e.style.display="none");e.style.display="";const a=de(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(ae[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:()=>{ye.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?(ye.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,Dt(n);break}}else n.overlay?function(e){const t=j(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(Se,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),o.persistent?i("Persistent message shown, skipping logging view"):await Wt(n)),n.firstLoad=!1,n.isDisplayChange=!1}Z(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&&!o.persistent){await Lt(n);break}try{const t=new URL(e);if(t&&"gist:"===t.protocol)switch(t.href.replace("gist://","").split("?")[0]){case"close":await Mt(n),await _t(n),await Lt(n),await Zt();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(Ze)return;Qe=e;const n=Je.find((t=>t.stepName===e));n?Ye={...n.displaySettings}:t&&(Ye={...t}),St()}(r,e),(o.persistent||Le(n))&&await async function(e,t,n){const o=await Oe(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&&ne(n,e)&&(i("Display settings changed, reloading message"),await Bt(n),ie(n,e),await zt(n,r??null));break}case"routeChanged":n.currentRoute=t.gist.parameters.route,n.renderStartTime=(new Date).getTime(),Z(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"===te(n)?function(e,t){const n=e.instanceId??"",i=xe(n),o=document.getElementById(i);if(o&&t.height>0){o.style.height=`${t.height}px`;const e=ye.get(n);e&&e.reposition()}}(n,t.gist.parameters):n.elementId&&!n.shouldResizeHeight||function(e,t){const n=H(e.elementId?e.elementId:xe(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(xe(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"===te(n)?Dt(n):on.overlayInstanceId?await qt(!1,n):Nt(n)}}}async function zt(e,t){e.isDisplayChange=!0,e.renderStartTime=(new Date).getTime();const n=te(e),o=e.elementId||null;if("tooltip"===n)return on.overlayInstanceId===e.instanceId&&(on.overlayInstanceId=null),e.shouldScale=!1,e.shouldResizeHeight=!1,void Rt(e,null,t);if(o){const t=Q(o);t&&t.instanceId!==e.instanceId&&(i(`Dismissing existing message at ${o} to make room for multi-step message`),await Lt(t))}if(e.overlay){on.overlayInstanceId=e.instanceId??null;const t=j(e);e.shouldScale=t.shouldScale,e.shouldResizeHeight=!0}else on.overlayInstanceId=null,e.shouldScale=!1,e.shouldResizeHeight=!ge(o??"");o&&G.includes(o)&&V(o),Rt(e,o,t)}async function Bt(e){"tooltip"===te(e)?ve(e):e.overlay?await we():e.elementId&&ue(e.elementId)}async function Ft(e,t,n){n&&ne(e,n)&&(await Bt(e),ie(e,n)),await zt(e,t??null)}async function Ht(e){i(`Logging user message view locally for: ${e.queueId}`),Pe(e)?await async function(e){i(`Marking broadcast ${e} as seen.`);const t=await Te();if(!t)return;const n=await ke(t,e);if(!n)return;const o=n.properties.gist.broadcast,{frequency:r}=o,l=Me(t,e),c=Ne(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 Re();if(!t)return;const n=a(t)??[];n.push(e),s(t,n)}(e.queueId??"")}async function _t(e){Pe(e)&&(i(`Logging broadcast dismissed locally for: ${e.queueId}`),await async function(e){i(`Marking broadcast ${e} as dismissed.`);const t=await Te();if(!t)return;const n=await ke(t,e);n&&(!0!==n.properties.gist.broadcast.frequency.ignoreDismiss?(s(Ne(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 Ue(e.queueId??""))}const jt="messageInboxUpdated";async function Gt(e){const t=await Xt();if(!t)return;const n=new Date;n.setMinutes(n.getMinutes()+60),s(t,e,n),on.events.dispatch(jt,e)}async function Vt(){const e=await Xt();if(!e)return[];const t=a(e)??[],n=new Date;return t.filter((e=>!e.expiry||new Date(e.expiry)>n))}async function Xt(){const e=await U();return e?`gist.web.inbox.messages.${e}`:null}const Jt=(e,t)=>e().then((e=>new Promise((t=>setTimeout(t,e))))(t).then((()=>Jt(e,t))));let Yt=!1,Qt=null;async function Kt(){Yt?await Zt():W()?(i("Queue watcher started"),Yt=!0,Jt((()=>new Promise((()=>{!async function(){if(S.hasActiveSSEConnection())return!S.isSSEConnectionManagedBySDK()&&Qt&&(i("Not the main instance, closing our SSE connection."),nn()),void await Zt();Qt&&(i("SSE connection not active, closing it."),nn()),!S.useSSE()||R()?await tn():await async function(){nn();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 tn();i(`Starting SSE queue listener on ${e}`),Qt=new EventSource(e),S.setActiveSSEConnection(),Qt.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 tn()})),Qt.addEventListener("messages",(async e=>{try{const t=JSON.parse(e.data);i("SSE message received"),await qe(t),await Ce(t),await Zt()}catch(e){i(`Failed to parse SSE message: ${e}`),nn()}})),Qt.addEventListener("inbox_messages",(async e=>{try{const t=JSON.parse(e.data);i("SSE inbox messages received"),await Gt(t)}catch(e){i(`Failed to parse SSE inbox messages: ${e}`)}})),Qt.addEventListener("error",(async()=>{i("SSE error received"),nn()})),Qt.addEventListener("heartbeat",(async()=>{i("SSE heartbeat received"),S.setActiveSSEConnection(),S.setUseSSEFlag(!0)}))}()}()}))),1e3)):i("User token not setup, queue not started.")}async function Zt(){const e=await async function(){const e=await Te();return e?(a(e)??[]).filter((t=>{const n=t.properties.gist.broadcast,{frequency:i}=n,o=a(Ne(e,t.queueId))??!0,s=a(Me(e,t.queueId))||0,r=0===i.count;return o&&(r||s<i.count)})):[]}(),t=await async function(){const e=await Ae();if(!e)return[];const t=a(e)??[],n=await async function(){const e=await Re();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 en(e)}async function en(e){let t=j(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||Le(e)){const n=await async function(e){const t=await Oe(e);return t?a(t):null}(e.queueId??"");n&&(i(`Restoring saved state for queueId ${e.queueId}`),n.displaySettings&&(ie(e,n.displaySettings),t=j(e)),e.savedStepName=n.stepName??null)}if(t.persistent||Le(e)||!await async function(e){const t=await We(e);return!!t&&null!==a(t)}(e.queueId??"")){let n=null;return t.isEmbedded?!on.config.isPreviewSession||!e.properties?.gist?.livePreview||H(t.elementId)||G.includes(t.elementId)?n=Pt(e,t.elementId):(i(`Preview: element "${t.elementId}" not found, showing as overlay so placement can be changed`),n=await kt(e)):n=await kt(e),n&&async function(e){const t=await We(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 tn(){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 $().post(`/api/v4/users?sessionId=${N()}`,{},{headers:e})}}catch(e){const n=E(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),Ce(n),Gt(o)}else 304===e.status&&i("304 response, using local store.");await Zt()}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 nn(e=!1){e&&S.removeActiveSSEConnection(),(e||S.isSSEConnectionManagedBySDK())&&S.setUseSSEFlag(!1),Qt&&(i("Stopping SSE queue listener..."),Qt.close(),Qt=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=[],ye.forEach((e=>e.cleanup())),ye.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(Fe);if(t){sessionStorage.setItem(o,String(!1)),on.setUserToken(t),i(`Preview mode enabled with user token: ${t}`),function(){if(document.getElementById(Ge))return;!function(){if(document.getElementById(je))return;const e=document.createElement("style");e.id=je,e.textContent=Be,document.head.appendChild(e)}();try{Ke="true"===sessionStorage.getItem(_e)}catch{Ke=!1}const e=ct("div",{id:Ge});document.body.appendChild(e),St()}();const n=e.get(He);if(n)try{const e=JSON.parse(atob(n)),t=e.stepName||null,i=e.displayType||null;(t||i)&&function(e,t){at=e,rt=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 Kt(),document.addEventListener("visibilitychange",(async()=>{"hidden"===document.visibilityState?this.isDocumentVisible=!1:(this.isDocumentVisible=!0,await Zt())}),!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 Tt(e))}(),await Zt()}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(q)),i(`Set user token "${e}" with expiry date set to ${t}`)}(e,t),nn(!0),await Kt())}static setUserLocale(e){var t;s(C,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(Ie),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(Ie),i(`Removed custom attribute "${e}"`),t}(e)}static async clearUserToken(){this.config.isPreviewSession||(B(),this.config.useAnonymousSession&&O(),nn(!0),await Kt())}static async dismissMessage(e){const t=J(e);t&&(await Mt(t),await _t(t),await Lt(t),await Zt())}static async embedMessage(e,t){return Pt(e,t)?.instanceId??null}static async showMessage(e){return(await kt(e))?.instanceId??null}static updateMessageDisplaySettings(e,t){const n=J(e);return!!n&&(n.displaySettings=t,he(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 Vt()).filter((e=>!e.opened)).length}static async getInboxMessages(){return await Vt()}static async updateInboxMessageOpenState(e,t){return await async function(e,t){const n=await Xt();if(!n)return;const o=await async function(e,t){try{return await $()(`/api/v1/messages/${e}`,{method:"PATCH",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})}catch(e){return E(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 Vt();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";on.events.dispatch("inboxMessageAction",{message:r,action:e})}on.events.dispatch(jt,await Vt())}(e,t)}static async removeInboxMessage(e){return await async function(e){const t=await Xt();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 Vt()).filter((t=>t.queueId!==e)),a=new Date;a.setMinutes(a.getMinutes()+60),s(t,o,a),on.events.dispatch(jt,await Vt())}(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()}}]);
Binary file