(()=>{const e="1774628580933-6c198d85-3b24-42cd-9404-2801fd54d1c6";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,n=3e4,i="100% 0px",s=!1,o={fetchMarginPercent:200,renderMarginPercent:100,mobileScaling:1},r={enabled:!0,loadDelay:100},d=(...e)=>s&&console.log(...e),a=(...e)=>console.warn(...e),l=(...e)=>console.error(...e);let c,p=null;function h(){if(!p||!p.parentNode)return;const e=p.parentNode;e.lastElementChild!==p&&e.appendChild(p)}const f=[{slot:"22562061343/0506-01_economistjurist-es_footer_",tagId:"embi_footer_intop_0d02eeef",type:"FOOTER_INTOP",ubication:"",position:"FOOTER",manualInsertion:!1,mobileSizes:[[320,50],[320,100]],desktopSizes:[[728,90],[970,90]],offset:null,tbLoaderURL:"",loadImmediately:!1,adunitMobile:{code:"embi_footer_intop_0d02eeef",mediaTypes:{banner:{sizes:[[320,50],[320,100]]}},bids:[],ortb2Imp:{ext:{gpid:"22562061343/0506-01_economistjurist-es_footer_",data:{pbadslot:"22562061343/0506-01_economistjurist-es_footer_",divId:"embi_footer_intop_0d02eeef"},instl:0,rwdd:0}}},adunitDesktop:{code:"embi_footer_intop_0d02eeef",mediaTypes:{banner:{sizes:[[728,90],[970,90]]}},bids:[],ortb2Imp:{ext:{gpid:"22562061343/0506-01_economistjurist-es_footer_",data:{pbadslot:"22562061343/0506-01_economistjurist-es_footer_",divId:"embi_footer_intop_0d02eeef"},instl:0,rwdd:0}}}}];if(!f.length)return void console.warn("No products data found, skipping initialization.");function m(e){try{const t=e.split(",");for(const e of t){const t=u(e);if(t)return t}return null}catch(t){return l("Error getting first location available with selectors:",e,t),null}}function u(e){try{return document.querySelector(e)}catch(t){return l("Error getting element with selector:",e,t),null}}function g(){const e=[];return f.forEach(t=>{t.tagId&&e.push(t.tagId),t.tagId2&&e.push(t.tagId2)}),e}function y(e,n=null){let i=0,s=0;if(e&&e.length>0&&e.forEach(e=>{if(Array.isArray(e)&&2===e.length){const[t,n]=e;t>i&&(i=t),n>s&&(s=n)}}),n){const e=t?n.adunitMobile:n.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,n]=e;t>i&&(i=t),n>s&&(s=n)}})}}return{maxWidth:i>0?`${i}px`:"none",maxHeight:s>0?`${s}px`:"none"}}!function(e,t){if(!document.querySelector(`script[src='${e}']`)){const n=document.createElement("script");n.async=t,n.type="text/javascript",n.src=e,document.head.appendChild(n)}}("https://securepubads.g.doubleclick.net/tag/js/gpt.js");var b=window.googletag=window.googletag||{};b.cmd=b.cmd||[];const I={visibleAds:new Set,hiddenAdsInViewport:new Set,sentinelObserver:null,refreshInterval:null,sentinels:new Map,lastRefreshTime:new Map,displayedAds:new Set,createSentinel(e,t){try{const n=document.createElement("div");return n.id=`sentinel_${e}`,n.className="ad-sentinel",n.style.cssText="\n position: absolute;\n width: 1px;\n height: 1px;\n opacity: 0;\n pointer-events: none;\n ",t.parentNode.insertBefore(n,t.nextSibling),this.sentinels.set(e,n),d(`Created sentinel for: ${e}`),n}catch(t){return l(`Error creating sentinel for ${e}:`,t),null}},shouldRefreshAd(e){const t=f.find(t=>t.tagId===e),i=t&&("HIGH_IMPACT"===t.type||"FOOTER_INTOP"===t.type||"DISPLAY_VIDEO_STICKY"===t.type);if(!(this.visibleAds.has(e)||this.hiddenAdsInViewport.has(e)||i))return d(` ❌ ${e} not in viewport (visible or hidden)`),!1;if(i)d(` 📍 ${e} is ${t.type} overlay`);else{const t=this.hiddenAdsInViewport.has(e);d(` 📍 ${e} is ${t?"hidden":"visible"} in viewport`)}const s=this.lastRefreshTime.get(e);if(!s)return d(` ✅ ${e} ready for first refresh (never refreshed before)`),!0;const o=Date.now()-s,r=o>=n;return d(` ${r?"✅":"⏳"} ${e} time since refresh: ${Math.round(o/1e3)}s / ${n/1e3}s`),r},markDisplayed(e){if(!this.displayedAds.has(e)){this.displayedAds.add(e),d(`📺 Ad marked as displayed: ${e}`);const t=document.getElementById(e);if(t){const n=t.getBoundingClientRect(),i=n.top0,s=0===n.width&&0===n.height;d(` - In viewport: ${i}, Hidden: ${s}, Size: ${n.width}x${n.height}`),i&&!s?(this.visibleAds.add(e),d(" - Added to visible ads immediately")):i&&s&&(this.hiddenAdsInViewport.add(e),d(" - Added to hidden ads in viewport"))}}},triggerAdRefresh(e,t="entered viewport"){try{f.find(t=>t.tagId===e);if(this.shouldRefreshAd(e)){d(`🎯 Triggering immediate refresh for ${e} (${t})`);const n=f.find(t=>t.tagId===e||t.tagId2===e);n&&(e===n.tagId&&n.adSlot?(b.pubads().refresh([n.adSlot]),this.lastRefreshTime.set(e,Date.now())):e===n.tagId2&&n.adSlotB&&(b.pubads().refresh([n.adSlotB]),this.lastRefreshTime.set(e,Date.now())))}else if(this.displayedAds.has(e)){const t=this.lastRefreshTime.get(e),n=Math.round((Date.now()-t)/1e3);d(`⏭️ Skipping refresh for ${e} (refreshed ${n}s ago)`)}else d(`⏭️ 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(d(`🔍 Sentinel check: ${t}, intersecting: ${e.isIntersecting}`),e.isIntersecting){const e=document.getElementById(t);if(e){const n=e.getBoundingClientRect(),i=0===n.width&&0===n.height;if(d(` - Ad dimensions: ${n.width}x${n.height}, isHidden: ${i}`),i){const e=this.hiddenAdsInViewport.has(t);this.hiddenAdsInViewport.add(t),this.visibleAds.delete(t),d(`🔍 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),d(`🔍 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),d(`🔍 Ad left viewport: ${t}`)}),d(`✅ Visible ads: ${this.visibleAds.size}, Hidden in viewport: ${this.hiddenAdsInViewport.size}`)},{rootMargin:i,threshold:0});const e=g();let t=0;e.forEach(e=>{const n=document.getElementById(e);if(n){const i=this.createSentinel(e,n);i&&(this.sentinelObserver.observe(i),t++,d(`👁️ Observing sentinel for: ${e}`))}else a(`⚠️ Element not found for observation: ${e}`)}),this.startRefreshTimer(),d(`✅ Fast refresh system initialized: ${t}/${e.length} ad units observed (GPT-only, sentinel-only)`),d(` - Refresh interval: ${n/1e3}s`),d(` - Observer margin: ${i}`)}catch(e){l("Error initializing refresh manager:",e)}},startRefreshTimer(){this.refreshInterval=setInterval(()=>{this.refreshVisibleAds()},n)},refreshVisibleAds(){try{const e=new Set;if(this.visibleAds.forEach(t=>e.add(t)),this.hiddenAdsInViewport.forEach(t=>e.add(t)),f.forEach(t=>{"FOOTER_INTOP"===t.type&&e.add(t.tagId)}),0===e.size)return void d("⏭️ No ads in refresh range");d(`🔄 Periodic refresh: ${e.size} ad(s) (${this.visibleAds.size} visible + ${this.hiddenAdsInViewport.size} hidden + overlays)`),e.forEach(e=>{try{const t=document.getElementById(e),i=this.shouldRefreshAd(e);if(d(`🔍 Checking ${e}: element=${!!t}, shouldRefresh=${i}, displayed=${this.displayedAds.has(e)}`),t&&i){d(`✅ Refreshing ad: ${e}`);const t=f.find(t=>t.tagId===e||t.tagId2===e);t?e===t.tagId&&t.adSlot?(b.pubads().refresh([t.adSlot]),this.lastRefreshTime.set(e,Date.now()),d(`✅ Refreshed successfully: ${e} (slot 1)`)):e===t.tagId2&&t.adSlotB?(b.pubads().refresh([t.adSlotB]),this.lastRefreshTime.set(e,Date.now()),d(`✅ 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),i=Math.round((Date.now()-t)/1e3);d(`⏭️ Skipping ${e} (refreshed ${i}s ago, interval: ${n/1e3}s)`)}else d(`⏭️ 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(),d("RefreshManager cleanup complete")}};function E(e,n="TOP"){const i=(p&&p.isConnected||(p=document.getElementById("embi-overlay-root"),p||(p=document.createElement("div"),p.id="embi-overlay-root",Object.assign(p.style,{position:"fixed",inset:"0",pointerEvents:"none",zIndex:"2147483647"}),document.body.appendChild(p))),p),s=document.createElement("div");s.id="embi-footer-intop-ad-container",Object.assign(s.style,{position:"fixed",left:t?"0":"50%",transform:t?"":"translateX(-50%)",width:t?"100vw":"auto",height:"auto",background:t?"rgba(0,0,0,0.75)":"transparent",bottom:"FOOTER"===n?"0px":"auto",top:"TOP"===n?"0px":"auto",zIndex:"1",boxShadow:"black 0 3px 10px 0",display:"none",transition:"bottom 0.3s ease-in-out",pointerEvents:"auto",textAlign:"center"});const o=document.createElement("div");o.id=e;const r=document.createElement("script");return r.textContent=`\n googletag.cmd.push(function() {\n googletag.display('${e}');\n });\n `,o.appendChild(r),s.appendChild(o),s.appendChild(function(e,t){const n=document.createElement("button");n.innerHTML="×",n.title="Close ad";const i="rgba(0, 0, 0, 0.6)",s="FOOTER"===t?"translate(50%, -50%)":"translate(50%, 50%)";return Object.assign(n.style,{position:"absolute",right:"0px",top:"FOOTER"===t?"0px":"auto",bottom:"TOP"===t?"0px":"auto",width:"16px",height:"16px",background:i,opacity:"1",padding:"0px",border:"none",borderRadius:"50%",color:"#fff",fontSize:"18px",fontWeight:"bold",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"2147483648",transform:s,transition:"background 0.2s ease, transform 0.2s ease",boxShadow:"0 2px 8px rgba(0,0,0,0.3)"}),n.addEventListener("mouseenter",()=>{n.style.background="rgba(0, 0, 0, 0.8)",n.style.transform=`${s} scale(1.1)`,n.style.boxShadow="0 4px 12px rgba(0,0,0,0.4)"}),n.addEventListener("mouseleave",()=>{n.style.background=i,n.style.transform=s,n.style.boxShadow="0 2px 8px rgba(0,0,0,0.3)"}),n.addEventListener("click",()=>{e.style.display="none"}),n}(s,n)),i.appendChild(s),h(),s}function v(e){try{if(e.manualInsertion&&"TABOOLA_INTEGRATION"!==e.type){const s=e.tagId;new MutationObserver((e,t)=>{document.getElementById(s)&&(b.cmd.push(function(){b.display(s)}),t.disconnect())}).observe(document.body,{childList:!0,subtree:!0})}else{const o=e.type,r=e.position,d=e.ubication,p=e.tagId,h=e.offset;function n(e,t){const n=document.createElement("script");n.textContent=`\n googletag.cmd.push(function() {\n googletag.display('${t}');\n });\n `,e.appendChild(n)}try{if("TABOOLA_INTEGRATION"===o)createTaboolaContainer(e);else if("HIGH_IMPACT"===o)INTERSTITIAL_CONTAINER=createInterstitialContainer(p);else if("DISPLAY_VIDEO_STICKY"===o)cornerContainer=createCornerContainer(p,r,h);else if("FOOTER_INTOP"===o)c=E(p,r);else if("DOUBLE_BOX"===o){const f=m(`${d}`);if(!f)return l(`Elemento con clase '${d}' no encontrado en el DOM para el anuncio ${p}. No se pudo insertar el DIV.`),!1;const u=e.tagId2,g=t?e.mobileSizes:e.desktopSizes,{maxWidth:I,maxHeight:v}=y(g,e),w=document.createElement("div");w.id=`container_${p}`,(i=w).style.display="flex",i.style.flexDirection=t?"column":"row",i.style.gap="24px",i.style.marginBottom="24px",i.style.background="transparent",i.style.justifyContent="center";const $=document.createElement("div");$.id=`wrapper_${p}`,$.className="ad-slot-wrapper",$.style.maxWidth=I,$.style.maxHeight=v,$.style.overflow="hidden",$.style.display="flex",$.style.justifyContent="center",$.style.alignItems="center";const A=document.createElement("div");A.id=p,A.className="ad-slot",A.style.minHeight="1px";const S=document.createElement("script");S.textContent=`\n googletag.cmd.push(function() {\n googletag.display('${p}');\n });\n `,A.appendChild(S),$.appendChild(A),w.appendChild($);const x=document.createElement("div");x.id=`wrapper_${u}`,x.className="ad-slot-wrapper",x.style.maxWidth=I,x.style.maxHeight=v,x.style.overflow="hidden",x.style.display="flex",x.style.justifyContent="center",x.style.alignItems="center";const T=document.createElement("div");T.id=u,T.className="ad-slot",T.style.minHeight="1px";const _=document.createElement("script");switch(_.textContent=`\n googletag.cmd.push(function() {\n googletag.display('${u}');\n });\n `,T.appendChild(_),x.appendChild(T),w.appendChild(x),r){case"INSERT_BEFORE":f.insertAdjacentElement("beforebegin",w);break;case"INSERT_AFTER":f.insertAdjacentElement("afterend",w);break;default:f.appendChild(w)}}else if("DISPLAY_VIDEO"===o){const O=m(`${d}`);if(!O)return void l(`Elemento con clase '${d}' no encontrado en el DOM para el anuncio ${p}.`);const R=t?e.mobileSizes:e.desktopSizes,{maxWidth:C,maxHeight:N}=y(R,e),k=document.createElement("div");k.id=`wrapper_${p}`,k.className="ad-slot-wrapper",k.style.maxWidth=C,k.style.maxHeight=N,k.style.overflow="hidden",k.style.margin="0 auto 24px",k.style.display="flex",k.style.justifyContent="center",k.style.alignItems="center";const z=document.createElement("div");switch(z.id=p,z.className="ad-slot",z.style.minHeight="1px",n(z,p),k.appendChild(z),r){case"INSERT_BEFORE":O.insertAdjacentElement("beforebegin",k);break;case"INSERT_AFTER":O.insertAdjacentElement("afterend",k);break;default:O.appendChild(k)}}else if(e.isSticky)cornerContainer=createCornerContainer(p,r),n(cornerContainer,p);else{const D=m(`${d}`);if(!D)return void l(`Elemento con clase '${d}' no encontrado en el DOM para el anuncio ${p}.`);const B=t?e.mobileSizes:e.desktopSizes,{maxWidth:L,maxHeight:P}=y(B,e),H=document.createElement("div");H.id=`wrapper_${p}`,H.className="ad-slot-wrapper",H.style.maxWidth=L,H.style.maxHeight=P,H.style.overflow="hidden",H.style.margin="0 auto 24px",H.style.display="flex",H.style.justifyContent="center",H.style.alignItems="center";const j=document.createElement("div");switch(j.id=p,j.className="ad-slot",j.style.minHeight="1px",n(j,p),H.appendChild(j),r){case"INSERT_BEFORE":D.insertAdjacentElement("beforebegin",H);break;case"INSERT_AFTER":D.insertAdjacentElement("afterend",H);break;default:D.appendChild(H)}}}catch(M){l(`Error procesando el anuncio ${p}:`,M)}}}catch(V){a("Error rendering adunit for product",e.tagId,V)}var i}function w(){try{f.map(e=>{v(e)}),b.cmd.push(function(){const e=f.filter(e=>"HIGH_IMPACT"===e.type||"FOOTER_INTOP"===e.type||"DISPLAY_VIDEO_STICKY"===e.type);e.length>0&&(d("🎯 Loading overlay ads immediately..."),e.forEach(e=>{try{d(` - Displaying ${e.type} ad: ${e.tagId}`),b.display(e.tagId)}catch(t){l(`Error displaying ${e.type} ad ${e.tagId}:`,t)}}))}),setTimeout(()=>{d("🔄 Initializing fast refresh system (GPT-only)..."),I.initialize()},r.loadDelay)}catch(e){l("Error in mainInitialization:",e)}finally{d("✅ EMBI ad system initialized successfully (GPT-only)")}}b.cmd.push(function(){if(f.filter(e=>"TABOOLA_INTEGRATION"!==e.type).forEach(e=>{try{const n=t?e.mobileSizes:e.desktopSizes;e.adSlot=b.defineSlot(e.slot,n,e.tagId).setForceSafeFrame(!1).addService(b.pubads()),"DOUBLE_BOX"===e.type&&(e.adSlotB=b.defineSlot(e.slot2,n,e.tagId2).setForceSafeFrame(!1).addService(b.pubads())),d(`GPT slot defined: ${e.tagId}`)}catch(t){l("Error creating GPT slot for product",e.tagId,t)}}),r.enabled){f.some(e=>e.loadImmediately)&&(b.pubads().enableSingleRequest(),d("Single Request enabled for priority ads"))}b.pubads().enableLazyLoad(o),b.pubads().collapseEmptyDivs(!0),b.pubads().setCentering(!0),b.pubads().addEventListener("slotRenderEnded",function(e){try{const t=e.slot.getSlotElementId();if(!g().find(e=>e===t))return;const n=e.isEmpty;d(`📺 Ad render event: ${t}, isEmpty: ${n}`),void 0!==I&&(I.lastRefreshTime.set(t,Date.now()),n?d(` ⚠️ Ad slot ${t} rendered empty - will retry on next refresh cycle`):I.markDisplayed(t))}catch(e){l("Error in slotRenderEnded event:",e)}const t=e.slot.getSlotElementId();f.forEach(n=>{try{t===n.tagId&&"FOOTER_INTOP"===n.type&&(i=c,s=e.isEmpty,i&&(i.style.display=s?"none":"block",s||h()))}catch(e){l("Error rendering slot for product",n.tagId,e)}var i,s})}),b.enableServices(),d("GPT configuration complete")}),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",w):w()})();