(()=>{const e="1775489800174-27e4bdef-59b2-4589-a8fa-b3bbf08ed103";if(window.__embiLoadedScriptKeys=window.__embiLoadedScriptKeys||new Set,window.__embiLoadedScriptKeys.has(e))return void console.warn("EMBI main script (this artifact) already executed. Skipping duplicate load.");window.__embiLoadedScriptKeys.add(e);const t=(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth)<=768,i=3e4,n="100% 0px",s=!1,d={fetchMarginPercent:200,renderMarginPercent:100,mobileScaling:1},r={enabled:!0,loadDelay:100},o=(...e)=>s&&console.log(...e),a=(...e)=>console.warn(...e),l=(...e)=>console.error(...e),c=[{slot:"/22562061343/0506_02_economistjurist_video-outstream__",tagId:"embi_video_inread_inline_1dfc7103",type:"VIDEO_INREAD_INLINE",ubication:"#contenido-post > p:nth-child(1)",position:"INSERT_AFTER",manualInsertion:!1,mobileSizes:[[1,1]],desktopSizes:[[1,1]],offset:null,nativeParams:{},loadImmediately:!1,adunitMobile:{code:"embi_video_inread_inline_1dfc7103",mediaTypes:{video:{context:"outstream",playerSize:[[300,250]],mimes:["video/mp4","video/webm","video/ogg"],protocols:[1,2,3,4,5,6,7,8],placement:2,plcmt:4,playbackmethod:[6],api:[2],skip:1}},bids:[],ortb2Imp:{ext:{gpid:"/22562061343/0506_02_economistjurist_video-outstream__",data:{pbadslot:"/22562061343/0506_02_economistjurist_video-outstream__",divId:"embi_video_inread_inline_1dfc7103"},instl:0,rwdd:0}}},adunitDesktop:{code:"embi_video_inread_inline_1dfc7103",mediaTypes:{video:{context:"outstream",playerSize:[[640,360]],mimes:["video/mp4","video/webm","video/ogg"],protocols:[1,2,3,4,5,6,7,8],placement:2,plcmt:4,playbackmethod:[6],api:[2],skip:1}},bids:[],ortb2Imp:{ext:{gpid:"/22562061343/0506_02_economistjurist_video-outstream__",data:{pbadslot:"/22562061343/0506_02_economistjurist_video-outstream__",divId:"embi_video_inread_inline_1dfc7103"},instl:0,rwdd:0}}}}];if(!c.length)return void console.warn("No products data found, skipping initialization.");function h(e){try{const t=e.split(",");for(const e of t){const t=p(e);if(t)return t}return null}catch(t){return l("Error getting first location available with selectors:",e,t),null}}function p(e){try{return document.querySelector(e)}catch(t){return l("Error getting element with selector:",e,t),null}}function m(e,i=null){let n=0,s=0;if(e&&e.length>0&&e.forEach(e=>{if(Array.isArray(e)&&2===e.length){const[t,i]=e;t>n&&(n=t),i>s&&(s=i)}}),i){const e=t?i.adunitMobile:i.adunitDesktop;if(e&&e.mediaTypes&&e.mediaTypes.video&&e.mediaTypes.video.playerSize){e.mediaTypes.video.playerSize.forEach(e=>{if(Array.isArray(e)&&2===e.length){const[t,i]=e;t>n&&(n=t),i>s&&(s=i)}})}}return{maxWidth:n>0?`${n}px`:"none",maxHeight:s>0?`${s}px`:"none"}}!function(e,t){if(!document.querySelector(`script[src='${e}']`)){const i=document.createElement("script");i.async=t,i.type="text/javascript",i.src=e,document.head.appendChild(i)}}("https://securepubads.g.doubleclick.net/tag/js/gpt.js");var f=window.googletag=window.googletag||{};f.cmd=f.cmd||[];const u={visibleAds:new Set,hiddenAdsInViewport:new Set,sentinelObserver:null,refreshInterval:null,sentinels:new Map,lastRefreshTime:new Map,displayedAds:new Set,createSentinel(e,t){try{const i=document.createElement("div");return i.id=`sentinel_${e}`,i.className="ad-sentinel",i.style.cssText="\n position: absolute;\n width: 1px;\n height: 1px;\n opacity: 0;\n pointer-events: none;\n ",t.parentNode.insertBefore(i,t.nextSibling),this.sentinels.set(e,i),o(`Created sentinel for: ${e}`),i}catch(t){return l(`Error creating sentinel for ${e}:`,t),null}},shouldRefreshAd(e){if(!(this.visibleAds.has(e)||this.hiddenAdsInViewport.has(e)))return o(` ❌ ${e} not in viewport (visible or hidden)`),!1;const t=this.hiddenAdsInViewport.has(e);o(` 📍 ${e} is ${t?"hidden":"visible"} in viewport`);const n=this.lastRefreshTime.get(e);if(!n)return o(` ✅ ${e} ready for first refresh (never refreshed before)`),!0;const s=Date.now()-n,d=s>=i;return o(` ${d?"✅":"⏳"} ${e} time since refresh: ${Math.round(s/1e3)}s / ${i/1e3}s`),d},markDisplayed(e){if(!this.displayedAds.has(e)){this.displayedAds.add(e),o(`📺 Ad marked as displayed: ${e}`);const t=document.getElementById(e);if(t){const i=t.getBoundingClientRect(),n=i.top0,s=0===i.width&&0===i.height;o(` - In viewport: ${n}, Hidden: ${s}, Size: ${i.width}x${i.height}`),n&&!s?(this.visibleAds.add(e),o(" - Added to visible ads immediately")):n&&s&&(this.hiddenAdsInViewport.add(e),o(" - Added to hidden ads in viewport"))}}},triggerAdRefresh(e,t="entered viewport"){try{c.find(t=>t.tagId===e);if(this.shouldRefreshAd(e)){o(`🎯 Triggering immediate refresh for ${e} (${t})`);const i=c.find(t=>t.tagId===e||t.tagId2===e);i&&(e===i.tagId&&i.adSlot?(f.pubads().refresh([i.adSlot]),this.lastRefreshTime.set(e,Date.now())):e===i.tagId2&&i.adSlotB&&(f.pubads().refresh([i.adSlotB]),this.lastRefreshTime.set(e,Date.now())))}else if(this.displayedAds.has(e)){const t=this.lastRefreshTime.get(e),i=Math.round((Date.now()-t)/1e3);o(`⏭️ Skipping refresh for ${e} (refreshed ${i}s ago)`)}else o(`⏭️ Skipping refresh for ${e} (not displayed yet)`)}catch(t){l(`Error triggering refresh for ${e}:`,t)}},initialize(){try{this.sentinelObserver=new IntersectionObserver(e=>{e.forEach(e=>{const t=e.target.id.replace("sentinel_","");if(o(`🔍 Sentinel check: ${t}, intersecting: ${e.isIntersecting}`),e.isIntersecting){const e=document.getElementById(t);if(e){const i=e.getBoundingClientRect(),n=0===i.width&&0===i.height;if(o(` - Ad dimensions: ${i.width}x${i.height}, isHidden: ${n}`),n){const e=this.hiddenAdsInViewport.has(t);this.hiddenAdsInViewport.add(t),this.visibleAds.delete(t),o(`🔍 Hidden ad in viewport: ${t}`),!e&&this.shouldRefreshAd(t)&&this.triggerAdRefresh(t,"hidden ad entered viewport")}else{const e=this.visibleAds.has(t);this.visibleAds.add(t),this.hiddenAdsInViewport.delete(t),o(`🔍 Visible ad in viewport: ${t}`),!e&&this.shouldRefreshAd(t)&&this.triggerAdRefresh(t,"visible ad entered viewport")}}}else this.hiddenAdsInViewport.delete(t),this.visibleAds.delete(t),o(`🔍 Ad left viewport: ${t}`)}),o(`✅ Visible ads: ${this.visibleAds.size}, Hidden in viewport: ${this.hiddenAdsInViewport.size}`)},{rootMargin:n,threshold:0});const e=function(){const e=[];return c.forEach(t=>{t.tagId&&e.push(t.tagId),t.tagId2&&e.push(t.tagId2)}),e}();let t=0;e.forEach(e=>{const i=document.getElementById(e);if(i){const n=this.createSentinel(e,i);n&&(this.sentinelObserver.observe(n),t++,o(`👁️ Observing sentinel for: ${e}`))}else a(`⚠️ Element not found for observation: ${e}`)}),this.startRefreshTimer(),o(`✅ Fast refresh system initialized: ${t}/${e.length} ad units observed (GPT-only, sentinel-only)`),o(` - Refresh interval: ${i/1e3}s`),o(` - Observer margin: ${n}`)}catch(e){l("Error initializing refresh manager:",e)}},startRefreshTimer(){this.refreshInterval=setInterval(()=>{this.refreshVisibleAds()},i)},refreshVisibleAds(){try{const e=new Set;if(this.visibleAds.forEach(t=>e.add(t)),this.hiddenAdsInViewport.forEach(t=>e.add(t)),0===e.size)return void o("⏭️ No ads in refresh range");o(`🔄 Periodic refresh: ${e.size} ad(s) (${this.visibleAds.size} visible + ${this.hiddenAdsInViewport.size} hidden)`),e.forEach(e=>{try{const t=document.getElementById(e),n=this.shouldRefreshAd(e);if(o(`🔍 Checking ${e}: element=${!!t}, shouldRefresh=${n}, displayed=${this.displayedAds.has(e)}`),t&&n){o(`✅ Refreshing ad: ${e}`);const t=c.find(t=>t.tagId===e||t.tagId2===e);t?e===t.tagId&&t.adSlot?(f.pubads().refresh([t.adSlot]),this.lastRefreshTime.set(e,Date.now()),o(`✅ Refreshed successfully: ${e} (slot 1)`)):e===t.tagId2&&t.adSlotB?(f.pubads().refresh([t.adSlotB]),this.lastRefreshTime.set(e,Date.now()),o(`✅ Refreshed successfully: ${e} (slot 2)`)):a(`⚠️ No matching adSlot found for ${e}`):a(`⚠️ No product found for ${e}`)}else if(t)if(this.displayedAds.has(e)){const t=this.lastRefreshTime.get(e),n=Math.round((Date.now()-t)/1e3);o(`⏭️ Skipping ${e} (refreshed ${n}s ago, interval: ${i/1e3}s)`)}else o(`⏭️ Skipping ${e} (not displayed yet)`);else a(`⚠️ Element not found: ${e}`)}catch(t){l(`Error refreshing ${e}:`,t)}})}catch(e){l("Error in refreshVisibleAds:",e)}},destroy(){this.sentinelObserver&&this.sentinelObserver.disconnect(),this.refreshInterval&&clearInterval(this.refreshInterval),this.sentinels.forEach(e=>{try{e&&e.parentNode&&e.parentNode.removeChild(e)}catch(e){l("Error removing sentinel:",e)}}),this.sentinels.clear(),this.lastRefreshTime.clear(),this.displayedAds.clear(),this.visibleAds.clear(),this.hiddenAdsInViewport.clear(),o("RefreshManager cleanup complete")}};function g(e){try{if(e.manualInsertion&&"NATIVE"!==e.type){const s=e.tagId;new MutationObserver((e,t)=>{document.getElementById(s)&&(f.cmd.push(function(){f.display(s)}),t.disconnect())}).observe(document.body,{childList:!0,subtree:!0})}else{const d=e.type,r=e.position,o=e.ubication,c=e.tagId,p=e.offset;function i(e,t){const i=document.createElement("script");i.textContent=`\n googletag.cmd.push(function() {\n googletag.display('${t}');\n });\n `,e.appendChild(i)}try{if("NATIVE"===d)createNativeContainer(e);else if("HIGH_IMPACT"===d)INTERSTITIAL_CONTAINER=createInterstitialContainer(c);else if("DISPLAY_VIDEO_STICKY"===d)cornerContainer=createCornerContainer(c,r,p);else if("FOOTER_INTOP"===d)footerInTopContainer=createfooterInTopContainer(c,r);else if("DOUBLE_BOX"===d){const u=h(`${o}`);if(!u)return l(`Elemento con clase '${o}' no encontrado en el DOM para el anuncio ${c}. No se pudo insertar el DIV.`),!1;const g=e.tagId2,y=t?e.mobileSizes:e.desktopSizes,{maxWidth:b,maxHeight:v}=m(y,e),I=document.createElement("div");I.id=`container_${c}`,(n=I).style.display="flex",n.style.flexDirection=t?"column":"row",n.style.gap="24px",n.style.marginBottom="24px",n.style.background="transparent",n.style.justifyContent="center";const E=document.createElement("div");E.id=`wrapper_${c}`,E.className="ad-slot-wrapper",E.style.maxWidth=b,E.style.maxHeight=v,E.style.overflow="hidden",E.style.display="flex",E.style.justifyContent="center",E.style.alignItems="center";const w=document.createElement("div");w.id=c,w.className="ad-slot",w.style.minHeight="1px";const $=document.createElement("script");$.textContent=`\n googletag.cmd.push(function() {\n googletag.display('${c}');\n });\n `,w.appendChild($),E.appendChild(w),I.appendChild(E);const _=document.createElement("div");_.id=`wrapper_${g}`,_.className="ad-slot-wrapper",_.style.maxWidth=b,_.style.maxHeight=v,_.style.overflow="hidden",_.style.display="flex",_.style.justifyContent="center",_.style.alignItems="center";const A=document.createElement("div");A.id=g,A.className="ad-slot",A.style.minHeight="1px";const S=document.createElement("script");switch(S.textContent=`\n googletag.cmd.push(function() {\n googletag.display('${g}');\n });\n `,A.appendChild(S),_.appendChild(A),I.appendChild(_),r){case"INSERT_BEFORE":u.insertAdjacentElement("beforebegin",I);break;case"INSERT_AFTER":u.insertAdjacentElement("afterend",I);break;default:u.appendChild(I)}}else if("DISPLAY_VIDEO"===d){const T=h(`${o}`);if(!T)return void l(`Elemento con clase '${o}' no encontrado en el DOM para el anuncio ${c}.`);const x=t?e.mobileSizes:e.desktopSizes,{maxWidth:R,maxHeight:C}=m(x,e),N=document.createElement("div");N.id=`wrapper_${c}`,N.className="ad-slot-wrapper",N.style.maxWidth=R,N.style.maxHeight=C,N.style.overflow="hidden",N.style.margin="0 auto 24px",N.style.display="flex",N.style.justifyContent="center",N.style.alignItems="center";const k=document.createElement("div");switch(k.id=c,k.className="ad-slot",k.style.minHeight="1px",i(k,c),N.appendChild(k),r){case"INSERT_BEFORE":T.insertAdjacentElement("beforebegin",N);break;case"INSERT_AFTER":T.insertAdjacentElement("afterend",N);break;default:T.appendChild(N)}}else if(e.isSticky)cornerContainer=createCornerContainer(c,r),i(cornerContainer,c);else{const z=h(`${o}`);if(!z)return void l(`Elemento con clase '${o}' no encontrado en el DOM para el anuncio ${c}.`);const D=t?e.mobileSizes:e.desktopSizes,{maxWidth:O,maxHeight:V}=m(D,e),B=document.createElement("div");B.id=`wrapper_${c}`,B.className="ad-slot-wrapper",B.style.maxWidth=O,B.style.maxHeight=V,B.style.overflow="hidden",B.style.margin="0 auto 24px",B.style.display="flex",B.style.justifyContent="center",B.style.alignItems="center";const j=document.createElement("div");switch(j.id=c,j.className="ad-slot",j.style.minHeight="1px",i(j,c),B.appendChild(j),r){case"INSERT_BEFORE":z.insertAdjacentElement("beforebegin",B);break;case"INSERT_AFTER":z.insertAdjacentElement("afterend",B);break;default:z.appendChild(B)}}}catch(H){l(`Error procesando el anuncio ${c}:`,H)}}}catch(M){a("Error rendering adunit for product",e.tagId,M)}var n}function y(){try{c.map(e=>{g(e)}),setTimeout(()=>{o("🔄 Initializing fast refresh system (GPT-only)..."),u.initialize()},r.loadDelay)}catch(e){l("Error in mainInitialization:",e)}finally{o("✅ EMBI ad system initialized successfully (GPT-only)")}}f.cmd.push(function(){if(c.filter(e=>"NATIVE"!==e.type).forEach(e=>{try{const i=t?e.mobileSizes:e.desktopSizes;e.adSlot=f.defineSlot(e.slot,i,e.tagId).setForceSafeFrame(!1).addService(f.pubads()),"DOUBLE_BOX"===e.type&&(e.adSlotB=f.defineSlot(e.slot2,i,e.tagId2).setForceSafeFrame(!1).addService(f.pubads())),o(`GPT slot defined: ${e.tagId}`)}catch(t){l("Error creating GPT slot for product",e.tagId,t)}}),r.enabled){c.some(e=>e.loadImmediately)&&(f.pubads().enableSingleRequest(),o("Single Request enabled for priority ads"))}f.pubads().enableLazyLoad(d),f.pubads().collapseEmptyDivs(!0),f.pubads().setCentering(!0),f.enableServices(),o("GPT configuration complete")}),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",y):y()})();