UNPKG

apxor

Version:
1 lines 84.6 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).Apxor=t()}(this,(function(){"use strict";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function t(t){for(var n=1;n<arguments.length;n++){var i=null!=arguments[n]?arguments[n]:{};n%2?e(Object(i),!0).forEach((function(e){a(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,d(i.key),i)}}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(e,t,n){return(t=d(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o,a,s=[],u=!0,l=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(i=o.call(n)).done)&&(s.push(i.value),s.length!==t);u=!0);}catch(e){l=!0,r=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw r}}return s}}(e,t)||l(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||l(e)||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 l(e,t){if(e){if("string"==typeof e)return c(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function d(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}var g={enable:!0,api_root:"https://server.apxor.com/v2/api",auto_track_events:["click","submit"],cookie_expiration:730,name:"",domain:"",cookie_prefix:"_apx_",idle_time_out:1800,ed_t_time:-1,sct_time:108e5,events:{stop:[],action:[]}},f={debug:!1,honorDNT:!1,idle_time_out:1800,client_id:null,session_id:null,plugins:[],version:"ALL",events_upload_time:-1,retry_time:-1,bulk_upload:!0,auto_event_logging:!1},h="local_storage",p=["inline_shown","inapp_shown","apx_onboarding_screen_shown"],v=["apx_survey_dialog_launched","apx_survey_launched"],_=["inline_dismissed","walk_through_cancelled","inapp_dismissed","apx_onboarding_completed","apx_onboarding_screen_dismissed"],m=["apx_survey_completed"],b=["apx_app_opened","install","apx_context_evaluated","InlineTargetViewClicked","InAppBackButtonPressed","InAppRedirectionFailed","inapp_show_failed","InAppXIconClicked","apx_video_inapp_button_clicked","apx_video_inapp_close_button_clicked","apx_video_inapp_failed","apx_video_inapp_maximised","apx_video_inapp_minimised","apx_video_inapp_volume_button_clicked"],y=["apx_survey_dialog_yes_clicked","apx_survey_dialog_close_icon_clicked","apx_survey_close_button_clicked","apx_survey_back_button_pressed","apx_survey_dialog_no_clicked","apx_survey_question_asked","apx_survey_question_answered","apx_survey_skip_button_clicked","apx_survey_back_button_clicked","apx_survey_"],w="Opera Mini",x="Opera",S="BlackBerry",I="Internet Explorer Mobile",E="Microsoft Edge",T="Facebook Mobile",D="Chrome",k="Chrome iOS",C="UC Browser",O="Firefox iOS",A="Mobile Safari",N="Safari",P="Android Mobile",V="Konqueror",J="Firefox",j="Internet Explorer",F="Mozilla",q="Brave",L=["apx_debug_enable","apx_log_level","_apx_config","apx_id","apx_ver","apx_ver","apx_in","_apx_od","_apx_use","_apx_cd","qe_state","apx_retained_session","apx_retained_days","_apx_ua","_apx_sc","_apx_ledt","_apx_lef","_apx_ch","_apx_lct","_apx_uih","apx_lbgt","_apx_lEt","_apx_sId","_apx_lt_count","apx_sst","apx_termination_ID","_apx_ew","_apx_scnm","0__lcfht","1__lcfht","_apx_td","apx-last-shown-times","apx-last-shown-session"];function K(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function M(e,t,n,i,r,o){return K((a=K(K(t,e),K(i,o)))<<(s=r)|a>>>32-s,n);var a,s}function R(e,t,n,i,r,o,a){return M(t&n|~t&i,e,t,r,o,a)}function H(e,t,n,i,r,o,a){return M(t&i|n&~i,e,t,r,o,a)}function B(e,t,n,i,r,o,a){return M(t^n^i,e,t,r,o,a)}function U(e,t,n,i,r,o,a){return M(n^(t|~i),e,t,r,o,a)}function Z(e,t){var n,i,r,o,a;e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;var s=1732584193,u=-271733879,l=-1732584194,c=271733878;for(n=0;n<e.length;n+=16)i=s,r=u,o=l,a=c,s=R(s,u,l,c,e[n],7,-680876936),c=R(c,s,u,l,e[n+1],12,-389564586),l=R(l,c,s,u,e[n+2],17,606105819),u=R(u,l,c,s,e[n+3],22,-1044525330),s=R(s,u,l,c,e[n+4],7,-176418897),c=R(c,s,u,l,e[n+5],12,1200080426),l=R(l,c,s,u,e[n+6],17,-1473231341),u=R(u,l,c,s,e[n+7],22,-45705983),s=R(s,u,l,c,e[n+8],7,1770035416),c=R(c,s,u,l,e[n+9],12,-1958414417),l=R(l,c,s,u,e[n+10],17,-42063),u=R(u,l,c,s,e[n+11],22,-1990404162),s=R(s,u,l,c,e[n+12],7,1804603682),c=R(c,s,u,l,e[n+13],12,-40341101),l=R(l,c,s,u,e[n+14],17,-1502002290),s=H(s,u=R(u,l,c,s,e[n+15],22,1236535329),l,c,e[n+1],5,-165796510),c=H(c,s,u,l,e[n+6],9,-1069501632),l=H(l,c,s,u,e[n+11],14,643717713),u=H(u,l,c,s,e[n],20,-373897302),s=H(s,u,l,c,e[n+5],5,-701558691),c=H(c,s,u,l,e[n+10],9,38016083),l=H(l,c,s,u,e[n+15],14,-660478335),u=H(u,l,c,s,e[n+4],20,-405537848),s=H(s,u,l,c,e[n+9],5,568446438),c=H(c,s,u,l,e[n+14],9,-1019803690),l=H(l,c,s,u,e[n+3],14,-187363961),u=H(u,l,c,s,e[n+8],20,1163531501),s=H(s,u,l,c,e[n+13],5,-1444681467),c=H(c,s,u,l,e[n+2],9,-51403784),l=H(l,c,s,u,e[n+7],14,1735328473),s=B(s,u=H(u,l,c,s,e[n+12],20,-1926607734),l,c,e[n+5],4,-378558),c=B(c,s,u,l,e[n+8],11,-2022574463),l=B(l,c,s,u,e[n+11],16,1839030562),u=B(u,l,c,s,e[n+14],23,-35309556),s=B(s,u,l,c,e[n+1],4,-1530992060),c=B(c,s,u,l,e[n+4],11,1272893353),l=B(l,c,s,u,e[n+7],16,-155497632),u=B(u,l,c,s,e[n+10],23,-1094730640),s=B(s,u,l,c,e[n+13],4,681279174),c=B(c,s,u,l,e[n],11,-358537222),l=B(l,c,s,u,e[n+3],16,-722521979),u=B(u,l,c,s,e[n+6],23,76029189),s=B(s,u,l,c,e[n+9],4,-640364487),c=B(c,s,u,l,e[n+12],11,-421815835),l=B(l,c,s,u,e[n+15],16,530742520),s=U(s,u=B(u,l,c,s,e[n+2],23,-995338651),l,c,e[n],6,-198630844),c=U(c,s,u,l,e[n+7],10,1126891415),l=U(l,c,s,u,e[n+14],15,-1416354905),u=U(u,l,c,s,e[n+5],21,-57434055),s=U(s,u,l,c,e[n+12],6,1700485571),c=U(c,s,u,l,e[n+3],10,-1894986606),l=U(l,c,s,u,e[n+10],15,-1051523),u=U(u,l,c,s,e[n+1],21,-2054922799),s=U(s,u,l,c,e[n+8],6,1873313359),c=U(c,s,u,l,e[n+15],10,-30611744),l=U(l,c,s,u,e[n+6],15,-1560198380),u=U(u,l,c,s,e[n+13],21,1309151649),s=U(s,u,l,c,e[n+4],6,-145523070),c=U(c,s,u,l,e[n+11],10,-1120210379),l=U(l,c,s,u,e[n+2],15,718787259),u=U(u,l,c,s,e[n+9],21,-343485551),s=K(s,i),u=K(u,r),l=K(l,o),c=K(c,a);return[s,u,l,c]}function X(e){var t,n="",i=32*e.length;for(t=0;t<i;t+=8)n+=String.fromCharCode(e[t>>5]>>>t%32&255);return n}function z(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t<n.length;t+=1)n[t]=0;var i=8*e.length;for(t=0;t<i;t+=8)n[t>>5]|=(255&e.charCodeAt(t/8))<<t%32;return n}function W(e){var t,n,i="";for(n=0;n<e.length;n+=1)t=e.charCodeAt(n),i+="0123456789abcdef".charAt(t>>>4&15)+"0123456789abcdef".charAt(15&t);return i}function G(e){return unescape(encodeURIComponent(e))}function Y(e){return function(e){return X(Z(z(e),8*e.length))}(G(e))}function Q(e,t){return function(e,t){var n,i,r=z(e),o=[],a=[];for(o[15]=a[15]=void 0,r.length>16&&(r=Z(r,8*e.length)),n=0;n<16;n+=1)o[n]=909522486^r[n],a[n]=1549556828^r[n];return i=Z(o.concat(z(t)),512+8*t.length),X(Z(a.concat(i),640))}(G(e),G(t))}var $=function(e,t,n){return t?n?Q(t,e):W(Q(t,e)):n?Y(e):W(Y(e))},ee=o((function e(){var t=this;i(this,e),a(this,"epBh",(function(e,n){if(t._listeners[e])for(var i=t._listeners[e],r=0;r<i.length;r++){(0,i[r])(n)}})),a(this,"registerForEvent",(function(e,n){var i;Ae(n)&&((i=t._listeners[e]?t._listeners[e]:[]).push(n),t._listeners[e]=i)})),a(this,"unregisterFromEvent",(function(e,n){if(t._listeners[e]){for(var i=t._listeners[e],r=[],o=0;o<i.length;o++){var a=i[o];a!==n&&r.push(a)}t._listeners[e]=r}})),a(this,"LeoF",(function(){t._listeners={}})),this._listeners={}})),te=function(e,t){return{name:"visible"===e?"FOREGROUND":"BACKGROUND",time:Ve(t)?Qe(t):0}},ne=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;if(Ne(e)&&et(t))return{name:e,additional_info:t,category:Ce(n)&&Ne(n)?n:void 0,time:Ve(i)?Qe(i):0}},ie=function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return{navigation_id:e,name:t,duration:Ve(n)?Qe(n):0,transition_time:Ve(i)?Qe(i):0}},re={navigation_events:[],app_events:[],system_events:[],user_events:[],chunk_attributes:{},user_attributes:{},session_attributes:{}},oe=function(e){return{sdk_version:301,config_id:"apx",tick_interval:1,chunk_retry_window:1800,sdk_start_time:e}},ae=function(e,n,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return xt.debug("Model : Building the initial state of the Chunk"),{sdk_info:oe(e),session_info:{id:i,launch_time:n,launch_time_string:Re(new Date(n)),startup_time:0,is_background:!1,is_first_session:!1,duration:0,total_duration:0,process_name:"",is_fatal:!1,launch_type:"normal"},app_info:{app_name:"",app_version:"ALL",bundle_id:"",installation_time:xe.getInstance().getInstallationTime(He()),app_mode:"production"},device_info:Ze(window),chunk_meta:{id:i+":"+r,number:r,reporting_times:[]},chunk_details:t(t({},re),{},{user_attributes:{},session_attributes:{}})}},se=o((function e(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,e),a(this,"wIRx",(function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],a=t.window.XMLHttpRequest;xt.debug("Request : POST request with data"),a?t.ytHu(e,n,i,r,o):(xt.error("Request : Unknown browser"),i(403,"Unknown")),xt.debug("Request : Sent request to server")})),a(this,"get",(function(e,n){var i=t.window,r=i.fetch,o=i.XMLHttpRequest;if(r)r(e).then((function(e){try{if(e.ok)return e.json()}catch(e){xt.debug("Request : Error while parsing the response ".concat(e))}return null})).then((function(e){Ce(e)?n(200,e):(xt.error("Request : API request failed. ".concat(JSON.stringify(e))),n(500,{}))})).catch((function(e){xt.error("Request : API request failed. ".concat(e)),n(500,e)}));else if(o){var a=new o;a.open("GET",e,!0),a.onreadystatechange=function(){4===a.readyState&&n(a.status,a.responseText)},a.send()}else xt.error("Request : Unknown browser"),n(403,"Unknown");xt.debug("Request : sent request to server")})),a(this,"ytHu",(function(e,n,i,r,o){var a=new XMLHttpRequest;a.onerror=function(e){xt.error("Request : API request failed. ".concat(e)),i(500,null)},a.open("POST",e,o),a.setRequestHeader("Content-Type","application/json; charset=UTF-8"),Object.keys(null!=r?r:{}).forEach((function(e){a.setRequestHeader(e,r[e])})),a.onreadystatechange=function(){if(4===a.readyState){var r=a.responseText,o=r.match(/Failed to execute 'send' on 'XMLHttpRequest'/);if(!(ke(o)||De(o)||ke(o[0])||De(o[0])||"Failed to execute 'send' on 'XMLHttpRequest'"!==o[0]))return void t.ytHu(e,n,i,!0);try{r=JSON.parse(r)}catch(e){xt.debug("Request : Error while parsing the response ".concat(e))}i(a.status,r)}};try{a.send(JSON.stringify(n))}catch(e){xt.error("Request : API request failed. ".concat(e)),i(500,e)}})),this.window=n})),ue="/chunks?appId=<app-id>&isTestDevice=<test-device>",le="/sdk/<app-id>/enabled-status?platform=web&version=301",ce=g.api_root,de=function(e,t){return ce+e.replace("<app-id>",t)},ge=o((function e(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this,e),a(this,"tOQt",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return null},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){return null};return function(n,i){xt.debug("XHR Response: [".concat(n,"]")),n<400?i&&"APXOR_STATUS_SUCCESS"===i.apxor_status?i.details?e(i.details):e(i):200===n?e(i):t(n,i):t&&Ae(t)&&t(n,i)}})),a(this,"rIhK",(function(e,t){n.makeGetRequest(n.sdkEnabledStatusAPI,e,t)})),a(this,"Hbcg",(function(e,t){n.makeGetRequest(n.configAPI,e,t)})),a(this,"NDqc",(function(e,t,i){n.request.wIRx(n.userInfoAPI,e,n.tOQt(t,i),{})})),a(this,"YVFj",(function(e,t,i){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];xt.debug("Posting chunk"),n.request.wIRx(n.chunksAPI,e,n.tOQt(t,i),{},r)})),a(this,"makeGetRequest",(function(e,t,i){n.request.get(e,n.tOQt(t,i))})),a(this,"makePostRequest",(function(e,t,i,r,o){n.request.wIRx(e,t,n.tOQt(r,o),i)})),this.request=new se(r),this.configAPI=de("/config/<app-id>/web",t),this.chunksAPI=de(ue,t),this.chunksAPI=this.chunksAPI.replace("<test-device>",xe.getInstance().isTestDevice()),this.sdkEnabledStatusAPI=de(le,t),this.userInfoAPI=de("/user?appId=<app-id>",t)})),fe=o((function e(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;i(this,e),a(this,"cnra",-1),a(this,"xrdw",0),a(this,"HpgM",(function(){return t.xrdw})),a(this,"QizG",(function(){return t.cnra})),a(this,"eetP",(function(){t.cnra=-1,t.xrdw=0})),a(this,"jMLq",(function(e){if("FOREGROUND"===e.name){if(-1!==t.cnra){var n=Math.round(Ye(Date.now()-t.cnra));t.xrdw+=n;var i=xe.getInstance().getFromStorage("_apx_sId");if(Ce(i)&&xe.getInstance().getSessionId()!==i){xe.getInstance().fdCw();var r=xe.getInstance().Xsuk(),o=r.total_duration,a=r.duration;t.xrdw=o>a?o-a:0}}}else t.cnra=Date.now(),xe.getInstance().persistToStorage("apx_lbgt",t.cnra)})),xe.getInstance().registerForEvent("SYSTEM_EVENT",this._onSystemEvent),this.xrdw=n,xe.getInstance().persistToStorage("apx_lbgt",this.cnra)})),he=function(){function e(t){var n=this;i(this,e),a(this,"VZsR",!1),a(this,"uOdr",(function(e){var t=!0;try{window[e]?(window[e].setItem("_apx_","apx"),"apx"!==window[e].getItem("_apx_")&&(t=!1),window[e].removeItem("_apx_")):t=!1}catch(e){t=!1}return t||xt.error("Storage : LocalStorage not supported"),t})),a(this,"ForZ",(function(e){xt.error("".concat(n.storageType," Error: "),e)})),a(this,"get",(function(e){try{return n.storage.getItem(e)}catch(t){xt.error("Storage : Error while getting the ".concat(e," from storage - ").concat(t))}return null})),a(this,"PFzt",(function(e){try{return JSON.parse(n.storage.getItem(e))}catch(t){xt.error("Storage : Error while parsing ".concat(e,"'s value from storage - ").concat(t))}return null})),a(this,"set",(function(e,t){try{n.storage.setItem(e,t)}catch(t){xt.error("Storage : Error while setting the ".concat(e,"'s value to storage - ").concat(t))}})),a(this,"wtVY",(function(e){try{n.storage.removeItem(e)}catch(t){xt.error("Storage : Error while removing the ".concat(e," from storage - ").concat(t))}})),a(this,"clear",(function(){try{n.storage.removeItem("_apx_config"),n.storage.removeItem("_apx_ua"),n.storage.removeItem("_apx_lEt"),n.storage.removeItem("_apx_sId"),n.storage.removeItem("_apx_sc"),n.storage.removeItem("apx_id"),n.storage.removeItem("apx_in"),n.storage.removeItem("apx_ver"),n.storage.removeItem("apx_lbgt"),n.storage.removeItem("_apx_cd"),n.storage.removeItem("_apx_od"),n.storage.removeItem("_apx_lt_count"),n.storage.removeItem("_apx_use"),n.storage.removeItem("_apx_scnm"),n.storage.removeItem("_apx_lct"),n.storage.removeItem("_apx_ch"),n.storage.removeItem("_apx_lef"),n.storage.removeItem("_apx_ledt")}catch(e){xt.error("Storage : Error while clearing the storage - ".concat(e))}})),this.VZsR=this.uOdr(t),this.VZsR?(this.storage=window[t],this.storageType=t):(this.storageType=t,this.storage={length:0,getItem:function(){},setItem:function(){},removeItem:function(){},clear:function(){},get:function(){},set:function(){},remove:function(){},getParsed:function(){}})}return o(e,[{key:"isStorageAvailable",value:function(){return this.VZsR}}],[{key:"waitForBrowserStorage",value:function(t){var n=15,i=setInterval((function(){n--,e.isLocalStorageEnabled()||n<=0?(xt.debug("Storage : Local storage available"),clearInterval(i),t()):xt.debug("Storage : Local storage not available yet")}),100)}},{key:"isLocalStorageEnabled",value:function(){try{var e="__apx_storage_test__";window.localStorage.setItem(e,"test");var t=window.localStorage.getItem(e);return window.localStorage.removeItem(e),"test"===t}catch(e){return xt.debug("Browser storage is not enabled yet : ".concat(e)),!1}}}]),e}();var pe=o((function e(){i(this,e)}));a(pe,"isCookieAvailable",(function(){try{var e=(new Date).getTime()+864e5;document.cookie="cookie_set=cookie_value; expires="+e;for(var t=document.cookie.split(";"),n=0;n<t.length;n++){if(-1!==t[n].indexOf("cookie_set"))return document.cookie="cookie_set=cookie_value; expires=Thu, 01 Jan 1970 00:00:01 GMT;",!0}return!1}catch(e){return!1}})),a(pe,"get",(function(e){if(window.document)for(var t=e+"=",n=window.document.cookie.split(";"),i=0;i<n.length;i++){for(var r=n[i];" "===r.charAt(0);)r=r.substring(1,r.length);if(0===r.indexOf(t))return decodeURIComponent(r.substring(t.length,r.length))}return null}));var ve=function(){function e(n){var r=this;i(this,e),a(this,"tACZ",""),a(this,"rJWh",(function(){var e,t=r.storage.get("_apx_config");if(Ce(t))try{t=JSON.parse(ut(r.tACZ,t))}catch(e){t=null}return null!==(e=t)&&void 0!==e?e:g})),a(this,"JfDe",(function(e){r.storage.set("_apx_config",st(r.tACZ,JSON.stringify(e)))})),a(this,"eYZo",(function(e){r.storage.set("apx_id",e)})),a(this,"hVbc",(function(){var e=null;try{e=r.storage.get("apx_id")}catch(e){xt.debug("Datamaager : Can not get user id from storage-"+e)}return e})),a(this,"IxdO",(function(e){return r.storage.set("apx_ver",e)})),a(this,"BShG",(function(){var e=r.storage.get("apx_ver");if(!Ce(e)&&pe.isCookieAvailable()){var t=pe.get("apx_ver");if(Ce(t))return r.storage.set("apx_ver",t),t}return e})),a(this,"JAMB",(function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:h;n===h?r.storage.set(e,t):"session_storage"===n&&r.sessionStorage.set(e,t)})),a(this,"getItem",(function(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:h;if(i===h?t=r.storage.get(e):"session_storage"===i&&(t=r.sessionStorage.get(e)),n){var o=at(t);if(null===o)try{t=JSON.parse(ut(r.tACZ,t))}catch(n){xt.debug("Datamanager : ".concat(e," - value not found in storage")),t=null}else t=o}return xt.debug("Datamanager : ".concat(e,"'s value from storage is ").concat(JSON.stringify(t))),t})),a(this,"wEKn",(function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:h,o=r.getItem(e,n,i);return Ce(o)?o:(xt.debug("Datamanager : ".concat(e,"'s value is not defined. Returning default-").concat(JSON.stringify(t))),t)})),a(this,"tBMX",(function(){r.storage.clear(),r.sessionStorage.clear()})),a(this,"resetUserProperties",(function(){xt.debug("Datamanager : Removing the user attributes form the storage"),r.storage.wtVY("_apx_ua")})),a(this,"uGge",(function(e){xt.debug("DataManager : Setting the installation time to ".concat(e)),r.storage.set("apx_in",e)})),a(this,"getInstallationTime",(function(e){var t=r.storage.get("apx_in");return Ce(t)?(xt.debug("Datamanager : Stored installation time ".concat(t)),Number(t)):(xt.debug("Datamanager : Stored installation time not found. Persisting and returning the default time ".concat(e)),r.uGge(e),e)})),a(this,"DtNg",(function(e){xt.debug("Datamanager : Persisting the old session chunk to the storage"),r.storage.set("_apx_od",st(r.tACZ,JSON.stringify(e)))})),a(this,"lSFO",(function(){var e;xt.debug("Datamanager : Getting the old session chunk details form the storage");var t=r.storage.get("_apx_od"),n=at(t);if(null===n)try{t=JSON.parse(ut(r.tACZ,t))}catch(e){t=null}else t=n;return null!==(e=t)&&void 0!==e?e:[]})),a(this,"PNZb",(function(){xt.debug("Datamanager : Removing the old session chunk details form the storage"),r.storage.wtVY("_apx_od")})),a(this,"jRHc",(function(){return r.getItem("_apx_use",!0)})),a(this,"lfkj",(function(e){xt.debug("Datamanager : Persisting the old session chunk details to the storage"),r.storage.set("_apx_use",st(r.tACZ,JSON.stringify(e)))})),a(this,"kAFz",(function(){xt.debug("Datamanager : Removing the old session chunk details form the storage"),r.storage.wtVY("_apx_use")})),a(this,"PfAT",(function(){xt.debug("Datamanager : Getting the session chunknumber map");var e=r.getItem("_apx_scnm",!0);return Ce(e)||(e={}),e})),a(this,"XSuq",(function(e){xt.debug("Datamanager : Persisting the new session chunknumber map");var t=st(r.tACZ,JSON.stringify(e));r.JAMB("_apx_scnm",t)})),a(this,"BHzB",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Date.now(),n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now(),i=arguments.length>2?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:3600;xt.debug("Datamanager : Creating a new chunk");var a,s=!1,u=Number(r.storage.get("_apx_lEt"))||0,l=Date.now(),c=Math.round(Ye(l-u)),d=r.IvbP();if((c>o||Oe(d))&&(s=!0),s)xt.debug("Datamanager : This is a new session. Creating a new chunk"),a=ae(e,n,i);else{xt.debug("Datamanager : This is an old session. Updating the existing chunk");var g=d.chunk_meta.number,f=d.session_info.id,h=g+1;(a=t({},d)).chunk_meta=t(t({},a.chunk_meta),{},{number:h,id:f+":"+h,reporting_times:[Date.now()]}),a.chunk_details=t({},re)}return{is_new_session:s,chunk:a}})),a(this,"VAuU",(function(){xt.debug("Datamanager : Current chunk removed from storage"),r.storage.wtVY("_apx_cd")})),a(this,"SKeQ",(function(e){xt.debug("Datamanager : Persisting the Current chunk to storage"),_t(e),r.storage.set("_apx_cd",st(r.tACZ,JSON.stringify(e)))})),a(this,"IvbP",(function(){return r.getItem("_apx_cd",!0)})),this.tACZ=n,this.storage=new he("localStorage"),this.sessionStorage=new he("sessionStorage"),xt.debug("DataManager : Initialized")}return o(e,[{key:"getltCount",value:function(e){try{var t=this.storage.get("_apx_lt_count");if(t){var n=ut(this.tACZ,t);return JSON.parse(n)[e.replace("'","").replace("’","")]}}catch(t){xt.error("Datamanager : Error gettting the LT Count for the event -"+e)}return 0}},{key:"updateRetainedDayCount",value:function(e){xt.debug("Datamanager : Re-calculating and updating the retention day");var t=this.getItem("apx_in"),n=Math.abs(t-e)/36e5,i=Math.floor(n/24);this.JAMB("apx_retained_days",i)}}]),e}(),_e=["scroll","touchmove"],me=o((function e(){var t=this,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];i(this,e),a(this,"lqaf",!0),a(this,"iZrg",(function(){xt.debug("Registering for System Event ","visibilitychange");var e=function(){var e=xe.getInstance(),n=e.getSDKRunningTimeInSec(),i="visible"===window.document.visibilityState,r=te(window.document.visibilityState,n);if(i?(e.AwLt(!1),t.cnra>-1&&(e.kNGe((function(){e.dispatchEvent("SYSTEM_EVENT",r)})),r.background_time=Qe(Ye(Date.now()-t.cnra)))):(e.AwLt(!0),e.vKjo(),t.cnra=Date.now(),e.dispatchEvent("SYSTEM_EVENT",r)),i){var o=e.getUserAttributes().apx_browser;!t.lqaf||-1!==o.indexOf("Mobile Safari")&&-1!==o.indexOf("Safari")||(t.lqaf=!1)}else e.DhQR()};qe(document,"visibilitychange",e),t._handlers.push(t.dtiO("visibilitychange",e))})),a(this,"GWAr",(function(){t._handlers.forEach((function(e){var t=e.type,n=e.handler;xt.debug("Unregistering from event type ",t),_e.includes(t)?Me(window.document,t,n):Me(document,t,n)})),t._handlers=[],t._scrollEvents=[],t._scrollData={}})),a(this,"HpSU",(function(){return[]})),a(this,"dtiO",(function(e,t){return{type:e,handler:t}})),this.cnra=-1,this._handlers=[],this._scrollEvents=[],this._scrollData={},this.lqaf=n,this.iZrg()})),be=o((function e(){var t=this;i(this,e),a(this,"kCDP",!0),a(this,"tACZ",""),a(this,"dKGR",0),a(this,"Cabq",1),a(this,"initialize",(function(e,n){t.tACZ=n;var i=e.validate_hash,r=void 0===i||i,o=e.cs_ht_time,a=void 0===o?-1:o;t.kCDP=r,t.configsHashThrottleTime=a,xe.getInstance().registerForEvent("APP_EVENT",(function(e){t.QFpv(e.name)}))})),a(this,"fetchConfiguration",(function(e,n,i,r){if(Ae(r))if(t.kCDP){var o=xe.getInstance();if(t.configsHashThrottleTime>0){var a=o.getValueOrDefault(e+"_lcfht",-1);if(a>0)if(Math.abs(Date.now()-a)<t.configsHashThrottleTime)return void t.NBET(e,r)}o.persistToStorage(e+"_lcfht",Date.now());var s=t.ngeV(),u={pid_mid:[]},l=s[e];if(Ce(l)){Array.isArray(l)||(l=[l]);var c=[];l.forEach((function(e){var t=e.pid+"_"+e.mid;c.includes(t)||c.push(t)})),c.length>0&&(u.pid_mid=c.join(","))}else l=[];var d=o.getUserAttributes().custom_user_id,g=void 0===d?null:d;g&&(n+="&customerId="+g),o.makePostRequest(n,u,{"Content-Type":"application/json"},(function(n){t.eJmJ(n,e,i,{configs:l,syncData:s},r)}),(function(){xt.error("Failed to fetch"),r(e,{configs:l})}))}else t.YdJZ(e,i,[],r)})),a(this,"ngeV",(function(){var e=xe.getInstance().getFromStorage("_apx_sc");return Ce(e)?JSON.parse((new TextDecoder).decode(dt(ut(xe.getInstance().getSiteId(),e)))):{}})),a(this,"NBET",(function(e,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=i;i||(r=t.ngeV());var o=r[e];Ce(o)&&(Array.isArray(o)||(o=[o]),xt.debug("Reading from storage"),n(e,{configs:o}))})),a(this,"eJmJ",(function(e,n,i,r,o){var a=e.pull,s=void 0===a?[]:a,u=e.drop,l=void 0===u?[]:u,c=r.configs,d=r.syncData,g=JSON.parse(xe.getInstance().getFromStorage("apx_termination_ID")),f=[];l.length>0||s.length>0?(l.forEach((function(e){var t=Ke(e);if(Le(t)){var n=JSON.parse(xe.getInstance().getFromStorage("_apx_never_show_ids"));n=n.filter((function(e){return e!==t})),xe.getInstance().persistToStorage("_apx_never_show_ids",JSON.stringify(n))}})),s.forEach((function(e){var n=Ke(e);if(mt(e,t.tACZ),Le(n)){var i=JSON.parse(xe.getInstance().getFromStorage("_apx_never_show_ids"));i=i.filter((function(e){return e!==n})),xe.getInstance().persistToStorage("_apx_never_show_ids",JSON.stringify(i))}})),c.forEach((function(e){l.includes(e.pid)||s.includes(e.pid)||f.push(e),l.includes(e.pid)&&null!==g&&null!=g&&g[e._id]&&(delete g[e._id],xe.getInstance().persistToStorage("apx_termination_ID",JSON.stringify(g)))})),d[n]=f,xe.getInstance().persistToStorage("_apx_sc",st(t.tACZ,gt((new TextEncoder).encode(JSON.stringify(d)))))):(xt.debug("Nothing to delete",n),f=c),s.length>0?(s.forEach((function(e){i+="&pids="+e})),t.YdJZ(n,i,f,o)):(xt.debug("Nothing to pull",n),o(n,{configs:f}))})),a(this,"YdJZ",(function(e,n,i,r){xe.getInstance().makeGetRequest(n,(function(n){if(Ce(n.configs)&&Array.isArray(n.configs)&&0==n.configs.length)r("",{configs:[]});else if(Ce(n.configs)&&Array.isArray(n.configs)){n.configs.forEach((function(n){var i,r,o,a,s,u=e===t.Cabq?"survey":"campaign";null===(i=xe.getInstance())||void 0===i||i.myRY("apx_config_received",{apx_nudge_type:e===t.Cabq?"survey":"campaign",apx_nudge_id:null==n?void 0:n._id,apx_nudge_name:null==n||null===(r=n.meta)||void 0===r?void 0:r.name,apx_variant_code:null!=n&&null!==(o=n.meta)&&void 0!==o&&o.isExperiment||null!=n&&null!==(a=n.meta)&&void 0!==a&&a.only_context?null==n||null===(s=n.meta)||void 0===s||null===(s=s.attr)||void 0===s?void 0:s.apx_variant_code:"TG"},void 0,!1,"apxor",u)}));var o=t.ngeV(),a=[].concat(u(i),u(n.configs));o[e]=a,xe.getInstance().persistToStorage("_apx_sc",st(t.tACZ,gt((new TextEncoder).encode(JSON.stringify(o))))),r(e,{configs:a})}}),(function(){r(e,{configs:[]})}))})),a(this,"klVb",(function(e){t.QFpv(e)})),a(this,"QFpv",(function(e){var n=t.ngeV();if(Ce(n.d)||(n.d={}),JSON.stringify(n.d).length>2097152)xt.error("Sync : Reached maximum limit. Can't store further");else{var i=0;Ce(n.d[e])&&(i=n.d[e]),i+=1,n.d[e]=i,xe.getInstance().persistToStorage("_apx_sc",st(t.tACZ,gt((new TextEncoder).encode(JSON.stringify(n)))))}})),a(this,"getEventCount",(function(e){var n=t.ngeV();return Ce(n.d)&&Ce(n.d[e])?n.d[e]:0}))})),ye=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return function(){xt.error("".concat(e,": Apxor SDK not initialised."))}},we={reportChunkOnVisibilityChange:ye("vKjo"),logAppEvent:ye("myRY"),logClientEvent:ye("logClientEvent"),logPageView:ye("logPageView"),setUserId:ye("setUserId"),setUserProperties:ye("setUserProperties"),setSessionProperties:ye("setSessionProperties"),setAppVersion:ye("setAppVersion"),getClientId:ye("getClientId"),getSessionId:ye("getSessionId"),startSession:ye("startSession"),endSession:ye("endSession"),flattenJSON:ye("flattenJSON"),setRedirectionHandler:ye("setRedirectionHandler"),setInitFlag:ye("setInitFlag"),dispatchValidationEvent:ye("dispatchValidationEvent")},xe=function(){function e(){var n=this;return i(this,e),a(this,"OVEi",{}),a(this,"JDLq",!1),a(this,"SJot",{}),a(this,"Nefe",{}),a(this,"LfeM",{}),a(this,"XypJ",{}),a(this,"bdKK",{}),a(this,"ZngE",{}),a(this,"FiHr",{}),a(this,"IXuB",1),a(this,"JBgz",null),a(this,"yOdy",!1),a(this,"ddNH",!1),a(this,"jIVe",{}),a(this,"XEdy",null),a(this,"ozmT",{}),a(this,"jvtL",{}),a(this,"hMaX",{}),a(this,"FWXZ",3600),a(this,"QrrS",20),a(this,"BKmE",-1),a(this,"tSKb",2e4),a(this,"pmqY",-1),a(this,"ZpVM",10),a(this,"IMOq",!1),a(this,"DlHX",!1),a(this,"FWDp",-1),a(this,"hJes",!1),a(this,"myVG",!0),a(this,"clientEvents",[]),a(this,"aZBa",[]),a(this,"zyxH",[]),a(this,"unAk",[]),a(this,"IGiu",{}),a(this,"MbyK",0),a(this,"TSTs",null),a(this,"utkn",[]),a(this,"yGlC",null),a(this,"TXKB",null),a(this,"OxEI",!1),a(this,"qAbf",!1),a(this,"UzaV",{}),a(this,"initWaitTime",1500),a(this,"version",""),a(this,"IPHr",""),a(this,"gXMj",""),a(this,"sessionStartTime",null),a(this,"sessionId",""),a(this,"wfoi",{}),a(this,"cMAZ",!1),a(this,"yYSu",(function(e){var t=n.config.plugins;if(Ce(t)&&Ce(t.length))for(var i=0;i<t.length;i++){var r=t[i];try{var o;null===(o=window[r])||void 0===o||o.init(e),xt.debug("Controller : Initialized plugin ".concat(r))}catch(e){xt.error("Controller : Failed to initialize plugin ".concat(r," with error ").concat(e))}}})),a(this,"initialize",(function(e,t,i,r,o,a){if(!n.JDLq){var s=function(){xt.debug("Controller : On Site enabled in config"),n.qshh(u,a)},u=function(e){n.gXMj=e,xt.debug("Controller : On config hash fetch"),n.wqdQ(e,l)},l=function(){xt.info("Controller : Waiting for resources completed"),n.Xygi(),n.PXEm(),n.lJmT(),n.IPHr=n.dCQL(),n.Plxh(),n.TbVE(),n.KBJe(),n.Reeu(),n.vlhN(),n.QNBW(),n.zTZU(),n.Uogu(),n.VPpO(n.gXMj);var e=n.scFA();n.jvtL=new fe(e),n.awMW(),n.kNGe(c)},c=function(){n.yOdy=!0,n.JDLq=!0;var e=n.fdCw();n.jIVe.SKeQ(e),n.yYSu(d)},d=function(){var e,t;(n.Zbvb(n.window.document.visibilityState),n.newSession&&(n.sessionStartTime=Date.now(),n.myRY("apx_app_opened",{time:Re(new Date)},void 0,!1,"apxor",""),n.PHjp()),n.logPageView(n.window.location.pathname),n.eEqB(),n.Nrov(),o(),n.setSessionProperties({apx_rtm_version:r.ApxorRTM._rtm_version}),null!==(e=r.ApxorRTM)&&void 0!==e&&e.isBadgePresent)&&(null===(t=r.ApxorRTM)||void 0===t||t.badgesLists.forEach((function(e){var t;n.isBadgeTriggerSatisfied(e)&&!document.getElementById("apxor-badge-container-".concat("-".concat(e).replaceAll(" ","").replace(/[^\w\s]/gi,"")))&&(null===(t=r.ApxorRTM)||void 0===t||null===(t=t.ceInstance)||void 0===t||t.notifyEventListener(ne("apxor-badge-container-".concat("-".concat(e).replaceAll(" ","").replace(/[^\w\s]/gi,"")),{},void 0,n.getTimeElapsedInSession())))})))};n.tCpD((function(){xt.debug("Controller : Wait for browser storage completed."),n.akEc(e,t,i,r),n.DMUe(),n.HtXV(),n.hMaX.initialize(n.config,n.siteId),n.ItTa(s,a)}))}})),a(this,"getSiteId",(function(){return n.siteId})),a(this,"setRedirectionHandler",(function(e){n.JDLq?n.TSTs?n.TSTs=e:(n.TSTs=e,n.registerForEvent("CLIENT_EVENT",n.eoHP)):we.setRedirectionHandler()})),a(this,"eoHP",(function(e){e&&"REDIRECT"===e.name&&n.TSTs(e.additional_info.url)})),a(this,"makePostRequest",(function(e,t,i,r,o){n._api.makePostRequest(e,t,i,r,o)})),a(this,"getDevInfo",(function(){return n.Nefe})),a(this,"getListOfEventsLogged",(function(){return n.UzaV})),a(this,"DwKF",(function(e,i){n.UzaV[e]=n.UzaV[e]||{first_logged_time:(new Date).toISOString()},n.UzaV[e]=t(t(t({},n.UzaV[e]),i),{},{latest_logged_time:(new Date).toISOString()}),n.persistToStorage("_apx_evl",st(n.siteId,JSON.stringify(n.UzaV)))})),a(this,"getInstallationTime",(function(){return n.jIVe.getInstallationTime(n.startTime)})),a(this,"tCpD",(function(e){xt.debug("Controller : Checking if the browsers localstorage is available."),he.waitForBrowserStorage(e)})),a(this,"akEc",(function(e,t,i,r){xt.debug("Controller : Initializing the state variables"),n.window=r,n.startTime=t,n.siteId=e,n.clientConfig=i||{},n.initWaitTime=n.clientConfig.sdk_init_wait?1e3*n.clientConfig.sdk_init_wait:2e3,n.jIVe=new ve(n.siteId),n._api=new ge(n.siteId,n.window),n.OVEi=new ee,n.hMaX=new be,n.LfeM=oe(n.startTime),n.sessionStartTime=parseInt(n.jIVe.wEKn("apx_sst",t)),xt.debug("Controller : session start time is ".concat(n.sessionStartTime)),xt.debug("Controller : SDK start time is ".concat(n.startTime)),n.sessionId=n.getFromStorage("_apx_sId")})),a(this,"PXEm",(function(){xt.debug("Controller : Initializing the LT Count ");try{var e=n.getFromStorage("_apx_lt_count");if(e)n.wfoi=JSON.parse((new TextDecoder).decode(dt(ut(n.siteId,e))));else{n.wfoi={};var t=st(n.siteId,gt((new TextEncoder).encode(JSON.stringify(n.wfoi))));n.persistToStorage("_apx_lt_count",t)}}catch(e){xt.error("Controller : LT Count object parsing failed ".concat(e))}})),a(this,"Xygi",(function(){var e=new URLSearchParams(location.search),t=e.get("_a")||e.get("_p")||e.get("_x")||e.get("_o")||e.get("_r");if(t||(t=n.getFromStorage("_apxor_url_param")),t)try{xt.debug("Controller : Initialising in WYSIWYG mode");var i=ut(n.siteId,t),r=i=JSON.parse(i),o=r.app_id,a=r.expiry,s=Date.now();if(o===n.siteId&&s<=a){var u=new Date(a+6e4).toUTCString(),l=btoa("_apx_ew");document.cookie="_apx_ewc=".concat(l,"; expires=").concat(u),i.expiry=i.expiry+6e4,n.persistToStorage("_apx_ew",i,!0),xt.debug("Controller : _apx_ewc cookie set")}e.delete("_a"),e.delete("_p"),e.delete("_x"),e.delete("_o"),e.delete("_r");var c=location.pathname,d=e.toString();""!==d&&(c+="?"+d),n.window.history.replaceState({},document.title,c),xt.debug("Controller : Query params reset after removing dashboard embedded params")}catch(e){xt.error("Controller : Error while setting the WYSIWYG cookie ".concat(e))}else xt.debug("Controller : Not in WYSIWYG mode")})),a(this,"DMUe",(function(){xt.debug("Controller : Setting the config");var e=n.jIVe.rJWh();n.VobT(e)})),a(this,"VobT",(function(e){n.config=t(t({},e),n.clientConfig),xt.debug("Controller : New config and client configs Configs merged")})),a(this,"HtXV",(function(){var e,t,i,r=n.config,o=r.version,a=void 0===o?"":o,s=r.bulk_upload,u=void 0===s||s,l=r.events_upload_time,c=r.idle_time_out,d=void 0===c?1800:c,g=r.events,f=void 0===g?{}:g,h=r.max_chunk_event_count,p=void 0===h?20:h,v=r.retry_time,_=r.max_sessions_in_storage,m=void 0===_?-1:_;n.version=n.IWwr(a),n.myVG=u,n.hJes=l>0,n.FWXZ=Ve(d)?d:1800,n.aZBa=null!==(e=f.stop)&&void 0!==e?e:[],n.zyxH=null!==(t=f.action)&&void 0!==t?t:[],n.unAk=null!==(i=f.app)&&void 0!==i?i:[],n.QrrS=Ce(p)&&Ve(p)?p:20,n.BKmE=Ce(l)&&Ve(l)&&l>=1e3?l:-1,n.pmqY=Ce(v)&&Ve(v)&&v>=1e3?v:-1,n.ZpVM=Ve(m)&&m>0?m:-1})),a(this,"IWwr",(function(e){var t;if(Ce(e))t=e,n.jIVe.IxdO(t);else{var i=n.jIVe.BShG();t=Ce(i)?i:""}return t})),a(this,"ItTa",(function(e,t){if(xt.debug("Controller : Checking if the Site is enabled existing config"),!n.config.enable)return xt.debug("Controller : Site is disabled. Can't initialise"),n.VPpO(""),n.KBJe(),void t();e()})),a(this,"qshh",(function(e,t){var i=n.jIVe.rJWh(),r=n.jIVe.wEKn("_apx_ledt",-1),o=i.ed_t_time;if(o>0&&r>0&&Math.abs(r-Date.now())<60*o*1e3)return xt.debug("Controller : Reinitializing with in the throttling time."),n.jIVe.wEKn("_apx_lef",!0)?void e(n.jIVe.wEKn("_apx_ch","")):(xt.debug("Controller : Site is not enabled from the last update. Can't initalise now. Recheck will happen after throttling time"),void t());n.YNDj(e,t)})),a(this,"YNDj",(function(e,t){xt.debug("Controller : Getting the site enabled status from the server"),n.persistToStorage("_apx_ledt",Date.now()),n._api.rIhK((function(i){var r=i.enabled,o=i.hash;n.persistToStorage("_apx_lef",r),r?(xt.debug("Controller : Site is enabled"),e(o)):(xt.debug("Controller : Site is disabled. Can't initialise the SDK"),n.JDLq=!1,n.yOdy=!1,n.ptjG(),t())}),(function(e){xt.error("Controller : enabled-status API failed ".concat(e))}))})),a(this,"ptjG",(function(){xt.debug("Controller: Stopping the SDK");try{var e,t;n.yOdy=!1,n.JDLq=!1,n.IMOq=!1,null===(e=n.OVEi)||void 0===e||e.LeoF(),null===(t=n.ozmT)||void 0===t||t.GWAr()}catch(e){xt.error("Controller : Failed to stop the SDK ".concat(e))}})),a(this,"wqdQ",(function(e,t){xt.debug("Controller: Waiting ".concat(n.initWaitTime,"ms for all the resource loading to finish")),setTimeout((function(){t(e)}),n.initWaitTime)})),a(this,"dCQL",(function(){var e=n.jIVe.hVbc();if(!Ce(e)){xt.debug("Controller : Device id not found in localstorage");var t=n.config.client_id;Ce(t)&&""!==t?(xt.debug("Controller : client id from clientconfig is the deviceid"),e=t):(xt.debug("Controller : Generated a new device id. This is a new device now"),e=Be()),n.dGCO(e)}return xt.debug("Controller : Device id is ".concat(e)),n.IPHr=e,e})),a(this,"dGCO",(function(e){n.jIVe.tBMX(),n.jIVe.eYZo(e),n.jIVe.uGge(Date.now()),n.XypJ=t(t({},n.XypJ),{},{is_first_session:!0}),n.DlHX=!0})),a(this,"zTZU",(function(){xt.debug("Controller : Setting the session state for session if ".concat(n.sessionId)),n.sessionId||(n.newSession=!0,n.sessionId=Be(),n.persistToStorage("_apx_sId",n.sessionId),n.persistToStorage("apx_sst",n.sessionStartTime))})),a(this,"Plxh",(function(){var e=Ze(n.window),t=e.device,i=e.os,r=e.browser_version,o=e.browser,a=e.dimensions,s=e.dpi,u=e.dimensions_in_pixels;n.Nefe=function(e,t,n,i,r,o,a,s){return{id:e,hardware_model:t,dimensions:n,os_version:i,platform:"web",dpi:r,dimensions_in_pixels:o,browser:a,browser_version:s}}(n.IPHr,t,a,i,s,u,o,r)})),a(this,"TbVE",(function(){xt.debug("Controller : Setting the default User attributes");var e=t({},n.Nefe),i=Xe(n.window,e);n.bdKK=t(t({},n.bdKK),i)})),a(this,"QNBW",(function(){xt.debug("Controller : Setting the default session attributes");var e=ze(n.window);n.ZngE=t(t({},n.ZngE),e)})),a(this,"Reeu",(function(){xt.debug("Controller : Merging the stored and default user attributes");var e=n.getFromStorage("_apx_ua",!0);if(Ce(e)){var i,r=at(e);if(null===r)try{r=JSON.parse(ut(n.siteId,e))}catch(e){r={}}n.bdKK=t(t({},null!==(i=r)&&void 0!==i?i:{}),n.bdKK)}})),a(this,"vlhN",(function(){var e=n.getFromStorage("_apx_evl",!0);if(Ce(e)){var i,r=at(e);if(null===r)try{r=JSON.parse(ut(n.siteId,e))}catch(e){r={}}n.UzaV=t({},null!==(i=r)&&void 0!==i?i:{})}})),a(this,"Uogu",(function(){n.FiHr=t(t({},re),{},{user_attributes:t({},n.bdKK),session_attributes:t({},n.ZngE)}),n.jIVe.lfkj(n.FiHr)})),a(this,"kNGe",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};xt.debug("Controller : Sending the old chunk to the server");var i=n.jIVe.lSFO();if(Ce(i)){var r,o,a,s,u,l,c=t({},n.FiHr);if(n.FiHr=t({},i.chunk_details)||{},(null===(r=n.FiHr)||void 0===r||null===(r=r.app_events)||void 0===r?void 0:r.length)>0||n.rEXN(),!((null===(o=n.FiHr)||void 0===o||null===(o=o.app_events)||void 0===o?void 0:o.length)>0))return n.FiHr=t({},c),void e();var d=null!==(a=null===(s=i=t(t({},i),{},{chunk_details:t({},n.FiHr)}))||void 0===s||null===(s=s.session_info)||void 0===s?void 0:s.id)&&void 0!==a?a:"1",g=null!==(u=null===(l=i)||void 0===l||null===(l=l.chunk_meta)||void 0===l?void 0:l.number)&&void 0!==u?u:1;n.jIVe.SKeQ(i),n._api.YVFj(i,(function(){n.iBCs(d,g+1),xt.debug("Controller : Old chunk reporting successful."),n.jIVe.PNZb(),n.jIVe.kAFz(),n.Uogu(),n.RJtR(),e()}),(function(){xt.debug("Controller : Old chunk reporting failed."),e()}))}else e()})),a(this,"rEXN",(function(){var e=n.jIVe.jRHc();if(Ce(e)){var t=e.app_events,i=e.navigation_events,r=e.system_events,o=e.user_events;n.FiHr.app_events=[].concat(u(n.FiHr.app_events||[]),u(t)),n.FiHr.navigation_events=[].concat(u(n.FiHr.navigation_events||[]),u(i)),n.FiHr.system_events=[].concat(u(n.FiHr.system_events||[]),u(r)),n.FiHr.user_events=[].concat(u(n.FiHr.user_events||[]),u(o)),n.jIVe.kAFz()}})),a(this,"iBCs",(function(e,t){var i=n.jIVe.PfAT();i[e]=t,n.jIVe.XSuq(i),n.IXuB=t})),a(this,"RJtR",(function(){var e=n.fdCw();return n.jIVe.SKeQ(e),e})),a(this,"fdCw",(function(){var e=Ce(n.config.name)?n.config.name:"",i=Ce(n.config.domain)?n.config.domain:"",r=n.jIVe.BHzB(n.startTime,n.sessionStartTime,n.sessionId,n.FWXZ),o=r.chunk,a=o.session_info,s=o.app_info,u=o.sdk_info,l=o.chunk_details,c=o.chunk_meta,d=l.session_attributes,g=l.user_attributes;return n.XypJ=t(t({},n.XypJ),a),n.XypJ.is_first_session=n.DlHX,n.LfeM=u,n.SJot=t(t({},s),{},{app_name:e,bundle_id:i,app_version:""+n.version}),n.IXuB=c.number,n.bdKK=t(t({},n.bdKK),g),n.ZngE=t(t({},n.ZngE),d),n.FiHr=l,n.rEXN(),n.newSession=r.is_new_session,n.newSession||n.XakL(o),{sdk_info:n.LfeM,session_info:n.XypJ,app_info:n.SJot,device_info:n.Nefe,chunk_details:l,chunk_meta:c}})),a(this,"XakL",(function(e){var t=e.session_info.id;t&&(n.sessionId=t,n.persistToStorage("_apx_sId",n.sessionId))})),a(this,"scFA",(function(){var e=n.XypJ,t=e.total_duration,i=e.duration;return t>i?t-i:0})),a(this,"VPpO",(function(e){if(xt.debug("Controller : Fetch a new config"),n.RNVC(e)){var t=n.config.sct_time,i=n.jIVe.wEKn("_apx_lct",-1);if(t>0&&i>0)if(Math.abs(Date.now()-i)<t)return void xt.debug("Controller : No need to fetch config. Did not pass the throttle time");n.persistToStorage("_apx_lct",Date.now()),n._api.Hbcg((function(e){var t;xt.debug("Controller : New config fetched"),n.jIVe.JfDe(e),n.persistToStorage("_apx_ch",null!==(t=e.hash)&&void 0!==t?t:$(e)),n.VobT(e),n.lJmT()}),(function(e){0!==e&&xt.error("Controller : Failed to fetch config")}))}else xt.debug("Controller : No need to fetch config. No change in hash")})),a(this,"KBJe",(function(){xt.debug("Controller : Posting user info");var e=n.LfeM.sdk_version,t={sdk_version:JSON.stringify(e),app_info:n.SJot,device_info:n.Nefe,user_attributes:n.bdKK},i=$(t),r=n.jIVe.wEKn("_apx_uih","");i!==r?n._api.NDqc(t,(function(){xt.debug("Controller : Posted user info. Persisting the hash to localstorage"),n.persistToStorage("_apx_uih",i)})):xt.debug("Controller : No need to post user info. No change in it")})),a(this,"RNVC",(function(e){return""===e||n.jIVe.wEKn("_apx_ch","")!==e})),a(this,"Zbvb",(function(e){xt.debug("Controller : Dispatching SYSTEM_EVENT");var t=te(e,n.getTimeElapsedInSession());n.dispatchEvent("SYSTEM_EVENT",t)})),a(this,"PHjp",(function(){xt.debug("Controller : Resetting the session frequncy of all the campaigns to 0");var e={};try{var t=n.getFromStorage("qe_state");Ce(t)&&(e=JSON.parse(ut(n.siteId,t))),Object.entries(e).forEach((function(t){var n=s(t,1)[0];return e[n].SESSION=0}))}catch(t){e={},xt.error("Controller : Can't reset campaign limits:".concat(t))}n.persistToStorage("qe_state",e,!0),n.window.ApxorRTM.resetFrequencyCounts()})),a(this,"awMW",(function(){xt.debug("Registering a handler for the system events"),Je(n.window,(function(){n.ddNH||(n.ICWb(),n.ozmT=new me(!1),n.ddNH=!0)}))})),a(this,"ICWb",(function(){var e=!1;je(window,(function(){(xt.debug("Controller : Executing before unload"),e)||n.yOdy&&(e=!0,"visible"===window.document.visibilityState&&(n.umWO(!0),n.Zbvb("hidden")),clearInterval(n.yGlC),clearInterval(n.TXKB),n.myVG&&n.jIVe.lfkj(n.FiHr),n.ozmT.GWAr())}))})),a(this,"Nrov",(function(){xt.debug("Controller : Registering the handlers for chunk reporting"),clearInterval(n.TXKB),n.TXKB=setInterval((function(){n.eEqB()}),n.tSKb),n.hJes&&(clearInterval(n.yGlC),n.yGlC=setInterval((function(){n.nDAd()}),n.BKmE))})),a(this,"eEqB",(function(){var e=n.FiHr,t=e.app_events,i=e.navigation_events;t.length+i.length>0&&!n.OxEI&&n.xOkx()})),a(this,"nDAd",(function(){var e=n.FiHr,t=e.app_events,i=e.navigation_events,r=t.length+i.length;(!n.myVG&&r>0||n.myVG&&r>=n.QrrS)&&n.xOkx()})),a(this,"xOkx",(function(){xt.debug("Controller : Preparing and reporting chunk");var e=n.ESaT(n.FiHr);n.nfPg(e,!1)})),a(this,"ESaT",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};xt.debug("Controller : Preparing chunk"),n.lHAn();var i={id:n.sessionId+":"+n.IXuB,number:n.IXuB,reporting_times:[Date.now()]};return e=t(t({},e),{},{user_attributes:n.bdKK,session_attributes:n.ZngE}),{sdk_info:n.LfeM,session_info:n.XypJ,app_info:n.SJot,device_info:n.Nefe,chunk_meta:i,chunk_details:e}})),a(this,"lHAn",(function(){xt.debug("Controller : Updating the foreground time");var e=n.getSDKRunningTimeInSec(),i=e;e-=n.jvtL.HpgM(),n.XypJ=t(t({},n.XypJ),{},{duration:Qe(e),total_duration:Qe(i)})})),a(this,"nfPg",(function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){};if(xt.debug("Controller : Reporting chunk"),n.IMOq)n.cMAZ=!0;else if(n.IMOq||n.pmqY>0&&-1!==n.FWDp&&Date.now()-n.FWDp<n.pmqY)n.Uogu();else{var r=e.chunk_details,o=r.app_events,a=r.system_events,s=r.navigation_events,u=r.user_events;if(o.length<1&&a.length<1&&s.length<1&&u.length<1)return xt.debug("Controller : Chunk not sent. No events in the chunk"),n.IMOq=!1,void i();n.IMOq=!0,n.iBCs(n.XypJ.id,n.IXuB+1),n.jIVe.kAFz(),n.jIVe.PNZb(),n.Uogu(),t?(n.IMOq=!1,n.jIVe.DtNg(e),i()):(n.jIVe.SKeQ(e),n._api.YVFj(e,(function(){if(xt.debug("Controller : Chunk successfully sent"),n.IMOq=!1,n.FWDp=-1,i(),n.cMAZ){n.cMAZ=!1;var e=n.ESaT(n.FiHr);n.nfPg(e)}}),(function(t){xt.debug("Controller : Chunk sending failed"),0!==t&&(n.IMOq=!1,t>=500&&(n.FWDp=Date.now()),413!==t&&417!==t&&n.jIVe.DtNg(e),i())})))}})),a(this,"setUserId",(function(e){n.JDLq?n.yOdy?De(e)||(xt.debug("Controller : User id set"),n.setUserProperties({custom_user_id:e})):xt.warn("Apxor SDK is not running"):we.setUserId()})),a(this,"setUserProperties",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i={};if(n.JDLq)if(n.yOdy){if(Object.keys(e).length>0){if(i=ht(e,n.bdKK),n.isTestDevice()&&Object.keys(i).length>0){var r=Object.keys(i);r.forEach((function(e){n.myRY("apx_property_updated",{apx_property_type:"user",apx_property_name:e,apx_property_old_value:n.bdKK[e]||"",apx_property_updated_value:i[e]},void 0,!1,"apxor","")}))}n.bdKK=t(t({},n.bdKK),e);try{xt.debug("Controller : User properties set"),n.persistToStorage("_apx_ua",st(n.siteId,JSON.stringify(n.bdKK)))}catch(e){xt.debug("Controller : Error while setting the use properties ".concat(e))}}}else xt.warn("Apxor SDK is not running");else we.setUserProperties()})),a(this,"setSessionProperties",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i={};if(n.JDLq)if(n.yOdy){if(Object.keys(e).length>0){if(xt.debug("Controller : Session properties set"),i=ht(e,n.ZngE),n.isTestDevice()&&Object.keys(i).length>0){var r=Object.keys(i);r.forEach((function(e){n.myRY("apx_property_updated",{apx_property_type:"session",apx_property_name:e,apx_property_old_value:n.ZngE[e]||"",apx_property_updated_value:i[e]},void 0,!1,"apxor","")}))}n.ZngE=t(t({},n.ZngE),e)}}else xt.warn("Apxor SDK is not running");else we.setSessionProperties()})),a(this,"setAppVersion",(function(e){n.JDLq?n.yOdy?n.version=e:xt.warn("Apxor SDK is not running"):we.setAppVersion()})),a(this,"lJmT",(function(){xt.debug("Controller : Updating the App info");var e=n.config,t=e.name,i=void 0===t?"":t,r=e.domain,o=void 0===r?n.window.location.host:r,a=n.jIVe.getInstallationTime(n.startTime),s=$e(n.window),u=Ce(n.clientConfig.version)?""+n.clientConfig.version:n.jIVe.BShG(),l=i;""===i&&"Unknown"===(l=Ge(n.window))&&(l=""),n.SJot=function(e,t,n,i,r){return{app_name:e,app_version:r=Ce(r)?r:"ALL",bundle_id:t,installation_time:n,app_mode:i}}(l,o,a,s,u)})),a(this,"getEventCount",(function(e){var t=-1;return n.clientEvents.forEach((function(n){n.name===e&&(t+=1)})),-1===t?n.hMaX.getEventCount(e):t})),a(this,"DhQR",(function(){n.umWO(),n.JBgz=null})),a(this,"umWO",(function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];xt.debug("Controller : Ending the navigation"),Ce(n.JBgz)&&(n.JBgz.duration=Qe(n.getSDKRunningTimeInSec()-n.JBgz.transition_time),n.dispatchEvent("NAVIGATION_EVENT",t({},n.JBgz),e))})),a(this,"getSessionId",(function(){return n.sessionId})),a(this,"NwcZ",(function(){return n.JDLq?n.yOdy?n.IPHr:(xt.warn("Controller : Apxor SDK is not running"),null):(we.getClientId(),null)})),a(this,"vKjo",(function(){var e;if(n.JDLq){var t=n.ESaT(n.FiHr),i=n.siteId,r=JSON.stringify(t);(null===(e=n.FiHr)||void 0===e?void 0:e.app_events.length)>0&&(xt.debug("Reporting a chunk on visibility change with sendBeacon"),n.jIVe.kAFz(),n.jIVe.DtNg(t),na