Files
pymc_console-dist/frontend/dist/assets/PathMapMapLibre-CEPFspHA.js
T
GitHub Actions Bot 86ee798a36 Release v0.9.139
Automated sync from private repository.
Built with obfuscation enabled.
2026-01-17 05:39:20 +00:00

2 lines
6.0 KiB
JavaScript

import{r as e,j as o,b4 as t,b5 as r,b6 as n,b7 as i,b8 as l}from"./vendor-react-6svyC5XA.js";import"./maplibre-gl-Bk5DsYkB.js";import"./vendor-core-BY0i4DpV.js";import"./deckgl-DTsmDcfs.js";const s={nodeColor:"#4338CA",localColor:"#4F46E5",hubColor:"#6366F1",edgeColor:"#3B3F4A",ambiguousColor:"#F9D26F",highlightColor:"#B49DFF",sourceColor:"#39D98A",destinationColor:"#B49DFF"};function a(){if("undefined"==typeof document)return s;const e=document.documentElement,o=getComputedStyle(e);return{nodeColor:o.getPropertyValue("--map-node-stroke").trim()||s.nodeColor,localColor:o.getPropertyValue("--map-local-color").trim()||s.localColor,hubColor:o.getPropertyValue("--map-hub-color").trim()||s.hubColor,edgeColor:o.getPropertyValue("--map-edge-rest").trim()||s.edgeColor,ambiguousColor:o.getPropertyValue("--accent-secondary").trim()||s.ambiguousColor,highlightColor:o.getPropertyValue("--accent-primary").trim()||s.highlightColor,sourceColor:o.getPropertyValue("--accent-success").trim()||s.sourceColor,destinationColor:o.getPropertyValue("--accent-primary").trim()||s.destinationColor}}function d(e,o,t,r=!1,n=!1,i=!1){const l=a(),s=r?`box-shadow: 0 0 0 3px ${l.highlightColor}40, 0 0 8px ${l.highlightColor}60;`:"";let d;d=n?l.sourceColor:i?l.destinationColor:e?l.localColor:o?l.hubColor:t?"transparent":l.ambiguousColor;const c=e||o||!t||n||i;return`<div style="\n width: 14px;\n height: 14px;\n background: ${d};\n border-radius: 50%;\n border: ${c?0:5}px solid ${c?"transparent":l.nodeColor};\n box-sizing: border-box;\n transition: box-shadow 0.15s ease;\n ${s}\n "></div>`}function c({resolvedPath:s,localNode:c,hubNodes:u=[],hoveredHopIndex:p,onHoverHop:m}){const h=e.useRef(null),g=e.useMemo(()=>new Set(u),[u]),[x,b]=e.useState(null),[C,y]=e.useState(0);e.useEffect(()=>{var e;const o=null==(e=h.current)?void 0:e.getMap();if(!o)return;const t=o.getCanvas();if(!t)return;const r=e=>{e.preventDefault()},n=()=>{y(e=>e+1)};return t.addEventListener("webglcontextlost",r),t.addEventListener("webglcontextrestored",n),()=>{t.removeEventListener("webglcontextlost",r),t.removeEventListener("webglcontextrestored",n)}},[C]);const{positions:f,markers:v,pathLineGeoJSON:j}=e.useMemo(()=>{const e=[],o=[],t=[];s.hops.forEach((r,n)=>{const i=r.candidates.filter(e=>{return o=e.latitude,t=e.longitude,0!==o||0!==t;var o,t});if(0===i.length)return;const l=[...i].sort((e,o)=>o.probability-e.probability)[0];t.push([l.longitude,l.latitude]);const s=!0===r.isSource,a=!0===r.isDestination;i.forEach((t,l)=>{const d=[t.latitude,t.longitude];e.push(d);const c=0===l;o.push({position:d,prefix:r.prefix,confidence:r.confidence,candidateCount:i.length,hopIndex:n,candidate:t,isHub:g.has(t.hash),isPrimary:c,isSource:s,isDestination:a})})});const r={type:"FeatureCollection",features:t.length>=2?[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}}]:[]};return{positions:e,markers:o,pathLineGeoJSON:r}},[s,g]),{initialBounds:k,center:N,zoom:S}=e.useMemo(()=>{if(0===f.length)return c?{initialBounds:null,center:[c.longitude,c.latitude],zoom:10}:{initialBounds:null,center:[0,0],zoom:2};let e=1/0,o=-1/0,t=1/0,r=-1/0;for(const[l,s]of f)l<e&&(e=l),l>o&&(o=l),s<t&&(t=s),s>r&&(r=s);const n=(e+o)/2,i=(t+r)/2;if(f.length>=2){const l=.15*(o-e)||.01,s=.15*(r-t)||.01;return{initialBounds:[[t-s,e-l],[r+s,o+l]],center:[i,n],zoom:10}}return{initialBounds:null,center:[i,n],zoom:12}},[f,c]),P=e.useCallback(e=>{b({longitude:e.position[1],latitude:e.position[0],marker:e})},[]);if(0===f.length)return o.jsx("div",{className:"h-[200px] flex items-center justify-center text-text-muted text-sm bg-bg-elevated",children:"No mappable path data"});const F=k?{bounds:k,fitBoundsOptions:{padding:30,maxZoom:16}}:{longitude:N[0],latitude:N[1],zoom:S};return o.jsxs(t,{ref:h,initialViewState:F,style:{height:"200px",width:"100%"},mapStyle:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",attributionControl:!1,children:[j.features.length>0&&o.jsx(r,{id:"path-line-source",type:"geojson",data:j,children:o.jsx(n,{id:"path-line",type:"line",paint:{"line-color":a().edgeColor,"line-width":2,"line-opacity":.7},layout:{"line-cap":"round","line-join":"round"}})}),v.map(e=>{const t=p===e.hopIndex;return o.jsx(i,{longitude:e.position[1],latitude:e.position[0],anchor:"center",onClick:()=>P(e),children:o.jsx("div",{style:{cursor:"pointer",opacity:e.isPrimary?1:.5},onMouseEnter:()=>null==m?void 0:m(e.hopIndex),onMouseLeave:()=>null==m?void 0:m(null),dangerouslySetInnerHTML:{__html:d(e.candidate.isLocal||!1,e.isHub,e.isPrimary,t,e.isSource,e.isDestination)}})},`${e.hopIndex}-${e.candidate.hash}`)}),x&&o.jsx(l,{longitude:x.longitude,latitude:x.latitude,anchor:"bottom",offset:[0,-12],closeOnClick:!1,onClose:()=>b(null),className:"maplibre-popup",children:o.jsxs("div",{className:"text-xs",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"font-semibold",children:x.marker.candidate.name}),(()=>{const e=a();return o.jsxs(o.Fragment,{children:[x.marker.isSource&&o.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.sourceColor,color:"#000"},children:"SRC"}),x.marker.isDestination&&o.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.destinationColor,color:"#000"},children:"DST"}),x.marker.isHub&&o.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.hubColor,color:"#000"},children:"HUB"}),x.marker.candidate.isLocal&&o.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.localColor,color:"#fff"},children:"LOCAL"})]})})()]}),o.jsxs("div",{className:"text-text-muted font-mono text-[10px]",children:[x.marker.prefix," • ",x.marker.candidate.hash.slice(0,10),"..."]}),!x.marker.isPrimary&&x.marker.candidateCount>1&&o.jsxs("div",{style:{color:a().ambiguousColor},children:["Alternative (",(100*x.marker.candidate.probability).toFixed(0),"%)"]}),x.marker.isPrimary&&x.marker.candidateCount>1&&o.jsxs("div",{className:"text-text-muted",children:[x.marker.candidateCount," candidates"]})]})})]},C)}export{c as default};