import{n as e}from"./createLucideIcon-x_DqbPgA.js";import{t}from"./useQuery-qKYvnzn0.js";import{l as n,n as r}from"./chunk-UVKPFVEO-CKgCEGmW.js";import{t as i}from"./arrow-left-7SrPmO8V.js";import{t as a}from"./BookmarkCard-3EgrSMYF.js";import{t as o}from"./hash-CV6VVf1c.js";import{t as s}from"./sparkles-67qznMb4.js";import{t as c}from"./client-BAPwymp0.js";var l=e();function u(){let{id:e}=n(),u=e??``,{data:d}=t({queryKey:[`tags`],queryFn:()=>c.get(`/api/v1/tags`)}),f=d?.find(e=>e.id===u),{data:p,isLoading:m}=t({queryKey:[`tag-items`,u],queryFn:()=>c.get(`/api/v1/tags/${u}/items?limit=100`),enabled:!!u}),{data:h}=t({queryKey:[`tag-merge-suggestions`],queryFn:()=>c.get(`/api/v1/tags/suggestions/merge`)}),g=h?.filter(e=>e.tag_a.id===u||e.tag_b.id===u).map(e=>e.tag_a.id===u?e.tag_b:e.tag_a)??[];return m?(0,l.jsx)(`div`,{className:`flex items-center justify-center h-64`,children:(0,l.jsx)(`div`,{className:`animate-pulse text-sky-600 text-lg`,children:`Loading...`})}):(0,l.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-6 animate-fade-in`,children:[(0,l.jsxs)(r,{to:`/tags`,className:`inline-flex items-center gap-1.5 text-sm text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 mb-6`,children:[(0,l.jsx)(i,{className:`w-4 h-4`}),`All Tags`]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3 mb-6`,children:[(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-xl flex items-center justify-center`,style:{backgroundColor:f?.color?`${f.color}20`:`rgb(14 165 233 / 0.1)`},children:(0,l.jsx)(o,{className:`w-5 h-5`,style:{color:f?.color||`#0ea5e9`}})}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-gray-100`,children:f?.name||`Tag`}),(0,l.jsxs)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:[p?.length??0,` item`,(p?.length??0)===1?``:`s`,f?.ai_generated&&(0,l.jsxs)(`span`,{className:`ml-2 inline-flex items-center gap-1 text-sky-500`,children:[(0,l.jsx)(s,{className:`w-3 h-3`}),` AI generated`]})]})]})]}),g.length>0&&(0,l.jsxs)(`div`,{className:`mb-6 p-4 rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800/50`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3`,children:`Similar Tags`}),(0,l.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:g.map(e=>(0,l.jsxs)(r,{to:`/tags/${e.id}`,className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-sky-50 dark:hover:bg-sky-900/20 hover:text-sky-600 transition-colors`,children:[(0,l.jsx)(o,{className:`w-3 h-3`}),e.name,(0,l.jsxs)(`span`,{className:`text-gray-400`,children:[`(`,e.usage_count,`)`]})]},e.id))})]}),p&&p.length>0?(0,l.jsx)(`div`,{className:`flex flex-col gap-3`,children:p.map(e=>(0,l.jsx)(a,{item:e,variant:`list`},e.id))}):(0,l.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,l.jsx)(o,{className:`h-12 w-12 text-gray-300 dark:text-gray-600 mx-auto mb-4`}),(0,l.jsx)(`p`,{className:`text-gray-700 dark:text-gray-300 text-lg font-medium mb-1`,children:`No items with this tag`}),(0,l.jsx)(`p`,{className:`text-sm text-gray-400 dark:text-gray-500`,children:`Items tagged with this tag will appear here`})]})]})}export{u as default};