apxor-qe 1.1.9-qa → 1.1.10-qa.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,f(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=f(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function c(t){return function(t){if(Array.isArray(t))return u(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 u(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 u(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 u(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 f(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)},l="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 d=function(t,e){return v(t,e=function(t){var e,r,n,i,o,a,s=0,c=[];if(!t)return t;t+="";do{e=(a=l.indexOf(t.charAt(s++))<<18|l.indexOf(t.charAt(s++))<<12|(i=l.indexOf(t.charAt(s++)))<<6|(o=l.indexOf(t.charAt(s++))))>>16&255,r=a>>8&255,n=255&a,c.push(e),64!==i&&(c.push(r),64!==o&&c.push(n))}while(s<t.length);return c}(e))},g=function(t){switch(t){case"app_event":return"AE";case"client_event":return"CE";case"activity_time":case"activity_event":return"AE"}return"Unknown"},p=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)},_=function(){var t=new Date;return t.getDate()+"/"+t.getMonth()+"/"+t.getFullYear()},S=window.ApxorLogger,x=a((function e(){var r=this;i(this,e),s(this,"UyeA","ALL"),s(this,"yyom",[]),s(this,"jEHM",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(r.UyeA=t.audience.audience_type,r.yyom=t.audience.attributes.user,r.jEHM=t.audience.attributes.session,!Array.isArray(r.yyom)||!Array.isArray(r.jEHM))return S.error("No attributes"),!1}catch(t){return S.error(t),!1}return!0})),s(this,"validate",(function(e,n){var i=!0;return"FTU"===r.UyeA&&(i=t.getController().getSessionInfo().is_first_session),i&&r.KpSk(e,r.yyom)&&r.KpSk(n,r.jEHM)})),s(this,"KpSk",(function(t,e){var r=e.length,i=!0;try{for(var o=function(){var r=e[a];if(!t.hasOwnProperty(r.name)||!1===i)return{v:!1};var n=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})),c=(Array.isArray(t[r.name])?t[r.name]:[t[r.name]]).some((function(t){return s.some((function(e){return y(t,e,n)}))}));i=i&&c},a=0;a<r;a++){var s=o();if("object"===n(s))return s.v}}catch(t){S.error(t),i=!1}return i}))})),b=window.ApxorLogger,E=a((function t(){var e=this;i(this,t),s(this,"ZjTK",0),s(this,"boPN",0),s(this,"cvxt","SESSION"),s(this,"mzQU",0),s(this,"RbMC",0),s(this,"CMct",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.ZjTK=t.frequency.count,e.CMct=e.ZjTK,e.boPN=t.frequency.time_interval,e.cvxt=t.frequency.validity,e.RbMC=t.frequency.ses_lmt,e._dayCount=t.frequency.day_lmt;var r=Q.getInstance().getQeState();if(!h(r)||!h(r[t._id]))return!0;if("SESSION"===e.cvxt){if(e.ZjTK=parseInt(e.ZjTK)-parseInt(r[t._id].SESSION),e.ZjTK<=0)return console.warn("Max count limit reached for session:"+t._id),!1}else{if("OVERALL"!==e.cvxt)return b.info("Invalid config."),!1;if(e.ZjTK=parseInt(e.ZjTK)-parseInt(r[t._id].OVERALL),e.ZjTK<=0)return console.warn("Max count limit reached for overall:"+t._id),!1}}catch(t){return b.error(t),!1}return!0})),s(this,"gQZN",(function(){e.ZjTK=e.ZjTK-1})),s(this,"getFrequencyCount",(function(){return e.ZjTK})),s(this,"flSr",(function(){"SESSION"===e.cvxt&&(e.ZjTK=e.CMct,b.info("Campaign Limit reset"))})),s(this,"Ldoq",(function(t){try{if(e.ZjTK<=0)return!1;var r=Q.getInstance().getQeState();if(!h(r)||!h(r[t]))return!0;if(0!==e.RbMC)if(parseInt(e.RbMC)-parseInt(r[t].SESSION)<=0)return!1;if(0!==e._dayCount){Q.getInstance();var n,i=_();if(parseInt(e._dayCount)-parseInt((null===(n=r[t])||void 0===n?void 0:n.DATES[i])||0)<=0)return!1}}catch(t){b.error("Error validating the frequency:"+t)}return!0}))})),N=a((function t(){var e=this;i(this,t),s(this,"cWZl",""),s(this,"UyeA",""),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var r;e.cWZl=t.meta.name,e.UyeA=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}))})),j=window.ApxorLogger,I=a((function t(){var e=this;i(this,t),s(this,"vGcI",-1),s(this,"qWUf",-1),s(this,"IZiK",-1),s(this,"TIGO",-1),s(this,"XRsG",!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 j.error("Not valid dates"),!1;if(e.vGcI=Date.parse(t.validity.start_date),e.qWUf=Date.parse(t.validity.end_date),h(t.time_limits_in_day)&&(e.XRsG=t.time_limits_in_day,e.XRsG&&h(t.time_limits))){var r=(new Date).toISOString().split("T")[0];if(e.IZiK=Date.parse(r+"T"+t.time_limits.start_time+".000Z"),e.TIGO=Date.parse(r+"T"+t.time_limits.end_time+".000Z"),isNaN(e.IZiK)||isNaN(e.TIGO))return j.error("Not valid times"),!1}}catch(t){return j.error(t),!1}return!0})),s(this,"validate",(function(){var t=Date.now();return t>e.vGcI&&t<e.qWUf&&(!e.XRsG||t>=e.IZiK&&t<=e.TIGO)}))})),A=a((function t(){var e=this;i(this,t),s(this,"cWZl",""),s(this,"xbhS",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.cWZl=t.name,e.xbhS=t.additional_info}catch(t){return!1}return!0}))})),Z=a((function t(){var e=this;i(this,t),s(this,"jwPz",0),s(this,"GTYM",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.jwPz=Number(t.lower),e.GTYM=Number(t.upper),isNaN(e.jwPz)||isNaN(e.GTYM))return!1}catch(t){return!1}return!0}))})),w=a((function t(){var e=this;i(this,t),s(this,"PLZU",0),s(this,"Nckz",""),s(this,"bmxQ",""),s(this,"BBIh",new A),s(this,"ckOr",new Z),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.Nckz=t.event_type,e.bmxQ=t.activity,e.BBIh.parse(t.details)&&e.ckOr.parse(t.time_bounds)}catch(t){return!1}}))})),C=a((function t(){var e=this;i(this,t),s(this,"PLZU",0),s(this,"oeND",-1),s(this,"ZjTK",0),s(this,"Erqi",""),s(this,"bmxQ",""),s(this,"Nckz",""),s(this,"ckOr",new Z),s(this,"BBIh",new A),s(this,"vBxh",new w),s(this,"xXjK","AND"),s(this,"OKxH",!1),s(this,"UyeA",void 0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.oeND=t.sequence,e.ZjTK=t.count_config.count,e.Erqi=t.count_config.operator,e.bmxQ=t.activity,e.Nckz=t.event_type,e.xXjK=t.combine_operator,e.UyeA=t.type,e.BBIh.parse(t.details)&&e.vBxh.parse(t.trigger)&&e.ckOr.parse(t.time_bounds)}catch(t){return Logger.error(t),!1}}))})),T=window.ApxorLogger,B=function(){function e(){var r=this;i(this,e),s(this,"GEya",0),s(this,"yhMK",""),s(this,"Zffo",new C),s(this,"tYzf",!1),s(this,"Cjuc",!1),s(this,"YDoy",0),s(this,"xXjK","AND"),s(this,"MVDT",-1),s(this,"rObi",[]),s(this,"xGwf",{}),s(this,"DIfm",!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.yhMK=n,r.YDoy=i,r.rObi=a;var s=r.Zffo.parse(e);if(s){if(r.xXjK=r.Zffo.xXjK,r.Zffo.OKxH){var c=r.Zffo.BBIh.cWZl;"APX_PAGE_OPENED"===c&&(c=r.Zffo.BBIh.xbhS.navigation_id,c=isDefined(c)?c:r.Zffo.BBIh.cWZl),r.MVDT=t.getController().getEventCount(c);var u=r.Zffo.ZjTK,f=r.Zffo.Erqi;if(r.Cjuc=r.affJ(r.MVDT-1,u,f,!1),r.tYzf=r.Cjuc,r.Cjuc&&"APX_PAGE_OPENED"===r.Zffo.BBIh.cWZl)return!0}return o&&0!==i||r.WARv(),!0}return!1})),s(this,"WARv",(function(){var t=r.Zffo,e=t.vBxh,n=Q.getInstance();"app_start"===e.Nckz?(r.tYzf=!0,n.registerForEvent(g(t.Nckz)+"___"+t.BBIh.cWZl,r.jWUh)):n.registerForEvent(g(t.Nckz)+"___"+e.BBIh.cWZl,r.jWUh)})),s(this,"mejv",(function(t,e,n,i){var o,a,s,c=(Date.now()-r.xGwf[e])/1e3;(null===(o=r.Zffo)||void 0===o||null===(a=o.BBIh)||void 0===a||null===(s=a.xbhS)||void 0===s?void 0:s.time)/1e3>c&&r._displayCampaign(n)})),s(this,"MxyB",(function(t,e,n,i){var o,a,s,c,u;r.DIfm=!0;var f=Date.now(),h=null===(o=r.Zffo)||void 0===o||null===(a=o.vBxh)||void 0===a?void 0:a.BBIh.cWZl,l=(f-r.xGwf[h])/1e3,v=null===(s=r.Zffo)||void 0===s||null===(c=s.BBIh)||void 0===c||null===(u=c.xbhS)||void 0===u?void 0:u.time;(v/=1e3)>l&&r._displayCampaign(n)})),s(this,"jWUh",(function(t,e,n,i){var o=Q.getInstance();if(r.tYzf)g(r.Zffo.Nckz)===t&&r.iNJh(n-r.Zffo.vBxh.PLZU,r.Zffo.ckOr)&&r.Zffo.BBIh.cWZl===e&&r.EcjA(r.Zffo.BBIh.xbhS,i)&&(r.GEya+=1,r.Cjuc=r.affJ(r.GEya,r.Zffo.ZjTK,r.Zffo.Erqi),r.Cjuc&&(r.Zffo.PLZU=n,o.validate(r.yhMK,r.YDoy)));else if(r.tYzf=r.JRja(t,e,n,i),r.tYzf){var a=r.Zffo,s=a.vBxh;if(s.PLZU=n,"activity_time"===(null==a?void 0:a.Nckz)){var c,u,f,h,l,v,d=null==a||null===(c=a.BBIh)||void 0===c||null===(u=c.xbhS)||void 0===u?void 0:u.time;(null==a||null===(f=a.BBIh)||void 0===f||null===(h=f.xbhS)||void 0===h?void 0:h.nkpi.length)>0&&(setTimeout((function(){r.DIfm||(r.Cjuc=!0,r.Cjuc&&(r.GEya+=1,r.Cjuc=r.affJ(r.GEya,r.Zffo.ZjTK,r.Zffo.Erqi),r.Cjuc&&(r.Zffo.PLZU=n,o.validate(r.yhMK,r.YDoy)))),a.BBIh.xbhS.nkpi.map((function(t){o.unregisterFromEvent(p(a.BBIh.xbhS.et)+"___"+t,r)}))}),d),a.BBIh.xbhS.nkpi.map((function(t){o.registerForEvent(p(a.BBIh.xbhS.et)+"___"+t,r.MxyB)}))),(null==a||null===(l=a.BBIh)||void 0===l||null===(v=l.xbhS)||void 0===v?void 0:v.kpi.length)>0&&(setTimeout((function(){a.BBIh.xbhS.kpi.map((function(t){o.unregisterFromEvent(p(a.BBIh.xbhS.et)+"___"+t,r)}))}),d),a.BBIh.xbhS.kpi.map((function(t){t===a.vBxh.BBIh.cWZl?(o.unregisterFromEvent(g(s.Nckz)+"___"+s.BBIh.cWZl,r),o.registerForEvent(p(a.BBIh.xbhS.et)+"___"+t,r.mejv)):o.registerForEvent(p(a.BBIh.xbhS.et)+"___"+t,r.MxyB)})))}else o.unregisterFromEvent(g(s.Nckz)+"___"+s.BBIh.cWZl,r),o.registerForEvent(g(a.Nckz)+"___"+a.BBIh.cWZl,r);r.xGwf[e]=Date.now()}})),s(this,"JRja",(function(t,e,n,i){var o=r.Zffo.vBxh;return g(o.Nckz)===t&&o.BBIh.cWZl===e&&r.iNJh(n,o.ckOr)&&r.EcjA(o.BBIh.xbhS,i)})),s(this,"iNJh",(function(t,e){var r=Math.ceil(t);return r>e.jwPz&&r<e.GTYM})),s(this,"affJ",(function(t,e,n){var i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];switch(i&&r.Zffo.OKxH&&(t+=r.MVDT),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,"EcjA",(function(t,e){var r=!0;try{var i=function(){if(!e.hasOwnProperty(o)||!1===r)return{v:!1};if("object"===n(t[o])){var i,a=t[o].op,s=t[o].t;"s"===s?i=t[o].val:"l"!==s&&"f"!==s||(i=parseFloat(t[o].val));var c=(Array.isArray(e[o])?e[o]:[e[o]]).some((function(t){return y(t,i,a)}));r=r&&c}else r=r&&y(e[o],t[o],"EQ")};for(var o in t){var a=i();if("object"===n(a))return a.v}}catch(t){T.error(t),r=!1}return r}))}return a(e,[{key:"_displayCampaign",value:function(t){var e=Q.getInstance();this.Cjuc=!0,this.Cjuc&&(this.GEya+=1,this.Cjuc=this.affJ(this.GEya,this.Zffo.ZjTK,this.Zffo.Erqi),this.Cjuc&&(this.Zffo.PLZU=t,e.validate(this.yhMK,this.YDoy)))}}]),e}(),q=a((function e(){var r=this;i(this,e),s(this,"LSNB",[]),s(this,"_ret_day",{}),s(this,"QNnT",{}),s(this,"GRZt",!1),s(this,"gpHa",!1),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{r.LSNB=t.overall_cfg.events,r._ret_day=t.overall_cfg.ret_day,r.QNnT=t.overall_cfg.session,r.GRZt=t.overall_cfg.toggleRetDay,r.LSNB=t.overall_cfg.events,r.gpHa=t.overall_cfg.toggleSession}catch(t){return Logger.error(error),!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.GRZt&&!isNaN(e)&&!(e>=r._ret_day.from&&e<=r._ret_day.to))return!1;if(r.gpHa&&!isNaN(n)&&!(n>=r.QNnT.from&&n<=r.QNnT.to))return!1;try{for(var i=t.getController().getFromStorage("_apx_lt_count"),o=t.getSiteId(),a=JSON.parse(d(o,i)),s=0;s<r.LSNB.length;s++){var c=r.LSNB[s].name.replace("'","").replace("’","");if(a.hasOwnProperty(c))return!1}}catch(t){Logger.error("Failed to validate the lt count:"+t)}return!0}))})),O=window.ApxorLogger,L=a((function e(){var n=this;i(this,e),s(this,"QqSU",[]),s(this,"yhMK",""),s(this,"Yryc",new N),s(this,"sbOv",new x),s(this,"cvxt",new I),s(this,"NHPo",new E),s(this,"wSOP",new q),s(this,"aNTC",!1),s(this,"cmsS",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(!h(t._id))return O.error("No Id"),!1;if(!h(t.enabled)||!t.enabled)return O.error("Not enabled"),!1;if(!(n.Yryc.parse(t)&&n.cvxt.parse(t)&&n.NHPo.parse(t)&&n.sbOv.parse(t)&&n.wSOP.parse(t)))return!1;if(!h(t.conditions)||!Array.isArray(t.conditions))return O.error("No valid conditions",t.conditions),!1;n.yhMK=t._id,n.aNTC=!!h(t.sequence_enabled)&&t.sequence_enabled,n.aNTC&&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.cmsS=[];var o=e[i];if("didn't"===o.type){var a,s,u={trigger_key:o.trigger.details.name,no_kpi_array:null==o||null===(a=o.details)||void 0===a||null===(s=a.additional_info)||void 0===s?void 0:s.nkpi,condition_id:null==o?void 0:o._id,time_bounds:o.time_bounds.upper};n.cmsS=[].concat(c(n.cmsS),[u])}var f=new B;f.initialize(o,n.yhMK,i,n.aNTC,n.cmsS)&&n.QqSU.push(f)}return n.QqSU.length>0}catch(t){return O.error(t),!1}})),s(this,"CEav",(function(t){if(!(t<0))if(n.aNTC){var e=n.QqSU[t];if(h(e)&&e.Cjuc){var r=n.QqSU[t-1];if(h(r)&&!r.Cjuc)return;var i=n.QqSU[t+1];h(i)?i.WARv():n.zLpd()}}else n.zLpd()})),s(this,"zLpd",(function(){var e=t.getController().getUserAttributes(),i=t.getController().getSessionAttributes();if(n.cvxt.validate()&&n.sbOv.validate(e,i)&&n.wSOP.validate()){for(var o=n.QqSU.length,a=o<1,s="",c=0;c<o;c++){var u=n.QqSU[c],f=u.Cjuc;if(""===s.trim())a=f;else switch(s){case"AND":a=a&&f;break;case"OR":a=a||f}s=u.xXjK}if(a){if(console.debug("onCondition satisfied"),!n.NHPo.Ldoq(n.yhMK))return void console.warn("Maximum limit reached",n.yhMK);console.log("Dispatching event",n.Yryc.UyeA),!0===n.Yryc._only_context&&t.logEvent("apx_context_evaluated",r(r({},n.Yryc._attr),{},{message_name:n.Yryc.cWZl,id:n.yhMK})),t.getController().dispatchEvent(n.Yryc.UyeA,{name:n.Yryc.UyeA,additional_info:{uuid:n.yhMK,name:n.Yryc.cWZl}})}}})),s(this,"gQZN",(function(){n.NHPo.gQZN()})),s(this,"getFrequencyCount",(function(){return n.NHPo.getFrequencyCount()})),s(this,"rFYG",(function(){return n.NHPo.flSr()}))})),F=a((function t(){var e=this;i(this,t),s(this,"qqVx",{}),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 L;a.parse(i)?e.qqVx[o]=a:console.warn("Failed to parse cfg",o)}}})),s(this,"validate",(function(t,r){e.qqVx.hasOwnProperty(t)&&e.qqVx[t].CEav(r)})),s(this,"gQZN",(function(t){e.qqVx[t].gQZN()})),s(this,"getFrequencyCount",(function(t){return e.qqVx[t].getFrequencyCount()})),s(this,"resetFrequencyCounts",(function(){var t=e.qqVx;for(var r in t)t[r].rFYG()})),s(this,"VHHg",(function(t){try{if(e.qqVx){var r=e.qqVx[t];if(r&&r.Yryc)return r.Yryc}}catch(t){console.log("Error in getting the campaign meta ".concat(t))}return{}}))})),K=window.ApxorLogger,P=a((function e(){var r=this;i(this,e),s(this,"aNgA",{}),s(this,"TkMT",[]),s(this,"SETl",!1),s(this,"initialize",(function(){var e=t.getController();e.registerForEvent("APP_EVENT",(function(t){return r.LevP(t,"AE")})),e.registerForEvent("CLIENT_EVENT",(function(t){return r.LevP(t,"CE")}))})),s(this,"EHRd",(function(){for(var t in r.TkMT)r.mXFd(t.event,t.key,t.type);r.SETl=!0})),s(this,"iUsm",(function(t,e){var n;"function"==typeof e&&((n=r.aNgA[t]?r.aNgA[t]:[]).push(e),r.aNgA[t]=n,K.debug("Listeners list: ",r.aNgA))})),s(this,"unregisterFromEvent",(function(t,e){if(r.aNgA[t]){for(var n=r.aNgA[t],i=[],o=0;o<n.length;o++){var a=n[o];a!==e&&i.push(a)}r.aNgA[t]=i}})),s(this,"LevP",(function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"AE",n=e+"___"+t.name;r.mXFd(t,n,e)})),s(this,"mXFd",(function(e,n,i){if(r.SETl){if(K.debug("Notifying listeners for event: "+e+", "+n,r.aNgA),r.aNgA[n])for(var o=r.aNgA[n],a=t.getController().getSDKRunningTimeInSec(),s=0;s<o.length;s++){(0,o[s])(i,e.name,a,e.additional_info)}}else r.TkMT.push({event:e,key:n,type:i})}))})),D=window.ApxorLogger,Q=function(){function e(){var r=this;return i(this,e),s(this,"eqVJ",!1),s(this,"FpCq",null),s(this,"QvjF",_()),s(this,"Impm",new P),s(this,"Ihrw",t.getSiteId()),s(this,"LxRr",{}),s(this,"getQeState",(function(){try{var e=t.getController().getFromStorage("qe_state");return e?JSON.parse(d(r.Ihrw,e)):(r.LxRr={},r.setQeState())}catch(t){return r.LxRr={},r.setQeState()}})),s(this,"setQeState",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{t.getController().persistToStorage("qe_state",r.LxRr,!0)}catch(n){""===e?r.LxRr={}:r.LxRr[e]={SESSION:0,OVERALL:0,DATES:{}},t.getController().persistToStorage("qe_state",r.LxRr,!0)}return r.LxRr})),s(this,"initialize",(function(){r.eqVJ||(r.eqVJ=!0,r.FpCq=new F,r.Impm.initialize(),r.LxRr=r.getQeState(),D.info("QE Initialized.."))})),s(this,"parse",(function(t){r.JRKV()?(r.FpCq.parse(t),r.Impm.EHRd()):D.warn("Must call init first. Unable to proceed")})),s(this,"validate",(function(t,e){r.JRKV()&&r.FpCq.validate(t,e)})),s(this,"updateCount",(function(t){try{h(r.LxRr[t])||r.createObjConfig(t),r.incrementFrequencies(t),r.setQeState(t),r.FpCq.gQZN(t)}catch(t){console.log("Could not update the count config:".concat(t))}})),s(this,"resetFrequencyCounts",(function(){r.FpCq.resetFrequencyCounts()})),s(this,"getFrequencyCount",(function(t){return r.FpCq.getFrequencyCount(t)})),s(this,"registerForEvent",(function(t,e){r.Impm.iUsm(t,e)})),s(this,"unregisterFromEvent",(function(t,e){r.Impm.unregisterFromEvent(t,e)})),s(this,"fetch",(function(e,r,n,i){t.getController().fetchConfiguration(e,r,n,i)})),s(this,"JRKV",(function(){return r.eqVJ})),s(this,"getCampaignMetaFromQueryEngine",(function(t){return r.FpCq.VHHg(t)})),s(this,"nawi",(function(){return r.QvjF})),e.instance||(e.instance=this),e.instance}return a(e,[{key:"createObjConfig",value:function(t){try{this.LxRr=this.getQeState(),h(this.LxRr[t])||(this.LxRr[t]={SESSION:0,OVERALL:0,DATES:{}},this.QvjF&&(this.LxRr[t].DATES[this.QvjF]=0),this.setQeState(t))}catch(t){D.error("Can not create the frequency count object:"+t)}}},{key:"incrementFrequencies",value:function(t){this.LxRr=this.getQeState();var e=this.LxRr[t];e.SESSION=e.SESSION+1,e.OVERALL=e.OVERALL+1;var r=_();r===this.QvjF&&e.DATES&&e.DATES[r]||(this.QvjF=r,e.DATES={},e.DATES[this.QvjF]=0),e.DATES[this.QvjF]=e.DATES[this.QvjF]+1}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}();s(Q,"instance",void 0),window.ceVersion=119;try{void 0===exports&&null===exports||(exports.default=Q,module.exports=exports.default)}catch(t){}return Q}));
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&&t.hasOwnProperty("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 d=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))},g=function(t){switch(t){case"app_event":return"AE";case"client_event":return"CE";case"activity_time":case"activity_event":return"AE"}return"Unknown"},y=function(t){return t.toUpperCase()},p=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)},_=function(){var t=new Date;return t.getDate()+"/"+t.getMonth()+"/"+t.getFullYear()},b=window.ApxorLogger,D=a(function e(){var r=this;i(this,e),s(this,"jyXB","ALL"),s(this,"lZth",[]),s(this,"iosT",[]),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(r.jyXB=t.audience.audience_type,r.lZth=t.audience.attributes.user,r.iosT=t.audience.attributes.session,!Array.isArray(r.lZth)||!Array.isArray(r.iosT))return b.error("No attributes"),!1}catch(t){return b.error(t),!1}return!0}),s(this,"validate",function(e,n){var i=!0;return"FTU"===r.jyXB&&(i=t.getController().getSessionInfo().is_first_session),i&&r.OYnt(e,r.lZth)&&r.OYnt(n,r.iosT)}),s(this,"OYnt",function(t,e){var r=e.length,i=!0;try{for(var o=function(){var r=e[a];if(!t[r.name]||!1===i)return{v:!1};var n=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 p(t,e,n)})});i=i&&u},a=0;a<r;a++){var s=o();if("object"===n(s))return s.v}}catch(t){b.error(t),i=!1}return i})}),S=window.ApxorLogger,E=a(function t(){var e=this;i(this,t),s(this,"KkoD",0),s(this,"mBSu",0),s(this,"hDCI","SESSION"),s(this,"moQB",0),s(this,"PQZP",0),s(this,"xmdK",0),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.KkoD=t.frequency.count,e.xmdK=e.KkoD,e.mBSu=t.frequency.time_interval,e.hDCI=t.frequency.validity,e.PQZP=t.frequency.ses_lmt,e._dayCount=t.frequency.day_lmt;var r=Z.getInstance().getQeState();if(!h(r)||!h(r[t._id]))return!0;if("SESSION"===e.hDCI){if(e.KkoD=parseInt(e.KkoD)-parseInt(r[t._id].SESSION),e.KkoD<=0)return console.warn("Max count limit reached for session:"+t._id),!1}else{if("OVERALL"!==e.hDCI)return S.info("Invalid config."),!1;if(e.KkoD=parseInt(e.KkoD)-parseInt(r[t._id].OVERALL),e.KkoD<=0)return console.warn("Max count limit reached for overall:"+t._id),!1}}catch(t){return S.error(t),!1}return!0}),s(this,"lSfk",function(){e.KkoD=e.KkoD-1}),s(this,"getFrequencyCount",function(){return e.KkoD}),s(this,"REfq",function(){"SESSION"===e.hDCI&&(e.KkoD=e.xmdK,S.info("Campaign Limit reset"))}),s(this,"JglD",function(t){try{if(e.KkoD<=0)return!1;var r=Z.getInstance().getQeState();if(!h(r)||!h(r[t]))return!0;if(0!==e.PQZP)if(parseInt(e.PQZP)-parseInt(r[t].SESSION)<=0)return!1;if(0!==e._dayCount){var n,i=_();if(parseInt(e._dayCount)-parseInt((null===(n=r[t])||void 0===n?void 0:n.DATES[i])||0)<=0)return!1}}catch(t){S.error("Error validating the frequency:"+t)}return!0})}),w=a(function t(){var e=this;i(this,t),s(this,"yaFV",""),s(this,"jyXB",""),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var r;e.yaFV=t.meta.name,e.jyXB=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})}),N=window.ApxorLogger,L=a(function t(){var e=this;i(this,t),s(this,"LKPg",-1),s(this,"rbaj",-1),s(this,"aRKQ",-1),s(this,"kDES",-1),s(this,"EGEc",!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 N.error("Not valid dates"),!1;if(e.LKPg=Date.parse(t.validity.start_date),e.rbaj=Date.parse(t.validity.end_date),h(t.time_limits_in_day)&&(e.EGEc=t.time_limits_in_day,e.EGEc&&h(t.time_limits))){var r=(new Date).toISOString().split("T")[0];if(e.aRKQ=Date.parse(r+"T"+t.time_limits.start_time+".000Z"),e.kDES=Date.parse(r+"T"+t.time_limits.end_time+".000Z"),isNaN(e.aRKQ)||isNaN(e.kDES))return N.error("Not valid times"),!1}}catch(t){return N.error(t),!1}return!0}),s(this,"validate",function(){var t=Date.now();return t>e.LKPg&&t<e.rbaj&&(!e.EGEc||t>=e.aRKQ&&t<=e.kDES)})}),A=a(function t(){var e=this;i(this,t),s(this,"yaFV",""),s(this,"GizD",{}),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.yaFV=t.name,e.GizD=t.additional_info}catch(t){return!1}return!0})}),k=a(function t(){var e=this;i(this,t),s(this,"rrCh",0),s(this,"gDCR",0),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.rrCh=Number(t.lower),e.gDCR=Number(t.upper),isNaN(e.rrCh)||isNaN(e.gDCR))return!1}catch(t){return!1}return!0})}),O=a(function t(){var e=this;i(this,t),s(this,"kVxJ",0),s(this,"cWDi",""),s(this,"uiSd",""),s(this,"ebLm",new A),s(this,"aAiV",new k),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.cWDi=t.event_type,e.uiSd=t.activity,e.ebLm.parse(t.details)&&e.aAiV.parse(t.time_bounds)}catch(t){return!1}})}),x=window.ApxorLogger,C=a(function t(){var e=this;i(this,t),s(this,"kVxJ",0),s(this,"svLj",-1),s(this,"KkoD",0),s(this,"ZVZY",""),s(this,"uiSd",""),s(this,"cWDi",""),s(this,"aAiV",new k),s(this,"ebLm",new A),s(this,"MgEa",new O),s(this,"bRor","AND"),s(this,"EpOC",!1),s(this,"jyXB",void 0),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.svLj=t.sequence,e.KkoD=t.count_config.count,e.ZVZY=t.count_config.operator,e.uiSd=t.activity,e.cWDi=t.event_type,e.bRor=t.combine_operator,e.jyXB=t.type,e.ebLm.parse(t.details)&&e.MgEa.parse(t.trigger)&&e.aAiV.parse(t.time_bounds)}catch(t){return x.error(t),!1}})}),q=window.ApxorLogger,M=function(){function e(){var r=this;i(this,e),s(this,"yqph",0),s(this,"zNLA",""),s(this,"wMtN",new C),s(this,"NKqT",!1),s(this,"mJlk",!1),s(this,"RfKK",0),s(this,"bRor","AND"),s(this,"GQSy",-1),s(this,"gIUZ",[]),s(this,"aOME",{}),s(this,"iqOO",!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]:[];if(r.zNLA=n,r.RfKK=i,r.gIUZ=a,r.wMtN.parse(e)){if(r.bRor=r.wMtN.bRor,r.wMtN.EpOC){var s=r.wMtN.ebLm.yaFV;"APX_PAGE_OPENED"===s&&(s=r.wMtN.ebLm.GizD.navigation_id,s=h(s)?s:r.wMtN.ebLm.yaFV),r.GQSy=t.getController().getEventCount(s);var u=r.wMtN.KkoD,c=r.wMtN.ZVZY;if(r.mJlk=r.pqqV(r.GQSy-1,u,c,!1),r.NKqT=r.mJlk,r.mJlk&&"APX_PAGE_OPENED"===r.wMtN.ebLm.yaFV)return!0}return o&&0!==i||r.gINm(),!0}return!1}),s(this,"gINm",function(){var t=r.wMtN,e=t.MgEa,n=Z.getInstance();"app_start"===e.cWDi?(r.NKqT=!0,n.registerForEvent(g(t.cWDi)+"___"+t.ebLm.yaFV,r.SnBK)):n.registerForEvent(g(t.cWDi)+"___"+e.ebLm.yaFV,r.SnBK)}),s(this,"gjCB",function(t,e,n,i){var o,a,s,u=(Date.now()-r.aOME[e])/1e3;(null===(o=r.wMtN)||void 0===o?void 0:null===(a=o.ebLm)||void 0===a?void 0:null===(s=a.GizD)||void 0===s?void 0:s.time)/1e3>u&&r._displayCampaign(n)}),s(this,"MhsE",function(t,e,n,i){var o,a,s,u,c;r.iqOO=!0;var l=Date.now(),h=null===(o=r.wMtN)||void 0===o?void 0:null===(a=o.MgEa)||void 0===a?void 0:a.ebLm.yaFV,f=(l-r.aOME[h])/1e3,v=null===(s=r.wMtN)||void 0===s?void 0:null===(u=s.ebLm)||void 0===u?void 0:null===(c=u.GizD)||void 0===c?void 0:c.time;(v/=1e3)>f&&r._displayCampaign(n)}),s(this,"SnBK",function(t,e,n,i){var o=Z.getInstance();if(r.NKqT)g(r.wMtN.cWDi)===t&&r.dLxA(n-r.wMtN.MgEa.kVxJ,r.wMtN.aAiV)&&r.wMtN.ebLm.yaFV===e&&r.eFNk(r.wMtN.ebLm.GizD,i)&&(r.yqph+=1,r.mJlk=r.pqqV(r.yqph,r.wMtN.KkoD,r.wMtN.ZVZY),r.mJlk&&(r.wMtN.kVxJ=n,o.validate(r.zNLA,r.RfKK)));else if(r.NKqT=r.mTyq(t,e,n,i),r.NKqT){var a=r.wMtN,s=a.MgEa;if(s.kVxJ=n,"activity_time"===(null==a?void 0:a.cWDi)){var u,c,l,h,f,v,d=null==a?void 0:null===(u=a.ebLm)||void 0===u?void 0:null===(c=u.GizD)||void 0===c?void 0:c.time;(null==a?void 0:null===(l=a.ebLm)||void 0===l?void 0:null===(h=l.GizD)||void 0===h?void 0:h.nkpi.length)>0&&(setTimeout(function(){r.iqOO||(r.mJlk=!0,r.mJlk&&(r.yqph+=1,r.mJlk=r.pqqV(r.yqph,r.wMtN.KkoD,r.wMtN.ZVZY),r.mJlk&&(r.wMtN.kVxJ=n,o.validate(r.zNLA,r.RfKK)))),a.ebLm.GizD.nkpi.map(function(t){o.unregisterFromEvent(y(a.ebLm.GizD.et)+"___"+t,r)})},d),a.ebLm.GizD.nkpi.map(function(t){o.registerForEvent(y(a.ebLm.GizD.et)+"___"+t,r.MhsE)})),(null==a?void 0:null===(f=a.ebLm)||void 0===f?void 0:null===(v=f.GizD)||void 0===v?void 0:v.kpi.length)>0&&(setTimeout(function(){a.ebLm.GizD.kpi.map(function(t){o.unregisterFromEvent(y(a.ebLm.GizD.et)+"___"+t,r)})},d),a.ebLm.GizD.kpi.map(function(t){t===a.MgEa.ebLm.yaFV?(o.unregisterFromEvent(g(s.cWDi)+"___"+s.ebLm.yaFV,r),o.registerForEvent(y(a.ebLm.GizD.et)+"___"+t,r.gjCB)):o.registerForEvent(y(a.ebLm.GizD.et)+"___"+t,r.MhsE)}))}else o.unregisterFromEvent(g(s.cWDi)+"___"+s.ebLm.yaFV,r),o.registerForEvent(g(a.cWDi)+"___"+a.ebLm.yaFV,r);r.aOME[e]=Date.now()}}),s(this,"mTyq",function(t,e,n,i){var o=r.wMtN.MgEa;return g(o.cWDi)===t&&o.ebLm.yaFV===e&&r.dLxA(n,o.aAiV)&&r.eFNk(o.ebLm.GizD,i)}),s(this,"dLxA",function(t,e){var r=Math.ceil(t);return r>e.rrCh&&r<e.gDCR}),s(this,"pqqV",function(t,e,n){switch((!(arguments.length>3&&void 0!==arguments[3])||arguments[3])&&r.wMtN.EpOC&&(t+=r.GQSy),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,"eFNk",function(t,e){var r=!0;try{var i=function(){if(!e[o]||!1===r)return{v:!1};if("object"===n(t[o])){var i,a=t[o].op,s=t[o].t;"s"===s?i=t[o].val:"l"!==s&&"f"!==s||(i=parseFloat(t[o].val));var u=(Array.isArray(e[o])?e[o]:[e[o]]).some(function(t){return p(t,i,a)});r=r&&u}else r=r&&p(e[o],t[o],"EQ")};for(var o in t){var a=i();if("object"===n(a))return a.v}}catch(t){q.error(t),r=!1}return r})}return a(e,[{key:"_displayCampaign",value:function(t){var e=Z.getInstance();this.mJlk=!0,this.mJlk&&(this.yqph+=1,this.mJlk=this.pqqV(this.yqph,this.wMtN.KkoD,this.wMtN.ZVZY),this.mJlk&&(this.wMtN.kVxJ=t,e.validate(this.zNLA,this.RfKK)))}}]),e}(),F="qe_state",I=window.ApxorLogger,z=a(function e(){var r=this;i(this,e),s(this,"JHaZ",[]),s(this,"_ret_day",{}),s(this,"Gbfo",{}),s(this,"sYjx",!1),s(this,"JxBs",!1),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{r.JHaZ=t.overall_cfg.events,r._ret_day=t.overall_cfg.ret_day,r.Gbfo=t.overall_cfg.session,r.sYjx=t.overall_cfg.toggleRetDay,r.JHaZ=t.overall_cfg.events,r.JxBs=t.overall_cfg.toggleSession}catch(t){return I.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.sYjx&&!isNaN(e)&&!(e>=r._ret_day.from&&e<=r._ret_day.to))return!1;if(r.JxBs&&!isNaN(n)&&!(n>=r.Gbfo.from&&n<=r.Gbfo.to))return!1;try{for(var i=t.getController().getFromStorage("_apx_lt_count"),o=t.getSiteId(),a=JSON.parse(d(o,i)),s=0;s<r.JHaZ.length;s++){if(a[r.JHaZ[s].name.replace("'","").replace("’","")])return!1}}catch(t){I.error("Failed to validate the lt count:"+t)}return!0})}),J=window.ApxorLogger,V=a(function e(){var n=this;i(this,e),s(this,"IuXx",[]),s(this,"zNLA",""),s(this,"SOrm",new w),s(this,"aTkp",new D),s(this,"hDCI",new L),s(this,"UnuD",new E),s(this,"IEfn",new z),s(this,"PiMM",!1),s(this,"JyrV",[]),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(!(n.SOrm.parse(t)&&n.hDCI.parse(t)&&n.UnuD.parse(t)&&n.aTkp.parse(t)&&n.IEfn.parse(t)))return!1;if(!h(t.conditions)||!Array.isArray(t.conditions))return J.error("No valid conditions",t.conditions),!1;n.zNLA=t._id,n.PiMM=!!h(t.sequence_enabled)&&t.sequence_enabled,n.PiMM&&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.JyrV=[];var o=e[i];if("didn't"===o.type){var a,s,c={trigger_key:o.trigger.details.name,no_kpi_array:null==o?void 0:null===(a=o.details)||void 0===a?void 0:null===(s=a.additional_info)||void 0===s?void 0:s.nkpi,condition_id:null==o?void 0:o._id,time_bounds:o.time_bounds.upper};n.JyrV=[].concat(u(n.JyrV),[c])}var l=new M;l.initialize(o,n.zNLA,i,n.PiMM,n.JyrV)&&n.IuXx.push(l)}return n.IuXx.length>0}catch(t){return J.error(t),!1}}),s(this,"PffH",function(t){if(!(t<0))if(n.PiMM){var e=n.IuXx[t];if(h(e)&&e.mJlk){var r=n.IuXx[t-1];if(h(r)&&!r.mJlk)return;var i=n.IuXx[t+1];h(i)?i.gINm():n.nhnX()}}else n.nhnX()}),s(this,"nhnX",function(){var e=t.getController().getUserAttributes(),i=t.getController().getSessionAttributes();if(n.hDCI.validate()&&n.aTkp.validate(e,i)&&n.IEfn.validate()){for(var o=n.IuXx.length,a=o<1,s="",u=0;u<o;u++){var c=n.IuXx[u],l=c.mJlk;if(""===s.trim())a=l;else switch(s){case"AND":a=a&&l;break;case"OR":a=a||l}s=c.bRor}if(a){if(console.debug("onCondition satisfied"),!n.UnuD.JglD(n.zNLA))return void console.warn("Maximum limit reached",n.zNLA);console.log("Dispatching event",n.SOrm.jyXB),!0===n.SOrm._only_context&&t.logEvent("apx_context_evaluated",r(r({},n.SOrm._attr),{},{message_name:n.SOrm.yaFV,id:n.zNLA})),t.getController().dispatchEvent(n.SOrm.jyXB,{name:n.SOrm.jyXB,additional_info:{uuid:n.zNLA,name:n.SOrm.yaFV}})}}}),s(this,"lSfk",function(){n.UnuD.lSfk()}),s(this,"getFrequencyCount",function(){return n.UnuD.getFrequencyCount()}),s(this,"cajt",function(){return n.UnuD.REfq()})}),j=a(function t(){var e=this;i(this,t),s(this,"ZhRR",{}),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 V;a.parse(i)?e.ZhRR[o]=a:console.warn("Failed to parse cfg",o)}}}),s(this,"validate",function(t,r){e.ZhRR[t]&&e.ZhRR[t].PffH(r)}),s(this,"lSfk",function(t){e.ZhRR[t].lSfk()}),s(this,"getFrequencyCount",function(t){return e.ZhRR[t].getFrequencyCount()}),s(this,"resetFrequencyCounts",function(){var t=e.ZhRR;for(var r in t)t[r].cajt()}),s(this,"Suhh",function(t){try{if(e.ZhRR){var r=e.ZhRR[t];if(r&&r.SOrm)return r.SOrm}}catch(t){console.log("Error in getting the campaign meta ".concat(t))}return{}})}),K=window.ApxorLogger,T=a(function e(){var r=this;i(this,e),s(this,"ihqx",{}),s(this,"sXGF",[]),s(this,"mBTm",!1),s(this,"initialize",function(){var e=t.getController();e.registerForEvent("APP_EVENT",function(t){return r.DHyY(t,"AE")}),e.registerForEvent("CLIENT_EVENT",function(t){return r.DHyY(t,"CE")})}),s(this,"sQAT",function(){for(var t in r.sXGF)r.QsuK(t.event,t.key,t.type);r.mBTm=!0}),s(this,"GvAJ",function(t,e){var n;"function"==typeof e&&((n=r.ihqx[t]?r.ihqx[t]:[]).push(e),r.ihqx[t]=n,K.debug("Listeners list: ",r.ihqx))}),s(this,"unregisterFromEvent",function(t,e){if(r.ihqx[t]){for(var n=r.ihqx[t],i=[],o=0;o<n.length;o++){var a=n[o];a!==e&&i.push(a)}r.ihqx[t]=i}}),s(this,"DHyY",function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"AE",n=e+"___"+t.name;r.QsuK(t,n,e)}),s(this,"QsuK",function(e,n,i){if(r.mBTm){if(K.debug("Notifying listeners for event: "+e+", "+n,r.ihqx),r.ihqx[n])for(var o=r.ihqx[n],a=t.getController().getSDKRunningTimeInSec(),s=0;s<o.length;s++){(0,o[s])(i,e.name,a,e.additional_info)}}else r.sXGF.push({event:e,key:n,type:i})})}),R=window.ApxorLogger,Z=function(){function e(){var r=this;return i(this,e),s(this,"ansf",!1),s(this,"wpgz",null),s(this,"ngyZ",_()),s(this,"dymD",new T),s(this,"Hdaj",t.getSiteId()),s(this,"JLze",{}),s(this,"getQeState",function(){try{var e=t.getController().getFromStorage(F);return e?JSON.parse(d(r.Hdaj,e)):(r.JLze={},r.setQeState())}catch(t){return r.JLze={},r.setQeState()}}),s(this,"setQeState",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{t.getController().persistToStorage(F,r.JLze,!0)}catch(n){""===e?r.JLze={}:r.JLze[e]={SESSION:0,OVERALL:0,DATES:{}},t.getController().persistToStorage(F,r.JLze,!0)}return r.JLze}),s(this,"initialize",function(){r.ansf||(r.ansf=!0,r.wpgz=new j,r.dymD.initialize(),r.JLze=r.getQeState(),R.info("QE Initialized.."))}),s(this,"parse",function(t){r.iQUj()?(r.wpgz.parse(t),r.dymD.sQAT()):R.warn("Must call init first. Unable to proceed")}),s(this,"validate",function(t,e){r.iQUj()&&r.wpgz.validate(t,e)}),s(this,"updateCount",function(t){try{h(r.JLze[t])||r.createObjConfig(t),r.incrementFrequencies(t),r.setQeState(t),r.wpgz.lSfk(t)}catch(t){console.log("Could not update the count config:".concat(t))}}),s(this,"resetFrequencyCounts",function(){r.wpgz.resetFrequencyCounts()}),s(this,"getFrequencyCount",function(t){return r.wpgz.getFrequencyCount(t)}),s(this,"registerForEvent",function(t,e){r.dymD.GvAJ(t,e)}),s(this,"unregisterFromEvent",function(t,e){r.dymD.unregisterFromEvent(t,e)}),s(this,"fetch",function(e,r,n,i){t.getController().fetchConfiguration(e,r,n,i)}),s(this,"iQUj",function(){return r.ansf}),s(this,"getCampaignMetaFromQueryEngine",function(t){return r.wpgz.Suhh(t)}),s(this,"ngye",function(){return r.ngyZ}),e.instance||(e.instance=this),e.instance}return a(e,[{key:"createObjConfig",value:function(t){try{this.JLze=this.getQeState(),h(this.JLze[t])||(this.JLze[t]={SESSION:0,OVERALL:0,DATES:{}},this.ngyZ&&(this.JLze[t].DATES[this.ngyZ]=0),this.setQeState(t))}catch(t){R.error("Can not create the frequency count object:"+t)}}},{key:"incrementFrequencies",value:function(t){this.JLze=this.getQeState();var e=this.JLze[t];e.SESSION=e.SESSION+1,e.OVERALL=e.OVERALL+1;var r=_();r===this.ngyZ&&e.DATES&&e.DATES[r]||(this.ngyZ=r,e.DATES={},e.DATES[this.ngyZ]=0),e.DATES[this.ngyZ]=e.DATES[this.ngyZ]+1}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}();s(Z,"instance",void 0),window.ceVersion=119;try{void 0===exports&&null===exports||(exports.default=Z,module.exports=exports.default)}catch(t){}return Z});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apxor-qe",
3
- "version": "1.1.9-qa",
3
+ "version": "1.1.10-qa.0",
4
4
  "author": "Uma Sankar Yedida <umasankar.yedida@apxor.com> (https://www.apxor.com)",
5
5
  "contributors": [
6
6
  {
@@ -28,46 +28,48 @@
28
28
  },
29
29
  "main": "dist/apxor.qe.min.js",
30
30
  "types": "dist/apxor.qe.d.ts",
31
- "scripts": {
32
- "start": "npm run dev && node conf/file-watcher.js",
33
- "clean": "rm -rf dist/",
34
- "rollup": "rollup --config conf/rollup.config.js --environment INCLUDE_DEPS,BUILD:production",
35
- "minify": "node conf/minify.sdk.js dist/apxor.qe.js && minify dist/apxor.qe.js > dist/apxor.qe.min.js && rm dist/apxor.qe.js dist/apxor.qe.js.bak",
36
- "build": "npm run clean && npm run rollup && npm run minify && cp ./src/apxor.qe.d.ts dist/apxor.qe.d.ts",
37
- "dev": "npm run clean && npm run rollup && cp ./src/apxor.qe.d.ts dist/apxor.qe.d.ts && mv dist/apxor.qe.js dist/apxor.qe.min.js",
38
- "prepublish": "check-node-version --npm \">=4\" || npm run prepare",
39
- "prepare": "npm run build",
40
- "lint": "eslint ./src/**.js",
41
- "coverage": "jest --coverage --config=conf/jest.config.js",
42
- "test": "jest --config=conf/jest.config.js --verbose --env=node",
43
- "test:watch": "jest --watch",
44
- "cypress": "./node_modules/.bin/cypress open"
45
- },
46
31
  "devDependencies": {
47
32
  "@babel/core": "^7.20.7",
48
33
  "@babel/eslint-parser": "^7.19.1",
49
34
  "@babel/plugin-proposal-class-properties": "^7.18.6",
50
35
  "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
51
36
  "@babel/preset-env": "^7.20.2",
37
+ "@vitest/coverage-v8": "^0.32.2",
52
38
  "babel-eslint": "^10.1.0",
53
39
  "babel-loader": "^9.1.0",
54
- "check-node-version": "^3.2.0",
55
40
  "chokidar": "^3.5.2",
56
- "cypress": "^3.2.0",
57
- "jest": "22.4.3",
41
+ "eslint-config-prettier": "^8.8.0",
42
+ "eslint-plugin-prettier": "^4.2.1",
58
43
  "minify": "^4.1.1",
59
44
  "rollup": "^1.13.1",
60
45
  "rollup-plugin-babel": "^4.3.2",
61
46
  "rollup-plugin-commonjs": "^10.0.0",
62
47
  "rollup-plugin-json": "^4.0.0",
63
48
  "rollup-plugin-node-resolve": "^5.0.1",
64
- "rollup-plugin-replace": "^2.2.0"
49
+ "rollup-plugin-replace": "^2.2.0",
50
+ "vite": "^4.3.9",
51
+ "vitest": "^0.32.2"
65
52
  },
66
53
  "dependencies": {
67
- "apxor": "^1.7.6"
54
+ "jsdom": "^22.1.0",
55
+ "apxor": "1.9.1-qa.0"
68
56
  },
69
57
  "files": [
70
58
  "dist"
71
59
  ],
72
- "unpkg": "dist/apxor.qe.min.js"
60
+ "unpkg": "dist/apxor.qe.min.js",
61
+ "scripts": {
62
+ "start": "npm run dev && node conf/file-watcher.js",
63
+ "clean": "rm -rf dist/",
64
+ "rollup": "rollup --config conf/rollup.config.js --environment INCLUDE_DEPS,BUILD:production",
65
+ "minify": "node conf/minify.sdk.js dist/apxor.qe.js && minify dist/apxor.qe.js > dist/apxor.qe.min.js && rm dist/apxor.qe.js ",
66
+ "prebuild": "npm run clean",
67
+ "build": "npm run rollup && npm run minify",
68
+ "postbuild": "cp ./src/apxor.qe.d.ts dist/apxor.qe.d.ts",
69
+ "dev": "npm run clean && npm run rollup && cp ./src/apxor.qe.d.ts dist/apxor.qe.d.ts && mv dist/apxor.qe.js dist/apxor.qe.min.js",
70
+ "lint": "eslint ./src/**.js",
71
+ "lint:fix": "eslint ./src/**.js --fix",
72
+ "coverage": "vitest run --coverage",
73
+ "test:ui": "vitest --ui --api 1337 --config ./conf/vite.config.js"
74
+ }
73
75
  }