1import{r as s,j as e}from"./react-vendor-DHsc3z8R.js";import{z as g,a as j,j as y}from"./index-D70tPUFV.js";import{A as N}from"./AdminHelpPanel-C8iCXHdJ.js";import{B as x}from"./book-open-C7BeMWwX.js";import{A as w}from"./arrow-right-DXfn4Mg0.js";import{S as v}from"./search-YZwZsmjz.js";import{C as k}from"./circle-check-big-DGuYSDiW.js";import{C as K}from"./circle-x-B27Qae86.js";import"./query-vendor-BpSM1h0G.js";import"./ui-vendor-CSbCjZRx.js";import"./motion-vendor-BtpmimIC.js";import"./info-DKvTITGs.js";import"./chevron-down-By7xSqX8.js";function V({token:A,onNavigate:u}){g(),j();const p={...y(),"Content-Type":"application/json"},[l,b]=s.useState([]),[h,c]=s.useState(!1),[r,f]=s.useState(""),[C,S]=s.useState(!1),[E,T]=s.useState(null),[B,L]=s.useState(null),[F,H]=s.useState({title:"",category:"",content:"",tierAccess:"free",active:!0}),d=async()=>{c(!0);try{const t=await fetch("/api/admin/knowledge-base",{headers:p});t.ok&&b(await t.json())}catch{}finally{c(!1)}};s.useEffect(()=>{d()},[]);const m=l.filter(t=>!r||t.title?.toLowerCase().includes(r.toLowerCase())||t.category?.toLowerCase().includes(r.toLowerCase()));return s.useEffect(()=>{d()},[]),e.jsxs("div",{className:"space-y-4",children:[e.jsx(N,{storageKey:"help-cap-kb",items:["This view shows how your knowledge base entries are distributed across access tiers for paying CapabilityAI users.","To add, edit, or bulk-manage entries, use the Knowledge Base tab in the main sidebar.","Set Tier Access on each entry in the main KB tab to control what Free vs Enterprise subscribers can search."]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 bg-secondary/30 border border-border/40 rounded-xl px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(x,{className:"w-4 h-4 text-accent-gold flex-shrink-0"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Add, edit, and bulk-manage entries in the ",e.jsx("span",{className:"text-foreground font-medium",children:"Knowledge Base"})," tab."]})]}),e.jsxs("button",{onClick:()=>u?.("kb"),"data-testid":"button-go-to-kb",className:"flex items-center gap-1.5 text-sm font-medium text-accent-gold-ink hover:text-accent-gold-ink whitespace-nowrap transition-colors flex-shrink-0",children:["Go to Knowledge Base ",e.jsx(w,{className:"w-3.5 h-3.5"})]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[{label:"All Tiers",value:"free",color:"border-border/50 text-muted-foreground"},{label:"Starter+",value:"starter",color:"border-info/40 text-info"},{label:"Professional+",value:"professional",color:"border-accent-gold/40 text-accent-gold"},{label:"Enterprise Only",value:"enterprise",color:"border-purple-500/40 text-purple-700"}].map(({label:t,value:a,color:i})=>{const o=l.filter(n=>(n.tierAccess==="both"||!n.tierAccess?"free":n.tierAccess)===a&&n.active).length;return e.jsxs("div",{className:`bg-secondary/20 border rounded-xl p-4 text-center ${i}`,children:[e.jsx("p",{className:"text-2xl font-bold",children:o}),e.jsx("p",{className:"text-xs mt-1 opacity-80",children:t})]},a)})}),e.jsxs("div",{className:"relative",children:[e.jsx(v,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx("input",{value:r,onChange:t=>f(t.target.value),placeholder:"Search by title or category...",className:"w-full bg-secondary/50 border border-border/50 rounded-lg pl-9 pr-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring/50"})]}),h?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"w-6 h-6 border-2 border-accent-gold/30 border-t-accent-gold rounded-full animate-spin"})}):m.length===0?e.jsxs("div",{className:"text-center py-16 text-muted-foreground border border-dashed border-border/40 rounded-xl",children:[e.jsx(x,{className:"w-10 h-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"font-medium",children:r?"No entries match your search":"No knowledge base entries yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Add entries in the main Knowledge Base tab"})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/40 text-left text-muted-foreground text-xs",children:[e.jsx("th",{className:"pb-3 pr-4 font-medium",children:"Title"}),e.jsx("th",{className:"pb-3 pr-4 font-medium",children:"Category"}),e.jsx("th",{className:"pb-3 pr-4 font-medium",children:"Tier Access"}),e.jsx("th",{className:"pb-3 font-medium",children:"Active"})]})}),e.jsx("tbody",{className:"divide-y divide-border/20",children:m.map(t=>{const a={free:"bg-secondary/50 text-foreground",both:"bg-secondary/50 text-foreground",starter:"bg-info/20 text-info-ink",professional:"bg-accent-gold/20 text-accent-gold-ink",enterprise:"bg-purple-500/20 text-purple-700"},i={free:"All Tiers",both:"All Tiers",starter:"Starter+",professional:"Professional+",enterprise:"Enterprise Only"},o=t.tierAccess||"free";return e.jsxs("tr",{"data-testid":`cap-kb-row-${t.id}`,className:"hover:bg-secondary/20",children:[e.jsx("td",{className:"py-3 pr-4 max-w-xs",children:e.jsx("p",{className:"font-medium text-foreground truncate",children:t.title})}),e.jsx("td",{className:"py-3 pr-4 text-xs text-muted-foreground",children:t.category}),e.jsx("td",{className:"py-3 pr-4",children:e.jsx("span",{className:`text-xs rounded-full px-2 py-0.5 font-medium ${a[o]||a.both}`,children:i[o]||o})}),e.jsx("td",{className:"py-3",children:t.active?e.jsx(k,{className:"w-4 h-4 text-success"}):e.jsx(K,{className:"w-4 h-4 text-destructive"})})]},t.id)})})]})})]})}export{V as KnowledgeBaseTab};
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.