(function e(b,g,d){function c(m,j){if(!g[m]){if(!b[m]){var i=typeof require=="function"&&require;if(!j&&i){return i(m,!0)}if(a){return a(m,!0)}var k=new Error("Cannot find module '"+m+"'");throw k.code="MODULE_NOT_FOUND",k}var h=g[m]={exports:{}};b[m][0].call(h.exports,function(l){var o=b[m][1][l];return c(o?o:l)},h,h.exports,e,b,g,d)}return g[m].exports}var a=typeof require=="function"&&require;for(var f=0;f or
DOM element")}}if(s){v=function(){if(!n){n=true;s()}}}this.recordEvent(l,t,v);setTimeout(v,m);if(!u.metaKey){return false}}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(m){var l=this.length>>>0;var n=Number(arguments[1])||0;n=(n<0)?Math.ceil(n):Math.floor(n);if(n<0){n+=l}for(;n0){o=JSON.parse(JSON.stringify(n.queue));n.queue=h();n.queue.options=o.options;n.emit("recordDeferredEvents",o.events);n.recordEvents(o.events,function(q,p){if(q){n.recordEvents(o.events)}else{o=void 0}})}return n}function i(o){var n="Event(s) not deferred: "+o;this.emit("error",n)}},{"./index":10,"./utils/each":15,"./utils/queue":18}],3:[function(d,c,g){var f=d("./utils/deepExtend");var i=d("./utils/each");c.exports={extendEvent:b,extendEvents:j,getExtendedEventBody:a};function b(k,l){if(arguments.length!==2||typeof k!=="string"||("object"!==typeof l&&"function"!==typeof l)){h.call(this,"Incorrect arguments provided to #extendEvent method");return}this.extensions.collections[k]=this.extensions.collections[k]||[];this.extensions.collections[k].push(l);this.emit("extendEvent",k,l);return this}function j(k){if(arguments.length!==1||("object"!==typeof k&&"function"!==typeof k)){h.call(this,"Incorrect arguments provided to #extendEvents method");return}this.extensions.events.push(k);this.emit("extendEvents",k);return this}function h(l){var k="Event(s) not extended: "+l;this.emit("error",k)}function a(l,k){if(k&&k.length>0){i(k,function(o,n){var m=(typeof o==="function")?o():o;f(l,m)})}return l}},{"./utils/deepExtend":14,"./utils/each":15}],4:[function(d,f,b){var a=d("./getScreenProfile"),g=d("./getWindowProfile");function c(){return{cookies:("undefined"!==typeof navigator.cookieEnabled)?navigator.cookieEnabled:false,codeName:navigator.appCodeName,language:navigator.language,name:navigator.appName,online:navigator.onLine,platform:navigator.platform,useragent:navigator.userAgent,version:navigator.appVersion,screen:a(),window:g()}}f.exports=c},{"./getScreenProfile":7,"./getWindowProfile":9}],5:[function(b,c,a){function d(f){var g=f||new Date();return{hour_of_day:g.getHours(),day_of_week:parseInt(1+g.getDay()),day_of_month:g.getDate(),month:parseInt(1+g.getMonth()),year:g.getFullYear()}}c.exports=d},{}],6:[function(c,d,a){function b(l){if(!l.nodeName){return""}var f=[];while(l.parentNode!=null){var k=0;var g=0;for(var j=0;j1){f.unshift(l.nodeName.toLowerCase()+":eq("+g+")")}else{f.unshift(l.nodeName.toLowerCase())}}l=l.parentNode}return f.slice(1).join(" > ")}d.exports=b},{}],7:[function(c,d,b){function a(){var h,f;if("undefined"==typeof window||!window.screen){return{}}h=["height","width","colorDepth","pixelDepth","availHeight","availWidth"];f={};for(var g=0;gwindow.innerHeight?"landscape":"portrait"};return f}d.exports=a},{}],8:[function(b,c,a){function d(){var f="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";return f.replace(/[xy]/g,function(i){var h=Math.random()*16|0,g=i=="x"?h:(h&3|8);return g.toString(16)})}c.exports=d},{}],9:[function(b,c,a){function d(){var f,h,g;if("undefined"==typeof document){return{}}f=document.body;h=document.documentElement;g={height:("innerHeight" in window)?window.innerHeight:document.documentElement.offsetHeight,width:("innerWidth" in window)?window.innerWidth:document.documentElement.offsetWidth,scrollHeight:Math.max(f.scrollHeight,f.offsetHeight,h.clientHeight,h.scrollHeight,h.offsetHeight)||null};if(window.screen){g.ratio={height:(window.screen.availHeight)?parseFloat((window.innerHeight/window.screen.availHeight).toFixed(2)):null,width:(window.screen.availWidth)?parseFloat((window.innerWidth/window.screen.availWidth).toFixed(2)):null}}return g}c.exports=d},{}],10:[function(d,f,c){var b=d("keen-core");var g=d("./utils/each"),h=d("./utils/extend"),a=d("./utils/queue");b.helpers=b.helpers||{};b.resources.events="{protocol}://{host}/3.0/projects/{projectId}/events";b.on("client",function(i){i.extensions={events:[],collections:{}};i.queue=a();i.queue.on("flush",function(){i.recordDeferredEvents()})});b.prototype.writeKey=function(i){if(!arguments.length){return this.config.writeKey}this.config.writeKey=(i?String(i):null);return this};b.prototype.setGlobalProperties=function(i){b.log("This method has been deprecated. Check out #extendEvents: https://github.com/keen/keen-tracking.js#extend-events");if(!i||typeof i!=="function"){this.emit("error","Invalid value for global properties: "+i);return}this.config.globalProperties=i;return this};f.exports=b},{"./utils/each":15,"./utils/extend":16,"./utils/queue":18,"keen-core":22}],11:[function(h,d,v){var c=h("./index");var b=h("./utils/base64");var f=h("./utils/each");var r=h("./utils/extend");var q=h("./extend-events");d.exports={recordEvent:k,recordEvents:i,addEvent:n,addEvents:l};function k(w,F,E,z){var x,C,A,G,B,D,y;x=this.url("events",encodeURIComponent(w));C={};A=E;y=("boolean"===typeof z)?z:true;if(!t.call(this,A)){return}if(!w||typeof w!=="string"){m.call(this,"Collection name must be a string.",A);return}if(this.config.globalProperties){C=this.config.globalProperties(w)}r(C,F);D={};q.getExtendedEventBody(D,this.extensions.events);q.getExtendedEventBody(D,this.extensions.collections[w]);q.getExtendedEventBody(D,[C]);this.emit("recordEvent",w,D);if(!c.enabled){m.call(this,"Keen.enabled is set to false.",A);return false}G=this.url("events",encodeURIComponent(w),{api_key:this.writeKey(),data:b.encode(JSON.stringify(D)),modified:new Date().getTime()});B=G.length2){m.call(this,"Incorrect arguments provided to #recordEvents method",w);return}if(this.config.globalProperties){f(A,function(C,D){f(C,function(E,G){var F=x.config.globalProperties(D);A[D][G]=r(F,E)})})}y={};f(A,function(D,C){y[C]=y[C]||[];f(D,function(G,F){var E={};q.getExtendedEventBody(E,x.extensions.events);q.getExtendedEventBody(E,x.extensions.collections[C]);q.getExtendedEventBody(E,[G]);y[C].push(E)})});this.emit("recordEvents",y);if(!c.enabled){m.call(this,"Keen.enabled is set to false.",w);return false}if(p()){u.call(this,"POST",z,y,w)}else{}B=w=null;return this}function n(){this.emit("error","This method has been deprecated. Check out #recordEvent: https://github.com/keen/keen-tracking.js#record-a-single-event");k.apply(this,arguments)}function l(){this.emit("error","This method has been deprecated. Check out #recordEvents: https://github.com/keen/keen-tracking.js#record-multiple-events");i.apply(this,arguments)}function t(x){var w=x;x=null;if(!this.projectId()){m.call(this,"Keen.Client is missing a projectId property.",w);return false}if(!this.writeKey()){m.call(this,"Keen.Client is missing a writeKey property.",w);return false}return true}function m(y,w){var x="Event(s) not recorded: "+y;this.emit("error",x);if(w){w.call(this,x,null);w=null}}function s(){if("undefined"!==typeof window){if(navigator.userAgent.indexOf("MSIE")!==-1||navigator.appVersion.indexOf("Trident/")>0){return 2000}}return 16000}function o(w,y,x,z){if(p()){u.call(this,"POST",w,y,z)}else{m.call(this,x)}}function u(D,y,z,C){var x=this;var A;var B=p();var w=C;C=null;B.onreadystatechange=function(){var E;if(B.readyState==4){if(B.status>=200&&B.status<300){try{E=JSON.parse(B.responseText)}catch(F){c.emit("error","Could not parse HTTP response: "+B.responseText);if(w){w.call(x,B,null)}}if(w&&E){w.call(x,null,E)}}else{c.emit("error","HTTP request failed.");if(w){w.call(x,B,null)}}}};B.open(D,y,true);B.setRequestHeader("Authorization",x.writeKey());B.setRequestHeader("Content-Type","application/json");if(z){A=JSON.stringify(z)}if(D.toUpperCase()==="GET"){B.send()}if(D.toUpperCase()==="POST"){B.send(A)}}function a(w){var x=p();if(x){x.open("GET",w,false);x.send(null)}}function p(){var w="undefined"==typeof window?this:window;if(w.XMLHttpRequest&&("file:"!=w.location.protocol||!w.ActiveXObject)){return new XMLHttpRequest}else{try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(x){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(x){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(x){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(x){}}return false}function g(w,F){var G=this,z=F,B=new Date().getTime(),D=document.createElement("script"),E=document.getElementsByTagName("head")[0],C="keenJSONPCallback",A=false;F=null;C+=B;while(C in window){C+="a"}window[C]=function(H){if(A===true){return}A=true;if(z){z.call(G,null,H)}x()};D.src=w+"&jsonp="+C;E.appendChild(D);D.onreadystatechange=function(){if(A===false&&this.readyState==="loaded"){A=true;y();x()}};D.onerror=function(){if(A===false){A=true;y();x()}};function y(){if(z){z.call(G,"An error occurred!",null)}}function x(){window[C]=undefined;try{delete window[C]}catch(H){}E.removeChild(D)}}function j(A,B){var y=this,w=B,x=document.createElement("img"),z=false;B=null;x.onload=function(){z=true;if("naturalHeight" in this){if(this.naturalHeight+this.naturalWidth===0){this.onerror();return}}else{if(this.width+this.height===0){this.onerror();return}}if(w){w.call(y)}};x.onerror=function(){z=true;if(w){w.call(y,"An error occurred!",null)}};x.src=A+"&c=clv1"}},{"./extend-events":3,"./index":10,"./utils/base64":12,"./utils/each":15,"./utils/extend":16}],12:[function(b,c,a){c.exports=b("keen-core/lib/utils/base64")},{"keen-core/lib/utils/base64":23}],13:[function(b,f,a){var d=b("js-cookie");var g=b("./extend");f.exports=c;function c(h){if(!arguments.length){return}if(this instanceof c===false){return new c(h)}this.config={key:h,options:{expires:365}};this.data=this.get();return this}c.prototype.get=function(i){var h={};if(d.get(this.config.key)){h=d.getJSON(this.config.key)}if(i&&typeof h==="object"&&typeof h!==null){return(typeof h[i]!=="undefined")?h[i]:null}else{return h}};c.prototype.set=function(i,h){if(!arguments.length||!this.enabled()){return this}if(typeof i==="string"&&arguments.length===2){this.data[i]=h?h:null}else{if(typeof i==="object"&&arguments.length===1){g(this.data,i)}}d.set(this.config.key,this.data,this.config.options);return this};c.prototype.expire=function(h){if(h){d.set(this.config.key,this.data,g(this.config.options,{expires:h}))}else{d.remove(this.config.key);this.data={}}return this};c.prototype.options=function(h){if(!arguments.length){return this.config.options}this.config.options=(typeof h==="object")?h:{};return this};c.prototype.enabled=function(){return navigator.cookieEnabled}},{"./extend":16,"js-cookie":21}],14:[function(c,d,a){d.exports=b;function b(k){for(var h=1;h0&&this.interval>=this.config.interval)||this.capacity>=this.config.capacity){this.emit("flush");this.interval=0}}f(a.prototype)},{"component-emitter":20}],19:[function(b,c,a){c.exports=d;function d(f){if(this instanceof d===false){return new d(f)}this.count=f||0;return this}d.prototype.start=function(){var f=this;this.pause();this.interval=setInterval(function(){f.count++},1000);return this};d.prototype.pause=function(){clearInterval(this.interval);return this};d.prototype.value=function(){return this.count};d.prototype.clear=function(){this.count=0;return this}},{}],20:[function(c,d,b){d.exports=f;function f(g){if(g){return a(g)}}function a(h){for(var g in f.prototype){h[g]=f.prototype[g]}return h}f.prototype.on=f.prototype.addEventListener=function(h,g){this._callbacks=this._callbacks||{};(this._callbacks["$"+h]=this._callbacks["$"+h]||[]).push(g);return this};f.prototype.once=function(i,h){function g(){this.off(i,g);h.apply(this,arguments)}g.fn=h;this.on(i,g);return this};f.prototype.off=f.prototype.removeListener=f.prototype.removeAllListeners=f.prototype.removeEventListener=function(l,j){this._callbacks=this._callbacks||{};if(0==arguments.length){this._callbacks={};return this}var k=this._callbacks["$"+l];if(!k){return this}if(1==arguments.length){delete this._callbacks["$"+l];return this}var g;for(var h=0;h1){n=f({path:"/"},g.defaults,n);if(typeof n.expires==="number"){var l=new Date();l.setMilliseconds(l.getMilliseconds()+n.expires*86400000);n.expires=l}try{u=JSON.stringify(q);if(/^[\{\[]/.test(u)){q=u}}catch(p){}if(!h.write){q=encodeURIComponent(String(q)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)}else{q=h.write(q,r)}r=encodeURIComponent(String(r));r=r.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent);r=r.replace(/[\(\)]/g,escape);return(document.cookie=[r,"=",q,n.expires&&"; expires="+n.expires.toUTCString(),n.path&&"; path="+n.path,n.domain&&"; domain="+n.domain,n.secure?"; secure":""].join(""))}if(!r){u={}}var t=document.cookie?document.cookie.split("; "):[];var s=/(%[0-9A-Z]{2})+/g;var o=0;for(;o-1){p.protocol=document.location.protocol.replace(":","")}if(p.host){p.host.replace(/.*?:\/\//g,"")}j(this.config,p);return this};o.prototype.masterKey=function(p){if(!arguments.length){return this.config.masterKey}this.config.masterKey=p?String(p):null;return this};o.prototype.projectId=function(p){if(!arguments.length){return this.config.projectId}this.config.projectId=(p?String(p):null);return this};o.prototype.resources=function(q){if(!arguments.length){return this.config.resources}var p=this;if(typeof q==="object"){i(q,function(s,r){p.config.resources[r]=(s?s:null)})}return p};o.prototype.url=function(q){var p=Array.prototype.slice.call(arguments,1),r=o.resources.base||"{protocol}://{host}",s;if(q&&typeof q==="string"){if(this.config.resources[q]){s=this.config.resources[q]}else{s=r+q}}else{s=r}i(this.config,function(u,t){if(typeof u!=="object"){s=s.replace("{"+t+"}",u)}});i(p,function(t,u){if(typeof t==="string"){s+="/"+t}else{if(typeof t==="object"){s+="?";i(t,function(w,v){s+=v+"="+w+"&"});s=s.slice(0,-1)}}});return s};l(function(){o.loaded=true;o.emit("ready")});function l(q){if(o.loaded||typeof document==="undefined"){q();return}if(document.readyState==null&&document.addEventListener){document.addEventListener("DOMContentLoaded",function p(){document.removeEventListener("DOMContentLoaded",p,false);document.readyState="complete"},false);document.readyState="loading"}k(q)}function k(p){if(/in/.test(document.readyState)){setTimeout(function(){k(p)},9)}else{p()}}if(m){m.Keen=o}if(typeof c!=="undefined"&&c.exports){c.exports=o}}).call(this,typeof window!=="undefined"?window:typeof g!=="undefined"?g:typeof self!=="undefined"?self:{})}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./utils/each":24,"./utils/extend":25,"./utils/parse-params":26,"./utils/serialize":27,"component-emitter":20}],23:[function(b,c,a){c.exports={map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(f){var d="",l=0,h=this.map,k,j,g,s,r,q,p;f=this.utf8.encode(f);while(l>2);r=(((k&3)<<4)|(j>>4));q=(isNaN(j)?64:((j&15)<<2)|(g>>6));p=(isNaN(j)||isNaN(g))?64:g&63;d=d+h.charAt(s)+h.charAt(r)+h.charAt(q)+h.charAt(p)}return d},decode:function(f){var d="",p=0,h=this.map,g=String.fromCharCode,t,s,r,q,l,k,j;f=f.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(p>4);k=((s&15)<<4)|(r>>2);j=((r&3)<<6)|q;d=d+(g(l)+((r!=64)?g(k):""))+(((q!=64)?g(j):""))}return this.utf8.decode(d)},utf8:{encode:function(j){var f="",d=0,h=String.fromCharCode,g;while(d127)&&(g<2048))?(h((g>>6)|192)+h((g&63)|128)):(h((g>>12)|224)+h(((g>>6)&63)|128)+h((g&63)|128)))}return f},decode:function(k){var g="",f=0,j=String.fromCharCode,d,h;while(f191)&&(h<224))?[j(((h&31)<<6)|((d=k.charCodeAt(f+1))&63)),(f+=2)][0]:[j(((h&15)<<12)|(((d=k.charCodeAt(f+1))&63)<<6)|((c3=k.charCodeAt(f+2))&63)),(f+=3)][0])}return g}}}},{}],24:[function(b,c,a){c.exports=d;function d(h,f,g){var i;if(!h){return 0}g=!g?h:g;if(h instanceof Array){for(i=0;i