Spaces:
Running
Running
| import{j as e,R as h,f as p,a as u}from"./index-B6LgHwxl.js";import{r as n}from"./vendor-C1HQAMsB.js";import{A as g}from"./AccessibleButton-B9jiZpHu.js";const j=({data:t,height:a=400,width:r,mode:i="2d",onNodeClick:d,onNodeHover:o})=>!t||!t.nodes.length?e.jsx("div",{style:{height:a,width:r},className:"flex items-center justify-center border border-gray-300 rounded",children:e.jsx("p",{className:"text-gray-500",children:"No data to display"})}):e.jsxs("div",{style:{height:a,width:r},className:"border border-gray-300 rounded p-4",children:[e.jsxs("div",{className:"text-sm text-gray-600 mb-2",children:["Network Graph: ",t.nodes.length," nodes, ",t.links.length," links"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Mode: ",i]}),e.jsx("div",{className:"mt-4 bg-gray-100 rounded h-64 flex items-center justify-center",children:e.jsx("span",{className:"text-gray-500",children:"Graph visualization placeholder"})})]}),f=()=>{const[t,a]=n.useState(void 0),[r,i]=n.useState(!0),[d,o]=n.useState(null),c=async()=>{i(!0),o(null);try{const l=await u.getGraphData(),m={nodes:l.nodes.map(s=>{var x;return{id:s.id,group:s.type,label:s.name||s.id,val:((x=s.properties)==null?void 0:x.val)||5,...s.properties}}),links:l.links.map(s=>({source:s.source,target:s.target,type:s.type}))};a(m)}catch(l){console.error("Failed to fetch network data:",l),o("Failed to load network visualization. Please try again.")}finally{i(!1)}};return n.useEffect(()=>{c()},[]),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight text-gray-900 dark:text-white",children:"Network Analysis"}),e.jsx("p",{className:"mt-2 text-sm text-gray-600 dark:text-gray-400",children:"Maximize detection by visualizing complex relationships between entities, accounts, and transactions."})]}),e.jsxs(g,{onClick:c,variant:"secondary",loading:r,children:[e.jsx(h,{className:"mr-2 h-4 w-4"}),"Refresh Data"]})]}),e.jsxs("div",{className:"bg-white dark:bg-slate-900 p-6 rounded-lg shadow border border-gray-200 dark:border-slate-800",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsx("h2",{className:"text-lg font-medium dark:text-white",children:"Global Entity Relationship Graph"}),e.jsxs("div",{className:"text-xs text-slate-500",children:[(t==null?void 0:t.nodes.length)||0," Entities • ",(t==null?void 0:t.links.length)||0," Connections"]})]}),r?e.jsx("div",{className:"h-[500px] flex items-center justify-center bg-slate-50 dark:bg-slate-950 rounded-lg border border-slate-200 dark:border-slate-800",children:e.jsxs("div",{className:"text-center",children:[e.jsx(p,{className:"h-8 w-8 animate-spin text-blue-500 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Analyzing network topology..."})]})}):d?e.jsx("div",{className:"h-[500px] flex items-center justify-center bg-red-50 dark:bg-red-900/10 rounded-lg border border-red-200 dark:border-red-900/50",children:e.jsxs("div",{className:"text-center text-red-600 dark:text-red-400",children:[e.jsx("p",{className:"font-medium",children:d}),e.jsx("button",{onClick:c,className:"text-sm underline mt-2 hover:text-red-700",children:"Retry"})]})}):e.jsx("div",{"data-tour":"network-graph",children:e.jsx(j,{data:t,height:600})})]})]})};export{f as default}; | |