import{d as z,r as S,s as k,z as h,o as E,a as M,n as w,e as j}from"./CGQLQ9ei.js";const O=["id"],v=z({__name:"Ad",props:{id:{},path:{},dimensions:{},targeting:{default:()=>({})},sizeMapping:{},showFrame:{type:Boolean,default:!1}},emits:["renderEnded"],setup(m,{emit:f}){const e=m,p=f,g=S(!1);let i=null;function b(){if(!window.googletag.cmd)return;const n=window.googletag;n.cmd.push(()=>{var r,c;const o=n.pubads().getSlots().find(s=>s.getSlotElementId()===e.id);if(o)Object.entries(e.targeting).forEach(([s,a])=>o.setTargeting(s,a.value)),n.pubads().refresh([o]),console.log(`actualizado: ${e.id}`);else if(e.sizeMapping){const s=n.sizeMapping();let a=!1;for(const t of e.sizeMapping)s.addSize(t.breakpoint,t.dimensions),t.dimensions.length&&t.breakpoint[0]===1185&&window.innerWidth>=1200&&(a=!0),t.dimensions.length&&t.breakpoint[0]===300&&window.innerWidth<1200&&(a=!0);a&&(i=(r=n.defineSlot(e.path,e.dimensions,e.id))==null?void 0:r.addService(n.pubads()),Object.entries(e.targeting).forEach(([t,l])=>{i==null||i.setTargeting(t,l.value)}),i==null||i.defineSizeMapping(s.build()),n.display(e.id),console.log(`create ad - ${e.id}`),n.pubads().addEventListener("slotRenderEnded",t=>{const l=t.slot;t.isEmpty?p("renderEnded",!1):(g.value=!0,p("renderEnded",!0,l.getSlotElementId()))}))}else i=(c=n.defineSlot(e.path,e.dimensions,e.id))==null?void 0:c.addService(n.pubads()),Object.entries(e.targeting).forEach(([s,a])=>{i==null||i.setTargeting(s,a.value)}),n.display(e.id)})}function u(){const d=googletag.pubads().getSlots().find(o=>o.getSlotElementId()===e.id);d&&(Object.entries(e.targeting).forEach(([o,r])=>{d.setTargeting(o,r.value)}),googletag.pubads().refresh([d]),p("renderEnded",!1,"resetAd"),console.log(`reset ad: ${e.id}`))}return k(()=>{b()}),h(()=>[e.path,e.dimensions,e.targeting,e.sizeMapping],u),(n,d)=>(E(),M("div",{id:n.id,class:w(["mx-auto mt-0 w-full flex",{"mb-24px py-16px":j(g),"bg-neutral-100":n.showFrame}])},null,10,O))}}),_=Object.freeze([{breakpoint:[1185,520],dimensions:[300,250]},{breakpoint:[300,480],dimensions:[]}]),y=Object.freeze([{breakpoint:[300,480],dimensions:[[300,250],[320,100]]},{breakpoint:[1185,520],dimensions:[]}]),A=Object.freeze([{breakpoint:[300,480],dimensions:[320,100]},{breakpoint:[1185,520],dimensions:[]}]),I=Object.freeze([{breakpoint:[1185,520],dimensions:[[970,90],[728,90]]},{breakpoint:[300,480],dimensions:[]}]),x=Object.freeze([{breakpoint:[1185,520],dimensions:[1,5]},{breakpoint:[300,480],dimensions:[]}]),B=Object.freeze([{breakpoint:[1185,520],dimensions:[]},{breakpoint:[300,480],dimensions:[[1,4],[320,480]]}]),$=Object.freeze([{breakpoint:[1185,520],dimensions:[]},{breakpoint:[300,480],dimensions:[[320,50],[320,100]]}]);export{v as _,_ as a,B as b,$ as c,I as d,x as e,A as f,y as m};