/** * @id5io/id5-api.js * @version v1.0.85 * @link https://id5.io/ * @license Apache-2.0 */ !function(){"use strict";function s(t,e){var r,s=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),s.push.apply(s,r)),s}function _(t){for(var e=1;ee.length)&&(t=e.length);for(var r=0,s=new Array(t);r=e.length?{done:!0}:{done:!1,value:e[s++]}},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 i,n=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return n=e.done,e},e:function(e){o=!0,i=e},f:function(){try{n||null==r.return||r.return()}finally{if(o)throw i}}}}function r(e,t,r){return function(e,t){if(e!==t)throw new TypeError("Private static access of wrong provenance")}(e,t),r}class e{debug(){}info(){}warn(){}error(){}}const g=new e;function o(e,t){var r="^\\d+(\\.\\d+(\\.\\d+){0,1}){0,1}$";if(e.match(r)&&t.match(r)){var s=e.split("."),i=t.split("."),r=e=>parseInt(e)||0,e=(e,t)=>{t=e-t;return 0==t?0:t<0?-1:1},t=e(r(s[0]),r(i[0]));if(0!==t)return t;t=e(r(s[1]),r(i[1]));return 0===t?e(r(s[2]),r(i[2])):t}}const n="Array",l="String",p="Function",v=Object.prototype.toString;function I(e,t){return v.call(e)==="[object "+t+"]"}function S(e){return I(e,p)}function w(e){return I(e,l)}function C(e){return I(e,n)}function y(e){return I(e,"Number")}function D(e){return I(e,"Object")}function b(e){return void 0!==e}function E(t,r){if(!function(e){if(!e)return 1;if(C(e)||w(e))return!(0{let r=t.split("="),s=u(r,2),i=s[0],n=s[1];return/\[\]$/.test(i)?(i=i.replace("[]",""),e[i]=e[i]||[],e[i].push(n)):e[i]=n||"",e},{}):{},hash:(r.hash||"").replace(/^#/,""),host:r.host||window.location.host}}function T(e){return(e.protocol||"http")+"://"+(e.host||e.hostname+(e.port?":".concat(e.port):""))+(e.pathname||"")+(e.search?"?".concat((r=e.search||"",Object.keys(r).map(t=>Array.isArray(r[t])?r[t].map(e=>"".concat(t,"[]=").concat(e)).join("&"):"".concat(t,"=").concat(r[t])).join("&"))):"")+(e.hash?"#".concat(e.hash):"");var r}function A(r,e){function s(e,t){if(S(Math.imul))return Math.imul(e,t);var r=(4194303&e)*(t|=0);return 4290772992&e&&(r+=(4290772992&e)*t|0),0|r}e=1>>16,2246822507)^s(n^n>>>13,3266489909),n=s(n^n>>>16,2246822507)^s(i^i>>>13,3266489909),(4294967296*(2097151&n)+(i>>>0)).toString()}const O="TRUE"===V("id5_debug").toUpperCase(),R="TRACE"===V("id5_debug").toUpperCase(),N=Boolean(window.console);let L=!1;function F(e,t,r,s,i){x()&&N&&e&&e.apply(console,["%cID5 - ".concat(t,"#").concat(r),"color: #fff; background: #1c307e; padding: 1px 4px; border-radius: 3px;",s].concat(i))}function x(){return O||R||L}class U extends e{constructor(e,t){super(),d(this,"_invocationId",void 0),d(this,"_origin",void 0),this._invocationId=t,this._origin=e}debug(){for(var e=arguments.length,t=new Array(e),r=0;r{this.options[e]=t,this.providedOptions[e]=t};Object.keys(a).forEach(e=>{if("segments"===e){const s=a[e],i=[];b(s)&&(k(s)?(s.forEach((e,t)=>{t="segments[".concat(t,"]");return k(e.ids)&&function(e,t){let r=!0;return E(e,e=>r=r&&t(e)),r}(e.ids,j)?e.ids.length<1?(d.error("Config option ".concat(t,".ids should contain at least one segment ID")),void(c.invalidSegments+=1)):j(e.destination)?void i.push(e):(Q(d,"".concat(t,".destination"),"String",e.destination),void(c.invalidSegments+=1)):(Q(d,"".concat(t,".ids"),"Array of String",e.ids),void(c.invalidSegments+=1))}),l(e,i)):Q(d,e,"Array",s))}else if("diagnostics"===e){const n=this.options.diagnostics,o=a.diagnostics;if(M(o,K.configTypes.diagnostics)){let t=_({},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,r;void 0!==Y[e]?(r=a[e])&&Y[e].includes(r)&&l(e,r):"partnerId"!==e&&(t=K.configTypes[e],b(r=a[e])&&(M(r,t)?l(e,r):Q(d,e,t,r)))}})}else d.error("Config options must be an object")}setPartnerId(e){let t;if(j(e)){if(t=parseInt(e),isNaN(t)||t<0)throw new Error("partnerId is required and must parse to a positive integer")}else H(e)&&(t=e);if(H(t)){if(H(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 Q(e,t,r,s){e.error("Config option ".concat(t," must be of type ").concat(r," but was ").concat(toString.call(s),". Ignoring..."))}d(K,"configTypes",{debugBypassConsent:"Boolean",allowLocalStorageWithoutConsentApi:"Boolean",cmpApi:"String",consentData:"Object",refreshInSeconds:"Number",partnerUserId:"String",callbackOnAvailable:"Function",callbackOnUpdates:"Function",callbackTimeoutInMs:"Number",pd:"String",abTesting:"Object",provider:"String",maxCascades:"Number",applyCreativeRestrictions:"Boolean",acr:"Boolean",disableUaHints:"Boolean",storageExpirationDays:"Number",att:"Number",diagnostics:"Object",multiplexing:"Object",dynamicConfig:"Object",allowGCReclaim:"String"});const $="undefined"!=typeof Promise&&"undefined"!=typeof fetch;class Z{constructor(e){var t=1function(r){Object.keys(r).forEach(function(e){var t=r[e];t&&(t instanceof Object?r[e]=JSON.stringify(t):r[e]="".concat(t))})}(e.tags)),fetch(this.url,{method:"POST",headers:{"Content-Type":"text/plain"},mode:"no-cors",body:JSON.stringify({metadata:_(_({},this._metadata),t),measurements:e})})):Promise.resolve()}}class ee{constructor(e,t){d(this,"_publisher",void 0),d(this,"_scheduled",void 0),this.meterRegistry=e,this._publisher=t;const r=this;this.meterRegistry.onUnregister(function(){const e=r._onUnloadPublishAbortController;if(e)return e.abort(),r.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 te=Object.freeze({});var re={EMPTY:te,from:function(e){return e?e instanceof Map?Object.fromEntries(e):e:te},toString:function(e){return Array.from(Object.entries(e),e=>{var t=u(e,2),e=t[0],t=t[1];return"".concat(e,"=").concat(t)}).sort().toString()}};const se=Object.freeze({TIMER:"TIMER",SUMMARY:"SUMMARY",COUNTER:"COUNTER"});class ie{constructor(e,t,r){d(this,"name",void 0),d(this,"tags",void 0),d(this,"values",void 0),this.name=e,this.tags=re.from(t),this.type=r,this.values=[]}reset(){this.values=[]}}class ne extends ie{constructor(e){super(e,1{return u(e,2)[1]})}}function he(){return new oe}function ue(e){return{partner:e}}class ge 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=_(_({},this.commonTags),re.from(e))}timer(e){return this.getOrCreate(e,1new ne(e,t))}counter(e){return this.getOrCreate(e,1new ae(e,t))}summary(e){return this.getOrCreate(e,1new ce(e,t))}unregister(){void 0!==this._onUnregisterCallback&&this._onUnregisterCallback(this)}onUnregister(e){this._onUnregisterCallback=e}}{constructor(e,t){var r=2{let s=r.data;if(void 0!==r.data&&r.data._isId5Message&&r.data.src!==i._id&&(void 0===r.data.dst||r.data.dst===i._id))try{[me,s.type].forEach(e=>{let t=i._handlers[e];t&&t.forEach(e=>e(s,r.source))})}catch(e){i._log.error("Error while handling message",s,e)}},{capture:!1,signal:e})}unregister(){this._abortController&&this._abortController.abort()}onAnyMessage(e){return this.onMessage(me,e)}onMessage(e,t){const r=this._handlers[e];return r?r.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 r=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(h(new ye,e.payload)))}_countInvalidMessage(e,t){var r=e=>null!=e;void 0!==this._metrics&&!function(e,t){return e.counter("instance.message.invalid.count",1t[e]).reduce((e,t)=>e&&t,!0);return new xe(s,Fe.CONSENT_API,t,r)}_addToDebugInfo(e,t,r){return void 0!==t.localStoragePurposeConsent&&(r[e+"-localStoragePurposeConsent"]=t.localStoragePurposeConsent),void 0!==t.vendorsConsentForId5Granted&&(r[e+"-vendorsConsentForId5Granted"]=t.vendorsConsentForId5Granted),r}_isGranted(){return!1===this.gdprApplies||!0===this.localStoragePurposeConsent&&!1!==this.vendorsConsentForId5Granted}hashCode(){this.localStoragePurposeConsent,this.ccpaString;var e=t(this,Ee);return A(JSON.stringify(e))}static createFrom(e){const t=h(new Le,e);return b(t.api)&&(t.apiTypes=function(e){var t=e.api;if(t===Te.NONE)return[];if(t!==Te.PREBID)return[t];{const r=[];return(b(e.gdprApplies)||b(e.consentString))&&r.push(Te.TCF_V2),b(e.ccpaString)&&r.push(Te.USP_V1),b(e.gppData)&&b(e.gppData.version)&&r.push(e.gppData.version),r}}(e),t.api=void 0),D(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 b(this.gdprApplies)&&(e.gdpr=this.gdprApplies),b(this.consentString)&&(e.gdpr_consent=this.consentString),b(this.ccpaString)&&(e.us_privacy=this.ccpaString),b(this.gppData)&&(e.gpp=this.gppData.gppString,e.gpp_sid=this.gppData.applicableSections.join(",")),e}}const Fe=Object.freeze({FORCE_ALLOWED_BY_CONFIG:"force_allowed_by_config",ID5_CONSENT:"id5_consent",PROVISIONAL:"provisional",JURISDICTION:"jurisdiction",CONSENT_API:"consent_api"});class xe{constructor(e,t){var r=2{var t=e.cacheId;i.has(t)||(e=r.getResponseFor(e.integrationId))&&(this._clientStore.storeResponseV2(t,e,r.timestamp,s),i.add(t))}),this._trueLinkAdapter.setPrivacy(null===(e=r.getGenericResponse())||void 0===e?void 0:e.privacy)}clearAll(e){this._clientStore.clearResponse(),this._clientStore.clearDateTime(),e.forEach(e=>{e=e.cacheId;this._clientStore.clearResponseV2(e)}),this._clientStore.clearHashedConsentData(),this._trueLinkAdapter.clearPrivacy(),this._clientStore.clearExtensions()}getCachedResponse(e){e=this._clientStore.getStoredResponseV2(e);if(e)return new je(e.response,e.responseTimestamp,e.nb,e.consents)}getCachedExtensions(){return this._clientStore.getExtensions()}storeExtensions(e){var t=y(e.ttl)?e.ttl/86400:Me.DEFAULT.EXTENSIONS.expiresDays,t=new Ve(Me.DEFAULT.EXTENSIONS.name,t);return this._clientStore.storeExtensions(e,t)}}class je{constructor(e,t){var r=2e}isStale(){return!this.timestamp||this._isOlderThanSec(1209600)}isResponseComplete(){return D(this.response)&&w(this.response.universal_uid)&&w(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 ke="_exp";class He{constructor(e){var t=1{e.removeItem(t)};this._replicas.forEach(e),this._lastKeyOperation[t]=e}setItem(t,r){this._primaryStorage.setItem(t,r);var e=e=>{e.setItem(t,r)};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 Xe{constructor(e){var t=1{const i=e.map(e=>{const t=e.cacheData;var r=null===t||void 0===t||null===(i=t.response)||void 0===i?void 0:i.signature,s=null===t||void 0===t?void 0:t.nb,i=null===t||void 0===t?void 0:t.getMaxAge();return this._createRequest(d,e,r,s,i,n,l)}),o=this._log,a=this._metrics,c=this;return new Promise((t,r)=>{const s=he();var e="".concat("https://id5-sync.com").concat("/gm/v3");o.info("Fetching ID5 ID from:",e,i),function(s,i,n,o,e){o=3{r.setRequestHeader(t,e)}),o.preflight&&r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.setRequestHeader("Content-Type",o.contentType||"text/plain"),"POST"===d&&n?r.send(n):r.send()}catch(e){a.error("ajax","xhr construction",e)}}(e,{success:function(e){o.info("Success at fetch call:",e),s.record(function(e,t){return ve(e,"success",1{var t=u(e,2),e=t[0],t=t[1];b(r[e])&&(l[t]=r[e])});e=r.abTesting;e&&!0===e.enabled&&(l.ab_testing={enabled:!0,control_group_pct:e.controlGroupPct});e=r.invalidSegmentsCount;return e&&0void 0!==e.find(e=>t.getId()===e)&&t.canDoCascade()).sort((e,t)=>{function r(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 r(e)-r(t)});if(0{const e=this._consentManager.localStorageGrant("fetch-before-request");if(o.info("Local storage grant",e),e.allowed){var r=this._store.hasConsentChanged(t);e.isDefinitivelyAllowed()&&this._store.storeConsent(t);var s=Be.checkIfAccessible();const c=new Map;let a=n;const i=this._followers.map(e=>{var t=e.getId(),r=(this._followersRequests[t]||0)+1,s=this._properties.id,i=!0===this._refreshRequired[e.getId()];a=a||i;var n,o=e.getCacheId();return c.has(o)||(n=this._store.getCachedResponse(o))&&c.set(o,n),_(_({},e.getFetchIdData()),{},{integrationId:t,requestCount:r,refresh:i,role:s===e.getId()?"leader":e.type||"follower",cacheId:o,cacheData:c.get(o),sourceVersion:e.getSourceVersion(),source:e.getSource()})});r||a?(o.info("Decided to fetch a fresh ID5 ID",{consentHasChanged:r,shouldRefresh:a}),o.info("Fetching ID5 ID (forceFetch:".concat(n,")")),this._inProgressFetch=!0,this._firstFetchTriggered=!0,this._fetcher.fetchId(i,t,s).then(e=>{this._handleRefreshResult(i,c,t,e),this._handleFetchCompleted()}).catch(e=>{this._handleFailed(e),this._handleFetchCompleted()})):(o.info("Not decided to refresh ID5 ID",{consentHasChanged:r,shouldRefresh:a}),this._handleFetchCompleted())}else o.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,r=this._metrics;t.info("Waiting for consent");const s=r.timer("fetch.consent.wait.time");return e.getConsentData().then(e=>(t.info("Consent received",e),s&&s.recordNow(),e))}start(){!0!==this._started&&(this._getId(!1),this._started=!0)}refreshUid(){var e=0e.getId()===t))&&this._provisionFromCache(r)),function(e,t,r){return e.counter("refresh.call.count",_({target:t},2e.getDeclaredConsentSource()).filter(e=>e!==Ae.none));var r=e.source||Ae.cmp,s=1===i.size&&i.has(Ae.partner);this._awaitedConsentFrom?this._awaitedConsentFrom===t?(this._consentManager.setConsentData(e),this._awaitedConsentFrom=void 0):this._handleIgnoredConsent(e,"awaited"):r!==Ae.partner||s?this._consentManager.setConsentData(e):this._handleIgnoredConsent(e,"partner")}}_handleIgnoredConsentUpdate(e){try{const s=this._consentManager._consentDataHolder.getValue();if(s){const i={},n=Le.createFrom(e);Object.values(Te).forEach(e=>{var t,r;n.apiTypes.includes(e)&&s.apiTypes.includes(e)?(t=JSON.stringify(s.getApiTypeData(e)),r=JSON.stringify(n.getApiTypeData(e)),i[e]=t===r?"same":"different"):n.apiTypes.includes(e)?i[e]="added":s.apiTypes.includes(e)&&(i[e]="missed")}),function(e,t){return e.counter("leader.consent.change.count",1r[e]=!0),function(e,t){return e.counter("leader.consent.ignore.count",1e.getId()===t);var s=r.getCacheId();r.updateFetchIdData(e);e=r.getCacheId();e!==s&&(this._log.info("Follower",r.getId(),"cacheId changed from",s," to",e,"required refresh"),this._refreshRequired[r.getId()]=!0)}addFollower(t){const e=this._log;var r=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()&&(s=t.getStorage(),e.debug("Adding follower's",t.getId(),"storage as replica"),this._leaderStorage.addReplica(s));var s=this._provisionFromCache(t);let i=new it;return!0===this._firstFetchTriggered&&(i.lateJoiner=!0,i.uniqueLateJoiner=r,s&&this._callRefresh({forceFetch:!0})),i}_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,r=m(this._followers);try{for(r.s();!(t=r.n()).done;){const s=t.value;s.notifyFetchUidCanceled({reason:"error"})}}catch(e){r.e(e)}finally{r.f()}}}class at extends nt{constructor(e,t){super(),d(this,"_messenger",void 0),d(this,"_leaderInstanceProperties",void 0),this._messenger=e,this._leaderInstanceProperties=t}_sendToLeader(e,t){this._messenger.callProxyMethod(this._leaderInstanceProperties.id,Ce.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 ct extends nt{constructor(){super(...arguments),d(this,"_callsQueue",[]),d(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,r=m(this._callsQueue);try{for(r.s();!(t=r.n()).done;){var s=t.value;this._callAssignedLeader(s.name,s.args)}}catch(e){r.e(e)}finally{r.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 dt extends We{constructor(e,t){super(),d(this,"_messenger",void 0),d(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,Ce.STORAGE,e,t)}}class lt extends tt{constructor(e,t){var r=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 ut extends class{getConsentData(){}localStorageGrant(){}setStoredPrivacy(){}}{constructor(e,t,r,s,i){super(),d(this,"_consentDataHolder",void 0),d(this,"storedPrivacyData",void 0),d(this,"localStorage",void 0),d(this,"_forceAllowLocalStorageGrant",void 0),this._log=s,this.localStorage=e,this.storageConfig=t,this._consentDataHolder=new ht,this._forceAllowLocalStorageGrant=r,this._metrics=i}isForceAllowLocalStorageGrant(){return this._forceAllowLocalStorageGrant}resetConsentData(e){this._consentDataHolder.reset(),this.storedPrivacyData=void 0,this._forceAllowLocalStorageGrant=e}localStorageGrant(){var e=0_(_({},e),{},{response:t,responseTimestamp:r,consents:s}))}getStoredResponseV2(e){return this._getObject(this.storageConfig.ID5_V2.withNameSuffixed(e))}incNbV2(e){let r=1{var t=Math.max(0,y(null==e?void 0:e.nb)?Math.round(e.nb)+r:r);return _(_({},e),{},{nb:t})})}static storedDataMatchesCurrentData(e,t){return null==e||e===t}storedConsentDataMatchesConsentData(e){return gt.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)}}class pt{constructor(e,t,r){d(this,"_metrics",void 0),d(this,"_log",void 0),d(this,"_store",void 0),this._metrics=e,this._log=t,this._store=r}static getChunkUrl(e,t){return"https://d".concat(e,".eu-").concat(t,"-id5-sync.com")}submitExtensionCall(t,r){var e=2{if(e.ok)return s.record(_e(this._metrics,r,!0)),e.json();s.record(_e(this._metrics,r,!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=>(s.record(_e(this._metrics,r,!1)),this._log.warn("Got error from ".concat(t," endpoint"),e),{}))}gatherChunks(e,r){if(e){let t=he();return Promise.all(Array.from({length:r.length},(e,t)=>{t=pt.getChunkUrl(t,r.urlVersion);return fetch(t).then(e=>{if(e.ok)return e.text();throw new Error("The call to get ".concat(r.name," was not ok, status: ").concat(e.status,", statusText: ").concat(e.statusText))})})).then(e=>(t.record(_e(this._metrics,r.name,!0)),{[r.name]:e,[r.name+"Version"]:"".concat(r.version)})).catch(e=>(t.record(_e(this._metrics,r.name,!1)),this._log.warn("Got error when getting ".concat(r.name),e),{}))}return Promise.resolve({})}gather(e){var t=this._store.getCachedExtensions();if(void 0!==t)return Promise.resolve(t);let r=he(),s=this._submitBounce(e),i=this._submitLbs();return this.submitExtensionCall("https://lb.eu-1-id5-sync.com/lb/v1","lb").then(e=>{var t=this.getChunksEnabled(e);return Promise.allSettled([Promise.resolve(e),this.gatherChunks(t,pt.CHUNKS_CONFIGS.devChunks),this.gatherChunks(t,pt.CHUNKS_CONFIGS.groupChunks),s,i])}).then(e=>{r.record(_e(this._metrics,"all",!0));let t=pt.DEFAULT_RESPONSE;return e.forEach(e=>{e.value&&(t=_(_({},t),e.value))}),this._store.storeExtensions(t),t}).catch(e=>(r.record(_e(this._metrics,"all",!1)),this._log.error("Got error ".concat(e," when gathering extensions data")),pt.DEFAULT_RESPONSE))}_submitLbs(){const e=new AbortController,t=setTimeout(()=>e.abort(),3e3);let r=this.submitExtensionCall("https://lbs.eu-1-id5-sync.com/lbs/v1","lbs",{signal:e.signal});return r.finally(()=>{clearTimeout(t)})}_submitBounce(e){return e.some(e=>{return b(null===(e=e.cacheData)||void 0===e?void 0:e.signature)})?Promise.resolve({}):this.submitExtensionCall("https://id5-sync.com/bounce","bounce",{credentials:"include"})}getChunksEnabled(e){e=null==e?void 0:e.chunks;return 0!==e&&e}}d(pt,"CHUNKS_CONFIGS",Object.freeze({devChunks:{name:"devChunks",urlVersion:3,length:8,version:4},groupChunks:{name:"groupChunks",urlVersion:4,length:8,version:4}})),d(pt,"DEFAULT_RESPONSE",{lbCDN:"%%LB_CDN%%"});const vt={createExtensions:function(e,t,r){return new pt(e,t,r)}},_t=Object.freeze({UNKNOWN:"unknown",LEADER:"leader",FOLLOWER:"follower"}),ft=Object.freeze({MULTIPLEXING:"multiplexing",SINGLETON:"singleton",MULTIPLEXING_PASSIVE:"multiplexing-passive"}),mt=Object.freeze({AWAITING_SCHEDULE:"awaiting_schedule",SKIPPED:"skipped",SCHEDULED:"scheduled",COMPLETED:"completed",CANCELED:"canceled"});class It{constructor(e,t,r){d(this,"properties",void 0),d(this,"knownState",void 0),d(this,"_joinTime",void 0),d(this,"_window",void 0),this.properties=e,this.knownState=t,this._window=r,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===ft.MULTIPLEXING||e===ft.MULTIPLEXING_PASSIVE}isLeaderCapable(){var e;return(null===(e=this.knownState)||void 0===e?void 0:e.operatingMode)===ft.MULTIPLEXING}isPassive(){var e;return(null===(e=this.knownState)||void 0===e?void 0:e.operatingMode)===ft.MULTIPLEXING_PASSIVE}getInstanceMultiplexingLeader(){var e,t;if((null===(e=this.knownState)||void 0===e?void 0:e.operatingMode)===ft.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 St{constructor(e,t,r,s){d(this,"properties",void 0),d(this,"_messenger",void 0),d(this,"_knownInstances",new Map),d(this,"role",void 0),d(this,"_mode",void 0),d(this,"_metrics",void 0),d(this,"_logger",void 0),d(this,"_window",void 0);var i=b(globalThis)&&b(globalThis.crypto)&&S(globalThis.crypto.randomUUID)?globalThis.crypto.randomUUID():"".concat(1e6*Math.random()|0);this.properties=h({id:i,version:"1.0.40",href:null===(i=e.location)||void 0===i?void 0:i.href,domain:null===(i=e.location)||void 0===i?void 0:i.hostname},t),this.role=_t.UNKNOWN,this._metrics=r,this._loadTime=performance.now(),this._logger=new wt(s,this),this._window=e,this._dispatcher=new $e(this._logger),this._followerRole=new rt(this._window,this.properties,this._dispatcher,this._logger,this._metrics)}updateConfig(e){h(this.properties,e)}register(e){try{this.updateConfig(e),this.init(),this._messenger.broadcastMessage(this._createHelloMessage(!1),we.TYPE)}catch(e){this._logger.error("Failed to register integration instance",e)}return this}init(){let s=this,i=s._window;s._mode=ft.MULTIPLEXING_PASSIVE,s._messenger=new be(s.properties.id,i,s._logger,s._metrics),s._messenger.onAnyMessage((e,t)=>{var r=Date.now()-e.timestamp|0;!function(e,t){return e.timer("instance.message.delivery.time",1{let r=h(new we,e.payload);void 0===r.isResponse&&(r.isResponse=void 0!==e.dst),s._handleHelloMessage(r,e,t)})}_handleHelloMessage(e,t,r){var s=e.isResponse;const i=new It(e.instance,e.instanceState,r);this._knownInstances.get(i.getId())?this._logger.debug("Instance already known",i.getId()):(this._knownInstances.set(i.getId(),i),s||this._messenger.sendResponseMessage(t,this._createHelloMessage(!0),we.TYPE),this._logger.debug("Instance joined",i.getId()),this._doFireEvent(Ke.ID5_INSTANCE_JOINED,i.properties),this._onInstanceDiscovered(e,i))}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 we(this.properties,e,t)}_doFireEvent(e){for(var t=arguments.length,r=new Array(1{t._timeoutId&&(t._timeoutId=void 0,t._instance._doElection(),t._closeWithState(mt.COMPLETED))},t._delayMs),t._state=mt.SCHEDULED,t._scheduleTime=performance.now()}skip(){this._closeWithState(mt.SKIPPED)}cancel(){this._timeoutId&&(clearTimeout(this._timeoutId),this._timeoutId=void 0),this._closeWithState(mt.CANCELED)}_closeWithState(e){this._state=e,this._closeTime=performance.now()}}class bt extends St{constructor(e,t,r,s,i,n,o){super(e,t,s,i),d(this,"_lastJoinedInstance",void 0),d(this,"_leader",void 0),d(this,"_remoteCallsToLeaderHandler",void 0),d(this,"_instanceCounters",void 0),d(this,"_election",void 0),d(this,"_storage",void 0),d(this,"_trueLinkAdapter",void 0),d(this,"_cachedIdProvider",void 0),this._leader=new ct,this._remoteCallsToLeaderHandler=new ct,this._instanceCounters=new yt(s,this.properties),this._storage=r,this._trueLinkAdapter=n,this._cachedIdProvider=new st("self",new Ge(o,n),this._logger,this._metrics),this._election=new Dt(this)}init(){super.init();var e,t=this;t._mode=!0===t.properties.singletonMode?ft.SINGLETON:ft.MULTIPLEXING,t._instanceCounters.addInstance(t.properties),function(r){const s=r._metrics;[100,200,500,1e3,2e3,3e3,5e3].forEach(t=>{setTimeout(()=>{var e=((null===(e=r._knownInstances)||void 0===e?void 0:e.size)||0)+1;s.summary("instance.partySize",{after:t,electionState:r._election._state}).record(e)},t)})}(t),t._messenger.onProxyMethodCall(new De(t._logger).registerTarget(Ce.LEADER,t._remoteCallsToLeaderHandler).registerTarget(Ce.FOLLOWER,t._followerRole).registerTarget(Ce.STORAGE,t._storage)),t._mode===ft.SINGLETON?(t._election.skip(),t._onLeaderElected(t.properties)):t._mode===ft.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"),i,n,t),this._trueLinkAdapter),n=new ze(r,t,vt.createExtensions(r,t,i));const a=new ot(this._window,e,s,i,o,r,t,n);a.addFollower(this._followerRole),this._leader.assignLeader(a),this._remoteCallsToLeaderHandler.assignLeader(a),this._mode===ft.MULTIPLEXING&&Array.from(this._knownInstances.values()).filter(e=>e.isMultiplexingPartyAllowed()).map(e=>a.addFollower(new lt(e,this._messenger,t,e.isPassive()?et.PASSIVE:et.STANDARD))),a.start()}_followRemoteLeader(e){this._leader.assignLeader(new at(this._messenger,e)),this._remoteCallsToLeaderHandler.assignLeader(new Et(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),h(this.properties.fetchIdData,e)}refreshUid(e){this._leader.refreshUid(e,this.properties.id)}_doElection(){var e=this._election;const t=this._knownInstances;let r=Array.from(t.values()).filter(e=>e.isMultiplexingPartyAllowed()&&e.isLeaderCapable()).map(e=>e.properties);r.push(this.properties),this._onLeaderElected(function(e){if(!e||0===e.length)return;e=e.sort((e,t)=>{let r=-(0|o(e.version,t.version));var s,i,n;return 0===r&&(r=e.source.localeCompare(t.source),0===r&&(r=-(0|o(e.sourceVersion,t.sourceVersion))),0===r&&(i=(null===(i=e.fetchIdData)||void 0===i||null===(s=i.refererInfo)||void 0===s?void 0:s.numIframes)||Number.MAX_SAFE_INTEGER,n=(null===(s=t.fetchIdData)||void 0===s||null===(n=s.refererInfo)||void 0===n?void 0:n.numIframes)||Number.MAX_SAFE_INTEGER,r=i-n),0===r&&(r=e.id.localeCompare(t.id))),r});return e[0]}(r));var s=this._lastJoinedInstance;s&&!function(e,t){return e.timer("instance.lastJoin.delay",_({},1w(e.brand)&&e.brand.search(t)<0)),C(e.fullVersionList)&&(e.fullVersionList=e.fullVersionList.filter(e=>w(e.brand)&&e.brand.search(t)<0)),e}}}const At={A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,a:26,b:27,c:28,d:29,e:30,f:31,g:32,h:33,i:34,j:35,k:36,l:37,m:38,n:39,o:40,p:41,q:42,r:43,s:44,t:45,u:46,v:47,w:48,x:49,y:50,z:51,0:52,1:53,2:54,3:55,4:56,5:57,6:58,7:59,8:60,9:61,"-":62,_:63,"+":62,"/":63};const Ot=Object.freeze({tcfv2:{objName:"__tcfapiCall",objKeys:["command","version"],returnObjName:"__tcfapiReturn"},uspv1:{objName:"__uspapiCall",objKeys:["command","version"],returnObjName:"__uspapiReturn"},gppv1:{objName:"__gppCall",objKeys:["command","parameter"],returnObjName:"__gppReturn"}}),Rt=Object.freeze({TCF:0,USP:1,GPP:2});class Nt{constructor(e,t){d(this,"direct",void 0),d(this,"version",void 0),this.direct=e,this.version=t}getConsentData(){var e=this;return f(function*(){return e.getClientConsentData()})()}static create(a,c){return f(function*(){var e=Vt._findCmpApi("__gpp"),t=e.cmpApiFrame,e=e.cmpApiFunction;let r,s=!1;if(!t)return a.warn("cmpApi: GPP not found! Using defaults."),Promise.resolve();if(G(e))s=!0,a.info("cmpApi: Detected GPP is directly accessible, calling it now."),r=e;else{a.info("cmpApi: Detected GPP is outside the current iframe. Using message passing.");const o=Vt._buildCmpSurrogate(Ot.gppv1,t);r=function(e,t,r){o(e,r,t)}}var i=yield new Promise(t=>{var e=r("ping",function(e){t(e)});W(e)&&t(e)});switch(i.gppVersion){case Ft.version:return new Ft(i,r,s);case Ut.version:return new Ut(i,r,s,c);default:var n="Unsupported version of gpp: ".concat(i.gppVersion);return a.warn(n),Promise.reject(n)}})()}static caTcfDataHasExpressConsent(e){e=e.PurposesExpressConsent;if(k(e)&&0e==Pe)}static tcfDataHasLocalStorageGrant(e){e=r(Nt,Nt,Lt).call(Nt,e,"PurposeConsent","PurposeConsents");if(k(e)&&0e==Pe))}static getTcfData(e){let t=void 0;return k(e)&&W(e[0])?t=e[0]:W(e)&&(t=e),t}}function Lt(e,t,r){return t in e?e[t]:e[r]}class Ft extends Nt{constructor(e,t,r){super(r,Ft.version),d(this,"gppFn",void 0),d(this,"ready",void 0),this.gppFn=t,this.ready=this.isReady(e)}isReady(e){return"loaded"===e.cmpStatus&&"visible"!==e.cmpDisplayStatus}getClientConsentData(){var s=this;return f(function*(){s.ready||(s.ready=yield new Promise(t=>{s.gppFn("addEventListener",e=>!!s.isReady(e.pingData)&&void t(!0))}));var e=new Promise(t=>{s.gppFn("getGPPData",e=>{t(e)})}),t=new Promise(t=>{s.gppFn("getSection",e=>{t(e)},"tcfeuv2")}),e=u(yield Promise.all([e,t]),2),t=e[0],e=e[1];const r=new Ne(Te.GPP_V1_0,t.applicableSections,t.gppString);return e&&(r.euTcfSection=new Re(Nt.tcfDataHasLocalStorageGrant(e),Nt.tcfDataHasID5VendorConsented(e))),r})()}}function xt(e,t,r){r&&(e.apiTypes.push(t),h(e,r))}d(Ft,"version","1.0");class Ut extends Nt{constructor(e,t,r,s){super(r,Ut.version),d(this,"gppFn",void 0),d(this,"readyPingData",void 0),d(this,"metrics",void 0),this.gppFn=t,"ready"===e.signalStatus&&(this.readyPingData=e),this.metrics=s}getClientConsentData(){var o=this;return f(function*(){const n=o.metrics;return new Promise(r=>{let s=!1;if(o.readyPingData)r(o.parsePingData(o.readyPingData));else{const i=Date.now();let t=setTimeout(()=>{t=void 0,o.gppFn("ping",e=>{"stub"===e.cmpStatus&&(n.counter("gpp.stubUsed",{cmpId:e.cmpId}).inc(),r(o.parsePingData(e)))})},1e3);o.gppFn("addEventListener",e=>"ready"===e.pingData.signalStatus&&void(s?Ut.measureAdditionalEvent(e,n,i):(t?(clearTimeout(t),t=void 0):s||n.timer("gpp.lateCmp",{cmpId:e.pingData.cmpId}).record(Date.now()-i),r(o.parsePingData(e.pingData)),s=!0)))}})})()}static measureAdditionalEvent(e,t,r){["cmpStatus","cmpDisplayStatus","signalStatus","sectionChange"].includes(e.eventName)&&t.timer("gpp.additionalEvents",{cmpId:e.pingData.cmpId,name:e.eventName}).record(Date.now()-r)}parsePingData(e){const t=new Ne(Te.GPP_V1_1,e.applicableSections,e.gppString);var r;return!t.applicableSections.includes(Oe.TCFEUV2)||(r=Nt.getTcfData(null===(r=e.parsedSections)||void 0===r?void 0:r.tcfeuv2))&&(t.euTcfSection=new Re(Nt.tcfDataHasLocalStorageGrant(r),Nt.tcfDataHasID5VendorConsented(r))),!t.applicableSections.includes(Oe.TCFCAV1)||(e=Nt.getTcfData(null===(e=e.parsedSections)||void 0===e?void 0:e.tcfcav1))&&(t.canadaTcfSection=new Re(Nt.caTcfDataHasExpressConsent(e),Nt.caTcfDataHasVendorExpressConsent(e))),t}}d(Ut,"version","1.1");class Vt{constructor(e){var t=1{s._lookupInProgress=!1})),this._consentDataPromise}_lookupConsentData(e,t,r){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 Le;return e.forcedGrantByConfig=!0,e.source=Ae.partner,Promise.resolve(e)}switch(t){case"static":return new Promise(e=>{this._parseStaticConsentData(r,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 r=new Le;if(r.source=Ae.partner,W(e.getTCData)){const s=this._parseTcfData(e.getTCData);xt(r,Te.TCF_V2,s);try{const i=this._metrics;this._lookupTcf(e=>{pe(i,{apiType:Te.TCF_V2,sameString:(null==e?void 0:e.consentString)===(null===s||void 0===s?void 0:s.consentString),sameLSPC:(null==e?void 0:e.localStoragePurposeConsent)===(null===s||void 0===s?void 0:s.localStoragePurposeConsent),sameVendorsConsentForId5Granted:(null==e?void 0:e.vendorsConsentForId5Granted)===(null===s||void 0===s?void 0:s.vendorsConsentForId5Granted),sameGdpr:(null==e?void 0:e.gdprApplies)===(null===s||void 0===s?void 0:s.gdprApplies)}).inc()})}catch(e){}}if(k(e.allowedVendors)&&xt(r,Te.ID5_ALLOWED_VENDORS,{allowedVendors:e.allowedVendors.map(e=>e.toString()),gdprApplies:!0}),W(e.getUSPData)){const n=this._parseUspData(e.getUSPData);xt(r,Te.USP_V1,n);try{const o=this._metrics;this._lookupUsp(e=>{pe(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===r.apiTypes.length&&this._log.warn("cmpApi: No static consent data detected! Using defaults."),this._log.info("cmpApi: Detected APIs '".concat(r.apiTypes,"' from static consent data"),e),t(r)}_lookupIabConsent(s){const i=[];let n=new Le;n.source=Ae.cmp;var e=r=>(i[r]=0,(e,t)=>{i[r]||(i[r]=Date.now(),e&&xt(n,t,e),i.every(e=>0{t?r(this._parseUspData(e),Te.USP_V1):(this._log.error("cmpApi: USP callback not successful. Using defaults for CCPA."),r())})}_lookupGpp(n){var o=this;return f(function*(){var t=Date.now();try{let e=yield Nt.create(o._log,o._metrics);if(e){var r={gppVersion:e.version,directCmp:e.direct};try{var s=yield e.getConsentData();n({gppData:s},s.version);var i=Date.now();o._metrics.timer("gpp.delay",r).record(i-t)}catch(e){o._metrics.counter("gpp.failure",h({type:"CONSENT"},r)).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,r)=>{const s=Math.random()+"",i={},n={};n[a.objKeys[0]]=e,n[a.objKeys[1]]=t,n.callId=s,i[a.objName]=n;const o=e=>{e=J(e,"data.".concat(a.returnObjName));e&&e.callId===s&&(void 0!==(e=r(e.returnValue,e.success))&&!0!==e||window.removeEventListener("message",o))};window.addEventListener("message",o,!1),c.postMessage(i,"*")}}_lookupTcf(e){var t=Vt._findTCF(),r=t.cmpFrame,t=t.cmpFunction;if(!r)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(r,e))}_lookupMessageTcf(e,t){e=Vt._buildCmpSurrogate(Ot.tcfv2,e);this._lookupDirectTcf(e,t)}_lookupDirectTcf(e,i){const n=this._log;e("addEventListener",2,(e,t)=>{var r,s;return r="event",s=e,n.info("cmpApi: TCFv2 - Received a call back: ".concat(r),s),t?!(!e||!1!==e.gdprApplies&&"tcloaded"!==e.eventStatus&&"useractioncomplete"!==e.eventStatus)&&void i(this._parseTcfData(e),Te.TCF_V2):(n.error("cmpApi: TCFv2 - Received insuccess: ".concat("addEventListener",". Please check your CMP setup. Using defaults for GDPR.")),void i())})}_parseUspData(e){if(W(e)&&j(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,r,s;if(r=Vt._isValidV2ConsentObject,s=Vt._normalizeV2Data,r(e))return s(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||j(e)}static _tcfDataHasID5VendorConsented(e){var t,r;return!0===(null==e||null===(t=e.vendor)||void 0===t||null===(r=t.consents)||void 0===r?void 0:r[Pe])}static _normalizeV2Data(e){let t=J(e,"purpose.consents.1");q(t)||(t=function(e,t){var r=152+t-1,t=~~(r/6);if(e&&"C"===e.charAt(0)&&!(e.length<=t)){t=e.charAt(t),t=At[t];if(void 0!==t)return 0!=(t&1<<6-r%6-1)}}(e.tcString,1));var r=Vt._tcfDataHasID5VendorConsented(e);return{consentString:e.tcString,localStoragePurposeConsent:t,gdprApplies:e.gdprApplies,vendorsConsentForId5Granted:r}}static _findTCF(){let e=window,t,r;for(;!t;){try{if("function"==typeof e.__tcfapi){r=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:r}}static _findCmpApi(e){let t=window,r,s;for(;!r;){try{if("function"==typeof t[e]){s=t[e],r=t;break}}catch(e){}try{if(t.frames["".concat(e,"Locator")]){r=t;break}}catch(e){}if(t===window.top)break;t=t.parent}return{cmpApiFrame:r,cmpApiFunction:s}}}class Mt{isBooted(){return D(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 Gt="id5-prebid-ext-module";class jt{set debug(e){e=e,L=!!e}get debug(){return x()}constructor(){d(this,"invocationId",0),d(this,"_version",X),d(this,"userIdReady",!1),this._isUsingCdn=!!(document&&document.currentScript&&document.currentScript.src&&0===document.currentScript.src.indexOf("https://cdn.id5-sync.com"))}fetchId5Id(d,l,h,u,g,p){var v=this;return f(function*(){var e;v.invocationId+=1;var t=B(window.pbjs)?window.pbjs.version:"unknown";const i=new U(Gt,v.invocationId);i.info("ID5 API Prebid external module version ".concat(v._version,". Invoking fetchId5Id()"),d,l);const r=new K({partnerId:l.partner,pd:l.pd,abTesting:l.abTesting,multiplexing:l.multiplexing,diagnostics:l.diagnostics,segments:l.segments,disableUaHints:l.disableUaHints,dynamicConfig:d},i);var s=r.getOptions();const n=v._configureDiagnostics(s.partnerId,s.diagnostics,h,i,t);n&&(!function(e,t){return e.timer("instance.load.delay",1{a.on(Ye.USER_ID_READY,(e,t)=>{try{var r=null!=t&&t.tags?_({},t.tags):{};null!=t&&t.timestamp&&n.timer("userid.provisioning.delivery.delay",r).record(Date.now()-t.timestamp),c.record(function(e,t,r){return e.timer("userid.provisioning.delay",_({cachedResponseUsed:t},2{i.info("ID5 User ID fetch canceled:",e.reason),t(e.reason)})}),t=yield v._gatherFetchIdData(r,h,i,t);return a.register({source:Gt,sourceVersion:X,sourceConfiguration:{options:r.getOptions()},fetchIdData:t,singletonMode:!0===(null==s||null===(e=s.multiplexing)||void 0===e?void 0:e._disabled),canDoCascade:null!==(e=l.canCookieSync)&&void 0!==e&&e,forceAllowLocalStorageGrant:!1,storageExpirationDays:s.storageExpirationDays}),o})()}_buildConsentData(e,t,r){const s=new Le;var i;return s.source=Ae.prebid,e&&(s.apiTypes.push(Te.TCF_V2),s.gdprApplies=e.gdprApplies,s.consentString=e.consentString,s.localStoragePurposeConsent=J(e.vendorData,"purpose.consents.1")),t&&(s.apiTypes.push(Te.USP_V1),s.ccpaString=t,s.localStoragePurposeConsent=!0),null!=r&&r.gppString&&(t=(e=Nt.getTcfData(null===(i=r.parsedSections)||void 0===i?void 0:i.tcfeuv2))?Nt.tcfDataHasLocalStorageGrant(e):void 0,i=e?Nt.tcfDataHasID5VendorConsented(e):void 0,(e=this._translateGppVersion(r.gppVersion))&&(s.apiTypes.push(e),s.gppData=new Ne(e,r.applicableSections,r.gppString),void 0===t&&void 0===i||(s.gppData.euTcfSection=new Re(t,i)))),s}_translateGppVersion(e){switch(e){case"1.0":return Te.GPP_V1_0;case"1.1":return Te.GPP_V1_1;default:return}}_configureDiagnostics(t,r,s,i,n){try{let e=new ge(Gt,this._version);if(e.addCommonTags(_(_({},ue(t)),{},{tml:null==s?void 0:s.topmostLocation,prebidVersion:n})),null==r||!r.publishingDisabled){const c=new ee(e,(o=r.publishingSampleRatio,Math.random()new Z(a,{sampling:o}).publish(e,t):e=>e));null!=r&&r.publishAfterLoadInMsec&&0