1import{p as Xe,v as P,l as G,r as l,j as e}from"./vendor-react-BBWSWmGs.js";import{u as p}from"./vendor-utils-Lnjz4V8o.js";import{u as Ss,D as _s}from"./data-table-pagination-BdIGt_6F.js";import{a as _,n as ks,P as Be,C as x,b as m,f as ne,B as i,k as d,a1 as Es,a2 as Ts,a3 as le,a4 as ie,I as ce,i as N,c as R,d as q,e as z,z as w,L as c,M as He,r as de,v as oe,w as xe,x as me,y as ue,F as he}from"./index-wOQ1qYka.js";import{P as Fs}from"./progress-zwpE394N.js";import{S as $,a as M,b as K,c as Q,d as y}from"./select-9eRL3UR3.js";import{T as Ge,a as Je,b as U,c as h,d as Ve,e as j}from"./table-BYUnt8dq.js";import{S as Ps}from"./switch-BqXTBt_n.js";import{S as je}from"./stat-card-BHeH-Kxk.js";import{P as b}from"./permission-gate-DD1KPYu7.js";import{S as pe}from"./status-badge-YWFfN_UH.js";import{a as As,S as Ds}from"./upload-constants-BDBRRcjk.js";import{u as Is,a as Ls,b as Os,c as Rs,d as qs}from"./use-evidence-0YxcFvPH.js";import{f as zs}from"./framework-labels-DuVwxSy_.js";import{R as $s,a6 as S,j as ge,d as Ms,F as B,T as H,aL as We,a7 as Ks,b5 as Qs,c as Ye,aU as ve,ah as Ze,L as F,aO as Us,y as Bs,$ as Hs,b6 as Gs,b7 as Js,aQ as fe}from"./vendor-icons-DVMne4jX.js";import"./vendor-ui-BreKxShT.js";import"./use-permission-Db5SbPUX.js";async function Vs(){const{data:t}=await _.get("/evidence-schedules/status");return t}async function Ws(){const{data:t}=await _.get("/evidence-schedules/");return t}async function Ys(t){const{data:r}=await _.post("/evidence-schedules/",t);return r}async function Zs(t,r){const{data:o}=await _.put(`/evidence-schedules/${t}`,r);return o}async function Xs(t){await _.delete(`/evidence-schedules/${t}`)}async function et(t){const{data:r}=await _.post(`/evidence-schedules/${t}/run`);return r}function st(){return Xe({queryKey:["evidence-schedules-status"],queryFn:()=>Vs()})}function tt(){return Xe({queryKey:["evidence-schedules"],queryFn:async()=>(await Ws()).items||[]})}function at(){const t=P();return G({mutationFn:r=>Ys(r),onSuccess:()=>{t.invalidateQueries({queryKey:["evidence-schedules"]}),t.invalidateQueries({queryKey:["evidence-schedules-status"]}),p.success("Collection schedule created")},onError:()=>{p.error("Failed to create schedule")}})}function rt(){const t=P();return G({mutationFn:({id:r,body:o})=>Zs(r,o),onSuccess:()=>{t.invalidateQueries({queryKey:["evidence-schedules"]}),t.invalidateQueries({queryKey:["evidence-schedules-status"]}),p.success("Schedule updated")},onError:()=>{p.error("Failed to update schedule")}})}function nt(){const t=P();return G({mutationFn:r=>Xs(r),onSuccess:()=>{t.invalidateQueries({queryKey:["evidence-schedules"]}),t.invalidateQueries({queryKey:["evidence-schedules-status"]}),p.success("Schedule deleted")},onError:()=>{p.error("Failed to delete schedule")}})}function lt(){const t=P();return G({mutationFn:r=>et(r),onSuccess:r=>{t.invalidateQueries({queryKey:["evidence-schedules"]}),t.invalidateQueries({queryKey:["evidence-schedules-status"]}),p.success(`Scan complete: ${r.findings_count} findings`)},onError:()=>{p.error("Scan failed")}})}function Ne(t){if(!t)return{label:"Unknown",color:"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-300"};const r=Math.floor((Date.now()-new Date(t).getTime())/(1e3*60*60*24));return r<=90?{label:"Fresh",color:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-300"}:r<=180?{label:"Aging",color:"bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-300"}:{label:"Stale",color:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-300"}}const it=[{value:"aws",label:"AWS"},{value:"azure",label:"Azure"},{value:"okta",label:"Okta"},{value:"google_workspace",label:"Google Workspace"}],ct=[{value:"promptfoo",label:"promptfoo"},{value:"deepeval",label:"DeepEval"},{value:"other",label:"Other (auto-detect)"}];function _t(){var ze,$e,Me,Ke,Qe,Ue;const[t,r]=l.useState(""),[o,es]=l.useState(null),[ss,ts]=l.useState("overview"),[as,A]=l.useState(!1),[D,ye]=l.useState(null),[I,be]=l.useState(""),[Ce,we]=l.useState(""),[Se,_e]=l.useState("document"),[rs,T]=l.useState(!1),[L,ke]=l.useState(""),[Ee,Te]=l.useState("24"),[a,O]=l.useState(null),Fe=ks(),J=zs(Fe),{data:g=[],isError:ns,error:ls,isFetching:is,refetch:cs}=Is(Fe),{data:Pe=[],isError:ds,error:os,isFetching:xs,refetch:ms}=Ls(),V=Os(),W=Rs(),{data:u,isLoading:us,error:hs}=qs(),{data:v}=st(),{data:Ae=[]}=tt(),Y=at(),js=rt(),De=nt(),Z=lt(),[k,X]=l.useState(null),ps=P(),[ee,Ie]=l.useState(""),[se,gs]=l.useState("promptfoo"),[Le,Oe]=l.useState(!1),[E,vs]=l.useState(null);async function fs(){let s;try{s=JSON.parse(ee)}catch{p.error("Not valid JSON â paste the raw results file exported by your red-team tool");return}Oe(!0);try{const{data:n}=await _.post("/evidence/redteam-import",{tool:se==="other"?void 0:se,results:s});vs(n.summary),ps.invalidateQueries({queryKey:["evidence"]}),p.success(`Imported ${n.summary.total} red-team tests (${n.summary.failed} failed) as vault evidence`)}catch(n){p.error(ne(n,"Failed to import red-team results"))}finally{Oe(!1)}}function te(s){ye(s??null),be(""),we(""),_e("document"),X(null),A(!0)}function Ns(){if(!I.trim())return;const s={title:I.trim(),description:Ce.trim()||void 0,evidence_type:Se,control_id:D||void 0,file:k||void 0};V.mutate(s,{onSuccess:()=>{A(!1),X(null)}})}function ys(){L&&Y.mutate({integration_type:L,interval_hours:parseInt(Ee,10)||24,enabled:!0},{onSuccess:()=>{T(!1),ke(""),Te("24")}})}const f=Ss({key:"evCtrl"});l.useEffect(()=>{f.resetPage()},[t]);const ae=g.filter(s=>{var n,C;return((n=s.title)==null?void 0:n.toLowerCase().includes(t.toLowerCase()))||((C=s.code)==null?void 0:C.toLowerCase().includes(t.toLowerCase()))}),bs=ae.slice((f.page-1)*f.pageSize,f.page*f.pageSize);function Cs(s){s!=="auto-collection"&&ts(s)}const Re=o?Pe.filter(s=>s.control_id===o):[],re=g.length,qe=g.filter(s=>s.evidence_count>0).length,ws=re>0?Math.round(qe/re*100):0;return(ns||ds)&&!is&&!xs?e.jsxs("div",{className:"space-y-6",children:[e.jsx(Be,{title:"Evidence Management",description:`Map evidence to ${J} controls â evidence is reusable across frameworks where controls overlap`}),e.jsx(x,{children:e.jsxs(m,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-destructive font-medium",children:ne(ls??os,"Failed to load evidence data")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Please check your connection and try again."}),e.jsx(i,{variant:"outline",className:"mt-4",onClick:()=>{cs(),ms()},children:"Retry"})]})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(Be,{title:"Evidence Management",description:`Map evidence to ${J} controls â evidence is reusable across frameworks where controls overlap`,actions:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(b,{permission:"evidence.manage",children:e.jsxs(i,{variant:"outline",disabled:!0,title:"Coming soon",children:[e.jsx($s,{className:"mr-2 h-4 w-4"}),"Auto-Collect",e.jsx(d,{variant:"secondary",className:"ml-2 text-[10px] px-1.5 py-0",children:"Soon"})]})}),e.jsx(b,{permission:"evidence.create",children:e.jsxs(i,{onClick:()=>te(),children:[e.jsx(S,{className:"mr-2 h-4 w-4"}),"Add Evidence"]})})]})}),e.jsxs("div",{className:"grid gap-3.5 grid-cols-2 lg:grid-cols-3",children:[e.jsx(je,{icon:ge,tint:"success",label:"Evidence Coverage",value:ws,unit:"%",delta:"Of tracked controls"}),e.jsx(je,{icon:Ms,tint:"brand",label:"Controls with Evidence",value:`${qe}/${re}`,delta:"Fully supported"}),e.jsx(je,{icon:B,tint:"accent",label:"Total Evidence Items",value:Pe.length,delta:"In library"})]}),e.jsxs(Es,{value:ss,onValueChange:Cs,children:[e.jsxs(Ts,{children:[e.jsxs(le,{value:"overview",children:[e.jsx(B,{className:"mr-2 h-4 w-4"}),J," controls"]}
1),e.jsxs(le,{value:"gaps",children:[e.jsx(H,{className:"mr-2 h-4 w-4"}),"Evidence Gaps",u&&u.gap_count>0&&e.jsx(d,{variant:"destructive",className:"ml-2 text-[10px] px-1.5 py-0",children:u.gap_count})]}),e.jsxs(le,{value:"auto-collection",disabled:!0,title:"Coming soon",className:"cursor-not-allowed opacity-60 data-[state=active]:bg-transparent",children:[e.jsx(We,{className:"mr-2 h-4 w-4"}),"Auto-Collection",e.jsx(d,{variant:"secondary",className:"ml-2 text-[10px] px-1.5 py-0",children:"Coming soon"})]})]}),e.jsx(ie,{value:"overview",className:"mt-6",children:e.jsxs("div",{className:"grid gap-6 lg:grid-cols-12",children:[e.jsxs("div",{className:"lg:col-span-5 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ks,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(ce,{placeholder:"Search controls...",value:t,onChange:s=>r(s.target.value),className:"pl-9"})]}),e.jsx("div",{className:"space-y-2",children:bs.map(s=>e.jsx(x,{className:N("cursor-pointer transition-all hover:shadow-md",o===s.id&&"border-primary ring-1 ring-primary"),onClick:()=>es(s.id),children:e.jsx(m,{className:"p-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5",children:s.evidence_count>0?e.jsx(ge,{className:"h-5 w-5 text-green-500"}):e.jsx(H,{className:"h-5 w-5 text-amber-500"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(d,{variant:"outline",className:"text-[10px] font-mono",children:s.code}),e.jsx(pe,{status:s.implementation_status})]}),e.jsx("h4",{className:"mt-1 text-sm font-medium",children:s.title}),s.description&&e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground line-clamp-2",children:s.description}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Qs,{className:"h-3 w-3"}),e.jsxs("span",{children:[s.evidence_count," evidence item(s)"]})]})]})]})})},s.id))}),ae.length>0?e.jsx(_s,{page:f.page,pageSize:f.pageSize,total:ae.length,onPageChange:f.setPage,onPageSizeChange:f.setPageSize,itemLabel:"controls"}):null]}),e.jsx("div",{className:"lg:col-span-7",children:o?e.jsxs(x,{children:[e.jsx(R,{children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs(q,{className:"text-base",children:["Evidence for ",(ze=g.find(s=>s.id===o))==null?void 0:ze.title]}),e.jsx(z,{className:"mt-0.5",children:($e=g.find(s=>s.id===o))==null?void 0:$e.code}),((Me=g.find(s=>s.id===o))==null?void 0:Me.description)&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground leading-relaxed",children:(Ke=g.find(s=>s.id===o))==null?void 0:Ke.description})]}),e.jsx(b,{permission:"evidence.create",children:e.jsxs(i,{size:"sm",onClick:()=>te(o),children:[e.jsx(S,{className:"mr-1 h-3 w-3"}),"Add Evidence"]})})]})}),e.jsx(m,{children:Re.length>0?e.jsx("div",{className:"space-y-3",children:Re.map(s=>{const n=Ne(s.collected_at);return e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>O(s),children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-muted",children:e.jsx(B,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"text-sm font-medium",children:s.title}),s.description&&e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:s.description}),e.jsxs("div",{className:"mt-2 flex items-center gap-3 flex-wrap",children:[e.jsx(d,{variant:"outline",className:"text-[10px] capitalize",children:s.evidence_type}),e.jsx(pe,{status:s.status}),e.jsxs(d,{className:N("text-[10px]",n.color),children:[e.jsx(Ye,{className:"mr-1 h-2.5 w-2.5"}),n.label]}),s.collected_at&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Collected ",w(s.collected_at)]}),s.expires_at&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Expires ",w(s.expires_at)]})]})]}),e.jsx(b,{permission:"evidence.delete",children:e.jsx(i,{size:"sm",variant:"ghost",className:"shrink-0 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:C=>{C.stopPropagation(),window.confirm(`Delete evidence "${s.title}"?`)&&W.mutate(s.id)},children:e.jsx(ve,{className:"h-4 w-4"})})})]},s.id)})}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ze,{className:"h-10 w-10 text-muted-foreground mb-3"}),e.jsx("p",{className:"text-sm font-medium",children:"No evidence mapped"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Upload or link evidence to this control"}),e.jsx(b,{permission:"evidence.create",children:e.jsxs(i,{size:"sm",className:"mt-4",onClick:()=>te(o),children:[e.jsx(S,{className:"mr-1 h-3 w-3"}),"Add Evidence"]})})]})})]}):e.jsx(x,{children:e.jsxs(m,{className:"flex flex-col items-center justify-center py-20",children:[e.jsx(Ze,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Select a control to view mapped evidence"})]})})})]})}),e.jsx(ie,{value:"gaps",className:"mt-6",children:us?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(F,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):u?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 grid-cols-2 lg:grid-cols-4",children:[e.jsx(x,{children:e.jsxs(m,{className:"p-4",children:[e.jsx("p",{className:"text-2xl font-bold",children:u.total_requirements}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Requirements"})]})}),e.jsx(x,{children:e.jsxs(m,{className:"p-4",children:[e.jsx("p",{className:"text-2xl font-bold text-green-600",children:u.covered_count}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Covered"})]})}),e.jsx(x,{children:e.jsxs(m,{className:"p-4",children:[e.jsx("p",{className:"text-2xl font-bold text-red-600",children:u.gap_count}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Gaps"})]})}),e.jsx(x,{children:e.jsxs(m,{className:"p-4",children:[e.jsxs("p",{className:"text-2xl font-bold",children:[u.coverage_pct,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Coverage"}),e.jsx(Fs,{value:u.coverage_pct,className:"mt-2 h-1.5"})]})})]}),e.jsxs(x,{children:[e.jsxs(R,{children:[e.jsx(q,{children:"Controls Lacking Recent Evidence"}),e.jsxs(z,{children:["Controls without evidence collected in the last ",u.freshness_window_days," days"]})]}),e.jsx(m,{children:u.gaps.length>0?e.jsx("div",{className:"space-y-3",children:u.gaps.map(s=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border p-3",children:[e.jsx("div",{className:"mt-0.5",children:s.priority==="critical"?e.jsx(H,{className:"h-5 w-5 text-red-500"}):e.jsx(Us,{className:"h-5 w-5 text-amber-500"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(d,{variant:"outline",className:"text-[10px] font-mono",children:s.code}),e.jsx(d,{className:N("text-[10px]",s.priority==="critical"?"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-300":"bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-300"),children:s.priority}),e.jsx(d,{variant:"outline",className:"text-[10px]",children:s.gap_type==="no_evidence"?"No Evidence":"Stale Evidence"})]}),e.jsx("h4",{className:"mt-1 text-sm font-medium",children:s.title}),e.jsxs("div",{className:"mt-1 flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsx("span",{children:s.category}),s.last_evidence_date?e.jsxs("span",{children:["Last evidence: ",w(s.last_evidence_date)]}):e.jsx("span",{children:"No evidence collected"})]})]})]},s.requirement_id))}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(ge,{className:"h-10 w-10 text-green-500 mb-3"}),e.jsx("p",{className:"text-sm font-medium",children:"All controls have recent evidence"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Great coverage! All requirements are backed by evidence."})]})})]})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(H,{className:"h-10 w-10 text-muted-foreground mb-3"}),e.jsx("p",{className:"text-sm font-medium",children:ne(hs,"Unable to load gap analysis")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Try refreshing the page"})]})}),e.jsx(ie,{value:"auto-collection",className:"mt-6",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 grid-cols-2 lg:grid-cols-3",children:[e.jsx(x,{children:e.jsx(m,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(v==null?void 0:v.active_schedules)??0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active Schedules"})]}),e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-green-100 dark:bg-green-900",children:e.jsx(Bs,{className:"h-5 w-5 text-green-600 dark:text-green-400"})})]})})}),e.jsx(x,{children:e.jsx(m,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:v!=null&&v.last_run_at?w(v.last_run_at):"Never"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last Run"})]}),e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-green-100 dark:bg-green-900",children:e.jsx(Ye,{className:"h-5 w-5 text-green-600 dark:text-green-400"})})]})})}),e.jsx(x,{children:e.jsx(m,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(v==null?void 0:v.total_findings_last_run)??0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Findings (Last Run)"})]}),e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-green-100 dark:bg-green-900",children:e.jsx(Hs,{className:"h-5 w-5 text-green-600 dark:text-green-400"})})]})})})]}),e.jsxs(x,{children:[e.jsx(R,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(q,{children:"Collection Schedules"}),e.jsx(z,{children:"Automated evidence collection from connected integrations"})]}),e.jsx(b,{permission:"evidence.create",children:e.jsxs(i,{onClick:()=>T(!0),children:[e.jsx(S,{className:"mr-2 h-4 w-4"}),"Add Schedule"]})})]})}),e.jsx(m,{children:Ae.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Ge,{children:[e.jsx(Je,{children:e.jsxs(U,{children:[e.jsx(h,{children:"Integration Type"}),e.jsx(h,{children:"Interval"}),e.jsx(h,{children:"Last Run"}),e.jsx(h,{children:"Status"}),e.jsx(h,{children:"Findings"}),e.jsx(h,{className:"text-right",children:"Actions"})]})}),e.jsx(Ve,{children:Ae.map(s=>e.jsxs(U,{children:[e.jsx(j,{children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(d,{variant:"outline",className:"capitalize",children:s.integration_type.replace("_"," ")})})}),e.jsx(j,{children:e.jsxs("span",{className:"text-sm",children:["Every ",s.interval_hours,"h"]})}),e.jsx(j,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:s.last_run_at?w(s.last_run_at):"Never"})}),e.jsx(j,{children:s.last_run_status?e.jsx(d,{className:N("text-[10px]",s.last_run_status==="success"?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-300":s.last_run_status==="failed"?"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-300":"bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-300"),children:s.last_run_status}):e.jsx(d,{variant:"outline",className:"text-[10px]",children:"Pending"})}),e.jsx(j,{children:e.jsx("span",{className:"text-sm font-medium",children:s.last_run_findings_count})}),e.jsx(j,{children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsxs(i,{variant:"outline",size:"sm",onClick:()=>Z.mutate(s.id),disabled:Z.isPending,children:[Z.isPending?e.jsx(F,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Gs,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"ml-1",children:"Run Now"})]}),e.jsx(Ps,{checked:s.enabled,onCheckedChange:n=>js.mutate({id:s.id,body:{enabled:n}})}),e.jsx(i,{variant:"ghost",size:"sm",onClick:()=>{window.confirm("Delete this collection schedule? This cannot be undone.")&&De.mutate(s.id)},disabled:De.isPending,children:e.jsx(ve,{className:"h-3.5 w-3.5 text-destructive"})})]})})]},s.id))})]})}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(We,{className:"h-10 w-10 text-muted-foreground mb-3"}),e.jsx("p",{className:"text-sm font-medium",children:"No collection schedules"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Set up automated evidence collection from your integrations"}),e.jsx(b,{permission:"evidence.create",children:e.jsxs(i,{size:"sm",className:"mt-4",onClick:()=>T(!0),children:[e.jsx(S,{className:"mr-1 h-3 w-3"}),"Add Schedule"]})})]})})]})]})})]}),e.jsx(b,{permission:"evidence.create",children:e.jsxs(x,{children:[e.jsxs(R,{children:[e.jsxs(q,{className:"flex items-center gap-2",children:[e.jsx(Js,{className:"h-5 w-5"}),"Import AI red-team results"]}),e.jsx(z,{children:"Paste results from promptfoo or DeepEval â findings are mapped to OWASP LLM Top 10, NIST AI RMF, and ISO/IEC 42001 and stored as procurement-grade evidence"})]}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-[200px_1fr]",children:[e.jsxs("div",{className:"grid gap-2 content-start",children:[e.jsx(c,{htmlFor:"redteam-tool",children:"Tool"}),e.jsxs($,{value:se,onValueChange:gs,children:[e.jsx(M,{id:"redteam-tool",children:e.jsx(K,{placeholder:"Select tool"})}),e.jsx(Q,{children:ct.map(s=>e.jsx(y,{value:s.value,children:s.label},s.value))})]}),e.jsxs("div",{className:"relative flex items-center gap-2 rounded-md border border-input bg-background px-3 py-2 text-sm cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>{var s;return(s=document.getElementById("redteam-file"))==null?void 0:s.click()},children:[e.jsx(fe,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-muted-foreground",children:"Load JSON file..."}),e.jsx("input",{id:"redteam-file",type:"file",className:"sr-only",accept:".json,application/json",onChange:s=>{var C;const n=(C=s.target.files)==null?void 0:C[0];n&&n.text().then(Ie),s.target.value=""}})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"redteam-json",children:"Results JSON"}),e.jsx(He,{id:"redteam-json",placeholder:'Paste the eval results JSON, e.g. {"results": [...]}',value:ee,onChange:s=>Ie(s.target.value),rows:6,className:"font-mono text-xs"})]})]}),e.jsxs(i,{onClick:fs,disabled:!ee.trim()||Le,children:[Le?e.jsx(F,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(fe,{className:"mr-2 h-4 w-4"}),"Import as Evidence"]}),E&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap text-sm",children:[e.jsx(d,{variant:"outline",children:E.tool}),e.jsxs("span",{children:[E.total," tests"]}
1),e.jsxs(d,{className:N("text-[10px]",E.failed>0?"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-300":"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-300"),children:[E.failed," failed"]})]}),e.jsx("div",{className:"overflow-x-auto rounded-md border",children:e.jsxs(Ge,{children:[e.jsx(Je,{children:e.jsxs(U,{children:[e.jsx(h,{children:"Category"}),e.jsx(h,{children:"OWASP LLM Top 10"}),e.jsx(h,{children:"NIST AI RMF"}),e.jsx(h,{children:"ISO/IEC 42001"}),e.jsx(h,{className:"text-right",children:"Pass / Fail"})]})}),e.jsx(Ve,{children:E.mapped.map(s=>e.jsxs(U,{children:[e.jsx(j,{className:"font-medium",children:s.label}),e.jsx(j,{children:e.jsx(d,{variant:"outline",className:"text-[10px] font-mono whitespace-nowrap",children:s.owasp_llm})}),e.jsx(j,{className:"text-sm text-muted-foreground whitespace-nowrap",children:s.nist_ai_rmf}),e.jsx(j,{className:"text-sm text-muted-foreground whitespace-nowrap",children:s.iso42001}),e.jsx(j,{className:"text-right",children:e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"text-green-600 dark:text-green-400 font-medium",children:s.total_count-s.failed_count})," / ",e.jsx("span",{className:N("font-medium",s.failed_count>0?"text-red-600 dark:text-red-400":"text-muted-foreground"),children:s.failed_count})]})})]},s.category))})]})})]})]})]})}),e.jsx(de,{open:as,onOpenChange:A,children:e.jsxs(oe,{className:"sm:max-w-[480px]",children:[e.jsxs(xe,{children:[e.jsx(me,{children:"Add Evidence"}),e.jsx(ue,{children:D?`Add evidence for ${((Qe=g.find(s=>s.id===D))==null?void 0:Qe.title)??"this control"}`:"Upload or create a new evidence item"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"evidence-title",children:"Title"}),e.jsx(ce,{id:"evidence-title",placeholder:"e.g. Access Control Policy v3",value:I,onChange:s=>be(s.target.value)})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"evidence-description",children:"Description"}),e.jsx(He,{id:"evidence-description",placeholder:"Describe what this evidence demonstrates...",value:Ce,onChange:s=>we(s.target.value),rows:3})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"evidence-type",children:"Evidence Type"}),e.jsxs($,{value:Se,onValueChange:_e,children:[e.jsx(M,{id:"evidence-type",children:e.jsx(K,{placeholder:"Select type"})}),e.jsxs(Q,{children:[e.jsx(y,{value:"document",children:"Document"}),e.jsx(y,{value:"screenshot",children:"Screenshot"}),e.jsx(y,{value:"log",children:"Log"}),e.jsx(y,{value:"config",children:"Configuration"}),e.jsx(y,{value:"attestation",children:"Attestation"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{children:"Attach File (optional)"}),e.jsxs("div",{className:N("relative flex items-center gap-3 rounded-md border border-input bg-background px-3 py-2 text-sm cursor-pointer hover:bg-accent/50 transition-colors",k&&"border-primary/40"),onClick:()=>{var s;return(s=document.getElementById("evidence-file"))==null?void 0:s.click()},children:[e.jsx(fe,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:N("truncate",k?"text-foreground":"text-muted-foreground"),children:k?`${k.name} (${(k.size/1024).toFixed(1)} KB)`:"Choose a file..."}),e.jsx("input",{id:"evidence-file",type:"file",className:"sr-only",accept:As,onChange:s=>{var n;return X(((n=s.target.files)==null?void 0:n[0])||null)}})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Ds})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"evidence-control",children:"Control (optional)"}),e.jsxs($,{value:D??"__none__",onValueChange:s=>ye(s==="__none__"?null:s),children:[e.jsx(M,{id:"evidence-control",children:e.jsx(K,{placeholder:"Select a control"})}),e.jsxs(Q,{children:[e.jsx(y,{value:"__none__",children:"None"}),g.map(s=>e.jsxs(y,{value:s.id,children:[s.code??s.id," - ",s.title]},s.id))]})]})]})]}),e.jsxs(he,{children:[e.jsx(i,{variant:"outline",onClick:()=>A(!1),children:"Cancel"}),e.jsxs(i,{onClick:Ns,disabled:!I.trim()||V.isPending,children:[V.isPending?e.jsx(F,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(S,{className:"mr-2 h-4 w-4"}),"Add Evidence"]})]})]})}),e.jsx(de,{open:rs,onOpenChange:T,children:e.jsxs(oe,{className:"sm:max-w-[480px]",children:[e.jsxs(xe,{children:[e.jsx(me,{children:"Add Collection Schedule"}),e.jsx(ue,{children:"Configure automated evidence collection from an integration"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"schedule-integration",children:"Integration Type"}),e.jsxs($,{value:L,onValueChange:ke,children:[e.jsx(M,{id:"schedule-integration",children:e.jsx(K,{placeholder:"Select integration"})}),e.jsx(Q,{children:it.map(s=>e.jsx(y,{value:s.value,children:s.label},s.value))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"schedule-interval",children:"Interval (hours)"}),e.jsx(ce,{id:"schedule-interval",type:"number",min:"1",max:"720",placeholder:"24",value:Ee,onChange:s=>Te(s.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"How often to collect evidence (1-720 hours)"})]})]}),e.jsxs(he,{children:[e.jsx(i,{variant:"outline",onClick:()=>T(!1),children:"Cancel"}),e.jsxs(i,{onClick:ys,disabled:!L||Y.isPending,children:[Y.isPending?e.jsx(F,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(S,{className:"mr-2 h-4 w-4"}),"Create Schedule"]})]})]})}),e.jsx(de,{open:!!a,onOpenChange:s=>!s&&O(null),children:e.jsxs(oe,{className:"max-w-lg",children:[e.jsxs(xe,{children:[e.jsxs(me,{className:"flex items-center gap-2",children:[e.jsx(B,{className:"h-5 w-5"}),a==null?void 0:a.title]}),e.jsx(ue,{children:"Evidence details and metadata"})]}),a&&e.jsxs("div",{className:"space-y-4",children:[a.description&&e.jsxs("div",{children:[e.jsx(c,{className:"text-xs text-muted-foreground",children:"Description"}),e.jsx("p",{className:"text-sm mt-1",children:a.description})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-xs text-muted-foreground",children:"Type"}),e.jsx("p",{className:"text-sm mt-1 capitalize",children:a.evidence_type})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-xs text-muted-foreground",children:"Status"}),e.jsx("div",{className:"mt-1",children:e.jsx(pe,{status:a.status})})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-xs text-muted-foreground",children:"Collected"}),e.jsx("p",{className:"text-sm mt-1",children:a.collected_at?w(a.collected_at):"Not collected"})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-xs text-muted-foreground",children:"Expires"}),e.jsx("p",{className:"text-sm mt-1",children:a.expires_at?w(a.expires_at):"No expiry"})]}),a.collected_at&&e.jsxs("div",{children:[e.jsx(c,{className:"text-xs text-muted-foreground",children:"Freshness"}),e.jsx("div",{className:"mt-1",children:e.jsx(d,{className:N("text-xs",Ne(a.collected_at).color),children:Ne(a.collected_at).label})})]}),a.control_id&&e.jsxs("div",{children:[e.jsx(c,{className:"text-xs text-muted-foreground",children:"Control"}),e.jsx("p",{className:"text-sm mt-1",children:((Ue=g.find(s=>
1s.id===a.control_id))==null?void 0:Ue.code)||a.control_id})]})]}),(()=>{const s=a==null?void 0:a.content_text;return s?e.jsxs("div",{children:[e.jsx(c,{className:"text-xs text-muted-foreground",children:"Content"}),e.jsx("div",{className:"mt-1 rounded border bg-muted/50 p-3 text-sm max-h-48 overflow-y-auto whitespace-pre-wrap",children:String(s)})]}):null})()]}),e.jsxs(he,{className:"flex justify-between sm:justify-between",children:[e.jsx(b,{permission:"evidence.delete",children:e.jsxs(i,{variant:"destructive",size:"sm",disabled:W.isPending,onClick:()=>{a&&window.confirm(`Delete evidence "${a.title}"?`)&&W.mutate(a.id,{onSuccess:()=>O(null)})},children:[e.jsx(ve,{className:"h-4 w-4 mr-1"}),"Delete"]})}),e.jsx(i,{variant:"outline",onClick:()=>O(null),children:"Close"})]})]})})]})}export{_t as default};
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.