apxor-qe 1.2.4 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("apxor")):"function"==typeof define&&define.amd?define(["apxor"],e):(t=t||self)["apxor-qe"]=e(t.Apxor)}(this,(function(t){"use strict";function e(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function r(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?e(Object(n),!0).forEach((function(e){s(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,l(n.key),n)}}function a(t,e,r){return e&&o(t.prototype,e),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e,r){return(e=l(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t){return function(t){if(Array.isArray(t))return c(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return c(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function l(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var h=function(t){return void 0!==t&&!function(t){return null===t}(t)},f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function v(t,e){return Array.from(e).map((function(e,r){return String.fromCharCode(e^function(t,e){return t.charCodeAt(Math.floor(e%t.length))}(t,r))})).join("")}var p=function(t,e){return v(t,e=function(t){var e,r,n,i,o,a,s=0,u=[];if(!t)return t;t+="";do{e=(a=f.indexOf(t.charAt(s++))<<18|f.indexOf(t.charAt(s++))<<12|(i=f.indexOf(t.charAt(s++)))<<6|(o=f.indexOf(t.charAt(s++))))>>16&255,r=a>>8&255,n=255&a,u.push(e),64!==i&&(u.push(r),64!==o&&u.push(n))}while(s<t.length);return u}(e))},d=function(t){switch(t){case"app_event":return"AE";case"client_event":return"CE";case"activity_time":case"activity_event":return"AE"}return"Unknown"},g=function(t){return t.toUpperCase()},y=function(t,e,r){switch(r){case"EQ":return t===e;case"GT":return t>e;case"GTE":return t>=e;case"LT":return t<e;case"LTE":return t<=e;case"NEQ":return t!==e;case"R":return m(e).test(t);default:return!1}},m=function(t){var e=t.replace(/.*\/([gimuy]*)$/,"$1");e===t&&(e="");var r=e?t.replace(new RegExp("^/(.*?)/"+e+"$"),"$1"):t;return new RegExp(r,e)},A=function(){var t=new Date;return t.getDate()+"/"+t.getMonth()+"/"+t.getFullYear()},_=window.ApxorLogger,E=a((function e(){var r=this;i(this,e),s(this,"OlPJ","ALL"),s(this,"ccAa",[]),s(this,"atqR",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(r.OlPJ=t.audience.audience_type,r.ccAa=t.audience.attributes.user,r.atqR=t.audience.attributes.session,!Array.isArray(r.ccAa)||!Array.isArray(r.atqR))return _.error("No attributes"),!1}catch(t){return _.error(t),!1}return!0})),s(this,"validate",(function(e,n){var i=!0;return"FTU"===r.OlPJ&&(i=t.getController().getSessionInfo().is_first_session),i&&r.zowh(e,r.ccAa)&&r.zowh(n,r.atqR)})),s(this,"zowh",(function(t,e){var r=e.length,n=!0;try{for(var i,o=function(){var r=e[a];if(!t[r.name]||!1===n)return{v:!1};var i=r.operator,o=r.type,s=r.value.map((function(t){return"s"===o?t:"l"===o?parseInt(t):"f"===o?parseFloat(t):void 0})),u=(Array.isArray(t[r.name])?t[r.name]:[t[r.name]]).some((function(t){return s.some((function(e){return y(t,e,i)}))}));n=n&&u},a=0;a<r;a++)if(i=o())return i.v}catch(t){_.error(t),n=!1}return n}))})),w=window.ApxorLogger,S=a((function t(){var e=this;i(this,t),s(this,"uQfG",0),s(this,"InyA",0),s(this,"MtmN","SESSION"),s(this,"btNb",0),s(this,"sLkK",0),s(this,"zwUB",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.uQfG=t.frequency.count,e.zwUB=e.uQfG,e.InyA=t.frequency.time_interval,e.MtmN=t.frequency.validity,e.sLkK=t.frequency.ses_lmt,e._dayCount=t.frequency.day_lmt;var r=M.getInstance().getQeState();if(!h(r)||!h(r[t._id]))return!0;if("SESSION"===e.MtmN){if(e.uQfG=parseInt(e.uQfG)-parseInt(r[t._id].SESSION),e.uQfG<=0)return console.warn("Max count limit reached for session:"+t._id),!1}else{if("OVERALL"!==e.MtmN)return w.info("Invalid config."),!1;if(e.uQfG=parseInt(e.uQfG)-parseInt(r[t._id].OVERALL),e.uQfG<=0)return console.warn("Max count limit reached for overall:"+t._id),!1}}catch(t){return w.error(t),!1}return!0})),s(this,"wnxp",(function(){e.uQfG=e.uQfG-1})),s(this,"getFrequencyCount",(function(){return e.uQfG})),s(this,"ScJa",(function(){"SESSION"===e.MtmN&&(e.uQfG=e.zwUB,w.info("Campaign Limit reset"))})),s(this,"BSns",(function(t){try{if(e.uQfG<=0)return!1;var r=M.getInstance().getQeState();if(!h(r)||!h(r[t]))return!0;if(0!==e.sLkK)if(parseInt(e.sLkK)-parseInt(r[t].SESSION)<=0)return!1;if(0!==e._dayCount){var n,i=A();if(parseInt(e._dayCount)-parseInt((null===(n=r[t])||void 0===n?void 0:n.DATES[i])||0)<=0)return!1}}catch(t){w.error("Error validating the frequency:"+t)}return!0}))})),O=a((function t(){var e=this;i(this,t),s(this,"KsvN",""),s(this,"OlPJ",""),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var r;e.KsvN=t.meta.name,e.OlPJ=t.meta.type,e._only_context=t.meta.only_context,e._attr=(null===(r=t.meta)||void 0===r?void 0:r.attr)||{}}catch(t){return window.ApxorLogger.error(t),!1}return!0}))})),b=window.ApxorLogger,k=a((function t(){var e=this;i(this,t),s(this,"AXJi",-1),s(this,"xIZS",-1),s(this,"bhjK",-1),s(this,"WRnt",-1),s(this,"sfJc",!1),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(isNaN(Date.parse(t.validity.start_date))||isNaN(Date.parse(t.validity.end_date)))return b.error("Not valid dates"),!1;if(e.AXJi=Date.parse(t.validity.start_date),e.xIZS=Date.parse(t.validity.end_date),h(t.time_limits_in_day)&&(e.sfJc=t.time_limits_in_day,e.sfJc&&h(t.time_limits))){var r=(new Date).toISOString().split("T")[0];if(e.bhjK=Date.parse(r+"T"+t.time_limits.start_time+".000Z"),e.WRnt=Date.parse(r+"T"+t.time_limits.end_time+".000Z"),isNaN(e.bhjK)||isNaN(e.WRnt))return b.error("Not valid times"),!1}}catch(t){return b.error(t),!1}return!0})),s(this,"validate",(function(){var t=Date.now();return t>e.AXJi&&t<e.xIZS&&(!e.sfJc||t>=e.bhjK&&t<=e.WRnt)}))})),T=a((function t(){var e=this;i(this,t),s(this,"KsvN",""),s(this,"OmwE",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.KsvN=t.name,e.OmwE=t.additional_info}catch(t){return!1}return!0}))})),Q=a((function t(){var e=this;i(this,t),s(this,"hPng",0),s(this,"EaoX",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.hPng=Number(t.lower),e.EaoX=Number(t.upper),isNaN(e.hPng)||isNaN(e.EaoX))return!1}catch(t){return!1}return!0}))})),N=a((function t(){var e=this;i(this,t),s(this,"ACyh",0),s(this,"oByE",""),s(this,"XXBT",""),s(this,"QrLp",new T),s(this,"XwsM",new Q),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.oByE=t.event_type,e.XXBT=t.activity,e.QrLp.parse(t.details)&&e.XwsM.parse(t.time_bounds)}catch(t){return!1}}))})),L=window.ApxorLogger,C=a((function t(){var e=this;i(this,t),s(this,"ACyh",0),s(this,"xiFM",-1),s(this,"uQfG",0),s(this,"GFOB",""),s(this,"XXBT",""),s(this,"oByE",""),s(this,"XwsM",new Q),s(this,"QrLp",new T),s(this,"uUDi",new N),s(this,"hfEI","AND"),s(this,"ytXh",!1),s(this,"OlPJ",void 0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.xiFM=t.sequence,e.uQfG=t.count_config.count,e.GFOB=t.count_config.operator,e.XXBT=t.activity,e.oByE=t.event_type,e.hfEI=t.combine_operator,e.OlPJ=t.type,e.QrLp.parse(t.details)&&e.uUDi.parse(t.trigger)&&e.XwsM.parse(t.time_bounds)}catch(t){return L.error(t),!1}}))})),F=window.ApxorLogger,P=function(){function e(){var r=this;i(this,e),s(this,"gCch",0),s(this,"khHY",""),s(this,"kTpA",new C),s(this,"LeeG",!1),s(this,"mOYl",!1),s(this,"ccds",0),s(this,"hfEI","AND"),s(this,"AdbQ",-1),s(this,"MLGX",[]),s(this,"auHD",{}),s(this,"bACZ",!1),s(this,"initialize",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];r.khHY=n,r.ccds=i,r.MLGX=a;var s=r.kTpA.parse(e);if(s){if(r.hfEI=r.kTpA.hfEI,r.kTpA.ytXh){var u=r.kTpA.QrLp.KsvN;"APX_PAGE_OPENED"===u&&(u=r.kTpA.QrLp.OmwE.navigation_id,u=h(u)?u:r.kTpA.QrLp.KsvN),r.AdbQ=t.getController().getEventCount(u);var c=r.kTpA.uQfG,l=r.kTpA.GFOB;if(r.mOYl=r.TnSn(r.AdbQ-1,c,l,!1),r.LeeG=r.mOYl,r.mOYl&&"APX_PAGE_OPENED"===r.kTpA.QrLp.KsvN)return!0}return o&&0!==i||r.UPYl(),!0}return!1})),s(this,"UPYl",(function(){var t=r.kTpA,e=t.uUDi,n=M.getInstance();"app_start"===e.oByE?(r.LeeG=!0,n.registerForEvent(d(t.oByE)+"___"+t.QrLp.KsvN,r.VolR)):n.registerForEvent(d(t.oByE)+"___"+e.QrLp.KsvN,r.VolR)})),s(this,"VNlO",(function(t,e,n,i){var o,a=(Date.now()-r.auHD[e])/1e3;(null===(o=r.kTpA)||void 0===o||null===(o=o.QrLp)||void 0===o||null===(o=o.OmwE)||void 0===o?void 0:o.time)/1e3>a&&r._displayCampaign(n)})),s(this,"dLQC",(function(t,e,n,i){var o,a;r.bACZ=!0;var s=Date.now(),u=null===(o=r.kTpA)||void 0===o||null===(o=o.uUDi)||void 0===o?void 0:o.QrLp.KsvN,c=(s-r.auHD[u])/1e3,l=null===(a=r.kTpA)||void 0===a||null===(a=a.QrLp)||void 0===a||null===(a=a.OmwE)||void 0===a?void 0:a.time;(l/=1e3)>c&&r._displayCampaign(n)})),s(this,"VolR",(function(t,e,n,i){var o=M.getInstance();if(r.LeeG)d(r.kTpA.oByE)===t&&r.PHir(n-r.kTpA.uUDi.ACyh,r.kTpA.XwsM)&&r.kTpA.QrLp.KsvN===e&&r.JXPv(r.kTpA.QrLp.OmwE,i)&&(r.gCch+=1,r.mOYl=r.TnSn(r.gCch,r.kTpA.uQfG,r.kTpA.GFOB),r.mOYl&&(r.kTpA.ACyh=n,o.validate(r.khHY,r.ccds)));else if(r.LeeG=r.XASt(t,e,n,i),r.LeeG){var a=r.kTpA,s=a.uUDi;if(s.ACyh=n,"activity_time"===(null==a?void 0:a.oByE)){var u,c,l,h=null==a||null===(u=a.QrLp)||void 0===u||null===(u=u.OmwE)||void 0===u?void 0:u.time;(null==a||null===(c=a.QrLp)||void 0===c||null===(c=c.OmwE)||void 0===c?void 0:c.nkpi.length)>0&&(setTimeout((function(){r.bACZ||(r.mOYl=!0,r.mOYl&&(r.gCch+=1,r.mOYl=r.TnSn(r.gCch,r.kTpA.uQfG,r.kTpA.GFOB),r.mOYl&&(r.kTpA.ACyh=n,o.validate(r.khHY,r.ccds)))),a.QrLp.OmwE.nkpi.map((function(t){o.unregisterFromEvent(g(a.QrLp.OmwE.et)+"___"+t,r)}))}),h),a.QrLp.OmwE.nkpi.map((function(t){o.registerForEvent(g(a.QrLp.OmwE.et)+"___"+t,r.dLQC)}))),(null==a||null===(l=a.QrLp)||void 0===l||null===(l=l.OmwE)||void 0===l?void 0:l.kpi.length)>0&&(setTimeout((function(){a.QrLp.OmwE.kpi.map((function(t){o.unregisterFromEvent(g(a.QrLp.OmwE.et)+"___"+t,r)}))}),h),a.QrLp.OmwE.kpi.map((function(t){t===a.uUDi.QrLp.KsvN?(o.unregisterFromEvent(d(s.oByE)+"___"+s.QrLp.KsvN,r),o.registerForEvent(g(a.QrLp.OmwE.et)+"___"+t,r.VNlO)):o.registerForEvent(g(a.QrLp.OmwE.et)+"___"+t,r.dLQC)})))}else o.unregisterFromEvent(d(s.oByE)+"___"+s.QrLp.KsvN,r),o.registerForEvent(d(a.oByE)+"___"+a.QrLp.KsvN,r);r.auHD[e]=Date.now()}})),s(this,"XASt",(function(t,e,n,i){var o=r.kTpA.uUDi;return d(o.oByE)===t&&o.QrLp.KsvN===e&&r.PHir(n,o.XwsM)&&r.JXPv(o.QrLp.OmwE,i)})),s(this,"PHir",(function(t,e){var r=Math.ceil(t);return r>e.hPng&&r<e.EaoX})),s(this,"TnSn",(function(t,e,n){var i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];switch(i&&r.kTpA.ytXh&&(t+=r.AdbQ),n){case"EQ":return t===e;case"GT":return t>e;case"GTE":return t>=e;case"LT":return t<e;case"LTE":return t<=e;default:return!1}})),s(this,"JXPv",(function(t,e){var r=!0;try{var i,o=function(){if(!e[a]||!1===r)return{v:!1};if("object"===n(t[a])){var i,o=t[a].op,s=t[a].t;"s"===s?i=t[a].val:"l"!==s&&"f"!==s||(i=parseFloat(t[a].val));var u=(Array.isArray(e[a])?e[a]:[e[a]]).some((function(t){return y(t,i,o)}));r=r&&u}else r=r&&y(e[a],t[a],"EQ")};for(var a in t)if(i=o())return i.v}catch(t){F.error(t),r=!1}return r}))}return a(e,[{key:"_displayCampaign",value:function(t){var e=M.getInstance();this.mOYl=!0,this.mOYl&&(this.gCch+=1,this.mOYl=this.TnSn(this.gCch,this.kTpA.uQfG,this.kTpA.GFOB),this.mOYl&&(this.kTpA.ACyh=t,e.validate(this.khHY,this.ccds)))}}]),e}(),G=window.ApxorLogger,x=a((function e(){var r=this;i(this,e),s(this,"AEeG",[]),s(this,"_ret_day",{}),s(this,"NGyb",{}),s(this,"ySyl",!1),s(this,"xrUm",!1),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{r.AEeG=t.overall_cfg.events,r._ret_day=t.overall_cfg.ret_day,r.NGyb=t.overall_cfg.session,r.ySyl=t.overall_cfg.toggleRetDay,r.AEeG=t.overall_cfg.events,r.xrUm=t.overall_cfg.toggleSession}catch(t){return G.error(t),!1}return!0})),s(this,"validate",(function(){var e=parseInt(t.getController().getFromStorage("apx_retained_days")),n=parseInt(t.getController().getFromStorage("apx_retained_session"));if(r.ySyl&&!isNaN(e)&&!(e>=r._ret_day.from&&e<=r._ret_day.to))return!1;if(r.xrUm&&!isNaN(n)&&!(n>=r.NGyb.from&&n<=r.NGyb.to))return!1;try{for(var i=t.getController().getFromStorage("_apx_lt_count"),o=t.getSiteId(),a=JSON.parse(p(o,i)),s=0;s<r.AEeG.length;s++){if(a[r.AEeG[s].name.replace("'","").replace("’","")])return!1}}catch(t){G.error("Failed to validate the lt count:"+t)}return!0}))})),X=window.ApxorLogger,q=a((function e(){var n=this;i(this,e),s(this,"tVlQ",[]),s(this,"khHY",""),s(this,"vbNk",new O),s(this,"lKMm",new E),s(this,"MtmN",new k),s(this,"ZPkK",new S),s(this,"MiVL",new x),s(this,"HAqW",!1),s(this,"QzOA",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(!h(t._id))return X.error("No Id"),!1;if(!h(t.enabled)||!t.enabled)return X.error("Not enabled"),!1;if(!(n.vbNk.parse(t)&&n.MtmN.parse(t)&&n.ZPkK.parse(t)&&n.lKMm.parse(t)&&n.MiVL.parse(t)))return!1;if(!h(t.conditions)||!Array.isArray(t.conditions))return X.error("No valid conditions",t.conditions),!1;n.khHY=t._id,n.HAqW=!!h(t.sequence_enabled)&&t.sequence_enabled,n.HAqW&&t.conditions.sort((function(t,e){return t.sequence<e.sequence}));for(var e=t.conditions,r=e.length,i=0;i<r;i++){n.QzOA=[];var o=e[i];if("didn't"===o.type){var a,s={trigger_key:o.trigger.details.name,no_kpi_array:null==o||null===(a=o.details)||void 0===a||null===(a=a.additional_info)||void 0===a?void 0:a.nkpi,condition_id:null==o?void 0:o._id,time_bounds:o.time_bounds.upper};n.QzOA=[].concat(u(n.QzOA),[s])}var c=new P;c.initialize(o,n.khHY,i,n.HAqW,n.QzOA)&&n.tVlQ.push(c)}return n.tVlQ.length>0}catch(t){return X.error(t),!1}})),s(this,"cxKp",(function(t){if(!(t<0))if(n.HAqW){var e=n.tVlQ[t];if(h(e)&&e.mOYl){var r=n.tVlQ[t-1];if(h(r)&&!r.mOYl)return;var i=n.tVlQ[t+1];h(i)?i.UPYl():n.VxHD()}}else n.VxHD()})),s(this,"VxHD",(function(){var e=t.getController().getUserAttributes(),i=t.getController().getSessionAttributes();if(n.MtmN.validate()&&n.lKMm.validate(e,i)&&n.MiVL.validate()){for(var o=n.tVlQ.length,a=o<1,s="",u=0;u<o;u++){var c=n.tVlQ[u],l=c.mOYl;if(""===s.trim())a=l;else switch(s){case"AND":a=a&&l;break;case"OR":a=a||l}s=c.hfEI}if(a){if(console.debug("onCondition satisfied"),!n.ZPkK.BSns(n.khHY))return void console.warn("Maximum limit reached",n.khHY);console.log("Dispatching event",n.vbNk.OlPJ),!0===n.vbNk._only_context&&t.logEvent("apx_context_evaluated",r(r({},n.vbNk._attr),{},{message_name:n.vbNk.KsvN,id:n.khHY})),t.getController().dispatchEvent(n.vbNk.OlPJ,{name:n.vbNk.OlPJ,additional_info:{uuid:n.khHY,name:n.vbNk.KsvN}})}}})),s(this,"wnxp",(function(){n.ZPkK.wnxp()})),s(this,"getFrequencyCount",(function(){return n.ZPkK.getFrequencyCount()})),s(this,"TFzA",(function(){return n.ZPkK.ScJa()}))})),D=a((function t(){var e=this;i(this,t),s(this,"gTqz",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{configs:[]};if(h(t)&&h(t.configs)){var r=t.configs;if(!Array.isArray(r))return;r.sort((function(t,e){var r,n;return(null!==(r=t.prio)&&void 0!==r?r:-1)-(null!==(n=e.prio)&&void 0!==n?n:-1)}));for(var n=0;n<r.length;n++){var i=r[n],o=i._id,a=new q;a.parse(i)?e.gTqz[o]=a:console.warn("Failed to parse cfg",o)}}})),s(this,"validate",(function(t,r){e.gTqz[t]&&e.gTqz[t].cxKp(r)})),s(this,"wnxp",(function(t){e.gTqz[t].wnxp()})),s(this,"getFrequencyCount",(function(t){return e.gTqz[t].getFrequencyCount()})),s(this,"resetFrequencyCounts",(function(){var t=e.gTqz;for(var r in t)t[r].TFzA()})),s(this,"Xijd",(function(t){try{if(e.gTqz){var r=e.gTqz[t];if(r&&r.vbNk)return r.vbNk}}catch(t){console.log("Error in getting the campaign meta ".concat(t))}return{}}))})),K=window.ApxorLogger,I=a((function e(){var r=this;i(this,e),s(this,"SPrF",{}),s(this,"EcTh",[]),s(this,"HxWM",!1),s(this,"initialize",(function(){var e=t.getController();e.registerForEvent("APP_EVENT",(function(t){return r.ZKQc(t,"AE")})),e.registerForEvent("CLIENT_EVENT",(function(t){return r.ZKQc(t,"CE")}))})),s(this,"MhGD",(function(){for(var t in r.EcTh)r.gdBA(t.event,t.key,t.type);r.HxWM=!0})),s(this,"rzbt",(function(t,e){var n;"function"==typeof e&&((n=r.SPrF[t]?r.SPrF[t]:[]).push(e),r.SPrF[t]=n,K.debug("Listeners list: ",r.SPrF))})),s(this,"unregisterFromEvent",(function(t,e){if(r.SPrF[t]){for(var n=r.SPrF[t],i=[],o=0;o<n.length;o++){var a=n[o];a!==e&&i.push(a)}r.SPrF[t]=i}})),s(this,"ZKQc",(function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"AE",n=e+"___"+t.name;r.gdBA(t,n,e)})),s(this,"gdBA",(function(e,n,i){if(r.HxWM){if(K.debug("Notifying listeners for event: "+e+", "+n,r.SPrF),r.SPrF[n])for(var o=r.SPrF[n],a=t.getController().getSDKRunningTimeInSec(),s=0;s<o.length;s++){(0,o[s])(i,e.name,a,e.additional_info)}}else r.EcTh.push({event:e,key:n,type:i})}))})),J=window.ApxorLogger,M=function(){function e(){var r=this;return i(this,e),s(this,"CueH",!1),s(this,"TVGk",null),s(this,"XFkq",A()),s(this,"CKgK",new I),s(this,"cuhG",t.getSiteId()),s(this,"waXJ",{}),s(this,"getQeState",(function(){try{var e=t.getController().getFromStorage("qe_state");return e?JSON.parse(p(r.cuhG,e)):(r.waXJ={},r.setQeState())}catch(t){return r.waXJ={},r.setQeState()}})),s(this,"setQeState",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{t.getController().persistToStorage("qe_state",r.waXJ,!0)}catch(n){""===e?r.waXJ={}:r.waXJ[e]={SESSION:0,OVERALL:0,DATES:{}},t.getController().persistToStorage("qe_state",r.waXJ,!0)}return r.waXJ})),s(this,"initialize",(function(){r.CueH||(r.CueH=!0,r.TVGk=new D,r.CKgK.initialize(),r.waXJ=r.getQeState(),J.info("QE Initialized.."))})),s(this,"parse",(function(t){r.iafS()?(r.TVGk.parse(t),r.CKgK.MhGD()):J.warn("Must call init first. Unable to proceed")})),s(this,"validate",(function(t,e){r.iafS()&&r.TVGk.validate(t,e)})),s(this,"updateCount",(function(t){try{h(r.waXJ[t])||r.createObjConfig(t),r.incrementFrequencies(t),r.setQeState(t),r.TVGk.wnxp(t)}catch(t){console.log("Could not update the count config:".concat(t))}})),s(this,"resetFrequencyCounts",(function(){r.TVGk.resetFrequencyCounts()})),s(this,"getFrequencyCount",(function(t){return r.TVGk.getFrequencyCount(t)})),s(this,"registerForEvent",(function(t,e){r.CKgK.rzbt(t,e)})),s(this,"unregisterFromEvent",(function(t,e){r.CKgK.unregisterFromEvent(t,e)})),s(this,"fetch",(function(e,r,n,i){t.getController().fetchConfiguration(e,r,n,i)})),s(this,"iafS",(function(){return r.CueH})),s(this,"getCampaignMetaFromQueryEngine",(function(t){return r.TVGk.Xijd(t)})),s(this,"SZpm",(function(){return r.XFkq})),e.instance||(e.instance=this),e.instance}return a(e,[{key:"createObjConfig",value:function(t){try{this.waXJ=this.getQeState(),h(this.waXJ[t])||(this.waXJ[t]={SESSION:0,OVERALL:0,DATES:{}},this.XFkq&&(this.waXJ[t].DATES[this.XFkq]=0),this.setQeState(t))}catch(t){J.error("Can not create the frequency count object:"+t)}}},{key:"incrementFrequencies",value:function(t){this.waXJ=this.getQeState();var e=this.waXJ[t];e.SESSION=e.SESSION+1,e.OVERALL=e.OVERALL+1;var r=A();r===this.XFkq&&e.DATES&&e.DATES[r]||(this.XFkq=r,e.DATES={},e.DATES[this.XFkq]=0),e.DATES[this.XFkq]=e.DATES[this.XFkq]+1}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}();s(M,"instance",void 0),window.ceVersion=124;try{void 0===exports&&null===exports||(exports.default=M,module.exports=exports.default)}catch(t){}return M}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("apxor")):"function"==typeof define&&define.amd?define(["apxor"],e):(t=t||self)["apxor-qe"]=e(t.Apxor)}(this,(function(t){"use strict";function e(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function n(t){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?e(Object(r),!0).forEach((function(e){s(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,l(r.key),r)}}function a(t,e,n){return e&&o(t.prototype,e),n&&o(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e,n){return(e=l(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u(t){return function(t){if(Array.isArray(t))return c(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return c(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function l(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var h=function(t){return void 0!==t&&!function(t){return null===t}(t)},f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function d(t,e){return Array.from(e).map((function(e,n){return String.fromCharCode(e^function(t,e){return t.charCodeAt(Math.floor(e%t.length))}(t,n))})).join("")}var v=function(t,e){return d(t,e=function(t){var e,n,r,i,o,a,s=0,u=[];if(!t)return t;t+="";do{e=(a=f.indexOf(t.charAt(s++))<<18|f.indexOf(t.charAt(s++))<<12|(i=f.indexOf(t.charAt(s++)))<<6|(o=f.indexOf(t.charAt(s++))))>>16&255,n=a>>8&255,r=255&a,u.push(e),64!==i&&(u.push(n),64!==o&&u.push(r))}while(s<t.length);return u}(e))},p=function(t){switch(t){case"app_event":return"AE";case"client_event":return"CE";case"activity_time":case"activity_event":return"AE"}return"Unknown"},g=function(t){return t.toUpperCase()},y=function(t,e,n){switch(n){case"EQ":return t===e;case"GT":return t>e;case"GTE":return t>=e;case"LT":return t<e;case"LTE":return t<=e;case"NEQ":return t!==e;case"R":return m(e).test(t);default:return!1}},m=function(t){var e=t.replace(/.*\/([gimuy]*)$/,"$1");e===t&&(e="");var n=e?t.replace(new RegExp("^/(.*?)/"+e+"$"),"$1"):t;return new RegExp(n,e)},_=function(){var t=new Date;return t.getDate()+"/"+t.getMonth()+"/"+t.getFullYear()},F=window.ApxorLogger,O=a((function e(){var n=this;i(this,e),s(this,"FFVT","ALL"),s(this,"Peqo",[]),s(this,"ukFQ",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(n.FFVT=t.audience.audience_type,n.Peqo=t.audience.attributes.user,n.ukFQ=t.audience.attributes.session,!Array.isArray(n.Peqo)||!Array.isArray(n.ukFQ))return F.error("No attributes"),!1}catch(t){return F.error(t),!1}return!0})),s(this,"validate",(function(e,r){var i=!0;return"FTU"===n.FFVT&&(i=t.getController().getSessionInfo().is_first_session),i&&n.pYKU(e,n.Peqo)&&n.pYKU(r,n.ukFQ)})),s(this,"pYKU",(function(t,e){var n=e.length,r=!0;try{for(var i,o=function(){var n=e[a];if(!t[n.name]||!1===r)return{v:!1};var i=n.operator,o=n.type,s=n.value.map((function(t){return"s"===o?t:"l"===o?parseInt(t):"f"===o?parseFloat(t):void 0})),u=(Array.isArray(t[n.name])?t[n.name]:[t[n.name]]).some((function(t){return s.some((function(e){return y(t,e,i)}))}));r=r&&u},a=0;a<n;a++)if(i=o())return i.v}catch(t){F.error(t),r=!1}return r}))})),C=window.ApxorLogger,V=a((function t(){var e=this;i(this,t),s(this,"FDLa",0),s(this,"CBbn",0),s(this,"bLov","SESSION"),s(this,"WzqN",0),s(this,"FhVO",0),s(this,"HkIT",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.FDLa=t.frequency.count,e.HkIT=e.FDLa,e.CBbn=t.frequency.time_interval,e.bLov=t.frequency.validity,e.FhVO=t.frequency.ses_lmt,e._dayCount=t.frequency.day_lmt;var n=M.getInstance().getQeState();if(!h(n)||!h(n[t._id]))return!0;if("SESSION"===e.bLov){if(e.FDLa=parseInt(e.FDLa)-parseInt(n[t._id].SESSION),e.FDLa<=0)return console.warn("Max count limit reached for session:"+t._id),!1}else{if("OVERALL"!==e.bLov)return C.info("Invalid config."),!1;if(e.FDLa=parseInt(e.FDLa)-parseInt(n[t._id].OVERALL),e.FDLa<=0)return console.warn("Max count limit reached for overall:"+t._id),!1}}catch(t){return C.error(t),!1}return!0})),s(this,"PUEA",(function(){e.FDLa=e.FDLa-1})),s(this,"getFrequencyCount",(function(){return e.FDLa})),s(this,"kPus",(function(){"SESSION"===e.bLov&&(e.FDLa=e.HkIT,C.info("Campaign Limit reset"))})),s(this,"Frbd",(function(t){try{if(e.FDLa<=0)return!1;var n=M.getInstance().getQeState();if(!h(n)||!h(n[t]))return!0;if(0!==e.FhVO)if(parseInt(e.FhVO)-parseInt(n[t].SESSION)<=0)return!1;if(0!==e._dayCount){var r,i=_();if(parseInt(e._dayCount)-parseInt((null===(r=n[t])||void 0===r?void 0:r.DATES[i])||0)<=0)return!1}}catch(t){C.error("Error validating the frequency:"+t)}return!0}))})),b=a((function t(){var e=this;i(this,t),s(this,"CtPY",""),s(this,"FFVT",""),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var n;e.CtPY=t.meta.name,e.FFVT=t.meta.type,e._only_context=t.meta.only_context,e._attr=(null===(n=t.meta)||void 0===n?void 0:n.attr)||{}}catch(t){return window.ApxorLogger.error(t),!1}return!0}))})),L=window.ApxorLogger,E=a((function t(){var e=this;i(this,t),s(this,"JHaV",-1),s(this,"CDOi",-1),s(this,"qOFY",-1),s(this,"vZJY",-1),s(this,"RnJn",!1),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(isNaN(Date.parse(t.validity.start_date))||isNaN(Date.parse(t.validity.end_date)))return L.error("Not valid dates"),!1;if(e.JHaV=Date.parse(t.validity.start_date),e.CDOi=Date.parse(t.validity.end_date),h(t.time_limits_in_day)&&(e.RnJn=t.time_limits_in_day,e.RnJn&&h(t.time_limits))){var n=(new Date).toISOString().split("T")[0];if(e.qOFY=Date.parse(n+"T"+t.time_limits.start_time+".000Z"),e.vZJY=Date.parse(n+"T"+t.time_limits.end_time+".000Z"),isNaN(e.qOFY)||isNaN(e.vZJY))return L.error("Not valid times"),!1}}catch(t){return L.error(t),!1}return!0})),s(this,"validate",(function(){var t=Date.now();return t>e.JHaV&&t<e.CDOi&&(!e.RnJn||t>=e.qOFY&&t<=e.vZJY)}))})),w=a((function t(){var e=this;i(this,t),s(this,"CtPY",""),s(this,"NVOO",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.CtPY=t.name,e.NVOO=t.additional_info}catch(t){return!1}return!0}))})),A=a((function t(){var e=this;i(this,t),s(this,"RZpl",0),s(this,"FsQW",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.RZpl=Number(t.lower),e.FsQW=Number(t.upper),isNaN(e.RZpl)||isNaN(e.FsQW))return!1}catch(t){return!1}return!0}))})),S=a((function t(){var e=this;i(this,t),s(this,"gplO",0),s(this,"AlVX",""),s(this,"fBwj",""),s(this,"QYMC",new w),s(this,"pWFR",new A),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.AlVX=t.event_type,e.fBwj=t.activity,e.QYMC.parse(t.details)&&e.pWFR.parse(t.time_bounds)}catch(t){return!1}}))})),k=window.ApxorLogger,Y=a((function t(){var e=this;i(this,t),s(this,"gplO",0),s(this,"fnMy",-1),s(this,"FDLa",0),s(this,"LXVx",""),s(this,"fBwj",""),s(this,"AlVX",""),s(this,"pWFR",new A),s(this,"QYMC",new w),s(this,"jsSe",new S),s(this,"kURO","AND"),s(this,"eatT",!1),s(this,"FFVT",void 0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.fnMy=t.sequence,e.FDLa=t.count_config.count,e.LXVx=t.count_config.operator,e.fBwj=t.activity,e.AlVX=t.event_type,e.kURO=t.combine_operator,e.FFVT=t.type,e.QYMC.parse(t.details)&&e.jsSe.parse(t.trigger)&&e.pWFR.parse(t.time_bounds)}catch(t){return k.error(t),!1}}))})),q=window.ApxorLogger,N=function(){function e(){var n=this;i(this,e),s(this,"vWIX",0),s(this,"Fdjl",""),s(this,"dqkJ",new Y),s(this,"AhjD",!1),s(this,"xVdJ",!1),s(this,"BjBE",0),s(this,"kURO","AND"),s(this,"sqsm",-1),s(this,"wlEj",[]),s(this,"qewW",{}),s(this,"doep",!1),s(this,"initialize",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];n.Fdjl=r,n.BjBE=i,n.wlEj=a;var s=n.dqkJ.parse(e);if(s){if(n.kURO=n.dqkJ.kURO,n.dqkJ.eatT){var u=n.dqkJ.QYMC.CtPY;"APX_PAGE_OPENED"===u&&(u=n.dqkJ.QYMC.NVOO.navigation_id,u=h(u)?u:n.dqkJ.QYMC.CtPY),n.sqsm=t.getController().getEventCount(u);var c=n.dqkJ.FDLa,l=n.dqkJ.LXVx;if(n.xVdJ=n.LzlO(n.sqsm-1,c,l,!1),n.AhjD=n.xVdJ,n.xVdJ&&"APX_PAGE_OPENED"===n.dqkJ.QYMC.CtPY)return!0}return o&&0!==i||n.qqsE(),!0}return!1})),s(this,"qqsE",(function(){var t=n.dqkJ,e=t.jsSe,r=M.getInstance();"app_start"===e.AlVX?(n.AhjD=!0,r.registerForEvent(p(t.AlVX)+"___"+t.QYMC.CtPY,n.LydU)):r.registerForEvent(p(t.AlVX)+"___"+e.QYMC.CtPY,n.LydU)})),s(this,"uMbk",(function(t,e,r,i){var o,a=(Date.now()-n.qewW[e])/1e3;(null===(o=n.dqkJ)||void 0===o||null===(o=o.QYMC)||void 0===o||null===(o=o.NVOO)||void 0===o?void 0:o.time)/1e3>a&&n._displayCampaign(r)})),s(this,"kIfZ",(function(t,e,r,i){var o,a;n.doep=!0;var s=Date.now(),u=null===(o=n.dqkJ)||void 0===o||null===(o=o.jsSe)||void 0===o?void 0:o.QYMC.CtPY,c=(s-n.qewW[u])/1e3,l=null===(a=n.dqkJ)||void 0===a||null===(a=a.QYMC)||void 0===a||null===(a=a.NVOO)||void 0===a?void 0:a.time;(l/=1e3)>c&&n._displayCampaign(r)})),s(this,"LydU",(function(t,e,r,i){var o=M.getInstance();if(n.AhjD)p(n.dqkJ.AlVX)===t&&n.Chvr(r-n.dqkJ.jsSe.gplO,n.dqkJ.pWFR)&&n.dqkJ.QYMC.CtPY===e&&n.BXyf(n.dqkJ.QYMC.NVOO,i)&&(n.vWIX+=1,n.xVdJ=n.LzlO(n.vWIX,n.dqkJ.FDLa,n.dqkJ.LXVx),n.xVdJ&&(n.dqkJ.gplO=r,o.validate(n.Fdjl,n.BjBE)));else if(n.AhjD=n.zOaF(t,e,r,i),n.AhjD){var a=n.dqkJ,s=a.jsSe;if(s.gplO=r,"activity_time"===(null==a?void 0:a.AlVX)){var u,c,l,h=null==a||null===(u=a.QYMC)||void 0===u||null===(u=u.NVOO)||void 0===u?void 0:u.time;(null==a||null===(c=a.QYMC)||void 0===c||null===(c=c.NVOO)||void 0===c?void 0:c.nkpi.length)>0&&(setTimeout((function(){n.doep||(n.xVdJ=!0,n.xVdJ&&(n.vWIX+=1,n.xVdJ=n.LzlO(n.vWIX,n.dqkJ.FDLa,n.dqkJ.LXVx),n.xVdJ&&(n.dqkJ.gplO=r,o.validate(n.Fdjl,n.BjBE)))),a.QYMC.NVOO.nkpi.map((function(t){o.unregisterFromEvent(g(a.QYMC.NVOO.et)+"___"+t,n)}))}),h),a.QYMC.NVOO.nkpi.map((function(t){o.registerForEvent(g(a.QYMC.NVOO.et)+"___"+t,n.kIfZ)}))),(null==a||null===(l=a.QYMC)||void 0===l||null===(l=l.NVOO)||void 0===l?void 0:l.kpi.length)>0&&(setTimeout((function(){a.QYMC.NVOO.kpi.map((function(t){o.unregisterFromEvent(g(a.QYMC.NVOO.et)+"___"+t,n)}))}),h),a.QYMC.NVOO.kpi.map((function(t){t===a.jsSe.QYMC.CtPY?(o.unregisterFromEvent(p(s.AlVX)+"___"+s.QYMC.CtPY,n),o.registerForEvent(g(a.QYMC.NVOO.et)+"___"+t,n.uMbk)):o.registerForEvent(g(a.QYMC.NVOO.et)+"___"+t,n.kIfZ)})))}else o.unregisterFromEvent(p(s.AlVX)+"___"+s.QYMC.CtPY,n),o.registerForEvent(p(a.AlVX)+"___"+a.QYMC.CtPY,n);n.qewW[e]=Date.now()}})),s(this,"zOaF",(function(t,e,r,i){var o=n.dqkJ.jsSe;return p(o.AlVX)===t&&o.QYMC.CtPY===e&&n.Chvr(r,o.pWFR)&&n.BXyf(o.QYMC.NVOO,i)})),s(this,"Chvr",(function(t,e){var n=Math.ceil(t);return n>e.RZpl&&n<e.FsQW})),s(this,"LzlO",(function(t,e,r){var i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];switch(i&&n.dqkJ.eatT&&(t+=n.sqsm),r){case"EQ":return t===e;case"GT":return t>e;case"GTE":return t>=e;case"LT":return t<e;case"LTE":return t<=e;default:return!1}})),s(this,"BXyf",(function(t,e){var n=!0;try{var i,o=function(){if(!e[a]||!1===n)return{v:!1};if("object"===r(t[a])){var i,o=t[a].op,s=t[a].t;"s"===s?i=t[a].val:"l"!==s&&"f"!==s||(i=parseFloat(t[a].val));var u=(Array.isArray(e[a])?e[a]:[e[a]]).some((function(t){return y(t,i,o)}));n=n&&u}else n=n&&y(e[a],t[a],"EQ")};for(var a in t)if(i=o())return i.v}catch(t){q.error(t),n=!1}return n}))}return a(e,[{key:"_displayCampaign",value:function(t){var e=M.getInstance();this.xVdJ=!0,this.xVdJ&&(this.vWIX+=1,this.xVdJ=this.LzlO(this.vWIX,this.dqkJ.FDLa,this.dqkJ.LXVx),this.xVdJ&&(this.dqkJ.gplO=t,e.validate(this.Fdjl,this.BjBE)))}}]),e}(),j=window.ApxorLogger,x=a((function e(){var n=this;i(this,e),s(this,"PMCb",[]),s(this,"_ret_day",{}),s(this,"ejSN",{}),s(this,"eQvN",!1),s(this,"eEge",!1),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{n.PMCb=t.overall_cfg.events,n._ret_day=t.overall_cfg.ret_day,n.ejSN=t.overall_cfg.session,n.eQvN=t.overall_cfg.toggleRetDay,n.PMCb=t.overall_cfg.events,n.eEge=t.overall_cfg.toggleSession}catch(t){return j.error(t),!1}return!0})),s(this,"validate",(function(){var e=parseInt(t.getController().getFromStorage("apx_retained_days")),r=parseInt(t.getController().getFromStorage("apx_retained_session"));if(n.eQvN&&!isNaN(e)&&!(e>=n._ret_day.from&&e<=n._ret_day.to))return!1;if(n.eEge&&!isNaN(r)&&!(r>=n.ejSN.from&&r<=n.ejSN.to))return!1;try{for(var i=t.getController().getFromStorage("_apx_lt_count"),o=t.getSiteId(),a=JSON.parse((new TextDecoder).decode(function(t){for(var e=new ArrayBuffer(t.length),n=new Uint8Array(e),r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return e}(v(o,i)))),s=0;s<n.PMCb.length;s++){if(a[n.PMCb[s].name.replace("'","").replace("’","")])return!1}}catch(t){j.error("Failed to validate the lt count:"+t)}return!0}))})),J=window.ApxorLogger,D=a((function e(){var r=this;i(this,e),s(this,"BHxj",[]),s(this,"Fdjl",""),s(this,"FBLV",new b),s(this,"HZsk",new O),s(this,"bLov",new E),s(this,"RUmb",new V),s(this,"mpfN",new x),s(this,"OBnx",!1),s(this,"lyLV",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(!h(t._id))return J.error("No Id"),!1;if(!h(t.enabled)||!t.enabled)return J.error("Not enabled"),!1;if(!(r.FBLV.parse(t)&&r.bLov.parse(t)&&r.RUmb.parse(t)&&r.HZsk.parse(t)&&r.mpfN.parse(t)))return!1;if(!h(t.conditions)||!Array.isArray(t.conditions))return J.error("No valid conditions",t.conditions),!1;r.Fdjl=t._id,r.OBnx=!!h(t.sequence_enabled)&&t.sequence_enabled,r.OBnx&&t.conditions.sort((function(t,e){return t.sequence<e.sequence}));for(var e=t.conditions,n=e.length,i=0;i<n;i++){r.lyLV=[];var o=e[i];if("didn't"===o.type){var a,s={trigger_key:o.trigger.details.name,no_kpi_array:null==o||null===(a=o.details)||void 0===a||null===(a=a.additional_info)||void 0===a?void 0:a.nkpi,condition_id:null==o?void 0:o._id,time_bounds:o.time_bounds.upper};r.lyLV=[].concat(u(r.lyLV),[s])}var c=new N;c.initialize(o,r.Fdjl,i,r.OBnx,r.lyLV)&&r.BHxj.push(c)}return r.BHxj.length>0}catch(t){return J.error(t),!1}})),s(this,"BLtn",(function(t){if(!(t<0))if(r.OBnx){var e=r.BHxj[t];if(h(e)&&e.xVdJ){var n=r.BHxj[t-1];if(h(n)&&!n.xVdJ)return;var i=r.BHxj[t+1];h(i)?i.qqsE():r.CtCE()}}else r.CtCE()})),s(this,"CtCE",(function(){var e=t.getController().getUserAttributes(),i=t.getController().getSessionAttributes();if(r.bLov.validate()&&r.HZsk.validate(e,i)&&r.mpfN.validate()){for(var o=r.BHxj.length,a=o<1,s="",u=0;u<o;u++){var c=r.BHxj[u],l=c.xVdJ;if(""===s.trim())a=l;else switch(s){case"AND":a=a&&l;break;case"OR":a=a||l}s=c.kURO}if(a){if(console.debug("onCondition satisfied"),!r.RUmb.Frbd(r.Fdjl))return void console.warn("Maximum limit reached",r.Fdjl);console.log("Dispatching event",r.FBLV.FFVT),!0===r.FBLV._only_context&&t.logEvent("apx_context_evaluated",n(n({},r.FBLV._attr),{},{message_name:r.FBLV.CtPY,id:r.Fdjl})),t.getController().dispatchEvent(r.FBLV.FFVT,{name:r.FBLV.FFVT,additional_info:{uuid:r.Fdjl,name:r.FBLV.CtPY}})}}})),s(this,"PUEA",(function(){r.RUmb.PUEA()})),s(this,"getFrequencyCount",(function(){return r.RUmb.getFrequencyCount()})),s(this,"YMgG",(function(){return r.RUmb.kPus()}))})),Q=a((function t(){var e=this;i(this,t),s(this,"benn",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{configs:[]};if(h(t)&&h(t.configs)){var n=t.configs;if(!Array.isArray(n))return;n.sort((function(t,e){var n,r;return(null!==(n=t.prio)&&void 0!==n?n:-1)-(null!==(r=e.prio)&&void 0!==r?r:-1)}));for(var r=0;r<n.length;r++){var i=n[r],o=i._id,a=new D;a.parse(i)?e.benn[o]=a:console.warn("Failed to parse cfg",o)}}})),s(this,"validate",(function(t,n){e.benn[t]&&e.benn[t].BLtn(n)})),s(this,"PUEA",(function(t){e.benn[t].PUEA()})),s(this,"getFrequencyCount",(function(t){return e.benn[t].getFrequencyCount()})),s(this,"resetFrequencyCounts",(function(){var t=e.benn;for(var n in t)t[n].YMgG()})),s(this,"SynP",(function(t){try{if(e.benn){var n=e.benn[t];if(n&&n.FBLV)return n.FBLV}}catch(t){console.log("Error in getting the campaign meta ".concat(t))}return{}}))})),T=window.ApxorLogger,P=a((function e(){var n=this;i(this,e),s(this,"VywR",{}),s(this,"Tdmf",[]),s(this,"wJFP",!1),s(this,"initialize",(function(){var e=t.getController();e.registerForEvent("APP_EVENT",(function(t){return n.tkDV(t,"AE")})),e.registerForEvent("CLIENT_EVENT",(function(t){return n.tkDV(t,"CE")}))})),s(this,"QkcY",(function(){for(var t in n.Tdmf)n.MCKA(t.event,t.key,t.type);n.wJFP=!0})),s(this,"HhWj",(function(t,e){var r;"function"==typeof e&&((r=n.VywR[t]?n.VywR[t]:[]).push(e),n.VywR[t]=r,T.debug("Listeners list: ",n.VywR))})),s(this,"unregisterFromEvent",(function(t,e){if(n.VywR[t]){for(var r=n.VywR[t],i=[],o=0;o<r.length;o++){var a=r[o];a!==e&&i.push(a)}n.VywR[t]=i}})),s(this,"tkDV",(function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"AE",r=e+"___"+t.name;n.MCKA(t,r,e)})),s(this,"MCKA",(function(e,r,i){if(n.wJFP){if(T.debug("Notifying listeners for event: "+e+", "+r,n.VywR),n.VywR[r])for(var o=n.VywR[r],a=t.getController().getSDKRunningTimeInSec(),s=0;s<o.length;s++){(0,o[s])(i,e.name,a,e.additional_info)}}else n.Tdmf.push({event:e,key:r,type:i})}))})),I=window.ApxorLogger,M=function(){function e(){var n=this;return i(this,e),s(this,"nckW",!1),s(this,"yTlh",null),s(this,"JXUH",_()),s(this,"cINd",new P),s(this,"TKYH",t.getSiteId()),s(this,"hLYu",{}),s(this,"getQeState",(function(){try{var e=t.getController().getFromStorage("qe_state");return e?JSON.parse(v(n.TKYH,e)):(n.hLYu={},n.setQeState())}catch(t){return n.hLYu={},n.setQeState()}})),s(this,"setQeState",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{t.getController().persistToStorage("qe_state",n.hLYu,!0)}catch(r){""===e?n.hLYu={}:n.hLYu[e]={SESSION:0,OVERALL:0,DATES:{}},t.getController().persistToStorage("qe_state",n.hLYu,!0)}return n.hLYu})),s(this,"initialize",(function(){n.nckW||(n.nckW=!0,n.yTlh=new Q,n.cINd.initialize(),n.hLYu=n.getQeState(),I.info("QE Initialized.."))})),s(this,"parse",(function(t){n.kEWF()?(n.yTlh.parse(t),n.cINd.QkcY()):I.warn("Must call init first. Unable to proceed")})),s(this,"validate",(function(t,e){n.kEWF()&&n.yTlh.validate(t,e)})),s(this,"updateCount",(function(t){try{h(n.hLYu[t])||n.createObjConfig(t),n.incrementFrequencies(t),n.setQeState(t),n.yTlh.PUEA(t)}catch(t){console.log("Could not update the count config:".concat(t))}})),s(this,"resetFrequencyCounts",(function(){n.yTlh.resetFrequencyCounts()})),s(this,"getFrequencyCount",(function(t){return n.yTlh.getFrequencyCount(t)})),s(this,"registerForEvent",(function(t,e){n.cINd.HhWj(t,e)})),s(this,"unregisterFromEvent",(function(t,e){n.cINd.unregisterFromEvent(t,e)})),s(this,"fetch",(function(e,n,r,i){t.getController().fetchConfiguration(e,n,r,i)})),s(this,"kEWF",(function(){return n.nckW})),s(this,"getCampaignMetaFromQueryEngine",(function(t){return n.yTlh.SynP(t)})),s(this,"VBfn",(function(){return n.JXUH})),e.instance||(e.instance=this),e.instance}return a(e,[{key:"createObjConfig",value:function(t){try{this.hLYu=this.getQeState(),h(this.hLYu[t])||(this.hLYu[t]={SESSION:0,OVERALL:0,DATES:{}},this.JXUH&&(this.hLYu[t].DATES[this.JXUH]=0),this.setQeState(t))}catch(t){I.error("Can not create the frequency count object:"+t)}}},{key:"incrementFrequencies",value:function(t){this.hLYu=this.getQeState();var e=this.hLYu[t];e.SESSION=e.SESSION+1,e.OVERALL=e.OVERALL+1;var n=_();n===this.JXUH&&e.DATES&&e.DATES[n]||(this.JXUH=n,e.DATES={},e.DATES[this.JXUH]=0),e.DATES[this.JXUH]=e.DATES[this.JXUH]+1}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}();s(M,"instance",void 0),window.ceVersion=130;try{void 0===exports&&null===exports||(exports.default=M,module.exports=exports.default)}catch(t){}return M}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apxor-qe",
3
- "version": "1.2.4",
3
+ "version": "1.3.0",
4
4
  "author": "Uma Sankar Yedida <umasankar.yedida@apxor.com> (https://www.apxor.com)",
5
5
  "contributors": [
6
6
  {
@@ -52,7 +52,7 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "jsdom": "^22.1.0",
55
- "apxor": "2.1.4"
55
+ "apxor": "2.2.0"
56
56
  },
57
57
  "files": [
58
58
  "dist"