1import{k0 as T,j$ as w,r as n,j as e,L as N}from"./index-Cz_StzOF.js";import{u as C}from"./useSuspenseQuery-C53WRaHC.js";import{A}from"./alert-error-mom43jPu.js";import{B as I}from"./badge-DNloBTC5.js";import{B as r}from"./button-DLLlTj8W.js";import{T as S,a as k,b as l,c as o,d as E,e as t}from"./table-BPvFjWXk.js";import{A as M}from"./admin-filter-bar-Dd_-CSon.js";import{A as z}from"./admin-page-header-Bn0eJ8kD.js";import{d as B,m as D}from"./tag-write.actions-BttR1Xz2.js";function L(){const{data:c}=C(T()),x=w(),[f,i]=n.useState(null),[h,j]=n.useState(null),[m,u]=n.useState(null),[d,g]=n.useState(""),b=async(s,a)=>{if(window.confirm(`Delete tag "${a}"? This cannot be undone.`)){j(s),i(null);try{await B({data:{id:s}}),await x.invalidate()}catch(p){i(p instanceof Error?p.message:"Failed to delete tag")}finally{j(null)}}},v=async s=>{if(d){i(null);try{await D({data:{sourceTagId:s,targetTagId:d}}),u(null),g(""),await x.invalidate()}catch(a){i(a instanceof Error?a.message:"Merge failed")}}},y=s=>c.filter(a=>a.id!==s);return e.jsxs("section",{className:"px-4 py-8",children:[e.jsx(z,{actions:e.jsx(M,{to:"/admin/website/tags/new",children:"New Tag"}),eyebrow:"Admin",title:"Tags"}),e.jsx(A,{error:f}),e.jsx("div",{className:"overflow-hidden rounded-xl border shadow-sm",children:e.jsxs(S,{children:[e.jsx(k,{children:e.jsxs(l,{children:[e.jsx(o,{children:"Name"}),e.jsx(o,{children:"Slug"}),e.jsx(o,{className:"w-24",children:"In use"}),e.jsx(o,{className:"w-48 text-right",children:"Actions"})]})}),e.jsxs(E,{children:[c.length===0&&e.jsx(l,{children:e.jsx(t,{className:"py-8 text-center text-muted-foreground",colSpan:4,children:"No tags yet. Add one to get started."})}),c.map(s=>e.jsxs(n.Fragment,{children:[e.jsxs(l,{children:[e.jsx(t,{className:"font-medium",children:s.name}),e.jsx(t,{className:"font-mono text-muted-foreground text-sm",children:s.slug}),e.jsx(t,{children:e.jsx(I,{variant:s.usageCount>0?"default":"secondary",children:s.usageCount})}),e.jsx(t,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(r,{asChild:!0,size:"sm",variant:"outline",children:e.jsx(N,{params:{tagId:s.id},to:"/admin/website/tags/$tagId",children:"Edit"})}),e.jsx(r,{disabled:m===s.id,onClick:()=>u(m===s.id?null:s.id),size:"sm",type:"button",variant:"outline",children:"Merge"}),e.jsx(r,{disabled:s.usageCount>0||h===s.id,onClick:()=>b(s.id,s.name),size:"sm",title:s.usageCount>0?"Remove this tag from all content first":void 0,type:"button",variant:"destructive",children:h===s.id?"â¦":"Delete"})]})})]}),m===s.id&&e.jsx(l,{children:e.jsx(t,{className:"bg-muted/40 pt-2 pb-3",colSpan:4,children:e.jsxs("div",{className:"flex items-center gap-3 pl-1",children:[e.jsxs("span",{className:"text-muted-foreground text-sm",children:['Merge "',s.name,'" into:']}),e.jsxs("select",{className:"rounded-md border border-input bg-background px-3 py-1 text-sm",onChange:a=>g(a.target.value),value:d,children:[e.jsx("option",{value:"",children:"Select target tagâ¦"}),y(s.id).map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]}),e.jsx(r,{disabled:!d,onClick:()=>v(s.id),size:"sm",type:"button",variant:"destructive",children:"Confirm Merge"}),e.jsx(r,{onClick:()=>{u(null),g("")},size:"sm",type:"button",variant:"ghost",children:"Cancel"})]})})},`${s.id}-merge`)]},s.id))]})]})})]})}function K(){return e.jsx(L,{})}export{K as component};
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.