/** * @id5io/id5-api.js * @version v1.0.97 * @link https://id5.io/ * @license Apache-2.0 */ !function(){"use strict";function r(t,e){var i,r=Object.keys(t);return Object.getOwnPropertySymbols&&(i=Object.getOwnPropertySymbols(t),e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,i)),r}function h(t){for(var e=1;ee.length)&&(t=e.length);for(var i=0,r=new Array(t);i=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:t}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,n=!0,o=!1;return{s:function(){i=i.call(e)},n:function(){var e=i.next();return n=e.done,e},e:function(e){o=!0,s=e},f:function(){try{n||null==i.return||i.return()}finally{if(o)throw s}}}}function n(e,t,i){return function(e,t){if(e!==t)throw new TypeError("Private static access of wrong provenance")}(e,t),i}function o(e,t,i){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return i}class e{debug(){}info(){}warn(){}error(){}}const p=new e;class d extends e{constructor(e,t){super(),this._prefix=e,this._delegate=t}debug(){for(var e=arguments.length,t=new Array(e),i=0;iparseInt(e)||0,e=(e,t)=>{t=e-t;return 0==t?0:t<0?-1:1},t=e(i(r[0]),i(s[0]));if(0!==t)return t;t=e(i(r[1]),i(s[1]));return 0===t?e(i(r[2]),i(s[2])):t}}const _="Array",m="String",I="Function",w=Object.prototype.toString;function y(e,t){return w.call(e)==="[object "+t+"]"}function S(e){return y(e,I)}function b(e){return y(e,m)}function C(e){return y(e,_)}function D(e){return y(e,"Number")}function E(e){return y(e,"Object")}function A(e){return void 0!==e}function T(t,i){if(!function(e){if(!e)return 1;if(C(e)||b(e))return!(0{let i=t.split("="),r=g(i,2),s=r[0],n=r[1];return/\[\]$/.test(s)?(s=s.replace("[]",""),e[s]=e[s]||[],e[s].push(n)):e[s]=n||"",e},{}):{},hash:(i.hash||"").replace(/^#/,""),host:i.host||window.location.host}}function O(e){return(e.protocol||"http")+"://"+(e.host||e.hostname+(e.port?":".concat(e.port):""))+(e.pathname||"")+(e.search?"?".concat((i=e.search||"",Object.keys(i).map(t=>Array.isArray(i[t])?i[t].map(e=>"".concat(t,"[]=").concat(e)).join("&"):"".concat(t,"=").concat(i[t])).join("&"))):"")+(e.hash?"#".concat(e.hash):"");var i}function R(i,e){function r(e,t){if(S(Math.imul))return Math.imul(e,t);var i=(4194303&e)*(t|=0);return 4290772992&e&&(i+=(4290772992&e)*t|0),0|i}e=1>>16,2246822507)^r(n^n>>>13,3266489909),n=r(n^n>>>16,2246822507)^r(s^s>>>13,3266489909),(4294967296*(2097151&n)+(s>>>0)).toString()}const x="TRUE"===M("id5_debug").toUpperCase(),L="TRACE"===M("id5_debug").toUpperCase(),U=Boolean(window.console);let N=!1;function F(e,t,i,r,s){k()&&U&&e&&e.apply(console,["%cID5 - ".concat(t,"#").concat(i),"color: #fff; background: #1c307e; padding: 1px 4px; border-radius: 3px;",r].concat(s))}function k(){return x||L||N}class j extends e{constructor(e,t){super(),l(this,"_invocationId",void 0),l(this,"_origin",void 0),this._invocationId=t,this._origin=e}debug(){for(var e=arguments.length,t=new Array(e),i=0;inull!=e&&"object"==typeof e;function Q(e,t){if(!(K(e)&&K(t)))return e===t;if(H(e)&&H(t))return function(t,i){var e=t.length===i.length;if(!e)return!1;for(let e=0;et[e]).reduce((e,t)=>e&&t,!0);return new ce(r,ae.CONSENT_API,t,i)}_addToDebugInfo(e,t,i){return void 0!==t.localStoragePurposeConsent&&(i[e+"-localStoragePurposeConsent"]=t.localStoragePurposeConsent),void 0!==t.vendorsConsentForId5Granted&&(i[e+"-vendorsConsentForId5Granted"]=t.vendorsConsentForId5Granted),i}_isGranted(){return!1===this.gdprApplies||!0===this.localStoragePurposeConsent&&!1!==this.vendorsConsentForId5Granted}hashCode(){this.localStoragePurposeConsent,this.ccpaString;var e=t(this,Z);return R(JSON.stringify(e))}static createFrom(e){const t=u(new oe,e);return A(t.api)&&(t.apiTypes=function(e){var t=e.api;if(t===te.NONE)return[];if(t!==te.PREBID)return[t];{const i=[];return(A(e.gdprApplies)||A(e.consentString))&&i.push(te.TCF_V2),A(e.ccpaString)&&i.push(te.USP_V1),A(e.gppData)&&A(e.gppData.version)&&i.push(e.gppData.version),i}}(e),t.api=void 0),E(t.gppData)&&(t.gppData=ne.createFrom(t.gppData)),t}getApiTypeData(e){if(this.apiTypes.includes(e)){if(e===te.USP_V1)return{ccpaString:this.ccpaString};if(e===te.TCF_V2)return{consentString:this.consentString,gdprApplies:this.gdprApplies,localStoragePurposeConsent:this.localStoragePurposeConsent};if(e===te.GPP_V1_1||e===te.GPP_V1_0)return this.gppData;if(e===te.ID5_ALLOWED_VENDORS)return{allowedVendors:this.allowedVendors}}}toConsents(){let e={};return A(this.gdprApplies)&&(e.gdpr=this.gdprApplies),A(this.consentString)&&(e.gdpr_consent=this.consentString),A(this.ccpaString)&&(e.us_privacy=this.ccpaString),A(this.gppData)&&(e.gpp=this.gppData.gppString,e.gpp_sid=this.gppData.applicableSections.join(",")),e}}const ae=Object.freeze({FORCE_ALLOWED_BY_CONFIG:"force_allowed_by_config",ID5_CONSENT:"id5_consent",PROVISIONAL:"provisional",JURISDICTION:"jurisdiction",CONSENT_API:"consent_api"});class ce{constructor(e,t){var i=2function(i){Object.keys(i).forEach(function(e){var t=i[e];t&&(t instanceof Object?i[e]=JSON.stringify(t):i[e]="".concat(t))})}(e.tags)),fetch(this.url,{method:"POST",headers:{"Content-Type":"text/plain"},mode:"no-cors",body:JSON.stringify({metadata:h(h({},this._metadata),t),measurements:e})})):Promise.resolve()}}class he{constructor(e,t){l(this,"_publisher",void 0),l(this,"_scheduled",void 0),this.meterRegistry=e,this._publisher=t;const i=this;this.meterRegistry.onUnregister(function(){const e=i._onUnloadPublishAbortController;if(e)return e.abort(),i.publish({trigger:"unregister"})})}publish(){let t=0this._publisher(e,t)).then(()=>this.meterRegistry.reset())}schedulePublishAfterMsec(e){const t=this;return t._scheduled||(setTimeout(()=>(t._scheduled=!1,t.publish({trigger:"fixed-time",fixed_time_msec:e})),e),t._scheduled=!0),this}schedulePublishBeforeUnload(){const e=this;var t="undefined"!=typeof AbortController?new AbortController:void 0;return t&&(addEventListener("beforeunload",()=>e.publish({trigger:"beforeunload"}),{capture:!1,signal:t.signal}),this._onUnloadPublishAbortController=t),this}}const ue=Object.freeze({});var ge={EMPTY:ue,from:function(e){return e?e instanceof Map?Object.fromEntries(e):e:ue},toString:function(e){return Array.from(Object.entries(e),e=>{var t=g(e,2),e=t[0],t=t[1];return"".concat(e,"=").concat(t)}).sort().toString()}};const pe=Object.freeze({TIMER:"TIMER",SUMMARY:"SUMMARY",COUNTER:"COUNTER"});class ve{constructor(e,t,i){l(this,"name",void 0),l(this,"tags",void 0),l(this,"values",void 0),this.name=e,this.tags=ge.from(t),this.type=i,this.values=[]}reset(){this.values=[]}}class _e extends ve{constructor(e){super(e,1{return g(e,2)[1]})}}function Se(){return new fe}function be(e){return{partner:e}}class Ce extends class{constructor(){var e=0({name:e.name,type:e.type,tags:e.tags,values:e.values})).filter(function(e){return e.values&&0e.reset())}addCommonTags(e){this.commonTags=h(h({},this.commonTags),ge.from(e))}timer(e){return this.getOrCreate(e,1new _e(e,t))}counter(e){return this.getOrCreate(e,1new me(e,t))}summary(e){return this.getOrCreate(e,1new Ie(e,t))}unregister(){void 0!==this._onUnregisterCallback&&this._onUnregisterCallback(this)}onUnregister(e){this._onUnregisterCallback=e}}{constructor(e,t){var i=2{var e=i("ping",function(e){t(e)});B(e)&&t(e)});switch(s.gppVersion){case Re.version:return new Re(s,i,r);case Le.version:return new Le(s,i,r,c);default:var n="Unsupported version of gpp: ".concat(s.gppVersion);return a.warn(n),Promise.reject(n)}})()}static caTcfDataHasExpressConsent(e){e=e.PurposesExpressConsent;if(H(e)&&0e==ee)}static tcfDataHasLocalStorageGrant(e){e=n(Pe,Pe,Oe).call(Pe,e,"PurposeConsent","PurposeConsents");if(H(e)&&0e==ee))}static getTcfData(e){let t=void 0;return H(e)&&B(e[0])?t=e[0]:B(e)&&(t=e),t}}function Oe(e,t,i){return t in e?e[t]:e[i]}class Re extends Pe{constructor(e,t,i){super(i,Re.version),l(this,"gppFn",void 0),l(this,"ready",void 0),this.gppFn=t,this.ready=this.isReady(e)}isReady(e){return"loaded"===e.cmpStatus&&"visible"!==e.cmpDisplayStatus}getClientConsentData(){var r=this;return i(function*(){r.ready||(r.ready=yield new Promise(t=>{r.gppFn("addEventListener",e=>!!r.isReady(e.pingData)&&void t(!0))}));var e=new Promise(t=>{r.gppFn("getGPPData",e=>{t(e)})}),t=new Promise(t=>{r.gppFn("getSection",e=>{t(e)},"tcfeuv2")}),e=g(yield Promise.all([e,t]),2),t=e[0],e=e[1];const i=new ne(te.GPP_V1_0,t.applicableSections,t.gppString);return e&&(i.euTcfSection=new se(Pe.tcfDataHasLocalStorageGrant(e),Pe.tcfDataHasID5VendorConsented(e))),i})()}}function xe(e,t,i){i&&(e.apiTypes.push(t),u(e,i))}l(Re,"version","1.0");class Le extends Pe{constructor(e,t,i,r){super(i,Le.version),l(this,"gppFn",void 0),l(this,"readyPingData",void 0),l(this,"metrics",void 0),this.gppFn=t,"ready"===e.signalStatus&&(this.readyPingData=e),this.metrics=r}getClientConsentData(){var o=this;return i(function*(){const n=o.metrics;return new Promise(i=>{let r=!1;if(o.readyPingData)i(o.parsePingData(o.readyPingData));else{const s=Date.now();let t=setTimeout(()=>{t=void 0,o.gppFn("ping",e=>{"stub"===e.cmpStatus&&(n.counter("gpp.stubUsed",{cmpId:e.cmpId}).inc(),i(o.parsePingData(e)))})},1e3);o.gppFn("addEventListener",e=>"ready"===e.pingData.signalStatus&&void(r?Le.measureAdditionalEvent(e,n,s):(t?(clearTimeout(t),t=void 0):r||n.timer("gpp.lateCmp",{cmpId:e.pingData.cmpId}).record(Date.now()-s),i(o.parsePingData(e.pingData)),r=!0)))}})})()}static measureAdditionalEvent(e,t,i){["cmpStatus","cmpDisplayStatus","signalStatus","sectionChange"].includes(e.eventName)&&t.timer("gpp.additionalEvents",{cmpId:e.pingData.cmpId,name:e.eventName}).record(Date.now()-i)}parsePingData(e){const t=new ne(te.GPP_V1_1,e.applicableSections,e.gppString);var i;return!t.applicableSections.includes(re.TCFEUV2)||(i=Pe.getTcfData(null===(i=e.parsedSections)||void 0===i?void 0:i.tcfeuv2))&&(t.euTcfSection=new se(Pe.tcfDataHasLocalStorageGrant(i),Pe.tcfDataHasID5VendorConsented(i))),!t.applicableSections.includes(re.TCFCAV1)||(e=Pe.getTcfData(null===(e=e.parsedSections)||void 0===e?void 0:e.tcfcav1))&&(t.canadaTcfSection=new se(Pe.caTcfDataHasExpressConsent(e),Pe.caTcfDataHasVendorExpressConsent(e))),t}}l(Le,"version","1.1");class Ue{constructor(e){var t=1{r._lookupInProgress=!1})),this._consentDataPromise}_lookupConsentData(e,t,i){if(e){this._log.warn("cmpApi: ID5 is operating in forced consent mode and will not retrieve any consent signals from the CMP");let e=new oe;return e.forcedGrantByConfig=!0,e.source=ie.partner,Promise.resolve(e)}switch(t){case"static":return new Promise(e=>{this._parseStaticConsentData(i,e)});case"iab":return new Promise(e=>{this._lookupIabConsent(e)});default:return this._log.error("cmpApi: Unknown consent API: ".concat(t)),Promise.reject(new Error("Unknown consent API: ".concat(t)))}}_parseStaticConsentData(e,t){e=e||{};let i=new oe;if(i.source=ie.partner,B(e.getTCData)){const r=this._parseTcfData(e.getTCData);xe(i,te.TCF_V2,r);try{const s=this._metrics;this._lookupTcf(e=>{De(s,{apiType:te.TCF_V2,sameString:(null==e?void 0:e.consentString)===(null===r||void 0===r?void 0:r.consentString),sameLSPC:(null==e?void 0:e.localStoragePurposeConsent)===(null===r||void 0===r?void 0:r.localStoragePurposeConsent),sameVendorsConsentForId5Granted:(null==e?void 0:e.vendorsConsentForId5Granted)===(null===r||void 0===r?void 0:r.vendorsConsentForId5Granted),sameGdpr:(null==e?void 0:e.gdprApplies)===(null===r||void 0===r?void 0:r.gdprApplies)}).inc()})}catch(e){}}if(H(e.allowedVendors)&&xe(i,te.ID5_ALLOWED_VENDORS,{allowedVendors:e.allowedVendors.map(e=>e.toString()),gdprApplies:!0}),B(e.getUSPData)){const n=this._parseUspData(e.getUSPData);xe(i,te.USP_V1,n);try{const o=this._metrics;this._lookupUsp(e=>{De(o,{apiType:te.USP_V1,sameString:(null==e?void 0:e.ccpaString)===(null===n||void 0===n?void 0:n.ccpaString)}).inc()})}catch(e){}}0===i.apiTypes.length&&this._log.warn("cmpApi: No static consent data detected! Using defaults."),this._log.info("cmpApi: Detected APIs '".concat(i.apiTypes,"' from static consent data"),e),t(i)}_lookupIabConsent(r){const s=[];let n=new oe;n.source=ie.cmp;var e=i=>(s[i]=0,(e,t)=>{s[i]||(s[i]=Date.now(),e&&xe(n,t,e),s.every(e=>0{t?i(this._parseUspData(e),te.USP_V1):(this._log.error("cmpApi: USP callback not successful. Using defaults for CCPA."),i())})}_lookupGpp(n){var o=this;return i(function*(){var t=Date.now();try{let e=yield Pe.create(o._log,o._metrics);if(e){var i={gppVersion:e.version,directCmp:e.direct};try{var r=yield e.getConsentData();n({gppData:r},r.version);var s=Date.now();o._metrics.timer("gpp.delay",i).record(s-t)}catch(e){o._metrics.counter("gpp.failure",u({type:"CONSENT"},i)).inc(),o._log.error("cmpApi: getting GPP consent not successful. Using defaults for Gpp."),n()}}else n()}catch(e){o._metrics.counter("gpp.failure",{type:"CLIENT"}).inc(),o._log.error("cmpApi: creating GPP client not successful. Using defaults for Gpp."),n()}})()}static _buildCmpSurrogate(a,c){return(e,t,i)=>{const r=Math.random()+"",s={},n={};n[a.objKeys[0]]=e,n[a.objKeys[1]]=t,n.callId=r,s[a.objName]=n;const o=e=>{e=Y(e,"data.".concat(a.returnObjName));e&&e.callId===r&&(void 0!==(e=i(e.returnValue,e.success))&&!0!==e||window.removeEventListener("message",o))};window.addEventListener("message",o,!1),c.postMessage(s,"*")}}_lookupTcf(e){var t=Ue._findTCF(),i=t.cmpFrame,t=t.cmpFunction;if(!i)return this._log.warn("cmpApi: TCF not found! Using defaults for GDPR."),void e();G(t)?this._lookupDirectTcf(t,e):(this._log.info("cmpApi: Detected TCF is outside the current iframe. Using message passing."),this._lookupMessageTcf(i,e))}_lookupMessageTcf(e,t){e=Ue._buildCmpSurrogate(Ae.tcfv2,e);this._lookupDirectTcf(e,t)}_lookupDirectTcf(e,s){const n=this._log;e("addEventListener",2,(e,t)=>{var i,r;return i="event",r=e,n.info("cmpApi: TCFv2 - Received a call back: ".concat(i),r),t?!(!e||!1!==e.gdprApplies&&"tcloaded"!==e.eventStatus&&"useractioncomplete"!==e.eventStatus)&&void s(this._parseTcfData(e),te.TCF_V2):(n.error("cmpApi: TCFv2 - Received insuccess: ".concat("addEventListener",". Please check your CMP setup. Using defaults for GDPR.")),void s())})}_parseUspData(e){if(B(e)&&W(e.uspString))return{ccpaString:e.uspString};this._log.error("cmpApi: No or malformed USP data. Using defaults for CCPA.")}_parseTcfData(e){let t=this._log,i,r;if(i=Ue._isValidV2ConsentObject,r=Ue._normalizeV2Data,i(e))return r(e);t.error("cmpApi: Invalid CMP data. Using defaults for GDPR.",e)}static _isValidV2ConsentObject(e){var t=e&&e.gdprApplies,e=e&&e.tcString;return!1===t||W(e)}static _tcfDataHasID5VendorConsented(e){var t,i;return!0===(null==e||null===(t=e.vendor)||void 0===t||null===(i=t.consents)||void 0===i?void 0:i[ee])}static _normalizeV2Data(e){let t=Y(e,"purpose.consents.1");z(t)||(t=function(e,t){var i=152+t-1,t=~~(i/6);if(e&&"C"===e.charAt(0)&&!(e.length<=t)){t=e.charAt(t),t=$[t];if(void 0!==t)return 0!=(t&1<<6-i%6-1)}}(e.tcString,1));var i=Ue._tcfDataHasID5VendorConsented(e);return{consentString:e.tcString,localStoragePurposeConsent:t,gdprApplies:e.gdprApplies,vendorsConsentForId5Granted:i}}static _findTCF(){let e=window,t,i;for(;!t;){try{if("function"==typeof e.__tcfapi){i=e.__tcfapi,t=e;break}}catch(e){}try{if(e.frames.__tcfapiLocator){t=e;break}}catch(e){}if(e===window.top)break;e=e.parent}return{cmpFrame:t,cmpFunction:i}}static _findCmpApi(e){let t=window,i,r;for(;!i;){try{if("function"==typeof t[e]){r=t[e],i=t;break}}catch(e){}try{if(t.frames["".concat(e,"Locator")]){i=t;break}}catch(e){}if(t===window.top)break;t=t.parent}return{cmpApiFrame:i,cmpApiFunction:r}}}const Ne=Object.freeze({CONSENT_UPDATED:"consent_updated",USER_ID_READY:"user_id_ready",CASCADE_NEEDED:"fire_sync_pixel",USER_ID_FETCH_CANCELED:"user_id_fetch_canceled",USER_ID_FETCH_FAILED:"user_id_fetch_failed"}),Fe=Object.freeze({ID5_MESSAGE_RECEIVED:"message",ID5_INSTANCE_JOINED:"instance-joined",ID5_LEADER_ELECTED:"leader-elected"}),ke=Object.freeze([...Object.values(Fe),...Object.values(Ne)]);class je{constructor(){var e=0this._trigger("immediate"),0):0this._trigger("timeout"),s))}_trigger(){let e=0{this._log.debug("Firing ".concat(this._callbackName," callback after ").concat(t,"ms. Triggered by ").concat(e,", configured timeoutMs=").concat(this._timeout)),this._beforeTrigger(),this._callbackFn.call(globalThis,...this._callbackArgs)},0))}triggerNow(){var e=0{this.options[e]=t,this.providedOptions[e]=t};var e;void 0!==a.partnerData&&(e=a.partnerData,A(a.pd)&&d.info("Both pd and partnerData provided. Using partnerData and ignoring pd."),this.options.partnerData=e,this.providedOptions.partnerData=e),Object.keys(a).forEach(e=>{if("segments"===e){const r=a[e],s=[];A(r)&&(H(r)?(r.forEach((e,t)=>{t="segments[".concat(t,"]");return H(e.ids)&&function(e,t){let i=!0;return T(e,e=>i=i&&t(e)),i}(e.ids,W)?e.ids.length<1?(d.error("Config option ".concat(t,".ids should contain at least one segment ID")),void(c.invalidSegments+=1)):W(e.destination)?void s.push(e):(qe(d,"".concat(t,".destination"),"String",e.destination),void(c.invalidSegments+=1)):(qe(d,"".concat(t,".ids"),"Array of String",e.ids),void(c.invalidSegments+=1))}),l(e,s)):qe(d,e,"Array",r))}else if("diagnostics"===e){const n=this.options.diagnostics,o=a.diagnostics;if(V(o,He.configTypes.diagnostics)){let t=h({},n);Object.keys(o).forEach(e=>{void 0!==n[e]&&typeof n[e]==typeof o[e]&&(t[e]=o[e])}),this.options[e]=t}this.providedOptions[e]=a[e]}else{var t,i;void 0!==We[e]?(i=a[e])&&We[e].includes(i)&&l(e,i):"partnerId"!==e&&"partnerData"!==e&&(t=He.configTypes[e],A(i=a[e])&&(V(i,t)?l(e,i):qe(d,e,t,i)))}})}else d.error("Config options must be an object")}setPartnerId(e){let t;if(W(e)){if(t=parseInt(e),isNaN(t)||t<0)throw new Error("partnerId is required and must parse to a positive integer")}else q(e)&&(t=e);if(q(t)){if(q(this.options.partnerId)&&t!==this.options.partnerId)throw new Error("Cannot update config with a different partnerId");this.options.partnerId=t,this.providedOptions.partnerId=e}}}function qe(e,t,i,r){e.error("Config option ".concat(t," must be of type ").concat(i," but was ").concat(toString.call(r),". Ignoring..."))}l(He,"configTypes",{debugBypassConsent:"Boolean",allowLocalStorageWithoutConsentApi:"Boolean",cmpApi:"String",consentData:"Object",refreshInSeconds:"Number",partnerUserId:"String",callbackOnAvailable:"Function",callbackOnUpdates:"Function",callbackTimeoutInMs:"Number",pd:"String",partnerData:"Object",abTesting:"Object",provider:"String",maxCascades:"Number",applyCreativeRestrictions:"Boolean",acr:"Boolean",disableUaHints:"Boolean",storageExpirationDays:"Number",att:"Number",diagnostics:"Object",multiplexing:"Object",dynamicConfig:"Object",allowGCReclaim:"String",gssProvider:"Object",gamTargetingPrefix:"String",exposeTargeting:"Boolean",idLookupMode:"Boolean"});class Be{constructor(e){const t=this,i=new Promise(e=>{t._resolve=e}),r=window.googletag=window.googletag||{};r.secureSignalProviders=r.secureSignalProviders||[],r.secureSignalProviders.push({id:e,collectorFunction:()=>i})}setUserId(e){this._resolve&&!0!==this._resolved&&(this._resolve(e),this._resolved=!0)}}class ze{constructor(e,t,i){l(this,"refererInfo",void 0),l(this,"apiVersion",void 0),l(this,"isUsingCdn",void 0),this.refererInfo=e,this.apiVersion=t,this.isUsingCdn=i}}class Je{constructor(e,t){l(this,"_targets",void 0),l(this,"_metrics",void 0),l(this,"_survivalTimer",void 0),this._targets=[e,t],this._metrics=t,this._survivalTimer=Se()}unregister(e){var t;this._survivalTimer&&this._metrics&&this._survivalTimer.record((t=this._metrics,e={unregisterTrigger:e},t.timer("instance.survival.time",e))),this._targets.forEach(e=>{try{J(e)&&G(e.unregister)&&e.unregister()}catch(e){}})}}globalThis.__id5_finalization_registry||(globalThis.__id5_finalization_registry=new class{constructor(){l(this,"_finalizationRegistry",void 0),l(this,"_instancesHolder",void 0),this._instancesHolder=new Set;try{this._finalizationRegistry=new FinalizationRegistry(e=>{try{J(e)&&G(e.unregister)&&e.unregister("gc-reclaim")}catch(e){}})}catch(e){}}register(e){try{e.getOptions().allowGCReclaim!==Ge.ASAP&&this._instancesHolder.add(e),this._finalizationRegistry.register(e,e._unregisterTargets,e)}catch(e){}}unregister(e){try{this.releaseInstance(e,!0),this._finalizationRegistry.unregister(e)}catch(e){}}releaseInstance(e){var t=1{},this),this}onUpdate(e){if(!G(e))throw new Error("onUpdate expects a function");return this._updateCallback=e,this._userIdAvailable&&this._fireOnUpdate(),this}unregister(){try{this._unregisterTargets.unregister("api-call"),Xe.unregister(this)}catch(e){}}constructor(e,t,i,r,s,n){var o=6{this._userIdAvailablePromiseResolver=e}),this._pageLevelInfo=s,this._unregisterTargets=new Je(this._multiplexingInstance,this._metrics),this._origin=n,Xe.register(this),this._registrationProperties=o}bootstrap(){var e;const n=Se(),o=this.config.getOptions(),a=this._ref();this._multiplexingInstance.on(Ne.USER_ID_READY,(e,t)=>{const i=a.deref();if(i){try{var r=null!=t&&t.tags?h({},t.tags):{},s=i._metrics;null!=t&&t.timestamp&&s.timer("userid.provisioning.delivery.delay",r).record(Date.now()-t.timestamp),n.record(function(e,t,i){return e.timer("userid.provisioning.delay",h({cachedResponseUsed:t},2{for(const e in s)window.googletag.setConfig({targeting:{[t+"_"+e]:s[e]}})})),s&&i&&!Q(null===(i=window)||void 0===i||null===(r=i.id5tags)||void 0===r?void 0:r.tags,s)&&(window.id5tags=window.id5tags||{cmd:[]},window.id5tags.cmd=window.id5tags.cmd||[],window.id5tags.cmd.forEach(e=>{setTimeout(()=>e(s),0)}),window.id5tags.cmd.push=function(e){e(s),Array.prototype.push.call(window.id5tags.cmd,e)},window.id5tags.tags=s)}}.updateTargeting(e,o.gamTargetingPrefix,o.exposeTargeting)}}).on(Ne.USER_ID_FETCH_CANCELED,e=>{const t=a.deref();t&&t._log.info("ID5 User ID fetch canceled:",e.reason)}),this._log.info("bootstrapped for partner ".concat(o.partnerId," with referer ").concat(null===(e=this._pageLevelInfo)||void 0===e?void 0:e.refererInfo," and options"),this.getProvidedOptions())}init(){const i=this.config.getOptions();var e=i.gssProvider;return e&&!0===e.enabled&&(this._gssProvider=new Be((null===(e=i.gssProvider)||void 0===e?void 0:e.id)||"id5-sync.com")),this._gatherFetchIdData().then(e=>{var t;this._multiplexingInstance.register(h({source:this._origin,sourceVersion:Ve,sourceConfiguration:{options:i},fetchIdData:e,singletonMode:!0===(null===i||void 0===i||null===(t=i.multiplexing)||void 0===t?void 0:t._disabled)||!0===(null===i||void 0===i?void 0:i.idLookupMode),forceAllowLocalStorageGrant:this.config.isForceAllowLocalStorageGrant(),storageExpirationDays:i.storageExpirationDays},this._registrationProperties))})}_gatherFetchIdData(){var t=this;return i(function*(){var e=t.config.getOptions();return Promise.resolve({partnerId:e.partnerId,refererInfo:t._pageLevelInfo.refererInfo,origin:t._origin,originVersion:t._pageLevelInfo.apiVersion,isUsingCdn:t._pageLevelInfo.isUsingCdn,abTesting:e.abTesting,provider:e.provider,refreshInSeconds:e.refreshInSeconds,providedRefreshInSeconds:t.getProvidedOptions().refreshInSeconds,trace:L,consentSource:ie.none,segments:e.segments,invalidSegmentsCount:t.getInvalidSegments(),idLookupMode:e.idLookupMode})})()}_ref(){return new("undefined"!=typeof WeakRef?WeakRef:Ye)(this)}_setUserId(e,t){var i=2= 0 and <= 1");break;case"control":this._isExposed=!1,this._log.info("User is in control group!")}var s=this._userId!==r||!1===Q(this._ext,e.ext)||!1===Q(this._ids,e.ids);this._userIdAvailable=!0,this._userId=r,this._gpId=e.gp,this._ids=e.ids,this._userIdAvailablePromiseResolver(r),this._ext=e.ext,this._publisherTrueLinkId=e.publisherTrueLinkId,this._fromCache=t,this._signature=e.signature,this._log.info("User id updated",{hasChanged:s,fromCache:t}),this._availableCallback&&this._availableCallback.triggerNow(),this._isRefreshing&&this._refreshCallback&&(!1===t||!1===this._isRefreshingWithFetch)&&this._refreshCallback.triggerNow(),s&&this._fireOnUpdate(),this.getOptions().allowGCReclaim!==Ge.AFTER_UID_SET||t&&i||Xe.releaseInstance(this),this._gssProvider&&this._gssProvider.setUserId(this.getUserId())}_fireOnUpdate(){setTimeout(()=>{G(this._updateCallback)&&(this._log.debug("Firing onUpdate"),this._updateCallback(this))},0)}}const Qe=JSON.stringify,$e=Object.prototype.hasOwnProperty,Ze=Object.freeze({OTHER:"other",HEM:"hem",PHONE:"phone",XPUID:"xpuid",XPUID_SOURCE:"xpuidSource",PUID:"puid",IDFA:"idfa",GAID:"gaid",URL:"url",DOMAIN:"domain",IPV4:"ipv4",IPV6:"ipv6",UA:"ua",IS_BURNER_EMAIL:"isBurnerEmail",IDFV:"idfv",CTV_ID:"ctvId",CTV_ID_TYPE:"ctvIdType",IAB_TOKEN:"iabToken"}),et=Object.freeze({[Ze.OTHER]:0,[Ze.HEM]:1,[Ze.PHONE]:2,[Ze.XPUID]:3,[Ze.XPUID_SOURCE]:4,[Ze.PUID]:5,[Ze.IDFA]:6,[Ze.GAID]:7,[Ze.URL]:8,[Ze.DOMAIN]:9,[Ze.IPV4]:10,[Ze.IPV6]:11,[Ze.UA]:12,[Ze.IS_BURNER_EMAIL]:13,[Ze.IDFV]:14,[Ze.CTV_ID]:15,[Ze.CTV_ID_TYPE]:16,[Ze.IAB_TOKEN]:17});function tt(){return(tt=i(function*(t,i){if(A(t))if(B(t)){const l=[];let e=0;var r,s=f(Object.keys(t).sort());try{for(s.s();!(r=s.n()).done;){var n,o,a=r.value,c=t[a];$e.call(et,a)?W(c)?(n=yield function(){return it.apply(this,arguments)}(a,c,i))?(o=et[a],l.push("".concat(o,"=").concat(encodeURIComponent(n)))):e+=1:(i.warn('partnerData value for key "'.concat(a,'" must be a string but was ').concat(Qe.call(c),". Skipping.")),e+=1):(i.warn('partnerData key "'.concat(a,'" is not a recognized key. Skipping.')),e+=1)}}catch(e){s.e(e)}finally{s.f()}if(0e.toString(16).padStart(2,"0")).join("")}})).apply(this,arguments)}function at(e){return W(e)&&/^[a-f0-9]{64}$/i.test(e)}class ct{static gatherUaHints(e,t){return i(function*(){if(A(window.navigator.userAgentData)&&!e){let e;try{e=yield window.navigator.userAgentData.getHighEntropyValues(["architecture","fullVersionList","model","platformVersion"])}catch(e){return void t.error("Error while calling navigator.userAgentData.getHighEntropyValues()",e)}return ct.filterUaHints(e)}})()}static filterUaHints(e){if(A(e)){const t=/[()-.:;=?_/]/g;return C(e.brands)&&(e.brands=e.brands.filter(e=>b(e.brand)&&e.brand.search(t)<0)),C(e.fullVersionList)&&(e.fullVersionList=e.fullVersionList.filter(e=>b(e.brand)&&e.brand.search(t)<0)),e}}}function dt(e,t,i){return e.timer("fetch.call.time",h({status:t},2{let r=i.data;if(void 0!==i.data&&i.data._isId5Message&&i.data.src!==s._id&&(void 0===i.data.dst||i.data.dst===s._id))try{[gt,r.type].forEach(e=>{let t=s._handlers[e];t&&t.forEach(e=>e(r,i.source))})}catch(e){s._log.error("Error while handling message",r,e)}},{capture:!1,signal:e})}unregister(){this._abortController&&this._abortController.abort()}onAnyMessage(e){return this.onMessage(gt,e)}onMessage(e,t){const i=this._handlers[e];return i?i.push(t):this._handlers[e]=[t],this}broadcastMessage(e,t){this._log.debug("Broadcasting message",t,e),this._postMessage(this._messageFactory.createBroadcastMessage(e,t))}sendResponseMessage(e,t){var i=2void 0===e.dst?(this._countInvalidMessage(e,"no-destination-proxy"),void this._log.error("Received invalid RemoteMethodCallMessage message",JSON.stringify(e),"Ignoring it....")):void t._handle(u(new mt,e.payload)))}_countInvalidMessage(e,t){var i=e=>null!=e;void 0!==this._metrics&&!function(e,t){return e.counter("instance.message.invalid.count",1{var t=e.cacheId;s.has(t)||(e=i.getResponseFor(e.integrationId))&&(this._clientStore.storeResponseV2(t,e,i.timestamp,r),s.add(t))}),this._trueLinkAdapter.setPrivacy(null===(e=i.getGenericResponse())||void 0===e?void 0:e.privacy)}clearAll(e){this._clientStore.clearResponseV1(),this._clientStore.clearDateTime(),e.forEach(e=>{e=e.cacheId;this._clientStore.clearResponseV2(e)}),this._clientStore.clearHashedConsentData(),this._trueLinkAdapter.clearPrivacy(),this._clientStore.clearExtensions(),this._clientStore.clearSignature()}getCachedResponse(e){e=this._clientStore.getStoredResponseV2(e);if(e)return new Dt(e.response,e.responseTimestamp,e.nb,e.consents)}getCachedSignature(){var e;return null===(e=this._clientStore.getStoredSignature())||void 0===e?void 0:e.signature}getCachedExtensions(){return this._clientStore.getExtensions()}storeExtensions(e){var t=D(e.ttl)?e.ttl/86400:bt.DEFAULT.EXTENSIONS.expiresDays,t=new St(bt.DEFAULT.EXTENSIONS.name,t);return this._clientStore.storeExtensions(e,t)}}class Dt{constructor(e,t){var i=2e}isStale(){return!this.timestamp||this._isOlderThanSec(1209600)}isResponseComplete(){return E(this.response)&&b(this.response.universal_uid)&&b(this.response.signature)}isValid(){return this.isResponseComplete()&&!this.isStale()}getMaxAge(){var e,t;return null===(e=this.response)||void 0===e||null===(t=e.cache_control)||void 0===t?void 0:t.max_age_sec}getAgeSec(){return(Date.now()-this.timestamp)/1e3|0}}const Et="_exp";class At{constructor(e){var t=1{e.removeItem(t)};this._replicas.forEach(e),this._lastKeyOperation[t]=e}setItem(t,i){this._primaryStorage.setItem(t,i);var e=e=>{e.setItem(t,i)};this._replicas.forEach(e),this._lastKeyOperation[t]=e}addReplica(t){Object.values(this._lastKeyOperation).forEach(e=>e(t)),this._replicas.push(t)}getKeysWithPrefix(e){return this._primaryStorage.getKeysWithPrefix(e)}}class Lt{constructor(e){var t=1{const s=e.map(e=>{const t=e.cacheData;var i=null===t||void 0===t||null===(s=t.response)||void 0===s?void 0:s.signature,r=null===t||void 0===t?void 0:t.nb,s=null===t||void 0===t?void 0:t.getMaxAge();return this._createRequest(d,e,i,r,s,n,l)}),o=this._log,a=this._metrics,c=this;return new Promise((t,i)=>{const r=Se();var e="".concat("https://id5-sync.com").concat("/gm/v3");o.info("Fetching ID5 ID from:",e,s),function(r,s,n,o,e){o=3{i.setRequestHeader(t,e)}),o.preflight&&i.setRequestHeader("X-Requested-With","XMLHttpRequest"),i.setRequestHeader("Content-Type",o.contentType||"text/plain"),"POST"===d&&n?i.send(n):i.send()}catch(e){a.error("ajax","xhr construction",e)}}(e,{success:function(e){o.info("Success at fetch call:",e),r.record(function(e,t){return dt(e,"success",1{var t=g(e,2),e=t[0],t=t[1];A(i[e])&&(l[t]=i[e])});e=i.abTesting;e&&!0===e.enabled&&(l.ab_testing={enabled:!0,control_group_pct:e.controlGroupPct});e=i.invalidSegmentsCount;return e&&0void 0!==e.find(e=>t.getId()===e)&&t.canDoCascade()).sort((e,t)=>{function i(e){var t;return(null===(e=e.getFetchIdData().refererInfo)||void 0===e||null===(t=e.stack)||void 0===t?void 0:t.length)||Number.MAX_SAFE_INTEGER}return i(e)-i(t)});if(0{const e=this._consentManager.localStorageGrant("fetch-before-request");if(d.info("Local storage grant",e),e.allowed){var i=this._store.hasConsentChanged(t);e.isDefinitivelyAllowed()&&this._store.storeConsent(t);var r=Rt.checkIfAccessible(),s=this._store.getCachedSignature();const c=new Map;let a=o;const n=this._followers.map(e=>{var t=e.getId(),i=(this._followersRequests[t]||0)+1,r=this._properties.id,s=!0===this._refreshRequired[e.getId()];a=a||s;var n,o=e.getCacheId();return c.has(o)||(n=this._store.getCachedResponse(o))&&c.set(o,n),h(h({},e.getFetchIdData()),{},{integrationId:t,requestCount:i,refresh:s,role:r===e.getId()?"leader":e.type||"follower",cacheId:o,cacheData:c.get(o),sourceVersion:e.getSourceVersion(),source:e.getSource()})});i||a?(d.info("Decided to fetch a fresh ID5 ID",{consentHasChanged:i,shouldRefresh:a}),d.info("Fetching ID5 ID (forceFetch:".concat(o,")")),this._inProgressFetch=!0,this._firstFetchTriggered=!0,this._fetcher.fetchId(n,t,r,s).then(e=>{this._handleRefreshResult(n,c,t,e),this._handleFetchCompleted()}).catch(e=>{this._handleFailed(e),this._handleFetchCompleted()})):(d.info("Not decided to refresh ID5 ID",{consentHasChanged:i,shouldRefresh:a}),this._handleFetchCompleted())}else d.info("No legal basis to use ID5",t),this._store.clearAll(this._followers.map(e=>({cacheId:e.getCacheId()}))),this._handleCancel("No legal basis to use ID5")})}_waitForConsent(){const t=this._log,e=this._consentManager,i=this._metrics;t.info("Waiting for consent");const r=i.timer("fetch.consent.wait.time");return e.getConsentData().then(e=>(t.info("Consent received",e),r&&r.recordNow(),e))}start(){!0!==this._started&&(this._getId(!1),this._started=!0)}refreshUid(){var e=0e.getId()===t))&&this._provisionFromCache(i)),function(e,t,i){return e.counter("refresh.call.count",h({target:t},2e.getDeclaredConsentSource()).filter(e=>e!==ie.none));var i=e.source||ie.cmp,r=1===s.size&&s.has(ie.partner);this._awaitedConsentFrom?this._awaitedConsentFrom===t?(this._consentManager.setConsentData(e),this._awaitedConsentFrom=void 0):this._handleIgnoredConsent(e,"awaited"):i!==ie.partner||r?this._consentManager.setConsentData(e):this._handleIgnoredConsent(e,"partner")}}_handleIgnoredConsentUpdate(e){try{const r=this._consentManager._consentDataHolder.getValue();if(r){const s={},n=oe.createFrom(e);Object.values(te).forEach(e=>{var t,i;n.apiTypes.includes(e)&&r.apiTypes.includes(e)?(t=JSON.stringify(r.getApiTypeData(e)),i=JSON.stringify(n.getApiTypeData(e)),s[e]=t===i?"same":"different"):n.apiTypes.includes(e)?s[e]="added":r.apiTypes.includes(e)&&(s[e]="missed")}),function(e,t){return e.counter("leader.consent.change.count",1i[e]=!0),function(e,t){return e.counter("leader.consent.ignore.count",1e.getId()===t);var r=i.getCacheId();i.updateFetchIdData(e);e=i.getCacheId();e!==r&&(this._log.info("Follower",i.getId(),"cacheId changed from",r," to",e,"required refresh"),this._refreshRequired[i.getId()]=!0)}addFollower(t){const e=this._log;var i=void 0===this._followers.find(e=>e.getCacheId()===t.getCacheId());this._followers.push(t),e.debug("Added follower",t.getId(),"cacheId",t.getCacheId()),this._window!==t.getWindow()&&(r=t.getStorage(),e.debug("Adding follower's",t.getId(),"storage as replica"),this._leaderStorage.addReplica(r));var r=this._provisionFromCache(t);let s=new Vt;return!0===this._firstFetchTriggered&&(s.lateJoiner=!0,s.uniqueLateJoiner=i,r&&this._callRefresh({forceFetch:!0})),s}_provisionFromCache(e){var t=this._cachedIdProvider.provisionFromCache(e);return this._refreshRequired[e.getId()]=t.refreshRequired,t.provisioned&&this._store.incNb(t.cacheId),t.refreshRequired}getProperties(){return this._properties}_handleFetchCompleted(){this._inProgressFetch=void 0,this._queuedRefreshArgs&&(this._callRefresh(...this._queuedRefreshArgs),this._queuedRefreshArgs=void 0)}_handleFailed(e){this._log.error("Fetch id failed",e);var t,i=f(this._followers);try{for(i.s();!(t=i.n()).done;){const r=t.value;r.notifyFetchUidCanceled({reason:"error"})}}catch(e){i.e(e)}finally{i.f()}}}class Ht extends Gt{constructor(e,t){super(),l(this,"_messenger",void 0),l(this,"_leaderInstanceProperties",void 0),this._messenger=e,this._leaderInstanceProperties=t}_sendToLeader(e,t){this._messenger.callProxyMethod(this._leaderInstanceProperties.id,ft.LEADER,e,t)}updateConsent(e,t){this._sendToLeader("updateConsent",[e,t])}refreshUid(e,t){this._sendToLeader("refreshUid",[e,t])}updateFetchIdData(e,t){this._sendToLeader("updateFetchIdData",[e,t])}getProperties(){return this._leaderInstanceProperties}}class qt extends Gt{constructor(){super(...arguments),l(this,"_callsQueue",[]),l(this,"_assignedLeader",void 0)}updateConsent(e,t){this._callOrBuffer("updateConsent",[e,t])}updateFetchIdData(e,t){this._callOrBuffer("updateFetchIdData",[e,t])}refreshUid(e,t){this._callOrBuffer("refreshUid",[e,t])}addFollower(e){return this._callOrBuffer("addFollower",[e])}getProperties(){if(this._assignedLeader)return this._assignedLeader.getProperties()}assignLeader(e){this._assignedLeader=e;var t,i=f(this._callsQueue);try{for(i.s();!(t=i.n()).done;){var r=t.value;this._callAssignedLeader(r.name,r.args)}}catch(e){i.e(e)}finally{i.f()}this._callsQueue=[]}_callOrBuffer(e,t){if(this._assignedLeader)return this._callAssignedLeader(e,t);this._callsQueue.push({name:e,args:t})}_callAssignedLeader(e,t){return this._assignedLeader[e](...t)}}class Bt extends Pt{constructor(e,t){super(),l(this,"_messenger",void 0),l(this,"_destinationId",void 0),this._messanger=e,this._destinationId=t}getItem(){}removeItem(e){this._remoteCall("removeItem",[e])}setItem(e,t){this._remoteCall("setItem",[e,t])}_remoteCall(e,t){this._messanger.callProxyMethod(this._destinationId,ft.STORAGE,e,t)}}class zt extends kt{constructor(e,t){var i=2{this._resolve=e})}set(e){this._hasValue?this._valuePromise=Promise.resolve(e):(this._hasValue=!0,this._resolve(e)),this._value=e}getValuePromise(){return this._valuePromise}hasValue(){return this._hasValue}getValue(){return this._value}}class Xt extends class{getConsentData(){}localStorageGrant(){}setStoredPrivacy(){}}{constructor(e,t,i,r,s){super(),l(this,"_consentDataHolder",void 0),l(this,"storedPrivacyData",void 0),l(this,"localStorage",void 0),l(this,"_forceAllowLocalStorageGrant",void 0),this._log=r,this.localStorage=e,this.storageConfig=t,this._consentDataHolder=new Jt,this._forceAllowLocalStorageGrant=i,this._metrics=s}isForceAllowLocalStorageGrant(){return this._forceAllowLocalStorageGrant}resetConsentData(e){this._consentDataHolder.reset(),this.storedPrivacyData=void 0,this._forceAllowLocalStorageGrant=e}localStorageGrant(){var e=0h(h({},e),{},{response:t,responseTimestamp:i,consents:r}))}getStoredResponseV2(e){return this._getObject(this.storageConfig.ID5_V2.withNameSuffixed(e))}storeSignature(e){return this._updateObject(this.storageConfig.ID5_SIGNATURE,()=>({signature:e}))}getStoredSignature(){return this._getObject(this.storageConfig.ID5_SIGNATURE)}clearSignature(){return this._clearObject(this.storageConfig.ID5_SIGNATURE)}incNbV2(e){let i=1{var t=Math.max(0,D(null==e?void 0:e.nb)?Math.round(e.nb)+i:i);return h(h({},e),{},{nb:t})})}static storedDataMatchesCurrentData(e,t){return null==e||e===t}storedConsentDataMatchesConsentData(e){return Yt.storedDataMatchesCurrentData(this.getHashedConsentData(),e.hashCode())}getExtensions(){return this._getObject(this.storageConfig.EXTENSIONS)}storeExtensions(e,t){return this._updateObject(t,()=>e)}clearExtensions(){return this.clear(this.storageConfig.EXTENSIONS)}}var Kt,Qt=new WeakSet,$t=new WeakSet,Zt=new WeakSet,ei=new WeakSet,ti=new WeakSet,ii=new WeakSet;class ri{constructor(e,t,i){ii.add(this),ti.add(this),ei.add(this),Zt.add(this),$t.add(this),Qt.add(this),l(this,"_metrics",void 0),l(this,"_log",void 0),l(this,"_store",void 0),this._metrics=e,this._log=t,this._store=i}static getChunkUrl(e,t){return"https://d".concat(e,".eu-").concat(t,"-id5-sync.com")}gather(i){var e=this._store.getCachedExtensions();if(void 0!==e)return Promise.resolve(e);let r=Se(),s=o(this,ei,ai).call(this,i),n=o(this,Zt,oi).call(this);return o(this,Qt,si).call(this,"https://lb.eu-1-id5-sync.com/lb/v1","lb").then(e=>{var t=o(this,ti,ci).call(this,e,o(this,ii,di).call(this,i));return Promise.allSettled([Promise.resolve(e),o(this,$t,ni).call(this,t,ri.CHUNKS_CONFIGS.devChunks),o(this,$t,ni).call(this,t,ri.CHUNKS_CONFIGS.groupChunks),s,n])}).then(e=>{r.record(lt(this._metrics,"all",!0));let t=ri.DEFAULT_RESPONSE;return e.forEach(e=>{e.value&&(t=h(h({},t),e.value))}),this._store.storeExtensions(t),t}).catch(e=>(r.record(lt(this._metrics,"all",!1)),this._log.error("Got error ".concat(e," when gathering extensions data")),ri.DEFAULT_RESPONSE))}}function si(t,i){var e=2{if(e.ok)return r.record(lt(this._metrics,i,!0)),e.json();r.record(lt(this._metrics,i,!1));e="The call to get extensions at ".concat(t," was not ok, status: ").concat(e.status,", statusText: ").concat(e.statusText);return this._log.warn(e),Promise.reject(new Error(e))}).catch(e=>(r.record(lt(this._metrics,i,!1)),this._log.warn("Got error from ".concat(t," endpoint"),e),{}))}function ni(e,i){if(e){let t=Se();return Promise.all(Array.from({length:i.length},(e,t)=>{t=ri.getChunkUrl(t,i.urlVersion);return fetch(t).then(e=>{if(e.ok)return e.text();throw new Error("The call to get ".concat(i.name," was not ok, status: ").concat(e.status,", statusText: ").concat(e.statusText))})})).then(e=>(t.record(lt(this._metrics,i.name,!0)),{[i.name]:e,[i.name+"Version"]:"".concat(i.version)})).catch(e=>(t.record(lt(this._metrics,i.name,!1)),this._log.warn("Got error when getting ".concat(i.name),e),{}))}return Promise.resolve({})}function oi(){const e=new AbortController,t=setTimeout(()=>e.abort(),3e3);let i=o(this,Qt,si).call(this,"https://lbs.eu-1-id5-sync.com/lbs/v1","lbs",{signal:e.signal});return i.finally(()=>{clearTimeout(t)})}function ai(e){return e.some(e=>{return A(null===(e=e.cacheData)||void 0===e?void 0:e.signature)})||o(this,ii,di).call(this,e)?Promise.resolve({}):o(this,Qt,si).call(this,"https://id5-sync.com/bounce","bounce",{credentials:"include"})}function ci(e,t){e=null==e?void 0:e.chunks;return 0!==e&&!t&&e}function di(e){return e.some(e=>!0===e.idLookupMode)}l(ri,"CHUNKS_CONFIGS",Object.freeze({devChunks:{name:"devChunks",urlVersion:3,length:8,version:4},groupChunks:{name:"groupChunks",urlVersion:4,length:8,version:4}})),l(ri,"DEFAULT_RESPONSE",{lbCDN:"%%LB_CDN%%"});const li={createExtensions:function(e,t,i){return new ri(e,t,i)}},hi=Object.freeze({UNKNOWN:"unknown",LEADER:"leader",FOLLOWER:"follower"}),ui=Object.freeze({MULTIPLEXING:"multiplexing",SINGLETON:"singleton",MULTIPLEXING_PASSIVE:"multiplexing-passive"}),gi=Object.freeze({AWAITING_SCHEDULE:"awaiting_schedule",SKIPPED:"skipped",SCHEDULED:"scheduled",COMPLETED:"completed",CANCELED:"canceled"});class pi{constructor(e,t,i){l(this,"properties",void 0),l(this,"knownState",void 0),l(this,"_joinTime",void 0),l(this,"_window",void 0),this.properties=e,this.knownState=t,this._window=i,this._joinTime=performance.now()}getId(){return this.properties.id}isMultiplexingPartyAllowed(){var e=null===(e=this.knownState)||void 0===e?void 0:e.operatingMode;return e===ui.MULTIPLEXING||e===ui.MULTIPLEXING_PASSIVE}isLeaderCapable(){var e;return(null===(e=this.knownState)||void 0===e?void 0:e.operatingMode)===ui.MULTIPLEXING}isPassive(){var e;return(null===(e=this.knownState)||void 0===e?void 0:e.operatingMode)===ui.MULTIPLEXING_PASSIVE}getInstanceMultiplexingLeader(){var e,t;if((null===(e=this.knownState)||void 0===e?void 0:e.operatingMode)===ui.MULTIPLEXING)return null===(e=this.knownState)||void 0===e||null===(t=e.multiplexing)||void 0===t?void 0:t.leader}getWindow(){return this._window}}class vi{constructor(e,t,i,r){l(this,"properties",void 0),l(this,"_messenger",void 0),l(this,"_knownInstances",new Map),l(this,"role",void 0),l(this,"_mode",void 0),l(this,"_metrics",void 0),l(this,"_logger",void 0),l(this,"_window",void 0);var s=A(globalThis)&&A(globalThis.crypto)&&S(globalThis.crypto.randomUUID)?globalThis.crypto.randomUUID():"".concat(1e6*Math.random()|0);this.properties=u({id:s,version:"1.0.44",href:null===(s=e.location)||void 0===s?void 0:s.href,domain:null===(s=e.location)||void 0===s?void 0:s.hostname},t),this.role=hi.UNKNOWN,this._metrics=i,this._loadTime=performance.now(),this._logger=new _i(r,this),this._window=e,this._dispatcher=new je(this._logger),this._followerRole=new jt(this._window,this.properties,this._dispatcher,this._logger,this._metrics)}updateConfig(e){u(this.properties,e)}register(e){try{this.updateConfig(e),this.init(),this._messenger.broadcastMessage(this._createHelloMessage(!1),_t.TYPE)}catch(e){this._logger.error("Failed to register integration instance",e)}return this}init(){let r=this,s=r._window;r._mode=ui.MULTIPLEXING_PASSIVE,r._messenger=new wt(r.properties.id,s,r._logger,r._metrics),r._messenger.onAnyMessage((e,t)=>{var i=Date.now()-e.timestamp|0;!function(e,t){return e.timer("instance.message.delivery.time",1{let i=u(new _t,e.payload);void 0===i.isResponse&&(i.isResponse=void 0!==e.dst),r._handleHelloMessage(i,e,t)})}_handleHelloMessage(e,t,i){var r=e.isResponse;const s=new pi(e.instance,e.instanceState,i);this._knownInstances.get(s.getId())?this._logger.debug("Instance already known",s.getId()):(this._knownInstances.set(s.getId(),s),r||this._messenger.sendResponseMessage(t,this._createHelloMessage(!0),_t.TYPE),this._logger.debug("Instance joined",s.getId()),this._doFireEvent(Fe.ID5_INSTANCE_JOINED,s.properties),this._onInstanceDiscovered(e,s))}unregister(){this._logger.info("Unregistering"),this._messenger&&this._messenger.unregister()}on(e,t){return this._dispatcher.on(e,t),this}_onInstanceDiscovered(){}_createHelloMessage(){var e=0e.properties)};return new _t(this.properties,e,t)}_doFireEvent(e){for(var t=arguments.length,i=new Array(1{t._timeoutId&&(t._timeoutId=void 0,t._instance._doElection(),t._closeWithState(gi.COMPLETED))},t._delayMs),t._state=gi.SCHEDULED,t._scheduleTime=performance.now()}skip(){this._closeWithState(gi.SKIPPED)}cancel(){this._timeoutId&&(clearTimeout(this._timeoutId),this._timeoutId=void 0),this._closeWithState(gi.CANCELED)}_closeWithState(e){this._state=e,this._closeTime=performance.now()}}class wi extends vi{constructor(e,t,i,r,s,n,o){super(e,t,r,s),l(this,"_lastJoinedInstance",void 0),l(this,"_leader",void 0),l(this,"_remoteCallsToLeaderHandler",void 0),l(this,"_instanceCounters",void 0),l(this,"_election",void 0),l(this,"_storage",void 0),l(this,"_trueLinkAdapter",void 0),l(this,"_cachedIdProvider",void 0),this._leader=new qt,this._remoteCallsToLeaderHandler=new qt,this._instanceCounters=new mi(r,this.properties),this._storage=i,this._trueLinkAdapter=n,this._cachedIdProvider=new Mt("self",new Ct(o,n),this._logger,this._metrics),this._election=new Ii(this)}init(){super.init();var e,t=this;t._mode=!0===t.properties.singletonMode?ui.SINGLETON:ui.MULTIPLEXING,t._instanceCounters.addInstance(t.properties),function(i){const r=i._metrics;[100,200,500,1e3,2e3,3e3,5e3].forEach(t=>{setTimeout(()=>{var e=((null===(e=i._knownInstances)||void 0===e?void 0:e.size)||0)+1;r.summary("instance.partySize",{after:t,electionState:i._election._state}).record(e)},t)})}(t),t._messenger.onProxyMethodCall(new It(t._logger).registerTarget(ft.LEADER,t._remoteCallsToLeaderHandler).registerTarget(ft.FOLLOWER,t._followerRole).registerTarget(ft.STORAGE,t._storage)),t._mode===ui.SINGLETON?(t._election.skip(),t._onLeaderElected(t.properties)):t._mode===ui.MULTIPLEXING&&(e=t.properties.electionDelayMSec||500,t._election.schedule(e))}_onInstanceDiscovered(e,t){e=e.isResponse;this._lastJoinedInstance=t,this._instanceCounters.addInstance(t.properties),function(e,t){return e.timer("instance.join.delay.time",1o.localStorageGrant("client-store"),s,n,t),this._trueLinkAdapter),n=new Ut(i,t,li.createExtensions(i,t,s));const a=new Wt(this._window,e,r,s,o,i,t,n);a.addFollower(this._followerRole),this._leader.assignLeader(a),this._remoteCallsToLeaderHandler.assignLeader(a),this._mode===ui.MULTIPLEXING&&Array.from(this._knownInstances.values()).filter(e=>e.isMultiplexingPartyAllowed()).map(e=>a.addFollower(new zt(e,this._messenger,t,e.isPassive()?Ft.PASSIVE:Ft.STANDARD))),a.start()}_followRemoteLeader(e){this._leader.assignLeader(new Ht(this._messenger,e)),this._remoteCallsToLeaderHandler.assignLeader(new yi(e.id,this._logger,this._metrics)),this._logger.info("Following remote leader ",e)}updateConsent(e){this._leader.updateConsent(e,this.properties.id)}updateFetchIdData(e){this._leader.updateFetchIdData(this.properties.id,e),u(this.properties.fetchIdData,e)}refreshUid(e){this._leader.refreshUid(e,this.properties.id)}_doElection(){var e=this._election;const t=this._knownInstances;let i=Array.from(t.values()).filter(e=>e.isMultiplexingPartyAllowed()&&e.isLeaderCapable()).map(e=>e.properties);i.push(this.properties),this._onLeaderElected(function(e){if(!e||0===e.length)return;e=e.sort((e,t)=>{let i=-(0|v(e.version,t.version));var r,s,n;return 0===i&&(i=e.source.localeCompare(t.source),0===i&&(i=-(0|v(e.sourceVersion,t.sourceVersion))),0===i&&(s=(null===(s=e.fetchIdData)||void 0===s||null===(r=s.refererInfo)||void 0===r?void 0:r.numIframes)||Number.MAX_SAFE_INTEGER,n=(null===(r=t.fetchIdData)||void 0===r||null===(n=r.refererInfo)||void 0===n?void 0:n.numIframes)||Number.MAX_SAFE_INTEGER,i=s-n),0===i&&(i=e.id.localeCompare(t.id))),i});return e[0]}(i));var r=this._lastJoinedInstance;r&&!function(e,t){return e.timer("instance.lastJoin.delay",h({},1e.eid)}onRefresh(e,t){if(!G(e))throw new Error("onRefresh expects a function");this._refreshCallback&&this._refreshCallback.disableWatchdog();var i=!0===this._isRefreshing&&!1===this._isRefreshingWithFetch&&this._userIdAvailable;return this._refreshCallback=new Me("onRefresh",this._log,this._metrics,e,t,i,()=>{this._isRefreshing=!1,this._isRefreshingWithFetch=!1},this),this}collectEvent(t,i){const r=e=>{e=new Request("https://id5-sync.com/event",{method:"POST",mode:"no-cors",body:JSON.stringify({partnerId:this.config.getOptions().partnerId,id5id:e,eventType:t,metadata:i})});return this._log.info("Sending event",e),fetch(e).catch(e=>this._log.error("Error while sending event to ID5 of type "+t,e))};return this._userIdAvailable?r(this._userId):this._userIdAvailablePromise.then(e=>r(e))}constructor(e,t,i,r,s,n,o,a,c){super(e,r,n,o,a,"api",{canDoCascade:!e.hasCreativeRestrictions()&&!0!==e.getOptions().idLookupMode}),l(this,"clientStore",void 0),l(this,"consentManagement",void 0),l(this,"_consentDataProvider",void 0),l(this,"_trueLinkAdapter",void 0),this.clientStore=t,this.consentManagement=i,this._consentDataProvider=s,this._trueLinkAdapter=c}bootstrap(){super.bootstrap();const i=this._ref();this._multiplexingInstance.on(Ne.CASCADE_NEEDED,e=>{const t=i.deref();t&&t._doCascade(e)})}init(){const e=super.init(),t=this._submitRefreshConsent().then(e=>{e&&this.consentManagement.setConsentData(e)});return e.then(()=>{this._multiplexingInstance.lookupForCachedId().provisioned||(this._log.info("Couldn't find cached userId. Will try again when consent is resolved"),t.then(()=>{this._log.info("Consent resolved. Looking for cached id again"),this._multiplexingInstance.lookupForCachedId()}))}),Promise.allSettled([e,t])}refreshId(t,e){let i,r;this._log.info("ID refresh requested (force=".concat(t,") with additional options "),e);try{this._isRefreshing=!0,this._isRefreshingWithFetch=t,this.config.updOptions(e);var s=this.config.getOptions();const n=s.allowLocalStorageWithoutConsentApi||s.debugBypassConsent;i=this._gatherFetchIdData().then(e=>{this._multiplexingInstance.updateFetchIdData(e),this._multiplexingInstance.refreshUid({resetConsent:!0,forceAllowLocalStorageGrant:n,forceFetch:t}),r=this._submitRefreshConsent()}),function(e,t,i){return e.counter("refresh.call.count",h({target:t},2super._gatherFetchIdData,o=this;return i(function*(){var e,t=o.config.getOptions(),i=yield ct.gatherUaHints(t.disableUaHints,o._log),r=yield n().call(o);let s=t.pd;return!t.partnerData||void 0!==(e=yield function(){return tt.apply(this,arguments)}(t.partnerData,o._log))&&(s=e),h(h({},r),{},{uaHints:i,pd:s,partnerUserId:t.partnerUserId,allowedVendors:null===(i=t.consentData)||void 0===i?void 0:i.allowedVendors,consentSource:"iab"===t.cmpApi&&!0!==t.debugBypassConsent?ie.cmp:ie.partner,trueLink:o._trueLinkAdapter.getTrueLink(),att:t.att})})()}_submitRefreshConsent(){var n=this;return i(function*(){var e=n.config.getOptions();let t=Se();var i=e.debugBypassConsent?"bypass":e.cmpApi;let r;try{r=yield n._consentDataProvider.refreshConsentData(e.debugBypassConsent,e.cmpApi,e.consentData);const s={};r.apiTypes.forEach(e=>s[e]=!0),t.record(Ee(n._metrics,i,h({success:!0},s))),n._multiplexingInstance.updateConsent(r)}catch(e){n._log.error("Couldn't get consent data",e),t.record(Ee(n._metrics,i,{success:!1,error:e.message}))}return r})()}localStorageGrant(){return this.clientStore.localStorageGrant()}getSignature(){return this._signature}}class Ci{isBooted(){return E(window.id5Bootstrap)}getTrueLink(){return this.isBooted()?window.id5Bootstrap.getTrueLinkInfo():{booted:!1}}setPrivacy(e){this.isBooted()&&window.id5Bootstrap.setPrivacy&&window.id5Bootstrap.setPrivacy(e)}clearPrivacy(){this.setPrivacy(void 0)}}const Di=(Kt=window,function(){try{var i=Ei(),r=i.length-1,s=null!==i[r].location||0{!function(t,i){try{const r=t._window;let e=Ti(r);e=e||(r.pbjs=r.pbjs||{});const s=e.que=e.que||[];s.push(()=>{t._pbjs=Ti(r),i(t._pbjs)})}catch(e){t._logger.error("PbjsDetector: Failed to setup detection:",e),i(null)}}(t,e)}),t._pbjsPromise)})()}}var Oi=Object.freeze({AUCTION_END:"auctionEnd",BID_WON:"bidWon",TCF2_ENFORCEMENT:"tcf2Enforcement",AD_RENDER_FAILED:"adRenderFailed",AD_RENDER_SUCCEEDED:"adRenderSucceeded"});const Ri=[Oi.AUCTION_END,Oi.BID_WON,Oi.AD_RENDER_FAILED,Oi.AD_RENDER_SUCCEEDED],xi=(new Date).getTimezoneOffset(),Li=Array.isArray,Ui="id5-api-js",Ni={};Ni[Oi.AUCTION_END]=function(e){const t={auctionId:e.auctionId,timestamp:e.timestamp,auctionEnd:e.auctionEnd};Li(e.bidsReceived)&&(t.bidsReceived=e.bidsReceived.map(Gi));Li(e.noBids)&&(t.noBids=e.noBids.map(Mi));Li(e.bidderRequests)&&(t.bidderRequests=e.bidderRequests.map(ki));return t},Ni[Oi.BID_WON]=Wi,Ni[Oi.AD_RENDER_FAILED]=function(e){return{adId:e.adId,reason:e.reason}},Ni[Oi.AD_RENDER_SUCCEEDED]=function(e){return{adId:e.adId,bid:Wi(e.bid)}},Ni.analyticsError=e=>e;class Fi{constructor(e,t,i,r){var s=4{s._logger.error("pbjsEventsTracker: sendEvent failed",e)})}catch(e){s._logger.error("pbjsEventsTracker: sendEvent failed (sync)",e)}return Promise.resolve()})()}makeEvent(e,t){t=Ni[e]?Ni[e](t):{};return{source:Ui,event:e,payload:t,partnerId:this._partnerId,meta:{sampling:this._sampling,pbjs:this._pbjsVersion,version:Ve,tz:xi}}}sendErrorEvent(e){return this.sendEvent(this.makeEvent("analyticsError",{message:e.message,stack:e.stack}))}}function ki(e){if(e){const t={};return e.bidderCode&&(t.bidderCode=e.bidderCode),Li(e.bids)&&(t.bids=e.bids.map(Vi)),e.ortb2&&(t.ortb2=Hi(e.ortb2)),t}}function ji(e){if(e){const t={};return e.ext&&(t.ext=function(e){if(e)return{linkType:e.linkType,pba:e.pba,abTestingControlGroup:e.abTestingControlGroup}}(e.ext)),t}}function Mi(e){if(e){const t={};return t.bidId=e.bidId,t}}function Vi(e){if(e){const t={};return e.adUnitCode&&(t.adUnitCode=e.adUnitCode),e.bidId&&(t.bidId=e.bidId),e.userId&&(t.userId=function(t){if(t){const i={};return Object.keys(t).forEach(e=>{"id5id"===e?i.id5id=ji(t[e]):i[e]=1}),i}}(e.userId)),e.ortb2&&(t.ortb2=Hi(e.ortb2)),Li(e.userIdAsEids)&&(t.userIdAsEids=e.userIdAsEids.map(qi)),t}}function Gi(i){if(i){const r={};return["adUnitCode","bidderCode","requestId","creativeId","dealId","responseTimestamp","requestTimestamp","width","height","netRevenue","mediaType","originalCpm","originalCurrency","cpm","currency"].forEach(e=>{var t=i[e];t&&(r[e]=t)}),r}}function Wi(i){if(i){const r={};return["auctionId","adUnitCode","bidderCode","requestId","creativeId","dealId","responseTimestamp","requestTimestamp","width","height","netRevenue","mediaType","originalCpm","originalCurrency","cpm","currency"].forEach(e=>{var t=i[e];t&&(r[e]=t)}),r}}function Hi(e){if(e){const t={};return e.user&&(t.user=function(e){if(e){const t={};return e.ext&&(t.ext=function(e){if(e){const t={};return Li(e.eids)&&(t.eids=e.eids.map(qi)),t}return}(e.ext)),t}return}(e.user)),t}}function qi(e){if(e){const t={};return e.source&&(t.source=e.source),Li(e.uids)&&"id5-sync.com"===e.source&&(t.uids=e.uids.map(ji)),t}}function Bi(t,e){let i=1{!function(o,a){let c=2e.json()).then(e=>{c.info("pbjsEventsTracker: Received from configuration endpoint",e);var t="number"==typeof e.sampling?e.sampling:0;if("string"!=typeof e.ingestUrl)return c.error("pbjsEventsTracker: cannot find ingestUrl in config endpoint response; no analytics will be available"),!1;var i=e.ingestUrl;const r=Li(e.eventsToTrack)?e.eventsToTrack:Ri;if(0{c.debug("pbjsEventsTracker: Past event found",e),e&&0<=r.indexOf(e.eventType)?n.push(s.track(e.eventType,e.args)):c.debug("pbjsEventsTracker: Past event ignored",e)}),c.info("pbjsEventsTracker: Register event handlers for",r),r.forEach(t=>{o.onEvent(t,e=>s.track(t,e))}),Promise.all(n).then(()=>!0)}return!1}).catch(e=>(c.error("pbjsEventsTracker: Failed to fetch configuration",e),!1)):(c.error("pbjsEventsTracker: prebidGlobal is not defined"),Promise.resolve(!1))}(e,t,i)}))}catch(e){i.error("pbjsEventsTracker: Failed to register",e)}}class zi{constructor(e){l(this,"_id5Api",void 0),this._id5Api=e,Ai.assignApiStandard(e,this)}init(e){const t=this._id5Api;t.invocationId+=1;const i=new j("api",t.invocationId);try{i.info("ID5 API version ".concat(t._version,". Invoking init()"),e);const u=new He(e,i);var r=u.getOptions();const g=this._configureDiagnostics(r,i);g&&(!function(e,t){return e.timer("instance.load.delay",1p.localStorageGrant("instance-client-store"),n,a,i);var c=new Ci,d=Si.createInstance(window,i,g,s,c,v),l=new Ue(g,i),h=new ze(t._referer,t._version,t._isUsingCdn);const _=new bi(u,v,p,g,l,i,d,h,c);return _.bootstrap(),_.init(),v.scheduleGC(g),setTimeout(()=>{var r,e;Bi(u.getOptions().partnerId,i),r=g,e=i,new Pi(window,e).getPbjs().then(e=>{if(r&&e){const i=Array.isArray(e.installedModules)?e.installedModules:[];var t=i.includes("id5IdSystem"),e=i.includes("id5AnalyticsAdapter");!function(e,t){return e.counter("pbjs.detected",1new le(o,{sampling:n}).publish(e,t):e=>e));null!=s&&s.publishAfterLoadInMsec&&0