1import{j as t}from"./vendor-ui-fc56ca80.js";import{u as x,f,r as m}from"./vendor-react-f9ccc48d.js";import{h as v,c2 as h}from"./index-90016d22.js";import"./vendor-firebase-a557f106.js";import"./vendor-utils-323b9898.js";import"./vendor-charts-9af8b7c0.js";function S(){const[p]=x(),a=f(),{churchData:s}=v(),[w,r]=m.useState(""),[g,i]=m.useState(!0);if(m.useEffect(()=>{if(a.state&&a.state.content){r(a.state.content),i(!1);return}const n=localStorage.getItem("newsletter_preview_content"),l=localStorage.getItem("newsletter_preview_timestamp"),d=Date.now();if(n&&l&&d-parseInt(l)<3e4){r(n),i(!1);return}if(window.opener&&window.opener.postMessage){window.opener.postMessage("REQUEST_CONTENT","*");const e=c=>{c.data&&c.data.type==="NEWSLETTER_CONTENT"&&(r(c.data.content||"<p>No se recibió contenido</p>"),i(!1),window.removeEventListener("message",e))};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}}const o=p.get("content");if(o)try{let e;try{e=atob(o)}catch{e=decodeURIComponent(o)}r(e)}catch(e){console.error("Error decoding content:",e),r("<p>Error loading preview content.</p>")}else r("<p>No content provided for preview.</p>");i(!1)},[p,a]),g)return t.jsx("div",{className:"flex items-center justify-center min-h-screen",children:t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-gray-900"})});const u=n=>{if(n.includes("<html"))return n;{const d=(s==null?void 0:s.name)||"La Iglesia Primera",o=(s==null?void 0:s.logoUrl)||"";return h.wrapHtmlContent(n,d,o)}};return t.jsx("div",{className:"min-h-screen bg-gray-100",children:t.jsxs("div",{className:"max-w-4xl mx-auto py-8 px-4",children:[t.jsx("div",{className:"bg-white shadow-md rounded-lg overflow-hidden",children:t.jsx("iframe",{srcDoc:u(w),className:"w-full border-0",style:{height:"calc(100vh - 200px)",minHeight:"600px",maxHeight:"1200px"},title:"Newsletter Preview"})}),t.jsxs("div",{className:"mt-6 text-center",children:[t.jsx("p",{className:"text-sm text-gray-500",children:"Esta es una vista previa de cómo se verá tu newsletter para los destinatarios."}),t.jsx("button",{onClick:()=>window.close(),className:"mt-4 px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700",children:"Cerrar Vista Previa"})]})]})})}export{S as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.