UNPKG

@swrve/web-sdk

Version:
1 lines 168 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SwrveSDK=t():e.SwrveSDK=t()}(self,(()=>{return e={996:function(e){var t;t=()=>(()=>{var e={25:()=>{"use strict";!function(){if(void 0===window.Reflect||void 0===window.customElements||window.customElements.polyfillWrapFlushCallback)return;const e=HTMLElement;window.HTMLElement=function(){return Reflect.construct(e,[],this.constructor)},HTMLElement.prototype=e.prototype,HTMLElement.prototype.constructor=HTMLElement,Object.setPrototypeOf(HTMLElement,e)}()},21:function(e,t,n){var r;e.exports=(r=r||function(e){var t;if("undefined"!=typeof window&&window.crypto&&(t=window.crypto),"undefined"!=typeof self&&self.crypto&&(t=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(t=globalThis.crypto),!t&&"undefined"!=typeof window&&window.msCrypto&&(t=window.msCrypto),!t&&void 0!==n.g&&n.g.crypto&&(t=n.g.crypto),!t)try{t=n(477)}catch(e){}var r=function(){if(t){if("function"==typeof t.getRandomValues)try{return t.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof t.randomBytes)try{return t.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},i=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),s={},o=s.lib={},a=o.Base={extend:function(e){var t=i(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},u=o.WordArray=a.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,i=e.sigBytes;if(this.clamp(),r%4)for(var s=0;s<i;s++){var o=n[s>>>2]>>>24-s%4*8&255;t[r+s>>>2]|=o<<24-(r+s)%4*8}else for(var a=0;a<i;a+=4)t[r+a>>>2]=n[a>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(r());return new u.init(t,e)}}),c=s.enc={},l=c.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var s=t[i>>>2]>>>24-i%4*8&255;r.push((s>>>4).toString(16)),r.push((15&s).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new u.init(n,t/2)}},p=c.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var s=t[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(s))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new u.init(n,t)}},h=c.Utf8={stringify:function(e){try{return decodeURIComponent(escape(p.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return p.parse(unescape(encodeURIComponent(e)))}},g=o.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n,r=this._data,i=r.words,s=r.sigBytes,o=this.blockSize,a=s/(4*o),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,l=e.min(4*c,s);if(c){for(var p=0;p<c;p+=o)this._doProcessBlock(i,p);n=i.splice(0,c),r.sigBytes-=l}return new u.init(n,l)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),f=(o.Hasher=g.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){g.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new f.HMAC.init(e,n).finalize(t)}}}),s.algo={});return s}(Math),r)},636:function(e,t,n){var r;e.exports=(r=n(21),function(e){var t=r,n=t.lib,i=n.WordArray,s=n.Hasher,o=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var u=o.MD5=s.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var n=0;n<16;n++){var r=t+n,i=e[r];e[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var s=this._hash.words,o=e[t+0],u=e[t+1],g=e[t+2],f=e[t+3],d=e[t+4],_=e[t+5],v=e[t+6],m=e[t+7],y=e[t+8],E=e[t+9],S=e[t+10],b=e[t+11],w=e[t+12],I=e[t+13],C=e[t+14],M=e[t+15],A=s[0],T=s[1],N=s[2],P=s[3];A=c(A,T,N,P,o,7,a[0]),P=c(P,A,T,N,u,12,a[1]),N=c(N,P,A,T,g,17,a[2]),T=c(T,N,P,A,f,22,a[3]),A=c(A,T,N,P,d,7,a[4]),P=c(P,A,T,N,_,12,a[5]),N=c(N,P,A,T,v,17,a[6]),T=c(T,N,P,A,m,22,a[7]),A=c(A,T,N,P,y,7,a[8]),P=c(P,A,T,N,E,12,a[9]),N=c(N,P,A,T,S,17,a[10]),T=c(T,N,P,A,b,22,a[11]),A=c(A,T,N,P,w,7,a[12]),P=c(P,A,T,N,I,12,a[13]),N=c(N,P,A,T,C,17,a[14]),A=l(A,T=c(T,N,P,A,M,22,a[15]),N,P,u,5,a[16]),P=l(P,A,T,N,v,9,a[17]),N=l(N,P,A,T,b,14,a[18]),T=l(T,N,P,A,o,20,a[19]),A=l(A,T,N,P,_,5,a[20]),P=l(P,A,T,N,S,9,a[21]),N=l(N,P,A,T,M,14,a[22]),T=l(T,N,P,A,d,20,a[23]),A=l(A,T,N,P,E,5,a[24]),P=l(P,A,T,N,C,9,a[25]),N=l(N,P,A,T,f,14,a[26]),T=l(T,N,P,A,y,20,a[27]),A=l(A,T,N,P,I,5,a[28]),P=l(P,A,T,N,g,9,a[29]),N=l(N,P,A,T,m,14,a[30]),A=p(A,T=l(T,N,P,A,w,20,a[31]),N,P,_,4,a[32]),P=p(P,A,T,N,y,11,a[33]),N=p(N,P,A,T,b,16,a[34]),T=p(T,N,P,A,C,23,a[35]),A=p(A,T,N,P,u,4,a[36]),P=p(P,A,T,N,d,11,a[37]),N=p(N,P,A,T,m,16,a[38]),T=p(T,N,P,A,S,23,a[39]),A=p(A,T,N,P,I,4,a[40]),P=p(P,A,T,N,o,11,a[41]),N=p(N,P,A,T,f,16,a[42]),T=p(T,N,P,A,v,23,a[43]),A=p(A,T,N,P,E,4,a[44]),P=p(P,A,T,N,w,11,a[45]),N=p(N,P,A,T,M,16,a[46]),A=h(A,T=p(T,N,P,A,g,23,a[47]),N,P,o,6,a[48]),P=h(P,A,T,N,m,10,a[49]),N=h(N,P,A,T,C,15,a[50]),T=h(T,N,P,A,_,21,a[51]),A=h(A,T,N,P,w,6,a[52]),P=h(P,A,T,N,f,10,a[53]),N=h(N,P,A,T,S,15,a[54]),T=h(T,N,P,A,u,21,a[55]),A=h(A,T,N,P,y,6,a[56]),P=h(P,A,T,N,M,10,a[57]),N=h(N,P,A,T,v,15,a[58]),T=h(T,N,P,A,I,21,a[59]),A=h(A,T,N,P,d,6,a[60]),P=h(P,A,T,N,b,10,a[61]),N=h(N,P,A,T,g,15,a[62]),T=h(T,N,P,A,E,21,a[63]),s[0]=s[0]+A|0,s[1]=s[1]+T|0,s[2]=s[2]+N|0,s[3]=s[3]+P|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var s=e.floor(r/4294967296),o=r;n[15+(i+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),n[14+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),t.sigBytes=4*(n.length+1),this._process();for(var a=this._hash,u=a.words,c=0;c<4;c++){var l=u[c];u[c]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}});function c(e,t,n,r,i,s,o){var a=e+(t&n|~t&r)+i+o;return(a<<s|a>>>32-s)+t}function l(e,t,n,r,i,s,o){var a=e+(t&r|n&~r)+i+o;return(a<<s|a>>>32-s)+t}function p(e,t,n,r,i,s,o){var a=e+(t^n^r)+i+o;return(a<<s|a>>>32-s)+t}function h(e,t,n,r,i,s,o){var a=e+(n^(t|~r))+i+o;return(a<<s|a>>>32-s)+t}t.MD5=s._createHelper(u),t.HmacMD5=s._createHmacHelper(u)}(Math),r.MD5)},846:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetManager=void 0;var i=r(n(706)),s=r(n(138)),o=function(){function e(){this.assets={},this._imagesCDN="",this._fontsCDN=""}return e.prototype.manageAssets=function(e){for(var t=0,n=e;t<n.length;t++){var r=n[t],i=r.getAssetID();void 0===this.assets[i]&&(s.default.info("add new asset "+i),this.assets[i]={id:i,path:r.getAssetPath().toString()})}return this.downloadAssets()},Object.defineProperty(e.prototype,"ImagesCDN",{get:function(){return this._imagesCDN},set:function(e){this._imagesCDN=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"FontsCDN",{get:function(){return this._fontsCDN},set:function(e){this._fontsCDN=e},enumerable:!1,configurable:!0}),e.prototype.clearCDN=function(){this._imagesCDN="",this._fontsCDN=""},e.prototype.checkAssetsForCampaign=function(e){for(var t=!0,n=0,r=e;n<r.length;n++){var i=r[n];if(!this.checkCache(i)){t=!1;break}}return t},e.prototype.checkCache=function(e){return i.default.getPlatform().checkStorageForAsset(e)},e.prototype.downloadAssets=function(){var e=this;s.default.info("download assets");var t=Object.keys(this.assets).map((function(t){return e.assets[t]}));return i.default.getPlatform().downloadAssets(t)},e}();t.AssetManager=o},496:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CampaignManager=void 0;var s=n(357),o=n(341),a=n(846),u=i(n(138)),c=n(705),l=n(872),p=i(n(67)),h=n(337),g=function(){function e(e,t,n,r){this.profileManager=e,this.campaigns=[],this.campaignState={},this.messages=[],this.triggers=[],this.onEmbeddedListener=null,this._maxMessagesPerSession=99999,this._minDelay=55,this._delayFirstMessage=150,this.MAX_MESSAGES_PER_SESSION=99999,this.MIN_DELAY=55,this.DELAY_FIRST_MESSAGE=150,this.messagesShownCount=0,this.lastShownMessageTime=0,this.storageManager=n,this.loadStoredCampaigns(this.profileManager.currentUser.userId),this.messageDisplayManager=new o.SwrveMessageDisplayManager(t,r),this.assetManager=new a.AssetManager,this.platform=t}return e.prototype.storeCampaigns=function(e,t,n){void 0!==e&&e.campaigns&&(this.handleCDN(e),this.campaigns=e.campaigns.campaigns||[],this.updateEmbeddedMessagesRawData(this.campaigns),this.parseGlobalRules(e.campaigns),this.parseMessages(this.campaigns),this.parseTriggers(this.campaigns),this.synchronizeCampaignState(),this.handleAssets(n,t),this.storageManager.saveData(s.CAMPAIGNS+this.profileManager.currentUser.userId,JSON.stringify(this.campaigns)))},e.prototype.resetCampaignState=function(){this.campaigns=[],this.messages=[],this.triggers=[],this.campaignState={},this.messagesShownCount=0,this.lastShownMessageTime=0},e.prototype.loadStoredCampaigns=function(e){this.resetCampaignState();var t=this.storageManager.getData(s.CAMPAIGNS+e);t&&(this.campaigns=JSON.parse(t),this.updateEmbeddedMessagesRawData(this.campaigns));var n=this.storageManager.getData(s.CAMPAIGN_STATE+e);n&&(this.campaignState=JSON.parse(n)),this.campaigns&&(this.parseMessages(this.campaigns),this.parseTriggers(this.campaigns))},e.prototype.synchronizeCampaignState=function(){var e=this,t=this.campaignState;this.campaignState={},this.campaigns.forEach((function(n){var r=n.id;e.campaignState[r]=t[r]||{status:s.SWRVE_CAMPAIGN_STATUS_UNSEEN,impressions:0,next:0,lastShownTime:0}})),this.storageManager.saveData(s.CAMPAIGN_STATE+this.profileManager.currentUser.userId,JSON.stringify(this.campaignState))},e.prototype.getCampaignIDs=function(){var e=this;return this.campaigns.map((function(t){return{id:t.id,type:t.messages?"iam":"unknown",variant_id:e.getCampaignVariantID(t)}}))},e.prototype.getCampaignVariantID=function(e){return e.messages&&e.messages[0]?e.messages[0].id:0},e.prototype.getCampaignState=function(e){return this.campaignState[e]},e.prototype.onEmbeddedMessage=function(e){this.onEmbeddedListener=e},e.prototype.onButtonClicked=function(e){this.messageDisplayManager.onButtonClicked(e)},e.prototype.showCampaign=function(e,t,n){if(e.messages&&e.messages.length>0){var r=e.messages[0];return r.parentCampaign=e.id,this.canCampaignRender(e,t)?(this.messageDisplayManager.showMessage(e.messages[0],e,this.assetManager.ImagesCDN,t),n&&n(r),this.updateCampaignState(r),!0):(u.default.error("cannot render campaign, not attempting to display"),!1)}return!(!e.embedded_message||!e.embedded_message.data||(e.embedded_message.parentCampaign=e.id,this.onEmbeddedListener&&this.onEmbeddedListener(e.embedded_message,t),0))},e.prototype.checkTriggers=function(e,t,n,i,o){var a=this;void 0===i&&(i=!1);var c,l=[],p=this.applyGlobalRules(),h=[];function g(e,t,n,r){u.default.debug("campaign trigger status: "+n+" displayed "+t),c={status:r,message:n},h.push({id:e,displayed:t,type:"iam",reason:n})}if(p.status===s.CAMPAIGN_MATCH)if(this.campaigns.forEach((function(n){if(n.triggers&&n.triggers.length>0)for(var o=0,u=n.triggers;o<u.length;o++){var c=u[o],p=c.event_name===e&&a.canTriggerWithPayload(c,t);if(!p&&i){var h="Campaign ["+n.id+"], Trigger ["+c.event_name+"], does not match eventName["+e+"] & payload["+JSON.stringify(t)+"]. Skipping this trigger.";g(n.id,"false",h,s.CAMPAIGN_NO_MATCH)}if(p){n.messages?n.messages.forEach((function(e){return l.push(r({parentCampaign:n.id},e))})):n.embedded_message&&l.push(r({parentCampaign:n.id},n.embedded_message));break}}else i&&(h="Campaign ["+n.id+"], no triggers (could be message centre). Skipping this campaign",g(n.id,"false",h,s.CAMPAIGN_ERROR_INVALID_TRIGGERS))})),l.length>0){l.sort((function(e,t){return e.priority-t.priority}));var f=l.filter((function(e){for(var t=0,n=a.campaigns;t<n.length;t++){var r=n[t];if(r.id===e.parentCampaign){var c=a.applyCampaignRules(r,o),l=c.status,p=c.message,h=l===s.CAMPAIGN_MATCH;return u.default.debug(p),i&&!h&&g(r.id,"false",p,l),h}}return!1}));if(f.length>1){var d=f.reduce((function(e,t){return t.priority<e?t.priority:e}),f[0].priority);f=f.filter((function(e){return e.priority<=d}))}if(f.length>0){var _=f.length>1?Math.floor(Math.random()*f.length):0,v=f[_];if(i){var m=f[_];f.filter((function(e,t){return t!==_})).forEach((function(e){var t="Campaign "+m.id+" was selected for display ahead of this campaign.";g(e.parentCampaign,"false",t,s.CAMPAIGN_ELIGIBLE_BUT_OTHER_CHOSEN)}));var y="Campaign ["+m.id+"], Trigger ["+e+"], matches "+e+" & payload "+JSON.stringify(t)+".";g(m.parentCampaign,"true",y,s.CAMPAIGN_MATCH)}if(this.lastShownMessageTime=this.getNow(),!this.messageDisplayManager.isIAMShowing())for(var E=0,S=this.campaigns;E<S.length;E++){var b=S[E];if(b.id===v.parentCampaign){if(b.messages&&b.messages.length>0){this.showMessage(v,b,o),this.updateCampaignState(v),n(v);break}if(b.embedded_message&&b.embedded_message.data){this.onEmbeddedListener&&this.onEmbeddedListener(v,o);break}}}}}else i&&(p={status:s.CAMPAIGN_NO_MATCH,message:"No matching campaigns."});var w=p.status===s.CAMPAIGN_MATCH&&c?c.status:p.status;return{globalStatus:p,campaignStatus:c,campaignFailCode:w,campaigns:h}},e.prototype.showMessage=function(e,t,n){this.messageDisplayManager.showMessage(e,t,this.assetManager.ImagesCDN,n)},e.prototype.closeMessage=function(){this.messageDisplayManager.closeMessage()},e.prototype.canTriggerWithPayload=function(e,t){return!("object"!=typeof e||!e)&&this.hasFulfilledCondition(e.conditions||{},t||{})},e.prototype.hasFulfilledCondition=function(e,t){switch(e.op){case"eq":return t[e.key]===e.value;case"and":for(var n=0,r=e.args;n<r.length;n++){var i=r[n];if(!this.hasFulfilledCondition(i,t))return!1}return!0;default:return 0===Object.keys(e).length}},e.prototype.handleCDN=function(e){if(this.assetManager.clearCDN(),e.campaigns&&e.campaigns.cdn_root)this.assetManager.ImagesCDN=e.campaigns.cdn_root;else if(e.campaigns&&e.campaigns.cdn_paths){var t=e.campaigns.cdn_paths;this.assetManager.ImagesCDN=t.message_images,this.assetManager.FontsCDN=t.message_fonts}},e.prototype.getAssetManager=function(){return this.assetManager},e.prototype.getMessageCenterCampaigns=function(e){var t=this;return this.campaigns.filter((function(n){return n.message_center&&t.campaignState[n.id].status!==s.SWRVE_CAMPAIGN_STATUS_DELETED&&t.canCampaignRender(n,e)})).map((function(e){return r({},e)}))},e.prototype.getEmbeddedMessageCenterCampaigns=function(e){var t=this;return this.campaigns.filter((function(e){return e.message_center&&e.embedded_message&&t.campaignState[e.id].status!==s.SWRVE_CAMPAIGN_STATUS_DELETED&&t.isCampaignActive(e,t.getNow())})).map((function(t){var n=t.embedded_message,i=r(r({},n),{data:n.data,dataRaw:n.data});try{var s;null!=(s="json"===i.type?h.TextTemplating.applyTextTemplatingToJSON(i.dataRaw,e):h.TextTemplating.applyTextTemplatingToString(i.dataRaw,e))&&(i.data=s)}catch(e){}return i}))},e.prototype.updateCampaignState=function(e){for(var t=0,n=this.campaigns;t<n.length;t++){var r=n[t];if(r.id===e.parentCampaign){var i=this.campaignState[r.id];i.impressions++,i.status=s.SWRVE_CAMPAIGN_STATUS_SEEN,i.lastShownTime=this.getNow(),this.campaignState[r.id]=i,this.storageManager.saveData(s.CAMPAIGN_STATE+this.profileManager.currentUser.userId,JSON.stringify(this.campaignState)),this.messagesShownCount++;break}}},e.prototype.markCampaignAsSeen=function(e){this.setCampaignStatus(e,s.SWRVE_CAMPAIGN_STATUS_SEEN)},e.prototype.removeMessageCenterCampaign=function(e){this.setCampaignStatus(e,s.SWRVE_CAMPAIGN_STATUS_DELETED)},e.prototype.setCampaignStatus=function(e,t){if(e){var n=this.campaignState[e.id];n.status=t,this.campaignState[e.id]=n,this.storageManager.saveData(s.CAMPAIGN_STATE+this.profileManager.currentUser.userId,JSON.stringify(this.campaignState))}},e.prototype.applyGlobalRules=function(){if(this.messagesShownCount>=this._maxMessagesPerSession)return{status:s.GLOBAL_CAMPAIGN_THROTTLE_MAX_IMPRESSIONS,message:"{App Throttle limit} Too many messages shown."};var e=this.profileManager.currentUser.sessionStart+1e3*this._delayFirstMessage;if(u.default.info("delay first message "+this._delayFirstMessage),e>this.getNow())return{status:s.GLOBAL_CAMPAIGN_THROTTLE_LAUNCH_TIME,message:"{App Throttle limit} Too soon after launch. Wait until "+e};var t=this.lastShownMessageTime+1e3*this._minDelay;return 0!==this.lastShownMessageTime&&t>this.getNow()?{status:s.GLOBAL_CAMPAIGN_THROTTLE_RECENT,message:"{App Throttle limit} Too soon after last message. Wait until "+t}:{status:s.CAMPAIGN_MATCH,message:"Global display rules passing."}},e.prototype.applyCampaignRules=function(t,n){var r=t.rules,i=this.campaignState[t.id];if(t.start_date>this.getNow()||t.end_date<this.getNow())return{status:s.CAMPAIGN_NOT_ACTIVE,message:"Campaign "+t.id+"not active."};var o=this.profileManager.currentUser.sessionStart+1e3*r.delay_first_message;if(o>this.getNow())return{status:s.CAMPAIGN_THROTTLE_LAUNCH_TIME,message:"{Campaign throttle limit} Too soon after launch. Wait until "+o};if(r.hasOwnProperty("dismiss_after_views")&&i.impressions>=r.dismiss_after_views){var a="{Campaign throttle limit} Campaign "+t.id+" has been shown "+t.rules.dismiss_after_views+" times already";return{status:s.CAMPAIGN_THROTTLE_MAX_IMPRESSIONS,message:a}}var u=i.lastShownTime+1e3*r.min_delay_between_messages;if(0!==i.lastShownTime&&u>this.getNow())return a="{Campaign throttle limit} Too soon after last campaign. Wait until "+(u+r.min_delay_between_messages),{status:s.CAMPAIGN_THROTTLE_RECENT,message:a};var c=e.getAllAssets([t],this.assetManager.ImagesCDN,n);return c.every((function(e){return e.canRender()}))?this.assetManager.checkAssetsForCampaign(c)?{status:s.CAMPAIGN_MATCH,message:"Campaign "+t.id+"passes display rules"}:{status:s.CAMPAIGN_NOT_DOWNLOADED,message:"Assets not loaded for Campaign "+t}:{status:s.CAMPAIGN_COULD_NOT_PERSONALIZE,message:"Personalization failed for campaign "+t}},e.prototype.parseGlobalRules=function(e){if(e&&e.rules){var t=e.rules;this._maxMessagesPerSession=t.hasOwnProperty("max_messages_per_session")?t.max_messages_per_session:this.MAX_MESSAGES_PER_SESSION,this._minDelay=t.hasOwnProperty("min_delay_between_messages")?t.min_delay_between_messages:this.MIN_DELAY,this._delayFirstMessage=t.hasOwnProperty("delay_first_message")?t.delay_first_message:this.DELAY_FIRST_MESSAGE}u.default.info("global Rules: max_messages_per_session:"+this._maxMessagesPerSession+" min_delay:"+this._minDelay+" delay_first_message:"+this._delayFirstMessage)},e.prototype.parseMessages=function(e){var t=this;e.forEach((function(e){e.messages&&e.messages.forEach((function(n){return t.messages.push(r({parentCampaign:e.id},n))})),e.embedded_message&&t.messages.push(r({parentCampaign:e.id},e.embedded_message))}))},e.prototype.parseTriggers=function(e){var t=this;e.forEach((function(e){e.triggers&&e.triggers.forEach((function(n){return t.triggers.push(r({parentCampaign:e.id},n))}))}))},e.prototype.handleAssets=function(t,n){var r=e.getAllAssets(this.campaigns,this.assetManager.ImagesCDN,n);this.assetManager.manageAssets(r).then((function(){u.default.info("asset download complete"),t()})).catch((function(e){u.default.info("error downloading assets "+e)}))},e.getAllAssets=function(e,t,n){for(var r=[],i=0,s=e;i<s.length;i++)for(var o=0,a=s[i].messages||[];o<a.length;o++)for(var u=a[o],p=0,h=u.template&&u.template.formats||[];p<h.length;p++){for(var g=h[p],f=0,d=g.buttons||[];f<d.length;f++){var _=d[f];r.push(new c.SwrveButton(_,t,n))}for(var v=0,m=g.images||[];v<m.length;v++){var y=m[v];r.push(new l.SwrveImage(y,t,n))}}return r},e.prototype.canCampaignRender=function(t,n){return e.getAllAssets([t],this.assetManager.ImagesCDN,n).every((function(e){return e.canRender()}))},e.prototype.getNow=function(){return p.default.nowInUtcTime()},e.prototype.updateEmbeddedMessagesRawData=function(e){e.forEach((function(e){if(e.embedded_message){var t=e.embedded_message;t.dataRaw=t.data}}))},e.prototype.isCampaignActive=function(e,t){return!(e.start_date>=t||t>=e.end_date)},e}();t.CampaignManager=g},822:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var s=n(337),o=n(340),a=n(457),u=function(e){function t(){var n=e.call(this)||this;return n._root=n.attachShadow({mode:"closed"}),n._root.appendChild(document.importNode(t.template().content,!0)),n._$styles=n._root.querySelector("style"),n._$button=n._root.querySelector("button"),n}return i(t,e),Object.defineProperty(t.prototype,"button",{set:function(e){this._button=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"personalizationProperties",{set:function(e){this._personalizationProperties=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasWidth",{get:function(){return this._canvasWidth},set:function(e){this._canvasWidth=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textForegroundColor",{get:function(){var e=o.DEFAULT_IAM_TEXT_FOREGROUND_COLOR;return this._inAppConfig&&this._inAppConfig.defaultTextForegroundColor&&(e=this._inAppConfig.defaultTextForegroundColor),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textBackgroundColor",{get:function(){var e=o.DEFAULT_IAM_TEXT_BACKGROUND_COLOR;return this._inAppConfig&&this._inAppConfig.defaultTextBackgroundColor&&(e=this._inAppConfig.defaultTextBackgroundColor),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textFontStyle",{get:function(){var e=o.DEFAULT_IAM_TEXT_FONT;return this._inAppConfig&&this._inAppConfig.defaultTextFontStyle&&(e=this._inAppConfig.defaultTextFontStyle),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasHeight",{get:function(){return this._canvasHeight},set:function(e){this._canvasHeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"inAppConfig",{set:function(e){this._inAppConfig=e},enumerable:!1,configurable:!0}),t.prototype.connectedCallback=function(){this._button.isSingleLineText?this.appendTextButton():this.appendImageButton()},t.prototype.appendTextButton=function(){var e=this.resolvePersonalizedText(this._button.button.text.value);this._$button.ariaLabel=e,this._$button.textContent=e,this._$styles.textContent+="\n button {\n background-color: #FFFFFF;\n width: ".concat(this._button.getWidth(),"px;\n height: ").concat(this._button.getHeight(),"px;\n top: ").concat(this.absoluteTopPosition(),"px;\n left: ").concat(this.absoluteLeftPosition(),"px;\n font-size: ").concat((0,a.getSingleLineTextFittedFontSize)(this._button.getWidth(),this._button.getHeight(),e,this.textFontStyle),"px;\n background-color: ").concat(this.textBackgroundColor,";\n color: ").concat(this.textForegroundColor,";\n font-family: ").concat(this.textFontStyle,";\n }\n ")},t.prototype.appendImageButton=function(){this._$styles.textContent+="\n button {\n background-image: url(".concat(this._button.getAssetPath(),");\n background-size: cover;\n width: ").concat(this._button.getWidth(),"px;\n height: ").concat(this._button.getHeight(),"px;\n top: ").concat(this.absoluteTopPosition(),"px;\n left: ").concat(this.absoluteLeftPosition(),"px;\n }\n ")},t.prototype.absoluteTopPosition=function(){return this._button.button.y.value+(this.canvasHeight/2-this._button.getHeight()/2)},t.prototype.absoluteLeftPosition=function(){return this._button.button.x.value+(this.canvasWidth/2-this._button.getWidth()/2)},t.prototype.resolvePersonalizedText=function(e){return s.TextTemplating.applyTextTemplatingToString(e,this._personalizationProperties)||e},t.template=function(){var e=document.createElement("template");return e.innerHTML=o.SWRVE_IAM_BUTTON_TEMPLATE_LITERAL,e},t}(HTMLElement);t.default=u},799:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(337),a=n(457),u=s(n(138)),c=n(340),l=function(e){function t(){var t=e.call(this)||this;return t._root=t.attachShadow({mode:"closed"}),t}return i(t,e),Object.defineProperty(t.prototype,"image",{set:function(e){this._image=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasWidth",{get:function(){return this._canvasWidth},set:function(e){this._canvasWidth=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasHeight",{get:function(){return this._canvasHeight},set:function(e){this._canvasHeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textForegroundColor",{get:function(){var e=c.DEFAULT_IAM_TEXT_FOREGROUND_COLOR;return this._inAppConfig&&this._inAppConfig.defaultTextForegroundColor&&(e=this._inAppConfig.defaultTextForegroundColor),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textBackgroundColor",{get:function(){var e=c.DEFAULT_IAM_TEXT_BACKGROUND_COLOR;return this._inAppConfig&&this._inAppConfig.defaultTextBackgroundColor&&(e=this._inAppConfig.defaultTextBackgroundColor),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textFontStyle",{get:function(){var e=c.DEFAULT_IAM_TEXT_FONT;return this._inAppConfig&&this._inAppConfig.defaultTextFontStyle&&(e=this._inAppConfig.defaultTextFontStyle),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"personalizationProperties",{set:function(e){this._personalizationProperties=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"inAppConfig",{set:function(e){this._inAppConfig=e},enumerable:!1,configurable:!0}),t.prototype.connectedCallback=function(){this._image.isSingleLineText?this.appendText():this.appendImage()},t.prototype.appendImage=function(){var e=document.createElement("style"),t=document.createElement("img");e.textContent+="\n img {\n width: ".concat(this._image.getWidth(),"px;\n height: ").concat(this._image.getHeight(),"px;\n top: ").concat(this.absoluteTopPosition(),"px;\n left: ").concat(this.absoluteLeftPosition(),"px;\n }\n "),t.src=this._image.getAssetPath(),this._root.appendChild(e),this._root.appendChild(t)},t.prototype.appendText=function(){var e=this.resolvePersonalizedText(this._image.image.text.value);if(null!==e){var t=document.createElement("style"),n=document.createElement("div");n.className="text",t.textContent+="\n .text {\n width: ".concat(this._image.getWidth(),"px;\n height: ").concat(this._image.getHeight(),"px;\n top: ").concat(this.absoluteTopPosition(),"px;\n left: ").concat(this.absoluteLeftPosition(),"px;\n font-size: ").concat((0,a.getSingleLineTextFittedFontSize)(this._image.getWidth(),this._image.getHeight(),e,this.textFontStyle),"px;\n background-color: ").concat(this.textBackgroundColor,";\n color: ").concat(this.textForegroundColor,";\n font-family: ").concat(this.textFontStyle,";\n position: absolute;\n overflow: hidden; \n white-space: nowrap; \n display: flex; \n justify-content: center; \n align-items: center;\n padding: 0;\n border: none;\n }\n "),n.innerText=e,this._root.appendChild(t),this._root.appendChild(n)}},t.prototype.absoluteTopPosition=function(){return this._image.image.y.value+(this.canvasHeight/2-this._image.getHeight()/2)},t.prototype.absoluteLeftPosition=function(){return this._image.image.x.value+(this.canvasWidth/2-this._image.getWidth()/2)},t.prototype.resolvePersonalizedText=function(e){try{return o.TextTemplating.applyTextTemplatingToString(e,this._personalizationProperties)}catch(t){return u.default.error("personalization could not be resolved for: "+e),null}},t}(HTMLElement);t.default=l},90:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var s=n(872),o=n(705),a=n(340),u=function(e){function t(){var n=e.call(this)||this;return n._root=n.attachShadow({mode:"closed"}),n._root.appendChild(document.importNode(t.template().content,!0)),n._overlayElement=n._root.querySelector(".".concat(a.SWRVE_IAM_OVERLAY)),n._canvasElement=n._root.querySelector(".".concat(a.SWRVE_IAM_CANVAS)),n._styles=n._root.querySelector("style"),n}return i(t,e),Object.defineProperty(t.prototype,"animation",{get:function(){return this.getAttribute("animation")},set:function(e){this.setAttribute("animation",e.toString())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"position",{get:function(){return this.getAttribute("position")},set:function(e){this.setAttribute("position",e.toString())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"message",{get:function(){return this._message},set:function(e){this._message=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"inAppConfig",{get:function(){return this._inAppConfig},set:function(e){this._inAppConfig=e},enumerable:!1,configurable:!0}),t.prototype.connectedCallback=function(){this._styles.textContent+=a.SWRVE_IAM_POSITIONS[this.position]},t.prototype.show=function(){this.renderMessage()},t.prototype.close=function(){this.removeMessage()},t.prototype.handleButtonClick=function(e){var t;this.dispatchEvent(new CustomEvent(a.SWRVE_IAM_BUTTON_CLICK_EVENT,{detail:{button:e,parentCampaign:null===(t=this._message)||void 0===t?void 0:t.parentCampaign}})),this.close()},t.prototype.renderMessage=function(){var e,t;this._canvasElement.style.width="".concat((null===(e=this.message)||void 0===e?void 0:e.canvasWidth)||0,"px"),this._canvasElement.style.height="".concat((null===(t=this.message)||void 0===t?void 0:t.canvasHeight)||0,"px"),this.appendImages(),this.appendButtons(),this._overlayElement.style.display="flex"},t.prototype.removeMessage=function(){this._overlayElement.style.display="none",this._canvasElement.style.width="0px",this._canvasElement.style.height="0px",this._canvasElement.innerHTML="",this._message=void 0},t.prototype.appendImages=function(){var e,t=this;null===(e=this._message)||void 0===e||e.images.forEach((function(e,n){var r,i=document.createElement("swrve-image");i.image=new s.SwrveImage(e,t._message.imagesCDN,null===(r=t._message)||void 0===r?void 0:r.personalizationProperties,t._message.scale),i.personalizationProperties=t._message.personalizationProperties,i.inAppConfig=t.inAppConfig,i.canvasHeight=t.message.canvasHeight,i.canvasWidth=t.message.canvasWidth,i.id="".concat(a.SWRVE_IAM_IMAGE,"-").concat(n),t._canvasElement.appendChild(i)}))},t.prototype.appendButtons=function(){var e,t=this;null===(e=this._message)||void 0===e||e.buttons.forEach((function(e,n){var r,i=document.createElement("swrve-button");i.button=new o.SwrveButton(e,t._message.imagesCDN,null===(r=t._message)||void 0===r?void 0:r.personalizationProperties,t._message.scale),i.personalizationProperties=t._message.personalizationProperties,i.inAppConfig=t.inAppConfig,i.onclick=function(){return t.handleButtonClick(e)},i.canvasHeight=t.message.canvasHeight,i.canvasWidth=t.message.canvasWidth,i.id="".concat(a.SWRVE_IAM_BUTTON,"-").concat(n),t._canvasElement.appendChild(i)}))},t.template=function(){var e=document.createElement("template");return e.innerHTML=a.SWRVE_IAM_TEMPLATE_LITERAL,e},t}(HTMLElement);t.default=u},340:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SWRVE_IAM_BUTTON_TEMPLATE_LITERAL=t.SWRVE_IAM_TEMPLATE_LITERAL=t.SWRVE_IAM_ENTER_ANIMATIONS=t.SWRVE_IAM_POSITIONS=t.SWRVE_IAM_DEFAULT_POSITION=t.SWRVE_IAM_DEFAULT_ENTER_ANIMATION=t.DEFAULT_IAM_TEXT_FONT=t.DEFAULT_IAM_TEXT_FOREGROUND_COLOR=t.DEFAULT_IAM_TEXT_BACKGROUND_COLOR=t.SWRVE_IAM_BUTTON_CLICK_EVENT=t.SWRVE_IAM_IMAGE=t.SWRVE_IAM_BUTTON=t.SWRVE_IAM_CANVAS=t.SWRVE_IAM_OVERLAY=t.SWRVE_IMAGE_BUTTON=t.SWRVE_TEXT_BUTTON=void 0,t.SWRVE_TEXT_BUTTON="text",t.SWRVE_IMAGE_BUTTON="image",t.SWRVE_IAM_OVERLAY="swrveIAM__overlay",t.SWRVE_IAM_CANVAS="swrveIAM__canvas",t.SWRVE_IAM_BUTTON="swrveIAM__button",t.SWRVE_IAM_IMAGE="swrveIAM__image",t.SWRVE_IAM_BUTTON_CLICK_EVENT="swrve-iam-button-click",t.DEFAULT_IAM_TEXT_BACKGROUND_COLOR="transparent",t.DEFAULT_IAM_TEXT_FOREGROUND_COLOR="#000000",t.DEFAULT_IAM_TEXT_FONT="Arial",t.SWRVE_IAM_DEFAULT_ENTER_ANIMATION="fadeInDown",t.SWRVE_IAM_DEFAULT_POSITION="center",t.SWRVE_IAM_POSITIONS={center:"\n .".concat(t.SWRVE_IAM_OVERLAY," {\n justify-content: center;\n align-items: center;\n }\n "),bottom:"\n .".concat(t.SWRVE_IAM_OVERLAY," {\n justify-content: center;\n align-items: end;\n }\n "),top:"\n .".concat(t.SWRVE_IAM_OVERLAY," {\n justify-content: center;\n align-items: baseline;\n }\n "),bottomRight:"\n .".concat(t.SWRVE_IAM_OVERLAY," {\n justify-content: end;\n align-items: end;\n }\n\n .").concat(t.SWRVE_IAM_CANVAS," {\n margin: 20px;\n }\n "),topRight:"\n .".concat(t.SWRVE_IAM_OVERLAY," {\n justify-content: end;\n align-items: baseline;\n }\n\n .").concat(t.SWRVE_IAM_CANVAS," {\n margin: 20px;\n }\n "),bottomLeft:"\n .".concat(t.SWRVE_IAM_OVERLAY," {\n justify-content: start;\n align-items: end;\n }\n\n .").concat(t.SWRVE_IAM_CANVAS," {\n margin: 20px;\n }\n "),topLeft:"\n .".concat(t.SWRVE_IAM_OVERLAY," {\n justify-content: start;\n align-items: baseline;\n }\n\n .").concat(t.SWRVE_IAM_CANVAS," {\n margin: 20px;\n }\n ")},t.SWRVE_IAM_ENTER_ANIMATIONS={fadeInDown:{className:"fadeInDown",templateLiteral:"\n @keyframes fadeInDown {\n from {\n opacity: 0;\n transform: translate3d(0, -100%, 0);\n }\n\n to {\n opacity: 1;\n transform: translate3d(0, 0, 0);\n }\n }\n\n .fadeInDown {\n animation-name: fadeInDown;\n animation-duration: 1.5s;\n }\n "},fadeInLeft:{className:"fadeInLeft",templateLiteral:"\n @keyframes fadeInLeft {\n from {\n opacity: 0;\n transform: translate3d(-2000px, 0, 0);\n }\n\n to {\n opacity: 1;\n transform: translate3d(0, 0, 0);\n }\n }\n\n .fadeInLeft {\n animation-name: fadeInLeft;\n animation-duration: 1.5s;\n }\n "},fadeInRight:{className:"fadeInRight",templateLiteral:"\n @keyframes fadeInRight {\n from {\n opacity: 0;\n transform: translate3d(2000px, 0, 0);\n }\n\n to {\n opacity: 1;\n transform: translate3d(0, 0, 0);\n }\n }\n\n .fadeInRight {\n animation-name: fadeInRight;\n animation-duration: 1.5s;\n }\n "},fadeInUp:{className:"fadeInUp",templateLiteral:"\n @keyframes fadeInUp {\n from {\n opacity: 0;\n transform: translate3d(0, 2000px, 0);\n }\n\n to {\n opacity: 1;\n transform: translate3d(0, 0, 0);\n }\n }\n\n .fadeInUp {\n animation-name: fadeInUpBig;\n animation-duration: 1.5s;\n }\n "},bounceInDown:{className:"bounceInDown",templateLiteral:"\n @keyframes bounceInDown {\n from,\n 60%,\n 75%,\n 90%,\n to {\n animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);\n }\n\n 0% {\n opacity: 0;\n transform: translate3d(0, -3000px, 0) scaleY(3);\n }\n\n 60% {\n opacity: 1;\n transform: translate3d(0, 25px, 0) scaleY(0.9);\n }\n\n 75% {\n transform: translate3d(0, -10px, 0) scaleY(0.95);\n }\n\n 90% {\n transform: translate3d(0, 5px, 0) scaleY(0.985);\n }\n\n to {\n transform: translate3d(0, 0, 0);\n }\n }\n\n .bounceInDown {\n animation-name: bounceInDown;\n animation-duration: 1.5s;\n }\n "}},t.SWRVE_IAM_TEMPLATE_LITERAL="\n <style>\n .".concat(t.SWRVE_IAM_OVERLAY," {\n position: fixed;\n left: 0;\n top: 0;\n height: 100vh;\n width: 100vw;\n background-color: rgb(0,0,0,.8);\n z-index: 1050;\n display: none;\n }\n\n .").concat(t.SWRVE_IAM_CANVAS," {\n position: relative;\n }\n\n @keyframes fadeIn {\n from {\n opacity: 0;\n }\n\n to {\n opacity: 1;\n }\n }\n\n .fadeIn {\n animation-name: fadeIn;\n animation-duration: .5s;\n }\n </style>\n\n <div class='swrveIAM__overlay fadeIn'>\n <div class='swrveIAM__canvas'></div>\n </div>\n"),t.SWRVE_IAM_BUTTON_TEMPLATE_LITERAL='\n <style>\n button {\n background: none;\n color: inherit;\n border: none;\n padding: 0;\n font: inherit;\n cursor: pointer;\n outline: inherit;\n position: absolute;\n }\n\n button:focus {\n box-shadow: 0 0 0 0.2rem rgb(0 123 255 / 50%);\n }\n\n button:hover {\n opacity: 60%;\n }\n </style>\n\n <button class="'.concat(t.SWRVE_IAM_BUTTON,'" role="button"></button>\n')},341:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SwrveMessageDisplayManager=void 0,n(25);var s=i(n(90)),o=i(n(822)),a=i(n(799)),u=function(){function e(e,t){this.onButtonClickedCallback=null,this.isOpen=!1,this.justClosed=!1,this.swrveIAM=document.createElement("swrve-in-app-message"),this.keymap=e.getKeymapping(),this.registerSwrveElements(),t?this.initSwrveIAM("none","center",t.InAppMessageConfig):this.initSwrveIAM("none","center"),this.initButtonClickListener()}return e.prototype.showMessage=function(e,t,n,i){var s=this.getLandscapeFormat(e);s&&(this.isOpen=!0,this.swrveIAM.message=r({personalizationProperties:i,imagesCDN:n,parentCampaign:t,scale:s.scale,images:s.images,buttons:s.buttons},this.getCanvasDimensions(s)),this.swrveIAM.show())},e.prototype.onButtonClicked=function(e){this.onButtonClickedCallback=e},e.prototype.isIAMShowing=function(){return this.isOpen},e.prototype.closeMessage=function(){this.isOpen=!1,this.justClosed=!0,this.swrveIAM.close()},e.prototype.initSwrveIAM=function(e,t,n){this.swrveIAM.setAttribute("animation",e),this.swrveIAM.setAttribute("position",t),this.swrveIAM.inAppConfig=n,document.body.appendChild(this.swrveIAM)},e.prototype.registerSwrveElements=function(){window.customElements.get("swrve-in-app-message")||window.customElements.define("swrve-in-app-message",s.default),window.customElements.get("swrve-button")||window.customElements.define("swrve-button",o.default),window.customElements.get("swrve-image")||window.customElements.define("swrve-image",a.default)},e.prototype.initButtonClickListener=function(){var e=this;this.swrveIAM.addEventListener("swrve-iam-button-click",(function(t){t.preventDefault(),t.stopImmediatePropagation(),e.closeMessage(),e.onButtonClickedCallback&&e.onButtonClickedCallback(t.detail.button,t.detail.parentCampaign)}))},e.prototype.getLandscapeFormat=function(e){var t=e.template.formats||null;if(!t)return null;var n=null;return t.forEach((function(e){"landscape"===e.orientation&&(n=e)})),n},e.prototype.getCanvasDimensions=function(e){var t;return(t=0!=e.images.length?e.images.find((function(e){return"Background"===e.name})):e.buttons.find((function(e){return"Background"===e.name})))?{canvasWidth:t.dynamic_image_url?t.w.value:t.image_width,canvasHeight:t.dynamic_image_url?t.h.value:t.image_height}:{canvasWidth:100,canvasHeight:100}},e}();t.SwrveMessageDisplayManager=u},705:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SwrveButton=void 0;var i=n(337),s=r(n(138)),o=function(){function e(e,t,n,r){this._button=e,this._cdn=t,this._scale=r,this._hasDynamicUrl=!!this._button.dynamic_image_url,this._isSingleLineText=!!this._button.text,this._personalizationProperties=n}return Object.defineProperty(e.prototype,"button",{get:function(){return this._button},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scale",{get:function(){return this._scale},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasDynamicUrl",{get:function(){return this._hasDynamicUrl},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isSingleLineText",{get:function(){return this._isSingleLineText},enumerable:!1,configurable:!0}),e.prototype.getAssetID=function(){return this.button.image_up?this.resolveOrFallbackUrlPersonalization(this.button.image_up.value):this.resolveOrFallbackUrlPersonalization("")},e.prototype.getAssetPath=function(){return this.button.image_up?this.resolveOrFallbackUrlPersonalization("".concat(this._cdn).concat(this.button.image_up.value)):this.resolveOrFallbackUrlPersonalization("")},e.prototype.canRender=function(){return this.isSingleLineText?null!==this.resolveTextTemplating(this.button.text.value,this._personalizationProperties):!(!this.hasDynamicUrl||null===this.resolveTextTemplating(this._button.dynamic_image_url,this._personalizationProperties))||void 0!==this._button.image_up},e.prototype.getWidth=function(){return this.hasDynamicUrl?this.button.w.value:this.button.image_width},e.prototype.getHeight=function(){return this.hasDynamicUrl?this.button.h.value:this.button.image_height},e.prototype.resolveOrFallbackUrlPersonalization=function(e){if(this.hasDynamicUrl)try{var t=i.TextTemplating.applyTextTemplatingToString(this.button.dynamic_image_url,this._personalizationProperties);if(null!==t)return t}catch(e){}return e},e.prototype.resolveTextTemplating=function(e,t){try{var n=i.TextTemplating.applyTextTemplatingToString(e,t);if(null!==n)return n}catch(t){s.default.debug("Could not resolve personalization for: "+e)}return null},e}();t.SwrveButton=o},530:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n={primaryNext:"Right",primaryPrev:"Left"},r={primaryNext:"Down",primaryPrev:"Up"},i={horizontal:n,vertical:r,bidirectional:null},s=function(){function e(e,t){this.index=0,this.props=t,this.items=e}return e.prototype.onFocus=function(){var e=this.items[this.index];e&&this.props.onFocus(e)},e.prototype.onBlur=function(){var e=this.items[this.index];e&&this.props.onBlur(e)},e.prototype.onKeyPress=function(e){var t=this.items[this.index];if(this.props.onKeyPress&&t&&this.props.onKeyPress(t,e))return!0;var s=this.props.direction;return"bidirectional"===s?this.handleDirection(r,e)||this.handleDirection(n,e):this.handleDirection(i[s||"vertical"]||r,e)},e.prototype.setItems=function(e){this.items=e},e.prototype.getItems=function(){return this.items},e.prototype.getCurrentIndex=function(){return this.index},e.prototype.setActiveItem=function(e){return e>=0&&e<this.items.length&&(this.props.onBlur(this.items[this.index]),this.index=e,this.props.onFocus(this.items[this.index])),!0},e.prototype.setActiveFirst=function(){this.setActiveItem(0)},e.prototype.setActiveLast=function(){this.setActiveItem(this.items.length-1)},e.prototype.handleDirection=function(e,t){var n=e.primaryNext;return t===e.primaryPrev?this.setActiveItem(this.index-1):t===n&&this.setActiveItem(this.index+1)},e}();t.default=s},872:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SwrveImage=void 0;var i=n(337),s=r(n(138)),o=function(){function e(e,t,n,r){this._image=e,this._cdn=t,this._scale=r,this._hasDynamicUrl=!!this._image.dynamic_image_url,this._isSingleLineText=!!this._image.text,this._personalizationProperties=n}return Object.defineProperty(e.prototype,"image",{get:function(){return this._image},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scale",{get:function(){return this._scale},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasDynamicUrl",{get:function(){return this._hasDynamicUrl},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isSingleLineText",{get:function(){return this._isSingleLineText},enumerable:!1,configurable:!0}),e.prototype.canRender=function(){return this.isSingleLineText?null!==this.resolveTextTemplating(this.image.text.value,this._personalizationProperties):!(!this.hasDynamicUrl||null===this.resolveTextTemplating(this._image.dynamic_image_url,this._personalizationProperties))||void 0!==this._image.image},e.prototype.getAssetID=function(){return this._image.image?this.resolveOrFallbackUrlPersonalization(this._image.image.value):this.resolveOrFallbackUrlPersonalization("")},e.prototype.getAssetPath=function(){return this._image.image?this.resolveOrFallbackUrlPersonalization("".concat(this._cdn).concat(this.image.image.value)):this.resolveOrFallbackUrlPersonalization("")},e.prototype.getWidth=function(){return this.hasDynamicUrl?this.image.w.value:this.image.image_width},e.prototype.getHeight=function(){return this.hasDynamicUrl?this.image.h.value:this.image.image_height},e.prototype.resolveOrFallbackUrlPersonalization=function(e){if(this.hasDynamicUrl){var t=this.resolveTextTemplating(this._image.dynamic_image_url,this._personalizationProperties);if(null!==t)return t}return e},e.prototype.resolveTextTemplating=function(e,t){try{var n=i.TextTemplating.applyTextTemplatingToString(e,t);if(null!==n)return n}catch(t){return s.default.debug("Could not resolve personalization for: "+e),null}return null},e}();t.SwrveImage=o},967:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.appID=e.appId,this.apiKey=e.apiKey,this.stack=e.stack||"us",this.language=e.language||"English",this.newSessionInterval=e.newSessionInterval||1800,this.eventsUrl=this.resolveEventsUrl(e),this.contentUrl=this.resolveContentUrl(e),this.identityUrl=this.resolveIdentityUrl(e),this.appVersion=e.appVersion||"1.0",this.appStore=e.appStore||"web",this.httpsTimeoutSeconds=e.httpsTimeoutSeconds||10,this.inAppMessageConfig=e.inAppMessageConfig||{autoShowMessagesMaxDelay:5e3},this.externalUserId=e.externalUserId||null,this.embeddedMessageConfig=e.embeddedMessageConfig||{},this.personalizationProvider=e.personalizationProvider||null,this.webPushConfig=e.webPushConfig||{webApiKeyCallback:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t]},autoPushSubscribe:!1}}return Object.defineProperty(e.prototype,"AppID",{get:function(){return this.appID},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ApiKey",{get:function(){return this.apiKey},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"EventsUrl",{get:function(){return this.eventsUrl},enumerable:!1,configurable:!0}),Object.defineProperty(e.