!function(){"use strict";var e,t,r,i,o,n,s,a,c,p,u,f,l,d,h,g,y,m,v,b,$,k,_,w=Array.prototype,O=Function.prototype,x=Object.prototype,S=w.slice,A=x.toString,E=x.hasOwnProperty,q=window.console,U=window.navigator,T=window.document,j=U.userAgent,B="alooma",M="__mps",P="__mpso",N="__mpa",C="__mpap",I="__mpu",D="$set",L="$set_once",H="$add",F="$append",J="$union",z="$people_distinct_id",Q="__alias",V="__cmpns",W="__timers",R=[M,P,N,C,I,z,Q,V,W,],Y="https:"==T.location.protocol?"https://":"http://",G=window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,K=!G&&-1==j.indexOf("MSIE")&&-1==j.indexOf("Mozilla"),X={},Z=!1,ee={api_host:Y+"api.alooma.com",cross_subdomain_cookie:!0,persistence:"cookie",persistence_name:"",cookie_name:"",loaded:function(){},store_google:!0,save_referrer:!0,test:!1,verbose:!1,img:!1,track_pageview:!0,debug:!1,track_links_timeout:300,cookie_expiration:365,upgrade:!1,disable_persistence:!1,disable_cookie:!1,secure_cookie:!1,ip:!0,property_blacklist:[]},et=!1;r=O.bind,i=w.forEach,o=w.indexOf,n=Array.isArray,s={},X.bind=function(e,t){var i,o;if(r&&e.bind===r)return r.apply(e,S.call(arguments,1));if(!X.isFunction(e))throw TypeError();return i=S.call(arguments,2),o=function(){if(!(this instanceof o))return e.apply(t,i.concat(S.call(arguments)));ctor.prototype=e.prototype;var r=new ctor;ctor.prototype=null;var n=e.apply(r,i.concat(S.call(arguments)));return Object(n)===n?n:r}},X.bind_instance_methods=function(e){for(var t in e)"function"==typeof e[t]&&(e[t]=X.bind(e[t],e))},a=X.each=function(e,t,r){if(null!=e){if(i&&e.forEach===i)e.forEach(t,r);else if(e.length===+e.length){for(var o=0,n=e.length;o/g,">").replace(/"/g,""").replace(/'/g,"'")),t},X.extend=function(e){return a(S.call(arguments,1),function(t){for(var r in t)void 0!==t[r]&&(e[r]=t[r])}),e},X.isArray=n||function(e){return"[object Array]"===A.call(e)},X.isFunction=function(e){try{return/^\s*\bfunction\b/.test(e)}catch(t){return!1}},X.isArguments=function(e){return!!(e&&E.call(e,"callee"))},X.toArray=function(e){return e?e.toArray?e.toArray():X.isArray(e)||X.isArguments(e)?S.call(e):X.values(e):[]},X.values=function(e){var t=[];return null==e||a(e,function(e){t[t.length]=e}),t},X.identity=function(e){return e},X.include=function(e,t){var r=!1;return null==e?r:o&&e.indexOf===o?-1!=e.indexOf(t):(a(e,function(e){if(r||(r=e===t))return s}),r)},X.includes=function(e,t){return -1!==e.indexOf(t)},X.inherit=function(e,t){return e.prototype=new t,e.prototype.constructor=e,e.superclass=t.prototype,e},X.isObject=function(e){return e===Object(e)&&!X.isArray(e)},X.isEmptyObject=function(e){if(X.isObject(e)){for(var t in e)if(E.call(e,t))return!1;return!0}return!1},X.isUndefined=function(e){return void 0===e},X.isString=function(e){return"[object String]"==A.call(e)},X.isDate=function(e){return"[object Date]"==A.call(e)},X.isNumber=function(e){return"[object Number]"==A.call(e)},X.encodeDates=function(e){return X.each(e,function(t,r){X.isDate(t)?e[r]=X.formatDate(t):X.isObject(t)&&(e[r]=X.encodeDates(t))}),e},X.formatDate=function(e){function t(e){return e<10?"0"+e:e}return e.getUTCFullYear()+"-"+t(e.getUTCMonth()+1)+"-"+t(e.getUTCDate())+"T"+t(e.getUTCHours())+":"+t(e.getUTCMinutes())+":"+t(e.getUTCSeconds())},X.safewrap=function(e){return function(){try{e.apply(this,arguments)}catch(t){er.critical("Implementation error. Please contact support@alooma.com.")}}},X.safewrap_class=function(e,t){for(var r=0;r0&&(t[r]=e)}),t},X.truncate=function(e,t){var r;return"string"==typeof e?r=e.slice(0,t):X.isArray(e)?(r=[],X.each(e,function(e){r.push(X.truncate(e,t))})):X.isObject(e)?(r={},X.each(e,function(e,i){r[i]=X.truncate(e,t)})):r=e,r},X.JSONEncode=function(e){var t=function(e){var t=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,r={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};return t.lastIndex=0,t.test(e)?'"'+e.replace(t,function(e){var t=r[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'},r=function(e,i){var o="",n=0,s="",a="",c=0,p=o,u=[],f=i[e];switch(f&&"object"==typeof f&&"function"==typeof f.toJSON&&(f=f.toJSON(e)),typeof f){case"string":return t(f);case"number":return isFinite(f)?String(f):"null";case"boolean":case"null":return String(f);case"object":if(!f)return"null";if(o+=" ",u=[],"[object Array]"===A.apply(f)){for(n=0,c=f.length;n="0"&&p<="9";)t+=p,h();if("."===p)for(t+=".";h()&&p>="0"&&p<="9";)t+=p;if("e"===p||"E"===p)for(t+=p,h(),("-"===p||"+"===p)&&(t+=p,h());p>="0"&&p<="9";)t+=p,h();if(isFinite(e=+t))return e;d("Bad number")},y=function(){var e,t,r,i="";if('"'===p)for(;h();){if('"'===p)return h(),i;if("\\"===p){if(h(),"u"===p){for(t=0,r=0;t<4&&isFinite(e=parseInt(h(),16));t+=1)r=16*r+e;i+=String.fromCharCode(r)}else if("string"==typeof l[p])i+=l[p];else break}else i+=p}d("Bad string")},m=function(){for(;p&&p<=" ";)h()},v=function(){switch(p){case"t":return h("t"),h("r"),h("u"),h("e"),!0;case"f":return h("f"),h("a"),h("l"),h("s"),h("e"),!1;case"n":return h("n"),h("u"),h("l"),h("l"),null}d("Unexpected '"+p+"'")},b=function(){var e=[];if("["===p){if(h("["),m(),"]"===p)return h("]"),e;for(;p;){if(e.push(f()),m(),"]"===p)return h("]"),e;h(","),m()}}d("Bad array")},$=function(){var e,t={};if("{"===p){if(h("{"),m(),"}"===p)return h("}"),t;for(;p;){if(e=y(),m(),h(":"),Object.hasOwnProperty.call(t,e)&&d('Duplicate key "'+e+'"'),t[e]=f(),m(),"}"===p)return h("}"),t;h(","),m()}}d("Bad object")},f=function(){switch(m(),p){case"{":return $();case"[":return b();case'"':return y();case"-":return g();default:return p>="0"&&p<="9"?g():v()}},function(e){var t;return u=e,c=0,p=" ",t=f(),m(),p&&d("Syntax error"),t}),X.base64Encode=function(e){var t,r,i,o,n,s,a,c,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u=0,f=0,l="",d=[];if(!e)return e;e=X.utf8Encode(e);do t=e.charCodeAt(u++),o=(c=t<<16|(r=e.charCodeAt(u++))<<8|(i=e.charCodeAt(u++)))>>18&63,n=c>>12&63,s=c>>6&63,a=63&c,d[f++]=p.charAt(o)+p.charAt(n)+p.charAt(s)+p.charAt(a);while(u127&&s<2048?String.fromCharCode(s>>6|192,63&s|128):String.fromCharCode(s>>12|224,s>>6&63|128,63&s|128),null!==a&&(r>t&&(o+=e.substring(t,r)),o+=a,t=r=i+1)}return r>t&&(o+=e.substring(t,e.length)),o},X.UUID=(k=function(){for(var e=1*new Date,t=0;e==1*new Date;)t++;return e.toString(16)+t.toString(16)},_=function(e){var t,r,i=j,o=[],n=0;function s(e,t){var r,i=0;for(r=0;r=4&&(n=s(n,o),o=[]);return o.length>0&&(n=s(n,o)),n.toString(16)},function(){var e=(screen.height*screen.width).toString(16);return k()+"-"+Math.random().toString(16).replace(".","")+"-"+_()+"-"+e+"-"+k()}),X.isBlockedUA=function(e){return!!/(google web preview|baiduspider|yandexbot|bingbot|googlebot|yahoo! slurp)/i.test(e)},X.HTTPBuildQuery=function(e,t){var r,i,o=[];return X.isUndefined(t)&&(t="&"),X.each(e,function(e,t){r=encodeURIComponent(e.toString()),i=encodeURIComponent(t),o[o.length]=i+"="+r}),o.join(t)},X.getQueryParam=function(e,t){var r=RegExp("[\\?&]"+(t=t.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]"))+"=([^&#]*)").exec(e);return null===r||r&&"string"!=typeof r[1]&&r[1].length?"":decodeURIComponent(r[1]).replace(/\+/g," ")},X.cookie={get:function(e){for(var t=e+"=",r=T.cookie.split(";"),i=0;i=0}return function t(i){if(!T.getElementsByTagName)return[];for(var o=i.split(" "),n=Array(T),s=0;s-1){var a=f.split("#"),c=a[0],p=a[1],u=T.getElementById(p);if(!u||c&&u.nodeName.toLowerCase()!=c)return[];n=Array(u);continue}if(f.indexOf(".")>-1){var f,l,a=f.split("."),c=a[0],d=a[1];c||(c="*");for(var h=[],g=0,y=0;y-1};break;default:k=function(e){return e.getAttribute(_)}}n=[],v=0;for(var b=0;b=3?t[2]:""},properties:function(){return X.extend(X.strip_empty_properties({$os:X.info.os(),$browser:X.info.browser(j,U.vendor,window.opera),$referrer:T.referrer,$referring_domain:X.info.referringDomain(T.referrer),$device:X.info.device(j)}),{$current_url:window.location.href,$browser_version:X.info.browserVersion(j,U.vendor,window.opera),$screen_height:screen.height,$screen_width:screen.width,mp_lib:"web",$lib_version:"1.0.0"})},people_properties:function(){return X.extend(X.strip_empty_properties({$os:X.info.os(),$browser:X.info.browser(j,U.vendor,window.opera)}),{$browser_version:X.info.browserVersion(j,U.vendor,window.opera)})},pageviewInfo:function(e){return X.strip_empty_properties({mp_page:e,mp_referrer:T.referrer,mp_browser:X.info.browser(j,U.vendor,window.opera),mp_platform:X.info.os()})}};var er={log:function(){if(Z&&!X.isUndefined(q)&&q)try{q.log.apply(q,arguments)}catch(e){X.each(arguments,function(e){q.log(e)})}},error:function(){if(Z&&!X.isUndefined(q)&&q){var e=["Alooma error:"].concat(X.toArray(arguments));try{q.error.apply(q,e)}catch(t){X.each(e,function(e){q.error(e)})}}},critical:function(){if(!X.isUndefined(q)&&q){var e=["Alooma error:"].concat(X.toArray(arguments));try{q.error.apply(q,e)}catch(t){X.each(e,function(e){q.error(e)})}}}},ei=function(e){this.props={},this.campaign_params_saved=!1,e.persistence_name?this.name="mp_"+e.persistence_name:this.name="mp_"+e.token+"_alooma";var t=e.persistence;"cookie"!==t&&"localStorage"!==t&&(er.critical('Unknown persistence type "'+t+'"; falling back to "cookie"'),t=e.persistence="cookie"),"localStorage"===t&&function(){var e=!0;try{var t="__mplssupport__";X.localStorage.set(t,"xyz"),"xyz"!==X.localStorage.get(t)&&(e=!1),X.localStorage.remove(t)}catch(r){e=!1}return e||er.error("localStorage unsupported; falling back to cookie store"),e}()?this.storage=X.localStorage:this.storage=X.cookie,this.load(),this.update_config(e),this.upgrade(e),this.save()};ei.prototype.properties=function(){var e={};return X.each(this.props,function(t,r){X.include(R,r)||(e[r]=t)}),e},ei.prototype.load=function(){if(!this.disabled){var e=this.storage.parse(this.name);e&&(this.props=X.extend({},e))}},ei.prototype.upgrade=function(e){var t,r,i=e.upgrade;i&&(t="mp_super_properties","string"==typeof i&&(t=i),r=this.storage.parse(t),this.storage.remove(t),this.storage.remove(t,!0),r&&(this.props=X.extend(this.props,r.all,r.events))),!e.cookie_name&&"alooma"!==e.name&&(t="mp_"+e.token+"_"+e.name,(r=this.storage.parse(t))&&(this.storage.remove(t),this.storage.remove(t,!0),this.register_once(r))),this.storage===X.localStorage&&(r=X.cookie.parse(this.name),X.cookie.remove(this.name),X.cookie.remove(this.name,!0),r&&this.register_once(r))},ei.prototype.save=function(){!this.disabled&&(this._expire_notification_campaigns(),this.storage.set(this.name,X.JSONEncode(this.props),this.expire_days,this.cross_subdomain,this.secure))},ei.prototype.remove=function(){this.storage.remove(this.name,!1),this.storage.remove(this.name,!0)},ei.prototype.clear=function(){this.remove(),this.props={}},ei.prototype.register_once=function(e,t,r){return!!X.isObject(e)&&(void 0===t&&(t="None"),this.expire_days=void 0===r?this.default_expiry:r,X.each(e,function(e,r){this.props[r]&&this.props[r]!==t||(this.props[r]=e)},this),this.save(),!0)},ei.prototype.register=function(e,t){return!!X.isObject(e)&&(this.expire_days=void 0===t?this.default_expiry:t,X.extend(this.props,e),this.save(),!0)},ei.prototype.unregister=function(e){e in this.props&&(delete this.props[e],this.save())},ei.prototype._expire_notification_campaigns=X.safewrap(function(){var e=this.props[V],t=Z?6e4:36e5;if(e){for(var r in e)1*new Date-e[r]>t&&delete e[r];X.isEmptyObject(e)&&delete this.props[V]}}),ei.prototype.update_campaign_params=function(){this.campaign_params_saved||(this.register_once(X.info.campaignParams()),this.campaign_params_saved=!0)},ei.prototype.update_search_keyword=function(e){this.register(X.info.searchInfo(e))},ei.prototype.update_referrer_info=function(e){this.register_once({$initial_referrer:e||"$direct",$initial_referring_domain:X.info.referringDomain(e)||"$direct"},"")},ei.prototype.get_referrer_info=function(){return X.strip_empty_properties({$initial_referrer:this.props.$initial_referrer,$initial_referring_domain:this.props.$initial_referring_domain})},ei.prototype.safe_merge=function(e){return X.each(this.props,function(t,r){r in e||(e[r]=t)}),e},ei.prototype.update_config=function(e){this.default_expiry=this.expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie)},ei.prototype.set_disabled=function(e){this.disabled=e,this.disabled&&this.remove()},ei.prototype.set_cross_subdomain=function(e){e!==this.cross_subdomain&&(this.cross_subdomain=e,this.remove(),this.save())},ei.prototype.get_cross_subdomain=function(){return this.cross_subdomain},ei.prototype.set_secure=function(e){e!==this.secure&&(this.secure=!!e,this.remove(),this.save())},ei.prototype._add_to_people_queue=function(e,t){var r=this._get_queue_key(e),i=t[e],o=this._get_or_create_queue(D),n=this._get_or_create_queue(L),s=this._get_or_create_queue(H),a=this._get_or_create_queue(J),c=this._get_or_create_queue(F,[]);r===M?(X.extend(o,i),this._pop_from_people_queue(H,i),this._pop_from_people_queue(J,i)):r===P?X.each(i,function(e,t){t in n||(n[t]=e)}):r===N?X.each(i,function(e,t){t in o?o[t]+=e:(t in s||(s[t]=0),s[t]+=e)},this):r===I?X.each(i,function(e,t){X.isArray(e)&&(t in a||(a[t]=[]),a[t]=a[t].concat(e))}):r===C&&c.push(i),er.log("ALOOMA PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):"),er.log(t),this.save()},ei.prototype._pop_from_people_queue=function(e,t){var r=this._get_queue(e);X.isUndefined(r)||(X.each(t,function(e,t){delete r[t]},this),this.save())},ei.prototype._get_queue_key=function(e){if(e===D)return M;if(e===L)return P;if(e===H)return N;if(e===F)return C;if(e===J)return I;er.error("Invalid queue:",e)},ei.prototype._get_queue=function(e){return this.props[this._get_queue_key(e)]},ei.prototype._get_or_create_queue=function(e,t){var r=this._get_queue_key(e),t=X.isUndefined(t)?{}:t;return this.props[r]||(this.props[r]=t)},ei.prototype.set_event_timer=function(e,t){var r=this.props[W]||{};r[e]=t,this.props[W]=r,this.save()},ei.prototype.remove_event_timer=function(e){var t=(this.props[W]||{})[e];return X.isUndefined(t)||(delete this.props[W][e],this.save()),t};var eo=function(r,i,o){var n,s=o===B?t:t[o];if(s&&0===e)n=s;else{if(s&&!X.isArray(s)){er.error("You have already initialized "+o);return}n=new en}return n._init(r,i,o),n.people=new es,n.people._init(n),Z=Z||n.get_config("debug"),!X.isUndefined(s)&&X.isArray(s)&&(n._execute_array.call(n.people,s.people),n._execute_array(s)),n},en=function(){};en.prototype.init=function(e,r,i){if(X.isUndefined(i)){er.error("You must name your new library: init(token, config, name)");return}if(i===B){er.error("You must initialize the main alooma object right after you include the Alooma js snippet");return}var o=eo(e,r,i);return t[i]=o,o._loaded(),o},en.prototype._init=function(e,t,r){this.__loaded=!0,this.config={},this.set_config(X.extend({},ee,t,{name:r,token:e,callback_fn:(r===B?r:B+"."+r)+"._jsc"})),this._jsc=function(){},this.__dom_loaded_queue=[],this.__request_queue=[],this.__disabled_events=[],this._flags={disable_all_events:!1,identify_called:!1},this.persistence=this.cookie=new ei(this.config),this.register_once({distinct_id:X.UUID()},"")},en.prototype._loaded=function(){this.get_config("loaded")(this),this.get_config("track_pageview")&&this.track_pageview()},en.prototype._dom_loaded=function(){X.each(this.__dom_loaded_queue,function(e){this._track_dom.apply(this,e)},this),X.each(this.__request_queue,function(e){this._send_request.apply(this,e)},this),delete this.__dom_loaded_queue,delete this.__request_queue},en.prototype._track_dom=function(e,t){if(this.get_config("img"))return er.error("You can't use DOM tracking functions with img = true."),!1;if(!et)return this.__dom_loaded_queue.push([e,t]),!1;var r=new e().init(this);return r.track.apply(r,t)},en.prototype._prepare_callback=function(e,t){if(X.isUndefined(e))return null;if(G)return function(r){e(r,t)};var r=this._jsc,i=""+Math.floor(1e8*Math.random()),o=this.get_config("callback_fn")+'["'+i+'"]';return r[i]=function(o){delete r[i],e(o,t)},o},en.prototype._send_err=function(e,t,r,i){try{i||(t.error=t.error||"timeout",this._send_request(e,t,r,!0))}catch(o){}},en.prototype._send_fb=function(e){try{var t=new XMLHttpRequest,r=this.get_config("api_host"),i=this.get_config("fb_host");e=e.replace(r,i),t.withCredentials=!0,t.open("GET",e,!0),t.send(null)}catch(o){}},en.prototype._send_request=function(e,t,r,i){if(K){this.__request_queue.push(arguments);return}var o=this.get_config("verbose");t.verbose&&(o=!0),this.get_config("test")&&(t.test=1),o&&(t.verbose=1),this.get_config("img")&&(t.img=1),!G&&(r?t.callback=r:(o||this.get_config("test"))&&(t.callback="(function(){})")),t.ip=this.get_config("ip")?1:0,t._=new Date().getTime().toString(),e+="?"+X.HTTPBuildQuery(t);var n=null;if("img"in t){var s=T.createElement("img");s.src=e,T.body.appendChild(s)}else if(G){var a=new XMLHttpRequest;i||(n=setTimeout((function(){this._send_err(e,t,r)}).bind(this),4e3)),a.withCredentials=!0,a.onreadystatechange=(function(s){if(4===a.readyState){if(n&&clearTimeout(n),200===a.status)r&&(o?r(X.JSONDecode(a.responseText)):r(Number(a.responseText)));else{var c="Bad HTTP status: "+a.status+" "+a.statusText;t.error=c,this._send_err(e,t,r,i),er.error(c),r&&(o?r({status:0,error:c}):r(0))}}}).bind(this),a.open("GET",e,!0),a.send(null),this.get_config("fb_host")&&this._send_fb(e)}else{var c=T.createElement("script");c.type="text/javascript",c.async=!0,c.defer=!0,c.src=e;var p=T.getElementsByTagName("script")[0];p.parentNode.insertBefore(c,p)}},en.prototype._execute_array=function(e){var t,r=[],i=[],o=[];X.each(e,function(e){e&&(t=e[0],"function"==typeof e?e.call(this):X.isArray(e)&&"alias"===t?r.push(e):X.isArray(e)&&-1!=t.indexOf("track")&&"function"==typeof this[t]?o.push(e):i.push(e))},this);var n=function(e,t){X.each(e,function(e){this[e[0]].apply(this,e.slice(1))},t)};n(r,this),n(i,this),n(o,this)},en.prototype.push=function(e){this._execute_array([e])},en.prototype.disable=function(e){void 0===e?this._flags.disable_all_events=!0:this.__disabled_events=this.__disabled_events.concat(e)},en.prototype.track=function(e,t,r){if(X.isUndefined(e)){er.error("No event name provided to alooma.track");return}if(this._event_is_disabled(e)){void 0!==r&&r(0);return}(t=t||{}).token=this.get_config("token");var i=this.persistence.remove_event_timer(e);if(!X.isUndefined(i)){var o=new Date().getTime()-i;t.$duration=parseFloat((o/1e3).toFixed(3))}this.persistence.update_search_keyword(T.referrer),this.get_config("store_google")&&this.persistence.update_campaign_params(),this.get_config("save_referrer")&&this.persistence.update_referrer_info(T.referrer),t=X.extend({},X.info.properties(),this.persistence.properties(),t);var n=this.get_config("property_blacklist");X.isArray(n)?X.each(n,function(e){delete t[e]}):er.error("Invalid value for property_blacklist config: "+n);var s={event:e,properties:t},a=X.truncate(s,255),c=X.JSONEncode(a),p=X.base64Encode(c);return er.log("ALOOMA REQUEST:"),er.log(a),this._send_request(this.get_config("api_host")+"/track/",{data:p},this._prepare_callback(r,a)),a},en.prototype.track_pageview=function(e){X.isUndefined(e)&&(e=T.location.href),this.track("mp_page_view",X.info.pageviewInfo(e))},en.prototype.time_event=function(e){if(X.isUndefined(e)){er.error("No event name provided to alooma.time_event");return}!this._event_is_disabled(e)&&this.persistence.set_event_timer(e,new Date().getTime())},en.prototype.register=function(e,t){this.persistence.register(e,t)},en.prototype.register_once=function(e,t,r){this.persistence.register_once(e,t,r)},en.prototype.unregister=function(e){this.persistence.unregister(e)},en.prototype._register_single=function(e,t){var r={};r[e]=t,this.register(r)},en.prototype.identify=function(e,t,r,i,o,n){e!=this.get_distinct_id()&&e!=this.get_property(Q)&&(this.unregister(Q),this._register_single("distinct_id",e)),this._check_and_handle_notifications(this.get_distinct_id()),this._flags.identify_called=!0,this.people._flush(t,r,i,o,n)},en.prototype.get_distinct_id=function(){return this.get_property("distinct_id")},en.prototype.alias=function(e,t){if(e===this.get_property(z))return er.critical("Attempting to create alias for existing People user - aborting."),-2;var r=this;return(X.isUndefined(t)&&(t=this.get_distinct_id()),e!==t)?(this._register_single(Q,e),this.track("$create_alias",{alias:e,distinct_id:t},function(t){r.identify(e)})):(er.error("alias matches current distinct_id - skipping api call."),this.identify(e),-1)},en.prototype.name_tag=function(e){this._register_single("mp_name_tag",e)},en.prototype.set_config=function(e){X.isObject(e)&&(X.extend(this.config,e),this.get_config("persistence_name")||(this.config.persistence_name=this.config.cookie_name),this.get_config("disable_persistence")||(this.config.disable_persistence=this.config.disable_cookie),this.persistence&&this.persistence.update_config(this.config),Z=Z||this.get_config("debug"))},en.prototype.get_config=function(e){return this.config[e]},en.prototype.get_property=function(e){return this.persistence.props[e]},en.prototype.toString=function(){var e=this.get_config("name");return e!==B&&(e=B+"."+e),e},en.prototype._event_is_disabled=function(e){return X.isBlockedUA(j)||this._flags.disable_all_events||X.include(this.__disabled_events,e)},en.prototype._check_and_handle_notifications=function(e){if(!(!e||this._flags.identify_called||this.get_config("disable_notifications"))){er.log("ALOOMA NOTIFICATION CHECK");var t={verbose:!0,version:"1",lib:"web",token:this.get_config("token"),distinct_id:e},r=this;this._send_request(this.get_config("api_host")+"/decide/",t,this._prepare_callback(function(e){e.notifications&&e.notifications.length>0&&r._show_notification.call(r,e.notifications[0])}))}},en.prototype._show_notification=function(e){};var es=function(){};es.prototype._init=function(e){this._alooma=e},es.prototype.set=function(e,t,r){var i={},o={};return X.isObject(e)?(X.each(e,function(e,t){this._is_reserved_property(t)||(o[t]=e)},this),r=t):o[e]=t,this._get_config("save_referrer")&&this._alooma.persistence.update_referrer_info(T.referrer),o=X.extend({},X.info.people_properties(),this._alooma.persistence.get_referrer_info(),o),i[D]=o,this._send_request(i,r)},es.prototype.set_once=function(e,t,r){var i={},o={};return X.isObject(e)?(X.each(e,function(e,t){this._is_reserved_property(t)||(o[t]=e)},this),r=t):o[e]=t,i[L]=o,this._send_request(i,r)},es.prototype.increment=function(e,t,r){var i={},o={};return X.isObject(e)?(X.each(e,function(e,t){this._is_reserved_property(t)||(isNaN(parseFloat(e))?er.error("Invalid increment value passed to alooma.people.increment - must be a number"):o[t]=e)},this),r=t):(X.isUndefined(t)&&(t=1),o[e]=t),i[H]=o,this._send_request(i,r)},es.prototype.append=function(e,t,r){var i={},o={};return X.isObject(e)?(X.each(e,function(e,t){this._is_reserved_property(t)||(o[t]=e)},this),r=t):o[e]=t,i[F]=o,this._send_request(i,r)},es.prototype.union=function(e,t,r){var i={},o={};return X.isObject(e)?(X.each(e,function(e,t){this._is_reserved_property(t)||(o[t]=X.isArray(e)?e:[e])},this),r=t):o[e]=X.isArray(t)?t:[t],i[J]=o,this._send_request(i,r)},es.prototype.track_charge=function(e,t,r){if(!X.isNumber(e)&&isNaN(e=parseFloat(e))){er.error("Invalid value passed to alooma.people.track_charge - must be a number");return}return this.append("$transactions",X.extend({$amount:e},t),r)},es.prototype.clear_charges=function(e){return this.set("$transactions",[],e)},es.prototype.delete_user=function(){if(!this._identify_called()){er.error("alooma.people.delete_user() requires you to call identify() first");return}var e={$delete:this._alooma.get_distinct_id()};return this._send_request(e)},es.prototype.toString=function(){return this._alooma.toString()+".people"},es.prototype._send_request=function(e,t){e.$token=this._get_config("token"),e.$distinct_id=this._alooma.get_distinct_id();var r=X.encodeDates(e),i=X.truncate(r,255),o=X.JSONEncode(r),n=X.base64Encode(o);return this._identify_called()?(er.log("ALOOMA PEOPLE REQUEST:"),er.log(i),this._alooma._send_request(this._get_config("api_host")+"/engage/",{data:n},this._alooma._prepare_callback(t,i)),i):(this._enqueue(e),X.isUndefined(t)||t(this._get_config("verbose")?{status:-1,error:null}:-1),i)},es.prototype._get_config=function(e){return this._alooma.get_config(e)},es.prototype._identify_called=function(){return!0===this._alooma._flags.identify_called},es.prototype._enqueue=function(e){D in e?this._alooma.persistence._add_to_people_queue(D,e):L in e?this._alooma.persistence._add_to_people_queue(L,e):H in e?this._alooma.persistence._add_to_people_queue(H,e):F in e?this._alooma.persistence._add_to_people_queue(F,e):J in e?this._alooma.persistence._add_to_people_queue(J,e):er.error("Invalid call to _enqueue():",e)},es.prototype._flush=function(e,t,r,i,o){var n=this,s=X.extend({},this._alooma.persistence._get_queue(D)),a=X.extend({},this._alooma.persistence._get_queue(L)),c=X.extend({},this._alooma.persistence._get_queue(H)),p=this._alooma.persistence._get_queue(F),u=X.extend({},this._alooma.persistence._get_queue(J));if(!X.isUndefined(s)&&X.isObject(s)&&!X.isEmptyObject(s)&&(n._alooma.persistence._pop_from_people_queue(D,s),this.set(s,function(t,r){0==t&&n._alooma.persistence._add_to_people_queue(D,s),X.isUndefined(e)||e(t,r)})),!X.isUndefined(a)&&X.isObject(a)&&!X.isEmptyObject(a)&&(n._alooma.persistence._pop_from_people_queue(L,a),this.set_once(a,function(e,t){0==e&&n._alooma.persistence._add_to_people_queue(L,a),X.isUndefined(i)||i(e,t)})),!X.isUndefined(c)&&X.isObject(c)&&!X.isEmptyObject(c)&&(n._alooma.persistence._pop_from_people_queue(H,c),this.increment(c,function(e,r){0==e&&n._alooma.persistence._add_to_people_queue(H,c),X.isUndefined(t)||t(e,r)})),!X.isUndefined(u)&&X.isObject(u)&&!X.isEmptyObject(u)&&(n._alooma.persistence._pop_from_people_queue(J,u),this.union(u,function(e,t){0==e&&n._alooma.persistence._add_to_people_queue(J,u),X.isUndefined(o)||o(e,t)})),!X.isUndefined(p)&&X.isArray(p)&&p.length){for(var f=p.length-1;f>=0;f--){var l=p.pop();n.append(l,function(e,t){0==e&&n._alooma.persistence._add_to_people_queue(F,l),X.isUndefined(r)||r(e,t)})}n._alooma.persistence.save()}},es.prototype._is_reserved_property=function(e){return"$distinct_id"===e||"$token"===e},en._Notification=function(e,t){X.bind_instance_methods(this),this.alooma=t,this.persistence=this.alooma.persistence,this.campaign_id=X.escapeHTML(e.id),this.message_id=X.escapeHTML(e.message_id),this.body=(X.escapeHTML(e.body)||"").replace(/\n/g,"
"),this.cta=X.escapeHTML(e.cta)||"Close",this.dest_url=X.escapeHTML(e.cta_url)||null,this.image_url=X.escapeHTML(e.image_url)||null,this.notif_type=X.escapeHTML(e.type)||"takeover",this.style=X.escapeHTML(e.style)||"light",this.thumb_image_url=X.escapeHTML(e.thumb_image_url)||null,this.title=X.escapeHTML(e.title)||"",this.video_url=X.escapeHTML(e.video_url)||null,this.clickthrough=!0,this.dest_url||(this.dest_url="#dismiss",this.clickthrough=!1),this.mini="mini"===this.notif_type,this.mini||(this.notif_type="takeover"),this._set_client_config(),this.imgs_to_preload=this._init_image_html(),this._init_video()},X.toArray=X.toArray,X.isObject=X.isObject,X.JSONEncode=X.JSONEncode,X.JSONDecode=X.JSONDecode,X.isBlockedUA=X.isBlockedUA,X.isEmptyObject=X.isEmptyObject,X.info=X.info,X.info.device=X.info.device,X.info.browser=X.info.browser,X.info.properties=X.info.properties,en.prototype.init=en.prototype.init,en.prototype.disable=en.prototype.disable,en.prototype.time_event=en.prototype.time_event,en.prototype.track=en.prototype.track,en.prototype.track_custom_event=en.prototype.track_custom_event,en.prototype.track_links=en.prototype.track_links,en.prototype.track_forms=en.prototype.track_forms,en.prototype.track_pageview=en.prototype.track_pageview,en.prototype.register=en.prototype.register,en.prototype.register_once=en.prototype.register_once,en.prototype.unregister=en.prototype.unregister,en.prototype.identify=en.prototype.identify,en.prototype.alias=en.prototype.alias,en.prototype.name_tag=en.prototype.name_tag,en.prototype.set_config=en.prototype.set_config,en.prototype.get_config=en.prototype.get_config,en.prototype.get_property=en.prototype.get_property,en.prototype.get_distinct_id=en.prototype.get_distinct_id,en.prototype.toString=en.prototype.toString,en.prototype._check_and_handle_notifications=en.prototype._check_and_handle_notifications,en.prototype._show_notification=en.prototype._show_notification,ei.prototype.properties=ei.prototype.properties,ei.prototype.update_search_keyword=ei.prototype.update_search_keyword,ei.prototype.update_referrer_info=ei.prototype.update_referrer_info,ei.prototype.get_cross_subdomain=ei.prototype.get_cross_subdomain,ei.prototype.clear=ei.prototype.clear,es.prototype.set=es.prototype.set,es.prototype.set_once=es.prototype.set_once,es.prototype.increment=es.prototype.increment,es.prototype.append=es.prototype.append,es.prototype.union=es.prototype.union,es.prototype.track_charge=es.prototype.track_charge,es.prototype.clear_charges=es.prototype.clear_charges,es.prototype.delete_user=es.prototype.delete_user,es.prototype.toString=es.prototype.toString,X.safewrap_class(en,["identify","_check_and_handle_notifications","_show_notification"]);var ea={},ec=function(){X.each(ea,function(e,r){r!==B&&(t[r]=e)}),t._=X},ep=function(){t.init=function(r,i,o){if(o)return t[o]||(t[o]=ea[o]=eo(r,i,o),t[o]._loaded()),t[o];var n=t;ea[B]?n=ea[B]:r&&((n=eo(r,i,B))._loaded(),ea[B]=n),t=n,1===e&&(window[B]=t),ec()}},eu=function(){function e(){!e.done&&(e.done=!0,et=!0,K=!1,X.each(ea,function(e){e._dom_loaded()}))}if(T.addEventListener)"complete"==T.readyState?e():T.addEventListener("DOMContentLoaded",e,!1);else if(T.attachEvent){T.attachEvent("onreadystatechange",e);var t=!1;try{t=null==window.frameElement}catch(r){}T.documentElement.doScroll&&t&&function t(){try{T.documentElement.doScroll("left")}catch(r){setTimeout(t,1);return}e()}()}X.register_event(window,"load",e,!0)};!function r(){if(e=1,t=window[B],X.isUndefined(t)){er.critical("'alooma' object not initialized. Ensure you are using the latest version of the Alooma JS Library along with the snippet we provide.");return}if(t.__loaded||t.config&&t.persistence){er.error("Alooma library has already been downloaded at least once.");return}if(1.1>(t.__SV||0)){er.critical("Version mismatch; please ensure you're using the latest version of the Alooma code snippet.");return}X.each(t._i,function(e){e&&X.isArray(e)&&(ea[e[e.length-1]]=eo.apply(this,e))}),ep(),t.init(),X.each(ea,function(e){e._loaded()}),eu()}()}();