@snowplow/browser-tracker
Version:
Browser tracker for Snowplow
103 lines (102 loc) • 50.1 kB
JavaScript
/*!
* Browser tracker for Snowplow v4.5.0 (http://bit.ly/sp-js)
* Copyright 2022 Snowplow Analytics Ltd, 2010 Anthon Pang
* Licensed under BSD-3-Clause
*/
'use strict';(function(x,ka){"object"===typeof exports&&"undefined"!==typeof module?ka(exports):"function"===typeof define&&define.amd?define(["exports"],ka):(x="undefined"!==typeof globalThis?globalThis:x||self,ka(x.snowplowBrowserTracking={}))})(this,function(x){function ka(a,b,c,d){function f(h){return h instanceof c?h:new c(function(g){g(h)})}return new (c||(c=Promise))(function(h,g){function k(p){try{m(d.next(p))}catch(u){g(u)}}function l(p){try{m(d["throw"](p))}catch(u){g(u)}}function m(p){p.done?
h(p.value):f(p.value).then(k,l)}m((d=d.apply(a,b||[])).next())})}function Ma(a,b){function c(m){return function(p){return d([m,p])}}function d(m){if(h)throw new TypeError("Generator is already executing.");for(;l&&(l=0,m[0]&&(f=0)),f;)try{if(h=1,g&&(k=m[0]&2?g["return"]:m[0]?g["throw"]||((k=g["return"])&&k.call(g),0):g.next)&&!(k=k.call(g,m[1])).done)return k;if(g=0,k)m=[m[0]&2,k.value];switch(m[0]){case 0:case 1:k=m;break;case 4:return f.label++,{value:m[1],done:!1};case 5:f.label++;g=m[1];m=[0];
continue;case 7:m=f.ops.pop();f.trys.pop();continue;default:if(!(k=f.trys,k=0<k.length&&k[k.length-1])&&(6===m[0]||2===m[0])){f=0;continue}if(3===m[0]&&(!k||m[1]>k[0]&&m[1]<k[3]))f.label=m[1];else if(6===m[0]&&f.label<k[1])f.label=k[1],k=m;else if(k&&f.label<k[2])f.label=k[2],f.ops.push(m);else{k[2]&&f.ops.pop();f.trys.pop();continue}}m=b.call(a,f)}catch(p){m=[6,p],g=0}finally{h=k=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}var f={label:0,sent:function(){if(k[0]&1)throw k[1];return k[1]},
trys:[],ops:[]},h,g,k,l=Object.create(("function"===typeof Iterator?Iterator:Object).prototype);return l.next=c(0),l["throw"]=c(1),l["return"]=c(2),"function"===typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l}function aa(a,b,c){if(c||2===arguments.length)for(var d=0,f=b.length,h;d<f;d++)!h&&d in b||(h||(h=Array.prototype.slice.call(b,0,d)),h[d]=b[d]);return a.concat(h||Array.prototype.slice.call(b))}function Rc(a,b=0){return(N[a[b+0]]+N[a[b+1]]+N[a[b+2]]+N[a[b+3]]+"-"+N[a[b+4]]+N[a[b+
5]]+"-"+N[a[b+6]]+N[a[b+7]]+"-"+N[a[b+8]]+N[a[b+9]]+"-"+N[a[b+10]]+N[a[b+11]]+N[a[b+12]]+N[a[b+13]]+N[a[b+14]]+N[a[b+15]]).toLowerCase()}function Sc(){if(!Xa&&(Xa="undefined"!==typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Xa))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Xa(Tc)}function la(a,b,c){if(bc.randomUUID&&!b&&!a)return bc.randomUUID();a=a||{};a=a.random||(a.rng||Sc)();a[6]=a[6]&
15|64;a[8]=a[8]&63|128;if(b){c=c||0;for(var d=0;16>d;++d)b[c+d]=a[d];return b}return Rc(a)}function Uc(a){var b=0,c=0;var d="";var f=[];if(!a)return a;a+="";do{var h=ra.indexOf(a.charAt(b++));var g=ra.indexOf(a.charAt(b++));d=ra.indexOf(a.charAt(b++));var k=ra.indexOf(a.charAt(b++));var l=h<<18|g<<12|d<<6|k;h=l>>16&255;g=l>>8&255;l&=255;64===d?f[c++]=String.fromCharCode(h):64===k?f[c++]=String.fromCharCode(h,g):f[c++]=String.fromCharCode(h,g,l)}while(b<a.length);d=f.join("");return function(m){return decodeURIComponent(m.split("").map(function(p){return"%"+
("00"+p.charCodeAt(0).toString(16)).slice(-2)}).join(""))}(d.replace(/\0+$/,""))}function Ya(){var a={},b=[],c=[],d=[],f,h=function(g,k){null!=k&&""!==k&&(a[g]=k)};return{add:h,addDict:function(g){for(var k in g)Object.prototype.hasOwnProperty.call(g,k)&&h(k,g[k])},addJson:function(g,k,l){l&&cc(l)&&(g={keyIfEncoded:g,keyIfNotEncoded:k,json:l},c.push(g),b.push(g))},addContextEntity:function(g){d.push(g)},getPayload:function(){return a},getJson:function(){return b},withJsonProcessor:function(g){f=g},
build:function(){null===f||void 0===f?void 0:f(this,c,d);return a}}}function Vc(a){return function(b,c,d){for(var f=function(m,p,u){m=JSON.stringify(m);if(a){u=b.add;if(m){var v=0,q=0,r=[];if(m){m=unescape(encodeURIComponent(m));do{var z=m.charCodeAt(v++);var G=m.charCodeAt(v++);var J=m.charCodeAt(v++);var H=z<<16|G<<8|J;z=H>>18&63;G=H>>12&63;J=H>>6&63;H&=63;r[q++]=ra.charAt(z)+ra.charAt(G)+ra.charAt(J)+ra.charAt(H)}while(v<m.length);v=r.join("");m=m.length%3;m=(m?v.slice(0,m-3):v)+"===".slice(m||
3)}m=m.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}u.call(b,p,m)}else b.add(u,m)},h=function(m,p){if(!m){var u=b.getPayload();if(a?u.cx:u.co){m=JSON;var v=m.parse;if(a){if(u=u.cx){switch(4-u.length%4){case 2:u+="==";break;case 3:u+="="}u=u.replace(/-/g,"+").replace(/_/g,"/");u=Uc(u)}}else u=u.co;m=v.call(m,u)}else m=void 0}m?m.data=m.data.concat(p.data):m=p;return m},g=void 0,k=0;k<c.length;k++){var l=c[k];"cx"===l.keyIfEncoded?g=h(g,l.json):f(l.json,l.keyIfEncoded,l.keyIfNotEncoded)}c.length=
0;d.length&&(c={schema:"iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-0",data:aa([],d,!0)},g=h(g,c),d.length=0);g&&f(g,"cx","co")}}function cc(a){if(!dc(a))return!1;for(var b in a)if(Object.prototype.hasOwnProperty.call(a,b))return!0;return!1}function dc(a){return"undefined"!==typeof a&&null!==a&&(a.constructor==={}.constructor||a.constructor===[].constructor)}function Wc(){var a=[],b=[],c={},d={};return{getGlobalPrimitives:function(){return a.concat(Object.values(c))},getConditionalProviders:function(){return b.concat(Object.values(d))},
addGlobalContexts:function(f){if(Array.isArray(f)){for(var h=[],g=[],k=0;k<f.length;k++){var l=f[k];Na(l)?h.push(l):ma(l)&&g.push(l)}a=a.concat(g);b=b.concat(h)}else for(h=0,f=Object.entries(f);h<f.length;h++)l=f[h],g=l[0],l=l[1],Na(l)?d[g]=l:ma(l)&&(c[g]=l)},clearGlobalContexts:function(){b=[];a=[];d={};c={}},removeGlobalContexts:function(f){for(var h=function(k){"string"===typeof k?(delete d[k],delete c[k]):Na(k)?b=b.filter(function(l){return!ec(k,l)}):ma(k)&&(a=a.filter(function(l){return!ec(k,
l)}))},g=0;g<f.length;g++)h(f[g])},getApplicableContexts:function(f){a:{var h=0;for(var g=f.getJson();h<g.length;h++){var k=g[h];if("ue_px"===k.keyIfEncoded&&"object"===typeof k.json.data&&(k=k.json.data.schema,"string"==typeof k)){h=k;break a}}h=""}g=f.getPayload().e;k="string"===typeof g?g:"";g=[];var l=pb(a.concat(Object.values(c)),f,k,h);g.push.apply(g,l);f=Xc(b.concat(Object.values(d)),f,k,h);g.push.apply(g,f);return g}}}function Yc(a){return{addPluginContexts:function(b){var c=b?aa([],b,!0):
[];a.forEach(function(d){try{d.contexts&&c.push.apply(c,d.contexts())}catch(f){P.error("Error adding plugin contexts",f)}});return c}}}function Zc(a){if("*"===a[0]||"*"===a[1])return!1;if(0<a.slice(2).length){var b=!1,c=0;for(a=a.slice(2);c<a.length;c++)if("*"===a[c])b=!0;else if(b)return!1;return!0}return 2==a.length?!0:!1}function fc(a){return(a=a.split("."))&&1<a.length?Zc(a):!1}function gc(a){a=/^iglu:((?:(?:[a-zA-Z0-9-_]+|\*).)+(?:[a-zA-Z0-9-_]+|\*))\/([a-zA-Z0-9-_.]+|\*)\/jsonschema\/([1-9][0-9]*|\*)-(0|[1-9][0-9]*|\*)-(0|[1-9][0-9]*|\*)$/.exec(a);
if(null!==a&&fc(a[1]))return a.slice(1,6)}function qb(a){if(a=gc(a)){var b=a[0];return 5===a.length&&fc(b)}return!1}function $c(a){return Array.isArray(a)&&a.every(function(b){return"string"===typeof b})}function hc(a){return $c(a)?a.every(function(b){return qb(b)}):"string"===typeof a?qb(a):!1}function Oa(a){return cc(a)&&"schema"in a&&"data"in a?"string"===typeof a.schema&&"object"===typeof a.data:!1}function ad(a){var b=0;if(null!=a&&"object"===typeof a&&!Array.isArray(a)){if(Object.prototype.hasOwnProperty.call(a,
"accept"))if(hc(a.accept))b+=1;else return!1;if(Object.prototype.hasOwnProperty.call(a,"reject"))if(hc(a.reject))b+=1;else return!1;return 0<b&&2>=b}return!1}function Za(a){return"function"===typeof a&&1>=a.length}function ma(a){return Za(a)||Oa(a)}function ic(a){return Array.isArray(a)&&2===a.length?Array.isArray(a[1])?Za(a[0])&&a[1].every(ma):Za(a[0])&&ma(a[1]):!1}function jc(a){return Array.isArray(a)&&2===a.length?ad(a[0])?Array.isArray(a[1])?a[1].every(ma):ma(a[1]):!1:!1}function Na(a){return ic(a)||
jc(a)}function bd(a,b){var c=0,d=0,f=a.accept;Array.isArray(f)?a.accept.some(function(h){return $a(h,b)})&&d++:"string"===typeof f&&$a(f,b)&&d++;f=a.reject;Array.isArray(f)?a.reject.some(function(h){return $a(h,b)})&&c++:"string"===typeof f&&$a(f,b)&&c++;return 0<d&&0===c?!0:!1}function $a(a,b){if(!qb(a))return!1;a=gc(a);b=/^iglu:([a-zA-Z0-9-_.]+)\/([a-zA-Z0-9-_]+)\/jsonschema\/([1-9][0-9]*)-(0|[1-9][0-9]*)-(0|[1-9][0-9]*)$/.exec(b);b=null!==b?b.slice(1,6):void 0;if(a&&b){if(!cd(a[0],b[0]))return!1;
for(var c=1;5>c;c++)if(!kc(a[c],b[c]))return!1;return!0}return!1}function cd(a,b){b=b.split(".");a=a.split(".");if(b&&a){if(b.length!==a.length)return!1;for(var c=0;c<a.length;c++)if(!kc(b[c],a[c]))return!1;return!0}return!1}function kc(a,b){return a&&b&&"*"===a||a===b}function lc(a){return Array.isArray(a)?a:[a]}function pb(a,b,c,d){var f;a=lc(a).map(function(h){a:if(Oa(h))h=[h];else{if(Za(h)){b:{var g=void 0;try{var k={event:b.getPayload(),eventType:c,eventSchema:d};g=h(k);if(Array.isArray(g)&&
g.every(Oa)||Oa(g)){var l=g;break b}l=void 0;break b}catch(m){}l=void 0}if(Oa(l)){h=[l];break a}else if(Array.isArray(l)){h=l;break a}}h=void 0}if(h&&0!==h.length)return h});return(f=[]).concat.apply(f,a.filter(function(h){return null!=h&&h.filter(Boolean)}))}function ab(a,b){return"function"===typeof a?a===b:JSON.stringify(a)===JSON.stringify(b)}function ec(a,b){if(Na(a)){if(!Na(b))return!1;var c=a[1],d=b[1];return ab(a[0],b[0])?Array.isArray(c)?Array.isArray(d)&&c.length===d.length?c.reduce(function(f,
h,g){return f&&ab(h,d[g])},!0):!1:Array.isArray(d)?!1:ab(c,d):!1}return ma(a)?ma(b)?ab(a,b):!1:!1}function Xc(a,b,c,d){var f;a=lc(a).map(function(h){a:{if(ic(h)){var g=h[0],k=!1;try{var l={event:b.getPayload(),eventType:c,eventSchema:d};k=g(l)}catch(m){k=!1}if(!0===k){h=pb(h[1],b,c,d);break a}}else if(jc(h)&&bd(h[0],d)){h=pb(h[1],b,c,d);break a}h=[]}if(h&&0!==h.length)return h});return(f=[]).concat.apply(f,a.filter(function(h){return null!=h&&h.filter(Boolean)}))}function dd(a){return null==a?{type:"dtm",
value:(new Date).getTime()}:"number"===typeof a?{type:"dtm",value:a}:"ttm"===a.type?{type:"ttm",value:a.value}:{type:"dtm",value:a.value||(new Date).getTime()}}function ed(a){void 0===a&&(a={});var b=!0,c=a.base64,d=a.corePlugins,f=null!==d&&void 0!==d?d:[];a=function(g,k,l){function m(r,z){r=u.getApplicableContexts(r);var G=[];z&&z.length&&G.push.apply(G,z);r&&r.length&&G.push.apply(G,r);return G}var p=Yc(k),u=Wc(),v=g,q={};return{track:function(r,z,G){if(b){if(r.withJsonProcessor(Vc(v)),r.add("eid",
la()),r.addDict(q),G=dd(G),r.add(G.type,G.value.toString()),z=m(r,p.addPluginContexts(z)),z=z&&z.length?{schema:"iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-0",data:z}:void 0,void 0!==z&&r.addJson("cx","co",z),k.forEach(function(H){try{H.beforeTrack&&H.beforeTrack(r)}catch(w){P.error("Plugin beforeTrack",w)}}),!k.find(function(H){try{return H.filter&&!1===H.filter(r.build())}catch(w){return P.error("Plugin filter",w),!1}})){"function"===typeof l&&l(r);var J=r.build();k.forEach(function(H){try{H.afterTrack&&
H.afterTrack(J)}catch(w){P.error("Plugin afterTrack",w)}});return J}}else P.error("Track called on deactivated tracker")},addPayloadPair:function(r,z){q[r]=z},getBase64Encoding:function(){return v},setBase64Encoding:function(r){v=r},addPayloadDict:function(r){for(var z in r)Object.prototype.hasOwnProperty.call(r,z)&&(q[z]=r[z])},resetPayloadPairs:function(r){q=dc(r)?r:{}},setTrackerVersion:function(r){q.tv=r},setTrackerNamespace:function(r){q.tna=r},setAppId:function(r){q.aid=r},setPlatform:function(r){q.p=
r},setUserId:function(r){q.uid=r},setScreenResolution:function(r,z){q.res=r+"x"+z},setViewport:function(r,z){q.vp=r+"x"+z},setColorDepth:function(r){q.cd=r},setTimezone:function(r){q.tz=r},setLang:function(r){q.lang=r},setIpAddress:function(r){q.ip=r},setUseragent:function(r){q.ua=r},addGlobalContexts:function(r){u.addGlobalContexts(r)},clearGlobalContexts:function(){u.clearGlobalContexts()},removeGlobalContexts:function(r){u.removeGlobalContexts(r)}}}(null!==c&&void 0!==c?c:!0,f,a.callback);var h=
Q(Q({},a),{addPlugin:function(g){var k,l;g=g.plugin;f.push(g);null===(k=g.logger)||void 0===k?void 0:k.call(g,P);null===(l=g.activateCorePlugin)||void 0===l?void 0:l.call(g,h)},deactivate:function(){f.forEach(function(g){var k;null===(k=g.deactivatePlugin)||void 0===k?void 0:k.call(g,h)});f.length=0;b=!1}});null===f||void 0===f?void 0:f.forEach(function(g){var k,l;null===(k=g.logger)||void 0===k?void 0:k.call(g,P);null===(l=g.activateCorePlugin)||void 0===l?void 0:l.call(g,h)});return h}function fd(a){var b=
a.pageUrl,c=a.pageTitle;a=a.referrer;var d=Ya();d.add("e","pv");d.add("url",b);d.add("page",c);d.add("refr",a);return d}function rb(a){var b=a.maxSize,c=void 0===b?1E3:b;a=a.events;var d=aa([],void 0===a?[]:a,!0),f=function(){return Promise.resolve(d.length)};return{count:f,add:function(h){for(d.push(h);d.length>c;)d.shift();return f()},removeHead:function(h){for(var g=0;g<h;g++)d.shift();return Promise.resolve()},iterator:function(){var h=0,g=aa([],d,!0);return{next:function(){return h<g.length?
Promise.resolve({value:g[h++],done:!1}):Promise.resolve({value:void 0,done:!0})}}},getAll:function(){return Promise.resolve(aa([],d,!0))},getAllPayloads:function(){return Promise.resolve(d.map(function(h){return h.payload}))}}}function gd(a){for(var b=(new Date).getTime().toString(),c=0;c<a.length;c++)a[c].stm=b;return a}function hd(a){function b(){var E=w.reduce(function(O,fa){return O+(R?fa.getPOSTRequestBytesCount():fa.getGETRequestBytesCount())},0);R&&(E+=88);return E}function c(){var E=new Headers;
R&&E.append("Content-Type","application/json; charset=UTF-8");u&&Object.keys(u).forEach(function(O){E.append(O,u[O])});0<w.length&&w[0].getServerAnonymization()&&E.append("SP-Anonymous","*");return E}function d(){var E=k;k.includes("://")||(E="".concat(m,"://").concat(k));p&&(E="".concat(E,":").concat(p));return E+(R?z:"/i")}function f(E,O){g(!1);ha=new AbortController;X=setTimeout(function(){console.error("Request timed out");X=void 0;g(!1,"Request timed out")},null!==v&&void 0!==v?v:5E3);O=Q({headers:c(),
signal:ha.signal,keepalive:r,credentials:H},O);return new Request(E,O)}function h(){var E=gd(w.map(function(O){return O.getPOSTRequestBody()}));return f(d(),{method:"POST",body:JSON.stringify({schema:"iglu:com.snowplowanalytics.snowplow/payload_data/jsonschema/1-0-4",data:E})})}function g(E,O){void 0!==X&&(clearTimeout(X),X=void 0);if(void 0!==ha){var fa=ha;ha=void 0;E||fa.abort(O)}}var k=a.endpoint,l=a.protocol,m=void 0===l?"https":l,p=a.port;l=a.eventMethod;var u=a.customHeaders,v=a.connectionTimeout,
q=a.keepalive,r=void 0===q?!1:q;q=a.postPath;var z=void 0===q?"/com.snowplowanalytics.snowplow/tp2":q;q=a.useStm;var G=void 0===q?!0:q;q=a.maxPostBytes;var J=void 0===q?4E4:q;a=a.credentials;var H=void 0===a?"include":a,w=[],R="post"===(void 0===l?"post":l).toLowerCase(),X,ha;return{addEvent:function(E){if(0<w.length&&(0<w.length?w[0].getServerAnonymization():void 0)!==E.getServerAnonymization())return!1;w.push(E);return!0},getEvents:function(){return w},toRequest:function(){if(0!==w.length){if(R)return h();
if(1!==w.length)throw Error("Only one event can be sent in a GET request");var E=w[0].getGETRequestURL(d(),G);return f(E,{method:"GET"})}},countBytes:b,countEvents:function(){return w.length},isFull:function(){return R?b()>=J:1<=w.length},closeRequest:g}}function mc(a){for(var b=0,c=0;c<a.length;c++){var d=a.charCodeAt(c);127>=d?b+=1:2047>=d?b+=2:55296<=d&&57343>=d?(b+=4,c++):b=65535>d?b+3:b+4}return b}function id(a){return Object.keys(a).map(function(b){return[b,a[b]]}).reduce(function(b,c){b[c[0]]=
c[1].toString();return b},{})}function nc(a){function b(){return a.payload}function c(l){if(null===f){var m={co:!0,cx:!0},p=[],u;for(u in l)l.hasOwnProperty(u)&&!m[u]&&p.push(u+"="+encodeURIComponent(l[u]));for(var v in m)l.hasOwnProperty(v)&&m[v]&&p.push(v+"="+encodeURIComponent(l[v]));f="?"+p.join("&")}return f}function d(){null===h&&(h=id(b()));return h}var f=null,h=null,g=null,k=null;return{getPayload:b,getServerAnonymization:function(){var l;return null!==(l=a.svrAnon)&&void 0!==l?l:!1},getGETRequestURL:function(l,
m){var p=c(b());return m?l+p.replace("?","?stm="+(new Date).getTime()+"&"):l+p},getGETRequestBytesCount:function(){if(null===g){var l=c(b());g=mc(l)}return g},getPOSTRequestBody:d,getPOSTRequestBytesCount:function(){null===k&&(k=mc(JSON.stringify(d())));return k}}}function jd(a){function b(A){return 200<=A&&300>A||!fa?!1:O.includes(A)?!0:!E.includes(A)}function c(A,F){void 0!==wa&&setTimeout(function(){try{null===wa||void 0===wa?void 0:wa(A,F)}catch(M){P.error("Error in onRequestSuccess",M)}},0)}
function d(A,F){void 0!==sa&&setTimeout(function(){try{null===sa||void 0===sa?void 0:sa(A,F)}catch(M){P.error("Error in onRequestFailure",M)}},0)}function f(A){return ka(this,void 0,void 0,function(){var F,M,L,ia,D,T;return Ma(this,function(Y){switch(Y.label){case 0:F=A.toRequest();if(void 0===F)throw Error("Empty batch");M=A.getEvents().map(function(xa){return xa.getPayload()});Y.label=1;case 1:return Y.trys.push([1,4,,5]),[4,Pa(F)];case 2:return L=Y.sent(),[4,L.text()];case 3:Y.sent();A.closeRequest(!0);
if(L.ok)return c(M,L),[2,{success:!0,retry:!1,status:L.status}];ia=b(L.status);d({events:M,status:L.status,message:L.statusText,willRetry:ia},L);return[2,{success:!1,retry:ia,status:L.status}];case 4:return D=Y.sent(),A.closeRequest(!1),T="string"===typeof D?D:D?D.message:"Unknown error",d({events:M,message:T,willRetry:!0}),[2,{success:!1,retry:!0}];case 5:return[2]}})})}function h(){return hd({endpoint:m,protocol:q,port:r,eventMethod:u,customHeaders:H,connectionTimeout:R,keepalive:X,maxPostBytes:z,
useStm:bb,credentials:ya,postPath:v})}function g(){return ka(this,void 0,void 0,function(){var A;return Ma(this,function(F){switch(F.label){case 0:if(!ha||Qa)return[3,2];Qa=!0;A=new Request(ha,{method:"GET"});return[4,Pa(A)];case 1:F.sent(),F.label=2;case 2:return[2]}})})}function k(){return ka(this,void 0,void 0,function(){var A;return Ma(this,function(F){switch(F.label){case 0:if(Ea)return[3,5];Ea=!0;F.label=1;case 1:return F.trys.push([1,3,4,5]),[4,l()];case 2:return F.sent(),[3,5];case 3:return A=
F.sent(),P.error("Error sending events",A),[3,5];case 4:return Ea=!1,[7];case 5:return[2]}})})}function l(){return ka(this,void 0,void 0,function(){var A,F,M,L,ia,D,T,Y,xa,Fa;return Ma(this,function(Z){switch(Z.label){case 0:return[4,g()];case 1:Z.sent(),A=h(),F=Ga.iterator(),Z.label=2;case 2:return A.isFull()?[3,4]:[4,F.next()];case 3:M=Z.sent();L=M.value;if((ia=M.done)||void 0===L)return[3,4];D=nc(L);return A.addEvent(D)?[3,2]:[3,4];case 4:return 0===A.countEvents()?[2]:[4,f(A)];case 5:T=Z.sent();
Y=T.success;xa=T.retry;Fa=T.status;if(!Y&&xa)return[3,7];Y||P.error("Status ".concat(Fa,", will not retry."));return[4,Ga.removeHead(A.countEvents())];case 6:Z.sent(),Z.label=7;case 7:return Y?[4,l()]:[3,9];case 8:Z.sent(),Z.label=9;case 9:return[2]}})})}var m=a.endpoint,p=a.eventMethod,u=void 0===p?"post":p,v=a.postPath,q=a.protocol,r=a.port;p=a.maxPostBytes;var z=void 0===p?4E4:p,G=a.maxGetBytes;p=a.bufferSize;var J=void 0===p?1:p,H=a.customHeaders,w=a.serverAnonymization,R=a.connectionTimeout,
X=a.keepalive,ha=a.idService;p=a.dontRetryStatusCodes;var E=void 0===p?[]:p;p=a.retryStatusCodes;var O=void 0===p?[]:p;p=a.retryFailedRequests;var fa=void 0===p?!0:p,sa=a.onRequestFailure,wa=a.onRequestSuccess;p=a.customFetch;var Pa=void 0===p?fetch:p,bb=a.useStm;p=a.eventStore;var Ga=void 0===p?rb({}):p,ya=a.credentials,Qa=!1,Ea=!1,za="post"===u.toLowerCase();E=E.concat([400,401,403,410,422]);return{flush:k,input:function(A){return ka(this,void 0,void 0,function(){var F,M,L,ia;return Ma(this,function(D){switch(D.label){case 0:D=
w;F={payload:A,svrAnon:void 0===D?!1:D};M=nc(F);a:{D=M;if(za){D=D.getPOSTRequestBytesCount()+88;var T=D>z;T&&P.warn("Event ("+D+"B) too big, max is "+z)}else{if(void 0===G){D=!1;break a}D=D.getGETRequestBytesCount();(T=D>G)&&P.warn("Event ("+D+"B) too big, max is "+G)}D=T}if(!D)return[3,2];L=h();L.addEvent(M);return[4,f(L)];case 1:return D.sent(),[3,5];case 2:return[4,Ga.add(F)];case 3:return ia=D.sent(),ia>=J?[4,k()]:[3,5];case 4:D.sent(),D.label=5;case 5:return[2]}})})},setCollectorUrl:function(A){m=
A},setAnonymousTracking:function(A){w=A},setBufferSize:function(A){J=A}}}function oc(a){try{var b=window.localStorage;b.removeItem(a);b.removeItem(a+".expires");return!0}catch(c){return!1}}function pc(a){try{return window.sessionStorage.getItem(a)}catch(b){}}function kd(a,b,c){var d,f=(new Date).getTime();b=Q(Q({},ld),b);var h=c.domainUserId,g=c.userId,k=c.sessionId,l=c.sourceId,m=c.sourcePlatform,p=c.event,u=p.currentTarget;p="function"===typeof b.reason?b.reason(p):null===(d=null===u||void 0===
u?void 0:u.textContent)||void 0===d?void 0:d.trim();return a?[h,f,b.sessionId&&k,b.userId&&sb(g||""),b.sourceId&&sb(l||""),b.sourcePlatform&&m,b.reason&&sb(p||"")].map(function(v){return v||""}).join(".").replace(/([.]*$)/,""):c.domainUserId+"."+f}function sb(a){return btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function qc(a){return Number.isInteger&&Number.isInteger(a)||"number"===typeof a&&isFinite(a)&&Math.floor(a)===a}function rc(a){var b=a&&"string"===typeof a.valueOf()?
!0:!1;b||(a=a.text||"",(b=document.getElementsByTagName("title"))&&null!=b[0]&&(a=b[0].text));return a}function tb(a){var b=/^(?:(?:https?|ftp):)\/*(?:[^@]+@)?([^:/#]+)/.exec(a);return b?b[1]:a}function sc(a){var b=a.length;"."===a.charAt(--b)&&(a=a.slice(0,b));"*."===a.slice(0,2)&&(a=a.slice(1));return a}function ub(a){var b=window,c=Ra("referrer",b.location.href)||Ra("referer",b.location.href);if(c)return c;if(a)return a;try{if(b.top)return b.top.document.referrer;if(b.parent)return b.parent.document.referrer}catch(d){}return document.referrer}
function Ha(a,b,c,d){if(a.addEventListener)return a.addEventListener(b,c,d),!0;if(a.attachEvent)return a.attachEvent("on"+b,c);a["on"+b]=c}function Ra(a,b){return(a=(new RegExp("^[^#]*[?&]"+a+"=([^&#]*)")).exec(b))?decodeURIComponent(a[1].replace(/\+/g," ")):null}function md(a,b){for(var c=window.location.hostname,d="_sp_root_domain_test_"+(new Date).getTime(),f="_test_value_"+(new Date).getTime(),h=c.split("."),g=h.length-2;0<=g;g--){var k=h.slice(g).join(".");ta(d,f,0,"/",k,a,b);if(ta(d)===f){cb(d,
"/",k,a,b);c=document.cookie.split("; ");d=[];for(f=0;f<c.length;f++)"_sp_root_domain_test_"===c[f].substring(0,21)&&d.push(c[f]);c=d;for(d=0;d<c.length;d++)cb(c[d],"/",k,a,b);return k}}return c}function cb(a,b,c,d,f){ta(a,"",-1,b,c,d,f)}function ta(a,b,c,d,f,h,g){return 1<arguments.length?document.cookie=a+"="+encodeURIComponent(null!==b&&void 0!==b?b:"")+(c?"; Expires="+(new Date(+new Date+1E3*c)).toUTCString():"")+(d?"; Path="+d:"")+(f?"; Domain="+f:"")+(h?"; SameSite="+h:"")+(g?"; Secure":""):
decodeURIComponent((("; "+document.cookie).split("; "+a+"=")[1]||"").split(";")[0])}function nd(a){function b(){return f?g().then(function(p){window.localStorage.setItem(h,JSON.stringify(p))}):Promise.resolve()}var c=a.maxLocalStorageQueueSize,d=void 0===c?1E3:c;c=a.useLocalStorage;var f=void 0===c?!0:c,h="snowplowOutQueue_".concat(a.trackerId);a=function(){if(f){var p=window.localStorage.getItem(h);p=p?JSON.parse(p):[];return rb({maxSize:d,events:p})}return rb({maxSize:d})}();var g=a.getAll,k=a.add,
l=a.count,m=a.removeHead;return{count:l,add:function(p){k(p);return b().then(l)},removeHead:function(p){m(p);return b()},iterator:a.iterator,getAll:g,getAllPayloads:a.getAllPayloads,setUseLocalStorage:function(p){f=p}}}function od(a,b){var c,d=null!==(c=a.eventStore)&&void 0!==c?c:nd(a);a.eventStore=d;a=jd(a);b.bufferFlushers.push(a.flush);return{enqueueRequest:a.input,executeQueue:a.flush,setAnonymousTracking:a.setAnonymousTracking,setCollectorUrl:a.setCollectorUrl,setBufferSize:a.setBufferSize,
setUseLocalStorage:function(f){d.hasOwnProperty("setUseLocalStorage")&&d.setUseLocalStorage(f)}}}function tc(a,b,c){if("translate.googleusercontent.com"===a)""===c&&(c=b),a=(a=/^(?:https?|ftp)(?::\/*(?:[^?]+))([?][^#]+)/.exec(b))&&1<(null===a||void 0===a?void 0:a.length)?Ra("u",a[1]):null,b=null!==a&&void 0!==a?a:"",a=tb(b);else if("cc.bingj.com"===a||"webcache.googleusercontent.com"===a)b=document.links[0].href,a=tb(b);return[a,b,c]}function pd(a,b,c,d){var f=Math.round((new Date).getTime()/1E3);
a?(a=a.split("."),a.unshift("0")):a=["1",b,f,d,f,"",c];a[6]&&"undefined"!==a[6]||(a[6]=la());a[7]&&"undefined"!==a[7]||(a[7]="");a[8]&&"undefined"!==a[8]||(a[8]="");a[9]&&"undefined"!==a[9]||(a[9]="");a[10]&&"undefined"!==a[10]||(a[10]=0);var h=function(g,k){g=parseInt(g);return isNaN(g)?k:g};b=function(g){return g?h(g,void 0):void 0};return[a[0],a[1],h(a[2],f),h(a[3],d),h(a[4],f),b(a[5]),a[6],a[7],a[8],b(a[9]),h(a[10],0)]}function Sa(a,b){void 0===b&&(b={memorizedVisitCount:1});b=b.memorizedVisitCount;
"0"===a[0]?(a[7]=a[6],a[5]=a[4],a[3]++):a[3]=b;b=la();a[6]=b;a[10]=0;a[8]="";a[9]=void 0;return b}function vb(a){a[4]=Math.round((new Date).getTime()/1E3)}function uc(a,b,c){var d=a[9];return{userId:c?"00000000-0000-0000-0000-000000000000":a[1],sessionId:a[6],eventIndex:a[10],sessionIndex:a[3],previousSessionId:c?null:a[7]||null,storageMechanism:"localStorage"==b?"LOCAL_STORAGE":"COOKIE_1",firstEventId:a[8]||null,firstEventTimestamp:d?(new Date(d)).toISOString():null}}function qd(){if(!vc&&document&&
document.body&&document.documentElement){vc=!0;var a=new ResizeObserver(function(){wb||(wb=requestAnimationFrame(function(){wb=null;db=xb()}))});a.observe(document.body);a.observe(document.documentElement)}}function yb(){if(!("ResizeObserver"in window))return xb();db||(db=xb());qd();return db}function xb(){var a=zb;if("innerWidth"in window){var b=window.innerWidth;var c=window.innerHeight}else c=document.documentElement||document.body,b=c.clientWidth,c=c.clientHeight;a=a(Math.max(0,b)+Ta+Math.max(0,
c));b=zb;var d=document.documentElement,f=document.body;c=Math.max(d.clientWidth,d.offsetWidth,d.scrollWidth);d=Math.max(d.clientHeight,d.offsetHeight,d.scrollHeight,f?Math.max(f.offsetHeight,f.scrollHeight):0);c=isNaN(c)||isNaN(d)?"":c+Ta+d;return{viewport:a,documentSize:b(c),resolution:zb(screen.width+Ta+screen.height),colorDepth:screen.colorDepth,devicePixelRatio:window.devicePixelRatio,cookiesEnabled:window.navigator.cookieEnabled,online:window.navigator.onLine,browserLanguage:window.navigator.language||
window.navigator.userLanguage,documentLanguage:document.documentElement.lang,webdriver:window.navigator.webdriver,deviceMemory:window.navigator.deviceMemory,hardwareConcurrency:window.navigator.hardwareConcurrency}}function zb(a){return a&&a.split(Ta).map(function(b){return Math.floor(Number(b))}).join(Ta)}function rd(a){function b(){void 0!==c&&(clearTimeout(c),c=void 0);h||(h=!0,void 0!==d&&ta(a,d[0],d[1],d[2],d[3],d[4],d[5]))}var c,d,f,h=!0;return{getValue:function(){var g;return d&&(!f||f>new Date)?
null!==(g=d[0])&&void 0!==g?g:ta(a):ta(a)},setValue:function(g,k,l,m,p,u){d=[g,k,l,m,p,u];h=!1;void 0===c&&(c=setTimeout(function(){c=void 0;b()},10));f=new Date(Date.now()+1E3*Math.min(.05,null!==k&&void 0!==k?k:.05));return!0},deleteValue:function(g,k,l,m){d=void 0;h=!0;void 0!==c&&(clearTimeout(c),c=void 0);cb(a,g,k,l,m)},flush:b}}function sd(a,b,c,d,f,h){void 0===h&&(h={});var g=[];a=function(l,m,p,u,v,q){function r(){Aa=tc(window.location.hostname,window.location.href,ub());Aa[1]!==ca&&(Ua=ub(ca));
wc=sc(Aa[0]);ca=Aa[1]}function z(e){return function(n){var t=n.currentTarget;n=kd(e,td,{domainUserId:eb,userId:ua||void 0,sessionId:ja,sourceId:xc,sourcePlatform:yc,event:n});if(null===t||void 0===t?0:t.href){n="_sp="+n;var B=t.href.split("#"),y=B[0].split("?"),I=y.shift();if(y=y.join("?")){for(var da=!0,S=y.split("&"),ea=0;ea<S.length;ea++)if("_sp="===S[ea].substr(0,4)){da=!1;S[ea]=n;y=S.join("&");break}da&&(y=n+"&"+y)}else y=n;B[0]=I+"?"+y;n=B.join("#");t.href=n}}}function G(e){for(var n=z(ud),
t=0;t<document.links.length;t++){var B=document.links[t];!B.spDecorationEnabled&&e(B)&&(B.addEventListener("click",n,!0),B.addEventListener("mousedown",n,!0),B.spDecorationEnabled=!0)}}function J(e){if(zc){var n=/#.*/;e=e.replace(n,"")}Ac&&(n=/[{}]/g,e=e.replace(n,""));return e}function H(e){return(e=/^([a-z]+):/.exec(e))?e[1]:null}function w(e){e=Ia+e+"."+Ba;if("localStorage"==K){try{var n=window.localStorage,t=n.getItem(e+".expires");if(null===t||+t>Date.now())var B=n.getItem(e);else n.removeItem(e),
n.removeItem(e+".expires"),B=void 0}catch(y){B=void 0}return B}if("cookie"==K||"cookieAndLocalStorage"==K)return na.getCookie(e)}function R(){r();Ba=vd((Ca||wc)+(Va||"/")).slice(0,4)}function X(){fb=(new Date).getTime()}function ha(){var e=E(),n=e[0];n<gb?gb=n:n>hb&&(hb=n);e=e[1];e<ib?ib=e:e>jb&&(jb=e);X()}function E(){var e=document.documentElement;return e?[e.scrollLeft||window.pageXOffset,e.scrollTop||window.pageYOffset]:[0,0]}function O(){var e=E(),n=e[0];hb=gb=n;jb=ib=e=e[1]}function fa(){return wa(Ia+
"ses."+Ba,"*",Bc)}function sa(e){var n=Ia+"id."+Ba;var t=U;e=aa([],e,!0);t&&(e[1]="",e[7]="");e.shift();t=e.join(".");return wa(n,t,Cc)}function wa(e,n,t){if(U&&!Da)return!1;if("localStorage"==K){void 0===t&&(t=63072E3);try{var B=window.localStorage,y=Date.now()+1E3*t;B.setItem("".concat(e,".expires"),y.toString());B.setItem(e,n);var I=!0}catch(da){I=!1}return I}return"cookie"==K||"cookieAndLocalStorage"==K?na.setCookie(e,n,t,Va,Ca,kb,lb):!1}function Pa(e){var n=Ia+"id."+Ba,t=Ia+"ses."+Ba;oc(n);oc(t);
na.deleteCookie(n,Va,Ca,kb,lb);na.deleteCookie(t,Va,Ca,kb,lb);null!==e&&void 0!==e&&e.preserveSession||(ja=la(),ba=1);null!==e&&void 0!==e&&e.preserveUser||(eb=U?"":la(),ua=null)}function bb(e){e&&e.stateStorageStrategy&&(q.stateStorageStrategy=e.stateStorageStrategy,K=Dc(q));U=!!q.anonymousTracking;Da=Ec(q);Ab=Fc(q);va.setUseLocalStorage("localStorage"==K||"cookieAndLocalStorage"==K);va.setAnonymousTracking(Ab)}function Ga(){if(!U||Da){var e="none"!=K&&!!w("ses"),n=ya();if(n[1])var t=n[1];else t=
U?"":la(),n[1]=t;eb=t;ja=e?n[6]:Sa(n);ba=n[3];"none"!=K&&(fa(),vb(n),sa(n),n[10]||na.flush())}}function ya(){if("none"==K)return["1","",0,0,0,void 0,"","","",void 0,0];var e=w("id")||void 0;return pd(e,eb,ja,ba)}function Qa(e){return 0===e.indexOf("http")?e:("https:"===document.location.protocol?"https":"http")+"://"+e}function Ea(){Bb&&null!=v.pageViewId||(v.pageViewId=la(),v.pageViewUrl=oa||ca)}function za(){A()&&(v.pageViewId=la(),v.pageViewUrl=oa||ca);return v.pageViewId}function A(){if(null==
v.pageViewId)return!0;if(Bb||!Ja)return!1;if(void 0===v.pageViewUrl)return!0;var e=oa||ca;if(!0===Ja||"full"==Ja||!("URL"in window))return v.pageViewUrl!=e;e=new URL(e);var n=new URL(v.pageViewUrl);return"pathname"==Ja?e.pathname!=n.pathname:"pathnameAndSearch"==Ja?e.pathname!=n.pathname||e.search!=n.search:!1}function F(){if("none"===K||U||!Gc)return null;var e=pc("_sp_tab_id");if(!e){e=la();try{window.sessionStorage.setItem("_sp_tab_id",e)}catch(n){}e=pc("_sp_tab_id")}return e||null}function M(){return{contexts:function(){return[{schema:"iglu:com.snowplowanalytics.snowplow/web_page/jsonschema/1-0-0",
data:{id:za()}}]}}}function L(){return{contexts:function(){return[{schema:"iglu:com.snowplowanalytics.snowplow/browser_context/jsonschema/2-0-0",data:Q(Q({},yb()),{tabId:F()})}]}}}function ia(e){var n=e.title,t=e.context,B=e.timestamp;e=e.contextCallback;r();Cb&&Cb==za()&&Ea();Cb=za();Ka=document.title;n?(La=n,Db=!0):Db&&(La=null);n=rc(La||Ka);V.track(fd({pageUrl:J(oa||ca),pageTitle:n,referrer:J(mb||Ua)}),(t||[]).concat(e?e():[]),B);B=new Date;n=!1;if(W.enabled&&!W.installed){n=W.installed=!0;var y=
{update:function(){if("undefined"!==typeof window&&"function"===typeof window.addEventListener){var da=!1,S=Object.defineProperty({},"passive",{get:function(){da=!0},set:function(){}}),ea=function(){};window.addEventListener("testPassiveEventSupport",ea,S);window.removeEventListener("testPassiveEventSupport",ea,S);y.hasSupport=da}}};y.update();var I="onwheel"in document.createElement("div")?"wheel":void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll";Object.prototype.hasOwnProperty.call(y,
"hasSupport")?Ha(document,I,X,{passive:!0}):Ha(document,I,X);O();I=function(da,S){void 0===S&&(S=X);return function(ea){return Ha(document,ea,S)}};"click mouseup mousedown mousemove keypress keydown keyup touchend touchstart".split(" ").forEach(I(document));["resize","focus","blur"].forEach(I(window));I(window,ha)("scroll")}if(W.enabled&&(wd||n))for(B in fb=B.getTime(),B=void 0,W.configurations)if(n=W.configurations[B])window.clearInterval(n.activityInterval),D(n,t,e)}function D(e,n,t){var B=function(da,
S){r();da({context:S,pageViewId:za(),minXOffset:gb,minYOffset:ib,maxXOffset:hb,maxYOffset:jb});O()},y=function(){fb+e.configMinimumVisitLength>(new Date).getTime()&&B(e.callback,(n||[]).concat(t?t():[]));e.activityInterval=window.setInterval(I,e.configHeartBeatTimer)},I=function(){fb+e.configHeartBeatTimer>(new Date).getTime()&&B(e.callback,(n||[]).concat(t?t():[]))};e.activityInterval=0===e.configMinimumVisitLength?window.setInterval(I,e.configHeartBeatTimer):window.setTimeout(y,e.configMinimumVisitLength)}
function T(e){var n=e.minimumVisitLength,t=e.heartbeatDelay;e=e.callback;if(qc(n)&&qc(t))return{configMinimumVisitLength:1E3*n,configHeartBeatTimer:1E3*t,callback:e};P.error("Activity tracking minimumVisitLength & heartbeatDelay must be integers")}function Y(e){var n=e.context,t=e.minXOffset,B=e.minYOffset,y=e.maxXOffset,I=e.maxYOffset;e=document.title;e!==Ka&&(Ka=e,La=void 0);e=V;var da=e.track,S=J(oa||ca),ea=rc(La||Ka),xd=J(mb||Ua);t=Math.round(t);y=Math.round(y);B=Math.round(B);I=Math.round(I);
var pa=Ya();pa.add("e","pp");pa.add("url",S);pa.add("page",ea);pa.add("refr",xd);t&&!isNaN(Number(t))&&pa.add("pp_mix",t.toString());y&&!isNaN(Number(y))&&pa.add("pp_max",y.toString());B&&!isNaN(Number(B))&&pa.add("pp_miy",B.toString());I&&!isNaN(Number(I))&&pa.add("pp_may",I.toString());da.call(e,pa,n)}function xa(e){var n=W.configurations[e];0===(null===n||void 0===n?void 0:n.configMinimumVisitLength)?window.clearTimeout(null===n||void 0===n?void 0:n.activityInterval):window.clearInterval(null===
n||void 0===n?void 0:n.activityInterval);W.configurations[e]=void 0}var Fa,Z,Eb,Fb,Gb,Hb,Ib,Jb,Kb,Lb,Mb,Nb,Ob,Pb,Qb,Rb,Sb,Tb,Ub,Vb;q.eventMethod=null!==(Fa=q.eventMethod)&&void 0!==Fa?Fa:"post";var Dc=function(e){var n;return null!==(n=e.stateStorageStrategy)&&void 0!==n?n:"cookieAndLocalStorage"},Ec=function(e){var n;return"boolean"===typeof e.anonymousTracking?!1:!0===(null===(n=e.anonymousTracking)||void 0===n?void 0:n.withSessionTracking)},Fc=function(e){var n;return"boolean"===typeof e.anonymousTracking?
!1:!0===(null===(n=e.anonymousTracking)||void 0===n?void 0:n.withServerAnonymisation)},yd=null!==(Eb=null===(Z=null===q||void 0===q?void 0:q.contexts)||void 0===Z?void 0:Z.browser)&&void 0!==Eb?Eb:!1,Gc=null!==(Gb=null===(Fb=null===q||void 0===q?void 0:q.contexts)||void 0===Fb?void 0:Fb.webPage)&&void 0!==Gb?Gb:!0,na=q.synchronousCookieWrite?zd:Ad;g.push(function(){return{beforeTrack:function(e){var n=w("ses"),t=ya(),B=0===t[10];Wb=Xb?!!na.getCookie(Xb):!1;if(Hc||Wb)Pa();else{"0"===t[0]?(ja=n||"none"==
K?t[6]:Sa(t),ba=t[3]):(new Date).getTime()-Yb>1E3*Bc&&(ba++,ja=Sa(t,{memorizedVisitCount:ba}));vb(t);if(0===t[10]){var y=e.build();t[8]=y.eid;y=y.dtm||y.ttm;t[9]=y?parseInt(y):void 0}t[10]+=1;y=yb();var I=y.documentSize;e.add("vp",y.viewport);e.add("ds",I);e.add("vid",Da?ba:U?null:ba);e.add("sid",Da?ja:U?null:ja);e.add("duid",U?null:t[1]);e.add("uid",U?null:ua);r();e.add("refr",J(mb||Ua));e.add("url",J(oa||ca));y=uc(t,K,U);!Bd||U&&!Da||e.addContextEntity({schema:"iglu:com.snowplowanalytics.snowplow/client_session/jsonschema/1-0-2",
data:y});"none"!=K&&(sa(t),e=fa(),n&&!B||!e||!nb||Zb||(na.flush(),nb(y),Zb=!1));Yb=(new Date).getTime()}}}}());Gc&&g.push(M());yd&&g.push(L());g.push.apply(g,null!==(Hb=q.plugins)&&void 0!==Hb?Hb:[]);var V=ed({base64:null!==(Ib=q.encodeBase64)&&void 0!==Ib?Ib:"post"!==q.eventMethod,corePlugins:g,callback:function(e){Hc||Wb||va.enqueueRequest(e.build())}}),Cd=document.characterSet||document.charset,Aa=tc(window.location.hostname,window.location.href,ub()),wc=sc(Aa[0]),ca=Aa[1],Ua=Aa[2],mb,yc=null!==
(Jb=q.platform)&&void 0!==Jb?Jb:"web",xc=null!==(Kb=q.appId)&&void 0!==Kb?Kb:"",Ic=q.appVersion,oa,Ka=document.title,La,Db=!1,wd=null!==(Lb=q.resetActivityTrackingOnPageView)&&void 0!==Lb?Lb:!0,zc,Ac,Ia=null!==(Mb=q.cookieName)&&void 0!==Mb?Mb:"_sp_",Ca=null!==(Nb=q.cookieDomain)&&void 0!==Nb?Nb:void 0,Dd=null!==(Ob=q.discoverRootDomain)&&void 0!==Ob?Ob:void 0===Ca,Va="/",kb=null!==(Pb=q.cookieSameSite)&&void 0!==Pb?Pb:"Lax",lb=null!==(Qb=q.cookieSecure)&&void 0!==Qb?Qb:!0,Jc=window.navigator.doNotTrack||
window.navigator.msDoNotTrack||window.doNotTrack,Hc="undefined"!==typeof q.respectDoNotTrack?q.respectDoNotTrack&&("yes"===Jc||"1"===Jc):!1,Xb,Cc=null!==(Rb=q.cookieLifetime)&&void 0!==Rb?Rb:63072E3,Bc=null!==(Sb=q.sessionCookieTimeout)&&void 0!==Sb?Sb:1800,Da=Ec(q),Ab=Fc(q),U=!!q.anonymousTracking,K=Dc(q),fb,Yb=(new Date).getTime(),gb,hb,ib,jb,Ba,eb,ja,ba=1,ua,va=od(Q({trackerId:l,endpoint:Qa(u),serverAnonymization:Ab,useLocalStorage:"localStorage"==K||"cookieAndLocalStorage"==K},q),v),Bb=!1,Ja=
null!==(Tb=q.preservePageViewIdForUrl)&&void 0!==Tb?Tb:!1,Cb=void 0,W={enabled:!1,installed:!1,configurations:{}},Bd=null!==(Vb=null===(Ub=q.contexts)||void 0===Ub?void 0:Ub.session)&&void 0!==Vb?Vb:!1,Wb,nb=q.onSessionUpdateCallback,Zb=!1,Kc=function(e){return"boolean"===typeof e?{useExtendedCrossDomainLinker:e}:{useExtendedCrossDomainLinker:!0,collectCrossDomainAttributes:e}}(q.useExtendedCrossDomainLinker||!1),ud=Kc.useExtendedCrossDomainLinker,td=Kc.collectCrossDomainAttributes;Dd&&!Ca&&(Ca=md(kb,
lb));var ob=yb(),Ed=ob.browserLanguage,Fd=ob.resolution,Gd=ob.colorDepth,Hd=ob.cookiesEnabled;var Lc="object"===typeof Intl&&"function"===typeof Intl.DateTimeFormat?(new Intl.DateTimeFormat).resolvedOptions().timeZone:void 0;V.setTrackerVersion(p);V.setTrackerNamespace(m);V.setAppId(xc);V.setPlatform(yc);V.addPayloadPair("cookie",Hd?"1":"0");V.addPayloadPair("cs",Cd);V.addPayloadPair("lang",Ed);V.addPayloadPair("res",Fd);V.addPayloadPair("cd",Gd);Lc&&V.addPayloadPair("tz",Lc);Ic&&V.addPlugin({plugin:{contexts:function(){return[{schema:"iglu:com.snowplowanalytics.snowplow/application/jsonschema/1-0-0",
data:{version:Ic}}]}}});R();Ga();q.crossDomainLinker&&G(q.crossDomainLinker);return Q(Q({},{getDomainSessionIndex:function(){return ba},getPageViewId:za,getTabId:F,newSession:function(){var e=ya();"0"===e[0]?(ja="none"!=K?Sa(e):e[6],ba=e[3]):(ba++,ja=Sa(e,{memorizedVisitCount:ba}));vb(e);if("none"!=K){var n=uc(e,K,U);sa(e);e=fa();na.flush();e&&nb&&(Zb=!0,nb(n))}Yb=(new Date).getTime()},getCookieName:function(e){return Ia+e+"."+Ba},getUserId:function(){return ua},getDomainUserId:function(){return ya()[1]},
getDomainUserInfo:function(){return ya()},setReferrerUrl:function(e){mb=e},setCustomUrl:function(e){r();var n=ca,t;H(e)?oa=e:"/"===e.slice(0,1)?oa=H(n)+"://"+tb(n)+e:(n=J(n),0<=(t=n.indexOf("?"))&&(n=n.slice(0,t)),(t=n.lastIndexOf("/"))!==n.length-1&&(n=n.slice(0,t+1)),oa=n+e)},setDocumentTitle:function(e){Ka=document.title;La=e;Db=!1},discardHashTag:function(e){zc=e},discardBrace:function(e){Ac=e},setCookiePath:function(e){Va=e;R()},setVisitorCookieTimeout:function(e){Cc=e},crossDomainLinker:function(e){G(e)},
enableActivityTracking:function(e){W.configurations.pagePing||(W.enabled=!0,W.configurations.pagePing=T(Q(Q({},e),{callback:Y})))},enableActivityTrackingCallback:function(e){W.configurations.callback||(W.enabled=!0,W.configurations.callback=T(e))},disableActivityTracking:function(){xa("pagePing")},disableActivityTrackingCallback:function(){xa("callback")},updatePageActivity:function(){X()},setOptOutCookie:function(e){Xb=e},setUserId:function(e){ua=e},setUserIdFromLocation:function(e){r();ua=Ra(e,
ca)},setUserIdFromReferrer:function(e){r();ua=Ra(e,Ua)},setUserIdFromCookie:function(e){ua=na.getCookie(e)},setCollectorUrl:function(e){va.setCollectorUrl(Qa(e))},setBufferSize:function(e){va.setBufferSize(e)},flushBuffer:function(e){void 0===e&&(e={});va.executeQueue();e.newBufferSize&&va.setBufferSize(e.newBufferSize)},trackPageView:function(e){void 0===e&&(e={});ia(e)},preservePageViewId:function(){Bb=!0},preservePageViewIdForUrl:function(e){Ja=e},disableAnonymousTracking:function(e){q.anonymousTracking=
!1;bb(e);Ga();va.executeQueue()},enableAnonymousTracking:function(e){var n;q.anonymousTracking=null!==(n=e&&(null===e||void 0===e?void 0:e.options))&&void 0!==n?n:!0;bb(e);Da||Ea()},clearUserData:Pa}),{id:l,namespace:m,core:V,sharedState:v})}(a,b,c,d,f,h);var k=Q(Q({},a),{addPlugin:function(l){var m,p;k.core.addPlugin(l);null===(p=(m=l.plugin).activateBrowserPlugin)||void 0===p?void 0:p.call(m,k)}});g.forEach(function(l){var m;null===(m=l.activateBrowserPlugin)||void 0===m?void 0:m.call(l,k)});return k}
function C(a,b){try{var c=null!==a&&void 0!==a?a:Object.keys(Wa);a=Wa;for(var d=[],f=0;f<c.length;f++){var h=c[f];a.hasOwnProperty(h)?d.push(a[h]):P.warn(h+" not configured")}d.forEach(b)}catch(g){P.error("Function failed",g)}}function Id(){function a(){"hidden"==f.visibilityState&&d.bufferFlushers.forEach(function(g){g(!1)})}function b(){var g;if(!d.hasLoaded)for(d.hasLoaded=!0,g=0;g<d.registeredOnLoadHandlers.length;g++)d.registeredOnLoadHandlers[g]();return!0}function c(){f.addEventListener?f.addEventListener("DOMContentLoaded",
function k(){f.removeEventListener("DOMContentLoaded",k,!1);b()}):f.attachEvent&&f.attachEvent("onreadystatechange",function l(){"complete"===f.readyState&&(f.detachEvent("onreadystatechange",l),b())});Ha(h,"load",b,!1)}var d=new Mc,f=document,h=window;f.visibilityState&&Ha(f,"visibilitychange",a,!1);Ha(h,"beforeunload",function(){d.bufferFlushers.forEach(function(g){g(!1)})},!1);"loading"===document.readyState?c():b();return d}var Q=function(){Q=Object.assign||function(a){for(var b,c=1,d=arguments.length;c<
d;c++){b=arguments[c];for(var f in b)Object.prototype.hasOwnProperty.call(b,f)&&(a[f]=b[f])}return a};return Q.apply(this,arguments)};"function"===typeof SuppressedError?SuppressedError:function(a,b,c){c=Error(c);return c.name="SuppressedError",c.error=a,c.suppressed=b,c};for(var N=[],$b=0;256>$b;++$b)N.push(($b+256).toString(16).slice(1));var Xa,Tc=new Uint8Array(16),bc={randomUUID:"undefined"!==typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)},ra="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
qa;(function(a){a[a.none=0]="none";a[a.error=1]="error";a[a.warn=2]="warn";a[a.debug=3]="debug";a[a.info=4]="info"})(qa||(qa={}));var P=function(a){void 0===a&&(a=qa.warn);return{setLogLevel:function(b){a=qa[b]?b:qa.warn},warn:function(b,c){for(var d=[],f=2;f<arguments.length;f++)d[f-2]=arguments[f];a>=qa.warn&&"undefined"!==typeof console&&(f="Snowplow: "+b,c?console.warn.apply(console,aa([f+"\n",c],d,!1)):console.warn.apply(console,aa([f],d,!1)))},error:function(b,c){for(var d=[],f=2;f<arguments.length;f++)d[f-
2]=arguments[f];a>=qa.error&&"undefined"!==typeof console&&(f="Snowplow: "+b+"\n",c?console.error.apply(console,aa([f+"\n",c],d,!1)):console.error.apply(console,aa([f],d,!1)))},debug:function(b){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];a>=qa.debug&&"undefined"!==typeof console&&console.debug.apply(console,aa(["Snowplow: "+b],c,!1))},info:function(b){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];a>=qa.info&&"undefined"!==typeof console&&console.info.apply(console,aa(["Snowplow: "+
b],c,!1))}}}(),Nc={},Oc={};(function(){var a={rotl:function(b,c){return b<<c|b>>>32-c},rotr:function(b,c){return b<<32-c|b>>>c},endian:function(b){if(b.constructor==Number)return a.rotl(b,8)&16711935|a.rotl(b,24)&4278255360;for(var c=0;c<b.length;c++)b[c]=a.endian(b[c]);return b},randomBytes:function(b){for(var c=[];0<b;b--)c.push(Math.floor(256*Math.random()));return c},bytesToWords:function(b){for(var c=[],d=0,f=0;d<b.length;d++,f+=8)c[f>>>5]|=b[d]<<24-f%32;return c},wordsToBytes:function(b){for(var c=
[],d=0;d<32*b.length;d+=8)c.push(b[d>>>5]>>>24-d%32&255);return c},bytesToHex:function(b){for(var c=[],d=0;d<b.length;d++)c.push((b[d]>>>4).toString(16)),c.push((b[d]&15).toString(16));return c.join("")},hexToBytes:function(b){for(var c=[],d=0;d<b.length;d+=2)c.push(parseInt(b.substr(d,2),16));return c},bytesToBase64:function(b){for(var c=[],d=0;d<b.length;d+=3)for(var f=b[d]<<16|b[d+1]<<8|b[d+2],h=0;4>h;h++)8*d+6*h<=8*b.length?c.push("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(f>>>
6*(3-h)&63)):c.push("=");return c.join("")},base64ToBytes:function(b){b=b.replace(/[^A-Z0-9+\/]/ig,"");for(var c=[],d=0,f=0;d<b.length;f=++d%4)0!=f&&c.push(("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(b.charAt(d-1))&Math.pow(2,-2*f+8)-1)<<2*f|"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(b.charAt(d))>>>6-2*f);return c}};Oc=a})();var ac={utf8:{stringToBytes:function(a){return ac.bin.stringToBytes(unescape(encodeURIComponent(a)))},bytesToString:function(a){return decodeURIComponent(escape(ac.bin.bytesToString(a)))}},
bin:{stringToBytes:function(a){for(var b=[],c=0;c<a.length;c++)b.push(a.charCodeAt(c)&255);return b},bytesToString:function(a){for(var b=[],c=0;c<a.length;c++)b.push(String.fromCharCode(a[c]));return b.join("")}}},Pc=ac;(function(){var a=Oc,b=Pc.utf8,c=Pc.bin,d=function(f,h){var g=a.wordsToBytes,k=f;k.constructor==String?k=b.stringToBytes(k):"undefined"!==typeof Buffer&&"function"==typeof Buffer.isBuffer&&Buffer.isBuffer(k)?k=Array.prototype.slice.call(k,0):Array.isArray(k)||(k=k.toString());f=a.bytesToWords(k);
var l=8*k.length;k=[];var m=1732584193,p=-271733879,u=-1732584194,v=271733878,q=-1009589776;f[l>>5]|=128<<24-l%32;f[(l+64>>>9<<4)+15]=l;for(l=0;l<f.length;l+=16){for(var r=m,z=p,G=u,J=v,H=q,w=0;80>w;w++){if(16>w)k[w]=f[l+w];else{var R=k[w-3]^k[w-8]^k[w-14]^k[w-16];k[w]=R<<1|R>>>31}R=(m<<5|m>>>27)+q+(k[w]>>>0)+(20>w?(p&u|~p&v)+1518500249:40>w?(p^u^v)+1859775393:60>w?(p&u|p&v|u&v)-1894007588:(p^u^v)-899497514);q=v;v=u;u=p<<30|p>>>2;p=m;m=R}m+=r;p+=z;u+=G;v+=J;q+=H}g=g.call(a,[m,p,u,v,q]);return h&&
h.asBytes?g:h&&h.asString?c.bytesToString(g):a.bytesToHex(g)};d._blocksize=16;d._digestsize=20;Nc=d})();var vd=Nc,ld={sessionId:!0,sourceId:!0,sourcePlatform:!1,userId:!1,reason:!1},vc=!1,wb=null,db,Ta="x",Ad=function(){function a(c){b[c]||(b[c]=rd(c));return b[c]}var b={};return{getCookie:function(c){return a(c).getValue()},setCookie:function(c,d,f,h,g,k,l){return a(c).setValue(d,f,h,g,k,l)},deleteCookie:function(c,d,f,h,g){a(c).deleteValue(d,f,h,g)},clearCache:function(){b={}},flush:function(){for(var c=
0,d=Object.values(b);c<d.length;c++)d[c].flush()}}}(),zd={getCookie:ta,setCookie:function(a,b,c,d,f,h,g){ta(a,b,c,d,f,h,g);return-1!==document.cookie.indexOf("".concat(a,"="))},deleteCookie:cb,flush:function(){}},Wa={},Mc=function(){return function(){this.bufferFlushers=[];this.hasLoaded=!1;this.registeredOnLoadHandlers=[]}}(),Qc="undefined"!==typeof window?Id():void 0;x.SharedState=Mc;x.addGlobalContexts=function(a,b){C(b,function(c){c.core.addGlobalContexts(a)})};x.addPlugin=function(a,b){C(b,function(c){c.addPlugin(a)})};
x.clearGlobalContexts=function(a){C(a,function(b){b.core.clearGlobalContexts()})};x.clearUserData=function(a,b){C(b,function(c){c.clearUserData(a)})};x.crossDomainLinker=function(a,b){C(b,function(c){c.crossDomainLinker(a)})};x.disableActivityTracking=function(a){C(a,function(b){b.disableActivityTracking()})};x.disableActivityTrackingCallback=function(a){C(a,function(b){b.disableActivityTrackingCallback()})};x.disableAnonymousTracking=function(a,b){C(b,function(c){c.disableAnonymousTracking(a)})};
x.discardBrace=function(a,b){C(b,function(c){c.discardBrace(a)})};x.discardHashTag=function(a,b){C(b,function(c){c.discardHashTag(a)})};x.enableActivityTracking=function(a,b){C(b,function(c){c.enableActivityTracking(a)})};x.enableActivityTrackingCallback=function(a,b){C(b,function(c){c.enableActivityTrackingCallback(a)})};x.enableAnonymousTracking=function(a,b){C(b,function(c){c.enableAnonymousTracking(a)})};x.flushBuffer=function(a,b){C(b,function(c){c.flushBuffer(a)})};x.newSession=function(a){C(a,
function(b){b.newSession()})};x.newTracker=function(a,b,c){if(Qc){var d="js-".concat("4.5.0");Wa.hasOwnProperty(a)?a=null:(Wa[a]=sd(a,a,d,b,Qc,c),a=Wa[a]);return a}};x.preservePageViewId=function(a){C(a,function(b){b.preservePageViewId()})};x.removeGlobalContexts=function(a,b){C(b,function(c){c.core.removeGlobalContexts(a)})};x.setBufferSize=function(a,b){C(b,function(c){c.setBufferSize(a)})};x.setCollectorUrl=function(a,b){C(b,function(c){c.setCollectorUrl(a)})};x.setCookiePath=function(a,b){C(b,
function(c){c.setCookiePath(a)})};x.setCustomUrl=function(a,b){C(b,function(c){c.setCustomUrl(a)})};x.setDocumentTitle=function(a,b){C(b,function(c){c.setDocumentTitle(a)})};x.setOptOutCookie=function(a,b){C(b,function(c){c.setOptOutCookie(a)})};x.setReferrerUrl=function(a,b){C(b,function(c){c.setReferrerUrl(a)})};x.setUserId=function(a,b){C(b,function(c){c.setUserId(a)})};x.setUserIdFromCookie=function(a,b){C(b,function(c){c.setUserIdFromCookie(a)})};x.setUserIdFromLocation=function(a,b){C(b,function(c){c.setUserIdFromLocation(a)})};
x.setUserIdFromReferrer=function(a,b){C(b,function(c){c.setUserIdFromReferrer(a)})};x.setVisitorCookieTimeout=function(a,b){C(b,function(c){c.setVisitorCookieTimeout(a)})};x.trackPageView=function(a,b){C(b,function(c){c.trackPageView(a)})};x.trackSelfDescribingEvent=function(a,b){C(b,function(c){c=c.core;var d=c.track,f=a.event,h=f.schema,g=f.data;f=Ya();h={schema:"iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",data:{schema:h,data:g}};f.add("e","ue");f.addJson("ue_px","ue_pr",
h);d.call(c,f,a.context,a.timestamp)})};x.trackStructEvent=function(a,b){C(b,function(c){c=c.core;var d=c.track,f=a.category,h=a.action,g=a.label,k=a.property,l=a.value,m=Ya();m.add("e","se");m.add("se_ca",f);m.add("se_ac",h);m.add("se_la",g);m.add("se_pr",k);m.add("se_va",null==l?void 0:l.toString());d.call(c,m,a.context,a.timestamp)})};x.updatePageActivity=function(a){C(a,function(b){b.updatePag