var _t=Object.defineProperty;var Rt=(t,s,n)=>s in t?_t(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var pe=(t,s,n)=>Rt(t,typeof s!="symbol"?s+"":s,n);import{d as He,r as o,j as e,t as Ce,c as at,bg as Nt,c9 as vt,ca as et,h as ke,cb as Tt,x as Ae,cc as Dt,cd as Lt,ce as Et,k as It,cf as Pt,cg as Ot,ch as Ft,ci as Ht,cj as Bt,bI as $t,ck as $e,bL as zt,cl as Wt,cm as Ut,N as ve,cn as Gt,co as Vt,cp as qt,cq as Kt,bi as Yt,K as Xt,Q as Zt,P as Qt,G as Jt,ao as es,ap as ts,V as ss,ai as ns,cr as as,cs as ze,ct as it,aa as is,R as rs,a4 as ls}from"./index-BOwCLZTK.js";import{L as we}from"./layers-Dg2mpSl7.js";import{u as tt,h as os,r as st}from"./consumer-registry-CTjikLma.js";import{C as We,e as cs}from"./easing-CsgXD0uy.js";import{T as ms,M as ds}from"./MqttModeBadge-CSj5wNzF.js";import{C as ue,P as us,a as hs,B as xs}from"./PageLayout-QKntxcnp.js";import{D as ps}from"./DataBox-BVnEv6Au.js";import{E as fs,A as Ue,D as Pe}from"./DataValue-x_TMPgMk.js";import{C as gs}from"./CollisionExplorerModal-Cudk5ace.js";import{H as rt}from"./hash-Dwn2PbMF.js";import{T as lt}from"./triangle-alert-SO3tIa8w.js";import{L as Oe}from"./LightSparkline-C68RXWon.js";import{A as bs}from"./activity-D5uH2SFx.js";import{c as ys,a as js,A as Ns}from"./AnalyzerFilterPanel-BWsROE43.js";import{useResolveSource as vs}from"./usePipelineStore-Cw6U5jyB.js";import{R as ye,C as Me}from"./Grid-eFMUBxsw.js";import{S as ks}from"./settings-2-CXNfSapN.js";import{N as ws}from"./network-D0Fgg1y-.js";import"./chevron-right-DJVm4pVP.js";import"./map-pin-C2z_C0J3.js";import"./index-2RIoVPos.js";import"./BasemapLayer-B-5TmAfZ.js";import"./monitor-smartphone-Dd11JEL9.js";import"./node-types-C6okL8rE.js";import"./circle-question-mark-XDnZ1ChV.js";import"./funnel-CWx99rlN.js";import"./search-Ba9CRHru.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 Ss=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],Ms=He("chart-line",Ss);/**
 * @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 Cs=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],ot=He("circle-check-big",Cs);/**
 * @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 As=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],_s=He("grid-3x3",As);/**
 * @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 Rs=[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"19",cy:"5",r:"1",key:"w8mnmm"}],["circle",{cx:"5",cy:"5",r:"1",key:"lttvr7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}],["circle",{cx:"19",cy:"19",r:"1",key:"shf9b7"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]],Ts=He("grip",Rs),kt={useAbsoluteThresholds:!0,baselinePercentile:6,spikePercentile:50,baselineDbm:-107,spikeDbm:-100,mergeGapSeconds:45,minSequenceLength:16,similarityToleranceDbm:5};function Ne(t,s){if(t.length===0)return 0;const n=s/100*(t.length-1),a=Math.floor(n),i=Math.ceil(n);return a===i?t[a]:t[a]+(t[i]-t[a])*(n-a)}function ct(t){if(t.length===0)return{median:0,p90:0,p95:0,p99:0,max:0,min:0};const s=[...t].sort((n,a)=>n-a);return{median:Ne(s,50),p90:Ne(s,90),p95:Ne(s,95),p99:Ne(s,99),max:s[s.length-1],min:s[0]}}function Ds(t,s={}){const n={...kt,...s};if(t.length<10)return{anomalies:[],thresholds:ct([]),totalSamples:t.length,anomalySamples:0};const a=t.map(b=>b.noise_floor_dbm),i=ct(a),l=[...a].sort((b,w)=>b-w);let r,u;n.useAbsoluteThresholds?(r=n.baselineDbm,u=n.spikeDbm):(r=Ne(l,n.baselinePercentile),u=Ne(l,n.spikePercentile));const c=[...t].sort((b,w)=>b.timestamp-w.timestamp),p=[];let d=null,x=0;for(const b of c)if(b.noise_floor_dbm>r&&b.noise_floor_dbm<u)if(x++,!d)d={startTs:b.timestamp,endTs:b.timestamp,values:[b.noise_floor_dbm],timestamps:[b.timestamp],rollingAvg:b.noise_floor_dbm};else{const k=Math.abs(b.noise_floor_dbm-d.rollingAvg)<=n.similarityToleranceDbm,T=b.timestamp-d.endTs<=n.mergeGapSeconds;k&&T?(d.endTs=b.timestamp,d.values.push(b.noise_floor_dbm),d.timestamps.push(b.timestamp),d.rollingAvg=d.values.reduce((O,z)=>O+z,0)/d.values.length):(d.values.length>=n.minSequenceLength&&p.push(d),d={startTs:b.timestamp,endTs:b.timestamp,values:[b.noise_floor_dbm],timestamps:[b.timestamp],rollingAvg:b.noise_floor_dbm})}else d&&d.values.length>=n.minSequenceLength&&p.push(d),d=null;return d&&d.values.length>=n.minSequenceLength&&p.push(d),p.length===0?{anomalies:[],thresholds:i,totalSamples:t.length,anomalySamples:x,debug:{baselineCutoff:r,spikeCutoff:u,midBandSamples:x}}:{anomalies:p.map(b=>{const w=Math.max(...b.values),N=b.values.reduce((k,T)=>k+T,0)/b.values.length;return{startTs:b.startTs,endTs:b.endTs,peakValue:w,avgValue:N,severity:Ls(N,r,u),sampleCount:b.values.length}}),thresholds:i,totalSamples:t.length,anomalySamples:x,debug:{baselineCutoff:r,spikeCutoff:u,midBandSamples:x}}}function Ls(t,s,n){const a=n-s;if(a===0)return"moderate";const i=(t-s)/a;return i>.66?"critical":i>.33?"severe":"moderate"}const Es=Object.entries(Nt).map(([t,s])=>{const n=parseInt(t,10);return{typeNum:n,key:`TYPE_${n}`,label:s}});function nt({sortedTypes:t,highlightedType:s,onTypeHover:n,aggregateShares:a,hoverData:i}){const l=o.useMemo(()=>{if(!i)return null;const c=new Map;for(const p of i.items)c.set(p.key,p.value);return c},[i]),r=l!==null,u=o.useMemo(()=>{const c=new Set(t.map(x=>x.key)),p=t.map(x=>({typeNum:x.typeNum,key:x.key,label:x.label})),d=Es.filter(x=>!c.has(x.key));return[...p,...d]},[t]);return e.jsxs("div",{className:"flex-shrink-0 pt-2 sm:pt-3 mt-1 sm:mt-2 px-0 sm:pr-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mx-0 sm:ml-9 sm:mr-0 mb-1 sm:mb-1.5 type-data-xs",children:[e.jsx("span",{className:"text-fg-muted",children:"Packet Types"}),r&&(i==null?void 0:i.timeLabel)&&e.jsx("span",{className:"text-sys-indigo tabular-nums",children:i.timeLabel})]}),e.jsx("div",{className:"flex flex-wrap gap-x-3 sm:gap-x-4 gap-y-1 type-data-xs mx-0 sm:ml-9 sm:mr-0",onMouseLeave:()=>n(null),children:u.map(c=>{const p=Ce(c.typeNum),d=(l==null?void 0:l.get(c.key))??0,x=a.get(c.key)??0,v=r?d:x,b=v>1e-4,w=a.has(c.key),N=s===c.key,k=s&&!N||r&&d<=1e-4||!r&&!s&&!w;return e.jsxs("div",{className:at("flex items-center gap-1.5 transition-opacity cursor-pointer hover:opacity-80",k&&"opacity-30"),onMouseEnter:()=>n(c.key),children:[e.jsx("div",{className:"shrink-0 w-3 h-3 rounded-xs",style:{backgroundColor:p}}),e.jsx("span",{className:"text-fg-secondary whitespace-nowrap",children:c.label}),b&&e.jsxs("span",{className:at("tabular-nums",r?"text-fg-primary":"text-fg-muted"),children:[(v*100).toFixed(1),"%"]})]},c.key)})})]})}const mt='ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',Is=2,Ps=3,Os=32,Fs=20,Hs=80;function dt(t,s,n,a,i){const l=t.reduce((p,d)=>p+d,0);if(l<=0||t.length===0)return[];const r=t.map((p,d)=>d).sort((p,d)=>t[d]-t[p]),u=r.map(p=>t[p]),c=new Array(t.length);return Je(u,r,l,s,n,a,i,c),c}function Je(t,s,n,a,i,l,r,u){if(t.length===0)return;if(t.length===1){u[s[0]]={x:a,y:i,w:l,h:r,index:s[0]};return}const c=l*r/n,p=l>=r,d=p?r:l;let x=0,v=1/0,b=0;for(let z=0;z<t.length;z++){const F=x+t[z],V=F*c/d;if(V<=0){b=z+1,x=F;continue}const I=t[0]*c/V,y=t[z]*c/V,m=Math.max(I>V?I/V:V/I,y>V?y/V:V/y);if(m<=v)v=m,b=z+1,x=F;else break}const w=d>0?x*c/d:0;let N=0;for(let z=0;z<b;z++){const V=(x>0?t[z]/x:0)*d;p?u[s[z]]={x:a,y:i+N,w,h:V,index:s[z]}:u[s[z]]={x:a+N,y:i,w:V,h:w,index:s[z]},N+=V}const k=t.slice(b),T=s.slice(b),O=n-x;p?Je(k,T,O,a+w,i,l-w,r,u):Je(k,T,O,a,i+w,l,r-w,u)}function ut(t,s,n,a,i,l){for(const r of s){const u=n[r.index];if(!u)continue;const c=Is*l,p=r.x*l+c/2,d=r.y*l+c/2,x=r.w*l-c,v=r.h*l-c;if(x<=0||v<=0)continue;const b=Ce(u.typeNum),w=i!==null&&i!==r.index;t.save(),t.globalAlpha=w?.4:1;const N=Ps*l;t.beginPath(),t.moveTo(p+N,d),t.lineTo(p+x-N,d),t.quadraticCurveTo(p+x,d,p+x,d+N),t.lineTo(p+x,d+v-N),t.quadraticCurveTo(p+x,d+v,p+x-N,d+v),t.lineTo(p+N,d+v),t.quadraticCurveTo(p,d+v,p,d+v-N),t.lineTo(p,d+N),t.quadraticCurveTo(p,d,p+N,d),t.closePath(),t.fillStyle=b,t.fill(),t.strokeStyle="rgba(0,0,0,0.2)",t.lineWidth=1*l,t.stroke();const k=4*l,T=r.w>36&&r.h>20,O=r.w>36&&r.h>32;if(T){const z=11*l;if(O){const F=a>0?u.size/a*100:0;t.font=`500 ${8*l}px ${mt}`,t.fillStyle="rgba(0,0,0,0.6)",t.textBaseline="alphabetic",t.textAlign="left",t.fillText(`${F.toFixed(1)}%`,p+k,d+v-k-z)}t.font=`600 ${9*l}px ${mt}`,t.fillStyle="rgba(0,0,0,0.85)",t.textBaseline="alphabetic",t.textAlign="left",t.fillText(u.name,p+k,d+v-k)}t.restore()}}function Bs(t,s,n){for(const a of t)if(s>=a.x&&s<=a.x+a.w&&n>=a.y&&n<=a.y+a.h)return a.index;return null}function $s({data:t,total:s,color:n,position:a,containerWidth:i,isAirtime:l}){if(!t||!a)return null;const r=(t.value/s*100).toFixed(1),u=160,d=i-a.x<u+24?Math.max(8,a.x-u-8):a.x+16;return e.jsx("div",{className:"absolute z-50 pointer-events-none",style:{left:d,top:Math.max(8,a.y-60)},children:e.jsxs("div",{className:"bg-tooltip-bg border border-edge-subtle rounded-lg px-3 py-2 shadow-xl min-w-[140px]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{backgroundColor:n}}),e.jsx("span",{className:"type-data-sm font-semibold text-fg-primary",children:t.name})]}),e.jsxs("div",{className:"space-y-0.5 type-data-xs text-fg-muted",children:[e.jsxs("div",{className:"flex justify-between gap-4",children:[e.jsx("span",{children:l?"Airtime":"Count"}),e.jsx("span",{className:"text-fg-primary tabular-nums font-medium",children:l?ht(t.value):t.value.toLocaleString()})]}),e.jsxs("div",{className:"flex justify-between gap-4",children:[e.jsx("span",{children:"Share"}),e.jsxs("span",{className:"text-fg-primary tabular-nums font-medium",children:[r,"%"]})]}),e.jsxs("div",{className:"flex justify-between gap-4",children:[e.jsx("span",{children:"Total"}),e.jsx("span",{className:"text-fg-primary tabular-nums font-medium",children:l?ht(s):s.toLocaleString()})]})]})]})})}function ht(t){return t>=6e4?`${(t/6e4).toFixed(1)}m`:t>=1e3?`${(t/1e3).toFixed(1)}s`:`${Math.round(t)}ms`}function zs({sortedTypes:t,aggregateShares:s,mode:n="share"}){var I,y,m;const[a,i]=o.useState(null),[l,r]=o.useState(null),[u,c]=o.useState(0),[p,d]=o.useState(null),x=o.useRef(null),v=o.useRef(null),b=o.useRef([]),w=n==="airtime",N=o.useMemo(()=>t.reduce((f,S)=>f+(w?S.totalAirtime:S.totalCount),0),[t,w]),k=o.useMemo(()=>t.map((f,S)=>({name:f.label,size:w?f.totalAirtime:f.totalCount,index:S,typeNum:f.typeNum,key:f.key})),[t,w]);o.useEffect(()=>{const f=v.current;if(!f)return;const S=f.parentElement;if(!S)return;const E=S.getBoundingClientRect(),W=E.width,g=E.height;if(W<=0||g<=0)return;const _=window.devicePixelRatio||1;f.width=Math.floor(W*_),f.height=Math.floor(g*_),f.style.width=`${W}px`,f.style.height=`${g}px`;const U=k.map(H=>H.size),Q=dt(U,0,0,W,g);b.current=Q;const ee=f.getContext("2d");ee&&(ee.clearRect(0,0,f.width,f.height),ut(ee,Q,k,N,a,_))},[k,N,a]),o.useEffect(()=>{const f=x.current;if(!f)return;const S=new ResizeObserver(()=>{const E=v.current;if(!E)return;const W=f.getBoundingClientRect(),g=W.width,_=W.height;if(g<=0||_<=0)return;const U=window.devicePixelRatio||1;E.width=Math.floor(g*U),E.height=Math.floor(_*U),E.style.width=`${g}px`,E.style.height=`${_}px`;const Q=k.map(R=>R.size),ee=dt(Q,0,0,g,_);b.current=ee;const H=E.getContext("2d");H&&(H.clearRect(0,0,E.width,E.height),ut(H,ee,k,N,a,U))});return S.observe(f),()=>S.disconnect()},[k,N]);const T=o.useCallback(f=>{const S=x.current;if(!S)return;const E=S.getBoundingClientRect(),W=f.clientX-E.left,g=f.clientY-E.top,_=Bs(b.current,W,g);i(_),_!==null?(c(E.width),r({x:W,y:g})):r(null)},[]),O=o.useCallback(()=>{i(null),r(null)},[]),z=o.useCallback(f=>{if(d(f),f){const S=k.findIndex(E=>E.key===f);i(S>=0?S:null)}else i(null)},[k]),F=a!==null?{name:((I=k[a])==null?void 0:I.name)??"",value:((y=k[a])==null?void 0:y.size)??0}:null,V=a!==null?Ce((m=k[a])==null?void 0:m.typeNum):"";return t.length===0||N===0?e.jsxs("div",{className:"h-full flex items-center justify-center text-fg-muted",children:[e.jsx(we,{className:"w-6 h-6 mr-2 opacity-50"}),e.jsx("span",{children:"No packet type data available"})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 min-h-0 relative",children:e.jsxs("div",{className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:Os,right:0,top:0,bottom:Fs},ref:x,onMouseMove:T,onMouseLeave:O,children:[e.jsx("canvas",{ref:v,className:"absolute inset-0",style:{cursor:"default"}}),e.jsx($s,{data:F,total:N,color:V,position:l,containerWidth:u,isAirtime:w})]})}),e.jsx("div",{style:{minHeight:Hs},children:e.jsx(nt,{sortedTypes:t,highlightedType:p,onTypeHover:z,aggregateShares:s})})]})}const Ge=32,Ve=20,Ws=300;function je(t){return t>=1e9?`${(t/1e9).toFixed(1)} Gb`:t>=1e6?`${(t/1e6).toFixed(1)} Mb`:t>=1e3?`${(t/1e3).toFixed(1)} Kb`:`${t.toFixed(0)} B`}function Us({packets:t,mode:s,startTs:n,endTs:a,radioConfig:i,bucketCount:l,lockedYMax:r,legendMinH:u}){const c=o.useMemo(()=>vt(),[]),p=c.blue,d=c.red,x=c.yellow,[v,b]=o.useState(null),{trendData:w,totals:N}=o.useMemo(()=>{if(t.length===0)return{trendData:[],totals:{rxBytes:0,txBytes:0,rxAirtime:0,txAirtime:0}};const y=a-n,m=Math.min(Math.ceil(y/Ws),l),f=y/m,S=[];let E=0,W=0,g=0,_=0;for(const G of t){const j=G.timestamp;if(j<n||j>=a)continue;const M=et(G),A=ke(G,{spreadingFactor:i.sf,bandwidthHz:i.bw,codingRate:i.cr,preambleLength:i.preamble}),B={timestamp:j,rxAirtime:0,txAirtime:0,rxBytes:0,txBytes:0};G.transmitted?(B.txAirtime=A,B.txBytes=M,W+=M,_+=A):(B.rxAirtime=A,B.rxBytes=M,E+=M,g+=A),S.push(B)}S.sort((G,j)=>G.timestamp-j.timestamp);const U=new Float64Array(S.length+1),Q=new Float64Array(S.length+1),ee=new Float64Array(S.length+1),H=new Float64Array(S.length+1),R=new Float64Array(S.length);for(let G=0;G<S.length;G++)U[G+1]=U[G]+S[G].rxAirtime,Q[G+1]=Q[G]+S[G].txAirtime,ee[G+1]=ee[G]+S[G].rxBytes,H[G+1]=H[G]+S[G].txBytes,R[G]=S[G].timestamp;const K=G=>{let j=0,M=R.length;for(;j<M;){const A=j+M>>>1;R[A]<G?j=A+1:M=A}return j},te=[],ie=f*1e3;for(let G=0;G<m;G++){const j=n+G*f,M=j+f,A=K(j),B=K(M);if(s==="share"){const Z=ee[B]-ee[A],he=H[B]-H[A];te.push({timestamp:j,rx:Z>0?Z:null,tx:he>0?he:null})}else{const Z=U[B]-U[A],he=Q[B]-Q[A],fe=Z/ie*100,ge=he/ie*100;te.push({timestamp:j,rx:fe>0?fe:null,tx:ge>0?ge:null})}}const ae=2/31;let se=null;return{trendData:te.map(G=>{const j=G.rx;return j!==null&&j>0&&(se===null?se=j:se=ae*j+(1-ae)*se),{...G,rxSmooth:se!==null&&se>0?se:null}}),totals:{rxBytes:E,txBytes:W,rxAirtime:g,txAirtime:_}}},[t,n,a,l,s,i]),k=o.useMemo(()=>{if(w.length===0)return s==="share"?100:10;let y=0;for(const f of w){const S=f.rx??0,E=f.tx??0;S>y&&(y=S),E>y&&(y=E)}const m=y*1.1;return s==="share"?m<=100?100:m<=500?Math.ceil(m/100)*100:m<=1e3?Math.ceil(m/200)*200:m<=5e3?Math.ceil(m/500)*500:m<=1e4?Math.ceil(m/1e3)*1e3:Math.ceil(m/5e3)*5e3:Math.max(1,Math.ceil(m))},[w,s]),T=r??k,O=o.useMemo(()=>{if(v!==null&&w[v]){const y=w[v],m=y.rx??0,f=y.tx??0;return s==="share"?{rx:je(m),tx:je(f),total:je(m+f),isHovered:!0}:{rx:`${m.toFixed(2)}%`,tx:`${f.toFixed(2)}%`,total:`${(m+f).toFixed(2)}%`,isHovered:!0}}if(s==="share")return{rx:je(N.rxBytes),tx:je(N.txBytes),total:je(N.rxBytes+N.txBytes),isHovered:!1};{let y=0,m=0,f=0;for(const W of w)(W.rx!==null||W.tx!==null)&&(y+=W.rx??0,m+=W.tx??0,f++);const S=f>0?y/f:0,E=f>0?m/f:0;return{rx:`${S.toFixed(2)}%`,tx:`${E.toFixed(2)}%`,total:`${(S+E).toFixed(2)}%`,isHovered:!1}}},[v,w,N,s]),z=o.useMemo(()=>{const y=a-n,m=y/3600;return[0,.25,.5,.75,1].map(S=>{const E=n+y*S,W=new Date(E*1e3),g=W.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),_=W.toLocaleDateString([],{weekday:"short"}),U=S===.25||S===.75;return{pct:S,label:m>=24?`${_} ${g}`:g,mobileHidden:U}})},[n,a]),F=o.useCallback(y=>{b(y)},[]);if(w.length===0)return e.jsxs("div",{className:"h-full flex items-center justify-center text-fg-muted",children:[e.jsx(we,{className:"w-6 h-6 mr-2 opacity-50"}),e.jsx("span",{children:"No packet data available"})]});const V=o.useMemo(()=>s==="airtime"?T<=5?1:T<=10?2:T<=20?5:Math.ceil(T/5):T<=100?25:T<=500?100:T<=1e3?200:T<=5e3?1e3:T<=1e4?2e3:Math.ceil(T/5e3)*1e3,[T,s]),I=o.useMemo(()=>{const y=[];for(let m=0;m<=T;m+=V){const f=(1-m/T)*100;let S;s==="airtime"?S=`${m}%`:m>=1e6?S=`${(m/1e6).toFixed(1)}M`:m>=1e3?S=`${(m/1e3).toFixed(0)}K`:S=`${m}`,y.push({pos:f,label:S})}return y},[T,V,s]);return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0 flex flex-col justify-between",style:{width:Ge,bottom:Ve},children:I.map((y,m)=>e.jsx("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${y.pos}%`,transform:m===0?"translateY(-100%)":m===I.length-1?"none":"translateY(-50%)",right:0},children:y.label},m))}),e.jsx("div",{className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:Ge,right:0,top:0,bottom:Ve},children:e.jsx(Tt,{data:w,yAxisMode:s==="share"?"share":"airtime",yMax:T,onHover:F,startTs:n,endTs:a,externalAxes:!0})}),e.jsx("div",{className:"absolute left-0 right-0 bottom-0 flex items-center pointer-events-none",style:{left:Ge,height:Ve,paddingTop:4},children:z.map((y,m)=>e.jsx("span",{className:`absolute type-data-xs text-fg-muted/60 tabular-nums ${y.mobileHidden?"hidden sm:inline":""}`,style:{left:`${y.pct*100}%`,transform:y.pct===0?"translateX(0)":y.pct===1?"translateX(-100%)":"translateX(-50%)"},children:y.label},m))})]}),e.jsxs("div",{className:"flex items-end justify-between pb-1",style:{minHeight:u},children:[e.jsxs("div",{className:"flex items-center gap-3 sm:gap-5 type-data-sm pl-2 sm:pl-11",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-4 sm:w-5 h-[2px] rounded-full",style:{backgroundColor:p}}),e.jsx("span",{className:"text-fg-secondary",children:"RX"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-4 sm:w-5 h-[2px] rounded-full",style:{backgroundColor:d}}),e.jsx("span",{className:"text-fg-secondary",children:"TX"})]}),e.jsxs("div",{className:"hidden sm:flex items-center gap-1.5",children:[e.jsx("div",{className:"w-5 h-[2px] rounded-full",style:{backgroundColor:x}}),e.jsx("span",{className:"text-fg-secondary",children:"Avg"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-4 sm:gap-8",children:[e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("div",{className:"type-data-xl text-fg-primary",children:O.rx}),e.jsx(Ae,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"RX"})]}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("div",{className:"type-data-xl text-fg-primary",children:O.tx}),e.jsx(Ae,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"TX"})]})]})]})]})}const xt=Dt;class Gs{constructor(){pe(this,"worker",null);pe(this,"listeners",new Set);pe(this,"currentResult",null);pe(this,"isComputing",!1);pe(this,"debounceTimer",null);pe(this,"debounceMs",250);pe(this,"lastCacheKey",null)}ensureWorker(){if(this.worker)return this.worker;if(typeof window>"u")return null;try{this.worker=new Worker(new URL("/assets/bucketing.worker-D0TT0k8y.js",import.meta.url),{type:"module"}),this.worker.onmessage=s=>{this.handleWorkerMessage(s.data)},this.worker.onerror=s=>{console.error("[BucketingService] Worker error:",s),this.isComputing=!1,this.notifyListeners()}}catch(s){console.error("[BucketingService] Failed to initialize worker:",s)}return this.worker}handleWorkerMessage(s){if(this.isComputing=!1,s.type==="error"){this.currentResult=null,this.notifyListeners();return}const n=s.payload;this.currentResult={points:n.points,rawValues:n.rawValues,packetTypes:n.packetTypes,timestamps:n.timestamps,count:n.count,minTime:n.minTime,maxTime:n.maxTime,minValue:n.minValue,maxValue:n.maxValue,rawMinValue:n.rawMinValue,rawMaxValue:n.rawMaxValue,unit:"%",stats:{p5:n.p5,p50:n.p50,p95:n.p95,uniqueValues:n.uniqueValues,topValues:n.topValues}},this.notifyListeners()}notifyListeners(){for(const s of this.listeners)try{s(this.currentResult,this.isComputing)}catch(n){console.error("[BucketingService] Listener error:",n)}}isCacheHit(s){return!this.lastCacheKey||!this.currentResult?!1:this.lastCacheKey.startTs===s.startTs&&this.lastCacheKey.endTs===s.endTs&&this.lastCacheKey.mode===s.mode&&this.lastCacheKey.packetCount===s.packetCount}compute(s,n,a,i,l){if(s.length===0||!l){this.currentResult=null,this.notifyListeners();return}const r={startTs:n,endTs:a,mode:i,packetCount:s.length};this.isCacheHit(r)||(this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.computeInternal(s,n,a,i,l,r)},this.debounceMs))}computeInternal(s,n,a,i,l,r){const u=this.ensureWorker();if(!u)return;const c=s.length,p=new Float64Array(c),d=new Float64Array(c),x=new Uint16Array(c),v=new Uint8Array(c),b={spreadingFactor:l.sf,bandwidthHz:l.bw,codingRate:l.cr,preambleLength:l.preamble};for(let N=0;N<c;N++){const k=s[N];p[N]=k.timestamp??0,v[N]=(k.type??k.payload_type??255)&255,x[N]=Math.min(et(k),65535),i==="airtime"?d[N]=ke(k,b):d[N]=1}this.isComputing=!0,this.lastCacheKey=r,this.notifyListeners();const w={type:"compute",payload:{timestamps:p,airtimeMs:d,byteSizes:x,packetTypes:v,startTs:n,endTs:a,mode:i}};u.postMessage(w,[p.buffer,d.buffer,x.buffer,v.buffer])}getResult(){return this.currentResult}isWorking(){return this.isComputing}subscribe(s){return this.listeners.add(s),s(this.currentResult,this.isComputing),()=>{this.listeners.delete(s)}}clear(){this.currentResult=null,this.lastCacheKey=null,this.notifyListeners()}terminate(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.worker&&(this.worker.terminate(),this.worker=null),this.listeners.clear()}}const qe=new Gs;function Vs(t,s,n,a,i){const[l,r]=o.useState(()=>qe.getResult());return o.useEffect(()=>qe.subscribe(u=>{r(u)}),[]),o.useEffect(()=>{qe.compute(t,s,n,a,i)},[t,s,n,a,i]),l}function qs({mode:t,packets:s,startTs:n,endTs:a,radioConfig:i,sortedTypes:l,aggregateShares:r,noiseFloorAnomalies:u,showNoiseFloorOverlay:c,overlayOpacity:p=.5,startLabel:d,endLabel:x,lockedYMax:v,legendMinH:b,dotSize:w,dotOpacity:N}){const[k,T]=o.useState(null),[O,z]=o.useState(null),F=o.useMemo(()=>(a-n)/3600,[n,a]),V=o.useCallback(H=>{z(H)},[]),y=Vs(s,n,a,t==="share"?"share":"airtime",i),[m,f]=o.useState(null),S=o.useCallback((H,R)=>{T(H),f(R??null)},[]),E=o.useMemo(()=>{if(m===null||!y||y.count===0)return null;const H=n+m*(a-n);let R;F>=168?R=75:F>=72?R=35:F>=24?R=15:F>=3?R=10:R=5;const K=R*60/2;return{start:H-K,end:H+K}},[m,y,n,a,F]),W=o.useMemo(()=>E?new Date((E.start+E.end)/2*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}):null,[E]),g=o.useMemo(()=>{if(k===null||!E)return null;const H=W??"",{start:R,end:K}=E,te=s.filter(j=>j.timestamp>=R&&j.timestamp<K);if(te.length===0)return{timestamp:(R+K)/2,timeLabel:H,items:l.map(j=>({key:j.key,label:j.label,value:0,color:xt(j.typeNum)}))};const ie=new Map,ae=new Map;let se=0,ce=0;for(const j of te){const A=`TYPE_${j.type??j.payload_type??-1}`;if(ie.set(A,(ie.get(A)??0)+1),se++,i){const B=ke(j,{spreadingFactor:i.sf,bandwidthHz:i.bw,codingRate:i.cr,preambleLength:i.preamble});ae.set(A,(ae.get(A)??0)+B),ce+=B}}const G=l.map(j=>{let M;return t==="airtime"?M=ce>0?(ae.get(j.key)??0)/ce:0:M=se>0?(ie.get(j.key)??0)/se:0,{key:j.key,label:j.label,value:M,color:xt(j.typeNum)}});return{timestamp:(R+K)/2,timeLabel:H,items:G}},[k,E,W,s,l,t,i]),_=t==="share",U=v??(y==null?void 0:y.maxValue)??(_?240:10),Q=o.useMemo(()=>{if(!_)return 5;const H=[10,20,25,50,100,200,250,500,1e3],R=U/4.5;for(const K of H)if(K>=R)return K;return U>5e3?Math.ceil(R/1e3)*1e3:Math.ceil(R/100)*100},[U,_]),ee=o.useMemo(()=>{const H=[];for(let R=0;R<=U;R+=Q){const K=(1-R/U)*100;H.push({pos:K,label:_?`${R}B`:`${R}%`})}return H},[U,Q,_]);return!y||y.count===0?e.jsxs("div",{className:"h-full flex items-center justify-center text-fg-muted",children:[e.jsx(we,{className:"w-6 h-6 mr-2 opacity-50"}),e.jsx("span",{children:"No packet data available"})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0 flex flex-col justify-between",style:{width:32,bottom:20},children:ee.map((H,R)=>e.jsx("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${H.pos}%`,transform:R===0?"translateY(-100%)":R===ee.length-1?"none":"translateY(-50%)",right:0},children:H.label},R))}),e.jsxs("div",{className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:32,right:0,top:0,bottom:20},children:[e.jsx(Lt,{scatterData:y,yAxisMode:t==="share"?"share":"airtime",onHover:S,noiseFloorAnomalies:u,showNoiseFloorOverlay:c,overlayOpacity:p,highlightedType:O,timeRangeHours:F,yAxisMaxOverride:v,dotSize:w,dotOpacity:N,startTs:n,endTs:a,externalAxes:!0}),W&&e.jsx("div",{className:"absolute top-1 right-1 px-2 py-0.5 bg-elevated/90 rounded type-data-xs text-sys-indigo pointer-events-none z-10",children:W})]}),d&&x&&e.jsxs("div",{className:"absolute left-0 right-0 bottom-0 flex justify-between pointer-events-none type-data-xs text-fg-muted/60",style:{left:32,height:20,paddingTop:4},children:[e.jsx("span",{children:d}),e.jsx("span",{children:x})]})]}),e.jsx("div",{style:{minHeight:b},children:e.jsx(nt,{sortedTypes:l,highlightedType:O,onTypeHover:V,aggregateShares:r,hoverData:g})})]})}function Ks({mode:t,onChange:s}){return e.jsxs("div",{className:"toggle-group toggle-group-sm",children:[e.jsx("button",{onClick:()=>s("share"),className:`toggle-group-item ${t==="share"?"active":""}`,children:"Total"}),e.jsx("button",{onClick:()=>s("airtime"),className:`toggle-group-item ${t==="airtime"?"active":""}`,children:"Airtime"})]})}function Ys({smoothing:t,onChange:s}){return e.jsxs("div",{className:"toggle-group toggle-group-sm",children:[e.jsx("button",{onClick:()=>s("stats"),className:`toggle-group-item ${t==="stats"?"active":""}`,title:"Statistics view (scatter plot)",children:e.jsx(Ts,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>s("trend"),className:`toggle-group-item ${t==="trend"?"active":""}`,title:"Trend line chart",children:e.jsx(Ms,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>s("ema"),className:`toggle-group-item ${t==="ema"?"active":""}`,title:"Stacked area (moderate smoothing)",children:e.jsx(we,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>s("ultra"),className:`toggle-group-item ${t==="ultra"?"active":""}`,title:"Stacked area (heavy smoothing)",children:e.jsx(Et,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>s("mosaic"),className:`toggle-group-item ${t==="mosaic"?"active":""}`,title:"Mosaic view (treemap)",children:e.jsx(_s,{className:"w-3.5 h-3.5"})})]})}function Xs({enabled:t,onChange:s,anomalyCount:n=0,showTuning:a=!1,onTuningChange:i}){return e.jsxs("div",{className:"relative inline-flex items-center gap-1",children:[t&&i&&e.jsx("button",{onClick:()=>i(!a),className:`toggle-group toggle-group-sm ${a?"active":""}`,title:a?"Hide tuning panel":"Show tuning panel",children:e.jsx("span",{className:`toggle-group-item ${a?"active":""}`,children:e.jsx(ks,{className:"w-3.5 h-3.5"})})}),e.jsx("button",{onClick:()=>s(!t),className:`toggle-group toggle-group-sm ${t?"active":""}`,title:t?"Hide noise floor anomalies":"Show noise floor anomalies",children:e.jsx("span",{className:`toggle-group-item ${t?"active":""}`,children:e.jsx(fs,{className:"w-3.5 h-3.5"})})}),n>0&&e.jsx("span",{className:"absolute -top-2 -right-2 min-w-[18px] h-[18px] px-1 rounded-full bg-sys-red text-white text-xs font-bold flex items-center justify-center pointer-events-none z-10",children:n>99?"99+":n})]})}const wt=[{target:"PacketAnalyzer",fn:"type",minStage:1},{target:"PacketAnalyzer",fn:"airtime",minStage:1,when:os}];st(wt);const pt=360,Zs=500,Qs={sf:10,bw:25e4,cr:5,preamble:8},Ke=32;function ft(t,s){const n=new Date(t*1e3),a=r=>r.toString().padStart(2,"0"),i=`${a(n.getHours())}:${a(n.getMinutes())}`;return s<24?i:`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][n.getMonth()]} ${n.getDate()} ${i}`}function Js(t){return Nt[t]??`TYPE_${t.toString(16).toUpperCase()}`}function en(t,s){const n=new Map;for(const i of t){const l=i.type??i.payload_type??-1,r=ke(i,{spreadingFactor:s.sf,bandwidthHz:s.bw,codingRate:s.cr,preambleLength:s.preamble}),u=n.get(l)??{count:0,airtime:0};n.set(l,{count:u.count+1,airtime:u.airtime+r})}const a=[];for(const[i,l]of n)a.push({typeNum:i,key:`TYPE_${i}`,label:Js(i),totalCount:l.count,totalAirtime:l.airtime});return a.sort((i,l)=>l.totalCount-i.totalCount)}function tn(t,s,n,a,i,l,r=0){const u=n-s,c=u/a,p=c*1e3,d=u/3600,x=s-r*c,v=n+r*c,b=a+2*r,w=[];for(let N=0;N<b;N++){const k=x+N*c,T=new Date(k*1e3),O=d>=24?T.toLocaleDateString([],{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:!1}):T.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),z={timestamp:k,time:O,counts:{},shares:{},airtimes:{},total:0,totalAirtime:0,bucketDurationMs:p};for(const F of l)z.counts[F.key]=0,z.airtimes[F.key]=0;w.push(z)}for(const N of t){const k=N.timestamp;if(k<x||k>=v)continue;const T=Math.min(Math.floor((k-x)/c),b-1),O=`TYPE_${N.type??N.payload_type??-1}`;w[T].counts[O]=(w[T].counts[O]??0)+1,w[T].total++;const z=ke(N,{spreadingFactor:i.sf,bandwidthHz:i.bw,codingRate:i.cr,preambleLength:i.preamble});w[T].airtimes[O]=(w[T].airtimes[O]??0)+z,w[T].totalAirtime+=z}for(const N of w)for(const k of l)N.shares[k.key]=N.total>0?N.counts[k.key]/N.total*100:0;return{buckets:w,visibleStart:r,visibleEnd:r+a}}function sn(t,s){const n=t.length;if(n===0)return[];if(s<.5)return[...t];const a=Math.sqrt(12*s*s/3+1);let i=Math.floor(a);i%2===0&&i--;const l=i+2,r=(12*s*s-3*i*i-12*i-9)/(-4*i-4),u=Math.round(r),c=[u>0?i:l,u>1?i:l,u>2?i:l];let p=new Float32Array(t);const d=new Float32Array(n);for(const x of c){const v=(x-1)/2;nn(p,d,n,v);const b=p;p=d,d.set(b)}return Array.from(p)}function nn(t,s,n,a){const i=a*2+1;let l=0;for(let r=0;r<=a;r++)l+=t[Math.min(r,n-1)];for(let r=0;r<a;r++)l+=t[0];for(let r=0;r<n;r++){s[r]=l/i;const u=r-a,c=r+a+1;l-=t[Math.max(0,Math.min(u,n-1))],l+=t[Math.max(0,Math.min(c,n-1))]}}function an(t,s){if(t.length===0)return[];if(s<=1)return[...t];const n=t.length,a=new Float32Array(n),i=Math.floor(s/2);let l=0,r=0;for(let u=0;u<=Math.min(i,n-1);u++)l+=t[u],r++;for(let u=0;u<n;u++){a[u]=l/r;const c=u-i,p=u+i+1;c>=0&&(l-=t[c],r--),p<n&&(l+=t[p],r++)}return Array.from(a)}const rn={ema:1800,ultra:14400},ln={ema:"sma",ultra:"gaussian"};function St(t,s,n){const a=rn[t],i=ln[t]??"sma";if(!a)return{sigma:0,window:1,handleSize:0};let l=Math.round(a/s);l=Math.max(3,Math.min(l,Math.floor(n/3))),l%2===0&&(l+=1);const r=Math.ceil(i==="gaussian"?l*Math.sqrt(4/12)*3:l/2);return i==="gaussian"?{sigma:l*Math.sqrt(.3333333333333333),window:l,handleSize:r}:{sigma:0,window:l,handleSize:r}}function on(t,s,n,a="ultra",i,l,r){var V;const{buckets:u,visibleStart:c,visibleEnd:p}=t,d=u.length,x=n.length,v=p-c;if(d===0||x===0)return[];const b=r&&i!==void 0&&l!==void 0?(l-i)/r:(V=u[0])!=null&&V.bucketDurationMs?u[0].bucketDurationMs/1e3:240,w=Array.from({length:x},()=>new Array(d).fill(0));for(let I=0;I<d;I++){const y=u[I];if(s==="share"){if(y.total>0)for(let m=0;m<x;m++)w[m][I]=(y.counts[n[m].key]??0)/y.total}else{let m=0;for(let f=0;f<x;f++)m+=y.airtimes[n[f].key]??0;if(m>0)for(let f=0;f<x;f++)w[f][I]=(y.airtimes[n[f].key]??0)/m}}const{sigma:N,window:k}=St(a,b,v);let T;N>0?T=w.map(I=>sn(I,N)):T=w.map(I=>an(I,k));for(let I=0;I<d;I++){let y=0;for(let m=0;m<x;m++)T[m][I]=Math.max(0,T[m][I]),y+=T[m][I];if(y>0){const m=1/y;for(let f=0;f<x;f++)T[f][I]*=m}}const O=v>pt?Math.ceil(v/pt):1,z=Math.ceil(v/O),F=[];for(let I=0;I<z;I++){const y=c+I*O,m=Math.min(c+(I+1)*O,p),f=m-y,S=new Array(x).fill(0);for(let g=y;g<m;g++)for(let _=0;_<x;_++)S[_]+=T[_][g];for(let g=0;g<x;g++)S[g]/=f;let E=0;for(let g=0;g<x;g++)E+=S[g];if(E>0){const g=1/E;for(let _=0;_<x;_++)S[_]*=g}const W={timestamp:u[y].timestamp,time:u[y].time};for(let g=0;g<x;g++)W[n[g].key]=S[g];F.push(W)}return F}const Ye=80;function cn(t,s,n,a,i){const u=Math.max(1,Math.ceil((n-s)/300));if(a==="airtime"){const c=new Float64Array(u);for(const d of t){const x=d.timestamp;if(x<s||x>=n)continue;const v=Math.min(Math.floor((x-s)/300),u-1);c[v]+=ke(d,{spreadingFactor:i.sf,bandwidthHz:i.bw,codingRate:i.cr,preambleLength:i.preamble})}let p=0;for(let d=0;d<u;d++){const x=c[d]/3e5*100;x>p&&(p=x)}return Math.max(1,Math.ceil(p*1.1))}else{let c=0;for(const p of t){const d=p.timestamp;if(d<s||d>=n)continue;const x=et(p);x>c&&(c=x)}return c<=240?240:Math.ceil(c*1.1/50)*50}}function mn({packets:t,allPackets:s,startTs:n,endTs:a,parentStartTs:i,parentEndTs:l,bucketCount:r,radioConfig:u=Qs,mode:c="share",smoothing:p="stats",noiseFloorAnomalies:d=null,showNoiseFloorOverlay:x=!1,overlayOpacity:v=.5,dotSize:b,dotOpacity:w}){tt(wt);const N=It(),[k,T]=o.useState(null),[O,z]=o.useState(null),[F,V]=o.useState([]),I=o.useRef(null),y=o.useRef(0);o.useEffect(()=>{const j=Math.abs(t.length-y.current);if(j===0&&F.length>0)return;I.current&&clearTimeout(I.current);const M=j>100?50:Zs;return I.current=setTimeout(()=>{y.current=t.length,V(t)},M),()=>{I.current&&clearTimeout(I.current)}},[t,F.length]);const m=o.useMemo(()=>en(F,u),[F,u]),f=o.useMemo(()=>{if(p!=="ema"&&p!=="ultra")return 0;const M=(a-n)/r,{handleSize:A}=St(p,M,r);return A},[p,n,a,r]),S=o.useMemo(()=>tn(F,n,a,r,u,m,f),[F,n,a,r,u,m,f]),E=o.useMemo(()=>m.reduce((j,M)=>j+M.totalCount,0),[m]),W=o.useMemo(()=>m.reduce((j,M)=>j+M.totalAirtime,0),[m]),{sortedTypes:g,aggregateShares:_}=o.useMemo(()=>{const j=new Map,M=c==="share"?E:W;if(M>0)for(const B of m){const Z=c==="share"?B.totalCount:B.totalAirtime;j.set(B.key,Z/M)}return{sortedTypes:[...m].sort((B,Z)=>(j.get(Z.key)??0)-(j.get(B.key)??0)),aggregateShares:j}},[m,E,W,c]),U=o.useMemo(()=>on(S,c,g,p,n,a,r),[S,c,g,p,n,a,r]),Q=o.useCallback(j=>T(j),[]),ee=o.useCallback(j=>z(j),[]),H=o.useCallback(j=>T(j),[]),R=o.useMemo(()=>{if(O===null||!U[O])return null;const j=U[O];return{timestamp:j.timestamp,timeLabel:j.time,items:g.map(M=>({key:M.key,label:M.label,value:j[M.key]??0,color:Ce(M.typeNum)}))}},[O,U,g]),K=o.useMemo(()=>{const j=U.map(A=>A.timestamp),M=g.map(A=>({key:A.key,label:A.label,color:Ce(A.typeNum),values:U.map(B=>B[A.key]??0)}));return{timestamps:j,series:M}},[U,g]),te=null,ie=s&&i!==void 0&&l!==void 0&&(n!==i||a!==l),ae=o.useMemo(()=>{if(!(!ie||!s||i===void 0||l===void 0))return cn(s,i,l,c,u)},[ie,s,i,l,c,u]);if(F.length===0)return t.length===0?e.jsxs("div",{className:"h-full flex items-center justify-center text-fg-muted",children:[e.jsx(we,{className:"w-6 h-6 mr-2 opacity-50"}),e.jsx("span",{children:"No packet data available"})]}):null;if(p==="mosaic")return e.jsx(zs,{sortedTypes:g,aggregateShares:_,mode:c});const se=(a-n)/3600,ce=ft(n,se),G=ft(a,se);return p==="stats"?e.jsx(qs,{mode:c,packets:F,startTs:n,endTs:a,radioConfig:u,sortedTypes:g,aggregateShares:_,noiseFloorAnomalies:d,showNoiseFloorOverlay:x,overlayOpacity:v,startLabel:ce,endLabel:G,lockedYMax:ae,legendMinH:Ye,dotSize:b,dotOpacity:w}):p==="trend"?e.jsx(Us,{packets:F,mode:c,startTs:n,endTs:a,radioConfig:u,bucketCount:r,lockedYMax:ae,legendMinH:Ye}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("div",{className:"absolute top-0 left-0 flex flex-col justify-between",style:{width:Ke,bottom:20},children:[0,20,40,60,80,100].map((j,M,A)=>e.jsxs("span",{className:"type-data-xs text-fg-secondary text-right pr-1.5",style:{position:"absolute",top:`${(1-j/100)*100}%`,transform:M===0?"translateY(-100%)":M===A.length-1?"none":"translateY(-50%)",right:0},children:[j,"%"]},j))}),e.jsx("div",{className:"absolute overflow-hidden radius-inner depth-stroke-inset bg-chart-inner",style:{left:Ke,right:0,top:0,bottom:20},children:e.jsx(Pt,{timestamps:K.timestamps,series:K.series,highlightedKey:k,cursorColor:N.cursor,onHover:ee,onSeriesHover:H,overlayLine:te,startTs:n,endTs:a,externalAxes:!0})}),e.jsxs("div",{className:"absolute left-0 right-0 bottom-0 flex justify-between pointer-events-none type-data-xs text-fg-muted/60",style:{left:Ke,height:20,paddingTop:4},children:[e.jsx("span",{children:ce}),e.jsx("span",{children:G})]})]}),e.jsx("div",{style:{minHeight:Ye},children:e.jsx(nt,{sortedTypes:g,highlightedType:k,onTypeHover:Q,aggregateShares:_,hoverData:R})})]})}const dn=o.memo(mn),Xe={ZOOM_DURATION:400,BLINK_DURATION:600},le={PADDING:6,DOT_RADIUS:5,DOT_RADIUS_HOVERED:7,LOCAL_DOT_RADIUS:5,CARDINAL_FONT_SIZE:10,INTERCARDINAL_FONT_SIZE:9,LABEL_INSET:8,DATA_HEADROOM:1.08},un={"1x":1,"2x":2,"4x":4,"8x":8,"16x":16,"36x":36},gt=[1,5,10,25,50,100,150],hn=22.5,Mt=hn*Math.PI/180,bt=Math.sin(Mt),yt=Math.cos(Mt);function xn(t,s,n,a){const i=Math.PI/180,l=(a-s)*i,r=t*i,u=n*i,c=Math.sin(l)*Math.cos(u),p=Math.cos(r)*Math.sin(u)-Math.sin(r)*Math.cos(u)*Math.cos(l);return(Math.atan2(c,p)*180/Math.PI+360)%360}function pn(t,s,n,a){const l=Math.PI/180,r=(n-t)*l,u=(a-s)*l,c=Math.sin(r/2)**2+Math.cos(t*l)*Math.cos(n*l)*Math.sin(u/2)**2;return 6371*2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c))}const fn=[{min:10,label:"Excellent"},{min:7,label:"Very Good"},{min:4,label:"Good"},{min:1,label:"Fair+"},{min:-2,label:"Fair"},{min:-5,label:"Fair-"},{min:-8,label:"Poor"},{min:-11,label:"Bad"},{min:-1/0,label:"Critical"}];function gn(t){var s;return((s=fn.find(n=>t>=n.min))==null?void 0:s.label)??"Critical"}function jt(t,s,n){const a=zt(t,n);return s[a]||"#808080"}function bn({neighbors:t,quickNeighbors:s,localLat:n,localLon:a,onStatsChange:i,title:l,badge:r,stats:u}){const[c,p]=o.useState(null),[d,x]=o.useState(new Set),[v,b]=o.useState({width:0,height:0}),[w,N]=o.useState("1x"),[k,T]=o.useState(1),O=o.useRef(null),z=o.useRef({}),F=o.useRef(null),V=o.useRef(k);V.current=k;const I=Ot(),y=Ft(),m=Ht(),f=Bt(),S=vt(),E=$t(),W=f?m.primary:m.secondary,g=f?.15:.4,_=f?.08:.25,U=f?S.blue:m.primary;o.useEffect(()=>{const h=F.current;if(!h)return;const P=new ResizeObserver(L=>{for(const $ of L){const{width:Y,height:J}=$.contentRect;Y>0&&J>0&&b({width:Y,height:J})}});P.observe(h);const D=h.getBoundingClientRect();return D.width>0&&D.height>0&&b({width:D.width,height:D.height}),()=>P.disconnect()},[]);const Q=o.useMemo(()=>{const h=new Set;if(s)for(const P of s)h.add(P.hash);return h},[s]),ee=o.useMemo(()=>{const h=new Map;if(s)for(const P of s)h.set(P.hash,{snr:P.avgSnr,rssi:P.avgRssi});return h},[s]),{processedNeighbors:H,maxDistance:R,totalNeighbors:K,zeroHopCount:te}=o.useMemo(()=>{const h=[];for(const[L,$]of Object.entries(t)){if(!$.latitude||!$.longitude||$.latitude===0||$.longitude===0||!Q.has(L))continue;const J=xn(n,a,$.latitude,$.longitude),ne=pn(n,a,$.latitude,$.longitude),X=ee.get(L);h.push({hash:L.slice(0,8),name:$.node_name||$.name||"Unknown",snr:(X==null?void 0:X.snr)??$.snr??null,rssi:(X==null?void 0:X.rssi)??$.rssi??null,bearing:J,distance:ne,normalizedDistance:0,lastSeen:$.last_seen,isZeroHop:!0})}const D=(h.length>0?Math.max(...h.map(L=>L.distance)):0)*le.DATA_HEADROOM;return h.sort((L,$)=>(L.snr??-1/0)-($.snr??-1/0)),{processedNeighbors:h,maxDistance:D,totalNeighbors:h.length,zeroHopCount:h.length}},[t,n,a,Q,ee]);o.useEffect(()=>{i==null||i({zeroHopCount:te,totalCount:K,maxDistanceKm:R})},[te,K,R]),o.useEffect(()=>{const h=un[w],P=V.current;O.current&&cancelAnimationFrame(O.current);const D=performance.now(),L=$=>{const Y=$-D,J=Math.min(Y/Xe.ZOOM_DURATION,1),ne=cs(J),X=P+(h-P)*ne;T(X),J<1?O.current=requestAnimationFrame(L):O.current=null};return O.current=requestAnimationFrame(L),()=>{O.current&&cancelAnimationFrame(O.current)}},[w]);const ie=R/k,ae=o.useMemo(()=>gt.filter(h=>h<=ie*1.1),[ie]);o.useEffect(()=>{const h=[];for(const D of H){const L=z.current[D.hash];L!==void 0&&L!==D.lastSeen&&h.push(D.hash),z.current[D.hash]=D.lastSeen}if(h.length===0)return;queueMicrotask(()=>{x(D=>new Set([...D,...h]))});const P=setTimeout(()=>{x(D=>{const L=new Set(D);return h.forEach($=>L.delete($)),L})},Xe.BLINK_DURATION);return()=>clearTimeout(P)},[H]);const se=n!==0&&a!==0,ce=o.useMemo(()=>{const{width:h,height:P}=v,D=h/2,L=P/2,$=Math.min(h,P),Y=Math.max(10,$/2-le.PADDING),J=Math.max(10,Y-le.LABEL_INSET);return{width:h,height:P,centerX:D,centerY:L,radius:J,labelRadius:Y}},[v]),{width:G,height:j,centerX:M,centerY:A,radius:B,labelRadius:Z}=ce,he=o.useId(),fe=o.useCallback((h,P)=>{const D=h*Math.PI/180;return{x:M+B*P*Math.sin(D),y:A-B*P*Math.cos(D)}},[M,A,B]),ge=o.useCallback(h=>{const D={N:0,NE:45,E:90,SE:135,S:180,SW:225,W:270,NW:315}[h]*Math.PI/180;return{x:M+Z*Math.sin(D),y:A-Z*Math.cos(D)}},[M,A,Z]),_e=o.useCallback(h=>{p(h)},[]),Re=o.useCallback(h=>{N(h)},[]),Te=o.useCallback(h=>R<=0?0:h/R*k,[R,k]),De=h=>`${h}km`,Se=28,Le=o.useMemo(()=>{const h=[{x:M,y:A-Z},{x:M+Z*Math.SQRT1_2,y:A-Z*Math.SQRT1_2}],P=ae.map(L=>{const $=L/R*k,Y=M+B*$*bt,J=A-B*$*yt;return{km:L,scale:$,lx:Y,ly:J}}).filter(L=>L.scale>=.02).sort((L,$)=>$.km-L.km),D=[];for(const L of P){const $=D.some(J=>{const ne=J.lx-L.lx,X=J.ly-L.ly;return Math.sqrt(ne*ne+X*X)<Se}),Y=h.some(J=>{const ne=J.x-L.lx,X=J.y-L.ly;return Math.sqrt(ne*ne+X*X)<Se});!$&&!Y&&D.push(L)}return D},[ae,R,k,M,A,B,Z]),Ee=v.width>0&&v.height>0;return se?K===0?e.jsxs("div",{ref:F,className:"flex flex-col items-center justify-center h-full text-fg-secondary",children:[e.jsx(We,{className:"w-8 h-8 mb-2 opacity-50"}),e.jsx("p",{children:"No nodes with location data"})]}):e.jsxs("div",{className:"flex h-full w-full overflow-visible",children:[e.jsxs("div",{ref:F,className:"relative flex-1 min-w-0 h-full overflow-visible -ml-4 sm:-ml-5",children:[Ee&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute depth-stroke-inset",style:{left:M-B-le.LABEL_INSET-4,top:A-B-le.LABEL_INSET-4,width:(B+le.LABEL_INSET)*2+8,height:(B+le.LABEL_INSET)*2+8,borderRadius:"50%",padding:4,boxSizing:"border-box",backgroundColor:f?"var(--zinc-925)":"var(--zinc-75)"}}),e.jsxs("svg",{width:G,height:j,className:"absolute inset-0 z-0",style:{overflow:"visible"},children:[e.jsxs("defs",{children:[e.jsx("style",{children:`
                @keyframes neighbor-blink-scale {
                  0%, 100% {
                    transform: scale(1);
                    opacity: 0;
                  }
                  50% {
                    transform: scale(1.3);
                    opacity: 0.8;
                  }
                }
                .neighbor-blink-ring {
                  transform-origin: center;
                  animation: neighbor-blink-scale ${Xe.BLINK_DURATION}ms ease-out forwards;
                }
              `}),e.jsx("clipPath",{id:he,children:e.jsx("circle",{cx:M,cy:A,r:B})})]}),(()=>{const h=B+le.LABEL_INSET+12,P=f?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.15)",D=f?"rgba(59, 130, 246, 0.4)":"rgba(59, 130, 246, 0.5)",L=6,$=16,Y=4,J=[0,90,180,270],ne=[45,135,225,315];return e.jsxs("g",{className:"radar-frame","aria-hidden":"true",children:[e.jsx("circle",{cx:M,cy:A,r:h,fill:"none",stroke:P,strokeWidth:1,strokeDasharray:"2 6"}),ne.map(X=>{const re=X*Math.PI/180,me=Math.cos(re),de=Math.sin(re),xe=h+Y,C=h+Y+$,q=M+xe*de,be=A-xe*me,Ie=M+C*de,Be=A-C*me;return e.jsxs("g",{children:[e.jsx("line",{x1:q,y1:be,x2:Ie,y2:Be,stroke:D,strokeWidth:1}),e.jsx("line",{x1:Ie-4*me,y1:Be-4*de,x2:Ie+4*me,y2:Be+4*de,stroke:D,strokeWidth:1})]},`corner-${X}`)}),J.map(X=>{const re=X*Math.PI/180,me=M+(h-L)*Math.sin(re),de=A-(h-L)*Math.cos(re),xe=M+(h+2)*Math.sin(re),C=A-(h+2)*Math.cos(re);return e.jsx("line",{x1:me,y1:de,x2:xe,y2:C,stroke:P,strokeWidth:1},`tick-cardinal-${X}`)}),ne.map(X=>{const re=X*Math.PI/180,me=M+(h-4)*Math.sin(re),de=A-(h-4)*Math.cos(re),xe=M+(h+1)*Math.sin(re),C=A-(h+1)*Math.cos(re);return e.jsx("line",{x1:me,y1:de,x2:xe,y2:C,stroke:P,strokeWidth:1},`tick-intercardinal-${X}`)})]})})(),(()=>{const h=B+le.LABEL_INSET+4,P=[0,...gt.map(D=>{const L=Te(D);return L<=0?0:Math.min(B*L,h)}),h];return P.slice(0,-1).map((D,L)=>{const $=P[L+1],Y=$-D;return Y<.5||L%2!==0?null:e.jsx("circle",{cx:M,cy:A,r:($+D)/2,fill:"none",stroke:"var(--subtle-fill)",strokeWidth:Y},`band-${L}`)})})(),ae.map(h=>{const P=Te(h);if(P<.02)return null;const D=Le.some(Y=>Y.km===h),L=M+B*P*bt,$=A-B*P*yt;return e.jsx("g",{children:D&&e.jsx("text",{x:L+4,y:$-2,textAnchor:"start",dominantBaseline:"auto",fill:m.secondary,fontSize:10,fontFamily:$e,children:De(h)})},`ring-${h}`)}),["N","E","S","W"].map(h=>{const D={N:0,E:90,S:180,W:270}[h]*Math.PI/180;return e.jsx("line",{x1:M,y1:A,x2:M+B*Math.sin(D),y2:A-B*Math.cos(D),stroke:W,strokeOpacity:g,strokeWidth:1,strokeDasharray:"4 4"},h)}),["NE","SE","SW","NW"].map(h=>{const D={NE:45,SE:135,SW:225,NW:315}[h]*Math.PI/180;return e.jsx("line",{x1:M,y1:A,x2:M+B*Math.sin(D),y2:A-B*Math.cos(D),stroke:W,strokeOpacity:_,strokeWidth:1,strokeDasharray:"4 4"},`diag-${h}`)}),["N","E","S","W"].map(h=>{const P=ge(h),D=h==="E"?"end":h==="W"?"start":"middle",L=h==="N"?"hanging":h==="S"?"auto":"middle";return e.jsx("text",{x:P.x,y:P.y,textAnchor:D,dominantBaseline:L,fill:U,fontSize:le.CARDINAL_FONT_SIZE,fontWeight:700,fontFamily:$e,"aria-hidden":"true",children:h},h)}),["NE","SE","SW","NW"].map(h=>{const P=ge(h),D=h==="NE"||h==="SE"?"end":"start",L=h==="NE"||h==="NW"?"hanging":"auto";return e.jsx("text",{x:P.x,y:P.y,textAnchor:D,dominantBaseline:L,fill:U,fontSize:le.INTERCARDINAL_FONT_SIZE,fontWeight:600,fontFamily:$e,"aria-hidden":"true",children:h},h)}),e.jsx("circle",{cx:M,cy:A,r:le.LOCAL_DOT_RADIUS,fill:y.chart6,stroke:f?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.2)",strokeWidth:1,role:"img","aria-label":"Local node"}),e.jsx("g",{clipPath:`url(#${he})`,children:H.map(h=>{const P=R>0?h.distance/R*k:0;if(P>1)return null;const{x:D,y:L}=fe(h.bearing,P),$=h.snr!==null?jt(h.snr,I,E):"#808080",Y=(c==null?void 0:c.hash)===h.hash,J=d.has(h.hash),ne=le.DOT_RADIUS_HOVERED*1.5;return e.jsxs("g",{role:"img","aria-label":`${h.name}: ${h.distance.toFixed(1)}km ${h.bearing.toFixed(0)}°`,children:[J&&e.jsx("circle",{cx:D,cy:L,r:ne,fill:"none",stroke:f?"rgba(255,255,255,0.9)":"rgba(0,0,0,0.7)",strokeWidth:2,className:"neighbor-blink-ring"}),Y&&e.jsx("circle",{cx:D,cy:L,r:ne,fill:$,opacity:.3}),e.jsx("circle",{cx:D,cy:L,r:Y?le.DOT_RADIUS_HOVERED:le.DOT_RADIUS,fill:$,stroke:f?"rgba(0,0,0,0.5)":"rgba(0,0,0,0.25)",strokeWidth:1,style:{cursor:"pointer",transition:"r 0.15s"},onMouseEnter:()=>_e(h),onMouseLeave:()=>_e(null)})]},h.hash)})})]})]}),c&&e.jsxs("div",{className:"absolute bg-tooltip-bg border border-edge-subtle rounded-lg px-3 py-2 text-sm pointer-events-none z-10 shadow-xl",style:{left:"50%",bottom:8,transform:"translateX(-50%)"},children:[e.jsx("div",{className:"font-medium text-fg-primary",children:c.name}),e.jsx("div",{className:"type-data-xs text-fg-secondary",children:c.hash}),c.snr!==null?e.jsx("div",{className:"flex gap-3 mt-1 text-xs",children:e.jsxs("span",{children:[e.jsx("span",{className:"text-fg-secondary",children:"SNR:"})," ",e.jsxs("span",{className:"tabular-nums",style:{color:jt(c.snr,I,E)},children:[c.snr.toFixed(1)," dB"]}),e.jsxs("span",{className:"text-fg-secondary ml-1",children:["(",gn(c.snr),")"]})]})}):e.jsx("div",{className:"text-xs text-fg-secondary mt-1",children:"No SNR data"}),e.jsxs("div",{className:"flex gap-3 text-xs",children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-fg-secondary",children:"Distance:"})," ",e.jsxs("span",{className:"tabular-nums text-fg-primary",children:[c.distance.toFixed(2)," km"]})]}),e.jsxs("span",{children:[e.jsx("span",{className:"text-fg-secondary",children:"Bearing:"})," ",e.jsxs("span",{className:"tabular-nums text-fg-primary",children:[c.bearing.toFixed(0),"°"]})]})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 px-1.5 pt-4 sm:pt-5 pb-2 flex-shrink-0 depth-raised radius-inset self-stretch",style:{width:"calc(100% / 6)"},children:[l&&e.jsxs("div",{className:"flex flex-col items-start gap-1 pb-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"icon-md flex items-center justify-center text-icon-card-title",children:e.jsx(We,{className:"w-3.5 h-3.5"})}),r&&e.jsx(Ae,{color:"zinc",children:r})]}),e.jsx("span",{className:"type-micro text-left text-[10px] leading-tight px-1",children:l})]}),e.jsx("div",{className:"flex flex-col gap-1 flex-1",role:"group","aria-label":"Zoom level",children:["1x","2x","4x","8x","16x","36x"].map(h=>e.jsx("button",{onClick:()=>Re(h),"aria-pressed":w===h,className:`flex flex-1 items-center justify-center min-w-[44px] sm:min-w-[32px] text-xs font-medium radius-inner depth-stroke-raised transition-colors ${w===h?"bg-sys-blue/20 text-sys-blue":"bg-subtle-fill/80 text-fg-secondary hover:bg-subtle-fill-strong hover:text-fg-primary"}`,children:h},h))})]})]}):e.jsxs("div",{ref:F,className:"flex flex-col items-center justify-center h-full text-fg-secondary",children:[e.jsx(We,{className:"w-8 h-8 mb-2 opacity-50"}),e.jsx("p",{children:"Local node coordinates not configured"}),e.jsx("p",{className:"text-xs mt-1",children:"Set latitude/longitude in config to enable"})]})}const yn=o.memo(bn),Ze={repeater:"var(--sys-blue)",companion:"var(--sys-cyan)",room_server:"var(--sys-indigo)"};function jn(t){if(t.contact_type){const s=t.contact_type.toLowerCase();if(s==="repeater"||s==="rep")return"repeater";if(s==="room server"||s==="room_server"||s==="room"||s==="server")return"room_server";if(s==="companion"||s==="client"||s==="cli")return"companion"}return t.is_repeater?"repeater":"companion"}function Nn({neighbors:t,timeRangeLabel:s}){const n=o.useMemo(()=>{const a={repeater:0,companion:0,room_server:0};for(const r of Object.values(t)){const u=jn(r);a[u]=(a[u]||0)+1}const i=Object.values(a).reduce((r,u)=>r+u,0);return{items:[{label:"Repeaters",count:a.repeater,percent:0,color:Ze.repeater},{label:"Companions",count:a.companion,percent:0,color:Ze.companion},{label:"Room Servers",count:a.room_server,percent:0,color:Ze.room_server}].map(r=>({...r,percent:i>0?r.count/i*100:0})).filter(r=>r.count>0).sort((r,u)=>u.count-r.count),total:i}},[t]);return n.total===0?e.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted type-body-sm",children:"No neighbors discovered yet"}):e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"flex-1 flex flex-col justify-evenly",children:n.items.map(a=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-sm text-fg-secondary",children:a.label}),e.jsxs("span",{className:"type-data-sm text-fg-secondary tabular-nums",children:[a.count," ",e.jsxs("span",{className:"text-fg-secondary/60",children:["(",a.percent.toFixed(0),"%)"]})]})]}),e.jsx("div",{className:"h-2.5 bg-subtle-fill/80 overflow-hidden rounded-full depth-stroke-inset",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-500 ease-out",style:{width:`${a.percent}%`,backgroundColor:a.color,minWidth:a.count>0?"4px":"0"}})})]},a.label))}),e.jsxs("div",{className:"mt-auto pt-2",children:[e.jsxs("div",{className:"data-box-label flex items-center gap-1.5",children:["Total Nodes",s&&e.jsx(Ae,{color:"zinc",children:s})]}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:n.total})]})]})}const vn=o.memo(Nn);function Qe({children:t,minHeight:s="100%",rootMargin:n="200px 0px",keepMounted:a=!0,className:i=""}){const l=o.useRef(null),[r,u]=o.useState(!1),[c,p]=o.useState(!1);o.useEffect(()=>{const x=l.current;if(!x)return;const v=new IntersectionObserver(([b])=>{const w=b.isIntersecting;p(w),w&&u(!0)},{rootMargin:n,threshold:0});return v.observe(x),()=>{v.disconnect()}},[n]);const d=c||a&&r;return e.jsx("div",{ref:l,className:`h-full w-full ${i}`,style:{minHeight:s},children:d?t:e.jsx("div",{className:"h-full w-full flex items-center justify-center text-fg-muted/50",children:e.jsx("div",{className:"animate-pulse text-xs",children:"Loading chart..."})})})}const Ct=[{target:"DisambiguationCard",fn:"disambiguation.collisions",minStage:2}];st(Ct);const kn=.9,wn=.7,Sn=.5,Mn=10,Cn=25,Fe={excellent:"text-signal-excellent",good:"text-signal-good",fair:"text-signal-fair",poor:"text-sys-blue"},An={excellent:"bg-signal-excellent/10",good:"bg-signal-good/10",fair:"bg-signal-fair/10",poor:"bg-sys-blue/10"};function _n(t){return t>=kn?"excellent":t>=wn?"good":t>=Sn?"fair":"poor"}function Rn(t){return t<=Mn?"excellent":t<=Cn?"good":"poor"}function Tn(){tt(Ct);const t=Wt(),s=Ut(),[n,a]=o.useState(null),i=o.useCallback((d,x)=>{a({prefix:d,candidateHashes:x})},[]),l=o.useCallback(()=>{a(null)},[]);if(!s)return e.jsxs(ue,{neomorphic:!0,children:[e.jsx(ve,{icon:e.jsx(rt,{}),title:"Prefix Conflicts"}),e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-fg-secondary",children:[e.jsx(Gt,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"type-data-xs",children:"No topology data available"}),e.jsx("p",{className:"type-data-xs opacity-70",children:"Run deep analysis to see stats"})]})})]});const r=_n(t.avgConfidence),u=Rn(t.collisionRate),c=r==="poor"||u==="poor"?"poor":r==="fair"||u==="fair"?"fair":r==="good"||u==="good"?"good":"excellent",p=c==="excellent"||c==="good"?ot:lt;return e.jsxs(ue,{neomorphic:!0,className:"flex flex-col overflow-hidden",children:[e.jsx(ve,{icon:e.jsx(rt,{}),title:"Prefix Conflicts",badgeColor:"zinc",actions:c==="poor"?e.jsxs(Ae,{color:"red",children:[e.jsx(lt,{className:"w-3 h-3"}),"Needs Attention"]}):e.jsxs("div",{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full ${An[c]}`,children:[e.jsx(p,{className:`w-3.5 h-3.5 ${Fe[c]}`}),e.jsx("span",{className:`type-data-xs font-medium ${Fe[c]}`,children:c==="excellent"?"Excellent":c==="good"?"Good":"Fair"})]})}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"flex gap-2 sm:gap-3",children:[e.jsxs("div",{className:"flex-1 flex flex-col radius-inner depth-stroke-inset px-3 py-2.5 sm:py-3 cursor-help",title:"Total unique 2-character prefixes observed in packet paths.",children:[e.jsx("span",{className:"type-data-xl text-fg-primary",children:e.jsx(Ue,{value:t.totalPrefixes,priority:"low"})}),e.jsx("span",{className:"type-micro text-fg-muted mt-0.5 sm:mt-1",children:"Prefixes"})]}),e.jsxs("div",{className:"flex-1 flex flex-col radius-inner depth-stroke-inset px-3 py-2.5 sm:py-3 cursor-help",title:"Prefixes that map to exactly one known node. No disambiguation needed.",children:[e.jsx("span",{className:"type-data-xl text-fg-primary",children:e.jsx(Ue,{value:t.unambiguousPrefixes,priority:"low"})}),e.jsx("span",{className:"type-micro text-fg-muted mt-0.5 sm:mt-1",children:"Unique"})]}),e.jsxs("div",{className:"flex-1 flex flex-col radius-inner depth-stroke-inset px-3 py-2.5 sm:py-3 cursor-help",title:"Prefixes matching multiple known nodes. Click a prefix below to explore candidates.",children:[e.jsx("span",{className:`type-data-xl ${t.collisionPrefixes>0?"text-sys-blue":"text-fg-primary"}`,children:e.jsx(Ue,{value:t.collisionPrefixes,priority:"low"})}),e.jsx("span",{className:`type-micro mt-0.5 sm:mt-1 ${t.collisionPrefixes>0?"text-sys-blue":"text-fg-muted"}`,children:"Conflicts"})]})]}),t.highCollisionPrefixes.length>0&&e.jsxs("div",{className:"pt-3",children:[e.jsx("div",{className:"data-box-label",children:"Problem Prefixes"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 content-start",children:t.highCollisionPrefixes.map(({prefix:d,candidateCount:x,candidateHashes:v})=>e.jsxs("button",{type:"button",onClick:()=>i(d,v),className:"inline-flex items-center gap-0.5 group",title:`${x} candidates - click to explore`,children:[e.jsx(ps,{children:d}),e.jsxs("span",{className:"text-fg-muted type-data-xs group-hover:text-fg-secondary transition-colors",children:["×",x]})]},d))})]}),t.lowConfidencePrefixes.length===0&&t.collisionPrefixes===0&&e.jsx("div",{className:"flex-1 flex items-center",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ot,{className:"w-3.5 h-3.5 text-signal-excellent"}),e.jsx("span",{className:"type-data-xs text-signal-excellent",children:"All prefixes uniquely identified"})]})}),e.jsxs("div",{className:"flex gap-2 sm:gap-3 mt-auto pt-3",children:[e.jsxs("div",{className:"flex-1 min-w-0 cursor-help",title:"Average confidence score across all disambiguated prefixes. Higher = more certain node identification.",children:[e.jsx("div",{className:"data-box-label",children:"Confidence"}),e.jsxs("div",{className:`data-box data-box-fill data-box-left ${Fe[r]}`,children:[(t.avgConfidence*100).toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex-1 min-w-0 cursor-help",title:"Percentage of 2-character prefixes that match multiple known nodes. Lower is better.",children:[e.jsx("div",{className:"data-box-label",children:"Collisions"}),e.jsxs("div",{className:`data-box data-box-fill data-box-left ${Fe[u]}`,children:[t.collisionRate.toFixed(1),"%"]})]})]})]}),e.jsx(gs,{isOpen:!!n,prefix:(n==null?void 0:n.prefix)||"",candidateHashes:(n==null?void 0:n.candidateHashes)||[],onClose:l})]})}const At=[{target:"PacketHealth",fn:"type",minStage:1},{target:"PacketHealth",fn:"duplicates",minStage:1}];st(At);const oe=24;function Dn(t,s,n,a){const i=Date.now()/1e3,l=s*60,r=i-l,u=l/oe,c=new Array(oe).fill(0),p=new Array(oe).fill(0),d=new Array(oe).fill(0),x=new Array(oe).fill(0),v=new Array(oe).fill(0),b=new Array(oe).fill(0);let w=0,N=0,k=0,T=0,O=0,z=0,F=0;if(a&&a.length>0)for(const g of a){const _=g.timestamp;if(_<r||_>i)continue;F++;const U=Math.min(oe-1,Math.floor((_-r)/u));U>=0&&v[U]++}else if(n!=null&&n>0){F=n;const g=n/oe;for(let _=0;_<oe;_++)v[_]=g}for(const g of t){if(g.packet_origin==="tx_local")continue;const _=g.timestamp;if(_<r||_>i)continue;w++;const U=Math.min(oe-1,Math.floor((_-r)/u));p[U]++,g.transmitted||g.packet_origin==="tx_forward"?(N++,c[U]++):g.is_duplicate||g.drop_reason==="Duplicate"?k++:g.drop_reason&&(T++,b[U]++),Yt(g.route??g.route_type)&&(O++,d[U]++),g._packetVersion===1&&(z++,x[U]++)}const V=F,I=w+V,y=[],m=[],f=[],S=[],E=[];for(let g=0;g<oe;g++){const _=p[g],U=c[g],Q=v[g],ee=b[g],H=(r+g*u)*1e3,R=_+Q;y.push({count:R>0?U/R*100:0,timestamp:H}),m.push({count:R>0?(ee+Q)/R*100:0,timestamp:H}),f.push({count:R>0?Q/R*100:0,timestamp:H}),S.push({count:_>0?d[g]/_*100:0,timestamp:H}),E.push({count:_>0?x[g]/_*100:0,timestamp:H})}const W=w-k;return{totalRx:w,uniqueRx:W,forwarded:N,duplicates:k,waste:T,efficiency:I>0?N/I*100:0,duplicateRate:I>0?k/I*100:0,wasteRate:I>0?(T+V)/I*100:0,sparkline:y,wasteSparkline:m,crcSparkline:f,transport:O,v2:z,transportSparkline:S,v2Sparkline:E}}function Ln({packets:t,rangeMinutes:s,rangeHours:n,timeRangeLabel:a,isLoaded:i=!0}){tt(At);const[l,r]=o.useState(null),[u,c]=o.useState(null),p=o.useCallback(async()=>{try{const v=await Vt(n);if(v.success&&v.data){r(v.data.count??v.data.history.length),c(v.data.history);return}const b=await qt(n);b.success&&b.data&&(r(b.data.count),c(null))}catch{}},[n]);o.useEffect(()=>{p()},[p]);const d=o.useMemo(()=>Dn(t,s,l,u),[t,s,l,u]),x=d.totalRx>0;return e.jsx(ue,{neomorphic:!0,isLoaded:i,skeletonType:"chart",children:i&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{icon:e.jsx(bs,{}),title:"Packet Health",badge:a,badgeColor:"zinc"}),e.jsx(Kt,{children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex gap-2 sm:gap-3 mb-2",children:[e.jsxs("div",{className:"flex-1 min-w-0 radius-inner depth-stroke-inset p-2 flex flex-col h-full cursor-help",title:"Total useless traffic: Software drops (e.g. empty, crypto) + Hardware CRC errors. Excludes duplicates.",children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("div",{className:"data-box-label",children:"Discarded"}),e.jsx("div",{className:"data-box data-box-compact shrink-0 text-sys-indigo",children:x?`${d.wasteRate.toFixed(1)}%`:"—"})]}),e.jsx("div",{className:"flex-1 min-h-[20px] max-h-[28px] w-full",children:e.jsx(Oe,{data:d.wasteSparkline,width:9999,height:24,className:"w-full",color:"var(--sys-indigo)",invertScale:!0})})]}),e.jsxs("div",{className:"flex-1 min-w-0 radius-inner depth-stroke-inset p-2 flex flex-col h-full cursor-help",title:"Packets lost at the radio hardware level due to corruption or interference.",children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("div",{className:"data-box-label flex items-center gap-1",children:"CRC Errors"}),e.jsx("div",{className:"data-box data-box-compact shrink-0 text-status-warning",children:l!==null?l:"—"})]}),e.jsx("div",{className:"flex-1 min-h-[20px] max-h-[28px] w-full",children:e.jsx(Oe,{data:d.crcSparkline,width:9999,height:24,className:"w-full",color:"var(--status-warning)",invertScale:!0})})]})]}),e.jsxs("div",{className:"flex gap-2 sm:gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0 radius-inner depth-stroke-inset p-2 flex flex-col h-full cursor-help",title:"Packets with Transport headers (reliable messaging)",children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("div",{className:"data-box-label",children:"Transport"}),e.jsx("div",{className:"data-box data-box-compact shrink-0 text-sys-amber",children:x?e.jsxs(e.Fragment,{children:[e.jsx(Pe,{children:d.transport}),e.jsx("span",{className:"punc-slash",children:"/"}),e.jsx(Pe,{children:d.uniqueRx})]}):"—"})]}),e.jsx("div",{className:"flex-1 min-h-[20px] max-h-[28px] w-full",children:e.jsx(Oe,{data:d.transportSparkline,width:9999,height:24,className:"w-full",color:"var(--sys-amber)"})})]}),e.jsxs("div",{className:"flex-1 min-w-0 radius-inner depth-stroke-inset p-2 flex flex-col h-full cursor-help",title:"Packets using V2 protocol format",children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("div",{className:"data-box-label",children:"V2"}),e.jsx("div",{className:"data-box data-box-compact shrink-0 text-sys-teal",children:x?e.jsxs(e.Fragment,{children:[e.jsx(Pe,{children:d.v2}),e.jsx("span",{className:"punc-slash",children:"/"}),e.jsx(Pe,{children:d.uniqueRx})]}):"—"})]}),e.jsx("div",{className:"flex-1 min-h-[20px] max-h-[28px] w-full",children:e.jsx(Oe,{data:d.v2Sparkline,width:9999,height:24,className:"w-full",color:"var(--sys-teal)"})})]})]}),e.jsxs("div",{className:"flex gap-2 sm:gap-3 mt-auto",children:[e.jsxs("div",{className:"flex-1 min-w-0 cursor-help",title:"Redundant packets dropped because they were already received",children:[e.jsx("div",{className:"data-box-label",children:"Dupes"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:x?`${d.duplicateRate.toFixed(1)}%`:"—"})]}),e.jsxs("div",{className:"flex-1 min-w-0 cursor-help",title:"Packets successfully retransmitted to extend the mesh",children:[e.jsx("div",{className:"data-box-label",children:"Forwarded"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:x?`${d.efficiency.toFixed(1)}%`:"—"})]})]})]})})]})})}function oa(){var De,Se,Le,Ee,h,P,D,L,$,Y,J,ne,X,re,me,de,xe;const t=Xt(),s=Zt(),n=Qt(),a=Jt(),i=es(),l=ts(),r=t!==null&&i,u=o.useRef(!1);r&&!u.current&&(u.current=!0);const c=u.current,p=ss(),d=ns(),x=as(),[v,b]=o.useState(null),[,w]=o.useState(null),[N]=o.useState(null),[k,T]=o.useState(()=>{const C=localStorage.getItem("statistics-view-mode");return C==="share"||C==="airtime"?C:"airtime"});o.useEffect(()=>{localStorage.setItem("statistics-view-mode",k)},[k]);const[O,z]=o.useState(()=>{const C=localStorage.getItem("statistics-smoothing-mode");return["ema","ultra","mosaic","stats","trend"].includes(C)?C:"stats"});o.useEffect(()=>{localStorage.setItem("statistics-smoothing-mode",O)},[O]);const[F,V]=o.useState(!1),[I,y]=o.useState(!1),[m,f]=o.useState(kt),[S,E]=o.useState(.5),[W,g]=o.useState(ys),[_,U]=o.useState(.5),[Q,ee]=o.useState(85),H=o.useMemo(()=>({0:0,1:0,2:1,3:2,4:3,5:4,6:5,7:6,8:7,9:8,10:9})[p]??3,[p]),R=ze[H].hours,K=R*60,te=ze[H],ie=it(R),ae=l.isBackgroundLoading,se=o.useCallback(C=>{const be={0:1,1:2,2:3,3:4,4:5,5:6,6:7,7:8,8:9,9:10}[C]??4;d(be)},[d]),ce=o.useMemo(()=>{var q;if(!((q=t==null?void 0:t.config)!=null&&q.radio))return null;const C=t.config.radio;return{sf:C.spreading_factor??10,bw:C.bandwidth??25e4,cr:C.coding_rate??5,preamble:C.preamble_length??8}},[(Se=(De=t==null?void 0:t.config)==null?void 0:De.radio)==null?void 0:Se.spreading_factor,(Ee=(Le=t==null?void 0:t.config)==null?void 0:Le.radio)==null?void 0:Ee.bandwidth,(P=(h=t==null?void 0:t.config)==null?void 0:h.radio)==null?void 0:P.coding_rate,(L=(D=t==null?void 0:t.config)==null?void 0:D.radio)==null?void 0:L.preamble_length]),G=o.useMemo(()=>x.length===0?{timestamps:[],values:[]}:{timestamps:x.map(C=>C.timestamp),values:x.map(C=>C.noise_floor_dbm)},[x]),j=o.useMemo(()=>{if(x.length<10)return{anomalies:[],debug:void 0};const C=Ds(x,m);return{anomalies:C.anomalies,debug:C.debug}},[x,m]),M=j.anomalies,A=o.useMemo(()=>{const C=(t==null?void 0:t.neighbors)??{};return Object.fromEntries(Object.entries(C).filter(([q])=>!s.has(q)))},[t==null?void 0:t.neighbors,s]),B=o.useMemo(()=>{const C=Date.now()/1e3-R*3600;return Object.fromEntries(Object.entries(A).filter(([,q])=>q.last_seen>=C))},[A,R]),Z=o.useMemo(()=>{const C=K*60/ie,q=Math.floor(Date.now()/1e3),be=Math.floor(q/C)*C;return{start:be-K*60,end:be}},[K,ie]),he=W.timeStart??Z.start,fe=W.timeEnd??Z.end,ge=(fe-he)/3600,_e=it(ge),Re=vs(),Te=o.useMemo(()=>js(a,W,Re,Z),[a,W,Re,Z]);return e.jsxs(us,{children:[e.jsx(hs,{title:"Statistics",icon:e.jsx(is,{}),subtitle:e.jsx(ds,{}),controls:e.jsx(ms,{ranges:ze,selectedIndex:H,onSelect:se,isPending:ae})}),N&&e.jsx(ue,{className:"border border-sys-red/50 bg-sys-red/10",children:e.jsx("p",{className:"text-sys-red",children:N})}),F&&I&&e.jsxs(ue,{className:"border border-sys-indigo/30 bg-surface/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"type-label",children:"Anomaly Detection Tuning"}),e.jsxs("span",{className:"type-data-xs text-fg-muted",children:["(",te.label,")"]})]}),e.jsx("button",{onClick:()=>f(C=>({...C,useAbsoluteThresholds:!C.useAbsoluteThresholds})),className:`type-data-xs px-2 py-1 rounded transition-colors ${m.useAbsoluteThresholds?"bg-sys-indigo/30 text-sys-indigo":"bg-elevated text-fg-muted hover:text-fg-secondary"}`,children:m.useAbsoluteThresholds?"Absolute dBm":"Percentile"})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"type-micro",children:"Baseline"}),e.jsxs("span",{className:"ml-2 type-data-sm text-status-warning",children:[((Y=($=j.debug)==null?void 0:$.baselineCutoff)==null?void 0:Y.toFixed(1))??"—"," dBm"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"type-micro",children:"Spike"}),e.jsxs("span",{className:"ml-2 type-data-sm text-status-warning",children:[((ne=(J=j.debug)==null?void 0:J.spikeCutoff)==null?void 0:ne.toFixed(1))??"—"," dBm"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"type-micro",children:"Mid-band"}),e.jsx("span",{className:"ml-2 type-data-sm text-sys-indigo",children:((X=j.debug)==null?void 0:X.midBandSamples)??0})]}),e.jsxs("div",{children:[e.jsx("span",{className:"type-micro",children:"Anomalies"}),e.jsx("span",{className:"ml-2 type-data-sm text-status-danger",children:M.length})]})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-edge-subtle space-y-4",children:[m.useAbsoluteThresholds?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Baseline (",m.baselineDbm," dBm)"]}),e.jsx("input",{type:"range",min:"-120",max:"-60",value:m.baselineDbm,onChange:C=>f(q=>({...q,baselineDbm:Number(C.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Spike (",m.spikeDbm," dBm)"]}),e.jsx("input",{type:"range",min:"-100",max:"-20",value:m.spikeDbm,onChange:C=>f(q=>({...q,spikeDbm:Number(C.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",m.mergeGapSeconds,"s)"]}),e.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:m.mergeGapSeconds,onChange:C=>f(q=>({...q,mergeGapSeconds:Number(C.target.value)})),className:"w-full accent-sys-indigo"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Min Sequence (",m.minSequenceLength,")"]}),e.jsx("input",{type:"range",min:"2",max:"20",value:m.minSequenceLength,onChange:C=>f(q=>({...q,minSequenceLength:Number(C.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",m.similarityToleranceDbm," dBm)"]}),e.jsx("input",{type:"range",min:"1",max:"15",value:m.similarityToleranceDbm,onChange:C=>f(q=>({...q,similarityToleranceDbm:Number(C.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(S*100),"%)"]}),e.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:S,onChange:C=>E(Number(C.target.value)),className:"w-full accent-sys-indigo"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Baseline (P",m.baselinePercentile,")"]}),e.jsx("input",{type:"range",min:"1",max:"50",value:m.baselinePercentile,onChange:C=>f(q=>({...q,baselinePercentile:Number(C.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Spike (P",m.spikePercentile,")"]}),e.jsx("input",{type:"range",min:"50",max:"99",value:m.spikePercentile,onChange:C=>f(q=>({...q,spikePercentile:Number(C.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",m.mergeGapSeconds,"s)"]}),e.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:m.mergeGapSeconds,onChange:C=>f(q=>({...q,mergeGapSeconds:Number(C.target.value)})),className:"w-full accent-sys-indigo"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Min Sequence (",m.minSequenceLength,")"]}),e.jsx("input",{type:"range",min:"2",max:"20",value:m.minSequenceLength,onChange:C=>f(q=>({...q,minSequenceLength:Number(C.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",m.similarityToleranceDbm," dBm)"]}),e.jsx("input",{type:"range",min:"1",max:"15",value:m.similarityToleranceDbm,onChange:C=>f(q=>({...q,similarityToleranceDbm:Number(C.target.value)})),className:"w-full accent-sys-indigo"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(S*100),"%)"]}),e.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:S,onChange:C=>E(Number(C.target.value)),className:"w-full accent-sys-indigo"})]})]})]}),e.jsxs("div",{className:"mt-4 p-3 bg-elevated radius-inner",children:[e.jsx("div",{className:"type-micro mb-1",children:"Config output"}),e.jsxs("div",{className:"type-data-sm text-status-success",children:[m.useAbsoluteThresholds?`useAbsoluteThresholds: true, baselineDbm: ${m.baselineDbm}, spikeDbm: ${m.spikeDbm}`:`useAbsoluteThresholds: false, baselinePercentile: ${m.baselinePercentile}, spikePercentile: ${m.spikePercentile}`,", mergeGapSeconds: ",m.mergeGapSeconds,", minSequenceLength: ",m.minSequenceLength,", similarityToleranceDbm: ",m.similarityToleranceDbm]})]})]})]}),e.jsxs(xs,{ready:c,children:[e.jsx("div",{className:"sm:hidden",children:ae&&e.jsx(ye,{template:"auto",children:e.jsx(ue,{className:"border border-sys-blue/30 bg-sys-blue/5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex h-3 w-3",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-sys-blue opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-3 w-3 bg-sys-blue"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"type-body-sm text-fg-primary",children:["Loading ",te.label," data..."]}),l.loadProgress&&e.jsxs("p",{className:"type-data-xs text-fg-muted mt-0.5",children:[l.loadProgress.loaded.toLocaleString()," packets (",l.loadProgress.percent,"%)"]})]})]})})})}),e.jsxs(e.Fragment,{children:[e.jsx(ye,{template:"hero-auto",children:e.jsx(ue,{neomorphic:!0,skeletonType:"chart",children:c&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{icon:e.jsx(we,{}),title:"Packet Analyzer",badge:te.label,badgeColor:"zinc",stackActionsOnMobile:!0,actions:e.jsxs("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:[O==="stats"&&e.jsx(Xs,{enabled:F,onChange:V,anomalyCount:M.length,showTuning:I,onTuningChange:y}),e.jsx(Ys,{smoothing:O,onChange:z}),e.jsx(Ks,{mode:k,onChange:T})]})}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(dn,{packets:Te,allPackets:a,startTs:he,endTs:fe,parentStartTs:Z.start,parentEndTs:Z.end,bucketCount:_e,radioConfig:ce??void 0,mode:k,smoothing:O,noiseFloorAnomalies:M,showNoiseFloorOverlay:F,overlayOpacity:S,dotSize:_,dotOpacity:Q/100})})]})})}),e.jsx(ye,{template:"auto",className:"relative z-10",children:e.jsx(ue,{neomorphic:!0,noPadding:!0,className:"overflow-visible",children:c&&e.jsx(Ns,{parentStartTs:Z.start,parentEndTs:Z.end,neighbors:A,filter:W,onChange:g,...O==="stats"?{scatterDotSize:_,onScatterDotSizeChange:U,scatterOpacity:Q,onScatterOpacityChange:ee}:{}})})}),e.jsxs(ye,{template:"panel",children:[e.jsx(Me,{span:12,md:6,children:e.jsx(ue,{neomorphic:!1,skeletonType:"chart",noPadding:c,className:"!bg-transparent !ring-0 !shadow-none !overflow-visible -mx-4 sm:mx-0 !px-0 !pr-0",children:c&&e.jsx(Qe,{children:e.jsx(yn,{neighbors:B,quickNeighbors:n,localLat:((me=(re=t==null?void 0:t.config)==null?void 0:re.repeater)==null?void 0:me.latitude)??0,localLon:((xe=(de=t==null?void 0:t.config)==null?void 0:de.repeater)==null?void 0:xe.longitude)??0,onStatsChange:w,title:"Link Quality",badge:te.label})})})}),e.jsx(Me,{span:12,md:6,children:e.jsx(ue,{neomorphic:!0,skeletonType:"chart",children:c&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{icon:e.jsx(ws,{}),title:"Network Composition",badge:te.label,badgeColor:"zinc"}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Qe,{children:e.jsx(vn,{neighbors:B,timeRangeLabel:te.label})})})]})})})]}),e.jsxs(ye,{template:"panel",children:[e.jsx(Me,{span:12,md:6,children:e.jsx(Tn,{})}),e.jsx(Me,{span:12,md:6,children:e.jsx(Ln,{packets:a,rangeMinutes:K,rangeHours:R,timeRangeLabel:te.label})})]}),e.jsx(ye,{template:"panel",children:e.jsx(Me,{span:12,children:e.jsx(ue,{neomorphic:!0,skeletonType:"chart",children:c&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{icon:e.jsx(rs,{}),title:"NOISE FLOOR dBm",stackActionsOnMobile:!0,actions:v?e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsxs("span",{className:"type-data-xs text-fg-muted whitespace-nowrap",children:["min ",e.jsx("span",{className:"data-box",children:v.min.toFixed(0)})]}),e.jsxs("span",{className:"type-data-xs text-fg-muted whitespace-nowrap",children:["avg ",e.jsx("span",{className:"data-box",children:v.avg.toFixed(0)})]}),e.jsxs("span",{className:"type-data-xs text-fg-muted whitespace-nowrap",children:["max ",e.jsx("span",{className:"data-box",children:v.max.toFixed(0)})]})]}):null}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Qe,{children:e.jsx(ls,{timestamps:G.timestamps,values:G.values,onStatsChange:b})})})]})})})})]})]})]})}export{oa as default};
