cdn.id5-sync.com Open in urlscan Pro
2606:4700:10::6816:3456  Public Scan

Submitted URL: http://cdn.id5-sync.com/api/1.0/esp.js
Effective URL: https://cdn.id5-sync.com/api/1.0/esp.js
Submission: On January 31 via api from US — Scanned from DE

Form analysis 0 forms found in the DOM

Text Content

/**
 * @id5io/id5-api.js
 * @version v1.0.57
 * @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 p(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?r(Object(i),!0).forEach(function(e){l(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}function c(e,t,i,r,s,n,o){try{var a=e[n](o),c=a.value}catch(e){return void i(e)}a.done?t(c):Promise.resolve(c).then(r,s)}function t(a){return function(){var e=this,o=arguments;return new Promise(function(t,i){var r=a.apply(e,o);function s(e){c(r,t,i,s,n,"next",e)}function n(e){c(r,t,i,s,n,"throw",e)}s(void 0)})}}function l(e,t,i){return(t=function(e){e=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0===i)return("string"===t?String:Number)(e);t=i.call(e,t||"default");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string");return"symbol"==typeof e?e:String(e)}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function d(){return(d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i,r=arguments[t];for(i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e}).apply(this,arguments)}function i(e,t){if(null==e)return{};var i,r=function(e,t){if(null==e)return{};for(var i,r={},s=Object.keys(e),n=0;n<s.length;n++)i=s[n],0<=t.indexOf(i)||(r[i]=e[i]);return r}(e,t);if(Object.getOwnPropertySymbols)for(var s=Object.getOwnPropertySymbols(e),n=0;n<s.length;n++)i=s[n],0<=t.indexOf(i)||Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i]);return r}function h(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r,s,n,o,a=[],c=!0,l=!1;try{if(n=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;c=!1}else for(;!(c=(r=n.call(i)).done)&&(a.push(r.value),a.length!==t);c=!0);}catch(e){l=!0,s=e}finally{try{if(!c&&null!=i.return&&(o=i.return(),Object(o)!==o))return}finally{if(l)throw s}}return a}}(e,t)||a(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){if(e){if("string"==typeof e)return s(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(i="Object"===i&&e.constructor?e.constructor.name:i)||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?s(e,t):void 0}}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);i<t;i++)r[i]=e[i];return r}function u(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=a(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var r=0,t=function(){};return{s:t,n:function(){return r>=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}}}}class e{debug(){}info(){}warn(){}error(){}}const g=new e;class _ extends e{constructor(e,t){super(),this._prefix=e,this._delegate=t}debug(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this._delegate.debug(this._prefix,...t)}info(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this._delegate.info(this._prefix,...t)}warn(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this._delegate.warn(this._prefix,...t)}error(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this._delegate.error(this._prefix,...t)}}const n="*",o=void 0;class v{constructor(e,t,i,r,s,n){var o=6<arguments.length&&void 0!==arguments[6]?arguments[6]:void 0;l(this,"_isId5Message",!0),l(this,"id",void 0),l(this,"timestamp",void 0),l(this,"type",void 0),l(this,"src",void 0),l(this,"dst",void 0),l(this,"request",void 0),l(this,"payload",void 0),this.id=r,this.timestamp=e,this.src=t,this.dst=i,this.type=n,this.request=o,this.payload=s}}class f{constructor(e){l(this,"_senderId",void 0),l(this,"_messageSeqNb",0),this._senderId=e,this._messageSeqNb=0}createBroadcastMessage(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:e.constructor.name;return new v(Date.now(),this._senderId,o,++this._messageSeqNb,e,t||e.constructor.name)}createResponse(e,t){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:t.constructor.name;return new v(Date.now(),this._senderId,e.src,++this._messageSeqNb,t,i||t.constructor.name,e)}createUnicastMessage(e,t){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:t.constructor.name;return new v(Date.now(),this._senderId,e,++this._messageSeqNb,t,i||t.constructor.name)}}class m{constructor(e){var t=1<arguments.length&&void 0!==arguments[1]&&arguments[1],i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:void 0;l(this,"instance",void 0),l(this,"instanceState",void 0),l(this,"isResponse",void 0),this.instance=e,this.instanceState=i,this.isResponse=t}}l(m,"TYPE","HelloMessage");const C=Object.freeze({LEADER:"leader",FOLLOWER:"follower",STORAGE:"storage"});class I{constructor(e,t,i){l(this,"target",void 0),l(this,"methodName",void 0),l(this,"methodArguments",void 0),this.target=e,this.methodName=t,this.methodArguments=i}}l(I,"TYPE","RemoteMethodCallMessage");class y{constructor(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:g;l(this,"_targets",{}),l(this,"_log",void 0),this._log=e}registerTarget(e,t){return this._targets[e]=t,this}_handle(t){const e=this._targets[t.target];if(e)try{e[t.methodName](...t.methodArguments)}catch(e){this._log.error("Error while handling method call ",t,e)}}}class w{constructor(e,t){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:g;l(this,"_id",void 0),l(this,"_messageFactory",void 0),l(this,"_log",void 0),l(this,"_onMessageCallBackFunction",void 0),this._id=e,this._messageFactory=new f(this._id),this._log=i,this._window=t,this._handlers={},this._register()}_register(){const s=this;s._abortController="undefined"!=typeof AbortController?new AbortController:void 0;var e=null===(e=s._abortController)||void 0===e?void 0:e.signal;s._window.addEventListener("message",i=>{let r=i.data;if(void 0!==i.data&&i.data._isId5Message)if(i.data.src!==s._id)if(void 0===i.data.dst||i.data.dst===s._id)try{[n,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)}else s._log.debug("Ignore msg not to me");else s._log.debug("Ignore loopback msg")},{capture:!1,signal:e})}deregister(){this._abortController&&this._abortController.abort()}onAnyMessage(e){return this.onMessage(n,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=2<arguments.length&&void 0!==arguments[2]?arguments[2]:t.constructor.name;this._log.debug("Sending response message",e,i,t),this._postMessage(this._messageFactory.createResponse(e,t,i))}unicastMessage(e,t){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:t.constructor.name;this._log.debug("Sending message to",e,i,t),this._postMessage(this._messageFactory.createUnicastMessage(e,t,i))}_postToWindow(e,t){try{e.postMessage(t,"*")}catch(e){this._log.error("Could not post message to window",e)}}_postMessage(r){let s=this;(function t(e){try{s._postToWindow(e,r);var i=e.frames;if(i)for(let e=0;e<i.length;e++)t(i[e])}catch(e){s._log.error("Could not broadcast message",e)}})(s._window.top)}callProxyMethod(e,t,i,r){this._log.info("Calling ProxyMethodCall",{target:t,name:i,args:r}),this.unicastMessage(e,new I(t,i,r),I.TYPE)}onProxyMethodCall(t){return this.onMessage(I.TYPE,e=>{t._handle(d(new I,e.payload))})}}function b(e,t){var i="^\\d+(\\.\\d+(\\.\\d+){0,1}){0,1}$";if(e.match(i)&&t.match(i)){var r=e.split("."),s=t.split("."),i=e=>parseInt(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 S="Array",D="String",E="Function",O="Object",T=Object.prototype.toString;function P(e,t){return T.call(e)==="[object "+t+"]"}function A(e){return P(e,E)}function R(e){return P(e,D)}function x(e){return P(e,S)}function N(e){return P(e,"Number")}function U(e){return P(e,O)}function L(e){return void 0!==e}function F(t,i){if(!function(e){if(!e)return 1;if(x(e)||R(e))return!(0<e.length);for(var t in e)if(hasOwnProperty.call(e,t))return;return 1}(t)){if(A(t.forEach))return t.forEach(i,this);let e=0;var r=t.length;if(0<r)for(;e<r;e++)i(t[e],e,t);else for(e in t)hasOwnProperty.call(t,e)&&i.call(this,t[e],e)}}function k(e,t){let i=document.createElement("a");t&&"noDecodeWholeURL"in t&&t.noDecodeWholeURL?i.href=e:i.href=decodeURIComponent(e);t=t&&"decodeSearchAsString"in t&&t.decodeSearchAsString;return{href:i.href,protocol:(i.protocol||"").replace(/:$/,""),hostname:i.hostname,port:+i.port,pathname:i.pathname.replace(/^(?!\/)/,"/"),search:t?i.search:(t=i.search||"")?t.replace(/^\?/,"").split("&").reduce((e,t)=>{let i=t.split("="),r=h(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 j(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 M(r,s,n,o,e){o=3<arguments.length&&void 0!==o?o:{};let a=4<arguments.length&&void 0!==e?e:g;try{let i;var c,l=o.method||(n?"POST":"GET");let e=document.createElement("a");e.href=r;let t="object"==typeof s&&null!==s?s:{success:function(){a.info("ajax","xhr success")},error:function(e){a.error("ajax","xhr error",null,e)}};"function"==typeof s&&(t.success=s),i=new window.XMLHttpRequest,i.onreadystatechange=function(){var e;4===i.readyState&&(200<=(e=i.status)&&e<300||304===e?t.success(i.responseText,i):t.error(i.statusText,i))},i.ontimeout=function(){a.error("ajax","xhr timeout after ",i.timeout,"ms")},"GET"===l&&n&&(d((c=k(r,o)).search,n),r=j(c)),i.open(l,r,!0),o.withCredentials&&(i.withCredentials=!0),F(o.customHeaders,(e,t)=>{i.setRequestHeader(t,e)}),o.preflight&&i.setRequestHeader("X-Requested-With","XMLHttpRequest"),i.setRequestHeader("Content-Type",o.contentType||"text/plain"),"POST"===l&&n?i.send(n):i.send()}catch(e){a.error("ajax","xhr construction",e)}}function V(i,e){function r(e,t){if(A(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<arguments.length&&void 0!==e?e:0;let s=3735928559^e,n=1103547991^e;for(let e=0,t;e<i.length;e++)t=i.charCodeAt(e),s=r(s^t,2654435761),n=r(n^t,1597334677);return s=r(s^s>>>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 G=["localStoragePurposeConsent","ccpaString"],W=Object.freeze({NONE:"none",TCF_V1:"TCFv1",TCF_V2:"TCFv2",USP_V1:"USPv1",ID5_ALLOWED_VENDORS:"ID5",PREBID:"PBJS",GPP_V1_0:"GPPv1.0",GPP_V1_1:"GPPv1.1"});class q extends Error{constructor(e,t){super(t),l(this,"consentData",void 0),this.consentData=e}}class B{constructor(e,t,i,r){l(this,"version",void 0),l(this,"localStoragePurposeConsent",void 0),l(this,"applicableSections",void 0),l(this,"gppString",void 0),this.version=e,this.localStoragePurposeConsent=t,this.applicableSections=i,this.gppString=r}isGranted(){return this.applicableSections.includes(2)?this.localStoragePurposeConsent:!!this.applicableSections.includes(6)||!(!this.applicableSections.includes(0)&&!this.applicableSections.includes(-1)&&0!==this.applicableSections.length)&&(void 0===this.localStoragePurposeConsent||this.localStoragePurposeConsent)}}class H{constructor(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:W.NONE,t=1<arguments.length&&void 0!==arguments[1]&&arguments[1],i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:void 0,r=3<arguments.length&&void 0!==arguments[3]&&arguments[3],s=4<arguments.length&&void 0!==arguments[4]?arguments[4]:void 0,n=5<arguments.length&&void 0!==arguments[5]?arguments[5]:void 0,o=6<arguments.length&&void 0!==arguments[6]&&arguments[6],a=7<arguments.length&&void 0!==arguments[7]?arguments[7]:void 0;l(this,"api",void 0),l(this,"gdprApplies",void 0),l(this,"consentString",void 0),l(this,"localStoragePurposeConsent",void 0),l(this,"allowedVendors",void 0),l(this,"ccpaString",void 0),l(this,"forcedGrantByConfig",void 0),l(this,"gppData",void 0),this.api=e,this.gdprApplies=t,this.consentString=i,this.localStoragePurposeConsent=r,this.ccpaString=s,this.allowedVendors=n,this.forcedGrantByConfig=o,this.gppData=a}localStorageGrant(){var e=!0===this.forcedGrantByConfig?J.FORCE_ALLOWED_BY_CONFIG:void 0===this.api||this.api===W.NONE?J.PROVISIONAL:J.CONSENT_API;return new K(this.isGranted(),e,this.api)}isGranted(){switch(this.api){case W.NONE:return!0;case W.TCF_V1:return!this.gdprApplies||!0===this.localStoragePurposeConsent;case W.TCF_V2:case W.PREBID:return!1===this.gdprApplies||!0===this.localStoragePurposeConsent;case W.ID5_ALLOWED_VENDORS:return this.allowedVendors.includes("131");case W.USP_V1:return!0;case W.GPP_V1_0:case W.GPP_V1_1:return this.gppData.isGranted()}}hashCode(){this.localStoragePurposeConsent,this.ccpaString;var e=i(this,G);return V(JSON.stringify(e))}}const J=Object.freeze({FORCE_ALLOWED_BY_CONFIG:"force_allowed_by_config",ID5_CONSENT:"id5_consent",PROVISIONAL:"provisional",JURISDICTION:"jurisdiction",CONSENT_API:"consent_api"});class K{constructor(e,t,i){l(this,"allowed",!1),l(this,"grantType",J.NONE),l(this,"api",W.NONE),this.allowed=e,this.grantType=t,this.api=i}isDefinitivelyAllowed(){return this.allowed&&this.grantType!==J.PROVISIONAL}}var Y=Object.freeze({STORAGE_CONFIG:{ID5:{name:"id5id",expiresDays:90},ID5_V2:{name:"id5id_v2",expiresDays:15},LAST:{name:"id5id_last",expiresDays:90},CONSENT_DATA:{name:"id5id_cached_consent_data",expiresDays:30},PRIVACY:{name:"id5id_privacy",expiresDays:30}},LEGACY_COOKIE_NAMES:["id5.1st","id5id.1st"],PRIVACY:{JURISDICTIONS:{gdpr:!0,ccpa:!1,lgpd:!0,other:!1}},ID5_EIDS_SOURCE:"id5-sync.com"});class z{constructor(e,t){this.name=e,this.expiresDays=t}withNameSuffixed(){let e=this.name;for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];for(var s=0,n=i;s<n.length;s++){var o=n[s];e+="_".concat(o)}return new z(e,this.expiresDays)}}class X{constructor(){let i=0<arguments.length&&void 0!==arguments[0]?arguments[0]:void 0;function e(e){var t=void 0!==i?Math.max(1,i):e.expiresDays;return new z(e.name,t)}var t=Y.STORAGE_CONFIG;this.ID5=e(t.ID5),this.ID5_V2=e(t.ID5_V2),this.LAST=e(t.LAST),this.CONSENT_DATA=e(t.CONSENT_DATA),this.PRIVACY=e(t.PRIVACY)}}l(X,"DEFAULT",new X);class Q{constructor(e){l(this,"_clientStore",void 0),this._clientStore=e}hasConsentChanged(e){return e&&!this._clientStore.storedConsentDataMatchesConsentData(e)}storeConsent(e){this._clientStore.putHashedConsentData(e)}incNb(e){this._clientStore.incNbV2(e,1<arguments.length&&void 0!==arguments[1]?arguments[1]:1)}updateNbs(e){var t,i=u(e);try{for(i.s();!(t=i.n()).done;){var r=h(t.value,2),s=r[0],n=r[1],o=null==n?void 0:n.nb;0<o&&this.incNb(s,-o)}}catch(e){i.e(e)}finally{i.f()}}storeResponse(e,i){this._clientStore.putResponseV1(i.getGenericResponse()),this._clientStore.setResponseDateTimeV1(new Date(i.timestamp).toUTCString());const r=new Set;e.forEach(e=>{var t=e.cacheId;r.has(t)||(e=i.getResponseFor(e.integrationId))&&(this._clientStore.storeResponseV2(t,e,i.timestamp),r.add(t))})}clearAll(e){this._clientStore.clearResponse(),this._clientStore.clearDateTime(),e.forEach(e=>{e=e.cacheId;this._clientStore.clearResponseV2(e)}),this._clientStore.clearHashedConsentData()}getCachedResponse(e){e=this._clientStore.getStoredResponseV2(e);if(e)return new $(e.response,e.responseTimestamp,e.nb)}}class ${constructor(e,t){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;l(this,"response",void 0),l(this,"timestamp",void 0),l(this,"nb",void 0),this.response=e,this.timestamp=t,this.nb=i}isExpired(){var e=this.getMaxAge();return!(N(e)&&0<e)||this._isOlderThanSec(e)}_isOlderThanSec(e){return this.timestamp<=0||Date.now()-this.timestamp>1e3*e}isStale(){return!this.timestamp||this._isOlderThanSec(1209600)}isResponseComplete(){return U(this.response)&&R(this.response.universal_uid)&&R(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}}class Z{constructor(){var e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],t=1<arguments.length&&void 0!==arguments[1]&&arguments[1];l(this,"lateJoiner",!1),l(this,"uniqueLateJoiner",!1),this.lateJoiner=e,this.uniqueLateJoiner=t}}class ee{updateConsent(){}updateFetchIdData(){}refreshUid(){}addFollower(){}getProperties(){}}class te extends ee{constructor(e,t,i,r,s,n){var o=6<arguments.length&&void 0!==arguments[6]?arguments[6]:g,a=7<arguments.length?arguments[7]:void 0;super(),l(this,"_followers",void 0),l(this,"_followersRequests",{}),l(this,"_refreshRequired",{}),l(this,"_fetcher",void 0),l(this,"_log",void 0),l(this,"_consentManager",void 0),l(this,"_cachedResponse",void 0),l(this,"_inProgressFetch",void 0),l(this,"_queuedRefreshOptions",void 0),l(this,"_lastConsentDataSet",void 0),l(this,"_metrics",void 0),l(this,"_leaderStorage",void 0),l(this,"_store",void 0),this._followers=[],this._fetcher=a,this._properties=t,this._consentManager=s,this._metrics=n,this._window=e,this._leaderStorage=i,this._log=o,this._store=r,this._firstFetchTriggered=!1}_handleRefreshResult(e,t){const i=t.refreshedResponse;if(void 0!==i){var r,s=u(e);try{for(s.s();!(r=s.n()).done;){var n=r.value.integrationId;this._followersRequests[n]=(this._followersRequests[n]||0)+1}}catch(e){s.e(e)}finally{s.f()}const l=[];var o,a=u(this._followers);try{for(a.s();!(o=a.n()).done;){const d=o.value;var c=i.getResponseFor(d.getId());void 0!==c&&(this._log.debug("Notify uid ready.","Follower:",d.getId(),"Uid:",c),this._refreshRequired[d.getId()]=!1,this._notifyUidReady(d,{timestamp:i.timestamp,responseObj:c,isFromCache:!1}),!0===c.cascade_needed&&l.push(d.getId()))}}catch(e){a.e(e)}finally{a.f()}t=t.consentData;void 0!==t&&0<l.length&&this._consentManager.localStorageGrant().isDefinitivelyAllowed()&&this._handleCascade(l,i,t)}}_notifyUidReady(e,t){var i=2<arguments.length&&void 0!==arguments[2]&&arguments[2],i={timestamp:Date.now(),tags:{lateJoiner:i,callType:e.callType}};e.notifyUidReady(t,i)}_handleCascade(e,t,i){var r,s=this._followers.filter(t=>void 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<s.length){const n=s[0];n.notifyCascadeNeeded({partnerId:n.getFetchIdData().partnerId,userId:t.getResponseFor(n.getId()).universal_uid,gdprApplies:i.gdprApplies,consentString:i.consentString,gppString:null===(t=i.gppData)||void 0===t?void 0:t.gppString,gppSid:null===(i=i.gppData)||void 0===i||null===(r=i.applicableSections)||void 0===r?void 0:r.join(",")})}else this._log.error("Couldn't find cascade eligible follower")}_handleCancel(e){var t,i=u(this._followers);try{for(i.s();!(t=i.n()).done;){const r=t.value;r.notifyFetchUidCanceled({reason:e})}}catch(e){i.e(e)}finally{i.f()}}_getId(){let s=0<arguments.length&&void 0!==arguments[0]&&arguments[0];const t=this._followers.map(e=>{var t=e.getId(),i=(this._followersRequests[t]||0)+1,r=this._properties.id;return s=s||!0===this._refreshRequired[e.getId()],p(p({},e.getFetchIdData()),{},{integrationId:t,requestCount:i,role:r===e.getId()?"leader":"follower",cacheId:e.getCacheId()})});this._inProgressFetch=!0,this._firstFetchTriggered=!0,this._fetcher.getId(t,s).then(e=>{this._handleRefreshResult(t,e),this._handleFetchCompleted()}).catch(e=>{e instanceof q?this._handleCancel(e.message):this._handleFailed(e),this._handleFetchCompleted()})}start(){!0!==this._started&&(this._getId(!1),this._started=!0)}refreshUid(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};this._inProgressFetch?this._queuedRefreshOptions=e:(!0===e.resetConsent&&this._consentManager.resetConsentData(!0===e.forceAllowLocalStorageGrant),this._getId(!0===e.forceFetch))}updateConsent(e){var t,i,r=this._lastConsentDataSet;r&&(t=(null==e?void 0:e.api)!==r.api,i=(null==e?void 0:e.consentString)!==r.consentString,r=(null==e?void 0:e.ccpaString)!==r.ccpaString,(t||i||r)&&this._metrics.consentChangeCounter({apiChanged:t,consentStringChanged:i,usPrivacyChanged:r}).inc()),this._consentManager.setConsentData(e),this._lastConsentDataSet=e}updateFetchIdData(t,e){const i=this._followers.find(e=>e.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(e){const t=this._log;this._followers.push(e),t.info("Added follower",e.getId(),"cacheId",e.getCacheId()),this._window!==e.getWindow()&&(i=e.getStorage(),t.info("Adding follower's",e.getId(),"storage as replica"),this._leaderStorage.addReplica(i));var i=e.getCacheId();const r=this._store.getCachedResponse(i);void 0!==r&&r.isValid()?(t.info("Found valid cached response for follower",{id:e.getId(),cacheId:e.getCacheId()}),this._notifyUidReady(e,{timestamp:r.timestamp,responseObj:r.response,isFromCache:!0}),this._store.incNb(i)):t.info("Couldn't find response for cacheId",e.getCacheId());i=!r||!r.isValid()||r.isExpired();this._refreshRequired[e.getId()]=i;let s=new Z;return!0===this._firstFetchTriggered&&(s.lateJoiner=!0,s.uniqueLateJoiner=!r,i&&this.refreshUid({forceFetch:!0})),s}getProperties(){return this._properties}_handleFetchCompleted(){this._inProgressFetch=void 0,this._queuedRefreshOptions&&(this.refreshUid(this._queuedRefreshOptions),this._queuedRefreshOptions=void 0)}_handleFailed(e){this._log.error("Fetch id failed",e);var t,i=u(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 ie extends ee{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,C.LEADER,e,t)}updateConsent(e){this._sendToLeader("updateConsent",[e])}refreshUid(e){this._sendToLeader("refreshUid",[e])}updateFetchIdData(e,t){this._sendToLeader("updateFetchIdData",[e,t])}getProperties(){return this._leaderInstanceProperties}}class re extends ee{constructor(){super(...arguments),l(this,"_callsQueue",[]),l(this,"_assignedLeader",void 0)}updateConsent(e){this._callOrBuffer("updateConsent",[e])}updateFetchIdData(e,t){this._callOrBuffer("updateFetchIdData",[e,t])}refreshUid(e){this._callOrBuffer("refreshUid",[e])}addFollower(e){return this._callOrBuffer("addFollower",[e])}getProperties(){if(this._assignedLeader)return this._assignedLeader.getProperties()}assignLeader(e){this._assignedLeader=e;var t,i=u(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)}}const se=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"}),ne=Object.freeze({ID5_MESSAGE_RECEIVED:"message",ID5_INSTANCE_JOINED:"instance-joined",ID5_LEADER_ELECTED:"leader-elected"}),oe=Object.freeze([...Object.values(ne),...Object.values(se)]);class ae{constructor(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:g;l(this,"_handlers",void 0),l(this,"_log",void 0),this._log=e,this._handlers={}}_dispatch(t){var e=this._handlers[t];if(e){for(var i=arguments.length,r=new Array(1<i?i-1:0),s=1;s<i;s++)r[s-1]=arguments[s];var n,o=u(e);try{for(o.s();!(n=o.n()).done;){const a=n.value;try{a(...r)}catch(e){this._log.error("Event ".concat(t," handler execution failed."),e)}}}catch(e){o.e(e)}finally{o.f()}}}emit(e){if(void 0!==e&&oe.includes(e)){for(var t=arguments.length,i=new Array(1<t?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];this._dispatch(e,...i)}else this._log.warn("Unsupported event",e)}on(e,t){void 0!==e&&oe.includes(e)?(this._handlers[e]||(this._handlers[e]=[]),this._handlers[e].push(t)):this._log.warn("Unsupported event",e)}}const ce="_exp";class le{constructor(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:g;l(this,"storage",void 0),l(this,"_log",void 0),this.storage=e,this._log=t}getItem(e){try{return this.storage.getItem(e)}catch(e){}}setItem(e,t){try{this.storage.setItem(e,t)}catch(e){}}removeItem(e){try{this.storage.removeItem(e)}catch(e){}}removeExpiredObjectWithPrefix(t){var i=1<arguments.length&&void 0!==arguments[1]&&arguments[1];this._log.info("Check, prefix",t);try{var r=this.storage.getKeysWithPrefix(t);let e=0;var s,n=u(r);try{for(n.s();!(s=n.n()).done;){var o,a,c=s.value;i?(this._log.info("Found",c," remove it"),this.removeItem(c)):(a=null==(o=this.getObjectWithExpiration({name:c}))?void 0:o.expireAt)&&a<Date.now()&&(this._log.info("Found expired object",c,"expiration time",a,"It will be removed"),this.removeItem(c),e+=1)}}catch(e){n.e(e)}finally{n.f()}return{all:r.length,expired:e}}catch(e){}}getItemWithExpiration(e){var t=e.name,e=this.getItem(t+ce);return!e||new Date(e).getTime()-Date.now()<=0?(this.removeItemWithExpiration({name:t}),null):this.getItem(t)}setItemWithExpiration(e,t){var i=e.name,e=e.expiresDays,e=Date.now()+864e5*e,e=new Date(e).toUTCString();this.setItem(i+ce,e),this.setItem(i,t)}removeItemWithExpiration(e){e=e.name;this.removeItem(e),this.removeItem(e+ce)}setObjectWithExpiration(e,t){var i=e.name,e=e.expiresDays,e=Date.now()+864e5*e;this.setItem(i,JSON.stringify({data:t,expireAt:e}))}getObjectWithExpiration(t){t=t.name;try{var e=JSON.parse(this.getItem(t));if(e.expireAt&&0<e.expireAt-Date.now())return e.data;e.expireAt&&this.removeItem(t)}catch(e){this._log.error("Error while getting ",t,"object from storage",e)}}updateObjectWithExpiration(e,t){var i=e.name,e=e.expiresDays;try{var r=t(this.getObjectWithExpiration({name:i}));return this.setObjectWithExpiration({name:i,expiresDays:e},r),r}catch(e){this._log.error("Error while updating object with ",i,e)}}}class de{getItem(){}removeItem(){}setItem(){}getKeysWithPrefix(){return[]}}const he=new de;class ue extends de{constructor(e){var t=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];super(),l(this,"_writingEnabled",void 0),l(this,"_underlying",void 0),this._writingEnabled=t;try{this._underlying=e.localStorage}catch(e){}}getItem(e){try{return this._underlying.getItem(e)}catch(e){}}removeItem(e){try{this._underlying.removeItem(e)}catch(e){}}setItem(e,t){try{this._writingEnabled&&this._underlying.setItem(e,t)}catch(e){}}getKeysWithPrefix(t){try{var i=this._underlying.length;if(this._writingEnabled){const r=[];for(let e=0;e<i;e++){const s=this._underlying.key(e);s&&s.startsWith(t)&&r.push(s)}return r}}catch(e){}}static checkIfAccessible(){var e="__id5test";try{return window.localStorage.setItem(e,e),window.localStorage.removeItem(e),!0}catch(e){return!1}}}class ge{constructor(e){l(this,"_replicas",[]),l(this,"_lastKeyOperation",{}),l(this,"_primaryStorage",void 0),this._primaryStorage=e}getItem(e){return this._primaryStorage.getItem(e)}removeItem(t){this._primaryStorage.removeItem(t);var e=e=>{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)}}const pe=Object.freeze({DIRECT_METHOD:"direct_method",POST_MESSAGE:"post_message"});class _e{constructor(e,t,i){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:g;l(this,"_instanceProperties",void 0),l(this,"_log",void 0),l(this,"callType",void 0),l(this,"_instanceWindow",void 0),this._instanceWindow=t,this._instanceProperties=i,this._log=r,this.callType=e}getId(){return this._instanceProperties.id}getFetchIdData(){return this._instanceProperties.fetchIdData}updateFetchIdData(e){d(this._instanceProperties.fetchIdData,e)}getCacheId(){var e=this._instanceProperties.fetchIdData,e={partnerId:e.partnerId,att:e.att,pd:e.pd,provider:e.provider,abTesting:e.abTesting,segments:JSON.stringify(e.segments),providedRefresh:e.providedRefreshInSeconds};return V(JSON.stringify(e))}notifyUidReady(){}notifyFetchUidCanceled(){}notifyCascadeNeeded(){}canDoCascade(){return!0===this._instanceProperties.canDoCascade}getStorage(){return he}getWindow(){return this._instanceWindow}}class ve extends _e{constructor(e,t,i){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:g;super(pe.DIRECT_METHOD,e,t,r),l(this,"_dispatcher",void 0),this._dispatcher=i}notifyUidReady(e,t){this._dispatcher.emit(se.USER_ID_READY,e,t)}notifyFetchUidCanceled(e){this._dispatcher.emit(se.USER_ID_FETCH_CANCELED,e)}notifyCascadeNeeded(e){this._dispatcher.emit(se.CASCADE_NEEDED,e)}}class fe extends de{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,C.STORAGE,e,t)}}class me extends _e{constructor(e,t){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:g;super(pe.POST_MESSAGE,e.getWindow(),e.properties,i),l(this,"_messenger",void 0),this._messenger=t}_callProxy(e,t){this._messenger.callProxyMethod(this.getId(),C.FOLLOWER,e,t)}notifyUidReady(e,t){this._callProxy("notifyUidReady",[e,t])}notifyFetchUidCanceled(e){this._callProxy("notifyFetchUidCanceled",[e])}notifyCascadeNeeded(e){this._callProxy("notifyCascadeNeeded",[e])}getStorage(){return new fe(this._messenger,this.getId())}}class Ce{constructor(){l(this,"_valuePromise",void 0),l(this,"_value",void 0),l(this,"_resolve",void 0),this.reset()}reset(){const t=this;t._value=void 0,t._valuePromise=new Promise(e=>{t._resolve=e})}set(e){this._value=e,this._resolve(this._value)}getValuePromise(){return this._valuePromise}hasValue(){return L(this._value)}getValue(){return this._value}}class Ie extends class{getConsentData(){}localStorageGrant(){}setStoredPrivacy(){}}{constructor(e,t,i,r){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 Ce,this._forceAllowLocalStorageGrant=i}resetConsentData(e){this._consentDataHolder.reset(),this.storedPrivacyData=void 0,this._forceAllowLocalStorageGrant=e}localStorageGrant(){const e=this._log;if(!0===this._forceAllowLocalStorageGrant)return e.warn("cmpApi: Local storage access granted by configuration override, consent will not be checked"),new K(!0,J.FORCE_ALLOWED_BY_CONFIG,W.NONE);if(this._consentDataHolder.hasValue()&&this._consentDataHolder.getValue().api!==W.NONE)return this._consentDataHolder.getValue().localStorageGrant();if(U(this.storedPrivacyData)||(t=this.localStorage.getItemWithExpiration(this.storageConfig.PRIVACY),this.storedPrivacyData=t&&JSON.parse(t),e.info("cmpApi: Loaded stored privacy data from local storage",this.storedPrivacyData)),this.storedPrivacyData&&!0===this.storedPrivacyData.id5_consent)return new K(!0,J.ID5_CONSENT,W.NONE);if(!this.storedPrivacyData||!L(this.storedPrivacyData.jurisdiction))return new K(!0,J.PROVISIONAL,W.NONE);var t=this.storedPrivacyData.jurisdiction,t=t in Y.PRIVACY.JURISDICTIONS&&Y.PRIVACY.JURISDICTIONS[t];return new K(!1===t,J.JURISDICTION,W.NONE)}setStoredPrivacy(e){const t=this._log;try{U(e)?(this.storedPrivacyData=e,this.localStorage.setItemWithExpiration(this.storageConfig.PRIVACY,JSON.stringify(e))):t.error("cmpApi: Cannot store privacy data if it is not an object",e)}catch(e){t.error("cmpApi: Error while storing privacy data",e)}}setConsentData(e){this._log.debug("Set consent data",e);e=d(new H,e);this._consentDataHolder.set(e)}getConsentData(){return this._consentDataHolder.getValuePromise()}}const ye="undefined"!=typeof Promise&&"undefined"!=typeof fetch;class we{constructor(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:void 0;this.url=e||"https://diagnostics.id5-sync.com/measurements",this._metadata=t}publish(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:void 0;return e&&0<e.length?(e.forEach(e=>function(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:p(p({},this._metadata),t),measurements:e})})):Promise.resolve()}}const be=Object.freeze({});var Se,De={EMPTY:be,from:function(e){return e?e instanceof Map?Object.fromEntries(e):e:be},toString:function(e){return Array.from(Object.entries(e),e=>{var t=h(e,2),e=t[0],t=t[1];return"".concat(e,"=").concat(t)}).sort().toString()}};const Ee=Object.freeze({TIMER:"TIMER",SUMMARY:"SUMMARY",COUNTER:"COUNTER"});class Oe{constructor(e,t,i){l(this,"name",void 0),l(this,"tags",void 0),l(this,"values",void 0),this.name=e,this.tags=De.from(t),this.type=i,this.values=[]}reset(){this.values=[]}}class Te extends Oe{constructor(e){super(e,1<arguments.length&&void 0!==arguments[1]?arguments[1]:void 0,Ee.TIMER)}startMeasurement(){try{return new Pe(this)}catch(e){return}}record(e){try{isNaN(e)||this.values.push({value:e,timestamp:Date.now()})}catch(e){}}recordNow(){try{var e;this.record(0|(null===(e=performance)||void 0===e?void 0:e.now()))}catch(e){}}}class Pe{constructor(){this.timer=0<arguments.length&&void 0!==arguments[0]?arguments[0]:void 0,this.startTime=performance.now()}record(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:void 0;try{var i=performance.now()-this.startTime|0;let e=t||this.timer;return e&&e.record(i),i}catch(e){return}}}class Ae extends Oe{constructor(e){super(e,1<arguments.length&&void 0!==arguments[1]?arguments[1]:void 0,Ee.COUNTER)}inc(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1;try{return 0===this.values.length?this.values.push({value:e,timestamp:Date.now()}):(this.values[0].value+=e,this.values[0].timestamp=Date.now()),this.values[0].value}catch(e){}}}class Re extends Oe{constructor(e){super(e,1<arguments.length&&void 0!==arguments[1]?arguments[1]:void 0,Ee.SUMMARY)}record(e){try{this.values.push({value:e,timestamp:Date.now()})}catch(e){}}}class xe{has(e){return void 0!==this[e]}set(e,t){return this[e]=t,this}get(e){return this[e]}values(){return Object.entries(this).map(e=>{return h(e,2)[1]})}}function Ne(){return new Pe}function Ue(e){return{partner:e}}class Le extends class{constructor(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:void 0,t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:void 0;l(this,"_registry",void 0),l(this,"commonTags",void 0),l(this,"_scheduled",void 0),this._registry=new xe,this.commonTags=De.from(e),this.commonPrefix=t}getOrCreate(e,t,i){var r=p(p({},t),this.commonTags),t=this.commonPrefix?this.commonPrefix+"."+e:e,e="".concat(t,"[").concat(De.toString(r),"]");return this._registry.has(e)||this._registry.set(e,i(t,r)),this._registry.get(e)}getAllMeasurements(){return this._registry.values().map(e=>({name:e.name,type:e.type,tags:e.tags,values:e.values})).filter(function(e){return e.values&&0<e.values.length})}reset(){Array.from(this._registry.values()).forEach(e=>e.reset())}addCommonTags(e){this.commonTags=p(p({},this.commonTags),De.from(e))}timer(e){return this.getOrCreate(e,1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},(e,t)=>new Te(e,t))}counter(e){return this.getOrCreate(e,1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},(e,t)=>new Ae(e,t))}summary(e){return this.getOrCreate(e,1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},(e,t)=>new Re(e,t))}publish(){let t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:e=>e,i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:void 0;return Promise.resolve(this.getAllMeasurements()).then(e=>t(e,i)).then(()=>this.reset())}schedulePublishAfterMsec(t,i){if(!this._scheduled){let e=this;setTimeout(()=>(e._scheduled=!1,e.publish(i,{trigger:"fixed-time",fixed_time_msec:t})),t),this._scheduled=!0}return this}schedulePublishBeforeUnload(e){let t=this;return addEventListener("beforeunload",()=>t.publish(e,{trigger:"beforeunload"})),this}}{constructor(e,t){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:void 0,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:void 0;super(p(p({source:e,version:t},Ue(i)),r),"id5.api")}loadDelayTimer(){return this.timer("instance.load.delay",0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}fetchCallTimer(e){return this.timer("fetch.call.time",p({status:e},1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}))}fetchFailureCallTimer(){return this.fetchCallTimer("fail",0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}fetchSuccessfulCallTimer(){return this.fetchCallTimer("success",0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}extensionsCallTimer(e,t){return this.timer("extensions.call.time",p({extensionType:e,status:t?"success":"fail"},2<arguments.length&&void 0!==arguments[2]?arguments[2]:{}))}consentRequestTimer(e){return this.timer("consent.request.time",p({requestType:e},1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}))}invocationCountSummary(){return this.summary("invocation.count",0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}instanceCounter(e){return this.counter("instance.count",p({instanceId:e},1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}))}instanceUniqueDomainsCounter(e){return this.counter("instance.domains.count",p({instanceId:e},1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}))}instanceUniqWindowsCounter(e){return this.counter("instance.windows.count",p({instanceId:e},1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}))}instanceUniqPartnersCounter(e){return this.counter("instance.partners.count",p({instanceId:e},1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}))}instanceJoinDelayTimer(){return this.timer("instance.join.delay.time",0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}instanceLateJoinCounter(e){return this.counter("instance.lateJoin.count",p({instanceId:e},1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}))}instanceLateJoinDelayTimer(){return this.timer("instance.lateJoin.delay",p({},0<arguments.length&&void 0!==arguments[0]?arguments[0]:{}))}instanceLastJoinDelayTimer(){return this.timer("instance.lastJoin.delay",p({},0<arguments.length&&void 0!==arguments[0]?arguments[0]:{}))}instanceMsgDeliveryTimer(){return this.timer("instance.message.delivery.time",0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}userIdProvisioningDelayTimer(e){return this.timer("userid.provisioning.delay",p({cachedResponseUsed:e},1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}))}userIdNotificationDeliveryDelayTimer(){return this.timer("userid.provisioning.delivery.delay",p({},0<arguments.length&&void 0!==arguments[0]?arguments[0]:{}))}consentChangeCounter(){return this.counter("leader.consent.change.count",0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}storageAllKeysCounter(){return this.summary("storage.keys.all.count",0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}storageExpiredKeysCounter(){return this.summary("storage.keys.expired.count",0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}}class Fe{constructor(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:Date.now();l(this,"timestamp",void 0),l(this,"response",void 0),this.response=e,this.timestamp=t}getGenericResponse(){return this.response.generic}getResponseFor(e){if(this.response.responses[e])return p(p({},this.response.generic),this.response.responses[e])}}class ke{constructor(e,t,i){l(this,"_extensionsProvider",void 0),l(this,"_metrics",void 0),l(this,"_log",void 0),this._extensionsProvider=e,this._metrics=t,this._log=i}refreshUid(e,l,d,h){return this._extensionsProvider.gather(e).then(n=>{const s=e.map(e=>{const t=d.get(e.cacheId);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(l,e,i,r,s,n,h)}),o=this._log,a=this._metrics,c=this;return new Promise((t,i)=>{const r=Ne();var e="".concat("https://id5-sync.com").concat("/gm/v3");o.info("Fetching ID5 ID from:",e,s),M(e,{success:function(e){o.info("Success at fetch call:",e),r.record(null===a||void 0===a?void 0:a.fetchSuccessfulCallTimer());try{t(c._validateResponse(e))}catch(e){i(e)}},error:function(e){r.record(null===a||void 0===a?void 0:a.fetchFailureCallTimer()),i(e)}},JSON.stringify({requests:s}),{method:"POST",withCredentials:!0},o)})})}_validateResponse(e){if(!e||!R(e)||e.length<1)throw new Error('Empty fetch response from ID5 servers: "'.concat(e,'"'));var t=JSON.parse(e);if(!U(t.generic))throw new Error("Server response failed to validate: ".concat(e));return this._log.info("Valid json response from ID5 received",t),t}_createRequest(e,i,t,r,s,n,o){this._log.info("Create request data for",{fetchIdData:i,consentData:e,signature:t,nbValue:r,refreshInSecondUsed:s,extensions:n});var a=i.partnerId;const c={requestId:i.integrationId,requestCount:i.requestCount,role:i.role,cacheId:i.cacheId,partner:a,v:i.originVersion,o:i.origin,tml:null===(a=i.refererInfo)||void 0===a?void 0:a.topmostLocation,ref:null===(a=i.refererInfo)||void 0===a?void 0:a.ref,cu:null===(a=i.refererInfo)||void 0===a?void 0:a.canonicalUrl,u:(null===(a=i.refererInfo)||void 0===a?void 0:a.stack[0])||window.location.href,top:null!==(a=i.refererInfo)&&void 0!==a&&a.reachedTop?1:0,localStorage:!0===o?1:0,nbPage:r,id5cdn:i.isUsingCdn,ua:window.navigator.userAgent,att:i.att};r=e.gdprApplies;L(r)&&(c.gdpr=r?1:0);r=e.consentString;L(r)&&(c.gdpr_consent=r),L(e.allowedVendors)&&(c.allowed_vendors=e.allowedVendors),L(e.gppData)&&(c.gpp_string=e.gppData.gppString,c.gpp_sid=e.gppData.applicableSections.join(",")),L(t)&&(c.s=t);t=i.uaHints;L(t)&&(c.ua_hints=t),L(e.ccpaString)&&""!==e.ccpaString&&(c.us_privacy=e.ccpaString),function(e){var t=Object.keys(e);let i=t.length,r=new Array(i);for(;i--;)r[i]=[t[i],e[t[i]]];return r}({pd:"pd",partnerUserId:"puid",provider:"provider",segments:"segments"}).forEach(e=>{var t=h(e,2),e=t[0],t=t[1];L(i[e])&&(c[t]=i[e])});e=i.abTesting;e&&!0===e.enabled&&(c.ab_testing={enabled:!0,control_group_pct:e.controlGroupPct});e=i.invalidSegmentsCount;return e&&0<e&&(c._invalid_segments=e),i.trace&&(c._trace=!0),c.provided_options={refresh_in_seconds:i.providedRefreshInSeconds},c.used_refresh_in_seconds=s,c.extensions=n,c}}class je{constructor(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:void 0;l(this,"consentData",void 0),l(this,"refreshedResponse",void 0),this.consentData=e,this.refreshedResponse=t}}class Me{constructor(e,t,i,r,s){s=5<arguments.length&&void 0!==arguments[5]?arguments[5]:new ke(s,i,r);l(this,"_store",void 0),l(this,"_consentManager",void 0),l(this,"_uidRefresher",void 0),l(this,"_metrics",void 0),l(this,"_log",void 0),this._store=t,this._consentManager=e,this._metrics=i,this._log=r,this._uidRefresher=s}getId(o){let a=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];const c=this._log;c.info("UidFetcher: requested to get an id:",o);const l=this._store,d=this._consentManager,e=this._metrics;c.info("Waiting for consent");const h=e.timer("fetch.consent.wait.time");return d.getConsentData().then(t=>{c.info("Consent received",t),h&&h.recordNow();const e=d.localStorageGrant();if(c.info("Local storage grant",e),!e.allowed)throw c.info("No legal basis to use ID5",t),new q(t,"No legal basis to use ID5");var i=ue.checkIfAccessible(),r=l.hasConsentChanged(t);if(e.isDefinitivelyAllowed()&&l.storeConsent(t),r||a){c.info("Decided to fetch a fresh ID5 ID",{consentHasChanged:r,refreshRequired:a});const s=this._collectCacheData(o),n=this;return c.info("Fetching ID5 ID (forceFetch:".concat(a,")")),this._uidRefresher.refreshUid(o,t,s,i).then(e=>n._handleSuccessfulFetchResponse(e,o,t,s))}return c.info("Not decided to refresh ID5 ID",{consentHasChanged:r,refreshRequired:a}),new je(t,void 0)})}_handleSuccessfulFetchResponse(e,t,i,r){const s=this._log,n=this._consentManager,o=this._store;var a=new Fe(e);n.setStoredPrivacy(e.generic.privacy);const c=n.localStorageGrant();return c.isDefinitivelyAllowed()?(s.info("Storing ID and request hashes in cache"),o.updateNbs(r),o.storeResponse(t,a)):(s.info("Cannot use local storage to cache ID",c),o.clearAll(t)),new je(i,a)}_collectCacheData(e){const t=new Map;var i,r=u(e);try{for(r.s();!(i=r.n()).done;){var s,n=i.value.cacheId;t.has(n)||(s=this._store.getCachedResponse(n))&&t.set(n,s)}}catch(e){r.e(e)}finally{r.f()}return t}}class Ve{constructor(e,t,i,r){l(this,"localStorageGrantChecker",void 0),l(this,"localStorage",void 0),l(this,"_log",void 0),this.localStorageGrantChecker=e,this.localStorage=t,this.storageConfig=i,this._log=r}get(e){const t=this._log;try{const r=this.localStorageGrant();if(r.isDefinitivelyAllowed()){var i=this.localStorage.getItemWithExpiration(e);return t.info("Local storage get key=".concat(e.name," value=").concat(i)),i}t.warn("clientStore.get() has been called without definitive grant",r)}catch(e){t.error(e)}}_getObject(e){const t=this._log;try{const r=this.localStorageGrant();if(r.isDefinitivelyAllowed()){var i=this.localStorage.getObjectWithExpiration(e);return t.info("Local storage get key=".concat(e.name," value=").concat(i)),i}t.warn("clientStore.get() has been called without definitive grant",r)}catch(e){t.error(e)}}clear(e){const t=this._log;try{this.localStorage.removeItemWithExpiration(e)}catch(e){t.error(e)}}scheduleGC(t){const i=this.localStorageGrant(),r=this.localStorage,s=this.storageConfig.ID5_V2.name;setTimeout(function(){var e;i.isDefinitivelyAllowed()&&(e=r.removeExpiredObjectWithPrefix(s),t.storageAllKeysCounter().record((null==e?void 0:e.all)||0),t.storageExpiredKeysCounter().record((null==e?void 0:e.expired)||0))},0)}_clearObject(e){const t=this._log;try{this.localStorage.removeItem(e.name)}catch(e){t.error(e)}}_put(e,t){const i=this._log;try{const r=this.localStorageGrant();r.isDefinitivelyAllowed()?(i.info("Local storage put key=".concat(e.name," value=").concat(t)),this.localStorage.setItemWithExpiration(e,t)):i.warn("clientStore._put() has been called without definitive grant",r)}catch(e){i.error(e)}}_updateObject(e,t){const i=this._log;try{const r=this.localStorageGrant();if(r.isDefinitivelyAllowed())return this.localStorage.updateObjectWithExpiration(e,t);i.warn("clientStore._updateObject() has been called without definitive grant",r)}catch(e){i.error(e)}}localStorageGrant(){return this.localStorageGrantChecker()}getResponse(){var e=this.get(this.storageConfig.ID5);return e&&JSON.parse(decodeURIComponent(e))}clearResponse(){this.clear(this.storageConfig.ID5)}clearResponseV2(e){this._clearObject(this.storageConfig.ID5_V2.withNameSuffixed(e))}putResponseV1(e){this._put(this.storageConfig.ID5,encodeURIComponent(R(e)?e:JSON.stringify(e)))}getHashedConsentData(){return this.get(this.storageConfig.CONSENT_DATA)}clearHashedConsentData(){this.clear(this.storageConfig.CONSENT_DATA)}putHashedConsentData(e){e!==new H&&this._put(this.storageConfig.CONSENT_DATA,e.hashCode())}static makeStoredHash(e){return V("string"==typeof e?e:"")}getDateTime(){return new Date(this.get(this.storageConfig.LAST)).getTime()}clearDateTime(){this.clear(this.storageConfig.LAST)}setResponseDateTimeV1(e){this._put(this.storageConfig.LAST,e)}storeResponseV2(e,t){let i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:Date.now();return this._updateObject(this.storageConfig.ID5_V2.withNameSuffixed(e),e=>p(p({},e),{},{response:t,responseTimestamp:i}))}getStoredResponseV2(e){return this._getObject(this.storageConfig.ID5_V2.withNameSuffixed(e))}incNbV2(e){let i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;return this._updateObject(this.storageConfig.ID5_V2.withNameSuffixed(e),e=>{var t=Math.max(0,N(null==e?void 0:e.nb)?Math.round(e.nb)+i:i);return p(p({},e),{},{nb:t})})}static storedDataMatchesCurrentData(e,t){return null==e||e===t}storedConsentDataMatchesConsentData(e){return Ve.storedDataMatchesCurrentData(this.getHashedConsentData(),e.hashCode())}}class Ge{constructor(e,t){l(this,"_metrics",void 0),l(this,"_log",void 0),this._metrics=e,this._log=t}static getChunkUrl(e,t){return"https://c".concat(e,".eu-").concat(t,"-id5-sync.com")}submitExtensionCall(t,i){let r=Ne();return fetch(t).then(e=>{if(e.ok)return r.record(this._metrics.extensionsCallTimer(i,!0)),e.json();r.record(this._metrics.extensionsCallTimer(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(this._metrics.extensionsCallTimer(i,!1)),this._log.warn("Got error from ".concat(t," endpoint"),e),{}))}gatherChunks(e,i){if(e){let t=Ne();return Promise.all(Array.from({length:i.length},(e,t)=>{t=Ge.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(this._metrics.extensionsCallTimer(i.name,!0)),{[i.name]:e,[i.name+"Version"]:"".concat(i.version)})).catch(e=>(t.record(this._metrics.extensionsCallTimer(i.name,!1)),this._log.warn("Got error when getting ".concat(i.name),e),{}))}return Promise.resolve({})}gather(i){let r=Ne();return this.submitExtensionCall("https://lb.eu-1-id5-sync.com/lb/v1","lb").then(e=>{var t=this.getChunksEnabled(i,e);return Promise.allSettled([Promise.resolve(e),this.gatherChunks(t,Ge.CHUNKS_CONFIGS.devChunks),this.gatherChunks(t,Ge.CHUNKS_CONFIGS.groupChunks)])}).then(e=>{r.record(this._metrics.extensionsCallTimer("all",!0));let t=Ge.DEFAULT_RESPONSE;return e.forEach(e=>{e.value&&(t=p(p({},t),e.value))}),t}).catch(e=>(r.record(this._metrics.extensionsCallTimer("all",!1)),this._log.error("Got error ".concat(e," when gathering extensions data")),Ge.DEFAULT_RESPONSE))}getChunksEnabled(e,t){e=e.some(e=>e.pd&&""!==e.pd.trim()),t=null==t?void 0:t.chunks;return 0!==t&&(e||t)}}l(Ge,"CHUNKS_CONFIGS",Object.freeze({devChunks:{name:"devChunks",urlVersion:3,length:8,version:4},groupChunks:{name:"groupChunks",urlVersion:4,length:8,version:4}})),l(Ge,"DEFAULT_RESPONSE",{lbCDN:"%%LB_CDN%%"});const We={createExtensions:function(e,t){return new Ge(e,t)}},qe=Object.freeze({UNKNOWN:"unknown",LEADER:"leader",FOLLOWER:"follower"}),Be=Object.freeze({MULTIPLEXING:"multiplexing",SINGLETON:"singleton"}),He=Object.freeze({AWAITING_SCHEDULE:"awaiting_schedule",SKIPPED:"skipped",SCHEDULED:"scheduled",COMPLETED:"completed",CANCELED:"canceled"});class Je{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;return(null===(e=this.knownState)||void 0===e?void 0:e.operatingMode)===Be.MULTIPLEXING}getInstanceMultiplexingLeader(){var e,t;if((null===(e=this.knownState)||void 0===e?void 0:e.operatingMode)===Be.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 Ke{constructor(e){l(this,"_knownValues",[]),l(this,"_counter",void 0),this._counter=e}add(e){e&&-1===this._knownValues.indexOf(e)&&(this._counter.inc(),this._knownValues.push(e))}}class Ye{constructor(e,t){l(this,"_instancesCounter",void 0),l(this,"_domainsCounter",void 0),l(this,"_windowsCounter",void 0),l(this,"_partnersCounter",void 0);var i=t.id;this._instancesCounter=e.instanceCounter(t.id),this._windowsCounter=new Ke(e.instanceUniqWindowsCounter(i)),this._partnersCounter=new Ke(e.instanceUniqPartnersCounter(i)),this._domainsCounter=new Ke(e.instanceUniqueDomainsCounter(i))}addInstance(e){var t,i,r;this._instancesCounter.inc(),this._partnersCounter.add((null==e||null===(t=e.fetchIdData)||void 0===t?void 0:t.partnerId)|(null==e||null===(i=e.sourceConfiguration)||void 0===i||null===(r=i.options)||void 0===r?void 0:r.partnerId)),this._domainsCounter.add(null==e?void 0:e.domain),this._windowsCounter.add(null==e?void 0:e.href)}}class ze{constructor(e){l(this,"_scheduleTime",void 0),l(this,"_closeTime",void 0),l(this,"_timeoutId",void 0),l(this,"_state",He.AWAITING_SCHEDULE),l(this,"_delayMs",void 0),l(this,"_instance",void 0),this._instance=e}schedule(e){const t=this;t._delayMs=e,this._timeoutId=setTimeout(()=>{t._timeoutId&&(t._timeoutId=void 0,t._instance._doElection(),t._closeWithState(He.COMPLETED))},t._delayMs),t._state=He.SCHEDULED,t._scheduleTime=performance.now()}skip(){this._closeWithState(He.SKIPPED)}cancel(){this._timeoutId&&(clearTimeout(this._timeoutId),this._timeoutId=void 0),this._closeWithState(He.CANCELED)}_closeWithState(e){this._state=e,this._closeTime=performance.now()}}class Xe{constructor(e,t,i,r){var s,n=4<arguments.length&&void 0!==arguments[4]?arguments[4]:g;l(this,"properties",void 0),l(this,"_messenger",void 0),l(this,"_knownInstances",new Map),l(this,"_lastJoinedInstance",void 0),l(this,"role",void 0),l(this,"_leader",void 0),l(this,"_mode",void 0),l(this,"_metrics",void 0),l(this,"_logger",void 0),l(this,"_instanceCounters",void 0),l(this,"_election",void 0),l(this,"_window",void 0),l(this,"_storage",void 0);var o=U(globalThis)&&U(globalThis.crypto)&&A(globalThis.crypto.randomUUID)?globalThis.crypto.randomUUID():"".concat(1e6*Math.random()|0);this.properties=d({id:o,version:"1.0.19",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=qe.UNKNOWN,this._metrics=r,this._instanceCounters=new Ye(r,this.properties),this._loadTime=performance.now(),this._logger=void 0!==n?new _("Instance(id=".concat(o,")"),n):g,this._window=e,this._dispatcher=new ae(this._logger),this._leader=new re,this._followerRole=new ve(this._window,this.properties,this._dispatcher,this._logger),this._election=new ze(this),this._storage=i}updateConfig(e){d(this.properties,e)}init(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1e3;let r=this,s=r._window;r._mode=!0===r.properties.singletonMode?Be.SINGLETON:Be.MULTIPLEXING,r._instanceCounters.addInstance(r.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)})}(r),r._messenger=new w(r.properties.id,s,r._logger),r._messenger.onAnyMessage((e,t)=>{var i=Date.now()-e.timestamp|0;r._metrics.instanceMsgDeliveryTimer({messageType:e.type,sameWindow:s===t}).record(i),r._logger.debug("Message received",e),r._doFireEvent(ne.ID5_MESSAGE_RECEIVED,e)}).onMessage(m.TYPE,(e,t)=>{let i=d(new m,e.payload);void 0===i.isResponse&&(i.isResponse=e.dst!==o),r._handleHelloMessage(i,e,t)}).onProxyMethodCall(new y(this._logger).registerTarget(C.LEADER,r._leader).registerTarget(C.FOLLOWER,r._followerRole).registerTarget(C.STORAGE,r._storage)),r._mode===Be.SINGLETON?(r._election.skip(),r._onLeaderElected(r.properties)):r._mode===Be.MULTIPLEXING&&r._election.schedule(e),r._messenger.broadcastMessage(r._createHelloMessage(!1),m.TYPE),void 0===s.__id5_instances&&(s.__id5_instances=[]),s.__id5_instances.push(r)}register(e){try{this.updateConfig(e),this.init()}catch(e){this._logger.error("Failed to register integration instance",e)}return this}_handleHelloMessage(e,t,i){this._joinInstance(e,t,i)}deregister(){let e=this._window.__id5_instances;void 0!==e&&e.splice(e.indexOf(this),1),this._messenger&&this._messenger.deregister()}on(e,t){return this._dispatcher.on(e,t),this}_joinInstance(e,t,i){var r=e.isResponse;const s=new Je(e.instance,e.instanceState,i);this._knownInstances.get(s.getId())?this._logger.debug("Instance already known",s.getId()):(this._knownInstances.set(s.getId(),s),this._lastJoinedInstance=s,this._instanceCounters.addInstance(s.properties),this._metrics.instanceJoinDelayTimer({election:this._election._state}).record(performance.now()-this._loadTime|0),r?(r=s.getInstanceMultiplexingLeader(),this._mode===Be.MULTIPLEXING&&this.role===qe.UNKNOWN&&void 0!==r&&(this._logger.info("Joined late, elected leader is",r),this._election.cancel(),this._onLeaderElected(r))):(this._messenger.sendResponseMessage(t,this._createHelloMessage(!0),m.TYPE),this._mode===Be.MULTIPLEXING&&this.role!==qe.UNKNOWN&&this._handleLateJoiner(s)),this._logger.debug("Instance joined",s.getId()),this._doFireEvent(ne.ID5_INSTANCE_JOINED,s.properties))}_createHelloMessage(){var e,t=0<arguments.length&&void 0!==arguments[0]&&arguments[0];let i={operatingMode:this._mode,knownInstances:Array.from(this._knownInstances.values()).map(e=>e.properties)};return this._mode===Be.MULTIPLEXING&&(i.multiplexing={role:this.role,electionState:null===(e=this._election)||void 0===e?void 0:e._state,leader:this._leader.getProperties()}),new m(this.properties,t,i)}_handleLateJoiner(e){this._logger.info("Late joiner detected",e.properties);var t=this._metrics.instanceLateJoinCounter(this.properties.id,{scope:"party"}).inc();this._metrics.instanceLateJoinDelayTimer({election:this._election._state,isFirst:1===t}).record(performance.now()-this._election._closeTime),!e.isMultiplexingPartyAllowed()||this.role!==qe.LEADER||!0===(null==(e=this._leader.addFollower(new me(e,this._messenger,this._logger)))?void 0:e.lateJoiner)&&this._metrics.instanceLateJoinCounter(this.properties.id,{scope:"leader",unique:!0===(null==e?void 0:e.uniqueLateJoiner)}).inc()}_doFireEvent(e){for(var t=arguments.length,i=new Array(1<t?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];this._dispatcher.emit(e,...i)}_actAsLeader(){var e=this.properties;const t=this._logger;var i=this._metrics,r=new ge(this._storage),s=new le(r),n=new X(e.storageExpirationDays);const o=new Ie(s,n,e.forceAllowLocalStorageGrant,t);s=new Q(new Ve(()=>o.localStorageGrant(),s,n,t)),n=new Me(o,s,i,t,We.createExtensions(i,t));const a=new te(this._window,e,r,s,o,i,t,n);a.addFollower(this._followerRole),this._leader.assignLeader(a),this._mode===Be.MULTIPLEXING&&Array.from(this._knownInstances.values()).filter(e=>e.isMultiplexingPartyAllowed()).map(e=>a.addFollower(new me(e,this._messenger,t))),a.start()}_followRemoteLeader(e){this._leader.assignLeader(new ie(this._messenger,e)),this._logger.info("Following remote leader ",e)}updateConsent(e){this._leader.updateConsent(e)}updateFetchIdData(e){this._leader.updateFetchIdData(this.properties.id,e),d(this.properties.fetchIdData,e)}refreshUid(e){this._leader.refreshUid(e)}_doElection(){var e=this._election;const t=this._knownInstances;let i=Array.from(t.values()).filter(e=>e.isMultiplexingPartyAllowed()).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=-b(e.version,t.version);return 0===i&&(i=e.source.localeCompare(t.source),0===i&&(i=-b(e.sourceVersion,t.sourceVersion)),0===i&&(i=e.id.localeCompare(t.id))),i});return e[0]}(i));var r=this._lastJoinedInstance;r&&this._metrics.instanceLastJoinDelayTimer().record(Math.max(r._joinTime-e._scheduleTime,0))}_onLeaderElected(e){var t=this;t.role=e.id===t.properties.id?qe.LEADER:qe.FOLLOWER,t.role===qe.LEADER?t._actAsLeader():t.role===qe.FOLLOWER&&t._followRemoteLeader(e),t._logger.debug("Leader elected",e.id,"my role",t.role),t._doFireEvent(ne.ID5_LEADER_ELECTED,t.role,t._leader.getProperties())}}const Qe=new class{createInstance(e,t,i,r){return new Xe(e,{},r,i,t)}},$e="TRUE"===ot("id5_debug").toUpperCase(),Ze="TRACE"===ot("id5_debug").toUpperCase(),et=Boolean(window.console);let tt=!1;function it(e,t){for(var i=arguments.length,r=new Array(2<i?i-2:0),s=2;s<i;s++)r[s-2]=arguments[s];rt(console.error,e,t,"ERROR",r)}function rt(e,t,i,r,s){st()&&et&&e&&e.apply(console,["%cID5 - ".concat(t,"#").concat(i),"color: #fff; background: #1c307e; padding: 1px 4px; border-radius: 3px;",r].concat(s))}function st(){return $e||Ze||tt}class nt 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;i<e;i++)t[i]=arguments[i];!function(e,t){for(var i=arguments.length,r=new Array(2<i?i-2:0),s=2;s<i;s++)r[s-2]=arguments[s];rt(console.info,e,t,"DEBUG",r)}(this._origin,this._invocationId,...t)}info(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];!function(e,t){for(var i=arguments.length,r=new Array(2<i?i-2:0),s=2;s<i;s++)r[s-2]=arguments[s];rt(console.info,e,t,"INFO",r)}(this._origin,this._invocationId,...t)}warn(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];!function(e,t){for(var i=arguments.length,r=new Array(2<i?i-2:0),s=2;s<i;s++)r[s-2]=arguments[s];rt(console.warn,e,t,"WARNING",r)}(this._origin,this._invocationId,...t)}error(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];it(this._origin,this._invocationId,...t)}}function ot(e){const t=new RegExp("[\\?&]"+e+"=([^&#]*)"),i=t.exec(window.location.search);return null===i?"":decodeURIComponent(i[1].replace(/\+/g," "))}const at=P,ct=A,lt=R,dt=x,ht=N,ut=U,gt=function(e){return P(e,"Boolean")},pt=L,_t=new nt("ajax");function vt(e,t,i,r){M(e,t,i,3<arguments.length&&void 0!==r?r:{},_t)}function ft(e){let t=new Image;t.src=e}function mt(e,t){const i=[];return F(e,e=>{t(e)&&i.push(e)}),i}function Ct(e,t,i,r,s){for(t=t.split?t.split("."):t,r=0;r<t.length;r++)e=e?e[t[r]]:s;return e===s?i:e}const It=e=>null!=e&&"object"==typeof e;function yt(){return(yt=t(function*(e,t){if(pt(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 function(e){if(!pt(e))return;const t=/[()-.:;=?_/]/g;dt(e.brands)&&(e.brands=mt(e.brands,e=>lt(e.brand)&&e.brand.search(t)<0));dt(e.fullVersionList)&&(e.fullVersionList=mt(e.fullVersionList,e=>lt(e.brand)&&e.brand.search(t)<0));return e}(e)}})).apply(this,arguments)}const wt=(Se=window,function(){try{var i=bt(),r=i.length-1,s=null!==i[r].location||0<r&&null!==i[r-1].referrer,n=function(e){let t=[];var i,r=null;let s=null,n=null,o=null,a=null,c;for(c=e.length-1;0<=c;c--){try{s=e[c].location}catch(e){}if(s)t.push(s),a=a||s;else if(0!==c){i=e[c-1];try{n=i.referrer,o=i.ancestor}catch(e){}n?(t.push(n),a=a||n):o?(t.push(o),a=a||o):t.push(r)}else t.push(r)}return{stack:t,detectedRefererUrl:a}}(i);let e,t;i[i.length-1].canonicalUrl&&(e=i[i.length-1].canonicalUrl);try{t=Se.top.document.referrer}catch(e){}return{topmostLocation:n.detectedRefererUrl,ref:t||null,reachedTop:s,numIframes:r,stack:n.stack,canonicalUrl:e}}catch(e){}});function bt(){let i=function(){let t=[],i;do{try{i=i?i.parent:Se;try{var r=i===Se.top;let e={referrer:i.document.referrer||null,location:i.location.href||null,isTop:r};r&&(e=d(e,{canonicalUrl:function(e){try{var t=e.querySelector("link[rel='canonical']");if(null!==t)return t.href}catch(e){}return null}(i.document)})),t.push(e)}catch(e){t.push({referrer:null,location:null,isTop:i===Se.top})}}catch(e){return t.push({referrer:null,location:null,isTop:!1}),t}}while(i!==Se.top);return t}();var r=function(){try{return Se.location.ancestorOrigins?Se.location.ancestorOrigins:void 0}catch(e){}}();if(r)for(let e=0,t=r.length;e<t;e++)i[e].ancestor=r[e];return i}const St={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 Dt=Object.freeze({tcfv1:{objName:"__cmpCall",objKeys:["command","parameter"],returnObjName:"__cmpReturn"},tcfv2:{objName:"__tcfapiCall",objKeys:["command","version"],returnObjName:"__tcfapiReturn"},uspv1:{objName:"__uspapiCall",objKeys:["command","version"],returnObjName:"__uspapiReturn"},gppv1:{objName:"__gppCall",objKeys:["command","parameter"],returnObjName:"__gppReturn"}}),Et=Object.freeze({TCF:0,USP:1,GPP:2});class Ot{constructor(e,t){l(this,"direct",void 0),l(this,"version",void 0),this.direct=e,this.version=t}getConsentData(){var e=this;return t(function*(){return e.getClientConsentData()})()}static create(a){return t(function*(){var e=At._findCmpApi("__gpp"),t=e.cmpApiFrame,e=e.cmpApiFunction;let i,r=!1;if(!t)return a.warn("cmpApi: GPP not found! Using defaults."),Promise.resolve();if(ct(e))r=!0,a.info("cmpApi: Detected GPP is directly accessible, calling it now."),i=e;else{a.info("cmpApi: Detected GPP is outside the current iframe. Using message passing.");const o=At._buildCmpSurrogate("gppv1",t);i=function(e,t,i){o(e,i,t)}}var s=yield new Promise(t=>{var e=i("ping",function(e){t(e)});e&&t(e)});switch(s.gppVersion){case Tt.version:return new Tt(s,i,r);case Pt.version:return new Pt(s,i,r);default:var n="Unsupported version of gpp: ".concat(s.gppVersion);return a.warn(n),Promise.reject(n)}})()}static tcfDataHasLocalStorageGrant(e){return dt(e.PurposeConsent)&&!0===e.PurposeConsent[0]&&0<=(null===(e=e.VendorConsent)||void 0===e?void 0:e.indexOf("131"))}}class Tt extends Ot{constructor(e,t,i){super(i,Tt.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 t(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=h(yield Promise.all([e,t]),2),t=e[0],e=e[1];const i=new B;return i.version=W.GPP_V1_0,i.gppString=t.gppString,i.applicableSections=t.applicableSections,e&&(i.localStoragePurposeConsent=Ot.tcfDataHasLocalStorageGrant(e)),i})()}}l(Tt,"version","1.0");class Pt extends Ot{constructor(e,t,i){super(i,Pt.version),l(this,"gppFn",void 0),l(this,"readyPingData",void 0),this.gppFn=t,"ready"===e.signalStatus&&(this.readyPingData=e)}getClientConsentData(){var i=this;return t(function*(){return new Promise(t=>{i.readyPingData?t(i.parsePingData(i.readyPingData)):i.gppFn("addEventListener",e=>"ready"===e.pingData.signalStatus&&void t(i.parsePingData(e.pingData)))})})()}parsePingData(e){const t=new B;t.gppString=e.gppString,t.version=W.GPP_V1_1,t.applicableSections=e.applicableSections;e=null===(e=e.parsedSections)||void 0===e?void 0:e.tcfeuv2;return e&&(t.localStoragePurposeConsent=Ot.tcfDataHasLocalStorageGrant(e[0])),t}}l(Pt,"version","1.1");class At{constructor(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:g;l(this,"_lookupInProgress",void 0),l(this,"_log",void 0),l(this,"_metrics",void 0),l(this,"_consentDataPromise",void 0),this._metrics=e,this._log=t}refreshConsentData(e,t,i){const r=this;return r._lookupInProgress||(r._lookupInProgress=!0,r._consentDataPromise=this._lookupConsentData(e,t,i).finally(()=>{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 H;return e.forcedGrantByConfig=!0,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||{};var i=new H;let r={};ut(e.getConsentData)?r=this._parseTcfData(e,1):ut(e.getTCData)?r=this._parseTcfData(e.getTCData,2):dt(e.allowedVendors)?r={api:W.ID5_ALLOWED_VENDORS,allowedVendors:e.allowedVendors.map(e=>e.toString()),gdprApplies:!0}:ut(e.getUSPData)?r=this._parseUspData(e.getUSPData):this._log.warn("cmpApi: No static consent data detected! Using defaults."),d(i,r),this._log.info("cmpApi: Detected API '".concat(i.api,"' from static consent data"),e),t(i)}_lookupIabConsent(i){const r=[];let s=new H;var e=t=>(r[t]=0,e=>{r[t]||(r[t]=Date.now(),e&&d(s,e),r.every(e=>0<e)&&i(s))}),t=e(Et.TCF),n=e(Et.USP),e=e(Et.GPP);this._lookupGpp(e),this._lookupTcf(t),this._lookupUsp(n)}_lookupUsp(i){var e=At._findCmpApi("__uspapi"),t=e.cmpApiFrame,e=e.cmpApiFunction;let r;if(!t)return this._log.warn("cmpApi: USP not found! Using defaults for CCPA."),void i();r=ct(e)?(this._log.info("cmpApi: Detected USP is directly accessible, calling it now."),e):(this._log.info("cmpApi: Detected USP is outside the current iframe. Using message passing."),At._buildCmpSurrogate("uspv1",t));r("getUSPData",1,(e,t)=>{t?i(this._parseUspData(e)):(this._log.error("cmpApi: USP callback not successful. Using defaults for CCPA."),i())})}_lookupGpp(o){var a=this;return t(function*(){var t=Date.now();try{let e=yield Ot.create(a._log);if(e){var i={gppVersion:e.version,directCmp:e.direct};try{var r=yield e.getConsentData(),s={api:r.version,gppData:r};o(s);var n=Date.now();a._metrics.timer("gpp.delay",i).record(n-t)}catch(e){a._metrics.counter("gpp.failure",d({type:"CONSENT"},i)).inc(),a._log.error("cmpApi: getting GPP consent not successful. Using defaults for Gpp."),o()}}else o()}catch(e){a._metrics.counter("gpp.failure",{type:"CLIENT"}).inc(),a._log.error("cmpApi: creating GPP client not successful. Using defaults for Gpp."),o()}})()}static _buildCmpSurrogate(c,l){return(e,t,i)=>{const r=Math.random()+"",s=Dt[c],n={},o={};o[s.objKeys[0]]=e,o[s.objKeys[1]]=t,o.callId=r,n[s.objName]=o;const a=e=>{e=Ct(e,"data.".concat(s.returnObjName));e&&e.callId===r&&(void 0!==(e=i(e.returnValue,e.success))&&!0!==e||window.removeEventListener("message",a))};window.addEventListener("message",a,!1),l.postMessage(n,"*")}}_lookupTcf(e){var t=At._findTCF(),i=t.cmpVersion,r=t.cmpFrame,t=t.cmpFunction;if(!r)return this._log.warn("cmpApi: TCF not found! Using defaults for GDPR."),void e();ct(t)?this._lookupDirectTcf(i,t,e):(this._log.info("cmpApi: Detected TCF is outside the current iframe. Using message passing."),this._lookupMessageTcf(i,r,e))}_lookupMessageTcf(e,t,i){t=At._buildCmpSurrogate(1===e?"tcfv1":"tcfv2",t);this._lookupDirectTcf(e,t,i)}_lookupDirectTcf(e,t,r){const s=this._log,n={},o={},a=(e,t,i)=>{s.info("cmpApi: TCFv".concat(e," - Received a call back: ").concat(t),i)},c=(e,t)=>{s.error("cmpApi: TCFv".concat(e," - Received insuccess: ").concat(t,". Please check your CMP setup. Using defaults for GDPR."))};var i,l=i=>(o[i]=!1,(e,t)=>{o[i]=!0,t?(a(1,i,e),n[i]=e):c(1,i),Object.values(o).every(e=>e)&&r(this._parseTcfData(n,1))}),d=(e,t)=>(a(2,"event",e),t?!(!e||!1!==e.gdprApplies&&"tcloaded"!==e.eventStatus&&"useractioncomplete"!==e.eventStatus)&&void r(this._parseTcfData(e,2)):(c(2,"addEventListener"),void r()));1===e?(i=l("getConsentData"),l=l("getVendorConsents"),t("getConsentData",null,i),t("getVendorConsents",null,l)):2===e&&t("addEventListener",e,d)}_parseUspData(e){if(ut(e)&&lt(e.uspString))return{api:W.USP_V1,ccpaString:e.uspString};this._log.error("cmpApi: No or malformed USP data. Using defaults for CCPA.")}_parseTcfData(e,t){let i=this._log,r,s;if(1===t)r=At._isValidV1ConsentObject,s=At._normalizeV1Data;else{if(2!==t)return void i.error("cmpApi: No or malformed CMP data. Using defaults for GDPR.");r=At._isValidV2ConsentObject,s=At._normalizeV2Data}if(r(e))return s(e);i.error("cmpApi: Invalid CMP data. Using defaults for GDPR.",e)}static _isValidV1ConsentObject(e){var t=Ct(e,"getConsentData.gdprApplies");return!!gt(t)&&(!1===t||lt(e.getConsentData.consentData)&&ut(e.getVendorConsents)&&1<Object.keys(e.getVendorConsents).length)}static _isValidV2ConsentObject(e){var t=e&&e.gdprApplies,e=e&&e.tcString;return!1===t||lt(e)}static _normalizeV1Data(e){return{consentString:e.getConsentData.consentData,localStoragePurposeConsent:Ct(e,"getVendorConsents.purposeConsents.1"),gdprApplies:e.getConsentData.gdprApplies,api:W.TCF_V1}}static _normalizeV2Data(e){let t=Ct(e,"purpose.consents.1");return gt(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=St[t];if(void 0!==t)return 0!=(t&1<<6-i%6-1)}}(e.tcString,1)),{consentString:e.tcString,localStoragePurposeConsent:t,gdprApplies:e.gdprApplies,api:W.TCF_V2}}static _findTCF(){let e=0,t=window,i,r;for(;!i;){try{if("function"==typeof t.__tcfapi||"function"==typeof t.__cmp){r="function"==typeof t.__tcfapi?(e=2,t.__tcfapi):(e=1,t.__cmp),i=t;break}}catch(e){}try{if(t.frames.__tcfapiLocator){e=2,i=t;break}}catch(e){}try{if(t.frames.__cmpLocator){e=1,i=t;break}}catch(e){}if(t===window.top)break;t=t.parent}return{cmpVersion:e,cmpFrame:i,cmpFunction:r}}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}}}class Rt{constructor(e,t,i,r,s,n,o){l(this,"_availableCallbackTimerId",void 0),l(this,"_availableCallbackFired",!1),l(this,"_availableCallback",void 0),l(this,"_updateCallback",void 0),l(this,"_refreshCallbackTimerId",void 0),l(this,"_refreshCallbackFired",!1),l(this,"_refreshCallback",void 0),l(this,"_isExposed",void 0),l(this,"_fromCache",void 0),l(this,"_isRefreshing",!1),l(this,"_isRefreshingWithFetch",!1),l(this,"_userId",void 0),l(this,"_ext",void 0),l(this,"_userIdAvailable",!1),l(this,"_userIdAvailablePromise",void 0),l(this,"_userIdAvailablePromiseResolver",void 0),l(this,"invocationId",void 0),l(this,"config",void 0),l(this,"clientStore",void 0),l(this,"consentManagement",void 0),l(this,"_consentDataProvider",void 0),l(this,"_metrics",void 0),l(this,"_logger",void 0),this.config=e,this.clientStore=t,this.consentManagement=i,this._metrics=r,this._consentDataProvider=s,this._logger=n,this.instance=o,this._userIdAvailablePromise=new Promise(e=>{this._userIdAvailablePromiseResolver=e})}getOptions(){return this.config.getOptions()}getProvidedOptions(){return this.config.getProvidedOptions()}getInvalidSegments(){return this.config.getInvalidSegments()}updateOptions(e){return this.config.updOptions(e)}startRefresh(e){this._isRefreshing=!0,this._isRefreshingWithFetch=e}setUserId(e,t){const i=this;var r=e.universal_uid;if(this._isExposed=!0,ut(e.ab_testing))switch(e.ab_testing.result){case"normal":break;default:case"error":this._logger.error("Id5Status: There was an error with A/B Testing. Make sure controlGroupRatio is a number >= 0 and <= 1");break;case"control":this._isExposed=!1,this.info("User is in control group!")}var s=this._userId!==r||!1===function e(t,i){if(!It(t)||!It(i))return t===i;var r=Object.keys(t),s=Object.keys(i);if(r.length!==s.length)return!1;for(var n=0,o=r;n<o.length;n++){var a=o[n];if(!e(t[a],i[a]))return!1}return!0}(this._ext,e.ext);this._userIdAvailable=!0,this._userId=r,this._userIdAvailablePromiseResolver(r),this._ext=e.ext,this._fromCache=t,this.info("User id updated, hasChanged: ".concat(s,", fromCache: ").concat(t)),ct(this._availableCallback)&&!1===this._availableCallbackFired&&(this._availableCallbackTimerId&&(this.info("Cancelling pending onAvailableCallback watchdog"),clearTimeout(this._availableCallbackTimerId),this._availableCallbackTimerId=void 0),this._availableCallbackTimerId=setTimeout(()=>Rt.doFireOnAvailableCallBack(i),0)),this._isRefreshing&&ct(this._refreshCallback)&&!1===this._refreshCallbackFired&&(!1!==t&&!1!==this._isRefreshingWithFetch||(this._refreshCallbackTimerId&&(this.info("Cancelling pending onRefreshCallback watchdog"),clearTimeout(this._refreshCallbackTimerId),this._refreshCallbackTimerId=void 0),this._refreshCallbackTimerId=setTimeout(()=>Rt.doFireOnRefreshCallBack(i),0))),s&&ct(this._updateCallback)&&setTimeout(()=>Rt.doFireOnUpdateCallBack(i),0)}getUserId(){return!1===this._isExposed?"0":this._userId}getLinkType(){return!1===this._isExposed?0:this.getExt().linkType}getExt(){var e=!1===this._isExposed?{}:this._ext;return d({abTestingControlGroup:!this.exposeUserId()},e)}isFromCache(){return this._fromCache}exposeUserId(){return this._isExposed}getUserIdAsEid(){return{source:Y.ID5_EIDS_SOURCE,uids:[{atype:1,id:this.getUserId(),ext:this.getExt()}]}}onAvailable(e,t){if(!ct(e))throw new Error("onAvailable expect a function");if(ct(this._availableCallback))this.info("onAvailable was already called, ignoring");else{this._availableCallback=e;const i=this;this._userIdAvailable?(this.info("User id already available firing callback immediately"),this._availableCallbackTimerId=setTimeout(()=>Rt.doFireOnAvailableCallBack(i),0)):0<t&&(this._availableCallbackTimerId=setTimeout(()=>Rt.doFireOnAvailableCallBack(i),t))}return this}onUpdate(e){if(!ct(e))throw new Error("onUpdate expect a function");this._updateCallback=e;const t=this;return this._userIdAvailable&&setTimeout(()=>Rt.doFireOnUpdateCallBack(t),0),this}onRefresh(e,t){if(!ct(e))throw new Error("onRefresh expect a function");this._refreshCallbackTimerId&&(clearTimeout(this._refreshCallbackTimerId),this._refreshCallbackTimerId=void 0),this._refreshCallback=e;const i=this;return!0===this._isRefreshing&&!1===this._isRefreshingWithFetch&&this._userIdAvailable?this._refreshCallbackTimerId=setTimeout(()=>Rt.doFireOnRefreshCallBack(i),0):0<t&&(this._refreshCallbackTimerId=setTimeout(()=>Rt.doFireOnRefreshCallBack(i),t)),this}localStorageGrant(){return this.clientStore.localStorageGrant()}info(e){this._logger.info("Id5Status: "+e)}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.info("Sending event",e),fetch(e).catch(e=>this._logger.error("Error while sending event to ID5 of type "+t,e))};return this._userIdAvailable?r(this._userId):this._userIdAvailablePromise.then(e=>r(e))}static doFireOnAvailableCallBack(e){e.info("Id5Status.doFireOnAvailableCallBack"),e._availableCallbackFired=!0,e._availableCallbackTimerId=void 0,e._availableCallback(e)}static doFireOnUpdateCallBack(e){e.info("Id5Status.doFireOnUpdateCallBack"),e._updateCallback(e)}static doFireOnRefreshCallBack(e){e.info("Id5Status.doFireOnRefreshCallBack"),e._refreshCallbackFired=!0,e._refreshCallbackTimerId=void 0,e._isRefreshing=!1,e._isRefreshingWithFetch=!1,e._refreshCallback(e)}}const xt="1.0.57";class Nt{constructor(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:g;if(l(this,"invocationId",void 0),l(this,"options",void 0),l(this,"providedOptions",void 0),l(this,"invalidSegments",void 0),this._log=t,this.options={debugBypassConsent:!1,allowLocalStorageWithoutConsentApi:!1,cmpApi:"iab",consentData:{getConsentData:{consentData:void 0,gdprApplies:void 0},getVendorConsents:{}},refreshInSeconds:7200,partnerId:void 0,partnerUserId:void 0,callbackOnAvailable:void 0,callbackOnUpdates:void 0,callbackTimeoutInMs:void 0,pd:void 0,abTesting:{enabled:!1,controlGroupPct:0},provider:void 0,maxCascades:8,applyCreativeRestrictions:!1,acr:!1,segments:void 0,disableUaHints:!1,storageExpirationDays:void 0,att:void 0,diagnostics:{publishingDisabled:!1,publishAfterLoadInMsec:3e4,publishBeforeWindowUnload:!0,publishingSampleRatio:.01},multiplexing:{_disabled:!1}},this.providedOptions={},!ht(e.partnerId)&&!lt(e.partnerId))throw new Error("partnerId is required and must be a number or a string");this.invalidSegments=0,this.updOptions(e),this.storageConfig=new X(e.storageExpirationDays)}getOptions(){return this.options}getProvidedOptions(){return this.providedOptions}getInvalidSegments(){return this.invalidSegments}hasCreativeRestrictions(){return this.options.applyCreativeRestrictions||this.options.acr}updOptions(a){const c=this,l=c._log;if(ut(a)){this.setPartnerId(a.partnerId);const d=(e,t)=>{this.options[e]=t,this.providedOptions[e]=t};Object.keys(a).forEach(e=>{if("segments"===e){const r=a[e],s=[];L(r)&&(dt(r)?(r.forEach((e,t)=>{t="segments[".concat(t,"]");return dt(e.ids)&&function(e,t){let i=!0;return F(e,e=>i=i&&t(e)),i}(e.ids,lt)?e.ids.length<1?(l.error("Config option ".concat(t,".ids should contain at least one segment ID")),void(c.invalidSegments+=1)):lt(e.destination)?void s.push(e):(Ut(l,"".concat(t,".destination"),"String",e.destination),void(c.invalidSegments+=1)):(Ut(l,"".concat(t,".ids"),"Array of String",e.ids),void(c.invalidSegments+=1))}),d(e,s)):Ut(l,e,"Array",r))}else if("diagnostics"===e){const n=this.options.diagnostics,o=a.diagnostics;if(at(o,Nt.configTypes.diagnostics)){let t=p({},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;"partnerId"!==e&&(t=Nt.configTypes[e],L(i=a[e])&&(at(i,t)?d(e,i):Ut(l,e,t,i)))}})}else l.error("Config options must be an object")}setPartnerId(e){let t;if(lt(e)){if(t=parseInt(e),isNaN(t)||t<0)throw new Error("partnerId is required and must parse to a positive integer")}else ht(e)&&(t=e);if(ht(t)){if(ht(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 Ut(e,t,i,r){e.error("Config option ".concat(t," must be of type ").concat(i," but was ").concat(toString.call(r),". Ignoring..."))}l(Nt,"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"});const Lt="api";const Ft=new class{set debug(e){e=e,tt=!!e}get debug(){return st()}constructor(){l(this,"loaded",!1),l(this,"_isUsingCdn",!1),l(this,"_referer",!1),l(this,"_version",xt),l(this,"versions",{}),l(this,"invocationId",0),this.loaded=!0,this._isUsingCdn=!!(document&&document.currentScript&&document.currentScript.src&&0===document.currentScript.src.indexOf("https://cdn.id5-sync.com")),this._referer=wt(),this.versions[xt]=!0}init(e){this.invocationId+=1;const r=new nt(Lt,this.invocationId);try{r.info("ID5 API version ".concat(this._version,". Invoking init()"),e);const n=new Nt(e,r),o=n.getOptions(),a=this._configureDiagnostics(o.partnerId,o.diagnostics,r);a&&(a.loadDelayTimer().recordNow(),a.invocationCountSummary().record(this.invocationId));var t=new ue(window,!n.hasCreativeRestrictions()),i=new le(t);const c=o.allowLocalStorageWithoutConsentApi||o.debugBypassConsent,l=new Ie(i,n.storageConfig,c,r);const d=new Ve(()=>l.localStorageGrant(),i,n.storageConfig,r),h=Qe.createInstance(window,r,a,t);var s=new At(a,r);const u=new Rt(n,d,l,a,s,r,h),g=Ne();return h.on(se.CASCADE_NEEDED,this._doCascade(u)).on(se.USER_ID_READY,(e,t)=>{try{var i=null!=t&&t.tags?p({},t.tags):{};null!=t&&t.timestamp&&a.userIdNotificationDeliveryDelayTimer(i).record(Date.now()-t.timestamp),g.record(a.userIdProvisioningDelayTimer(e.isFromCache,p(p({},i),{},{isUpdate:u._userIdAvailable})))}catch(e){r.error("Failed to measure provisioning metrics",e)}u.setUserId(e.responseObj,e.isFromCache)}).on(se.USER_ID_FETCH_CANCELED,e=>r.info("ID5 User ID fetch canceled:",e.reason)),this._gatherFetchIdData(u).then(e=>{var t;return h.register({source:Lt,sourceVersion:xt,sourceConfiguration:{options:u.getOptions()},fetchIdData:e,singletonMode:!0===(null===o||void 0===o||null===(t=o.multiplexing)||void 0===t?void 0:t._disabled),canDoCascade:!o.applyCreativeRestrictions,forceAllowLocalStorageGrant:c,storageExpirationDays:o.storageExpirationDays})}),this._submitRefreshConsent(o,s,h,a,r).then(e=>{e&&(l.setConsentData(e),d.scheduleGC(a))}),r.info("ID5 initialized for partner ".concat(o.partnerId," with referer ").concat(this._referer.referer," and options"),e),u}catch(e){r.error("Exception caught during init()",e)}}_doCascade(a){return e=>{const t=a._logger,i=a.config;var r,s,n,o=i.getOptions();e.partnerId===o.partnerId&&0<=o.maxCascades&&!i.hasCreativeRestrictions()&&(r=o.partnerUserId&&0<o.partnerUserId.length,s=e.gppString?"&gpp=".concat(e.gppString,"&gpp_sid=").concat(e.gppSid):"",s="".concat("https://id5-sync.com","/").concat(r?"s":"i","/").concat(o.partnerId,"/").concat(o.maxCascades,".gif?")+"id5id=".concat(e.userId,"&o=api").concat(r?"&puid="+o.partnerUserId:"","&gdpr_consent=").concat(e.consentString,"&gdpr=").concat(e.gdprApplies).concat(s),t.info("Opportunities to cascade available",s),n=s,"loading"!==document.readyState?ft(n):document.addEventListener("DOMContentLoaded",function(){ft(n)}))}}_submitRefreshConsent(e,t,i,r,s){let n=Ne(),o=e.debugBypassConsent?"bypass":e.cmpApi;return t.refreshConsentData(e.debugBypassConsent,e.cmpApi,e.consentData).then(e=>(n.record(r.consentRequestTimer(o,{success:!0,apiType:e.api})),i.updateConsent(e),e)).catch(e=>{s.error("Couldn't get consent data",e),n.record(r.consentRequestTimer(o,{success:!1,error:e.message}))})}refreshId(e){let t=1<arguments.length&&void 0!==arguments[1]&&arguments[1];var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};if(!gt(t))throw new Error("Invalid signature for refreshId(): second parameter must be a boolean");const r=e._logger;try{r.info("Invoking refreshId()",arguments),e.startRefresh(t),e.updateOptions(i);var s=e.getOptions();const n=e.instance,o=s.allowLocalStorageWithoutConsentApi||s.debugBypassConsent;this._gatherFetchIdData(e).then(e=>{n.updateFetchIdData(e),n.refreshUid({resetConsent:!0,forceAllowLocalStorageGrant:o,forceFetch:t})}),this._submitRefreshConsent(s,e._consentDataProvider,n,e._metrics,e._logger)}catch(e){r.error("Exception caught from refreshId()",e)}return e}_gatherFetchIdData(t){const i=t.getOptions();var e=t._logger;return function(){return yt.apply(this,arguments)}(i.disableUaHints,e).then(e=>({partnerId:i.partnerId,refererInfo:this._referer,origin:Lt,originVersion:this._version,isUsingCdn:this._isUsingCdn,att:i.att,uaHints:e,abTesting:i.abTesting,segments:i.segments,invalidSegmentsCount:t.getInvalidSegments(),provider:i.provider,pd:i.pd,partnerUserId:i.partnerUserId,refreshInSeconds:i.refreshInSeconds,providedRefreshInSeconds:t.getProvidedOptions().refreshInSeconds,trace:Ze}))}_configureDiagnostics(t,i,r){try{let e=new Le(Lt,xt);var s;return e.addCommonTags(p(p({},Ue(t)),{},{tml:this._referer.topmostLocation})),null!=i&&i.publishingDisabled||(n=i.publishingSampleRatio,s=Math.random()<n&&ye?(e,t)=>new we(o,{sampling:n}).publish(e,t):e=>e,null!=i&&i.publishAfterLoadInMsec&&0<i.publishAfterLoadInMsec&&e.schedulePublishAfterMsec(i.publishAfterLoadInMsec,s),null!=i&&i.publishBeforeWindowUnload&&e.schedulePublishBeforeUnload(s)),e}catch(e){return void r.error("Failed to configure diagnostics",e)}var n,o}},kt=window.googletag=window.googletag||{};kt.encryptedSignalProviders=kt.encryptedSignalProviders||[],kt.encryptedSignalProviders.push({id:"id5-sync.com",collectorFunction:()=>{const s="https://id5-sync.com/api/esp/increment?counter=";return new Promise((t,i)=>{if(!ut(window.ID5EspConfig)){var r=()=>i(new Error("No ID5 config"));return it("esp","Expected window.ID5EspConfig to be an Object with the necessary configuration! Cannot invoke ID5 fetch."),void vt(s+"no-config",{success:r,error:r})}window.ID5EspConfig.provider=window.ID5EspConfig.provider||"g-esp";try{Ft.init(window.ID5EspConfig).onAvailable(e=>{t(e.getUserId())})}catch(e){r=()=>i(e);it("esp","Exception while initializing ID5 within googletag ESP! Cannot invoke ID5 fetch."),vt(s+"exception",{success:r,error:r})}})}})}();