import{a as e,n as t,r as n}from"./createLucideIcon-x_DqbPgA.js";import{i as r,t as i}from"./useQuery-qKYvnzn0.js";import{t as a}from"./useMutation-C6r_dxL-.js";import{n as o}from"./chunk-UVKPFVEO-CKgCEGmW.js";import{t as s}from"./highlighter-Bj3QdGbG.js";import{t as c}from"./search-vuVMIPX1.js";import{t as l}from"./trash-2-CeScAUrt.js";import{t as u}from"./client-BAPwymp0.js";import{n as d}from"./utils-BHgrqvTr.js";var f=e(n(),1),p=t(),m=[`yellow`,`green`,`blue`,`red`,`purple`],h={yellow:`bg-yellow-100 dark:bg-yellow-900/30 border-yellow-300 dark:border-yellow-700`,green:`bg-green-100 dark:bg-green-900/30 border-green-300 dark:border-green-700`,blue:`bg-blue-100 dark:bg-blue-900/30 border-blue-300 dark:border-blue-700`,red:`bg-red-100 dark:bg-red-900/30 border-red-300 dark:border-red-700`,purple:`bg-purple-100 dark:bg-purple-900/30 border-purple-300 dark:border-purple-700`};function g(){let e=r(),[t,n]=(0,f.useState)(``),[g,_]=(0,f.useState)(null),{data:v,isLoading:y}=i({queryKey:[`highlights`,t],queryFn:()=>t?u.get(`/api/v1/highlights/search?q=${encodeURIComponent(t)}`):u.get(`/api/v1/highlights`)}),b=a({mutationFn:e=>u.del(`/api/v1/highlights/${e}`),onSuccess:()=>e.invalidateQueries({queryKey:[`highlights`]})}),x=g?v?.filter(e=>e.color===g):v;return(0,p.jsxs)(`div`,{className:`animate-fade-in max-w-5xl mx-auto px-4`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-3 mb-6`,children:[(0,p.jsx)(s,{className:`w-6 h-6 text-sky-600`}),(0,p.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-gray-100`,children:`Highlights`})]}),(0,p.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3 mb-6`,children:[(0,p.jsxs)(`div`,{className:`relative flex-1`,children:[(0,p.jsx)(c,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400`}),(0,p.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),placeholder:`Search highlights...`,className:`w-full pl-10 pr-4 py-2 rounded-xl border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 text-sm`})]}),(0,p.jsx)(`div`,{className:`flex gap-1`,children:m.map(e=>(0,p.jsx)(`button`,{onClick:()=>_(g===e?null:e),className:`w-8 h-8 rounded-lg border-2 transition-all cursor-pointer ${h[e]} ${g===e?`ring-2 ring-sky-500 ring-offset-1 dark:ring-offset-gray-950`:``}`},e))})]}),y?(0,p.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:3}).map((e,t)=>(0,p.jsxs)(`div`,{className:`rounded-xl border border-gray-200 dark:border-gray-800 p-4 space-y-2`,children:[(0,p.jsx)(`div`,{className:`h-4 w-full animate-pulse bg-gray-200 dark:bg-gray-700 rounded`}),(0,p.jsx)(`div`,{className:`h-3 w-3/4 animate-pulse bg-gray-100 dark:bg-gray-800 rounded`}),(0,p.jsx)(`div`,{className:`h-3 w-16 animate-pulse bg-gray-100 dark:bg-gray-800 rounded`})]},t))}):x?.length?(0,p.jsx)(`div`,{className:`space-y-3`,children:x.map(e=>(0,p.jsxs)(`div`,{className:`rounded-xl border p-4 ${h[e.color]||h.yellow}`,children:[(0,p.jsx)(`p`,{className:`text-sm text-gray-900 dark:text-gray-100 leading-relaxed`,children:e.text}),e.note&&(0,p.jsx)(`p`,{className:`text-xs text-gray-600 dark:text-gray-300 mt-2 italic`,children:e.note}),(0,p.jsxs)(`div`,{className:`flex items-center justify-between mt-3`,children:[(0,p.jsx)(`span`,{className:`text-[10px] text-gray-500 dark:text-gray-400`,children:d(e.created_at)}),(0,p.jsx)(`button`,{onClick:()=>b.mutate(e.id),"aria-label":`Delete highlight`,className:`p-1 text-gray-400 hover:text-red-500 transition-colors cursor-pointer`,children:(0,p.jsx)(l,{className:`w-3.5 h-3.5`})})]})]},e.id))}):(0,p.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,p.jsx)(s,{className:`w-12 h-12 text-gray-300 dark:text-gray-600 mx-auto mb-4`}),(0,p.jsx)(`p`,{className:`text-gray-700 dark:text-gray-300 text-lg font-medium mb-1`,children:`No highlights`}),(0,p.jsx)(`p`,{className:`text-sm text-gray-400 dark:text-gray-500 mb-4`,children:`Select text on any saved item to create a highlight.`}),(0,p.jsx)(o,{to:`/knowledge`,className:`text-sm text-sky-600 hover:text-sky-700 font-medium`,children:`Browse your items`})]})]})}export{g as default};