// @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{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{qi as t}from"./lucide-icons-BdRF0moN.js";import{t as n}from"./jsx-runtime-By8HlURe.js";import{t as r}from"./dist-DQ82bf9M.js";import{u as i}from"./esm-CRVqHnq2.js";import{t as a}from"./useQuery-rCAlChE8.js";import{r as o}from"./sanitizeUrl-Bk5f35GN.js";import{o as s,r as c}from"./react-intl-eZirkCBg.js";import{l,t as u}from"./useCurrentUser-C6OJJlWo.js";import{n as d}from"./useFollowActions-cve70R08.js";import{n as f,o as p,r as m,t as h}from"./avatar--oX_CTF4.js";import{n as g}from"./chunk-62JRHF6Z-yJW_vgm4.js";import{n as _}from"./CustomEmoji-DRcU63lJ.js";import{t as v}from"./skeleton-CVls4GW9.js";import{t as y}from"./timeAgo-BXjjbyXp.js";import{n as b}from"./imeta-83Lqxs5-.js";import{t as x}from"./DecryptedImage-DLbW5kmn.js";import{s as S}from"./index-CYEZWNq6.js";var C=e(t(),1),w=n();function T(e){for(let t of b(e)){let e=o(t.url);if(e)return{url:e,alt:t.alt,encryption:t.encryption}}}function E(){let{nostr:e}=r(),{user:t}=u(),{data:n}=d(),{data:i}=S(),o=n?.pubkeys,s=t&&o?.length?o:i,{data:l,isLoading:f}=a({queryKey:[`widget-photo`,t?`follows`:`curator`],queryFn:async()=>(await e.query([{kinds:[20],limit:1,...s?{authors:s}:{}}]))[0]??null,staleTime:5*6e4,enabled:t?o!==void 0:i!==void 0});return f?(0,w.jsxs)(`div`,{className:`space-y-2 p-1`,children:[(0,w.jsx)(v,{className:`w-full aspect-[4/3] rounded-lg`}),(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(v,{className:`size-5 rounded-full`}),(0,w.jsx)(v,{className:`h-3 w-24`})]})]}):l?(0,w.jsx)(D,{event:l}):(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground p-1`,children:(0,w.jsx)(c,{id:`widgets.photo.empty`,defaultMessage:`No photos yet.`})})}function D({event:e}){let t=s(),n=l(e.pubkey),r=n.data?.metadata,a=p(r),o=r?.name||r?.display_name||t.formatMessage({id:`common.anonymous`,defaultMessage:`Anonymous`}),c=(0,C.useMemo)(()=>i.neventEncode({id:e.id,author:e.pubkey}),[e]),u=(0,C.useMemo)(()=>T(e.tags),[e.tags]),d=e.content?.trim();return u?(0,w.jsxs)(g,{to:`/${c}`,className:`block group`,children:[(0,w.jsx)(`div`,{className:`rounded-lg overflow-hidden bg-secondary/30`,children:(0,w.jsx)(x,{url:u.url,encryption:u.encryption,alt:u.alt??d??t.formatMessage({id:`widgets.photo.alt`,defaultMessage:`Photo`}),className:`w-full object-cover max-h-[220px] group-hover:scale-[1.02] transition-transform duration-300`,loading:`lazy`,decoding:`async`})}),(0,w.jsxs)(`div`,{className:`mt-2 px-0.5 space-y-1`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,w.jsxs)(h,{shape:a,className:`size-4`,children:[(0,w.jsx)(m,{src:r?.picture,alt:o}),(0,w.jsx)(f,{className:`bg-primary/20 text-primary text-[8px]`,children:o[0]?.toUpperCase()})]}),(0,w.jsx)(`span`,{className:`text-xs font-semibold truncate`,children:n.data?.event?(0,w.jsx)(_,{tags:n.data.event.tags,children:o}):o}),(0,w.jsxs)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:[`· `,y(e.created_at)]})]}),d&&(0,w.jsx)(`p`,{className:`text-[13px] text-muted-foreground leading-snug line-clamp-2`,children:d})]})]}):null}export{E as PhotoWidget};
// @license-end
