var gaconnector2=function(){const e=["color","date","datetime-local","month","number","range","search","time","url","week"],t={name:[/^name$/i,/^user.*name$/i],email:[/email/i],phone:[/phone/i]};let n=!1;var r=!1;let o,a,i,c,s=!0,l=[],d=null,u=null;const g=!!(window.TextEncoder&&window.Uint8Array&&window.crypto&&window.crypto.subtle&&window.crypto.subtle.digest),f=!!window.crypto&&!!window.crypto.randomUUID,m="https://track.gaconnector.com/track_pageview",h="https://track.gaconnector.com/save_identifier";function p(){n&&console.debug.apply(console,arguments)}const w=e=>{if("function"==typeof navigator.sendBeacon)navigator.sendBeacon(e);else{var t=new XMLHttpRequest;t.open("GET",e,!0),t.send()}},y=()=>{try{if("string"==typeof u&&u.length)return p("resolvePageUrl: using params.pageUrl",u),u;const e=window.location.href;if(-1!==e.indexOf("?"))return p("resolvePageUrl: using window.location.href",e),e;const t="undefined"!=typeof performance&&performance&&"function"==typeof performance.getEntriesByType?performance.getEntriesByType("navigation"):[],n=t&&t[0]&&t[0].name;return n&&-1!==n.indexOf("?")&&new URL(n).origin===new URL(e).origin?(p("resolvePageUrl: using performance navigation entry",n),n):(p("resolvePageUrl: falling back to window.location.href (no query string available anywhere)",e),e)}catch(e){return p("resolvePageUrl: error, falling back to window.location.href",e),window.location.href}},v=e=>new Promise((function(t,n){!function n(){var r=new Promise((function(t,n){!function(){window.dataLayer.push(arguments)}("get",a,e,(function(e){t(e)}))})),o=new Promise((function(e,t){setTimeout((function(){t(new Error("Timeout after 200ms"))}),200)}));Promise.race([r,o]).then((function(e){e?t(e):setTimeout(n,200)})).catch((function(e){setTimeout(n,200)}))}()})),b=()=>{if(window.dataLayer){var e=window.dataLayer.find((function(e){return"config"===e[0]&&e[1].startsWith("G-")}));if(e)return p("Found measurement id in dataLayer",e[1]),e[1]}if(window.google_tag_data&&google_tag_data.tidr&&google_tag_data.tidr.container){var t=Object.keys(google_tag_data.tidr.container);if(t.length>0){var n=t.find((function(e){return e.startsWith("G-")}));if(n)return p("Found measurement id in google_tag_data",n),n}}let r=(()=>{const e=document.cookie.split("; ").find((e=>e.startsWith("_ga_")));if(e){const t=e.split("=")[0];if(/^_ga_[A-Z0-9]+$/.test(t))return"G-"+t.replace("_ga_","")}return null})();return r?(p("Found measurement id in cookie",r),r):(p("No measurement id found"),r)},k=()=>{const e=document.cookie.split("; ").find((e=>"_ga"===e.split("=")[0]));if(e){let t=e.split("=")[1].split(".");return t.length<4?null:t[2]+"."+t[3]}return null},_=()=>{var e=b(),t=document.cookie.split("; ").find((function(t){return t.startsWith("_ga_"+e.replace("G-",""))}));if(t){var n=t.split("=");if(2===n.length){var r=n[1].split(".");if(r.length>2){var o=r[2];if(parseInt(o)===new Date(1e3*o).getTime()/1e3)return o}}}return null},S=e=>{if("localhost"===window.location.hostname)return"localhost";for(var t,n=e.split("/")[2],r=[/[-\w]+(?:\.(?:com|org|net|int|edu|gov|io|ai|gg|info|xyz|site|biz|aero|mil|name|coop|jobs|travel|online|live|shop|store|xn--[-\w]+|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bl|bm|bn|bo|bq|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cw|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mf|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw)){1,2}$/i,/[-\w]+\.(?:[-\w]+\.xn--[-\w]+|[-\w]{2,}|[-\w]+\.[-\w]{2})$/i],o=0;oe.length)).length>2?t.replace("www.",""):t},I=e=>{var t=e.match(/:\/\/(www[0-9]?\.)?(.[^/:]+)/i);return null!=t&&t.length>2&&"string"==typeof t[2]&&t[2].length>0?t[2]:null},j=(e,t,n)=>{s?localStorage.setItem(e,t):((e,t,n)=>{p("Setting cookie",e,t);var r=new Date;r.setTime(r.getTime()+31536e6);var o="expires="+r.toUTCString();document.cookie=e+"="+t+"; "+o+";domain=."+S(window.location.href)+";path=/"})(e,t)},E=e=>{e+="=";for(var t=document.cookie.split(";"),n=0;ns&&localStorage.getItem(e)||E(e),A=()=>{if(f)return crypto.randomUUID();function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()},L=e=>{if(g){const t=(new TextEncoder).encode(e);return new Promise(((e,n)=>{window.crypto.subtle.digest("SHA-256",t).then((t=>{const n=Array.from(new Uint8Array(t)).map((e=>("00"+e.toString(16)).slice(-2))).join("");e(n.toUpperCase())})).catch(n)}))}return Promise.resolve(function(e){function t(e,t){return e>>>t|e<<32-t}function n(e,t){return e>>>t}function r(e,t,n){return e&t^~e&n}function o(e,t,n){return e&t^e&n^t&n}function a(e){return t(e,2)^t(e,13)^t(e,22)}function i(e){return t(e,6)^t(e,11)^t(e,25)}function c(e){return t(e,7)^t(e,18)^n(e,3)}var s,l=new Array(1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998);function d(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}return(s=e,function(e){for(var t,n="0123456789abcdef",r="",o=0;o>>4&15)+n.charAt(15&t);return r}(function(e){return function(e){for(var t="",n=0;n<32*e.length;n+=8)t+=String.fromCharCode(e[n>>5]>>>24-n%32&255);return t}(function(e,s){var u,g,f,m,h,p,w,y,v,b,k,_,S,I=new Array(1779033703,-1150833019,1013904242,-1521486534,1359893119,-1694144372,528734635,1541459225),j=new Array(64);for(e[s>>5]|=128<<24-s%32,e[15+(s+64>>9<<4)]=s,v=0;v>2),n=0;n>5]|=(255&e.charCodeAt(n/8))<<24-n%32;return t}(e),8*e.length))}(function(e){for(var t,n,r="",o=-1;++o>>6&31,128|63&t):t<=65535?r+=String.fromCharCode(224|t>>>12&15,128|t>>>6&63,128|63&t):t<=2097151&&(r+=String.fromCharCode(240|t>>>18&7,128|t>>>12&63,128|t>>>6&63,128|63&t));return r}(s)))).toUpperCase()}(e))},T=(e,t)=>{p("identify",e,t),o&&d&&e&&t&&L(t.toLowerCase()).then((t=>{const n=new URL(h),r={gaconnector_id:o,account_id:d,name:e,value_hash:t,gamid:a,gacid:i,gasid:c};for(let e in r)n.searchParams.set(e,r[e]);w(n.toString())})).catch(console.error)},C=()=>{Array.from(document.getElementsByTagName("input")).filter((t=>!t.getAttribute("data-gaconnector-tracked")&&!e.includes(t.type))).forEach((e=>{e.setAttribute("data-gaconnector-tracked",!0),e.addEventListener("change",R)}))},R=e=>{if(n=e.target.value,/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(n))T("email",e.target.value);else for(const n in t)t[n].some((t=>t.test(e.target.name)||t.test(e.target.id)))&&T(n,e.target.value);var n},P=()=>{p("initializeTrackPageview",{insideIframe:x(),automatedTesting:r}),x()&&!r||((()=>{p("Track pageview triggered");const e=new URL(m),t=y(),n=new URL(t).searchParams,r={gaconnector_id:o,account_id:d,referer:document.referrer,page_url:t};["gclid","utm_source","utm_medium","utm_campaign","utm_term","utm_content"].forEach((function(e){const t=n.get(e);r[e]=t||""}));for(let t in r)e.searchParams.set(t,r[t]);w(e.toString())})(),new Promise((function(e,t){let n=0;!function t(){n++,p("Attempting to get measurement id");var r=b();if(r)e(r);else{if(n>=50)return p("Timeout getting measurement id"),e();setTimeout(t,200)}}()})).then((function(e){a=e,a&&(new Promise((function(e,t){if(window.gtag||window.dataLayer)return void v("client_id").then((function(t){p("Got client id from dataLayer",t),e(t)})).catch((function(t){let n=k();if(n)return p("Got client id from cookie (error fallback)",n),e(n);p("No client id found (error fallback)"),e()}));let n=k();return n&&p("Got client id from cookie (fallback)",n),e(n)})).then((function(e){i=e})).catch((function(e){console.error(e)})),new Promise((function(e,t){if(!window.gtag&&!window.dataLayer){var n=_();return n?(p("Got session id from cookie (fallback)",n),e(n)):e(null)}v("session_id").then((function(t){p("Got session id from dataLayer",t),e(t)})).catch((function(t){var n=_();if(n)return p("Got session id from cookie (error fallback)",n),e(n);p("No session id found (error fallback)"),e()}))})).then((function(e){c=e})).catch((function(e){console.error(e)})))})).catch((function(e){console.error(e)})))},x=()=>self!==top,z=()=>{for(var e=document.querySelectorAll("iframe"),t=0;t{e.data&&"object"==typeof e.data&&e.data.gaconnectorId&&(p("Received iframe message",e),o=e.data.gaconnectorId,d=e.data.accountId,j("gaconnector2_id",o,365),e.data.gaMeasurementId&&(a=e.data.gaMeasurementId),e.data.gaClientId&&(i=e.data.gaClientId),e.data.gaSessionId&&(c=e.data.gaSessionId))},O=e=>{var t,n=e.dataset.originalHref;return void 0===n&&(e.dataset.originalHref=e.href,n=e.href),t=n.indexOf("?")>-1?"&":"?",e.href=n+t+"gaconnectorId="+o,e.href},G=()=>{for(var e=S(window.location.href),t=I(window.location.href),n=document.getElementsByTagName("a"),r=0;r-1&&a!==e||s&&l.indexOf(i)>-1&&i!==t)&&O(o)}},W=e=>{document.cookie=e+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"},q=e=>{localStorage.removeItem(e)},M=e=>{const t=!!window.localStorage&&!!window.localStorage.setItem,n=!!e&&"localStorage"===e.storageEngine,r=!e||"string"!=typeof e.storageEngine,o=!!e&&!!e.internalDomains&&!!e.internalDomains.length;s=t&&(n||r&&!o),gaconnector2.useLocalStorage=s;const a=(()=>{for(var e={},t=document.cookie.split("; "),n=0;n13&&"gaconnector2_"==r.substring(0,13)&&(e[r.replace("gaconnector2_","")]=o)}return e})(),i=(()=>{for(var e=Object.keys(localStorage),t={},n=0;n0)return;t.resolveWith(document,[o])}},bindReady:function(){if(!t){if(t=o._Deferred(),"complete"===document.readyState)return setTimeout(o.ready,1);if(document.addEventListener)document.addEventListener("DOMContentLoaded",n,!1),window.addEventListener("load",o.ready,!1);else if(document.attachEvent){document.attachEvent("onreadystatechange",n),window.attachEvent("onload",o.ready);var r=!1;try{r=null==window.frameElement}catch(e){}document.documentElement.doScroll&&r&&e()}}},_Deferred:function(){var e,t,n,r=[],a={done:function(){if(!n){var t,i,c,s,l,d=arguments;for(e&&(l=e,e=0),t=0,i=d.length;t{d=e,"object"==typeof t&&null!==t&&"string"==typeof t.pageUrl&&t.pageUrl.length&&(u=t.pageUrl),o=(()=>{const e=new URL(y()).searchParams.get("gaconnectorId"),t=U("gaconnectorId")||U("gaconnector2_id"),n=e||t||A();return n!==U("gaconnector2_id")&&j("gaconnector2_id",n,365),n})(),(e=>{if(!0===e)n=!0;else try{var t=document.querySelector('script[src*="gaconnector.js"]');t||(t=document.querySelector('script[src*="https://track.gaconnector.com/js"]')),t&&"true"===new URL(t.src).searchParams.get("debug")&&(n=!0)}catch(e){console.error(e)}n&&p("GA Connector debugging enabled")})("object"==typeof t&&t.debug),M(t),r="object"==typeof t&&!0===t.automatedTesting,!1!==t.iframeEnabled&&(x()?(p("Adding receiveGaConnectorId listener"),window.addEventListener("message",D,!1)):(p("Messaging child iframes"),z(),setInterval(z,1e3))),P(),N((function(){C(),setInterval(C,1e3),t.internalDomains&&(l=t.internalDomains,G(),setInterval(G,1e3))}))},identify:T,debugData:()=>JSON.parse(JSON.stringify({accountId:d,gaconnectorId:o,gaSessionId:c||null,gaClientId:i||null,gaMeasurementId:a||null,cryptoApiSupported:g,cryptoRandomUuidSupported:f,settingsPageUrl:u,pageUrl:y()}))};return Object.freeze?Object.freeze(B):B}();