import React, { useEffect, useRef, useState } from 'react'; import { X } from 'lucide-react'; const MobileAdBanner = () => { const [visible, setVisible] = useState(true); const [closed, setClosed] = useState(false); const iframeRef = useRef(null); useEffect(() => { const wasClosed = sessionStorage.getItem('mobileAdClosed'); if (wasClosed === 'true') { setClosed(true); setVisible(false); } }, []); useEffect(() => { if (!visible || closed || !iframeRef.current) return; const timer = setTimeout(() => { if (!iframeRef.current) return; const iframe = iframeRef.current; const doc = iframe.contentDocument || iframe.contentWindow.document; doc.open(); doc.write(`
`); doc.close(); }, 500); return () => clearTimeout(timer); }, [visible, closed]); const handleClose = () => { setVisible(false); setClosed(true); sessionStorage.setItem('mobileAdClosed', 'true'); }; if (!visible || closed) return null; return (