customerio-gist-web 3.18.3 → 3.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gist.min.js +1 -1
- package/dist/types/gist.d.ts +37 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/managers/custom-attribute-manager.d.ts +5 -0
- package/dist/types/managers/gist-properties-manager.d.ts +15 -0
- package/dist/types/managers/inbox-message-manager.d.ts +5 -0
- package/dist/types/managers/locale-manager.d.ts +2 -0
- package/dist/types/managers/message-broadcast-manager.d.ts +6 -0
- package/dist/types/managers/message-component-manager.d.ts +12 -0
- package/dist/types/managers/message-manager.d.ts +5 -0
- package/dist/types/managers/message-user-queue-manager.d.ts +9 -0
- package/dist/types/managers/page-component-manager.d.ts +2 -0
- package/dist/types/managers/queue-manager.d.ts +4 -0
- package/dist/types/managers/user-manager.d.ts +8 -0
- package/dist/types/services/log-service.d.ts +2 -0
- package/dist/types/services/message-service.d.ts +1 -0
- package/dist/types/services/network.d.ts +16 -0
- package/dist/types/services/queue-service.d.ts +4 -0
- package/dist/types/services/settings.d.ts +41 -0
- package/dist/types/templates/embed.d.ts +1 -0
- package/dist/types/templates/message.d.ts +1 -0
- package/dist/types/types.d.ts +68 -0
- package/dist/types/utilities/event-emitter.d.ts +8 -0
- package/dist/types/utilities/event-emitter.test.d.ts +1 -0
- package/dist/types/utilities/local-storage.d.ts +6 -0
- package/dist/types/utilities/local-storage.test.d.ts +1 -0
- package/dist/types/utilities/log.d.ts +1 -0
- package/dist/types/utilities/log.test.d.ts +1 -0
- package/dist/types/utilities/message-utils.d.ts +10 -0
- package/dist/types/utilities/preview-mode.d.ts +1 -0
- package/package.json +18 -3
- package/src/gist.js +75 -24
- package/src/index.js +1 -2
- package/src/types.ts +74 -0
- package/src/utilities/event-emitter.test.ts +53 -0
- package/src/utilities/event-emitter.ts +40 -0
- package/src/utilities/local-storage.test.ts +91 -0
- package/src/utilities/local-storage.ts +102 -0
- package/src/utilities/log.test.ts +34 -0
- package/src/utilities/{log.js → log.ts} +2 -2
- package/.github/workflows/eslint.yml +0 -26
- package/.github/workflows/release.yml +0 -92
- package/.github/workflows/release_hotfix.yml +0 -41
- package/.github/workflows/release_version.yml +0 -57
- package/.mise/config.toml +0 -2
- package/CODEOWNERS +0 -2
- package/eslint.config.mjs +0 -10
- package/examples/inbox.js +0 -84
- package/examples/index.html +0 -319
- package/examples/settings.js +0 -76
- package/examples/styles.css +0 -424
- package/index.d.ts +0 -1
- package/index.js +0 -2
- package/src/utilities/event-emitter.js +0 -31
- package/src/utilities/local-storage.js +0 -86
- package/test.sh +0 -4
- package/webpack.config.js +0 -11
package/dist/gist.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Gist=t():e.Gist=t()}(this,(()=>(()=>{var e={595:(e,t,n)=>{"use strict";n.d(t,{A:()=>nt});class s{on(e,t){var n=this[e];n?n.push(t):this[e]=[t]}off(e,t){var n=this[e];if(n)if(t){var s=n.indexOf(t);-1!==s&&n.splice(s,1),0===n.length&&delete this[e]}else delete this[e]}dispatch(e,t){var n=this[e];n&&n.forEach((e=>e(t)))}}function i(e){nt.config&&nt.config.logging&&console.log(`Gist: ${e}`)}const a=365,o="gist.web.isPersistingSession";function r(e,t,n=null){var s=n;s||(s=new Date).setDate(s.getDate()+a);const i={value:t,expiry:s};l().setItem(e,JSON.stringify(i))}function c(e){return g(e)}function u(e){l().removeItem(e)}function d(){const e=sessionStorage.getItem(o);return null===e?(sessionStorage.setItem(o,"true"),!0):"true"===e}function l(){return d()?localStorage:sessionStorage}function g(e){if(!e)return null;try{const t=l().getItem(e);if(!t)return null;const n=JSON.parse(t);if(!n.expiry)return n.value;const s=new Date,i=new Date(n.expiry),a=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(s.getTime()+366e4);return a&&i.getTime()>o.getTime()||s.getTime()>i.getTime()?(u(e),null):n.value}catch(t){i(`Error checking key ${e} for expiry: ${t}`)}return null}var m,p=new Uint8Array(16);function f(){if(!m&&!(m="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 m(p)}const h=/^(?:[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 y=[],w=0;w<256;++w)y.push((w+256).toString(16).substr(1));const v=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(y[e[t+0]]+y[e[t+1]]+y[e[t+2]]+y[e[t+3]]+"-"+y[e[t+4]]+y[e[t+5]]+"-"+y[e[t+6]]+y[e[t+7]]+"-"+y[e[t+8]]+y[e[t+9]]+"-"+y[e[t+10]]+y[e[t+11]]+y[e[t+12]]+y[e[t+13]]+y[e[t+14]]+y[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&h.test(e)}(n))throw TypeError("Stringified UUID is invalid");return n},b=function(e,t,n){var s=(e=e||{}).random||(e.rng||f)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=s[i];return t}return v(s)},S="gist.web.userQueueUseSSE",I="gist.web.activeSSEConnection";let x,$=30;const E={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:function(){return x||(x=b()),x},useSSE:function(){return c(S)??!1},setUseSSEFlag:function(e){r(S,e,new Date((new Date).getTime()+6e4)),i(`Set user uses SSE to "${e}"`)},removeActiveSSEConnection:function(){u(I)},setActiveSSEConnection:function(){r(I,E.getSdkId(),new Date((new Date).getTime()+E.getSSEHeartbeat()))},hasActiveSSEConnection:function(){return c(I)??!1},isSSEConnectionManagedBySDK:function(){return c(I)===E.getSdkId()},getSSEHeartbeat:function(){return 1e3*($+5)},setSSEHeartbeat:function(e){e&&e>0&&($=e)}};function C(){const e=E.GIST_QUEUE_API_ENDPOINT[nt.config.env],t={"X-CIO-Site-Id":nt.config.siteId,"X-CIO-Client-Platform":"web"},n=_();async function s(n,s={}){const i=e+n,a=new AbortController,o=setTimeout((()=>a.abort()),5e3);try{const e=await fetch(i,{method:s.method||"GET",headers:{...t,...s.headers||{}},body:s.method&&"GET"!==s.method.toUpperCase()?s.body:void 0,signal:a.signal});clearTimeout(o);const n=e.headers.get("content-type")?.includes("application/json"),r=n?await e.json():await e.text(),c=Object.fromEntries(e.headers.entries());if(e.status<200||e.status>=400)throw{response:{status:e.status,data:r,headers:c}};return{status:e.status,headers:c,data:r}}catch(e){throw clearTimeout(o),e.response||(e.response={status:0,data:e.message||"Unknown error"}),e}}return null!=n&&(t["X-Gist-Encoded-User-Token"]=n),s.post=(e,t={},n={})=>s(e,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",...n.headers||{}}}),s}const D="gist.web.userLocale";var k=600,T=!1;const M="gist.web.userQueueNextPullCheck",q="gist.web.sessionId";function P(){var e=c(q);return e||(e=b()),r(q,e,new Date((new Date).getTime()+18e5)),e}const R="gist.web.userToken",L="gist.web.usingGuestUserToken",A="gist.web.guestUserToken";function N(){return null!==c(L)}function W(){return c(R)}function U(){if(null===W()){var e=c(A);null==e&&(e=b(),r(A,e),i(`Set guest user token "${e}" with expiry date set to 1 year from today`)),r(R,e),r(L,!0),i(`Using anonymous session with token: "${e}"`)}}async function O(){var 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 _(){var e=W();return null===e?null:btoa(e)}async function H(e){try{return await C().post(`/api/v1/logs/queue/${e}`)}catch(e){return e.response}}function j(e){const t={isEmbedded:!1,elementId:"",hasRouteRule:!1,routeRule:"",position:"",hasPosition:!1,shouldScale:!1,campaignId:null,messageWidth:414,overlayColor:"#00000033",persistent:!1,exitClick:!1,hasCustomWidth:!1},n=e?.properties?.gist;return n?{isEmbedded:!!n.elementId,elementId:n.elementId||"",hasRouteRule:!!n.routeRuleWeb,routeRule:n.routeRuleWeb||"",position:n.position||"",hasPosition:!!n.position,shouldScale:!!n.scale,campaignId:n.campaignId??null,messageWidth:n.messageWidth>0?n.messageWidth:t.messageWidth,hasCustomWidth:n.messageWidth>0,overlayColor:n.overlayColor||t.overlayColor,persistent:!!n.persistent,exitClick:!!n.exitClick}:t}var 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 z(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 V=["x-gist-top","x-gist-bottom","x-gist-floating-top","x-gist-floating-bottom"];function F(e){return nt.currentMessages.find((t=>t.instanceId===e))}function B(e){return!!e&&nt.currentMessages.some((t=>t.queueId===e))}function J(e){return e?nt.currentMessages.find((t=>t.elementId===e)):null}function Q(e){nt.currentMessages=nt.currentMessages.filter((t=>t.instanceId!==e))}function X(e,t){Q(e),nt.currentMessages.push(t)}function K(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 Y(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";else if("overlay"===t.displayType){e.overlay=!1;const n=K(t.overlayPosition);e.elementId=n,e.properties.gist.elementId=n,e.position=null,e.properties.gist.position=null}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.elementId&&V.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 Z=e=>new Promise((t=>setTimeout(t,e)));function ee(e){var t=ue(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 te(e){var t=ue(e);if(t)return t.style&&t.style.height&&"0px"!=t.style.height}function ne(e,t,n=null){const s=document.getElementById(e);s&&(s.onload=function(){!function(e,t,n=null){const s=document.getElementById(e);if(s&&s.contentWindow){const e={options:t,capabilities:se};n&&(t.stepId=n),s.contentWindow.postMessage(e,"*")}}(e,t,n)})}const se=["MultiStepDisplayTypes"];function ie(e){if(!e.displaySettings)return;const t=re(e.instanceId),n=document.getElementById(t);n&&n.contentWindow&&n.contentWindow.postMessage({action:"updateDisplaySettings",displaySettings:e.displaySettings},"*")}async function ae(){var e=document.querySelector(".gist-message");e&&(e.classList.remove("gist-visible"),await Z(300)),oe()}function oe(){var e=document.querySelector("#gist-embed-message");e&&e.parentNode.removeChild(e)}function re(e){return`gist-${e}`}function ce(){var e=document.querySelector(".gist-message");e&&e.classList.add("gist-visible")}function ue(e){try{return document.querySelector(`#${e}`)||null}catch{return null}}const de="gist.web.customAttributes";let le=new Map;function ge(){const e=Array.from(le.entries()),t=new Date;t.setDate(t.getDate()+30),r(de,e,t),i(`Saved ${le.size} custom attributes to storage with TTL of 30 days`)}!function(){const e=c(de);if(e)try{le=new Map(e)}catch{le=new Map}else le=new Map}();const me="gist.web.message.broadcasts",pe=60;async function fe(e){const t=await ve();if(!t)return;const n=new Date;n.setMinutes(n.getMinutes()+pe),r(t,e.filter(ye),n)}async function he(e,t){return c(e).find((e=>e.queueId===t))}function ye(e){return e.properties&&e.properties.gist&&e.properties.gist.broadcast}function we(e){if(!ye(e))return!1;const{broadcast:t}=e.properties.gist;return 0===t.frequency.delay&&0===t.frequency.count}async function ve(){const e=await O();return e?`${me}.${e}`:null}function be(e,t){return`${e}.${t}.numberOfTimesShown`}function Se(e,t){return`${e}.${t}.shouldShow`}const Ie="gist.web.message.user",xe=60;async function $e(e){const t=await Ee();if(!t)return;const n=e.filter((e=>!(e.properties&&e.properties.gist&&e.properties.gist.broadcast))),s=new Date;s.setMinutes(s.getMinutes()+xe),r(t,n,s)}async function Ee(){const e=await O();return e?`${Ie}.${e}`:null}async function Ce(){const e=await O();return e?`${Ie}.${e}.seen`:null}async function De(e){const t=await O();return t?`${Ie}.${t}.message.${e}.loading`:null}async function ke(e){const t=await O();return t?`${Ie}.${t}.message.${e}.state`:null}async function Te(e){const t=await ke(e);t&&(u(t),i(`Cleared message state for queueId: ${e}`))}async function Me(e){if(nt.isDocumentVisible){if(B(e.queueId))return i(`Message with queueId ${e.queueId} is already showing.`),null;if(nt.overlayInstanceId)return i(`Message ${nt.overlayInstanceId} already showing.`),null;var t=j(e);return e.instanceId=b(),e.overlay=!0,e.firstLoad=!0,e.shouldResizeHeight=!0,e.shouldScale=t.shouldScale,e.renderStartTime=(new Date).getTime(),nt.overlayInstanceId=e.instanceId,nt.currentMessages.push(e),Ne(e,null,e.savedStepName||null)}return i("Document hidden, not showing message now."),null}function qe(e,t){return nt.isDocumentVisible?B(e.queueId)?(i(`Message with queueId ${e.queueId} is already showing.`),null):J(t)?(i(`Message with elementId ${t} already has a message.`),null):(e.instanceId=b(),e.overlay=!1,e.firstLoad=!0,e.shouldScale=!1,e.elementId=t,e.shouldResizeHeight=!te(t),e.renderStartTime=(new Date).getTime(),nt.currentMessages.push(e),Ne(e,t,e.savedStepName||null)):(i("Document hidden, not showing message now."),null)}async function Pe(e){e?(nt.messageDismissed(e),e.overlay?await Ae(!0,e):Le(e)):i(`Message with instance id: ${e.instanceId} not found`)}async function Re(e){var t=j(e);e?t.persistent&&(i("Persistent message dismissed, logging view"),await _e(e),await We(e),await Te(e.queueId)):i(`Message with instance id: ${e.instanceId} not found`)}function Le(e){Q(e.instanceId),ee(e.elementId)}async function Ae(e,t){e?await ae():oe(),0==nt.currentMessages.length&&(window.removeEventListener("message",Oe),window.removeEventListener("touchstart",Ue)),Q(t.instanceId),nt.overlayInstanceId=null}function Ne(e,t=null,n=null){var s={endpoint:E.ENGINE_API_ENDPOINT[nt.config.env],siteId:nt.config.siteId,dataCenter:nt.config.dataCenter,messageId:e.messageId,instanceId:e.instanceId,livePreview:!1,properties:e.properties,customAttributes:Object.fromEntries(new Map(le))},a=`${E.GIST_VIEW_ENDPOINT[nt.config.env]}/index.html`;return window.addEventListener("message",Oe),window.addEventListener("touchstart",Ue),t?(G.includes(t)&&z(t),function(e,t,n,s,a=null){var o=ue(e);if(o){var r=re(n.instanceId);o.classList.add(r);var c=j(n),u=c.messageWidth+"px";V.includes(e)&&!c.hasCustomWidth&&(u="100%"),G.includes(e)&&(o.style.width=u),te(e)||(o.style.height="0px"),o.innerHTML=function(e,t,n){var s=function(e,t,n){var s=800;return t.messageWidth>s&&(s=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: ${s}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>`}(re(t.instanceId),n,e);return s}(t,n,c),ne(r,s,a)}else i(`Message could not be embedded, elementId ${e} not found.`)}(t,a,e,s,n)):function(e,t,n,s=null){document.querySelectorAll("#gist-embed-message").forEach((function(e){e.parentNode.removeChild(e)})),document.body.insertAdjacentHTML("afterbegin",function(e,t){var n=j(t),s=function(e,t,n){var s=600;return t.messageWidth>s&&(s=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: ${s}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>`}(re(t.instanceId),n,e);return s}(e,t)),ne(re(t.instanceId),n,s)}(a,e,s,n),e}async function We(e){i(`Message shown, logging view for: ${e.messageId}`);var t={};null!=e.queueId?(await _e(e),t=await H(e.queueId)):t=await async function(e){try{return await C().post(`/api/v1/logs/message/${e}`)}catch(e){return e.response}}(e.messageId),200===t.status?i("Message view logged"):i(`Problem logging message: ${t.status}`)}function Ue(){}async function Oe(e){if(e.data.gist&&e.origin===E.RENDERER_HOST){var t=e.data.gist.instanceId,n=F(t);if(!n)return;var s=j(n);switch(e.data.gist.method){case"routeLoaded":var a=.001*((new Date).getTime()-n.renderStartTime);i(`Engine render for message: ${n.messageId} timer elapsed in ${a.toFixed(3)} seconds`),async function(e){const t=await De(e);if(!t)return!1;u(t)}(n.queueId),n.currentRoute=e.data.gist.parameters.route,e.data.gist.parameters.fullDisplaySettings&&!n.displaySettings?n.displaySettings=e.data.gist.parameters.fullDisplaySettings:n.displaySettings&&(i("SDK already has display settings state, sending it to iframe"),ie(n)),(n.firstLoad||n.isDisplayChange)&&(n.overlay?function(e){var t=j(e),n=document.querySelector("#gist-overlay");if(n){n.classList.add("gist-visible");var s=document.querySelector(".gist-message");e.position?s.classList.add("gist-"+e.position):s.classList.add("gist-center"),setTimeout(ce,100),t.exitClick&&setTimeout((()=>function(e){var t=document.querySelector("#gist-overlay");t&&t.addEventListener("click",(function(){nt.dismissMessage(e)}))}(e.instanceId)),1e3)}else oe()}(n):(h=ue(n.elementId))&&h.classList.add("gist-visible"),n.firstLoad&&!n.isDisplayChange&&(nt.messageShown(n),s.persistent?i("Persistent message shown, skipping logging view"):await We(n)),n.firstLoad=!1,n.isDisplayChange=!1),X(t,n);break;case"tap":var o=e.data.gist.parameters.action,d=e.data.gist.parameters.name;if(nt.messageAction(n,o,d),e.data.gist.parameters.system&&!s.persistent){await Pe(n);break}try{var l=new URL(o);if(l&&"gist:"===l.protocol)switch(l.href.replace("gist://","").split("?")[0]){case"close":await Pe(n),await Re(n),await He(n),await Ye();break;case"showMessage":var g=l.searchParams.get("messageId"),m=l.searchParams.get("properties");g&&(m&&(m=JSON.parse(atob(m))),await nt.showMessage({messageId:g,properties:m}));break;case"loadPage":(l=l.href.substring(l.href.indexOf("?url=")+5))&&(l.startsWith("mailto:")||l.startsWith("https://")||l.startsWith("http://")||l.startsWith("/")?window.location.href=l:window.location.href=window.location+l)}}catch{}break;case"changeMessageStep":var p=e.data.gist.parameters.displaySettings,f=e.data.gist.parameters.messageStepName;(s.persistent||we(n))&&await async function(e,t,n){const s=await ke(e);if(!s)return;const a=c(s)||{},o={stepName:void 0!==t?t:a.stepName,displaySettings:void 0!==n?n:a.displaySettings},u=new Date;u.setDate(u.getDate()+30),r(s,o,u),i(`Saved message state for queueId: ${e}`)}(n.queueId,f,p),p&&function(e,t){const n=(s=e).overlay?"modal":s.elementId&&G.includes(s.elementId)?"overlay":s.elementId?"inline":"modal";var s;const i=t.displayType;if(void 0===i)return!1;if(n!==i)return!0;const a=j(e);switch(i){case"modal":if((e.position||"center")!==(t.modalPosition||"center"))return!0;if(void 0!==t.dismissOutsideClick&&a.exitClick!==t.dismissOutsideClick)return!0;if(void 0!==t.overlayColor&&a.overlayColor!==t.overlayColor)return!0;break;case"overlay":{const n=K(t.overlayPosition);if(e.elementId!==n)return!0;break}case"inline":if(e.elementId!==t.elementSelector)return!0}return void 0!==t.maxWidth&&a.messageWidth!==t.maxWidth}(n,p)&&(i("Display settings changed, reloading message"),await async function(e){e.overlay?await ae():ee(e.elementId)}(n),Y(n,p),await async function(e,t){e.isDisplayChange=!0,e.renderStartTime=(new Date).getTime();var n=e.elementId||null;if(n){const t=J(n);t&&t.instanceId!==e.instanceId&&(i(`Dismissing existing message at ${n} to make room for multi-step message`),await Pe(t))}if(e.overlay){nt.overlayInstanceId=e.instanceId;var s=j(e);e.shouldScale=s.shouldScale,e.shouldResizeHeight=!0}else nt.overlayInstanceId=null,e.shouldScale=!1,e.shouldResizeHeight=!te(n);n&&G.includes(n)&&z(n),Ne(e,n,t)}(n,f));break;case"routeChanged":n.currentRoute=e.data.gist.parameters.route,n.renderStartTime=(new Date).getTime(),X(t,n),i(`Route changed to: ${n.currentRoute}`);break;case"sizeChanged":i(`Size Changed Width: ${e.data.gist.parameters.width} - Height: ${e.data.gist.parameters.height}`),n.elementId&&!n.shouldResizeHeight||function(e,t){var n=ue(e.elementId?e.elementId:re(e.instanceId));if(n){var s=n.style;if(t.height>0)if(t.height>window.innerHeight){var i=1-(t.height/window.innerHeight-1);e.shouldScale&&i>=.4?(s.height=`${t.height}px`,s.transform=`translateX(-50%) translateY(-50%) scale(${i})`):s.height=`${window.innerHeight}px`}else s.height=`${t.height}px`}}(n,e.data.gist.parameters);break;case"titleChanged":i(`Overlay title changed to: ${e.data.gist.parameters.title}`),function(e,t){var n=ue(re(e));n&&(n.title=t)}(t,e.data.gist.parameters.title);break;case"eventDispatched":nt.events.dispatch("eventDispatched",{name:e.data.gist.parameters.name,payload:e.data.gist.parameters.payload});break;case"error":case"routeError":nt.messageError(n),nt.overlayInstanceId?Ae(!1,n):Le(n)}}var h}async function _e(e){i(`Logging user message view locally for: ${e.queueId}`),ye(e)?await async function(e){i(`Marking broadcast ${e} as seen.`);const t=await ve();if(!t)return;const n=await he(t,e);if(!n)return;const{broadcast:s}=n.properties.gist,a=be(t,e),o=Se(t,e);let u=c(a)||0;if(r(a,u+1),1===s.frequency.count)r(o,!1),i(`Marked broadcast ${e} as seen.`);else{let t=new Date;t.setSeconds(t.getSeconds()+s.frequency.delay),r(o,!1,t),i(`Marked broadcast ${e} as seen, broadcast was seen ${u+1} times, next show date is ${t}.`)}}(e.queueId):await async function(e){const t=await Ce();if(!t)return;const n=c(t)??[];n.push(e),r(t,n)}(e.queueId)}async function He(e){ye(e)&&(i(`Logging broadcast dismissed locally for: ${e.queueId}`),await async function(e){i(`Marking broadcast ${e} as dismissed.`);const t=await ve();if(!t)return;const n=await he(t,e);if(!n)return;const{broadcast:s}=n.properties.gist;!0!==s.frequency.ignoreDismiss?(r(Se(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 Te(e.queueId))}const je="messageInboxUpdated",Ge="gist.web.inbox.messages",ze=60;async function Ve(e){const t=await Be();if(!t)return;const n=new Date;n.setMinutes(n.getMinutes()+ze),r(t,e,n),nt.events.dispatch(je,e)}async function Fe(){const e=await Be();if(!e)return[];const t=c(e)??[],n=new Date;return t.filter((e=>!e.expiry||new Date(e.expiry)>n))}async function Be(){const e=await O();return e?`${Ge}.${e}`:null}var Je=(e,t)=>e().then((e=>new Promise((t=>setTimeout(t,e))))(t).then((()=>Je(e,t)))),Qe=!1;let Xe=null;async function Ke(){Qe?await Ye():W()?(i("Queue watcher started"),Qe=!0,Je((()=>new Promise((()=>async function(){if(E.hasActiveSSEConnection())return!E.isSSEConnectionManagedBySDK()&&Xe&&(i("Not the main instance, closing our SSE connection."),tt()),void await Ye();Xe&&(i("SSE connection not active, closing it."),tt()),!E.useSSE()||N()?await et():await async function(){tt();const e=null===(t=_())?(i("No user token available for SSE endpoint."),null):E.GIST_QUEUE_REALTIME_API_ENDPOINT[nt.config.env]+`/api/v3/sse?userToken=${t}&siteId=${nt.config.siteId}&sessionId=${P()}`;var t;if(null===e)return i("SSE endpoint not available, falling back to polling."),void await et();i(`Starting SSE queue listener on ${e}`),Xe=new EventSource(e),E.setActiveSSEConnection(),Xe.addEventListener("connected",(async e=>{try{i("SSE connection received:"),E.setUseSSEFlag(!0);var t=JSON.parse(e.data);t.heartbeat&&(E.setSSEHeartbeat(t.heartbeat),i(`SSE heartbeat set to ${t.heartbeat} seconds`)),E.setActiveSSEConnection()}catch(e){i(`Failed to parse SSE settings: ${e}`)}u(M),await et()})),Xe.addEventListener("messages",(async e=>{try{var t=JSON.parse(e.data);i("SSE message received:"),await $e(t),await fe(t),await Ye()}catch(e){i("Failed to parse SSE message"),tt()}})),Xe.addEventListener("inbox_messages",(async e=>{try{var t=JSON.parse(e.data);i("SSE inbox messages received:"),await Ve(t)}catch(e){i("Failed to parse SSE inbox messages")}})),Xe.addEventListener("error",(async e=>{i("SSE error received:"),tt()})),Xe.addEventListener("heartbeat",(async e=>{i("SSE heartbeat received:"),E.setActiveSSEConnection(),E.setUseSSEFlag(!0)}))}()}()))),1e3)):i("User token not setup, queue not started.")}async function Ye(){var e=await async function(){const e=await ve();return e?(c(e)??[]).filter((t=>{const{broadcast:n}=t.properties.gist,s=c(Se(e,t.queueId))??!0,i=c(be(e,t.queueId))||0,a=0===n.frequency.count;return s&&(a||i<n.frequency.count)})):[]}(),t=await async function(){const e=await Ee();if(!e)return[];const t=c(e)??[],n=await async function(){const e=await Ce();return e?c(e)??[]:[]}();return t.filter((e=>!n.includes(e.queueId)))}(),n=e.concat(t);i(`Messages in local queue: ${n.length}`);var s=n.sort(((e,t)=>e.priority-t.priority));for(const e of s)await Ze(e)}async function Ze(e){var t=j(e);if(t.hasRouteRule){var n=nt.currentRoute;null==n&&(n=new URL(window.location.href).pathname);var s=t.routeRule;if(i(`Verifying route ${n} against rule: ${s}`),!new RegExp(s).test(n))return i(`Route ${n} does not match rule.`),!1}if(t.hasPosition&&(e.position=t.position),t.persistent||we(e)){const n=await async function(e){const t=await ke(e);return t?c(t):null}(e.queueId);n&&(i(`Restoring saved state for queueId ${e.queueId}`),n.displaySettings&&(Y(e,n.displaySettings),t=j(e)),e.savedStepName=n.stepName)}if(t.persistent||we(e)||!await async function(e){const t=await De(e);return!!t&&null!==c(t)}(e.queueId)){var a;return(a=t.isEmbedded?qe(e,t.elementId):await Me(e))&&async function(e){const t=await De(e);if(!t)return!1;r(t,!0,new Date(Date.now()+5e3))}(e.queueId),a}return i(`Not showing message with queueId ${e.queueId} because its already loading.`),!1}async function et(){if(W())if(nt.isDocumentVisible)if(null===c(M)){var e=await async function(){const e=W();var t;try{if(!T){T=!0;var n={"X-Gist-User-Anonymous":N(),"Content-Language":null!==c(D)?c(D):navigator.language};t=await C().post(`/api/v4/users?sessionId=${P()}`,{},{headers:n})}}catch(e){e.response?t=e.response:i(`Error getting user queue: ${e}`)}finally{T=!1}return e!==W()?(i("User token changed, clearing queue next pull check."),void u(M)):(function(e){if(e&&e.headers){var t=e.headers["x-gist-queue-polling-interval"];t&&t>0&&(k=t)}var n=new Date((new Date).getTime()+1e3*k);r(M,k,n)}(t),function(e){const t="true"===e?.headers?.["x-cio-use-sse"]?.toLowerCase();E.setUseSSEFlag(t)}(t),t)}();if(e){if(200===e.status||204===e.status){i("200 response, updating local store.");var t=e.data?.inAppMessages||[],n=e.data?.inboxMessages||[];$e(t),fe(t),Ve(n)}else 304===e.status&&i("304 response, using local store.");await Ye()}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 tt(e=!1){e&&E.removeActiveSSEConnection(),(e||E.isSSEConnectionManagedBySDK())&&E.setUseSSEFlag(!1),Xe&&(i("Stopping SSE queue listener..."),Xe.close(),Xe=null)}const nt=class{static async setup(e){this.initialized?i("Gist SDK already initialized, skipping setup."):(this.initialized=!0,this.events=new s,this.config={useAnonymousSession:void 0!==e.useAnonymousSession&&e.useAnonymousSession,siteId:e.siteId,dataCenter:e.dataCenter,env:void 0===e.env?"prod":e.env,logging:void 0!==e.logging&&e.logging,experiments:void 0!==e.experiments&&e.experiments},this.currentMessages=[],this.overlayInstanceId=null,this.currentRoute=null,this.isDocumentVisible=!0,this.config.isPreviewSession=function(){const e=new URLSearchParams(window.location.search).get("cioPreviewId");return e&&(sessionStorage.setItem(o,!1),nt.setUserToken(e),i(`Preview mode enabled with user token: ${e}`)),!d()}(),function(){const e=l();for(let t=e.length-1;t>=0;t--)g(e.key(t))}(),i(`Setup complete on ${this.config.env} environment.`),this.config.isPreviewSession||!this.config.useAnonymousSession||new URLSearchParams(location.search).has("ajs_uid")||U(),await Ke(),document.addEventListener("visibilitychange",(async()=>{"hidden"===document.visibilityState?this.isDocumentVisible=!1:(this.isDocumentVisible=!0,await Ye())}),!1))}static async setCurrentRoute(e){this.currentRoute=e,i(`Current route set to: ${e}`),await Ye()}static async setUserToken(e,t){this.config.isPreviewSession||(function(e,t){void 0===t&&(t=new Date).setDate(t.getDate()+30),r(R,e,t),N()&&(u(M),u(L)),i(`Set user token "${e}" with expiry date set to ${t}`)}(e,t),tt(!0),await Ke())}static setUserLocale(e){var t;r(D,t=e),i(`Set user locate to "${t}"`)}static setCustomAttribute(e,t){return function(e,t){return e&&"string"==typeof e?(le.set(e,t),ge(),i(`Set custom attribute "${e}" to "${t}"`),!0):(i(`Invalid key for custom attribute: ${e}`),!1)}(e,t)}static clearCustomAttributes(){le.clear(),u(de),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=le.has(e);return le.delete(e),le.size>0?ge():u(de),i(`Removed custom attribute "${e}"`),t}(e)}static async clearUserToken(){this.config.isPreviewSession||(u(R),i("Cleared user token"),this.config.useAnonymousSession&&U(),tt(!0),await Ke())}static async dismissMessage(e){var t=F(e);await Pe(t),await Re(t),await He(t),await Ye()}static async embedMessage(e,t){var n=qe(e,t);return n?n.instanceId:null}static async showMessage(e){var t=await Me(e);return t?t.instanceId:null}static updateMessageDisplaySettings(e,t){var n=F(e);return!!n&&(n.displaySettings=t,ie(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 Fe()).filter((e=>!e.opened)).length}static async getInboxMessages(){return await Fe()}static async updateInboxMessageOpenState(e,t){return await async function(e,t){const n=await Be();if(!n)return;const s=await async function(e,t){try{return await C()(`/api/v1/messages/${e}`,{method:"PATCH",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})}catch(e){return e.response}}(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 Fe();let o=null;const c=a.map((n=>n.queueId===e?(n.opened=t,o=n,{...n}):n)),u=new Date;if(u.setMinutes(u.getMinutes()+ze),r(n,c,u),o){const e=t?"opened":"unopened";nt.events.dispatch("inboxMessageAction",{message:o,action:e})}nt.events.dispatch(je,await Fe())}(e,t)}static async removeInboxMessage(e){return await async function(e){const t=await Be();if(!t)return;const n=await H(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 Fe()).filter((t=>t.queueId!==e)),a=new Date;a.setMinutes(a.getMinutes()+ze),r(t,s,a),nt.events.dispatch(je,await Fe())}(e)}}},44:(e,t,n)=>{const s=n(595).A;e.exports=s}},t={};function n(s){var i=t[s];if(void 0!==i)return i.exports;var a=t[s]={exports:{}};return e[s](a,a.exports,n),a.exports}return n.d=(e,t)=>{for(var s in t)n.o(t,s)&&!n.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n(44)})()));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Gist=t():e.Gist=t()}(this,()=>(()=>{"use strict";var e={d:(t,s)=>{for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{default:()=>Je});class s{constructor(){this.callbacks={}}on(e,t){const s=this.callbacks[e];s?s.push(t):this.callbacks[e]=[t]}off(e,t){const s=this.callbacks[e];if(!s)return;if(!t)return void delete this.callbacks[e];const n=s.indexOf(t);-1!==n&&s.splice(n,1),0===s.length&&delete this.callbacks[e]}dispatch(e,t){const s=this.callbacks[e];s&&s.forEach(e=>e(t))}}function n(e){Je.config&&Je.config.logging&&console.log(`Gist: ${e}`)}const i="gist.web.isPersistingSession";function a(e,t,s=null){let n=s;n||(n=new Date,n.setDate(n.getDate()+365));const i={value:t,expiry:n};u().setItem(e,JSON.stringify(i))}function o(e){return l(e)}function r(e){u().removeItem(e)}function c(){const e=sessionStorage.getItem(i);return null===e?(sessionStorage.setItem(i,"true"),!0):"true"===e}function u(){return c()?localStorage:sessionStorage}function l(e){if(!e)return null;try{const t=u().getItem(e);if(!t)return null;const s=JSON.parse(t);if(!s.expiry)return s.value;const n=new Date,i=new Date(s.expiry),a=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(n.getTime()+366e4);return a&&i.getTime()>o.getTime()||n.getTime()>i.getTime()?(r(e),null):s.value}catch(t){n(`Error checking key ${e} for expiry: ${t}`)}return null}var d,g=new Uint8Array(16);function m(){if(!d&&!(d="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 d(g)}const p=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var f=[],h=0;h<256;++h)f.push((h+256).toString(16).substr(1));const y=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s=(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&&p.test(e)}(s))throw TypeError("Stringified UUID is invalid");return s},w=function(e,t,s){var n=(e=e||{}).random||(e.rng||m)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){s=s||0;for(var i=0;i<16;++i)t[s+i]=n[i];return t}return y(n)},v="gist.web.userQueueUseSSE",b="gist.web.activeSSEConnection";let S,I=30;const x={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:function(){return S||(S=w()),S},useSSE:function(){return o(v)??!1},setUseSSEFlag:function(e){a(v,e,new Date((new Date).getTime()+6e4)),n(`Set user uses SSE to "${e}"`)},removeActiveSSEConnection:function(){r(b)},setActiveSSEConnection:function(){a(b,x.getSdkId(),new Date((new Date).getTime()+x.getSSEHeartbeat()))},hasActiveSSEConnection:function(){return o(b)??!1},isSSEConnectionManagedBySDK:function(){return o(b)===x.getSdkId()},getSSEHeartbeat:function(){return 1e3*(I+5)},setSSEHeartbeat:function(e){e&&e>0&&(I=e)}};function $(){const e=x.GIST_QUEUE_API_ENDPOINT[Je.config.env],t={"X-CIO-Site-Id":Je.config.siteId,"X-CIO-Client-Platform":"web"},s=U();async function n(s,n={}){const i=e+s,a=new AbortController,o=setTimeout(()=>a.abort(),5e3);try{const e=await fetch(i,{method:n.method||"GET",headers:{...t,...n.headers||{}},body:n.method&&"GET"!==n.method.toUpperCase()?n.body:void 0,signal:a.signal});clearTimeout(o);const s=e.headers.get("content-type")?.includes("application/json"),r=s?await e.json():await e.text(),c=Object.fromEntries(e.headers.entries());if(e.status<200||e.status>=400)throw{response:{status:e.status,data:r,headers:c}};return{status:e.status,headers:c,data:r}}catch(e){throw clearTimeout(o),e.response||(e.response={status:0,data:e.message||"Unknown error"}),e}}return null!=s&&(t["X-Gist-Encoded-User-Token"]=s),n.post=(e,t={},s={})=>n(e,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",...s.headers||{}}}),n}const E="gist.web.userLocale";var C=600,D=!1;const k="gist.web.userQueueNextPullCheck",T="gist.web.sessionId";function M(){var e=o(T);return e||(e=w()),a(T,e,new Date((new Date).getTime()+18e5)),e}const q="gist.web.userToken",P="gist.web.usingGuestUserToken",R="gist.web.guestUserToken";function L(){return null!==o(P)}function N(){return o(q)}function W(){if(null===N()){var e=o(R);null==e&&(e=w(),a(R,e),n(`Set guest user token "${e}" with expiry date set to 1 year from today`)),a(q,e),a(P,!0),n(`Using anonymous session with token: "${e}"`)}}async function A(){var e=N();return null===e?null:await async function(e){const t=(new TextEncoder).encode(e),s=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(s)).map(e=>e.toString(16).padStart(2,"0")).join("")}(e)}function U(){var e=N();return null===e?null:btoa(e)}async function O(e){try{return await $().post(`/api/v1/logs/queue/${e}`)}catch(e){return e.response}}function _(e){const t={isEmbedded:!1,elementId:"",hasRouteRule:!1,routeRule:"",position:"",hasPosition:!1,shouldScale:!1,campaignId:null,messageWidth:414,overlayColor:"#00000033",persistent:!1,exitClick:!1,hasCustomWidth:!1},s=e?.properties?.gist;return s?{isEmbedded:!!s.elementId,elementId:s.elementId||"",hasRouteRule:!!s.routeRuleWeb,routeRule:s.routeRuleWeb||"",position:s.position||"",hasPosition:!!s.position,shouldScale:!!s.scale,campaignId:s.campaignId??null,messageWidth:s.messageWidth>0?s.messageWidth:t.messageWidth,hasCustomWidth:s.messageWidth>0,overlayColor:s.overlayColor||t.overlayColor,persistent:!!s.persistent,exitClick:!!s.exitClick}:t}var H=["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 j(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),n("Top & bottom elements injected into page")}const z=["x-gist-top","x-gist-bottom","x-gist-floating-top","x-gist-floating-bottom"];function G(e){return Je.currentMessages.find(t=>t.instanceId===e)}function V(e){return!!e&&Je.currentMessages.some(t=>t.queueId===e)}function F(e){return e?Je.currentMessages.find(t=>t.elementId===e):null}function B(e){Je.currentMessages=Je.currentMessages.filter(t=>t.instanceId!==e)}function J(e,t){B(e),Je.currentMessages.push(t)}function Q(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]:(n(`Invalid overlay position "${e}", defaulting to "topCenter"`),t.topCenter)}function X(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";else if("overlay"===t.displayType){e.overlay=!1;const s=Q(t.overlayPosition);e.elementId=s,e.properties.gist.elementId=s,e.position=null,e.properties.gist.position=null}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.elementId&&z.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}function K(e){var t=oe(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 Y(e){var t=oe(e);if(t)return t.style&&t.style.height&&"0px"!=t.style.height}function Z(e,t,s=null){const n=document.getElementById(e);n&&(n.onload=function(){!function(e,t,s=null){const n=document.getElementById(e);if(n&&n.contentWindow){const e={options:t,capabilities:ee};s&&(t.stepId=s),n.contentWindow.postMessage(e,"*")}}(e,t,s)})}const ee=["MultiStepDisplayTypes"];function te(e){if(!e.displaySettings)return;const t=ie(e.instanceId),s=document.getElementById(t);s&&s.contentWindow&&s.contentWindow.postMessage({action:"updateDisplaySettings",displaySettings:e.displaySettings},"*")}async function se(){var e=document.querySelector(".gist-message");e&&(e.classList.remove("gist-visible"),await new Promise(e=>setTimeout(e,300))),ne()}function ne(){var e=document.querySelector("#gist-embed-message");e&&e.parentNode.removeChild(e)}function ie(e){return`gist-${e}`}function ae(){var e=document.querySelector(".gist-message");e&&e.classList.add("gist-visible")}function oe(e){try{return document.querySelector(`#${e}`)||null}catch{return null}}const re="gist.web.customAttributes";let ce=new Map;function ue(){const e=Array.from(ce.entries()),t=new Date;t.setDate(t.getDate()+30),a(re,e,t),n(`Saved ${ce.size} custom attributes to storage with TTL of 30 days`)}async function le(e){const t=await pe();if(!t)return;const s=new Date;s.setMinutes(s.getMinutes()+60),a(t,e.filter(ge),s)}async function de(e,t){return o(e).find(e=>e.queueId===t)}function ge(e){return e.properties&&e.properties.gist&&e.properties.gist.broadcast}function me(e){if(!ge(e))return!1;const{broadcast:t}=e.properties.gist;return 0===t.frequency.delay&&0===t.frequency.count}async function pe(){const e=await A();return e?`gist.web.message.broadcasts.${e}`:null}function fe(e,t){return`${e}.${t}.numberOfTimesShown`}function he(e,t){return`${e}.${t}.shouldShow`}!function(){const e=o(re);if(e)try{ce=new Map(e)}catch{ce=new Map}else ce=new Map}();const ye="gist.web.message.user";async function we(e){const t=await ve();if(!t)return;const s=e.filter(e=>!(e.properties&&e.properties.gist&&e.properties.gist.broadcast)),n=new Date;n.setMinutes(n.getMinutes()+60),a(t,s,n)}async function ve(){const e=await A();return e?`${ye}.${e}`:null}async function be(){const e=await A();return e?`${ye}.${e}.seen`:null}async function Se(e){const t=await A();return t?`${ye}.${t}.message.${e}.loading`:null}async function Ie(e){const t=await A();return t?`${ye}.${t}.message.${e}.state`:null}async function xe(e){const t=await Ie(e);t&&(r(t),n(`Cleared message state for queueId: ${e}`))}async function $e(e){if(Je.isDocumentVisible){if(V(e.queueId))return n(`Message with queueId ${e.queueId} is already showing.`),null;if(Je.overlayInstanceId)return n(`Message ${Je.overlayInstanceId} already showing.`),null;var t=_(e);return e.instanceId=w(),e.overlay=!0,e.firstLoad=!0,e.shouldResizeHeight=!0,e.shouldScale=t.shouldScale,e.renderStartTime=(new Date).getTime(),Je.overlayInstanceId=e.instanceId,Je.currentMessages.push(e),Me(e,null,e.savedStepName||null)}return n("Document hidden, not showing message now."),null}function Ee(e,t){return Je.isDocumentVisible?V(e.queueId)?(n(`Message with queueId ${e.queueId} is already showing.`),null):F(t)?(n(`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=!Y(t),e.renderStartTime=(new Date).getTime(),Je.currentMessages.push(e),Me(e,t,e.savedStepName||null)):(n("Document hidden, not showing message now."),null)}async function Ce(e){e?(Je.messageDismissed(e),e.overlay?await Te(!0,e):ke(e)):n(`Message with instance id: ${e.instanceId} not found`)}async function De(e){var t=_(e);e?t.persistent&&(n("Persistent message dismissed, logging view"),await Le(e),await qe(e),await xe(e.queueId)):n(`Message with instance id: ${e.instanceId} not found`)}function ke(e){B(e.instanceId),K(e.elementId)}async function Te(e,t){e?await se():ne(),0==Je.currentMessages.length&&(window.removeEventListener("message",Re),window.removeEventListener("touchstart",Pe)),B(t.instanceId),Je.overlayInstanceId=null}function Me(e,t=null,s=null){var i={endpoint:x.ENGINE_API_ENDPOINT[Je.config.env],siteId:Je.config.siteId,dataCenter:Je.config.dataCenter,messageId:e.messageId,instanceId:e.instanceId,livePreview:!1,properties:e.properties,customAttributes:Object.fromEntries(new Map(ce))},a=`${x.GIST_VIEW_ENDPOINT[Je.config.env]}/index.html`;return window.addEventListener("message",Re),window.addEventListener("touchstart",Pe),t?(H.includes(t)&&j(t),function(e,t,s,i,a=null){var o=oe(e);if(o){var r=ie(s.instanceId);o.classList.add(r);var c=_(s),u=c.messageWidth+"px";z.includes(e)&&!c.hasCustomWidth&&(u="100%"),H.includes(e)&&(o.style.width=u),Y(e)||(o.style.height="0px"),o.innerHTML=function(e,t,s){var n=function(e,t,s){var n=800;return t.messageWidth>n&&(n=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: ${n}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="${s}"></iframe>\n </div>\n </div>`}(ie(t.instanceId),s,e);return n}(t,s,c),Z(r,i,a)}else n(`Message could not be embedded, elementId ${e} not found.`)}(t,a,e,i,s)):function(e,t,s,n=null){document.querySelectorAll("#gist-embed-message").forEach(function(e){e.parentNode.removeChild(e)}),document.body.insertAdjacentHTML("afterbegin",function(e,t){var s=_(t),n=function(e,t,s){var n=600;return t.messageWidth>n&&(n=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: ${n}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="${s}"></iframe>\n </div>\n </div>`}(ie(t.instanceId),s,e);return n}(e,t)),Z(ie(t.instanceId),s,n)}(a,e,i,s),e}async function qe(e){n(`Message shown, logging view for: ${e.messageId}`);var t={};null!=e.queueId?(await Le(e),t=await O(e.queueId)):t=await async function(e){try{return await $().post(`/api/v1/logs/message/${e}`)}catch(e){return e.response}}(e.messageId),200===t.status?n("Message view logged"):n(`Problem logging message: ${t.status}`)}function Pe(){}async function Re(e){if(e.data.gist&&e.origin===x.RENDERER_HOST){var t=e.data.gist.instanceId,s=G(t);if(!s)return;var i=_(s);switch(e.data.gist.method){case"routeLoaded":var c=.001*((new Date).getTime()-s.renderStartTime);n(`Engine render for message: ${s.messageId} timer elapsed in ${c.toFixed(3)} seconds`),async function(e){const t=await Se(e);if(!t)return!1;r(t)}(s.queueId),s.currentRoute=e.data.gist.parameters.route,e.data.gist.parameters.fullDisplaySettings&&!s.displaySettings?s.displaySettings=e.data.gist.parameters.fullDisplaySettings:s.displaySettings&&(n("SDK already has display settings state, sending it to iframe"),te(s)),(s.firstLoad||s.isDisplayChange)&&(s.overlay?function(e){var t=_(e),s=document.querySelector("#gist-overlay");if(s){s.classList.add("gist-visible");var n=document.querySelector(".gist-message");e.position?n.classList.add("gist-"+e.position):n.classList.add("gist-center"),setTimeout(ae,100),t.exitClick&&setTimeout(()=>function(e){var t=document.querySelector("#gist-overlay");t&&t.addEventListener("click",function(){Je.dismissMessage(e)})}(e.instanceId),1e3)}else ne()}(s):(h=oe(s.elementId))&&h.classList.add("gist-visible"),s.firstLoad&&!s.isDisplayChange&&(Je.messageShown(s),i.persistent?n("Persistent message shown, skipping logging view"):await qe(s)),s.firstLoad=!1,s.isDisplayChange=!1),J(t,s);break;case"tap":var u=e.data.gist.parameters.action,l=e.data.gist.parameters.name;if(Je.messageAction(s,u,l),e.data.gist.parameters.system&&!i.persistent){await Ce(s);break}try{var d=new URL(u);if(d&&"gist:"===d.protocol)switch(d.href.replace("gist://","").split("?")[0]){case"close":await Ce(s),await De(s),await Ne(s),await Ge();break;case"showMessage":var g=d.searchParams.get("messageId"),m=d.searchParams.get("properties");g&&(m&&(m=JSON.parse(atob(m))),await Je.showMessage({messageId:g,properties:m}));break;case"loadPage":(d=d.href.substring(d.href.indexOf("?url=")+5))&&(d.startsWith("mailto:")||d.startsWith("https://")||d.startsWith("http://")||d.startsWith("/")?window.location.href=d:window.location.href=window.location+d)}}catch{}break;case"changeMessageStep":var p=e.data.gist.parameters.displaySettings,f=e.data.gist.parameters.messageStepName;(i.persistent||me(s))&&await async function(e,t,s){const i=await Ie(e);if(!i)return;const r=o(i)||{},c={stepName:void 0!==t?t:r.stepName,displaySettings:void 0!==s?s:r.displaySettings},u=new Date;u.setDate(u.getDate()+30),a(i,c,u),n(`Saved message state for queueId: ${e}`)}(s.queueId,f,p),p&&function(e,t){const s=(n=e).overlay?"modal":n.elementId&&H.includes(n.elementId)?"overlay":n.elementId?"inline":"modal";var n;const i=t.displayType;if(void 0===i)return!1;if(s!==i)return!0;const a=_(e);switch(i){case"modal":if((e.position||"center")!==(t.modalPosition||"center"))return!0;if(void 0!==t.dismissOutsideClick&&a.exitClick!==t.dismissOutsideClick)return!0;if(void 0!==t.overlayColor&&a.overlayColor!==t.overlayColor)return!0;break;case"overlay":{const s=Q(t.overlayPosition);if(e.elementId!==s)return!0;break}case"inline":if(e.elementId!==t.elementSelector)return!0}return void 0!==t.maxWidth&&a.messageWidth!==t.maxWidth}(s,p)&&(n("Display settings changed, reloading message"),await async function(e){e.overlay?await se():K(e.elementId)}(s),X(s,p),await async function(e,t){e.isDisplayChange=!0,e.renderStartTime=(new Date).getTime();var s=e.elementId||null;if(s){const t=F(s);t&&t.instanceId!==e.instanceId&&(n(`Dismissing existing message at ${s} to make room for multi-step message`),await Ce(t))}if(e.overlay){Je.overlayInstanceId=e.instanceId;var i=_(e);e.shouldScale=i.shouldScale,e.shouldResizeHeight=!0}else Je.overlayInstanceId=null,e.shouldScale=!1,e.shouldResizeHeight=!Y(s);s&&H.includes(s)&&j(s),Me(e,s,t)}(s,f));break;case"routeChanged":s.currentRoute=e.data.gist.parameters.route,s.renderStartTime=(new Date).getTime(),J(t,s),n(`Route changed to: ${s.currentRoute}`);break;case"sizeChanged":n(`Size Changed Width: ${e.data.gist.parameters.width} - Height: ${e.data.gist.parameters.height}`),s.elementId&&!s.shouldResizeHeight||function(e,t){var s=oe(e.elementId?e.elementId:ie(e.instanceId));if(s){var n=s.style;if(t.height>0)if(t.height>window.innerHeight){var i=1-(t.height/window.innerHeight-1);e.shouldScale&&i>=.4?(n.height=`${t.height}px`,n.transform=`translateX(-50%) translateY(-50%) scale(${i})`):n.height=`${window.innerHeight}px`}else n.height=`${t.height}px`}}(s,e.data.gist.parameters);break;case"titleChanged":n(`Overlay title changed to: ${e.data.gist.parameters.title}`),function(e,t){var s=oe(ie(e));s&&(s.title=t)}(t,e.data.gist.parameters.title);break;case"eventDispatched":Je.events.dispatch("eventDispatched",{name:e.data.gist.parameters.name,payload:e.data.gist.parameters.payload});break;case"error":case"routeError":Je.messageError(s),Je.overlayInstanceId?Te(!1,s):ke(s)}}var h}async function Le(e){n(`Logging user message view locally for: ${e.queueId}`),ge(e)?await async function(e){n(`Marking broadcast ${e} as seen.`);const t=await pe();if(!t)return;const s=await de(t,e);if(!s)return;const{broadcast:i}=s.properties.gist,r=fe(t,e),c=he(t,e);let u=o(r)||0;if(a(r,u+1),1===i.frequency.count)a(c,!1),n(`Marked broadcast ${e} as seen.`);else{let t=new Date;t.setSeconds(t.getSeconds()+i.frequency.delay),a(c,!1,t),n(`Marked broadcast ${e} as seen, broadcast was seen ${u+1} times, next show date is ${t}.`)}}(e.queueId):await async function(e){const t=await be();if(!t)return;const s=o(t)??[];s.push(e),a(t,s)}(e.queueId)}async function Ne(e){ge(e)&&(n(`Logging broadcast dismissed locally for: ${e.queueId}`),await async function(e){n(`Marking broadcast ${e} as dismissed.`);const t=await pe();if(!t)return;const s=await de(t,e);if(!s)return;const{broadcast:i}=s.properties.gist;!0!==i.frequency.ignoreDismiss?(a(he(t,e),!1),n(`Marked broadcast ${e} as dismissed and will not show again.`)):n(`Broadcast ${e} is set to ignore dismiss.`)}(e.queueId),await xe(e.queueId))}const We="messageInboxUpdated";async function Ae(e){const t=await Oe();if(!t)return;const s=new Date;s.setMinutes(s.getMinutes()+60),a(t,e,s),Je.events.dispatch(We,e)}async function Ue(){const e=await Oe();if(!e)return[];const t=o(e)??[],s=new Date;return t.filter(e=>!e.expiry||new Date(e.expiry)>s)}async function Oe(){const e=await A();return e?`gist.web.inbox.messages.${e}`:null}var _e=(e,t)=>e().then((e=>new Promise(t=>setTimeout(t,e)))(t).then(()=>_e(e,t))),He=!1;let je=null;async function ze(){He?await Ge():N()?(n("Queue watcher started"),He=!0,_e(()=>new Promise(()=>async function(){if(x.hasActiveSSEConnection())return!x.isSSEConnectionManagedBySDK()&&je&&(n("Not the main instance, closing our SSE connection."),Be()),void await Ge();je&&(n("SSE connection not active, closing it."),Be()),!x.useSSE()||L()?await Fe():await async function(){Be();const e=null===(t=U())?(n("No user token available for SSE endpoint."),null):x.GIST_QUEUE_REALTIME_API_ENDPOINT[Je.config.env]+`/api/v3/sse?userToken=${t}&siteId=${Je.config.siteId}&sessionId=${M()}`;var t;if(null===e)return n("SSE endpoint not available, falling back to polling."),void await Fe();n(`Starting SSE queue listener on ${e}`),je=new EventSource(e),x.setActiveSSEConnection(),je.addEventListener("connected",async e=>{try{n("SSE connection received:"),x.setUseSSEFlag(!0);var t=JSON.parse(e.data);t.heartbeat&&(x.setSSEHeartbeat(t.heartbeat),n(`SSE heartbeat set to ${t.heartbeat} seconds`)),x.setActiveSSEConnection()}catch(e){n(`Failed to parse SSE settings: ${e}`)}r(k),await Fe()}),je.addEventListener("messages",async e=>{try{var t=JSON.parse(e.data);n("SSE message received:"),await we(t),await le(t),await Ge()}catch(e){n("Failed to parse SSE message"),Be()}}),je.addEventListener("inbox_messages",async e=>{try{var t=JSON.parse(e.data);n("SSE inbox messages received:"),await Ae(t)}catch(e){n("Failed to parse SSE inbox messages")}}),je.addEventListener("error",async e=>{n("SSE error received:"),Be()}),je.addEventListener("heartbeat",async e=>{n("SSE heartbeat received:"),x.setActiveSSEConnection(),x.setUseSSEFlag(!0)})}()}()),1e3)):n("User token not setup, queue not started.")}async function Ge(){var e=await async function(){const e=await pe();return e?(o(e)??[]).filter(t=>{const{broadcast:s}=t.properties.gist,n=o(he(e,t.queueId))??!0,i=o(fe(e,t.queueId))||0,a=0===s.frequency.count;return n&&(a||i<s.frequency.count)}):[]}(),t=await async function(){const e=await ve();if(!e)return[];const t=o(e)??[],s=await async function(){const e=await be();return e?o(e)??[]:[]}();return t.filter(e=>!s.includes(e.queueId))}(),s=e.concat(t);n(`Messages in local queue: ${s.length}`);var i=s.sort((e,t)=>e.priority-t.priority);for(const e of i)await Ve(e)}async function Ve(e){var t=_(e);if(t.hasRouteRule){var s=Je.currentRoute;null==s&&(s=new URL(window.location.href).pathname);var i=t.routeRule;if(n(`Verifying route ${s} against rule: ${i}`),!new RegExp(i).test(s))return n(`Route ${s} does not match rule.`),!1}if(t.hasPosition&&(e.position=t.position),t.persistent||me(e)){const s=await async function(e){const t=await Ie(e);return t?o(t):null}(e.queueId);s&&(n(`Restoring saved state for queueId ${e.queueId}`),s.displaySettings&&(X(e,s.displaySettings),t=_(e)),e.savedStepName=s.stepName)}if(t.persistent||me(e)||!await async function(e){const t=await Se(e);return!!t&&null!==o(t)}(e.queueId)){var r;return(r=t.isEmbedded?Ee(e,t.elementId):await $e(e))&&async function(e){const t=await Se(e);if(!t)return!1;a(t,!0,new Date(Date.now()+5e3))}(e.queueId),r}return n(`Not showing message with queueId ${e.queueId} because its already loading.`),!1}async function Fe(){if(N())if(Je.isDocumentVisible)if(null===o(k)){var e=await async function(){const e=N();var t;try{if(!D){D=!0;var s={"X-Gist-User-Anonymous":L(),"Content-Language":null!==o(E)?o(E):navigator.language};t=await $().post(`/api/v4/users?sessionId=${M()}`,{},{headers:s})}}catch(e){e.response?t=e.response:n(`Error getting user queue: ${e}`)}finally{D=!1}return e!==N()?(n("User token changed, clearing queue next pull check."),void r(k)):(function(e){if(e&&e.headers){var t=e.headers["x-gist-queue-polling-interval"];t&&t>0&&(C=t)}var s=new Date((new Date).getTime()+1e3*C);a(k,C,s)}(t),function(e){const t="true"===e?.headers?.["x-cio-use-sse"]?.toLowerCase();x.setUseSSEFlag(t)}(t),t)}();if(e){if(200===e.status||204===e.status){n("200 response, updating local store.");var t=e.data?.inAppMessages||[],s=e.data?.inboxMessages||[];we(t),le(t),Ae(s)}else 304===e.status&&n("304 response, using local store.");await Ge()}else n("No response object returned while checking message queue.")}else n("Next queue pull scheduled for later.");else n("Document not visible, skipping queue check.");else n("User token reset, skipping queue check.")}function Be(e=!1){e&&x.removeActiveSSEConnection(),(e||x.isSSEConnectionManagedBySDK())&&x.setUseSSEFlag(!1),je&&(n("Stopping SSE queue listener..."),je.close(),je=null)}const Je=class{static events;static config;static initialized;static currentMessages;static overlayInstanceId;static currentRoute;static isDocumentVisible;static async setup(e){this.initialized?n("Gist SDK already initialized, skipping setup."):(this.initialized=!0,this.events=new s,this.config={useAnonymousSession:void 0!==e.useAnonymousSession&&e.useAnonymousSession,siteId:e.siteId,dataCenter:e.dataCenter,env:void 0===e.env?"prod":e.env,logging:void 0!==e.logging&&e.logging,experiments:void 0!==e.experiments&&e.experiments},this.currentMessages=[],this.overlayInstanceId=null,this.currentRoute=null,this.isDocumentVisible=!0,this.config.isPreviewSession=function(){const e=new URLSearchParams(window.location.search).get("cioPreviewId");return e&&(sessionStorage.setItem(i,String(!1)),Je.setUserToken(e),n(`Preview mode enabled with user token: ${e}`)),!c()}(),function(){const e=u();for(let t=e.length-1;t>=0;t--)l(e.key(t))}(),n(`Setup complete on ${this.config.env} environment.`),this.config.isPreviewSession||!this.config.useAnonymousSession||new URLSearchParams(location.search).has("ajs_uid")||W(),await ze(),document.addEventListener("visibilitychange",async()=>{"hidden"===document.visibilityState?this.isDocumentVisible=!1:(this.isDocumentVisible=!0,await Ge())},!1))}static async setCurrentRoute(e){this.currentRoute=e,n(`Current route set to: ${e}`),await Ge()}static async setUserToken(e,t){this.config.isPreviewSession||(function(e,t){void 0===t&&(t=new Date).setDate(t.getDate()+30),a(q,e,t),L()&&(r(k),r(P)),n(`Set user token "${e}" with expiry date set to ${t}`)}(e,t),Be(!0),await ze())}static setUserLocale(e){var t;a(E,t=e),n(`Set user locate to "${t}"`)}static setCustomAttribute(e,t){return function(e,t){return e&&"string"==typeof e?(ce.set(e,t),ue(),n(`Set custom attribute "${e}" to "${t}"`),!0):(n(`Invalid key for custom attribute: ${e}`),!1)}(e,t)}static clearCustomAttributes(){ce.clear(),r(re),n("Cleared all custom attributes")}static removeCustomAttribute(e){return function(e){if(!e||"string"!=typeof e)return n(`Invalid key for custom attribute: ${e}`),!1;const t=ce.has(e);return ce.delete(e),ce.size>0?ue():r(re),n(`Removed custom attribute "${e}"`),t}(e)}static async clearUserToken(){this.config.isPreviewSession||(r(q),n("Cleared user token"),this.config.useAnonymousSession&&W(),Be(!0),await ze())}static async dismissMessage(e){var t=G(e);await Ce(t),await De(t),await Ne(t),await Ge()}static async embedMessage(e,t){var s=Ee(e,t);return s?s.instanceId:null}static async showMessage(e){var t=await $e(e);return t?t.instanceId:null}static updateMessageDisplaySettings(e,t){var s=G(e);return!!s&&(s.displaySettings=t,te(s),!0)}static messageShown(e){n(`Message shown: ${e.messageId}`),this.events.dispatch("messageShown",e)}static messageDismissed(e){null!==e&&(n(`Message dismissed: ${e.messageId}`),this.events.dispatch("messageDismissed",e))}static messageError(e){n(`Message error: ${e.messageId}`),this.events.dispatch("messageError",e)}static messageAction(e,t,s){n(`Message action: ${e.currentRoute}, ${t} with name ${s} on ${e.instanceId}`),this.events.dispatch("messageAction",{message:e,action:t,name:s})}static async getInboxUnopenedCount(){return(await Ue()).filter(e=>!e.opened).length}static async getInboxMessages(){return await Ue()}static async updateInboxMessageOpenState(e,t){return await async function(e,t){const s=await Oe();if(!s)return;const i=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.response}}(e,{opened:t});if(!i||i.status<200||i.status>=300){const e=`Failed to mark inbox message opened: ${i?.status||"unknown error"}`;throw n(e),new Error(e)}const o=await Ue();let r=null;const c=o.map(s=>s.queueId===e?(s.opened=t,r=s,{...s}):s),u=new Date;if(u.setMinutes(u.getMinutes()+60),a(s,c,u),r){const e=t?"opened":"unopened";Je.events.dispatch("inboxMessageAction",{message:r,action:e})}Je.events.dispatch(We,await Ue())}(e,t)}static async removeInboxMessage(e){return await async function(e){const t=await Oe();if(!t)return;const s=await O(e);if(!s||s.status<200||s.status>=300){const e=`Failed to remove inbox message: ${s?.status||"unknown error"}`;throw n(e),new Error(e)}const i=(await Ue()).filter(t=>t.queueId!==e),o=new Date;o.setMinutes(o.getMinutes()+60),a(t,i,o),Je.events.dispatch(We,await Ue())}(e)}};return t.default})());
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export default class _default {
|
|
2
|
+
/** @type {import('./utilities/event-emitter').default} */
|
|
3
|
+
static events: import("./utilities/event-emitter").default;
|
|
4
|
+
/** @type {import('./types').GistConfig} */
|
|
5
|
+
static config: import("./types").GistConfig;
|
|
6
|
+
/** @type {boolean} */
|
|
7
|
+
static initialized: boolean;
|
|
8
|
+
/** @type {any[]} */
|
|
9
|
+
static currentMessages: any[];
|
|
10
|
+
/** @type {string | null} */
|
|
11
|
+
static overlayInstanceId: string | null;
|
|
12
|
+
/** @type {string | null} */
|
|
13
|
+
static currentRoute: string | null;
|
|
14
|
+
/** @type {boolean} */
|
|
15
|
+
static isDocumentVisible: boolean;
|
|
16
|
+
static setup(config: any): Promise<void>;
|
|
17
|
+
static setCurrentRoute(route: any): Promise<void>;
|
|
18
|
+
/** @param {string} userToken @param {Date} [expiryDate] */
|
|
19
|
+
static setUserToken(userToken: string, expiryDate?: Date): Promise<void>;
|
|
20
|
+
static setUserLocale(userLocale: any): void;
|
|
21
|
+
static setCustomAttribute(key: any, value: any): boolean;
|
|
22
|
+
static clearCustomAttributes(): void;
|
|
23
|
+
static removeCustomAttribute(key: any): boolean;
|
|
24
|
+
static clearUserToken(): Promise<void>;
|
|
25
|
+
static dismissMessage(instanceId: any): Promise<void>;
|
|
26
|
+
static embedMessage(message: any, elementId: any): Promise<any>;
|
|
27
|
+
static showMessage(message: any): Promise<any>;
|
|
28
|
+
static updateMessageDisplaySettings(instanceId: any, displaySettings: any): boolean;
|
|
29
|
+
static messageShown(message: any): void;
|
|
30
|
+
static messageDismissed(message: any): void;
|
|
31
|
+
static messageError(message: any): void;
|
|
32
|
+
static messageAction(message: any, action: any, name: any): void;
|
|
33
|
+
static getInboxUnopenedCount(): Promise<any>;
|
|
34
|
+
static getInboxMessages(): Promise<any>;
|
|
35
|
+
static updateInboxMessageOpenState(queueId: any, opened: any): Promise<void>;
|
|
36
|
+
static removeInboxMessage(queueId: any): Promise<void>;
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./gist";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export function setCustomAttribute(key: any, value: any): boolean;
|
|
2
|
+
export function getCustomAttribute(key: any): any;
|
|
3
|
+
export function getAllCustomAttributes(): Map<any, any>;
|
|
4
|
+
export function clearCustomAttributes(): void;
|
|
5
|
+
export function removeCustomAttribute(key: any): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function resolveMessageProperties(message: any): {
|
|
2
|
+
isEmbedded: boolean;
|
|
3
|
+
elementId: any;
|
|
4
|
+
hasRouteRule: boolean;
|
|
5
|
+
routeRule: any;
|
|
6
|
+
position: any;
|
|
7
|
+
hasPosition: boolean;
|
|
8
|
+
shouldScale: boolean;
|
|
9
|
+
campaignId: any;
|
|
10
|
+
messageWidth: any;
|
|
11
|
+
hasCustomWidth: boolean;
|
|
12
|
+
overlayColor: any;
|
|
13
|
+
persistent: boolean;
|
|
14
|
+
exitClick: boolean;
|
|
15
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export function updateInboxMessagesLocalStore(messages: any): Promise<void>;
|
|
2
|
+
export function getInboxMessagesFromLocalStore(): Promise<any>;
|
|
3
|
+
export function getInboxMessagesByTopic(topic: any): Promise<any>;
|
|
4
|
+
export function updateInboxMessageOpenState(queueId: any, opened: any): Promise<void>;
|
|
5
|
+
export function removeInboxMessage(queueId: any): Promise<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export function updateBroadcastsLocalStore(messages: any): Promise<void>;
|
|
2
|
+
export function getEligibleBroadcasts(): Promise<any>;
|
|
3
|
+
export function markBroadcastAsSeen(broadcastId: any): Promise<void>;
|
|
4
|
+
export function markBroadcastAsDismissed(broadcastId: any): Promise<void>;
|
|
5
|
+
export function isMessageBroadcast(message: any): any;
|
|
6
|
+
export function isShowAlwaysBroadcast(message: any): boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function loadEmbedComponent(elementId: any, url: any, message: any, options: any, stepName?: null): void;
|
|
2
|
+
export function showEmbedComponent(elementId: any): void;
|
|
3
|
+
export function hideEmbedComponent(elementId: any): void;
|
|
4
|
+
export function elementHasHeight(elementId: any): any;
|
|
5
|
+
export function resizeComponent(message: any, size: any): void;
|
|
6
|
+
export function loadOverlayComponent(url: any, message: any, options: any, stepName?: null): void;
|
|
7
|
+
export function sendOptionsToIframe(iframeId: any, options: any, stepName?: null): void;
|
|
8
|
+
export function sendDisplaySettingsToIframe(message: any): void;
|
|
9
|
+
export function showOverlayComponent(message: any): void;
|
|
10
|
+
export function hideOverlayComponent(): Promise<void>;
|
|
11
|
+
export function removeOverlayComponent(): void;
|
|
12
|
+
export function changeOverlayTitle(instanceId: any, title: any): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export function showMessage(message: any): Promise<any>;
|
|
2
|
+
export function embedMessage(message: any, elementId: any): any;
|
|
3
|
+
export function hideMessage(message: any): Promise<void>;
|
|
4
|
+
export function removePersistentMessage(message: any): Promise<void>;
|
|
5
|
+
export function logBroadcastDismissedLocally(message: any): Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function updateQueueLocalStore(messages: any): Promise<void>;
|
|
2
|
+
export function getMessagesFromLocalStore(): Promise<any>;
|
|
3
|
+
export function markUserQueueMessageAsSeen(queueId: any): Promise<void>;
|
|
4
|
+
export function isMessageLoading(queueId: any): Promise<boolean>;
|
|
5
|
+
export function setMessageLoading(queueId: any): Promise<false | undefined>;
|
|
6
|
+
export function setMessageLoaded(queueId: any): Promise<false | undefined>;
|
|
7
|
+
export function saveMessageState(queueId: any, stepName: any, displaySettings: any): Promise<void>;
|
|
8
|
+
export function getSavedMessageState(queueId: any): Promise<unknown>;
|
|
9
|
+
export function clearMessageState(queueId: any): Promise<void>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function isUsingGuestUserToken(): boolean;
|
|
2
|
+
export function getUserToken(): unknown;
|
|
3
|
+
export function setUserToken(userToken: any, expiryDate: any): void;
|
|
4
|
+
export function useGuestSession(): void;
|
|
5
|
+
export function isAnonymousUser(): boolean;
|
|
6
|
+
export function getHashedUserToken(): Promise<string | null>;
|
|
7
|
+
export function getEncodedUserToken(): string | null;
|
|
8
|
+
export function clearUserToken(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function updateMessage(queueId: any, updatedFields: any): Promise<any>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function UserNetworkInstance(): {
|
|
2
|
+
(path: any, options?: {}): Promise<{
|
|
3
|
+
status: number;
|
|
4
|
+
headers: {
|
|
5
|
+
[k: string]: string;
|
|
6
|
+
};
|
|
7
|
+
data: any;
|
|
8
|
+
}>;
|
|
9
|
+
post(path: any, data?: {}, config?: {}): Promise<{
|
|
10
|
+
status: number;
|
|
11
|
+
headers: {
|
|
12
|
+
[k: string]: string;
|
|
13
|
+
};
|
|
14
|
+
data: any;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export namespace settings {
|
|
2
|
+
let RENDERER_HOST: string;
|
|
3
|
+
namespace ENGINE_API_ENDPOINT {
|
|
4
|
+
let prod: string;
|
|
5
|
+
let dev: string;
|
|
6
|
+
let local: string;
|
|
7
|
+
}
|
|
8
|
+
namespace GIST_QUEUE_API_ENDPOINT {
|
|
9
|
+
let prod_1: string;
|
|
10
|
+
export { prod_1 as prod };
|
|
11
|
+
let dev_1: string;
|
|
12
|
+
export { dev_1 as dev };
|
|
13
|
+
let local_1: string;
|
|
14
|
+
export { local_1 as local };
|
|
15
|
+
}
|
|
16
|
+
namespace GIST_QUEUE_REALTIME_API_ENDPOINT {
|
|
17
|
+
let prod_2: string;
|
|
18
|
+
export { prod_2 as prod };
|
|
19
|
+
let dev_2: string;
|
|
20
|
+
export { dev_2 as dev };
|
|
21
|
+
let local_2: string;
|
|
22
|
+
export { local_2 as local };
|
|
23
|
+
}
|
|
24
|
+
namespace GIST_VIEW_ENDPOINT {
|
|
25
|
+
let prod_3: string;
|
|
26
|
+
export { prod_3 as prod };
|
|
27
|
+
let dev_3: string;
|
|
28
|
+
export { dev_3 as dev };
|
|
29
|
+
let local_3: string;
|
|
30
|
+
export { local_3 as local };
|
|
31
|
+
}
|
|
32
|
+
function getSdkId(): any;
|
|
33
|
+
function useSSE(): {};
|
|
34
|
+
function setUseSSEFlag(useSSE: any): void;
|
|
35
|
+
function removeActiveSSEConnection(): void;
|
|
36
|
+
function setActiveSSEConnection(): void;
|
|
37
|
+
function hasActiveSSEConnection(): {};
|
|
38
|
+
function isSSEConnectionManagedBySDK(): boolean;
|
|
39
|
+
function getSSEHeartbeat(): number;
|
|
40
|
+
function setSSEHeartbeat(heartbeat: any): void;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function embedHTMLTemplate(elementId: any, messageProperties: any, url: any): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function messageHTMLTemplate(elementId: any, messageProperties: any, url: any): string;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export type GistEnv = "prod" | "dev" | "local";
|
|
2
|
+
export interface GistConfig {
|
|
3
|
+
siteId: string;
|
|
4
|
+
dataCenter: string;
|
|
5
|
+
env?: GistEnv;
|
|
6
|
+
logging?: boolean;
|
|
7
|
+
experiments?: boolean;
|
|
8
|
+
useAnonymousSession?: boolean;
|
|
9
|
+
isPreviewSession?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface GistMessage {
|
|
12
|
+
messageId: string;
|
|
13
|
+
queueId?: string;
|
|
14
|
+
instanceId?: string;
|
|
15
|
+
overlay?: boolean;
|
|
16
|
+
elementId?: string | null;
|
|
17
|
+
firstLoad?: boolean;
|
|
18
|
+
shouldScale?: boolean;
|
|
19
|
+
shouldResizeHeight?: boolean;
|
|
20
|
+
renderStartTime?: number;
|
|
21
|
+
currentRoute?: string;
|
|
22
|
+
position?: string;
|
|
23
|
+
savedStepName?: string | null;
|
|
24
|
+
isDisplayChange?: boolean;
|
|
25
|
+
displaySettings?: DisplaySettings;
|
|
26
|
+
properties?: MessageProperties;
|
|
27
|
+
}
|
|
28
|
+
export interface DisplaySettings {
|
|
29
|
+
displayType?: "modal" | "overlay" | "inline" | "tooltip";
|
|
30
|
+
modalPosition?: string;
|
|
31
|
+
overlayPosition?: string;
|
|
32
|
+
elementSelector?: string;
|
|
33
|
+
maxWidth?: number;
|
|
34
|
+
overlayColor?: string;
|
|
35
|
+
dismissOutsideClick?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface MessageProperties {
|
|
38
|
+
gist?: GistProperties;
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
}
|
|
41
|
+
export interface GistProperties {
|
|
42
|
+
elementId?: string | null;
|
|
43
|
+
position?: string | null;
|
|
44
|
+
messageWidth?: number;
|
|
45
|
+
overlayColor?: string;
|
|
46
|
+
exitClick?: boolean;
|
|
47
|
+
tooltipPosition?: string;
|
|
48
|
+
routeRuleWeb?: string;
|
|
49
|
+
scale?: boolean;
|
|
50
|
+
campaignId?: string | null;
|
|
51
|
+
persistent?: boolean;
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
}
|
|
54
|
+
export interface ResolvedMessageProperties {
|
|
55
|
+
isEmbedded: boolean;
|
|
56
|
+
elementId: string;
|
|
57
|
+
hasRouteRule: boolean;
|
|
58
|
+
routeRule: string;
|
|
59
|
+
position: string;
|
|
60
|
+
hasPosition: boolean;
|
|
61
|
+
shouldScale: boolean;
|
|
62
|
+
campaignId: string | null;
|
|
63
|
+
messageWidth: number;
|
|
64
|
+
overlayColor: string;
|
|
65
|
+
persistent: boolean;
|
|
66
|
+
exitClick: boolean;
|
|
67
|
+
hasCustomWidth: boolean;
|
|
68
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type EventCallback = (event: unknown) => void;
|
|
2
|
+
export default class EventEmitter {
|
|
3
|
+
private callbacks;
|
|
4
|
+
on(name: string, callback: EventCallback): void;
|
|
5
|
+
off(name: string, callback?: EventCallback): void;
|
|
6
|
+
dispatch(name: string, event: unknown): void;
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function shouldPersistSession(persisted: boolean | string): void;
|
|
2
|
+
export declare function setKeyToLocalStore(key: string, value: unknown, ttl?: Date | null): void;
|
|
3
|
+
export declare function getKeyFromLocalStore(key: string): unknown | null;
|
|
4
|
+
export declare function clearKeyFromLocalStore(key: string): void;
|
|
5
|
+
export declare function clearExpiredFromLocalStore(): void;
|
|
6
|
+
export declare function isSessionBeingPersisted(): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function log(message: string): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function fetchMessageByInstanceId(instanceId: any): any;
|
|
2
|
+
export function isQueueIdAlreadyShowing(queueId: any): boolean;
|
|
3
|
+
export function fetchMessageByElementId(elementId: any): any;
|
|
4
|
+
export function removeMessageByInstanceId(instanceId: any): void;
|
|
5
|
+
export function updateMessageByInstanceId(instanceId: any, message: any): void;
|
|
6
|
+
export function mapOverlayPositionToElementId(overlayPosition: any): any;
|
|
7
|
+
export function getCurrentDisplayType(message: any): "modal" | "overlay" | "inline";
|
|
8
|
+
export function hasDisplayChanged(currentMessage: any, displaySettings: any): boolean;
|
|
9
|
+
export function applyDisplaySettings(message: any, displaySettings: any): void;
|
|
10
|
+
export const wideOverlayPositions: string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function setupPreview(): boolean;
|
package/package.json
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "customerio-gist-web",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.19.1",
|
|
4
4
|
"description": "Build beautiful in-app flows with no code and deliver them instantly to your app. http://customer.io",
|
|
5
5
|
"private": false,
|
|
6
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"src"
|
|
9
|
+
],
|
|
6
10
|
"scripts": {
|
|
7
11
|
"start": "npm-run-all --parallel watch:server watch:build",
|
|
8
|
-
"build:prod": "webpack --mode=production --output-filename gist.min.js",
|
|
12
|
+
"build:prod": "webpack --mode=production --output-filename gist.min.js && npm run build:types",
|
|
13
|
+
"build:types": "tsc --project tsconfig.build.json",
|
|
9
14
|
"watch:build": "webpack --watch --progress --mode=development",
|
|
10
|
-
"watch:server": "http-server"
|
|
15
|
+
"watch:server": "http-server",
|
|
16
|
+
"test": "vitest run",
|
|
17
|
+
"test:watch": "vitest",
|
|
18
|
+
"typecheck": "tsc --noEmit"
|
|
11
19
|
},
|
|
20
|
+
"types": "./dist/types/index.d.ts",
|
|
12
21
|
"browser": "dist/gist.min.js",
|
|
13
22
|
"exports": {
|
|
23
|
+
"types": "./dist/types/index.d.ts",
|
|
14
24
|
"require": "./dist/gist.min.js",
|
|
15
25
|
"import": "./src/index.js"
|
|
16
26
|
},
|
|
@@ -21,7 +31,12 @@
|
|
|
21
31
|
"eslint": "^9.13.0",
|
|
22
32
|
"globals": "^15.11.0",
|
|
23
33
|
"http-server": "^14.1.1",
|
|
34
|
+
"jsdom": "^26.1.0",
|
|
24
35
|
"npm-run-all": "^4.1.5",
|
|
36
|
+
"ts-loader": "^9.5.4",
|
|
37
|
+
"typescript": "^5.9.3",
|
|
38
|
+
"typescript-eslint": "^8.56.0",
|
|
39
|
+
"vitest": "^4.0.18",
|
|
25
40
|
"webpack": "^5.91.0",
|
|
26
41
|
"webpack-cli": "^5.1.4"
|
|
27
42
|
},
|