PageSourceSearch

https://rouen-bouge.fr/assets/NewsletterComposerPage-BbhueFcL.js

js rouen-bouge.fr collected 2026-10-02 19:54:31 UTC 28,580 bytes, 108 lines download raw bytes

vendor: 4,731 bytes, lines 1-11
1import{c as Se,o as Qe,r as n,j as e,P as Q,aj as Ze,am as J,a as Z,g as D,X as et,s as A,d as h}from"./index-DvwP-Zr8.js";import{A as tt}from"./AdminLayout-C03x7ibc.js";import{B as z}from"./button-4P_Nsplj.js";import{I as S}from"./input-ZMJDqW4n.js";import{C as b,a as w,b as N,d as _}from"./card-DametLb1.js";import{C as ve}from"./checkbox-DgIaH9ye.js";import{s as st}from"./index-b1Hnr8AB.js";import{S as ye}from"./switch-Deyw4fAf.js";import{L as E}from"./label-BEw5h5L7.js";import{S as B,a as V,b as U,c as q,d as O}from"./select-BtgtVuOH.js";import{u as at}from"./useWordPress-DlXx1Nz_.js";import{u as rt}from"./useEvents-BVL4sO1f.js";import{u as nt}from"./useSiteSettings-bVp6oyBR.js";import{c as lt}from"./useAds-77cezzOJ.js";import{g as F,s as je,a as be}from"./wordpress-Bpx1AK2_.js";import{U as it}from"./upload-B9-y2vw3.js";import{S as ot}from"./star-UuDGOSDq.js";import{N as we}from"./newspaper-CrRyADd9.js";import{C as Ne}from"./calendar-days-Cqu1sFKB.js";import{M as ct}from"./megaphone-CYKl6W_o.js";import{L as dt}from"./list-BQrkYaKv.js";import{E as pt}from"./eye-BEH9BoIv.js";import{S as mt}from"./send-DaM7PcLa.js";import{f as G}from"./format-DZYYZzof.js";import{f as W}from"./fr-TqZFd7oH.js";import"./logo-rouen-bouge-B0IHZYcV.js";import"./settings-hMyE6vAu.js";import"./chevron-left-DgTAXmyj.js";import"./log-out-Cgb4WbnD.js";import"./menu-OnOzzZr4.js";import"./chart-column-BpCkngdK.js";import"./trending-up-80BXvHgT.js";import"./sparkles-CEwW15GO.js";import"./instagram-DvFPU6q3.js";import"./mail-DjWnhzI_.js";import"./ticket-CYRCxo7t.js";import"./index-aHyGAGLx.js";import"./check-Dd1RHR-L.js";import"./index-BdQq_4o_.js";import"./index-B1P5DQK5.js";import"./index-CBSFb-F-.js";import"./chevron-up--bBnR_8N.js";import"./useQuery-BWnxGLDx.js";import"./useMutation-DCabkvd2.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const ut=Se("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const xt=Se("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);function ft(){return st.useSyncExternalStore(gt,()=>!0,()=>!1)}function gt(){return()=>{}}var ee="Avatar",[ht,us]=Qe(ee),[vt,ke]=ht(ee),Ee=n.forwardRef((a,l)=>{const{__scopeAvatar:o,...p}=a,[d,i]=n.useState("idle");return e.jsx(vt,{scope:o,imageLoadingStatus:d,onImageLoadingStatusChange:i,children:e.jsx(Q.span,{...p,ref:l})})});Ee.displayName=ee;var Ce="AvatarImage",$e=n.forwardRef((a,l)=>{const{__scopeAvatar:o,src:p,onLoadingStatusChange:d=()=>{},...i}=a,m=ke(Ce,o),x=yt(p,i),u=Ze(y=>{d(y),m.onImageLoadingStatusChange(y)});return J(()=>{x!=="idle"&&u(x)},[x,u]),x==="loaded"?e.jsx(Q.img,{...i,ref:l,src:p}):null});$e.displayName=Ce;var Le="AvatarFallback",Ae=n.forwardRef((a,l)=>{const{__scopeAvatar:o,delayMs:p,...d}=a,i=ke(Le,o),[m,x]=n.useState(p===void 0);return n.useEffect(()=>{if(p!==void 0){const u=window.setTimeout(()=>x(!0),p);return()=>window.clearTimeout(u)}},[p]),m&&i.imageLoadingStatus!=="loaded"?e.jsx(Q.span,{...d,ref:l}):null});Ae.displayName=Le;function _e(a,l){return a?l?(a.src!==l&&(a.src=l),a.complete&&a.naturalWidth>0?"loaded":"loading"):"error":"idle"}function yt(a,{referrerPolicy:l,crossOrigin:o}){const p=ft(),d=n.useRef(null),i=p?(d.current||(d.current=new window.Image),d.current):null,[m,x]=n.useState(()=>_e(i,a));return J(()=>{x(_e(i,a))},[i,a]),J(()=>{const u=C=>()=>{x(C)};if(!i)return;const y=u("loaded"),k=u("error");return i.addEventListener("load",y),i.addEventListener("error",k),l&&(i.referrerPolicy=l),typeof o=="string"&&(i.crossOrigin=o),()=>{i.removeEventListener("load",y),i.removeEventListener("error",k)}},[i,o,l]),m}var ze=Ee,Fe=$e,Me=Ae;const Ie=n.forwardRef(({className:a,...l},o)=>e.jsx(ze,{ref:o,className:Z("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",a),...l}));Ie.displayName=ze.displayName;const Re=n.forwardRef(({className:a,...l},o)=>e.jsx(Fe,{ref:o,className:Z("aspect-square h-full w-full",a),...l}));Re.displayName=Fe.displayName;const Pe=n.forwardRef(({className:a,...l},o)=>e.jsx(Me,{ref:o,className:Z("flex h-full w-full items-center justify-center rounded-full bg-muted",a),...l}));Pe.displayName=Me.displayName;function xs(){var ue,xe;const{data:a,isLoading:l}=at(1,20),{data:o,isLoading:p}=rt(),{data:d}
11=nt(),{data:i}=lt(),[m,x]=n.useState([]),[u,y]=n.useState([]),[k,C]=n.useState(""),[M,g]=n.useState("Hello les Rouennais ! 👋"),[K,Te]=n.useState("Voilà les bons plans que je vous ai sélectionnés cette semaine 🌟"),[te,se]=n.useState(!1),[ae,re]=n.useState(!1),[ne,le]=n.useState(!1),[P,He]=n.useState(""),[T,ie]=n.useState(null),[De,oe]=n.useState(!1),ce=n.useRef(null),[f,$]=n.useState({enabled:!1,image_url:"",title:"",link_url:"",label:"Partenaire"}),[c,I]=n.useState({enabled:!1,type:"article",article_id:null,event_id:null}),[H,Be]=n.useState([]),[Ve,de]=n.useState(!1),[j,pe]=n.useState(""),X=(ue=d==null?void 0:d.find(t=>t.key==="brevo_list_id"))==null?void 0:ue.value;n.useEffect(()=>{var s;const t=(s=d==null?void 0:d.find(r=>r.key==="newsletter_avatar_url"))==null?void 0:s.value;t&&ie(t)},[d]),n.useEffect(()=>{(async()=>{de(!0);try{const{data:s,error:r}=await A.functions.invoke("brevo-lists");if(r)throw r;s!=null&&s.lists&&Be(s.lists)}catch(s){console.error("Failed to fetch Brevo lists:",s)}finally{de(!1)}})()},[]),n.useEffect(()=>{X&&!j&&pe(X)},[X]);const Ue=async t=>{var r;const s=(r=t.target.files)==null?void 0:r[0];if(s){if(!s.type.startsWith("image/")){h.error("Fichier image requis");return}oe(!0);try{const R=`avatar-newsletter.${s.name.split(".").pop()}`,{error:fe}=await A.storage.from("newsletter-assets").upload(R,s,{upsert:!0});if(fe)throw fe;const{data:{publicUrl:ge}}=A.storage.from("newsletter-assets").getPublicUrl(R);ie(ge);const{error:he}=await A.from("site_settings").upsert({key:"newsletter_avatar_url",value:ge},{onConflict:"key"});he&&console.error("Failed to save avatar URL:",he),h.success("Avatar mis à jour !")}catch(v){h.error(`Erreur upload : ${v.message}`)}finally{oe(!1)}}},L=n.useMemo(()=>o?o.slice(0,20):[],[o]);n.useEffect(()=>{C(`🔥 Cette semaine à Rouen - ${new Date().toLocaleDateString("fr-FR",{day:"numeric",month:"long"})}`)},[]);const qe=t=>x(s=>s.includes(t)?s.filter(r=>r!==t):[...s,t]),Oe=t=>y(s=>s.includes(t)?s.filter(r=>r!==t):[...s,t]),Ge=t=>{const s=i==null?void 0:i.find(r=>r.id===t);s&&$(r=>({...r,image_url:s.image_url,title:s.title,link_url:s.link_url}))},We=()=>{var t;if(!c.enabled)return null;if(c.type==="article"&&c.article_id){const s=a==null?void 0:a.posts.find(r=>r.id===c.article_id);return s?{type:"article",title:s.title.rendered,slug:s.slug,image:F(s,"medium_large")||F(s,"medium")||"",excerpt:je(s.excerpt.rendered).slice(0,200),category:((t=be(s)[0])==null?void 0:t.name)||"Actu"}:null}if(c.type==="event"&&c.event_id){const s=L.find(r=>r.id===c.event_id);return s?{type:"event",title:s.title,event_date:s.event_date,location_name:s.location_name,id:s.id,image:s.image_url||""}:null}return null},Y=()=>{const t=((a==null?void 0:a.posts)||[]).filter(r=>m.includes(r.id)).map(r=>{var v;return{title:r.title.rendered,slug:r.slug,excerpt:je(r.excerpt.rendered).slice(0,140),image:F(r,"medium")||"",category:((v=be(r)[0])==null?void 0:v.name)||"Actu"}}),s=L.filter(r=>u.includes(r.id)).map(r=>({id:r.id,title:r.title,event_date:r.event_date,location_name:r.location_name}));return{articles:t,events:s,deal:null,subject:k,intro_title:M,intro_message:K,avatar_url:T,sponsor:f.enabled?{image_url:f.image_url,title:f.title,link_url:f.link_url,label:f.label}:null,highlight:We()}},Ke=()=>se(!0),Xe=async()=>{var s;if(!j){h.error("Sélectionnez une liste Brevo");return}if(m.length===0&&u.length===0){h.error("Sélectionnez au moins un contenu");return}const t=((s=H.find(r=>r.id.toString()===j))==null?void 0:s.name)||`liste #${j}`;if(confirm(`Envoyer la newsletter à "${t}" ?`)){re(!0);try{const r={...Y(),list_id:parseInt(j)},{data:v,error:R}=await A.functions.invoke("send-weekly-newsletter",{body:r});if(R)throw R;if(v!=null&&v.error)throw new Error(v.error);h.success(`Newsletter envoyée ! ${r.articles.length} articles, ${r.events.length} événements`)}catch(r){h.error(`Erreur : ${r.message}`)}finally{re(!1)}}},Ye=async()=>{if(!P){h.error("Entrez une adresse email pour le test");return}if(m.length===0&&u.length===0){h.error("Sélectionnez au moins un contenu");return}le(!0);try{const t={...Y(),test_email:P},{data:s,error:r}=await A.functions.invoke("send-weekly-newsletter",{body:t});if(r)throw r;if(s!=null&&s.error)throw new Error(s.error);h.success(`Email test envoyé à ${P} !`)}catch(t){h.error(`Erreur : ${t.message}`)}finally{le(!1)}},Je=Y(),me=(i==null?void 0:i.filter(t=>t.is_active))||[];return e.jsx(tt,{title:"Composer la Newsletter",children:e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs(b,{children:[e.jsx(w,{className:"pb-3",children:e.jsx(N,{className:"text-base",children:"Objet de l'email"})}),e.jsx(_,{children:e.jsx(S,{value:k,onChange:t=>C(t.target.value),placeholder:"Objet..."})})]}),e.jsxs(b,{children:[e.jsx(w,{className:"pb-3",children:e.jsx(N,{className:"text-base",children:"Message d'introduction"})}),e.jsxs(_,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"relative group cursor-pointer",onClick:()=>{var t;return(t=ce.current)==null?void 0:t.click()},children:[e.jsxs(Ie,{className:"w-16 h-16",children:[T?e.jsx(Re,{src:T,alt:"Avatar newsletter"}):null,e.jsx(Pe,{children:e.jsx(xt,{className:"w-6 h-6"})})]}),e.jsx("div",{className:"absolute inset-0 bg-black/40 rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:De?e.jsx(D,{className:"w-4 h-4 text-white animate-spin"}):e.jsx(it,{className:"w-4 h-4 text-white"})}),e.jsx("input",{ref:ce,type:"file",accept:"image/*",className:"hidden",onChange:Ue})]}),e.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:"Cliquez pour changer la photo avatar de la newsletter"})]}),e.jsx(S,{value:M,onChange:t=>g(t.target.value),placeholder:"Titre (ex: Hello les Rouennais !)"}),e.jsx(S,{value:K,onChange:t=>Te(t.target.value),placeholder:"Message sous l'avatar..."})]})]}),e.jsxs(b,{children:[e.jsx(w,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(N,{className:"text-base flex items-center gap-2",children:[e.jsx(ot,{className:"w-4 h-4 text-yellow-500"}),"Mise en avant"]}),e.jsx(ye,{checked:c.enabled,onCheckedChange:t=>I(s=>({...s,enabled:t}))})]})}),c.enabled&&e.jsxs(_,{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(z,{variant:c.type==="article"?"default":"outline",size:"sm",onClick:()=>I(t=>({...t,type:"article",event_id:null})),children:[e.jsx(we,{className:"w-3.5 h-3.5 mr-1.5"})," Article"]}),e.jsxs(z,{variant:c.type==="event"?"default":"outline",size:"sm",onClick:()=>I(t=>({...t,type:"event",article_id:null})),children:[e.jsx(Ne,{className:"w-3.5 h-3.5 mr-1.5"})," Événement"]})]}),c.type==="article"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(E,{className:"text-xs text-muted-foreground",children:"Choisir un article"}),e.jsxs(B,{value:((xe=c.article_id)==null?void 0:xe.toString())||"",onValueChange:t=>I(s=>({...s,article_id:parseInt(t)})),children:[e.jsx(V,{children:e.jsx(U,{placeholder:"Sélectionner un article..."})}),e.jsx(q,{children:a==null?void 0:a.posts.map(t=>e.jsx(O,{value:t.id.toString(),children:e.jsx("span",{dangerouslySetInnerHTML:{__html:t.title.rendered}})},t.id))})]})]}),c.type==="event"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(E,{className:"text-xs text-muted-foreground",children:"Choisir un événement"}),e.jsxs(B,{value:c.event_id||"",onValueChange:t=>I(s=>({...s,event_id:t})),children:[e.jsx(V,{children:e.jsx(U,{placeholder:"Sélectionner un événement..."})}),e.jsx(q,{children:L.map(t=>e.jsxs(O,{value:t.id,children:[t.title," — ",G(new Date(t.event_date),"dd MMM",{locale:W})]},t.id))})]})]}),c.type==="article"&&c.article_id&&(()=>{const t=a==null?void 0:a.posts.find(r=>r.id===c.article_id);if(!t)return null;const s=F(t,"thumbnail");return e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg bg-muted/50 border",children:[s&&e.jsx("img",{src:s,alt:"",className:"w-14 h-14 roun
11ded object-cover shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold line-clamp-2",dangerouslySetInnerHTML:{__html:t.title.rendered}}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Article mis en avant"})]})]})})(),c.type==="event"&&c.event_id&&(()=>{const t=L.find(s=>s.id===c.event_id);return t?e.jsx("div",{className:"flex items-center gap-3 p-2 rounded-lg bg-muted/50 border",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold",children:t.title}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[G(new Date(t.event_date),"EEEE dd MMM",{locale:W})," • ",t.location_name]})]})}):null})()]})]}),e.jsxs(b,{children:[e.jsx(w,{className:"pb-3",children:e.jsxs(N,{className:"text-base flex items-center gap-2",children:[e.jsx(we,{className:"w-4 h-4 text-primary"}),"Articles (",m.length," sélectionnés)"]})}),e.jsx(_,{className:"max-h-80 overflow-y-auto space-y-2",children:l?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Chargement..."}):a==null?void 0:a.posts.map(t=>e.jsxs("label",{className:"flex items-start gap-3 p-2 rounded-lg hover:bg-muted cursor-pointer",children:[e.jsx(ve,{checked:m.includes(t.id),onCheckedChange:()=>qe(t.id),className:"mt-1"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium line-clamp-2",dangerouslySetInnerHTML:{__html:t.title.rendered}}),e.jsx("p",{className:"text-xs text-muted-foreground",children:G(new Date(t.date),"dd MMM yyyy",{locale:W})})]}),F(t,"thumbnail")&&e.jsx("img",{src:F(t,"thumbnail"),alt:"",className:"w-12 h-12 rounded object-cover shrink-0"})]},t.id))})]}),e.jsxs(b,{children:[e.jsx(w,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(N,{className:"text-base flex items-center gap-2",children:[e.jsx(ct,{className:"w-4 h-4 text-orange-500"}),"Sponsor / Pub"]}),e.jsx(ye,{checked:f.enabled,onCheckedChange:t=>$(s=>({...s,enabled:t}))})]})}),f.enabled&&e.jsxs(_,{className:"space-y-3",children:[me.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(E,{className:"text-xs text-muted-foreground",children:"Charger depuis une pub existante"}),e.jsxs(B,{onValueChange:Ge,children:[e.jsx(V,{children:e.jsx(U,{placeholder:"Sélectionner une pub..."})}),e.jsx(q,{children:me.map(t=>e.jsx(O,{value:t.id,children:t.title},t.id))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(E,{className:"text-xs text-muted-foreground",children:"Label"}),e.jsx(S,{value:f.label,onChange:t=>$(s=>({...s,label:t.target.value})),placeholder:"Partenaire"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(E,{className:"text-xs text-muted-foreground",children:"Titre"}),e.jsx(S,{value:f.title,onChange:t=>$(s=>({...s,title:t.target.value})),placeholder:"Titre de la pub"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(E,{className:"text-xs text-muted-foreground",children:"URL de l'image"}),e.jsx(S,{value:f.image_url,onChange:t=>$(s=>({...s,image_url:t.target.value})),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(E,{className:"text-xs text-muted-foreground",children:"Lien (CTA)"}),e.jsx(S,{value:f.link_url,onChange:t=>$(s=>({...s,link_url:t.target.value})),placeholder:"https://..."})]}),f.image_url&&e.jsx("div",{className:"rounded-lg overflow-hidden border",children:e.jsx("img",{src:f.image_url,alt:"Aperçu pub",className:"w-full h-32 object-cover"})})]})]}),e.jsxs(b,{children:[e.jsx(w,{className:"pb-3",children:e.jsxs(N,{className:"text-base flex items-center gap-2",children:[e.jsx(Ne,{className:"w-4 h-4 text-accent"}),"Événements (",u.length," sélectionnés)"]})}),e.jsx(_,{className:"max-h-64 overflow-y-auto space-y-2",children:p?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Chargement..."}):L.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"Aucun événement à venir"}):L.map(t=>e.jsxs("label",{className:"flex items-start gap-3 p-2 rounded-lg hover:bg-muted cursor-pointer",children:[e.jsx(ve,{checked:u.includes(t.id),onCheckedChange:()=>Oe(t.id),className:"mt-1"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:t.title}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[G(new Date(t.event_date),"EEEE dd MMM",{locale:W})," • ",t.location_name]})]})]},t.id))})]}),e.jsxs(b,{children:[e.jsx(w,{className:"pb-3",children:e.jsxs(N,{className:"text-base flex items-center gap-2",children:[e.jsx(ut,{className:"w-4 h-4"})," Envoi test"]})}),e.jsx(_,{className:"space-y-3",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(S,{value:P,onChange:t=>He(t.target.value),placeholder:"[email protected]",type:"email",className:"flex-1"}),e.jsx(z,{variant:"outline",onClick:Ye,disabled:ne,children:ne?e.jsx(D,{className:"w-4 h-4 animate-spin"}):"Tester"})]})})]}),e.jsxs(b,{children:[e.jsx(w,{className:"pb-3",children:e.jsxs(N,{className:"text-base flex items-center gap-2",children:[e.jsx(dt,{className:"w-4 h-4 text-primary"}),"Liste d'envoi Brevo"]})}),e.jsx(_,{children:Ve?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(D,{className:"w-4 h-4 animate-spin"})," Chargement des listes..."]}):H.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Aucune liste trouvée. Vérifiez votre clé API Brevo."}):e.jsxs(B,{value:j,onValueChange:pe,children:[e.jsx(V,{children:e.jsx(U,{placeholder:"Sélectionner une liste..."})}),e.jsx(q,{children:H.map(t=>e.jsxs(O,{value:t.id.toString(),children:[t.name," (",t.totalSubscribers," contacts)"]},t.id))})]})})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(z,{variant:"outline",onClick:Ke,className:"flex-1",children:[e.jsx(pt,{className:"w-4 h-4 mr-2"})," Aperçu"]}),e.jsxs(z,{onClick:Xe,disabled:ae||!j,className:"flex-1",children:[ae?e.jsx(D,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(mt,{className:"w-4 h-4 mr-2"}),"Envoyer à la liste"]})]}),j?(()=>{const t=H.find(s=>s.id.toString()===j);return t?e.jsxs("p",{className:"text-sm text-muted-foreground text-center",children:["📬 ",e.jsx("strong",{children:t.name})," — ",t.totalSubscribers," contact",t.totalSubscribers!==1?"s":""]}):null})():e.jsx("p",{className:"text-sm text-destructive",children:"⚠️ Sélectionnez une liste Brevo ci-dessus"})]}),e.jsx("div",{className:"sticky top-20",children:e.jsxs(b,{className:"h-[calc(100vh-8rem)] flex flex-col",children:[e.jsxs(w,{className:"pb-3 flex flex-row items-center justify-between",children:[e.jsx(N,{className:"text-base",children:"Aperçu"}),te&&e.jsx(z,{variant:"ghost",size:"icon",onClick:()=>se(!1),children:e.jsx(et,{className:"w-4 h-4"})})]}),e.jsx(_,{className:"flex-1 overflow-hidden p-0",children:te||m.length>0||u.length>0||c.enabled?e.jsx("iframe",{srcDoc:wt(Je,M,K,T),className:"w-full h-full border-0",title:"Newsletter preview"}):e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Sélectionnez du contenu pour voir l'aperçu"})})]})})]})})}function jt(a,l){if(!a)return"";if(a.type==="article")return`
12    <tr><td style="padding:16px 32px;">
13      <table width="100%" cellpadding="0" cellspacing="0" style="background:linear-gradient(135deg,#FFF8E1,#FFF3E0);border-radius:12px;overflow:hidden;">
14        ${a.image?`<tr><td>
15          <a href="${l}/${a.slug}"><img src="${a.image}" width="100%" style="display:block;max-height:220px;object-fit:cover;" alt="" /></a>
16        </td></tr>`:""}
17        <tr><td style="padding:20px;">
18          <span style="font-size:10px;color:#E65100;font-weight:700;text-transform:uppercase;letter-spacing:1px;">⭐ ${a.category||"À lire"}</span>
19          <a href="${l}/${a.slug}" style="text-decoration:none;color:#111;"><p style="margin:8px 0;font-size:20px;font-weight:800;line-height:1.3;">${a.title}</p></a>
20          <p style="margin:0 0 16px;font-size:14px;color:#555;line-height:1.5;">${a.excerpt}...</p>
21          <a href="${l}/${a.slug}" style="display:inline-block;background:#E61D4F;color:white;padding:10px 24px;border-radius:8px;text-decoration:none;font-weight:700;font-size:14px;">Lire l'article →</a>
22        </td></tr>
23      </table>
24    </td></tr>`;if(a.type==="event"){const o=new Date(a.event_date);return`
25    <tr><td style="padding:16px 32px;">
26      <table width="100%" cellpadding="0" cellspacing="0" style="background:linear-gradient(135deg,#E8F5E9,#F1F8E9);border-radius:12px;overflow:hidden;">
27        ${a.image?`<tr><td>
28          <a href="${l}/evenements/${a.slug||a.id}"><img src="${a.image}" width="100%" style="display:block;max-height:220px;object-fit:cover;" alt="" /></a>
29        </td></tr>`:""}
30        <tr><td style="padding:20px;">
31          <span style="font-size:10px;color:#2E7D32;font-weight:700;text-transform:uppercase;letter-spacing:1px;">⭐ Événement à ne pas manquer</span>
32          <a href="${l}/evenements/${a.slug||a.id}" style="text-decoration:none;color:#111;"><p style="margin:8px 0;font-size:20px;font-weight:800;line-height:1.3;">${a.title}</p></a>
33          <p style="margin:0 0 4px;font-size:14px;color:#555;">📅 ${o.toLocaleDateString("fr-FR",{weekday:"long",day:"numeric",month:"long"})}</p>
34          <p style="margin:0 0 16px;font-size:14px;color:#555;">📍 ${a.location_name}</p>
35          <a href="${l}/evenements/${a.slug||a.id}" style="display:inline-block;background:#2E7D32;color:white;padding:10px 24px;border-radius:8px;text-decoration:none;font-weight:700;font-size:14px;">Voir l'événement →</a>
36        </td></tr>
37      </table>
38    </td></tr>`}return""}function bt(a){return a?`
39    <tr><td style="padding:16px 32px;">
40      <table width="100%" cellpadding="0" cellspacing="0" style="border:2px solid #E61D4F;border-radius:12px;overflow:hidden;">
41        <tr><td style="padding:16px 20px 12px;">
42          <span style="font-size:10px;color:#E61D4F;font-weight:700;text-transform:uppercase;letter-spacing:1px;">${a.label}</span>
43        </td></tr>
44        ${a.image_url?`<tr><td style="padding:0 20px;">
45          <a href="${a.link_url}" target="_blank"><img src="${a.image_url}" width="100%" style="border-radius:8px;display:block;max-height:200px;object-fit:cover;" alt="${a.title}" /></a>
46        </td></tr>`:""}
47        <tr><td style="padding:12px 20px;">
48          <p style="margin:0 0 12px;font-size:16px;font-weight:700;color:#111;">${a.title}</p>
49          ${a.link_url?`<a href="${a.link_url}" target="_blank" style="display:inline-block;background:#E61D4F;color:white;padding:8px 20px;border-radius:8px;text-decoration:none;font-weight:600;font-size:13px;">Découvrir →</a>`:""}
50        </td></tr>
51      </table>
52    </td></tr>`:""}function wt(a,l,o,p){const d="https://rouen-bouge.lovable.app",{articles:i,events:m,sponsor:x,highlight:u}=a,y=i.length?i.map(g=>`
53    <tr><td style="padding: 12px 0; border-bottom: 1px solid #f0f0f0;">
54      <table width="100%" cellpadding="0" cellspacing="0"><tr>
55        ${g.image?`<td width="120" style="padding-right: 16px; vertical-align: top;">
56          <img src="${g.image}" width="120" height="80" style="border-radius: 8px; object-fit: cover; display: block;" alt="" />
57        </td>`:""}
58        <td style="vertical-align: top;">
59          <span style="font-size: 11px; color: #E61D4F; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;">${g.category}</span>
60          <p style="margin: 4px 0 0; font-size: 16px; font-weight: 700; line-height: 1.3; color: #111;">${g.title}</p>
61          <p style="margin: 4px 0 0; font-size: 13px; color: #666; line-height: 1.4;">${g.excerpt}...</p>
62        </td>
63      </tr></table>
64    </td></tr>
65  `).join(""):"",k=m.length?m.map(g=>`
66    <tr><td style="padding: 8px 0;">
67      <table width="100%" cellpadding="0" cellspacing="0"><tr>
68        <td width="50" style="vertical-align: top; text-align: center; padding-right: 12px;">
69          <div style="background: #E61D4F; color: white; border-radius: 8px; padding: 6px 8px;">
70            <div style="font-size: 18px; font-weight: 800; line-height: 1;">${new Date(g.event_date).getDate()}</div>
71            <div style="font-size: 10px; text-transform: uppercase;">${new Date(g.event_date).toLocaleDateString("fr-FR",{month:"short"})}</div>
72          </div>
73        </td>
74        <td style="vertical-align: top;">
75          <p style="margin: 0; font-size: 15px; font-weight: 600; color: #111;">${g.title}</p>
76          <p style="margin: 2px 0 0; font-size: 12px; color: #888;">📍 ${g.location_name}</p>
77        </td>
78      </tr></table>
79    </td></tr>
80  `).join(""):"",C=jt(u,d),M=bt(x||null);return`<!DOCTYPE html><html lang="fr"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width"></head>
81<body style="margin:0;padding:0;background:#f5f5f5;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;">
82  <table width="100%" cellpadding="0" cellspacing="0" style="background:#f5f5f5;padding:20px 0;"><tr><td align="center">
83    <table width="600" cellpadding="0" cellspacing="0" style="background:white;border-radius:16px;overflow:hidden;max-width:100%;">
84      <tr><td style="background:#111;padding:24px 32px;text-align:center;">
85        <h1 style="margin:0;color:white;font-size:28px;font-weight:800;">ROUEN <span style="color:#E61D4F;">BOUGE</span></h1>
86      </td></tr>
87      <tr><td style="background:linear-gradient(180deg,#f8c8d4 0%,#fdf0f3 60%,#ffffff 100%);padding:32px 32px 24px;text-align:center;">
88        ${p?`<div style="width:100px;height:100px;margin:0 auto 16px;border-radius:50%;background:rgba(255,255,255,0.5);padding:4px;">
89          <img src="${p}" width="92" height="92" style="border-radius:50%;object-fit:cover;display:block;" alt="Avatar" />
90        </div>`:""}
91        <h2 style="margin:0 0 8px;font-size:22px;font-weight:800;color:#111;">${l}</h2>
92        <p style="margin:0;font-size:14px;color:#555;line-height:1.5;">${o}</p>
93      </td></tr>
94      ${C}
95      ${i.length?`<tr><td style="padding:24px 32px 16px;"><h2 style="margin:0 0 16px;font-size:20px;color:#111;">📰 À la une</h2><table width="100%" cellpadding="0" cellspacing="0">${y}</table></td></tr>`:""}
96      ${M}
97      ${m.length?`<tr><td style="padding:16px 32px;"><h2 style="margin:0 0 16px;font-size:20px;color:#111;">🎉 Les événements</h2><table width="100%" cellpadding="0" cellspacing="0">${k}</table><p style="margin:16px 0 0;text-align:center;"><a href="${d}/evenements" style="display:inline-block;background:#3F80FF;color:white;padding:10px 24px;border-radius:8px;text-decoration:none;font-weight:600;font-size:14px;">Voir tous les événements →</a></p></td></tr>`:""}
98      <tr><td style="padding:32px 32px 16px;text-align:center;
98border-top:1px solid #f0f0f0;">
99        <p style="margin:0 0 8px;font-size:13px;color:#888;">Rouen Bouge - Ton média local positif 💛</p>
100        <p style="margin:0;font-size:12px;color:#aaa;"><a href="${d}" style="color:#E61D4F;text-decoration:none;">rouen-bouge.fr</a> • <a href="https://bonnes-adresses.fr" style="color:#3F80FF;text-decoration:none;">bonnes-adresses.fr</a></p>
101      </td></tr>
102      <tr><td style="padding:0 32px 32px;text-align:center;">
103        <p style="margin:0 0 12px;font-size:11px;color:#aaa;line-height:1.5;">Vous recevez cet email car vous êtes inscrit(e) à la newsletter Rouen Bouge.</p>
104        <p style="margin:0;font-size:12px;"><span style="color:#E61D4F;text-decoration:underline;font-weight:600;cursor:default;">Se désinscrire</span> <span style="color:#ccc;margin:0 6px;">|</span> <span style="color:#888;text-decoration:underline;cursor:default;">Gérer mes préférences</span></p>
105      </td></tr>
106    </table>
107  </td></tr></table>
108</body></html>`}export{xs 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.