// @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{J as e,Sr as t}from"./lucide-icons-BdRF0moN.js";import{t as n}from"./jsx-runtime-By8HlURe.js";import{r}from"./react-intl-eZirkCBg.js";import{n as i}from"./chunk-62JRHF6Z-yJW_vgm4.js";import{t as a}from"./skeleton-CVls4GW9.js";import{t as o}from"./wikimedia-CCPyM-j2.js";import{t as s}from"./useWikipediaFeatured-CTWYChC1.js";var c=n();function l(){let{data:n,isLoading:l,isError:u}=s();if(l)return(0,c.jsxs)(`div`,{className:`space-y-3 p-1`,children:[(0,c.jsx)(a,{className:`w-full aspect-[16/9] rounded-lg`}),(0,c.jsx)(a,{className:`h-4 w-3/4`}),(0,c.jsx)(a,{className:`h-3 w-full`}),(0,c.jsx)(a,{className:`h-3 w-4/5`})]});if(u)return(0,c.jsx)(`p`,{className:`text-sm text-muted-foreground p-1`,children:(0,c.jsx)(r,{id:`widgets.wikipedia.loadFailed`,defaultMessage:`Failed to load featured article.`})});let d=n?.tfa;if(!d)return(0,c.jsx)(`p`,{className:`text-sm text-muted-foreground p-1`,children:(0,c.jsx)(r,{id:`widgets.wikipedia.empty`,defaultMessage:`No featured article today.`})});let f=o(d.thumbnail?.source,500,d.originalimage?.width),p=d.extract.length>200?d.extract.slice(0,200)+`...`:d.extract,m=d.normalizedtitle??d.titles?.normalized??d.title,h=d.content_urls.desktop.page;return(0,c.jsxs)(i,{to:`/i/${encodeURIComponent(h)}`,className:`block w-full text-left group`,children:[f&&(0,c.jsx)(`div`,{className:`relative aspect-[16/9] rounded-lg overflow-hidden bg-gradient-to-br from-amber-500/10 to-orange-500/10 mb-2`,children:(0,c.jsx)(`img`,{src:f,alt:m,className:`w-full h-full object-cover`,loading:`lazy`,decoding:`async`})}),(0,c.jsxs)(`div`,{className:`space-y-1 px-0.5`,children:[(0,c.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,c.jsx)(e,{className:`size-3 text-amber-500 shrink-0 mt-0.5`}),(0,c.jsx)(`h3`,{className:`text-sm font-bold leading-snug group-hover:text-primary transition-colors line-clamp-2`,children:m})]}),(0,c.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed line-clamp-3`,children:p}),(0,c.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/70 pt-0.5`,children:[(0,c.jsx)(t,{className:`size-2.5`}),(0,c.jsx)(`span`,{children:`Wikipedia`})]})]})]})}export{l as WikipediaWidget};
// @license-end
