!function(){"use strict";let s=null;const c=["debug","info","warn","error"];let l=c.reduce((e,a,d)=>(e[a]=function(){var e="debug"===a?"log":a;if(s&&console&&"function"==typeof console[e]){var t=c.indexOf(s.toString().toLocaleLowerCase());if(!0===s||-1{p[i].push(e)});for(let n=0;ne[1]).flatMap(e=>e);for(var t of e){let e=t.value.trim();if(g(e)){l.debug("We detected: ",e),m();break}}}catch(e){}};v[i].push(a),o[n].addEventListener(u.detectionEventType,a,{once:!0,capture:!0})}let d=_(e);for(let e=0;e()\[\].,;:\s@"]+(\.[^<>()\[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,}))/i;if(u.detectionSubject.includes("email")&&t.test(e))return e=e.match(t)[0].toLowerCase().trim(),l.debug("We detected email: "+e),a(e,"email"),!0;return!1}(e)||!1}function y(n,i){u.detectDynamicNodes&&(o[i]=new d(function(e,t){l.debug("Detected dynamically added nodes."),r(n,i)},500),o[i].observe(n,{childList:!0,subtree:!0,attributes:!0}))}function i(e){e&&e.type&&e.identifier?"email"!==e.type?l.error("Identifier type is not supported, ",e.type):(a(e.identifier,e.type),m()):l.error("wrong identifier format")}function a(e,t){var n;e&&t&&(n=new CustomEvent("detected-identifier",{detail:{identifier:e,type:t}}),l.info("Dispatched event with identifier: ",e," and type: ",t),window.dispatchEvent(n))}function h(e){if(e&&e.__upixel_detection)try{r(e.__upixel_detection.root,e.__upixel_detection.scopeName)}catch(e){}}function w(t,n,i){l.debug(`collectElements("${n}", ${i})`);let o=[];for(var e of i)0{o.includes(e)||o.push(e)});var r=window.location.hostname,a=document.getElementsByTagName("iframe");for(let e=0;e{o.includes(e)||o.push(e)})}return o}function _(e){return[...e.querySelectorAll("*")].filter(e=>!!e.shadowRoot).map(e=>e.shadowRoot)}function d(e,t){this.callback=e,this.minDelayMs=t,this.lastInvocationTime=0,this.args=null,this.nextTimeoutHandle=null,this.mutationObserver=new MutationObserver(this.throttledCallback.bind(this))}d.prototype.observe=function(e,t){this.mutationObserver.observe(e,t)},d.prototype.disconnect=function(){null!=this.nextTimeoutHandle&&clearTimeout(this.nextTimeoutHandle),this.mutationObserver.disconnect()},d.prototype.takeRecords=function(){return this.mutationObserver.takeRecords()},d.prototype.throttledCallback=function(e,t){var n=Date.now();null!=this.args?this.args=arguments:this.lastInvocationTime+this.minDelayMse("debug"),window.ttdPixel.disableLog=()=>e(null)}();var ttd_dom_ready=function(){var t,n,i={"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regexp","[object Object]":"object"},l={isReady:!1,readyWait:1,holdReady:function(e){e?l.readyWait++:l.ready(!0)},ready:function(e){if(!0===e&&!--l.readyWait||!0!==e&&!l.isReady){if(!document.body)return setTimeout(l.ready,1);(l.isReady=!0)!==e&&0<--l.readyWait||t.resolveWith(document,[l])}},bindReady:function(){if(!t){if(t=l._Deferred(),"complete"===document.readyState)return setTimeout(l.ready,1);if(document.addEventListener)document.addEventListener("DOMContentLoaded",n,!1),window.addEventListener("load",l.ready,!1);else if(document.attachEvent){document.attachEvent("onreadystatechange",n),window.attachEvent("onload",l.ready);var e=!1;try{e=null==window.frameElement}catch(e){}document.documentElement.doScroll&&e&&o()}}},_Deferred:function(){var a,n,d,s=[],c={done:function(){if(!d){var e,t,n,i,o,r=arguments;for(a&&(o=a,a=0),e=0,t=r.length;e{var n=document.createElement("script");n.setAttribute("defer",!0),n.setAttribute("src","https://js.adsrvr.org/uid2-sdk.js"),n.addEventListener("load",()=>{e(),i()}),n.addEventListener("error",e=>{t(e),o(e)}),document.body.appendChild(n)}):(async()=>{try{await window.ttdPixel.uid2SdkLoaderPromise,i()}catch(e){console.warn("Failed to load uid2 sdk: ",e)}})())};var l=document.getElementsByTagName("body")[0];if(l){var u="",p={},f={MonetaryValue:"v",MonetaryValueFormat:"vf"},v=[];if("undefined"!=typeof _pixelParams)for(var m in _pixelParams){var g=_pixelParams[m],m=f[m];m&&g&&!/%%.*%%/i.test(g)&&(g=encodeURIComponent(g),v.push(m+"="+g),p[m]=g)}var y="adv="+r,h="upid="+d.join(","),w=(p.adv=r,G||function(){var e=window,t="",n=!1;try{top.location.href&&(t=top.location.href)}catch(e){n=!0}if(n)for(;;)try{if(t=e.document.referrer,window.parent==e)break;e=window.parent}catch(e){break}-1{n=e});var E=null,D=!1,T=null;"function"==typeof __tcfapi?(k=setTimeout(z,1e3),__tcfapi("addEventListener",2,B)):"function"==typeof __cmp?(E=setTimeout($,1e3),__cmp("ping",null,U)):"function"==typeof __gpp?void 0!==(y=I()).gppString?N(y.gppString,y.gppSid):(L=setTimeout(F,1e3),__gpp("addEventListener",M)):R();let i=!1;void 0!==t&&(i=!0);let o=r+":"+d.join(","),a=!1;i?(a=!0,this.setupUid2Sdk(o,()=>j(t),e=>{console.warn("UID2 enabled but failed to register hooks: ",e)})):window.addEventListener("message",e=>{try{if(null!==e.origin&&"null"!==e.origin){var t=new URL(e.origin);if(t.hostname.endsWith(".adsrvr.org")&&!i&&"string"==typeof e.data){const n=JSON.parse(e.data);n.type&&"string"==typeof n.type&&"UID2"===n.type&&n.advertiserId&&"string"==typeof n.advertiserId&&n.advertiserId==r&&(a=!0,this.setupUid2Sdk(o,()=>j(n),e=>{console.warn("UID2 enabled but failed to register hooks: ",e)}))}}}catch(e){}});var L=null,S=!1,k=null,x=!1;async function P(){"hidden"===document.visibilityState&&(c&&await W(p),document.removeEventListener("visibilitychange",P))}async function H(e,n){try{var t,i,o=e();!o&&function(e){if("string"==typeof e.subscriptionId&&"string"==typeof e.serverPublicKey)return 1;console.error("subscription id and serverPublicKey must both be provided and both be strings to run cstg")}(n)&&(void 0!==n.email?window.__uid2.setIdentityFromEmail(n.email,n):void 0!==n.emailHash?window.__uid2.setIdentityFromEmailHash(n.emailHash,n):void 0!==n.phone&&window.__uid2.setIdentityFromPhone(n.phone,n)),o?(c?await W(p,o.advertising_token):await O(o.advertising_token),document.removeEventListener("visibilitychange",P)):window.ttdPixel.activeDetection||(t=new Promise(t=>{window.addEventListener("detected-identifier",function(e){t(e.detail.identifier),window.ttdPixel.activeDetection=null}),window.ttdPixel.startDetection(n)}),i=await(window.ttdPixel.activeDetection=t),await window.__uid2.setIdentityFromEmail(i,n))}catch(e){console.warn("error setting up fireOrDetact: ",e)}}function j(n){try{window.__uid2.callbacks.push(async(e,t)=>{switch(e){case"SdkLoaded":try{window.__ttd_m_invoke_once=window.__ttd_m_invoke_once||{},window.__ttd_m_invoke_once._uid2_init||(window.__ttd_m_invoke_once._uid2_init=1,n.baseUrl||(n.baseUrl="https://global.prod.uidapi.com"),__uid2.init({baseUrl:n.baseUrl}))}catch(e){console.info("Non-TTD actor initialized UID2 SDK, mind the consistency of UID2 baseUrl.")}break;case"InitCompleted":await H(()=>t.identity,n);break;case"IdentityUpdated":c?await W(p,t.identity.advertising_token):await O(t.identity.advertising_token),document.removeEventListener("visibilitychange",P)}})}catch(e){console.warn("Did not setup uid2 hooks: ",e)}}function I(){var e,t=__gpp("getGPPData"),t={gppString:t?.gppString,gppSid:t?.applicableSections?.join(",")};return void 0===t.gppString&&(e=__gpp("ping"),t.gppString=e?.gppString,t.gppSid=e?.applicableSections?.join(",")),t}function M(e,t){var n;S?__gpp("removeEventListener",function(){},e.listenerId):"signalStatus"===e.eventName&&"ready"===e.data&&(n=I(),clearTimeout(L),T=new Date,N(n.gppString,n.gppSid),__gpp("removeEventListener",function(){},e.listenerId))}function F(){S=!0,R()}function $(){D=!0,R()}function U(e){D||(e.cmpLoaded||e.gdprAppliesGlobally?(clearTimeout(E),T=new Date,__cmp("getConsentData",null,R)):setTimeout(function(){__cmp("ping",null,U)},200))}function R(e){var t;null!=T&&(t=new Date-T,u=u+"&ret="+t,p.ret=t),D&&(u+="&pto=1",p.pto="1"),null!=e&&(t=e.gdprApplies?"1":"0",u=u+"&gdpr="+t+"&gdpr_consent="+e.consentData,p.gdpr=t,p.gdpr_consent=e.consentData),A()}async function A(){var e="universal_pixel_"+d.join("_");n(u),await C(u,e,"TTD Universal Pixel"),document.addEventListener("visibilitychange",P)}async function O(e,t){await C(await q+"&uiddt="+e+"&uidcs="+t,"universal_pixel_"+d.join("_")+"_uid","TTD Universal Pixel with UID")}async function C(e,t,n){let i=document.getElementById(t);for(;i&&i.parentElement.removeChild(i),i=document.getElementById(t););let o=document.createElement("iframe");function r(){l.appendChild(o),setTimeout(async()=>{c&&!a&&(await W(p),document.removeEventListener("visibilitychange",P))},1e3)}o.setAttribute("id",t),o.setAttribute("height",0),o.setAttribute("width",0),o.setAttribute("style","display:none;"),o.setAttribute("src",e),o.setAttribute("title",n),"complete"===document.readyState?setTimeout(r,0):window.addEventListener?window.addEventListener("load",r):window.attachEvent?window.attachEvent("onload",r):r()}function z(){x=!0,R()}function B(e,t){var n;x?__tcfapi("removeEventListener",2,function(e){},e.listenerId):t&&(clearTimeout(k),t=e,null!=T&&(n=new Date-T,u=u+"&ret="+n,p.ret=n),x&&(u+="&pto=1",p.pto="1"),null!=t&&(n=function(e){return e?"1":"0"}(t.gdprApplies),u=u+"&gdpr="+n+"&gdpr_consent="+t.tcString,p.gdpr=n,p.gdpr_consent=t.tcString),A(),T=new Date,__tcfapi("removeEventListener",2,function(e){},e.listenerId))}function N(e,t){var n;null!=T&&(n=new Date-T,u=u+"&ret="+n,p.ret=n),null!=e&&(u=u+"&gpp_consent="+e,p.gpp_consent=e),null!=t&&(u=u+"&gpp_sid="+t,p.gpp_sid=t),A()}async function W(i,e){i.pixel_ids=d,e&&(i.uid2_token=e);const o={data:[{...i}]},r=`https://${J(s)}/track/realtimeconversion`;return new Promise((e,t)=>{const n=new XMLHttpRequest;n.withCredentials=!0,n.open("POST",r),n.setRequestHeader("Content-type","application/json"),n.setRequestHeader("eventDataSource","UpSdk"),n.setRequestHeader("eventDataSourceVersion",K),n.onload=()=>{(200<=n.status&&n.status<300?e:t)(n.response)},n.onerror=async()=>{t(n.statusText),async function(e){var t="universal_pixel_"+d.join("_");e.eds="UpSdkGet",e.edsv=K,e.upid=d.join(",");const{pixel_ids:n,...i}=e;e=new URLSearchParams(i),await C(`https://${J(s)}/track/rt`+"?"+e.toString(),t,"TTD Universal Pixel Realtime")}(i)},n.send(JSON.stringify(o))})}}}this.init=async function(t,n,i,o,r,a){if(("string"==typeof arguments[3]||!arguments[3]&&7<=arguments.length)&&(arguments[3]=null,4