const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PathMapMapLibre-DJ-BX1tG.js","assets/index-BuFgUdF6.js","assets/BasemapLayer-9KgDoniZ.js","assets/car-qFqeHYL3.js","assets/useMapViewStore-CYTMhi1e.js","assets/index-tC-yebOi.js","assets/index-CjY609r3.js","assets/index-C9lzYVvf.css","assets/maplibre-gl-B1CfjdFi.css"])))=>i.map(i=>d[i]);
import{e as Se,bN as nt,bO as Ps,q as rt,n as lt,j as e,c as H,B as ns,t as it,r as m,a1 as rs,V as B,ao as je,bP as ct,bQ as Bs,bR as Ms,bS as Ls,aa as oe,bT as Rs,bU as Hs,bV as Fs,bW as me,bX as Xe,bY as Ze,_ as ot,bZ as dt,b_ as xt,b$ as mt,c0 as ht,c1 as ut,c2 as pt,m as ce,ax as le,a3 as ft,a0 as gt,c3 as J,c4 as yt,c5 as ie,c6 as jt,c7 as bt,c8 as hs,c9 as Nt,ca as vt,cb as wt,cc as kt,cd as Ct,ce as _t,cf as Je,cg as St,at as Tt,a6 as Ds,ch as Pt,ci as Bt,cj as Mt,ck as Lt,aC as As,aD as Es,d as We,cl as Rt,aE as Ht,cm as Ft,cn as ls,co as Dt}from"./index-BuFgUdF6.js";import{C as At,u as Et}from"./chevron-up-DLh9FCfg.js";import{p as zt,e as zs,g as It,b as $t}from"./primitives-BvUzgqAa.js";import{u as Ut,r as Ot,a as Vt,b as Gt,c as Qt,d as qt,i as Wt}from"./consumer-registry-YGO4kl9s.js";import{D as Pe,R as Ie,P as Be,g as Kt}from"./badge-colors-Dl76Mz8m.js";import{g as Is,e as Ce,a as $s}from"./chat-utils-DXcrFuPC.js";import{S as $e,i as Ue,a as Yt,g as us}from"./SignalIndicator-DlCNJ53K.js";import{A as Xt}from"./arrow-up-m4nuWusa.js";import{A as he}from"./arrow-right-DMRkyqKR.js";import{A as Us}from"./arrow-down-P3Gn06Ex.js";import{C as is}from"./chevron-right-Bn33xBBB.js";import{d as Zt}from"./payload-detail-C-jD4akC.js";import{M as Oe}from"./map-pin-DUIK7gpx.js";import{C as Jt}from"./circle-question-mark-NwPFAIxO.js";import{L as ea}from"./layers-BrblF2UQ.js";import{H as Os}from"./hash-B0n1oBpr.js";import{C as de}from"./clock-CiO_tPRQ.js";import{L as cs,R as sa}from"./route-D01DJn_x.js";import{A as ta}from"./activity-CU9M_dkq.js";import{D as aa}from"./database-6NHqXCMW.js";import{H as na,D as es,u as ra}from"./useMapViewStore-CYTMhi1e.js";import{S as ve}from"./shield-BMVOQHpc.js";import{C as Vs}from"./MqttModeBadge-BeRzf62U.js";import{Z as ps}from"./zap-CcGk7ixp.js";/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const la=[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],ia=Se("corner-down-right",la);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ca=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Gs=Se("message-circle-question-mark",ca);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const oa=[["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}],["path",{d:"m9 17-5-5 5-5",key:"nvlc11"}]],da=Se("reply",oa);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const xa=[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]],fs=Se("stethoscope",xa);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ma=[["path",{d:"M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978",key:"1n3hpd"}],["path",{d:"M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978",key:"rfe1zi"}],["path",{d:"M18 9h1.5a1 1 0 0 0 0-5H18",key:"7xy6bh"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z",key:"1mhfuq"}],["path",{d:"M6 9H4.5a1 1 0 0 1 0-5H6",key:"tex48p"}]],gs=Se("trophy",ma);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ha=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],we=Se("user",ha);function ua(s){s.values.forEach(a=>a.stop())}function ss(s,a){[...a].reverse().forEach(n=>{const i=s.getVariant(n);i&&Ps(s,i),s.variantChildren&&s.variantChildren.forEach(l=>{ss(l,a)})})}function pa(s,a){if(Array.isArray(a))return ss(s,a);if(typeof a=="string")return ss(s,[a]);Ps(s,a)}function fa(){const s=new Set,a={subscribe(t){return s.add(t),()=>void s.delete(t)},start(t,n){const i=[];return s.forEach(l=>{i.push(nt(l,t,{transitionOverride:n}))}),Promise.all(i)},set(t){return s.forEach(n=>{pa(n,t)})},stop(){s.forEach(t=>{ua(t)})},mount(){return()=>{a.stop()}}};return a}function ga(){const s=rt(fa);return lt(s.mount,[]),s}function ya({"aria-label":s="Page navigation",className:a,...t}){return e.jsx("nav",{"aria-label":s,...t,className:H("flex gap-x-2",a)})}function ja({onClick:s,disabled:a=!1,className:t,children:n="Previous"}){return e.jsx("span",{className:H("grow basis-0",t),children:e.jsxs(ns,{plain:!0,onClick:s,disabled:a,"aria-label":"Previous page",className:H("gap-1",a&&"invisible"),children:[e.jsx("svg",{className:"size-4 stroke-current",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M2.75 8H13.25M2.75 8L5.25 5.5M2.75 8L5.25 10.5",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})}),n]})})}function ba({onClick:s,disabled:a=!1,className:t,children:n="Next"}){return e.jsx("span",{className:H("flex grow basis-0 justify-end",t),children:e.jsxs(ns,{plain:!0,onClick:s,disabled:a,"aria-label":"Next page",className:H("gap-1",a&&"invisible"),children:[n,e.jsx("svg",{className:"size-4 stroke-current",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M13.25 8L2.75 8M13.25 8L10.75 10.5M13.25 8L10.75 5.5",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})})]})})}function Na({className:s,...a}){return e.jsx("span",{...a,className:H("hidden items-baseline gap-x-2 sm:flex",s)})}function va({page:s,current:a=!1,onClick:t,className:n,children:i}){return e.jsx(ns,{plain:!a,outline:a,onClick:()=>t==null?void 0:t(s),"aria-label":`Page ${s}`,"aria-current":a?"page":void 0,className:H("min-w-[2.25rem] before:absolute before:-inset-px before:rounded-lg",a&&"before:bg-subtle-fill",n),children:i??s})}function wa({className:s,...a}){return e.jsx("span",{"aria-hidden":"true",...a,className:H("w-[2.25rem] select-none text-center text-sm text-fg-muted",s),children:"…"})}function ka(s,a,t=1){if(a<=7)return Array.from({length:a},(x,g)=>g+1);const n=Math.max(s-t,1),i=Math.min(s+t,a),l=n>2,r=i<a-1;if(!l&&r){const x=3+2*t;return[...Array.from({length:x},(u,y)=>y+1),"gap",a]}if(l&&!r){const x=3+2*t;return[1,"gap",...Array.from({length:x},(u,y)=>a-x+y+1)]}return[1,"gap",...Array.from({length:i-n+1},(x,g)=>n+g),"gap",a]}const ur=it(s=>({requestedHash:null,requestChannel:a=>s({requestedHash:a}),clearRequest:()=>s({requestedHash:null})}));function Ca(s){if(s.length===0)return[];const a=[];let t=0;for(;t<s.length;){const n=s[t],i=n.packet_hash;let l=1,r=n;if(i)for(;t+l<s.length&&s[t+l].packet_hash===i;)s[t+l].packet_origin==="tx_local"&&(r=s[t+l]),l++;a.push({packet:r,dupeCount:l}),t+=l}return a}const _a={rx:{icon:Us,label:"Rx",badgeColor:Pe.rx,avatarBg:"bg-sys-green/15",avatarText:"text-sys-green"},forward:{icon:he,label:"Fwd",badgeColor:Pe.forward,avatarBg:"bg-sys-cyan/15",avatarText:"text-sys-cyan"},duplicate:{icon:rs,label:"Dupe",badgeColor:Pe.duplicate,avatarBg:"bg-fg-muted/15",avatarText:"text-fg-secondary"},tx:{icon:Xt,label:"Tx",badgeColor:Pe.tx,avatarBg:"bg-sys-indigo/15",avatarText:"text-sys-indigo"},dropped:{icon:ia,label:"Drop",badgeColor:Pe.dropped,avatarBg:"bg-sys-amber/15",avatarText:"text-sys-amber"}},ys={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},Sa={sm:"w-8 h-8",md:"w-9 h-9",lg:"w-10 h-10"};function Ta(s){return s.packet_origin==="tx_local"?"tx":s.packet_origin==="tx_forward"?"forward":s.is_duplicate?"duplicate":s.transmitted?"forward":s.drop_reason?"dropped":"rx"}function Pa({packet:s,showLabel:a=!0,variant:t="avatar",size:n="sm"}){const i=Ta(s),l=_a[i],r=l.icon;return t==="avatar"?e.jsx("div",{className:H("flex items-center justify-center rounded-full flex-shrink-0",l.avatarBg,Sa[n]),children:e.jsx(r,{className:H(ys[n],l.avatarText)})}):e.jsxs(B,{color:l.badgeColor,children:[e.jsx(r,{className:ys[n]}),a&&l.label]})}const Qs=m.memo(Pa);function Ba({path:s,localHash:a,className:t}){if(!s||s.length===0)return e.jsx("span",{className:H("text-fg-muted text-xs",t),children:"—"});const n=a?je(a):null;return e.jsx("span",{className:H("flex items-center gap-0.5 type-data-xs overflow-hidden",t),children:s.map((i,l)=>{const r=l===s.length-1,c=n!==null&&ct(i.toUpperCase(),n);return e.jsxs("span",{className:"flex items-center flex-shrink-0",children:[c?e.jsx("span",{className:"px-1 py-0.5 rounded bg-sys-amber/20 text-sys-amber text-[9px] font-medium",children:"You"}):e.jsx("span",{className:"px-1 py-0.5 rounded bg-subtle-fill-hover text-fg-secondary",children:i.toUpperCase()}),!r&&e.jsx(is,{className:"w-2.5 h-2.5 text-fg-muted mx-0.5 flex-shrink-0"})]},`${i}-${l}`)})})}const qs=m.memo(Ba);function Ws({channelName:s,onClick:a,active:t,compact:n,className:i}){const l=s.startsWith("#")?s:`#${s}`,r=H("inline-flex items-center flex-shrink-0","font-medium",n?"px-1.5 h-4 leading-4 rounded text-[10px]":"px-2 h-5 leading-5 rounded text-xs",t?"bg-sys-blue/20 text-sys-blue":"bg-sys-blue/10 text-sys-blue",a&&!t&&"hover:bg-sys-blue/20 cursor-pointer",i);return a?e.jsx("button",{type:"button",onClick:a,className:r,children:l}):e.jsx("span",{className:r,children:l})}function Ks({packet:s}){return s._remoteSource?e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge("teal"),children:"HTTP"}):s._mqttSource&&!s._remoteSource?e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge("purple"),children:"MQTT"}):null}function ge(s){return{"--data-box-accent":me[s]}}function Ys(s){const a=s.payload_type_name||Hs(s.payload_type??s.type),t=s.route_type_name||Fs(s.route_type??s.route),n=Be[a]??"zinc",i=Ie[t]??"zinc";return{payloadType:a,routeType:t,payloadColor:n,routeColor:i}}function Ve(s){if(!s)return[];if(Array.isArray(s))return s;try{const a=JSON.parse(s);return Array.isArray(a)?a:[]}catch{return[]}}function Xs(s,a){if(a){const t=a(s);return{name:t.name,isCompanion:t.isCompanion,isRepeater:t.isRepeater}}return{name:null,isCompanion:!1,isRepeater:!1}}function Ma({packet:s,onClick:a,localHash:t,neighbors:n,resolveSource:i,isFlashing:l=!1,isTraceHighlighted:r,onTraceHover:c,traceTag:x,onViewTraceReport:g,dupeGroupPosition:u,isDupeGroupHovered:y=!1,onDupeGroupHover:k,dupeCount:b,getDecodedContent:d,onChannelClick:C}){const M=b?!1:Bs(s.is_duplicate),o=u!==void 0,{payloadType:N,routeType:f,payloadColor:_,routeColor:v}=Ys(s),p=s.packet_origin==="tx_local",I=N==="TRACE",V=Ve(s.original_path),q=Ve(s.forwarded_path),Y=q.length>0?q:V,E=s.src_hash?je(s.src_hash):null,{name:X,isRepeater:F}=Xs(s,i);let D=null,W=null,Z=null,O=null;if(N==="GRP_TXT"&&d){const z=d(s);z!=null&&z.decrypted&&(W=z.senderName,Z=z.channelName,O=z.channelHash,z.text&&(D=z.text))}else if(N==="TXT_MSG"&&s.raw_packet)try{const z=Ms.fromHex(s.raw_packet);if(z.success&&z.packet){const L=Ls(z.packet.payload);L&&!L.encrypted&&(D=L.text)}}catch{}const T=W||(F?null:X),$=!!T,ee=!$&&F&&!!X,ne=!$&&!ee&&N==="GRP_TXT"&&!D,P=s.payload_length??s.length??0;s.lbt_attempts;const h=m.useCallback(()=>{I&&x&&g?g(x):a(s)},[I,x,g,a,s]),se=m.useCallback(()=>{I&&x&&c&&c(x),o&&k&&s.packet_hash&&k(s.packet_hash)},[I,x,c,o,k,s.packet_hash]),te=m.useCallback(()=>{c&&c(null),k&&k(null)},[c,k]),R=me[_]||me.zinc,U=y,G=()=>{const z={pointerEvents:"none"};return u==="first"?{...z,borderTop:`2px solid ${R}`,borderLeft:`2px solid ${R}`,borderRight:`2px solid ${R}`,borderBottom:"none",borderRadius:"8px 8px 0 0",inset:"-2px -2px 0 -2px"}:u==="middle"?{...z,borderTop:"none",borderLeft:`2px solid ${R}`,borderRight:`2px solid ${R}`,borderBottom:"none",borderRadius:0,inset:"0 -2px"}:u==="last"?{...z,borderTop:"none",borderLeft:`2px solid ${R}`,borderRight:`2px solid ${R}`,borderBottom:`2px solid ${R}`,borderRadius:"0 0 8px 8px",inset:"0 -2px -2px -2px"}:{...z,border:`2px solid ${R}`,borderRadius:"8px",inset:"-2px"}};return e.jsxs("div",{onClick:h,onMouseEnter:se,onMouseLeave:te,className:H("group relative cursor-pointer","hover:bg-subtle-fill",M&&!y&&"opacity-40",l&&"flash-row",p&&"bg-sys-indigo/5",r&&"bg-sys-teal/10"),children:[e.jsx("div",{className:H("absolute pointer-events-none transition-opacity duration-75",o?U?"opacity-100":"opacity-0":"opacity-0 group-hover:opacity-100"),style:G()}),e.jsxs("div",{className:"relative flex items-center gap-2 min-[600px]:gap-3 px-2 py-2 min-[600px]:px-3 min-[600px]:py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("div",{className:"relative flex-shrink-0",children:$?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-1 ring-edge-subtle",style:{backgroundColor:Is(Ce(T).cleanName)},children:Ce(T).emoji?e.jsx("span",{className:"text-base leading-none",children:Ce(T).emoji}):e.jsx("span",{className:"text-white text-[10px] font-bold tracking-tighter",children:$s(T)})}):ee?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(oe,{className:"size-5 text-sys-blue"})}):ne?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center bg-zinc-500/20 ring-1 ring-edge-subtle",children:e.jsx(Gs,{className:"size-4 text-fg-muted"})}):e.jsx(Qs,{packet:s,variant:"avatar",size:"sm"})}),e.jsx("div",{className:"min-w-0",children:$?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-[13px] text-fg-primary font-sans truncate max-w-[90px]",children:T}),E&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate",children:E})]}):ee?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-[13px] text-fg-primary font-sans truncate max-w-[90px]",children:X}),E&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate",children:E})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-bold text-[13px] text-fg-primary font-sans truncate",children:E||"—"}),X&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate max-w-[70px]",children:X})]})})]}),e.jsxs("div",{className:"flex-1 flex items-center gap-1 min-[600px]:gap-1.5 min-[900px]:gap-2 min-w-0",children:[e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge(_),children:N}),p&&e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge("indigo"),children:"LOCAL"}),e.jsx(Ks,{packet:s}),b&&b>1&&e.jsxs("span",{className:"data-box data-box-compact flex-shrink-0",children:["×",b]}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge(v),children:f}),e.jsxs("span",{className:"hidden min-[520px]:inline type-data-xs text-fg-muted flex-shrink-0",children:[P,"B"]}),e.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:D||Z?e.jsxs("span",{className:"text-[11px] text-fg-secondary truncate block flex items-center gap-1",children:[Z&&e.jsx(Ws,{channelName:Z,compact:!0,onClick:C&&O?z=>{z.stopPropagation(),C(O)}:void 0}),D&&e.jsx("span",{className:"italic truncate",children:D})]}):e.jsx(qs,{path:Y,localHash:t})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("span",{className:"data-box data-box-compact",children:Rs(s.timestamp)}),e.jsx($e,{rssi:s.rssi,snr:s.snr,compact:!0,showValues:!0,validated:Ue(s)})]})]})]})}function La({packet:s,onClick:a,localHash:t,neighbors:n,resolveSource:i,isFlashing:l=!1,isTraceHighlighted:r,traceTag:c,onViewTraceReport:x,dupeGroupPosition:g,isDupeGroupHovered:u=!1,onDupeGroupHover:y,dupeCount:k,getDecodedContent:b,onChannelClick:d}){const{payloadType:C,routeType:M,payloadColor:o,routeColor:N}=Ys(s),f=s.packet_origin==="tx_local",_=C==="TRACE",v=k?!1:Bs(s.is_duplicate),p=Ve(s.original_path),I=Ve(s.forwarded_path),V=I.length>0?I:p,q=s._hopCount??V.length,Y=s.src_hash?je(s.src_hash):null,{name:E,isRepeater:X}=Xs(s,i);let F=null,D=null,W=null,Z=null;if(C==="GRP_TXT"&&b){const R=b(s);R!=null&&R.decrypted&&(D=R.senderName,W=R.channelName,Z=R.channelHash,R.text&&(F=R.text))}else if(C==="TXT_MSG"&&s.raw_packet)try{const R=Ms.fromHex(s.raw_packet);if(R.success&&R.packet){const U=Ls(R.packet.payload);U&&!U.encrypted&&(F=U.text)}}catch{}const O=D||(X?null:E),T=!!O,$=!T&&X&&!!E,ee=!T&&!$&&C==="GRP_TXT"&&!F,ne=s.payload_length??s.length??0,P=s.lbt_attempts??0,h=()=>{_&&c&&x?x(c):a(s)},se=me[o]||me.zinc,te=()=>{if(!g)return{opacity:0};const R=u?1:.4,U=u?"3px":"2px";return g==="first"?{backgroundColor:se,opacity:R,width:U,top:"6px",bottom:0,borderRadius:"0 9999px 0 0"}:g==="middle"?{backgroundColor:se,opacity:R,width:U,top:0,bottom:0,borderRadius:0}:g==="last"?{backgroundColor:se,opacity:R,width:U,top:0,bottom:"6px",borderRadius:"0 0 9999px 0"}:{backgroundColor:se,opacity:R,width:U,top:"6px",bottom:"6px",borderRadius:"9999px"}};return e.jsxs("div",{onClick:h,className:H("relative pl-3 pr-2.5 py-2 cursor-pointer","active:bg-subtle-fill-hover",v&&"opacity-40",l&&"flash-row",f&&"bg-sys-indigo/5",r&&"bg-sys-teal/10"),children:[e.jsx("div",{className:"absolute left-0 transition-all",style:te()}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"relative flex-shrink-0 mt-0.5",children:T?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-1 ring-edge-subtle",style:{backgroundColor:Is(Ce(O).cleanName)},children:Ce(O).emoji?e.jsx("span",{className:"text-base leading-none",children:Ce(O).emoji}):e.jsx("span",{className:"text-white text-[10px] font-bold tracking-tighter",children:$s(O)})}):$?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(oe,{className:"size-5 text-sys-blue"})}):ee?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center bg-zinc-500/20 ring-1 ring-edge-subtle",children:e.jsx(Gs,{className:"size-4 text-fg-muted"})}):e.jsx(Qs,{packet:s,variant:"avatar",size:"sm"})}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[T?e.jsx("span",{className:"font-medium text-[14px] text-fg-primary tracking-tight truncate min-w-0",children:O}):$?e.jsx("span",{className:"font-medium text-[14px] text-fg-primary tracking-tight truncate min-w-0",children:E}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold text-[14px] text-fg-primary tracking-tight flex-shrink-0",children:Y||"—"}),E&&e.jsx("span",{className:"text-[12px] text-fg-muted truncate min-w-0",children:E})]}),e.jsx("div",{className:"flex-1"}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge(o),children:C}),f&&e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge("indigo"),children:"LOCAL"}),e.jsx(Ks,{packet:s}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:ge(N),children:M}),k&&k>1&&e.jsxs("span",{className:"data-box data-box-compact flex-shrink-0",children:["×",k]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx("span",{className:"type-data-xs text-fg-muted w-[28px] text-right",children:s.rssi}),e.jsx($e,{rssi:s.rssi,compact:!0,showValues:!1,validated:Ue(s)})]})]}),e.jsxs("div",{className:"flex items-center gap-1 type-data-xs text-fg-muted",children:[e.jsx("span",{className:"data-box data-box-compact flex-shrink-0",children:Rs(s.timestamp)}),ne>0&&e.jsxs("span",{children:[ne,"B"]}),P>0&&e.jsxs("span",{className:P>1?"text-sys-amber/60":void 0,children:["LBT:",P]}),s.snr!=null&&e.jsxs("span",{children:[s.snr.toFixed(0),"dB"]}),F||W?e.jsxs("span",{className:"text-[11px] text-fg-secondary truncate flex items-center gap-1 min-w-0",children:[W&&e.jsx(Ws,{channelName:W,compact:!0,onClick:d&&Z?R=>{R.stopPropagation(),d(Z)}:void 0}),F&&e.jsx("span",{className:"italic truncate",children:F})]}):q>0?e.jsx(qs,{path:V,localHash:t}):null]})]})]})]})}const Ra=m.memo(Ma),Ha=m.memo(La);function Fa(s,a,t,n,i=!1){const l=s.toUpperCase(),r=[],c=t&&Xe(l,t);c&&r.push(t);for(const b of Object.keys(a))Xe(l,b)&&r.push(b);if(i&&c&&t&&r.length===1)return{matches:r,probability:1,bestMatch:t};if(i&&c&&r.length>1){const b=r.filter(d=>d!==t);if(b.length===1)return{matches:r,probability:1,bestMatch:b[0]}}const x=r.length>0?1/r.length:0,g=[...r].sort();let u=null,y=-1;if(g.length===1)u=g[0];else if(g.length>1&&n){for(const b of g){const d=n.get(b),C=d?typeof d=="number"?d:d.combinedScore:0;C>y&&(y=C,u=b)}u||(u=g[0])}else g.length>0&&(u=g[0]);let k=x;if(r.length>1&&n&&y>0){let b=0;for(const d of r){const C=n.get(d);b+=C?typeof C=="number"?C:C.combinedScore:0}b>0&&(k=Math.min(.95,y/b))}return{matches:r,probability:k,bestMatch:u}}function Da(s,a,t,n){const l=(t-s)*Math.PI/180,r=(n-a)*Math.PI/180,c=Math.sin(l/2)*Math.sin(l/2)+Math.cos(s*Math.PI/180)*Math.cos(t*Math.PI/180)*Math.sin(r/2)*Math.sin(r/2);return 6371e3*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))}function Aa(s){return s<100?1:s<500?.9:s<1e3?.7:s<5e3?.5:s<1e4?.3:.1}const Ea=m.lazy(()=>ot(()=>import("./PathMapMapLibre-DJ-BX1tG.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])));function za(s,a,t,n,i=!1,l,r,c){const x=dt(a);let g;r&&(g=xt(r,s,{position:c,isLastHop:i}).confidence);const{matches:u,probability:y}=Fa(s,x,n,l,i),k=u.length,b=[],d=s.toUpperCase(),C=t&&t.latitude!==void 0&&t.longitude!==void 0&&(t.latitude!==0||t.longitude!==0);for(const o of u){if(n&&Xe(d,n)&&o===n&&C&&t){b.push({hash:o,name:t.name||"Local Node",latitude:t.latitude,longitude:t.longitude,probability:i?1:y,isLocal:!0});continue}const N=x[o];N!=null&&N.latitude&&(N!=null&&N.longitude)&&!(N.latitude===0&&N.longitude===0)&&b.push({hash:o,name:N.node_name||N.name||"Unknown",latitude:N.latitude,longitude:N.longitude,probability:y,isLocal:!1,isDirectNeighbor:N.zero_hop===!0})}const M=b.length;if(M===1)b[0].probability=g??1;else if(M>1)if(g!==void 0&&g>0){const o=b[0];o.probability=g;const N=1-g,f=M-1;b.slice(1).forEach(_=>{_.probability=N/f})}else{let o=0;const N=b.map(f=>{if(f.isLocal)return{candidate:f,score:1};const _=l==null?void 0:l.get(f.hash);let v=.5;if(C&&t){const I=Da(t.latitude,t.longitude,f.latitude,f.longitude);v=Aa(I)}let p;return _?p=v*.3+_.hopConsistencyScore*.3+_.frequencyScore*.4:(p=v,f.isDirectNeighbor&&(p=Math.max(p,.8))),o+=p,{candidate:f,score:p}});if(o>0)N.forEach(({candidate:f,score:_})=>{f.probability=Math.min(.95,_/o)});else{const f=1/M;b.forEach(_=>_.probability=f)}}return{candidates:b,totalMatches:k}}function Ia(s,a,t,n,i,l){if(!s||s.length===0)return{hops:[],overallConfidence:0,hasValidPath:!1};const r=s.length-1,c=s.map((u,y)=>{const k=y===r,b=s.length-y,{candidates:d,totalMatches:C}=za(u,a,t,n,k,i,l,b),M=d.length>0?Math.max(...d.map(o=>o.probability)):0;return{prefix:u,candidates:d,confidence:M,totalMatches:C}}),x=c.reduce((u,y)=>y.confidence===0?0:u*y.confidence,1),g=c.some(u=>u.candidates.length>0);return{hops:c,overallConfidence:x,hasValidPath:g}}function $a(s){return`${(s*100).toFixed(0)}%`}function Ua(s){return s>=1?"text-sys-green":s>=.5?"text-sys-indigo":s>=.25?"text-signal-poor":s>0?"text-sys-red":"text-fg-muted"}function Oa(s,a,t){let n;return a===0?n=t.muted:s>=1?n=t.success:s>=.5?n=t.secondary:s>=.25?n=t.poor:s>0?n=t.danger:n=t.muted,{color:n}}class Va extends m.Component{constructor(a){super(a),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?e.jsxs("div",{className:"h-[200px] flex items-center justify-center text-fg-muted",children:[e.jsx(Ze,{className:"w-4 h-4 mr-2"}),"Map failed to load"]}):this.props.children}}function Ge({path:s,neighbors:a,localNode:t,localHash:n,srcHash:i,dstHash:l,neighborAffinity:r,prefixLookup:c,hubNodes:x,traceSnr:g,advertiserSource:u}){const[y,k]=m.useState(null),b=m.useMemo(()=>{if(!u)return null;const f=u.nodeType==="wardrive";return{prefix:u.prefix||"??",candidates:[{hash:u.publicKey||u.prefix||"source",name:u.name,latitude:u.latitude,longitude:u.longitude,probability:1,isLocal:!1,isWardrive:f}],confidence:1,totalMatches:1,isSource:!0}},[u]),d=m.useMemo(()=>{if(u||!i)return null;const f=je(i),_=a[i];if((_==null?void 0:_.latitude)&&(_==null?void 0:_.longitude)&&!(_.latitude===0&&_.longitude===0))return{prefix:f,candidates:[{hash:i,name:_.node_name||_.name||"Source",latitude:_.latitude,longitude:_.longitude,probability:1,isLocal:!1,isDirectNeighbor:_.zero_hop===!0}],confidence:1,totalMatches:1,isSource:!0};const p=(_==null?void 0:_.node_name)||(_==null?void 0:_.name)||i.slice(0,8);return{prefix:f,candidates:[{hash:i,name:p,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isSource:!0}},[u,i,a]),C=m.useMemo(()=>{const f=l!=null&&l.startsWith("0x")?l.slice(2):l;if((!f||f==="00"||f==="0000000000000000")&&t&&n){const q=je(n),Y=t.latitude!==0||t.longitude!==0;return{prefix:q,candidates:[{hash:n,name:t.name||"Local Node",latitude:Y?t.latitude:0,longitude:Y?t.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}if(!l)return null;const v=je(l);if(n&&l===n&&t){const q=t.latitude!==0||t.longitude!==0;return{prefix:v,candidates:[{hash:l,name:t.name||"Local Node",latitude:q?t.latitude:0,longitude:q?t.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}const p=a[l];if((p==null?void 0:p.latitude)&&(p==null?void 0:p.longitude)&&!(p.latitude===0&&p.longitude===0))return{prefix:v,candidates:[{hash:l,name:p.node_name||p.name||"Destination",latitude:p.latitude,longitude:p.longitude,probability:1,isLocal:!1,isDirectNeighbor:p.zero_hop===!0}],confidence:1,totalMatches:1,isDestination:!0};const V=(p==null?void 0:p.node_name)||(p==null?void 0:p.name)||l.slice(0,8);return{prefix:v,candidates:[{hash:l,name:V,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isDestination:!0}},[l,a,t,n]),M=m.useMemo(()=>Ia(s,a,t,n,r,c),[s,a,t,n,r,c]),o=m.useMemo(()=>{const f=[];b?f.push(b):d&&f.push(d),f.push(...M.hops),C&&f.push(C);const _=f.reduce((p,I)=>I.confidence===0?0:p*I.confidence,1),v=f.some(p=>p.candidates.some(I=>I.latitude!==0||I.longitude!==0));return{hops:f,overallConfidence:_,hasValidPath:v}},[b,d,M,C]),N=m.useMemo(()=>{const f=getComputedStyle(document.documentElement);return{success:f.getPropertyValue("--sys-green").trim()||"#39D98A",secondary:f.getPropertyValue("--sys-indigo").trim()||"#F9D26F",poor:f.getPropertyValue("--signal-poor").trim()||"#FF8A5C",danger:f.getPropertyValue("--sys-red").trim()||"#FF5C7A",muted:f.getPropertyValue("--text-muted").trim()||"#767688"}},[]);return o.hasValidPath?e.jsxs("div",{className:"h-full flex flex-col space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-muted",children:"Path Confidence:"}),e.jsx("span",{className:Ua(o.overallConfidence),children:$a(o.overallConfidence)}),e.jsx("button",{className:"text-fg-muted hover:text-fg-secondary transition-colors",title:"Confidence is calculated based on how many known nodes match each path prefix. Multiple matches reduce confidence due to collision probability.",children:e.jsx(Jt,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-sys-green"}),e.jsx("span",{className:"text-fg-muted",children:"Exact"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-sys-indigo"}),e.jsx("span",{className:"text-fg-muted",children:"Multi"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-fg-muted"}),e.jsx("span",{className:"text-fg-muted",children:"Unknown"})]})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx(Va,{children:e.jsx(m.Suspense,{fallback:e.jsx("div",{className:"h-full bg-elevated flex items-center justify-center text-fg-muted text-sm",children:"Loading map..."}),children:e.jsx(Ea,{resolvedPath:o,localNode:t,hubNodes:x,hoveredHopIndex:y,onHoverHop:k,traceSnr:g})})})}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:o.hops.map((f,_)=>{var q,Y,E;const v=f.isSource===!0,p=f.isDestination===!0,I=y===_;let V;return v?V=`Source: ${((q=f.candidates[0])==null?void 0:q.name)||"Unknown"}`:p?V=`Destination: ${((Y=f.candidates[0])==null?void 0:Y.name)||"Unknown"}`:f.totalMatches===0?V="No matching nodes found":f.totalMatches===1?V=`Exact match: ${((E=f.candidates[0])==null?void 0:E.name)||"Unknown"}`:V=`${f.totalMatches} possible matches (${(f.confidence*100).toFixed(0)}% confidence)`,e.jsxs("div",{className:H("flex items-center gap-1 px-1.5 py-0.5 rounded type-data-xs cursor-pointer transition-all",I?"bg-sys-blue/20 ring-1 ring-sys-blue/50":"bg-elevated hover:bg-subtle",v&&"border border-sys-green/30",p&&"border border-sys-blue/30"),title:V,onMouseEnter:()=>k(_),onMouseLeave:()=>k(null),children:[v&&e.jsx("span",{className:"text-sys-green text-[8px] mr-0.5",children:"SRC"}),p&&e.jsx("span",{className:"text-sys-blue text-[8px] mr-0.5",children:"DST"}),e.jsx("span",{style:Oa(f.confidence,f.totalMatches,N),children:f.prefix}),!v&&!p&&f.totalMatches>1&&e.jsxs("span",{className:"text-fg-muted",children:["×",f.totalMatches]}),!v&&!p&&f.totalMatches===0&&e.jsx("span",{className:"text-fg-muted",children:"?"})]},_)})})]}):e.jsxs("div",{className:"flex items-center justify-center text-fg-muted text-xs py-4",children:[e.jsx(Oe,{className:"w-3.5 h-3.5 mr-1.5 opacity-50"}),"No location data available for path nodes"]})}const Ke=16;function Qe(s){return s.match(/.{1,2}/g)||[]}function ye(s){return s!==null&&s.startsWith("payload:")}const _e={hexRestOpacity:15,cardRestBg:"color-mix(in srgb, var(--elevated) 60%, var(--body))",cardRestShadow:`
    var(--depth-stroke-tl),
    var(--depth-stroke-br)
  `,selectionBorderWidth:2},ts={type:"tween",duration:.25,ease:[.25,.1,.25,1]};function Ga(s,a){return s?`inset 0 0 0 ${_e.selectionBorderWidth}px ${me[a]}`:_e.cardRestShadow}function Qa(s,a){return s?a:`color-mix(in srgb, ${a} ${_e.hexRestOpacity}%, transparent)`}function qa({segments:s,selectedSegment:a,onSegmentClick:t}){const[n,i]=m.useState(null),[l,r]=m.useState(null),c=s.some(u=>u.id!==void 0)&&t,x=[];for(const u of s){const y=Qe(u.hex);for(const k of y)x.push({byte:k.toUpperCase(),color:u.color,id:u.id})}const g=[];for(let u=0;u<x.length;u+=Ke)g.push(x.slice(u,u+Ke));return e.jsx("div",{className:"space-y-1",children:g.map((u,y)=>{const k=u.length<Ke;return e.jsx("div",{className:"flex rounded-md overflow-hidden",children:u.map(({byte:b,color:d,id:C},M)=>{const o=M===u.length-1,N=k&&o,f=me[d],p=(C?n===C:l===d)||!!(C&&a===C);return e.jsx("span",{className:`w-[1.75rem] text-xs text-center py-0.5 font-mono select-text ${c?"cursor-pointer":""}`,style:{backgroundColor:Qa(p,f),color:p?"rgba(255,255,255,0.95)":f,transition:p?"none":"background-color 0.15s ease-out, color 0.15s ease-out",touchAction:"manipulation",...N?{borderRadius:"0 0.375rem 0.375rem 0"}:{}},onMouseEnter:()=>{C?i(C):r(d)},onMouseLeave:()=>{i(null),r(null)},onClick:()=>C&&(t==null?void 0:t(C)),onTouchStart:()=>{C?i(C):r(d)},onTouchEnd:()=>{i(null),r(null)},children:b},M)})},y)})})}function Wa({rawHex:s,hexSegments:a,selectedSegment:t,onSegmentClick:n}){const[i,l]=m.useState(!1),r=m.useCallback(async()=>{await ft(s.toUpperCase()),l(!0),setTimeout(()=>l(!1),2e3)},[s]);return e.jsxs("div",{className:"bg-inset radius-inner p-6 relative depth-stroke-inset",children:[e.jsx(qa,{segments:a,selectedSegment:t,onSegmentClick:n}),e.jsx("button",{onClick:r,className:"absolute bottom-3 right-3 flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg bg-subtle-fill-hover hover:bg-subtle-fill-strong text-fg-muted hover:text-fg-secondary transition-all text-xs font-sans",title:"Copy raw packet hex",children:i?e.jsxs(e.Fragment,{children:[e.jsx(gt,{className:"w-3.5 h-3.5 text-sys-green"}),e.jsx("span",{className:"text-sys-green",children:"Copied"})]}):e.jsxs(e.Fragment,{children:[e.jsx(rs,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Copy"})]})})]})}function Ka(s,a){const t=[];let n=0;const i=a.slice(0,64);t.push({id:"payload:publicKey",title:"Public Key",color:"pink",hex:i,startByte:n,endByte:n+31,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:s.publicKey.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Ed25519 public key (32 bytes)"})]})}),n+=32;const l=a.slice(64,72);t.push({id:"payload:timestamp",title:"Timestamp",color:"orange",hex:l,startByte:n,endByte:n+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",copy:!0,children:l.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[s.timestamp," (",ie(s.timestamp),")"]})]})}),n+=4;const r=a.slice(72,200);t.push({id:"payload:signature",title:"Signature",color:"teal",hex:r,startByte:n,endByte:n+63,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:s.signature.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Ed25519 signature (64 bytes)"})]})}),n+=64;const c=a.slice(200,202);if(t.push({id:"payload:flags",title:"Flags",color:"blue",hex:c,startByte:n,endByte:n,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(J,{size:"standard",copy:!0,children:["0x",s.flags.toString(16).padStart(2,"0").toUpperCase()]}),e.jsx("p",{className:"text-xs text-fg-primary mt-1",children:s.flagsDescription}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["Node Type: ",s.nodeType]})]})}),n+=1,s.latitude!==void 0){const x=a.slice(n*2,n*2+8);t.push({id:"payload:latitude",title:"Latitude",color:"green",hex:x,startByte:n,endByte:n+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",copy:!0,children:x.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[s.latitude.toFixed(6),"°"]})]})}),n+=4}if(s.longitude!==void 0){const x=a.slice(n*2,n*2+8);t.push({id:"payload:longitude",title:"Longitude",color:"indigo",hex:x,startByte:n,endByte:n+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",copy:!0,children:x.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[s.longitude.toFixed(6),"°"]})]})}),n+=4}if(s.name){const x=a.slice(n*2),g=x.length/2;t.push({id:"payload:name",title:"Name",color:"amber",hex:x,startByte:n,endByte:n+g-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",copy:!0,children:x.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:['"',s.name,'"']})]})})}return t}function Ya(s,a){return[{id:"payload:crc",title:"CRC",color:"green",hex:a.slice(0,8),startByte:0,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(J,{size:"standard",copy:!0,children:["0x",s.crc]}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"CRC32 of acknowledged packet"})]})}]}function Xa(s,a){const t=[];t.push({id:"payload:channelHash",title:"Channel Hash",color:"blue",hex:a.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(J,{size:"standard",copy:!0,children:["0x",s.channelHash]}),s.channelName&&e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:["Channel: ",s.channelName]})]})}),s.macHex&&t.push({id:"payload:mac",title:"MAC",color:"indigo",hex:a.slice(2,6),startByte:1,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",copy:!0,children:s.macHex.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Truncated HMAC-SHA256"})]})});const n=a.slice(6);return n&&t.push({id:"payload:ciphertext",title:s.decrypted?"Message":"Ciphertext",color:s.decrypted?"green":"zinc",hex:n,startByte:3,endByte:3+n.length/2-1,decoded:s.decrypted?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-fg-primary",children:['"',s.text,'"']}),s.senderName&&e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:["From: ",s.senderName]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:n.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"AES-128-ECB encrypted"})]})}),t}function Za(s,a){const t=[];t.push({id:"payload:channelHash",title:"Channel Hash",color:"blue",hex:a.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(J,{size:"standard",copy:!0,children:["0x",s.channelHash]}),s.channelName&&e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:["Channel: ",s.channelName]})]})}),s.macHex&&t.push({id:"payload:mac",title:"MAC",color:"indigo",hex:a.slice(2,6),startByte:1,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",copy:!0,children:s.macHex.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Truncated HMAC-SHA256"})]})});const n=a.slice(6);return n&&t.push({id:"payload:ciphertext",title:s.decrypted?"Decrypted Data":"Encrypted Data",color:s.decrypted?"green":"zinc",hex:n,startByte:3,endByte:3+n.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:(s.decryptedHex||n).toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[s.dataLength," bytes",s.decrypted?"":" (AES-128-ECB encrypted)"]})]})}),t}function Ja(s,a){const t=[],n=parseInt(a.slice(0,2),16),i=isNaN(n)?{hashSize:1,hopCount:s.pathLength}:jt(n),l=i.hopCount*i.hashSize;if(t.push({id:"payload:pathLength",title:"Path Length",color:"blue",hex:a.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",children:i.hopCount}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[i.hopCount," hop",i.hopCount!==1?"s":"",i.hashSize>1&&` × ${i.hashSize}B hashes`]})]})}),s.path.length>0){const r=a.slice(2,2+l*2);t.push({id:"payload:path",title:"Path Hops",color:"amber",hex:r,startByte:1,endByte:l,decoded:e.jsx(e.Fragment,{children:e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:s.path.map((c,x)=>e.jsxs("span",{className:"flex items-center gap-1",children:[x>0&&e.jsx(he,{className:"w-3 h-3 text-fg-muted"}),e.jsx(B,{color:"amber",className:"font-mono",children:c})]},x))})})})}if(s.extraType!=null){const r=1+l;t.push({id:"payload:extraType",title:"Extra Type",color:"indigo",hex:a.slice(r*2,r*2+2),startByte:r,endByte:r,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",children:s.extraTypeName??`0x${s.extraType.toString(16).padStart(2,"0")}`}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Bundled payload type"})]})})}if(s.extraData){const r=1+l+1,c=a.slice(r*2);c&&t.push({id:"payload:extraData",title:"Extra Data",color:"indigo",hex:c,startByte:r,endByte:r+c.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:c.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[c.length/2," bytes"]})]})})}return t}function en(s,a){const t=[];t.push({id:"payload:crc",title:"Trace Tag",color:"blue",hex:a.slice(0,8),startByte:0,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(J,{size:"standard",copy:!0,children:["0x",s.traceTag]}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Unique trace request identifier"})]})}),t.push({id:"payload:mac",title:"Auth Code",color:"indigo",hex:a.slice(8,16),startByte:4,endByte:7,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",copy:!0,children:s.authCode}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Authentication/verification code"})]})});const n=1<<(s.flags&3);t.push({id:"payload:flags",title:"Flags",color:"amber",hex:a.slice(16,18),startByte:8,endByte:8,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(J,{size:"standard",copy:!0,children:["0x",s.flags.toString(16).toUpperCase().padStart(2,"0")]}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:s.flags===0?"No flags set (1B hashes)":`Bits 0-1: ${n}B per hash • ${s.flags.toString(2).padStart(8,"0")}b`})]})});const i=a.slice(18);return i&&t.push({id:"payload:path",title:"Target Path",color:"indigo",hex:i,startByte:9,endByte:9+i.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:s.pathHashes.map((l,r)=>{const c=s.snrValues[r],x=c!==void 0?Kt(c):"zinc";return e.jsxs("span",{className:"flex items-center gap-1",children:[r>0&&e.jsx(he,{className:"w-3 h-3 text-fg-muted"}),e.jsx(B,{color:"indigo",className:"font-mono",children:l}),c!==void 0&&e.jsxs(B,{color:x,className:"font-mono",children:[c>=0?"+":"",Number.isInteger(c)?c:c.toFixed(1),"dB"]})]},r)})}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[s.pathHashes.length," target ",s.pathHashes.length===1?"hop":"hops",n>1&&` × ${n}B hashes`,s.snrValues.length>0&&` • ${s.snrValues.length} SNR ${s.snrValues.length===1?"value":"values"} collected`,s.isComplete&&" • ✓ Complete"]})]})}),t}function sn(s,a){const t=[];t.push({id:"payload:msgId",title:"Message ID",color:"blue",hex:a.slice(0,4),startByte:0,endByte:1,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",copy:!0,children:s.messageId.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Unique message identifier"})]})}),t.push({id:"payload:partNum",title:"Part Number",color:"amber",hex:a.slice(4,6),startByte:2,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",copy:!0,children:s.partNumber}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"0-indexed part number"})]})}),t.push({id:"payload:totalParts",title:"Total Parts",color:"orange",hex:a.slice(6,8),startByte:3,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(J,{size:"standard",copy:!0,children:s.totalParts}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:["Part ",s.partNumber+1," of ",s.totalParts]})]})});const n=a.slice(8);return n&&t.push({id:"payload:partData",title:"Part Data",color:"cyan",hex:n,startByte:4,endByte:4+n.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:n.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[n.length/2," bytes"]})]})}),t}function tn(s,a){switch(s.type){case"advert":return Ka(s,a);case"ack":return Ya(s,a);case"grp_txt":return Xa(s,a);case"grp_data":return Za(s,a);case"path":return Ja(s,a);case"trace":return en(s,a);case"multipart":return sn(s,a);default:return[{id:"payload:ciphertext",title:"Raw Data",color:"zinc",hex:a,startByte:0,endByte:a.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:a.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[a.length/2," bytes"]})]})}]}}function an(s){return s.map(a=>({id:a.id,hex:a.hex,color:a.color}))}function nn({bits:s,field:a,value:t,binary:n}){const i=()=>{if(a==="Payload Type"){const l=Be[t]||"zinc";return e.jsx(B,{color:l,children:t})}if(a==="Route Type"){const l=Ie[t]||"zinc";return e.jsx(B,{color:l,children:t})}return e.jsx("span",{className:"text-sm text-fg-primary",children:t})};return e.jsxs("tr",{children:[e.jsx("td",{className:"py-1.5 text-xs text-fg-muted tabular-nums",children:s}),e.jsx("td",{className:"py-1.5 text-sm text-fg-secondary",children:a}),e.jsx("td",{className:"py-1.5",children:i()}),e.jsx("td",{className:"py-1.5 type-data-xs text-sys-cyan",children:n})]})}function js({id:s,title:a,color:t,hexBytes:n,startByte:i,endByte:l,isSelected:r,children:c}){const x=n?Qe(n):[];return e.jsxs(ce.div,{layout:"position",layoutId:s,transition:ts,className:"w-full min-w-0 overflow-hidden radius-inner p-4 sm:p-5 space-y-4",style:{backgroundColor:_e.cardRestBg,boxShadow:Ga(r,t)},children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 min-w-0",children:[e.jsx(B,{color:t,children:a}),x.length>0&&x.length<=16&&x.map((g,u)=>e.jsx(B,{color:t,className:"font-mono",children:g.toUpperCase()},u))]}),e.jsxs("span",{className:"type-data-xs text-fg-muted flex-shrink-0",children:["Bytes ",i,"-",l]})]}),e.jsx("div",{className:"min-w-0 overflow-hidden",children:c})]})}function rn({advert:s,timestamp:a}){const t=a?ie(a):ie(s.timestamp);return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-indigo/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-indigo) 0%, var(--sys-blue) 100%)"},children:e.jsx(oe,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:s.name||"Unknown Node"}),e.jsx("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:s.nodeType})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[s.latitude!==void 0&&s.longitude!==void 0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Oe,{className:"w-4 h-4 text-sys-indigo flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-fg-secondary font-mono",children:[s.latitude.toFixed(5),"°, ",s.longitude.toFixed(5),"°"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"w-4 h-4 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:t})]})]})]})})}function ln({decoded:s,timestamp:a}){const t=a?ie(a):"Unknown";return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-teal/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-teal) 0%, var(--sys-cyan) 100%)"},children:e.jsx(aa,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:s.channelName||"Channel Data"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:[s.dataLength," bytes • ",s.decrypted?"Decrypted":"Encrypted"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Os,{className:"w-4 h-4 text-sys-teal flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-fg-secondary font-sans",children:["Channel: ",e.jsxs("span",{className:"font-mono",children:["0x",s.channelHash]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"w-4 h-4 text-sys-teal flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:t})]}),s.decrypted&&s.decryptedHex&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-edge-subtle",children:[e.jsx("p",{className:"type-micro text-fg-muted mb-1 font-sans",children:"Decrypted Data"}),e.jsx("div",{className:"max-w-full overflow-x-auto",children:e.jsx(J,{size:"compact",copy:!0,className:"inline-block",children:e.jsx("span",{className:"break-all text-xs",children:s.decryptedHex.toUpperCase()})})})]})]})]})})}function cn({decoded:s,timestamp:a,isLoading:t=!1,onDecrypted:n}){const i=a?ie(a):"Unknown",[l,r]=m.useState(""),[c,x]=m.useState(!1),[g,u]=m.useState(null),[y,k]=m.useState(!1),b=m.useCallback(async()=>{if(!(!l.trim()||!s.ciphertextHex||!s.macHex)){x(!0),u(null);try{const d=parseInt(s.channelHash,16),C=hs(s.macHex),M=hs(s.ciphertextHex),o=await Nt(l.trim(),d,C,M);if(o.success){const N=o.result.plaintext,f=new TextDecoder("utf-8",{fatal:!1}).decode(N.slice(5)),_=f.indexOf(": "),v={...s,channelName:o.result.channelName,decrypted:!0,timestamp:N[0]|N[1]<<8|N[2]<<16|N[3]<<24,flags:N[4],senderName:_>0?f.slice(0,_):void 0,text:_>0?f.slice(_+2):f};n==null||n(v),r(""),k(!1)}else u(o.error)}catch(d){u(d instanceof Error?d.message:"Unknown error")}finally{x(!1)}}},[l,s,n]);return t?e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-xl p-4 sm:p-5",style:{backgroundColor:"color-mix(in srgb, var(--elevated) 60%, var(--body))",boxShadow:`
              inset 0 0 0 1px color-mix(in srgb, var(--fg-primary) 6%, transparent),
              inset 0 1px 0 color-mix(in srgb, white 3%, transparent),
              0 1px 2px color-mix(in srgb, black 5%, transparent)
            `},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3 h-[15px]",children:[e.jsx("div",{className:"h-2.5 w-12 rounded bg-subtle-fill-hover animate-pulse"}),e.jsx("div",{className:"h-2.5 w-16 rounded bg-subtle-fill-hover animate-pulse"})]}),e.jsx("div",{className:"inline-block max-w-[85%] px-3.5 py-2 rounded-2xl rounded-tl-md",style:{background:"color-mix(in srgb, var(--sys-blue) 30%, transparent)"},children:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"h-3.5 w-48 rounded bg-subtle-fill-strong animate-pulse"}),e.jsx("div",{className:"h-3.5 w-32 rounded bg-subtle-fill-strong animate-pulse"})]})})]})}):s.decrypted?e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-xl p-4 sm:p-5",style:{backgroundColor:"color-mix(in srgb, var(--elevated) 60%, var(--body))",boxShadow:`
              inset 0 0 0 1px color-mix(in srgb, var(--fg-primary) 6%, transparent),
              inset 0 1px 0 color-mix(in srgb, white 3%, transparent),
              0 1px 2px color-mix(in srgb, black 5%, transparent)
            `},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.senderName&&e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["From ",e.jsx("span",{className:"text-fg-secondary font-medium",children:s.senderName})]}),s.channelName&&e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["in ",e.jsx("span",{className:"text-sys-cyan font-medium",children:s.channelName})]})]}),e.jsx("div",{className:"inline-block max-w-[85%] px-3.5 py-2 rounded-2xl rounded-tl-md",style:{background:"linear-gradient(135deg, var(--sys-blue) 0%, color-mix(in srgb, var(--sys-blue) 85%, var(--sys-cyan)) 100%)"},children:e.jsx("p",{className:"text-sm text-white font-sans leading-relaxed whitespace-pre-wrap break-words",children:s.text})})]})}):e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-zinc-500/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--zinc-500) 0%, color-mix(in srgb, var(--zinc-500) 70%, black) 100%)"},children:e.jsx(cs,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:s.isPublicHashChannel?"Public Hash Channel":"Encrypted Message"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:["Channel hash: ",e.jsxs("span",{className:"font-mono",children:["0x",s.channelHash]})]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"w-4 h-4 text-zinc-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:i})]}),s.ciphertextHex&&s.macHex&&e.jsx("div",{className:"space-y-2",children:y?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:l,onChange:d=>r(d.target.value),placeholder:"Channel name (e.g. south-bay)",className:"flex-1 px-3 py-1.5 text-sm rounded-lg bg-subtle-fill-strong border border-edge-subtle text-fg-primary placeholder:text-fg-muted focus:outline-none focus:border-zinc-500",onKeyDown:d=>d.key==="Enter"&&b(),disabled:c}),e.jsx("button",{onClick:b,disabled:c||!l.trim(),className:"px-3 py-1.5 text-sm font-medium rounded-lg bg-zinc-600 hover:bg-zinc-500 text-white disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:c?"Testing...":"Try"}),e.jsx("button",{onClick:()=>{k(!1),u(null),r("")},className:"px-2 py-1.5 text-sm rounded-lg hover:bg-subtle-fill-strong text-fg-muted transition-colors",children:"×"})]}),g&&e.jsx("p",{className:"text-xs text-sys-red",children:g})]}):e.jsx("button",{onClick:()=>k(!0),className:"text-xs text-zinc-400 hover:text-zinc-300 underline underline-offset-2 transition-colors",children:"Know the channel name? Try to decrypt"})}),!y&&e.jsx("p",{className:"text-xs text-fg-muted",children:s.isPublicHashChannel?"Public hash channel message. Key not in common channel list.":"Unknown hash channel. Channel name required for decryption."})]})]})})}function on({decoded:s,timestamp:a}){const t=a?ie(a):"Unknown";return e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shadow-md",style:{background:"linear-gradient(135deg, var(--sys-green) 0%, var(--sys-teal) 100%)"},children:e.jsx(bt,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary font-sans",children:"Acknowledgment"}),e.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:["CRC: ",e.jsxs("span",{className:"font-mono text-sys-green",children:["0x",s.crc]})," · ",t]})]})]})}function dn({decoded:s,timestamp:a}){const t=a?ie(a):"Unknown",n=s.path.length;return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-amber/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-amber) 0%, var(--sys-orange) 100%)"},children:e.jsx(sa,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:"Path Response"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:[n," ",n===1?"hop":"hops"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"w-4 h-4 text-sys-amber flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:t})]}),s.path.length>0&&e.jsx("div",{className:"mt-2 pt-2 border-t border-edge-subtle",children:e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.path.map((i,l)=>e.jsxs("div",{className:"flex items-center gap-2",children:[l>0&&e.jsx(he,{className:"w-4 h-4 text-sys-amber"}),e.jsx(B,{color:"amber",className:"font-mono",children:i})]},l))})})]})]})})}function xn({decoded:s,timestamp:a}){const t=a?ie(a):"Unknown",n=s.pathHashes.length,i=s.snrValues.length,l=r=>r>=7?"green":r>=0?"yellow":r>=-5?"orange":"red";return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-blue/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-blue) 0%, var(--sys-indigo) 100%)"},children:e.jsx(ta,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:["Trace ",s.isComplete?"Complete":"In Progress"]}),e.jsxs("p",{className:"text-sm text-fg-muted mt-0.5",children:["Tag: 0x",s.traceTag.slice(0,8),s.isComplete&&" • ✓"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary",children:t})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-fg-muted",children:[e.jsxs("span",{children:[n," target ",n===1?"hop":"hops"]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[i," SNR ",i===1?"sample":"samples"]}),s.authCode!==0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{children:["Auth: ",s.authCode]})]})]}),s.pathHashes.length>0&&e.jsx("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:s.pathHashes.map((r,c)=>{const x=s.snrValues[c],g=x!==void 0?l(x):"zinc",u=x!==void 0;return e.jsxs("div",{className:"flex items-center gap-2",children:[c>0&&e.jsx(he,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{color:u?"blue":"zinc",className:"font-mono",children:r}),u&&e.jsxs(B,{color:g,className:"font-mono",children:[x>=0?"+":"",Number.isInteger(x)?x:x.toFixed(1),"dB"]})]})]},c)})})]})]})})}function mn({decoded:s,timestamp:a}){const t=a?ie(a):"Unknown";return s.encrypted?e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shadow-md",style:{background:"linear-gradient(135deg, var(--sys-indigo) 0%, var(--sys-blue) 100%)"},children:e.jsx(cs,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary font-sans",children:"Encrypted Message"}),e.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:[s.srcHash," → ",s.destHash," · ",t]})]})]}):e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5 px-1",children:[e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:[e.jsx("span",{className:"font-mono text-fg-secondary",children:s.srcHash})," → ",e.jsx("span",{className:"font-mono text-fg-secondary",children:s.destHash})]}),e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["· ",t]})]}),e.jsx("div",{className:"inline-block max-w-[85%] px-3.5 py-2 rounded-2xl rounded-tr-md ml-auto",style:{background:"linear-gradient(135deg, var(--sys-green) 0%, var(--sys-teal) 100%)"},children:e.jsx("p",{className:"text-sm text-white font-sans leading-relaxed whitespace-pre-wrap break-words",children:s.text})})]})}function hn({decoded:s,timestamp:a}){const t=a?ie(a):"Unknown",n=(s.partNumber+1)/s.totalParts*100;return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-yellow/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-yellow) 0%, var(--sys-amber) 100%)"},children:e.jsx(ea,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:"Multipart Segment"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:["Part ",s.partNumber+1," of ",s.totalParts]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsx("div",{children:e.jsx("div",{className:"h-2 bg-subtle-fill-strong rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${n}%`,background:"linear-gradient(90deg, var(--sys-yellow), var(--sys-amber))"}})})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Os,{className:"w-4 h-4 text-sys-yellow flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-fg-secondary font-sans",children:["Message ID: ",e.jsx("span",{className:"font-mono",children:s.messageId})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"w-4 h-4 text-sys-yellow flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:t})]})]})]})})}function un({decoded:s,timestamp:a,payloadType:t}){const n=a?ie(a):"Unknown",l=(()=>{switch(t){case le.REQ:return{icon:vt,gradient:"var(--sys-orange), var(--sys-red)",bg:"rgba(249, 115, 22, 0.15)",label:"Request"};case le.RESPONSE:return{icon:da,gradient:"var(--sys-green), var(--sys-teal)",bg:"rgba(34, 197, 94, 0.15)",label:"Response"};case le.ANON_REQ:return{icon:cs,gradient:"var(--sys-indigo), var(--sys-pink)",bg:"rgba(91, 91, 214, 0.15)",label:"Anonymous Request"};default:return{icon:Yt,gradient:"var(--sys-gray), var(--sys-slate)",bg:"rgba(107, 114, 128, 0.15)",label:s.payloadTypeName}}})(),r=l.icon;return e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shadow-md",style:{background:`linear-gradient(135deg, ${l.gradient})`},children:e.jsx(r,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary font-sans",children:l.label}),e.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:[s.length," bytes · ",n]})]})]})}function pn({pathHex:s}){if(!s)return null;const a=Qe(s);return e.jsx("div",{className:"flex flex-wrap items-center gap-2 py-2",children:a.map((t,n)=>e.jsxs("div",{className:"flex items-center gap-2",children:[n>0&&e.jsx(he,{className:"w-4 h-4 text-sys-amber flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(J,{size:"compact",copy:!0,children:t.toUpperCase()}),e.jsx("span",{className:"text-xs text-fg-muted font-sans tabular-nums w-4 text-left",children:n+1})]})]},n))})}function fn({decoded:s,payloadType:a}){const t=yt[a]||`TYPE_${a}`;switch(s.type){case"advert":{const n=s.nodeType==="chat"?"companion":s.nodeType.replace("_"," "),i=s.latitude!==void 0&&s.longitude!==void 0&&!(s.latitude===0&&s.longitude===0);return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Role:"})," ",n]}),s.name&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Name:"})," ",s.name]}),i&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Location:"})," ",s.latitude.toFixed(4),"°, ",s.longitude.toFixed(4),"°"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Time:"})," ",ie(s.timestamp)]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Flags:"})," ",s.flagsDescription]})]})}case"ack":return e.jsx("div",{className:"text-xs text-fg-primary space-y-0.5",children:e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"CRC:"})," 0x",s.crc]})});case"path":return e.jsx("div",{className:"text-xs text-fg-primary space-y-1",children:e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Path:"})," ",s.pathString||"(empty)"]})});case"trace":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Tag:"})," 0x",s.traceTag]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Target Path:"})," ",s.pathString||"(empty)"]}),s.snrValues.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"SNR:"})," ",s.snrValues.map(n=>`${n>=0?"+":""}${Number.isInteger(n)?n:n.toFixed(1)}dB`).join(" → ")]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Status:"})," ",s.isComplete?"✓ Complete":`In progress (${s.snrValues.length}/${s.pathHashes.length})`]})]});case"txt_msg":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Dest:"})," ",s.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Src:"})," ",s.srcHash]}),s.encrypted?e.jsx("p",{className:"text-fg-muted italic",children:"Encrypted content"}):e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Text:"})," ",s.text]})]});case"grp_txt":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Channel:"})," ",s.channelName?e.jsx("span",{className:"text-sys-green",children:s.channelName}):s.isPublicHashChannel?e.jsx("span",{className:"text-sys-indigo",children:"Public Hash Channel"}):e.jsxs("span",{className:"font-mono",children:["0x",s.channelHash]})]}),s.decrypted?e.jsxs(e.Fragment,{children:[s.senderName&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"From:"})," ",s.senderName]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Text:"})," ",s.text]})]}):s.isPublicHashChannel?e.jsx("p",{className:"text-fg-muted italic",children:"Encrypted (public hash channel)"}):e.jsx("p",{className:"text-fg-muted italic",children:"Encrypted (unknown channel)"})]});case"grp_data":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Channel:"})," ",s.channelName?e.jsx("span",{className:"text-sys-teal",children:s.channelName}):e.jsxs("span",{className:"font-mono",children:["0x",s.channelHash]})]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Data:"})," ",s.dataLength," bytes ",s.decrypted?"(decrypted)":"(encrypted)"]})]});case"multipart":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Part:"})," ",s.partNumber+1,"/",s.totalParts]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Message ID:"})," ",s.messageId]})]});case"control":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Control:"})," ",s.subtypeName]}),s.dataLength>0&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Data:"})," ",s.dataLength," bytes"]})]});case"req":case"response":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Dest:"})," ",s.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Src:"})," ",s.srcHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Ciphertext:"})," ",s.ciphertextLength," bytes"]})]});case"anon_req":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Dest:"})," ",s.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Pub Key:"})," ",e.jsxs("span",{className:"font-mono break-all",children:[s.senderPublicKey.slice(0,16),"…"]})]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Ciphertext:"})," ",s.ciphertextLength," bytes"]})]});default:return e.jsxs("p",{className:"text-xs text-fg-secondary",children:[t," (","length"in s?s.length:0," bytes)"]})}}function gn({packet:s,decodedGrpTxt:a}){var E,X;const t=s.raw_packet||"",n=t.length/2,i=mt(),[l,r]=m.useState(null),[c,x]=m.useState(null),[g,u]=m.useState(!1),[y,k]=m.useState(null),b=m.useCallback(F=>{k(D=>D===F?null:F)},[]),d=m.useMemo(()=>zt(t),[t]),C=(E=d==null?void 0:d.packet)==null?void 0:E.payloadType,M=(d==null?void 0:d.payloadHex)||"",o=(X=d==null?void 0:d.packet)==null?void 0:X.payload,N=C===le.GRP_TXT,f=C===le.GRP_DATA,_=N&&!a&&(!i||g);if(m.useEffect(()=>{if(r(null),u(!1),a||!N||!o||o.length<4)return;if(!i){u(!0);return}u(!0);let F=!1;return ht(o).then(D=>{F||(r(D),u(!1))}),()=>{F=!0}},[M,N,i,a]),m.useEffect(()=>{if(x(null),!f||!o||o.length<4||!i)return;let F=!1;return ut(o).then(D=>{F||x(D)}),()=>{F=!0}},[M,f,i]),!d||t.length===0)return e.jsx("div",{className:"p-4 text-center text-fg-muted",children:e.jsx("p",{className:"text-sm",children:"No raw packet data available"})});const{packet:v}=d;let p=d.decoded;a&&d.decoded.type==="grp_txt"?p=a:l&&d.decoded.type==="grp_txt"?p=l:c&&d.decoded.type==="grp_data"&&(p=c);const I=()=>{switch(p.type){case"advert":return e.jsx(rn,{advert:p,timestamp:s.timestamp});case"grp_data":return e.jsx(ln,{decoded:p,timestamp:s.timestamp});case"grp_txt":return e.jsx(cn,{decoded:p,timestamp:s.timestamp,isLoading:_,onDecrypted:r});case"ack":return e.jsx(on,{decoded:p,timestamp:s.timestamp});case"path":return e.jsx(dn,{decoded:p,timestamp:s.timestamp});case"trace":return e.jsx(xn,{decoded:p,timestamp:s.timestamp});case"txt_msg":return e.jsx(mn,{decoded:p,timestamp:s.timestamp});case"multipart":return e.jsx(hn,{decoded:p,timestamp:s.timestamp});case"generic":return v.payloadType===le.REQ||v.payloadType===le.RESPONSE||v.payloadType===le.ANON_REQ?e.jsx(un,{decoded:p,timestamp:s.timestamp,payloadType:v.payloadType}):null;default:return null}},V=m.useMemo(()=>tn(p,d.payloadHex),[p,d.payloadHex]),q=y==="payload"||ye(y),Y=m.useMemo(()=>{const F=[{id:"header",hex:d.headerHex,color:"red"},...d.transportCodesHex?[{id:"transportCodes",hex:d.transportCodesHex,color:"indigo"}]:[],{id:"pathLength",hex:d.pathLengthHex,color:"green"},...d.pathDataHex?[{id:"pathData",hex:d.pathDataHex,color:"amber"}]:[]];return q?[...F,...an(V)]:[...F,{id:"payload",hex:d.payloadHex,color:"cyan"}]},[d,q,V]);return e.jsxs("div",{className:"font-mono space-y-2 min-w-0 overflow-hidden",children:[I(),e.jsx(Wa,{rawHex:t,hexSegments:Y,selectedSegment:y,onSegmentClick:b}),e.jsx(pt,{children:e.jsx(ce.div,{layout:!0,transition:ts,className:"space-y-2 min-w-0",children:(()=>{var T,$,ee,ne;const D=[{id:"header",title:"Header",color:"red",startByte:0,endByte:0,hexBytes:`0x${d.headerHex.toUpperCase()}`,condition:!0,content:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"type-micro text-fg-muted font-sans",children:[e.jsx("th",{className:"py-1 font-medium",children:e.jsx("span",{className:"underline underline-offset-4 decoration-edge-subtle",children:"Bits"})}),e.jsx("th",{className:"py-1 font-medium",children:e.jsx("span",{className:"underline underline-offset-4 decoration-edge-subtle",children:"Field"})}),e.jsx("th",{className:"py-1 font-medium",children:e.jsx("span",{className:"underline underline-offset-4 decoration-edge-subtle",children:"Value"})}),e.jsx("th",{className:"py-1 font-medium",children:e.jsx("span",{className:"underline underline-offset-4 decoration-edge-subtle",children:"Binary"})})]})}),e.jsx("tbody",{children:d.headerFields.map(P=>e.jsx(nn,{...P},P.bits))})]})},{id:"transportCodes",title:"Transport Codes",color:"indigo",startByte:1,endByte:4,hexBytes:((T=d.transportCodesHex)==null?void 0:T.toUpperCase())||"",condition:!!d.transportCodesHex,content:e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-fg-muted",children:"Two 16-bit transport codes for encrypted routing"}),e.jsxs("div",{className:"mt-1 text-xs text-fg-secondary",children:["Code 1: 0x",($=d.transportCodesHex)==null?void 0:$.slice(0,4).toUpperCase()," | Code 2: 0x",(ee=d.transportCodesHex)==null?void 0:ee.slice(4,8).toUpperCase()]})]})},{id:"pathLength",title:"Path Length",color:"green",startByte:d.transportCodesHex?5:1,endByte:d.transportCodesHex?5:1,hexBytes:`0x${d.pathLengthHex.toUpperCase()}`,condition:!0,content:e.jsxs("p",{className:"text-xs text-fg-muted pt-1",children:[v.pathLen," bytes showing route taken (increases as packet floods)"]})},{id:"pathData",title:"Path Data",color:"amber",startByte:d.transportCodesHex?6:2,endByte:(d.transportCodesHex?5:1)+v.pathLen,hexBytes:((ne=d.pathDataHex)==null?void 0:ne.toUpperCase())||"",condition:v.pathLen>0,content:e.jsxs("div",{className:"space-y-3",children:[e.jsx(pn,{pathHex:d.pathDataHex}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Historical route taken (bytes are added as packet floods through network)"})]})},{id:"payload",title:"Payload",color:"cyan",startByte:d.payloadStartByte,endByte:n-1,hexBytes:d.payloadHex.toUpperCase(),condition:!0,content:e.jsxs(e.Fragment,{children:[!ye(y)&&e.jsxs("div",{className:"p-3 radius-inner bg-inset depth-stroke-inset",children:[e.jsx("p",{className:"type-micro text-fg-muted mb-1.5 font-sans",children:"Decoded"}),e.jsx(fn,{decoded:p,payloadType:v.payloadType})]}),!ye(y)&&V.length>0&&e.jsx("p",{className:"type-micro text-fg-muted mt-3 font-sans",children:"Click a field below to highlight its bytes"}),ye(y)&&e.jsx("p",{className:"type-micro text-fg-muted font-sans",children:"↑ Selected field above • Other fields below ↓"})]})}].filter(P=>P.condition),W=ye(y)?V.find(P=>P.id===y):null,Z=ye(y)?[...D].sort((P,h)=>P.id==="payload"?-1:h.id==="payload"?1:0):[...D].sort((P,h)=>P.id===y?-1:h.id===y?1:0),O=ye(y)?V.filter(P=>P.id!==y):[];return e.jsxs(e.Fragment,{children:[W&&e.jsx(js,{id:`subfield-${W.id}`,title:W.title,color:W.color,startByte:d.payloadStartByte+W.startByte,endByte:d.payloadStartByte+W.endByte,hexBytes:W.hex.toUpperCase(),isSelected:!0,children:W.decoded},W.id),Z.map(P=>e.jsx(js,{id:`section-${P.id}`,title:P.title,color:P.color,startByte:P.startByte,endByte:P.endByte,hexBytes:P.hexBytes,isSelected:P.id===y,children:P.content},P.id)),O.map(P=>e.jsxs(ce.div,{layout:"position",layoutId:`subfield-${P.id}`,transition:ts,className:"w-full min-w-0 overflow-hidden radius-inner p-4 sm:p-5 space-y-4",style:{backgroundColor:_e.cardRestBg,boxShadow:_e.cardRestShadow},children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 min-w-0",children:[e.jsx(B,{color:P.color,children:P.title}),P.hex.length<=32&&Qe(P.hex).map((h,se)=>e.jsx(B,{color:P.color,className:"font-mono",children:h.toUpperCase()},se))]}),e.jsxs("span",{className:"type-data-xs text-fg-muted flex-shrink-0",children:["Bytes ",d.payloadStartByte+P.startByte,"-",d.payloadStartByte+P.endByte]})]}),e.jsx("div",{className:"min-w-0 overflow-hidden p-3 radius-inner bg-inset depth-stroke-inset",children:P.decoded})]},P.id))]})})()})})]})}const bs=m.memo(gn);function Ns(s){if(!s)return[];if(Array.isArray(s))return s;try{const a=JSON.parse(s);return Array.isArray(a)?a:[]}catch{return[]}}function as({hop:s,compact:a=!1,index:t=0,highlightIndex:n=-1,isTrace:i=!1}){var c;const l=t===n,r=ga();return m.useEffect(()=>{l&&i&&r.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"}})},[l,i,r]),e.jsxs(ce.div,{className:H("flex items-center gap-1.5",a?"flex-row":"flex-col"),animate:{scale:l?1.05:1,opacity:l?1:.85},transition:{duration:.3,ease:"easeInOut"},children:[e.jsxs(ce.div,{className:H("flex items-center gap-1.5 px-2.5 py-1 rounded-md","font-mono text-xs font-semibold",s.isLocal?"bg-sys-amber/20 text-sys-amber ring-1 ring-sys-amber/30":"bg-elevated/50 text-fg-primary ring-1 ring-edge-strong/50"),animate:r,initial:{boxShadow:"0 0 0 0px rgba(113, 156, 223, 0)"},children:[s.isLocal&&e.jsx(na,{className:"w-3 h-3"}),e.jsx("span",{children:s.prefix}),s.confidence!==void 0&&s.confidence<.9&&e.jsxs("span",{className:"text-[9px] opacity-70",children:[(s.confidence*100).toFixed(0),"%"]})]}),!a&&((c=s.neighborInfo)==null?void 0:c.name)&&e.jsx("span",{className:"text-xs text-fg-muted truncate max-w-[80px]",children:s.neighborInfo.name})]})}function yn({snr:s,sf:a}){const t=_t(s,a),i=Ct()[t]||"#6b7280",l=Number.isInteger(s)?s.toString():s.toFixed(1);return e.jsxs(B,{customColor:i,compact:!0,className:"font-mono",children:[s>=0?"+":"",l,"dB"]})}function jn({hops:s,compact:a,isTrace:t=!1,sf:n}){const[i,l]=m.useState(-1);return m.useEffect(()=>{if(s.length===0)return;const r=setTimeout(()=>{l(0)},400),c=setInterval(()=>{l(x=>{const g=x+1;return g>=s.length?(clearInterval(c),-1):g})},t?500:600);return()=>{clearTimeout(r),clearInterval(c)}},[s.length,t]),e.jsx("div",{className:"p-6",style:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"4px 8px"},children:s.map((r,c)=>{const x=c%2===0,g=c===s.length-1;return e.jsxs("div",{className:"contents",children:[e.jsx("div",{className:H("flex items-center","justify-end"),children:x&&e.jsx(as,{hop:r,compact:a,index:c,highlightIndex:i,isTrace:t})}),e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[28px]",children:!g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px flex-1 bg-border-strong/40 min-h-[8px]"}),r.snr!==void 0&&e.jsx(yn,{snr:r.snr,sf:n}),e.jsx("svg",{className:"w-3 h-3 text-fg-muted flex-shrink-0",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M6 2v8M3 7l3 3 3-3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]})}),e.jsx("div",{className:H("flex items-center","justify-start"),children:!x&&e.jsx(as,{hop:r,compact:a,index:c,highlightIndex:i,isTrace:t})})]},`${r.prefix}-${c}`)})})}function bn({packet:s,neighbors:a,localHash:t,neighborAffinity:n,ghostPrefixes:i,direction:l="horizontal",compact:r=!1,traceSnr:c,overridePath:x}){const g=c!==void 0&&c.length>0,u=wt(),y=Ns(s.original_path),k=Ns(s.forwarded_path),b=x??(k.length>0?k:y),d=t?je(t):"",C=m.useMemo(()=>b.map((o,N)=>{const f=o.toUpperCase(),_=f===d,v=(i==null?void 0:i.has(f))??!1,p=kt(f,a,n);return{prefix:f,fullHash:p==null?void 0:p.hash,neighborInfo:p==null?void 0:p.info,isLocal:_,isGhost:v,confidence:p==null?void 0:p.confidence,snr:c==null?void 0:c[N]}}),[b,a,n,d,i,c]);if(C.length===0)return e.jsxs("div",{className:"flex items-center gap-2 text-fg-muted text-xs",children:[e.jsx(oe,{className:"w-4 h-4 opacity-50"}),e.jsx("span",{children:"Direct / No path data"})]});if(l==="flowchart")return e.jsx(jn,{hops:C,compact:r,isTrace:g,sf:u});const M=l==="horizontal"?he:Us;return e.jsx("div",{className:H("flex gap-1.5",l==="horizontal"?"flex-row flex-wrap items-center":"flex-col items-start"),children:C.map((o,N)=>e.jsxs("div",{className:H("flex items-center gap-1.5",l==="vertical"&&"flex-col"),children:[e.jsx(as,{hop:o,compact:r}),N<C.length-1&&e.jsx(M,{className:"w-3 h-3 text-fg-muted flex-shrink-0"})]},`${o.prefix}-${N}`))})}const ke=m.memo(bn);function ae(s,a){if(s!=null)return typeof s=="boolean"?String(s):typeof s=="number"&&a?`${s} ${a}`:String(s)}const Q=()=>"blue",Nn=[{fn:"id",group:"identity",fmt:"int",read:s=>ae(s.id),color:Q},{fn:"packet_hash",group:"identity",fmt:"hex<sha256>",read:s=>s.packet_hash||void 0,color:Q},{fn:"timestamp",group:"identity",fmt:"epoch<s>",read:s=>s.timestamp?String(s.timestamp):void 0,color:Q,annotate:s=>s.timestamp>0?Je(s.timestamp):void 0},{fn:"type",group:"classification",fmt:"enum<payload_type>",read:s=>ae(s.type??s.payload_type),color:Q},{fn:"route",group:"classification",fmt:"enum<route_type>",read:s=>ae(s.route??s.route_type),color:Q},{fn:"rssi",group:"signal",fmt:"int<dBm>",read:s=>ae(s.rssi,"dBm"),color:Q},{fn:"snr",group:"signal",fmt:"float<dB>",read:s=>ae(s.snr,"dB"),color:Q},{fn:"path_length",group:"size",fmt:"int<hops>",read:s=>{if(s.path_length!=null)return s.path_length===0?"zero-hop":`${s.path_length} hops`},color:Q},{fn:"payload_length",group:"size",fmt:"int<B>",read:s=>ae(s.payload_length,"B"),color:Q},{fn:"airtime",group:"size",fmt:"float<ms>",read:s=>ae(s.airtime_ms,"ms"),color:Q},{fn:"src_hash",group:"addressing",fmt:"hex<2>",read:s=>s.src_hash??void 0,color:Q},{fn:"dst_hash",group:"addressing",fmt:"hex<2>",read:s=>s.dst_hash??void 0,color:Q},{fn:"path_hash",group:"addressing",fmt:"hex[]|hex",read:s=>Array.isArray(s.path_hash)?`[${s.path_hash.join(", ")}]`:ae(s.path_hash),color:Q,renderValue:s=>Array.isArray(s.path_hash)?Ye(s.path_hash):null},{fn:"score",group:"addressing",fmt:"int",read:s=>ae(s.score),color:Q},{fn:"original_path",group:"paths",fmt:"hex[]",read:s=>Array.isArray(s.original_path)?`[${s.original_path.join(", ")}]`:void 0,color:Q,renderValue:s=>Array.isArray(s.original_path)&&s.original_path.length>0?Ye(s.original_path,s.src_hash||void 0,s.dst_hash||void 0,!0):null},{fn:"forwarded_path",group:"paths",fmt:"hex[]",read:s=>Array.isArray(s.forwarded_path)?`[${s.forwarded_path.join(", ")}]`:void 0,color:Q,renderValue:s=>Array.isArray(s.forwarded_path)&&s.forwarded_path.length>0?Ye(s.forwarded_path):null},{fn:"transmitted",group:"status",fmt:"bool",read:s=>ae(s.transmitted),color:Q},{fn:"is_duplicate",group:"status",fmt:"bool",read:s=>ae(s.is_duplicate),color:Q},{fn:"drop_reason",group:"status",fmt:"string|null",read:s=>s.drop_reason??void 0,color:Q},{fn:"tx_delay",group:"status",fmt:"int<ms>",read:s=>ae(s.tx_delay_ms,"ms"),color:Q},{fn:"origin",group:"status",fmt:"enum<rx|tx_local|tx_forward>",read:s=>s.packet_origin??void 0,color:Q},{fn:"duplicates",group:"status",fmt:"PacketDuplicate[]",read:s=>s.duplicates!=null&&s.duplicates.length>0?`${s.duplicates.length}`:ae(s.duplicates),color:Q},{fn:"lbt_attempts",group:"lbt",fmt:"int",read:s=>ae(s.lbt_attempts),color:Q},{fn:"lbt_backoff",group:"lbt",fmt:"json<float[]>",read:s=>ae(s.lbt_backoff_delays_ms),color:Q},{fn:"lbt_busy",group:"lbt",fmt:"bool|int",read:s=>ae(s.lbt_channel_busy),color:Q}];function Ye(s,a,t,n){const i=s.length>0,l=a||n,r=t||n;return e.jsxs("span",{className:"inline-flex items-center gap-1 flex-wrap",children:[l&&e.jsxs(e.Fragment,{children:[a?e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] text-sys-blue",children:a}):e.jsx("span",{className:"inline-block border border-edge-subtle/50 rounded px-1.5 py-0.5 font-mono text-[11px] text-fg-muted/30",children:"XX"}),(i||r)&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"})]}),s.map((c,x)=>e.jsxs(m.Fragment,{children:[x>0&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"}),e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] text-sys-blue",children:c})]},x)),r&&e.jsxs(e.Fragment,{children:[i&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"}),t?e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] text-sys-blue",children:t}):e.jsx("span",{className:"inline-block border border-edge-subtle/50 rounded px-1.5 py-0.5 font-mono text-[11px] text-fg-muted/30",children:"XX"})]})]})}let Ee=null;function vn(){if(!Ee){Ee=new Map;for(const s of Nn)Ee.set(s.fn,s)}return Ee}function vs(s,a){var r;const t=vn().get(a);if(!t)return null;const n=t.read(s);if(n===void 0)return null;const i=t.color(s),l=(r=t.annotate)==null?void 0:r.call(t,s);return l?{text:n,color:i,annotation:l}:{text:n,color:i}}function ws(s){if(!s)return[];if(Array.isArray(s))return s;try{const a=JSON.parse(s);return Array.isArray(a)?a:[]}catch{return[]}}function ks({packets:s,selectedIndex:a,onSelect:t,compact:n=!1}){if(s.length<=1)return null;const i=a>0,l=a<s.length-1;return e.jsxs("div",{className:H("flex items-center gap-1",n?"gap-0.5":"gap-1"),children:[e.jsx("button",{onClick:()=>i&&t(a-1),disabled:!i,className:H("p-0.5 radius-badge transition-base",i?"text-fg-muted hover:text-fg-primary hover-bg":"text-fg-muted cursor-not-allowed"),"aria-label":"Previous observation",children:e.jsx(Vs,{className:n?"size-3":"size-4"})}),e.jsx("div",{className:"flex items-center gap-0.5",children:s.map((r,c)=>{const x=c===a,u=new Date(r.timestamp*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"});return e.jsx(Rt,{color:x?"cyan":"zinc",filled:x,compact:n,onClick:()=>t(c),title:`Observation ${c+1} at ${u}`,className:H("transition-all duration-150",!x&&"opacity-60 hover:opacity-100"),children:n?e.jsx("span",{className:"tabular-nums",children:c+1}):e.jsxs("span",{className:"tabular-nums text-xs",children:["#",c+1,r.rssi!=null&&e.jsx("span",{className:"ml-1 opacity-70",children:r.rssi})]})},`${r.timestamp}_${c}`)})}),e.jsx("button",{onClick:()=>l&&t(a+1),disabled:!l,className:H("p-0.5 radius-badge transition-base",l?"text-fg-muted hover:text-fg-primary hover-bg":"text-fg-muted cursor-not-allowed"),"aria-label":"Next observation",children:e.jsx(is,{className:n?"size-3":"size-4"})}),e.jsxs("span",{className:H("text-fg-muted ml-1",n?"text-[9px]":"text-xs"),children:[e.jsx(rs,{className:"inline size-3 mr-0.5 opacity-50"}),s.length]})]})}function ze({icon:s,label:a,disabled:t=!1}){return e.jsx(ce.div,{className:"flex items-center gap-1 text-xs",title:a,animate:{opacity:t?.25:.6},transition:{duration:.15,ease:[.4,0,.2,1]},children:e.jsx("span",{className:H("flex items-center justify-center size-5 radius-badge border-control transition-base",t?"bg-subtle-fill border-edge-subtle":"bg-subtle-fill"),children:s})})}function wn({hasDuplicates:s,hasPrev:a,hasNext:t,canPrevDupe:n,canNextDupe:i}){return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(ze,{icon:e.jsx(At,{className:"size-3"}),label:"Previous packet (↑)",disabled:!a}),e.jsx(ze,{icon:e.jsx(Ht,{className:"size-3"}),label:"Next packet (↓)",disabled:!t})]}),s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-3 bg-subtle-fill-strong"}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(ze,{icon:e.jsx(Vs,{className:"size-3"}),label:"Previous observation (←)",disabled:!n}),e.jsx(ze,{icon:e.jsx(is,{className:"size-3"}),label:"Next observation (→)",disabled:!i})]})]})]})}function kn({packets:s,initialIndex:a=0,onClose:t,onNavigatePrev:n,onNavigateNext:i,hasPrev:l=!1,hasNext:r=!1,resolveSource:c,getDecodedContent:x}){var De;const[g,u]=m.useState(a),y=s[g]??s[0],k=s.length>1,[b,d]=m.useState(null),[C,M]=m.useState(!1);m.useEffect(()=>{if(!y._stripped){d(null);return}let j=!1;M(!0);const w=y.packet_hash;if(!w){M(!1);return}return St(w).then(S=>{j||(S.success&&S.data&&(d(S.data),(S.data.type??S.data.payload_type)===le.GRP_TXT&&S.data.raw_packet&&Tt.getState().queueDecryption([S.data])),M(!1))}).catch(()=>{j||M(!1)}),()=>{j=!0}},[y]);const o=b??y,N=g>0,f=g<s.length-1,_=m.useCallback(j=>{u(Math.max(0,Math.min(j,s.length-1)))},[s.length]);m.useEffect(()=>{const j=w=>{if(!(w.target instanceof HTMLInputElement||w.target instanceof HTMLTextAreaElement))switch(w.key){case"ArrowUp":w.preventDefault(),n==null||n();break;case"ArrowDown":w.preventDefault(),i==null||i();break;case"ArrowLeft":w.preventDefault(),N&&u(S=>S-1);break;case"ArrowRight":w.preventDefault(),f&&u(S=>S+1);break}};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[n,i,N,f]);const v=Ds(),p=Pt(),I=Bt(),V=Mt(),q=m.useMemo(()=>new Set(V.map(j=>j.prefix.toUpperCase())),[V]),Y=o.payload_type_name||Hs(o.payload_type??o.type),E=o.route_type_name||Fs(o.route_type??o.route),X=o.payload_length??o.length??0,F=o.path_hash_size,D=ws(o.original_path),W=ws(o.forwarded_path),Z=D.length>0||W.length>0,O=W.length>0?W:D,T=m.useMemo(()=>{var j;if((j=v==null?void 0:v.config)!=null&&j.repeater)return{latitude:v.config.repeater.latitude,longitude:v.config.repeater.longitude,name:v.config.node_name||"Local Node"}},[v]),$=(v==null?void 0:v.neighbors)??{},ee=I.size>0?I:void 0,ne=o.raw_packet&&o.raw_packet.length>0,P=y._stripped&&C,h=m.useMemo(()=>c?c(o):null,[c,o]),se=Lt(o.packet_hash),te=m.useMemo(()=>!x||(o.payload_type??o.type)!==le.GRP_TXT?null:x(o),[x,o]),R=m.useMemo(()=>{if((o.payload_type??o.type)!==le.GRP_TXT)return null;if(se!=null&&se.decoded){const w=se.decoded;return{type:"grp_txt",channelHash:w.channelHash,channelName:w.channelName,text:w.text??"",decrypted:w.decrypted,senderName:w.senderName,timestamp:w.timestamp,flags:w.flags,macCorrupted:w.macCorrupted}}return te!=null&&te.decrypted?{type:"grp_txt",channelHash:te.channelHash??"",channelName:te.channelName??"",text:te.text??"",decrypted:!0,senderName:te.senderName??"",timestamp:0,flags:0,macCorrupted:te.corrupted}:null},[o,se,te]),U=m.useMemo(()=>Zt(o,R),[o,R]),G=U.kind==="trace"?U.data:null,z=U.kind==="trace"?U.snrValues:void 0,L=U.kind==="advert"?U.data:null,ue=U.kind==="advert"?U.sourceNode:void 0,Me=U.kind==="grp_txt"?U.wardriveSourceNode??void 0:void 0,re=U.kind==="anon_req"?U.data:null,Le=j=>!j||j===0?"Unknown":new Date(j*1e3).toLocaleString(),Te=(o.payload_type??o.type)===le.ADVERT&&(ue!==void 0||Z),be=Me!==void 0,He=ue??Me,Fe=Be[Y]??"zinc",qe=me[Fe]||me.zinc;return e.jsxs(As,{open:!0,onClose:t,size:"5xl",motionPlus:!0,solid:!0,className:"sm:h-[85vh] sm:max-h-[800px] md:h-[80vh] md:max-h-[900px]",children:[e.jsxs("div",{className:"sm:hidden",children:[e.jsx("div",{className:"flex justify-center pt-2 pb-1",children:e.jsx("div",{className:"w-9 h-1 rounded-full bg-fg-muted","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-center justify-between px-3 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(B,{color:Be[Y]??"zinc",className:"!text-[9px] !px-1.5 !py-0",children:Y}),e.jsx(B,{color:Ie[E]??"zinc",className:"!text-[9px] !px-1.5 !py-0",children:E}),e.jsxs(B,{color:"zinc",className:"!text-[9px] !px-1.5 !py-0",children:[X,"B"]}),F!=null&&F>1&&e.jsxs(B,{color:"orange",className:"!text-[9px] !px-1.5 !py-0",children:[F,"B hashes"]})]}),e.jsx("button",{onClick:t,className:"px-3 py-1.5 text-[15px] font-medium text-sys-blue active:text-sys-blue/80 transition-base flex-shrink-0 radius-inner active:bg-subtle-fill",children:"Done"})]}),k&&e.jsx("div",{className:"px-3 pb-2",children:e.jsx(ks,{packets:s,selectedIndex:g,onSelect:_,compact:!0})})]}),e.jsx("div",{className:"hidden sm:block px-6 pt-5 pb-4",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{color:Be[Y]??"zinc",children:Y}),e.jsx(B,{color:Ie[E]??"zinc",children:E}),e.jsxs(B,{color:"zinc",children:[X,"B"]}),F!=null&&F>1&&e.jsxs(B,{color:"orange",children:[F,"B hashes"]}),k&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-4 bg-subtle-fill-strong"}),e.jsx(ks,{packets:s,selectedIndex:g,onSelect:_})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(wn,{hasDuplicates:k,hasPrev:l,hasNext:r,canPrevDupe:N,canNextDupe:f}),e.jsx("button",{onClick:t,className:"p-1.5 -m-1.5 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-elevated flex-shrink-0",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]})}),e.jsx("div",{className:"sm:hidden h-[2px]",style:{backgroundColor:qe,opacity:.6}}),e.jsxs(Es,{className:"p-0 overflow-hidden flex-1 flex flex-col min-h-0",children:[e.jsx("div",{className:"md:hidden flex-1 overflow-y-auto overflow-x-hidden",children:e.jsxs("div",{className:"px-2 pt-2 space-y-2",children:[(o.rssi!=null||o.snr!=null)&&e.jsxs("div",{className:"relative flex items-center justify-between px-2 py-1.5 radius-inner bg-subtle-fill depth-stroke",children:[e.jsx(We,{mode:"popLayout",initial:!1,children:e.jsxs(ce.div,{className:"flex items-center gap-3",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15,ease:[.4,0,.2,1]},children:[e.jsx($e,{rssi:o.rssi,snr:o.snr,compact:!0,showValues:!0,validated:Ue(o)}),e.jsx("span",{className:"text-[11px] text-fg-muted",children:us(o.rssi)})]},g)}),O.length>0&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[O.length," hop",O.length!==1?"s":""]})]}),(Z&&O.length>0||Te||be)&&e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-[4/3] w-full",children:e.jsx(Ge,{path:O,neighbors:$,localNode:T,localHash:v==null?void 0:v.local_hash,srcHash:o.src_hash,dstHash:o.dst_hash,neighborAffinity:ee,hubNodes:[...p],traceSnr:z,advertiserSource:He})})}),G&&G.pathHashes.length>0&&e.jsxs("div",{className:"radius-inner bg-inset overflow-hidden depth-stroke-inset",children:[e.jsx("div",{className:"px-3 py-2 space-y-1.5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Trace Route"}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx(B,{color:G.isComplete?"green":"amber",compact:!0,children:G.isComplete?"Complete":"In Progress"})})]})}),e.jsx(ke,{packet:o,neighbors:$,localHash:v==null?void 0:v.local_hash,neighborAffinity:ee,ghostPrefixes:q,direction:"flowchart",compact:!0,overridePath:G.pathHashes,traceSnr:G.snrValues})]}),Z&&!G&&e.jsxs("div",{className:"radius-inner bg-inset overflow-hidden depth-stroke-inset",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Path"}),e.jsxs(B,{color:"zinc",compact:!0,children:[O.length," hop",O.length!==1?"s":""]})]}),e.jsx(ke,{packet:o,neighbors:$,localHash:v==null?void 0:v.local_hash,neighborAffinity:ee,ghostPrefixes:q,direction:"flowchart",compact:!0,traceSnr:z})]}),h&&(h.name||h.hash)&&!L&&!re&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Source"}),e.jsx(B,{color:h.isRepeater?"blue":h.isCompanion?"violet":h.type==="room_server"?"lime":"zinc",compact:!0,children:h.type==="room_server"?"room server":h.type})]}),e.jsxs("div",{className:"p-3 space-y-1.5",children:[h.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:h.name}),!h.confident&&e.jsx("span",{className:"text-[9px] text-fg-muted/60 italic",children:"ambiguous"})]}),h.hash&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-data-xs text-fg-muted truncate font-mono",children:h.hash.length>16?`${h.hash.slice(0,16)}…${h.hash.slice(-8)}`:h.hash.startsWith("0x")?h.hash.slice(2,10)+"…":h.hash.slice(0,8)+"…"})]})]})]}),re&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Sender Identity"}),e.jsx(B,{color:h!=null&&h.isRepeater?"blue":h!=null&&h.isCompanion?"violet":(h==null?void 0:h.type)==="room_server"?"lime":"amber",compact:!0,children:h!=null&&h.type&&h.type!=="unknown"?h.type==="room_server"?"room server":h.type:"companion"})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[(h==null?void 0:h.name)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:h.name}),!h.confident&&e.jsx("span",{className:"text-[9px] text-fg-muted/60 italic",children:"ambiguous"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Dest: ",e.jsx("span",{className:"font-mono",children:re.destHash})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ve,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"type-data-xs text-fg-muted break-all font-mono leading-relaxed",children:re.senderPublicKey})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:[re.ciphertextLength,"B encrypted payload"]})]})]})]}),L&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Advertiser Info"}),e.jsx(B,{color:"lime",compact:!0,children:L.nodeType})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[L.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:L.name})]}),L.latitude&&L.longitude&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Oe,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"type-data-xs text-fg-secondary",children:[L.latitude.toFixed(5),", ",L.longitude.toFixed(5)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"type-data-xs text-fg-muted truncate",children:[L.publicKey.slice(0,16),"...",L.publicKey.slice(-8)]})]}),L.timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:Le(L.timestamp)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:L.flagsDescription||`Flags: 0x${L.flags.toString(16).padStart(2,"0")}`})]})]})]}),P?e.jsx("div",{className:"pt-1 px-3 py-6 text-center",children:e.jsx("span",{className:"text-xs text-fg-muted animate-pulse",children:"Loading packet details…"})}):ne?e.jsx("div",{className:"pt-1",children:e.jsx(bs,{packet:o,decodedGrpTxt:R})}):null]})}),e.jsxs("div",{className:"hidden md:grid md:grid-cols-2 flex-1 overflow-hidden",children:[e.jsx("div",{className:"overflow-y-auto overflow-x-hidden scrollbar-none px-4 pt-4",children:P?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("span",{className:"text-sm text-fg-muted animate-pulse",children:"Loading packet details…"})}):ne?e.jsx(bs,{packet:o,decodedGrpTxt:R}):null}),e.jsxs("div",{className:"grid overflow-hidden",style:{gridTemplateRows:"minmax(280px, 1fr) auto"},children:[e.jsx("div",{className:"overflow-hidden p-2",children:Z&&O.length>0||Te||be?e.jsx("div",{className:"h-full w-full overflow-hidden",children:e.jsx(Ge,{path:O,neighbors:$,localNode:T,localHash:v==null?void 0:v.local_hash,srcHash:o.src_hash,dstHash:o.dst_hash,neighborAffinity:ee,hubNodes:[...p],traceSnr:z,advertiserSource:He})}):e.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center text-center px-4",children:[e.jsx(oe,{className:"w-8 h-8 text-fg-muted/50 mb-2"}),e.jsx("span",{className:"text-sm text-fg-muted",children:"Direct Reception"}),e.jsx("span",{className:"text-xs text-fg-muted/70 mt-1",children:"Zero-hop packet — received directly from sender"})]})}),e.jsxs("div",{className:"overflow-y-auto max-h-[200px] p-2 space-y-2",children:[!G&&O.length<=1&&(o.rssi!=null||o.snr!=null)&&e.jsx("div",{className:"surface-base radius-inner p-4 depth-stroke",children:e.jsxs("dl",{className:"text-xs grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-fg-muted mb-1",children:"Signal"}),e.jsx(We,{mode:"popLayout",initial:!1,children:e.jsxs(ce.dd,{className:"flex items-center gap-2",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15,ease:[.4,0,.2,1]},children:[e.jsx($e,{rssi:o.rssi,snr:o.snr,validated:Ue(o)}),e.jsx("span",{className:"font-medium text-fg-primary",children:us(o.rssi)})]},g)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-fg-muted mb-1",children:"RF"}),e.jsx(We,{mode:"popLayout",initial:!1,children:e.jsxs(ce.dd,{className:"type-data text-fg-secondary",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15,ease:[.4,0,.2,1]},children:[(De=vs(o,"rssi"))==null?void 0:De.text,(()=>{const j=vs(o,"snr");return j?` · ${j.text}`:null})()]},g)})]})]})}),h&&(h.name||h.hash)&&!L&&!re&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Source"}),e.jsx(B,{color:h.isRepeater?"blue":h.isCompanion?"violet":h.type==="room_server"?"lime":"zinc",compact:!0,children:h.type==="room_server"?"room server":h.type})]}),e.jsxs("div",{className:"p-4 space-y-2",children:[h.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:h.name}),!h.confident&&e.jsx("span",{className:"text-[10px] text-fg-muted/60 italic",children:"ambiguous"})]}),h.hash&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-[11px] font-mono text-fg-muted truncate",children:h.hash.length>16?`${h.hash.slice(0,16)}…${h.hash.slice(-8)}`:h.hash.startsWith("0x")?h.hash.slice(2,10)+"…":h.hash.slice(0,8)+"…"})]})]})]}),re&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Sender Identity"}),e.jsx(B,{color:h!=null&&h.isRepeater?"blue":h!=null&&h.isCompanion?"violet":(h==null?void 0:h.type)==="room_server"?"lime":"amber",compact:!0,children:h!=null&&h.type&&h.type!=="unknown"?h.type==="room_server"?"room server":h.type:"companion"})]}),e.jsxs("div",{className:"p-4 space-y-2.5",children:[(h==null?void 0:h.name)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:h.name}),!h.confident&&e.jsx("span",{className:"text-[10px] text-fg-muted/60 italic",children:"ambiguous"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Dest: ",e.jsx("span",{className:"font-mono",children:re.destHash})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ve,{className:"w-4 h-4 text-fg-muted flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-[11px] font-mono text-fg-muted break-all leading-relaxed",children:re.senderPublicKey})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:[re.ciphertextLength,"B encrypted payload"]})]})]})]}),L&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Advertiser"}),e.jsx(B,{color:"lime",compact:!0,children:L.nodeType})]}),e.jsxs("div",{className:"p-4 space-y-2.5",children:[L.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:L.name})]}),L.latitude&&L.longitude&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Oe,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"type-data-xs text-fg-secondary",children:[L.latitude.toFixed(5),", ",L.longitude.toFixed(5)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-[11px] font-mono text-fg-muted truncate",children:[L.publicKey.slice(0,16),"...",L.publicKey.slice(-8)]})]}),L.timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:Le(L.timestamp)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-[11px] text-fg-muted",children:L.flagsDescription||`Flags: 0x${L.flags.toString(16).padStart(2,"0")}`})]})]})]}),G&&G.pathHashes.length>0&&e.jsxs("div",{className:"radius-inner bg-inset overflow-hidden depth-stroke-inset",children:[e.jsxs("div",{className:"px-4 py-2 flex items-center justify-between",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Trace Route"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(B,{color:G.isComplete?"green":"amber",compact:!0,children:G.isComplete?"Complete":"In Progress"}),e.jsxs(B,{color:"teal",compact:!0,children:[G.pathHashes.length,"h"]})]})]}),e.jsx(ke,{packet:o,neighbors:$,localHash:v==null?void 0:v.local_hash,neighborAffinity:ee,ghostPrefixes:q,direction:"flowchart",compact:!0,overridePath:G.pathHashes,traceSnr:G.snrValues})]}),Z&&!G&&e.jsxs("div",{className:"radius-inner bg-inset overflow-hidden depth-stroke-inset",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Path"}),e.jsxs(B,{color:"zinc",compact:!0,children:[O.length,"h"]})]}),e.jsx(ke,{packet:o,neighbors:$,localHash:v==null?void 0:v.local_hash,neighborAffinity:ee,ghostPrefixes:q,direction:"flowchart",compact:!0,traceSnr:z})]})]})]})]})]})]})}const Cn=m.memo(kn);function Cs({label:s,numericValue:a,unit:t,icon:n,subtext:i,showSign:l=!1}){return e.jsxs("div",{className:"radius-inner p-3 sm:radius-inset sm:p-4 bg-subtle-fill ring-1 ring-inset ring-edge-subtle",children:[e.jsx("div",{className:"mb-1.5 sm:mb-2",children:e.jsx("span",{className:"text-xs sm:type-micro text-fg-muted",children:s})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(es,{value:a,format:{minimumFractionDigits:1,maximumFractionDigits:1,signDisplay:l?"always":"auto"},className:"type-data-hero tracking-tight text-fg-primary"}),e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx(n,{className:"w-[14px] h-[14px] text-fg-muted"}),t&&e.jsx("span",{className:"text-xs font-medium leading-tight text-fg-muted",children:t})]})]}),i&&e.jsx("p",{className:"mt-1.5 sm:mt-2 type-data-xs sm:text-[11px] text-fg-muted/80 truncate",children:i})]})}function _n({snr:s}){const a=s>=5?"bg-sys-teal":s>=0?"bg-sys-green":s>=-5?"bg-sys-amber":s>=-10?"bg-sys-orange":"bg-sys-red";return e.jsx("span",{className:H("w-1.5 h-1.5 rounded-full flex-shrink-0",a),title:`SNR: ${s.toFixed(1)} dB`})}function _s({fromPrefix:s,toPrefix:a,fromName:t,toName:n,snr:i,maxSnr:l,isWeakest:r,isStrongest:c,index:x=0}){const u=Math.max(l+5,15),y=Math.max(0,Math.min(100,(i- -20)/(u- -20)*100)),k="bg-[#0074BE]",b=i>=5?"bg-sys-teal":i>=0?"bg-sys-green":i>=-5?"bg-sys-amber":i>=-10?"bg-sys-orange":"bg-sys-red",d=.3+x*.15;return e.jsxs("div",{className:"relative p-3 pl-5 radius-inner bg-subtle-fill ring-1 ring-inset ring-edge-subtle",children:[e.jsx("span",{className:H("absolute left-0 top-1/2 -translate-y-1/2 h-4 w-0.5 rounded-full",b)}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5",children:e.jsx(_n,{snr:i})}),e.jsxs("div",{className:"sm:hidden",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:"text-[13px] font-medium text-fg-secondary truncate",children:t||s}),e.jsx(he,{className:"w-3 h-3 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-[13px] font-semibold text-fg-primary truncate",children:n||a})]}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-2 flex-shrink-0",children:[r&&e.jsx(B,{color:"red",compact:!0,children:"Low"}),c&&!r&&e.jsxs(B,{color:"amber",compact:!0,children:[e.jsx(gs,{className:"w-2.5 h-2.5"}),"Best"]}),e.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[12px] font-mono font-bold tabular-nums bg-subtle-fill-hover text-fg-primary ring-1 ring-inset ring-edge-subtle",children:[i>=0?"+":"−",Math.abs(i).toFixed(1)]})]})]}),e.jsx("div",{className:"h-1.5 bg-subtle-fill-strong rounded-full overflow-hidden",children:e.jsx(ce.div,{className:H("h-full rounded-full",k),initial:{width:0},animate:{width:`${y}%`},transition:{duration:1.5,delay:d,ease:[.25,.1,.25,1]}})})]}),e.jsxs("div",{className:"hidden sm:block",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("code",{className:"type-data-xs text-fg-muted",children:s}),t&&e.jsx("span",{className:"text-xs text-fg-secondary truncate max-w-[100px]",children:t})]}),e.jsx(he,{className:"w-3 h-3 text-fg-muted/40 flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("code",{className:"font-mono text-xs font-semibold text-fg-primary",children:a}),n&&e.jsx("span",{className:"text-xs text-fg-secondary truncate max-w-[100px]",children:n})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[r&&e.jsx(B,{color:"red",compact:!0,children:"Bottleneck"}),c&&!r&&e.jsxs(B,{color:"amber",compact:!0,children:[e.jsx(gs,{className:"w-3 h-3"}),"Strongest"]}),e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-sm font-mono font-semibold tabular-nums bg-subtle-fill-hover text-fg-primary ring-1 ring-inset ring-edge-subtle",children:[i>=0?"+":"−",Math.abs(i).toFixed(1)]})]})]}),e.jsx("div",{className:"h-1.5 bg-elevated rounded-full overflow-hidden",children:e.jsx(ce.div,{className:H("h-full rounded-full",k),initial:{width:0},animate:{width:`${y}%`},transition:{duration:1.5,delay:d,ease:[.25,.1,.25,1]}})})]})]})}function fe(s,a){if(s==="You")return"You";const t=s.toUpperCase();for(const[n,i]of Object.entries(a))if((n.startsWith("0x")?n.slice(2,4):n.slice(0,2)).toUpperCase()===t)return i.name||i.node_name||void 0}function Sn({report:s,onClose:a}){var g,u;const t=Ds(),n=(t==null?void 0:t.neighbors)??{},i=(g=t==null?void 0:t.config)!=null&&g.repeater?{latitude:t.config.repeater.latitude,longitude:t.config.repeater.longitude,name:t.config.node_name||"Local Node"}:void 0,l=(u=s.bestObservation)==null?void 0:u.decoded.snrValues,r=s.linkQuality?s.linkQuality.avgSnr>=5?"excellent":s.linkQuality.avgSnr>=0?"good":s.linkQuality.avgSnr>=-5?"fair":"poor":"unknown",x={excellent:"var(--signal-excellent)",good:"var(--signal-good)",fair:"var(--signal-fair)",poor:"var(--signal-poor)",unknown:"var(--fg-muted)"}[r];return e.jsxs(As,{open:!0,onClose:a,size:"5xl",motionPlus:!0,children:[e.jsxs("div",{className:"sm:hidden",children:[e.jsx("div",{className:"flex justify-center pt-2 pb-1",children:e.jsx("div",{className:"w-9 h-1 rounded-full bg-fg-primary/30","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-center justify-between px-4 pb-2",children:[e.jsx("h2",{className:"font-semibold text-[17px] text-fg-primary",children:"Trace Report"}),e.jsx("button",{onClick:a,className:"text-[17px] font-medium text-sys-blue active:text-sys-blue/80",children:"Done"})]})]}),e.jsx("div",{className:"sm:hidden h-[2px]",style:{backgroundColor:x,opacity:.6}}),e.jsx("div",{className:"hidden sm:block px-6 pt-5 pb-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[e.jsx("h2",{className:"type-micro",children:"Trace Report"}),e.jsxs(B,{color:r==="excellent"||r==="good"?"green":r==="fair"?"amber":"red",children:[e.jsx(fs,{className:"w-3 h-3 mr-1"}),r==="excellent"?"Excellent":r==="good"?"Good":r==="fair"?"Fair":"Poor"]})]}),e.jsx("p",{className:"mt-1 text-xs sm:text-sm font-mono text-fg-muted tabular-nums",children:s.traceTag})]}),e.jsx("button",{onClick:a,className:"p-1.5 -m-1.5 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-elevated flex-shrink-0",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),e.jsxs("div",{className:"hidden sm:flex flex-wrap items-center gap-1.5 sm:gap-2 px-4 sm:px-6 pb-3 sm:pb-4 border-b border-edge-subtle",children:[e.jsxs(B,{color:"teal",children:[e.jsx("span",{className:"font-mono tabular-nums",children:s.targetHopCount}),e.jsxs("span",{className:"ml-1",children:["hop",s.targetHopCount!==1?"s":""]})]}),e.jsxs(B,{color:"zinc",children:[e.jsx("span",{className:"font-mono tabular-nums",children:s.observationCount}),e.jsx("span",{className:"ml-1",children:"obs"})]}),s.linkQuality&&e.jsxs(B,{color:"indigo",children:[e.jsx("span",{className:"font-mono tabular-nums",children:s.linkQuality.avgSnr.toFixed(1)}),e.jsx("span",{className:"ml-1",children:"dB avg"})]}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:Ft(s.duration)}),s.linkQuality&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-fg-muted/40",children:"•"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium bg-sys-red/15 text-sys-red ring-1 ring-inset ring-sys-red/25",children:[e.jsx("span",{className:"opacity-70",children:"Min"}),e.jsx("span",{className:"font-mono tabular-nums",children:s.linkQuality.minSnr.toFixed(1)})]}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium bg-sys-teal/15 text-sys-teal ring-1 ring-inset ring-sys-teal/25",children:[e.jsx("span",{className:"opacity-70",children:"Max"}),e.jsx("span",{className:"font-mono tabular-nums",children:s.linkQuality.maxSnr.toFixed(1)})]})]})]})]}),e.jsxs(Es,{className:"p-0 overflow-hidden",children:[e.jsx("div",{className:"md:hidden h-[75vh] max-h-[calc(100vh-80px)] overflow-y-auto overflow-x-hidden",children:e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[s.linkQuality&&e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"radius-inner bg-subtle-fill ring-1 ring-inset ring-edge-subtle p-2.5 text-center",children:[e.jsx(es,{value:Math.abs(s.linkQuality.minSnr),format:{maximumFractionDigits:0,signDisplay:"never"},prefix:s.linkQuality.minSnr<0?"-":"",className:"text-[20px] font-bold font-mono tabular-nums flex items-center justify-center text-fg-primary"}),e.jsxs("div",{className:"flex items-center justify-center gap-1 mt-1",children:[e.jsx(Ze,{className:"w-2.5 h-2.5 text-fg-muted"}),e.jsx("span",{className:"text-xs text-fg-muted",children:"Min dB"})]})]}),e.jsxs("div",{className:"radius-inner bg-subtle-fill ring-1 ring-inset ring-edge-subtle p-2.5 text-center",children:[e.jsx(es,{value:s.linkQuality.maxSnr,format:{maximumFractionDigits:0,signDisplay:"always"},className:"text-[20px] font-bold font-mono text-fg-primary tabular-nums flex items-center justify-center"}),e.jsxs("div",{className:"flex items-center justify-center gap-1 mt-1",children:[e.jsx(ps,{className:"w-2.5 h-2.5 text-fg-muted"}),e.jsx("span",{className:"text-xs text-fg-muted",children:"Max dB"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(B,{color:r==="excellent"||r==="good"?"green":r==="fair"?"amber":"red",compact:!0,children:[e.jsx(fs,{className:"w-2.5 h-2.5 mr-0.5"}),r==="excellent"?"Excellent":r==="good"?"Good":r==="fair"?"Fair":"Poor"]}),e.jsxs(B,{color:"teal",compact:!0,children:[s.targetHopCount," hops"]}),e.jsxs(B,{color:"zinc",compact:!0,children:[s.observationCount," obs"]}),e.jsx("span",{className:"type-data-xs text-fg-muted ml-auto",children:s.traceTag.slice(0,8)})]}),s.targetPath.length>0&&e.jsx("div",{className:"overflow-hidden radius-inset",children:e.jsx("div",{className:"aspect-[4/3] w-full",children:e.jsx(Ge,{path:s.targetPath,neighbors:n,localNode:i,localHash:t==null?void 0:t.local_hash,srcHash:s.srcHash,dstHash:s.dstHash,traceSnr:l})})}),e.jsxs("div",{className:"radius-inset bg-body overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"text-[11px] font-medium text-fg-secondary",children:"Route Path"}),s.linkQuality&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:["SNR ",s.linkQuality.minSnr.toFixed(1)," → ",s.linkQuality.maxSnr.toFixed(1)," dB"]})]}),s.bestObservation?e.jsx(ke,{packet:s.bestObservation.packet,neighbors:n,localHash:t==null?void 0:t.local_hash,direction:"flowchart",compact:!0,overridePath:s.targetPath,traceSnr:s.bestObservation.decoded.snrValues}):e.jsx("div",{className:"p-6 text-center text-fg-muted text-xs",children:"No path data available"})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"type-micro text-fg-muted mb-2",children:["Link Quality · ",s.hopStats.length," hops"]}),e.jsx("div",{className:"space-y-1.5",children:s.hopStats.length>0?s.hopStats.map((y,k)=>{var M,o,N;const b=k<s.targetPath.length-1?s.targetPath[k+1]:"You",d=fe(y.prefix,n),C=fe(b,n);return e.jsx(_s,{fromPrefix:y.prefix,toPrefix:b,fromName:d,toName:C,snr:y.snr,maxSnr:((M=s.linkQuality)==null?void 0:M.maxSnr)??10,isWeakest:((o=s.linkQuality)==null?void 0:o.weakestLinkPosition)===k,isStrongest:((N=s.linkQuality)==null?void 0:N.strongestLinkPosition)===k,index:k},`${y.prefix}-${k}`)}):e.jsx("div",{className:"text-xs text-fg-muted py-6 text-center",children:"No link data collected"})})]}),e.jsx("div",{className:"pt-1 pb-2 text-center",children:e.jsxs("span",{className:"text-xs text-fg-muted",children:["Traced ",Je(s.firstSeen)]})})]})}),e.jsxs("div",{className:"hidden md:flex md:flex-row h-[70vh] max-h-[calc(100vh-200px)] overflow-hidden",children:[e.jsx("div",{className:"w-1/2 flex flex-col min-w-0 min-h-0 overflow-hidden border-r border-edge-subtle",children:e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[s.linkQuality&&(()=>{const y=s.targetPath[s.linkQuality.weakestLinkPosition],k=s.targetPath[s.linkQuality.weakestLinkPosition+1]||"You",b=fe(y,n),d=fe(k,n),C=s.targetPath[s.linkQuality.strongestLinkPosition],M=s.targetPath[s.linkQuality.strongestLinkPosition+1]||"You",o=fe(C,n),N=fe(M,n);return e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Cs,{label:"Weakest Link",numericValue:s.linkQuality.minSnr,unit:"dB",icon:Ze,subtext:`${b||y} → ${d||k}`}),e.jsx(Cs,{label:"Best Link",numericValue:s.linkQuality.maxSnr,showSign:!0,unit:"dB",icon:ps,subtext:`${o||C} → ${N||M}`})]})})(),e.jsxs("div",{children:[e.jsx("h3",{className:"type-micro text-fg-muted mb-3",children:"Link Details"}),e.jsx("div",{className:"space-y-2",children:s.hopStats.length>0?s.hopStats.map((y,k)=>{var M,o,N;const b=k<s.targetPath.length-1?s.targetPath[k+1]:"You",d=fe(y.prefix,n),C=fe(b,n);return e.jsx(_s,{fromPrefix:y.prefix,toPrefix:b,fromName:d,toName:C,snr:y.snr,maxSnr:((M=s.linkQuality)==null?void 0:M.maxSnr)??10,isWeakest:((o=s.linkQuality)==null?void 0:o.weakestLinkPosition)===k,isStrongest:((N=s.linkQuality)==null?void 0:N.strongestLinkPosition)===k,index:k},`${y.prefix}-${k}`)}):e.jsx("div",{className:"text-xs text-fg-muted py-8 text-center",children:"No link data collected"})})]}),e.jsxs("div",{className:"pt-2 text-center",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Traced "}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:Je(s.firstSeen)})]})]})}),e.jsxs("div",{className:"w-1/2 min-w-0 overflow-y-auto p-3 space-y-2",children:[s.targetPath.length>0&&e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-square w-full",children:e.jsx(Ge,{path:s.targetPath,neighbors:n,localNode:i,localHash:t==null?void 0:t.local_hash,srcHash:s.srcHash,dstHash:s.dstHash,traceSnr:l})})}),e.jsxs("div",{className:"radius-inset bg-black overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Trace Route"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(B,{color:s.isComplete?"green":"amber",compact:!0,children:s.isComplete?"Complete":`${s.maxHopsObserved}/${s.targetHopCount}`}),e.jsxs(B,{color:"teal",compact:!0,children:[s.targetHopCount," hop",s.targetHopCount!==1?"s":""]})]})]}),s.linkQuality&&s.bestObservation&&e.jsxs("div",{className:"flex items-center gap-4 px-4 pb-2 type-data-xs text-fg-muted",children:[e.jsxs("span",{children:[e.jsx("span",{className:"opacity-60",children:"Tag"})," ",e.jsx("code",{className:"text-sys-teal tabular-nums",children:s.traceTag.slice(0,8)})]}),e.jsxs("span",{children:[e.jsx("span",{className:"opacity-60",children:"SNR"})," ",e.jsxs("code",{className:"text-sys-indigo tabular-nums",children:[s.linkQuality.minSnr.toFixed(1),"–",s.linkQuality.maxSnr.toFixed(1)]}),e.jsx("span",{className:"opacity-60",children:" dB"})]})]}),s.bestObservation?e.jsx(ke,{packet:s.bestObservation.packet,neighbors:n,localHash:t==null?void 0:t.local_hash,direction:"flowchart",compact:!0,overridePath:s.targetPath,traceSnr:s.bestObservation.decoded.snrValues}):e.jsx("div",{className:"p-8 text-center text-fg-muted text-xs",children:"No path data available"})]})]})]})]})]})}const Tn=m.memo(Sn),Zs=[{target:"PacketList",fn:"type",minStage:1},{target:"PacketList",fn:"route",minStage:1},{target:"PacketList",fn:"rssi",minStage:1},{target:"PacketList",fn:"snr",minStage:1},{target:"PacketList",fn:"path",minStage:1,when:Vt},{target:"PacketList",fn:"src_hash",minStage:1,when:Gt},{target:"PacketList",fn:"text",minStage:1,when:Qt},{target:"PacketList",fn:"ack",minStage:1,when:qt},{target:"PacketList",fn:"decrypt",minStage:2,when:Wt},{target:"PacketList",fn:"duplicates",minStage:1}];Ot(Zs);const Pn=48,Bn=72,Mn=100,Ln=5,Rn=600,Js="(min-width: 640px)";let xe=null;function Hn(s){return typeof window>"u"?()=>{}:(xe||(xe=window.matchMedia(Js)),xe.addEventListener("change",s),()=>xe==null?void 0:xe.removeEventListener("change",s))}function Fn(){return typeof window>"u"?!0:(xe||(xe=window.matchMedia(Js)),xe.matches)}function Dn(){return m.useSyncExternalStore(Hn,Fn,()=>!0)}function An(s,a,t){const[n,i]=m.useState(1),l=t?Math.ceil(s/a):1;m.useEffect(()=>{n>l&&l>0&&queueMicrotask(()=>i(1))},[l,n]);const r=m.useCallback(x=>i(Math.max(1,Math.min(x,l))),[l]),c=m.useMemo(()=>ka(n,l),[n,l]);return{currentPage:n,totalPages:l,goToPage:r,pageRange:c}}function En(s,a){const[t,n]=m.useState(null),i=m.useRef(0);return m.useEffect(()=>{var u,y;if(!a||!s.length)return;const l=((u=s[0])==null?void 0:u.timestamp)??0,r=l>i.current&&i.current>0;if(i.current=l,!r)return;const c=(y=s[0])==null?void 0:y.packet_hash;if(!c)return;const x=requestAnimationFrame(()=>n(c)),g=setTimeout(()=>n(null),600);return()=>{cancelAnimationFrame(x),clearTimeout(g)}},[s,a]),t}function zn(s){if(!s||s.length<6)return null;const a=Dt(s);if(!a||a.offset>=s.length)return null;const t=s.slice(a.offset);return t.length>=38?t.slice(0,38):t}function In(s){if(s.length<=1)return s;const a=new Map,t=new Map,n=new Map;for(let r=0;r<s.length;r++){const{packet:c}=s[r],x=c.payload_type??c.type;if(x!==ls.GRP_TXT)continue;const g=c._payloadHexPrefix??zn(c.raw_packet);if(g){const b=a.get(g);if(b!==void 0){n.set(r,b);continue}a.set(g,r)}const u=c.payload_length??c.length??0,y=Math.floor((c.timestamp??0)/60),k=`${x}:${u}:${y}`;if(!g){const b=t.get(k);if(b!==void 0){n.set(r,b);continue}}t.has(k)||t.set(k,r)}if(n.size===0)return s;const i=new Map;for(const[r,c]of n)i.set(c,(i.get(c)??0)+s[r].dupeCount);const l=[];for(let r=0;r<s.length;r++){if(n.has(r))continue;const c=i.get(r)??0;l.push(c>0?{packet:s[r].packet,dupeCount:s[r].dupeCount+c}:s[r])}return l}function $n(s){const a=new Map;for(const t of s)if((t.payload_type??t.type)===ls.TRACE&&t.packet_hash){const i=t._traceTag??(t.payload?zs(t.payload):null);i&&a.set(t.packet_hash,i)}return a}function Un(s){const a=new Map;if(s.length===0)return a;for(let t=0;t<s.length;t++){const n=s[t].packet_hash;if(!n)continue;const i=s[t-1],l=s[t+1],r=(i==null?void 0:i.packet_hash)===n,c=(l==null?void 0:l.packet_hash)===n;(r||c)&&(r&&c?a.set(t,"middle"):r?a.set(t,"last"):c&&a.set(t,"first"))}return a}function Ss({message:s}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-14 text-center",children:[e.jsx(oe,{className:"size-6 text-fg-muted mb-2"}),e.jsx("p",{className:"text-sm text-fg-primary",children:s}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Packets will appear here"})]})}function Ts(){return e.jsx("div",{className:"py-14 text-center text-sm text-fg-muted",children:"Loading packets…"})}function On({showPagination:s,currentPage:a,perPage:t,displayCount:n,totalCount:i,action:l}){const r=s?(a-1)*t+1:1,c=s?Math.min(a*t,i):n;return e.jsxs("div",{className:"flex items-center justify-between gap-4 border-t border-edge-subtle px-4 py-3 text-xs text-fg-muted sm:px-6",children:[e.jsxs("span",{children:["Showing"," ",e.jsx("span",{className:"font-medium text-fg-secondary",children:s?`${r}–${c}`:n})," ","of"," ",e.jsx("span",{className:"font-medium text-fg-secondary",children:i})," ","packets"]}),l]})}function pr({packets:s,allPackets:a,localHash:t,neighbors:n,loading:i=!1,maxPackets:l,perPage:r=50,showPagination:c=!1,onPacketSelect:x,flashNewest:g=!1,emptyMessage:u="No packets found",className:y,footerAction:k,hideDupes:b=!1,getDecodedContent:d,onChannelClick:C,resolveSource:M,virtualized:o=!0}){Ut(Zs);const[N,f]=m.useState(null),[_,v]=m.useState(null),[p,I]=m.useState({traceTag:null,dupeGroup:null}),V=m.useRef(null),q=ra(j=>j.setModalMapOpen);m.useEffect(()=>(q(!!N),()=>q(!1)),[N,q]),m.useLayoutEffect(()=>{I({traceTag:null,dupeGroup:null})},[s]);const Y=a??s,E=m.useMemo(()=>l&&l>0&&!b?s.slice(0,l):s,[s,l,b]),X=m.useMemo(()=>{if(!b)return null;const j=Ca(E),w=In(j);return l&&l>0?w.slice(0,l):w},[E,b,l]),F=X?X.length:E.length,{currentPage:D,totalPages:W,goToPage:Z,pageRange:O}=An(F,r,c),T=m.useMemo(()=>{if(b||!c)return E;const j=(D-1)*r;return E.slice(j,j+r)},[E,c,D,r,b]),$=m.useMemo(()=>{if(!X)return null;if(!c)return X;const j=(D-1)*r;return X.slice(j,j+r)},[X,c,D,r]),ee=m.useMemo(()=>$n(T),[T]),ne=m.useMemo(()=>Un(T),[T]),P=En(s,g),h=Dn(),se=m.useMemo(()=>b&&$?$:T,[b,$,T]),te=o&&se.length>Mn,R=h?Pn:Bn,U=Et({count:te?se.length:0,getScrollElement:()=>V.current,estimateSize:()=>R,overscan:Ln}),G=m.useCallback((j,w)=>{var Ne,Ae;const S=j.packet_hash;if(!S)return[j];let A=w;for(;A>0&&((Ne=T[A-1])==null?void 0:Ne.packet_hash)===S;)A--;let K=w;for(;K<T.length-1&&((Ae=T[K+1])==null?void 0:Ae.packet_hash)===S;)K++;return A===K?[j]:T.slice(A,K+1)},[T]),z=m.useCallback(j=>{var A,K;const w=(A=T[j])==null?void 0:A.packet_hash;if(!w)return j;let S=j;for(;S>0&&((K=T[S-1])==null?void 0:K.packet_hash)===w;)S--;return S},[T]),L=m.useCallback(j=>{var A,K;const w=(A=T[j])==null?void 0:A.packet_hash;if(!w)return j;let S=j;for(;S<T.length-1&&((K=T[S+1])==null?void 0:K.packet_hash)===w;)S++;return S},[T]),ue=m.useCallback((j,w)=>{if(x){x(j);return}if(w!==void 0){const S=G(j,w),A=S.indexOf(j);f({packets:S,initialIndex:A>=0?A:0,rowIndex:w})}else f({packets:[j],initialIndex:0,rowIndex:0})},[x,G]),Me=m.useCallback(()=>{if(!N)return;const w=z(N.rowIndex)-1;if(w<0)return;const S=T[w];if(!S)return;const A=G(S,w);f({packets:A,initialIndex:0,rowIndex:w})},[N,T,z,G]),re=m.useCallback(()=>{if(!N)return;const w=L(N.rowIndex)+1;if(w>=T.length)return;const S=T[w];if(!S)return;const A=G(S,w);f({packets:A,initialIndex:0,rowIndex:w})},[N,T,L,G]),Le=m.useMemo(()=>N?z(N.rowIndex)>0:!1,[N,z]),os=m.useMemo(()=>N?L(N.rowIndex)<T.length-1:!1,[N,L,T.length]),Re=m.useCallback(j=>I(w=>({...w,traceTag:j})),[]),Te=m.useCallback(j=>I(w=>({...w,dupeGroup:j})),[]),ds=m.useCallback(()=>{I({traceTag:null,dupeGroup:null})},[]),be=m.useCallback(j=>{const w=Y.filter(K=>(K.payload_type??K.type)===ls.TRACE&&K.payload&&zs(K.payload)===j);if(w.length===0)return;const A=It(w).get(j);A!=null&&A.length&&v($t(j,A))},[Y]),He=m.useCallback(j=>{const w=Y.find(S=>S.packet_hash===j);w&&(v(null),ue(w))},[Y,ue]),Fe=m.useCallback((j,w,S)=>{const A=h?Ra:Ha;if(S){const{packet:pe,dupeCount:st}=j,ms=pe.packet_hash?ee.get(pe.packet_hash):void 0,tt=p.traceTag!==null&&ms===p.traceTag;return e.jsx(A,{packet:pe,onClick:at=>ue(at,w),localHash:t,neighbors:n,resolveSource:M,isFlashing:g&&P===pe.packet_hash,traceTag:ms,isTraceHighlighted:tt,onTraceHover:Re,onViewTraceReport:be,dupeCount:st,getDecodedContent:d,onChannelClick:C},`${pe.packet_hash}_${pe.timestamp}_${w}`)}const K=j,Ne=K.packet_hash?ee.get(K.packet_hash):void 0,Ae=p.traceTag!==null&&Ne===p.traceTag,xs=ne.get(w),et=xs!==void 0&&p.dupeGroup!==null&&K.packet_hash===p.dupeGroup;return e.jsx(A,{packet:K,onClick:pe=>ue(pe,w),localHash:t,neighbors:n,resolveSource:M,isFlashing:g&&P===K.packet_hash,traceTag:Ne,isTraceHighlighted:Ae,onTraceHover:Re,onViewTraceReport:be,dupeGroupPosition:xs,isDupeGroupHovered:et,onDupeGroupHover:Te,getDecodedContent:d,onChannelClick:C},`${K.packet_hash}_${K.timestamp}_${w}`)},[h,ee,p.traceTag,p.dupeGroup,ue,t,n,M,g,P,Re,be,ne,Te,d,C]),qe=()=>{if(i&&s.length===0)return e.jsx(Ts,{});if(T.length===0)return e.jsx(Ss,{message:u});const j=b&&$!==null;return(j?$:T).map((S,A)=>Fe(S,A,j))},De=()=>{if(i&&s.length===0)return e.jsx(Ts,{});if(se.length===0)return e.jsx(Ss,{message:u});const j=b&&$!==null,w=U.getVirtualItems();return e.jsx("div",{style:{height:`${U.getTotalSize()}px`,width:"100%",position:"relative"},children:w.map(S=>{const A=se[S.index];return e.jsx("div",{"data-index":S.index,ref:U.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${S.start}px)`},children:Fe(A,S.index,j)},S.key)})})};return e.jsxs("div",{className:H("flex flex-col",y),onMouseLeave:ds,children:[te?e.jsx("div",{ref:V,className:"divide-y divide-edge-subtle overflow-auto",style:{maxHeight:Rn},children:De()}):e.jsx("div",{className:"divide-y divide-edge-subtle py-1",children:qe()}),c&&W>1&&e.jsx("nav",{className:"border-t border-edge-subtle px-4 py-3",children:e.jsxs(ya,{className:"justify-center",children:[e.jsx(ja,{onClick:()=>Z(D-1),disabled:D===1}),e.jsx(Na,{children:O.map((j,w)=>j==="gap"?e.jsx(wa,{},`gap-${w}`):e.jsx(va,{page:j,current:j===D,onClick:Z},j))}),e.jsx(ba,{onClick:()=>Z(D+1),disabled:D===W})]})}),e.jsx(On,{showPagination:c,currentPage:D,perPage:r,displayCount:$?$.length:T.length,totalCount:c?F:s.length,action:k}),!x&&N&&e.jsx(Cn,{packets:N.packets,initialIndex:N.initialIndex,onClose:()=>f(null),onNavigatePrev:Me,onNavigateNext:re,hasPrev:Le,hasNext:os,resolveSource:M,getDecodedContent:d}),_&&e.jsx(Tn,{report:_,onClose:()=>v(null),onViewPacket:He})]})}export{Ws as C,pr as P,fs as S,gs as T,Ta as g,ur as u};
