1import{r,s as l,j as e,C as g,b as p,p as j,v as f,d as N,a as c,Z as C,af as _,ac as I,ad as S,x as T,z as q,g as E,T as L}from"./index-CT3mG8No.js";import{C as D,b as A,a as M}from"./collapsible-Dx9uShpA.js";import{L as U}from"./lightbulb-DIiM8qE_.js";import"./index-VKhLDAfi.js";const P=({ticker:n})=>{const[i,x]=r.useState([]),[o,b]=r.useState([]),[d,y]=r.useState(null),[v,h]=r.useState(!0);r.useEffect(()=>{(async()=>{h(!0);try{const{data:a}=await l.from("quant_insights").select("*").eq("symbol",n).eq("is_active",!0).order("created_at",{ascending:!1}).limit(10),{data:m}=await l.from("quant_agent_signals").select("*").eq("symbol",n).order("created_at",{ascending:!1}).limit(5);x(a||[]),b(m||[])}catch(a){console.error("Error fetching quant insights:",a)}h(!1)})();const t=l.channel("quant-insights").on("postgres_changes",{event:"INSERT",schema:"public",table:"quant_insights",filter:`symbol=eq.${n}`},a=>x(m=>[a.new,...m].slice(0,10))).subscribe();return()=>{l.removeChannel(t)}},[n]);const w=s=>{switch(s){case"bullish":return e.jsx(L,{className:"h-4 w-4 text-green-500"});case"bearish":return e.jsx(E,{className:"h-4 w-4 text-red-500"});case"mixed":return e.jsx(q,{className:"h-4 w-4 text-yellow-500"});default:return e.jsx(T,{className:"h-4 w-4 text-muted-foreground"})}},u=s=>{switch(s){case"BUY":return"bg-green-500/20 text-green-400 border-green-500/30";case"SELL":return"bg-red-500/20 text-red-400 border-red-500/30";case"WATCH":return"bg-yellow-500/20 text-yellow-400 border-yellow-500/30";default:return"bg-muted text-muted-foreground"}};return v?e.jsxs(g,{className:"bg-card/50 backdrop-blur border-border/50",children:[e.jsx(p,{className:"pb-3",children:e.jsxs(j,{className:"flex items-center gap-2 text-lg",children:[e.jsx(f,{className:"h-5 w-5 text-primary"}),"Quant Intelligence Engine"]})}),e.jsx(N,{children:e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"animate-pulse text-muted-foreground",children:"Computing insights..."})})})]}):e.jsxs(g,{className:"bg-card/50 backdrop-blur border-border/50",children:[e.jsx(p,{className:"pb-3",children:e.jsxs(j,{className:"flex items-center gap-2 text-lg",children:[e.jsx(f,{className:"h-5 w-5 text-primary"}),"Quant Intelligence Engine",e.jsxs(c,{variant:"outline",className:"ml-auto text-xs",children:[i.length," Active Insights"]})]})}),e.jsxs(N,{className:"space-y-4",children:[o.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(C,{className:"h-4 w-4 text-primary"}),"Agent Signals"]}),e.jsx("div",{className:"grid gap-2",children:o.slice(0,2).map(s=>e.jsxs("div",{className:`p-3 rounded-lg border ${u(s.signal_type)}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx(c,{className:u(s.signal_type),children:s.signal_type}),e.jsx("span",{className:"text-xs opacity-70",children:s.time_horizon})]}),e.jsx(_,{value:s.signal_strength*100,className:"h-1.5 mb-2"}),e.jsx("p",{className:"text-xs opacity-80 line-clamp-2",children:s.reasoning})]},s.id))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(U,{className:"h-4 w-4 text-yellow-500"}),"Deep Insights"]}),i.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No insights computed yet. The engine learns as more data flows in."}):e.jsx("div",{className:"space-y-2",children:i.map(s=>e.jsx(D,{open:d===s.id,onOpenChange:()=>y(d===s.id?null:s.id),children:e.jsxs("div",{className:"border rounded-lg p-3 bg-background/50",children:[e.jsx(A,{className:"w-full",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-start gap-2 text-left",children:[w(s.sentiment),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s.title}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:s.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(c,{variant:"outline",className:"text-xs",children:[Math.round(s.confidence_score*100),"%"]}),d===s.id?e.jsx(I,{className:"h-4 w-4"}):e.jsx(S,{className:"h-4 w-4"})]})]})}),e.jsxs(M,{className:"mt-3 pt-3 border-t space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Confidence:"})," ",Math.round(s.confidence_score*100),"%"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Impact:"})," ",Math.round(s.impact_score*100),"%"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Urgency:"})," ",Math.round(s.urgency_score*100),"%"]})]}),s.inference_chain&&s.inference_chain.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium mb-1",children:"Inference Chain:"}),e.jsx("ul",{className:"text-xs text-muted-foreground space-y-1",children:s.inference_chain.slice(0,3).map((t,a)=>e.jsxs("li",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-primary",children:"â"})," ",t]},a))})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:(s.tags||[]).slice(0,5).map((t,a)=>e.jsx(c,{variant:"secondary",className:"text-xs",children:t},a))})]})]})},s.id))})]})]})]})};export{P as QuantInsightsPanel,P 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.