{"version":3,"file":"TrackginBanner.CQrIkYFP.mjs","names":["React.useState","React.useRef"],"sources":["https:/framerusercontent.com/modules/oMlBsXovgSBHIyu77ZKb/SuXtbnM6m9bAiwogpuxd/TrackginBanner.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{ControlType,addPropertyControls,RenderTarget}from\"framer\";export default function GA4Banner(props){const{children,promotion_id,promotion_name,location}=props;const[hasBeenViewed,setHasBeenViewed]=React.useState(false);const bannerRef=React.useRef(null);const sendEvent=eventName=>{if(typeof window!==\"undefined\"){window.dataLayer=window.dataLayer||[];window.dataLayer.push({event:eventName,promotion_id,promotion_name,location});console.log(`📡 [GA4] ${eventName}:`,{promotion_id,promotion_name,location});}};// Lógica para detectar se o banner apareceu na tela (Intersection Observer)\nReact.useEffect(()=>{// Não dispara no Canvas do Framer, apenas no Preview ou Site Publicado\nif(RenderTarget.current()===RenderTarget.canvas)return;if(hasBeenViewed)return;// Garante que dispare apenas 1 vez\nconst observer=new IntersectionObserver(([entry])=>{if(entry.isIntersecting){sendEvent(\"view_promotion\");setHasBeenViewed(true);observer.disconnect()// Para de observar após o disparo\n;}},{threshold:.5}// 50% do banner precisa estar visível para contar\n);if(bannerRef.current){observer.observe(bannerRef.current);}return()=>observer.disconnect();},[sendEvent,hasBeenViewed]);return /*#__PURE__*/_jsx(\"div\",{ref:bannerRef,onClick:()=>sendEvent(\"select_promotion\"),style:{display:\"block\",cursor:\"pointer\"},children:children});}addPropertyControls(GA4Banner,{children:{type:ControlType.ComponentInstance,title:\"Banner Element\"},promotion_id:{type:ControlType.String,title:\"Promo ID\",defaultValue:\"promo_01\"},promotion_name:{type:ControlType.String,title:\"Promo Name\",defaultValue:\"Campanha Ver\\xe3o\"},location:{type:ControlType.String,title:\"Location\",defaultValue:\"home_hero\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"GA4Banner\",\"slots\":[],\"annotations\":{\"framerContractVersion\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