import{r as m,a5 as g,j as e,a6 as p,a7 as b}from"./vendor-laZsiqLO.js";import w from"./InlineRelatedWidget-CmRLpMNL.js";import{u as x}from"./app-D2josV_r.js";import"./useTranslation-BW0o-tkY.js";import"./bootstrap-CBwglqL9.js";/* empty css            */const h=({url:i})=>(m.useEffect(()=>{const s="twitter-wjs";if(document.getElementById(s))window.twttr&&window.twttr.widgets&&window.twttr.widgets.load();else{const n=document.createElement("script");n.id=s,n.src="https://platform.twitter.com/widgets.js",n.async=!0,document.body.appendChild(n)}},[i]),e.jsx("div",{className:"flex justify-center w-full my-8",children:e.jsx("div",{className:"w-full max-w-[550px] min-h-[350px] border border-border bg-muted/10 rounded-[var(--radius)] flex items-center justify-center relative overflow-hidden",children:e.jsx("blockquote",{className:"twitter-tweet w-full","data-dnt":"true",children:e.jsx("a",{href:i})})})})),y=({url:i})=>{m.useEffect(()=>{const n="instagram-wjs";if(document.getElementById(n))window.instgrm&&window.instgrm.Embeds&&window.instgrm.Embeds.process();else{const o=document.createElement("script");o.id=n,o.src="https://www.instagram.com/embed.js",o.async=!0,document.body.appendChild(o)}},[i]);const s=i.split("?")[0].replace(/\/$/,"")+"/";return e.jsx("div",{className:"flex justify-center w-full my-8",children:e.jsx("div",{className:"w-full max-w-[540px] min-h-[500px] border border-border bg-muted/5 rounded-[var(--radius)] flex items-center justify-center relative overflow-hidden",children:e.jsx("blockquote",{className:"instagram-media","data-instgrm-permalink":s,"data-instgrm-version":"14",style:{background:"#FFF",border:"0",borderRadius:"var(--radius)",boxShadow:"0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15)",margin:"1px",maxWidth:"540px",minWidth:"326px",padding:"0",width:"99.375%"},children:e.jsx("a",{href:s,children:"View this post on Instagram"})})})})};function A({post:i,inlineRelated:s}){const{openLightbox:n}=x(),o=m.useMemo(()=>{if(!i.content)return{first:"",second:""};const t=g.sanitize(i.content,{ADD_TAGS:["iframe","blockquote"],ADD_ATTR:["allowfullscreen","allow","frameborder","target","data-instgrm-permalink","data-instgrm-version","data-social-embed","data-type","data-url","data-youtube-video","data-dnt"]}),r=t.split("</p>");if(r.length<6||!s||s.length===0)return{first:t,second:""};const a=5,c=r.slice(0,a).map(d=>d+"</p>").join(""),l=r.slice(a).map(d=>d+"</p>").join("");return{first:c,second:l}},[i.content,s]),u={replace:t=>{if(t.attribs&&t.attribs["data-social-embed"]==="true"){const{"data-type":r,"data-url":a}=t.attribs,c=r==="twitter"?a.replace("x.com","twitter.com"):a;if(r==="twitter")return e.jsx(h,{url:c});if(r==="instagram")return e.jsx(y,{url:c})}if(t.name==="iframe"||t.attribs&&t.attribs["data-youtube-video"]!==void 0){const r=t.name==="iframe"?t:t.children?.find(a=>a.name==="iframe");if(r&&r.attribs)return e.jsx("div",{className:"relative w-full aspect-video my-8 bg-black shadow-sm overflow-hidden rounded-[var(--radius)]",children:e.jsx("iframe",{...r.attribs,className:"absolute top-0 left-0 w-full h-full border-0",allowFullScreen:!0,loading:"lazy"})})}if(t.name==="img"){const{src:r,alt:a}=t.attribs;return e.jsx("img",{src:r,alt:a||"Article Image",className:"cursor-zoom-in hover:opacity-95 transition-opacity w-full h-auto rounded-[var(--radius)]",onClick:()=>n([{src:r,title:a}])})}if(t.name==="figure"&&t.attribs?.class?.includes("image-figure")){const r=t.children?.find(a=>a.name==="img");if(r){const{src:a,alt:c}=r.attribs,l=t.children?.find(f=>f.name==="figcaption");let d=l&&l.children?.length>0;return e.jsxs("figure",{className:"image-figure my-8 overflow-hidden border bg-muted/20 rounded-[var(--radius)]",children:[e.jsx("img",{src:a,alt:c||"Article Image",className:"w-full h-auto block m-0 cursor-zoom-in hover:opacity-95 transition-opacity",onClick:()=>n([{src:a,title:c}])}),d&&e.jsx("figcaption",{className:"text-center text-sm text-muted-foreground p-3 italic bg-background/50 border-t",children:b.domToReact(l.children)})]})}}}};return e.jsxs("div",{className:`prose prose-lg dark:prose-invert max-w-none \r
            prose-headings:font-serif prose-headings:font-bold \r
            prose-p:text-gray-700 dark:prose-p:text-gray-300 prose-p:leading-8 \r
            prose-a:text-primary hover:prose-a:opacity-80\r
            prose-img:rounded-[var(--radius)] mb-12`,children:[p(o.first,u),o.second&&e.jsx(w,{categoryName:i.category?.name,posts:s}),p(o.second||(o.first?"":cleanContent),u)]})}export{A as default};
