// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0-or-later // @source: https://gitlab.com/soapbox-pub/ditto/-/tree/f0a3877c import{p as e,vr as t}from"./lucide-icons-BdRF0moN.js";import{t as n}from"./jsx-runtime-By8HlURe.js";import{a as r}from"./downloadFile-kpATXaJi.js";import{r as i,t as a}from"./lib-D6JeXc-v.js";var o=n();function s(e,t=200){if(!e)return``;let n=e.split(` `).map(e=>e.trim()).filter(Boolean);for(let e of n)if(!e.startsWith(`#`)&&!e.match(/^[-*_]{3,}$/)&&!e.startsWith("```")&&!e.match(/^[-*+]\s/)&&!e.match(/^\d+\.\s/)&&!e.startsWith(`>`)&&e.length>10){let n=e.replace(/\*\*(.*?)\*\*/g,`$1`).replace(/\*(.*?)\*/g,`$1`).replace(/`(.*?)`/g,`$1`).replace(/\[(.*?)\]\(.*?\)/g,`$1`).trim();if(n.length>t){let e=n.slice(0,t),r=e.lastIndexOf(` `);return`${r>t*.7?e.slice(0,r):e}...`}return n}let r=e.replace(/\n/g,` `).trim();return r.length>t?`${r.slice(0,t).trim()}...`:r}function c({event:n,preview:c=!0}){let l=n.tags.find(([e])=>e===`title`)?.[1],u=n.tags.find(([e])=>e===`d`)?.[1]??``,d=n.tags.filter(([e])=>e===`k`).map(([,e])=>e),f=n.tags.some(([e,t])=>e===`t`&&t===`shakespeare`),p=c?s(n.content,200):``,m=l||`NIP: ${u}`;return(0,o.jsxs)(`div`,{className:`mt-2 space-y-3`,children:[(0,o.jsx)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:(0,o.jsxs)(`div`,{className:`px-3.5 py-3 space-y-2`,children:[(0,o.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,o.jsx)(t,{className:`size-4 text-sky-600 dark:text-sky-400 shrink-0 mt-0.5`}),(0,o.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,o.jsx)(`span`,{className:`font-semibold text-sm leading-snug`,children:m}),c&&p&&(0,o.jsx)(`p`,{className:`text-[13px] text-muted-foreground mt-0.5 line-clamp-3 leading-relaxed`,children:p})]})]}),d.length>0&&(0,o.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[d.slice(0,c?6:d.length).map(e=>(0,o.jsxs)(`span`,{className:`text-[11px] font-mono text-muted-foreground`,children:[`Kind `,e]},e)),c&&d.length>6&&(0,o.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/50`,children:[`+`,d.length-6,` more`]})]}),f&&(0,o.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-full bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90`,onClick:e=>{e.stopPropagation(),r(`https://shakespeare.diy`)},children:[(0,o.jsx)(e,{className:`size-3`}),`Edit with Shakespeare`]})]})}),!c&&n.content&&(0,o.jsx)(`div`,{className:`rounded-2xl border border-border overflow-hidden px-4 py-4 sidebar:px-5 sidebar:py-5`,children:(0,o.jsx)(`div`,{className:`prose prose-sm max-w-none break-words text-foreground prose-headings:text-foreground prose-headings:font-bold prose-strong:text-foreground prose-a:text-primary prose-img:rounded-lg prose-pre:overflow-x-auto prose-pre:rounded-lg prose-pre:bg-muted prose-pre:text-foreground prose-code:text-[13px] prose-code:text-foreground prose-code:before:content-none prose-code:after:content-none prose-code:bg-muted prose-code:rounded prose-code:px-1.5 prose-code:py-0.5 prose-code:font-normal prose-li:marker:text-muted-foreground prose-blockquote:text-muted-foreground prose-blockquote:border-border prose-hr:border-border prose-th:text-foreground`,children:(0,o.jsx)(i,{rehypePlugins:[a],children:n.content})})})]})}export{c as CustomNipCard}; // @license-end