Files
pymc_console-dist/frontend/dist/assets/DeepAnalysisModal-L9EkN490.js
GitHub Actions Bot c8c3f164ee Sync build v0.9.286
Automated sync from private repository.
Commit: fad7f9633de61427bfc2c672b7ddecaa0952d717
2026-02-27 07:48:08 +00:00

2 lines
8.3 KiB
JavaScript

import{c as e}from"./geo-utils-DJn8DnxF.js";import{r as t,j as s}from"./vendor-react-alRNW2nb.js";import{c as n}from"./vendor-core-FtpmsTnh.js";import{bH as i,bI as a,av as o,dr as l,ds as r,Y as c,dt as u,_ as f}from"./index-CkRTgHHA.js";import{m as g}from"./vendor-motion-DNp0Qg4F.js";import{a as m,bs as d,aR as h,aa as p,bo as x,L as b}from"./vendor-icons-TO0PZKGR.js";const y={hidden:{opacity:0,scale:.9},visible:{opacity:1,scale:1,transition:{type:"spring",stiffness:400,damping:15}},exit:{opacity:0,scale:.9,transition:{duration:a.fast}}},j={hidden:{opacity:0,y:"100%"},visible:{opacity:1,y:0,transition:{type:"spring",stiffness:400,damping:30}},exit:{opacity:0,y:"100%",transition:{duration:a.medium,ease:i.easeIn}}};function v(e,t){let s=0;for(let n=0;n<e.length;n++)s+=e[n]*t[n];return s}function N(e){const t=function(e){return Math.sqrt(v(e,e))}(e);if(t>0)for(let s=0;s<e.length;s++)e[s]/=t}function w(e,t){const s=v(e,t);for(let n=0;n<e.length;n++)e[n]-=s*t[n]}function M(e,t){const s=e.length,n=new Array(s).fill(0);for(let i=0;i<s;i++)for(let a=0;a<s;a++)n[i]+=e[i][a]*t[a];return n}function A(e){const t=Math.exp(-e/30);return Math.max(.05,t)}function C(e){const t=e.length,s=Array(t).fill(null).map(()=>Array(t).fill(0));for(let n=0;n<t;n++){let i=0;for(let a=0;a<t;a++)i+=e[n][a],s[n][a]=-e[n][a];s[n][n]=i}return s}function H(e){const t=e.length,s=Array(t).fill(1/Math.sqrt(t));let n=0;for(let l=0;l<t;l++){let s=0;for(let n=0;n<t;n++)s+=Math.abs(e[l][n]);n=Math.max(n,s)}const i=Array(t).fill(null).map(()=>Array(t).fill(0));for(let l=0;l<t;l++){for(let s=0;s<t;s++)i[l][s]=-e[l][s];i[l][l]=n+i[l][l]}let a=Array(t).fill(0).map((e,t)=>43758.5453*Math.sin(12.9898*t)%1-.5);w(a,s),N(a);let o=0;for(let l=0;l<100;l++){const e=M(i,a);w(e,s);const t=v(e,e)/v(a,e);if(N(e),a=e,Math.abs(t-o)<1e-8)return{vector:a,eigenvalue:n-t};o=t}return{vector:a,eigenvalue:n-o}}function k(t,s){if(t.length<2)return 0;const n=[];for(const e of t){const t=s.get(e);t&&n.push(t)}if(n.length<2)return 0;const i=Math.min(n.length,20),a=n.length<=i?n:function(e,t){if(t>=e.length)return e;const s=[],n=e.length/t;for(let i=0;i<t;i++)s.push(e[Math.floor(i*n)]);return s}(n,i);let o=0;for(let l=0;l<a.length;l++)for(let t=l+1;t<a.length;t++){const s=e(a[l][0],a[l][1],a[t][0],a[t][1])/1e3;o=Math.max(o,s)}return o}function T(t,s,n,i){const a=s.length;if(a<3)return null;const o=new Set(s),l=t.filter(e=>o.has(e.fromHash)&&o.has(e.toHash));if(0===l.length)return null;const r=function(t,s,n,i){const a=s.length,o=new Map(s.map((e,t)=>[e,t])),l=Array(a).fill(null).map(()=>Array(a).fill(0));for(const r of t){const t=o.get(r.fromHash),s=o.get(r.toHash);if(void 0!==t&&void 0!==s&&t!==s){const a=r.strength*r.certainCount;let o=1;if(n){const t=n.get(r.fromHash),s=n.get(r.toHash);t&&s&&(o=A(e(t[0],t[1],s[0],s[1])/1e3))}let c=1;if(i){const e=[r.fromHash,r.toHash].sort().join("-");c=1-.7*(i.get(e)??0)}const u=.3+.7*(r.symmetryRatio??0),f=Math.pow(a,.7)*Math.pow(o,.3)*c*u;l[t][s]=f,l[s][t]=f}}return l}(l,s,n,i),c=C(r),{vector:u,eigenvalue:f}=H(c);if(f<.001)return null;const g=[],m=[];for(let e=0;e<a;e++)u[e]<0?g.push(s[e]):m.push(s[e]);return g.length<5||m.length<5?null:{group0:g,group1:m,fiedlerValue:f}}function L(e,t,s,n){const i=t.length;if(i<3)return{communities:new Map([[0,t]]),nodePartitions:t.map(e=>({hash:e,community:0,fiedlerValue:0})),numCommunities:1,fiedlerValue:0,isConnected:i<=1};const a=[];let o=1/0;const l=[[t,0]];for(;l.length>0;){const[t,i]=l.shift();if((s?k(t,s):0)>20&&i<4&&t.length>=10){const a=T(e,t,s,n);if(a){o=Math.min(o,a.fiedlerValue),l.push([a.group0,i+1]),l.push([a.group1,i+1]);continue}}a.push(t)}const r=new Map,c=[],u=new Map;for(let f=0;f<a.length;f++){r.set(f,a[f]);for(const e of a[f])u.set(e,f)}for(const f of t)c.push({hash:f,community:u.get(f)??0,fiedlerValue:0});return{communities:r,nodePartitions:c,numCommunities:a.length,fiedlerValue:o===1/0?0:o,isConnected:!0}}function V(e){const t=["rgba(139, 92, 246, 0.25)","rgba(16, 185, 129, 0.25)","rgba(245, 158, 11, 0.25)","rgba(239, 68, 68, 0.25)","rgba(59, 130, 246, 0.25)","rgba(236, 72, 153, 0.25)","rgba(20, 184, 166, 0.25)","rgba(249, 115, 22, 0.25)"];return t[e%t.length]}function D(e,t){if(t.length<3)return 0;const s=t.length,n=new Map(t.map((e,t)=>[e,t])),i=Array(s).fill(null).map(()=>Array(s).fill(0));for(const l of e){const e=n.get(l.fromHash),t=n.get(l.toHash);void 0!==e&&void 0!==t&&e!==t&&(i[e][t]=1,i[t][e]=1)}const a=C(i),{eigenvalue:o}=H(a);return Math.max(0,o)}function z(e){const t=["rgba(139, 92, 246, 0.6)","rgba(16, 185, 129, 0.6)","rgba(245, 158, 11, 0.6)","rgba(239, 68, 68, 0.6)","rgba(59, 130, 246, 0.6)","rgba(236, 72, 153, 0.6)","rgba(20, 184, 166, 0.6)","rgba(249, 115, 22, 0.6)"];return t[e%t.length]}function P({label:e,icon:t,status:i,detail:a}){return s.jsxs("div",{className:n("flex items-center gap-3 py-3 px-4 radius-inset transition-base","active"===i&&"bg-sys-blue/10","complete"===i&&"bg-sys-blue/10 ring-2 ring-inset ring-sys-blue","pending"===i&&"opacity-40"),children:[s.jsx("div",{className:n("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 transition-all duration-300","active"===i&&"bg-sys-blue/20","complete"===i&&"bg-sys-blue/20","pending"===i&&"bg-subtle-fill"),children:"complete"===i?s.jsx(m,{className:"w-4 h-4 text-sys-blue"}):"active"===i?s.jsx(b,{className:"w-4 h-4 animate-spin text-sys-blue"}):s.jsx("span",{className:"text-fg-muted",children:t})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:n("text-sm font-medium transition-colors","active"===i&&"text-sys-blue","complete"===i&&"text-sys-blue","pending"===i&&"text-fg-muted"),children:e}),a&&"pending"!==i&&s.jsx("div",{className:"text-xs text-fg-muted mt-0.5 truncate",children:a})]})]})}const S=t.memo(function({isOpen:e,onClose:n}){const{packetCacheState:i,triggerDeepAnalysis:a}=o(),b=l(),j=r(),v=i.packetCount,[N,w]=t.useState("fetching");t.useEffect(()=>{e&&a()},[e,a]),t.useEffect(()=>{if(e)if(i.isTopologyLoading)w("fetching");else if(b)w("analyzing"),setTimeout(()=>w("building"),500),setTimeout(()=>w("discovering"),1e3);else if(j>0&&!i.isTopologyLoading){w("complete");const e=setTimeout(()=>{n()},1500);return()=>clearTimeout(e)}},[e,i.isTopologyLoading,b,j,n]);const M="complete"===N,A=i.loadProgress,C=t.useMemo(()=>A&&A.target>0?`Loading... ${(A.loaded/1e3).toFixed(1)}k / ${(A.target/1e3).toFixed(1)}k packets (${A.percent}%)`:v>0?`${v.toLocaleString()} packets loaded`:"Connecting to database...",[A,v]),H=e=>{const t=["fetching","analyzing","building","discovering","complete"],s=t.indexOf(N),n=t.indexOf(e);return n<s?"complete":n===s?"active":"pending"},k=M?n:()=>{};return s.jsx(c,{open:e,onClose:k,size:"sm",bottomSheet:!1,children:s.jsx(u,{isLoading:!M,borderRadius:16,children:s.jsx(f,{className:"p-6 radius-card overflow-hidden",children:M?s.jsxs("div",{className:"flex flex-col items-center py-6",children:[s.jsx(g.div,{variants:y,initial:"hidden",animate:"visible",className:"w-16 h-16 rounded-full flex items-center justify-center mb-4 bg-sys-blue/20",children:s.jsx(m,{className:"w-8 h-8 text-sys-blue"})}),s.jsx("h3",{className:"type-micro text-sys-blue",children:"Ready!"}),s.jsx("button",{onClick:n,className:"mt-3 sm:hidden min-h-[44px] min-w-[44px] px-4 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[s.jsx("div",{className:"w-10 h-10 radius-inset flex items-center justify-center bg-sys-blue/15",children:s.jsx(d,{className:"w-5 h-5 text-sys-blue"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"type-micro",children:"Deep Analysis"}),s.jsx("p",{className:"text-xs text-fg-muted",children:"Building mesh topology"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(P,{label:"Fetching Packets",icon:s.jsx(h,{className:"w-4 h-4"}),status:H("fetching"),detail:C}),s.jsx(P,{label:"Analyzing Database",icon:s.jsx(p,{className:"w-4 h-4"}),status:H("analyzing"),detail:"Processing packet paths"}),s.jsx(P,{label:"Building Topology",icon:s.jsx(d,{className:"w-4 h-4"}),status:H("building"),detail:"Computing mesh edges"}),s.jsx(P,{label:"Discovering Nodes",icon:s.jsx(x,{className:"w-4 h-4"}),status:H("discovering"),detail:"Viterbi HMM ghost detection"})]}),s.jsx("p",{className:"text-xs text-fg-muted text-center mt-5",children:"This may take a few seconds..."})]})})})})});export{S as D,V as a,L as b,D as c,z as g,j as s};