fourm.solutions.cdn.jp.optable.co Open in urlscan Pro
34.36.86.249  Public Scan

URL: https://fourm.solutions.cdn.jp.optable.co/public-assets/fourm-sdk.js
Submission: On September 04 via manual from JP — Scanned from JP

Form analysis 0 forms found in the DOM

Text Content

/*! For license information please see fourm-sdk.js.LICENSE.txt */
(()=>{var __webpack_modules__={23:(module,exports,__webpack_require__)=>{var __WEBPACK_AMD_DEFINE_RESULT__;(function(){"use strict";var ERROR="input is invalid type",WINDOW="object"==typeof window,root=WINDOW?window:{};root.JS_SHA256_NO_WINDOW&&(WINDOW=!1);var WEB_WORKER=!WINDOW&&"object"==typeof self,NODE_JS=!root.JS_SHA256_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;NODE_JS?root=__webpack_require__.g:WEB_WORKER&&(root=self);var COMMON_JS=!root.JS_SHA256_NO_COMMON_JS&&module.exports,AMD=__webpack_require__.amdO,ARRAY_BUFFER=!root.JS_SHA256_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,HEX_CHARS="0123456789abcdef".split(""),EXTRA=[-2147483648,8388608,32768,128],SHIFT=[24,16,8,0],K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],OUTPUT_TYPES=["hex","array","digest","arrayBuffer"],blocks=[];!root.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!ARRAY_BUFFER||!root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});var createOutputMethod=function(e,t){return function(s){return new Sha256(t,!0).update(s)[e]()}},createMethod=function(e){var t=createOutputMethod("hex",e);NODE_JS&&(t=nodeWrap(t,e)),t.create=function(){return new Sha256(e)},t.update=function(e){return t.create().update(e)};for(var s=0;s<OUTPUT_TYPES.length;++s){var r=OUTPUT_TYPES[s];t[r]=createOutputMethod(r,e)}return t},nodeWrap=function(method,is224){var crypto=eval("require('crypto')"),Buffer=eval("require('buffer').Buffer"),algorithm=is224?"sha224":"sha256",nodeMethod=function(e){if("string"==typeof e)return crypto.createHash(algorithm).update(e,"utf8").digest("hex");if(null==e)throw new Error(ERROR);return e.constructor===ArrayBuffer&&(e=new Uint8Array(e)),Array.isArray(e)||ArrayBuffer.isView(e)||e.constructor===Buffer?crypto.createHash(algorithm).update(new Buffer(e)).digest("hex"):method(e)};return nodeMethod},createHmacOutputMethod=function(e,t){return function(s,r){return new HmacSha256(s,t,!0).update(r)[e]()}},createHmacMethod=function(e){var t=createHmacOutputMethod("hex",e);t.create=function(t){return new HmacSha256(t,e)},t.update=function(e,s){return t.create(e).update(s)};for(var s=0;s<OUTPUT_TYPES.length;++s){var r=OUTPUT_TYPES[s];t[r]=createHmacOutputMethod(r,e)}return t};function Sha256(e,t){t?(blocks[0]=blocks[16]=blocks[1]=blocks[2]=blocks[3]=blocks[4]=blocks[5]=blocks[6]=blocks[7]=blocks[8]=blocks[9]=blocks[10]=blocks[11]=blocks[12]=blocks[13]=blocks[14]=blocks[15]=0,this.blocks=blocks):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=e}function HmacSha256(e,t,s){var r,i=typeof e;if("string"===i){var n,o=[],a=e.length,c=0;for(r=0;r<a;++r)(n=e.charCodeAt(r))<128?o[c++]=n:n<2048?(o[c++]=192|n>>6,o[c++]=128|63&n):n<55296||n>=57344?(o[c++]=224|n>>12,o[c++]=128|n>>6&63,o[c++]=128|63&n):(n=65536+((1023&n)<<10|1023&e.charCodeAt(++r)),o[c++]=240|n>>18,o[c++]=128|n>>12&63,o[c++]=128|n>>6&63,o[c++]=128|63&n);e=o}else{if("object"!==i)throw new Error(ERROR);if(null===e)throw new Error(ERROR);if(ARRAY_BUFFER&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||ARRAY_BUFFER&&ArrayBuffer.isView(e)))throw new Error(ERROR)}e.length>64&&(e=new Sha256(t,!0).update(e).array());var l=[],h=[];for(r=0;r<64;++r){var d=e[r]||0;l[r]=92^d,h[r]=54^d}Sha256.call(this,t,s),this.update(h),this.oKeyPad=l,this.inner=!0,this.sharedMemory=s}Sha256.prototype.update=function(e){if(!this.finalized){var t,s=typeof e;if("string"!==s){if("object"!==s)throw new Error(ERROR);if(null===e)throw new Error(ERROR);if(ARRAY_BUFFER&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||ARRAY_BUFFER&&ArrayBuffer.isView(e)))throw new Error(ERROR);t=!0}for(var r,i,n=0,o=e.length,a=this.blocks;n<o;){if(this.hashed&&(this.hashed=!1,a[0]=this.block,a[16]=a[1]=a[2]=a[3]=a[4]=a[5]=a[6]=a[7]=a[8]=a[9]=a[10]=a[11]=a[12]=a[13]=a[14]=a[15]=0),t)for(i=this.start;n<o&&i<64;++n)a[i>>2]|=e[n]<<SHIFT[3&i++];else for(i=this.start;n<o&&i<64;++n)(r=e.charCodeAt(n))<128?a[i>>2]|=r<<SHIFT[3&i++]:r<2048?(a[i>>2]|=(192|r>>6)<<SHIFT[3&i++],a[i>>2]|=(128|63&r)<<SHIFT[3&i++]):r<55296||r>=57344?(a[i>>2]|=(224|r>>12)<<SHIFT[3&i++],a[i>>2]|=(128|r>>6&63)<<SHIFT[3&i++],a[i>>2]|=(128|63&r)<<SHIFT[3&i++]):(r=65536+((1023&r)<<10|1023&e.charCodeAt(++n)),a[i>>2]|=(240|r>>18)<<SHIFT[3&i++],a[i>>2]|=(128|r>>12&63)<<SHIFT[3&i++],a[i>>2]|=(128|r>>6&63)<<SHIFT[3&i++],a[i>>2]|=(128|63&r)<<SHIFT[3&i++]);this.lastByteIndex=i,this.bytes+=i-this.start,i>=64?(this.block=a[16],this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},Sha256.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>2]|=EXTRA[3&t],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}},Sha256.prototype.hash=function(){var e,t,s,r,i,n,o,a,c,l=this.h0,h=this.h1,d=this.h2,u=this.h3,p=this.h4,g=this.h5,_=this.h6,f=this.h7,m=this.blocks;for(e=16;e<64;++e)t=((i=m[e-15])>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,s=((i=m[e-2])>>>17|i<<15)^(i>>>19|i<<13)^i>>>10,m[e]=m[e-16]+t+m[e-7]+s<<0;for(c=h&d,e=0;e<64;e+=4)this.first?(this.is224?(n=300032,f=(i=m[0]-1413257819)-150054599<<0,u=i+24177077<<0):(n=704751109,f=(i=m[0]-210244248)-1521486534<<0,u=i+143694565<<0),this.first=!1):(t=(l>>>2|l<<30)^(l>>>13|l<<19)^(l>>>22|l<<10),r=(n=l&h)^l&d^c,f=u+(i=f+(s=(p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7))+(p&g^~p&_)+K[e]+m[e])<<0,u=i+(t+r)<<0),t=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),r=(o=u&l)^u&h^n,_=d+(i=_+(s=(f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7))+(f&p^~f&g)+K[e+1]+m[e+1])<<0,t=((d=i+(t+r)<<0)>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),r=(a=d&u)^d&l^o,g=h+(i=g+(s=(_>>>6|_<<26)^(_>>>11|_<<21)^(_>>>25|_<<7))+(_&f^~_&p)+K[e+2]+m[e+2])<<0,t=((h=i+(t+r)<<0)>>>2|h<<30)^(h>>>13|h<<19)^(h>>>22|h<<10),r=(c=h&d)^h&u^a,p=l+(i=p+(s=(g>>>6|g<<26)^(g>>>11|g<<21)^(g>>>25|g<<7))+(g&_^~g&f)+K[e+3]+m[e+3])<<0,l=i+(t+r)<<0;this.h0=this.h0+l<<0,this.h1=this.h1+h<<0,this.h2=this.h2+d<<0,this.h3=this.h3+u<<0,this.h4=this.h4+p<<0,this.h5=this.h5+g<<0,this.h6=this.h6+_<<0,this.h7=this.h7+f<<0},Sha256.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,s=this.h2,r=this.h3,i=this.h4,n=this.h5,o=this.h6,a=this.h7,c=HEX_CHARS[e>>28&15]+HEX_CHARS[e>>24&15]+HEX_CHARS[e>>20&15]+HEX_CHARS[e>>16&15]+HEX_CHARS[e>>12&15]+HEX_CHARS[e>>8&15]+HEX_CHARS[e>>4&15]+HEX_CHARS[15&e]+HEX_CHARS[t>>28&15]+HEX_CHARS[t>>24&15]+HEX_CHARS[t>>20&15]+HEX_CHARS[t>>16&15]+HEX_CHARS[t>>12&15]+HEX_CHARS[t>>8&15]+HEX_CHARS[t>>4&15]+HEX_CHARS[15&t]+HEX_CHARS[s>>28&15]+HEX_CHARS[s>>24&15]+HEX_CHARS[s>>20&15]+HEX_CHARS[s>>16&15]+HEX_CHARS[s>>12&15]+HEX_CHARS[s>>8&15]+HEX_CHARS[s>>4&15]+HEX_CHARS[15&s]+HEX_CHARS[r>>28&15]+HEX_CHARS[r>>24&15]+HEX_CHARS[r>>20&15]+HEX_CHARS[r>>16&15]+HEX_CHARS[r>>12&15]+HEX_CHARS[r>>8&15]+HEX_CHARS[r>>4&15]+HEX_CHARS[15&r]+HEX_CHARS[i>>28&15]+HEX_CHARS[i>>24&15]+HEX_CHARS[i>>20&15]+HEX_CHARS[i>>16&15]+HEX_CHARS[i>>12&15]+HEX_CHARS[i>>8&15]+HEX_CHARS[i>>4&15]+HEX_CHARS[15&i]+HEX_CHARS[n>>28&15]+HEX_CHARS[n>>24&15]+HEX_CHARS[n>>20&15]+HEX_CHARS[n>>16&15]+HEX_CHARS[n>>12&15]+HEX_CHARS[n>>8&15]+HEX_CHARS[n>>4&15]+HEX_CHARS[15&n]+HEX_CHARS[o>>28&15]+HEX_CHARS[o>>24&15]+HEX_CHARS[o>>20&15]+HEX_CHARS[o>>16&15]+HEX_CHARS[o>>12&15]+HEX_CHARS[o>>8&15]+HEX_CHARS[o>>4&15]+HEX_CHARS[15&o];return this.is224||(c+=HEX_CHARS[a>>28&15]+HEX_CHARS[a>>24&15]+HEX_CHARS[a>>20&15]+HEX_CHARS[a>>16&15]+HEX_CHARS[a>>12&15]+HEX_CHARS[a>>8&15]+HEX_CHARS[a>>4&15]+HEX_CHARS[15&a]),c},Sha256.prototype.toString=Sha256.prototype.hex,Sha256.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,s=this.h2,r=this.h3,i=this.h4,n=this.h5,o=this.h6,a=this.h7,c=[e>>24&255,e>>16&255,e>>8&255,255&e,t>>24&255,t>>16&255,t>>8&255,255&t,s>>24&255,s>>16&255,s>>8&255,255&s,r>>24&255,r>>16&255,r>>8&255,255&r,i>>24&255,i>>16&255,i>>8&255,255&i,n>>24&255,n>>16&255,n>>8&255,255&n,o>>24&255,o>>16&255,o>>8&255,255&o];return this.is224||c.push(a>>24&255,a>>16&255,a>>8&255,255&a),c},Sha256.prototype.array=Sha256.prototype.digest,Sha256.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),this.is224||t.setUint32(28,this.h7),e},HmacSha256.prototype=new Sha256,HmacSha256.prototype.finalize=function(){if(Sha256.prototype.finalize.call(this),this.inner){this.inner=!1;var e=this.array();Sha256.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(e),Sha256.prototype.finalize.call(this)}};var exports=createMethod();exports.sha256=exports,exports.sha224=createMethod(!0),exports.sha256.hmac=createHmacMethod(),exports.sha224.hmac=createHmacMethod(!0),COMMON_JS?module.exports=exports:(root.sha256=exports.sha256,root.sha224=exports.sha224,AMD&&(__WEBPACK_AMD_DEFINE_RESULT__=function(){return exports}.call(exports,__webpack_require__,exports,module),void 0===__WEBPACK_AMD_DEFINE_RESULT__||(module.exports=__WEBPACK_AMD_DEFINE_RESULT__)))})()}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var s=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](s,s.exports,__webpack_require__),s.exports}__webpack_require__.amdO={},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();var __webpack_exports__={};(()=>{"use strict";const e="v0.19.2",t={insecure:!1,cookies:!0,initPassport:!0};var s;!function(e){e[e.DeviceID=1]="DeviceID",e[e.InAppImpression=2]="InAppImpression",e[e.PersonID=3]="PersonID"}(s||(s={}));const r="loblawmedia.ca";function i(e){return t=this,s=void 0,i=function*(){const t=yield c("/v2/targeting",e,{method:"GET",headers:{Accept:"application/json"}});return t&&new a(e).setTargeting(t),t},new((r=void 0)||(r=Promise))((function(e,n){function o(e){try{c(i.next(e))}catch(e){n(e)}}function a(e){try{c(i.throw(e))}catch(e){n(e)}}function c(t){var s;t.done?e(t.value):(s=t.value,s instanceof r?s:new r((function(e){e(s)}))).then(o,a)}c((i=i.apply(t,s||[])).next())}));var t,s,r,i}function n(e){var t,r;return{user:{data:(null!==(t=null==e?void 0:e.audience)&&void 0!==t?t:[]).map((e=>({name:e.provider,segment:e.ids,ext:{segtax:e.rtb_segtax}}))),ext:{eids:(null!==(r=null==e?void 0:e.user)&&void 0!==r?r:[]).map((e=>({source:e.provider,uids:e.ids.map((({id:e})=>({id:e,atype:s.PersonID})))})))}}}}function o(e){var t;const s={};if(!e)return s;for(const r of null!==(t=e.audience)&&void 0!==t?t:[])r.keyspace&&(r.keyspace in s||(s[r.keyspace]=[]),s[r.keyspace].push(...r.ids.map((e=>e.id))));return s}class a{constructor(e){this.Config=e;const t=btoa(function(e){const t=new Uint16Array(e.length);for(let s=0;s<t.length;s++)t[s]=e.charCodeAt(s);return String.fromCharCode(...new Uint8Array(t.buffer))}(`${this.Config.host}/${this.Config.site}`));this.targetingV1Key="OPTABLE_TGT_"+t,this.passportKey="OPTABLE_PASS_"+t,this.targetingKey="OPTABLE_V2_TGT_"+t,this.lmpidKey="__lmpid",this.siteKey="OPTABLE_SITE_"+t}getPassport(){return window.localStorage.getItem(this.passportKey)}getV1Targeting(){const e=window.localStorage.getItem(this.targetingV1Key),t=e?JSON.parse(e):null;return t?{user:[],audience:Object.entries(t).map((([e,t])=>({provider:"optable.co",keyspace:e,rtb_segtax:5001,ids:[].concat(t).map((e=>({id:String(e)})))})))}:null}getTargeting(){const e=window.localStorage.getItem(this.targetingKey);return(e?JSON.parse(e):null)||this.getV1Targeting()}setPassport(e){e&&e.length>0&&window.localStorage.setItem(this.passportKey,e)}setTargeting(e){e&&(window.localStorage.setItem(this.targetingKey,JSON.stringify(e)),this.setLmpid(e))}setSite(e){e&&window.localStorage.setItem(this.siteKey,JSON.stringify(e))}getSite(){const e=window.localStorage.getItem(this.siteKey);return e?JSON.parse(e):null}setLmpid(e){var t,s,i,n;const o=null===(t=e.user)||void 0===t?void 0:t.find((e=>e.provider===r));if(!o)return;const a=null!==(n=null===(i=null===(s=o.ids)||void 0===s?void 0:s[0])||void 0===i?void 0:i.id)&&void 0!==n?n:"";window.localStorage.setItem(this.lmpidKey,a),window.__lmpid=a}getLmpid(){return window.__lmpid||window.localStorage.getItem(this.lmpidKey)||null}clearPassport(){window.localStorage.removeItem(this.passportKey)}clearTargeting(){window.localStorage.removeItem(this.targetingKey)}clearSite(){window.localStorage.removeItem(this.siteKey)}}function c(t,s,r){return i=this,n=void 0,c=function*(){const i=yield globalThis.fetch(function(t,s,r){const{site:i,host:n,insecure:o,cookies:c}=s,l=new URL(`${i}${t}`,`${o?"http":"https"}://${n}`);if(c)l.search=new URLSearchParams({cookies:"yes",osdk:`web-${e}`}).toString();else{const t=new a(s).getPassport();l.search=new URLSearchParams({cookies:"no",passport:t||"",osdk:`web-${e}`}).toString()}const h=Object.assign({},r);return h.credentials="include",new Request(l.toString(),h)}(t,s,r)),n=i.headers.get("Content-Type"),o=(null==n?void 0:n.startsWith("application/json"))?yield i.json():yield i.text();if(!i.ok)throw new Error(o.error);return o.passport&&(new a(s).setPassport(o.passport),delete o.passport),o},new((o=void 0)||(o=Promise))((function(e,t){function s(e){try{a(c.next(e))}catch(e){t(e)}}function r(e){try{a(c.throw(e))}catch(e){t(e)}}function a(t){var i;t.done?e(t.value):(i=t.value,i instanceof o?i:new o((function(e){e(i)}))).then(s,r)}a((c=c.apply(i,n||[])).next())}));var i,n,o,c}function l(e){return t=this,s=void 0,i=function*(){const t=yield c("/config",e,{method:"GET",headers:{Accept:"application/json"}});return new a(e).setSite(t),t},new((r=void 0)||(r=Promise))((function(e,n){function o(e){try{c(i.next(e))}catch(e){n(e)}}function a(e){try{c(i.throw(e))}catch(e){n(e)}}function c(t){var s;t.done?e(t.value):(s=t.value,s instanceof r?s:new r((function(e){e(s)}))).then(o,a)}c((i=i.apply(t,s||[])).next())}));var t,s,r,i}var h=__webpack_require__(23),d=function(e,t,s,r){return new(s||(s=Promise))((function(i,n){function o(e){try{c(r.next(e))}catch(e){n(e)}}function a(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,a)}c((r=r.apply(e,t||[])).next())}))};class u{constructor(e){var s;this.dcn=(s=e,Object.assign(Object.assign({},t),s));const r=()=>{};this.init=this.dcn.initPassport?l(this.dcn).then(r).catch(r):Promise.resolve()}identify(...e){return d(this,void 0,void 0,(function*(){return yield this.init,function(e,t){return c("/identify",e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}(this.dcn,e.filter((e=>e)))}))}uid2Token(e){return d(this,void 0,void 0,(function*(){return yield this.init,function(e,t){return c("/uid2/token",e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}(this.dcn,e)}))}targeting(){return d(this,void 0,void 0,(function*(){return yield this.init,i(this.dcn)}))}targetingFromCache(){return e=this.dcn,new a(e).getTargeting();var e}site(){return d(this,void 0,void 0,(function*(){return l(this.dcn)}))}siteFromCache(){return e=this.dcn,new a(e).getSite();var e}targetingClearCache(){var e;e=this.dcn,new a(e).clearTargeting()}lmpidFromCache(){return e=this.dcn,new a(e).getLmpid();var e}prebidORTB2(){return d(this,void 0,void 0,(function*(){return n(yield this.targeting())}))}prebidORTB2FromCache(){return n(this.targetingFromCache())}targetingKeyValues(){return d(this,void 0,void 0,(function*(){return o(yield this.targeting())}))}targetingKeyValuesFromCache(){return o(this.targetingFromCache())}witness(e,t={}){return d(this,void 0,void 0,(function*(){return yield this.init,function(e,t,s){const r={event:t,properties:s};return c("/witness",e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}(this.dcn,e,t)}))}profile(e){return d(this,void 0,void 0,(function*(){return yield this.init,function(e,t){const s={traits:t};return c("/profile",e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})}(this.dcn,e)}))}static eid(e){return e?"e:"+h.sha256.hex(e.toLowerCase().trim()):""}static cid(e,t=0){let s="c:";if("string"!=typeof e)throw new Error("Invalid ppid");if("number"!=typeof t||isNaN(t)||t<0||t>9)throw new Error("Invalid variant");return t>0&&(s=`c${t}:`),e?s+e.trim():""}static TargetingKeyValues(e){return o(e)}static PrebidORTB2(e){return n(e)}}u.version=e;const p=u;class g{debug(){}info(){}warn(){}error(){}}const _=new g;class f extends g{constructor(e,t){super(),this._prefix=e,this._delegate=t}debug(...e){this._delegate.debug(this._prefix,...e)}info(...e){this._delegate.info(this._prefix,...e)}warn(...e){this._delegate.warn(this._prefix,...e)}error(...e){this._delegate.error(this._prefix,...e)}}const m="*",w=void 0;class S{_isId5Message=!0;id;timestamp;type;src;dst;request;payload;constructor(e,t,s,r,i,n,o){this.id=r,this.timestamp=e,this.src=t,this.dst=s,this.type=n,this.request=o,this.payload=i}}class C{_senderId;_messageSeqNb=0;constructor(e){this._senderId=e,this._messageSeqNb=0}createBroadcastMessage(e,t=e.constructor.name){return new S(Date.now(),this._senderId,w,++this._messageSeqNb,e,t||e.constructor.name)}createResponse(e,t,s=t.constructor.name){return new S(Date.now(),this._senderId,e.src,++this._messageSeqNb,t,s||t.constructor.name,e)}createUnicastMessage(e,t,s=t.constructor.name){return new S(Date.now(),this._senderId,e,++this._messageSeqNb,t,s||t.constructor.name)}}class y{static TYPE="HelloMessage";instance;instanceState;isResponse;constructor(e,t=!1,s){this.instance=e,this.instanceState=s,this.isResponse=t}}const v=Object.freeze({LEADER:"leader",FOLLOWER:"follower",STORAGE:"storage"});class I{static TYPE="RemoteMethodCallMessage";target;methodName;methodArguments;constructor(e,t,s){this.target=e,this.methodName=t,this.methodArguments=s}}class b{_targets={};_log;constructor(e=_){this._log=e}registerTarget(e,t){return this._targets[e]=t,this}_handle(e){const t=this._targets[e.target];if(t)try{t[e.methodName](...e.methodArguments)}catch(t){this._log.error("Error while handling method call ",e,t)}}}class E{_id;_messageFactory;_log;_onMessageCallBackFunction=void 0;constructor(e,t,s=_){this._id=e,this._messageFactory=new C(this._id),this._log=s,this._window=t,this._handlers={},this._register()}_register(){const e=this;e._abortController="undefined"!=typeof AbortController?new AbortController:void 0;const t=e._abortController?.signal;e._window.addEventListener("message",(t=>{let s=t.data;if(void 0!==t.data&&t.data._isId5Message){if(t.data.src===e._id)return void e._log.debug("Ignore loopback msg");if(void 0!==t.data.dst&&t.data.dst!==e._id)return void e._log.debug("Ignore msg not to me");try{[m,s.type].forEach((r=>{let i=e._handlers[r];i&&i.forEach((e=>e(s,t.source)))}))}catch(t){e._log.error("Error while handling message",s,t)}}}),{capture:!1,signal:t})}unregister(){this._abortController&&this._abortController.abort()}onAnyMessage(e){return this.onMessage(m,e)}onMessage(e,t){const s=this._handlers[e];return s?s.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,s=t.constructor.name){this._log.debug("Sending response message",e,s,t),this._postMessage(this._messageFactory.createResponse(e,t,s))}unicastMessage(e,t,s=t.constructor.name){this._log.debug("Sending message to",e,s,t),this._postMessage(this._messageFactory.createUnicastMessage(e,t,s))}_postToWindow(e,t){try{e.postMessage(t,"*")}catch(e){this._log.error("Could not post message to window",e)}}_postMessage(e){let t=this,s=function(r){try{t._postToWindow(r,e);let i=r.frames;if(i)for(let e=0;e<i.length;e++)s(i[e])}catch(e){t._log.error("Could not broadcast message",e)}};s(t._window.top)}callProxyMethod(e,t,s,r){this._log.info("Calling ProxyMethodCall",{target:t,name:s,args:r}),this.unicastMessage(e,new I(t,s,r),I.TYPE)}onProxyMethodCall(e){return this.onMessage(I.TYPE,(t=>{e._handle(Object.assign(new I,t.payload))}))}}function A(e,t){let s="^\\d+(\\.\\d+(\\.\\d+){0,1}){0,1}$";if(!e.match(s)||!t.match(s))return;let r=e.split("."),i=t.split("."),n=e=>parseInt(e)||0,o=(e,t)=>{let s=e-t;return 0===s?0:s<0?-1:1},a=o(n(r[0]),n(i[0]));if(0===a){let e=o(n(r[1]),n(i[1]));return 0===e?o(n(r[2]),n(i[2])):e}return a}const D=Object.prototype.toString;function T(e,t){return D.call(e)==="[object "+t+"]"}function R(e){return T(e,"Function")}function P(e){return T(e,"String")}function O(e){return T(e,"Array")}function x(e){return T(e,"Number")}function U(e){return T(e,"Object")}function F(e){return void 0!==e}function H(e,t){if(function(e){if(!e)return!0;if(O(e)||P(e))return!(e.length>0);for(let t in e)if(hasOwnProperty.call(e,t))return!1;return!0}(e))return;if(R(e.forEach))return e.forEach(t,this);let s=0,r=e.length;if(r>0)for(;s<r;s++)t(e[s],s,e);else for(s in e)hasOwnProperty.call(e,s)&&t.call(this,e[s],s)}function N(e,t,s,r={},i=_){try{let a,c=r.method||(s?"POST":"GET");document.createElement("a").href=e;let l="object"==typeof t&&null!==t?t:{success:function(){i.info("ajax","xhr success")},error:function(e){i.error("ajax","xhr error",null,e)}};if("function"==typeof t&&(l.success=t),a=new window.XMLHttpRequest,a.onreadystatechange=function(){if(4===a.readyState){let e=a.status;e>=200&&e<300||304===e?l.success(a.responseText,a):l.error(a.statusText,a)}},a.ontimeout=function(){i.error("ajax","xhr timeout after ",a.timeout,"ms")},"GET"===c&&s){let t=function(e,t){let s=document.createElement("a");t&&"noDecodeWholeURL"in t&&t.noDecodeWholeURL?s.href=e:s.href=decodeURIComponent(e);let r=t&&"decodeSearchAsString"in t&&t.decodeSearchAsString;return{href:s.href,protocol:(s.protocol||"").replace(/:$/,""),hostname:s.hostname,port:+s.port,pathname:s.pathname.replace(/^(?!\/)/,"/"),search:r?s.search:(i=s.search||"",i?i.replace(/^\?/,"").split("&").reduce(((e,t)=>{let[s,r]=t.split("=");return/\[\]$/.test(s)?(s=s.replace("[]",""),e[s]=e[s]||[],e[s].push(r)):e[s]=r||"",e}),{}):{}),hash:(s.hash||"").replace(/^#/,""),host:s.host||window.location.host};var i}(e,r);Object.assign(t.search,s),e=((n=t).protocol||"http")+"://"+(n.host||n.hostname+(n.port?`:${n.port}`:""))+(n.pathname||"")+(n.search?`?${o=n.search||"",Object.keys(o).map((e=>Array.isArray(o[e])?o[e].map((t=>`${e}[]=${t}`)).join("&"):`${e}=${o[e]}`)).join("&")}`:"")+(n.hash?`#${n.hash}`:"")}a.open(c,e,!0),r.withCredentials&&(a.withCredentials=!0),H(r.customHeaders,((e,t)=>{a.setRequestHeader(t,e)})),r.preflight&&a.setRequestHeader("X-Requested-With","XMLHttpRequest"),a.setRequestHeader("Content-Type",r.contentType||"text/plain"),"POST"===c&&s?a.send(s):a.send()}catch(e){i.error("ajax","xhr construction",e)}var n,o}function L(e,t=0){let s=function(e,t){if(R(Math.imul))return Math.imul(e,t);var s=(4194303&e)*(t|=0);return 4290772992&e&&(s+=(4290772992&e)*t|0),0|s},r=3735928559^t,i=1103547991^t;for(let t,n=0;n<e.length;n++)t=e.charCodeAt(n),r=s(r^t,2654435761),i=s(i^t,1597334677);return r=s(r^r>>>16,2246822507)^s(i^i>>>13,3266489909),i=s(i^i>>>16,2246822507)^s(r^r>>>13,3266489909),(4294967296*(2097151&i)+(r>>>0)).toString()}const k=Object.freeze({cmp:"cmp",partner:"partner",prebid:"prebid"}),M=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 V{version;localStoragePurposeConsent;applicableSections;gppString;constructor(e,t,s,r){this.version=e,this.localStoragePurposeConsent=t,this.applicableSections=s,this.gppString=r}isGranted(){return this.applicableSections.includes(2)?!0===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 j{apiTypes;gdprApplies;consentString;localStoragePurposeConsent;allowedVendors;ccpaString;forcedGrantByConfig;gppData;source;constructor(){this.apiTypes=[],this.gdprApplies=!1,this.consentString=void 0,this.localStoragePurposeConsent=!1,this.ccpaString=void 0,this.allowedVendors=void 0,this.forcedGrantByConfig=!1,this.gppData=void 0}localStorageGrant(){return!0===this.forcedGrantByConfig?new W(!0,G.FORCE_ALLOWED_BY_CONFIG):0===this.apiTypes.length?new W(!0,G.PROVISIONAL):this._getLocalStorageGrantFromApi()}_getLocalStorageGrantFromApi(){const e=this.apiTypes,t={};e.includes(M.TCF_V1)&&(t[M.TCF_V1]=!this.gdprApplies||!0===this.localStoragePurposeConsent),e.includes(M.TCF_V2)&&(t[M.TCF_V2]=!1===this.gdprApplies||!0===this.localStoragePurposeConsent),e.includes(M.ID5_ALLOWED_VENDORS)&&(t[M.ID5_ALLOWED_VENDORS]=this.allowedVendors.includes("131")),e.includes(M.USP_V1)&&(t[M.USP_V1]=!0),e.includes(M.GPP_V1_0)&&(t[M.GPP_V1_0]=this.gppData.isGranted()),e.includes(M.GPP_V1_1)&&(t[M.GPP_V1_1]=this.gppData.isGranted());const s=Object.keys(t).map((e=>t[e])).reduce(((e,t)=>e&&t),!0);return new W(s,G.CONSENT_API,t)}hashCode(){const{localStoragePurposeConsent:e,ccpaString:t,...s}=this;return L(JSON.stringify(s))}static createFrom(e){const t=Object.assign(new j,e);return F(t.api)&&(t.apiTypes=function(e){const t=e.api;if(t===M.NONE)return[];if(t===M.PREBID){const t=[];return(F(e.gdprApplies)||F(e.consentString))&&t.push(M.TCF_V2),F(e.ccpaString)&&t.push(M.USP_V1),F(e.gppData)&&F(e.gppData.version)&&t.push(e.gppData.version),t}return[t]}(e),t.api=void 0),U(t.gppData)&&(t.gppData=Object.assign(new V,t.gppData)),t}getApiTypeData(e){if(this.apiTypes.includes(e)){if(e===M.USP_V1)return{ccpaString:this.ccpaString};if(e===M.TCF_V2)return{consentString:this.consentString,gdprApplies:this.gdprApplies,localStoragePurposeConsent:this.localStoragePurposeConsent};if(e===M.GPP_V1_1||e===M.GPP_V1_0)return this.gppData;if(e===M.ID5_ALLOWED_VENDORS)return{allowedVendors:this.allowedVendors}}}}const G=Object.freeze({FORCE_ALLOWED_BY_CONFIG:"force_allowed_by_config",ID5_CONSENT:"id5_consent",PROVISIONAL:"provisional",JURISDICTION:"jurisdiction",CONSENT_API:"consent_api"});class W{allowed=!1;grantType=G.NONE;api={};constructor(e,t,s={}){this.allowed=e,this.grantType=t,this.api=s}isDefinitivelyAllowed(){return this.allowed&&this.grantType!==G.PROVISIONAL}}class B{getConsentData(){}localStorageGrant(){}setStoredPrivacy(){}}const X=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 J{constructor(e,t){this.name=e,this.expiresDays=t}withNameSuffixed(...e){let t=this.name;for(const s of e)t+=`_${s}`;return new J(t,this.expiresDays)}}class q{constructor(e){let t=X.STORAGE_CONFIG,s=function(t){let s=void 0!==e?Math.max(1,e):t.expiresDays;return new J(t.name,s)};this.ID5=s(t.ID5),this.ID5_V2=s(t.ID5_V2),this.LAST=s(t.LAST),this.CONSENT_DATA=s(t.CONSENT_DATA),this.PRIVACY=s(t.PRIVACY)}static DEFAULT=new q}class ${_clientStore;constructor(e){this._clientStore=e}hasConsentChanged(e){return e&&!this._clientStore.storedConsentDataMatchesConsentData(e)}storeConsent(e){this._clientStore.putHashedConsentData(e)}incNb(e,t=1){this._clientStore.incNbV2(e,t)}updateNbs(e){for(const[t,s]of e){const e=s?.nb;e>0&&this.incNb(t,-e)}}storeResponse(e,t){this._clientStore.putResponseV1(t.getGenericResponse()),this._clientStore.setResponseDateTimeV1(new Date(t.timestamp).toUTCString());const s=new Set;e.forEach((e=>{const r=e.cacheId;if(!s.has(r)){const i=t.getResponseFor(e.integrationId);i&&(this._clientStore.storeResponseV2(r,i,t.timestamp),s.add(r))}}))}clearAll(e){this._clientStore.clearResponse(),this._clientStore.clearDateTime(),e.forEach((e=>{const t=e.cacheId;this._clientStore.clearResponseV2(t)})),this._clientStore.clearHashedConsentData()}getCachedResponse(e){const t=this._clientStore.getStoredResponseV2(e);if(t)return new K(t.response,t.responseTimestamp,t.nb)}}class K{response;timestamp;nb;constructor(e,t,s=0){this.response=e,this.timestamp=t,this.nb=s}isExpired(){const e=this.getMaxAge();return!(x(e)&&e>0)||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)&&P(this.response.universal_uid)&&P(this.response.signature)}isValid(){return this.isResponseComplete()&&!this.isStale()}getMaxAge(){return this.response?.cache_control?.max_age_sec}}const z="_exp",Y=864e5;class Q{storage;_log;constructor(e,t=_){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(e,t=!1){this._log.info("Check, prefix",e);try{const s=this.storage.getKeysWithPrefix(e);let r=0;for(const e of s)if(t)this._log.info("Found",e," remove it"),this.removeItem(e);else{const t=this.getObjectWithExpiration({name:e})?.expireAt;t&&t<Date.now()&&(this._log.info("Found expired object",e,"expiration time",t,"It will be removed"),this.removeItem(e),r+=1)}return{all:s.length,expired:r}}catch(e){}}getItemWithExpiration({name:e}){const t=this.getItem(e+z);return!t||new Date(t).getTime()-Date.now()<=0?(this.removeItemWithExpiration({name:e}),null):this.getItem(e)}setItemWithExpiration({name:e,expiresDays:t},s){const r=Date.now()+t*Y,i=new Date(r).toUTCString();this.setItem(e+z,i),this.setItem(e,s)}removeItemWithExpiration({name:e}){this.removeItem(e),this.removeItem(e+z)}setObjectWithExpiration({name:e,expiresDays:t},s){const r={data:s,expireAt:Date.now()+t*Y};this.setItem(e,JSON.stringify(r))}getObjectWithExpiration({name:e}){try{const t=JSON.parse(this.getItem(e));if(t.expireAt&&t.expireAt-Date.now()>0)return t.data;t.expireAt&&this.removeItem(e)}catch(t){this._log.error("Error while getting ",e,"object from storage",t)}}updateObjectWithExpiration({name:e,expiresDays:t},s){try{const r=s(this.getObjectWithExpiration({name:e}));return this.setObjectWithExpiration({name:e,expiresDays:t},r),r}catch(t){this._log.error("Error while updating object with ",e,t)}}}class Z{getItem(){}removeItem(){}setItem(){}getKeysWithPrefix(){return[]}}const ee=new Z;class te extends Z{_writingEnabled;_underlying;constructor(e,t=!0){super(),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(e){try{const t=this._underlying.length;if(this._writingEnabled){const s=[];for(let r=0;r<t;r++){const t=this._underlying.key(r);t&&t.startsWith(e)&&s.push(t)}return s}}catch(e){}}static checkIfAccessible(){const e="__id5test";try{return window.localStorage.setItem(e,e),window.localStorage.removeItem(e),!0}catch(e){return!1}}}class se{_replicas=[];_lastKeyOperation={};_primaryStorage;constructor(e){this._primaryStorage=e}getItem(e){return this._primaryStorage.getItem(e)}removeItem(e){this._primaryStorage.removeItem(e);const t=t=>{t.removeItem(e)};this._replicas.forEach(t),this._lastKeyOperation[e]=t}setItem(e,t){this._primaryStorage.setItem(e,t);const s=s=>{s.setItem(e,t)};this._replicas.forEach(s),this._lastKeyOperation[e]=s}addReplica(e){Object.values(this._lastKeyOperation).forEach((t=>t(e))),this._replicas.push(e)}getKeysWithPrefix(e){return this._primaryStorage.getKeysWithPrefix(e)}}const re="undefined"!=typeof Promise&&"undefined"!=typeof fetch;class ie{constructor(e,t){this.url=e||"https://diagnostics.id5-sync.com/measurements",this._metadata=t}publish(e,t){return e&&e.length>0?(e.forEach((e=>{return t=e.tags,void Object.keys(t).forEach((function(e){let s=t[e];s&&(t[e]=s instanceof Object?JSON.stringify(s):`${s}`)}));var t})),fetch(this.url,{method:"POST",headers:{"Content-Type":"text/plain"},mode:"no-cors",body:JSON.stringify({metadata:{...this._metadata,...t},measurements:e})})):Promise.resolve()}}const ne=Object.freeze({}),oe=function(e){return e?e instanceof Map?Object.fromEntries(e):e:ne},ae=function(e){return Array.from(Object.entries(e),(([e,t])=>`${e}=${t}`)).sort().toString()},ce=Object.freeze({TIMER:"TIMER",SUMMARY:"SUMMARY",COUNTER:"COUNTER"});class le{name;tags;values;constructor(e,t,s){this.name=e,this.tags=oe(t),this.type=s,this.values=[]}reset(){this.values=[]}}class he extends le{constructor(e,t){super(e,t,ce.TIMER)}startMeasurement(){try{return new de(this)}catch(e){return}}record(e){try{isNaN(e)||this.values.push({value:e,timestamp:Date.now()})}catch(e){}}recordNow(){try{this.record(0|performance?.now())}catch(e){}}}class de{constructor(e){this.timer=e,this.startTime=performance.now()}record(e){try{let t=performance.now()-this.startTime|0,s=e||this.timer;return s&&s.record(t),t}catch(e){return}}}class ue extends le{constructor(e,t){super(e,t,ce.COUNTER)}inc(e=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 pe extends le{constructor(e,t){super(e,t,ce.SUMMARY)}record(e){try{this.values.push({value:e,timestamp:Date.now()})}catch(e){}}}class ge{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])=>e))}}class _e{_registry;commonTags;_scheduled;constructor(e,t){this._registry=new ge,this.commonTags=oe(e),this.commonPrefix=t}getOrCreate(e,t,s){let r={...t,...this.commonTags},i=this.commonPrefix?this.commonPrefix+"."+e:e;const n=`${i}[${ae(r)}]`;return this._registry.has(n)||this._registry.set(n,s(i,r)),this._registry.get(n)}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&&e.values.length>0}))}reset(){Array.from(this._registry.values()).forEach((e=>e.reset()))}addCommonTags(e){this.commonTags={...this.commonTags,...oe(e)}}timer(e,t={}){return this.getOrCreate(e,t,((e,t)=>new he(e,t)))}counter(e,t={}){return this.getOrCreate(e,t,((e,t)=>new ue(e,t)))}summary(e,t={}){return this.getOrCreate(e,t,((e,t)=>new pe(e,t)))}publish(e=(e=>e),t){return Promise.resolve(this.getAllMeasurements()).then((s=>e(s,t))).then((()=>this.reset()))}schedulePublishAfterMsec(e,t){if(!this._scheduled){let s=this;setTimeout((()=>(s._scheduled=!1,s.publish(t,{trigger:"fixed-time",fixed_time_msec:e}))),e),this._scheduled=!0}return this}schedulePublishBeforeUnload(e){const t=this,s="undefined"!=typeof AbortController?new AbortController:void 0;return s&&(s.publisher=e,addEventListener("beforeunload",(()=>t.publish(e,{trigger:"beforeunload"})),{capture:!1,signal:s.signal}),this._onUnloadPublishAbortController=s),this}unregister(){const e=this._onUnloadPublishAbortController;if(e)return e.abort(),this.publish(e.publisher,{trigger:"unregister"})}}function fe(){return new de}function me(e){return{partner:e}}class we extends _e{constructor(e,t,s,r){super({source:e,version:t,...me(s),...r},"id5.api")}loadDelayTimer(e={}){return this.timer("instance.load.delay",e)}fetchCallTimer(e,t={}){return this.timer("fetch.call.time",{status:e,...t})}fetchFailureCallTimer(e={}){return this.fetchCallTimer("fail",e)}fetchSuccessfulCallTimer(e={}){return this.fetchCallTimer("success",e)}extensionsCallTimer(e,t,s={}){return this.timer("extensions.call.time",{extensionType:e,status:t?"success":"fail",...s})}consentRequestTimer(e,t={}){return this.timer("consent.request.time",{requestType:e,...t})}invocationCountSummary(e={}){return this.summary("invocation.count",e)}instanceCounter(e,t={}){return this.counter("instance.count",{instanceId:e,...t})}instanceUniqueDomainsCounter(e,t={}){return this.counter("instance.domains.count",{instanceId:e,...t})}instanceUniqWindowsCounter(e,t={}){return this.counter("instance.windows.count",{instanceId:e,...t})}instanceUniqPartnersCounter(e,t={}){return this.counter("instance.partners.count",{instanceId:e,...t})}instanceJoinDelayTimer(e={}){return this.timer("instance.join.delay.time",e)}instanceLateJoinCounter(e,t={}){return this.counter("instance.lateJoin.count",{instanceId:e,...t})}instanceLateJoinDelayTimer(e={}){return this.timer("instance.lateJoin.delay",{...e})}instanceLastJoinDelayTimer(e={}){return this.timer("instance.lastJoin.delay",{...e})}instanceMsgDeliveryTimer(e={}){return this.timer("instance.message.delivery.time",e)}userIdProvisioningDelayTimer(e,t={}){return this.timer("userid.provisioning.delay",{cachedResponseUsed:e,...t})}userIdNotificationDeliveryDelayTimer(e={}){return this.timer("userid.provisioning.delivery.delay",{...e})}consentChangeCounter(e={}){return this.counter("leader.consent.change.count",e)}consentIgnoreCounter(e={}){return this.counter("leader.consent.ignore.count",e)}storageAllKeysCounter(e={}){return this.summary("storage.keys.all.count",e)}storageExpiredKeysCounter(e={}){return this.summary("storage.keys.expired.count",e)}instanceSurvivalTime(e={}){return this.timer("instance.survival.time",e)}localStorageGrantCounter(e={}){return this.counter("consent.lsg.count",e)}consentDiscrepancyCounter(e={}){return this.counter("consent.discrepancy.count",e)}refreshCallCounter(e,t={}){return this.counter("refresh.call.count",{target:e,...t})}}class Se{timestamp;response;constructor(e,t=Date.now()){this.response=e,this.timestamp=t}getGenericResponse(){return this.response.generic}getResponseFor(e){if(this.response?.responses&&this.response?.responses[e])return{...this.response.generic,...this.response.responses[e]}}}class Ce{_extensionsProvider;_metrics;_log;constructor(e,t,s){this._extensionsProvider=s,this._metrics=e,this._log=t}fetchId(e,t,s){return this._extensionsProvider.gather(e).then((r=>{const i=e.map((e=>{const i=e.cacheData,n=i?.response?.signature,o=i?.nb,a=i?.getMaxAge();return this._createRequest(t,e,n,o,a,r,s)})),n=this._log,o=this._metrics,a=this;return new Promise(((e,t)=>{const s=fe(),r="https://id5-sync.com/gm/v3";n.info("Fetching ID5 ID from:",r,i),N(r,{success:function(r){n.info("Success at fetch call:",r),s.record(o?.fetchSuccessfulCallTimer());try{e(new Se(a._validateResponse(r)))}catch(e){t(e)}},error:function(e){s.record(o?.fetchFailureCallTimer()),t(e)}},JSON.stringify({requests:i}),{method:"POST",withCredentials:!0},n)}))}))}_validateResponse(e){if(!e||!P(e)||e.length<1)throw new Error(`Empty fetch response from ID5 servers: "${e}"`);const t=JSON.parse(e);if(!U(t.generic))throw new Error(`Server response failed to validate: ${e}`);return this._log.info("Valid json response from ID5 received",t),t}_createRequest(e,t,s,r,i,n,o){this._log.info("Create request data for",{fetchIdData:t,consentData:e,signature:s,nbValue:r,refreshInSecondUsed:i,extensions:n});const a=t.partnerId,c={requestId:t.integrationId,requestCount:t.requestCount,role:t.role,cacheId:t.cacheId,refresh:t.refresh,partner:a,v:t.originVersion,o:t.origin,tml:t.refererInfo?.topmostLocation,ref:t.refererInfo?.ref,cu:t.refererInfo?.canonicalUrl,u:t.refererInfo?.stack[0]||window.location.href,top:t.refererInfo?.reachedTop?1:0,localStorage:!0===o?1:0,nbPage:r,id5cdn:t.isUsingCdn,ua:window.navigator.userAgent,att:t.att},l=e.gdprApplies;F(l)&&(c.gdpr=l?1:0);const h=e.consentString;F(h)&&(c.gdpr_consent=h),F(t.allowedVendors)?c.allowed_vendors=t.allowedVendors:F(e.allowedVendors)&&(c.allowed_vendors=e.allowedVendors),F(e.gppData)&&(c.gpp_string=e.gppData.gppString,c.gpp_sid=e.gppData.applicableSections.join(",")),F(s)&&(c.s=s);const d=t.uaHints;F(d)&&(c.ua_hints=d),F(e.ccpaString)&&""!==e.ccpaString&&(c.us_privacy=e.ccpaString),function(e){let t=Object.keys(e),s=t.length,r=new Array(s);for(;s--;)r[s]=[t[s],e[t[s]]];return r}({pd:"pd",partnerUserId:"puid",provider:"provider",segments:"segments"}).forEach((e=>{const[s,r]=e;F(t[s])&&(c[r]=t[s])}));const u=t.abTesting;u&&!0===u.enabled&&(c.ab_testing={enabled:!0,control_group_pct:u.controlGroupPct});const p=t.invalidSegmentsCount;return p&&p>0&&(c._invalid_segments=p),t.trace&&(c._trace=!0),c.provided_options={refresh_in_seconds:t.providedRefreshInSeconds},c.used_refresh_in_seconds=i,c.extensions=n,c}}class ye{lateJoiner=!1;uniqueLateJoiner=!1;constructor(e=!1,t=!1){this.lateJoiner=e,this.uniqueLateJoiner=t}}class ve{updateConsent(){}updateFetchIdData(){}refreshUid(){}addFollower(){}getProperties(){}}class Ie extends ve{_followers;_followersRequests={};_refreshRequired={};_fetcher;_log;_consentManager;_inProgressFetch;_queuedRefreshArgs;_lastConsentDataSet;_metrics;_leaderStorage;_store;constructor(e,t,s,r,i,n,o=_,a){super(),this._followers=[],this._fetcher=a,this._properties=t,this._consentManager=i,this._metrics=n,this._window=e,this._leaderStorage=s,this._log=o,this._store=r,this._firstFetchTriggered=!1}_handleRefreshResult(e,t,s,r){const i=this._log,n=this._consentManager,o=this._store;if(void 0!==r){n.setStoredPrivacy(r.getGenericResponse()?.privacy);const a=n.localStorageGrant("fetcher-after-response");a.isDefinitivelyAllowed()?(i.info("Storing ID and request hashes in cache"),o.updateNbs(t),o.storeResponse(e,r)):(i.info("Cannot use local storage to cache ID",a),o.clearAll(e));for(const t of e){const e=t.integrationId;this._followersRequests[e]=(this._followersRequests[e]||0)+1}const c=[];for(const e of this._followers){const t=r.getResponseFor(e.getId());void 0!==t&&(this._log.debug("Notify uid ready.","Follower:",e.getId(),"Uid:",t),this._refreshRequired[e.getId()]=!1,this._notifyUidReady(e,{timestamp:r.timestamp,responseObj:t,isFromCache:!1}),!0===t.cascade_needed&&c.push(e.getId()))}void 0!==s&&c.length>0&&this._consentManager.localStorageGrant("leader-before-cascade").isDefinitivelyAllowed()&&this._handleCascade(c,r,s)}}_notifyUidReady(e,t,s=!1){const r={timestamp:Date.now(),tags:{lateJoiner:s,callType:e.callType}};e.notifyUidReady(t,r)}_handleCascade(e,t,s){const r=this._followers.filter((t=>void 0!==e.find((e=>t.getId()===e))&&t.canDoCascade())).sort(((e,t)=>{const s=function(e){return e.getFetchIdData().refererInfo?.stack?.length||Number.MAX_SAFE_INTEGER};return s(e)-s(t)}));if(r.length>0){const e=r[0];e.notifyCascadeNeeded({partnerId:e.getFetchIdData().partnerId,userId:t.getResponseFor(e.getId()).universal_uid,gdprApplies:s.gdprApplies,consentString:s.consentString,gppString:s.gppData?.gppString,gppSid:s.gppData?.applicableSections?.join(",")})}else this._log.error("Couldn't find cascade eligible follower")}_handleCancel(e){for(const t of this._followers)t.notifyFetchUidCanceled({reason:e})}_getId(e=!1){const t=this._log;this._waitForConsent().then((s=>{const r=this._consentManager.localStorageGrant("fetch-before-request");if(t.info("Local storage grant",r),r.allowed){const i=this._store,n=this._store.hasConsentChanged(s);r.isDefinitivelyAllowed()&&i.storeConsent(s);const o=te.checkIfAccessible(),a=new Map;let c=e;const l=this._followers.map((e=>{const t=e.getId(),s=(this._followersRequests[t]||0)+1,r=this._properties.id,i=!0===this._refreshRequired[e.getId()];c=c||i;const n=e.getCacheId();if(!a.has(n)){const e=this._store.getCachedResponse(n);e&&a.set(n,e)}return{...e.getFetchIdData(),integrationId:t,requestCount:s,refresh:i,role:r===e.getId()?"leader":"follower",cacheId:n,cacheData:a.get(n)}}));n||c?(t.info("Decided to fetch a fresh ID5 ID",{consentHasChanged:n,shouldRefresh:c}),t.info(`Fetching ID5 ID (forceFetch:${e})`),this._inProgressFetch=!0,this._firstFetchTriggered=!0,this._fetcher.fetchId(l,s,o).then((e=>{this._handleRefreshResult(l,a,s,e),this._handleFetchCompleted()})).catch((e=>{this._handleFailed(e),this._handleFetchCompleted()}))):(t.info("Not decided to refresh ID5 ID",{consentHasChanged:n,shouldRefresh:c}),this._handleFetchCompleted())}else t.info("No legal basis to use ID5",s),this._handleCancel("No legal basis to use ID5")}))}_waitForConsent(){const e=this._log,t=this._consentManager,s=this._metrics;e.info("Waiting for consent");const r=s.timer("fetch.consent.wait.time");return t.getConsentData().then((t=>(e.info("Consent received",t),r&&r.recordNow(),t)))}start(){!0!==this._started&&(this._getId(!1),this._started=!0)}refreshUid(e={},t){const s=!0===e.forceFetch;if(t)if(s)this._refreshRequired[t]=!0;else{const e=this._followers.find((e=>e.getId()===t));e&&this._provisionFromCache(e)}this._metrics.refreshCallCounter("leader",{overwrites:void 0===this._queuedRefreshArgs}).inc(),this._callRefresh(e,t)}_callRefresh(e={},t){this._inProgressFetch?this._queuedRefreshArgs=[e,t]:(!0===e.resetConsent&&(this._consentManager.resetConsentData(!0===e.forceAllowLocalStorageGrant),this._awaitedConsentFrom=t),this._getId(!0===e.forceFetch))}updateConsent(e,t){if(this._consentManager.hasConsentSet())this._handleIgnoredConsentUpdate(e);else{const s=new Set(this._followers.map((e=>e.getDeclaredConsentSource()))),r=e.source||k.cmp,i=1===s.size&&s.has(k.partner);this._awaitedConsentFrom?this._awaitedConsentFrom===t?(this._consentManager.setConsentData(e),this._awaitedConsentFrom=void 0):this._handleIgnoredConsent(e,"awaited"):r!==k.partner||i?this._consentManager.setConsentData(e):this._handleIgnoredConsent(e,"partner")}}_handleIgnoredConsentUpdate(e){try{const t=this._consentManager._consentDataHolder.getValue();if(t){const s={},r=j.createFrom(e);Object.values(M).forEach((e=>{if(r.apiTypes.includes(e)&&t.apiTypes.includes(e)){const i=JSON.stringify(t.getApiTypeData(e)),n=JSON.stringify(r.getApiTypeData(e));s[e]=i===n?"same":"different"}else r.apiTypes.includes(e)?s[e]="added":t.apiTypes.includes(e)&&(s[e]="missed")})),this._metrics.consentChangeCounter(s).inc()}}catch(e){this._log.error(e)}}_handleIgnoredConsent(e,t){try{const s={reason:t,source:e.source};e.apiTypes.forEach((e=>s[e]=!0)),this._metrics.consentIgnoreCounter(s)}catch(e){this._log.error(e)}}updateFetchIdData(e,t){const s=this._followers.find((t=>t.getId()===e)),r=s.getCacheId();s.updateFetchIdData(t);const i=s.getCacheId();i!==r&&(this._log.info("Follower",s.getId(),"cacheId changed from",r," to",i,"required refresh"),this._refreshRequired[s.getId()]=!0)}addFollower(e){const t=this._log,s=void 0===this._followers.find((t=>t.getCacheId()===e.getCacheId()));if(this._followers.push(e),t.info("Added follower",e.getId(),"cacheId",e.getCacheId()),this._window!==e.getWindow()){const s=e.getStorage();t.info("Adding follower's",e.getId(),"storage as replica"),this._leaderStorage.addReplica(s)}const r=this._provisionFromCache(e);let i=new ye;return!0===this._firstFetchTriggered&&(i.lateJoiner=!0,i.uniqueLateJoiner=s,r&&this._callRefresh({forceFetch:!0})),i}_provisionFromCache(e){const t=this._log,s=e.getCacheId(),r=this._store.getCachedResponse(s),i=!r||!r.isValid()||r.isExpired();return this._refreshRequired[e.getId()]=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,willBeRefreshed:!!i}),this._store.incNb(s)):t.info("Couldn't find response for cacheId",e.getCacheId()),i}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);for(const e of this._followers)e.notifyFetchUidCanceled({reason:"error"})}}class be extends ve{_messenger;_leaderInstanceProperties;constructor(e,t){super(),this._messenger=e,this._leaderInstanceProperties=t}_sendToLeader(e,t){this._messenger.callProxyMethod(this._leaderInstanceProperties.id,v.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 Ee extends ve{_callsQueue=[];_assignedLeader;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;for(const e of this._callsQueue)this._callAssignedLeader(e.name,e.args);this._callsQueue=[]}_callOrBuffer(e,t){return this._assignedLeader?this._callAssignedLeader(e,t):void this._callsQueue.push({name:e,args:t})}_callAssignedLeader(e,t){return this._assignedLeader[e](...t)}}const Ae=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"}),De=Object.freeze({ID5_MESSAGE_RECEIVED:"message",ID5_INSTANCE_JOINED:"instance-joined",ID5_LEADER_ELECTED:"leader-elected"}),Te=Object.freeze([...Object.values(De),...Object.values(Ae)]);class Re{_handlers;_log;constructor(e=_){this._log=e,this._handlers={}}_dispatch(e,...t){const s=this._handlers[e];if(s)for(const r of s)try{r(...t)}catch(t){this._log.error(`Event ${e} handler execution failed.`,t)}}emit(e,...t){void 0!==e&&Te.includes(e)?this._dispatch(e,...t):this._log.warn("Unsupported event",e)}on(e,t){void 0!==e&&Te.includes(e)?(this._handlers[e]||(this._handlers[e]=[]),this._handlers[e].push(t)):this._log.warn("Unsupported event",e)}}const Pe=Object.freeze({DIRECT_METHOD:"direct_method",POST_MESSAGE:"post_message"});class Oe{_instanceProperties;_log;callType;_instanceWindow;constructor(e,t,s,r=_){this._instanceWindow=t,this._instanceProperties=s,this._log=r,this.callType=e}getId(){return this._instanceProperties.id}getFetchIdData(){return this._instanceProperties.fetchIdData}updateFetchIdData(e){Object.assign(this._instanceProperties.fetchIdData,e)}getCacheId(){const e=this._instanceProperties.fetchIdData,t={partnerId:e.partnerId,att:e.att,pd:e.pd,provider:e.provider,abTesting:e.abTesting,segments:JSON.stringify(e.segments),providedRefresh:e.providedRefreshInSeconds};return L(JSON.stringify(t))}getDeclaredConsentSource(){return this._instanceProperties.fetchIdData.consentSource||k.cmp}notifyUidReady(){}notifyFetchUidCanceled(){}notifyCascadeNeeded(){}canDoCascade(){return!0===this._instanceProperties.canDoCascade}getStorage(){return ee}getWindow(){return this._instanceWindow}}class xe extends Oe{_dispatcher;constructor(e,t,s,r=_){super(Pe.DIRECT_METHOD,e,t,r),this._dispatcher=s}notifyUidReady(e,t){this._dispatcher.emit(Ae.USER_ID_READY,e,t)}notifyFetchUidCanceled(e){this._dispatcher.emit(Ae.USER_ID_FETCH_CANCELED,e)}notifyCascadeNeeded(e){this._dispatcher.emit(Ae.CASCADE_NEEDED,e)}}class Ue extends Z{_messenger;_destinationId;constructor(e,t){super(),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,v.STORAGE,e,t)}}class Fe extends Oe{_messenger;constructor(e,t,s=_){super(Pe.POST_MESSAGE,e.getWindow(),e.properties,s),this._messenger=t}_callProxy(e,t){this._messenger.callProxyMethod(this.getId(),v.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 Ue(this._messenger,this.getId())}}class He{_valuePromise;_value;_resolve;_hasValue;constructor(){this.reset()}reset(){this._value=void 0,this._hasValue=!1,this._valuePromise=new Promise((e=>{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 Ne extends B{_consentDataHolder;storedPrivacyData;localStorage;_forceAllowLocalStorageGrant;constructor(e,t,s,r,i){super(),this._log=r,this.localStorage=e,this.storageConfig=t,this._consentDataHolder=new He,this._forceAllowLocalStorageGrant=s,this._metrics=i}isForceAllowLocalStorageGrant(){return this._forceAllowLocalStorageGrant}resetConsentData(e){this._consentDataHolder.reset(),this.storedPrivacyData=void 0,this._forceAllowLocalStorageGrant=e}localStorageGrant(e="unknown"){const t=this._getLocalStorageGrant();return this._metrics?.localStorageGrantCounter({allowed:t.allowed,grantType:t.grantType,lsgContext:e,consentSet:this._consentDataHolder?.hasValue(),...t.api})?.inc(),t}_getLocalStorageGrant(){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 W(!0,G.FORCE_ALLOWED_BY_CONFIG);if(!this._consentDataHolder.hasValue()||0===this._consentDataHolder.getValue().apiTypes.length){if(!U(this.storedPrivacyData)){const 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)}if(this.storedPrivacyData&&!0===this.storedPrivacyData.id5_consent)return new W(!0,G.ID5_CONSENT);if(!this.storedPrivacyData||!F(this.storedPrivacyData.jurisdiction))return new W(!0,G.PROVISIONAL);const t=this.storedPrivacyData.jurisdiction,s=t in X.PRIVACY.JURISDICTIONS&&X.PRIVACY.JURISDICTIONS[t];return new W(!1===s,G.JURISDICTION)}return this._consentDataHolder.getValue().localStorageGrant()}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);let t=j.createFrom(e);this._consentDataHolder.set(t)}getConsentData(){return this._consentDataHolder.getValuePromise()}hasConsentSet(){return this._consentDataHolder.hasValue()}}class Le{localStorageGrantChecker;localStorage;_log;constructor(e,t,s,r){this.localStorageGrantChecker=e,this.localStorage=t,this.storageConfig=s,this._log=r}get(e){const t=this._log;try{const s=this.localStorageGrant();if(s.isDefinitivelyAllowed()){let s=this.localStorage.getItemWithExpiration(e);return t.info(`Local storage get key=${e.name} value=${s}`),s}t.warn("clientStore.get() has been called without definitive grant",s)}catch(e){t.error(e)}}_getObject(e){const t=this._log;try{const s=this.localStorageGrant();if(s.isDefinitivelyAllowed()){let s=this.localStorage.getObjectWithExpiration(e);return t.info(`Local storage get key=${e.name} value=${s}`),s}t.warn("clientStore.get() has been called without definitive grant",s)}catch(e){t.error(e)}}clear(e){const t=this._log;try{this.localStorage.removeItemWithExpiration(e)}catch(e){t.error(e)}}scheduleGC(e){const t=this.localStorageGrant(),s=this.localStorage,r=this.storageConfig.ID5_V2.name;setTimeout((function(){if(t.isDefinitivelyAllowed()){const t=s.removeExpiredObjectWithPrefix(r);e.storageAllKeysCounter().record(t?.all||0),e.storageExpiredKeysCounter().record(t?.expired||0)}}),0)}_clearObject(e){const t=this._log;try{this.localStorage.removeItem(e.name)}catch(e){t.error(e)}}_put(e,t){const s=this._log;try{const r=this.localStorageGrant();r.isDefinitivelyAllowed()?(s.info(`Local storage put key=${e.name} value=${t}`),this.localStorage.setItemWithExpiration(e,t)):s.warn("clientStore._put() has been called without definitive grant",r)}catch(e){s.error(e)}}_updateObject(e,t){const s=this._log;try{const r=this.localStorageGrant();if(r.isDefinitivelyAllowed())return this.localStorage.updateObjectWithExpiration(e,t);s.warn("clientStore._updateObject() has been called without definitive grant",r)}catch(e){s.error(e)}}localStorageGrant(){return this.localStorageGrantChecker()}getResponse(){let e=this.get(this.storageConfig.ID5);return e?JSON.parse(decodeURIComponent(e)):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(P(e)?e:JSON.stringify(e)))}getHashedConsentData(){return this.get(this.storageConfig.CONSENT_DATA)}clearHashedConsentData(){this.clear(this.storageConfig.CONSENT_DATA)}putHashedConsentData(e){e!==new j&&this._put(this.storageConfig.CONSENT_DATA,e.hashCode())}static makeStoredHash(e){return L("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,s=Date.now()){return this._updateObject(this.storageConfig.ID5_V2.withNameSuffixed(e),(e=>({...e,response:t,responseTimestamp:s})))}getStoredResponseV2(e){return this._getObject(this.storageConfig.ID5_V2.withNameSuffixed(e))}incNbV2(e,t=1){return this._updateObject(this.storageConfig.ID5_V2.withNameSuffixed(e),(e=>{const s=Math.max(0,x(e?.nb)?Math.round(e.nb)+t:t);return{...e,nb:s}}))}static storedDataMatchesCurrentData(e,t){return null==e||e===t}storedConsentDataMatchesConsentData(e){return Le.storedDataMatchesCurrentData(this.getHashedConsentData(),e.hashCode())}}class ke{_metrics;_log;constructor(e,t){this._metrics=e,this._log=t}static CHUNKS_CONFIGS=Object.freeze({devChunks:{name:"devChunks",urlVersion:3,length:8,version:4},groupChunks:{name:"groupChunks",urlVersion:4,length:8,version:4}});static DEFAULT_RESPONSE={lbCDN:"%%LB_CDN%%"};static getChunkUrl(e,t){return`https://c${e}.eu-${t}-id5-sync.com`}submitExtensionCall(e,t){let s=fe();return fetch(e).then((r=>{if(r.ok)return s.record(this._metrics.extensionsCallTimer(t,!0)),r.json();{s.record(this._metrics.extensionsCallTimer(t,!1));let i=`The call to get extensions at ${e} was not ok, status: ${r.status}, statusText: ${r.statusText}`;return this._log.warn(i),Promise.reject(new Error(i))}})).catch((r=>(s.record(this._metrics.extensionsCallTimer(t,!1)),this._log.warn(`Got error from ${e} endpoint`,r),{})))}gatherChunks(e,t){if(e){let e=fe();return Promise.all(Array.from({length:t.length},((e,s)=>{const r=ke.getChunkUrl(s,t.urlVersion);return fetch(r).then((e=>{if(e.ok)return e.text();throw new Error(`The call to get ${t.name} was not ok, status: ${e.status}, statusText: ${e.statusText}`)}))}))).then((s=>(e.record(this._metrics.extensionsCallTimer(t.name,!0)),{[t.name]:s,[t.name+"Version"]:`${t.version}`}))).catch((s=>(e.record(this._metrics.extensionsCallTimer(t.name,!1)),this._log.warn(`Got error when getting ${t.name}`,s),{})))}return Promise.resolve({})}gather(e){let t=fe();return this.submitExtensionCall("https://lb.eu-1-id5-sync.com/lb/v1","lb").then((t=>{let s=this.getChunksEnabled(e,t);return Promise.allSettled([Promise.resolve(t),this.gatherChunks(s,ke.CHUNKS_CONFIGS.devChunks),this.gatherChunks(s,ke.CHUNKS_CONFIGS.groupChunks)])})).then((e=>{t.record(this._metrics.extensionsCallTimer("all",!0));let s=ke.DEFAULT_RESPONSE;return e.forEach((e=>{e.value&&(s={...s,...e.value})})),s})).catch((e=>(t.record(this._metrics.extensionsCallTimer("all",!1)),this._log.error(`Got error ${e} when gathering extensions data`),ke.DEFAULT_RESPONSE)))}getChunksEnabled(e,t){let s=e.some((e=>e.pd&&""!==e.pd.trim())),r=t?.chunks;return 0!==r&&(s||r)}}const Me=Object.freeze({UNKNOWN:"unknown",LEADER:"leader",FOLLOWER:"follower"}),Ve=Object.freeze({MULTIPLEXING:"multiplexing",SINGLETON:"singleton"}),je=Object.freeze({AWAITING_SCHEDULE:"awaiting_schedule",SKIPPED:"skipped",SCHEDULED:"scheduled",COMPLETED:"completed",CANCELED:"canceled"});class Ge{properties;knownState;_joinTime;_window;constructor(e,t,s){this.properties=e,this.knownState=t,this._window=s,this._joinTime=performance.now()}getId(){return this.properties.id}isMultiplexingPartyAllowed(){return this.knownState?.operatingMode===Ve.MULTIPLEXING}getInstanceMultiplexingLeader(){if(this.knownState?.operatingMode===Ve.MULTIPLEXING)return this.knownState?.multiplexing?.leader}getWindow(){return this._window}}class We{_knownValues=[];_counter;constructor(e){this._counter=e}add(e){e&&-1===this._knownValues.indexOf(e)&&(this._counter.inc(),this._knownValues.push(e))}}class Be{_instancesCounter;_domainsCounter;_windowsCounter;_partnersCounter;constructor(e,t){let s=t.id;this._instancesCounter=e.instanceCounter(t.id),this._windowsCounter=new We(e.instanceUniqWindowsCounter(s)),this._partnersCounter=new We(e.instanceUniqPartnersCounter(s)),this._domainsCounter=new We(e.instanceUniqueDomainsCounter(s))}addInstance(e){this._instancesCounter.inc(),this._partnersCounter.add(e?.fetchIdData?.partnerId|e?.sourceConfiguration?.options?.partnerId),this._domainsCounter.add(e?.domain),this._windowsCounter.add(e?.href)}}class Xe{_scheduleTime;_closeTime;_timeoutId;_state=je.AWAITING_SCHEDULE;_delayMs;_instance;constructor(e){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(je.COMPLETED))}),t._delayMs),t._state=je.SCHEDULED,t._scheduleTime=performance.now()}skip(){this._closeWithState(je.SKIPPED)}cancel(){this._timeoutId&&(clearTimeout(this._timeoutId),this._timeoutId=void 0),this._closeWithState(je.CANCELED)}_closeWithState(e){this._state=e,this._closeTime=performance.now()}}class Je{properties;_messenger;_knownInstances=new Map;_lastJoinedInstance;role;_leader;_mode;_metrics;_logger;_instanceCounters;_election;_window;_storage;constructor(e,t,s,r,i=_){const n=F(globalThis)&&F(globalThis.crypto)&&R(globalThis.crypto.randomUUID)?globalThis.crypto.randomUUID():""+(1e6*Math.random()|0);this.properties=Object.assign({id:n,version:"1.0.23",href:e.location?.href,domain:e.location?.hostname},t),this.role=Me.UNKNOWN,this._metrics=r,this._instanceCounters=new Be(r,this.properties),this._loadTime=performance.now(),this._logger=void 0!==i?new f(`Instance(id=${n})`,i):_,this._window=e,this._dispatcher=new Re(this._logger),this._leader=new Ee,this._followerRole=new xe(this._window,this.properties,this._dispatcher,this._logger),this._election=new Xe(this),this._storage=s}updateConfig(e){Object.assign(this.properties,e)}init(e=1e3){let t=this,s=t._window;t._mode=!0===t.properties.singletonMode?Ve.SINGLETON:Ve.MULTIPLEXING,t._instanceCounters.addInstance(t.properties),function(e){const t=e._metrics;[100,200,500,1e3,2e3,3e3,5e3].forEach((s=>{setTimeout((()=>{const r=(e._knownInstances?.size||0)+1;t.summary("instance.partySize",{after:s,electionState:e._election._state}).record(r)}),s)}))}(t),t._messenger=new E(t.properties.id,s,t._logger),t._messenger.onAnyMessage(((e,r)=>{let i=Date.now()-e.timestamp|0;t._metrics.instanceMsgDeliveryTimer({messageType:e.type,sameWindow:s===r}).record(i),t._logger.debug("Message received",e),t._doFireEvent(De.ID5_MESSAGE_RECEIVED,e)})).onMessage(y.TYPE,((e,s)=>{let r=Object.assign(new y,e.payload);void 0===r.isResponse&&(r.isResponse=e.dst!==w),t._handleHelloMessage(r,e,s)})).onProxyMethodCall(new b(this._logger).registerTarget(v.LEADER,t._leader).registerTarget(v.FOLLOWER,t._followerRole).registerTarget(v.STORAGE,t._storage)),t._mode===Ve.SINGLETON?(t._election.skip(),t._onLeaderElected(t.properties)):t._mode===Ve.MULTIPLEXING&&t._election.schedule(e),t._messenger.broadcastMessage(t._createHelloMessage(!1),y.TYPE)}register(e){try{this.updateConfig(e),this.init()}catch(e){this._logger.error("Failed to register integration instance",e)}return this}_handleHelloMessage(e,t,s){this._joinInstance(e,t,s)}unregister(){this._logger.info("Unregistering"),this._messenger&&this._messenger.unregister()}on(e,t){return this._dispatcher.on(e,t),this}_joinInstance(e,t,s){const r=e.isResponse,i=new Ge(e.instance,e.instanceState,s);if(this._knownInstances.get(i.getId()))this._logger.debug("Instance already known",i.getId());else{if(this._knownInstances.set(i.getId(),i),this._lastJoinedInstance=i,this._instanceCounters.addInstance(i.properties),this._metrics.instanceJoinDelayTimer({election:this._election._state}).record(performance.now()-this._loadTime|0),r){const e=i.getInstanceMultiplexingLeader();this._mode===Ve.MULTIPLEXING&&this.role===Me.UNKNOWN&&void 0!==e&&(this._logger.info("Joined late, elected leader is",e),this._election.cancel(),this._onLeaderElected(e))}else this._messenger.sendResponseMessage(t,this._createHelloMessage(!0),y.TYPE),this._mode===Ve.MULTIPLEXING&&this.role!==Me.UNKNOWN&&this._handleLateJoiner(i);this._logger.debug("Instance joined",i.getId()),this._doFireEvent(De.ID5_INSTANCE_JOINED,i.properties)}}_createHelloMessage(e=!1){let t={operatingMode:this._mode,knownInstances:Array.from(this._knownInstances.values()).map((e=>e.properties))};return this._mode===Ve.MULTIPLEXING&&(t.multiplexing={role:this.role,electionState:this._election?._state,leader:this._leader.getProperties()}),new y(this.properties,e,t)}_handleLateJoiner(e){this._logger.info("Late joiner detected",e.properties);const t=this._metrics.instanceLateJoinCounter(this.properties.id,{scope:"party"}).inc();if(this._metrics.instanceLateJoinDelayTimer({election:this._election._state,isFirst:1===t}).record(performance.now()-this._election._closeTime),e.isMultiplexingPartyAllowed()&&this.role===Me.LEADER){let t=this._leader.addFollower(new Fe(e,this._messenger,this._logger));!0===t?.lateJoiner&&this._metrics.instanceLateJoinCounter(this.properties.id,{scope:"leader",unique:!0===t?.uniqueLateJoiner}).inc()}}_doFireEvent(e,...t){this._dispatcher.emit(e,...t)}_actAsLeader(){const e=this.properties,t=this._logger,s=this._metrics,r=new se(this._storage),i=new Q(r),n=new q(e.storageExpirationDays),o=new Ne(i,n,e.forceAllowLocalStorageGrant,t,s),a=new $(new Le((()=>o.localStorageGrant("client-store")),i,n,t)),c=new Ce(s,t,function(e,t){return new ke(e,t)}(s,t)),l=new Ie(this._window,e,r,a,o,s,t,c);l.addFollower(this._followerRole),this._leader.assignLeader(l),this._mode===Ve.MULTIPLEXING&&Array.from(this._knownInstances.values()).filter((e=>e.isMultiplexingPartyAllowed())).map((e=>l.addFollower(new Fe(e,this._messenger,t)))),l.start()}_followRemoteLeader(e){this._leader.assignLeader(new be(this._messenger,e)),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),Object.assign(this.properties.fetchIdData,e)}refreshUid(e){this._leader.refreshUid(e,this.properties.id)}_doElection(){const e=this._election,t=this._knownInstances;let s=Array.from(t.values()).filter((e=>e.isMultiplexingPartyAllowed())).map((e=>e.properties));s.push(this.properties),this._onLeaderElected(function(e){if(e&&0!==e.length)return e.sort(((e,t)=>{let s=-A(e.version,t.version);return 0===s&&(s=e.source.localeCompare(t.source),0===s&&(s=-A(e.sourceVersion,t.sourceVersion)),0===s&&(s=e.id.localeCompare(t.id))),s}))[0]}(s));const r=this._lastJoinedInstance;r&&this._metrics.instanceLastJoinDelayTimer().record(Math.max(r._joinTime-e._scheduleTime,0))}_onLeaderElected(e){const t=this;t.role=e.id===t.properties.id?Me.LEADER:Me.FOLLOWER,t.role===Me.LEADER?t._actAsLeader():t.role===Me.FOLLOWER&&t._followRemoteLeader(e),t._logger.debug("Leader elected",e.id,"my role",t.role),t._doFireEvent(De.ID5_LEADER_ELECTED,t.role,t._leader.getProperties())}getId(){return this.properties.id}}const qe=new class{createInstance(e,t,s,r){return new Je(e,{},r,s,t)}},$e="TRUE"===st("id5_debug").toUpperCase(),Ke="TRACE"===st("id5_debug").toUpperCase(),ze=Boolean(window.console);let Ye=!1;function Qe(e,t,s,r,i){et()&&ze&&e&&e.apply(console,[`%cID5 - ${t}#${s}`,"color: #fff; background: #1c307e; padding: 1px 4px; border-radius: 3px;",r].concat(i))}function Ze(e){Ye=!!e}function et(){return $e||Ke||Ye}class tt extends g{_invocationId;_origin;constructor(e,t){super(),this._invocationId=t,this._origin=e}debug(...e){!function(e,t,...s){Qe(console.info,e,t,"DEBUG",s)}(this._origin,this._invocationId,...e)}info(...e){!function(e,t,...s){Qe(console.info,e,t,"INFO",s)}(this._origin,this._invocationId,...e)}warn(...e){!function(e,t,...s){Qe(console.warn,e,t,"WARNING",s)}(this._origin,this._invocationId,...e)}error(...e){!function(e,t,...s){Qe(console.error,e,t,"ERROR",s)}(this._origin,this._invocationId,...e)}}function st(e){const t=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(window.location.search);return null===t?"":decodeURIComponent(t[1].replace(/\+/g," "))}const rt=T,it=R,nt=P,ot=O,at=x,ct=U,lt=function(e){return T(e,"Boolean")},ht=F;function dt(e){(new Image).src=e}function ut(e,t,s,r,i){for(t=t.split?t.split("."):t,r=0;r<t.length;r++)e=e?e[t[r]]:i;return e===i?s:e}new tt("ajax");const pt=e=>null!=e&&"object"==typeof e;function gt(e,t){if(!pt(e)||!pt(t))return e===t;const s=Object.keys(e),r=Object.keys(t);if(s.length!==r.length)return!1;for(let r of s)if(!gt(e[r],t[r]))return!1;return!0}const _t=function(e){function t(e){try{let t=e.querySelector("link[rel='canonical']");if(null!==t)return t.href}catch(e){}return null}return function(){try{let s,r,i=function(){let s=function(){let s,r=[];do{try{s=s?s.parent:e;try{let i=s===e.top,n={referrer:s.document.referrer||null,location:s.location.href||null,isTop:i};i&&(n=Object.assign(n,{canonicalUrl:t(s.document)})),r.push(n)}catch(t){r.push({referrer:null,location:null,isTop:s===e.top})}}catch(e){return r.push({referrer:null,location:null,isTop:!1}),r}}while(s!==e.top);return r}(),r=function(){try{if(!e.location.ancestorOrigins)return;return e.location.ancestorOrigins}catch(e){}}();if(r)for(let e=0,t=r.length;e<t;e++)s[e].ancestor=r[e];return s}(),n=i.length-1,o=null!==i[n].location||n>0&&null!==i[n-1].referrer,a=function(e){let t,s=[],r=null,i=null,n=null,o=null,a=null;for(t=e.length-1;t>=0;t--){try{r=e[t].location}catch(e){}if(r)s.push(r),a||(a=r);else if(0!==t){i=e[t-1];try{n=i.referrer,o=i.ancestor}catch(e){}n?(s.push(n),a||(a=n)):o?(s.push(o),a||(a=o)):s.push(null)}else s.push(null)}return{stack:s,detectedRefererUrl:a}}(i);i[i.length-1].canonicalUrl&&(s=i[i.length-1].canonicalUrl);try{r=e.top.document.referrer}catch(e){}return{topmostLocation:a.detectedRefererUrl,ref:r||null,reachedTop:o,numIframes:n,stack:a.stack,canonicalUrl:s}}catch(e){}}}(window),ft={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},mt=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"}}),wt=Object.freeze({TCF:0,USP:1,GPP:2});class St{direct;version;constructor(e,t){this.direct=e,this.version=t}async getConsentData(){return this.getClientConsentData()}static async create(e){const{cmpApiFrame:t,cmpApiFunction:s}=It._findCmpApi("__gpp");let r,i=!1;if(!t)return e.warn("cmpApi: GPP not found! Using defaults."),Promise.resolve();if(it(s))i=!0,e.info("cmpApi: Detected GPP is directly accessible, calling it now."),r=s;else{e.info("cmpApi: Detected GPP is outside the current iframe. Using message passing.");const s=It._buildCmpSurrogate(mt.gppv1,t);r=function(e,t,r){s(e,r,t)}}const n=await new Promise((e=>{const t=r("ping",(function(t){e(t)}));t&&e(t)}));switch(n.gppVersion){case Ct.version:return new Ct(n,r,i);case vt.version:return new vt(n,r,i);default:{const t=`Unsupported version of gpp: ${n.gppVersion}`;return e.warn(t),Promise.reject(t)}}}static tcfDataHasLocalStorageGrant(e){return ot(e.PurposeConsent)&&!0===e.PurposeConsent[0]&&e.VendorConsent?.indexOf("131")>=0}static getTcfData(e){const t=e?.tcfeuv2;let s;return ot(t)&&ct(t[0])?s=t[0]:ct(t)&&(s=t),s}}class Ct extends St{static version="1.0";gppFn;ready;constructor(e,t,s){super(s,Ct.version),this.gppFn=t,this.ready=this.isReady(e)}isReady(e){return"loaded"===e.cmpStatus&&"visible"!==e.cmpDisplayStatus}async getClientConsentData(){this.ready||(this.ready=await new Promise((e=>{this.gppFn("addEventListener",(t=>{if(!this.isReady(t.pingData))return!1;e(!0)}))})));const e=new Promise((e=>{this.gppFn("getGPPData",(t=>{e(t)}))})),t=new Promise((e=>{this.gppFn("getSection",(t=>{e(t)}),"tcfeuv2")})),[s,r]=await Promise.all([e,t]),i=new V;return i.version=M.GPP_V1_0,i.gppString=s.gppString,i.applicableSections=s.applicableSections,r&&(i.localStoragePurposeConsent=St.tcfDataHasLocalStorageGrant(r)),i}}function yt(e,t,s){s&&(e.apiTypes.push(t),Object.assign(e,s))}class vt extends St{static version="1.1";gppFn;readyPingData;constructor(e,t,s){super(s,vt.version),this.gppFn=t,"ready"===e.signalStatus&&(this.readyPingData=e)}async getClientConsentData(){return new Promise((e=>{this.readyPingData?e(this.parsePingData(this.readyPingData)):this.gppFn("addEventListener",(t=>{if("ready"!==t.pingData.signalStatus)return!1;e(this.parsePingData(t.pingData))}))}))}parsePingData(e){const t=new V;t.gppString=e.gppString,t.version=M.GPP_V1_1,t.applicableSections=e.applicableSections;let s=St.getTcfData(e.parsedSections);return s&&(t.localStoragePurposeConsent=St.tcfDataHasLocalStorageGrant(s)),t}}class It{_lookupInProgress;_log;_metrics;_consentDataPromise;constructor(e,t=_){this._metrics=e,this._log=t}refreshConsentData(e,t,s){const r=this;return r._lookupInProgress||(r._lookupInProgress=!0,r._consentDataPromise=this._lookupConsentData(e,t,s).finally((()=>{r._lookupInProgress=!1}))),this._consentDataPromise}_lookupConsentData(e,t,s){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 j;return e.forcedGrantByConfig=!0,e.source=k.partner,Promise.resolve(e)}switch(t){case"static":return new Promise((e=>{this._parseStaticConsentData(s,e)}));case"iab":return new Promise((e=>{this._lookupIabConsent(e)}));default:return this._log.error(`cmpApi: Unknown consent API: ${t}`),Promise.reject(new Error(`Unknown consent API: ${t}`))}}_parseStaticConsentData(e,t){e=e||{};let s=new j;if(s.source=k.partner,ct(e.getTCData)){const t=this._parseTcfData(e.getTCData);yt(s,M.TCF_V2,t);try{const e=this._metrics;this._lookupTcf((s=>{e.consentDiscrepancyCounter({apiType:M.TCF_V2,sameString:s?.consentString===t?.consentString,sameLSPC:s?.localStoragePurposeConsent===t?.localStoragePurposeConsent,sameGdpr:s?.gdprApplies===t?.gdprApplies}).inc()}))}catch(e){}}if(ot(e.allowedVendors)&&yt(s,M.ID5_ALLOWED_VENDORS,{allowedVendors:e.allowedVendors.map((e=>e.toString())),gdprApplies:!0}),ct(e.getUSPData)){const t=this._parseUspData(e.getUSPData);yt(s,M.USP_V1,t);try{const e=this._metrics;this._lookupUsp((s=>{e.consentDiscrepancyCounter({apiType:M.USP_V1,sameString:s?.ccpaString===t?.ccpaString}).inc()}))}catch(e){}}0===s.apiTypes.length&&this._log.warn("cmpApi: No static consent data detected! Using defaults."),this._log.info(`cmpApi: Detected APIs '${s.apiTypes}' from static consent data`,e),t(s)}_lookupIabConsent(e){const t=[];let s=new j;s.source=k.cmp;const r=r=>(t[r]=0,(i,n)=>{t[r]||(t[r]=Date.now(),i&&yt(s,n,i),t.every((e=>e>0))&&e(s))}),i=r(wt.TCF),n=r(wt.USP),o=r(wt.GPP);this._lookupGpp(o),this._lookupTcf(i),this._lookupUsp(n)}_lookupUsp(e){const{cmpApiFrame:t,cmpApiFunction:s}=It._findCmpApi("__uspapi");let r;if(!t)return this._log.warn("cmpApi: USP not found! Using defaults for CCPA."),void e();it(s)?(this._log.info("cmpApi: Detected USP is directly accessible, calling it now."),r=s):(this._log.info("cmpApi: Detected USP is outside the current iframe. Using message passing."),r=It._buildCmpSurrogate(mt.uspv1,t)),r("getUSPData",1,((t,s)=>{s?e(this._parseUspData(t),M.USP_V1):(this._log.error("cmpApi: USP callback not successful. Using defaults for CCPA."),e())}))}async _lookupGpp(e){const t=Date.now();try{let s=await St.create(this._log);if(s){let r={gppVersion:s.version,directCmp:s.direct};try{let i=await s.getConsentData();e({gppData:i},i.version);let n=Date.now();this._metrics.timer("gpp.delay",r).record(n-t)}catch(t){this._metrics.counter("gpp.failure",Object.assign({type:"CONSENT"},r)).inc(),this._log.error("cmpApi: getting GPP consent not successful. Using defaults for Gpp."),e()}}else e()}catch(t){this._metrics.counter("gpp.failure",{type:"CLIENT"}).inc(),this._log.error("cmpApi: creating GPP client not successful. Using defaults for Gpp."),e()}}static _buildCmpSurrogate(e,t){return(s,r,i)=>{const n=Math.random()+"",o={},a={};a[e.objKeys[0]]=s,a[e.objKeys[1]]=r,a.callId=n,o[e.objName]=a;const c=t=>{const s=ut(t,`data.${e.returnObjName}`);if(s&&s.callId===n){const e=i(s.returnValue,s.success);void 0!==e&&!0!==e||window.removeEventListener("message",c)}};window.addEventListener("message",c,!1),t.postMessage(o,"*")}}_lookupTcf(e){const{cmpFrame:t,cmpFunction:s}=It._findTCF();if(!t)return this._log.warn("cmpApi: TCF not found! Using defaults for GDPR."),void e();it(s)?this._lookupDirectTcf(s,e):(this._log.info("cmpApi: Detected TCF is outside the current iframe. Using message passing."),this._lookupMessageTcf(t,e))}_lookupMessageTcf(e,t){const s=It._buildCmpSurrogate(mt.tcfv2,e);this._lookupDirectTcf(s,t)}_lookupDirectTcf(e,t){const s=this._log;e("addEventListener",2,((e,r)=>{return i=e,s.info("cmpApi: TCFv2 - Received a call back: event",i),r?!(!e||!1!==e.gdprApplies&&"tcloaded"!==e.eventStatus&&"useractioncomplete"!==e.eventStatus)&&void t(this._parseTcfData(e),M.TCF_V2):(s.error("cmpApi: TCFv2 - Received insuccess: addEventListener. Please check your CMP setup. Using defaults for GDPR."),void t());var i}))}_parseUspData(e){if(ct(e)&&nt(e.uspString))return{ccpaString:e.uspString};this._log.error("cmpApi: No or malformed USP data. Using defaults for CCPA.")}_parseTcfData(e){let t,s,r=this._log;if(t=It._isValidV2ConsentObject,s=It._normalizeV2Data,t(e))return s(e);r.error("cmpApi: Invalid CMP data. Using defaults for GDPR.",e)}static _isValidV2ConsentObject(e){const t=e&&e.gdprApplies,s=e&&e.tcString;return!1===t||nt(s)}static _normalizeV2Data(e){let t=ut(e,"purpose.consents.1");return lt(t)||(t=function(e,t){if(!e||"C"!==e.charAt(0)||e.length<=25)return;let s=e.charAt(25),r=ft[s];return void 0!==r?0!=(8&r):void 0}(e.tcString)),{consentString:e.tcString,localStoragePurposeConsent:t,gdprApplies:e.gdprApplies}}static _findTCF(){let e,t,s=window;for(;!e;){try{if("function"==typeof s.__tcfapi){t=s.__tcfapi,e=s;break}}catch(e){}try{if(s.frames.__tcfapiLocator){e=s;break}}catch(e){}if(s===window.top)break;s=s.parent}return{cmpFrame:e,cmpFunction:t}}static _findCmpApi(e){let t,s,r=window;for(;!t;){try{if("function"==typeof r[e]){s=r[e],t=r;break}}catch(e){}try{if(r.frames[`${e}Locator`]){t=r;break}}catch(e){}if(r===window.top)break;r=r.parent}return{cmpApiFrame:t,cmpApiFunction:s}}}const bt="1.0.63";class Et{static async gatherUaHints(e,t){if(!F(window.navigator.userAgentData)||e)return;let s;try{s=await window.navigator.userAgentData.getHighEntropyValues(["architecture","fullVersionList","model","platformVersion"])}catch(e){return void t.error("Error while calling navigator.userAgentData.getHighEntropyValues()",e)}return Et.filterUaHints(s)}static filterUaHints(e){if(!F(e))return;const t=/[()-.:;=?_/]/g;return O(e.brands)&&(e.brands=e.brands.filter((e=>P(e.brand)&&e.brand.search(t)<0))),O(e.fullVersionList)&&(e.fullVersionList=e.fullVersionList.filter((e=>P(e.brand)&&e.brand.search(t)<0))),e}}const At=Object.freeze({NEVER:"never",AFTER_UID_SET:"after-uid-set",ASAP:"asap"}),Dt=Object.freeze({allowGCReclaim:Object.values(At)});class Tt{invocationId;options;providedOptions;invalidSegments;static 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"};constructor(e,t=_){if(this._log=t,this.options={debugBypassConsent:!1,allowLocalStorageWithoutConsentApi:!1,cmpApi:"iab",consentData:{},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},allowGCReclaim:At.AFTER_UID_SET},this.providedOptions={},!at(e.partnerId)&&!nt(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 q(e.storageExpirationDays)}getOptions(){return this.options}getProvidedOptions(){return this.providedOptions}getInvalidSegments(){return this.invalidSegments}hasCreativeRestrictions(){return this.options.applyCreativeRestrictions||this.options.acr}updOptions(e){const t=this,s=t._log;if(!ct(e))return void s.error("Config options must be an object");this.setPartnerId(e.partnerId);const r=(e,t)=>{this.options[e]=t,this.providedOptions[e]=t};Object.keys(e).forEach((i=>{if("segments"===i){const n=e[i],o=[];if(!F(n))return;if(!ot(n))return void Rt(s,i,"Array",n);n.forEach(((e,r)=>{const i=`segments[${r}]`;return ot(e.ids)&&function(e,t){let s=!0;return H(e,(e=>s=s&&t(e))),s}(e.ids,nt)?e.ids.length<1?(s.error(`Config option ${i}.ids should contain at least one segment ID`),void(t.invalidSegments+=1)):nt(e.destination)?void o.push(e):(Rt(s,`${i}.destination`,"String",e.destination),void(t.invalidSegments+=1)):(Rt(s,`${i}.ids`,"Array of String",e.ids),void(t.invalidSegments+=1))})),r(i,o)}else if("diagnostics"===i){const t=this.options.diagnostics,s=e.diagnostics;if(rt(s,Tt.configTypes.diagnostics)){let e={...t};Object.keys(s).forEach((r=>{void 0!==t[r]&&typeof t[r]==typeof s[r]&&(e[r]=s[r])})),this.options[i]=e}this.providedOptions[i]=e[i]}else if(void 0!==Dt[i]){const t=e[i];t&&Dt[i].includes(t)&&r(i,t)}else if("partnerId"!==i){const t=Tt.configTypes[i],n=e[i];F(n)&&(rt(n,t)?r(i,n):Rt(s,i,t,n))}}))}setPartnerId(e){let t;if(nt(e)){if(t=parseInt(e),isNaN(t)||t<0)throw new Error("partnerId is required and must parse to a positive integer")}else at(e)&&(t=e);if(at(t)){if(at(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 Rt(e,t,s,r){e.error(`Config option ${t} must be of type ${s} but was ${toString.call(r)}. Ignoring...`)}class Pt{_called;_callbackFn;_callbackArgs;_beforeTrigger;_watchdog;constructor(e,t,s,r,...i){this._callbackFn=e,this._callbackArgs=i,this._beforeTrigger=r,this._called=!1,s?this._watchdog=setTimeout((()=>this._trigger()),0):t>0&&(this._watchdog=setTimeout((()=>this._trigger()),t))}_trigger(){this._watchdog=void 0,this._called||(this._called=!0,setTimeout((()=>{this._beforeTrigger(),this._callbackFn.call(globalThis,...this._callbackArgs)}),0))}triggerNow(){this.disableWatchdog(),this._trigger()}disableWatchdog(){this._watchdog&&(clearTimeout(this._watchdog),this._watchdog=void 0)}}const Ot="api";class xt{refererInfo;apiVersion;isUsingCdn;constructor(e,t,s){this.refererInfo=e,this.apiVersion=t,this.isUsingCdn=s}}class Ut{_targets;_metrics;_survivalTimer;constructor(e,t){this._targets=[e,t],this._metrics=t,this._survivalTimer=fe()}unregister(e){this._survivalTimer&&this._metrics&&this._survivalTimer.record(this._metrics.instanceSurvivalTime({unregisterTrigger:e})),this._targets.forEach((e=>{try{ht(e)&&it(e.unregister)&&e.unregister()}catch(e){}}))}}globalThis.__id5_finalization_registry||(globalThis.__id5_finalization_registry=new class{_finalizationRegistry;_instancesHolder;constructor(){this._instancesHolder=new Set;try{this._finalizationRegistry=new FinalizationRegistry((e=>{try{ht(e)&&it(e.unregister)&&e.unregister("gc-reclaim")}catch(e){}}))}catch(e){}}register(e){try{e.getOptions().allowGCReclaim!==At.ASAP&&this._instancesHolder.add(e),this._finalizationRegistry.register(e,e._unregisterTargets,e)}catch(e){}}unregister(e){try{this.releaseInstance(e,!0),this._finalizationRegistry.unregister(e)}catch(e){}}releaseInstance(e,t=!1){(!e.getOptions().allowGCReclaim!==At.NEVER||t)&&this._instancesHolder.delete(e)}});const Ft=globalThis.__id5_finalization_registry;class Ht{_ref;constructor(e){this._ref=e}deref(){return this._ref}}class Nt{_availableCallback;_updateCallback;_refreshCallback;_isExposed;_fromCache;_isRefreshing=!1;_isRefreshingWithFetch=!1;_userId;_ext;_userIdAvailable=!1;_userIdAvailablePromise;_userIdAvailablePromiseResolver;invocationId;config;clientStore;consentManagement;_consentDataProvider;_metrics;_log;_multiplexingInstance;_pageLevelInfo;getOptions(){return this.config.getOptions()}getProvidedOptions(){return this.config.getProvidedOptions()}getInvalidSegments(){return this.config.getInvalidSegments()}getUserId(){return!1===this._isExposed?"0":this._userId}getLinkType(){return!1===this._isExposed?0:this.getExt().linkType}getExt(){let e=!1===this._isExposed?{}:this._ext;return Object.assign({abTestingControlGroup:!this.exposeUserId()},e)}isFromCache(){return this._fromCache}exposeUserId(){return this._isExposed}getUserIdAsEid(){return{source:X.ID5_EIDS_SOURCE,uids:[{atype:1,id:this.getUserId(),ext:this.getExt()}]}}onAvailable(e,t){if(!it(e))throw new Error("onAvailable expects a function");return this._availableCallback?this._log.warn("onAvailable was already called, ignoring"):this._availableCallback=new Pt(e,t,this._userIdAvailable,(()=>{this._log.debug("Firing onAvailable callback")}),this),this}onUpdate(e){if(!it(e))throw new Error("onUpdate expects a function");return this._updateCallback=e,this._userIdAvailable&&this._fireOnUpdate(),this}onRefresh(e,t){if(!it(e))throw new Error("onRefresh expects a function");this._refreshCallback&&this._refreshCallback.disableWatchdog();const s=!0===this._isRefreshing&&!1===this._isRefreshingWithFetch&&this._userIdAvailable;return this._refreshCallback=new Pt(e,t,s,(()=>{this._log.debug("Firing onRefresh callback"),this._isRefreshing=!1,this._isRefreshingWithFetch=!1}),this),this}unregister(){try{this._unregisterTargets.unregister("api-call"),Ft.unregister(this)}catch(e){}}collectEvent(e,t){const s=s=>{const r=new Request("https://id5-sync.com/event",{method:"POST",mode:"no-cors",body:JSON.stringify({partnerId:this.config.getOptions().partnerId,id5id:s,eventType:e,metadata:t})});return this._log.info("Sending event",r),fetch(r).catch((t=>this._log.error("Error while sending event to ID5 of type "+e,t)))};return this._userIdAvailable?s(this._userId):this._userIdAvailablePromise.then((e=>s(e)))}constructor(e,t,s,r,i,n,o,a){this.config=e,this.clientStore=t,this.consentManagement=s,this._metrics=r,this._consentDataProvider=i,this._log=new f("Id5Instance:",n),this._multiplexingInstance=o,this._userIdAvailablePromise=new Promise((e=>{this._userIdAvailablePromiseResolver=e})),this._pageLevelInfo=a,this._unregisterTargets=new Ut(this._multiplexingInstance,this._metrics),Ft.register(this)}bootstrap(){const e=fe(),t=this.config.getOptions(),s=this._ref();this._multiplexingInstance.on(Ae.CASCADE_NEEDED,(e=>{const t=s.deref();t&&t._doCascade(e)})).on(Ae.USER_ID_READY,((t,r)=>{const i=s.deref();if(i){try{const s=r?.tags?{...r.tags}:{},n=i._metrics;r?.timestamp&&n.userIdNotificationDeliveryDelayTimer(s).record(Date.now()-r.timestamp),e.record(n.userIdProvisioningDelayTimer(t.isFromCache,{...s,isUpdate:i._userIdAvailable,hasOnAvailable:void 0!==i._availableCallback,hasOnRefresh:void 0!==i._refreshCallback,hasOnUpdate:void 0!==i._updateCallback}))}catch(e){i._log.error("Failed to measure provisioning metrics",e)}i._setUserId(t.responseObj,t.isFromCache,t.willBeRefreshed)}})).on(Ae.USER_ID_FETCH_CANCELED,(e=>{const t=s.deref();t&&t._log.info("ID5 User ID fetch canceled:",e.reason)})),this._log.info(`bootstrapped for partner ${t.partnerId} with referer ${this._refererInfo} and options`,this.getProvidedOptions())}firstFetch(){const e=this.config.getOptions(),t=this._gatherFetchIdData().then((t=>{this._multiplexingInstance.register({source:Ot,sourceVersion:bt,sourceConfiguration:{options:e},fetchIdData:t,singletonMode:!0===e?.multiplexing?._disabled,canDoCascade:!this.config.hasCreativeRestrictions(),forceAllowLocalStorageGrant:this.consentManagement.isForceAllowLocalStorageGrant(),storageExpirationDays:e.storageExpirationDays})})),s=this._submitRefreshConsent().then((e=>{e&&this.consentManagement.setConsentData(e)}));return Promise.allSettled([t,s])}refreshId(e,t){let s,r;this._log.info(`ID refresh requested (force=${e}) with additional options `,t);try{this._isRefreshing=!0,this._isRefreshingWithFetch=e,this.config.updOptions(t);const i=this.config.getOptions(),n=i.allowLocalStorageWithoutConsentApi||i.debugBypassConsent;s=this._gatherFetchIdData().then((t=>{this._multiplexingInstance.updateFetchIdData(t),this._multiplexingInstance.refreshUid({resetConsent:!0,forceAllowLocalStorageGrant:n,forceFetch:e}),r=this._submitRefreshConsent()})),this._metrics.refreshCallCounter("public-api").inc()}catch(e){return this._log.error("Exception caught from refreshId()",e),Promise.reject(e)}return Promise.allSettled([s,r])}_doCascade(e){const t=this.config.getOptions();if(e.partnerId===t.partnerId&&t.maxCascades>=0&&!this.config.hasCreativeRestrictions()){const r=t.partnerUserId&&t.partnerUserId.length>0,i=new URL(`/${r?"s":"i"}/${t.partnerId}/${t.maxCascades}.gif`,"https://id5-sync.com"),n=i.searchParams;n.set("o","api"),n.set("id5id",e.userId),n.set("gdpr_consent",e.consentString),n.set("gdpr",e.gdprApplies),e.gppString&&(n.set("gpp",e.gppString),n.set("gpp_sid",e.gppSid)),r&&n.set("puid",t.partnerUserId),this._log.info("Opportunities to cascade available",i.href),s=i.href,"loading"!==document.readyState?dt(s):document.addEventListener("DOMContentLoaded",(function(){dt(s)}))}var s}async _gatherFetchIdData(){const e=this.config.getOptions(),t=await Et.gatherUaHints(e.disableUaHints,this._log);return{partnerId:e.partnerId,refererInfo:this._pageLevelInfo.refererInfo,origin:Ot,originVersion:this._pageLevelInfo.apiVersion,isUsingCdn:this._pageLevelInfo.isUsingCdn,att:e.att,uaHints:t,abTesting:e.abTesting,segments:e.segments,invalidSegmentsCount:this.getInvalidSegments(),provider:e.provider,pd:e.pd,partnerUserId:e.partnerUserId,refreshInSeconds:e.refreshInSeconds,providedRefreshInSeconds:this.getProvidedOptions().refreshInSeconds,trace:Ke,allowedVendors:e.consentData?.allowedVendors,consentSource:"iab"===e.cmpApi&&!0!==e.debugBypassConsent?k.cmp:k.partner}}_ref(){return"undefined"!=typeof WeakRef?new WeakRef(this):new Ht(this)}async _submitRefreshConsent(){const e=this.config.getOptions();let t,s=fe(),r=e.debugBypassConsent?"bypass":e.cmpApi;try{t=await this._consentDataProvider.refreshConsentData(e.debugBypassConsent,e.cmpApi,e.consentData);const i={};t.apiTypes.forEach((e=>i[e]=!0)),s.record(this._metrics.consentRequestTimer(r,{success:!0,...i})),this._multiplexingInstance.updateConsent(t)}catch(e){this._log.error("Couldn't get consent data",e),s.record(this._metrics.consentRequestTimer(r,{success:!1,error:e.message}))}return t}_setUserId(e,t,s=!1){const r=e.universal_uid;if(this._isExposed=!0,ct(e.ab_testing))switch(e.ab_testing.result){case"normal":break;default:case"error":this._log.error("There was an error with A/B Testing. Make sure controlGroupRatio is a number >= 0 and <= 1");break;case"control":this._isExposed=!1,this._log.info("User is in control group!")}const i=this._userId!==r||!1===gt(this._ext,e.ext);this._userIdAvailable=!0,this._userId=r,this._userIdAvailablePromiseResolver(r),this._ext=e.ext,this._fromCache=t,this._log.info("User id updated",{hasChanged:i,fromCache:t}),this._availableCallback&&this._availableCallback.triggerNow(),this._isRefreshing&&this._refreshCallback&&(!1===t||!1===this._isRefreshingWithFetch)&&this._refreshCallback.triggerNow(),i&&this._fireOnUpdate(),this.getOptions().allowGCReclaim!==At.AFTER_UID_SET||t&&s||Ft.releaseInstance(this)}_fireOnUpdate(){setTimeout((()=>{it(this._updateCallback)&&(this._log.debug("Firing onUpdate"),this._updateCallback(this))}),0)}localStorageGrant(){return this.clientStore.localStorageGrant()}}const Lt=new class{loaded=!1;set debug(e){Ze(e)}get debug(){return et()}_isUsingCdn=!1;_referer=!1;_version=bt;versions={};invocationId=0;constructor(){this.loaded=!0,this._isUsingCdn=!!(document&&document.currentScript&&document.currentScript.src&&0===document.currentScript.src.indexOf("https://cdn.id5-sync.com")),this._referer=_t(),this.versions[bt]=!0}init(e){this.invocationId+=1;const t=new tt(Ot,this.invocationId);try{t.info(`ID5 API version ${this._version}. Invoking init()`,e);const s=new Tt(e,t),r=s.getOptions(),i=this._configureDiagnostics(r,t);i&&(i.loadDelayTimer().recordNow(),i.invocationCountSummary().record(this.invocationId,{fenced:"function"==typeof window.Fence&&window.fence instanceof window.Fence}));const n=new te(window,!s.hasCreativeRestrictions()),o=new Q(n),a=r.allowLocalStorageWithoutConsentApi||r.debugBypassConsent,c=new Ne(o,s.storageConfig,a,t,i),l=new Le((()=>c.localStorageGrant()),o,s.storageConfig,t),h=qe.createInstance(window,t,i,n),d=new It(i,t),u=new xt(this._referer,this._version,this._isUsingCdn),p=new Nt(s,l,c,i,d,t,h,u);return p.bootstrap(),p.firstFetch(),l.scheduleGC(i),p}catch(e){t.error("Exception caught during init()",e)}}refreshId(e,t=!1,s={}){if(!lt(t))throw new Error("Invalid usage of refreshId(): second parameter must be a boolean");return e.refreshId(t,s),e}_configureDiagnostics(e,t){try{const t=e.partnerId,r=new we(Ot,bt),i=e.diagnostics;if(r.addCommonTags({...me(t),tml:this._referer.topmostLocation,provider:e.provider?e.provider:"default"}),!i?.publishingDisabled){let e=(s=i.publishingSampleRatio,Math.random()<s&&re?(e,t)=>new ie(undefined,{sampling:s}).publish(e,t):e=>e);i?.publishAfterLoadInMsec&&i.publishAfterLoadInMsec>0&&r.schedulePublishAfterMsec(i.publishAfterLoadInMsec,e),i?.publishBeforeWindowUnload&&r.schedulePublishBeforeUnload(e)}return r}catch(e){return void t.error("Failed to configure diagnostics",e)}var s}},kt=Lt;function Mt(e){var t,s,r,i,n,o,a,c,l,h;return{advertiserId:null===(t=e.advertiserId)||void 0===t?void 0:t.toString(),campaignId:null===(s=e.campaignId)||void 0===s?void 0:s.toString(),creativeId:null===(r=e.creativeId)||void 0===r?void 0:r.toString(),isEmpty:null===(i=e.isEmpty)||void 0===i?void 0:i.toString(),lineItemId:null===(n=e.lineItemId)||void 0===n?void 0:n.toString(),serviceName:null===(o=e.serviceName)||void 0===o?void 0:o.toString(),size:null===(a=e.size)||void 0===a?void 0:a.toString(),slotElementId:null===(c=e.slot)||void 0===c?void 0:c.getSlotElementId(),sourceAgnosticCreativeId:null===(l=e.sourceAgnosticCreativeId)||void 0===l?void 0:l.toString(),sourceAgnosticLineItemId:null===(h=e.sourceAgnosticLineItemId)||void 0===h?void 0:h.toString()}}p.prototype.installGPTEventListeners=function(){const e=this;e.installGPTEventListeners=function(){},window.googletag=window.googletag||{cmd:[]};const t=window.googletag;t.cmd.push((function(){t.pubads().addEventListener("slotRenderEnded",(function(t){e.witness("googletag.events.slotRenderEnded",Mt(t))})),t.pubads().addEventListener("impressionViewable",(function(t){e.witness("googletag.events.impressionViewable",Mt(t))}))}))},p.prototype.installGPTSecureSignals=function(){this.installGPTSecureSignals=function(){},window.googletag=window.googletag||{cmd:[],secureSignalProviders:[]};const e=window.googletag,t=this.lmpidFromCache();t&&e.cmd.push((function(){e.secureSignalProviders.push({id:r,collectorFunction:function(){return Promise.resolve(t)}})}))};const Vt=/^[a-f0-9]{64}$/i;p.prototype.tryIdentifyFromParams=function(e,t){const s=new RegExp(`^${e||"oeid"}$`,"i"),r=new URLSearchParams(window.location.search);let i="";for(const[e,t]of r)if(s.test(e)){i=t;break}""!=i&&(t||function(e){return Vt.test(e)}(i))&&this.identify((t||"e")+":"+i.toLowerCase())};p.prototype.getTopics=function(){return e=this,t=void 0,r=function*(){if(!("browsingTopics"in document))throw"browsing-topics not supported";const e=yield this.site();if(!e.getTopicsURL)throw"origin not enabled for topics api";const t=new URL(e.getTopicsURL),s=document.createElement("iframe");s.src=t.toString(),s.allow="browsing-topics "+t.origin,s.style.display="none";const r=new Promise(((e,t)=>{window.addEventListener("message",(r=>{r.source===s.contentWindow&&(r.data.error?t(new Error(r.data.error.toString())):e(r.data.result))}))}));return document.body.appendChild(s),r},new((s=void 0)||(s=Promise))((function(i,n){function o(e){try{c(r.next(e))}catch(e){n(e)}}function a(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,a)}c((r=r.apply(e,t||[])).next())}));var e,t,s,r},p.prototype.ingestTopics=function(){this.getTopics().then((e=>{if(!e.length)return;const t=e.reduce(((e,t)=>{const s=`topics_v${t.taxonomyVersion}`;return e[s]?e[s]+=",":e[s]="",e[s]+=String(t.topic),e}),{});this.profile(t)})).catch((()=>{}))};window.optable=window.optable||{cmd:[]},window.optable.site=window.optable.site||"default-fallback",window.optable.SDK=p,window.optable.instance=new p({host:"fourm.cloud.jp.optable.co",site:window.optable.site,cookies:!1}),window.optable.instance.targeting(),"default-fallback"!=window.optable.instance.dcn.site&&window.optable.instance.ingestTopics(),window.googletag=window.googletag||{cmd:[]},window.googletag.cmd.push((function(){const e=window.optable.instance.targetingKeyValuesFromCache();for(const[t,s]of Object.entries(e))googletag.pubads().setTargeting(t,s)})),kt.init({partnerId:1027}).onAvailable((function(e){let t=e.getUserId();t&&window.optable.instance.identify("id5:"+t)})),window.optable.instance.witness("pageview",{hostname:window.location.hostname,pathname:window.location.pathname}),window.optable.cmd=new class{constructor(e){if(Array.isArray(e))for(const t of e)"function"==typeof t&&t()}push(e){e()}}(window.optable.cmd||[])})()})();