@bidkernel/analytics 0.28.0 → 0.29.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 +0 -8
- package/dist/index.d.ts +0 -8
- package/dist/index.js +7 -66
- package/dist/index.mjs +7 -66
- package/package.json +1 -1
package/dist/analytics.global.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var bidkernelPrebidAnalyticsBundle=(()=>{var _=(i,e)=>()=>(i&&(e=i(i=0)),e);var Lt=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);function _t(){if(typeof window<"u"){let i=window;return i.__bidkernelLogListeners||(i.__bidkernelLogListeners=new Set),i.__bidkernelLogListeners}return St}function Ot(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 R.INFO}function ue(i){return new le(i)}var R,De,$,Ct,St,le,Ue=_(()=>{"use strict";R={DEBUG:"DEBUG",INFO:"INFO",WARN:"WARN",ERROR:"ERROR"},De={[R.DEBUG]:10,[R.INFO]:20,[R.WARN]:30,[R.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"},Ct=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??R.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(De[t]??20)>=(De[this._level]??20)}formatTime(e){return this._customFormatTime?this._customFormatTime(e):Ot(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=_t();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(),l={id:`bk_log_${d}_${++Ct}`,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(l);let c=this._getConsole();if(!c)return;let I=$.badge,g=$.event;r===R.WARN?(I=$.badgeWarn,g=$.eventWarn):r===R.ERROR&&(I=$.badgeError,g=$.eventError);let f=`%c${this._prefix}%c ${s} %c${t}%c`,S=[I,$.dim,g,$.reset],b=[f,...S];switch(n.length>0&&b.push(...n),r){case R.DEBUG:typeof c.log=="function"?c.log(...b):typeof c.debug=="function"&&c.debug(...b);break;case R.INFO:typeof c.info=="function"?c.info(...b):typeof c.log=="function"&&c.log(...b);break;case R.WARN:typeof c.warn=="function"?c.warn(...b):typeof c.log=="function"&&c.log(...b);break;case R.ERROR:typeof c.error=="function"?c.error(...b):typeof c.log=="function"&&c.log(...b);break;default:typeof c.log=="function"&&c.log(...b);break}}debug(e,...t){this.log(R.DEBUG,e,...t)}info(e,...t){this.log(R.INFO,e,...t)}warn(e,...t){this.log(R.WARN,e,...t)}error(e,...t){this.log(R.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 Me(){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?Pe(n,r):pe(n,r)}function Ne(i,e){let t=pe(i,e),n=t.hi&2147483648;n&&(t=Pe(t.lo,t.hi));let r=he(t.lo,t.hi);return n?"-"+r:r}function he(i,e){if({lo:i,hi:e}=Bt(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 Bt(i,e){return{lo:i>>>0,hi:e>>>0}}function pe(i,e){return{lo:i|0,hi:e|0}}function Pe(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 Fe(){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=_(()=>{"use strict";ne=4294967296;ke=i=>{let e=String(i);return"0000000".slice(e.length)+e}});function xt(){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()),Ve(t),t},uParse(t){return typeof t!="string"&&(t=t.toString()),$e(t),t},enc(t){return typeof t!="string"&&(t=t.toString()),Ve(t),fe(t)},uEnc(t){return typeof t!="string"&&(t=t.toString()),$e(t),fe(t)},dec(t,n){return Ne(t,n)},uDec(t,n){return he(t,n)}}}function Ve(i){if(!/^-?[0-9]+$/.test(i))throw new Error("invalid int64: "+i)}function $e(i){if(!/^[0-9]+$/.test(i))throw new Error("invalid uint64: "+i)}var U,We=_(()=>{"use strict";ye();U=xt()});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=_(()=>{"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>Mt||i<Nt)throw new Error("invalid int32: "+i)}function je(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 Pt(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>Dt||i<Ut))throw new Error("invalid float32: "+i)}var W,Dt,Ut,kt,Mt,Nt,j,O,qe=_(()=>{"use strict";ye();We();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={}));Dt=34028234663852886e22,Ut=-34028234663852886e22,kt=4294967295,Mt=2147483647,Nt=-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(je(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){Pt(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){je(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=U.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=U.uEnc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=U.enc(e);return ie(t.lo,t.hi,this.buf),this}sint64(e){let t=U.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=U.uEnc(e);return ie(t.lo,t.hi,this.buf),this}},O=class{constructor(e,t=me().decodeUtf8){this.decodeUtf8=t,this.varint64=Me,this.uint32=Fe,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 U.dec(...this.varint64())}uint64(){return U.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,U.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 U.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return U.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 He=_(()=>{"use strict"});var Ke=_(()=>{"use strict"});var Ge=_(()=>{"use strict"});var Ye=_(()=>{"use strict";qe();He();Ie();Ke();Ge()});function Ft(){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 Vt(){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:[],level:void 0}}function $t(){return{key:"",value:""}}function Wt(){return{adUnitCode:"",outcome:0,bid:void 0,refreshIndex:0,floorCents:void 0,floorSource:0,floorTreatmentBp:void 0}}function jt(){return{bidder:"",cpm:0,currency:"",width:0,height:0,dealId:"",mediaType:"",latencyMs:0,advertiserDomain:"",creativeId:""}}var y,F,oe,Ee,ze,Xe,Qe,re,Te=_(()=>{"use strict";Ye();y={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,PUBLISHER:18,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=Ft();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])=>{Xe.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)Qe.encode(t,e.uint32(98).fork()).join();return i.level!==void 0&&e.uint32(106).string(i.level),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!==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=Xe.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=Qe.decode(t,t.uint32());s!==void 0&&r.bidderOutcomes.push(s);continue}case 13:{if(o!==106)break;r.level=t.string();continue}}if((o&7)===4||o===0)break;t.skip(o&7)}return r}};Xe={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=$t();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}};Qe={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=Wt();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=jt();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(qt.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(Je)return Je.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 qt,Je,zn,et=_(()=>{"use strict";qt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,Je=typeof TextEncoder<"u"?new TextEncoder:null,zn=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 ln(i){let e="";for(let n=0;n<i.length;n+=8192)e+=String.fromCharCode(...i.subarray(n,n+8192));return btoa(e)}function un(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 fn(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 hn(i){let e={},t=0;for(let n of Object.keys(i)){if(t>=Yt)break;let r=i[n];if(r==null)continue;let o=String(r);e[n]=o.length>nt?`${o.slice(0,nt)}...[truncated]`:o,t++}return e}function pn(i){let e=i.slice(se.length).split("_");return e.length===2&&/^\d+$/.test(e[0])}function gn(i,e){if(!i||!e)return!1;try{return new URL(i).origin===new URL(e).origin}catch{return!1}}function at(i){try{typeof localStorage<"u"&&(localStorage.setItem(st,i.toString()),z=i)}catch{}}function ct(i=Date.now()){return V>0&&i-V<=dt}function de(){let i=Date.now(),e=!!x&&!ct(i);if(V=i,e){x=null;for(let t of mn)t();return}!Z||!x||z===0||i-z<yn||at(i)}function In(){return!x||Z&&z===0}function vn(){if(ot||typeof window>"u")return;ot=!0;let i=()=>de();for(let e of bn)window.addEventListener(e,i,{passive:!0,capture:!0});typeof document<"u"&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&de()})}function Re(){let i=Date.now(),e=!!x&&ct(i);try{if(Z&&typeof localStorage<"u"){let t=localStorage.getItem(rt),n=localStorage.getItem(st),r=n&&parseInt(n,10)||0;if(t&&r&&i-r<=dt)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(rt,o),at(V),x=o,o}}catch{}return e||(x=X(),V=i),x}function u(i){return String(i??"").replace(/%/g,"%25").replace(/:/g,"%3A")}function En(i,e){switch(i){case"auctionInit":return`auctionInit:${u(e?.auctionId)}`;case"auctionEnd":return`auctionEnd:${u(e?.auctionId)}`;case"bidRequested":{let t=Array.isArray(e?.bids)?e.bids.map(n=>u(n?.bidId||n?.transactionId||n?.adUnitCode)).join(","):"";return`bidRequested:${u(e?.auctionId)}:${u(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:${u(t.auctionId)}:${u(t.adUnitCode)}:${u(t.bidderCode||t.bidder)}:${u(n)}:${u(r)}`}case"bidTimeout":return"bidTimeout:"+(Array.isArray(e)?e:e?[e]:[]).map(n=>`${u(n?.auctionId)}:${u(n?.bidderCode||n?.bidder)}:${u(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:${u(t.auctionId)}:${u(t.adUnitCode)}:${u(t.bidderCode||t.bidder)}:${u(n)}:${u(r)}`}case"noBid":return`noBid:${u(e?.auctionId)}:${u(e?.adUnitCode)}:${u(e?.bidderCode||e?.bidder)}:${u(e?.bidId||e?.transactionId)}`;case"adRenderFailed":{let t=e?.bid||{};return`adRenderFailed:${u(t.auctionId||e?.auctionId)}:${u(t.adUnitCode||e?.adUnitCode)}:${u(t.bidderCode||t.bidder||e?.bidderCode||e?.bidder)}:${u(e?.reason)}:${u(e?.message)}`}case"adRenderSucceeded":{let t=e?.bid||e||{},n=t.creativeId||t.adId||e?.adId||"",r=t.originalCpm??t.cpm??"";return`adRenderSucceeded:${u(t.auctionId||e?.auctionId)}:${u(t.adUnitCode||e?.adUnitCode)}:${u(t.bidderCode||t.bidder)}:${u(n)}:${u(r)}`}case"setTargeting":return`setTargeting:${Object.keys(e||{}).sort().map(u).join(",")}`;case"auctionDebug":return`auctionDebug:${u(e?.type)}:${u(String(e?.arguments?.[0]??"").slice(0,50))}`;default:return""}}function H(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 Tn(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 Ce(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?.()||"",l={pbjsGlobalName:i,...e,...s};if(a&&!gn(l.endpoint||"",a)&&(Y.warn(`Ignoring analytics endpoint change to ${l.endpoint||"(empty)"}: this page is pinned to ${a}. Reload to change the ingest endpoint.`),l.endpoint=a),d)try{d.disable()}catch(I){Y.warn("Failed to disable previous analytics instance:",I)}let c=new C(l);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=Tn(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 tt,Ht,ee,Kt,Gt,we,nt,Yt,it,se,zt,Xt,Qt,Zt,Jt,en,Ae,tn,nn,K,rn,on,sn,dn,an,cn,rt,st,dt,x,V,Z,yn,z,bn,ot,mn,Le,Y,C,Se=_(()=>{"use strict";Ue();Te();et();tt=1e4,Ht=50,ee=200,Kt=300*1e3,Gt=10,we=32*1024,nt=1024,Yt=16,it="text/plain",se="_bidkernel_pending_",zt=20,Xt=7200*1e3,Qt=1e4,Zt={auctionStart:y.AUCTION_START,auctionEnd:y.AUCTION_END,bidWin:y.BID_WIN,adRenderFailed:y.AD_RENDER_FAILED,click:y.CLICK,impression:y.IMPRESSION,timeInView:y.TIME_IN_VIEW,viewable:y.VIEWABLE},Jt={WARN:y.WARN,ERROR:y.ERROR},en=new Set([y.ERROR,y.WARN,y.PUBLISHER]),Ae={INFO:1,WARN:2,ERROR:3},tn=3e3,nn=new Set([y.IMPRESSION,y.BID_WIN,y.CLICK]),K=1800*1e3,rn=200,on=1e3,sn=50,dn=200,an={static:oe.FLOOR_SOURCE_STATIC,pool:oe.FLOOR_SOURCE_POOL,none:oe.FLOOR_SOURCE_NONE},cn=1e3,rt="_bidkernel_session",st="_bidkernel_session_ts",dt=1800*1e3,x=null,V=0,Z=!0;yn=60*1e3,z=0,bn=["pointerdown","pointermove","keydown","scroll","wheel","touchstart"],ot=!1,mn=new Set;Le=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=En(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"}),C=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 Le;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||fn(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:tn,publisherLogLevel:e.publisherLogLevel&&(e.publisherLogLevel.toUpperCase()==="INFO"||e.publisherLogLevel.toUpperCase()==="WARN"||e.publisherLogLevel.toUpperCase()==="ERROR")?e.publisherLogLevel.toUpperCase():"INFO"},i.allInstances.add(this),this.logger=ue({prefix:"[analytics]",logLevel:this.config.logLevel}),de(),this.managesSessionId=!e.sessionId,this.managesSessionId&&(this.config.sessionId=Re()),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),vn(),this.flushTimer=setInterval(()=>this.flush(),tt),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,l=n[d];l&&l(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(y.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(y.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)<cn)return!1;this.lastClickAt.set(e,n);let r=this.getCachedBid(e);return this.enqueue(y.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(y.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 l=typeof performance<"u"&&performance.now?performance.now():Date.now();if(s.lastEnteredViewAt=s.inView?l: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=l,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 l=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:l};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=`${u(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>K){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>K&&this.cachedWinningBids.delete(t);for(;this.cachedWinningBids.size>rn;){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>=on;){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>sn;){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=`${u(e)}:${s}`;if(o){if(n){if(this.slotEmittedImpressionKeys.has(`${d}:auc:${u(n)}:ad:${u(o)}`)||this.slotEmittedImpressionKeys.has(`${d}:ad:${u(o)}`))return!0}else if(this.slotEmittedImpressionKeys.has(`${d}:ad:${u(o)}`))return!0;if(r&&r!==o){if(n){if(this.slotEmittedImpressionKeys.has(`${d}:auc:${u(n)}:${u(r)}`)||this.slotEmittedImpressionKeys.has(`${d}:${u(r)}`))return!0}else if(this.slotEmittedImpressionKeys.has(`${d}:${u(r)}`))return!0}return!1}return r?n?this.slotEmittedImpressionKeys.has(`${d}:auc:${u(n)}:${u(r)}`)||this.slotEmittedImpressionKeys.has(`${d}:${u(r)}`):this.slotEmittedImpressionKeys.has(`${d}:${u(r)}`):n?this.slotEmittedImpressionKeys.has(`${d}:auc:${u(n)}`):this.slotEmittedImpressionKeys.has(d)}markImpressionEmitted(e,t,n,r,o){let s=`${u(e)}:${t}`;!!(o||r)?(o&&(this.addImpressionKey(`${s}:ad:${u(o)}`),n&&this.addImpressionKey(`${s}:auc:${u(n)}:ad:${u(o)}`)),r&&r!==o&&(this.addImpressionKey(`${s}:${u(r)}`),n&&this.addImpressionKey(`${s}:auc:${u(n)}:${u(r)}`)),n&&this.addImpressionKey(`${s}:auc:${u(n)}`)):(this.addImpressionKey(s),n&&this.addImpressionKey(`${s}:auc:${u(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||"",l=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),S=g?this.slotLastAuctionIds.get(g)||(f?f.auctionId:void 0):void 0,b=!!(g&&d&&S&&S!==d&&t?.refreshIndex===void 0),L={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",...H(s).width?H(s):o?.bidTrace?{width:o.bidTrace.width,height:o.bidTrace.height}:H(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(b&&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=L,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,l,c)||r&&r!==n&&this.hasImpressionEmitted(r,B,d,l,c)?(this.log("DEBUG",`Impression already emitted for slot ${n||r} in cycle ${B}`),!1):(n&&this.markImpressionEmitted(n,B,d,l,c),r&&r!==n&&this.markImpressionEmitted(r,B,d,l,c),this.enqueue(y.IMPRESSION,"impression",{auctionId:d,transactionId:a,adUnitCode:r,bid:L,metadata:{...t?.metadata,refresh_index:String(B)}}),f&&(!f.bidPayload&&L&&(f.bidPayload=L),!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(l){this.log("ERROR","Error in threshold callback",l)}}}},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)}setPublisherLogLevel(e){let t=e?e.toUpperCase():"INFO";t==="INFO"||t==="WARN"||t==="ERROR"?this.config.publisherLogLevel=t:this.config.publisherLogLevel="INFO"}getPublisherLogLevel(){return this.config.publisherLogLevel||"INFO"}trackRawEvent(e,t,n){if(t&&t.startsWith("pub:")){let o=e?e.toUpperCase():"";if(o!=="INFO"&&o!=="WARN"&&o!=="ERROR")return;this.enqueue(y.PUBLISHER,t,n,o);return}let r=Jt[e]??Zt[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>dn;){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=Re())}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(y.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(y.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",l=`${n}:${s}`;r.has(l)||r.set(l,{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 l=o>0?{bidder:n,cpm:o,currency:e.originalCurrency??e.currency??"USD",...H(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:l})}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),l=`${o}:${s}`,c=a.get(l);c?(c.outcome=F.BIDDER_OUTCOME_TIMEOUT,d>0&&c.bid&&(c.bid.latencyMs=d)):a.set(l,{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",...H(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(y.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(y.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||"",l=(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||l?.bidTrace?.mediaType==="video"||l?.rawBid?.mediaType==="video"||n&&this.slotViewabilityRecords.get(n)?.mediaType==="video",I=c?"video":s||l?.bidTrace?.mediaType||"banner",g={bidder:t.bidderCode||t.bidder||l?.bidTrace?.bidder||"",cpm:Number.isFinite(t.originalCpm)?t.originalCpm:Number.isFinite(t.cpm)?t.cpm:l?.bidTrace?.cpm??0,currency:t.originalCurrency??t.currency??l?.bidTrace?.currency??"USD",...H(t).width?H(t):l?.bidTrace?{width:l.bidTrace.width,height:l.bidTrace.height}:H(t),dealId:t.dealId||l?.bidTrace?.dealId||"",mediaType:I,latencyMs:Number.isFinite(t.timeToRespond)?t.timeToRespond:l?.bidTrace?.latencyMs??0,advertiserDomain:t.meta?.advertiserDomains?.[0]||l?.bidTrace?.advertiserDomain||"",creativeId:t.creativeId||l?.bidTrace?.creativeId||""},f=r||l?.auctionId||"",S=o||l?.transactionId||"",b=n?this.slotViewabilityRecords.get(n):void 0,L=b&&f&&b.auctionId&&b.auctionId!==f;if(!!(n&&b&&L)){this.flushSlotTimeInView(n);let v=(this.slotRefreshIndices.get(n)??(b?b.refreshIndex:0))+1;this.slotRefreshIndices.set(n,v),this.slotLastAuctionIds.set(n,f),b&&(b.refreshIndex=v,b.auctionId=f,b.transactionId=S,b.bidPayload=g,b.viewableFired=!1,b.accumulatedTimeInViewMs=0)}else n&&(f&&this.slotLastAuctionIds.set(n,f),this.slotRefreshIndices.has(n)||this.slotRefreshIndices.set(n,0));let k=n?this.slotRefreshIndices.get(n)??(b?b.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,k,f,g.creativeId)||(n&&this.markImpressionEmitted(n,k,f,g.creativeId),this.enqueue(y.IMPRESSION,"impression",{auctionId:f,transactionId:S,adUnitCode:n,bid:g,metadata:{refresh_index:String(k)}})),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:S,mediaType:I,bid:g,refreshIndex:k})}}isDuplicate(e,t){return this.deduper.isDuplicate(e,t)}enqueue(e,t,n,r){if(!this.isEnabled||!this.shouldSample(e,r))return;this.managesSessionId&&In()&&(this.config.sessionId=Re());let o={eventId:q(X()),timestampMs:Date.now(),type:e,eventName:en.has(e)?t:"",auctionId:q(String(n.auctionId||"")),transactionId:q(String(n.transactionId||"")),adUnitCode:n.adUnitCode||n.elementId||"",namespace:n.ns||n.namespace||""};e===y.PUBLISHER&&r&&(o.level=r),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 l=this.floorDecisionFor(String(n.auctionId||""),a.adUnitCode||"");return{...a,refreshIndex:a.refreshIndex??this.auctionCycleIndex(a.adUnitCode||""),...l?{floorCents:l.floorCents,floorSource:an[l.source],floorTreatmentBp:Math.round(l.treatment*1e4)}:{}}}));let s={...n.metadata};if(e===y.PUBLISHER&&n)for(let[a,l]of Object.entries(n))l!=null&&s[a]===void 0&&a!=="metadata"&&(s[a]=typeof l=="object"?JSON.stringify(l):String(l));if(e===y.BID_WIN||e===y.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=hn(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)):nn.has(e)&&this.revenueFlushTimer===null&&(this.revenueFlushTimer=setTimeout(()=>{this.revenueFlushTimer=null,this.flush()},this.config.revenueFlushDelayMs))}shouldSample(e,t){if(e===y.ERROR)return this.errorCount++,this.errorCount<=Ht;if(e===y.WARN)return this.config.warningsEnabled;if(e===y.PUBLISHER){let n=this.config.publisherLogLevel||"INFO",r=Ae[n.toUpperCase()]??Ae.INFO;return(Ae[t?.toUpperCase()??""]??0)>=r}return 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":it},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(tt*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:it});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,ln(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)},Qt))}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):pn(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>Xt)continue;let d;try{d=un(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 wn(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 pt(i,e,t){let n=ae(i),{err:r,message:o,metadata:s}=wn(e);return n.log("WARN","IMA AdErrorEvent received",e),n.enqueue(y.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 An(i,e){if(!i||typeof i!="object"||lt.has(i))return;lt.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 C.getActiveInstances())try{let o=yt(r,{mediaType:"video"});pt(r,n,{adStarted:!1,adUnitCode:o?.adUnitCode||"video",auctionId:o?.auctionId,transactionId:o?.transactionId,bid:o?.bidTrace})}catch{}})}catch{}}function ut(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 C.getActiveInstances())try{s.attachImaAdsManager(o)}catch{}return o};n.__bidkernelHooked=!0,e.getAdsManager=n}}catch{}}function ft(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 C.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 C.getActiveInstances())try{o.attachImaAdsManager(this)}catch{}return t.apply(this,r)};n.__bidkernelHooked=!0,e.start=n}}catch{}}function ht(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(An(this,t),(r==="adsManagerLoaded"||r===(this?.AdsManagerLoadedEvent?.Type?.ADS_MANAGER_LOADED||"adsManagerLoaded"))&&typeof o=="function"){let d=_e.get(o);return d||(d=function(a){if(a&&typeof a.getAdsManager=="function"&&!a.getAdsManager.__bidkernelHooked){let l=a.getAdsManager;a.getAdsManager=function(...c){let I=l.apply(this,c);if(I)for(let g of C.getActiveInstances())try{g.attachImaAdsManager(I)}catch{}return I},a.getAdsManager.__bidkernelHooked=!0}return o.apply(this,arguments)},_e.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"?_e.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&&ut(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,ut(o)}})}catch{}}i.AdsLoader&&ht(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,ht(o)}})}catch{}}i.AdsManager&&ft(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,ft(o)}})}catch{}}}catch{}}function gt(){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 yt(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>K)&&(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>K)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>K)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>K||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>K||(!s||d.timestamp>s.timestamp)&&(s=d);return s}function bt(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||"",l=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=yt(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)||"",G=(typeof p?.getCreativeId=="function"?p.getCreativeId():p?.creativeId)||"";return g={sessionId:h,adId:E||void 0,creativeId:G||void 0},g},S=p=>{let h=typeof p?.getAd=="function"?p.getAd():p?.ad;f(h),n.log("DEBUG","IMA AdEvent.LOADED received",{slotId:s,activeAdSession:g})},b=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 G=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",vt=t?.adUnitCode&&t.adUnitCode!=="video"?t.adUnitCode:N?.adUnitCode||ce,Et=a||N?.auctionId||"",Tt=l||N?.transactionId||"",Oe=G.creativeId||E.creativeId||N?.bidTrace?.creativeId||t?.bid?.creativeId||"",wt=G.adId||E.adId||Oe||G.sessionId,Be={...N?.rawBid||t?.bid,mediaType:"video",creativeId:Oe},xe=n.recordImpression(ce,{adUnitCode:vt,auctionId:Et,transactionId:Tt,mediaType:"video",bid:Be,adId:wt,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 At=J?J.toUpperCase():"STARTED/IMPRESSION";if(n.log("DEBUG",`IMA AdEvent.${At} received${xe?"":" (second event for this ad, already counted)"}`,p),xe&&t?.onImpression)try{t.onImpression(ce,{ad:h,bid:Be})}catch(Rt){n.log("ERROR","Error in onImpression callback",Rt)}},L=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(y.CLICK,"click",{auctionId:a||h?.auctionId,transactionId:l||h?.transactionId,adUnitCode:E,bid:h?.bidTrace||t?.bid,metadata:{...t?.metadata,media_type:"video"}})},k=p=>{g=null;let h=c(),E=t?.adUnitCode&&t.adUnitCode!=="video"?t.adUnitCode:h?.adUnitCode||s,G=pt(i,p,{adStarted:I,adUnitCode:E,auctionId:a||h?.auctionId,transactionId:l||h?.transactionId,bid:h?.bidTrace||t?.bid,metadata:t?.metadata});if(t?.onError)try{t.onError(G)}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:S},{type:T.STARTED||"started",handler:b},{type:T.IMPRESSION||"impression",handler:b},{type:T.FIRST_QUARTILE||"firstQuartile",handler:()=>L("firstQuartile")},{type:T.MIDPOINT||"midpoint",handler:()=>L("midpoint")},{type:T.THIRD_QUARTILE||"thirdQuartile",handler:()=>L("thirdQuartile")},{type:T.COMPLETE||"complete",handler:()=>{g=null,L("complete")}},{type:T.ALL_ADS_COMPLETED||"allAdsCompleted",handler:()=>{g=null}},{type:T.CLICK||"click",handler:B},{type:M.AD_ERROR||"adError",handler:k}],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 Rn(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 bt(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||"",l=()=>(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=l(),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)},S=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))}},b=()=>{I.q4||(I.q4=!0,t?.onMilestone?.("complete",o))},L=m=>{let w=(m?.target instanceof HTMLVideoElement?m.target:c)?.error||c?.error,D=l(),p=w?`HTML5 video error code ${w.code}: ${w.message}`:"Video playback error";if(n.log("WARN",p),n.enqueue(y.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",S),m.addEventListener("ended",b),m.addEventListener("error",L)},k=m=>{m.removeEventListener("playing",f),m.removeEventListener("play",f),m.removeEventListener("timeupdate",S),m.removeEventListener("ended",b),m.removeEventListener("error",L)},v=null;r&&r!==c&&(r.addEventListener("playing",f,!0),r.addEventListener("play",f,!0),r.addEventListener("timeupdate",S,!0),r.addEventListener("ended",b,!0),r.addEventListener("error",L,!0)),c&&B(c),r&&r.tagName?.toLowerCase()!=="video"&&typeof MutationObserver<"u"&&(v=new MutationObserver(()=>{let m=r.querySelector("video");m&&m!==c&&(c&&k(c),c=m,c&&B(c))}),v.observe(r,{childList:!0,subtree:!0}));let T=l();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",S,!0),r.removeEventListener("ended",b,!0),r.removeEventListener("error",L,!0)),c&&k(c),n.videoDetachCleanups.delete(M)};return n.videoDetachCleanups.add(M),M}var ae,_e,lt,Ln,mt=_(()=>{"use strict";Se();Te();ae=i=>i,_e=new WeakMap,lt=new WeakSet;typeof window<"u"&>();C.prototype.attachImaAdsManager=function(i,e){return bt(this,i,e)};C.prototype.attachVideoPlayer=function(i,e){return Rn(this,i,e)};Ln=C.prototype.enable;C.prototype.enable=function(){Ln.call(this),typeof window<"u"&&(gt(),window.google?.ima&&te(window.google.ima))}});var Sn=Lt(()=>{Se();mt();var It="https://by.bidkernel.io/t",Cn=window._bidkernelPbjsGlobal||"pbjs";Ce(Cn,{endpoint:It});window.bidkernelPrebidAnalytics={...window.bidkernelPrebidAnalytics,register:(i,e)=>Ce(i,{endpoint:It,...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=>{C.setLogLevel(i)},getLogLevel:()=>C.getLogLevel()}});return Sn();})();
|
|
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,12 +51,6 @@ interface AnalyticsConfig {
|
|
|
51
51
|
region?: string;
|
|
52
52
|
auctionEnabled?: boolean;
|
|
53
53
|
warningsEnabled?: boolean;
|
|
54
|
-
/**
|
|
55
|
-
* Minimum log level collected for publisher report events (INFO | WARN | ERROR).
|
|
56
|
-
* ERROR is always collected by construction: it is the top of the ordering.
|
|
57
|
-
* Defaults to "INFO".
|
|
58
|
-
*/
|
|
59
|
-
publisherLogLevel?: "INFO" | "WARN" | "ERROR" | string;
|
|
60
54
|
/**
|
|
61
55
|
* Compat: accepted and ignored. Errors are always collected -- see
|
|
62
56
|
* shouldSample() for why -- so this only ever legitimately held `true`, and
|
|
@@ -307,8 +301,6 @@ declare class BidkernelPrebidAnalytics {
|
|
|
307
301
|
getEndpoint(): string;
|
|
308
302
|
getRefreshIndex(slotId: string): number;
|
|
309
303
|
triggerSlotRefresh(slotId: string, options?: SlotObserveOptions): void;
|
|
310
|
-
setPublisherLogLevel(level: string): void;
|
|
311
|
-
getPublisherLogLevel(): string;
|
|
312
304
|
trackRawEvent(level: string, eventName: string, data: any): void;
|
|
313
305
|
/**
|
|
314
306
|
* Record the wrapper's Live Floors decision for an auction and ad unit,
|
package/dist/index.d.ts
CHANGED
|
@@ -51,12 +51,6 @@ interface AnalyticsConfig {
|
|
|
51
51
|
region?: string;
|
|
52
52
|
auctionEnabled?: boolean;
|
|
53
53
|
warningsEnabled?: boolean;
|
|
54
|
-
/**
|
|
55
|
-
* Minimum log level collected for publisher report events (INFO | WARN | ERROR).
|
|
56
|
-
* ERROR is always collected by construction: it is the top of the ordering.
|
|
57
|
-
* Defaults to "INFO".
|
|
58
|
-
*/
|
|
59
|
-
publisherLogLevel?: "INFO" | "WARN" | "ERROR" | string;
|
|
60
54
|
/**
|
|
61
55
|
* Compat: accepted and ignored. Errors are always collected -- see
|
|
62
56
|
* shouldSample() for why -- so this only ever legitimately held `true`, and
|
|
@@ -307,8 +301,6 @@ declare class BidkernelPrebidAnalytics {
|
|
|
307
301
|
getEndpoint(): string;
|
|
308
302
|
getRefreshIndex(slotId: string): number;
|
|
309
303
|
triggerSlotRefresh(slotId: string, options?: SlotObserveOptions): void;
|
|
310
|
-
setPublisherLogLevel(level: string): void;
|
|
311
|
-
getPublisherLogLevel(): string;
|
|
312
304
|
trackRawEvent(level: string, eventName: string, data: any): void;
|
|
313
305
|
/**
|
|
314
306
|
* Record the wrapper's Live Floors decision for an auction and ad unit,
|
package/dist/index.js
CHANGED
|
@@ -355,12 +355,6 @@ var TraceEventType = {
|
|
|
355
355
|
* and were dropped for want of one, so warnings_enabled controlled nothing.
|
|
356
356
|
*/
|
|
357
357
|
WARN: 17,
|
|
358
|
-
/**
|
|
359
|
-
* PUBLISHER - A custom event recorded by publisher code via the sdk.report API.
|
|
360
|
-
* Carries its own event_name (prefixed pub:) and severity level on the wire,
|
|
361
|
-
* keeping wrapper telemetry separate from publisher volume in reporting.
|
|
362
|
-
*/
|
|
363
|
-
PUBLISHER: 18,
|
|
364
358
|
UNRECOGNIZED: -1
|
|
365
359
|
};
|
|
366
360
|
var BidderOutcome = {
|
|
@@ -592,8 +586,7 @@ function createBaseTraceEvent() {
|
|
|
592
586
|
eventId: new Uint8Array(0),
|
|
593
587
|
metadata: {},
|
|
594
588
|
viewableDurationMs: void 0,
|
|
595
|
-
bidderOutcomes: []
|
|
596
|
-
level: void 0
|
|
589
|
+
bidderOutcomes: []
|
|
597
590
|
};
|
|
598
591
|
}
|
|
599
592
|
var TraceEvent = {
|
|
@@ -636,9 +629,6 @@ var TraceEvent = {
|
|
|
636
629
|
BidderOutcomeEntry.encode(v, writer.uint32(98).fork()).join();
|
|
637
630
|
}
|
|
638
631
|
}
|
|
639
|
-
if (message.level !== void 0) {
|
|
640
|
-
writer.uint32(106).string(message.level);
|
|
641
|
-
}
|
|
642
632
|
return writer;
|
|
643
633
|
},
|
|
644
634
|
decode(input, length) {
|
|
@@ -738,13 +728,6 @@ var TraceEvent = {
|
|
|
738
728
|
}
|
|
739
729
|
continue;
|
|
740
730
|
}
|
|
741
|
-
case 13: {
|
|
742
|
-
if (tag !== 106) {
|
|
743
|
-
break;
|
|
744
|
-
}
|
|
745
|
-
message.level = reader.string();
|
|
746
|
-
continue;
|
|
747
|
-
}
|
|
748
731
|
}
|
|
749
732
|
if ((tag & 7) === 4 || tag === 0) {
|
|
750
733
|
break;
|
|
@@ -1084,14 +1067,8 @@ var LEVEL_TO_TYPE = {
|
|
|
1084
1067
|
};
|
|
1085
1068
|
var SELF_NAMING_TYPES = /* @__PURE__ */ new Set([
|
|
1086
1069
|
TraceEventType.ERROR,
|
|
1087
|
-
TraceEventType.WARN
|
|
1088
|
-
TraceEventType.PUBLISHER
|
|
1070
|
+
TraceEventType.WARN
|
|
1089
1071
|
]);
|
|
1090
|
-
var LEVEL_SEVERITY = {
|
|
1091
|
-
INFO: 1,
|
|
1092
|
-
WARN: 2,
|
|
1093
|
-
ERROR: 3
|
|
1094
|
-
};
|
|
1095
1072
|
var REVENUE_FLUSH_DELAY_MS = 3e3;
|
|
1096
1073
|
var REVENUE_FLUSH_TYPES = /* @__PURE__ */ new Set([
|
|
1097
1074
|
TraceEventType.IMPRESSION,
|
|
@@ -1464,8 +1441,7 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
1464
1441
|
logLevel: config.logLevel ? normalizeLogLevel(config.logLevel) : defaultLogger.getLevel(),
|
|
1465
1442
|
pbjsGlobalName: config.pbjsGlobalName || "pbjs",
|
|
1466
1443
|
attachPbjsListeners: config.attachPbjsListeners ?? true,
|
|
1467
|
-
revenueFlushDelayMs: Number.isFinite(config.revenueFlushDelayMs) && config.revenueFlushDelayMs >= 0 ? config.revenueFlushDelayMs : REVENUE_FLUSH_DELAY_MS
|
|
1468
|
-
publisherLogLevel: config.publisherLogLevel && (config.publisherLogLevel.toUpperCase() === "INFO" || config.publisherLogLevel.toUpperCase() === "WARN" || config.publisherLogLevel.toUpperCase() === "ERROR") ? config.publisherLogLevel.toUpperCase() : "INFO"
|
|
1444
|
+
revenueFlushDelayMs: Number.isFinite(config.revenueFlushDelayMs) && config.revenueFlushDelayMs >= 0 ? config.revenueFlushDelayMs : REVENUE_FLUSH_DELAY_MS
|
|
1469
1445
|
};
|
|
1470
1446
|
_BidkernelPrebidAnalytics.allInstances.add(this);
|
|
1471
1447
|
this.logger = createLogger({
|
|
@@ -2448,26 +2424,7 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2448
2424
|
this.observeSlot(record.element, slotId, options);
|
|
2449
2425
|
}
|
|
2450
2426
|
}
|
|
2451
|
-
setPublisherLogLevel(level) {
|
|
2452
|
-
const norm = level ? level.toUpperCase() : "INFO";
|
|
2453
|
-
if (norm === "INFO" || norm === "WARN" || norm === "ERROR") {
|
|
2454
|
-
this.config.publisherLogLevel = norm;
|
|
2455
|
-
} else {
|
|
2456
|
-
this.config.publisherLogLevel = "INFO";
|
|
2457
|
-
}
|
|
2458
|
-
}
|
|
2459
|
-
getPublisherLogLevel() {
|
|
2460
|
-
return this.config.publisherLogLevel || "INFO";
|
|
2461
|
-
}
|
|
2462
2427
|
trackRawEvent(level, eventName, data) {
|
|
2463
|
-
if (eventName && eventName.startsWith("pub:")) {
|
|
2464
|
-
const normLevel = level ? level.toUpperCase() : "";
|
|
2465
|
-
if (normLevel !== "INFO" && normLevel !== "WARN" && normLevel !== "ERROR") {
|
|
2466
|
-
return;
|
|
2467
|
-
}
|
|
2468
|
-
this.enqueue(TraceEventType.PUBLISHER, eventName, data, normLevel);
|
|
2469
|
-
return;
|
|
2470
|
-
}
|
|
2471
2428
|
const eventType = LEVEL_TO_TYPE[level] ?? EVENT_NAME_TO_TYPE[eventName];
|
|
2472
2429
|
if (eventType === void 0) return;
|
|
2473
2430
|
this.enqueue(eventType, eventName, data);
|
|
@@ -2860,9 +2817,9 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2860
2817
|
isDuplicate(eventName, data) {
|
|
2861
2818
|
return this.deduper.isDuplicate(eventName, data);
|
|
2862
2819
|
}
|
|
2863
|
-
enqueue(type, eventName, data
|
|
2820
|
+
enqueue(type, eventName, data) {
|
|
2864
2821
|
if (!this.isEnabled) return;
|
|
2865
|
-
if (!this.shouldSample(type
|
|
2822
|
+
if (!this.shouldSample(type)) return;
|
|
2866
2823
|
if (this.managesSessionId && sessionNeedsSync()) {
|
|
2867
2824
|
this.config.sessionId = getOrCreateSessionId();
|
|
2868
2825
|
}
|
|
@@ -2871,16 +2828,13 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2871
2828
|
timestampMs: Date.now(),
|
|
2872
2829
|
type,
|
|
2873
2830
|
// Typed events have a fixed name that ingest derives from `type`; only
|
|
2874
|
-
// ERROR
|
|
2831
|
+
// ERROR and WARN carry theirs, which names the failure or condition.
|
|
2875
2832
|
eventName: SELF_NAMING_TYPES.has(type) ? eventName : "",
|
|
2876
2833
|
auctionId: idToBytes(String(data.auctionId || "")),
|
|
2877
2834
|
transactionId: idToBytes(String(data.transactionId || "")),
|
|
2878
2835
|
adUnitCode: data.adUnitCode || data.elementId || "",
|
|
2879
2836
|
namespace: data.ns || data.namespace || ""
|
|
2880
2837
|
};
|
|
2881
|
-
if (type === TraceEventType.PUBLISHER && level) {
|
|
2882
|
-
protoEvent.level = level;
|
|
2883
|
-
}
|
|
2884
2838
|
if (data.bid) {
|
|
2885
2839
|
protoEvent.bid = {
|
|
2886
2840
|
bidder: data.bid.bidder || "",
|
|
@@ -2918,13 +2872,6 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2918
2872
|
);
|
|
2919
2873
|
}
|
|
2920
2874
|
const metadata = { ...data.metadata };
|
|
2921
|
-
if (type === TraceEventType.PUBLISHER && data) {
|
|
2922
|
-
for (const [k, v] of Object.entries(data)) {
|
|
2923
|
-
if (v !== void 0 && v !== null && metadata[k] === void 0 && k !== "metadata") {
|
|
2924
|
-
metadata[k] = typeof v === "object" ? JSON.stringify(v) : String(v);
|
|
2925
|
-
}
|
|
2926
|
-
}
|
|
2927
|
-
}
|
|
2928
2875
|
if (type === TraceEventType.BID_WIN || type === TraceEventType.IMPRESSION) {
|
|
2929
2876
|
const floor = this.floorDecisionFor(
|
|
2930
2877
|
String(data.auctionId || ""),
|
|
@@ -2962,7 +2909,7 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2962
2909
|
}, this.config.revenueFlushDelayMs);
|
|
2963
2910
|
}
|
|
2964
2911
|
}
|
|
2965
|
-
shouldSample(type
|
|
2912
|
+
shouldSample(type) {
|
|
2966
2913
|
if (type === TraceEventType.ERROR) {
|
|
2967
2914
|
this.errorCount++;
|
|
2968
2915
|
return this.errorCount <= MAX_ERRORS_PER_SESSION;
|
|
@@ -2970,12 +2917,6 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2970
2917
|
if (type === TraceEventType.WARN) {
|
|
2971
2918
|
return this.config.warningsEnabled;
|
|
2972
2919
|
}
|
|
2973
|
-
if (type === TraceEventType.PUBLISHER) {
|
|
2974
|
-
const minLevel = this.config.publisherLogLevel || "INFO";
|
|
2975
|
-
const minRank = LEVEL_SEVERITY[minLevel.toUpperCase()] ?? LEVEL_SEVERITY.INFO;
|
|
2976
|
-
const eventRank = LEVEL_SEVERITY[level?.toUpperCase() ?? ""] ?? 0;
|
|
2977
|
-
return eventRank >= minRank;
|
|
2978
|
-
}
|
|
2979
2920
|
return this.config.auctionEnabled;
|
|
2980
2921
|
}
|
|
2981
2922
|
requeue(events) {
|
package/dist/index.mjs
CHANGED
|
@@ -312,12 +312,6 @@ var TraceEventType = {
|
|
|
312
312
|
* and were dropped for want of one, so warnings_enabled controlled nothing.
|
|
313
313
|
*/
|
|
314
314
|
WARN: 17,
|
|
315
|
-
/**
|
|
316
|
-
* PUBLISHER - A custom event recorded by publisher code via the sdk.report API.
|
|
317
|
-
* Carries its own event_name (prefixed pub:) and severity level on the wire,
|
|
318
|
-
* keeping wrapper telemetry separate from publisher volume in reporting.
|
|
319
|
-
*/
|
|
320
|
-
PUBLISHER: 18,
|
|
321
315
|
UNRECOGNIZED: -1
|
|
322
316
|
};
|
|
323
317
|
var BidderOutcome = {
|
|
@@ -549,8 +543,7 @@ function createBaseTraceEvent() {
|
|
|
549
543
|
eventId: new Uint8Array(0),
|
|
550
544
|
metadata: {},
|
|
551
545
|
viewableDurationMs: void 0,
|
|
552
|
-
bidderOutcomes: []
|
|
553
|
-
level: void 0
|
|
546
|
+
bidderOutcomes: []
|
|
554
547
|
};
|
|
555
548
|
}
|
|
556
549
|
var TraceEvent = {
|
|
@@ -593,9 +586,6 @@ var TraceEvent = {
|
|
|
593
586
|
BidderOutcomeEntry.encode(v, writer.uint32(98).fork()).join();
|
|
594
587
|
}
|
|
595
588
|
}
|
|
596
|
-
if (message.level !== void 0) {
|
|
597
|
-
writer.uint32(106).string(message.level);
|
|
598
|
-
}
|
|
599
589
|
return writer;
|
|
600
590
|
},
|
|
601
591
|
decode(input, length) {
|
|
@@ -695,13 +685,6 @@ var TraceEvent = {
|
|
|
695
685
|
}
|
|
696
686
|
continue;
|
|
697
687
|
}
|
|
698
|
-
case 13: {
|
|
699
|
-
if (tag !== 106) {
|
|
700
|
-
break;
|
|
701
|
-
}
|
|
702
|
-
message.level = reader.string();
|
|
703
|
-
continue;
|
|
704
|
-
}
|
|
705
688
|
}
|
|
706
689
|
if ((tag & 7) === 4 || tag === 0) {
|
|
707
690
|
break;
|
|
@@ -1041,14 +1024,8 @@ var LEVEL_TO_TYPE = {
|
|
|
1041
1024
|
};
|
|
1042
1025
|
var SELF_NAMING_TYPES = /* @__PURE__ */ new Set([
|
|
1043
1026
|
TraceEventType.ERROR,
|
|
1044
|
-
TraceEventType.WARN
|
|
1045
|
-
TraceEventType.PUBLISHER
|
|
1027
|
+
TraceEventType.WARN
|
|
1046
1028
|
]);
|
|
1047
|
-
var LEVEL_SEVERITY = {
|
|
1048
|
-
INFO: 1,
|
|
1049
|
-
WARN: 2,
|
|
1050
|
-
ERROR: 3
|
|
1051
|
-
};
|
|
1052
1029
|
var REVENUE_FLUSH_DELAY_MS = 3e3;
|
|
1053
1030
|
var REVENUE_FLUSH_TYPES = /* @__PURE__ */ new Set([
|
|
1054
1031
|
TraceEventType.IMPRESSION,
|
|
@@ -1421,8 +1398,7 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
1421
1398
|
logLevel: config.logLevel ? normalizeLogLevel(config.logLevel) : defaultLogger.getLevel(),
|
|
1422
1399
|
pbjsGlobalName: config.pbjsGlobalName || "pbjs",
|
|
1423
1400
|
attachPbjsListeners: config.attachPbjsListeners ?? true,
|
|
1424
|
-
revenueFlushDelayMs: Number.isFinite(config.revenueFlushDelayMs) && config.revenueFlushDelayMs >= 0 ? config.revenueFlushDelayMs : REVENUE_FLUSH_DELAY_MS
|
|
1425
|
-
publisherLogLevel: config.publisherLogLevel && (config.publisherLogLevel.toUpperCase() === "INFO" || config.publisherLogLevel.toUpperCase() === "WARN" || config.publisherLogLevel.toUpperCase() === "ERROR") ? config.publisherLogLevel.toUpperCase() : "INFO"
|
|
1401
|
+
revenueFlushDelayMs: Number.isFinite(config.revenueFlushDelayMs) && config.revenueFlushDelayMs >= 0 ? config.revenueFlushDelayMs : REVENUE_FLUSH_DELAY_MS
|
|
1426
1402
|
};
|
|
1427
1403
|
_BidkernelPrebidAnalytics.allInstances.add(this);
|
|
1428
1404
|
this.logger = createLogger({
|
|
@@ -2405,26 +2381,7 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2405
2381
|
this.observeSlot(record.element, slotId, options);
|
|
2406
2382
|
}
|
|
2407
2383
|
}
|
|
2408
|
-
setPublisherLogLevel(level) {
|
|
2409
|
-
const norm = level ? level.toUpperCase() : "INFO";
|
|
2410
|
-
if (norm === "INFO" || norm === "WARN" || norm === "ERROR") {
|
|
2411
|
-
this.config.publisherLogLevel = norm;
|
|
2412
|
-
} else {
|
|
2413
|
-
this.config.publisherLogLevel = "INFO";
|
|
2414
|
-
}
|
|
2415
|
-
}
|
|
2416
|
-
getPublisherLogLevel() {
|
|
2417
|
-
return this.config.publisherLogLevel || "INFO";
|
|
2418
|
-
}
|
|
2419
2384
|
trackRawEvent(level, eventName, data) {
|
|
2420
|
-
if (eventName && eventName.startsWith("pub:")) {
|
|
2421
|
-
const normLevel = level ? level.toUpperCase() : "";
|
|
2422
|
-
if (normLevel !== "INFO" && normLevel !== "WARN" && normLevel !== "ERROR") {
|
|
2423
|
-
return;
|
|
2424
|
-
}
|
|
2425
|
-
this.enqueue(TraceEventType.PUBLISHER, eventName, data, normLevel);
|
|
2426
|
-
return;
|
|
2427
|
-
}
|
|
2428
2385
|
const eventType = LEVEL_TO_TYPE[level] ?? EVENT_NAME_TO_TYPE[eventName];
|
|
2429
2386
|
if (eventType === void 0) return;
|
|
2430
2387
|
this.enqueue(eventType, eventName, data);
|
|
@@ -2817,9 +2774,9 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2817
2774
|
isDuplicate(eventName, data) {
|
|
2818
2775
|
return this.deduper.isDuplicate(eventName, data);
|
|
2819
2776
|
}
|
|
2820
|
-
enqueue(type, eventName, data
|
|
2777
|
+
enqueue(type, eventName, data) {
|
|
2821
2778
|
if (!this.isEnabled) return;
|
|
2822
|
-
if (!this.shouldSample(type
|
|
2779
|
+
if (!this.shouldSample(type)) return;
|
|
2823
2780
|
if (this.managesSessionId && sessionNeedsSync()) {
|
|
2824
2781
|
this.config.sessionId = getOrCreateSessionId();
|
|
2825
2782
|
}
|
|
@@ -2828,16 +2785,13 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2828
2785
|
timestampMs: Date.now(),
|
|
2829
2786
|
type,
|
|
2830
2787
|
// Typed events have a fixed name that ingest derives from `type`; only
|
|
2831
|
-
// ERROR
|
|
2788
|
+
// ERROR and WARN carry theirs, which names the failure or condition.
|
|
2832
2789
|
eventName: SELF_NAMING_TYPES.has(type) ? eventName : "",
|
|
2833
2790
|
auctionId: idToBytes(String(data.auctionId || "")),
|
|
2834
2791
|
transactionId: idToBytes(String(data.transactionId || "")),
|
|
2835
2792
|
adUnitCode: data.adUnitCode || data.elementId || "",
|
|
2836
2793
|
namespace: data.ns || data.namespace || ""
|
|
2837
2794
|
};
|
|
2838
|
-
if (type === TraceEventType.PUBLISHER && level) {
|
|
2839
|
-
protoEvent.level = level;
|
|
2840
|
-
}
|
|
2841
2795
|
if (data.bid) {
|
|
2842
2796
|
protoEvent.bid = {
|
|
2843
2797
|
bidder: data.bid.bidder || "",
|
|
@@ -2875,13 +2829,6 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2875
2829
|
);
|
|
2876
2830
|
}
|
|
2877
2831
|
const metadata = { ...data.metadata };
|
|
2878
|
-
if (type === TraceEventType.PUBLISHER && data) {
|
|
2879
|
-
for (const [k, v] of Object.entries(data)) {
|
|
2880
|
-
if (v !== void 0 && v !== null && metadata[k] === void 0 && k !== "metadata") {
|
|
2881
|
-
metadata[k] = typeof v === "object" ? JSON.stringify(v) : String(v);
|
|
2882
|
-
}
|
|
2883
|
-
}
|
|
2884
|
-
}
|
|
2885
2832
|
if (type === TraceEventType.BID_WIN || type === TraceEventType.IMPRESSION) {
|
|
2886
2833
|
const floor = this.floorDecisionFor(
|
|
2887
2834
|
String(data.auctionId || ""),
|
|
@@ -2919,7 +2866,7 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2919
2866
|
}, this.config.revenueFlushDelayMs);
|
|
2920
2867
|
}
|
|
2921
2868
|
}
|
|
2922
|
-
shouldSample(type
|
|
2869
|
+
shouldSample(type) {
|
|
2923
2870
|
if (type === TraceEventType.ERROR) {
|
|
2924
2871
|
this.errorCount++;
|
|
2925
2872
|
return this.errorCount <= MAX_ERRORS_PER_SESSION;
|
|
@@ -2927,12 +2874,6 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2927
2874
|
if (type === TraceEventType.WARN) {
|
|
2928
2875
|
return this.config.warningsEnabled;
|
|
2929
2876
|
}
|
|
2930
|
-
if (type === TraceEventType.PUBLISHER) {
|
|
2931
|
-
const minLevel = this.config.publisherLogLevel || "INFO";
|
|
2932
|
-
const minRank = LEVEL_SEVERITY[minLevel.toUpperCase()] ?? LEVEL_SEVERITY.INFO;
|
|
2933
|
-
const eventRank = LEVEL_SEVERITY[level?.toUpperCase() ?? ""] ?? 0;
|
|
2934
|
-
return eventRank >= minRank;
|
|
2935
|
-
}
|
|
2936
2877
|
return this.config.auctionEnabled;
|
|
2937
2878
|
}
|
|
2938
2879
|
requeue(events) {
|
package/package.json
CHANGED