cdn-adm.pbstck.com Open in urlscan Pro
2606:4700:10::ac43:1997  Public Scan

URL: https://cdn-adm.pbstck.com/kleanads/js/kleanads-2408051036.js
Submission: On August 06 via api from IT — Scanned from IT

Form analysis 0 forms found in the DOM

Text Content

var kleanads=function(e){"use strict";var t,i,n;!function(e){e.HISTORY_MUTATION="_pbstck_kleanads_historyMutation",e.PAGE_CHANGE="_pbstck_kleanads_pageChange",e.REFRESH_INIT="_pbstck_kleanads_refreshInit"}(t||(t={})),function(e){e.SPA_RELOAD="admSPAReload"}(i||(i={})),function(e){e.REPLACE_STATE="replaceState",e.PUSH_STATE="pushState"}(n||(n={}));const s=e=>{window.history[e]=new Proxy(window.history[e],{apply(i,n,s){const o=window.location.href,r=i.apply(n,s),a=new CustomEvent(t.HISTORY_MUTATION,{detail:{referrer:o,stateObj:s[0],title:s[1],url:s[2],type:e}});return dispatchEvent(a),r}})},o=()=>{s(n.REPLACE_STATE),s(n.PUSH_STATE)};var r;const a=/kleanads:debug/.test(window.location.href),d=!!(null===(r=window.localStorage)||void 0===r?void 0:r.getItem)&&null!==window.localStorage.getItem("kleanads");function l(){return a||d}function c(e,t){return`[${e}] [${performance.now().toFixed(2)}] ${t}`}function u(e,t,...i){l()&&console.log(c(e,t),...i)}function f(e,t,...i){l()&&console.debug(c(e,t),...i)}function h(e,t,...i){l()&&console.error(c(e,t),...i)}function g(e,t){const i={type:"customEvent",eventName:e,message:t};window.postMessage(i,"*")}class p{constructor(e,t,i,n=1){this.tagId=e,this.kleanadsVersion=t,this.throttling=n,this.device=i||"na"}handleMessage(e,t,i){const n={source:"kleanads",type:"log",level:e,message:t,tagId:this.tagId,kleanadsVersion:this.kleanadsVersion,href:window.location.href,device:this.device,...i};var s,o;s=n,o=this.throttling,100*Math.random()<o&&navigator.sendBeacon("https://intake.pbstck.com/v1/trace",JSON.stringify(s))}error(e){this.handleMessage("error",e)}warn(e){this.handleMessage("warn",e)}logWithPayload(e,t){this.handleMessage("info",e,t)}}const v="kleanads";let m,b="na",y="na",C="na";function w(e,...t){u(v,e,...t)}function A(e,...t){f(v,e,...t)}function S(e,...t){!function(e,t,...i){l()&&console.warn(c(e,t),...i)}(v,e,...t),null==m||m.warn(e)}function I(e,...t){h(v,e,...t),null==m||m.error(e),navigator.sendBeacon(`https://intake.pbstck.com/v1/intake/error?tId=${b}&v=${y}&s=${C}&c=1`,JSON.stringify([{message:e}]))}function k(e,t){null==m||m.logWithPayload(e,t)}function E(e){return null!==document.getElementById(e)}function $(e){const t=document.getElementById(e);if(t){return t.getBoundingClientRect().top}return w(`[DOM] div ${e} not found during get distance from top`),0}function O(e,t){return new Promise(((i,n)=>e().then(i).catch((i=>{return t>1?(s=100,new Promise((e=>setTimeout(e,s)))).then(O.bind(null,e,t-1)).then((e=>e)).catch(n):n(i);var s}))))}const T=async(e,t=3)=>O((()=>import(e)),t).then((e=>e)).catch((i=>{throw I(`Failed to load module ${e} after ${t} retries`,i),new Error("Too many failed attempt to load external module.")})),_=(e,t)=>{const i=function(e,t){const i=document.createElement("script");return i.setAttribute("src",e),i}(e);i.setAttribute("async","true"),i.setAttribute("data-kleanads","true"),document.head.append(i)};async function R(e,t){const{beforeStart:i}=t,n=function(e,t){var i;return(null!==(i=e.extraScripts)&&void 0!==i?i:[]).filter((i=>i.tagId===e.tagId&&!!i.beforeStart===t))}(e,i);if(n.length>0){w(i?"Loading extraScripts before config":"Loading extraScripts after consent");const e=n.filter((({synchronous:e})=>!e)).flatMap((e=>e.scripts)),t=n.filter((({synchronous:e})=>e)).flatMap((e=>e.scripts));w(`downloading async extra script ${e}`),e.forEach((e=>_(e))),w(`downloading sync extra script ${t}`);for(const e of t)try{await T(e)}catch(e){w("[extra-script] Error while loading sync extra script",e)}}}function L(e,t){return e.size<t.size?1:e.size>t.size?-1:0}function U(e){return e.filter(N)}function x(e){if("fluid"===e)return"fluid";const[t,i]=e.split("x");return[parseInt(t,10),parseInt(i,10)]}function P(e){return e>=100||e>=Math.floor(100*Math.random())+1}function N(e){return Array.isArray(e)&&2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]}const j=(e,t)=>("master"===e.roadblock?0:1)-("master"===t.roadblock?0:1)||$(e.divId)-$(t.divId);for(var D,B=[],M=0;M<256;++M)B.push((M+256).toString(16).slice(1));var F=new Uint8Array(16);function z(){if(!D&&!(D="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return D(F)}var W,V={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function G(e,t,i){if(V.randomUUID&&!t&&!e)return V.randomUUID();var n=(e=e||{}).random||(e.rng||z)();return n[6]=15&n[6]|64,n[8]=63&n[8]|128,function(e,t=0){return(B[e[t+0]]+B[e[t+1]]+B[e[t+2]]+B[e[t+3]]+"-"+B[e[t+4]]+B[e[t+5]]+"-"+B[e[t+6]]+B[e[t+7]]+"-"+B[e[t+8]]+B[e[t+9]]+"-"+B[e[t+10]]+B[e[t+11]]+B[e[t+12]]+B[e[t+13]]+B[e[t+14]]+B[e[t+15]]).toLowerCase()}(n)}function H(e){const t=document.createElement("meta");t.setAttribute("name","pbstck_context:pbstck_ab_test"),t.content=e,document.head.appendChild(t)}function J(e,t){const i=document.createElement("meta");i.setAttribute("name",`pbstck:${e}`),i.content=t,document.head.appendChild(i)}function K(e){const t={};e.document.querySelectorAll('meta[name^="ad:"]').forEach((e=>{const i=function(e){var t;const i=(null===(t=e.attributes.getNamedItem("name"))||void 0===t?void 0:t.value)||"";return i.startsWith("ad:")?i.slice(3):i}(e);i&&(t[i]=function(e){var t;const i=(null===(t=e.attributes.getNamedItem("content"))||void 0===t?void 0:t.value)||"";return i.split(",")}(e))}));const i=new URLSearchParams(e.location.search);for(const e of i.keys())e.startsWith("ad:")&&(u("kleanads-common",`Add key ${e} found in URL to metaTargetings`),t[e.slice(3)]=i.getAll(e));return t}function q(){const e=document.head.querySelector('meta[name="ad:no_cmp"]');return!!e&&"true"===e.content}!function(e){e.USE_EXISTING_DIV="useExistingDiv",e.CREATE_NEW_DIV="createNewDiv"}(W||(W={}));const X=(e,t)=>"fluid"===e&&"fluid"===t||e[0]===t[0]&&e[1]===t[1],Y=e=>!!e.sizes.find((e=>X(e,[1800,1e3])));function Q(e){var t;const i=null!==(t=e.values)&&void 0!==t?t:[];return e.value?e.value:i}function Z(){window.sublime=window.sublime||{};const e=window.sublime.notifyId||G();return window.sublime.notifyId=e,e}const ee=(e,t)=>({...e,bids:t,mediaTypes:{video:{mimes:["video/mp4","video/webm","application/javascript"],context:"instream",playerSize:[640,480]}}}),te=(e,t,i)=>({...t,bids:i.filter((t=>e.biddersOutstream.includes(t.bidder))),mediaTypes:{video:{context:"outstream",playerSize:[640,480],mimes:["video/mp4","video/ogg","video/webm","application/javascript"],protocols:[1,2,3,4,5,6,7,8,11,12,13,14],api:[1,2,3,5,6,7],playbackmethod:[2,3,4],skip:1,linearity:2,startdelay:0,placement:3,plcmt:4,maxduration:30,playVideoVisibleThreshold:25,nonViewableBehavior:"pause"}},renderer:{url:"https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js",options:{adText:"",aspectRatio:"16:9",skippable:{enabled:!0,skipButtonText:"SKIP"}}}}),ie=e=>{var t;const i=[];return e.isInstream?["Instream"]:((e.sizes.length>0||(null!==(t=e.extraAdServerSizes)&&void 0!==t?t:[]).length>0)&&i.push("Banner"),e.canOutstream&&i.push("Outstream"),i)},ne=["adyoulike"],se=(e,t,i)=>{const n=e.biddersSkin?i.filter((t=>{var i;return null===(i=e.biddersSkin)||void 0===i?void 0:i.includes(t.bidder)})):i,s={...t,bids:n.filter((e=>!ne.includes(e.bidder))),mediaTypes:{banner:{sizes:[[1800,1e3]]}}},o=U(e.sizes).filter((e=>!X(e,[1800,1e3])));if(o.length>0){return[{...t,bids:i,mediaTypes:{banner:{sizes:o}}},s]}return[s]},oe=(e,t,i)=>({...t,bids:i,mediaTypes:{banner:{sizes:U(e.sizes)}}});function re(e,t,i){var n;const s=e.bidders.map((e=>function(e,t){var i;return"sublime"===e.bidder||e.bidder===(null===(i=null==t?void 0:t.find((e=>"sublime"===e.bidderSource)))||void 0===i?void 0:i.bidderLabel)?(u("common","[Sublime] generate notify id"),{...e,params:{...e.params,notifyId:Z()}}):e}(e,t))),o=e.floors;o&&i&&(o.values.banner=Math.max(o.values.banner,i));const r={code:e.divId,pubstack:{adUnitName:e.adServerAdUnitName,adUnitPath:ae(e)},floors:o,ortb2Imp:e.ortb2Imp},a=e.getTargetings();if(a.find((e=>"ad_index"===e.key))){const e=null===(n=a.find((e=>"ad_index"===e.key)))||void 0===n?void 0:n.value;r.pubstack&&(r.pubstack.tags=[`ad_index:${e}`])}const d=ie(e);if(d.includes("Instream"))return[ee(r,s)];const l=[];return d.includes("Banner")&&(Y(e)?l.push(...se(e,r,s)):l.push(oe(e,r,s))),d.includes("Outstream")&&l.push(te(e,r,s)),l}function ae(e){var t;const i=[...e.getTargetings()],n=(null!==(t=e.pubstackDeclarationTargetingKeys)&&void 0!==t?t:[]).map((e=>{const t=i.find((t=>t.key===e));if(t)return t;{const t=K(window)[e];return t?{key:e,values:t}:void 0}})).filter((e=>!!e)).map((e=>`${e.key}=${function(e){const t=e.values?e.values.join(","):"";return e.value?e.value:t}(e)}`)).join("&"),s=e.adUnitPath.includes("?")?"&":"?";return n.length>0?`${e.adUnitPath}${s}${n}`:e.adUnitPath}const de="adServerAdUnitName";function le(e,t,i,n){const s=[];if("number"!=typeof t&&""===t||s.push(t),i&&0!==i.length){const e=function(e,t){return e.filter((e=>e!==de)).map((e=>t.get(e))).filter((e=>e)).join("/")}(i,n);e&&s.push(e)}else S("Ad unit path config is missing for this site");const o=`/${s.join("/")}`;return i&&i.includes(de)?`${o}/${e}`:`${o}`}function ce(e){return e&&"string"==typeof e?e:void 0}function ue(e){if(null!=e&&"number"==typeof e)return e}function fe(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function he(e){return new Promise(((t,i)=>{if(window.lucead_loaded)return void t();window.lucead_loaded=!0;const n=document.createElement("script");n.src=`https://s.lucead.com/prebid/${e}.js`,n.onload=()=>t(window.lucead_prebid),n.onerror=i,document.head.appendChild(n)}))}function ge(e){var t,i,n,s,o,r,a,d,l;if(!fe(e))throw new Error("unable to parse JSON: adUnit is not valid");const c=pe(e.divId,"divId"),u=pe(e.adUnitName,"adUnitName"),f=function(e,t){if(!Array.isArray(e))throw new Error(`Unable to parse JSON: the ${t} field ${e} is not a valid list of Size`);return e}(e.sizes,"sizes"),h=function(e,t){if(!Array.isArray(e))throw new Error(`Unable to parse JSON: the ${t} field ${e} is not a valid list of PrebidBidder`);for(const t of e)if("string"!=typeof t.bidder)throw new Error(`Unable to parse JSON: the bidder field ${t.bidder} (inside bidders) is not a valid bidder name`);return e}(e.bidders,"bidders"),g=ve(e.parallax,"parallax",!1),p=ve(e.dynamic,"dynamic",!1),v=ve(e.sticky,"sticky",!1),m=me(e.targeting,"targeting"),b=function(e,t){if(!e)return;if(!Array.isArray(e))throw new Error(`Unable to parse JSON: the ${t} field ${e} is not valid KeyValueTargeting list`);const i=[];for(const n of e){const e=me(n,t);e&&i.push(e)}return i}(e.extraTargetings,"extraTargetings");if(void 0!==e.floors&&!fe(e.floors))throw new Error("unable to parse JSON: the floors field is not valid");if(void 0!==(null===(t=e.floors)||void 0===t?void 0:t.currency)&&"string"!=typeof(null===(i=e.floors)||void 0===i?void 0:i.currency))throw new Error("unable to parse JSON: the floors field is missing the currency");if(void 0!==(null===(n=e.floors)||void 0===n?void 0:n.schema)&&!fe(null===(s=e.floors)||void 0===s?void 0:s.schema))throw new Error("unable to parse JSON: the floors field is missing the schema");if(e.floors){if("string"!=typeof(null===(o=e.floors.schema)||void 0===o?void 0:o.delimiter))throw new Error("unable to parse JSON: the floors schema field is missing the delimiter");if(!Array.isArray(null===(r=e.floors.schema)||void 0===r?void 0:r.fields))throw new Error("unable to parse JSON: the floors field schema delimiter is not an array");for(const t of e.floors.schema.fields)if(void 0===t||"string"!=typeof t)throw new Error("unable to parse JSON: the bidder field inside bidders array is not valid")}if(void 0!==(null===(a=e.floors)||void 0===a?void 0:a.values)&&"object"!=typeof(null===(d=e.floors)||void 0===d?void 0:d.values))throw new Error("unable to parse JSON: the floors field is missing the values or they are not well formed");if(void 0!==e.extraAdServerSizes&&!Array.isArray(e.extraAdServerSizes))throw new Error(`unable to parse JSON: the extraAdServerSizes field for adunit ${c} is not valid: ${e.extraAdServerSizes}`);let y,C,w,A;if(void 0!==e.canOutstream&&"boolean"!=typeof e.canOutstream)throw new Error("unable to parse JSON: the canOutstream field is not valid");if(y=e.canOutstream,void 0!==e.isInstream&&"boolean"!=typeof e.isInstream)throw new Error("unable to parse JSON: the isInstream field is not valid");if(C=e.isInstream,e.biddersOutstream){if(!Array.isArray(e.biddersOutstream))throw new Error(`unable to parse JSON: the biddersOutstream field for adunit ${c} is not valid: ${e.biddersOutstream}`);for(const t of e.biddersOutstream)if("string"!=typeof t)throw new Error("unable to parse JSON: the value inside biddersOutstream array is not valid")}switch(e.outOfPageType){case"interstitial":case"default":w=e.outOfPageType;break;default:w=void 0}switch(e.roadblock){case"master":case"companion":A=e.roadblock;break;default:A=void 0}return{divId:c,adUnitName:u,sizes:f,adServerAdUnitName:e.adServerAdUnitName,slotName:e.slotName,bidders:h,parallax:g,dynamic:p,targeting:m,extraTargetings:b,sticky:v,stickyDivCreation:!!e.stickyDivCreation,anchor:e.anchor,floors:e.floors,extraAdServerSizes:e.extraAdServerSizes,headerBiddingEnabled:ve(e.headerBiddingEnabled,"headerBiddingEnabled",!0),canOutstream:y,isInstream:C,biddersOutstream:null!==(l=e.biddersOutstream)&&void 0!==l?l:[],outOfPageType:w,roadblock:A}}function pe(e,t){if("string"!=typeof e)throw new Error(`Unable to parse JSON: the ${t} field ${e} is not a valid string`);return e}function ve(e,t,i){if(void 0!==e&&"boolean"!=typeof e)throw new Error(`Unable to parse JSON: the ${t} field ${e} is not a valid boolean`);return null!=e?e:i}function me(e,t){if(!e)return;if(!fe(e))throw new Error(`Unable to parse JSON: the ${t} field ${e} is not a valid KeyValueTargeting`);const i=pe(e.key,t),n=ce(e.value),s=function(e){if(e&&Array.isArray(e))return e}(e.values);if(!n&&!s)throw new Error(`Unable to parse JSON: targeting.value(s) is not valid for field ${t}`);return{key:i,value:n,values:s}}function be(e,t,i,n,s){return e.flatMap((e=>{var o,r,a,d,l,c,u;const f=le(e.adServerAdUnitName||e.divId,i,n,t);if(e.bidders.forEach((e=>{var t;if("lucead"===e.bidder&&(null===(t=e.params)||void 0===t?void 0:t.siteId)){const{siteId:t,...i}=e.params,n={...i,loader:he(t)};e.params=n}})),e.dynamic)return function(e,t,i){return function(e){const t=e.divId.startsWith("css:")?e.divId.replace("css:",""):`[id^="${e.divId}"]`;try{return Array.from(document.querySelectorAll(t))}catch(e){return I(`${t} is not a valid CSS selector`),[]}}(e).map((n=>{var s,o,r,a;const d=n.id;return{...e,canOutstream:null!==(s=e.canOutstream)&&void 0!==s&&s,isInstream:null!==(o=e.isInstream)&&void 0!==o&&o,divId:d,slotName:e.slotName||t,dynamic:!1,adUnitPath:(null===(r=null==n?void 0:n.attributes.getNamedItem("data-adunitpath"))||void 0===r?void 0:r.value)||t,adServerAdUnitName:null!==(a=e.adServerAdUnitName)&&void 0!==a?a:e.divId,pubstackDeclarationTargetingKeys:null!=i?i:[],getTargetings:()=>[...[...e.targeting?[e.targeting]:[],...e.extraTargetings||[]],...[...Ce(null==n?void 0:n.attributes),ye(d)]]}}))}(e,f,s);{const t=function(e){const t=e.startsWith("css:")?e.replace("css:",""):void 0;try{return t?document.querySelector(t):document.getElementById(e)}catch(t){return I(`${e} is not a valid CSS selector`),null}}(e.divId);if(t||"interstitial"===e.outOfPageType||e.sticky&&e.stickyDivCreation||(null===(o=e.anchor)||void 0===o?void 0:o.mode)===W.CREATE_NEW_DIV){return[{...e,divId:null!==(r=null==t?void 0:t.id)&&void 0!==r?r:e.divId,canOutstream:null!==(a=e.canOutstream)&&void 0!==a&&a,isInstream:null!==(d=e.isInstream)&&void 0!==d&&d,adUnitPath:(null===(l=null==t?void 0:t.attributes.getNamedItem("data-adunitpath"))||void 0===l?void 0:l.value)||f,slotName:e.slotName||f,adServerAdUnitName:null!==(u=null!==(c=e.adServerAdUnitName)&&void 0!==c?c:null==t?void 0:t.id)&&void 0!==u?u:e.divId,pubstackDeclarationTargetingKeys:null!=s?s:[],getTargetings:()=>[...[...e.targeting?[e.targeting]:[],...e.extraTargetings||[]],...[...Ce(null==t?void 0:t.attributes)]]}]}return w(`Div id missing for ${e.divId}, no further action on this ad unit`),[]}}))}function ye(e){const t=new RegExp("\\D","g");return{key:"ad_index",value:e.replace(t,"")}}function Ce(e){return Array.from(null!=e?e:[]).filter((e=>e.name.startsWith("data-ad-"))).map((e=>({key:e.name.replace("data-ad-",""),value:e.value})))}var we;!function(e){e.Stop="stop",e.Continue="continue",e.InstantSecondChance="instantSecondChance"}(we||(we={}));const Ae={advertisers:[],orders:[],lineItems:[]};var Se,Ie;function ke(e){if(!e)return;if(!fe(e))throw new Error("unable to parse JSON: lazyLoadingGoogle field is not valid");if(0===Object.keys(e).length||!e.googleFetchMarginPercent&&!e.googleRenderMarginPercent&&!e.googleMobileScaling)return{};const t={};return"number"==typeof e.googleFetchMarginPercent&&(t.googleFetchMarginPercent=e.googleFetchMarginPercent),"number"==typeof e.googleRenderMarginPercent&&(t.googleRenderMarginPercent=e.googleRenderMarginPercent),"number"==typeof e.googleMobileScaling&&(t.googleMobileScaling=e.googleMobileScaling),t}function Ee(e){if(null==e)return;if(!fe(e))throw new Error("unable to parse JSON: lazyLoadingKleanads field is not valid");let t;return"number"!=typeof e.viewportPercent?e.numberOfViewports&&"number"==typeof e.numberOfViewports?t=e.numberOfViewports:(S("unable to parse JSON: the lazyLoadingKleanads field is not valid, falling back to 0 viewport"),t=0):t=e.viewportPercent,{viewportPercent:t}}function $e(e){if(null!=e){if(!fe(e))throw new Error("unable to parse JSON: lazyLoading field is not valid");if("string"!=typeof e.configName)throw new Error("unable to parse JSON: the lazyLoading's configName field is not valid");return{configName:e.configName,lazyLoadingGoogle:ke(e.lazyLoadingGoogle),lazyLoadingKleanads:Ee(e.lazyLoadingKleanads)}}}function Oe(e){if(!Array.isArray(e))throw new Error("unable to parse JSON: the adUnits field is not valid");const t=[];for(const i of e)try{t.push(ge(i))}catch(e){I("Invalid ad unit configuration",e)}return t}function Te(e){if(!e)return;if(!fe(e))throw new Error("unable to parse JSON: the refreshConfig field is not valid");if(!Array.isArray(e.adUnitConfig))throw new Error("unable to parse JSON: the refreshConfig field is not valid");const t=[];for(const i of e.adUnitConfig)try{t.push(_e(i))}catch(e){I("Invalid refresh configuration",e)}return{adUnitConfig:t}}function _e(e){if(!fe(e))throw new Error("unable to parse JSON: the adUnitRefreshConfig field is not valid");if(!Array.isArray(e.specificRules))throw new Error("unable to parse JSON: the adUnitRefreshConfig specificRules field is not valid");if("number"!=typeof e.timer)throw new Error("unable to parse JSON: the adUnitRefreshConfig timer field is not valid");if(void 0===e.adUnitNames)throw new Error("unable to parse JSON: the adUnitRefreshConfig adUnitNames field is missing");if(!Array.isArray(e.adUnitNames))throw new Error("unable to parse JSON: the adUnitRefreshConfig adUnitNames field is not valid");if(void 0!==e.alwaysInView&&"boolean"!=typeof e.alwaysInView)throw new Error("unable to parse JSON: the adUnitRefreshConfig alwaysInView field is not valid");let t,i;if(void 0!==e.refreshBehaviorOnEmpty)switch(e.refreshBehaviorOnEmpty){case"continue":t=we.Continue;break;case"instantSecondChance":t=we.InstantSecondChance;break;case"stop":t=we.Stop;break;default:throw new Error("unable to parse JSON: the adUnitRefreshConfig refreshBehaviorOnEmpty field is not valid")}if(void 0!==e.refreshOutOfFocusConfig){if(!fe(e.refreshOutOfFocusConfig))throw new Error("unable to parse JSON: the adUnitRefreshConfig refreshOutOfFocusConfig field is not valid");if(void 0===e.refreshOutOfFocusConfig.timerInView||"number"!=typeof e.refreshOutOfFocusConfig.timerInView)throw new Error("unable to parse JSON: the adUnitRefreshConfig refreshOutOfFocusConfig timerInView field is not valid");if(void 0!==e.refreshOutOfFocusConfig.refreshOutOfView&&"boolean"!=typeof e.refreshOutOfFocusConfig.refreshOutOfView)throw new Error("unable to parse JSON: the adUnitRefreshConfig refreshOutOfFocusConfig refreshOutOfView field is not valid");i={timerInView:e.refreshOutOfFocusConfig.timerInView,refreshOutOfView:e.refreshOutOfFocusConfig.refreshOutOfView}}return{adUnitNames:e.adUnitNames,timer:e.timer,capping:ue(e.capping),specificRules:e.specificRules,alwaysInView:e.alwaysInView,refreshBehaviorOnEmpty:t,refreshOutOfFocusConfig:i}}function Re(e){if(!function(e){if(!e)throw new Error("unable to parse JSON: prebidConfig field is not valid");return Object.keys(e).includes("adCallTimeout")&&Object.keys(e).includes("pbjsConfig")}(e))throw new Error("unable to parse JSON: prebidConfig field is not valid");if("number"!=typeof e.adCallTimeout)throw new Error("unable to parse JSON: the prebidConfig's adCallTimeout field is not valid");return{adCallTimeout:e.adCallTimeout,pbjsConfig:Le(e.pbjsConfig)}}function Le(e){if(!fe(e))throw new Error("unable to parse JSON: pbjsConfig field is not valid");void 0===e.allowLocalStorage&&(e.allowLocalStorage=!0);const t=Ue(e,"userSync"),i=Ue(e,"outbrain"),n=Ue(e,"realTimeData"),s=Ue(e,"analytics"),o=Ue(e,"currency"),r=Ue(e,"bidderConfigs"),a=Ue(e,"priceGranularity"),d=Ue(e,"floors"),l=Ue(e,"schain"),c=function(e){if(e&&Array.isArray(e))return e}(e.bidderAliases);return{...e,...c&&{bidderAliases:c},...t&&{userSync:t},...i&&{outbrain:i},...n&&{realTimeData:n},...s&&{analytics:s},...r&&{bidderConfigs:r},...o&&{currency:o},...a&&{priceGranularity:a},...d&&{floors:d},...l&&{schain:l}}}!function(e){e.firstId="firstId",e.utiqId="utiqId",e.sharedId="sharedId"}(Se||(Se={})),function(e){e.id5id="id5Id"}(Ie||(Ie={}));const Ue=(e,t)=>{if(!(t in e))return;const i=ce(e[t]);if(i)try{return JSON.parse(i)}catch(e){I(`unable to parse JSON in pbjsConfigFromPartial: ${t} `,e)}};async function xe(e,t,i,n){const s=function(e,t,i,n){const s=function(e,t,i,n,s){return`${e}/config/${t.scopeId.substring(0,8)}/${n.substring(0,8)}/${t.stackId}/${i}/${s}.json`}(e.configUrl,i,n,e.tagId,t);return s.replace(/([^:]\/)\/+/g,"$1")}(e,t,i,n);return new Promise((e=>{fetch(s).then((t=>{t.text().then((async t=>{const i=function(e){const t=JSON.parse(e);return{...t,lazyLoading:$e(t.lazyLoading),adUnits:Oe(t.adUnits),prebidConfig:Re(t.prebidConfig),refreshConfig:Te(t.refreshConfig)}}(t);e(i)}))})).catch((async t=>{I(`unable to load the configuration ${t}`),e(void 0)}))}))}var Pe,Ne,je;!function(e){e.BEGIN_INIT="begin_init",e.CMP_RESPONSE_AVAILABLE="cmp_response_available",e.MAIN_THREAD_END="main_thread_end",e.GOOGLETAG_READY="googletag_ready",e.APSTAG_READY="apstag_ready",e.PREBID_READY="prebid_ready"}(Pe||(Pe={})),function(e){e.BEGIN_CONFIGURE="begin_configure",e.BEGIN_START="begin_start",e.SPA_RELOAD="spa_reload"}(Ne||(Ne={})),function(e){e.START_AUCTION="start_auction",e.END_PBJS_AUCTION="end_pbjs_auction",e.END_APS_AUCTION="end_aps_auction",e.START_AD_SERVER_CALL="start_ad_server_call",e.SLOT_RENDER_ENDED_TIME="slot_render_ended_time",e.SLOT_RESPONSE_RECEIVED_TIME="slot_response_received_time"}(je||(je={}));const De=[],Be=[],Me="getEntriesByName"in performance&&"measure"in performance&&"mark"in performance;function Fe(e){De.includes(e)||(Xe(e),De.push(e))}function ze(e){Xe(e)}function We(e,t){const i=qe(e,t);Be.includes(i)||(Xe(i),Be.push(i))}function Ve(e){return function(e){if(Me)return performance.getEntriesByName(e).map((e=>e.startTime));return[]}(e)}function Ge(e){if(De.includes(e))return function(e){if(Me)return performance.getEntriesByName(e)[0].startTime;return}(e)}function He(e,t){if(De.includes(e)&&De.includes(t))return Ye(e,t)}function Je(e,t,i){const n=qe(e,i);if(De.includes(t)&&Be.includes(n))return Ye(t,n)}function Ke(e,t,i){const n=qe(e,t),s=qe(e,i);if(Be.includes(n)&&Be.includes(s))return Ye(n,s)}function qe(e,t){return`${e}_${t}`}function Xe(e){Me&&(performance.mark(e.toString()),w(`[performance] [mark] ${e}: ${performance.getEntriesByName(e)[0].startTime.toFixed(2)}`))}function Ye(e,t){if(Me){const i=`measure_${e}_${t}`,n=performance.getEntriesByName(i);if(0!==n.length&&"measure"===n[0].entryType)return n[0].duration;try{return performance.measure(i,e,t).duration}catch{return}}}var Qe;!function(e){e.UNKNOWN="unknown",e.WAIT_USER_CONSENT="wait_user_consent",e.WAIT_USER_REFUSED="wait_user_refused"}(Qe||(Qe={}));let Ze=Qe.UNKNOWN;function et(e){Ze=e}const tt=[];function it(e,t){tt.includes(e)||(k("[metric] adunit",{...ot(e,t)}),tt.push(e))}const nt=new Map;function st(e){const t=function(e){const t=performance.getEntriesByName(e);return t.length>0&&"mark"===t[0].entryType}(Pe.GOOGLETAG_READY);nt.set(e,t)}function ot(e,t){return{adUnit:e,consentType:Ze,eventOrigin:t,startAuctionFromConsent:Je(e,Pe.CMP_RESPONSE_AVAILABLE,je.START_AUCTION),pbjsAuctionDuration:Ke(e,je.START_AUCTION,je.END_PBJS_AUCTION),apsAuctionDuration:Ke(e,je.START_AUCTION,je.END_APS_AUCTION),startAdServerCallFromConsent:Je(e,Pe.CMP_RESPONSE_AVAILABLE,je.START_AD_SERVER_CALL),slotRenderEndedFromConsent:Je(e,Pe.CMP_RESPONSE_AVAILABLE,je.SLOT_RENDER_ENDED_TIME),adServerResponseDuration:Ke(e,je.START_AD_SERVER_CALL,je.SLOT_RESPONSE_RECEIVED_TIME),totalAdCallDuration:Ke(e,je.START_AUCTION,je.SLOT_RENDER_ENDED_TIME),isGoogletagReadyAtPbjsAuctionEnd:nt.get(e)}}function rt(){const e=Ge(Pe.BEGIN_INIT),t=Ve(Ne.BEGIN_CONFIGURE),i=Ve(Ne.BEGIN_START),n=Ve(Ne.SPA_RELOAD),s=function(e){if(e.length>=2)return e[e.length-1]-e[e.length-2];return}(n),o={countSpaReloads:n.length,countConfigures:t.length,countStarts:i.length};e&&t.length>0&&(o.initToConfigure=t[t.length-1]-e),t.length>0&&i.length>0&&(o.configureToStart=i[i.length-1]-t[t.length-1]),s?o.diffSpaReload=s:t[0]&&n[0]&&(o.diffSpaReload=n[0]-t[0]),k("[metric] start",o)}function at(e){return new Promise(((t,i)=>{!function(e,t,i){(n=e,new Promise(((e,t)=>dt(n,e)))).then((()=>{try{!function(e,t){const i=function(e){return e.__tcfapi}(e);i("addEventListener",2,(e=>{if(e&&("useractioncomplete"===e.eventStatus||"tcloaded"===e.eventStatus)){w("[consent] Consent status ",e.eventStatus),Fe(Pe.CMP_RESPONSE_AVAILABLE);const i=function(e){if(!e.purpose.consents||0===Object.keys(e.purpose.consents).length)return!1;for(const t in e.purpose.consents)if(!e.purpose.consents[t])return!1;return!0}(e);et(i?Qe.WAIT_USER_CONSENT:Qe.WAIT_USER_REFUSED),t(i)}}))}(e,t)}catch(e){w("[consent] Error while loading tcf api"),i(e)}})).catch((e=>{w("[consent] Error while loading tcf api",e),i(e)}));var n}(e,t,i)}))}function dt(e,t,i){const n=e.__tcfapi;n&&function(e){if("function"!=typeof e)throw new Error("__tcfapi is not a function");return!0}(n)?t():setTimeout((()=>dt(e,t)),100)}function lt(e){return e.map((e=>({key:e.key.toLowerCase(),defaultValue:e.defaultValue?e.defaultValue.toLowerCase():void 0,otherValues:e.otherValues?e.otherValues.map((e=>e.toLowerCase())):[]})))}function ct(e,t,i){(function(e,t,i){const n=[],s=lt(t).filter((e=>void 0!==e.defaultValue)).map((e=>e.key.toLowerCase())),o=[];e.document.querySelectorAll('meta[name^="pbstck_context:"]').forEach((e=>{var t;const i=null===(t=e.attributes.getNamedItem("name"))||void 0===t?void 0:t.value.substring(15).toLowerCase();i&&o.push(i)}));for(const e of i)s.includes(e)&&!o.includes(e)&&n.push(e);return n})(e,t,i).forEach((e=>{S(`[context] Missing ${e} context key used in adunit path`)}))}const ut={pbjsFinished:!1,apsFinished:!1},ft="[executor] [instream]";class ht{constructor(e,t,i,n,s){this.rank=1,this.adServer=e,this.pbjs=t,this.aps=i,this.bidderAliases=n,this.kleanadsRunCount=s}executeAdCall(e){setTimeout((()=>{it(e.divId,"executorTimeout")}),2e4),this.adServer.declareAdUnit(e),this.adUnitAuctionStatus?S(`${ft} cannot make a new ad call, existing one on ${e.divId}.`):(w(`${ft} executeAdCall for adunit`,e),this.startAuction(e))}executeRefresh(e){this.adServer.cleanTargetings();const t={labels:["pubstackRefresh",`pubstackRefreshRank:${e.rank}`]};this.startAuction(e.adUnit,t)}startAuction(e,t){if(this.adUnitAuctionStatus=ut,We(e.divId,je.START_AUCTION),w(`${ft} starting auctions for ${e.divId}`),this.pbjs){const i=this.pbjs.getPbjs();this.pbjs.startPbjsAuction([e],(()=>{this.kleanadsRunCount===Zi?this.pbjsFinished(i,e):w(`${ft} kleanads run count has changed (from ${this.kleanadsRunCount} to ${Zi}), avoid calling pbjsFinished`)}),this.bidderAliases,t)}this.aps&&this.aps.startApsAuction([e],((t,i)=>{this.kleanadsRunCount===Zi?this.apsFinished(t,e,i):w(`${ft} kleanads run count has changed (from ${this.kleanadsRunCount} to ${Zi}), avoid calling apsFinished`)})),this.pbjs||this.aps||this.adServer.executeWhenAdServerReady((()=>{this.kleanadsRunCount===Zi?this.callAdServer(e):w(`${ft} kleanads run count has changed (from ${this.kleanadsRunCount} to ${Zi}), avoid calling AdServer`)}))}isAlreadyMonetized(){return!!this.adUnitAuctionStatus}pbjsFinished(e,t){w(`${ft} pbjs end callback for ${t.divId}`,e.getAllPrebidWinningBids()),We(t.divId,je.END_PBJS_AUCTION),st(t.divId),this.adServer.executeWhenAdServerReady((()=>{w(`${ft} pbjs end callback ad server ready ${t.divId}`),this.adServer.setPbjsTargetings(e,t),this.adUnitAuctionStatus&&(this.adUnitAuctionStatus.pbjsFinished=!0),this.canCallAdServer()&&this.callAdServer(t)}))}apsFinished(e,t,i){w(`${ft} aps end callback ${t.divId}`,i),We(t.divId,je.END_APS_AUCTION),this.adServer.executeWhenAdServerReady((()=>{w(`${ft} aps end callback ad server ready ${t.divId}`),this.adServer.setApsTargetings(e,i),this.adUnitAuctionStatus&&(this.adUnitAuctionStatus.apsFinished=!0),this.canCallAdServer()&&this.callAdServer(t)}))}canCallAdServer(){const e=this.adUnitAuctionStatus;return this.aps&&!this.pbjs?e&&e.apsFinished:this.pbjs&&!this.aps?e&&e.pbjsFinished:this.pbjs&&this.aps?e&&e.apsFinished&&e.pbjsFinished:void 0}callAdServer(e){We(e.divId,je.START_AD_SERVER_CALL),this.adServer.callAdServer(e,(()=>{w(`${ft} onCallFinished called, adding setTimeout to a new auction`),setTimeout((()=>{this.executeRefresh({adUnit:e,rank:this.rank}),this.rank++}),5e3)})),w(`${ft} ad server called ${e.divId}`)}}function gt(e){if("string"==typeof e)return!0;if(Array.isArray(e)){for(const t of e)if("string"!=typeof t)return!1;return!0}return!1}function pt(e,t,i){const n=t.getTargeting(i);n&&n.length>0&&(w(`removing ${i} targeting from slot ${e}`),t.clearTargeting(i))}const vt="bid_bidder",mt="bid_size",bt="bid_mediatype",yt="adm";class Ct{constructor(){this.uprEnabled=!0}setUprState(e,t){switch("true"===function(e,t){const i=`meta[name="${t}"]`,n=e.document.querySelector(i);return null!==n?n.getAttribute("content"):null}(window,"adm_feature:upr_disabled")&&(e="disabled"),e){case"disabled":this.uprEnabled=!1;break;case"tested":this.uprEnabled=P(null!=t?t:50),this.uprTested=!0;break;default:this.uprEnabled=!0}}static getInstance(){return Ct.instance||(Ct.instance=new Ct),Ct.instance}}const wt="[GAM]",At="pbstck_ab_test",St="xp_variant",It={},kt=[3,1];let Et=!1;const $t=[];function Ot(e){return new Promise(((t,i)=>_t(e,t,i)))}const Tt=50;function _t(e,t,i){if(e.googletag)try{e.googletag.apiReady?t():setTimeout((()=>_t(e,t,i)),Tt)}catch(e){i(e)}else setTimeout((()=>_t(e,t,i)),Tt)}function Rt(e,t,i,n,s,o){Ot(e).then((()=>{var r,a;w("googletag ready, starting initialization"),e.googletag.pubads().disableInitialLoad(),e.googletag.pubads().enableSingleRequest()||I("unable to enable single request"),function(e,t,i,n){const s=e.googletag.pubads();i.forEach(((e,t)=>{e&&s.setTargeting(t,e)}));const o=K(e);w("[targetings] here are the targetings",o),Object.keys(o).forEach((e=>{s.setTargeting(e,o[e])})),s.setTargeting(yt,"1"),s.setTargeting("device",t);const r=Ct.getInstance().grapeshotValues;(null==r?void 0:r.length)&&s.setTargeting("gs_cat",r);if(n&&n.length>0){const e=n[0].value;s.setTargeting("adm_ab_test",`poc:${e}`)}if(Ct.getInstance().uprTested){w(`${wt} setting xp_variant/pbstck_ab_test gam targeting value any previous value will be ignored`);const e=`floor_optimization:${Ct.getInstance().uprEnabled}`;s.setTargeting(St,e),s.setTargeting(At,e)}}(e,t,i,o),s&&s.ppidValue&&e.googletag.pubads().setPublisherProvidedId(s.ppidValue),e.googletag.enableServices(),(null===(r=null==n?void 0:n.lazyLoadingGoogle)||void 0===r?void 0:r.googleFetchMarginPercent)&&(null===(a=null==n?void 0:n.lazyLoadingGoogle)||void 0===a?void 0:a.googleRenderMarginPercent)&&e.googletag.pubads().enableLazyLoad({fetchMarginPercent:n.lazyLoadingGoogle.googleFetchMarginPercent,renderMarginPercent:n.lazyLoadingGoogle.googleRenderMarginPercent,mobileScaling:n.lazyLoadingGoogle.googleMobileScaling}),e.googletag.pubads().setCentering(!0),w("googletag initialized"),Et=!0,$t.forEach((e=>e())),Fe(Pe.GOOGLETAG_READY),k("[metric] googletag",{consentType:Ze,googletagReady:He(Pe.CMP_RESPONSE_AVAILABLE,Pe.GOOGLETAG_READY),adUnitWithAuctionEnded:Array.from(nt.keys())}),A("GAM","googletag slotRenderEnded listener added"),e.googletag.pubads().addEventListener("slotRenderEnded",Lt),e.googletag.pubads().addEventListener("slotResponseReceived",xt),e.googletag.pubads().addEventListener("slotOnload",Ut)}))}const Lt=e=>{const t=e.slot,i=t.getSlotElementId();We(i,je.SLOT_RENDER_ENDED_TIME),it(i,"slotRenderEnded"),function(e,t){pt(e,t,"ad_floor-rule"),pt(e,t,"prkv")}(i,t),w(`slot render ended for ${i}`)},Ut=e=>{const t=e.slot.getSlotElementId();w(`slot onload received for ${t}`),setTimeout((()=>{const e=document.getElementById(t);if(e){const i=function(e){if(e.scrollHeight>e.clientHeight)return{overflow:"height",scroll:e.scrollHeight,client:e.clientHeight};if(e.scrollWidth>e.clientWidth)return{overflow:"width",scroll:e.scrollWidth,client:e.clientWidth};return}(e);i&&I(`${wt} Overflow problem while rendering '${JSON.stringify(It[t])}' | ${JSON.stringify(i)}`)}}),100)},xt=e=>{const t=e.slot.getSlotElementId();w(`slot response received for ${t}`),We(t,je.SLOT_RESPONSE_RECEIVED_TIME)};function Pt(e,t){for(const i of e.getTargetings()){const n=Q(i),s=i.key;t.setTargeting(s,n),w(`${wt} adding targeting (${s}, ${n}) to adunit ${e.divId}`)}t.setTargeting("ad_adunitname",[e.adServerAdUnitName])}function Nt(e){Et?e():$t.push(e)}class jt{constructor(e,t){this.pubstackWindow=e,this.prebidOrderIds=t}prebidReady(e){w(`${wt} prebidReady`,e)}init(e,t,i,n,s){Rt(this.pubstackWindow,e,t,i,n,s)}declareAdUnits(e){return this.declareGoogleSlots(e)}cleanAdUnits(){this.executeWhenAdServerReady((()=>{w(`${wt} cleaning slots`,this.pubstackWindow.googletag.pubads().getSlots().map((e=>e.getSlotElementId())),this.pubstackWindow.googletag.pubads().getSlots());const e=[];this.pubstackWindow.googletag.pubads().getSlots().forEach((t=>{const i=this.pubstackWindow.googletag.destroySlots([t]);A(`${wt} slot ${t.getSlotElementId()} destroyed ? ${i}`),i||(e.push(t),w(`${wt} slot ${t.getSlotElementId()} not destroyed, retrying later`))})),e.length?I(`${wt} unable to destroy slot ${Dt(e)}`):A(`${wt} all slots destroyed`),this.pubstackWindow.googletag.pubads().removeEventListener("slotRenderEnded",Lt),this.pubstackWindow.googletag.pubads().removeEventListener("slotResponseReceived",xt),this.pubstackWindow.googletag.pubads().removeEventListener("slotOnload",Ut),$t.splice(0)}))}setPbjsTargetings(e,t){e?(w(`${wt} try to put pbjs targeting keys for ${t.map((e=>e.divId)).join(",")}`),t.forEach((t=>{const i=this.getSlot(t,"setPbjsTargetings");i&&function(e,t,i){i.getTargetingKeys().forEach((e=>{"bid_"!==e.substring(0,4)&&"hb_"!==e.substring(0,3)||i.clearTargeting(e)}));const n=t.getAdserverTargetingForAdUnitCode(e.divId);for(const t of Object.keys(n)){const s=n[t];gt(s)?i.setTargeting(t,s):S(`[targeting] unable to set targeting ${t}=${s} on adUnit ${e.divId}`)}}(t,e,i)}))):I(`${wt} no pbjs given: unable to put header bidding targetings`)}setApsTargetings(e,t,i){e&&(w(`${wt} putting targeting keys for aps auction`,i),e.setDisplayBids())}setRefreshTargeting(e){const t=this.getSlot(e.adUnit,"setPbjsTargetings");var i,n;t&&(i=t,n=e.rank,i.setTargeting("ad_refresh","1"),i.setTargeting("pbstck_refresh","1"),i.setTargeting("ad_refresh-rank",function(e){return e<10?`${e}`:"10-more"}(n)))}callAdServer(e){w(`${wt} preparing call to GAM for ${e.map((e=>e.divId)).join(",")}`,e);const t=this.pubstackWindow.googletag.pubads().getSlots(),i=e.map((e=>({adUnit:e,slot:t.find((t=>t.getSlotElementId()===e.divId))}))).filter((e=>!!e.slot));i.forEach((({adUnit:e,slot:t})=>Pt(e,t)));const n=i.map((({slot:e})=>e));w(`${wt} calling GAM with ${n.length} slots`,Dt(n),Dt(t)),g("googletag:refresh",{slotIds:n.map((e=>e.getSlotElementId()))}),this.pubstackWindow.googletag.pubads().refresh(n)}executeWhenAdServerReady(e){Et?e():$t.push(e)}renderListener(e){Nt((()=>{this.renderListenerCallback=t=>{const i=t.slot,n=t.campaignId,s={divId:i.getSlotElementId(),creativeId:t.creativeId,lineItemId:t.lineItemId,orderId:n,size:Bt(t),isEmpty:t.isEmpty,advertiserId:t.advertiserId};if(n&&this.prebidOrderIds.includes(n)){const e=i.getTargeting(vt);e&&(s.hb_bidder=Array.isArray(e)?e[0]:e);const t=i.getTargeting(mt);t&&t[0]&&(s.size=x(t[0]));const n=i.getTargeting(bt);n&&(s.hb_mediaType=Array.isArray(n)?n[0]:n)}It[s.divId]=s,e(s)},this.pubstackWindow.googletag.pubads().addEventListener("slotRenderEnded",this.renderListenerCallback)}))}removeRenderListener(){this.renderListenerCallback&&(A("GAM","removing render listener"),this.pubstackWindow.googletag.pubads().removeEventListener("slotRenderEnded",this.renderListenerCallback))}getSlot(e,t){const i=this.pubstackWindow.googletag.pubads().getSlots().filter((t=>t.getSlotElementId()===e.divId));if(0!==i.length)return i.length>1&&I(`${wt} multiple slot found for adunit ${e.divId} on operation ${t}`),i[0];I(`${wt} slot not found for adunit ${e.divId} on operation ${t}`)}declareGoogleSlots(e){return new Promise((t=>{Nt((()=>{const i=e.sort(j),n=[];i.forEach((e=>{var t,i,s;if("interstitial"===e.outOfPageType){w(`${wt} define slot interstitial for ${e.divId} (${e.adUnitPath})`);const t=window.googletag.defineOutOfPageSlot(e.adUnitPath,googletag.enums.OutOfPageFormat.INTERSTITIAL);t&&(w("slot interstitial created"),t.addService(googletag.pubads()),n.push(t),Pt(e,t))}else if(document.getElementById(e.divId)){let n;if("default"===e.outOfPageType)w(`${wt} define slot out of page for ${e.divId} (${e.adUnitPath})`),n=null===(t=window.googletag.defineOutOfPageSlot(e.adUnitPath,e.divId))||void 0===t?void 0:t.addService(googletag.pubads());else{const t=[kt,...e.sizes,...null!==(i=e.extraAdServerSizes)&&void 0!==i?i:[]];w(`${wt} define slot for ${e.divId} (${e.adUnitPath})`),n=null===(s=window.googletag.defineSlot(e.adUnitPath,t,e.divId))||void 0===s?void 0:s.addService(googletag.pubads())}n?(w(`${wt} slot created, displaying ${e.divId}`),googletag.display(e.divId)):I(`${wt} unable to create slot for ${e.divId}`)}else w(`${wt} unable to display ${e.divId}, the div does not exist`)})),n.forEach((e=>{w(`${wt} calling googletag.display for interstitial slot`,e),googletag.display(e)})),n.length>0&&googletag.pubads().refresh(n);const s=Ct.getInstance().declareXPLNTargetings;s&&s(),t()}))}))}}function Dt(e){return e.map((e=>({id:e.getSlotElementId(),path:e.getAdUnitPath()})))}function Bt(e){return e.size}function Mt(e,t,i,n,s){const o=`${n}_${s}`;navigator.sendBeacon(`https://intake.pbstck.com/v1/intake/gam-impression?sId=${t}&tId=${e}&c=1&s=${o}&v=${i}`)}const Ft="[Local-AdServer]";class zt{constructor(){this.managedDivs=[],this.callbacks=[]}prebidReady(e){this.pbjs=e}callAdServer(e){this.pbjs?(w(`${Ft} callAdServer`,e),e.forEach((e=>{if(this.managedDivs.includes(e.divId)){const t=this.pbjs.getHighestCpmBids(e.divId);if(t.length>0){const e=t[0];try{!function(e,t){var i,n;if(w(`${Ft} renderOne`,t),!t||!t.adId)throw new Error(`${Ft} no winning bid or adId provided ${t}`);{const s=document.getElementById(t.adUnitCode);if(!s)throw new Error(`${Ft} unable to find div ${t.adUnitCode}`);{const o=s.getElementsByTagName("iframe");w(`${Ft} found ${o.length} iframe to remove`),Array.from(o).forEach((e=>e.remove()));const r=document.createElement("iframe");r.scrolling="no",r.frameBorder="0",r.marginHeight="0",r.name=`prebid_ads_iframe_${t.adUnitCode}`,r.title="3rd party ad content",null===(i=r.sandbox)||void 0===i||i.add("allow-forms","allow-popups","allow-popups-to-escape-sandbox","allow-same-origin","allow-scripts","allow-top-navigation-by-user-activation"),r.setAttribute("aria-label","Advertisment"),r.style.setProperty("border","0"),r.style.setProperty("margin","0"),r.style.setProperty("overflow","hidden"),s.appendChild(r);const a=null===(n=r.contentWindow)||void 0===n?void 0:n.document;if(!a)throw new Error(`${Ft} error while getting document from iframe`);{e.renderAd(a,t.adId);const i="/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */button,hr,input{overflow:visible}progress,sub,sup{vertical-align:baseline}[type=checkbox],[type=radio],legend{box-sizing:border-box;padding:0}html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}details,main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:ButtonText dotted 1px}fieldset{padding:.35em .75em .625em}legend{color:inherit;display:table;max-width:100%;white-space:normal}textarea{overflow:auto}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}[hidden],template{display:none}",n=a.createElement("style");n.appendChild(a.createTextNode(i)),a.head.appendChild(n)}}}}(this.pbjs,e);const t={divId:e.adUnitCode,isEmpty:!1,hb_bidder:e.adserverTargeting.bid_bidder,hb_mediaType:e.adserverTargeting.bid_mediatype,size:e.adserverTargeting.bid_size?x(e.adserverTargeting.bid_size):null,advertiserId:null,lineItemId:null,orderId:null,creativeId:null};this.renderListenerCallback(t)}catch(e){I(`${Ft} unable to render: ${e}`)}}else{const t={divId:e.divId,isEmpty:!0,size:null,advertiserId:null,lineItemId:null,orderId:null,creativeId:null};this.renderListenerCallback(t)}}}))):I(`${Ft} pbjs is not available`)}cleanAdUnits(){w(`${Ft} cleanAdUnits - START`),this.managedDivs.forEach((e=>{const t=document.getElementById(e);if(t){const e=t.getElementsByTagName("iframe");w(`${Ft} found ${e.length} iframe to remove`),Array.from(e).forEach((e=>e.remove()))}})),this.managedDivs=[],w(`${Ft} cleanAdUnits - END`,this.managedDivs)}declareAdUnits(e){return w(`${Ft} declareAdUnits (adUnits, managedDivs)`,e,this.managedDivs),e.forEach((e=>{this.managedDivs.includes(e.divId)?I(`${Ft} adUnit already declared ${e.divId}`):this.managedDivs.push(e.divId)})),Promise.resolve(void 0)}executeWhenAdServerReady(e){w(`${Ft} executeWhenAdServerReady`,e),e()}init(e,t,i,n,s){w(`${Ft} init (nothing to do), this are the input params:`,e,t,i,n,s)}removeRenderListener(){w(`${Ft} removeRenderListener`),this.callbacks=[]}renderListenerCallback(e){w(`${Ft} renderListenerCallback called event:`,e),this.callbacks.forEach((t=>t(e)))}renderListener(e){w(`${Ft} renderListener`,e),this.callbacks.push(e)}setApsTargetings(){}setPbjsTargetings(){}setRefreshTargeting(){}}class Wt{constructor(){this.name="AdServer",this.scriptLoaded=!1,this.loaded=!1}get adServer(){return this._adServer}isLoaded(){return this.loaded}async load(){this.loaded=!0}async onAfterConsentRefused({config:e}){var t;if(!this._adServer)switch(e.consentlessMode){case"GAM":this._adServer=new jt(window,(null===(t=e.globalRefreshConfig)||void 0===t?void 0:t.prebidOrderIds)||[]),this._adServer.renderListener((t=>{t.isEmpty||Mt(e.tagId,e.stack.scopeId,e.kleanadsVersion,e.stack.stackId,e.stackVersion)})),this.scriptLoaded||(_("https://pagead2.googlesyndication.com/tag/js/gpt.js"),this.scriptLoaded=!0);break;case"local":this._adServer=new zt;break;default:w("AdServerModule - onAfterConsentRefused - no ad server configured for consentless")}}async onAfterConsentAccepted({config:e}){var t;this._adServer||(this._adServer=new jt(window,(null===(t=e.globalRefreshConfig)||void 0===t?void 0:t.prebidOrderIds)||[]),this._adServer.renderListener((t=>{t.isEmpty||Mt(e.tagId,e.stack.scopeId,e.kleanadsVersion,e.stack.stackId,e.stackVersion)})),this.scriptLoaded||(_("https://securepubads.g.doubleclick.net/tag/js/gpt.js"),this.scriptLoaded=!0))}async onStackConfigLoad({config:e,stackConfig:t}){this._adServer?this._adServer.init(e.device,e.pageContext,t.lazyLoading,t.gamConfig,t.runningABTest):I("AdServerModule - onStackConfigLoad - no ad server configured")}async onPrepareAdUnits({toPreparedAdUnits:e}){var t;const i=(null!=e?e:[]).filter((e=>!e.isInstream));return null===(t=this._adServer)||void 0===t?void 0:t.declareAdUnits(i)}async onAfterPrebidReady({prebid:e}){const t=e.getPbjs();this._adServer?this._adServer.prebidReady(t):I("AdServerModule - onAfterPrebidReady - no ad server configured")}async clean(){this._adServer?this._adServer.cleanAdUnits():I("AdServerModule - clean - no ad server configured")}}function Vt(e,t,i,n,s,o){function r(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var a,d=n.kind,l="getter"===d?"get":"setter"===d?"set":"value",c=!t&&e?n.static?e:e.prototype:null,u=t||(c?Object.getOwnPropertyDescriptor(c,n.name):{}),f=!1,h=i.length-1;h>=0;h--){var g={};for(var p in n)g[p]="access"===p?{}:n[p];for(var p in n.access)g.access[p]=n.access[p];g.addInitializer=function(e){if(f)throw new TypeError("Cannot add initializers after decoration has completed");o.push(r(e||null))};var v=(0,i[h])("accessor"===d?{get:u.get,set:u.set}:u[l],g);if("accessor"===d){if(void 0===v)continue;if(null===v||"object"!=typeof v)throw new TypeError("Object expected");(a=r(v.get))&&(u.get=a),(a=r(v.set))&&(u.set=a),(a=r(v.init))&&s.unshift(a)}else(a=r(v))&&("field"===d?s.unshift(a):u[l]=a)}c&&Object.defineProperty(c,n.name,u),f=!0}function Gt(e,t,i){for(var n=arguments.length>2,s=0;s<t.length;s++)i=n?t[s].call(e,i):t[s].call(e);return n?i:void 0}function Ht(e,t,i){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:t})}function Jt(e){return function(t,i){return class extends t{constructor(){super(...arguments),this.deferLoadingTo=e}}}}"function"==typeof SuppressedError&&SuppressedError;let Kt=4400;const qt="[executor] [APS]";let Xt=!1,Yt=!1;function Qt(e){const t=e.apstag;if(t.kleanadsBlocker){w(`${qt} getting apstag from blocker's methods`);const e=t;return{...t,fetchBids:e.fetchBidsKleanads,setDisplayBids:e.setDisplayBidsKleanads}}return t}class Zt{constructor(e,t){this.pubstackWindow=e,this.apsPubId=t}setEnableApsForTests(e){!function(e){I(`${qt} this function should be used only for testing purpose`),Xt=e}(e)}load(){!function(e){function t(t,i){var n,s;null===(s=null===(n=Qt(e))||void 0===n?void 0:n._Q)||void 0===s||s.push([t,i])}Xt=!0,e.apstag||(w(`${qt} overriding apstag`),e.apstag={_Q:[]}),w(`${qt} overriding apstag functions`),e.apstag.init=(...e)=>t("i",e),w(`${qt} init set!`,e.apstag.init),e.apstag.fetchBids=(...e)=>t("f",e),e.apstag.setDisplayBids=()=>{},e.apstag.targetingKeys=()=>[],_("//c.amazon-adsystem.com/aax2/apstag.js")}(this.pubstackWindow)}startApsAuction(e,t){if(!Xt)return w(`${qt} skipping auction for adunits [${e.map((e=>e.divId)).join(",")}]`),void t(void 0,[]);if(!Yt)return S(`${qt} cannot start auction: apstag is not initialized`),void t(void 0,[]);const i=Qt(this.pubstackWindow);if(!i)return S(`${qt} cannot find apstag on the page`),void t(void 0,[]);const n=function(e){return e.filter((e=>e.headerBiddingEnabled)).reduce(((e,t)=>{const i=ie(t);if(i.includes("Instream")){const t={slotID:"videoSlot",mediaType:"video",sizes:[[640,480]]};return[...e,t]}if(i.includes("Banner")&&i.includes("Outstream")){const i={slotID:t.divId,slotName:t.slotName,mediaType:"multi-format",multiFormatProperties:{display:{sizes:U(t.sizes)},video:{sizes:[[640,480]]}}};return[...e,i]}if(i.includes("Banner")){const i={slotID:t.divId,slotName:t.slotName,sizes:U(t.sizes)};return i.sizes.length?[...e,i]:e}if(i.includes("Outstream")){const i={slotID:t.divId,mediaType:"video",sizes:[[640,480]]};return[...e,i]}return[]}),[])}(e);if(w(`${qt} apsSlots created`,n),0===n.length)return void t(i,[]);w(`${qt} calling fetchBids`);let s=!1;setTimeout((()=>{s||(S(`${qt} fetchbids did not response before ${Kt}ms, calling callback`),s=!0,t(i,[]))}),Kt),i.fetchBids({slots:n},(e=>{s||(s=!0,t(i,e))})),w(`${qt} auction started`,n)}initAps(e){if(Xt){Kt=e+1400,w(`${qt} updating failsafe timeout to ${Kt}`);const t=Qt(this.pubstackWindow);if(!t)return void S(`${qt} cannot find apstag on the page`);t.init({pubID:this.apsPubId,adServer:"googletag",bidTimeout:e,deals:!0,videoAdServer:"DFP"},(()=>{w(`${qt} apstag init done`),Fe(Pe.APSTAG_READY),k("[metric] apstag",{consentType:Ze,apstagReady:He(Pe.CMP_RESPONSE_AVAILABLE,Pe.APSTAG_READY)})})),Yt=!0}else w(`${qt} apstag init skipped`)}}let ei=(()=>{let e,t,i=[Jt("onStackConfigLoad")],n=[];return t=class{constructor(){this.name="Aps"}get aps(){return this._aps}isLoaded(){return!!this._aps}async load({stackConfig:e}){var t;this._aps=function(e,t){if(e&&t.some((e=>e.headerBiddingEnabled&&(e.isInstream||e.canOutstream||e.sizes.some((e=>"fluid"!==e)))))){w("downloading amazon apstag");const t=new Zt(window,e);return t.load(),t}}(null===(t=e.tamConfig)||void 0===t?void 0:t.apsPubId,e.adUnits)}async onStackConfigLoad({config:e,stackConfig:t}){var i,n,s;null===(i=this._aps)||void 0===i||i.initAps(null!==(s=null===(n=t.prebidConfig)||void 0===n?void 0:n.adCallTimeout)&&void 0!==s?s:e.adCallTimeout)}async clean(){}},Ht(t,"ApsModule"),(()=>{const s="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;Vt(null,e={value:t},i,{kind:"class",name:t.name,metadata:s},null,n),t=e.value,s&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:s}),Gt(t,n)})(),t})();const ti="ModuleService";class ii{constructor(e,t){this.modules=t,this.lifecycleState={config:e},w(`[${ti}] Init: ${this.modules.length} modules registered`);for(const e of this.modules)e.isLoaded()?w(`[${ti}] Module ${e.name} is already loaded`):w(`[${ti}] Registered module ${e.name}.${e.deferLoadingTo?`Deferred loading to ${e.deferLoadingTo}`:""}`)}getModules(){return this.modules}getLoadedModuleInstance(e){return this.modules.filter((e=>e.isLoaded())).find((t=>t instanceof e))}async loadModules(e){for(const t of e){w(ti,`Loading module ${t.name}`);try{await t.load(this.lifecycleState)}catch(e){I(ti,`Error while loading module ${t.name}`,e)}}}async loadInitialModules(){const e=this.modules.filter((e=>!e.deferLoadingTo&&!e.isLoaded()));w(`[${ti}] Loading initial modules. ${e.length} modules to load`),await this.loadModules(e)}async modulesDispatchEvent(e,...t){this.lifecycleState={...this.lifecycleState,...t[0]};const i=this.lifecycleState,n=this.modules.filter((t=>t.deferLoadingTo===e&&!t.isLoaded()));return w(`[${ti}] event call: ${e}. ${n.length} deferred modules to load`),await this.loadModules(n),new Promise((t=>{var n;const s=this.modules.filter((t=>t.isLoaded()&&t[e]&&"function"==typeof t[e]));w(`[${ti}] event call: ${e}. ${s.length} modules to call`);const o=[];for(const t of s){w(ti,`Calling ${e} on module ${t.name}`);const s=null===(n=t[e])||void 0===n?void 0:n.call(t,i);s instanceof Promise&&o.push(s)}t(o)}))}async modulesCleanUp(){const e=this.modules.filter((e=>e.isLoaded()));w(`[${ti}] Cleaning modules. ${e.length} modules cleanup started`);for(const t of e)w(ti,`Cleaning module ${t.name}`),await t.clean(this.lifecycleState);this.modules=[]}}const ni="[pbjs] [sublime]";const si=(e,t)=>e.delimiter===t.delimiter&&"|"===e.delimiter&&e.fields.length+1===t.fields.length&&e.fields.every(((e,i)=>e===t.fields[i])),oi=1900,ri="[pbjs]";function ai(e,t=[]){const i=null==t?void 0:t.map((e=>e.bidderSource));return Array.from(new Set(e.flatMap((e=>e.bidders)).map((e=>e.bidder)).concat(i)))}function di(e,t,i,n,s){var o,r,a,d,l,c,u,f,h,g,p;w(`${ri}[initPbjs] Start prebid initialization`);const{currency:v,userSync:m,priceGranularity:b,bidderAdjustments:y,bidderAliases:C,bidderConfigs:A,floors:I,analytics:E,schain:$,outbrain:O,realTimeData:T,allowLocalStorage:R,fledgeForGpt:L,paapi:U,dsaConfig:x,s2sConfig:P,enableTIDs:N}=i,j=ai(t,C);if(e.setConfig(n),v&&(w(`${ri}[initPbjs] set currency config`,v),e.setConfig({currency:v,priceGranularity:"dense"}),b&&(w(`${ri}[initPbjs] set priceGranularity config`,b),e.setConfig({priceGranularity:b}))),P&&(w(`${ri}[initPbjs] set prebid server config`,P),e.setConfig({s2sConfig:P})),m){const t=Object.keys(null!==(r=null===(o=null==P?void 0:P.extPrebid)||void 0===o?void 0:o.aliases)&&void 0!==r?r:{}),i={filterSettings:{iframe:{bidders:Object.values(null!==(d=null===(a=null==P?void 0:P.extPrebid)||void 0===a?void 0:a.aliases)&&void 0!==d?d:{}).concat(null!==(c=null===(l=null==P?void 0:P.bidders)||void 0===l?void 0:l.filter((e=>!t.includes(e))))&&void 0!==c?c:[]).concat(["optidigital","richaudience","justpremium","impactify","smilewanted","onetag","connectad","adagio"]),filter:"include"},image:{bidders:"*",filter:"include"}},...m};w(`${ri}[initPbjs] set userSync config`,i),e.setConfig({userSync:i})}O&&(w(`${ri}[initPbjs] set Outbrain config:`,O),e.setConfig({outbrain:O})),T&&(w(`${ri}[initPbjs] set realTimeData config`,T),e.setConfig({realTimeData:T})),I&&(w(`${ri}[initPbjs] set floors config`,I),e.setConfig({floors:I}));const D=null==T?void 0:T.dataProviders.find((e=>"greenbidsRtdProvider"===e.name));if(E||D){const t=E||[];if(D){const e=null===(u=D.params)||void 0===u?void 0:u.pbuid;if(e&&!t.find((e=>"greenbids"===e.provider))){const i=function(e,t){return{provider:"greenbids",options:{pbuid:e,sampling:t}}}(e,null===(f=D.params)||void 0===f?void 0:f.sampling);t.push(i)}}w(`${ri}[initPbjs] enable analytics`,t),e.enableAnalytics(t)}if($&&(w(`${ri}[initPbjs] set schain config`,$),e.setConfig({schain:$})),L&&e.setConfig({fledgeForGpt:{enabled:!0}}),U&&e.setConfig({paapi:U}),A){w(`${ri}[initPbjs] set bidder config`,A);for(const t of A)e.setBidderConfig(t)}const B={};if(y){w(`${ri}[initPbjs] set bidder adjustments config`,y);for(const e of y)B[e.bidder]={bidCpmAdjustment:function(t){return t*e.adjustment}}}if(R)for(const e of j)B[e]={...B[e],storageAllowed:!0};if(B.standard={adserverTargeting:[{key:vt,val:function(e){return e.bidderCode}},{key:"bid_id",val:function(e){return e.adId}},{key:"bid_cpm",val:function(e){return e.pbCg}},{key:mt,val:function(e){return e.size}},{key:bt,val:function(e){return e.mediaType}},{key:"bid_videoId",val:function(e){return e.videoCacheKey}}]},s&&Ct.getInstance().uprEnabled&&(B.standard={adserverTargeting:[...B.standard.adserverTargeting,{key:"prkv",val:e=>li(e,s)},{key:"ad_floor-rule",val:e=>li(e,s)}]}),Object.keys(B).length>0&&(e.bidderSettings=B),C){w(`${ri}[initPbjs] set alias bidder`,C);for(const t of C)e.aliasBidder(t.bidderSource,t.bidderLabel)}if(ui(t,"sublime",C)){const e=function(e,t){var i,n;const s=null===(i=null==t?void 0:t.find((e=>"sublime"===e.bidderSource)))||void 0===i?void 0:i.bidderLabel,o=e.filter((e=>e.bidders.find((e=>"sublime"===e.bidder||e.bidder===s))));if(0===o.length)return;if(o.length>1)return void S(`${ni} Sublime bidder has multiple adUnits ${o.map((e=>e.divId)).join("")}`,o);const r=null===(n=o[0].bidders.find((e=>"sublime"===e.bidder||e.bidder===s)))||void 0===n?void 0:n.params;if(r){const e=r.zoneId;if(e&&("string"==typeof e||"number"==typeof e))return`${e}`}else S(`${ni} unable to extract Sublime zoneId from ${o[0].divId}`,o[0])}(t,C);if(e){const t=`https://sac.ayads.co/sublime/${e}/prebid`;w(`${ri}[initPbjs] loading sublime script ${t}`),_(t)}}if(null===(h=e.installedModules)||void 0===h?void 0:h.includes("utiqSystem")){const t=localStorage.getItem("utiqPass");if(t)try{const i=JSON.parse(t),n=null!==(null===(p=null===(g=null==i?void 0:i.connectId)||void 0===g?void 0:g.idGraph)||void 0===p?void 0:p[0].atid);w(`${ri}[initPbjs] set Utiq key values isUtiqPresent=`,n),e.mergeConfig({ortb2:{site:{keywords:"isUtiqPresent="+n}}})}catch(e){S(`${ri}[initPbjs] Utiq config is not valid JSON`,t)}}x&&(w(`${ri}[initPbjs] set DSA config`,x),e.mergeConfig({ortb2:{regs:{ext:{dsa:x}}}})),ui(t,"criteo",C)&&e.setConfig({criteo:{fastBidVersion:"latest"}}),void 0!==N&&(w(`${ri}[initPbjs] setting enableTIDs to`,N),e.setConfig({enableTIDs:N})),Fe(Pe.PREBID_READY),k("[metric] pbjs",{consentType:Ze,pbjsReady:He(Pe.CMP_RESPONSE_AVAILABLE,Pe.PREBID_READY)}),w(`${ri}[initPbjs] Prebid is initialized`)}function li(e,t){const i=e.cpm,n=i>0?function(e,t){let i;if(t.forEach((t=>{const n=parseFloat(t.max);n>e&&(i=!i||n<parseFloat(i.max)?t:i)})),!i)return Math.max(...t.map((e=>parseFloat(e.max))));const n=parseFloat(i.increment);return parseFloat((Math.floor(e/n)*n).toFixed(2))}(i,t):0,s=Math.max(...t.map((e=>parseFloat(e.max))));return Math.min(n,s).toFixed(2)}function ci(e,t,i,n,s){const[o,r,a]=function(e){const t=[],i=[],n=[];return e.forEach((e=>{e.headerBiddingEnabled&&e.bidders.length>0?(t.push(e),i.push(e.divId)):n.push(e.divId)})),[t,i.join(","),n.join(",")]}(t);if(o.length>0){const t=null==s?void 0:s.timeout,d=null==s?void 0:s.labels,l=function(e){const t=e.getConfig("bidderTimeout");if(t){if("number"==typeof t)return t+oi;if(parseInt(t))return parseInt(t)+oi}return 3e3+oi}(e);let c=!1;setTimeout((()=>{c||(S(`${ri}prebid requestBids did not response before ${l}ms, calling callback`),c=!0,i())}),l);const u=()=>{c||(c=!0,i())};if(!(e=>1===new Set(e.map((e=>e.floors)).filter((e=>void 0!==e)).map((e=>[...e.schema.fields,e.schema.delimiter].join("")))).size)(o)){const e=(e=>e.map((e=>e.floors)).filter((e=>void 0!==e)).map((e=>e.schema)).reduce(((e,t)=>(e?t.fields.length>e.fields.length&&(e=t):e=t,e)),void 0))(o);e&&(w(`${ri}floors schema are not the same, unifying schema`),((e,t)=>{e.forEach((i=>{var n;if(i.floors&&(null===(n=i.floors)||void 0===n?void 0:n.schema)!==t){const n=i.floors.schema;if(si(n,t)){i.floors.schema=t;const e=i.floors.values;i.floors.values={};for(const t of Object.keys(e))i.floors.values[`${t}|*`]=e[t]}else I(`Unable to unify schema for adUnits ${e.map((e=>e.divId)).join(", ")}.`,t)}}))})(o,e))}const f=o.flatMap((t=>{if(t.dynamicPrebidFloor){const i=e.getHighestCpmBids(t.divId);if(i.length>0){const e=i[0].cpm,s=Math.floor(100*e)/100;return re(t,n,s)}}return re(t,n)}));w(`${ri}[executor] [pbjs] calling requestBids for ${f.map((e=>e.code)).join(",")}`),e.requestBids({timeout:t,adUnits:f,bidsBackHandler:u,labels:d}),w(`${ri}[executor] [pbjs] prebid auction started for [${r}] | prebid auction skipped for [${a}]`,o)}else w(`${ri}[executor] [pbjs] no prebid auction to start for [${a}]`),i()}function ui(e,t,i){const n=e.flatMap((e=>e.bidders)).map((e=>e.bidder)),s=[...new Set(n)],o=[t,...(null==i?void 0:i.filter((e=>e.bidderSource===t)).map((e=>e.bidderLabel)))||[]];return s.some((e=>null==o?void 0:o.includes(e)))}class fi{constructor(e){this.pbjs=e.getPbjs()}initPbjs(e,t,i,n){di(this.pbjs,e,t,i,n)}extractUniqAdaptersName(e,t=[]){return ai(e,t)}roundUpToNearestIncrement(e,t){return function(e,t){const i=e.sort(((e,t)=>e.max<t.max?-1:1)),n=i.filter((e=>t<=e.max));if(0===n.length)return w(`${ri}[Price granularity] round up - initial CpmValue : ${t} // rounded value : ${i[i.length-1].max} `),i[i.length-1].max.toFixed(2);const s=n[0].increment;let o=t%s==0?t:t+(s-t%s);const r=t.toString().split("."),a=r.length>1?r[1].split("").length:0;(o-s).toFixed(a)===t.toFixed(a)&&(o=t);const d=o.toFixed(2);return w(`${ri}[Price granularity] round up - initial CpmValue : ${t} // rounded value : ${d} `),d}(e,t)}startPbjsAuction(e,t,i,n){ci(this.pbjs,e,t,i,n)}getPbjs(){return this.pbjs}setContextValuesAsTargeting(e,t,i){const n={};for(const[t,i]of e)n[t]=i;for(const e in t)1===t[e].length?n[e]=t[e][0]:n[e]=t[e];this.pbjs.setBidderConfig({bidders:i,config:{ortb2:{site:{ext:{data:n}}},appnexusAuctionKeywords:n}})}}let hi=(()=>{let e,t,i=[Jt("onStackConfigLoad")],n=[];return t=class{constructor(){this.name="Prebid"}get pbjs(){return this._pbjs}isLoaded(){return!!this._pbjs}async load({config:e,stackConfig:t}){this._pbjs=await async function(e,t){if(t.some((e=>e.headerBiddingEnabled&&e.bidders.length)))try{const t=await T(e);return new fi(t)}catch(e){return void w("[config] Error while loading the kleanadsPbjs module",e)}}(e.newPrebidUrl,t.adUnits),this._pbjs&&this.aliasWindowPbjs(window,this._pbjs.getPbjs())}async onStackConfigLoad({config:e,stackConfig:t}){var i,n,s;if(!this._pbjs)throw new Error("PrebidModule is not loaded");const o=null!==(n=null===(i=null==t?void 0:t.prebidConfig)||void 0===i?void 0:i.adCallTimeout)&&void 0!==n?n:e.adCallTimeout,r=t.prebidConfig.pbjsConfig,a={gdpr:{cmpApi:"iab",timeout:8e3,defaultGdprScope:!0}},d=this._pbjs.getPbjs().installedModules;d.includes("consentManagementUsp")&&(a.usp={cmpApi:"iab",timeout:8e3}),d.includes("consentManagementGpp")&&(a.gpp={cmpApi:"iab",timeout:8e3});const l={bidderTimeout:o,useBidCache:!0,maxRequestsPerOrigin:6,consentManagement:e.noCmp?void 0:a,enableSendAllBids:!1,pageUrl:document.location.href,cache:{url:"https://prebid.adnxs.com/pbc/v1/cache",ignoreBidderCacheKey:!0},timeoutBuffer:400};if(this._pbjs.initPbjs(t.adUnits,r,l,e.priceRuleBuckets),null===(s=null==r?void 0:r.targetingBehaviors)||void 0===s?void 0:s.sendKVTargetings){const i=K(window),n=this._pbjs.extractUniqAdaptersName(t.adUnits,r.bidderAliases).filter((e=>{var t;return!(null===(t=r.targetingBehaviors)||void 0===t?void 0:t.biddersBlackList.includes(e))}));this._pbjs.setContextValuesAsTargeting(e.pageContext,i,n)}}async clean(){var e;this.setDefaultPbjsConfig();const t=null===(e=this._pbjs)||void 0===e?void 0:e.getPbjs();t&&(t.bidderSettings={})}aliasWindowPbjs(e,t){e.pbjs=t}setDefaultPbjsConfig(){var e;null===(e=this._pbjs)||void 0===e||e.getPbjs().setConfig({bidderTimeout:3e3,enableSendAllBids:!0,useBidCache:!1,deviceAccess:!0,timeoutBuffer:400,disableAjaxTimeout:!1,maxNestedIframes:10,priceGranularity:"medium",customPriceBucket:{},mediaTypePriceGranularity:{},bidderSequence:"random",auctionOptions:{},userSync:{syncEnabled:!0,filterSettings:{image:{bidders:"*",filter:"include"}},syncsPerBidder:5,syncDelay:3e3,auctionDelay:0}})}},Ht(t,"PrebidModule"),(()=>{const s="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;Vt(null,e={value:t},i,{kind:"class",name:t.name,metadata:s},null,n),t=e.value,s&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:s}),Gt(t,n)})(),t})();class gi{constructor(e,t){this.pubstackWindow=e,this.rule=t}isDivIdMatchingRule(e){const t=document.getElementById(e);if(t){const e=t.getBoundingClientRect();return this.rule(this.pubstackWindow,e)}return!1}}const pi=(e,t,i)=>{if(function(e){return 0===e.top&&0===e.bottom&&0===e.left&&0===e.right&&0===e.width&&0===e.height}(t))return!1;const n=-i*e.innerHeight,s=(1+i)*e.innerHeight>t.top,o=t.bottom>n;return s&&o};function vi(e,t,i,n){const s=e.filter((e=>e.roadblock)).filter((e=>!e.isInstream)).filter((e=>E(e.divId))),o=e.filter((e=>!e.roadblock)).filter((e=>!e.isInstream)).filter((e=>E(e.divId))),r=e.filter((e=>e.isInstream)).filter((e=>E(e.divId)));t.executeAdCallRoadblock(s),r.length>0&&(r.length>1&&S(`cannot monetize multiple instream adunits, using only the first one ${r[0].divId}`),null==i||i.executeAdCall(r[0]));const a=function(e){if(e&&e.lazyLoadingKleanads){const t=e.lazyLoadingKleanads.viewportPercent/100;return w(`[lazyloading] lazy loading enabled with ${t} viewports`),(e,i)=>pi(e,i,t)}}(n);if(a){const e=new gi(window,a);s.length>0?setTimeout((()=>mi(o,e,t)),1e3):mi(o,e,t)}else s.length>0?setTimeout((()=>t.executeAdCall(o)),1e3):t.executeAdCall(o)}function mi(e,t,i){const n=e.filter((e=>{var i;return e.sticky||(null===(i=e.anchor)||void 0===i?void 0:i.mode)||e.outOfPageType||t.isDivIdMatchingRule(e.divId)})),s=n.filter((e=>!i.isAlreadyMonetized(e)));i.executeAdCall(s),setTimeout((()=>mi(e,t,i)),200)}function bi(e,t){var i;const n=null===(i=null==e?void 0:e.sites)||void 0===i?void 0:i[t],s=null==e?void 0:e.scope;return null!=n?n:s}function yi(e,t){var i;if(t)return null!==(i=t[e])&&void 0!==i?i:t.type}function Ci(e){var t;const i=("; "+document.cookie).split("; "+e+"=");if(2===i.length)return null===(t=i.pop())||void 0===t?void 0:t.split(";").shift()}function wi(e,t){return t.flatMap((t=>[t,...e.filter((e=>e.bidderSource===t)).map((e=>e.bidderLabel))]))}class Ai{constructor(e,t){this.stackLoadedConfig={...e,runningABTest:[]},this.pocOverrides=t}withConvertToInstreamAdUnit(){const e=this.pocOverrides.convertToInstreamAdUnits;return e&&this.stackLoadedConfig.adUnits.forEach((t=>{const i=e[t.adUnitName];i&&(t.isInstream=!0,t.dynamic=!1,t.parallax=!1,t.sticky=!1,t.canOutstream=!1,t.biddersOutstream=[],t.floors=i.floors,t.instreamParams=i.instreamParams)})),this}withFirstId(){var e,t,i;if(null===(e=this.pocOverrides)||void 0===e?void 0:e.firstId){const e=this.stackLoadedConfig.prebidConfig.pbjsConfig.bidderAliases||[],n=function(){const e=new RegExp("(?:(?:^|.*; *)firstid *= *([^;]*).*$)|^.*$","i"),t=document.cookie.match(e);return t&&t[1]?decodeURIComponent(t[1]):void 0}();if(n){const s=null!==(i=null===(t=this.stackLoadedConfig.prebidConfig.pbjsConfig.userSync)||void 0===t?void 0:t.userIds)&&void 0!==i?i:[];s.push({name:"pubProvidedId",bidders:wi(e,["appnexus","pubmatic","rubicon","ix","nexx360","criteo","smartadserver","mediasquare","ogury","freewheel-ssp","outbrain","taboola","adf"]),params:{eids:[{source:"first-id.fr",uids:[{id:n,atype:1,ext:{stype:"ppuid"}}]}]}}),this.stackLoadedConfig.prebidConfig.pbjsConfig.userSync={...this.stackLoadedConfig.prebidConfig.pbjsConfig.userSync,userIds:s}}}return this}withId5Id(){var e,t,i;if(null===(e=this.pocOverrides)||void 0===e?void 0:e.id5id){const e=localStorage.getItem(this.pocOverrides.id5id.pd);e&&(null!==(i=null===(t=this.stackLoadedConfig.prebidConfig.pbjsConfig.userSync)||void 0===t?void 0:t.userIds)&&void 0!==i?i:[]).forEach((t=>{"id5Id"===t.name&&(t.params||(t.params={}),t.params.pd=e)}))}return this}withConvertToInterstitialAdUnit(){const e=this.pocOverrides.convertToInterstitialAdUnits;return e&&this.stackLoadedConfig.adUnits.forEach((t=>{e.includes(t.adUnitName)&&(t.outOfPageType="interstitial",w(`Interstitial adUnit found: ${t.adUnitName}`))})),this}withSkinRenderingSettings(e,t){var i,n,s;const o=null===(i=this.pocOverrides)||void 0===i?void 0:i.skinRenderingSettings,r=null===(n=null==o?void 0:o.stackLevel)||void 0===n?void 0:n[t],a=null===(s=null==o?void 0:o.siteLevel)||void 0===s?void 0:s[e];return(null==a?void 0:a.disableSkinBids)||(null==r?void 0:r.disableSkinBids)?this.stackLoadedConfig.adUnits=this.stackLoadedConfig.adUnits.map((e=>({...e,sizes:e.sizes.filter((e=>!X(e,[1800,1e3])))}))):((null==a?void 0:a.biddersOverride)||(null==r?void 0:r.biddersOverride))&&(this.stackLoadedConfig.adUnits=this.stackLoadedConfig.adUnits.map((e=>{var t;return e.sizes.some((e=>X(e,[1800,1e3])))?{...e,biddersSkin:null!==(t=null==r?void 0:r.biddersOverride)&&void 0!==t?t:null==a?void 0:a.biddersOverride}:e}))),this}withRefreshOutOfFocus(e){var t,i;const n=null===(t=this.pocOverrides)||void 0===t?void 0:t.refreshOutOfFocus;if(n){const t=bi(n,e);t&&(null===(i=this.stackLoadedConfig.refreshConfig)||void 0===i||i.adUnitConfig.forEach((e=>{e.refreshOutOfFocusConfig=t})))}return this}withPpidSolution(e){var t;const i=bi(null===(t=this.pocOverrides)||void 0===t?void 0:t.ppidSolutions,e);if(i){const e=Array.isArray(i.ppidSolution)?i.ppidSolution:[i.ppidSolution],{type:t,value:n}=function(e){var t,i;for(const n of e)switch(n){case Se.firstId:return{type:"prebid",value:"first-id.fr"};case Se.sharedId:return{type:"prebid",value:"pubcid.org"};case Se.utiqId:return{type:"prebid",value:"utiq.com"};case Ie.id5id:{const e=localStorage.getItem("id5id");if(e)return{type:"other",value:(i=e,JSON.parse(decodeURIComponent(i)).gp)};break}default:{let e=localStorage.getItem(n);if(e)return{type:"other",value:e};if(e=null!==(t=Ci(n))&&void 0!==t?t:null,e)return{type:"other",value:e}}}return{type:"other",value:""}}(e);if("prebid"===t)this.stackLoadedConfig.prebidConfig.pbjsConfig.userSync={...this.stackLoadedConfig.prebidConfig.pbjsConfig.userSync,ppid:n};else this.stackLoadedConfig.gamConfig&&n&&(this.stackLoadedConfig.gamConfig.ppidValue=n)}return this}withRefreshAlwaysInView(){var e;const t=null===(e=this.pocOverrides)||void 0===e?void 0:e.refreshAlwaysInViewAdUnitNames;if(this.stackLoadedConfig.refreshConfig&&t&&t.length>0){const e=[];this.stackLoadedConfig.refreshConfig.adUnitConfig.forEach((i=>{t.forEach((t=>{var n;(null===(n=i.adUnitNames)||void 0===n?void 0:n.includes(t))&&(e.push({...i,alwaysInView:!0,adUnitNames:[t]}),i.adUnitNames.splice(i.adUnitNames.indexOf(t),1))}))})),this.stackLoadedConfig.refreshConfig.adUnitConfig=[...this.stackLoadedConfig.refreshConfig.adUnitConfig.filter((e=>(e.adUnitNames||[]).length>0)),...e]}return this}withrefreshBehaviorOnEmpty(){var e,t;const i=null===(e=this.pocOverrides)||void 0===e?void 0:e.refreshBehaviorOnEmpty;return i&&(null===(t=this.stackLoadedConfig.refreshConfig)||void 0===t||t.adUnitConfig.forEach((e=>{e.refreshBehaviorOnEmpty=i}))),this}withStickyDivCreation(){var e;const t=null===(e=this.pocOverrides)||void 0===e?void 0:e.stickyDivCreation;return t&&this.stackLoadedConfig.adUnits.filter((e=>e.sticky)).forEach((e=>e.stickyDivCreation=t)),this}withOutbrainConfig(e){var t;if(null===(t=this.pocOverrides)||void 0===t?void 0:t.outbrainConfig){const t=this.pocOverrides.outbrainConfig.find((t=>t.siteId===e)),i=this.pocOverrides.outbrainConfig.find((e=>!e.siteId)),n=t||i;n&&(this.stackLoadedConfig.prebidConfig.pbjsConfig.outbrain={bidderUrl:n.bidderUrl,usersyncUrl:n.usersyncUrl})}return this}withXplnConfig(e){const t=bi(this.pocOverrides.xplnConfig,e);return t&&(this.stackLoadedConfig.xplnConfig=t),this}withFloorEnforcement(e){var t,i,n,s,o,r;if(null===(t=this.pocOverrides)||void 0===t?void 0:t.floorEnforcement){const t=null===(s=null===(n=null===(i=this.pocOverrides)||void 0===i?void 0:i.floorEnforcement)||void 0===n?void 0:n.sites)||void 0===s?void 0:s[e],a=null===(r=null===(o=this.pocOverrides)||void 0===o?void 0:o.floorEnforcement)||void 0===r?void 0:r.scope;(t||a)&&(this.stackLoadedConfig.prebidConfig.pbjsConfig.floors={...this.stackLoadedConfig.prebidConfig.pbjsConfig.floors,enforcement:{...null!=t?t:a}})}return this}withDynamicPrebidFloors(e){var t,i,n,s,o,r;if(null===(t=this.pocOverrides)||void 0===t?void 0:t.dynamicPrebidFloors){const t=null===(s=null===(n=null===(i=this.pocOverrides)||void 0===i?void 0:i.dynamicPrebidFloors)||void 0===n?void 0:n.sites)||void 0===s?void 0:s[e],a=null===(r=null===(o=this.pocOverrides)||void 0===o?void 0:o.dynamicPrebidFloors)||void 0===r?void 0:r.scope;(t||a)&&this.stackLoadedConfig.adUnits.forEach((e=>{e.dynamicPrebidFloor=!0}))}return this}withFledgeForGpt(){var e,t;if(null===(e=this.pocOverrides)||void 0===e?void 0:e.fledgeForGpt){const e=wi(this.stackLoadedConfig.prebidConfig.pbjsConfig.bidderAliases||[],["criteo"]);this.stackLoadedConfig.adUnits.forEach((t=>{var i;t.bidders.find((t=>e.includes(t.bidder)))&&(t.ortb2Imp={...t.ortb2Imp,ext:{...null===(i=t.ortb2Imp)||void 0===i?void 0:i.ext,ae:1}})})),this.stackLoadedConfig.prebidConfig.pbjsConfig.bidderConfigs||(this.stackLoadedConfig.prebidConfig.pbjsConfig.bidderConfigs=[]);const i=this.stackLoadedConfig.prebidConfig.pbjsConfig.bidderConfigs.find((t=>Array.isArray(t.bidders)&&t.bidders.find((t=>e.includes(t)))));i&&i.config?i.config.fledgeEnabled=!0:null===(t=this.stackLoadedConfig.prebidConfig.pbjsConfig.bidderConfigs)||void 0===t||t.push({bidders:[...e],config:{fledgeEnabled:!0}}),this.stackLoadedConfig.prebidConfig.pbjsConfig={...this.stackLoadedConfig.prebidConfig.pbjsConfig,fledgeForGpt:!0}}return this}withRtbHousePaapi(){if(this.pocOverrides.rtbhousePaapi){const e=wi(this.stackLoadedConfig.prebidConfig.pbjsConfig.bidderAliases||[],["rtbhouse"]);this.stackLoadedConfig.adUnits.some((t=>t.bidders.some((t=>e.includes(t.bidder)))))&&(this.stackLoadedConfig.prebidConfig.pbjsConfig={...this.stackLoadedConfig.prebidConfig.pbjsConfig,paapi:{enabled:!0,bidders:[...e],defaultForSlots:1,gpt:{autoconfig:!0}}})}return this}withSkinFloor(e){var t,i,n;const s=null===(t=this.pocOverrides)||void 0===t?void 0:t.skinFloor;if(s){const t=null!==(n=null===(i=s.specificFloor)||void 0===i?void 0:i[e])&&void 0!==n?n:s.defaultFloor;this.stackLoadedConfig.adUnits.forEach((e=>{var i;if(e.sizes.some((e=>X(e,[1800,1e3]))))if(e.floors){const n=null===(i=e.floors)||void 0===i?void 0:i.values.banner;n?e.floors={...e.floors,schema:{delimiter:"|",fields:["mediaType","size"]},values:{"banner|*":n,"banner|1800x1000":t}}:I("no banner value found in floors, skin floor cannot be applied.",e.floors)}else e.floors={currency:s.currency,schema:{delimiter:"|",fields:["mediaType","size"]},values:{"banner|1800x1000":t}}}))}return this}withDsaConfig(){var e,t;return(null===(e=this.pocOverrides)||void 0===e?void 0:e.dsaConfig)&&(this.stackLoadedConfig.prebidConfig.pbjsConfig={...this.stackLoadedConfig.prebidConfig.pbjsConfig,dsaConfig:null===(t=this.pocOverrides)||void 0===t?void 0:t.dsaConfig}),this}withPrebidServerConfig(e){var t,i,n,s,o,r;if((null===(t=this.pocOverrides)||void 0===t?void 0:t.prebidServer)&&this.pocOverrides.prebidServer.siteIds.includes(e)){if(P(this.pocOverrides.prebidServer.ratio)){w("Run ABTest hybrid monetization PBJS + PBS");const e=P(void 0!==(null===(i=this.stackLoadedConfig.prebidConfig.pbjsConfig)||void 0===i?void 0:i.priceGranularity)&&this.pocOverrides.prebidServer.ratioPriceGranularity?this.pocOverrides.prebidServer.ratioPriceGranularity:0);this.stackLoadedConfig.prebidConfig.pbjsConfig={...this.stackLoadedConfig.prebidConfig.pbjsConfig,s2sConfig:{...this.pocOverrides.prebidServer.s2sConfig}};let t=null!==(n=this.pocOverrides.prebidServer.metaABTestServerSide)&&void 0!==n?n:"rule2";e&&(null===(o=null===(s=this.stackLoadedConfig.prebidConfig.pbjsConfig.s2sConfig)||void 0===s?void 0:s.extPrebid)||void 0===o?void 0:o.targeting)&&(this.stackLoadedConfig.prebidConfig.pbjsConfig.s2sConfig.extPrebid.targeting.priceGranularity=this.stackLoadedConfig.prebidConfig.pbjsConfig.priceGranularity,t=`${t}_with_pg`,w("Run ABTest for PriceGranularity on Prebid Server side")),H(t)}else H(null!==(r=this.pocOverrides.prebidServer.metaABTestClientSide)&&void 0!==r?r:"rule1")}return this}withPbjsAnalytics(e){var t;const i=bi(null===(t=this.pocOverrides)||void 0===t?void 0:t.pbjsAnalytics,e);if(i){const e=this.stackLoadedConfig.prebidConfig.pbjsConfig.analytics||[];this.stackLoadedConfig.prebidConfig.pbjsConfig.analytics=[...e,...i]}return this}withAnchorDesktop(e){var t;return bi(null===(t=this.pocOverrides)||void 0===t?void 0:t.anchorDesktop,e)&&this.stackLoadedConfig.adUnits.filter((e=>void 0!==e.anchor)).forEach((e=>e.anchorDesktop=!0)),this}build(){return this.stackLoadedConfig}}function Si(e,t,i,n){var s;const{pocOverrides:o,runningABTest:r}=function(e,t){var i;const{overrideABTest:n,...s}=e,o=(null===(i=null==n?void 0:n.sites)||void 0===i?void 0:i[t])||(null==n?void 0:n.scope);if(!o)return{pocOverrides:s,runningABTest:[]};const r=P(o.ratio),a=Object.keys(o.populationB);if(r){return{pocOverrides:Object.assign({...s},{...o.populationB}),runningABTest:a.map((e=>({name:e,value:"B"})))}}return{pocOverrides:s,runningABTest:a.map((e=>({name:e,value:"A"})))}}(null!==(s=t.pocOverrides)&&void 0!==s?s:{},t.tagId);return{...new Ai(e,o).withConvertToInstreamAdUnit().withFirstId().withId5Id().withSkinRenderingSettings(t.tagId,n.stackId).withRefreshAlwaysInView().withrefreshBehaviorOnEmpty().withRefreshOutOfFocus(t.tagId).withStickyDivCreation().withXplnConfig(t.tagId).withOutbrainConfig(t.tagId).withFledgeForGpt().withRtbHousePaapi().withSkinFloor(t.tagId).withDsaConfig().withPrebidServerConfig(t.tagId).withPpidSolution(t.tagId).withConvertToInterstitialAdUnit().withPbjsAnalytics(t.tagId).withFloorEnforcement(t.tagId).withDynamicPrebidFloors(t.tagId).withAnchorDesktop(t.tagId).build(),runningABTest:r}}const Ii=e=>!!e.priority&&!!e.conditions,ki=e=>!e.priority&&!e.conditions,Ei=e=>"elements"in e;const $i={AND:({elements:e},t)=>e.every((e=>Ti(e,t))),OR:({elements:e},t)=>e.some((e=>Ti(e,t)))},Oi={IN:({key:e,values:t},i)=>t.some((t=>t===i.get(e))),NOT_IN:({key:e,values:t},i)=>!t.some((t=>t===i.get(e)))};function Ti(e,t){return Ei(e)?$i[e.op](e,t):Oi[e.op](e,t)}const _i={pbjsFinished:!1,apsFinished:!1},Ri="[executor] [buffered]";var Li;!function(e){e[e.FirstCall=0]="FirstCall",e[e.Refresh=1]="Refresh"}(Li||(Li={}));class Ui{constructor(e,t,i,n,s,o){this.buffer=[],this.auctionRunning=!1,this.adUnitAuctionStatus=new Map,this.adServer=e,this.pbjs=t,this.aps=i,this.logPrefix=`${Ri}${o?` [${o}]`:""}`,this.bidderAliases=n,this.kleanadsRunCount=s}executeAdCall(e){if(0===e.length)return;setTimeout((()=>{e.forEach((e=>it(e.divId,"executorTimeout")))}),2e4);const t=e.filter((e=>!this.adUnitAuctionStatus.has(e.divId))).sort(((e,t)=>$(e.divId)-$(t.divId)));this.logAlreadyMonetizedAdUnits(e,t),w(`${this.logPrefix} buffering adunits`,e),t.forEach((e=>{this.bufferAdUnits({adUnits:[e],origin:Li.FirstCall})}))}executeAdCallRoadblock(e){if(0===e.length)return;setTimeout((()=>{e.forEach((e=>it(e.divId,"executorTimeout")))}),2e4);const t=e.filter((e=>!this.adUnitAuctionStatus.has(e.divId))).sort(j);this.logAlreadyMonetizedAdUnits(e,t),w(`${this.logPrefix} buffering adunits`,e),g("executor:roadblock",{slotIds:t.map((e=>e.divId))}),this.bufferAdUnits({adUnits:t,origin:Li.FirstCall})}bufferAdUnits(e){var t;switch(this.buffer.push(e),e.origin){case Li.FirstCall:null===(t=e.adUnits)||void 0===t||t.forEach((e=>{this.adUnitAuctionStatus.set(e.divId,_i)}));break;case Li.Refresh:this.adUnitAuctionStatus.set(e.refreshableAdUnit.adUnit.divId,_i);break;default:I(`${this.logPrefix} unknown buffer entry origin`)}this.startAuctionForBufferedAdUnits()}executeRefresh(e){this.bufferAdUnits({refreshableAdUnit:e,origin:Li.Refresh})}startAuctionForBufferedAdUnits(){if(this.auctionRunning)return void w(`${this.logPrefix} auction already running, not starting a new one`);w(`${this.logPrefix} looking at buffer with ${this.buffer.length} entries`);const e=this.buffer.shift();if(w(`${this.logPrefix} adunits taken from buffer`,e),e)switch(e.origin){case Li.FirstCall:this.startAuction(e.adUnits);break;case Li.Refresh:this.startAuction([e.refreshableAdUnit.adUnit],{labels:["pubstackRefresh",`pubstackRefreshRank:${e.refreshableAdUnit.rank}`]});break;default:I(`${this.logPrefix} unknown buffer entry origin`)}else w(`${this.logPrefix} no more adunit to monetize in buffer`)}startAuction(e,t){if(this.auctionRunning=!0,e.forEach((e=>{We(e.divId,je.START_AUCTION)})),w(`${this.logPrefix} starting auctions for ${e.map((e=>e.divId))}`),this.pbjs){const i=this.pbjs.getPbjs();this.pbjs.startPbjsAuction(e,(()=>{this.kleanadsRunCount===Zi?this.pbjsFinished(i,e):w(`${Ri} kleanads run count has changed (from ${this.kleanadsRunCount} to ${Zi}), avoid calling pbjsFinished`)}),this.bidderAliases,t)}this.aps&&this.aps.startApsAuction(e,((t,i)=>{this.kleanadsRunCount===Zi?this.apsFinished(t,e,i):w(`${Ri} kleanads run count has changed (from ${this.kleanadsRunCount} to ${Zi}), avoid calling apsFinished`)})),this.pbjs||this.aps||this.adServer.executeWhenAdServerReady((()=>{this.kleanadsRunCount===Zi?this.callAdServer(e):w(`${Ri} kleanads run count has changed (from ${this.kleanadsRunCount} to ${Zi}), avoid calling AdServer`)}))}isAlreadyMonetized(e){return this.adUnitAuctionStatus.has(e.divId)}logAlreadyMonetizedAdUnits(e,t){if(e.length!==t.length){const t=e.filter((e=>this.adUnitAuctionStatus.has(e.divId)));S(`${this.logPrefix} cannot make a new ad call, existing one on ${t.map((e=>e.divId)).join(",")}.`)}}pbjsFinished(e,t){w(`${this.logPrefix} pbjs end callback for ${t.map((e=>e.divId)).join(",")}`,e.getAllPrebidWinningBids()),t.forEach((e=>{We(e.divId,je.END_PBJS_AUCTION),st(e.divId)})),this.adServer.executeWhenAdServerReady((()=>{w(`${this.logPrefix} pbjs end callback ad server ready ${t.map((e=>e.divId)).join(",")}`),this.adServer.setPbjsTargetings(e,t),t.forEach((e=>{const t=this.adUnitAuctionStatus.get(e.divId);t&&this.adUnitAuctionStatus.set(e.divId,{...t,pbjsFinished:!0})})),this.canCallAdServer(t)&&this.callAdServer(t)}))}apsFinished(e,t,i){w(`${this.logPrefix} aps end callback ${t.map((e=>e.divId)).join(",")}`,i),t.forEach((e=>We(e.divId,je.END_APS_AUCTION))),this.adServer.executeWhenAdServerReady((()=>{w(`${this.logPrefix} aps end callback ad server ready ${t.map((e=>e.divId)).join(",")}`),this.adServer.setApsTargetings(e,t,i),t.forEach((e=>{const t=this.adUnitAuctionStatus.get(e.divId);t&&this.adUnitAuctionStatus.set(e.divId,{...t,apsFinished:!0})})),this.canCallAdServer(t)&&this.callAdServer(t)}))}canCallAdServer(e){const t=e.filter((e=>{const t=this.adUnitAuctionStatus.get(e.divId);return this.aps&&!this.pbjs?t&&t.apsFinished:this.pbjs&&!this.aps?t&&t.pbjsFinished:this.pbjs&&this.aps?t&&t.apsFinished&&t.pbjsFinished:void 0}));return t.length>0&&t.length!==e.length&&I(`${this.logPrefix} cannot call ad server for ${e.map((e=>e.divId)).join(",")}, some ad units are not ready`),t.length>0}callAdServer(e){if(this.auctionRunning=!1,this.startAuctionForBufferedAdUnits(),e.forEach((e=>{We(e.divId,je.START_AD_SERVER_CALL)})),e.length>0){this.adServer.callAdServer(e);const t=e.map((e=>e.divId));w(`${this.logPrefix} ad server called ${t.join(",")}`)}}}class xi{constructor(e,t,i){this.stackConfig=e,this.kleanAdsConfig=t,this.pageContext=i,this.adUnits=[],this.callbacks=[]}alreadyUsedDivIds(){return this.adUnits.map((e=>e.divId))}setConfig(e,t,i){this.stackConfig=e,this.kleanAdsConfig=t,this.pageContext=i,this.adUnits=[],this.callbacks=[]}async executeWhenAdUnitsFound(e){const t=(i=this.stackConfig,n=this.kleanAdsConfig,s=this.pageContext,Pi(i.adUnits,i,n,s)).filter((e=>!this.alreadyUsedDivIds().includes(e.divId)));var i,n,s;if(this.adUnits.push(...t),await e(this.adUnits),this.callbacks.push(e),!this.adUnitObserver){const e=async e=>{const t=function(e,t,i,n){return Pi([e],t,i,n)}(e,this.stackConfig,this.kleanAdsConfig,this.pageContext).filter((e=>!this.alreadyUsedDivIds().includes(e.divId))).reduce(((e,t)=>(e.find((e=>e.divId===t.divId))?I(`We tried to prepare two times the same divId, skipping adUnit ${t.adServerAdUnitName} from the list`,t):(e.push(t),A("New adUnit dynamicaly loaded",t.divId)),e)),[]);t.length>0&&(this.adUnits.push(...t),this.callbacks.forEach((async e=>{await e(t)})))};this.startAdUnitObserver(e)}}cleanObserverAndAdUnits(){var e;null===(e=this.adUnitObserver)||void 0===e||e.disconnect(),this.adUnitObserver=void 0,this.adUnits=[]}startAdUnitObserver(e){const t=this.alreadyUsedDivIds(),i=this.stackConfig.adUnits.filter((e=>!t.includes(e.divId)||e.dynamic)),n=document.body,s=new MutationObserver(function(e,t){return(i,n)=>{i.filter((e=>"childList"===e.type&&e.addedNodes.length>0)).forEach((i=>{Array.from(i.addedNodes).filter((e=>e.nodeType===Node.ELEMENT_NODE)).forEach((i=>{e.forEach((e=>{const n=e.divId.startsWith("css:")?e.divId.replace("css:",""):e.dynamic?`[id^="${e.divId}"]`:`[id="${e.divId}"]`;(i.matches(n)||i.querySelectorAll(n).length>0)&&t(e)}))}))}))}}(i,e));s.observe(n,{childList:!0,subtree:!0}),this.adUnitObserver=s}}function Pi(e,t,i,n){var s,o;const r=null!==(o=null===(s=null==t?void 0:t.gamConfig)||void 0===s?void 0:s.adUnitPathConfig)&&void 0!==o?o:[];return be(e,n,function(e,t){var i,n,s,o,r;const a=null!==(n=null===(i=null==t?void 0:t.gamConfig)||void 0===i?void 0:i.networkId)&&void 0!==n?n:e.networkId,d=(null===(s=null==t?void 0:t.gamConfig)||void 0===s?void 0:s.mcmIds)&&(null===(o=null==t?void 0:t.gamConfig)||void 0===o?void 0:o.mcmIds.length)>0?null===(r=null==t?void 0:t.gamConfig)||void 0===r?void 0:r.mcmIds:e.mcmIds;return a?d?[a,...d].join(","):a:""}(i,t),r,i.pubstackDeclarationTargetingKeys)}let Ni=(()=>{let e,t,i=[Jt("onStackConfigLoad")],n=[];return t=class{constructor(){this.name="AdUnitsManager"}get adUnitsManager(){return this._adUnitsManager}isLoaded(){return!!this._adUnitsManager}async load({config:e,stackConfig:t}){this._adUnitsManager=new xi(t,e,e.pageContext)}async onStackConfigLoad({config:e,stackConfig:t}){var i;null===(i=this._adUnitsManager)||void 0===i||i.setConfig(t,e,e.pageContext)}async clean(){var e;null===(e=this._adUnitsManager)||void 0===e||e.cleanObserverAndAdUnits()}},Ht(t,"AdUnitsManagerModule"),(()=>{const s="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;Vt(null,e={value:t},i,{kind:"class",name:t.name,metadata:s},null,n),t=e.value,s&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:s}),Gt(t,n)})(),t})();const ji=e=>{var t,i;if(null===(t=e.refreshConfig)||void 0===t?void 0:t.adUnitConfig.some((e=>e.refreshOutOfFocusConfig)))return e;return e.refreshConfig&&P(1)&&(null===(i=e.refreshConfig)||void 0===i||i.adUnitConfig.forEach((e=>{e.refreshOutOfFocusConfig={timerInView:1}}))),e},Di="kleanads-refresh";function Bi(e,...t){u(Di,e,...t)}function Mi(e,...t){f(Di,e,...t)}class Fi{constructor(e,t){this.element=e,this.dateIn=0,this.pastTimeInView=0,this.isInview=!1,this.alwaysInView=null!=t&&t,this.isTabActivated="visible"===window.document.visibilityState,this.isVisible=!window.document.hidden,this.resetAt=0,this.hasBeenReset=!1}getTimeInView(e){return this.hasBeenReset?e>=this.dateIn&&this.dateIn>0&&(this.isInview||this.alwaysInView)&&this.isTabActivated?this.pastTimeInView+(e-this.dateIn):this.pastTimeInView:0}getTimeOnPage(e){return this.hasBeenReset?e-this.resetAt:0}resetTimer(e){(this.isInview||this.alwaysInView)&&this.isTabActivated&&(this.dateIn=e),this.resetAt=e,this.hasBeenReset=!0,this.pastTimeInView=0}updateTimerOnInViewChange(e,t){this.isInview=e,this.updateTimer(t)}updateTimerOnTabStatusChange(e,t){this.isTabActivated=e,this.updateTimer(t)}updateTimerOnVisibleChange(e,t){this.isVisible=e,this.updateTimer(t)}updateTimer(e){if((this.isInview||this.alwaysInView)&&this.isTabActivated)return 0===this.dateIn?void(this.dateIn=e):this.dateIn>0?void 0:void(this.dateIn=e);this.dateIn>0&&(e>=this.dateIn&&(this.pastTimeInView=this.pastTimeInView+(e-this.dateIn)),this.dateIn=0)}}const zi={root:null,rootMargin:"0px",threshold:.5};class Wi{constructor(e,t){this.elements={},this.observer=new IntersectionObserver((e=>{this.handleIntersect(e,this),Mi("AdUnitsObserver",this)}),zi),this.configAlwaysInView=t,e.forEach((e=>{this.elements[e.id]=new Fi(e,null==t?void 0:t[e.id]),this.observer.observe(e)})),addEventListener("visibilitychange",(()=>{Mi("visibilitychange",window.document.visibilityState),"visible"===window.document.visibilityState?Object.keys(this.elements).forEach((e=>{this.elements[e].updateTimerOnTabStatusChange(!0,Date.now())})):Object.keys(this.elements).forEach((e=>{this.elements[e].updateTimerOnTabStatusChange(!1,Date.now())}))}))}isObserving(e){return e in this.elements}unobserve(e){this.isObserving(e)&&(this.observer.unobserve(this.elements[e].element),delete this.elements[e])}observe(e){var t;this.isObserving(e.id)||(this.elements[e.id]=new Fi(e,null===(t=this.configAlwaysInView)||void 0===t?void 0:t[e.id]),this.observer.observe(e))}getObservedDivIds(){return Object.keys(this.elements)}getTimeInView(e,t){return this.isObserving(e)?this.elements[e].getTimeInView(t):0}isInView(e){return!!this.isObserving(e)&&this.elements[e].isInview}getTimeOnPage(e,t){return this.isObserving(e)?this.elements[e].getTimeOnPage(t):0}resetTimers(e,t){e.forEach((e=>{Mi(`reseting time for ${e}`),this.elements[e].resetTimer(t)}))}getAdUnitInViewTimer(e){return this.elements[e]}handleIntersect(e,t){e.forEach((e=>{const i=Date.now();t.elements[e.target.id].updateTimerOnInViewChange(e.isIntersecting,i),Mi("AdUnitsObserver",e.target.id,t.elements[e.target.id])}))}}class Vi{constructor(e,t,i){this.adUnitsObserver=new Wi(e,i),this.exclusions=t,this.lastRenderInfo={},this.refreshRank={},this.hasAuctionInProgress={},this.shouldRefreshBeforeTimerEnd={},this.consecutiveSecondChanceAttempts={},e.forEach((e=>{this.refreshRank[e.id]=0,this.hasAuctionInProgress[e.id]=!1,this.shouldRefreshBeforeTimerEnd[e.id]=!1,this.consecutiveSecondChanceAttempts[e.id]=0}))}unobserve(e){Mi("refresh unobserve",e),this.adUnitsObserver.unobserve(e)}addAdUnits(e){e.forEach((e=>{Mi("refresh addAdUnit",e.id),this.adUnitsObserver.observe(e),this.refreshRank[e.id]=0,this.hasAuctionInProgress[e.id]=!1}))}getTimeInView(e,t){return this.adUnitsObserver.getTimeInView(e,t)}getTimeOnPage(e,t){return this.adUnitsObserver.getTimeOnPage(e,t)}isInView(e){return this.adUnitsObserver.isInView(e)}needRefresh(e,t,i){var n,s;if(!this.adUnitsObserver.isObserving(e))return!1;if(this.cappingReached(e,i.capping))return!1;if(this.hasAuctionInProgress[e])return!1;if(this.shouldRefreshBeforeTimerEnd[e])return this.shouldRefreshBeforeTimerEnd[e]=!1,!0;const o=this.getTimeInView(e,t),r=this.getTimer(e,i.timer,i.refreshSpecificRules);!function(e,t,i,n,s,o){if(l()){const r=document.getElementById(t),a=null==r?void 0:r.parentElement,d="refresh_kleanads";let l=document.getElementById(`${d}_${t}-refresh-debug`);l||(l=document.createElement("div"),l.id=`${d}_${t}-refresh-debug`,l.style.position="absolute",l.style.bottom="5px",l.style.left="5px",l.style.zIndex="99999999",l.style.backdropFilter="blur(6px)",l.style.textShadow="1px 1px 1px rgba(0, 0, 0, 0.3)",l.style.fontFamily="Arial, sans-serif",l.style.borderRadius="5px",l.style.color="white",l.style.padding="8px 16px",l.style.display="flex",l.style.flexDirection="column",l.style.gap="5px",l.style.textAlign="left",l.style.border="1px solid white",l.style.transition="background-color 250ms linear",null==a||a.prepend(l));let c=document.getElementById(`${d}_${t}-refresh-div-id`);c||(c=document.createElement("span"),c.id=`${d}_${t}-refresh-div-id`,l.appendChild(c)),c.textContent=`${t}`,c.style.fontSize="1rem",c.style.fontWeight="bold";let u=document.getElementById(`${d}_${t}-refresh-debug-timer`);u||(u=document.createElement("span"),u.id=`${d}_${t}-refresh-debug-timer`,l.appendChild(u)),u.textContent=`Time in view : ${Math.floor(i/1e3).toString()}`,u.style.fontSize="1rem";let f=document.getElementById(`${d}_${t}-refresh-debug-refresh-rank`);f||(f=document.createElement("span"),f.id=`${d}_${t}-refresh-debug-refresh-rank`,l.appendChild(f));const h=null!=n?n:"∞";f.textContent=`Refresh rank : ${e.getRefreshRank(t).toString()} / ${h}`,f.style.fontSize="1rem",l.style.backgroundColor=s&&o?"rgba(55, 110, 79, 0.7)":"rgba(140, 71, 79, 0.7)"}}(this,e,o,i.capping,null===(n=this.adUnitsObserver.getAdUnitInViewTimer(e))||void 0===n?void 0:n.isTabActivated,null===(s=this.adUnitsObserver.getAdUnitInViewTimer(e))||void 0===s?void 0:s.isInview);const a=i.refreshOutOfFocusConfig,d=i.alwaysInView;if(a&&!d){const n=this.getTimeOnPage(e,t),s=this.isInView(e),r=1e3*a.timerInView,d=this.getTimer(e,i.timer,i.refreshSpecificRules);return a.refreshOutOfView?o>=r&&n>=d:s&&o>=r&&n>=d}return o>=r}cappingReached(e,t){return!!t&&t<this.getRefreshRank(e)}getTimer(e,t,i){if("video"===this.getLastWinningMediaType(e))return 3e4;const n=this.getLastWinningBidder(e),s=this.getLastSize(e),o=[];return i.forEach((e=>{if(!e.timer)return;const t=!!n&&e.bidders.includes(n)&&0===e.sizes.length,i=s&&e.sizes.find((e=>X(e,s)))&&0===e.bidders.length,r=n&&s&&e.bidders.includes(n)&&e.sizes.find((e=>X(e,s)));(t||i||r)&&o.push(1e3*e.timer)})),o.length>0?Math.max(...o):1e3*t}getObservedDivIds(){return this.adUnitsObserver.getObservedDivIds()}getRefreshRank(e){const t=this.refreshRank[e];return this.adUnitsObserver.isObserving(e)&&t?t:0}updateAdUnitStatus(e,t){const i=e.divId;if(this.refreshRank[i]+=1,this.lastRenderInfo[i]=e,Mi(`update status ${i} new refresh rank ${this.refreshRank[i]}`),e.isEmpty){if(t.refreshBehaviorOnEmpty===we.Continue)return;if(t.refreshBehaviorOnEmpty===we.InstantSecondChance)return void(this.consecutiveSecondChanceAttempts[t.divId]<1&&(this.consecutiveSecondChanceAttempts[t.divId]++,this.shouldRefreshBeforeTimerEnd[t.divId]=!0));Mi(`${i} is excluded from refresh from now on (empty impression)`),this.unobserve(i)}else this.consecutiveSecondChanceAttempts[t.divId]=0;const n=t.refreshSpecificRules.filter((e=>!e.timer)),s=this.getLastWinningBidder(t.divId),o=this.getLastSize(t.divId);(!!n.find((e=>{const t=!!s&&e.bidders.includes(s),i=!!o&&!!e.sizes.find((e=>X(e,o))),n=t&&0===e.sizes.length,r=i&&0===e.bidders.length;return n||r||t&&i}))||this.isExcludedByConfig(t.divId)||this.cappingReached(i,t.capping))&&(Mi(`${i} is excluded from refresh from now on`),this.unobserve(i))}getLastSize(e){var t;return(null===(t=this.lastRenderInfo[e])||void 0===t?void 0:t.size)||void 0}getLastAdvertiserId(e){var t;return(null===(t=this.lastRenderInfo[e])||void 0===t?void 0:t.advertiserId)||void 0}getLastWinningBidder(e){var t;return null===(t=this.lastRenderInfo[e])||void 0===t?void 0:t.hb_bidder}getLastWinningMediaType(e){var t;return null===(t=this.lastRenderInfo[e])||void 0===t?void 0:t.hb_mediaType}resetTimer(e,t){this.adUnitsObserver.resetTimers([e],t),this.hasAuctionInProgress[e]=!1}setAuctionInProgress(e){this.hasAuctionInProgress[e]=!0}isExcludedByConfig(e){const t=this.getLastAdvertiserId(e),i=this.getLastWinningLineItemId(e),n=this.getLastWinningOrderId(e),s=!!t&&this.exclusions.advertisers.includes(t),o=!!n&&this.exclusions.orders.includes(n),r=!!i&&this.exclusions.lineItems.includes(i);return s||o||r}getLastWinningLineItemId(e){var t;return(null===(t=this.lastRenderInfo[e])||void 0===t?void 0:t.lineItemId)||void 0}getLastWinningOrderId(e){var t;return(null===(t=this.lastRenderInfo[e])||void 0===t?void 0:t.orderId)||void 0}}async function Gi(e,i,n,s,o){const r=[],a=[],d={},l=new Vi([],s,d);e.executeWhenAdUnitsFound((async e=>{Bi("adUnits found for refresh",e),function(e,t){return e.flatMap((e=>{const i=e.adUnitNames.flatMap((e=>t.filter((t=>t.adUnitName.startsWith(e))))),n=e.specificRules.map((e=>e.bidder?{bidders:[e.bidder],sizes:[],timer:e.timer}:e));return i.filter((e=>!!e)).flatMap((t=>({...t,alwaysInView:e.alwaysInView,capping:e.capping,timer:e.timer,refreshSpecificRules:n,refreshBehaviorOnEmpty:e.refreshBehaviorOnEmpty,refreshOutOfFocusConfig:e.refreshOutOfFocusConfig})))}))}(n,e).forEach((e=>{r.push(e),e.alwaysInView&&(d[e.divId]=!0);const t=document.getElementById(e.divId);t?(a.push(t),l.addAdUnits([t])):Bi("element to refresh not found with id",e.divId)}))})),o.renderListener((e=>function(e,t,i){const n=e.divId,s=t.find((e=>e.divId===n));if(s){const t=e.hb_bidder;i.resetTimer(n,Date.now()),i.updateAdUnitStatus(e,s),t&&Mi(`we have a winning bidder for ${n} that is from prebid: ${t}`),Mi("render on",n)}}(e,r,l)));const c=()=>{const e=[],t=Date.now();l.getObservedDivIds().forEach((i=>{const n=r.find((e=>e.divId===i));n&&l.needRefresh(i,t,n)&&e.push(n)})),e.length>0&&e.forEach((e=>{const t=l.getRefreshRank(e.divId);Bi(`refresh on ${e.divId} with rank ${t}`);const n={adUnit:e,rank:t};o.setRefreshTargeting(n),i.executeRefresh(n),l.setAuctionInProgress(e.divId)})),l.getObservedDivIds().length>=0?setTimeout((()=>{c()}),100):Bi("There is no more adUnits observed, stop refreshCycle")};c();window.dispatchEvent(new CustomEvent(t.REFRESH_INIT,{detail:{stopRefresh:e=>{e&&Array.isArray(e)&&(null==e?void 0:e.length)>0?e.forEach((e=>{l.unobserve(e)})):l.getObservedDivIds().forEach((e=>{l.unobserve(e)}))}}}));const u=()=>{window.removeEventListener(t.PAGE_CHANGE,u),Bi("history mutation event received"),o.removeRenderListener(),a.forEach((e=>{l.resetTimer(e.id,Date.now()),l.unobserve(e.id)})),l.refreshRank={},l.lastRenderInfo={}};window.addEventListener(t.PAGE_CHANGE,u)}const Hi="[instream] [Dailymotion]";class Ji{constructor(e,t,i,n){this.callbackAdded=!1,this.configSetOnce=!1,this.adReadyToFetchReceivedOnce=!1,this.adReadyToFetchCallback=()=>{},this.declaredAdUnit="",this.pubstackWindow=e,this.pageContext=t,this.device=i,this.targetings=qi(this.device,this.pubstackWindow),this.instreamType=null!=n?n:"dailymotion-v1"}declareAdUnit(e){"dailymotion-v3"===this.instreamType&&""===this.declaredAdUnit&&(this.declaredAdUnit=e.divId,this.executeWhenAdServerReady((()=>{const t=this.pubstackWindow.dailymotion;t?t.getPlayer(e.divId).then((t=>{var i;t.on(null===(i=this.pubstackWindow.dailymotion)||void 0===i?void 0:i.events.AD_READYTOFETCH,(()=>{w(`${Hi} ${e.divId} event AD_READYTOFETCH received`),this.adReadyToFetchReceivedOnce||(this.adReadyToFetchReceivedOnce=!0),this.adReadyToFetchCallback()}))})):I(`${Hi} unable to get dailymotion on the page`)})))}setApsTargetings(e,t){var i;if(!e||0===t.length)return;w(`${Hi} putting targeting keys for aps auction of winning bidder`,t[0]);const n=null===(i=t[0].helpers)||void 0===i?void 0:i.qsParams();if(n)return void this.targetings.push(n.slice(1));const s=t[0].qsParams;s&&this.targetings.push(s.slice(1))}executeWhenAdServerReady(e){this.pubstackWindow.dailymotion?e():setTimeout(this.executeWhenAdServerReady.bind(this,e),100)}async callAdServer(e,t){var i,n,s;const o=e.divId;if("dailymotion-v3"===this.instreamType&&e.divId!==this.declaredAdUnit)return void I(`${Hi} ${e.divId} call ad server but it is not the same divId as the one declared ${this.declaredAdUnit}`);w(`${Hi} ${o} call ad server`);const r=await(null===(i=this.pubstackWindow.dailymotion)||void 0===i?void 0:i.getPlayer(o));if(!r)return void I(`${Hi} no player found for ${o}`);w(`${Hi} ${o} player:`,r);const a=await r.getState();switch(this.customConfig=function(e,t,i,n){var s,o;const r=function(e){return e.getTargetings().map(Ki)}(e);w(`${Hi} adUnitTargetings`,r);const a=Array.from(i.entries()).filter((([,e])=>!!e)).map((([e,t])=>`${e}=${t}`)),d=r.concat(t).concat(a).join("&"),l={...null===(s=e.instreamParams)||void 0===s?void 0:s.vast,vpmute:n.playerIsMuted?1:0},c=Object.keys(l).map((function(e){return`${e}=${l[e]}`})).join("&"),u=null===(o=e.instreamParams)||void 0===o?void 0:o.adDeactivationContext;let f=!1;if(u){const e=i.get(u.key);f=!!e&&u.values.includes(e)}const h={dynamiciu:e.adUnitPath,keyvalues:d,keyvalues2:c};return f?{...h,premium:"true"}:h}(e,this.targetings,this.pageContext,a),w(`${Hi} generated customConfig`,this.customConfig),this.instreamType){case"dailymotion-v1":w(`${Hi} ${o} setCustomConfig`,this.customConfig),r.setCustomConfig(this.customConfig),w(`${Hi} ad server called ${o}`),document.dispatchEvent(new CustomEvent("admDailymotionReady",{detail:{divId:o}})),w(`${Hi} ${o} admDailymotionReady event dispatched`);break;case"dailymotion-v2":this.callbackAdded||(w(`${Hi} ${o} add callback to event ${null===(n=this.pubstackWindow.dailymotion)||void 0===n?void 0:n.events.AD_READYTOFETCH}`),r.on(null===(s=this.pubstackWindow.dailymotion)||void 0===s?void 0:s.events.AD_READYTOFETCH,(()=>{w(`${Hi} ${o} event AD_READYTOFETCH received, setCustomConfig`,this.customConfig),this.customConfig&&r.setCustomConfig(this.customConfig),t&&(w(`${Hi} ${o} event AD_READYTOFETCH, call "onCallFinished"`),t())})),this.callbackAdded=!0);break;case"dailymotion-v3":!this.configSetOnce&&this.adReadyToFetchReceivedOnce?(w(`${Hi} ${e.divId} event AD_READYTOFETCH already received, setting customConfig"`,this.customConfig),this.customConfig&&(r.setCustomConfig(this.customConfig),this.configSetOnce=!0),t&&(w(`${Hi} ${e.divId} event AD_READYTOFETCH, call "onCallFinished"`),t())):this.adReadyToFetchCallback=()=>{w(`${Hi} ${e.divId} event AD_READYTOFETCH callback, setting customConfig"`,this.customConfig),this.customConfig&&r.setCustomConfig(this.customConfig)}}}setPbjsTargetings(e,t){if(e){w(`${Hi} put pbjs targeting keys for ${t.divId}`);const i=e.getAdserverTargetingForAdUnitCode(t.divId);for(const e of Object.keys(i)){const n=i[e];gt(n)?this.targetings.push(`${e}=${n}`):S(`${Hi} [targeting] unable to set targeting ${e}=${n} on adUnit ${t.divId}`)}}else I(`${Hi} no pbjs given: unable to put header bidding targetings`)}cleanTargetings(){this.targetings.splice(0),this.targetings.push(...qi(this.device,this.pubstackWindow))}}function Ki(e){const t=Q(e);return`${e.key}=${"string"==typeof t?t:t.join(",")}`}function qi(e,t){const i=[],n=K(t);Object.keys(n).forEach((e=>{const t=n[e].join(",");i.push(`${e}=${t}`)})),i.push(`${yt}=1`),i.push(`device=${e}`);const s=Ct.getInstance().grapeshotValues;(null==s?void 0:s.length)&&i.push(`gs_cat=${s.join(",")}`);try{const e=JSON.parse(t.localStorage._pdfps).slice(0,250).join(",");""!==e?i.push(`permutive=${e}`):w(`[${Hi}] no permutive targeting found`)}catch(e){w(`[${Hi}] error reading permutive targeting`)}return i}const Xi="[optimization]",Yi=async e=>{try{const t=await Qi();if(null==e?void 0:e.prebidConfig.adCallTimeout){const i=t.getTimeout(null==e?void 0:e.prebidConfig.adCallTimeout);w(`${Xi} Ad call timeout optimized from ${null==e?void 0:e.prebidConfig.adCallTimeout} to ${i}`),e.prebidConfig.adCallTimeout=i}}catch(e){I(`${Xi} Error while loading optimization engine`,e)}return e},Qi=async()=>new Promise(((e,t)=>{try{const i={env:{}};WebAssembly.instantiateStreaming(fetch("https://cdn-adm.pbstck.com/kleanads/wasm/volt.wasm"),i).then((t=>{w(`${Xi} WebAssembly module loaded successfully`,t),e(t.instance.exports)})).catch((e=>{t(e)}))}catch(e){t(e)}}));let Zi=1;async function en(e,t){var i,n,s,o,r,a,d;ze(Ne.BEGIN_CONFIGURE),await R(e,{beforeStart:!0});const l=window;w(`Configure kleanads.js (version: ${e.kleanadsVersion}, run count: ${Zi})`);const c=function(e,t){const i=t.sort(L);for(const t of i)if(e>=t.size)return t.device;return"desktop"}(l.innerWidth,e.screenSizeBreakpoints);!function(e,t,i,n){m=new p(e,t,i,n),b=e,y=t}(e.tagId,e.kleanadsVersion,c,bi(null===(i=e.pocOverrides)||void 0===i?void 0:i.traceThrottling,e.tagId)),Ct.getInstance().setUprState(null===(n=e.pocOverrides)||void 0===n?void 0:n.uprState,null===(s=e.pocOverrides)||void 0===s?void 0:s.uprRatio);const u=function(e,t){const i=lt(t),n=new Map(i.map((({key:e,defaultValue:t})=>[e,t])));e.document.querySelectorAll('meta[name^="pbstck_context:"]').forEach((e=>{var t,s;const o=null===(t=e.attributes.getNamedItem("name"))||void 0===t?void 0:t.value.substring(15).toLowerCase(),r=null===(s=e.attributes.getNamedItem("content"))||void 0===s?void 0:s.value.toLowerCase();if(o&&r){const e=i.find((({key:e})=>e===o));e&&(function(e,t){var i;return t.defaultValue===e||(null!==(i=t.otherValues)&&void 0!==i?i:[]).includes(e)}(r,e)?(n.set(o,r),w(`[context] found context ${o} with content ${r}`)):S(`[context] Unknown ${o} value ${r}`))}}));const s=new URLSearchParams(e.location.search);for(const e of s.keys())e.startsWith("pbstck_context:")&&(w(`[context] Add key ${e} found in URL to context`),n.set(e.slice(15),s.get(e)||""));return n}(l,e.context);0===u.size?w("[context] No context set"):(w("[context] The following context will be used:"),u.forEach(((e,t)=>{w(`[context] ${t} => ${e}`)})));const f=function(e,t){const i=e.filter(Ii).sort(((e,t)=>e.priority-t.priority)),n=e.filter(ki);0===n.length&&I("[stacks] Could not find default stack"),n.length>1&&I("[stacks] Multiple default stacks found");const s=n[0],o=i.find((e=>Ti(e.conditions,t))),r=null!=o?o:s;return r?w(`[stacks] served stack: ${r.stackId} ${r===s?"(default stack)":""}`,r):I("[stacks] No stack to serve"),r}(e.stacks,u);if(!f)return void I("No stack found, stopping monetization");const h=sn(f.versions).toString(),g={...e,device:c,stack:f,stackVersion:h,pageContext:u,consentlessMode:null===(o=e.pocOverrides)||void 0===o?void 0:o.consentlessMode,noCmp:q(),spaMode:null===(a=null===(r=e.spaConfig)||void 0===r?void 0:r[e.tagId])||void 0===a?void 0:a.mode,pubstackWindow:l,instreamType:yi(e.tagId,null===(d=e.pocOverrides)||void 0===d?void 0:d.instreamConfig)},v=new ii(g,t);await v.loadInitialModules(),C=h;return{configPromise:tn(e,c,f,h,u),kleanAdsConfig:g,moduleService:v}}async function tn(e,t,i,n,s){return xe(e,t,i,n).then((t=>t?e.pocOverrides?Si(t,e,0,i):{...t,runningABTest:[]}:t)).then((e=>e?ji(e):e))}async function nn(e){var t,i,n,s,r,a,d,l,c;const{configPromise:u,kleanAdsConfig:{device:f,pageContext:h,...g},moduleService:p}=e;w("StartKleanAds"),ze(Ne.BEGIN_START),rt();const v=g.noCmp||await at(window);Ze!==Qe.UNKNOWN&&k("[metric] cmpResponseAvailable",{cmpResponseAvailable:Ge(Pe.CMP_RESPONSE_AVAILABLE),fromBeginCmpResponseAvailable:He(Pe.BEGIN_INIT,Pe.CMP_RESPONSE_AVAILABLE),consentType:Ze}),await p.modulesDispatchEvent("onAfterConsent"),await R(g,{beforeStart:!1});const m=g.stacks.find((e=>e.stackId===function(e){var t,i;return null===(i=null===(t=e.pocOverrides)||void 0===t?void 0:t.consentlessStacks)||void 0===i?void 0:i[e.tagId]}(g)));if(v){const e=await p.modulesDispatchEvent("onAfterConsentAccepted");await Promise.all(e)}else{w("Consent refused");const e=await p.modulesDispatchEvent("onAfterConsentRefused");await Promise.all(e),m&&(w("Consentless stack is the following",m),g.stack=m,g.stackVersion=sn(m.versions).toString(),w("Consent not given, using override consentless stack: ",m.stackId))}if(v||g.consentlessMode||m){await p.modulesDispatchEvent("onBeforeStackConfigLoad");const e=v?u:tn(g,f,g.stack,g.stackVersion);let o=await e;if(o&&(null===(t=g.pocOverrides)||void 0===t?void 0:t.optimizationModule)&&(o=await Yi(o),w("[pocOverrides] Optimization module finished")),w("[config] kleanAdsConfig:",g),w("[config] stackLoadedConfig:",o),o){if(g.pocOverrides&&g.pocOverrides.grapeshotTargetings){w("[pocOverrides] Poc Grapeshot enabled");const e=await async function(e){return new Promise((t=>{const i=`${e}${encodeURIComponent(window.location.href)}`,n=document.createElement("script");n.async=!0,n.src=i,n.onload=()=>t(window.gs_channels),setTimeout((()=>t(void 0)),3e3),n.onerror=()=>t(void 0),document.head.append(n)}))}(g.pocOverrides.grapeshotTargetings);Ct.getInstance().grapeshotValues=e}await p.modulesDispatchEvent("onStackConfigLoad",{stackConfig:o});const e=null===(i=p.getLoadedModuleInstance(hi))||void 0===i?void 0:i.pbjs;e&&await p.modulesDispatchEvent("onAfterPrebidReady",{prebid:e});const t=null===(n=p.getLoadedModuleInstance(ei))||void 0===n?void 0:n.aps,u=null===(s=p.getLoadedModuleInstance(Wt))||void 0===s?void 0:s.adServer;u&&await p.modulesDispatchEvent("onAfterAdServerReady",{adServer:u});const v=null===(r=p.getLoadedModuleInstance(Ni))||void 0===r?void 0:r.adUnitsManager;if(!u)return void I("no adServer found, stopping monetization");if(!v)return void I("no adUnitManager found, stopping monetization");ct(window,g.context,null!==(d=null===(a=o.gamConfig)||void 0===a?void 0:a.adUnitPathConfig)&&void 0!==d?d:[]);const m=new Ui(u,e,t,null!==(l=o.prebidConfig.pbjsConfig.bidderAliases)&&void 0!==l?l:[],Zi),b=o.adUnits.some((e=>e.isInstream))?new ht(new Ji(window,h,f,g.instreamType),e,t,null!==(c=o.prebidConfig.pbjsConfig.bidderAliases)&&void 0!==c?c:[],Zi):void 0,y=async e=>{w("[config] adUnits to monetize:",e);const t=await p.modulesDispatchEvent("onPrepareAdUnits",{toPreparedAdUnits:e});Promise.all(t).then((()=>{w("[config] adUnits prepared"),p.modulesDispatchEvent("onAfterPrepareAdUnits",{preparedAdUnits:e})})),vi(e,m,b,o.lazyLoading)};await v.executeWhenAdUnitsFound(y);const C=o.refreshConfig,A=g.globalRefreshConfig;if(A&&C){const e=g.networkId&&A.hasExclusions?await dn(g.configUrl,g.networkId,g.stack.scopeId):Ae;Gi(v,m,C.adUnitConfig,e,u)}}else I("no input configuration, stopping monetization")}else w("consent not given, no monetization");switch(g.spaMode){case"manual":w("[SPA] manual SPA enabled"),an((()=>{w("[SPA] manual page change requested, restarting kleanads.js"),on(g,p)}));break;case"auto":w("[SPA] auto SPA enabled"),o(),rn((()=>{w("[SPA] page change detected, restarting kleanads.js"),on(g,p)}))}Fe(Pe.MAIN_THREAD_END)}function sn(e){const t=e.sort(((e,t)=>e.ratio-t.ratio));return P(void 0!==t[0].ratio?t[0].ratio:100)?t[0].version:t[1].version}const on=async(e,t)=>{ze(Ne.SPA_RELOAD),Zi+=1,w("Unloading Kleanads, run cleanup on all modules");const i=t.getModules();await t.modulesCleanUp(),w("Kleanads unloaded, restarting");const n=await en(e,i);n&&nn(n)},rn=e=>{const i=new MutationObserver((()=>{s()})),n=e=>{const t=e,n=new URL(t.detail.referrer),s=(o=t.detail.url)?`${o}`.startsWith("http")?new URL(o).pathname:`${o}`:"";var o;n.pathname!==s&&i.observe(document.head,{attributes:!0,childList:!0,subtree:!0})};window.addEventListener(t.HISTORY_MUTATION,n);const s=()=>{window.removeEventListener(t.HISTORY_MUTATION,n),i.disconnect(),window.dispatchEvent(new CustomEvent(t.PAGE_CHANGE)),e()}},an=e=>{const n=()=>{s()};window.addEventListener(i.SPA_RELOAD,n);const s=()=>{window.removeEventListener(i.SPA_RELOAD,n),window.dispatchEvent(new CustomEvent(t.PAGE_CHANGE)),e()}},dn=async(e,t,i)=>await fetch(`${e}/refresh-exclusions/${t}/${i}/currentExclusions.json`).then((async e=>e.json().then((e=>e)).catch((e=>{I(`unable to extract line items with no refresh: ${e}`)})))).catch((e=>I(`unable to get line items with no refresh: ${e}`)));let ln=(()=>{let e,t,i=[Jt("onAfterConsent")],n=[];return t=class{constructor(){this.name="Collector",this._isLoaded=!1,this._scriptAdded=!1}isLoaded(){return this._isLoaded}async load(){this._isLoaded=!0}async onAfterConsent({config:e}){this._scriptAdded||(setTimeout((()=>{w("Downloading pubstack collector"),_(`https://boot.pbstck.com/v1/tag/${e.tagId}`)}),200),this._scriptAdded=!0)}async clean(){}},Ht(t,"CollectorModule"),(()=>{const s="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;Vt(null,e={value:t},i,{kind:"class",name:t.name,metadata:s},null,n),t=e.value,s&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:s}),Gt(t,n)})(),t})();let cn=(()=>{let e,t,i=[Jt("onStackConfigLoad")],n=[];var s=t=class{constructor(){this.name="SkinRendering",this._isLoaded=!1,this.eligibleForSkinRendering=!1}isLoaded(){return this._isLoaded}async load({config:e,stackConfig:t}){var i,n,s,o,r,a,d,l,c,u;if(this.eligibleForSkinRendering=function(e,t){var i,n,s,o,r,a,d,l,c;return!!(null===(o=null===(s=null===(n=null===(i=e.pocOverrides)||void 0===i?void 0:i.skinRenderingSettings)||void 0===n?void 0:n.siteLevel)||void 0===s?void 0:s[e.tagId])||void 0===o?void 0:o.enabledSkinRenderAdaptation)&&!(null===(l=null===(d=null===(a=null===(r=e.pocOverrides)||void 0===r?void 0:r.skinRenderingSettings)||void 0===a?void 0:a.stackLevel)||void 0===d?void 0:d[e.stack.stackId])||void 0===l?void 0:l.disableSkinRenderAdaptation)&&(null===(c=t.adUnits)||void 0===c?void 0:c.some((e=>e.sizes.some((e=>X(e,[1800,1e3]))))))}(e,t),this.eligibleForSkinRendering){const{maxHeaderHeightPx:t,marginTopPx:f,siteContentWidthPx:h,additionalSkinRenderingCss:g}=null!==(u=null!==(r=null===(o=null===(s=null===(n=null===(i=e.pocOverrides)||void 0===i?void 0:i.skinRenderingSettings)||void 0===n?void 0:n.stackLevel)||void 0===s?void 0:s[e.stack.stackId])||void 0===o?void 0:o.style)&&void 0!==r?r:null===(c=null===(l=null===(d=null===(a=e.pocOverrides)||void 0===a?void 0:a.skinRenderingSettings)||void 0===d?void 0:d.siteLevel)||void 0===l?void 0:l[e.tagId])||void 0===c?void 0:c.style)&&void 0!==u?u:{};this.configuredMaxHeaderHeightPx=t,this.configuredMarginTopPx=f,this.configuredSiteContentWidthPx=h,this.configuredAdditionalSkinRenderingCss=g,this._isLoaded=!0,w("[Skin] Configuration eligible for skin rendering.")}}async onAfterPrebidReady({prebid:e,config:{pubstackWindow:t}}){this.pbjs=e,this.eligibleForSkinRendering&&(this.onBidWonHandler=this.onBidWon.bind(this),this.pbjs.getPbjs().onEvent("bidWon",this.onBidWonHandler),Nt((()=>{this.onSlotRenderEndedHandler=this.onSlotRenderEnded.bind(this),t.googletag.pubads().addEventListener("slotRenderEnded",this.onSlotRenderEndedHandler)})))}async clean(){var e;this.onBidWonHandler&&(null===(e=this.pbjs)||void 0===e||e.getPbjs().offEvent("bidWon",this.onBidWonHandler),this.onBidWonHandler=void 0),this.onSlotRenderEndedHandler&&(window.googletag.pubads().removeEventListener("slotRenderEnded",this.onSlotRenderEndedHandler),this.onSlotRenderEndedHandler=void 0),this._isLoaded=!1}onBidWon(e){this.shouldApplyPrebidSkinRendering(e)?this.applySkinCSS(e.adUnitCode,"prebid"):this.removeSkinRendering(e.adUnitCode)}onSlotRenderEnded(e){this.isFromGAM(e)?this.applySkinCSS(e.slot.getSlotElementId(),"gam"):e.size&&!X(e.size,[3,1])&&this.removeSkinRendering(e.slot.getSlotElementId())}removeSkinRendering(e){const t=document.getElementById(e);t&&t.classList.remove(s.SKIN_RENDERING_CSS_CLASS)}shouldApplyPrebidSkinRendering(e){var t;const i=["sublime","justpremium","gumgum"],n=null===(t=this.pbjs)||void 0===t?void 0:t.getPbjs();if(n){const t=i.some((t=>e.bidderCode===t||n.aliasRegistry[e.bidderCode]===t));return"1800x1000"===e.size&&!t}return function(e,...t){h(Di,e,...t)}("shouldApplyPrebidSkinRendering: unable to get aliasRegistry: prebid is not defined"),!1}isFromGAM(e){var t;return!!(null===(t=e.size)||void 0===t?void 0:t.length)&&1800===e.size[0]&&1e3===e.size[1]}applySkinCSS(e,t){var i,n,o,r;const a=document.getElementById(e);if(a){if("gam"===t)return;w(`[Skin] applying rendering for ${e} from ${t}`);const d=null!==(i=this.configuredMaxHeaderHeightPx)&&void 0!==i?i:250,l=null!==(n=this.configuredMarginTopPx)&&void 0!==n?n:0,c=null!==(o=this.configuredSiteContentWidthPx)&&void 0!==o?o:1e3,u=null!==(r=this.configuredAdditionalSkinRenderingCss)&&void 0!==r?r:"",f=1e3,h=(1800-c)/2,g=h+c,p=document.createElement("style");p.textContent=`\n        #${e}.${s.SKIN_RENDERING_CSS_CLASS} {\n          /* leave security margin to help display top of creative */\n          height: ${d}px;\n          /* set it properly in page flow */\n          display: block;\n          margin-top: ${l}px;\n        }\n  \n        #${e}.${s.SKIN_RENDERING_CSS_CLASS} > div {\n          /* horizontally center creative */\n          transform: translateX(-50%);\n          position: absolute;\n          left: 50%;\n  \n          /* clipping out the unused part of the creative to leave content visible */\n          clip-path: polygon(0 0, 0% 100%, ${h}px ${f}px, ${h}px ${d}px, ${g}px ${d}px, ${g}px 100%, 100% 100%, 100% 0%);\n        }\n  \n        ${u}\n        `,document.head.appendChild(p),a.classList.add(s.SKIN_RENDERING_CSS_CLASS)}else S(`skin rendering impossible - adUnitDiv not found for ${e}`)}};return Ht(t,"SkinRenderingModule"),(()=>{const o="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;Vt(null,e={value:t},i,{kind:"class",name:t.name,metadata:o},null,n),s=t=e.value,o&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:o})})(),t.SKIN_RENDERING_CSS_CLASS="pbstck_skin_rendering",Gt(t,n),s=t})();const un="adm-ad-loading",fn="adm-ad-empty",hn="adm-ad-rendered",gn="adm-ad-skin",pn="data-adm-skin",vn=["sublime","justpremium","gumgum","dspx"];let mn=(()=>{let e,t,i=[Jt("onAfterAdServerReady")],n=[];return t=class{constructor(){this.name="CssClass",this._isLoaded=!1}async load({config:e,adServer:t}){this.pubstackWindow=e.pubstackWindow,t.renderListener(this.applyClassBySlotRenderEndedEvent),this._isLoaded=!0}async onAfterPrebidReady({prebid:e}){e.getPbjs().onEvent("bidWon",this.applyClassByBidWon)}async applyClassBySlotRenderEndedEvent(e){var t;const i=e.divId,n=document.getElementById(i);n&&(e.isEmpty?(n.classList.replace(un,fn),w(`[CSS Class] slot empty: ${i}`)):(n.classList.replace(un,hn),n.classList.replace(fn,hn),(null===(t=e.size)||void 0===t?void 0:t.length)&&1800===e.size[0]&&1e3===e.size[1]?(n.classList.add(gn),n.setAttribute(pn,"gam"),w(`[CSS Class] slot rendered is skin: ${i}`)):(n.classList.remove(gn),n.removeAttribute(pn)),w(`[CSS Class] slot rendered: ${i}`)))}applyClassByBidWon(e){const t=document.getElementById(e.adUnitCode);"1800x1000"===e.size&&(null==t||t.classList.add(gn),null==t||t.setAttribute(pn,"prebid"),vn.includes(e.bidderCode)||null==t||t.classList.add("adm-ad-skin-resizable"),w(`[CSS Class] bidWon is skin: ${e.adUnitCode}`))}async onPrepareAdUnits({toPreparedAdUnits:e}){e&&e.forEach((e=>{const t=document.getElementById(e.divId);t&&t.classList.add(un)}))}isLoaded(){return this._isLoaded}clean(){return this._isLoaded=!1,Promise.resolve(void 0)}},Ht(t,"CssClassModule"),(()=>{const s="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;Vt(null,e={value:t},i,{kind:"class",name:t.name,metadata:s},null,n),t=e.value,s&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:s}),Gt(t,n)})(),t})();var bn;class yn extends HTMLElement{constructor(){super();const e=window.kleanadsPbjs;if(e)try{e.onEvent("bidWon",this.winningBid.bind(this))}catch(e){S("[pbstck-sticky] unable to listen to bidWon event",e)}else S("[pbstck-sticky] pbjs not loaded, unable to listen to bidWon event");this.attachShadow({mode:"open"}),this.mutationObserver=new MutationObserver((e=>{w("[pbstck-sticky] [mutationObs]",e),this.isAddingCreative(e)&&(w("[pbstck-sticky] [mutationObs] add element on nested"),bn.shouldDisplay=!0),this.updateShadowLayout()})),this.addEventListener("close",(()=>{w('[pbstck-sticky] event "close" caught, closing sticky component'),this.close()}))}winningBid(e){e.adUnitCode===this.id&&(w("[pbstck-sticky] [winningBid]",e),w("[pbstck-sticky] [winningBid]",e.bidderCode,e.adUnitCode),bn.biddersNotToDisplay.includes(e.bidderCode)&&(bn.shouldDisplay=!1,this.updateShadowLayout()))}close(){w("[pbstck-sticky] closing sticky component"),this.shadowRoot&&(this.mutationObserver.disconnect(),this.shadowRoot.innerHTML="\n          <style>\n              :host {\n                display: none;\n              }\n          </style>")}isAddingCreative(e){var t,i,n;return(null===(t=e[0])||void 0===t?void 0:t.addedNodes[0])&&(null===(n=null===(i=e[0])||void 0===i?void 0:i.target.parentElement)||void 0===n?void 0:n.id)===this.id}connectedCallback(){this.isConnected&&(w("[pbstck-sticky] no-ad"),this.setAttribute("data-pbstck-component","no-ad"),this.setShadowDom("<div></div>"),this.updateShadowLayout(),this.mutationObserver.observe(this,{subtree:!0,childList:!0}))}disconnectedCallback(){this.mutationObserver.disconnect()}attributeChangedCallback(){this.updateShadowLayout()}getHighestChild(){const e=Array.from(this.children);if(0!==e.length)return Cn(e)}setShadowDom(e){this.shadowRoot&&(bn.shouldDisplay?this.shadowRoot.innerHTML=`\n          <style> \n              :host {\n                display: block;\n                max-height: ${bn.maxHeight}px;\n                overflow: hidden;\n                position: fixed;\n                bottom: 0;\n                left: 0;\n                right: 0;\n                margin: 0;\n                padding: 0;\n                z-index: 99999999;\n              }\n              .sticky-button {\n                height: 28px;\n                width: 28px;\n                background: ${bn.backgroundColor};\n                position: absolute;\n                bottom: 0;\n                right: 0;\n                border-radius: 5px 0 0 0;\n                box-shadow: rgba(0, 0, 0, 0.2) -2px -2px 3px -1px, rgba(0, 0, 0, 0.1) -1px -1px 2px -1px !important;\n              }\n              .sticky-button-container {\n                height: 30px;\n                position: relative;\n              }\n              .sticky-button-text {\n                display: block;\n                height: 22px;\n                width: 22px;\n                padding: 3px;\n              }\n              .sticky-container {\n                background: ${bn.backgroundColor};\n                padding: 8px 0;\n                box-shadow: rgba(0, 0, 0, 0.2) 0px -1px 5px -1px, rgba(0, 0, 0, 0.1) 0px 1px 2px -1px !important;\n              }\n              .sticky-container slot > * {\n                position: relative;\n              }\n              ::slotted(*) {\n                position: relative;\n              }\n              .cross {\n                display: block;\n              }\n              .sticky-container slot {\n                width: fit-content;\n                width: -moz-fit-content;\n                block-size: fit-content;\n                margin: 0 auto !important;\n                display: block;\n              }\n            }\n          </style>\n          ${e}`:this.shadowRoot.innerHTML="\n          <style>\n              :host {\n                display: block;\n                width: 100%;\n                height: 1px;\n                background: transparent;\n                position: fixed;\n                bottom: 0;\n              }\n          </style><div></div>")}updateShadowLayout(){if(w(`[pbstck-sticky] updating element ${this.id}`),!this.shadowRoot)return;this.setAttribute("data-pbstck-component","sticky");const e=document.createElement("div");e.className="sticky-container";const t=document.createElement("slot");e.append(t),this.setShadowDom(`${e.outerHTML}`);const i=this.getHighestChild();if(i&&bn.shouldDisplay){i.style.display="block",i.style.margin="0 auto",i.style.bottom="0",i.style.maxHeight=`${bn.maxCreativeHeight}px`;const e=document.createElement("div");e.className="sticky-button-container";const t=document.createElement("div");t.className="sticky-button";const n=document.createElement("div");n.className="sticky-button-text",n.addEventListener("click",(()=>{w("[pbstck-sticky] Close button pressed, hiding the sticky adunit"),this.close()}));const s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d","M 5.3,18.7 C 5.5,18.9 5.7,19 6,19 6.3,19 6.5,18.9 6.7,18.7 l 5.3,-5.3 5.3,5.3 c 0.2,0.2 0.5,0.3 0.7,0.3 0.2,0 0.5,-0.1 0.7,-0.3 0.4,-0.4 0.4,-1 0,-1.4 L 13.4,12 18.7,6.7 c 0.4,-0.4 0.4,-1 0,-1.4 -0.4,-0.4 -1,-0.4 -1.4,0 L 12,10.6 6.7,5.3 c -0.4,-0.4 -1,-0.4 -1.4,0 -0.4,0.4 -0.4,1 0,1.4 l 5.3,5.3 -5.3,5.3 c -0.4,0.4 -0.4,1 0,1.4 z");const o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("class","cross"),o.setAttribute("height","22px"),o.setAttribute("width","22px"),o.setAttribute("fill","#333"),o.append(s),n.append(o),t.append(n),e.append(t),this.shadowRoot.prepend(e)}}}bn=yn,yn.backgroundColor="rgb(250, 250, 250)",yn.maxCreativeHeight=216,yn.buttonHeight=32,yn.maxHeight=bn.maxCreativeHeight+bn.buttonHeight,yn.shouldDisplay=!1,yn.biddersNotToDisplay=["ogury","missena","seedtag","kargo","gumgum"];const Cn=e=>e.reduce(((e,t)=>t.offsetHeight>e.offsetHeight?t:e),e[0]);function wn(e){if(e.sticky||e.anchor){const t=e.divId,i=document.getElementById(t);if(w("[pbstck-sticky]",e),"pbstck-sticky"===(null==i?void 0:i.localName))return void w(`[pbstck-sticky] div ${t} already prepared`);const n=document.createElement("pbstck-sticky");n.id=t;const s=`adm-sticky-${t}`;if(i)w(`[pbstck-sticky] div ${t} existing`),i.id=s,i.appendChild(n);else{w(`[pbstck-sticky] div ${t} not existing`);const e=document.createElement("div");e.id=s,e.appendChild(n),document.body.appendChild(e)}}}const An="[parallax]";class Sn{constructor(e){this.id=e.divId;const t=document.getElementById(this.id);if(!t)throw S(`${An} container not found for adUnit ${this.id}`),new Error(`container not found for adUnit ${this.id}`);const i=e.sizes.filter((e=>"fluid"!==e)).reduce(((e,[,t])=>t>e?t:e),0);this.adUnitContainerMaxHeightPx=Math.max(i,600)/2,this.minViewableHeightPx=Math.min(this.adUnitContainerMaxHeightPx+10,310),this.adUnitContainer=t;const n=this.adUnitContainer.attachShadow({mode:"open"});n.innerHTML=`\n      <div id="${Sn.PARALLAX_CLIP_ID}"><slot></slot></div>\n    `,this.adUnitContainerShadowRoot=n,this.cacheLatestBidWon(),this.observeMutations(),w(`${An} prepareGoodParallax for adUnit ${this.id}`)}getHighestChildRect(e){const t=e.children;if(0===t.length)return;const i=(e=>e.reduce(((e,t)=>{const i=getComputedStyle(e),n=getComputedStyle(t);return parseInt(n.height)>parseInt(i.height)?t:e}),e[0]))(Array.from(t));return i.getBoundingClientRect()}cacheLatestBidWon(){const e=null===window||void 0===window?void 0:window.kleanadsPbjs;if(e)try{e.onEvent("auctionEnd",(e=>{var t;(null===(t=e.adUnitCodes)||void 0===t?void 0:t.includes(this.id))&&(this.latestBidWonInfo=void 0)})),e.onEvent("bidWon",(t=>{if(t.adUnitCode===this.id){const{bidderCode:i,size:n}=t,s=Sn.BLOCKED_BIDDERS.some((t=>{var n;return i===t||(null===(n=null==e?void 0:e.aliasRegistry)||void 0===n?void 0:n[i])===t})),o=Sn.BLOCKED_SIZES.some((e=>e===n)),r="banner"===(null==t?void 0:t.mediaType);this.latestBidWonInfo={isParallaxable:r&&!o&&!s}}}))}catch(e){S(`${An} unable to listen to bidWon event`,e)}else S(`${An} pbjs not loaded, unable to listen to bidWon event`)}observeMutations(){this.resizeObserver=new ResizeObserver((e=>{const t=e.some((e=>{var t,i;return Array.from(null!==(i=null===(t=e.target.parentElement)||void 0===t?void 0:t.children)&&void 0!==i?i:[]).some((e=>e.getBoundingClientRect().height>this.adUnitContainerMaxHeightPx))}));(this.latestBidWonInfo?this.latestBidWonInfo.isParallaxable&&t:t)?this.renderParallax():this.cleanUp()})),this.mutationObserver=new MutationObserver((e=>{this.mutationDebounceTimeout&&clearTimeout(this.mutationDebounceTimeout),this.mutationDebounceTimeout=setTimeout((()=>{this.mutationDebounceTimeout=void 0,e.flatMap((e=>Array.from(e.addedNodes))).forEach((e=>{var t;e instanceof HTMLElement&&(null===(t=this.resizeObserver)||void 0===t||t.observe(e))})),e.flatMap((e=>Array.from(e.removedNodes))).forEach((e=>{var t;e instanceof HTMLElement&&(null===(t=this.resizeObserver)||void 0===t||t.unobserve(e))}))}),Sn.MUTATION_DEBOUNCE_TIMEOUT_VALUE_MS)})),this.mutationObserver.observe(this.adUnitContainer,{childList:!0})}renderParallax(){var e,t,i;this.adUnitContainer.classList.add(Sn.PARALLAX_ADUNIT_CONTAINER_CLASS),null===(e=this.adUnitContainerShadowRoot.getElementById(Sn.PARALLAX_CLIP_ID))||void 0===e||e.classList.add(Sn.PARALLAX_CLIP_ENABLED_CLASS);const n=this.getHighestChildRect(this.adUnitContainer),s=(window.innerHeight-(null!==(t=null==n?void 0:n.height)&&void 0!==t?t:0))/2,o=new CSSStyleSheet;o.insertRule(`#${Sn.PARALLAX_CLIP_ID}.${Sn.PARALLAX_CLIP_ENABLED_CLASS} { height: ${this.minViewableHeightPx}px; width: ${null!==(i=null==n?void 0:n.width)&&void 0!==i?i:0}px; clip-path: rect(0 auto ${this.minViewableHeightPx}px 0); position: relative; margin: 0 auto; } `),o.insertRule(`#${Sn.PARALLAX_CLIP_ID}.${Sn.PARALLAX_CLIP_ENABLED_CLASS} ::slotted(*) {\n        position: fixed;\n        top: ${s}px;\n      }`),this.adUnitContainerShadowRoot.adoptedStyleSheets=[o]}cleanUp(){var e;this.adUnitContainer.classList.remove(Sn.PARALLAX_ADUNIT_CONTAINER_CLASS),null===(e=this.adUnitContainerShadowRoot.getElementById(Sn.PARALLAX_CLIP_ID))||void 0===e||e.classList.remove(Sn.PARALLAX_CLIP_ENABLED_CLASS)}}Sn.MUTATION_DEBOUNCE_TIMEOUT_VALUE_MS=40,Sn.PARALLAX_ADUNIT_CONTAINER_CLASS="adm-parallax",Sn.PARALLAX_CLIP_ID="adm-parallax-clip",Sn.PARALLAX_CLIP_ENABLED_CLASS="adm-parallax-clip-enabled",Sn.BLOCKED_BIDDERS=["invibes","seedtag","kargo"],Sn.BLOCKED_SIZES=["1x1"];const In=e=>new Sn(e);let kn=(()=>{let e,t,i=[Jt("onStackConfigLoad")],n=[];return t=class{constructor(){this.name="ContainersModule",this.loaded=!1,this.firstStickyDefined=!1}isLoaded(){return this.loaded}async load(){if("function"==typeof(null===customElements||void 0===customElements?void 0:customElements.define)&&"function"==typeof MutationObserver)try{customElements.define("pbstck-sticky",yn)}catch(e){I(`[ContainersModule] unable to define custom elements, error "${e}"`)}else S('[ContainersModule] unable to define custom elements, error: "browser not compatible"');this.loaded=!0}async onPrepareAdUnits({config:e,toPreparedAdUnits:t}){for(const i of null!=t?t:[])i.parallax&&In(i),"mobile"!==e.device&&!i.anchorDesktop||!i.sticky&&!i.anchor||this.firstStickyDefined||(wn(i),this.firstStickyDefined=!0)}async clean(){}},Ht(t,"ContainersModule"),(()=>{const s="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;Vt(null,e={value:t},i,{kind:"class",name:t.name,metadata:s},null,n),t=e.value,s&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:s}),Gt(t,n)})(),t})(),En=(()=>{let e,t,i=[Jt("onAfterPrepareAdUnits")],n=[];return t=class{constructor(){this.name="XplnModule",this.loaded=!1}async load(){this.loaded=!0}async onStackConfigLoad({config:e,stackConfig:t}){var i,n;if((null===(i=t.xplnConfig)||void 0===i?void 0:i.enabled)&&(null===(n=t.xplnConfig)||void 0===n?void 0:n.publisherId)){const i=t.xplnConfig.publisherId;((e,t)=>{const i=e.document.createElement("script"),n=e.document.createElement("script");i.innerHTML=`(function(x,p,l,n,a,i) {\n          a=p.createElement(l);a.async=!0;a.src=n;a.xpln=x;\n          i=p.currentScript||p.getElementsByTagName(l)[0];i.parentNode.insertBefore(a,i);\n          })({xid:'${t}'},document,'script','https://cdn.xpln.tech/page.js');`,n.innerHTML=`(function(x,p,l,n,a,i) {\n          self.xpln_targeting=function(){};\n          a=x.createElement(p);a.async=!0;\n          a.src=l+'${t}'+'/'+location.hostname+'.js';\n          i=x.currentScript||x.getElementsByTagName(p)[0];i.parentNode.insertBefore(a,i);\n          })(document,'script','https://cdn.xpln.tech/');`,i.type="text/javascript",n.type="text/javascript",i.setAttribute("data-kleanads","true"),n.setAttribute("data-kleanads","true"),e.document.head.appendChild(i),e.document.head.appendChild(n)})(e.pubstackWindow,i)}}async onAfterPrepareAdUnits({config:e,stackConfig:t}){w("XplnModule declare xpln targeting when ready"),(null==t?void 0:t.xplnConfig)&&On(e.pubstackWindow)}async clean(){this.loaded=!1}isLoaded(){return this.loaded}},Ht(t,"XplnModule"),(()=>{const s="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;Vt(null,e={value:t},i,{kind:"class",name:t.name,metadata:s},null,n),t=e.value,s&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:s}),Gt(t,n)})(),t})();const $n=(e,t)=>{if(!(t>15))return e.xpln_targeting&&e.xpln_targeting.toString().length>100?(e.xpln_targeting(),void w("XPLN targeting called")):void setTimeout((()=>$n(e,t+1)),300);S("Could not declare XPLN targetings, xpln_targeting function is undefined")},On=e=>{$n(e,0)};let Tn=(()=>{let e,i,n=[Jt("onStackConfigLoad")],s=[];return i=class{constructor(){this.name="PublicAccessModule",this._isLoaded=!1}isLoaded(){return this._isLoaded}async load({config:e,stackConfig:i}){e.pubstackWindow._pbstckKleanAds.getBootstrapConfig=()=>{const{pubstackWindow:t,...i}=e;return i},e.pubstackWindow._pbstckKleanAds.getStackConfig=()=>i,e.pubstackWindow._pbstckKleanAds.apiReady=!0,window.addEventListener(t.REFRESH_INIT,(t=>{e.pubstackWindow._pbstckKleanAds.stopRefresh=e=>{var i,n;null===(n=null===(i=null==t?void 0:t.detail)||void 0===i?void 0:i.stopRefresh)||void 0===n||n.call(i,e)},e.pubstackWindow._pbstckKleanAds.refreshApiReady=!0})),this._isLoaded=!0}async clean({config:e}){e.pubstackWindow._pbstckKleanAds.apiReady=!1,e.pubstackWindow._pbstckKleanAds.getBootstrapConfig=()=>{throw new Error("Not ready yet, wait for apiLoaded.")},e.pubstackWindow._pbstckKleanAds.getStackConfig=()=>{throw new Error("Not ready yet, wait for apiLoaded.")}}},Ht(i,"PublicAccessModule"),(()=>{const t="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;Vt(null,e={value:i},n,{kind:"class",name:i.name,metadata:t},null,s),i=e.value,t&&Object.defineProperty(i,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t}),Gt(i,s)})(),i})();const _n=[class{constructor(){this.name="Metas",this._isLoaded=!1,this.customFields=[],this.targetings=[]}async load({config:e}){J("kleanads-version",e.kleanadsVersion),J("config-version",e.stackVersion),J("kleanads-stack-id",e.stack.stackId),this.customFields.push("kleanads-version","config-version","kleanads-stack-id"),function(e,t){const i=document.createElement("meta");i.setAttribute("name",`ad:${e}`),i.content=t,document.head.appendChild(i)}("adm_stack",`${e.stack.stackId}_v${e.stackVersion}`),this.targetings.push("adm_stack"),Ct.getInstance().uprTested&&(J("xp_variant",`floor_optimization:${Ct.getInstance().uprEnabled}`),this.customFields.push("xp_variant")),this._isLoaded=!0}async onStackConfigLoad({stackConfig:e}){var t;if(e.runningABTest.length>0){J("adm_ab_test",`poc:${e.runningABTest[0].value}`),this.customFields.push("adm_ab_test")}if(e.runningABTest.forEach((e=>{J(e.name,e.value),this.customFields.push(e.name)})),e.refreshConfig){J("refresh-out-of-focus",`${null===(t=e.refreshConfig)||void 0===t?void 0:t.adUnitConfig.some((e=>!!e.refreshOutOfFocusConfig))}`),this.customFields.push("refresh-out-of-focus")}}isLoaded(){return this._isLoaded}async clean(){this.customFields.forEach((e=>{try{!function(e){const t=document.querySelector(`meta[name="pbstck:${e}"]`);t&&t.remove()}(e)}catch(t){S(`Unable to remove CustomField meta tag ${e}`,t)}})),this.customFields=[],this.targetings.forEach((e=>{try{!function(e){const t=document.querySelector(`meta[name="ad:${e}"]`);t&&t.remove()}(e)}catch(t){S(`Unable to remove targeting meta tag ${e}`,t)}})),this.targetings=[],this._isLoaded=!1}},hi,ei,kn,Wt,ln,Ni,cn,mn,En,Tn];class Rn{static getModules(){return _n}}async function Ln(e){var t,i,n;if(window._kleanadslock)return void w("kleanads.js already started");window._kleanadslock=!0,Fe(Pe.BEGIN_INIT);const s=async()=>{const t=await en(e,Rn.getModules().map((e=>new e)));t&&await nn(t)};if(null===(t=e.pocOverrides)||void 0===t?void 0:t.waitForEventToInit){const t=setTimeout((()=>{I("Wait for init event is too long")}),6e4),o=()=>{var i;window.removeEventListener((null===(i=e.pocOverrides)||void 0===i?void 0:i.waitForEventToInit)||"",o),clearTimeout(t),s()};w(`[INIT] wait for event ${null===(i=e.pocOverrides)||void 0===i?void 0:i.waitForEventToInit} to start kleanads`),window.addEventListener(null===(n=e.pocOverrides)||void 0===n?void 0:n.waitForEventToInit,o)}else await s()}return window._pbstckKleanAds={initKleanAds:Ln,apiReady:!1,getBootstrapConfig:()=>{throw new Error("Not ready yet, wait for apiReady.")},getStackConfig:()=>{throw new Error("Not ready yet, wait for apiReady.")},refreshApiReady:!1,stopRefresh:()=>{throw new Error("Not ready yet, wait for refreshApiReady.")}},e.initKleanAds=Ln,e}({});