mirror of
https://github.com/dmduran12/pymc_console-dist.git
synced 2026-03-28 17:43:04 +01:00
3 lines
28 KiB
JavaScript
3 lines
28 KiB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContactsMapMapLibre-BtIfp876.js","assets/vendor-react-alRNW2nb.js","assets/vendor-virt-BytWoLhu.js","assets/cosmograph-DqYT4sUA.js","assets/consumer-registry-BUFl6buY.js","assets/index-CkRTgHHA.js","assets/vendor-charts-C916_-gs.js","assets/vendor-core-FtpmsTnh.js","assets/vendor-motion-DNp0Qg4F.js","assets/vendor-icons-TO0PZKGR.js","assets/vendor-fonts-CRZaZSFf.js","assets/link-scoring-C0BjaK96.js","assets/ConfirmModal-B6Rz8ROW.js","assets/DeepAnalysisModal-L9EkN490.js","assets/geo-utils-DJn8DnxF.js","assets/useMapViewStore-sFZdb1_p.js","assets/BasemapLayer-CSqjQAiA.js","assets/vendor-geo-2MTwbTwv.js","assets/node-types-DRVunROD.js","assets/easing-GXZYrvDD.js","assets/badge-colors-BxLppqaF.js","assets/LightSparkline-BAD3v4m9.js","assets/ping-DPgnsJJf.js","assets/PageLayout-BWMUVZgC.js","assets/listbox-DrzA7Ewq.js","assets/TimeRangeStepper-CsLZzi5t.js","assets/chat-utils-mqGCinix.js","assets/SignalIndicator-Bdj3-1hL.js","assets/CollisionExplorerModal-BUHEIiWh.js","assets/DataBox-DpDXI-WX.js","assets/maplibre-gl-B1CfjdFi.css","assets/vendor-charts-D1GxaB_c.css","assets/vendor-fonts-hkYiuhFD.css","assets/index-BawBpZYt.css","assets/ContactsMapMapLibre-BwWOEply.css"])))=>i.map(i=>d[i]);
|
|
import{j as e,r as s}from"./vendor-react-alRNW2nb.js";import{c as t}from"./vendor-core-FtpmsTnh.js";import{as as a,at as n,H as l,V as r,au as i,h as c,av as o,t as d,aw as m,ax as x,ay as h,r as u,az as p,aA as g,aB as f,v as j,W as b,D as N,aC as v,aD as y,e as w,I as k}from"./index-CkRTgHHA.js";import{p as C}from"./ping-DPgnsJJf.js";import{c as S}from"./node-types-DRVunROD.js";import{P as M,a as R,B as P}from"./PageLayout-BWMUVZgC.js";import{L,a as $}from"./listbox-DrzA7Ewq.js";import{T as _}from"./TimeRangeStepper-CsLZzi5t.js";import{_ as F}from"./cosmograph-DqYT4sUA.js";import{u as z,e as E,f as I,r as H}from"./consumer-registry-BUFl6buY.js";import{e as T,g as O,a as D}from"./chat-utils-mqGCinix.js";import{a as V}from"./SignalIndicator-Bdj3-1hL.js";import{C as U}from"./CollisionExplorerModal-BUHEIiWh.js";import{ah as B,a as A,ai as W,j as G,aj as q,R as K,a2 as J,ak as Q,al as X,A as Y,am as Z,T as ee,an as se,ao as te,ap as ae,aq as ne,a7 as le,L as re,ar as ie,as as ce,U as oe,at as de,a1 as me,X as xe,au as he,av as ue,a5 as pe,aw as ge}from"./vendor-icons-TO0PZKGR.js";import{D as fe}from"./DataBox-DpDXI-WX.js";import{C as je}from"./badge-colors-BxLppqaF.js";import{C as be}from"./ConfirmModal-B6Rz8ROW.js";class Ne extends s.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}render(){var s;return this.state.hasError?e.jsx("div",{className:"map-container-16-9 flex items-center justify-center rounded-2xl surface-base",role:"alert","aria-live":"assertive",children:e.jsxs("div",{className:"text-center text-fg-muted p-4",children:[e.jsx("p",{className:"text-lg mb-2",children:"Map failed to load"}),e.jsx("p",{className:"text-sm text-fg-muted",children:(null==(s=this.state.error)?void 0:s.message)||"Unknown error"}),e.jsx("p",{className:"text-xs text-fg-muted mt-2",children:"Try refreshing the page or check your browser's WebGL support."})]})}):this.props.children}}const ve=s.lazy(()=>F(()=>import("./ContactsMapMapLibre-BtIfp876.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34])));function ye({neighbors:t,localNode:a,localHash:n,onRemoveNode:l,selectedNodeHash:r,onNodeSelected:i,highlightedEdgeKey:c,highlightedGhost:o}){return e.jsx(Ne,{children:e.jsx(s.Suspense,{fallback:e.jsx("div",{className:"map-container-16-9 flex items-center justify-center rounded-2xl surface-base",role:"status","aria-live":"polite","aria-label":"Loading map",children:e.jsxs("div",{className:"text-fg-muted flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 border-2 border-sys-blue border-t-transparent rounded-full animate-spin","aria-hidden":"true"}),e.jsx("span",{children:"Loading map..."})]})}),children:e.jsx(ve,{neighbors:t,localNode:a,localHash:n,onRemoveNode:l,selectedNodeHash:r,onNodeSelected:i,highlightedEdgeKey:c,highlightedGhost:o})})})}const we=s.memo(function({hash:t,className:r="",size:i="sm",collisionInfo:c,isViterbiResolved:o}){const d=a(),m=n(),[x,h]=s.useState(!1),u=s.useMemo(()=>l(t),[t]),p=s.useMemo(()=>void 0!==c?c:u?d.find(e=>e.prefix===u)??null:null,[u,d,c]),g=o??(m.totalPaths>0&&m.avgPathConfidence>=.7),f=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h(!0)},[]),j=s.useCallback(()=>{h(!1)},[]);if(!p)return null;const b="sm"===i?"w-3.5 h-3.5":"w-4 h-4",N=g?"text-sys-cyan hover:text-sys-cyan hover:bg-sys-cyan/10 focus:ring-sys-cyan/50":"text-signal-fair hover:text-sys-indigo hover:bg-signal-fair/10 focus:ring-signal-fair/50",v=g?`Prefix conflict resolved by Viterbi HMM (${(100*m.avgPathConfidence).toFixed(0)}% confidence)`:`Prefix conflict: ${p.candidateCount} nodes share prefix "${u}"`;return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:f,className:`inline-flex items-center justify-center p-0.5 rounded focus:outline-none focus:ring-2 transition-colors cursor-pointer touch-manipulation ${N} ${r}`,title:v,"aria-label":`View prefix conflict for ${u}${g?" (Viterbi resolved)":""}`,children:g?e.jsxs("span",{className:"relative",children:[e.jsx(B,{className:b}),e.jsx(A,{className:"absolute -bottom-0.5 -right-0.5 w-2 h-2 text-sys-green"})]}):e.jsx(W,{className:b})}),e.jsx(U,{isOpen:x,prefix:p.prefix,candidateHashes:p.candidateHashes,onClose:j})]})}),ke=[{target:"Contacts",fn:"name",minStage:1,when:E},{target:"Contacts",fn:"traceLinks.directed",minStage:2,when:I}];H(ke);const Ce=s.memo(function({hash:s,contact:t,isHub:a,isNeighbor:n,distance:l,centrality:o,sparklineData:d,neighborSignal:m,collisionInfo:x,isViterbiResolved:h,isPinging:u,isPingingThis:p,pingResult:g,pingError:f,gatewayInfo:j,lastForwarderPrefix:b,isMobile:N,pathStability:v,onRowClick:y,onPing:w,onRemove:k}){z(ke);const C=t.latitude&&t.longitude&&0!==t.latitude&&0!==t.longitude,M=t.node_name||t.name||"Unknown",R=n&&m,P=S(t),{isRepeater:L,isCompanion:$,isRoomServer:_,isClient:F,label:E}=P,I=n?`${E} — Direct RF contact (zero-hop neighbor)`:`${E} — Flood routing (multi-hop via mesh)`,H=t.first_seen?r(t.first_seen).replace(/ ago$/i," old"):null;return e.jsxs("div",{className:`contacts-grid-row ${a?"bg-sys-amber/5 border-l-2 border-l-sys-amber":""} ${C?"cursor-pointer hover:bg-subtle-fill":""}`,onClick:()=>y(s),children:[e.jsxs("div",{className:"contacts-col-node flex items-center gap-2 min-w-0",children:[R&&null!==(null==m?void 0:m.avgSnr)?e.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 self-center ${i(m.avgSnr)}`}):e.jsx("div",{className:"w-2 flex-shrink-0"}),e.jsx("div",{className:"w-6 h-6 flex items-center justify-center flex-shrink-0",title:I,children:(()=>{if(_&&L)return e.jsxs("div",{className:"relative w-5 h-5",children:[e.jsx(G,{className:"w-5 h-5 absolute inset-0 text-sys-pink"}),e.jsx(q,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-sys-teal"})]});if(_)return e.jsx(G,{className:"w-5 h-5 text-sys-pink"});if(L)return e.jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(K,{className:"w-3.5 h-3.5 text-sys-blue"})});if(($||F)&&"Unknown"!==M){const{emoji:s,cleanName:t}=T(M);return e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center",style:{backgroundColor:O(t)},children:s?e.jsx("span",{className:"text-sm leading-none",children:s}):e.jsx("span",{className:"text-white text-[9px] font-bold tracking-tighter",children:D(M)})})}return e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center bg-zinc-500/20",children:e.jsx(J,{className:"w-3.5 h-3.5 text-sys-amber"})})})()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 overflow-hidden",children:[e.jsx("span",{className:"roster-title truncate",title:M,children:M}),n&&e.jsx(c,{color:je.neighbor,compact:!0,className:"flex-shrink-0",children:"NBR"}),a&&e.jsxs(c,{color:je.hub,compact:!0,className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(Q,{className:"w-3 h-3"}),"HUB"]}),L&&e.jsx(c,{color:je.repeater,compact:!0,className:"flex-shrink-0",children:"RPT"}),_&&e.jsx(c,{color:je.room,compact:!0,className:"flex-shrink-0",children:"ROOM"}),$&&e.jsx(c,{color:je.companion,compact:!0,className:"flex-shrink-0",children:"COMP"}),F&&e.jsx(c,{color:je.client,compact:!0,className:"flex-shrink-0",children:"CLIENT"}),N&&e.jsxs(c,{color:"cyan",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",children:[e.jsx(X,{className:"w-2.5 h-2.5"}),"MOBILE"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx(fe,{copy:!0,size:"compact",truncate:[8,6],children:s}),e.jsx(we,{hash:s,collisionInfo:x,isViterbiResolved:h}),!n&&j&&e.jsxs(c,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:`Via ${j.name||j.prefix} (${j.hopCount} hop${1!==j.hopCount?"s":""})`,children:[e.jsx(Y,{className:"w-2.5 h-2.5"}),e.jsx("span",{className:"font-mono",children:j.prefix}),j.hopCount>1&&e.jsxs("span",{className:"opacity-60",children:["+",j.hopCount-1]})]}),b&&!n&&e.jsxs(c,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:`Last forwarded by ${b}`,children:[e.jsx(Z,{className:"w-2.5 h-2.5"}),e.jsx("span",{className:"font-mono",children:b})]}),null!=v&&0!==v&&e.jsx(c,{color:v>0?"green":"amber",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:v>0?"Path stability improving":"Path stability declining",children:v>0?e.jsx(ee,{className:"w-2.5 h-2.5"}):e.jsx(se,{className:"w-2.5 h-2.5"})}),d.length>0&&(()=>{const s=d.reduce((e,s)=>e+s.count,0);if(0===s)return null;const t=s/24;return e.jsxs(c,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:`${s} packets in last 24h (~${t.toFixed(1)}/hr)`,children:[e.jsx(te,{className:"w-2.5 h-2.5"}),e.jsxs("span",{children:[t<1?"<1":t.toFixed(0),"/hr"]})]})})(),H&&e.jsxs(c,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0 opacity-70",title:`First discovered ${H}`,children:[e.jsx(ae,{className:"w-2.5 h-2.5"}),e.jsx("span",{children:H})]})]})]})]}),e.jsxs("div",{className:"contacts-col-signal flex items-center justify-end gap-2",children:[R&&null!==(null==m?void 0:m.avgRssi)&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(V,{rssi:m.avgRssi,className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:Math.round(m.avgRssi)})]}),R&&null!==(null==m?void 0:m.avgSnr)&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[m.avgSnr.toFixed(1)," dB"]})]}),e.jsx("div",{className:"contacts-col-distance flex items-center justify-end gap-1 text-fg-muted",children:null!=l&&e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"w-3 h-3"}),e.jsx("span",{className:"type-data-xs",children:(U=l,U<1e3?`${Math.round(U)}m`:`${(U/1e3).toFixed(1)}km`)})]})}),e.jsx("div",{className:"contacts-col-centrality flex items-center justify-end gap-1",children:o>0&&e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"w-3 h-3 text-sys-indigo"}),e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[(100*o).toFixed(0),"%"]})]})}),e.jsx("div",{className:"contacts-col-seen flex items-center justify-end",children:e.jsx("span",{className:"type-data-xs text-fg-primary whitespace-nowrap",children:t.last_seen?r(t.last_seen):"—"})}),e.jsxs("div",{className:"contacts-col-actions flex items-center justify-end gap-1",children:[n&&e.jsx(e.Fragment,{children:g?e.jsxs("div",{className:"flex items-center gap-1 text-sys-green",title:`RTT: ${g.rtt_ms.toFixed(0)}ms`,children:[e.jsx(A,{className:"w-3.5 h-3.5"}),e.jsxs("span",{className:"type-data-xs hidden sm:inline",children:[g.snr_db.toFixed(1),"dB"]})]}):f?e.jsx("span",{className:"text-sys-red text-xs",title:f,children:"✗"}):e.jsx("button",{onClick:e=>w(s,e),disabled:u,className:"p-1 sm:p-1.5 radius-inner text-fg-muted/50 hover:text-sys-blue hover:bg-sys-blue/10 transition-base disabled:opacity-50 disabled:cursor-not-allowed",title:"Ping neighbor for updated signal info",children:p?e.jsx(re,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 animate-spin"}):e.jsx(ie,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})}),e.jsx("button",{onClick:e=>{e.stopPropagation(),k(s,M)},className:"p-1 sm:p-1.5 radius-inner text-fg-muted/50 hover:text-sys-red hover:bg-sys-red/10 transition-base",title:"Remove contact",children:e.jsx(ce,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})]})]});var U}),Se=[],Me=[{field:"lastHeard",icon:pe,label:"Recent"},{field:"distance",icon:ne,label:"Distance"},{field:"centrality",icon:le,label:"Centrality"}];function Re(e,s){const{color:a="primary",border:n=!1}=s??{};return t("flex items-center gap-1.5 px-2 py-1.5 text-sm radius-inner transition-base",e?"success"===a?"bg-sys-green/20 text-sys-green":"bg-sys-blue/20 text-sys-blue":"text-fg-muted hover:text-fg-secondary hover-bg",n&&(e?"success"===a?"border border-sys-green/30":"border border-sys-blue/30":"border border-transparent"))}function Pe(e,s,t,a){const n=(t-e)*Math.PI/180,l=(a-s)*Math.PI/180,r=Math.sin(n/2)*Math.sin(n/2)+Math.cos(e*Math.PI/180)*Math.cos(t*Math.PI/180)*Math.sin(l/2)*Math.sin(l/2);return 2*Math.atan2(Math.sqrt(r),Math.sqrt(1-r))*6371e3}const Le=Object.freeze(Object.defineProperty({__proto__:null,default:function(){const{stats:r}=o(),i=d(),c=m(),F=x(),z=h(),E=u(),I=p(),H=g(),T=f(),O=j(),D=b(),V=N[O],U=a(),B=n(),W=v(),q=B.totalPaths>0&&B.avgPathConfidence>=.7,Q=s.useMemo(()=>{const e=new Map;for(const s of U)e.set(s.prefix,s);return e},[U]),[X,Y]=s.useState(null),[Z,ee]=s.useState("lastHeard"),[se,te]=s.useState("desc"),[ae,ne]=s.useState(""),[le,ie]=s.useState(!1),[ce,pe]=s.useState(new Set),[fe,je]=s.useState(!1),[Ne,ve]=s.useState(null),[we,ke]=s.useState(null),[Le,$e]=s.useState(new Map),[_e,Fe]=s.useState(new Map),[ze,Ee]=s.useState(25),[Ie,He]=s.useState(25),Te=s.useRef(null),Oe=s.useMemo(()=>(null==r?void 0:r.neighbors)??{},[null==r?void 0:r.neighbors]),De=s.useMemo(()=>{const e=Date.now()/1e3-60*V.minutes;return Object.fromEntries(Object.entries(Oe).filter(([s,t])=>!i.has(s)&&(t.last_seen??0)>=e))},[Oe,i,V.minutes]),Ve=y(),Ue=null==r?void 0:r.local_hash,Be=s.useMemo(()=>{const e=new Map;if(!Ue||0===I.size)return e;for(const[s,t]of I)if(s.endsWith(`→${Ue}`)&&t.hops.length>1){const a=s.split("→")[0],n=t.hops[t.hops.length-1];e.set(a,n)}return e},[I,Ue]),Ae=s.useMemo(()=>{const e=new Map;if(!(null==Ve?void 0:Ve.latitude)||!(null==Ve?void 0:Ve.longitude))return e;for(const[s,t]of Object.entries(De))t.latitude&&t.longitude&&0!==t.latitude&&0!==t.longitude?e.set(s,Pe(Ve.latitude,Ve.longitude,t.latitude,t.longitude)):e.set(s,null);return e},[De,Ve]),{neighborHashSet:We,neighborSignalMap:Ge}=s.useMemo(()=>{const e=new Set,s=new Map;for(const t of E)e.add(t.hash),s.set(t.hash,{avgRssi:t.avgRssi,avgSnr:t.avgSnr});return{neighborHashSet:e,neighborSignalMap:s}},[E]),qe=s.useMemo(()=>{const e=ae.toLowerCase().trim(),s="neighbor"===e||"neighbors"===e,t=le||s,a=ce.size>0;return Object.fromEntries(Object.entries(De).filter(([n,r])=>{if(a){const e=function(e){return function(e){switch(e){case"room_server":return"room";case"repeater":return"repeater";case"companion":case"unknown":return"companion"}}(S(e).type)}(r);if(!ce.has(e))return!1}if(t&&!We.has(n))return!1;if(s)return!0;if(!e)return!0;const i=(r.node_name||r.name||"").toLowerCase(),c=l(n).toLowerCase();return i.includes(e)||c.includes(e)||n.toLowerCase().includes(e)}))},[De,ae,le,We,ce]),Ke=s.useMemo(()=>{const e=Object.entries(qe),s=ae.toLowerCase().trim(),t=2===s.length&&/^[0-9a-f]{2}$/i.test(s);return e.sort(([e,a],[n,r])=>{if(t){const t=l(e).toLowerCase(),a=l(n).toLowerCase(),r=t===s,i=a===s;if(r&&!i)return-1;if(i&&!r)return 1}let i=0;switch(Z){case"lastHeard":i=(a.last_seen||0)-(r.last_seen||0);break;case"distance":{const s=Ae.get(e)??null,t=Ae.get(n)??null;i=null===s&&null===t?0:null===s?1:null===t?-1:s-t;break}case"centrality":i=(z.get(e)||0)-(z.get(n)||0)}return"desc"===se?-i:i})},[qe,Z,se,Ae,z,ae]),Je=s.useMemo(()=>{let e=0,s=0,t=0,a=0,n=0;for(const[,l]of Ke){const r=S(l),i=l.latitude&&l.longitude&&0!==l.latitude&&0!==l.longitude;switch(r.type){case"room_server":t++;break;case"repeater":s++;break;case"companion":e++;break;case"unknown":n++}i&&a++}return{companions:e,repeaters:s,roomServers:t,total:Ke.length,withLocation:a,unknown:n}},[Ke]),Qe=s.useMemo(()=>new Set(F),[F]),Xe=s.useMemo(()=>0===ze?Ke:Ke.slice(0,Ie),[Ke,Ie,ze]);s.useEffect(()=>{He(ze||Ke.length)},[Z,se,ae,le,ce,ze,Ke.length]),s.useEffect(()=>{const e=e=>{e.target.closest("[data-dropdown]")||je(!1)};return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[]),s.useEffect(()=>{if(0===ze)return;const e=new IntersectionObserver(e=>{e[0].isIntersecting&&Ie<Ke.length&&He(e=>Math.min(e+ze,Ke.length))},{threshold:.1,rootMargin:"100px"});return Te.current&&e.observe(Te.current),()=>e.disconnect()},[ze,Ie,Ke.length]);const Ye=s.useCallback(e=>{Ee(e),He(e||Ke.length)},[Ke.length]),Ze=s.useCallback(e=>{Z===e?te(e=>"desc"===e?"asc":"desc"):(ee(e),te("desc"))},[Z]),es=s.useCallback(e=>{const s=De[e];(null==s?void 0:s.latitude)&&(null==s?void 0:s.longitude)&&0!==s.latitude&&0!==s.longitude&&ve(e)},[De]),ss=s.useCallback(()=>{ve(null)},[]),ts=s.useCallback((e,s)=>{Y({hash:e,name:s})},[]),as=s.useCallback(async(e,s)=>{if(s.stopPropagation(),!we){ke(e),$e(s=>{const t=new Map(s);return t.delete(e),t}),Fe(s=>{const t=new Map(s);return t.delete(e),t});try{const s=e.startsWith("0x")?e.slice(0,4):`0x${e.slice(0,2)}`,t=await C(s,30);t.success&&t.data?($e(s=>new Map(s).set(e,t.data)),setTimeout(()=>{$e(s=>{const t=new Map(s);return t.delete(e),t})},1e4)):(Fe(s=>new Map(s).set(e,t.error||"Ping failed")),setTimeout(()=>{Fe(s=>{const t=new Map(s);return t.delete(e),t})},5e3))}catch(t){const s=t instanceof Error?t.message:"Ping failed";Fe(t=>new Map(t).set(e,s)),setTimeout(()=>{Fe(s=>{const t=new Map(s);return t.delete(e),t})},5e3)}finally{ke(null)}}},[we]);return e.jsxs(M,{children:[e.jsx(R,{title:"Contacts",icon:e.jsx(oe,{}),controls:e.jsxs("div",{className:"flex items-center gap-3 sm:gap-5",children:[e.jsxs("div",{className:"hidden sm:flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Total:"}),e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${Je.total} discovered node${1!==Je.total?"s":""} on the mesh network`,children:[e.jsx(oe,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:Je.total})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Types:"}),Je.repeaters>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Repeaters",children:[e.jsx(K,{className:"w-3.5 h-3.5 text-sys-blue"}),e.jsx("span",{children:Je.repeaters})]}),Je.companions>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Companions",children:[e.jsx(de,{className:"w-3.5 h-3.5 text-fg-muted"}),e.jsx("span",{children:Je.companions})]}),Je.roomServers>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Room Servers",children:[e.jsx(G,{className:"w-3.5 h-3.5 text-sys-pink"}),e.jsx("span",{children:Je.roomServers})]}),Je.withLocation>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"With GPS location",children:[e.jsx(me,{className:"w-3.5 h-3.5 text-sys-green"}),e.jsx("span",{children:Je.withLocation})]}),Je.unknown>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Unknown type",children:[e.jsx(J,{className:"w-3.5 h-3.5 text-sys-amber"}),e.jsx("span",{children:Je.unknown})]})]})]}),e.jsxs("div",{className:"flex sm:hidden items-center gap-1.5",children:[e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(oe,{className:"w-3 h-3 text-fg-secondary"}),e.jsx("span",{children:Je.total})]}),Je.repeaters>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(K,{className:"w-3 h-3 text-sys-blue"}),e.jsx("span",{children:Je.repeaters})]}),Je.companions>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(de,{className:"w-3 h-3 text-fg-muted"}),e.jsx("span",{children:Je.companions})]}),Je.roomServers>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(G,{className:"w-3 h-3 text-sys-pink"}),e.jsx("span",{children:Je.roomServers})]}),e.jsx(_,{ranges:N,selectedIndex:O,onSelect:D,size:"sm"})]}),e.jsx("div",{className:"hidden sm:block",children:e.jsx(_,{ranges:N,selectedIndex:O,onSelect:D})})]})}),e.jsxs(P,{children:[T?e.jsx(ye,{neighbors:De,localNode:Ve??void 0,localHash:Ue,onRemoveNode:c,selectedNodeHash:Ne,onNodeSelected:ss}):e.jsx("div",{className:"surface-base radius-card aspect-video flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 border-2 border-sys-blue border-t-transparent rounded-full animate-spin"}),e.jsx("span",{className:"text-sm text-fg-muted",children:"Loading map..."})]})}),e.jsx(w,{noPadding:!0,children:T?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 px-3 sm:px-4 py-2.5 border-b border-edge-subtle",children:[e.jsx("span",{className:"icon-md flex items-center justify-center text-icon-card-title flex-shrink-0",children:e.jsx(oe,{})}),e.jsx("span",{className:"type-micro flex-shrink-0 mr-auto hidden sm:block",children:"Discovered Contacts"}),e.jsx(k,{type:"search",size:"sm",value:ae,onChange:e=>ne(e.target.value),placeholder:"Search...",leadingIcon:e.jsx(he,{className:"w-3.5 h-3.5"}),trailingIcon:ae?e.jsx("button",{onClick:()=>{ne(""),"neighbor"!==ae.toLowerCase().trim()&&"neighbors"!==ae.toLowerCase().trim()||ie(!1)},className:"text-fg-muted hover:text-fg-secondary",children:e.jsx(xe,{className:"w-3 h-3"})}):void 0,className:"w-24 sm:w-32 xl:w-44","aria-label":"Search contacts"}),e.jsx("div",{className:"h-4 w-px bg-border-subtle flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsxs("div",{className:"relative","data-dropdown":!0,children:[e.jsxs("button",{onClick:()=>je(!fe),className:Re(ce.size>0,{border:!0}),title:"Filter by contact type",children:[e.jsx(ue,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:"Filter"}),ce.size>0&&e.jsx("span",{className:"tabular-nums text-xs bg-sys-blue/30 px-1 rounded",children:ce.size})]}),fe&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 surface-elevated radius-inner py-1 min-w-[140px]",children:[[{key:"repeater",label:"Repeaters"},{key:"companion",label:"Companions"},{key:"room",label:"Rooms"}].map(({key:s,label:a})=>e.jsxs("button",{onClick:()=>{pe(e=>{const t=new Set(e);return t.has(s)?t.delete(s):t.add(s),t})},className:"w-full px-3 py-1.5 text-sm text-left hover-bg transition-base flex items-center gap-2",children:[e.jsx("span",{className:t("w-4 h-4 flex items-center justify-center radius-badge border",ce.has(s)?"bg-sys-blue border-sys-blue text-white":"border-edge-subtle"),children:ce.has(s)&&e.jsx(A,{className:"w-3 h-3"})}),e.jsx("span",{className:ce.has(s)?"text-fg-primary":"text-fg-secondary",children:a})]},s)),ce.size>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-edge-subtle my-1"}),e.jsx("button",{onClick:()=>pe(new Set),className:"w-full px-3 py-1.5 text-sm text-left text-fg-muted hover:text-fg-secondary hover-bg transition-base",children:"Clear filters"})]})]})]}),We.size>0&&e.jsxs("button",{onClick:()=>ie(!le),className:Re(le,{color:"success",border:!0}),title:le?"Show all contacts":"Show only MeshCore neighbors (direct RF contact)",children:[e.jsx(K,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:"Neighbors"})]})]}),e.jsx("div",{className:"h-4 w-px bg-border-subtle flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[Me.map(({field:s,icon:a,label:n})=>e.jsxs("button",{onClick:()=>Ze(s),className:Re(Z===s),title:`Sort by ${n.toLowerCase()}`,children:[e.jsx(a,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:n}),Z===s&&e.jsx(ge,{className:t("w-3 h-3","asc"===se&&"rotate-180")})]},s)),e.jsx("div",{className:"h-4 w-px bg-border-subtle"}),e.jsxs(L,{value:ze,onChange:Ye,className:"w-auto min-w-[50px] [&_button]:py-1 [&_button]:px-2 [&_button]:text-xs [&_button]:min-h-0","aria-label":"Items per page",children:[e.jsx($,{value:25,children:"25"}),e.jsx($,{value:50,children:"50"}),e.jsx($,{value:100,children:"100"}),e.jsx($,{value:0,children:"All"})]})]})]}),Ke.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden sm:grid contacts-grid-header border-b border-edge-subtle/50 px-3 py-2 type-micro text-fg-muted",children:[e.jsx("div",{className:"contacts-col-node",children:"Node"}),e.jsx("div",{className:"contacts-col-signal text-right",children:"Signal"}),e.jsx("div",{className:"contacts-col-distance text-right",children:"Distance"}),e.jsx("div",{className:"contacts-col-centrality text-right",children:"Centrality"}),e.jsx("div",{className:"contacts-col-seen text-right",children:"Last Seen"}),e.jsx("div",{className:"contacts-col-actions"})]}),e.jsx("div",{className:"divide-y divide-edge-subtle/30",children:Xe.map(([s,t])=>{const a=l(s),n=Qe.has(s),r=We.has(s),i=Ae.get(s)??null,c=z.get(s)||0,o=r?Ge.get(s):void 0,d=a?Q.get(a)??null:null,m=W.get(s)??Se;let x=null;if(!r&&Ue&&I.size>0){const e=`${s}→${Ue}`,t=I.get(e);if(t&&t.hops.length>0){const e=t.hops[0],s=Object.keys(Oe).find(s=>s.toUpperCase().startsWith(e.toUpperCase())),a=s?Oe[s]:null;x={prefix:e,name:(null==a?void 0:a.node_name)??(null==a?void 0:a.name)??null,hopCount:t.hopCount}}}const h=H.has(s),u=Be.get(s)??null;return e.jsx(Ce,{hash:s,contact:t,isHub:n,isNeighbor:r,distance:i,centrality:c,sparklineData:m,neighborSignal:o,collisionInfo:d,isViterbiResolved:q,isPinging:null!==we,isPingingThis:we===s,pingResult:Le.get(s),pingError:_e.get(s),gatewayInfo:x,lastForwarderPrefix:u,isMobile:h,onRowClick:es,onPing:as,onRemove:ts},s)})}),ze>0&&Ie<Ke.length&&e.jsxs("div",{ref:Te,className:"flex items-center justify-center py-4 text-fg-muted",children:[e.jsx(re,{className:"w-4 h-4 animate-spin mr-2"}),e.jsx("span",{className:"text-xs",children:"Loading more..."})]}),e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-t border-edge-subtle/50 text-xs text-fg-muted",children:[e.jsxs("span",{className:"tabular-nums",children:["Showing ",Xe.length," of ",Ke.length]}),ze>0&&Ie<Ke.length&&e.jsx("button",{onClick:()=>He(e=>Math.min(e+ze,Ke.length)),className:"text-sys-blue hover:text-sys-blue/80 transition-base",children:"Load more"})]})]}):e.jsxs("div",{className:"roster-empty",children:[e.jsx(oe,{className:"roster-empty-icon"}),e.jsx("div",{className:"type-label text-fg-secondary",children:"No Contacts Discovered"}),e.jsx("div",{className:"type-data-xs text-fg-muted mt-1",children:"Contacts will appear here as they advertise on the mesh network."})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-edge-subtle",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded bg-elevated animate-pulse"}),e.jsx("div",{className:"w-32 h-4 rounded bg-elevated animate-pulse"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-16 h-6 rounded bg-elevated animate-pulse"}),e.jsx("div",{className:"w-24 h-6 rounded bg-elevated animate-pulse"}),e.jsx("div",{className:"w-16 h-6 rounded bg-elevated animate-pulse"})]})]}),e.jsx("div",{className:"px-3 py-3 space-y-3",children:[...Array(5)].map((s,t)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 rounded bg-elevated animate-pulse"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-4 w-32 rounded bg-elevated animate-pulse"}),e.jsx("div",{className:"h-3 w-24 rounded bg-elevated animate-pulse"})]}),e.jsx("div",{className:"w-12 h-4 rounded bg-elevated animate-pulse"}),e.jsx("div",{className:"w-16 h-4 rounded bg-elevated animate-pulse"})]},t))})]})})]}),e.jsx(be,{isOpen:!!X,title:"Remove Contact",message:`Are you sure you would like to remove ${(null==X?void 0:X.name)||"this contact"}?`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{X&&c(X.hash),Y(null)},onCancel:()=>Y(null)})]})}},Symbol.toStringTag,{value:"Module"}));export{Le as C,we as P};
|