// @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{H as t,P as n,_n as r,cr as i,qi as a}from"./lucide-icons-BdRF0moN.js";import{t as o}from"./jsx-runtime-By8HlURe.js";import{t as s}from"./useAppContext-Ughdk2-Z.js";import{t as c}from"./utils-BFSTDHdM.js";import{t as l}from"./skeleton-CVls4GW9.js";import{t as u}from"./useInView-DAJQSIvc.js";import{r as d}from"./NoteCard-COwLfrJJ.js";import{t as f}from"./usePageRefresh-BuJEOs2u.js";import{r as p}from"./useTrending-DsL3v2RN.js";import{C as m,w as h,y as g}from"./index-CYEZWNq6.js";import{t as _}from"./ClientUsersChart-D834ctTi.js";import{t as v}from"./PageHeader-CMi4aeE4.js";var y=e(a(),1),b=o();function x(){let{config:e}=s();h({title:`Trends | ${e.appName}`,description:`Trending hashtags and posts on Nostr`});let[a,o]=(0,y.useState)(`hot`),c=f((0,y.useMemo)(()=>[[`client-counts`],[`infinite-sorted-posts`,a]],[a])),{data:l,isPending:x,isLoading:T,fetchNextPage:E,hasNextPage:D,isFetchingNextPage:O}=p(a,!0),{isMuted:k}=g(),A=(0,y.useMemo)(()=>{let e=new Set;return l?.pages.flat().filter(t=>!(e.has(t.id)||(e.add(t.id),k(t))))??[]},[l?.pages,k]),{ref:j,inView:M}=u({threshold:0,rootMargin:`400px`});return(0,y.useEffect)(()=>{M&&D&&!O&&E()},[M,D,O,E]),(0,b.jsxs)(`main`,{className:``,children:[(0,b.jsx)(v,{title:`Trends`,icon:(0,b.jsx)(n,{className:`size-5`})}),(0,b.jsxs)(m,{onRefresh:c,children:[(0,b.jsx)(`div`,{className:`p-4`,children:(0,b.jsx)(_,{})}),(0,b.jsxs)(`div`,{className:`flex border-b border-border`,children:[(0,b.jsx)(S,{icon:(0,b.jsx)(i,{className:`size-4`}),label:`Hot`,active:a===`hot`,onClick:()=>o(`hot`)}),(0,b.jsx)(S,{icon:(0,b.jsx)(n,{className:`size-4`}),label:`Rising`,active:a===`rising`,onClick:()=>o(`rising`)}),(0,b.jsx)(S,{icon:(0,b.jsx)(t,{className:`size-4`}),label:`Controversial`,active:a===`controversial`,onClick:()=>o(`controversial`)})]}),(x||T)&&A.length===0?(0,b.jsx)(`div`,{className:`divide-y divide-border`,children:Array.from({length:5}).map((e,t)=>(0,b.jsx)(w,{},t))}):A.length>0?(0,b.jsxs)(`div`,{children:[A.map(e=>(0,b.jsx)(d,{event:e},e.id)),D&&(0,b.jsx)(`div`,{ref:j,className:`py-4`,children:O&&(0,b.jsx)(`div`,{className:`flex justify-center`,children:(0,b.jsx)(r,{className:`size-5 animate-spin text-muted-foreground`})})})]}):(0,b.jsx)(C,{message:`No ${a} posts right now.`})]})]})}function S({icon:e,label:t,active:n,onClick:r}){return(0,b.jsxs)(`button`,{onClick:r,className:c(`flex-1 py-2.5 flex items-center justify-center gap-1.5 text-sm font-medium transition-colors relative hover:bg-secondary/40`,n?`text-foreground`:`text-muted-foreground`),children:[e,t,n&&(0,b.jsx)(`div`,{className:`absolute bottom-0 left-1/2 -translate-x-1/2 w-12 h-0.5 rounded-full bg-primary`})]})}function C({message:e}){return(0,b.jsx)(`div`,{className:`py-16 px-8 text-center`,children:(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:e})})}function w(){return(0,b.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(l,{className:`size-11 rounded-full shrink-0`}),(0,b.jsxs)(`div`,{className:`min-w-0 space-y-1.5`,children:[(0,b.jsx)(l,{className:`h-4 w-28`}),(0,b.jsx)(l,{className:`h-3 w-36`})]})]}),(0,b.jsxs)(`div`,{className:`mt-2 space-y-1.5`,children:[(0,b.jsx)(l,{className:`h-4 w-full`}),(0,b.jsx)(l,{className:`h-4 w-4/5`})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-6 mt-3 -ml-2`,children:[(0,b.jsx)(l,{className:`h-4 w-8`}),(0,b.jsx)(l,{className:`h-4 w-8`}),(0,b.jsx)(l,{className:`h-4 w-8`})]})]})}export{x as TrendsPage};
// @license-end
