@optable/web-sdk 0.30.0 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,12 +10,12 @@ JavaScript SDK for integrating with an [Optable Data Connectivity Node (DCN)](ht
10
10
  - [Versioning](#versioning)
11
11
  - [Domains and Cookies](#domains-and-cookies)
12
12
  - [LocalStorage](#localstorage)
13
- - [Using (npm module)](#using-npm-module)
13
+ - [Using the npm module](#using-the-npm-module)
14
14
  - [Identify API](#identify-api)
15
15
  - [Profile API](#profile-api)
16
16
  - [Targeting API](#targeting-api)
17
17
  - [Witness API](#witness-api)
18
- - [Using (script tag)](#using-script-tag)
18
+ - [Using a script tag](#using-a-script-tag)
19
19
  - [Integrating GAM360](#integrating-gam360)
20
20
  - [Targeting key values](#targeting-key-values)
21
21
  - [Targeting key values from local cache](#targeting-key-values-from-local-cache)
@@ -92,7 +92,7 @@ const sdk = new OptableSDK({ host: "dcn.customer.com", site: "my-site", cookies:
92
92
 
93
93
  Note that the default is `cookies: true` and will be inferred if you do not specify the `cookies` parameter at all.
94
94
 
95
- # Using (npm module)
95
+ # Using the npm module
96
96
 
97
97
  ## Initialization Configuration (`InitConfig`)
98
98
 
@@ -120,6 +120,9 @@ When creating an instance of `OptableSDK`, you can pass an `InitConfig` object t
120
120
  - **`initPassport` (boolean, default: `true`)**
121
121
  If `true`, initializes the user passport (identity mechanism) upon SDK load.
122
122
 
123
+ - **`initTargeting` (boolean, default: `false`)**
124
+ If `true`, the SDK will automatically perform a targeting request during initialization and store the response in cache. This ensures the cache is populated with the most up-to-date targeting data as soon as the SDK is loaded.
125
+
123
126
  - **`consent` (`InitConsent`)**
124
127
  Defines the consent settings for data collection and processing.
125
128
 
@@ -222,8 +225,8 @@ The `targeting` API will automatically cache resulting key value data in client
222
225
  ```{javascript
223
226
  const cachedTargetingData = sdk.targetingFromCache();
224
227
  if (cachedTargetingData) {
225
- console.log(`Audience targeting: ${targeting.audience}`)
226
- console.log(`User targeting: ${targeting.user}`)
228
+ console.log(`Audience targeting: ${cachedTargetingData.audience}`)
229
+ console.log(`User targeting: ${cachedTargetingData.user}`)
227
230
  }
228
231
  ```
229
232
 
@@ -262,15 +265,41 @@ type WitnessProperties = {
262
265
  };
263
266
  ```
264
267
 
265
- ## Using (script tag)
268
+ ## Using a script tag
266
269
 
267
- For each [SDK release](https://github.com/Optable/optable-web-sdk/releases), a webpack generated browser bundle targeting the browsers list described by `npx browserslist "> 0.25%, not dead"` can be loaded on a web site via a `script` tag.
270
+ For each [SDK release](https://github.com/Optable/optable-web-sdk/releases), a webpack-generated browser bundle targeting the browsers list described by `npx browserslist "> 0.25%, not dead"` can be loaded on a website via a `script` tag.
268
271
 
269
- As described in the **Installation** section above, in order to avoid having to block the rendering of the page, the recommended way to load the SDK via `script` tag is asynchronously with the `async` attribute. Therefore, to use the SDK you should take care to `push` your _commands_ onto the `window.optable.cmd` array of functions, which are automatically executed by the SDK browser bundle once it has loaded.
272
+ As described in the **Installation** section above, the recommended way to load the SDK via `script` tag is asynchronously using the `async` attribute, to avoid blocking page rendering.
270
273
 
271
- The browser bundle exports the same `OptableSDK` constructor documented in the **npm module** section above in the `optable` window object, as `optable.SDK`
274
+ ### Option 1: Automatic Initialization
272
275
 
273
- The following shows an example of how to safely initialize the SDK and dispatch an `identify` API request to a DCN, from an input element after the document was loaded.
276
+ If you want to avoid manually instantiating the SDK, you can define the `instance_config` before loading the SDK bundle. When the script loads, it will automatically initialize the SDK using this configuration and assign the instance to `window.optable.instance`.
277
+
278
+ ```html
279
+ <!-- Define configuration before loading the SDK -->
280
+ <script>
281
+ window.optable = { cmd: [], instance_config: { host: "dcn.customer.com", site: "my-site" } };
282
+ </script>
283
+
284
+ <!-- Asynchronously load the SDK -->
285
+ <script async src="https://cdn.optable.co/web-sdk/v0/sdk.js"></script>
286
+
287
+ <!-- Optionally identify a client-side user after the page loads -->
288
+ <script>
289
+ window.addEventListener("DOMContentLoaded", () => {
290
+ optable.cmd.push(() => {
291
+ const emailInput = document.getElementById("email");
292
+ optable.instance.identify(optable.SDK.eid(emailInput.value)).then(() => {
293
+ console.log("Identify API Success!");
294
+ });
295
+ });
296
+ });
297
+ </script>
298
+ ```
299
+
300
+ ### Option 2: Manual Initialization with Commands Queue
301
+
302
+ You can also manually initialize the SDK using the cmd queue. This approach is useful if you prefer full control or are loading the config dynamically.
274
303
 
275
304
  ```html
276
305
  <!-- Asynchronously load the SDK as early as possible: -->
@@ -280,14 +309,12 @@ The following shows an example of how to safely initialize the SDK and dispatch
280
309
  <script>
281
310
  // Setup stub that will get replaced once the SDK get loaded
282
311
  window.optable = window.optable || { cmd: [] };
283
-
284
312
  optable.cmd.push(() => {
285
313
  // At this point optable.SDK is available and can be used to create a new sdk instance.
286
314
  // That instance can be stored anywhere for later referencing.
287
315
  // One option is to keep it within the global optable object space.
288
316
  optable.instance = new optable.SDK({ host: "dcn.customer.com", site: "my-site" });
289
317
  });
290
-
291
318
  // Now configure DOM content loaded event listener to dispatch identify() API:
292
319
  window.addEventListener("DOMContentLoaded", (event) => {
293
320
  optable.cmd.push(() => {
@@ -486,7 +513,75 @@ You can verify the signal was correctly passed to GAM by searching for its value
486
513
 
487
514
  ## Integrating Prebid
488
515
 
489
- The Optable Web SDK can fetch targeting data from a DCN and prepare an audience taxonomy object similar to the one described in [the prebid.js first party data documentation](https://docs.prebid.org/features/firstPartyData.html#segments-and-taxonomy). The `prebidORTB2FromCache()` function returns the object from the targeting data stored by `targeting()` API calls in `LocalStorage`.
516
+ The Optable Web SDK can integrate with Prebid.js to provide targeting data for real-time bidding. There are three main ways to integrate:
517
+
518
+ ### Open Pair ID Prebid Module
519
+
520
+ For publishers who only need to transmit Optable's cleanroom PAIR IDs in the bid stream, the [Open Pair ID Prebid module](https://docs.prebid.org/dev-docs/modules/userid-submodules/open-pair) provides a simple integration method.
521
+ This approach is recommended when PAIR ID transmission is your only requirement.
522
+
523
+ Here's how to integrate it:
524
+
525
+ ```html
526
+ <!-- Optable SDK async load: -->
527
+ <script async src="https://cdn.optable.co/web-sdk/v0/sdk.js"></script>
528
+
529
+ <!-- Prebid.js lib async load: -->
530
+ <script async src="prebid.js"></script>
531
+
532
+ <!-- Initialize Optable SDK and cache PAIR identifiers: -->
533
+ <script>
534
+ window.optable = window.optable || { cmd: [] };
535
+ // Init Optable SDK via command:
536
+ optable.cmd.push(function () {
537
+ optable.instance = new optable.SDK({ host: "dcn.customer.com", site: "my-site" });
538
+ });
539
+ // Call targeting() to cache PAIR identifiers
540
+ optable.cmd.push(function () {
541
+ optable.instance.targeting().catch((err) => {
542
+ // Maybe log error
543
+ });
544
+ });
545
+ </script>
546
+
547
+ <!-- Configure Prebid.js to use the cached PAIR identifiers: -->
548
+ <script>
549
+ window.pbjs = window.pbjs || { que: [] };
550
+ pbjs.que.push(function () {
551
+ // Configure the Open Pair Prebid module to look for our cached PAIR identifiers
552
+ pbjs.mergeConfig({
553
+ userSync: {
554
+ userIds: [
555
+ {
556
+ name: "openPairId",
557
+ inserter: "<PUBLISHER DOMAIN>", // Replace with your publisher domain
558
+ matcher: "optable.co",
559
+ params: {
560
+ optable: { storageKey: "_optable_pairId" },
561
+ },
562
+ },
563
+ ],
564
+ },
565
+ });
566
+ // Request bids - the Open Pair module will automatically include the PAIR identifiers
567
+ pbjs.requestBids({
568
+ bidsBackHandler: function (bids) {
569
+ // Handle bids
570
+ },
571
+ timeout: 3000,
572
+ });
573
+ });
574
+ </script>
575
+ ```
576
+
577
+ Key points about this integration:
578
+
579
+ - It only transmits PAIR IDs, making it simpler than the full ORTB2 integration
580
+ - The PAIR IDs are automatically picked up from the Optable SDK's local storage
581
+ - No additional configuration is needed beyond this snippet
582
+ - It's compatible with all bidders that support the Open Pair ID module
583
+
584
+ If you need to transmit additional targeting data or have more control over what information is sent to bidders, you should use the ORTB2 integration method described in the next section.
490
585
 
491
586
  ### Seller Defined Audiences
492
587
 
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see sdk.js.LICENSE.txt */
2
- (()=>{var e={396:e=>{e.exports=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}},312:(e,t,r)=>{var i;!function(){"use strict";var t="input is invalid type",n="object"==typeof window,s=n?window:{};s.JS_SHA256_NO_WINDOW&&(n=!1);var o=!n&&"object"==typeof self,a=!s.JS_SHA256_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;a?s=r.g:o&&(s=self);var c=!s.JS_SHA256_NO_COMMON_JS&&e.exports,u=r.amdO,d=!s.JS_SHA256_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,h="0123456789abcdef".split(""),p=[-2147483648,8388608,32768,128],g=[24,16,8,0],l=[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],f=["hex","array","digest","arrayBuffer"],m=[];!s.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!d||!s.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});var y=function(e,t){return function(r){return new P(t,!0).update(r)[e]()}},w=function(e){var t=y("hex",e);a&&(t=A(t,e)),t.create=function(){return new P(e)},t.update=function(e){return t.create().update(e)};for(var r=0;r<f.length;++r){var i=f[r];t[i]=y(i,e)}return t},A=function(e,i){var n,o=r(394),a=r(903).Buffer,c=i?"sha224":"sha256";return n=a.from&&!s.JS_SHA256_NO_BUFFER_FROM?a.from:function(e){return new a(e)},function(r){if("string"==typeof r)return o.createHash(c).update(r,"utf8").digest("hex");if(null==r)throw new Error(t);return r.constructor===ArrayBuffer&&(r=new Uint8Array(r)),Array.isArray(r)||ArrayBuffer.isView(r)||r.constructor===a?o.createHash(c).update(n(r)).digest("hex"):e(r)}},v=function(e,t){return function(r,i){return new b(r,t,!0).update(i)[e]()}},S=function(e){var t=v("hex",e);t.create=function(t){return new b(t,e)},t.update=function(e,r){return t.create(e).update(r)};for(var r=0;r<f.length;++r){var i=f[r];t[i]=v(i,e)}return t};function P(e,t){t?(m[0]=m[16]=m[1]=m[2]=m[3]=m[4]=m[5]=m[6]=m[7]=m[8]=m[9]=m[10]=m[11]=m[12]=m[13]=m[14]=m[15]=0,this.blocks=m):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 b(e,r,i){var n,s=typeof e;if("string"===s){var o,a=[],c=e.length,u=0;for(n=0;n<c;++n)(o=e.charCodeAt(n))<128?a[u++]=o:o<2048?(a[u++]=192|o>>>6,a[u++]=128|63&o):o<55296||o>=57344?(a[u++]=224|o>>>12,a[u++]=128|o>>>6&63,a[u++]=128|63&o):(o=65536+((1023&o)<<10|1023&e.charCodeAt(++n)),a[u++]=240|o>>>18,a[u++]=128|o>>>12&63,a[u++]=128|o>>>6&63,a[u++]=128|63&o);e=a}else{if("object"!==s)throw new Error(t);if(null===e)throw new Error(t);if(d&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||d&&ArrayBuffer.isView(e)))throw new Error(t)}e.length>64&&(e=new P(r,!0).update(e).array());var h=[],p=[];for(n=0;n<64;++n){var g=e[n]||0;h[n]=92^g,p[n]=54^g}P.call(this,r,i),this.update(p),this.oKeyPad=h,this.inner=!0,this.sharedMemory=i}P.prototype.update=function(e){if(!this.finalized){var r,i=typeof e;if("string"!==i){if("object"!==i)throw new Error(t);if(null===e)throw new Error(t);if(d&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||d&&ArrayBuffer.isView(e)))throw new Error(t);r=!0}for(var n,s,o=0,a=e.length,c=this.blocks;o<a;){if(this.hashed&&(this.hashed=!1,c[0]=this.block,this.block=c[16]=c[1]=c[2]=c[3]=c[4]=c[5]=c[6]=c[7]=c[8]=c[9]=c[10]=c[11]=c[12]=c[13]=c[14]=c[15]=0),r)for(s=this.start;o<a&&s<64;++o)c[s>>>2]|=e[o]<<g[3&s++];else for(s=this.start;o<a&&s<64;++o)(n=e.charCodeAt(o))<128?c[s>>>2]|=n<<g[3&s++]:n<2048?(c[s>>>2]|=(192|n>>>6)<<g[3&s++],c[s>>>2]|=(128|63&n)<<g[3&s++]):n<55296||n>=57344?(c[s>>>2]|=(224|n>>>12)<<g[3&s++],c[s>>>2]|=(128|n>>>6&63)<<g[3&s++],c[s>>>2]|=(128|63&n)<<g[3&s++]):(n=65536+((1023&n)<<10|1023&e.charCodeAt(++o)),c[s>>>2]|=(240|n>>>18)<<g[3&s++],c[s>>>2]|=(128|n>>>12&63)<<g[3&s++],c[s>>>2]|=(128|n>>>6&63)<<g[3&s++],c[s>>>2]|=(128|63&n)<<g[3&s++]);this.lastByteIndex=s,this.bytes+=s-this.start,s>=64?(this.block=c[16],this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},P.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>>2]|=p[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()}},P.prototype.hash=function(){var e,t,r,i,n,s,o,a,c,u=this.h0,d=this.h1,h=this.h2,p=this.h3,g=this.h4,f=this.h5,m=this.h6,y=this.h7,w=this.blocks;for(e=16;e<64;++e)t=((n=w[e-15])>>>7|n<<25)^(n>>>18|n<<14)^n>>>3,r=((n=w[e-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,w[e]=w[e-16]+t+w[e-7]+r|0;for(c=d&h,e=0;e<64;e+=4)this.first?(this.is224?(s=300032,y=(n=w[0]-1413257819)-150054599|0,p=n+24177077|0):(s=704751109,y=(n=w[0]-210244248)-1521486534|0,p=n+143694565|0),this.first=!1):(t=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),i=(s=u&d)^u&h^c,y=p+(n=y+(r=(g>>>6|g<<26)^(g>>>11|g<<21)^(g>>>25|g<<7))+(g&f^~g&m)+l[e]+w[e])|0,p=n+(t+i)|0),t=(p>>>2|p<<30)^(p>>>13|p<<19)^(p>>>22|p<<10),i=(o=p&u)^p&d^s,m=h+(n=m+(r=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7))+(y&g^~y&f)+l[e+1]+w[e+1])|0,t=((h=n+(t+i)|0)>>>2|h<<30)^(h>>>13|h<<19)^(h>>>22|h<<10),i=(a=h&p)^h&u^o,f=d+(n=f+(r=(m>>>6|m<<26)^(m>>>11|m<<21)^(m>>>25|m<<7))+(m&y^~m&g)+l[e+2]+w[e+2])|0,t=((d=n+(t+i)|0)>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),i=(c=d&h)^d&p^a,g=u+(n=g+(r=(f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7))+(f&m^~f&y)+l[e+3]+w[e+3])|0,u=n+(t+i)|0,this.chromeBugWorkAround=!0;this.h0=this.h0+u|0,this.h1=this.h1+d|0,this.h2=this.h2+h|0,this.h3=this.h3+p|0,this.h4=this.h4+g|0,this.h5=this.h5+f|0,this.h6=this.h6+m|0,this.h7=this.h7+y|0},P.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,i=this.h3,n=this.h4,s=this.h5,o=this.h6,a=this.h7,c=h[e>>>28&15]+h[e>>>24&15]+h[e>>>20&15]+h[e>>>16&15]+h[e>>>12&15]+h[e>>>8&15]+h[e>>>4&15]+h[15&e]+h[t>>>28&15]+h[t>>>24&15]+h[t>>>20&15]+h[t>>>16&15]+h[t>>>12&15]+h[t>>>8&15]+h[t>>>4&15]+h[15&t]+h[r>>>28&15]+h[r>>>24&15]+h[r>>>20&15]+h[r>>>16&15]+h[r>>>12&15]+h[r>>>8&15]+h[r>>>4&15]+h[15&r]+h[i>>>28&15]+h[i>>>24&15]+h[i>>>20&15]+h[i>>>16&15]+h[i>>>12&15]+h[i>>>8&15]+h[i>>>4&15]+h[15&i]+h[n>>>28&15]+h[n>>>24&15]+h[n>>>20&15]+h[n>>>16&15]+h[n>>>12&15]+h[n>>>8&15]+h[n>>>4&15]+h[15&n]+h[s>>>28&15]+h[s>>>24&15]+h[s>>>20&15]+h[s>>>16&15]+h[s>>>12&15]+h[s>>>8&15]+h[s>>>4&15]+h[15&s]+h[o>>>28&15]+h[o>>>24&15]+h[o>>>20&15]+h[o>>>16&15]+h[o>>>12&15]+h[o>>>8&15]+h[o>>>4&15]+h[15&o];return this.is224||(c+=h[a>>>28&15]+h[a>>>24&15]+h[a>>>20&15]+h[a>>>16&15]+h[a>>>12&15]+h[a>>>8&15]+h[a>>>4&15]+h[15&a]),c},P.prototype.toString=P.prototype.hex,P.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,i=this.h3,n=this.h4,s=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,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,s>>>24&255,s>>>16&255,s>>>8&255,255&s,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},P.prototype.array=P.prototype.digest,P.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},b.prototype=new P,b.prototype.finalize=function(){if(P.prototype.finalize.call(this),this.inner){this.inner=!1;var e=this.array();P.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(e),P.prototype.finalize.call(this)}};var I=w();I.sha256=I,I.sha224=w(!0),I.sha256.hmac=S(),I.sha224.hmac=S(!0),c?e.exports=I:(s.sha256=I.sha256,s.sha224=I.sha224,u&&(void 0===(i=function(){return I}.call(I,r,I,e))||(e.exports=i)))}()},903:()=>{},394:()=>{}},t={};function r(i){var n=t[i];if(void 0!==n)return n.exports;var s=t[i]={exports:{}};return e[i](s,s.exports,r),s.exports}r.amdO={},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e={r:"v0.30.0"};var t=r(396),i=r.n(t);async function n(e){const t=await A("/config",e,{method:"GET",headers:{Accept:"application/json"}});return new w(e).setSite(t),t}const s={"Europe/Vienna":"gdpr","Europe/Brussels":"gdpr","Europe/Sofia":"gdpr","Europe/Zagreb":"gdpr","Asia/Nicosia":"gdpr","Europe/Nicosia":"gdpr","Europe/Prague":"gdpr","Europe/Copenhagen":"gdpr","Europe/Tallinn":"gdpr","Europe/Helsinki":"gdpr","Europe/Paris":"gdpr","Europe/Berlin":"gdpr","Europe/Athens":"gdpr","Europe/Budapest":"gdpr","Atlantic/Reykjavik":"gdpr","Europe/Dublin":"gdpr","Europe/Rome":"gdpr","Europe/Riga":"gdpr","Europe/Vaduz":"gdpr","Europe/Vilnius":"gdpr","Europe/Luxembourg":"gdpr","Europe/Malta":"gdpr","Europe/Oslo":"gdpr","Europe/Warsaw":"gdpr","Europe/Lisbon":"gdpr","Europe/Bucharest":"gdpr","Europe/Bratislava":"gdpr","Europe/Ljubljana":"gdpr","Europe/Madrid":"gdpr","Europe/Stockholm":"gdpr","Europe/Amsterdam":"gdpr","Atlantic/Azores":"gdpr","Atlantic/Canary":"gdpr","America/Cayenne":"gdpr","America/Guadeloupe":"gdpr","Atlantic/Madeira":"gdpr","America/Martinique":"gdpr","Indian/Mayotte":"gdpr","Indian/Reunion":"gdpr","America/Marigot":"gdpr","Europe/Zurich":"gdpr","Europe/London":"gdpr","America/Toronto":"can","America/Adak":"us","America/Anchorage":"us","America/Atka":"us","America/Boise":"us","America/Chicago":"us","America/Denver":"us","America/Detroit":"us","America/Indiana/Indianapolis":"us","America/Indiana/Knox":"us","America/Indiana/Marengo":"us","America/Indiana/Petersburg":"us","America/Indiana/Tell_City":"us","America/Indiana/Vevay":"us","America/Indiana/Vincennes":"us","America/Indiana/Winamac":"us","America/Indianapolis":"us","America/Juneau":"us","America/Kentucky/Louisville":"us","America/Kentucky/Monticello":"us","America/Knox_IN":"us","America/Los_Angeles":"us","America/Louisville":"us","America/Menominee":"us","America/Metlakatla":"us","America/New_York":"us","America/Nome":"us","America/North_Dakota/Beulah":"us","America/North_Dakota/Center":"us","America/North_Dakota/New_Salem":"us","America/Phoenix":"us","America/Shiprock":"us","America/Sitka":"us","America/Yakutat":"us","Pacific/Honolulu":"us"},o="tcfcav1",a="tcfeuv2",c=[2],u=[5],d=[7,8,10,12,17,13,18,14,19,20,21,15,22,16,11,9];function h(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=function(e,t){const{gdprApplies:r,gppSectionIDs:i,gdprData:n}=t;if(void 0!==r)return r?"gdpr":"gdpr"===e?null:e;if(void 0!==n&&"gdpr"===e)return"gdpr";if(void 0===i||1===i.length&&0===i[0])return e;if(1===i.length&&-1===i[0])return null;if(i.some((e=>c.includes(e))))return"gdpr";if(i.some((e=>u.includes(e))))return"can";if(i.some((e=>d.includes(e))))return"us";switch(e){case"gdpr":if(!i.some((e=>c.includes(e))))return null;break;case"can":if(!i.some((e=>u.includes(e))))return null;break;case"us":if(!i.some((e=>d.includes(e))))return null}return e}(e,t),n={reg:i,gpp:t.gppString,gppSectionIDs:t.gppSectionIDs,gdpr:t.gdprString,gdprApplies:t.gdprApplies,deviceAccess:!1,createProfilesForAdvertising:!1,useProfilesForAdvertising:!1,measureAdvertisingPerformance:!1};switch(i){case"gdpr":t.gdprData?(n.deviceAccess=g(t.gdprData,1,r.tcfeuVendorID),n.createProfilesForAdvertising=g(t.gdprData,3,r.tcfeuVendorID),n.useProfilesForAdvertising=g(t.gdprData,4,r.tcfeuVendorID),n.measureAdvertisingPerformance=g(t.gdprData,7,r.tcfeuVendorID)):t.gppData&&(n.deviceAccess=f(t.gppData,1,r.tcfeuVendorID),n.createProfilesForAdvertising=f(t.gppData,3,r.tcfeuVendorID),n.useProfilesForAdvertising=f(t.gppData,4,r.tcfeuVendorID),n.measureAdvertisingPerformance=f(t.gppData,7,r.tcfeuVendorID));break;case"can":n.deviceAccess=!0,t.gppData&&(n.createProfilesForAdvertising=l(t.gppData,3,r.tcfcaVendorID),n.useProfilesForAdvertising=l(t.gppData,4,r.tcfcaVendorID),n.measureAdvertisingPerformance=l(t.gppData,7,r.tcfcaVendorID));break;default:n.deviceAccess=!0,n.createProfilesForAdvertising=!0,n.useProfilesForAdvertising=!0,n.measureAdvertisingPerformance=!0}return n}function p(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r={},i=h(e,r,t);return"function"==typeof window.__tcfapi&&window.__tcfapi?.("addEventListener",2,((n,s)=>{s&&("tcloaded"===n.eventStatus||"useractioncomplete"===n.eventStatus)&&(n=>{r.gdprString=n.tcString,r.gdprApplies=n.gdprApplies,r.gdprData=n,Object.assign(i,h(e,r,t))})(n)})),"function"==typeof window.__gpp&&window.__gpp?.("addEventListener",((n,s)=>{s&&"signalStatus"===n.eventName&&"ready"===n.data&&(n=>{r.gppString=n.gppString,r.gppSectionIDs=n.applicableSections,r.gppData=n,Object.assign(i,h(e,r,t))})(n.pingData)})),i}function g(e,t,r){return r?!!e.purpose?.consents?.[t]&&!!e.vendor?.consents?.[r]:!!e.publisher?.consents?.[t]}function l(e,t,r){const i=t>1,n=e.parsedSections?.[o]||[];if("number"==typeof r){const e=n.find((e=>"Version"in e));if(!e)return!1;let s=e.PurposesExpressConsent.includes(t)&&e.VendorExpressConsent.includes(r);return i&&(s||=e.PurposesImpliedConsent.includes(t)&&e.VendorImpliedConsent.includes(r)),s}const s=n.find((e=>"SubsectionType"in e&&3===e.SubsectionType));if(!s)return!1;let a=s.PubPurposesExpressConsent.includes(t);return i&&(a||=s.PubPurposesImpliedConsent.includes(t)),a}function f(e,t,r){const i=t>1,n=e.parsedSections?.[a]||[];if("number"==typeof r){const e=n.find((e=>"Version"in e));if(!e)return!1;let s=e.PurposeConsent.includes(t)&&e.VendorConsent.includes(r);return i&&(s||=e.PurposesLITransparency.includes(t)&&e.VendorLegitimateInterest.includes(r)),s}const s=n.find((e=>"SegmentType"in e&&3===e.SegmentType));if(!s)return!1;let o=s.PubPurposesConsent.includes(t);return i&&(o||=s.PubPurposesLITransparency.includes(t)),o}class m{constructor(e){i()(this,"consent",void 0),this.consent=e}getItem(e){return this.consent.deviceAccess?window.localStorage.getItem(e):null}setItem(e,t){this.consent.deviceAccess&&window.localStorage.setItem(e,t)}removeItem(e){this.consent.deviceAccess&&window.localStorage.removeItem(e)}}function y(e){const t=new Uint16Array(e.length);for(let r=0;r<t.length;r++)t[r]=e.charCodeAt(r);return btoa(String.fromCharCode(...new Uint8Array(t.buffer)))}class w{constructor(e){this.config=e,i()(this,"deprecatedPassportKey",void 0),i()(this,"passportKey",void 0),i()(this,"targetingKey",void 0),i()(this,"siteKey",void 0),i()(this,"storage",void 0);const t=function(e){return e.legacyHostCache?y(`${e.legacyHostCache}/${e.site}`):y(`${e.host}/${e.site}`)}(e),r=function(e){return e.node?y(`${e.host}/${e.node}`):y(e.host)}(e);this.deprecatedPassportKey="OPTABLE_PASS_"+t,this.passportKey="OPTABLE_PASSPORT_"+r,this.targetingKey="OPTABLE_TARGETING_"+r,this.siteKey="OPTABLE_SITE_"+r,this.storage=new m(this.config.consent)}getPassport(){return this.getFirstExistingItem(this.passportKey,this.deprecatedPassportKey)}getTargeting(){const e=this.storage.getItem(this.targetingKey);return e?JSON.parse(e):null}setPassport(e){e&&e.length>0&&this.storage.setItem(this.passportKey,e)}setTargeting(e){e&&this.storage.setItem(this.targetingKey,JSON.stringify(e))}setSite(e){e&&this.storage.setItem(this.siteKey,JSON.stringify(e))}getSite(){const e=this.storage.getItem(this.siteKey);return e?JSON.parse(e):null}getFirstExistingItem(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];for(const e of t){const t=this.storage.getItem(e);if(t)return t}return null}clearPassport(){this.storage.removeItem(this.passportKey),this.storage.removeItem(this.deprecatedPassportKey)}clearTargeting(){this.storage.removeItem(this.targetingKey)}clearSite(){this.storage.removeItem(this.siteKey)}}async function A(t,r,i){const n=await globalThis.fetch(function(t,r,i){const{host:n,cookies:s}=r,o=new URL(t,`https://${n}`);if(o.searchParams.set("osdk",`web-${e.r}`),o.searchParams.set("sid",r.sessionID),r.node&&o.searchParams.set("t",r.node),r.site&&o.searchParams.set("o",r.site),void 0!==r.consent.gpp&&o.searchParams.set("gpp",r.consent.gpp),void 0!==r.consent.gppSectionIDs&&o.searchParams.set("gpp_sid",r.consent.gppSectionIDs.join(",")),void 0!==r.consent.gdpr&&o.searchParams.set("gdpr_consent",r.consent.gdpr),void 0!==r.consent.gdprApplies&&o.searchParams.set("gdpr",Number(r.consent.gdprApplies).toString()),r.readOnly&&o.searchParams.set("ro","true"),s)o.searchParams.set("cookies","yes");else{const e=new w(r).getPassport();o.searchParams.set("cookies","no"),o.searchParams.set("passport",e||"")}const a={...i};return a.credentials=r.consent.deviceAccess?"include":"omit",r.mockedIP&&(a.headers=new Headers(a.headers),a.headers.set("X-Forwarded-For",r.mockedIP)),new Request(o.toString(),a)}(t,r,i)),s=n.headers.get("Content-Type"),o=s?.startsWith("application/json")?await n.json():await n.text();if(!n.ok)throw new Error(o.error);return o.passport&&(new w(r).setPassport(o.passport),delete o.passport),o}var v;function S(e){return{user:{data:(e?.audience??[]).map((e=>({name:e.provider,segment:e.ids,ext:{segtax:e.rtb_segtax}}))),ext:{eids:(e?.user??[]).map((e=>({source:e.provider,uids:e.ids.map((e=>{let{id:t}=e;return{id:t,atype:v.PersonID}}))})))}}}}function P(e){const t={};if(!e)return t;for(const r of e.audience??[])r.keyspace&&(r.keyspace in t||(t[r.keyspace]=[]),t[r.keyspace].push(...r.ids.map((e=>e.id))));return t}!function(e){e[e.DeviceID=1]="DeviceID",e[e.InAppImpression=2]="InAppImpression",e[e.PersonID=3]="PersonID"}(v||(v={}));const b={cookies:!0,initPassport:!0,readOnly:!1,experiments:[],consent:{reg:null,deviceAccess:!0,createProfilesForAdvertising:!0,useProfilesForAdvertising:!0,measureAdvertisingPerformance:!0}};function I(){const e=new Uint8Array(16);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}var E=r(312);class C{constructor(e){i()(this,"dcn",void 0),i()(this,"init",void 0),this.dcn=function(e){const t={host:e.host,site:e.site,cookies:e.cookies??b.cookies,initPassport:e.initPassport??b.initPassport,consent:b.consent,readOnly:e.readOnly??b.readOnly,node:e.node,legacyHostCache:e.legacyHostCache,experiments:e.experiments??b.experiments,mockedIP:e.mockedIP,sessionID:e.sessionID??I()};return e.consent?.static?t.consent=e.consent.static:e.consent?.cmpapi&&(t.consent=p(function(){const e=Intl.DateTimeFormat().resolvedOptions().timeZone,t=s[e];return"can"===t?["fr","fr-CA"].some((e=>navigator.languages.includes(e)))?"can":null:t??null}(),e.consent.cmpapi)),t}(e);const t=()=>{};this.init=this.dcn.initPassport?n(this.dcn).then(t).catch(t):Promise.resolve()}async identify(){await this.init;for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e,t){return A("/identify",e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}(this.dcn,t.filter((e=>e)))}async uid2Token(e){return await this.init,function(e,t){return A("/uid2/token",e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}(this.dcn,e)}async targeting(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"__passport__";return await this.init,async function(e,t){const r="/v2/targeting?"+new URLSearchParams({id:t}).toString(),i=await A(r,e,{method:"GET",headers:{Accept:"application/json"}});return i&&new w(e).setTargeting(i),i}(this.dcn,e)}targetingFromCache(){return e=this.dcn,new w(e).getTargeting();var e}async site(){return n(this.dcn)}siteFromCache(){return e=this.dcn,new w(e).getSite();var e}targetingClearCache(){var e;e=this.dcn,new w(e).clearTargeting()}async prebidORTB2(){return S(await this.targeting())}prebidORTB2FromCache(){return S(this.targetingFromCache())}async targetingKeyValues(){return P(await this.targeting())}targetingKeyValuesFromCache(){return P(this.targetingFromCache())}async witness(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return await this.init,function(e,t,r){const i={event:t,properties:r};return A("/witness",e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}(this.dcn,e,t)}async profile(e){return await this.init,function(e,t){const r={traits:t};return A("/profile",e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}(this.dcn,e)}async tokenize(e){return await this.init,function(e,t){let r="/v1/tokenize";e.experiments.includes("tokenize-v2")&&(r="/v2/tokenize");let i={id:t};return A(r,e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}(this.dcn,e)}async resolve(e){return await this.init,async function(e,t){const r=new URLSearchParams;"string"==typeof t&&r.append("id",t);const i="/v1/resolve?"+r.toString();return function(e){const t={clusters:[],lmpid:""};if("object"!=typeof e||null===e)return t;if("lmpid"in e&&"string"==typeof e?.lmpid&&(t.lmpid=e.lmpid),!("clusters"in e)||!Array.isArray(e?.clusters))return t;for(const r of e.clusters){const e={ids:[],traits:[]};if(Array.isArray(r?.ids))for(const t of r.ids)"string"==typeof t&&e.ids.push(t);if(Array.isArray(r?.traits))for(const t of r.traits)"string"==typeof t?.key&&"string"==typeof t?.value&&e.traits.push({key:t.key,value:t.value});(e.ids.length>0||e.traits.length>0)&&t.clusters.push(e)}return t}(await A(i,e,{method:"GET",headers:{Accept:"application/json"}}))}(this.dcn,e)}static eid(e){return e?"e:"+E.sha256.hex(e.toLowerCase().trim()):""}static sha256(e){return e?E.sha256.hex(e):""}static cid(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r="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&&(r=`c${t}:`),e?r+e.trim():""}static TargetingKeyValues(e){return P(e)}static PrebidORTB2(e){return S(e)}}i()(C,"version",e.r);const _=C;function k(e){return{advertiserId:e.advertiserId?.toString(),campaignId:e.campaignId?.toString(),creativeId:e.creativeId?.toString(),isEmpty:e.isEmpty?.toString(),lineItemId:e.lineItemId?.toString(),serviceName:e.serviceName?.toString(),size:e.size?.toString(),slotElementId:e.slot?.getSlotElementId(),sourceAgnosticCreativeId:e.sourceAgnosticCreativeId?.toString(),sourceAgnosticLineItemId:e.sourceAgnosticLineItemId?.toString()}}_.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",k(t))})),t.pubads().addEventListener("impressionViewable",(function(t){e.witness("googletag.events.impressionViewable",k(t))}))}))},_.prototype.installGPTSecureSignals=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];window.googletag=window.googletag||{cmd:[]};const i=window.googletag;t&&t.length>0&&i.cmd.push((()=>{t.forEach((e=>{let{provider:t,id:r}=e;i.secureSignalProviders.push({id:t,collectorFunction:()=>Promise.resolve(r)})}))}))};const T=/^[a-f0-9]{64}$/i;_.prototype.tryIdentifyFromParams=function(e,t){const r=new RegExp(`^${e||"oeid"}$`,"i"),i=new URLSearchParams(window.location.search);let n="";for(const[e,t]of i)if(r.test(e)){n=t;break}""!=n&&(t||function(e){return T.test(e)}(n))&&this.identify((t||"e")+":"+n.toLowerCase())},_.prototype.auctionConfigFromCache=function(){const e=this.siteFromCache();return e?e.auctionConfig??null:null},_.prototype.installGPTAuctionConfigs=function(e){const t=this;t.installGPTAuctionConfigs=function(){},window.googletag=window.googletag||{cmd:[]};const r=window.googletag;r.cmd.push((function(){let i=r.pubads().getSlots();e&&(i=i.filter(e));const n=t.auctionConfigFromCache();if(n)for(const e of i){const t=e.getSizes(),r=[];for(const e of t)"fluid"!==e&&r.push({configKey:n.seller+"-"+e.getWidth()+"x"+e.getHeight(),auctionConfig:{...n,requestedSize:{width:e.getWidth()+"px",height:e.getHeight()+"px"}}});e.setConfig({componentAuction:r})}}))},_.prototype.runAdAuction=async function(e,t){if(!("runAdAuction"in navigator))throw"run-ad-auction not supported";const r=document.getElementById(e);if(!r)throw"spot not found";const i=function(e){const t=window.getComputedStyle(e,null);return{width:t.getPropertyValue("width"),height:t.getPropertyValue("height")}}(r),n=this.auctionConfigFromCache();if(!n)return!1;const s={...n,requestedSize:i,resolveToConfig:!0},o=t?.iframe??!1;o&&(s.resolveToConfig=!1);const a=await navigator.runAdAuction(s);if(!a)return r.replaceChildren(),!1;if(o){const e=document.createElement("iframe");e.src=a,e.style.border="none",e.style.width=i.width,e.style.height=i.height,r.replaceChildren(e)}else{const e=document.createElement("fencedframe");e.config=a,e.style.border="none",r.replaceChildren(e)}return!0},_.prototype.joinAdInterestGroups=async function(){if(!("joinAdInterestGroup"in navigator))throw"join-ad-interest-group not supported";if(!(this.dcn.consent.deviceAccess&&this.dcn.consent.createProfilesForAdvertising&&this.dcn.consent.measureAdvertisingPerformance))throw"consent not granted for joining interest groups";const e=await this.site();if(!e.interestGroupPixel)throw"origin not enabled for protected audience apis";const t=new URL(e.interestGroupPixel),r=document.createElement("iframe");r.src=t.toString(),r.allow="join-ad-interest-group "+t.origin,r.style.display="none";const i=new Promise(((e,t)=>{window.addEventListener("message",(i=>{i.source===r.contentWindow&&("success"!==i.data.result?t():e())}))}));return document.body.appendChild(r),i},_.prototype.getTopics=async function(){if(!("browsingTopics"in document))throw"browsing-topics not supported";if(!this.dcn.consent.deviceAccess)throw"consent not granted for reading browsing topics";const e=await this.site();if(!e.getTopicsURL)throw"origin not enabled for topics api";const t=new URL(e.getTopicsURL),r=document.createElement("iframe");r.src=t.toString(),r.allow="browsing-topics "+t.origin,r.style.display="none";const i=new Promise(((e,t)=>{window.addEventListener("message",(i=>{i.source===r.contentWindow&&(i.data.error?t(new Error(i.data.error.toString())):e(i.data.result))}))}));return document.body.appendChild(r),i},_.prototype.ingestTopics=function(){this.getTopics().then((e=>{if(!e.length)return;const t=e.reduce(((e,t)=>{const r=`topics_v${t.taxonomyVersion}`;return e[r]?e[r]+=",":e[r]="",e[r]+=String(t.topic),e}),{});this.profile(t)})).catch((()=>{}))},window.optable=window.optable||{},window.optable.SDK=_,window.optable.cmd=new class{constructor(e){if(this.cmds=e,Array.isArray(this.cmds))for(const e of this.cmds)"function"==typeof e&&e()}push(e){e()}}(window.optable.cmd||[]),window.optable.utils={resolveMultiNodeTargeting:async function(e){return e?e.some((e=>e.priority))?async function(e){const t=new Set,r={user:{data:[],eids:[]}},i=new Map,n=new Map;const s=e.map((e=>{let{targetingFn:t,matcher:s,mm:o,priority:a}=e;return t().then((e=>function(e,t,s){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;const a=Math.max(0,o),{data:c=[],eids:u=[]}=e.ortb2?.user??{};r.user.data.push(...c),u.filter((e=>e.uids.length)).forEach((e=>{let{ext:r,...o}=e;const c=i.get(a)??[];i.set(a,[...c,t]);const u=n.get(a)??[];n.set(a,[...u,{...o,matcher:t,mm:s}])}))}(e,s,o,a)))}));await Promise.allSettled(s);const o=Array.from(n.keys()).sort(((e,t)=>e-t)).filter((e=>n.get(e)?.length)).shift();if(o){const e=i.get(o)||[];r.user.eids.push(...n.get(o)||[]),e.forEach((e=>t.add(e)))}return{ortb2:r,eidSources:t}}(e):async function(e){const t=new Set,r={user:{data:[],eids:[]}};const i=e.map((e=>{let{targetingFn:i,matcher:n,mm:s}=e;return i().then((e=>function(e,i,n){const{data:s=[],eids:o=[]}=e.ortb2?.user??{};r.user.data.push(...s),o.filter((e=>e.uids.length)).forEach((e=>{let{ext:s,...o}=e;t.add(i),r.user.eids.push({...o,mm:n,matcher:i})}))}(e,n,s)))}));return await Promise.allSettled(i),{ortb2:r,eidSources:t}}(e):Promise.reject("No targeting rules provided")}}})()})();
2
+ (()=>{var t={312:(t,e,r)=>{var i;!function(){"use strict";var e="input is invalid type",n="object"==typeof window,s=n?window:{};s.JS_SHA256_NO_WINDOW&&(n=!1);var o=!n&&"object"==typeof self,a=!s.JS_SHA256_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;a?s=r.g:o&&(s=self);var c=!s.JS_SHA256_NO_COMMON_JS&&t.exports,u=r.amdO,d=!s.JS_SHA256_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,h="0123456789abcdef".split(""),p=[-2147483648,8388608,32768,128],g=[24,16,8,0],l=[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],f=["hex","array","digest","arrayBuffer"],y=[];!s.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!d||!s.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});var m=function(t,e){return function(r){return new b(e,!0).update(r)[t]()}},w=function(t){var e=m("hex",t);a&&(e=A(e,t)),e.create=function(){return new b(t)},e.update=function(t){return e.create().update(t)};for(var r=0;r<f.length;++r){var i=f[r];e[i]=m(i,t)}return e},A=function(t,i){var n,o=r(394),a=r(903).Buffer,c=i?"sha224":"sha256";return n=a.from&&!s.JS_SHA256_NO_BUFFER_FROM?a.from:function(t){return new a(t)},function(r){if("string"==typeof r)return o.createHash(c).update(r,"utf8").digest("hex");if(null==r)throw new Error(e);return r.constructor===ArrayBuffer&&(r=new Uint8Array(r)),Array.isArray(r)||ArrayBuffer.isView(r)||r.constructor===a?o.createHash(c).update(n(r)).digest("hex"):t(r)}},v=function(t,e){return function(r,i){return new P(r,e,!0).update(i)[t]()}},S=function(t){var e=v("hex",t);e.create=function(e){return new P(e,t)},e.update=function(t,r){return e.create(t).update(r)};for(var r=0;r<f.length;++r){var i=f[r];e[i]=v(i,t)}return e};function b(t,e){e?(y[0]=y[16]=y[1]=y[2]=y[3]=y[4]=y[5]=y[6]=y[7]=y[8]=y[9]=y[10]=y[11]=y[12]=y[13]=y[14]=y[15]=0,this.blocks=y):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t?(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=t}function P(t,r,i){var n,s=typeof t;if("string"===s){var o,a=[],c=t.length,u=0;for(n=0;n<c;++n)(o=t.charCodeAt(n))<128?a[u++]=o:o<2048?(a[u++]=192|o>>>6,a[u++]=128|63&o):o<55296||o>=57344?(a[u++]=224|o>>>12,a[u++]=128|o>>>6&63,a[u++]=128|63&o):(o=65536+((1023&o)<<10|1023&t.charCodeAt(++n)),a[u++]=240|o>>>18,a[u++]=128|o>>>12&63,a[u++]=128|o>>>6&63,a[u++]=128|63&o);t=a}else{if("object"!==s)throw new Error(e);if(null===t)throw new Error(e);if(d&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||d&&ArrayBuffer.isView(t)))throw new Error(e)}t.length>64&&(t=new b(r,!0).update(t).array());var h=[],p=[];for(n=0;n<64;++n){var g=t[n]||0;h[n]=92^g,p[n]=54^g}b.call(this,r,i),this.update(p),this.oKeyPad=h,this.inner=!0,this.sharedMemory=i}b.prototype.update=function(t){if(!this.finalized){var r,i=typeof t;if("string"!==i){if("object"!==i)throw new Error(e);if(null===t)throw new Error(e);if(d&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||d&&ArrayBuffer.isView(t)))throw new Error(e);r=!0}for(var n,s,o=0,a=t.length,c=this.blocks;o<a;){if(this.hashed&&(this.hashed=!1,c[0]=this.block,this.block=c[16]=c[1]=c[2]=c[3]=c[4]=c[5]=c[6]=c[7]=c[8]=c[9]=c[10]=c[11]=c[12]=c[13]=c[14]=c[15]=0),r)for(s=this.start;o<a&&s<64;++o)c[s>>>2]|=t[o]<<g[3&s++];else for(s=this.start;o<a&&s<64;++o)(n=t.charCodeAt(o))<128?c[s>>>2]|=n<<g[3&s++]:n<2048?(c[s>>>2]|=(192|n>>>6)<<g[3&s++],c[s>>>2]|=(128|63&n)<<g[3&s++]):n<55296||n>=57344?(c[s>>>2]|=(224|n>>>12)<<g[3&s++],c[s>>>2]|=(128|n>>>6&63)<<g[3&s++],c[s>>>2]|=(128|63&n)<<g[3&s++]):(n=65536+((1023&n)<<10|1023&t.charCodeAt(++o)),c[s>>>2]|=(240|n>>>18)<<g[3&s++],c[s>>>2]|=(128|n>>>12&63)<<g[3&s++],c[s>>>2]|=(128|n>>>6&63)<<g[3&s++],c[s>>>2]|=(128|63&n)<<g[3&s++]);this.lastByteIndex=s,this.bytes+=s-this.start,s>=64?(this.block=c[16],this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},b.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex;t[16]=this.block,t[e>>>2]|=p[3&e],this.block=t[16],e>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}},b.prototype.hash=function(){var t,e,r,i,n,s,o,a,c,u=this.h0,d=this.h1,h=this.h2,p=this.h3,g=this.h4,f=this.h5,y=this.h6,m=this.h7,w=this.blocks;for(t=16;t<64;++t)e=((n=w[t-15])>>>7|n<<25)^(n>>>18|n<<14)^n>>>3,r=((n=w[t-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,w[t]=w[t-16]+e+w[t-7]+r|0;for(c=d&h,t=0;t<64;t+=4)this.first?(this.is224?(s=300032,m=(n=w[0]-1413257819)-150054599|0,p=n+24177077|0):(s=704751109,m=(n=w[0]-210244248)-1521486534|0,p=n+143694565|0),this.first=!1):(e=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),i=(s=u&d)^u&h^c,m=p+(n=m+(r=(g>>>6|g<<26)^(g>>>11|g<<21)^(g>>>25|g<<7))+(g&f^~g&y)+l[t]+w[t])|0,p=n+(e+i)|0),e=(p>>>2|p<<30)^(p>>>13|p<<19)^(p>>>22|p<<10),i=(o=p&u)^p&d^s,y=h+(n=y+(r=(m>>>6|m<<26)^(m>>>11|m<<21)^(m>>>25|m<<7))+(m&g^~m&f)+l[t+1]+w[t+1])|0,e=((h=n+(e+i)|0)>>>2|h<<30)^(h>>>13|h<<19)^(h>>>22|h<<10),i=(a=h&p)^h&u^o,f=d+(n=f+(r=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7))+(y&m^~y&g)+l[t+2]+w[t+2])|0,e=((d=n+(e+i)|0)>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),i=(c=d&h)^d&p^a,g=u+(n=g+(r=(f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7))+(f&y^~f&m)+l[t+3]+w[t+3])|0,u=n+(e+i)|0,this.chromeBugWorkAround=!0;this.h0=this.h0+u|0,this.h1=this.h1+d|0,this.h2=this.h2+h|0,this.h3=this.h3+p|0,this.h4=this.h4+g|0,this.h5=this.h5+f|0,this.h6=this.h6+y|0,this.h7=this.h7+m|0},b.prototype.hex=function(){this.finalize();var t=this.h0,e=this.h1,r=this.h2,i=this.h3,n=this.h4,s=this.h5,o=this.h6,a=this.h7,c=h[t>>>28&15]+h[t>>>24&15]+h[t>>>20&15]+h[t>>>16&15]+h[t>>>12&15]+h[t>>>8&15]+h[t>>>4&15]+h[15&t]+h[e>>>28&15]+h[e>>>24&15]+h[e>>>20&15]+h[e>>>16&15]+h[e>>>12&15]+h[e>>>8&15]+h[e>>>4&15]+h[15&e]+h[r>>>28&15]+h[r>>>24&15]+h[r>>>20&15]+h[r>>>16&15]+h[r>>>12&15]+h[r>>>8&15]+h[r>>>4&15]+h[15&r]+h[i>>>28&15]+h[i>>>24&15]+h[i>>>20&15]+h[i>>>16&15]+h[i>>>12&15]+h[i>>>8&15]+h[i>>>4&15]+h[15&i]+h[n>>>28&15]+h[n>>>24&15]+h[n>>>20&15]+h[n>>>16&15]+h[n>>>12&15]+h[n>>>8&15]+h[n>>>4&15]+h[15&n]+h[s>>>28&15]+h[s>>>24&15]+h[s>>>20&15]+h[s>>>16&15]+h[s>>>12&15]+h[s>>>8&15]+h[s>>>4&15]+h[15&s]+h[o>>>28&15]+h[o>>>24&15]+h[o>>>20&15]+h[o>>>16&15]+h[o>>>12&15]+h[o>>>8&15]+h[o>>>4&15]+h[15&o];return this.is224||(c+=h[a>>>28&15]+h[a>>>24&15]+h[a>>>20&15]+h[a>>>16&15]+h[a>>>12&15]+h[a>>>8&15]+h[a>>>4&15]+h[15&a]),c},b.prototype.toString=b.prototype.hex,b.prototype.digest=function(){this.finalize();var t=this.h0,e=this.h1,r=this.h2,i=this.h3,n=this.h4,s=this.h5,o=this.h6,a=this.h7,c=[t>>>24&255,t>>>16&255,t>>>8&255,255&t,e>>>24&255,e>>>16&255,e>>>8&255,255&e,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,s>>>24&255,s>>>16&255,s>>>8&255,255&s,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},b.prototype.array=b.prototype.digest,b.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(this.is224?28:32),e=new DataView(t);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),e.setUint32(20,this.h5),e.setUint32(24,this.h6),this.is224||e.setUint32(28,this.h7),t},P.prototype=new b,P.prototype.finalize=function(){if(b.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();b.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(t),b.prototype.finalize.call(this)}};var E=w();E.sha256=E,E.sha224=w(!0),E.sha256.hmac=S(),E.sha224.hmac=S(!0),c?t.exports=E:(s.sha256=E.sha256,s.sha224=E.sha224,u&&(void 0===(i=function(){return E}.call(E,r,E,t))||(t.exports=i)))}()},903:()=>{},394:()=>{}},e={};function r(i){var n=e[i];if(void 0!==n)return n.exports;var s=e[i]={exports:{}};return t[i](s,s.exports,r),s.exports}r.amdO={},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),(()=>{"use strict";const t={r:"v0.32.0"};function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function i(t,r,i){return(r=function(t){var r=function(t){if("object"!=e(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,"string");if("object"!=e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==e(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[r]=i,t}async function n(t){const e=await S("/config",t,{method:"GET",headers:{Accept:"application/json"}});return new v(t).setSite(e),e}const s={"Europe/Vienna":"gdpr","Europe/Brussels":"gdpr","Europe/Sofia":"gdpr","Europe/Zagreb":"gdpr","Asia/Nicosia":"gdpr","Europe/Nicosia":"gdpr","Europe/Prague":"gdpr","Europe/Copenhagen":"gdpr","Europe/Tallinn":"gdpr","Europe/Helsinki":"gdpr","Europe/Paris":"gdpr","Europe/Berlin":"gdpr","Europe/Athens":"gdpr","Europe/Budapest":"gdpr","Atlantic/Reykjavik":"gdpr","Europe/Dublin":"gdpr","Europe/Rome":"gdpr","Europe/Riga":"gdpr","Europe/Vaduz":"gdpr","Europe/Vilnius":"gdpr","Europe/Luxembourg":"gdpr","Europe/Malta":"gdpr","Europe/Oslo":"gdpr","Europe/Warsaw":"gdpr","Europe/Lisbon":"gdpr","Europe/Bucharest":"gdpr","Europe/Bratislava":"gdpr","Europe/Ljubljana":"gdpr","Europe/Madrid":"gdpr","Europe/Stockholm":"gdpr","Europe/Amsterdam":"gdpr","Atlantic/Azores":"gdpr","Atlantic/Canary":"gdpr","America/Cayenne":"gdpr","America/Guadeloupe":"gdpr","Atlantic/Madeira":"gdpr","America/Martinique":"gdpr","Indian/Mayotte":"gdpr","Indian/Reunion":"gdpr","America/Marigot":"gdpr","Europe/Zurich":"gdpr","Europe/London":"gdpr","America/Toronto":"can","America/Adak":"us","America/Anchorage":"us","America/Atka":"us","America/Boise":"us","America/Chicago":"us","America/Denver":"us","America/Detroit":"us","America/Indiana/Indianapolis":"us","America/Indiana/Knox":"us","America/Indiana/Marengo":"us","America/Indiana/Petersburg":"us","America/Indiana/Tell_City":"us","America/Indiana/Vevay":"us","America/Indiana/Vincennes":"us","America/Indiana/Winamac":"us","America/Indianapolis":"us","America/Juneau":"us","America/Kentucky/Louisville":"us","America/Kentucky/Monticello":"us","America/Knox_IN":"us","America/Los_Angeles":"us","America/Louisville":"us","America/Menominee":"us","America/Metlakatla":"us","America/New_York":"us","America/Nome":"us","America/North_Dakota/Beulah":"us","America/North_Dakota/Center":"us","America/North_Dakota/New_Salem":"us","America/Phoenix":"us","America/Shiprock":"us","America/Sitka":"us","America/Yakutat":"us","Pacific/Honolulu":"us"},o="tcfcav1",a="tcfeuv2",c=[2],u=[5],d=[7,8,10,12,17,13,18,14,19,20,21,15,22,16,11,9];function h(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=function(t,e){const{gdprApplies:r,gppSectionIDs:i,gdprData:n}=e;if(void 0!==r)return r?"gdpr":"gdpr"===t?null:t;if(void 0!==n&&"gdpr"===t)return"gdpr";if(void 0===i||1===i.length&&0===i[0])return t;if(1===i.length&&-1===i[0])return null;if(i.some((t=>c.includes(t))))return"gdpr";if(i.some((t=>u.includes(t))))return"can";if(i.some((t=>d.includes(t))))return"us";switch(t){case"gdpr":if(!i.some((t=>c.includes(t))))return null;break;case"can":if(!i.some((t=>u.includes(t))))return null;break;case"us":if(!i.some((t=>d.includes(t))))return null}return t}(t,e),n={reg:i,gpp:e.gppString,gppSectionIDs:e.gppSectionIDs,gdpr:e.gdprString,gdprApplies:e.gdprApplies,deviceAccess:!1,createProfilesForAdvertising:!1,useProfilesForAdvertising:!1,measureAdvertisingPerformance:!1};switch(i){case"gdpr":e.gdprData?(n.deviceAccess=g(e.gdprData,1,r.tcfeuVendorID),n.createProfilesForAdvertising=g(e.gdprData,3,r.tcfeuVendorID),n.useProfilesForAdvertising=g(e.gdprData,4,r.tcfeuVendorID),n.measureAdvertisingPerformance=g(e.gdprData,7,r.tcfeuVendorID)):e.gppData&&(n.deviceAccess=f(e.gppData,1,r.tcfeuVendorID),n.createProfilesForAdvertising=f(e.gppData,3,r.tcfeuVendorID),n.useProfilesForAdvertising=f(e.gppData,4,r.tcfeuVendorID),n.measureAdvertisingPerformance=f(e.gppData,7,r.tcfeuVendorID));break;case"can":n.deviceAccess=!0,e.gppData&&(n.createProfilesForAdvertising=l(e.gppData,3,r.tcfcaVendorID),n.useProfilesForAdvertising=l(e.gppData,4,r.tcfcaVendorID),n.measureAdvertisingPerformance=l(e.gppData,7,r.tcfcaVendorID));break;default:n.deviceAccess=!0,n.createProfilesForAdvertising=!0,n.useProfilesForAdvertising=!0,n.measureAdvertisingPerformance=!0}return n}function p(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r={},i=h(t,r,e);return"function"==typeof window.__tcfapi&&window.__tcfapi?.("addEventListener",2,((n,s)=>{s&&("tcloaded"===n.eventStatus||"useractioncomplete"===n.eventStatus)&&(n=>{r.gdprString=n.tcString,r.gdprApplies=n.gdprApplies,r.gdprData=n,Object.assign(i,h(t,r,e))})(n)})),"function"==typeof window.__gpp&&window.__gpp?.("addEventListener",((n,s)=>{s&&"signalStatus"===n.eventName&&"ready"===n.data&&(n=>{r.gppString=n.gppString,r.gppSectionIDs=n.applicableSections,r.gppData=n,Object.assign(i,h(t,r,e))})(n.pingData)})),i}function g(t,e,r){return r?!!t.purpose?.consents?.[e]&&!!t.vendor?.consents?.[r]:!!t.publisher?.consents?.[e]}function l(t,e,r){const i=e>1,n=t.parsedSections?.[o]||[];if("number"==typeof r){const t=n.find((t=>"Version"in t));if(!t)return!1;let s=t.PurposesExpressConsent.includes(e)&&t.VendorExpressConsent.includes(r);return i&&(s||=t.PurposesImpliedConsent.includes(e)&&t.VendorImpliedConsent.includes(r)),s}const s=n.find((t=>"SubsectionType"in t&&3===t.SubsectionType));if(!s)return!1;let a=s.PubPurposesExpressConsent.includes(e);return i&&(a||=s.PubPurposesImpliedConsent.includes(e)),a}function f(t,e,r){const i=e>1,n=t.parsedSections?.[a]||[];if("number"==typeof r){const t=n.find((t=>"Version"in t));if(!t)return!1;let s=t.PurposeConsent.includes(e)&&t.VendorConsent.includes(r);return i&&(s||=t.PurposesLITransparency.includes(e)&&t.VendorLegitimateInterest.includes(r)),s}const s=n.find((t=>"SegmentType"in t&&3===t.SegmentType));if(!s)return!1;let o=s.PubPurposesConsent.includes(e);return i&&(o||=s.PubPurposesLITransparency.includes(e)),o}class y{constructor(t){i(this,"consent",void 0),this.consent=t}getItem(t){return this.consent.deviceAccess?window.localStorage.getItem(t):null}setItem(t,e){this.consent.deviceAccess&&window.localStorage.setItem(t,e)}removeItem(t){this.consent.deviceAccess&&window.localStorage.removeItem(t)}}const m="_optable_pairId";function w(t){const e=new Uint16Array(t.length);for(let r=0;r<e.length;r++)e[r]=t.charCodeAt(r);return btoa(String.fromCharCode(...new Uint8Array(e.buffer)))}function A(t){return t.node?w(`${t.host}/${t.node}`):w(`${t.host}`)}class v{constructor(t){this.config=t,i(this,"passportKeys",void 0),i(this,"targetingKeys",void 0),i(this,"siteKeys",void 0),i(this,"pairKeys",void 0),i(this,"storage",void 0),this.passportKeys=function(t){const e=[],r=[],i=`OPTABLE_PASSPORT_${A(t)}`;return e.push(i),r.push(i),t.legacyHostCache?(r.push(`OPTABLE_PASSPORT_${w(`${t.legacyHostCache}`)}`),r.push(`OPTABLE_PASS_${w(`${t.legacyHostCache}/${t.site}`)}`)):r.push(`OPTABLE_PASS_${w(`${t.host}/${t.site}`)}`),{write:e,read:r}}(t),this.targetingKeys=function(t){const e=`OPTABLE_TARGETING_${A(t)}`;return{write:[e],read:[e]}}(t),this.siteKeys=function(t){const e=`OPTABLE_SITE_${A(t)}`;return{write:[e],read:[e]}}(t),this.pairKeys={write:[m],read:[m]},this.storage=new y(this.config.consent)}getPassport(){return this.readStorageKeys(this.passportKeys)}setPassport(t){this.writeToStorageKeys(this.passportKeys,t)}getTargeting(){const t=this.readStorageKeys(this.targetingKeys);return t?JSON.parse(t):null}setTargeting(t){t&&(this.writeToStorageKeys(this.targetingKeys,JSON.stringify(t)),this.setPairIDs(t))}getSite(){const t=this.readStorageKeys(this.siteKeys);return t?JSON.parse(t):null}setSite(t){t&&this.writeToStorageKeys(this.siteKeys,JSON.stringify(t))}setPairIDs(t){const e=t.ortb2?.user?.eids?.filter((t=>"pair-protocol.com"===t.source)),r=e?.flatMap((t=>t.uids));if(!r)return;const i=new Set(r.map((t=>t.id)));this.writeToStorageKeys(this.pairKeys,btoa(JSON.stringify({envelope:[...i]})))}getPairIDs(){const t=this.readStorageKeys(this.pairKeys);return t?JSON.parse(atob(t))?.envelope:null}readStorageKeys(t){for(const e of t.read){const t=this.storage.getItem(e);if(t)return t}return null}writeToStorageKeys(t,e){if(e)for(const r of t.write)this.storage.setItem(r,e)}clearStorageKeys(t){for(const e of t.read)this.storage.removeItem(e)}clearPassport(){this.clearStorageKeys(this.passportKeys)}clearTargeting(){this.clearStorageKeys(this.targetingKeys)}clearSite(){this.clearStorageKeys(this.siteKeys)}}async function S(e,r,i){const n=await globalThis.fetch(function(e,r,i){const{host:n,cookies:s}=r,o=new URL(e,`https://${n}`);if(o.searchParams.set("osdk",`web-${t.r}`),o.searchParams.set("sid",r.sessionID),r.skipEnrichment&&o.searchParams.set("skip_enrichment",`${r.skipEnrichment}`),r.node&&o.searchParams.set("t",r.node),r.site&&o.searchParams.set("o",r.site),void 0!==r.consent.gpp&&o.searchParams.set("gpp",r.consent.gpp),void 0!==r.consent.gppSectionIDs&&o.searchParams.set("gpp_sid",r.consent.gppSectionIDs.join(",")),void 0!==r.consent.gdpr&&o.searchParams.set("gdpr_consent",r.consent.gdpr),void 0!==r.consent.gdprApplies&&o.searchParams.set("gdpr",Number(r.consent.gdprApplies).toString()),r.readOnly&&o.searchParams.set("ro","true"),s)o.searchParams.set("cookies","yes");else{const t=new v(r).getPassport();o.searchParams.set("cookies","no"),o.searchParams.set("passport",t||"")}const a={...i};return a.credentials=r.consent.deviceAccess?"include":"omit",r.mockedIP&&(a.headers=new Headers(a.headers),a.headers.set("X-Forwarded-For",r.mockedIP)),new Request(o.toString(),a)}(e,r,i)),s=n.headers.get("Content-Type"),o=s?.startsWith("application/json")?await n.json():await n.text();if(!n.ok)throw new Error(o.error);return o.passport&&(new v(r).setPassport(o.passport),delete o.passport),o}var b,P,E,I=((P=I||{})[P.Banner=1]="Banner",P[P.Video=2]="Video",P[P.Audio=3]="Audio",P[P.Native=4]="Native",P),T={},_={},C={};(E=b||(b={})).Placement=_,E.Media=C,E.Context=T;const k={cookies:!0,initPassport:!0,readOnly:!1,experiments:[],consent:{reg:null,deviceAccess:!0,createProfilesForAdvertising:!0,useProfilesForAdvertising:!0,measureAdvertisingPerformance:!0}};function D(){const t=new Uint8Array(16);return crypto.getRandomValues(t),btoa(String.fromCharCode(...t)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function O(t){return{user:{data:(t?.audience??[]).map((t=>({name:t.provider,segment:t.ids,ext:{segtax:t.rtb_segtax}}))),ext:{eids:(t?.user??[]).map((t=>({source:t.provider,uids:t.ids.map((t=>{let{id:e}=t;return{id:e,atype:3}}))})))}}}}function x(t){const e={};if(!t)return e;for(const r of t.audience??[])r.keyspace&&(r.keyspace in e||(e[r.keyspace]=[]),e[r.keyspace].push(...r.ids.map((t=>t.id))));return e}var K=r(312);class B{constructor(t){i(this,"dcn",void 0),i(this,"init",void 0),this.dcn=function(t){const e={host:t.host,site:t.site,cookies:t.cookies??k.cookies,initPassport:t.initPassport??k.initPassport,consent:k.consent,readOnly:t.readOnly??k.readOnly,node:t.node,legacyHostCache:t.legacyHostCache,experiments:t.experiments??k.experiments,mockedIP:t.mockedIP,sessionID:t.sessionID??D(),skipEnrichment:t.skipEnrichment,initTargeting:t.initTargeting};return t.consent?.static?e.consent=t.consent.static:t.consent?.cmpapi&&(e.consent=p(function(){const t=Intl.DateTimeFormat().resolvedOptions().timeZone,e=s[t];return"can"===e?["fr","fr-CA"].some((t=>navigator.languages.includes(t)))?"can":null:e??null}(),t.consent.cmpapi)),e}(t),this.init=this.initialize()}async initialize(){this.dcn.initPassport&&await n(this.dcn).catch((()=>{})),this.dcn.initTargeting&&this.targeting().catch((()=>{}))}async identify(){await this.init;for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return function(t,e){return S("/identify",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}(this.dcn,e.filter((t=>t)))}async uid2Token(t){return await this.init,function(t,e){return S("/uid2/token",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}(this.dcn,t)}async targeting(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"__passport__";return await this.init,async function(t,e){const r="/v2/targeting?"+new URLSearchParams({id:e}).toString(),i=await S(r,t,{method:"GET",headers:{Accept:"application/json"}});return i&&(new v(t).setTargeting(i),function(t,e){const r=e.ortb2?.user?.eids?.map((t=>t.matcher));window.dispatchEvent(new CustomEvent("optable-targeting:change",{detail:{instance:t.node||t.host,resolved:!!e.ortb2?.user?.eids?.length,ortb2:e.ortb2,provenance:new Set(r)}}))}(t,i)),i}(this.dcn,t)}targetingFromCache(){return t=this.dcn,new v(t).getTargeting();var t}async site(){return n(this.dcn)}siteFromCache(){return t=this.dcn,new v(t).getSite();var t}targetingClearCache(){var t;t=this.dcn,new v(t).clearTargeting()}async prebidORTB2(){return O(await this.targeting())}prebidORTB2FromCache(){return O(this.targetingFromCache())}async targetingKeyValues(){return x(await this.targeting())}targetingKeyValuesFromCache(){return x(this.targetingFromCache())}async witness(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return await this.init,function(t,e,r){const i={event:e,properties:r};return S("/witness",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}(this.dcn,t,e)}async profile(t){return await this.init,function(t,e){const r={traits:e};return S("/profile",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}(this.dcn,t)}async tokenize(t){return await this.init,function(t,e){let r="/v1/tokenize";t.experiments.includes("tokenize-v2")&&(r="/v2/tokenize");let i={id:e};return S(r,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}(this.dcn,t)}async resolve(t){return await this.init,async function(t,e){const r=new URLSearchParams;"string"==typeof e&&r.append("id",e);const i="/v1/resolve?"+r.toString();return function(t){const e={clusters:[],lmpid:""};if("object"!=typeof t||null===t)return e;if("lmpid"in t&&"string"==typeof t?.lmpid&&(e.lmpid=t.lmpid),!("clusters"in t)||!Array.isArray(t?.clusters))return e;for(const r of t.clusters){const t={ids:[],traits:[]};if(Array.isArray(r?.ids))for(const e of r.ids)"string"==typeof e&&t.ids.push(e);if(Array.isArray(r?.traits))for(const e of r.traits)"string"==typeof e?.key&&"string"==typeof e?.value&&t.traits.push({key:e.key,value:e.value});(t.ids.length>0||t.traits.length>0)&&e.clusters.push(t)}return e}(await S(i,t,{method:"GET",headers:{Accept:"application/json"}}))}(this.dcn,t)}static eid(t){return t?"e:"+K.sha256.hex(t.toLowerCase().trim()):""}static sha256(t){return t?K.sha256.hex(t):""}static cid(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r="c:";if("string"!=typeof t)throw new Error("Invalid ppid");if("number"!=typeof e||isNaN(e)||e<0||e>9)throw new Error("Invalid variant");return e>0&&(r=`c${e}:`),t?r+t.trim():""}static TargetingKeyValues(t){return x(t)}static PrebidORTB2(t){return O(t)}}i(B,"version",t.r);const N=B;function V(t){return{advertiserId:t.advertiserId?.toString(),campaignId:t.campaignId?.toString(),creativeId:t.creativeId?.toString(),isEmpty:t.isEmpty?.toString(),lineItemId:t.lineItemId?.toString(),serviceName:t.serviceName?.toString(),size:t.size?.toString(),slotElementId:t.slot?.getSlotElementId(),sourceAgnosticCreativeId:t.sourceAgnosticCreativeId?.toString(),sourceAgnosticLineItemId:t.sourceAgnosticLineItemId?.toString()}}N.prototype.installGPTEventListeners=function(){const t=this;t.installGPTEventListeners=function(){},window.googletag=window.googletag||{cmd:[]};const e=window.googletag;e.cmd.push((function(){e.pubads().addEventListener("slotRenderEnded",(function(e){t.witness("googletag.events.slotRenderEnded",V(e))})),e.pubads().addEventListener("impressionViewable",(function(e){t.witness("googletag.events.impressionViewable",V(e))}))}))},N.prototype.installGPTSecureSignals=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];window.googletag=window.googletag||{cmd:[]};const i=window.googletag;e&&e.length>0&&i.cmd.push((()=>{e.forEach((t=>{let{provider:e,id:r}=t;i.secureSignalProviders.push({id:e,collectorFunction:()=>Promise.resolve(r)})}))}))};const j=/^[a-f0-9]{64}$/i;N.prototype.tryIdentifyFromParams=function(t,e){const r=new RegExp(`^${t||"oeid"}$`,"i"),i=new URLSearchParams(window.location.search);let n="";for(const[t,e]of i)if(r.test(t)){n=e;break}""!=n&&(e||function(t){return j.test(t)}(n))&&this.identify((e||"e")+":"+n.toLowerCase())},N.prototype.auctionConfig=async function(){let t=this.siteFromCache();return t||(t=await this.site()),t.auctionConfig??null},N.prototype.installGPTAuctionConfigs=async function(t){this.installGPTAuctionConfigs=function(){return Promise.resolve()};const e=await this.auctionConfig();if(!e)return;window.googletag=window.googletag||{cmd:[]};const r=window.googletag;r.cmd.push((function(){let i=r.pubads().getSlots();t&&(i=i.filter(t));for(const t of i){const r=t.getSizes(),i=[];for(const t of r)"fluid"!==t&&i.push({configKey:e.seller+"-"+t.getWidth()+"x"+t.getHeight(),auctionConfig:{...e,requestedSize:{width:t.getWidth()+"px",height:t.getHeight()+"px"}}});t.setConfig({componentAuction:i})}}))},N.prototype.runAdAuction=async function(t,e){if(!("runAdAuction"in navigator))throw"run-ad-auction not supported";const r=document.getElementById(t);if(!r)throw"spot not found";const i=function(t){const e=window.getComputedStyle(t,null);return{width:e.getPropertyValue("width"),height:e.getPropertyValue("height")}}(r),n=await this.auctionConfig();if(!n)return!1;const s={...n,requestedSize:i,resolveToConfig:!0},o=e?.iframe??!1;o&&(s.resolveToConfig=!1);const a=await navigator.runAdAuction(s);if(!a)return r.replaceChildren(),!1;if(o){const t=document.createElement("iframe");t.src=a,t.style.border="none",t.style.width=i.width,t.style.height=i.height,r.replaceChildren(t)}else{const t=document.createElement("fencedframe");t.config=a,t.style.border="none",r.replaceChildren(t)}return!0},N.prototype.joinAdInterestGroups=async function(){if(!("joinAdInterestGroup"in navigator))throw"join-ad-interest-group not supported";if(!(this.dcn.consent.deviceAccess&&this.dcn.consent.createProfilesForAdvertising&&this.dcn.consent.measureAdvertisingPerformance))throw"consent not granted for joining interest groups";const t=await this.site();if(!t.interestGroupPixel)throw"origin not enabled for protected audience apis";const e=new URL(t.interestGroupPixel),r=document.createElement("iframe");r.src=e.toString(),r.allow="join-ad-interest-group "+e.origin,r.style.display="none";const i=new Promise(((t,e)=>{window.addEventListener("message",(i=>{i.source===r.contentWindow&&("success"!==i.data.result?e():t())}))}));return document.body.appendChild(r),i},N.prototype.getTopics=async function(){if(!("browsingTopics"in document))throw"browsing-topics not supported";if(!this.dcn.consent.deviceAccess)throw"consent not granted for reading browsing topics";const t=await this.site();if(!t.getTopicsURL)throw"origin not enabled for topics api";const e=new URL(t.getTopicsURL),r=document.createElement("iframe");r.src=e.toString(),r.allow="browsing-topics "+e.origin,r.style.display="none";const i=new Promise(((t,e)=>{window.addEventListener("message",(i=>{i.source===r.contentWindow&&(i.data.error?e(new Error(i.data.error.toString())):t(i.data.result))}))}));return document.body.appendChild(r),i},N.prototype.ingestTopics=function(){this.getTopics().then((t=>{if(!t.length)return;const e=t.reduce(((t,e)=>{const r=`topics_v${e.taxonomyVersion}`;return t[r]?t[r]+=",":t[r]="",t[r]+=String(e.topic),t}),{});this.profile(e)})).catch((()=>{}))},window.optable=window.optable||{},window.optable.SDK=N,window.optable.cmd=new class{constructor(t){if(this.cmds=t,Array.isArray(this.cmds))for(const t of this.cmds)"function"==typeof t&&t()}push(t){t()}}(window.optable.cmd||[]),window.optable.utils={resolveMultiNodeTargeting:async function(t){return t?t.some((t=>t.priority))?async function(t){const e=new Set,r={user:{data:[],eids:[]}},i=new Map,n=new Map;const s=t.map((t=>{let{targetingFn:e,matcher:s,mm:o,priority:a}=t;return e().then((t=>function(t,e,s){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;const a=Math.max(0,o),{data:c=[],eids:u=[]}=t.ortb2?.user??{};r.user.data.push(...c),u.filter((t=>t.uids.length)).forEach((t=>{let{ext:r,...o}=t;const c=i.get(a)??[];i.set(a,[...c,e]);const u=n.get(a)??[];n.set(a,[...u,{...o,matcher:e,mm:s}])}))}(t,s,o,a)))}));await Promise.allSettled(s);const o=Array.from(n.keys()).sort(((t,e)=>t-e)).filter((t=>n.get(t)?.length)).shift();if(o){const t=i.get(o)||[];r.user.eids.push(...n.get(o)||[]),t.forEach((t=>e.add(t)))}return{ortb2:r,eidSources:e}}(t):async function(t){const e=new Set,r={user:{data:[],eids:[]}};const i=t.map((t=>{let{targetingFn:i,matcher:n,mm:s}=t;return i().then((t=>function(t,i,n){const{data:s=[],eids:o=[]}=t.ortb2?.user??{};r.user.data.push(...s),o.filter((t=>t.uids.length)).forEach((t=>{let{ext:s,...o}=t;e.add(i),r.user.eids.push({...o,mm:n,matcher:i})}))}(t,n,s)))}));return await Promise.allSettled(i),{ortb2:r,eidSources:e}}(t):Promise.reject("No targeting rules provided")}},window.optable.instance_config&&(window.optable.instance=new N(window.optable.instance_config))})()})();
@@ -11,9 +11,9 @@ type RunAdAuctionOptions = {
11
11
  declare module "../sdk" {
12
12
  interface OptableSDK {
13
13
  joinAdInterestGroups: () => Promise<void>;
14
- auctionConfigFromCache: () => AuctionConfig | null;
14
+ auctionConfig: () => Promise<AuctionConfig | null>;
15
15
  runAdAuction: (domID: string, options?: RunAdAuctionOptions) => Promise<boolean>;
16
- installGPTAuctionConfigs: (filter?: GPTSlotFilter) => void;
16
+ installGPTAuctionConfigs: (filter?: GPTSlotFilter) => Promise<void>;
17
17
  }
18
18
  }
19
19
  export {};
@@ -9,15 +9,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import OptableSDK from "../sdk";
11
11
  /*
12
- * auctionConfigFromCache obtains the cached auction configuration for the current origin
12
+ * auctionConfig obtains the auction configuration for the current origin
13
13
  */
14
- OptableSDK.prototype.auctionConfigFromCache = function () {
15
- var _a;
16
- const siteConfig = this.siteFromCache();
17
- if (!siteConfig) {
18
- return null;
19
- }
20
- return (_a = siteConfig.auctionConfig) !== null && _a !== void 0 ? _a : null;
14
+ OptableSDK.prototype.auctionConfig = function () {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ var _a;
17
+ let siteConfig = this.siteFromCache();
18
+ if (!siteConfig) {
19
+ siteConfig = yield this.site();
20
+ }
21
+ return (_a = siteConfig.auctionConfig) !== null && _a !== void 0 ? _a : null;
22
+ });
21
23
  };
22
24
  function elementInnerSize(element) {
23
25
  const style = window.getComputedStyle(element, null);
@@ -31,34 +33,38 @@ function elementInnerSize(element) {
31
33
  * and installs it into the page GPT slots, optionally filtered.
32
34
  */
33
35
  OptableSDK.prototype.installGPTAuctionConfigs = function (filter) {
34
- const sdk = this;
35
- sdk.installGPTAuctionConfigs = function () { };
36
- window.googletag = window.googletag || { cmd: [] };
37
- const gpt = window.googletag;
38
- gpt.cmd.push(function () {
39
- let slots = gpt.pubads().getSlots();
40
- if (filter) {
41
- slots = slots.filter(filter);
42
- }
43
- const siteAuctionConfig = sdk.auctionConfigFromCache();
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const sdk = this;
38
+ sdk.installGPTAuctionConfigs = function () {
39
+ return Promise.resolve();
40
+ };
41
+ const siteAuctionConfig = yield sdk.auctionConfig();
44
42
  if (!siteAuctionConfig) {
45
43
  return;
46
44
  }
47
- for (const slot of slots) {
48
- const sizes = slot.getSizes();
49
- const componentAuction = [];
50
- for (const size of sizes) {
51
- if (size === "fluid") {
52
- continue;
45
+ window.googletag = window.googletag || { cmd: [] };
46
+ const gpt = window.googletag;
47
+ gpt.cmd.push(function () {
48
+ let slots = gpt.pubads().getSlots();
49
+ if (filter) {
50
+ slots = slots.filter(filter);
51
+ }
52
+ for (const slot of slots) {
53
+ const sizes = slot.getSizes();
54
+ const componentAuction = [];
55
+ for (const size of sizes) {
56
+ if (size === "fluid") {
57
+ continue;
58
+ }
59
+ componentAuction.push({
60
+ configKey: siteAuctionConfig.seller + "-" + size.getWidth() + "x" + size.getHeight(),
61
+ auctionConfig: Object.assign(Object.assign({}, siteAuctionConfig), { requestedSize: { width: size.getWidth() + "px", height: size.getHeight() + "px" } }),
62
+ });
53
63
  }
54
- componentAuction.push({
55
- configKey: siteAuctionConfig.seller + "-" + size.getWidth() + "x" + size.getHeight(),
56
- auctionConfig: Object.assign(Object.assign({}, siteAuctionConfig), { requestedSize: { width: size.getWidth() + "px", height: size.getHeight() + "px" } }),
57
- });
64
+ // @ts-ignore // outdated typings for componentAuction expects some legacy field names
65
+ slot.setConfig({ componentAuction });
58
66
  }
59
- // @ts-ignore // outdated typings for componentAuction expects some legacy field names
60
- slot.setConfig({ componentAuction });
61
- }
67
+ });
62
68
  });
63
69
  };
64
70
  /*
@@ -76,7 +82,7 @@ OptableSDK.prototype.runAdAuction = function (domID, options) {
76
82
  throw "spot not found";
77
83
  }
78
84
  const requestedSize = elementInnerSize(spot);
79
- const siteAuctionConfig = this.auctionConfigFromCache();
85
+ const siteAuctionConfig = yield this.auctionConfig();
80
86
  if (!siteAuctionConfig) {
81
87
  return false;
82
88
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "v0.30.0"
2
+ "version": "v0.32.0"
3
3
  }
@@ -16,6 +16,8 @@ type InitConfig = {
16
16
  experiments?: Experiment[];
17
17
  mockedIP?: string;
18
18
  sessionID?: string;
19
+ skipEnrichment?: boolean;
20
+ initTargeting?: boolean;
19
21
  };
20
22
  type ResolvedConfig = {
21
23
  site: string;
@@ -29,6 +31,8 @@ type ResolvedConfig = {
29
31
  experiments: Experiment[];
30
32
  mockedIP?: string;
31
33
  sessionID: string;
34
+ skipEnrichment?: boolean;
35
+ initTargeting?: boolean;
32
36
  };
33
37
  declare const DCN_DEFAULTS: {
34
38
  cookies: boolean;
@@ -26,6 +26,8 @@ function getConfig(init) {
26
26
  experiments: (_d = init.experiments) !== null && _d !== void 0 ? _d : DCN_DEFAULTS.experiments,
27
27
  mockedIP: init.mockedIP,
28
28
  sessionID: (_e = init.sessionID) !== null && _e !== void 0 ? _e : generateSessionID(),
29
+ skipEnrichment: init.skipEnrichment,
30
+ initTargeting: init.initTargeting,
29
31
  };
30
32
  if ((_f = init.consent) === null || _f === void 0 ? void 0 : _f.static) {
31
33
  config.consent = init.consent.static;
@@ -0,0 +1,4 @@
1
+ import { ResolvedConfig } from "../../config";
2
+ import { TargetingResponse } from "../../edge/targeting";
3
+ declare function sendTargetingUpdateEvent(config: ResolvedConfig, response: TargetingResponse): void;
4
+ export { sendTargetingUpdateEvent };
@@ -0,0 +1,14 @@
1
+ const targetingEventName = "optable-targeting:change";
2
+ function sendTargetingUpdateEvent(config, response) {
3
+ var _a, _b, _c, _d, _e, _f;
4
+ const matchers = (_c = (_b = (_a = response.ortb2) === null || _a === void 0 ? void 0 : _a.user) === null || _b === void 0 ? void 0 : _b.eids) === null || _c === void 0 ? void 0 : _c.map((x) => x.matcher);
5
+ window.dispatchEvent(new CustomEvent(targetingEventName, {
6
+ detail: {
7
+ instance: config.node || config.host,
8
+ resolved: !!((_f = (_e = (_d = response.ortb2) === null || _d === void 0 ? void 0 : _d.user) === null || _e === void 0 ? void 0 : _e.eids) === null || _f === void 0 ? void 0 : _f.length),
9
+ ortb2: response.ortb2,
10
+ provenance: new Set(matchers),
11
+ },
12
+ }));
13
+ }
14
+ export { sendTargetingUpdateEvent };
@@ -14,6 +14,9 @@ function buildRequest(path, config, init) {
14
14
  const url = new URL(path, `https://${host}`);
15
15
  url.searchParams.set("osdk", `web-${buildInfo.version}`);
16
16
  url.searchParams.set("sid", config.sessionID);
17
+ if (config.skipEnrichment) {
18
+ url.searchParams.set("skip_enrichment", `${config.skipEnrichment}`);
19
+ }
17
20
  if (config.node) {
18
21
  url.searchParams.set("t", config.node);
19
22
  }
@@ -0,0 +1,12 @@
1
+ import type { ResolvedConfig } from "../config";
2
+ type StorageKeys = {
3
+ write: string[];
4
+ read: string[];
5
+ };
6
+ export declare function encodeBase64(str: string): string;
7
+ declare function generateSiteKeys(config: ResolvedConfig): StorageKeys;
8
+ declare function generateTargetingKeys(config: ResolvedConfig): StorageKeys;
9
+ declare function generatedPairKeys(): StorageKeys;
10
+ declare function generatePassportKeys(config: ResolvedConfig): StorageKeys;
11
+ export type { StorageKeys };
12
+ export { generateSiteKeys, generatedPairKeys, generatePassportKeys, generateTargetingKeys };
@@ -0,0 +1,52 @@
1
+ const pairStorageKey = "_optable_pairId";
2
+ export function encodeBase64(str) {
3
+ const codeUnits = new Uint16Array(str.length);
4
+ for (let i = 0; i < codeUnits.length; i++) {
5
+ codeUnits[i] = str.charCodeAt(i);
6
+ }
7
+ return btoa(String.fromCharCode(...new Uint8Array(codeUnits.buffer)));
8
+ }
9
+ function getWriteKeyBase64FromConfig(config) {
10
+ if (config.node) {
11
+ return encodeBase64(`${config.host}/${config.node}`);
12
+ }
13
+ return encodeBase64(`${config.host}`);
14
+ }
15
+ // Generate the keys for the site storage
16
+ // The keys are generated based on the host and node configs
17
+ function generateSiteKeys(config) {
18
+ const key = `OPTABLE_SITE_${getWriteKeyBase64FromConfig(config)}`;
19
+ return { write: [key], read: [key] };
20
+ }
21
+ // Generate the keys for the targeting storage
22
+ // The keys are generated based on the host and node configs
23
+ function generateTargetingKeys(config) {
24
+ const key = `OPTABLE_TARGETING_${getWriteKeyBase64FromConfig(config)}`;
25
+ return { write: [key], read: [key] };
26
+ }
27
+ function generatedPairKeys() {
28
+ return { write: [pairStorageKey], read: [pairStorageKey] };
29
+ }
30
+ // Generate the keys for the passport storage
31
+ // The keys are generated based on the host and node configs
32
+ // We need to keep backward compatibility with the legacy host cache
33
+ // We support keeping cache when moving from host only to host/node
34
+ // We do not support keeping cache when moving from host/node to host only
35
+ function generatePassportKeys(config) {
36
+ const write = [];
37
+ const read = [];
38
+ const writeKey = `OPTABLE_PASSPORT_${getWriteKeyBase64FromConfig(config)}`;
39
+ write.push(writeKey);
40
+ read.push(writeKey);
41
+ // We keep `OPTABLE_PASS` keys for backward compatibility
42
+ // Once all clients are updated, we can remove them on next tag
43
+ if (config.legacyHostCache) {
44
+ read.push(`OPTABLE_PASSPORT_${encodeBase64(`${config.legacyHostCache}`)}`);
45
+ read.push(`OPTABLE_PASS_${encodeBase64(`${config.legacyHostCache}/${config.site}`)}`);
46
+ }
47
+ else {
48
+ read.push(`OPTABLE_PASS_${encodeBase64(`${config.host}/${config.site}`)}`);
49
+ }
50
+ return { write, read };
51
+ }
52
+ export { generateSiteKeys, generatedPairKeys, generatePassportKeys, generateTargetingKeys };
@@ -1,27 +1,30 @@
1
1
  import { SiteResponse } from "../edge/site";
2
2
  import type { ResolvedConfig } from "../config";
3
3
  import type { TargetingResponse } from "../edge/targeting";
4
- export declare function encodeBase64(str: string): string;
5
- export declare function deprecatedGenerateCacheKey(config: ResolvedConfig): string;
6
- export declare function generateCacheKey(config: ResolvedConfig): string;
4
+ import { StorageKeys } from "./storage-keys";
7
5
  declare class LocalStorage {
8
6
  private config;
9
- private deprecatedPassportKey;
10
- private passportKey;
11
- private targetingKey;
12
- private siteKey;
7
+ private passportKeys;
8
+ private targetingKeys;
9
+ private siteKeys;
10
+ private pairKeys;
13
11
  private storage;
14
12
  constructor(config: ResolvedConfig);
15
13
  getPassport(): string | null;
16
- getTargeting(): TargetingResponse | null;
17
14
  setPassport(passport: string): void;
15
+ getTargeting(): TargetingResponse | null;
18
16
  setTargeting(targeting?: TargetingResponse | null): void;
19
- setSite(site?: SiteResponse | null): void;
20
17
  getSite(): SiteResponse | null;
21
- getFirstExistingItem(...keys: string[]): string | null;
18
+ setSite(site?: SiteResponse | null): void;
19
+ setPairIDs(targeting: TargetingResponse): void;
20
+ getPairIDs(): string[] | null;
21
+ readStorageKeys(keys: StorageKeys): string | null;
22
+ writeToStorageKeys(keys: StorageKeys, value: string): void;
23
+ clearStorageKeys(keys: StorageKeys): void;
22
24
  clearPassport(): void;
23
25
  clearTargeting(): void;
24
26
  clearSite(): void;
25
27
  }
28
+ export type { StorageKeys as PassportKeys, ResolvedConfig };
26
29
  export { LocalStorage };
27
30
  export default LocalStorage;
@@ -1,68 +1,60 @@
1
1
  import { LocalStorageProxy } from "./regs/storage";
2
- export function encodeBase64(str) {
3
- const codeUnits = new Uint16Array(str.length);
4
- for (let i = 0; i < codeUnits.length; i++) {
5
- codeUnits[i] = str.charCodeAt(i);
6
- }
7
- return btoa(String.fromCharCode(...new Uint8Array(codeUnits.buffer)));
8
- }
9
- // Used to create an old keygen for getItem only
10
- export function deprecatedGenerateCacheKey(config) {
11
- if (config.legacyHostCache) {
12
- return encodeBase64(`${config.legacyHostCache}/${config.site}`);
13
- }
14
- return encodeBase64(`${config.host}/${config.site}`);
15
- }
16
- // Used as keygen for setting and getting from localstorage
17
- export function generateCacheKey(config) {
18
- if (config.node) {
19
- return encodeBase64(`${config.host}/${config.node}`);
20
- }
21
- return encodeBase64(config.host);
22
- }
2
+ import { generatedPairKeys, generatePassportKeys, generateSiteKeys, generateTargetingKeys, } from "./storage-keys";
3
+ const pairEIDSource = "pair-protocol.com";
23
4
  class LocalStorage {
24
5
  constructor(config) {
25
6
  this.config = config;
26
- // This is a deprecated keygen, keeping for backwards compatibility
27
- const deprecatedBase64ConfigKey = deprecatedGenerateCacheKey(config);
28
- const base64ConfigKey = generateCacheKey(config);
29
- this.deprecatedPassportKey = "OPTABLE_PASS_" + deprecatedBase64ConfigKey;
30
- this.passportKey = "OPTABLE_PASSPORT_" + base64ConfigKey;
31
- this.targetingKey = "OPTABLE_TARGETING_" + base64ConfigKey;
32
- this.siteKey = "OPTABLE_SITE_" + base64ConfigKey;
7
+ this.passportKeys = generatePassportKeys(config);
8
+ this.targetingKeys = generateTargetingKeys(config);
9
+ this.siteKeys = generateSiteKeys(config);
10
+ this.pairKeys = generatedPairKeys();
33
11
  this.storage = new LocalStorageProxy(this.config.consent);
34
12
  }
35
13
  getPassport() {
36
- return this.getFirstExistingItem(this.passportKey, this.deprecatedPassportKey);
14
+ return this.readStorageKeys(this.passportKeys);
15
+ }
16
+ setPassport(passport) {
17
+ this.writeToStorageKeys(this.passportKeys, passport);
37
18
  }
38
19
  getTargeting() {
39
- const raw = this.storage.getItem(this.targetingKey);
20
+ const raw = this.readStorageKeys(this.targetingKeys);
40
21
  return raw ? JSON.parse(raw) : null;
41
22
  }
42
- setPassport(passport) {
43
- if (passport && passport.length > 0) {
44
- this.storage.setItem(this.passportKey, passport);
45
- }
46
- }
47
23
  setTargeting(targeting) {
48
24
  if (!targeting) {
49
25
  return;
50
26
  }
51
- this.storage.setItem(this.targetingKey, JSON.stringify(targeting));
27
+ this.writeToStorageKeys(this.targetingKeys, JSON.stringify(targeting));
28
+ this.setPairIDs(targeting);
29
+ }
30
+ getSite() {
31
+ const raw = this.readStorageKeys(this.siteKeys);
32
+ return raw ? JSON.parse(raw) : null;
52
33
  }
53
34
  setSite(site) {
54
35
  if (!site) {
55
36
  return;
56
37
  }
57
- this.storage.setItem(this.siteKey, JSON.stringify(site));
38
+ this.writeToStorageKeys(this.siteKeys, JSON.stringify(site));
58
39
  }
59
- getSite() {
60
- const raw = this.storage.getItem(this.siteKey);
61
- const parsed = raw ? JSON.parse(raw) : null;
62
- return parsed;
40
+ setPairIDs(targeting) {
41
+ var _a, _b, _c;
42
+ const eids = (_c = (_b = (_a = targeting.ortb2) === null || _a === void 0 ? void 0 : _a.user) === null || _b === void 0 ? void 0 : _b.eids) === null || _c === void 0 ? void 0 : _c.filter((eid) => eid.source === pairEIDSource);
43
+ const uids = eids === null || eids === void 0 ? void 0 : eids.flatMap((eid) => eid.uids);
44
+ if (!uids) {
45
+ return;
46
+ }
47
+ const ids = new Set(uids.map((uid) => uid.id));
48
+ this.writeToStorageKeys(this.pairKeys, btoa(JSON.stringify({ envelope: [...ids] })));
49
+ }
50
+ getPairIDs() {
51
+ var _a;
52
+ const raw = this.readStorageKeys(this.pairKeys);
53
+ return raw ? (_a = JSON.parse(atob(raw))) === null || _a === void 0 ? void 0 : _a.envelope : null;
63
54
  }
64
- getFirstExistingItem(...keys) {
65
- for (const key of keys) {
55
+ // Returns the first key with data
56
+ readStorageKeys(keys) {
57
+ for (const key of keys.read) {
66
58
  const value = this.storage.getItem(key);
67
59
  if (value) {
68
60
  return value;
@@ -70,15 +62,26 @@ class LocalStorage {
70
62
  }
71
63
  return null;
72
64
  }
65
+ writeToStorageKeys(keys, value) {
66
+ if (value) {
67
+ for (const key of keys.write) {
68
+ this.storage.setItem(key, value);
69
+ }
70
+ }
71
+ }
72
+ clearStorageKeys(keys) {
73
+ for (const key of keys.read) {
74
+ this.storage.removeItem(key);
75
+ }
76
+ }
73
77
  clearPassport() {
74
- this.storage.removeItem(this.passportKey);
75
- this.storage.removeItem(this.deprecatedPassportKey);
78
+ this.clearStorageKeys(this.passportKeys);
76
79
  }
77
80
  clearTargeting() {
78
- this.storage.removeItem(this.targetingKey);
81
+ this.clearStorageKeys(this.targetingKeys);
79
82
  }
80
83
  clearSite() {
81
- this.storage.removeItem(this.siteKey);
84
+ this.clearStorageKeys(this.siteKeys);
82
85
  }
83
86
  }
84
87
  export { LocalStorage };
@@ -1,6 +1,5 @@
1
- import type { BidRequest } from "iab-openrtb/v26";
2
1
  import type { ResolvedConfig } from "../config";
3
- import { User as RTB2User } from "./rtb2";
2
+ import * as ortb2 from "iab-openrtb/v26";
4
3
  type Identifier = {
5
4
  id: string;
6
5
  };
@@ -17,18 +16,18 @@ type UserIdentifiers = {
17
16
  type TargetingResponse = {
18
17
  audience?: AudienceIdentifiers[];
19
18
  user?: UserIdentifiers[];
20
- ortb2: Partial<BidRequest>;
19
+ ortb2: {
20
+ user: ortb2.User;
21
+ };
21
22
  };
22
23
  declare function Targeting(config: ResolvedConfig, id: string): Promise<TargetingResponse>;
23
24
  declare function TargetingFromCache(config: ResolvedConfig): TargetingResponse | null;
24
25
  declare function TargetingClearCache(config: ResolvedConfig): void;
25
26
  type PrebidORTB2 = {
26
- user?: RTB2User;
27
+ user: ortb2.User;
27
28
  };
28
29
  declare function PrebidORTB2(tdata: TargetingResponse | null): PrebidORTB2;
29
- type TargetingKeyValues = {
30
- [key: string]: string[];
31
- };
30
+ type TargetingKeyValues = Record<string, string[]>;
32
31
  declare function TargetingKeyValues(tdata: TargetingResponse | null): TargetingKeyValues;
33
32
  export { Targeting, TargetingFromCache, TargetingClearCache, PrebidORTB2, TargetingKeyValues };
34
33
  export default Targeting;
@@ -9,7 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { fetch } from "../core/network";
11
11
  import { LocalStorage } from "../core/storage";
12
- import { UIDAgentType } from "./rtb2";
12
+ import * as adcom from "iab-adcom";
13
+ import { sendTargetingUpdateEvent } from "../core/events/cache-refresh";
13
14
  function Targeting(config, id) {
14
15
  return __awaiter(this, void 0, void 0, function* () {
15
16
  const searchParams = new URLSearchParams({ id });
@@ -21,6 +22,7 @@ function Targeting(config, id) {
21
22
  if (response) {
22
23
  const ls = new LocalStorage(config);
23
24
  ls.setTargeting(response);
25
+ sendTargetingUpdateEvent(config, response);
24
26
  }
25
27
  return response;
26
28
  });
@@ -33,18 +35,6 @@ function TargetingClearCache(config) {
33
35
  const ls = new LocalStorage(config);
34
36
  ls.clearTargeting();
35
37
  }
36
- /*
37
- * Prebid.js supports passing seller-defined audiences to compatible
38
- * bidder adapters.
39
- *
40
- * We return the contents to be merged in ortb2 and passed to
41
- * bidder adapters via mergeConfig(ortb2)... the caller is free
42
- * to append additional objects before setting the final result.
43
- *
44
- * References:
45
- * https://docs.prebid.org/features/firstPartyData.html#segments-and-taxonomy
46
- * https://iabtechlab.com/wp-content/uploads/2021/03/IABTechLab_Taxonomy_and_Data_Transparency_Standards_to_Support_Seller-defined_Audience_and_Context_Signaling_2021-03.pdf
47
- */
48
38
  function PrebidORTB2(tdata) {
49
39
  var _a, _b;
50
40
  return {
@@ -57,7 +47,7 @@ function PrebidORTB2(tdata) {
57
47
  ext: {
58
48
  eids: ((_b = tdata === null || tdata === void 0 ? void 0 : tdata.user) !== null && _b !== void 0 ? _b : []).map((identifiers) => ({
59
49
  source: identifiers.provider,
60
- uids: identifiers.ids.map(({ id }) => ({ id, atype: UIDAgentType.PersonID })),
50
+ uids: identifiers.ids.map(({ id }) => ({ id, atype: adcom.AgentType.PERSON_BASED })),
61
51
  })),
62
52
  },
63
53
  },
@@ -1,7 +1,7 @@
1
1
  import type { ResolvedConfig } from "../config";
2
- import { User } from "./rtb2";
2
+ import type { User } from "iab-openrtb/v26";
3
3
  type TokenizeResponse = {
4
- User: User;
4
+ user: User;
5
5
  };
6
6
  type TokenizeRequest = {
7
7
  id: string;
package/lib/dist/sdk.d.ts CHANGED
@@ -11,6 +11,7 @@ declare class OptableSDK {
11
11
  dcn: ResolvedConfig;
12
12
  private init;
13
13
  constructor(dcn: InitConfig);
14
+ initialize(): Promise<void>;
14
15
  identify(...ids: string[]): Promise<void>;
15
16
  uid2Token(id: string): Promise<Uid2TokenResponse>;
16
17
  targeting(id?: string): Promise<TargetingResponse>;
package/lib/dist/sdk.js CHANGED
@@ -21,9 +21,17 @@ import { Tokenize } from "./edge/tokenize";
21
21
  class OptableSDK {
22
22
  constructor(dcn) {
23
23
  this.dcn = getConfig(dcn);
24
- // If initPassport, prefetch site config and cache it, it assigns a passport as a side effect
25
- const noop = () => { };
26
- this.init = this.dcn.initPassport ? Site(this.dcn).then(noop).catch(noop) : Promise.resolve();
24
+ this.init = this.initialize();
25
+ }
26
+ initialize() {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ if (this.dcn.initPassport) {
29
+ yield Site(this.dcn).catch(() => { });
30
+ }
31
+ if (this.dcn.initTargeting) {
32
+ this.targeting().catch(() => { });
33
+ }
34
+ });
27
35
  }
28
36
  identify(...ids) {
29
37
  return __awaiter(this, void 0, void 0, function* () {
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "homepage": "https://optable.co",
11
11
  "license": "SEE LICENSE IN LICENSE",
12
- "version": "v0.30.0",
12
+ "version": "v0.32.0",
13
13
  "devDependencies": {
14
14
  "@babel/core": "^7.12.3",
15
15
  "@babel/plugin-proposal-class-properties": "^7.12.1",
@@ -33,7 +33,7 @@
33
33
  "whatwg-fetch": "^3.6.20"
34
34
  },
35
35
  "dependencies": {
36
- "@babel/runtime": "^7.12.5",
36
+ "@babel/runtime": "^7.27.0",
37
37
  "iab-openrtb": "^1.0.1",
38
38
  "js-sha256": "^0.11.0",
39
39
  "regenerator-runtime": "^0.13.7"
@@ -1,36 +0,0 @@
1
- type UserSegment = {
2
- id?: string;
3
- name?: string;
4
- value?: string;
5
- ext?: any;
6
- };
7
- type UserData = {
8
- id?: string;
9
- name?: string;
10
- segment?: UserSegment[];
11
- ext?: {
12
- segtax: number;
13
- };
14
- };
15
- type ExtendedIdentifierUID = {
16
- id: string;
17
- atype: UIDAgentType;
18
- ext?: any;
19
- };
20
- type ExtendedIdentifiers = {
21
- source: string;
22
- uids: ExtendedIdentifierUID[];
23
- };
24
- type UserExt = {
25
- eids?: ExtendedIdentifiers[];
26
- };
27
- type User = {
28
- data?: UserData[];
29
- ext?: UserExt;
30
- };
31
- declare enum UIDAgentType {
32
- DeviceID = 1,
33
- InAppImpression = 2,
34
- PersonID = 3
35
- }
36
- export { User, UIDAgentType };
@@ -1,7 +0,0 @@
1
- var UIDAgentType;
2
- (function (UIDAgentType) {
3
- UIDAgentType[UIDAgentType["DeviceID"] = 1] = "DeviceID";
4
- UIDAgentType[UIDAgentType["InAppImpression"] = 2] = "InAppImpression";
5
- UIDAgentType[UIDAgentType["PersonID"] = 3] = "PersonID";
6
- })(UIDAgentType || (UIDAgentType = {}));
7
- export { UIDAgentType };