Files
pymc_console-dist/frontend/dist/assets/PathMapMapLibre-ChIFu4o3.js
T
GitHub Actions Bot f1ba7bed23 Sync build v0.9.195
Automated sync from private repository.
Commit: f0b9f5cc884f073df6c5886e881f1792c4705296
2026-01-29 18:29:14 +00:00

2 lines
10 KiB
JavaScript

import{r as e,j as t,bj as o,bk as r,bl as n,bm as a,bM as i,aD as s,m as l,bN as d,ab as c}from"./vendor-react-C341c8YC.js";import"./maplibre-gl-Bk5DsYkB.js";import{n as u}from"./recharts-6XUQYgRA.js";import{u as m,B as p}from"./BasemapLayer-S9Ush6Hh.js";import{h,s as x,p as g}from"./useThemeColors-AeHMyThq.js";import{H as f,B as b}from"./index-BJEgt3tp.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const v={version:8,sources:{},layers:[],glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf"},y={nodeColor:"#4338CA",localColor:"#4F46E5",hubColor:"#6366F1",edgeColor:"#3B3F4A",ambiguousColor:"#F9D26F",highlightColor:"#B49DFF",sourceColor:"#39D98A",destinationColor:"#B49DFF"};function C(e,t){if(!e)return t;if(e.startsWith("#"))return e;const o=g(e);return o?`#${o.r.toString(16).padStart(2,"0")}${o.g.toString(16).padStart(2,"0")}${o.b.toString(16).padStart(2,"0")}`:t}function j(){if("undefined"==typeof document)return y;const e=document.documentElement,t=getComputedStyle(e);return{nodeColor:C(t.getPropertyValue("--map-node-stroke").trim(),y.nodeColor),localColor:C(t.getPropertyValue("--map-local-color").trim(),y.localColor),hubColor:C(t.getPropertyValue("--map-hub-color").trim(),y.hubColor),edgeColor:C(t.getPropertyValue("--map-edge-rest").trim(),y.edgeColor),ambiguousColor:C(t.getPropertyValue("--accent-secondary").trim(),y.ambiguousColor),highlightColor:C(t.getPropertyValue("--accent-primary").trim(),y.highlightColor),sourceColor:C(t.getPropertyValue("--accent-success").trim(),y.sourceColor),destinationColor:C(t.getPropertyValue("--accent-primary").trim(),y.destinationColor)}}function k({prefix:o,isLocal:r,isSource:n,isDestination:a,isLastHop:i,isHighlighted:m,isAnimating:p,isWardrive:h,candidate:x,onHover:g,onLeave:f,onClick:v}){const y=s(),[C,j]=e.useState(!1);e.useEffect(()=>{p&&y.start({boxShadow:["0 0 0 0px rgba(113, 156, 223, 0)","0 0 0 2px rgba(113, 156, 223, 0.5)","0 0 0 2px rgba(113, 156, 223, 0.5)","0 0 0 0px rgba(113, 156, 223, 0)"],transition:{duration:.5,times:[0,.2,.7,1],ease:"easeInOut"}})},[p,y]);const k=e.useCallback(()=>{j(!0),g()},[g]),N=e.useCallback(()=>{j(!1),f()},[f]);return h?t.jsxs(l.div,{className:u("flex items-center cursor-pointer","transition-all duration-150",m&&"ring-2 ring-accent-primary/50 rounded-full",C&&"relative z-50"),animate:y,initial:{boxShadow:"0 0 0 0px rgba(249, 115, 22, 0)"},onMouseEnter:k,onMouseLeave:N,onClick:v,style:{pointerEvents:"auto"},children:[t.jsx("div",{className:u("flex items-center justify-center","w-7 h-7 rounded-full","bg-orange-500 text-white","shadow-lg border-2 border-orange-300/50","transition-transform duration-150",C&&"scale-110"),children:t.jsx(d,{className:"w-4 h-4",strokeWidth:2.5})}),C&&t.jsxs(b,{color:"orange",filled:!0,className:"ml-1 text-[10px] font-mono shadow-lg",children:[o,x.name&&t.jsx("span",{className:"ml-1 opacity-75",children:x.name})]})]}):t.jsx(l.div,{className:u("flex items-center cursor-pointer","transition-all duration-150",m&&"ring-2 ring-accent-primary/50 rounded",C&&"relative z-50"),animate:y,initial:{boxShadow:"0 0 0 0px rgba(113, 156, 223, 0)"},onMouseEnter:k,onMouseLeave:N,onClick:v,style:{pointerEvents:"auto"},children:t.jsxs(b,{color:h?"orange":r?"amber":n?"green":i?"amber":a?"purple":"blue",filled:!0,className:"font-mono text-[10px] shadow-lg border border-current/30",children:[r&&t.jsx(c,{className:"w-2.5 h-2.5 mr-1"}),o,C&&x.name&&t.jsx("span",{className:"ml-1 opacity-75",children:x.name})]})})}function N({hopNumber:e,snr:o,edgeColor:r}){return t.jsxs("div",{className:"flex flex-col items-center gap-0.5 pointer-events-none",children:[t.jsx("span",{className:"w-3.5 h-3.5 rounded-full flex items-center justify-center font-mono font-bold tabular-nums shadow-md",style:{backgroundColor:r||"#71717a",color:"#fff",fontSize:"8px",lineHeight:1,textShadow:"0 1px 1px rgba(0,0,0,0.4)"},children:e}),void 0!==o&&t.jsx(b,{color:"zinc",compact:!0,className:"!text-[9px] font-mono tabular-nums shadow-sm",children:o.toFixed(1)})]})}function S({resolvedPath:s,localNode:l,hubNodes:d=[],hoveredHopIndex:c,onHoverHop:g,traceSnr:b}){const y=void 0!==b&&b.length>0,C=e.useRef(null),S=m(),w=e.useMemo(()=>new Set(d),[d]),[F,L]=e.useState(null),D=f(),[E,M]=e.useState(!1),[P,H]=e.useState(0);e.useEffect(()=>{var e;const t=null==(e=C.current)?void 0:e.getMap();if(!t)return;const o=t.getCanvas();if(!o)return;const r=e=>{e.preventDefault()},n=()=>{H(e=>e+1)};return o.addEventListener("webglcontextlost",r),o.addEventListener("webglcontextrestored",n),()=>{o.removeEventListener("webglcontextlost",r),o.removeEventListener("webglcontextrestored",n)}},[P]);const{positions:$,markers:V,edges:B}=e.useMemo(()=>{const e=[],t=[],o=[],r=[];let n=0,a=!1;return s.hops.forEach((i,s)=>{const l=i.candidates.filter(e=>{return t=e.latitude,o=e.longitude,0!==t||0!==o;var t,o});if(0===l.length)return;const d=[...l].sort((e,t)=>t.probability-e.probability)[0],c=[d.longitude,d.latitude];if(r.push(c),r.length>=2){const e=r[r.length-2],t=r.length-2,n=null==b?void 0:b[t],i=c[0]-e[0],s=c[1]-e[1],l=Math.atan2(i,s)*(180/Math.PI),d=j();let u;u=a?"#F97316":void 0!==n?h()[x(n)]||"#71717a":d.edgeColor,o.push({from:e,to:c,snrFwd:n,midpoint:[(e[0]+c[0])/2,(e[1]+c[1])/2],bearing:l,color:u,isFromWardrive:a})}const u=!0===i.isSource,m=!0===i.isDestination,p=!0===d.isWardrive;a=p,l.forEach((o,r)=>{const a=[o.latitude,o.longitude];e.push(a);const d=0===r;t.push({position:a,prefix:i.prefix,confidence:i.confidence,candidateCount:l.length,hopIndex:s,candidate:o,isHub:w.has(o.hash),isPrimary:d,isSource:u,isDestination:m,validIndex:n})}),n++}),{positions:e,markers:t,edges:o}},[s,w,b]),I=e.useMemo(()=>{const e=V.filter(e=>e.isPrimary&&(e.confidence>=.5||e.isSource||e.isDestination));if(0===e.length)return null;let t=1/0,o=-1/0,r=1/0,n=-1/0;for(const a of e){const[e,i]=a.position;e<t&&(t=e),e>o&&(o=e),i<r&&(r=i),i>n&&(n=i)}return[[r,t],[n,o]]},[V]),W=e.useMemo(()=>{if(0===$.length)return l?[l.longitude,l.latitude]:[0,0];let e=0,t=0;for(const[o,r]of $)e+=o,t+=r;return[t/$.length,e/$.length]},[$,l]),A=e.useCallback(()=>{var e;const t=null==(e=C.current)?void 0:e.getMap();t&&I?(t.fitBounds(I,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:0}),setTimeout(()=>{M(!0)},50)):M(!0)},[I]),z=e.useMemo(()=>I?`${I[0][0].toFixed(5)},${I[0][1].toFixed(5)},${I[1][0].toFixed(5)},${I[1][1].toFixed(5)}`:"",[I]);e.useEffect(()=>{var e;if(!E)return;const t=null==(e=C.current)?void 0:e.getMap();t&&I&&t.fitBounds(I,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:300})},[z,E,I]);const R=D&&E,O=e.useCallback(e=>{L({longitude:e.position[1],latitude:e.position[0],marker:e})},[]);return 0===$.length?t.jsx("div",{className:"h-full flex items-center justify-center text-text-muted text-sm bg-bg-elevated",children:"No mappable path data"}):t.jsxs("div",{className:"h-full w-full relative",children:[t.jsx("div",{className:u("absolute inset-0 bg-bg-elevated flex items-center justify-center","transition-opacity duration-200 ease-out pointer-events-none",R?"opacity-0":"opacity-100"),children:t.jsx("div",{className:"w-5 h-5 border-2 border-text-muted/30 border-t-text-muted rounded-full animate-spin"})}),t.jsx("div",{className:"h-full w-full transition-opacity duration-300 ease-out",style:{opacity:R?1:0},children:t.jsxs(o,{ref:C,initialViewState:{longitude:W[0],latitude:W[1],zoom:10},onLoad:A,style:{height:"100%",width:"100%"},mapStyle:v,attributionControl:!1,children:[t.jsx(p,{mode:S}),B.map((e,o)=>{const a={type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e.from,e.to]}}]};return t.jsx(r,{id:`edge-${o}`,type:"geojson",data:a,children:t.jsx(n,{id:`edge-line-${o}`,type:"line",paint:{"line-color":e.color,"line-width":4,"line-opacity":1},layout:{"line-cap":"round","line-join":"round"}})},`edge-${o}`)}),B.map((e,o)=>t.jsx(a,{longitude:e.midpoint[0],latitude:e.midpoint[1],anchor:"center",children:t.jsx(N,{hopNumber:o+1,snr:y?e.snrFwd:void 0,edgeColor:e.color})},`hop-${o}`)),(()=>{const e=V.filter(e=>e.isPrimary),o=e.length>1?e.length-2:-1;return e.map((e,r)=>{const n=c===e.hopIndex,i=r===o&&!e.candidate.isLocal&&!e.isDestination;return t.jsx(a,{longitude:e.position[1],latitude:e.position[0],anchor:"center",children:t.jsx(k,{prefix:e.prefix,isLocal:e.candidate.isLocal||!1,isSource:e.isSource,isDestination:e.isDestination,isLastHop:i,isHighlighted:n,isAnimating:!1,isWardrive:e.candidate.isWardrive||!1,candidate:e.candidate,onHover:()=>null==g?void 0:g(e.hopIndex),onLeave:()=>null==g?void 0:g(null),onClick:()=>O(e)})},`${e.hopIndex}-${e.candidate.hash}`)})})(),F&&t.jsx(i,{longitude:F.longitude,latitude:F.latitude,anchor:"bottom",offset:[0,-12],closeOnClick:!1,onClose:()=>L(null),className:"maplibre-popup",children:t.jsxs("div",{className:"text-xs",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"font-semibold",children:F.marker.candidate.name}),(()=>{const e=j();return t.jsxs(t.Fragment,{children:[F.marker.isSource&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.sourceColor,color:"#000"},children:"SRC"}),F.marker.isDestination&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.destinationColor,color:"#000"},children:"DST"}),F.marker.isHub&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.hubColor,color:"#000"},children:"HUB"}),F.marker.candidate.isLocal&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.localColor,color:"#fff"},children:"LOCAL"}),F.marker.candidate.isWardrive&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:"#F97316",color:"#fff"},children:"WARDRIVE"})]})})()]}),t.jsxs("div",{className:"text-text-muted font-mono text-[10px]",children:[F.marker.prefix," • ",F.marker.candidate.hash.slice(0,10),"..."]}),!F.marker.isPrimary&&F.marker.candidateCount>1&&t.jsxs("div",{style:{color:j().ambiguousColor},children:["Alternative (",(100*F.marker.candidate.probability).toFixed(0),"%)"]}),F.marker.isPrimary&&F.marker.candidateCount>1&&t.jsxs("div",{className:"text-text-muted",children:[F.marker.candidateCount," candidates"]})]})})]},P)})]})}export{S as default};