static.growthrx.in Open in urlscan Pro
2a02:26f0:fb:5a7::2a5b  Public Scan

URL: https://static.growthrx.in/js/v2/web-sdk.js
Submission Tags: falconsandbox
Submission: On March 04 via api from US — Scanned from DE

Form analysis 0 forms found in the DOM

Text Content

!function(window){function argSlice(e,t){var n=[];t||(t=0);for(var i=t;i<e.length;i++)n.push(e[i]);return n}function plugin_setDmpId(){var e=getCookie(GRX_COL_UUID_COOKIE_NAME);grx("set","dmpId",e)}function plugin_setDeviceCategory(){var e="desktop",t=navigator.userAgent;-1<t.indexOf("iPad")?e="tablet":-1<t.indexOf("Android")&&-1===t.indexOf("Mobi")?e="tablet":(-1<t.indexOf("Phone")||-1<t.indexOf("Mobi"))&&(e="mobile"),grx("set","deviceCategory",e)}function plugin_showNotificationWelcomeMessage(e,i){grx("addListener","notification_permission_allowed",function(){var n,t=i||{title:"Thank You",content:"for subscribing to notification"};try{n=new Notification(t.title,{body:t.content,icon:t.icon,image:t.image,badge:t.badge,data:{url:t.url,flag:"grx"}})}catch(e){sw_registration&&(n=sw_registration.showNotification(t.title,{body:t.content,icon:t.icon,image:t.image,badge:t.badge,data:{url:t.url,flag:"grx"}}))}n&&(n.onclick=function(e){var t=e.target.data;n.close(),t&&t.url&&window.open(t.url)})})}function plugin_trackUtm(e){var t=window.location.search;if(-1<t.indexOf("utm_")){if(void 0===e.projectCode)return void log("Call grx.init() with projectCode before sending trackevent");var n=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],i={},o="?"===t[0]?t.substr(1):t;((o?o.split("&"):[])||[]).map(function(e){if(e){var t=e.split("=");t[0]&&0<t[0].length&&t[1]&&0<t[1].length&&0<=n.indexOf(t[0])&&(i[decodeURIComponent(t[0])]=decodeURIComponent(t[1]||""))}}),grx("track","attribution",i)}}function plugin_inApp(r){var n=[],i=!0,p=nlog("inApp");function t(e,t){if(p("checkAndRunInAppAlerts",e,t),i)return p("holding Event",e,t),void n.push({event_name:e,properties:t});a(e,t)}function o(){if(0===n.length)return i=!1,void p("NO HeldRules");p("running HeldRules"),n.forEach(function(e){a(e.event_name,e.properties)}),i=!1}function a(t,n){if(!t||0!==t.indexOf("NOTI_")){p("runRule",t,n);var i=getValue("grx-"+r.projectCode+"-campaigns",!0);if(i)try{var o=[];i=JSON.parse(i),p("Got Stored campaigns",i),i.forEach(function(e){(function(e,t,n){var i=function(e){try{return e.liveSegment.BEHAVIOR.andQueries[0].orQueries[0].criteria}catch(e){return[]}}(e);if(!i)return p("["+e.campaignId+"] No campaign criteria found"),!1;p("["+e.campaignId+"] Checking campaign with criteria ",i);var o=(r=i,a=t,void 0!==r.find(function(e){return"grx_name"===e.field&&(e.value===a||"*"===e.value)}));var r,a;if(p("["+e.campaignId+"] Criteria name match",o),!o)return!1;var c=function(e,i,o){var r=!0,t=e.map(function(e,t){if("property"!==e.identifier)return"CountCriterion"!==e._ct||s(e,t,i,o);var n=s(e,t,i,o);return n||(r=!1),n});r&&d(o);return p("["+o.campaignId+"] Checked props",t),-1===t.indexOf(!1)}(i,n,e);return p("["+e.campaignId+"] Criteria props match",c),!!c})(e,t,n)&&o.push(e.campaignId)}),o&&0<o.length?(p("valid campaigns",o),i.forEach(function(e){-1<o.indexOf(e.campaignId)?function(n){p("["+n.campaignId+"] Checking capping for campaign",n.campaignId);var e=u(),i=v(n),t=m(n,"session"),o=f(n,30);if(o.push(t),o.push("LIFETIME"),c=n,s=i[n.campaignId],l=o,Object.keys(s).forEach(function(e){-1===l.indexOf(e)?(p("["+c.campaignId+"] DELETING CAPPING",e),delete s[e]):p("["+c.campaignId+"] NOT DELETING CAPPING",e)}),setValue(e,JSON.stringify(i),30),n.capping&&0<n.capping.length){var r=n.capping,a=r.map(function(e,t){return function(t,e,n,i){switch(p("["+t.campaignId+"] Checking capping ",i,e),e._ct){case"DayCapping":var o=0,r=f(t,e.duration);return r.map(function(e){o+=n[t.campaignId]&&n[t.campaignId][e]?n[t.campaignId][e]:0}),!!(o&&o>e.count);case"DNDCapping":var a=(new Date).getDay();return e.day===["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY","SUNDAY"][a];case"SessionCapping":var c=m(t,"session"),s=n[t.campaignId]?n[t.campaignId][c]:0;return s>e.count&&(p("["+t.campaignId+"] Session capped for campaign",t.campaignId," at ",e.count,", stored value:",s),!0);default:return!1}}(n,e,i,t)});return p("["+n.campaignId+"] Capping response",a),-1<a.indexOf(!0)}var c,s,l;return!1}(e)?p("["+e.campaignId+"] Campaign capped: ",e.campaignId):function(t){var n=t.behaviourSegmentId;if(p("["+t.campaignId+"] Campaign checkSegments"),n){p("["+t.campaignId+"] Found behaviour segment, checking with server",n);try{var e=getUrl().replace("/track","/user/project-"+r.projectCode+"/platform-web/user-segment?segmentId="+n+"&gid="+_grx.getGID());fetch(e,{headers:{"Content-Type":"application/json",Accept:"application/json"}}).then(function(e){return e.json()}).then(function(e){p("["+t.campaignId+"] Server response for",n,e.exists),e.exists&&h(t)})}catch(e){sendException(e)}}else h(t)}(e):p("No valid campaign for this event",t,n)})):p("No valid campaign for this event",t,n)}catch(e){p(e),p("ERROR in parsing campaign",i)}else p("No Stored Campaign",i)}}function s(e,t,n,i){var o=n[e.field];switch(e._ct){case"MatchCriterion":if(!o)return!1;switch(p("["+i.campaignId+"] Checking criteria ",t,":",e._ct,e.matchingType,e.field,"=",e.value," for ",o),e.matchingType){case"EQUALS":return o===e.value;case"LIKE":return-1<e.value.indexOf(o);case"NOTLIKE":return-1===e.value.indexOf(o);case"MATCH":return Boolean(o.match(e.value));case"NOTMATCH":return!Boolean(o.match(e.value));case"STARTS_WITH":return 0===e.value.indexOf(o);case"ENDS_WITH":return e.value.indexOf(o)===e.value.length-o.length;case"CONTAINS":return-1<e.value.indexOf(o);case"EQUALS_IGNORE_CASE":return o.toLowerCase()===e.value.toLowerCase();case"NOTCONTAINS":return-1===e.value.indexOf(o);case"ISNULL":return null===o;case"NOTNULL":return null!==o}break;case"CountCriterion":var r=function(e){var t=l(e),n=m(e);g(e,t[e.campaignId],n);var i=t[e.campaignId][n];void 0===i&&(i=d(e));return t[e.campaignId][n]=i}(i);switch(p("["+i.campaignId+"] Checking criteria ",t,":",e._ct,e.type,e.value,",stored val:",r),e.type){case"ATLEAST":return r>=e.value;case"LESS_THAN":return r<e.value;case"EXACTLY":return r===e.value}break;case"NumberCriterion":switch(e.matchingType){case"LESS_THAN":return o<e.value;case"GREATER_THAN":return o>e.value;case"LESS_THAN_EQUAL_TO":return o<=e.value;case"GREATER_THAN_EQUAL_TO":return o>=e.value;case"EXACTLY":return o===e.value}break;case"boolCriterion":switch(e.matchingType){case"true":return o;case"false":return!1===o}break;case"BetweenCriterion":case"InRangeTimeCriterion":var a=new Date(e.to).getTime(),c=new Date(e.from).getTime(),s=new Date(o).getTime();return c<=s&&s<=a;case"InLastTimeCriterion":return o===e.time;default:return!1}return!1}function c(){return"grx-"+r.projectCode+"-campaign-count"}function u(){return"grx-"+r.projectCode+"-campaign-capping"}function l(e){var t=c(),n=getValue(t),i={};return n?i=JSON.parse(n):i[e.campaignId]={},i[e.campaignId]||(i[e.campaignId]={}),i}function d(e){var t=c(),n=l(e),i=m(e);g(e,n[e.campaignId],i);var o=n[e.campaignId][i];return void 0===o&&(o=0),p("["+e.campaignId+"] Incr campaign event count [",t,"] from ",o," to ",o+1),o++,n[e.campaignId][i]=o,setValue(t,JSON.stringify(n),30),o}function g(t,n,i){Object.keys(n).forEach(function(e){0!==e.indexOf("DAY-")&&0!==e.indexOf("SESSION-")||e===i?p("["+t.campaignId+"] NOT DELETING",e):(p("["+t.campaignId+"] DELETING",e),delete n[e])})}function f(e,t){for(var n=[],i=(new Date).getTime(),o=0;o<t;o++){var r=m(e,"day",new Date(i-864e5*o));n.push(r)}return n}function m(e,t,n){switch(t||e.retention){case"day":return"DAY-"+getYYYYMMDD(n);case"session":return"SESSION-"+getSessionId();case"campaign_lifetime":return"LIFETIME";default:return"default"}}function v(e){var t=u(),n=getValue(t),i={};return n&&(i=JSON.parse(n)),i[e.campaignId]||(i[e.campaignId]={}),i}function h(e){if(y(e.campaignType)){var t=function(e){if(1===e.campaignType.length)return{campaignType:e.campaignType[0].type,properties:e.properties[0],campaignId:e.campaignId};for(var t=Math.floor(99*Math.random())+1,n=0,i=0,o=0;o<e.campaignType.length;o++)if(n+=Number(e.campaignType[o].allocation),t<n){i=o;break}return{campaignType:e.campaignType[i].type,properties:e.properties[i],campaignId:e.campaignId+"__"+e.campaignType[i].name}}(e);e.campaignType=t.campaignType,e.properties=t.properties,e.campaignId=t.campaignId,x(e)}else y(e.properties)&&(e.properties=e.properties[0]),x(e)}function y(e){return"[object Array]"===Object.prototype.toString.call(e)}function x(e){_grx.track("NOTI_SENT_SUCCESS",{grx_notificationId:e.campaignId}),e.delay&&0<e.delay&&p("["+e.campaignId+"] Adding delay of ",e.delay,"seconds"),setTimeout(function(){!function(t){try{var e=new Date(getValue("grx-"+r.projectCode+"-lastInAppDateTime",new Date)),n=((new Date).getTime()-e.getTime())/1e3,i=n-t.dwell_time;p("["+t.campaignId+"] Checking dwellTime(",t.dwell_time,"secs): last trigger time",e,", ",timeConvert(n/60),"ago. has dwell:",i),!i||0<i?b(t):(_grx.track("NOTI_CRITERION_FAILED",{grx_notificationId:t.campaignId,grx_notificationFailReason:"Dwell time limit: "+-1*i+" seconds remaining"}),p("["+t.campaignId+"] Dwell time limit for ",t.campaignId,",remaining dwell time:",Math.floor(-1*i),"seconds"))}catch(e){b(t)}}(e)},1e3*(e.delay||0))}function b(e){!function(e,t){var n=u(),i=v(e),o=m(e,"day");i[e.campaignId][o]||(i[e.campaignId][o]=0),i[e.campaignId][o]=i[e.campaignId][o]+1;var r=m(e,"session");i[e.campaignId][r]||(i[e.campaignId][r]=0),i[e.campaignId][r]=i[e.campaignId][r]+1;var a=m(e,"campaign_lifetime");i[e.campaignId][a]||(i[e.campaignId][a]=0),i[e.campaignId][a]=i[e.campaignId][a]+1,setValue(n,JSON.stringify(i),30)}(e),_grx.track("NOTI_DELIVERED",{grx_notificationId:e.campaignId}),setValue("grx-"+r.projectCode+"-lastInAppDateTime",new Date),p("["+e.campaignId+"] dispatch 'in_app_notification' event",e),"custom"==e.campaignType||"silent"==e.campaignType?_grx.dispatch("in_app_notification",e):_grx.showCampaign(e.campaignType,e.properties)}return p("Registered plugin: inApp"),function(){var e=getValue("grx-"+r.projectCode+"-campaigns-fetched-at"),t=new Date(e),n=new Date-(e?t:0);if(n>r.campaignInterval){p("Fetching campaign for project:",r.projectCode);var i=getUrl().replace("/track","/user/project-"+r.projectCode+"/platform-web/campaigns/list");try{p("Fetching campaign url:",i),fetch(i,{headers:{"Content-Type":"application/json",Accept:"application/json"}}).then(function(e){return e.json()}).then(function(e){var t;e.forEach(function(t){try{t.campaignType=JSON.parse(t.campaignType)}catch(e){t.campaignType=t.campaignType}}),setValue("grx-"+r.projectCode+"-campaigns-fetched-at",new Date),p("Got campaign",e),t=e,setValue("grx-"+r.projectCode+"-campaigns",JSON.stringify(t),30),p("Stored campaigns"),o()})}catch(e){sendException(e)}}else p("NOT fetching campaign for project:",r.projectCode,"\r\n          Last fetched",timeConvert(n/1e3/60)," ago at :",e),o()}(),_grx.addListener("after_event",function(e){p("after_event",e.detail),t(e.detail.name,e.detail.properties)}),{runInAppAlerts:t}}var Jc;Jc=function(){"use strict";function e(t){var n=this.constructor;return this.then(function(e){return n.resolve(t()).then(function(){return e})},function(e){return n.resolve(t()).then(function(){return n.reject(e)})})}var t=setTimeout;function s(e){return Boolean(e&&void 0!==e.length)}function i(){}function r(e){if(!(this instanceof r))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],u(e,this)}function o(n,i){for(;3===n._state;)n=n._value;0!==n._state?(n._handled=!0,r._immediateFn(function(){var e=1===n._state?i.onFulfilled:i.onRejected;if(null!==e){var t;try{t=e(n._value)}catch(e){return void c(i.promise,e)}a(i.promise,t)}else(1===n._state?a:c)(i.promise,n._value)})):n._deferreds.push(i)}function a(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof r)return t._state=3,t._value=e,void l(t);if("function"==typeof n)return void u((i=n,o=e,function(){i.apply(o,arguments)}),t)}t._state=1,t._value=e,l(t)}catch(e){c(t,e)}var i,o}function c(e,t){e._state=2,e._value=t,l(e)}function l(e){2===e._state&&0===e._deferreds.length&&r._immediateFn(function(){e._handled||r._unhandledRejectionFn(e._value)});for(var t=0,n=e._deferreds.length;t<n;t++)o(e,e._deferreds[t]);e._deferreds=null}function p(e,t,n){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.promise=n}function u(e,t){var n=!1;try{e(function(e){n||(n=!0,a(t,e))},function(e){n||(n=!0,c(t,e))})}catch(e){if(n)return;n=!0,c(t,e)}}r.prototype.catch=function(e){return this.then(null,e)},r.prototype.then=function(e,t){var n=new this.constructor(i);return o(this,new p(e,t,n)),n},r.prototype.finally=e,r.all=function(t){return new r(function(i,o){if(!s(t))return o(new TypeError("Promise.all accepts an array"));var r=Array.prototype.slice.call(t);if(0===r.length)return i([]);var a=r.length;function c(t,e){try{if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if("function"==typeof n)return void n.call(e,function(e){c(t,e)},o)}r[t]=e,0==--a&&i(r)}catch(e){o(e)}}for(var e=0;e<r.length;e++)c(e,r[e])})},r.resolve=function(t){return t&&"object"==typeof t&&t.constructor===r?t:new r(function(e){e(t)})},r.reject=function(n){return new r(function(e,t){t(n)})},r.race=function(o){return new r(function(e,t){if(!s(o))return t(new TypeError("Promise.race accepts an array"));for(var n=0,i=o.length;n<i;n++)r.resolve(o[n]).then(e,t)})},r._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){t(e,0)},r._unhandledRejectionFn=function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)};var n=function(){if("undefined"!=typeof self)return self;if(void 0!==window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")}();"Promise"in n?n.Promise.prototype.finally||(n.Promise.prototype.finally=e):n.Promise=r},"object"==typeof exports&&"undefined"!=typeof module||"function"==typeof define&&define.amd,Jc(),window.console&&window.console.log||(window.console={log:function(){}});try{Function.prototype.bind||(Function.prototype.bind=function(){var t=this,n=arguments[0],i=argSlice(arguments,1);if("function"!=typeof t)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");return function(){var e=i.concat(argSlice(arguments));return t.apply(n,e)}}),function(){if("function"==typeof window.CustomEvent)return;function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}e.prototype=window.Event.prototype,window.CustomEvent=e}(),Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(e){if(null==this)throw TypeError('"this" is null or not defined');var t=Object(this),n=t.length>>>0;if("function"!=typeof e)throw TypeError("predicate must be a function");for(var i=arguments[1],o=0;o<n;){var r=t[o];if(e.call(i,r,o,t))return r;o++}},configurable:!0,writable:!0}),Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(e){"use strict";if(null==e)throw new TypeError("Cannot convert first argument to object");for(var t=Object(e),n=1;n<arguments.length;n++){var i=arguments[n];if(null!=i){i=Object(i);for(var o=Object.keys(Object(i)),r=0,a=o.length;r<a;r++){var c=o[r],s=Object.getOwnPropertyDescriptor(i,c);void 0!==s&&s.enumerable&&(t[c]=i[c])}}}return t}}),window.fetch||(window.fetch=function(o,r){return new Promise(function(e,t){var n=null;if(window.XMLHttpRequest?n=new XMLHttpRequest:window.ActiveXObject&&(n=new ActiveXObject("Microsoft.XMLHTTP")),null!==n){for(var i in n.open(r.method,o),n.timeout=3e4,r.headers)n.setRequestHeader(i,r.headers[i]);n.onerror=function(e){t(e)},n.ontimeout=function(e){t(e)},n.onreadystatechange=function(){if(4===n.readyState)if(202<n.status){n.status,n.responseText;t(new Error(n.responseText))}else e({body:n.responseText,json:function(){return JSON.parse(n.responseText)}})},n.send(r.body)}})});var _grx={},preLoadEvents=window.grx&&window.grx.q?window.grx.q:[],eventListArr=[];window.grx=function(){var e=arguments[0],t=argSlice(arguments,1);if(_grx[e]&&"function"==typeof _grx[e])return _grx[e].apply(_grx,t)};var VERSION="2.5.0";function version(e){for(var t=e.split("."),n="1",i=0;i<t.length;i++)n+=prefix(t[i],3,0);return parseInt(n)}function prefix(e,t,n){var i=(e+"").length;if(0<t-i){for(var o=e,r=0;r<t-i;r++)o=n+""+o;return o}return e+""}var GRX_COOKIE_NAME="_grx",GRX_SESSION_COOKIE_NAME="_grxs",GRX_COL_UUID_COOKIE_NAME="_col_uuid",plugins={setDmpId:plugin_setDmpId,setDeviceCategory:plugin_setDeviceCategory,showNotificationWelcomeMessage:plugin_showNotificationWelcomeMessage,trackUtm:plugin_trackUtm,inApp:plugin_inApp},plugin_fn={},DEFAULT_SERVICE_WORKER="/sw.js",config={key:"config",sdk:"growthrx",url:"https://api.growthrx.in/v2/track",attribution_tracking:!1,platform:"web",sdkVersion:VERSION,sdkBuild:version(VERSION),timeInterval:1,campaignInterval:216e5,defaultInterval:1,sessionTime:30,eventFireTimer:5,timeout:5,service_worker:DEFAULT_SERVICE_WORKER,askPermission:!0,applicationServerKey:"BJbc9ibd8jputjGDrpcWO32Ky80HfmSo7eo87NqZnE4DUlOsWLBvlE2ODc-2CkOMMgxlORpeLercmKcnP9rGccA",page_properties:{}},sw_registration,generateUUID=function(){var n=(new Date).getTime();return"undefined"!=typeof performance&&"function"==typeof performance.now&&(n+=performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=(n+16*Math.random())%16|0;return n=Math.floor(n/16),("x"===e?t:3&t|8).toString(16)})},post=function(e,t,n,i){log("sending data ",t),fetch(e,{method:"post",headers:{Accept:"application/json","Content-Type":"application/json",sentAt:(new Date).getTime()},timeout:1e3*config.timeout,body:JSON.stringify(t),keepalive:!i}).then(function(e){return e.json()}).then(function(e){config.timeInterval=config.defaultInterval,log("Request succeeded with JSON response",e),n&&n(null,e)}).catch(function(e){log("Request failed",e),n&&n(e)})},exists=function(e){return void 0!==e&&""!==e&&null!=e},setCookie=function(e,t,n,i,o){var r=new Date;r.setTime(r.getTime()+24*n*60*60*1e3);var a="expires="+r.toUTCString();o||(o="/"),i||(i=location.hostname),document.cookie=e+"="+t+";"+a+";domain="+i+";path="+o+"; Secure; SameSite=Strict"},getCookie=function(e){var t=e+"=",n=decodeURIComponent(document.cookie);if(n)for(var i=n.split(";"),o=0;o<i.length;o++){for(var r=i[o];" "===r.charAt(0);)r=r.substring(1);if(0===r.indexOf(t))return r.substring(t.length,r.length)}return""},getValue=function(e,t){var n=null;if(window.localStorage)if((n=localStorage.getItem(e))&&-1<n.indexOf("~~")){var i=n.split("~~");parseInt(i[1])<(new Date).getTime()?(n=null,t&&localStorage.removeItem(e)):n=i[0]}else if(n&&-1<n.indexOf("[]")){var o=n.split("[]");parseInt(o[1])<(new Date).getTime()?(n=null,t&&localStorage.removeItem(e)):n=o[0]}return null!==n?n:getCookie(e)},setValue=function(t,n,i){var e=24*(i=i||30)*60*60*1e3,o=(new Date).getTime()+e;if(window.localStorage)if(null==n)localStorage.removeItem(t);else try{localStorage.setItem(t,n+"~~"+o)}catch(e){setCookie(t,n,i)}else setCookie(t,n,null==n?0:i)},clog="true"===getValue("grx_log")?Function.prototype.bind.call(window.console.log,window.console):function(){},log=function(){void 0!==window.console&&"true"===getValue("grx_log")&&Array.from&&clog.apply(clog,["GRX_LOG: "].concat(Array.from(arguments)))},nlog=function(e){return function(){log.apply(log,[e+": "].concat(Array.from(arguments)))}};log("GrowthRx SDK: v"+config.sdkVersion);var getAnonymousId=function(){var e=getCookie(GRX_COOKIE_NAME);return exists(e)?(setAnonymousId(e),setValue("coke_uuid",null),e):(e=getValue("coke_uuid"),exists(e)?(setAnonymousId(e),setValue("coke_uuid",null)):(e=generateUUID(),setAnonymousId(e)),e)},setAnonymousId=function(e){var t=getRootDomain();setCookie(GRX_COOKIE_NAME,e,730,t,"/")},getSessionId=function(){var e=getCookie(GRX_SESSION_COOKIE_NAME);return exists(e)?(setSessionId(e),setValue("GRXsdkSessionId",null),e):(e=getValue("GRXsdkSessionId"),exists(e)?(e=e.split("|")[0],setSessionId(e),setValue("GRXsdkSessionId",null)):(e=generateUUID(),setSessionId(e)),e)},setSessionId=function(e){var t=getRootDomain(),n=1/24/60*config.sessionTime;setCookie("_grxs",e,n,t,"/")},getRootDomain=function(){var e=location.host.split(":")[0].split(".").reverse().slice(0,2).reverse().join(".");return"localhost"===e?e:"."+e},getUrl=function(){return config.url},padDate=function(e){return e<10?"0"+e:e},getDateTime=function(e){return e||new Date},getYear=function(e){return getDateTime(e).getFullYear()},getMonth=function(e){return padDate(getDateTime(e).getMonth()+1)},getDate=function(e){return padDate(getDateTime(e).getDate())},getHours=function(e){return padDate(getDateTime(e).getHours())},getMinutes=function(e){return padDate(getDateTime(e).getMinutes())},getYYYYMMDD=function(e){return getYear(e)+getMonth(e)+getDate(e)},getHHMM=function(e){return getHours(e)+getMinutes(e)},timeConvert=function(e){var t=e/60,n=Math.floor(t),i=60*(t-n);return n+" hour(s) and "+Math.round(i)+" minute(s)"};_grx.log=function(){log.apply(this,arguments)},_grx.enable_log=function(){if(window.localStorage)return localStorage.setItem("grx_log","true"),clog=Function.prototype.bind.call(window.console.log,window.console),"Log Enabled"},_grx.disable_log=function(){if(window.localStorage)return clog=function(){},localStorage.removeItem("grx_log"),"Log Disabled"},_grx.init=function(e,t){config=Object.assign({},config,{projectCode:e,startTimestamp:(new Date).getTime(),anonymous_id:getAnonymousId()},t),_grx.registerPlugin("setDmpId"),_grx.registerPlugin("setDeviceCategory"),config.service_worker!==DEFAULT_SERVICE_WORKER&&_grx.enablePush(Object.assign({},config,{askPermission:!1,inline:!0})),!0===config.attribution_tracking&&(window.console&&window.console.warn&&console.warn("grx('init',{attribution_tracking:true}); is deprecated, use grx('registerPlugin','trackUtm')"),_grx.registerPlugin("trackUtm")),setTimeout(function(){_grx.dispatch("ready")},1)},_grx.set=function(e,t){"applicationServerKey"===e?(config[e]=t,window.console&&window.console.warn&&console.warn("grx('set', 'applicationServerKey' ,'<value>') is deprecated, use grx('config','applicationServerKey', '<value>')")):"userId"===e?(config[e]=t,window.console&&window.console.warn&&console.warn("grx('set', 'userId' ,'<value>') is deprecated, use grx('userId', '<value>')")):config.page_properties[e]=t},_grx.config=function(e,t){"service_worker"===e&&t!==DEFAULT_SERVICE_WORKER&&_grx.enablePush(Object.assign({},config,{askPermission:!1,inline:!0})),config[e]=t},_grx.userId=function(e){config.userId=e},_grx.registerPlugin=function(e,t){var n=plugins[e];return n&&"function"==typeof n&&!plugin_fn[e]?(plugin_fn[e]=n(config,t)||!0,"Registered Plugin: "+e):plugin_fn[e]?(log("Already Registered Plugin: "+e),"Already Registered Plugin: "+e):(log("Not Found Plugin: "+e),"Not Found Plugin: "+e)};var pushEvents=function(e){try{if(eventListArr&&0<eventListArr.length){var t=eventListArr;eventListArr=[],post(getUrl(),t,function(e,t){e&&t&&log("Event failed:",t)},e)}}catch(e){sendException(e)}},operaAgent=-1<navigator.userAgent.indexOf("OP");window.document.addEventListener("visibilitychange",pushEvents.bind(this,operaAgent),!1);var checkAndSendEvent=function(){try{var e=(new Date).getTime()-config.startTimestamp;eventListArr.length&&(config.eventCount<=eventListArr.length||e/1e3>=config.eventFireTimer)&&(config.startTimestamp=(new Date).getTime(),pushEvents(!0)),setTimeout(checkAndSendEvent,1e3*config.timeInterval)}catch(e){sendException(e)}};function askPermission(e){return"granted"===Notification.permission?(log("Notification Permission ",Notification.permission),new Promise(function(e,t){e(Notification.permission)})):"denied"===Notification.permission?(log("Notification Permission ",Notification.permission),new Promise(function(e,t){e(Notification.permission)})):e?(log("Notification Permission is default, asking"),isSubscribed()&&setUnSubscribed(),new Promise(function(t,e){var n=Notification.requestPermission(function(e){t(e)});n&&n.then(t,e)}).then(function(e){return"granted"===e?(log("Notification permission granted.",e),_grx.dispatch("notification_permission_allowed")):"denied"===e?(log("Notification permission denied.",e),_grx.dispatch("notification_permission_blocked")):(log("Notification permission default.",e),_grx.dispatch("notification_permission_closed")),e})):(log("Not asking Notification Permission ",Notification.permission),new Promise(function(e,t){e(Notification.permission)}))}function registerServiceWorker(e){return config.service_worker?(log("Registering service worker: "+config.service_worker,"with permission: ",e),navigator.serviceWorker.register(config.service_worker).then(function(e){return(sw_registration=e).update(),log("Service worker successfully registered."),send_message_to_sw(config),e}).catch(function(e){log("Unable to register service worker.",e)})):(log("Not Registering service worker: value is ",config.service_worker),!1)}function isSubscribed(){return getValue("subscribe_push")}function setSubscribed(e){setValue("subscribe_push",JSON.stringify(e),10)}function setUnSubscribed(){setValue("subscribe_push",null,10)}function getSubscription(e){return e.pushManager.getSubscription()}function getSubscriptionStr(t){return getSubscription(t).then(function(e){return e?(log("Retrieved PushSubscription: "+JSON.stringify(e)),log("with applicationServerKey: "+getApplicationServerKey(e)),validateApplicationServerKey(e,t)):(log("Could not get Subscription: "+e),null)}).catch(function(e){log("Error in get subscription",e)})}function resubscribe(e,i){return new Promise(function(t,n){i.unsubscribe().then(function(){subscribe(e).then(function(e){log("subscribed: ",e),e?t(e):n(e)}).catch(n)}).catch(n)})}function subscribe(n){var e={userVisibleOnly:!0,applicationServerKey:urlBase64ToUint8Array(config.applicationServerKey)};return getSubscription(n).then(function(t){return t?JSON.parse(JSON.stringify(t)):n.pushManager.subscribe(e).then(function(e){return log("Subscribed PushSubscription: "+JSON.stringify(e)),log("with applicationServerKey: "+getApplicationServerKey(e)),JSON.parse(JSON.stringify(e))}).catch(function(e){return log("Error in subscribing",e),resubscribe(n,t)})}).catch(function(e){log("Error in getSubscription",e)})}function subscribeUserToPush(i){if(i){if("granted"===Notification.permission){if(!config.applicationServerKey)return log("applicationServerKey is "+config.applicationServerKey),!1;var e=isSubscribed();return new Promise(function(t,n){return e&&"{"===e[0]?(log("Already subscribed to push"),getSubscriptionStr(i).then(t).catch(n)):(setUnSubscribed(),log("Getting current subscription"),getSubscription(i).then(function(e){return log("Got PushSubscription: "+JSON.stringify(e)),log("with applicationServerKey: "+getApplicationServerKey(e)),e?validateApplicationServerKey(e,i).then(t).catch(n):subscribe(i).then(t).catch(n)}).catch(function(e){return log("No existing subscription",e),subscribe(i).then(t).catch(n)}))})}log("Cannot subscribe to push, notification permission not granted")}else log("Cannot subscribe to push, service worker not registered")}function validateApplicationServerKey(i,o){return new Promise(function(e,t){var n=getApplicationServerKey(i);n&&n!==config.applicationServerKey?(log("applicationServerKey Mismatch. \nExisting: "+n,"\nNew     : "+config.applicationServerKey),log("Unsubscribing existing subscription"),resubscribe(o,i).then(e).then(t)):i&&e(JSON.parse(JSON.stringify(i)))})}function getApplicationServerKey(e){return e&&e.options&&e.options.applicationServerKey&&Uint8ArrayTourlBase64(e.options.applicationServerKey)}function sendToServer(i,o){var e=isSubscribed();if(e&&0<e.length&&!i)return log("Sending push_unsubscribed to server"),setUnSubscribed(),e=null,new Promise(function(e,t){_grx.track("push_unsubscribed"),e()});if(i){if(JSON.stringify(i)!==e)return log("Sending subscription to server"),setSubscribed(i),new Promise(function(e,t){var n={endpoint:i.endpoint,expirationTime:i.expirationTime,keys_p256dh:i.keys.p256dh,keys_auth:i.keys.auth};o?_grx.profile("push_refresh",n):_grx.profile("push_subscription",n),e()});log("Already sent to server")}else log("Cannot send to server, no push subscription")}function Uint8ArrayTourlBase64(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function urlBase64ToUint8Array(e){for(var t=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),n=window.atob(t),i=new Uint8Array(n.length),o=0;o<n.length;o++)i[o]=n.charCodeAt(o);return i}function send_message_to_sw(i){return new Promise(function(t,n){var e=new MessageChannel;e.port1.onmessage=function(e){e.data.error?n(e.data.error):(window.grx.apply(_grx,e.data),t(e.data))},navigator.serviceWorker.controller&&navigator.serviceWorker.controller.postMessage(i,[e.port2])})}function getEventObject(e,t,n,i,o){n||(n={});var r=Object.assign({},config.page_properties,n),a={projectCode:config.projectCode,gid:config.anonymous_id,name:e,type:t,properties:r,platform:config.platform,sdkVersion:config.sdkVersion,sdkBuild:config.sdkBuild,createdAt:(new Date).getTime(),sessionId:getSessionId(),insertId:generateUUID(),nonInteraction:i,userId:config.userId};return o&&(a.operations=o),a}setTimeout(checkAndSendEvent,1e3*config.timeInterval),_grx.__track=function(e,t,n,i,o){log('track "'+t+'" to queue',e,n);try{if(void 0===config.projectCode||0===config.projectCode.length)return void log("Call grx.init() with projectCode before sending track event");n||(n={});var r=getEventObject(e,t,n,i,o);log('adding "'+t+'" to queue',e,n),eventListArr.push(r),_grx.dispatch("after_event",r)}catch(e){sendException(e)}},_grx.track=function(e,t,n){_grx.__track(e,"event",t,n)},_grx.profile=function(e,t,n){_grx.__track(e,"profile",t,n)},_grx.operations=function(e,t,n){_grx.__track(e,"profile",null,n,t)},_grx.showCampaign=function(type,payload){var grx_banner=document.getElementById("grx_banner");grx_banner&&document.body.removeChild(grx_banner);var grx_popup=document.getElementById("grx_popup");grx_popup&&document.body.removeChild(grx_popup);var grx_box=document.getElementById("grx_box");grx_box&&document.body.removeChild(grx_box);var grx_html=document.getElementById("grx_html");grx_html&&document.body.removeChild(grx_html);var isSmallScreen=window.innerWidth<600;if("banner"==type){var container=document.createElement("div");if(container.style.cssText="z-index:100000;position: fixed;width: calc(100% - 50px);left: 0px;background: rgb(4, 24, 106);display: flex;justify-content: space-around;align-items: center;padding: 10px 25px;font-family:Helvetica,Calibri,Arial,sans-serif;;line-height: 1.5;font-size: 14px;box-sizing: content-box;",isSmallScreen&&(container.style.cssText="z-index: 100000;position: fixed;width: calc(100% - 20px);left: 0px;background: rgb(4, 24, 106);display: flex;justify-content: space-around;align-items: center;padding: 10px;font-family:Helvetica,Calibri,Arial,sans-serif;line-height: 1.5;font-size: 14px;box-sizing: content-box;border-radius: 10px;flex-wrap: wrap;"),container.style.backgroundColor=payload.backgroundColor,container.id="grx_banner","Top"==payload.position?container.style.top=0:container.style.bottom=0,payload.roundedCorners&&(container.style.borderRadius="10px"),payload.imageUrl){var img=document.createElement("img");img.src=payload.imageUrl,img.style.cssText="width: 90px;height: 90px;object-fit: cover;position: absolute;left: 10px;",isSmallScreen&&(img.style.cssText="width: 25px;height: 25px;object-fit: cover;position: absolute;top:12px;left: 10px;"),container.appendChild(img)}var main=document.createElement("div");payload.imageUrl&&(main.style.cssText="width: 70%;margin-left:100px"),isSmallScreen&&(main.style.cssText="width: 100%;");var titleElem=document.createElement("h3");titleElem.style.cssText="margin-top: 10px;",isSmallScreen&&(titleElem.style.cssText="margin-top: 0px;margin-bottom: 10px;font-size: 13px;font-weight: 400;",payload.imageUrl&&(titleElem.style.marginLeft="30px"),payload.showCloseIcon&&(titleElem.style.marginRight="30px")),titleElem.style.color=payload.textColor,titleElem.innerText=payload.title?payload.title:"",main.appendChild(titleElem);var msgElem=document.createElement("h4");if(msgElem.style.cssText="font-weight: 200;",isSmallScreen&&(msgElem.style.cssText="padding: 0px;font-size: 11px;margin: 2px;font-weight: 200;"),msgElem.style.color=payload.textColor,msgElem.innerText=payload.message?payload.message:"",main.appendChild(msgElem),container.appendChild(main),payload.showCloseIcon){var closeIcon=document.createElement("div");closeIcon.style.cssText="position: absolute;right: 5px;font-size: 40px;transform: rotate(45deg);cursor: pointer;",isSmallScreen&&(closeIcon.style.cssText="position: absolute;top:0px;right: 10px;font-size: 30px;transform: rotate(45deg);cursor: pointer;"),closeIcon.innerText="+",closeIcon.style.color=payload.textColor,closeIcon.addEventListener("click",function(){document.body.removeChild(container)}),container.appendChild(closeIcon)}if(payload.buttonText){var button=document.createElement("button");button.style.cssText="cursor: pointer;border: none;padding: 11px 32px;font-size: 16px;border-radius: 3px;",isSmallScreen&&(button.style.cssText="cursor: pointer;border: none;font-size: 12px;border-radius: 3px;padding: 5px 10px;"),button.style.backgroundColor=payload.buttonColor,button.style.color=payload.buttonTextColor,button.innerText=payload.buttonText,button.addEventListener("click",function(){"openLink"==payload.onClickEvent&&(document.body.removeChild(container),window.open(payload.link,"_blank")),"invokeFunction"==payload.onClickEvent&&(document.body.removeChild(container),eval(payload.func))}),container.appendChild(button)}document.body.appendChild(container)}if("popup"==type){var backdrop=document.createElement("div");backdrop.style.cssText="z-index:100000;display: flex;justify-content: center;align-items: center;position: fixed;top: 0;left: 0;bottom: 0;right: 0;background-color: rgba(0, 0, 0, 0.65);font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';line-height: 1.5;font-size: 14px;",backdrop.id="grx_popup",backdrop.addEventListener("click",function(){document.body.removeChild(backdrop)});var container=document.createElement("div");container.style.cssText="width: 60%;padding:40px;display: flex;justify-content: space-around;align-items: center;position: relative;flex-flow: column;",isSmallScreen&&(container.style.cssText="width: 90%;padding:10px;display: flex;justify-content: space-around;align-items: center;position: relative;flex-flow: column;"),container.style.backgroundColor=payload.backgroundColor,container.addEventListener("click",function(e){e.stopPropagation()}),payload.roundedCorners&&(container.style.borderRadius="10px");var body=document.createElement("div");if(body.style.cssText="display: flex;justify-content: space-around;width: 100%;",payload.imageUrl){var img=document.createElement("img");img.src=payload.imageUrl,img.style.cssText="max-width:150px;max-height:150px;object-fit: cover",isSmallScreen&&(img.style.cssText="position: absolute;max-width: 40px;max-height: 40px;object-fit: cover;top: 10px;left: 10px;"),body.appendChild(img)}var main=document.createElement("div");main.style.cssText="margin: 0px 15px;display: flex;flex-flow: column;justify-content: space-around;",!isSmallScreen&&payload.imageUrl&&(main.style.width="calc(100% - 180px)"),isSmallScreen&&(main.style.cssText="display: flex;flex-flow: column;justify-content: space-around;");var titleElem=document.createElement("h3");titleElem.style.cssText="margin:5px 0px;font-weight: bold;",isSmallScreen&&(titleElem.style.cssText="margin-top: 0px;margin-bottom: 10px; font-weight: bold;line-height: 1.1;",payload.imageUrl&&(titleElem.style.marginLeft="43px"),payload.showCloseIcon&&(titleElem.style.marginRight="43px")),titleElem.style.color=payload.textColor,titleElem.innerText=payload.title?payload.title:"",main.appendChild(titleElem);var msgElem=document.createElement("h4");if(msgElem.style.cssText="font-weight: 500;margin-top: 5px;",isSmallScreen&&(msgElem.style.cssText="font-weight: 500;line-height: 1.1;margin-top: 5px;"),msgElem.style.color=payload.textColor,msgElem.innerText=payload.message?payload.message:"",main.appendChild(msgElem),body.appendChild(main),container.appendChild(body),payload.showCloseIcon){var closeIcon=document.createElement("div");closeIcon.style.cssText="position: absolute;top: -10px;right: 8px;font-size: 40px;transform: rotate(45deg);cursor: pointer;",closeIcon.innerText="+",closeIcon.style.color=payload.textColor,closeIcon.addEventListener("click",function(){document.body.removeChild(backdrop)}),container.appendChild(closeIcon)}if(payload.buttonText){var button=document.createElement("button");button.style.cssText="cursor: pointer;border: none;padding: 11px 32px;font-size: 16px;border-radius: 3px;",button.style.backgroundColor=payload.buttonColor,button.style.color=payload.buttonTextColor,button.innerText=payload.buttonText,button.addEventListener("click",function(){"openLink"==payload.onClickEvent&&(document.body.removeChild(backdrop),window.open(payload.link,"_blank")),"invokeFunction"==payload.onClickEvent&&(document.body.removeChild(backdrop),eval(payload.func))}),container.appendChild(button)}backdrop.appendChild(container),document.body.appendChild(backdrop)}if("box"==type){var container=document.createElement("div");if(container.style.cssText="z-index: 100000;position: fixed;width: 300px;background: rgb(4, 24, 106);display: flex;justify-content: space-around;align-items: center;padding: 10px;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';line-height: 1.5;font-size: 14px;",container.style.backgroundColor=payload.backgroundColor,container.id="grx_box","TopLeft"==payload.position?(container.style.top="10px",container.style.left="10px"):"TopRight"==payload.position?(container.style.top="10px",container.style.right="10px"):"BottomLeft"==payload.position?(container.style.bottom="10px",container.style.left="10px"):("BottomRight"==payload.position?container.style.bottom="10px":container.style.top="10px",container.style.right="10px"),payload.roundedCorners&&(container.style.borderRadius="10px"),payload.imageUrl){var img=document.createElement("img");img.src=payload.imageUrl,img.style.cssText="width: 40px;height: 40px;object-fit: cover;position: absolute;top: 10px;left: 10px;",container.appendChild(img)}var main=document.createElement("div");main.style.cssText="margin-left: 5px;margin-right: 10px;";var titleElem=document.createElement("h3");titleElem.style.cssText="margin-top: 0px;margin-bottom: 10px; line-height: 1.1;font-size: 14px;font-weight: bold;",payload.imageUrl&&(titleElem.style.marginLeft="40px"),payload.showCloseIcon&&(titleElem.style.marginRight="40px"),titleElem.style.color=payload.textColor,titleElem.innerText=payload.title?payload.title:"",main.appendChild(titleElem);var msgElem=document.createElement("h5");if(msgElem.style.cssText="font-weight: 500",msgElem.style.color=payload.textColor,msgElem.innerText=payload.message?payload.message:"",main.appendChild(msgElem),container.appendChild(main),payload.showCloseIcon){var closeIcon=document.createElement("div");closeIcon.style.cssText="position: absolute;right: 10px;top:0px;font-size: 35px;transform: rotate(45deg);cursor: pointer;",closeIcon.innerText="+",closeIcon.style.color=payload.textColor,closeIcon.addEventListener("click",function(){document.body.removeChild(container)}),container.appendChild(closeIcon)}document.body.appendChild(container)}if("html"==type){var html=payload.html.replace(">",' id="grx_html" >');document.body.insertAdjacentHTML("beforeend",html)}},_grx.getGID=function(){return getAnonymousId()},_grx.getSessionID=function(){return getSessionId()},_grx.disablePush=function(e){setUnSubscribed(),navigator.serviceWorker.getRegistration().then(function(e){getSubscription(e).then(function(e){e&&e.unsubscribe()})})},_grx.enablePush=function(e){if("serviceWorker"in navigator)if("PushManager"in window){e&&void 0!==e.service_worker&&(window.console&&window.console.warn&&!0!==e.inline&&console.warn("Declaration of service worker in grx('enablePush',{service_worker:'"+e.service_worker+"'}) is deprecated, use grx('config','service_worker','"+e.service_worker+"');grx('enablePush');"),config.service_worker=e.service_worker);var t=config.askPermission;e&&void 0!==e.askPermission&&(window.console&&window.console.warn&&!0!==e.inline&&console.warn("Declaration of askPermission in grx('enablePush',{askPermission:"+e.askPermission+"}) is deprecated, use grx('config','askPermission',"+e.askPermission+");grx('enablePush')"),t=e.askPermission,!0!==e.inline&&(config.askPermission=e.askPermission));var n=!1;n=window.localStorage?localStorage.getItem("subscribe_push"):getCookie("subscribe_push"),askPermission(t).then(registerServiceWorker).then(subscribeUserToPush).then(function(e){return sendToServer(e,n)}).catch(function(e){log("Error ",e)})}else log("Push isn't supported on this browser");else log("Service Worker isn't supported on this browser")},_grx.addListener=function(e,t){document.addEventListener(e,t,!1)},_grx.removeListener=function(e,t){document.removeEventListener(e,t,!1)},_grx.dispatch=function(e,t){var n=new CustomEvent(e,{detail:t});document.dispatchEvent?document.dispatchEvent(n):document.fireEvent&&document.fireEvent(n)},preLoadEvents.forEach(function(e){window.grx.apply(_grx,e)})}catch(e){sendException(e)}function sendException(e){if(log(e),-1<location.host.indexOf("speakingtree")&&window.ga&&e)try{ga("send","event","grx_exc",e.message,e.stack?e.stack.split("\n")[1]:"none")}catch(e){ga("send","event","grx_exc","invalid"+e.message,"could not parse")}}}(window);