@bidkernel/analytics 0.26.0 → 0.27.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/dist/analytics.global.js +1 -1
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +27 -20
- package/dist/index.mjs +27 -20
- package/package.json +1 -1
package/dist/analytics.global.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var bidkernelPrebidAnalyticsBundle=(()=>{var R=(i,e)=>()=>(i&&(e=i(i=0)),e);var Ct=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);function Lt(){if(typeof window<"u"){let i=window;return i.__bidkernelLogListeners||(i.__bidkernelLogListeners=new Set),i.__bidkernelLogListeners}return St}function Rt(i){if((i<0||!Number.isFinite(i))&&(i=0),i<1e3)return`${i.toFixed(2)}ms`;let e=i/1e3;if(e<60)return`${e.toFixed(2)}s`;let t=Math.floor(e/60);return t<60?`${t}m ${(e%60).toFixed(2)}s`:`${Math.floor(t/60)}h ${t%60}m ${(e%60).toFixed(2)}s`}function P(i){if(typeof i=="string"){let e=i.toUpperCase();if(e==="DEBUG"||e==="INFO"||e==="WARN"||e==="ERROR")return e}return C.INFO}function ue(i){return new le(i)}var C,xe,$,_t,St,le,De=R(()=>{"use strict";C={DEBUG:"DEBUG",INFO:"INFO",WARN:"WARN",ERROR:"ERROR"},xe={[C.DEBUG]:10,[C.INFO]:20,[C.WARN]:30,[C.ERROR]:40},$={badge:"color: #2dd4bf; font-weight: bold",badgeWarn:"background: #f59e0b; color: #fff; padding: 2px 4px; border-radius: 3px; font-weight: bold",badgeError:"background: #ef4444; color: #fff; padding: 2px 4px; border-radius: 3px; font-weight: bold",dim:"color: #6b7280",event:"color: #38bdf8; font-weight: bold",eventWarn:"color: #f59e0b; font-weight: bold",eventError:"color: #ef4444; font-weight: bold",reset:"color: inherit"},_t=0,St=new Set;le=class i{_prefix;_level;_loadedAt;_now;_console;_customFormatTime;_listeners=new Set;constructor(e={}){this._prefix=e.prefix??"[bidkernel]",this._level=P(e.logLevel??C.INFO),this._now=e.now,this._console=e.console,this._customFormatTime=e.formatTime,e.onLog&&this._listeners.add(e.onLog),this._loadedAt=e.loadedAt??(this._now?this._now():typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now())}get prefix(){return this._prefix}set prefix(e){this._prefix=e}get logLevel(){return this._level}set logLevel(e){this._level=P(e)}getLevel(){return this._level}setLevel(e){this._level=P(e)}getPrefix(){return this._prefix}setPrefix(e){this._prefix=e}resetTiming(e){this._loadedAt=e??(this._now?this._now():typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now())}getLoadedAt(){return this._loadedAt}addListener(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}removeListener(e){this._listeners.delete(e)}isEnabled(e){let t=P(e);return(xe[t]??20)>=(xe[this._level]??20)}formatTime(e){return this._customFormatTime?this._customFormatTime(e):Rt(e)}_getConsole(){if(this._console)return this._console;if(typeof console<"u")return console}_getElapsed(){let e=this._now?this._now():typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();return Math.max(0,e-this._loadedAt)}_dispatchRecord(e){for(let n of this._listeners)try{n(e)}catch{}let t=Lt();for(let n of t)if(!this._listeners.has(n))try{n(e)}catch{}if(typeof window<"u"&&typeof window.dispatchEvent=="function")try{window.dispatchEvent(new CustomEvent("__bidkernel_log__",{detail:e}))}catch{}}log(e,t,...n){let r=P(e);if(!this.isEnabled(r))return;let o=this._getElapsed(),s=this.formatTime(o),d=Date.now(),u={id:`bk_log_${d}_${++_t}`,timestamp:d,elapsedMs:o,level:r,prefix:this._prefix,message:t,args:n,data:n.length===1?n[0]:n.length>1?n:void 0};this._dispatchRecord(u);let c=this._getConsole();if(!c)return;let I=$.badge,g=$.event;r===C.WARN?(I=$.badgeWarn,g=$.eventWarn):r===C.ERROR&&(I=$.badgeError,g=$.eventError);let f=`%c${this._prefix}%c ${s} %c${t}%c`,L=[I,$.dim,g,$.reset],y=[f,...L];switch(n.length>0&&y.push(...n),r){case C.DEBUG:typeof c.log=="function"?c.log(...y):typeof c.debug=="function"&&c.debug(...y);break;case C.INFO:typeof c.info=="function"?c.info(...y):typeof c.log=="function"&&c.log(...y);break;case C.WARN:typeof c.warn=="function"?c.warn(...y):typeof c.log=="function"&&c.log(...y);break;case C.ERROR:typeof c.error=="function"?c.error(...y):typeof c.log=="function"&&c.log(...y);break;default:typeof c.log=="function"&&c.log(...y);break}}debug(e,...t){this.log(C.DEBUG,e,...t)}info(e,...t){this.log(C.INFO,e,...t)}warn(e,...t){this.log(C.WARN,e,...t)}error(e,...t){this.log(C.ERROR,e,...t)}logEvent(e){e&&(e.data!==void 0?this.log(e.level,e.eventName,e.data):this.log(e.level,e.eventName))}child(e,t={}){let n=this._prefix;if(e){let r=e.startsWith("[")&&e.endsWith("]")?e:`[${e}]`;n=`${this._prefix}${r}`}return new i({prefix:n,logLevel:t.logLevel??this._level,loadedAt:t.loadedAt??this._loadedAt,now:t.now??this._now,console:t.console??this._console,formatTime:t.formatTime??this._customFormatTime,...t})}withPrefix(e){return new i({prefix:e,logLevel:this._level,loadedAt:this._loadedAt,now:this._now,console:this._console,formatTime:this._customFormatTime})}}});function Ue(){let i=0,e=0;for(let n=0;n<28;n+=7){let r=this.buf[this.pos++];if(i|=(r&127)<<n,(r&128)==0)return this.assertBounds(),[i,e]}let t=this.buf[this.pos++];if(i|=(t&15)<<28,e=(t&112)>>4,(t&128)==0)return this.assertBounds(),[i,e];for(let n=3;n<=31;n+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<n,(r&128)==0)return this.assertBounds(),[i,e]}throw new Error("invalid varint")}function ie(i,e,t){for(let o=0;o<28;o=o+7){let s=i>>>o,d=!(!(s>>>7)&&e==0),a=(d?s|128:s)&255;if(t.push(a),!d)return}let n=i>>>28&15|(e&7)<<4,r=e>>3!=0;if(t.push((r?n|128:n)&255),!!r){for(let o=3;o<31;o=o+7){let s=e>>>o,d=!!(s>>>7),a=(d?s|128:s)&255;if(t.push(a),!d)return}t.push(e>>>31&1)}}function fe(i){let e=i[0]==="-";e&&(i=i.slice(1));let t=1e6,n=0,r=0;function o(s,d){let a=Number(i.slice(s,d));r*=t,n=n*t+a,n>=ne&&(r=r+(n/ne|0),n=n%ne)}return o(-24,-18),o(-18,-12),o(-12,-6),o(-6),e?Ne(n,r):pe(n,r)}function Me(i,e){let t=pe(i,e),n=t.hi&2147483648;n&&(t=Ne(t.lo,t.hi));let r=he(t.lo,t.hi);return n?"-"+r:r}function he(i,e){if({lo:i,hi:e}=Ot(i,e),e<=2097151)return String(ne*e+i);let t=i&16777215,n=(i>>>24|e<<8)&16777215,r=e>>16&65535,o=t+n*6777216+r*6710656,s=n+r*8147497,d=r*2,a=1e7;return o>=a&&(s+=Math.floor(o/a),o%=a),s>=a&&(d+=Math.floor(s/a),s%=a),d.toString()+ke(s)+ke(o)}function Ot(i,e){return{lo:i>>>0,hi:e>>>0}}function pe(i,e){return{lo:i|0,hi:e|0}}function Ne(i,e){return e=~e,i?i=~i+1:e+=1,pe(i,e)}function ge(i,e){if(i>=0){for(;i>127;)e.push(i&127|128),i=i>>>7;e.push(i)}else{for(let t=0;t<9;t++)e.push(i&127|128),i=i>>7;e.push(1)}}function Pe(){let i=this.buf[this.pos++],e=i&127;if((i&128)==0)return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<7,(i&128)==0)return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<14,(i&128)==0)return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<21,(i&128)==0)return this.assertBounds(),e;i=this.buf[this.pos++],e|=(i&15)<<28;for(let t=5;(i&128)!==0&&t<10;t++)i=this.buf[this.pos++];if((i&128)!=0)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var ne,ke,ye=R(()=>{"use strict";ne=4294967296;ke=i=>{let e=String(i);return"0000000".slice(e.length)+e}});function Bt(){let i=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof i.getBigInt64=="function"&&typeof i.getBigUint64=="function"&&typeof i.setBigInt64=="function"&&typeof i.setBigUint64=="function"&&(!!globalThis.Deno||typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let t=BigInt("-9223372036854775808"),n=BigInt("9223372036854775807"),r=BigInt("0"),o=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(s){let d=typeof s=="bigint"?s:BigInt(s);if(d>n||d<t)throw new Error(`invalid int64: ${s}`);return d},uParse(s){let d=typeof s=="bigint"?s:BigInt(s);if(d>o||d<r)throw new Error(`invalid uint64: ${s}`);return d},enc(s){return i.setBigInt64(0,this.parse(s),!0),{lo:i.getInt32(0,!0),hi:i.getInt32(4,!0)}},uEnc(s){return i.setBigInt64(0,this.uParse(s),!0),{lo:i.getInt32(0,!0),hi:i.getInt32(4,!0)}},dec(s,d){return i.setInt32(0,s,!0),i.setInt32(4,d,!0),i.getBigInt64(0,!0)},uDec(s,d){return i.setInt32(0,s,!0),i.setInt32(4,d,!0),i.getBigUint64(0,!0)}}}return{zero:"0",supported:!1,parse(t){return typeof t!="string"&&(t=t.toString()),Fe(t),t},uParse(t){return typeof t!="string"&&(t=t.toString()),Ve(t),t},enc(t){return typeof t!="string"&&(t=t.toString()),Fe(t),fe(t)},uEnc(t){return typeof t!="string"&&(t=t.toString()),Ve(t),fe(t)},dec(t,n){return Me(t,n)},uDec(t,n){return he(t,n)}}}function Fe(i){if(!/^-?[0-9]+$/.test(i))throw new Error("invalid int64: "+i)}function Ve(i){if(!/^[0-9]+$/.test(i))throw new Error("invalid uint64: "+i)}var k,$e=R(()=>{"use strict";ye();k=Bt()});function me(){if(globalThis[be]==null){let i=new globalThis.TextEncoder,e=new globalThis.TextDecoder;globalThis[be]={encodeUtf8(t){return i.encode(t)},decodeUtf8(t){return e.decode(t)},checkUtf8(t){try{return encodeURIComponent(t),!0}catch{return!1}}}}return globalThis[be]}var be,Ie=R(()=>{"use strict";be=Symbol.for("@bufbuild/protobuf/text-encoding")});function ve(i){if(typeof i=="string")i=Number(i);else if(typeof i!="number")throw new Error("invalid int32: "+typeof i);if(!Number.isInteger(i)||i>Ut||i<Mt)throw new Error("invalid int32: "+i)}function We(i){if(typeof i=="string")i=Number(i);else if(typeof i!="number")throw new Error("invalid uint32: "+typeof i);if(!Number.isInteger(i)||i>kt||i<0)throw new Error("invalid uint32: "+i)}function Nt(i){if(typeof i=="string"){let e=i;if(i=Number(i),Number.isNaN(i)&&e!=="NaN")throw new Error("invalid float32: "+e)}else if(typeof i!="number")throw new Error("invalid float32: "+typeof i);if(Number.isFinite(i)&&(i>xt||i<Dt))throw new Error("invalid float32: "+i)}var W,xt,Dt,kt,Ut,Mt,j,O,je=R(()=>{"use strict";ye();$e();Ie();(function(i){i[i.Varint=0]="Varint",i[i.Bit64=1]="Bit64",i[i.LengthDelimited=2]="LengthDelimited",i[i.StartGroup=3]="StartGroup",i[i.EndGroup=4]="EndGroup",i[i.Bit32=5]="Bit32"})(W||(W={}));xt=34028234663852886e22,Dt=-34028234663852886e22,kt=4294967295,Ut=2147483647,Mt=-2147483648,j=class{constructor(e=me().encodeUtf8){this.encodeUtf8=e,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let e=0;for(let r=0;r<this.chunks.length;r++)e+=this.chunks[r].length;let t=new Uint8Array(e),n=0;for(let r=0;r<this.chunks.length;r++)t.set(this.chunks[r],n),n+=this.chunks[r].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(We(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return ve(e),ge(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.encodeUtf8(e);return this.uint32(t.byteLength),this.raw(t)}float(e){Nt(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){We(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){ve(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return ve(e),e=(e<<1^e>>31)>>>0,ge(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=k.enc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=k.uEnc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=k.enc(e);return ie(t.lo,t.hi,this.buf),this}sint64(e){let t=k.enc(e),n=t.hi>>31,r=t.lo<<1^n,o=(t.hi<<1|t.lo>>>31)^n;return ie(r,o,this.buf),this}uint64(e){let t=k.uEnc(e);return ie(t.lo,t.hi,this.buf),this}},O=class{constructor(e,t=me().decodeUtf8){this.decodeUtf8=t,this.varint64=Ue,this.uint32=Pe,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.uint32(),t=e>>>3,n=e&7;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e,t){let n=this.pos;switch(e){case W.Varint:for(;this.buf[this.pos++]&128;);break;case W.Bit64:this.pos+=4;case W.Bit32:this.pos+=4;break;case W.LengthDelimited:let r=this.uint32();this.pos+=r;break;case W.StartGroup:for(;;){let[o,s]=this.tag();if(s===W.EndGroup){if(t!==void 0&&o!==t)throw new Error("invalid end group tag");break}this.skip(s,o)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return k.dec(...this.varint64())}uint64(){return k.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,k.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return k.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return k.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.decodeUtf8(this.bytes())}}});var qe=R(()=>{"use strict"});var Ke=R(()=>{"use strict"});var Ge=R(()=>{"use strict"});var He=R(()=>{"use strict";je();qe();Ie();Ke();Ge()});function Pt(){return{propertyId:new Uint8Array(0),pageviewId:new Uint8Array(0),sessionId:new Uint8Array(0),pageUrl:"",country:"",region:"",deviceType:"",userId:new Uint8Array(0),domain:"",events:[],browser:"",deviceManufacturer:"",deviceModel:"",city:"",postalCode:""}}function Ft(){return{timestampMs:0,type:0,eventName:"",auctionId:new Uint8Array(0),transactionId:new Uint8Array(0),adUnitCode:"",bid:void 0,namespace:"",eventId:new Uint8Array(0),metadata:{},viewableDurationMs:void 0,bidderOutcomes:[]}}function Vt(){return{key:"",value:""}}function $t(){return{adUnitCode:"",outcome:0,bid:void 0,refreshIndex:0,floorCents:void 0,floorSource:0,floorTreatmentBp:void 0}}function Wt(){return{bidder:"",cpm:0,currency:"",width:0,height:0,dealId:"",mediaType:"",latencyMs:0,advertiserDomain:"",creativeId:""}}var m,F,oe,Ee,ze,Ye,Xe,re,Te=R(()=>{"use strict";He();m={TRACE_EVENT_TYPE_UNSPECIFIED:0,AUCTION_START:1,AUCTION_END:2,BID_WIN:4,IMPRESSION:5,VIEWABLE:6,TIME_IN_VIEW:7,ERROR:9,SLOT_DEFINED:10,SLOT_DESTROYED:11,CLICK:12,AD_RENDER_FAILED:13,UNRECOGNIZED:-1},F={BIDDER_OUTCOME_UNSPECIFIED:0,BIDDER_OUTCOME_BID:1,BIDDER_OUTCOME_NO_BID:2,BIDDER_OUTCOME_TIMEOUT:3,BIDDER_OUTCOME_ERROR:4,BIDDER_OUTCOME_NO_RESPONSE:5,UNRECOGNIZED:-1},oe={FLOOR_SOURCE_UNSPECIFIED:0,FLOOR_SOURCE_STATIC:1,FLOOR_SOURCE_POOL:2,FLOOR_SOURCE_NONE:3,UNRECOGNIZED:-1};Ee={encode(i,e=new j){if(i.propertyId!==void 0&&i.propertyId.length!==0&&e.uint32(10).bytes(i.propertyId),i.pageviewId!==void 0&&i.pageviewId.length!==0&&e.uint32(18).bytes(i.pageviewId),i.sessionId!==void 0&&i.sessionId.length!==0&&e.uint32(26).bytes(i.sessionId),i.pageUrl!==void 0&&i.pageUrl!==""&&e.uint32(34).string(i.pageUrl),i.country!==void 0&&i.country!==""&&e.uint32(42).string(i.country),i.region!==void 0&&i.region!==""&&e.uint32(50).string(i.region),i.deviceType!==void 0&&i.deviceType!==""&&e.uint32(58).string(i.deviceType),i.userId!==void 0&&i.userId.length!==0&&e.uint32(66).bytes(i.userId),i.domain!==void 0&&i.domain!==""&&e.uint32(74).string(i.domain),i.events!==void 0&&i.events.length!==0)for(let t of i.events)ze.encode(t,e.uint32(82).fork()).join();return i.browser!==void 0&&i.browser!==""&&e.uint32(90).string(i.browser),i.deviceManufacturer!==void 0&&i.deviceManufacturer!==""&&e.uint32(98).string(i.deviceManufacturer),i.deviceModel!==void 0&&i.deviceModel!==""&&e.uint32(106).string(i.deviceModel),i.city!==void 0&&i.city!==""&&e.uint32(114).string(i.city),i.postalCode!==void 0&&i.postalCode!==""&&e.uint32(122).string(i.postalCode),e},decode(i,e){let t=i instanceof O?i:new O(i),n=e===void 0?t.len:t.pos+e,r=Pt();for(;t.pos<n;){let o=t.uint32();switch(o>>>3){case 1:{if(o!==10)break;r.propertyId=t.bytes();continue}case 2:{if(o!==18)break;r.pageviewId=t.bytes();continue}case 3:{if(o!==26)break;r.sessionId=t.bytes();continue}case 4:{if(o!==34)break;r.pageUrl=t.string();continue}case 5:{if(o!==42)break;r.country=t.string();continue}case 6:{if(o!==50)break;r.region=t.string();continue}case 7:{if(o!==58)break;r.deviceType=t.string();continue}case 8:{if(o!==66)break;r.userId=t.bytes();continue}case 9:{if(o!==74)break;r.domain=t.string();continue}case 10:{if(o!==82)break;let s=ze.decode(t,t.uint32());s!==void 0&&r.events.push(s);continue}case 11:{if(o!==90)break;r.browser=t.string();continue}case 12:{if(o!==98)break;r.deviceManufacturer=t.string();continue}case 13:{if(o!==106)break;r.deviceModel=t.string();continue}case 14:{if(o!==114)break;r.city=t.string();continue}case 15:{if(o!==122)break;r.postalCode=t.string();continue}}if((o&7)===4||o===0)break;t.skip(o&7)}return r}};ze={encode(i,e=new j){if(i.timestampMs!==void 0&&i.timestampMs!==0&&e.uint32(9).double(i.timestampMs),i.type!==void 0&&i.type!==0&&e.uint32(16).int32(i.type),i.eventName!==void 0&&i.eventName!==""&&e.uint32(26).string(i.eventName),i.auctionId!==void 0&&i.auctionId.length!==0&&e.uint32(34).bytes(i.auctionId),i.transactionId!==void 0&&i.transactionId.length!==0&&e.uint32(42).bytes(i.transactionId),i.adUnitCode!==void 0&&i.adUnitCode!==""&&e.uint32(50).string(i.adUnitCode),i.bid!==void 0&&re.encode(i.bid,e.uint32(58).fork()).join(),i.namespace!==void 0&&i.namespace!==""&&e.uint32(66).string(i.namespace),i.eventId!==void 0&&i.eventId.length!==0&&e.uint32(74).bytes(i.eventId),globalThis.Object.entries(i.metadata||{}).forEach(([t,n])=>{Ye.encode({key:t,value:n},e.uint32(82).fork()).join()}),i.viewableDurationMs!==void 0&&e.uint32(89).double(i.viewableDurationMs),i.bidderOutcomes!==void 0&&i.bidderOutcomes.length!==0)for(let t of i.bidderOutcomes)Xe.encode(t,e.uint32(98).fork()).join();return e},decode(i,e){let t=i instanceof O?i:new O(i),n=e===void 0?t.len:t.pos+e,r=Ft();for(;t.pos<n;){let o=t.uint32();switch(o>>>3){case 1:{if(o!==9)break;r.timestampMs=t.double();continue}case 2:{if(o!==16)break;r.type=t.int32();continue}case 3:{if(o!==26)break;r.eventName=t.string();continue}case 4:{if(o!==34)break;r.auctionId=t.bytes();continue}case 5:{if(o!==42)break;r.transactionId=t.bytes();continue}case 6:{if(o!==50)break;r.adUnitCode=t.string();continue}case 7:{if(o!==58)break;r.bid=re.decode(t,t.uint32());continue}case 8:{if(o!==66)break;r.namespace=t.string();continue}case 9:{if(o!==74)break;r.eventId=t.bytes();continue}case 10:{if(o!==82)break;let s=Ye.decode(t,t.uint32());s.value!==void 0&&(r.metadata[s.key]=s.value);continue}case 11:{if(o!==89)break;r.viewableDurationMs=t.double();continue}case 12:{if(o!==98)break;let s=Xe.decode(t,t.uint32());s!==void 0&&r.bidderOutcomes.push(s);continue}}if((o&7)===4||o===0)break;t.skip(o&7)}return r}};Ye={encode(i,e=new j){return i.key!==""&&e.uint32(10).string(i.key),i.value!==""&&e.uint32(18).string(i.value),e},decode(i,e){let t=i instanceof O?i:new O(i),n=e===void 0?t.len:t.pos+e,r=Vt();for(;t.pos<n;){let o=t.uint32();switch(o>>>3){case 1:{if(o!==10)break;r.key=t.string();continue}case 2:{if(o!==18)break;r.value=t.string();continue}}if((o&7)===4||o===0)break;t.skip(o&7)}return r}};Xe={encode(i,e=new j){return i.adUnitCode!==void 0&&i.adUnitCode!==""&&e.uint32(18).string(i.adUnitCode),i.outcome!==void 0&&i.outcome!==0&&e.uint32(32).int32(i.outcome),i.bid!==void 0&&re.encode(i.bid,e.uint32(50).fork()).join(),i.refreshIndex!==void 0&&i.refreshIndex!==0&&e.uint32(56).int32(i.refreshIndex),i.floorCents!==void 0&&e.uint32(64).int32(i.floorCents),i.floorSource!==void 0&&i.floorSource!==0&&e.uint32(72).int32(i.floorSource),i.floorTreatmentBp!==void 0&&e.uint32(80).int32(i.floorTreatmentBp),e},decode(i,e){let t=i instanceof O?i:new O(i),n=e===void 0?t.len:t.pos+e,r=$t();for(;t.pos<n;){let o=t.uint32();switch(o>>>3){case 2:{if(o!==18)break;r.adUnitCode=t.string();continue}case 4:{if(o!==32)break;r.outcome=t.int32();continue}case 6:{if(o!==50)break;r.bid=re.decode(t,t.uint32());continue}case 7:{if(o!==56)break;r.refreshIndex=t.int32();continue}case 8:{if(o!==64)break;r.floorCents=t.int32();continue}case 9:{if(o!==72)break;r.floorSource=t.int32();continue}case 10:{if(o!==80)break;r.floorTreatmentBp=t.int32();continue}}if((o&7)===4||o===0)break;t.skip(o&7)}return r}};re={encode(i,e=new j){return i.bidder!==void 0&&i.bidder!==""&&e.uint32(10).string(i.bidder),i.cpm!==void 0&&i.cpm!==0&&e.uint32(17).double(i.cpm),i.currency!==void 0&&i.currency!==""&&e.uint32(26).string(i.currency),i.width!==void 0&&i.width!==0&&e.uint32(32).int32(i.width),i.height!==void 0&&i.height!==0&&e.uint32(40).int32(i.height),i.dealId!==void 0&&i.dealId!==""&&e.uint32(50).string(i.dealId),i.mediaType!==void 0&&i.mediaType!==""&&e.uint32(58).string(i.mediaType),i.latencyMs!==void 0&&i.latencyMs!==0&&e.uint32(65).double(i.latencyMs),i.advertiserDomain!==void 0&&i.advertiserDomain!==""&&e.uint32(74).string(i.advertiserDomain),i.creativeId!==void 0&&i.creativeId!==""&&e.uint32(82).string(i.creativeId),e},decode(i,e){let t=i instanceof O?i:new O(i),n=e===void 0?t.len:t.pos+e,r=Wt();for(;t.pos<n;){let o=t.uint32();switch(o>>>3){case 1:{if(o!==10)break;r.bidder=t.string();continue}case 2:{if(o!==17)break;r.cpm=t.double();continue}case 3:{if(o!==26)break;r.currency=t.string();continue}case 4:{if(o!==32)break;r.width=t.int32();continue}case 5:{if(o!==40)break;r.height=t.int32();continue}case 6:{if(o!==50)break;r.dealId=t.string();continue}case 7:{if(o!==58)break;r.mediaType=t.string();continue}case 8:{if(o!==65)break;r.latencyMs=t.double();continue}case 9:{if(o!==74)break;r.advertiserDomain=t.string();continue}case 10:{if(o!==82)break;r.creativeId=t.string();continue}}if((o&7)===4||o===0)break;t.skip(o&7)}return r}}});function q(i){if(!i)return new Uint8Array(0);if(jt.test(i)){let t=i.replace(/-/g,""),n=new Uint8Array(16);for(let r=0;r<16;r++)n[r]=parseInt(t.slice(r*2,r*2+2),16);return n}if(Ze)return Ze.encode(i);let e=new Uint8Array(i.length);for(let t=0;t<i.length;t++)e[t]=i.charCodeAt(t)&255;return e}var jt,Ze,Gn,Je=R(()=>{"use strict";jt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,Ze=typeof TextEncoder<"u"?new TextEncoder:null,Gn=typeof TextDecoder<"u"?new TextDecoder:null});function X(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{let e=Math.random()*16|0;return(i==="x"?e:e&3|8).toString(16)})}function dn(i){let e="";for(let n=0;n<i.length;n+=8192)e+=String.fromCharCode(...i.subarray(n,n+8192));return btoa(e)}function an(i){let e=atob(i),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function cn(i){if(!i)return!1;let e;try{e=new URL(i)}catch{return!1}return e.username||e.password?!1:e.protocol==="https:"?!0:e.protocol==="http:"?e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname==="[::1]":!1}function ln(i){let e={},t=0;for(let n of Object.keys(i)){if(t>=Ht)break;let r=i[n];if(r==null)continue;let o=String(r);e[n]=o.length>tt?`${o.slice(0,tt)}...[truncated]`:o,t++}return e}function un(i){let e=i.slice(se.length).split("_");return e.length===2&&/^\d+$/.test(e[0])}function fn(i,e){if(!i||!e)return!1;try{return new URL(i).origin===new URL(e).origin}catch{return!1}}function dt(i){try{typeof localStorage<"u"&&(localStorage.setItem(ot,i.toString()),Y=i)}catch{}}function at(i=Date.now()){return V>0&&i-V<=st}function de(){let i=Date.now(),e=!!x&&!at(i);if(V=i,e){x=null;for(let t of gn)t();return}!Z||!x||Y===0||i-Y<hn||dt(i)}function yn(){return!x||Z&&Y===0}function bn(){if(rt||typeof window>"u")return;rt=!0;let i=()=>de();for(let e of pn)window.addEventListener(e,i,{passive:!0,capture:!0});typeof document<"u"&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&de()})}function Ae(){let i=Date.now(),e=!!x&&at(i);try{if(Z&&typeof localStorage<"u"){let t=localStorage.getItem(it),n=localStorage.getItem(ot),r=n&&parseInt(n,10)||0;if(t&&r&&i-r<=st)return(x!==t||V<r)&&(x=t,V=Math.max(V,r)),Y===0&&(Y=r),t;let o=e?x:X();return e||(V=i),localStorage.setItem(it,o),dt(V),x=o,o}}catch{}return e||(x=X(),V=i),x}function l(i){return String(i??"").replace(/%/g,"%25").replace(/:/g,"%3A")}function mn(i,e){switch(i){case"auctionInit":return`auctionInit:${l(e?.auctionId)}`;case"auctionEnd":return`auctionEnd:${l(e?.auctionId)}`;case"bidRequested":{let t=Array.isArray(e?.bids)?e.bids.map(n=>l(n?.bidId||n?.transactionId||n?.adUnitCode)).join(","):"";return`bidRequested:${l(e?.auctionId)}:${l(e?.bidderCode||e?.bidder)}:${t}`}case"bidResponse":{let t=e||{},n=t.creativeId||t.adId||t.requestId||t.bidId||"",r=t.originalCpm??t.cpm??"";return`bidResponse:${l(t.auctionId)}:${l(t.adUnitCode)}:${l(t.bidderCode||t.bidder)}:${l(n)}:${l(r)}`}case"bidTimeout":return"bidTimeout:"+(Array.isArray(e)?e:e?[e]:[]).map(n=>`${l(n?.auctionId)}:${l(n?.bidderCode||n?.bidder)}:${l(n?.bidId||n?.transactionId||n?.adUnitCode)}`).join(",");case"bidWon":{let t=e||{},n=t.creativeId||t.adId||t.requestId||t.bidId||"",r=t.originalCpm??t.cpm??"";return`bidWon:${l(t.auctionId)}:${l(t.adUnitCode)}:${l(t.bidderCode||t.bidder)}:${l(n)}:${l(r)}`}case"noBid":return`noBid:${l(e?.auctionId)}:${l(e?.adUnitCode)}:${l(e?.bidderCode||e?.bidder)}:${l(e?.bidId||e?.transactionId)}`;case"adRenderFailed":{let t=e?.bid||{};return`adRenderFailed:${l(t.auctionId||e?.auctionId)}:${l(t.adUnitCode||e?.adUnitCode)}:${l(t.bidderCode||t.bidder||e?.bidderCode||e?.bidder)}:${l(e?.reason)}:${l(e?.message)}`}case"adRenderSucceeded":{let t=e?.bid||e||{},n=t.creativeId||t.adId||e?.adId||"",r=t.originalCpm??t.cpm??"";return`adRenderSucceeded:${l(t.auctionId||e?.auctionId)}:${l(t.adUnitCode||e?.adUnitCode)}:${l(t.bidderCode||t.bidder)}:${l(n)}:${l(r)}`}case"setTargeting":return`setTargeting:${Object.keys(e||{}).sort().map(l).join(",")}`;case"auctionDebug":return`auctionDebug:${l(e?.type)}:${l(String(e?.arguments?.[0]??"").slice(0,50))}`;default:return""}}function K(i){if(Number.isFinite(i?.width)&&Number.isFinite(i?.height))return{width:i.width,height:i.height};if(typeof i?.size=="string"){let e=i.size.match(/^(\d+)x(\d+)$/);if(e)return{width:Number(e[1]),height:Number(e[2])}}return{width:Number.isFinite(i?.width)?i.width:0,height:Number.isFinite(i?.height)?i.height:0}}function Q(i,e=!0){if(!i)return null;if(Array.isArray(i)){let t=i.find(n=>n?.provider==="bidkernel")??(e?i.find(n=>n&&typeof n=="object"&&n.provider===void 0):void 0);return t?Q(t,e):null}if(typeof i=="object"){if(i.options&&typeof i.options=="object")return i.options;if(i.config&&typeof i.config=="object")return i.config;if(i.propertyId||i.endpoint)return i}return null}function In(i){if(!i)return null;if(i._bidkernelAnalyticsConfig){let e=Q(i._bidkernelAnalyticsConfig);if(e)return e}if(i.bidkernelPrebidAnalytics){let e=i.bidkernelPrebidAnalytics;if(e.options){let t=Q(e.options);if(t)return t}if(e.config){let t=Q(e.config);if(t)return t}if(e.propertyId)return Q(e)}return null}function _e(i="pbjs",e){let t=typeof window<"u"?window:{};t[i]=t[i]||{};let n=t[i],r=s=>{let d=t._bidkernelPrebidAnalytics,a=d?.getEndpoint?.()||"",u={pbjsGlobalName:i,...e,...s};if(a&&!fn(u.endpoint||"",a)&&(z.warn(`Ignoring analytics endpoint change to ${u.endpoint||"(empty)"}: this page is pinned to ${a}. Reload to change the ingest endpoint.`),u.endpoint=a),d)try{d.disable()}catch(I){z.warn("Failed to disable previous analytics instance:",I)}let c=new S(u);return c.enable(),t._bidkernelPrebidAnalytics=c,c},o=()=>{try{n.adapterManager&&typeof n.adapterManager.registerAnalyticsAdapter=="function"&&n.adapterManager.registerAnalyticsAdapter({adapter:{enableAnalytics:d=>{let a=Q(d,!Array.isArray(d));a&&r(a)},disableAnalytics:()=>{t._bidkernelPrebidAnalytics&&t._bidkernelPrebidAnalytics.disable()}},code:"bidkernel"});let s=In(t);s&&(s.propertyId||e?.propertyId)&&r(s)}catch(s){z.warn("Failed to register standard Prebid analytics adapter:",s)}};n.adapterManager&&typeof n.adapterManager.registerAnalyticsAdapter=="function"?o():(n.que=n.que||[],n.que.push(o))}var et,qt,ee,Kt,Gt,we,tt,Ht,nt,se,zt,Yt,Xt,Qt,Zt,Jt,G,en,tn,nn,rn,on,sn,it,ot,st,x,V,Z,hn,Y,pn,rt,gn,Ce,z,S,Se=R(()=>{"use strict";De();Te();Je();et=1e4,qt=50,ee=200,Kt=300*1e3,Gt=10,we=32*1024,tt=1024,Ht=16,nt="text/plain",se="_bidkernel_pending_",zt=20,Yt=7200*1e3,Xt=1e4,Qt={auctionStart:m.AUCTION_START,auctionEnd:m.AUCTION_END,bidWin:m.BID_WIN,adRenderFailed:m.AD_RENDER_FAILED,click:m.CLICK,impression:m.IMPRESSION,timeInView:m.TIME_IN_VIEW,viewable:m.VIEWABLE},Zt=3e3,Jt=new Set([m.IMPRESSION,m.BID_WIN,m.CLICK]),G=1800*1e3,en=200,tn=1e3,nn=50,rn=200,on={static:oe.FLOOR_SOURCE_STATIC,pool:oe.FLOOR_SOURCE_POOL,none:oe.FLOOR_SOURCE_NONE},sn=1e3,it="_bidkernel_session",ot="_bidkernel_session_ts",st=1800*1e3,x=null,V=0,Z=!0;hn=60*1e3,Y=0,pn=["pointerdown","pointermove","keydown","scroll","wheel","touchstart"],rt=!1,gn=new Set;Ce=class{seenObjects=new WeakMap;seenKeys=new Set;isDuplicate(e,t){if(!t)return!1;if(typeof t=="object"){let r=this.seenObjects.get(t);if(r){if(r.has(e))return!0;r.add(e)}else this.seenObjects.set(t,new Set([e]))}let n=mn(e,t);if(n){if(this.seenKeys.has(n))return!0;if(this.seenKeys.size>=1e3){let r=this.seenKeys.values().next().value;r!==void 0&&this.seenKeys.delete(r)}this.seenKeys.add(n)}return!1}};z=ue({prefix:"[analytics]",logLevel:"INFO"}),S=class i{static activeInstances=new Set;static allInstances=new Set;static getActiveInstances(){return i.activeInstances}static setLogLevel(e){let t=P(e);z.setLevel(t);for(let n of i.allInstances)n.setLogLevel(t)}static getLogLevel(){return z.getLevel()}static setStorageAllowed(e){Z=e,Y=0}static isStorageAllowed(){return Z}config;queue=[];errorCount=0;flushTimer=null;boundFlushBeacon;boundVisibilityChange;isEnabled=!1;boundPbjsHandlers=[];pageUrl="";deduper=new Ce;consecutiveSendFailures=0;nextSendAllowedAt=0;replayedEventCount=0;revenueFlushTimer=null;persistedBatchKeys=[];persistedCleanupTimer=null;intersectionObserver=null;slotViewabilityRecords=new Map;elementToSlotId=new Map;slotRefreshIndices=new Map;slotAdSessionCounters=new Map;slotLastAuctionIds=new Map;pendingThresholdListeners=new Map;pendingViewableListeners=new Map;slotElements=new Map;clickDetachCleanups=new Set;lastClickAt=new Map;slotEmittedImpressionKeys=new Set;cachedWinningBids=new Map;videoDetachCleanups=new Set;auctionBidderOutcomes=new Map;floorDecisions=new Map;logger;managesSessionId;constructor(e){e.storageAllowed!==void 0&&i.setStorageAllowed(e.storageAllowed);let t=e.endpoint||"",n=!t||cn(t)?t:"";this.config={endpoint:n,propertyId:e.propertyId||"",pageviewId:e.pageviewId||X(),sessionId:e.sessionId||"",userId:e.userId||"",deviceType:e.deviceType||"desktop",country:e.country||"",region:e.region||"",auctionEnabled:e.auctionEnabled??!0,warningsEnabled:e.warningsEnabled??!0,errorsEnabled:e.errorsEnabled??!0,viewabilityEnabled:e.viewabilityEnabled??!0,storageAllowed:e.storageAllowed??!0,logLevel:e.logLevel?P(e.logLevel):z.getLevel(),pbjsGlobalName:e.pbjsGlobalName||"pbjs",attachPbjsListeners:e.attachPbjsListeners??!0,revenueFlushDelayMs:Number.isFinite(e.revenueFlushDelayMs)&&e.revenueFlushDelayMs>=0?e.revenueFlushDelayMs:Zt},i.allInstances.add(this),this.logger=ue({prefix:"[analytics]",logLevel:this.config.logLevel}),de(),this.managesSessionId=!e.sessionId,this.managesSessionId&&(this.config.sessionId=Ae()),t&&!n&&this.log("ERROR",`Rejected untrusted analytics endpoint ${t}: must be an absolute https:// URL without embedded credentials. Events will not be transmitted.`),this.boundFlushBeacon=()=>{this.flushAllSlotsTimeInView(),this.flushBeacon()},this.boundVisibilityChange=()=>this.handleVisibilityChange()}setLogLevel(e){let t=P(e);this.config.logLevel=t,this.logger.setLevel(t),z.setLevel(t)}getLogLevel(){return this.logger.getLevel()}enable(){if(!this.isEnabled){if(this.isEnabled=!0,i.activeInstances.add(this),this.logger.setLevel(this.config.logLevel),this.config.endpoint||this.log("WARN","Endpoint is empty. Analytics events will not be transmitted."),this.config.viewabilityEnabled&&typeof IntersectionObserver<"u"){this.intersectionObserver=new IntersectionObserver(this.handleIntersection.bind(this),{threshold:[.5]});for(let e of this.slotViewabilityRecords.values())e.element&&this.intersectionObserver.observe(e.element)}if(this.config.attachPbjsListeners&&this.attachPbjs(),typeof window<"u"){if(!this.pageUrl)try{let e=new URL(window.location.href);this.pageUrl=e.origin+e.pathname}catch{this.pageUrl=window.location.href}window.addEventListener("pagehide",this.boundFlushBeacon),typeof document<"u"&&document.addEventListener("visibilitychange",this.boundVisibilityChange),bn(),this.flushTimer=setInterval(()=>this.flush(),et),this.resendPersistedBatches()}}}attachPbjs(){if(!this.isEnabled)return!1;if(this.boundPbjsHandlers.length>0)return!0;let t=(typeof window<"u"?window:{})[this.config.pbjsGlobalName]||{};if(typeof t.onEvent!="function")return this.log("WARN","pbjs.onEvent is not defined. Prebid analytics will not function."),!1;this.log("DEBUG","Attaching event listeners to pbjs");let n={auctionInit:this.handleAuctionInit.bind(this),auctionEnd:this.handleAuctionEnd.bind(this),bidRequested:this.handleBidRequested.bind(this),bidResponse:this.handleBidResponse.bind(this),bidTimeout:this.handleBidTimeout.bind(this),bidWon:this.handleBidWon.bind(this),noBid:this.handleNoBid.bind(this),adRenderFailed:this.handleAdRenderFailed.bind(this),adRenderSucceeded:this.handleAdRenderSucceeded.bind(this)};for(let[r,o]of Object.entries(n))t.onEvent(r,o),this.boundPbjsHandlers.push({event:r,handler:o});if(typeof t.getEvents=="function")try{let r=t.getEvents();if(Array.isArray(r)){let o=r.slice(this.replayedEventCount);if(this.replayedEventCount=r.length,o.length>0){this.log("DEBUG",`Replaying ${o.length} historical events from pbjs.getEvents()`);for(let s of o){if(!s)continue;let d=s.eventType||s.event||s.name,a=s.args!==void 0?s.args:s.data!==void 0?s.data:s,u=n[d];u&&u(a)}}}}catch(r){this.log("WARN","Failed to replay historical events from pbjs.getEvents()",r)}return!0}disable(){if(this.isEnabled){this.flushAllSlotsTimeInView(),this.isEnabled=!1,i.activeInstances.delete(this);for(let e of this.slotViewabilityRecords.values()){e.dwellTimer&&(clearTimeout(e.dwellTimer),e.dwellTimer=null,e.dwellStartedAt=null);for(let t of e.thresholdListeners)t.timer&&(clearTimeout(t.timer),t.timer=null)}this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.slotViewabilityRecords.clear(),this.elementToSlotId.clear();for(let e of this.videoDetachCleanups)try{e()}catch{}this.videoDetachCleanups.clear();for(let e of Array.from(this.clickDetachCleanups))try{e()}catch{}if(this.clickDetachCleanups.clear(),this.slotElements.clear(),this.cachedWinningBids.clear(),this.slotEmittedImpressionKeys.clear(),this.slotLastAuctionIds.clear(),this.auctionBidderOutcomes.clear(),this.floorDecisions.clear(),this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),this.revenueFlushTimer&&(clearTimeout(this.revenueFlushTimer),this.revenueFlushTimer=null),this.persistedCleanupTimer&&(clearTimeout(this.persistedCleanupTimer),this.persistedCleanupTimer=null),typeof window<"u"&&(window.removeEventListener("pagehide",this.boundFlushBeacon),typeof document<"u"&&document.removeEventListener("visibilitychange",this.boundVisibilityChange)),this.boundPbjsHandlers.length>0){let t=(typeof window<"u"?window:{})[this.config.pbjsGlobalName]||{};if(typeof t.offEvent=="function")for(let{event:n,handler:r}of this.boundPbjsHandlers)t.offEvent(n,r);this.boundPbjsHandlers=[]}this.flush()}}handleVisibilityChange(){if(!(typeof document>"u")){if(document.visibilityState==="hidden"){let e=typeof performance<"u"&&performance.now?performance.now():Date.now();for(let t of this.slotViewabilityRecords.values()){t.inView&&t.lastEnteredViewAt!==null&&(t.accumulatedTimeInViewMs+=Math.max(0,e-t.lastEnteredViewAt),t.lastEnteredViewAt=null,this.checkThresholdListeners(t)),t.dwellTimer&&(clearTimeout(t.dwellTimer),t.dwellTimer=null,t.dwellStartedAt=null);for(let r of t.thresholdListeners)r.timer&&(clearTimeout(r.timer),r.timer=null);let n=Math.round(t.accumulatedTimeInViewMs);n>0&&this.enqueue(m.TIME_IN_VIEW,"timeInView",{auctionId:t.auctionId,transactionId:t.transactionId,adUnitCode:t.adUnitCode,viewableDurationMs:n,bid:t.bidPayload,metadata:{...t.metadata,refresh_index:String(t.refreshIndex)}})}this.flushBeacon()}else if(document.visibilityState==="visible"){let e=typeof performance<"u"&&performance.now?performance.now():Date.now();for(let t of this.slotViewabilityRecords.values())if(t.inView){if(t.lastEnteredViewAt=e,!t.viewableFired&&t.dwellTimer===null){let n=t.mediaType==="video"?2e3:1e3;t.dwellStartedAt=e,t.dwellTimer=setTimeout(()=>{this.handleDwellComplete(t)},n)}this.scheduleThresholdTimers(t)}}}}handleIntersection(e){for(let t of e){let n=this.elementToSlotId.get(t.target);if(!n){for(let a of i.activeInstances)if(a!==this&&a.elementToSlotId.has(t.target)){a.handleIntersection([t]);break}continue}let r=this.slotViewabilityRecords.get(n);if(!r)continue;let o=t.isIntersecting&&(t.intersectionRatio===void 0||t.intersectionRatio>=.5),s=typeof document>"u"||document.visibilityState==="visible",d=typeof performance<"u"&&performance.now?performance.now():Date.now();if(o){if(!r.inView&&(r.inView=!0,s)){if(r.lastEnteredViewAt=d,!r.viewableFired&&r.dwellTimer===null){let a=r.mediaType==="video"?2e3:1e3;r.dwellStartedAt=d,r.dwellTimer=setTimeout(()=>{this.handleDwellComplete(r)},a)}this.scheduleThresholdTimers(r)}}else{r.inView&&(r.lastEnteredViewAt!==null&&(r.accumulatedTimeInViewMs+=Math.max(0,d-r.lastEnteredViewAt),r.lastEnteredViewAt=null),r.inView=!1,this.checkThresholdListeners(r)),r.dwellTimer!==null&&(clearTimeout(r.dwellTimer),r.dwellTimer=null,r.dwellStartedAt=null);for(let a of r.thresholdListeners)a.timer&&(clearTimeout(a.timer),a.timer=null)}}}handleDwellComplete(e){e.dwellTimer=null,e.dwellStartedAt=null,e.inView&&(typeof document<"u"&&document.visibilityState==="hidden"||(e.viewableFired||(e.viewableFired=!0,this.enqueue(m.VIEWABLE,"viewable",{auctionId:e.auctionId,transactionId:e.transactionId,adUnitCode:e.adUnitCode,bid:e.bidPayload,metadata:{...e.metadata,refresh_index:String(e.refreshIndex)}})),this.notifyViewable(e)))}notifyViewable(e){if(e.viewableFired){for(let t of e.viewableListeners)if(t.firedForIndex!==e.refreshIndex){t.firedForIndex=e.refreshIndex;try{t.callback(e.slotId)}catch(n){this.log("ERROR","Error in viewable listener callback",n)}}}}setSlotElement(e,t){this.slotElements.set(e,t);let n=this.slotViewabilityRecords.get(e);n&&n.element!==t&&this.observeSlot(t,e,{refreshIndex:n.refreshIndex})}recordClick(e,t){if(!this.isEnabled||!e)return!1;let n=Date.now();if(n-(this.lastClickAt.get(e)||0)<sn)return!1;this.lastClickAt.set(e,n);let r=this.getCachedBid(e);return this.enqueue(m.CLICK,"click",{auctionId:r?.auctionId||"",transactionId:r?.transactionId||"",adUnitCode:e,bid:r?.bidTrace,metadata:{...t?.metadata,refresh_index:String(this.getRefreshIndex(e))}}),!0}attachClickTracker(e,t){if(typeof window>"u")return()=>{};let n=()=>{setTimeout(()=>{let o=document.activeElement;o&&(o===e||e.contains(o))&&(this.recordClick(t,{metadata:{source:"blur"}}),window.focus())},0)};window.addEventListener("blur",n);let r=()=>{window.removeEventListener("blur",n),this.clickDetachCleanups.delete(r)};return this.clickDetachCleanups.add(r),r}onViewable(e,t){let n={callback:t,firedForIndex:-1},r=this.slotViewabilityRecords.get(e);return r?(r.viewableListeners.add(n),this.notifyViewable(r)):(this.pendingViewableListeners.has(e)||this.pendingViewableListeners.set(e,new Set),this.pendingViewableListeners.get(e).add(n)),()=>{this.slotViewabilityRecords.get(e)?.viewableListeners.delete(n),this.pendingViewableListeners.get(e)?.delete(n)}}scheduleThresholdTimers(e){if(!e.inView||typeof document<"u"&&document.visibilityState==="hidden")return;let t=this.getCurrentTimeInView(e);for(let n of e.thresholdListeners)if(!n.fired)if(t>=n.thresholdMs){n.fired=!0,n.timer&&(clearTimeout(n.timer),n.timer=null);try{n.callback(e.slotId,t)}catch(r){this.log("ERROR","Error in threshold listener callback",r)}}else{n.timer&&clearTimeout(n.timer);let r=n.thresholdMs-t;n.timer=setTimeout(()=>{if(n.timer=null,!n.fired&&e.inView&&(typeof document>"u"||document.visibilityState==="visible")){let o=this.getCurrentTimeInView(e);if(o>=n.thresholdMs){n.fired=!0;try{n.callback(e.slotId,o)}catch(s){this.log("ERROR","Error in threshold listener callback",s)}}}},r)}}checkThresholdListeners(e){let t=this.getCurrentTimeInView(e);for(let n of e.thresholdListeners)if(!n.fired&&t>=n.thresholdMs){n.fired=!0,n.timer&&(clearTimeout(n.timer),n.timer=null);try{n.callback(e.slotId,t)}catch(r){this.log("ERROR","Error in threshold listener callback",r)}}}getCurrentTimeInView(e){let t=e.accumulatedTimeInViewMs;if(e.inView&&e.lastEnteredViewAt!==null){let n=typeof performance<"u"&&performance.now?performance.now():Date.now();t+=Math.max(0,n-e.lastEnteredViewAt)}return t}flushSlotTimeInView(e){let t=this.slotViewabilityRecords.get(e);if(!t)return;if(t.inView&&t.lastEnteredViewAt!==null){let r=typeof performance<"u"&&performance.now?performance.now():Date.now();t.accumulatedTimeInViewMs+=Math.max(0,r-t.lastEnteredViewAt),t.lastEnteredViewAt=null}let n=Math.round(t.accumulatedTimeInViewMs);n>0&&this.enqueue(m.TIME_IN_VIEW,"timeInView",{auctionId:t.auctionId,transactionId:t.transactionId,adUnitCode:t.adUnitCode,viewableDurationMs:n,bid:t.bidPayload,metadata:{...t.metadata,refresh_index:String(t.refreshIndex)}}),t.accumulatedTimeInViewMs=0}flushAllSlotsTimeInView(){for(let e of Array.from(this.slotViewabilityRecords.keys()))this.flushSlotTimeInView(e)}observeSlot(e,t,n){if(!this.config.viewabilityEnabled)return;let r=null;if(typeof e=="string"){if(typeof document<"u"){try{r=document.querySelector(e)||document.getElementById(e)}catch{r=document.getElementById(e)}r||(r=document.getElementById(e))}}else r=e;let o=t||n?.adUnitCode||(r?r.id:"")||X(),s=this.slotViewabilityRecords.get(o);if(s){if(n?.refreshIndex===void 0||n.refreshIndex>s.refreshIndex){this.flushSlotTimeInView(o);let a=n?.refreshIndex!==void 0?n.refreshIndex:(this.slotRefreshIndices.get(o)??s.refreshIndex)+1;this.slotRefreshIndices.set(o,a),s.dwellTimer&&(clearTimeout(s.dwellTimer),s.dwellTimer=null,s.dwellStartedAt=null);for(let c of s.thresholdListeners)c.fired=!1,c.timer&&(clearTimeout(c.timer),c.timer=null);s.viewableFired=!1,s.accumulatedTimeInViewMs=0;let u=typeof performance<"u"&&performance.now?performance.now():Date.now();if(s.lastEnteredViewAt=s.inView?u:null,s.refreshIndex=a,s.auctionId=n?.auctionId||s.auctionId,s.transactionId=n?.transactionId||s.transactionId,s.mediaType=n?.mediaType||s.mediaType||"banner",s.bidPayload=n?.bid!==void 0?n.bid:s.bidPayload,s.metadata=n?.metadata??s.metadata,s.inView&&(typeof document>"u"||document.visibilityState==="visible")){let c=s.mediaType==="video"?2e3:1e3;s.dwellStartedAt=u,s.dwellTimer=setTimeout(()=>{this.handleDwellComplete(s)},c),this.scheduleThresholdTimers(s)}}else s.auctionId=n?.auctionId||s.auctionId,s.transactionId=n?.transactionId||s.transactionId,s.mediaType=n?.mediaType||s.mediaType,n?.bid!==void 0&&(s.bidPayload=n.bid),n?.metadata!==void 0&&(s.metadata=n.metadata);n?.auctionId&&this.slotLastAuctionIds.set(o,n.auctionId),r&&(s.element&&s.element!==r&&this.intersectionObserver&&(this.intersectionObserver.unobserve(s.element),this.elementToSlotId.delete(s.element)),s.element=r,this.elementToSlotId.set(r,o),this.intersectionObserver?.observe(r))}else{let d=n?.refreshIndex??this.slotRefreshIndices.get(o)??0;this.slotRefreshIndices.set(o,d),n?.auctionId&&this.slotLastAuctionIds.set(o,n.auctionId);let a=this.pendingThresholdListeners.get(o)||new Set;this.pendingThresholdListeners.delete(o);let u=this.pendingViewableListeners.get(o)||new Set;this.pendingViewableListeners.delete(o);let c={slotId:o,element:r,adUnitCode:n?.adUnitCode||o,auctionId:n?.auctionId||"",transactionId:n?.transactionId||"",mediaType:n?.mediaType||"banner",bidPayload:n?.bid,metadata:n?.metadata,refreshIndex:d,inView:!1,lastEnteredViewAt:null,accumulatedTimeInViewMs:0,viewableFired:!1,dwellTimer:null,dwellStartedAt:null,thresholdListeners:a,viewableListeners:u};this.slotViewabilityRecords.set(o,c),r&&(this.elementToSlotId.set(r,o),this.intersectionObserver?.observe(r))}}unobserveSlot(e){let t=this.slotViewabilityRecords.get(e);if(t){this.flushSlotTimeInView(e),t.dwellTimer&&(clearTimeout(t.dwellTimer),t.dwellTimer=null,t.dwellStartedAt=null);for(let n of t.thresholdListeners)n.timer&&(clearTimeout(n.timer),n.timer=null);t.thresholdListeners=new Set,t.viewableListeners=new Set,t.element&&this.intersectionObserver&&(this.intersectionObserver.unobserve(t.element),this.elementToSlotId.delete(t.element),t.element=null),t.inView=!1,t.lastEnteredViewAt=null}}destroySlot(e){this.unobserveSlot(e),this.slotViewabilityRecords.delete(e),this.slotRefreshIndices.delete(e),this.slotAdSessionCounters.delete(e),this.slotLastAuctionIds.delete(e),this.pendingThresholdListeners.delete(e),this.pendingViewableListeners.delete(e);let t=`${l(e)}:`;for(let r of Array.from(this.slotEmittedImpressionKeys))(r===e||r.startsWith(t))&&this.slotEmittedImpressionKeys.delete(r);let n=this.cachedWinningBids.get(e);n&&this.deleteCachedBidEntry(n)}getCachedBid(e){let t=this.cachedWinningBids.get(e);if(t){if(Date.now()-t.timestamp>G){this.deleteCachedBidEntry(t);return}return t}}deleteCachedBidEntry(e){for(let[t,n]of Array.from(this.cachedWinningBids))n===e&&this.cachedWinningBids.delete(t)}pruneCachedWinningBids(){let e=Date.now();for(let[t,n]of Array.from(this.cachedWinningBids))e-n.timestamp>G&&this.cachedWinningBids.delete(t);for(;this.cachedWinningBids.size>en;){let t=this.cachedWinningBids.keys().next();if(t.done)break;this.cachedWinningBids.delete(t.value)}}addImpressionKey(e){if(!this.slotEmittedImpressionKeys.has(e)){for(;this.slotEmittedImpressionKeys.size>=tn;){let t=this.slotEmittedImpressionKeys.values().next();if(t.done)break;this.slotEmittedImpressionKeys.delete(t.value)}this.slotEmittedImpressionKeys.add(e)}}getOrCreateAuctionOutcomes(e){let t=this.auctionBidderOutcomes.get(e);for(t||(t=new Map,this.auctionBidderOutcomes.set(e,t));this.auctionBidderOutcomes.size>nn;){let n=this.auctionBidderOutcomes.keys().next();if(n.done||n.value===e)break;this.auctionBidderOutcomes.delete(n.value)}return t}nextSlotAdSession(e){let t=(this.slotAdSessionCounters.get(e)??0)+1;return this.slotAdSessionCounters.set(e,t),`ad-session-${t}`}hasImpressionEmitted(e,t,n,r,o){let s=t??this.slotRefreshIndices.get(e)??0,d=`${l(e)}:${s}`;if(o){if(n){if(this.slotEmittedImpressionKeys.has(`${d}:auc:${l(n)}:ad:${l(o)}`)||this.slotEmittedImpressionKeys.has(`${d}:ad:${l(o)}`)||this.slotEmittedImpressionKeys.has(`${d}:auc:${l(n)}:${l(o)}`)||this.slotEmittedImpressionKeys.has(`${d}:${l(o)}`))return!0}else if(this.slotEmittedImpressionKeys.has(`${d}:ad:${l(o)}`)||this.slotEmittedImpressionKeys.has(`${d}:${l(o)}`))return!0;if(r&&r!==o){if(n){if(this.slotEmittedImpressionKeys.has(`${d}:auc:${l(n)}:${l(r)}`)||this.slotEmittedImpressionKeys.has(`${d}:${l(r)}`))return!0}else if(this.slotEmittedImpressionKeys.has(`${d}:${l(r)}`))return!0}return!1}return r?n?this.slotEmittedImpressionKeys.has(`${d}:auc:${l(n)}:${l(r)}`)||this.slotEmittedImpressionKeys.has(`${d}:${l(r)}`):this.slotEmittedImpressionKeys.has(`${d}:${l(r)}`):n?this.slotEmittedImpressionKeys.has(`${d}:auc:${l(n)}`):this.slotEmittedImpressionKeys.has(d)}markImpressionEmitted(e,t,n,r,o){let s=`${l(e)}:${t}`;!!(o||r)?(o&&(this.addImpressionKey(`${s}:ad:${l(o)}`),this.addImpressionKey(`${s}:${l(o)}`),n&&(this.addImpressionKey(`${s}:auc:${l(n)}:ad:${l(o)}`),this.addImpressionKey(`${s}:auc:${l(n)}:${l(o)}`))),r&&r!==o&&(this.addImpressionKey(`${s}:${l(r)}`),n&&this.addImpressionKey(`${s}:auc:${l(n)}:${l(r)}`)),n&&this.addImpressionKey(`${s}:auc:${l(n)}`)):(this.addImpressionKey(s),n&&this.addImpressionKey(`${s}:auc:${l(n)}`))}recordImpression(e,t){if(!this.isEnabled)return!1;let n=e||t?.adUnitCode||"",r=t?.adUnitCode||n,o=(t?.auctionId&&n?this.getCachedBid(`${t.auctionId}:${n}`):void 0)||(t?.auctionId&&r?this.getCachedBid(`${t.auctionId}:${r}`):void 0)||(n?this.getCachedBid(n):void 0)||(r?this.getCachedBid(r):void 0),s=t?.bid||o?.rawBid||{},d=t?.auctionId||s.auctionId||o?.auctionId||"",a=t?.transactionId||s.transactionId||o?.transactionId||"",u=s.creativeId||o?.bidTrace?.creativeId||t?.bid?.creativeId||"",c=t?.adId||s.adId||t?.bid?.adId||"",I=t?.mediaType||s.mediaType||o?.bidTrace?.mediaType||"banner",g=n||r,f=(n?this.slotViewabilityRecords.get(n):void 0)||(r?this.slotViewabilityRecords.get(r):void 0),L=g?this.slotLastAuctionIds.get(g)||(f?f.auctionId:void 0):void 0,y=!!(g&&d&&L&&L!==d&&t?.refreshIndex===void 0),_={bidder:s.bidderCode||s.bidder||o?.bidTrace?.bidder||"",cpm:Number.isFinite(s.originalCpm)?s.originalCpm:Number.isFinite(s.cpm)?s.cpm:o?.bidTrace?.cpm??0,currency:s.originalCurrency??s.currency??o?.bidTrace?.currency??"USD",...K(s).width?K(s):o?.bidTrace?{width:o.bidTrace.width,height:o.bidTrace.height}:K(s),dealId:s.dealId||o?.bidTrace?.dealId||"",mediaType:I,latencyMs:Number.isFinite(s.timeToRespond)?s.timeToRespond:o?.bidTrace?.latencyMs??0,advertiserDomain:s.meta?.advertiserDomains?.[0]||o?.bidTrace?.advertiserDomain||"",creativeId:s.creativeId||o?.bidTrace?.creativeId||""};if(y&&g){this.flushSlotTimeInView(g);let v=(this.slotRefreshIndices.get(g)??(f?f.refreshIndex:0))+1;this.slotRefreshIndices.set(g,v),this.slotLastAuctionIds.set(g,d),f&&(f.refreshIndex=v,f.auctionId=d,f.transactionId=a,f.bidPayload=_,f.viewableFired=!1,f.accumulatedTimeInViewMs=0)}else g&&(d&&this.slotLastAuctionIds.set(g,d),this.slotRefreshIndices.has(g)||this.slotRefreshIndices.set(g,0));let B=t?.refreshIndex??(n?this.slotRefreshIndices.get(n)??(r?this.slotRefreshIndices.get(r):void 0)??(f?f.refreshIndex:0):0);return n&&this.hasImpressionEmitted(n,B,d,u,c)||r&&r!==n&&this.hasImpressionEmitted(r,B,d,u,c)?(this.log("DEBUG",`Impression already emitted for slot ${n||r} in cycle ${B}`),!1):(n&&this.markImpressionEmitted(n,B,d,u,c),r&&r!==n&&this.markImpressionEmitted(r,B,d,u,c),this.enqueue(m.IMPRESSION,"impression",{auctionId:d,transactionId:a,adUnitCode:r,bid:_,metadata:{...t?.metadata,refresh_index:String(B)}}),f&&(!f.bidPayload&&_&&(f.bidPayload=_),!f.auctionId&&d&&(f.auctionId=d),!f.transactionId&&a&&(f.transactionId=a)),!0)}onTimeInViewThreshold(e,t,n){let r={thresholdMs:t,callback:n,timer:null,fired:!1},o=this.slotViewabilityRecords.get(e);if(o){o.thresholdListeners.add(r);let s=this.getCurrentTimeInView(o);if(s>=t){r.fired=!0;try{n(e,s)}catch(d){this.log("ERROR","Error in threshold callback",d)}}else if(o.inView&&(typeof document>"u"||document.visibilityState==="visible")){let d=t-s;r.timer=setTimeout(()=>{if(r.timer=null,!r.fired&&o.inView&&(typeof document>"u"||document.visibilityState==="visible")){let a=this.getCurrentTimeInView(o);if(a>=t){r.fired=!0;try{n(e,a)}catch(u){this.log("ERROR","Error in threshold callback",u)}}}},d)}}else this.pendingThresholdListeners.has(e)||this.pendingThresholdListeners.set(e,new Set),this.pendingThresholdListeners.get(e).add(r);return()=>{r.timer&&(clearTimeout(r.timer),r.timer=null),o&&o.thresholdListeners.delete(r);let s=this.pendingThresholdListeners.get(e);s&&s.delete(r)}}getViewabilityState(e){let t=this.slotViewabilityRecords.get(e);if(!t)return;let n=Math.round(this.getCurrentTimeInView(t));return{inView:t.inView,viewable:t.viewableFired,timeInViewMs:n,refreshIndex:t.refreshIndex}}getEndpoint(){return this.config.endpoint}getRefreshIndex(e){return this.slotRefreshIndices.get(e)??0}triggerSlotRefresh(e,t){let n=this.slotViewabilityRecords.get(e);n&&n.element&&this.observeSlot(n.element,e,t)}trackRawEvent(e,t,n){let r=Qt[t]??(e==="ERROR"?m.ERROR:void 0);r!==void 0&&this.enqueue(r,t,n,e)}recordFloorDecision(e,t,n){if(!e||!t)return;let r=`${e}:${t}`;for(this.floorDecisions.delete(r),this.floorDecisions.set(r,{floorCents:n.floorCents!==void 0&&Number.isFinite(n.floorCents)?Math.round(n.floorCents):void 0,source:n.source,treatment:Number.isFinite(n.treatment)?n.treatment:1});this.floorDecisions.size>rn;){let o=this.floorDecisions.keys().next();if(o.done)break;this.floorDecisions.delete(o.value)}}floorDecisionFor(e,t){return e&&t?this.floorDecisions.get(`${e}:${t}`):void 0}setUserId(e){this.config.userId=e}setSessionId(e){this.config.sessionId=e,this.managesSessionId=!e,this.managesSessionId&&(this.config.sessionId=Ae())}navigate(e,t){if(this.disable(),this.slotRefreshIndices.clear(),this.slotAdSessionCounters.clear(),this.floorDecisions.clear(),this.pendingThresholdListeners.clear(),this.config.pageviewId=e||X(),t)try{let n=new URL(t);this.pageUrl=n.origin+n.pathname}catch{this.pageUrl=t}else this.pageUrl="";this.logger.resetTiming(),de(),this.enable()}handleAuctionInit(e){if(this.isDuplicate("auctionInit",e))return;this.log("DEBUG","auctionInit",e);let t=e.auctionId||"";t&&(this.auctionBidderOutcomes.delete(t),this.getOrCreateAuctionOutcomes(t)),this.enqueue(m.AUCTION_START,"auctionStart",{auctionId:t,transactionId:e.transactionId||""})}handleAuctionEnd(e){if(this.isDuplicate("auctionEnd",e))return;this.log("DEBUG","auctionEnd",e);let t=e.auctionId||"",n=t?this.auctionBidderOutcomes.get(t):void 0,r=n?Array.from(n.values()):[];t&&this.auctionBidderOutcomes.delete(t),this.enqueue(m.AUCTION_END,"auctionEnd",{auctionId:t,transactionId:e.transactionId||"",bidderOutcomes:r})}auctionCycleIndex(e){if(!e)return 0;let t=this.slotRefreshIndices.get(e)??this.slotViewabilityRecords.get(e)?.refreshIndex;return t===void 0?0:t+1}handleBidRequested(e){if(this.isDuplicate("bidRequested",e))return;this.log("DEBUG","bidRequested",e);let t=e.auctionId||"",n=e.bidderCode||e.bidder||"";if(!t||!n)return;let r=this.getOrCreateAuctionOutcomes(t);Array.isArray(e.bids)&&e.bids.forEach(o=>{let s=o.adUnitCode||"",d=Object.keys(o.mediaTypes||{}),a=d.length>0?d[0]:o.mediaType||"banner",u=`${n}:${s}`;r.has(u)||r.set(u,{adUnitCode:s,outcome:F.BIDDER_OUTCOME_NO_RESPONSE,bid:{bidder:n,mediaType:a,latencyMs:0}})})}handleBidResponse(e){if(this.isDuplicate("bidResponse",e))return;this.log("DEBUG","bidResponse",e);let t=e.auctionId||"",n=e.bidderCode||e.bidder||"",r=e.adUnitCode||"",o=Number.isFinite(e.originalCpm)?e.originalCpm:Number.isFinite(e.cpm)?e.cpm:0,s=Number.isFinite(e.timeToRespond)?e.timeToRespond:0,d=Object.keys(e.mediaTypes||{}),a=e.mediaType||(e.mediaTypes?.video?"video":d.length>0?d[0]:"banner");if(!t||!n)return;let u=o>0?{bidder:n,cpm:o,currency:e.originalCurrency??e.currency??"USD",...K(e),dealId:e.dealId||"",mediaType:a,latencyMs:s,advertiserDomain:e.meta?.advertiserDomains?.[0]||"",creativeId:e.creativeId||""}:{bidder:n,mediaType:a,latencyMs:s};this.getOrCreateAuctionOutcomes(t).set(`${n}:${r}`,{adUnitCode:r,outcome:o>0?F.BIDDER_OUTCOME_BID:F.BIDDER_OUTCOME_NO_BID,bid:u})}handleBidTimeout(e){if(this.isDuplicate("bidTimeout",e))return;this.log("DEBUG","bidTimeout",e);let t=Array.isArray(e)?e:e?[e]:[];for(let n of t){let r=n.auctionId||"",o=n.bidderCode||n.bidder||"",s=n.adUnitCode||"",d=Number.isFinite(n.timeout)?n.timeout:0;if(r&&o){let a=this.getOrCreateAuctionOutcomes(r),u=`${o}:${s}`,c=a.get(u);c?(c.outcome=F.BIDDER_OUTCOME_TIMEOUT,d>0&&c.bid&&(c.bid.latencyMs=d)):a.set(u,{adUnitCode:s,outcome:F.BIDDER_OUTCOME_TIMEOUT,bid:{bidder:o,mediaType:"banner",latencyMs:d}})}}}handleBidWon(e){if(this.isDuplicate("bidWon",e))return;this.log("DEBUG","bidWon",e);let t=e.auctionId||"",n=e.transactionId||"",r=e.adUnitCode||e.adId||"",o=Object.keys(e.mediaTypes||{}),s=e.mediaType||(e.mediaTypes?.video?"video":o.length>0?o[0]:"banner"),d={bidder:e.bidderCode||e.bidder||"",cpm:Number.isFinite(e.originalCpm)?e.originalCpm:Number.isFinite(e.cpm)?e.cpm:0,currency:e.originalCurrency??e.currency??"USD",...K(e),dealId:e.dealId||"",mediaType:s,latencyMs:Number.isFinite(e.timeToRespond)?e.timeToRespond:0,advertiserDomain:e.meta?.advertiserDomains?.[0]||"",creativeId:e.creativeId||""};if(r){let a={bidTrace:d,auctionId:t,transactionId:n,adUnitCode:r,rawBid:e,timestamp:Date.now()};this.cachedWinningBids.set(r,a),e.adId&&e.adId!==r&&this.cachedWinningBids.set(e.adId,a),t&&(this.cachedWinningBids.set(`${t}:${r}`,a),e.adId&&e.adId!==r&&this.cachedWinningBids.set(`${t}:${e.adId}`,a)),this.pruneCachedWinningBids()}this.enqueue(m.BID_WIN,"bidWon",{auctionId:t,transactionId:n,adUnitCode:r,bid:d})}handleNoBid(e){if(this.isDuplicate("noBid",e))return;this.log("DEBUG","noBid",e);let t=e.auctionId||"",n=e.bidderCode||e.bidder||"",r=e.adUnitCode||"";if(t&&n){let o=this.getOrCreateAuctionOutcomes(t),s=`${n}:${r}`,d=o.get(s);d?d.outcome===F.BIDDER_OUTCOME_NO_RESPONSE&&(d.outcome=F.BIDDER_OUTCOME_NO_BID):o.set(s,{adUnitCode:r,outcome:F.BIDDER_OUTCOME_NO_BID,bid:{bidder:n,mediaType:"banner",latencyMs:0}})}}handleAdRenderFailed(e){if(this.isDuplicate("adRenderFailed",e))return;this.log("DEBUG","adRenderFailed",e);let t=e.bid||{};this.enqueue(m.AD_RENDER_FAILED,"adRenderFailed",{auctionId:t.auctionId||e.auctionId||"",transactionId:t.transactionId||e.transactionId||"",adUnitCode:t.adUnitCode||e.adUnitCode||"",bid:{bidder:t.bidderCode||t.bidder||e.bidderCode||e.bidder||""},metadata:{reason:String(e.reason||""),message:String(e.message||e.error?.message||"")},error:e.error||(e.message?new Error(String(e.message)):void 0)})}handleAdRenderSucceeded(e){if(this.isDuplicate("adRenderSucceeded",e))return;this.log("DEBUG","adRenderSucceeded",e);let t=e.bid||e||{},n=e.adUnitCode||t.adUnitCode||e.adId||t.adId||"",r=t.auctionId||e.auctionId||"",o=t.transactionId||e.transactionId||"",s=t.mediaType||"banner",d=e.adUnitCode||t.adUnitCode||"",a=e.adId||t.adId||"",u=(r&&d?this.getCachedBid(`${r}:${d}`):void 0)||(r&&a?this.getCachedBid(`${r}:${a}`):void 0)||(d?this.getCachedBid(d):void 0)||(a?this.getCachedBid(a):void 0),c=s==="video"||t.mediaType==="video"||t.mediaTypes?.video!==void 0||u?.bidTrace?.mediaType==="video"||u?.rawBid?.mediaType==="video"||n&&this.slotViewabilityRecords.get(n)?.mediaType==="video",I=c?"video":s||u?.bidTrace?.mediaType||"banner",g={bidder:t.bidderCode||t.bidder||u?.bidTrace?.bidder||"",cpm:Number.isFinite(t.originalCpm)?t.originalCpm:Number.isFinite(t.cpm)?t.cpm:u?.bidTrace?.cpm??0,currency:t.originalCurrency??t.currency??u?.bidTrace?.currency??"USD",...K(t).width?K(t):u?.bidTrace?{width:u.bidTrace.width,height:u.bidTrace.height}:K(t),dealId:t.dealId||u?.bidTrace?.dealId||"",mediaType:I,latencyMs:Number.isFinite(t.timeToRespond)?t.timeToRespond:u?.bidTrace?.latencyMs??0,advertiserDomain:t.meta?.advertiserDomains?.[0]||u?.bidTrace?.advertiserDomain||"",creativeId:t.creativeId||u?.bidTrace?.creativeId||""},f=r||u?.auctionId||"",L=o||u?.transactionId||"",y=n?this.slotViewabilityRecords.get(n):void 0,_=y&&f&&y.auctionId&&y.auctionId!==f;if(!!(n&&y&&_)){this.flushSlotTimeInView(n);let v=(this.slotRefreshIndices.get(n)??(y?y.refreshIndex:0))+1;this.slotRefreshIndices.set(n,v),this.slotLastAuctionIds.set(n,f),y&&(y.refreshIndex=v,y.auctionId=f,y.transactionId=L,y.bidPayload=g,y.viewableFired=!1,y.accumulatedTimeInViewMs=0)}else n&&(f&&this.slotLastAuctionIds.set(n,f),this.slotRefreshIndices.has(n)||this.slotRefreshIndices.set(n,0));let U=n?this.slotRefreshIndices.get(n)??(y?y.refreshIndex:0):0;if(c?this.log("DEBUG",`adRenderSucceeded received for video ad unit ${n||"unknown"}: suppressing IMPRESSION until verified video lifecycle event`):n&&this.hasImpressionEmitted(n,U,f,g.creativeId)||(n&&this.markImpressionEmitted(n,U,f,g.creativeId),this.enqueue(m.IMPRESSION,"impression",{auctionId:f,transactionId:L,adUnitCode:n,bid:g,metadata:{refresh_index:String(U)}})),this.config.viewabilityEnabled&&typeof document<"u"){let v=n&&this.slotElements.get(n)||null,T=n||e.adId||t.adId;if(!v&&T&&(v=document.getElementById(T)),!v&&typeof window<"u"&&window.googletag?.pubads)try{let M=window.googletag.pubads().getSlots();for(let b of M)if((b.getAdUnitPath?.()===n||b.getSlotElementId?.()===n)&&(v=document.getElementById(b.getSlotElementId()),v))break}catch{}if(!v&&T)try{for(let M of Array.from(document.querySelectorAll("[data-ad-slot]")))if(M.getAttribute("data-ad-slot")===T){v=M;break}}catch{}v&&this.observeSlot(v,n||T,{adUnitCode:n,auctionId:f,transactionId:L,mediaType:I,bid:g,refreshIndex:U})}}isDuplicate(e,t){return this.deduper.isDuplicate(e,t)}enqueue(e,t,n,r){if(!this.isEnabled||!this.shouldSample(e,r))return;this.managesSessionId&&yn()&&(this.config.sessionId=Ae());let o={eventId:q(X()),timestampMs:Date.now(),type:e,eventName:e===m.ERROR?t:"",auctionId:q(String(n.auctionId||"")),transactionId:q(String(n.transactionId||"")),adUnitCode:n.adUnitCode||n.elementId||"",namespace:n.ns||n.namespace||""};n.bid&&(o.bid={bidder:n.bid.bidder||"",cpm:Number.isFinite(n.bid.cpm)?n.bid.cpm:0,currency:n.bid.currency||"",width:Number.isFinite(n.bid.width)?n.bid.width:0,height:Number.isFinite(n.bid.height)?n.bid.height:0,dealId:n.bid.dealId||"",mediaType:n.bid.mediaType||"",latencyMs:Number.isFinite(n.bid.latencyMs)?n.bid.latencyMs:0,advertiserDomain:n.bid.advertiserDomain||"",creativeId:n.bid.creativeId||""}),n.viewableDurationMs!==void 0&&(o.viewableDurationMs=Number.isFinite(n.viewableDurationMs)?n.viewableDurationMs:0),n.bidderOutcomes&&Array.isArray(n.bidderOutcomes)&&(o.bidderOutcomes=n.bidderOutcomes.map(a=>{let u=this.floorDecisionFor(String(n.auctionId||""),a.adUnitCode||"");return{...a,refreshIndex:a.refreshIndex??this.auctionCycleIndex(a.adUnitCode||""),...u?{floorCents:u.floorCents,floorSource:on[u.source],floorTreatmentBp:Math.round(u.treatment*1e4)}:{}}}));let s={...n.metadata};if(e===m.BID_WIN||e===m.IMPRESSION){let a=this.floorDecisionFor(String(n.auctionId||""),o.adUnitCode||"");a&&(a.floorCents!==void 0&&(s.floor_cents=String(a.floorCents)),s.floor_source=a.source,s.floor_treatment=a.treatment.toFixed(2))}n.error!==void 0&&n.error!==null&&(s.error=typeof n.error=="object"&&n.error.message?String(n.error.message):String(n.error)),n.gpid&&(s.gpid=String(n.gpid)),n.refreshIndex!==void 0&&s.refresh_index===void 0&&(s.refresh_index=String(n.refreshIndex));let d=ln(s);Object.keys(d).length>0&&(o.metadata=d),this.queue.push(o),this.queue.length>=ee?(this.flush(),this.queue.length>ee&&this.queue.splice(0,this.queue.length-ee)):Jt.has(e)&&this.revenueFlushTimer===null&&(this.revenueFlushTimer=setTimeout(()=>{this.revenueFlushTimer=null,this.flush()},this.config.revenueFlushDelayMs))}shouldSample(e,t){return e===m.ERROR?(this.errorCount++,this.errorCount>qt?!1:this.config.errorsEnabled):t==="WARN"?this.config.warningsEnabled:this.config.auctionEnabled}requeue(e){e.length&&(this.queue=e.concat(this.queue),this.queue.length>ee&&this.queue.splice(0,this.queue.length-ee))}drainBatch(){if(this.queue.length===0||!this.config.endpoint)return null;let e=typeof window<"u"?window.location.hostname:"",t=n=>({propertyId:q(this.config.propertyId),pageviewId:q(this.config.pageviewId),sessionId:q(this.config.sessionId),pageUrl:this.pageUrl,country:this.config.country,region:this.config.region,deviceType:this.config.deviceType,userId:q(this.config.userId),domain:e,events:n});for(;;){if(this.queue.length===0)return null;let n=this.queue,r=Ee.encode(t(n)).finish();for(;n.length>1&&r.byteLength>we;)n=n.slice(0,Math.floor(n.length/2)),r=Ee.encode(t(n)).finish();if(r.byteLength>we){let[o]=this.queue.splice(0,1);this.log("WARN",`Dropping oversized event (type ${o?.type}, ${r.byteLength} bytes exceeds the ${we}-byte cap on its own)`);continue}return this.queue=this.queue.slice(n.length),{url:`${this.config.endpoint}/${this.config.propertyId}`,encoded:r,events:n}}}sendFetch(e,t=!1,n,r=!1){let o={method:"POST",headers:{"Content-Type":nt},body:e.encoded};t&&(o.keepalive=!0),fetch(e.url,o).then(d=>{if(d.ok)r||(this.consecutiveSendFailures=0,this.nextSendAllowedAt=0),n&&n();else{if(this.log("WARN",`Failed to send batch: HTTP ${d.status}`),d.status>=400&&d.status<500&&d.status!==429&&d.status!==408){this.log("WARN",`Dropping batch due to non-retryable client error HTTP ${d.status}`);return}r||this.handleSendFailure(e.events)}}).catch(d=>{this.log("ERROR","Failed to send batch",d),r||this.handleSendFailure(e.events)});let s=typeof globalThis<"u"?globalThis.process:void 0;if(s&&typeof s._tickCallback=="function")try{s._tickCallback()}catch{}}handleSendFailure(e){this.consecutiveSendFailures++;let t=Math.min(et*2**(this.consecutiveSendFailures-1),Kt);this.nextSendAllowedAt=Date.now()+t,this.consecutiveSendFailures<=Gt?this.requeue(e):this.log("WARN",`Dropping ${e.length} events after ${this.consecutiveSendFailures} consecutive send failures`)}flush(){if(Date.now()<this.nextSendAllowedAt)return;let e=this.drainBatch();for(;e&&(this.sendFetch(e,!1),!(Date.now()<this.nextSendAllowedAt));)e=this.drainBatch()}flushBeacon(){let e=this.drainBatch();for(;e;){let t=!1;if(typeof navigator<"u"&&typeof navigator.sendBeacon=="function")try{let n=new Blob([e.encoded],{type:nt});t=navigator.sendBeacon(e.url,n)}catch{t=!1}if(!t){let n=this.persistBatch(e.encoded);this.sendFetch(e,!0,()=>this.removePersistedBatch(n))}e=this.drainBatch()}this.schedulePersistedCleanup()}pendingKeyPrefix(){return`${se}${encodeURIComponent(this.config.propertyId)}_`}persistBatch(e){if(!Z)return null;try{if(typeof localStorage>"u"||!this.config.propertyId)return null;let t=0;for(let r=0;r<localStorage.length;r++){let o=localStorage.key(r);o&&o.startsWith(se)&&t++}if(t>=zt)return null;let n=`${this.pendingKeyPrefix()}${Date.now()}_${Math.floor(Math.random()*1e6)}`;return localStorage.setItem(n,dn(e)),this.persistedBatchKeys.push(n),n}catch{return null}}removePersistedBatch(e){if(!e)return;try{typeof localStorage<"u"&&localStorage.removeItem(e)}catch{}let t=this.persistedBatchKeys.indexOf(e);t!==-1&&this.persistedBatchKeys.splice(t,1)}schedulePersistedCleanup(){this.persistedBatchKeys.length!==0&&(this.persistedCleanupTimer&&clearTimeout(this.persistedCleanupTimer),this.persistedCleanupTimer=setTimeout(()=>{this.persistedCleanupTimer=null;for(let e of Array.from(this.persistedBatchKeys))this.removePersistedBatch(e)},Xt))}resendPersistedBatches(){try{if(typeof localStorage>"u"||!this.config.endpoint||!this.config.propertyId)return;let e=this.pendingKeyPrefix(),t=[],n=[];for(let r=0;r<localStorage.length;r++){let o=localStorage.key(r);!o||!o.startsWith(se)||(o.startsWith(e)?t.push(o):un(o)&&n.push(o))}for(let r of n)try{localStorage.removeItem(r)}catch{}for(let r of t){let o=null;try{o=localStorage.getItem(r),localStorage.removeItem(r)}catch{continue}if(!o)continue;let s=parseInt(r.slice(e.length),10);if(!Number.isFinite(s)||Date.now()-s>Yt)continue;let d;try{d=an(o)}catch{continue}d.byteLength!==0&&(this.log("DEBUG",`Resending persisted exit batch (${d.byteLength} bytes)`),this.sendFetch({url:`${this.config.endpoint}/${this.config.propertyId}`,encoded:d,events:[]},!1,void 0,!0))}}catch{}}log(e,t,...n){this.logger.log(e,t,...n)}}});function vn(i){let e=typeof i?.getError=="function"?i.getError():i?.error||i,t=a=>e&&typeof e[a]=="function"?e[a]():void 0,n=t("getMessage")||e?.message||String(e||"IMA ad error"),r=t("getErrorCode")??e?.code,o=t("getVastErrorCode"),s=t("getType")??e?.type,d={message:n};return r&&(d.error_code=String(r)),o&&(d.vast_error_code=String(o)),s&&(d.error_type=String(s)),{err:e,message:n,metadata:d}}function ht(i,e,t){let n=ae(i),{err:r,message:o,metadata:s}=vn(e);return n.log("WARN","IMA AdErrorEvent received",e),n.enqueue(m.AD_RENDER_FAILED,"adRenderFailed",{auctionId:t.auctionId,transactionId:t.transactionId,adUnitCode:t.adUnitCode,bid:t.bid,metadata:{...t.metadata,reason:t.adStarted?"ima_playback_error":"ima_ad_error",playback_phase:t.adStarted?"post_start":"pre_start",...s},error:typeof r=="object"?r:new Error(o)}),r}function En(i,e){if(!i||typeof i!="object"||ct.has(i))return;ct.add(i);let t=typeof window<"u"&&window.google?.ima?.AdErrorEvent?.Type?.AD_ERROR||"adError";try{e.call(i,t,n=>{for(let r of S.getActiveInstances())try{let o=gt(r,{mediaType:"video"});ht(r,n,{adStarted:!1,adUnitCode:o?.adUnitCode||"video",auctionId:o?.auctionId,transactionId:o?.transactionId,bid:o?.bidTrace})}catch{}})}catch{}}function lt(i){if(i)try{let e=i.prototype;if(e&&typeof e.getAdsManager=="function"&&!e.getAdsManager.__bidkernelHooked){let t=e.getAdsManager,n=function(...r){let o=t.apply(this,r);if(o)for(let s of S.getActiveInstances())try{s.attachImaAdsManager(o)}catch{}return o};n.__bidkernelHooked=!0,e.getAdsManager=n}}catch{}}function ut(i){if(i)try{let e=i.prototype||i;if(e&&typeof e.init=="function"&&!e.init.__bidkernelHooked){let t=e.init,n=function(...r){for(let o of S.getActiveInstances())try{o.attachImaAdsManager(this)}catch{}return t.apply(this,r)};n.__bidkernelHooked=!0,e.init=n}if(e&&typeof e.start=="function"&&!e.start.__bidkernelHooked){let t=e.start,n=function(...r){for(let o of S.getActiveInstances())try{o.attachImaAdsManager(this)}catch{}return t.apply(this,r)};n.__bidkernelHooked=!0,e.start=n}}catch{}}function ft(i){if(i)try{let e=i.prototype;if(!e)return;if(typeof e.addEventListener=="function"&&!e.addEventListener.__bidkernelHooked){let t=e.addEventListener,n=function(r,o,...s){if(En(this,t),(r==="adsManagerLoaded"||r===(this?.AdsManagerLoadedEvent?.Type?.ADS_MANAGER_LOADED||"adsManagerLoaded"))&&typeof o=="function"){let d=Le.get(o);return d||(d=function(a){if(a&&typeof a.getAdsManager=="function"&&!a.getAdsManager.__bidkernelHooked){let u=a.getAdsManager;a.getAdsManager=function(...c){let I=u.apply(this,c);if(I)for(let g of S.getActiveInstances())try{g.attachImaAdsManager(I)}catch{}return I},a.getAdsManager.__bidkernelHooked=!0}return o.apply(this,arguments)},Le.set(o,d)),t.call(this,r,d,...s)}return t.call(this,r,o,...s)};n.__bidkernelHooked=!0,e.addEventListener=n}if(typeof e.removeEventListener=="function"&&!e.removeEventListener.__bidkernelHooked){let t=e.removeEventListener,n=function(r,o,...s){let d=typeof o=="function"?Le.get(o):void 0;return t.call(this,r,d||o,...s)};n.__bidkernelHooked=!0,e.removeEventListener=n}}catch{}}function te(i){if(!(!i||typeof i!="object"))try{i.AdsManagerLoadedEvent&<(i.AdsManagerLoadedEvent);let e=Object.getOwnPropertyDescriptor(i,"AdsManagerLoadedEvent");if(!e||e.configurable){let r=i.AdsManagerLoadedEvent;try{Object.defineProperty(i,"AdsManagerLoadedEvent",{configurable:!0,enumerable:!0,get(){return r},set(o){r=o,lt(o)}})}catch{}}i.AdsLoader&&ft(i.AdsLoader);let t=Object.getOwnPropertyDescriptor(i,"AdsLoader");if(!t||t.configurable){let r=i.AdsLoader;try{Object.defineProperty(i,"AdsLoader",{configurable:!0,enumerable:!0,get(){return r},set(o){r=o,ft(o)}})}catch{}}i.AdsManager&&ut(i.AdsManager);let n=Object.getOwnPropertyDescriptor(i,"AdsManager");if(!n||n.configurable){let r=i.AdsManager;try{Object.defineProperty(i,"AdsManager",{configurable:!0,enumerable:!0,get(){return r},set(o){r=o,ut(o)}})}catch{}}}catch{}}function pt(){if(typeof window>"u")return;let i=window;if(i.google?.ima&&te(i.google.ima),i.google&&typeof i.google=="object"){let t=Object.getOwnPropertyDescriptor(i.google,"ima");if(!t||t.configurable){let n=i.google.ima;try{Object.defineProperty(i.google,"ima",{configurable:!0,enumerable:!0,get(){return n},set(r){n=r,te(r)}})}catch{}}}let e=Object.getOwnPropertyDescriptor(i,"google");if(!e||e.configurable){let t=i.google;try{Object.defineProperty(i,"google",{configurable:!0,enumerable:!0,get(){return t},set(n){if(t=n,t&&typeof t=="object"){t.ima&&te(t.ima);let r=Object.getOwnPropertyDescriptor(t,"ima");if(!r||r.configurable){let o=t.ima;try{Object.defineProperty(t,"ima",{configurable:!0,enumerable:!0,get(){return o},set(s){o=s,te(s)}})}catch{}}}}})}catch{}}}function gt(i,e){let t=ae(i),n=Date.now(),r=d=>t.hasImpressionEmitted(d.adUnitCode,void 0,d.auctionId,d.bidTrace.creativeId);if(e?.creativeId||e?.adId){for(let d of Array.from(t.cachedWinningBids.values()))if(!(n-d.timestamp>G)&&(e.creativeId&&(d.bidTrace.creativeId===e.creativeId||d.rawBid?.creativeId===e.creativeId)||e.adId&&(d.rawBid?.adId===e.adId||d.adUnitCode===e.adId)))return d}let o;if(e?.mediaType){for(let a of Array.from(t.cachedWinningBids.values())){if(n-a.timestamp>G)continue;(a.bidTrace.mediaType===e.mediaType||a.rawBid?.mediaType===e.mediaType||e.mediaType==="video"&&a.rawBid?.mediaTypes?.video!==void 0)&&(r(a)||(!o||a.timestamp<o.timestamp)&&(o=a))}if(o)return o;let d;for(let a of Array.from(t.cachedWinningBids.values())){if(n-a.timestamp>G)continue;(a.bidTrace.mediaType===e.mediaType||a.rawBid?.mediaType===e.mediaType||e.mediaType==="video"&&a.rawBid?.mediaTypes?.video!==void 0)&&(!d||a.timestamp>d.timestamp)&&(d=a)}if(d)return d}for(let d of Array.from(t.cachedWinningBids.values()))n-d.timestamp>G||r(d)||(!o||d.timestamp>o.timestamp)&&(o=d);if(o)return o;let s;for(let d of Array.from(t.cachedWinningBids.values()))n-d.timestamp>G||(!s||d.timestamp>s.timestamp)&&(s=d);return s}function yt(i,e,t){let n=ae(i);if(!e||typeof e.addEventListener!="function")return n.log("WARN","Invalid AdsManager passed to attachImaAdsManager"),()=>{};if(!e.__bidkernelAttachedInstances)try{Object.defineProperty(e,"__bidkernelAttachedInstances",{value:new Map,configurable:!0,writable:!0})}catch{e.__bidkernelAttachedInstances=new Map}let r=e.__bidkernelAttachedInstances,o=r.get(i);if(o){if(!t)return()=>{};o()}let s=t?.slotId||t?.adUnitCode||"video",d=t?.adUnitCode||s,a=t?.auctionId||"",u=t?.transactionId||"",c=p=>{let h=(a?n.getCachedBid(`${a}:${d}`):void 0)||(a&&s!==d?n.getCachedBid(`${a}:${s}`):void 0)||(d!=="video"?n.getCachedBid(d):void 0)||(s!==d&&s!=="video"?n.getCachedBid(s):void 0);return h||(h=gt(i,{creativeId:p?.creativeId,adId:p?.adId,mediaType:"video"})),h},I=!1,g=null,f=p=>{let h=typeof n.nextSlotAdSession=="function"?n.nextSlotAdSession(s):`ad-session-${(n.slotAdSessionCounters?.get(s)??0)+1}`;if(n.slotAdSessionCounters&&typeof n.nextSlotAdSession!="function"){let N=(n.slotAdSessionCounters.get(s)??0)+1;n.slotAdSessionCounters.set(s,N)}let E=(typeof p?.getAdId=="function"?p.getAdId():p?.adId??p?.id)||"",H=(typeof p?.getCreativeId=="function"?p.getCreativeId():p?.creativeId)||"";return g={sessionId:h,adId:E||void 0,creativeId:H||void 0},g},L=p=>{let h=typeof p?.getAd=="function"?p.getAd():p?.ad;f(h),n.log("DEBUG","IMA AdEvent.LOADED received",{slotId:s,activeAdSession:g})},y=p=>{I=!0;let h=typeof p?.getAd=="function"?p.getAd():p?.ad,E={};h&&(E.creativeId=(typeof h.getCreativeId=="function"?h.getCreativeId():h.creativeId)||"",E.adId=(typeof h.getAdId=="function"?h.getAdId():h.id)||"",E.title=(typeof h.getTitle=="function"?h.getTitle():h.title)||"",E.duration=typeof h.getDuration=="function"?h.getDuration():h.duration,E.advertiserName=typeof h.getAdvertiserName=="function"?h.getAdvertiserName():""),!g||E.adId&&g.adId&&g.adId!==E.adId?f(h):(!g.adId&&E.adId&&(g.adId=E.adId),!g.creativeId&&E.creativeId&&(g.creativeId=E.creativeId));let H=g||f(h),N=c(E),ce=t?.slotId&&t.slotId!=="video"?t.slotId:t?.adUnitCode&&t.adUnitCode!=="video"?t.adUnitCode:N?.adUnitCode||t?.slotId||t?.adUnitCode||"video",It=t?.adUnitCode&&t.adUnitCode!=="video"?t.adUnitCode:N?.adUnitCode||ce,vt=a||N?.auctionId||"",Et=u||N?.transactionId||"",Re=H.creativeId||E.creativeId||N?.bidTrace?.creativeId||t?.bid?.creativeId||"",Tt=H.adId||E.adId||Re||H.sessionId,Oe={...N?.rawBid||t?.bid,mediaType:"video",creativeId:Re},Be=n.recordImpression(ce,{adUnitCode:It,auctionId:vt,transactionId:Et,mediaType:"video",bid:Oe,adId:Tt,metadata:{...t?.metadata,media_type:"video",...E.title?{ad_title:E.title}:{},...Number.isFinite(E.duration)?{ad_duration_s:String(E.duration)}:{}}}),J=typeof p?.type=="string"?p.type:typeof p?.getType=="function"?p.getType():typeof p=="string"?p:"";J.toLowerCase().startsWith("adevent.")&&(J=J.slice(8));let wt=J?J.toUpperCase():"STARTED/IMPRESSION";if(n.log("DEBUG",`IMA AdEvent.${wt} received${Be?"":" (second event for this ad, already counted)"}`,p),Be&&t?.onImpression)try{t.onImpression(ce,{ad:h,bid:Oe})}catch(At){n.log("ERROR","Error in onImpression callback",At)}},_=p=>{if(n.log("DEBUG",`IMA AdEvent milestone: ${p}`),t?.onMilestone)try{t.onMilestone(p,s)}catch(h){n.log("ERROR","Error in onMilestone callback",h)}},B=p=>{n.log("DEBUG","IMA AdEvent.CLICK received",p);let h=c(),E=t?.adUnitCode&&t.adUnitCode!=="video"?t.adUnitCode:h?.adUnitCode||s;n.enqueue(m.CLICK,"click",{auctionId:a||h?.auctionId,transactionId:u||h?.transactionId,adUnitCode:E,bid:h?.bidTrace||t?.bid,metadata:{...t?.metadata,media_type:"video"}})},U=p=>{g=null;let h=c(),E=t?.adUnitCode&&t.adUnitCode!=="video"?t.adUnitCode:h?.adUnitCode||s,H=ht(i,p,{adStarted:I,adUnitCode:E,auctionId:a||h?.auctionId,transactionId:u||h?.transactionId,bid:h?.bidTrace||t?.bid,metadata:t?.metadata});if(t?.onError)try{t.onError(H)}catch(N){n.log("ERROR","Error in onError callback",N)}},v=typeof window<"u"?window.google?.ima:void 0,T=v?.AdEvent?.Type||{},M=v?.AdErrorEvent?.Type||{},b=[{type:T.LOADED||"loaded",handler:L},{type:T.STARTED||"started",handler:y},{type:T.IMPRESSION||"impression",handler:y},{type:T.FIRST_QUARTILE||"firstQuartile",handler:()=>_("firstQuartile")},{type:T.MIDPOINT||"midpoint",handler:()=>_("midpoint")},{type:T.THIRD_QUARTILE||"thirdQuartile",handler:()=>_("thirdQuartile")},{type:T.COMPLETE||"complete",handler:()=>{g=null,_("complete")}},{type:T.ALL_ADS_COMPLETED||"allAdsCompleted",handler:()=>{g=null}},{type:T.CLICK||"click",handler:B},{type:M.AD_ERROR||"adError",handler:U}],A=new Set,w=[];for(let p of b)A.has(p.type)||(A.add(p.type),w.push(p));for(let{type:p,handler:h}of w)try{e.addEventListener(p,h)}catch{}let D=()=>{g=null,r.delete(i);for(let{type:p,handler:h}of w)try{e.removeEventListener(p,h)}catch{}n.videoDetachCleanups.delete(D)};return r.set(i,D),n.videoDetachCleanups.add(D),D}function Tn(i,e,t){let n=ae(i);if(!e)return n.log("WARN","attachVideoPlayer called with null/undefined target"),()=>{};let r=null;if(typeof e=="string"){if(typeof document<"u")try{r=document.querySelector(e)||document.getElementById(e)}catch{r=document.getElementById(e)}}else if(typeof HTMLElement<"u"&&e instanceof HTMLElement)r=e;else if(e&&typeof e=="object"&&e.nodeType===1)r=e;else{if(typeof e.addEventListener=="function"&&(typeof e.init=="function"||typeof e.start=="function"||typeof e.getCuePoints=="function"||typeof e.getVolume=="function"||e.__imaAdsManager))return yt(i,e,t);e&&typeof e.addEventListener=="function"&&(r=e)}let o=t?.slotId||t?.adUnitCode||(r?r.id:"")||"video",s=t?.adUnitCode||o,d=t?.auctionId||"",a=t?.transactionId||"",u=()=>(d?n.getCachedBid(`${d}:${s}`):void 0)||(d&&o!==s?n.getCachedBid(`${d}:${o}`):void 0)||n.getCachedBid(s)||(o!==s?n.getCachedBid(o):void 0),c=null;r&&(r.tagName&&r.tagName.toLowerCase()==="video"?c=r:c=r.querySelector("video"));let I={q1:!1,q2:!1,q3:!1,q4:!1},g=b=>{let A=b||c||(r?.querySelector?r.querySelector("video"):null),w=u(),D={...w?.rawBid||t?.bid,mediaType:"video"};if(n.recordImpression(o,{adUnitCode:s,auctionId:d||w?.auctionId,transactionId:a||w?.transactionId,mediaType:"video",bid:D,metadata:{...t?.metadata,media_type:"video",...A&&Number.isFinite(A.duration)?{video_duration_s:String(Math.round(A.duration))}:{}}})&&t?.onImpression)try{t.onImpression(o,{element:A||r,bid:D})}catch(h){n.log("ERROR","Error in onImpression callback",h)}},f=b=>{n.log("DEBUG","HTML5 video playing event received");let A=b?.target instanceof HTMLVideoElement?b.target:c;g(A)},L=b=>{let A=b?.target instanceof HTMLVideoElement?b.target:c;if(A&&A.currentTime>0&&(g(A),Number.isFinite(A.duration)&&A.duration>0)){let w=A.currentTime/A.duration;w>=.25&&!I.q1&&(I.q1=!0,t?.onMilestone?.("firstQuartile",o)),w>=.5&&!I.q2&&(I.q2=!0,t?.onMilestone?.("midpoint",o)),w>=.75&&!I.q3&&(I.q3=!0,t?.onMilestone?.("thirdQuartile",o))}},y=()=>{I.q4||(I.q4=!0,t?.onMilestone?.("complete",o))},_=b=>{let w=(b?.target instanceof HTMLVideoElement?b.target:c)?.error||c?.error,D=u(),p=w?`HTML5 video error code ${w.code}: ${w.message}`:"Video playback error";if(n.log("WARN",p),n.enqueue(m.AD_RENDER_FAILED,"adRenderFailed",{auctionId:d||D?.auctionId,transactionId:a||D?.transactionId,adUnitCode:s,bid:D?.bidTrace||t?.bid,metadata:{...t?.metadata,reason:"html5_video_error",message:p,...w?.code?{error_code:String(w.code)}:{}},error:w?new Error(p):void 0}),t?.onError)try{t.onError(w)}catch(h){n.log("ERROR","Error in onError callback",h)}},B=b=>{b.addEventListener("playing",f),b.addEventListener("play",f),b.addEventListener("timeupdate",L),b.addEventListener("ended",y),b.addEventListener("error",_)},U=b=>{b.removeEventListener("playing",f),b.removeEventListener("play",f),b.removeEventListener("timeupdate",L),b.removeEventListener("ended",y),b.removeEventListener("error",_)},v=null;r&&r!==c&&(r.addEventListener("playing",f,!0),r.addEventListener("play",f,!0),r.addEventListener("timeupdate",L,!0),r.addEventListener("ended",y,!0),r.addEventListener("error",_,!0)),c&&B(c),r&&r.tagName?.toLowerCase()!=="video"&&typeof MutationObserver<"u"&&(v=new MutationObserver(()=>{let b=r.querySelector("video");b&&b!==c&&(c&&U(c),c=b,c&&B(c))}),v.observe(r,{childList:!0,subtree:!0}));let T=u();t?.trackViewability!==!1&&r&&n.observeSlot(r,o,{adUnitCode:s,auctionId:d||T?.auctionId,transactionId:a||T?.transactionId,mediaType:"video",bid:T?.bidTrace||t?.bid,metadata:t?.metadata});let M=()=>{v&&(v.disconnect(),v=null),r&&r!==c&&(r.removeEventListener("playing",f,!0),r.removeEventListener("play",f,!0),r.removeEventListener("timeupdate",L,!0),r.removeEventListener("ended",y,!0),r.removeEventListener("error",_,!0)),c&&U(c),n.videoDetachCleanups.delete(M)};return n.videoDetachCleanups.add(M),M}var ae,Le,ct,wn,bt=R(()=>{"use strict";Se();Te();ae=i=>i,Le=new WeakMap,ct=new WeakSet;typeof window<"u"&&pt();S.prototype.attachImaAdsManager=function(i,e){return yt(this,i,e)};S.prototype.attachVideoPlayer=function(i,e){return Tn(this,i,e)};wn=S.prototype.enable;S.prototype.enable=function(){wn.call(this),typeof window<"u"&&(pt(),window.google?.ima&&te(window.google.ima))}});var Cn=Ct(()=>{Se();bt();var mt="https://by.bidkernel.io/t",An=window._bidkernelPbjsGlobal||"pbjs";_e(An,{endpoint:mt});window.bidkernelPrebidAnalytics={...window.bidkernelPrebidAnalytics,register:(i,e)=>_e(i,{endpoint:mt,...e}),attachVideoPlayer:(i,e)=>{let t=window._bidkernelPrebidAnalytics;return t?.attachVideoPlayer?t.attachVideoPlayer(i,e):()=>{}},attachImaAdsManager:(i,e)=>{let t=window._bidkernelPrebidAnalytics;return t?.attachImaAdsManager?t.attachImaAdsManager(i,e):()=>{}},recordImpression:(i,e)=>{let t=window._bidkernelPrebidAnalytics;return t?.recordImpression?t.recordImpression(i,e):!1},setLogLevel:i=>{S.setLogLevel(i)},getLogLevel:()=>S.getLogLevel()}});return Cn();})();
|
|
1
|
+
"use strict";var bidkernelPrebidAnalyticsBundle=(()=>{var L=(i,e)=>()=>(i&&(e=i(i=0)),e);var Ct=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);function Rt(){if(typeof window<"u"){let i=window;return i.__bidkernelLogListeners||(i.__bidkernelLogListeners=new Set),i.__bidkernelLogListeners}return St}function Lt(i){if((i<0||!Number.isFinite(i))&&(i=0),i<1e3)return`${i.toFixed(2)}ms`;let e=i/1e3;if(e<60)return`${e.toFixed(2)}s`;let t=Math.floor(e/60);return t<60?`${t}m ${(e%60).toFixed(2)}s`:`${Math.floor(t/60)}h ${t%60}m ${(e%60).toFixed(2)}s`}function P(i){if(typeof i=="string"){let e=i.toUpperCase();if(e==="DEBUG"||e==="INFO"||e==="WARN"||e==="ERROR")return e}return C.INFO}function ue(i){return new le(i)}var C,xe,$,_t,St,le,De=L(()=>{"use strict";C={DEBUG:"DEBUG",INFO:"INFO",WARN:"WARN",ERROR:"ERROR"},xe={[C.DEBUG]:10,[C.INFO]:20,[C.WARN]:30,[C.ERROR]:40},$={badge:"color: #2dd4bf; font-weight: bold",badgeWarn:"background: #f59e0b; color: #fff; padding: 2px 4px; border-radius: 3px; font-weight: bold",badgeError:"background: #ef4444; color: #fff; padding: 2px 4px; border-radius: 3px; font-weight: bold",dim:"color: #6b7280",event:"color: #38bdf8; font-weight: bold",eventWarn:"color: #f59e0b; font-weight: bold",eventError:"color: #ef4444; font-weight: bold",reset:"color: inherit"},_t=0,St=new Set;le=class i{_prefix;_level;_loadedAt;_now;_console;_customFormatTime;_listeners=new Set;constructor(e={}){this._prefix=e.prefix??"[bidkernel]",this._level=P(e.logLevel??C.INFO),this._now=e.now,this._console=e.console,this._customFormatTime=e.formatTime,e.onLog&&this._listeners.add(e.onLog),this._loadedAt=e.loadedAt??(this._now?this._now():typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now())}get prefix(){return this._prefix}set prefix(e){this._prefix=e}get logLevel(){return this._level}set logLevel(e){this._level=P(e)}getLevel(){return this._level}setLevel(e){this._level=P(e)}getPrefix(){return this._prefix}setPrefix(e){this._prefix=e}resetTiming(e){this._loadedAt=e??(this._now?this._now():typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now())}getLoadedAt(){return this._loadedAt}addListener(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}removeListener(e){this._listeners.delete(e)}isEnabled(e){let t=P(e);return(xe[t]??20)>=(xe[this._level]??20)}formatTime(e){return this._customFormatTime?this._customFormatTime(e):Lt(e)}_getConsole(){if(this._console)return this._console;if(typeof console<"u")return console}_getElapsed(){let e=this._now?this._now():typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();return Math.max(0,e-this._loadedAt)}_dispatchRecord(e){for(let n of this._listeners)try{n(e)}catch{}let t=Rt();for(let n of t)if(!this._listeners.has(n))try{n(e)}catch{}if(typeof window<"u"&&typeof window.dispatchEvent=="function")try{window.dispatchEvent(new CustomEvent("__bidkernel_log__",{detail:e}))}catch{}}log(e,t,...n){let r=P(e);if(!this.isEnabled(r))return;let o=this._getElapsed(),s=this.formatTime(o),d=Date.now(),u={id:`bk_log_${d}_${++_t}`,timestamp:d,elapsedMs:o,level:r,prefix:this._prefix,message:t,args:n,data:n.length===1?n[0]:n.length>1?n:void 0};this._dispatchRecord(u);let c=this._getConsole();if(!c)return;let I=$.badge,g=$.event;r===C.WARN?(I=$.badgeWarn,g=$.eventWarn):r===C.ERROR&&(I=$.badgeError,g=$.eventError);let f=`%c${this._prefix}%c ${s} %c${t}%c`,R=[I,$.dim,g,$.reset],y=[f,...R];switch(n.length>0&&y.push(...n),r){case C.DEBUG:typeof c.log=="function"?c.log(...y):typeof c.debug=="function"&&c.debug(...y);break;case C.INFO:typeof c.info=="function"?c.info(...y):typeof c.log=="function"&&c.log(...y);break;case C.WARN:typeof c.warn=="function"?c.warn(...y):typeof c.log=="function"&&c.log(...y);break;case C.ERROR:typeof c.error=="function"?c.error(...y):typeof c.log=="function"&&c.log(...y);break;default:typeof c.log=="function"&&c.log(...y);break}}debug(e,...t){this.log(C.DEBUG,e,...t)}info(e,...t){this.log(C.INFO,e,...t)}warn(e,...t){this.log(C.WARN,e,...t)}error(e,...t){this.log(C.ERROR,e,...t)}logEvent(e){e&&(e.data!==void 0?this.log(e.level,e.eventName,e.data):this.log(e.level,e.eventName))}child(e,t={}){let n=this._prefix;if(e){let r=e.startsWith("[")&&e.endsWith("]")?e:`[${e}]`;n=`${this._prefix}${r}`}return new i({prefix:n,logLevel:t.logLevel??this._level,loadedAt:t.loadedAt??this._loadedAt,now:t.now??this._now,console:t.console??this._console,formatTime:t.formatTime??this._customFormatTime,...t})}withPrefix(e){return new i({prefix:e,logLevel:this._level,loadedAt:this._loadedAt,now:this._now,console:this._console,formatTime:this._customFormatTime})}}});function Ue(){let i=0,e=0;for(let n=0;n<28;n+=7){let r=this.buf[this.pos++];if(i|=(r&127)<<n,(r&128)==0)return this.assertBounds(),[i,e]}let t=this.buf[this.pos++];if(i|=(t&15)<<28,e=(t&112)>>4,(t&128)==0)return this.assertBounds(),[i,e];for(let n=3;n<=31;n+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<n,(r&128)==0)return this.assertBounds(),[i,e]}throw new Error("invalid varint")}function ie(i,e,t){for(let o=0;o<28;o=o+7){let s=i>>>o,d=!(!(s>>>7)&&e==0),a=(d?s|128:s)&255;if(t.push(a),!d)return}let n=i>>>28&15|(e&7)<<4,r=e>>3!=0;if(t.push((r?n|128:n)&255),!!r){for(let o=3;o<31;o=o+7){let s=e>>>o,d=!!(s>>>7),a=(d?s|128:s)&255;if(t.push(a),!d)return}t.push(e>>>31&1)}}function fe(i){let e=i[0]==="-";e&&(i=i.slice(1));let t=1e6,n=0,r=0;function o(s,d){let a=Number(i.slice(s,d));r*=t,n=n*t+a,n>=ne&&(r=r+(n/ne|0),n=n%ne)}return o(-24,-18),o(-18,-12),o(-12,-6),o(-6),e?Ne(n,r):pe(n,r)}function Me(i,e){let t=pe(i,e),n=t.hi&2147483648;n&&(t=Ne(t.lo,t.hi));let r=he(t.lo,t.hi);return n?"-"+r:r}function he(i,e){if({lo:i,hi:e}=Ot(i,e),e<=2097151)return String(ne*e+i);let t=i&16777215,n=(i>>>24|e<<8)&16777215,r=e>>16&65535,o=t+n*6777216+r*6710656,s=n+r*8147497,d=r*2,a=1e7;return o>=a&&(s+=Math.floor(o/a),o%=a),s>=a&&(d+=Math.floor(s/a),s%=a),d.toString()+ke(s)+ke(o)}function Ot(i,e){return{lo:i>>>0,hi:e>>>0}}function pe(i,e){return{lo:i|0,hi:e|0}}function Ne(i,e){return e=~e,i?i=~i+1:e+=1,pe(i,e)}function ge(i,e){if(i>=0){for(;i>127;)e.push(i&127|128),i=i>>>7;e.push(i)}else{for(let t=0;t<9;t++)e.push(i&127|128),i=i>>7;e.push(1)}}function Pe(){let i=this.buf[this.pos++],e=i&127;if((i&128)==0)return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<7,(i&128)==0)return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<14,(i&128)==0)return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<21,(i&128)==0)return this.assertBounds(),e;i=this.buf[this.pos++],e|=(i&15)<<28;for(let t=5;(i&128)!==0&&t<10;t++)i=this.buf[this.pos++];if((i&128)!=0)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var ne,ke,ye=L(()=>{"use strict";ne=4294967296;ke=i=>{let e=String(i);return"0000000".slice(e.length)+e}});function Bt(){let i=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof i.getBigInt64=="function"&&typeof i.getBigUint64=="function"&&typeof i.setBigInt64=="function"&&typeof i.setBigUint64=="function"&&(!!globalThis.Deno||typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let t=BigInt("-9223372036854775808"),n=BigInt("9223372036854775807"),r=BigInt("0"),o=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(s){let d=typeof s=="bigint"?s:BigInt(s);if(d>n||d<t)throw new Error(`invalid int64: ${s}`);return d},uParse(s){let d=typeof s=="bigint"?s:BigInt(s);if(d>o||d<r)throw new Error(`invalid uint64: ${s}`);return d},enc(s){return i.setBigInt64(0,this.parse(s),!0),{lo:i.getInt32(0,!0),hi:i.getInt32(4,!0)}},uEnc(s){return i.setBigInt64(0,this.uParse(s),!0),{lo:i.getInt32(0,!0),hi:i.getInt32(4,!0)}},dec(s,d){return i.setInt32(0,s,!0),i.setInt32(4,d,!0),i.getBigInt64(0,!0)},uDec(s,d){return i.setInt32(0,s,!0),i.setInt32(4,d,!0),i.getBigUint64(0,!0)}}}return{zero:"0",supported:!1,parse(t){return typeof t!="string"&&(t=t.toString()),Fe(t),t},uParse(t){return typeof t!="string"&&(t=t.toString()),Ve(t),t},enc(t){return typeof t!="string"&&(t=t.toString()),Fe(t),fe(t)},uEnc(t){return typeof t!="string"&&(t=t.toString()),Ve(t),fe(t)},dec(t,n){return Me(t,n)},uDec(t,n){return he(t,n)}}}function Fe(i){if(!/^-?[0-9]+$/.test(i))throw new Error("invalid int64: "+i)}function Ve(i){if(!/^[0-9]+$/.test(i))throw new Error("invalid uint64: "+i)}var k,$e=L(()=>{"use strict";ye();k=Bt()});function me(){if(globalThis[be]==null){let i=new globalThis.TextEncoder,e=new globalThis.TextDecoder;globalThis[be]={encodeUtf8(t){return i.encode(t)},decodeUtf8(t){return e.decode(t)},checkUtf8(t){try{return encodeURIComponent(t),!0}catch{return!1}}}}return globalThis[be]}var be,Ie=L(()=>{"use strict";be=Symbol.for("@bufbuild/protobuf/text-encoding")});function ve(i){if(typeof i=="string")i=Number(i);else if(typeof i!="number")throw new Error("invalid int32: "+typeof i);if(!Number.isInteger(i)||i>Ut||i<Mt)throw new Error("invalid int32: "+i)}function We(i){if(typeof i=="string")i=Number(i);else if(typeof i!="number")throw new Error("invalid uint32: "+typeof i);if(!Number.isInteger(i)||i>kt||i<0)throw new Error("invalid uint32: "+i)}function Nt(i){if(typeof i=="string"){let e=i;if(i=Number(i),Number.isNaN(i)&&e!=="NaN")throw new Error("invalid float32: "+e)}else if(typeof i!="number")throw new Error("invalid float32: "+typeof i);if(Number.isFinite(i)&&(i>xt||i<Dt))throw new Error("invalid float32: "+i)}var W,xt,Dt,kt,Ut,Mt,j,O,je=L(()=>{"use strict";ye();$e();Ie();(function(i){i[i.Varint=0]="Varint",i[i.Bit64=1]="Bit64",i[i.LengthDelimited=2]="LengthDelimited",i[i.StartGroup=3]="StartGroup",i[i.EndGroup=4]="EndGroup",i[i.Bit32=5]="Bit32"})(W||(W={}));xt=34028234663852886e22,Dt=-34028234663852886e22,kt=4294967295,Ut=2147483647,Mt=-2147483648,j=class{constructor(e=me().encodeUtf8){this.encodeUtf8=e,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let e=0;for(let r=0;r<this.chunks.length;r++)e+=this.chunks[r].length;let t=new Uint8Array(e),n=0;for(let r=0;r<this.chunks.length;r++)t.set(this.chunks[r],n),n+=this.chunks[r].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(We(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return ve(e),ge(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.encodeUtf8(e);return this.uint32(t.byteLength),this.raw(t)}float(e){Nt(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){We(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){ve(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return ve(e),e=(e<<1^e>>31)>>>0,ge(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=k.enc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=k.uEnc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=k.enc(e);return ie(t.lo,t.hi,this.buf),this}sint64(e){let t=k.enc(e),n=t.hi>>31,r=t.lo<<1^n,o=(t.hi<<1|t.lo>>>31)^n;return ie(r,o,this.buf),this}uint64(e){let t=k.uEnc(e);return ie(t.lo,t.hi,this.buf),this}},O=class{constructor(e,t=me().decodeUtf8){this.decodeUtf8=t,this.varint64=Ue,this.uint32=Pe,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.uint32(),t=e>>>3,n=e&7;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e,t){let n=this.pos;switch(e){case W.Varint:for(;this.buf[this.pos++]&128;);break;case W.Bit64:this.pos+=4;case W.Bit32:this.pos+=4;break;case W.LengthDelimited:let r=this.uint32();this.pos+=r;break;case W.StartGroup:for(;;){let[o,s]=this.tag();if(s===W.EndGroup){if(t!==void 0&&o!==t)throw new Error("invalid end group tag");break}this.skip(s,o)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return k.dec(...this.varint64())}uint64(){return k.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,k.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return k.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return k.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.decodeUtf8(this.bytes())}}});var qe=L(()=>{"use strict"});var Ke=L(()=>{"use strict"});var Ge=L(()=>{"use strict"});var He=L(()=>{"use strict";je();qe();Ie();Ke();Ge()});function Pt(){return{propertyId:new Uint8Array(0),pageviewId:new Uint8Array(0),sessionId:new Uint8Array(0),pageUrl:"",country:"",region:"",deviceType:"",userId:new Uint8Array(0),domain:"",events:[],browser:"",deviceManufacturer:"",deviceModel:"",city:"",postalCode:""}}function Ft(){return{timestampMs:0,type:0,eventName:"",auctionId:new Uint8Array(0),transactionId:new Uint8Array(0),adUnitCode:"",bid:void 0,namespace:"",eventId:new Uint8Array(0),metadata:{},viewableDurationMs:void 0,bidderOutcomes:[]}}function Vt(){return{key:"",value:""}}function $t(){return{adUnitCode:"",outcome:0,bid:void 0,refreshIndex:0,floorCents:void 0,floorSource:0,floorTreatmentBp:void 0}}function Wt(){return{bidder:"",cpm:0,currency:"",width:0,height:0,dealId:"",mediaType:"",latencyMs:0,advertiserDomain:"",creativeId:""}}var b,F,oe,Ee,Ye,ze,Xe,re,Te=L(()=>{"use strict";He();b={TRACE_EVENT_TYPE_UNSPECIFIED:0,AUCTION_START:1,AUCTION_END:2,BID_WIN:4,IMPRESSION:5,VIEWABLE:6,TIME_IN_VIEW:7,ERROR:9,SLOT_DEFINED:10,SLOT_DESTROYED:11,CLICK:12,AD_RENDER_FAILED:13,WARN:17,UNRECOGNIZED:-1},F={BIDDER_OUTCOME_UNSPECIFIED:0,BIDDER_OUTCOME_BID:1,BIDDER_OUTCOME_NO_BID:2,BIDDER_OUTCOME_TIMEOUT:3,BIDDER_OUTCOME_ERROR:4,BIDDER_OUTCOME_NO_RESPONSE:5,UNRECOGNIZED:-1},oe={FLOOR_SOURCE_UNSPECIFIED:0,FLOOR_SOURCE_STATIC:1,FLOOR_SOURCE_POOL:2,FLOOR_SOURCE_NONE:3,UNRECOGNIZED:-1};Ee={encode(i,e=new j){if(i.propertyId!==void 0&&i.propertyId.length!==0&&e.uint32(10).bytes(i.propertyId),i.pageviewId!==void 0&&i.pageviewId.length!==0&&e.uint32(18).bytes(i.pageviewId),i.sessionId!==void 0&&i.sessionId.length!==0&&e.uint32(26).bytes(i.sessionId),i.pageUrl!==void 0&&i.pageUrl!==""&&e.uint32(34).string(i.pageUrl),i.country!==void 0&&i.country!==""&&e.uint32(42).string(i.country),i.region!==void 0&&i.region!==""&&e.uint32(50).string(i.region),i.deviceType!==void 0&&i.deviceType!==""&&e.uint32(58).string(i.deviceType),i.userId!==void 0&&i.userId.length!==0&&e.uint32(66).bytes(i.userId),i.domain!==void 0&&i.domain!==""&&e.uint32(74).string(i.domain),i.events!==void 0&&i.events.length!==0)for(let t of i.events)Ye.encode(t,e.uint32(82).fork()).join();return i.browser!==void 0&&i.browser!==""&&e.uint32(90).string(i.browser),i.deviceManufacturer!==void 0&&i.deviceManufacturer!==""&&e.uint32(98).string(i.deviceManufacturer),i.deviceModel!==void 0&&i.deviceModel!==""&&e.uint32(106).string(i.deviceModel),i.city!==void 0&&i.city!==""&&e.uint32(114).string(i.city),i.postalCode!==void 0&&i.postalCode!==""&&e.uint32(122).string(i.postalCode),e},decode(i,e){let t=i instanceof O?i:new O(i),n=e===void 0?t.len:t.pos+e,r=Pt();for(;t.pos<n;){let o=t.uint32();switch(o>>>3){case 1:{if(o!==10)break;r.propertyId=t.bytes();continue}case 2:{if(o!==18)break;r.pageviewId=t.bytes();continue}case 3:{if(o!==26)break;r.sessionId=t.bytes();continue}case 4:{if(o!==34)break;r.pageUrl=t.string();continue}case 5:{if(o!==42)break;r.country=t.string();continue}case 6:{if(o!==50)break;r.region=t.string();continue}case 7:{if(o!==58)break;r.deviceType=t.string();continue}case 8:{if(o!==66)break;r.userId=t.bytes();continue}case 9:{if(o!==74)break;r.domain=t.string();continue}case 10:{if(o!==82)break;let s=Ye.decode(t,t.uint32());s!==void 0&&r.events.push(s);continue}case 11:{if(o!==90)break;r.browser=t.string();continue}case 12:{if(o!==98)break;r.deviceManufacturer=t.string();continue}case 13:{if(o!==106)break;r.deviceModel=t.string();continue}case 14:{if(o!==114)break;r.city=t.string();continue}case 15:{if(o!==122)break;r.postalCode=t.string();continue}}if((o&7)===4||o===0)break;t.skip(o&7)}return r}};Ye={encode(i,e=new j){if(i.timestampMs!==void 0&&i.timestampMs!==0&&e.uint32(9).double(i.timestampMs),i.type!==void 0&&i.type!==0&&e.uint32(16).int32(i.type),i.eventName!==void 0&&i.eventName!==""&&e.uint32(26).string(i.eventName),i.auctionId!==void 0&&i.auctionId.length!==0&&e.uint32(34).bytes(i.auctionId),i.transactionId!==void 0&&i.transactionId.length!==0&&e.uint32(42).bytes(i.transactionId),i.adUnitCode!==void 0&&i.adUnitCode!==""&&e.uint32(50).string(i.adUnitCode),i.bid!==void 0&&re.encode(i.bid,e.uint32(58).fork()).join(),i.namespace!==void 0&&i.namespace!==""&&e.uint32(66).string(i.namespace),i.eventId!==void 0&&i.eventId.length!==0&&e.uint32(74).bytes(i.eventId),globalThis.Object.entries(i.metadata||{}).forEach(([t,n])=>{ze.encode({key:t,value:n},e.uint32(82).fork()).join()}),i.viewableDurationMs!==void 0&&e.uint32(89).double(i.viewableDurationMs),i.bidderOutcomes!==void 0&&i.bidderOutcomes.length!==0)for(let t of i.bidderOutcomes)Xe.encode(t,e.uint32(98).fork()).join();return e},decode(i,e){let t=i instanceof O?i:new O(i),n=e===void 0?t.len:t.pos+e,r=Ft();for(;t.pos<n;){let o=t.uint32();switch(o>>>3){case 1:{if(o!==9)break;r.timestampMs=t.double();continue}case 2:{if(o!==16)break;r.type=t.int32();continue}case 3:{if(o!==26)break;r.eventName=t.string();continue}case 4:{if(o!==34)break;r.auctionId=t.bytes();continue}case 5:{if(o!==42)break;r.transactionId=t.bytes();continue}case 6:{if(o!==50)break;r.adUnitCode=t.string();continue}case 7:{if(o!==58)break;r.bid=re.decode(t,t.uint32());continue}case 8:{if(o!==66)break;r.namespace=t.string();continue}case 9:{if(o!==74)break;r.eventId=t.bytes();continue}case 10:{if(o!==82)break;let s=ze.decode(t,t.uint32());s.value!==void 0&&(r.metadata[s.key]=s.value);continue}case 11:{if(o!==89)break;r.viewableDurationMs=t.double();continue}case 12:{if(o!==98)break;let s=Xe.decode(t,t.uint32());s!==void 0&&r.bidderOutcomes.push(s);continue}}if((o&7)===4||o===0)break;t.skip(o&7)}return r}};ze={encode(i,e=new j){return i.key!==""&&e.uint32(10).string(i.key),i.value!==""&&e.uint32(18).string(i.value),e},decode(i,e){let t=i instanceof O?i:new O(i),n=e===void 0?t.len:t.pos+e,r=Vt();for(;t.pos<n;){let o=t.uint32();switch(o>>>3){case 1:{if(o!==10)break;r.key=t.string();continue}case 2:{if(o!==18)break;r.value=t.string();continue}}if((o&7)===4||o===0)break;t.skip(o&7)}return r}};Xe={encode(i,e=new j){return i.adUnitCode!==void 0&&i.adUnitCode!==""&&e.uint32(18).string(i.adUnitCode),i.outcome!==void 0&&i.outcome!==0&&e.uint32(32).int32(i.outcome),i.bid!==void 0&&re.encode(i.bid,e.uint32(50).fork()).join(),i.refreshIndex!==void 0&&i.refreshIndex!==0&&e.uint32(56).int32(i.refreshIndex),i.floorCents!==void 0&&e.uint32(64).int32(i.floorCents),i.floorSource!==void 0&&i.floorSource!==0&&e.uint32(72).int32(i.floorSource),i.floorTreatmentBp!==void 0&&e.uint32(80).int32(i.floorTreatmentBp),e},decode(i,e){let t=i instanceof O?i:new O(i),n=e===void 0?t.len:t.pos+e,r=$t();for(;t.pos<n;){let o=t.uint32();switch(o>>>3){case 2:{if(o!==18)break;r.adUnitCode=t.string();continue}case 4:{if(o!==32)break;r.outcome=t.int32();continue}case 6:{if(o!==50)break;r.bid=re.decode(t,t.uint32());continue}case 7:{if(o!==56)break;r.refreshIndex=t.int32();continue}case 8:{if(o!==64)break;r.floorCents=t.int32();continue}case 9:{if(o!==72)break;r.floorSource=t.int32();continue}case 10:{if(o!==80)break;r.floorTreatmentBp=t.int32();continue}}if((o&7)===4||o===0)break;t.skip(o&7)}return r}};re={encode(i,e=new j){return i.bidder!==void 0&&i.bidder!==""&&e.uint32(10).string(i.bidder),i.cpm!==void 0&&i.cpm!==0&&e.uint32(17).double(i.cpm),i.currency!==void 0&&i.currency!==""&&e.uint32(26).string(i.currency),i.width!==void 0&&i.width!==0&&e.uint32(32).int32(i.width),i.height!==void 0&&i.height!==0&&e.uint32(40).int32(i.height),i.dealId!==void 0&&i.dealId!==""&&e.uint32(50).string(i.dealId),i.mediaType!==void 0&&i.mediaType!==""&&e.uint32(58).string(i.mediaType),i.latencyMs!==void 0&&i.latencyMs!==0&&e.uint32(65).double(i.latencyMs),i.advertiserDomain!==void 0&&i.advertiserDomain!==""&&e.uint32(74).string(i.advertiserDomain),i.creativeId!==void 0&&i.creativeId!==""&&e.uint32(82).string(i.creativeId),e},decode(i,e){let t=i instanceof O?i:new O(i),n=e===void 0?t.len:t.pos+e,r=Wt();for(;t.pos<n;){let o=t.uint32();switch(o>>>3){case 1:{if(o!==10)break;r.bidder=t.string();continue}case 2:{if(o!==17)break;r.cpm=t.double();continue}case 3:{if(o!==26)break;r.currency=t.string();continue}case 4:{if(o!==32)break;r.width=t.int32();continue}case 5:{if(o!==40)break;r.height=t.int32();continue}case 6:{if(o!==50)break;r.dealId=t.string();continue}case 7:{if(o!==58)break;r.mediaType=t.string();continue}case 8:{if(o!==65)break;r.latencyMs=t.double();continue}case 9:{if(o!==74)break;r.advertiserDomain=t.string();continue}case 10:{if(o!==82)break;r.creativeId=t.string();continue}}if((o&7)===4||o===0)break;t.skip(o&7)}return r}}});function q(i){if(!i)return new Uint8Array(0);if(jt.test(i)){let t=i.replace(/-/g,""),n=new Uint8Array(16);for(let r=0;r<16;r++)n[r]=parseInt(t.slice(r*2,r*2+2),16);return n}if(Ze)return Ze.encode(i);let e=new Uint8Array(i.length);for(let t=0;t<i.length;t++)e[t]=i.charCodeAt(t)&255;return e}var jt,Ze,Yn,Je=L(()=>{"use strict";jt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,Ze=typeof TextEncoder<"u"?new TextEncoder:null,Yn=typeof TextDecoder<"u"?new TextDecoder:null});function X(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{let e=Math.random()*16|0;return(i==="x"?e:e&3|8).toString(16)})}function cn(i){let e="";for(let n=0;n<i.length;n+=8192)e+=String.fromCharCode(...i.subarray(n,n+8192));return btoa(e)}function ln(i){let e=atob(i),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function un(i){if(!i)return!1;let e;try{e=new URL(i)}catch{return!1}return e.username||e.password?!1:e.protocol==="https:"?!0:e.protocol==="http:"?e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname==="[::1]":!1}function fn(i){let e={},t=0;for(let n of Object.keys(i)){if(t>=Ht)break;let r=i[n];if(r==null)continue;let o=String(r);e[n]=o.length>tt?`${o.slice(0,tt)}...[truncated]`:o,t++}return e}function hn(i){let e=i.slice(se.length).split("_");return e.length===2&&/^\d+$/.test(e[0])}function pn(i,e){if(!i||!e)return!1;try{return new URL(i).origin===new URL(e).origin}catch{return!1}}function dt(i){try{typeof localStorage<"u"&&(localStorage.setItem(ot,i.toString()),z=i)}catch{}}function at(i=Date.now()){return V>0&&i-V<=st}function de(){let i=Date.now(),e=!!x&&!at(i);if(V=i,e){x=null;for(let t of bn)t();return}!Z||!x||z===0||i-z<gn||dt(i)}function mn(){return!x||Z&&z===0}function In(){if(rt||typeof window>"u")return;rt=!0;let i=()=>de();for(let e of yn)window.addEventListener(e,i,{passive:!0,capture:!0});typeof document<"u"&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&de()})}function Ae(){let i=Date.now(),e=!!x&&at(i);try{if(Z&&typeof localStorage<"u"){let t=localStorage.getItem(it),n=localStorage.getItem(ot),r=n&&parseInt(n,10)||0;if(t&&r&&i-r<=st)return(x!==t||V<r)&&(x=t,V=Math.max(V,r)),z===0&&(z=r),t;let o=e?x:X();return e||(V=i),localStorage.setItem(it,o),dt(V),x=o,o}}catch{}return e||(x=X(),V=i),x}function l(i){return String(i??"").replace(/%/g,"%25").replace(/:/g,"%3A")}function vn(i,e){switch(i){case"auctionInit":return`auctionInit:${l(e?.auctionId)}`;case"auctionEnd":return`auctionEnd:${l(e?.auctionId)}`;case"bidRequested":{let t=Array.isArray(e?.bids)?e.bids.map(n=>l(n?.bidId||n?.transactionId||n?.adUnitCode)).join(","):"";return`bidRequested:${l(e?.auctionId)}:${l(e?.bidderCode||e?.bidder)}:${t}`}case"bidResponse":{let t=e||{},n=t.creativeId||t.adId||t.requestId||t.bidId||"",r=t.originalCpm??t.cpm??"";return`bidResponse:${l(t.auctionId)}:${l(t.adUnitCode)}:${l(t.bidderCode||t.bidder)}:${l(n)}:${l(r)}`}case"bidTimeout":return"bidTimeout:"+(Array.isArray(e)?e:e?[e]:[]).map(n=>`${l(n?.auctionId)}:${l(n?.bidderCode||n?.bidder)}:${l(n?.bidId||n?.transactionId||n?.adUnitCode)}`).join(",");case"bidWon":{let t=e||{},n=t.creativeId||t.adId||t.requestId||t.bidId||"",r=t.originalCpm??t.cpm??"";return`bidWon:${l(t.auctionId)}:${l(t.adUnitCode)}:${l(t.bidderCode||t.bidder)}:${l(n)}:${l(r)}`}case"noBid":return`noBid:${l(e?.auctionId)}:${l(e?.adUnitCode)}:${l(e?.bidderCode||e?.bidder)}:${l(e?.bidId||e?.transactionId)}`;case"adRenderFailed":{let t=e?.bid||{};return`adRenderFailed:${l(t.auctionId||e?.auctionId)}:${l(t.adUnitCode||e?.adUnitCode)}:${l(t.bidderCode||t.bidder||e?.bidderCode||e?.bidder)}:${l(e?.reason)}:${l(e?.message)}`}case"adRenderSucceeded":{let t=e?.bid||e||{},n=t.creativeId||t.adId||e?.adId||"",r=t.originalCpm??t.cpm??"";return`adRenderSucceeded:${l(t.auctionId||e?.auctionId)}:${l(t.adUnitCode||e?.adUnitCode)}:${l(t.bidderCode||t.bidder)}:${l(n)}:${l(r)}`}case"setTargeting":return`setTargeting:${Object.keys(e||{}).sort().map(l).join(",")}`;case"auctionDebug":return`auctionDebug:${l(e?.type)}:${l(String(e?.arguments?.[0]??"").slice(0,50))}`;default:return""}}function K(i){if(Number.isFinite(i?.width)&&Number.isFinite(i?.height))return{width:i.width,height:i.height};if(typeof i?.size=="string"){let e=i.size.match(/^(\d+)x(\d+)$/);if(e)return{width:Number(e[1]),height:Number(e[2])}}return{width:Number.isFinite(i?.width)?i.width:0,height:Number.isFinite(i?.height)?i.height:0}}function Q(i,e=!0){if(!i)return null;if(Array.isArray(i)){let t=i.find(n=>n?.provider==="bidkernel")??(e?i.find(n=>n&&typeof n=="object"&&n.provider===void 0):void 0);return t?Q(t,e):null}if(typeof i=="object"){if(i.options&&typeof i.options=="object")return i.options;if(i.config&&typeof i.config=="object")return i.config;if(i.propertyId||i.endpoint)return i}return null}function En(i){if(!i)return null;if(i._bidkernelAnalyticsConfig){let e=Q(i._bidkernelAnalyticsConfig);if(e)return e}if(i.bidkernelPrebidAnalytics){let e=i.bidkernelPrebidAnalytics;if(e.options){let t=Q(e.options);if(t)return t}if(e.config){let t=Q(e.config);if(t)return t}if(e.propertyId)return Q(e)}return null}function _e(i="pbjs",e){let t=typeof window<"u"?window:{};t[i]=t[i]||{};let n=t[i],r=s=>{let d=t._bidkernelPrebidAnalytics,a=d?.getEndpoint?.()||"",u={pbjsGlobalName:i,...e,...s};if(a&&!pn(u.endpoint||"",a)&&(Y.warn(`Ignoring analytics endpoint change to ${u.endpoint||"(empty)"}: this page is pinned to ${a}. Reload to change the ingest endpoint.`),u.endpoint=a),d)try{d.disable()}catch(I){Y.warn("Failed to disable previous analytics instance:",I)}let c=new S(u);return c.enable(),t._bidkernelPrebidAnalytics=c,c},o=()=>{try{n.adapterManager&&typeof n.adapterManager.registerAnalyticsAdapter=="function"&&n.adapterManager.registerAnalyticsAdapter({adapter:{enableAnalytics:d=>{let a=Q(d,!Array.isArray(d));a&&r(a)},disableAnalytics:()=>{t._bidkernelPrebidAnalytics&&t._bidkernelPrebidAnalytics.disable()}},code:"bidkernel"});let s=En(t);s&&(s.propertyId||e?.propertyId)&&r(s)}catch(s){Y.warn("Failed to register standard Prebid analytics adapter:",s)}};n.adapterManager&&typeof n.adapterManager.registerAnalyticsAdapter=="function"?o():(n.que=n.que||[],n.que.push(o))}var et,qt,ee,Kt,Gt,we,tt,Ht,nt,se,Yt,zt,Xt,Qt,Zt,Jt,en,tn,G,nn,rn,on,sn,dn,an,it,ot,st,x,V,Z,gn,z,yn,rt,bn,Ce,Y,S,Se=L(()=>{"use strict";De();Te();Je();et=1e4,qt=50,ee=200,Kt=300*1e3,Gt=10,we=32*1024,tt=1024,Ht=16,nt="text/plain",se="_bidkernel_pending_",Yt=20,zt=7200*1e3,Xt=1e4,Qt={auctionStart:b.AUCTION_START,auctionEnd:b.AUCTION_END,bidWin:b.BID_WIN,adRenderFailed:b.AD_RENDER_FAILED,click:b.CLICK,impression:b.IMPRESSION,timeInView:b.TIME_IN_VIEW,viewable:b.VIEWABLE},Zt={WARN:b.WARN,ERROR:b.ERROR},Jt=new Set([b.ERROR,b.WARN]),en=3e3,tn=new Set([b.IMPRESSION,b.BID_WIN,b.CLICK]),G=1800*1e3,nn=200,rn=1e3,on=50,sn=200,dn={static:oe.FLOOR_SOURCE_STATIC,pool:oe.FLOOR_SOURCE_POOL,none:oe.FLOOR_SOURCE_NONE},an=1e3,it="_bidkernel_session",ot="_bidkernel_session_ts",st=1800*1e3,x=null,V=0,Z=!0;gn=60*1e3,z=0,yn=["pointerdown","pointermove","keydown","scroll","wheel","touchstart"],rt=!1,bn=new Set;Ce=class{seenObjects=new WeakMap;seenKeys=new Set;isDuplicate(e,t){if(!t)return!1;if(typeof t=="object"){let r=this.seenObjects.get(t);if(r){if(r.has(e))return!0;r.add(e)}else this.seenObjects.set(t,new Set([e]))}let n=vn(e,t);if(n){if(this.seenKeys.has(n))return!0;if(this.seenKeys.size>=1e3){let r=this.seenKeys.values().next().value;r!==void 0&&this.seenKeys.delete(r)}this.seenKeys.add(n)}return!1}};Y=ue({prefix:"[analytics]",logLevel:"INFO"}),S=class i{static activeInstances=new Set;static allInstances=new Set;static getActiveInstances(){return i.activeInstances}static setLogLevel(e){let t=P(e);Y.setLevel(t);for(let n of i.allInstances)n.setLogLevel(t)}static getLogLevel(){return Y.getLevel()}static setStorageAllowed(e){Z=e,z=0}static isStorageAllowed(){return Z}config;queue=[];errorCount=0;flushTimer=null;boundFlushBeacon;boundVisibilityChange;isEnabled=!1;boundPbjsHandlers=[];pageUrl="";deduper=new Ce;consecutiveSendFailures=0;nextSendAllowedAt=0;replayedEventCount=0;revenueFlushTimer=null;persistedBatchKeys=[];persistedCleanupTimer=null;intersectionObserver=null;slotViewabilityRecords=new Map;elementToSlotId=new Map;slotRefreshIndices=new Map;slotAdSessionCounters=new Map;slotLastAuctionIds=new Map;pendingThresholdListeners=new Map;pendingViewableListeners=new Map;slotElements=new Map;clickDetachCleanups=new Set;lastClickAt=new Map;slotEmittedImpressionKeys=new Set;cachedWinningBids=new Map;videoDetachCleanups=new Set;auctionBidderOutcomes=new Map;floorDecisions=new Map;logger;managesSessionId;constructor(e){e.storageAllowed!==void 0&&i.setStorageAllowed(e.storageAllowed);let t=e.endpoint||"",n=!t||un(t)?t:"";this.config={endpoint:n,propertyId:e.propertyId||"",pageviewId:e.pageviewId||X(),sessionId:e.sessionId||"",userId:e.userId||"",deviceType:e.deviceType||"desktop",country:e.country||"",region:e.region||"",auctionEnabled:e.auctionEnabled??!0,warningsEnabled:e.warningsEnabled??!0,errorsEnabled:e.errorsEnabled??!0,viewabilityEnabled:e.viewabilityEnabled??!0,storageAllowed:e.storageAllowed??!0,logLevel:e.logLevel?P(e.logLevel):Y.getLevel(),pbjsGlobalName:e.pbjsGlobalName||"pbjs",attachPbjsListeners:e.attachPbjsListeners??!0,revenueFlushDelayMs:Number.isFinite(e.revenueFlushDelayMs)&&e.revenueFlushDelayMs>=0?e.revenueFlushDelayMs:en},i.allInstances.add(this),this.logger=ue({prefix:"[analytics]",logLevel:this.config.logLevel}),de(),this.managesSessionId=!e.sessionId,this.managesSessionId&&(this.config.sessionId=Ae()),t&&!n&&this.log("ERROR",`Rejected untrusted analytics endpoint ${t}: must be an absolute https:// URL without embedded credentials. Events will not be transmitted.`),this.boundFlushBeacon=()=>{this.flushAllSlotsTimeInView(),this.flushBeacon()},this.boundVisibilityChange=()=>this.handleVisibilityChange()}setLogLevel(e){let t=P(e);this.config.logLevel=t,this.logger.setLevel(t),Y.setLevel(t)}getLogLevel(){return this.logger.getLevel()}enable(){if(!this.isEnabled){if(this.isEnabled=!0,i.activeInstances.add(this),this.logger.setLevel(this.config.logLevel),this.config.endpoint||this.log("WARN","Endpoint is empty. Analytics events will not be transmitted."),this.config.viewabilityEnabled&&typeof IntersectionObserver<"u"){this.intersectionObserver=new IntersectionObserver(this.handleIntersection.bind(this),{threshold:[.5]});for(let e of this.slotViewabilityRecords.values())e.element&&this.intersectionObserver.observe(e.element)}if(this.config.attachPbjsListeners&&this.attachPbjs(),typeof window<"u"){if(!this.pageUrl)try{let e=new URL(window.location.href);this.pageUrl=e.origin+e.pathname}catch{this.pageUrl=window.location.href}window.addEventListener("pagehide",this.boundFlushBeacon),typeof document<"u"&&document.addEventListener("visibilitychange",this.boundVisibilityChange),In(),this.flushTimer=setInterval(()=>this.flush(),et),this.resendPersistedBatches()}}}attachPbjs(){if(!this.isEnabled)return!1;if(this.boundPbjsHandlers.length>0)return!0;let t=(typeof window<"u"?window:{})[this.config.pbjsGlobalName]||{};if(typeof t.onEvent!="function")return this.log("WARN","pbjs.onEvent is not defined. Prebid analytics will not function."),!1;this.log("DEBUG","Attaching event listeners to pbjs");let n={auctionInit:this.handleAuctionInit.bind(this),auctionEnd:this.handleAuctionEnd.bind(this),bidRequested:this.handleBidRequested.bind(this),bidResponse:this.handleBidResponse.bind(this),bidTimeout:this.handleBidTimeout.bind(this),bidWon:this.handleBidWon.bind(this),noBid:this.handleNoBid.bind(this),adRenderFailed:this.handleAdRenderFailed.bind(this),adRenderSucceeded:this.handleAdRenderSucceeded.bind(this)};for(let[r,o]of Object.entries(n))t.onEvent(r,o),this.boundPbjsHandlers.push({event:r,handler:o});if(typeof t.getEvents=="function")try{let r=t.getEvents();if(Array.isArray(r)){let o=r.slice(this.replayedEventCount);if(this.replayedEventCount=r.length,o.length>0){this.log("DEBUG",`Replaying ${o.length} historical events from pbjs.getEvents()`);for(let s of o){if(!s)continue;let d=s.eventType||s.event||s.name,a=s.args!==void 0?s.args:s.data!==void 0?s.data:s,u=n[d];u&&u(a)}}}}catch(r){this.log("WARN","Failed to replay historical events from pbjs.getEvents()",r)}return!0}disable(){if(this.isEnabled){this.flushAllSlotsTimeInView(),this.isEnabled=!1,i.activeInstances.delete(this);for(let e of this.slotViewabilityRecords.values()){e.dwellTimer&&(clearTimeout(e.dwellTimer),e.dwellTimer=null,e.dwellStartedAt=null);for(let t of e.thresholdListeners)t.timer&&(clearTimeout(t.timer),t.timer=null)}this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.slotViewabilityRecords.clear(),this.elementToSlotId.clear();for(let e of this.videoDetachCleanups)try{e()}catch{}this.videoDetachCleanups.clear();for(let e of Array.from(this.clickDetachCleanups))try{e()}catch{}if(this.clickDetachCleanups.clear(),this.slotElements.clear(),this.cachedWinningBids.clear(),this.slotEmittedImpressionKeys.clear(),this.slotLastAuctionIds.clear(),this.auctionBidderOutcomes.clear(),this.floorDecisions.clear(),this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),this.revenueFlushTimer&&(clearTimeout(this.revenueFlushTimer),this.revenueFlushTimer=null),this.persistedCleanupTimer&&(clearTimeout(this.persistedCleanupTimer),this.persistedCleanupTimer=null),typeof window<"u"&&(window.removeEventListener("pagehide",this.boundFlushBeacon),typeof document<"u"&&document.removeEventListener("visibilitychange",this.boundVisibilityChange)),this.boundPbjsHandlers.length>0){let t=(typeof window<"u"?window:{})[this.config.pbjsGlobalName]||{};if(typeof t.offEvent=="function")for(let{event:n,handler:r}of this.boundPbjsHandlers)t.offEvent(n,r);this.boundPbjsHandlers=[]}this.flush()}}handleVisibilityChange(){if(!(typeof document>"u")){if(document.visibilityState==="hidden"){let e=typeof performance<"u"&&performance.now?performance.now():Date.now();for(let t of this.slotViewabilityRecords.values()){t.inView&&t.lastEnteredViewAt!==null&&(t.accumulatedTimeInViewMs+=Math.max(0,e-t.lastEnteredViewAt),t.lastEnteredViewAt=null,this.checkThresholdListeners(t)),t.dwellTimer&&(clearTimeout(t.dwellTimer),t.dwellTimer=null,t.dwellStartedAt=null);for(let r of t.thresholdListeners)r.timer&&(clearTimeout(r.timer),r.timer=null);let n=Math.round(t.accumulatedTimeInViewMs);n>0&&this.enqueue(b.TIME_IN_VIEW,"timeInView",{auctionId:t.auctionId,transactionId:t.transactionId,adUnitCode:t.adUnitCode,viewableDurationMs:n,bid:t.bidPayload,metadata:{...t.metadata,refresh_index:String(t.refreshIndex)}})}this.flushBeacon()}else if(document.visibilityState==="visible"){let e=typeof performance<"u"&&performance.now?performance.now():Date.now();for(let t of this.slotViewabilityRecords.values())if(t.inView){if(t.lastEnteredViewAt=e,!t.viewableFired&&t.dwellTimer===null){let n=t.mediaType==="video"?2e3:1e3;t.dwellStartedAt=e,t.dwellTimer=setTimeout(()=>{this.handleDwellComplete(t)},n)}this.scheduleThresholdTimers(t)}}}}handleIntersection(e){for(let t of e){let n=this.elementToSlotId.get(t.target);if(!n){for(let a of i.activeInstances)if(a!==this&&a.elementToSlotId.has(t.target)){a.handleIntersection([t]);break}continue}let r=this.slotViewabilityRecords.get(n);if(!r)continue;let o=t.isIntersecting&&(t.intersectionRatio===void 0||t.intersectionRatio>=.5),s=typeof document>"u"||document.visibilityState==="visible",d=typeof performance<"u"&&performance.now?performance.now():Date.now();if(o){if(!r.inView&&(r.inView=!0,s)){if(r.lastEnteredViewAt=d,!r.viewableFired&&r.dwellTimer===null){let a=r.mediaType==="video"?2e3:1e3;r.dwellStartedAt=d,r.dwellTimer=setTimeout(()=>{this.handleDwellComplete(r)},a)}this.scheduleThresholdTimers(r)}}else{r.inView&&(r.lastEnteredViewAt!==null&&(r.accumulatedTimeInViewMs+=Math.max(0,d-r.lastEnteredViewAt),r.lastEnteredViewAt=null),r.inView=!1,this.checkThresholdListeners(r)),r.dwellTimer!==null&&(clearTimeout(r.dwellTimer),r.dwellTimer=null,r.dwellStartedAt=null);for(let a of r.thresholdListeners)a.timer&&(clearTimeout(a.timer),a.timer=null)}}}handleDwellComplete(e){e.dwellTimer=null,e.dwellStartedAt=null,e.inView&&(typeof document<"u"&&document.visibilityState==="hidden"||(e.viewableFired||(e.viewableFired=!0,this.enqueue(b.VIEWABLE,"viewable",{auctionId:e.auctionId,transactionId:e.transactionId,adUnitCode:e.adUnitCode,bid:e.bidPayload,metadata:{...e.metadata,refresh_index:String(e.refreshIndex)}})),this.notifyViewable(e)))}notifyViewable(e){if(e.viewableFired){for(let t of e.viewableListeners)if(t.firedForIndex!==e.refreshIndex){t.firedForIndex=e.refreshIndex;try{t.callback(e.slotId)}catch(n){this.log("ERROR","Error in viewable listener callback",n)}}}}setSlotElement(e,t){this.slotElements.set(e,t);let n=this.slotViewabilityRecords.get(e);n&&n.element!==t&&this.observeSlot(t,e,{refreshIndex:n.refreshIndex})}recordClick(e,t){if(!this.isEnabled||!e)return!1;let n=Date.now();if(n-(this.lastClickAt.get(e)||0)<an)return!1;this.lastClickAt.set(e,n);let r=this.getCachedBid(e);return this.enqueue(b.CLICK,"click",{auctionId:r?.auctionId||"",transactionId:r?.transactionId||"",adUnitCode:e,bid:r?.bidTrace,metadata:{...t?.metadata,refresh_index:String(this.getRefreshIndex(e))}}),!0}attachClickTracker(e,t){if(typeof window>"u")return()=>{};let n=()=>{setTimeout(()=>{let o=document.activeElement;o&&(o===e||e.contains(o))&&(this.recordClick(t,{metadata:{source:"blur"}}),window.focus())},0)};window.addEventListener("blur",n);let r=()=>{window.removeEventListener("blur",n),this.clickDetachCleanups.delete(r)};return this.clickDetachCleanups.add(r),r}onViewable(e,t){let n={callback:t,firedForIndex:-1},r=this.slotViewabilityRecords.get(e);return r?(r.viewableListeners.add(n),this.notifyViewable(r)):(this.pendingViewableListeners.has(e)||this.pendingViewableListeners.set(e,new Set),this.pendingViewableListeners.get(e).add(n)),()=>{this.slotViewabilityRecords.get(e)?.viewableListeners.delete(n),this.pendingViewableListeners.get(e)?.delete(n)}}scheduleThresholdTimers(e){if(!e.inView||typeof document<"u"&&document.visibilityState==="hidden")return;let t=this.getCurrentTimeInView(e);for(let n of e.thresholdListeners)if(!n.fired)if(t>=n.thresholdMs){n.fired=!0,n.timer&&(clearTimeout(n.timer),n.timer=null);try{n.callback(e.slotId,t)}catch(r){this.log("ERROR","Error in threshold listener callback",r)}}else{n.timer&&clearTimeout(n.timer);let r=n.thresholdMs-t;n.timer=setTimeout(()=>{if(n.timer=null,!n.fired&&e.inView&&(typeof document>"u"||document.visibilityState==="visible")){let o=this.getCurrentTimeInView(e);if(o>=n.thresholdMs){n.fired=!0;try{n.callback(e.slotId,o)}catch(s){this.log("ERROR","Error in threshold listener callback",s)}}}},r)}}checkThresholdListeners(e){let t=this.getCurrentTimeInView(e);for(let n of e.thresholdListeners)if(!n.fired&&t>=n.thresholdMs){n.fired=!0,n.timer&&(clearTimeout(n.timer),n.timer=null);try{n.callback(e.slotId,t)}catch(r){this.log("ERROR","Error in threshold listener callback",r)}}}getCurrentTimeInView(e){let t=e.accumulatedTimeInViewMs;if(e.inView&&e.lastEnteredViewAt!==null){let n=typeof performance<"u"&&performance.now?performance.now():Date.now();t+=Math.max(0,n-e.lastEnteredViewAt)}return t}flushSlotTimeInView(e){let t=this.slotViewabilityRecords.get(e);if(!t)return;if(t.inView&&t.lastEnteredViewAt!==null){let r=typeof performance<"u"&&performance.now?performance.now():Date.now();t.accumulatedTimeInViewMs+=Math.max(0,r-t.lastEnteredViewAt),t.lastEnteredViewAt=null}let n=Math.round(t.accumulatedTimeInViewMs);n>0&&this.enqueue(b.TIME_IN_VIEW,"timeInView",{auctionId:t.auctionId,transactionId:t.transactionId,adUnitCode:t.adUnitCode,viewableDurationMs:n,bid:t.bidPayload,metadata:{...t.metadata,refresh_index:String(t.refreshIndex)}}),t.accumulatedTimeInViewMs=0}flushAllSlotsTimeInView(){for(let e of Array.from(this.slotViewabilityRecords.keys()))this.flushSlotTimeInView(e)}observeSlot(e,t,n){if(!this.config.viewabilityEnabled)return;let r=null;if(typeof e=="string"){if(typeof document<"u"){try{r=document.querySelector(e)||document.getElementById(e)}catch{r=document.getElementById(e)}r||(r=document.getElementById(e))}}else r=e;let o=t||n?.adUnitCode||(r?r.id:"")||X(),s=this.slotViewabilityRecords.get(o);if(s){if(n?.refreshIndex===void 0||n.refreshIndex>s.refreshIndex){this.flushSlotTimeInView(o);let a=n?.refreshIndex!==void 0?n.refreshIndex:(this.slotRefreshIndices.get(o)??s.refreshIndex)+1;this.slotRefreshIndices.set(o,a),s.dwellTimer&&(clearTimeout(s.dwellTimer),s.dwellTimer=null,s.dwellStartedAt=null);for(let c of s.thresholdListeners)c.fired=!1,c.timer&&(clearTimeout(c.timer),c.timer=null);s.viewableFired=!1,s.accumulatedTimeInViewMs=0;let u=typeof performance<"u"&&performance.now?performance.now():Date.now();if(s.lastEnteredViewAt=s.inView?u:null,s.refreshIndex=a,s.auctionId=n?.auctionId||s.auctionId,s.transactionId=n?.transactionId||s.transactionId,s.mediaType=n?.mediaType||s.mediaType||"banner",s.bidPayload=n?.bid!==void 0?n.bid:s.bidPayload,s.metadata=n?.metadata??s.metadata,s.inView&&(typeof document>"u"||document.visibilityState==="visible")){let c=s.mediaType==="video"?2e3:1e3;s.dwellStartedAt=u,s.dwellTimer=setTimeout(()=>{this.handleDwellComplete(s)},c),this.scheduleThresholdTimers(s)}}else s.auctionId=n?.auctionId||s.auctionId,s.transactionId=n?.transactionId||s.transactionId,s.mediaType=n?.mediaType||s.mediaType,n?.bid!==void 0&&(s.bidPayload=n.bid),n?.metadata!==void 0&&(s.metadata=n.metadata);n?.auctionId&&this.slotLastAuctionIds.set(o,n.auctionId),r&&(s.element&&s.element!==r&&this.intersectionObserver&&(this.intersectionObserver.unobserve(s.element),this.elementToSlotId.delete(s.element)),s.element=r,this.elementToSlotId.set(r,o),this.intersectionObserver?.observe(r))}else{let d=n?.refreshIndex??this.slotRefreshIndices.get(o)??0;this.slotRefreshIndices.set(o,d),n?.auctionId&&this.slotLastAuctionIds.set(o,n.auctionId);let a=this.pendingThresholdListeners.get(o)||new Set;this.pendingThresholdListeners.delete(o);let u=this.pendingViewableListeners.get(o)||new Set;this.pendingViewableListeners.delete(o);let c={slotId:o,element:r,adUnitCode:n?.adUnitCode||o,auctionId:n?.auctionId||"",transactionId:n?.transactionId||"",mediaType:n?.mediaType||"banner",bidPayload:n?.bid,metadata:n?.metadata,refreshIndex:d,inView:!1,lastEnteredViewAt:null,accumulatedTimeInViewMs:0,viewableFired:!1,dwellTimer:null,dwellStartedAt:null,thresholdListeners:a,viewableListeners:u};this.slotViewabilityRecords.set(o,c),r&&(this.elementToSlotId.set(r,o),this.intersectionObserver?.observe(r))}}unobserveSlot(e){let t=this.slotViewabilityRecords.get(e);if(t){this.flushSlotTimeInView(e),t.dwellTimer&&(clearTimeout(t.dwellTimer),t.dwellTimer=null,t.dwellStartedAt=null);for(let n of t.thresholdListeners)n.timer&&(clearTimeout(n.timer),n.timer=null);t.thresholdListeners=new Set,t.viewableListeners=new Set,t.element&&this.intersectionObserver&&(this.intersectionObserver.unobserve(t.element),this.elementToSlotId.delete(t.element),t.element=null),t.inView=!1,t.lastEnteredViewAt=null}}destroySlot(e){this.unobserveSlot(e),this.slotViewabilityRecords.delete(e),this.slotRefreshIndices.delete(e),this.slotAdSessionCounters.delete(e),this.slotLastAuctionIds.delete(e),this.pendingThresholdListeners.delete(e),this.pendingViewableListeners.delete(e);let t=`${l(e)}:`;for(let r of Array.from(this.slotEmittedImpressionKeys))(r===e||r.startsWith(t))&&this.slotEmittedImpressionKeys.delete(r);let n=this.cachedWinningBids.get(e);n&&this.deleteCachedBidEntry(n)}getCachedBid(e){let t=this.cachedWinningBids.get(e);if(t){if(Date.now()-t.timestamp>G){this.deleteCachedBidEntry(t);return}return t}}deleteCachedBidEntry(e){for(let[t,n]of Array.from(this.cachedWinningBids))n===e&&this.cachedWinningBids.delete(t)}pruneCachedWinningBids(){let e=Date.now();for(let[t,n]of Array.from(this.cachedWinningBids))e-n.timestamp>G&&this.cachedWinningBids.delete(t);for(;this.cachedWinningBids.size>nn;){let t=this.cachedWinningBids.keys().next();if(t.done)break;this.cachedWinningBids.delete(t.value)}}addImpressionKey(e){if(!this.slotEmittedImpressionKeys.has(e)){for(;this.slotEmittedImpressionKeys.size>=rn;){let t=this.slotEmittedImpressionKeys.values().next();if(t.done)break;this.slotEmittedImpressionKeys.delete(t.value)}this.slotEmittedImpressionKeys.add(e)}}getOrCreateAuctionOutcomes(e){let t=this.auctionBidderOutcomes.get(e);for(t||(t=new Map,this.auctionBidderOutcomes.set(e,t));this.auctionBidderOutcomes.size>on;){let n=this.auctionBidderOutcomes.keys().next();if(n.done||n.value===e)break;this.auctionBidderOutcomes.delete(n.value)}return t}nextSlotAdSession(e){let t=(this.slotAdSessionCounters.get(e)??0)+1;return this.slotAdSessionCounters.set(e,t),`ad-session-${t}`}hasImpressionEmitted(e,t,n,r,o){let s=t??this.slotRefreshIndices.get(e)??0,d=`${l(e)}:${s}`;if(o){if(n){if(this.slotEmittedImpressionKeys.has(`${d}:auc:${l(n)}:ad:${l(o)}`)||this.slotEmittedImpressionKeys.has(`${d}:ad:${l(o)}`))return!0}else if(this.slotEmittedImpressionKeys.has(`${d}:ad:${l(o)}`))return!0;if(r&&r!==o){if(n){if(this.slotEmittedImpressionKeys.has(`${d}:auc:${l(n)}:${l(r)}`)||this.slotEmittedImpressionKeys.has(`${d}:${l(r)}`))return!0}else if(this.slotEmittedImpressionKeys.has(`${d}:${l(r)}`))return!0}return!1}return r?n?this.slotEmittedImpressionKeys.has(`${d}:auc:${l(n)}:${l(r)}`)||this.slotEmittedImpressionKeys.has(`${d}:${l(r)}`):this.slotEmittedImpressionKeys.has(`${d}:${l(r)}`):n?this.slotEmittedImpressionKeys.has(`${d}:auc:${l(n)}`):this.slotEmittedImpressionKeys.has(d)}markImpressionEmitted(e,t,n,r,o){let s=`${l(e)}:${t}`;!!(o||r)?(o&&(this.addImpressionKey(`${s}:ad:${l(o)}`),n&&this.addImpressionKey(`${s}:auc:${l(n)}:ad:${l(o)}`)),r&&r!==o&&(this.addImpressionKey(`${s}:${l(r)}`),n&&this.addImpressionKey(`${s}:auc:${l(n)}:${l(r)}`)),n&&this.addImpressionKey(`${s}:auc:${l(n)}`)):(this.addImpressionKey(s),n&&this.addImpressionKey(`${s}:auc:${l(n)}`))}recordImpression(e,t){if(!this.isEnabled)return!1;let n=e||t?.adUnitCode||"",r=t?.adUnitCode||n,o=(t?.auctionId&&n?this.getCachedBid(`${t.auctionId}:${n}`):void 0)||(t?.auctionId&&r?this.getCachedBid(`${t.auctionId}:${r}`):void 0)||(n?this.getCachedBid(n):void 0)||(r?this.getCachedBid(r):void 0),s=t?.bid||o?.rawBid||{},d=t?.auctionId||s.auctionId||o?.auctionId||"",a=t?.transactionId||s.transactionId||o?.transactionId||"",u=s.creativeId||o?.bidTrace?.creativeId||t?.bid?.creativeId||"",c=t?.adId||s.adId||t?.bid?.adId||"",I=t?.mediaType||s.mediaType||o?.bidTrace?.mediaType||"banner",g=n||r,f=(n?this.slotViewabilityRecords.get(n):void 0)||(r?this.slotViewabilityRecords.get(r):void 0),R=g?this.slotLastAuctionIds.get(g)||(f?f.auctionId:void 0):void 0,y=!!(g&&d&&R&&R!==d&&t?.refreshIndex===void 0),_={bidder:s.bidderCode||s.bidder||o?.bidTrace?.bidder||"",cpm:Number.isFinite(s.originalCpm)?s.originalCpm:Number.isFinite(s.cpm)?s.cpm:o?.bidTrace?.cpm??0,currency:s.originalCurrency??s.currency??o?.bidTrace?.currency??"USD",...K(s).width?K(s):o?.bidTrace?{width:o.bidTrace.width,height:o.bidTrace.height}:K(s),dealId:s.dealId||o?.bidTrace?.dealId||"",mediaType:I,latencyMs:Number.isFinite(s.timeToRespond)?s.timeToRespond:o?.bidTrace?.latencyMs??0,advertiserDomain:s.meta?.advertiserDomains?.[0]||o?.bidTrace?.advertiserDomain||"",creativeId:s.creativeId||o?.bidTrace?.creativeId||""};if(y&&g){this.flushSlotTimeInView(g);let v=(this.slotRefreshIndices.get(g)??(f?f.refreshIndex:0))+1;this.slotRefreshIndices.set(g,v),this.slotLastAuctionIds.set(g,d),f&&(f.refreshIndex=v,f.auctionId=d,f.transactionId=a,f.bidPayload=_,f.viewableFired=!1,f.accumulatedTimeInViewMs=0)}else g&&(d&&this.slotLastAuctionIds.set(g,d),this.slotRefreshIndices.has(g)||this.slotRefreshIndices.set(g,0));let B=t?.refreshIndex??(n?this.slotRefreshIndices.get(n)??(r?this.slotRefreshIndices.get(r):void 0)??(f?f.refreshIndex:0):0);return n&&this.hasImpressionEmitted(n,B,d,u,c)||r&&r!==n&&this.hasImpressionEmitted(r,B,d,u,c)?(this.log("DEBUG",`Impression already emitted for slot ${n||r} in cycle ${B}`),!1):(n&&this.markImpressionEmitted(n,B,d,u,c),r&&r!==n&&this.markImpressionEmitted(r,B,d,u,c),this.enqueue(b.IMPRESSION,"impression",{auctionId:d,transactionId:a,adUnitCode:r,bid:_,metadata:{...t?.metadata,refresh_index:String(B)}}),f&&(!f.bidPayload&&_&&(f.bidPayload=_),!f.auctionId&&d&&(f.auctionId=d),!f.transactionId&&a&&(f.transactionId=a)),!0)}onTimeInViewThreshold(e,t,n){let r={thresholdMs:t,callback:n,timer:null,fired:!1},o=this.slotViewabilityRecords.get(e);if(o){o.thresholdListeners.add(r);let s=this.getCurrentTimeInView(o);if(s>=t){r.fired=!0;try{n(e,s)}catch(d){this.log("ERROR","Error in threshold callback",d)}}else if(o.inView&&(typeof document>"u"||document.visibilityState==="visible")){let d=t-s;r.timer=setTimeout(()=>{if(r.timer=null,!r.fired&&o.inView&&(typeof document>"u"||document.visibilityState==="visible")){let a=this.getCurrentTimeInView(o);if(a>=t){r.fired=!0;try{n(e,a)}catch(u){this.log("ERROR","Error in threshold callback",u)}}}},d)}}else this.pendingThresholdListeners.has(e)||this.pendingThresholdListeners.set(e,new Set),this.pendingThresholdListeners.get(e).add(r);return()=>{r.timer&&(clearTimeout(r.timer),r.timer=null),o&&o.thresholdListeners.delete(r);let s=this.pendingThresholdListeners.get(e);s&&s.delete(r)}}getViewabilityState(e){let t=this.slotViewabilityRecords.get(e);if(!t)return;let n=Math.round(this.getCurrentTimeInView(t));return{inView:t.inView,viewable:t.viewableFired,timeInViewMs:n,refreshIndex:t.refreshIndex}}getEndpoint(){return this.config.endpoint}getRefreshIndex(e){return this.slotRefreshIndices.get(e)??0}triggerSlotRefresh(e,t){let n=this.slotViewabilityRecords.get(e);n&&n.element&&this.observeSlot(n.element,e,t)}trackRawEvent(e,t,n){let r=Zt[e]??Qt[t];r!==void 0&&this.enqueue(r,t,n)}recordFloorDecision(e,t,n){if(!e||!t)return;let r=`${e}:${t}`;for(this.floorDecisions.delete(r),this.floorDecisions.set(r,{floorCents:n.floorCents!==void 0&&Number.isFinite(n.floorCents)?Math.round(n.floorCents):void 0,source:n.source,treatment:Number.isFinite(n.treatment)?n.treatment:1});this.floorDecisions.size>sn;){let o=this.floorDecisions.keys().next();if(o.done)break;this.floorDecisions.delete(o.value)}}floorDecisionFor(e,t){return e&&t?this.floorDecisions.get(`${e}:${t}`):void 0}setUserId(e){this.config.userId=e}setSessionId(e){this.config.sessionId=e,this.managesSessionId=!e,this.managesSessionId&&(this.config.sessionId=Ae())}navigate(e,t){if(this.disable(),this.slotRefreshIndices.clear(),this.slotAdSessionCounters.clear(),this.floorDecisions.clear(),this.pendingThresholdListeners.clear(),this.config.pageviewId=e||X(),t)try{let n=new URL(t);this.pageUrl=n.origin+n.pathname}catch{this.pageUrl=t}else this.pageUrl="";this.logger.resetTiming(),de(),this.enable()}handleAuctionInit(e){if(this.isDuplicate("auctionInit",e))return;this.log("DEBUG","auctionInit",e);let t=e.auctionId||"";t&&(this.auctionBidderOutcomes.delete(t),this.getOrCreateAuctionOutcomes(t)),this.enqueue(b.AUCTION_START,"auctionStart",{auctionId:t,transactionId:e.transactionId||""})}handleAuctionEnd(e){if(this.isDuplicate("auctionEnd",e))return;this.log("DEBUG","auctionEnd",e);let t=e.auctionId||"",n=t?this.auctionBidderOutcomes.get(t):void 0,r=n?Array.from(n.values()):[];t&&this.auctionBidderOutcomes.delete(t),this.enqueue(b.AUCTION_END,"auctionEnd",{auctionId:t,transactionId:e.transactionId||"",bidderOutcomes:r})}auctionCycleIndex(e){if(!e)return 0;let t=this.slotRefreshIndices.get(e)??this.slotViewabilityRecords.get(e)?.refreshIndex;return t===void 0?0:t+1}handleBidRequested(e){if(this.isDuplicate("bidRequested",e))return;this.log("DEBUG","bidRequested",e);let t=e.auctionId||"",n=e.bidderCode||e.bidder||"";if(!t||!n)return;let r=this.getOrCreateAuctionOutcomes(t);Array.isArray(e.bids)&&e.bids.forEach(o=>{let s=o.adUnitCode||"",d=Object.keys(o.mediaTypes||{}),a=d.length>0?d[0]:o.mediaType||"banner",u=`${n}:${s}`;r.has(u)||r.set(u,{adUnitCode:s,outcome:F.BIDDER_OUTCOME_NO_RESPONSE,bid:{bidder:n,mediaType:a,latencyMs:0}})})}handleBidResponse(e){if(this.isDuplicate("bidResponse",e))return;this.log("DEBUG","bidResponse",e);let t=e.auctionId||"",n=e.bidderCode||e.bidder||"",r=e.adUnitCode||"",o=Number.isFinite(e.originalCpm)?e.originalCpm:Number.isFinite(e.cpm)?e.cpm:0,s=Number.isFinite(e.timeToRespond)?e.timeToRespond:0,d=Object.keys(e.mediaTypes||{}),a=e.mediaType||(e.mediaTypes?.video?"video":d.length>0?d[0]:"banner");if(!t||!n)return;let u=o>0?{bidder:n,cpm:o,currency:e.originalCurrency??e.currency??"USD",...K(e),dealId:e.dealId||"",mediaType:a,latencyMs:s,advertiserDomain:e.meta?.advertiserDomains?.[0]||"",creativeId:e.creativeId||""}:{bidder:n,mediaType:a,latencyMs:s};this.getOrCreateAuctionOutcomes(t).set(`${n}:${r}`,{adUnitCode:r,outcome:o>0?F.BIDDER_OUTCOME_BID:F.BIDDER_OUTCOME_NO_BID,bid:u})}handleBidTimeout(e){if(this.isDuplicate("bidTimeout",e))return;this.log("DEBUG","bidTimeout",e);let t=Array.isArray(e)?e:e?[e]:[];for(let n of t){let r=n.auctionId||"",o=n.bidderCode||n.bidder||"",s=n.adUnitCode||"",d=Number.isFinite(n.timeout)?n.timeout:0;if(r&&o){let a=this.getOrCreateAuctionOutcomes(r),u=`${o}:${s}`,c=a.get(u);c?(c.outcome=F.BIDDER_OUTCOME_TIMEOUT,d>0&&c.bid&&(c.bid.latencyMs=d)):a.set(u,{adUnitCode:s,outcome:F.BIDDER_OUTCOME_TIMEOUT,bid:{bidder:o,mediaType:"banner",latencyMs:d}})}}}handleBidWon(e){if(this.isDuplicate("bidWon",e))return;this.log("DEBUG","bidWon",e);let t=e.auctionId||"",n=e.transactionId||"",r=e.adUnitCode||e.adId||"",o=Object.keys(e.mediaTypes||{}),s=e.mediaType||(e.mediaTypes?.video?"video":o.length>0?o[0]:"banner"),d={bidder:e.bidderCode||e.bidder||"",cpm:Number.isFinite(e.originalCpm)?e.originalCpm:Number.isFinite(e.cpm)?e.cpm:0,currency:e.originalCurrency??e.currency??"USD",...K(e),dealId:e.dealId||"",mediaType:s,latencyMs:Number.isFinite(e.timeToRespond)?e.timeToRespond:0,advertiserDomain:e.meta?.advertiserDomains?.[0]||"",creativeId:e.creativeId||""};if(r){let a={bidTrace:d,auctionId:t,transactionId:n,adUnitCode:r,rawBid:e,timestamp:Date.now()};this.cachedWinningBids.set(r,a),e.adId&&e.adId!==r&&this.cachedWinningBids.set(e.adId,a),t&&(this.cachedWinningBids.set(`${t}:${r}`,a),e.adId&&e.adId!==r&&this.cachedWinningBids.set(`${t}:${e.adId}`,a)),this.pruneCachedWinningBids()}this.enqueue(b.BID_WIN,"bidWon",{auctionId:t,transactionId:n,adUnitCode:r,bid:d})}handleNoBid(e){if(this.isDuplicate("noBid",e))return;this.log("DEBUG","noBid",e);let t=e.auctionId||"",n=e.bidderCode||e.bidder||"",r=e.adUnitCode||"";if(t&&n){let o=this.getOrCreateAuctionOutcomes(t),s=`${n}:${r}`,d=o.get(s);d?d.outcome===F.BIDDER_OUTCOME_NO_RESPONSE&&(d.outcome=F.BIDDER_OUTCOME_NO_BID):o.set(s,{adUnitCode:r,outcome:F.BIDDER_OUTCOME_NO_BID,bid:{bidder:n,mediaType:"banner",latencyMs:0}})}}handleAdRenderFailed(e){if(this.isDuplicate("adRenderFailed",e))return;this.log("DEBUG","adRenderFailed",e);let t=e.bid||{};this.enqueue(b.AD_RENDER_FAILED,"adRenderFailed",{auctionId:t.auctionId||e.auctionId||"",transactionId:t.transactionId||e.transactionId||"",adUnitCode:t.adUnitCode||e.adUnitCode||"",bid:{bidder:t.bidderCode||t.bidder||e.bidderCode||e.bidder||""},metadata:{reason:String(e.reason||""),message:String(e.message||e.error?.message||"")},error:e.error||(e.message?new Error(String(e.message)):void 0)})}handleAdRenderSucceeded(e){if(this.isDuplicate("adRenderSucceeded",e))return;this.log("DEBUG","adRenderSucceeded",e);let t=e.bid||e||{},n=e.adUnitCode||t.adUnitCode||e.adId||t.adId||"",r=t.auctionId||e.auctionId||"",o=t.transactionId||e.transactionId||"",s=t.mediaType||"banner",d=e.adUnitCode||t.adUnitCode||"",a=e.adId||t.adId||"",u=(r&&d?this.getCachedBid(`${r}:${d}`):void 0)||(r&&a?this.getCachedBid(`${r}:${a}`):void 0)||(d?this.getCachedBid(d):void 0)||(a?this.getCachedBid(a):void 0),c=s==="video"||t.mediaType==="video"||t.mediaTypes?.video!==void 0||u?.bidTrace?.mediaType==="video"||u?.rawBid?.mediaType==="video"||n&&this.slotViewabilityRecords.get(n)?.mediaType==="video",I=c?"video":s||u?.bidTrace?.mediaType||"banner",g={bidder:t.bidderCode||t.bidder||u?.bidTrace?.bidder||"",cpm:Number.isFinite(t.originalCpm)?t.originalCpm:Number.isFinite(t.cpm)?t.cpm:u?.bidTrace?.cpm??0,currency:t.originalCurrency??t.currency??u?.bidTrace?.currency??"USD",...K(t).width?K(t):u?.bidTrace?{width:u.bidTrace.width,height:u.bidTrace.height}:K(t),dealId:t.dealId||u?.bidTrace?.dealId||"",mediaType:I,latencyMs:Number.isFinite(t.timeToRespond)?t.timeToRespond:u?.bidTrace?.latencyMs??0,advertiserDomain:t.meta?.advertiserDomains?.[0]||u?.bidTrace?.advertiserDomain||"",creativeId:t.creativeId||u?.bidTrace?.creativeId||""},f=r||u?.auctionId||"",R=o||u?.transactionId||"",y=n?this.slotViewabilityRecords.get(n):void 0,_=y&&f&&y.auctionId&&y.auctionId!==f;if(!!(n&&y&&_)){this.flushSlotTimeInView(n);let v=(this.slotRefreshIndices.get(n)??(y?y.refreshIndex:0))+1;this.slotRefreshIndices.set(n,v),this.slotLastAuctionIds.set(n,f),y&&(y.refreshIndex=v,y.auctionId=f,y.transactionId=R,y.bidPayload=g,y.viewableFired=!1,y.accumulatedTimeInViewMs=0)}else n&&(f&&this.slotLastAuctionIds.set(n,f),this.slotRefreshIndices.has(n)||this.slotRefreshIndices.set(n,0));let U=n?this.slotRefreshIndices.get(n)??(y?y.refreshIndex:0):0;if(c?this.log("DEBUG",`adRenderSucceeded received for video ad unit ${n||"unknown"}: suppressing IMPRESSION until verified video lifecycle event`):n&&this.hasImpressionEmitted(n,U,f,g.creativeId)||(n&&this.markImpressionEmitted(n,U,f,g.creativeId),this.enqueue(b.IMPRESSION,"impression",{auctionId:f,transactionId:R,adUnitCode:n,bid:g,metadata:{refresh_index:String(U)}})),this.config.viewabilityEnabled&&typeof document<"u"){let v=n&&this.slotElements.get(n)||null,T=n||e.adId||t.adId;if(!v&&T&&(v=document.getElementById(T)),!v&&typeof window<"u"&&window.googletag?.pubads)try{let M=window.googletag.pubads().getSlots();for(let m of M)if((m.getAdUnitPath?.()===n||m.getSlotElementId?.()===n)&&(v=document.getElementById(m.getSlotElementId()),v))break}catch{}if(!v&&T)try{for(let M of Array.from(document.querySelectorAll("[data-ad-slot]")))if(M.getAttribute("data-ad-slot")===T){v=M;break}}catch{}v&&this.observeSlot(v,n||T,{adUnitCode:n,auctionId:f,transactionId:R,mediaType:I,bid:g,refreshIndex:U})}}isDuplicate(e,t){return this.deduper.isDuplicate(e,t)}enqueue(e,t,n){if(!this.isEnabled||!this.shouldSample(e))return;this.managesSessionId&&mn()&&(this.config.sessionId=Ae());let r={eventId:q(X()),timestampMs:Date.now(),type:e,eventName:Jt.has(e)?t:"",auctionId:q(String(n.auctionId||"")),transactionId:q(String(n.transactionId||"")),adUnitCode:n.adUnitCode||n.elementId||"",namespace:n.ns||n.namespace||""};n.bid&&(r.bid={bidder:n.bid.bidder||"",cpm:Number.isFinite(n.bid.cpm)?n.bid.cpm:0,currency:n.bid.currency||"",width:Number.isFinite(n.bid.width)?n.bid.width:0,height:Number.isFinite(n.bid.height)?n.bid.height:0,dealId:n.bid.dealId||"",mediaType:n.bid.mediaType||"",latencyMs:Number.isFinite(n.bid.latencyMs)?n.bid.latencyMs:0,advertiserDomain:n.bid.advertiserDomain||"",creativeId:n.bid.creativeId||""}),n.viewableDurationMs!==void 0&&(r.viewableDurationMs=Number.isFinite(n.viewableDurationMs)?n.viewableDurationMs:0),n.bidderOutcomes&&Array.isArray(n.bidderOutcomes)&&(r.bidderOutcomes=n.bidderOutcomes.map(d=>{let a=this.floorDecisionFor(String(n.auctionId||""),d.adUnitCode||"");return{...d,refreshIndex:d.refreshIndex??this.auctionCycleIndex(d.adUnitCode||""),...a?{floorCents:a.floorCents,floorSource:dn[a.source],floorTreatmentBp:Math.round(a.treatment*1e4)}:{}}}));let o={...n.metadata};if(e===b.BID_WIN||e===b.IMPRESSION){let d=this.floorDecisionFor(String(n.auctionId||""),r.adUnitCode||"");d&&(d.floorCents!==void 0&&(o.floor_cents=String(d.floorCents)),o.floor_source=d.source,o.floor_treatment=d.treatment.toFixed(2))}n.error!==void 0&&n.error!==null&&(o.error=typeof n.error=="object"&&n.error.message?String(n.error.message):String(n.error)),n.gpid&&(o.gpid=String(n.gpid)),n.refreshIndex!==void 0&&o.refresh_index===void 0&&(o.refresh_index=String(n.refreshIndex));let s=fn(o);Object.keys(s).length>0&&(r.metadata=s),this.queue.push(r),this.queue.length>=ee?(this.flush(),this.queue.length>ee&&this.queue.splice(0,this.queue.length-ee)):tn.has(e)&&this.revenueFlushTimer===null&&(this.revenueFlushTimer=setTimeout(()=>{this.revenueFlushTimer=null,this.flush()},this.config.revenueFlushDelayMs))}shouldSample(e){return e===b.ERROR?(this.errorCount++,this.errorCount<=qt):e===b.WARN?this.config.warningsEnabled:this.config.auctionEnabled}requeue(e){e.length&&(this.queue=e.concat(this.queue),this.queue.length>ee&&this.queue.splice(0,this.queue.length-ee))}drainBatch(){if(this.queue.length===0||!this.config.endpoint)return null;let e=typeof window<"u"?window.location.hostname:"",t=n=>({propertyId:q(this.config.propertyId),pageviewId:q(this.config.pageviewId),sessionId:q(this.config.sessionId),pageUrl:this.pageUrl,country:this.config.country,region:this.config.region,deviceType:this.config.deviceType,userId:q(this.config.userId),domain:e,events:n});for(;;){if(this.queue.length===0)return null;let n=this.queue,r=Ee.encode(t(n)).finish();for(;n.length>1&&r.byteLength>we;)n=n.slice(0,Math.floor(n.length/2)),r=Ee.encode(t(n)).finish();if(r.byteLength>we){let[o]=this.queue.splice(0,1);this.log("WARN",`Dropping oversized event (type ${o?.type}, ${r.byteLength} bytes exceeds the ${we}-byte cap on its own)`);continue}return this.queue=this.queue.slice(n.length),{url:`${this.config.endpoint}/${this.config.propertyId}`,encoded:r,events:n}}}sendFetch(e,t=!1,n,r=!1){let o={method:"POST",headers:{"Content-Type":nt},body:e.encoded};t&&(o.keepalive=!0),fetch(e.url,o).then(d=>{if(d.ok)r||(this.consecutiveSendFailures=0,this.nextSendAllowedAt=0),n&&n();else{if(this.log("WARN",`Failed to send batch: HTTP ${d.status}`),d.status>=400&&d.status<500&&d.status!==429&&d.status!==408){this.log("WARN",`Dropping batch due to non-retryable client error HTTP ${d.status}`);return}r||this.handleSendFailure(e.events)}}).catch(d=>{this.log("ERROR","Failed to send batch",d),r||this.handleSendFailure(e.events)});let s=typeof globalThis<"u"?globalThis.process:void 0;if(s&&typeof s._tickCallback=="function")try{s._tickCallback()}catch{}}handleSendFailure(e){this.consecutiveSendFailures++;let t=Math.min(et*2**(this.consecutiveSendFailures-1),Kt);this.nextSendAllowedAt=Date.now()+t,this.consecutiveSendFailures<=Gt?this.requeue(e):this.log("WARN",`Dropping ${e.length} events after ${this.consecutiveSendFailures} consecutive send failures`)}flush(){if(Date.now()<this.nextSendAllowedAt)return;let e=this.drainBatch();for(;e&&(this.sendFetch(e,!1),!(Date.now()<this.nextSendAllowedAt));)e=this.drainBatch()}flushBeacon(){let e=this.drainBatch();for(;e;){let t=!1;if(typeof navigator<"u"&&typeof navigator.sendBeacon=="function")try{let n=new Blob([e.encoded],{type:nt});t=navigator.sendBeacon(e.url,n)}catch{t=!1}if(!t){let n=this.persistBatch(e.encoded);this.sendFetch(e,!0,()=>this.removePersistedBatch(n))}e=this.drainBatch()}this.schedulePersistedCleanup()}pendingKeyPrefix(){return`${se}${encodeURIComponent(this.config.propertyId)}_`}persistBatch(e){if(!Z)return null;try{if(typeof localStorage>"u"||!this.config.propertyId)return null;let t=0;for(let r=0;r<localStorage.length;r++){let o=localStorage.key(r);o&&o.startsWith(se)&&t++}if(t>=Yt)return null;let n=`${this.pendingKeyPrefix()}${Date.now()}_${Math.floor(Math.random()*1e6)}`;return localStorage.setItem(n,cn(e)),this.persistedBatchKeys.push(n),n}catch{return null}}removePersistedBatch(e){if(!e)return;try{typeof localStorage<"u"&&localStorage.removeItem(e)}catch{}let t=this.persistedBatchKeys.indexOf(e);t!==-1&&this.persistedBatchKeys.splice(t,1)}schedulePersistedCleanup(){this.persistedBatchKeys.length!==0&&(this.persistedCleanupTimer&&clearTimeout(this.persistedCleanupTimer),this.persistedCleanupTimer=setTimeout(()=>{this.persistedCleanupTimer=null;for(let e of Array.from(this.persistedBatchKeys))this.removePersistedBatch(e)},Xt))}resendPersistedBatches(){try{if(typeof localStorage>"u"||!this.config.endpoint||!this.config.propertyId)return;let e=this.pendingKeyPrefix(),t=[],n=[];for(let r=0;r<localStorage.length;r++){let o=localStorage.key(r);!o||!o.startsWith(se)||(o.startsWith(e)?t.push(o):hn(o)&&n.push(o))}for(let r of n)try{localStorage.removeItem(r)}catch{}for(let r of t){let o=null;try{o=localStorage.getItem(r),localStorage.removeItem(r)}catch{continue}if(!o)continue;let s=parseInt(r.slice(e.length),10);if(!Number.isFinite(s)||Date.now()-s>zt)continue;let d;try{d=ln(o)}catch{continue}d.byteLength!==0&&(this.log("DEBUG",`Resending persisted exit batch (${d.byteLength} bytes)`),this.sendFetch({url:`${this.config.endpoint}/${this.config.propertyId}`,encoded:d,events:[]},!1,void 0,!0))}}catch{}}log(e,t,...n){this.logger.log(e,t,...n)}}});function Tn(i){let e=typeof i?.getError=="function"?i.getError():i?.error||i,t=a=>e&&typeof e[a]=="function"?e[a]():void 0,n=t("getMessage")||e?.message||String(e||"IMA ad error"),r=t("getErrorCode")??e?.code,o=t("getVastErrorCode"),s=t("getType")??e?.type,d={message:n};return r&&(d.error_code=String(r)),o&&(d.vast_error_code=String(o)),s&&(d.error_type=String(s)),{err:e,message:n,metadata:d}}function ht(i,e,t){let n=ae(i),{err:r,message:o,metadata:s}=Tn(e);return n.log("WARN","IMA AdErrorEvent received",e),n.enqueue(b.AD_RENDER_FAILED,"adRenderFailed",{auctionId:t.auctionId,transactionId:t.transactionId,adUnitCode:t.adUnitCode,bid:t.bid,metadata:{...t.metadata,reason:t.adStarted?"ima_playback_error":"ima_ad_error",playback_phase:t.adStarted?"post_start":"pre_start",...s},error:typeof r=="object"?r:new Error(o)}),r}function wn(i,e){if(!i||typeof i!="object"||ct.has(i))return;ct.add(i);let t=typeof window<"u"&&window.google?.ima?.AdErrorEvent?.Type?.AD_ERROR||"adError";try{e.call(i,t,n=>{for(let r of S.getActiveInstances())try{let o=gt(r,{mediaType:"video"});ht(r,n,{adStarted:!1,adUnitCode:o?.adUnitCode||"video",auctionId:o?.auctionId,transactionId:o?.transactionId,bid:o?.bidTrace})}catch{}})}catch{}}function lt(i){if(i)try{let e=i.prototype;if(e&&typeof e.getAdsManager=="function"&&!e.getAdsManager.__bidkernelHooked){let t=e.getAdsManager,n=function(...r){let o=t.apply(this,r);if(o)for(let s of S.getActiveInstances())try{s.attachImaAdsManager(o)}catch{}return o};n.__bidkernelHooked=!0,e.getAdsManager=n}}catch{}}function ut(i){if(i)try{let e=i.prototype||i;if(e&&typeof e.init=="function"&&!e.init.__bidkernelHooked){let t=e.init,n=function(...r){for(let o of S.getActiveInstances())try{o.attachImaAdsManager(this)}catch{}return t.apply(this,r)};n.__bidkernelHooked=!0,e.init=n}if(e&&typeof e.start=="function"&&!e.start.__bidkernelHooked){let t=e.start,n=function(...r){for(let o of S.getActiveInstances())try{o.attachImaAdsManager(this)}catch{}return t.apply(this,r)};n.__bidkernelHooked=!0,e.start=n}}catch{}}function ft(i){if(i)try{let e=i.prototype;if(!e)return;if(typeof e.addEventListener=="function"&&!e.addEventListener.__bidkernelHooked){let t=e.addEventListener,n=function(r,o,...s){if(wn(this,t),(r==="adsManagerLoaded"||r===(this?.AdsManagerLoadedEvent?.Type?.ADS_MANAGER_LOADED||"adsManagerLoaded"))&&typeof o=="function"){let d=Re.get(o);return d||(d=function(a){if(a&&typeof a.getAdsManager=="function"&&!a.getAdsManager.__bidkernelHooked){let u=a.getAdsManager;a.getAdsManager=function(...c){let I=u.apply(this,c);if(I)for(let g of S.getActiveInstances())try{g.attachImaAdsManager(I)}catch{}return I},a.getAdsManager.__bidkernelHooked=!0}return o.apply(this,arguments)},Re.set(o,d)),t.call(this,r,d,...s)}return t.call(this,r,o,...s)};n.__bidkernelHooked=!0,e.addEventListener=n}if(typeof e.removeEventListener=="function"&&!e.removeEventListener.__bidkernelHooked){let t=e.removeEventListener,n=function(r,o,...s){let d=typeof o=="function"?Re.get(o):void 0;return t.call(this,r,d||o,...s)};n.__bidkernelHooked=!0,e.removeEventListener=n}}catch{}}function te(i){if(!(!i||typeof i!="object"))try{i.AdsManagerLoadedEvent&<(i.AdsManagerLoadedEvent);let e=Object.getOwnPropertyDescriptor(i,"AdsManagerLoadedEvent");if(!e||e.configurable){let r=i.AdsManagerLoadedEvent;try{Object.defineProperty(i,"AdsManagerLoadedEvent",{configurable:!0,enumerable:!0,get(){return r},set(o){r=o,lt(o)}})}catch{}}i.AdsLoader&&ft(i.AdsLoader);let t=Object.getOwnPropertyDescriptor(i,"AdsLoader");if(!t||t.configurable){let r=i.AdsLoader;try{Object.defineProperty(i,"AdsLoader",{configurable:!0,enumerable:!0,get(){return r},set(o){r=o,ft(o)}})}catch{}}i.AdsManager&&ut(i.AdsManager);let n=Object.getOwnPropertyDescriptor(i,"AdsManager");if(!n||n.configurable){let r=i.AdsManager;try{Object.defineProperty(i,"AdsManager",{configurable:!0,enumerable:!0,get(){return r},set(o){r=o,ut(o)}})}catch{}}}catch{}}function pt(){if(typeof window>"u")return;let i=window;if(i.google?.ima&&te(i.google.ima),i.google&&typeof i.google=="object"){let t=Object.getOwnPropertyDescriptor(i.google,"ima");if(!t||t.configurable){let n=i.google.ima;try{Object.defineProperty(i.google,"ima",{configurable:!0,enumerable:!0,get(){return n},set(r){n=r,te(r)}})}catch{}}}let e=Object.getOwnPropertyDescriptor(i,"google");if(!e||e.configurable){let t=i.google;try{Object.defineProperty(i,"google",{configurable:!0,enumerable:!0,get(){return t},set(n){if(t=n,t&&typeof t=="object"){t.ima&&te(t.ima);let r=Object.getOwnPropertyDescriptor(t,"ima");if(!r||r.configurable){let o=t.ima;try{Object.defineProperty(t,"ima",{configurable:!0,enumerable:!0,get(){return o},set(s){o=s,te(s)}})}catch{}}}}})}catch{}}}function gt(i,e){let t=ae(i),n=Date.now(),r=d=>t.hasImpressionEmitted(d.adUnitCode,void 0,d.auctionId,d.bidTrace.creativeId);if(e?.creativeId||e?.adId){for(let d of Array.from(t.cachedWinningBids.values()))if(!(n-d.timestamp>G)&&(e.creativeId&&(d.bidTrace.creativeId===e.creativeId||d.rawBid?.creativeId===e.creativeId)||e.adId&&(d.rawBid?.adId===e.adId||d.adUnitCode===e.adId)))return d}let o;if(e?.mediaType){for(let a of Array.from(t.cachedWinningBids.values())){if(n-a.timestamp>G)continue;(a.bidTrace.mediaType===e.mediaType||a.rawBid?.mediaType===e.mediaType||e.mediaType==="video"&&a.rawBid?.mediaTypes?.video!==void 0)&&(r(a)||(!o||a.timestamp<o.timestamp)&&(o=a))}if(o)return o;let d;for(let a of Array.from(t.cachedWinningBids.values())){if(n-a.timestamp>G)continue;(a.bidTrace.mediaType===e.mediaType||a.rawBid?.mediaType===e.mediaType||e.mediaType==="video"&&a.rawBid?.mediaTypes?.video!==void 0)&&(!d||a.timestamp>d.timestamp)&&(d=a)}if(d)return d}for(let d of Array.from(t.cachedWinningBids.values()))n-d.timestamp>G||r(d)||(!o||d.timestamp>o.timestamp)&&(o=d);if(o)return o;let s;for(let d of Array.from(t.cachedWinningBids.values()))n-d.timestamp>G||(!s||d.timestamp>s.timestamp)&&(s=d);return s}function yt(i,e,t){let n=ae(i);if(!e||typeof e.addEventListener!="function")return n.log("WARN","Invalid AdsManager passed to attachImaAdsManager"),()=>{};if(!e.__bidkernelAttachedInstances)try{Object.defineProperty(e,"__bidkernelAttachedInstances",{value:new Map,configurable:!0,writable:!0})}catch{e.__bidkernelAttachedInstances=new Map}let r=e.__bidkernelAttachedInstances,o=r.get(i);if(o){if(!t)return()=>{};o()}let s=t?.slotId||t?.adUnitCode||"video",d=t?.adUnitCode||s,a=t?.auctionId||"",u=t?.transactionId||"",c=p=>{let h=(a?n.getCachedBid(`${a}:${d}`):void 0)||(a&&s!==d?n.getCachedBid(`${a}:${s}`):void 0)||(d!=="video"?n.getCachedBid(d):void 0)||(s!==d&&s!=="video"?n.getCachedBid(s):void 0);return h||(h=gt(i,{creativeId:p?.creativeId,adId:p?.adId,mediaType:"video"})),h},I=!1,g=null,f=p=>{let h=typeof n.nextSlotAdSession=="function"?n.nextSlotAdSession(s):`ad-session-${(n.slotAdSessionCounters?.get(s)??0)+1}`;if(n.slotAdSessionCounters&&typeof n.nextSlotAdSession!="function"){let N=(n.slotAdSessionCounters.get(s)??0)+1;n.slotAdSessionCounters.set(s,N)}let E=(typeof p?.getAdId=="function"?p.getAdId():p?.adId??p?.id)||"",H=(typeof p?.getCreativeId=="function"?p.getCreativeId():p?.creativeId)||"";return g={sessionId:h,adId:E||void 0,creativeId:H||void 0},g},R=p=>{let h=typeof p?.getAd=="function"?p.getAd():p?.ad;f(h),n.log("DEBUG","IMA AdEvent.LOADED received",{slotId:s,activeAdSession:g})},y=p=>{I=!0;let h=typeof p?.getAd=="function"?p.getAd():p?.ad,E={};h&&(E.creativeId=(typeof h.getCreativeId=="function"?h.getCreativeId():h.creativeId)||"",E.adId=(typeof h.getAdId=="function"?h.getAdId():h.id)||"",E.title=(typeof h.getTitle=="function"?h.getTitle():h.title)||"",E.duration=typeof h.getDuration=="function"?h.getDuration():h.duration,E.advertiserName=typeof h.getAdvertiserName=="function"?h.getAdvertiserName():""),!g||E.adId&&g.adId&&g.adId!==E.adId?f(h):(!g.adId&&E.adId&&(g.adId=E.adId),!g.creativeId&&E.creativeId&&(g.creativeId=E.creativeId));let H=g||f(h),N=c(E),ce=t?.slotId&&t.slotId!=="video"?t.slotId:t?.adUnitCode&&t.adUnitCode!=="video"?t.adUnitCode:N?.adUnitCode||t?.slotId||t?.adUnitCode||"video",It=t?.adUnitCode&&t.adUnitCode!=="video"?t.adUnitCode:N?.adUnitCode||ce,vt=a||N?.auctionId||"",Et=u||N?.transactionId||"",Le=H.creativeId||E.creativeId||N?.bidTrace?.creativeId||t?.bid?.creativeId||"",Tt=H.adId||E.adId||Le||H.sessionId,Oe={...N?.rawBid||t?.bid,mediaType:"video",creativeId:Le},Be=n.recordImpression(ce,{adUnitCode:It,auctionId:vt,transactionId:Et,mediaType:"video",bid:Oe,adId:Tt,metadata:{...t?.metadata,media_type:"video",...E.title?{ad_title:E.title}:{},...Number.isFinite(E.duration)?{ad_duration_s:String(E.duration)}:{}}}),J=typeof p?.type=="string"?p.type:typeof p?.getType=="function"?p.getType():typeof p=="string"?p:"";J.toLowerCase().startsWith("adevent.")&&(J=J.slice(8));let wt=J?J.toUpperCase():"STARTED/IMPRESSION";if(n.log("DEBUG",`IMA AdEvent.${wt} received${Be?"":" (second event for this ad, already counted)"}`,p),Be&&t?.onImpression)try{t.onImpression(ce,{ad:h,bid:Oe})}catch(At){n.log("ERROR","Error in onImpression callback",At)}},_=p=>{if(n.log("DEBUG",`IMA AdEvent milestone: ${p}`),t?.onMilestone)try{t.onMilestone(p,s)}catch(h){n.log("ERROR","Error in onMilestone callback",h)}},B=p=>{n.log("DEBUG","IMA AdEvent.CLICK received",p);let h=c(),E=t?.adUnitCode&&t.adUnitCode!=="video"?t.adUnitCode:h?.adUnitCode||s;n.enqueue(b.CLICK,"click",{auctionId:a||h?.auctionId,transactionId:u||h?.transactionId,adUnitCode:E,bid:h?.bidTrace||t?.bid,metadata:{...t?.metadata,media_type:"video"}})},U=p=>{g=null;let h=c(),E=t?.adUnitCode&&t.adUnitCode!=="video"?t.adUnitCode:h?.adUnitCode||s,H=ht(i,p,{adStarted:I,adUnitCode:E,auctionId:a||h?.auctionId,transactionId:u||h?.transactionId,bid:h?.bidTrace||t?.bid,metadata:t?.metadata});if(t?.onError)try{t.onError(H)}catch(N){n.log("ERROR","Error in onError callback",N)}},v=typeof window<"u"?window.google?.ima:void 0,T=v?.AdEvent?.Type||{},M=v?.AdErrorEvent?.Type||{},m=[{type:T.LOADED||"loaded",handler:R},{type:T.STARTED||"started",handler:y},{type:T.IMPRESSION||"impression",handler:y},{type:T.FIRST_QUARTILE||"firstQuartile",handler:()=>_("firstQuartile")},{type:T.MIDPOINT||"midpoint",handler:()=>_("midpoint")},{type:T.THIRD_QUARTILE||"thirdQuartile",handler:()=>_("thirdQuartile")},{type:T.COMPLETE||"complete",handler:()=>{g=null,_("complete")}},{type:T.ALL_ADS_COMPLETED||"allAdsCompleted",handler:()=>{g=null}},{type:T.CLICK||"click",handler:B},{type:M.AD_ERROR||"adError",handler:U}],A=new Set,w=[];for(let p of m)A.has(p.type)||(A.add(p.type),w.push(p));for(let{type:p,handler:h}of w)try{e.addEventListener(p,h)}catch{}let D=()=>{g=null,r.delete(i);for(let{type:p,handler:h}of w)try{e.removeEventListener(p,h)}catch{}n.videoDetachCleanups.delete(D)};return r.set(i,D),n.videoDetachCleanups.add(D),D}function An(i,e,t){let n=ae(i);if(!e)return n.log("WARN","attachVideoPlayer called with null/undefined target"),()=>{};let r=null;if(typeof e=="string"){if(typeof document<"u")try{r=document.querySelector(e)||document.getElementById(e)}catch{r=document.getElementById(e)}}else if(typeof HTMLElement<"u"&&e instanceof HTMLElement)r=e;else if(e&&typeof e=="object"&&e.nodeType===1)r=e;else{if(typeof e.addEventListener=="function"&&(typeof e.init=="function"||typeof e.start=="function"||typeof e.getCuePoints=="function"||typeof e.getVolume=="function"||e.__imaAdsManager))return yt(i,e,t);e&&typeof e.addEventListener=="function"&&(r=e)}let o=t?.slotId||t?.adUnitCode||(r?r.id:"")||"video",s=t?.adUnitCode||o,d=t?.auctionId||"",a=t?.transactionId||"",u=()=>(d?n.getCachedBid(`${d}:${s}`):void 0)||(d&&o!==s?n.getCachedBid(`${d}:${o}`):void 0)||n.getCachedBid(s)||(o!==s?n.getCachedBid(o):void 0),c=null;r&&(r.tagName&&r.tagName.toLowerCase()==="video"?c=r:c=r.querySelector("video"));let I={q1:!1,q2:!1,q3:!1,q4:!1},g=m=>{let A=m||c||(r?.querySelector?r.querySelector("video"):null),w=u(),D={...w?.rawBid||t?.bid,mediaType:"video"};if(n.recordImpression(o,{adUnitCode:s,auctionId:d||w?.auctionId,transactionId:a||w?.transactionId,mediaType:"video",bid:D,metadata:{...t?.metadata,media_type:"video",...A&&Number.isFinite(A.duration)?{video_duration_s:String(Math.round(A.duration))}:{}}})&&t?.onImpression)try{t.onImpression(o,{element:A||r,bid:D})}catch(h){n.log("ERROR","Error in onImpression callback",h)}},f=m=>{n.log("DEBUG","HTML5 video playing event received");let A=m?.target instanceof HTMLVideoElement?m.target:c;g(A)},R=m=>{let A=m?.target instanceof HTMLVideoElement?m.target:c;if(A&&A.currentTime>0&&(g(A),Number.isFinite(A.duration)&&A.duration>0)){let w=A.currentTime/A.duration;w>=.25&&!I.q1&&(I.q1=!0,t?.onMilestone?.("firstQuartile",o)),w>=.5&&!I.q2&&(I.q2=!0,t?.onMilestone?.("midpoint",o)),w>=.75&&!I.q3&&(I.q3=!0,t?.onMilestone?.("thirdQuartile",o))}},y=()=>{I.q4||(I.q4=!0,t?.onMilestone?.("complete",o))},_=m=>{let w=(m?.target instanceof HTMLVideoElement?m.target:c)?.error||c?.error,D=u(),p=w?`HTML5 video error code ${w.code}: ${w.message}`:"Video playback error";if(n.log("WARN",p),n.enqueue(b.AD_RENDER_FAILED,"adRenderFailed",{auctionId:d||D?.auctionId,transactionId:a||D?.transactionId,adUnitCode:s,bid:D?.bidTrace||t?.bid,metadata:{...t?.metadata,reason:"html5_video_error",message:p,...w?.code?{error_code:String(w.code)}:{}},error:w?new Error(p):void 0}),t?.onError)try{t.onError(w)}catch(h){n.log("ERROR","Error in onError callback",h)}},B=m=>{m.addEventListener("playing",f),m.addEventListener("play",f),m.addEventListener("timeupdate",R),m.addEventListener("ended",y),m.addEventListener("error",_)},U=m=>{m.removeEventListener("playing",f),m.removeEventListener("play",f),m.removeEventListener("timeupdate",R),m.removeEventListener("ended",y),m.removeEventListener("error",_)},v=null;r&&r!==c&&(r.addEventListener("playing",f,!0),r.addEventListener("play",f,!0),r.addEventListener("timeupdate",R,!0),r.addEventListener("ended",y,!0),r.addEventListener("error",_,!0)),c&&B(c),r&&r.tagName?.toLowerCase()!=="video"&&typeof MutationObserver<"u"&&(v=new MutationObserver(()=>{let m=r.querySelector("video");m&&m!==c&&(c&&U(c),c=m,c&&B(c))}),v.observe(r,{childList:!0,subtree:!0}));let T=u();t?.trackViewability!==!1&&r&&n.observeSlot(r,o,{adUnitCode:s,auctionId:d||T?.auctionId,transactionId:a||T?.transactionId,mediaType:"video",bid:T?.bidTrace||t?.bid,metadata:t?.metadata});let M=()=>{v&&(v.disconnect(),v=null),r&&r!==c&&(r.removeEventListener("playing",f,!0),r.removeEventListener("play",f,!0),r.removeEventListener("timeupdate",R,!0),r.removeEventListener("ended",y,!0),r.removeEventListener("error",_,!0)),c&&U(c),n.videoDetachCleanups.delete(M)};return n.videoDetachCleanups.add(M),M}var ae,Re,ct,Cn,bt=L(()=>{"use strict";Se();Te();ae=i=>i,Re=new WeakMap,ct=new WeakSet;typeof window<"u"&&pt();S.prototype.attachImaAdsManager=function(i,e){return yt(this,i,e)};S.prototype.attachVideoPlayer=function(i,e){return An(this,i,e)};Cn=S.prototype.enable;S.prototype.enable=function(){Cn.call(this),typeof window<"u"&&(pt(),window.google?.ima&&te(window.google.ima))}});var Sn=Ct(()=>{Se();bt();var mt="https://by.bidkernel.io/t",_n=window._bidkernelPbjsGlobal||"pbjs";_e(_n,{endpoint:mt});window.bidkernelPrebidAnalytics={...window.bidkernelPrebidAnalytics,register:(i,e)=>_e(i,{endpoint:mt,...e}),attachVideoPlayer:(i,e)=>{let t=window._bidkernelPrebidAnalytics;return t?.attachVideoPlayer?t.attachVideoPlayer(i,e):()=>{}},attachImaAdsManager:(i,e)=>{let t=window._bidkernelPrebidAnalytics;return t?.attachImaAdsManager?t.attachImaAdsManager(i,e):()=>{}},recordImpression:(i,e)=>{let t=window._bidkernelPrebidAnalytics;return t?.recordImpression?t.recordImpression(i,e):!1},setLogLevel:i=>{S.setLogLevel(i)},getLogLevel:()=>S.getLogLevel()}});return Sn();})();
|
package/dist/index.d.mts
CHANGED
|
@@ -51,6 +51,13 @@ interface AnalyticsConfig {
|
|
|
51
51
|
region?: string;
|
|
52
52
|
auctionEnabled?: boolean;
|
|
53
53
|
warningsEnabled?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Compat: accepted and ignored. Errors are always collected -- see
|
|
56
|
+
* shouldSample() for why -- so this only ever legitimately held `true`, and
|
|
57
|
+
* honouring it meant a config that omitted it silently disabled error
|
|
58
|
+
* reporting. Kept so existing integrations still type-check; remove once no
|
|
59
|
+
* caller passes it (edge/src/sdk, edge/src/worker and the docs are clear).
|
|
60
|
+
*/
|
|
54
61
|
errorsEnabled?: boolean;
|
|
55
62
|
/** Whether to enable client-side IAB viewability and time-in-view measurement. Defaults to true. */
|
|
56
63
|
viewabilityEnabled?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -51,6 +51,13 @@ interface AnalyticsConfig {
|
|
|
51
51
|
region?: string;
|
|
52
52
|
auctionEnabled?: boolean;
|
|
53
53
|
warningsEnabled?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Compat: accepted and ignored. Errors are always collected -- see
|
|
56
|
+
* shouldSample() for why -- so this only ever legitimately held `true`, and
|
|
57
|
+
* honouring it meant a config that omitted it silently disabled error
|
|
58
|
+
* reporting. Kept so existing integrations still type-check; remove once no
|
|
59
|
+
* caller passes it (edge/src/sdk, edge/src/worker and the docs are clear).
|
|
60
|
+
*/
|
|
54
61
|
errorsEnabled?: boolean;
|
|
55
62
|
/** Whether to enable client-side IAB viewability and time-in-view measurement. Defaults to true. */
|
|
56
63
|
viewabilityEnabled?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -347,6 +347,14 @@ var TraceEventType = {
|
|
|
347
347
|
CLICK: 12,
|
|
348
348
|
/** AD_RENDER_FAILED - Prebid failed to render the winning ad */
|
|
349
349
|
AD_RENDER_FAILED: 13,
|
|
350
|
+
/**
|
|
351
|
+
* WARN - A wrapper condition worth reporting that is not a failure: a slot with no
|
|
352
|
+
* fitting sizes, a video load the watchdog cut short. Carries its own
|
|
353
|
+
* event_name, like ERROR. Publishers gate these with warnings_enabled;
|
|
354
|
+
* ERROR is never gated. Before this type these events reached the adapter
|
|
355
|
+
* and were dropped for want of one, so warnings_enabled controlled nothing.
|
|
356
|
+
*/
|
|
357
|
+
WARN: 17,
|
|
350
358
|
UNRECOGNIZED: -1
|
|
351
359
|
};
|
|
352
360
|
var BidderOutcome = {
|
|
@@ -1053,6 +1061,14 @@ var EVENT_NAME_TO_TYPE = {
|
|
|
1053
1061
|
timeInView: TraceEventType.TIME_IN_VIEW,
|
|
1054
1062
|
viewable: TraceEventType.VIEWABLE
|
|
1055
1063
|
};
|
|
1064
|
+
var LEVEL_TO_TYPE = {
|
|
1065
|
+
WARN: TraceEventType.WARN,
|
|
1066
|
+
ERROR: TraceEventType.ERROR
|
|
1067
|
+
};
|
|
1068
|
+
var SELF_NAMING_TYPES = /* @__PURE__ */ new Set([
|
|
1069
|
+
TraceEventType.ERROR,
|
|
1070
|
+
TraceEventType.WARN
|
|
1071
|
+
]);
|
|
1056
1072
|
var REVENUE_FLUSH_DELAY_MS = 3e3;
|
|
1057
1073
|
var REVENUE_FLUSH_TYPES = /* @__PURE__ */ new Set([
|
|
1058
1074
|
TraceEventType.IMPRESSION,
|
|
@@ -2182,14 +2198,10 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2182
2198
|
if (auctionId) {
|
|
2183
2199
|
if (this.slotEmittedImpressionKeys.has(
|
|
2184
2200
|
`${baseSlotKey}:auc:${escapeKeyPart(auctionId)}:ad:${escapeKeyPart(adId)}`
|
|
2185
|
-
) || this.slotEmittedImpressionKeys.has(`${baseSlotKey}:ad:${escapeKeyPart(adId)}`)
|
|
2186
|
-
this.slotEmittedImpressionKeys.has(
|
|
2187
|
-
`${baseSlotKey}:auc:${escapeKeyPart(auctionId)}:${escapeKeyPart(adId)}`
|
|
2188
|
-
) || this.slotEmittedImpressionKeys.has(`${baseSlotKey}:${escapeKeyPart(adId)}`)) {
|
|
2201
|
+
) || this.slotEmittedImpressionKeys.has(`${baseSlotKey}:ad:${escapeKeyPart(adId)}`)) {
|
|
2189
2202
|
return true;
|
|
2190
2203
|
}
|
|
2191
|
-
} else if (this.slotEmittedImpressionKeys.has(`${baseSlotKey}:ad:${escapeKeyPart(adId)}`)
|
|
2192
|
-
this.slotEmittedImpressionKeys.has(`${baseSlotKey}:${escapeKeyPart(adId)}`)) {
|
|
2204
|
+
} else if (this.slotEmittedImpressionKeys.has(`${baseSlotKey}:ad:${escapeKeyPart(adId)}`)) {
|
|
2193
2205
|
return true;
|
|
2194
2206
|
}
|
|
2195
2207
|
if (creativeId && creativeId !== adId) {
|
|
@@ -2224,14 +2236,10 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2224
2236
|
if (hasIdentity) {
|
|
2225
2237
|
if (adId) {
|
|
2226
2238
|
this.addImpressionKey(`${baseSlotKey}:ad:${escapeKeyPart(adId)}`);
|
|
2227
|
-
this.addImpressionKey(`${baseSlotKey}:${escapeKeyPart(adId)}`);
|
|
2228
2239
|
if (auctionId) {
|
|
2229
2240
|
this.addImpressionKey(
|
|
2230
2241
|
`${baseSlotKey}:auc:${escapeKeyPart(auctionId)}:ad:${escapeKeyPart(adId)}`
|
|
2231
2242
|
);
|
|
2232
|
-
this.addImpressionKey(
|
|
2233
|
-
`${baseSlotKey}:auc:${escapeKeyPart(auctionId)}:${escapeKeyPart(adId)}`
|
|
2234
|
-
);
|
|
2235
2243
|
}
|
|
2236
2244
|
}
|
|
2237
2245
|
if (creativeId && creativeId !== adId) {
|
|
@@ -2417,9 +2425,9 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2417
2425
|
}
|
|
2418
2426
|
}
|
|
2419
2427
|
trackRawEvent(level, eventName, data) {
|
|
2420
|
-
const eventType =
|
|
2428
|
+
const eventType = LEVEL_TO_TYPE[level] ?? EVENT_NAME_TO_TYPE[eventName];
|
|
2421
2429
|
if (eventType === void 0) return;
|
|
2422
|
-
this.enqueue(eventType, eventName, data
|
|
2430
|
+
this.enqueue(eventType, eventName, data);
|
|
2423
2431
|
}
|
|
2424
2432
|
/**
|
|
2425
2433
|
* Record the wrapper's Live Floors decision for an auction and ad unit,
|
|
@@ -2809,9 +2817,9 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2809
2817
|
isDuplicate(eventName, data) {
|
|
2810
2818
|
return this.deduper.isDuplicate(eventName, data);
|
|
2811
2819
|
}
|
|
2812
|
-
enqueue(type, eventName, data
|
|
2820
|
+
enqueue(type, eventName, data) {
|
|
2813
2821
|
if (!this.isEnabled) return;
|
|
2814
|
-
if (!this.shouldSample(type
|
|
2822
|
+
if (!this.shouldSample(type)) return;
|
|
2815
2823
|
if (this.managesSessionId && sessionNeedsSync()) {
|
|
2816
2824
|
this.config.sessionId = getOrCreateSessionId();
|
|
2817
2825
|
}
|
|
@@ -2820,8 +2828,8 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2820
2828
|
timestampMs: Date.now(),
|
|
2821
2829
|
type,
|
|
2822
2830
|
// Typed events have a fixed name that ingest derives from `type`; only
|
|
2823
|
-
// ERROR
|
|
2824
|
-
eventName: type
|
|
2831
|
+
// ERROR and WARN carry theirs, which names the failure or condition.
|
|
2832
|
+
eventName: SELF_NAMING_TYPES.has(type) ? eventName : "",
|
|
2825
2833
|
auctionId: idToBytes(String(data.auctionId || "")),
|
|
2826
2834
|
transactionId: idToBytes(String(data.transactionId || "")),
|
|
2827
2835
|
adUnitCode: data.adUnitCode || data.elementId || "",
|
|
@@ -2901,13 +2909,12 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2901
2909
|
}, this.config.revenueFlushDelayMs);
|
|
2902
2910
|
}
|
|
2903
2911
|
}
|
|
2904
|
-
shouldSample(type
|
|
2912
|
+
shouldSample(type) {
|
|
2905
2913
|
if (type === TraceEventType.ERROR) {
|
|
2906
2914
|
this.errorCount++;
|
|
2907
|
-
|
|
2908
|
-
return this.config.errorsEnabled;
|
|
2915
|
+
return this.errorCount <= MAX_ERRORS_PER_SESSION;
|
|
2909
2916
|
}
|
|
2910
|
-
if (
|
|
2917
|
+
if (type === TraceEventType.WARN) {
|
|
2911
2918
|
return this.config.warningsEnabled;
|
|
2912
2919
|
}
|
|
2913
2920
|
return this.config.auctionEnabled;
|
package/dist/index.mjs
CHANGED
|
@@ -304,6 +304,14 @@ var TraceEventType = {
|
|
|
304
304
|
CLICK: 12,
|
|
305
305
|
/** AD_RENDER_FAILED - Prebid failed to render the winning ad */
|
|
306
306
|
AD_RENDER_FAILED: 13,
|
|
307
|
+
/**
|
|
308
|
+
* WARN - A wrapper condition worth reporting that is not a failure: a slot with no
|
|
309
|
+
* fitting sizes, a video load the watchdog cut short. Carries its own
|
|
310
|
+
* event_name, like ERROR. Publishers gate these with warnings_enabled;
|
|
311
|
+
* ERROR is never gated. Before this type these events reached the adapter
|
|
312
|
+
* and were dropped for want of one, so warnings_enabled controlled nothing.
|
|
313
|
+
*/
|
|
314
|
+
WARN: 17,
|
|
307
315
|
UNRECOGNIZED: -1
|
|
308
316
|
};
|
|
309
317
|
var BidderOutcome = {
|
|
@@ -1010,6 +1018,14 @@ var EVENT_NAME_TO_TYPE = {
|
|
|
1010
1018
|
timeInView: TraceEventType.TIME_IN_VIEW,
|
|
1011
1019
|
viewable: TraceEventType.VIEWABLE
|
|
1012
1020
|
};
|
|
1021
|
+
var LEVEL_TO_TYPE = {
|
|
1022
|
+
WARN: TraceEventType.WARN,
|
|
1023
|
+
ERROR: TraceEventType.ERROR
|
|
1024
|
+
};
|
|
1025
|
+
var SELF_NAMING_TYPES = /* @__PURE__ */ new Set([
|
|
1026
|
+
TraceEventType.ERROR,
|
|
1027
|
+
TraceEventType.WARN
|
|
1028
|
+
]);
|
|
1013
1029
|
var REVENUE_FLUSH_DELAY_MS = 3e3;
|
|
1014
1030
|
var REVENUE_FLUSH_TYPES = /* @__PURE__ */ new Set([
|
|
1015
1031
|
TraceEventType.IMPRESSION,
|
|
@@ -2139,14 +2155,10 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2139
2155
|
if (auctionId) {
|
|
2140
2156
|
if (this.slotEmittedImpressionKeys.has(
|
|
2141
2157
|
`${baseSlotKey}:auc:${escapeKeyPart(auctionId)}:ad:${escapeKeyPart(adId)}`
|
|
2142
|
-
) || this.slotEmittedImpressionKeys.has(`${baseSlotKey}:ad:${escapeKeyPart(adId)}`)
|
|
2143
|
-
this.slotEmittedImpressionKeys.has(
|
|
2144
|
-
`${baseSlotKey}:auc:${escapeKeyPart(auctionId)}:${escapeKeyPart(adId)}`
|
|
2145
|
-
) || this.slotEmittedImpressionKeys.has(`${baseSlotKey}:${escapeKeyPart(adId)}`)) {
|
|
2158
|
+
) || this.slotEmittedImpressionKeys.has(`${baseSlotKey}:ad:${escapeKeyPart(adId)}`)) {
|
|
2146
2159
|
return true;
|
|
2147
2160
|
}
|
|
2148
|
-
} else if (this.slotEmittedImpressionKeys.has(`${baseSlotKey}:ad:${escapeKeyPart(adId)}`)
|
|
2149
|
-
this.slotEmittedImpressionKeys.has(`${baseSlotKey}:${escapeKeyPart(adId)}`)) {
|
|
2161
|
+
} else if (this.slotEmittedImpressionKeys.has(`${baseSlotKey}:ad:${escapeKeyPart(adId)}`)) {
|
|
2150
2162
|
return true;
|
|
2151
2163
|
}
|
|
2152
2164
|
if (creativeId && creativeId !== adId) {
|
|
@@ -2181,14 +2193,10 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2181
2193
|
if (hasIdentity) {
|
|
2182
2194
|
if (adId) {
|
|
2183
2195
|
this.addImpressionKey(`${baseSlotKey}:ad:${escapeKeyPart(adId)}`);
|
|
2184
|
-
this.addImpressionKey(`${baseSlotKey}:${escapeKeyPart(adId)}`);
|
|
2185
2196
|
if (auctionId) {
|
|
2186
2197
|
this.addImpressionKey(
|
|
2187
2198
|
`${baseSlotKey}:auc:${escapeKeyPart(auctionId)}:ad:${escapeKeyPart(adId)}`
|
|
2188
2199
|
);
|
|
2189
|
-
this.addImpressionKey(
|
|
2190
|
-
`${baseSlotKey}:auc:${escapeKeyPart(auctionId)}:${escapeKeyPart(adId)}`
|
|
2191
|
-
);
|
|
2192
2200
|
}
|
|
2193
2201
|
}
|
|
2194
2202
|
if (creativeId && creativeId !== adId) {
|
|
@@ -2374,9 +2382,9 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2374
2382
|
}
|
|
2375
2383
|
}
|
|
2376
2384
|
trackRawEvent(level, eventName, data) {
|
|
2377
|
-
const eventType =
|
|
2385
|
+
const eventType = LEVEL_TO_TYPE[level] ?? EVENT_NAME_TO_TYPE[eventName];
|
|
2378
2386
|
if (eventType === void 0) return;
|
|
2379
|
-
this.enqueue(eventType, eventName, data
|
|
2387
|
+
this.enqueue(eventType, eventName, data);
|
|
2380
2388
|
}
|
|
2381
2389
|
/**
|
|
2382
2390
|
* Record the wrapper's Live Floors decision for an auction and ad unit,
|
|
@@ -2766,9 +2774,9 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2766
2774
|
isDuplicate(eventName, data) {
|
|
2767
2775
|
return this.deduper.isDuplicate(eventName, data);
|
|
2768
2776
|
}
|
|
2769
|
-
enqueue(type, eventName, data
|
|
2777
|
+
enqueue(type, eventName, data) {
|
|
2770
2778
|
if (!this.isEnabled) return;
|
|
2771
|
-
if (!this.shouldSample(type
|
|
2779
|
+
if (!this.shouldSample(type)) return;
|
|
2772
2780
|
if (this.managesSessionId && sessionNeedsSync()) {
|
|
2773
2781
|
this.config.sessionId = getOrCreateSessionId();
|
|
2774
2782
|
}
|
|
@@ -2777,8 +2785,8 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2777
2785
|
timestampMs: Date.now(),
|
|
2778
2786
|
type,
|
|
2779
2787
|
// Typed events have a fixed name that ingest derives from `type`; only
|
|
2780
|
-
// ERROR
|
|
2781
|
-
eventName: type
|
|
2788
|
+
// ERROR and WARN carry theirs, which names the failure or condition.
|
|
2789
|
+
eventName: SELF_NAMING_TYPES.has(type) ? eventName : "",
|
|
2782
2790
|
auctionId: idToBytes(String(data.auctionId || "")),
|
|
2783
2791
|
transactionId: idToBytes(String(data.transactionId || "")),
|
|
2784
2792
|
adUnitCode: data.adUnitCode || data.elementId || "",
|
|
@@ -2858,13 +2866,12 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2858
2866
|
}, this.config.revenueFlushDelayMs);
|
|
2859
2867
|
}
|
|
2860
2868
|
}
|
|
2861
|
-
shouldSample(type
|
|
2869
|
+
shouldSample(type) {
|
|
2862
2870
|
if (type === TraceEventType.ERROR) {
|
|
2863
2871
|
this.errorCount++;
|
|
2864
|
-
|
|
2865
|
-
return this.config.errorsEnabled;
|
|
2872
|
+
return this.errorCount <= MAX_ERRORS_PER_SESSION;
|
|
2866
2873
|
}
|
|
2867
|
-
if (
|
|
2874
|
+
if (type === TraceEventType.WARN) {
|
|
2868
2875
|
return this.config.warningsEnabled;
|
|
2869
2876
|
}
|
|
2870
2877
|
return this.config.auctionEnabled;
|
package/package.json
CHANGED