1import{j as e}from"./vendor-radix-miDeECL4.js";import{L,r as l}from"./vendor-react-BBjb5hzp.js";import{n as $,o as D,E,u as P,D as q,S as B,I as R,p as T,q as W,r as F,t as I,v as h,R as N,M as z,f as u}from"./index-DGrYQ9Ri.js";import{f as O}from"./format-CseJm2dS.js";import{u as Q,a as V,b as H}from"./useNewsletters-D5L_9x1C.js";import{S as U}from"./search-DMV43r0l.js";import{A as Z,a as v}from"./arrow-up-narrow-wide-BRENJ241.js";import"./vendor-charts-D_igoWGj.js";import"./vendor-supabase-DwR6CW6F.js";import"./vendor-query-CnkSJpBn.js";import"./en-US-BddybvhD.js";function G({newsletter:t,className:p}){const r=t.published_at||t.beehiiv_created_at||t.created_at,n=t.required_tier==="premium"||t.required_tier==="paid";return e.jsx(L,{to:`/newsletter/${t.id}`,className:p,children:e.jsxs("div",{className:"rounded-xl overflow-hidden h-full flex flex-col transition-all duration-200 hover:border-[#a855f7]/30 group",style:{background:"#0a0e18",border:"1px solid rgba(255,255,255,0.08)"},children:[e.jsx("div",{className:"h-[2px]",style:{background:n?"#ffd700":"#a855f7"}}),t.thumbnail_url&&e.jsx("div",{className:"aspect-video overflow-hidden rounded-t-xl",style:{background:"#080c14"},children:e.jsx("img",{src:t.thumbnail_url,alt:t.title,className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105 opacity-90 group-hover:opacity-100",loading:"lazy"})}),e.jsxs("div",{className:"p-4 flex flex-col flex-1 min-h-[180px]",children:[e.jsx("h3",{className:"font-semibold text-sm sm:text-base text-white leading-snug line-clamp-2 group-hover:text-[#a855f7] transition-colors min-h-[2.75rem]",children:t.title}),e.jsx("p",{className:"mt-3 text-[12px] text-white/40 line-clamp-2 leading-relaxed min-h-[2.25rem]",children:t.excerpt||""}),e.jsxs("div",{className:"mt-auto pt-3 flex flex-wrap items-center gap-2",children:[r&&e.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 text-[10px] font-mono rounded",style:{background:"rgba(255,255,255,0.04)",color:"rgba(255,255,255,0.5)",border:"1px solid rgba(255,255,255,0.06)"},children:[e.jsx($,{className:"h-3 w-3"}),O(new Date(r),"MMM d, yyyy")]}),n&&e.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 text-[10px] font-mono font-bold uppercase tracking-wider rounded",style:{background:"rgba(255,215,0,0.10)",color:"#ffd700",border:"1px solid rgba(255,215,0,0.25)"},children:[e.jsx(D,{className:"h-3 w-3"}),"Premium"]}),t.view_count!=null&&t.view_count>0&&e.jsxs("span",{className:"flex items-center gap-1 ml-auto text-[10px] font-mono text-white/30",children:[e.jsx(E,{className:"h-3 w-3"}),t.view_count]})]})]})]})})}function ne(){const{isAdmin:t,subscriptionTier:p}=P(),[r,n]=l.useState(""),[g,k]=l.useState("newest"),[d,f]=l.useState(12),[y,S]=l.useState("weekly"),{data:i,isLoading:m,refetch:C}=Q(100,g,{category:y}),{data:x}=V(),o=H(),c=l.useMemo(()=>{if(!i)return[];if(!r.trim())return i;const s=r.toLowerCase();return i.filter(a=>a.title.toLowerCase().includes(s)||a.excerpt?.toLowerCase().includes(s)||a.content?.toLowerCase().includes(s))},[i,r]),w=l.useMemo(()=>c.slice(0,d),[c,d]),_=d<c.length,b=async(s=!1)=>{try{const a=await o.mutateAsync({limit:100,clearFirst:s});a.synced===0?u.warning(`No newsletters synced. Received ${a.receivedFromBeehiiv} posts.`):u.success(`${s?"Fresh sync: ":""}Synced ${a.synced} newsletters`),C()}catch(a){u.error(a?.message||"Failed to sync newsletters")}},M=()=>{f(s=>s+12)};return e.jsxs(q,{children:[e.jsx(B,{title:"Newsletter Archive",description:"Browse Weekly Wizdom's crypto & stock market newsletters. Expert analysis, trade ideas, and market insights delivered weekly.",canonical:"/newsletters"}),e.jsxs("div",{className:"p-4 sm:p-6 space-y-6",children:[(x?.monthly_report??0)>0&&e.jsx("div",{className:"flex gap-2",children:["weekly","monthly_report"].map(s=>{const a=y===s,A=s==="weekly"?"Weekly":"Monthly Reports",j=s==="weekly"?x?.weekly:x?.monthly_report;return e.jsxs("button",{onClick:()=>{S(s),f(12)},className:`rounded-xl px-4 py-2 text-sm font-mono transition-colors ${a?"text-white":"text-white/60 hover:text-white"}`,style:{background:a?"rgba(255,255,255,0.08)":"rgba(255,255,255,0.03)",border:`1px solid ${a?"rgba(255,255,255,0.2)":"rgba(255,255,255,0.06)"}`},children:[A," ",typeof j=="number"&&e.jsxs("span",{className:"opacity-50",children:["(",j,")"]})]},s)})}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(U,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-white/50"}),e.jsx(R,{placeholder:"Search newsletters...",value:r,onChange:s=>n(s.target.value),className:"pl-10"})]}),e.jsxs(T,{value:g,onValueChange:s=>k(s),children:[e.jsx(W,{className:"w-full sm:w-40",children:e.jsx(F,{placeholder:"Sort by"})}),e.jsxs(I,{children:[e.jsx(h,{value:"newest",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"h-4 w-4"}),"Newest"]})}),e.jsx(h,{value:"oldest",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(v,{className:"h-4 w-4"}),"Oldest"]})}),e.jsx(h,{value:"title",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(v,{className:"h-4 w-4"}),"Title A-Z"]})})]})]}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>b(!1),disabled:o.isPending,className:"rounded-xl inline-flex items-center justify-center gap-2 px-4 py-2 text-sm font-mono text-white/70 hover:text-white transition-colors disabled:opacity-50",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.08)"},children:[e.jsx(N,{className:`h-4 w-4 ${o.isPending?"animate-spin":""}`}),"Sync"]}),e.jsxs("button",{onClick:()=>{confirm("This will delete all newsletters and re-sync from Beehiiv. Continue?")&&b(!0)},disabled:o.isPending,className:"rounded-xl inline-flex items-center justify-center gap-2 px-4 py-2 text-sm font-mono text-white/70 hover:text-white transition-colors disabled:opacity-50",style:{background:"rgba(255,255,255,0.04)",border:"1px solid #ff2e50"},children:[e.jsx(N,{className:`h-4 w-4 ${o.isPending?"animate-spin":""}`}
1),"Fresh Sync"]})]})]}),m&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[...Array(8)].map((s,a)=>e.jsx("div",{className:"h-64 animate-pulse bg-white/[0.02] rounded-xl",style:{background:"#0a0e18"}},a))}),!m&&w.length>0&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:w.map(s=>e.jsx(G,{newsletter:s},s.id))}),!m&&c.length===0&&e.jsxs("div",{className:"text-center py-12 rounded-xl",style:{background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.06)"},children:[e.jsx(z,{className:"h-12 w-12 text-white/30 mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-mono font-medium text-white mb-2",children:"No newsletters found"}),e.jsx("p",{className:"text-white/50 font-mono text-sm",children:r?"Try adjusting your search query":"Check back later for new content"})]}),_&&e.jsx("div",{className:"flex justify-center",children:e.jsx("button",{onClick:M,className:"rounded-xl inline-flex items-center justify-center px-6 py-2 text-sm font-mono text-white/70 hover:text-white transition-colors",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.08)"},children:"Load More"})})]})]})}export{ne as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.