import{a as e,n as t,r as n,t as r}from"./createLucideIcon-x_DqbPgA.js";import{t as i}from"./useQuery-qKYvnzn0.js";import{i as a}from"./use-items-CGLT3yWe.js";import{n as o}from"./chunk-UVKPFVEO-CKgCEGmW.js";import{t as s}from"./BookmarkCard-3EgrSMYF.js";import{t as c}from"./book-open-sKRokCqo.js";import{t as l}from"./clock-DIkpCm8X.js";import{t as u}from"./inbox-B7AQiXmx.js";import{t as d}from"./plus-BVh-Qbu5.js";import{t as f}from"./sticky-note-CtEl5XUr.js";import{t as p}from"./client-BAPwymp0.js";var m=r(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),h=e(n(),1),g=t();function _(){let{data:e,isLoading:t,isError:n}=i({queryKey:[`stats`],queryFn:()=>p.get(`/api/v1/stats`)}),{data:r,isLoading:_,isError:v}=a(),[y,b]=(0,h.useState)(8),x=r?.pages.flat()??[],S=x.slice(0,y),C=x.length>y;return n||v?(0,g.jsx)(`div`,{className:`max-w-7xl mx-auto px-4 py-6`,children:(0,g.jsx)(`div`,{className:`p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg text-red-600 dark:text-red-400 text-sm`,children:`Failed to load dashboard data. Please try refreshing the page.`})}):(0,g.jsxs)(`div`,{className:`animate-fade-in max-w-7xl mx-auto space-y-8`,children:[(0,g.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3 md:gap-4`,children:[{label:`Browse all`,value:e?.total_items,suffix:`items`,icon:c,link:`/knowledge`},{label:`Added this week`,value:e?.items_this_week,suffix:`new`,icon:u,link:`/knowledge`},{label:`Open notes`,value:e?.total_notes,suffix:`notes`,icon:f,link:`/notes`},{label:`Continue reading`,value:null,suffix:``,icon:l,link:`/reading-list`}].map(e=>{let n=e.icon;return(0,g.jsxs)(o,{to:e.link,className:`rounded-xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 p-4 md:p-5 hover:border-sky-200 dark:hover:border-sky-800 transition-colors duration-200 cursor-pointer`,children:[(0,g.jsx)(`div`,{className:`flex items-center gap-2.5 mb-3`,children:(0,g.jsx)(`div`,{className:`p-2 rounded-lg bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400`,children:(0,g.jsx)(n,{className:`h-4 w-4 md:h-5 md:w-5`})})}),(0,g.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e.label}),e.value!=null&&(0,g.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-0.5`,children:t?(0,g.jsx)(`span`,{className:`inline-block w-8 h-3 animate-pulse bg-gray-200 dark:bg-gray-800 rounded`}):`${e.value} ${e.suffix}`})]},e.label)})}),(0,g.jsxs)(`div`,{children:[(0,g.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,g.jsx)(`h2`,{className:`text-lg md:text-xl font-bold text-gray-900 dark:text-gray-100`,children:`Recent Items`}),(0,g.jsx)(o,{to:`/knowledge`,className:`text-sm text-[#0096C7] hover:text-[#0077A8] font-medium transition-colors cursor-pointer`,children:`View all →`})]}),_?(0,g.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4`,children:Array.from({length:4}).map((e,t)=>(0,g.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 overflow-hidden`,children:[(0,g.jsx)(`div`,{className:`aspect-video animate-pulse bg-gray-100 dark:bg-gray-800`}),(0,g.jsxs)(`div`,{className:`p-4 space-y-2`,children:[(0,g.jsx)(`div`,{className:`h-3 w-16 animate-pulse bg-gray-100 dark:bg-gray-800 rounded`}),(0,g.jsx)(`div`,{className:`h-4 w-full animate-pulse bg-gray-200 dark:bg-gray-700 rounded`}),(0,g.jsx)(`div`,{className:`h-3 w-3/4 animate-pulse bg-gray-100 dark:bg-gray-800 rounded`})]})]},t))}):S.length===0?(0,g.jsxs)(`div`,{className:`text-center py-16 rounded-2xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900`,children:[(0,g.jsx)(c,{className:`h-12 w-12 text-gray-300 dark:text-gray-600 mx-auto mb-4`}),(0,g.jsx)(`p`,{className:`text-gray-700 dark:text-gray-300 text-lg font-medium mb-1`,children:`No saved items`}),(0,g.jsx)(`p`,{className:`text-gray-400 dark:text-gray-500 text-sm mb-6`,children:`Save a URL or create a note to get started.`}),(0,g.jsxs)(o,{to:`/add`,className:`inline-flex items-center gap-2 px-5 py-2.5 bg-[#0096C7] text-white rounded-xl font-medium hover:bg-[#0077A8] hover:shadow-lg transition-all duration-200 cursor-pointer`,children:[(0,g.jsx)(d,{className:`h-4 w-4`}),`Add your first item`]})]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4`,children:S.map(e=>(0,g.jsx)(s,{item:e,variant:`grid`},e.id))}),C&&(0,g.jsx)(`div`,{className:`mt-6 text-center`,children:(0,g.jsxs)(`button`,{onClick:()=>b(e=>e+8),className:`inline-flex items-center gap-2 px-5 py-2.5 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 rounded-xl text-sm font-medium hover:shadow-md transition-all duration-200 cursor-pointer`,children:[(0,g.jsx)(m,{className:`h-4 w-4`}),`View more`]})})]})]})]})}export{_ as default};