1import{A as G,r as T,a as O,b as U,bb as _,bc as j,g as K,q as W,h as Q,j as e,l as r,M as d,N as p,S as u,Q as I,m as i,v as Y,I as z,B as J,$ as X,H as Z,K as b,aH as F,bm as ee,ar as se,i as ae,c as te,a5 as ce,bo as ne,C as re,ao as ie}from"./index-Ojn8dnb4.js";import{S as oe}from"./seo-C0iGv6QW.js";import{u as le,t as de}from"./zod-DkZ4fTr9.js";import{T as me}from"./textarea-CriIgNpw.js";import{F as xe,a as N,b as f,c as y,d as v,e as C}from"./form-GdNaYlV_.js";import{S as pe,a as he,b as ue,c as ge,d as je}from"./select-ClkkhIG3.js";import{R as be}from"./routed-intelligence-alert-ClUsJXRf.js";import{S as g}from"./skeleton-BD64H99-.js";import{C as Ne}from"./credit-cost-badge-B6fJox9_.js";import{C as fe}from"./circle-check-big-Csc00KiP.js";import{A as ye}from"./archive-BDnCQdRp.js";import{C as ve}from"./clock-BZWFN7jt.js";import"./label-RJe8aUSP.js";import"./chevron-up-Dm1YbDE-.js";const Ce=["Healthcare","FinTech","E-Commerce","SaaS","Manufacturing","Legal","Education","Insurance","Real Estate","Technology","Finance & Banking","Pharmaceuticals","Biotechnology","Telecommunications","Energy & Utilities","Aerospace & Defense","Automotive","Retail & Consumer Goods","Hospital
1ity & Tourism","Transportation & Logistics","Construction","Media & Entertainment","Cybersecurity","Cloud Computing","Artificial Intelligence","HealthTech","EdTech","PropTech","CleanTech","Private Equity & VC","Investment Management","Professional Services","Government & Public Sector","Non-Profit & NGO","Agriculture","Food & Beverage","Mining & Metals","Oil & Gas","Environmental Services","Other"];function Be(){const{t:a}=G(),[R,m]=T.useState(""),[A,k]=T.useState(null),{toast:o}=O(),{data:S,isLoading:E}=U({queryKey:["/api/agent-reports"]}),x=S?[...S].filter(s=>s.agentType==="compliance_watchdog").sort((s,t)=>new Date(t.createdAt).getTime()-new Date(s.createdAt).getTime()).slice(0,10):[],D=_({industry:j().min(1,a("validation.industryRequired")),policyContent:j().min(50,a("validation.policyMinLength")),documentName:j().min(1,a("validation.documentRequired"))}),n=le({resolver:de(D),defaultValues:{industry:"",policyContent:"",documentName:""}}),{mutate:P,isPending:l}=K({mutationFn:async s=>(await Q("POST","/api/agents/compliance-watchdog",s)).json(),onSuccess:s=>{k(s),m(""),W.invalidateQueries({queryKey:["/api/agent-reports"]}),W.invalidateQueries({queryKey:["/api/credits/balance"]}),o({title:a("common.scanComplete"),description:a("complianceWatchdog.scanReady")})},onError:s=>{m("");const t=s.message||"";if(t.includes("Insufficient credits")||t.includes("402")){const h=t.match(/"cost":(\d+)/),w=t.match(/"balance":(\d+)/),$=h?h[1]:"20",H=w?w[1]:"0";o({variant:"destructive",title:"Insufficient Credits",description:`You need ${$} IC for this scan. Current balance: ${H} IC. Visit the Wallet to get more credits.`})}else o({variant:"destructive",title:"Scan Failed",description:t||a("complianceWatchdog.errorAnalysis")})}}),L=s=>{typeof s.industry=="string"&&s.industry&&n.setValue("industry",s.industry),o({title:"Intelligence Applied",description:"Routed findings have been added to your context."})},M=s=>
1{o({title:"Securing Your Data",description:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{className:"h-4 w-4 text-emerald-500"}),e.jsx("span",{children:"Scrubbing sensitive data for privacy..."})]})}),m(a("complianceWatchdog.loadingStep1")),setTimeout(()=>m(a("complianceWatchdog.loadingStep2")),3e3),setTimeout(()=>m(a("complianceWatchdog.loadingStep3")),6e3),P(s)},B=async s=>{const t=s.target.files?.[0];if(!t)return;n.setValue("documentName",t.name);const h=await t.text();n.setValue("policyContent",h),o({title:a("common.fileLoaded"),description:`${a("common.loaded")} ${t.name}`})},c=A?.outputs,q=s=>s>=80?"text-green-500":s>=60?"text-yellow-500":"text-red-500",V=s=>s==="high"?"bg-red-500/20 text-red-400 border-red-500/30":s==="medium"?"bg-yellow-500/20 text-yellow-400 border-yellow-500/30":"bg-green-500/20 text-green-400 border-green-500/30";return e.jsxs(e.Fragment,{children:[e.jsx(oe,{title:"Compliance Watchdog",description:"Monitor regulatory compliance, industry standards, and risk factors across your prospect pipeline.",url:"/compliance",noIndex:!0}),e.jsxs("div",{className:"space-y-5 sm:space-y-8 pb-20 min-w-0 overflow-x-hidden",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-display font-bold text-white break-words",children:[a("complianceWatchdog.title")," ",e.jsx("span",{className:"text-accent",children:a("complianceWatchdog.titleHighlight")})]}),e.jsx("p",{className:"text-muted-foreground",children:a("complianceWatchdog.description")})]}),e.jsx(be,{targetAgent:"compliance_watchdog",onUseIntelligence:L}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-5 sm:gap-8",children:[e.jsxs(r,{className:"border-border/50 bg-card/50 backdrop-blur-xl",children:[e.jsxs(d,{children:[e.jsxs(p,{className:"flex items-center gap-2",children:[e.jsx(u,{className:"h-5 w-5 text-primary"}),a("complianceWatchdog.cardTitle")]}),e.jsx(I,{children:a("complianceWatchdog.cardDescription")})]}),e.jsxs(i,{children:[e.jsx(xe,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(M),className:"space-y-4",children:[e.jsx(N,{control:n.control,name:"industry",render:({field:s})=>e.jsxs(f,{children:[e.jsx(y,{children:a("complianceWatchdog.industry")}),e.jsxs(pe,{onValueChange:s.onChange,value:s.value,disabled:l,children:[e.jsx(v,{children:e.jsx(he,{className:"h-12 bg-background/50","data-testid":"select-industry",children:e.jsx(ue,{placeholder:a("complianceWatchdog.industryPlaceholder")})})}),e.jsx(ge,{children:Ce.map(t=>e.jsx(je,{value:t,children:t},t))})]}),e.jsx(C,{})]})}),e.jsxs("div",{className:"border-2 border-dashed border-border/50 rounded-xl p-6 text-center hover:border-primary/50 transition-colors",children:[e.jsx("input",{type:"file",accept:".txt,.pdf,.docx,.doc",onChange:B,className:"hidden",id:"policy-upload","data-testid":"input-policy-upload"}),e.jsxs("label",{htmlFor:"policy-upload",className:"cursor-pointer",children:[e.jsx(Y,{className:"h-10 w-10 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a("complianceWatchdog.uploadPolicy")})]})]}),e.jsx(N,{control:n.control,name:"documentName",render:({field:s})=>e.jsxs(f,{children:[e.jsx(y,{children:a("rfpDraftsman.documentName")}),e.jsx(v,{children:e.jsx(z,{placeholder:"e.g. Privacy Policy v2.0",className:"h-12 bg-background/50",...s,disabled:l,"data-testid":"input-document-name"})}),e.jsx(C,{})]})}),e.jsx(N,{control:n.control,name:"policyContent",render:({field:s})=>e.jsxs(f,{children:[e.jsx(y,{children:a("complianceWatchdog.policyContent")}),e.jsx(v,{children:e.jsx(me,{placeholder:a("complianceWatchdog.policyPlaceholder"),className:"min-h-[150px] bg-background/50",...s,disabled:l,"data-testid":"textarea-policy-content"})}),e.jsx(C,{})]})}),e.jsx(J,{type:"submit",disabled:l,className:"w-full h-12 text-lg font-bold","data-testid":"button-scan-compliance",children:l?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(X,{className:"h-5 w-5 animate-spin"}),a("complianceWatchdog.scanningButton")]}):e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(u,{className:"h-5 w-5"}),a("complianceWatchdog.scanButton"),e.jsx(Ne,{cost:Z.compliance_report.cost,size:"sm"})]})})]})}),l&&e.jsx(b.div,{initial:{opacity:0,y:10}
1,animate:{opacity:1,y:0},className:"text-center p-4 mt-4 rounded-xl bg-accent/5 border border-accent/10",children:e.jsx("p",{className:"text-accent font-medium animate-pulse",children:R})})]})]}),c&&e.jsxs(b.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},className:"space-y-6",children:[e.jsxs(r,{className:"border-border/50 bg-card/50",children:[e.jsx(d,{className:"pb-2",children:e.jsx(p,{className:"text-lg",children:a("complianceWatchdog.complianceScore")})}),e.jsx(i,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:F("text-5xl font-bold",q(c.complianceScore)),children:[c.complianceScore,"%"]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(ee,{value:c.complianceScore,className:"h-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:c.complianceScore>=80?"Good standing":c.complianceScore>=60?"Needs improvement":"Critical gaps found"})]})]})})]}),c.regulations?.length>0&&e.jsxs(r,{className:"border-border/50 bg-card/50",children:[e.jsx(d,{className:"pb-2",children:e.jsxs(p,{className:"text-lg flex items-center gap-2",children:[e.jsx(fe,{className:"h-5 w-5 text-primary"}),a("complianceWatchdog.regulations")]})}),e.jsx(i,{children:e.jsx("div",{className:"space-y-3 max-h-48 overflow-y-auto",children:c.regulations.map((s,t)=>e.jsx("div",{className:"p-3 rounded-lg bg-background/30 border border-border/30",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s.name}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s.description}),e.jsxs("p",{className:"text-xs text-primary mt-1",children:[a("common.effective"),": ",s.effectiveDate]})]}),s.source&&e.jsx("a",{href:s.source,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:e.jsx(se,{className:"h-4 w-4"})})]})},t))})})]}),c.gaps?.length>0&&e.jsxs(r,{className:"border-border/50 bg-card/50",children:[e.jsx(d,{className:"pb-2",children:e.jsxs(p,{className:"text-lg flex items-center gap-2 text-yellow-500",children:[e.jsx(ae,{className:"h-5 w-5"}),a("complianceWatchdog.complianceGaps")," (",c.gaps.length,")"]})}),e.jsx(i,{children:e.jsx("div",{className:"space-y-3 max-h-64 overflow-y-auto",children:c.gaps.map((s,t)=>e.jsxs("div",{className:F("p-3 rounded-lg border",V(s.severity)),children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"font-medium text-sm",children:s.regulation}),e.jsx("span",{className:"text-xs uppercase font-bold",children:s.severity})]}),e.jsx("p",{className:"text-sm opacity-80",children:s.issue}),e.jsxs("p",{className:"text-xs mt-2 opacity-60",children:[e.jsxs("span",{className:"font-medium",children:[a("common.recommendation"),":"]})," ",s.recommendation]})]},t))})})]})]})]}),e.jsxs("div",{className:"space-y-4 mt-8",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-xl font-semibold flex items-center gap-2",children:[e.jsx(ye,{className:"h-5 w-5 text-muted-foreground"}),a("complianceWatchdog.savedScans","Saved Compliance Scans")]}),x.length>0&&e.jsxs(te,{variant:"secondary",className:"text-xs",children:[x.length," ",x.length===1?"scan":"scans"]})]}),E?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(s=>e.jsxs(r,{className:"border-border/50 bg-card/50",children:[e.jsxs(d,{className:"pb-2",children:[e.jsx(g,{className:"h-4 w-3/4"}),e.jsx(g,{className:"h-3 w-1/2"})]}),e.jsxs(i,{children:[e.jsx(g,{className:"h-3 w-full mb-2"}),e.jsx(g,{className:"h-3 w-2/3"})]})]},s))}):x.length===0?e.jsx(r,{className:"border-border/50 bg-card/30 border-dashed",children:e.jsxs(i,{className:"py-8 text-center",children:[e.jsx(u,{className:"h-12 w-12 mx-auto text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:a("complianceWatchdog.noSavedScans","No compliance scans generated yet. Create your first one above!")})]})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:x.map(s=>{const t=s.inputs;return e.jsx(b.div,{initial:{opacity:0,y:10}
1,animate:{opacity:1,y:0},transition:{duration:.2},children:e.jsx(ce,{href:`/compliance-reports/${s.id}`,children:e.jsxs(r,{className:"border-border/50 bg-card/50 hover-elevate cursor-pointer transition-all h-full","data-testid":`card-compliance-${s.id}`,children:[e.jsxs(d,{className:"pb-2",children:[e.jsxs(p,{className:"text-base flex items-center gap-2",children:[e.jsx(u,{className:"h-4 w-4 text-yellow-500 shrink-0"}),e.jsx("span",{className:"truncate",children:s.title||t?.documentName||"Compliance Scan"})]}),e.jsx(I,{className:"truncate",children:t?.industry||"Industry Analysis"})]}),e.jsx(i,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(ve,{className:"h-3 w-3"}),new Date(s.createdAt).toLocaleDateString()]})}),e.jsx(ne,{className:"pt-2 border-t border-border/30",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:a("common.viewDetails","View Details")}),e.jsx(re,{className:"h-4 w-4 text-muted-foreground"})]})})]})})},s.id)})})]})]})]})}export{Be 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.