import{n as e,t}from"./createLucideIcon-x_DqbPgA.js";import{i as n,t as r}from"./useQuery-qKYvnzn0.js";import{t as i}from"./useMutation-C6r_dxL-.js";import{t as a}from"./book-open-sKRokCqo.js";import{t as o}from"./circle-check-big-BGRXsaKU.js";import{t as s}from"./clock-DIkpCm8X.js";import{t as c}from"./inbox-B7AQiXmx.js";import{t as l}from"./share-2-Bhe3xEV6.js";import{t as u}from"./client-BAPwymp0.js";var d=t(`library`,[[`path`,{d:`m16 6 4 14`,key:`ji33uf`}],[`path`,{d:`M12 6v14`,key:`1n7gus`}],[`path`,{d:`M8 8v12`,key:`1gg7y9`}],[`path`,{d:`M4 4v16`,key:`6qkkli`}]]),f=e();function p({role:e}){return(0,f.jsx)(`span`,{className:`text-xs font-medium px-2 py-0.5 rounded-full ${e===`editor`?`bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-300`:`bg-sky-100 text-sky-800 dark:bg-sky-900/30 dark:text-sky-300`}`,children:e})}function m({type:e}){return e===`collection`?(0,f.jsx)(d,{className:`w-5 h-5 text-purple-500`}):e===`tag`?(0,f.jsx)(a,{className:`w-5 h-5 text-green-500`}):(0,f.jsx)(l,{className:`w-5 h-5 text-sky-500`})}function h({share:e}){let t=n(),r=i({mutationFn:()=>u.post(`/api/v1/shares/${e.share_id}/accept`,{}),onSuccess:()=>{t.invalidateQueries({queryKey:[`shared-with-me`]})}}),a=e.share_type===`item`?`Item`:e.share_type===`collection`?`Collection`:`Tag`,c=e.item_id??e.collection_id??e.tag_id??`Unknown`;return(0,f.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 p-5 flex flex-col gap-3`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,f.jsx)(m,{type:e.share_type}),(0,f.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:a}),(0,f.jsx)(p,{role:e.role}),e.accepted?(0,f.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-xs text-green-600 dark:text-green-400`,children:[(0,f.jsx)(o,{className:`w-3.5 h-3.5`}),` Accepted`]}):(0,f.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400`,children:[(0,f.jsx)(s,{className:`w-3.5 h-3.5`}),` Pending`]})]}),(0,f.jsxs)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 font-mono truncate`,children:[`ID: `,c]}),(0,f.jsxs)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:[`Shared `,new Date(e.created_at).toLocaleDateString()]}),!e.accepted&&(0,f.jsx)(`button`,{onClick:()=>r.mutate(),disabled:r.isPending,className:`mt-1 w-full rounded-xl bg-[#0096C7] hover:bg-[#007BA8] disabled:opacity-60 text-white text-sm font-medium py-2 transition-colors`,children:r.isPending?`Accepting…`:`Accept`})]})}function g(){let{data:e,isLoading:t}=r({queryKey:[`shared-with-me`],queryFn:()=>u.get(`/api/v1/shares/shared-with-me`)});return(0,f.jsxs)(`div`,{className:`animate-fade-in max-w-4xl mx-auto px-4 md:px-6`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-3 mb-6`,children:[(0,f.jsx)(l,{className:`w-6 h-6 text-sky-600`}),(0,f.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-gray-100`,children:`Shared with Me`})]}),t?(0,f.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4`,children:[1,2,3].map(e=>(0,f.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 p-5 space-y-3`,children:[(0,f.jsx)(`div`,{className:`h-3 w-24 animate-pulse bg-gray-100 dark:bg-gray-800 rounded`}),(0,f.jsx)(`div`,{className:`h-4 w-full animate-pulse bg-gray-200 dark:bg-gray-700 rounded`}),(0,f.jsx)(`div`,{className:`h-3 w-20 animate-pulse bg-gray-100 dark:bg-gray-800 rounded`})]},e))}):!e||e.length===0?(0,f.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,f.jsx)(c,{className:`w-12 h-12 text-gray-300 dark:text-gray-600 mx-auto mb-4`}),(0,f.jsx)(`p`,{className:`text-gray-700 dark:text-gray-300 text-lg font-medium mb-1`,children:`No shared items`}),(0,f.jsx)(`p`,{className:`text-sm text-gray-400 dark:text-gray-500`,children:`Items shared with you by other users will appear here.`})]}):(0,f.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4`,children:e.map(e=>(0,f.jsx)(h,{share:e},e.share_id))})]})}export{g as default};